WebCore:
authorbfulgham@webkit.org <bfulgham@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jul 2009 04:42:50 +0000 (04:42 +0000)
committerbfulgham@webkit.org <bfulgham@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jul 2009 04:42:50 +0000 (04:42 +0000)
2009-07-09  Roland Steiner  <rolandsteiner@google.com>

        Reviewed by Maciej Stachowiak.

        Implement the part of HTML5 spec that deals with parsing of <rp> and <rt> tags
        in that their end tags are optional if followed by <rp>/<rt>.

        Also specify a new accessibility role "annotation" for <rp> and <rt>.

        Affected code parts are not enclosed in #IF ENABLE(RUBY), since the parsing
        is not affected by whether ruby is rendered properly or not (in fact, it may
        be more profound without ruby layouting, since the contents of <rp> are not hidden).

        Test: fast/ruby/parse-rp.html

        * accessibility/AccessibilityObject.h:
        (WebCore::):
        * accessibility/AccessibilityRenderObject.cpp:
        (WebCore::AccessibilityRenderObject::roleValue):
        * html/HTMLElement.cpp:
        (WebCore::HTMLElement::endTagRequirement):
        (WebCore::HTMLElement::tagPriority):
        (WebCore::inlineTagList):
        * html/HTMLParser.cpp:
        (WebCore::HTMLParser::rpCreateErrorCheck):
        (WebCore::HTMLParser::rtCreateErrorCheck):
        (WebCore::HTMLParser::getNode):
        * html/HTMLParser.h:
        * html/HTMLTagNames.in:

LayoutTests:

2009-07-09  Roland Steiner  <rolandsteiner@google.com>

        Reviewed by Maciej Stachowiak.

        Test proper parsing of HTML5 <rp> and <rt> tags.
        Both tags are optional if followed by another <rp>/<rt> tag.

        See also https://bugs.webkit.org/show_bug.cgi?id=26985

        * fast/ruby: Added.
        * fast/ruby/parse-rp-expected.txt: Added.
        * fast/ruby/parse-rp.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/ruby/parse-rp-expected.txt [new file with mode: 0644]
LayoutTests/fast/ruby/parse-rp.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/accessibility/AccessibilityObject.h
WebCore/accessibility/AccessibilityRenderObject.cpp
WebCore/html/HTMLElement.cpp
WebCore/html/HTMLParser.cpp
WebCore/html/HTMLParser.h
WebCore/html/HTMLTagNames.in

index f44764d..ff5d33f 100644 (file)
@@ -1,3 +1,16 @@
+2009-07-09  Roland Steiner  <rolandsteiner@google.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        Test proper parsing of HTML5 <rp> and <rt> tags.
+        Both tags are optional if followed by another <rp>/<rt> tag.
+        
+        See also https://bugs.webkit.org/show_bug.cgi?id=26985
+
+        * fast/ruby: Added.
+        * fast/ruby/parse-rp-expected.txt: Added.
+        * fast/ruby/parse-rp.html: Added.
+
 2009-07-09  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/ruby/parse-rp-expected.txt b/LayoutTests/fast/ruby/parse-rp-expected.txt
new file mode 100644 (file)
index 0000000..be982de
--- /dev/null
@@ -0,0 +1,5 @@
+The following is a test for parsing ruby <rp> and <rt> elements. According to HTML5 spec, end-tags for both are optional if followed by another <rp> or <rt>. However, they should NOT be auto-closed by other inline elements, such as <span>.
+
+TEST PASSED: Markup was correct
+
+Before base/left rp/text/right rp After
diff --git a/LayoutTests/fast/ruby/parse-rp.html b/LayoutTests/fast/ruby/parse-rp.html
new file mode 100644 (file)
index 0000000..1c57446
--- /dev/null
@@ -0,0 +1,22 @@
+<html>
+<head>
+<script>
+function test()
+{
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+    var markup = document.getElementById("ruby").outerHTML;
+    if (markup == '<ruby id="ruby">base/<rp><span>left</span> rp/</rp><rt>text/</rt><rp>right <span>rp</span></rp></ruby>')
+        result = "TEST PASSED: Markup was correct";
+    else
+        result = "TEST FAILED: Markup was " + markup;
+    document.getElementById("result").firstChild.data = result;
+}
+</script>
+</head>
+<body onload="test()">
+<p>The following is a test for parsing ruby &lt;rp&gt; and &lt;rt&gt; elements. According to HTML5 spec, end-tags for both are optional if followed by another &lt;rp&gt; or &lt;rt&gt;. However, they should NOT be auto-closed by other inline elements, such as &lt;span&gt;.</p>
+<p id="result">TEST DID NOT RUN</p>
+Before <ruby id="ruby">base/<rp><span>left</span> rp/<rt>text/<rp>right <span>rp</span></ruby> After
+</body>
+</html>
index fc64fcb..0e7516b 100644 (file)
@@ -1,3 +1,33 @@
+2009-07-09  Roland Steiner  <rolandsteiner@google.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        Implement the part of HTML5 spec that deals with parsing of <rp> and <rt> tags
+        in that their end tags are optional if followed by <rp>/<rt>.
+
+        Also specify a new accessibility role "annotation" for <rp> and <rt>.
+
+        Affected code parts are not enclosed in #IF ENABLE(RUBY), since the parsing
+        is not affected by whether ruby is rendered properly or not (in fact, it may 
+        be more profound without ruby layouting, since the contents of <rp> are not hidden).
+
+        Test: fast/ruby/parse-rp.html
+
+        * accessibility/AccessibilityObject.h:
+        (WebCore::):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::roleValue):
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::endTagRequirement):
+        (WebCore::HTMLElement::tagPriority):
+        (WebCore::inlineTagList):
+        * html/HTMLParser.cpp:
+        (WebCore::HTMLParser::rpCreateErrorCheck):
+        (WebCore::HTMLParser::rtCreateErrorCheck):
+        (WebCore::HTMLParser::getNode):
+        * html/HTMLParser.h:
+        * html/HTMLTagNames.in:
+
 2009-07-09  Dmitry Titov  <dimich@chromium.org>
 
         Not reviewed, fix for previous commit.
index 89f03e8..22a7f99 100644 (file)
@@ -151,7 +151,8 @@ enum AccessibilityRole {
     ListBoxOptionRole,
     TableHeaderContainerRole,
     DefinitionListTermRole,
-    DefinitionListDefinitionRole
+    DefinitionListDefinitionRole,
+    AnnotationRole
 };
 
 struct VisiblePositionRange {
index 47900ea..7d2ddc5 100644 (file)
@@ -2325,6 +2325,9 @@ AccessibilityRole AccessibilityRenderObject::roleValue() const
     if (node && node->hasTagName(dtTag))
         return DefinitionListTermRole;
 
+    if (node && (node->hasTagName(rpTag) || node->hasTagName(rtTag)))
+        return AnnotationRole;
+    
     if (m_renderer->isBlockFlow() || (node && node->hasTagName(labelTag)))
         return GroupRole;
     
index 5655df8..8acc6bd 100644 (file)
@@ -79,7 +79,7 @@ HTMLTagStatus HTMLElement::endTagRequirement() const
 {
     if (hasLocalName(wbrTag))
         return TagStatusForbidden;
-    if (hasLocalName(dtTag) || hasLocalName(ddTag))
+    if (hasLocalName(dtTag) || hasLocalName(ddTag) || hasLocalName(rpTag) || hasLocalName(rtTag))
         return TagStatusOptional;
 
     // Same values as <span>.  This way custom tag name elements will behave like inline spans.
@@ -90,9 +90,9 @@ int HTMLElement::tagPriority() const
 {
     if (hasLocalName(wbrTag))
         return 0;
-    if (hasLocalName(addressTag) || hasLocalName(ddTag) || hasLocalName(dtTag) || hasLocalName(noscriptTag))
+    if (hasLocalName(addressTag) || hasLocalName(ddTag) || hasLocalName(dtTag) || hasLocalName(noscriptTag) || hasLocalName(rpTag) || hasLocalName(rtTag))
         return 3;
-    if (hasLocalName(centerTag) || hasLocalName(nobrTag))
+    if (hasLocalName(centerTag) || hasLocalName(nobrTag) || hasLocalName(rubyTag))
         return 5;
     if (hasLocalName(noembedTag) || hasLocalName(noframesTag))
         return 10;
@@ -875,6 +875,9 @@ static HashSet<AtomicStringImpl*>* inlineTagList()
         tagList.add(audioTag.localName().impl());
         tagList.add(videoTag.localName().impl());
 #endif
+        tagList.add(rpTag.localName().impl());
+        tagList.add(rtTag.localName().impl());
+        tagList.add(rubyTag.localName().impl());
     }
     return &tagList;
 }
index ea6bbe2..6693b49 100644 (file)
@@ -793,6 +793,20 @@ bool HTMLParser::dtCreateErrorCheck(Token* t, RefPtr<Node>& result)
     return true;
 }
 
+bool HTMLParser::rpCreateErrorCheck(Token*, RefPtr<Node>&)
+{
+    popBlock(rpTag);
+    popBlock(rtTag);
+    return true;
+}
+
+bool HTMLParser::rtCreateErrorCheck(Token*, RefPtr<Node>&)
+{
+    popBlock(rpTag);
+    popBlock(rtTag);
+    return true;
+}
+
 bool HTMLParser::nestedCreateErrorCheck(Token* t, RefPtr<Node>&)
 {
     popBlock(t->tagName);
@@ -917,6 +931,8 @@ PassRefPtr<Node> HTMLParser::getNode(Token* t)
         gFunctionMap.set(pTag.localName().impl(), &HTMLParser::pCloserCreateErrorCheck);
         gFunctionMap.set(plaintextTag.localName().impl(), &HTMLParser::pCloserCreateErrorCheck);
         gFunctionMap.set(preTag.localName().impl(), &HTMLParser::pCloserCreateErrorCheck);
+        gFunctionMap.set(rpTag.localName().impl(), &HTMLParser::rpCreateErrorCheck);
+        gFunctionMap.set(rtTag.localName().impl(), &HTMLParser::rtCreateErrorCheck);
         gFunctionMap.set(sTag.localName().impl(), &HTMLParser::nestedStyleCreateErrorCheck);
         gFunctionMap.set(selectTag.localName().impl(), &HTMLParser::selectCreateErrorCheck);
         gFunctionMap.set(smallTag.localName().impl(), &HTMLParser::nestedStyleCreateErrorCheck);
index 19f553e..bd12049 100644 (file)
@@ -102,6 +102,8 @@ private:
     bool noscriptCreateErrorCheck(Token*, RefPtr<Node>&);
     bool pCloserCreateErrorCheck(Token*, RefPtr<Node>&);
     bool pCloserStrictCreateErrorCheck(Token*, RefPtr<Node>&);
+    bool rpCreateErrorCheck(Token*, RefPtr<Node>&);
+    bool rtCreateErrorCheck(Token*, RefPtr<Node>&);
     bool selectCreateErrorCheck(Token*, RefPtr<Node>&);
     bool tableCellCreateErrorCheck(Token*, RefPtr<Node>&);
     bool tableSectionCreateErrorCheck(Token*, RefPtr<Node>&);
index ae195fe..c066e3c 100644 (file)
@@ -89,6 +89,9 @@ param
 plaintext interfaceName=HTMLElement
 pre
 q interfaceName=HTMLQuoteElement
+rp interfaceName=HTMLElement
+rt interfaceName=HTMLElement
+ruby interfaceName=HTMLElement
 s interfaceName=HTMLElement
 samp interfaceName=HTMLElement
 script constructorNeedsCreatedByParser