OLD | NEW |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 class DeprecatedPaintLayerCompositor; | 42 class DeprecatedPaintLayerCompositor; |
43 class LayoutQuote; | 43 class LayoutQuote; |
44 | 44 |
45 // The root of the layout tree, corresponding to the CSS initial containing bloc
k. | 45 // The root of the layout tree, corresponding to the CSS initial containing bloc
k. |
46 // It's dimensions match that of the logical viewport (which may be different fr
om | 46 // It's dimensions match that of the logical viewport (which may be different fr
om |
47 // the visible viewport in fixed-layout mode), and it is always at position (0,0
) | 47 // the visible viewport in fixed-layout mode), and it is always at position (0,0
) |
48 // relative to the document (and so isn't necessarily in view). | 48 // relative to the document (and so isn't necessarily in view). |
49 class CORE_EXPORT LayoutView final : public LayoutBlockFlow { | 49 class CORE_EXPORT LayoutView final : public LayoutBlockFlow { |
50 public: | 50 public: |
51 explicit LayoutView(Document*); | 51 explicit LayoutView(Document*); |
52 virtual ~LayoutView(); | 52 ~LayoutView() override; |
53 void willBeDestroyed() override; | 53 void willBeDestroyed() override; |
54 | 54 |
55 // hitTest() will update layout, style and compositing first while hitTestNo
LifecycleUpdate() does not. | 55 // hitTest() will update layout, style and compositing first while hitTestNo
LifecycleUpdate() does not. |
56 bool hitTest(HitTestResult&); | 56 bool hitTest(HitTestResult&); |
57 bool hitTestNoLifecycleUpdate(HitTestResult&); | 57 bool hitTestNoLifecycleUpdate(HitTestResult&); |
58 | 58 |
59 // Returns the total count of calls to HitTest, for testing. | 59 // Returns the total count of calls to HitTest, for testing. |
60 unsigned hitTestCount() const { return m_hitTestCount; } | 60 unsigned hitTestCount() const { return m_hitTestCount; } |
61 unsigned hitTestCacheHits() const { return m_hitTestCacheHits; } | 61 unsigned hitTestCacheHits() const { return m_hitTestCacheHits; } |
62 | 62 |
63 void clearHitTestCache() { m_hitTestCache->clear(); } | 63 void clearHitTestCache() { m_hitTestCache->clear(); } |
64 | 64 |
65 virtual const char* name() const override { return "LayoutView"; } | 65 const char* name() const override { return "LayoutView"; } |
66 | 66 |
67 virtual bool isOfType(LayoutObjectType type) const override { return type ==
LayoutObjectLayoutView || LayoutBlockFlow::isOfType(type); } | 67 bool isOfType(LayoutObjectType type) const override { return type == LayoutO
bjectLayoutView || LayoutBlockFlow::isOfType(type); } |
68 | 68 |
69 virtual DeprecatedPaintLayerType layerTypeRequired() const override { return
NormalDeprecatedPaintLayer; } | 69 DeprecatedPaintLayerType layerTypeRequired() const override { return NormalD
eprecatedPaintLayer; } |
70 | 70 |
71 virtual bool isChildAllowed(LayoutObject*, const ComputedStyle&) const overr
ide; | 71 bool isChildAllowed(LayoutObject*, const ComputedStyle&) const override; |
72 | 72 |
73 virtual void layout() override; | 73 void layout() override; |
74 virtual void updateLogicalWidth() override; | 74 void updateLogicalWidth() override; |
75 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const override; | 75 void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, L
ogicalExtentComputedValues&) const override; |
76 | 76 |
77 // Based on FrameView::layoutSize, but: | 77 // Based on FrameView::layoutSize, but: |
78 // - checks for null FrameView | 78 // - checks for null FrameView |
79 // - returns 0x0 if using printing layout | 79 // - returns 0x0 if using printing layout |
80 // - scrollbar exclusion is compatible with root layer scrolling | 80 // - scrollbar exclusion is compatible with root layer scrolling |
81 IntSize layoutSize(IncludeScrollbarsInRect = ExcludeScrollbars) const; | 81 IntSize layoutSize(IncludeScrollbarsInRect = ExcludeScrollbars) const; |
82 | 82 |
83 int viewHeight(IncludeScrollbarsInRect scrollbarInclusion = ExcludeScrollbar
s) const { return layoutSize(scrollbarInclusion).height(); } | 83 int viewHeight(IncludeScrollbarsInRect scrollbarInclusion = ExcludeScrollbar
s) const { return layoutSize(scrollbarInclusion).height(); } |
84 int viewWidth(IncludeScrollbarsInRect scrollbarInclusion = ExcludeScrollbars
) const { return layoutSize(scrollbarInclusion).width(); } | 84 int viewWidth(IncludeScrollbarsInRect scrollbarInclusion = ExcludeScrollbars
) const { return layoutSize(scrollbarInclusion).width(); } |
85 | 85 |
86 int viewLogicalWidth(IncludeScrollbarsInRect = ExcludeScrollbars) const; | 86 int viewLogicalWidth(IncludeScrollbarsInRect = ExcludeScrollbars) const; |
87 int viewLogicalHeight(IncludeScrollbarsInRect = ExcludeScrollbars) const; | 87 int viewLogicalHeight(IncludeScrollbarsInRect = ExcludeScrollbars) const; |
88 | 88 |
89 LayoutUnit viewLogicalHeightForPercentages() const; | 89 LayoutUnit viewLogicalHeightForPercentages() const; |
90 | 90 |
91 float zoomFactor() const; | 91 float zoomFactor() const; |
92 | 92 |
93 FrameView* frameView() const { return m_frameView; } | 93 FrameView* frameView() const { return m_frameView; } |
94 | 94 |
95 enum ViewportConstrainedPosition { | 95 enum ViewportConstrainedPosition { |
96 IsNotFixedPosition, | 96 IsNotFixedPosition, |
97 IsFixedPosition, | 97 IsFixedPosition, |
98 }; | 98 }; |
99 | 99 |
100 static ViewportConstrainedPosition viewportConstrainedPosition(EPosition pos
ition) { return position == FixedPosition ? IsFixedPosition : IsNotFixedPosition
; } | 100 static ViewportConstrainedPosition viewportConstrainedPosition(EPosition pos
ition) { return position == FixedPosition ? IsFixedPosition : IsNotFixedPosition
; } |
101 void mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* paintInva
lidationContainer, LayoutRect&, ViewportConstrainedPosition, const PaintInvalida
tionState*) const; | 101 void mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* paintInva
lidationContainer, LayoutRect&, ViewportConstrainedPosition, const PaintInvalida
tionState*) const; |
102 virtual void mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* p
aintInvalidationContainer, LayoutRect&, const PaintInvalidationState*) const ove
rride; | 102 void mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* paintInva
lidationContainer, LayoutRect&, const PaintInvalidationState*) const override; |
103 void adjustViewportConstrainedOffset(LayoutRect&, ViewportConstrainedPositio
n) const; | 103 void adjustViewportConstrainedOffset(LayoutRect&, ViewportConstrainedPositio
n) const; |
104 | 104 |
105 void invalidatePaintForRectangle(const LayoutRect&, PaintInvalidationReason)
const; | 105 void invalidatePaintForRectangle(const LayoutRect&, PaintInvalidationReason)
const; |
106 | 106 |
107 void invalidatePaintForViewAndCompositedLayers(); | 107 void invalidatePaintForViewAndCompositedLayers(); |
108 | 108 |
109 virtual void paint(const PaintInfo&, const LayoutPoint&) override; | 109 void paint(const PaintInfo&, const LayoutPoint&) override; |
110 virtual void paintBoxDecorationBackground(const PaintInfo&, const LayoutPoin
t&) override; | 110 void paintBoxDecorationBackground(const PaintInfo&, const LayoutPoint&) over
ride; |
111 | 111 |
112 enum SelectionPaintInvalidationMode { PaintInvalidationNewXOROld, PaintInval
idationNewMinusOld }; | 112 enum SelectionPaintInvalidationMode { PaintInvalidationNewXOROld, PaintInval
idationNewMinusOld }; |
113 void setSelection(LayoutObject* start, int startPos, LayoutObject*, int endP
os, SelectionPaintInvalidationMode = PaintInvalidationNewXOROld); | 113 void setSelection(LayoutObject* start, int startPos, LayoutObject*, int endP
os, SelectionPaintInvalidationMode = PaintInvalidationNewXOROld); |
114 void clearSelection(); | 114 void clearSelection(); |
115 void setSelection(const FrameSelection&); | 115 void setSelection(const FrameSelection&); |
116 bool hasPendingSelection() const { return m_pendingSelection->hasPendingSele
ction(); } | 116 bool hasPendingSelection() const { return m_pendingSelection->hasPendingSele
ction(); } |
117 void commitPendingSelection(); | 117 void commitPendingSelection(); |
118 LayoutObject* selectionStart(); | 118 LayoutObject* selectionStart(); |
119 LayoutObject* selectionEnd(); | 119 LayoutObject* selectionEnd(); |
120 IntRect selectionBounds(); | 120 IntRect selectionBounds(); |
121 void selectionStartEnd(int& startPos, int& endPos); | 121 void selectionStartEnd(int& startPos, int& endPos); |
122 void invalidatePaintForSelection(); | 122 void invalidatePaintForSelection(); |
123 | 123 |
124 virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedO
ffset) const override; | 124 void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) c
onst override; |
125 virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const overrid
e; | 125 void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const override; |
126 | 126 |
127 virtual LayoutRect viewRect() const override; | 127 LayoutRect viewRect() const override; |
128 | 128 |
129 bool shouldDoFullPaintInvalidationForNextLayout() const; | 129 bool shouldDoFullPaintInvalidationForNextLayout() const; |
130 bool doingFullPaintInvalidation() const { return m_frameView->needsFullPaint
Invalidation(); } | 130 bool doingFullPaintInvalidation() const { return m_frameView->needsFullPaint
Invalidation(); } |
131 | 131 |
132 LayoutState* layoutState() const { return m_layoutState; } | 132 LayoutState* layoutState() const { return m_layoutState; } |
133 | 133 |
134 virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&) overrid
e; | 134 void updateHitTestResult(HitTestResult&, const LayoutPoint&) override; |
135 | 135 |
136 LayoutUnit pageLogicalHeight() const { return m_pageLogicalHeight; } | 136 LayoutUnit pageLogicalHeight() const { return m_pageLogicalHeight; } |
137 void setPageLogicalHeight(LayoutUnit height) | 137 void setPageLogicalHeight(LayoutUnit height) |
138 { | 138 { |
139 if (m_pageLogicalHeight != height) { | 139 if (m_pageLogicalHeight != height) { |
140 m_pageLogicalHeight = height; | 140 m_pageLogicalHeight = height; |
141 m_pageLogicalHeightChanged = true; | 141 m_pageLogicalHeightChanged = true; |
142 } | 142 } |
143 } | 143 } |
144 bool pageLogicalHeightChanged() const { return m_pageLogicalHeightChanged; } | 144 bool pageLogicalHeightChanged() const { return m_pageLogicalHeightChanged; } |
(...skipping 20 matching lines...) Expand all Loading... |
165 LayoutQuote* layoutQuoteHead() const { return m_layoutQuoteHead; } | 165 LayoutQuote* layoutQuoteHead() const { return m_layoutQuoteHead; } |
166 | 166 |
167 // FIXME: This is a work around because the current implementation of counte
rs | 167 // FIXME: This is a work around because the current implementation of counte
rs |
168 // requires walking the entire tree repeatedly and most pages don't actually
use either | 168 // requires walking the entire tree repeatedly and most pages don't actually
use either |
169 // feature so we shouldn't take the performance hit when not needed. Long te
rm we should | 169 // feature so we shouldn't take the performance hit when not needed. Long te
rm we should |
170 // rewrite the counter and quotes code. | 170 // rewrite the counter and quotes code. |
171 void addLayoutCounter() { m_layoutCounterCount++; } | 171 void addLayoutCounter() { m_layoutCounterCount++; } |
172 void removeLayoutCounter() { ASSERT(m_layoutCounterCount > 0); m_layoutCount
erCount--; } | 172 void removeLayoutCounter() { ASSERT(m_layoutCounterCount > 0); m_layoutCount
erCount--; } |
173 bool hasLayoutCounters() { return m_layoutCounterCount; } | 173 bool hasLayoutCounters() { return m_layoutCounterCount; } |
174 | 174 |
175 virtual bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect)
const override; | 175 bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const ov
erride; |
176 | 176 |
177 double layoutViewportWidth() const; | 177 double layoutViewportWidth() const; |
178 double layoutViewportHeight() const; | 178 double layoutViewportHeight() const; |
179 | 179 |
180 void pushLayoutState(LayoutState& layoutState) { m_layoutState = &layoutStat
e; } | 180 void pushLayoutState(LayoutState& layoutState) { m_layoutState = &layoutStat
e; } |
181 void popLayoutState() { ASSERT(m_layoutState); m_layoutState = m_layoutState
->next(); } | 181 void popLayoutState() { ASSERT(m_layoutState); m_layoutState = m_layoutState
->next(); } |
182 virtual void invalidateTreeIfNeeded(PaintInvalidationState&) override final; | 182 void invalidateTreeIfNeeded(PaintInvalidationState&) final; |
183 | 183 |
184 virtual LayoutRect visualOverflowRect() const override; | 184 LayoutRect visualOverflowRect() const override; |
185 | 185 |
186 // Invalidates paint for the entire view, including composited descendants,
but not including child frames. | 186 // Invalidates paint for the entire view, including composited descendants,
but not including child frames. |
187 // It is very likely you do not want to call this method. | 187 // It is very likely you do not want to call this method. |
188 void setShouldDoFullPaintInvalidationForViewAndAllDescendants(); | 188 void setShouldDoFullPaintInvalidationForViewAndAllDescendants(); |
189 | 189 |
190 private: | 190 private: |
191 virtual void mapLocalToContainer(const LayoutBoxModelObject* paintInvalidati
onContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wa
sFixed = nullptr, const PaintInvalidationState* = nullptr) const override; | 191 void mapLocalToContainer(const LayoutBoxModelObject* paintInvalidationContai
ner, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed =
nullptr, const PaintInvalidationState* = nullptr) const override; |
192 | 192 |
193 template <typename Strategy> | 193 template <typename Strategy> |
194 void commitPendingSelectionAlgorithm(); | 194 void commitPendingSelectionAlgorithm(); |
195 | 195 |
196 virtual const LayoutObject* pushMappingToContainer(const LayoutBoxModelObjec
t* ancestorToStopAt, LayoutGeometryMap&) const override; | 196 const LayoutObject* pushMappingToContainer(const LayoutBoxModelObject* ances
torToStopAt, LayoutGeometryMap&) const override; |
197 virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) c
onst override; | 197 void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) const ove
rride; |
198 virtual void computeSelfHitTestRects(Vector<LayoutRect>&, const LayoutPoint&
layerOffset) const override; | 198 void computeSelfHitTestRects(Vector<LayoutRect>&, const LayoutPoint& layerOf
fset) const override; |
199 | 199 |
200 void layoutContent(); | 200 void layoutContent(); |
201 #if ENABLE(ASSERT) | 201 #if ENABLE(ASSERT) |
202 void checkLayoutState(); | 202 void checkLayoutState(); |
203 #endif | 203 #endif |
204 | 204 |
205 friend class ForceHorriblySlowRectMapping; | 205 friend class ForceHorriblySlowRectMapping; |
206 | 206 |
207 bool shouldUsePrintingLayout() const; | 207 bool shouldUsePrintingLayout() const; |
208 | 208 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 m_paintInvalidationState->m_cachedOffsetsEnabled = true; | 257 m_paintInvalidationState->m_cachedOffsetsEnabled = true; |
258 } | 258 } |
259 private: | 259 private: |
260 const PaintInvalidationState* m_paintInvalidationState; | 260 const PaintInvalidationState* m_paintInvalidationState; |
261 bool m_didDisable; | 261 bool m_didDisable; |
262 }; | 262 }; |
263 | 263 |
264 } // namespace blink | 264 } // namespace blink |
265 | 265 |
266 #endif // LayoutView_h | 266 #endif // LayoutView_h |
OLD | NEW |