void CSSStyleSheet::willMutateRules() { // If we are the only client it is safe to mutate. if (m_contents->hasOneClient() && !m_contents->isInMemoryCache()) { m_contents->setMutable(); return; } // Only cacheable stylesheets should have multiple clients. ASSERT(m_contents->isCacheable()); // Copy-on-write. m_contents->unregisterClient(this); m_contents = m_contents->copy(); m_contents->registerClient(this); m_contents->setMutable(); // Any existing CSSOM wrappers need to be connected to the copied child rules. reattachChildRuleCSSOMWrappers(); }
void CSSStyleSheet::willMutateRules() { // If we are the only client it is safe to mutate. if (!m_contents->isUsedFromTextCache() && !m_contents->isReferencedFromResource()) { m_contents->clearRuleSet(); m_contents->setMutable(); return; } // Only cacheable stylesheets should have multiple clients. DCHECK(m_contents->isCacheableForStyleElement() || m_contents->isCacheableForResource()); // Copy-on-write. m_contents->unregisterClient(this); m_contents = m_contents->copy(); m_contents->registerClient(this); m_contents->setMutable(); // Any existing CSSOM wrappers need to be connected to the copied child rules. reattachChildRuleCSSOMWrappers(); }
void CSSStyleSheet::willMutateRules() { // If we are the only client it is safe to mutate. if (m_contents->clientSize() <= 1 && !m_contents->isReferencedFromResource()) { m_contents->clearRuleSet(); if (Document* document = ownerDocument()) m_contents->removeSheetFromCache(document); m_contents->setMutable(); return; } // Only cacheable stylesheets should have multiple clients. ASSERT((isStyleElement(ownerNode()) && m_contents->isCacheableForStyleElement()) || m_contents->isCacheableForResource()); // Copy-on-write. m_contents->unregisterClient(this); m_contents = m_contents->copy(); m_contents->registerClient(this); m_contents->setMutable(); // Any existing CSSOM wrappers need to be connected to the copied child rules. reattachChildRuleCSSOMWrappers(); }