Changeset 112166 in webkit
- Timestamp:
- Mar 26, 2012 4:01:23 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r112165 r112166 1 2012-03-26 Levi Weintraub <leviw@chromium.org> 2 3 Update localSelectionRect to return a LayoutRect 4 https://bugs.webkit.org/show_bug.cgi?id=82183 5 6 Reviewed by Eric Seidel. 7 8 localSelectionRect returns a rectangle in the coordinate space of its renderer, 9 and therefor should remain LayoutUnits until being promoted to absolute 10 coordinates or painted. Also fixing an incorrect conversion of startPos and 11 endPos in selectionRectForRepaint. 12 13 No new tests. No change in behavior. 14 15 * rendering/InlineTextBox.cpp: 16 (WebCore::InlineTextBox::localSelectionRect): Continuing to use enclosingIntRect 17 for the value being returned from the font engine since these floating point 18 values should not be pixel snapped. 19 * rendering/InlineTextBox.h: 20 (InlineTextBox): 21 * rendering/RenderReplaced.cpp: 22 (WebCore::RenderReplaced::localSelectionRect): 23 * rendering/RenderReplaced.h: 24 (RenderReplaced): 25 * rendering/RenderText.cpp: 26 (WebCore::localQuadForTextBox): 27 (WebCore::RenderText::absoluteRectsForRange): 28 (WebCore::RenderText::absoluteQuadsForRange): 29 (WebCore::RenderText::selectionRectForRepaint): Fixing an incorrect conversion of 30 start/endPos to LayoutUnits. These values represent a range of selected characters, 31 not layout values! 32 * rendering/svg/RenderSVGInlineText.cpp: 33 (WebCore::RenderSVGInlineText::localCaretRect): 34 * rendering/svg/SVGInlineTextBox.cpp: 35 (WebCore::SVGInlineTextBox::localSelectionRect): 36 * rendering/svg/SVGInlineTextBox.h: 37 (SVGInlineTextBox): 38 1 39 2012-03-26 Justin Novosad <junov@chromium.org> 2 40 -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r110983 r112166 175 175 } 176 176 177 IntRect InlineTextBox::localSelectionRect(int startPos, int endPos)177 LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos) 178 178 { 179 179 int sPos = max(startPos - m_start, 0); … … 181 181 182 182 if (sPos > ePos) 183 return IntRect();183 return LayoutRect(); 184 184 185 185 FontCachePurgePreventer fontCachePurgePreventer; 186 186 187 187 RenderText* textObj = textRenderer(); 188 int selTop = selectionTop();189 int selHeight = selectionHeight();188 LayoutUnit selTop = selectionTop(); 189 LayoutUnit selHeight = selectionHeight(); 190 190 RenderStyle* styleToUse = textObj->style(m_firstLine); 191 191 const Font& font = styleToUse->font(); … … 197 197 endPos = textRun.length(); 198 198 199 IntRect r = enclosingIntRect(font.selectionRectForText(textRun, FloatPoint(logicalLeft(), selTop), selHeight, sPos, ePos));200 201 int logicalWidth = r.width();199 LayoutRect r = enclosingIntRect(font.selectionRectForText(textRun, FloatPoint(logicalLeft(), selTop), selHeight, sPos, ePos)); 200 201 LayoutUnit logicalWidth = r.width(); 202 202 if (r.x() > logicalRight()) 203 203 logicalWidth = 0; … … 205 205 logicalWidth = logicalRight() - r.x(); 206 206 207 IntPoint topPoint = isHorizontal() ? IntPoint(r.x(), selTop) : IntPoint(selTop, r.x());208 int width = isHorizontal() ? logicalWidth : selHeight;209 int height = isHorizontal() ? selHeight : logicalWidth;210 211 return IntRect(topPoint, IntSize(width, height));207 LayoutPoint topPoint = isHorizontal() ? LayoutPoint(r.x(), selTop) : LayoutPoint(selTop, r.x()); 208 LayoutUnit width = isHorizontal() ? logicalWidth : selHeight; 209 LayoutUnit height = isHorizontal() ? selHeight : logicalWidth; 210 211 return LayoutRect(topPoint, LayoutSize(width, height)); 212 212 } 213 213 -
trunk/Source/WebCore/rendering/InlineTextBox.h
r101342 r112166 111 111 virtual FloatRect calculateBoundaries() const { return FloatRect(x(), y(), width(), height()); } 112 112 113 virtual IntRect localSelectionRect(int startPos, int endPos);113 virtual LayoutRect localSelectionRect(int startPos, int endPos); 114 114 bool isSelected(int startPos, int endPos) const; 115 115 void selectionStartEnd(int& sPos, int& ePos); -
trunk/Source/WebCore/rendering/RenderReplaced.cpp
r111126 r112166 489 489 } 490 490 491 IntRect RenderReplaced::localSelectionRect(bool checkWhetherSelected) const491 LayoutRect RenderReplaced::localSelectionRect(bool checkWhetherSelected) const 492 492 { 493 493 if (checkWhetherSelected && !isSelected()) 494 return IntRect();494 return LayoutRect(); 495 495 496 496 if (!m_inlineBoxWrapper) 497 497 // We're a block-level replaced element. Just return our own dimensions. 498 return IntRect(IntPoint(), size());498 return LayoutRect(LayoutPoint(), size()); 499 499 500 500 RootInlineBox* root = m_inlineBoxWrapper->root(); 501 int newLogicalTop = root->block()->style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - root->selectionBottom() : root->selectionTop() - m_inlineBoxWrapper->logicalTop();501 LayoutUnit newLogicalTop = root->block()->style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - root->selectionBottom() : root->selectionTop() - m_inlineBoxWrapper->logicalTop(); 502 502 if (root->block()->style()->isHorizontalWritingMode()) 503 return IntRect(0, newLogicalTop, width(), root->selectionHeight());504 return IntRect(newLogicalTop, 0, root->selectionHeight(), height());503 return LayoutRect(0, newLogicalTop, width(), root->selectionHeight()); 504 return LayoutRect(newLogicalTop, 0, root->selectionHeight(), height()); 505 505 } 506 506 -
trunk/Source/WebCore/rendering/RenderReplaced.h
r105513 r112166 60 60 virtual void paint(PaintInfo&, const LayoutPoint&); 61 61 bool shouldPaint(PaintInfo&, const LayoutPoint&); 62 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).62 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). 63 63 64 64 private: -
trunk/Source/WebCore/rendering/RenderText.cpp
r110323 r112166 313 313 { 314 314 unsigned realEnd = min(box->end() + 1, end); 315 IntRect r = box->localSelectionRect(start, realEnd);315 LayoutRect r = box->localSelectionRect(start, realEnd); 316 316 if (r.height()) { 317 317 if (!useSelectionHeight) { … … 348 348 FloatRect r = box->calculateBoundaries(); 349 349 if (useSelectionHeight) { 350 IntRect selectionRect = box->localSelectionRect(start, end);350 LayoutRect selectionRect = box->localSelectionRect(start, end); 351 351 if (box->isHorizontal()) { 352 352 r.setHeight(selectionRect.height()); … … 431 431 FloatRect r = box->calculateBoundaries(); 432 432 if (useSelectionHeight) { 433 // FIXME: localSelectionRect should switch to return FloatRect soon with the subpixellayout branch. 434 IntRect selectionRect = box->localSelectionRect(start, end); 433 LayoutRect selectionRect = box->localSelectionRect(start, end); 435 434 if (box->isHorizontal()) { 436 435 r.setHeight(selectionRect.height()); … … 1549 1548 // Now calculate startPos and endPos for painting selection. 1550 1549 // We include a selection while endPos > 0 1551 LayoutUnit startPos, endPos;1550 int startPos, endPos; 1552 1551 if (selectionState() == SelectionInside) { 1553 1552 // We are fully selected. -
trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp
r112119 r112166 148 148 // Use the edge of the selection rect to determine the caret rect. 149 149 if (static_cast<unsigned>(caretOffset) < textBox->start() + textBox->len()) { 150 IntRect rect = textBox->localSelectionRect(caretOffset, caretOffset + 1);151 int x = box->isLeftToRightDirection() ? rect.x() : rect.maxX();150 LayoutRect rect = textBox->localSelectionRect(caretOffset, caretOffset + 1); 151 LayoutUnit x = box->isLeftToRightDirection() ? rect.x() : rect.maxX(); 152 152 return LayoutRect(x, rect.y(), caretWidth, rect.height()); 153 153 } 154 154 155 IntRect rect = textBox->localSelectionRect(caretOffset - 1, caretOffset);156 int x = box->isLeftToRightDirection() ? rect.maxX() : rect.x();155 LayoutRect rect = textBox->localSelectionRect(caretOffset - 1, caretOffset); 156 LayoutUnit x = box->isLeftToRightDirection() ? rect.maxX() : rect.x(); 157 157 return LayoutRect(x, rect.y(), caretWidth, rect.height()); 158 158 } -
trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
r111674 r112166 129 129 } 130 130 131 IntRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPosition)131 LayoutRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPosition) 132 132 { 133 133 int boxStart = start(); … … 135 135 endPosition = min(endPosition - boxStart, static_cast<int>(len())); 136 136 if (startPosition >= endPosition) 137 return IntRect();137 return LayoutRect(); 138 138 139 139 RenderText* text = textRenderer(); -
trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h
r110593 r112166 48 48 void paintSelectionBackground(PaintInfo&); 49 49 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom); 50 virtual IntRect localSelectionRect(int startPosition, int endPosition);50 virtual LayoutRect localSelectionRect(int startPosition, int endPosition); 51 51 52 52 bool mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment&, int& startPosition, int& endPosition) const;
Note: See TracChangeset
for help on using the changeset viewer.