OLD | NEW |
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 16 matching lines...) Expand all Loading... |
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 #include "config.h" | 32 #include "config.h" |
33 | 33 |
34 #include "core/inspector/InspectorLayerTreeAgent.h" | 34 #include "core/inspector/InspectorLayerTreeAgent.h" |
35 | 35 |
36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/frame/FrameHost.h" |
37 #include "core/frame/LocalFrame.h" | 38 #include "core/frame/LocalFrame.h" |
| 39 #include "core/frame/Settings.h" |
38 #include "core/inspector/IdentifiersFactory.h" | 40 #include "core/inspector/IdentifiersFactory.h" |
39 #include "core/inspector/InspectorNodeIds.h" | 41 #include "core/inspector/InspectorNodeIds.h" |
40 #include "core/inspector/InspectorState.h" | 42 #include "core/inspector/InspectorState.h" |
41 #include "core/inspector/InstrumentingAgents.h" | 43 #include "core/inspector/InstrumentingAgents.h" |
42 #include "core/loader/DocumentLoader.h" | 44 #include "core/loader/DocumentLoader.h" |
43 #include "core/page/Page.h" | 45 #include "core/page/Page.h" |
44 #include "core/rendering/RenderPart.h" | 46 #include "core/rendering/RenderPart.h" |
45 #include "core/rendering/RenderView.h" | 47 #include "core/rendering/RenderView.h" |
46 #include "core/rendering/compositing/CompositedLayerMapping.h" | 48 #include "core/rendering/compositing/CompositedLayerMapping.h" |
47 #include "core/rendering/compositing/RenderLayerCompositor.h" | 49 #include "core/rendering/compositing/RenderLayerCompositor.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 216 |
215 PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > InspectorLayerTre
eAgent::buildLayerTree() | 217 PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > InspectorLayerTre
eAgent::buildLayerTree() |
216 { | 218 { |
217 RenderLayerCompositor* compositor = renderLayerCompositor(); | 219 RenderLayerCompositor* compositor = renderLayerCompositor(); |
218 if (!compositor || !compositor->inCompositingMode()) | 220 if (!compositor || !compositor->inCompositingMode()) |
219 return nullptr; | 221 return nullptr; |
220 | 222 |
221 LayerIdToNodeIdMap layerIdToNodeIdMap; | 223 LayerIdToNodeIdMap layerIdToNodeIdMap; |
222 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > layers = TypeBuil
der::Array<TypeBuilder::LayerTree::Layer>::create(); | 224 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > layers = TypeBuil
der::Array<TypeBuilder::LayerTree::Layer>::create(); |
223 buildLayerIdToNodeIdMap(compositor->rootRenderLayer(), layerIdToNodeIdMap); | 225 buildLayerIdToNodeIdMap(compositor->rootRenderLayer(), layerIdToNodeIdMap); |
224 gatherGraphicsLayers(compositor->rootGraphicsLayer(), layerIdToNodeIdMap, la
yers); | 226 gatherGraphicsLayers(rootGraphicsLayer(), layerIdToNodeIdMap, layers); |
225 return layers.release(); | 227 return layers.release(); |
226 } | 228 } |
227 | 229 |
228 void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(RenderLayer* root, LayerId
ToNodeIdMap& layerIdToNodeIdMap) | 230 void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(RenderLayer* root, LayerId
ToNodeIdMap& layerIdToNodeIdMap) |
229 { | 231 { |
230 if (root->hasCompositedLayerMapping()) { | 232 if (root->hasCompositedLayerMapping()) { |
231 if (Node* node = root->renderer()->generatingNode()) { | 233 if (Node* node = root->renderer()->generatingNode()) { |
232 GraphicsLayer* graphicsLayer = root->compositedLayerMapping()->child
ForSuperlayers(); | 234 GraphicsLayer* graphicsLayer = root->compositedLayerMapping()->child
ForSuperlayers(); |
233 layerIdToNodeIdMap.set(graphicsLayer->platformLayer()->id(), idForNo
de(node)); | 235 layerIdToNodeIdMap.set(graphicsLayer->platformLayer()->id(), idForNo
de(node)); |
234 } | 236 } |
(...skipping 26 matching lines...) Expand all Loading... |
261 return InspectorNodeIds::idForNode(node); | 263 return InspectorNodeIds::idForNode(node); |
262 } | 264 } |
263 | 265 |
264 RenderLayerCompositor* InspectorLayerTreeAgent::renderLayerCompositor() | 266 RenderLayerCompositor* InspectorLayerTreeAgent::renderLayerCompositor() |
265 { | 267 { |
266 RenderView* renderView = m_page->deprecatedLocalMainFrame()->contentRenderer
(); | 268 RenderView* renderView = m_page->deprecatedLocalMainFrame()->contentRenderer
(); |
267 RenderLayerCompositor* compositor = renderView ? renderView->compositor() :
0; | 269 RenderLayerCompositor* compositor = renderView ? renderView->compositor() :
0; |
268 return compositor; | 270 return compositor; |
269 } | 271 } |
270 | 272 |
| 273 GraphicsLayer* InspectorLayerTreeAgent::rootGraphicsLayer() |
| 274 { |
| 275 if (m_page->settings().pinchVirtualViewportEnabled()) |
| 276 return m_page->frameHost().pinchViewport().rootGraphicsLayer(); |
| 277 |
| 278 return renderLayerCompositor()->rootGraphicsLayer(); |
| 279 } |
| 280 |
271 static GraphicsLayer* findLayerById(GraphicsLayer* root, int layerId) | 281 static GraphicsLayer* findLayerById(GraphicsLayer* root, int layerId) |
272 { | 282 { |
273 if (root->platformLayer()->id() == layerId) | 283 if (root->platformLayer()->id() == layerId) |
274 return root; | 284 return root; |
275 if (root->replicaLayer()) { | 285 if (root->replicaLayer()) { |
276 if (GraphicsLayer* layer = findLayerById(root->replicaLayer(), layerId)) | 286 if (GraphicsLayer* layer = findLayerById(root->replicaLayer(), layerId)) |
277 return layer; | 287 return layer; |
278 } | 288 } |
279 for (size_t i = 0, size = root->children().size(); i < size; ++i) { | 289 for (size_t i = 0, size = root->children().size(); i < size; ++i) { |
280 if (GraphicsLayer* layer = findLayerById(root->children()[i], layerId)) | 290 if (GraphicsLayer* layer = findLayerById(root->children()[i], layerId)) |
281 return layer; | 291 return layer; |
282 } | 292 } |
283 return 0; | 293 return 0; |
284 } | 294 } |
285 | 295 |
286 GraphicsLayer* InspectorLayerTreeAgent::layerById(ErrorString* errorString, cons
t String& layerId) | 296 GraphicsLayer* InspectorLayerTreeAgent::layerById(ErrorString* errorString, cons
t String& layerId) |
287 { | 297 { |
288 bool ok; | 298 bool ok; |
289 int id = layerId.toInt(&ok); | 299 int id = layerId.toInt(&ok); |
290 if (!ok) { | 300 if (!ok) { |
291 *errorString = "Invalid layer id"; | 301 *errorString = "Invalid layer id"; |
292 return 0; | 302 return 0; |
293 } | 303 } |
294 RenderLayerCompositor* compositor = renderLayerCompositor(); | 304 RenderLayerCompositor* compositor = renderLayerCompositor(); |
295 if (!compositor) { | 305 if (!compositor) { |
296 *errorString = "Not in compositing mode"; | 306 *errorString = "Not in compositing mode"; |
297 return 0; | 307 return 0; |
298 } | 308 } |
299 | 309 |
300 GraphicsLayer* result = findLayerById(compositor->rootGraphicsLayer(), id); | 310 GraphicsLayer* result = findLayerById(rootGraphicsLayer(), id); |
301 if (!result) | 311 if (!result) |
302 *errorString = "No layer matching given id found"; | 312 *errorString = "No layer matching given id found"; |
303 return result; | 313 return result; |
304 } | 314 } |
305 | 315 |
306 void InspectorLayerTreeAgent::compositingReasons(ErrorString* errorString, const
String& layerId, RefPtr<TypeBuilder::Array<String> >& reasonStrings) | 316 void InspectorLayerTreeAgent::compositingReasons(ErrorString* errorString, const
String& layerId, RefPtr<TypeBuilder::Array<String> >& reasonStrings) |
307 { | 317 { |
308 const GraphicsLayer* graphicsLayer = layerById(errorString, layerId); | 318 const GraphicsLayer* graphicsLayer = layerById(errorString, layerId); |
309 if (!graphicsLayer) | 319 if (!graphicsLayer) |
310 return; | 320 return; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer) | 433 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer) |
424 { | 434 { |
425 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id()); | 435 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id()); |
426 if (index == WTF::kNotFound) | 436 if (index == WTF::kNotFound) |
427 return; | 437 return; |
428 m_pageOverlayLayerIds.remove(index); | 438 m_pageOverlayLayerIds.remove(index); |
429 } | 439 } |
430 | 440 |
431 | 441 |
432 } // namespace blink | 442 } // namespace blink |
OLD | NEW |