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/RenderInline.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/RenderInline.cpp')
-rw-r--r-- | Source/WebCore/rendering/RenderInline.cpp | 84 |
1 files changed, 41 insertions, 43 deletions
diff --git a/Source/WebCore/rendering/RenderInline.cpp b/Source/WebCore/rendering/RenderInline.cpp index 0a5a65ee9..4449d72e3 100644 --- a/Source/WebCore/rendering/RenderInline.cpp +++ b/Source/WebCore/rendering/RenderInline.cpp @@ -146,9 +146,8 @@ static void updateStyleOfAnonymousBlockContinuations(RenderObject* block, const RenderInline* cont = toRenderBlock(block)->inlineElementContinuation(); if (oldStyle->position() == RelativePosition && hasRelPositionedInlineAncestor(cont)) continue; - RefPtr<RenderStyle> blockStyle = RenderStyle::createAnonymousStyle(block->style()); + RefPtr<RenderStyle> blockStyle = RenderStyle::createAnonymousStyleWithDisplay(block->style(), BLOCK); blockStyle->setPosition(newStyle->position()); - blockStyle->setDisplay(BLOCK); block->setStyle(blockStyle); } } @@ -281,8 +280,7 @@ void RenderInline::addChildIgnoringContinuation(RenderObject* newChild, RenderOb // inline into continuations. This involves creating an anonymous block box to hold // |newChild|. We then make that block box a continuation of this inline. We take all of // the children after |beforeChild| and put them in a clone of this object. - RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyle(style()); - newStyle->setDisplay(BLOCK); + RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(style(), BLOCK); // If inside an inline affected by relative positioning the block needs to be affected by it too. // Giving the block a layer like this allows it to collect the x/y offsets from inline parents later. @@ -426,7 +424,7 @@ void RenderInline::splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox madeNewBeforeBlock = true; } - RenderBlock* post = block->createAnonymousBlockWithSameTypeAs(pre); + RenderBlock* post = toRenderBlock(pre->createAnonymousBoxWithSameTypeAs(block)); RenderObject* boxFirst = madeNewBeforeBlock ? block->firstChild() : pre->nextSibling(); if (madeNewBeforeBlock) @@ -701,7 +699,9 @@ static LayoutUnit computeMargin(const RenderInline* renderer, const Length& marg if (margin.isFixed()) return margin.value(); if (margin.isPercent()) - return margin.calcMinValue(max<LayoutUnit>(0, renderer->containingBlock()->availableLogicalWidth())); + return minimumValueForLength(margin, max<LayoutUnit>(0, renderer->containingBlock()->availableLogicalWidth())); + if (margin.isViewportPercentage()) + return valueForLength(margin, 0, renderer->view()); return 0; } @@ -785,14 +785,14 @@ VisiblePosition RenderInline::positionForPoint(const LayoutPoint& point) return RenderBoxModelObject::positionForPoint(point); } -LayoutRect RenderInline::linesBoundingBox() const +IntRect RenderInline::linesBoundingBox() const { if (!alwaysCreateLineBoxes()) { ASSERT(!firstLineBox()); - return enclosingLayoutRect(culledInlineBoundingBox(this)); + return enclosingIntRect(culledInlineBoundingBox(this)); } - LayoutRect result; + IntRect result; // See <rdar://problem/5289721>, for an unknown reason the linked list here is sometimes inconsistent, first is non-zero and last is zero. We have been // unable to reproduce this at all (and consequently unable to figure ot why this is happening). The assert will hopefully catch the problem in debug @@ -815,7 +815,7 @@ LayoutRect RenderInline::linesBoundingBox() const float y = isHorizontal ? firstLineBox()->y() : logicalLeftSide; float width = isHorizontal ? logicalRightSide - logicalLeftSide : lastLineBox()->logicalBottom() - x; float height = isHorizontal ? lastLineBox()->logicalBottom() - y : logicalRightSide - logicalLeftSide; - result = enclosingLayoutRect(FloatRect(x, y, width, height)); + result = enclosingIntRect(FloatRect(x, y, width, height)); } return result; @@ -976,8 +976,8 @@ LayoutRect RenderInline::linesVisualOverflowBoundingBox() const return LayoutRect(); // Return the width of the minimal left side and the maximal right side. - LayoutUnit logicalLeftSide = numeric_limits<LayoutUnit>::max(); - LayoutUnit logicalRightSide = numeric_limits<LayoutUnit>::min(); + LayoutUnit logicalLeftSide = MAX_LAYOUT_UNIT; + LayoutUnit logicalRightSide = MIN_LAYOUT_UNIT; for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { logicalLeftSide = min(logicalLeftSide, curr->logicalLeftVisualOverflow()); logicalRightSide = max(logicalRightSide, curr->logicalRightVisualOverflow()); @@ -1011,18 +1011,27 @@ LayoutRect RenderInline::clippedOverflowRectForRepaint(RenderBoxModelObject* rep // Now invalidate a rectangle. LayoutUnit ow = style() ? style()->outlineSize() : 0; - + + bool hitRepaintContainer = false; + // We need to add in the relative position offsets of any inlines (including us) up to our // containing block. RenderBlock* cb = containingBlock(); for (const RenderObject* inlineFlow = this; inlineFlow && inlineFlow->isRenderInline() && inlineFlow != cb; inlineFlow = inlineFlow->parent()) { - if (inlineFlow->style()->position() == RelativePosition && inlineFlow->hasLayer()) + if (inlineFlow == repaintContainer) { + hitRepaintContainer = true; + break; + } + if (inlineFlow->style()->position() == RelativePosition && inlineFlow->hasLayer()) toRenderInline(inlineFlow)->layer()->relativePositionOffset(left, top); } LayoutRect r(-ow + left, -ow + top, boundingBox.width() + ow * 2, boundingBox.height() + ow * 2); + if (hitRepaintContainer || !cb) + return r; + if (cb->hasColumns()) cb->adjustRectForColumns(r); @@ -1036,11 +1045,8 @@ LayoutRect RenderInline::clippedOverflowRectForRepaint(RenderBoxModelObject* rep LayoutRect boxRect(LayoutPoint(), cb->cachedSizeForOverflowClip()); r = intersection(repaintRect, boxRect); } - - // FIXME: need to ensure that we compute the correct repaint rect when the repaint container - // is an inline. - if (repaintContainer != this) - cb->computeRectForRepaint(repaintContainer, r); + + cb->computeRectForRepaint(repaintContainer, r); if (ow) { for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) { @@ -1050,7 +1056,7 @@ LayoutRect RenderInline::clippedOverflowRectForRepaint(RenderBoxModelObject* rep } } - if (continuation() && !continuation()->isInline()) { + if (continuation() && !continuation()->isInline() && continuation()->parent()) { LayoutRect contRect = continuation()->rectWithOutlineForRepaint(repaintContainer, ow); r.unite(contRect); } @@ -1104,18 +1110,6 @@ void RenderInline::computeRectForRepaint(RenderBoxModelObject* repaintContainer, } } -#if ENABLE(CSS_FILTERS) - if (style()->hasFilterOutsets()) { - LayoutUnit topOutset; - LayoutUnit rightOutset; - LayoutUnit bottomOutset; - LayoutUnit leftOutset; - style()->filter().getOutsets(topOutset, rightOutset, bottomOutset, leftOutset); - rect.move(-leftOutset, -topOutset); - rect.expand(leftOutset + rightOutset, topOutset + bottomOutset); - } -#endif - if (style()->position() == RelativePosition && layer()) { // Apply the relative position offset when invalidating a rectangle. The layer // is translated, but the render box isn't, so we need to do this to get the @@ -1168,7 +1162,7 @@ LayoutSize RenderInline::offsetFromContainer(RenderObject* container, const Layo return offset; } -void RenderInline::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState& transformState, bool* wasFixed) const +void RenderInline::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState& transformState, ApplyContainerFlipOrNot applyContainerFlip, bool* wasFixed) const { if (repaintContainer == this) return; @@ -1189,9 +1183,11 @@ void RenderInline::mapLocalToContainer(RenderBoxModelObject* repaintContainer, b if (!o) return; - IntPoint centerPoint = roundedIntPoint(transformState.mappedPoint()); - if (o->isBox() && o->style()->isFlippedBlocksWritingMode()) - transformState.move(toRenderBox(o)->flipForWritingModeIncludingColumns(roundedIntPoint(transformState.mappedPoint())) - centerPoint); + if (applyContainerFlip && o->isBox() && o->style()->isFlippedBlocksWritingMode()) { + IntPoint centerPoint = roundedIntPoint(transformState.mappedPoint()); + transformState.move(toRenderBox(o)->flipForWritingModeIncludingColumns(centerPoint) - centerPoint); + applyContainerFlip = DoNotApplyContainerFlip; + } LayoutSize containerOffset = offsetFromContainer(o, roundedLayoutPoint(transformState.mappedPoint())); @@ -1211,7 +1207,7 @@ void RenderInline::mapLocalToContainer(RenderBoxModelObject* repaintContainer, b return; } - o->mapLocalToContainer(repaintContainer, fixed, useTransforms, transformState, wasFixed); + o->mapLocalToContainer(repaintContainer, fixed, useTransforms, transformState, applyContainerFlip, wasFixed); } void RenderInline::updateDragState(bool dragOn) @@ -1307,10 +1303,10 @@ LayoutUnit RenderInline::lineHeight(bool firstLine, LineDirectionMode /*directio if (firstLine && document()->usesFirstLineRules()) { RenderStyle* s = style(firstLine); if (s != style()) - return s->computedLineHeight(); + return s->computedLineHeight(view()); } - return style()->computedLineHeight(); + return style()->computedLineHeight(view()); } LayoutUnit RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const @@ -1457,6 +1453,8 @@ void RenderInline::paintOutlineForLine(GraphicsContext* graphicsContext, const L LayoutSize(thisline.width() + offset, thisline.height() + offset)); IntRect pixelSnappedBox = pixelSnappedIntRect(box); + IntRect pixelSnappedLastLine = pixelSnappedIntRect(paintOffset.x() + lastline.x(), 0, lastline.width(), 0); + IntRect pixelSnappedNextLine = pixelSnappedIntRect(paintOffset.x() + nextline.x(), 0, nextline.width(), 0); // left edge drawLineForBoxSide(graphicsContext, @@ -1486,7 +1484,7 @@ void RenderInline::paintOutlineForLine(GraphicsContext* graphicsContext, const L drawLineForBoxSide(graphicsContext, pixelSnappedBox.x() - outlineWidth, pixelSnappedBox.y() - outlineWidth, - min(pixelSnappedBox.maxX() + outlineWidth, (lastline.isEmpty() ? 1000000 : paintOffset.x() + lastline.x())), + min(pixelSnappedBox.maxX() + outlineWidth, (lastline.isEmpty() ? 1000000 : pixelSnappedLastLine.x())), pixelSnappedBox.y(), BSTop, outlineColor, outlineStyle, outlineWidth, @@ -1495,7 +1493,7 @@ void RenderInline::paintOutlineForLine(GraphicsContext* graphicsContext, const L if (lastline.maxX() < thisline.maxX()) drawLineForBoxSide(graphicsContext, - max(lastline.isEmpty() ? -1000000 : paintOffset.x() + lastline.maxX(), pixelSnappedBox.x() - outlineWidth), + max(lastline.isEmpty() ? -1000000 : pixelSnappedLastLine.maxX(), pixelSnappedBox.x() - outlineWidth), pixelSnappedBox.y() - outlineWidth, pixelSnappedBox.maxX() + outlineWidth, pixelSnappedBox.y(), @@ -1519,7 +1517,7 @@ void RenderInline::paintOutlineForLine(GraphicsContext* graphicsContext, const L drawLineForBoxSide(graphicsContext, pixelSnappedBox.x() - outlineWidth, pixelSnappedBox.maxY(), - min(pixelSnappedBox.maxX() + outlineWidth, !nextline.isEmpty() ? paintOffset.x() + nextline.x() + 1 : 1000000), + min(pixelSnappedBox.maxX() + outlineWidth, !nextline.isEmpty() ? pixelSnappedNextLine.x() + 1 : 1000000), pixelSnappedBox.maxY() + outlineWidth, BSBottom, outlineColor, outlineStyle, outlineWidth, @@ -1528,7 +1526,7 @@ void RenderInline::paintOutlineForLine(GraphicsContext* graphicsContext, const L if (nextline.maxX() < thisline.maxX()) drawLineForBoxSide(graphicsContext, - max(!nextline.isEmpty() ? paintOffset.x() + nextline.maxX() : -1000000, pixelSnappedBox.x() - outlineWidth), + max(!nextline.isEmpty() ? pixelSnappedNextLine.maxX() : -1000000, pixelSnappedBox.x() - outlineWidth), pixelSnappedBox.maxY(), pixelSnappedBox.maxX() + outlineWidth, pixelSnappedBox.maxY() + outlineWidth, |