Changeset 95030 in webkit
- Timestamp:
- Sep 13, 2011 9:44:15 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r95028 r95030 1 2011-09-13 Xianzhu Wang <wangxianzhu@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Webkit wraps between hyphen-minus and numeric characters 6 https://bugs.webkit.org/show_bug.cgi?id=20677 7 8 Disallow wrapping between a hyphen-minus and a digit if the hyphen-minus 9 is not directly after a digit or a letter. 10 11 * fast/text/line-breaks-after-hyphen-before-number-expected.txt: Added. 12 * fast/text/line-breaks-after-hyphen-before-number.html: Added. 13 1 14 2011-09-12 Sam Weinig <sam@webkit.org> 2 15 -
trunk/Source/WebCore/ChangeLog
r95029 r95030 1 2011-09-13 Xianzhu Wang <wangxianzhu@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Webkit wraps between hyphen-minus and numeric characters 6 https://bugs.webkit.org/show_bug.cgi?id=20677 7 8 Disallow wrapping between a hyphen-minus and a digit if the hyphen-minus 9 is not directly after a digit or a letter. 10 11 Test: fast/text/line-breaks-after-hyphen-before-number.html 12 13 * rendering/break_lines.cpp: 14 (WebCore::asciiLineBreakTable): Disabled line-breaking after '-' and before '.', '0'-'9'. Note: the change for '0'-'9' doesn't really matter because the case is handled hard-coded in shouldBreakAfter(). 15 (WebCore::shouldBreakAfter): Changed line-breaking behavior after '-'. 16 (WebCore::nextBreakablePosition): Passes lastLastCh to shouldBreakAfter. 17 1 18 2011-09-13 Erik Wright <erikwright@chromium.org> 2 19 -
trunk/Source/WebCore/rendering/break_lines.cpp
r85036 r95030 1 1 /* 2 2 * Copyright (C) 2005, 2007, 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 28 29 29 30 #include "TextBreakIterator.h" 31 #include <wtf/ASCIICType.h> 30 32 #include <wtf/StdLibExtras.h> 31 33 #include <wtf/unicode/CharacterNames.h> … … 67 69 68 70 // Line breaking table for printable ASCII characters. Line breaking opportunities in this table are as below: 69 // - before open ning punctuations such as '(', '<', '[', '{' after certain characters (compatible with Firefox 3.6);71 // - before opening punctuations such as '(', '<', '[', '{' after certain characters (compatible with Firefox 3.6); 70 72 // - after '-' and '?' (backward-compatible, and compatible with Internet Explorer). 71 73 // Please refer to <https://bugs.webkit.org/show_bug.cgi?id=37698> for line breaking matrixes of different browsers … … 85 87 { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // + 86 88 { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // , 87 { B(1, 1, 1, 1, 1, 1, 1, 1), B(1, 1, 1, 1, 1, 1, 1, 1), F, B(1, 1, 1, 1, 1, 1, 1, 1), F, F, F, B(1, 1, 1, 1, 1, 1, 1, 1), F, F, F, B(1, 1, 1, 1, 1, 1, 1, 1) }, // -89 { B(1, 1, 1, 1, 1, 1, 1, 1), B(1, 1, 1, 1, 1, 0, 1, 0), 0, B(0, 1, 1, 1, 1, 1, 1, 1), F, F, F, B(1, 1, 1, 1, 1, 1, 1, 1), F, F, F, B(1, 1, 1, 1, 1, 1, 1, 1) }, // - Note: breaking before '0'-'9' is handled hard-coded in shouldBreakAfter(). 88 90 { B(0, 0, 0, 0, 0, 0, 0, 1), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 1, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 1, 0, 0, 0, 0, 0) }, // . 89 91 { B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // / … … 118 120 COMPILE_ASSERT(WTF_ARRAY_LENGTH(asciiLineBreakTable) == asciiLineBreakTableLastChar - asciiLineBreakTableFirstChar + 1, TestLineBreakTableConsistency); 119 121 120 static inline bool shouldBreakAfter(UChar ch, UChar nextCh)122 static inline bool shouldBreakAfter(UChar lastCh, UChar ch, UChar nextCh) 121 123 { 122 124 switch (ch) { … … 127 129 // We may want to remove or conditionalize this workaround at some point. 128 130 return true; 131 case '-': 132 if (isASCIIDigit(nextCh)) { 133 // Don't allow line breaking between '-' and a digit if the '-' may mean a minus sign in the context, 134 // while allow breaking in 'ABCD-1234' and '1234-5678' which may be in long URLs. 135 return isASCIIAlphanumeric(lastCh); 136 } 137 // Fall through 129 138 default: 130 139 // If both ch and nextCh are ASCII characters, use a lookup table for enhanced speed and for compatibility … … 152 161 int nextBreak = -1; 153 162 163 UChar lastLastCh = pos > 1 ? str[pos - 2] : 0; 154 164 UChar lastCh = pos > 0 ? str[pos - 1] : 0; 155 165 for (int i = pos; i < len; i++) { 156 166 UChar ch = str[i]; 157 167 158 if (isBreakableSpace(ch, treatNoBreakSpaceAsBreak) || shouldBreakAfter(last Ch, ch))168 if (isBreakableSpace(ch, treatNoBreakSpaceAsBreak) || shouldBreakAfter(lastLastCh, lastCh, ch)) 159 169 return i; 160 170 … … 169 179 } 170 180 181 lastLastCh = lastCh; 171 182 lastCh = ch; 172 183 }
Note: See TracChangeset
for help on using the changeset viewer.