| 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/fetch/MemoryCache.h" | 9 #include "core/fetch/MemoryCache.h" |
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 Document* document = m_frameView.frame().document(); | 66 Document* document = m_frameView.frame().document(); |
| 67 | 67 |
| 68 #ifndef NDEBUG | 68 #ifndef NDEBUG |
| 69 bool fillWithRed; | 69 bool fillWithRed; |
| 70 if (document->printing()) | 70 if (document->printing()) |
| 71 fillWithRed = false; // Printing, don't fill with red (can't remember wh
y). | 71 fillWithRed = false; // Printing, don't fill with red (can't remember wh
y). |
| 72 else if (m_frameView.frame().owner()) | 72 else if (m_frameView.frame().owner()) |
| 73 fillWithRed = false; // Subframe, don't fill with red. | 73 fillWithRed = false; // Subframe, don't fill with red. |
| 74 else if (m_frameView.isTransparent()) | 74 else if (m_frameView.isTransparent()) |
| 75 fillWithRed = false; // Transparent, don't fill with red. | 75 fillWithRed = false; // Transparent, don't fill with red. |
| 76 else if (m_frameView.paintBehavior() & PaintBehaviorSelectionOnly) | 76 else if (gGlobalPaintFlags & GlobalPaintSelectionOnly) |
| 77 fillWithRed = false; // Selections are transparent, don't fill with red. | 77 fillWithRed = false; // Selections are transparent, don't fill with red. |
| 78 else if (m_frameView.nodeToDraw()) | 78 else if (m_frameView.nodeToDraw()) |
| 79 fillWithRed = false; // Element images are transparent, don't fill with
red. | 79 fillWithRed = false; // Element images are transparent, don't fill with
red. |
| 80 else | 80 else |
| 81 fillWithRed = true; | 81 fillWithRed = true; |
| 82 | 82 |
| 83 if (fillWithRed && !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(
*context, *m_frameView.layoutView(), DisplayItem::DebugRedFill)) { | 83 if (fillWithRed && !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(
*context, *m_frameView.layoutView(), DisplayItem::DebugRedFill)) { |
| 84 IntRect contentRect(IntPoint(), m_frameView.contentsSize()); | 84 IntRect contentRect(IntPoint(), m_frameView.contentsSize()); |
| 85 LayoutObjectDrawingRecorder drawingRecorder(*context, *m_frameView.layou
tView(), DisplayItem::DebugRedFill, contentRect); | 85 LayoutObjectDrawingRecorder drawingRecorder(*context, *m_frameView.layou
tView(), DisplayItem::DebugRedFill, contentRect); |
| 86 } | 86 } |
| 87 #endif | 87 #endif |
| 88 | 88 |
| 89 LayoutView* layoutView = m_frameView.layoutView(); | 89 LayoutView* layoutView = m_frameView.layoutView(); |
| 90 if (!layoutView) { | 90 if (!layoutView) { |
| 91 WTF_LOG_ERROR("called FramePainter::paint with nil layoutObject"); | 91 WTF_LOG_ERROR("called FramePainter::paint with nil layoutObject"); |
| 92 return; | 92 return; |
| 93 } | 93 } |
| 94 | 94 |
| 95 RELEASE_ASSERT(!m_frameView.needsLayout()); | 95 RELEASE_ASSERT(!m_frameView.needsLayout()); |
| 96 ASSERT(document->lifecycle().state() >= DocumentLifecycle::CompositingClean)
; | 96 ASSERT(document->lifecycle().state() >= DocumentLifecycle::CompositingClean)
; |
| 97 | 97 |
| 98 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data
(layoutView, LayoutRect(rect), 0)); | 98 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data
(layoutView, LayoutRect(rect), 0)); |
| 99 | 99 |
| 100 bool isTopLevelPainter = !s_inPaintContents; | 100 bool isTopLevelPainter = !s_inPaintContents; |
| 101 s_inPaintContents = true; | 101 s_inPaintContents = true; |
| 102 | 102 |
| 103 FontCachePurgePreventer fontCachePurgePreventer; | 103 FontCachePurgePreventer fontCachePurgePreventer; |
| 104 | 104 |
| 105 PaintBehavior oldPaintBehavior = m_frameView.paintBehavior(); | 105 // TODO(jchaffraix): Why is this here and done globally once per paint phase
? |
| 106 | |
| 107 if (FrameView* parentView = m_frameView.parentFrameView()) { | |
| 108 if (parentView->paintBehavior() & PaintBehaviorFlattenCompositingLayers) | |
| 109 m_frameView.setPaintBehavior(m_frameView.paintBehavior() | PaintBeha
viorFlattenCompositingLayers); | |
| 110 } | |
| 111 | |
| 112 if (document->printing()) | 106 if (document->printing()) |
| 113 m_frameView.setPaintBehavior(m_frameView.paintBehavior() | PaintBehavior
FlattenCompositingLayers); | 107 gGlobalPaintFlags |= GlobalPaintFlattenCompositingLayers; |
| 114 | 108 |
| 115 ASSERT(!m_frameView.isPainting()); | 109 ASSERT(!m_frameView.isPainting()); |
| 116 m_frameView.setIsPainting(true); | 110 m_frameView.setIsPainting(true); |
| 117 | 111 |
| 118 // m_frameView.nodeToDraw() is used to draw only one element (and its descen
dants) | 112 // m_frameView.nodeToDraw() is used to draw only one element (and its descen
dants) |
| 119 LayoutObject* layoutObject = m_frameView.nodeToDraw() ? m_frameView.nodeToDr
aw()->layoutObject() : 0; | 113 LayoutObject* layoutObject = m_frameView.nodeToDraw() ? m_frameView.nodeToDr
aw()->layoutObject() : 0; |
| 120 DeprecatedPaintLayer* rootLayer = layoutView->layer(); | 114 DeprecatedPaintLayer* rootLayer = layoutView->layer(); |
| 121 | 115 |
| 122 #if ENABLE(ASSERT) | 116 #if ENABLE(ASSERT) |
| 123 layoutView->assertSubtreeIsLaidOut(); | 117 layoutView->assertSubtreeIsLaidOut(); |
| 124 LayoutObject::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(*rootLayer-
>layoutObject()); | 118 LayoutObject::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(*rootLayer-
>layoutObject()); |
| 125 #endif | 119 #endif |
| 126 | 120 |
| 127 DeprecatedPaintLayerPainter layerPainter(*rootLayer); | 121 DeprecatedPaintLayerPainter layerPainter(*rootLayer); |
| 128 | 122 |
| 129 float deviceScaleFactor = blink::deviceScaleFactor(rootLayer->layoutObject()
->frame()); | 123 float deviceScaleFactor = blink::deviceScaleFactor(rootLayer->layoutObject()
->frame()); |
| 130 context->setDeviceScaleFactor(deviceScaleFactor); | 124 context->setDeviceScaleFactor(deviceScaleFactor); |
| 131 | 125 |
| 132 layerPainter.paint(context, LayoutRect(rect), m_frameView.paintBehavior(), l
ayoutObject); | 126 layerPainter.paint(context, LayoutRect(rect), PaintBehaviorNormal, layoutObj
ect); |
| 133 | 127 |
| 134 if (rootLayer->containsDirtyOverlayScrollbars()) | 128 if (rootLayer->containsDirtyOverlayScrollbars()) |
| 135 layerPainter.paintOverlayScrollbars(context, LayoutRect(rect), m_frameVi
ew.paintBehavior(), layoutObject); | 129 layerPainter.paintOverlayScrollbars(context, LayoutRect(rect), PaintBeha
viorNormal, layoutObject); |
| 136 | 130 |
| 137 m_frameView.setIsPainting(false); | 131 m_frameView.setIsPainting(false); |
| 138 | 132 |
| 139 m_frameView.setPaintBehavior(oldPaintBehavior); | |
| 140 m_frameView.setLastPaintTime(currentTime()); | 133 m_frameView.setLastPaintTime(currentTime()); |
| 141 | 134 |
| 142 // Regions may have changed as a result of the visibility/z-index of element
changing. | 135 // Regions may have changed as a result of the visibility/z-index of element
changing. |
| 143 if (document->annotatedRegionsDirty()) | 136 if (document->annotatedRegionsDirty()) |
| 144 m_frameView.updateAnnotatedRegions(); | 137 m_frameView.updateAnnotatedRegions(); |
| 145 | 138 |
| 146 if (isTopLevelPainter) { | 139 if (isTopLevelPainter) { |
| 147 // Everything that happens after paintContents completions is considered | 140 // Everything that happens after paintContents completions is considered |
| 148 // to be part of the next frame. | 141 // to be part of the next frame. |
| 149 memoryCache()->updateFramePaintTimestamp(); | 142 memoryCache()->updateFramePaintTimestamp(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 if (needsBackground) { | 181 if (needsBackground) { |
| 189 IntRect toFill = bar->frameRect(); | 182 IntRect toFill = bar->frameRect(); |
| 190 toFill.intersect(rect); | 183 toFill.intersect(rect); |
| 191 context->fillRect(toFill, m_frameView.baseBackgroundColor()); | 184 context->fillRect(toFill, m_frameView.baseBackgroundColor()); |
| 192 } | 185 } |
| 193 | 186 |
| 194 bar->paint(context, rect); | 187 bar->paint(context, rect); |
| 195 } | 188 } |
| 196 | 189 |
| 197 } // namespace blink | 190 } // namespace blink |
| OLD | NEW |