Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/StyleSheetContents.cpp |
| diff --git a/third_party/WebKit/Source/core/css/StyleSheetContents.cpp b/third_party/WebKit/Source/core/css/StyleSheetContents.cpp |
| index be7d917df767513bc75e55fef728e24855593542..be199485ccd790933f278c6bae8578cab046fac3 100644 |
| --- a/third_party/WebKit/Source/core/css/StyleSheetContents.cpp |
| +++ b/third_party/WebKit/Source/core/css/StyleSheetContents.cpp |
| @@ -326,6 +326,12 @@ const AtomicString& StyleSheetContents::namespaceURIFromPrefix( |
| void StyleSheetContents::parseAuthorStyleSheet( |
| const CSSStyleSheetResource* cachedStyleSheet, |
| const SecurityOrigin* securityOrigin) { |
| + // All StyleSheetContents are first parsed with a single owner document and |
| + // node. This guarantees us that we will always have a valid document for use |
| + // counting. |
| + DCHECK(hasSingleOwnerDocument()); |
| + DCHECK(hasSingleOwnerNode()); |
| + |
| TRACE_EVENT1("blink,devtools.timeline", "ParseAuthorStyleSheet", "data", |
| InspectorParseAuthorStyleSheetEvent::data(cachedStyleSheet)); |
| double startTimeMS = monotonicallyIncreasingTimeMS(); |
| @@ -491,6 +497,10 @@ Document* StyleSheetContents::singleOwnerDocument() const { |
| return root->clientSingleOwnerDocument(); |
| } |
| +Document* StyleSheetContents::anyOwnerDocument() const { |
| + return rootStyleSheet()->clientAnyOwnerDocument(); |
| +} |
| + |
| static bool childRulesHaveFailedOrCanceledSubresources( |
| const HeapVector<Member<StyleRuleBase>>& rules) { |
| for (unsigned i = 0; i < rules.size(); ++i) { |
| @@ -531,13 +541,16 @@ bool StyleSheetContents::hasFailedOrCanceledSubresources() const { |
| return childRulesHaveFailedOrCanceledSubresources(m_childRules); |
| } |
| -Document* StyleSheetContents::clientSingleOwnerDocument() const { |
| - if (!m_hasSingleOwnerDocument || clientSize() <= 0) |
| +Document* StyleSheetContents::clientAnyOwnerDocument() const { |
| + if (clientSize() <= 0) |
| return nullptr; |
| + return m_loadingClients.size() |
| + ? (*m_loadingClients.begin())->ownerDocument() |
| + : (*m_completedClients.begin())->ownerDocument(); |
|
rune
2016/12/02 22:18:08
Nit: is the return rewrite due to the chromium cod
Charlie Harrison
2016/12/02 22:38:46
I can change it back, I was mostly just trying to
Charlie Harrison
2016/12/05 19:30:09
Done.
|
| +} |
| - if (m_loadingClients.size()) |
| - return (*m_loadingClients.begin())->ownerDocument(); |
| - return (*m_completedClients.begin())->ownerDocument(); |
| +Document* StyleSheetContents::clientSingleOwnerDocument() const { |
| + return m_hasSingleOwnerDocument ? clientAnyOwnerDocument() : nullptr; |
| } |
| StyleSheetContents* StyleSheetContents::parentStyleSheet() const { |