Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.cpp

Issue 1639363002: Move have_wheel_event_handlers to WebLayerTreeView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove blank line Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 27 matching lines...) Expand all
38 #include "core/frame/LocalFrame.h" 38 #include "core/frame/LocalFrame.h"
39 #include "core/frame/Settings.h" 39 #include "core/frame/Settings.h"
40 #include "core/inspector/IdentifiersFactory.h" 40 #include "core/inspector/IdentifiersFactory.h"
41 #include "core/inspector/InspectedFrames.h" 41 #include "core/inspector/InspectedFrames.h"
42 #include "core/inspector/InstrumentingAgents.h" 42 #include "core/inspector/InstrumentingAgents.h"
43 #include "core/layout/LayoutPart.h" 43 #include "core/layout/LayoutPart.h"
44 #include "core/layout/LayoutView.h" 44 #include "core/layout/LayoutView.h"
45 #include "core/layout/compositing/CompositedLayerMapping.h" 45 #include "core/layout/compositing/CompositedLayerMapping.h"
46 #include "core/layout/compositing/PaintLayerCompositor.h" 46 #include "core/layout/compositing/PaintLayerCompositor.h"
47 #include "core/loader/DocumentLoader.h" 47 #include "core/loader/DocumentLoader.h"
48 #include "core/page/ChromeClient.h"
48 #include "platform/geometry/IntRect.h" 49 #include "platform/geometry/IntRect.h"
49 #include "platform/graphics/CompositingReasons.h" 50 #include "platform/graphics/CompositingReasons.h"
50 #include "platform/graphics/GraphicsLayer.h" 51 #include "platform/graphics/GraphicsLayer.h"
51 #include "platform/graphics/PictureSnapshot.h" 52 #include "platform/graphics/PictureSnapshot.h"
52 #include "platform/graphics/paint/SkPictureBuilder.h" 53 #include "platform/graphics/paint/SkPictureBuilder.h"
53 #include "platform/image-encoders/skia/PNGImageEncoder.h" 54 #include "platform/image-encoders/skia/PNGImageEncoder.h"
54 #include "platform/transforms/TransformationMatrix.h" 55 #include "platform/transforms/TransformationMatrix.h"
55 #include "public/platform/WebFloatPoint.h" 56 #include "public/platform/WebFloatPoint.h"
56 #include "public/platform/WebLayer.h" 57 #include "public/platform/WebLayer.h"
57 #include "wtf/text/Base64.h" 58 #include "wtf/text/Base64.h"
(...skipping 14 matching lines...) Expand all
72 .setX(rect.x) 73 .setX(rect.x)
73 .setY(rect.y) 74 .setY(rect.y)
74 .setHeight(rect.height) 75 .setHeight(rect.height)
75 .setWidth(rect.width); 76 .setWidth(rect.width);
76 RefPtr<TypeBuilder::LayerTree::ScrollRect> scrollRectObject = TypeBuilder::L ayerTree::ScrollRect::create() 77 RefPtr<TypeBuilder::LayerTree::ScrollRect> scrollRectObject = TypeBuilder::L ayerTree::ScrollRect::create()
77 .setRect(rectObject.release()) 78 .setRect(rectObject.release())
78 .setType(type); 79 .setType(type);
79 return scrollRectObject.release(); 80 return scrollRectObject.release();
80 } 81 }
81 82
82 static PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect> > build ScrollRectsForLayer(GraphicsLayer* graphicsLayer) 83 static PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>> buildS crollRectsForLayer(GraphicsLayer* graphicsLayer, bool reportWheelScrollers)
83 { 84 {
84 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect> > scrollRects = TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>::create(); 85 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect> > scrollRects = TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>::create();
85 WebLayer* webLayer = graphicsLayer->platformLayer(); 86 WebLayer* webLayer = graphicsLayer->platformLayer();
86 for (size_t i = 0; i < webLayer->nonFastScrollableRegion().size(); ++i) { 87 for (size_t i = 0; i < webLayer->nonFastScrollableRegion().size(); ++i) {
87 scrollRects->addItem(buildScrollRect(webLayer->nonFastScrollableRegion() [i], TypeBuilder::LayerTree::ScrollRect::Type::RepaintsOnScroll)); 88 scrollRects->addItem(buildScrollRect(webLayer->nonFastScrollableRegion() [i], TypeBuilder::LayerTree::ScrollRect::Type::RepaintsOnScroll));
88 } 89 }
89 for (size_t i = 0; i < webLayer->touchEventHandlerRegion().size(); ++i) { 90 for (size_t i = 0; i < webLayer->touchEventHandlerRegion().size(); ++i) {
90 scrollRects->addItem(buildScrollRect(webLayer->touchEventHandlerRegion() [i], TypeBuilder::LayerTree::ScrollRect::Type::TouchEventHandler)); 91 scrollRects->addItem(buildScrollRect(webLayer->touchEventHandlerRegion() [i], TypeBuilder::LayerTree::ScrollRect::Type::TouchEventHandler));
91 } 92 }
92 if (webLayer->haveWheelEventHandlers()) { 93 if (reportWheelScrollers) {
93 WebRect webRect(webLayer->position().x, webLayer->position().y, webLayer ->bounds().width, webLayer->bounds().height); 94 WebRect webRect(webLayer->position().x, webLayer->position().y, webLayer ->bounds().width, webLayer->bounds().height);
94 scrollRects->addItem(buildScrollRect(webRect, TypeBuilder::LayerTree::Sc rollRect::Type::WheelEventHandler)); 95 scrollRects->addItem(buildScrollRect(webRect, TypeBuilder::LayerTree::Sc rollRect::Type::WheelEventHandler));
95 } 96 }
96 return scrollRects->length() ? scrollRects.release() : nullptr; 97 return scrollRects->length() ? scrollRects.release() : nullptr;
97 } 98 }
98 99
99 static PassRefPtr<TypeBuilder::LayerTree::Layer> buildObjectForLayer(GraphicsLay er* graphicsLayer, int nodeId) 100 static PassRefPtr<TypeBuilder::LayerTree::Layer> buildObjectForLayer(GraphicsLay er* graphicsLayer, int nodeId, bool reportWheelEventListeners)
100 { 101 {
101 WebLayer* webLayer = graphicsLayer->platformLayer(); 102 WebLayer* webLayer = graphicsLayer->platformLayer();
102 RefPtr<TypeBuilder::LayerTree::Layer> layerObject = TypeBuilder::LayerTree:: Layer::create() 103 RefPtr<TypeBuilder::LayerTree::Layer> layerObject = TypeBuilder::LayerTree:: Layer::create()
103 .setLayerId(idForLayer(graphicsLayer)) 104 .setLayerId(idForLayer(graphicsLayer))
104 .setOffsetX(webLayer->position().x) 105 .setOffsetX(webLayer->position().x)
105 .setOffsetY(webLayer->position().y) 106 .setOffsetY(webLayer->position().y)
106 .setWidth(webLayer->bounds().width) 107 .setWidth(webLayer->bounds().width)
107 .setHeight(webLayer->bounds().height) 108 .setHeight(webLayer->bounds().height)
108 .setPaintCount(graphicsLayer->paintCount()) 109 .setPaintCount(graphicsLayer->paintCount())
109 .setDrawsContent(webLayer->drawsContent()); 110 .setDrawsContent(webLayer->drawsContent());
(...skipping 21 matching lines...) Expand all
131 if (webLayer->bounds().width > 0) 132 if (webLayer->bounds().width > 0)
132 layerObject->setAnchorX(transformOrigin.x() / webLayer->bounds().wid th); 133 layerObject->setAnchorX(transformOrigin.x() / webLayer->bounds().wid th);
133 else 134 else
134 layerObject->setAnchorX(0.0); 135 layerObject->setAnchorX(0.0);
135 if (webLayer->bounds().height > 0) 136 if (webLayer->bounds().height > 0)
136 layerObject->setAnchorY(transformOrigin.y() / webLayer->bounds().hei ght); 137 layerObject->setAnchorY(transformOrigin.y() / webLayer->bounds().hei ght);
137 else 138 else
138 layerObject->setAnchorY(0.0); 139 layerObject->setAnchorY(0.0);
139 layerObject->setAnchorZ(transformOrigin.z()); 140 layerObject->setAnchorZ(transformOrigin.z());
140 } 141 }
141 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect> > scrollRects = buildScrollRectsForLayer(graphicsLayer); 142 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>> scrollRects = buildScrollRectsForLayer(graphicsLayer, reportWheelEventListeners);
142 if (scrollRects) 143 if (scrollRects)
143 layerObject->setScrollRects(scrollRects.release()); 144 layerObject->setScrollRects(scrollRects.release());
144 return layerObject; 145 return layerObject;
145 } 146 }
146 147
147 InspectorLayerTreeAgent::InspectorLayerTreeAgent(InspectedFrames* inspectedFrame s) 148 InspectorLayerTreeAgent::InspectorLayerTreeAgent(InspectedFrames* inspectedFrame s)
148 : InspectorBaseAgent<InspectorLayerTreeAgent, InspectorFrontend::LayerTree>( "LayerTree") 149 : InspectorBaseAgent<InspectorLayerTreeAgent, InspectorFrontend::LayerTree>( "LayerTree")
149 , m_inspectedFrames(inspectedFrames) 150 , m_inspectedFrames(inspectedFrames)
150 { 151 {
151 } 152 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 204
204 PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > InspectorLayerTre eAgent::buildLayerTree() 205 PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > InspectorLayerTre eAgent::buildLayerTree()
205 { 206 {
206 PaintLayerCompositor* compositor = paintLayerCompositor(); 207 PaintLayerCompositor* compositor = paintLayerCompositor();
207 if (!compositor || !compositor->inCompositingMode()) 208 if (!compositor || !compositor->inCompositingMode())
208 return nullptr; 209 return nullptr;
209 210
210 LayerIdToNodeIdMap layerIdToNodeIdMap; 211 LayerIdToNodeIdMap layerIdToNodeIdMap;
211 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > layers = TypeBuil der::Array<TypeBuilder::LayerTree::Layer>::create(); 212 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > layers = TypeBuil der::Array<TypeBuilder::LayerTree::Layer>::create();
212 buildLayerIdToNodeIdMap(compositor->rootLayer(), layerIdToNodeIdMap); 213 buildLayerIdToNodeIdMap(compositor->rootLayer(), layerIdToNodeIdMap);
213 gatherGraphicsLayers(rootGraphicsLayer(), layerIdToNodeIdMap, layers); 214 int scrollingLayerId = m_inspectedFrames->root()->view()->layerForScrolling( )->platformLayer()->id();
215 bool haveWheelEventHandlers = m_inspectedFrames->root()->chromeClient().have WheelEventHandlers();
216
217 gatherGraphicsLayers(rootGraphicsLayer(), layerIdToNodeIdMap, layers, haveWh eelEventHandlers, scrollingLayerId);
214 return layers.release(); 218 return layers.release();
215 } 219 }
216 220
217 void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(PaintLayer* root, LayerIdT oNodeIdMap& layerIdToNodeIdMap) 221 void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(PaintLayer* root, LayerIdT oNodeIdMap& layerIdToNodeIdMap)
218 { 222 {
219 if (root->hasCompositedLayerMapping()) { 223 if (root->hasCompositedLayerMapping()) {
220 if (Node* node = root->layoutObject()->generatingNode()) { 224 if (Node* node = root->layoutObject()->generatingNode()) {
221 GraphicsLayer* graphicsLayer = root->compositedLayerMapping()->child ForSuperlayers(); 225 GraphicsLayer* graphicsLayer = root->compositedLayerMapping()->child ForSuperlayers();
222 layerIdToNodeIdMap.set(graphicsLayer->platformLayer()->id(), idForNo de(node)); 226 layerIdToNodeIdMap.set(graphicsLayer->platformLayer()->id(), idForNo de(node));
223 } 227 }
224 } 228 }
225 for (PaintLayer* child = root->firstChild(); child; child = child->nextSibli ng()) 229 for (PaintLayer* child = root->firstChild(); child; child = child->nextSibli ng())
226 buildLayerIdToNodeIdMap(child, layerIdToNodeIdMap); 230 buildLayerIdToNodeIdMap(child, layerIdToNodeIdMap);
227 if (!root->layoutObject()->isLayoutIFrame()) 231 if (!root->layoutObject()->isLayoutIFrame())
228 return; 232 return;
229 FrameView* childFrameView = toFrameView(toLayoutPart(root->layoutObject())-> widget()); 233 FrameView* childFrameView = toFrameView(toLayoutPart(root->layoutObject())-> widget());
230 if (LayoutView* childLayoutView = childFrameView->layoutView()) { 234 if (LayoutView* childLayoutView = childFrameView->layoutView()) {
231 if (PaintLayerCompositor* childCompositor = childLayoutView->compositor( )) 235 if (PaintLayerCompositor* childCompositor = childLayoutView->compositor( ))
232 buildLayerIdToNodeIdMap(childCompositor->rootLayer(), layerIdToNodeI dMap); 236 buildLayerIdToNodeIdMap(childCompositor->rootLayer(), layerIdToNodeI dMap);
233 } 237 }
234 } 238 }
235 239
236 void InspectorLayerTreeAgent::gatherGraphicsLayers(GraphicsLayer* root, HashMap< int, int>& layerIdToNodeIdMap, RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree: :Layer> >& layers) 240 void InspectorLayerTreeAgent::gatherGraphicsLayers(GraphicsLayer* root, HashMap< int, int>& layerIdToNodeIdMap, RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree: :Layer>>& layers, bool hasWheelEventHandlers, int scrollingLayerId)
237 { 241 {
238 int layerId = root->platformLayer()->id(); 242 int layerId = root->platformLayer()->id();
239 if (m_pageOverlayLayerIds.find(layerId) != WTF::kNotFound) 243 if (m_pageOverlayLayerIds.find(layerId) != WTF::kNotFound)
240 return; 244 return;
241 layers->addItem(buildObjectForLayer(root, layerIdToNodeIdMap.get(layerId))); 245 layers->addItem(buildObjectForLayer(root, layerIdToNodeIdMap.get(layerId), h asWheelEventHandlers && layerId == scrollingLayerId));
242 if (GraphicsLayer* replica = root->replicaLayer()) 246 if (GraphicsLayer* replica = root->replicaLayer())
243 gatherGraphicsLayers(replica, layerIdToNodeIdMap, layers); 247 gatherGraphicsLayers(replica, layerIdToNodeIdMap, layers, hasWheelEventH andlers, scrollingLayerId);
244 for (size_t i = 0, size = root->children().size(); i < size; ++i) 248 for (size_t i = 0, size = root->children().size(); i < size; ++i)
245 gatherGraphicsLayers(root->children()[i], layerIdToNodeIdMap, layers); 249 gatherGraphicsLayers(root->children()[i], layerIdToNodeIdMap, layers, ha sWheelEventHandlers, scrollingLayerId);
246 } 250 }
247 251
248 int InspectorLayerTreeAgent::idForNode(Node* node) 252 int InspectorLayerTreeAgent::idForNode(Node* node)
249 { 253 {
250 return DOMNodeIds::idForNode(node); 254 return DOMNodeIds::idForNode(node);
251 } 255 }
252 256
253 PaintLayerCompositor* InspectorLayerTreeAgent::paintLayerCompositor() 257 PaintLayerCompositor* InspectorLayerTreeAgent::paintLayerCompositor()
254 { 258 {
255 LayoutView* layoutView = m_inspectedFrames->root()->contentLayoutObject(); 259 LayoutView* layoutView = m_inspectedFrames->root()->contentLayoutObject();
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer) 467 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer)
464 { 468 {
465 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id()); 469 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id());
466 if (index == WTF::kNotFound) 470 if (index == WTF::kNotFound)
467 return; 471 return;
468 m_pageOverlayLayerIds.remove(index); 472 m_pageOverlayLayerIds.remove(index);
469 } 473 }
470 474
471 475
472 } // namespace blink 476 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698