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

Side by Side Diff: third_party/WebKit/Source/core/paint/PartPainter.cpp

Issue 2916493002: Make SelectionState enum class (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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/PartPainter.h" 5 #include "core/paint/PartPainter.h"
6 6
7 #include "core/frame/FrameOrPlugin.h" 7 #include "core/frame/FrameOrPlugin.h"
8 #include "core/layout/LayoutPart.h" 8 #include "core/layout/LayoutPart.h"
9 #include "core/paint/BoxPainter.h" 9 #include "core/paint/BoxPainter.h"
10 #include "core/paint/LayoutObjectDrawingRecorder.h" 10 #include "core/paint/LayoutObjectDrawingRecorder.h"
11 #include "core/paint/ObjectPainter.h" 11 #include "core/paint/ObjectPainter.h"
12 #include "core/paint/PaintInfo.h" 12 #include "core/paint/PaintInfo.h"
13 #include "core/paint/PaintLayer.h" 13 #include "core/paint/PaintLayer.h"
14 #include "core/paint/ReplacedPainter.h" 14 #include "core/paint/ReplacedPainter.h"
15 #include "core/paint/RoundedInnerRectClipper.h" 15 #include "core/paint/RoundedInnerRectClipper.h"
16 #include "core/paint/ScrollableAreaPainter.h" 16 #include "core/paint/ScrollableAreaPainter.h"
17 #include "core/paint/TransformRecorder.h" 17 #include "core/paint/TransformRecorder.h"
18 #include "platform/wtf/Optional.h" 18 #include "platform/wtf/Optional.h"
19 19
20 namespace blink { 20 namespace blink {
21 21
22 bool PartPainter::IsSelected() const { 22 bool PartPainter::IsSelected() const {
23 SelectionState s = layout_part_.GetSelectionState(); 23 SelectionState s = layout_part_.GetSelectionState();
24 if (s == SelectionNone) 24 if (s == SelectionState::kNone)
25 return false; 25 return false;
26 if (s == SelectionInside) 26 if (s == SelectionState::kInside)
27 return true; 27 return true;
28 28
29 int selection_start, selection_end; 29 int selection_start, selection_end;
30 std::tie(selection_start, selection_end) = layout_part_.SelectionStartEnd(); 30 std::tie(selection_start, selection_end) = layout_part_.SelectionStartEnd();
31 if (s == SelectionStart) 31 if (s == SelectionState::kStart)
32 return selection_start == 0; 32 return selection_start == 0;
33 33
34 int end = layout_part_.GetNode()->hasChildren() 34 int end = layout_part_.GetNode()->hasChildren()
35 ? layout_part_.GetNode()->CountChildren() 35 ? layout_part_.GetNode()->CountChildren()
36 : 1; 36 : 1;
37 if (s == SelectionEnd) 37 if (s == SelectionState::kEnd)
38 return selection_end == end; 38 return selection_end == end;
39 if (s == SelectionBoth) 39 if (s == SelectionState::kStartAndEnd)
40 return selection_start == 0 && selection_end == end; 40 return selection_start == 0 && selection_end == end;
41 41
42 DCHECK(0); 42 DCHECK(0);
43 return false; 43 return false;
44 } 44 }
45 45
46 void PartPainter::Paint(const PaintInfo& paint_info, 46 void PartPainter::Paint(const PaintInfo& paint_info,
47 const LayoutPoint& paint_offset) { 47 const LayoutPoint& paint_offset) {
48 ObjectPainter(layout_part_).CheckPaintOffset(paint_info, paint_offset); 48 ObjectPainter(layout_part_).CheckPaintOffset(paint_info, paint_offset);
49 LayoutPoint adjusted_paint_offset = paint_offset + layout_part_.Location(); 49 LayoutPoint adjusted_paint_offset = paint_offset + layout_part_.Location();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 paint_location - frame_or_plugin->FrameRect().Location(); 134 paint_location - frame_or_plugin->FrameRect().Location();
135 TransformRecorder transform( 135 TransformRecorder transform(
136 paint_info.context, layout_part_, 136 paint_info.context, layout_part_,
137 AffineTransform::Translation(view_paint_offset.Width(), 137 AffineTransform::Translation(view_paint_offset.Width(),
138 view_paint_offset.Height())); 138 view_paint_offset.Height()));
139 CullRect adjusted_cull_rect(paint_info.GetCullRect(), -view_paint_offset); 139 CullRect adjusted_cull_rect(paint_info.GetCullRect(), -view_paint_offset);
140 frame_or_plugin->Paint(paint_info.context, adjusted_cull_rect); 140 frame_or_plugin->Paint(paint_info.context, adjusted_cull_rect);
141 } 141 }
142 142
143 } // namespace blink 143 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/ListMarkerPainter.cpp ('k') | third_party/WebKit/Source/core/paint/ReplacedPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698