Changeset 20967 in webkit
- Timestamp:
- Apr 19, 2007 10:02:19 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r20966 r20967 1 2007-04-19 David Hyatt <hyatt@apple.com> 2 3 Fix for bug 13208, implement word-break. This patch produces a partial 4 implementation of word-break. word-break: break-all is implemented. In 5 addition, a custom value, word-break: break-word is added that is a hybrid 6 of word-wrap: break-word and word-break: break-all (and more useful than 7 either). 8 9 Reviewed by beth 10 11 Added fast/text/word-break.html 12 13 * css/CSSComputedStyleDeclaration.cpp: 14 (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): 15 * css/CSSPropertyNames.in: 16 * css/CSSValueKeywords.in: 17 * css/cssparser.cpp: 18 (WebCore::CSSParser::parseValue): 19 * css/cssstyleselector.cpp: 20 (WebCore::CSSStyleSelector::applyProperty): 21 * rendering/RenderStyle.cpp: 22 (WebCore::StyleRareInheritedData::StyleRareInheritedData): 23 (WebCore::StyleRareInheritedData::operator==): 24 (WebCore::RenderStyle::diff): 25 * rendering/RenderStyle.h: 26 (WebCore::): 27 (WebCore::RenderStyle::breakWords): 28 (WebCore::RenderStyle::wordBreak): 29 (WebCore::RenderStyle::setWordBreak): 30 (WebCore::RenderStyle::initialWordBreak): 31 (WebCore::RenderStyle::initialWordWrap): 32 * rendering/RenderText.cpp: 33 (WebCore::RenderText::calcMinMaxWidthInternal): 34 * rendering/RenderTextControl.cpp: 35 (WebCore::RenderTextControl::createInnerTextStyle): 36 (WebCore::RenderTextControl::calcHeight): 37 * rendering/bidi.cpp: 38 (WebCore::RenderBlock::findNextLineBreak): 39 1 40 2007-04-20 Mark Rowe <mrowe@apple.com> 2 41 -
trunk/WebCore/css/CSSComputedStyleDeclaration.cpp
r20889 r20967 1407 1407 case CSS_PROP_WIDTH: 1408 1408 return new CSSPrimitiveValue(renderer->contentWidth(), CSSPrimitiveValue::CSS_PX); 1409 case CSS_PROP_WORD_BREAK: 1410 switch (style->wordBreak()) { 1411 case NormalWordBreak: 1412 return new CSSPrimitiveValue(CSS_VAL_NORMAL); 1413 case BreakAllWordBreak: 1414 return new CSSPrimitiveValue(CSS_VAL_BREAK_ALL); 1415 case BreakWordBreak: 1416 return new CSSPrimitiveValue(CSS_VAL_BREAK_WORD); 1417 } 1409 1418 case CSS_PROP_WORD_SPACING: 1410 1419 return new CSSPrimitiveValue(style->wordSpacing(), CSSPrimitiveValue::CSS_PX); 1411 1420 case CSS_PROP_WORD_WRAP: 1412 1421 switch (style->wordWrap()) { 1413 case WBNORMAL:1422 case NormalWordWrap: 1414 1423 return new CSSPrimitiveValue(CSS_VAL_NORMAL); 1415 case B REAK_WORD:1424 case BreakWordWrap: 1416 1425 return new CSSPrimitiveValue(CSS_VAL_BREAK_WORD); 1417 1426 } -
trunk/WebCore/css/CSSPropertyNames.in
r19862 r20967 137 137 widows 138 138 width 139 word-break 139 140 word-spacing 140 141 word-wrap -
trunk/WebCore/css/CSSValueKeywords.in
r20841 r20967 462 462 463 463 # 464 # CSS_PROP_WORD_BREAK 465 # 466 break-all 467 468 # 464 469 # CSS_PROP_WORD_WRAP 465 470 # -
trunk/WebCore/css/cssparser.cpp
r20889 r20967 904 904 else 905 905 valid_primitive = validUnit(value, FLength, strict); 906 break; 907 908 case CSS_PROP_WORD_BREAK: // normal | break-all | break-word (this is a custom extension) 909 if (id == CSS_VAL_NORMAL || id == CSS_VAL_BREAK_ALL || CSS_VAL_BREAK_WORD) 910 valid_primitive = true; 906 911 break; 907 912 -
trunk/WebCore/css/cssstyleselector.cpp
r20889 r20967 2664 2664 } 2665 2665 2666 case CSS_PROP_WORD_WRAP: 2667 { 2666 case CSS_PROP_WORD_BREAK: { 2667 HANDLE_INHERIT_AND_INITIAL(wordBreak, WordBreak) 2668 2669 EWordBreak b; 2670 switch (primitiveValue->getIdent()) { 2671 case CSS_VAL_BREAK_ALL: 2672 b = BreakAllWordBreak; 2673 break; 2674 case CSS_VAL_BREAK_WORD: 2675 b = BreakWordBreak; 2676 break; 2677 case CSS_VAL_NORMAL: 2678 default: 2679 b = NormalWordBreak; 2680 break; 2681 } 2682 style->setWordBreak(b); 2683 return; 2684 } 2685 2686 case CSS_PROP_WORD_WRAP: { 2668 2687 HANDLE_INHERIT_AND_INITIAL(wordWrap, WordWrap) 2669 2670 if(!primitiveValue->getIdent()) return;2671 2688 2672 2689 EWordWrap s; 2673 2690 switch(primitiveValue->getIdent()) { 2674 2691 case CSS_VAL_BREAK_WORD: 2675 s = B REAK_WORD;2692 s = BreakWordWrap; 2676 2693 break; 2677 2694 case CSS_VAL_NORMAL: 2678 2695 default: 2679 s = WBNORMAL; 2680 break; 2681 } 2696 s = NormalWordWrap; 2697 break; 2698 } 2699 2682 2700 style->setWordWrap(s); 2683 2701 return; -
trunk/WebCore/rendering/RenderStyle.cpp
r19862 r20967 525 525 , textSecurity(RenderStyle::initialTextSecurity()) 526 526 , userModify(READ_ONLY) 527 , wordWrap(WBNORMAL) 527 , wordBreak(RenderStyle::initialWordBreak()) 528 , wordWrap(RenderStyle::initialWordWrap()) 528 529 , nbspMode(NBNORMAL) 529 530 , khtmlLineBreak(LBNORMAL) … … 542 543 , textSecurity(o.textSecurity) 543 544 , userModify(o.userModify) 545 , wordBreak(o.wordBreak) 544 546 , wordWrap(o.wordWrap) 545 547 , nbspMode(o.nbspMode) … … 564 566 && textSecurity == o.textSecurity 565 567 && userModify == o.userModify 568 && wordBreak == o.wordBreak 566 569 && wordWrap == o.wordWrap 567 570 && nbspMode == o.nbspMode … … 944 947 if (rareInheritedData->highlight != other->rareInheritedData->highlight || 945 948 rareInheritedData->textSizeAdjust != other->rareInheritedData->textSizeAdjust || 949 rareInheritedData->wordBreak != other->rareInheritedData->wordBreak || 946 950 rareInheritedData->wordWrap != other->rareInheritedData->wordWrap || 947 951 rareInheritedData->nbspMode != other->rareInheritedData->nbspMode || -
trunk/WebCore/rendering/RenderStyle.h
r20889 r20967 719 719 // Word Break Values. Matches WinIE, rather than CSS3 720 720 721 enum EWordBreak { 722 NormalWordBreak, BreakAllWordBreak, BreakWordBreak 723 }; 724 721 725 enum EWordWrap { 722 WBNORMAL, BREAK_WORD726 NormalWordWrap, BreakWordWrap 723 727 }; 724 728 … … 881 885 unsigned textSecurity : 2; // ETextSecurity 882 886 unsigned userModify : 2; // EUserModify (editing) 887 unsigned wordBreak : 2; // EWordBreak 883 888 unsigned wordWrap : 1; // EWordWrap 884 889 unsigned nbspMode : 1; // ENBSPMode … … 1373 1378 return whiteSpace() == PRE_WRAP || khtmlLineBreak() == AFTER_WHITE_SPACE; 1374 1379 } 1380 bool breakWords() const { 1381 return wordBreak() == BreakWordBreak || wordWrap() == BreakWordWrap; 1382 } 1375 1383 1376 1384 const Color & backgroundColor() const { return background->m_color; } … … 1457 1465 EMarginCollapse marginTopCollapse() const { return static_cast<EMarginCollapse>(rareNonInheritedData->marginTopCollapse); } 1458 1466 EMarginCollapse marginBottomCollapse() const { return static_cast<EMarginCollapse>(rareNonInheritedData->marginBottomCollapse); } 1467 EWordBreak wordBreak() const { return static_cast<EWordBreak>(rareInheritedData->wordBreak); } 1459 1468 EWordWrap wordWrap() const { return static_cast<EWordWrap>(rareInheritedData->wordWrap); } 1460 1469 ENBSPMode nbspMode() const { return static_cast<ENBSPMode>(rareInheritedData->nbspMode); } … … 1698 1707 void setMarginTopCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginTopCollapse, c); } 1699 1708 void setMarginBottomCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginBottomCollapse, c); } 1709 void setWordBreak(EWordBreak b) { SET_VAR(rareInheritedData, wordBreak, b); } 1700 1710 void setWordWrap(EWordWrap b) { SET_VAR(rareInheritedData, wordWrap, b); } 1701 1711 void setNBSPMode(ENBSPMode b) { SET_VAR(rareInheritedData, nbspMode, b); } … … 1845 1855 static EMarginCollapse initialMarginTopCollapse() { return MCOLLAPSE; } 1846 1856 static EMarginCollapse initialMarginBottomCollapse() { return MCOLLAPSE; } 1847 static EWordWrap initialWordWrap() { return WBNORMAL; } 1857 static EWordBreak initialWordBreak() { return NormalWordBreak; } 1858 static EWordWrap initialWordWrap() { return NormalWordWrap; } 1848 1859 static ENBSPMode initialNBSPMode() { return NBNORMAL; } 1849 1860 static EKHTMLLineBreak initialKHTMLLineBreak() { return LBNORMAL; } -
trunk/WebCore/rendering/RenderText.cpp
r20959 r20967 537 537 bool breakNBSP = style()->autoWrap() && style()->nbspMode() == SPACE; 538 538 539 bool breakAll = (style()->wordBreak() == BreakAllWordBreak || style()->wordBreak() == BreakWordBreak) && style()->autoWrap(); 540 539 541 for (int i = 0; i < len; i++) { 540 542 UChar c = txt[i]; … … 574 576 continue; 575 577 576 bool hasBreak = isBreakable(txt, i, len, nextBreakable, breakNBSP);578 bool hasBreak = breakAll || isBreakable(txt, i, len, nextBreakable, breakNBSP); 577 579 int j = i; 578 580 while (c != '\n' && !isSpaceAccordingToStyle(c, style()) && c != '\t' && c != softHyphen) { … … 581 583 break; 582 584 c = txt[j]; 583 if ( isBreakable(txt, j, len, nextBreakable, breakNBSP))585 if (breakAll || isBreakable(txt, j, len, nextBreakable, breakNBSP)) 584 586 break; 585 587 } -
trunk/WebCore/rendering/RenderTextControl.cpp
r20685 r20967 149 149 if (static_cast<HTMLTextAreaElement*>(element)->wrap() == HTMLTextAreaElement::ta_NoWrap) { 150 150 textBlockStyle->setWhiteSpace(PRE); 151 textBlockStyle->setWordWrap( WBNORMAL);151 textBlockStyle->setWordWrap(NormalWordWrap); 152 152 } else { 153 153 textBlockStyle->setWhiteSpace(PRE_WRAP); 154 textBlockStyle->setWordWrap(B REAK_WORD);154 textBlockStyle->setWordWrap(BreakWordWrap); 155 155 } 156 156 } else { 157 157 textBlockStyle->setWhiteSpace(PRE); 158 textBlockStyle->setWordWrap( WBNORMAL);158 textBlockStyle->setWordWrap(NormalWordWrap); 159 159 textBlockStyle->setOverflowX(OHIDDEN); 160 160 textBlockStyle->setOverflowY(OHIDDEN); … … 598 598 int scrollbarSize = 0; 599 599 // We are able to have a horizontal scrollbar if the overflow style is scroll, or if its auto and there's no word wrap. 600 if (m_innerText->renderer()->style()->overflowX() == OSCROLL || (m_innerText->renderer()->style()->overflowX() == OAUTO && m_innerText->renderer()->style()->wordWrap() == WBNORMAL))600 if (m_innerText->renderer()->style()->overflowX() == OSCROLL || (m_innerText->renderer()->style()->overflowX() == OAUTO && m_innerText->renderer()->style()->wordWrap() == NormalWordWrap)) 601 601 scrollbarSize = 15; 602 602 -
trunk/WebCore/rendering/bidi.cpp
r20889 r20967 2227 2227 // Auto-wrapping text should wrap in the middle of a word only if it could not wrap before the word, 2228 2228 // which is only possible if the word is the first thing on the line, that is, if |w| is zero. 2229 bool breakWords = o->style()-> wordWrap() == BREAK_WORD&& ((autoWrap && !w) || currWS == PRE);2229 bool breakWords = o->style()->breakWords() && ((autoWrap && !w) || currWS == PRE); 2230 2230 bool midWordBreak = false; 2231 2231 bool breakAll = o->style()->wordBreak() == BreakAllWordBreak && autoWrap; 2232 2232 2233 while (len) { 2233 2234 bool previousCharacterIsSpace = currentCharacterIsSpace; … … 2277 2278 currentCharacterIsWS = currentCharacterIsSpace || (breakNBSP && c == noBreakSpace); 2278 2279 2279 if (break Words && !midWordBreak) {2280 if (breakAll || (breakWords && !midWordBreak)) { 2280 2281 wrapW += t->width(pos, 1, f, w + wrapW); 2281 2282 midWordBreak = w + wrapW > width; … … 2283 2284 2284 2285 bool betweenWords = c == '\n' || (currWS != PRE && !atStart && isBreakable(str, pos, strlen, nextBreakable, breakNBSP)); 2285 2286 if (betweenWords || midWordBreak ) {2286 2287 if (betweenWords || midWordBreak || breakAll) { 2287 2288 bool stoppedIgnoringSpaces = false; 2288 2289 if (ignoringSpaces) {
Note: See TracChangeset
for help on using the changeset viewer.