| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 192 |
| 193 void Element::clearElementFlag(ElementFlags mask) | 193 void Element::clearElementFlag(ElementFlags mask) |
| 194 { | 194 { |
| 195 if (!hasRareData()) | 195 if (!hasRareData()) |
| 196 return; | 196 return; |
| 197 elementRareData()->clearElementFlag(mask); | 197 elementRareData()->clearElementFlag(mask); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void Element::clearTabIndexExplicitlyIfNeeded() | 200 void Element::clearTabIndexExplicitlyIfNeeded() |
| 201 { | 201 { |
| 202 if (hasRareData()) { | 202 if (hasRareData()) |
| 203 elementRareData()->clearTabIndexExplicitly(); | 203 elementRareData()->clearTabIndexExplicitly(); |
| 204 // As tabindex is removed, unless there is an tabstop attribute, | |
| 205 // revert tabstop to default to match tabindex at this point (0). | |
| 206 if (!fastHasAttribute(tabstopAttr)) | |
| 207 setTabStopInternal(true); | |
| 208 } | |
| 209 } | 204 } |
| 210 | 205 |
| 211 void Element::setTabIndexExplicitly(short tabIndex) | 206 void Element::setTabIndexExplicitly(short tabIndex) |
| 212 { | 207 { |
| 213 ensureElementRareData().setTabIndexExplicitly(tabIndex); | 208 ensureElementRareData().setTabIndexExplicitly(tabIndex); |
| 214 if (!fastHasAttribute(tabstopAttr)) | |
| 215 setTabStopInternal(tabIndex >= 0); | |
| 216 } | 209 } |
| 217 | 210 |
| 218 void Element::setTabIndex(int value) | 211 void Element::setTabIndex(int value) |
| 219 { | 212 { |
| 220 setIntegralAttribute(tabindexAttr, value); | 213 setIntegralAttribute(tabindexAttr, value); |
| 221 } | 214 } |
| 222 | 215 |
| 223 short Element::tabIndex() const | 216 short Element::tabIndex() const |
| 224 { | 217 { |
| 225 return hasRareData() ? elementRareData()->tabIndex() : 0; | 218 return hasRareData() ? elementRareData()->tabIndex() : 0; |
| (...skipping 1826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2052 clearTabIndexExplicitlyIfNeeded(); | 2045 clearTabIndexExplicitlyIfNeeded(); |
| 2053 if (treeScope().adjustedFocusedElement() == this) { | 2046 if (treeScope().adjustedFocusedElement() == this) { |
| 2054 // We might want to call blur(), but it's dangerous to dispatch | 2047 // We might want to call blur(), but it's dangerous to dispatch |
| 2055 // events here. | 2048 // events here. |
| 2056 document().setNeedsFocusedElementCheck(); | 2049 document().setNeedsFocusedElementCheck(); |
| 2057 } | 2050 } |
| 2058 } else if (parseHTMLInteger(value, tabindex)) { | 2051 } else if (parseHTMLInteger(value, tabindex)) { |
| 2059 // Clamp tabindex to the range of 'short' to match Firefox's behavio
r. | 2052 // Clamp tabindex to the range of 'short' to match Firefox's behavio
r. |
| 2060 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short
>::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max()
)))); | 2053 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short
>::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max()
)))); |
| 2061 } | 2054 } |
| 2062 } else if (RuntimeEnabledFeatures::tabStopAttributeEnabled() && name == tabs
topAttr) { | |
| 2063 UseCounter::count(document(), UseCounter::TabStopAttribute); | |
| 2064 if (!hasAttribute(tabstopAttr)) { | |
| 2065 // tabstop attribute removed. | |
| 2066 clearElementFlag(TabStopWasSetExplicitly); | |
| 2067 setTabStopInternal(tabIndex() >= 0); | |
| 2068 } else { | |
| 2069 // Treat empty attribute as true. | |
| 2070 if (equalIgnoringCase(value, "true") || equalIgnoringCase(value, "")
) { | |
| 2071 setElementFlag(TabStopWasSetExplicitly, true); | |
| 2072 setTabStopInternal(true); | |
| 2073 } else if (equalIgnoringCase(value, "false")) { | |
| 2074 setElementFlag(TabStopWasSetExplicitly, true); | |
| 2075 setTabStopInternal(false); | |
| 2076 } else { | |
| 2077 // When value is other than "true", "false", "", the value is ig
nored and | |
| 2078 // falls back the default state. | |
| 2079 clearElementFlag(TabStopWasSetExplicitly); | |
| 2080 setTabStopInternal(tabIndex() >= 0); | |
| 2081 } | |
| 2082 } | |
| 2083 } | 2055 } |
| 2084 } | 2056 } |
| 2085 | 2057 |
| 2086 bool Element::parseAttributeName(QualifiedName& out, const AtomicString& namespa
ceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState) | 2058 bool Element::parseAttributeName(QualifiedName& out, const AtomicString& namespa
ceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState) |
| 2087 { | 2059 { |
| 2088 AtomicString prefix, localName; | 2060 AtomicString prefix, localName; |
| 2089 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio
nState)) | 2061 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio
nState)) |
| 2090 return false; | 2062 return false; |
| 2091 ASSERT(!exceptionState.hadException()); | 2063 ASSERT(!exceptionState.hadException()); |
| 2092 | 2064 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2209 if (document().focusedElement() == this) | 2181 if (document().focusedElement() == this) |
| 2210 return; | 2182 return; |
| 2211 | 2183 |
| 2212 if (!document().isActive()) | 2184 if (!document().isActive()) |
| 2213 return; | 2185 return; |
| 2214 | 2186 |
| 2215 document().updateLayoutIgnorePendingStylesheets(); | 2187 document().updateLayoutIgnorePendingStylesheets(); |
| 2216 if (!isFocusable()) | 2188 if (!isFocusable()) |
| 2217 return; | 2189 return; |
| 2218 | 2190 |
| 2219 if (shadowRoot() && tabIndex() >= 0 && !tabStop()) { | |
| 2220 if (containsIncludingShadowDOM(document().focusedElement())) | |
| 2221 return; | |
| 2222 | |
| 2223 // Slide the focus to its inner node. | |
| 2224 Node* next = document().page()->focusController().findFocusableNode(WebF
ocusTypeForward, *this); | |
| 2225 if (next && next->isElementNode() && containsIncludingShadowDOM(next)) { | |
| 2226 toElement(next)->focus(false, WebFocusTypeForward); | |
| 2227 return; | |
| 2228 } | |
| 2229 } | |
| 2230 | |
| 2231 RefPtrWillBeRawPtr<Node> protect(this); | 2191 RefPtrWillBeRawPtr<Node> protect(this); |
| 2232 if (!document().page()->focusController().setFocusedElement(this, document()
.frame(), type)) | 2192 if (!document().page()->focusController().setFocusedElement(this, document()
.frame(), type)) |
| 2233 return; | 2193 return; |
| 2234 | 2194 |
| 2235 // Setting the focused node above might have invalidated the layout due to s
cripts. | 2195 // Setting the focused node above might have invalidated the layout due to s
cripts. |
| 2236 document().updateLayoutIgnorePendingStylesheets(); | 2196 document().updateLayoutIgnorePendingStylesheets(); |
| 2237 if (!isFocusable()) | 2197 if (!isFocusable()) |
| 2238 return; | 2198 return; |
| 2239 | 2199 |
| 2240 cancelFocusAppearanceUpdate(); | 2200 cancelFocusAppearanceUpdate(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2325 bool Element::isKeyboardFocusable() const | 2285 bool Element::isKeyboardFocusable() const |
| 2326 { | 2286 { |
| 2327 return isFocusable() && tabIndex() >= 0; | 2287 return isFocusable() && tabIndex() >= 0; |
| 2328 } | 2288 } |
| 2329 | 2289 |
| 2330 bool Element::isMouseFocusable() const | 2290 bool Element::isMouseFocusable() const |
| 2331 { | 2291 { |
| 2332 return isFocusable(); | 2292 return isFocusable(); |
| 2333 } | 2293 } |
| 2334 | 2294 |
| 2335 bool Element::tabStop() const | |
| 2336 { | |
| 2337 if (hasElementFlag(TabStopWasSetExplicitly)) | |
| 2338 return elementRareData()->tabStop(); | |
| 2339 return tabIndex() >= 0; | |
| 2340 } | |
| 2341 | |
| 2342 void Element::setTabStop(bool flag) | |
| 2343 { | |
| 2344 // Reflect the value in the HTML attribute. Note that we cannot use setBoole
anAttribute() | |
| 2345 // because the tabstop attribute is an enumerated attribute. | |
| 2346 // After tabstop attribute is set, the property value is modified accordingl
y. | |
| 2347 setAttribute(tabstopAttr, flag ? "true" : "false"); | |
| 2348 } | |
| 2349 | |
| 2350 void Element::setTabStopInternal(bool flag) | |
| 2351 { | |
| 2352 ensureElementRareData().setTabStop(flag); | |
| 2353 if (shadowRoot() && shadowRoot()->containsIncludingShadowDOM(document().focu
sedElement())) | |
| 2354 setFocus(true); | |
| 2355 } | |
| 2356 | |
| 2357 bool Element::isFocusedElementInDocument() const | 2295 bool Element::isFocusedElementInDocument() const |
| 2358 { | 2296 { |
| 2359 return this == document().focusedElement(); | 2297 return this == document().focusedElement(); |
| 2360 } | 2298 } |
| 2361 | 2299 |
| 2362 void Element::dispatchFocusEvent(Element* oldFocusedElement, WebFocusType type) | 2300 void Element::dispatchFocusEvent(Element* oldFocusedElement, WebFocusType type) |
| 2363 { | 2301 { |
| 2364 RefPtrWillBeRawPtr<FocusEvent> event = FocusEvent::create(EventTypeNames::fo
cus, false, false, document().domWindow(), 0, oldFocusedElement); | 2302 RefPtrWillBeRawPtr<FocusEvent> event = FocusEvent::create(EventTypeNames::fo
cus, false, false, document().domWindow(), 0, oldFocusedElement); |
| 2365 EventDispatcher::dispatchEvent(*this, FocusEventDispatchMediator::create(eve
nt.release())); | 2303 EventDispatcher::dispatchEvent(*this, FocusEventDispatchMediator::create(eve
nt.release())); |
| 2366 } | 2304 } |
| (...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3450 { | 3388 { |
| 3451 #if ENABLE(OILPAN) | 3389 #if ENABLE(OILPAN) |
| 3452 if (hasRareData()) | 3390 if (hasRareData()) |
| 3453 visitor->trace(elementRareData()); | 3391 visitor->trace(elementRareData()); |
| 3454 visitor->trace(m_elementData); | 3392 visitor->trace(m_elementData); |
| 3455 #endif | 3393 #endif |
| 3456 ContainerNode::trace(visitor); | 3394 ContainerNode::trace(visitor); |
| 3457 } | 3395 } |
| 3458 | 3396 |
| 3459 } // namespace blink | 3397 } // namespace blink |
| OLD | NEW |