Changeset 126605 in webkit
- Timestamp:
- Aug 24, 2012 11:48:49 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 13 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r126604 r126605 1 2012-08-24 Bear Travis <betravis@adobe.com> 2 3 [CSS Exclusions] Enable shape-inside for simple rectangles 4 https://bugs.webkit.org/show_bug.cgi?id=89259 5 6 Reviewed by Levi Weintraub. 7 8 Test that inline content correctly wraps for a simple rectangular 9 shape-inside. Text and inline content should wrap inside the 10 rectangular shape-inside, and overflow to its containing block. 11 Inline content inside a shape-inside should also avoid floats. 12 13 * fast/exclusions/shape-inside/shape-inside-floats-simple-expected.html: Added. 14 * fast/exclusions/shape-inside/shape-inside-floats-simple.html: Added. 15 * fast/exclusions/shape-inside/shape-inside-inline-elements-expected.html: Added. 16 * fast/exclusions/shape-inside/shape-inside-inline-elements.html: Added. 17 * fast/exclusions/shape-inside/shape-inside-overflow-expected.html: Added. 18 * fast/exclusions/shape-inside/shape-inside-overflow.html: Added. 19 * fast/exclusions/shape-inside/shape-inside-percentage-auto-expected.html: Added. 20 * fast/exclusions/shape-inside/shape-inside-percentage-auto.html: Added. 21 * fast/exclusions/shape-inside/shape-inside-text-expected.html: Added. 22 * fast/exclusions/shape-inside/shape-inside-text.html: Added. 23 1 24 2012-08-24 Julien Chaffraix <jchaffraix@webkit.org> 2 25 -
trunk/Source/WebCore/CMakeLists.txt
r126372 r126605 2100 2100 rendering/RootInlineBox.cpp 2101 2101 rendering/ScrollBehavior.cpp 2102 rendering/WrapShapeInfo.cpp 2102 2103 rendering/break_lines.cpp 2103 2104 -
trunk/Source/WebCore/ChangeLog
r126602 r126605 1 2012-08-24 Bear Travis <betravis@adobe.com> 2 3 [CSS Exclusions] Enable shape-inside for simple rectangles 4 https://bugs.webkit.org/show_bug.cgi?id=89259 5 6 Reviewed by Levi Weintraub. 7 8 This patch is the first in a series enabling shape-inside. It adds 9 support for inline layout within a single render block with a 10 rectangular shape-inside. 11 Each RenderBlock with a valid shape-inside maintains a WrapShapeInfo, 12 which can calculate the areas, or LineSegments, where inline content 13 can flow on a line. The WrapShapeInfo class maintains a static map of 14 RenderBlocks to WrapShapeInfos. The basic algorithm involves three stages: 15 1. Determine if the RenderBlock has a valid shape-inside, and store it 16 in a WrapShapeInfo if necessary. 17 2. If the inline content is affected by a shape-inside, use the 18 corresponding WrapShapeInfo to break the content into line segments. 19 3. Lay out the line segments. 20 21 Tests: fast/exclusions/shape-inside/shape-inside-floats-simple.html 22 fast/exclusions/shape-inside/shape-inside-inline-elements.html 23 fast/exclusions/shape-inside/shape-inside-overflow.html 24 fast/exclusions/shape-inside/shape-inside-percentage-auto.html 25 fast/exclusions/shape-inside/shape-inside-text.html 26 27 * CMakeLists.txt: 28 * GNUmakefile.list.am: 29 * Target.pri: 30 * WebCore.gypi: 31 * WebCore.vcproj/WebCore.vcproj: 32 * WebCore.xcodeproj/project.pbxproj: 33 * rendering/RenderBlock.cpp: 34 (WebCore::RenderBlock::willBeDestroyed): Remove WrapShapeInfo when destroyed. 35 (WebCore::RenderBlock::styleDidChange): Detect modifications to style()->wrapShapeInside. 36 (WebCore): 37 (WebCore::RenderBlock::updateWrapShapeInfoAfterStyleChange): Update WrapShapeInfo 38 when style()->wrapShapeInside changes. 39 (WebCore::RenderBlock::layoutBlock): Notify WrapShapeInfo of changes in logicalWidth 40 and logicalHeight before laying out inline content. 41 * rendering/RenderBlock.h: 42 (RenderBlock): 43 (WebCore::RenderBlock::wrapShapeInfo): Return the wrapShapeInfo associated with a 44 RenderBlock. 45 * rendering/RenderBlockLineLayout.cpp: 46 (WebCore::LineWidth::LineWidth): Determine the WrapShapeInfo::LineSegment this LineWidth 47 corresponds to, if any. 48 (LineWidth): 49 (WebCore::LineWidth::updateAvailableWidth): The width's LineSegment boundaries affect 50 the available width. 51 (WebCore::RenderBlock::computeInlineDirectionPositionsForLine): The current LineSegment 52 affects the left & right positioning of inline boxes. 53 (WebCore::RenderBlock::layoutRunsAndFloatsInRange): Move to the top of the inside wrap 54 shape before beginning inline layout, and update the line segments for each line. 55 * rendering/WrapShapeInfo.cpp: Added. 56 (WebCore): 57 (WebCore::WrapShapeInfo::WrapShapeInfo): Create an empty WrapShapeInfo. 58 (WebCore::WrapShapeInfo::~WrapShapeInfo): No additional cleanup. 59 (WebCore::WrapShapeInfo::create): Create a WrapShapeInfo reference. 60 (WebCore::WrapShapeInfo::ensureWrapShapeInfoForRenderBlock): Create a WrapShapeInfo 61 for a RenderBlock with an inside WrapShape and place it in the WrapShapeInfo map. 62 (WebCore::WrapShapeInfo::wrapShapeInfoForRenderBlock): Lookup the WrapShapeInfo for 63 a RenderBlock in the WrapShapeInfo map. 64 (WebCore::WrapShapeInfo::isWrapShapeInfoEnabledForBlock): Determine if a RenderBlock 65 has an inside wrap shape that we can use for inline layout. 66 (WebCore::WrapShapeInfo::removeWrapShapeInfoForRenderBlock): Remove a RenderBlock's 67 WrapShapeInfo from the WrapShapeInfo map. 68 (WebCore::WrapShapeInfo::hasSegments): Returns true if there are any line segments 69 for the current line. 70 (WebCore::WrapShapeInfo::computeShapeSize): Compute the dimensions of the wrap shape 71 based on a block's logical width & height. 72 (WebCore::WrapShapeInfo::computeSegmentsForLine): Sets the current line and computes 73 its line segments. 74 * rendering/WrapShapeInfo.h: Added. 75 (WebCore): 76 (LineSegment): 77 (WrapShapeInfo): 78 (WebCore::WrapShapeInfo::shapeTop): The top of a wrap shape, where the inline content 79 area begins. 80 (WebCore::WrapShapeInfo::segments): The list of line segments for the current line. 81 (WebCore::WrapShapeInfo::wrapShapeSizeNeedsRecomputing): Mark a WrapShapeInfo as 82 needing to recompute its WrapShape dimensions. 83 (WebCore::WrapShapeInfo::lineState): The current line state: above, inside, or below 84 the wrap shape. 85 * rendering/style/RenderStyle.cpp: 86 (WebCore::RenderStyle::diff): Changes to shape inside require relayout. 87 1 88 2012-08-24 David Hyatt <hyatt@apple.com> 2 89 -
trunk/Source/WebCore/GNUmakefile.list.am
r126583 r126605 5033 5033 Source/WebCore/rendering/ScrollBehavior.h \ 5034 5034 Source/WebCore/rendering/VerticalPositionCache.h \ 5035 Source/WebCore/rendering/WrapShapeInfo.cpp \ 5036 Source/WebCore/rendering/WrapShapeInfo.h \ 5035 5037 Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp \ 5036 5038 Source/WebCore/rendering/mathml/RenderMathMLBlock.h \ -
trunk/Source/WebCore/Target.pri
r126372 r126605 1183 1183 rendering/RootInlineBox.cpp \ 1184 1184 rendering/ScrollBehavior.cpp \ 1185 rendering/WrapShapeInfo.cpp \ 1185 1186 rendering/style/ContentData.cpp \ 1186 1187 rendering/style/CounterDirectives.cpp \ … … 2365 2366 rendering/RootInlineBox.h \ 2366 2367 rendering/ScrollBehavior.h \ 2368 rendering/WrapShapeInfo.h \ 2367 2369 rendering/style/ContentData.h \ 2368 2370 rendering/style/CounterDirectives.h \ -
trunk/Source/WebCore/WebCore.gypi
r126566 r126605 584 584 'rendering/RootInlineBox.h', 585 585 'rendering/ScrollBehavior.h', 586 'rendering/WrapShapeInfo.h', 586 587 'rendering/style/BorderData.h', 587 588 'rendering/style/BorderValue.h', … … 4871 4872 'rendering/TrailingFloatsRootInlineBox.h', 4872 4873 'rendering/VerticalPositionCache.h', 4874 'rendering/WrapShapeInfo.cpp', 4873 4875 'rendering/break_lines.cpp', 4874 4876 'rendering/break_lines.h', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r126437 r126605 42036 42036 </File> 42037 42037 <File 42038 RelativePath="..\rendering\WrapShapeInfo.cpp" 42039 > 42040 </File> 42041 <File 42042 RelativePath="..\rendering\WrapShapeInfo.h" 42043 > 42044 </File> 42045 <File 42038 42046 RelativePath="..\rendering\svg\RenderSVGAllInOne.cpp" 42039 42047 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r126486 r126605 6441 6441 FD6F252C13F5EF0E0065165F /* MediaElementAudioSourceNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD6F252913F5EF0E0065165F /* MediaElementAudioSourceNode.cpp */; }; 6442 6442 FD6F252D13F5EF0E0065165F /* MediaElementAudioSourceNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD6F252A13F5EF0E0065165F /* MediaElementAudioSourceNode.h */; }; 6443 FD748ABF15BF74ED0059CF0D /* WrapShapeInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD748ABD15BF74ED0059CF0D /* WrapShapeInfo.cpp */; }; 6444 FD748AC015BF74ED0059CF0D /* WrapShapeInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = FD748ABE15BF74ED0059CF0D /* WrapShapeInfo.h */; settings = {ATTRIBUTES = (Private, ); }; }; 6443 6445 FD7868B9136B999200D403DF /* JSDynamicsCompressorNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD7868B7136B999200D403DF /* JSDynamicsCompressorNode.cpp */; }; 6444 6446 FD7868BA136B999200D403DF /* JSDynamicsCompressorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD7868B8136B999200D403DF /* JSDynamicsCompressorNode.h */; }; … … 13847 13849 FD6F252A13F5EF0E0065165F /* MediaElementAudioSourceNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaElementAudioSourceNode.h; sourceTree = "<group>"; }; 13848 13850 FD6F252B13F5EF0E0065165F /* MediaElementAudioSourceNode.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaElementAudioSourceNode.idl; sourceTree = "<group>"; }; 13851 FD748ABD15BF74ED0059CF0D /* WrapShapeInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WrapShapeInfo.cpp; sourceTree = "<group>"; }; 13852 FD748ABE15BF74ED0059CF0D /* WrapShapeInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WrapShapeInfo.h; sourceTree = "<group>"; }; 13849 13853 FD7868B7136B999200D403DF /* JSDynamicsCompressorNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDynamicsCompressorNode.cpp; sourceTree = "<group>"; }; 13850 13854 FD7868B8136B999200D403DF /* JSDynamicsCompressorNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDynamicsCompressorNode.h; sourceTree = "<group>"; }; … … 21462 21466 37FC96DA1104ED71003E1FAD /* TrailingFloatsRootInlineBox.h */, 21463 21467 BCA257141293C010007A263D /* VerticalPositionCache.h */, 21468 FD748ABD15BF74ED0059CF0D /* WrapShapeInfo.cpp */, 21469 FD748ABE15BF74ED0059CF0D /* WrapShapeInfo.h */, 21464 21470 ); 21465 21471 path = rendering; … … 25406 25412 93309E24099E64920056E581 /* WrapContentsInDummySpanCommand.h in Headers */, 25407 25413 FDE6860315B0A96100BB480C /* WrapShapeFunctions.h in Headers */, 25414 FD748AC015BF74ED0059CF0D /* WrapShapeInfo.h in Headers */, 25408 25415 FDE6860415B0A96100BB480C /* WrapShapes.h in Headers */, 25409 25416 9BAF3B2412C1A39800014BF1 /* WritingDirection.h in Headers */, … … 28493 28500 93309E23099E64920056E581 /* WrapContentsInDummySpanCommand.cpp in Sources */, 28494 28501 FDE6860215B0A93B00BB480C /* WrapShapeFunctions.cpp in Sources */, 28502 FD748ABF15BF74ED0059CF0D /* WrapShapeInfo.cpp in Sources */, 28495 28503 F553B89315BE26C000B134C9 /* WrapShapes.cpp in Sources */, 28496 28504 A833C7CC0A2CF07400D57664 /* XLinkNames.cpp in Sources */, -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r126520 r126605 62 62 #include "TransformState.h" 63 63 #include <wtf/StdLibExtras.h> 64 #if ENABLE(CSS_EXCLUSIONS) 65 #include "WrapShapeInfo.h" 66 #endif 64 67 65 68 using namespace std; … … 275 278 if (lineGridBox()) 276 279 lineGridBox()->destroy(renderArena()); 280 281 #if ENABLE(CSS_EXCLUSIONS) 282 WrapShapeInfo::removeWrapShapeInfoForRenderBlock(this); 283 #endif 277 284 278 285 if (UNLIKELY(gDelayedUpdateScrollInfoSet != 0)) … … 320 327 { 321 328 RenderBox::styleDidChange(diff, oldStyle); 329 330 #if ENABLE(CSS_EXCLUSIONS) 331 // FIXME: Bug 89993: Style changes should affect the WrapShapeInfos for other render blocks that 332 // share the same WrapShapeInfo 333 updateWrapShapeInfoAfterStyleChange(style()->wrapShapeInside(), oldStyle ? oldStyle->wrapShapeInside() : 0); 334 #endif 322 335 323 336 if (!isAnonymousBlock()) { … … 1367 1380 } 1368 1381 1382 #if ENABLE(CSS_EXCLUSIONS) 1383 void RenderBlock::updateWrapShapeInfoAfterStyleChange(const WrapShape* wrapShape, const WrapShape* oldWrapShape) 1384 { 1385 // FIXME: A future optimization would do a deep comparison for equality. 1386 if (wrapShape == oldWrapShape) 1387 return; 1388 1389 if (wrapShape) { 1390 WrapShapeInfo* wrapShapeInfo = WrapShapeInfo::ensureWrapShapeInfoForRenderBlock(this); 1391 wrapShapeInfo->dirtyWrapShapeSize(); 1392 } else 1393 WrapShapeInfo::removeWrapShapeInfoForRenderBlock(this); 1394 } 1395 #endif 1396 1369 1397 void RenderBlock::computeInitialRegionRangeForBlock() 1370 1398 { … … 1462 1490 } 1463 1491 computeInitialRegionRangeForBlock(); 1492 #if ENABLE(CSS_EXCLUSIONS) 1493 // FIXME: Bug 93547: Resolve logical height for percentage based vertical lengths 1494 if (WrapShapeInfo* wrapShapeInfo = this->wrapShapeInfo()) 1495 wrapShapeInfo->computeShapeSize(logicalWidth(), 0); 1496 #endif 1464 1497 1465 1498 // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, to track -
trunk/Source/WebCore/rendering/RenderBlock.h
r126343 r126605 34 34 #include <wtf/ListHashSet.h> 35 35 36 #if ENABLE(CSS_EXCLUSIONS) 37 #include "WrapShapeInfo.h" 38 #endif 39 36 40 namespace WebCore { 37 41 … … 397 401 #endif 398 402 403 #if ENABLE(CSS_EXCLUSIONS) 404 WrapShapeInfo* wrapShapeInfo() const 405 { 406 return style()->wrapShapeInside() && WrapShapeInfo::isWrapShapeInfoEnabledForRenderBlock(this) ? WrapShapeInfo::wrapShapeInfoForRenderBlock(this) : 0; 407 } 408 #endif 409 399 410 protected: 400 411 virtual void willBeDestroyed(); … … 486 497 487 498 private: 499 #if ENABLE(CSS_EXCLUSIONS) 500 void updateWrapShapeInfoAfterStyleChange(const WrapShape*, const WrapShape* oldWrapShape); 501 #endif 488 502 virtual RenderObjectChildList* virtualChildren() { return children(); } 489 503 virtual const RenderObjectChildList* virtualChildren() const { return children(); } -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r126100 r126605 47 47 #include <wtf/unicode/CharacterNames.h> 48 48 49 #if ENABLE(CSS_EXCLUSIONS) 50 #include "WrapShapeInfo.h" 51 #endif 52 49 53 #if ENABLE(SVG) 50 54 #include "RenderSVGInlineText.h" … … 71 75 , m_right(0) 72 76 , m_availableWidth(0) 77 #if ENABLE(CSS_EXCLUSIONS) 78 , m_segment(0) 79 #endif 73 80 , m_isFirstLine(isFirstLine) 74 81 { 75 82 ASSERT(block); 83 #if ENABLE(CSS_EXCLUSIONS) 84 WrapShapeInfo* wrapShapeInfo = m_block->wrapShapeInfo(); 85 // FIXME: Bug 91878: Add support for multiple segments, currently we only support one 86 if (wrapShapeInfo && wrapShapeInfo->lineState() == WrapShapeInfo::LINE_INSIDE_SHAPE) { 87 // All interior shape positions should have at least one segment 88 ASSERT(wrapShapeInfo->hasSegments()); 89 m_segment = &wrapShapeInfo->segments()[0]; 90 } 91 #endif 76 92 updateAvailableWidth(); 77 93 } … … 115 131 float m_right; 116 132 float m_availableWidth; 133 #if ENABLE(CSS_EXCLUSIONS) 134 const LineSegment* m_segment; 135 #endif 117 136 bool m_isFirstLine; 118 137 }; … … 138 157 m_left = m_block->logicalLeftOffsetForLine(height, m_isFirstLine, logicalHeight); 139 158 m_right = m_block->logicalRightOffsetForLine(height, m_isFirstLine, logicalHeight); 159 160 #if ENABLE(CSS_EXCLUSIONS) 161 if (m_segment) { 162 m_left = max<float>(m_segment->logicalLeft, m_left); 163 m_right = min<float>(m_segment->logicalRight, m_right); 164 } 165 #endif 140 166 141 167 computeAvailableWidthFromLeftAndRight(); … … 778 804 bool firstLine = lineInfo.isFirstLine() && !(isAnonymousBlock() && parent()->firstChild() != this); 779 805 float logicalLeft = pixelSnappedLogicalLeftOffsetForLine(logicalHeight(), firstLine, lineLogicalHeight); 780 float availableLogicalWidth = pixelSnappedLogicalRightOffsetForLine(logicalHeight(), firstLine, lineLogicalHeight) - logicalLeft; 806 float logicalRight = pixelSnappedLogicalRightOffsetForLine(logicalHeight(), firstLine, lineLogicalHeight); 807 #if ENABLE(CSS_EXCLUSIONS) 808 WrapShapeInfo* wrapShapeInfo = this->wrapShapeInfo(); 809 if (wrapShapeInfo && wrapShapeInfo->lineState() == WrapShapeInfo::LINE_INSIDE_SHAPE) { 810 logicalLeft = max<float>(roundToInt(wrapShapeInfo->segments()[0].logicalLeft), logicalLeft); 811 logicalRight = min<float>(floorToInt(wrapShapeInfo->segments()[0].logicalRight), logicalRight); 812 } 813 #endif 814 float availableLogicalWidth = logicalRight - logicalLeft; 781 815 782 816 bool needsWordSpacing = false; … … 1253 1287 LineBreaker lineBreaker(this); 1254 1288 1289 #if ENABLE(CSS_EXCLUSIONS) 1290 WrapShapeInfo* wrapShapeInfo = this->wrapShapeInfo(); 1291 // Move to the top of the shape inside to begin layout 1292 if (wrapShapeInfo && logicalHeight() < wrapShapeInfo->shapeTop()) 1293 setLogicalHeight(wrapShapeInfo->shapeTop()); 1294 #endif 1295 1255 1296 while (!end.atEnd()) { 1256 1297 // FIXME: Is this check necessary before the first iteration or can it be moved to the end? … … 1271 1312 bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly(); 1272 1313 FloatingObject* lastFloatFromPreviousLine = (m_floatingObjects && !m_floatingObjects->set().isEmpty()) ? m_floatingObjects->set().last() : 0; 1314 #if ENABLE(CSS_EXCLUSIONS) 1315 // FIXME: Bug 89993: If the wrap shape comes from a parent, we will need to adjust 1316 // the height coordinate 1317 if (wrapShapeInfo) 1318 wrapShapeInfo->computeSegmentsForLine(logicalHeight()); 1319 #endif 1273 1320 end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), lineBreakIteratorInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines); 1274 1321 if (resolver.position().atEnd()) { -
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r126438 r126605 454 454 // If regions change, trigger a relayout to re-calc regions. 455 455 if (rareNonInheritedData->m_dashboardRegions != other->rareNonInheritedData->m_dashboardRegions) 456 return StyleDifferenceLayout; 457 #endif 458 459 #if ENABLE(CSS_EXCLUSIONS) 460 if (rareNonInheritedData->m_wrapShapeInside != other->rareNonInheritedData->m_wrapShapeInside) 456 461 return StyleDifferenceLayout; 457 462 #endif … … 674 679 // to avoid having diff() == StyleDifferenceEqual where wrap-shapes actually differ. 675 680 // Tracking bug: https://bugs.webkit.org/show_bug.cgi?id=62991 676 if (rareNonInheritedData->m_wrapShapeInside != other->rareNonInheritedData->m_wrapShapeInside 677 || rareNonInheritedData->m_wrapShapeOutside != other->rareNonInheritedData->m_wrapShapeOutside) 681 if (rareNonInheritedData->m_wrapShapeOutside != other->rareNonInheritedData->m_wrapShapeOutside) 678 682 return StyleDifferenceRepaint; 679 683
Note: See TracChangeset
for help on using the changeset viewer.