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); |