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

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: 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
Index: Source/core/inspector/LayoutEditor.cpp
diff --git a/Source/core/inspector/LayoutEditor.cpp b/Source/core/inspector/LayoutEditor.cpp
index dda416465416510fd00327606496e06e70c3696b..492e7c725c7a027f749fbcd7802657129a576f9b 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,19 @@ FloatPoint orthogonalVector(FloatPoint from, FloatPoint to, FloatPoint defaultVe
} // namespace
-LayoutEditor::LayoutEditor(Node* node)
- : m_node(node)
+LayoutEditor::LayoutEditor()
+ : m_node(nullptr)
+ , m_cssAgent(nullptr)
+ , m_changingProperty(CSSPropertyInvalid)
+ , m_propertyInitialValue(0)
{
}
PassRefPtr<JSONObject> LayoutEditor::buildJSONInfo() const
{
+ if (!m_node || !m_cssAgent)
+ return nullptr;
+
LayoutObject* layoutObject = m_node->layoutObject();
if (!layoutObject)
@@ -105,7 +112,32 @@ 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())
+ return;
+ m_propertyInitialValue = toCSSPrimitiveValue(cssValue.get())->getFloatValue();
+}
+
+void LayoutEditor::overlayPropertyChanged(float delta)
+{
+ if (m_cssAgent && m_changingProperty)
+ m_cssAgent->updateCSSProperty(m_node.get(), m_changingProperty, delta + m_propertyInitialValue);
+}
+
+void LayoutEditor::overlayEndedPropertyChange()
+{
+ m_changingProperty = CSSPropertyInvalid;
+ m_propertyInitialValue = 0;
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698