Catch up ruby and its tag omission rule changes in HTML5 CR Feb 2014
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Apr 2014 17:41:38 +0000 (17:41 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Apr 2014 17:41:38 +0000 (17:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=131175

Patch by Koji Ishii <kojishi@gmail.com> on 2014-04-17
Reviewed by Darin Adler.

Source/WebCore:
Tests: html5lib/resources/ruby.dat
       html5lib/resources/tests19.dat

This patch makes WebKit HTML parser to match to the tag omission rules of HTML5 CR Feb 2014:
http://www.w3.org/TR/2014/CR-html5-20140204/syntax.html#syntax-tag-omission
with the support for two new elements (rb, rtc) which were also defined in the spec:
http://www.w3.org/TR/2014/CR-html5-20140204/text-level-semantics.html#the-rb-element
http://www.w3.org/TR/2014/CR-html5-20140204/text-level-semantics.html#the-rtc-element
to better support use cases presented by W3C I18N WG:
http://www.w3.org/TR/ruby-use-cases/

* html/HTMLTagNames.in: rb and rtc added as HTMLElement interfaces.
* html/parser/HTMLConstructionSite.cpp:
(WebCore::hasImpliedEndTag): the spec says rb and rtc have implied end tags.
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::processStartTagForInBody): rb and rtc added. rt excludes rtc from its implied end tags.

LayoutTests:
25 new test cases in 2 test files imported from pull requests to html5lib-tests,
with run- and expected-files generated.
All new tests pass with the changes included in this patch.

* html5lib/generated/run-ruby-data-expected.txt: Added.
* html5lib/generated/run-ruby-data.html: Added (generated by generate-test-wrappers.py)
* html5lib/generated/run-ruby-write-expected.txt: Added.
* html5lib/generated/run-ruby-write.html: Added (generated by generate-test-wrappers.py)
* html5lib/resources/ruby.dat: Added from https://github.com/darobin/html5lib-tests/pull/1
* html5lib/resources/tests19.dat: Updated from https://github.com/html5lib/html5lib-tests/pull/27

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167437 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/html5lib/generated/run-ruby-data-expected.txt [new file with mode: 0644]
LayoutTests/html5lib/generated/run-ruby-data.html [new file with mode: 0644]
LayoutTests/html5lib/generated/run-ruby-write-expected.txt [new file with mode: 0644]
LayoutTests/html5lib/generated/run-ruby-write.html [new file with mode: 0644]
LayoutTests/html5lib/resources/ruby.dat [new file with mode: 0644]
LayoutTests/html5lib/resources/tests19.dat
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLTagNames.in
Source/WebCore/html/parser/HTMLConstructionSite.cpp
Source/WebCore/html/parser/HTMLTreeBuilder.cpp

index 65db8a8..3950aef 100644 (file)
@@ -1,3 +1,21 @@
+2014-04-17  Koji Ishii  <kojishi@gmail.com>
+
+        Catch up ruby and its tag omission rule changes in HTML5 CR Feb 2014
+        https://bugs.webkit.org/show_bug.cgi?id=131175
+
+        Reviewed by Darin Adler.
+
+        25 new test cases in 2 test files imported from pull requests to html5lib-tests,
+        with run- and expected-files generated.
+        All new tests pass with the changes included in this patch.
+
+        * html5lib/generated/run-ruby-data-expected.txt: Added.
+        * html5lib/generated/run-ruby-data.html: Added (generated by generate-test-wrappers.py)
+        * html5lib/generated/run-ruby-write-expected.txt: Added.
+        * html5lib/generated/run-ruby-write.html: Added (generated by generate-test-wrappers.py)
+        * html5lib/resources/ruby.dat: Added from https://github.com/darobin/html5lib-tests/pull/1
+        * html5lib/resources/tests19.dat: Updated from https://github.com/html5lib/html5lib-tests/pull/27
+
 2014-04-17  Alexey Proskuryakov  <ap@apple.com>
 
         Don't skip inspector/dom/content-flow-list.html and inspector/dom/content-flow-content-removal.html.
diff --git a/LayoutTests/html5lib/generated/run-ruby-data-expected.txt b/LayoutTests/html5lib/generated/run-ruby-data-expected.txt
new file mode 100644 (file)
index 0000000..3b5d176
--- /dev/null
@@ -0,0 +1 @@
+../resources/ruby.dat: PASS
diff --git a/LayoutTests/html5lib/generated/run-ruby-data.html b/LayoutTests/html5lib/generated/run-ruby-data.html
new file mode 100644 (file)
index 0000000..8ddf4e6
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<script>
+var test_files = [ '../resources/ruby.dat' ]
+</script>
+<script src="../../resources/dump-as-markup.js"></script>
+<script>window.forceDataURLs = true;</script>
+<script src="../resources/runner.js"></script>
diff --git a/LayoutTests/html5lib/generated/run-ruby-write-expected.txt b/LayoutTests/html5lib/generated/run-ruby-write-expected.txt
new file mode 100644 (file)
index 0000000..3b5d176
--- /dev/null
@@ -0,0 +1 @@
+../resources/ruby.dat: PASS
diff --git a/LayoutTests/html5lib/generated/run-ruby-write.html b/LayoutTests/html5lib/generated/run-ruby-write.html
new file mode 100644 (file)
index 0000000..2b53521
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<script>
+var test_files = [ '../resources/ruby.dat' ]
+</script>
+<script src="../../resources/dump-as-markup.js"></script>
+
+<script src="../resources/runner.js"></script>
diff --git a/LayoutTests/html5lib/resources/ruby.dat b/LayoutTests/html5lib/resources/ruby.dat
new file mode 100644 (file)
index 0000000..80d0c53
--- /dev/null
@@ -0,0 +1,298 @@
+#data
+<html><ruby>a<rb>b<rb></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rb>
+|         "b"
+|       <rb>
+
+#data
+<html><ruby>a<rb>b<rt></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rb>
+|         "b"
+|       <rt>
+
+#data
+<html><ruby>a<rb>b<rtc></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rb>
+|         "b"
+|       <rtc>
+
+#data
+<html><ruby>a<rb>b<rp></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rb>
+|         "b"
+|       <rp>
+
+#data
+<html><ruby>a<rb>b<span></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rb>
+|         "b"
+|         <span>
+
+#data
+<html><ruby>a<rt>b<rb></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rt>
+|         "b"
+|       <rb>
+
+#data
+<html><ruby>a<rt>b<rt></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rt>
+|         "b"
+|       <rt>
+
+#data
+<html><ruby>a<rt>b<rtc></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rt>
+|         "b"
+|       <rtc>
+
+#data
+<html><ruby>a<rt>b<rp></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rt>
+|         "b"
+|       <rp>
+
+#data
+<html><ruby>a<rt>b<span></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rt>
+|         "b"
+|         <span>
+
+#data
+<html><ruby>a<rtc>b<rb></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rtc>
+|         "b"
+|       <rb>
+
+#data
+<html><ruby>a<rtc>b<rt>c<rt>d</ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rtc>
+|         "b"
+|         <rt>
+|           "c"
+|         <rt>
+|           "d"
+
+#data
+<html><ruby>a<rtc>b<rtc></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rtc>
+|         "b"
+|       <rtc>
+
+#data
+<html><ruby>a<rtc>b<rp></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rtc>
+|         "b"
+|       <rp>
+
+#data
+<html><ruby>a<rtc>b<span></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rtc>
+|         "b"
+|         <span>
+
+#data
+<html><ruby>a<rp>b<rb></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rp>
+|         "b"
+|       <rb>
+
+#data
+<html><ruby>a<rp>b<rt></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rp>
+|         "b"
+|       <rt>
+
+#data
+<html><ruby>a<rp>b<rtc></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rp>
+|         "b"
+|       <rtc>
+
+#data
+<html><ruby>a<rp>b<rp></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rp>
+|         "b"
+|       <rp>
+
+#data
+<html><ruby>a<rp>b<span></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rp>
+|         "b"
+|         <span>
+
+#data
+<html><ruby><rtc><ruby>a<rb>b<rt></ruby></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       <rtc>
+|         <ruby>
+|           "a"
+|           <rb>
+|             "b"
+|           <rt>
index 9e7e03f..cd1be6e 100644 (file)
 |         <rt>
 
 #data
+<html><ruby>a<rb>b<rt></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rb>
+|         "b"
+|       <rt>
+
+#data
+<html><ruby>a<rp>b<rt></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rp>
+|         "b"
+|       <rt>
+
+#data
+<html><ruby>a<rt>b<rt></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rt>
+|         "b"
+|       <rt>
+
+#data
+<html><ruby>a<rtc>b<rt>c<rb>d</ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+|   <head>
+|   <body>
+|     <ruby>
+|       "a"
+|       <rtc>
+|         "b"
+|         <rt>
+|           "c"
+|       <rb>
+|         "d"
+
+#data
 <!doctype html><math/><foo>
 #errors
 (1,27): expected-closing-tag-but-got-eof
index 2ffeeb4..159d5fe 100644 (file)
@@ -1,3 +1,27 @@
+2014-04-17  Koji Ishii  <kojishi@gmail.com>
+
+        Catch up ruby and its tag omission rule changes in HTML5 CR Feb 2014
+        https://bugs.webkit.org/show_bug.cgi?id=131175
+
+        Reviewed by Darin Adler.
+
+        Tests: html5lib/resources/ruby.dat
+               html5lib/resources/tests19.dat
+
+        This patch makes WebKit HTML parser to match to the tag omission rules of HTML5 CR Feb 2014:
+        http://www.w3.org/TR/2014/CR-html5-20140204/syntax.html#syntax-tag-omission
+        with the support for two new elements (rb, rtc) which were also defined in the spec:
+        http://www.w3.org/TR/2014/CR-html5-20140204/text-level-semantics.html#the-rb-element
+        http://www.w3.org/TR/2014/CR-html5-20140204/text-level-semantics.html#the-rtc-element
+        to better support use cases presented by W3C I18N WG:
+        http://www.w3.org/TR/ruby-use-cases/
+
+        * html/HTMLTagNames.in: rb and rtc added as HTMLElement interfaces.
+        * html/parser/HTMLConstructionSite.cpp:
+        (WebCore::hasImpliedEndTag): the spec says rb and rtc have implied end tags.
+        * html/parser/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processStartTagForInBody): rb and rtc added. rt excludes rtc from its implied end tags.
+
 2014-04-17  Darin Adler  <darin@apple.com>
 
         Try to fix EFL and GTK builds.
index 5fc8634..73f4560 100644 (file)
@@ -100,8 +100,10 @@ plaintext interfaceName=HTMLElement
 pre
 progress interfaceName=HTMLProgressElement, conditional=PROGRESS_ELEMENT, generateTypeHelpers
 q interfaceName=HTMLQuoteElement
+rb interfaceName=HTMLElement
 rp interfaceName=HTMLElement
 rt interfaceName=HTMLElement
+rtc interfaceName=HTMLElement
 ruby interfaceName=HTMLElement
 s interfaceName=HTMLElement
 samp interfaceName=HTMLElement
index 3407d29..0cfe602 100644 (file)
@@ -64,8 +64,10 @@ static bool hasImpliedEndTag(const HTMLStackItem* item)
         || isHTMLOptionElement(item->node())
         || isHTMLOptGroupElement(item->node())
         || item->hasTagName(pTag)
+        || item->hasTagName(rbTag)
         || item->hasTagName(rpTag)
-        || item->hasTagName(rtTag);
+        || item->hasTagName(rtTag)
+        || item->hasTagName(rtcTag);
 }
 
 static bool shouldUseLengthLimit(const ContainerNode* node)
index 40144f8..69d86d6 100644 (file)
@@ -876,7 +876,7 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken* token)
         m_tree.insertHTMLElement(token);
         return;
     }
-    if (token->name() == rpTag || token->name() == rtTag) {
+    if (token->name() == rbTag || token->name() == rpTag || token->name() == rtcTag) {
         if (m_tree.openElements()->inScope(rubyTag.localName())) {
             m_tree.generateImpliedEndTags();
             if (!m_tree.currentStackItem()->hasTagName(rubyTag))
@@ -885,6 +885,15 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken* token)
         m_tree.insertHTMLElement(token);
         return;
     }
+    if (token->name() == rtTag) {
+        if (m_tree.openElements()->inScope(rubyTag.localName())) {
+            m_tree.generateImpliedEndTagsWithExclusion(rtcTag.localName());
+            if (!m_tree.currentStackItem()->hasTagName(rubyTag) && !m_tree.currentStackItem()->hasTagName(rtcTag))
+                parseError(token);
+        }
+        m_tree.insertHTMLElement(token);
+        return;
+    }
     if (token->name() == MathMLNames::mathTag.localName()) {
         m_tree.reconstructTheActiveFormattingElements();
         adjustMathMLAttributes(*token);