Example #1
0
Vector<WebPopupItem> WebPopupMenu::populateItems()
{
    size_t size = m_popupClient->listSize();

    Vector<WebPopupItem> items;
    items.reserveInitialCapacity(size);
    
    for (size_t i = 0; i < size; ++i) {
        if (m_popupClient->itemIsSeparator(i))
            items.append(WebPopupItem(WebPopupItem::Seperator));
        else {
            // FIXME: Add support for styling the font.
            // FIXME: Add support for styling the foreground and background colors.
            // FIXME: Find a way to customize text color when an item is highlighted.
            items.append(WebPopupItem(WebPopupItem::Item, m_popupClient->itemText(i), m_popupClient->itemToolTip(i), m_popupClient->itemAccessibilityText(i), m_popupClient->itemIsEnabled(i), m_popupClient->itemIsLabel(i)));
        }
    }

    return items;
}
bool WebPopupItem::decode(CoreIPC::ArgumentDecoder* decoder, WebPopupItem& item)
{
    uint32_t type;
    String text;
    uint64_t textDirection;
    bool hasTextDirectionOverride;
    String toolTip;
    String accessibilityText;
    bool isEnabled;
    bool isLabel;
    if (!decoder->decode(CoreIPC::Out(type, text, textDirection, hasTextDirectionOverride, toolTip, accessibilityText, isEnabled, isLabel)))
        return false;

    item = WebPopupItem(static_cast<Type>(type), text, static_cast<TextDirection>(textDirection), hasTextDirectionOverride, toolTip, accessibilityText, isEnabled, isLabel);
    return true;
}
bool WebPopupItem::decode(IPC::Decoder& decoder, WebPopupItem& item)
{
    Type type;
    if (!decoder.decodeEnum(type))
        return false;

    String text;
    if (!decoder.decode(text))
        return false;
    
    TextDirection textDirection;
    if (!decoder.decodeEnum(textDirection))
        return false;

    bool hasTextDirectionOverride;
    if (!decoder.decode(hasTextDirectionOverride))
        return false;

    String toolTip;
    if (!decoder.decode(toolTip))
        return false;

    String accessibilityText;
    if (!decoder.decode(accessibilityText))
        return false;

    bool isEnabled;
    if (!decoder.decode(isEnabled))
        return false;

    bool isLabel;
    if (!decoder.decode(isLabel))
        return false;

    bool isSelected;
    if (!decoder.decode(isSelected))
        return false;

    item = WebPopupItem(type, text, textDirection, hasTextDirectionOverride, toolTip, accessibilityText, isEnabled, isLabel, isSelected);
    return true;
}