| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
| 9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
| 10 * disclaimer. | 10 * disclaimer. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 LineWidth::LineWidth(RenderBlockFlow& block, bool isFirstLine, IndentTextOrNot s
houldIndentText) | 38 LineWidth::LineWidth(RenderBlockFlow& block, bool isFirstLine, IndentTextOrNot s
houldIndentText) |
| 39 : m_block(block) | 39 : m_block(block) |
| 40 , m_uncommittedWidth(0) | 40 , m_uncommittedWidth(0) |
| 41 , m_committedWidth(0) | 41 , m_committedWidth(0) |
| 42 , m_trailingWhitespaceWidth(0) | 42 , m_trailingWhitespaceWidth(0) |
| 43 , m_left(0) | 43 , m_left(0) |
| 44 , m_right(0) | 44 , m_right(0) |
| 45 , m_availableWidth(0) | 45 , m_availableWidth(0) |
| 46 , m_isFirstLine(isFirstLine) | |
| 47 , m_shouldIndentText(shouldIndentText) | 46 , m_shouldIndentText(shouldIndentText) |
| 48 { | 47 { |
| 49 updateAvailableWidth(); | 48 updateAvailableWidth(); |
| 50 } | 49 } |
| 51 | 50 |
| 52 void LineWidth::updateAvailableWidth(LayoutUnit replacedHeight) | 51 void LineWidth::updateAvailableWidth() |
| 53 { | 52 { |
| 54 LayoutUnit height = m_block.logicalHeight(); | 53 m_left = m_block.logicalLeftOffsetForLine(shouldIndentText()).toFloat(); |
| 55 LayoutUnit logicalHeight = m_block.minLineHeightForReplacedRenderer(m_isFirs
tLine, replacedHeight); | 54 m_right = m_block.logicalRightOffsetForLine(shouldIndentText()).toFloat(); |
| 56 m_left = m_block.logicalLeftOffsetForLine(height, shouldIndentText(), logica
lHeight).toFloat(); | |
| 57 m_right = m_block.logicalRightOffsetForLine(height, shouldIndentText(), logi
calHeight).toFloat(); | |
| 58 | |
| 59 computeAvailableWidthFromLeftAndRight(); | 55 computeAvailableWidthFromLeftAndRight(); |
| 60 } | 56 } |
| 61 | 57 |
| 62 void LineWidth::commit() | 58 void LineWidth::commit() |
| 63 { | 59 { |
| 64 m_committedWidth += m_uncommittedWidth; | 60 m_committedWidth += m_uncommittedWidth; |
| 65 m_uncommittedWidth = 0; | 61 m_uncommittedWidth = 0; |
| 66 } | 62 } |
| 67 | 63 |
| 68 inline static float availableWidthAtOffset(const RenderBlockFlow& block, const L
ayoutUnit& offset, bool shouldIndentText, float& newLineLeft, float& newLineRigh
t) | |
| 69 { | |
| 70 newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText).toFlo
at(); | |
| 71 newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentText).toF
loat(); | |
| 72 return std::max(0.0f, newLineRight - newLineLeft); | |
| 73 } | |
| 74 | |
| 75 void LineWidth::updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWid
th, const float& newLineLeft, const float& newLineRight) | 64 void LineWidth::updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWid
th, const float& newLineLeft, const float& newLineRight) |
| 76 { | 65 { |
| 77 if (newLineWidth <= m_availableWidth) | 66 if (newLineWidth <= m_availableWidth) |
| 78 return; | 67 return; |
| 79 | 68 |
| 80 m_block.setLogicalHeight(newLineTop); | 69 m_block.setLogicalHeight(newLineTop); |
| 81 m_availableWidth = newLineWidth.toFloat(); | 70 m_availableWidth = newLineWidth.toFloat(); |
| 82 m_left = newLineLeft; | 71 m_left = newLineLeft; |
| 83 m_right = newLineRight; | 72 m_right = newLineRight; |
| 84 } | 73 } |
| 85 | 74 |
| 86 | 75 |
| 87 void LineWidth::fitBelowFloats(bool isFirstLine) | 76 void LineWidth::fitBelowFloats(bool isFirstLine) |
| 88 { | 77 { |
| 89 ASSERT(!m_committedWidth); | 78 ASSERT(!m_committedWidth); |
| 90 ASSERT(!fitsOnLine()); | 79 ASSERT(!fitsOnLine()); |
| 91 | 80 |
| 92 LayoutUnit floatLogicalBottom; | 81 LayoutUnit floatLogicalBottom; |
| 93 LayoutUnit lastFloatLogicalBottom = m_block.logicalHeight(); | 82 LayoutUnit lastFloatLogicalBottom = m_block.logicalHeight(); |
| 94 float newLineWidth = m_availableWidth; | 83 float newLineWidth = m_availableWidth; |
| 95 float newLineLeft = m_left; | 84 float newLineLeft = m_left; |
| 96 float newLineRight = m_right; | 85 float newLineRight = m_right; |
| 97 | 86 |
| 98 while (true) { | 87 while (true) { |
| 99 floatLogicalBottom = lastFloatLogicalBottom; | 88 floatLogicalBottom = lastFloatLogicalBottom; |
| 100 if (floatLogicalBottom <= lastFloatLogicalBottom) | 89 if (floatLogicalBottom <= lastFloatLogicalBottom) |
| 101 break; | 90 break; |
| 102 | 91 |
| 103 newLineWidth = availableWidthAtOffset(m_block, floatLogicalBottom, shoul
dIndentText(), newLineLeft, newLineRight); | 92 newLineLeft = m_block.logicalLeftOffsetForLine(shouldIndentText()).toFlo
at(); |
| 93 newLineRight = m_block.logicalRightOffsetForLine(shouldIndentText()).toF
loat(); |
| 94 newLineWidth = std::max(0.0f, newLineRight - newLineLeft); |
| 95 |
| 104 lastFloatLogicalBottom = floatLogicalBottom; | 96 lastFloatLogicalBottom = floatLogicalBottom; |
| 105 | 97 |
| 106 if (newLineWidth >= m_uncommittedWidth) | 98 if (newLineWidth >= m_uncommittedWidth) |
| 107 break; | 99 break; |
| 108 } | 100 } |
| 109 updateLineDimension(lastFloatLogicalBottom, newLineWidth, newLineLeft, newLi
neRight); | 101 updateLineDimension(lastFloatLogicalBottom, newLineWidth, newLineLeft, newLi
neRight); |
| 110 } | 102 } |
| 111 | 103 |
| 112 void LineWidth::computeAvailableWidthFromLeftAndRight() | 104 void LineWidth::computeAvailableWidthFromLeftAndRight() |
| 113 { | 105 { |
| 114 m_availableWidth = max(0.0f, m_right - m_left); | 106 m_availableWidth = max(0.0f, m_right - m_left); |
| 115 } | 107 } |
| 116 | 108 |
| 117 } | 109 } |
| OLD | NEW |