summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/core/rendering/InlineFlowBox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/rendering/InlineFlowBox.cpp')
-rw-r--r--chromium/third_party/WebKit/Source/core/rendering/InlineFlowBox.cpp345
1 files changed, 186 insertions, 159 deletions
diff --git a/chromium/third_party/WebKit/Source/core/rendering/InlineFlowBox.cpp b/chromium/third_party/WebKit/Source/core/rendering/InlineFlowBox.cpp
index 68952fc6e18..b3384b2e33c 100644
--- a/chromium/third_party/WebKit/Source/core/rendering/InlineFlowBox.cpp
+++ b/chromium/third_party/WebKit/Source/core/rendering/InlineFlowBox.cpp
@@ -20,7 +20,7 @@
#include "config.h"
#include "core/rendering/InlineFlowBox.h"
-#include "CSSPropertyNames.h"
+#include "core/CSSPropertyNames.h"
#include "core/dom/Document.h"
#include "core/rendering/HitTestResult.h"
#include "core/rendering/InlineTextBox.h"
@@ -109,7 +109,7 @@ void InlineFlowBox::addToLine(InlineBox* child)
child->setFirstLineStyleBit(isFirstLineStyle());
child->setIsHorizontal(isHorizontal());
if (child->isText()) {
- if (child->renderer()->parent() == renderer())
+ if (child->renderer().parent() == renderer())
m_hasTextChildren = true;
setHasTextDescendantsOnAncestors(this);
} else if (child->isInlineFlowBox()) {
@@ -117,14 +117,14 @@ void InlineFlowBox::addToLine(InlineBox* child)
setHasTextDescendantsOnAncestors(this);
}
- if (descendantsHaveSameLineHeightAndBaseline() && !child->renderer()->isOutOfFlowPositioned()) {
- RenderStyle* parentStyle = renderer()->style(isFirstLineStyle());
- RenderStyle* childStyle = child->renderer()->style(isFirstLineStyle());
+ if (descendantsHaveSameLineHeightAndBaseline() && !child->renderer().isOutOfFlowPositioned()) {
+ RenderStyle* parentStyle = renderer().style(isFirstLineStyle());
+ RenderStyle* childStyle = child->renderer().style(isFirstLineStyle());
bool shouldClearDescendantsHaveSameLineHeightAndBaseline = false;
- if (child->renderer()->isReplaced())
+ if (child->renderer().isReplaced())
shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
else if (child->isText()) {
- if (child->renderer()->isBR() || child->renderer()->parent() != renderer()) {
+ if (child->renderer().isBR() || child->renderer().parent() != renderer()) {
if (!parentStyle->font().fontMetrics().hasIdenticalAscentDescentAndLineGap(childStyle->font().fontMetrics())
|| parentStyle->lineHeight() != childStyle->lineHeight()
|| (parentStyle->verticalAlign() != BASELINE && !isRootInlineBox()) || childStyle->verticalAlign() != BASELINE)
@@ -133,7 +133,7 @@ void InlineFlowBox::addToLine(InlineBox* child)
if (childStyle->hasTextCombine() || childStyle->textEmphasisMark() != TextEmphasisMarkNone)
shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
} else {
- if (child->renderer()->isBR()) {
+ if (child->renderer().isBR()) {
// FIXME: This is dumb. We only turn off because current layout test results expect the <br> to be 0-height on the baseline.
// Other than making a zillion tests have to regenerate results, there's no reason to ditch the optimization here.
shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
@@ -154,19 +154,21 @@ void InlineFlowBox::addToLine(InlineBox* child)
clearDescendantsHaveSameLineHeightAndBaseline();
}
- if (!child->renderer()->isOutOfFlowPositioned()) {
+ if (!child->renderer().isOutOfFlowPositioned()) {
if (child->isText()) {
- RenderStyle* childStyle = child->renderer()->style(isFirstLineStyle());
+ RenderStyle* childStyle = child->renderer().style(isFirstLineStyle());
if (childStyle->letterSpacing() < 0 || childStyle->textShadow() || childStyle->textEmphasisMark() != TextEmphasisMarkNone || childStyle->textStrokeWidth())
child->clearKnownToHaveNoOverflow();
- } else if (child->renderer()->isReplaced()) {
- RenderBox* box = toRenderBox(child->renderer());
- if (box->hasRenderOverflow() || box->hasSelfPaintingLayer())
+ } else if (child->renderer().isReplaced()) {
+ RenderBox& box = toRenderBox(child->renderer());
+ if (box.hasRenderOverflow() || box.hasSelfPaintingLayer())
child->clearKnownToHaveNoOverflow();
- } else if (!child->renderer()->isBR() && (child->renderer()->style(isFirstLineStyle())->boxShadow() || child->boxModelObject()->hasSelfPaintingLayer()
- || (child->renderer()->isListMarker() && !toRenderListMarker(child->renderer())->isInside())
- || child->renderer()->style(isFirstLineStyle())->hasBorderImageOutsets()))
+ } else if (!child->renderer().isBR() && (child->renderer().style(isFirstLineStyle())->boxShadow() || child->boxModelObject()->hasSelfPaintingLayer()
+ || (child->renderer().isListMarker() && !toRenderListMarker(child->renderer()).isInside())
+ || child->renderer().style(isFirstLineStyle())->hasBorderImageOutsets()
+ || child->renderer().style(isFirstLineStyle())->hasOutline())) {
child->clearKnownToHaveNoOverflow();
+ }
if (knownToHaveNoOverflow() && child->isInlineFlowBox() && !toInlineFlowBox(child)->knownToHaveNoOverflow())
clearKnownToHaveNoOverflow();
@@ -175,14 +177,14 @@ void InlineFlowBox::addToLine(InlineBox* child)
checkConsistency();
}
-void InlineFlowBox::removeChild(InlineBox* child)
+void InlineFlowBox::removeChild(InlineBox* child, MarkLineBoxes markDirty)
{
checkConsistency();
- if (!isDirty())
+ if (markDirty == MarkLineBoxesDirty && !isDirty())
dirtyLineBoxes();
- root()->childRemoved(child);
+ root().childRemoved(child);
if (child == m_firstChild)
m_firstChild = child->nextOnLine();
@@ -222,7 +224,7 @@ void InlineFlowBox::deleteLine()
void InlineFlowBox::removeLineBoxFromRenderObject()
{
- toRenderInline(renderer())->lineBoxes()->removeLineBox(this);
+ rendererLineBoxes()->removeLineBox(this);
}
void InlineFlowBox::extractLine()
@@ -235,7 +237,7 @@ void InlineFlowBox::extractLine()
void InlineFlowBox::extractLineBoxFromRenderObject()
{
- toRenderInline(renderer())->lineBoxes()->extractLineBox(this);
+ rendererLineBoxes()->extractLineBox(this);
}
void InlineFlowBox::attachLine()
@@ -248,7 +250,7 @@ void InlineFlowBox::attachLine()
void InlineFlowBox::attachLineBoxToRenderObject()
{
- toRenderInline(renderer())->lineBoxes()->attachLineBox(this);
+ rendererLineBoxes()->attachLineBox(this);
}
void InlineFlowBox::adjustPosition(float dx, float dy)
@@ -262,7 +264,7 @@ void InlineFlowBox::adjustPosition(float dx, float dy)
RenderLineBoxList* InlineFlowBox::rendererLineBoxes() const
{
- return toRenderInline(renderer())->lineBoxes();
+ return toRenderInline(renderer()).lineBoxes();
}
static inline bool isLastChildForRenderer(RenderObject* ancestor, RenderObject* child)
@@ -276,7 +278,7 @@ static inline bool isLastChildForRenderer(RenderObject* ancestor, RenderObject*
RenderObject* curr = child;
RenderObject* parent = curr->parent();
while (parent && (!parent->isRenderBlock() || parent->isInline())) {
- if (parent->lastChild() != curr)
+ if (parent->slowLastChild() != curr)
return false;
if (parent == ancestor)
return true;
@@ -308,13 +310,13 @@ void InlineFlowBox::determineSpacingForFlowBoxes(bool lastLine, bool isLogically
// The root inline box never has borders/margins/padding.
if (parent()) {
- bool ltr = renderer()->style()->isLeftToRightDirection();
+ bool ltr = renderer().style()->isLeftToRightDirection();
// Check to see if all initial lines are unconstructed. If so, then
// we know the inline began on this line (unless we are a continuation).
RenderLineBoxList* lineBoxList = rendererLineBoxes();
- if (!lineBoxList->firstLineBox()->isConstructed() && !renderer()->isInlineElementContinuation()) {
- if (renderer()->style()->boxDecorationBreak() == DCLONE)
+ if (!lineBoxList->firstLineBox()->isConstructed() && !renderer().isInlineElementContinuation()) {
+ if (renderer().style()->boxDecorationBreak() == DCLONE)
includeLeftEdge = includeRightEdge = true;
else if (ltr && lineBoxList->firstLineBox() == this)
includeLeftEdge = true;
@@ -323,23 +325,23 @@ void InlineFlowBox::determineSpacingForFlowBoxes(bool lastLine, bool isLogically
}
if (!lineBoxList->lastLineBox()->isConstructed()) {
- RenderInline* inlineFlow = toRenderInline(renderer());
- bool isLastObjectOnLine = !isAnsectorAndWithinBlock(renderer(), logicallyLastRunRenderer) || (isLastChildForRenderer(renderer(), logicallyLastRunRenderer) && !isLogicallyLastRunWrapped);
+ RenderInline& inlineFlow = toRenderInline(renderer());
+ bool isLastObjectOnLine = !isAnsectorAndWithinBlock(&renderer(), logicallyLastRunRenderer) || (isLastChildForRenderer(&renderer(), logicallyLastRunRenderer) && !isLogicallyLastRunWrapped);
// We include the border under these conditions:
// (1) The next line was not created, or it is constructed. We check the previous line for rtl.
// (2) The logicallyLastRun is not a descendant of this renderer.
// (3) The logicallyLastRun is a descendant of this renderer, but it is the last child of this renderer and it does not wrap to the next line.
// (4) The decoration break is set to clone therefore there will be borders on every sides.
- if (renderer()->style()->boxDecorationBreak() == DCLONE)
+ if (renderer().style()->boxDecorationBreak() == DCLONE)
includeLeftEdge = includeRightEdge = true;
else if (ltr) {
if (!nextLineBox()
- && ((lastLine || isLastObjectOnLine) && !inlineFlow->continuation()))
+ && ((lastLine || isLastObjectOnLine) && !inlineFlow.continuation()))
includeRightEdge = true;
} else {
if ((!prevLineBox() || prevLineBox()->isConstructed())
- && ((lastLine || isLastObjectOnLine) && !inlineFlow->continuation()))
+ && ((lastLine || isLastObjectOnLine) && !inlineFlow.continuation()))
includeLeftEdge = true;
}
}
@@ -377,13 +379,13 @@ float InlineFlowBox::placeBoxesInInlineDirection(float logicalLeft, bool& needsW
float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastChild, float& logicalLeft, float& minLogicalLeft, float& maxLogicalRight, bool& needsWordSpacing, GlyphOverflowAndFallbackFontsMap& textBoxDataMap)
{
for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->nextOnLine()) {
- if (curr->renderer()->isText()) {
+ if (curr->renderer().isText()) {
InlineTextBox* text = toInlineTextBox(curr);
- RenderText* rt = toRenderText(text->renderer());
- if (rt->textLength()) {
- if (needsWordSpacing && isSpaceOrNewline(rt->characterAt(text->start())))
- logicalLeft += rt->style(isFirstLineStyle())->font().wordSpacing();
- needsWordSpacing = !isSpaceOrNewline(rt->characterAt(text->end()));
+ RenderText& rt = toRenderText(text->renderer());
+ if (rt.textLength()) {
+ if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->start())))
+ logicalLeft += rt.style(isFirstLineStyle())->font().fontDescription().wordSpacing();
+ needsWordSpacing = !isSpaceOrNewline(rt.characterAt(text->end()));
}
text->setLogicalLeft(logicalLeft);
if (knownToHaveNoOverflow())
@@ -392,17 +394,18 @@ float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, Inlin
if (knownToHaveNoOverflow())
maxLogicalRight = max(logicalLeft, maxLogicalRight);
} else {
- if (curr->renderer()->isOutOfFlowPositioned()) {
- if (curr->renderer()->parent()->style()->isLeftToRightDirection())
+ if (curr->renderer().isOutOfFlowPositioned()) {
+ if (curr->renderer().parent()->style()->isLeftToRightDirection()) {
curr->setLogicalLeft(logicalLeft);
- else
+ } else {
// Our offset that we cache needs to be from the edge of the right border box and
// not the left border box. We have to subtract |x| from the width of the block
// (which can be obtained from the root line box).
- curr->setLogicalLeft(root()->block()->logicalWidth() - logicalLeft);
+ curr->setLogicalLeft(root().block().logicalWidth() - logicalLeft);
+ }
continue; // The positioned object has no effect on the width.
}
- if (curr->renderer()->isRenderInline()) {
+ if (curr->renderer().isRenderInline()) {
InlineFlowBox* flow = toInlineFlowBox(curr);
logicalLeft += flow->marginLogicalLeft();
if (knownToHaveNoOverflow())
@@ -411,7 +414,7 @@ float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, Inlin
if (knownToHaveNoOverflow())
maxLogicalRight = max(logicalLeft, maxLogicalRight);
logicalLeft += flow->marginLogicalRight();
- } else if (!curr->renderer()->isListMarker() || toRenderListMarker(curr->renderer())->isInside()) {
+ } else if (!curr->renderer().isListMarker() || toRenderListMarker(curr->renderer()).isInside()) {
// The box can have a different writing-mode than the overall line, so this is a bit complicated.
// Just get all the physical margin and overflow values by hand based off |isVertical|.
LayoutUnit logicalLeftMargin = isHorizontal() ? curr->boxModelObject()->marginLeft() : curr->boxModelObject()->marginTop();
@@ -438,19 +441,19 @@ bool InlineFlowBox::requiresIdeographicBaseline(const GlyphOverflowAndFallbackFo
if (isHorizontal())
return false;
- if (renderer()->style(isFirstLineStyle())->fontDescription().nonCJKGlyphOrientation() == NonCJKGlyphOrientationUpright
- || renderer()->style(isFirstLineStyle())->font().primaryFont()->hasVerticalGlyphs())
+ if (renderer().style(isFirstLineStyle())->fontDescription().nonCJKGlyphOrientation() == NonCJKGlyphOrientationUpright
+ || renderer().style(isFirstLineStyle())->font().primaryFont()->hasVerticalGlyphs())
return true;
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
- if (curr->renderer()->isOutOfFlowPositioned())
+ if (curr->renderer().isOutOfFlowPositioned())
continue; // Positioned placeholders don't affect calculations.
if (curr->isInlineFlowBox()) {
if (toInlineFlowBox(curr)->requiresIdeographicBaseline(textBoxDataMap))
return true;
} else {
- if (curr->renderer()->style(isFirstLineStyle())->font().primaryFont()->hasVerticalGlyphs())
+ if (curr->renderer().style(isFirstLineStyle())->font().primaryFont()->hasVerticalGlyphs())
return true;
const Vector<const SimpleFontData*>* usedFonts = 0;
@@ -476,7 +479,7 @@ void InlineFlowBox::adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, i
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
// The computed lineheight needs to be extended for the
// positioned elements
- if (curr->renderer()->isOutOfFlowPositioned())
+ if (curr->renderer().isOutOfFlowPositioned())
continue; // Positioned placeholders don't affect calculations.
if (curr->verticalAlign() == TOP || curr->verticalAlign() == BOTTOM) {
int lineHeight = curr->lineHeight();
@@ -543,7 +546,7 @@ void InlineFlowBox::computeLogicalBoxHeights(RootInlineBox* rootBox, LayoutUnit&
return;
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
- if (curr->renderer()->isOutOfFlowPositioned())
+ if (curr->renderer().isOutOfFlowPositioned())
continue; // Positioned placeholders don't affect calculations.
InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox(curr) : 0;
@@ -554,7 +557,7 @@ void InlineFlowBox::computeLogicalBoxHeights(RootInlineBox* rootBox, LayoutUnit&
// The verticalPositionForBox function returns the distance between the child box's baseline
// and the root box's baseline. The value is negative if the child box's baseline is above the
// root box's baseline, and it is positive if the child box's baseline is below the root box's baseline.
- curr->setLogicalTop(rootBox->verticalPositionForBox(curr, verticalPositionCache));
+ curr->setLogicalTop(rootBox->verticalPositionForBox(curr, verticalPositionCache).toFloat());
int ascent = 0;
int descent = 0;
@@ -600,7 +603,7 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
{
bool isRootBox = isRootInlineBox();
if (isRootBox) {
- const FontMetrics& fontMetrics = renderer()->style(isFirstLineStyle())->fontMetrics();
+ const FontMetrics& fontMetrics = renderer().style(isFirstLineStyle())->fontMetrics();
// RootInlineBoxes are always placed on at pixel boundaries in their logical y direction. Not doing
// so results in incorrect rendering of text decorations, most notably underlines.
setLogicalTop(roundToInt(top + maxAscent - fontMetrics.ascent(baselineType)));
@@ -614,20 +617,20 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
}
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
- if (curr->renderer()->isOutOfFlowPositioned())
+ if (curr->renderer().isOutOfFlowPositioned())
continue; // Positioned placeholders don't affect calculations.
if (descendantsHaveSameLineHeightAndBaseline()) {
- curr->adjustBlockDirectionPosition(adjustmentForChildrenWithSameLineHeightAndBaseline);
+ curr->adjustBlockDirectionPosition(adjustmentForChildrenWithSameLineHeightAndBaseline.toFloat());
continue;
}
InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox(curr) : 0;
bool childAffectsTopBottomPos = true;
if (curr->verticalAlign() == TOP)
- curr->setLogicalTop(top);
+ curr->setLogicalTop(top.toFloat());
else if (curr->verticalAlign() == BOTTOM)
- curr->setLogicalTop(top + maxHeight - curr->lineHeight());
+ curr->setLogicalTop((top + maxHeight - curr->lineHeight()).toFloat());
else {
if (!strictMode && inlineFlowBox && !inlineFlowBox->hasTextChildren() && !curr->boxModelObject()->hasInlineDirectionBordersOrPadding()
&& !(inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() && inlineFlowBox->hasTextDescendants()))
@@ -642,48 +645,48 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
LayoutUnit boxHeightIncludingMargins = boxHeight;
if (curr->isText() || curr->isInlineFlowBox()) {
- const FontMetrics& fontMetrics = curr->renderer()->style(isFirstLineStyle())->fontMetrics();
+ const FontMetrics& fontMetrics = curr->renderer().style(isFirstLineStyle())->fontMetrics();
newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.ascent(baselineType);
if (curr->isInlineFlowBox()) {
- RenderBoxModelObject* boxObject = toRenderBoxModelObject(curr->renderer());
- newLogicalTop -= boxObject->style(isFirstLineStyle())->isHorizontalWritingMode() ? boxObject->borderTop() + boxObject->paddingTop() :
- boxObject->borderRight() + boxObject->paddingRight();
+ RenderBoxModelObject& boxObject = toRenderBoxModelObject(curr->renderer());
+ newLogicalTop -= boxObject.style(isFirstLineStyle())->isHorizontalWritingMode() ? boxObject.borderTop() + boxObject.paddingTop() :
+ boxObject.borderRight() + boxObject.paddingRight();
}
newLogicalTopIncludingMargins = newLogicalTop;
- } else if (!curr->renderer()->isBR()) {
- RenderBox* box = toRenderBox(curr->renderer());
+ } else if (!curr->renderer().isBR()) {
+ RenderBox& box = toRenderBox(curr->renderer());
newLogicalTopIncludingMargins = newLogicalTop;
- LayoutUnit overSideMargin = curr->isHorizontal() ? box->marginTop() : box->marginRight();
- LayoutUnit underSideMargin = curr->isHorizontal() ? box->marginBottom() : box->marginLeft();
+ LayoutUnit overSideMargin = curr->isHorizontal() ? box.marginTop() : box.marginRight();
+ LayoutUnit underSideMargin = curr->isHorizontal() ? box.marginBottom() : box.marginLeft();
newLogicalTop += overSideMargin;
boxHeightIncludingMargins += overSideMargin + underSideMargin;
}
- curr->setLogicalTop(newLogicalTop);
+ curr->setLogicalTop(newLogicalTop.toFloat());
if (childAffectsTopBottomPos) {
- if (curr->renderer()->isRubyRun()) {
+ if (curr->renderer().isRubyRun()) {
// Treat the leading on the first and last lines of ruby runs as not being part of the overall lineTop/lineBottom.
// Really this is a workaround hack for the fact that ruby should have been done as line layout and not done using
// inline-block.
- if (renderer()->style()->isFlippedLinesWritingMode() == (curr->renderer()->style()->rubyPosition() == RubyPositionAfter))
+ if (renderer().style()->isFlippedLinesWritingMode() == (curr->renderer().style()->rubyPosition() == RubyPositionAfter))
hasAnnotationsBefore = true;
else
hasAnnotationsAfter = true;
- RenderRubyRun* rubyRun = toRenderRubyRun(curr->renderer());
- if (RenderRubyBase* rubyBase = rubyRun->rubyBase()) {
+ RenderRubyRun& rubyRun = toRenderRubyRun(curr->renderer());
+ if (RenderRubyBase* rubyBase = rubyRun.rubyBase()) {
LayoutUnit bottomRubyBaseLeading = (curr->logicalHeight() - rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox() ? rubyBase->lastRootBox()->lineBottom() : LayoutUnit());
LayoutUnit topRubyBaseLeading = rubyBase->logicalTop() + (rubyBase->firstRootBox() ? rubyBase->firstRootBox()->lineTop() : LayoutUnit());
- newLogicalTop += !renderer()->style()->isFlippedLinesWritingMode() ? topRubyBaseLeading : bottomRubyBaseLeading;
+ newLogicalTop += !renderer().style()->isFlippedLinesWritingMode() ? topRubyBaseLeading : bottomRubyBaseLeading;
boxHeight -= (topRubyBaseLeading + bottomRubyBaseLeading);
}
}
if (curr->isInlineTextBox()) {
TextEmphasisPosition emphasisMarkPosition;
- if (toInlineTextBox(curr)->getEmphasisMarkPosition(curr->renderer()->style(isFirstLineStyle()), emphasisMarkPosition)) {
+ if (toInlineTextBox(curr)->getEmphasisMarkPosition(curr->renderer().style(isFirstLineStyle()), emphasisMarkPosition)) {
bool emphasisMarkIsOver = emphasisMarkPosition == TextEmphasisPositionOver;
- if (emphasisMarkIsOver != curr->renderer()->style(isFirstLineStyle())->isFlippedLinesWritingMode())
+ if (emphasisMarkIsOver != curr->renderer().style(isFirstLineStyle())->isFlippedLinesWritingMode())
hasAnnotationsBefore = true;
else
hasAnnotationsAfter = true;
@@ -723,7 +726,7 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
lineBottomIncludingMargins = max(lineBottom, lineBottomIncludingMargins);
}
- if (renderer()->style()->isFlippedLinesWritingMode())
+ if (renderer().style()->isFlippedLinesWritingMode())
flipLinesInBlockDirection(lineTopIncludingMargins, lineBottomIncludingMargins);
}
}
@@ -731,7 +734,7 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
void InlineFlowBox::computeMaxLogicalTop(float& maxLogicalTop) const
{
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
- if (curr->renderer()->isOutOfFlowPositioned())
+ if (curr->renderer().isOutOfFlowPositioned())
continue; // Positioned placeholders don't affect calculations.
if (descendantsHaveSameLineHeightAndBaseline())
@@ -751,7 +754,7 @@ void InlineFlowBox::flipLinesInBlockDirection(LayoutUnit lineTop, LayoutUnit lin
setLogicalTop(lineBottom - (logicalTop() - lineTop) - logicalHeight());
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
- if (curr->renderer()->isOutOfFlowPositioned())
+ if (curr->renderer().isOutOfFlowPositioned())
continue; // Positioned placeholders aren't affected here.
if (curr->isInlineFlowBox())
@@ -767,7 +770,7 @@ inline void InlineFlowBox::addBoxShadowVisualOverflow(LayoutRect& logicalVisualO
if (!parent())
return;
- RenderStyle* style = renderer()->style(isFirstLineStyle());
+ RenderStyle* style = renderer().style(isFirstLineStyle());
if (!style->boxShadow())
return;
@@ -800,7 +803,7 @@ inline void InlineFlowBox::addBorderOutsetVisualOverflow(LayoutRect& logicalVisu
if (!parent())
return;
- RenderStyle* style = renderer()->style(isFirstLineStyle());
+ RenderStyle* style = renderer().style(isFirstLineStyle());
if (!style->hasBorderImageOutsets())
return;
@@ -829,12 +832,25 @@ inline void InlineFlowBox::addBorderOutsetVisualOverflow(LayoutRect& logicalVisu
logicalRightVisualOverflow - logicalLeftVisualOverflow, logicalBottomVisualOverflow - logicalTopVisualOverflow);
}
+inline void InlineFlowBox::addOutlineVisualOverflow(LayoutRect& logicalVisualOverflow)
+{
+ // Outline on root line boxes is applied to the block and not to the lines.
+ if (!parent())
+ return;
+
+ RenderStyle* style = renderer().style(isFirstLineStyle());
+ if (!style->hasOutline())
+ return;
+
+ logicalVisualOverflow.inflate(style->outlineSize());
+}
+
inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, LayoutRect& logicalVisualOverflow)
{
if (textBox->knownToHaveNoOverflow())
return;
- RenderStyle* style = textBox->renderer()->style(isFirstLineStyle());
+ RenderStyle* style = textBox->renderer().style(isFirstLineStyle());
GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(textBox);
GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.second;
@@ -862,7 +878,7 @@ inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp
// If letter-spacing is negative, we should factor that into right layout overflow. (Even in RTL, letter-spacing is
// applied to the right, so this is not an issue with left overflow.
- rightGlyphOverflow -= min(0, (int)style->font().letterSpacing());
+ rightGlyphOverflow -= min(0, (int)style->font().fontDescription().letterSpacing());
LayoutUnit textShadowLogicalTop;
LayoutUnit textShadowLogicalBottom;
@@ -891,13 +907,13 @@ inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp
inline void InlineFlowBox::addReplacedChildOverflow(const InlineBox* inlineBox, LayoutRect& logicalLayoutOverflow, LayoutRect& logicalVisualOverflow)
{
- RenderBox* box = toRenderBox(inlineBox->renderer());
+ RenderBox& box = toRenderBox(inlineBox->renderer());
// Visual overflow only propagates if the box doesn't have a self-painting layer. This rectangle does not include
// transforms or relative positioning (since those objects always have self-painting layers), but it does need to be adjusted
// for writing-mode differences.
- if (!box->hasSelfPaintingLayer()) {
- LayoutRect childLogicalVisualOverflow = box->logicalVisualOverflowRectForPropagation(renderer()->style());
+ if (!box.hasSelfPaintingLayer()) {
+ LayoutRect childLogicalVisualOverflow = box.logicalVisualOverflowRectForPropagation(renderer().style());
childLogicalVisualOverflow.move(inlineBox->logicalLeft(), inlineBox->logicalTop());
logicalVisualOverflow.unite(childLogicalVisualOverflow);
}
@@ -905,7 +921,7 @@ inline void InlineFlowBox::addReplacedChildOverflow(const InlineBox* inlineBox,
// Layout overflow internal to the child box only propagates if the child box doesn't have overflow clip set.
// Otherwise the child border box propagates as layout overflow. This rectangle must include transforms and relative positioning
// and be adjusted for writing-mode differences.
- LayoutRect childLogicalLayoutOverflow = box->logicalLayoutOverflowRectForPropagation(renderer()->style());
+ LayoutRect childLogicalLayoutOverflow = box.logicalLayoutOverflowRectForPropagation(renderer().style());
childLogicalLayoutOverflow.move(inlineBox->logicalLeft(), inlineBox->logicalTop());
logicalLayoutOverflow.unite(childLogicalLayoutOverflow);
}
@@ -913,8 +929,13 @@ inline void InlineFlowBox::addReplacedChildOverflow(const InlineBox* inlineBox,
void InlineFlowBox::computeOverflow(LayoutUnit lineTop, LayoutUnit lineBottom, GlyphOverflowAndFallbackFontsMap& textBoxDataMap)
{
// If we know we have no overflow, we can just bail.
- if (knownToHaveNoOverflow())
+ if (knownToHaveNoOverflow()) {
+ ASSERT(!m_overflow);
return;
+ }
+
+ if (m_overflow)
+ m_overflow.clear();
// Visual overflow just includes overflow for stuff we need to repaint ourselves. Self-painting layers are ignored.
// Layout overflow is used to determine scrolling extent, so it still includes child layers and also factors in
@@ -924,20 +945,21 @@ void InlineFlowBox::computeOverflow(LayoutUnit lineTop, LayoutUnit lineBottom, G
addBoxShadowVisualOverflow(logicalVisualOverflow);
addBorderOutsetVisualOverflow(logicalVisualOverflow);
+ addOutlineVisualOverflow(logicalVisualOverflow);
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
- if (curr->renderer()->isOutOfFlowPositioned())
+ if (curr->renderer().isOutOfFlowPositioned())
continue; // Positioned placeholders don't affect calculations.
- if (curr->renderer()->isText()) {
+ if (curr->renderer().isText()) {
InlineTextBox* text = toInlineTextBox(curr);
- RenderText* rt = toRenderText(text->renderer());
- if (rt->isBR())
+ RenderText& rt = toRenderText(text->renderer());
+ if (rt.isBR())
continue;
LayoutRect textBoxOverflow(enclosingLayoutRect(text->logicalFrameRect()));
addTextBoxVisualOverflow(text, textBoxDataMap, textBoxOverflow);
logicalVisualOverflow.unite(textBoxOverflow);
- } else if (curr->renderer()->isRenderInline()) {
+ } else if (curr->renderer().isRenderInline()) {
InlineFlowBox* flow = toInlineFlowBox(curr);
flow->computeOverflow(lineTop, lineBottom, textBoxDataMap);
if (!flow->boxModelObject()->hasSelfPaintingLayer())
@@ -945,16 +967,16 @@ void InlineFlowBox::computeOverflow(LayoutUnit lineTop, LayoutUnit lineBottom, G
LayoutRect childLayoutOverflow = flow->logicalLayoutOverflowRect(lineTop, lineBottom);
childLayoutOverflow.move(flow->boxModelObject()->relativePositionLogicalOffset());
logicalLayoutOverflow.unite(childLayoutOverflow);
- } else
+ } else {
addReplacedChildOverflow(curr, logicalLayoutOverflow, logicalVisualOverflow);
+ }
}
setOverflowFromLogicalRects(logicalLayoutOverflow, logicalVisualOverflow, lineTop, lineBottom);
}
-void InlineFlowBox::setLayoutOverflow(const LayoutRect& rect, LayoutUnit lineTop, LayoutUnit lineBottom)
+void InlineFlowBox::setLayoutOverflow(const LayoutRect& rect, const LayoutRect& frameBox)
{
- LayoutRect frameBox = enclosingLayoutRect(frameRectIncludingLineHeight(lineTop, lineBottom));
if (frameBox.contains(rect) || rect.isEmpty())
return;
@@ -964,9 +986,8 @@ void InlineFlowBox::setLayoutOverflow(const LayoutRect& rect, LayoutUnit lineTop
m_overflow->setLayoutOverflow(rect);
}
-void InlineFlowBox::setVisualOverflow(const LayoutRect& rect, LayoutUnit lineTop, LayoutUnit lineBottom)
+void InlineFlowBox::setVisualOverflow(const LayoutRect& rect, const LayoutRect& frameBox)
{
- LayoutRect frameBox = enclosingLayoutRect(frameRectIncludingLineHeight(lineTop, lineBottom));
if (frameBox.contains(rect) || rect.isEmpty())
return;
@@ -978,11 +999,13 @@ void InlineFlowBox::setVisualOverflow(const LayoutRect& rect, LayoutUnit lineTop
void InlineFlowBox::setOverflowFromLogicalRects(const LayoutRect& logicalLayoutOverflow, const LayoutRect& logicalVisualOverflow, LayoutUnit lineTop, LayoutUnit lineBottom)
{
+ LayoutRect frameBox = enclosingLayoutRect(frameRectIncludingLineHeight(lineTop, lineBottom));
+
LayoutRect layoutOverflow(isHorizontal() ? logicalLayoutOverflow : logicalLayoutOverflow.transposedRect());
- setLayoutOverflow(layoutOverflow, lineTop, lineBottom);
+ setLayoutOverflow(layoutOverflow, frameBox);
LayoutRect visualOverflow(isHorizontal() ? logicalVisualOverflow : logicalVisualOverflow.transposedRect());
- setVisualOverflow(visualOverflow, lineTop, lineBottom);
+ setVisualOverflow(visualOverflow, frameBox);
}
bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
@@ -997,11 +1020,11 @@ bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
// We need to account for culled inline parents of the hit-tested nodes, so that they may also get included in area-based hit-tests.
RenderObject* culledParent = 0;
for (InlineBox* curr = lastChild(); curr; curr = curr->prevOnLine()) {
- if (curr->renderer()->isText() || !curr->boxModelObject()->hasSelfPaintingLayer()) {
+ if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintingLayer()) {
RenderObject* newParent = 0;
// Culled parents are only relevant for area-based hit-tests, so ignore it in point-based ones.
if (locationInContainer.isRectBasedTest()) {
- newParent = curr->renderer()->parent();
+ newParent = curr->renderer().parent();
if (newParent == renderer())
newParent = 0;
}
@@ -1018,7 +1041,7 @@ bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
culledParent = newParent;
}
if (curr->nodeAtPoint(request, result, locationInContainer, accumulatedOffset, lineTop, lineBottom)) {
- renderer()->updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
+ renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
return true;
}
}
@@ -1038,13 +1061,13 @@ bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
LayoutUnit height = frameRect.height();
// Constrain our hit testing to the line top and bottom if necessary.
- bool noQuirksMode = renderer()->document().inNoQuirksMode();
+ bool noQuirksMode = renderer().document().inNoQuirksMode();
if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAndBaseline() && hasTextDescendants())) {
- RootInlineBox* rootBox = root();
+ RootInlineBox& rootBox = root();
LayoutUnit& top = isHorizontal() ? minY : minX;
LayoutUnit& logicalHeight = isHorizontal() ? height : width;
- LayoutUnit bottom = min(rootBox->lineBottom(), top + logicalHeight);
- top = max(rootBox->lineTop(), top);
+ LayoutUnit bottom = min(rootBox.lineBottom(), top + logicalHeight);
+ top = max(rootBox.lineTop(), top);
logicalHeight = bottom - top;
}
@@ -1054,8 +1077,8 @@ bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
rect.moveBy(accumulatedOffset);
if (visibleToHitTestRequest(request) && locationInContainer.intersects(rect)) {
- renderer()->updateHitTestResult(result, flipForWritingMode(locationInContainer.point() - toLayoutSize(accumulatedOffset))); // Don't add in m_x or m_y here, we want coords in the containing block's space.
- if (!result.addNodeToRectBasedTestResult(renderer()->node(), request, locationInContainer, rect))
+ renderer().updateHitTestResult(result, flipForWritingMode(locationInContainer.point() - toLayoutSize(accumulatedOffset))); // Don't add in m_x or m_y here, we want coords in the containing block's space.
+ if (!result.addNodeToRectBasedTestResult(renderer().node(), request, locationInContainer, rect))
return true;
}
@@ -1065,7 +1088,6 @@ bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom));
- overflowRect.inflate(renderer()->maximalOutlineSize(paintInfo.phase));
flipForWritingMode(overflowRect);
overflowRect.moveBy(paintOffset);
@@ -1076,16 +1098,16 @@ void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
if (paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) {
// Add ourselves to the paint info struct's list of inlines that need to paint their
// outlines.
- if (renderer()->style()->visibility() == VISIBLE && renderer()->hasOutline() && !isRootInlineBox()) {
- RenderInline* inlineFlow = toRenderInline(renderer());
+ if (renderer().style()->visibility() == VISIBLE && renderer().hasOutline() && !isRootInlineBox()) {
+ RenderInline& inlineFlow = toRenderInline(renderer());
RenderBlock* cb = 0;
- bool containingBlockPaintsContinuationOutline = inlineFlow->continuation() || inlineFlow->isInlineElementContinuation();
+ bool containingBlockPaintsContinuationOutline = inlineFlow.continuation() || inlineFlow.isInlineElementContinuation();
if (containingBlockPaintsContinuationOutline) {
// FIXME: See https://bugs.webkit.org/show_bug.cgi?id=54690. We currently don't reconnect inline continuations
// after a child removal. As a result, those merged inlines do not get seperated and hence not get enclosed by
// anonymous blocks. In this case, it is better to bail out and paint it ourself.
- RenderBlock* enclosingAnonymousBlock = renderer()->containingBlock();
+ RenderBlock* enclosingAnonymousBlock = renderer().containingBlock();
if (!enclosingAnonymousBlock->isAnonymousBlock())
containingBlockPaintsContinuationOutline = false;
else {
@@ -1102,9 +1124,9 @@ void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
if (containingBlockPaintsContinuationOutline) {
// Add ourselves to the containing block of the entire continuation so that it can
// paint us atomically.
- cb->addContinuationWithOutline(toRenderInline(renderer()->node()->renderer()));
- } else if (!inlineFlow->isInlineElementContinuation()) {
- paintInfo.outlineObjects()->add(inlineFlow);
+ cb->addContinuationWithOutline(toRenderInline(renderer().node()->renderer()));
+ } else if (!inlineFlow.isInlineElementContinuation()) {
+ paintInfo.outlineObjects()->add(&inlineFlow);
}
}
} else if (paintInfo.phase == PaintPhaseMask) {
@@ -1120,14 +1142,19 @@ void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
return;
PaintPhase paintPhase = paintInfo.phase == PaintPhaseChildOutlines ? PaintPhaseOutline : paintInfo.phase;
- PaintInfo childInfo(paintInfo);
- childInfo.phase = paintPhase;
- childInfo.updatePaintingRootForChildren(renderer());
// Paint our children.
if (paintPhase != PaintPhaseSelfOutline) {
+ PaintInfo childInfo(paintInfo);
+ childInfo.phase = paintPhase;
+
+ if (childInfo.paintingRoot && childInfo.paintingRoot->isDescendantOf(&renderer()))
+ childInfo.paintingRoot = 0;
+ else
+ childInfo.updatePaintingRootForChildren(&renderer());
+
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
- if (curr->renderer()->isText() || !curr->boxModelObject()->hasSelfPaintingLayer())
+ if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintingLayer())
curr->paint(childInfo, paintOffset, lineTop, lineBottom);
}
}
@@ -1146,17 +1173,17 @@ bool InlineFlowBox::boxShadowCanBeAppliedToBackground(const FillLayer& lastBackg
// The checks here match how paintFillLayer() decides whether to clip (if it does, the shadow
// would be clipped out, so it has to be drawn separately).
StyleImage* image = lastBackgroundLayer.image();
- bool hasFillImage = image && image->canRender(renderer(), renderer()->style()->effectiveZoom());
- return (!hasFillImage && !renderer()->style()->hasBorderRadius()) || (!prevLineBox() && !nextLineBox()) || !parent();
+ bool hasFillImage = image && image->canRender(renderer(), renderer().style()->effectiveZoom());
+ return (!hasFillImage && !renderer().style()->hasBorderRadius()) || (!prevLineBox() && !nextLineBox()) || !parent();
}
void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, const LayoutRect& rect, CompositeOperator op)
{
StyleImage* img = fillLayer->image();
- bool hasFillImage = img && img->canRender(renderer(), renderer()->style()->effectiveZoom());
- if ((!hasFillImage && !renderer()->style()->hasBorderRadius()) || (!prevLineBox() && !nextLineBox()) || !parent())
+ bool hasFillImage = img && img->canRender(renderer(), renderer().style()->effectiveZoom());
+ if ((!hasFillImage && !renderer().style()->hasBorderRadius()) || (!prevLineBox() && !nextLineBox()) || !parent()) {
boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect, BackgroundBleedNone, this, rect.size(), op);
- else if (renderer()->style()->boxDecorationBreak() == DCLONE) {
+ } else if (renderer().style()->boxDecorationBreak() == DCLONE) {
GraphicsContextStateSaver stateSaver(*paintInfo.context);
paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height()));
boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect, BackgroundBleedNone, this, rect.size(), op);
@@ -1169,7 +1196,7 @@ void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, c
// the previous line left off.
LayoutUnit logicalOffsetOnLine = 0;
LayoutUnit totalLogicalWidth;
- if (renderer()->style()->direction() == LTR) {
+ if (renderer().style()->direction() == LTR) {
for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLineBox())
logicalOffsetOnLine += curr->logicalWidth();
totalLogicalWidth = logicalOffsetOnLine;
@@ -1206,13 +1233,13 @@ void InlineFlowBox::paintBoxShadow(const PaintInfo& info, RenderStyle* s, Shadow
void InlineFlowBox::constrainToLineTopAndBottomIfNeeded(LayoutRect& rect) const
{
- bool noQuirksMode = renderer()->document().inNoQuirksMode();
+ bool noQuirksMode = renderer().document().inNoQuirksMode();
if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAndBaseline() && hasTextDescendants())) {
- const RootInlineBox* rootBox = root();
+ const RootInlineBox& rootBox = root();
LayoutUnit logicalTop = isHorizontal() ? rect.y() : rect.x();
LayoutUnit logicalHeight = isHorizontal() ? rect.height() : rect.width();
- LayoutUnit bottom = min(rootBox->lineBottom(), logicalTop + logicalHeight);
- logicalTop = max(rootBox->lineTop(), logicalTop);
+ LayoutUnit bottom = min(rootBox.lineBottom(), logicalTop + logicalHeight);
+ logicalTop = max(rootBox.lineTop(), logicalTop);
logicalHeight = bottom - logicalTop;
if (isHorizontal()) {
rect.setY(logicalTop);
@@ -1227,7 +1254,7 @@ void InlineFlowBox::constrainToLineTopAndBottomIfNeeded(LayoutRect& rect) const
static LayoutRect clipRectForNinePieceImageStrip(InlineFlowBox* box, const NinePieceImage& image, const LayoutRect& paintRect)
{
LayoutRect clipRect(paintRect);
- RenderStyle* style = box->renderer()->style();
+ RenderStyle* style = box->renderer().style();
LayoutBoxExtent outsets = style->imageOutsets(image);
if (box->isHorizontal()) {
clipRect.setY(paintRect.y() - outsets.top());
@@ -1253,7 +1280,7 @@ static LayoutRect clipRectForNinePieceImageStrip(InlineFlowBox* box, const NineP
void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
- if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground)
+ if (!paintInfo.shouldPaintWithinRoot(&renderer()) || renderer().style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground)
return;
// Pixel snap background/border painting.
@@ -1270,21 +1297,21 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&
// You can use p::first-line to specify a background. If so, the root line boxes for
// a line may actually have to paint a background.
- RenderStyle* styleToUse = renderer()->style(isFirstLineStyle());
- if ((!parent() && isFirstLineStyle() && styleToUse != renderer()->style()) || (parent() && renderer()->hasBoxDecorations())) {
+ RenderStyle* styleToUse = renderer().style(isFirstLineStyle());
+ if ((!parent() && isFirstLineStyle() && styleToUse != renderer().style()) || (parent() && renderer().hasBoxDecorations())) {
LayoutRect paintRect = LayoutRect(adjustedPaintoffset, frameRect.size());
// Shadow comes first and is behind the background and border.
if (!boxModelObject()->boxShadowShouldBeAppliedToBackground(BackgroundBleedNone, this))
paintBoxShadow(paintInfo, styleToUse, Normal, paintRect);
- Color c = renderer()->resolveColor(styleToUse, CSSPropertyBackgroundColor);
+ Color c = renderer().resolveColor(styleToUse, CSSPropertyBackgroundColor);
paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), paintRect);
paintBoxShadow(paintInfo, styleToUse, Inset, paintRect);
// :first-line cannot be used to put borders on a line. Always paint borders with our
// non-first-line style.
- if (parent() && renderer()->style()->hasBorder()) {
- const NinePieceImage& borderImage = renderer()->style()->borderImage();
+ if (parent() && renderer().style()->hasBorder()) {
+ const NinePieceImage& borderImage = renderer().style()->borderImage();
StyleImage* borderImageSource = borderImage.image();
bool hasBorderImage = borderImageSource && borderImageSource->canRender(renderer(), styleToUse->effectiveZoom());
if (hasBorderImage && !borderImageSource->isLoaded())
@@ -1293,7 +1320,7 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&
// The simple case is where we either have no border image or we are the only box for this object. In those
// cases only a single call to draw is required.
if (!hasBorderImage || (!prevLineBox() && !nextLineBox()))
- boxModelObject()->paintBorder(paintInfo, paintRect, renderer()->style(isFirstLineStyle()), BackgroundBleedNone, includeLogicalLeftEdge(), includeLogicalRightEdge());
+ boxModelObject()->paintBorder(paintInfo, paintRect, renderer().style(isFirstLineStyle()), BackgroundBleedNone, includeLogicalLeftEdge(), includeLogicalRightEdge());
else {
// We have a border image that spans multiple lines.
// We need to adjust tx and ty by the width of all previous lines.
@@ -1317,7 +1344,7 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&
LayoutRect clipRect = clipRectForNinePieceImageStrip(this, borderImage, paintRect);
GraphicsContextStateSaver stateSaver(*context);
context->clip(clipRect);
- boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer()->style(isFirstLineStyle()));
+ boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer().style(isFirstLineStyle()));
}
}
}
@@ -1325,7 +1352,7 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&
void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
- if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
+ if (!paintInfo.shouldPaintWithinRoot(&renderer()) || renderer().style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
return;
// Pixel snap mask painting.
@@ -1338,16 +1365,16 @@ void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs
flipForWritingMode(localRect);
LayoutPoint adjustedPaintOffset = paintOffset + localRect.location();
- const NinePieceImage& maskNinePieceImage = renderer()->style()->maskBoxImage();
- StyleImage* maskBoxImage = renderer()->style()->maskBoxImage().image();
+ const NinePieceImage& maskNinePieceImage = renderer().style()->maskBoxImage();
+ StyleImage* maskBoxImage = renderer().style()->maskBoxImage().image();
// Figure out if we need to push a transparency layer to render our mask.
bool pushTransparencyLayer = false;
- bool compositedMask = renderer()->hasLayer() && boxModelObject()->layer()->hasCompositedMask();
- bool flattenCompositingLayers = renderer()->view()->frameView() && renderer()->view()->frameView()->paintBehavior() & PaintBehaviorFlattenCompositingLayers;
+ bool compositedMask = renderer().hasLayer() && boxModelObject()->layer()->hasCompositedMask();
+ bool flattenCompositingLayers = renderer().view()->frameView() && renderer().view()->frameView()->paintBehavior() & PaintBehaviorFlattenCompositingLayers;
CompositeOperator compositeOp = CompositeSourceOver;
if (!compositedMask || flattenCompositingLayers) {
- if ((maskBoxImage && renderer()->style()->maskLayers()->hasImage()) || renderer()->style()->maskLayers()->next())
+ if ((maskBoxImage && renderer().style()->maskLayers()->hasImage()) || renderer().style()->maskLayers()->next())
pushTransparencyLayer = true;
compositeOp = CompositeDestinationIn;
@@ -1359,9 +1386,9 @@ void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs
}
LayoutRect paintRect = LayoutRect(adjustedPaintOffset, frameRect.size());
- paintFillLayers(paintInfo, Color(), renderer()->style()->maskLayers(), paintRect, compositeOp);
+ paintFillLayers(paintInfo, Color::transparent, renderer().style()->maskLayers(), paintRect, compositeOp);
- bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(renderer(), renderer()->style()->effectiveZoom());
+ bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(renderer(), renderer().style()->effectiveZoom());
if (!hasBoxImage || !maskBoxImage->isLoaded()) {
if (pushTransparencyLayer)
paintInfo.context->endLayer();
@@ -1371,7 +1398,7 @@ void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs
// The simple case is where we are the only box for this object. In those
// cases only a single call to draw is required.
if (!prevLineBox() && !nextLineBox()) {
- boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(adjustedPaintOffset, frameRect.size()), renderer()->style(), maskNinePieceImage, compositeOp);
+ boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(adjustedPaintOffset, frameRect.size()), renderer().style(), maskNinePieceImage, compositeOp);
} else {
// We have a mask image that spans multiple lines.
// We need to adjust _tx and _ty by the width of all previous lines.
@@ -1389,7 +1416,7 @@ void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs
LayoutRect clipRect = clipRectForNinePieceImageStrip(this, maskNinePieceImage, paintRect);
GraphicsContextStateSaver stateSaver(*paintInfo.context);
paintInfo.context->clip(clipRect);
- boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer()->style(), maskNinePieceImage, compositeOp);
+ boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer().style(), maskNinePieceImage, compositeOp);
}
if (pushTransparencyLayer)
@@ -1466,19 +1493,19 @@ LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi
{
LayoutUnit result = 0;
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
- if (curr->renderer()->isOutOfFlowPositioned())
+ if (curr->renderer().isOutOfFlowPositioned())
continue; // Positioned placeholders don't affect calculations.
if (curr->isInlineFlowBox())
result = max(result, toInlineFlowBox(curr)->computeOverAnnotationAdjustment(allowedPosition));
- if (curr->renderer()->isReplaced() && curr->renderer()->isRubyRun() && curr->renderer()->style()->rubyPosition() == RubyPositionBefore) {
- RenderRubyRun* rubyRun = toRenderRubyRun(curr->renderer());
- RenderRubyText* rubyText = rubyRun->rubyText();
+ if (curr->renderer().isReplaced() && curr->renderer().isRubyRun() && curr->renderer().style()->rubyPosition() == RubyPositionBefore) {
+ RenderRubyRun& rubyRun = toRenderRubyRun(curr->renderer());
+ RenderRubyText* rubyText = rubyRun.rubyText();
if (!rubyText)
continue;
- if (!rubyRun->style()->isFlippedLinesWritingMode()) {
+ if (!rubyRun.style()->isFlippedLinesWritingMode()) {
LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (rubyText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit());
if (topOfFirstRubyTextLine >= 0)
continue;
@@ -1494,7 +1521,7 @@ LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi
}
if (curr->isInlineTextBox()) {
- RenderStyle* style = curr->renderer()->style(isFirstLineStyle());
+ RenderStyle* style = curr->renderer().style(isFirstLineStyle());
TextEmphasisPosition emphasisMarkPosition;
if (style->textEmphasisMark() != TextEmphasisMarkNone && toInlineTextBox(curr)->getEmphasisMarkPosition(style, emphasisMarkPosition) && emphasisMarkPosition == TextEmphasisPositionOver) {
if (!style->isFlippedLinesWritingMode()) {
@@ -1514,19 +1541,19 @@ LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPos
{
LayoutUnit result = 0;
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
- if (curr->renderer()->isOutOfFlowPositioned())
+ if (curr->renderer().isOutOfFlowPositioned())
continue; // Positioned placeholders don't affect calculations.
if (curr->isInlineFlowBox())
result = max(result, toInlineFlowBox(curr)->computeUnderAnnotationAdjustment(allowedPosition));
- if (curr->renderer()->isReplaced() && curr->renderer()->isRubyRun() && curr->renderer()->style()->rubyPosition() == RubyPositionAfter) {
- RenderRubyRun* rubyRun = toRenderRubyRun(curr->renderer());
- RenderRubyText* rubyText = rubyRun->rubyText();
+ if (curr->renderer().isReplaced() && curr->renderer().isRubyRun() && curr->renderer().style()->rubyPosition() == RubyPositionAfter) {
+ RenderRubyRun& rubyRun = toRenderRubyRun(curr->renderer());
+ RenderRubyText* rubyText = rubyRun.rubyText();
if (!rubyText)
continue;
- if (rubyRun->style()->isFlippedLinesWritingMode()) {
+ if (rubyRun.style()->isFlippedLinesWritingMode()) {
LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (rubyText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit());
if (topOfFirstRubyTextLine >= 0)
continue;
@@ -1542,7 +1569,7 @@ LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPos
}
if (curr->isInlineTextBox()) {
- RenderStyle* style = curr->renderer()->style(isFirstLineStyle());
+ RenderStyle* style = curr->renderer().style(isFirstLineStyle());
if (style->textEmphasisMark() != TextEmphasisMarkNone && style->textEmphasisPosition() == TextEmphasisPositionUnder) {
if (!style->isFlippedLinesWritingMode()) {
LayoutUnit bottomOfEmphasisMark = curr->logicalBottom() + style->font().emphasisMarkHeight(style->textEmphasisMarkString());
@@ -1573,7 +1600,7 @@ void InlineFlowBox::collectLeafBoxesInLogicalOrder(Vector<InlineBox*>& leafBoxes
leafBoxesInLogicalOrder.append(leaf);
}
- if (renderer()->style()->rtlOrdering() == VisualOrder)
+ if (renderer().style()->rtlOrdering() == VisualOrder)
return;
// Reverse of reordering of the line (L2 according to Bidi spec):