| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/css/cssom/StyleValue.h" | |
| 6 | |
| 7 #include "bindings/core/v8/ExceptionState.h" | |
| 8 #include "bindings/core/v8/ScriptValue.h" | |
| 9 #include "bindings/core/v8/ToV8.h" | |
| 10 #include "core/StylePropertyShorthand.h" | |
| 11 #include "core/css/cssom/StyleValueFactory.h" | |
| 12 #include "core/css/parser/CSSParser.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 ScriptValue StyleValue::parse(ScriptState* scriptState, const String& propertyNa
me, const String& value, ExceptionState& exceptionState) | |
| 17 { | |
| 18 if (propertyName.isEmpty()) { | |
| 19 exceptionState.throwTypeError("Property name cannot be empty"); | |
| 20 return ScriptValue::createNull(scriptState); | |
| 21 } | |
| 22 | |
| 23 CSSPropertyID propertyID = cssPropertyID(propertyName); | |
| 24 if (propertyID == CSSPropertyInvalid) { | |
| 25 exceptionState.throwTypeError("Invalid property name"); | |
| 26 return ScriptValue::createNull(scriptState); | |
| 27 } | |
| 28 if (isShorthandProperty(propertyID)) { | |
| 29 exceptionState.throwTypeError("Parsing shorthand properties is not suppo
rted"); | |
| 30 return ScriptValue::createNull(scriptState); | |
| 31 } | |
| 32 | |
| 33 CSSValue* cssValue = CSSParser::parseSingleValue(propertyID, value, strictCS
SParserContext()); | |
| 34 if (!cssValue) | |
| 35 return ScriptValue::createNull(scriptState); | |
| 36 | |
| 37 StyleValue* styleValue = StyleValueFactory::create(propertyID, *cssValue); | |
| 38 if (!styleValue) | |
| 39 return ScriptValue::createNull(scriptState); | |
| 40 | |
| 41 v8::Local<v8::Value> wrappedValue = toV8(styleValue, scriptState->context()-
>Global(), scriptState->isolate()); | |
| 42 return ScriptValue(scriptState, wrappedValue); | |
| 43 } | |
| 44 | |
| 45 } // namespace blink | |
| OLD | NEW |