Diff
Modified: trunk/LayoutTests/ChangeLog (226613 => 226614)
--- trunk/LayoutTests/ChangeLog 2018-01-09 06:19:20 UTC (rev 226613)
+++ trunk/LayoutTests/ChangeLog 2018-01-09 06:41:18 UTC (rev 226614)
@@ -1,3 +1,19 @@
+2018-01-08 Chris Nardi <[email protected]>
+
+ ::first-letter incorrectly selects grapheme pairs
+ https://bugs.webkit.org/show_bug.cgi?id=181315
+
+ Reviewed by Darin Adler.
+
+ * fast/css/first-letter-punctuation-expected.html: Added.
+ * fast/css/first-letter-punctuation.html:
+ * platform/gtk/fast/css/first-letter-punctuation-expected.png: Removed.
+ * platform/gtk/fast/css/first-letter-punctuation-expected.txt: Removed.
+ * platform/ios/fast/css/first-letter-punctuation-expected.txt: Removed.
+ * platform/mac/fast/css/first-letter-punctuation-expected.png: Removed.
+ * platform/mac/fast/css/first-letter-punctuation-expected.txt: Removed.
+ * platform/win/fast/css/first-letter-punctuation-expected.txt: Removed.
+
2018-01-08 Darin Adler <[email protected]>
Special list-item counter starts from an incorrect number for ::before and ::after
Added: trunk/LayoutTests/fast/css/first-letter-punctuation-expected.html (0 => 226614)
--- trunk/LayoutTests/fast/css/first-letter-punctuation-expected.html (rev 0)
+++ trunk/LayoutTests/fast/css/first-letter-punctuation-expected.html 2018-01-09 06:41:18 UTC (rev 226614)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <style type="text/css">
+ .bigGreenText
+ {
+ color: green;
+ font-size: 36px;
+ }
+ </style>
+ </head>
+ <body>
+ <p>Test passes if all the T and surrounding punctuation are green.</p>
+ <div><span class="bigGreenText">(T)</span>est</div>
+ <div><span class="bigGreenText">“T”</span>est</div>
+ <div><span class="bigGreenText">« T »</span>est</div>
+ <div><span class="bigGreenText">« T »</span> est</div>
+ <div><span class="bigGreenText">𐄀T𐄀</span>est</div>
+ </body>
+</html>
\ No newline at end of file
Modified: trunk/LayoutTests/fast/css/first-letter-punctuation.html (226613 => 226614)
--- trunk/LayoutTests/fast/css/first-letter-punctuation.html 2018-01-09 06:19:20 UTC (rev 226613)
+++ trunk/LayoutTests/fast/css/first-letter-punctuation.html 2018-01-09 06:41:18 UTC (rev 226614)
@@ -15,5 +15,6 @@
<div>“T”est</div>
<div>« T »est</div>
<div>« T » est</div>
+ <div>𐄀T𐄀est</div>
</body>
</html>
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (226613 => 226614)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2018-01-09 06:19:20 UTC (rev 226613)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2018-01-09 06:41:18 UTC (rev 226614)
@@ -1,3 +1,19 @@
+2018-01-08 Chris Nardi <[email protected]>
+
+ ::first-letter incorrectly selects grapheme pairs
+ https://bugs.webkit.org/show_bug.cgi?id=181315
+
+ Reviewed by Darin Adler.
+
+ Updated css-pseudo-4 to latest WPT revision and added first-letter-004.html.
+
+ * web-platform-tests/css/css-pseudo-4/first-letter-004-expected.html: Added.
+ * web-platform-tests/css/css-pseudo-4/first-letter-004.html: Added.
+ * web-platform-tests/css/css-pseudo-4/marker-color-expected.html:
+ * web-platform-tests/css/css-pseudo-4/marker-color.html:
+ * web-platform-tests/css/css-pseudo-4/marker-font-properties.html:
+ * web-platform-tests/css/css-pseudo-4/w3c-import.log:
+
2018-01-08 Commit Queue <[email protected]>
Unreviewed, rolling out r226532 and r226540.
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/first-letter-004-expected.html (0 => 226614)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/first-letter-004-expected.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/first-letter-004-expected.html 2018-01-09 06:41:18 UTC (rev 226614)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Reference</title>
+<style>
+ div {
+ font-size: 36px;
+ }
+ span {
+ color: green;
+ }
+</style>
+<body>
+ <p>Test passes if the "T" and surrounding punctuation below are green.</p>
+ <div><span>၎̀T̀၎̀</span>est</div>
+</body>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/first-letter-004.html (0 => 226614)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/first-letter-004.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/first-letter-004.html 2018-01-09 06:41:18 UTC (rev 226614)
@@ -0,0 +1,24 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>CSS Test: ::first-letter formatting</title>
+ <link rel="author" title="Chris Nardi" href=""
+ <link rel="match" href=""
+ <link rel="help" href=""
+ <meta name="flags" content="">
+ <meta name="assert" content="Test checks that punctuation and letters with combining characters still have proper ::first-letter styling.">
+ <style>
+ div {
+ font-size: 36px;
+ }
+ div::first-letter {
+ color: green;
+ }
+ </style>
+</head>
+<body>
+ <p>Test passes if the "T" and surrounding punctuation below are green.</p>
+ <div>၎̀T̀၎̀est</div>
+</body>
+</html>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/marker-color-expected.html (226613 => 226614)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/marker-color-expected.html 2018-01-09 06:19:20 UTC (rev 226613)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/marker-color-expected.html 2018-01-09 06:41:18 UTC (rev 226614)
@@ -14,7 +14,7 @@
</head>
<body>
<ol>
- <li><!-- The list marker should be a green square. --></li>
+ <li><!-- The list marker should be a green square.--></li>
</ol>
</body>
</html>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/marker-color.html (226613 => 226614)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/marker-color.html 2018-01-09 06:19:20 UTC (rev 226613)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/marker-color.html 2018-01-09 06:41:18 UTC (rev 226614)
@@ -21,7 +21,7 @@
</head>
<body>
<ol>
- <li><!-- The list marker should be a green square. --></li>
+ <li><!-- The list marker should be a green square.--></li>
</ol>
</body>
</html>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/marker-font-properties.html (226613 => 226614)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/marker-font-properties.html 2018-01-09 06:19:20 UTC (rev 226613)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/marker-font-properties.html 2018-01-09 06:41:18 UTC (rev 226614)
@@ -27,7 +27,7 @@
</head>
<body>
<ol>
- <li><span style="font-size: 24px"><!-- FIXME: Needed to ensure consistent baseline position with expected result in WebKit (why?). --></span></li>
+ <li><span style="font-size: 24px"><!-- FIXME: Needed to ensure consistent baseline position with expected result in WebKit (why?). --></span></li>
</ol>
</body>
</html>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/w3c-import.log (226613 => 226614)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/w3c-import.log 2018-01-09 06:19:20 UTC (rev 226613)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/w3c-import.log 2018-01-09 06:41:18 UTC (rev 226614)
@@ -21,6 +21,8 @@
/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/first-letter-002.html
/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/first-letter-003-expected.html
/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/first-letter-003.html
+/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/first-letter-004-expected.html
+/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/first-letter-004.html
/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/marker-and-other-pseudo-elements-expected.html
/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/marker-and-other-pseudo-elements.html
/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/marker-color-expected.html
Deleted: trunk/LayoutTests/platform/gtk/fast/css/first-letter-punctuation-expected.png
(Binary files differ)
Deleted: trunk/LayoutTests/platform/gtk/fast/css/first-letter-punctuation-expected.txt (226613 => 226614)
--- trunk/LayoutTests/platform/gtk/fast/css/first-letter-punctuation-expected.txt 2018-01-09 06:19:20 UTC (rev 226613)
+++ trunk/LayoutTests/platform/gtk/fast/css/first-letter-punctuation-expected.txt 2018-01-09 06:41:18 UTC (rev 226614)
@@ -1,32 +0,0 @@
-layer at (0,0) size 800x600
- RenderView at (0,0) size 800x600
-layer at (0,0) size 800x226
- RenderBlock {HTML} at (0,0) size 800x226
- RenderBody {BODY} at (8,16) size 784x202
- RenderBlock {P} at (0,0) size 784x18
- RenderText {#text} at (0,0) size 391x17
- text run at (0,0) width 391: "Test passes if all the T and surrounding punctuation are green."
- RenderBlock {DIV} at (0,34) size 784x42
- RenderInline (generated) at (0,0) size 46x40 [color=#008000]
- RenderText at (0,1) size 46x40
- text run at (0,1) width 46: "(T)"
- RenderText {#text} at (46,19) size 17x17
- text run at (46,19) width 17: "est"
- RenderBlock {DIV} at (0,76) size 784x42
- RenderInline (generated) at (0,0) size 54x40 [color=#008000]
- RenderText at (0,1) size 54x40
- text run at (0,1) width 54: "\x{201C}T\x{201D}"
- RenderText {#text} at (54,19) size 17x17
- text run at (54,19) width 17: "est"
- RenderBlock {DIV} at (0,118) size 784x42
- RenderInline (generated) at (0,0) size 76x40 [color=#008000]
- RenderText at (0,1) size 76x40
- text run at (0,1) width 76: "\x{AB} T \x{BB}"
- RenderText {#text} at (76,19) size 17x17
- text run at (76,19) width 17: "est"
- RenderBlock {DIV} at (0,160) size 784x42
- RenderInline (generated) at (0,0) size 76x40 [color=#008000]
- RenderText at (0,1) size 76x40
- text run at (0,1) width 76: "\x{AB} T \x{BB}"
- RenderText {#text} at (76,19) size 33x17
- text run at (76,19) width 33: " est"
Deleted: trunk/LayoutTests/platform/ios/fast/css/first-letter-punctuation-expected.txt (226613 => 226614)
--- trunk/LayoutTests/platform/ios/fast/css/first-letter-punctuation-expected.txt 2018-01-09 06:19:20 UTC (rev 226613)
+++ trunk/LayoutTests/platform/ios/fast/css/first-letter-punctuation-expected.txt 2018-01-09 06:41:18 UTC (rev 226614)
@@ -1,32 +0,0 @@
-layer at (0,0) size 800x600
- RenderView at (0,0) size 800x600
-layer at (0,0) size 800x232
- RenderBlock {HTML} at (0,0) size 800x232
- RenderBody {BODY} at (8,16) size 784x208
- RenderBlock {P} at (0,0) size 784x20
- RenderText {#text} at (0,0) size 398x19
- text run at (0,0) width 398: "Test passes if all the T and surrounding punctuation are green."
- RenderBlock {DIV} at (0,36) size 784x43
- RenderInline (generated) at (0,0) size 46x41 [color=#008000]
- RenderText at (0,1) size 46x41
- text run at (0,1) width 46: "(T)"
- RenderText {#text} at (45,19) size 19x19
- text run at (45,19) width 19: "est"
- RenderBlock {DIV} at (0,79) size 784x43
- RenderInline (generated) at (0,0) size 54x41 [color=#008000]
- RenderText at (0,1) size 54x41
- text run at (0,1) width 54: "\x{201C}T\x{201D}"
- RenderText {#text} at (53,19) size 19x19
- text run at (53,19) width 19: "est"
- RenderBlock {DIV} at (0,122) size 784x43
- RenderInline (generated) at (0,0) size 76x41 [color=#008000]
- RenderText at (0,1) size 76x41
- text run at (0,1) width 76: "\x{AB} T \x{BB}"
- RenderText {#text} at (75,19) size 19x19
- text run at (75,19) width 19: "est"
- RenderBlock {DIV} at (0,165) size 784x43
- RenderInline (generated) at (0,0) size 76x41 [color=#008000]
- RenderText at (0,1) size 76x41
- text run at (0,1) width 76: "\x{AB} T \x{BB}"
- RenderText {#text} at (75,19) size 35x19
- text run at (75,19) width 35: " est"
Deleted: trunk/LayoutTests/platform/mac/fast/css/first-letter-punctuation-expected.png
(Binary files differ)
Deleted: trunk/LayoutTests/platform/mac/fast/css/first-letter-punctuation-expected.txt (226613 => 226614)
--- trunk/LayoutTests/platform/mac/fast/css/first-letter-punctuation-expected.txt 2018-01-09 06:19:20 UTC (rev 226613)
+++ trunk/LayoutTests/platform/mac/fast/css/first-letter-punctuation-expected.txt 2018-01-09 06:41:18 UTC (rev 226614)
@@ -1,32 +0,0 @@
-layer at (0,0) size 800x600
- RenderView at (0,0) size 800x600
-layer at (0,0) size 800x222
- RenderBlock {HTML} at (0,0) size 800x222
- RenderBody {BODY} at (8,16) size 784x198
- RenderBlock {P} at (0,0) size 784x18
- RenderText {#text} at (0,0) size 398x18
- text run at (0,0) width 398: "Test passes if all the T and surrounding punctuation are green."
- RenderBlock {DIV} at (0,34) size 784x41
- RenderInline (generated) at (0,0) size 46x41 [color=#008000]
- RenderText at (0,0) size 46x41
- text run at (0,0) width 46: "(T)"
- RenderText {#text} at (45,18) size 19x18
- text run at (45,18) width 19: "est"
- RenderBlock {DIV} at (0,75) size 784x41
- RenderInline (generated) at (0,0) size 54x41 [color=#008000]
- RenderText at (0,0) size 54x41
- text run at (0,0) width 54: "\x{201C}T\x{201D}"
- RenderText {#text} at (53,18) size 19x18
- text run at (53,18) width 19: "est"
- RenderBlock {DIV} at (0,116) size 784x41
- RenderInline (generated) at (0,0) size 76x41 [color=#008000]
- RenderText at (0,0) size 76x41
- text run at (0,0) width 76: "\x{AB} T \x{BB}"
- RenderText {#text} at (75,18) size 19x18
- text run at (75,18) width 19: "est"
- RenderBlock {DIV} at (0,157) size 784x41
- RenderInline (generated) at (0,0) size 76x41 [color=#008000]
- RenderText at (0,0) size 76x41
- text run at (0,0) width 76: "\x{AB} T \x{BB}"
- RenderText {#text} at (75,18) size 35x18
- text run at (75,18) width 35: " est"
Deleted: trunk/LayoutTests/platform/win/fast/css/first-letter-punctuation-expected.txt (226613 => 226614)
--- trunk/LayoutTests/platform/win/fast/css/first-letter-punctuation-expected.txt 2018-01-09 06:19:20 UTC (rev 226613)
+++ trunk/LayoutTests/platform/win/fast/css/first-letter-punctuation-expected.txt 2018-01-09 06:41:18 UTC (rev 226614)
@@ -1,32 +0,0 @@
-layer at (0,0) size 800x600
- RenderView at (0,0) size 800x600
-layer at (0,0) size 800x222
- RenderBlock {HTML} at (0,0) size 800x222
- RenderBody {BODY} at (8,16) size 784x198
- RenderBlock {P} at (0,0) size 784x18
- RenderText {#text} at (0,0) size 391x18
- text run at (0,0) width 391: "Test passes if all the T and surrounding punctuation are green."
- RenderBlock {DIV} at (0,34) size 784x41
- RenderInline (generated) at (0,0) size 46x41 [color=#008000]
- RenderText at (0,0) size 46x41
- text run at (0,0) width 46: "(T)"
- RenderText {#text} at (46,18) size 17x18
- text run at (46,18) width 17: "est"
- RenderBlock {DIV} at (0,75) size 784x41
- RenderInline (generated) at (0,0) size 54x41 [color=#008000]
- RenderText at (0,0) size 54x41
- text run at (0,0) width 54: "\x{201C}T\x{201D}"
- RenderText {#text} at (54,18) size 17x18
- text run at (54,18) width 17: "est"
- RenderBlock {DIV} at (0,116) size 784x41
- RenderInline (generated) at (0,0) size 76x41 [color=#008000]
- RenderText at (0,0) size 76x41
- text run at (0,0) width 76: "\x{AB} T \x{BB}"
- RenderText {#text} at (76,18) size 17x18
- text run at (76,18) width 17: "est"
- RenderBlock {DIV} at (0,157) size 784x41
- RenderInline (generated) at (0,0) size 76x41 [color=#008000]
- RenderText at (0,0) size 76x41
- text run at (0,0) width 76: "\x{AB} T \x{BB}"
- RenderText {#text} at (76,18) size 33x18
- text run at (76,18) width 33: " est"
Modified: trunk/Source/WebCore/ChangeLog (226613 => 226614)
--- trunk/Source/WebCore/ChangeLog 2018-01-09 06:19:20 UTC (rev 226613)
+++ trunk/Source/WebCore/ChangeLog 2018-01-09 06:41:18 UTC (rev 226614)
@@ -1,3 +1,21 @@
+2018-01-08 Chris Nardi <[email protected]>
+
+ ::first-letter incorrectly selects grapheme pairs
+ https://bugs.webkit.org/show_bug.cgi?id=181315
+
+ Reviewed by Darin Adler.
+
+ Grapheme pairs were incorrectly selected by ::first-letter. This
+ change fixes their selection.
+
+ Tests: Updated fast/css/first-letter-punctuation.html and imported
+ LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo-4/first-letter-004.html
+
+ * rendering/updating/RenderTreeBuilderFirstLetter.cpp:
+ (WebCore::isPunctuationForFirstLetter):
+ (WebCore::shouldSkipForFirstLetter):
+ (WebCore::RenderTreeBuilder::FirstLetter::createRenderers):
+
2018-01-08 Darin Adler <[email protected]>
Special list-item counter starts from an incorrect number for ::before and ::after
Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp (226613 => 226614)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp 2018-01-09 06:19:20 UTC (rev 226613)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp 2018-01-09 06:41:18 UTC (rev 226614)
@@ -91,12 +91,12 @@
// CSS 2.1 http://www.w3.org/TR/CSS21/selector.html#first-letter
// "Punctuation (i.e, characters defined in Unicode [UNICODE] in the "open" (Ps), "close" (Pe),
// "initial" (Pi). "final" (Pf) and "other" (Po) punctuation classes), that precedes or follows the first letter should be included"
-static inline bool isPunctuationForFirstLetter(UChar c)
+static inline bool isPunctuationForFirstLetter(UChar32 c)
{
return U_GET_GC_MASK(c) & (U_GC_PS_MASK | U_GC_PE_MASK | U_GC_PI_MASK | U_GC_PF_MASK | U_GC_PO_MASK);
}
-static inline bool shouldSkipForFirstLetter(UChar c)
+static inline bool shouldSkipForFirstLetter(UChar32 c)
{
return isSpaceOrNewline(c) || c == noBreakSpace || isPunctuationForFirstLetter(c);
}
@@ -218,8 +218,8 @@
unsigned length = 0;
// Account for leading spaces and punctuation.
- while (length < oldText.length() && shouldSkipForFirstLetter(oldText[length]))
- length++;
+ while (length < oldText.length() && shouldSkipForFirstLetter(oldText.characterStartingAt(length)))
+ length += numCharactersInGraphemeClusters(StringView(oldText).substring(length), 1);
// Account for first grapheme cluster.
length += numCharactersInGraphemeClusters(StringView(oldText).substring(length), 1);
@@ -226,14 +226,17 @@
// Keep looking for whitespace and allowed punctuation, but avoid
// accumulating just whitespace into the :first-letter.
- for (unsigned scanLength = length; scanLength < oldText.length(); ++scanLength) {
- UChar c = oldText[scanLength];
+ unsigned numCharacters = 0;
+ for (unsigned scanLength = length; scanLength < oldText.length(); scanLength += numCharacters) {
+ UChar32 c = oldText.characterStartingAt(scanLength);
if (!shouldSkipForFirstLetter(c))
break;
+ numCharacters = numCharactersInGraphemeClusters(StringView(oldText).substring(scanLength), 1);
+
if (isPunctuationForFirstLetter(c))
- length = scanLength + 1;
+ length = scanLength + numCharacters;
}
auto* textNode = currentTextChild.textNode();