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 25 matching lines...) Expand all Loading... |
36 #include "core/style/ComputedStyle.h" | 36 #include "core/style/ComputedStyle.h" |
37 #include "wtf/StdLibExtras.h" | 37 #include "wtf/StdLibExtras.h" |
38 #include "wtf/text/CharacterNames.h" | 38 #include "wtf/text/CharacterNames.h" |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 using namespace HTMLNames; | 42 using namespace HTMLNames; |
43 | 43 |
44 inline HTMLOptGroupElement::HTMLOptGroupElement(Document& document) | 44 inline HTMLOptGroupElement::HTMLOptGroupElement(Document& document) |
45 : HTMLElement(optgroupTag, document) { | 45 : HTMLElement(optgroupTag, document) { |
46 setHasCustomStyleCallbacks(); | |
47 } | 46 } |
48 | 47 |
49 // An explicit empty destructor should be in HTMLOptGroupElement.cpp, because | 48 // An explicit empty destructor should be in HTMLOptGroupElement.cpp, because |
50 // if an implicit destructor is used or an empty destructor is defined in | 49 // if an implicit destructor is used or an empty destructor is defined in |
51 // HTMLOptGroupElement.h, when including HTMLOptGroupElement.h, | 50 // HTMLOptGroupElement.h, when including HTMLOptGroupElement.h, |
52 // msvc tries to expand the destructor and causes | 51 // msvc tries to expand the destructor and causes |
53 // a compile error because of lack of ComputedStyle definition. | 52 // a compile error because of lack of ComputedStyle definition. |
54 HTMLOptGroupElement::~HTMLOptGroupElement() {} | 53 HTMLOptGroupElement::~HTMLOptGroupElement() {} |
55 | 54 |
56 HTMLOptGroupElement* HTMLOptGroupElement::create(Document& document) { | 55 HTMLOptGroupElement* HTMLOptGroupElement::create(Document& document) { |
(...skipping 11 matching lines...) Expand all Loading... |
68 HTMLElement::parseAttribute(params); | 67 HTMLElement::parseAttribute(params); |
69 | 68 |
70 if (params.name == disabledAttr) { | 69 if (params.name == disabledAttr) { |
71 pseudoStateChanged(CSSSelector::PseudoDisabled); | 70 pseudoStateChanged(CSSSelector::PseudoDisabled); |
72 pseudoStateChanged(CSSSelector::PseudoEnabled); | 71 pseudoStateChanged(CSSSelector::PseudoEnabled); |
73 } else if (params.name == labelAttr) { | 72 } else if (params.name == labelAttr) { |
74 updateGroupLabel(); | 73 updateGroupLabel(); |
75 } | 74 } |
76 } | 75 } |
77 | 76 |
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 { | 77 bool HTMLOptGroupElement::supportsFocus() const { |
92 HTMLSelectElement* select = ownerSelectElement(); | 78 HTMLSelectElement* select = ownerSelectElement(); |
93 if (select && select->usesMenuList()) | 79 if (select && select->usesMenuList()) |
94 return false; | 80 return false; |
95 return HTMLElement::supportsFocus(); | 81 return HTMLElement::supportsFocus(); |
96 } | 82 } |
97 | 83 |
98 bool HTMLOptGroupElement::matchesEnabledPseudoClass() const { | 84 bool HTMLOptGroupElement::matchesEnabledPseudoClass() const { |
99 return !isDisabledFormControl(); | 85 return !isDisabledFormControl(); |
100 } | 86 } |
101 | 87 |
102 Node::InsertionNotificationRequest HTMLOptGroupElement::insertedInto( | 88 Node::InsertionNotificationRequest HTMLOptGroupElement::insertedInto( |
103 ContainerNode* insertionPoint) { | 89 ContainerNode* insertionPoint) { |
104 HTMLElement::insertedInto(insertionPoint); | 90 HTMLElement::insertedInto(insertionPoint); |
105 if (HTMLSelectElement* select = ownerSelectElement()) { | 91 if (HTMLSelectElement* select = ownerSelectElement()) { |
106 if (insertionPoint == select) | 92 if (insertionPoint == select) |
107 select->optGroupInsertedOrRemoved(*this); | 93 select->optGroupInsertedOrRemoved(*this); |
108 } | 94 } |
109 return InsertionDone; | 95 return InsertionDone; |
110 } | 96 } |
111 | 97 |
112 void HTMLOptGroupElement::removedFrom(ContainerNode* insertionPoint) { | 98 void HTMLOptGroupElement::removedFrom(ContainerNode* insertionPoint) { |
113 if (isHTMLSelectElement(*insertionPoint)) { | 99 if (isHTMLSelectElement(*insertionPoint)) { |
114 if (!parentNode()) | 100 if (!parentNode()) |
115 toHTMLSelectElement(insertionPoint)->optGroupInsertedOrRemoved(*this); | 101 toHTMLSelectElement(insertionPoint)->optGroupInsertedOrRemoved(*this); |
116 } | 102 } |
117 HTMLElement::removedFrom(insertionPoint); | 103 HTMLElement::removedFrom(insertionPoint); |
118 } | 104 } |
119 | 105 |
120 void HTMLOptGroupElement::updateNonComputedStyle() { | |
121 m_style = originalStyleForLayoutObject(); | |
122 if (layoutObject()) { | |
123 if (HTMLSelectElement* select = ownerSelectElement()) | |
124 select->updateListOnLayoutObject(); | |
125 } | |
126 } | |
127 | |
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 { | 106 String HTMLOptGroupElement::groupLabelText() const { |
138 String itemText = getAttribute(labelAttr); | 107 String itemText = getAttribute(labelAttr); |
139 | 108 |
140 // In WinIE, leading and trailing whitespace is ignored in options and | 109 // In WinIE, leading and trailing whitespace is ignored in options and |
141 // optgroups. We match this behavior. | 110 // optgroups. We match this behavior. |
142 itemText = itemText.stripWhiteSpace(); | 111 itemText = itemText.stripWhiteSpace(); |
143 // We want to collapse our whitespace too. This will match other browsers. | 112 // We want to collapse our whitespace too. This will match other browsers. |
144 itemText = itemText.simplifyWhiteSpace(); | 113 itemText = itemText.simplifyWhiteSpace(); |
145 | 114 |
146 return itemText; | 115 return itemText; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 label.setTextContent(labelText); | 155 label.setTextContent(labelText); |
187 label.setAttribute(aria_labelAttr, AtomicString(labelText)); | 156 label.setAttribute(aria_labelAttr, AtomicString(labelText)); |
188 } | 157 } |
189 | 158 |
190 HTMLDivElement& HTMLOptGroupElement::optGroupLabelElement() const { | 159 HTMLDivElement& HTMLOptGroupElement::optGroupLabelElement() const { |
191 return *toHTMLDivElementOrDie(userAgentShadowRoot()->getElementById( | 160 return *toHTMLDivElementOrDie(userAgentShadowRoot()->getElementById( |
192 ShadowElementNames::optGroupLabel())); | 161 ShadowElementNames::optGroupLabel())); |
193 } | 162 } |
194 | 163 |
195 } // namespace blink | 164 } // namespace blink |
OLD | NEW |