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

Unified Diff: Source/core/html/HTMLElement.cpp

Issue 201293002: Add Traversal<*Element>::firstAncestor() API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add firstAncestorOrSelf() Created 6 years, 9 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 | « Source/core/editing/FrameSelection.cpp ('k') | Source/core/html/HTMLEmbedElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLElement.cpp
diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp
index d07e5ad529976f660040219d04a06dde203b44f2..57cd08514ec9b1a293ebb29528433b9bfd21a2e2 100644
--- a/Source/core/html/HTMLElement.cpp
+++ b/Source/core/html/HTMLElement.cpp
@@ -610,13 +610,11 @@ TranslateAttributeMode HTMLElement::translateAttributeMode() const
bool HTMLElement::translate() const
{
- for (const Node* n = this; n; n = n->parentNode()) {
- if (n->isHTMLElement()) {
- TranslateAttributeMode mode = toHTMLElement(n)->translateAttributeMode();
- if (mode != TranslateAttributeInherit) {
- ASSERT(mode == TranslateAttributeYes || mode == TranslateAttributeNo);
- return mode == TranslateAttributeYes;
- }
+ for (const HTMLElement* element = this; element; element = Traversal<HTMLElement>::firstAncestor(*element)) {
+ TranslateAttributeMode mode = element->translateAttributeMode();
+ if (mode != TranslateAttributeInherit) {
+ ASSERT(mode == TranslateAttributeYes || mode == TranslateAttributeNo);
+ return mode == TranslateAttributeYes;
}
}
@@ -631,11 +629,7 @@ void HTMLElement::setTranslate(bool enable)
HTMLFormElement* HTMLElement::findFormAncestor() const
{
- for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode()) {
- if (isHTMLFormElement(*ancestor))
- return toHTMLFormElement(ancestor);
- }
- return 0;
+ return Traversal<HTMLFormElement>::firstAncestor(*this);
}
static inline bool elementAffectsDirectionality(const Node* node)
« no previous file with comments | « Source/core/editing/FrameSelection.cpp ('k') | Source/core/html/HTMLEmbedElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698