Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> | 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
| 3 * 1999 Lars Knoll <knoll@kde.org> | 3 * 1999 Lars Knoll <knoll@kde.org> |
| 4 * 1999 Antti Koivisto <koivisto@kde.org> | 4 * 1999 Antti Koivisto <koivisto@kde.org> |
| 5 * 2000 Dirk Mueller <mueller@kde.org> | 5 * 2000 Dirk Mueller <mueller@kde.org> |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 9 * Copyright (C) 2009 Google Inc. All rights reserved. | 9 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 10 * | 10 * |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 #include "core/layout/compositing/PaintLayerCompositor.h" | 83 #include "core/layout/compositing/PaintLayerCompositor.h" |
| 84 #include "core/layout/svg/LayoutSVGRoot.h" | 84 #include "core/layout/svg/LayoutSVGRoot.h" |
| 85 #include "core/loader/DocumentLoader.h" | 85 #include "core/loader/DocumentLoader.h" |
| 86 #include "core/loader/FrameLoader.h" | 86 #include "core/loader/FrameLoader.h" |
| 87 #include "core/loader/FrameLoaderClient.h" | 87 #include "core/loader/FrameLoaderClient.h" |
| 88 #include "core/page/AutoscrollController.h" | 88 #include "core/page/AutoscrollController.h" |
| 89 #include "core/page/ChromeClient.h" | 89 #include "core/page/ChromeClient.h" |
| 90 #include "core/page/FocusController.h" | 90 #include "core/page/FocusController.h" |
| 91 #include "core/page/FrameTree.h" | 91 #include "core/page/FrameTree.h" |
| 92 #include "core/page/Page.h" | 92 #include "core/page/Page.h" |
| 93 #include "core/page/PrintContext.h" | |
| 93 #include "core/page/scrolling/RootScrollerUtil.h" | 94 #include "core/page/scrolling/RootScrollerUtil.h" |
| 94 #include "core/page/scrolling/ScrollingCoordinator.h" | 95 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 95 #include "core/page/scrolling/TopDocumentRootScrollerController.h" | 96 #include "core/page/scrolling/TopDocumentRootScrollerController.h" |
| 96 #include "core/paint/FramePainter.h" | 97 #include "core/paint/FramePainter.h" |
| 97 #include "core/paint/PaintLayer.h" | 98 #include "core/paint/PaintLayer.h" |
| 98 #include "core/paint/PaintTiming.h" | 99 #include "core/paint/PaintTiming.h" |
| 99 #include "core/paint/PrePaintTreeWalk.h" | 100 #include "core/paint/PrePaintTreeWalk.h" |
| 100 #include "core/plugins/PluginView.h" | 101 #include "core/plugins/PluginView.h" |
| 101 #include "core/style/ComputedStyle.h" | 102 #include "core/style/ComputedStyle.h" |
| 102 #include "core/svg/SVGDocumentExtensions.h" | 103 #include "core/svg/SVGDocumentExtensions.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 #define CHECK_FOR_DIRTY_LAYOUT(arg) \ | 139 #define CHECK_FOR_DIRTY_LAYOUT(arg) \ |
| 139 do { \ | 140 do { \ |
| 140 if (!(arg)) { \ | 141 if (!(arg)) { \ |
| 141 NOTREACHED(); \ | 142 NOTREACHED(); \ |
| 142 return false; \ | 143 return false; \ |
| 143 } \ | 144 } \ |
| 144 } while (false) | 145 } while (false) |
| 145 | 146 |
| 146 namespace blink { | 147 namespace blink { |
| 147 | 148 |
| 149 // A4 Portrait dimensions in pixels | |
| 150 const int kA4PortraitPageWidth = 595; | |
| 151 const int kA4PortraitPageHeight = 842; | |
| 152 | |
| 148 using namespace HTMLNames; | 153 using namespace HTMLNames; |
| 149 | 154 |
| 150 // The maximum number of updateWidgets iterations that should be done before | 155 // The maximum number of updateWidgets iterations that should be done before |
| 151 // returning. | 156 // returning. |
| 152 static const unsigned maxUpdateWidgetsIterations = 2; | 157 static const unsigned maxUpdateWidgetsIterations = 2; |
| 153 static const double resourcePriorityUpdateDelayAfterScroll = 0.250; | 158 static const double resourcePriorityUpdateDelayAfterScroll = 0.250; |
| 154 | 159 |
| 155 static bool s_initialTrackAllPaintInvalidations = false; | 160 static bool s_initialTrackAllPaintInvalidations = false; |
| 156 | 161 |
| 157 FrameView::FrameView(LocalFrame& frame) | 162 FrameView::FrameView(LocalFrame& frame) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 visitor->trace(m_fragmentAnchor); | 232 visitor->trace(m_fragmentAnchor); |
| 228 visitor->trace(m_scrollableAreas); | 233 visitor->trace(m_scrollableAreas); |
| 229 visitor->trace(m_animatingScrollableAreas); | 234 visitor->trace(m_animatingScrollableAreas); |
| 230 visitor->trace(m_autoSizeInfo); | 235 visitor->trace(m_autoSizeInfo); |
| 231 visitor->trace(m_children); | 236 visitor->trace(m_children); |
| 232 visitor->trace(m_viewportScrollableArea); | 237 visitor->trace(m_viewportScrollableArea); |
| 233 visitor->trace(m_visibilityObserver); | 238 visitor->trace(m_visibilityObserver); |
| 234 visitor->trace(m_scrollAnchor); | 239 visitor->trace(m_scrollAnchor); |
| 235 visitor->trace(m_anchoringAdjustmentQueue); | 240 visitor->trace(m_anchoringAdjustmentQueue); |
| 236 visitor->trace(m_scrollbarManager); | 241 visitor->trace(m_scrollbarManager); |
| 242 visitor->trace(m_printContext); | |
| 237 Widget::trace(visitor); | 243 Widget::trace(visitor); |
| 238 ScrollableArea::trace(visitor); | 244 ScrollableArea::trace(visitor); |
| 239 } | 245 } |
| 240 | 246 |
| 241 void FrameView::reset() { | 247 void FrameView::reset() { |
| 242 // The compositor throttles the main frame using deferred commits, we can't | 248 // The compositor throttles the main frame using deferred commits, we can't |
| 243 // throttle it here or it seems the root compositor doesn't get setup | 249 // throttle it here or it seems the root compositor doesn't get setup |
| 244 // properly. | 250 // properly. |
| 245 if (RuntimeEnabledFeatures:: | 251 if (RuntimeEnabledFeatures:: |
| 246 renderingPipelineThrottlingLoadingIframesEnabled()) | 252 renderingPipelineThrottlingLoadingIframesEnabled()) |
| (...skipping 2632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2879 SourceLocation::capture(m_frame->document()), nullptr); | 2885 SourceLocation::capture(m_frame->document()), nullptr); |
| 2880 m_frame->document()->dispatchErrorEvent(error, NotSharableCrossOrigin); | 2886 m_frame->document()->dispatchErrorEvent(error, NotSharableCrossOrigin); |
| 2881 // Ensure notifications will get delivered in next cycle. | 2887 // Ensure notifications will get delivered in next cycle. |
| 2882 if (FrameView* frameView = m_frame->view()) | 2888 if (FrameView* frameView = m_frame->view()) |
| 2883 frameView->scheduleAnimation(); | 2889 frameView->scheduleAnimation(); |
| 2884 } | 2890 } |
| 2885 | 2891 |
| 2886 DCHECK(!layoutView()->needsLayout()); | 2892 DCHECK(!layoutView()->needsLayout()); |
| 2887 } | 2893 } |
| 2888 | 2894 |
| 2895 void FrameView::dispatchEventsForPrintingOnAllFrames() { | |
| 2896 DCHECK(m_frame->isMainFrame()); | |
| 2897 for (Frame* currentFrame = m_frame; currentFrame; | |
| 2898 currentFrame = currentFrame->tree().traverseNext(m_frame)) { | |
| 2899 if (currentFrame->isLocalFrame()) | |
| 2900 toLocalFrame(currentFrame)->document()->dispatchEventsForPrinting(); | |
| 2901 } | |
| 2902 } | |
| 2903 | |
| 2904 void FrameView::setupPrintContext() { | |
| 2905 if (!m_frame->document()->printing()) { | |
|
mstensho (USE GERRIT)
2017/02/08 14:32:29
Could consider an early return here; i.e.:
if (
gozzard
2017/02/09 04:17:25
Done.
| |
| 2906 if (!m_printContext) | |
| 2907 m_printContext = new PrintContext(m_frame); | |
| 2908 if (m_frame->settings()) | |
| 2909 m_frame->settings()->setShouldPrintBackgrounds(true); | |
| 2910 FloatRect pageRect(0, 0, kA4PortraitPageWidth, kA4PortraitPageHeight); | |
| 2911 m_printContext->begin(pageRect.width(), pageRect.height()); | |
| 2912 float height; | |
| 2913 m_printContext->computePageRects(pageRect, 0, 0, 1.0, height); | |
| 2914 dispatchEventsForPrintingOnAllFrames(); | |
|
pdr.
2017/02/08 06:34:08
Could you use forAllNonThrottledFrameViews for thi
gozzard
2017/02/09 04:17:25
dispatchEventsForPrinting() ultimately informs som
| |
| 2915 } | |
|
pdr.
2017/02/08 06:34:08
I think this approach can fail to dispatch print e
gozzard
2017/02/09 04:17:25
This appears to be the case. However, I believe th
| |
| 2916 } | |
| 2917 | |
| 2918 void FrameView::clearPrintContext() { | |
| 2919 if (m_printContext) { | |
|
mstensho (USE GERRIT)
2017/02/08 14:32:29
Might even consider an early return on !m_printCon
gozzard
2017/02/09 04:17:26
Done.
| |
| 2920 m_printContext->end(); | |
| 2921 m_printContext.clear(); | |
| 2922 } | |
| 2923 } | |
| 2924 | |
| 2889 // TODO(leviw): We don't assert lifecycle information from documents in child | 2925 // TODO(leviw): We don't assert lifecycle information from documents in child |
| 2890 // PluginViews. | 2926 // PluginViews. |
| 2891 void FrameView::updateLifecyclePhasesInternal( | 2927 void FrameView::updateLifecyclePhasesInternal( |
| 2892 DocumentLifecycle::LifecycleState targetState) { | 2928 DocumentLifecycle::LifecycleState targetState) { |
| 2893 if (m_currentUpdateLifecyclePhasesTargetState != | 2929 if (m_currentUpdateLifecyclePhasesTargetState != |
| 2894 DocumentLifecycle::Uninitialized) { | 2930 DocumentLifecycle::Uninitialized) { |
| 2895 NOTREACHED() << "FrameView::updateLifecyclePhasesInternal() reentrance"; | 2931 NOTREACHED() << "FrameView::updateLifecyclePhasesInternal() reentrance"; |
| 2896 return; | 2932 return; |
| 2897 } | 2933 } |
| 2898 | 2934 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2911 | 2947 |
| 2912 AutoReset<DocumentLifecycle::LifecycleState> targetStateScope( | 2948 AutoReset<DocumentLifecycle::LifecycleState> targetStateScope( |
| 2913 &m_currentUpdateLifecyclePhasesTargetState, targetState); | 2949 &m_currentUpdateLifecyclePhasesTargetState, targetState); |
| 2914 | 2950 |
| 2915 if (shouldThrottleRendering()) { | 2951 if (shouldThrottleRendering()) { |
| 2916 updateViewportIntersectionsForSubtree( | 2952 updateViewportIntersectionsForSubtree( |
| 2917 std::min(targetState, DocumentLifecycle::CompositingClean)); | 2953 std::min(targetState, DocumentLifecycle::CompositingClean)); |
| 2918 return; | 2954 return; |
| 2919 } | 2955 } |
| 2920 | 2956 |
| 2957 if (RuntimeEnabledFeatures::printBrowserEnabled()) { | |
| 2958 setupPrintContext(); | |
| 2959 } else { | |
| 2960 clearPrintContext(); | |
| 2961 } | |
|
mstensho (USE GERRIT)
2017/02/08 14:32:29
No need for the curly braces.
gozzard
2017/02/09 04:17:25
Done.
| |
| 2962 | |
| 2921 updateStyleAndLayoutIfNeededRecursive(); | 2963 updateStyleAndLayoutIfNeededRecursive(); |
| 2922 DCHECK(lifecycle().state() >= DocumentLifecycle::LayoutClean); | 2964 DCHECK(lifecycle().state() >= DocumentLifecycle::LayoutClean); |
| 2923 | 2965 |
| 2924 if (targetState == DocumentLifecycle::LayoutClean) { | 2966 if (targetState == DocumentLifecycle::LayoutClean) { |
| 2925 updateViewportIntersectionsForSubtree(targetState); | 2967 updateViewportIntersectionsForSubtree(targetState); |
| 2926 return; | 2968 return; |
| 2927 } | 2969 } |
| 2928 | 2970 |
| 2929 forAllNonThrottledFrameViews([](FrameView& frameView) { | 2971 forAllNonThrottledFrameViews([](FrameView& frameView) { |
| 2930 frameView.performScrollAnchoringAdjustments(); | 2972 frameView.performScrollAnchoringAdjustments(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2983 // TODO(pdr): prePaint should be under the "Paint" devtools timeline step | 3025 // TODO(pdr): prePaint should be under the "Paint" devtools timeline step |
| 2984 // for slimming paint v2. | 3026 // for slimming paint v2. |
| 2985 if (targetState >= DocumentLifecycle::PrePaintClean) | 3027 if (targetState >= DocumentLifecycle::PrePaintClean) |
| 2986 prePaint(); | 3028 prePaint(); |
| 2987 } | 3029 } |
| 2988 | 3030 |
| 2989 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 3031 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 2990 DocumentAnimations::updateAnimations(layoutView()->document()); | 3032 DocumentAnimations::updateAnimations(layoutView()->document()); |
| 2991 | 3033 |
| 2992 if (targetState == DocumentLifecycle::PaintClean) { | 3034 if (targetState == DocumentLifecycle::PaintClean) { |
| 2993 if (!m_frame->document()->printing()) | 3035 if (!m_frame->document()->printing() || |
| 3036 RuntimeEnabledFeatures::printBrowserEnabled()) | |
| 2994 paintTree(); | 3037 paintTree(); |
| 2995 | 3038 |
| 2996 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 3039 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 2997 pushPaintArtifactToCompositor(); | 3040 pushPaintArtifactToCompositor(); |
| 2998 | 3041 |
| 2999 DCHECK(!view.hasPendingSelection()); | 3042 DCHECK(!view.hasPendingSelection()); |
| 3000 DCHECK((m_frame->document()->printing() && | 3043 DCHECK((m_frame->document()->printing() && |
| 3001 lifecycle().state() == DocumentLifecycle::PrePaintClean) || | 3044 lifecycle().state() == DocumentLifecycle::PrePaintClean) || |
| 3002 lifecycle().state() == DocumentLifecycle::PaintClean); | 3045 lifecycle().state() == DocumentLifecycle::PaintClean); |
| 3003 } | 3046 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3075 | 3118 |
| 3076 LayoutViewItem view = layoutViewItem(); | 3119 LayoutViewItem view = layoutViewItem(); |
| 3077 ASSERT(!view.isNull()); | 3120 ASSERT(!view.isNull()); |
| 3078 forAllNonThrottledFrameViews([](FrameView& frameView) { | 3121 forAllNonThrottledFrameViews([](FrameView& frameView) { |
| 3079 frameView.lifecycle().advanceTo(DocumentLifecycle::InPaint); | 3122 frameView.lifecycle().advanceTo(DocumentLifecycle::InPaint); |
| 3080 }); | 3123 }); |
| 3081 | 3124 |
| 3082 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 3125 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 3083 if (layoutView()->layer()->needsRepaint()) { | 3126 if (layoutView()->layer()->needsRepaint()) { |
| 3084 GraphicsContext graphicsContext(*m_paintController); | 3127 GraphicsContext graphicsContext(*m_paintController); |
| 3128 if (RuntimeEnabledFeatures::printBrowserEnabled()) | |
| 3129 graphicsContext.setPrinting(true); | |
| 3085 paint(graphicsContext, CullRect(LayoutRect::infiniteIntRect())); | 3130 paint(graphicsContext, CullRect(LayoutRect::infiniteIntRect())); |
| 3086 m_paintController->commitNewDisplayItems(LayoutSize()); | 3131 m_paintController->commitNewDisplayItems(LayoutSize()); |
| 3087 notifyPaint(*m_paintController); | 3132 notifyPaint(*m_paintController); |
| 3088 } | 3133 } |
| 3089 } else { | 3134 } else { |
| 3090 // A null graphics layer can occur for painting of SVG images that are not | 3135 // A null graphics layer can occur for painting of SVG images that are not |
| 3091 // parented into the main frame tree, or when the FrameView is the main | 3136 // parented into the main frame tree, or when the FrameView is the main |
| 3092 // frame view of a page overlay. The page overlay is in the layer tree of | 3137 // frame view of a page overlay. The page overlay is in the layer tree of |
| 3093 // the host page and will be painted during painting of the host page. | 3138 // the host page and will be painted during painting of the host page. |
| 3094 if (GraphicsLayer* rootGraphicsLayer = | 3139 if (GraphicsLayer* rootGraphicsLayer = |
| (...skipping 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5095 std::unique_ptr<CompositorAnimationTimeline> timeline) { | 5140 std::unique_ptr<CompositorAnimationTimeline> timeline) { |
| 5096 m_animationTimeline = std::move(timeline); | 5141 m_animationTimeline = std::move(timeline); |
| 5097 } | 5142 } |
| 5098 | 5143 |
| 5099 void FrameView::setAnimationHost( | 5144 void FrameView::setAnimationHost( |
| 5100 std::unique_ptr<CompositorAnimationHost> host) { | 5145 std::unique_ptr<CompositorAnimationHost> host) { |
| 5101 m_animationHost = std::move(host); | 5146 m_animationHost = std::move(host); |
| 5102 } | 5147 } |
| 5103 | 5148 |
| 5104 } // namespace blink | 5149 } // namespace blink |
| OLD | NEW |