Exemple #1
0
void PopupMenuImpl::addOptGroup(ItemIterationContext& context,
                                HTMLOptGroupElement& element) {
  SharedBuffer* data = context.m_buffer;
  PagePopupClient::addString("{\n", data);
  PagePopupClient::addString("type: \"optgroup\",\n", data);
  addProperty("label", element.groupLabelText(), data);
  addProperty("title", element.title(), data);
  addProperty("ariaLabel", element.fastGetAttribute(HTMLNames::aria_labelAttr),
              data);
  addProperty("disabled", element.isDisabledFormControl(), data);
  addElementStyle(context, element);
  context.startGroupChildren(*m_ownerElement->itemComputedStyle(element));
  // We should call ItemIterationContext::finishGroupIfNecessary() later.
}
void PopupMenuImpl::addOptGroup(HTMLOptGroupElement& element, bool enableExtraStyling, SharedBuffer* data)
{
    PagePopupClient::addString("{\n", data);
    PagePopupClient::addString("type: \"optgroup\",\n", data);
    addProperty("label", element.groupLabelText(), data);
    addProperty("title", element.title(), data);
    addProperty("ariaLabel", element.fastGetAttribute(HTMLNames::aria_labelAttr), data);
    addProperty("disabled", element.isDisabledFormControl(), data);
    addElementStyle(element, enableExtraStyling, data);
    PagePopupClient::addString("children: [", data);
    for (HTMLElement& child : Traversal<HTMLElement>::childrenOf(element)) {
        if (isHTMLOptionElement(child))
            addOption(toHTMLOptionElement(child), enableExtraStyling, data);
        if (isHTMLOptGroupElement(child))
            addOptGroup(toHTMLOptGroupElement(child), enableExtraStyling, data);
        if (isHTMLHRElement(child))
            addSeparator(toHTMLHRElement(child), enableExtraStyling, data);
    }
    PagePopupClient::addString("],\n", data);
    PagePopupClient::addString("},\n", data);
}
void PopupMenuImpl::addOptGroup(ItemIterationContext& context, HTMLOptGroupElement& element)
{
    SharedBuffer* data = context.m_buffer;
    ++context.m_listIndex;
    PagePopupClient::addString("{\n", data);
    PagePopupClient::addString("type: \"optgroup\",\n", data);
    addProperty("label", element.groupLabelText(), data);
    addProperty("title", element.title(), data);
    addProperty("ariaLabel", element.fastGetAttribute(HTMLNames::aria_labelAttr), data);
    addProperty("disabled", element.isDisabledFormControl(), data);
    addElementStyle(context, element);
    PagePopupClient::addString("children: [", data);
    for (HTMLElement& child : Traversal<HTMLElement>::childrenOf(element)) {
        if (isHTMLOptionElement(child))
            addOption(context, toHTMLOptionElement(child));
        // TODO(tkent): Ignore nested OPTGROUP. crbug.com/502101.
        if (isHTMLOptGroupElement(child))
            addOptGroup(context, toHTMLOptGroupElement(child));
        if (isHTMLHRElement(child))
            addSeparator(context, toHTMLHRElement(child));
    }
    PagePopupClient::addString("],\n", data);
    PagePopupClient::addString("},\n", data);
}