Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| index 21e6e9cd7f463c54dd4d7ea778c4bf3770bf49ad..73447261765a4737a68da8d128907c0eb7c736b5 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| @@ -725,11 +725,6 @@ bool LayoutObject::skipInvalidationWhenLaidOutChildren() const |
| return !hasBoxEffect(); |
| } |
| -LayoutBlock* LayoutObject::firstLineBlock() const |
| -{ |
| - return nullptr; |
| -} |
| - |
| static inline bool objectIsRelayoutBoundary(const LayoutObject* object) |
| { |
| // FIXME: In future it may be possible to broaden these conditions in order to improve performance. |
| @@ -1837,12 +1832,31 @@ void LayoutObject::setPseudoStyle(PassRefPtr<ComputedStyle> pseudoStyle) |
| void LayoutObject::firstLineStyleDidChange(const ComputedStyle& oldStyle, const ComputedStyle& newStyle) |
| { |
| StyleDifference diff = oldStyle.visualInvalidationDiff(newStyle); |
| - if (diff.hasDifference()) { |
| - // TODO(rune@opera.com): We should use the diff to determine whether a repaint vs. layout |
| - // is needed, but for now just assume a layout will be required. The diff code |
| - // in LayoutObject::setStyle would need to be factored out so that it could be reused. |
| - setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidationReason::StyleChange); |
| + |
| + if (diff.needsPaintInvalidation() || diff.textDecorationOrColorChanged()) { |
| + // We need to invalidate all inline boxes in the first line, because they need to be |
| + // repainted with the new style, e.g. background, font style, etc. |
| + LayoutBlockFlow* firstLineContainer = nullptr; |
| + if (canHaveFirstLineOrFirstLetterStyle()) { |
| + // This object is a LayoutBlock having FIRST_LINE pseudo style changed. |
| + firstLineContainer = toLayoutBlock(this)->nearestInnerBlockWithFirstLine(); |
| + } else if (isLayoutInline()) { |
| + // This object is a LayoutInline having FIRST_LINE_INHERITED pesudo style changed. |
| + // This method can be called even if the LayoutInline doesn't intersect the first line, |
| + // but we only need to invalidate only if it does. |
|
chrishtr
2015/12/07 18:06:03
Nit: remove second "only"
Xianzhu
2015/12/07 20:42:48
Done.
|
| + if (InlineBox* firstLineBox = toLayoutInline(this)->firstLineBoxIncludingCulling()) { |
| + if (firstLineBox->isFirstLineStyle()) |
| + firstLineContainer = toLayoutBlockFlow(containingBlock()); |
| + } |
| + } |
| + if (firstLineContainer) { |
| + firstLineContainer->invalidateDisplayItemClientsOfFirstLine(); |
| + if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
|
chrishtr
2015/12/07 18:06:03
Add a comment explaining why this is conditional o
Xianzhu
2015/12/07 20:42:48
Done.
|
| + firstLineContainer->setShouldDoFullPaintInvalidation(); |
| + } |
| } |
| + if (diff.needsLayout()) |
| + setNeedsLayoutAndPrefWidthsRecalc(LayoutInvalidationReason::StyleChange); |
| } |
| void LayoutObject::markContainingBlocksForOverflowRecalc() |
| @@ -2802,8 +2816,8 @@ static PassRefPtr<ComputedStyle> firstLineStyleForCachedUncachedType(StyleCacheS |
| if (layoutObject->isBeforeOrAfterContent()) |
| layoutObjectForFirstLineStyle = layoutObject->parent(); |
| - if (layoutObjectForFirstLineStyle->isLayoutBlockFlow() || layoutObjectForFirstLineStyle->isLayoutButton()) { |
| - if (LayoutBlock* firstLineBlock = layoutObjectForFirstLineStyle->firstLineBlock()) { |
| + if (layoutObjectForFirstLineStyle->canHaveFirstLineOrFirstLetterStyle()) { |
| + if (LayoutBlock* firstLineBlock = toLayoutBlock(layoutObjectForFirstLineStyle)->enclosingFirstLineStyleBlock()) { |
| if (type == Cached) |
| return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style); |
| return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(FIRST_LINE), style, firstLineBlock == layoutObject ? style : 0); |