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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 transformArray->addItem(flattenedMatrix[i]); | 103 transformArray->addItem(flattenedMatrix[i]); |
104 layerObject->setTransform(transformArray); | 104 layerObject->setTransform(transformArray); |
105 const FloatPoint3D& anchor = graphicsLayer->anchorPoint(); | 105 const FloatPoint3D& anchor = graphicsLayer->anchorPoint(); |
106 layerObject->setAnchorX(anchor.x()); | 106 layerObject->setAnchorX(anchor.x()); |
107 layerObject->setAnchorY(anchor.y()); | 107 layerObject->setAnchorY(anchor.y()); |
108 layerObject->setAnchorZ(anchor.z()); | 108 layerObject->setAnchorZ(anchor.z()); |
109 } | 109 } |
110 return layerObject; | 110 return layerObject; |
111 } | 111 } |
112 | 112 |
113 static void addRegionObjects(const blink::WebVector<blink::WebRect>& regions, | |
114 TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>& scrollRects, | |
115 const TypeBuilder::LayerTree::ScrollRect::Type::Enum& type, | |
116 const TypeBuilder::LayerTree::LayerId& layerId) | |
117 { | |
118 for (size_t i = 0; i < regions.size(); ++i) { | |
119 RefPtr<TypeBuilder::LayerTree::ScrollRect> regionObject = TypeBuilder::L ayerTree::ScrollRect::create() | |
120 .setLayerId(layerId) | |
121 .setX(regions[i].x) | |
122 .setY(regions[i].y) | |
123 .setHeight(regions[i].height) | |
124 .setWidth(regions[i].width) | |
125 .setType(type); | |
126 scrollRects.addItem(regionObject); | |
127 } | |
128 } | |
129 | |
130 static void addScrollRectsForLayer(GraphicsLayer* graphicsLayer, | |
131 TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>& scrollRects) | |
132 { | |
133 blink::WebLayer* webLayer = graphicsLayer->platformLayer(); | |
134 addRegionObjects(webLayer->nonFastScrollableRegion(), | |
caseq
2014/02/26 11:21:10
nit: you don't have to wrap this call, we don't ha
malch
2014/02/26 11:43:36
Done.
| |
135 scrollRects, | |
136 TypeBuilder::LayerTree::ScrollRect::Type::RepaintsOnScroll, | |
137 idForLayer(graphicsLayer)); | |
138 addRegionObjects(webLayer->touchEventHandlerRegion(), | |
caseq
2014/02/26 11:21:10
ditto.
malch
2014/02/26 11:43:36
Done.
| |
139 scrollRects, | |
140 TypeBuilder::LayerTree::ScrollRect::Type::TouchEventHandler, | |
141 idForLayer(graphicsLayer)); | |
142 if (webLayer->haveWheelEventHandlers()) { | |
143 RefPtr<TypeBuilder::LayerTree::ScrollRect> regionObject = TypeBuilder::L ayerTree::ScrollRect::create() | |
144 .setLayerId(idForLayer(graphicsLayer)) | |
145 .setX(webLayer->position().x) | |
146 .setY(webLayer->position().y) | |
147 .setHeight(webLayer->bounds().height) | |
148 .setWidth(webLayer->bounds().width) | |
149 .setType(TypeBuilder::LayerTree::ScrollRect::Type::WheelEventHandler ); | |
150 scrollRects.addItem(regionObject); | |
151 } | |
152 } | |
153 | |
113 InspectorLayerTreeAgent::InspectorLayerTreeAgent(InspectorDOMAgent* domAgent, Pa ge* page) | 154 InspectorLayerTreeAgent::InspectorLayerTreeAgent(InspectorDOMAgent* domAgent, Pa ge* page) |
114 : InspectorBaseAgent<InspectorLayerTreeAgent>("LayerTree") | 155 : InspectorBaseAgent<InspectorLayerTreeAgent>("LayerTree") |
115 , m_frontend(0) | 156 , m_frontend(0) |
116 , m_page(page) | 157 , m_page(page) |
117 , m_domAgent(domAgent) | 158 , m_domAgent(domAgent) |
118 { | 159 { |
119 } | 160 } |
120 | 161 |
121 InspectorLayerTreeAgent::~InspectorLayerTreeAgent() | 162 InspectorLayerTreeAgent::~InspectorLayerTreeAgent() |
122 { | 163 { |
(...skipping 24 matching lines...) Expand all Loading... | |
147 } | 188 } |
148 | 189 |
149 void InspectorLayerTreeAgent::disable(ErrorString*) | 190 void InspectorLayerTreeAgent::disable(ErrorString*) |
150 { | 191 { |
151 m_instrumentingAgents->setInspectorLayerTreeAgent(0); | 192 m_instrumentingAgents->setInspectorLayerTreeAgent(0); |
152 m_snapshotById.clear(); | 193 m_snapshotById.clear(); |
153 } | 194 } |
154 | 195 |
155 void InspectorLayerTreeAgent::layerTreeDidChange() | 196 void InspectorLayerTreeAgent::layerTreeDidChange() |
156 { | 197 { |
157 m_frontend->layerTreeDidChange(buildLayerTree()); | 198 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > layers = TypeBuil der::Array<TypeBuilder::LayerTree::Layer>::create(); |
199 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect> > scrollRects = TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>::create(); | |
200 if (buildLayerTree(*layers, *scrollRects)) | |
201 m_frontend->layerTreeDidChange(layers, scrollRects); | |
202 else | |
203 m_frontend->layerTreeDidChange(nullptr, nullptr); | |
158 } | 204 } |
159 | 205 |
160 void InspectorLayerTreeAgent::didPaint(RenderObject*, const GraphicsLayer* graph icsLayer, GraphicsContext*, const LayoutRect& rect) | 206 void InspectorLayerTreeAgent::didPaint(RenderObject*, const GraphicsLayer* graph icsLayer, GraphicsContext*, const LayoutRect& rect) |
161 { | 207 { |
162 // Should only happen for FrameView paints when compositing is off. Consider different instrumentation method for that. | 208 // Should only happen for FrameView paints when compositing is off. Consider different instrumentation method for that. |
163 if (!graphicsLayer) | 209 if (!graphicsLayer) |
164 return; | 210 return; |
165 | 211 |
166 RefPtr<TypeBuilder::DOM::Rect> domRect = TypeBuilder::DOM::Rect::create() | 212 RefPtr<TypeBuilder::DOM::Rect> domRect = TypeBuilder::DOM::Rect::create() |
167 .setX(rect.x()) | 213 .setX(rect.x()) |
168 .setY(rect.y()) | 214 .setY(rect.y()) |
169 .setWidth(rect.width()) | 215 .setWidth(rect.width()) |
170 .setHeight(rect.height()); | 216 .setHeight(rect.height()); |
171 m_frontend->layerPainted(idForLayer(graphicsLayer), domRect.release()); | 217 m_frontend->layerPainted(idForLayer(graphicsLayer), domRect.release()); |
172 } | 218 } |
173 | 219 |
174 PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > InspectorLayerTre eAgent::buildLayerTree() | 220 bool InspectorLayerTreeAgent::buildLayerTree(TypeBuilder::Array<TypeBuilder::Lay erTree::Layer>& layers, |
221 TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>& scrollRects) | |
175 { | 222 { |
176 RenderLayerCompositor* compositor = renderLayerCompositor(); | 223 RenderLayerCompositor* compositor = renderLayerCompositor(); |
177 if (!compositor || !compositor->inCompositingMode()) | 224 if (!compositor || !compositor->inCompositingMode()) |
178 return nullptr; | 225 return false; |
179 LayerIdToNodeIdMap layerIdToNodeIdMap; | 226 LayerIdToNodeIdMap layerIdToNodeIdMap; |
180 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > layers = TypeBuil der::Array<TypeBuilder::LayerTree::Layer>::create(); | |
181 buildLayerIdToNodeIdMap(compositor->rootRenderLayer(), layerIdToNodeIdMap); | 227 buildLayerIdToNodeIdMap(compositor->rootRenderLayer(), layerIdToNodeIdMap); |
182 gatherGraphicsLayers(compositor->rootGraphicsLayer(), layerIdToNodeIdMap, la yers); | 228 gatherGraphicsLayers(compositor->rootGraphicsLayer(), layerIdToNodeIdMap, la yers, scrollRects); |
183 return layers.release(); | 229 return true; |
184 } | 230 } |
185 | 231 |
186 void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(RenderLayer* root, LayerId ToNodeIdMap& layerIdToNodeIdMap) | 232 void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(RenderLayer* root, LayerId ToNodeIdMap& layerIdToNodeIdMap) |
187 { | 233 { |
188 if (root->hasCompositedLayerMapping()) { | 234 if (root->hasCompositedLayerMapping()) { |
189 if (Node* node = root->renderer()->generatingNode()) { | 235 if (Node* node = root->renderer()->generatingNode()) { |
190 GraphicsLayer* graphicsLayer = root->compositedLayerMapping()->child ForSuperlayers(); | 236 GraphicsLayer* graphicsLayer = root->compositedLayerMapping()->child ForSuperlayers(); |
191 layerIdToNodeIdMap.set(graphicsLayer->platformLayer()->id(), idForNo de(node)); | 237 layerIdToNodeIdMap.set(graphicsLayer->platformLayer()->id(), idForNo de(node)); |
192 } | 238 } |
193 } | 239 } |
194 for (RenderLayer* child = root->firstChild(); child; child = child->nextSibl ing()) | 240 for (RenderLayer* child = root->firstChild(); child; child = child->nextSibl ing()) |
195 buildLayerIdToNodeIdMap(child, layerIdToNodeIdMap); | 241 buildLayerIdToNodeIdMap(child, layerIdToNodeIdMap); |
196 if (!root->renderer()->isRenderIFrame()) | 242 if (!root->renderer()->isRenderIFrame()) |
197 return; | 243 return; |
198 FrameView* childFrameView = toFrameView(toRenderWidget(root->renderer())->wi dget()); | 244 FrameView* childFrameView = toFrameView(toRenderWidget(root->renderer())->wi dget()); |
199 if (RenderView* childRenderView = childFrameView->renderView()) { | 245 if (RenderView* childRenderView = childFrameView->renderView()) { |
200 if (RenderLayerCompositor* childCompositor = childRenderView->compositor ()) | 246 if (RenderLayerCompositor* childCompositor = childRenderView->compositor ()) |
201 buildLayerIdToNodeIdMap(childCompositor->rootRenderLayer(), layerIdT oNodeIdMap); | 247 buildLayerIdToNodeIdMap(childCompositor->rootRenderLayer(), layerIdT oNodeIdMap); |
202 } | 248 } |
203 } | 249 } |
204 | 250 |
205 void InspectorLayerTreeAgent::gatherGraphicsLayers(GraphicsLayer* root, HashMap< int, int>& layerIdToNodeIdMap, RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree: :Layer> >& layers) | 251 void InspectorLayerTreeAgent::gatherGraphicsLayers(GraphicsLayer* root, HashMap< int, int>& layerIdToNodeIdMap, |
252 TypeBuilder::Array<TypeBuilder::LayerTree::Layer>& layers, TypeBuilder::Arra y<TypeBuilder::LayerTree::ScrollRect>& scrollRects) | |
206 { | 253 { |
207 int layerId = root->platformLayer()->id(); | 254 int layerId = root->platformLayer()->id(); |
208 if (m_pageOverlayLayerIds.find(layerId) != WTF::kNotFound) | 255 if (m_pageOverlayLayerIds.find(layerId) != WTF::kNotFound) |
209 return; | 256 return; |
210 layers->addItem(buildObjectForLayer(root, layerIdToNodeIdMap.get(layerId))); | 257 layers.addItem(buildObjectForLayer(root, layerIdToNodeIdMap.get(layerId))); |
258 addScrollRectsForLayer(root, scrollRects); | |
211 if (GraphicsLayer* replica = root->replicaLayer()) | 259 if (GraphicsLayer* replica = root->replicaLayer()) |
212 gatherGraphicsLayers(replica, layerIdToNodeIdMap, layers); | 260 gatherGraphicsLayers(replica, layerIdToNodeIdMap, layers, scrollRects); |
213 for (size_t i = 0, size = root->children().size(); i < size; ++i) | 261 for (size_t i = 0, size = root->children().size(); i < size; ++i) |
214 gatherGraphicsLayers(root->children()[i], layerIdToNodeIdMap, layers); | 262 gatherGraphicsLayers(root->children()[i], layerIdToNodeIdMap, layers, sc rollRects); |
215 } | 263 } |
216 | 264 |
217 int InspectorLayerTreeAgent::idForNode(Node* node) | 265 int InspectorLayerTreeAgent::idForNode(Node* node) |
218 { | 266 { |
219 int nodeId = m_domAgent->boundNodeId(node); | 267 int nodeId = m_domAgent->boundNodeId(node); |
220 if (!nodeId) { | 268 if (!nodeId) { |
221 ErrorString ignoredError; | 269 ErrorString ignoredError; |
222 nodeId = m_domAgent->pushNodeToFrontend(&ignoredError, m_domAgent->bound NodeId(&node->document()), node); | 270 nodeId = m_domAgent->pushNodeToFrontend(&ignoredError, m_domAgent->bound NodeId(&node->document()), node); |
223 } | 271 } |
224 return nodeId; | 272 return nodeId; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer) | 442 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer) |
395 { | 443 { |
396 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id()); | 444 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id()); |
397 if (index == WTF::kNotFound) | 445 if (index == WTF::kNotFound) |
398 return; | 446 return; |
399 m_pageOverlayLayerIds.remove(index); | 447 m_pageOverlayLayerIds.remove(index); |
400 } | 448 } |
401 | 449 |
402 | 450 |
403 } // namespace WebCore | 451 } // namespace WebCore |
OLD | NEW |