Exemplo n.º 1
0
 static void labelAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
   INC_STATS("DOM.HTMLOptGroupElement.label._set");
   HTMLOptGroupElement* imp = V8HTMLOptGroupElement::toNative(info.Holder());
   V8Parameter<WithNullCheck> v = value;
   imp->setLabel(v);
   return;
 }
Exemplo n.º 2
0
 static void disabledAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
   INC_STATS("DOM.HTMLOptGroupElement.disabled._set");
   HTMLOptGroupElement* imp = V8HTMLOptGroupElement::toNative(info.Holder());
   bool v = value->BooleanValue();
   imp->setDisabled(v);
   return;
 }
static v8::Handle<v8::Value> disabledAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.HTMLOptGroupElement.disabled._get");
    HTMLOptGroupElement* imp = V8HTMLOptGroupElement::toNative(info.Holder());
	if (!R_check(imp)) return v8::Handle<v8::Value>(v8::Undefined());
    return v8Boolean(imp->hasAttribute(WebCore::HTMLNames::disabledAttr));
}
Exemplo n.º 4
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 JSHTMLOptGroupElement::putValueProperty(ExecState* exec, int token, JSValue* value)
{
    switch (token) {
    case DisabledAttrNum: {
        HTMLOptGroupElement* imp = static_cast<HTMLOptGroupElement*>(impl());
        imp->setDisabled(value->toBoolean(exec));
        break;
    }
    case LabelAttrNum: {
        HTMLOptGroupElement* imp = static_cast<HTMLOptGroupElement*>(impl());
        imp->setLabel(valueToStringWithNullCheck(exec, value));
        break;
    }
    }
}
JSValue* JSHTMLOptGroupElement::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case DisabledAttrNum: {
        HTMLOptGroupElement* imp = static_cast<HTMLOptGroupElement*>(impl());
        return jsBoolean(imp->disabled());
    }
    case LabelAttrNum: {
        HTMLOptGroupElement* imp = static_cast<HTMLOptGroupElement*>(impl());
        return jsString(exec, imp->label());
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}
Exemplo n.º 7
0
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);
}
Exemplo n.º 9
0
HTMLOptGroupElement* HTMLOptGroupElement::create(Document& document) {
  HTMLOptGroupElement* optGroupElement = new HTMLOptGroupElement(document);
  optGroupElement->ensureUserAgentShadowRoot();
  return optGroupElement;
}
Exemplo n.º 10
0
 static v8::Handle<v8::Value> labelAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) {
   INC_STATS("DOM.HTMLOptGroupElement.label._get");
   HTMLOptGroupElement* imp = V8HTMLOptGroupElement::toNative(info.Holder());
   return v8String(imp->label());
 }
Exemplo n.º 11
0
 static v8::Handle<v8::Value> disabledAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) {
   INC_STATS("DOM.HTMLOptGroupElement.disabled._get");
   HTMLOptGroupElement* imp = V8HTMLOptGroupElement::toNative(info.Holder());
   return v8Boolean(imp->disabled());
 }
Exemplo n.º 12
0
void DeprecatedRenderSelect::updateFromElement()
{
    m_ignoreSelectEvents = true;

    // change widget type
    bool oldMultiple = m_multiple;
    m_multiple = static_cast<HTMLSelectElement*>(node())->multiple();

    if (oldMultiple != m_multiple) {
        static_cast<ListBox*>(m_widget)->setSelectionMode(m_multiple ? ListBox::Extended : ListBox::Single);
        m_selectionChanged = true;
        m_optionsChanged = true;
    }

    // update contents listbox/combobox based on options in m_element
    if (m_optionsChanged) {
        static_cast<HTMLSelectElement*>(node())->recalcListItems();
        const Vector<HTMLElement*>& listItems = static_cast<HTMLSelectElement*>(node())->listItems();
        int listIndex;

        static_cast<ListBox*>(m_widget)->clear();
        
        bool groupEnabled = true;
        for (listIndex = 0; listIndex < int(listItems.size()); listIndex++) {
            if (listItems[listIndex]->hasTagName(optgroupTag)) {
                HTMLOptGroupElement* optgroupElement = static_cast<HTMLOptGroupElement*>(listItems[listIndex]);
                DeprecatedString label = optgroupElement->getAttribute(labelAttr).deprecatedString();
                label.replace('\\', backslashAsCurrencySymbol());
                
                // In WinIE, an optgroup can't start or end with whitespace (other than the indent
                // we give it).  We match this behavior.
                label = label.stripWhiteSpace();
                // We want to collapse our whitespace too.  This will match other browsers.
                label = label.simplifyWhiteSpace();

                groupEnabled = optgroupElement->isEnabled();
                
                static_cast<ListBox*>(m_widget)->appendGroupLabel(label, groupEnabled);

            } else if (listItems[listIndex]->hasTagName(optionTag)) {
                HTMLOptionElement* optionElement = static_cast<HTMLOptionElement*>(listItems[listIndex]);
                DeprecatedString itemText = optionElement->text().deprecatedString();
                if (itemText.isEmpty())
                    itemText = optionElement->getAttribute(labelAttr).deprecatedString();
                
                itemText.replace('\\', backslashAsCurrencySymbol());

                // In WinIE, leading and trailing whitespace is ignored in options. We match this behavior.
                itemText = itemText.stripWhiteSpace();
                // We want to collapse our whitespace too.  This will match other browsers.
                itemText = itemText.simplifyWhiteSpace();
                
                if (listItems[listIndex]->parentNode()->hasTagName(optgroupTag))
                    itemText.prepend("    ");

                static_cast<ListBox*>(m_widget)->appendItem(itemText, groupEnabled && optionElement->isEnabled());
            } else
                ASSERT(false);
            m_selectionChanged = true;
        }
        static_cast<ListBox*>(m_widget)->doneAppendingItems();
        setNeedsLayoutAndMinMaxRecalc();
        m_optionsChanged = false;
    }

    // update selection
    if (m_selectionChanged)
        updateSelection();

    m_ignoreSelectEvents = false;

    RenderFormElement::updateFromElement();
}
void setJSHTMLOptGroupElementLabel(ExecState* exec, JSObject* thisObject, JSValue value)
{
    HTMLOptGroupElement* imp = static_cast<HTMLOptGroupElement*>(static_cast<JSHTMLOptGroupElement*>(thisObject)->impl());
    imp->setLabel(valueToStringWithNullCheck(exec, value));
}
void setJSHTMLOptGroupElementDisabled(ExecState* exec, JSObject* thisObject, JSValue value)
{
    HTMLOptGroupElement* imp = static_cast<HTMLOptGroupElement*>(static_cast<JSHTMLOptGroupElement*>(thisObject)->impl());
    imp->setDisabled(value.toBoolean(exec));
}