| 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() && !candidate.needsReattachLayoutTree()) |
| 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; |
| 250 if (style->hasPseudoElementStyle()) |
| 251 return false; |
| 260 if (candidate.isLink() != element().isLink()) | 252 if (candidate.isLink() != element().isLink()) |
| 261 return false; | 253 return false; |
| 262 if (candidate.shadowPseudoId() != element().shadowPseudoId()) | 254 if (candidate.shadowPseudoId() != element().shadowPseudoId()) |
| 263 return false; | 255 return false; |
| 264 if (!sharingCandidateHasIdenticalStyleAffectingAttributes(candidate)) | 256 if (!sharingCandidateHasIdenticalStyleAffectingAttributes(candidate)) |
| 265 return false; | 257 return false; |
| 266 if (candidate.additionalPresentationAttributeStyle() != | 258 if (candidate.additionalPresentationAttributeStyle() != |
| 267 element().additionalPresentationAttributeStyle()) | 259 element().additionalPresentationAttributeStyle()) |
| 268 return false; | 260 return false; |
| 269 if (candidate.hasID() && | 261 if (candidate.hasID() && |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 } | 402 } |
| 411 | 403 |
| 412 // Tracking child index requires unique style for each node. This may get set | 404 // Tracking child index requires unique style for each node. This may get set |
| 413 // by the sibling rule match above. | 405 // by the sibling rule match above. |
| 414 if (!element().parentElementOrShadowRoot()->childrenSupportStyleSharing()) { | 406 if (!element().parentElementOrShadowRoot()->childrenSupportStyleSharing()) { |
| 415 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), | 407 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), |
| 416 sharedStyleRejectedByParent, 1); | 408 sharedStyleRejectedByParent, 1); |
| 417 return nullptr; | 409 return nullptr; |
| 418 } | 410 } |
| 419 | 411 |
| 420 return getElementStyle(*shareElement); | 412 return shareElement->mutableComputedStyle(); |
| 421 } | 413 } |
| 422 | 414 |
| 423 } // namespace blink | 415 } // namespace blink |
| OLD | NEW |