void CSSStyleSheet::deleteRule(unsigned index, ExceptionCode& ec) { if (index >= length()) { ec = INDEX_SIZE_ERR; return; } ec = 0; unsigned childVectorIndex = index; if (hasCharsetRule()) { if (childVectorIndex == 0) { clearCharsetRule(); goto success; } --childVectorIndex; } if (childVectorIndex < m_importRules.size()) { m_importRules[childVectorIndex]->clearParentStyleSheet(); m_importRules.remove(childVectorIndex); goto success; } childVectorIndex -= m_importRules.size(); m_childRules.remove(childVectorIndex); success: if (!m_childRuleCSSOMWrappers.isEmpty()) { m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0); m_childRuleCSSOMWrappers.remove(index); } styleSheetChanged(); }
void MyMenu::setStyleSheet(QString arg) { QString m_styleSheet = menu->styleSheet (); if (m_styleSheet != arg) { menu->setStyleSheet (arg); emit styleSheetChanged(arg); } }
unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, ExceptionCode& ec) { ec = 0; if (index > length()) { ec = INDEX_SIZE_ERR; return 0; } CSSParser p(cssParserMode()); RefPtr<StyleRuleBase> rule = p.parseRule(this, ruleString); if (!rule) { ec = SYNTAX_ERR; return 0; } // Parser::parseRule doesn't currently allow @charset so we don't need to deal with it. ASSERT(!rule->isCharsetRule()); unsigned childVectorIndex = index; // m_childRules does not contain @charset which is always in index 0 if it exists. if (hasCharsetRule()) { if (childVectorIndex == 0) { // Nothing can be inserted before @charset. ec = HIERARCHY_REQUEST_ERR; return 0; } --childVectorIndex; } if (childVectorIndex < m_importRules.size() || (childVectorIndex == m_importRules.size() && rule->isImportRule())) { // Inserting non-import rule before @import is not allowed. if (!rule->isImportRule()) { ec = HIERARCHY_REQUEST_ERR; return 0; } m_importRules.insert(childVectorIndex, static_cast<StyleRuleImport*>(rule.get())); m_importRules[childVectorIndex]->requestStyleSheet(); goto success; } // Inserting @import rule after a non-import rule is not allowed. if (rule->isImportRule()) { ec = HIERARCHY_REQUEST_ERR; return 0; } childVectorIndex -= m_importRules.size(); m_childRules.insert(childVectorIndex, rule.release()); success: if (!m_childRuleCSSOMWrappers.isEmpty()) m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>()); // FIXME: Stylesheet doesn't actually change meaningfully before the imported sheets are loaded. styleSheetChanged(); return index; }
void CSSStyleSheet::deleteRule(unsigned index, ExceptionCode& ec) { if (index >= length()) { ec = INDEX_SIZE_ERR; return; } ec = 0; remove(index); styleSheetChanged(); }
void CSSStyleSheet::deleteRule(unsigned index, ExceptionCode& ec) { if (index >= length()) { ec = INDEX_SIZE_ERR; return; } ec = 0; item(index)->setParent(0); m_children.remove(index); styleSheetChanged(); }
unsigned CSSStyleSheet::insertRule(const String& rule, unsigned index, ExceptionCode& ec) { ec = 0; if (index > length()) { ec = INDEX_SIZE_ERR; return 0; } CSSParser p(useStrictParsing()); RefPtr<CSSRule> r = p.parseRule(this, rule); if (!r) { ec = SYNTAX_ERR; return 0; } // Throw a HIERARCHY_REQUEST_ERR exception if the rule cannot be inserted at the specified index. The best // example of this is an @import rule inserted after regular rules. if (index > 0) { if (r->isImportRule()) { // Check all the rules that come before this one to make sure they are only @charset and @import rules. for (unsigned i = 0; i < index; ++i) { if (!item(i)->isCharsetRule() && !item(i)->isImportRule()) { ec = HIERARCHY_REQUEST_ERR; return 0; } } } else if (r->isCharsetRule()) { // The @charset rule has to come first and there can be only one. ec = HIERARCHY_REQUEST_ERR; return 0; } } CSSRule* c = r.get(); m_children.insert(index, r.release()); c->insertedIntoParent(); styleSheetChanged(); return index; }
unsigned CSSStyleSheet::insertRule(const String& rule, unsigned index, ExceptionCode& ec) { ec = 0; if (index > length()) { ec = INDEX_SIZE_ERR; return 0; } CSSParser p(useStrictParsing()); RefPtr<CSSRule> r = p.parseRule(this, rule); if (!r) { ec = SYNTAX_ERR; return 0; } // ### // 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. insert(index, r.release()); styleSheetChanged(); return index; }