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

Unified Diff: Source/core/dom/Position.cpp

Issue 482903002: Get rid of loops looking for the first Element ancestor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update one more instance Created 6 years, 4 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/dom/Position.cpp
diff --git a/Source/core/dom/Position.cpp b/Source/core/dom/Position.cpp
index 63fb25c95d51ace7c8bec00fa511bd12260750d0..57412cc93cbeede2e33591cd1e35d805ca413207 100644
--- a/Source/core/dom/Position.cpp
+++ b/Source/core/dom/Position.cpp
@@ -279,9 +279,9 @@ Position::AnchorType Position::anchorTypeForLegacyEditingPosition(Node* anchorNo
Element* Position::element() const
{
Node* n = anchorNode();
- while (n && !n->isElementNode())
- n = n->parentNode();
- return toElement(n);
+ if (!n || n->isElementNode())
+ return toElement(n);
+ return n->parentElement();
esprehn 2014/08/19 01:02:45 n -> node
Inactive 2014/08/19 12:51:45 Done.
}
PassRefPtrWillBeRawPtr<CSSComputedStyleDeclaration> Position::computedStyle() const

Powered by Google App Engine
This is Rietveld 408576698