OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "core/rendering/RenderBox.h" | 28 #include "core/rendering/RenderBox.h" |
29 #include "platform/geometry/IntRect.h" | 29 #include "platform/geometry/IntRect.h" |
30 | 30 |
31 namespace blink { | 31 namespace blink { |
32 | 32 |
33 class RenderSelectionInfoBase : public NoBaseWillBeGarbageCollected<RenderSelect
ionInfoBase> { | 33 class RenderSelectionInfoBase : public NoBaseWillBeGarbageCollected<RenderSelect
ionInfoBase> { |
34 WTF_MAKE_NONCOPYABLE(RenderSelectionInfoBase); WTF_MAKE_FAST_ALLOCATED_WILL_
BE_REMOVED; | 34 WTF_MAKE_NONCOPYABLE(RenderSelectionInfoBase); WTF_MAKE_FAST_ALLOCATED_WILL_
BE_REMOVED; |
35 public: | 35 public: |
36 RenderSelectionInfoBase() | 36 RenderSelectionInfoBase() |
37 : m_object(nullptr) | 37 : m_object(nullptr) |
38 , m_repaintContainer(nullptr) | 38 , m_paintInvalidationContainer(nullptr) |
39 , m_state(RenderObject::SelectionNone) | 39 , m_state(RenderObject::SelectionNone) |
40 { | 40 { |
41 } | 41 } |
42 | 42 |
43 RenderSelectionInfoBase(RenderObject* o) | 43 RenderSelectionInfoBase(RenderObject* o) |
44 : m_object(o) | 44 : m_object(o) |
45 , m_repaintContainer(o->containerForPaintInvalidation()) | 45 , m_paintInvalidationContainer(o->containerForPaintInvalidation()) |
46 , m_state(o->selectionState()) | 46 , m_state(o->selectionState()) |
47 { | 47 { |
48 } | 48 } |
49 | 49 |
50 void trace(Visitor* visitor) | 50 void trace(Visitor* visitor) |
51 { | 51 { |
52 visitor->trace(m_object); | 52 visitor->trace(m_object); |
53 visitor->trace(m_repaintContainer); | 53 visitor->trace(m_paintInvalidationContainer); |
54 } | 54 } |
55 | 55 |
56 RenderObject* object() const { return m_object; } | 56 RenderObject* object() const { return m_object; } |
57 const RenderLayerModelObject* repaintContainer() const { return m_repaintCon
tainer; } | 57 const RenderLayerModelObject* paintInvalidationContainer() const { return m_
paintInvalidationContainer; } |
58 RenderObject::SelectionState state() const { return m_state; } | 58 RenderObject::SelectionState state() const { return m_state; } |
59 | 59 |
60 protected: | 60 protected: |
61 RawPtrWillBeMember<RenderObject> m_object; | 61 RawPtrWillBeMember<RenderObject> m_object; |
62 RawPtrWillBeMember<const RenderLayerModelObject> m_repaintContainer; | 62 RawPtrWillBeMember<const RenderLayerModelObject> m_paintInvalidationContaine
r; |
63 RenderObject::SelectionState m_state; | 63 RenderObject::SelectionState m_state; |
64 }; | 64 }; |
65 | 65 |
66 // This struct is used when the selection changes to cache the old and new state
of the selection for each RenderObject. | 66 // This struct is used when the selection changes to cache the old and new state
of the selection for each RenderObject. |
67 class RenderSelectionInfo FINAL : public RenderSelectionInfoBase { | 67 class RenderSelectionInfo FINAL : public RenderSelectionInfoBase { |
68 public: | 68 public: |
69 RenderSelectionInfo(RenderObject* o, bool clipToVisibleContent) | 69 RenderSelectionInfo(RenderObject* o, bool clipToVisibleContent) |
70 : RenderSelectionInfoBase(o) | 70 : RenderSelectionInfoBase(o) |
71 { | 71 { |
72 if (o->canUpdateSelectionOnRootLineBoxes()) { | 72 if (o->canUpdateSelectionOnRootLineBoxes()) { |
73 m_rect = o->selectionRectForPaintInvalidation(m_repaintContainer, cl
ipToVisibleContent); | 73 m_rect = o->selectionRectForPaintInvalidation(m_paintInvalidationCon
tainer, clipToVisibleContent); |
74 // FIXME: groupedMapping() leaks the squashing abstraction. See Rend
erBlockSelectionInfo for more details. | 74 // FIXME: groupedMapping() leaks the squashing abstraction. See Rend
erBlockSelectionInfo for more details. |
75 if (m_repaintContainer && m_repaintContainer->layer()->groupedMappin
g()) | 75 if (m_paintInvalidationContainer && m_paintInvalidationContainer->la
yer()->groupedMapping()) |
76 RenderLayer::mapRectToPaintInvalidationBacking(m_repaintContaine
r, m_repaintContainer, m_rect); | 76 RenderLayer::mapRectToPaintInvalidationBacking(m_paintInvalidati
onContainer, m_paintInvalidationContainer, m_rect); |
77 } else { | 77 } else { |
78 m_rect = LayoutRect(); | 78 m_rect = LayoutRect(); |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 void repaint() | 82 void invalidatePaint() |
83 { | 83 { |
84 m_object->invalidatePaintUsingContainer(m_repaintContainer, m_rect, Inva
lidationSelection); | 84 m_object->invalidatePaintUsingContainer(m_paintInvalidationContainer, m_
rect, InvalidationSelection); |
85 } | 85 } |
86 | 86 |
87 LayoutRect rect() const { return m_rect; } | 87 LayoutRect rect() const { return m_rect; } |
88 | 88 |
89 private: | 89 private: |
90 LayoutRect m_rect; // relative to repaint container | 90 LayoutRect m_rect; // relative to paint invalidation container |
91 }; | 91 }; |
92 | 92 |
93 | 93 |
94 // This struct is used when the selection changes to cache the old and new state
of the selection for each RenderBlock. | 94 // This struct is used when the selection changes to cache the old and new state
of the selection for each RenderBlock. |
95 class RenderBlockSelectionInfo FINAL : public RenderSelectionInfoBase { | 95 class RenderBlockSelectionInfo FINAL : public RenderSelectionInfoBase { |
96 public: | 96 public: |
97 RenderBlockSelectionInfo(RenderBlock* b) | 97 RenderBlockSelectionInfo(RenderBlock* b) |
98 : RenderSelectionInfoBase(b) | 98 : RenderSelectionInfoBase(b) |
99 { | 99 { |
100 if (b->canUpdateSelectionOnRootLineBoxes()) | 100 if (b->canUpdateSelectionOnRootLineBoxes()) |
101 m_rects = block()->selectionGapRectsForRepaint(m_repaintContainer); | 101 m_rects = block()->selectionGapRectsForPaintInvalidation(m_paintInva
lidationContainer); |
102 else | 102 else |
103 m_rects = GapRects(); | 103 m_rects = GapRects(); |
104 } | 104 } |
105 | 105 |
106 void repaint() | 106 void invalidatePaint() |
107 { | 107 { |
108 LayoutRect repaintRect = m_rects; | 108 LayoutRect paintInvalidationRect = m_rects; |
109 // FIXME: this is leaking the squashing abstraction. However, removing t
he groupedMapping() condiitional causes | 109 // FIXME: this is leaking the squashing abstraction. However, removing t
he groupedMapping() condiitional causes |
110 // RenderBox::mapRectToPaintInvalidationBacking to get called, which mak
es rect adjustments even if you pass the same | 110 // RenderBox::mapRectToPaintInvalidationBacking to get called, which mak
es rect adjustments even if you pass the same |
111 // repaintContainer as the render object. Find out why it does that and
fix. | 111 // paintInvalidationContainer as the render object. Find out why it does
that and fix. |
112 if (m_repaintContainer && m_repaintContainer->layer()->groupedMapping()) | 112 if (m_paintInvalidationContainer && m_paintInvalidationContainer->layer(
)->groupedMapping()) |
113 RenderLayer::mapRectToPaintInvalidationBacking(m_repaintContainer, m
_repaintContainer, repaintRect); | 113 RenderLayer::mapRectToPaintInvalidationBacking(m_paintInvalidationCo
ntainer, m_paintInvalidationContainer, paintInvalidationRect); |
114 m_object->invalidatePaintUsingContainer(m_repaintContainer, repaintRect,
InvalidationSelection); | 114 m_object->invalidatePaintUsingContainer(m_paintInvalidationContainer, pa
intInvalidationRect, InvalidationSelection); |
115 } | 115 } |
116 | 116 |
117 RenderBlock* block() const { return toRenderBlock(m_object); } | 117 RenderBlock* block() const { return toRenderBlock(m_object); } |
118 GapRects rects() const { return m_rects; } | 118 GapRects rects() const { return m_rects; } |
119 | 119 |
120 private: | 120 private: |
121 GapRects m_rects; // relative to repaint container | 121 GapRects m_rects; // relative to paint invalidation container |
122 }; | 122 }; |
123 | 123 |
124 } // namespace blink | 124 } // namespace blink |
125 | 125 |
126 | 126 |
127 #endif // RenderSelectionInfo_h | 127 #endif // RenderSelectionInfo_h |
OLD | NEW |