Chromium Code Reviews| Index: Source/core/inspector/InspectorOverlay.cpp |
| diff --git a/Source/core/inspector/InspectorOverlay.cpp b/Source/core/inspector/InspectorOverlay.cpp |
| index fdfec1cffc51e77ceb4bff332e69741ff6410f65..6da8b3f55858fe8453ad250338e5b9c0f6fa7e61 100644 |
| --- a/Source/core/inspector/InspectorOverlay.cpp |
| +++ b/Source/core/inspector/InspectorOverlay.cpp |
| @@ -492,6 +492,101 @@ static PassRefPtr<JSONObject> buildObjectForSize(const IntSize& size) |
| return result.release(); |
| } |
| +static FloatPoint localPointToRoot(RenderObject* renderer, const FrameView* mainView, const FrameView* view, const FloatPoint& point) |
| +{ |
| + FloatPoint result = renderer->localToAbsolute(point); |
| + result = view->contentsToRootView(roundedIntPoint(result)); |
| + result += mainView->scrollOffset(); |
| + return result; |
| +} |
| + |
| +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 = localPointToRoot(info->renderer, info->rootView, info->view, point); |
| + info->array->pushNumber(point.x()); |
| + info->array->pushNumber(point.y()); |
| + } |
| +} |
| + |
| +static void appendPathSegment(void* info, const PathElement* pathElement) |
| +{ |
| + PathApplyInfo* pathApplyInfo = static_cast<PathApplyInfo*>(info); |
|
pfeldman
2014/04/15 11:59:09
Please don't reinterpret, call it using simple loo
Habib Virji
2014/04/17 15:43:47
Tried to remove but problem is paths.shape.apply(&
apavlov
2014/04/17 16:11:32
Well, the current code is along the lines of what
|
| + FloatPoint point; |
| + switch (pathElement->type) { |
| + // The points member will contain 1 value. |
| + case PathElementMoveToPoint: |
| + appendPathCommandAndPoints(pathApplyInfo, ("M"), pathElement->points, 1); |
|
apavlov
2014/04/17 16:11:32
The parentheses around strings are not needed?
|
| + 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; |
| + } |
| +} |
| + |
| +static PassRefPtr<JSONObject> 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)); |
| + contentsQuadToPage(containingFrame->page()->mainFrame()->view(), containingFrame->view(), 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 = containingFrame->page()->mainFrame()->view(); |
|
pfeldman
2014/04/15 11:59:09
Extract FrameView* mainView above - you use it mul
Habib Virji
2014/04/17 15:43:47
Done.
|
| + info.view = containingFrame->view(); |
|
pfeldman
2014/04/15 11:59:09
FrameView* containingView
Habib Virji
2014/04/17 15:43:47
Done.
|
| + 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 +643,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); |