| 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 17 matching lines...) Expand all Loading... |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "core/layout/line/LineWidth.h" | 31 #include "core/layout/line/LineWidth.h" |
| 32 | 32 |
| 33 #include "core/layout/LayoutBlock.h" | 33 #include "core/layout/LayoutBlock.h" |
| 34 #include "core/layout/LayoutRubyRun.h" | 34 #include "core/layout/LayoutRubyRun.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 LineWidth::LineWidth(LayoutBlockFlow& block, bool isFirstLine, IndentTextOrNot s
houldIndentText) | 38 LineWidth::LineWidth(LineLayoutBlockFlow block, bool isFirstLine, IndentTextOrNo
t shouldIndentText) |
| 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_overhangWidth(0) | 42 , m_overhangWidth(0) |
| 43 , m_trailingWhitespaceWidth(0) | 43 , m_trailingWhitespaceWidth(0) |
| 44 , m_left(0) | 44 , m_left(0) |
| 45 , m_right(0) | 45 , m_right(0) |
| 46 , m_availableWidth(0) | 46 , m_availableWidth(0) |
| 47 , m_isFirstLine(isFirstLine) | 47 , m_isFirstLine(isFirstLine) |
| 48 , m_shouldIndentText(shouldIndentText) | 48 , m_shouldIndentText(shouldIndentText) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 rubyRun->getOverhang(m_isFirstLine, startLayoutObject, endLayoutObject, star
tOverhang, endOverhang); | 112 rubyRun->getOverhang(m_isFirstLine, startLayoutObject, endLayoutObject, star
tOverhang, endOverhang); |
| 113 | 113 |
| 114 startOverhang = std::min<int>(startOverhang, m_committedWidth); | 114 startOverhang = std::min<int>(startOverhang, m_committedWidth); |
| 115 m_availableWidth += startOverhang; | 115 m_availableWidth += startOverhang; |
| 116 | 116 |
| 117 endOverhang = std::max(std::min<int>(endOverhang, m_availableWidth - current
Width()), 0); | 117 endOverhang = std::max(std::min<int>(endOverhang, m_availableWidth - current
Width()), 0); |
| 118 m_availableWidth += endOverhang; | 118 m_availableWidth += endOverhang; |
| 119 m_overhangWidth += startOverhang + endOverhang; | 119 m_overhangWidth += startOverhang + endOverhang; |
| 120 } | 120 } |
| 121 | 121 |
| 122 inline static float availableWidthAtOffset(const LayoutBlockFlow& block, const L
ayoutUnit& offset, bool shouldIndentText, float& newLineLeft, | 122 inline static float availableWidthAtOffset(LineLayoutBlockFlow block, const Layo
utUnit& offset, bool shouldIndentText, float& newLineLeft, |
| 123 float& newLineRight, const LayoutUnit& lineHeight = 0) | 123 float& newLineRight, const LayoutUnit& lineHeight = 0) |
| 124 { | 124 { |
| 125 newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText, lineH
eight).toFloat(); | 125 newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText, lineH
eight).toFloat(); |
| 126 newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentText, lin
eHeight).toFloat(); | 126 newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentText, lin
eHeight).toFloat(); |
| 127 return std::max(0.0f, newLineRight - newLineLeft); | 127 return std::max(0.0f, newLineRight - newLineLeft); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void LineWidth::updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWid
th, const float& newLineLeft, const float& newLineRight) | 130 void LineWidth::updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWid
th, const float& newLineLeft, const float& newLineRight) |
| 131 { | 131 { |
| 132 if (newLineWidth <= m_availableWidth) | 132 if (newLineWidth <= m_availableWidth) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 ASSERT(!m_committedWidth); | 166 ASSERT(!m_committedWidth); |
| 167 ASSERT(!fitsOnLine()); | 167 ASSERT(!fitsOnLine()); |
| 168 m_block.positionNewFloats(this); | 168 m_block.positionNewFloats(this); |
| 169 | 169 |
| 170 LayoutUnit floatLogicalBottom; | 170 LayoutUnit floatLogicalBottom; |
| 171 LayoutUnit lastFloatLogicalBottom = m_block.logicalHeight(); | 171 LayoutUnit lastFloatLogicalBottom = m_block.logicalHeight(); |
| 172 float newLineWidth = m_availableWidth; | 172 float newLineWidth = m_availableWidth; |
| 173 float newLineLeft = m_left; | 173 float newLineLeft = m_left; |
| 174 float newLineRight = m_right; | 174 float newLineRight = m_right; |
| 175 | 175 |
| 176 FloatingObject* lastFloatFromPreviousLine = (m_block.containsFloats() ? m_bl
ock.m_floatingObjects->set().last().get() : 0); | 176 FloatingObject* lastFloatFromPreviousLine = m_block.lastFloatFromPreviousLin
e(); |
| 177 if (lastFloatFromPreviousLine && lastFloatFromPreviousLine->layoutObject
()->shapeOutsideInfo()) | 177 if (lastFloatFromPreviousLine && lastFloatFromPreviousLine->layoutObject
()->shapeOutsideInfo()) |
| 178 return wrapNextToShapeOutside(isFirstLine); | 178 return wrapNextToShapeOutside(isFirstLine); |
| 179 | 179 |
| 180 while (true) { | 180 while (true) { |
| 181 floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lastFloatLogica
lBottom, ShapeOutsideFloatShapeOffset); | 181 floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lastFloatLogica
lBottom, ShapeOutsideFloatShapeOffset); |
| 182 if (floatLogicalBottom <= lastFloatLogicalBottom) | 182 if (floatLogicalBottom <= lastFloatLogicalBottom) |
| 183 break; | 183 break; |
| 184 | 184 |
| 185 newLineWidth = availableWidthAtOffset(m_block, floatLogicalBottom, shoul
dIndentText(), newLineLeft, newLineRight); | 185 newLineWidth = availableWidthAtOffset(m_block, floatLogicalBottom, shoul
dIndentText(), newLineLeft, newLineRight); |
| 186 lastFloatLogicalBottom = floatLogicalBottom; | 186 lastFloatLogicalBottom = floatLogicalBottom; |
| 187 | 187 |
| 188 if (newLineWidth >= m_uncommittedWidth) | 188 if (newLineWidth >= m_uncommittedWidth) |
| 189 break; | 189 break; |
| 190 } | 190 } |
| 191 updateLineDimension(lastFloatLogicalBottom, newLineWidth, newLineLeft, newLi
neRight); | 191 updateLineDimension(lastFloatLogicalBottom, newLineWidth, newLineLeft, newLi
neRight); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void LineWidth::computeAvailableWidthFromLeftAndRight() | 194 void LineWidth::computeAvailableWidthFromLeftAndRight() |
| 195 { | 195 { |
| 196 m_availableWidth = max(0.0f, m_right - m_left) + m_overhangWidth; | 196 m_availableWidth = max(0.0f, m_right - m_left) + m_overhangWidth; |
| 197 } | 197 } |
| 198 | 198 |
| 199 } | 199 } |
| OLD | NEW |