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

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

Issue 2473743003: Call Element::rebuildLayoutTree from Document::updateStyle directly (Closed)
Patch Set: Make needsAttach() only check if getStyleChangeType flag is NeedsReattachStyleChange and add a Layo… Created 3 years, 9 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. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
10 * (http://www.torchmobile.com/) 10 * (http://www.torchmobile.com/)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "core/style/ComputedStyle.h" 52 #include "core/style/ComputedStyle.h"
53 #include "core/svg/SVGElement.h" 53 #include "core/svg/SVGElement.h"
54 #include "platform/instrumentation/tracing/TraceEvent.h" 54 #include "platform/instrumentation/tracing/TraceEvent.h"
55 #include "wtf/HashSet.h" 55 #include "wtf/HashSet.h"
56 #include "wtf/text/AtomicString.h" 56 #include "wtf/text/AtomicString.h"
57 57
58 namespace blink { 58 namespace blink {
59 59
60 using namespace HTMLNames; 60 using namespace HTMLNames;
61 61
62 inline ComputedStyle* getElementStyle(Element& element) {
63 if (element.needsReattachLayoutTree()) {
64 StyleReattachData styleReattachData =
65 element.document().getStyleReattachData(element);
66 if (styleReattachData.computedStyle)
67 return styleReattachData.computedStyle.get();
68 }
69 return element.mutableComputedStyle();
70 }
71
62 bool SharedStyleFinder::canShareStyleWithControl(Element& candidate) const { 72 bool SharedStyleFinder::canShareStyleWithControl(Element& candidate) const {
63 if (!isHTMLInputElement(candidate) || !isHTMLInputElement(element())) 73 if (!isHTMLInputElement(candidate) || !isHTMLInputElement(element()))
64 return false; 74 return false;
65 75
66 HTMLInputElement& candidateInput = toHTMLInputElement(candidate); 76 HTMLInputElement& candidateInput = toHTMLInputElement(candidate);
67 HTMLInputElement& thisInput = toHTMLInputElement(element()); 77 HTMLInputElement& thisInput = toHTMLInputElement(element());
68 78
69 if (candidateInput.isAutofilled() != thisInput.isAutofilled()) 79 if (candidateInput.isAutofilled() != thisInput.isAutofilled())
70 return false; 80 return false;
71 if (candidateInput.shouldAppearChecked() != thisInput.shouldAppearChecked()) 81 if (candidateInput.shouldAppearChecked() != thisInput.shouldAppearChecked())
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 return false; 231 return false;
222 } 232 }
223 return true; 233 return true;
224 } 234 }
225 235
226 DISABLE_CFI_PERF 236 DISABLE_CFI_PERF
227 bool SharedStyleFinder::canShareStyleWithElement(Element& candidate) const { 237 bool SharedStyleFinder::canShareStyleWithElement(Element& candidate) const {
228 if (element() == candidate) 238 if (element() == candidate)
229 return false; 239 return false;
230 Element* parent = candidate.parentOrShadowHostElement(); 240 Element* parent = candidate.parentOrShadowHostElement();
231 const ComputedStyle* style = candidate.computedStyle(); 241 const ComputedStyle* style = getElementStyle(candidate);
232 if (!style) 242 if (!style)
233 return false; 243 return false;
234 if (!style->isSharable()) 244 if (!style->isSharable())
235 return false; 245 return false;
236 if (!parent) 246 if (!parent)
237 return false; 247 return false;
238 if (element().parentOrShadowHostElement()->computedStyle() != 248 if (getElementStyle(*element().parentOrShadowHostElement()) !=
239 parent->computedStyle()) 249 getElementStyle(*parent))
240 return false; 250 return false;
241 if (candidate.tagQName() != element().tagQName()) 251 if (candidate.tagQName() != element().tagQName())
242 return false; 252 return false;
243 if (candidate.inlineStyle()) 253 if (candidate.inlineStyle())
244 return false; 254 return false;
245 if (candidate.needsStyleRecalc()) 255 if (candidate.needsStyleRecalc() && !candidate.needsReattachLayoutTree())
246 return false; 256 return false;
247 if (candidate.isSVGElement() && 257 if (candidate.isSVGElement() &&
248 toSVGElement(candidate).animatedSMILStyleProperties()) 258 toSVGElement(candidate).animatedSMILStyleProperties())
249 return false; 259 return false;
250 if (candidate.isLink() != element().isLink()) 260 if (candidate.isLink() != element().isLink())
251 return false; 261 return false;
252 if (candidate.shadowPseudoId() != element().shadowPseudoId()) 262 if (candidate.shadowPseudoId() != element().shadowPseudoId())
253 return false; 263 return false;
254 if (!sharingCandidateHasIdenticalStyleAffectingAttributes(candidate)) 264 if (!sharingCandidateHasIdenticalStyleAffectingAttributes(candidate))
255 return false; 265 return false;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 } 410 }
401 411
402 // Tracking child index requires unique style for each node. This may get set 412 // Tracking child index requires unique style for each node. This may get set
403 // by the sibling rule match above. 413 // by the sibling rule match above.
404 if (!element().parentElementOrShadowRoot()->childrenSupportStyleSharing()) { 414 if (!element().parentElementOrShadowRoot()->childrenSupportStyleSharing()) {
405 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), 415 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(),
406 sharedStyleRejectedByParent, 1); 416 sharedStyleRejectedByParent, 1);
407 return nullptr; 417 return nullptr;
408 } 418 }
409 419
410 return shareElement->mutableComputedStyle(); 420 return getElementStyle(*shareElement);
411 } 421 }
412 422
413 } // namespace blink 423 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698