OLD | NEW |
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 Loading... |
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 | |
72 bool SharedStyleFinder::canShareStyleWithControl(Element& candidate) const { | 62 bool SharedStyleFinder::canShareStyleWithControl(Element& candidate) const { |
73 if (!isHTMLInputElement(candidate) || !isHTMLInputElement(element())) | 63 if (!isHTMLInputElement(candidate) || !isHTMLInputElement(element())) |
74 return false; | 64 return false; |
75 | 65 |
76 HTMLInputElement& candidateInput = toHTMLInputElement(candidate); | 66 HTMLInputElement& candidateInput = toHTMLInputElement(candidate); |
77 HTMLInputElement& thisInput = toHTMLInputElement(element()); | 67 HTMLInputElement& thisInput = toHTMLInputElement(element()); |
78 | 68 |
79 if (candidateInput.isAutofilled() != thisInput.isAutofilled()) | 69 if (candidateInput.isAutofilled() != thisInput.isAutofilled()) |
80 return false; | 70 return false; |
81 if (candidateInput.shouldAppearChecked() != thisInput.shouldAppearChecked()) | 71 if (candidateInput.shouldAppearChecked() != thisInput.shouldAppearChecked()) |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 return false; | 221 return false; |
232 } | 222 } |
233 return true; | 223 return true; |
234 } | 224 } |
235 | 225 |
236 DISABLE_CFI_PERF | 226 DISABLE_CFI_PERF |
237 bool SharedStyleFinder::canShareStyleWithElement(Element& candidate) const { | 227 bool SharedStyleFinder::canShareStyleWithElement(Element& candidate) const { |
238 if (element() == candidate) | 228 if (element() == candidate) |
239 return false; | 229 return false; |
240 Element* parent = candidate.parentOrShadowHostElement(); | 230 Element* parent = candidate.parentOrShadowHostElement(); |
241 const ComputedStyle* style = getElementStyle(candidate); | 231 const ComputedStyle* style = candidate.computedStyle(); |
242 if (!style) | 232 if (!style) |
243 return false; | 233 return false; |
244 if (!style->isSharable()) | 234 if (!style->isSharable()) |
245 return false; | 235 return false; |
246 if (!parent) | 236 if (!parent) |
247 return false; | 237 return false; |
248 if (getElementStyle(*element().parentOrShadowHostElement()) != | 238 if (element().parentOrShadowHostElement()->computedStyle() != |
249 getElementStyle(*parent)) | 239 parent->computedStyle()) |
250 return false; | 240 return false; |
251 if (candidate.tagQName() != element().tagQName()) | 241 if (candidate.tagQName() != element().tagQName()) |
252 return false; | 242 return false; |
253 if (candidate.inlineStyle()) | 243 if (candidate.inlineStyle()) |
254 return false; | 244 return false; |
255 if (candidate.needsStyleRecalc() && !candidate.needsReattachLayoutTree()) | 245 if (candidate.needsStyleRecalc()) |
256 return false; | 246 return false; |
257 if (candidate.isSVGElement() && | 247 if (candidate.isSVGElement() && |
258 toSVGElement(candidate).animatedSMILStyleProperties()) | 248 toSVGElement(candidate).animatedSMILStyleProperties()) |
259 return false; | 249 return false; |
260 if (candidate.isLink() != element().isLink()) | 250 if (candidate.isLink() != element().isLink()) |
261 return false; | 251 return false; |
262 if (candidate.shadowPseudoId() != element().shadowPseudoId()) | 252 if (candidate.shadowPseudoId() != element().shadowPseudoId()) |
263 return false; | 253 return false; |
264 if (!sharingCandidateHasIdenticalStyleAffectingAttributes(candidate)) | 254 if (!sharingCandidateHasIdenticalStyleAffectingAttributes(candidate)) |
265 return false; | 255 return false; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 } | 400 } |
411 | 401 |
412 // Tracking child index requires unique style for each node. This may get set | 402 // Tracking child index requires unique style for each node. This may get set |
413 // by the sibling rule match above. | 403 // by the sibling rule match above. |
414 if (!element().parentElementOrShadowRoot()->childrenSupportStyleSharing()) { | 404 if (!element().parentElementOrShadowRoot()->childrenSupportStyleSharing()) { |
415 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), | 405 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), |
416 sharedStyleRejectedByParent, 1); | 406 sharedStyleRejectedByParent, 1); |
417 return nullptr; | 407 return nullptr; |
418 } | 408 } |
419 | 409 |
420 return getElementStyle(*shareElement); | 410 return shareElement->mutableComputedStyle(); |
421 } | 411 } |
422 | 412 |
423 } // namespace blink | 413 } // namespace blink |
OLD | NEW |