Commit 1947a216 authored by eae@chromium.org's avatar eae@chromium.org

Switch rendering tree selection code to to new layout types

https://bugs.webkit.org/show_bug.cgi?id=63762

Reviewed by Eric Seidel.

Switch selection getters and selection gap calculation methods over to
new layout abstraction.

No new tests, no functionality changes.

* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::selectionTop):
(WebCore::InlineTextBox::selectionBottom):
(WebCore::InlineTextBox::selectionHeight):
(WebCore::InlineTextBox::isSelected):
* rendering/InlineTextBox.h:
* rendering/RenderBR.h:
(WebCore::RenderBR::selectionRectForRepaint):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::selectionGapRectsForRepaint):
(WebCore::RenderBlock::selectionGaps):
(WebCore::RenderBlock::inlineSelectionGaps):
(WebCore::RenderBlock::blockSelectionGaps):
(WebCore::RenderBlock::blockSelectionGap):
(WebCore::RenderBlock::logicalLeftSelectionGap):
(WebCore::RenderBlock::logicalRightSelectionGap):
(WebCore::RenderBlock::logicalLeftSelectionOffset):
(WebCore::RenderBlock::logicalRightSelectionOffset):
(WebCore::RenderBlock::positionForPointWithInlineChildren):
(WebCore::RenderBlock::desiredColumnWidth):
* rendering/RenderBlock.h:
(WebCore::RenderBlock::selectionRectForRepaint):
* rendering/RenderListMarker.cpp:
(WebCore::RenderListMarker::selectionRectForRepaint):
* rendering/RenderListMarker.h:
* rendering/RenderObject.h:
(WebCore::RenderObject::selectionRect):
(WebCore::RenderObject::selectionRectForRepaint):
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::selectionRectForRepaint):
* rendering/RenderReplaced.h:
* rendering/RenderSelectionInfo.h:
(WebCore::RenderSelectionInfo::RenderSelectionInfo):
* rendering/RenderText.cpp:
(WebCore::RenderText::selectionRectForRepaint):
* rendering/RenderText.h:
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::selectionTop):
(WebCore::RootInlineBox::selectionBottom):
* rendering/RootInlineBox.h:
(WebCore::RootInlineBox::selectionHeight):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@90596 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent df9d0779
2011-07-07 Emil A Eklund <eae@chromium.org>
Switch rendering tree selection code to to new layout types
https://bugs.webkit.org/show_bug.cgi?id=63762
Reviewed by Eric Seidel.
Switch selection getters and selection gap calculation methods over to
new layout abstraction.
No new tests, no functionality changes.
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::selectionTop):
(WebCore::InlineTextBox::selectionBottom):
(WebCore::InlineTextBox::selectionHeight):
(WebCore::InlineTextBox::isSelected):
* rendering/InlineTextBox.h:
* rendering/RenderBR.h:
(WebCore::RenderBR::selectionRectForRepaint):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::selectionGapRectsForRepaint):
(WebCore::RenderBlock::selectionGaps):
(WebCore::RenderBlock::inlineSelectionGaps):
(WebCore::RenderBlock::blockSelectionGaps):
(WebCore::RenderBlock::blockSelectionGap):
(WebCore::RenderBlock::logicalLeftSelectionGap):
(WebCore::RenderBlock::logicalRightSelectionGap):
(WebCore::RenderBlock::logicalLeftSelectionOffset):
(WebCore::RenderBlock::logicalRightSelectionOffset):
(WebCore::RenderBlock::positionForPointWithInlineChildren):
(WebCore::RenderBlock::desiredColumnWidth):
* rendering/RenderBlock.h:
(WebCore::RenderBlock::selectionRectForRepaint):
* rendering/RenderListMarker.cpp:
(WebCore::RenderListMarker::selectionRectForRepaint):
* rendering/RenderListMarker.h:
* rendering/RenderObject.h:
(WebCore::RenderObject::selectionRect):
(WebCore::RenderObject::selectionRectForRepaint):
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::selectionRectForRepaint):
* rendering/RenderReplaced.h:
* rendering/RenderSelectionInfo.h:
(WebCore::RenderSelectionInfo::RenderSelectionInfo):
* rendering/RenderText.cpp:
(WebCore::RenderText::selectionRectForRepaint):
* rendering/RenderText.h:
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::selectionTop):
(WebCore::RootInlineBox::selectionBottom):
* rendering/RootInlineBox.h:
(WebCore::RootInlineBox::selectionHeight):
2011-07-07 Gavin Peters <gavinp@chromium.org>
Reviewed by Alexey Proskuryakov.
......
......@@ -98,25 +98,25 @@ int InlineTextBox::lineHeight() const
return toRenderBoxModelObject(renderer()->parent())->lineHeight(m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine);
}
int InlineTextBox::selectionTop()
LayoutUnit InlineTextBox::selectionTop()
{
return root()->selectionTop();
}
int InlineTextBox::selectionBottom()
LayoutUnit InlineTextBox::selectionBottom()
{
return root()->selectionBottom();
}
int InlineTextBox::selectionHeight()
LayoutUnit InlineTextBox::selectionHeight()
{
return root()->selectionHeight();
}
bool InlineTextBox::isSelected(int startPos, int endPos) const
{
int sPos = max(startPos - m_start, 0);
int ePos = min(endPos - m_start, (int)m_len);
LayoutUnit sPos = max<LayoutUnit>(startPos - m_start, 0);
LayoutUnit ePos = min<LayoutUnit>(endPos - m_start, m_len);
return (sPos < ePos);
}
......
......@@ -95,9 +95,9 @@ public:
virtual const char* boxName() const;
#endif
private:
int selectionTop();
int selectionBottom();
int selectionHeight();
LayoutUnit selectionTop();
LayoutUnit selectionBottom();
LayoutUnit selectionHeight();
TextRun constructTextRun(RenderStyle*, const Font&, BufferForAppendingHyphen* = 0) const;
TextRun constructTextRun(RenderStyle*, const Font&, const UChar*, int length, BufferForAppendingHyphen* = 0) const;
......
......@@ -38,7 +38,7 @@ public:
virtual const char* renderName() const { return "RenderBR"; }
virtual IntRect selectionRectForRepaint(RenderBoxModelObject* /*repaintContainer*/, bool /*clipToVisibleContent*/) { return IntRect(); }
virtual LayoutRect selectionRectForRepaint(RenderBoxModelObject* /*repaintContainer*/, bool /*clipToVisibleContent*/) { return LayoutRect(); }
virtual float width(unsigned /*from*/, unsigned /*len*/, const Font&, float /*xPos*/, HashSet<const SimpleFontData*>* = 0 /*fallbackFonts*/ , GlyphOverflow* = 0) const { return 0; }
virtual float width(unsigned /*from*/, unsigned /*len*/, float /*xpos*/, bool = false /*firstLine*/, HashSet<const SimpleFontData*>* = 0 /*fallbackFonts*/, GlyphOverflow* = 0) const { return 0; }
......
......@@ -2754,9 +2754,9 @@ GapRects RenderBlock::selectionGapRectsForRepaint(RenderBoxModelObject* repaintC
if (hasOverflowClip())
offsetFromRepaintContainer -= layer()->scrolledContentOffset();
int lastTop = 0;
int lastLeft = logicalLeftSelectionOffset(this, lastTop);
int lastRight = logicalRightSelectionOffset(this, lastTop);
LayoutUnit lastTop = 0;
LayoutUnit lastLeft = logicalLeftSelectionOffset(this, lastTop);
LayoutUnit lastRight = logicalRightSelectionOffset(this, lastTop);
return selectionGaps(this, offsetFromRepaintContainer, IntSize(), lastTop, lastLeft, lastRight);
}
......@@ -2819,14 +2819,14 @@ IntRect RenderBlock::logicalRectToPhysicalRect(const IntPoint& rootBlockPhysical
return result;
}
GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
int& lastLogicalTop, int& lastLogicalLeft, int& lastLogicalRight, const PaintInfo* paintInfo)
GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo)
{
// IMPORTANT: Callers of this method that intend for painting to happen need to do a save/restore.
// Clip out floating and positioned objects when painting selection gaps.
if (paintInfo) {
// Note that we don't clip out overflow for positioned objects. We just stick to the border box.
IntRect flippedBlockRect = IntRect(offsetFromRootBlock.width(), offsetFromRootBlock.height(), width(), height());
LayoutRect flippedBlockRect(offsetFromRootBlock.width(), offsetFromRootBlock.height(), width(), height());
rootBlock->flipForWritingMode(flippedBlockRect);
flippedBlockRect.moveBy(rootBlockPhysicalPosition);
clipOutPositionedObjects(paintInfo, flippedBlockRect.location(), m_positionedObjects.get());
......@@ -2838,9 +2838,9 @@ GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const IntPoint& root
FloatingObjectSetIterator end = floatingObjectSet.end();
for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
FloatingObject* r = *it;
IntRect floatBox = IntRect(offsetFromRootBlock.width() + xPositionForFloatIncludingMargin(r),
offsetFromRootBlock.height() + yPositionForFloatIncludingMargin(r),
r->m_renderer->width(), r->m_renderer->height());
LayoutRect floatBox(offsetFromRootBlock.width() + xPositionForFloatIncludingMargin(r),
offsetFromRootBlock.height() + yPositionForFloatIncludingMargin(r),
r->m_renderer->width(), r->m_renderer->height());
rootBlock->flipForWritingMode(floatBox);
floatBox.move(rootBlockPhysicalPosition.x(), rootBlockPhysicalPosition.y());
paintInfo->context->clipOut(floatBox);
......@@ -2874,8 +2874,8 @@ GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const IntPoint& root
return result;
}
GapRects RenderBlock::inlineSelectionGaps(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
int& lastLogicalTop, int& lastLogicalLeft, int& lastLogicalRight, const PaintInfo* paintInfo)
GapRects RenderBlock::inlineSelectionGaps(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo)
{
GapRects result;
......@@ -2898,16 +2898,16 @@ GapRects RenderBlock::inlineSelectionGaps(RenderBlock* rootBlock, const IntPoint
// Now paint the gaps for the lines.
for (; curr && curr->hasSelectedChildren(); curr = curr->nextRootBox()) {
int selTop = curr->selectionTop();
int selHeight = curr->selectionHeight();
LayoutUnit selTop = curr->selectionTop();
LayoutUnit selHeight = curr->selectionHeight();
if (!containsStart && !lastSelectedLine &&
selectionState() != SelectionStart && selectionState() != SelectionBoth)
result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight,
selTop, paintInfo));
IntRect logicalRect(curr->logicalLeft(), selTop, curr->logicalWidth(), selTop + selHeight);
logicalRect.move(isHorizontalWritingMode() ? offsetFromRootBlock : IntSize(offsetFromRootBlock.height(), offsetFromRootBlock.width()));
LayoutRect logicalRect(curr->logicalLeft(), selTop, curr->logicalWidth(), selTop + selHeight);
logicalRect.move(isHorizontalWritingMode() ? offsetFromRootBlock : offsetFromRootBlock.transposedSize());
IntRect physicalRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalPosition, logicalRect);
if (!paintInfo || (isHorizontalWritingMode() && physicalRect.y() < paintInfo->rect.maxY() && physicalRect.maxY() > paintInfo->rect.y())
|| (!isHorizontalWritingMode() && physicalRect.x() < paintInfo->rect.maxX() && physicalRect.maxX() > paintInfo->rect.x()))
......@@ -2929,8 +2929,8 @@ GapRects RenderBlock::inlineSelectionGaps(RenderBlock* rootBlock, const IntPoint
return result;
}
GapRects RenderBlock::blockSelectionGaps(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
int& lastLogicalTop, int& lastLogicalLeft, int& lastLogicalRight, const PaintInfo* paintInfo)
GapRects RenderBlock::blockSelectionGaps(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo)
{
GapRects result;
......@@ -2949,7 +2949,7 @@ GapRects RenderBlock::blockSelectionGaps(RenderBlock* rootBlock, const IntPoint&
if (curr->isRelPositioned() && curr->hasLayer()) {
// If the relposition offset is anything other than 0, then treat this just like an absolute positioned element.
// Just disregard it completely.
IntSize relOffset = curr->layer()->relativePositionOffset();
LayoutSize relOffset = curr->layer()->relativePositionOffset();
if (relOffset.width() || relOffset.height())
continue;
}
......@@ -2985,60 +2985,60 @@ GapRects RenderBlock::blockSelectionGaps(RenderBlock* rootBlock, const IntPoint&
lastLogicalRight = logicalRightSelectionOffset(rootBlock, curr->logicalBottom());
} else if (childState != SelectionNone)
// We must be a block that has some selected object inside it. Go ahead and recur.
result.unite(toRenderBlock(curr)->selectionGaps(rootBlock, rootBlockPhysicalPosition, IntSize(offsetFromRootBlock.width() + curr->x(), offsetFromRootBlock.height() + curr->y()),
result.unite(toRenderBlock(curr)->selectionGaps(rootBlock, rootBlockPhysicalPosition, LayoutSize(offsetFromRootBlock.width() + curr->x(), offsetFromRootBlock.height() + curr->y()),
lastLogicalTop, lastLogicalLeft, lastLogicalRight, paintInfo));
}
return result;
}
IntRect RenderBlock::blockSelectionGap(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
int lastLogicalTop, int lastLogicalLeft, int lastLogicalRight, int logicalBottom, const PaintInfo* paintInfo)
LayoutRect RenderBlock::blockSelectionGap(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
LayoutUnit lastLogicalTop, LayoutUnit lastLogicalLeft, LayoutUnit lastLogicalRight, LayoutUnit logicalBottom, const PaintInfo* paintInfo)
{
int logicalTop = lastLogicalTop;
int logicalHeight = blockDirectionOffset(rootBlock, offsetFromRootBlock) + logicalBottom - logicalTop;
if (logicalHeight <= 0)
return IntRect();
LayoutUnit logicalTop = lastLogicalTop;
LayoutUnit logicalHeight = blockDirectionOffset(rootBlock, offsetFromRootBlock) + logicalBottom - logicalTop;
if (logicalHeight <= static_cast<LayoutUnit>(0))
return LayoutRect();
// Get the selection offsets for the bottom of the gap
int logicalLeft = max(lastLogicalLeft, logicalLeftSelectionOffset(rootBlock, logicalBottom));
int logicalRight = min(lastLogicalRight, logicalRightSelectionOffset(rootBlock, logicalBottom));
int logicalWidth = logicalRight - logicalLeft;
if (logicalWidth <= 0)
return IntRect();
LayoutUnit logicalLeft = max(lastLogicalLeft, logicalLeftSelectionOffset(rootBlock, logicalBottom));
LayoutUnit logicalRight = min(lastLogicalRight, logicalRightSelectionOffset(rootBlock, logicalBottom));
LayoutUnit logicalWidth = logicalRight - logicalLeft;
if (logicalWidth <= static_cast<LayoutUnit>(0))
return LayoutRect();
IntRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalPosition, IntRect(logicalLeft, logicalTop, logicalWidth, logicalHeight));
LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalPosition, LayoutRect(logicalLeft, logicalTop, logicalWidth, logicalHeight));
if (paintInfo)
paintInfo->context->fillRect(gapRect, selectionBackgroundColor(), style()->colorSpace());
return gapRect;
}
IntRect RenderBlock::logicalLeftSelectionGap(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
RenderObject* selObj, int logicalLeft, int logicalTop, int logicalHeight, const PaintInfo* paintInfo)
LayoutRect RenderBlock::logicalLeftSelectionGap(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
RenderObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo* paintInfo)
{
int rootBlockLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock) + logicalTop;
int rootBlockLogicalLeft = max(logicalLeftSelectionOffset(rootBlock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight));
int rootBlockLogicalRight = min(inlineDirectionOffset(rootBlock, offsetFromRootBlock) + logicalLeft, min(logicalRightSelectionOffset(rootBlock, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHeight)));
int rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalLeft;
if (rootBlockLogicalWidth <= 0)
return IntRect();
LayoutUnit rootBlockLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock) + logicalTop;
LayoutUnit rootBlockLogicalLeft = max(logicalLeftSelectionOffset(rootBlock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight));
LayoutUnit rootBlockLogicalRight = min(inlineDirectionOffset(rootBlock, offsetFromRootBlock) + logicalLeft, min(logicalRightSelectionOffset(rootBlock, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHeight)));
LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalLeft;
if (rootBlockLogicalWidth <= static_cast<LayoutUnit>(0))
return LayoutRect();
IntRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalPosition, IntRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalWidth, logicalHeight));
LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalPosition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalWidth, logicalHeight));
if (paintInfo)
paintInfo->context->fillRect(gapRect, selObj->selectionBackgroundColor(), selObj->style()->colorSpace());
return gapRect;
}
IntRect RenderBlock::logicalRightSelectionGap(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
RenderObject* selObj, int logicalRight, int logicalTop, int logicalHeight, const PaintInfo* paintInfo)
LayoutRect RenderBlock::logicalRightSelectionGap(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
RenderObject* selObj, int logicalRight, int logicalTop, int logicalHeight, const PaintInfo* paintInfo)
{
int rootBlockLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock) + logicalTop;
int rootBlockLogicalLeft = max(inlineDirectionOffset(rootBlock, offsetFromRootBlock) + logicalRight, max(logicalLeftSelectionOffset(rootBlock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight)));
int rootBlockLogicalRight = min(logicalRightSelectionOffset(rootBlock, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHeight));
int rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalLeft;
if (rootBlockLogicalWidth <= 0)
return IntRect();
LayoutUnit rootBlockLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock) + logicalTop;
LayoutUnit rootBlockLogicalLeft = max(inlineDirectionOffset(rootBlock, offsetFromRootBlock) + logicalRight, max(logicalLeftSelectionOffset(rootBlock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight)));
LayoutUnit rootBlockLogicalRight = min(logicalRightSelectionOffset(rootBlock, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHeight));
LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalLeft;
if (rootBlockLogicalWidth <= static_cast<LayoutUnit>(0))
return LayoutRect();
IntRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalPosition, IntRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalWidth, logicalHeight));
LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalPosition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalWidth, logicalHeight));
if (paintInfo)
paintInfo->context->fillRect(gapRect, selObj->selectionBackgroundColor(), selObj->style()->colorSpace());
return gapRect;
......@@ -3055,9 +3055,9 @@ void RenderBlock::getSelectionGapInfo(SelectionState state, bool& leftGap, bool&
(state == RenderObject::SelectionEnd && !ltr);
}
int RenderBlock::logicalLeftSelectionOffset(RenderBlock* rootBlock, int position)
LayoutUnit RenderBlock::logicalLeftSelectionOffset(RenderBlock* rootBlock, LayoutUnit position)
{
int logicalLeft = logicalLeftOffsetForLine(position, false);
LayoutUnit logicalLeft = logicalLeftOffsetForLine(position, false);
if (logicalLeft == logicalLeftOffsetForContent()) {
if (rootBlock != this)
// The border can potentially be further extended by our containingBlock().
......@@ -3073,9 +3073,9 @@ int RenderBlock::logicalLeftSelectionOffset(RenderBlock* rootBlock, int position
return logicalLeft;
}
int RenderBlock::logicalRightSelectionOffset(RenderBlock* rootBlock, int position)
LayoutUnit RenderBlock::logicalRightSelectionOffset(RenderBlock* rootBlock, LayoutUnit position)
{
int logicalRight = logicalRightOffsetForLine(position, false);
LayoutUnit logicalRight = logicalRightOffsetForLine(position, false);
if (logicalRight == logicalRightOffsetForContent()) {
if (rootBlock != this)
// The border can potentially be further extended by our containingBlock().
......@@ -4145,7 +4145,7 @@ static VisiblePosition positionForPointRespectingEditingBoundaries(RenderBlock*
return ancestor->createVisiblePosition(childNode->nodeIndex() + 1, UPSTREAM);
}
VisiblePosition RenderBlock::positionForPointWithInlineChildren(const IntPoint& pointInLogicalContents)
VisiblePosition RenderBlock::positionForPointWithInlineChildren(const LayoutPoint& pointInLogicalContents)
{
ASSERT(childrenInline());
......@@ -4336,7 +4336,7 @@ void RenderBlock::setDesiredColumnCountAndWidth(int count, int width)
}
}
int RenderBlock::desiredColumnWidth() const
LayoutUnit RenderBlock::desiredColumnWidth() const
{
if (!hasColumns())
return contentLogicalWidth();
......
......@@ -298,8 +298,8 @@ protected:
virtual void paint(PaintInfo&, const LayoutPoint&);
virtual void paintObject(PaintInfo&, const LayoutPoint&);
int logicalRightOffsetForLine(int position, int fixedOffset, bool applyTextIndent = true, int* logicalHeightRemaining = 0) const;
int logicalLeftOffsetForLine(int position, int fixedOffset, bool applyTextIndent = true, int* logicalHeightRemaining = 0) const;
LayoutUnit logicalRightOffsetForLine(LayoutUnit position, LayoutUnit fixedOffset, bool applyTextIndent = true, int* logicalHeightRemaining = 0) const;
LayoutUnit logicalLeftOffsetForLine(LayoutUnit position, LayoutUnit fixedOffset, bool applyTextIndent = true, int* logicalHeightRemaining = 0) const;
virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const;
virtual void adjustInlineDirectionLineBounds(int /* expansionOpportunityCount */, float& /* logicalLeft */, float& /* logicalWidth */) const { }
......@@ -612,27 +612,27 @@ private:
virtual void updateDragState(bool dragOn);
virtual void childBecameNonInline(RenderObject* child);
virtual IntRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool /*clipToVisibleContent*/)
virtual LayoutRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool /*clipToVisibleContent*/)
{
return selectionGapRectsForRepaint(repaintContainer);
}
virtual bool shouldPaintSelectionGaps() const;
bool isSelectionRoot() const;
GapRects selectionGaps(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
int& lastLogicalTop, int& lastLogicalLeft, int& lastLogicalRight, const PaintInfo* = 0);
GapRects inlineSelectionGaps(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
int& lastLogicalTop, int& lastLogicalLeft, int& lastLogicalRight, const PaintInfo*);
GapRects blockSelectionGaps(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
int& lastLogicalTop, int& lastLogicalLeft, int& lastLogicalRight, const PaintInfo*);
IntRect blockSelectionGap(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
int lastLogicalTop, int lastLogicalLeft, int lastLogicalRight, int logicalBottom, const PaintInfo*);
int logicalLeftSelectionOffset(RenderBlock* rootBlock, int position);
int logicalRightSelectionOffset(RenderBlock* rootBlock, int position);
GapRects selectionGaps(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* = 0);
GapRects inlineSelectionGaps(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo*);
GapRects blockSelectionGaps(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo*);
IntRect blockSelectionGap(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
LayoutUnit lastLogicalTop, LayoutUnit lastLogicalLeft, LayoutUnit lastLogicalRight, LayoutUnit logicalBottom, const PaintInfo*);
LayoutUnit logicalLeftSelectionOffset(RenderBlock* rootBlock, LayoutUnit position);
LayoutUnit logicalRightSelectionOffset(RenderBlock* rootBlock, LayoutUnit position);
virtual void absoluteRects(Vector<LayoutRect>&, const LayoutPoint& accumulatedOffset);
virtual void absoluteQuads(Vector<FloatQuad>&);
int desiredColumnWidth() const;
LayoutUnit desiredColumnWidth() const;
unsigned desiredColumnCount() const;
void setDesiredColumnCountAndWidth(int count, int width);
......
......@@ -1698,15 +1698,15 @@ void RenderListMarker::setSelectionState(SelectionState state)
containingBlock()->setSelectionState(state);
}
IntRect RenderListMarker::selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent)
LayoutRect RenderListMarker::selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent)
{
ASSERT(!needsLayout());
if (selectionState() == SelectionNone || !inlineBoxWrapper())
return IntRect();
return LayoutRect();
RootInlineBox* root = inlineBoxWrapper()->root();
IntRect rect(0, root->selectionTop() - y(), width(), root->selectionHeight());
LayoutRect rect(0, root->selectionTop() - y(), width(), root->selectionHeight());
if (clipToVisibleContent)
computeRectForRepaint(repaintContainer, rect);
......
......@@ -65,7 +65,7 @@ private:
bool isText() const { return !isImage(); }
virtual void setSelectionState(SelectionState);
virtual IntRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent = true);
virtual LayoutRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent = true);
virtual bool canBeSelectionLeaf() const { return true; }
void updateMargins();
......
......@@ -703,8 +703,8 @@ public:
// A single rectangle that encompasses all of the selected objects within this object. Used to determine the tightest
// possible bounding box for the selection.
IntRect selectionRect(bool clipToVisibleContent = true) { return selectionRectForRepaint(0, clipToVisibleContent); }
virtual IntRect selectionRectForRepaint(RenderBoxModelObject* /*repaintContainer*/, bool /*clipToVisibleContent*/ = true) { return IntRect(); }
LayoutRect selectionRect(bool clipToVisibleContent = true) { return selectionRectForRepaint(0, clipToVisibleContent); }
virtual LayoutRect selectionRectForRepaint(RenderBoxModelObject* /*repaintContainer*/, bool /*clipToVisibleContent*/ = true) { return LayoutRect(); }
// Whether or not an object can be part of the leaf elements of the selection.
virtual bool canBeSelectionLeaf() const { return false; }
......
......@@ -431,14 +431,14 @@ VisiblePosition RenderReplaced::positionForPoint(const LayoutPoint& point)
return RenderBox::positionForPoint(point);
}
IntRect RenderReplaced::selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent)
LayoutRect RenderReplaced::selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent)
{
ASSERT(!needsLayout());
if (!isSelected())
return IntRect();
return LayoutRect();
IntRect rect = localSelectionRect();
LayoutRect rect = localSelectionRect();
if (clipToVisibleContent)
computeRectForRepaint(repaintContainer, rect);
else
......
......@@ -81,7 +81,7 @@ private:
virtual bool canBeSelectionLeaf() const { return true; }
virtual IntRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent = true);
virtual LayoutRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent = true);
IntSize m_intrinsicSize;
bool m_hasIntrinsicSize;
......
......@@ -62,7 +62,7 @@ class RenderSelectionInfo : public RenderSelectionInfoBase {
public:
RenderSelectionInfo(RenderObject* o, bool clipToVisibleContent)
: RenderSelectionInfoBase(o)
, m_rect(o->needsLayout() ? IntRect() : o->selectionRectForRepaint(m_repaintContainer, clipToVisibleContent))
, m_rect(o->needsLayout() ? LayoutRect() : o->selectionRectForRepaint(m_repaintContainer, clipToVisibleContent))
{
}
......
......@@ -1381,19 +1381,19 @@ IntRect RenderText::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintC
return rendererToRepaint->clippedOverflowRectForRepaint(repaintContainer);
}
IntRect RenderText::selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent)
LayoutRect RenderText::selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent)
{
ASSERT(!needsLayout());
if (selectionState() == SelectionNone)
return IntRect();
return LayoutRect();
RenderBlock* cb = containingBlock();
if (!cb)
return IntRect();
return LayoutRect();
// Now calculate startPos and endPos for painting selection.
// We include a selection while endPos > 0
int startPos, endPos;
LayoutUnit startPos, endPos;
if (selectionState() == SelectionInside) {
// We are fully selected.
startPos = 0;
......@@ -1409,7 +1409,7 @@ IntRect RenderText::selectionRectForRepaint(RenderBoxModelObject* repaintContain
if (startPos == endPos)
return IntRect();
IntRect rect;
LayoutRect rect;
for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
rect.unite(box->selectionRect(startPos, endPos));
rect.unite(ellipsisRectForBox(box, startPos, endPos));
......
......@@ -96,7 +96,7 @@ public:
virtual bool canBeSelectionLeaf() const { return true; }
virtual void setSelectionState(SelectionState s);
virtual IntRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent = true);
virtual LayoutRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent = true);
virtual IntRect localCaretRect(InlineBox*, int caretOffset, int* extraWidthToEndOfLine = 0);
virtual LayoutUnit marginLeft() const { return style()->marginLeft().calcMinValue(0); }
......
......@@ -396,9 +396,9 @@ InlineBox* RootInlineBox::lastSelectedBox()
return 0;
}
int RootInlineBox::selectionTop() const
LayoutUnit RootInlineBox::selectionTop() const
{
int selectionTop = m_lineTop;
LayoutUnit selectionTop = m_lineTop;
if (m_hasAnnotationsBefore)
selectionTop -= !renderer()->style()->isFlippedLinesWritingMode() ? computeOverAnnotationAdjustment(m_lineTop) : computeUnderAnnotationAdjustment(m_lineTop);
......@@ -406,15 +406,15 @@ int RootInlineBox::selectionTop() const
if (renderer()->style()->isFlippedLinesWritingMode())
return selectionTop;
int prevBottom = prevRootBox() ? prevRootBox()->selectionBottom() : block()->borderBefore() + block()->paddingBefore();
LayoutUnit prevBottom = prevRootBox() ? prevRootBox()->selectionBottom() : block()->borderBefore() + block()->paddingBefore();
if (prevBottom < selectionTop && block()->containsFloats()) {
// This line has actually been moved further down, probably from a large line-height, but possibly because the
// line was forced to clear floats. If so, let's check the offsets, and only be willing to use the previous
// line's bottom if the offsets are greater on both sides.
int prevLeft = block()->logicalLeftOffsetForLine(prevBottom, false);
int prevRight = block()->logicalRightOffsetForLine(prevBottom, false);
int newLeft = block()->logicalLeftOffsetForLine(selectionTop, false);
int newRight = block()->logicalRightOffsetForLine(selectionTop, false);
LayoutUnit prevLeft = block()->logicalLeftOffsetForLine(prevBottom, false);
LayoutUnit prevRight = block()->logicalRightOffsetForLine(prevBottom, false);
LayoutUnit newLeft = block()->logicalLeftOffsetForLine(selectionTop, false);
LayoutUnit newRight = block()->logicalRightOffsetForLine(selectionTop, false);
if (prevLeft > newLeft || prevRight < newRight)
return selectionTop;
}
......@@ -422,9 +422,9 @@ int RootInlineBox::selectionTop() const
return prevBottom;
}
int RootInlineBox::selectionBottom() const
LayoutUnit RootInlineBox::selectionBottom() const
{
int selectionBottom = m_lineBottom;
LayoutUnit selectionBottom = m_lineBottom;
if (m_hasAnnotationsAfter)
selectionBottom += !renderer()->style()->isFlippedLinesWritingMode() ? computeUnderAnnotationAdjustment(m_lineBottom) : computeOverAnnotationAdjustment(m_lineBottom);
......@@ -432,15 +432,15 @@ int RootInlineBox::selectionBottom() const
if (!renderer()->style()->isFlippedLinesWritingMode() || !nextRootBox())
return selectionBottom;
int nextTop = nextRootBox()->selectionTop();
LayoutUnit nextTop = nextRootBox()->selectionTop();
if (nextTop > selectionBottom && block()->containsFloats()) {
// The next line has actually been moved further over, probably from a large line-height, but possibly because the
// line was forced to clear floats. If so, let's check the offsets, and only be willing to use the next
// line's top if the offsets are greater on both sides.
int nextLeft = block()->logicalLeftOffsetForLine(nextTop, false);
int nextRight = block()->logicalRightOffsetForLine(nextTop, false);
int newLeft = block()->logicalLeftOffsetForLine(selectionBottom, false);
int newRight = block()->logicalRightOffsetForLine(selectionBottom, false);
LayoutUnit nextLeft = block()->logicalLeftOffsetForLine(nextTop, false);
LayoutUnit nextRight = block()->logicalRightOffsetForLine(nextTop, false);
LayoutUnit newLeft = block()->logicalLeftOffsetForLine(selectionBottom, false);
LayoutUnit newRight = block()->logicalRightOffsetForLine(selectionBottom, false);