Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Unified Diff: third_party/WebKit/Source/core/dom/StyleEngine.cpp

Issue 2835183002: Provide a method to remove inserted style sheet (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/StyleEngine.cpp
diff --git a/third_party/WebKit/Source/core/dom/StyleEngine.cpp b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
index 720758e56148c3a9fe66b32955bfca3e56c998c1..bc1a1699c3a8ca0908af62442f074942b3e343bc 100644
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
@@ -155,10 +155,24 @@ void StyleEngine::UpdateStyleSheetList(TreeScope& tree_scope) {
DCHECK(!all_tree_scopes_dirty_);
}
-void StyleEngine::InjectAuthorSheet(StyleSheetContents* author_sheet) {
- injected_author_style_sheets_.push_back(TraceWrapperMember<CSSStyleSheet>(
- this, CSSStyleSheet::Create(author_sheet, *document_)));
+WebStyleSheetId StyleEngine::InjectAuthorSheet(
+ StyleSheetContents* author_sheet) {
+ injected_author_style_sheets_.push_back(std::make_pair(
+ ++injected_author_sheets_id_count_,
+ TraceWrapperMember<CSSStyleSheet>(
+ this, CSSStyleSheet::Create(author_sheet, *document_))));
+
MarkDocumentDirty();
+ return injected_author_sheets_id_count_;
+}
+
+void StyleEngine::RemoveInjectedAuthorSheet(WebStyleSheetId author_sheet_id) {
+ for (size_t i = 0; i < injected_author_style_sheets_.size(); ++i) {
+ if (injected_author_style_sheets_[i].first == author_sheet_id) {
+ injected_author_style_sheets_.erase(i);
+ MarkDocumentDirty();
+ }
+ }
}
CSSStyleSheet& StyleEngine::EnsureInspectorStyleSheet() {
@@ -1230,8 +1244,8 @@ DEFINE_TRACE(StyleEngine) {
}
DEFINE_TRACE_WRAPPERS(StyleEngine) {
- for (auto sheet : injected_author_style_sheets_) {
- visitor->TraceWrappers(sheet);
+ for (const auto& sheet : injected_author_style_sheets_) {
+ visitor->TraceWrappers(sheet.second);
}
visitor->TraceWrappers(document_style_sheet_collection_);
}
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | third_party/WebKit/Source/core/dom/StyleEngineTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698