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

arv at chromium.org arv at chromium.org
Wed Apr 7 23:54:41 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit dcecd918f6a756e31722a766868228619fe5231c
Author: arv at chromium.org <arv at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Nov 24 00:30:37 2009 +0000

    2009-11-23  Erik Arvidsson  <arv at chromium.org>
    
            Reviewed by Eric Seidel.
    
            JSC bindings for HasIndexGetter generates incorrect code (affects
            MediaList and CSSStyleDeclaration).
            This cleans up the edge cases for indexing out of range for style and
            computed style objects to return an empty string according to the spec.
            MediaList now returns null when indexed out of range.
            https://bugs.webkit.org/show_bug.cgi?id=31683
    
            * fast/dom/CSSStyleDeclaration/css-computed-style-item-expected.txt: Added.
            * fast/dom/CSSStyleDeclaration/css-computed-style-item.html: Added.
            * fast/dom/CSSStyleDeclaration/css-style-item-expected.txt: Added.
            * fast/dom/CSSStyleDeclaration/css-style-item.html: Added.
            * fast/dom/CSSStyleDeclaration/script-tests/css-computed-style-item.js: Added.
            * fast/dom/CSSStyleDeclaration/script-tests/css-style-item.js: Added.
            * fast/dom/StyleSheet/css-medialist-item-expected.txt: Added.
            * fast/dom/StyleSheet/css-medialist-item.html: Added.
            * fast/dom/StyleSheet/script-tests/TEMPLATE.html: Copied from LayoutTests/fast/backgrounds/repeat/script-tests/TEMPLATE.html.
            * fast/dom/StyleSheet/script-tests/css-medialist-item.js: Added.
    2009-11-23  Erik Arvidsson  <arv at chromium.org>
    
            Reviewed by Eric Seidel.
    
            JSC bindings for HasIndexGetter generates incorrect code (affects
            MediaList and CSSStyleDeclaration).
            This cleans up the edge cases for indexing out of range for style and
            computed style objects to return an empty string according to the spec.
            MediaList now returns null when indexed out of range.
            https://bugs.webkit.org/show_bug.cgi?id=31683
    
            Tests: fast/dom/CSSStyleDeclaration/css-computed-style-item.html
                   fast/dom/CSSStyleDeclaration/css-style-item.html
                   fast/dom/StyleSheet/css-medialist-item.html
    
            * bindings/scripts/CodeGeneratorJS.pm: If IndexGetterReturnsString then
                    we do not check the length before calling the item function.
            * css/CSSComputedStyleDeclaration.cpp:
            (WebCore::CSSComputedStyleDeclaration::item):
            * css/CSSMutableStyleDeclaration.cpp:
            (WebCore::CSSMutableStyleDeclaration::item):
            * css/CSSStyleDeclaration.idl:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51326 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 3ba35b2..825ef50 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,25 @@
+2009-11-23  Erik Arvidsson  <arv at chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        JSC bindings for HasIndexGetter generates incorrect code (affects
+        MediaList and CSSStyleDeclaration).
+        This cleans up the edge cases for indexing out of range for style and
+        computed style objects to return an empty string according to the spec.
+        MediaList now returns null when indexed out of range.
+        https://bugs.webkit.org/show_bug.cgi?id=31683
+
+        * fast/dom/CSSStyleDeclaration/css-computed-style-item-expected.txt: Added.
+        * fast/dom/CSSStyleDeclaration/css-computed-style-item.html: Added.
+        * fast/dom/CSSStyleDeclaration/css-style-item-expected.txt: Added.
+        * fast/dom/CSSStyleDeclaration/css-style-item.html: Added.
+        * fast/dom/CSSStyleDeclaration/script-tests/css-computed-style-item.js: Added.
+        * fast/dom/CSSStyleDeclaration/script-tests/css-style-item.js: Added.
+        * fast/dom/StyleSheet/css-medialist-item-expected.txt: Added.
+        * fast/dom/StyleSheet/css-medialist-item.html: Added.
+        * fast/dom/StyleSheet/script-tests/TEMPLATE.html: Copied from LayoutTests/fast/backgrounds/repeat/script-tests/TEMPLATE.html.
+        * fast/dom/StyleSheet/script-tests/css-medialist-item.js: Added.
+
 2009-11-23  Csaba Osztrogonác  <ossy at webkit.org>
 
         Unreviewed. Skip new test added in r51324.
diff --git a/LayoutTests/fast/dom/CSSStyleDeclaration/css-computed-style-item-expected.txt b/LayoutTests/fast/dom/CSSStyleDeclaration/css-computed-style-item-expected.txt
new file mode 100644
index 0000000..b425aab
--- /dev/null
+++ b/LayoutTests/fast/dom/CSSStyleDeclaration/css-computed-style-item-expected.txt
@@ -0,0 +1,12 @@
+This tests indexing outside the range of the computed style object.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS typeof computedStyle.length is "number"
+PASS computedStyle[computedStyle.length] is ""
+PASS computedStyle[-1] is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/CSSStyleDeclaration/css-computed-style-item.html b/LayoutTests/fast/dom/CSSStyleDeclaration/css-computed-style-item.html
new file mode 100644
index 0000000..155c672
--- /dev/null
+++ b/LayoutTests/fast/dom/CSSStyleDeclaration/css-computed-style-item.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/css-computed-style-item.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/CSSStyleDeclaration/css-style-item-expected.txt b/LayoutTests/fast/dom/CSSStyleDeclaration/css-style-item-expected.txt
new file mode 100644
index 0000000..5b57e49
--- /dev/null
+++ b/LayoutTests/fast/dom/CSSStyleDeclaration/css-style-item-expected.txt
@@ -0,0 +1,13 @@
+This tests indexing outside the range of the style object.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS style.length is 1
+PASS style[0] is "color"
+PASS style[1] is ""
+PASS style[-1] is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/CSSStyleDeclaration/css-style-item.html b/LayoutTests/fast/dom/CSSStyleDeclaration/css-style-item.html
new file mode 100644
index 0000000..b0858cc
--- /dev/null
+++ b/LayoutTests/fast/dom/CSSStyleDeclaration/css-style-item.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/css-style-item.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/CSSStyleDeclaration/script-tests/css-computed-style-item.js b/LayoutTests/fast/dom/CSSStyleDeclaration/script-tests/css-computed-style-item.js
new file mode 100644
index 0000000..8522f65
--- /dev/null
+++ b/LayoutTests/fast/dom/CSSStyleDeclaration/script-tests/css-computed-style-item.js
@@ -0,0 +1,14 @@
+description("This tests indexing outside the range of the computed style object.");
+
+var element = document.createElement('div');
+element.style.color = 'rgb(120, 120, 120)';
+document.documentElement.appendChild(element);
+var computedStyle = window.getComputedStyle(element, null);
+
+shouldBeEqualToString('typeof computedStyle.length', 'number');
+shouldBeEqualToString('computedStyle[computedStyle.length]', '');
+shouldBeUndefined('computedStyle[-1]')
+
+document.documentElement.removeChild(element);
+
+successfullyParsed = true;
diff --git a/LayoutTests/fast/dom/CSSStyleDeclaration/script-tests/css-style-item.js b/LayoutTests/fast/dom/CSSStyleDeclaration/script-tests/css-style-item.js
new file mode 100644
index 0000000..ad85fb9
--- /dev/null
+++ b/LayoutTests/fast/dom/CSSStyleDeclaration/script-tests/css-style-item.js
@@ -0,0 +1,15 @@
+description("This tests indexing outside the range of the style object.");
+
+var element = document.createElement('div');
+element.style.color = 'red';
+document.documentElement.appendChild(element);
+var style = element.style;
+
+shouldEvaluateTo('style.length', 1);
+shouldBeEqualToString('style[0]', 'color');
+shouldBeEqualToString('style[1]', '');
+shouldBeUndefined('style[-1]')
+
+document.documentElement.removeChild(element);
+
+successfullyParsed = true;
diff --git a/LayoutTests/fast/dom/StyleSheet/css-medialist-item-expected.txt b/LayoutTests/fast/dom/StyleSheet/css-medialist-item-expected.txt
new file mode 100644
index 0000000..1468f1b
--- /dev/null
+++ b/LayoutTests/fast/dom/StyleSheet/css-medialist-item-expected.txt
@@ -0,0 +1,14 @@
+This tests indexing outside the range of the media list object.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS mediaList.length is 2
+PASS mediaList[0] is "screen"
+PASS mediaList[1] is "print"
+PASS mediaList[2] is null
+PASS mediaList[-1] is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/StyleSheet/css-medialist-item.html b/LayoutTests/fast/dom/StyleSheet/css-medialist-item.html
new file mode 100644
index 0000000..4d0c598
--- /dev/null
+++ b/LayoutTests/fast/dom/StyleSheet/css-medialist-item.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/css-medialist-item.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/backgrounds/repeat/script-tests/TEMPLATE.html b/LayoutTests/fast/dom/StyleSheet/script-tests/TEMPLATE.html
similarity index 100%
copy from LayoutTests/fast/backgrounds/repeat/script-tests/TEMPLATE.html
copy to LayoutTests/fast/dom/StyleSheet/script-tests/TEMPLATE.html
diff --git a/LayoutTests/fast/dom/StyleSheet/script-tests/css-medialist-item.js b/LayoutTests/fast/dom/StyleSheet/script-tests/css-medialist-item.js
new file mode 100644
index 0000000..22974e7
--- /dev/null
+++ b/LayoutTests/fast/dom/StyleSheet/script-tests/css-medialist-item.js
@@ -0,0 +1,16 @@
+description("This tests indexing outside the range of the media list object.");
+
+var styleElement  = document.createElement('style');
+styleElement.setAttribute('media', 'screen, print');
+document.documentElement.appendChild(styleElement)
+var mediaList = document.styleSheets[document.styleSheets.length - 1].media;
+
+shouldEvaluateTo('mediaList.length', 2);
+shouldBeEqualToString('mediaList[0]', 'screen');
+shouldBeEqualToString('mediaList[1]', 'print');
+shouldBeNull('mediaList[2]');
+shouldBeUndefined('mediaList[-1]')
+
+document.documentElement.removeChild(styleElement);
+
+successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ceaae74..d7f363d 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2009-11-23  Erik Arvidsson  <arv at chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        JSC bindings for HasIndexGetter generates incorrect code (affects
+        MediaList and CSSStyleDeclaration).
+        This cleans up the edge cases for indexing out of range for style and
+        computed style objects to return an empty string according to the spec.
+        MediaList now returns null when indexed out of range.
+        https://bugs.webkit.org/show_bug.cgi?id=31683
+
+        Tests: fast/dom/CSSStyleDeclaration/css-computed-style-item.html
+               fast/dom/CSSStyleDeclaration/css-style-item.html
+               fast/dom/StyleSheet/css-medialist-item.html
+
+        * bindings/scripts/CodeGeneratorJS.pm: If IndexGetterReturnsString then
+                we do not check the length before calling the item function.
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::item):
+        * css/CSSMutableStyleDeclaration.cpp:
+        (WebCore::CSSMutableStyleDeclaration::item):
+        * css/CSSStyleDeclaration.idl:
+
 2009-11-23  Simon Fraser  <simon.fraser at apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm
index d8367ac..5c390dc 100644
--- a/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -316,7 +316,14 @@ sub GenerateGetOwnPropertySlotBody
     if ($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) {
         push(@getOwnPropertySlotImpl, "    bool ok;\n");
         push(@getOwnPropertySlotImpl, "    unsigned index = propertyName.toUInt32(&ok, false);\n");
-        push(@getOwnPropertySlotImpl, "    if (ok && index < static_cast<$implClassName*>(impl())->length()) {\n");
+
+        # If the item function returns a string then we let the ConvertNullStringTo handle the cases
+        # where the index is out of range.
+        if (IndexGetterReturnsStrings($implClassName)) {
+            push(@getOwnPropertySlotImpl, "    if (ok) {\n");
+        } else {
+            push(@getOwnPropertySlotImpl, "    if (ok && index < static_cast<$implClassName*>(impl())->length()) {\n");
+        }
         if ($dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) {
             push(@getOwnPropertySlotImpl, "        slot.setValue(getByIndex(exec, index));\n");
         } else {
diff --git a/WebCore/css/CSSComputedStyleDeclaration.cpp b/WebCore/css/CSSComputedStyleDeclaration.cpp
index e056da4..58e4ac6 100644
--- a/WebCore/css/CSSComputedStyleDeclaration.cpp
+++ b/WebCore/css/CSSComputedStyleDeclaration.cpp
@@ -1478,7 +1478,7 @@ unsigned CSSComputedStyleDeclaration::length() const
 String CSSComputedStyleDeclaration::item(unsigned i) const
 {
     if (i >= length())
-        return String();
+        return "";
 
     return getPropertyName(static_cast<CSSPropertyID>(computedProperties[i]));
 }
diff --git a/WebCore/css/CSSMutableStyleDeclaration.cpp b/WebCore/css/CSSMutableStyleDeclaration.cpp
index aa8e028..a7e7b58 100644
--- a/WebCore/css/CSSMutableStyleDeclaration.cpp
+++ b/WebCore/css/CSSMutableStyleDeclaration.cpp
@@ -636,7 +636,7 @@ unsigned CSSMutableStyleDeclaration::length() const
 String CSSMutableStyleDeclaration::item(unsigned i) const
 {
     if (i >= m_properties.size())
-       return String();
+       return "";
     return getPropertyName(static_cast<CSSPropertyID>(m_properties[i].id()));
 }
 
diff --git a/WebCore/css/CSSStyleDeclaration.idl b/WebCore/css/CSSStyleDeclaration.idl
index 3e37418..42682ef 100644
--- a/WebCore/css/CSSStyleDeclaration.idl
+++ b/WebCore/css/CSSStyleDeclaration.idl
@@ -44,7 +44,7 @@ module css {
             raises(DOMException);
 
         readonly attribute unsigned long    length;
-        [ConvertNullStringTo=Null] DOMString          item(in unsigned long index);
+        DOMString          item(in unsigned long index);
         readonly attribute CSSRule          parentRule;
 
         // Extensions

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list