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

Side by Side Diff: third_party/WebKit/Source/core/editing/LayoutSelection.h

Issue 2921863002: Introduce range-based for loop in LayoutSelection. (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2006 Apple Computer, Inc. 3 * Copyright (C) 2006 Apple Computer, Inc.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 26 matching lines...) Expand all
37 // 2 LayoutObjects are only valid for |Text| node without 'transform' or 37 // 2 LayoutObjects are only valid for |Text| node without 'transform' or
38 // 'first-letter'. 38 // 'first-letter'.
39 // TODO(editing-dev): Clarify the meaning of "offset". 39 // TODO(editing-dev): Clarify the meaning of "offset".
40 // editing/ passes them as offsets in the DOM tree but layout uses them as 40 // editing/ passes them as offsets in the DOM tree but layout uses them as
41 // offset in the layout tree. This doesn't work in the cases of 41 // offset in the layout tree. This doesn't work in the cases of
42 // CSS first-letter or character transform. See crbug.com/17528. 42 // CSS first-letter or character transform. See crbug.com/17528.
43 class SelectionPaintRange { 43 class SelectionPaintRange {
44 DISALLOW_NEW(); 44 DISALLOW_NEW();
45 45
46 public: 46 public:
47 class Iterator
48 : public std::iterator<std::input_iterator_tag, LayoutObject*> {
49 public:
50 explicit Iterator(const SelectionPaintRange*);
51 Iterator(const Iterator&) = default;
52 bool operator==(const Iterator& other) const {
53 return current_ == other.current_;
54 }
55 bool operator!=(const Iterator& other) const {
56 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.
57 }
58 Iterator& operator++();
59 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.
60
61 private:
62 LayoutObject* current_;
63 const LayoutObject* included_end_;
64 const LayoutObject* stop_;
65 };
66 Iterator begin() const { return Iterator(this); };
67 Iterator end() const { return Iterator(nullptr); };
68
47 SelectionPaintRange() = default; 69 SelectionPaintRange() = default;
48 SelectionPaintRange(LayoutObject* start_layout_object, 70 SelectionPaintRange(LayoutObject* start_layout_object,
49 int start_offset, 71 int start_offset,
50 LayoutObject* end_layout_object, 72 LayoutObject* end_layout_object,
51 int end_offset); 73 int end_offset);
52 74
53 bool operator==(const SelectionPaintRange& other) const; 75 bool operator==(const SelectionPaintRange& other) const;
54 76
55 LayoutObject* StartLayoutObject() const; 77 LayoutObject* StartLayoutObject() const;
56 int StartOffset() const; 78 int StartOffset() const;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 115
94 Member<FrameSelection> frame_selection_; 116 Member<FrameSelection> frame_selection_;
95 bool has_pending_selection_ : 1; 117 bool has_pending_selection_ : 1;
96 118
97 SelectionPaintRange paint_range_; 119 SelectionPaintRange paint_range_;
98 }; 120 };
99 121
100 } // namespace blink 122 } // namespace blink
101 123
102 #endif 124 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698