Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 2362223002: Stop clamping tabIndex to short range (Closed)
Patch Set: Fix tabindex-clamp.html Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/ElementRareData.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Element.cpp
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp
index 7aae88c83b5a16951b3eb756e306129b334a7f90..469bc7a952c742e9449d340a4b81df0a039a8166 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -216,16 +216,18 @@ void Element::clearTabIndexExplicitlyIfNeeded() {
elementRareData()->clearTabIndexExplicitly();
}
-void Element::setTabIndexExplicitly(short tabIndex) {
- ensureElementRareData().setTabIndexExplicitly(tabIndex);
+void Element::setTabIndexExplicitly() {
+ ensureElementRareData().setTabIndexExplicitly();
}
void Element::setTabIndex(int value) {
setIntegralAttribute(tabindexAttr, value);
}
-short Element::tabIndex() const {
- return hasRareData() ? elementRareData()->tabIndex() : 0;
+int Element::tabIndex() const {
+ return hasElementFlag(TabIndexWasSetExplicitly)
+ ? getIntegralAttribute(tabindexAttr)
+ : 0;
}
bool Element::layoutObjectIsFocusable() const {
@@ -2437,19 +2439,16 @@ void Element::parseAttribute(const QualifiedName& name,
const AtomicString& value) {
if (name == tabindexAttr) {
int tabindex = 0;
- if (value.isEmpty()) {
+ if (value.isEmpty() || !parseHTMLInteger(value, tabindex)) {
clearTabIndexExplicitlyIfNeeded();
if (adjustedFocusedElementInTreeScope() == this) {
// We might want to call blur(), but it's dangerous to dispatch
// events here.
document().setNeedsFocusedElementCheck();
}
- } else if (parseHTMLInteger(value, tabindex)) {
- // Clamp tabindex to the range of 'short' to match Firefox's behavior.
- setTabIndexExplicitly(
- max(static_cast<int>(std::numeric_limits<short>::min()),
- std::min(tabindex,
- static_cast<int>(std::numeric_limits<short>::max()))));
+ } else {
+ // We only set when value is in integer range.
+ setTabIndexExplicitly();
}
} else if (name == XMLNames::langAttr) {
pseudoStateChanged(CSSSelector::PseudoLang);
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/ElementRareData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698