| 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, 2008, 2009, 2010, 2012 Apple Inc. All rights
reserved. | 3 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 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 27 matching lines...) Expand all Loading... |
| 38 class CSSStyleSheet; | 38 class CSSStyleSheet; |
| 39 class Document; | 39 class Document; |
| 40 class Node; | 40 class Node; |
| 41 class StyleRuleBase; | 41 class StyleRuleBase; |
| 42 class StyleRuleFontFace; | 42 class StyleRuleFontFace; |
| 43 | 43 |
| 44 class StyleSheetContents : public RefCounted<StyleSheetContents> { | 44 class StyleSheetContents : public RefCounted<StyleSheetContents> { |
| 45 public: | 45 public: |
| 46 static PassRefPtr<StyleSheetContents> create(const CSSParserContext& context
) | 46 static PassRefPtr<StyleSheetContents> create(const CSSParserContext& context
) |
| 47 { | 47 { |
| 48 return adoptRef(new StyleSheetContents(String(), context)); | 48 return adoptRef(new StyleSheetContents(context)); |
| 49 } | |
| 50 static PassRefPtr<StyleSheetContents> create(const String& originalURL, cons
t CSSParserContext& context) | |
| 51 { | |
| 52 return adoptRef(new StyleSheetContents(originalURL, context)); | |
| 53 } | 49 } |
| 54 | 50 |
| 55 ~StyleSheetContents(); | 51 ~StyleSheetContents(); |
| 56 | 52 |
| 57 const CSSParserContext& parserContext() const { return m_parserContext; } | 53 const CSSParserContext& parserContext() const { return m_parserContext; } |
| 58 | 54 |
| 59 bool parseString(const String&); | 55 bool parseString(const String&); |
| 60 bool parseStringAtPosition(const String&, const TextPosition&, bool); | 56 bool parseStringAtPosition(const String&, const TextPosition&, bool); |
| 61 | 57 |
| 62 bool isCacheable() const; | |
| 63 | |
| 64 bool hasSingleOwnerNode() const; | 58 bool hasSingleOwnerNode() const; |
| 65 Node* singleOwnerNode() const; | 59 Node* singleOwnerNode() const; |
| 66 Document* singleOwnerDocument() const; | 60 Document* singleOwnerDocument() const; |
| 67 | 61 |
| 68 KURL completeURL(const String& url) const; | |
| 69 | |
| 70 void parserAppendRule(PassRefPtr<StyleRuleBase>); | 62 void parserAppendRule(PassRefPtr<StyleRuleBase>); |
| 71 void parserSetUsesRemUnits(bool b) { m_usesRemUnits = b; } | 63 void parserSetUsesRemUnits(bool b) { m_usesRemUnits = b; } |
| 72 | 64 |
| 73 void clearRules(); | 65 void clearRules(); |
| 74 | 66 |
| 75 // Rules other than @charset and @import. | 67 // Rules other than @charset and @import. |
| 76 const Vector<RefPtr<StyleRuleBase> >& childRules() const { return m_childRul
es; } | 68 const Vector<RefPtr<StyleRuleBase> >& childRules() const { return m_childRul
es; } |
| 77 | 69 |
| 78 // Note that href is the URL that started the redirect chain that led to | |
| 79 // this style sheet. This property probably isn't useful for much except | |
| 80 // the JavaScript binding (which needs to use this value for security). | |
| 81 String originalURL() const { return m_originalURL; } | |
| 82 const KURL& baseURL() const { return m_parserContext.baseURL(); } | |
| 83 | |
| 84 unsigned ruleCount() const; | 70 unsigned ruleCount() const; |
| 85 StyleRuleBase* ruleAt(unsigned index) const; | 71 StyleRuleBase* ruleAt(unsigned index) const; |
| 86 | 72 |
| 87 bool usesRemUnits() const { return m_usesRemUnits; } | 73 bool usesRemUnits() const { return m_usesRemUnits; } |
| 88 | 74 |
| 89 void registerClient(CSSStyleSheet*); | 75 void registerClient(CSSStyleSheet*); |
| 90 void unregisterClient(CSSStyleSheet*); | 76 void unregisterClient(CSSStyleSheet*); |
| 91 size_t clientSize() const { return m_loadingClients.size() + m_completedClie
nts.size(); } | 77 size_t clientSize() const { return m_loadingClients.size() + m_completedClie
nts.size(); } |
| 92 bool hasOneClient() const { return clientSize() == 1; } | 78 bool hasOneClient() const { return clientSize() == 1; } |
| 93 | 79 |
| 94 void removeSheetFromCache(Document*); | 80 void removeSheetFromCache(Document*); |
| 95 | 81 |
| 96 void setHasMediaQueries(); | 82 void setHasMediaQueries(); |
| 97 bool hasMediaQueries() const { return m_hasMediaQueries; } | 83 bool hasMediaQueries() const { return m_hasMediaQueries; } |
| 98 | 84 |
| 99 void shrinkToFit(); | 85 void shrinkToFit(); |
| 100 RuleSet& ruleSet() { ASSERT(m_ruleSet); return *m_ruleSet.get(); } | 86 RuleSet& ruleSet() { ASSERT(m_ruleSet); return *m_ruleSet.get(); } |
| 101 RuleSet& ensureRuleSet(const MediaQueryEvaluator&, AddRuleFlags); | 87 RuleSet& ensureRuleSet(const MediaQueryEvaluator&, AddRuleFlags); |
| 102 void clearRuleSet(); | 88 void clearRuleSet(); |
| 103 | 89 |
| 104 private: | 90 private: |
| 105 StyleSheetContents(const String& originalURL, const CSSParserContext&); | 91 explicit StyleSheetContents(const CSSParserContext&); |
| 106 | 92 |
| 107 void notifyRemoveFontFaceRule(const StyleRuleFontFace*); | 93 void notifyRemoveFontFaceRule(const StyleRuleFontFace*); |
| 108 | 94 |
| 109 Document* clientSingleOwnerDocument() const; | 95 Document* clientSingleOwnerDocument() const; |
| 110 | 96 |
| 111 bool m_usesRemUnits : 1; | 97 bool m_usesRemUnits : 1; |
| 112 bool m_hasMediaQueries : 1; | 98 bool m_hasMediaQueries : 1; |
| 113 bool m_hasSingleOwnerDocument : 1; | 99 bool m_hasSingleOwnerDocument : 1; |
| 114 | 100 |
| 115 String m_originalURL; | |
| 116 OwnPtr<RuleSet> m_ruleSet; | 101 OwnPtr<RuleSet> m_ruleSet; |
| 117 Vector<RefPtr<StyleRuleBase> > m_childRules; | 102 Vector<RefPtr<StyleRuleBase> > m_childRules; |
| 118 CSSParserContext m_parserContext; | 103 CSSParserContext m_parserContext; |
| 119 | 104 |
| 120 HashSet<RawPtr<CSSStyleSheet> > m_loadingClients; | 105 HashSet<RawPtr<CSSStyleSheet> > m_loadingClients; |
| 121 HashSet<RawPtr<CSSStyleSheet> > m_completedClients; | 106 HashSet<RawPtr<CSSStyleSheet> > m_completedClients; |
| 122 typedef HashSet<RawPtr<CSSStyleSheet> >::iterator ClientsIterator; | 107 typedef HashSet<RawPtr<CSSStyleSheet> >::iterator ClientsIterator; |
| 123 }; | 108 }; |
| 124 | 109 |
| 125 } // namespace | 110 } // namespace |
| 126 | 111 |
| 127 #endif // SKY_ENGINE_CORE_CSS_STYLESHEETCONTENTS_H_ | 112 #endif // SKY_ENGINE_CORE_CSS_STYLESHEETCONTENTS_H_ |
| OLD | NEW |