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

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/SharedStyleFinder.cpp

Issue 2399633003: reflow comments in core/css/resolver (Closed)
Patch Set: Created 4 years, 2 months 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) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
6 * All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
10 * (http://www.torchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 11 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 12 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
11 * Copyright (C) 2013 Google Inc. All rights reserved. 13 * Copyright (C) 2013 Google Inc. All rights reserved.
12 * 14 *
13 * This library is free software; you can redistribute it and/or 15 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Library General Public 16 * modify it under the terms of the GNU Library General Public
15 * License as published by the Free Software Foundation; either 17 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version. 18 * version 2 of the License, or (at your option) any later version.
17 * 19 *
18 * This library is distributed in the hope that it will be useful, 20 * This library is distributed in the hope that it will be useful,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 Element& candidate) const { 125 Element& candidate) const {
124 if (element().sharesSameElementData(candidate)) 126 if (element().sharesSameElementData(candidate))
125 return true; 127 return true;
126 if (element().fastGetAttribute(XMLNames::langAttr) != 128 if (element().fastGetAttribute(XMLNames::langAttr) !=
127 candidate.fastGetAttribute(XMLNames::langAttr)) 129 candidate.fastGetAttribute(XMLNames::langAttr))
128 return false; 130 return false;
129 if (element().fastGetAttribute(langAttr) != 131 if (element().fastGetAttribute(langAttr) !=
130 candidate.fastGetAttribute(langAttr)) 132 candidate.fastGetAttribute(langAttr))
131 return false; 133 return false;
132 134
133 // These two checks must be here since RuleSet has a special case to allow sty le sharing between elements 135 // These two checks must be here since RuleSet has a special case to allow
134 // with type and readonly attributes whereas other attribute selectors prevent sharing. 136 // style sharing between elements with type and readonly attributes whereas
137 // other attribute selectors prevent sharing.
135 if (typeAttributeValue(element()) != typeAttributeValue(candidate)) 138 if (typeAttributeValue(element()) != typeAttributeValue(candidate))
136 return false; 139 return false;
137 if (element().fastGetAttribute(readonlyAttr) != 140 if (element().fastGetAttribute(readonlyAttr) !=
138 candidate.fastGetAttribute(readonlyAttr)) 141 candidate.fastGetAttribute(readonlyAttr))
139 return false; 142 return false;
140 143
141 if (!m_elementAffectedByClassRules) { 144 if (!m_elementAffectedByClassRules) {
142 if (candidate.hasClass() && 145 if (candidate.hasClass() &&
143 classNamesAffectedByRules(candidate.classNames())) 146 classNamesAffectedByRules(candidate.classNames()))
144 return false; 147 return false;
145 } else if (candidate.hasClass()) { 148 } else if (candidate.hasClass()) {
146 // SVG elements require a (slow!) getAttribute comparision because "class" i s an animatable attribute for SVG. 149 // SVG elements require a (slow!) getAttribute comparision because "class"
150 // is an animatable attribute for SVG.
147 if (element().isSVGElement()) { 151 if (element().isSVGElement()) {
148 if (element().getAttribute(classAttr) != 152 if (element().getAttribute(classAttr) !=
149 candidate.getAttribute(classAttr)) 153 candidate.getAttribute(classAttr))
150 return false; 154 return false;
151 } else if (element().classNames() != candidate.classNames()) { 155 } else if (element().classNames() != candidate.classNames()) {
152 return false; 156 return false;
153 } 157 }
154 } else { 158 } else {
155 return false; 159 return false;
156 } 160 }
157 161
158 if (element().presentationAttributeStyle() != 162 if (element().presentationAttributeStyle() !=
159 candidate.presentationAttributeStyle()) 163 candidate.presentationAttributeStyle())
160 return false; 164 return false;
161 165
162 // FIXME: Consider removing this, it's unlikely we'll have so many progress el ements 166 // FIXME: Consider removing this, it's unlikely we'll have so many progress
163 // that sharing the style makes sense. Instead we should just not support styl e sharing 167 // elements that sharing the style makes sense. Instead we should just not
164 // for them. 168 // support style sharing for them.
165 if (isHTMLProgressElement(element())) { 169 if (isHTMLProgressElement(element())) {
166 if (element().shouldAppearIndeterminate() != 170 if (element().shouldAppearIndeterminate() !=
167 candidate.shouldAppearIndeterminate()) 171 candidate.shouldAppearIndeterminate())
168 return false; 172 return false;
169 } 173 }
170 174
171 if (isHTMLOptGroupElement(element()) || isHTMLOptionElement(element())) { 175 if (isHTMLOptGroupElement(element()) || isHTMLOptionElement(element())) {
172 if (element().isDisabledFormControl() != candidate.isDisabledFormControl()) 176 if (element().isDisabledFormControl() != candidate.isDisabledFormControl())
173 return false; 177 return false;
174 if (isHTMLOptionElement(element()) && 178 if (isHTMLOptionElement(element()) &&
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 if (isControl && !canShareStyleWithControl(candidate)) 261 if (isControl && !canShareStyleWithControl(candidate))
258 return false; 262 return false;
259 263
260 if (isHTMLOptionElement(candidate) && isHTMLOptionElement(element()) && 264 if (isHTMLOptionElement(candidate) && isHTMLOptionElement(element()) &&
261 (toHTMLOptionElement(candidate).selected() != 265 (toHTMLOptionElement(candidate).selected() !=
262 toHTMLOptionElement(element()).selected() || 266 toHTMLOptionElement(element()).selected() ||
263 toHTMLOptionElement(candidate).spatialNavigationFocused() != 267 toHTMLOptionElement(candidate).spatialNavigationFocused() !=
264 toHTMLOptionElement(element()).spatialNavigationFocused())) 268 toHTMLOptionElement(element()).spatialNavigationFocused()))
265 return false; 269 return false;
266 270
267 // FIXME: This line is surprisingly hot, we may wish to inline hasDirectionAut o into StyleResolver. 271 // FIXME: This line is surprisingly hot, we may wish to inline
272 // hasDirectionAuto into StyleResolver.
268 if (candidate.isHTMLElement() && toHTMLElement(candidate).hasDirectionAuto()) 273 if (candidate.isHTMLElement() && toHTMLElement(candidate).hasDirectionAuto())
269 return false; 274 return false;
270 275
271 if (candidate.isLink() && m_context.elementLinkState() != style->insideLink()) 276 if (candidate.isLink() && m_context.elementLinkState() != style->insideLink())
272 return false; 277 return false;
273 278
274 if (candidate.isUnresolvedV0CustomElement() != 279 if (candidate.isUnresolvedV0CustomElement() !=
275 element().isUnresolvedV0CustomElement()) 280 element().isUnresolvedV0CustomElement())
276 return false; 281 return false;
277 282
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 return nullptr; 372 return nullptr;
368 } 373 }
369 374
370 if (matchesRuleSet(m_uncommonAttributeRuleSet)) { 375 if (matchesRuleSet(m_uncommonAttributeRuleSet)) {
371 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), 376 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(),
372 sharedStyleRejectedByUncommonAttributeRules, 377 sharedStyleRejectedByUncommonAttributeRules,
373 1); 378 1);
374 return nullptr; 379 return nullptr;
375 } 380 }
376 381
377 // Tracking child index requires unique style for each node. This may get set by the sibling rule match above. 382 // Tracking child index requires unique style for each node. This may get set
383 // by the sibling rule match above.
378 if (!element().parentElementOrShadowRoot()->childrenSupportStyleSharing()) { 384 if (!element().parentElementOrShadowRoot()->childrenSupportStyleSharing()) {
379 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), 385 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(),
380 sharedStyleRejectedByParent, 1); 386 sharedStyleRejectedByParent, 1);
381 return nullptr; 387 return nullptr;
382 } 388 }
383 389
384 return shareElement->mutableComputedStyle(); 390 return shareElement->mutableComputedStyle();
385 } 391 }
386 392
387 } // namespace blink 393 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698