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

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

Issue 2901263002: Introduce SelectionPaintRange in LayoutSelection (Closed)
Patch Set: Make SelectionPaintRange immutable 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 17b7c6dc7f5b15a0e312cb984899cfd2868aed52..138fd15821fcf07b857b923b783debebcd2968cc 100644
--- a/third_party/WebKit/Source/core/editing/LayoutSelection.h
+++ b/third_party/WebKit/Source/core/editing/LayoutSelection.h
@@ -30,6 +30,44 @@ namespace blink {
class FrameSelection;
+class SelectionPaintRange {
+ DISALLOW_NEW();
+
+ public:
+ SelectionPaintRange() = default;
+ SelectionPaintRange(LayoutObject* start_layout_object,
+ int start_offset,
+ LayoutObject* end_layout_object,
+ int end_offset);
+
+ bool operator==(const SelectionPaintRange& other) const;
+ bool operator!=(const SelectionPaintRange& other) const;
+
+ LayoutObject* StartLayoutObject() const { return start_layout_object_; }
yosin_UTC9 2017/05/24 09:31:18 Let's have |IsNull()| and we should not make gette
yoichio 2017/05/25 02:00:36 Done.
+ int StartOffset() const { return start_offset_; }
+ LayoutObject* EndLayoutObject() const { return end_layout_object_; }
+ int EndOffset() const { return end_offset_; }
+
+ private:
+ // The current selection represented as 2 boundaries.
+ // Selection boundaries are represented in LayoutView by a tuple
+ // (LayoutObject, DOM node offset).
+ // See http://www.w3.org/TR/dom/#range for more information.
+ //
+ // |start_layout_object_| and |end_layout_object_| are only valid for
+ // |Text| node without 'transform' or 'first-letter'.
+ //
+ // Those are used for selection painting and paint invalidation upon
+ // selection change.
+ // TODO(editing-dev): Clarify the meaning of |start_offset_| and
+ // |end_offset_|. editing/ passes them as offsets in the DOM tree but layout
+ // uses them as offset in the layout tree.
+ LayoutObject* start_layout_object_ = nullptr;
+ int start_offset_ = -1;
+ LayoutObject* end_layout_object_ = nullptr;
+ int end_offset_ = -1;
+};
+
class LayoutSelection final : public GarbageCollected<LayoutSelection> {
public:
static LayoutSelection* Create(FrameSelection& frame_selection) {
@@ -47,10 +85,7 @@ class LayoutSelection final : public GarbageCollected<LayoutSelection> {
kPaintInvalidationNewMinusOld
};
void SetSelection(
- LayoutObject* start,
- int start_pos,
- LayoutObject*,
- int end_pos,
+ const SelectionPaintRange&,
SelectionPaintInvalidationMode = kPaintInvalidationNewXOROld);
void ClearSelection();
std::pair<int, int> SelectionStartEnd();
@@ -67,24 +102,7 @@ class LayoutSelection final : public GarbageCollected<LayoutSelection> {
Member<FrameSelection> frame_selection_;
bool has_pending_selection_ : 1;
- // The current selection represented as 2 boundaries.
- // Selection boundaries are represented in LayoutView by a tuple
- // (LayoutObject, DOM node offset).
- // See http://www.w3.org/TR/dom/#range for more information.
- //
- // |m_selectionStartPos| and |m_selectionEndPos| are only valid for
- // |Text| node without 'transform' or 'first-letter'.
- //
- // Those are used for selection painting and paint invalidation upon
- // selection change.
- LayoutObject* selection_start_;
- LayoutObject* selection_end_;
-
- // TODO(yosin): Clarify the meaning of these variables. editing/ passes
- // them as offsets in the DOM tree but layout uses them as offset in the
- // layout tree.
- int selection_start_pos_;
- int selection_end_pos_;
+ SelectionPaintRange paint_range_;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698