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

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: Fix tests Created 4 years, 11 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 .setX(rect.x) 72 .setX(rect.x)
73 .setY(rect.y) 73 .setY(rect.y)
74 .setHeight(rect.height) 74 .setHeight(rect.height)
75 .setWidth(rect.width); 75 .setWidth(rect.width);
76 RefPtr<TypeBuilder::LayerTree::ScrollRect> scrollRectObject = TypeBuilder::L ayerTree::ScrollRect::create() 76 RefPtr<TypeBuilder::LayerTree::ScrollRect> scrollRectObject = TypeBuilder::L ayerTree::ScrollRect::create()
77 .setRect(rectObject.release()) 77 .setRect(rectObject.release())
78 .setType(type); 78 .setType(type);
79 return scrollRectObject.release(); 79 return scrollRectObject.release();
80 } 80 }
81 81
82 static PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect> > build ScrollRectsForLayer(GraphicsLayer* graphicsLayer) 82 static PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>> buildS crollRectsForLayer(GraphicsLayer* graphicsLayer, bool reportWheelScrollers)
83 { 83 {
84 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect> > scrollRects = TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>::create(); 84 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect> > scrollRects = TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>::create();
85 WebLayer* webLayer = graphicsLayer->platformLayer(); 85 WebLayer* webLayer = graphicsLayer->platformLayer();
86 for (size_t i = 0; i < webLayer->nonFastScrollableRegion().size(); ++i) { 86 for (size_t i = 0; i < webLayer->nonFastScrollableRegion().size(); ++i) {
87 scrollRects->addItem(buildScrollRect(webLayer->nonFastScrollableRegion() [i], TypeBuilder::LayerTree::ScrollRect::Type::RepaintsOnScroll)); 87 scrollRects->addItem(buildScrollRect(webLayer->nonFastScrollableRegion() [i], TypeBuilder::LayerTree::ScrollRect::Type::RepaintsOnScroll));
88 } 88 }
89 for (size_t i = 0; i < webLayer->touchEventHandlerRegion().size(); ++i) { 89 for (size_t i = 0; i < webLayer->touchEventHandlerRegion().size(); ++i) {
90 scrollRects->addItem(buildScrollRect(webLayer->touchEventHandlerRegion() [i], TypeBuilder::LayerTree::ScrollRect::Type::TouchEventHandler)); 90 scrollRects->addItem(buildScrollRect(webLayer->touchEventHandlerRegion() [i], TypeBuilder::LayerTree::ScrollRect::Type::TouchEventHandler));
91 } 91 }
92 if (webLayer->haveWheelEventHandlers()) { 92 if (reportWheelScrollers && webLayer->haveWheelEventHandlers()) {
93 WebRect webRect(webLayer->position().x, webLayer->position().y, webLayer ->bounds().width, webLayer->bounds().height); 93 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)); 94 scrollRects->addItem(buildScrollRect(webRect, TypeBuilder::LayerTree::Sc rollRect::Type::WheelEventHandler));
95 } 95 }
96 return scrollRects->length() ? scrollRects.release() : nullptr; 96 return scrollRects->length() ? scrollRects.release() : nullptr;
97 } 97 }
98 98
99 static PassRefPtr<TypeBuilder::LayerTree::Layer> buildObjectForLayer(GraphicsLay er* graphicsLayer, int nodeId) 99 static PassRefPtr<TypeBuilder::LayerTree::Layer> buildObjectForLayer(GraphicsLay er* graphicsLayer, int nodeId, int scrollingLayerId)
100 { 100 {
101 WebLayer* webLayer = graphicsLayer->platformLayer(); 101 WebLayer* webLayer = graphicsLayer->platformLayer();
102 RefPtr<TypeBuilder::LayerTree::Layer> layerObject = TypeBuilder::LayerTree:: Layer::create() 102 RefPtr<TypeBuilder::LayerTree::Layer> layerObject = TypeBuilder::LayerTree:: Layer::create()
103 .setLayerId(idForLayer(graphicsLayer)) 103 .setLayerId(idForLayer(graphicsLayer))
104 .setOffsetX(webLayer->position().x) 104 .setOffsetX(webLayer->position().x)
105 .setOffsetY(webLayer->position().y) 105 .setOffsetY(webLayer->position().y)
106 .setWidth(webLayer->bounds().width) 106 .setWidth(webLayer->bounds().width)
107 .setHeight(webLayer->bounds().height) 107 .setHeight(webLayer->bounds().height)
108 .setPaintCount(graphicsLayer->paintCount()) 108 .setPaintCount(graphicsLayer->paintCount())
109 .setDrawsContent(webLayer->drawsContent()); 109 .setDrawsContent(webLayer->drawsContent());
(...skipping 21 matching lines...) Expand all
131 if (webLayer->bounds().width > 0) 131 if (webLayer->bounds().width > 0)
132 layerObject->setAnchorX(transformOrigin.x() / webLayer->bounds().wid th); 132 layerObject->setAnchorX(transformOrigin.x() / webLayer->bounds().wid th);
133 else 133 else
134 layerObject->setAnchorX(0.0); 134 layerObject->setAnchorX(0.0);
135 if (webLayer->bounds().height > 0) 135 if (webLayer->bounds().height > 0)
136 layerObject->setAnchorY(transformOrigin.y() / webLayer->bounds().hei ght); 136 layerObject->setAnchorY(transformOrigin.y() / webLayer->bounds().hei ght);
137 else 137 else
138 layerObject->setAnchorY(0.0); 138 layerObject->setAnchorY(0.0);
139 layerObject->setAnchorZ(transformOrigin.z()); 139 layerObject->setAnchorZ(transformOrigin.z());
140 } 140 }
141 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect> > scrollRects = buildScrollRectsForLayer(graphicsLayer); 141 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>> scrollRects = buildScrollRectsForLayer(graphicsLayer, webLayer->id() == scrollingLayerId);
142 if (scrollRects) 142 if (scrollRects)
143 layerObject->setScrollRects(scrollRects.release()); 143 layerObject->setScrollRects(scrollRects.release());
144 return layerObject; 144 return layerObject;
145 } 145 }
146 146
147 InspectorLayerTreeAgent::InspectorLayerTreeAgent(InspectedFrames* inspectedFrame s) 147 InspectorLayerTreeAgent::InspectorLayerTreeAgent(InspectedFrames* inspectedFrame s)
148 : InspectorBaseAgent<InspectorLayerTreeAgent, InspectorFrontend::LayerTree>( "LayerTree") 148 : InspectorBaseAgent<InspectorLayerTreeAgent, InspectorFrontend::LayerTree>( "LayerTree")
149 , m_inspectedFrames(inspectedFrames) 149 , m_inspectedFrames(inspectedFrames)
150 { 150 {
151 } 151 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > InspectorLayerTre eAgent::buildLayerTree() 204 PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > InspectorLayerTre eAgent::buildLayerTree()
205 { 205 {
206 PaintLayerCompositor* compositor = paintLayerCompositor(); 206 PaintLayerCompositor* compositor = paintLayerCompositor();
207 if (!compositor || !compositor->inCompositingMode()) 207 if (!compositor || !compositor->inCompositingMode())
208 return nullptr; 208 return nullptr;
209 209
210 LayerIdToNodeIdMap layerIdToNodeIdMap; 210 LayerIdToNodeIdMap layerIdToNodeIdMap;
211 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > layers = TypeBuil der::Array<TypeBuilder::LayerTree::Layer>::create(); 211 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > layers = TypeBuil der::Array<TypeBuilder::LayerTree::Layer>::create();
212 buildLayerIdToNodeIdMap(compositor->rootLayer(), layerIdToNodeIdMap); 212 buildLayerIdToNodeIdMap(compositor->rootLayer(), layerIdToNodeIdMap);
213 gatherGraphicsLayers(rootGraphicsLayer(), layerIdToNodeIdMap, layers); 213 int scrollingLayerId = m_inspectedFrames->root()->view()->layerForScrolling( )->platformLayer()->id();
214 gatherGraphicsLayers(rootGraphicsLayer(), layerIdToNodeIdMap, layers, scroll ingLayerId);
214 return layers.release(); 215 return layers.release();
215 } 216 }
216 217
217 void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(PaintLayer* root, LayerIdT oNodeIdMap& layerIdToNodeIdMap) 218 void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(PaintLayer* root, LayerIdT oNodeIdMap& layerIdToNodeIdMap)
218 { 219 {
219 if (root->hasCompositedLayerMapping()) { 220 if (root->hasCompositedLayerMapping()) {
220 if (Node* node = root->layoutObject()->generatingNode()) { 221 if (Node* node = root->layoutObject()->generatingNode()) {
221 GraphicsLayer* graphicsLayer = root->compositedLayerMapping()->child ForSuperlayers(); 222 GraphicsLayer* graphicsLayer = root->compositedLayerMapping()->child ForSuperlayers();
222 layerIdToNodeIdMap.set(graphicsLayer->platformLayer()->id(), idForNo de(node)); 223 layerIdToNodeIdMap.set(graphicsLayer->platformLayer()->id(), idForNo de(node));
223 } 224 }
224 } 225 }
225 for (PaintLayer* child = root->firstChild(); child; child = child->nextSibli ng()) 226 for (PaintLayer* child = root->firstChild(); child; child = child->nextSibli ng())
226 buildLayerIdToNodeIdMap(child, layerIdToNodeIdMap); 227 buildLayerIdToNodeIdMap(child, layerIdToNodeIdMap);
227 if (!root->layoutObject()->isLayoutIFrame()) 228 if (!root->layoutObject()->isLayoutIFrame())
228 return; 229 return;
229 FrameView* childFrameView = toFrameView(toLayoutPart(root->layoutObject())-> widget()); 230 FrameView* childFrameView = toFrameView(toLayoutPart(root->layoutObject())-> widget());
230 if (LayoutView* childLayoutView = childFrameView->layoutView()) { 231 if (LayoutView* childLayoutView = childFrameView->layoutView()) {
231 if (PaintLayerCompositor* childCompositor = childLayoutView->compositor( )) 232 if (PaintLayerCompositor* childCompositor = childLayoutView->compositor( ))
232 buildLayerIdToNodeIdMap(childCompositor->rootLayer(), layerIdToNodeI dMap); 233 buildLayerIdToNodeIdMap(childCompositor->rootLayer(), layerIdToNodeI dMap);
233 } 234 }
234 } 235 }
235 236
236 void InspectorLayerTreeAgent::gatherGraphicsLayers(GraphicsLayer* root, HashMap< int, int>& layerIdToNodeIdMap, RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree: :Layer> >& layers) 237 void InspectorLayerTreeAgent::gatherGraphicsLayers(GraphicsLayer* root, HashMap< int, int>& layerIdToNodeIdMap, RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree: :Layer>>& layers, int scrollingLayerId)
237 { 238 {
238 int layerId = root->platformLayer()->id(); 239 int layerId = root->platformLayer()->id();
239 if (m_pageOverlayLayerIds.find(layerId) != WTF::kNotFound) 240 if (m_pageOverlayLayerIds.find(layerId) != WTF::kNotFound)
240 return; 241 return;
241 layers->addItem(buildObjectForLayer(root, layerIdToNodeIdMap.get(layerId))); 242 layers->addItem(buildObjectForLayer(root, layerIdToNodeIdMap.get(layerId), s crollingLayerId));
242 if (GraphicsLayer* replica = root->replicaLayer()) 243 if (GraphicsLayer* replica = root->replicaLayer())
243 gatherGraphicsLayers(replica, layerIdToNodeIdMap, layers); 244 gatherGraphicsLayers(replica, layerIdToNodeIdMap, layers, scrollingLayer Id);
244 for (size_t i = 0, size = root->children().size(); i < size; ++i) 245 for (size_t i = 0, size = root->children().size(); i < size; ++i)
245 gatherGraphicsLayers(root->children()[i], layerIdToNodeIdMap, layers); 246 gatherGraphicsLayers(root->children()[i], layerIdToNodeIdMap, layers, sc rollingLayerId);
246 } 247 }
247 248
248 int InspectorLayerTreeAgent::idForNode(Node* node) 249 int InspectorLayerTreeAgent::idForNode(Node* node)
249 { 250 {
250 return DOMNodeIds::idForNode(node); 251 return DOMNodeIds::idForNode(node);
251 } 252 }
252 253
253 PaintLayerCompositor* InspectorLayerTreeAgent::paintLayerCompositor() 254 PaintLayerCompositor* InspectorLayerTreeAgent::paintLayerCompositor()
254 { 255 {
255 LayoutView* layoutView = m_inspectedFrames->root()->contentLayoutObject(); 256 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) 464 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer)
464 { 465 {
465 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id()); 466 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id());
466 if (index == WTF::kNotFound) 467 if (index == WTF::kNotFound)
467 return; 468 return;
468 m_pageOverlayLayerIds.remove(index); 469 m_pageOverlayLayerIds.remove(index);
469 } 470 }
470 471
471 472
472 } // namespace blink 473 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698