| 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 23 matching lines...) Expand all Loading... |
| 34 #include "bindings/core/v8/V8InspectorOverlayHost.h" | 34 #include "bindings/core/v8/V8InspectorOverlayHost.h" |
| 35 #include "core/dom/ClientRect.h" | 35 #include "core/dom/ClientRect.h" |
| 36 #include "core/dom/Element.h" | 36 #include "core/dom/Element.h" |
| 37 #include "core/dom/Node.h" | 37 #include "core/dom/Node.h" |
| 38 #include "core/dom/PseudoElement.h" | 38 #include "core/dom/PseudoElement.h" |
| 39 #include "core/frame/FrameView.h" | 39 #include "core/frame/FrameView.h" |
| 40 #include "core/frame/LocalFrame.h" | 40 #include "core/frame/LocalFrame.h" |
| 41 #include "core/frame/Settings.h" | 41 #include "core/frame/Settings.h" |
| 42 #include "core/inspector/InspectorClient.h" | 42 #include "core/inspector/InspectorClient.h" |
| 43 #include "core/inspector/InspectorOverlayHost.h" | 43 #include "core/inspector/InspectorOverlayHost.h" |
| 44 #include "core/layout/LayoutObject.h" |
| 44 #include "core/layout/shapes/ShapeOutsideInfo.h" | 45 #include "core/layout/shapes/ShapeOutsideInfo.h" |
| 45 #include "core/loader/EmptyClients.h" | 46 #include "core/loader/EmptyClients.h" |
| 46 #include "core/loader/FrameLoadRequest.h" | 47 #include "core/loader/FrameLoadRequest.h" |
| 47 #include "core/page/Chrome.h" | 48 #include "core/page/Chrome.h" |
| 48 #include "core/page/EventHandler.h" | 49 #include "core/page/EventHandler.h" |
| 49 #include "core/page/Page.h" | 50 #include "core/page/Page.h" |
| 50 #include "core/rendering/RenderBox.h" | 51 #include "core/rendering/RenderBox.h" |
| 51 #include "core/rendering/RenderBoxModelObject.h" | 52 #include "core/rendering/RenderBoxModelObject.h" |
| 52 #include "core/rendering/RenderInline.h" | 53 #include "core/rendering/RenderInline.h" |
| 53 #include "core/rendering/RenderObject.h" | |
| 54 #include "core/rendering/style/RenderStyleConstants.h" | 54 #include "core/rendering/style/RenderStyleConstants.h" |
| 55 #include "platform/JSONValues.h" | 55 #include "platform/JSONValues.h" |
| 56 #include "platform/PlatformMouseEvent.h" | 56 #include "platform/PlatformMouseEvent.h" |
| 57 #include "platform/ScriptForbiddenScope.h" | 57 #include "platform/ScriptForbiddenScope.h" |
| 58 #include "platform/graphics/GraphicsContextStateSaver.h" | 58 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 59 #include "public/platform/Platform.h" | 59 #include "public/platform/Platform.h" |
| 60 #include "public/platform/WebData.h" | 60 #include "public/platform/WebData.h" |
| 61 #include "wtf/Vector.h" | 61 #include "wtf/Vector.h" |
| 62 #include "wtf/text/StringBuilder.h" | 62 #include "wtf/text/StringBuilder.h" |
| 63 #include <v8.h> | 63 #include <v8.h> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 void appendPathElement(const PathElement*); | 90 void appendPathElement(const PathElement*); |
| 91 void appendPathCommandAndPoints(const char* command, const FloatPoint points
[], size_t length); | 91 void appendPathCommandAndPoints(const char* command, const FloatPoint points
[], size_t length); |
| 92 | 92 |
| 93 RefPtr<TypeBuilder::Array<JSONValue> > m_path; | 93 RefPtr<TypeBuilder::Array<JSONValue> > m_path; |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 class ShapePathBuilder : public PathBuilder { | 96 class ShapePathBuilder : public PathBuilder { |
| 97 public: | 97 public: |
| 98 ShapePathBuilder(FrameView& view, RenderObject& renderer, const ShapeOutside
Info& shapeOutsideInfo) | 98 ShapePathBuilder(FrameView& view, LayoutObject& renderer, const ShapeOutside
Info& shapeOutsideInfo) |
| 99 : m_view(view) | 99 : m_view(view) |
| 100 , m_renderer(renderer) | 100 , m_renderer(renderer) |
| 101 , m_shapeOutsideInfo(shapeOutsideInfo) { } | 101 , m_shapeOutsideInfo(shapeOutsideInfo) { } |
| 102 | 102 |
| 103 static PassRefPtr<TypeBuilder::Array<JSONValue> > buildPath(FrameView& view,
RenderObject& renderer, const ShapeOutsideInfo& shapeOutsideInfo, const Path& p
ath) | 103 static PassRefPtr<TypeBuilder::Array<JSONValue>> buildPath(FrameView& view,
LayoutObject& renderer, const ShapeOutsideInfo& shapeOutsideInfo, const Path& pa
th) |
| 104 { | 104 { |
| 105 ShapePathBuilder builder(view, renderer, shapeOutsideInfo); | 105 ShapePathBuilder builder(view, renderer, shapeOutsideInfo); |
| 106 builder.appendPath(path); | 106 builder.appendPath(path); |
| 107 return builder.path(); | 107 return builder.path(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 protected: | 110 protected: |
| 111 virtual FloatPoint translatePoint(const FloatPoint& point) | 111 virtual FloatPoint translatePoint(const FloatPoint& point) |
| 112 { | 112 { |
| 113 FloatPoint rendererPoint = m_shapeOutsideInfo.shapeToRendererPoint(point
); | 113 FloatPoint rendererPoint = m_shapeOutsideInfo.shapeToRendererPoint(point
); |
| 114 return m_view.contentsToRootView(roundedIntPoint(m_renderer.localToAbsol
ute(rendererPoint))); | 114 return m_view.contentsToRootView(roundedIntPoint(m_renderer.localToAbsol
ute(rendererPoint))); |
| 115 } | 115 } |
| 116 | 116 |
| 117 private: | 117 private: |
| 118 FrameView& m_view; | 118 FrameView& m_view; |
| 119 RenderObject& m_renderer; | 119 LayoutObject& m_renderer; |
| 120 const ShapeOutsideInfo& m_shapeOutsideInfo; | 120 const ShapeOutsideInfo& m_shapeOutsideInfo; |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 class InspectorOverlayChromeClient final: public EmptyChromeClient { | 123 class InspectorOverlayChromeClient final: public EmptyChromeClient { |
| 124 public: | 124 public: |
| 125 InspectorOverlayChromeClient(ChromeClient& client, InspectorOverlay* overlay
) | 125 InspectorOverlayChromeClient(ChromeClient& client, InspectorOverlay* overlay
) |
| 126 : m_client(client) | 126 : m_client(client) |
| 127 , m_overlay(overlay) | 127 , m_overlay(overlay) |
| 128 { } | 128 { } |
| 129 | 129 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 static void contentsQuadToScreen(const FrameView* view, FloatQuad& quad) | 240 static void contentsQuadToScreen(const FrameView* view, FloatQuad& quad) |
| 241 { | 241 { |
| 242 quad.setP1(view->contentsToRootView(roundedIntPoint(quad.p1()))); | 242 quad.setP1(view->contentsToRootView(roundedIntPoint(quad.p1()))); |
| 243 quad.setP2(view->contentsToRootView(roundedIntPoint(quad.p2()))); | 243 quad.setP2(view->contentsToRootView(roundedIntPoint(quad.p2()))); |
| 244 quad.setP3(view->contentsToRootView(roundedIntPoint(quad.p3()))); | 244 quad.setP3(view->contentsToRootView(roundedIntPoint(quad.p3()))); |
| 245 quad.setP4(view->contentsToRootView(roundedIntPoint(quad.p4()))); | 245 quad.setP4(view->contentsToRootView(roundedIntPoint(quad.p4()))); |
| 246 } | 246 } |
| 247 | 247 |
| 248 static bool buildNodeQuads(RenderObject* renderer, FloatQuad* content, FloatQuad
* padding, FloatQuad* border, FloatQuad* margin) | 248 static bool buildNodeQuads(LayoutObject* renderer, FloatQuad* content, FloatQuad
* padding, FloatQuad* border, FloatQuad* margin) |
| 249 { | 249 { |
| 250 FrameView* containingView = renderer->frameView(); | 250 FrameView* containingView = renderer->frameView(); |
| 251 if (!containingView) | 251 if (!containingView) |
| 252 return false; | 252 return false; |
| 253 if (!renderer->isBox() && !renderer->isRenderInline()) | 253 if (!renderer->isBox() && !renderer->isRenderInline()) |
| 254 return false; | 254 return false; |
| 255 | 255 |
| 256 LayoutRect contentBox; | 256 LayoutRect contentBox; |
| 257 LayoutRect paddingBox; | 257 LayoutRect paddingBox; |
| 258 LayoutRect borderBox; | 258 LayoutRect borderBox; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 contentsQuadToScreen(containingView, *content); | 298 contentsQuadToScreen(containingView, *content); |
| 299 contentsQuadToScreen(containingView, *padding); | 299 contentsQuadToScreen(containingView, *padding); |
| 300 contentsQuadToScreen(containingView, *border); | 300 contentsQuadToScreen(containingView, *border); |
| 301 contentsQuadToScreen(containingView, *margin); | 301 contentsQuadToScreen(containingView, *margin); |
| 302 | 302 |
| 303 return true; | 303 return true; |
| 304 } | 304 } |
| 305 | 305 |
| 306 static void buildNodeHighlight(Node& node, const HighlightConfig& highlightConfi
g, Highlight* highlight) | 306 static void buildNodeHighlight(Node& node, const HighlightConfig& highlightConfi
g, Highlight* highlight) |
| 307 { | 307 { |
| 308 RenderObject* renderer = node.renderer(); | 308 LayoutObject* renderer = node.renderer(); |
| 309 if (!renderer) | 309 if (!renderer) |
| 310 return; | 310 return; |
| 311 | 311 |
| 312 highlight->setDataFromConfig(highlightConfig); | 312 highlight->setDataFromConfig(highlightConfig); |
| 313 | 313 |
| 314 // RenderSVGRoot should be highlighted through the isBox() code path, all ot
her SVG elements should just dump their absoluteQuads(). | 314 // RenderSVGRoot should be highlighted through the isBox() code path, all ot
her SVG elements should just dump their absoluteQuads(). |
| 315 if (renderer->node() && renderer->node()->isSVGElement() && !renderer->isSVG
Root()) { | 315 if (renderer->node() && renderer->node()->isSVGElement() && !renderer->isSVG
Root()) { |
| 316 Vector<FloatQuad> quads; | 316 Vector<FloatQuad> quads; |
| 317 renderer->absoluteQuads(quads); | 317 renderer->absoluteQuads(quads); |
| 318 FrameView* containingView = renderer->frameView(); | 318 FrameView* containingView = renderer->frameView(); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 array->addItem(quad.p2().y()); | 587 array->addItem(quad.p2().y()); |
| 588 array->addItem(quad.p3().x()); | 588 array->addItem(quad.p3().x()); |
| 589 array->addItem(quad.p3().y()); | 589 array->addItem(quad.p3().y()); |
| 590 array->addItem(quad.p4().x()); | 590 array->addItem(quad.p4().x()); |
| 591 array->addItem(quad.p4().y()); | 591 array->addItem(quad.p4().y()); |
| 592 return array.release(); | 592 return array.release(); |
| 593 } | 593 } |
| 594 | 594 |
| 595 static const ShapeOutsideInfo* shapeOutsideInfoForNode(Node* node, Shape::Displa
yPaths* paths, FloatQuad* bounds) | 595 static const ShapeOutsideInfo* shapeOutsideInfoForNode(Node* node, Shape::Displa
yPaths* paths, FloatQuad* bounds) |
| 596 { | 596 { |
| 597 RenderObject* renderer = node->renderer(); | 597 LayoutObject* renderer = node->renderer(); |
| 598 if (!renderer || !renderer->isBox() || !toRenderBox(renderer)->shapeOutsideI
nfo()) | 598 if (!renderer || !renderer->isBox() || !toRenderBox(renderer)->shapeOutsideI
nfo()) |
| 599 return nullptr; | 599 return nullptr; |
| 600 | 600 |
| 601 FrameView* containingView = node->document().view(); | 601 FrameView* containingView = node->document().view(); |
| 602 RenderBox* renderBox = toRenderBox(renderer); | 602 RenderBox* renderBox = toRenderBox(renderer); |
| 603 const ShapeOutsideInfo* shapeOutsideInfo = renderBox->shapeOutsideInfo(); | 603 const ShapeOutsideInfo* shapeOutsideInfo = renderBox->shapeOutsideInfo(); |
| 604 | 604 |
| 605 shapeOutsideInfo->computedShape().buildDisplayPaths(*paths); | 605 shapeOutsideInfo->computedShape().buildDisplayPaths(*paths); |
| 606 | 606 |
| 607 LayoutRect shapeBounds = shapeOutsideInfo->computedShapePhysicalBoundingBox(
); | 607 LayoutRect shapeBounds = shapeOutsideInfo->computedShapePhysicalBoundingBox(
); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 } | 657 } |
| 658 if (pseudoElement) { | 658 if (pseudoElement) { |
| 659 if (pseudoElement->pseudoId() == BEFORE) | 659 if (pseudoElement->pseudoId() == BEFORE) |
| 660 classNames.appendLiteral("::before"); | 660 classNames.appendLiteral("::before"); |
| 661 else if (pseudoElement->pseudoId() == AFTER) | 661 else if (pseudoElement->pseudoId() == AFTER) |
| 662 classNames.appendLiteral("::after"); | 662 classNames.appendLiteral("::after"); |
| 663 } | 663 } |
| 664 if (!classNames.isEmpty()) | 664 if (!classNames.isEmpty()) |
| 665 elementInfo->setString("className", classNames.toString()); | 665 elementInfo->setString("className", classNames.toString()); |
| 666 | 666 |
| 667 RenderObject* renderer = element->renderer(); | 667 LayoutObject* renderer = element->renderer(); |
| 668 FrameView* containingView = element->document().view(); | 668 FrameView* containingView = element->document().view(); |
| 669 if (!renderer || !containingView) | 669 if (!renderer || !containingView) |
| 670 return elementInfo; | 670 return elementInfo; |
| 671 | 671 |
| 672 // Render the getBoundingClientRect() data in the tooltip | 672 // Render the getBoundingClientRect() data in the tooltip |
| 673 // to be consistent with the rulers (see http://crbug.com/262338). | 673 // to be consistent with the rulers (see http://crbug.com/262338). |
| 674 RefPtrWillBeRawPtr<ClientRect> boundingBox = element->getBoundingClientRect(
); | 674 RefPtrWillBeRawPtr<ClientRect> boundingBox = element->getBoundingClientRect(
); |
| 675 elementInfo->setString("nodeWidth", String::number(boundingBox->width())); | 675 elementInfo->setString("nodeWidth", String::number(boundingBox->width())); |
| 676 elementInfo->setString("nodeHeight", String::number(boundingBox->height())); | 676 elementInfo->setString("nodeHeight", String::number(boundingBox->height())); |
| 677 | 677 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 } | 815 } |
| 816 | 816 |
| 817 void InspectorOverlay::onTimer(Timer<InspectorOverlay>*) | 817 void InspectorOverlay::onTimer(Timer<InspectorOverlay>*) |
| 818 { | 818 { |
| 819 m_drawViewSize = false; | 819 m_drawViewSize = false; |
| 820 update(); | 820 update(); |
| 821 } | 821 } |
| 822 | 822 |
| 823 bool InspectorOverlay::getBoxModel(Node* node, RefPtr<TypeBuilder::DOM::BoxModel
>& model) | 823 bool InspectorOverlay::getBoxModel(Node* node, RefPtr<TypeBuilder::DOM::BoxModel
>& model) |
| 824 { | 824 { |
| 825 RenderObject* renderer = node->renderer(); | 825 LayoutObject* renderer = node->renderer(); |
| 826 FrameView* view = node->document().view(); | 826 FrameView* view = node->document().view(); |
| 827 if (!renderer || !view) | 827 if (!renderer || !view) |
| 828 return false; | 828 return false; |
| 829 | 829 |
| 830 FloatQuad content, padding, border, margin; | 830 FloatQuad content, padding, border, margin; |
| 831 if (!buildNodeQuads(node->renderer(), &content, &padding, &border, &margin)) | 831 if (!buildNodeQuads(node->renderer(), &content, &padding, &border, &margin)) |
| 832 return false; | 832 return false; |
| 833 | 833 |
| 834 IntRect boundingBox = pixelSnappedIntRect(view->contentsToRootView(renderer-
>absoluteBoundingBoxRect())); | 834 IntRect boundingBox = pixelSnappedIntRect(view->contentsToRootView(renderer-
>absoluteBoundingBoxRect())); |
| 835 RenderBoxModelObject* modelObject = renderer->isBoxModelObject() ? toRenderB
oxModelObject(renderer) : nullptr; | 835 RenderBoxModelObject* modelObject = renderer->isBoxModelObject() ? toRenderB
oxModelObject(renderer) : nullptr; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 hideHighlight(); | 890 hideHighlight(); |
| 891 } | 891 } |
| 892 | 892 |
| 893 void InspectorOverlay::startedRecordingProfile() | 893 void InspectorOverlay::startedRecordingProfile() |
| 894 { | 894 { |
| 895 if (!m_activeProfilerCount++) | 895 if (!m_activeProfilerCount++) |
| 896 freePage(); | 896 freePage(); |
| 897 } | 897 } |
| 898 | 898 |
| 899 } // namespace blink | 899 } // namespace blink |
| OLD | NEW |