void StyleSheetContents::wrapperDeleteRule(unsigned index) { ASSERT(m_isMutable); ASSERT_WITH_SECURITY_IMPLICATION(index < ruleCount()); unsigned childVectorIndex = index; if (hasCharsetRule()) { if (childVectorIndex == 0) { clearCharsetRule(); return; } --childVectorIndex; } if (childVectorIndex < m_importRules.size()) { m_importRules[childVectorIndex]->clearParentStyleSheet(); if (m_importRules[childVectorIndex]->isFontFaceRule()) notifyRemoveFontFaceRule(toStyleRuleFontFace(m_importRules[childVectorIndex].get())); m_importRules.remove(childVectorIndex); return; } childVectorIndex -= m_importRules.size(); if (m_childRules[childVectorIndex]->isFontFaceRule()) notifyRemoveFontFaceRule(toStyleRuleFontFace(m_childRules[childVectorIndex].get())); m_childRules.remove(childVectorIndex); }
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 StyleSheetContents::clearRules() { for (unsigned i = 0; i < m_importRules.size(); ++i) { ASSERT(m_importRules.at(i)->parentStyleSheet() == this); m_importRules[i]->clearParentStyleSheet(); } m_importRules.clear(); m_childRules.clear(); clearCharsetRule(); }
void CSSStyleSheet::clearRules() { // For style rules outside the document, .parentStyleSheet can become null even if the style rule // is still observable from JavaScript. This matches the behavior of .parentNode for nodes, but // it's not ideal because it makes the CSSOM's behavior depend on the timing of garbage collection. for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) { if (m_childRuleCSSOMWrappers[i]) m_childRuleCSSOMWrappers[i]->setParentStyleSheet(0); } m_childRuleCSSOMWrappers.clear(); for (unsigned i = 0; i < m_importRules.size(); ++i) { ASSERT(m_importRules.at(i)->parentStyleSheet() == this); m_importRules[i]->clearParentStyleSheet(); } m_importRules.clear(); m_childRules.clear(); clearCharsetRule(); }
void StyleSheetContents::wrapperDeleteRule(unsigned index) { ASSERT(m_isMutable); ASSERT(index < ruleCount()); unsigned childVectorIndex = index; if (hasCharsetRule()) { if (childVectorIndex == 0) { clearCharsetRule(); return; } --childVectorIndex; } if (childVectorIndex < m_importRules.size()) { m_importRules.remove(childVectorIndex); return; } childVectorIndex -= m_importRules.size(); m_childRules.remove(childVectorIndex); }
void StyleSheetContents::clearRules() { m_importRules.clear(); m_childRules.clear(); clearCharsetRule(); }