| 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 m_didLoadErrorOccur |= sheet->errorOccurred(); | 422 m_didLoadErrorOccur |= sheet->errorOccurred(); |
| 423 // updateLayoutIgnorePendingStyleSheets can cause us to create the RuleSet o
n this | 423 // updateLayoutIgnorePendingStyleSheets can cause us to create the RuleSet o
n this |
| 424 // sheet before its imports have loaded. So clear the RuleSet when the impor
ts | 424 // sheet before its imports have loaded. So clear the RuleSet when the impor
ts |
| 425 // load since the import's subrules are flattened into its parent sheet's Ru
leSet. | 425 // load since the import's subrules are flattened into its parent sheet's Ru
leSet. |
| 426 clearRuleSet(); | 426 clearRuleSet(); |
| 427 } | 427 } |
| 428 | 428 |
| 429 void StyleSheetContents::startLoadingDynamicSheet() | 429 void StyleSheetContents::startLoadingDynamicSheet() |
| 430 { | 430 { |
| 431 StyleSheetContents* root = rootStyleSheet(); | 431 StyleSheetContents* root = rootStyleSheet(); |
| 432 for (ClientsIterator it = root->m_loadingClients.begin(); it != root->m_load
ingClients.end(); ++it) | 432 for (const auto& client : root->m_loadingClients) |
| 433 (*it)->startLoadingDynamicSheet(); | 433 client->startLoadingDynamicSheet(); |
| 434 // Copy the completed clients to a vector for iteration. | 434 // Copy the completed clients to a vector for iteration. |
| 435 // startLoadingDynamicSheet will move the style sheet from the | 435 // startLoadingDynamicSheet will move the style sheet from the |
| 436 // completed state to the loading state which modifies the set of | 436 // completed state to the loading state which modifies the set of |
| 437 // completed clients. We therefore need the copy in order to not | 437 // completed clients. We therefore need the copy in order to not |
| 438 // modify the set of completed clients while iterating it. | 438 // modify the set of completed clients while iterating it. |
| 439 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > completedClients; | 439 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > completedClients; |
| 440 copyToVector(root->m_completedClients, completedClients); | 440 copyToVector(root->m_completedClients, completedClients); |
| 441 for (unsigned i = 0; i < completedClients.size(); ++i) | 441 for (unsigned i = 0; i < completedClients.size(); ++i) |
| 442 completedClients[i]->startLoadingDynamicSheet(); | 442 completedClients[i]->startLoadingDynamicSheet(); |
| 443 } | 443 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 { | 608 { |
| 609 if (!m_ruleSet) { | 609 if (!m_ruleSet) { |
| 610 m_ruleSet = RuleSet::create(); | 610 m_ruleSet = RuleSet::create(); |
| 611 m_ruleSet->addRulesFromSheet(this, medium, addRuleFlags); | 611 m_ruleSet->addRulesFromSheet(this, medium, addRuleFlags); |
| 612 } | 612 } |
| 613 return *m_ruleSet.get(); | 613 return *m_ruleSet.get(); |
| 614 } | 614 } |
| 615 | 615 |
| 616 static void clearResolvers(WillBeHeapHashSet<RawPtrWillBeWeakMember<CSSStyleShee
t> >& clients) | 616 static void clearResolvers(WillBeHeapHashSet<RawPtrWillBeWeakMember<CSSStyleShee
t> >& clients) |
| 617 { | 617 { |
| 618 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<CSSStyleSheet> >::iterator it
= clients.begin(); it != clients.end(); ++it) { | 618 for (const auto& sheet : clients) { |
| 619 if (Document* document = (*it)->ownerDocument()) | 619 if (Document* document = sheet->ownerDocument()) |
| 620 document->styleEngine()->clearResolver(); | 620 document->styleEngine()->clearResolver(); |
| 621 } | 621 } |
| 622 } | 622 } |
| 623 | 623 |
| 624 void StyleSheetContents::clearRuleSet() | 624 void StyleSheetContents::clearRuleSet() |
| 625 { | 625 { |
| 626 if (StyleSheetContents* parentSheet = parentStyleSheet()) | 626 if (StyleSheetContents* parentSheet = parentStyleSheet()) |
| 627 parentSheet->clearRuleSet(); | 627 parentSheet->clearRuleSet(); |
| 628 | 628 |
| 629 // Don't want to clear the StyleResolver if the RuleSet hasn't been created | 629 // Don't want to clear the StyleResolver if the RuleSet hasn't been created |
| 630 // since we only clear the StyleResolver so that it's members are properly | 630 // since we only clear the StyleResolver so that it's members are properly |
| 631 // updated in ScopedStyleResolver::addRulesFromSheet. | 631 // updated in ScopedStyleResolver::addRulesFromSheet. |
| 632 if (!m_ruleSet) | 632 if (!m_ruleSet) |
| 633 return; | 633 return; |
| 634 | 634 |
| 635 // Clearing the ruleSet means we need to recreate the styleResolver data str
uctures. | 635 // Clearing the ruleSet means we need to recreate the styleResolver data str
uctures. |
| 636 // See the StyleResolver calls in ScopedStyleResolver::addRulesFromSheet. | 636 // See the StyleResolver calls in ScopedStyleResolver::addRulesFromSheet. |
| 637 clearResolvers(m_loadingClients); | 637 clearResolvers(m_loadingClients); |
| 638 clearResolvers(m_completedClients); | 638 clearResolvers(m_completedClients); |
| 639 m_ruleSet.clear(); | 639 m_ruleSet.clear(); |
| 640 } | 640 } |
| 641 | 641 |
| 642 static void removeFontFaceRules(WillBeHeapHashSet<RawPtrWillBeWeakMember<CSSStyl
eSheet> >& clients, const StyleRuleFontFace* fontFaceRule) | 642 static void removeFontFaceRules(WillBeHeapHashSet<RawPtrWillBeWeakMember<CSSStyl
eSheet> >& clients, const StyleRuleFontFace* fontFaceRule) |
| 643 { | 643 { |
| 644 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<CSSStyleSheet> >::iterator it
= clients.begin(); it != clients.end(); ++it) { | 644 for (const auto& sheet : clients) { |
| 645 if (Node* ownerNode = (*it)->ownerNode()) | 645 if (Node* ownerNode = sheet->ownerNode()) |
| 646 ownerNode->document().styleEngine()->removeFontFaceRules(WillBeHeapV
ector<RawPtrWillBeMember<const StyleRuleFontFace> >(1, fontFaceRule)); | 646 ownerNode->document().styleEngine()->removeFontFaceRules(WillBeHeapV
ector<RawPtrWillBeMember<const StyleRuleFontFace> >(1, fontFaceRule)); |
| 647 } | 647 } |
| 648 } | 648 } |
| 649 | 649 |
| 650 void StyleSheetContents::notifyRemoveFontFaceRule(const StyleRuleFontFace* fontF
aceRule) | 650 void StyleSheetContents::notifyRemoveFontFaceRule(const StyleRuleFontFace* fontF
aceRule) |
| 651 { | 651 { |
| 652 StyleSheetContents* root = rootStyleSheet(); | 652 StyleSheetContents* root = rootStyleSheet(); |
| 653 removeFontFaceRules(root->m_loadingClients, fontFaceRule); | 653 removeFontFaceRules(root->m_loadingClients, fontFaceRule); |
| 654 removeFontFaceRules(root->m_completedClients, fontFaceRule); | 654 removeFontFaceRules(root->m_completedClients, fontFaceRule); |
| 655 } | 655 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 visitor->trace(m_ownerRule); | 687 visitor->trace(m_ownerRule); |
| 688 visitor->trace(m_importRules); | 688 visitor->trace(m_importRules); |
| 689 visitor->trace(m_childRules); | 689 visitor->trace(m_childRules); |
| 690 visitor->trace(m_loadingClients); | 690 visitor->trace(m_loadingClients); |
| 691 visitor->trace(m_completedClients); | 691 visitor->trace(m_completedClients); |
| 692 visitor->trace(m_ruleSet); | 692 visitor->trace(m_ruleSet); |
| 693 #endif | 693 #endif |
| 694 } | 694 } |
| 695 | 695 |
| 696 } | 696 } |
| OLD | NEW |