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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 bool Element::layoutObjectIsFocusable() const | 251 bool Element::layoutObjectIsFocusable() const |
| 252 { | 252 { |
| 253 // Elements in canvas fallback content are not rendered, but they are allowe d to be | 253 // Elements in canvas fallback content are not rendered, but they are allowe d to be |
| 254 // focusable as long as their canvas is displayed and visible. | 254 // focusable as long as their canvas is displayed and visible. |
| 255 if (isInCanvasSubtree()) { | 255 if (isInCanvasSubtree()) { |
| 256 const HTMLCanvasElement* canvas = Traversal<HTMLCanvasElement>::firstAnc estorOrSelf(*this); | 256 const HTMLCanvasElement* canvas = Traversal<HTMLCanvasElement>::firstAnc estorOrSelf(*this); |
| 257 ASSERT(canvas); | 257 ASSERT(canvas); |
| 258 return canvas->layoutObject() && canvas->layoutObject()->style()->visibi lity() == VISIBLE; | 258 return canvas->layoutObject() && canvas->layoutObject()->style()->visibi lity() == VISIBLE; |
| 259 } | 259 } |
| 260 | 260 |
| 261 // FIXME: These asserts should be in Node::isFocusable, but there are some | |
| 262 // callsites like Document::setFocusedElement that would currently fail on | |
| 263 // them. See crbug.com/251163 | |
| 264 if (!layoutObject()) { | |
| 265 // We can't just use needsStyleRecalc() because if the node is in a | |
| 266 // display:none tree it might say it needs style recalc but the whole | |
| 267 // document is actually up to date. | |
| 268 // In addition, style cannot be cleared out for non-active documents, | |
| 269 // so in that case the childNeedsStyleRecalc check is invalid. | |
| 270 ASSERT(!document().isActive() || !document().childNeedsStyleRecalc()); | |
| 271 } | |
| 272 | |
| 273 // FIXME: Even if we are not visible, we might have a child that is visible. | 261 // FIXME: Even if we are not visible, we might have a child that is visible. |
| 274 // Hyatt wants to fix that some day with a "has visible content" flag or the like. | 262 // Hyatt wants to fix that some day with a "has visible content" flag or the like. |
| 275 if (!layoutObject() || layoutObject()->style()->visibility() != VISIBLE) | 263 return layoutObject() && layoutObject()->style()->visibility() == VISIBLE; |
| 276 return false; | |
| 277 | |
| 278 return true; | |
| 279 } | 264 } |
| 280 | 265 |
| 281 PassRefPtrWillBeRawPtr<Node> Element::cloneNode(bool deep) | 266 PassRefPtrWillBeRawPtr<Node> Element::cloneNode(bool deep) |
| 282 { | 267 { |
| 283 return deep ? cloneElementWithChildren() : cloneElementWithoutChildren(); | 268 return deep ? cloneElementWithChildren() : cloneElementWithoutChildren(); |
| 284 } | 269 } |
| 285 | 270 |
| 286 PassRefPtrWillBeRawPtr<Element> Element::cloneElementWithChildren() | 271 PassRefPtrWillBeRawPtr<Element> Element::cloneElementWithChildren() |
| 287 { | 272 { |
| 288 RefPtrWillBeRawPtr<Element> clone = cloneElementWithoutChildren(); | 273 RefPtrWillBeRawPtr<Element> clone = cloneElementWithoutChildren(); |
| (...skipping 2150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2439 if (!isSVGElement()) | 2424 if (!isSVGElement()) |
| 2440 return false; | 2425 return false; |
| 2441 return (hasEventListeners(EventTypeNames::focus) | 2426 return (hasEventListeners(EventTypeNames::focus) |
| 2442 || hasEventListeners(EventTypeNames::blur) | 2427 || hasEventListeners(EventTypeNames::blur) |
| 2443 || hasEventListeners(EventTypeNames::focusin) | 2428 || hasEventListeners(EventTypeNames::focusin) |
| 2444 || hasEventListeners(EventTypeNames::focusout)); | 2429 || hasEventListeners(EventTypeNames::focusout)); |
| 2445 } | 2430 } |
| 2446 | 2431 |
| 2447 bool Element::isFocusable() const | 2432 bool Element::isFocusable() const |
| 2448 { | 2433 { |
| 2434 ASSERT(!document().isActive() || !document().childNeedsStyleRecalc()); | |
|
falken
2016/02/05 04:42:40
Was the comment about using childNeedsStyleRecalc(
tkent
2016/02/05 04:57:45
Ah, the comment is still valid. I add it again.
| |
| 2449 return inDocument() && supportsFocus() && !isInert() && layoutObjectIsFocusa ble(); | 2435 return inDocument() && supportsFocus() && !isInert() && layoutObjectIsFocusa ble(); |
| 2450 } | 2436 } |
| 2451 | 2437 |
| 2452 bool Element::isKeyboardFocusable() const | 2438 bool Element::isKeyboardFocusable() const |
| 2453 { | 2439 { |
| 2454 return isFocusable() && tabIndex() >= 0; | 2440 return isFocusable() && tabIndex() >= 0; |
| 2455 } | 2441 } |
| 2456 | 2442 |
| 2457 bool Element::isMouseFocusable() const | 2443 bool Element::isMouseFocusable() const |
| 2458 { | 2444 { |
| (...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3623 { | 3609 { |
| 3624 #if ENABLE(OILPAN) | 3610 #if ENABLE(OILPAN) |
| 3625 if (hasRareData()) | 3611 if (hasRareData()) |
| 3626 visitor->trace(elementRareData()); | 3612 visitor->trace(elementRareData()); |
| 3627 visitor->trace(m_elementData); | 3613 visitor->trace(m_elementData); |
| 3628 #endif | 3614 #endif |
| 3629 ContainerNode::trace(visitor); | 3615 ContainerNode::trace(visitor); |
| 3630 } | 3616 } |
| 3631 | 3617 |
| 3632 } // namespace blink | 3618 } // namespace blink |
| OLD | NEW |