| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 HTMLElement::parseAttribute(name, oldValue, value); | 61 HTMLElement::parseAttribute(name, oldValue, value); |
| 62 | 62 |
| 63 if (name == disabledAttr) { | 63 if (name == disabledAttr) { |
| 64 pseudoStateChanged(CSSSelector::PseudoDisabled); | 64 pseudoStateChanged(CSSSelector::PseudoDisabled); |
| 65 pseudoStateChanged(CSSSelector::PseudoEnabled); | 65 pseudoStateChanged(CSSSelector::PseudoEnabled); |
| 66 } else if (name == labelAttr) { | 66 } else if (name == labelAttr) { |
| 67 updateGroupLabel(); | 67 updateGroupLabel(); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 void HTMLOptGroupElement::attachLayoutTree(const AttachContext& context) { | |
| 72 if (context.resolvedStyle) { | |
| 73 DCHECK(!m_style || m_style == context.resolvedStyle); | |
| 74 m_style = context.resolvedStyle; | |
| 75 } | |
| 76 HTMLElement::attachLayoutTree(context); | |
| 77 } | |
| 78 | |
| 79 void HTMLOptGroupElement::detachLayoutTree(const AttachContext& context) { | |
| 80 m_style.clear(); | |
| 81 HTMLElement::detachLayoutTree(context); | |
| 82 } | |
| 83 | |
| 84 bool HTMLOptGroupElement::supportsFocus() const { | 71 bool HTMLOptGroupElement::supportsFocus() const { |
| 85 HTMLSelectElement* select = ownerSelectElement(); | 72 HTMLSelectElement* select = ownerSelectElement(); |
| 86 if (select && select->usesMenuList()) | 73 if (select && select->usesMenuList()) |
| 87 return false; | 74 return false; |
| 88 return HTMLElement::supportsFocus(); | 75 return HTMLElement::supportsFocus(); |
| 89 } | 76 } |
| 90 | 77 |
| 91 bool HTMLOptGroupElement::matchesEnabledPseudoClass() const { | 78 bool HTMLOptGroupElement::matchesEnabledPseudoClass() const { |
| 92 return !isDisabledFormControl(); | 79 return !isDisabledFormControl(); |
| 93 } | 80 } |
| 94 | 81 |
| 95 Node::InsertionNotificationRequest HTMLOptGroupElement::insertedInto( | 82 Node::InsertionNotificationRequest HTMLOptGroupElement::insertedInto( |
| 96 ContainerNode* insertionPoint) { | 83 ContainerNode* insertionPoint) { |
| 97 HTMLElement::insertedInto(insertionPoint); | 84 HTMLElement::insertedInto(insertionPoint); |
| 98 if (HTMLSelectElement* select = ownerSelectElement()) { | 85 if (HTMLSelectElement* select = ownerSelectElement()) { |
| 99 if (insertionPoint == select) | 86 if (insertionPoint == select) |
| 100 select->optGroupInsertedOrRemoved(*this); | 87 select->optGroupInsertedOrRemoved(*this); |
| 101 } | 88 } |
| 102 return InsertionDone; | 89 return InsertionDone; |
| 103 } | 90 } |
| 104 | 91 |
| 105 void HTMLOptGroupElement::removedFrom(ContainerNode* insertionPoint) { | 92 void HTMLOptGroupElement::removedFrom(ContainerNode* insertionPoint) { |
| 106 if (isHTMLSelectElement(*insertionPoint)) { | 93 if (isHTMLSelectElement(*insertionPoint)) { |
| 107 if (!parentNode()) | 94 if (!parentNode()) |
| 108 toHTMLSelectElement(insertionPoint)->optGroupInsertedOrRemoved(*this); | 95 toHTMLSelectElement(insertionPoint)->optGroupInsertedOrRemoved(*this); |
| 109 } | 96 } |
| 110 HTMLElement::removedFrom(insertionPoint); | 97 HTMLElement::removedFrom(insertionPoint); |
| 111 } | 98 } |
| 112 | 99 |
| 113 void HTMLOptGroupElement::updateNonComputedStyle() { | 100 void HTMLOptGroupElement::willRecalcStyle(StyleRecalcChange change) { |
| 114 m_style = originalStyleForLayoutObject(); | 101 if (layoutObject() && (change >= IndependentInherit || needsStyleRecalc())) { |
| 115 if (layoutObject()) { | |
| 116 if (HTMLSelectElement* select = ownerSelectElement()) | 102 if (HTMLSelectElement* select = ownerSelectElement()) |
| 117 select->updateListOnLayoutObject(); | 103 select->updateListOnLayoutObject(); |
| 118 } | 104 } |
| 119 } | 105 } |
| 120 | 106 |
| 121 ComputedStyle* HTMLOptGroupElement::nonLayoutObjectComputedStyle() const { | |
| 122 return m_style.get(); | |
| 123 } | |
| 124 | |
| 125 PassRefPtr<ComputedStyle> HTMLOptGroupElement::customStyleForLayoutObject() { | |
| 126 updateNonComputedStyle(); | |
| 127 return m_style; | |
| 128 } | |
| 129 | |
| 130 String HTMLOptGroupElement::groupLabelText() const { | 107 String HTMLOptGroupElement::groupLabelText() const { |
| 131 String itemText = getAttribute(labelAttr); | 108 String itemText = getAttribute(labelAttr); |
| 132 | 109 |
| 133 // In WinIE, leading and trailing whitespace is ignored in options and | 110 // In WinIE, leading and trailing whitespace is ignored in options and |
| 134 // optgroups. We match this behavior. | 111 // optgroups. We match this behavior. |
| 135 itemText = itemText.stripWhiteSpace(); | 112 itemText = itemText.stripWhiteSpace(); |
| 136 // We want to collapse our whitespace too. This will match other browsers. | 113 // We want to collapse our whitespace too. This will match other browsers. |
| 137 itemText = itemText.simplifyWhiteSpace(); | 114 itemText = itemText.simplifyWhiteSpace(); |
| 138 | 115 |
| 139 return itemText; | 116 return itemText; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 label.setTextContent(labelText); | 156 label.setTextContent(labelText); |
| 180 label.setAttribute(aria_labelAttr, AtomicString(labelText)); | 157 label.setAttribute(aria_labelAttr, AtomicString(labelText)); |
| 181 } | 158 } |
| 182 | 159 |
| 183 HTMLDivElement& HTMLOptGroupElement::optGroupLabelElement() const { | 160 HTMLDivElement& HTMLOptGroupElement::optGroupLabelElement() const { |
| 184 return *toHTMLDivElementOrDie(userAgentShadowRoot()->getElementById( | 161 return *toHTMLDivElementOrDie(userAgentShadowRoot()->getElementById( |
| 185 ShadowElementNames::optGroupLabel())); | 162 ShadowElementNames::optGroupLabel())); |
| 186 } | 163 } |
| 187 | 164 |
| 188 } // namespace blink | 165 } // namespace blink |
| OLD | NEW |