OLD | NEW |
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 "config.h" | 5 #include "config.h" |
6 #include "core/paint/FramePainter.h" | 6 #include "core/paint/FramePainter.h" |
7 | 7 |
8 #include "core/dom/DocumentMarkerController.h" | 8 #include "core/dom/DocumentMarkerController.h" |
9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
10 #include "core/inspector/InspectorInstrumentation.h" | 10 #include "core/inspector/InspectorInstrumentation.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 LayoutView* layoutView = m_frameView.layoutView(); | 97 LayoutView* layoutView = m_frameView.layoutView(); |
98 if (!layoutView) { | 98 if (!layoutView) { |
99 WTF_LOG_ERROR("called FramePainter::paint with nil renderer"); | 99 WTF_LOG_ERROR("called FramePainter::paint with nil renderer"); |
100 return; | 100 return; |
101 } | 101 } |
102 | 102 |
103 RELEASE_ASSERT(!m_frameView.needsLayout()); | 103 RELEASE_ASSERT(!m_frameView.needsLayout()); |
104 ASSERT(document->lifecycle().state() >= DocumentLifecycle::CompositingClean)
; | 104 ASSERT(document->lifecycle().state() >= DocumentLifecycle::CompositingClean)
; |
105 | 105 |
106 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Paint", "data"
, InspectorPaintEvent::data(layoutView, rect, 0)); | 106 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Paint", "data"
, InspectorPaintEvent::data(layoutView, LayoutRect(rect), 0)); |
107 | 107 |
108 bool isTopLevelPainter = !s_inPaintContents; | 108 bool isTopLevelPainter = !s_inPaintContents; |
109 s_inPaintContents = true; | 109 s_inPaintContents = true; |
110 | 110 |
111 FontCachePurgePreventer fontCachePurgePreventer; | 111 FontCachePurgePreventer fontCachePurgePreventer; |
112 | 112 |
113 PaintBehavior oldPaintBehavior = m_frameView.paintBehavior(); | 113 PaintBehavior oldPaintBehavior = m_frameView.paintBehavior(); |
114 | 114 |
115 if (FrameView* parentView = m_frameView.parentFrameView()) { | 115 if (FrameView* parentView = m_frameView.parentFrameView()) { |
116 if (parentView->paintBehavior() & PaintBehaviorFlattenCompositingLayers) | 116 if (parentView->paintBehavior() & PaintBehaviorFlattenCompositingLayers) |
117 m_frameView.setPaintBehavior(m_frameView.paintBehavior() | PaintBeha
viorFlattenCompositingLayers); | 117 m_frameView.setPaintBehavior(m_frameView.paintBehavior() | PaintBeha
viorFlattenCompositingLayers); |
118 } | 118 } |
119 | 119 |
120 if (m_frameView.paintBehavior() == PaintBehaviorNormal) | 120 if (m_frameView.paintBehavior() == PaintBehaviorNormal) |
121 document->markers().invalidateRenderedRectsForMarkersInRect(rect); | 121 document->markers().invalidateRenderedRectsForMarkersInRect(LayoutRect(r
ect)); |
122 | 122 |
123 if (document->printing()) | 123 if (document->printing()) |
124 m_frameView.setPaintBehavior(m_frameView.paintBehavior() | PaintBehavior
FlattenCompositingLayers); | 124 m_frameView.setPaintBehavior(m_frameView.paintBehavior() | PaintBehavior
FlattenCompositingLayers); |
125 | 125 |
126 ASSERT(!m_frameView.isPainting()); | 126 ASSERT(!m_frameView.isPainting()); |
127 m_frameView.setIsPainting(true); | 127 m_frameView.setIsPainting(true); |
128 | 128 |
129 // m_frameView.nodeToDraw() is used to draw only one element (and its descen
dants) | 129 // m_frameView.nodeToDraw() is used to draw only one element (and its descen
dants) |
130 LayoutObject* renderer = m_frameView.nodeToDraw() ? m_frameView.nodeToDraw()
->renderer() : 0; | 130 LayoutObject* renderer = m_frameView.nodeToDraw() ? m_frameView.nodeToDraw()
->renderer() : 0; |
131 Layer* rootLayer = layoutView->layer(); | 131 Layer* rootLayer = layoutView->layer(); |
132 | 132 |
133 #if ENABLE(ASSERT) | 133 #if ENABLE(ASSERT) |
134 layoutView->assertSubtreeIsLaidOut(); | 134 layoutView->assertSubtreeIsLaidOut(); |
135 LayoutObject::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(*rootLayer-
>renderer()); | 135 LayoutObject::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(*rootLayer-
>renderer()); |
136 #endif | 136 #endif |
137 | 137 |
138 LayerPainter layerPainter(*rootLayer); | 138 LayerPainter layerPainter(*rootLayer); |
139 | 139 |
140 float deviceScaleFactor = blink::deviceScaleFactor(rootLayer->renderer()->fr
ame()); | 140 float deviceScaleFactor = blink::deviceScaleFactor(rootLayer->renderer()->fr
ame()); |
141 context->setDeviceScaleFactor(deviceScaleFactor); | 141 context->setDeviceScaleFactor(deviceScaleFactor); |
142 | 142 |
143 layerPainter.paint(context, rect, m_frameView.paintBehavior(), renderer); | 143 layerPainter.paint(context, LayoutRect(rect), m_frameView.paintBehavior(), r
enderer); |
144 | 144 |
145 if (rootLayer->containsDirtyOverlayScrollbars()) | 145 if (rootLayer->containsDirtyOverlayScrollbars()) |
146 layerPainter.paintOverlayScrollbars(context, rect, m_frameView.paintBeha
vior(), renderer); | 146 layerPainter.paintOverlayScrollbars(context, LayoutRect(rect), m_frameVi
ew.paintBehavior(), renderer); |
147 | 147 |
148 m_frameView.setIsPainting(false); | 148 m_frameView.setIsPainting(false); |
149 | 149 |
150 m_frameView.setPaintBehavior(oldPaintBehavior); | 150 m_frameView.setPaintBehavior(oldPaintBehavior); |
151 m_frameView.setLastPaintTime(currentTime()); | 151 m_frameView.setLastPaintTime(currentTime()); |
152 | 152 |
153 // Regions may have changed as a result of the visibility/z-index of element
changing. | 153 // Regions may have changed as a result of the visibility/z-index of element
changing. |
154 if (document->annotatedRegionsDirty()) | 154 if (document->annotatedRegionsDirty()) |
155 m_frameView.updateAnnotatedRegions(); | 155 m_frameView.updateAnnotatedRegions(); |
156 | 156 |
157 if (isTopLevelPainter) { | 157 if (isTopLevelPainter) { |
158 // Everything that happens after paintContents completions is considered | 158 // Everything that happens after paintContents completions is considered |
159 // to be part of the next frame. | 159 // to be part of the next frame. |
160 m_frameView.setCurrentFrameTimeStamp(currentTime()); | 160 m_frameView.setCurrentFrameTimeStamp(currentTime()); |
161 s_inPaintContents = false; | 161 s_inPaintContents = false; |
162 } | 162 } |
163 | 163 |
164 InspectorInstrumentation::didPaint(layoutView, 0, context, rect); | 164 InspectorInstrumentation::didPaint(layoutView, 0, context, LayoutRect(rect))
; |
165 } | 165 } |
166 | 166 |
167 void FramePainter::paintScrollbars(GraphicsContext* context, const IntRect& rect
) | 167 void FramePainter::paintScrollbars(GraphicsContext* context, const IntRect& rect
) |
168 { | 168 { |
169 if (m_frameView.horizontalScrollbar() && !m_frameView.layerForHorizontalScro
llbar()) | 169 if (m_frameView.horizontalScrollbar() && !m_frameView.layerForHorizontalScro
llbar()) |
170 paintScrollbar(context, m_frameView.horizontalScrollbar(), rect); | 170 paintScrollbar(context, m_frameView.horizontalScrollbar(), rect); |
171 if (m_frameView.verticalScrollbar() && !m_frameView.layerForVerticalScrollba
r()) | 171 if (m_frameView.verticalScrollbar() && !m_frameView.layerForVerticalScrollba
r()) |
172 paintScrollbar(context, m_frameView.verticalScrollbar(), rect); | 172 paintScrollbar(context, m_frameView.verticalScrollbar(), rect); |
173 | 173 |
174 if (m_frameView.layerForScrollCorner()) | 174 if (m_frameView.layerForScrollCorner()) |
175 return; | 175 return; |
176 | 176 |
177 // FIXME: This is wrong. scroll corners are currently painted in the local s
pace of the scroll corner, | 177 // FIXME: This is wrong. scroll corners are currently painted in the local s
pace of the scroll corner, |
178 // not the space of the frame. Either change scroll corners to paint in the
frame's coordinate space, | 178 // not the space of the frame. Either change scroll corners to paint in the
frame's coordinate space, |
179 // or adjust for the location of the scroll corner. | 179 // or adjust for the location of the scroll corner. |
180 paintScrollCorner(context, m_frameView.scrollCornerRect()); | 180 paintScrollCorner(context, m_frameView.scrollCornerRect()); |
181 } | 181 } |
182 | 182 |
183 void FramePainter::paintScrollCorner(GraphicsContext* context, const IntRect& co
rnerRect) | 183 void FramePainter::paintScrollCorner(GraphicsContext* context, const IntRect& co
rnerRect) |
184 { | 184 { |
185 if (m_frameView.scrollCorner()) { | 185 if (m_frameView.scrollCorner()) { |
186 bool needsBackground = m_frameView.frame().isMainFrame(); | 186 bool needsBackground = m_frameView.frame().isMainFrame(); |
187 if (needsBackground) | 187 if (needsBackground) |
188 context->fillRect(cornerRect, m_frameView.baseBackgroundColor()); | 188 context->fillRect(cornerRect, m_frameView.baseBackgroundColor()); |
189 ScrollbarPainter::paintIntoRect(m_frameView.scrollCorner(), context, cor
nerRect.location(), cornerRect); | 189 ScrollbarPainter::paintIntoRect(m_frameView.scrollCorner(), context, cor
nerRect.location(), LayoutRect(cornerRect)); |
190 return; | 190 return; |
191 } | 191 } |
192 | 192 |
193 ScrollbarTheme::theme()->paintScrollCorner(context, m_frameView.displayItemC
lient(), cornerRect); | 193 ScrollbarTheme::theme()->paintScrollCorner(context, m_frameView.displayItemC
lient(), cornerRect); |
194 } | 194 } |
195 | 195 |
196 void FramePainter::paintScrollbar(GraphicsContext* context, Scrollbar* bar, cons
t IntRect& rect) | 196 void FramePainter::paintScrollbar(GraphicsContext* context, Scrollbar* bar, cons
t IntRect& rect) |
197 { | 197 { |
198 bool needsBackground = bar->isCustomScrollbar() && m_frameView.frame().isMai
nFrame(); | 198 bool needsBackground = bar->isCustomScrollbar() && m_frameView.frame().isMai
nFrame(); |
199 if (needsBackground) { | 199 if (needsBackground) { |
(...skipping 28 matching lines...) Expand all Loading... |
228 { | 228 { |
229 IntRect horizontalOverhangRect; | 229 IntRect horizontalOverhangRect; |
230 IntRect verticalOverhangRect; | 230 IntRect verticalOverhangRect; |
231 m_frameView.calculateOverhangAreasForPainting(horizontalOverhangRect, vertic
alOverhangRect); | 231 m_frameView.calculateOverhangAreasForPainting(horizontalOverhangRect, vertic
alOverhangRect); |
232 | 232 |
233 if (dirtyRect.intersects(horizontalOverhangRect) || dirtyRect.intersects(ver
ticalOverhangRect)) | 233 if (dirtyRect.intersects(horizontalOverhangRect) || dirtyRect.intersects(ver
ticalOverhangRect)) |
234 paintOverhangAreas(context, horizontalOverhangRect, verticalOverhangRect
, dirtyRect); | 234 paintOverhangAreas(context, horizontalOverhangRect, verticalOverhangRect
, dirtyRect); |
235 } | 235 } |
236 | 236 |
237 } // namespace blink | 237 } // namespace blink |
OLD | NEW |