Title: [124518] trunk
Revision
124518
Author
[email protected]
Date
2012-08-02 15:50:52 -0700 (Thu, 02 Aug 2012)

Log Message

Built in quotes don't use lang attribute
https://bugs.webkit.org/show_bug.cgi?id=92918

Patch by Elliott Sprehn <[email protected]> on 2012-08-02
Reviewed by Alexey Proskuryakov.

Source/WebCore:

Previously even though there was a table in RenderQuote of languages mapped
to quotes we always used basic quotes. This patch removes the broken tree
walking and uses Element::computeInheritedLanguage fixing this.

Tests: fast/css-generated-content/quotes-lang-expected.html
       fast/css-generated-content/quotes-lang.html
       fast/css-generated-content/quotes-xml-lang-expected.html
       fast/css-generated-content/quotes-xml-lang.html

* rendering/RenderQuote.cpp:
(WebCore::RenderQuote::originalText):
(WebCore::RenderQuote::quotesData): New method that determines the right QuotesData to use.
(WebCore):
* rendering/RenderQuote.h:
(RenderQuote):

LayoutTests:

Add a test that the built in quote languages are used and that custom
languages work as well. This also tests that xml:lang takes precedence
over lang.

* fast/css-generated-content/quotes-lang-expected.html: Added.
* fast/css-generated-content/quotes-lang.html: Added.
* fast/css-generated-content/quotes-xml-lang-expected.html: Added.
* fast/css-generated-content/quotes-xml-lang.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (124517 => 124518)


--- trunk/LayoutTests/ChangeLog	2012-08-02 22:48:27 UTC (rev 124517)
+++ trunk/LayoutTests/ChangeLog	2012-08-02 22:50:52 UTC (rev 124518)
@@ -1,3 +1,19 @@
+2012-08-02  Elliott Sprehn  <[email protected]>
+
+        Built in quotes don't use lang attribute
+        https://bugs.webkit.org/show_bug.cgi?id=92918
+
+        Reviewed by Alexey Proskuryakov.
+
+        Add a test that the built in quote languages are used and that custom
+        languages work as well. This also tests that xml:lang takes precedence
+        over lang.
+
+        * fast/css-generated-content/quotes-lang-expected.html: Added.
+        * fast/css-generated-content/quotes-lang.html: Added.
+        * fast/css-generated-content/quotes-xml-lang-expected.html: Added.
+        * fast/css-generated-content/quotes-xml-lang.html: Added.
+
 2012-06-15  David Barton  <[email protected]>
 
         MathML: nested square root symbols have varying descenders

Added: trunk/LayoutTests/fast/css-generated-content/quotes-lang-expected.html (0 => 124518)


--- trunk/LayoutTests/fast/css-generated-content/quotes-lang-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-generated-content/quotes-lang-expected.html	2012-08-02 22:50:52 UTC (rev 124518)
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+
+<style>
+    span:before, span:after { content: '"'; }
+
+    .example:before, .example > span:before { content: "A"; }
+    .example:after, .example > span:after { content: "B"; }
+
+    .en:before { content: "\201C"; }
+    .en:after { content: "\201D"; }
+    .en > span:before { content: "\2018"; }
+    .en > span:after { content: "\2019"; }
+
+    .no:before { content: "\00AB"; }
+    .no:after { content: "\00BB"; }
+    .no > span:before { content: "\2039"; }
+    .no > span:after { content: "\203A"; }
+
+    .ro:before, .ro > span:before { content: "\201E"; }
+    .ro:after, .ro > span:after { content: "\201D"; }
+
+    .ru:before { content: "\00AB"; }
+    .ru:after { content: "\00BB"; }
+    .ru > span:before { content: "\201E"; }
+    .ru > span:after { content: "\201C"; }
+</style>
+
+<p>
+    You should see the quotes for the specified language on each line below,
+    and not just basic " and ' characters unless no language is specified.
+</p>
+
+<span></span>
+<br>
+
+<span class="en"><span>en</span></span>
+<br>
+
+<span class="no"><span>no</span></span>
+<br>
+
+<span class="ro"><span>ro</span></span>
+<br>
+
+<span class="ru"><span>ru</span></span>
+<br>
+
+<span class="example"><span>example</span></span>
+<br>
+
+<p>
+    <span class="example">example</span>
+</p>

Added: trunk/LayoutTests/fast/css-generated-content/quotes-lang.html (0 => 124518)


--- trunk/LayoutTests/fast/css-generated-content/quotes-lang.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-generated-content/quotes-lang.html	2012-08-02 22:50:52 UTC (rev 124518)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+
+<style>
+   q:lang(example) {
+        quotes: "A" "B";
+   }
+</style>
+
+<p>
+    You should see the quotes for the specified language on each line below,
+    and not just basic " and ' characters unless no language is specified.
+</p>
+
+<q></q>
+<br>
+
+<!-- These languages are from the map in RenderQuote -->
+<q lang="en"><q>en</q></q>
+<br>
+
+<q lang="no"><q>no</q></q>
+<br>
+
+<q lang="ro"><q>ro</q></q>
+<br>
+
+<q lang="ru"><q>ru</q></q>
+<br>
+
+<q lang="example"><q>example</q></q>
+<br>
+
+<div lang="example">
+    <p>
+        <q>example</q>
+    </p>
+</div>

Added: trunk/LayoutTests/fast/css-generated-content/quotes-xml-lang-expected.xhtml (0 => 124518)


--- trunk/LayoutTests/fast/css-generated-content/quotes-xml-lang-expected.xhtml	                        (rev 0)
+++ trunk/LayoutTests/fast/css-generated-content/quotes-xml-lang-expected.xhtml	2012-08-02 22:50:52 UTC (rev 124518)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <head>
+        <style>
+            span:before { content: "\00AB"; }
+            span:after { content: "\00BB"; }
+        </style>
+    </head>
+    <body>
+        <p>
+            You should see russian quotes because xml:lang takes precedence:
+            <a href=""
+        </p>
+
+        <span></span>
+    </body>
+</html>

Added: trunk/LayoutTests/fast/css-generated-content/quotes-xml-lang.xhtml (0 => 124518)


--- trunk/LayoutTests/fast/css-generated-content/quotes-xml-lang.xhtml	                        (rev 0)
+++ trunk/LayoutTests/fast/css-generated-content/quotes-xml-lang.xhtml	2012-08-02 22:50:52 UTC (rev 124518)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <body>
+        <p>
+            You should see russian quotes because xml:lang takes precedence:
+            <a href=""
+        </p>
+
+        <q xml:lang="ru" lang="en"></q>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (124517 => 124518)


--- trunk/Source/WebCore/ChangeLog	2012-08-02 22:48:27 UTC (rev 124517)
+++ trunk/Source/WebCore/ChangeLog	2012-08-02 22:50:52 UTC (rev 124518)
@@ -1,3 +1,26 @@
+2012-08-02  Elliott Sprehn  <[email protected]>
+
+        Built in quotes don't use lang attribute
+        https://bugs.webkit.org/show_bug.cgi?id=92918
+
+        Reviewed by Alexey Proskuryakov.
+
+        Previously even though there was a table in RenderQuote of languages mapped
+        to quotes we always used basic quotes. This patch removes the broken tree
+        walking and uses Element::computeInheritedLanguage fixing this.
+
+        Tests: fast/css-generated-content/quotes-lang-expected.html
+               fast/css-generated-content/quotes-lang.html
+               fast/css-generated-content/quotes-xml-lang-expected.html
+               fast/css-generated-content/quotes-xml-lang.html
+
+        * rendering/RenderQuote.cpp:
+        (WebCore::RenderQuote::originalText):
+        (WebCore::RenderQuote::quotesData): New method that determines the right QuotesData to use.
+        (WebCore):
+        * rendering/RenderQuote.h:
+        (RenderQuote):
+
 2012-08-02  Adam Barth  <[email protected]>
 
         Add back a header I mistakenly removed in my previous commit.

Modified: trunk/Source/WebCore/rendering/RenderQuote.cpp (124517 => 124518)


--- trunk/Source/WebCore/rendering/RenderQuote.cpp	2012-08-02 22:48:27 UTC (rev 124517)
+++ trunk/Source/WebCore/rendering/RenderQuote.cpp	2012-08-02 22:50:52 UTC (rev 124518)
@@ -22,8 +22,6 @@
 #include "RenderQuote.h"
 
 #include "Document.h"
-#include "Element.h"
-#include "HTMLElement.h"
 #include "QuotesData.h"
 #include "RenderStyle.h"
 #include <wtf/text/AtomicString.h>
@@ -157,42 +155,12 @@
     return staticBasicQuotes;
 }
 
-static const QuotesData* defaultQuotes(const RenderObject* object)
-{
-    DEFINE_STATIC_LOCAL(String, langString, ("lang"));
-    Node* node =  object->generatingNode();
-    Element* element;
-    if (!node) {
-        element = object->document()->body();
-        if (!element)
-            element = object->document()->documentElement();
-    } else if (!node->isElementNode()) {
-        element = node->parentElement();
-        if (!element)
-            return basicQuotesData();
-    } else
-      element = toElement(node);
-    AtomicString language = element->getAttribute(langString);
-    while (language.isNull()) {
-        element = element->parentElement();
-        if (!element)
-            return basicQuotesData();
-        language = element->getAttribute(langString);
-    }
-    const QuotesData* quotesData = quotesDataLanguageMap().get(language);
-    if (!quotesData)
-        return basicQuotesData();
-    return quotesData;
-}
-
 PassRefPtr<StringImpl> RenderQuote::originalText() const
 {
     if (!parent())
         return 0;
     ASSERT(m_depth != UNKNOWN_DEPTH);
-    const QuotesData* quotes = style()->quotes();
-    if (!quotes)
-        quotes = defaultQuotes(this);
+    const QuotesData* quotes = quotesData();
     switch (m_type) {
     case NO_OPEN_QUOTE:
     case NO_CLOSE_QUOTE:
@@ -214,6 +182,20 @@
     RenderText::computePreferredLogicalWidths(lead);
 }
 
+const QuotesData* RenderQuote::quotesData() const
+{
+    if (QuotesData* customQuotes = style()->quotes())
+        return customQuotes;
+
+    AtomicString language = style()->locale();
+    if (language.isNull())
+        return basicQuotesData();
+    const QuotesData* quotes = quotesDataLanguageMap().get(language);
+    if (!quotes)
+        return basicQuotesData();
+    return quotes;
+}
+
 void RenderQuote::rendererSubtreeAttached(RenderObject* renderer)
 {
     ASSERT(renderer->view());

Modified: trunk/Source/WebCore/rendering/RenderQuote.h (124517 => 124518)


--- trunk/Source/WebCore/rendering/RenderQuote.h	2012-08-02 22:48:27 UTC (rev 124517)
+++ trunk/Source/WebCore/rendering/RenderQuote.h	2012-08-02 22:50:52 UTC (rev 124518)
@@ -41,6 +41,8 @@
     virtual bool isQuote() const { return true; };
     virtual PassRefPtr<StringImpl> originalText() const;
     virtual void computePreferredLogicalWidths(float leadWidth);
+    const QuotesData* quotesData() const;
+
     QuoteType m_type;
     int m_depth;
     RenderQuote* m_next;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to