Changeset 156022 in webkit
- Timestamp:
- Sep 17, 2013 8:27:35 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r156019 r156022 1 2013-09-17 Zoltan Horvath <zoltan@webkit.org> 2 3 [CSS Shapes] Use the float height to determine position in shape-inside 4 https://bugs.webkit.org/show_bug.cgi?id=102846 5 6 Reviewed by Darin Adler. 7 8 Float positioning inside shape-inside has been working only for simple cases when the float boundaries didn't overlap with the shape. 9 This patch fixes the behavior for left floats and shapes with inline content. I want to add this work step by step, therefore the next 10 step would be to add support for block content with inline content (e.g. paragraphs) then cover cases with right floats. 11 12 * fast/shapes/shape-inside/shape-inside-left-float-in-lower-left-triangle-inline-content-expected.html: Added. 13 * fast/shapes/shape-inside/shape-inside-left-float-in-lower-left-triangle-inline-content.html: Added. 14 * fast/shapes/shape-inside/shape-inside-left-float-in-lower-right-triangle-inline-content-expected.html: Added. 15 * fast/shapes/shape-inside/shape-inside-left-float-in-lower-right-triangle-inline-content.html: Added. 16 * fast/shapes/shape-inside/shape-inside-left-float-in-upper-left-triangle-inline-content-expected.html: Added. 17 * fast/shapes/shape-inside/shape-inside-left-float-in-upper-left-triangle-inline-content.html: Added. 18 * fast/shapes/shape-inside/shape-inside-left-float-in-upper-right-triangle-inline-content-expected.html: Added. 19 * fast/shapes/shape-inside/shape-inside-left-float-in-upper-right-triangle-inline-content.html: Added. 20 1 21 2013-09-17 Filip Pizlo <fpizlo@apple.com> 2 22 -
trunk/Source/WebCore/ChangeLog
r156015 r156022 1 2013-09-17 Zoltan Horvath <zoltan@webkit.org> 2 3 [CSS Shapes] Use the float height to determine position in shape-inside 4 https://bugs.webkit.org/show_bug.cgi?id=102846 5 6 Reviewed by Darin Adler. 7 8 Float positioning inside shape-inside has been working only for simple cases when the float boundaries didn't overlap with the shape. 9 This patch fixes the behavior for left floats and shapes with inline content. I want to add this work step by step, therefore the next 10 step would be to add support for block content with inline content (e.g. paragraphs) then cover cases with right floats. 11 12 Tests: fast/shapes/shape-inside/shape-inside-left-float-in-lower-left-triangle-inline-content.html 13 fast/shapes/shape-inside/shape-inside-left-float-in-lower-right-triangle-inline-content.html 14 fast/shapes/shape-inside/shape-inside-left-float-in-upper-left-triangle-inline-content.html 15 fast/shapes/shape-inside/shape-inside-left-float-in-upper-right-triangle-inline-content.html 16 17 * rendering/LineWidth.cpp: 18 (WebCore::LineWidth::LineWidth): Use the new updateCurrentShapeSegment member function. 19 (WebCore::LineWidth::updateCurrentShapeSegment): We need a function to update the current line segment's reference, since we use it multiple places. 20 * rendering/LineWidth.h: Add new member function. 21 * rendering/RenderBlock.cpp: 22 (WebCore::RenderBlock::computeLogicalLocationForFloat): Fix positioning of a floating element. 23 * rendering/RenderBlockLineLayout.cpp: 24 (WebCore::RenderBlock::updateShapeAndSegmentsForCurrentLine): Use updateSegmentsForLine instead of computeSegmentsForLine. 25 (WebCore::RenderBlock::updateShapeAndSegmentsForCurrentLineInFlowThread): Use updateSegmentsForLine instead of computeSegmentsForLine. 26 (WebCore::RenderBlock::adjustLogicalLineTopAndLogicalHeightIfNeeded): 27 (WebCore::updateSegmentsForShapes): After our float is positioned, we need to adjust the current lineTop and update the logical height to be able to wrap around the float. 28 (WebCore::RenderBlock::LineBreaker::nextSegmentBreak): If we have a float in our line we might need to adjust our lineTop and logicalHeight. 29 * rendering/shapes/ShapeInfo.cpp: 30 (WebCore::::computeSegmentsForLine): Add new const function to compute the segments. I'd like make this function static later if possible. 31 (WebCore::::updateSegmentsForLine): Old computeSegmentsForLine, change name to indicate that it is actually changing things. 32 * rendering/shapes/ShapeInfo.h: Update function names, add declaration. 33 (WebCore::ShapeInfo::clearSegments): 34 (WebCore::ShapeInfo::logicalLineBottom): 35 (WebCore::ShapeInfo::lineOverlapsShapeBounds): 36 * rendering/shapes/ShapeInsideInfo.cpp: 37 (WebCore::ShapeInsideInfo::computeFirstFitPositionForFloat): Compute the first fit position below the current line position inside shapes. I called this function 38 this way, because currently we use it only for shapes. 39 * rendering/shapes/ShapeInsideInfo.h: Update function names. 40 * rendering/shapes/ShapeOutsideInfo.cpp: Update function names. 41 (WebCore::ShapeOutsideInfo::computeSegmentsForContainingBlockLine): 42 (WebCore::ShapeOutsideInfo::updateSegmentsForLine): 43 * rendering/shapes/ShapeOutsideInfo.h: Update function names. 44 1 45 2013-09-17 Sam Weinig <sam@webkit.org> 2 46 -
trunk/Source/WebCore/rendering/LineWidth.cpp
r155569 r156022 50 50 { 51 51 #if ENABLE(CSS_SHAPES) 52 if (ShapeInsideInfo* shapeInsideInfo = m_block.layoutShapeInsideInfo()) 53 m_segment = shapeInsideInfo->currentSegment(); 52 updateCurrentShapeSegment(); 54 53 #endif 55 54 updateAvailableWidth(); … … 205 204 } 206 205 206 #if ENABLE(CSS_SHAPES) 207 void LineWidth::updateCurrentShapeSegment() 208 { 209 if (ShapeInsideInfo* shapeInsideInfo = m_block.layoutShapeInsideInfo()) 210 m_segment = shapeInsideInfo->currentSegment(); 211 } 212 #endif 213 207 214 void LineWidth::computeAvailableWidthFromLeftAndRight() 208 215 { -
trunk/Source/WebCore/rendering/LineWidth.h
r155565 r156022 71 71 void setTrailingWhitespaceWidth(float collapsedWhitespace, float borderPaddingMargin = 0); 72 72 73 #if ENABLE(CSS_SHAPES) 74 void updateCurrentShapeSegment(); 75 #endif 76 73 77 bool shouldIndentText() const { return m_shouldIndentText == IndentText; } 74 78 -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r155975 r156022 3354 3354 // FIXME Bug 102948: This only works for shape outside directly set on this block. 3355 3355 ShapeInsideInfo* shapeInsideInfo = this->shapeInsideInfo(); 3356 // FIXME Bug 102846: Take into account the height of the content. The offset should be 3357 // equal to the maximum segment length. 3358 if (shapeInsideInfo && shapeInsideInfo->hasSegments() && shapeInsideInfo->segments().size() == 1) { 3359 // FIXME Bug 102949: Add support for shapes with multipe segments. 3360 3361 // The segment offsets are relative to the content box. 3362 logicalRightOffset = logicalLeftOffset + shapeInsideInfo->segments()[0].logicalRight; 3363 logicalLeftOffset += shapeInsideInfo->segments()[0].logicalLeft; 3356 // FIXME: Implement behavior for right floats. 3357 if (shapeInsideInfo) { 3358 // FIXME: If the float doesn't fit in the shape we should push it under the content box 3359 logicalTopOffset = shapeInsideInfo->computeFirstFitPositionForFloat(LayoutSize(floatingObject->width(), floatingObject->height())); 3360 if (logicalHeight() > logicalTopOffset) 3361 logicalTopOffset = logicalHeight(); 3362 3363 SegmentList segments = shapeInsideInfo->computeSegmentsForLine(logicalTopOffset, childBox->logicalHeight()); 3364 // FIXME Bug 102949: Add support for shapes with multiple segments. 3365 if (segments.size() == 1) { 3366 // The segment offsets are relative to the content box. 3367 logicalRightOffset = logicalLeftOffset + segments[0].logicalRight; 3368 logicalLeftOffset += segments[0].logicalLeft; 3369 } 3364 3370 } else 3365 3371 #endif -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r155975 r156022 1355 1355 1356 1356 // FIXME: Bug 95361: It is possible for a line to grow beyond lineHeight, in which case these segments may be incorrect. 1357 shapeInsideInfo-> computeSegmentsForLine(LayoutSize(lineLeft, lineTop), lineHeight);1357 shapeInsideInfo->updateSegmentsForLine(LayoutSize(lineLeft, lineTop), lineHeight); 1358 1358 1359 1359 pushShapeContentOverflowBelowTheContentBox(this, shapeInsideInfo, lineTop, lineHeight); … … 1428 1428 1429 1429 // FIXME: 118571 - Shape inside on a region does not yet take into account its padding for nested flow blocks 1430 shapeInsideInfo-> computeSegmentsForLine(LayoutSize(0, lineTop), lineHeight);1430 shapeInsideInfo->updateSegmentsForLine(LayoutSize(0, lineTop), lineHeight); 1431 1431 1432 1432 if (currentRegion->isLastRegion()) … … 1446 1446 newLogicalHeight = logicalHeight(); 1447 1447 } 1448 1449 1448 1450 1449 end = restartLayoutRunsAndFloatsInRange(logicalHeight(), newLogicalHeight, lastFloatFromPreviousLine, resolver, end); … … 2587 2586 return canBreakHere; 2588 2587 } 2588 2589 #if ENABLE(CSS_SHAPES) 2590 static void updateSegmentsForShapes(RenderBlock* block, const FloatingObject* lastFloatFromPreviousLine, const WordMeasurements& wordMeasurements, LineWidth& width, bool isFirstLine) 2591 { 2592 ASSERT(lastFloatFromPreviousLine); 2593 2594 ShapeInsideInfo* shapeInsideInfo = block->layoutShapeInsideInfo(); 2595 LayoutUnit lineLogicalHeight = logicalHeightForLine(block, isFirstLine); 2596 LayoutUnit lineLogicalBottom = block->logicalHeight() + lineLogicalHeight; 2597 bool lineOverlapsWithFloat = (lastFloatFromPreviousLine->y() < lineLogicalBottom) && (block->logicalHeight() < lastFloatFromPreviousLine->maxY()); 2598 2599 if (!shapeInsideInfo || !lineOverlapsWithFloat) 2600 return; 2601 2602 float minWidth = firstPositiveWidth(wordMeasurements); 2603 2604 LayoutUnit availableWidth = block->width() - lastFloatFromPreviousLine->maxX(); 2605 if (availableWidth < minWidth) 2606 block->setLogicalHeight(lastFloatFromPreviousLine->maxY()); 2607 2608 if (block->logicalHeight() < lastFloatFromPreviousLine->y()) { 2609 shapeInsideInfo->adjustLogicalLineTop(minWidth + lastFloatFromPreviousLine->width()); 2610 block->setLogicalHeight(shapeInsideInfo->logicalLineTop()); 2611 } 2612 2613 shapeInsideInfo->updateSegmentsForLine(block->logicalHeight(), lineLogicalHeight); 2614 width.updateCurrentShapeSegment(); 2615 width.updateAvailableWidth(); 2616 } 2617 #endif 2589 2618 2590 2619 InlineIterator RenderBlock::LineBreaker::nextSegmentBreak(InlineBidiResolver& resolver, LineInfo& lineInfo, RenderTextInfo& renderTextInfo, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements& wordMeasurements) … … 2926 2955 wordMeasurement.endOffset = current.m_pos; 2927 2956 wordMeasurement.startOffset = lastSpace; 2928 2957 2929 2958 float additionalTempWidth; 2930 2959 if (wordTrailingSpaceWidth && c == ' ') … … 2949 2978 } 2950 2979 2980 #if ENABLE(CSS_SHAPES) 2981 if (lastFloatFromPreviousLine) 2982 updateSegmentsForShapes(m_block, lastFloatFromPreviousLine, wordMeasurements, width, lineInfo.isFirstLine()); 2983 #endif 2951 2984 applyWordSpacing = wordSpacing && currentCharacterIsSpace; 2952 2985 -
trunk/Source/WebCore/rendering/shapes/ShapeInfo.cpp
r155627 r156022 70 70 71 71 template<class RenderType> 72 bool ShapeInfo<RenderType>::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) 72 SegmentList ShapeInfo<RenderType>::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) const 73 { 74 ASSERT(lineHeight >= 0); 75 SegmentList segments; 76 77 getIntervals((lineTop - logicalTopOffset()), std::min(lineHeight, shapeLogicalBottom() - lineTop), segments); 78 79 for (size_t i = 0; i < segments.size(); i++) { 80 segments[i].logicalLeft += logicalLeftOffset(); 81 segments[i].logicalRight += logicalLeftOffset(); 82 } 83 84 return segments; 85 } 86 87 template<class RenderType> 88 bool ShapeInfo<RenderType>::updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) 73 89 { 74 90 ASSERT(lineHeight >= 0); … … 78 94 79 95 if (lineOverlapsShapeBounds()) 80 getIntervals(m_shapeLineTop, std::min(m_lineHeight, shapeLogicalBottom() - lineTop), m_segments); 81 82 LayoutUnit logicalLeftOffset = this->logicalLeftOffset(); 83 for (size_t i = 0; i < m_segments.size(); i++) { 84 m_segments[i].logicalLeft += logicalLeftOffset; 85 m_segments[i].logicalRight += logicalLeftOffset; 86 } 96 m_segments = computeSegmentsForLine(lineTop, lineHeight); 87 97 88 98 return m_segments.size(); -
trunk/Source/WebCore/rendering/shapes/ShapeInfo.h
r155655 r156022 84 84 } 85 85 86 virtual bool computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight); 86 SegmentList computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) const; 87 virtual bool updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight); 87 88 void clearSegments() { m_segments.clear(); } 88 89 … … 96 97 LayoutUnit logicalLineTop() const { return m_shapeLineTop + logicalTopOffset(); } 97 98 LayoutUnit logicalLineBottom() const { return m_shapeLineTop + m_lineHeight + logicalTopOffset(); } 99 LayoutUnit logicalLineBottom(LayoutUnit lineHeight) const { return m_shapeLineTop + lineHeight + logicalTopOffset(); } 98 100 99 101 LayoutUnit shapeContainingBlockLogicalHeight() const { return (m_renderer->style()->boxSizing() == CONTENT_BOX) ? (m_shapeLogicalSize.height() + m_renderer->borderAndPaddingLogicalHeight()) : m_shapeLogicalSize.height(); } 100 102 101 103 bool lineOverlapsShapeBounds() const { return logicalLineTop() < shapeLogicalBottom() && shapeLogicalTop() <= logicalLineBottom(); } 104 bool lineOverlapsShapeBounds(LayoutUnit lineHeight) const { return logicalLineTop() < shapeLogicalBottom() && shapeLogicalTop() <= logicalLineBottom(lineHeight); } 102 105 103 106 void dirtyShapeSize() { m_shape.clear(); } -
trunk/Source/WebCore/rendering/shapes/ShapeInsideInfo.cpp
r155627 r156022 82 82 } 83 83 84 LayoutUnit ShapeInsideInfo::computeFirstFitPositionForFloat(const LayoutSize floatSize) const 85 { 86 if (!computedShape() || !floatSize.width() || shapeLogicalBottom() < logicalLineTop()) 87 return 0; 88 89 LayoutUnit firstFitPosition = 0; 90 if (computedShape()->firstIncludedIntervalLogicalTop(m_shapeLineTop, floatSize, firstFitPosition) && (m_shapeLineTop <= firstFitPosition)) 91 return firstFitPosition; 92 93 return 0; 94 } 95 84 96 } 85 97 #endif -
trunk/Source/WebCore/rendering/shapes/ShapeInsideInfo.h
r155627 r156022 69 69 static bool isEnabledFor(const RenderBlock* renderer); 70 70 71 bool computeSegmentsForLine(LayoutSize lineOffset, LayoutUnit lineHeight)71 bool updateSegmentsForLine(LayoutSize lineOffset, LayoutUnit lineHeight) 72 72 { 73 73 m_segmentRanges.clear(); 74 bool result = ShapeInfo<RenderBlock>:: computeSegmentsForLine(lineOffset.height(), lineHeight);74 bool result = ShapeInfo<RenderBlock>::updateSegmentsForLine(lineOffset.height(), lineHeight); 75 75 for (size_t i = 0; i < m_segments.size(); i++) { 76 76 m_segments[i].logicalLeft -= lineOffset.width(); … … 80 80 } 81 81 82 virtual bool computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) OVERRIDE82 virtual bool updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) OVERRIDE 83 83 { 84 84 m_segmentRanges.clear(); 85 return ShapeInfo<RenderBlock>:: computeSegmentsForLine(lineTop, lineHeight);85 return ShapeInfo<RenderBlock>::updateSegmentsForLine(lineTop, lineHeight); 86 86 } 87 87 … … 105 105 } 106 106 bool adjustLogicalLineTop(float minSegmentWidth); 107 LayoutUnit computeFirstFitPositionForFloat(const LayoutSize) const; 107 108 108 109 void setNeedsLayout(bool value) { m_needsLayout = value; } -
trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp
r155627 r156022 56 56 { 57 57 LayoutUnit lineTopInShapeCoordinates = lineTop - floatTop + logicalTopOffset(); 58 return computeSegmentsForLine(lineTopInShapeCoordinates, lineHeight);58 return updateSegmentsForLine(lineTopInShapeCoordinates, lineHeight); 59 59 } 60 60 61 bool ShapeOutsideInfo:: computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight)61 bool ShapeOutsideInfo::updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) 62 62 { 63 63 if (shapeSizeDirty() || m_lineTop != lineTop || m_lineHeight != lineHeight) { 64 if (ShapeInfo<RenderBox>:: computeSegmentsForLine(lineTop, lineHeight)) {64 if (ShapeInfo<RenderBox>::updateSegmentsForLine(lineTop, lineHeight)) { 65 65 m_leftSegmentMarginBoxDelta = m_segments[0].logicalLeft + m_renderer->marginStart(); 66 66 m_rightSegmentMarginBoxDelta = m_segments[m_segments.size()-1].logicalRight - m_renderer->logicalWidth() - m_renderer->marginEnd(); -
trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.h
r155627 r156022 46 46 47 47 bool computeSegmentsForContainingBlockLine(LayoutUnit lineTop, LayoutUnit floatTop, LayoutUnit lineHeight); 48 virtual bool computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) OVERRIDE;48 virtual bool updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) OVERRIDE; 49 49 50 50 static PassOwnPtr<ShapeOutsideInfo> createInfo(const RenderBox* renderer) { return adoptPtr(new ShapeOutsideInfo(renderer)); }
Note: See TracChangeset
for help on using the changeset viewer.