Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: Source/core/rendering/RootInlineBox.cpp

Issue 699683002: Continue with InlineBox float->LayoutUnit migration. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: default constructors Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // First sanity-check the unoverflowed width of the whole line to see if the re is sufficient room. 107 // First sanity-check the unoverflowed width of the whole line to see if the re is sufficient room.
108 int delta = ltr ? lineBoxEdge - blockEdge : blockEdge - lineBoxEdge; 108 int delta = ltr ? lineBoxEdge - blockEdge : blockEdge - lineBoxEdge;
109 if (logicalWidth() - delta < ellipsisWidth) 109 if (logicalWidth() - delta < ellipsisWidth)
110 return false; 110 return false;
111 111
112 // Next iterate over all the line boxes on the line. If we find a replaced element that intersects 112 // Next iterate over all the line boxes on the line. If we find a replaced element that intersects
113 // then we refuse to accommodate the ellipsis. Otherwise we're ok. 113 // then we refuse to accommodate the ellipsis. Otherwise we're ok.
114 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth); 114 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth);
115 } 115 }
116 116
117 float RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, bool ltr, f loat blockLeftEdge, float blockRightEdge, float ellipsisWidth, 117 FloatWillBeLayoutUnit RootInlineBox::placeEllipsis(const AtomicString& ellipsisS tr, bool ltr, FloatWillBeLayoutUnit blockLeftEdge, FloatWillBeLayoutUnit blockR ightEdge, FloatWillBeLayoutUnit ellipsisWidth,
118 InlineBox* markupBox) 118 InlineBox* markupBox)
119 { 119 {
120 // Create an ellipsis box. 120 // Create an ellipsis box.
121 EllipsisBox* ellipsisBox = new EllipsisBox(renderer(), ellipsisStr, this, 121 EllipsisBox* ellipsisBox = new EllipsisBox(renderer(), ellipsisStr, this,
122 ellipsisWidth - (markupBox ? markupBox->logicalWidth() : 0), logicalHeig ht(), 122 ellipsisWidth - (markupBox ? markupBox->logicalWidth() : 0), logicalHeig ht(),
123 x(), y(), !prevRootBox(), isHorizontal(), markupBox); 123 x(), y(), !prevRootBox(), isHorizontal(), markupBox);
124 124
125 if (!gEllipsisBoxMap) 125 if (!gEllipsisBoxMap)
126 gEllipsisBoxMap = new EllipsisBoxMap(); 126 gEllipsisBoxMap = new EllipsisBoxMap();
127 gEllipsisBoxMap->add(this, ellipsisBox); 127 gEllipsisBoxMap->add(this, ellipsisBox);
128 setHasEllipsisBox(true); 128 setHasEllipsisBox(true);
129 129
130 // FIXME: Do we need an RTL version of this? 130 // FIXME: Do we need an RTL version of this?
131 if (ltr && (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdg e) { 131 if (ltr && (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdg e) {
132 ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth()); 132 ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth());
133 return logicalWidth() + ellipsisWidth; 133 return logicalWidth() + ellipsisWidth;
134 } 134 }
135 135
136 // Now attempt to find the nearest glyph horizontally and place just to the right (or left in RTL) 136 // Now attempt to find the nearest glyph horizontally and place just to the right (or left in RTL)
137 // of that glyph. Mark all of the objects that intersect the ellipsis box a s not painting (as being 137 // of that glyph. Mark all of the objects that intersect the ellipsis box a s not painting (as being
138 // truncated). 138 // truncated).
139 bool foundBox = false; 139 bool foundBox = false;
140 float truncatedWidth = 0; 140 FloatWillBeLayoutUnit truncatedWidth = 0;
141 float position = placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellips isWidth, truncatedWidth, foundBox); 141 FloatWillBeLayoutUnit position = placeEllipsisBox(ltr, blockLeftEdge, blockR ightEdge, ellipsisWidth, truncatedWidth, foundBox);
142 ellipsisBox->setLogicalLeft(position); 142 ellipsisBox->setLogicalLeft(position);
143 return truncatedWidth; 143 return truncatedWidth;
144 } 144 }
145 145
146 float RootInlineBox::placeEllipsisBox(bool ltr, float blockLeftEdge, float block RightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) 146 FloatWillBeLayoutUnit RootInlineBox::placeEllipsisBox(bool ltr, FloatWillBeLayou tUnit blockLeftEdge, FloatWillBeLayoutUnit blockRightEdge, FloatWillBeLayoutUnit ellipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool& foundBox)
147 { 147 {
148 float result = InlineFlowBox::placeEllipsisBox(ltr, blockLeftEdge, blockRigh tEdge, ellipsisWidth, truncatedWidth, foundBox); 148 FloatWillBeLayoutUnit result = InlineFlowBox::placeEllipsisBox(ltr, blockLef tEdge, blockRightEdge, ellipsisWidth, truncatedWidth, foundBox);
149 if (result == -1) { 149 if (result == -1) {
150 result = ltr ? blockRightEdge - ellipsisWidth : blockLeftEdge; 150 result = ltr ? blockRightEdge - ellipsisWidth : blockLeftEdge;
151 truncatedWidth = blockRightEdge - blockLeftEdge; 151 truncatedWidth = blockRightEdge - blockLeftEdge;
152 } 152 }
153 return result; 153 return result;
154 } 154 }
155 155
156 void RootInlineBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom) 156 void RootInlineBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
157 { 157 {
158 RootInlineBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBotto m); 158 RootInlineBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBotto m);
159 } 159 }
160 160
161 bool RootInlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated Offset, LayoutUnit lineTop, LayoutUnit lineBottom) 161 bool RootInlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated Offset, LayoutUnit lineTop, LayoutUnit lineBottom)
162 { 162 {
163 if (hasEllipsisBox() && visibleToHitTestRequest(request)) { 163 if (hasEllipsisBox() && visibleToHitTestRequest(request)) {
164 if (ellipsisBox()->nodeAtPoint(request, result, locationInContainer, acc umulatedOffset, lineTop, lineBottom)) { 164 if (ellipsisBox()->nodeAtPoint(request, result, locationInContainer, acc umulatedOffset, lineTop, lineBottom)) {
165 renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset)); 165 renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
166 return true; 166 return true;
167 } 167 }
168 } 168 }
169 return InlineFlowBox::nodeAtPoint(request, result, locationInContainer, accu mulatedOffset, lineTop, lineBottom); 169 return InlineFlowBox::nodeAtPoint(request, result, locationInContainer, accu mulatedOffset, lineTop, lineBottom);
170 } 170 }
171 171
172 void RootInlineBox::adjustPosition(float dx, float dy) 172 void RootInlineBox::adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUn it dy)
173 { 173 {
174 InlineFlowBox::adjustPosition(dx, dy); 174 InlineFlowBox::adjustPosition(dx, dy);
175 LayoutUnit blockDirectionDelta = isHorizontal() ? dy : dx; // The block dire ction delta is a LayoutUnit. 175 LayoutUnit blockDirectionDelta = isHorizontal() ? dy : dx; // The block dire ction delta is a LayoutUnit.
176 m_lineTop += blockDirectionDelta; 176 m_lineTop += blockDirectionDelta;
177 m_lineBottom += blockDirectionDelta; 177 m_lineBottom += blockDirectionDelta;
178 m_lineTopWithLeading += blockDirectionDelta; 178 m_lineTopWithLeading += blockDirectionDelta;
179 m_lineBottomWithLeading += blockDirectionDelta; 179 m_lineBottomWithLeading += blockDirectionDelta;
180 m_selectionBottom += blockDirectionDelta; 180 m_selectionBottom += blockDirectionDelta;
181 if (hasEllipsisBox()) 181 if (hasEllipsisBox())
182 ellipsisBox()->adjustPosition(dx, dy); 182 ellipsisBox()->adjustPosition(dx, dy);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 if (annotationsAdjustment) { 239 if (annotationsAdjustment) {
240 // FIXME: Need to handle pagination here. We might have to move to the n ext page/column as a result of the 240 // FIXME: Need to handle pagination here. We might have to move to the n ext page/column as a result of the
241 // ruby expansion. 241 // ruby expansion.
242 adjustBlockDirectionPosition(annotationsAdjustment.toFloat()); 242 adjustBlockDirectionPosition(annotationsAdjustment.toFloat());
243 heightOfBlock += annotationsAdjustment; 243 heightOfBlock += annotationsAdjustment;
244 } 244 }
245 245
246 return heightOfBlock + maxHeight; 246 return heightOfBlock + maxHeight;
247 } 247 }
248 248
249 float RootInlineBox::maxLogicalTop() const 249 FloatWillBeLayoutUnit RootInlineBox::maxLogicalTop() const
250 { 250 {
251 float maxLogicalTop = 0; 251 FloatWillBeLayoutUnit maxLogicalTop = 0;
leviw_travelin_and_unemployed 2014/11/13 19:51:23 Ditto.
252 computeMaxLogicalTop(maxLogicalTop); 252 computeMaxLogicalTop(maxLogicalTop);
253 return maxLogicalTop; 253 return maxLogicalTop;
254 } 254 }
255 255
256 LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const 256 LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const
257 { 257 {
258 LayoutUnit result = 0; 258 LayoutUnit result = 0;
259 259
260 if (!renderer().style()->isFlippedLinesWritingMode()) { 260 if (!renderer().style()->isFlippedLinesWritingMode()) {
261 // Annotations under the previous line may push us down. 261 // Annotations under the previous line may push us down.
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 } 857 }
858 858
859 #ifndef NDEBUG 859 #ifndef NDEBUG
860 const char* RootInlineBox::boxName() const 860 const char* RootInlineBox::boxName() const
861 { 861 {
862 return "RootInlineBox"; 862 return "RootInlineBox";
863 } 863 }
864 #endif 864 #endif
865 865
866 } // namespace blink 866 } // namespace blink
OLDNEW
« Source/core/rendering/InlineTextBox.cpp ('K') | « Source/core/rendering/RootInlineBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698