Changeset 159579 in webkit
- Timestamp:
- Nov 20, 2013, 1:23:19 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r159575 r159579 1 2013-11-20 Antti Koivisto <antti@apple.com> 2 3 Simple line layout should support floats 4 https://bugs.webkit.org/show_bug.cgi?id=124666 5 6 Reviewed by Dave Hyatt. 7 8 * fast/text/simple-lines-float-compare-expected.html: Added. 9 * fast/text/simple-lines-float-compare.html: Added. 10 * fast/text/simple-lines-float-expected.html: Added. 11 * fast/text/simple-lines-float.html: Added. 12 1 13 2013-11-20 Robert Hogan <robert@webkit.org> 2 14 -
trunk/Source/WebCore/ChangeLog
r159578 r159579 1 2013-11-20 Antti Koivisto <antti@apple.com> 2 3 Simple line layout should support floats 4 https://bugs.webkit.org/show_bug.cgi?id=124666 5 6 Reviewed by Dave Hyatt. 7 8 Tests: fast/text/simple-lines-float-compare.html 9 fast/text/simple-lines-float.html 10 11 * rendering/line/LineWidth.h: 12 (WebCore::LineWidth::logicalLeftOffset): 13 14 Expose the left offset so we don't need to recompute it. 15 16 * rendering/SimpleLineLayout.cpp: 17 (WebCore::SimpleLineLayout::canUseFor): 18 (WebCore::SimpleLineLayout::computeLineLeft): 19 20 Include the left offset from floats. 21 22 (WebCore::SimpleLineLayout::createTextRuns): 23 24 Keep the flow height updated during the loop as LineWidth reads the current position from there. 25 26 * rendering/SimpleLineLayoutResolver.h: 27 (WebCore::SimpleLineLayout::RunResolver::Run::rect): 28 (WebCore::SimpleLineLayout::RunResolver::Run::baseline): 29 (WebCore::SimpleLineLayout::RunResolver::RunResolver): 30 (WebCore::SimpleLineLayout::RunResolver::lineIndexForHeight): 31 32 We now bake the border and the padding to the line left offset. No need to add it during resolve. 33 1 34 2013-11-20 Alexey Proskuryakov <ap@apple.com> 2 35 -
trunk/Source/WebCore/rendering/SimpleLineLayout.cpp
r159194 r159579 43 43 #include "RenderView.h" 44 44 #include "Settings.h" 45 #include "SimpleLineLayout Resolver.h"45 #include "SimpleLineLayoutFunctions.h" 46 46 #include "Text.h" 47 47 #include "TextPaintStyle.h" … … 106 106 if (!flow.firstChild()->isText()) 107 107 return false; 108 // Supporting floats would be very beneficial.109 if (flow.containsFloats())110 return false;111 108 if (!flow.isHorizontalWritingMode()) 112 109 return false; … … 183 180 return false; 184 181 const RenderText& textRenderer = toRenderText(*flow.firstChild()); 182 if (flow.containsFloats()) { 183 // We can't use the code path if any lines would need to be shifted below floats. This is because we don't keep per-line y coordinates. 184 // It is enough to test the first line width only as currently all floats must be overhanging. 185 if (textRenderer.minLogicalWidth() > LineWidth(const_cast<RenderBlockFlow&>(flow), false, DoNotIndentText).availableWidth()) 186 return false; 187 } 185 188 if (textRenderer.isCombineText() || textRenderer.isCounter() || textRenderer.isQuote() || textRenderer.isTextFragment() 186 189 #if ENABLE(SVG) … … 374 377 } 375 378 376 static float computeLineLeft(ETextAlign textAlign, float remainingWidth) 377 { 379 static float computeLineLeft(ETextAlign textAlign, const LineWidth& lineWidth) 380 { 381 float remainingWidth = lineWidth.availableWidth() - lineWidth.committedWidth(); 382 float left = lineWidth.logicalLeftOffset(); 378 383 switch (textAlign) { 379 384 case LEFT: 380 385 case WEBKIT_LEFT: 381 386 case TASTART: 382 return 0;387 return left; 383 388 case RIGHT: 384 389 case WEBKIT_RIGHT: 385 390 case TAEND: 386 return std::max<float>(remainingWidth, 0);391 return left + std::max<float>(remainingWidth, 0); 387 392 case CENTER: 388 393 case WEBKIT_CENTER: 389 return std::max<float>(remainingWidth / 2, 0);394 return left + std::max<float>(remainingWidth / 2, 0); 390 395 case JUSTIFY: 391 396 break; … … 413 418 const unsigned textLength = textRenderer.textLength(); 414 419 420 LayoutUnit borderAndPaddingBefore = flow.borderAndPaddingBefore(); 421 LayoutUnit lineHeight = lineHeightFromFlow(flow); 422 415 423 LazyLineBreakIterator lineBreakIterator(textRenderer.text(), flow.style().locale()); 416 424 … … 422 430 unsigned lineStart = lineEnd; 423 431 432 // LineWidth reads the current y position from the flow so keep it updated. 433 flow.setLogicalHeight(lineHeight * lineCount + borderAndPaddingBefore); 424 434 LineWidth lineWidth(flow, false, DoNotIndentText); 435 425 436 auto lineRuns = createLineRuns(lineStart, lineWidth, lineBreakIterator, style, text, textLength, textRenderer); 426 437 … … 431 442 lineRuns.last().isEndOfLine = true; 432 443 433 float lineLeft = computeLineLeft(style.textAlign, lineWidth .availableWidth() - lineWidth.committedWidth());444 float lineLeft = computeLineLeft(style.textAlign, lineWidth); 434 445 adjustRunOffsets(lineRuns, lineLeft); 435 446 -
trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h
r159560 r159579 109 109 const LayoutUnit m_lineHeight; 110 110 const LayoutUnit m_baseline; 111 const LayoutUnit m_borderAndPaddingBefore; 111 112 const float m_ascent; 112 113 const float m_descent; 113 const LayoutPoint m_contentOffset;114 114 }; 115 115 … … 167 167 auto& run = m_iterator.simpleRun(); 168 168 169 LayoutPoint linePosition(floor(run.left), resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline - resolver.m_ascent); 169 float baselinePosition = resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline; 170 LayoutPoint linePosition(floor(run.left), baselinePosition - resolver.m_ascent + resolver.m_borderAndPaddingBefore); 170 171 LayoutSize lineSize(ceil(run.right) - floor(run.left), resolver.m_ascent + resolver.m_descent); 171 return LayoutRect(linePosition + resolver.m_contentOffset, lineSize);172 return LayoutRect(linePosition, lineSize); 172 173 } 173 174 … … 177 178 auto& run = m_iterator.simpleRun(); 178 179 179 float baseline Y= resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline;180 return FloatPoint(run.left, baseline Y) + resolver.m_contentOffset;180 float baselinePosition = resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline; 181 return FloatPoint(run.left, baselinePosition + resolver.m_borderAndPaddingBefore); 181 182 } 182 183 … … 254 255 , m_lineHeight(lineHeightFromFlow(flow)) 255 256 , m_baseline(baselineFromFlow(flow)) 257 , m_borderAndPaddingBefore(flow.borderAndPaddingBefore()) 256 258 , m_ascent(flow.style().font().fontMetrics().ascent()) 257 259 , m_descent(flow.style().font().fontMetrics().descent()) 258 , m_contentOffset(flow.borderLeft() + flow.paddingLeft(), flow.borderTop() + flow.paddingTop())259 260 { 260 261 } … … 273 274 { 274 275 ASSERT(m_lineHeight); 275 float y = std::max<float>(height - m_ contentOffset.y()- m_baseline + m_ascent, 0);276 float y = std::max<float>(height - m_borderAndPaddingBefore - m_baseline + m_ascent, 0); 276 277 return std::min<unsigned>(y / m_lineHeight, m_layout.lineCount() - 1); 277 278 } -
trunk/Source/WebCore/rendering/line/LineWidth.h
r159569 r159579 57 57 float committedWidth() const { return m_committedWidth; } 58 58 float availableWidth() const { return m_availableWidth; } 59 float logicalLeftOffset() const { return m_left; } 59 60 60 61 void updateAvailableWidth(LayoutUnit minimumHeight = 0);
Note:
See TracChangeset
for help on using the changeset viewer.