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

Unified Diff: third_party/WebKit/Source/core/editing/DOMSelection.cpp

Issue 2783103002: Dispose temporary and not-cached Range in DOMSelection
Patch Set: update Created 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/DOMSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/DOMSelection.cpp b/third_party/WebKit/Source/core/editing/DOMSelection.cpp
index d473161afba0f1e496fda0842d1b9f6079b6c2fb..5baad3bab0b5703e3fdb928a53a847f096b230f8 100644
--- a/third_party/WebKit/Source/core/editing/DOMSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/DOMSelection.cpp
@@ -538,7 +538,12 @@ Range* DOMSelection::getRangeAt(unsigned index,
}
Range* DOMSelection::primaryRangeOrNull() const {
- return rangeCount() > 0 ? getRangeAt(0, ASSERT_NO_EXCEPTION) : nullptr;
+ if (rangeCount() <= 0)
+ return nullptr;
+ Range* range = getRangeAt(0, ASSERT_NO_EXCEPTION);
+ if (!isSelectionOfDocument())
yosin_UTC9 2017/04/04 04:50:07 I'm not a fan of this approach. We still create te
yoichio 2017/04/04 05:32:42 Creating temporary Ranges and Disposing them is di
yosin_UTC9 2017/04/04 07:21:31 Calling Range::dispose() is error prone in this ca
tkent 2017/04/04 08:41:24 I agree that it's a hack :) If we have no reason t
+ range->dispose();
+ return range;
}
EphemeralRange DOMSelection::createRangeFromSelectionEditor() const {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698