OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 204 |
205 void Element::clearElementFlag(ElementFlags mask) | 205 void Element::clearElementFlag(ElementFlags mask) |
206 { | 206 { |
207 if (!hasRareData()) | 207 if (!hasRareData()) |
208 return; | 208 return; |
209 elementRareData()->clearElementFlag(mask); | 209 elementRareData()->clearElementFlag(mask); |
210 } | 210 } |
211 | 211 |
212 void Element::clearTabIndexExplicitlyIfNeeded() | 212 void Element::clearTabIndexExplicitlyIfNeeded() |
213 { | 213 { |
214 if (hasRareData()) | 214 if (hasRareData()) { |
215 elementRareData()->clearTabIndexExplicitly(); | 215 elementRareData()->clearTabIndexExplicitly(); |
| 216 // As tabindex is removed, unless there is an tabstop attribute, |
| 217 // revert tabstop to default to match tabindex at this point (0). |
| 218 if (!fastHasAttribute(tabstopAttr)) |
| 219 setTabStopInternal(true); |
| 220 } |
216 } | 221 } |
217 | 222 |
218 void Element::setTabIndexExplicitly(short tabIndex) | 223 void Element::setTabIndexExplicitly(short tabIndex) |
219 { | 224 { |
220 ensureElementRareData().setTabIndexExplicitly(tabIndex); | 225 ensureElementRareData().setTabIndexExplicitly(tabIndex); |
| 226 if (!fastHasAttribute(tabstopAttr)) |
| 227 setTabStopInternal(tabIndex >= 0); |
221 } | 228 } |
222 | 229 |
223 void Element::setTabIndex(int value) | 230 void Element::setTabIndex(int value) |
224 { | 231 { |
225 setIntegralAttribute(tabindexAttr, value); | 232 setIntegralAttribute(tabindexAttr, value); |
226 } | 233 } |
227 | 234 |
228 short Element::tabIndex() const | 235 short Element::tabIndex() const |
229 { | 236 { |
230 return hasRareData() ? elementRareData()->tabIndex() : 0; | 237 return hasRareData() ? elementRareData()->tabIndex() : 0; |
(...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2085 clearTabIndexExplicitlyIfNeeded(); | 2092 clearTabIndexExplicitlyIfNeeded(); |
2086 if (treeScope().adjustedFocusedElement() == this) { | 2093 if (treeScope().adjustedFocusedElement() == this) { |
2087 // We might want to call blur(), but it's dangerous to dispatch | 2094 // We might want to call blur(), but it's dangerous to dispatch |
2088 // events here. | 2095 // events here. |
2089 document().setNeedsFocusedElementCheck(); | 2096 document().setNeedsFocusedElementCheck(); |
2090 } | 2097 } |
2091 } else if (parseHTMLInteger(value, tabindex)) { | 2098 } else if (parseHTMLInteger(value, tabindex)) { |
2092 // Clamp tabindex to the range of 'short' to match Firefox's behavio
r. | 2099 // Clamp tabindex to the range of 'short' to match Firefox's behavio
r. |
2093 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short
>::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max()
)))); | 2100 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short
>::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max()
)))); |
2094 } | 2101 } |
| 2102 } else if (RuntimeEnabledFeatures::tabStopAttributeEnabled() && name == tabs
topAttr) { |
| 2103 if (!hasAttribute(tabstopAttr)) { |
| 2104 // tabstop attribute removed. |
| 2105 clearElementFlag(TabStopWasSetExplicitly); |
| 2106 setTabStopInternal(tabIndex() >= 0); |
| 2107 } else { |
| 2108 // Treat empty attribute as true. |
| 2109 if (equalIgnoringCase(value, "true") || equalIgnoringCase(value, "")
) { |
| 2110 setTabStopInternal(true); |
| 2111 setElementFlag(TabStopWasSetExplicitly, true); |
| 2112 } else if (equalIgnoringCase(value, "false")) { |
| 2113 setTabStopInternal(false); |
| 2114 setElementFlag(TabStopWasSetExplicitly, true); |
| 2115 } else { |
| 2116 // When value is other than "true", "false", "", the value is ig
nored and |
| 2117 // falls back the default state. |
| 2118 clearElementFlag(TabStopWasSetExplicitly); |
| 2119 setTabStopInternal(tabIndex() >= 0); |
| 2120 } |
| 2121 } |
2095 } | 2122 } |
2096 } | 2123 } |
2097 | 2124 |
2098 bool Element::parseAttributeName(QualifiedName& out, const AtomicString& namespa
ceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState) | 2125 bool Element::parseAttributeName(QualifiedName& out, const AtomicString& namespa
ceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState) |
2099 { | 2126 { |
2100 AtomicString prefix, localName; | 2127 AtomicString prefix, localName; |
2101 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio
nState)) | 2128 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio
nState)) |
2102 return false; | 2129 return false; |
2103 ASSERT(!exceptionState.hadException()); | 2130 ASSERT(!exceptionState.hadException()); |
2104 | 2131 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2327 return isFocusable() && tabIndex() >= 0; | 2354 return isFocusable() && tabIndex() >= 0; |
2328 } | 2355 } |
2329 | 2356 |
2330 bool Element::isMouseFocusable() const | 2357 bool Element::isMouseFocusable() const |
2331 { | 2358 { |
2332 return isFocusable(); | 2359 return isFocusable(); |
2333 } | 2360 } |
2334 | 2361 |
2335 bool Element::tabStop() const | 2362 bool Element::tabStop() const |
2336 { | 2363 { |
2337 // Any element which never supports focus will always return false. | 2364 if (hasElementFlag(TabStopWasSetExplicitly)) |
2338 return supportsFocus() && (hasRareData() ? elementRareData()->tabStop() : tr
ue); | 2365 return elementRareData()->tabStop(); |
| 2366 return tabIndex() >= 0; |
2339 } | 2367 } |
2340 | 2368 |
2341 void Element::setTabStop(bool flag) | 2369 void Element::setTabStop(bool flag) |
2342 { | 2370 { |
| 2371 // Reflect the value in the HTML attribute. Note that we cannot use setBoole
anAttribute() |
| 2372 // because the tabstop attribute is an enumerated attribute. |
| 2373 // After tabstop attribute is set, the property value is modified accordingl
y. |
| 2374 setAttribute(tabstopAttr, flag ? "true" : "false"); |
| 2375 } |
| 2376 |
| 2377 void Element::setTabStopInternal(bool flag) |
| 2378 { |
2343 ensureElementRareData().setTabStop(flag); | 2379 ensureElementRareData().setTabStop(flag); |
2344 focusStateChanged(); | 2380 focusStateChanged(); |
2345 } | 2381 } |
2346 | 2382 |
2347 void Element::dispatchFocusEvent(Element* oldFocusedElement, WebFocusType type) | 2383 void Element::dispatchFocusEvent(Element* oldFocusedElement, WebFocusType type) |
2348 { | 2384 { |
2349 RefPtrWillBeRawPtr<FocusEvent> event = FocusEvent::create(EventTypeNames::fo
cus, false, false, document().domWindow(), 0, oldFocusedElement); | 2385 RefPtrWillBeRawPtr<FocusEvent> event = FocusEvent::create(EventTypeNames::fo
cus, false, false, document().domWindow(), 0, oldFocusedElement); |
2350 EventDispatcher::dispatchEvent(*this, FocusEventDispatchMediator::create(eve
nt.release())); | 2386 EventDispatcher::dispatchEvent(*this, FocusEventDispatchMediator::create(eve
nt.release())); |
2351 } | 2387 } |
2352 | 2388 |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3459 { | 3495 { |
3460 #if ENABLE(OILPAN) | 3496 #if ENABLE(OILPAN) |
3461 if (hasRareData()) | 3497 if (hasRareData()) |
3462 visitor->trace(elementRareData()); | 3498 visitor->trace(elementRareData()); |
3463 visitor->trace(m_elementData); | 3499 visitor->trace(m_elementData); |
3464 #endif | 3500 #endif |
3465 ContainerNode::trace(visitor); | 3501 ContainerNode::trace(visitor); |
3466 } | 3502 } |
3467 | 3503 |
3468 } // namespace blink | 3504 } // namespace blink |
OLD | NEW |