Changeset 148781 in webkit
- Timestamp:
- Apr 19, 2013 4:28:26 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r148774 r148781 1 2013-04-19 Bear Travis <betravis@adobe.com> 2 3 [CSS Exclusions] Implement empty segments for multiple-segment shape-insides 4 https://bugs.webkit.org/show_bug.cgi?id=100049 5 6 Reviewed by David Hyatt. 7 8 Testing that shape-insides do not place content where it will not fit. Also 9 fixing up some previous tests and expectations. 10 11 * fast/exclusions/resources/multi-segment-polygon.js: 12 (simulateWithText): Enable multi-line shape expectations using arrays. 13 * fast/exclusions/resources/simple-rectangle.js: 14 (createRectangleTest): Add overflow: break-word property to tests. 15 (createRectangleTestResult): Ditto. 16 * fast/exclusions/shape-inside/shape-inside-empty-expected.html: Adjust results 17 for tests where content should be pushed down. 18 * fast/exclusions/shape-inside/shape-inside-empty-segments-expected.html: Added. 19 * fast/exclusions/shape-inside/shape-inside-empty-segments.html: Added. 20 * fast/exclusions/shape-inside/shape-inside-empty.html: Shapes with height but 21 no width should still push content down below the shape. 22 1 23 2013-04-19 Jessie Berlin <jberlin@apple.com> 2 24 -
trunk/LayoutTests/fast/exclusions/resources/multi-segment-polygon.js
r136729 r148781 22 22 div.style.setProperty('font', fontSize + 'px/1 Ahem, sans-serif'); 23 23 div.style.setProperty('color', 'green'); 24 if (content instanceof Array) { 25 div.style.setProperty('white-space', 'pre'); 26 content = content.join('\n'); 27 } 24 28 div.innerHTML = content; 25 29 } -
trunk/LayoutTests/fast/exclusions/resources/simple-rectangle.js
r138040 r148781 19 19 rules.push('-webkit-shape-inside: rectangle(' + rectangleBounds.join(',') + ')'); 20 20 rules.push('position: relative'); 21 rules.push('overflow-wrap: break-word'); 21 22 stylesheet.insertRule('#' + elementId + '{' + rules.join(';') + '}'); 22 23 … … 46 47 rules.push('padding-top: ' + shapeBounds.y + units, 'padding-bottom: ' + (bounds.height - shapeBounds.height - shapeBounds.y) + units); 47 48 rules.push('position: relative'); 49 rules.push('overflow-wrap: break-word'); 48 50 stylesheet.insertRule('#' + elementId + '{' + rules.join(';') + '}'); 49 51 -
trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-empty-expected.html
r131766 r148781 11 11 height: 2em; 12 12 border: solid green; 13 box-sizing: border-box; 14 } 15 .padded { 16 padding-top: 1em; 13 17 } 14 18 </style> 15 19 </head> 16 20 <body> 17 <p class="shape-inside ">18 This text should be unconstrained by the rectangle(0px, 0px, 0px, 100px) shape-inside CSS property.21 <p class="shape-inside padded"> 22 This text should be shifted down 1em by the rectangle(0px, 0px, 0px, 1em) shape-inside CSS property. 19 23 </p> 20 24 <p class="shape-inside"> 21 This text should be unconstrained by the rectangle(0px, 0px, 1 00px, 0px) shape-inside CSS property.25 This text should be unconstrained by the rectangle(0px, 0px, 1em, 0px) shape-inside CSS property. 22 26 </p> 23 27 <p class="shape-inside"> 24 28 This text should be unconstrained by the circle(0px, 0px, 0px) shape-inside CSS property. 25 29 </p> 26 <p class="shape-inside ">27 This text should be unconstrained by the ellipseX0(0px, 0px, 0px, 100px) shape-inside CSS property.30 <p class="shape-inside padded"> 31 This text should be shifted down 1em by the ellipseX0(0px, 0px, 0px, 1em) shape-inside CSS property. 28 32 </p> 29 33 <p class="shape-inside"> 30 This text should be unconstrained by the ellipse(0px, 0px, 100px, 0px) shape-inside CSS property. 31 </p> 32 <p class="shape-inside"> 33 This text should be unconstrained by the polygon() shape-inside CSS property. 34 This text should be unconstrained by the ellipse(0px, 0px, 1em, 0px) shape-inside CSS property. 34 35 </p> 35 36 <p class="shape-inside"> … … 37 38 </p> 38 39 <p class="shape-inside"> 39 This text should be unconstrained by the polygon(0px 0px, 1 0px0px) shape-inside CSS property.40 This text should be unconstrained by the polygon(0px 0px, 1em 0px) shape-inside CSS property. 40 41 </p> 41 42 </body> -
trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-empty.html
r131766 r148781 11 11 height: 2em; 12 12 border: solid green; 13 box-sizing: border-box; 13 14 } 14 15 15 16 #shape-inside-rectangle-width0 { 16 -webkit-shape-inside: rectangle(0px, 0px, 0px, 100px); 17 -webkit-shape-inside: rectangle(0px, 0px, 0px, 1em); 18 padding-top: 1em; 17 19 } 18 20 19 21 #shape-inside-rectangle-height0 { 20 -webkit-shape-inside: rectangle(0px, 0px, 1 00px, 0px);22 -webkit-shape-inside: rectangle(0px, 0px, 1em, 0px); 21 23 } 22 24 … … 26 28 27 29 #shape-inside-ellipse-radiusX0 { 28 -webkit-shape-inside: ellipse(0px, 0px, 0px, 100px); 30 -webkit-shape-inside: ellipse(0px, 0px, 0px, 1em); 31 padding-top: 1em; 29 32 } 30 33 31 34 #shape-inside-ellipse-radiusY0 { 32 -webkit-shape-inside: ellipse(0px, 0px, 100px, 0px); 33 } 34 35 #shape-inside-polygon-0vertices { 36 -webkit-shape-inside: polygon(); 35 -webkit-shape-inside: ellipse(0px, 0px, 1em, 0px); 37 36 } 38 37 … … 42 41 43 42 #shape-inside-polygon-2vertices { 44 -webkit-shape-inside: polygon(0px 0px, 1 0px0px);43 -webkit-shape-inside: polygon(0px 0px, 1em 0px); 45 44 } 46 45 </style> … … 48 47 <body> 49 48 <p class="shape-inside" id="shape-inside-rectangle-width0"> 50 This text should be unconstrained by the rectangle(0px, 0px, 0px, 100px) shape-inside CSS property.49 This text should be shifted down 1em by the rectangle(0px, 0px, 0px, 1em) shape-inside CSS property. 51 50 </p> 52 51 <p class="shape-inside" id="shape-inside-rectangle-height0"> 53 This text should be unconstrained by the rectangle(0px, 0px, 1 00px, 0px) shape-inside CSS property.52 This text should be unconstrained by the rectangle(0px, 0px, 1em, 0px) shape-inside CSS property. 54 53 </p> 55 54 <p class="shape-inside" id="shape-inside-circle-radius0"> … … 57 56 </p> 58 57 <p class="shape-inside" id="shape-inside-ellipse-radiusX0"> 59 This text should be unconstrained by the ellipseX0(0px, 0px, 0px, 100px) shape-inside CSS property.58 This text should be shifted down 1em by the ellipseX0(0px, 0px, 0px, 1em) shape-inside CSS property. 60 59 </p> 61 60 <p class="shape-inside" id="shape-inside-ellipse-radiusY0"> 62 This text should be unconstrained by the ellipse(0px, 0px, 100px, 0px) shape-inside CSS property. 63 </p> 64 <p class="shape-inside" id="shape-inside-polygon-0vertices"> 65 This text should be unconstrained by the polygon() shape-inside CSS property. 61 This text should be unconstrained by the ellipse(0px, 0px, 1em, 0px) shape-inside CSS property. 66 62 </p> 67 63 <p class="shape-inside" id="shape-inside-polygon-1vertex"> … … 69 65 </p> 70 66 <p class="shape-inside" id="shape-inside-polygon-2vertices"> 71 This text should be unconstrained by the polygon(0px 0px, 1 0px0px) shape-inside CSS property.67 This text should be unconstrained by the polygon(0px 0px, 1em 0px) shape-inside CSS property. 72 68 </p> 73 69 </body> -
trunk/Source/WebCore/ChangeLog
r148777 r148781 1 2013-04-19 Bear Travis <betravis@adobe.com> 2 3 [CSS Exclusions] Implement empty segments for multiple-segment shape-insides 4 https://bugs.webkit.org/show_bug.cgi?id=100049 5 6 Reviewed by David Hyatt. 7 8 Content should not overflow a shape-inside segment, even if that means no content 9 will be placed in that segment. Overflow may be pushed to outside the shape. This 10 patch removes the restriction that every line must consume at least some text 11 input while inside a shape-inside. Content that does not fit is pushed down until 12 it does, either inside the shape or just below it. 13 14 Test: fast/exclusions/shape-inside/shape-inside-empty-segments.html 15 16 * rendering/RenderBlockLineLayout.cpp: 17 (WebCore::constructBidiRunsForSegment): Do not include empty segments for 18 consideration, as the actual BidiRuns construction expects to consume at 19 least one character. 20 (WebCore::constructBidiRunsForLine): Ditto. 21 (WebCore::firstPositiveWidth): Find the first positive word measurement width, 22 as there may be some empty word break measurements inserted. 23 (WebCore::adjustLogicalLineTop): Move the current line down, if necessary, to 24 fit it within the shape inside. 25 (WebCore::RenderBlock::layoutRunsAndFloatsInRange): If nothing fit in the 26 current segment, find the first available position for the smallest item 27 at the beginning of the text. 28 (WebCore::RenderBlock::LineBreaker::nextLineBreak): Return an empty segment 29 for a line that is inside the shape, but has no segments. 30 (WebCore::RenderBlock::LineBreaker::nextSegmentBreak): Do not consume 31 input to meet minimum size requirements if you are inside a shape. 32 1 33 2013-04-19 Ryosuke Niwa <rniwa@webkit.org> 2 34 -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r148658 r148781 1297 1297 // of the resolver owning the runs. 1298 1298 ASSERT(&topResolver.runs() == &bidiRuns); 1299 ASSERT(topResolver.position() != endOfRuns); 1299 1300 RenderObject* currentRoot = topResolver.position().root(); 1300 1301 topResolver.createBidiRunsForLine(endOfRuns, override, previousLineBrokeCleanly); … … 1383 1384 topResolver.midpointState().betweenMidpoints = false; 1384 1385 } 1386 if (segmentStart == segmentEnd) 1387 continue; 1385 1388 topResolver.setPosition(segmentStart, numberOfIsolateAncestors(segmentStart)); 1386 1389 constructBidiRunsForSegment(topResolver, bidiRuns, segmentEnd, override, previousLineBrokeCleanly); … … 1621 1624 } 1622 1625 1626 #if ENABLE(CSS_EXCLUSIONS) 1627 static inline float firstPositiveWidth(const WordMeasurements& wordMeasurements) 1628 { 1629 for (size_t i = 0; i < wordMeasurements.size(); ++i) { 1630 if (wordMeasurements[i].width > 0) 1631 return wordMeasurements[i].width; 1632 } 1633 return 0; 1634 } 1635 1636 static inline LayoutUnit adjustLogicalLineTop(ExclusionShapeInsideInfo* exclusionShapeInsideInfo, InlineIterator start, InlineIterator end, const WordMeasurements& wordMeasurements) 1637 { 1638 if (!exclusionShapeInsideInfo || end != start) 1639 return 0; 1640 1641 float minWidth = firstPositiveWidth(wordMeasurements); 1642 ASSERT(minWidth || wordMeasurements.isEmpty()); 1643 if (minWidth > 0 && exclusionShapeInsideInfo->adjustLogicalLineTop(minWidth)) 1644 return exclusionShapeInsideInfo->logicalLineTop(); 1645 1646 return exclusionShapeInsideInfo->shapeLogicalBottom(); 1647 } 1648 #endif 1649 1623 1650 void RenderBlock::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, InlineBidiResolver& resolver, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus, unsigned consecutiveHyphenatedLines) 1624 1651 { … … 1695 1722 break; 1696 1723 } 1724 1725 #if ENABLE(CSS_EXCLUSIONS) 1726 if (LayoutUnit adjustedLogicalLineTop = adjustLogicalLineTop(exclusionShapeInsideInfo, resolver.position(), end, wordMeasurements)) { 1727 end = restartLayoutRunsAndFloatsInRange(logicalHeight(), adjustedLogicalLineTop - absoluteLogicalTop, lastFloatFromPreviousLine, resolver, oldEnd); 1728 continue; 1729 } 1730 #endif 1731 1697 1732 ASSERT(end != resolver.position()); 1698 1699 #if ENABLE(CSS_EXCLUSIONS)1700 if (exclusionShapeInsideInfo && wordMeasurements.size() && exclusionShapeInsideInfo->adjustLogicalLineTop(wordMeasurements[0].width)) {1701 end = restartLayoutRunsAndFloatsInRange(logicalHeight(), exclusionShapeInsideInfo->logicalLineTop() - absoluteLogicalTop, lastFloatFromPreviousLine, resolver, oldEnd);1702 continue;1703 }1704 #endif1705 1733 1706 1734 // This is a short-cut for empty lines. … … 2653 2681 #else 2654 2682 ExclusionShapeInsideInfo* exclusionShapeInsideInfo = m_block->layoutExclusionShapeInsideInfo(); 2655 if (!exclusionShapeInsideInfo || !exclusionShapeInsideInfo-> hasSegments())2683 if (!exclusionShapeInsideInfo || !exclusionShapeInsideInfo->lineOverlapsShapeBounds()) 2656 2684 return nextSegmentBreak(resolver, lineInfo, renderTextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurements); 2657 2685 2658 2686 InlineIterator end = resolver.position(); 2659 2687 InlineIterator oldEnd = end; 2688 2689 if (!exclusionShapeInsideInfo->hasSegments()) { 2690 end = nextSegmentBreak(resolver, lineInfo, renderTextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurements); 2691 resolver.setPositionIgnoringNestedIsolates(oldEnd); 2692 return oldEnd; 2693 } 2660 2694 2661 2695 const SegmentList& segments = exclusionShapeInsideInfo->segments(); … … 2673 2707 if (resolver.position() == end) { 2674 2708 // Nothing fit this segment 2709 end = segmentStart; 2675 2710 segmentRanges.append(LineSegmentRange(segmentStart, segmentStart)); 2676 2711 resolver.setPositionIgnoringNestedIsolates(segmentStart); … … 3296 3331 3297 3332 end: 3298 if (lBreak == resolver.position() && (!lBreak.m_obj || !lBreak.m_obj->isBR())) { 3333 #if ENABLE(CSS_EXCLUSIONS) 3334 ExclusionShapeInsideInfo* shapeInfo = m_block->layoutExclusionShapeInsideInfo(); 3335 bool segmentAllowsOverflow = !shapeInfo || !shapeInfo->hasSegments(); 3336 #else 3337 bool segmentAllowsOverflow = true; 3338 #endif 3339 3340 if (lBreak == resolver.position() && (!lBreak.m_obj || !lBreak.m_obj->isBR()) && segmentAllowsOverflow) { 3299 3341 // we just add as much as possible 3300 3342 if (blockStyle->whiteSpace() == PRE && !current.m_pos) { … … 3308 3350 } 3309 3351 3310 // FIXME Bug 100049: We do not need to consume input in a multi-segment line3311 // unless no segment will.3312 3352 // make sure we consume at least one char/object. 3313 if (lBreak == resolver.position() )3353 if (lBreak == resolver.position() && segmentAllowsOverflow) 3314 3354 lBreak.increment(); 3315 3355
Note: See TracChangeset
for help on using the changeset viewer.