Chromium Code Reviews| 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) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. |
| 7 * All rights reserved. | 7 * All rights reserved. |
| 8 * Copyright (C) 2009 Google Inc. All rights reserved. | 8 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. |
| 10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
| (...skipping 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1952 if (oldStyle.hasPseudoStyle(PseudoIdSelection) || | 1952 if (oldStyle.hasPseudoStyle(PseudoIdSelection) || |
| 1953 styleRef().hasPseudoStyle(PseudoIdSelection)) | 1953 styleRef().hasPseudoStyle(PseudoIdSelection)) |
| 1954 invalidatePaintForSelection(); | 1954 invalidatePaintForSelection(); |
| 1955 } | 1955 } |
| 1956 | 1956 |
| 1957 void LayoutObject::applyFirstLineChanges(const ComputedStyle& oldStyle) { | 1957 void LayoutObject::applyFirstLineChanges(const ComputedStyle& oldStyle) { |
| 1958 if (oldStyle.hasPseudoStyle(PseudoIdFirstLine)) { | 1958 if (oldStyle.hasPseudoStyle(PseudoIdFirstLine)) { |
| 1959 RefPtr<ComputedStyle> oldPseudoStyle = | 1959 RefPtr<ComputedStyle> oldPseudoStyle = |
| 1960 oldStyle.getCachedPseudoStyle(PseudoIdFirstLine); | 1960 oldStyle.getCachedPseudoStyle(PseudoIdFirstLine); |
| 1961 if (styleRef().hasPseudoStyle(PseudoIdFirstLine) && oldPseudoStyle) { | 1961 if (styleRef().hasPseudoStyle(PseudoIdFirstLine) && oldPseudoStyle) { |
| 1962 RefPtr<ComputedStyle> newPseudoStyle = | 1962 RefPtr<ComputedStyle> newPseudoStyle = uncachedFirstLineStyle(); |
| 1963 uncachedFirstLineStyle(mutableStyle()); | |
| 1964 if (newPseudoStyle) { | 1963 if (newPseudoStyle) { |
| 1965 firstLineStyleDidChange(*oldPseudoStyle, *newPseudoStyle); | 1964 firstLineStyleDidChange(*oldPseudoStyle, *newPseudoStyle); |
| 1966 return; | 1965 return; |
| 1967 } | 1966 } |
| 1968 } | 1967 } |
| 1969 } | 1968 } |
| 1970 setNeedsLayoutAndPrefWidthsRecalc(LayoutInvalidationReason::StyleChange); | 1969 setNeedsLayoutAndPrefWidthsRecalc(LayoutInvalidationReason::StyleChange); |
| 1971 } | 1970 } |
| 1972 | 1971 |
| 1973 void LayoutObject::propagateStyleToAnonymousChildren() { | 1972 void LayoutObject::propagateStyleToAnonymousChildren() { |
| (...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3024 if (layoutObject->isBeforeOrAfterContent()) | 3023 if (layoutObject->isBeforeOrAfterContent()) |
| 3025 layoutObjectForFirstLineStyle = layoutObject->parent(); | 3024 layoutObjectForFirstLineStyle = layoutObject->parent(); |
| 3026 | 3025 |
| 3027 if (layoutObjectForFirstLineStyle->behavesLikeBlockContainer()) { | 3026 if (layoutObjectForFirstLineStyle->behavesLikeBlockContainer()) { |
| 3028 if (const LayoutBlock* firstLineBlock = | 3027 if (const LayoutBlock* firstLineBlock = |
| 3029 toLayoutBlock(layoutObjectForFirstLineStyle) | 3028 toLayoutBlock(layoutObjectForFirstLineStyle) |
| 3030 ->enclosingFirstLineStyleBlock()) { | 3029 ->enclosingFirstLineStyleBlock()) { |
| 3031 if (type == Cached) | 3030 if (type == Cached) |
| 3032 return firstLineBlock->getCachedPseudoStyle(PseudoIdFirstLine, style); | 3031 return firstLineBlock->getCachedPseudoStyle(PseudoIdFirstLine, style); |
| 3033 return firstLineBlock->getUncachedPseudoStyle( | 3032 return firstLineBlock->getUncachedPseudoStyle( |
| 3034 PseudoStyleRequest(PseudoIdFirstLine), style, | 3033 PseudoStyleRequest(PseudoIdFirstLine), style); |
| 3035 firstLineBlock == layoutObject ? style : 0); | |
| 3036 } | 3034 } |
| 3037 } else if (!layoutObjectForFirstLineStyle->isAnonymous() && | 3035 } else if (!layoutObjectForFirstLineStyle->isAnonymous() && |
| 3038 layoutObjectForFirstLineStyle->isLayoutInline() && | 3036 layoutObjectForFirstLineStyle->isLayoutInline() && |
| 3039 !layoutObjectForFirstLineStyle->node() | 3037 !layoutObjectForFirstLineStyle->node() |
| 3040 ->isFirstLetterPseudoElement()) { | 3038 ->isFirstLetterPseudoElement()) { |
| 3041 const ComputedStyle* parentStyle = | 3039 const ComputedStyle* parentStyle = |
| 3042 layoutObjectForFirstLineStyle->parent()->firstLineStyle(); | 3040 layoutObjectForFirstLineStyle->parent()->firstLineStyle(); |
| 3043 if (parentStyle != layoutObjectForFirstLineStyle->parent()->style()) { | 3041 if (parentStyle != layoutObjectForFirstLineStyle->parent()->style()) { |
| 3044 if (type == Cached) { | 3042 if (type == Cached) { |
| 3045 // A first-line style is in effect. Cache a first-line style for | 3043 // A first-line style is in effect. Cache a first-line style for |
| 3046 // ourselves. | 3044 // ourselves. |
| 3047 layoutObjectForFirstLineStyle->mutableStyleRef().setHasPseudoStyle( | 3045 layoutObjectForFirstLineStyle->mutableStyleRef().setHasPseudoStyle( |
| 3048 PseudoIdFirstLineInherited); | 3046 PseudoIdFirstLineInherited); |
| 3049 return layoutObjectForFirstLineStyle->getCachedPseudoStyle( | 3047 return layoutObjectForFirstLineStyle->getCachedPseudoStyle( |
| 3050 PseudoIdFirstLineInherited, parentStyle); | 3048 PseudoIdFirstLineInherited, parentStyle); |
| 3051 } | 3049 } |
| 3052 return layoutObjectForFirstLineStyle->getUncachedPseudoStyle( | 3050 return layoutObjectForFirstLineStyle->getUncachedPseudoStyle( |
| 3053 PseudoStyleRequest(PseudoIdFirstLineInherited), parentStyle, style); | 3051 PseudoStyleRequest(PseudoIdFirstLineInherited), parentStyle); |
| 3054 } | 3052 } |
| 3055 } | 3053 } |
| 3056 return nullptr; | 3054 return nullptr; |
| 3057 } | 3055 } |
| 3058 | 3056 |
| 3059 PassRefPtr<ComputedStyle> LayoutObject::uncachedFirstLineStyle( | 3057 PassRefPtr<ComputedStyle> LayoutObject::uncachedFirstLineStyle() const { |
| 3060 ComputedStyle* style) const { | |
| 3061 if (!document().styleEngine().usesFirstLineRules()) | 3058 if (!document().styleEngine().usesFirstLineRules()) |
| 3062 return nullptr; | 3059 return nullptr; |
| 3063 | 3060 |
| 3064 ASSERT(!isText()); | 3061 ASSERT(!isText()); |
| 3065 | 3062 |
| 3066 return firstLineStyleForCachedUncachedType(Uncached, this, style); | 3063 return firstLineStyleForCachedUncachedType(Uncached, this, m_style.get()); |
| 3067 } | 3064 } |
| 3068 | 3065 |
| 3069 ComputedStyle* LayoutObject::cachedFirstLineStyle() const { | 3066 ComputedStyle* LayoutObject::cachedFirstLineStyle() const { |
| 3070 ASSERT(document().styleEngine().usesFirstLineRules()); | 3067 ASSERT(document().styleEngine().usesFirstLineRules()); |
| 3071 | 3068 |
| 3072 if (RefPtr<ComputedStyle> style = firstLineStyleForCachedUncachedType( | 3069 if (RefPtr<ComputedStyle> style = firstLineStyleForCachedUncachedType( |
| 3073 Cached, isText() ? parent() : this, m_style.get())) | 3070 Cached, isText() ? parent() : this, m_style.get())) |
| 3074 return style.get(); | 3071 return style.get(); |
| 3075 | 3072 |
| 3076 return m_style.get(); | 3073 return m_style.get(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 3088 | 3085 |
| 3089 RefPtr<ComputedStyle> result = | 3086 RefPtr<ComputedStyle> result = |
| 3090 getUncachedPseudoStyle(PseudoStyleRequest(pseudo), parentStyle); | 3087 getUncachedPseudoStyle(PseudoStyleRequest(pseudo), parentStyle); |
| 3091 if (result) | 3088 if (result) |
| 3092 return mutableStyleRef().addCachedPseudoStyle(result.release()); | 3089 return mutableStyleRef().addCachedPseudoStyle(result.release()); |
| 3093 return nullptr; | 3090 return nullptr; |
| 3094 } | 3091 } |
| 3095 | 3092 |
| 3096 PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyle( | 3093 PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyle( |
| 3097 const PseudoStyleRequest& pseudoStyleRequest, | 3094 const PseudoStyleRequest& pseudoStyleRequest, |
| 3098 const ComputedStyle* parentStyle, | 3095 const ComputedStyle* parentStyle) const { |
| 3099 const ComputedStyle* ownStyle) const { | 3096 if (pseudoStyleRequest.pseudoId < FirstInternalPseudoId && |
| 3100 if (pseudoStyleRequest.pseudoId < FirstInternalPseudoId && !ownStyle && | |
| 3101 !style()->hasPseudoStyle(pseudoStyleRequest.pseudoId)) | 3097 !style()->hasPseudoStyle(pseudoStyleRequest.pseudoId)) |
|
rune
2017/03/23 22:57:46
I'm not sure I understand this code, but it looks
| |
| 3102 return nullptr; | 3098 return nullptr; |
| 3103 | 3099 |
| 3104 if (!parentStyle) { | 3100 if (!parentStyle) |
| 3105 ASSERT(!ownStyle); | |
| 3106 parentStyle = style(); | 3101 parentStyle = style(); |
| 3107 } | |
| 3108 | 3102 |
| 3109 if (!node()) | 3103 if (!node()) |
| 3110 return nullptr; | 3104 return nullptr; |
| 3111 | 3105 |
| 3112 Element* element = Traversal<Element>::firstAncestorOrSelf(*node()); | 3106 Element* element = Traversal<Element>::firstAncestorOrSelf(*node()); |
| 3113 if (!element) | 3107 if (!element) |
| 3114 return nullptr; | 3108 return nullptr; |
| 3115 | 3109 |
| 3116 if (pseudoStyleRequest.pseudoId == PseudoIdFirstLineInherited) { | 3110 if (pseudoStyleRequest.pseudoId == PseudoIdFirstLineInherited) { |
| 3117 RefPtr<ComputedStyle> result = | 3111 RefPtr<ComputedStyle> result = |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3645 const blink::LayoutObject* root = object1; | 3639 const blink::LayoutObject* root = object1; |
| 3646 while (root->parent()) | 3640 while (root->parent()) |
| 3647 root = root->parent(); | 3641 root = root->parent(); |
| 3648 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3642 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
| 3649 } else { | 3643 } else { |
| 3650 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); | 3644 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); |
| 3651 } | 3645 } |
| 3652 } | 3646 } |
| 3653 | 3647 |
| 3654 #endif | 3648 #endif |
| OLD | NEW |