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

Side by Side Diff: Source/core/inspector/LayoutEditor.cpp

Issue 1303173007: Oilpan: Unship Oilpan from CSSValues Base URL: svn://svn.chromium.org/blink/trunk
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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/LayoutEditor.h ('k') | Source/core/layout/svg/ReferenceFilterBuilder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/inspector/LayoutEditor.h" 6 #include "core/inspector/LayoutEditor.h"
7 7
8 #include "core/css/CSSComputedStyleDeclaration.h" 8 #include "core/css/CSSComputedStyleDeclaration.h"
9 #include "core/dom/NodeComputedStyle.h" 9 #include "core/dom/NodeComputedStyle.h"
10 #include "core/frame/FrameView.h" 10 #include "core/frame/FrameView.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 FloatQuad marginHandles = translateAndProject(contentMeans, orthogonals, mar gin, 12); 183 FloatQuad marginHandles = translateAndProject(contentMeans, orthogonals, mar gin, 12);
184 appendAnchorFor(anchors.get(), "margin", "margin-top", marginHandles.p1(), o rthogonals.p1()); 184 appendAnchorFor(anchors.get(), "margin", "margin-top", marginHandles.p1(), o rthogonals.p1());
185 appendAnchorFor(anchors.get(), "margin", "margin-right", marginHandles.p2(), orthogonals.p2()); 185 appendAnchorFor(anchors.get(), "margin", "margin-right", marginHandles.p2(), orthogonals.p2());
186 appendAnchorFor(anchors.get(), "margin", "margin-bottom", marginHandles.p3() , orthogonals.p3()); 186 appendAnchorFor(anchors.get(), "margin", "margin-bottom", marginHandles.p3() , orthogonals.p3());
187 appendAnchorFor(anchors.get(), "margin", "margin-left", marginHandles.p4(), orthogonals.p4()); 187 appendAnchorFor(anchors.get(), "margin", "margin-left", marginHandles.p4(), orthogonals.p4());
188 188
189 object->setArray("anchors", anchors.release()); 189 object->setArray("anchors", anchors.release());
190 return object.release(); 190 return object.release();
191 } 191 }
192 192
193 RefPtrWillBeRawPtr<CSSPrimitiveValue> LayoutEditor::getPropertyCSSValue(CSSPrope rtyID property) const 193 RefPtr<CSSPrimitiveValue> LayoutEditor::getPropertyCSSValue(CSSPropertyID proper ty) const
194 { 194 {
195 RefPtrWillBeRawPtr<CSSStyleDeclaration> style = m_cssAgent->findEffectiveDec laration(m_element.get(), property); 195 RefPtrWillBeRawPtr<CSSStyleDeclaration> style = m_cssAgent->findEffectiveDec laration(m_element.get(), property);
196 if (!style) 196 if (!style)
197 return nullptr; 197 return nullptr;
198 198
199 RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(p roperty); 199 RefPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(property);
200 if (!cssValue || !cssValue->isPrimitiveValue()) 200 if (!cssValue || !cssValue->isPrimitiveValue())
201 return nullptr; 201 return nullptr;
202 202
203 return toCSSPrimitiveValue(cssValue.get()); 203 return toCSSPrimitiveValue(cssValue.get());
204 } 204 }
205 205
206 PassRefPtr<JSONObject> LayoutEditor::createValueDescription(const String& proper tyName) const 206 PassRefPtr<JSONObject> LayoutEditor::createValueDescription(const String& proper tyName) const
207 { 207 {
208 RefPtrWillBeRawPtr<CSSPrimitiveValue> cssValue = getPropertyCSSValue(cssProp ertyID(propertyName)); 208 RefPtr<CSSPrimitiveValue> cssValue = getPropertyCSSValue(cssPropertyID(prope rtyName));
209 if (cssValue && !(cssValue->isLength() || cssValue->isPercentage())) 209 if (cssValue && !(cssValue->isLength() || cssValue->isPercentage()))
210 return nullptr; 210 return nullptr;
211 211
212 RefPtr<JSONObject> object = JSONObject::create(); 212 RefPtr<JSONObject> object = JSONObject::create();
213 object->setNumber("value", cssValue ? cssValue->getFloatValue() : 0); 213 object->setNumber("value", cssValue ? cssValue->getFloatValue() : 0);
214 CSSPrimitiveValue::UnitType unitType = cssValue ? cssValue->typeWithCalcReso lved() : CSSPrimitiveValue::UnitType::Pixels; 214 CSSPrimitiveValue::UnitType unitType = cssValue ? cssValue->typeWithCalcReso lved() : CSSPrimitiveValue::UnitType::Pixels;
215 object->setString("unit", CSSPrimitiveValue::unitTypeToString(unitType)); 215 object->setString("unit", CSSPrimitiveValue::unitTypeToString(unitType));
216 // TODO: Support an editing of other popular units like: em, rem 216 // TODO: Support an editing of other popular units like: em, rem
217 object->setBoolean("mutable", isMutableUnitType(unitType)); 217 object->setBoolean("mutable", isMutableUnitType(unitType));
218 return object.release(); 218 return object.release();
219 } 219 }
220 220
221 void LayoutEditor::appendAnchorFor(JSONArray* anchors, const String& type, const String& propertyName, const FloatPoint& position, const FloatPoint& orthogonalV ector) const 221 void LayoutEditor::appendAnchorFor(JSONArray* anchors, const String& type, const String& propertyName, const FloatPoint& position, const FloatPoint& orthogonalV ector) const
222 { 222 {
223 RefPtr<JSONObject> description = createValueDescription(propertyName); 223 RefPtr<JSONObject> description = createValueDescription(propertyName);
224 if (description) 224 if (description)
225 anchors->pushObject(createAnchor(position, type, propertyName, orthogona lVector, description.release())); 225 anchors->pushObject(createAnchor(position, type, propertyName, orthogona lVector, description.release()));
226 } 226 }
227 227
228 void LayoutEditor::overlayStartedPropertyChange(const String& anchorName) 228 void LayoutEditor::overlayStartedPropertyChange(const String& anchorName)
229 { 229 {
230 m_changingProperty = cssPropertyID(anchorName); 230 m_changingProperty = cssPropertyID(anchorName);
231 if (!m_element || !m_changingProperty) 231 if (!m_element || !m_changingProperty)
232 return; 232 return;
233 233
234 RefPtrWillBeRawPtr<CSSPrimitiveValue> cssValue = getPropertyCSSValue(m_chang ingProperty); 234 RefPtr<CSSPrimitiveValue> cssValue = getPropertyCSSValue(m_changingProperty) ;
235 m_valueUnitType = cssValue ? cssValue->typeWithCalcResolved() : CSSPrimitive Value::UnitType::Pixels; 235 m_valueUnitType = cssValue ? cssValue->typeWithCalcResolved() : CSSPrimitive Value::UnitType::Pixels;
236 if (!isMutableUnitType(m_valueUnitType)) 236 if (!isMutableUnitType(m_valueUnitType))
237 return; 237 return;
238 238
239 switch (m_valueUnitType) { 239 switch (m_valueUnitType) {
240 case CSSPrimitiveValue::UnitType::Pixels: 240 case CSSPrimitiveValue::UnitType::Pixels:
241 m_factor = 1; 241 m_factor = 1;
242 break; 242 break;
243 case CSSPrimitiveValue::UnitType::Ems: 243 case CSSPrimitiveValue::UnitType::Ems:
244 m_factor = m_element->computedStyle()->computedFontSize(); 244 m_factor = m_element->computedStyle()->computedFontSize();
(...skipping 23 matching lines...) Expand all
268 268
269 void LayoutEditor::overlayEndedPropertyChange() 269 void LayoutEditor::overlayEndedPropertyChange()
270 { 270 {
271 m_changingProperty = CSSPropertyInvalid; 271 m_changingProperty = CSSPropertyInvalid;
272 m_propertyInitialValue = 0; 272 m_propertyInitialValue = 0;
273 m_factor = 0; 273 m_factor = 0;
274 m_valueUnitType = CSSPrimitiveValue::UnitType::Unknown; 274 m_valueUnitType = CSSPrimitiveValue::UnitType::Unknown;
275 } 275 }
276 276
277 } // namespace blink 277 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/LayoutEditor.h ('k') | Source/core/layout/svg/ReferenceFilterBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698