Index: Source/core/inspector/InspectorOverlay.cpp |
diff --git a/Source/core/inspector/InspectorOverlay.cpp b/Source/core/inspector/InspectorOverlay.cpp |
index fdfec1cffc51e77ceb4bff332e69741ff6410f65..14fedb03a3b3b0038e8087f6205b20b6c6c74cef 100644 |
--- a/Source/core/inspector/InspectorOverlay.cpp |
+++ b/Source/core/inspector/InspectorOverlay.cpp |
@@ -492,6 +492,95 @@ static PassRefPtr<JSONObject> buildObjectForSize(const IntSize& size) |
return result.release(); |
} |
+struct PathApplyInfo { |
+ FrameView* rootView; |
+ FrameView* view; |
+ JSONArray* array; |
+ RenderObject* renderer; |
+ const ShapeOutsideInfo* shapeOutsideInfo; |
+}; |
+ |
+static void appendPathCommandAndPoints(PathApplyInfo* info, const String& command, const FloatPoint points[], unsigned length) |
+{ |
+ FloatPoint point; |
+ info->array->pushString(command); |
+ for (unsigned i = 0; i < length; i++) { |
+ point = info->shapeOutsideInfo->shapeToRendererPoint(points[i]); |
+ point = info->view->contentsToRootView(roundedIntPoint(info->renderer->localToAbsolute(point))) + info->rootView->scrollOffset(); |
+ info->array->pushNumber(point.x()); |
+ info->array->pushNumber(point.y()); |
+ } |
+} |
+ |
+static void appendPathSegment(void* info, const PathElement* pathElement) |
+{ |
+ PathApplyInfo* pathApplyInfo = static_cast<PathApplyInfo*>(info); |
+ FloatPoint point; |
+ switch (pathElement->type) { |
+ // The points member will contain 1 value. |
+ case PathElementMoveToPoint: |
+ appendPathCommandAndPoints(pathApplyInfo, "M", pathElement->points, 1); |
+ break; |
+ // The points member will contain 1 value. |
+ case PathElementAddLineToPoint: |
+ appendPathCommandAndPoints(pathApplyInfo, "L", pathElement->points, 1); |
+ break; |
+ // The points member will contain 3 values. |
+ case PathElementAddCurveToPoint: |
+ appendPathCommandAndPoints(pathApplyInfo, "C", pathElement->points, 3); |
+ break; |
+ // The points member will contain 2 values. |
+ case PathElementAddQuadCurveToPoint: |
+ appendPathCommandAndPoints(pathApplyInfo, "Q", pathElement->points, 2); |
+ break; |
+ // The points member will contain no values. |
+ case PathElementCloseSubpath: |
+ appendPathCommandAndPoints(pathApplyInfo, "Z", 0, 0); |
+ break; |
+ } |
+} |
+ |
+PassRefPtr<JSONObject> InspectorOverlay::buildObjectForShapeOutside(LocalFrame* containingFrame, RenderBox* renderer) |
+{ |
+ const ShapeOutsideInfo* shapeOutsideInfo = renderer->shapeOutsideInfo(); |
+ if (!shapeOutsideInfo) |
+ return nullptr; |
+ |
+ RefPtr<JSONObject> shapeObject = JSONObject::create(); |
+ LayoutRect shapeBounds = shapeOutsideInfo->computedShapePhysicalBoundingBox(); |
+ FloatQuad shapeQuad = renderer->localToAbsoluteQuad(FloatRect(shapeBounds)); |
+ FrameView* mainView = containingFrame->page()->mainFrame()->view(); |
+ FrameView* containingView = containingFrame->view(); |
+ contentsQuadToPage(mainView, containingView, shapeQuad); |
+ shapeObject->setArray("bounds", buildArrayForQuad(shapeQuad)); |
+ |
+ Shape::DisplayPaths paths; |
+ shapeOutsideInfo->computedShape().buildDisplayPaths(paths); |
+ |
+ if (paths.shape.length()) { |
+ RefPtr<JSONArray> shapePath = JSONArray::create(); |
+ PathApplyInfo info; |
+ info.rootView = mainView; |
+ info.view = containingView; |
+ info.array = shapePath.get(); |
+ info.renderer = renderer; |
+ info.shapeOutsideInfo = shapeOutsideInfo; |
+ |
+ paths.shape.apply(&info, &appendPathSegment); |
+ |
+ shapeObject->setArray("shape", shapePath.release()); |
+ |
+ if (paths.marginShape.length()) { |
+ shapePath = JSONArray::create(); |
+ info.array = shapePath.get(); |
+ paths.marginShape.apply(&info, &appendPathSegment); |
+ shapeObject->setArray("marginShape", shapePath.release()); |
+ } |
+ } |
+ |
+ return shapeObject.release(); |
+} |
+ |
void InspectorOverlay::drawNodeHighlight() |
{ |
if (!m_highlightNode) |
@@ -548,6 +637,11 @@ void InspectorOverlay::drawNodeHighlight() |
RenderBoxModelObject* modelObject = renderer->isBoxModelObject() ? toRenderBoxModelObject(renderer) : 0; |
elementInfo->setString("nodeWidth", String::number(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedOffsetWidth(), modelObject) : boundingBox.width())); |
elementInfo->setString("nodeHeight", String::number(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedOffsetHeight(), modelObject) : boundingBox.height())); |
+ if (renderer->isBox()) { |
+ RenderBox* renderBox = toRenderBox(renderer); |
+ if (RefPtr<JSONObject> shapeObject = buildObjectForShapeOutside(containingFrame, renderBox)) |
+ elementInfo->setObject("shapeOutsideInfo", shapeObject.release()); |
+ } |
highlightObject->setObject("elementInfo", elementInfo.release()); |
} |
evaluateInOverlay("drawNodeHighlight", highlightObject); |