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

Unified Diff: Source/core/html/HTMLOptGroupElement.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/html/HTMLObjectElement.cpp ('k') | Source/core/html/HTMLOptionElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLOptGroupElement.cpp
diff --git a/Source/core/html/HTMLOptGroupElement.cpp b/Source/core/html/HTMLOptGroupElement.cpp
index 314e220d088510271d3c705f7d8c1ff1d8a13450..d9f835b0faf0c1bed924df7183c59ed7dc6dc81b 100644
--- a/Source/core/html/HTMLOptGroupElement.cpp
+++ b/Source/core/html/HTMLOptGroupElement.cpp
@@ -75,11 +75,8 @@ void HTMLOptGroupElement::parseAttribute(const QualifiedName& name, const Atomic
void HTMLOptGroupElement::recalcSelectOptions()
{
- ContainerNode* select = parentNode();
- while (select && !isHTMLSelectElement(*select))
- select = select->parentNode();
- if (select)
- toHTMLSelectElement(select)->setRecalcListItems();
+ if (HTMLSelectElement* select = Traversal<HTMLSelectElement>::firstAncestor(*this))
+ select->setRecalcListItems();
}
void HTMLOptGroupElement::attach(const AttachContext& context)
@@ -127,14 +124,7 @@ String HTMLOptGroupElement::groupLabelText() const
HTMLSelectElement* HTMLOptGroupElement::ownerSelectElement() const
{
- ContainerNode* select = parentNode();
- while (select && !isHTMLSelectElement(*select))
- select = select->parentNode();
-
- if (!select)
- return 0;
-
- return toHTMLSelectElement(select);
+ return Traversal<HTMLSelectElement>::firstAncestor(*this);
}
void HTMLOptGroupElement::accessKeyAction(bool)
« no previous file with comments | « Source/core/html/HTMLObjectElement.cpp ('k') | Source/core/html/HTMLOptionElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698