Chromium Code Reviews| Index: Source/core/inspector/LayoutEditor.cpp |
| diff --git a/Source/core/inspector/LayoutEditor.cpp b/Source/core/inspector/LayoutEditor.cpp |
| index dda416465416510fd00327606496e06e70c3696b..d6cefc5edb48be35a11c3b957542367fca077db1 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,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) |
|
dgozman
2015/06/25 12:30:59
Let's explicitly compare with CSSPropertyInvalid.
sergeyv
2015/06/25 12:54:31
In CSSComputedStyleDeclaration.cpp they do like th
|
| + return; |
| + |
| + RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSComputedStyleDeclaration::create(m_node, true); |
| + RefPtrWillBeRawPtr<CSSValue> cssValue = computedStyleInfo->getPropertyCSSValue(m_changingProperty); |
| + if (!cssValue->isPrimitiveValue()) |
| + return; |
|
dgozman
2015/06/25 12:30:59
m_changingProperty = CSSPropertyInvalid;
sergeyv
2015/06/25 12:54:31
Done.
|
| + |
| + m_propertyInitialValue = toCSSPrimitiveValue(cssValue.get())->getFloatValue(); |
| +} |
| +void LayoutEditor::overlayPropertyChanged(float cssDelta) |
| +{ |
| + if (m_changingProperty) |
|
dgozman
2015/06/25 12:31:00
Let's explicitly compare with CSSPropertyInvalid.
sergeyv
2015/06/25 12:54:31
ditto
|
| + m_cssAgent->updateCSSProperty(m_node.get(), m_changingProperty, cssDelta + m_propertyInitialValue); |
| +} |
| + |
| +void LayoutEditor::overlayEndedPropertyChange() |
| +{ |
| + m_changingProperty = CSSPropertyInvalid; |
| + m_propertyInitialValue = 0; |
| } |
| } // namespace blink |