Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights |
| 6 * reserved. | 6 * reserved. |
| 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 HTMLElement::parseAttribute(params); | 68 HTMLElement::parseAttribute(params); |
| 69 | 69 |
| 70 if (params.name == disabledAttr) { | 70 if (params.name == disabledAttr) { |
| 71 pseudoStateChanged(CSSSelector::PseudoDisabled); | 71 pseudoStateChanged(CSSSelector::PseudoDisabled); |
| 72 pseudoStateChanged(CSSSelector::PseudoEnabled); | 72 pseudoStateChanged(CSSSelector::PseudoEnabled); |
| 73 } else if (params.name == labelAttr) { | 73 } else if (params.name == labelAttr) { |
| 74 updateGroupLabel(); | 74 updateGroupLabel(); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 void HTMLOptGroupElement::attachLayoutTree(const AttachContext& context) { | |
| 79 if (context.resolvedStyle) { | |
| 80 DCHECK(!m_style || m_style == context.resolvedStyle); | |
| 81 m_style = context.resolvedStyle; | |
| 82 } | |
| 83 HTMLElement::attachLayoutTree(context); | |
| 84 } | |
| 85 | |
| 86 void HTMLOptGroupElement::detachLayoutTree(const AttachContext& context) { | |
| 87 m_style.clear(); | |
| 88 HTMLElement::detachLayoutTree(context); | |
| 89 } | |
| 90 | |
| 91 bool HTMLOptGroupElement::supportsFocus() const { | 78 bool HTMLOptGroupElement::supportsFocus() const { |
| 92 HTMLSelectElement* select = ownerSelectElement(); | 79 HTMLSelectElement* select = ownerSelectElement(); |
| 93 if (select && select->usesMenuList()) | 80 if (select && select->usesMenuList()) |
| 94 return false; | 81 return false; |
| 95 return HTMLElement::supportsFocus(); | 82 return HTMLElement::supportsFocus(); |
| 96 } | 83 } |
| 97 | 84 |
| 98 bool HTMLOptGroupElement::matchesEnabledPseudoClass() const { | 85 bool HTMLOptGroupElement::matchesEnabledPseudoClass() const { |
| 99 return !isDisabledFormControl(); | 86 return !isDisabledFormControl(); |
| 100 } | 87 } |
| 101 | 88 |
| 102 Node::InsertionNotificationRequest HTMLOptGroupElement::insertedInto( | 89 Node::InsertionNotificationRequest HTMLOptGroupElement::insertedInto( |
| 103 ContainerNode* insertionPoint) { | 90 ContainerNode* insertionPoint) { |
| 104 HTMLElement::insertedInto(insertionPoint); | 91 HTMLElement::insertedInto(insertionPoint); |
| 105 if (HTMLSelectElement* select = ownerSelectElement()) { | 92 if (HTMLSelectElement* select = ownerSelectElement()) { |
| 106 if (insertionPoint == select) | 93 if (insertionPoint == select) |
| 107 select->optGroupInsertedOrRemoved(*this); | 94 select->optGroupInsertedOrRemoved(*this); |
| 108 } | 95 } |
| 109 return InsertionDone; | 96 return InsertionDone; |
| 110 } | 97 } |
| 111 | 98 |
| 112 void HTMLOptGroupElement::removedFrom(ContainerNode* insertionPoint) { | 99 void HTMLOptGroupElement::removedFrom(ContainerNode* insertionPoint) { |
| 113 if (isHTMLSelectElement(*insertionPoint)) { | 100 if (isHTMLSelectElement(*insertionPoint)) { |
| 114 if (!parentNode()) | 101 if (!parentNode()) |
| 115 toHTMLSelectElement(insertionPoint)->optGroupInsertedOrRemoved(*this); | 102 toHTMLSelectElement(insertionPoint)->optGroupInsertedOrRemoved(*this); |
| 116 } | 103 } |
| 117 HTMLElement::removedFrom(insertionPoint); | 104 HTMLElement::removedFrom(insertionPoint); |
| 118 } | 105 } |
| 119 | 106 |
| 120 void HTMLOptGroupElement::updateNonComputedStyle() { | 107 void HTMLOptGroupElement::willRecalcStyle(StyleRecalcChange change) { |
| 121 m_style = originalStyleForLayoutObject(); | 108 if (layoutObject() && (change >= IndependentInherit || needsStyleRecalc())) { |
|
rune
2017/01/27 13:09:23
I don't think I understand this test completely. A
emilio
2017/01/27 22:13:15
These were the conditions that gated the customSty
rune
2017/02/06 22:40:44
I cannot make sense of this at all. layoutObject()
emilio
2017/02/08 10:59:24
So I experimented with this, and this condition is
| |
| 122 if (layoutObject()) { | |
| 123 if (HTMLSelectElement* select = ownerSelectElement()) | 109 if (HTMLSelectElement* select = ownerSelectElement()) |
| 124 select->updateListOnLayoutObject(); | 110 select->updateListOnLayoutObject(); |
| 125 } | 111 } |
| 126 } | 112 } |
| 127 | 113 |
| 128 ComputedStyle* HTMLOptGroupElement::nonLayoutObjectComputedStyle() const { | |
| 129 return m_style.get(); | |
| 130 } | |
| 131 | |
| 132 PassRefPtr<ComputedStyle> HTMLOptGroupElement::customStyleForLayoutObject() { | |
| 133 updateNonComputedStyle(); | |
| 134 return m_style; | |
| 135 } | |
| 136 | |
| 137 String HTMLOptGroupElement::groupLabelText() const { | 114 String HTMLOptGroupElement::groupLabelText() const { |
| 138 String itemText = getAttribute(labelAttr); | 115 String itemText = getAttribute(labelAttr); |
| 139 | 116 |
| 140 // In WinIE, leading and trailing whitespace is ignored in options and | 117 // In WinIE, leading and trailing whitespace is ignored in options and |
| 141 // optgroups. We match this behavior. | 118 // optgroups. We match this behavior. |
| 142 itemText = itemText.stripWhiteSpace(); | 119 itemText = itemText.stripWhiteSpace(); |
| 143 // We want to collapse our whitespace too. This will match other browsers. | 120 // We want to collapse our whitespace too. This will match other browsers. |
| 144 itemText = itemText.simplifyWhiteSpace(); | 121 itemText = itemText.simplifyWhiteSpace(); |
| 145 | 122 |
| 146 return itemText; | 123 return itemText; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 label.setTextContent(labelText); | 163 label.setTextContent(labelText); |
| 187 label.setAttribute(aria_labelAttr, AtomicString(labelText)); | 164 label.setAttribute(aria_labelAttr, AtomicString(labelText)); |
| 188 } | 165 } |
| 189 | 166 |
| 190 HTMLDivElement& HTMLOptGroupElement::optGroupLabelElement() const { | 167 HTMLDivElement& HTMLOptGroupElement::optGroupLabelElement() const { |
| 191 return *toHTMLDivElementOrDie(userAgentShadowRoot()->getElementById( | 168 return *toHTMLDivElementOrDie(userAgentShadowRoot()->getElementById( |
| 192 ShadowElementNames::optGroupLabel())); | 169 ShadowElementNames::optGroupLabel())); |
| 193 } | 170 } |
| 194 | 171 |
| 195 } // namespace blink | 172 } // namespace blink |
| OLD | NEW |