Chromium Code Reviews| 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 "core/paint/FramePainter.h" | 5 #include "core/paint/FramePainter.h" |
| 6 | 6 |
| 7 #include "core/editing/markers/DocumentMarkerController.h" | 7 #include "core/editing/markers/DocumentMarkerController.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/inspector/InspectorInstrumentation.h" | 9 #include "core/inspector/InspectorInstrumentation.h" |
| 10 #include "core/inspector/InspectorTraceEvents.h" | 10 #include "core/inspector/InspectorTraceEvents.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 // to be part of the next frame. | 189 // to be part of the next frame. |
| 190 memoryCache()->updateFramePaintTimestamp(); | 190 memoryCache()->updateFramePaintTimestamp(); |
| 191 s_inPaintContents = false; | 191 s_inPaintContents = false; |
| 192 } | 192 } |
| 193 | 193 |
| 194 probe::didPaint(layoutView->frame(), 0, context, LayoutRect(rect)); | 194 probe::didPaint(layoutView->frame(), 0, context, LayoutRect(rect)); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void FramePainter::paintScrollbars(GraphicsContext& context, | 197 void FramePainter::paintScrollbars(GraphicsContext& context, |
| 198 const IntRect& rect) { | 198 const IntRect& rect) { |
| 199 ScrollbarTheme* scrollbarTheme = nullptr; | |
| 199 if (frameView().horizontalScrollbar() && | 200 if (frameView().horizontalScrollbar() && |
| 200 !frameView().layerForHorizontalScrollbar()) | 201 !frameView().layerForHorizontalScrollbar()) { |
| 201 paintScrollbar(context, *frameView().horizontalScrollbar(), rect); | 202 paintScrollbar(context, *frameView().horizontalScrollbar(), rect); |
| 203 scrollbarTheme = &frameView().horizontalScrollbar()->theme(); | |
| 204 } | |
| 202 if (frameView().verticalScrollbar() && | 205 if (frameView().verticalScrollbar() && |
| 203 !frameView().layerForVerticalScrollbar()) | 206 !frameView().layerForVerticalScrollbar()) { |
| 204 paintScrollbar(context, *frameView().verticalScrollbar(), rect); | 207 paintScrollbar(context, *frameView().verticalScrollbar(), rect); |
| 208 scrollbarTheme = &frameView().horizontalScrollbar()->theme(); | |
| 209 } | |
| 205 | 210 |
| 206 if (frameView().layerForScrollCorner()) | 211 if (frameView().layerForScrollCorner()) |
| 207 return; | 212 return; |
| 208 | 213 |
| 209 paintScrollCorner(context, frameView().scrollCornerRect()); | 214 DCHECK(scrollbarTheme); |
| 215 scrollbarTheme = scrollbarTheme ? scrollbarTheme : &ScrollbarTheme::theme(); | |
| 216 paintScrollCorner(context, *scrollbarTheme, frameView().scrollCornerRect()); | |
| 210 } | 217 } |
| 211 | 218 |
| 212 void FramePainter::paintScrollCorner(GraphicsContext& context, | 219 void FramePainter::paintScrollCorner(GraphicsContext& context, |
| 220 ScrollbarTheme& theme, | |
|
bokan
2017/03/13 13:52:09
Rather than passing the theme in, just computed it
| |
| 213 const IntRect& cornerRect) { | 221 const IntRect& cornerRect) { |
| 214 if (frameView().scrollCorner()) { | 222 if (frameView().scrollCorner()) { |
| 215 bool needsBackground = frameView().frame().isMainFrame(); | 223 bool needsBackground = frameView().frame().isMainFrame(); |
| 216 if (needsBackground && | 224 if (needsBackground && |
| 217 !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( | 225 !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( |
| 218 context, *frameView().layoutView(), | 226 context, *frameView().layoutView(), |
| 219 DisplayItem::kScrollbarCorner)) { | 227 DisplayItem::kScrollbarCorner)) { |
| 220 LayoutObjectDrawingRecorder drawingRecorder( | 228 LayoutObjectDrawingRecorder drawingRecorder( |
| 221 context, *frameView().layoutView(), DisplayItem::kScrollbarCorner, | 229 context, *frameView().layoutView(), DisplayItem::kScrollbarCorner, |
| 222 FloatRect(cornerRect)); | 230 FloatRect(cornerRect)); |
| 223 context.fillRect(cornerRect, frameView().baseBackgroundColor()); | 231 context.fillRect(cornerRect, frameView().baseBackgroundColor()); |
| 224 } | 232 } |
| 225 ScrollbarPainter::paintIntoRect(*frameView().scrollCorner(), context, | 233 ScrollbarPainter::paintIntoRect(*frameView().scrollCorner(), context, |
| 226 cornerRect.location(), | 234 cornerRect.location(), |
| 227 LayoutRect(cornerRect)); | 235 LayoutRect(cornerRect)); |
| 228 return; | 236 return; |
| 229 } | 237 } |
| 230 | 238 |
| 231 ScrollbarTheme::theme().paintScrollCorner(context, *frameView().layoutView(), | 239 theme.paintScrollCorner(context, *frameView().layoutView(), cornerRect); |
| 232 cornerRect); | |
| 233 } | 240 } |
| 234 | 241 |
| 235 void FramePainter::paintScrollbar(GraphicsContext& context, | 242 void FramePainter::paintScrollbar(GraphicsContext& context, |
| 236 Scrollbar& bar, | 243 Scrollbar& bar, |
| 237 const IntRect& rect) { | 244 const IntRect& rect) { |
| 238 bool needsBackground = | 245 bool needsBackground = |
| 239 bar.isCustomScrollbar() && frameView().frame().isMainFrame(); | 246 bar.isCustomScrollbar() && frameView().frame().isMainFrame(); |
| 240 if (needsBackground) { | 247 if (needsBackground) { |
| 241 IntRect toFill = bar.frameRect(); | 248 IntRect toFill = bar.frameRect(); |
| 242 toFill.intersect(rect); | 249 toFill.intersect(rect); |
| 243 context.fillRect(toFill, frameView().baseBackgroundColor()); | 250 context.fillRect(toFill, frameView().baseBackgroundColor()); |
| 244 } | 251 } |
| 245 | 252 |
| 246 bar.paint(context, CullRect(rect)); | 253 bar.paint(context, CullRect(rect)); |
| 247 } | 254 } |
| 248 | 255 |
| 249 const FrameView& FramePainter::frameView() { | 256 const FrameView& FramePainter::frameView() { |
| 250 DCHECK(m_frameView); | 257 DCHECK(m_frameView); |
| 251 return *m_frameView; | 258 return *m_frameView; |
| 252 } | 259 } |
| 253 | 260 |
| 254 } // namespace blink | 261 } // namespace blink |
| OLD | NEW |