Diff
Modified: trunk/Source/WebCore/ChangeLog (112165 => 112166)
--- trunk/Source/WebCore/ChangeLog 2012-03-26 22:59:53 UTC (rev 112165)
+++ trunk/Source/WebCore/ChangeLog 2012-03-26 23:01:23 UTC (rev 112166)
@@ -1,3 +1,41 @@
+2012-03-26 Levi Weintraub <[email protected]>
+
+ Update localSelectionRect to return a LayoutRect
+ https://bugs.webkit.org/show_bug.cgi?id=82183
+
+ Reviewed by Eric Seidel.
+
+ localSelectionRect returns a rectangle in the coordinate space of its renderer,
+ and therefor should remain LayoutUnits until being promoted to absolute
+ coordinates or painted. Also fixing an incorrect conversion of startPos and
+ endPos in selectionRectForRepaint.
+
+ No new tests. No change in behavior.
+
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::localSelectionRect): Continuing to use enclosingIntRect
+ for the value being returned from the font engine since these floating point
+ values should not be pixel snapped.
+ * rendering/InlineTextBox.h:
+ (InlineTextBox):
+ * rendering/RenderReplaced.cpp:
+ (WebCore::RenderReplaced::localSelectionRect):
+ * rendering/RenderReplaced.h:
+ (RenderReplaced):
+ * rendering/RenderText.cpp:
+ (WebCore::localQuadForTextBox):
+ (WebCore::RenderText::absoluteRectsForRange):
+ (WebCore::RenderText::absoluteQuadsForRange):
+ (WebCore::RenderText::selectionRectForRepaint): Fixing an incorrect conversion of
+ start/endPos to LayoutUnits. These values represent a range of selected characters,
+ not layout values!
+ * rendering/svg/RenderSVGInlineText.cpp:
+ (WebCore::RenderSVGInlineText::localCaretRect):
+ * rendering/svg/SVGInlineTextBox.cpp:
+ (WebCore::SVGInlineTextBox::localSelectionRect):
+ * rendering/svg/SVGInlineTextBox.h:
+ (SVGInlineTextBox):
+
2012-03-26 Justin Novosad <[email protected]>
[Chromium] Crash in Canvas2DLayerChromium::pushPropertiesTo
Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (112165 => 112166)
--- trunk/Source/WebCore/rendering/InlineTextBox.cpp 2012-03-26 22:59:53 UTC (rev 112165)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp 2012-03-26 23:01:23 UTC (rev 112166)
@@ -174,19 +174,19 @@
length += hyphenString.length();
}
-IntRect InlineTextBox::localSelectionRect(int startPos, int endPos)
+LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos)
{
int sPos = max(startPos - m_start, 0);
int ePos = min(endPos - m_start, (int)m_len);
if (sPos > ePos)
- return IntRect();
+ return LayoutRect();
FontCachePurgePreventer fontCachePurgePreventer;
RenderText* textObj = textRenderer();
- int selTop = selectionTop();
- int selHeight = selectionHeight();
+ LayoutUnit selTop = selectionTop();
+ LayoutUnit selHeight = selectionHeight();
RenderStyle* styleToUse = textObj->style(m_firstLine);
const Font& font = styleToUse->font();
@@ -196,19 +196,19 @@
if (respectHyphen)
endPos = textRun.length();
- IntRect r = enclosingIntRect(font.selectionRectForText(textRun, FloatPoint(logicalLeft(), selTop), selHeight, sPos, ePos));
+ LayoutRect r = enclosingIntRect(font.selectionRectForText(textRun, FloatPoint(logicalLeft(), selTop), selHeight, sPos, ePos));
- int logicalWidth = r.width();
+ LayoutUnit logicalWidth = r.width();
if (r.x() > logicalRight())
logicalWidth = 0;
else if (r.maxX() > logicalRight())
logicalWidth = logicalRight() - r.x();
- IntPoint topPoint = isHorizontal() ? IntPoint(r.x(), selTop) : IntPoint(selTop, r.x());
- int width = isHorizontal() ? logicalWidth : selHeight;
- int height = isHorizontal() ? selHeight : logicalWidth;
+ LayoutPoint topPoint = isHorizontal() ? LayoutPoint(r.x(), selTop) : LayoutPoint(selTop, r.x());
+ LayoutUnit width = isHorizontal() ? logicalWidth : selHeight;
+ LayoutUnit height = isHorizontal() ? selHeight : logicalWidth;
- return IntRect(topPoint, IntSize(width, height));
+ return LayoutRect(topPoint, LayoutSize(width, height));
}
void InlineTextBox::deleteLine(RenderArena* arena)
Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (112165 => 112166)
--- trunk/Source/WebCore/rendering/InlineTextBox.h 2012-03-26 22:59:53 UTC (rev 112165)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h 2012-03-26 23:01:23 UTC (rev 112166)
@@ -110,7 +110,7 @@
public:
virtual FloatRect calculateBoundaries() const { return FloatRect(x(), y(), width(), height()); }
- virtual IntRect localSelectionRect(int startPos, int endPos);
+ virtual LayoutRect localSelectionRect(int startPos, int endPos);
bool isSelected(int startPos, int endPos) const;
void selectionStartEnd(int& sPos, int& ePos);
Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (112165 => 112166)
--- trunk/Source/WebCore/rendering/RenderReplaced.cpp 2012-03-26 22:59:53 UTC (rev 112165)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp 2012-03-26 23:01:23 UTC (rev 112166)
@@ -488,20 +488,20 @@
return rect;
}
-IntRect RenderReplaced::localSelectionRect(bool checkWhetherSelected) const
+LayoutRect RenderReplaced::localSelectionRect(bool checkWhetherSelected) const
{
if (checkWhetherSelected && !isSelected())
- return IntRect();
+ return LayoutRect();
if (!m_inlineBoxWrapper)
// We're a block-level replaced element. Just return our own dimensions.
- return IntRect(IntPoint(), size());
+ return LayoutRect(LayoutPoint(), size());
RootInlineBox* root = m_inlineBoxWrapper->root();
- int newLogicalTop = root->block()->style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - root->selectionBottom() : root->selectionTop() - m_inlineBoxWrapper->logicalTop();
+ LayoutUnit newLogicalTop = root->block()->style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - root->selectionBottom() : root->selectionTop() - m_inlineBoxWrapper->logicalTop();
if (root->block()->style()->isHorizontalWritingMode())
- return IntRect(0, newLogicalTop, width(), root->selectionHeight());
- return IntRect(newLogicalTop, 0, root->selectionHeight(), height());
+ return LayoutRect(0, newLogicalTop, width(), root->selectionHeight());
+ return LayoutRect(newLogicalTop, 0, root->selectionHeight(), height());
}
void RenderReplaced::setSelectionState(SelectionState state)
Modified: trunk/Source/WebCore/rendering/RenderReplaced.h (112165 => 112166)
--- trunk/Source/WebCore/rendering/RenderReplaced.h 2012-03-26 22:59:53 UTC (rev 112165)
+++ trunk/Source/WebCore/rendering/RenderReplaced.h 2012-03-26 23:01:23 UTC (rev 112166)
@@ -59,7 +59,7 @@
virtual void paint(PaintInfo&, const LayoutPoint&);
bool shouldPaint(PaintInfo&, const LayoutPoint&);
- IntRect localSelectionRect(bool checkWhetherSelected = true) const; // This is in local coordinates, but it's a physical rect (so the top left corner is physical top left).
+ LayoutRect localSelectionRect(bool checkWhetherSelected = true) const; // This is in local coordinates, but it's a physical rect (so the top left corner is physical top left).
private:
virtual RenderBox* embeddedContentBox() const { return 0; }
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (112165 => 112166)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2012-03-26 22:59:53 UTC (rev 112165)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2012-03-26 23:01:23 UTC (rev 112166)
@@ -312,7 +312,7 @@
static FloatRect localQuadForTextBox(InlineTextBox* box, unsigned start, unsigned end, bool useSelectionHeight)
{
unsigned realEnd = min(box->end() + 1, end);
- IntRect r = box->localSelectionRect(start, realEnd);
+ LayoutRect r = box->localSelectionRect(start, realEnd);
if (r.height()) {
if (!useSelectionHeight) {
// Change the height and y position (or width and x for vertical text)
@@ -347,7 +347,7 @@
if (start <= box->start() && box->end() < end) {
FloatRect r = box->calculateBoundaries();
if (useSelectionHeight) {
- IntRect selectionRect = box->localSelectionRect(start, end);
+ LayoutRect selectionRect = box->localSelectionRect(start, end);
if (box->isHorizontal()) {
r.setHeight(selectionRect.height());
r.setY(selectionRect.y());
@@ -430,8 +430,7 @@
if (start <= box->start() && box->end() < end) {
FloatRect r = box->calculateBoundaries();
if (useSelectionHeight) {
- // FIXME: localSelectionRect should switch to return FloatRect soon with the subpixellayout branch.
- IntRect selectionRect = box->localSelectionRect(start, end);
+ LayoutRect selectionRect = box->localSelectionRect(start, end);
if (box->isHorizontal()) {
r.setHeight(selectionRect.height());
r.setY(selectionRect.y());
@@ -1548,7 +1547,7 @@
// Now calculate startPos and endPos for painting selection.
// We include a selection while endPos > 0
- LayoutUnit startPos, endPos;
+ int startPos, endPos;
if (selectionState() == SelectionInside) {
// We are fully selected.
startPos = 0;
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp (112165 => 112166)
--- trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp 2012-03-26 22:59:53 UTC (rev 112165)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp 2012-03-26 23:01:23 UTC (rev 112166)
@@ -147,13 +147,13 @@
// Use the edge of the selection rect to determine the caret rect.
if (static_cast<unsigned>(caretOffset) < textBox->start() + textBox->len()) {
- IntRect rect = textBox->localSelectionRect(caretOffset, caretOffset + 1);
- int x = box->isLeftToRightDirection() ? rect.x() : rect.maxX();
+ LayoutRect rect = textBox->localSelectionRect(caretOffset, caretOffset + 1);
+ LayoutUnit x = box->isLeftToRightDirection() ? rect.x() : rect.maxX();
return LayoutRect(x, rect.y(), caretWidth, rect.height());
}
- IntRect rect = textBox->localSelectionRect(caretOffset - 1, caretOffset);
- int x = box->isLeftToRightDirection() ? rect.maxX() : rect.x();
+ LayoutRect rect = textBox->localSelectionRect(caretOffset - 1, caretOffset);
+ LayoutUnit x = box->isLeftToRightDirection() ? rect.maxX() : rect.x();
return LayoutRect(x, rect.y(), caretWidth, rect.height());
}
Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp (112165 => 112166)
--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp 2012-03-26 22:59:53 UTC (rev 112165)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp 2012-03-26 23:01:23 UTC (rev 112166)
@@ -128,13 +128,13 @@
return selectionRect;
}
-IntRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPosition)
+LayoutRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPosition)
{
int boxStart = start();
startPosition = max(startPosition - boxStart, 0);
endPosition = min(endPosition - boxStart, static_cast<int>(len()));
if (startPosition >= endPosition)
- return IntRect();
+ return LayoutRect();
RenderText* text = textRenderer();
ASSERT(text);
Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h (112165 => 112166)
--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h 2012-03-26 22:59:53 UTC (rev 112165)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h 2012-03-26 23:01:23 UTC (rev 112166)
@@ -47,7 +47,7 @@
void paintSelectionBackground(PaintInfo&);
virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom);
- virtual IntRect localSelectionRect(int startPosition, int endPosition);
+ virtual LayoutRect localSelectionRect(int startPosition, int endPosition);
bool mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment&, int& startPosition, int& endPosition) const;