summaryrefslogtreecommitdiff
path: root/Source/WebCore/css/CSSGroupingRule.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/css/CSSGroupingRule.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/css/CSSGroupingRule.cpp')
-rw-r--r--Source/WebCore/css/CSSGroupingRule.cpp42
1 files changed, 19 insertions, 23 deletions
diff --git a/Source/WebCore/css/CSSGroupingRule.cpp b/Source/WebCore/css/CSSGroupingRule.cpp
index 664c9b9a1..42bb83bd1 100644
--- a/Source/WebCore/css/CSSGroupingRule.cpp
+++ b/Source/WebCore/css/CSSGroupingRule.cpp
@@ -41,10 +41,10 @@
namespace WebCore {
-CSSGroupingRule::CSSGroupingRule(StyleRuleGroup* groupRule, CSSStyleSheet* parent)
+CSSGroupingRule::CSSGroupingRule(StyleRuleGroup& groupRule, CSSStyleSheet* parent)
: CSSRule(parent)
, m_groupRule(groupRule)
- , m_childRuleCSSOMWrappers(groupRule->childRules().size())
+ , m_childRuleCSSOMWrappers(groupRule.childRules().size())
{
}
@@ -57,26 +57,23 @@ CSSGroupingRule::~CSSGroupingRule()
}
}
-unsigned CSSGroupingRule::insertRule(const String& ruleString, unsigned index, ExceptionCode& ec)
+ExceptionOr<unsigned> CSSGroupingRule::insertRule(const String& ruleString, unsigned index)
{
ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size());
if (index > m_groupRule->childRules().size()) {
// INDEX_SIZE_ERR: Raised if the specified index is not a valid insertion point.
- ec = INDEX_SIZE_ERR;
- return 0;
+ return Exception { INDEX_SIZE_ERR };
}
- CSSParser parser(parserContext());
CSSStyleSheet* styleSheet = parentStyleSheet();
- RefPtr<StyleRuleBase> newRule = parser.parseRule(styleSheet ? &styleSheet->contents() : nullptr, ruleString);
+ RefPtr<StyleRuleBase> newRule = CSSParser::parseRule(parserContext(), styleSheet ? &styleSheet->contents() : nullptr, ruleString);
if (!newRule) {
// SYNTAX_ERR: Raised if the specified rule has a syntax error and is unparsable.
- ec = SYNTAX_ERR;
- return 0;
+ return Exception { SYNTAX_ERR };
}
- if (newRule->isImportRule()) {
+ if (newRule->isImportRule() || newRule->isNamespaceRule()) {
// FIXME: an HIERARCHY_REQUEST_ERR should also be thrown for a @charset or a nested
// @media rule. They are currently not getting parsed, resulting in a SYNTAX_ERR
// to get raised above.
@@ -84,8 +81,7 @@ unsigned CSSGroupingRule::insertRule(const String& ruleString, unsigned index, E
// HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at the specified
// index, e.g., if an @import rule is inserted after a standard rule set or other
// at-rule.
- ec = HIERARCHY_REQUEST_ERR;
- return 0;
+ return Exception { HIERARCHY_REQUEST_ERR };
}
CSSStyleSheet::RuleMutationScope mutationScope(this);
@@ -95,15 +91,14 @@ unsigned CSSGroupingRule::insertRule(const String& ruleString, unsigned index, E
return index;
}
-void CSSGroupingRule::deleteRule(unsigned index, ExceptionCode& ec)
+ExceptionOr<void> CSSGroupingRule::deleteRule(unsigned index)
{
ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size());
if (index >= m_groupRule->childRules().size()) {
// INDEX_SIZE_ERR: Raised if the specified index does not correspond to a
// rule in the media rule list.
- ec = INDEX_SIZE_ERR;
- return;
+ return Exception { INDEX_SIZE_ERR };
}
CSSStyleSheet::RuleMutationScope mutationScope(this);
@@ -113,6 +108,8 @@ void CSSGroupingRule::deleteRule(unsigned index, ExceptionCode& ec)
if (m_childRuleCSSOMWrappers[index])
m_childRuleCSSOMWrappers[index]->setParentRule(0);
m_childRuleCSSOMWrappers.remove(index);
+
+ return { };
}
void CSSGroupingRule::appendCssTextForItems(StringBuilder& result) const
@@ -133,7 +130,7 @@ unsigned CSSGroupingRule::length() const
CSSRule* CSSGroupingRule::item(unsigned index) const
{
if (index >= length())
- return 0;
+ return nullptr;
ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size());
RefPtr<CSSRule>& rule = m_childRuleCSSOMWrappers[index];
if (!rule)
@@ -141,20 +138,19 @@ CSSRule* CSSGroupingRule::item(unsigned index) const
return rule.get();
}
-CSSRuleList* CSSGroupingRule::cssRules() const
+CSSRuleList& CSSGroupingRule::cssRules() const
{
if (!m_ruleListCSSOMWrapper)
- m_ruleListCSSOMWrapper = std::make_unique<LiveCSSRuleList<CSSGroupingRule>>(const_cast<CSSGroupingRule*>(this));
- return m_ruleListCSSOMWrapper.get();
+ m_ruleListCSSOMWrapper = std::make_unique<LiveCSSRuleList<CSSGroupingRule>>(const_cast<CSSGroupingRule&>(*this));
+ return *m_ruleListCSSOMWrapper;
}
-void CSSGroupingRule::reattach(StyleRuleBase* rule)
+void CSSGroupingRule::reattach(StyleRuleBase& rule)
{
- ASSERT(rule);
- m_groupRule = static_cast<StyleRuleGroup*>(rule);
+ m_groupRule = static_cast<StyleRuleGroup&>(rule);
for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) {
if (m_childRuleCSSOMWrappers[i])
- m_childRuleCSSOMWrappers[i]->reattach(m_groupRule->childRules()[i].get());
+ m_childRuleCSSOMWrappers[i]->reattach(*m_groupRule.get().childRules()[i]);
}
}