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

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

Issue 1378523003: Devtools[LayoutEditor]: Precise drag with Shift (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@medias-every
Patch Set: Created 5 years, 3 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 | « third_party/WebKit/Source/core/inspector/InspectorOverlayPage.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/inspector/LayoutEditor.cpp
diff --git a/third_party/WebKit/Source/core/inspector/LayoutEditor.cpp b/third_party/WebKit/Source/core/inspector/LayoutEditor.cpp
index 9c4abd5c78527b009f281ea08feb103f1717db49..482c3e8a8e9ce45321bd2e630f74cd11c66b8451 100644
--- a/third_party/WebKit/Source/core/inspector/LayoutEditor.cpp
+++ b/third_party/WebKit/Source/core/inspector/LayoutEditor.cpp
@@ -193,6 +193,12 @@ void buildMediaListChain(CSSRule* rule, Vector<String>& mediaArray)
}
}
+float roundValue(float value, CSSPrimitiveValue::UnitType unitType)
+{
+ float roundTo = unitType == CSSPrimitiveValue::UnitType::Pixels ? 1 : 0.05;
+ return round(value / roundTo) * roundTo;
+}
+
} // namespace
LayoutEditor::LayoutEditor(Element* element, InspectorCSSAgent* cssAgent, InspectorDOMAgent* domAgent, ScriptController* scriptController)
@@ -329,7 +335,7 @@ void LayoutEditor::overlayPropertyChanged(float cssDelta)
{
if (m_changingProperty && m_factor) {
float newValue = cssDelta / m_factor + m_propertyInitialValue;
- newValue = newValue >= 0 ? newValue : 0;
+ newValue = newValue >= 0 ? roundValue(newValue, m_valueUnitType) : 0;
m_isDirty |= setCSSPropertyValueInCurrentRule(truncateZeroes(String::format("%.2f", newValue)) + CSSPrimitiveValue::unitTypeToString(m_valueUnitType));
}
}
« no previous file with comments | « third_party/WebKit/Source/core/inspector/InspectorOverlayPage.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698