diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
commit | 2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (patch) | |
tree | 988e8c5b116dd0466244ae2fe5af8ee9be926d76 /Source/WebCore/rendering/InlineFlowBox.cpp | |
parent | dd91e772430dc294e3bf478c119ef8d43c0a3358 (diff) | |
download | qtwebkit-2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47.tar.gz |
Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286)
Diffstat (limited to 'Source/WebCore/rendering/InlineFlowBox.cpp')
-rw-r--r-- | Source/WebCore/rendering/InlineFlowBox.cpp | 90 |
1 files changed, 50 insertions, 40 deletions
diff --git a/Source/WebCore/rendering/InlineFlowBox.cpp b/Source/WebCore/rendering/InlineFlowBox.cpp index bf84a0a03..cbd685d69 100644 --- a/Source/WebCore/rendering/InlineFlowBox.cpp +++ b/Source/WebCore/rendering/InlineFlowBox.cpp @@ -45,6 +45,13 @@ using namespace std; namespace WebCore { +class SameSizeAsInlineFlowBox : public InlineBox { + void* pointers[5]; + uint32_t bitfields : 24; +}; + +COMPILE_ASSERT(sizeof(InlineFlowBox) == sizeof(SameSizeAsInlineFlowBox), InlineFlowBox_should_stay_small); + #ifndef NDEBUG InlineFlowBox::~InlineFlowBox() @@ -102,7 +109,7 @@ void InlineFlowBox::addToLine(InlineBox* child) child->setPrevOnLine(m_lastChild); m_lastChild = child; } - child->setFirstLineStyleBit(m_firstLine); + child->setFirstLineStyleBit(isFirstLineStyle()); child->setIsHorizontal(isHorizontal()); if (child->isText()) { if (child->renderer()->parent() == renderer()) @@ -114,8 +121,8 @@ void InlineFlowBox::addToLine(InlineBox* child) } if (descendantsHaveSameLineHeightAndBaseline() && !child->renderer()->isPositioned()) { - RenderStyle* parentStyle = renderer()->style(m_firstLine); - RenderStyle* childStyle = child->renderer()->style(m_firstLine); + RenderStyle* parentStyle = renderer()->style(isFirstLineStyle()); + RenderStyle* childStyle = child->renderer()->style(isFirstLineStyle()); bool shouldClearDescendantsHaveSameLineHeightAndBaseline = false; if (child->renderer()->isReplaced()) shouldClearDescendantsHaveSameLineHeightAndBaseline = true; @@ -152,16 +159,16 @@ void InlineFlowBox::addToLine(InlineBox* child) if (!child->renderer()->isPositioned()) { if (child->isText()) { - RenderStyle* childStyle = child->renderer()->style(m_firstLine); + 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()) child->clearKnownToHaveNoOverflow(); - } else if (!child->renderer()->isBR() && (child->renderer()->style(m_firstLine)->boxShadow() || child->boxModelObject()->hasSelfPaintingLayer() + } else if (!child->renderer()->isBR() && (child->renderer()->style(isFirstLineStyle())->boxShadow() || child->boxModelObject()->hasSelfPaintingLayer() || (child->renderer()->isListMarker() && !toRenderListMarker(child->renderer())->isInside()) - || child->renderer()->style(m_firstLine)->hasBorderImageOutsets())) + || child->renderer()->style(isFirstLineStyle())->hasBorderImageOutsets())) child->clearKnownToHaveNoOverflow(); if (knownToHaveNoOverflow() && child->isInlineFlowBox() && !toInlineFlowBox(child)->knownToHaveNoOverflow()) @@ -175,7 +182,7 @@ void InlineFlowBox::removeChild(InlineBox* child) { checkConsistency(); - if (!m_dirty) + if (!isDirty()) dirtyLineBoxes(); root()->childRemoved(child); @@ -223,7 +230,7 @@ void InlineFlowBox::removeLineBoxFromRenderObject() void InlineFlowBox::extractLine() { - if (!m_extracted) + if (!extracted()) extractLineBoxFromRenderObject(); for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) child->extractLine(); @@ -236,7 +243,7 @@ void InlineFlowBox::extractLineBoxFromRenderObject() void InlineFlowBox::attachLine() { - if (m_extracted) + if (extracted()) attachLineBoxToRenderObject(); for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) child->attachLine(); @@ -365,7 +372,7 @@ float InlineFlowBox::placeBoxesInInlineDirection(float logicalLeft, bool& needsW RenderText* rt = toRenderText(text->renderer()); if (rt->textLength()) { if (needsWordSpacing && isSpaceOrNewline(rt->characters()[text->start()])) - logicalLeft += rt->style(m_firstLine)->font().wordSpacing(); + logicalLeft += rt->style(isFirstLineStyle())->font().wordSpacing(); needsWordSpacing = !isSpaceOrNewline(rt->characters()[text->end()]); } text->setLogicalLeft(logicalLeft); @@ -424,8 +431,8 @@ bool InlineFlowBox::requiresIdeographicBaseline(const GlyphOverflowAndFallbackFo if (isHorizontal()) return false; - if (renderer()->style(m_firstLine)->fontDescription().textOrientation() == TextOrientationUpright - || renderer()->style(m_firstLine)->font().primaryFont()->hasVerticalGlyphs()) + if (renderer()->style(isFirstLineStyle())->fontDescription().textOrientation() == TextOrientationUpright + || renderer()->style(isFirstLineStyle())->font().primaryFont()->hasVerticalGlyphs()) return true; for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { @@ -436,7 +443,7 @@ bool InlineFlowBox::requiresIdeographicBaseline(const GlyphOverflowAndFallbackFo if (toInlineFlowBox(curr)->requiresIdeographicBaseline(textBoxDataMap)) return true; } else { - if (curr->renderer()->style(m_firstLine)->font().primaryFont()->hasVerticalGlyphs()) + if (curr->renderer()->style(isFirstLineStyle())->font().primaryFont()->hasVerticalGlyphs()) return true; const Vector<const SimpleFontData*>* usedFonts = 0; @@ -586,8 +593,10 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei { bool isRootBox = isRootInlineBox(); if (isRootBox) { - const FontMetrics& fontMetrics = renderer()->style(m_firstLine)->fontMetrics(); - setLogicalTop(top + maxAscent - fontMetrics.ascent(baselineType)); + 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))); } LayoutUnit adjustmentForChildrenWithSameLineHeightAndBaseline = 0; @@ -626,11 +635,11 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei LayoutUnit boxHeightIncludingMargins = boxHeight; if (curr->isText() || curr->isInlineFlowBox()) { - const FontMetrics& fontMetrics = curr->renderer()->style(m_firstLine)->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(m_firstLine)->isHorizontalWritingMode() ? boxObject->borderTop() + boxObject->paddingTop() : + newLogicalTop -= boxObject->style(isFirstLineStyle())->isHorizontalWritingMode() ? boxObject->borderTop() + boxObject->paddingTop() : boxObject->borderRight() + boxObject->paddingRight(); } newLogicalTopIncludingMargins = newLogicalTop; @@ -657,17 +666,17 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei RenderRubyRun* rubyRun = toRenderRubyRun(curr->renderer()); if (RenderRubyBase* rubyBase = rubyRun->rubyBase()) { - LayoutUnit bottomRubyBaseLeading = (curr->logicalHeight() - rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox() ? rubyBase->lastRootBox()->lineBottom() : zeroLayoutUnit); - LayoutUnit topRubyBaseLeading = rubyBase->logicalTop() + (rubyBase->firstRootBox() ? rubyBase->firstRootBox()->lineTop() : zeroLayoutUnit); + LayoutUnit bottomRubyBaseLeading = (curr->logicalHeight() - rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox() ? rubyBase->lastRootBox()->lineBottom() : ZERO_LAYOUT_UNIT); + LayoutUnit topRubyBaseLeading = rubyBase->logicalTop() + (rubyBase->firstRootBox() ? rubyBase->firstRootBox()->lineTop() : ZERO_LAYOUT_UNIT); newLogicalTop += !renderer()->style()->isFlippedLinesWritingMode() ? topRubyBaseLeading : bottomRubyBaseLeading; boxHeight -= (topRubyBaseLeading + bottomRubyBaseLeading); } } if (curr->isInlineTextBox()) { TextEmphasisPosition emphasisMarkPosition; - if (toInlineTextBox(curr)->getEmphasisMarkPosition(curr->renderer()->style(m_firstLine), emphasisMarkPosition)) { + if (toInlineTextBox(curr)->getEmphasisMarkPosition(curr->renderer()->style(isFirstLineStyle()), emphasisMarkPosition)) { bool emphasisMarkIsOver = emphasisMarkPosition == TextEmphasisPositionOver; - if (emphasisMarkIsOver != curr->renderer()->style(m_firstLine)->isFlippedLinesWritingMode()) + if (emphasisMarkIsOver != curr->renderer()->style(isFirstLineStyle())->isFlippedLinesWritingMode()) hasAnnotationsBefore = true; else hasAnnotationsAfter = true; @@ -734,7 +743,7 @@ inline void InlineFlowBox::addBoxShadowVisualOverflow(LayoutRect& logicalVisualO if (!parent()) return; - RenderStyle* style = renderer()->style(m_firstLine); + RenderStyle* style = renderer()->style(isFirstLineStyle()); if (!style->boxShadow()) return; @@ -767,7 +776,7 @@ inline void InlineFlowBox::addBorderOutsetVisualOverflow(LayoutRect& logicalVisu if (!parent()) return; - RenderStyle* style = renderer()->style(m_firstLine); + RenderStyle* style = renderer()->style(isFirstLineStyle()); if (!style->hasBorderImageOutsets()) return; @@ -787,8 +796,8 @@ inline void InlineFlowBox::addBorderOutsetVisualOverflow(LayoutRect& logicalVisu LayoutUnit borderOutsetLogicalRight; style->getBorderImageInlineDirectionOutsets(borderOutsetLogicalLeft, borderOutsetLogicalRight); - LayoutUnit outsetLogicalLeft = includeLogicalLeftEdge() ? borderOutsetLogicalLeft : zeroLayoutUnit; - LayoutUnit outsetLogicalRight = includeLogicalRightEdge() ? borderOutsetLogicalRight : zeroLayoutUnit; + LayoutUnit outsetLogicalLeft = includeLogicalLeftEdge() ? borderOutsetLogicalLeft : ZERO_LAYOUT_UNIT; + LayoutUnit outsetLogicalRight = includeLogicalRightEdge() ? borderOutsetLogicalRight : ZERO_LAYOUT_UNIT; LayoutUnit logicalLeftVisualOverflow = min(pixelSnappedLogicalLeft() - outsetLogicalLeft, logicalVisualOverflow.x()); LayoutUnit logicalRightVisualOverflow = max(pixelSnappedLogicalRight() + outsetLogicalRight, logicalVisualOverflow.maxX()); @@ -802,7 +811,7 @@ inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp if (textBox->knownToHaveNoOverflow()) return; - RenderStyle* style = textBox->renderer()->style(m_firstLine); + RenderStyle* style = textBox->renderer()->style(isFirstLineStyle()); GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(textBox); GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->second.second; @@ -1116,8 +1125,8 @@ void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, c for (InlineFlowBox* curr = this; curr; curr = curr->prevLineBox()) totalLogicalWidth += curr->logicalWidth(); } - LayoutUnit stripX = rect.x() - (isHorizontal() ? logicalOffsetOnLine : zeroLayoutUnit); - LayoutUnit stripY = rect.y() - (isHorizontal() ? zeroLayoutUnit : logicalOffsetOnLine); + LayoutUnit stripX = rect.x() - (isHorizontal() ? logicalOffsetOnLine : ZERO_LAYOUT_UNIT); + LayoutUnit stripY = rect.y() - (isHorizontal() ? ZERO_LAYOUT_UNIT : logicalOffsetOnLine); LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : static_cast<LayoutUnit>(width()); LayoutUnit stripHeight = isHorizontal() ? static_cast<LayoutUnit>(height()) : totalLogicalWidth; @@ -1208,8 +1217,8 @@ 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(m_firstLine); - if ((!parent() && m_firstLine && 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)) @@ -1231,7 +1240,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(), 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. @@ -1247,15 +1256,15 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& LayoutUnit totalLogicalWidth = logicalOffsetOnLine; for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) totalLogicalWidth += curr->logicalWidth(); - LayoutUnit stripX = adjustedPaintoffset.x() - (isHorizontal() ? logicalOffsetOnLine : zeroLayoutUnit); - LayoutUnit stripY = adjustedPaintoffset.y() - (isHorizontal() ? zeroLayoutUnit : logicalOffsetOnLine); + LayoutUnit stripX = adjustedPaintoffset.x() - (isHorizontal() ? logicalOffsetOnLine : ZERO_LAYOUT_UNIT); + LayoutUnit stripY = adjustedPaintoffset.y() - (isHorizontal() ? ZERO_LAYOUT_UNIT : logicalOffsetOnLine); LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : frameRect.width(); LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : totalLogicalWidth; LayoutRect clipRect = clipRectForNinePieceImageStrip(this, borderImage, paintRect); GraphicsContextStateSaver stateSaver(*context); context->clip(clipRect); - boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer()->style()); + boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer()->style(isFirstLineStyle())); } } } @@ -1282,8 +1291,9 @@ void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs // 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; CompositeOperator compositeOp = CompositeSourceOver; - if (!compositedMask) { + if (!compositedMask || flattenCompositingLayers) { if ((maskBoxImage && renderer()->style()->maskLayers()->hasImage()) || renderer()->style()->maskLayers()->next()) pushTransparencyLayer = true; @@ -1318,8 +1328,8 @@ void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs LayoutUnit totalLogicalWidth = logicalOffsetOnLine; for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) totalLogicalWidth += curr->logicalWidth(); - LayoutUnit stripX = adjustedPaintOffset.x() - (isHorizontal() ? logicalOffsetOnLine : zeroLayoutUnit); - LayoutUnit stripY = adjustedPaintOffset.y() - (isHorizontal() ? zeroLayoutUnit : logicalOffsetOnLine); + LayoutUnit stripX = adjustedPaintOffset.x() - (isHorizontal() ? logicalOffsetOnLine : ZERO_LAYOUT_UNIT); + LayoutUnit stripY = adjustedPaintOffset.y() - (isHorizontal() ? ZERO_LAYOUT_UNIT : logicalOffsetOnLine); LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : frameRect.width(); LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : totalLogicalWidth; @@ -1416,7 +1426,7 @@ LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi continue; if (!rubyRun->style()->isFlippedLinesWritingMode()) { - LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (rubyText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : zeroLayoutUnit); + LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (rubyText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : ZERO_LAYOUT_UNIT); if (topOfFirstRubyTextLine >= 0) continue; topOfFirstRubyTextLine += curr->logicalTop(); @@ -1431,7 +1441,7 @@ LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi } if (curr->isInlineTextBox()) { - RenderStyle* style = curr->renderer()->style(m_firstLine); + RenderStyle* style = curr->renderer()->style(isFirstLineStyle()); TextEmphasisPosition emphasisMarkPosition; if (style->textEmphasisMark() != TextEmphasisMarkNone && toInlineTextBox(curr)->getEmphasisMarkPosition(style, emphasisMarkPosition) && emphasisMarkPosition == TextEmphasisPositionOver) { if (!style->isFlippedLinesWritingMode()) { @@ -1458,7 +1468,7 @@ LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPos result = max(result, toInlineFlowBox(curr)->computeUnderAnnotationAdjustment(allowedPosition)); if (curr->isInlineTextBox()) { - RenderStyle* style = curr->renderer()->style(m_firstLine); + 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()); |