Commit 62dc0010 authored by hyatt@apple.com's avatar hyatt@apple.com

2009-01-26 David Hyatt <hyatt@apple.com>

        Move absoluteClippedOverflowRect, linesBoundingBox and borderBoundingBox from RenderFlow to RenderInline.

        Reviewed by Eric Seidel

        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::containingBlockHeightForPositioned):
        * rendering/RenderFlow.cpp:
        * rendering/RenderFlow.h:
        * rendering/RenderInline.cpp:
        (WebCore::RenderInline::linesBoundingBox):
        (WebCore::RenderInline::absoluteClippedOverflowRect):
        * rendering/RenderInline.h:
        (WebCore::RenderInline::borderBoundingBox):
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::updateLayerPosition):
        * rendering/RenderTreeAsText.cpp:
        (WebCore::operator<<):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@40266 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c72ee774
2009-01-26 David Hyatt <hyatt@apple.com>
Move absoluteClippedOverflowRect, linesBoundingBox and borderBoundingBox from RenderFlow to RenderInline.
Reviewed by Eric Seidel
* rendering/RenderBox.cpp:
(WebCore::RenderBox::containingBlockHeightForPositioned):
* rendering/RenderFlow.cpp:
* rendering/RenderFlow.h:
* rendering/RenderInline.cpp:
(WebCore::RenderInline::linesBoundingBox):
(WebCore::RenderInline::absoluteClippedOverflowRect):
* rendering/RenderInline.h:
(WebCore::RenderInline::borderBoundingBox):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateLayerPosition):
* rendering/RenderTreeAsText.cpp:
(WebCore::operator<<):
2009-01-26 Dimitri Glazkov <dglazkov@chromium.org>
Reviewed by Eric Seidel.
......@@ -2216,7 +2216,7 @@ int RenderBox::containingBlockHeightForPositioned(const RenderObject* containing
int heightResult;
if (containingBlock->isRenderInline()) {
ASSERT(containingBlock->isRelPositioned());
heightResult = static_cast<const RenderFlow*>(containingBlock)->linesBoundingBox().height();
heightResult = static_cast<const RenderInline*>(containingBlock)->linesBoundingBox().height();
} else
heightResult = containingBlockBox->height();
......
......@@ -480,96 +480,6 @@ bool RenderFlow::hitTestLines(const HitTestRequest& request, HitTestResult& resu
return false;
}
IntRect RenderFlow::absoluteClippedOverflowRect()
{
if (isRenderInline()) {
// Only run-ins are allowed in here during layout.
ASSERT(!view() || !view()->layoutStateEnabled() || isRunIn());
if (!firstLineBox() && !continuation())
return IntRect();
// Find our leftmost position.
IntRect boundingBox(linesBoundingBox());
int left = boundingBox.x();
int top = boundingBox.y();
// Now invalidate a rectangle.
int ow = style() ? style()->outlineSize() : 0;
// We need to add in the relative position offsets of any inlines (including us) up to our
// containing block.
RenderBlock* cb = containingBlock();
for (RenderObject* inlineFlow = this; inlineFlow && inlineFlow->isRenderInline() && inlineFlow != cb;
inlineFlow = inlineFlow->parent()) {
if (inlineFlow->style()->position() == RelativePosition && inlineFlow->hasLayer())
toRenderBox(inlineFlow)->layer()->relativePositionOffset(left, top);
}
IntRect r(-ow + left, -ow + top, boundingBox.width() + ow * 2, boundingBox.height() + ow * 2);
if (cb->hasColumns())
cb->adjustRectForColumns(r);
if (cb->hasOverflowClip()) {
// cb->height() is inaccurate if we're in the middle of a layout of |cb|, so use the
// layer's size instead. Even if the layer's size is wrong, the layer itself will repaint
// anyway if its size does change.
int x = r.x();
int y = r.y();
IntRect boxRect(0, 0, cb->layer()->width(), cb->layer()->height());
cb->layer()->subtractScrolledContentOffset(x, y); // For overflow:auto/scroll/hidden.
IntRect repaintRect(x, y, r.width(), r.height());
r = intersection(repaintRect, boxRect);
}
cb->computeAbsoluteRepaintRect(r);
if (ow) {
for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) {
if (!curr->isText()) {
IntRect childRect = curr->getAbsoluteRepaintRectWithOutline(ow);
r.unite(childRect);
}
}
if (continuation() && !continuation()->isInline()) {
IntRect contRect = continuation()->getAbsoluteRepaintRectWithOutline(ow);
r.unite(contRect);
}
}
return r;
}
return RenderContainer::absoluteClippedOverflowRect();
}
IntRect RenderFlow::linesBoundingBox() const
{
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
// builds and help us someday figure out why. We also put in a redundant check of lastLineBox() to avoid the crash for now.
ASSERT(!firstLineBox() == !lastLineBox()); // Either both are null or both exist.
if (firstLineBox() && lastLineBox()) {
// Return the width of the minimal left side and the maximal right side.
int leftSide = 0;
int rightSide = 0;
for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
if (curr == firstLineBox() || curr->xPos() < leftSide)
leftSide = curr->xPos();
if (curr == firstLineBox() || curr->xPos() + curr->width() > rightSide)
rightSide = curr->xPos() + curr->width();
}
result.setWidth(rightSide - leftSide);
result.setX(leftSide);
result.setHeight(lastLineBox()->yPos() + lastLineBox()->height() - firstLineBox()->yPos());
result.setY(firstLineBox()->yPos());
}
return result;
}
int RenderFlow::lowestPosition(bool includeOverflowInterior, bool includeSelf) const
{
ASSERT(!isRenderInline());
......
......@@ -89,8 +89,6 @@ public:
void paintLines(PaintInfo&, int tx, int ty);
bool hitTestLines(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
virtual IntRect absoluteClippedOverflowRect();
virtual int lowestPosition(bool includeOverflowInterior = true, bool includeSelf = true) const;
virtual int rightmostPosition(bool includeOverflowInterior = true, bool includeSelf = true) const;
virtual int leftmostPosition(bool includeOverflowInterior = true, bool includeSelf = true) const;
......@@ -107,17 +105,6 @@ public:
void checkConsistency() const;
IntRect linesBoundingBox() const;
virtual IntRect borderBoundingBox() const
{
if (isRenderInline()) {
IntRect boundingBox = linesBoundingBox();
return IntRect(0, 0, boundingBox.width(), boundingBox.height());
}
return borderBoxRect();
}
private:
// An inline can be split with blocks occurring in between the inline content.
// When this occurs we need a pointer to our next object. We can basically be
......
......@@ -28,6 +28,7 @@
#include "FloatQuad.h"
#include "RenderArena.h"
#include "RenderBlock.h"
#include "RenderView.h"
#include "VisiblePosition.h"
namespace WebCore {
......@@ -371,4 +372,90 @@ VisiblePosition RenderInline::positionForCoordinates(int x, int y)
return RenderFlow::positionForCoordinates(x, y);
}
IntRect RenderInline::linesBoundingBox() const
{
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
// builds and help us someday figure out why. We also put in a redundant check of lastLineBox() to avoid the crash for now.
ASSERT(!firstLineBox() == !lastLineBox()); // Either both are null or both exist.
if (firstLineBox() && lastLineBox()) {
// Return the width of the minimal left side and the maximal right side.
int leftSide = 0;
int rightSide = 0;
for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
if (curr == firstLineBox() || curr->xPos() < leftSide)
leftSide = curr->xPos();
if (curr == firstLineBox() || curr->xPos() + curr->width() > rightSide)
rightSide = curr->xPos() + curr->width();
}
result.setWidth(rightSide - leftSide);
result.setX(leftSide);
result.setHeight(lastLineBox()->yPos() + lastLineBox()->height() - firstLineBox()->yPos());
result.setY(firstLineBox()->yPos());
}
return result;
}
IntRect RenderInline::absoluteClippedOverflowRect()
{
// Only run-ins are allowed in here during layout.
ASSERT(!view() || !view()->layoutStateEnabled() || isRunIn());
if (!firstLineBox() && !continuation())
return IntRect();
// Find our leftmost position.
IntRect boundingBox(linesBoundingBox());
int left = boundingBox.x();
int top = boundingBox.y();
// Now invalidate a rectangle.
int ow = style() ? style()->outlineSize() : 0;
// We need to add in the relative position offsets of any inlines (including us) up to our
// containing block.
RenderBlock* cb = containingBlock();
for (RenderObject* inlineFlow = this; inlineFlow && inlineFlow->isRenderInline() && inlineFlow != cb;
inlineFlow = inlineFlow->parent()) {
if (inlineFlow->style()->position() == RelativePosition && inlineFlow->hasLayer())
toRenderBox(inlineFlow)->layer()->relativePositionOffset(left, top);
}
IntRect r(-ow + left, -ow + top, boundingBox.width() + ow * 2, boundingBox.height() + ow * 2);
if (cb->hasColumns())
cb->adjustRectForColumns(r);
if (cb->hasOverflowClip()) {
// cb->height() is inaccurate if we're in the middle of a layout of |cb|, so use the
// layer's size instead. Even if the layer's size is wrong, the layer itself will repaint
// anyway if its size does change.
int x = r.x();
int y = r.y();
IntRect boxRect(0, 0, cb->layer()->width(), cb->layer()->height());
cb->layer()->subtractScrolledContentOffset(x, y); // For overflow:auto/scroll/hidden.
IntRect repaintRect(x, y, r.width(), r.height());
r = intersection(repaintRect, boxRect);
}
cb->computeAbsoluteRepaintRect(r);
if (ow) {
for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) {
if (!curr->isText()) {
IntRect childRect = curr->getAbsoluteRepaintRectWithOutline(ow);
r.unite(childRect);
}
}
if (continuation() && !continuation()->isInline()) {
IntRect contRect = continuation()->getAbsoluteRepaintRectWithOutline(ow);
r.unite(contRect);
}
}
return r;
}
} // namespace WebCore
......@@ -65,8 +65,18 @@ public:
void absoluteRects(Vector<IntRect>&, int tx, int ty, bool topLevel = true);
virtual void absoluteQuads(Vector<FloatQuad>&, bool topLevel = true);
virtual IntRect absoluteClippedOverflowRect();
virtual VisiblePosition positionForCoordinates(int x, int y);
IntRect linesBoundingBox() const;
virtual IntRect borderBoundingBox() const
{
IntRect boundingBox = linesBoundingBox();
return IntRect(0, 0, boundingBox.width(), boundingBox.height());
}
protected:
virtual void styleDidChange(RenderStyle::Diff, const RenderStyle* oldStyle);
......
......@@ -427,7 +427,7 @@ void RenderLayer::updateLayerPosition()
setPos(x, y);
if (renderer()->isRenderInline()) {
RenderFlow* inlineFlow = static_cast<RenderFlow*>(renderer());
RenderInline* inlineFlow = static_cast<RenderInline*>(renderer());
IntRect lineBox = inlineFlow->linesBoundingBox();
setWidth(lineBox.width());
setHeight(lineBox.height());
......
......@@ -195,7 +195,7 @@ static TextStream &operator<<(TextStream& ts, const RenderObject& o)
} else if (o.isBox()) {
if (o.isRenderInline()) {
// FIXME: Would be better not to just dump 0, 0 as the x and y here.
const RenderFlow& inlineFlow = static_cast<const RenderFlow&>(o);
const RenderInline& inlineFlow = static_cast<const RenderInline&>(o);
r = IntRect(0, 0, inlineFlow.linesBoundingBox().width(), inlineFlow.linesBoundingBox().height());
adjustForTableCells = false;
} else if (o.isTableCell()) {
......
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