Changeset 155565 in webkit
- Timestamp:
- Sep 11, 2013 2:29:37 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r155549 r155565 2110 2110 rendering/LayoutState.cpp 2111 2111 rendering/LayoutRepainter.cpp 2112 rendering/LineWidth.cpp 2112 2113 rendering/PointerEventsHitRules.cpp 2113 2114 rendering/RenderApplet.cpp -
trunk/Source/WebCore/ChangeLog
r155559 r155565 1 2013-09-11 Zoltan Horvath <zoltan@webkit.org> 2 3 Move LineWidth out of RenderBlockLineLayout 4 https://bugs.webkit.org/show_bug.cgi?id=121107 5 6 Reviewed by David Hyatt. 7 8 Move LineWidth class and related code into LineWidth.{h,cpp}. 9 10 No new tests, no behavior change. 11 12 * CMakeLists.txt: 13 * GNUmakefile.list.am: 14 * Target.pri: 15 * WebCore.vcxproj/WebCore.vcxproj: 16 * WebCore.xcodeproj/project.pbxproj: 17 * rendering/LineWidth.cpp: Added. 18 (WebCore::LineWidth::applyOverhang): 19 (WebCore::LineWidth::fitBelowFloats): 20 * rendering/LineWidth.h: Added. 21 (WebCore::logicalHeightForLine): 22 (WebCore::LineWidth::LineWidth): 23 (WebCore::LineWidth::fitsOnLine): 24 (WebCore::LineWidth::fitsOnLineIncludingExtraWidth): 25 (WebCore::LineWidth::fitsOnLineExcludingTrailingWhitespace): 26 (WebCore::LineWidth::currentWidth): 27 (WebCore::LineWidth::uncommittedWidth): 28 (WebCore::LineWidth::committedWidth): 29 (WebCore::LineWidth::availableWidth): 30 (WebCore::LineWidth::addUncommittedWidth): 31 (WebCore::LineWidth::commit): 32 (WebCore::LineWidth::setTrailingWhitespaceWidth): 33 (WebCore::LineWidth::shouldIndentText): 34 (WebCore::LineWidth::computeAvailableWidthFromLeftAndRight): 35 (WebCore::LineWidth::fitsOnLineExcludingTrailingCollapsedWhitespace): 36 (WebCore::LineWidth::updateAvailableWidth): 37 (WebCore::LineWidth::shrinkAvailableWidthForNewFloatIfNeeded): 38 * rendering/RenderBlockLineLayout.cpp: 39 1 40 2013-09-11 Ryosuke Niwa <rniwa@webkit.org> 2 41 -
trunk/Source/WebCore/GNUmakefile.list.am
r155549 r155565 4365 4365 Source/WebCore/rendering/LayoutRepainter.h \ 4366 4366 Source/WebCore/rendering/LayoutRepainter.cpp \ 4367 Source/WebCore/rendering/LineWidth.h \ 4368 Source/WebCore/rendering/LineWidth.cpp \ 4367 4369 Source/WebCore/rendering/OverlapTestRequestClient.h \ 4368 4370 Source/WebCore/rendering/Pagination.h \ -
trunk/Source/WebCore/Target.pri
r155549 r155565 1151 1151 rendering/LayoutState.cpp \ 1152 1152 rendering/LayoutRepainter.cpp \ 1153 rendering/LineWidth.cpp \ 1153 1154 rendering/RenderApplet.cpp \ 1154 1155 rendering/RenderArena.cpp \ … … 2405 2406 rendering/LayoutRepainter.h \ 2406 2407 rendering/LayoutState.h \ 2408 rendering/LineWidth.h \ 2407 2409 rendering/LogicalSelectionOffsetCaches.h \ 2408 2410 rendering/mathml/RenderMathMLBlock.h \ -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
r155549 r155565 9635 9635 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild> 9636 9636 </ClCompile> 9637 <ClCompile Include="..\rendering\LineWidth.cpp" /> 9637 9638 <ClCompile Include="..\rendering\PointerEventsHitRules.cpp"> 9638 9639 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> … … 20007 20008 <ClInclude Include="..\rendering\LayoutRepainter.h" /> 20008 20009 <ClInclude Include="..\rendering\LayoutState.h" /> 20010 <ClInclude Include="..\rendering\LineWidth.h" /> 20009 20011 <ClInclude Include="..\rendering\PaintInfo.h" /> 20010 20012 <ClInclude Include="..\rendering\PaintPhase.h" /> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r155549 r155565 3421 3421 A07D3358152B632D001B6393 /* WebGLShaderPrecisionFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = A07D3357152B632D001B6393 /* WebGLShaderPrecisionFormat.h */; }; 3422 3422 A08CF154152B77B3009C5775 /* WebGLShaderPrecisionFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A08CF153152B77B3009C5775 /* WebGLShaderPrecisionFormat.cpp */; }; 3423 A0CB002417DF82660017896B /* LineWidth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A0CB002317DF81AC0017896B /* LineWidth.cpp */; }; 3424 A0CB002517DF826C0017896B /* LineWidth.h in Headers */ = {isa = PBXBuildFile; fileRef = A0CB002117DE9CD00017896B /* LineWidth.h */; settings = {ATTRIBUTES = (); }; }; 3423 3425 A0EE0DF5144F825500F80B0D /* WebGLDebugRendererInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A0EE0DF1144F825500F80B0D /* WebGLDebugRendererInfo.cpp */; }; 3424 3426 A0EE0DF6144F825500F80B0D /* WebGLDebugRendererInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = A0EE0DF2144F825500F80B0D /* WebGLDebugRendererInfo.h */; }; … … 10016 10018 A07D3359152B633E001B6393 /* WebGLShaderPrecisionFormat.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLShaderPrecisionFormat.idl; path = canvas/WebGLShaderPrecisionFormat.idl; sourceTree = "<group>"; }; 10017 10019 A08CF153152B77B3009C5775 /* WebGLShaderPrecisionFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLShaderPrecisionFormat.cpp; path = canvas/WebGLShaderPrecisionFormat.cpp; sourceTree = "<group>"; }; 10020 A0CB002117DE9CD00017896B /* LineWidth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineWidth.h; sourceTree = "<group>"; }; 10021 A0CB002317DF81AC0017896B /* LineWidth.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LineWidth.cpp; sourceTree = "<group>"; }; 10018 10022 A0EE0DEF144F823200F80B0D /* WebGLDebugShaders.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLDebugShaders.idl; path = canvas/WebGLDebugShaders.idl; sourceTree = "<group>"; }; 10019 10023 A0EE0DF0144F824300F80B0D /* WebGLDebugRendererInfo.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLDebugRendererInfo.idl; path = canvas/WebGLDebugRendererInfo.idl; sourceTree = "<group>"; }; … … 20392 20396 2D9066040BE141D400956998 /* LayoutState.cpp */, 20393 20397 2D9066050BE141D400956998 /* LayoutState.h */, 20398 A0CB002317DF81AC0017896B /* LineWidth.cpp */, 20399 A0CB002117DE9CD00017896B /* LineWidth.h */, 20394 20400 9BA273F3172206BB0097CE47 /* LogicalSelectionOffsetCaches.h */, 20395 20401 3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */, … … 24561 24567 BE16C59517CFE17200852C04 /* InbandWebVTTTextTrack.h in Headers */, 24562 24568 BC10D76817D8EE71005E2626 /* RenderBlockFlow.h in Headers */, 24569 A0CB002517DF826C0017896B /* LineWidth.h in Headers */, 24563 24570 ); 24564 24571 runOnlyForDeploymentPostprocessing = 0; … … 27587 27594 BE16C59417CFE17200852C04 /* InbandWebVTTTextTrack.cpp in Sources */, 27588 27595 BC10D76717D8EE6E005E2626 /* RenderBlockFlow.cpp in Sources */, 27596 A0CB002417DF82660017896B /* LineWidth.cpp in Sources */, 27589 27597 ); 27590 27598 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r155554 r155565 29 29 #include "InlineIterator.h" 30 30 #include "InlineTextBox.h" 31 #include "LineWidth.h" 31 32 #include "Logging.h" 32 33 #include "RenderArena.h" … … 67 68 const unsigned cMaxLineDepth = 200; 68 69 69 static LayoutUnit logicalHeightForLine(const RenderBlock* block, bool isFirstLine, LayoutUnit replacedHeight = 0)70 {71 if (!block->document().inNoQuirksMode() && replacedHeight)72 return replacedHeight;73 74 if (!(block->style(isFirstLine)->lineBoxContain() & LineBoxContainBlock))75 return 0;76 77 return max<LayoutUnit>(replacedHeight, block->lineHeight(isFirstLine, block->isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes));78 }79 80 70 #if ENABLE(CSS_SHAPES) 81 71 ShapeInsideInfo* RenderBlock::layoutShapeInsideInfo() const … … 94 84 } 95 85 #endif 96 97 enum IndentTextOrNot { DoNotIndentText, IndentText };98 99 class LineWidth {100 public:101 LineWidth(RenderBlock* block, bool isFirstLine, IndentTextOrNot shouldIndentText)102 : m_block(block)103 , m_uncommittedWidth(0)104 , m_committedWidth(0)105 , m_overhangWidth(0)106 , m_trailingWhitespaceWidth(0)107 , m_trailingCollapsedWhitespaceWidth(0)108 , m_left(0)109 , m_right(0)110 , m_availableWidth(0)111 #if ENABLE(CSS_SHAPES)112 , m_segment(0)113 #endif114 , m_isFirstLine(isFirstLine)115 , m_shouldIndentText(shouldIndentText)116 {117 ASSERT(block);118 #if ENABLE(CSS_SHAPES)119 if (ShapeInsideInfo* shapeInsideInfo = m_block->layoutShapeInsideInfo())120 m_segment = shapeInsideInfo->currentSegment();121 #endif122 updateAvailableWidth();123 }124 bool fitsOnLine(bool ignoringTrailingSpace = false)125 {126 return ignoringTrailingSpace ? fitsOnLineExcludingTrailingCollapsedWhitespace() : fitsOnLineIncludingExtraWidth(0);127 }128 bool fitsOnLineIncludingExtraWidth(float extra) const { return currentWidth() + extra <= m_availableWidth; }129 bool fitsOnLineExcludingTrailingWhitespace(float extra) const { return currentWidth() - m_trailingWhitespaceWidth + extra <= m_availableWidth; }130 131 float currentWidth() const { return m_committedWidth + m_uncommittedWidth; }132 // FIXME: We should eventually replace these three functions by ones that work on a higher abstraction.133 float uncommittedWidth() const { return m_uncommittedWidth; }134 float committedWidth() const { return m_committedWidth; }135 float availableWidth() const { return m_availableWidth; }136 137 void updateAvailableWidth(LayoutUnit minimumHeight = 0);138 void shrinkAvailableWidthForNewFloatIfNeeded(FloatingObject*);139 void addUncommittedWidth(float delta) { m_uncommittedWidth += delta; }140 void commit()141 {142 m_committedWidth += m_uncommittedWidth;143 m_uncommittedWidth = 0;144 }145 void applyOverhang(RenderRubyRun*, RenderObject* startRenderer, RenderObject* endRenderer);146 void fitBelowFloats();147 void setTrailingWhitespaceWidth(float collapsedWhitespace, float borderPaddingMargin = 0) { m_trailingCollapsedWhitespaceWidth = collapsedWhitespace; m_trailingWhitespaceWidth = collapsedWhitespace + borderPaddingMargin; }148 149 bool shouldIndentText() const { return m_shouldIndentText == IndentText; }150 151 private:152 void computeAvailableWidthFromLeftAndRight()153 {154 m_availableWidth = max(0.0f, m_right - m_left) + m_overhangWidth;155 }156 bool fitsOnLineExcludingTrailingCollapsedWhitespace() const { return currentWidth() - m_trailingCollapsedWhitespaceWidth <= m_availableWidth; }157 158 private:159 RenderBlock* m_block;160 float m_uncommittedWidth;161 float m_committedWidth;162 float m_overhangWidth; // The amount by which |m_availableWidth| has been inflated to account for possible contraction due to ruby overhang.163 float m_trailingWhitespaceWidth;164 float m_trailingCollapsedWhitespaceWidth;165 float m_left;166 float m_right;167 float m_availableWidth;168 #if ENABLE(CSS_SHAPES)169 const LineSegment* m_segment;170 #endif171 bool m_isFirstLine;172 IndentTextOrNot m_shouldIndentText;173 };174 175 inline void LineWidth::updateAvailableWidth(LayoutUnit replacedHeight)176 {177 LayoutUnit height = m_block->logicalHeight();178 LayoutUnit logicalHeight = logicalHeightForLine(m_block, m_isFirstLine, replacedHeight);179 m_left = m_block->logicalLeftOffsetForLine(height, shouldIndentText(), logicalHeight);180 m_right = m_block->logicalRightOffsetForLine(height, shouldIndentText(), logicalHeight);181 182 #if ENABLE(CSS_SHAPES)183 if (m_segment) {184 m_left = max<float>(m_segment->logicalLeft, m_left);185 m_right = min<float>(m_segment->logicalRight, m_right);186 }187 #endif188 189 computeAvailableWidthFromLeftAndRight();190 }191 192 inline void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(FloatingObject* newFloat)193 {194 LayoutUnit height = m_block->logicalHeight();195 if (height < newFloat->logicalTop(m_block->isHorizontalWritingMode()) || height >= newFloat->logicalBottom(m_block->isHorizontalWritingMode()))196 return;197 198 #if ENABLE(CSS_SHAPES)199 // When floats with shape outside are stacked, the floats are positioned based on the margin box of the float,200 // not the shape's contour. Since we computed the width based on the shape contour when we added the float,201 // when we add a subsequent float on the same line, we need to undo the shape delta in order to position202 // based on the margin box. In order to do this, we need to walk back through the floating object list to find203 // the first previous float that is on the same side as our newFloat.204 ShapeOutsideInfo* previousShapeOutsideInfo = 0;205 const FloatingObjectSet& floatingObjectSet = m_block->m_floatingObjects->set();206 FloatingObjectSetIterator it = floatingObjectSet.end();207 FloatingObjectSetIterator begin = floatingObjectSet.begin();208 for (--it; it != begin; --it) {209 FloatingObject* previousFloat = *it;210 if (previousFloat != newFloat && previousFloat->type() == newFloat->type()) {211 previousShapeOutsideInfo = previousFloat->renderer()->shapeOutsideInfo();212 if (previousShapeOutsideInfo) {213 previousShapeOutsideInfo->computeSegmentsForContainingBlockLine(m_block->logicalHeight(), previousFloat->logicalTop(m_block->isHorizontalWritingMode()), logicalHeightForLine(m_block, m_isFirstLine));214 }215 break;216 }217 }218 219 ShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer()->shapeOutsideInfo();220 if (shapeOutsideInfo) {221 shapeOutsideInfo->computeSegmentsForContainingBlockLine(m_block->logicalHeight(), newFloat->logicalTop(m_block->isHorizontalWritingMode()), logicalHeightForLine(m_block, m_isFirstLine));222 }223 #endif224 225 if (newFloat->type() == FloatingObject::FloatLeft) {226 float newLeft = newFloat->logicalRight(m_block->isHorizontalWritingMode());227 #if ENABLE(CSS_SHAPES)228 if (previousShapeOutsideInfo)229 newLeft -= previousShapeOutsideInfo->rightSegmentMarginBoxDelta();230 if (shapeOutsideInfo)231 newLeft += shapeOutsideInfo->rightSegmentMarginBoxDelta();232 #endif233 234 if (shouldIndentText() && m_block->style()->isLeftToRightDirection())235 newLeft += floorToInt(m_block->textIndentOffset());236 m_left = max<float>(m_left, newLeft);237 } else {238 float newRight = newFloat->logicalLeft(m_block->isHorizontalWritingMode());239 #if ENABLE(CSS_SHAPES)240 if (previousShapeOutsideInfo)241 newRight -= previousShapeOutsideInfo->leftSegmentMarginBoxDelta();242 if (shapeOutsideInfo)243 newRight += shapeOutsideInfo->leftSegmentMarginBoxDelta();244 #endif245 246 if (shouldIndentText() && !m_block->style()->isLeftToRightDirection())247 newRight -= floorToInt(m_block->textIndentOffset());248 m_right = min<float>(m_right, newRight);249 }250 251 computeAvailableWidthFromLeftAndRight();252 }253 254 void LineWidth::applyOverhang(RenderRubyRun* rubyRun, RenderObject* startRenderer, RenderObject* endRenderer)255 {256 int startOverhang;257 int endOverhang;258 rubyRun->getOverhang(m_isFirstLine, startRenderer, endRenderer, startOverhang, endOverhang);259 260 startOverhang = min<int>(startOverhang, m_committedWidth);261 m_availableWidth += startOverhang;262 263 endOverhang = max(min<int>(endOverhang, m_availableWidth - currentWidth()), 0);264 m_availableWidth += endOverhang;265 m_overhangWidth += startOverhang + endOverhang;266 }267 268 void LineWidth::fitBelowFloats()269 {270 ASSERT(!m_committedWidth);271 ASSERT(!fitsOnLine());272 273 LayoutUnit floatLogicalBottom;274 LayoutUnit lastFloatLogicalBottom = m_block->logicalHeight();275 float newLineWidth = m_availableWidth;276 float newLineLeft = m_left;277 float newLineRight = m_right;278 while (true) {279 floatLogicalBottom = m_block->nextFloatLogicalBottomBelow(lastFloatLogicalBottom);280 if (floatLogicalBottom <= lastFloatLogicalBottom)281 break;282 283 newLineLeft = m_block->logicalLeftOffsetForLine(floatLogicalBottom, shouldIndentText());284 newLineRight = m_block->logicalRightOffsetForLine(floatLogicalBottom, shouldIndentText());285 newLineWidth = max(0.0f, newLineRight - newLineLeft);286 lastFloatLogicalBottom = floatLogicalBottom;287 if (newLineWidth >= m_uncommittedWidth)288 break;289 }290 291 if (newLineWidth > m_availableWidth) {292 m_block->setLogicalHeight(lastFloatLogicalBottom);293 m_availableWidth = newLineWidth + m_overhangWidth;294 m_left = newLineLeft;295 m_right = newLineRight;296 }297 }298 86 299 87 class LineInfo { … … 2929 2717 LineMidpointState& lineMidpointState = resolver.midpointState(); 2930 2718 2931 LineWidth width( m_block, lineInfo.isFirstLine(), requiresIndent(lineInfo.isFirstLine(), lineInfo.previousLineBrokeCleanly(), m_block->style()));2719 LineWidth width(*m_block, lineInfo.isFirstLine(), requiresIndent(lineInfo.isFirstLine(), lineInfo.previousLineBrokeCleanly(), m_block->style())); 2932 2720 2933 2721 skipLeadingWhitespace(resolver, lineInfo, lastFloatFromPreviousLine, width);
Note: See TracChangeset
for help on using the changeset viewer.