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

Unified Diff: third_party/WebKit/Source/core/editing/LayoutSelection.h

Issue 2921863002: Introduce range-based for loop in LayoutSelection. (Closed)
Patch Set: Created 3 years, 7 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: third_party/WebKit/Source/core/editing/LayoutSelection.h
diff --git a/third_party/WebKit/Source/core/editing/LayoutSelection.h b/third_party/WebKit/Source/core/editing/LayoutSelection.h
index 253275660843da4575402697e35a0a9115120ecc..d6d78a73afe3d5741965fabc44fd417f50dba73c 100644
--- a/third_party/WebKit/Source/core/editing/LayoutSelection.h
+++ b/third_party/WebKit/Source/core/editing/LayoutSelection.h
@@ -44,6 +44,28 @@ class SelectionPaintRange {
DISALLOW_NEW();
public:
+ class Iterator
+ : public std::iterator<std::input_iterator_tag, LayoutObject*> {
+ public:
+ explicit Iterator(const SelectionPaintRange*);
+ Iterator(const Iterator&) = default;
+ bool operator==(const Iterator& other) const {
+ return current_ == other.current_;
+ }
+ bool operator!=(const Iterator& other) const {
+ return current_ != other.current_;
yosin_UTC9 2017/06/02 08:35:44 |return !operator==(other)| is better.
yoichio 2017/06/12 06:12:52 Done.
+ }
+ Iterator& operator++();
+ LayoutObject* operator*() const { return current_; }
yosin_UTC9 2017/06/02 08:35:44 We should have DCHECK(current_);
yoichio 2017/06/12 06:12:52 Done.
+
+ private:
+ LayoutObject* current_;
+ const LayoutObject* included_end_;
+ const LayoutObject* stop_;
+ };
+ Iterator begin() const { return Iterator(this); };
+ Iterator end() const { return Iterator(nullptr); };
+
SelectionPaintRange() = default;
SelectionPaintRange(LayoutObject* start_layout_object,
int start_offset,

Powered by Google App Engine
This is Rietveld 408576698