Changeset 87964 in webkit
- Timestamp:
- Jun 2, 2011 4:49:08 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r87961 r87964 1 2011-06-02 Levi Weintraub <leviw@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Teach InlineBox about FloatPoint 6 https://bugs.webkit.org/show_bug.cgi?id=44412 7 8 Original patch by Eric Seidel. Updated by me. 9 10 This is another step towards more point/size 11 usage throughout the rendering tree. 12 13 Added left(), right(), top(), and bottom() methods 14 to InlineBox. Removed m_x, and m_y and replaced them 15 with a single m_topLeft member. 16 17 No new tests since this is just a refactoring. 18 19 * rendering/EllipsisBox.cpp: 20 (WebCore::EllipsisBox::paint): 21 (WebCore::EllipsisBox::selectionRect): 22 (WebCore::EllipsisBox::paintSelection): 23 (WebCore::EllipsisBox::nodeAtPoint): 24 * rendering/EllipsisBox.h: 25 (WebCore::EllipsisBox::EllipsisBox): 26 * rendering/InlineBox.cpp: 27 (WebCore::InlineBox::adjustPosition): 28 (WebCore::InlineBox::canAccommodateEllipsis): 29 * rendering/InlineBox.h: 30 (WebCore::InlineBox::InlineBox): 31 (WebCore::InlineBox::setX): 32 (WebCore::InlineBox::x): 33 (WebCore::InlineBox::left): 34 (WebCore::InlineBox::setY): 35 (WebCore::InlineBox::y): 36 (WebCore::InlineBox::top): 37 (WebCore::InlineBox::topLeft): 38 (WebCore::InlineBox::right): 39 (WebCore::InlineBox::bottom): 40 (WebCore::InlineBox::logicalLeft): 41 (WebCore::InlineBox::setLogicalLeft): 42 (WebCore::InlineBox::logicalTop): 43 (WebCore::InlineBox::setLogicalTop): 44 (WebCore::InlineBox::logicalFrameRect): 45 * rendering/InlineFlowBox.h: 46 (WebCore::InlineFlowBox::frameRectIncludingLineHeight): 47 * rendering/InlineTextBox.cpp: 48 (WebCore::InlineTextBox::placeEllipsisBox): 49 (WebCore::InlineTextBox::paintTextMatchMarker): 50 (WebCore::InlineTextBox::computeRectForReplacementMarker): 51 * rendering/RenderText.cpp: 52 (WebCore::RenderText::firstRunX): 53 (WebCore::RenderText::firstRunY): 54 * rendering/RenderTreeAsText.cpp: 55 (WebCore::writeTextRun): 56 * rendering/RootInlineBox.cpp: 57 (WebCore::RootInlineBox::placeEllipsis): 58 * rendering/svg/RenderSVGText.cpp: 59 (WebCore::RenderSVGText::positionForPoint): 60 * rendering/svg/SVGInlineTextBox.h: 61 (WebCore::SVGInlineTextBox::selectionTop): 62 * rendering/svg/SVGRootInlineBox.cpp: 63 (WebCore::SVGRootInlineBox::closestLeafChildForPosition): 64 1 65 2011-06-02 Jian Li <jianli@chromium.org> 2 66 -
trunk/Source/WebCore/rendering/EllipsisBox.cpp
r87753 r87964 56 56 57 57 // FIXME: Why is this always LTR? Fix by passing correct text run flags below. 58 context->drawText(font, RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint( m_x + paintOffset.x(), m_y+ paintOffset.y() + style->fontMetrics().ascent()));58 context->drawText(font, RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(x() + paintOffset.x(), y() + paintOffset.y() + style->fontMetrics().ascent())); 59 59 60 60 // Restore the regular fill color. … … 68 68 // Paint the markup box 69 69 IntPoint adjustedPaintOffset = paintOffset; 70 adjustedPaintOffset.move( m_x+ m_logicalWidth - m_markupBox->x(),71 m_y+ style->fontMetrics().ascent() - (m_markupBox->y() + m_markupBox->renderer()->style(m_firstLine)->fontMetrics().ascent()));70 adjustedPaintOffset.move(x() + m_logicalWidth - m_markupBox->x(), 71 y() + style->fontMetrics().ascent() - (m_markupBox->y() + m_markupBox->renderer()->style(m_firstLine)->fontMetrics().ascent())); 72 72 m_markupBox->paint(paintInfo, adjustedPaintOffset, lineTop, lineBottom); 73 73 } … … 79 79 const Font& font = style->font(); 80 80 // FIXME: Why is this always LTR? Fix by passing correct text run flags below. 81 return enclosingIntRect(font.selectionRectForText(RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint( m_x + tx, m_y+ ty + root()->selectionTop()), root()->selectionHeight()));81 return enclosingIntRect(font.selectionRectForText(RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(x() + tx, y() + ty + root()->selectionTop()), root()->selectionHeight())); 82 82 } 83 83 … … 95 95 96 96 GraphicsContextStateSaver stateSaver(*context); 97 int y= root()->selectionTop();97 int top = root()->selectionTop(); 98 98 int h = root()->selectionHeight(); 99 context->clip(IntRect( m_x + tx, y+ ty, m_logicalWidth, h));99 context->clip(IntRect(x() + tx, top + ty, m_logicalWidth, h)); 100 100 // FIXME: Why is this always LTR? Fix by passing correct text run flags below. 101 context->drawHighlightForText(font, RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint( m_x + tx, m_y + ty + y), h, c, style->colorSpace());101 context->drawHighlightForText(font, RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(x() + tx, y() + ty + top), h, c, style->colorSpace()); 102 102 } 103 103 104 104 bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty, int lineTop, int lineBottom) 105 105 { 106 tx += m_x;107 ty += m_y;106 tx += x(); 107 ty += y(); 108 108 109 109 // Hit test the markup box. -
trunk/Source/WebCore/rendering/EllipsisBox.h
r87753 r87964 32 32 EllipsisBox(RenderObject* obj, const AtomicString& ellipsisStr, InlineFlowBox* parent, 33 33 int width, int height, int y, bool firstLine, bool isVertical, InlineBox* markupBox) 34 : InlineBox(obj, 0, y, width, firstLine, true, false, false, isVertical, 0, 0, parent)34 : InlineBox(obj, FloatPoint(0, y), width, firstLine, true, false, false, isVertical, 0, 0, parent) 35 35 , m_height(height) 36 36 , m_str(ellipsisStr) -
trunk/Source/WebCore/rendering/InlineBox.cpp
r87753 r87964 187 187 void InlineBox::adjustPosition(float dx, float dy) 188 188 { 189 m_x += dx; 190 m_y += dy; 189 m_topLeft.move(dx, dy); 191 190 192 191 if (m_renderer->isReplaced()) … … 307 306 return true; 308 307 309 IntRect boxRect( m_x, 0, m_logicalWidth, 10);308 IntRect boxRect(left(), 0, m_logicalWidth, 10); 310 309 IntRect ellipsisRect(ltr ? blockEdge - ellipsisWidth : blockEdge, 0, ellipsisWidth, 10); 311 310 return !(boxRect.intersects(ellipsisRect)); -
trunk/Source/WebCore/rendering/InlineBox.h
r87771 r87964 40 40 , m_parent(0) 41 41 , m_renderer(obj) 42 , m_x(0)43 , m_y(0)44 42 , m_logicalWidth(0) 45 43 , m_firstLine(false) … … 69 67 } 70 68 71 InlineBox(RenderObject* obj, float x, float y, float logicalWidth, bool firstLine, bool constructed,69 InlineBox(RenderObject* obj, FloatPoint topLeft, float logicalWidth, bool firstLine, bool constructed, 72 70 bool dirty, bool extracted, bool isHorizontal, InlineBox* next, InlineBox* prev, InlineFlowBox* parent) 73 71 : m_next(next) … … 75 73 , m_parent(parent) 76 74 , m_renderer(obj) 77 , m_x(x) 78 , m_y(y) 75 , m_topLeft(topLeft) 79 76 , m_logicalWidth(logicalWidth) 80 77 , m_firstLine(firstLine) … … 227 224 228 225 // x() is the left side of the box in the containing block's coordinate system. 229 void setX(float x) { m_x = x; } 230 float x() const { return m_x; } 226 void setX(float x) { m_topLeft.setX(x); } 227 float x() const { return m_topLeft.x(); } 228 float left() const { return m_topLeft.x(); } 231 229 232 230 // y() is the top side of the box in the containing block's coordinate system. 233 void setY(float y) { m_y = y; } 234 float y() const { return m_y; } 231 void setY(float y) { m_topLeft.setY(y); } 232 float y() const { return m_topLeft.y(); } 233 float top() const { return m_topLeft.y(); } 234 235 const FloatPoint& topLeft() const { return m_topLeft; } 235 236 236 237 float width() const { return isHorizontal() ? logicalWidth() : logicalHeight(); } 237 238 float height() const { return isHorizontal() ? logicalHeight() : logicalWidth(); } 239 float right() const { return left() + width(); } 240 float bottom() const { return top() + height(); } 238 241 239 242 // The logicalLeft position is the left edge of the line box in a horizontal line and the top edge in a vertical line. 240 float logicalLeft() const { return isHorizontal() ? m_ x : m_y; }243 float logicalLeft() const { return isHorizontal() ? m_topLeft.x() : m_topLeft.y(); } 241 244 float logicalRight() const { return logicalLeft() + logicalWidth(); } 242 245 void setLogicalLeft(float left) 243 246 { 244 247 if (isHorizontal()) 245 m_x = left;248 setX(left); 246 249 else 247 m_y = left;250 setY(left); 248 251 } 249 252 int pixelSnappedLogicalLeft() const { return logicalLeft(); } … … 251 254 252 255 // The logicalTop[ position is the top edge of the line box in a horizontal line and the left edge in a vertical line. 253 int logicalTop() const { return isHorizontal() ? m_ y : m_x; }256 int logicalTop() const { return isHorizontal() ? m_topLeft.y() : m_topLeft.x(); } 254 257 int logicalBottom() const { return logicalTop() + logicalHeight(); } 255 258 void setLogicalTop(int top) 256 259 { 257 260 if (isHorizontal()) 258 m_y = top;261 setY(top); 259 262 else 260 m_x = top;263 setX(top); 261 264 } 262 265 … … 268 271 int logicalHeight() const; 269 272 270 FloatRect logicalFrameRect() const { return isHorizontal() ? IntRect(m_ x, m_y, m_logicalWidth, logicalHeight()) : IntRect(m_y, m_x, m_logicalWidth, logicalHeight()); }273 FloatRect logicalFrameRect() const { return isHorizontal() ? IntRect(m_topLeft.x(), m_topLeft.y(), m_logicalWidth, logicalHeight()) : IntRect(m_topLeft.y(), m_topLeft.x(), m_logicalWidth, logicalHeight()); } 271 274 272 275 virtual int baselinePosition(FontBaseline baselineType) const { return boxModelObject()->baselinePosition(baselineType, m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); } … … 331 334 RenderObject* m_renderer; 332 335 333 float m_x; 334 float m_y; 336 FloatPoint m_topLeft; 335 337 float m_logicalWidth; 336 338 -
trunk/Source/WebCore/rendering/InlineFlowBox.h
r87753 r87964 256 256 { 257 257 if (isHorizontal()) 258 return FloatRect(m_ x, lineTop, width(), lineBottom - lineTop);259 return FloatRect(lineTop, m_ y, lineBottom - lineTop, height());258 return FloatRect(m_topLeft.x(), lineTop, width(), lineBottom - lineTop); 259 return FloatRect(lineTop, m_topLeft.y(), lineBottom - lineTop, height()); 260 260 } 261 261 -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r87866 r87964 243 243 // LTR: the left edge of the ellipsis is to the left of our text run. 244 244 // RTL: the right edge of the ellipsis is to the right of our text run. 245 bool ltrFullTruncation = flowIsLTR && ellipsisX <= m_x;246 bool rtlFullTruncation = !flowIsLTR && ellipsisX >= (m_x + m_logicalWidth);245 bool ltrFullTruncation = flowIsLTR && ellipsisX <= left(); 246 bool rtlFullTruncation = !flowIsLTR && ellipsisX >= left() + logicalWidth(); 247 247 if (ltrFullTruncation || rtlFullTruncation) { 248 248 // Too far. Just set full truncation, but return -1 and let the ellipsis just be placed at the edge of the box. … … 252 252 } 253 253 254 bool ltrEllipsisWithinBox = flowIsLTR && (ellipsisX < m_x + m_logicalWidth);255 bool rtlEllipsisWithinBox = !flowIsLTR && (ellipsisX > m_x);254 bool ltrEllipsisWithinBox = flowIsLTR && (ellipsisX < right()); 255 bool rtlEllipsisWithinBox = !flowIsLTR && (ellipsisX > left()); 256 256 if (ltrEllipsisWithinBox || rtlEllipsisWithinBox) { 257 257 foundBox = true; … … 264 264 // Width in pixels of the visible portion of the box, excluding the ellipsis. 265 265 int visibleBoxWidth = visibleRightEdge - visibleLeftEdge - ellipsisWidth; 266 ellipsisX = ltr ? m_x + visibleBoxWidth : m_x + m_logicalWidth- visibleBoxWidth;266 ellipsisX = ltr ? left() + visibleBoxWidth : right() - visibleBoxWidth; 267 267 } 268 268 … … 272 272 // and the ellipsis edge. 273 273 m_truncation = cFullTruncation; 274 return min(ellipsisX, m_x);274 return min(ellipsisX, x()); 275 275 } 276 276 … … 288 288 // have a situation such as |Hello| -> |...He| 289 289 if (flowIsLTR) 290 return m_x+ widthOfVisibleText;290 return left() + widthOfVisibleText; 291 291 else 292 return (m_x + m_logicalWidth) - widthOfVisibleText - ellipsisWidth;292 return right() - widthOfVisibleText - ellipsisWidth; 293 293 } 294 294 return -1; … … 1052 1052 1053 1053 // Always compute and store the rect associated with this marker. The computed rect is in absolute coordinates. 1054 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoint( m_x, selectionTop()), selHeight, sPos, ePos));1054 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoint(x(), selectionTop()), selHeight, sPos, ePos)); 1055 1055 markerRect = renderer()->localToAbsoluteQuad(FloatRect(markerRect)).enclosingBoundingBox(); 1056 1056 toRenderedDocumentMarker(marker)->setRenderedRect(markerRect); … … 1071 1071 { 1072 1072 // Replacement markers are not actually drawn, but their rects need to be computed for hit testing. 1073 int y= selectionTop();1073 int top = selectionTop(); 1074 1074 int h = selectionHeight(); 1075 1075 … … 1077 1077 int ePos = min(marker->endOffset() - m_start, (unsigned)m_len); 1078 1078 TextRun run = constructTextRun(style, font); 1079 IntPoint startPoint = IntPoint( m_x, y);1079 IntPoint startPoint = IntPoint(x(), top); 1080 1080 1081 1081 // Compute and store the rect associated with this marker. -
trunk/Source/WebCore/rendering/RenderText.cpp
r87936 r87964 981 981 float RenderText::firstRunX() const 982 982 { 983 return m_firstTextBox ? m_firstTextBox-> m_x: 0;983 return m_firstTextBox ? m_firstTextBox->x() : 0; 984 984 } 985 985 986 986 float RenderText::firstRunY() const 987 987 { 988 return m_firstTextBox ? m_firstTextBox-> m_y: 0;988 return m_firstTextBox ? m_firstTextBox->y() : 0; 989 989 } 990 990 -
trunk/Source/WebCore/rendering/RenderTreeAsText.cpp
r87467 r87964 495 495 // FIXME: For now use an "enclosingIntRect" model for x, y and logicalWidth, although this makes it harder 496 496 // to detect any changes caused by the conversion to floating point. :( 497 int x = run. m_x;498 int y = run. m_y;499 int logicalWidth = ceilf(run. m_x + run.m_logicalWidth) - x;497 int x = run.x(); 498 int y = run.y(); 499 int logicalWidth = ceilf(run.left() + run.logicalWidth()) - x; 500 500 501 501 // FIXME: Table cell adjustment is temporary until results can be updated. -
trunk/Source/WebCore/rendering/RootInlineBox.cpp
r87866 r87964 115 115 // FIXME: Do we need an RTL version of this? 116 116 if (ltr && (x() + logicalWidth() + ellipsisWidth) <= blockRightEdge) { 117 ellipsisBox-> m_x = x() + logicalWidth();117 ellipsisBox->setX(x() + logicalWidth()); 118 118 return; 119 119 } … … 123 123 // truncated). 124 124 bool foundBox = false; 125 ellipsisBox-> m_x = placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, foundBox);125 ellipsisBox->setX(placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, foundBox)); 126 126 } 127 127 -
trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp
r86705 r87964 222 222 return createVisiblePosition(0, DOWNSTREAM); 223 223 224 return closestBox->renderer()->positionForPoint(IntPoint(pointInContents.x(), closestBox-> m_y));224 return closestBox->renderer()->positionForPoint(IntPoint(pointInContents.x(), closestBox->y())); 225 225 } 226 226 -
trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h
r87753 r87964 41 41 void setLogicalHeight(int height) { m_logicalHeight = height; } 42 42 43 virtual int selectionTop() { return m_y; }43 virtual int selectionTop() { return top(); } 44 44 virtual int selectionHeight() { return m_logicalHeight; } 45 45 virtual int offsetForPosition(float x, bool includePartialGlyphs = true) const; -
trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp
r87753 r87964 210 210 if (!leaf->isSVGInlineTextBox()) 211 211 continue; 212 if (point.y() < leaf-> m_y)213 continue; 214 if (point.y() > leaf-> m_y+ leaf->virtualLogicalHeight())212 if (point.y() < leaf->y()) 213 continue; 214 if (point.y() > leaf->y() + leaf->virtualLogicalHeight()) 215 215 continue; 216 216 217 217 closestLeaf = leaf; 218 if (point.x() < leaf-> m_x + leaf->m_logicalWidth)218 if (point.x() < leaf->left() + leaf->logicalWidth()) 219 219 return leaf; 220 220 }
Note: See TracChangeset
for help on using the changeset viewer.