Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorHighlight.cpp

Issue 2108803006: Fix inspector overlay when use-zoom-for-dsf is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix crash when FrameView is null Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/inspector/InspectorHighlight.cpp
diff --git a/third_party/WebKit/Source/core/inspector/InspectorHighlight.cpp b/third_party/WebKit/Source/core/inspector/InspectorHighlight.cpp
index 09c2e5836bcb30d8d2d2abba45db0a6eeb168518..57442ed43560da2122286c5571a037f801e235b6 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorHighlight.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorHighlight.cpp
@@ -12,6 +12,7 @@
#include "core/layout/LayoutObject.h"
#include "core/layout/shapes/ShapeOutsideInfo.h"
#include "core/style/ComputedStyleConstants.h"
+#include "platform/HostWindow.h"
#include "platform/graphics/Path.h"
namespace blink {
@@ -27,9 +28,11 @@ public:
std::unique_ptr<protocol::ListValue> release() { return std::move(m_path); }
- void appendPath(const Path& path)
+ void appendPath(const Path& path, float scale)
{
- path.apply(this, &PathBuilder::appendPathElement);
+ Path transformPath(path);
+ transformPath.transform(AffineTransform().scale(scale));
+ transformPath.apply(this, &PathBuilder::appendPathElement);
}
protected:
@@ -90,10 +93,10 @@ public:
, m_layoutObject(layoutObject)
, m_shapeOutsideInfo(shapeOutsideInfo) { }
- static std::unique_ptr<protocol::ListValue> buildPath(FrameView& view, LayoutObject& layoutObject, const ShapeOutsideInfo& shapeOutsideInfo, const Path& path)
+ static std::unique_ptr<protocol::ListValue> buildPath(FrameView& view, LayoutObject& layoutObject, const ShapeOutsideInfo& shapeOutsideInfo, const Path& path, float scale)
{
ShapePathBuilder builder(view, layoutObject, shapeOutsideInfo);
- builder.appendPath(path);
+ builder.appendPath(path, scale);
return builder.release();
}
@@ -213,11 +216,12 @@ std::unique_ptr<protocol::DictionaryValue> buildElementInfo(Element* element)
} // namespace
-InspectorHighlight::InspectorHighlight()
+InspectorHighlight::InspectorHighlight(float scale)
: m_highlightPaths(protocol::ListValue::create())
, m_showRulers(false)
, m_showExtensionLines(false)
, m_displayAsMaterial(false)
+ , m_scale(scale)
{
}
@@ -234,7 +238,11 @@ InspectorHighlight::InspectorHighlight(Node* node, const InspectorHighlightConfi
, m_showRulers(highlightConfig.showRulers)
, m_showExtensionLines(highlightConfig.showExtensionLines)
, m_displayAsMaterial(highlightConfig.displayAsMaterial)
+ , m_scale(1.f)
{
+ FrameView* frameView = node->document().view();
+ if (frameView)
+ m_scale = 1.f / frameView->getHostWindow()->windowToViewportScalar(1.f);
appendPathsForShapeOutside(node, highlightConfig);
appendNodeHighlight(node, highlightConfig);
if (appendElementInfo && node->isElementNode())
@@ -249,7 +257,7 @@ void InspectorHighlight::appendQuad(const FloatQuad& quad, const Color& fillColo
{
Path path = quadToPath(quad);
PathBuilder builder;
- builder.appendPath(path);
+ builder.appendPath(path, m_scale);
appendPath(builder.release(), fillColor, outlineColor, name);
}
@@ -288,9 +296,9 @@ void InspectorHighlight::appendPathsForShapeOutside(Node* node, const InspectorH
return;
}
- appendPath(ShapePathBuilder::buildPath(*node->document().view(), *node->layoutObject(), *shapeOutsideInfo, paths.shape), config.shape, Color::transparent);
+ appendPath(ShapePathBuilder::buildPath(*node->document().view(), *node->layoutObject(), *shapeOutsideInfo, paths.shape, m_scale), config.shape, Color::transparent);
if (paths.marginShape.length())
- appendPath(ShapePathBuilder::buildPath(*node->document().view(), *node->layoutObject(), *shapeOutsideInfo, paths.marginShape), config.shapeMargin, Color::transparent);
+ appendPath(ShapePathBuilder::buildPath(*node->document().view(), *node->layoutObject(), *shapeOutsideInfo, paths.marginShape, m_scale), config.shapeMargin, Color::transparent);
}
void InspectorHighlight::appendNodeHighlight(Node* node, const InspectorHighlightConfig& highlightConfig)
@@ -362,8 +370,8 @@ bool InspectorHighlight::getBoxModel(Node* node, std::unique_ptr<protocol::DOM::
if (const ShapeOutsideInfo* shapeOutsideInfo = shapeOutsideInfoForNode(node, &paths, &boundsQuad)) {
(*model)->setShapeOutside(protocol::DOM::ShapeOutsideInfo::create()
.setBounds(buildArrayForQuad(boundsQuad))
- .setShape(protocol::Array<protocol::Value>::parse(ShapePathBuilder::buildPath(*view, *layoutObject, *shapeOutsideInfo, paths.shape).get(), &errors))
- .setMarginShape(protocol::Array<protocol::Value>::parse(ShapePathBuilder::buildPath(*view, *layoutObject, *shapeOutsideInfo, paths.marginShape).get(), &errors))
+ .setShape(protocol::Array<protocol::Value>::parse(ShapePathBuilder::buildPath(*view, *layoutObject, *shapeOutsideInfo, paths.shape, 1.f).get(), &errors))
+ .setMarginShape(protocol::Array<protocol::Value>::parse(ShapePathBuilder::buildPath(*view, *layoutObject, *shapeOutsideInfo, paths.marginShape, 1.f).get(), &errors))
.build());
}
« no previous file with comments | « third_party/WebKit/Source/core/inspector/InspectorHighlight.h ('k') | third_party/WebKit/Source/web/InspectorOverlay.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698