Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: Source/core/dom/Element.cpp

Issue 397303005: Add Traversal<>::firstAncestorOrSelf() overload taking a const reference in argument (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/dom/ElementTraversal.h » ('j') | Source/core/dom/ElementTraversal.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 #include "core/editing/htmlediting.h" 75 #include "core/editing/htmlediting.h"
76 #include "core/editing/markup.h" 76 #include "core/editing/markup.h"
77 #include "core/events/EventDispatcher.h" 77 #include "core/events/EventDispatcher.h"
78 #include "core/events/FocusEvent.h" 78 #include "core/events/FocusEvent.h"
79 #include "core/frame/FrameView.h" 79 #include "core/frame/FrameView.h"
80 #include "core/frame/LocalFrame.h" 80 #include "core/frame/LocalFrame.h"
81 #include "core/frame/Settings.h" 81 #include "core/frame/Settings.h"
82 #include "core/frame/UseCounter.h" 82 #include "core/frame/UseCounter.h"
83 #include "core/frame/csp/ContentSecurityPolicy.h" 83 #include "core/frame/csp/ContentSecurityPolicy.h"
84 #include "core/html/ClassList.h" 84 #include "core/html/ClassList.h"
85 #include "core/html/HTMLCanvasElement.h"
85 #include "core/html/HTMLCollection.h" 86 #include "core/html/HTMLCollection.h"
86 #include "core/html/HTMLDocument.h" 87 #include "core/html/HTMLDocument.h"
87 #include "core/html/HTMLElement.h" 88 #include "core/html/HTMLElement.h"
88 #include "core/html/HTMLFormControlsCollection.h" 89 #include "core/html/HTMLFormControlsCollection.h"
89 #include "core/html/HTMLFrameElementBase.h" 90 #include "core/html/HTMLFrameElementBase.h"
90 #include "core/html/HTMLFrameOwnerElement.h" 91 #include "core/html/HTMLFrameOwnerElement.h"
91 #include "core/html/HTMLLabelElement.h" 92 #include "core/html/HTMLLabelElement.h"
92 #include "core/html/HTMLOptionsCollection.h" 93 #include "core/html/HTMLOptionsCollection.h"
93 #include "core/html/HTMLTableRowsCollection.h" 94 #include "core/html/HTMLTableRowsCollection.h"
94 #include "core/html/HTMLTemplateElement.h" 95 #include "core/html/HTMLTemplateElement.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 short Element::tabIndex() const 218 short Element::tabIndex() const
218 { 219 {
219 return hasRareData() ? elementRareData()->tabIndex() : 0; 220 return hasRareData() ? elementRareData()->tabIndex() : 0;
220 } 221 }
221 222
222 bool Element::rendererIsFocusable() const 223 bool Element::rendererIsFocusable() const
223 { 224 {
224 // Elements in canvas fallback content are not rendered, but they are allowe d to be 225 // Elements in canvas fallback content are not rendered, but they are allowe d to be
225 // focusable as long as their canvas is displayed and visible. 226 // focusable as long as their canvas is displayed and visible.
226 if (isInCanvasSubtree()) { 227 if (isInCanvasSubtree()) {
227 const Element* e = this; 228 const HTMLCanvasElement* canvas = Traversal<HTMLCanvasElement>::firstAnc estorOrSelf(*this);
228 while (e && !e->hasLocalName(canvasTag)) 229 ASSERT(canvas);
229 e = e->parentElement(); 230 return canvas->renderer() && canvas->renderer()->style()->visibility() = = VISIBLE;
230 ASSERT(e);
231 return e->renderer() && e->renderer()->style()->visibility() == VISIBLE;
232 } 231 }
233 232
234 // FIXME: These asserts should be in Node::isFocusable, but there are some 233 // FIXME: These asserts should be in Node::isFocusable, but there are some
235 // callsites like Document::setFocusedElement that would currently fail on 234 // callsites like Document::setFocusedElement that would currently fail on
236 // them. See crbug.com/251163 235 // them. See crbug.com/251163
237 if (!renderer()) { 236 if (!renderer()) {
238 // We can't just use needsStyleRecalc() because if the node is in a 237 // We can't just use needsStyleRecalc() because if the node is in a
239 // display:none tree it might say it needs style recalc but the whole 238 // display:none tree it might say it needs style recalc but the whole
240 // document is actually up to date. 239 // document is actually up to date.
241 ASSERT(!document().childNeedsStyleRecalc()); 240 ASSERT(!document().childNeedsStyleRecalc());
(...skipping 3126 matching lines...) Expand 10 before | Expand all | Expand 10 after
3368 { 3367 {
3369 #if ENABLE(OILPAN) 3368 #if ENABLE(OILPAN)
3370 if (hasRareData()) 3369 if (hasRareData())
3371 visitor->trace(elementRareData()); 3370 visitor->trace(elementRareData());
3372 visitor->trace(m_elementData); 3371 visitor->trace(m_elementData);
3373 #endif 3372 #endif
3374 ContainerNode::trace(visitor); 3373 ContainerNode::trace(visitor);
3375 } 3374 }
3376 3375
3377 } // namespace WebCore 3376 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/ElementTraversal.h » ('j') | Source/core/dom/ElementTraversal.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698