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

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

Issue 2901263002: Introduce SelectionPaintRange 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 12 matching lines...) Expand all
23 #define LayoutSelection_h 23 #define LayoutSelection_h
24 24
25 #include "core/editing/Position.h" 25 #include "core/editing/Position.h"
26 #include "core/editing/VisibleSelection.h" 26 #include "core/editing/VisibleSelection.h"
27 #include "platform/heap/Handle.h" 27 #include "platform/heap/Handle.h"
28 28
29 namespace blink { 29 namespace blink {
30 30
31 class FrameSelection; 31 class FrameSelection;
32 32
33 struct SelectionPaintRange {
yosin_UTC9 2017/05/24 08:38:46 I think it is better to use |class| and make this
yoichio 2017/05/24 09:09:29 Done.
34 DISALLOW_NEW();
35 // The current selection represented as 2 boundaries.
36 // Selection boundaries are represented in LayoutView by a tuple
37 // (LayoutObject, DOM node offset).
38 // See http://www.w3.org/TR/dom/#range for more information.
39 //
40 // |start_layout_object_| and |end_layout_object_| are only valid for
41 // |Text| node without 'transform' or 'first-letter'.
42 //
43 // Those are used for selection painting and paint invalidation upon
44 // selection change.
45 // TODO(editing-dev): Clarify the meaning of |start_offset_| and
46 // |end_offset_|. editing/ passes them as offsets in the DOM tree but layout
47 // uses them as offset in the layout tree.
48 LayoutObject* start_layout_object_;
yosin_UTC9 2017/05/24 08:38:46 nit: Member variable of |struct| should not end wi
yoichio 2017/05/24 09:09:29 Acknowledged.
49 int start_offset_;
50 LayoutObject* end_layout_object_;
51 int end_offset_;
52
53 SelectionPaintRange()
54 : start_layout_object_(nullptr),
yosin_UTC9 2017/05/24 08:38:46 nit: Let's use inline initialization, e.g. Layout
yoichio 2017/05/24 09:09:29 Done.
55 start_offset_(-1),
56 end_layout_object_(nullptr),
57 end_offset_(-1) {}
58 SelectionPaintRange(LayoutObject* start_layout_object,
59 int start_offset,
60 LayoutObject* end_layout_object,
61 int end_offset)
62 : start_layout_object_(start_layout_object),
63 start_offset_(start_offset),
64 end_layout_object_(end_layout_object),
65 end_offset_(end_offset){};
yosin_UTC9 2017/05/24 08:38:46 nit: s/{}/ {}/ We should have DCHECK for paramete
yoichio 2017/05/24 09:09:29 Done.
66
67 bool operator==(const SelectionPaintRange& other) {
yosin_UTC9 2017/05/24 08:38:46 nit: s/{/ const {/ This function should be ".cpp"
yoichio 2017/05/24 09:09:29 Done.
68 return start_layout_object_ == other.start_layout_object_ &&
69 start_offset_ == other.start_offset_ &&
70 end_layout_object_ == other.end_layout_object_ &&
71 end_offset_ == other.end_offset_;
72 }
73 };
74
33 class LayoutSelection final : public GarbageCollected<LayoutSelection> { 75 class LayoutSelection final : public GarbageCollected<LayoutSelection> {
34 public: 76 public:
35 static LayoutSelection* Create(FrameSelection& frame_selection) { 77 static LayoutSelection* Create(FrameSelection& frame_selection) {
36 return new LayoutSelection(frame_selection); 78 return new LayoutSelection(frame_selection);
37 } 79 }
38 80
39 bool HasPendingSelection() const { return has_pending_selection_; } 81 bool HasPendingSelection() const { return has_pending_selection_; }
40 void SetHasPendingSelection() { has_pending_selection_ = true; } 82 void SetHasPendingSelection() { has_pending_selection_ = true; }
41 void Commit(); 83 void Commit();
42 84
43 IntRect SelectionBounds(); 85 IntRect SelectionBounds();
44 void InvalidatePaintForSelection(); 86 void InvalidatePaintForSelection();
45 enum SelectionPaintInvalidationMode { 87 enum SelectionPaintInvalidationMode {
46 kPaintInvalidationNewXOROld, 88 kPaintInvalidationNewXOROld,
47 kPaintInvalidationNewMinusOld 89 kPaintInvalidationNewMinusOld
48 }; 90 };
49 void SetSelection( 91 void SetSelection(
50 LayoutObject* start, 92 const SelectionPaintRange&,
51 int start_pos,
52 LayoutObject*,
53 int end_pos,
54 SelectionPaintInvalidationMode = kPaintInvalidationNewXOROld); 93 SelectionPaintInvalidationMode = kPaintInvalidationNewXOROld);
55 void ClearSelection(); 94 void ClearSelection();
56 std::pair<int, int> SelectionStartEnd(); 95 std::pair<int, int> SelectionStartEnd();
57 void OnDocumentShutdown(); 96 void OnDocumentShutdown();
58 97
59 DECLARE_TRACE(); 98 DECLARE_TRACE();
60 99
61 private: 100 private:
62 LayoutSelection(FrameSelection&); 101 LayoutSelection(FrameSelection&);
63 102
64 SelectionInFlatTree CalcVisibleSelection( 103 SelectionInFlatTree CalcVisibleSelection(
65 const VisibleSelectionInFlatTree&) const; 104 const VisibleSelectionInFlatTree&) const;
66 105
67 Member<FrameSelection> frame_selection_; 106 Member<FrameSelection> frame_selection_;
68 bool has_pending_selection_ : 1; 107 bool has_pending_selection_ : 1;
69 108
70 // The current selection represented as 2 boundaries. 109 SelectionPaintRange paint_range_;
71 // Selection boundaries are represented in LayoutView by a tuple
72 // (LayoutObject, DOM node offset).
73 // See http://www.w3.org/TR/dom/#range for more information.
74 //
75 // |m_selectionStartPos| and |m_selectionEndPos| are only valid for
76 // |Text| node without 'transform' or 'first-letter'.
77 //
78 // Those are used for selection painting and paint invalidation upon
79 // selection change.
80 LayoutObject* selection_start_;
81 LayoutObject* selection_end_;
82
83 // TODO(yosin): Clarify the meaning of these variables. editing/ passes
84 // them as offsets in the DOM tree but layout uses them as offset in the
85 // layout tree.
86 int selection_start_pos_;
87 int selection_end_pos_;
88 }; 110 };
89 111
90 } // namespace blink 112 } // namespace blink
91 113
92 #endif 114 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698