Changeset 94710 in webkit
- Timestamp:
- Sep 7, 2011 1:59:39 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r94709 r94710 1 2011-09-07 Dan Bernstein <mitz@apple.com> 2 3 <rdar://problem/8881922> Support the hyphenate-limit-lines property 4 https://bugs.webkit.org/show_bug.cgi?id=67730 5 6 Reviewed by Dave Hyatt. 7 8 * fast/css/parsing-hyphenate-limit-lines-expected.txt: Added. 9 * fast/css/parsing-hyphenate-limit-lines.html: Added. 10 * fast/text/hyphenate-limit-lines.html: Added. 11 * platform/mac/fast/text/hyphenate-limit-lines-expected.png: Added. 12 * platform/mac/fast/text/hyphenate-limit-lines-expected.txt: Added. 13 1 14 2011-09-07 Csaba Osztrogonác <ossy@webkit.org> 2 15 -
trunk/Source/WebCore/ChangeLog
r94706 r94710 1 2011-09-07 Dan Bernstein <mitz@apple.com> 2 3 <rdar://problem/8881922> Support the hyphenate-limit-lines property 4 https://bugs.webkit.org/show_bug.cgi?id=67730 5 6 Reviewed by Dave Hyatt. 7 8 Tests: fast/css/parsing-hyphenate-limit-lines.html 9 fast/text/hyphenate-limit-lines.html 10 11 * css/CSSComputedStyleDeclaration.cpp: 12 (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Added hyphenate-limit-lines. 13 * css/CSSParser.cpp: 14 (WebCore::CSSParser::parseValue): Ditto. Valid values are non-negative integers and the keyword 15 "no-limit". 16 * css/CSSPropertyNames.in: Added -webkit-hyphenate-limit-lines. 17 * css/CSSStyleSelector.cpp: 18 (WebCore::CSSStyleSelector::applyProperty): Added hyphenate-limit-lines. 19 * css/CSSValueKeywords.in: Added the "no-limit" value keyword. 20 * rendering/RenderBlock.h: 21 * rendering/RenderBlockLineLayout.cpp: 22 (WebCore::RenderBlock::layoutRunsAndFloats): Count the number of consecutive hyphenated lines 23 before the start line and pass it to layoutRunsAndFloatsInRange(). 24 (WebCore::RenderBlock::layoutRunsAndFloatsInRange): Keep track of the number of consecutive 25 hyphenated lines before the current line and pass it to LineBreaker::nextLineBreak(). 26 (WebCore::tryHyphenating): Added parameters for the number of consecutive hyphenated lines before 27 the current line and the limit on consecutive hyphenated lines, and an early return if the limit 28 has been reached. 29 (WebCore::RenderBlock::LineBreaker::nextLineBreak): Added a parameter for the number of consecutive 30 hyphenated lines before the current line, which is passed through to tryHyphenating, along with 31 the value of hyphenate-limit-lines. 32 * rendering/RootInlineBox.cpp: 33 (WebCore::RootInlineBox::isHyphenated): Added. Returns true if the line was hyphenated. 34 * rendering/RootInlineBox.h: 35 * rendering/style/RenderStyle.h: 36 (WebCore::InheritedFlags::hyphenationLimitLines): Added this getter. 37 (WebCore::InheritedFlags::setHyphenationLimitLines): Added this setter. 38 (WebCore::InheritedFlags::initialHyphenationLimitLines): Added. The initial value is -1, 39 corresponding to "no-limit". 40 * rendering/style/StyleRareInheritedData.cpp: 41 (WebCore::StyleRareInheritedData::StyleRareInheritedData): Initialize new member variable. 42 (WebCore::StyleRareInheritedData::operator==): Compare new member variable. 43 * rendering/style/StyleRareInheritedData.h: 44 1 45 2011-09-02 Ojan Vafai <ojan@chromium.org> 2 46 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r94597 r94710 216 216 CSSPropertyWebkitHyphenateLimitAfter, 217 217 CSSPropertyWebkitHyphenateLimitBefore, 218 CSSPropertyWebkitHyphenateLimitLines, 218 219 CSSPropertyWebkitHyphens, 219 220 CSSPropertyWebkitLineBoxContain, … … 1309 1310 return CSSPrimitiveValue::createIdentifier(CSSValueAuto); 1310 1311 return CSSPrimitiveValue::create(style->hyphenationLimitBefore(), CSSPrimitiveValue::CSS_NUMBER); 1312 case CSSPropertyWebkitHyphenateLimitLines: 1313 if (style->hyphenationLimitLines() < 0) 1314 return CSSPrimitiveValue::createIdentifier(CSSValueNoLimit); 1315 return CSSPrimitiveValue::create(style->hyphenationLimitLines(), CSSPrimitiveValue::CSS_NUMBER); 1311 1316 case CSSPropertyWebkitBorderFit: 1312 1317 if (style->borderFit() == BorderFitBorder) -
trunk/Source/WebCore/css/CSSParser.cpp
r94597 r94710 1897 1897 case CSSPropertyWebkitHyphenateLimitAfter: 1898 1898 if (id == CSSValueAuto || validUnit(value, FInteger | FNonNeg, true)) 1899 validPrimitive = true; 1900 break; 1901 1902 case CSSPropertyWebkitHyphenateLimitLines: 1903 if (id == CSSValueNoLimit || validUnit(value, FInteger | FNonNeg, true)) 1899 1904 validPrimitive = true; 1900 1905 break; -
trunk/Source/WebCore/css/CSSPropertyNames.in
r94593 r94710 258 258 -webkit-hyphenate-limit-after 259 259 -webkit-hyphenate-limit-before 260 -webkit-hyphenate-limit-lines 260 261 -webkit-hyphens 261 262 -epub-hyphens = -webkit-hyphens -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r94657 r94710 3550 3550 else 3551 3551 m_style->setHyphenationLimitBefore(primitiveValue->getValue<short>(CSSPrimitiveValue::CSS_NUMBER)); 3552 return; 3553 } 3554 case CSSPropertyWebkitHyphenateLimitLines: { 3555 HANDLE_INHERIT_AND_INITIAL(hyphenationLimitLines, HyphenationLimitLines); 3556 if (primitiveValue->getIdent() == CSSValueNoLimit) 3557 m_style->setHyphenationLimitLines(-1); 3558 else 3559 m_style->setHyphenationLimitLines(primitiveValue->getValue<short>(CSSPrimitiveValue::CSS_NUMBER)); 3552 3560 return; 3553 3561 } -
trunk/Source/WebCore/css/CSSValueKeywords.in
r94104 r94710 777 777 windowed 778 778 779 // -webkit-hyphenate-limit-lines 780 no-limit 781 779 782 // -webkit-hyphens 780 783 // none -
trunk/Source/WebCore/rendering/RenderBlock.h
r94492 r94710 564 564 } 565 565 566 InlineIterator nextLineBreak(InlineBidiResolver&, LineInfo&, LineBreakIteratorInfo&, FloatingObject* lastFloatFromPreviousLine );566 InlineIterator nextLineBreak(InlineBidiResolver&, LineInfo&, LineBreakIteratorInfo&, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines); 567 567 568 568 bool lineWasHyphenated() { return m_hyphenated; } … … 796 796 RootInlineBox* createLineBoxesFromBidiRuns(BidiRunList<BidiRun>&, const InlineIterator& end, LineInfo&, VerticalPositionCache&, BidiRun* trailingSpaceRun); 797 797 void layoutRunsAndFloats(LineLayoutState&, bool hasInlineChild); 798 void layoutRunsAndFloatsInRange(LineLayoutState&, InlineBidiResolver&, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus );798 void layoutRunsAndFloatsInRange(LineLayoutState&, InlineBidiResolver&, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus, unsigned consecutiveHyphenatedLines); 799 799 void linkToEndLineIfNeeded(LineLayoutState&); 800 800 static void repaintDirtyFloats(Vector<FloatWithRect>& floats); -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r94693 r94710 937 937 RootInlineBox* startLine = determineStartPosition(layoutState, resolver); 938 938 939 unsigned consecutiveHyphenatedLines = 0; 940 if (startLine) { 941 for (RootInlineBox* line = startLine->prevRootBox(); line && line->isHyphenated(); line = line->prevRootBox()) 942 consecutiveHyphenatedLines++; 943 } 944 939 945 // FIXME: This would make more sense outside of this function, but since 940 946 // determineStartPosition can change the fullLayout flag we have to do this here. Failure to call … … 985 991 } 986 992 987 layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineBidiStatus );993 layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineBidiStatus, consecutiveHyphenatedLines); 988 994 linkToEndLineIfNeeded(layoutState); 989 995 repaintDirtyFloats(layoutState.floats()); 990 996 } 991 997 992 void RenderBlock::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, InlineBidiResolver& resolver, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus )998 void RenderBlock::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, InlineBidiResolver& resolver, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus, unsigned consecutiveHyphenatedLines) 993 999 { 994 1000 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated(); … … 1016 1022 bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly(); 1017 1023 FloatingObject* lastFloatFromPreviousLine = (m_floatingObjects && !m_floatingObjects->set().isEmpty()) ? m_floatingObjects->set().last() : 0; 1018 end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), lineBreakIteratorInfo, lastFloatFromPreviousLine );1024 end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), lineBreakIteratorInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines); 1019 1025 if (resolver.position().atEnd()) { 1020 1026 // FIXME: We shouldn't be creating any runs in findNextLineBreak to begin with! … … 1046 1052 BidiRun* trailingSpaceRun = !layoutState.lineInfo().previousLineBrokeCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0; 1047 1053 1048 if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated()) 1054 if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated()) { 1049 1055 bidiRuns.logicallyLastRun()->m_hasHyphen = true; 1056 consecutiveHyphenatedLines++; 1057 } else 1058 consecutiveHyphenatedLines = 0; 1050 1059 1051 1060 // Now that the runs have been ordered, we create the line boxes. … … 1680 1689 } 1681 1690 1682 static void tryHyphenating(RenderText* text, const Font& font, const AtomicString& localeIdentifier, int minimumPrefixLength, int minimumSuffixLength, int lastSpace, int pos, float xPos, int availableWidth, bool isFixedPitch, bool collapseWhiteSpace, int lastSpaceWordSpacing, InlineIterator& lineBreak, int nextBreakable, bool& hyphenated)1691 static void tryHyphenating(RenderText* text, const Font& font, const AtomicString& localeIdentifier, unsigned consecutiveHyphenatedLines, int consecutiveHyphenatedLinesLimit, int minimumPrefixLength, int minimumSuffixLength, int lastSpace, int pos, float xPos, int availableWidth, bool isFixedPitch, bool collapseWhiteSpace, int lastSpaceWordSpacing, InlineIterator& lineBreak, int nextBreakable, bool& hyphenated) 1683 1692 { 1684 1693 // Map 'hyphenate-limit-{before,after}: auto;' to 2. … … 1690 1699 1691 1700 if (pos - lastSpace <= minimumSuffixLength) 1701 return; 1702 1703 if (consecutiveHyphenatedLinesLimit >= 0 && consecutiveHyphenatedLines >= static_cast<unsigned>(consecutiveHyphenatedLinesLimit)) 1692 1704 return; 1693 1705 … … 1950 1962 1951 1963 InlineIterator RenderBlock::LineBreaker::nextLineBreak(InlineBidiResolver& resolver, LineInfo& lineInfo, 1952 LineBreakIteratorInfo& lineBreakIteratorInfo, FloatingObject* lastFloatFromPreviousLine )1964 LineBreakIteratorInfo& lineBreakIteratorInfo, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines) 1953 1965 { 1954 1966 reset(); … … 2269 2281 if (lineWasTooWide || !width.fitsOnLine()) { 2270 2282 if (canHyphenate && !width.fitsOnLine()) { 2271 tryHyphenating(t, f, style->locale(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, current.m_pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, current.m_nextBreakablePosition, m_hyphenated);2283 tryHyphenating(t, f, style->locale(), consecutiveHyphenatedLines, m_block->style()->hyphenationLimitLines(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, current.m_pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, current.m_nextBreakablePosition, m_hyphenated); 2272 2284 if (m_hyphenated) 2273 2285 goto end; … … 2387 2399 if (!width.fitsOnLine()) { 2388 2400 if (canHyphenate) 2389 tryHyphenating(t, f, style->locale(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, current.m_pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, current.m_nextBreakablePosition, m_hyphenated);2401 tryHyphenating(t, f, style->locale(), consecutiveHyphenatedLines, m_block->style()->hyphenationLimitLines(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, current.m_pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, current.m_nextBreakablePosition, m_hyphenated); 2390 2402 2391 2403 if (!m_hyphenated && lBreak.previousInSameNode() == softHyphen && style->hyphens() != HyphensNone) -
trunk/Source/WebCore/rendering/RootInlineBox.cpp
r94084 r94710 87 87 InlineFlowBox::clearTruncation(); 88 88 } 89 } 90 91 bool RootInlineBox::isHyphenated() const 92 { 93 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { 94 if (box->isInlineTextBox()) { 95 if (toInlineTextBox(box)->hasHyphen()) 96 return true; 97 } 98 } 99 100 return false; 89 101 } 90 102 -
trunk/Source/WebCore/rendering/RootInlineBox.h
r94084 r94710 96 96 97 97 virtual void clearTruncation(); 98 99 bool isHyphenated() const; 98 100 99 101 virtual int baselinePosition(FontBaseline baselineType) const { return boxModelObject()->baselinePosition(baselineType, m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); } -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r94206 r94710 715 715 short hyphenationLimitBefore() const { return rareInheritedData->hyphenationLimitBefore; } 716 716 short hyphenationLimitAfter() const { return rareInheritedData->hyphenationLimitAfter; } 717 short hyphenationLimitLines() const { return rareInheritedData->hyphenationLimitLines; } 717 718 const AtomicString& hyphenationString() const { return rareInheritedData->hyphenationString; } 718 719 const AtomicString& locale() const { return rareInheritedData->locale; } … … 1095 1096 void setHyphenationLimitBefore(short limit) { SET_VAR(rareInheritedData, hyphenationLimitBefore, limit); } 1096 1097 void setHyphenationLimitAfter(short limit) { SET_VAR(rareInheritedData, hyphenationLimitAfter, limit); } 1098 void setHyphenationLimitLines(short limit) { SET_VAR(rareInheritedData, hyphenationLimitLines, limit); } 1097 1099 void setHyphenationString(const AtomicString& h) { SET_VAR(rareInheritedData, hyphenationString, h); } 1098 1100 void setLocale(const AtomicString& locale) { SET_VAR(rareInheritedData, locale, locale); } … … 1377 1379 static short initialHyphenationLimitBefore() { return -1; } 1378 1380 static short initialHyphenationLimitAfter() { return -1; } 1381 static short initialHyphenationLimitLines() { return -1; } 1379 1382 static const AtomicString& initialHyphenationString() { return nullAtom; } 1380 1383 static const AtomicString& initialLocale() { return nullAtom; } -
trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp
r92871 r94710 56 56 , hyphenationLimitBefore(-1) 57 57 , hyphenationLimitAfter(-1) 58 , hyphenationLimitLines(-1) 58 59 { 59 60 } … … 92 93 , hyphenationLimitBefore(o.hyphenationLimitBefore) 93 94 , hyphenationLimitAfter(o.hyphenationLimitAfter) 95 , hyphenationLimitLines(o.hyphenationLimitLines) 94 96 , locale(o.locale) 95 97 , textEmphasisCustomMark(o.textEmphasisCustomMark) … … 137 139 && hyphenationLimitBefore == o.hyphenationLimitBefore 138 140 && hyphenationLimitAfter == o.hyphenationLimitAfter 141 && hyphenationLimitLines == o.hyphenationLimitLines 139 142 && textEmphasisFill == o.textEmphasisFill 140 143 && textEmphasisMark == o.textEmphasisMark -
trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h
r87121 r94710 93 93 short hyphenationLimitBefore; 94 94 short hyphenationLimitAfter; 95 short hyphenationLimitLines; 95 96 96 97 AtomicString locale;
Note: See TracChangeset
for help on using the changeset viewer.