[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
abarth at webkit.org
abarth at webkit.org
Wed Dec 22 13:25:15 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 9f272bbe4cb1f0900525e83f99a40bc22889c9fa
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Sep 14 22:53:02 2010 +0000
2010-09-14 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
incorrect tabindex parsing
https://bugs.webkit.org/show_bug.cgi?id=21076
Updated our integer parsing for tabindex to use the algorithm from the
HTML5 spec.
Test: fast/parser/tabindex-parsing-2.html
* html/HTMLElement.cpp:
(WebCore::HTMLElement::parseMappedAttribute):
* html/parser/HTMLParserIdioms.cpp:
(WebCore::parseHTMLInteger):
* html/parser/HTMLParserIdioms.h:
2010-09-14 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
incorrect tabindex parsing
https://bugs.webkit.org/show_bug.cgi?id=21076
* fast/parser/tabindex-parsing-2-expected.txt: Added.
* fast/parser/tabindex-parsing-2.html: Added.
- Test a bunch of corner cases in tabindex parsing.
* fast/parser/tabindex-parsing-expected.txt:
* fast/parser/tabindex-parsing.html:
- Update expected result. This case is actually the one that the
original reporter was complaining about.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/wtf/text/WTFString.h b/JavaScriptCore/wtf/text/WTFString.h
index 9ec043a..8a4a6c7 100644
--- a/JavaScriptCore/wtf/text/WTFString.h
+++ b/JavaScriptCore/wtf/text/WTFString.h
@@ -459,9 +459,18 @@ using WTF::String;
using WTF::append;
using WTF::appendNumber;
using WTF::charactersAreAllASCII;
+using WTF::charactersToIntStrict;
+using WTF::charactersToUIntStrict;
+using WTF::charactersToInt64Strict;
+using WTF::charactersToUInt64Strict;
+using WTF::charactersToIntPtrStrict;
+using WTF::charactersToInt;
+using WTF::charactersToUInt;
+using WTF::charactersToInt64;
+using WTF::charactersToUInt64;
+using WTF::charactersToIntPtr;
using WTF::charactersToDouble;
using WTF::charactersToFloat;
-using WTF::charactersToInt;
using WTF::equal;
using WTF::equalIgnoringCase;
using WTF::find;
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 053d52f..159bd76 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,18 @@
+2010-09-14 Adam Barth <abarth at webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ incorrect tabindex parsing
+ https://bugs.webkit.org/show_bug.cgi?id=21076
+
+ * fast/parser/tabindex-parsing-2-expected.txt: Added.
+ * fast/parser/tabindex-parsing-2.html: Added.
+ - Test a bunch of corner cases in tabindex parsing.
+ * fast/parser/tabindex-parsing-expected.txt:
+ * fast/parser/tabindex-parsing.html:
+ - Update expected result. This case is actually the one that the
+ original reporter was complaining about.
+
2010-09-14 Jian Li <jianli at chromium.org>
Reviewed by David Levin.
diff --git a/LayoutTests/fast/parser/tabindex-parsing-2-expected.txt b/LayoutTests/fast/parser/tabindex-parsing-2-expected.txt
new file mode 100644
index 0000000..4d11284
--- /dev/null
+++ b/LayoutTests/fast/parser/tabindex-parsing-2-expected.txt
@@ -0,0 +1,112 @@
+<div tabindex="+4"></div> => 4
+<div tabindex="-4"></div> => -4
+<div tabindex="+-4"></div> => -1
+<div tabindex="-+4"></div> => -1
+<div tabindex="+04"></div> => 4
+<div tabindex="-04"></div> => -4
+<div tabindex="+"></div> => -1
+<div tabindex="-"></div> => -1
+<div tabindex=" +4"></div> => 4
+<div tabindex=" -4"></div> => -4
+<div tabindex=" +-4"></div> => -1
+<div tabindex=" -+4"></div> => -1
+<div tabindex=" +04"></div> => 4
+<div tabindex=" -04"></div> => -4
+<div tabindex=" +"></div> => -1
+<div tabindex=" -"></div> => -1
+<div tabindex="+4 "></div> => 4
+<div tabindex="-4 "></div> => -4
+<div tabindex="+-4 "></div> => -1
+<div tabindex="-+4 "></div> => -1
+<div tabindex="+04 "></div> => 4
+<div tabindex="-04 "></div> => -4
+<div tabindex="+ "></div> => -1
+<div tabindex="- "></div> => -1
+<div tabindex="	+4"></div> => 4
+<div tabindex="	-4"></div> => -4
+<div tabindex="	+-4"></div> => -1
+<div tabindex="	-+4"></div> => -1
+<div tabindex="	+04"></div> => 4
+<div tabindex="	-04"></div> => -4
+<div tabindex="	+"></div> => -1
+<div tabindex="	-"></div> => -1
+<div tabindex="+4	"></div> => 4
+<div tabindex="-4	"></div> => -4
+<div tabindex="+-4	"></div> => -1
+<div tabindex="-+4	"></div> => -1
+<div tabindex="+04	"></div> => 4
+<div tabindex="-04	"></div> => -4
+<div tabindex="+	"></div> => -1
+<div tabindex="-	"></div> => -1
+<div tabindex="
++4"></div> => 4
+<div tabindex="
+-4"></div> => -4
+<div tabindex="
++-4"></div> => -1
+<div tabindex="
+-+4"></div> => -1
+<div tabindex="
++04"></div> => 4
+<div tabindex="
+-04"></div> => -4
+<div tabindex="
++"></div> => -1
+<div tabindex="
+-"></div> => -1
+<div tabindex="+4
+"></div> => 4
+<div tabindex="-4
+"></div> => -4
+<div tabindex="+-4
+"></div> => -1
+<div tabindex="-+4
+"></div> => -1
+<div tabindex="+04
+"></div> => 4
+<div tabindex="-04
+"></div> => -4
+<div tabindex="+
+"></div> => -1
+<div tabindex="-
+"></div> => -1
+<div tabindex=" +4"></div> => -1
+<div tabindex=" -4"></div> => -1
+<div tabindex=" +-4"></div> => -1
+<div tabindex=" -+4"></div> => -1
+<div tabindex=" +04"></div> => -1
+<div tabindex=" -04"></div> => -1
+<div tabindex=" +"></div> => -1
+<div tabindex=" -"></div> => -1
+<div tabindex="+4 "></div> => 4
+<div tabindex="-4 "></div> => -4
+<div tabindex="+-4 "></div> => -1
+<div tabindex="-+4 "></div> => -1
+<div tabindex="+04 "></div> => 4
+<div tabindex="-04 "></div> => -4
+<div tabindex="+ "></div> => -1
+<div tabindex="- "></div> => -1
+<div tabindex="+4xx"></div> => 4
+<div tabindex="-4xx"></div> => -4
+<div tabindex="+-4xx"></div> => -1
+<div tabindex="-+4xx"></div> => -1
+<div tabindex="+04xx"></div> => 4
+<div tabindex="-04xx"></div> => -4
+<div tabindex="+xx"></div> => -1
+<div tabindex="-xx"></div> => -1
+<div tabindex="+4"></div> => 4
+<div tabindex="-4"></div> => -4
+<div tabindex="+-4"></div> => -1
+<div tabindex="-+4"></div> => -1
+<div tabindex="+04"></div> => 4
+<div tabindex="-04"></div> => -4
+<div tabindex="+"></div> => -1
+<div tabindex="-"></div> => -1
+<div tabindex="+4/"></div> => 4
+<div tabindex="-4/"></div> => -4
+<div tabindex="+-4/"></div> => -1
+<div tabindex="-+4/"></div> => -1
+<div tabindex="+04/"></div> => 4
+<div tabindex="-04/"></div> => -4
+<div tabindex="+/"></div> => -1
+<div tabindex="-/"></div> => -1
diff --git a/LayoutTests/fast/parser/tabindex-parsing-2.html b/LayoutTests/fast/parser/tabindex-parsing-2.html
new file mode 100644
index 0000000..0e48bd4
--- /dev/null
+++ b/LayoutTests/fast/parser/tabindex-parsing-2.html
@@ -0,0 +1,130 @@
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+</script>
+<div tabindex="+4"></div>
+<div tabindex="-4"></div>
+<div tabindex="+-4"></div>
+<div tabindex="-+4"></div>
+<div tabindex="+04"></div>
+<div tabindex="-04"></div>
+<div tabindex="+"></div>
+<div tabindex="-"></div>
+<div tabindex=" +4"></div>
+<div tabindex=" -4"></div>
+<div tabindex=" +-4"></div>
+<div tabindex=" -+4"></div>
+<div tabindex=" +04"></div>
+<div tabindex=" -04"></div>
+<div tabindex=" +"></div>
+<div tabindex=" -"></div>
+<div tabindex="+4 "></div>
+<div tabindex="-4 "></div>
+<div tabindex="+-4 "></div>
+<div tabindex="-+4 "></div>
+<div tabindex="+04 "></div>
+<div tabindex="-04 "></div>
+<div tabindex="+ "></div>
+<div tabindex="- "></div>
+<div tabindex="	+4"></div>
+<div tabindex="	-4"></div>
+<div tabindex="	+-4"></div>
+<div tabindex="	-+4"></div>
+<div tabindex="	+04"></div>
+<div tabindex="	-04"></div>
+<div tabindex="	+"></div>
+<div tabindex="	-"></div>
+<div tabindex="+4	"></div>
+<div tabindex="-4	"></div>
+<div tabindex="+-4	"></div>
+<div tabindex="-+4	"></div>
+<div tabindex="+04	"></div>
+<div tabindex="-04	"></div>
+<div tabindex="+	"></div>
+<div tabindex="-	"></div>
+<div tabindex="
++4"></div>
+<div tabindex="
+-4"></div>
+<div tabindex="
++-4"></div>
+<div tabindex="
+-+4"></div>
+<div tabindex="
++04"></div>
+<div tabindex="
+-04"></div>
+<div tabindex="
++"></div>
+<div tabindex="
+-"></div>
+<div tabindex="+4
+"></div>
+<div tabindex="-4
+"></div>
+<div tabindex="+-4
+"></div>
+<div tabindex="-+4
+"></div>
+<div tabindex="+04
+"></div>
+<div tabindex="-04
+"></div>
+<div tabindex="+
+"></div>
+<div tabindex="-
+"></div>
+<div tabindex=" +4"></div>
+<div tabindex=" -4"></div>
+<div tabindex=" +-4"></div>
+<div tabindex=" -+4"></div>
+<div tabindex=" +04"></div>
+<div tabindex=" -04"></div>
+<div tabindex=" +"></div>
+<div tabindex=" -"></div>
+<div tabindex="+4 "></div>
+<div tabindex="-4 "></div>
+<div tabindex="+-4 "></div>
+<div tabindex="-+4 "></div>
+<div tabindex="+04 "></div>
+<div tabindex="-04 "></div>
+<div tabindex="+ "></div>
+<div tabindex="- "></div>
+<div tabindex="+4xx"></div>
+<div tabindex="-4xx"></div>
+<div tabindex="+-4xx"></div>
+<div tabindex="-+4xx"></div>
+<div tabindex="+04xx"></div>
+<div tabindex="-04xx"></div>
+<div tabindex="+xx"></div>
+<div tabindex="-xx"></div>
+<div tabindex=+4></div>
+<div tabindex=-4></div>
+<div tabindex=+-4></div>
+<div tabindex=-+4></div>
+<div tabindex=+04></div>
+<div tabindex=-04></div>
+<div tabindex=+></div>
+<div tabindex=-></div>
+<div tabindex=+4/></div>
+<div tabindex=-4/></div>
+<div tabindex=+-4/></div>
+<div tabindex=-+4/></div>
+<div tabindex=+04/></div>
+<div tabindex=-04/></div>
+<div tabindex=+/></div>
+<div tabindex=-/></div>
+<pre id="result"></pre>
+<script>
+function log(msg) {
+ var line = document.createElement('pre');
+ line.appendChild(document.createTextNode(msg));
+ document.getElementById('result').appendChild(line);
+}
+
+var divs = document.getElementsByTagName('div');
+for (var i = 0; i < divs.length; ++i) {
+ var elmt = divs[i];
+ log(elmt.outerHTML.replace('\t', '	') + ' => ' + elmt.tabIndex);
+}
+</script>
diff --git a/LayoutTests/fast/parser/tabindex-parsing-expected.txt b/LayoutTests/fast/parser/tabindex-parsing-expected.txt
index 4670ceb..0e776c0 100644
--- a/LayoutTests/fast/parser/tabindex-parsing-expected.txt
+++ b/LayoutTests/fast/parser/tabindex-parsing-expected.txt
@@ -9,8 +9,8 @@ This element shouldn't be focusable PASSED
This element should be focusable PASSED
.tabIndex=7 getAttribute('tabindex')='007'
-This element shouldn't be focusable PASSED
-.tabIndex=-1 getAttribute('tabindex')='1px'
+This element should be focusable PASSED
+.tabIndex=1 getAttribute('tabindex')='1px'
This element should be focusable PASSED
.tabIndex=0 getAttribute('tabindex')='-0'
diff --git a/LayoutTests/fast/parser/tabindex-parsing.html b/LayoutTests/fast/parser/tabindex-parsing.html
index be7a7aa..533353d 100644
--- a/LayoutTests/fast/parser/tabindex-parsing.html
+++ b/LayoutTests/fast/parser/tabindex-parsing.html
@@ -59,7 +59,7 @@ From HTML5 spec:<blockquote>
<p tabindex="007" onfocus="p3Focused=true" onclick="test(p3Focused,true,3)">This element should be focusable <br>
<span id="sp3">Click to test manually</span>
</p>
-<p tabindex="1px" onfocus="p4Focused=true" onclick="test(p4Focused,false,4)">This element shouldn't be focusable <br>
+<p tabindex="1px" onfocus="p4Focused=true" onclick="test(p4Focused,true,4)">This element should be focusable <br>
<span id="sp4">Click to test manually</span>
</p>
<p tabindex="-0" onfocus="p5Focused=true" onclick="test(p5Focused,true,5)">This element should be focusable <br>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index df7dfbe..58b28d0 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2010-09-14 Adam Barth <abarth at webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ incorrect tabindex parsing
+ https://bugs.webkit.org/show_bug.cgi?id=21076
+
+ Updated our integer parsing for tabindex to use the algorithm from the
+ HTML5 spec.
+
+ Test: fast/parser/tabindex-parsing-2.html
+
+ * html/HTMLElement.cpp:
+ (WebCore::HTMLElement::parseMappedAttribute):
+ * html/parser/HTMLParserIdioms.cpp:
+ (WebCore::parseHTMLInteger):
+ * html/parser/HTMLParserIdioms.h:
+
2010-09-14 Brent Fulgham <bfulgham at webkit.org>
Build correction, no review.
diff --git a/WebCore/html/HTMLElement.cpp b/WebCore/html/HTMLElement.cpp
index 28b4b90..a4dccc7 100644
--- a/WebCore/html/HTMLElement.cpp
+++ b/WebCore/html/HTMLElement.cpp
@@ -39,6 +39,7 @@
#include "HTMLElementFactory.h"
#include "HTMLFormElement.h"
#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
#include "RenderWordBreak.h"
#include "ScriptEventListener.h"
#include "Settings.h"
@@ -142,12 +143,10 @@ void HTMLElement::parseMappedAttribute(Attribute* attr)
setContentEditable(attr);
} else if (attr->name() == tabindexAttr) {
indexstring = getAttribute(tabindexAttr);
- if (indexstring.length()) {
- bool parsedOK;
- int tabindex = indexstring.toIntStrict(&parsedOK);
- if (parsedOK)
- // Clamp tabindex to the range of 'short' to match Firefox's behavior.
- setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short>::min()), min(tabindex, static_cast<int>(std::numeric_limits<short>::max()))));
+ int tabindex = 0;
+ if (parseHTMLInteger(indexstring, tabindex)) {
+ // Clamp tabindex to the range of 'short' to match Firefox's behavior.
+ setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short>::min()), min(tabindex, static_cast<int>(std::numeric_limits<short>::max()))));
}
} else if (attr->name() == langAttr) {
// FIXME: Implement
diff --git a/WebCore/html/parser/HTMLParserIdioms.cpp b/WebCore/html/parser/HTMLParserIdioms.cpp
index 7026369..a558cf5 100644
--- a/WebCore/html/parser/HTMLParserIdioms.cpp
+++ b/WebCore/html/parser/HTMLParserIdioms.cpp
@@ -91,4 +91,54 @@ bool parseToDoubleForNumberType(const String& string, double* result)
return true;
}
+// http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-integers
+bool parseHTMLInteger(const String& input, int& value)
+{
+ // Step 1
+ // Step 2
+ const UChar* position = input.characters();
+ const UChar* end = position + input.length();
+
+ // Step 3
+ int sign = 1;
+
+ // Step 4
+ while (position < end) {
+ if (!isHTMLSpace(*position))
+ break;
+ ++position;
+ }
+
+ // Step 5
+ if (position == end)
+ return false;
+ ASSERT(position < end);
+
+ // Step 6
+ if (*position == '-') {
+ sign = -1;
+ ++position;
+ } else if (*position == '+')
+ ++position;
+ if (position == end)
+ return false;
+ ASSERT(position < end);
+
+ // Step 7
+ if (!isASCIIDigit(*position))
+ return false;
+
+ // Step 8
+ Vector<UChar, 16> digits;
+ while (position < end) {
+ if (!isASCIIDigit(*position))
+ break;
+ digits.append(*position++);
+ }
+
+ // Step 9
+ value = sign * charactersToIntStrict(digits.data(), digits.size());
+ return true;
+}
+
}
diff --git a/WebCore/html/parser/HTMLParserIdioms.h b/WebCore/html/parser/HTMLParserIdioms.h
index 3ae20b5..f4704f7 100644
--- a/WebCore/html/parser/HTMLParserIdioms.h
+++ b/WebCore/html/parser/HTMLParserIdioms.h
@@ -45,6 +45,9 @@ String serializeForNumberType(double);
// The double* parameter may be 0 to check if the string can be parsed without getting the result.
bool parseToDoubleForNumberType(const String&, double*);
+// http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-integers
+bool parseHTMLInteger(const String&, int&);
+
// Inline implementations of some of the functions declared above.
inline bool isHTMLSpace(UChar character)
diff --git a/WebCore/wml/WMLElement.cpp b/WebCore/wml/WMLElement.cpp
index 4d18e94..5c8a94c 100644
--- a/WebCore/wml/WMLElement.cpp
+++ b/WebCore/wml/WMLElement.cpp
@@ -72,12 +72,10 @@ void WMLElement::parseMappedAttribute(Attribute* attr)
addCSSProperty(attr, CSSPropertyTextAlign, attr->value());
} else if (attr->name() == HTMLNames::tabindexAttr) {
String indexstring = attr->value();
- if (indexstring.length()) {
- bool parsedOK;
- int tabindex = indexstring.toIntStrict(&parsedOK);
- if (parsedOK)
- // Clamp tabindex to the range of 'short' to match Firefox's behavior.
- setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short>::min()), min(tabindex, static_cast<int>(std::numeric_limits<short>::max()))));
+ int tabindex = 0;
+ if (parseHTMLInteger(tabindex)) {
+ // Clamp tabindex to the range of 'short' to match Firefox's behavior.
+ setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short>::min()), min(tabindex, static_cast<int>(std::numeric_limits<short>::max()))));
}
}
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list