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

Unified Diff: Source/core/css/CSSStyleSheet.cpp

Issue 1321943002: Support for CSSOM CSSNamespaceRule interface (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated as per review comments 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 | « Source/core/css/CSSRule.idl ('k') | Source/core/css/StyleRule.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSStyleSheet.cpp
diff --git a/Source/core/css/CSSStyleSheet.cpp b/Source/core/css/CSSStyleSheet.cpp
index 71871efde40c748ea039a5f756f3f5a7ae2e5bad..9c39237ca99d5306a77f7326a49c64aef40bde2a 100644
--- a/Source/core/css/CSSStyleSheet.cpp
+++ b/Source/core/css/CSSStyleSheet.cpp
@@ -292,9 +292,7 @@ unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
CSSParserContext context(m_contents->parserContext(), UseCounter::getFrom(this));
RefPtrWillBeRawPtr<StyleRuleBase> rule = CSSParser::parseRule(context, m_contents.get(), ruleString);
- // FIXME: @namespace rules have special handling in the CSSOM spec, but it
- // mostly doesn't make sense since we don't support CSSNamespaceRule
- if (!rule || rule->isNamespaceRule()) {
+ if (!rule) {
exceptionState.throwDOMException(SyntaxError, "Failed to parse the rule '" + ruleString + "'.");
return 0;
}
@@ -302,7 +300,10 @@ unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
bool success = m_contents->wrapperInsertRule(rule, index);
if (!success) {
- exceptionState.throwDOMException(HierarchyRequestError, "Failed to insert the rule.");
+ if (rule->isNamespaceRule())
+ exceptionState.throwDOMException(InvalidStateError, "Failed to insert the rule");
+ else
+ exceptionState.throwDOMException(HierarchyRequestError, "Failed to insert the rule.");
return 0;
}
if (!m_childRuleCSSOMWrappers.isEmpty())
@@ -327,7 +328,11 @@ void CSSStyleSheet::deleteRule(unsigned index, ExceptionState& exceptionState)
}
RuleMutationScope mutationScope(this);
- m_contents->wrapperDeleteRule(index);
+ bool success = m_contents->wrapperDeleteRule(index);
+ if (!success) {
+ exceptionState.throwDOMException(InvalidStateError, "Failed to delete rule");
+ return;
+ }
if (!m_childRuleCSSOMWrappers.isEmpty()) {
if (m_childRuleCSSOMWrappers[index])
« no previous file with comments | « Source/core/css/CSSRule.idl ('k') | Source/core/css/StyleRule.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698