OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 { | 103 { |
104 ShapePathBuilder builder(view, renderer, shapeOutsideInfo); | 104 ShapePathBuilder builder(view, renderer, shapeOutsideInfo); |
105 builder.appendPath(path); | 105 builder.appendPath(path); |
106 return builder.path(); | 106 return builder.path(); |
107 } | 107 } |
108 | 108 |
109 protected: | 109 protected: |
110 virtual FloatPoint translatePoint(const FloatPoint& point) | 110 virtual FloatPoint translatePoint(const FloatPoint& point) |
111 { | 111 { |
112 FloatPoint rendererPoint = m_shapeOutsideInfo.shapeToRendererPoint(point
); | 112 FloatPoint rendererPoint = m_shapeOutsideInfo.shapeToRendererPoint(point
); |
113 return m_view.contentsToRootView(roundedIntPoint(m_renderer.localToAbsol
ute(rendererPoint))); | 113 return m_view.contentsToRootFrame(roundedIntPoint(m_renderer.localToAbso
lute(rendererPoint))); |
114 } | 114 } |
115 | 115 |
116 private: | 116 private: |
117 FrameView& m_view; | 117 FrameView& m_view; |
118 LayoutObject& m_renderer; | 118 LayoutObject& m_renderer; |
119 const ShapeOutsideInfo& m_shapeOutsideInfo; | 119 const ShapeOutsideInfo& m_shapeOutsideInfo; |
120 }; | 120 }; |
121 | 121 |
122 class InspectorOverlayChromeClient final: public EmptyChromeClient { | 122 class InspectorOverlayChromeClient final: public EmptyChromeClient { |
123 public: | 123 public: |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 return object.release(); | 229 return object.release(); |
230 } | 230 } |
231 | 231 |
232 private: | 232 private: |
233 bool m_showRulers; | 233 bool m_showRulers; |
234 bool m_showExtensionLines; | 234 bool m_showExtensionLines; |
235 RefPtr<JSONObject> m_elementInfo; | 235 RefPtr<JSONObject> m_elementInfo; |
236 RefPtr<JSONArray> m_highlightPaths; | 236 RefPtr<JSONArray> m_highlightPaths; |
237 }; | 237 }; |
238 | 238 |
239 static void contentsQuadToScreen(const FrameView* view, FloatQuad& quad) | 239 static void contentsQuadToRootFrame(const FrameView* view, FloatQuad& quad) |
240 { | 240 { |
241 quad.setP1(view->contentsToRootView(roundedIntPoint(quad.p1()))); | 241 quad.setP1(view->contentsToRootFrame(roundedIntPoint(quad.p1()))); |
242 quad.setP2(view->contentsToRootView(roundedIntPoint(quad.p2()))); | 242 quad.setP2(view->contentsToRootFrame(roundedIntPoint(quad.p2()))); |
243 quad.setP3(view->contentsToRootView(roundedIntPoint(quad.p3()))); | 243 quad.setP3(view->contentsToRootFrame(roundedIntPoint(quad.p3()))); |
244 quad.setP4(view->contentsToRootView(roundedIntPoint(quad.p4()))); | 244 quad.setP4(view->contentsToRootFrame(roundedIntPoint(quad.p4()))); |
245 } | 245 } |
246 | 246 |
247 static bool buildNodeQuads(LayoutObject* renderer, FloatQuad* content, FloatQuad
* padding, FloatQuad* border, FloatQuad* margin) | 247 static bool buildNodeQuads(LayoutObject* renderer, FloatQuad* content, FloatQuad
* padding, FloatQuad* border, FloatQuad* margin) |
248 { | 248 { |
249 FrameView* containingView = renderer->frameView(); | 249 FrameView* containingView = renderer->frameView(); |
250 if (!containingView) | 250 if (!containingView) |
251 return false; | 251 return false; |
252 if (!renderer->isBox() && !renderer->isRenderInline()) | 252 if (!renderer->isBox() && !renderer->isRenderInline()) |
253 return false; | 253 return false; |
254 | 254 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 // Ignore marginTop and marginBottom for inlines. | 287 // Ignore marginTop and marginBottom for inlines. |
288 marginBox = LayoutRect(borderBox.x() - renderInline->marginLeft(), borde
rBox.y(), | 288 marginBox = LayoutRect(borderBox.x() - renderInline->marginLeft(), borde
rBox.y(), |
289 borderBox.width() + renderInline->marginWidth(), borderBox.height())
; | 289 borderBox.width() + renderInline->marginWidth(), borderBox.height())
; |
290 } | 290 } |
291 | 291 |
292 *content = renderer->localToAbsoluteQuad(FloatRect(contentBox)); | 292 *content = renderer->localToAbsoluteQuad(FloatRect(contentBox)); |
293 *padding = renderer->localToAbsoluteQuad(FloatRect(paddingBox)); | 293 *padding = renderer->localToAbsoluteQuad(FloatRect(paddingBox)); |
294 *border = renderer->localToAbsoluteQuad(FloatRect(borderBox)); | 294 *border = renderer->localToAbsoluteQuad(FloatRect(borderBox)); |
295 *margin = renderer->localToAbsoluteQuad(FloatRect(marginBox)); | 295 *margin = renderer->localToAbsoluteQuad(FloatRect(marginBox)); |
296 | 296 |
297 contentsQuadToScreen(containingView, *content); | 297 contentsQuadToRootFrame(containingView, *content); |
298 contentsQuadToScreen(containingView, *padding); | 298 contentsQuadToRootFrame(containingView, *padding); |
299 contentsQuadToScreen(containingView, *border); | 299 contentsQuadToRootFrame(containingView, *border); |
300 contentsQuadToScreen(containingView, *margin); | 300 contentsQuadToRootFrame(containingView, *margin); |
301 | 301 |
302 return true; | 302 return true; |
303 } | 303 } |
304 | 304 |
305 static void buildNodeHighlight(Node& node, const HighlightConfig& highlightConfi
g, Highlight* highlight) | 305 static void buildNodeHighlight(Node& node, const HighlightConfig& highlightConfi
g, Highlight* highlight) |
306 { | 306 { |
307 LayoutObject* renderer = node.renderer(); | 307 LayoutObject* renderer = node.renderer(); |
308 if (!renderer) | 308 if (!renderer) |
309 return; | 309 return; |
310 | 310 |
311 highlight->setDataFromConfig(highlightConfig); | 311 highlight->setDataFromConfig(highlightConfig); |
312 | 312 |
313 // LayoutSVGRoot should be highlighted through the isBox() code path, all ot
her SVG elements should just dump their absoluteQuads(). | 313 // LayoutSVGRoot should be highlighted through the isBox() code path, all ot
her SVG elements should just dump their absoluteQuads(). |
314 if (renderer->node() && renderer->node()->isSVGElement() && !renderer->isSVG
Root()) { | 314 if (renderer->node() && renderer->node()->isSVGElement() && !renderer->isSVG
Root()) { |
315 Vector<FloatQuad> quads; | 315 Vector<FloatQuad> quads; |
316 renderer->absoluteQuads(quads); | 316 renderer->absoluteQuads(quads); |
317 FrameView* containingView = renderer->frameView(); | 317 FrameView* containingView = renderer->frameView(); |
318 for (size_t i = 0; i < quads.size(); ++i) { | 318 for (size_t i = 0; i < quads.size(); ++i) { |
319 if (containingView) | 319 if (containingView) |
320 contentsQuadToScreen(containingView, quads[i]); | 320 contentsQuadToRootFrame(containingView, quads[i]); |
321 highlight->appendQuad(quads[i], highlightConfig.content, highlightCo
nfig.contentOutline); | 321 highlight->appendQuad(quads[i], highlightConfig.content, highlightCo
nfig.contentOutline); |
322 } | 322 } |
323 return; | 323 return; |
324 } | 324 } |
325 | 325 |
326 FloatQuad content, padding, border, margin; | 326 FloatQuad content, padding, border, margin; |
327 if (!buildNodeQuads(renderer, &content, &padding, &border, &margin)) | 327 if (!buildNodeQuads(renderer, &content, &padding, &border, &margin)) |
328 return; | 328 return; |
329 highlight->appendQuad(content, highlightConfig.content, highlightConfig.cont
entOutline); | 329 highlight->appendQuad(content, highlightConfig.content, highlightConfig.cont
entOutline); |
330 highlight->appendQuad(padding, highlightConfig.padding); | 330 highlight->appendQuad(padding, highlightConfig.padding); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 return nullptr; | 597 return nullptr; |
598 | 598 |
599 FrameView* containingView = node->document().view(); | 599 FrameView* containingView = node->document().view(); |
600 RenderBox* renderBox = toRenderBox(renderer); | 600 RenderBox* renderBox = toRenderBox(renderer); |
601 const ShapeOutsideInfo* shapeOutsideInfo = renderBox->shapeOutsideInfo(); | 601 const ShapeOutsideInfo* shapeOutsideInfo = renderBox->shapeOutsideInfo(); |
602 | 602 |
603 shapeOutsideInfo->computedShape().buildDisplayPaths(*paths); | 603 shapeOutsideInfo->computedShape().buildDisplayPaths(*paths); |
604 | 604 |
605 LayoutRect shapeBounds = shapeOutsideInfo->computedShapePhysicalBoundingBox(
); | 605 LayoutRect shapeBounds = shapeOutsideInfo->computedShapePhysicalBoundingBox(
); |
606 *bounds = renderBox->localToAbsoluteQuad(FloatRect(shapeBounds)); | 606 *bounds = renderBox->localToAbsoluteQuad(FloatRect(shapeBounds)); |
607 contentsQuadToScreen(containingView, *bounds); | 607 contentsQuadToRootFrame(containingView, *bounds); |
608 | 608 |
609 return shapeOutsideInfo; | 609 return shapeOutsideInfo; |
610 } | 610 } |
611 | 611 |
612 static void appendPathsForShapeOutside(Highlight& highlight, const HighlightConf
ig& config, Node* node) | 612 static void appendPathsForShapeOutside(Highlight& highlight, const HighlightConf
ig& config, Node* node) |
613 { | 613 { |
614 Shape::DisplayPaths paths; | 614 Shape::DisplayPaths paths; |
615 FloatQuad boundsQuad; | 615 FloatQuad boundsQuad; |
616 | 616 |
617 const ShapeOutsideInfo* shapeOutsideInfo = shapeOutsideInfoForNode(node, &pa
ths, &boundsQuad); | 617 const ShapeOutsideInfo* shapeOutsideInfo = shapeOutsideInfoForNode(node, &pa
ths, &boundsQuad); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 { | 822 { |
823 LayoutObject* renderer = node->renderer(); | 823 LayoutObject* renderer = node->renderer(); |
824 FrameView* view = node->document().view(); | 824 FrameView* view = node->document().view(); |
825 if (!renderer || !view) | 825 if (!renderer || !view) |
826 return false; | 826 return false; |
827 | 827 |
828 FloatQuad content, padding, border, margin; | 828 FloatQuad content, padding, border, margin; |
829 if (!buildNodeQuads(node->renderer(), &content, &padding, &border, &margin)) | 829 if (!buildNodeQuads(node->renderer(), &content, &padding, &border, &margin)) |
830 return false; | 830 return false; |
831 | 831 |
832 IntRect boundingBox = pixelSnappedIntRect(view->contentsToRootView(renderer-
>absoluteBoundingBoxRect())); | 832 IntRect boundingBox = pixelSnappedIntRect(view->contentsToRootFrame(renderer
->absoluteBoundingBoxRect())); |
833 LayoutBoxModelObject* modelObject = renderer->isBoxModelObject() ? toLayoutB
oxModelObject(renderer) : nullptr; | 833 LayoutBoxModelObject* modelObject = renderer->isBoxModelObject() ? toLayoutB
oxModelObject(renderer) : nullptr; |
834 | 834 |
835 model = TypeBuilder::DOM::BoxModel::create() | 835 model = TypeBuilder::DOM::BoxModel::create() |
836 .setContent(buildArrayForQuad(content)) | 836 .setContent(buildArrayForQuad(content)) |
837 .setPadding(buildArrayForQuad(padding)) | 837 .setPadding(buildArrayForQuad(padding)) |
838 .setBorder(buildArrayForQuad(border)) | 838 .setBorder(buildArrayForQuad(border)) |
839 .setMargin(buildArrayForQuad(margin)) | 839 .setMargin(buildArrayForQuad(margin)) |
840 .setWidth(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedO
ffsetWidth(), modelObject) : boundingBox.width()) | 840 .setWidth(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedO
ffsetWidth(), modelObject) : boundingBox.width()) |
841 .setHeight(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnapped
OffsetHeight(), modelObject) : boundingBox.height()); | 841 .setHeight(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnapped
OffsetHeight(), modelObject) : boundingBox.height()); |
842 | 842 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 hideHighlight(); | 888 hideHighlight(); |
889 } | 889 } |
890 | 890 |
891 void InspectorOverlay::startedRecordingProfile() | 891 void InspectorOverlay::startedRecordingProfile() |
892 { | 892 { |
893 if (!m_activeProfilerCount++) | 893 if (!m_activeProfilerCount++) |
894 freePage(); | 894 freePage(); |
895 } | 895 } |
896 | 896 |
897 } // namespace blink | 897 } // namespace blink |
OLD | NEW |