Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1242)

Unified Diff: Source/core/layout/LayoutInline.cpp

Issue 1215023010: Fix style propagation to continuations (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix bug again Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/platform/linux/fast/repaint/outline-continuations-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutInline.cpp
diff --git a/Source/core/layout/LayoutInline.cpp b/Source/core/layout/LayoutInline.cpp
index ae7e9c3cdd9abf5581d0a9329bc7ba5880da9a6f..0fe8e2b0a77bdd1f253d198a9ca24e3bf33d950c 100644
--- a/Source/core/layout/LayoutInline.cpp
+++ b/Source/core/layout/LayoutInline.cpp
@@ -151,32 +151,32 @@ static LayoutObject* inFlowPositionedInlineAncestor(LayoutObject* p)
return nullptr;
}
-static void updateStyleOfAnonymousBlockContinuations(LayoutObject* block, const ComputedStyle& newStyle, const ComputedStyle& oldStyle)
+static void updateStyleOfAnonymousBlockContinuations(LayoutObject* block, const ComputedStyle& newStyle, const ComputedStyle& oldStyle, LayoutObject* containingBlockOfEndOfContinuation)
{
- for (;block && block->isAnonymousBlock(); block = block->nextSibling()) {
+ // If an inline's outline or in-flow positioning has changed then any descendant blocks will need to change their styles accordingly.
+ bool updateOutline = !newStyle.isOutlineEquivalent(&oldStyle);
+ bool updatePosition = newStyle.position() != oldStyle.position() && (newStyle.hasInFlowPosition() || oldStyle.hasInFlowPosition());
+ if (!updateOutline && !updatePosition)
+ return;
+
+ for (; block && block != containingBlockOfEndOfContinuation && block->isAnonymousBlock(); block = block->nextSibling()) {
if (!toLayoutBlock(block)->isAnonymousBlockContinuation())
continue;
- RefPtr<ComputedStyle> newBlockStyle;
+ RefPtr<ComputedStyle> newBlockStyle = ComputedStyle::clone(block->styleRef());
- if (!block->style()->isOutlineEquivalent(&newStyle)) {
- newBlockStyle = ComputedStyle::clone(block->styleRef());
+ if (updateOutline)
newBlockStyle->setOutlineFromStyle(newStyle);
- }
- if (block->style()->position() != newStyle.position()) {
+ if (updatePosition) {
// If we are no longer in-flow positioned but our descendant block(s) still have an in-flow positioned ancestor then
// their containing anonymous block should keep its in-flow positioning.
- if (oldStyle.hasInFlowPosition()
- && inFlowPositionedInlineAncestor(toLayoutBlock(block)->inlineElementContinuation()))
+ if (oldStyle.hasInFlowPosition() && inFlowPositionedInlineAncestor(toLayoutBlock(block)->inlineElementContinuation()))
continue;
- if (!newBlockStyle)
- newBlockStyle = ComputedStyle::clone(block->styleRef());
newBlockStyle->setPosition(newStyle.position());
}
- if (newBlockStyle)
- block->setStyle(newBlockStyle);
+ block->setStyle(newBlockStyle);
}
}
@@ -192,22 +192,20 @@ void LayoutInline::styleDidChange(StyleDifference diff, const ComputedStyle* old
// need to pass its style on to anyone else.
const ComputedStyle& newStyle = styleRef();
LayoutInline* continuation = inlineElementContinuation();
+ LayoutInline* endOfContinuation = nullptr;
for (LayoutInline* currCont = continuation; currCont; currCont = currCont->inlineElementContinuation()) {
LayoutBoxModelObject* nextCont = currCont->continuation();
currCont->setContinuation(nullptr);
currCont->setStyle(mutableStyle());
currCont->setContinuation(nextCont);
+ endOfContinuation = currCont;
}
- // If an inline's outline or in-flow positioning has changed then any descendant blocks will need to change their styles accordingly.
- // Do this by updating the styles of the descendant blocks' containing anonymous blocks - there may be more than one.
- if (continuation && oldStyle
- && (!newStyle.isOutlineEquivalent(oldStyle)
- || (newStyle.position() != oldStyle->position() && (newStyle.hasInFlowPosition() || oldStyle->hasInFlowPosition())))) {
- // If any descendant blocks exist then they will be in the next anonymous block and its siblings.
+ if (continuation && oldStyle) {
+ ASSERT(endOfContinuation);
LayoutObject* block = containingBlock()->nextSibling();
if (block && block->isAnonymousBlock())
- updateStyleOfAnonymousBlockContinuations(block, newStyle, *oldStyle);
+ updateStyleOfAnonymousBlockContinuations(block, newStyle, *oldStyle, endOfContinuation->containingBlock());
}
if (!alwaysCreateLineBoxes()) {
« no previous file with comments | « LayoutTests/platform/linux/fast/repaint/outline-continuations-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698