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 25 matching lines...) Expand all Loading... |
36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
37 #include "core/frame/FrameHost.h" | 37 #include "core/frame/FrameHost.h" |
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/InspectorNodeIds.h" | 41 #include "core/inspector/InspectorNodeIds.h" |
42 #include "core/inspector/InspectorPageAgent.h" | 42 #include "core/inspector/InspectorPageAgent.h" |
43 #include "core/inspector/InspectorState.h" | 43 #include "core/inspector/InspectorState.h" |
44 #include "core/inspector/InstrumentingAgents.h" | 44 #include "core/inspector/InstrumentingAgents.h" |
45 #include "core/layout/compositing/CompositedLayerMapping.h" | 45 #include "core/layout/compositing/CompositedLayerMapping.h" |
46 #include "core/layout/compositing/RenderLayerCompositor.h" | 46 #include "core/layout/compositing/LayerCompositor.h" |
47 #include "core/loader/DocumentLoader.h" | 47 #include "core/loader/DocumentLoader.h" |
48 #include "core/rendering/RenderPart.h" | 48 #include "core/rendering/RenderPart.h" |
49 #include "core/rendering/RenderView.h" | 49 #include "core/rendering/RenderView.h" |
50 #include "platform/geometry/IntRect.h" | 50 #include "platform/geometry/IntRect.h" |
51 #include "platform/graphics/CompositingReasons.h" | 51 #include "platform/graphics/CompositingReasons.h" |
52 #include "platform/graphics/PictureSnapshot.h" | 52 #include "platform/graphics/PictureSnapshot.h" |
53 #include "platform/graphics/paint/DisplayItemList.h" | 53 #include "platform/graphics/paint/DisplayItemList.h" |
54 #include "platform/image-encoders/skia/PNGImageEncoder.h" | 54 #include "platform/image-encoders/skia/PNGImageEncoder.h" |
55 #include "platform/transforms/TransformationMatrix.h" | 55 #include "platform/transforms/TransformationMatrix.h" |
56 #include "public/platform/WebFloatPoint.h" | 56 #include "public/platform/WebFloatPoint.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 RefPtr<TypeBuilder::DOM::Rect> domRect = TypeBuilder::DOM::Rect::create() | 210 RefPtr<TypeBuilder::DOM::Rect> domRect = TypeBuilder::DOM::Rect::create() |
211 .setX(rect.x()) | 211 .setX(rect.x()) |
212 .setY(rect.y()) | 212 .setY(rect.y()) |
213 .setWidth(rect.width()) | 213 .setWidth(rect.width()) |
214 .setHeight(rect.height()); | 214 .setHeight(rect.height()); |
215 m_frontend->layerPainted(idForLayer(graphicsLayer), domRect.release()); | 215 m_frontend->layerPainted(idForLayer(graphicsLayer), domRect.release()); |
216 } | 216 } |
217 | 217 |
218 PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > InspectorLayerTre
eAgent::buildLayerTree() | 218 PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > InspectorLayerTre
eAgent::buildLayerTree() |
219 { | 219 { |
220 RenderLayerCompositor* compositor = renderLayerCompositor(); | 220 LayerCompositor* compositor = renderLayerCompositor(); |
221 if (!compositor || !compositor->inCompositingMode()) | 221 if (!compositor || !compositor->inCompositingMode()) |
222 return nullptr; | 222 return nullptr; |
223 | 223 |
224 LayerIdToNodeIdMap layerIdToNodeIdMap; | 224 LayerIdToNodeIdMap layerIdToNodeIdMap; |
225 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > layers = TypeBuil
der::Array<TypeBuilder::LayerTree::Layer>::create(); | 225 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > layers = TypeBuil
der::Array<TypeBuilder::LayerTree::Layer>::create(); |
226 buildLayerIdToNodeIdMap(compositor->rootRenderLayer(), layerIdToNodeIdMap); | 226 buildLayerIdToNodeIdMap(compositor->rootLayer(), layerIdToNodeIdMap); |
227 gatherGraphicsLayers(rootGraphicsLayer(), layerIdToNodeIdMap, layers); | 227 gatherGraphicsLayers(rootGraphicsLayer(), layerIdToNodeIdMap, layers); |
228 return layers.release(); | 228 return layers.release(); |
229 } | 229 } |
230 | 230 |
231 void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(RenderLayer* root, LayerId
ToNodeIdMap& layerIdToNodeIdMap) | 231 void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(Layer* root, LayerIdToNode
IdMap& layerIdToNodeIdMap) |
232 { | 232 { |
233 if (root->hasCompositedLayerMapping()) { | 233 if (root->hasCompositedLayerMapping()) { |
234 if (Node* node = root->renderer()->generatingNode()) { | 234 if (Node* node = root->renderer()->generatingNode()) { |
235 GraphicsLayer* graphicsLayer = root->compositedLayerMapping()->child
ForSuperlayers(); | 235 GraphicsLayer* graphicsLayer = root->compositedLayerMapping()->child
ForSuperlayers(); |
236 layerIdToNodeIdMap.set(graphicsLayer->platformLayer()->id(), idForNo
de(node)); | 236 layerIdToNodeIdMap.set(graphicsLayer->platformLayer()->id(), idForNo
de(node)); |
237 } | 237 } |
238 } | 238 } |
239 for (RenderLayer* child = root->firstChild(); child; child = child->nextSibl
ing()) | 239 for (Layer* child = root->firstChild(); child; child = child->nextSibling()) |
240 buildLayerIdToNodeIdMap(child, layerIdToNodeIdMap); | 240 buildLayerIdToNodeIdMap(child, layerIdToNodeIdMap); |
241 if (!root->renderer()->isRenderIFrame()) | 241 if (!root->renderer()->isRenderIFrame()) |
242 return; | 242 return; |
243 FrameView* childFrameView = toFrameView(toRenderPart(root->renderer())->widg
et()); | 243 FrameView* childFrameView = toFrameView(toRenderPart(root->renderer())->widg
et()); |
244 if (RenderView* childRenderView = childFrameView->renderView()) { | 244 if (RenderView* childRenderView = childFrameView->renderView()) { |
245 if (RenderLayerCompositor* childCompositor = childRenderView->compositor
()) | 245 if (LayerCompositor* childCompositor = childRenderView->compositor()) |
246 buildLayerIdToNodeIdMap(childCompositor->rootRenderLayer(), layerIdT
oNodeIdMap); | 246 buildLayerIdToNodeIdMap(childCompositor->rootLayer(), layerIdToNodeI
dMap); |
247 } | 247 } |
248 } | 248 } |
249 | 249 |
250 void InspectorLayerTreeAgent::gatherGraphicsLayers(GraphicsLayer* root, HashMap<
int, int>& layerIdToNodeIdMap, RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree:
:Layer> >& layers) | 250 void InspectorLayerTreeAgent::gatherGraphicsLayers(GraphicsLayer* root, HashMap<
int, int>& layerIdToNodeIdMap, RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree:
:Layer> >& layers) |
251 { | 251 { |
252 int layerId = root->platformLayer()->id(); | 252 int layerId = root->platformLayer()->id(); |
253 if (m_pageOverlayLayerIds.find(layerId) != WTF::kNotFound) | 253 if (m_pageOverlayLayerIds.find(layerId) != WTF::kNotFound) |
254 return; | 254 return; |
255 layers->addItem(buildObjectForLayer(root, layerIdToNodeIdMap.get(layerId))); | 255 layers->addItem(buildObjectForLayer(root, layerIdToNodeIdMap.get(layerId))); |
256 if (GraphicsLayer* replica = root->replicaLayer()) | 256 if (GraphicsLayer* replica = root->replicaLayer()) |
257 gatherGraphicsLayers(replica, layerIdToNodeIdMap, layers); | 257 gatherGraphicsLayers(replica, layerIdToNodeIdMap, layers); |
258 for (size_t i = 0, size = root->children().size(); i < size; ++i) | 258 for (size_t i = 0, size = root->children().size(); i < size; ++i) |
259 gatherGraphicsLayers(root->children()[i], layerIdToNodeIdMap, layers); | 259 gatherGraphicsLayers(root->children()[i], layerIdToNodeIdMap, layers); |
260 } | 260 } |
261 | 261 |
262 int InspectorLayerTreeAgent::idForNode(Node* node) | 262 int InspectorLayerTreeAgent::idForNode(Node* node) |
263 { | 263 { |
264 return InspectorNodeIds::idForNode(node); | 264 return InspectorNodeIds::idForNode(node); |
265 } | 265 } |
266 | 266 |
267 RenderLayerCompositor* InspectorLayerTreeAgent::renderLayerCompositor() | 267 LayerCompositor* InspectorLayerTreeAgent::renderLayerCompositor() |
268 { | 268 { |
269 RenderView* renderView = m_pageAgent->inspectedFrame()->contentRenderer(); | 269 RenderView* renderView = m_pageAgent->inspectedFrame()->contentRenderer(); |
270 RenderLayerCompositor* compositor = renderView ? renderView->compositor() :
nullptr; | 270 LayerCompositor* compositor = renderView ? renderView->compositor() : nullpt
r; |
271 return compositor; | 271 return compositor; |
272 } | 272 } |
273 | 273 |
274 GraphicsLayer* InspectorLayerTreeAgent::rootGraphicsLayer() | 274 GraphicsLayer* InspectorLayerTreeAgent::rootGraphicsLayer() |
275 { | 275 { |
276 if (m_pageAgent->frameHost()->settings().pinchVirtualViewportEnabled()) | 276 if (m_pageAgent->frameHost()->settings().pinchVirtualViewportEnabled()) |
277 return m_pageAgent->frameHost()->pinchViewport().rootGraphicsLayer(); | 277 return m_pageAgent->frameHost()->pinchViewport().rootGraphicsLayer(); |
278 | 278 |
279 return renderLayerCompositor()->rootGraphicsLayer(); | 279 return renderLayerCompositor()->rootGraphicsLayer(); |
280 } | 280 } |
(...skipping 14 matching lines...) Expand all Loading... |
295 } | 295 } |
296 | 296 |
297 GraphicsLayer* InspectorLayerTreeAgent::layerById(ErrorString* errorString, cons
t String& layerId) | 297 GraphicsLayer* InspectorLayerTreeAgent::layerById(ErrorString* errorString, cons
t String& layerId) |
298 { | 298 { |
299 bool ok; | 299 bool ok; |
300 int id = layerId.toInt(&ok); | 300 int id = layerId.toInt(&ok); |
301 if (!ok) { | 301 if (!ok) { |
302 *errorString = "Invalid layer id"; | 302 *errorString = "Invalid layer id"; |
303 return nullptr; | 303 return nullptr; |
304 } | 304 } |
305 RenderLayerCompositor* compositor = renderLayerCompositor(); | 305 LayerCompositor* compositor = renderLayerCompositor(); |
306 if (!compositor) { | 306 if (!compositor) { |
307 *errorString = "Not in compositing mode"; | 307 *errorString = "Not in compositing mode"; |
308 return nullptr; | 308 return nullptr; |
309 } | 309 } |
310 | 310 |
311 GraphicsLayer* result = findLayerById(rootGraphicsLayer(), id); | 311 GraphicsLayer* result = findLayerById(rootGraphicsLayer(), id); |
312 if (!result) | 312 if (!result) |
313 *errorString = "No layer matching given id found"; | 313 *errorString = "No layer matching given id found"; |
314 return result; | 314 return result; |
315 } | 315 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer) | 486 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer) |
487 { | 487 { |
488 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id()); | 488 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id()); |
489 if (index == WTF::kNotFound) | 489 if (index == WTF::kNotFound) |
490 return; | 490 return; |
491 m_pageOverlayLayerIds.remove(index); | 491 m_pageOverlayLayerIds.remove(index); |
492 } | 492 } |
493 | 493 |
494 | 494 |
495 } // namespace blink | 495 } // namespace blink |
OLD | NEW |