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

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

Issue 2835183002: Provide a method to remove inserted style sheet (Closed)
Patch Set: review feedback 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 0634c6ef6687e915f7a688860400b3aca78550f3..9d10e578b316779a59e87ce8ddd7a11ff435cd48 100644
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
@@ -136,10 +136,23 @@ StyleEngine::StyleSheetsForStyleSheetList(TreeScope& tree_scope) {
->StyleSheetsForStyleSheetList();
}
-void StyleEngine::InjectAuthorSheet(StyleSheetContents* author_sheet) {
- injected_author_style_sheets_.push_back(TraceWrapperMember<CSSStyleSheet>(
- this, CSSStyleSheet::Create(author_sheet, *document_)));
+unsigned 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(unsigned 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() {
@@ -1175,8 +1188,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_);
}

Powered by Google App Engine
This is Rietveld 408576698