OLD | NEW |
---|---|
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 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. |
8 * All rights reserved. | 8 * All rights reserved. |
9 * (C) 2007 Eric Seidel (eric@webkit.org) | 9 * (C) 2007 Eric Seidel (eric@webkit.org) |
10 * | 10 * |
(...skipping 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2009 if (localChange != NoChange) { | 2009 if (localChange != NoChange) { |
2010 layoutObject->setStyle(newStyle.get()); | 2010 layoutObject->setStyle(newStyle.get()); |
2011 } else { | 2011 } else { |
2012 // Although no change occurred, we use the new style so that the cousin | 2012 // Although no change occurred, we use the new style so that the cousin |
2013 // style sharing code won't get fooled into believing this style is the | 2013 // style sharing code won't get fooled into believing this style is the |
2014 // same. | 2014 // same. |
2015 // FIXME: We may be able to remove this hack, see discussion in | 2015 // FIXME: We may be able to remove this hack, see discussion in |
2016 // https://codereview.chromium.org/30453002/ | 2016 // https://codereview.chromium.org/30453002/ |
2017 layoutObject->setStyleInternal(newStyle.get()); | 2017 layoutObject->setStyleInternal(newStyle.get()); |
2018 } | 2018 } |
2019 } else if (localChange != NoChange && | 2019 } else { |
2020 shouldStoreNonLayoutObjectComputedStyle(*newStyle)) { | 2020 if (localChange != NoChange) { |
2021 storeNonLayoutObjectComputedStyle(newStyle); | 2021 if (shouldStoreNonLayoutObjectComputedStyle(*newStyle)) |
2022 storeNonLayoutObjectComputedStyle(newStyle); | |
2023 else if (hasRareData()) | |
2024 elementRareData()->clearComputedStyle(); | |
rune
2017/04/04 20:32:40
I think I've commented on this before ...
Was the
| |
2025 } | |
2022 } | 2026 } |
2023 | 2027 |
2024 if (getStyleChangeType() >= SubtreeStyleChange) | 2028 if (getStyleChangeType() >= SubtreeStyleChange) |
2025 return Force; | 2029 return Force; |
2026 | 2030 |
2027 if (change > Inherit || localChange > Inherit) | 2031 if (change > Inherit || localChange > Inherit) |
2028 return max(localChange, change); | 2032 return max(localChange, change); |
2029 | 2033 |
2030 if (localChange < IndependentInherit) { | 2034 if (localChange < IndependentInherit) { |
2031 if (oldStyle->hasChildDependentFlags()) { | 2035 if (oldStyle->hasChildDependentFlags()) { |
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3185 elementStyle = rareData.computedStyle(); | 3189 elementStyle = rareData.computedStyle(); |
3186 } | 3190 } |
3187 | 3191 |
3188 if (!pseudoElementSpecifier) | 3192 if (!pseudoElementSpecifier) |
3189 return elementStyle; | 3193 return elementStyle; |
3190 | 3194 |
3191 if (ComputedStyle* pseudoElementStyle = | 3195 if (ComputedStyle* pseudoElementStyle = |
3192 elementStyle->getCachedPseudoStyle(pseudoElementSpecifier)) | 3196 elementStyle->getCachedPseudoStyle(pseudoElementSpecifier)) |
3193 return pseudoElementStyle; | 3197 return pseudoElementStyle; |
3194 | 3198 |
3195 // TODO(ecobos): Passing two times elementStyle may be wrong, though we don't | 3199 const ComputedStyle* layoutParentStyle = elementStyle; |
3196 // support display: contents elements' pseudo-elements yet, so this is not a | 3200 if (hasDisplayContentsStyle()) { |
3197 // problem for now. | 3201 LayoutObject* parentLayoutObject = |
3202 LayoutTreeBuilderTraversal::parentLayoutObject(*this); | |
3203 if (parentLayoutObject) | |
3204 layoutParentStyle = parentLayoutObject->style(); | |
3205 } | |
3206 | |
3198 RefPtr<ComputedStyle> result = | 3207 RefPtr<ComputedStyle> result = |
3199 document().ensureStyleResolver().pseudoStyleForElement( | 3208 document().ensureStyleResolver().pseudoStyleForElement( |
3200 this, PseudoStyleRequest(pseudoElementSpecifier, | 3209 this, |
3201 PseudoStyleRequest::ForComputedStyle), | 3210 PseudoStyleRequest(pseudoElementSpecifier, |
3202 elementStyle, elementStyle); | 3211 PseudoStyleRequest::ForComputedStyle), |
3212 elementStyle, layoutParentStyle); | |
3203 DCHECK(result); | 3213 DCHECK(result); |
3204 return elementStyle->addCachedPseudoStyle(result.release()); | 3214 return elementStyle->addCachedPseudoStyle(result.release()); |
3205 } | 3215 } |
3206 | 3216 |
3207 const ComputedStyle* Element::nonLayoutObjectComputedStyle() const { | 3217 const ComputedStyle* Element::nonLayoutObjectComputedStyle() const { |
3208 if (layoutObject() || !hasRareData()) | 3218 if (layoutObject() || !hasRareData()) |
3209 return nullptr; | 3219 return nullptr; |
3210 | 3220 |
3211 return elementRareData()->computedStyle(); | 3221 return elementRareData()->computedStyle(); |
3212 } | 3222 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3288 // PseudoElement styles hang off their parent element's style so if we | 3298 // PseudoElement styles hang off their parent element's style so if we |
3289 // needed a style recalc we should Force one on the pseudo. FIXME: We | 3299 // needed a style recalc we should Force one on the pseudo. FIXME: We |
3290 // should figure out the right text sibling to pass. | 3300 // should figure out the right text sibling to pass. |
3291 element->recalcStyle(change == UpdatePseudoElements ? Force : change); | 3301 element->recalcStyle(change == UpdatePseudoElements ? Force : change); |
3292 | 3302 |
3293 // Wait until our parent is not displayed or | 3303 // Wait until our parent is not displayed or |
3294 // pseudoElementLayoutObjectIsNeeded is false, otherwise we could | 3304 // pseudoElementLayoutObjectIsNeeded is false, otherwise we could |
3295 // continuously create and destroy PseudoElements when | 3305 // continuously create and destroy PseudoElements when |
3296 // LayoutObject::isChildAllowed on our parent returns false for the | 3306 // LayoutObject::isChildAllowed on our parent returns false for the |
3297 // PseudoElement's layoutObject for each style recalc. | 3307 // PseudoElement's layoutObject for each style recalc. |
3298 if (!layoutObject() || !pseudoElementLayoutObjectIsNeeded( | 3308 if (!canGeneratePseudoElement(pseudoId) || |
3299 pseudoStyle(PseudoStyleRequest(pseudoId)))) | 3309 !pseudoElementLayoutObjectIsNeeded( |
3310 pseudoStyle(PseudoStyleRequest(pseudoId)))) | |
3300 elementRareData()->setPseudoElement(pseudoId, nullptr); | 3311 elementRareData()->setPseudoElement(pseudoId, nullptr); |
3301 } else if (pseudoId == PseudoIdFirstLetter && element && | 3312 } else if (pseudoId == PseudoIdFirstLetter && element && |
3302 change >= UpdatePseudoElements && | 3313 change >= UpdatePseudoElements && |
3303 !FirstLetterPseudoElement::firstLetterTextLayoutObject(*element)) { | 3314 !FirstLetterPseudoElement::firstLetterTextLayoutObject(*element)) { |
3304 // This can happen if we change to a float, for example. We need to cleanup | 3315 // This can happen if we change to a float, for example. We need to cleanup |
3305 // the first-letter pseudoElement and then fix the text of the original | 3316 // the first-letter pseudoElement and then fix the text of the original |
3306 // remaining text layoutObject. This can be seen in Test 7 of | 3317 // remaining text layoutObject. This can be seen in Test 7 of |
3307 // fast/css/first-letter-removed-added.html | 3318 // fast/css/first-letter-removed-added.html |
3308 elementRareData()->setPseudoElement(pseudoId, nullptr); | 3319 elementRareData()->setPseudoElement(pseudoId, nullptr); |
3309 } else if (change >= UpdatePseudoElements) { | 3320 } else if (change >= UpdatePseudoElements) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3415 RefPtr<ComputedStyle> result = | 3426 RefPtr<ComputedStyle> result = |
3416 document().ensureStyleResolver().styleForElement( | 3427 document().ensureStyleResolver().styleForElement( |
3417 this, parentStyle, parentStyle, DisallowStyleSharing); | 3428 this, parentStyle, parentStyle, DisallowStyleSharing); |
3418 result->setStyleType(PseudoIdFirstLineInherited); | 3429 result->setStyleType(PseudoIdFirstLineInherited); |
3419 return result.release(); | 3430 return result.release(); |
3420 } | 3431 } |
3421 | 3432 |
3422 return document().ensureStyleResolver().pseudoStyleForElement( | 3433 return document().ensureStyleResolver().pseudoStyleForElement( |
3423 this, request, parentStyle, parentStyle); | 3434 this, request, parentStyle, parentStyle); |
3424 } | 3435 } |
3436 // For display: contents elements, we still need to generate ::before and | |
3437 // ::after, but the rest of the pseudo-elements should only be used for elements | |
3438 // with an actual layout object. | |
3439 bool Element::canGeneratePseudoElement(PseudoId pseudoId) const { | |
3440 if (hasDisplayContentsStyle()) | |
3441 return pseudoId == PseudoIdBefore || pseudoId == PseudoIdAfter; | |
3442 return !!layoutObject(); | |
3443 } | |
3425 | 3444 |
3426 bool Element::matches(const AtomicString& selectors, | 3445 bool Element::matches(const AtomicString& selectors, |
3427 ExceptionState& exceptionState) { | 3446 ExceptionState& exceptionState) { |
3428 SelectorQuery* selectorQuery = document().selectorQueryCache().add( | 3447 SelectorQuery* selectorQuery = document().selectorQueryCache().add( |
3429 selectors, document(), exceptionState); | 3448 selectors, document(), exceptionState); |
3430 if (!selectorQuery) | 3449 if (!selectorQuery) |
3431 return false; | 3450 return false; |
3432 return selectorQuery->matches(*this); | 3451 return selectorQuery->matches(*this); |
3433 } | 3452 } |
3434 | 3453 |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4270 } | 4289 } |
4271 | 4290 |
4272 DEFINE_TRACE_WRAPPERS(Element) { | 4291 DEFINE_TRACE_WRAPPERS(Element) { |
4273 if (hasRareData()) { | 4292 if (hasRareData()) { |
4274 visitor->traceWrappers(elementRareData()); | 4293 visitor->traceWrappers(elementRareData()); |
4275 } | 4294 } |
4276 ContainerNode::traceWrappers(visitor); | 4295 ContainerNode::traceWrappers(visitor); |
4277 } | 4296 } |
4278 | 4297 |
4279 } // namespace blink | 4298 } // namespace blink |
OLD | NEW |