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

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

Issue 1311783003: Devtools[LayoutEditor]: Rework layout-editor workflow (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@resize
Patch Set: Created 5 years, 4 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 180fb21b5bba6efd69f7af6df1471f7b08fc39d4..3c19be6e4c02482a4194e154404fb641c87be6e1 100644
--- a/Source/core/inspector/LayoutEditor.cpp
+++ b/Source/core/inspector/LayoutEditor.cpp
@@ -9,6 +9,7 @@
#include "core/dom/NodeComputedStyle.h"
#include "core/frame/FrameView.h"
#include "core/inspector/InspectorCSSAgent.h"
+#include "core/inspector/InspectorDOMAgent.h"
#include "core/inspector/InspectorHighlight.h"
#include "core/layout/LayoutBox.h"
#include "core/layout/LayoutInline.h"
@@ -140,11 +141,13 @@ float toValidValue(CSSPropertyID propertyId, float newValue)
}
} // namespace
-LayoutEditor::LayoutEditor(InspectorCSSAgent* cssAgent)
+LayoutEditor::LayoutEditor(InspectorCSSAgent* cssAgent, InspectorDOMAgent* domAgent)
: m_element(nullptr)
, m_cssAgent(cssAgent)
+ , m_domAgent(domAgent)
, m_changingProperty(CSSPropertyInvalid)
, m_propertyInitialValue(0)
+ , m_madeChanges(false)
{
}
@@ -152,13 +155,19 @@ DEFINE_TRACE(LayoutEditor)
{
visitor->trace(m_element);
visitor->trace(m_cssAgent);
+ visitor->trace(m_domAgent);
}
void LayoutEditor::setNode(Node* node)
{
- m_element = node && node->isElementNode() ? toElement(node) : nullptr;
+ Element* element = node && node->isElementNode() ? toElement(node) : nullptr;
+ if (element == m_element)
+ return;
+
+ m_element = element;
m_changingProperty = CSSPropertyInvalid;
m_propertyInitialValue = 0;
+ m_madeChanges = false;
}
PassRefPtr<JSONObject> LayoutEditor::buildJSONInfo() const
@@ -263,6 +272,7 @@ void LayoutEditor::overlayPropertyChanged(float cssDelta)
String errorString;
float newValue = toValidValue(m_changingProperty, cssDelta / m_factor + m_propertyInitialValue);
m_cssAgent->setCSSPropertyValue(&errorString, m_element.get(), m_changingProperty, truncateZeroes(String::format("%.2f", newValue)) + CSSPrimitiveValue::unitTypeToString(m_valueUnitType));
+ m_madeChanges = true;
}
}
@@ -274,4 +284,16 @@ void LayoutEditor::overlayEndedPropertyChange()
m_valueUnitType = CSSPrimitiveValue::UnitType::Unknown;
}
+void LayoutEditor::clearSelection(bool commitChanges)
+{
+ m_domAgent->resumeSearchingForNode(m_element.get());
+ ErrorString errorString;
+ if (commitChanges)
+ m_domAgent->markUndoableState(&errorString);
+ else if (m_madeChanges)
+ m_domAgent->undo(&errorString);
+
+ m_madeChanges = false;
pfeldman 2015/08/24 23:18:13 m_isDirty
sergeyv 2015/08/25 17:58:02 Done.
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698