void UserContentController::removeUserStyleSheet(DOMWrapperWorld& world, const URL& url) { if (!m_userStyleSheets) return; auto it = m_userStyleSheets->find(&world); if (it == m_userStyleSheets->end()) return; auto& stylesheets = *it->value; bool sheetsChanged = false; for (int i = stylesheets.size() - 1; i >= 0; --i) { if (stylesheets[i]->url() == url) { stylesheets.remove(i); sheetsChanged = true; } } if (!sheetsChanged) return; if (stylesheets.isEmpty()) m_userStyleSheets->remove(it); invalidateInjectedStyleSheetCacheInAllFrames(); }
void PageGroup::removeUserStyleSheetFromWorld(DOMWrapperWorld* world, const URL& url) { ASSERT_ARG(world, world); if (!m_userStyleSheets) return; UserStyleSheetMap::iterator it = m_userStyleSheets->find(world); bool sheetsChanged = false; if (it == m_userStyleSheets->end()) return; UserStyleSheetVector* stylesheets = it->value.get(); for (int i = stylesheets->size() - 1; i >= 0; --i) { if (stylesheets->at(i)->url() == url) { stylesheets->remove(i); sheetsChanged = true; } } if (!sheetsChanged) return; if (stylesheets->isEmpty()) m_userStyleSheets->remove(it); invalidateInjectedStyleSheetCacheInAllFrames(); }
void UserContentController::removeAllUserContent() { m_userScripts = nullptr; if (m_userStyleSheets) { m_userStyleSheets = nullptr; invalidateInjectedStyleSheetCacheInAllFrames(); } }
void PageGroup::removeAllUserContent() { m_userScripts.clear(); if (m_userStyleSheets) { m_userStyleSheets.clear(); invalidateInjectedStyleSheetCacheInAllFrames(); } }
void UserContentController::removeUserStyleSheets(DOMWrapperWorld& world) { if (!m_userStyleSheets) return; if (!m_userStyleSheets->remove(&world)) return; invalidateInjectedStyleSheetCacheInAllFrames(); }
void PageGroup::removeUserStyleSheetsFromWorld(DOMWrapperWorld* world) { ASSERT_ARG(world, world); if (!m_userStyleSheets) return; if (!m_userStyleSheets->remove(world)) return; invalidateInjectedStyleSheetCacheInAllFrames(); }
void UserContentController::addUserStyleSheet(DOMWrapperWorld& world, std::unique_ptr<UserStyleSheet> userStyleSheet, UserStyleInjectionTime injectionTime) { if (!m_userStyleSheets) m_userStyleSheets = std::make_unique<UserStyleSheetMap>(); auto& styleSheetsInWorld = m_userStyleSheets->add(&world, nullptr).iterator->value; if (!styleSheetsInWorld) styleSheetsInWorld = std::make_unique<UserStyleSheetVector>(); styleSheetsInWorld->append(WTF::move(userStyleSheet)); if (injectionTime == InjectInExistingDocuments) invalidateInjectedStyleSheetCacheInAllFrames(); }
void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld* world, const String& source, const URL& url, const Vector<String>& whitelist, const Vector<String>& blacklist, UserContentInjectedFrames injectedFrames, UserStyleLevel level, UserStyleInjectionTime injectionTime) { ASSERT_ARG(world, world); OwnPtr<UserStyleSheet> userStyleSheet = adoptPtr(new UserStyleSheet(source, url, whitelist, blacklist, injectedFrames, level)); if (!m_userStyleSheets) m_userStyleSheets = adoptPtr(new UserStyleSheetMap); OwnPtr<UserStyleSheetVector>& styleSheetsInWorld = m_userStyleSheets->add(world, nullptr).iterator->value; if (!styleSheetsInWorld) styleSheetsInWorld = adoptPtr(new UserStyleSheetVector); styleSheetsInWorld->append(userStyleSheet.release()); if (injectionTime == InjectInExistingDocuments) invalidateInjectedStyleSheetCacheInAllFrames(); }