Chromium Code Reviews| 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 (!hasAttribute(tabstopAttr)) | |
|
tkent
2015/03/31 06:16:32
hasAttribute -> fastHasAttribute
kochi
2015/03/31 08:04:24
Done.
| |
| 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 (!hasAttribute(tabstopAttr)) | |
|
tkent
2015/03/31 06:16:32
Ditto.
kochi
2015/03/31 08:04:24
Done.
| |
| 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 } | |
|
tkent
2015/03/31 06:16:32
What should happen if a string other than "true" "
kochi
2015/03/31 08:04:24
If tabstop is not either of "true", "", "false", i
| |
| 2116 } | |
| 2095 } | 2117 } |
| 2096 } | 2118 } |
| 2097 | 2119 |
| 2098 bool Element::parseAttributeName(QualifiedName& out, const AtomicString& namespa ceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState) | 2120 bool Element::parseAttributeName(QualifiedName& out, const AtomicString& namespa ceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState) |
| 2099 { | 2121 { |
| 2100 AtomicString prefix, localName; | 2122 AtomicString prefix, localName; |
| 2101 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio nState)) | 2123 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio nState)) |
| 2102 return false; | 2124 return false; |
| 2103 ASSERT(!exceptionState.hadException()); | 2125 ASSERT(!exceptionState.hadException()); |
| 2104 | 2126 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2327 return isFocusable() && tabIndex() >= 0; | 2349 return isFocusable() && tabIndex() >= 0; |
| 2328 } | 2350 } |
| 2329 | 2351 |
| 2330 bool Element::isMouseFocusable() const | 2352 bool Element::isMouseFocusable() const |
| 2331 { | 2353 { |
| 2332 return isFocusable(); | 2354 return isFocusable(); |
| 2333 } | 2355 } |
| 2334 | 2356 |
| 2335 bool Element::tabStop() const | 2357 bool Element::tabStop() const |
| 2336 { | 2358 { |
| 2337 // Any element which never supports focus will always return false. | 2359 if (hasElementFlag(TabStopWasSetExplicitly)) |
| 2338 return supportsFocus() && (hasRareData() ? elementRareData()->tabStop() : tr ue); | 2360 return elementRareData()->tabStop(); |
| 2361 return tabIndex() >= 0; | |
| 2339 } | 2362 } |
| 2340 | 2363 |
| 2341 void Element::setTabStop(bool flag) | 2364 void Element::setTabStop(bool flag) |
| 2342 { | 2365 { |
| 2366 // Reflect the value in the HTML attribute. Note that we cannot use setBoole anAttribute() | |
| 2367 // because the tabstop attribute is an enumerated attribute. | |
| 2368 // After tabstop attribute is set, the property value is modified accordingl y. | |
| 2369 setAttribute(tabstopAttr, flag ? "true" : "false"); | |
| 2370 } | |
| 2371 | |
| 2372 void Element::setTabStopInternal(bool flag) | |
| 2373 { | |
| 2343 ensureElementRareData().setTabStop(flag); | 2374 ensureElementRareData().setTabStop(flag); |
| 2344 focusStateChanged(); | 2375 focusStateChanged(); |
| 2345 } | 2376 } |
| 2346 | 2377 |
| 2347 void Element::dispatchFocusEvent(Element* oldFocusedElement, WebFocusType type) | 2378 void Element::dispatchFocusEvent(Element* oldFocusedElement, WebFocusType type) |
| 2348 { | 2379 { |
| 2349 RefPtrWillBeRawPtr<FocusEvent> event = FocusEvent::create(EventTypeNames::fo cus, false, false, document().domWindow(), 0, oldFocusedElement); | 2380 RefPtrWillBeRawPtr<FocusEvent> event = FocusEvent::create(EventTypeNames::fo cus, false, false, document().domWindow(), 0, oldFocusedElement); |
| 2350 EventDispatcher::dispatchEvent(*this, FocusEventDispatchMediator::create(eve nt.release())); | 2381 EventDispatcher::dispatchEvent(*this, FocusEventDispatchMediator::create(eve nt.release())); |
| 2351 } | 2382 } |
| 2352 | 2383 |
| (...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3459 { | 3490 { |
| 3460 #if ENABLE(OILPAN) | 3491 #if ENABLE(OILPAN) |
| 3461 if (hasRareData()) | 3492 if (hasRareData()) |
| 3462 visitor->trace(elementRareData()); | 3493 visitor->trace(elementRareData()); |
| 3463 visitor->trace(m_elementData); | 3494 visitor->trace(m_elementData); |
| 3464 #endif | 3495 #endif |
| 3465 ContainerNode::trace(visitor); | 3496 ContainerNode::trace(visitor); |
| 3466 } | 3497 } |
| 3467 | 3498 |
| 3468 } // namespace blink | 3499 } // namespace blink |
| OLD | NEW |