Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLOptGroupElement.cpp

Issue 2450093005: Support display: contents for elements, first-line and first-letter pseudos. (Closed)
Patch Set: Support display: contents for elements, first-line and first-letter pseudos. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 PassRefPtr<ComputedStyle> HTMLOptGroupElement::customStyleForLayoutObject() {
114 m_style = originalStyleForLayoutObject(); 101 RefPtr<ComputedStyle> style = originalStyleForLayoutObject();
102 storeNonLayoutObjectComputedStyle(style);
103
115 if (layoutObject()) { 104 if (layoutObject()) {
116 if (HTMLSelectElement* select = ownerSelectElement()) 105 if (HTMLSelectElement* select = ownerSelectElement())
117 select->updateListOnLayoutObject(); 106 select->updateListOnLayoutObject();
118 } 107 }
119 }
120 108
121 ComputedStyle* HTMLOptGroupElement::nonLayoutObjectComputedStyle() const { 109 return std::move(style);
122 return m_style.get();
123 }
124
125 PassRefPtr<ComputedStyle> HTMLOptGroupElement::customStyleForLayoutObject() {
126 updateNonComputedStyle();
127 return m_style;
128 } 110 }
129 111
130 String HTMLOptGroupElement::groupLabelText() const { 112 String HTMLOptGroupElement::groupLabelText() const {
131 String itemText = getAttribute(labelAttr); 113 String itemText = getAttribute(labelAttr);
132 114
133 // In WinIE, leading and trailing whitespace is ignored in options and 115 // In WinIE, leading and trailing whitespace is ignored in options and
134 // optgroups. We match this behavior. 116 // optgroups. We match this behavior.
135 itemText = itemText.stripWhiteSpace(); 117 itemText = itemText.stripWhiteSpace();
136 // We want to collapse our whitespace too. This will match other browsers. 118 // We want to collapse our whitespace too. This will match other browsers.
137 itemText = itemText.simplifyWhiteSpace(); 119 itemText = itemText.simplifyWhiteSpace();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 label.setTextContent(labelText); 161 label.setTextContent(labelText);
180 label.setAttribute(aria_labelAttr, AtomicString(labelText)); 162 label.setAttribute(aria_labelAttr, AtomicString(labelText));
181 } 163 }
182 164
183 HTMLDivElement& HTMLOptGroupElement::optGroupLabelElement() const { 165 HTMLDivElement& HTMLOptGroupElement::optGroupLabelElement() const {
184 return *toHTMLDivElement(userAgentShadowRoot()->getElementById( 166 return *toHTMLDivElement(userAgentShadowRoot()->getElementById(
185 ShadowElementNames::optGroupLabel())); 167 ShadowElementNames::optGroupLabel()));
186 } 168 }
187 169
188 } // namespace blink 170 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698