[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Thu Apr 8 00:57:42 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 0e9174207339eaecdf249ae84d5450c9884cb82b
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 7 21:32:13 2010 +0000

    2010-01-07  Christian Sejersen  <christian.webkit at gmail.com>
    
            Reviewed by Darin Adler.
    
            document.title does not replace or remove space characters
            https://bugs.webkit.org/show_bug.cgi?id=27032
    
            * fast/dom/Document/document-title-get-expected.txt: Added.
            * fast/dom/Document/document-title-get.html: Added.
            * fast/dom/Document/script-tests/document-title-get.js: Added.
    2010-01-07  Christian Sejersen  <christian.webkit at gmail.com>
    
            Reviewed by Darin Adler.
    
            document.title does not replace or remove space characters
            https://bugs.webkit.org/show_bug.cgi?id=27032
    
            Test: fast/dom/Document/document-title-get.html
    
            * dom/Document.cpp:
            (WebCore::Document::Document):
            Initialization of m_rawTitle
            (WebCore::canonicalizedTitle):
            Moved from DocumentLoader.cpp with minor edits
            (WebCore::Document::updateTitle):
            Ensures the title is canonicalized
            (WebCore::Document::setTitle):
            Uses m_rawTitle instaed of m_title
            (WebCore::Document::removeTitle):
            Uses m_rawTitle instead of m_title
    
            * dom/Document.h:
            Added m_rawTitle that stores the passed in title, m_title now stores the
            canonicalized title
    
            * loader/DocumentLoader.cpp:
            (WebCore::DocumentLoader::setTitle):
            The title passed in is now canonicalized in Document.cpp
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52944 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 855b577..ec6f04a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2010-01-07  Christian Sejersen  <christian.webkit at gmail.com>
+
+        Reviewed by Darin Adler.
+
+        document.title does not replace or remove space characters
+        https://bugs.webkit.org/show_bug.cgi?id=27032
+
+        * fast/dom/Document/document-title-get-expected.txt: Added.
+        * fast/dom/Document/document-title-get.html: Added.
+        * fast/dom/Document/script-tests/document-title-get.js: Added.
+
 2010-01-07  Yuzo Fujishima  <yuzo at google.com>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/dom/Document/document-title-get-expected.txt b/LayoutTests/fast/dom/Document/document-title-get-expected.txt
new file mode 100644
index 0000000..812bc9a
--- /dev/null
+++ b/LayoutTests/fast/dom/Document/document-title-get-expected.txt
@@ -0,0 +1,22 @@
+This test checks the implementation of getting the document.title attribute.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Test with no title set
+PASS document.title is ""
+Test with empty title
+PASS document.title is ""
+Test with only whitespace
+PASS document.title is ""
+Test with no whitespace
+PASS document.title is "nowhitespacetitle"
+Test with whitespace
+PASS document.title is "one space"
+Test with various whitespace lengths and fields
+PASS document.title is "lots of whitespace and newlines"
+Test with various length strings
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Document/document-title-get.html b/LayoutTests/fast/dom/Document/document-title-get.html
new file mode 100644
index 0000000..99deacb
--- /dev/null
+++ b/LayoutTests/fast/dom/Document/document-title-get.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/document-title-get.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/Document/script-tests/document-title-get.js b/LayoutTests/fast/dom/Document/script-tests/document-title-get.js
new file mode 100644
index 0000000..8e3efdb
--- /dev/null
+++ b/LayoutTests/fast/dom/Document/script-tests/document-title-get.js
@@ -0,0 +1,28 @@
+description("This test checks the implementation of getting the document.title attribute.");
+
+debug('Test with no title set');
+shouldBeEqualToString("document.title", "");
+
+debug('Test with empty title');
+document.title = "";
+shouldBeEqualToString("document.title","");
+
+debug('Test with only whitespace');
+document.title = "\t\n\r    \r     \t\n\n";
+shouldBeEqualToString("document.title","");
+
+debug('Test with no whitespace');
+document.title = "nowhitespacetitle";
+shouldBeEqualToString("document.title","nowhitespacetitle");
+
+debug('Test with whitespace');
+document.title = "\u0009\u000aone\u000b\u000cspace\u000d\u0020";
+shouldBeEqualToString("document.title","one space");
+
+debug('Test with various whitespace lengths and fields');
+document.title = "   lots of \r whitespace and \n\n\n    \t    newlines \t";
+shouldBeEqualToString("document.title", "lots of whitespace and newlines");
+
+debug('Test with various length strings');
+
+var successfullyParsed = true;
\ No newline at end of file
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2f2da26..bd891bd 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,32 @@
+2010-01-07  Christian Sejersen  <christian.webkit at gmail.com>
+
+        Reviewed by Darin Adler.
+
+        document.title does not replace or remove space characters
+        https://bugs.webkit.org/show_bug.cgi?id=27032
+
+        Test: fast/dom/Document/document-title-get.html
+
+        * dom/Document.cpp: 
+        (WebCore::Document::Document): 
+        Initialization of m_rawTitle
+        (WebCore::canonicalizedTitle): 
+        Moved from DocumentLoader.cpp with minor edits
+        (WebCore::Document::updateTitle): 
+        Ensures the title is canonicalized
+        (WebCore::Document::setTitle): 
+        Uses m_rawTitle instaed of m_title 
+        (WebCore::Document::removeTitle): 
+        Uses m_rawTitle instead of m_title
+        
+        * dom/Document.h: 
+        Added m_rawTitle that stores the passed in title, m_title now stores the 
+        canonicalized title
+        
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::setTitle): 
+        The title passed in is now canonicalized in Document.cpp
+
 2010-01-07  Yuzo Fujishima  <yuzo at google.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index e3c5463..cd94be6 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -114,6 +114,7 @@
 #include "SegmentedString.h"
 #include "SelectionController.h"
 #include "Settings.h"
+#include "StringBuffer.h"
 #include "StyleSheetList.h"
 #include "TextEvent.h"
 #include "TextIterator.h"
@@ -323,6 +324,7 @@ Document::Document(Frame* frame, bool isXHTML)
     , m_styleRecalcTimer(this, &Document::styleRecalcTimerFired)
     , m_frameElementsShouldIgnoreScrolling(false)
     , m_title("")
+    , m_rawTitle("")
     , m_titleSetExplicitly(false)
     , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFired)
     , m_executeScriptSoonTimer(this, &Document::executeScriptSoonTimerFired)
@@ -1064,8 +1066,67 @@ Element* Document::getElementByAccessKey(const String& key) const
     return m_elementsByAccessKey.get(key.impl());
 }
 
+/*
+ * Performs three operations:
+ *  1. Convert control characters to spaces
+ *  2. Trim leading and trailing spaces
+ *  3. Collapse internal whitespace.
+ */
+static inline String canonicalizedTitle(Document* document, const String& title)
+{
+    const UChar* characters = title.characters();
+    unsigned length = title.length();
+    unsigned i;
+
+    StringBuffer buffer(length);
+    unsigned builderIndex = 0;
+
+    // Skip leading spaces and leading characters that would convert to spaces
+    for (i = 0; i < length; ++i) {
+        UChar c = characters[i];
+        if (!(c <= 0x20 || c == 0x7F))
+            break;
+    }
+
+    if (i == length)
+        return "";
+
+    // Replace control characters with spaces, and backslashes with currency symbols, and collapse whitespace.
+    bool previousCharWasWS = false;
+    for (; i < length; ++i) {
+        UChar c = characters[i];
+        if (c <= 0x20 || c == 0x7F || (WTF::Unicode::category(c) & (WTF::Unicode::Separator_Line | WTF::Unicode::Separator_Paragraph))) {
+            if (previousCharWasWS)
+                continue;
+            buffer[builderIndex++] = ' ';
+            previousCharWasWS = true;
+        } else {
+            buffer[builderIndex++] = c;
+            previousCharWasWS = false;
+        }
+    }
+
+    // Strip trailing spaces
+    while (builderIndex > 0) {
+        --builderIndex;
+        if (buffer[builderIndex] != ' ')
+            break;
+    }
+
+    if (!builderIndex && buffer[builderIndex] == ' ')
+        return "";
+
+    buffer.shrink(builderIndex + 1);
+
+    // Replace the backslashes with currency symbols if the encoding requires it.
+    document->displayBufferModifiedByEncoding(buffer.characters(), buffer.length());
+    
+    return String::adopt(buffer);
+}
+
 void Document::updateTitle()
 {
+    m_title = canonicalizedTitle(this, m_rawTitle);
     if (Frame* f = frame())
         f->loader()->setTitle(m_title);
 }
@@ -1092,10 +1153,10 @@ void Document::setTitle(const String& title, Element* titleElement)
         m_titleElement = titleElement;
     }
 
-    if (m_title == title)
+    if (m_rawTitle == title)
         return;
 
-    m_title = title;
+    m_rawTitle = title;
     updateTitle();
 
     if (m_titleSetExplicitly && m_titleElement && m_titleElement->hasTagName(titleTag))
@@ -1120,8 +1181,8 @@ void Document::removeTitle(Element* titleElement)
             }
     }
 
-    if (!m_titleElement && !m_title.isEmpty()) {
-        m_title = "";
+    if (!m_titleElement && !m_rawTitle.isEmpty()) {
+        m_rawTitle = "";
         updateTitle();
     }
 }
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h
index 8e6ab1f..c71e80f 100644
--- a/WebCore/dom/Document.h
+++ b/WebCore/dom/Document.h
@@ -1073,6 +1073,7 @@ private:
     bool m_frameElementsShouldIgnoreScrolling;
 
     String m_title;
+    String m_rawTitle;
     bool m_titleSetExplicitly;
     RefPtr<Element> m_titleElement;
 
diff --git a/WebCore/loader/DocumentLoader.cpp b/WebCore/loader/DocumentLoader.cpp
index 1507fe9..37a2de2 100644
--- a/WebCore/loader/DocumentLoader.cpp
+++ b/WebCore/loader/DocumentLoader.cpp
@@ -46,7 +46,6 @@
 #include "PlatformString.h"
 #include "Settings.h"
 #include "SharedBuffer.h"
-#include "StringBuffer.h"
 #include "XMLTokenizer.h"
 
 #include <wtf/Assertions.h>
@@ -54,67 +53,6 @@
 
 namespace WebCore {
 
-/*
- * Performs four operations:
- *  1. Convert backslashes to currency symbols
- *  2. Convert control characters to spaces
- *  3. Trim leading and trailing spaces
- *  4. Collapse internal whitespace.
- */
-static inline String canonicalizedTitle(const String& title, Frame* frame)
-{
-    ASSERT(!title.isEmpty());
-
-    const UChar* characters = title.characters();
-    unsigned length = title.length();
-    unsigned i;
-
-    StringBuffer buffer(length);
-    unsigned builderIndex = 0;
-
-    // Skip leading spaces and leading characters that would convert to spaces
-    for (i = 0; i < length; ++i) {
-        UChar c = characters[i];
-        if (!(c <= 0x20 || c == 0x7F))
-            break;
-    }
-
-    if (i == length)
-        return "";
-
-    // Replace control characters with spaces, and backslashes with currency symbols, and collapse whitespace.
-    bool previousCharWasWS = false;
-    for (; i < length; ++i) {
-        UChar c = characters[i];
-        if (c <= 0x20 || c == 0x7F || (WTF::Unicode::category(c) & (WTF::Unicode::Separator_Line | WTF::Unicode::Separator_Paragraph))) {
-            if (previousCharWasWS)
-                continue;
-            buffer[builderIndex++] = ' ';
-            previousCharWasWS = true;
-        } else {
-            buffer[builderIndex++] = c;
-            previousCharWasWS = false;
-        }
-    }
-
-    // Strip trailing spaces
-    while (builderIndex > 0) {
-        --builderIndex;
-        if (buffer[builderIndex] != ' ')
-            break;
-    }
-
-    if (!builderIndex && buffer[builderIndex] == ' ')
-        return "";
-
-    buffer.shrink(builderIndex + 1);
-    
-    // Replace the backslashes with currency symbols if the encoding requires it.
-    frame->document()->displayBufferModifiedByEncoding(buffer.characters(), buffer.length());
-
-    return String::adopt(buffer);
-}
-
 static void cancelAll(const ResourceLoaderSet& loaders)
 {
     const ResourceLoaderSet copy = loaders;
@@ -662,10 +600,9 @@ void DocumentLoader::setTitle(const String& title)
     if (title.isEmpty())
         return;
 
-    String trimmed = canonicalizedTitle(title, m_frame);
-    if (!trimmed.isEmpty() && m_pageTitle != trimmed) {
+    if (m_pageTitle != title) {
         frameLoader()->willChangeTitle(this);
-        m_pageTitle = trimmed;
+        m_pageTitle = title;
         frameLoader()->didChangeTitle(this);
     }
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list