 Chromium Code Reviews
 Chromium Code Reviews Issue 2921863002:
  Introduce range-based for loop in LayoutSelection.  (Closed)
    
  
    Issue 2921863002:
  Introduce range-based for loop in LayoutSelection.  (Closed) 
  | 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, |