Chromium Code Reviews| 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..5eaca496d8c2fc955f8a86c1290a8b85dffc0f78 100644 |
| --- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
| +++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
| @@ -58,6 +58,7 @@ |
| #include "core/svg/SVGStyleElement.h" |
| #include "platform/fonts/FontCache.h" |
| #include "platform/instrumentation/tracing/TraceEvent.h" |
| +#include "platform/wtf/Atomics.h" |
| namespace blink { |
| @@ -136,10 +137,26 @@ 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_))); |
| +int StyleEngine::InjectAuthorSheet(StyleSheetContents* author_sheet) { |
| + AtomicIncrement(&injected_author_sheets_id_count_); |
|
rune
2017/05/16 09:00:58
StyleEngine is not made to be thread-safe. Why not
limasdf
2017/05/18 12:32:53
Done.
|
| + 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_; |
| +} |
| + |
| +bool StyleEngine::RemoveInjectedAuthorSheet(int id) { |
| + for (size_t i = 0; i < injected_author_style_sheets_.size(); ++i) { |
|
rune
2017/05/16 09:00:58
I suppose we can assume the number of injected she
|
| + if (injected_author_style_sheets_[i].first == id) { |
| + injected_author_style_sheets_.erase(i); |
| + MarkDocumentDirty(); |
| + return true; |
| + } |
| + } |
| + return false; |
| } |
| CSSStyleSheet& StyleEngine::EnsureInspectorStyleSheet() { |
| @@ -1175,8 +1192,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_); |
| } |