| Index: third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp
|
| diff --git a/third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp b/third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp
|
| index 556d2778516a4dfbe5c42a3e3590d84dd738f942..08e7cbf3dc0830527ad06ec1d2ec388de970c1a0 100644
|
| --- a/third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp
|
| +++ b/third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp
|
| @@ -372,6 +372,28 @@ bool verifyStyleText(Document* document, const String& text)
|
| return verifyRuleText(document, "div {" + text + "}");
|
| }
|
|
|
| +bool verifyKeyframeKeyText(Document* document, const String& keyText)
|
| +{
|
| + RefPtrWillBeRawPtr<StyleSheetContents> styleSheet = StyleSheetContents::create(strictCSSParserContext());
|
| + RuleSourceDataList sourceData;
|
| + String text = "@keyframes boguzAnim { " + keyText + " { -webkit-boguz-propertee : none; } }";
|
| + StyleSheetHandler handler(text, document, &sourceData);
|
| + CSSParser::parseSheetForInspector(parserContextForDocument(document), styleSheet.get(), text, handler);
|
| +
|
| + // Exactly two should be parsed.
|
| + unsigned ruleCount = sourceData.size();
|
| + if (ruleCount != 2 || sourceData.at(0)->type != StyleRule::Keyframes || sourceData.at(1)->type != StyleRule::Keyframe)
|
| + return false;
|
| +
|
| + // Exactly one property should be in keyframe rule.
|
| + WillBeHeapVector<CSSPropertySourceData>& propertyData = sourceData.at(1)->styleSourceData->propertyData;
|
| + unsigned propertyCount = propertyData.size();
|
| + if (propertyCount != 1)
|
| + return false;
|
| +
|
| + return true;
|
| +}
|
| +
|
| bool verifySelectorText(Document* document, const String& selectorText)
|
| {
|
| DEFINE_STATIC_LOCAL(String, bogusPropertyName, ("-webkit-boguz-propertee"));
|
| @@ -996,6 +1018,34 @@ RefPtrWillBeRawPtr<CSSStyleRule> InspectorStyleSheet::setRuleSelector(const Sour
|
| return styleRule;
|
| }
|
|
|
| +PassRefPtrWillBeRawPtr<CSSKeyframeRule> InspectorStyleSheet::setKeyframeKey(const SourceRange& range, const String& text, SourceRange* newRange, String* oldText, ExceptionState& exceptionState)
|
| +{
|
| + if (!verifyKeyframeKeyText(m_pageStyleSheet->ownerDocument(), text)) {
|
| + exceptionState.throwDOMException(SyntaxError, "Keyframe key text is not valid.");
|
| + return nullptr;
|
| + }
|
| +
|
| + RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = findRuleByHeaderRange(range);
|
| + if (!sourceData || !sourceData->styleSourceData) {
|
| + exceptionState.throwDOMException(NotFoundError, "Source range didn't match existing source range");
|
| + return nullptr;
|
| + }
|
| +
|
| + RefPtrWillBeRawPtr<CSSRule> rule = ruleForSourceData(sourceData);
|
| + if (!rule || !rule->parentStyleSheet() || rule->type() != CSSRule::KEYFRAME_RULE) {
|
| + exceptionState.throwDOMException(NotFoundError, "Source range didn't match existing style source range");
|
| + return nullptr;
|
| + }
|
| +
|
| + RefPtrWillBeRawPtr<CSSKeyframeRule> keyframeRule = toCSSKeyframeRule(rule.get());
|
| + keyframeRule->setKeyText(text, exceptionState);
|
| +
|
| + replaceText(sourceData->ruleHeaderRange, text, newRange, oldText);
|
| + onStyleSheetTextChanged();
|
| +
|
| + return keyframeRule;
|
| +}
|
| +
|
| PassRefPtrWillBeRawPtr<CSSRule> InspectorStyleSheet::setStyleText(const SourceRange& range, const String& text, SourceRange* newRange, String* oldText, ExceptionState& exceptionState)
|
| {
|
| if (!verifyStyleText(m_pageStyleSheet->ownerDocument(), text)) {
|
| @@ -1370,6 +1420,24 @@ PassRefPtr<TypeBuilder::CSS::CSSRule> InspectorStyleSheet::buildObjectForRuleWit
|
| return result.release();
|
| }
|
|
|
| +PassRefPtr<TypeBuilder::CSS::CSSKeyframeRule> InspectorStyleSheet::buildObjectForKeyframeRule(CSSKeyframeRule* keyframeRule)
|
| +{
|
| + CSSStyleSheet* styleSheet = pageStyleSheet();
|
| + if (!styleSheet)
|
| + return nullptr;
|
| +
|
| + RefPtr<TypeBuilder::CSS::Value> keyText = TypeBuilder::CSS::Value::create().setText(keyframeRule->keyText());
|
| + keyText->setRange(buildSourceRangeObject(sourceDataForRule(keyframeRule)->ruleHeaderRange));
|
| + RefPtr<TypeBuilder::CSS::CSSKeyframeRule> result = TypeBuilder::CSS::CSSKeyframeRule::create()
|
| + // TODO(samli): keyText() normalises 'from' and 'to' keyword values.
|
| + .setKeyText(keyText)
|
| + .setOrigin(m_origin)
|
| + .setStyle(buildObjectForStyle(keyframeRule->style()));
|
| + if (canBind(m_origin) && !id().isEmpty())
|
| + result->setStyleSheetId(id());
|
| + return result.release();
|
| +}
|
| +
|
| bool InspectorStyleSheet::getText(String* result)
|
| {
|
| if (m_sourceData) {
|
|
|