| 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. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. |
| 7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1864 if (diff.needsPaintInvalidationLayer() && !hasLayer()) { | 1864 if (diff.needsPaintInvalidationLayer() && !hasLayer()) { |
| 1865 diff.clearNeedsPaintInvalidation(); | 1865 diff.clearNeedsPaintInvalidation(); |
| 1866 diff.setNeedsPaintInvalidationObject(); | 1866 diff.setNeedsPaintInvalidationObject(); |
| 1867 } | 1867 } |
| 1868 | 1868 |
| 1869 return diff; | 1869 return diff; |
| 1870 } | 1870 } |
| 1871 | 1871 |
| 1872 void LayoutObject::setPseudoStyle(PassRefPtr<ComputedStyle> pseudoStyle) | 1872 void LayoutObject::setPseudoStyle(PassRefPtr<ComputedStyle> pseudoStyle) |
| 1873 { | 1873 { |
| 1874 ASSERT(pseudoStyle->styleType() == BEFORE || pseudoStyle->styleType() == AFT
ER || pseudoStyle->styleType() == FIRST_LETTER); | 1874 ASSERT(pseudoStyle->styleType() == PseudoIdBefore || pseudoStyle->styleType(
) == PseudoIdAfter || pseudoStyle->styleType() == PseudoIdFirstLetter); |
| 1875 | 1875 |
| 1876 // FIXME: We should consider just making all pseudo items use an inherited s
tyle. | 1876 // FIXME: We should consider just making all pseudo items use an inherited s
tyle. |
| 1877 | 1877 |
| 1878 // Images are special and must inherit the pseudoStyle so the width and heig
ht of | 1878 // Images are special and must inherit the pseudoStyle so the width and heig
ht of |
| 1879 // the pseudo element doesn't change the size of the image. In all other cas
es we | 1879 // the pseudo element doesn't change the size of the image. In all other cas
es we |
| 1880 // can just share the style. | 1880 // can just share the style. |
| 1881 // | 1881 // |
| 1882 // Quotes are also LayoutInline, so we need to create an inherited style to
avoid | 1882 // Quotes are also LayoutInline, so we need to create an inherited style to
avoid |
| 1883 // getting an inline with positioning or an invalid display. | 1883 // getting an inline with positioning or an invalid display. |
| 1884 // | 1884 // |
| 1885 if (isImage() || isQuote()) { | 1885 if (isImage() || isQuote()) { |
| 1886 RefPtr<ComputedStyle> style = ComputedStyle::create(); | 1886 RefPtr<ComputedStyle> style = ComputedStyle::create(); |
| 1887 style->inheritFrom(*pseudoStyle); | 1887 style->inheritFrom(*pseudoStyle); |
| 1888 setStyle(style.release()); | 1888 setStyle(style.release()); |
| 1889 return; | 1889 return; |
| 1890 } | 1890 } |
| 1891 | 1891 |
| 1892 setStyle(pseudoStyle); | 1892 setStyle(pseudoStyle); |
| 1893 } | 1893 } |
| 1894 | 1894 |
| 1895 void LayoutObject::firstLineStyleDidChange(const ComputedStyle& oldStyle, const
ComputedStyle& newStyle) | 1895 void LayoutObject::firstLineStyleDidChange(const ComputedStyle& oldStyle, const
ComputedStyle& newStyle) |
| 1896 { | 1896 { |
| 1897 StyleDifference diff = oldStyle.visualInvalidationDiff(newStyle); | 1897 StyleDifference diff = oldStyle.visualInvalidationDiff(newStyle); |
| 1898 | 1898 |
| 1899 if (diff.needsPaintInvalidation() || diff.textDecorationOrColorChanged()) { | 1899 if (diff.needsPaintInvalidation() || diff.textDecorationOrColorChanged()) { |
| 1900 // We need to invalidate all inline boxes in the first line, because the
y need to be | 1900 // We need to invalidate all inline boxes in the first line, because the
y need to be |
| 1901 // repainted with the new style, e.g. background, font style, etc. | 1901 // repainted with the new style, e.g. background, font style, etc. |
| 1902 LayoutBlockFlow* firstLineContainer = nullptr; | 1902 LayoutBlockFlow* firstLineContainer = nullptr; |
| 1903 if (canHaveFirstLineOrFirstLetterStyle()) { | 1903 if (canHaveFirstLineOrFirstLetterStyle()) { |
| 1904 // This object is a LayoutBlock having FIRST_LINE pseudo style chang
ed. | 1904 // This object is a LayoutBlock having PseudoIdFirstLine pseudo styl
e changed. |
| 1905 firstLineContainer = toLayoutBlock(this)->nearestInnerBlockWithFirst
Line(); | 1905 firstLineContainer = toLayoutBlock(this)->nearestInnerBlockWithFirst
Line(); |
| 1906 } else if (isLayoutInline()) { | 1906 } else if (isLayoutInline()) { |
| 1907 // This object is a LayoutInline having FIRST_LINE_INHERITED pesudo
style changed. | 1907 // This object is a LayoutInline having FIRST_LINE_INHERITED pesudo
style changed. |
| 1908 // This method can be called even if the LayoutInline doesn't inters
ect the first line, | 1908 // This method can be called even if the LayoutInline doesn't inters
ect the first line, |
| 1909 // but we only need to invalidate if it does. | 1909 // but we only need to invalidate if it does. |
| 1910 if (InlineBox* firstLineBox = toLayoutInline(this)->firstLineBoxIncl
udingCulling()) { | 1910 if (InlineBox* firstLineBox = toLayoutInline(this)->firstLineBoxIncl
udingCulling()) { |
| 1911 if (firstLineBox->isFirstLineStyle()) | 1911 if (firstLineBox->isFirstLineStyle()) |
| 1912 firstLineContainer = toLayoutBlockFlow(containingBlock()); | 1912 firstLineContainer = toLayoutBlockFlow(containingBlock()); |
| 1913 } | 1913 } |
| 1914 } | 1914 } |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2123 // to PageEventHandler. | 2123 // to PageEventHandler. |
| 2124 frame->localFrameRoot()->eventHandler().scheduleCursorUpdate(); | 2124 frame->localFrameRoot()->eventHandler().scheduleCursorUpdate(); |
| 2125 } | 2125 } |
| 2126 } | 2126 } |
| 2127 } | 2127 } |
| 2128 | 2128 |
| 2129 void LayoutObject::propagateStyleToAnonymousChildren(bool blockChildrenOnly) | 2129 void LayoutObject::propagateStyleToAnonymousChildren(bool blockChildrenOnly) |
| 2130 { | 2130 { |
| 2131 // FIXME: We could save this call when the change only affected non-inherite
d properties. | 2131 // FIXME: We could save this call when the change only affected non-inherite
d properties. |
| 2132 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli
ng()) { | 2132 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli
ng()) { |
| 2133 if (!child->isAnonymous() || child->style()->styleType() != NOPSEUDO) | 2133 if (!child->isAnonymous() || child->style()->styleType() != PseudoIdNone
) |
| 2134 continue; | 2134 continue; |
| 2135 | 2135 |
| 2136 if (blockChildrenOnly && !child->isLayoutBlock()) | 2136 if (blockChildrenOnly && !child->isLayoutBlock()) |
| 2137 continue; | 2137 continue; |
| 2138 | 2138 |
| 2139 if (child->isLayoutFullScreen() || child->isLayoutFullScreenPlaceholder(
)) | 2139 if (child->isLayoutFullScreen() || child->isLayoutFullScreenPlaceholder(
)) |
| 2140 continue; | 2140 continue; |
| 2141 | 2141 |
| 2142 RefPtr<ComputedStyle> newStyle = ComputedStyle::createAnonymousStyleWith
Display(styleRef(), child->style()->display()); | 2142 RefPtr<ComputedStyle> newStyle = ComputedStyle::createAnonymousStyleWith
Display(styleRef(), child->style()->display()); |
| 2143 | 2143 |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3022 | 3022 |
| 3023 static PassRefPtr<ComputedStyle> firstLineStyleForCachedUncachedType(StyleCacheS
tate type, const LayoutObject* layoutObject, ComputedStyle* style) | 3023 static PassRefPtr<ComputedStyle> firstLineStyleForCachedUncachedType(StyleCacheS
tate type, const LayoutObject* layoutObject, ComputedStyle* style) |
| 3024 { | 3024 { |
| 3025 const LayoutObject* layoutObjectForFirstLineStyle = layoutObject; | 3025 const LayoutObject* layoutObjectForFirstLineStyle = layoutObject; |
| 3026 if (layoutObject->isBeforeOrAfterContent()) | 3026 if (layoutObject->isBeforeOrAfterContent()) |
| 3027 layoutObjectForFirstLineStyle = layoutObject->parent(); | 3027 layoutObjectForFirstLineStyle = layoutObject->parent(); |
| 3028 | 3028 |
| 3029 if (layoutObjectForFirstLineStyle->canHaveFirstLineOrFirstLetterStyle()) { | 3029 if (layoutObjectForFirstLineStyle->canHaveFirstLineOrFirstLetterStyle()) { |
| 3030 if (LayoutBlock* firstLineBlock = toLayoutBlock(layoutObjectForFirstLine
Style)->enclosingFirstLineStyleBlock()) { | 3030 if (LayoutBlock* firstLineBlock = toLayoutBlock(layoutObjectForFirstLine
Style)->enclosingFirstLineStyleBlock()) { |
| 3031 if (type == Cached) | 3031 if (type == Cached) |
| 3032 return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style); | 3032 return firstLineBlock->getCachedPseudoStyle(PseudoIdFirstLine, s
tyle); |
| 3033 return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(FIR
ST_LINE), style, firstLineBlock == layoutObject ? style : 0); | 3033 return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(Pse
udoIdFirstLine), style, firstLineBlock == layoutObject ? style : 0); |
| 3034 } | 3034 } |
| 3035 } else if (!layoutObjectForFirstLineStyle->isAnonymous() && layoutObjectForF
irstLineStyle->isLayoutInline() | 3035 } else if (!layoutObjectForFirstLineStyle->isAnonymous() && layoutObjectForF
irstLineStyle->isLayoutInline() |
| 3036 && !layoutObjectForFirstLineStyle->node()->isFirstLetterPseudoElement())
{ | 3036 && !layoutObjectForFirstLineStyle->node()->isFirstLetterPseudoElement())
{ |
| 3037 const ComputedStyle* parentStyle = layoutObjectForFirstLineStyle->parent
()->firstLineStyle(); | 3037 const ComputedStyle* parentStyle = layoutObjectForFirstLineStyle->parent
()->firstLineStyle(); |
| 3038 if (parentStyle != layoutObjectForFirstLineStyle->parent()->style()) { | 3038 if (parentStyle != layoutObjectForFirstLineStyle->parent()->style()) { |
| 3039 if (type == Cached) { | 3039 if (type == Cached) { |
| 3040 // A first-line style is in effect. Cache a first-line style for
ourselves. | 3040 // A first-line style is in effect. Cache a first-line style for
ourselves. |
| 3041 layoutObjectForFirstLineStyle->mutableStyleRef().setHasPseudoSty
le(FIRST_LINE_INHERITED); | 3041 layoutObjectForFirstLineStyle->mutableStyleRef().setHasPseudoSty
le(PseudoIdFirstLineInherited); |
| 3042 return layoutObjectForFirstLineStyle->getCachedPseudoStyle(FIRST
_LINE_INHERITED, parentStyle); | 3042 return layoutObjectForFirstLineStyle->getCachedPseudoStyle(Pseud
oIdFirstLineInherited, parentStyle); |
| 3043 } | 3043 } |
| 3044 return layoutObjectForFirstLineStyle->getUncachedPseudoStyle(PseudoS
tyleRequest(FIRST_LINE_INHERITED), parentStyle, style); | 3044 return layoutObjectForFirstLineStyle->getUncachedPseudoStyle(PseudoS
tyleRequest(PseudoIdFirstLineInherited), parentStyle, style); |
| 3045 } | 3045 } |
| 3046 } | 3046 } |
| 3047 return nullptr; | 3047 return nullptr; |
| 3048 } | 3048 } |
| 3049 | 3049 |
| 3050 PassRefPtr<ComputedStyle> LayoutObject::uncachedFirstLineStyle(ComputedStyle* st
yle) const | 3050 PassRefPtr<ComputedStyle> LayoutObject::uncachedFirstLineStyle(ComputedStyle* st
yle) const |
| 3051 { | 3051 { |
| 3052 if (!document().styleEngine().usesFirstLineRules()) | 3052 if (!document().styleEngine().usesFirstLineRules()) |
| 3053 return nullptr; | 3053 return nullptr; |
| 3054 | 3054 |
| 3055 ASSERT(!isText()); | 3055 ASSERT(!isText()); |
| 3056 | 3056 |
| 3057 return firstLineStyleForCachedUncachedType(Uncached, this, style); | 3057 return firstLineStyleForCachedUncachedType(Uncached, this, style); |
| 3058 } | 3058 } |
| 3059 | 3059 |
| 3060 ComputedStyle* LayoutObject::cachedFirstLineStyle() const | 3060 ComputedStyle* LayoutObject::cachedFirstLineStyle() const |
| 3061 { | 3061 { |
| 3062 ASSERT(document().styleEngine().usesFirstLineRules()); | 3062 ASSERT(document().styleEngine().usesFirstLineRules()); |
| 3063 | 3063 |
| 3064 if (RefPtr<ComputedStyle> style = firstLineStyleForCachedUncachedType(Cached
, isText() ? parent() : this, m_style.get())) | 3064 if (RefPtr<ComputedStyle> style = firstLineStyleForCachedUncachedType(Cached
, isText() ? parent() : this, m_style.get())) |
| 3065 return style.get(); | 3065 return style.get(); |
| 3066 | 3066 |
| 3067 return m_style.get(); | 3067 return m_style.get(); |
| 3068 } | 3068 } |
| 3069 | 3069 |
| 3070 ComputedStyle* LayoutObject::getCachedPseudoStyle(PseudoId pseudo, const Compute
dStyle* parentStyle) const | 3070 ComputedStyle* LayoutObject::getCachedPseudoStyle(PseudoId pseudo, const Compute
dStyle* parentStyle) const |
| 3071 { | 3071 { |
| 3072 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo)) | 3072 if (pseudo < FirstInternalPseudoId && !style()->hasPseudoStyle(pseudo)) |
| 3073 return nullptr; | 3073 return nullptr; |
| 3074 | 3074 |
| 3075 ComputedStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo); | 3075 ComputedStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo); |
| 3076 if (cachedStyle) | 3076 if (cachedStyle) |
| 3077 return cachedStyle; | 3077 return cachedStyle; |
| 3078 | 3078 |
| 3079 RefPtr<ComputedStyle> result = getUncachedPseudoStyle(PseudoStyleRequest(pse
udo), parentStyle); | 3079 RefPtr<ComputedStyle> result = getUncachedPseudoStyle(PseudoStyleRequest(pse
udo), parentStyle); |
| 3080 if (result) | 3080 if (result) |
| 3081 return mutableStyleRef().addCachedPseudoStyle(result.release()); | 3081 return mutableStyleRef().addCachedPseudoStyle(result.release()); |
| 3082 return nullptr; | 3082 return nullptr; |
| 3083 } | 3083 } |
| 3084 | 3084 |
| 3085 PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyle(const PseudoStyle
Request& pseudoStyleRequest, const ComputedStyle* parentStyle, const ComputedSty
le* ownStyle) const | 3085 PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyle(const PseudoStyle
Request& pseudoStyleRequest, const ComputedStyle* parentStyle, const ComputedSty
le* ownStyle) const |
| 3086 { | 3086 { |
| 3087 if (pseudoStyleRequest.pseudoId < FIRST_INTERNAL_PSEUDOID && !ownStyle && !s
tyle()->hasPseudoStyle(pseudoStyleRequest.pseudoId)) | 3087 if (pseudoStyleRequest.pseudoId < FirstInternalPseudoId && !ownStyle && !sty
le()->hasPseudoStyle(pseudoStyleRequest.pseudoId)) |
| 3088 return nullptr; | 3088 return nullptr; |
| 3089 | 3089 |
| 3090 if (!parentStyle) { | 3090 if (!parentStyle) { |
| 3091 ASSERT(!ownStyle); | 3091 ASSERT(!ownStyle); |
| 3092 parentStyle = style(); | 3092 parentStyle = style(); |
| 3093 } | 3093 } |
| 3094 | 3094 |
| 3095 if (!node()) | 3095 if (!node()) |
| 3096 return nullptr; | 3096 return nullptr; |
| 3097 | 3097 |
| 3098 Element* element = Traversal<Element>::firstAncestorOrSelf(*node()); | 3098 Element* element = Traversal<Element>::firstAncestorOrSelf(*node()); |
| 3099 if (!element) | 3099 if (!element) |
| 3100 return nullptr; | 3100 return nullptr; |
| 3101 | 3101 |
| 3102 if (pseudoStyleRequest.pseudoId == FIRST_LINE_INHERITED) { | 3102 if (pseudoStyleRequest.pseudoId == PseudoIdFirstLineInherited) { |
| 3103 RefPtr<ComputedStyle> result = document().ensureStyleResolver().styleFor
Element(element, parentStyle, DisallowStyleSharing); | 3103 RefPtr<ComputedStyle> result = document().ensureStyleResolver().styleFor
Element(element, parentStyle, DisallowStyleSharing); |
| 3104 result->setStyleType(FIRST_LINE_INHERITED); | 3104 result->setStyleType(PseudoIdFirstLineInherited); |
| 3105 return result.release(); | 3105 return result.release(); |
| 3106 } | 3106 } |
| 3107 | 3107 |
| 3108 return document().ensureStyleResolver().pseudoStyleForElement(element, pseud
oStyleRequest, parentStyle); | 3108 return document().ensureStyleResolver().pseudoStyleForElement(element, pseud
oStyleRequest, parentStyle); |
| 3109 } | 3109 } |
| 3110 | 3110 |
| 3111 PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyleFromParentOrShadow
Host() const | 3111 PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyleFromParentOrShadow
Host() const |
| 3112 { | 3112 { |
| 3113 if (!node()) | 3113 if (!node()) |
| 3114 return nullptr; | 3114 return nullptr; |
| 3115 | 3115 |
| 3116 if (ShadowRoot* root = node()->containingShadowRoot()) { | 3116 if (ShadowRoot* root = node()->containingShadowRoot()) { |
| 3117 if (root->type() == ShadowRootType::UserAgent) { | 3117 if (root->type() == ShadowRootType::UserAgent) { |
| 3118 if (Element* shadowHost = node()->shadowHost()) { | 3118 if (Element* shadowHost = node()->shadowHost()) { |
| 3119 return shadowHost->layoutObject()->getUncachedPseudoStyle(Pseudo
StyleRequest(SELECTION)); | 3119 return shadowHost->layoutObject()->getUncachedPseudoStyle(Pseudo
StyleRequest(PseudoIdSelection)); |
| 3120 } | 3120 } |
| 3121 } | 3121 } |
| 3122 } | 3122 } |
| 3123 | 3123 |
| 3124 return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)); | 3124 return getUncachedPseudoStyle(PseudoStyleRequest(PseudoIdSelection)); |
| 3125 } | 3125 } |
| 3126 | 3126 |
| 3127 void LayoutObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio
n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug
h, bool quirksMode, bool firstlineStyle) | 3127 void LayoutObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio
n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug
h, bool quirksMode, bool firstlineStyle) |
| 3128 { | 3128 { |
| 3129 LayoutObject* curr = this; | 3129 LayoutObject* curr = this; |
| 3130 const ComputedStyle* styleToUse = nullptr; | 3130 const ComputedStyle* styleToUse = nullptr; |
| 3131 unsigned currDecs = TextDecorationNone; | 3131 unsigned currDecs = TextDecorationNone; |
| 3132 Color resultColor; | 3132 Color resultColor; |
| 3133 TextDecorationStyle resultStyle; | 3133 TextDecorationStyle resultStyle; |
| 3134 do { | 3134 do { |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3731 const blink::LayoutObject* root = object1; | 3731 const blink::LayoutObject* root = object1; |
| 3732 while (root->parent()) | 3732 while (root->parent()) |
| 3733 root = root->parent(); | 3733 root = root->parent(); |
| 3734 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3734 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
| 3735 } else { | 3735 } else { |
| 3736 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); | 3736 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); |
| 3737 } | 3737 } |
| 3738 } | 3738 } |
| 3739 | 3739 |
| 3740 #endif | 3740 #endif |
| OLD | NEW |