Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 } | 319 } |
| 320 | 320 |
| 321 const AtomicString& StyleSheetContents::namespaceURIFromPrefix( | 321 const AtomicString& StyleSheetContents::namespaceURIFromPrefix( |
| 322 const AtomicString& prefix) { | 322 const AtomicString& prefix) { |
| 323 return m_namespaces.get(prefix); | 323 return m_namespaces.get(prefix); |
| 324 } | 324 } |
| 325 | 325 |
| 326 void StyleSheetContents::parseAuthorStyleSheet( | 326 void StyleSheetContents::parseAuthorStyleSheet( |
| 327 const CSSStyleSheetResource* cachedStyleSheet, | 327 const CSSStyleSheetResource* cachedStyleSheet, |
| 328 const SecurityOrigin* securityOrigin) { | 328 const SecurityOrigin* securityOrigin) { |
| 329 // All StyleSheetContents are first parsed with a single owner document and | |
| 330 // node. This guarantees us that we will always have a valid document for use | |
| 331 // counting. | |
| 332 DCHECK(hasSingleOwnerDocument()); | |
| 333 DCHECK(hasSingleOwnerNode()); | |
| 334 | |
| 329 TRACE_EVENT1("blink,devtools.timeline", "ParseAuthorStyleSheet", "data", | 335 TRACE_EVENT1("blink,devtools.timeline", "ParseAuthorStyleSheet", "data", |
| 330 InspectorParseAuthorStyleSheetEvent::data(cachedStyleSheet)); | 336 InspectorParseAuthorStyleSheetEvent::data(cachedStyleSheet)); |
| 331 double startTimeMS = monotonicallyIncreasingTimeMS(); | 337 double startTimeMS = monotonicallyIncreasingTimeMS(); |
| 332 | 338 |
| 333 bool isSameOriginRequest = | 339 bool isSameOriginRequest = |
| 334 securityOrigin && securityOrigin->canRequest(baseURL()); | 340 securityOrigin && securityOrigin->canRequest(baseURL()); |
| 335 | 341 |
| 336 // When the response was fetched via the Service Worker, the original URL may | 342 // When the response was fetched via the Service Worker, the original URL may |
| 337 // not be same as the base URL. | 343 // not be same as the base URL. |
| 338 // TODO(horo): When we will use the original URL as the base URL, we can | 344 // TODO(horo): When we will use the original URL as the base URL, we can |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 if (root->m_loadingClients.size()) | 490 if (root->m_loadingClients.size()) |
| 485 return (*root->m_loadingClients.begin())->ownerNode(); | 491 return (*root->m_loadingClients.begin())->ownerNode(); |
| 486 return (*root->m_completedClients.begin())->ownerNode(); | 492 return (*root->m_completedClients.begin())->ownerNode(); |
| 487 } | 493 } |
| 488 | 494 |
| 489 Document* StyleSheetContents::singleOwnerDocument() const { | 495 Document* StyleSheetContents::singleOwnerDocument() const { |
| 490 StyleSheetContents* root = rootStyleSheet(); | 496 StyleSheetContents* root = rootStyleSheet(); |
| 491 return root->clientSingleOwnerDocument(); | 497 return root->clientSingleOwnerDocument(); |
| 492 } | 498 } |
| 493 | 499 |
| 500 Document* StyleSheetContents::anyOwnerDocument() const { | |
| 501 return rootStyleSheet()->clientAnyOwnerDocument(); | |
| 502 } | |
| 503 | |
| 494 static bool childRulesHaveFailedOrCanceledSubresources( | 504 static bool childRulesHaveFailedOrCanceledSubresources( |
| 495 const HeapVector<Member<StyleRuleBase>>& rules) { | 505 const HeapVector<Member<StyleRuleBase>>& rules) { |
| 496 for (unsigned i = 0; i < rules.size(); ++i) { | 506 for (unsigned i = 0; i < rules.size(); ++i) { |
| 497 const StyleRuleBase* rule = rules[i].get(); | 507 const StyleRuleBase* rule = rules[i].get(); |
| 498 switch (rule->type()) { | 508 switch (rule->type()) { |
| 499 case StyleRuleBase::Style: | 509 case StyleRuleBase::Style: |
| 500 if (toStyleRule(rule)->propertiesHaveFailedOrCanceledSubresources()) | 510 if (toStyleRule(rule)->propertiesHaveFailedOrCanceledSubresources()) |
| 501 return true; | 511 return true; |
| 502 break; | 512 break; |
| 503 case StyleRuleBase::FontFace: | 513 case StyleRuleBase::FontFace: |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 524 } | 534 } |
| 525 } | 535 } |
| 526 return false; | 536 return false; |
| 527 } | 537 } |
| 528 | 538 |
| 529 bool StyleSheetContents::hasFailedOrCanceledSubresources() const { | 539 bool StyleSheetContents::hasFailedOrCanceledSubresources() const { |
| 530 ASSERT(isCacheableForResource()); | 540 ASSERT(isCacheableForResource()); |
| 531 return childRulesHaveFailedOrCanceledSubresources(m_childRules); | 541 return childRulesHaveFailedOrCanceledSubresources(m_childRules); |
| 532 } | 542 } |
| 533 | 543 |
| 544 Document* StyleSheetContents::clientAnyOwnerDocument() const { | |
| 545 if (clientSize() <= 0) | |
| 546 return nullptr; | |
| 547 return m_loadingClients.size() | |
| 548 ? (*m_loadingClients.begin())->ownerDocument() | |
| 549 : (*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.
| |
| 550 } | |
| 551 | |
| 534 Document* StyleSheetContents::clientSingleOwnerDocument() const { | 552 Document* StyleSheetContents::clientSingleOwnerDocument() const { |
| 535 if (!m_hasSingleOwnerDocument || clientSize() <= 0) | 553 return m_hasSingleOwnerDocument ? clientAnyOwnerDocument() : nullptr; |
| 536 return nullptr; | |
| 537 | |
| 538 if (m_loadingClients.size()) | |
| 539 return (*m_loadingClients.begin())->ownerDocument(); | |
| 540 return (*m_completedClients.begin())->ownerDocument(); | |
| 541 } | 554 } |
| 542 | 555 |
| 543 StyleSheetContents* StyleSheetContents::parentStyleSheet() const { | 556 StyleSheetContents* StyleSheetContents::parentStyleSheet() const { |
| 544 return m_ownerRule ? m_ownerRule->parentStyleSheet() : nullptr; | 557 return m_ownerRule ? m_ownerRule->parentStyleSheet() : nullptr; |
| 545 } | 558 } |
| 546 | 559 |
| 547 void StyleSheetContents::registerClient(CSSStyleSheet* sheet) { | 560 void StyleSheetContents::registerClient(CSSStyleSheet* sheet) { |
| 548 ASSERT(!m_loadingClients.contains(sheet) && | 561 ASSERT(!m_loadingClients.contains(sheet) && |
| 549 !m_completedClients.contains(sheet)); | 562 !m_completedClients.contains(sheet)); |
| 550 | 563 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 685 visitor->trace(m_importRules); | 698 visitor->trace(m_importRules); |
| 686 visitor->trace(m_namespaceRules); | 699 visitor->trace(m_namespaceRules); |
| 687 visitor->trace(m_childRules); | 700 visitor->trace(m_childRules); |
| 688 visitor->trace(m_loadingClients); | 701 visitor->trace(m_loadingClients); |
| 689 visitor->trace(m_completedClients); | 702 visitor->trace(m_completedClients); |
| 690 visitor->trace(m_ruleSet); | 703 visitor->trace(m_ruleSet); |
| 691 visitor->trace(m_referencedFromResource); | 704 visitor->trace(m_referencedFromResource); |
| 692 } | 705 } |
| 693 | 706 |
| 694 } // namespace blink | 707 } // namespace blink |
| OLD | NEW |