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

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: Slight clean up 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
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)

Powered by Google App Engine
This is Rietveld 408576698