Changeset 147513 in webkit
- Timestamp:
- Apr 2, 2013 6:32:24 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r147510 r147513 1 2013-04-02 Jaehun Lim <ljaehun.lim@samsung.com> 2 3 [css3-text] Rendering -webkit-each-line value for text-indent from css3-text 4 https://bugs.webkit.org/show_bug.cgi?id=113259 5 6 CSS3 TEXT introduces new value, "each-line" for text-indent. 7 Indentation affects the first line of the block container as well as each line 8 after a forced line break, but does not affect lines after a soft wrap break. 9 10 Reviewed by Levi Weintraub. 11 12 * fast/css3-text/css3-text-indent/text-indent-each-line-expected.html: Added. 13 * fast/css3-text/css3-text-indent/text-indent-each-line.html: Added. 14 * platform/win/TestExpectations: 15 * platform/wincairo/TestExpectations: 16 1 17 2013-04-02 Dean Jackson <dino@apple.com> 2 18 -
trunk/LayoutTests/platform/win/TestExpectations
r147492 r147513 2508 2508 fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-decoration-color.html 2509 2509 fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-underline-position.html 2510 fast/css3-text/css3-text-indent/getComputedStyle/getComputedStyle-text-indent-inherited.html 2511 fast/css3-text/css3-text-indent/getComputedStyle/getComputedStyle-text-indent.html 2510 fast/css3-text/css3-text-indent [ Failure ] 2512 2511 2513 2512 # Needs rebaseline. -
trunk/LayoutTests/platform/wincairo/TestExpectations
r147048 r147513 2984 2984 fast/css3-text/css3-text-align-last/getComputedStyle/getComputedStyle-text-align-last.html 2985 2985 fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-decoration-line.html 2986 fast/css3-text/css3-text-indent/getComputedStyle/getComputedStyle-text-indent-inherited.html 2987 fast/css3-text/css3-text-indent/getComputedStyle/getComputedStyle-text-indent.html 2986 fast/css3-text/css3-text-indent [ Failure ] 2988 2987 2989 2988 # Spellchecker behavior tests. -
trunk/Source/WebCore/ChangeLog
r147506 r147513 1 2013-04-02 Jaehun Lim <ljaehun.lim@samsung.com> 2 3 [css3-text] Rendering -webkit-each-line value for text-indent from css3-text 4 https://bugs.webkit.org/show_bug.cgi?id=113259 5 6 Reviewed by Levi Weintraub. 7 8 CSS3 TEXT introduces new value, "each-line" for text-indent. 9 Indentation affects the first line of the block container as well as each line 10 after a forced line break, but does not affect lines after a soft wrap break. 11 12 This patch is the rendering part to support each-line value for text-indent. 13 It's prefixed and guarded by CSS3_TEXT flag. 14 15 Test: fast/css3-text/css3-text-indent/text-indent-each-line.html 16 17 * rendering/RenderBlock.h: 18 (WebCore::RenderBlock::availableLogicalWidthForLine): 19 (WebCore::RenderBlock::logicalRightOffsetForLine): 20 (WebCore::RenderBlock::logicalLeftOffsetForLine): 21 (WebCore::RenderBlock::startOffsetForLine): 22 (WebCore::RenderBlock::endOffsetForLine): 23 (WebCore::RenderBlock::pixelSnappedLogicalLeftOffsetForLine): 24 (WebCore::RenderBlock::pixelSnappedLogicalRightOffsetForLine): 25 Rename a parameter from firstLine to shouldIndentText. 26 27 * rendering/RenderBlockLineLayout.cpp: 28 (WebCore::LineWidth::LineWidth): 29 (WebCore::LineWidth::shouldIndentText): Return boolean according to m_shouldIndentText. 30 (WebCore::LineWidth::updateAvailableWidth): 31 (WebCore::LineWidth::shrinkAvailableWidthForNewFloatIfNeeded): 32 (WebCore::LineWidth::fitBelowFloats): 33 Add enum IndentTextOrNot and m_shouldIndentText. 34 Use m_shouldIndentText instead of m_isFirstLine. 35 36 (WebCore::requiresIndent): Decide whether text indentation is required. 37 (WebCore::updateLogicalInlinePositions): 38 (WebCore::RenderBlock::computeInlineDirectionPositionsForLine): 39 (WebCore::RenderBlock::LineBreaker::nextSegmentBreak): 40 1 41 2013-04-02 Glenn Adams <glenn@skynav.com> 2 42 -
trunk/Source/WebCore/rendering/RenderBlock.h
r147245 r147513 166 166 // Versions that can compute line offsets with the region and page offset passed in. Used for speed to avoid having to 167 167 // compute the region all over again when you already know it. 168 LayoutUnit availableLogicalWidthForLine(LayoutUnit position, bool firstLine, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0) const169 { 170 return max<LayoutUnit>(0, logicalRightOffsetForLine(position, firstLine, region, offsetFromLogicalTopOfFirstPage, logicalHeight)171 - logicalLeftOffsetForLine(position, firstLine, region, offsetFromLogicalTopOfFirstPage, logicalHeight));172 } 173 LayoutUnit logicalRightOffsetForLine(LayoutUnit position, bool firstLine, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0) const174 { 175 return logicalRightOffsetForLine(position, logicalRightOffsetForContent(region, offsetFromLogicalTopOfFirstPage), firstLine, 0, logicalHeight);176 } 177 LayoutUnit logicalLeftOffsetForLine(LayoutUnit position, bool firstLine, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0) const178 { 179 return logicalLeftOffsetForLine(position, logicalLeftOffsetForContent(region, offsetFromLogicalTopOfFirstPage), firstLine, 0, logicalHeight);180 } 181 LayoutUnit startOffsetForLine(LayoutUnit position, bool firstLine, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0) const182 { 183 return style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, firstLine, region, offsetFromLogicalTopOfFirstPage, logicalHeight)184 : logicalWidth() - logicalRightOffsetForLine(position, firstLine, region, offsetFromLogicalTopOfFirstPage, logicalHeight);185 } 186 LayoutUnit endOffsetForLine(LayoutUnit position, bool firstLine, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0) const187 { 188 return !style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, firstLine, region, offsetFromLogicalTopOfFirstPage, logicalHeight)189 : logicalWidth() - logicalRightOffsetForLine(position, firstLine, region, offsetFromLogicalTopOfFirstPage, logicalHeight);190 } 191 192 LayoutUnit availableLogicalWidthForLine(LayoutUnit position, bool firstLine, LayoutUnit logicalHeight = 0) const193 { 194 return availableLogicalWidthForLine(position, firstLine, regionAtBlockOffset(position), offsetFromLogicalTopOfFirstPage(), logicalHeight);195 } 196 LayoutUnit logicalRightOffsetForLine(LayoutUnit position, bool firstLine, LayoutUnit logicalHeight = 0) const197 { 198 return logicalRightOffsetForLine(position, logicalRightOffsetForContent(position), firstLine, 0, logicalHeight);199 } 200 LayoutUnit logicalLeftOffsetForLine(LayoutUnit position, bool firstLine, LayoutUnit logicalHeight = 0) const201 { 202 return logicalLeftOffsetForLine(position, logicalLeftOffsetForContent(position), firstLine, 0, logicalHeight);203 } 204 LayoutUnit pixelSnappedLogicalLeftOffsetForLine(LayoutUnit position, bool firstLine, LayoutUnit logicalHeight = 0) const205 { 206 return roundToInt(logicalLeftOffsetForLine(position, firstLine, logicalHeight));207 } 208 LayoutUnit pixelSnappedLogicalRightOffsetForLine(LayoutUnit position, bool firstLine, LayoutUnit logicalHeight = 0) const168 LayoutUnit availableLogicalWidthForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0) const 169 { 170 return max<LayoutUnit>(0, logicalRightOffsetForLine(position, shouldIndentText, region, offsetFromLogicalTopOfFirstPage, logicalHeight) 171 - logicalLeftOffsetForLine(position, shouldIndentText, region, offsetFromLogicalTopOfFirstPage, logicalHeight)); 172 } 173 LayoutUnit logicalRightOffsetForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0) const 174 { 175 return logicalRightOffsetForLine(position, logicalRightOffsetForContent(region, offsetFromLogicalTopOfFirstPage), shouldIndentText, 0, logicalHeight); 176 } 177 LayoutUnit logicalLeftOffsetForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0) const 178 { 179 return logicalLeftOffsetForLine(position, logicalLeftOffsetForContent(region, offsetFromLogicalTopOfFirstPage), shouldIndentText, 0, logicalHeight); 180 } 181 LayoutUnit startOffsetForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0) const 182 { 183 return style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, shouldIndentText, region, offsetFromLogicalTopOfFirstPage, logicalHeight) 184 : logicalWidth() - logicalRightOffsetForLine(position, shouldIndentText, region, offsetFromLogicalTopOfFirstPage, logicalHeight); 185 } 186 LayoutUnit endOffsetForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0) const 187 { 188 return !style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, shouldIndentText, region, offsetFromLogicalTopOfFirstPage, logicalHeight) 189 : logicalWidth() - logicalRightOffsetForLine(position, shouldIndentText, region, offsetFromLogicalTopOfFirstPage, logicalHeight); 190 } 191 192 LayoutUnit availableLogicalWidthForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const 193 { 194 return availableLogicalWidthForLine(position, shouldIndentText, regionAtBlockOffset(position), offsetFromLogicalTopOfFirstPage(), logicalHeight); 195 } 196 LayoutUnit logicalRightOffsetForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const 197 { 198 return logicalRightOffsetForLine(position, logicalRightOffsetForContent(position), shouldIndentText, 0, logicalHeight); 199 } 200 LayoutUnit logicalLeftOffsetForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const 201 { 202 return logicalLeftOffsetForLine(position, logicalLeftOffsetForContent(position), shouldIndentText, 0, logicalHeight); 203 } 204 LayoutUnit pixelSnappedLogicalLeftOffsetForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const 205 { 206 return roundToInt(logicalLeftOffsetForLine(position, shouldIndentText, logicalHeight)); 207 } 208 LayoutUnit pixelSnappedLogicalRightOffsetForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const 209 209 { 210 210 // FIXME: Multicolumn layouts break carrying over subpixel values to the logical right offset because the lines may be shifted … … 212 212 // by one pixel when rendered versus layed out, which can result in the line being clipped. For now, we have to floor. 213 213 // https://bugs.webkit.org/show_bug.cgi?id=105461 214 return floorToInt(logicalRightOffsetForLine(position, firstLine, logicalHeight));215 } 216 LayoutUnit startOffsetForLine(LayoutUnit position, bool firstLine, LayoutUnit logicalHeight = 0) const217 { 218 return style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, firstLine, logicalHeight)219 : logicalWidth() - logicalRightOffsetForLine(position, firstLine, logicalHeight);220 } 221 LayoutUnit endOffsetForLine(LayoutUnit position, bool firstLine, LayoutUnit logicalHeight = 0) const222 { 223 return !style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, firstLine, logicalHeight)224 : logicalWidth() - logicalRightOffsetForLine(position, firstLine, logicalHeight);225 } 226 227 LayoutUnit startAlignedOffsetForLine(LayoutUnit position, bool firstLine);214 return floorToInt(logicalRightOffsetForLine(position, shouldIndentText, logicalHeight)); 215 } 216 LayoutUnit startOffsetForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const 217 { 218 return style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, shouldIndentText, logicalHeight) 219 : logicalWidth() - logicalRightOffsetForLine(position, shouldIndentText, logicalHeight); 220 } 221 LayoutUnit endOffsetForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const 222 { 223 return !style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, shouldIndentText, logicalHeight) 224 : logicalWidth() - logicalRightOffsetForLine(position, shouldIndentText, logicalHeight); 225 } 226 227 LayoutUnit startAlignedOffsetForLine(LayoutUnit position, bool shouldIndentText); 228 228 LayoutUnit textIndentOffset() const; 229 229 -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r147506 r147513 90 90 #endif 91 91 92 enum IndentTextOrNot { DoNotIndentText, IndentText }; 93 92 94 class LineWidth { 93 95 public: 94 LineWidth(RenderBlock* block, bool isFirstLine )96 LineWidth(RenderBlock* block, bool isFirstLine, IndentTextOrNot shouldIndentText) 95 97 : m_block(block) 96 98 , m_uncommittedWidth(0) … … 104 106 #endif 105 107 , m_isFirstLine(isFirstLine) 108 , m_shouldIndentText(shouldIndentText) 106 109 { 107 110 ASSERT(block); … … 132 135 void applyOverhang(RenderRubyRun*, RenderObject* startRenderer, RenderObject* endRenderer); 133 136 void fitBelowFloats(); 137 138 bool shouldIndentText() { return m_shouldIndentText == IndentText; } 134 139 135 140 private: … … 151 156 #endif 152 157 bool m_isFirstLine; 158 IndentTextOrNot m_shouldIndentText; 153 159 }; 154 160 … … 157 163 LayoutUnit height = m_block->logicalHeight(); 158 164 LayoutUnit logicalHeight = logicalHeightForLine(m_block, m_isFirstLine, replacedHeight); 159 m_left = m_block->logicalLeftOffsetForLine(height, m_isFirstLine, logicalHeight);160 m_right = m_block->logicalRightOffsetForLine(height, m_isFirstLine, logicalHeight);165 m_left = m_block->logicalLeftOffsetForLine(height, shouldIndentText(), logicalHeight); 166 m_right = m_block->logicalRightOffsetForLine(height, shouldIndentText(), logicalHeight); 161 167 162 168 #if ENABLE(CSS_EXCLUSIONS) … … 189 195 #endif 190 196 191 if ( m_isFirstLine&& m_block->style()->isLeftToRightDirection())197 if (shouldIndentText() && m_block->style()->isLeftToRightDirection()) 192 198 newLeft += floorToInt(m_block->textIndentOffset()); 193 199 m_left = max<float>(m_left, newLeft); … … 199 205 #endif 200 206 201 if ( m_isFirstLine&& !m_block->style()->isLeftToRightDirection())207 if (shouldIndentText() && !m_block->style()->isLeftToRightDirection()) 202 208 newRight -= floorToInt(m_block->textIndentOffset()); 203 209 m_right = min<float>(m_right, newRight); … … 236 242 break; 237 243 238 newLineLeft = m_block->logicalLeftOffsetForLine(floatLogicalBottom, m_isFirstLine);239 newLineRight = m_block->logicalRightOffsetForLine(floatLogicalBottom, m_isFirstLine);244 newLineLeft = m_block->logicalLeftOffsetForLine(floatLogicalBottom, shouldIndentText()); 245 newLineRight = m_block->logicalRightOffsetForLine(floatLogicalBottom, shouldIndentText()); 240 246 newLineWidth = max(0.0f, newLineRight - newLineLeft); 241 247 lastFloatLogicalBottom = floatLogicalBottom; … … 952 958 } 953 959 954 static void updateLogicalInlinePositions(RenderBlock* block, float& lineLogicalLeft, float& lineLogicalRight, float& availableLogicalWidth, bool firstLine, LayoutUnit boxLogicalHeight) 960 static IndentTextOrNot requiresIndent(bool isFirstLine, bool isAfterHardLineBreak, RenderStyle* style) 961 { 962 if (isFirstLine) 963 return IndentText; 964 #if ENABLE(CSS3_TEXT) 965 if (isAfterHardLineBreak && style->textIndentLine() == TextIndentEachLine) 966 return IndentText; 967 #else 968 UNUSED_PARAM(isAfterHardLineBreak); 969 UNUSED_PARAM(style); 970 #endif 971 return DoNotIndentText; 972 } 973 974 static void updateLogicalInlinePositions(RenderBlock* block, float& lineLogicalLeft, float& lineLogicalRight, float& availableLogicalWidth, bool firstLine, IndentTextOrNot shouldIndentText, LayoutUnit boxLogicalHeight) 955 975 { 956 976 LayoutUnit lineLogicalHeight = logicalHeightForLine(block, firstLine, boxLogicalHeight); 957 lineLogicalLeft = block->pixelSnappedLogicalLeftOffsetForLine(block->logicalHeight(), firstLine, lineLogicalHeight);958 lineLogicalRight = block->pixelSnappedLogicalRightOffsetForLine(block->logicalHeight(), firstLine, lineLogicalHeight);977 lineLogicalLeft = block->pixelSnappedLogicalLeftOffsetForLine(block->logicalHeight(), shouldIndentText == IndentText, lineLogicalHeight); 978 lineLogicalRight = block->pixelSnappedLogicalRightOffsetForLine(block->logicalHeight(), shouldIndentText == IndentText, lineLogicalHeight); 959 979 availableLogicalWidth = lineLogicalRight - lineLogicalLeft; 960 980 } … … 967 987 // CSS 2.1: "'Text-indent' only affects a line if it is the first formatted line of an element. For example, the first line of an anonymous block 968 988 // box is only affected if it is the first child of its parent element." 969 bool firstLine = lineInfo.isFirstLine() && !(isAnonymousBlock() && parent()->firstChild() != this); 989 // CSS3 "text-indent", "-webkit-each-line" affects the first line of the block container as well as each line after a forced line break, 990 // but does not affect lines after a soft wrap break. 991 bool isFirstLine = lineInfo.isFirstLine() && !(isAnonymousBlock() && parent()->firstChild() != this); 992 bool isAfterHardLineBreak = lineBox->prevRootBox() && lineBox->prevRootBox()->endsWithBreak(); 993 IndentTextOrNot shouldIndentText = requiresIndent(isFirstLine, isAfterHardLineBreak, style()); 970 994 float lineLogicalLeft; 971 995 float lineLogicalRight; 972 996 float availableLogicalWidth; 973 updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, availableLogicalWidth, firstLine, 0);997 updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, availableLogicalWidth, isFirstLine, shouldIndentText, 0); 974 998 bool needsWordSpacing; 975 999 #if ENABLE(CSS_EXCLUSIONS) … … 1007 1031 if (firstRun && firstRun->m_object->isReplaced()) { 1008 1032 RenderBox* renderBox = toRenderBox(firstRun->m_object); 1009 updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, availableLogicalWidth, firstLine, renderBox->logicalHeight());1033 updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, availableLogicalWidth, isFirstLine, shouldIndentText, renderBox->logicalHeight()); 1010 1034 } 1011 1035 … … 2636 2660 LineMidpointState& lineMidpointState = resolver.midpointState(); 2637 2661 2638 LineWidth width(m_block, lineInfo.isFirstLine() );2662 LineWidth width(m_block, lineInfo.isFirstLine(), requiresIndent(lineInfo.isFirstLine(), lineInfo.previousLineBrokeCleanly(), m_block->style())); 2639 2663 2640 2664 skipLeadingWhitespace(resolver, lineInfo, lastFloatFromPreviousLine, width);
Note: See TracChangeset
for help on using the changeset viewer.