Cleanup RenderInline style propagation to continuations

- Remove unnecessary RenderInline::setContinuation(). Push outline style
  in RenderInline::addChildIgnoringContinuation() along with original
  style propagation for 'position'.
- In updateStyleOfAnonymousBlockContinuations() create newBlockStyle
  only once. Fixed original issue when pushing 'position' by replacing
  createAnonymousStyleWithDisplay() with RenderStyle::clone().
  The issue caused just-set outline style to be lost because
  createAnonymousStyleWithDisplay() doesn't copy non-inherited styles.

BUG=405222
TEST=refactory only, no functional change

Review URL: https://codereview.chromium.org/538213002

git-svn-id: svn://svn.chromium.org/blink/trunk@181566 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 317a9c13
...@@ -254,7 +254,7 @@ protected: ...@@ -254,7 +254,7 @@ protected:
InterpolationQuality chooseInterpolationQuality(GraphicsContext*, Image*, const void*, const LayoutSize&); InterpolationQuality chooseInterpolationQuality(GraphicsContext*, Image*, const void*, const LayoutSize&);
RenderBoxModelObject* continuation() const; RenderBoxModelObject* continuation() const;
virtual void setContinuation(RenderBoxModelObject*); void setContinuation(RenderBoxModelObject*);
LayoutRect localCaretRectForEmptyElement(LayoutUnit width, LayoutUnit textIndentOffset); LayoutRect localCaretRectForEmptyElement(LayoutUnit width, LayoutUnit textIndentOffset);
......
...@@ -162,10 +162,11 @@ static void updateStyleOfAnonymousBlockContinuations(RenderObject* block, const ...@@ -162,10 +162,11 @@ static void updateStyleOfAnonymousBlockContinuations(RenderObject* block, const
if (!toRenderBlock(block)->isAnonymousBlockContinuation()) if (!toRenderBlock(block)->isAnonymousBlockContinuation())
continue; continue;
RefPtr<RenderStyle> newBlockStyle;
if (!block->style()->isOutlineEquivalent(newStyle)) { if (!block->style()->isOutlineEquivalent(newStyle)) {
RefPtr<RenderStyle> blockStyle = RenderStyle::clone(block->style()); newBlockStyle = RenderStyle::clone(block->style());
blockStyle->setOutlineFromStyle(*newStyle); newBlockStyle->setOutlineFromStyle(*newStyle);
block->setStyle(blockStyle);
} }
if (block->style()->position() != newStyle->position()) { if (block->style()->position() != newStyle->position()) {
...@@ -174,12 +175,13 @@ static void updateStyleOfAnonymousBlockContinuations(RenderObject* block, const ...@@ -174,12 +175,13 @@ static void updateStyleOfAnonymousBlockContinuations(RenderObject* block, const
if (oldStyle->hasInFlowPosition() if (oldStyle->hasInFlowPosition()
&& inFlowPositionedInlineAncestor(toRenderBlock(block)->inlineElementContinuation())) && inFlowPositionedInlineAncestor(toRenderBlock(block)->inlineElementContinuation()))
continue; continue;
// FIXME: We should share blockStyle with the outline case, but it fails layout tests if (!newBlockStyle)
// for dynamic position change of inlines containing block continuations. crbug.com/405222. newBlockStyle = RenderStyle::clone(block->style());
RefPtr<RenderStyle> blockStyle = RenderStyle::createAnonymousStyleWithDisplay(block->style(), BLOCK); newBlockStyle->setPosition(newStyle->position());
blockStyle->setPosition(newStyle->position());
block->setStyle(blockStyle);
} }
if (newBlockStyle)
block->setStyle(newBlockStyle);
} }
} }
...@@ -202,8 +204,8 @@ void RenderInline::styleDidChange(StyleDifference diff, const RenderStyle* oldSt ...@@ -202,8 +204,8 @@ void RenderInline::styleDidChange(StyleDifference diff, const RenderStyle* oldSt
currCont->setContinuation(nextCont); currCont->setContinuation(nextCont);
} }
// If an inline's in-flow positioning has changed then any descendant blocks will need to change their in-flow positioning accordingly. // 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 position of the descendant blocks' containing anonymous blocks - there may be more than one. // Do this by updating the styles of the descendant blocks' containing anonymous blocks - there may be more than one.
if (continuation && oldStyle if (continuation && oldStyle
&& (!newStyle->isOutlineEquivalent(oldStyle) && (!newStyle->isOutlineEquivalent(oldStyle)
|| (newStyle->position() != oldStyle->position() && (newStyle->hasInFlowPosition() || oldStyle->hasInFlowPosition())))) { || (newStyle->position() != oldStyle->position() && (newStyle->hasInFlowPosition() || oldStyle->hasInFlowPosition())))) {
...@@ -223,18 +225,6 @@ void RenderInline::styleDidChange(StyleDifference diff, const RenderStyle* oldSt ...@@ -223,18 +225,6 @@ void RenderInline::styleDidChange(StyleDifference diff, const RenderStyle* oldSt
} }
} }
void RenderInline::setContinuation(RenderBoxModelObject* continuation)
{
RenderBoxModelObject::setContinuation(continuation);
if (continuation && continuation->isAnonymousBlock() && !continuation->style()->isOutlineEquivalent(style())) {
// Push outline style to the block continuation.
RefPtr<RenderStyle> blockStyle = RenderStyle::clone(continuation->style());
blockStyle->setOutlineFromStyle(*style());
continuation->setStyle(blockStyle);
}
// FIXME: What if continuation is added when the inline has relative position? crbug.com/405222.
}
void RenderInline::updateAlwaysCreateLineBoxes(bool fullLayout) void RenderInline::updateAlwaysCreateLineBoxes(bool fullLayout)
{ {
// Once we have been tainted once, just assume it will happen again. This way effects like hover highlighting that change the // Once we have been tainted once, just assume it will happen again. This way effects like hover highlighting that change the
...@@ -349,6 +339,10 @@ void RenderInline::addChildIgnoringContinuation(RenderObject* newChild, RenderOb ...@@ -349,6 +339,10 @@ void RenderInline::addChildIgnoringContinuation(RenderObject* newChild, RenderOb
if (RenderObject* positionedAncestor = inFlowPositionedInlineAncestor(this)) if (RenderObject* positionedAncestor = inFlowPositionedInlineAncestor(this))
newStyle->setPosition(positionedAncestor->style()->position()); newStyle->setPosition(positionedAncestor->style()->position());
// Push outline style to the block continuation.
if (!newStyle->isOutlineEquivalent(style()))
newStyle->setOutlineFromStyle(*style());
RenderBlockFlow* newBox = RenderBlockFlow::createAnonymous(&document()); RenderBlockFlow* newBox = RenderBlockFlow::createAnonymous(&document());
newBox->setStyle(newStyle.release()); newBox->setStyle(newStyle.release());
RenderBoxModelObject* oldContinuation = continuation(); RenderBoxModelObject* oldContinuation = continuation();
......
...@@ -89,7 +89,7 @@ public: ...@@ -89,7 +89,7 @@ public:
void paintOutline(PaintInfo&, const LayoutPoint&); void paintOutline(PaintInfo&, const LayoutPoint&);
using RenderBoxModelObject::continuation; using RenderBoxModelObject::continuation;
virtual void setContinuation(RenderBoxModelObject*) OVERRIDE FINAL; using RenderBoxModelObject::setContinuation;
bool alwaysCreateLineBoxes() const { return alwaysCreateLineBoxesForRenderInline(); } bool alwaysCreateLineBoxes() const { return alwaysCreateLineBoxesForRenderInline(); }
void setAlwaysCreateLineBoxes(bool alwaysCreateLineBoxes = true) { setAlwaysCreateLineBoxesForRenderInline(alwaysCreateLineBoxes); } void setAlwaysCreateLineBoxes(bool alwaysCreateLineBoxes = true) { setAlwaysCreateLineBoxesForRenderInline(alwaysCreateLineBoxes); }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment