| Index: Source/core/html/HTMLOptionElement.cpp
|
| diff --git a/Source/core/html/HTMLOptionElement.cpp b/Source/core/html/HTMLOptionElement.cpp
|
| index 79239f43d70034107d2d61f13d3d2e29703a3344..675631777597bb7ff7a01104b105030b391bd25f 100644
|
| --- a/Source/core/html/HTMLOptionElement.cpp
|
| +++ b/Source/core/html/HTMLOptionElement.cpp
|
| @@ -34,7 +34,9 @@
|
| #include "core/dom/NodeTraversal.h"
|
| #include "core/dom/ScriptLoader.h"
|
| #include "core/dom/Text.h"
|
| +#include "core/dom/shadow/ShadowRoot.h"
|
| #include "core/html/HTMLDataListElement.h"
|
| +#include "core/html/HTMLOptGroupElement.h"
|
| #include "core/html/HTMLSelectElement.h"
|
| #include "core/html/parser/HTMLParserIdioms.h"
|
| #include "core/rendering/RenderTheme.h"
|
| @@ -56,13 +58,16 @@ HTMLOptionElement::HTMLOptionElement(Document& document)
|
|
|
| PassRefPtrWillBeRawPtr<HTMLOptionElement> HTMLOptionElement::create(Document& document)
|
| {
|
| - return adoptRefWillBeNoop(new HTMLOptionElement(document));
|
| + RefPtrWillBeRawPtr<HTMLOptionElement> option = adoptRefWillBeNoop(new HTMLOptionElement(document));
|
| + option->ensureUserAgentShadowRoot();
|
| + return option.release();
|
| }
|
|
|
| PassRefPtrWillBeRawPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstructor(Document& document, const String& data, const AtomicString& value,
|
| bool defaultSelected, bool selected, ExceptionState& exceptionState)
|
| {
|
| RefPtrWillBeRawPtr<HTMLOptionElement> element = adoptRefWillBeNoop(new HTMLOptionElement(document));
|
| + element->ensureUserAgentShadowRoot();
|
| element->appendChild(Text::create(document, data.isNull() ? "" : data), exceptionState);
|
| if (exceptionState.hadException())
|
| return nullptr;
|
| @@ -95,12 +100,6 @@ void HTMLOptionElement::detach(const AttachContext& context)
|
| HTMLElement::detach(context);
|
| }
|
|
|
| -bool HTMLOptionElement::rendererIsFocusable() const
|
| -{
|
| - // Option elements do not have a renderer so we check the renderStyle instead.
|
| - return renderStyle() && renderStyle()->display() != NONE;
|
| -}
|
| -
|
| String HTMLOptionElement::text() const
|
| {
|
| Document& document = this->document();
|
| @@ -188,6 +187,8 @@ void HTMLOptionElement::parseAttribute(const QualifiedName& name, const AtomicSt
|
| } else if (name == selectedAttr) {
|
| if (bool willBeSelected = !value.isNull())
|
| setSelected(willBeSelected);
|
| + } else if (name == labelAttr) {
|
| + updateLabel();
|
| } else
|
| HTMLElement::parseAttribute(name, value);
|
| }
|
| @@ -251,6 +252,7 @@ void HTMLOptionElement::childrenChanged(bool changedByParser, Node* beforeChange
|
| dataList->optionElementChildrenChanged();
|
| else if (HTMLSelectElement* select = ownerSelectElement())
|
| select->optionElementChildrenChanged();
|
| + updateLabel();
|
| HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
|
| }
|
|
|
| @@ -279,12 +281,9 @@ void HTMLOptionElement::setLabel(const AtomicString& label)
|
|
|
| void HTMLOptionElement::updateNonRenderStyle()
|
| {
|
| - bool oldDisplayNoneStatus = isDisplayNone();
|
| m_style = originalStyleForRenderer();
|
| - if (oldDisplayNoneStatus != isDisplayNone()) {
|
| - if (HTMLSelectElement* select = ownerSelectElement())
|
| - select->updateListOnRenderer();
|
| - }
|
| + if (HTMLSelectElement* select = ownerSelectElement())
|
| + select->updateListOnRenderer();
|
| }
|
|
|
| RenderStyle* HTMLOptionElement::nonRendererStyle() const
|
| @@ -343,6 +342,14 @@ Node::InsertionNotificationRequest HTMLOptionElement::insertedInto(ContainerNode
|
| return HTMLElement::insertedInto(insertionPoint);
|
| }
|
|
|
| +void HTMLOptionElement::removedFrom(ContainerNode* insertionPoint)
|
| +{
|
| + HTMLSelectElement* select = Traversal<HTMLSelectElement>::firstAncestorOrSelf(*insertionPoint);
|
| + if (select)
|
| + return select->optionRemoved(this);
|
| + HTMLElement::removedFrom(insertionPoint);
|
| +}
|
| +
|
| String HTMLOptionElement::collectOptionInnerText() const
|
| {
|
| StringBuilder text;
|
| @@ -366,16 +373,17 @@ HTMLFormElement* HTMLOptionElement::form() const
|
| return 0;
|
| }
|
|
|
| -bool HTMLOptionElement::isDisplayNone() const
|
| +void HTMLOptionElement::didAddUserAgentShadowRoot(ShadowRoot& root)
|
| {
|
| - ContainerNode* parent = parentNode();
|
| - // Check for parent optgroup having display NONE
|
| - if (parent && isHTMLOptGroupElement(*parent)) {
|
| - if (toHTMLOptGroupElement(*parent).isDisplayNone())
|
| - return true;
|
| - }
|
| - RenderStyle* style = nonRendererStyle();
|
| - return style && style->display() == NONE;
|
| + updateLabel();
|
| +}
|
| +
|
| +void HTMLOptionElement::updateLabel()
|
| +{
|
| + ShadowRoot* root = userAgentShadowRoot();
|
| + if (!root)
|
| + return;
|
| + root->setTextContent(textIndentedToRespectGroupLabel());
|
| }
|
|
|
| } // namespace WebCore
|
|
|