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

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

Issue 441873010: DevTools: [SSP] Implement adding new rule in user stylesheet (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: minor changes Created 6 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/InspectorCSSAgent.cpp
diff --git a/Source/core/inspector/InspectorCSSAgent.cpp b/Source/core/inspector/InspectorCSSAgent.cpp
index 49bc591a39fde46fc3b040253a5d56a872591689..6d3c22195745555bb8efab090c3602a67bdb9cba 100644
--- a/Source/core/inspector/InspectorCSSAgent.cpp
+++ b/Source/core/inspector/InspectorCSSAgent.cpp
@@ -316,10 +316,11 @@ private:
class InspectorCSSAgent::AddRuleAction FINAL : public InspectorCSSAgent::StyleSheetAction {
WTF_MAKE_NONCOPYABLE(AddRuleAction);
public:
- AddRuleAction(InspectorStyleSheet* styleSheet, const String& selector)
+ AddRuleAction(InspectorStyleSheet* styleSheet, const String& ruleText, const SourceRange& location)
: InspectorCSSAgent::StyleSheetAction("AddRule")
, m_styleSheet(styleSheet)
- , m_selector(selector)
+ , m_ruleText(ruleText)
+ , m_location(location)
{
}
@@ -330,12 +331,14 @@ public:
virtual bool undo(ExceptionState& exceptionState) OVERRIDE
{
- return m_styleSheet->deleteRule(m_newId, exceptionState);
+ return m_styleSheet->deleteRule(m_newId, m_oldText, exceptionState);
}
virtual bool redo(ExceptionState& exceptionState) OVERRIDE
{
- CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_selector, exceptionState);
+ if (!m_styleSheet->getText(&m_oldText))
+ return false;
+ CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_ruleText, m_location, exceptionState);
if (exceptionState.hadException())
return false;
m_newId = m_styleSheet->ruleId(cssStyleRule);
@@ -353,8 +356,9 @@ public:
private:
RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet;
InspectorCSSId m_newId;
- String m_selector;
- String m_oldSelector;
+ String m_ruleText;
+ String m_oldText;
+ SourceRange m_location;
};
// static
@@ -932,14 +936,17 @@ void InspectorCSSAgent::createStyleSheet(ErrorString* errorString, const String&
*outStyleSheetId = inspectorStyleSheet->id();
}
-void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleSheetId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result)
+void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleSheetId, const String& ruleText, const RefPtr<JSONObject>& location, RefPtr<TypeBuilder::CSS::CSSRule>& result)
{
InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(errorString, styleSheetId);
if (!inspectorStyleSheet)
return;
+ SourceRange ruleLocation;
+ if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, location, &ruleLocation))
+ return;
TrackExceptionState exceptionState;
- RefPtrWillBeRawPtr<AddRuleAction> action = adoptRefWillBeNoop(new AddRuleAction(inspectorStyleSheet, selector));
+ RefPtrWillBeRawPtr<AddRuleAction> action = adoptRefWillBeNoop(new AddRuleAction(inspectorStyleSheet, ruleText, ruleLocation));
bool success = m_domAgent->history()->perform(action, exceptionState);
if (!success) {
*errorString = InspectorDOMAgent::toErrorString(exceptionState);

Powered by Google App Engine
This is Rietveld 408576698