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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/dom/ElementTraversal.h » ('j') | Source/core/dom/ElementTraversal.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 438e0a2b670744d44c94116f38379b5e31d74ef4..e1417ce42663cae175d11cdeeb2564920dc745b5 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -82,6 +82,7 @@
#include "core/frame/UseCounter.h"
#include "core/frame/csp/ContentSecurityPolicy.h"
#include "core/html/ClassList.h"
+#include "core/html/HTMLCanvasElement.h"
#include "core/html/HTMLCollection.h"
#include "core/html/HTMLDocument.h"
#include "core/html/HTMLElement.h"
@@ -224,11 +225,9 @@ bool Element::rendererIsFocusable() const
// Elements in canvas fallback content are not rendered, but they are allowed to be
// focusable as long as their canvas is displayed and visible.
if (isInCanvasSubtree()) {
- const Element* e = this;
- while (e && !e->hasLocalName(canvasTag))
- e = e->parentElement();
- ASSERT(e);
- return e->renderer() && e->renderer()->style()->visibility() == VISIBLE;
+ const HTMLCanvasElement* canvas = Traversal<HTMLCanvasElement>::firstAncestorOrSelf(*this);
+ ASSERT(canvas);
+ return canvas->renderer() && canvas->renderer()->style()->visibility() == VISIBLE;
}
// FIXME: These asserts should be in Node::isFocusable, but there are some
« 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