| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 #include "core/layout/compositing/PaintLayerCompositor.h" | 85 #include "core/layout/compositing/PaintLayerCompositor.h" |
| 86 #include "core/layout/svg/LayoutSVGRoot.h" | 86 #include "core/layout/svg/LayoutSVGRoot.h" |
| 87 #include "core/loader/DocumentLoader.h" | 87 #include "core/loader/DocumentLoader.h" |
| 88 #include "core/loader/FrameLoader.h" | 88 #include "core/loader/FrameLoader.h" |
| 89 #include "core/loader/FrameLoaderClient.h" | 89 #include "core/loader/FrameLoaderClient.h" |
| 90 #include "core/page/AutoscrollController.h" | 90 #include "core/page/AutoscrollController.h" |
| 91 #include "core/page/ChromeClient.h" | 91 #include "core/page/ChromeClient.h" |
| 92 #include "core/page/FocusController.h" | 92 #include "core/page/FocusController.h" |
| 93 #include "core/page/FrameTree.h" | 93 #include "core/page/FrameTree.h" |
| 94 #include "core/page/Page.h" | 94 #include "core/page/Page.h" |
| 95 #include "core/page/PrintContext.h" |
| 95 #include "core/page/scrolling/RootScrollerUtil.h" | 96 #include "core/page/scrolling/RootScrollerUtil.h" |
| 96 #include "core/page/scrolling/ScrollingCoordinator.h" | 97 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 97 #include "core/page/scrolling/TopDocumentRootScrollerController.h" | 98 #include "core/page/scrolling/TopDocumentRootScrollerController.h" |
| 98 #include "core/paint/BlockPaintInvalidator.h" | 99 #include "core/paint/BlockPaintInvalidator.h" |
| 99 #include "core/paint/FramePainter.h" | 100 #include "core/paint/FramePainter.h" |
| 100 #include "core/paint/PaintLayer.h" | 101 #include "core/paint/PaintLayer.h" |
| 101 #include "core/paint/PaintTiming.h" | 102 #include "core/paint/PaintTiming.h" |
| 102 #include "core/paint/PrePaintTreeWalk.h" | 103 #include "core/paint/PrePaintTreeWalk.h" |
| 103 #include "core/plugins/PluginView.h" | 104 #include "core/plugins/PluginView.h" |
| 104 #include "core/style/ComputedStyle.h" | 105 #include "core/style/ComputedStyle.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 #define CHECK_FOR_DIRTY_LAYOUT(arg) \ | 141 #define CHECK_FOR_DIRTY_LAYOUT(arg) \ |
| 141 do { \ | 142 do { \ |
| 142 if (!(arg)) { \ | 143 if (!(arg)) { \ |
| 143 NOTREACHED(); \ | 144 NOTREACHED(); \ |
| 144 return false; \ | 145 return false; \ |
| 145 } \ | 146 } \ |
| 146 } while (false) | 147 } while (false) |
| 147 | 148 |
| 148 namespace blink { | 149 namespace blink { |
| 149 | 150 |
| 151 // A4 Portrait dimensions in pixels |
| 152 const int kA4PortraitPageWidth = 595; |
| 153 const int kA4PortraitPageHeight = 842; |
| 154 |
| 150 using namespace HTMLNames; | 155 using namespace HTMLNames; |
| 151 | 156 |
| 152 // The maximum number of updateWidgets iterations that should be done before | 157 // The maximum number of updateWidgets iterations that should be done before |
| 153 // returning. | 158 // returning. |
| 154 static const unsigned maxUpdateWidgetsIterations = 2; | 159 static const unsigned maxUpdateWidgetsIterations = 2; |
| 155 static const double resourcePriorityUpdateDelayAfterScroll = 0.250; | 160 static const double resourcePriorityUpdateDelayAfterScroll = 0.250; |
| 156 | 161 |
| 157 static bool s_initialTrackAllPaintInvalidations = false; | 162 static bool s_initialTrackAllPaintInvalidations = false; |
| 158 | 163 |
| 159 FrameView::FrameView(LocalFrame& frame) | 164 FrameView::FrameView(LocalFrame& frame) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 visitor->trace(m_fragmentAnchor); | 234 visitor->trace(m_fragmentAnchor); |
| 230 visitor->trace(m_scrollableAreas); | 235 visitor->trace(m_scrollableAreas); |
| 231 visitor->trace(m_animatingScrollableAreas); | 236 visitor->trace(m_animatingScrollableAreas); |
| 232 visitor->trace(m_autoSizeInfo); | 237 visitor->trace(m_autoSizeInfo); |
| 233 visitor->trace(m_children); | 238 visitor->trace(m_children); |
| 234 visitor->trace(m_viewportScrollableArea); | 239 visitor->trace(m_viewportScrollableArea); |
| 235 visitor->trace(m_visibilityObserver); | 240 visitor->trace(m_visibilityObserver); |
| 236 visitor->trace(m_scrollAnchor); | 241 visitor->trace(m_scrollAnchor); |
| 237 visitor->trace(m_anchoringAdjustmentQueue); | 242 visitor->trace(m_anchoringAdjustmentQueue); |
| 238 visitor->trace(m_scrollbarManager); | 243 visitor->trace(m_scrollbarManager); |
| 244 visitor->trace(m_printContext); |
| 239 Widget::trace(visitor); | 245 Widget::trace(visitor); |
| 240 ScrollableArea::trace(visitor); | 246 ScrollableArea::trace(visitor); |
| 241 } | 247 } |
| 242 | 248 |
| 243 void FrameView::reset() { | 249 void FrameView::reset() { |
| 244 // The compositor throttles the main frame using deferred commits, we can't | 250 // The compositor throttles the main frame using deferred commits, we can't |
| 245 // throttle it here or it seems the root compositor doesn't get setup | 251 // throttle it here or it seems the root compositor doesn't get setup |
| 246 // properly. | 252 // properly. |
| 247 if (RuntimeEnabledFeatures:: | 253 if (RuntimeEnabledFeatures:: |
| 248 renderingPipelineThrottlingLoadingIframesEnabled()) | 254 renderingPipelineThrottlingLoadingIframesEnabled()) |
| (...skipping 2630 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()) |
| 2906 return; |
| 2907 if (!m_printContext) |
| 2908 m_printContext = new PrintContext(m_frame); |
| 2909 if (m_frame->settings()) |
| 2910 m_frame->settings()->setShouldPrintBackgrounds(true); |
| 2911 FloatRect pageRect(0, 0, kA4PortraitPageWidth, kA4PortraitPageHeight); |
| 2912 m_printContext->begin(pageRect.width(), pageRect.height()); |
| 2913 float height; |
| 2914 m_printContext->computePageRects(pageRect, 0, 0, 1.0, height); |
| 2915 dispatchEventsForPrintingOnAllFrames(); |
| 2916 } |
| 2917 |
| 2918 void FrameView::clearPrintContext() { |
| 2919 if (!m_printContext) |
| 2920 return; |
| 2921 m_printContext->end(); |
| 2922 m_printContext.clear(); |
| 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 |
| 2921 updateStyleAndLayoutIfNeededRecursive(); | 2962 updateStyleAndLayoutIfNeededRecursive(); |
| 2922 DCHECK(lifecycle().state() >= DocumentLifecycle::LayoutClean); | 2963 DCHECK(lifecycle().state() >= DocumentLifecycle::LayoutClean); |
| 2923 | 2964 |
| 2924 if (targetState == DocumentLifecycle::LayoutClean) { | 2965 if (targetState == DocumentLifecycle::LayoutClean) { |
| 2925 updateViewportIntersectionsForSubtree(targetState); | 2966 updateViewportIntersectionsForSubtree(targetState); |
| 2926 return; | 2967 return; |
| 2927 } | 2968 } |
| 2928 | 2969 |
| 2929 forAllNonThrottledFrameViews([](FrameView& frameView) { | 2970 forAllNonThrottledFrameViews([](FrameView& frameView) { |
| 2930 frameView.performScrollAnchoringAdjustments(); | 2971 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 | 3024 // TODO(pdr): prePaint should be under the "Paint" devtools timeline step |
| 2984 // for slimming paint v2. | 3025 // for slimming paint v2. |
| 2985 if (targetState >= DocumentLifecycle::PrePaintClean) | 3026 if (targetState >= DocumentLifecycle::PrePaintClean) |
| 2986 prePaint(); | 3027 prePaint(); |
| 2987 } | 3028 } |
| 2988 | 3029 |
| 2989 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 3030 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 2990 DocumentAnimations::updateAnimations(layoutView()->document()); | 3031 DocumentAnimations::updateAnimations(layoutView()->document()); |
| 2991 | 3032 |
| 2992 if (targetState == DocumentLifecycle::PaintClean) { | 3033 if (targetState == DocumentLifecycle::PaintClean) { |
| 2993 if (!m_frame->document()->printing()) | 3034 if (!m_frame->document()->printing() || |
| 3035 RuntimeEnabledFeatures::printBrowserEnabled()) |
| 2994 paintTree(); | 3036 paintTree(); |
| 2995 | 3037 |
| 2996 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 3038 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 2997 pushPaintArtifactToCompositor(); | 3039 pushPaintArtifactToCompositor(); |
| 2998 | 3040 |
| 2999 DCHECK(!view.hasPendingSelection()); | 3041 DCHECK(!view.hasPendingSelection()); |
| 3000 DCHECK((m_frame->document()->printing() && | 3042 DCHECK((m_frame->document()->printing() && |
| 3001 lifecycle().state() == DocumentLifecycle::PrePaintClean) || | 3043 lifecycle().state() == DocumentLifecycle::PrePaintClean) || |
| 3002 lifecycle().state() == DocumentLifecycle::PaintClean); | 3044 lifecycle().state() == DocumentLifecycle::PaintClean); |
| 3003 } | 3045 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3076 | 3118 |
| 3077 LayoutViewItem view = layoutViewItem(); | 3119 LayoutViewItem view = layoutViewItem(); |
| 3078 ASSERT(!view.isNull()); | 3120 ASSERT(!view.isNull()); |
| 3079 forAllNonThrottledFrameViews([](FrameView& frameView) { | 3121 forAllNonThrottledFrameViews([](FrameView& frameView) { |
| 3080 frameView.lifecycle().advanceTo(DocumentLifecycle::InPaint); | 3122 frameView.lifecycle().advanceTo(DocumentLifecycle::InPaint); |
| 3081 }); | 3123 }); |
| 3082 | 3124 |
| 3083 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 3125 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 3084 if (layoutView()->layer()->needsRepaint()) { | 3126 if (layoutView()->layer()->needsRepaint()) { |
| 3085 GraphicsContext graphicsContext(*m_paintController); | 3127 GraphicsContext graphicsContext(*m_paintController); |
| 3128 if (RuntimeEnabledFeatures::printBrowserEnabled()) |
| 3129 graphicsContext.setPrinting(true); |
| 3086 paint(graphicsContext, CullRect(LayoutRect::infiniteIntRect())); | 3130 paint(graphicsContext, CullRect(LayoutRect::infiniteIntRect())); |
| 3087 m_paintController->commitNewDisplayItems(LayoutSize()); | 3131 m_paintController->commitNewDisplayItems(LayoutSize()); |
| 3088 notifyPaint(*m_paintController); | 3132 notifyPaint(*m_paintController); |
| 3089 } | 3133 } |
| 3090 } else { | 3134 } else { |
| 3091 // 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 |
| 3092 // 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 |
| 3093 // 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 |
| 3094 // 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. |
| 3095 if (GraphicsLayer* rootGraphicsLayer = | 3139 if (GraphicsLayer* rootGraphicsLayer = |
| (...skipping 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5101 std::unique_ptr<CompositorAnimationTimeline> timeline) { | 5145 std::unique_ptr<CompositorAnimationTimeline> timeline) { |
| 5102 m_animationTimeline = std::move(timeline); | 5146 m_animationTimeline = std::move(timeline); |
| 5103 } | 5147 } |
| 5104 | 5148 |
| 5105 void FrameView::setAnimationHost( | 5149 void FrameView::setAnimationHost( |
| 5106 std::unique_ptr<CompositorAnimationHost> host) { | 5150 std::unique_ptr<CompositorAnimationHost> host) { |
| 5107 m_animationHost = std::move(host); | 5151 m_animationHost = std::move(host); |
| 5108 } | 5152 } |
| 5109 | 5153 |
| 5110 } // namespace blink | 5154 } // namespace blink |
| OLD | NEW |