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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 StyleSheetContents::StyleSheetContents(StyleRuleImport* ownerRule, const String& originalURL, const CSSParserContext& context) | 58 StyleSheetContents::StyleSheetContents(StyleRuleImport* ownerRule, const String& originalURL, const CSSParserContext& context) |
59 : m_ownerRule(ownerRule) | 59 : m_ownerRule(ownerRule) |
60 , m_originalURL(originalURL) | 60 , m_originalURL(originalURL) |
61 , m_defaultNamespace(starAtom) | 61 , m_defaultNamespace(starAtom) |
62 , m_hasSyntacticallyValidCSSHeader(true) | 62 , m_hasSyntacticallyValidCSSHeader(true) |
63 , m_didLoadErrorOccur(false) | 63 , m_didLoadErrorOccur(false) |
64 , m_isMutable(false) | 64 , m_isMutable(false) |
65 , m_hasFontFaceRule(false) | 65 , m_hasFontFaceRule(false) |
66 , m_hasMediaQueries(false) | 66 , m_hasMediaQueries(false) |
67 , m_hasSingleOwnerDocument(true) | 67 , m_hasSingleOwnerDocument(true) |
68 , m_isUsedFromTextCache(false) | |
68 , m_parserContext(context) | 69 , m_parserContext(context) |
69 { | 70 { |
70 } | 71 } |
71 | 72 |
72 StyleSheetContents::StyleSheetContents(const StyleSheetContents& o) | 73 StyleSheetContents::StyleSheetContents(const StyleSheetContents& o) |
73 : m_ownerRule(nullptr) | 74 : m_ownerRule(nullptr) |
74 , m_originalURL(o.m_originalURL) | 75 , m_originalURL(o.m_originalURL) |
75 , m_importRules(o.m_importRules.size()) | 76 , m_importRules(o.m_importRules.size()) |
76 , m_namespaceRules(o.m_namespaceRules.size()) | 77 , m_namespaceRules(o.m_namespaceRules.size()) |
77 , m_childRules(o.m_childRules.size()) | 78 , m_childRules(o.m_childRules.size()) |
78 , m_namespaces(o.m_namespaces) | 79 , m_namespaces(o.m_namespaces) |
79 , m_defaultNamespace(o.m_defaultNamespace) | 80 , m_defaultNamespace(o.m_defaultNamespace) |
80 , m_hasSyntacticallyValidCSSHeader(o.m_hasSyntacticallyValidCSSHeader) | 81 , m_hasSyntacticallyValidCSSHeader(o.m_hasSyntacticallyValidCSSHeader) |
81 , m_didLoadErrorOccur(false) | 82 , m_didLoadErrorOccur(false) |
82 , m_isMutable(false) | 83 , m_isMutable(false) |
83 , m_hasFontFaceRule(o.m_hasFontFaceRule) | 84 , m_hasFontFaceRule(o.m_hasFontFaceRule) |
84 , m_hasMediaQueries(o.m_hasMediaQueries) | 85 , m_hasMediaQueries(o.m_hasMediaQueries) |
85 , m_hasSingleOwnerDocument(true) | 86 , m_hasSingleOwnerDocument(true) |
87 , m_isUsedFromTextCache(false) | |
86 , m_parserContext(o.m_parserContext) | 88 , m_parserContext(o.m_parserContext) |
87 { | 89 { |
88 // FIXME: Copy import rules. | 90 // FIXME: Copy import rules. |
89 ASSERT(o.m_importRules.isEmpty()); | 91 ASSERT(o.m_importRules.isEmpty()); |
90 | 92 |
91 for (unsigned i = 0; i < m_childRules.size(); ++i) | 93 for (unsigned i = 0; i < m_childRules.size(); ++i) |
92 m_childRules[i] = o.m_childRules[i]->copy(); | 94 m_childRules[i] = o.m_childRules[i]->copy(); |
93 } | 95 } |
94 | 96 |
95 StyleSheetContents::~StyleSheetContents() | 97 StyleSheetContents::~StyleSheetContents() |
96 { | 98 { |
97 } | 99 } |
98 | 100 |
99 void StyleSheetContents::setHasSyntacticallyValidCSSHeader(bool isValidCss) | 101 void StyleSheetContents::setHasSyntacticallyValidCSSHeader(bool isValidCss) |
100 { | 102 { |
101 if (!isValidCss) { | |
102 if (Document* document = clientSingleOwnerDocument()) | |
103 removeSheetFromCache(document); | |
haraken
2016/08/03 01:01:18
For example, don't you need to explicitly remove t
rune
2016/08/03 09:20:05
I think that removeSheetFromCache here never remov
| |
104 } | |
105 m_hasSyntacticallyValidCSSHeader = isValidCss; | 103 m_hasSyntacticallyValidCSSHeader = isValidCss; |
106 } | 104 } |
107 | 105 |
108 bool StyleSheetContents::isCacheableForResource() const | 106 bool StyleSheetContents::isCacheableForResource() const |
109 { | 107 { |
110 // This would require dealing with multiple clients for load callbacks. | 108 // This would require dealing with multiple clients for load callbacks. |
111 if (!loadCompleted()) | 109 if (!loadCompleted()) |
112 return false; | 110 return false; |
113 // FIXME: StyleSheets with media queries can't be cached because their RuleS et | 111 // FIXME: StyleSheets with media queries can't be cached because their RuleS et |
114 // is processed differently based off the media queries, which might resolve | 112 // is processed differently based off the media queries, which might resolve |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 } | 537 } |
540 | 538 |
541 void StyleSheetContents::unregisterClient(CSSStyleSheet* sheet) | 539 void StyleSheetContents::unregisterClient(CSSStyleSheet* sheet) |
542 { | 540 { |
543 m_loadingClients.remove(sheet); | 541 m_loadingClients.remove(sheet); |
544 m_completedClients.remove(sheet); | 542 m_completedClients.remove(sheet); |
545 | 543 |
546 if (!sheet->ownerDocument() || !m_loadingClients.isEmpty() || !m_completedCl ients.isEmpty()) | 544 if (!sheet->ownerDocument() || !m_loadingClients.isEmpty() || !m_completedCl ients.isEmpty()) |
547 return; | 545 return; |
548 | 546 |
549 if (m_hasSingleOwnerDocument) | |
550 removeSheetFromCache(sheet->ownerDocument()); | |
551 m_hasSingleOwnerDocument = true; | 547 m_hasSingleOwnerDocument = true; |
552 } | 548 } |
553 | 549 |
554 void StyleSheetContents::clientLoadCompleted(CSSStyleSheet* sheet) | 550 void StyleSheetContents::clientLoadCompleted(CSSStyleSheet* sheet) |
555 { | 551 { |
556 ASSERT(m_loadingClients.contains(sheet) || !sheet->ownerDocument()); | 552 ASSERT(m_loadingClients.contains(sheet) || !sheet->ownerDocument()); |
557 m_loadingClients.remove(sheet); | 553 m_loadingClients.remove(sheet); |
558 // In m_ownerNode->sheetLoaded, the CSSStyleSheet might be detached. | 554 // In m_ownerNode->sheetLoaded, the CSSStyleSheet might be detached. |
559 // (i.e. clearOwnerNode was invoked.) | 555 // (i.e. clearOwnerNode was invoked.) |
560 // In this case, we don't need to add the stylesheet to completed clients. | 556 // In this case, we don't need to add the stylesheet to completed clients. |
561 if (!sheet->ownerDocument()) | 557 if (!sheet->ownerDocument()) |
562 return; | 558 return; |
563 m_completedClients.add(sheet); | 559 m_completedClients.add(sheet); |
564 } | 560 } |
565 | 561 |
566 void StyleSheetContents::clientLoadStarted(CSSStyleSheet* sheet) | 562 void StyleSheetContents::clientLoadStarted(CSSStyleSheet* sheet) |
567 { | 563 { |
568 ASSERT(m_completedClients.contains(sheet)); | 564 ASSERT(m_completedClients.contains(sheet)); |
569 m_completedClients.remove(sheet); | 565 m_completedClients.remove(sheet); |
570 m_loadingClients.add(sheet); | 566 m_loadingClients.add(sheet); |
571 } | 567 } |
572 | 568 |
573 void StyleSheetContents::removeSheetFromCache(Document* document) | |
574 { | |
575 ASSERT(document); | |
576 document->styleEngine().removeSheet(this); | |
577 } | |
578 | |
579 void StyleSheetContents::setReferencedFromResource(CSSStyleSheetResource* resour ce) | 569 void StyleSheetContents::setReferencedFromResource(CSSStyleSheetResource* resour ce) |
580 { | 570 { |
581 DCHECK(resource); | 571 DCHECK(resource); |
582 DCHECK(!isReferencedFromResource()); | 572 DCHECK(!isReferencedFromResource()); |
583 DCHECK(isCacheableForResource()); | 573 DCHECK(isCacheableForResource()); |
584 m_referencedFromResource = resource; | 574 m_referencedFromResource = resource; |
585 } | 575 } |
586 | 576 |
587 void StyleSheetContents::clearReferencedFromResource() | 577 void StyleSheetContents::clearReferencedFromResource() |
588 { | 578 { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
674 visitor->trace(m_importRules); | 664 visitor->trace(m_importRules); |
675 visitor->trace(m_namespaceRules); | 665 visitor->trace(m_namespaceRules); |
676 visitor->trace(m_childRules); | 666 visitor->trace(m_childRules); |
677 visitor->trace(m_loadingClients); | 667 visitor->trace(m_loadingClients); |
678 visitor->trace(m_completedClients); | 668 visitor->trace(m_completedClients); |
679 visitor->trace(m_ruleSet); | 669 visitor->trace(m_ruleSet); |
680 visitor->trace(m_referencedFromResource); | 670 visitor->trace(m_referencedFromResource); |
681 } | 671 } |
682 | 672 |
683 } // namespace blink | 673 } // namespace blink |
OLD | NEW |