From 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Thu, 2 Jun 2011 12:07:03 +0100 Subject: Merge WebKit at r84325: Initial merge by git. Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b --- Source/WebCore/rendering/RenderText.cpp | 46 ++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 9 deletions(-) (limited to 'Source/WebCore/rendering/RenderText.cpp') diff --git a/Source/WebCore/rendering/RenderText.cpp b/Source/WebCore/rendering/RenderText.cpp index e660875..b35820a 100644 --- a/Source/WebCore/rendering/RenderText.cpp +++ b/Source/WebCore/rendering/RenderText.cpp @@ -177,7 +177,7 @@ void RenderText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyl } } -void RenderText::destroy() +void RenderText::removeAndDestroyTextBoxes() { if (!documentBeingDestroyed()) { if (firstTextBox()) { @@ -192,6 +192,11 @@ void RenderText::destroy() parent()->dirtyLinesFromChangedChild(this); } deleteTextBoxes(); +} + +void RenderText::destroy() +{ + removeAndDestroyTextBoxes(); RenderObject::destroy(); } @@ -268,7 +273,7 @@ PassRefPtr RenderText::originalText() const void RenderText::absoluteRects(Vector& rects, int tx, int ty) { for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) - rects.append(IntRect(tx + box->x(), ty + box->y(), box->logicalWidth(), box->logicalHeight())); + rects.append(enclosingIntRect(FloatRect(tx + box->x(), ty + box->y(), box->width(), box->height()))); } void RenderText::absoluteRectsForRange(Vector& rects, unsigned start, unsigned end, bool useSelectionHeight) @@ -1300,15 +1305,38 @@ IntRect RenderText::linesBoundingBox() const return result; } -IntRect RenderText::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) +IntRect RenderText::linesVisualOverflowBoundingBox() const { - RenderObject* cb = containingBlock(); - // The containing block may be an ancestor of repaintContainer, but we need to do a repaintContainer-relative repaint. - if (repaintContainer && repaintContainer != cb) { - if (!cb->isDescendantOf(repaintContainer)) - return repaintContainer->clippedOverflowRectForRepaint(repaintContainer); + if (!firstTextBox()) + return IntRect(); + + // Return the width of the minimal left side and the maximal right side. + int logicalLeftSide = numeric_limits::max(); + int logicalRightSide = numeric_limits::min(); + for (InlineTextBox* curr = firstTextBox(); curr; curr = curr->nextTextBox()) { + logicalLeftSide = min(logicalLeftSide, curr->logicalLeftVisualOverflow()); + logicalRightSide = max(logicalRightSide, curr->logicalRightVisualOverflow()); } - return cb->clippedOverflowRectForRepaint(repaintContainer); + + int logicalTop = firstTextBox()->logicalTopVisualOverflow(); + int logicalWidth = logicalRightSide - logicalLeftSide; + int logicalHeight = lastTextBox()->logicalBottomVisualOverflow() - logicalTop; + + IntRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight); + if (!style()->isHorizontalWritingMode()) + rect = rect.transposedRect(); + return rect; +} + +IntRect RenderText::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) +{ + bool repaintContainerSkipped; + RenderObject* container = this->container(repaintContainer, &repaintContainerSkipped); + // The container may be an ancestor of repaintContainer, but we need to do a repaintContainer-relative repaint. + if (repaintContainerSkipped) + return repaintContainer->clippedOverflowRectForRepaint(repaintContainer); + + return container->clippedOverflowRectForRepaint(repaintContainer); } IntRect RenderText::selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent) -- cgit v1.1