Index: Source/core/editing/FrameSelection.cpp |
diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp |
index 0c6083da2dbe8c3e0c54be10ef36358e84826cc6..ccf5d819810d8996ec86a9d5ca8a3fb0ab2bee86 100644 |
--- a/Source/core/editing/FrameSelection.cpp |
+++ b/Source/core/editing/FrameSelection.cpp |
@@ -1751,15 +1751,12 @@ HTMLFormElement* FrameSelection::currentForm() const |
start = this->start().deprecatedNode(); |
// Try walking up the node tree to find a form element. |
- Node* node; |
- for (node = start; node; node = node->parentNode()) { |
- if (isHTMLFormElement(*node)) |
- return toHTMLFormElement(node); |
- if (node->isHTMLElement()) { |
- HTMLFormElement* owner = toHTMLElement(node)->formOwner(); |
- if (owner) |
- return owner; |
- } |
+ HTMLElement* element = !start || start->isHTMLElement() ? toHTMLElement(start) : Traversal<HTMLElement>::firstAncestor(*start); |
esprehn
2014/03/21 07:58:33
This seems like it makes the code less readable.
Inactive
2014/03/21 14:37:24
Fair enough, I gave it another shot.
|
+ for (; element; element = Traversal<HTMLElement>::firstAncestor(*element)) { |
+ if (isHTMLFormElement(*element)) |
+ return toHTMLFormElement(element); |
+ if (HTMLFormElement* owner = element->formOwner()) |
+ return owner; |
} |
// Try walking forward in the node tree to find a form element. |