Changeset 172864 in webkit
- Timestamp:
- Aug 22, 2014, 12:07:17 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r172862 r172864 1 2014-08-22 Simon Fraser <simon.fraser@apple.com> 2 3 Implement paint flashing via GraphicsLayers in the WK2 inspector overlay 4 https://bugs.webkit.org/show_bug.cgi?id=136136 5 6 Reviewed by Sam Weinig, Joseph Pecoraro. 7 8 Allow InspectorClient to have a custom implementation of showPaintRect(). For 9 WebKit2's WebInspectorClient, implement this by creating a set of GraphicsLayers 10 which are parented in a document overlay, with 0.25s fade-out animations. 11 12 Also change InspectorInstrumentation::didPaintImpl() to no longer take a GraphicsContext; 13 it makes no sense to paint the paint rects directly into the context of the web page. 14 Now that the paint rects are painted into an overlay, the rectangles need to be converted 15 to root document coordinates, which is done in InspectorInstrumentation::didPaintImpl(). 16 17 Remove the generic InspectorOverlay::drawOutline()-based indicators; they will 18 be reimplemented in a later patch. 19 20 * WebCore.exp.in: 21 * inspector/InspectorClient.h: 22 (WebCore::InspectorClient::showPaintRect): 23 * inspector/InspectorInstrumentation.cpp: 24 (WebCore::InspectorInstrumentation::didPaintImpl): 25 * inspector/InspectorInstrumentation.h: 26 (WebCore::InspectorInstrumentation::didPaint): 27 * inspector/InspectorPageAgent.cpp: 28 (WebCore::InspectorPageAgent::didPaint): 29 * inspector/InspectorPageAgent.h: 30 * page/FrameView.cpp: 31 (WebCore::FrameView::didPaintContents): 32 * rendering/RenderLayerBacking.cpp: 33 (WebCore::RenderLayerBacking::paintContents): 34 1 35 2014-08-22 Commit Queue <commit-queue@webkit.org> 2 36 -
trunk/Source/WebCore/WebCore.exp.in
r172854 r172864 760 760 __ZN7WebCore17HistoryController33restoreScrollPositionAndViewStateEv 761 761 __ZN7WebCore17JSDOMGlobalObject6s_infoE 762 __ZN7WebCore17KeyframeValueList6insertEN3WTF10PassOwnPtrIKNS_14AnimationValueEEE 762 763 __ZN7WebCore17MouseRelatedEvent7offsetXEv 763 764 __ZN7WebCore17MouseRelatedEvent7offsetYEv … … 1378 1379 __ZN7WebCore8toUInt16EPN3JSC9ExecStateENS0_7JSValueENS_30IntegerConversionConfigurationE 1379 1380 __ZN7WebCore8toUInt64EPN3JSC9ExecStateENS0_7JSValueENS_30IntegerConversionConfigurationE 1381 __ZN7WebCore9AnimationC1Ev 1382 __ZN7WebCore9AnimationD1Ev 1380 1383 __ZN7WebCore9DOMWindow30dispatchAllPendingUnloadEventsEv 1381 1384 __ZN7WebCore9DOMWindow36dispatchAllPendingBeforeUnloadEventsEv -
trunk/Source/WebCore/inspector/InspectorClient.h
r172862 r172864 35 35 namespace WebCore { 36 36 37 class FloatRect; 38 class Frame; 37 39 class InspectorController; 38 class Frame;39 40 class Page; 40 41 … … 61 62 virtual void clearBrowserCookies() { } 62 63 63 virtual bool overridesShowPaintRects() { return false; }64 virtual bool overridesShowPaintRects() const { return false; } 64 65 virtual void setShowPaintRects(bool) { } 66 virtual void showPaintRect(const FloatRect&) { } 65 67 66 68 virtual bool canShowDebugBorders() { return false; } -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r171195 r172864 486 486 } 487 487 488 void InspectorInstrumentation::didPaintImpl(InstrumentingAgents* instrumentingAgents, RenderObject* renderer, GraphicsContext* context, const LayoutRect& rect)488 void InspectorInstrumentation::didPaintImpl(InstrumentingAgents* instrumentingAgents, RenderObject* renderer, const LayoutRect& rect) 489 489 { 490 490 if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) 491 491 timelineAgent->didPaint(renderer, rect); 492 492 493 if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent()) 493 pageAgent->didPaint( context, rect);494 pageAgent->didPaint(renderer, rect); 494 495 } 495 496 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r172862 r172864 167 167 static void didScrollLayer(Frame*); 168 168 static void willPaint(RenderObject*); 169 static void didPaint(RenderObject*, GraphicsContext*,const LayoutRect&);169 static void didPaint(RenderObject*, const LayoutRect&); 170 170 static InspectorInstrumentationCookie willRecalculateStyle(Document*); 171 171 static void didRecalculateStyle(const InspectorInstrumentationCookie&); … … 365 365 static void didScrollLayerImpl(InstrumentingAgents*); 366 366 static void willPaintImpl(InstrumentingAgents*, RenderObject*); 367 static void didPaintImpl(InstrumentingAgents*, RenderObject*, GraphicsContext*,const LayoutRect&);367 static void didPaintImpl(InstrumentingAgents*, RenderObject*, const LayoutRect&); 368 368 static InspectorInstrumentationCookie willRecalculateStyleImpl(InstrumentingAgents*, Frame*); 369 369 static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&); … … 1122 1122 } 1123 1123 1124 inline void InspectorInstrumentation::didPaint(RenderObject* renderer, GraphicsContext* context,const LayoutRect& rect)1124 inline void InspectorInstrumentation::didPaint(RenderObject* renderer, const LayoutRect& rect) 1125 1125 { 1126 1126 #if ENABLE(INSPECTOR) 1127 1127 FAST_RETURN_IF_NO_FRONTENDS(void()); 1128 1128 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderer(renderer)) 1129 didPaintImpl(instrumentingAgents, renderer, context,rect);1129 didPaintImpl(instrumentingAgents, renderer, rect); 1130 1130 #else 1131 1131 UNUSED_PARAM(renderer); 1132 UNUSED_PARAM(context);1133 1132 UNUSED_PARAM(rect); 1134 1133 #endif -
trunk/Source/WebCore/inspector/InspectorPageAgent.cpp
r172790 r172864 881 881 } 882 882 883 void InspectorPageAgent::didPaint(GraphicsContext* context, const LayoutRect& rect) 884 { 885 if (!m_enabled || m_client->overridesShowPaintRects() || !m_showPaintRects) 886 return; 887 888 static int colorSelector = 0; 889 const Color colors[] = { 890 Color(0xFF, 0, 0, 0x3F), 891 Color(0xFF, 0, 0xFF, 0x3F), 892 Color(0, 0, 0xFF, 0x3F), 893 }; 894 895 LayoutRect inflatedRect(rect); 896 inflatedRect.inflate(-1); 897 m_overlay->drawOutline(context, inflatedRect, colors[colorSelector++ % WTF_ARRAY_LENGTH(colors)]); 883 void InspectorPageAgent::didPaint(RenderObject* renderer, const LayoutRect& rect) 884 { 885 if (!m_enabled || !m_showPaintRects) 886 return; 887 888 LayoutRect absoluteRect = LayoutRect(renderer->localToAbsoluteQuad(FloatRect(rect)).boundingBox()); 889 FrameView* view = renderer->document().view(); 890 891 LayoutRect rootRect = absoluteRect; 892 if (!view->frame().isMainFrame()) { 893 IntRect rootViewRect = view->contentsToRootView(pixelSnappedIntRect(absoluteRect)); 894 rootRect = view->frame().mainFrame().view()->rootViewToContents(rootViewRect); 895 } 896 897 if (m_client->overridesShowPaintRects()) { 898 m_client->showPaintRect(rect); 899 return; 900 } 901 902 // FIXME: the overlay needs to accumulate paint rects and draw them itself. 898 903 } 899 904 -
trunk/Source/WebCore/inspector/InspectorPageAgent.h
r172655 r172864 56 56 class Frame; 57 57 class Frontend; 58 class GraphicsContext;59 58 class InspectorClient; 60 59 class InspectorOverlay; … … 62 61 class URL; 63 62 class Page; 63 class RenderObject; 64 64 class SharedBuffer; 65 65 class TextResourceDecoder; … … 141 141 void didRunJavaScriptDialog(); 142 142 void applyEmulatedMedia(String*); 143 void didPaint( GraphicsContext*, const LayoutRect&);143 void didPaint(RenderObject*, const LayoutRect&); 144 144 void didLayout(); 145 145 void didScroll(); -
trunk/Source/WebCore/page/FrameView.cpp
r172854 r172864 3670 3670 3671 3671 if (!context->paintingDisabled()) { 3672 InspectorInstrumentation::didPaint(renderView(), context,dirtyRect);3672 InspectorInstrumentation::didPaint(renderView(), dirtyRect); 3673 3673 // FIXME: should probably not fire milestones for snapshot painting. https://bugs.webkit.org/show_bug.cgi?id=117623 3674 3674 firePaintRelatedMilestonesIfNeeded(); -
trunk/Source/WebCore/rendering/RenderLayerBacking.cpp
r172836 r172864 2199 2199 paintIntoLayer(graphicsLayer, &context, dirtyRect, PaintBehaviorNormal, paintingPhase); 2200 2200 2201 InspectorInstrumentation::didPaint(&renderer(), &context,dirtyRect);2201 InspectorInstrumentation::didPaint(&renderer(), dirtyRect); 2202 2202 } else if (graphicsLayer == layerForHorizontalScrollbar()) { 2203 2203 paintScrollbar(m_owningLayer.horizontalScrollbar(), context, dirtyRect); -
trunk/Source/WebKit2/ChangeLog
r172860 r172864 1 2014-08-22 Simon Fraser <simon.fraser@apple.com> 2 3 Implement paint flashing via GraphicsLayers in the WK2 inspector overlay 4 https://bugs.webkit.org/show_bug.cgi?id=136136 5 6 Reviewed by Sam Weinig, Joseph Pecoraro. 7 8 Allow InspectorClient to have a custom implementation of showPaintRect(). For 9 WebKit2's WebInspectorClient, implement this by creating a set of GraphicsLayers 10 which are parented in a document overlay, with 0.25s fade-out animations. 11 12 Also change InspectorInstrumentation::didPaintImpl() to no longer take a GraphicsContext; 13 it makes no sense to paint the paint rects directly into the context of the web page. 14 Now that the paint rects are painted into an overlay, the rectangles need to be converted 15 to root document coordinates, which is done in InspectorInstrumentation::didPaintImpl(). 16 17 Remove the generic InspectorOverlay::drawOutline()-based indicators; they will 18 be reimplemented in a later patch. 19 20 * WebProcess/WebCoreSupport/WebInspectorClient.cpp: 21 (WebKit::RepaintIndicatorLayerClient::RepaintIndicatorLayerClient): 22 (WebKit::RepaintIndicatorLayerClient::~RepaintIndicatorLayerClient): 23 (WebKit::RepaintIndicatorLayerClient::notifyAnimationEnded): 24 (WebKit::WebInspectorClient::WebInspectorClient): 25 (WebKit::WebInspectorClient::~WebInspectorClient): 26 (WebKit::WebInspectorClient::showPaintRect): 27 (WebKit::WebInspectorClient::animationEndedForLayer): 28 * WebProcess/WebCoreSupport/WebInspectorClient.h: 29 (WebKit::WebInspectorClient::WebInspectorClient): Deleted. 30 1 31 2014-08-22 Jon Lee <jonlee@apple.com> 2 32 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp
r170445 r172864 29 29 #if ENABLE(INSPECTOR) 30 30 31 #include "DrawingArea.h" 31 32 #include "WebInspector.h" 32 33 #include "WebPage.h" 33 34 #include <WebCore/InspectorController.h> 34 35 #include <WebCore/Page.h> 36 #include <wtf/CurrentTime.h> 35 37 36 38 #if PLATFORM(IOS) … … 41 43 42 44 namespace WebKit { 45 46 class RepaintIndicatorLayerClient final : public GraphicsLayerClient { 47 public: 48 RepaintIndicatorLayerClient(WebInspectorClient& inspectorClient) 49 : m_inspectorClient(inspectorClient) 50 { 51 } 52 virtual ~RepaintIndicatorLayerClient() { } 53 private: 54 virtual void notifyAnimationEnded(const GraphicsLayer* layer, const String&) override 55 { 56 m_inspectorClient.animationEndedForLayer(layer); 57 } 58 59 WebInspectorClient& m_inspectorClient; 60 }; 61 62 WebInspectorClient::WebInspectorClient(WebPage* page) 63 : m_page(page) 64 , m_highlightOverlay(nullptr) 65 { 66 } 67 68 WebInspectorClient::~WebInspectorClient() 69 { 70 for (auto layer : m_paintRectLayers) { 71 layer->removeFromParent(); 72 delete layer; 73 } 74 75 if (m_paintRectOverlay) 76 m_page->uninstallPageOverlay(m_paintRectOverlay.get()); 77 } 43 78 44 79 void WebInspectorClient::inspectorDestroyed() … … 101 136 } 102 137 138 void WebInspectorClient::showPaintRect(const FloatRect& rect) 139 { 140 if (!m_paintRectOverlay) { 141 m_paintRectOverlay = PageOverlay::create(this, PageOverlay::OverlayType::Document); 142 m_page->installPageOverlay(m_paintRectOverlay, PageOverlay::FadeMode::DoNotFade); 143 } 144 145 if (!m_paintIndicatorLayerClient) 146 m_paintIndicatorLayerClient = std::make_unique<RepaintIndicatorLayerClient>(*this); 147 148 std::unique_ptr<GraphicsLayer> paintLayer = GraphicsLayer::create(m_page->drawingArea()->graphicsLayerFactory(), *m_paintIndicatorLayerClient); 149 150 paintLayer->setAnchorPoint(FloatPoint3D()); 151 paintLayer->setPosition(rect.location()); 152 paintLayer->setSize(rect.size()); 153 paintLayer->setBackgroundColor(Color(1.0f, 0.0f, 0.0f, 0.2f)); 154 155 KeyframeValueList fadeKeyframes(AnimatedPropertyOpacity); 156 OwnPtr<AnimationValue> intialValue = FloatAnimationValue::create(0, 1); 157 fadeKeyframes.insert(intialValue.release()); 158 159 OwnPtr<AnimationValue> finalValue = FloatAnimationValue::create(0.25, 0); 160 fadeKeyframes.insert(finalValue.release()); 161 162 RefPtr<Animation> opacityAnimation = Animation::create(); 163 opacityAnimation->setDuration(0.25); 164 165 paintLayer->addAnimation(fadeKeyframes, FloatSize(), opacityAnimation.get(), ASCIILiteral("opacity"), 0); 166 167 m_paintRectLayers.add(paintLayer.get()); 168 169 GraphicsLayer* overlayRootLayer = m_paintRectOverlay->layer(); 170 overlayRootLayer->addChild(paintLayer.release()); 171 } 172 173 void WebInspectorClient::animationEndedForLayer(const GraphicsLayer* layer) 174 { 175 const_cast<GraphicsLayer*>(layer)->removeFromParent(); 176 m_paintRectLayers.remove(const_cast<GraphicsLayer*>(layer)); 177 delete layer; 178 } 179 103 180 #if PLATFORM(IOS) 104 181 void WebInspectorClient::showInspectorIndication() -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h
r170445 r172864 33 33 #include <WebCore/InspectorClient.h> 34 34 #include <WebCore/InspectorForwarding.h> 35 #include <wtf/HashSet.h> 35 36 36 37 namespace WebCore { 37 38 class GraphicsContext; 39 class GraphicsLayer; 38 40 class IntRect; 39 41 } … … 42 44 43 45 class WebPage; 46 class RepaintIndicatorLayerClient; 44 47 45 48 class WebInspectorClient : public WebCore::InspectorClient, public WebCore::InspectorFrontendChannel, private PageOverlay::Client { 49 friend class RepaintIndicatorLayerClient; 46 50 public: 47 WebInspectorClient(WebPage* page) 48 : m_page(page) 49 , m_highlightOverlay(0) 50 { 51 } 51 WebInspectorClient(WebPage*); 52 virtual ~WebInspectorClient(); 52 53 53 54 private: … … 69 70 #endif 70 71 72 virtual bool overridesShowPaintRects() const override { return true; } 73 virtual void showPaintRect(const WebCore::FloatRect&) override; 74 71 75 virtual bool sendMessageToFrontend(const String&) override; 72 76 … … 80 84 virtual bool mouseEvent(PageOverlay*, const WebMouseEvent&) override; 81 85 86 void animationEndedForLayer(const WebCore::GraphicsLayer*); 87 82 88 WebPage* m_page; 83 89 PageOverlay* m_highlightOverlay; 90 91 RefPtr<PageOverlay> m_paintRectOverlay; 92 std::unique_ptr<RepaintIndicatorLayerClient> m_paintIndicatorLayerClient; 93 HashSet<WebCore::GraphicsLayer*> m_paintRectLayers; // Ideally this would be HashSet<std::unique_ptr<GraphicsLayer>> but that doesn't work yet. webkit.org/b/136166 84 94 }; 85 95
Note:
See TracChangeset
for help on using the changeset viewer.