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

Unified Diff: Source/core/inspector/LayoutEditor.cpp

Issue 1206833003: Devtools[LayoutEditor]: Pass data about property change from InspectorOverlayPage (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address pfeldman's comment Created 5 years, 6 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
« no previous file with comments | « Source/core/inspector/LayoutEditor.h ('k') | Source/web/InspectorOverlayImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/LayoutEditor.cpp
diff --git a/Source/core/inspector/LayoutEditor.cpp b/Source/core/inspector/LayoutEditor.cpp
index dda416465416510fd00327606496e06e70c3696b..b5da852867ac6192e63994074d48cba2693f6710 100644
--- a/Source/core/inspector/LayoutEditor.cpp
+++ b/Source/core/inspector/LayoutEditor.cpp
@@ -5,14 +5,15 @@
#include "config.h"
#include "core/inspector/LayoutEditor.h"
-#include "core/dom/Node.h"
+#include "core/css/CSSComputedStyleDeclaration.h"
+#include "core/css/CSSPrimitiveValue.h"
#include "core/frame/FrameView.h"
+#include "core/inspector/InspectorCSSAgent.h"
#include "core/layout/LayoutBox.h"
#include "core/layout/LayoutInline.h"
#include "core/layout/LayoutObject.h"
#include "platform/JSONValues.h"
-
namespace blink {
namespace {
@@ -50,13 +51,26 @@ FloatPoint orthogonalVector(FloatPoint from, FloatPoint to, FloatPoint defaultVe
} // namespace
-LayoutEditor::LayoutEditor(Node* node)
- : m_node(node)
+LayoutEditor::LayoutEditor(InspectorCSSAgent* cssAgent)
+ : m_node(nullptr)
+ , m_cssAgent(cssAgent)
+ , m_changingProperty(CSSPropertyInvalid)
+ , m_propertyInitialValue(0)
+{
+}
+
+void LayoutEditor::setNode(Node* node)
{
+ m_node = node;
+ m_changingProperty = CSSPropertyInvalid;
+ m_propertyInitialValue = 0;
}
PassRefPtr<JSONObject> LayoutEditor::buildJSONInfo() const
{
+ if (!m_node)
+ return nullptr;
+
LayoutObject* layoutObject = m_node->layoutObject();
if (!layoutObject)
@@ -105,7 +119,34 @@ PassRefPtr<JSONObject> LayoutEditor::buildJSONInfo() const
object->setArray("anchors", anchors.release());
return object.release();
+}
+
+void LayoutEditor::overlayStartedPropertyChange(const String& anchorName)
+{
+ m_changingProperty = cssPropertyID(anchorName);
+ if (!m_node || !m_changingProperty)
+ return;
+
+ RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSComputedStyleDeclaration::create(m_node, true);
+ RefPtrWillBeRawPtr<CSSValue> cssValue = computedStyleInfo->getPropertyCSSValue(m_changingProperty);
+ if (!cssValue->isPrimitiveValue()) {
+ m_changingProperty = CSSPropertyInvalid;
+ return;
+ }
+
+ m_propertyInitialValue = toCSSPrimitiveValue(cssValue.get())->getFloatValue();
+}
+void LayoutEditor::overlayPropertyChanged(float cssDelta)
+{
+ if (m_changingProperty)
+ m_cssAgent->setCSSPropertyValue(m_node.get(), m_changingProperty, cssDelta + m_propertyInitialValue);
+}
+
+void LayoutEditor::overlayEndedPropertyChange()
+{
+ m_changingProperty = CSSPropertyInvalid;
+ m_propertyInitialValue = 0;
}
} // namespace blink
« no previous file with comments | « Source/core/inspector/LayoutEditor.h ('k') | Source/web/InspectorOverlayImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698