| Differences between
and this patch
- Source/WebCore/ChangeLog +226 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2012-04-10  Antti Koivisto  <antti@apple.com>
2
3
        Split CSSStyleSheet into internal and CSSOM type
4
        https://bugs.webkit.org/show_bug.cgi?id=83612
5
        
6
        Reviewed by NOBODY (OOPS!).
7
8
        This will complete the separation of our style sheet data structures from CSSOM.
9
        
10
        The internal parts of CSSStyleSheet split into StyleSheetInternal. CSS parser
11
        and style selector will operate on internal types. Unline other CSSOM types
12
        CSSStyleSheets are still always instantiated to hold the top level author stylesheets
13
        (by Nodes) and act as interface from DOM types.
14
15
        * css/CSSFontFaceSrcValue.cpp:
16
        (WebCore::CSSFontFaceSrcValue::addSubresourceStyleURLs):
17
        * css/CSSFontFaceSrcValue.h:
18
        (CSSFontFaceSrcValue):
19
        * css/CSSImportRule.cpp:
20
        (WebCore::StyleRuleImport::create):
21
        (WebCore::StyleRuleImport::StyleRuleImport):
22
        (WebCore::StyleRuleImport::setCSSStyleSheet):
23
        (WebCore::StyleRuleImport::requestStyleSheet):
24
        (WebCore::CSSImportRule::~CSSImportRule):
25
        (WebCore):
26
        (WebCore::CSSImportRule::styleSheet):
27
        * css/CSSImportRule.h:
28
        (WebCore):
29
        (StyleRuleImport):
30
        (WebCore::StyleRuleImport::parentStyleSheet):
31
        (WebCore::StyleRuleImport::styleSheet):
32
        (CSSImportRule):
33
        * css/CSSMediaRule.cpp:
34
        (WebCore::CSSMediaRule::insertRule):
35
        * css/CSSParser.cpp:
36
        (WebCore::CSSParser::parseSheet):
37
        (WebCore::CSSParser::parseRule):
38
        (WebCore::CSSParser::parseKeyframeRule):
39
        (WebCore::CSSParser::parseFontFaceValue):
40
        (WebCore::CSSParser::parseValue):
41
        (WebCore::CSSParser::parseSelector):
42
        (WebCore::CSSParser::parseDeclaration):
43
        (WebCore::CSSParser::setStyleSheet):
44
        (WebCore::CSSParser::parseFlowThread):
45
        * css/CSSParser.h:
46
        (WebCore):
47
        (CSSParser):
48
        * css/CSSPrimitiveValue.cpp:
49
        (WebCore::CSSPrimitiveValue::addSubresourceStyleURLs):
50
        * css/CSSPrimitiveValue.h:
51
        (CSSPrimitiveValue):
52
        * css/CSSReflectValue.cpp:
53
        (WebCore::CSSReflectValue::addSubresourceStyleURLs):
54
        * css/CSSReflectValue.h:
55
        (CSSReflectValue):
56
        * css/CSSRule.h:
57
        (CSSRule):
58
        * css/CSSStyleSelector.cpp:
59
        (RuleSet):
60
        (WebCore):
61
        (WebCore::CSSStyleSelector::CSSStyleSelector):
62
        (WebCore::CSSStyleSelector::addAuthorRulesAndCollectUserRulesFromSheets):
63
        (WebCore::CSSStyleSelector::determineScope):
64
        (WebCore::CSSStyleSelector::appendAuthorStylesheets):
65
        (WebCore::parseUASheet):
66
        (WebCore::CSSStyleSelector::collectMatchingRulesForList):
67
        * css/CSSStyleSelector.h:
68
        (CSSStyleSelector):
69
        
70
            Add a set for root CSSStyleSheet objects so that the wrappers created in ensureFullCSSOMWrapperForInspector
71
            stay valid.
72
        
73
        * css/CSSStyleSheet.cpp:
74
        (WebCore::StyleSheetInternal::StyleSheetInternal):
75
        (WebCore::StyleSheetInternal::~StyleSheetInternal):
76
        (WebCore::StyleSheetInternal::parserAppendRule):
77
        (WebCore::StyleSheetInternal::createChildRuleCSSOMWrapper):
78
        (WebCore::StyleSheetInternal::ruleCount):
79
        (WebCore::StyleSheetInternal::clearCharsetRule):
80
        (WebCore::StyleSheetInternal::clearRules):
81
        (WebCore::StyleSheetInternal::parserSetEncodingFromCharsetRule):
82
        (WebCore::StyleSheetInternal::wrapperInsertRule):
83
        (WebCore::StyleSheetInternal::wrapperDeleteRule):
84
        (WebCore::StyleSheetInternal::addNamespace):
85
        (WebCore::StyleSheetInternal::determineNamespace):
86
        (WebCore::StyleSheetInternal::parseString):
87
        (WebCore::StyleSheetInternal::parseStringAtLine):
88
        (WebCore::StyleSheetInternal::isLoading):
89
        (WebCore::StyleSheetInternal::checkLoaded):
90
        (WebCore::StyleSheetInternal::notifyLoadedSheet):
91
        (WebCore::StyleSheetInternal::startLoadingDynamicSheet):
92
        (WebCore::StyleSheetInternal::findStyleSheetOwnerNode):
93
        (WebCore::StyleSheetInternal::findDocument):
94
        (WebCore::StyleSheetInternal::setMediaQueries):
95
        (WebCore::StyleSheetInternal::styleSheetChanged):
96
        (WebCore):
97
        (WebCore::StyleSheetInternal::baseURL):
98
        (WebCore::StyleSheetInternal::completeURL):
99
        (WebCore::StyleSheetInternal::addSubresourceStyleURLs):
100
        (WebCore::StyleSheetInternal::parentStyleSheet):
101
        (WebCore::CSSStyleSheet::CSSStyleSheet):
102
        (WebCore::CSSStyleSheet::~CSSStyleSheet):
103
        (WebCore::CSSStyleSheet::setDisabled):
104
        (WebCore::CSSStyleSheet::length):
105
        (WebCore::CSSStyleSheet::item):
106
        (WebCore::CSSStyleSheet::rules):
107
        (WebCore::CSSStyleSheet::insertRule):
108
        (WebCore::CSSStyleSheet::addRule):
109
        (WebCore::CSSStyleSheet::cssRules):
110
        (WebCore::CSSStyleSheet::deleteRule):
111
        (WebCore::CSSStyleSheet::media):
112
        (WebCore::CSSStyleSheet::parentStyleSheet):
113
        * css/CSSStyleSheet.h:
114
        (WebCore):
115
        (WebCore::StyleSheetInternal::create):
116
        (WebCore::StyleSheetInternal::createInline):
117
        (StyleSheetInternal):
118
        (WebCore::StyleSheetInternal::ownerNode):
119
        (WebCore::StyleSheetInternal::clearOwnerNode):
120
        (WebCore::StyleSheetInternal::ownerRule):
121
        (WebCore::StyleSheetInternal::originalURL):
122
        (WebCore::StyleSheetInternal::title):
123
        (WebCore::StyleSheetInternal::setTitle):
124
        (WebCore::StyleSheetInternal::setFinalURL):
125
        (WebCore::StyleSheetInternal::finalURL):
126
        (CSSStyleSheet):
127
        (WebCore::CSSStyleSheet::create):
128
        (WebCore::CSSStyleSheet::removeRule):
129
        (WebCore::CSSStyleSheet::clearOwnerRule):
130
        (WebCore::CSSStyleSheet::styleSheetChanged):
131
        (WebCore::CSSStyleSheet::findDocument):
132
        (WebCore::CSSStyleSheet::internal):
133
        (WebCore::CSSStyleSheet::isCSSStyleSheet):
134
        (WebCore::CSSStyleSheet::type):
135
        * css/CSSValue.cpp:
136
        (WebCore::CSSValue::addSubresourceStyleURLs):
137
        * css/CSSValue.h:
138
        (WebCore):
139
        (CSSValue):
140
        * css/CSSValueList.cpp:
141
        (WebCore::CSSValueList::addSubresourceStyleURLs):
142
        * css/CSSValueList.h:
143
        (CSSValueList):
144
        * css/CSSValuePool.cpp:
145
        (WebCore::CSSValuePool::createFontFaceValue):
146
        * css/CSSValuePool.h:
147
        (WebCore):
148
        (CSSValuePool):
149
        * css/PropertySetCSSStyleDeclaration.cpp:
150
        (WebCore::PropertySetCSSStyleDeclaration::setCssText):
151
        (WebCore::PropertySetCSSStyleDeclaration::setProperty):
152
        (WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal):
153
        * css/PropertySetCSSStyleDeclaration.h:
154
        (WebCore):
155
        * css/StylePropertySet.cpp:
156
        (WebCore::StylePropertySet::setProperty):
157
        (WebCore::StylePropertySet::parseDeclaration):
158
        (WebCore::StylePropertySet::addSubresourceStyleURLs):
159
        * css/StylePropertySet.h:
160
        (WebCore):
161
        (StylePropertySet):
162
        * css/StyleSheet.cpp:
163
        (WebCore):
164
        * css/StyleSheet.h:
165
        (StyleSheet):
166
        (WebCore::StyleSheet::media):
167
        (WebCore::StyleSheet::ownerRule):
168
        (WebCore::StyleSheet::isXSLStyleSheet):
169
        * css/WebKitCSSKeyframesRule.cpp:
170
        (WebCore::WebKitCSSKeyframesRule::insertRule):
171
        * dom/DOMImplementation.cpp:
172
        (WebCore::DOMImplementation::createCSSStyleSheet):
173
        * dom/Document.cpp:
174
        (WebCore::Document::updateBaseURL):
175
        (WebCore::Document::pageUserSheet):
176
        (WebCore::Document::pageGroupUserSheets):
177
        (WebCore::Document::addUserSheet):
178
        (WebCore::Document::elementSheet):
179
        (WebCore::Document::testAddedStylesheetRequiresStyleRecalc):
180
        (WebCore::Document::analyzeStylesheetChange):
181
        * dom/Document.h:
182
        (WebCore):
183
        (Document):
184
        (WebCore::Document::documentUserSheets):
185
        * dom/ElementAttributeData.cpp:
186
        (WebCore::ElementAttributeData::updateInlineStyleAvoidingMutation):
187
        * dom/ProcessingInstruction.cpp:
188
        (WebCore::ProcessingInstruction::setCSSStyleSheet):
189
        (WebCore::ProcessingInstruction::parseStyleSheet):
190
        * dom/StyleElement.cpp:
191
        (WebCore::StyleElement::createSheet):
192
        * dom/StyledElement.cpp:
193
        (WebCore::StyledElement::setInlineStyleProperty):
194
        (WebCore::StyledElement::addSubresourceAttributeURLs):
195
        (WebCore):
196
        (WebCore::StyledElement::addPropertyToAttributeStyle):
197
        * dom/StyledElement.h:
198
        (WebCore):
199
        * html/HTMLFontElement.cpp:
200
        (WebCore::HTMLFontElement::collectStyleForAttribute):
201
        * html/HTMLLinkElement.cpp:
202
        (WebCore::HTMLLinkElement::parseAttribute):
203
        (WebCore::HTMLLinkElement::setCSSStyleSheet):
204
        (WebCore::HTMLLinkElement::styleSheetIsLoading):
205
        (WebCore::HTMLLinkElement::addSubresourceAttributeURLs):
206
        * html/HTMLStyleElement.cpp:
207
        (WebCore::HTMLStyleElement::parseAttribute):
208
        (WebCore::HTMLStyleElement::addSubresourceAttributeURLs):
209
        * inspector/InspectorStyleSheet.cpp:
210
        (WebCore::fillMediaListChain):
211
        (WebCore::InspectorStyle::setPropertyText):
212
        (WebCore::InspectorStyleSheet::styleSheetURL):
213
        (WebCore::InspectorStyleSheet::reparseStyleSheet):
214
        (WebCore::InspectorStyleSheet::ensureSourceData):
215
        (WebCore::InspectorStyleSheetForInlineStyle::getStyleAttributeRanges):
216
        * page/PageSerializer.cpp:
217
        (WebCore::PageSerializer::serializeCSSStyleSheet):
218
        * svg/SVGStyleElement.cpp:
219
        (WebCore::SVGStyleElement::parseAttribute):
220
        * xml/XSLStyleSheet.h:
221
        (XSLStyleSheet):
222
        (WebCore::XSLStyleSheet::finalURL):
223
        * xml/XSLStyleSheetLibxslt.cpp:
224
        (WebCore::XSLStyleSheet::XSLStyleSheet):
225
        (WebCore::XSLStyleSheet::isLoading):
226
1
2012-04-11  Yury Semikhatsky  <yurys@chromium.org>
227
2012-04-11  Yury Semikhatsky  <yurys@chromium.org>
2
228
3
        Web Inspector: showing summary view is very slow on a snapshot with thousands of constructors
229
        Web Inspector: showing summary view is very slow on a snapshot with thousands of constructors
- Source/WebCore/css/CSSFontFaceSrcValue.cpp -1 / +1 lines
Lines 73-79 String CSSFontFaceSrcValue::customCssTex Source/WebCore/css/CSSFontFaceSrcValue.cpp_sec1
73
    return result;
73
    return result;
74
}
74
}
75
75
76
void CSSFontFaceSrcValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const CSSStyleSheet* styleSheet)
76
void CSSFontFaceSrcValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
77
{
77
{
78
    if (!isLocal())
78
    if (!isLocal())
79
        addSubresourceURL(urls, styleSheet->completeURL(m_resource));
79
        addSubresourceURL(urls, styleSheet->completeURL(m_resource));
- Source/WebCore/css/CSSFontFaceSrcValue.h -1 / +1 lines
Lines 65-71 public: Source/WebCore/css/CSSFontFaceSrcValue.h_sec1
65
65
66
    String customCssText() const;
66
    String customCssText() const;
67
67
68
    void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
68
    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
69
69
70
    CachedFont* cachedFont(Document*);
70
    CachedFont* cachedFont(Document*);
71
71
- Source/WebCore/css/CSSImportRule.cpp -9 / +25 lines
Lines 33-44 Source/WebCore/css/CSSImportRule.cpp_sec1
33
33
34
namespace WebCore {
34
namespace WebCore {
35
35
36
PassRefPtr<StyleRuleImport> StyleRuleImport::create(CSSStyleSheet* parent, const String& href, PassRefPtr<MediaQuerySet> media)
36
PassRefPtr<StyleRuleImport> StyleRuleImport::create(StyleSheetInternal* parent, const String& href, PassRefPtr<MediaQuerySet> media)
37
{
37
{
38
    return adoptRef(new StyleRuleImport(parent, href, media));
38
    return adoptRef(new StyleRuleImport(parent, href, media));
39
}
39
}
40
40
41
StyleRuleImport::StyleRuleImport(CSSStyleSheet* parent, const String& href, PassRefPtr<MediaQuerySet> media)
41
StyleRuleImport::StyleRuleImport(StyleSheetInternal* parent, const String& href, PassRefPtr<MediaQuerySet> media)
42
    : StyleRuleBase(Import, 0)
42
    : StyleRuleBase(Import, 0)
43
    , m_parentStyleSheet(parent)
43
    , m_parentStyleSheet(parent)
44
    , m_styleSheetClient(this)
44
    , m_styleSheetClient(this)
Lines 64-70 void StyleRuleImport::setCSSStyleSheet(c Source/WebCore/css/CSSImportRule.cpp_sec2
64
{
64
{
65
    if (m_styleSheet)
65
    if (m_styleSheet)
66
        m_styleSheet->clearOwnerRule();
66
        m_styleSheet->clearOwnerRule();
67
    m_styleSheet = CSSStyleSheet::create(this, href, baseURL, charset);
67
    m_styleSheet = StyleSheetInternal::create(this, href, baseURL, charset);
68
68
69
    bool crossOriginCSS = false;
69
    bool crossOriginCSS = false;
70
    bool validMIMEType = false;
70
    bool validMIMEType = false;
Lines 88-94 void StyleRuleImport::setCSSStyleSheet(c Source/WebCore/css/CSSImportRule.cpp_sec3
88
        crossOriginCSS = true;
88
        crossOriginCSS = true;
89
89
90
    if (crossOriginCSS && !validMIMEType && !m_styleSheet->hasSyntacticallyValidCSSHeader())
90
    if (crossOriginCSS && !validMIMEType && !m_styleSheet->hasSyntacticallyValidCSSHeader())
91
        m_styleSheet = CSSStyleSheet::create(this, href, baseURL, charset);
91
        m_styleSheet = StyleSheetInternal::create(this, href, baseURL, charset);
92
92
93
    if (isStrictParserMode(cssParserMode) && needsSiteSpecificQuirks) {
93
    if (isStrictParserMode(cssParserMode) && needsSiteSpecificQuirks) {
94
        // Work around <https://bugs.webkit.org/show_bug.cgi?id=28350>.
94
        // Work around <https://bugs.webkit.org/show_bug.cgi?id=28350>.
Lines 98-106 void StyleRuleImport::setCSSStyleSheet(c Source/WebCore/css/CSSImportRule.cpp_sec4
98
        // while the other lacks the second trailing newline.
98
        // while the other lacks the second trailing newline.
99
        if (baseURL.string().endsWith(slashKHTMLFixesDotCss) && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText)
99
        if (baseURL.string().endsWith(slashKHTMLFixesDotCss) && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText)
100
                && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1) {
100
                && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1) {
101
            ASSERT(m_styleSheet->length() == 1);
101
            ASSERT(m_styleSheet->childRules().size() == 1);
102
            ExceptionCode ec;
102
            m_styleSheet->clearRules();
103
            m_styleSheet->deleteRule(0, ec);
104
        }
103
        }
105
    }
104
    }
106
105
Lines 136-143 void StyleRuleImport::requestStyleSheet( Source/WebCore/css/CSSImportRule.cpp_sec5
136
135
137
    // Check for a cycle in our import chain.  If we encounter a stylesheet
136
    // Check for a cycle in our import chain.  If we encounter a stylesheet
138
    // in our parent chain with the same URL, then just bail.
137
    // in our parent chain with the same URL, then just bail.
139
    CSSStyleSheet* rootSheet = m_parentStyleSheet;
138
    StyleSheetInternal* rootSheet = m_parentStyleSheet;
140
    for (CSSStyleSheet* sheet = m_parentStyleSheet; sheet; sheet = sheet->parentStyleSheet()) {
139
    for (StyleSheetInternal* sheet = m_parentStyleSheet; sheet; sheet = sheet->parentStyleSheet()) {
141
        // FIXME: This is wrong if the finalURL was updated via document::updateBaseURL.
140
        // FIXME: This is wrong if the finalURL was updated via document::updateBaseURL.
142
        if (absHref == sheet->finalURL().string())
141
        if (absHref == sheet->finalURL().string())
143
            return;
142
            return;
Lines 166-171 CSSImportRule::CSSImportRule(StyleRuleIm Source/WebCore/css/CSSImportRule.cpp_sec6
166
{
165
{
167
}
166
}
168
167
168
CSSImportRule::~CSSImportRule()
169
{
170
    if (m_styleSheetCSSOMWrapper)
171
        m_styleSheetCSSOMWrapper->clearOwnerRule();
172
}
173
169
MediaList* CSSImportRule::media()
174
MediaList* CSSImportRule::media()
170
{
175
{
171
    return m_importRule->mediaQueries()->ensureMediaList(parentStyleSheet());
176
    return m_importRule->mediaQueries()->ensureMediaList(parentStyleSheet());
Lines 187-190 String CSSImportRule::cssText() const Source/WebCore/css/CSSImportRule.cpp_sec7
187
    return result.toString();
192
    return result.toString();
188
}
193
}
189
194
195
CSSStyleSheet* CSSImportRule::styleSheet() const
196
{ 
197
    if (!m_importRule->styleSheet())
198
        return 0;
199
200
    if (!m_styleSheetCSSOMWrapper)
201
        m_styleSheetCSSOMWrapper = CSSStyleSheet::create(m_importRule->styleSheet(), const_cast<CSSImportRule*>(this));
202
    return m_styleSheetCSSOMWrapper.get(); 
203
}
204
205
190
} // namespace WebCore
206
} // namespace WebCore
- Source/WebCore/css/CSSImportRule.h -8 / +12 lines
Lines 33-50 namespace WebCore { Source/WebCore/css/CSSImportRule.h_sec1
33
class CachedCSSStyleSheet;
33
class CachedCSSStyleSheet;
34
class MediaList;
34
class MediaList;
35
class MediaQuerySet;
35
class MediaQuerySet;
36
class StyleSheetInternal;
36
37
37
class StyleRuleImport : public StyleRuleBase {
38
class StyleRuleImport : public StyleRuleBase {
38
public:
39
public:
39
    static PassRefPtr<StyleRuleImport> create(CSSStyleSheet* parent, const String& href, PassRefPtr<MediaQuerySet>);
40
    static PassRefPtr<StyleRuleImport> create(StyleSheetInternal* parent, const String& href, PassRefPtr<MediaQuerySet>);
40
41
41
    ~StyleRuleImport();
42
    ~StyleRuleImport();
42
    
43
    
43
    CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; }
44
    StyleSheetInternal* parentStyleSheet() const { return m_parentStyleSheet; }
44
    void clearParentStyleSheet() { m_parentStyleSheet = 0; }
45
    void clearParentStyleSheet() { m_parentStyleSheet = 0; }
45
46
46
    String href() const { return m_strHref; }
47
    String href() const { return m_strHref; }
47
    CSSStyleSheet* styleSheet() const { return m_styleSheet.get(); }
48
    StyleSheetInternal* styleSheet() const { return m_styleSheet.get(); }
48
49
49
    // Not part of the CSSOM.
50
    // Not part of the CSSOM.
50
    bool isLoading() const;
51
    bool isLoading() const;
Lines 70-84 private: Source/WebCore/css/CSSImportRule.h_sec2
70
    void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*);
71
    void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*);
71
    friend class ImportedStyleSheetClient;
72
    friend class ImportedStyleSheetClient;
72
73
73
    StyleRuleImport(CSSStyleSheet* parent, const String& href, PassRefPtr<MediaQuerySet>);
74
    StyleRuleImport(StyleSheetInternal* parent, const String& href, PassRefPtr<MediaQuerySet>);
74
75
75
    // FXIME: This needs to go away.
76
    StyleSheetInternal* m_parentStyleSheet;
76
    CSSStyleSheet* m_parentStyleSheet;
77
77
78
    ImportedStyleSheetClient m_styleSheetClient;
78
    ImportedStyleSheetClient m_styleSheetClient;
79
    String m_strHref;
79
    String m_strHref;
80
    RefPtr<MediaQuerySet> m_mediaQueries;
80
    RefPtr<MediaQuerySet> m_mediaQueries;
81
    RefPtr<CSSStyleSheet> m_styleSheet;
81
    RefPtr<StyleSheetInternal> m_styleSheet;
82
    CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
82
    CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
83
    bool m_loading;
83
    bool m_loading;
84
};
84
};
Lines 86-95 private: Source/WebCore/css/CSSImportRule.h_sec3
86
class CSSImportRule : public CSSRule {
86
class CSSImportRule : public CSSRule {
87
public:
87
public:
88
    static PassRefPtr<CSSImportRule> create(StyleRuleImport* rule, CSSStyleSheet* sheet) { return adoptRef(new CSSImportRule(rule, sheet)); }
88
    static PassRefPtr<CSSImportRule> create(StyleRuleImport* rule, CSSStyleSheet* sheet) { return adoptRef(new CSSImportRule(rule, sheet)); }
89
    
90
    ~CSSImportRule();
89
91
90
    String href() const { return m_importRule->href(); }
92
    String href() const { return m_importRule->href(); }
91
    MediaList* media();
93
    MediaList* media();
92
    CSSStyleSheet* styleSheet() const { return m_importRule->styleSheet(); }
94
    CSSStyleSheet* styleSheet() const;
93
    
95
    
94
    String cssText() const;
96
    String cssText() const;
95
97
Lines 97-102 private: Source/WebCore/css/CSSImportRule.h_sec4
97
    CSSImportRule(StyleRuleImport*, CSSStyleSheet*);
99
    CSSImportRule(StyleRuleImport*, CSSStyleSheet*);
98
100
99
    RefPtr<StyleRuleImport> m_importRule;
101
    RefPtr<StyleRuleImport> m_importRule;
102
103
    mutable RefPtr<CSSStyleSheet> m_styleSheetCSSOMWrapper;
100
};
104
};
101
105
102
} // namespace WebCore
106
} // namespace WebCore
- Source/WebCore/css/CSSMediaRule.cpp -3 / +4 lines
Lines 1-7 Source/WebCore/css/CSSMediaRule.cpp_sec1
1
/**
1
/**
2
 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
2
 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3
 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
3
 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
4
 * Copyright (C) 2002, 2005, 2006 Apple Computer, Inc.
4
 * Copyright (C) 2002, 2005, 2006, 2012 Apple Computer, Inc.
5
 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org)
5
 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org)
6
 *
6
 *
7
 * This library is free software; you can redistribute it and/or
7
 * This library is free software; you can redistribute it and/or
Lines 58-65 unsigned CSSMediaRule::insertRule(const Source/WebCore/css/CSSMediaRule.cpp_sec2
58
        return 0;
58
        return 0;
59
    }
59
    }
60
60
61
    CSSParser p(cssParserMode());
61
    CSSStyleSheet* styleSheet = parentStyleSheet();
62
    RefPtr<StyleRuleBase> newRule = p.parseRule(parentStyleSheet(), ruleString);
62
    CSSParser parser(styleSheet ? styleSheet->internal()->cssParserMode() : CSSStrictMode);
63
    RefPtr<StyleRuleBase> newRule = parser.parseRule(styleSheet ? styleSheet->internal() : 0, ruleString);
63
    if (!newRule) {
64
    if (!newRule) {
64
        // SYNTAX_ERR: Raised if the specified rule has a syntax error and is unparsable.
65
        // SYNTAX_ERR: Raised if the specified rule has a syntax error and is unparsable.
65
        ec = SYNTAX_ERR;
66
        ec = SYNTAX_ERR;
- Source/WebCore/css/CSSParser.cpp -10 / +10 lines
Lines 252-258 void CSSParser::setupParser(const char* Source/WebCore/css/CSSParser.cpp_sec1
252
    resetRuleBodyMarks();
252
    resetRuleBodyMarks();
253
}
253
}
254
254
255
void CSSParser::parseSheet(CSSStyleSheet* sheet, const String& string, int startLineNumber, StyleRuleRangeMap* ruleRangeMap)
255
void CSSParser::parseSheet(StyleSheetInternal* sheet, const String& string, int startLineNumber, StyleRuleRangeMap* ruleRangeMap)
256
{
256
{
257
    setStyleSheet(sheet);
257
    setStyleSheet(sheet);
258
    m_defaultNamespace = starAtom; // Reset the default namespace.
258
    m_defaultNamespace = starAtom; // Reset the default namespace.
Lines 270-276 void CSSParser::parseSheet(CSSStyleSheet Source/WebCore/css/CSSParser.cpp_sec2
270
    m_rule = 0;
270
    m_rule = 0;
271
}
271
}
272
272
273
PassRefPtr<StyleRuleBase> CSSParser::parseRule(CSSStyleSheet* sheet, const String& string)
273
PassRefPtr<StyleRuleBase> CSSParser::parseRule(StyleSheetInternal* sheet, const String& string)
274
{
274
{
275
    setStyleSheet(sheet);
275
    setStyleSheet(sheet);
276
    m_allowNamespaceDeclarations = false;
276
    m_allowNamespaceDeclarations = false;
Lines 279-285 PassRefPtr<StyleRuleBase> CSSParser::par Source/WebCore/css/CSSParser.cpp_sec3
279
    return m_rule.release();
279
    return m_rule.release();
280
}
280
}
281
281
282
PassRefPtr<StyleKeyframe> CSSParser::parseKeyframeRule(CSSStyleSheet *sheet, const String &string)
282
PassRefPtr<StyleKeyframe> CSSParser::parseKeyframeRule(StyleSheetInternal* sheet, const String &string)
283
{
283
{
284
    setStyleSheet(sheet);
284
    setStyleSheet(sheet);
285
    setupParser("@-webkit-keyframe-rule{ ", string, "} ");
285
    setupParser("@-webkit-keyframe-rule{ ", string, "} ");
Lines 909-915 static bool parseKeywordValue(StylePrope Source/WebCore/css/CSSParser.cpp_sec4
909
    return true;
909
    return true;
910
}
910
}
911
911
912
PassRefPtr<CSSValueList> CSSParser::parseFontFaceValue(const AtomicString& string, CSSStyleSheet* contextStyleSheet)
912
PassRefPtr<CSSValueList> CSSParser::parseFontFaceValue(const AtomicString& string, StyleSheetInternal* contextStyleSheet)
913
{
913
{
914
    RefPtr<StylePropertySet> dummyStyle = StylePropertySet::create();
914
    RefPtr<StylePropertySet> dummyStyle = StylePropertySet::create();
915
    if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, CSSQuirksMode, contextStyleSheet))
915
    if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, CSSQuirksMode, contextStyleSheet))
Lines 917-923 PassRefPtr<CSSValueList> CSSParser::pars Source/WebCore/css/CSSParser.cpp_sec5
917
    return static_pointer_cast<CSSValueList>(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily));
917
    return static_pointer_cast<CSSValueList>(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily));
918
}
918
}
919
919
920
bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode cssParserMode, CSSStyleSheet* contextStyleSheet)
920
bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode cssParserMode, StyleSheetInternal* contextStyleSheet)
921
{
921
{
922
    if (parseSimpleLengthValue(declaration, propertyID, string, important, cssParserMode))
922
    if (parseSimpleLengthValue(declaration, propertyID, string, important, cssParserMode))
923
        return true;
923
        return true;
Lines 929-935 bool CSSParser::parseValue(StyleProperty Source/WebCore/css/CSSParser.cpp_sec6
929
    return parser.parseValue(declaration, propertyID, string, important, contextStyleSheet);
929
    return parser.parseValue(declaration, propertyID, string, important, contextStyleSheet);
930
}
930
}
931
931
932
bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSStyleSheet* contextStyleSheet)
932
bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, StyleSheetInternal* contextStyleSheet)
933
{
933
{
934
    setStyleSheet(contextStyleSheet);
934
    setStyleSheet(contextStyleSheet);
935
935
Lines 1007-1013 bool CSSParser::parseSystemColor(RGBA32& Source/WebCore/css/CSSParser.cpp_sec7
1007
1007
1008
void CSSParser::parseSelector(const String& string, Document* doc, CSSSelectorList& selectorList)
1008
void CSSParser::parseSelector(const String& string, Document* doc, CSSSelectorList& selectorList)
1009
{
1009
{
1010
    RefPtr<CSSStyleSheet> dummyStyleSheet = CSSStyleSheet::create(doc);
1010
    RefPtr<StyleSheetInternal> dummyStyleSheet = StyleSheetInternal::create(doc);
1011
1011
1012
    setStyleSheet(dummyStyleSheet.get());
1012
    setStyleSheet(dummyStyleSheet.get());
1013
    m_selectorListForParseSelector = &selectorList;
1013
    m_selectorListForParseSelector = &selectorList;
Lines 1022-1028 void CSSParser::parseSelector(const Stri Source/WebCore/css/CSSParser.cpp_sec8
1022
    ASSERT(dummyStyleSheet->hasOneRef());
1022
    ASSERT(dummyStyleSheet->hasOneRef());
1023
}
1023
}
1024
1024
1025
bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& string, RefPtr<CSSStyleSourceData>* styleSourceData, CSSStyleSheet* contextStyleSheet)
1025
bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& string, RefPtr<CSSStyleSourceData>* styleSourceData, StyleSheetInternal* contextStyleSheet)
1026
{
1026
{
1027
    // Length of the "@-webkit-decls{" prefix.
1027
    // Length of the "@-webkit-decls{" prefix.
1028
    static const unsigned prefixLength = 15;
1028
    static const unsigned prefixLength = 15;
Lines 1099-1105 void CSSParser::clearProperties() Source/WebCore/css/CSSParser.cpp_sec9
1099
    m_hasFontFaceOnlyValues = false;
1099
    m_hasFontFaceOnlyValues = false;
1100
}
1100
}
1101
1101
1102
void CSSParser::setStyleSheet(CSSStyleSheet* styleSheet)
1102
void CSSParser::setStyleSheet(StyleSheetInternal* styleSheet)
1103
{
1103
{
1104
    m_styleSheet = styleSheet;
1104
    m_styleSheet = styleSheet;
1105
}
1105
}
Lines 7283-7289 bool CSSParser::parseFlowThread(const St Source/WebCore/css/CSSParser.cpp_sec10
7283
    ASSERT(doc);
7283
    ASSERT(doc);
7284
    ASSERT(doc->cssRegionsEnabled());
7284
    ASSERT(doc->cssRegionsEnabled());
7285
7285
7286
    RefPtr<CSSStyleSheet> dummyStyleSheet = CSSStyleSheet::create(doc);
7286
    RefPtr<StyleSheetInternal> dummyStyleSheet = StyleSheetInternal::create(doc);
7287
    setStyleSheet(dummyStyleSheet.get());
7287
    setStyleSheet(dummyStyleSheet.get());
7288
7288
7289
    setupParser("@-webkit-decls{-webkit-flow-into:", flowName, "}");
7289
    setupParser("@-webkit-decls{-webkit-flow-into:", flowName, "}");
- Source/WebCore/css/CSSParser.h -10 / +10 lines
Lines 49-55 class CSSBorderImageSliceValue; Source/WebCore/css/CSSParser.h_sec1
49
class CSSPrimitiveValue;
49
class CSSPrimitiveValue;
50
class CSSProperty;
50
class CSSProperty;
51
class CSSSelectorList;
51
class CSSSelectorList;
52
class CSSStyleSheet;
53
class CSSValue;
52
class CSSValue;
54
class CSSValueList;
53
class CSSValueList;
55
class CSSWrapShape;
54
class CSSWrapShape;
Lines 62-67 class StylePropertyShorthand; Source/WebCore/css/CSSParser.h_sec2
62
class StyleRuleBase;
61
class StyleRuleBase;
63
class StyleRuleKeyframes;
62
class StyleRuleKeyframes;
64
class StyleKeyframe;
63
class StyleKeyframe;
64
class StyleSheetInternal;
65
class StyledElement;
65
class StyledElement;
66
66
67
class CSSParser {
67
class CSSParser {
Lines 70-84 public: Source/WebCore/css/CSSParser.h_sec3
70
70
71
    ~CSSParser();
71
    ~CSSParser();
72
72
73
    void parseSheet(CSSStyleSheet*, const String&, int startLineNumber = 0, StyleRuleRangeMap* ruleRangeMap = 0);
73
    void parseSheet(StyleSheetInternal*, const String&, int startLineNumber = 0, StyleRuleRangeMap* = 0);
74
    PassRefPtr<StyleRuleBase> parseRule(CSSStyleSheet*, const String&);
74
    PassRefPtr<StyleRuleBase> parseRule(StyleSheetInternal*, const String&);
75
    PassRefPtr<StyleKeyframe> parseKeyframeRule(CSSStyleSheet*, const String&);
75
    PassRefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetInternal*, const String&);
76
    static bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, CSSParserMode, CSSStyleSheet*);
76
    static bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, CSSParserMode, StyleSheetInternal*);
77
    static bool parseColor(RGBA32& color, const String&, bool strict = false);
77
    static bool parseColor(RGBA32& color, const String&, bool strict = false);
78
    static bool parseSystemColor(RGBA32& color, const String&, Document*);
78
    static bool parseSystemColor(RGBA32& color, const String&, Document*);
79
    static PassRefPtr<CSSValueList> parseFontFaceValue(const AtomicString&, CSSStyleSheet* contextStyleSheet);
79
    static PassRefPtr<CSSValueList> parseFontFaceValue(const AtomicString&, StyleSheetInternal* contextStyleSheet);
80
    PassRefPtr<CSSPrimitiveValue> parseValidPrimitive(int ident, CSSParserValue*);
80
    PassRefPtr<CSSPrimitiveValue> parseValidPrimitive(int ident, CSSParserValue*);
81
    bool parseDeclaration(StylePropertySet*, const String&, RefPtr<CSSStyleSourceData>*, CSSStyleSheet* contextStyleSheet);
81
    bool parseDeclaration(StylePropertySet*, const String&, RefPtr<CSSStyleSourceData>*, StyleSheetInternal* contextStyleSheet);
82
    PassOwnPtr<MediaQuery> parseMediaQuery(const String&);
82
    PassOwnPtr<MediaQuery> parseMediaQuery(const String&);
83
83
84
    Document* findDocument() const;
84
    Document* findDocument() const;
Lines 286-292 public: Source/WebCore/css/CSSParser.h_sec4
286
    CSSParserMode m_cssParserMode;
286
    CSSParserMode m_cssParserMode;
287
    bool m_important;
287
    bool m_important;
288
    CSSPropertyID m_id;
288
    CSSPropertyID m_id;
289
    CSSStyleSheet* m_styleSheet;
289
    StyleSheetInternal* m_styleSheet;
290
    RefPtr<StyleRuleBase> m_rule;
290
    RefPtr<StyleRuleBase> m_rule;
291
    RefPtr<StyleKeyframe> m_keyframe;
291
    RefPtr<StyleKeyframe> m_keyframe;
292
    OwnPtr<MediaQuery> m_mediaQuery;
292
    OwnPtr<MediaQuery> m_mediaQuery;
Lines 345-351 private: Source/WebCore/css/CSSParser.h_sec5
345
    inline void detectDashToken(int);
345
    inline void detectDashToken(int);
346
    inline void detectAtToken(int, bool);
346
    inline void detectAtToken(int, bool);
347
347
348
    void setStyleSheet(CSSStyleSheet*);
348
    void setStyleSheet(StyleSheetInternal*);
349
349
350
    inline bool inStrictMode() const { return m_cssParserMode == CSSStrictMode || m_cssParserMode == SVGAttributeMode; }
350
    inline bool inStrictMode() const { return m_cssParserMode == CSSStrictMode || m_cssParserMode == SVGAttributeMode; }
351
    inline bool inQuirksMode() const { return m_cssParserMode == CSSQuirksMode; }
351
    inline bool inQuirksMode() const { return m_cssParserMode == CSSQuirksMode; }
Lines 363-369 private: Source/WebCore/css/CSSParser.h_sec6
363
    bool isGeneratedImageValue(CSSParserValue*) const;
363
    bool isGeneratedImageValue(CSSParserValue*) const;
364
    bool parseGeneratedImage(CSSParserValueList*, RefPtr<CSSValue>&);
364
    bool parseGeneratedImage(CSSParserValueList*, RefPtr<CSSValue>&);
365
365
366
    bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, CSSStyleSheet* contextStyleSheet);
366
    bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, StyleSheetInternal* contextStyleSheet);
367
367
368
    enum SizeParameterType {
368
    enum SizeParameterType {
369
        None,
369
        None,
- Source/WebCore/css/CSSPrimitiveValue.cpp -1 / +1 lines
Lines 1060-1066 String CSSPrimitiveValue::customCssText( Source/WebCore/css/CSSPrimitiveValue.cpp_sec1
1060
    return text;
1060
    return text;
1061
}
1061
}
1062
1062
1063
void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const CSSStyleSheet* styleSheet)
1063
void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
1064
{
1064
{
1065
    if (m_primitiveUnitType == CSS_URI)
1065
    if (m_primitiveUnitType == CSS_URI)
1066
        addSubresourceURL(urls, styleSheet->completeURL(m_value.string));
1066
        addSubresourceURL(urls, styleSheet->completeURL(m_value.string));
- Source/WebCore/css/CSSPrimitiveValue.h -1 / +1 lines
Lines 272-278 public: Source/WebCore/css/CSSPrimitiveValue.h_sec1
272
272
273
    bool isQuirkValue() { return m_isQuirkValue; }
273
    bool isQuirkValue() { return m_isQuirkValue; }
274
274
275
    void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
275
    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
276
276
277
    Length viewportPercentageLength();
277
    Length viewportPercentageLength();
278
    
278
    
- Source/WebCore/css/CSSReflectValue.cpp -1 / +1 lines
Lines 59-65 String CSSReflectValue::customCssText() Source/WebCore/css/CSSReflectValue.cpp_sec1
59
    return result;
59
    return result;
60
}
60
}
61
61
62
void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const CSSStyleSheet* styleSheet)
62
void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
63
{
63
{
64
    if (m_mask)
64
    if (m_mask)
65
        m_mask->addSubresourceStyleURLs(urls, styleSheet);
65
        m_mask->addSubresourceStyleURLs(urls, styleSheet);
- Source/WebCore/css/CSSReflectValue.h -1 / +1 lines
Lines 49-55 public: Source/WebCore/css/CSSReflectValue.h_sec1
49
49
50
    String customCssText() const;
50
    String customCssText() const;
51
51
52
    void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
52
    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
53
53
54
private:
54
private:
55
    CSSReflectValue(CSSReflectionDirection direction, PassRefPtr<CSSPrimitiveValue> offset, PassRefPtr<CSSValue> mask)
55
    CSSReflectValue(CSSReflectionDirection direction, PassRefPtr<CSSPrimitiveValue> offset, PassRefPtr<CSSValue> mask)
- Source/WebCore/css/CSSRule.h -16 lines
Lines 69-83 public: Source/WebCore/css/CSSRule.h_sec1
69
    bool isRegionRule() const { return type() == WEBKIT_REGION_RULE; }
69
    bool isRegionRule() const { return type() == WEBKIT_REGION_RULE; }
70
    bool isImportRule() const { return type() == IMPORT_RULE; }
70
    bool isImportRule() const { return type() == IMPORT_RULE; }
71
71
72
    CSSParserMode cssParserMode() const
73
    {
74
        if (parentRule())
75
            return parentRule()->cssParserMode();
76
        if (parentStyleSheet())
77
            return parentStyleSheet()->cssParserMode();
78
        return CSSStrictMode;
79
    }
80
81
    void setParentStyleSheet(CSSStyleSheet* styleSheet)
72
    void setParentStyleSheet(CSSStyleSheet* styleSheet)
82
    {
73
    {
83
        m_parentIsRule = false;
74
        m_parentIsRule = false;
Lines 102-114 public: Source/WebCore/css/CSSRule.h_sec2
102
    String cssText() const;
93
    String cssText() const;
103
    void setCssText(const String&, ExceptionCode&);
94
    void setCssText(const String&, ExceptionCode&);
104
95
105
    KURL baseURL() const
106
    {
107
        if (CSSStyleSheet* parentSheet = parentStyleSheet())
108
            return parentSheet->baseURL();
109
        return KURL();
110
    }
111
112
protected:
96
protected:
113
    CSSRule(CSSStyleSheet* parent, Type type)
97
    CSSRule(CSSStyleSheet* parent, Type type)
114
        : m_hasCachedSelectorText(false)
98
        : m_hasCachedSelectorText(false)
- Source/WebCore/css/CSSStyleSelector.cpp -29 / +38 lines
Lines 235-241 public: Source/WebCore/css/CSSStyleSelector.cpp_sec1
235
235
236
    typedef HashMap<AtomicStringImpl*, OwnPtr<Vector<RuleData> > > AtomRuleMap;
236
    typedef HashMap<AtomicStringImpl*, OwnPtr<Vector<RuleData> > > AtomRuleMap;
237
237
238
    void addRulesFromSheet(CSSStyleSheet*, const MediaQueryEvaluator&, CSSStyleSelector* = 0, const ContainerNode* = 0);
238
    void addRulesFromSheet(StyleSheetInternal*, const MediaQueryEvaluator&, CSSStyleSelector* = 0, const ContainerNode* = 0);
239
239
240
    void addStyleRule(StyleRule*, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool isInRegionRule = false);
240
    void addStyleRule(StyleRule*, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool isInRegionRule = false);
241
    void addRule(StyleRule*, CSSSelector*, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool isInRegionRule = false);
241
    void addRule(StyleRule*, CSSSelector*, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool isInRegionRule = false);
Lines 285-297 static RuleSet* defaultStyle; Source/WebCore/css/CSSStyleSelector.cpp_sec2
285
static RuleSet* defaultQuirksStyle;
285
static RuleSet* defaultQuirksStyle;
286
static RuleSet* defaultPrintStyle;
286
static RuleSet* defaultPrintStyle;
287
static RuleSet* defaultViewSourceStyle;
287
static RuleSet* defaultViewSourceStyle;
288
static CSSStyleSheet* simpleDefaultStyleSheet;
288
static StyleSheetInternal* simpleDefaultStyleSheet;
289
static CSSStyleSheet* defaultStyleSheet;
289
static StyleSheetInternal* defaultStyleSheet;
290
static CSSStyleSheet* quirksStyleSheet;
290
static StyleSheetInternal* quirksStyleSheet;
291
static CSSStyleSheet* svgStyleSheet;
291
static StyleSheetInternal* svgStyleSheet;
292
static CSSStyleSheet* mathMLStyleSheet;
292
static StyleSheetInternal* mathMLStyleSheet;
293
static CSSStyleSheet* mediaControlsStyleSheet;
293
static StyleSheetInternal* mediaControlsStyleSheet;
294
static CSSStyleSheet* fullscreenStyleSheet;
294
static StyleSheetInternal* fullscreenStyleSheet;
295
295
296
RenderStyle* CSSStyleSelector::s_styleNotYetAvailable;
296
RenderStyle* CSSStyleSelector::s_styleNotYetAvailable;
297
297
Lines 399-405 CSSStyleSelector::CSSStyleSelector(Docum Source/WebCore/css/CSSStyleSelector.cpp_sec3
399
399
400
    // FIXME: This sucks! The user sheet is reparsed every time!
400
    // FIXME: This sucks! The user sheet is reparsed every time!
401
    OwnPtr<RuleSet> tempUserStyle = RuleSet::create();
401
    OwnPtr<RuleSet> tempUserStyle = RuleSet::create();
402
    if (CSSStyleSheet* pageUserSheet = document->pageUserSheet())
402
    if (StyleSheetInternal* pageUserSheet = document->pageUserSheet())
403
        tempUserStyle->addRulesFromSheet(pageUserSheet, *m_medium, this);
403
        tempUserStyle->addRulesFromSheet(pageUserSheet, *m_medium, this);
404
    addAuthorRulesAndCollectUserRulesFromSheets(document->pageGroupUserSheets(), *tempUserStyle);
404
    addAuthorRulesAndCollectUserRulesFromSheets(document->pageGroupUserSheets(), *tempUserStyle);
405
    addAuthorRulesAndCollectUserRulesFromSheets(document->documentUserSheets(), *tempUserStyle);
405
    addAuthorRulesAndCollectUserRulesFromSheets(document->documentUserSheets(), *tempUserStyle);
Lines 418-431 CSSStyleSelector::CSSStyleSelector(Docum Source/WebCore/css/CSSStyleSelector.cpp_sec4
418
    appendAuthorStylesheets(0, document->styleSheets()->vector());
418
    appendAuthorStylesheets(0, document->styleSheets()->vector());
419
}
419
}
420
420
421
void CSSStyleSelector::addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<CSSStyleSheet> >* userSheets, RuleSet& userStyle)
421
void CSSStyleSelector::addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<StyleSheetInternal> >* userSheets, RuleSet& userStyle)
422
{
422
{
423
    if (!userSheets)
423
    if (!userSheets)
424
        return;
424
        return;
425
425
426
    unsigned length = userSheets->size();
426
    unsigned length = userSheets->size();
427
    for (unsigned i = 0; i < length; i++) {
427
    for (unsigned i = 0; i < length; i++) {
428
        const RefPtr<CSSStyleSheet>& sheet = userSheets->at(i);
428
        const RefPtr<StyleSheetInternal>& sheet = userSheets->at(i);
429
        if (sheet->isUserStyleSheet())
429
        if (sheet->isUserStyleSheet())
430
            userStyle.addRulesFromSheet(sheet.get(), *m_medium, this);
430
            userStyle.addRulesFromSheet(sheet.get(), *m_medium, this);
431
        else
431
        else
Lines 464-470 void CSSStyleSelector::collectFeatures() Source/WebCore/css/CSSStyleSelector.cpp_sec5
464
}
464
}
465
465
466
#if ENABLE(STYLE_SCOPED)
466
#if ENABLE(STYLE_SCOPED)
467
const ContainerNode* CSSStyleSelector::determineScope(const CSSStyleSheet* sheet)
467
const ContainerNode* CSSStyleSelector::determineScope(const StyleSheetInternal* sheet)
468
{
468
{
469
    ASSERT(sheet);
469
    ASSERT(sheet);
470
470
Lines 505-511 void CSSStyleSelector::appendAuthorStyle Source/WebCore/css/CSSStyleSelector.cpp_sec6
505
            continue;
505
            continue;
506
        CSSStyleSheet* cssSheet = static_cast<CSSStyleSheet*>(stylesheets[i].get());
506
        CSSStyleSheet* cssSheet = static_cast<CSSStyleSheet*>(stylesheets[i].get());
507
#if ENABLE(STYLE_SCOPED)
507
#if ENABLE(STYLE_SCOPED)
508
        const ContainerNode* scope = determineScope(cssSheet);
508
        const ContainerNode* scope = determineScope(cssSheet->internal());
509
        if (scope) {
509
        if (scope) {
510
            ScopedRuleSetMap::AddResult addResult = m_scopedAuthorStyles.add(scope, nullptr);
510
            ScopedRuleSetMap::AddResult addResult = m_scopedAuthorStyles.add(scope, nullptr);
511
            if (addResult.isNewEntry)
511
            if (addResult.isNewEntry)
Lines 514-520 void CSSStyleSelector::appendAuthorStyle Source/WebCore/css/CSSStyleSelector.cpp_sec7
514
            continue;
514
            continue;
515
        }
515
        }
516
#endif
516
#endif
517
        m_authorStyle->addRulesFromSheet(cssSheet, *m_medium, this);
517
        m_authorStyle->addRulesFromSheet(cssSheet->internal(), *m_medium, this);
518
        if (!m_styleRuleToCSSOMWrapperMap.isEmpty())
518
        if (!m_styleRuleToCSSOMWrapperMap.isEmpty())
519
            collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, cssSheet);
519
            collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, cssSheet);
520
    }
520
    }
Lines 680-693 void CSSStyleSelector::Features::clear() Source/WebCore/css/CSSStyleSelector.cpp_sec8
680
    usesLinkRules = false;
680
    usesLinkRules = false;
681
}
681
}
682
682
683
static CSSStyleSheet* parseUASheet(const String& str)
683
static StyleSheetInternal* parseUASheet(const String& str)
684
{
684
{
685
    CSSStyleSheet* sheet = CSSStyleSheet::create().leakRef(); // leak the sheet on purpose
685
    StyleSheetInternal* sheet = StyleSheetInternal::create().leakRef(); // leak the sheet on purpose
686
    sheet->parseString(str);
686
    sheet->parseString(str);
687
    return sheet;
687
    return sheet;
688
}
688
}
689
689
690
static CSSStyleSheet* parseUASheet(const char* characters, unsigned size)
690
static StyleSheetInternal* parseUASheet(const char* characters, unsigned size)
691
{
691
{
692
    return parseUASheet(String(characters, size));
692
    return parseUASheet(String(characters, size));
693
}
693
}
Lines 2237-2243 bool CSSStyleSelector::checkRegionSelect Source/WebCore/css/CSSStyleSelector.cpp_sec9
2237
    return false;
2237
    return false;
2238
}
2238
}
2239
    
2239
    
2240
bool CSSStyleSelector::determineStylesheetSelectorScopes(CSSStyleSheet* stylesheet, HashSet<AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes)
2240
bool CSSStyleSelector::determineStylesheetSelectorScopes(StyleSheetInternal* stylesheet, HashSet<AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes)
2241
{
2241
{
2242
    ASSERT(!stylesheet->isLoading());
2242
    ASSERT(!stylesheet->isLoading());
2243
2243
Lines 2462-2468 void RuleSet::addRegionRule(StyleRuleReg Source/WebCore/css/CSSStyleSelector.cpp_sec10
2462
    m_regionSelectorsAndRuleSets.append(RuleSetSelectorPair(regionRule->selectorList().first(), regionRuleSet.release()));
2462
    m_regionSelectorsAndRuleSets.append(RuleSetSelectorPair(regionRule->selectorList().first(), regionRuleSet.release()));
2463
}
2463
}
2464
2464
2465
void RuleSet::addRulesFromSheet(CSSStyleSheet* sheet, const MediaQueryEvaluator& medium, CSSStyleSelector* styleSelector, const ContainerNode* scope)
2465
void RuleSet::addRulesFromSheet(StyleSheetInternal* sheet, const MediaQueryEvaluator& medium, CSSStyleSelector* styleSelector, const ContainerNode* scope)
2466
{
2466
{
2467
    ASSERT(sheet);
2467
    ASSERT(sheet);
2468
2468
Lines 2903-2909 static void collectCSSOMWrappers(HashMap Source/WebCore/css/CSSStyleSelector.cpp_sec11
2903
    }
2903
    }
2904
}
2904
}
2905
2905
2906
static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wrapperMap, Document* document)
2906
static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wrapperMap, HashSet<RefPtr<CSSStyleSheet> >& sheetWrapperSet, StyleSheetInternal* styleSheet)
2907
{
2908
    if (!styleSheet)
2909
        return;
2910
    RefPtr<CSSStyleSheet> styleSheetWrapper = CSSStyleSheet::create(styleSheet);
2911
    sheetWrapperSet.add(styleSheetWrapper);
2912
    collectCSSOMWrappers(wrapperMap, styleSheetWrapper.get());
2913
}
2914
2915
static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wrapperMap, HashSet<RefPtr<CSSStyleSheet> >& sheetWrapperSet, Document* document)
2907
{
2916
{
2908
    const Vector<RefPtr<StyleSheet> >& styleSheets = document->styleSheets()->vector();
2917
    const Vector<RefPtr<StyleSheet> >& styleSheets = document->styleSheets()->vector();
2909
    for (unsigned i = 0; i < styleSheets.size(); ++i) {
2918
    for (unsigned i = 0; i < styleSheets.size(); ++i) {
Lines 2912-2932 static void collectCSSOMWrappers(HashMap Source/WebCore/css/CSSStyleSelector.cpp_sec12
2912
            continue;
2921
            continue;
2913
        collectCSSOMWrappers(wrapperMap, static_cast<CSSStyleSheet*>(styleSheet));
2922
        collectCSSOMWrappers(wrapperMap, static_cast<CSSStyleSheet*>(styleSheet));
2914
    }
2923
    }
2915
    collectCSSOMWrappers(wrapperMap, document->pageUserSheet());
2924
    collectCSSOMWrappers(wrapperMap, sheetWrapperSet, document->pageUserSheet());
2916
}
2925
}
2917
2926
2918
CSSStyleRule* CSSStyleSelector::ensureFullCSSOMWrapperForInspector(StyleRule* rule)
2927
CSSStyleRule* CSSStyleSelector::ensureFullCSSOMWrapperForInspector(StyleRule* rule)
2919
{
2928
{
2920
    if (m_styleRuleToCSSOMWrapperMap.isEmpty()) {
2929
    if (m_styleRuleToCSSOMWrapperMap.isEmpty()) {
2921
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, simpleDefaultStyleSheet);
2930
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, simpleDefaultStyleSheet);
2922
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, defaultStyleSheet);
2931
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, defaultStyleSheet);
2923
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, quirksStyleSheet);
2932
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, quirksStyleSheet);
2924
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, svgStyleSheet);
2933
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, svgStyleSheet);
2925
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, mathMLStyleSheet);
2934
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, mathMLStyleSheet);
2926
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, mediaControlsStyleSheet);
2935
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, mediaControlsStyleSheet);
2927
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, fullscreenStyleSheet);
2936
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, fullscreenStyleSheet);
2928
2937
2929
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, document());
2938
        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, document());
2930
    }
2939
    }
2931
    return m_styleRuleToCSSOMWrapperMap.get(rule).get();
2940
    return m_styleRuleToCSSOMWrapperMap.get(rule).get();
2932
}
2941
}
- Source/WebCore/css/CSSStyleSelector.h -3 / +5 lines
Lines 80-85 class StyleRulePage; Source/WebCore/css/CSSStyleSelector.h_sec1
80
class StyleRuleRegion;
80
class StyleRuleRegion;
81
class StyleShader;
81
class StyleShader;
82
class StyleSheet;
82
class StyleSheet;
83
class StyleSheetInternal;
83
class StyleSheetList;
84
class StyleSheetList;
84
class StyledElement;
85
class StyledElement;
85
class WebKitCSSFilterValue;
86
class WebKitCSSFilterValue;
Lines 156-162 public: Source/WebCore/css/CSSStyleSelector.h_sec2
156
    void appendAuthorStylesheets(unsigned firstNew, const Vector<RefPtr<StyleSheet> >&);
157
    void appendAuthorStylesheets(unsigned firstNew, const Vector<RefPtr<StyleSheet> >&);
157
    
158
    
158
    // Find the ids or classes the selectors on a stylesheet are scoped to. The selectors only apply to elements in subtrees where the root element matches the scope.
159
    // Find the ids or classes the selectors on a stylesheet are scoped to. The selectors only apply to elements in subtrees where the root element matches the scope.
159
    static bool determineStylesheetSelectorScopes(CSSStyleSheet*, HashSet<AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes);
160
    static bool determineStylesheetSelectorScopes(StyleSheetInternal*, HashSet<AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes);
160
161
161
private:
162
private:
162
    void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO);
163
    void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO);
Lines 399-405 public: Source/WebCore/css/CSSStyleSelector.h_sec3
399
private:
400
private:
400
    static RenderStyle* s_styleNotYetAvailable;
401
    static RenderStyle* s_styleNotYetAvailable;
401
402
402
    void addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<CSSStyleSheet> >*, RuleSet& userStyle);
403
    void addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<StyleSheetInternal> >*, RuleSet& userStyle);
403
404
404
    void cacheBorderAndBackground();
405
    void cacheBorderAndBackground();
405
406
Lines 496-508 private: Source/WebCore/css/CSSStyleSelector.h_sec4
496
    const CSSStyleApplyProperty& m_applyProperty;
497
    const CSSStyleApplyProperty& m_applyProperty;
497
    
498
    
498
    HashMap<StyleRule*, RefPtr<CSSStyleRule> > m_styleRuleToCSSOMWrapperMap;
499
    HashMap<StyleRule*, RefPtr<CSSStyleRule> > m_styleRuleToCSSOMWrapperMap;
500
    HashSet<RefPtr<CSSStyleSheet> > m_styleSheetCSSOMWrapperSet;
499
501
500
#if ENABLE(CSS_SHADERS)
502
#if ENABLE(CSS_SHADERS)
501
    bool m_hasPendingShaders;
503
    bool m_hasPendingShaders;
502
#endif
504
#endif
503
505
504
#if ENABLE(STYLE_SCOPED)
506
#if ENABLE(STYLE_SCOPED)
505
    static const ContainerNode* determineScope(const CSSStyleSheet*);
507
    static const ContainerNode* determineScope(const StyleSheetInternal*);
506
508
507
    typedef HashMap<const ContainerNode*, OwnPtr<RuleSet> > ScopedRuleSetMap;
509
    typedef HashMap<const ContainerNode*, OwnPtr<RuleSet> > ScopedRuleSetMap;
508
510
- Source/WebCore/css/CSSStyleSheet.cpp -171 / +217 lines
Lines 1-6 Source/WebCore/css/CSSStyleSheet.cpp_sec1
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 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
Lines 74-82 static bool isAcceptableCSSStyleSheetPar Source/WebCore/css/CSSStyleSheet.cpp_sec2
74
}
74
}
75
#endif
75
#endif
76
76
77
CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const KURL& baseURL, const String& charset)
77
StyleSheetInternal::StyleSheetInternal(Node* parentNode, const String& originalURL, const KURL& finalURL, const String& charset)
78
    : StyleSheet(parentNode, href, baseURL)
78
    : m_ownerNode(parentNode)
79
    , m_ownerRule(0)
79
    , m_ownerRule(0)
80
    , m_originalURL(originalURL)
81
    , m_finalURL(finalURL)
80
    , m_charset(charset)
82
    , m_charset(charset)
81
    , m_loadCompleted(false)
83
    , m_loadCompleted(false)
82
    , m_cssParserMode(CSSQuirksMode)
84
    , m_cssParserMode(CSSQuirksMode)
Lines 87-111 CSSStyleSheet::CSSStyleSheet(Node* paren Source/WebCore/css/CSSStyleSheet.cpp_sec3
87
    ASSERT(isAcceptableCSSStyleSheetParent(parentNode));
89
    ASSERT(isAcceptableCSSStyleSheetParent(parentNode));
88
}
90
}
89
91
90
CSSStyleSheet::CSSStyleSheet(StyleRuleImport* ownerRule, const String& href, const KURL& baseURL, const String& charset)
92
StyleSheetInternal::StyleSheetInternal(StyleRuleImport* ownerRule, const String& originalURL, const KURL& finalURL, const String& charset)
91
    : StyleSheet(href, baseURL)
93
    : m_ownerNode(0)
92
    , m_ownerRule(ownerRule)
94
    , m_ownerRule(ownerRule)
95
    , m_originalURL(originalURL)
96
    , m_finalURL(finalURL)
93
    , m_charset(charset)
97
    , m_charset(charset)
94
    , m_loadCompleted(false)
98
    , m_loadCompleted(false)
95
    , m_cssParserMode((ownerRule && ownerRule->parentStyleSheet()) ? ownerRule->parentStyleSheet()->cssParserMode() : CSSStrictMode)
99
    , m_cssParserMode((ownerRule && ownerRule->parentStyleSheet()) ? ownerRule->parentStyleSheet()->cssParserMode() : CSSStrictMode)
96
    , m_hasSyntacticallyValidCSSHeader(true)
100
    , m_hasSyntacticallyValidCSSHeader(true)
97
    , m_didLoadErrorOccur(false)
101
    , m_didLoadErrorOccur(false)
98
{
102
{
99
    CSSStyleSheet* parentSheet = ownerRule ? ownerRule->parentStyleSheet() : 0;
103
    StyleSheetInternal* parentSheet = ownerRule ? ownerRule->parentStyleSheet() : 0;
100
    m_isUserStyleSheet = parentSheet ? parentSheet->isUserStyleSheet() : false;
104
    m_isUserStyleSheet = parentSheet ? parentSheet->isUserStyleSheet() : false;
101
}
105
}
102
106
103
CSSStyleSheet::~CSSStyleSheet()
107
StyleSheetInternal::~StyleSheetInternal()
104
{
108
{
105
    clearRules();
109
    clearRules();
106
}
110
}
107
111
108
void CSSStyleSheet::parserAppendRule(PassRefPtr<StyleRuleBase> rule)
112
void StyleSheetInternal::parserAppendRule(PassRefPtr<StyleRuleBase> rule)
109
{
113
{
110
    ASSERT(!rule->isCharsetRule());
114
    ASSERT(!rule->isCharsetRule());
111
    if (rule->isImportRule()) {
115
    if (rule->isImportRule()) {
Lines 118-141 void CSSStyleSheet::parserAppendRule(Pas Source/WebCore/css/CSSStyleSheet.cpp_sec4
118
    m_childRules.append(rule);
122
    m_childRules.append(rule);
119
}
123
}
120
124
121
PassRefPtr<CSSRule> CSSStyleSheet::createChildRuleCSSOMWrapper(unsigned index)
125
PassRefPtr<CSSRule> StyleSheetInternal::createChildRuleCSSOMWrapper(unsigned index, CSSStyleSheet* parentWrapper)
122
{
126
{
123
    ASSERT(index < length());
127
    ASSERT(index < ruleCount());
124
    
128
    
125
    unsigned childVectorIndex = index;
129
    unsigned childVectorIndex = index;
126
    if (hasCharsetRule()) {
130
    if (hasCharsetRule()) {
127
        if (index == 0)
131
        if (index == 0)
128
            return CSSCharsetRule::create(this, m_encodingFromCharsetRule);
132
            return CSSCharsetRule::create(parentWrapper, m_encodingFromCharsetRule);
129
        --childVectorIndex;
133
        --childVectorIndex;
130
    }
134
    }
131
    if (childVectorIndex < m_importRules.size())
135
    if (childVectorIndex < m_importRules.size())
132
        return m_importRules[childVectorIndex]->createCSSOMWrapper(this);
136
        return m_importRules[childVectorIndex]->createCSSOMWrapper(parentWrapper);
133
    
137
    
134
    childVectorIndex -= m_importRules.size();
138
    childVectorIndex -= m_importRules.size();
135
    return m_childRules[childVectorIndex]->createCSSOMWrapper(this);
139
    return m_childRules[childVectorIndex]->createCSSOMWrapper(parentWrapper);
136
}
140
}
137
141
138
unsigned CSSStyleSheet::length() const
142
unsigned StyleSheetInternal::ruleCount() const
139
{
143
{
140
    unsigned result = 0;
144
    unsigned result = 0;
141
    result += hasCharsetRule() ? 1 : 0;
145
    result += hasCharsetRule() ? 1 : 0;
Lines 144-181 unsigned CSSStyleSheet::length() const Source/WebCore/css/CSSStyleSheet.cpp_sec5
144
    return result;
148
    return result;
145
}
149
}
146
150
147
CSSRule* CSSStyleSheet::item(unsigned index)
151
void StyleSheetInternal::clearCharsetRule()
148
{
149
    unsigned ruleCount = length();
150
    if (index >= ruleCount)
151
        return 0;
152
    
153
    if (m_childRuleCSSOMWrappers.isEmpty())
154
        m_childRuleCSSOMWrappers.grow(ruleCount);
155
    ASSERT(m_childRuleCSSOMWrappers.size() == ruleCount);
156
157
    RefPtr<CSSRule>& cssRule = m_childRuleCSSOMWrappers[index];
158
    if (!cssRule)
159
        cssRule = createChildRuleCSSOMWrapper(index);
160
    return cssRule.get();
161
}
162
163
void CSSStyleSheet::clearCharsetRule()
164
{
152
{
165
    m_encodingFromCharsetRule = String();
153
    m_encodingFromCharsetRule = String();
166
}
154
}
167
155
168
void CSSStyleSheet::clearRules()
156
void StyleSheetInternal::clearRules()
169
{
157
{
170
    // For style rules outside the document, .parentStyleSheet can become null even if the style rule
171
    // is still observable from JavaScript. This matches the behavior of .parentNode for nodes, but
172
    // it's not ideal because it makes the CSSOM's behavior depend on the timing of garbage collection.
173
    for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) {
174
        if (m_childRuleCSSOMWrappers[i])
175
            m_childRuleCSSOMWrappers[i]->setParentStyleSheet(0);
176
    }
177
    m_childRuleCSSOMWrappers.clear();
178
179
    for (unsigned i = 0; i < m_importRules.size(); ++i) {
158
    for (unsigned i = 0; i < m_importRules.size(); ++i) {
180
        ASSERT(m_importRules.at(i)->parentStyleSheet() == this);
159
        ASSERT(m_importRules.at(i)->parentStyleSheet() == this);
181
        m_importRules[i]->clearParentStyleSheet();
160
        m_importRules[i]->clearParentStyleSheet();
Lines 185-229 void CSSStyleSheet::clearRules() Source/WebCore/css/CSSStyleSheet.cpp_sec6
185
    clearCharsetRule();
164
    clearCharsetRule();
186
}
165
}
187
166
188
void CSSStyleSheet::parserSetEncodingFromCharsetRule(const String& encoding)
167
void StyleSheetInternal::parserSetEncodingFromCharsetRule(const String& encoding)
189
{
168
{
190
    // Parser enforces that there is ever only one @charset.
169
    // Parser enforces that there is ever only one @charset.
191
    ASSERT(m_encodingFromCharsetRule.isNull());
170
    ASSERT(m_encodingFromCharsetRule.isNull());
192
    m_encodingFromCharsetRule = encoding; 
171
    m_encodingFromCharsetRule = encoding; 
193
}
172
}
194
173
195
PassRefPtr<CSSRuleList> CSSStyleSheet::rules()
174
bool StyleSheetInternal::wrapperInsertRule(PassRefPtr<StyleRuleBase> rule, unsigned index)
196
{
175
{
197
    KURL url = finalURL();
176
    ASSERT(index <= ruleCount());
198
    Document* document = findDocument();
199
    if (!url.isEmpty() && document && !document->securityOrigin()->canRequest(url))
200
        return 0;
201
    // IE behavior.
202
    RefPtr<StaticCSSRuleList> nonCharsetRules = StaticCSSRuleList::create();
203
    unsigned ruleCount = length();
204
    for (unsigned i = 0; i < ruleCount; ++i) {
205
        CSSRule* rule = item(i);
206
        if (rule->isCharsetRule())
207
            continue;
208
        nonCharsetRules->rules().append(rule);
209
    }
210
    return nonCharsetRules.release();
211
}
212
213
unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, ExceptionCode& ec)
214
{
215
    ec = 0;
216
    if (index > length()) {
217
        ec = INDEX_SIZE_ERR;
218
        return 0;
219
    }
220
    CSSParser p(cssParserMode());
221
    RefPtr<StyleRuleBase> rule = p.parseRule(this, ruleString);
222
223
    if (!rule) {
224
        ec = SYNTAX_ERR;
225
        return 0;
226
    }
227
    // Parser::parseRule doesn't currently allow @charset so we don't need to deal with it.
177
    // Parser::parseRule doesn't currently allow @charset so we don't need to deal with it.
228
    ASSERT(!rule->isCharsetRule());
178
    ASSERT(!rule->isCharsetRule());
229
    
179
    
Lines 232-330 unsigned CSSStyleSheet::insertRule(const Source/WebCore/css/CSSStyleSheet.cpp_sec7
232
    if (hasCharsetRule()) {
182
    if (hasCharsetRule()) {
233
        if (childVectorIndex == 0) {
183
        if (childVectorIndex == 0) {
234
            // Nothing can be inserted before @charset.
184
            // Nothing can be inserted before @charset.
235
            ec = HIERARCHY_REQUEST_ERR;
185
            return false;
236
            return 0;
237
        }
186
        }
238
        --childVectorIndex;
187
        --childVectorIndex;
239
    }
188
    }
240
    
189
    
241
    if (childVectorIndex < m_importRules.size() || (childVectorIndex == m_importRules.size() && rule->isImportRule())) {
190
    if (childVectorIndex < m_importRules.size() || (childVectorIndex == m_importRules.size() && rule->isImportRule())) {
242
        // Inserting non-import rule before @import is not allowed.
191
        // Inserting non-import rule before @import is not allowed.
243
        if (!rule->isImportRule()) {
192
        if (!rule->isImportRule())
244
            ec = HIERARCHY_REQUEST_ERR;
193
            return false;
245
            return 0;
246
        }
247
        m_importRules.insert(childVectorIndex, static_cast<StyleRuleImport*>(rule.get()));
194
        m_importRules.insert(childVectorIndex, static_cast<StyleRuleImport*>(rule.get()));
248
        m_importRules[childVectorIndex]->requestStyleSheet();
195
        m_importRules[childVectorIndex]->requestStyleSheet();
249
        goto success;
196
        // FIXME: Stylesheet doesn't actually change meaningfully before the imported sheets are loaded.
197
        styleSheetChanged();
198
        return true;
250
    }
199
    }
251
    // Inserting @import rule after a non-import rule is not allowed.
200
    // Inserting @import rule after a non-import rule is not allowed.
252
    if (rule->isImportRule()) {
201
    if (rule->isImportRule())
253
        ec = HIERARCHY_REQUEST_ERR;
202
        return false;
254
        return 0;
255
    }
256
    childVectorIndex -= m_importRules.size();
203
    childVectorIndex -= m_importRules.size();
257
 
204
 
258
    m_childRules.insert(childVectorIndex, rule.release());
205
    m_childRules.insert(childVectorIndex, rule);
259
    
206
    
260
success:
261
    if (!m_childRuleCSSOMWrappers.isEmpty())
262
        m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>());
263
264
    // FIXME: Stylesheet doesn't actually change meaningfully before the imported sheets are loaded.
265
    styleSheetChanged();
207
    styleSheetChanged();
266
    return index;
208
    return true;
267
}
268
269
int CSSStyleSheet::addRule(const String& selector, const String& style, int index, ExceptionCode& ec)
270
{
271
    insertRule(selector + " { " + style + " }", index, ec);
272
273
    // As per Microsoft documentation, always return -1.
274
    return -1;
275
}
276
277
int CSSStyleSheet::addRule(const String& selector, const String& style, ExceptionCode& ec)
278
{
279
    return addRule(selector, style, length(), ec);
280
}
209
}
281
210
282
PassRefPtr<CSSRuleList> CSSStyleSheet::cssRules()
211
void StyleSheetInternal::wrapperDeleteRule(unsigned index)
283
{
212
{
284
    KURL url = finalURL();
213
    ASSERT(index < ruleCount());
285
    Document* document = findDocument();
286
    if (!url.isEmpty() && document && !document->securityOrigin()->canRequest(url))
287
        return 0;
288
    if (!m_ruleListCSSOMWrapper)
289
        m_ruleListCSSOMWrapper = adoptPtr(new StyleSheetCSSRuleList(this));
290
    return m_ruleListCSSOMWrapper.get();
291
}
292
214
293
void CSSStyleSheet::deleteRule(unsigned index, ExceptionCode& ec)
294
{
295
    if (index >= length()) {
296
        ec = INDEX_SIZE_ERR;
297
        return;
298
    }
299
    
300
    ec = 0;
301
    unsigned childVectorIndex = index;
215
    unsigned childVectorIndex = index;
302
    if (hasCharsetRule()) {
216
    if (hasCharsetRule()) {
303
        if (childVectorIndex == 0) {
217
        if (childVectorIndex == 0) {
304
            clearCharsetRule();
218
            clearCharsetRule();
305
            goto success;
219
            styleSheetChanged();
220
            return;
306
        }
221
        }
307
        --childVectorIndex;
222
        --childVectorIndex;
308
    }
223
    }
309
    if (childVectorIndex < m_importRules.size()) {
224
    if (childVectorIndex < m_importRules.size()) {
310
        m_importRules[childVectorIndex]->clearParentStyleSheet();
225
        m_importRules[childVectorIndex]->clearParentStyleSheet();
311
        m_importRules.remove(childVectorIndex);
226
        m_importRules.remove(childVectorIndex);
312
        goto success;
227
        styleSheetChanged();
228
        return;
313
    }
229
    }
314
    childVectorIndex -= m_importRules.size();
230
    childVectorIndex -= m_importRules.size();
315
231
316
    m_childRules.remove(childVectorIndex);
232
    m_childRules.remove(childVectorIndex);
317
318
success:
319
    if (!m_childRuleCSSOMWrappers.isEmpty()) {
320
        m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0);
321
        m_childRuleCSSOMWrappers.remove(index);
322
    }
323
324
    styleSheetChanged();
233
    styleSheetChanged();
325
}
234
}
326
235
327
void CSSStyleSheet::addNamespace(CSSParser* p, const AtomicString& prefix, const AtomicString& uri)
236
void StyleSheetInternal::addNamespace(CSSParser* p, const AtomicString& prefix, const AtomicString& uri)
328
{
237
{
329
    if (uri.isNull())
238
    if (uri.isNull())
330
        return;
239
        return;
Lines 337-343 void CSSStyleSheet::addNamespace(CSSPars Source/WebCore/css/CSSStyleSheet.cpp_sec8
337
        p->m_defaultNamespace = uri;
246
        p->m_defaultNamespace = uri;
338
}
247
}
339
248
340
const AtomicString& CSSStyleSheet::determineNamespace(const AtomicString& prefix)
249
const AtomicString& StyleSheetInternal::determineNamespace(const AtomicString& prefix)
341
{
250
{
342
    if (prefix.isNull())
251
    if (prefix.isNull())
343
        return nullAtom; // No namespace. If an element/attribute has a namespace, we won't match it.
252
        return nullAtom; // No namespace. If an element/attribute has a namespace, we won't match it.
Lines 350-361 const AtomicString& CSSStyleSheet::deter Source/WebCore/css/CSSStyleSheet.cpp_sec9
350
    return nullAtom; // Assume we won't match any namespaces.
259
    return nullAtom; // Assume we won't match any namespaces.
351
}
260
}
352
261
353
bool CSSStyleSheet::parseString(const String &string, CSSParserMode cssParserMode)
262
bool StyleSheetInternal::parseString(const String &string, CSSParserMode cssParserMode)
354
{
263
{
355
    return parseStringAtLine(string, cssParserMode, 0);
264
    return parseStringAtLine(string, cssParserMode, 0);
356
}
265
}
357
266
358
bool CSSStyleSheet::parseStringAtLine(const String& string, CSSParserMode cssParserMode, int startLineNumber)
267
bool StyleSheetInternal::parseStringAtLine(const String& string, CSSParserMode cssParserMode, int startLineNumber)
359
{
268
{
360
    setCSSParserMode(cssParserMode);
269
    setCSSParserMode(cssParserMode);
361
    CSSParser p(cssParserMode);
270
    CSSParser p(cssParserMode);
Lines 363-369 bool CSSStyleSheet::parseStringAtLine(co Source/WebCore/css/CSSStyleSheet.cpp_sec10
363
    return true;
272
    return true;
364
}
273
}
365
274
366
bool CSSStyleSheet::isLoading()
275
bool StyleSheetInternal::isLoading() const
367
{
276
{
368
    for (unsigned i = 0; i < m_importRules.size(); ++i) {
277
    for (unsigned i = 0; i < m_importRules.size(); ++i) {
369
        if (m_importRules[i]->isLoading())
278
        if (m_importRules[i]->isLoading())
Lines 372-378 bool CSSStyleSheet::isLoading() Source/WebCore/css/CSSStyleSheet.cpp_sec11
372
    return false;
281
    return false;
373
}
282
}
374
283
375
void CSSStyleSheet::checkLoaded()
284
void StyleSheetInternal::checkLoaded()
376
{
285
{
377
    if (isLoading())
286
    if (isLoading())
378
        return;
287
        return;
Lines 380-387 void CSSStyleSheet::checkLoaded() Source/WebCore/css/CSSStyleSheet.cpp_sec12
380
    // Avoid |this| being deleted by scripts that run via
289
    // Avoid |this| being deleted by scripts that run via
381
    // ScriptableDocumentParser::executeScriptsWaitingForStylesheets().
290
    // ScriptableDocumentParser::executeScriptsWaitingForStylesheets().
382
    // See <rdar://problem/6622300>.
291
    // See <rdar://problem/6622300>.
383
    RefPtr<CSSStyleSheet> protector(this);
292
    RefPtr<StyleSheetInternal> protector(this);
384
    if (CSSStyleSheet* styleSheet = parentStyleSheet())
293
    if (StyleSheetInternal* styleSheet = parentStyleSheet())
385
        styleSheet->checkLoaded();
294
        styleSheet->checkLoaded();
386
295
387
    RefPtr<Node> owner = ownerNode();
296
    RefPtr<Node> owner = ownerNode();
Lines 394-443 void CSSStyleSheet::checkLoaded() Source/WebCore/css/CSSStyleSheet.cpp_sec13
394
    }
303
    }
395
}
304
}
396
305
397
void CSSStyleSheet::notifyLoadedSheet(const CachedCSSStyleSheet* sheet)
306
void StyleSheetInternal::notifyLoadedSheet(const CachedCSSStyleSheet* sheet)
398
{
307
{
399
    ASSERT(sheet);
308
    ASSERT(sheet);
400
    m_didLoadErrorOccur |= sheet->errorOccurred();
309
    m_didLoadErrorOccur |= sheet->errorOccurred();
401
}
310
}
402
311
403
void CSSStyleSheet::startLoadingDynamicSheet()
312
void StyleSheetInternal::startLoadingDynamicSheet()
404
{
313
{
405
    if (Node* owner = ownerNode())
314
    if (Node* owner = ownerNode())
406
        owner->startLoadingDynamicSheet();
315
        owner->startLoadingDynamicSheet();
407
}
316
}
408
317
409
Node* CSSStyleSheet::findStyleSheetOwnerNode() const
318
Node* StyleSheetInternal::findStyleSheetOwnerNode() const
410
{
319
{
411
    for (const CSSStyleSheet* sheet = this; sheet; sheet = sheet->parentStyleSheet()) {
320
    for (const StyleSheetInternal* sheet = this; sheet; sheet = sheet->parentStyleSheet()) {
412
        if (Node* ownerNode = sheet->ownerNode())
321
        if (Node* ownerNode = sheet->ownerNode())
413
            return ownerNode;
322
            return ownerNode;
414
    }
323
    }
415
    return 0;
324
    return 0;
416
}
325
}
417
326
418
Document* CSSStyleSheet::findDocument()
327
Document* StyleSheetInternal::findDocument()
419
{
328
{
420
    Node* ownerNode = findStyleSheetOwnerNode();
329
    Node* ownerNode = findStyleSheetOwnerNode();
421
330
422
    return ownerNode ? ownerNode->document() : 0;
331
    return ownerNode ? ownerNode->document() : 0;
423
}
332
}
424
    
425
MediaList* CSSStyleSheet::media() const 
426
{ 
427
    if (!m_mediaQueries)
428
        return 0;
429
    return m_mediaQueries->ensureMediaList(const_cast<CSSStyleSheet*>(this));
430
}
431
333
432
void CSSStyleSheet::setMediaQueries(PassRefPtr<MediaQuerySet> mediaQueries)
334
void StyleSheetInternal::setMediaQueries(PassRefPtr<MediaQuerySet> mediaQueries)
433
{
335
{
434
    m_mediaQueries = mediaQueries;
336
    m_mediaQueries = mediaQueries;
435
}
337
}
436
338
437
void CSSStyleSheet::styleSheetChanged()
339
void StyleSheetInternal::styleSheetChanged()
438
{
340
{
439
    CSSStyleSheet* rootSheet = this;
341
    StyleSheetInternal* rootSheet = this;
440
    while (CSSStyleSheet* parent = rootSheet->parentStyleSheet())
342
    while (StyleSheetInternal* parent = rootSheet->parentStyleSheet())
441
        rootSheet = parent;
343
        rootSheet = parent;
442
344
443
    /* FIXME: We don't need to do everything updateStyleSelector does,
345
    /* FIXME: We don't need to do everything updateStyleSelector does,
Lines 447-454 void CSSStyleSheet::styleSheetChanged() Source/WebCore/css/CSSStyleSheet.cpp_sec14
447
    if (Document* documentToUpdate = rootSheet->findDocument())
349
    if (Document* documentToUpdate = rootSheet->findDocument())
448
        documentToUpdate->styleSelectorChanged(DeferRecalcStyle);
350
        documentToUpdate->styleSelectorChanged(DeferRecalcStyle);
449
}
351
}
352
    
353
KURL StyleSheetInternal::baseURL() const
354
{
355
    if (!m_finalURL.isNull())
356
        return m_finalURL;
357
    if (StyleSheetInternal* parentSheet = parentStyleSheet())
358
        return parentSheet->baseURL();
359
    if (!m_ownerNode)
360
        return KURL();
361
    return m_ownerNode->document()->baseURL();
362
}
450
363
451
KURL CSSStyleSheet::completeURL(const String& url) const
364
KURL StyleSheetInternal::completeURL(const String& url) const
452
{
365
{
453
    // Always return a null URL when passed a null string.
366
    // Always return a null URL when passed a null string.
454
    // FIXME: Should we change the KURL constructor to have this behavior?
367
    // FIXME: Should we change the KURL constructor to have this behavior?
Lines 461-473 KURL CSSStyleSheet::completeURL(const St Source/WebCore/css/CSSStyleSheet.cpp_sec15
461
    return KURL(baseURL(), url, encoding);
374
    return KURL(baseURL(), url, encoding);
462
}
375
}
463
376
464
void CSSStyleSheet::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
377
void StyleSheetInternal::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
465
{
378
{
466
    Deque<CSSStyleSheet*> styleSheetQueue;
379
    Deque<StyleSheetInternal*> styleSheetQueue;
467
    styleSheetQueue.append(this);
380
    styleSheetQueue.append(this);
468
381
469
    while (!styleSheetQueue.isEmpty()) {
382
    while (!styleSheetQueue.isEmpty()) {
470
        CSSStyleSheet* styleSheet = styleSheetQueue.takeFirst();
383
        StyleSheetInternal* styleSheet = styleSheetQueue.takeFirst();
471
        
384
        
472
        for (unsigned i = 0; i < styleSheet->m_importRules.size(); ++i) {
385
        for (unsigned i = 0; i < styleSheet->m_importRules.size(); ++i) {
473
            StyleRuleImport* importRule = styleSheet->m_importRules[i].get();
386
            StyleRuleImport* importRule = styleSheet->m_importRules[i].get();
Lines 486-510 void CSSStyleSheet::addSubresourceStyleU Source/WebCore/css/CSSStyleSheet.cpp_sec16
486
    }
399
    }
487
}
400
}
488
401
489
CSSImportRule* CSSStyleSheet::ensureCSSOMWrapper(StyleRuleImport* importRule)
402
StyleSheetInternal* StyleSheetInternal::parentStyleSheet() const
490
{
403
{
491
     for (unsigned i = 0; i < m_importRules.size(); ++i) {
404
    return m_ownerRule ? m_ownerRule->parentStyleSheet() : 0;
492
         if (m_importRules[i] == importRule)
493
             return static_cast<CSSImportRule*>(item(i));
494
     }
495
    ASSERT_NOT_REACHED();
496
    return 0;
497
}
405
}
498
406
499
CSSImportRule* CSSStyleSheet::ownerRule() const 
407
CSSStyleSheet::CSSStyleSheet(PassRefPtr<StyleSheetInternal> styleSheet, CSSImportRule* ownerRule)
500
{  
408
    : m_internal(styleSheet)
501
    return parentStyleSheet() ? parentStyleSheet()->ensureCSSOMWrapper(m_ownerRule) : 0; 
409
    , m_isDisabled(false)
410
    , m_ownerRule(ownerRule)
411
{
502
}
412
}
503
413
504
CSSStyleSheet* CSSStyleSheet::parentStyleSheet() const
414
CSSStyleSheet::~CSSStyleSheet()
505
{
415
{
506
    ASSERT(isCSSStyleSheet());
416
    // For style rules outside the document, .parentStyleSheet can become null even if the style rule
507
    return m_ownerRule ? m_ownerRule->parentStyleSheet() : 0;
417
    // is still observable from JavaScript. This matches the behavior of .parentNode for nodes, but
418
    // it's not ideal because it makes the CSSOM's behavior depend on the timing of garbage collection.
419
    for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) {
420
        if (m_childRuleCSSOMWrappers[i])
421
            m_childRuleCSSOMWrappers[i]->setParentStyleSheet(0);
422
    }
423
}
424
425
void CSSStyleSheet::setDisabled(bool disabled)
426
{ 
427
    if (disabled == m_isDisabled)
428
        return;
429
    m_isDisabled = disabled; 
430
    m_internal->styleSheetChanged();
431
}
432
433
unsigned CSSStyleSheet::length() const
434
{
435
    return m_internal->ruleCount();
436
}
437
438
CSSRule* CSSStyleSheet::item(unsigned index)
439
{
440
    unsigned ruleCount = length();
441
    if (index >= ruleCount)
442
        return 0;
443
444
    if (m_childRuleCSSOMWrappers.isEmpty())
445
        m_childRuleCSSOMWrappers.grow(ruleCount);
446
    ASSERT(m_childRuleCSSOMWrappers.size() == ruleCount);
447
    
448
    RefPtr<CSSRule>& cssRule = m_childRuleCSSOMWrappers[index];
449
    if (!cssRule)
450
        cssRule = m_internal->createChildRuleCSSOMWrapper(index, this);
451
    return cssRule.get();
452
}
453
454
PassRefPtr<CSSRuleList> CSSStyleSheet::rules()
455
{
456
    KURL url = m_internal->finalURL();
457
    Document* document = m_internal->findDocument();
458
    if (!url.isEmpty() && document && !document->securityOrigin()->canRequest(url))
459
        return 0;
460
    // IE behavior.
461
    RefPtr<StaticCSSRuleList> nonCharsetRules = StaticCSSRuleList::create();
462
    unsigned ruleCount = length();
463
    for (unsigned i = 0; i < ruleCount; ++i) {
464
        CSSRule* rule = item(i);
465
        if (rule->isCharsetRule())
466
            continue;
467
        nonCharsetRules->rules().append(rule);
468
    }
469
    return nonCharsetRules.release();
470
}
471
472
unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, ExceptionCode& ec)
473
{
474
    ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size() == m_internal->ruleCount());
475
476
    ec = 0;
477
    if (index > length()) {
478
        ec = INDEX_SIZE_ERR;
479
        return 0;
480
    }
481
    CSSParser p(m_internal->cssParserMode());
482
    RefPtr<StyleRuleBase> rule = p.parseRule(m_internal.get(), ruleString);
483
484
    if (!rule) {
485
        ec = SYNTAX_ERR;
486
        return 0;
487
    }
488
    bool success = m_internal->wrapperInsertRule(rule, index);
489
    if (!success) {
490
        ec = HIERARCHY_REQUEST_ERR;
491
        return 0;
492
    }        
493
    if (!m_childRuleCSSOMWrappers.isEmpty())
494
        m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>());
495
    return index;
496
}
497
498
void CSSStyleSheet::deleteRule(unsigned index, ExceptionCode& ec)
499
{
500
    ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size() == m_internal->ruleCount());
501
502
    if (index >= length()) {
503
        ec = INDEX_SIZE_ERR;
504
        return;
505
    }
506
    m_internal->wrapperDeleteRule(index);
507
508
    if (!m_childRuleCSSOMWrappers.isEmpty()) {
509
        m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0);
510
        m_childRuleCSSOMWrappers.remove(index);
511
    }
512
}
513
514
int CSSStyleSheet::addRule(const String& selector, const String& style, int index, ExceptionCode& ec)
515
{
516
    insertRule(selector + " { " + style + " }", index, ec);
517
    
518
    // As per Microsoft documentation, always return -1.
519
    return -1;
520
}
521
522
int CSSStyleSheet::addRule(const String& selector, const String& style, ExceptionCode& ec)
523
{
524
    return addRule(selector, style, length(), ec);
525
}
526
527
528
PassRefPtr<CSSRuleList> CSSStyleSheet::cssRules()
529
{
530
    KURL url = m_internal->finalURL();
531
    Document* document = m_internal->findDocument();
532
    if (!url.isEmpty() && document && !document->securityOrigin()->canRequest(url))
533
        return 0;
534
    if (!m_ruleListCSSOMWrapper)
535
        m_ruleListCSSOMWrapper = adoptPtr(new StyleSheetCSSRuleList(this));
536
    return m_ruleListCSSOMWrapper.get();
537
}
538
539
MediaList* CSSStyleSheet::media() const 
540
{ 
541
    if (!m_internal->mediaQueries())
542
        return 0;
543
    return m_internal->mediaQueries()->ensureMediaList(const_cast<CSSStyleSheet*>(this));
544
}
545
546
CSSStyleSheet* CSSStyleSheet::parentStyleSheet() const 
547
{ 
548
    return m_ownerRule ? m_ownerRule->parentStyleSheet() : 0; 
549
}
550
551
void CSSStyleSheet::clearChildRuleCSSOMWrappers()
552
{
553
    m_childRuleCSSOMWrappers.clear();
508
}
554
}
509
555
510
}
556
}
- Source/WebCore/css/CSSStyleSheet.h -41 / +100 lines
Lines 1-6 Source/WebCore/css/CSSStyleSheet.h_sec1
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 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
Lines 31-36 class CSSImportRule; Source/WebCore/css/CSSStyleSheet.h_sec2
31
class CSSParser;
31
class CSSParser;
32
class CSSRule;
32
class CSSRule;
33
class CSSRuleList;
33
class CSSRuleList;
34
class CSSStyleSheet;
34
class CachedCSSStyleSheet;
35
class CachedCSSStyleSheet;
35
class CachedResourceLoader;
36
class CachedResourceLoader;
36
class Document;
37
class Document;
Lines 41-93 struct CSSNamespace; Source/WebCore/css/CSSStyleSheet.h_sec3
41
42
42
typedef int ExceptionCode;
43
typedef int ExceptionCode;
43
44
44
class CSSStyleSheet : public StyleSheet {
45
class StyleSheetInternal : public RefCounted<StyleSheetInternal> {
45
public:
46
public:
46
    static PassRefPtr<CSSStyleSheet> create()
47
    static PassRefPtr<StyleSheetInternal> create()
47
    {
48
    {
48
        return adoptRef(new CSSStyleSheet(static_cast<StyleRuleImport*>(0), String(), KURL(), String()));
49
        return adoptRef(new StyleSheetInternal(static_cast<StyleRuleImport*>(0), String(), KURL(), String()));
49
    }
50
    }
50
    static PassRefPtr<CSSStyleSheet> create(Node* ownerNode)
51
    static PassRefPtr<StyleSheetInternal> create(Node* ownerNode)
51
    {
52
    {
52
        return adoptRef(new CSSStyleSheet(ownerNode, String(), KURL(), String()));
53
        return adoptRef(new StyleSheetInternal(ownerNode, String(), KURL(), String()));
53
    }
54
    }
54
    static PassRefPtr<CSSStyleSheet> create(Node* ownerNode, const String& originalURL, const KURL& finalURL, const String& charset)
55
    static PassRefPtr<StyleSheetInternal> create(Node* ownerNode, const String& originalURL, const KURL& finalURL, const String& charset)
55
    {
56
    {
56
        return adoptRef(new CSSStyleSheet(ownerNode, originalURL, finalURL, charset));
57
        return adoptRef(new StyleSheetInternal(ownerNode, originalURL, finalURL, charset));
57
    }
58
    }
58
    static PassRefPtr<CSSStyleSheet> create(StyleRuleImport* ownerRule, const String& originalURL, const KURL& finalURL, const String& charset)
59
    static PassRefPtr<StyleSheetInternal> create(StyleRuleImport* ownerRule, const String& originalURL, const KURL& finalURL, const String& charset)
59
    {
60
    {
60
        return adoptRef(new CSSStyleSheet(ownerRule, originalURL, finalURL, charset));
61
        return adoptRef(new StyleSheetInternal(ownerRule, originalURL, finalURL, charset));
61
    }
62
    }
62
    static PassRefPtr<CSSStyleSheet> createInline(Node* ownerNode, const KURL& finalURL)
63
    static PassRefPtr<StyleSheetInternal> createInline(Node* ownerNode, const KURL& finalURL)
63
    {
64
    {
64
        return adoptRef(new CSSStyleSheet(ownerNode, finalURL.string(), finalURL, String()));
65
        return adoptRef(new StyleSheetInternal(ownerNode, finalURL.string(), finalURL, String()));
65
    }
66
    }
66
67
67
    virtual ~CSSStyleSheet();
68
    ~StyleSheetInternal();
68
69
    virtual CSSStyleSheet* parentStyleSheet() const OVERRIDE;
70
71
    PassRefPtr<CSSRuleList> cssRules();
72
    unsigned insertRule(const String& rule, unsigned index, ExceptionCode&);
73
    void deleteRule(unsigned index, ExceptionCode&);
74
75
    // IE Extensions
76
    PassRefPtr<CSSRuleList> rules();
77
    int addRule(const String& selector, const String& style, int index, ExceptionCode&);
78
    int addRule(const String& selector, const String& style, ExceptionCode&);
79
    void removeRule(unsigned index, ExceptionCode& ec) { deleteRule(index, ec); }
80
69
81
    void addNamespace(CSSParser*, const AtomicString& prefix, const AtomicString& uri);
70
    void addNamespace(CSSParser*, const AtomicString& prefix, const AtomicString& uri);
82
    const AtomicString& determineNamespace(const AtomicString& prefix);
71
    const AtomicString& determineNamespace(const AtomicString& prefix);
83
72
84
    void styleSheetChanged();
73
    void styleSheetChanged();
85
74
86
    virtual bool parseString(const String&, CSSParserMode = CSSStrictMode);
75
    bool parseString(const String&, CSSParserMode = CSSStrictMode);
87
76
88
    bool parseStringAtLine(const String&, CSSParserMode, int startLineNumber);
77
    bool parseStringAtLine(const String&, CSSParserMode, int startLineNumber);
89
78
90
    virtual bool isLoading();
79
    bool isLoading() const;
91
80
92
    void checkLoaded();
81
    void checkLoaded();
93
    void startLoadingDynamicSheet();
82
    void startLoadingDynamicSheet();
Lines 115-152 public: Source/WebCore/css/CSSStyleSheet.h_sec4
115
104
116
    void clearRules();
105
    void clearRules();
117
106
118
    unsigned length() const;
119
    CSSRule* item(unsigned index);
120
121
    // Rules other than @charset and @import.
107
    // Rules other than @charset and @import.
122
    const Vector<RefPtr<StyleRuleBase> >& childRules() const { return m_childRules; }
108
    const Vector<RefPtr<StyleRuleBase> >& childRules() const { return m_childRules; }
123
    const Vector<RefPtr<StyleRuleImport> >& importRules() const { return m_importRules; }
109
    const Vector<RefPtr<StyleRuleImport> >& importRules() const { return m_importRules; }
124
110
125
    virtual MediaList* media() const OVERRIDE;
126
127
    MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
111
    MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
128
    void setMediaQueries(PassRefPtr<MediaQuerySet>);
112
    void setMediaQueries(PassRefPtr<MediaQuerySet>);
129
113
130
    void notifyLoadedSheet(const CachedCSSStyleSheet*);
114
    void notifyLoadedSheet(const CachedCSSStyleSheet*);
131
    
115
    
132
    virtual CSSImportRule* ownerRule() const OVERRIDE;
116
    StyleSheetInternal* parentStyleSheet() const;
117
    Node* ownerNode() const { return m_ownerNode; }
118
    void clearOwnerNode() { m_ownerNode = 0; }
119
    StyleRuleImport* ownerRule() const { return m_ownerRule; }
133
    void clearOwnerRule() { m_ownerRule = 0; }
120
    void clearOwnerRule() { m_ownerRule = 0; }
134
    
121
    
135
    CSSImportRule* ensureCSSOMWrapper(StyleRuleImport*);
122
    // Note that href is the URL that started the redirect chain that led to
123
    // this style sheet. This property probably isn't useful for much except
124
    // the JavaScript binding (which needs to use this value for security).
125
    String originalURL() const { return m_originalURL; }
126
    String title() const { return m_title; }
127
    void setTitle(const String& title) { m_title = title; }
128
    
129
    void setFinalURL(const KURL& finalURL) { m_finalURL = finalURL; }
130
    const KURL& finalURL() const { return m_finalURL; }
131
    KURL baseURL() const;
136
132
137
private:
133
    unsigned ruleCount() const;
138
    CSSStyleSheet(Node* ownerNode, const String& originalURL, const KURL& finalURL, const String& charset);
134
    
139
    CSSStyleSheet(StyleRuleImport* ownerRule, const String& originalURL, const KURL& finalURL, const String& charset);
135
    bool wrapperInsertRule(PassRefPtr<StyleRuleBase>, unsigned index);
136
    void wrapperDeleteRule(unsigned index);
140
137
141
    virtual bool isCSSStyleSheet() const { return true; }
138
    PassRefPtr<CSSRule> createChildRuleCSSOMWrapper(unsigned index, CSSStyleSheet* parentWrapper);
142
    virtual String type() const { return "text/css"; }
139
140
private:
141
    StyleSheetInternal(Node* ownerNode, const String& originalURL, const KURL& finalURL, const String& charset);
142
    StyleSheetInternal(StyleRuleImport* ownerRule, const String& originalURL, const KURL& finalURL, const String& charset);
143
    
143
    
144
    void clearCharsetRule();
144
    void clearCharsetRule();
145
    bool hasCharsetRule() const { return !m_encodingFromCharsetRule.isNull(); }
145
    bool hasCharsetRule() const { return !m_encodingFromCharsetRule.isNull(); }
146
146
147
    PassRefPtr<CSSRule> createChildRuleCSSOMWrapper(unsigned index);
147
    Node* m_ownerNode;
148
149
    StyleRuleImport* m_ownerRule;
148
    StyleRuleImport* m_ownerRule;
149
150
    String m_originalURL;
151
    KURL m_finalURL;
152
    String m_title;
153
150
    String m_encodingFromCharsetRule;
154
    String m_encodingFromCharsetRule;
151
    Vector<RefPtr<StyleRuleImport> > m_importRules;
155
    Vector<RefPtr<StyleRuleImport> > m_importRules;
152
    Vector<RefPtr<StyleRuleBase> > m_childRules;
156
    Vector<RefPtr<StyleRuleBase> > m_childRules;
Lines 159-165 private: Source/WebCore/css/CSSStyleSheet.h_sec5
159
    bool m_isUserStyleSheet : 1;
163
    bool m_isUserStyleSheet : 1;
160
    bool m_hasSyntacticallyValidCSSHeader : 1;
164
    bool m_hasSyntacticallyValidCSSHeader : 1;
161
    bool m_didLoadErrorOccur : 1;
165
    bool m_didLoadErrorOccur : 1;
166
};
167
168
class CSSStyleSheet : public StyleSheet {
169
public:
170
    static RefPtr<CSSStyleSheet> create(PassRefPtr<StyleSheetInternal> sheet, CSSImportRule* ownerRule = 0) 
171
    { 
172
        return adoptRef(new CSSStyleSheet(sheet, ownerRule));
173
    }
174
175
    virtual ~CSSStyleSheet();
176
177
    virtual CSSStyleSheet* parentStyleSheet() const OVERRIDE;
178
    virtual Node* ownerNode() const OVERRIDE { return m_internal->ownerNode(); }
179
    virtual MediaList* media() const OVERRIDE;
180
    virtual String href() const OVERRIDE { return m_internal->originalURL(); }  
181
    virtual String title() const OVERRIDE { return m_internal->title(); }
182
    virtual bool disabled() const OVERRIDE { return m_isDisabled; }
183
    virtual void setDisabled(bool) OVERRIDE;
184
    
185
    PassRefPtr<CSSRuleList> cssRules();
186
    unsigned insertRule(const String& rule, unsigned index, ExceptionCode&);
187
    void deleteRule(unsigned index, ExceptionCode&);
188
    
189
    // IE Extensions
190
    PassRefPtr<CSSRuleList> rules();
191
    int addRule(const String& selector, const String& style, int index, ExceptionCode&);
192
    int addRule(const String& selector, const String& style, ExceptionCode&);
193
    void removeRule(unsigned index, ExceptionCode& ec) { deleteRule(index, ec); }
194
    
195
    // For CSSRuleList.
196
    unsigned length() const;
197
    CSSRule* item(unsigned index);
198
199
    virtual void clearOwnerNode() OVERRIDE { m_internal->clearOwnerNode(); }
200
    virtual CSSImportRule* ownerRule() const OVERRIDE { return m_ownerRule; }
201
    virtual KURL baseURL() const OVERRIDE { return m_internal->baseURL(); }
202
    virtual bool isLoading() const OVERRIDE { return m_internal->isLoading(); }
203
    
204
    void clearOwnerRule() { m_ownerRule = 0; }
205
    void styleSheetChanged() { m_internal->styleSheetChanged(); }
206
    Document* findDocument() { return m_internal->findDocument(); }
207
    
208
    void clearChildRuleCSSOMWrappers();
209
210
    StyleSheetInternal* internal() const { return m_internal.get(); }
211
212
private:
213
    CSSStyleSheet(PassRefPtr<StyleSheetInternal>, CSSImportRule* ownerRule);
214
215
    virtual bool isCSSStyleSheet() const { return true; }
216
    virtual String type() const { return "text/css"; }
217
    
218
    RefPtr<StyleSheetInternal> m_internal;
219
    bool m_isDisabled;
162
220
221
    CSSImportRule* m_ownerRule;
163
    mutable Vector<RefPtr<CSSRule> > m_childRuleCSSOMWrappers;
222
    mutable Vector<RefPtr<CSSRule> > m_childRuleCSSOMWrappers;
164
    mutable OwnPtr<CSSRuleList> m_ruleListCSSOMWrapper;
223
    mutable OwnPtr<CSSRuleList> m_ruleListCSSOMWrapper;
165
};
224
};
- Source/WebCore/css/CSSValue.cpp -1 / +1 lines
Lines 99-105 CSSValue::Type CSSValue::cssValueType() Source/WebCore/css/CSSValue.cpp_sec1
99
    return CSS_CUSTOM;
99
    return CSS_CUSTOM;
100
}
100
}
101
101
102
void CSSValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const CSSStyleSheet* styleSheet)
102
void CSSValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
103
{
103
{
104
    // This should get called for internal instances only.
104
    // This should get called for internal instances only.
105
    ASSERT(!isCSSOMSafe());
105
    ASSERT(!isCSSOMSafe());
- Source/WebCore/css/CSSValue.h -2 / +2 lines
Lines 29-35 Source/WebCore/css/CSSValue.h_sec1
29
29
30
namespace WebCore {
30
namespace WebCore {
31
31
32
class CSSStyleSheet;
32
class StyleSheetInternal;
33
    
33
    
34
// FIXME: The current CSSValue and subclasses should be turned into internal types (StyleValue).
34
// FIXME: The current CSSValue and subclasses should be turned into internal types (StyleValue).
35
// The few subtypes that are actually exposed in CSSOM can be seen in the cloneForCSSOM() function.
35
// The few subtypes that are actually exposed in CSSOM can be seen in the cloneForCSSOM() function.
Lines 107-113 public: Source/WebCore/css/CSSValue.h_sec2
107
107
108
    PassRefPtr<CSSValue> cloneForCSSOM() const;
108
    PassRefPtr<CSSValue> cloneForCSSOM() const;
109
109
110
    void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
110
    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
111
111
112
protected:
112
protected:
113
113
- Source/WebCore/css/CSSValueList.cpp -1 / +1 lines
Lines 136-142 String CSSValueList::customCssText() con Source/WebCore/css/CSSValueList.cpp_sec1
136
    return result.toString();
136
    return result.toString();
137
}
137
}
138
138
139
void CSSValueList::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const CSSStyleSheet* styleSheet)
139
void CSSValueList::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
140
{
140
{
141
    size_t size = m_values.size();
141
    size_t size = m_values.size();
142
    for (size_t i = 0; i < size; ++i)
142
    for (size_t i = 0; i < size; ++i)
- Source/WebCore/css/CSSValueList.h -1 / +1 lines
Lines 60-66 public: Source/WebCore/css/CSSValueList.h_sec1
60
60
61
    String customCssText() const;
61
    String customCssText() const;
62
62
63
    void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
63
    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
64
    
64
    
65
    PassRefPtr<CSSValueList> cloneForCSSOM() const;
65
    PassRefPtr<CSSValueList> cloneForCSSOM() const;
66
66
- Source/WebCore/css/CSSValuePool.cpp -1 / +1 lines
Lines 133-139 PassRefPtr<CSSPrimitiveValue> CSSValuePo Source/WebCore/css/CSSValuePool.cpp_sec1
133
    return value;
133
    return value;
134
}
134
}
135
135
136
PassRefPtr<CSSValueList> CSSValuePool::createFontFaceValue(const AtomicString& string, CSSStyleSheet* contextStyleSheet)
136
PassRefPtr<CSSValueList> CSSValuePool::createFontFaceValue(const AtomicString& string, StyleSheetInternal* contextStyleSheet)
137
{
137
{
138
    // Just wipe out the cache and start rebuilding if it gets too big.
138
    // Just wipe out the cache and start rebuilding if it gets too big.
139
    const int maximumFontFaceCacheSize = 128;
139
    const int maximumFontFaceCacheSize = 128;
- Source/WebCore/css/CSSValuePool.h -1 / +2 lines
Lines 36-45 Source/WebCore/css/CSSValuePool.h_sec1
36
namespace WebCore {
36
namespace WebCore {
37
37
38
class CSSValueList;
38
class CSSValueList;
39
class StyleSheetInternal;
39
40
40
class CSSValuePool {
41
class CSSValuePool {
41
public:
42
public:
42
    PassRefPtr<CSSValueList> createFontFaceValue(const AtomicString&, CSSStyleSheet* contextStyleSheet);
43
    PassRefPtr<CSSValueList> createFontFaceValue(const AtomicString&, StyleSheetInternal* contextStyleSheet);
43
    PassRefPtr<CSSPrimitiveValue> createFontFamilyValue(const String&);
44
    PassRefPtr<CSSPrimitiveValue> createFontFamilyValue(const String&);
44
    PassRefPtr<CSSInheritedValue> createInheritedValue() { return m_inheritedValue; }
45
    PassRefPtr<CSSInheritedValue> createInheritedValue() { return m_inheritedValue; }
45
    PassRefPtr<CSSInitialValue> createImplicitInitialValue() { return m_implicitInitialValue; }
46
    PassRefPtr<CSSInitialValue> createImplicitInitialValue() { return m_implicitInitialValue; }
- Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp -3 / +3 lines
Lines 153-159 void PropertySetCSSStyleDeclaration::set Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp_sec1
153
#endif
153
#endif
154
    ec = 0;
154
    ec = 0;
155
    // FIXME: Detect syntax errors and set ec.
155
    // FIXME: Detect syntax errors and set ec.
156
    m_propertySet->parseDeclaration(text, contextStyleSheet());
156
    m_propertySet->parseDeclaration(text, contextStyleSheet()->internal());
157
157
158
    didMutate();
158
    didMutate();
159
#if ENABLE(MUTATION_OBSERVERS)
159
#if ENABLE(MUTATION_OBSERVERS)
Lines 214-220 void PropertySetCSSStyleDeclaration::set Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp_sec2
214
        return;
214
        return;
215
    bool important = priority.find("important", 0, false) != notFound;
215
    bool important = priority.find("important", 0, false) != notFound;
216
    ec = 0;
216
    ec = 0;
217
    bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());
217
    bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet()->internal());
218
    if (changed) {
218
    if (changed) {
219
        // CSS DOM requires raising SYNTAX_ERR of parsing failed, but this is too dangerous for compatibility,
219
        // CSS DOM requires raising SYNTAX_ERR of parsing failed, but this is too dangerous for compatibility,
220
        // see <http://bugs.webkit.org/show_bug.cgi?id=7296>.
220
        // see <http://bugs.webkit.org/show_bug.cgi?id=7296>.
Lines 261-267 void PropertySetCSSStyleDeclaration::set Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp_sec3
261
    StyleAttributeMutationScope mutationScope(this);
261
    StyleAttributeMutationScope mutationScope(this);
262
#endif
262
#endif
263
    ec = 0;
263
    ec = 0;
264
    bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet());
264
    bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet()->internal());
265
    if (changed) {
265
    if (changed) {
266
        didMutate();
266
        didMutate();
267
#if ENABLE(MUTATION_OBSERVERS)
267
#if ENABLE(MUTATION_OBSERVERS)
- Source/WebCore/css/PropertySetCSSStyleDeclaration.h -1 / +1 lines
Lines 32-40 namespace WebCore { Source/WebCore/css/PropertySetCSSStyleDeclaration.h_sec1
32
32
33
class CSSRule;
33
class CSSRule;
34
class CSSProperty;
34
class CSSProperty;
35
class CSSStyleSheet;
36
class CSSValue;
35
class CSSValue;
37
class StylePropertySet;
36
class StylePropertySet;
37
class StyleSheetInternal;
38
class StyledElement;
38
class StyledElement;
39
39
40
class PropertySetCSSStyleDeclaration : public CSSStyleDeclaration {
40
class PropertySetCSSStyleDeclaration : public CSSStyleDeclaration {
- Source/WebCore/css/StylePropertySet.cpp -3 / +3 lines
Lines 484-490 bool StylePropertySet::isPropertyImplici Source/WebCore/css/StylePropertySet.cpp_sec1
484
    return property ? property->isImplicit() : false;
484
    return property ? property->isImplicit() : false;
485
}
485
}
486
486
487
bool StylePropertySet::setProperty(CSSPropertyID propertyID, const String& value, bool important, CSSStyleSheet* contextStyleSheet)
487
bool StylePropertySet::setProperty(CSSPropertyID propertyID, const String& value, bool important, StyleSheetInternal* contextStyleSheet)
488
{
488
{
489
    // Setting the value to an empty string just removes the property in both IE and Gecko.
489
    // Setting the value to an empty string just removes the property in both IE and Gecko.
490
    // Setting it to null seems to produce less consistent results, but we treat it just the same.
490
    // Setting it to null seems to produce less consistent results, but we treat it just the same.
Lines 531-537 bool StylePropertySet::setProperty(CSSPr Source/WebCore/css/StylePropertySet.cpp_sec2
531
    return true;
531
    return true;
532
}
532
}
533
533
534
void StylePropertySet::parseDeclaration(const String& styleDeclaration, CSSStyleSheet* contextStyleSheet)
534
void StylePropertySet::parseDeclaration(const String& styleDeclaration, StyleSheetInternal* contextStyleSheet)
535
{
535
{
536
    m_properties.clear();
536
    m_properties.clear();
537
    CSSParser parser(cssParserMode());
537
    CSSParser parser(cssParserMode());
Lines 793-799 void StylePropertySet::merge(const Style Source/WebCore/css/StylePropertySet.cpp_sec3
793
    }
793
    }
794
}
794
}
795
795
796
void StylePropertySet::addSubresourceStyleURLs(ListHashSet<KURL>& urls, CSSStyleSheet* contextStyleSheet)
796
void StylePropertySet::addSubresourceStyleURLs(ListHashSet<KURL>& urls, StyleSheetInternal* contextStyleSheet)
797
{
797
{
798
    size_t size = m_properties.size();
798
    size_t size = m_properties.size();
799
    for (size_t i = 0; i < size; ++i)
799
    for (size_t i = 0; i < size; ++i)
- Source/WebCore/css/StylePropertySet.h -3 / +4 lines
Lines 37-42 class KURL; Source/WebCore/css/StylePropertySet.h_sec1
37
class PropertySetCSSStyleDeclaration;
37
class PropertySetCSSStyleDeclaration;
38
class StyledElement;
38
class StyledElement;
39
class StylePropertyShorthand;
39
class StylePropertyShorthand;
40
class StyleSheetInternal;
40
41
41
class StylePropertySet : public RefCounted<StylePropertySet> {
42
class StylePropertySet : public RefCounted<StylePropertySet> {
42
public:
43
public:
Lines 68-74 public: Source/WebCore/css/StylePropertySet.h_sec2
68
    bool isPropertyImplicit(CSSPropertyID) const;
69
    bool isPropertyImplicit(CSSPropertyID) const;
69
70
70
    // These expand shorthand properties into multiple properties.
71
    // These expand shorthand properties into multiple properties.
71
    bool setProperty(CSSPropertyID, const String& value, bool important = false, CSSStyleSheet* contextStyleSheet = 0);
72
    bool setProperty(CSSPropertyID, const String& value, bool important = false, StyleSheetInternal* contextStyleSheet = 0);
72
    void setProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important = false);
73
    void setProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important = false);
73
74
74
    // These do not. FIXME: This is too messy, we can do better.
75
    // These do not. FIXME: This is too messy, we can do better.
Lines 77-83 public: Source/WebCore/css/StylePropertySet.h_sec3
77
    
78
    
78
    bool removeProperty(CSSPropertyID, String* returnText = 0);
79
    bool removeProperty(CSSPropertyID, String* returnText = 0);
79
80
80
    void parseDeclaration(const String& styleDeclaration, CSSStyleSheet* contextStyleSheet);
81
    void parseDeclaration(const String& styleDeclaration, StyleSheetInternal* contextStyleSheet);
81
82
82
    void addParsedProperties(const CSSProperty*, int numProperties);
83
    void addParsedProperties(const CSSProperty*, int numProperties);
83
    void addParsedProperty(const CSSProperty&);
84
    void addParsedProperty(const CSSProperty&);
Lines 91-97 public: Source/WebCore/css/StylePropertySet.h_sec4
91
    void setCSSParserMode(CSSParserMode cssParserMode) { m_cssParserMode = cssParserMode; }
92
    void setCSSParserMode(CSSParserMode cssParserMode) { m_cssParserMode = cssParserMode; }
92
    CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); }
93
    CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); }
93
94
94
    void addSubresourceStyleURLs(ListHashSet<KURL>&, CSSStyleSheet* contextStyleSheet);
95
    void addSubresourceStyleURLs(ListHashSet<KURL>&, StyleSheetInternal* contextStyleSheet);
95
96
96
    PassRefPtr<StylePropertySet> copy() const;
97
    PassRefPtr<StylePropertySet> copy() const;
97
    // Used by StyledElement::copyNonAttributeProperties().
98
    // Used by StyledElement::copyNonAttributeProperties().
- Source/WebCore/css/StyleSheet.cpp -39 lines
Lines 20-68 Source/WebCore/css/StyleSheet.cpp_sec1
20
#include "config.h"
20
#include "config.h"
21
#include "StyleSheet.h"
21
#include "StyleSheet.h"
22
22
23
#include "CSSImportRule.h"
24
#include "CSSStyleSheet.h"
25
#include "Document.h"
26
#include "Node.h"
27
28
namespace WebCore {
23
namespace WebCore {
29
24
30
StyleSheet::StyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL)
31
    : m_disabled(false)
32
    , m_ownerNode(parentNode)
33
    , m_originalURL(originalURL)
34
    , m_finalURL(finalURL)
35
{
36
}
37
38
StyleSheet::StyleSheet(const String& originalURL, const KURL& finalURL)
39
    : m_disabled(false)
40
    , m_ownerNode(0)
41
    , m_originalURL(originalURL)
42
    , m_finalURL(finalURL)
43
{
44
}
45
46
StyleSheet::~StyleSheet()
25
StyleSheet::~StyleSheet()
47
{
26
{
48
}
27
}
49
28
50
KURL StyleSheet::baseURL() const
51
{
52
    if (!m_finalURL.isNull())
53
        return m_finalURL;
54
    if (StyleSheet* parentSheet = parentStyleSheet())
55
        return parentSheet->baseURL();
56
    if (!m_ownerNode)
57
        return KURL();
58
    return m_ownerNode->document()->baseURL();
59
}
60
61
void StyleSheet::setDisabled(bool disabled)
62
{
63
     m_disabled = disabled;
64
     if (isCSSStyleSheet())
65
         static_cast<CSSStyleSheet*>(this)->styleSheetChanged();
66
}
67
68
}
29
}
- Source/WebCore/css/StyleSheet.h -37 / +10 lines
Lines 1-6 Source/WebCore/css/StyleSheet.h_sec1
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, 2008 Apple Inc. All rights reserved.
3
 * Copyright (C) 2004, 2006, 2008, 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
Lines 39-86 class StyleSheet : public RefCounted<Sty Source/WebCore/css/StyleSheet.h_sec2
39
public:
39
public:
40
    virtual ~StyleSheet();
40
    virtual ~StyleSheet();
41
41
42
    bool disabled() const { return m_disabled; }
42
    virtual bool disabled() const = 0;
43
    void setDisabled(bool);
43
    virtual void setDisabled(bool) = 0;
44
44
    virtual Node* ownerNode() const = 0;
45
    Node* ownerNode() const { return m_ownerNode; }
46
    void clearOwnerNode() { m_ownerNode = 0; }
47
48
    virtual CSSImportRule* ownerRule() const { return 0; }
49
50
    virtual StyleSheet* parentStyleSheet() const { return 0; }
45
    virtual StyleSheet* parentStyleSheet() const { return 0; }
51
46
    virtual String href() const = 0;
52
    // Note that href is the URL that started the redirect chain that led to
47
    virtual String title() const = 0;
53
    // this style sheet. This property probably isn't useful for much except
54
    // the JavaScript binding (which needs to use this value for security).
55
    const String& href() const { return m_originalURL; }
56
57
    void setFinalURL(const KURL& finalURL) { m_finalURL = finalURL; }
58
    const KURL& finalURL() const { return m_finalURL; }
59
60
    const String& title() const { return m_strTitle; }
61
    void setTitle(const String& s) { m_strTitle = s; }
62
    virtual MediaList* media() const { return 0; }
48
    virtual MediaList* media() const { return 0; }
63
64
    virtual String type() const = 0;
49
    virtual String type() const = 0;
65
    virtual bool isLoading() = 0;
66
67
    virtual bool parseString(const String&, CSSParserMode = CSSStrictMode) = 0;
68
50
51
    virtual CSSImportRule* ownerRule() const { return 0; }
52
    virtual void clearOwnerNode() = 0;
53
    virtual KURL baseURL() const = 0;
54
    virtual bool isLoading() const = 0;
69
    virtual bool isCSSStyleSheet() const { return false; }
55
    virtual bool isCSSStyleSheet() const { return false; }
70
    virtual bool isXSLStyleSheet() const { return false; }
56
    virtual bool isXSLStyleSheet() const { return false; }
71
72
    KURL baseURL() const;
73
74
protected:
75
    StyleSheet(Node* ownerNode, const String& href, const KURL& finalURL);
76
    StyleSheet(const String& href, const KURL& finalURL);
77
78
private:
79
    bool m_disabled;
80
    Node* m_ownerNode;
81
    String m_originalURL;
82
    KURL m_finalURL;
83
    String m_strTitle;
84
};
57
};
85
58
86
} // namespace
59
} // namespace
- Source/WebCore/css/WebKitCSSKeyframesRule.cpp -2 / +3 lines
Lines 109-116 void WebKitCSSKeyframesRule::insertRule( Source/WebCore/css/WebKitCSSKeyframesRule.cpp_sec1
109
{
109
{
110
    ASSERT(m_childRuleCSSOMWrappers.size() == m_keyframesRule->keyframes().size());
110
    ASSERT(m_childRuleCSSOMWrappers.size() == m_keyframesRule->keyframes().size());
111
111
112
    CSSParser p(cssParserMode());
112
    CSSStyleSheet* styleSheet = parentStyleSheet();
113
    RefPtr<StyleKeyframe> keyframe = p.parseKeyframeRule(parentStyleSheet(), ruleText);
113
    CSSParser parser(styleSheet ? styleSheet->internal()->cssParserMode() : CSSStrictMode);
114
    RefPtr<StyleKeyframe> keyframe = parser.parseKeyframeRule(styleSheet ? styleSheet->internal() : 0, ruleText);
114
    if (!keyframe)
115
    if (!keyframe)
115
        return;
116
        return;
116
117
- Source/WebCore/dom/DOMImplementation.cpp -2 / +2 lines
Lines 307-315 PassRefPtr<CSSStyleSheet> DOMImplementat Source/WebCore/dom/DOMImplementation.cpp_sec1
307
{
307
{
308
    // FIXME: Title should be set.
308
    // FIXME: Title should be set.
309
    // FIXME: Media could have wrong syntax, in which case we should generate an exception.
309
    // FIXME: Media could have wrong syntax, in which case we should generate an exception.
310
    RefPtr<CSSStyleSheet> sheet = CSSStyleSheet::create();
310
    RefPtr<StyleSheetInternal> sheet = StyleSheetInternal::create();
311
    sheet->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(media));
311
    sheet->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(media));
312
    return sheet.release();
312
    return CSSStyleSheet::create(sheet);
313
}
313
}
314
314
315
static const char* const validXMLMIMETypeChars = "[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]"; // per RFCs: 3023, 2045
315
static const char* const validXMLMIMETypeChars = "[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]"; // per RFCs: 3023, 2045
- Source/WebCore/dom/Document.cpp -14 / +14 lines
Lines 3-9 Source/WebCore/dom/Document.cpp_sec1
3
 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
3
 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
4
 *           (C) 2001 Dirk Mueller (mueller@kde.org)
4
 *           (C) 2001 Dirk Mueller (mueller@kde.org)
5
 *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
5
 *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6
 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
6
 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved.
7
 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
7
 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
8
 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved.
8
 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved.
9
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
Lines 2557-2563 void Document::updateBaseURL() Source/WebCore/dom/Document.cpp_sec2
2557
        m_baseURL = KURL();
2557
        m_baseURL = KURL();
2558
2558
2559
    if (m_elemSheet)
2559
    if (m_elemSheet)
2560
        m_elemSheet->setFinalURL(m_baseURL);
2560
        m_elemSheet->internal()->setFinalURL(m_baseURL);
2561
    
2561
    
2562
    if (!equalIgnoringFragmentIdentifier(oldBaseURL, m_baseURL)) {
2562
    if (!equalIgnoringFragmentIdentifier(oldBaseURL, m_baseURL)) {
2563
        // Base URL change changes any relative visited links.
2563
        // Base URL change changes any relative visited links.
Lines 2688-2694 bool Document::canBeAccessedByEveryAnces Source/WebCore/dom/Document.cpp_sec3
2688
    return true;
2688
    return true;
2689
}
2689
}
2690
2690
2691
CSSStyleSheet* Document::pageUserSheet()
2691
StyleSheetInternal* Document::pageUserSheet()
2692
{
2692
{
2693
    if (m_pageUserSheet)
2693
    if (m_pageUserSheet)
2694
        return m_pageUserSheet.get();
2694
        return m_pageUserSheet.get();
Lines 2702-2708 CSSStyleSheet* Document::pageUserSheet() Source/WebCore/dom/Document.cpp_sec4
2702
        return 0;
2702
        return 0;
2703
    
2703
    
2704
    // Parse the sheet and cache it.
2704
    // Parse the sheet and cache it.
2705
    m_pageUserSheet = CSSStyleSheet::createInline(this, settings()->userStyleSheetLocation());
2705
    m_pageUserSheet = StyleSheetInternal::createInline(this, settings()->userStyleSheetLocation());
2706
    m_pageUserSheet->setIsUserStyleSheet(true);
2706
    m_pageUserSheet->setIsUserStyleSheet(true);
2707
    m_pageUserSheet->parseString(userSheetText, strictToCSSParserMode(!inQuirksMode()));
2707
    m_pageUserSheet->parseString(userSheetText, strictToCSSParserMode(!inQuirksMode()));
2708
    return m_pageUserSheet.get();
2708
    return m_pageUserSheet.get();
Lines 2723-2729 void Document::updatePageUserSheet() Source/WebCore/dom/Document.cpp_sec5
2723
        styleSelectorChanged(RecalcStyleImmediately);
2723
        styleSelectorChanged(RecalcStyleImmediately);
2724
}
2724
}
2725
2725
2726
const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const
2726
const Vector<RefPtr<StyleSheetInternal> >* Document::pageGroupUserSheets() const
2727
{
2727
{
2728
    if (m_pageGroupUserSheetCacheValid)
2728
    if (m_pageGroupUserSheetCacheValid)
2729
        return m_pageGroupUserSheets.get();
2729
        return m_pageGroupUserSheets.get();
Lines 2748-2758 const Vector<RefPtr<CSSStyleSheet> >* Do Source/WebCore/dom/Document.cpp_sec6
2748
                continue;
2748
                continue;
2749
            if (!UserContentURLPattern::matchesPatterns(url(), sheet->whitelist(), sheet->blacklist()))
2749
            if (!UserContentURLPattern::matchesPatterns(url(), sheet->whitelist(), sheet->blacklist()))
2750
                continue;
2750
                continue;
2751
            RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::createInline(const_cast<Document*>(this), sheet->url());
2751
            RefPtr<StyleSheetInternal> parsedSheet = StyleSheetInternal::createInline(const_cast<Document*>(this), sheet->url());
2752
            parsedSheet->setIsUserStyleSheet(sheet->level() == UserStyleUserLevel);
2752
            parsedSheet->setIsUserStyleSheet(sheet->level() == UserStyleUserLevel);
2753
            parsedSheet->parseString(sheet->source(), strictToCSSParserMode(!inQuirksMode()));
2753
            parsedSheet->parseString(sheet->source(), strictToCSSParserMode(!inQuirksMode()));
2754
            if (!m_pageGroupUserSheets)
2754
            if (!m_pageGroupUserSheets)
2755
                m_pageGroupUserSheets = adoptPtr(new Vector<RefPtr<CSSStyleSheet> >);
2755
                m_pageGroupUserSheets = adoptPtr(new Vector<RefPtr<StyleSheetInternal> >);
2756
            m_pageGroupUserSheets->append(parsedSheet.release());
2756
            m_pageGroupUserSheets->append(parsedSheet.release());
2757
        }
2757
        }
2758
    }
2758
    }
Lines 2776-2785 void Document::updatePageGroupUserSheets Source/WebCore/dom/Document.cpp_sec7
2776
        styleSelectorChanged(RecalcStyleImmediately);
2776
        styleSelectorChanged(RecalcStyleImmediately);
2777
}
2777
}
2778
2778
2779
void Document::addUserSheet(PassRefPtr<CSSStyleSheet> userSheet)
2779
void Document::addUserSheet(PassRefPtr<StyleSheetInternal> userSheet)
2780
{
2780
{
2781
    if (!m_userSheets)
2781
    if (!m_userSheets)
2782
        m_userSheets = adoptPtr(new Vector<RefPtr<CSSStyleSheet> >);
2782
        m_userSheets = adoptPtr(new Vector<RefPtr<StyleSheetInternal> >);
2783
    m_userSheets->append(userSheet);
2783
    m_userSheets->append(userSheet);
2784
    styleSelectorChanged(RecalcStyleImmediately);
2784
    styleSelectorChanged(RecalcStyleImmediately);
2785
}
2785
}
Lines 2787-2793 void Document::addUserSheet(PassRefPtr<C Source/WebCore/dom/Document.cpp_sec8
2787
CSSStyleSheet* Document::elementSheet()
2787
CSSStyleSheet* Document::elementSheet()
2788
{
2788
{
2789
    if (!m_elemSheet)
2789
    if (!m_elemSheet)
2790
        m_elemSheet = CSSStyleSheet::createInline(this, m_baseURL);
2790
        m_elemSheet = CSSStyleSheet::create(StyleSheetInternal::createInline(this, m_baseURL));
2791
    return m_elemSheet.get();
2791
    return m_elemSheet.get();
2792
}
2792
}
2793
2793
Lines 3316-3325 void Document::collectActiveStylesheets( Source/WebCore/dom/Document.cpp_sec9
3316
    }
3316
    }
3317
}
3317
}
3318
3318
3319
bool Document::testAddedStylesheetRequiresStyleRecalc(CSSStyleSheet* stylesheet)
3319
bool Document::testAddedStylesheetRequiresStyleRecalc(StyleSheetInternal* stylesheet)
3320
{
3320
{
3321
    if (stylesheet->disabled())
3322
        return false;
3323
    // See if all rules on the sheet are scoped to some specific ids or classes.
3321
    // See if all rules on the sheet are scoped to some specific ids or classes.
3324
    // Then test if we actually have any of those in the tree at the moment.
3322
    // Then test if we actually have any of those in the tree at the moment.
3325
    // FIXME: Even we if we find some, we could just invalidate those subtrees instead of invalidating the entire style.
3323
    // FIXME: Even we if we find some, we could just invalidate those subtrees instead of invalidating the entire style.
Lines 3391-3397 void Document::analyzeStylesheetChange(S Source/WebCore/dom/Document.cpp_sec10
3391
    for (unsigned i = oldStylesheetCount; i < newStylesheetCount; ++i) {
3389
    for (unsigned i = oldStylesheetCount; i < newStylesheetCount; ++i) {
3392
        if (!newStylesheets[i]->isCSSStyleSheet())
3390
        if (!newStylesheets[i]->isCSSStyleSheet())
3393
            return;
3391
            return;
3394
        if (testAddedStylesheetRequiresStyleRecalc(static_cast<CSSStyleSheet*>(newStylesheets[i].get())))
3392
        if (newStylesheets[i]->disabled())
3393
            continue;
3394
        if (testAddedStylesheetRequiresStyleRecalc(static_cast<CSSStyleSheet*>(newStylesheets[i].get())->internal()))
3395
            return;
3395
            return;
3396
    }
3396
    }
3397
    requiresFullStyleRecalc = false;
3397
    requiresFullStyleRecalc = false;
- Source/WebCore/dom/Document.h -9 / +10 lines
Lines 3-9 Source/WebCore/dom/Document.h_sec1
3
 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
3
 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
4
 *           (C) 2001 Dirk Mueller (mueller@kde.org)
4
 *           (C) 2001 Dirk Mueller (mueller@kde.org)
5
 *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
5
 *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6
 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
6
 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
7
 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
7
 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
8
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
8
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9
 * Copyright (C) 2011 Google Inc. All rights reserved.
9
 * Copyright (C) 2011 Google Inc. All rights reserved.
Lines 127-132 class SerializedScriptValue; Source/WebCore/dom/Document.h_sec2
127
class SegmentedString;
127
class SegmentedString;
128
class Settings;
128
class Settings;
129
class StyleSheet;
129
class StyleSheet;
130
class StyleSheetInternal;
130
class StyleSheetList;
131
class StyleSheetList;
131
class Text;
132
class Text;
132
class TextResourceDecoder;
133
class TextResourceDecoder;
Lines 623-638 public: Source/WebCore/dom/Document.h_sec3
623
    bool canNavigate(Frame* targetFrame);
624
    bool canNavigate(Frame* targetFrame);
624
    bool canBeAccessedByEveryAncestorFrame();
625
    bool canBeAccessedByEveryAncestorFrame();
625
626
626
    CSSStyleSheet* pageUserSheet();
627
    StyleSheetInternal* pageUserSheet();
627
    void clearPageUserSheet();
628
    void clearPageUserSheet();
628
    void updatePageUserSheet();
629
    void updatePageUserSheet();
629
630
630
    const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets() const;
631
    const Vector<RefPtr<StyleSheetInternal> >* pageGroupUserSheets() const;
631
    void clearPageGroupUserSheets();
632
    void clearPageGroupUserSheets();
632
    void updatePageGroupUserSheets();
633
    void updatePageGroupUserSheets();
633
634
634
    const Vector<RefPtr<CSSStyleSheet> >* documentUserSheets() const { return m_userSheets.get(); }
635
    const Vector<RefPtr<StyleSheetInternal> >* documentUserSheets() const { return m_userSheets.get(); }
635
    void addUserSheet(PassRefPtr<CSSStyleSheet> userSheet);
636
    void addUserSheet(PassRefPtr<StyleSheetInternal> userSheet);
636
637
637
    CSSStyleSheet* elementSheet();
638
    CSSStyleSheet* elementSheet();
638
    
639
    
Lines 1181-1187 private: Source/WebCore/dom/Document.h_sec4
1181
    
1182
    
1182
    bool updateActiveStylesheets(StyleSelectorUpdateFlag);
1183
    bool updateActiveStylesheets(StyleSelectorUpdateFlag);
1183
    void collectActiveStylesheets(Vector<RefPtr<StyleSheet> >&);
1184
    void collectActiveStylesheets(Vector<RefPtr<StyleSheet> >&);
1184
    bool testAddedStylesheetRequiresStyleRecalc(CSSStyleSheet*);
1185
    bool testAddedStylesheetRequiresStyleRecalc(StyleSheetInternal*);
1185
    void analyzeStylesheetChange(StyleSelectorUpdateFlag, const Vector<RefPtr<StyleSheet> >& newStylesheets, bool& requiresStyleSelectorReset, bool& requiresFullStyleRecalc);
1186
    void analyzeStylesheetChange(StyleSelectorUpdateFlag, const Vector<RefPtr<StyleSheet> >& newStylesheets, bool& requiresStyleSelectorReset, bool& requiresFullStyleRecalc);
1186
1187
1187
    void deleteCustomFonts();
1188
    void deleteCustomFonts();
Lines 1257-1265 private: Source/WebCore/dom/Document.h_sec5
1257
    bool m_hasNodesWithPlaceholderStyle;
1258
    bool m_hasNodesWithPlaceholderStyle;
1258
1259
1259
    RefPtr<CSSStyleSheet> m_elemSheet;
1260
    RefPtr<CSSStyleSheet> m_elemSheet;
1260
    RefPtr<CSSStyleSheet> m_pageUserSheet;
1261
    RefPtr<StyleSheetInternal> m_pageUserSheet;
1261
    mutable OwnPtr<Vector<RefPtr<CSSStyleSheet> > > m_pageGroupUserSheets;
1262
    mutable OwnPtr<Vector<RefPtr<StyleSheetInternal> > > m_pageGroupUserSheets;
1262
    OwnPtr<Vector<RefPtr<CSSStyleSheet> > > m_userSheets;
1263
    OwnPtr<Vector<RefPtr<StyleSheetInternal> > > m_userSheets;
1263
    mutable bool m_pageGroupUserSheetCacheValid;
1264
    mutable bool m_pageGroupUserSheetCacheValid;
1264
1265
1265
    bool m_printing;
1266
    bool m_printing;
- Source/WebCore/dom/ElementAttributeData.cpp -2 / +3 lines
Lines 3-9 Source/WebCore/dom/ElementAttributeData.cpp_sec1
3
 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
3
 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
4
 *           (C) 2001 Peter Kelly (pmk@post.com)
4
 *           (C) 2001 Peter Kelly (pmk@post.com)
5
 *           (C) 2001 Dirk Mueller (mueller@kde.org)
5
 *           (C) 2001 Dirk Mueller (mueller@kde.org)
6
 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010 Apple Inc. All rights reserved.
6
 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010, 2012 Apple Inc. All rights reserved.
7
 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
7
 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
8
 *
8
 *
9
 * This library is free software; you can redistribute it and/or
9
 * This library is free software; you can redistribute it and/or
Lines 26-31 Source/WebCore/dom/ElementAttributeData.cpp_sec2
26
#include "config.h"
26
#include "config.h"
27
#include "ElementAttributeData.h"
27
#include "ElementAttributeData.h"
28
28
29
#include "CSSStyleSheet.h"
29
#include "StyledElement.h"
30
#include "StyledElement.h"
30
31
31
namespace WebCore {
32
namespace WebCore {
Lines 82-88 void ElementAttributeData::updateInlineS Source/WebCore/dom/ElementAttributeData.cpp_sec3
82
        m_inlineStyleDecl = StylePropertySet::create();
83
        m_inlineStyleDecl = StylePropertySet::create();
83
        m_inlineStyleDecl->setCSSParserMode(strictToCSSParserMode(element->isHTMLElement() && !element->document()->inQuirksMode()));
84
        m_inlineStyleDecl->setCSSParserMode(strictToCSSParserMode(element->isHTMLElement() && !element->document()->inQuirksMode()));
84
    }
85
    }
85
    m_inlineStyleDecl->parseDeclaration(text, element->document()->elementSheet());
86
    m_inlineStyleDecl->parseDeclaration(text, element->document()->elementSheet()->internal());
86
}
87
}
87
88
88
void ElementAttributeData::destroyInlineStyle(StyledElement* element)
89
void ElementAttributeData::destroyInlineStyle(StyledElement* element)
- Source/WebCore/dom/ProcessingInstruction.cpp -8 / +13 lines
Lines 211-225 void ProcessingInstruction::setCSSStyleS Source/WebCore/dom/ProcessingInstruction.cpp_sec1
211
    }
211
    }
212
212
213
    ASSERT(m_isCSS);
213
    ASSERT(m_isCSS);
214
    RefPtr<CSSStyleSheet> newSheet = CSSStyleSheet::create(this, href, baseURL, charset);
214
    RefPtr<StyleSheetInternal> newSheet = StyleSheetInternal::create(this, href, baseURL, charset);
215
    m_sheet = newSheet;
215
    m_sheet = CSSStyleSheet::create(newSheet);
216
    // We don't need the cross-origin security check here because we are
216
    // We don't need the cross-origin security check here because we are
217
    // getting the sheet text in "strict" mode. This enforces a valid CSS MIME
217
    // getting the sheet text in "strict" mode. This enforces a valid CSS MIME
218
    // type.
218
    // type.
219
    parseStyleSheet(sheet->sheetText(true));
220
    newSheet->setTitle(m_title);
219
    newSheet->setTitle(m_title);
221
    newSheet->setMediaQueries(MediaQuerySet::create(m_media));
220
    newSheet->setMediaQueries(MediaQuerySet::create(m_media));
222
    newSheet->setDisabled(m_alternate);
221
    m_sheet->setDisabled(m_alternate);
222
223
    parseStyleSheet(sheet->sheetText(true));
223
}
224
}
224
225
225
#if ENABLE(XSLT)
226
#if ENABLE(XSLT)
Lines 233-239 void ProcessingInstruction::setXSLStyleS Source/WebCore/dom/ProcessingInstruction.cpp_sec2
233
234
234
void ProcessingInstruction::parseStyleSheet(const String& sheet)
235
void ProcessingInstruction::parseStyleSheet(const String& sheet)
235
{
236
{
236
    m_sheet->parseString(sheet, CSSStrictMode);
237
    if (m_isCSS)
238
        static_cast<CSSStyleSheet*>(m_sheet.get())->internal()->parseString(sheet, CSSStrictMode);
239
    else if (m_isXSL)
240
        static_cast<XSLStyleSheet*>(m_sheet.get())->parseString(sheet, CSSStrictMode);
241
237
    if (m_cachedSheet)
242
    if (m_cachedSheet)
238
        m_cachedSheet->removeClient(this);
243
        m_cachedSheet->removeClient(this);
239
    m_cachedSheet = 0;
244
    m_cachedSheet = 0;
Lines 241-247 void ProcessingInstruction::parseStyleSh Source/WebCore/dom/ProcessingInstruction.cpp_sec3
241
    m_loading = false;
246
    m_loading = false;
242
247
243
    if (m_isCSS)
248
    if (m_isCSS)
244
        static_cast<CSSStyleSheet*>(m_sheet.get())->checkLoaded();
249
        static_cast<CSSStyleSheet*>(m_sheet.get())->internal()->checkLoaded();
245
#if ENABLE(XSLT)
250
#if ENABLE(XSLT)
246
    else if (m_isXSL)
251
    else if (m_isXSL)
247
        static_cast<XSLStyleSheet*>(m_sheet.get())->checkLoaded();
252
        static_cast<XSLStyleSheet*>(m_sheet.get())->checkLoaded();
Lines 253-260 void ProcessingInstruction::setCSSStyleS Source/WebCore/dom/ProcessingInstruction.cpp_sec4
253
    ASSERT(!m_cachedSheet);
258
    ASSERT(!m_cachedSheet);
254
    ASSERT(!m_loading);
259
    ASSERT(!m_loading);
255
    m_sheet = sheet;
260
    m_sheet = sheet;
256
    m_sheet->setTitle(m_title);
261
    sheet->internal()->setTitle(m_title);
257
    m_sheet->setDisabled(m_alternate);
262
    sheet->setDisabled(m_alternate);
258
}
263
}
259
264
260
bool ProcessingInstruction::offsetInCharacters() const
265
bool ProcessingInstruction::offsetInCharacters() const
- Source/WebCore/dom/StyleElement.cpp -5 / +6 lines
Lines 164-179 void StyleElement::createSheet(Element* Source/WebCore/dom/StyleElement.cpp_sec1
164
        if (screenEval.eval(mediaQueries.get()) || printEval.eval(mediaQueries.get())) {
164
        if (screenEval.eval(mediaQueries.get()) || printEval.eval(mediaQueries.get())) {
165
            document->addPendingSheet();
165
            document->addPendingSheet();
166
            m_loading = true;
166
            m_loading = true;
167
            m_sheet = CSSStyleSheet::create(e, String(), KURL(), document->inputEncoding());
167
            RefPtr<StyleSheetInternal> styleSheet = StyleSheetInternal::create(e, String(), KURL(), document->inputEncoding());
168
            m_sheet->parseStringAtLine(text, strictToCSSParserMode(!document->inQuirksMode()), startLineNumber);
168
            styleSheet->parseStringAtLine(text, strictToCSSParserMode(!document->inQuirksMode()), startLineNumber);
169
            m_sheet->setMediaQueries(mediaQueries.release());
169
            styleSheet->setMediaQueries(mediaQueries.release());
170
            m_sheet->setTitle(e->title());
170
            styleSheet->setTitle(e->title());
171
            m_sheet = CSSStyleSheet::create(styleSheet);
171
            m_loading = false;
172
            m_loading = false;
172
        }
173
        }
173
    }
174
    }
174
175
175
    if (m_sheet)
176
    if (m_sheet)
176
        m_sheet->checkLoaded();
177
        m_sheet->internal()->checkLoaded();
177
}
178
}
178
179
179
bool StyleElement::isLoading() const
180
bool StyleElement::isLoading() const
- Source/WebCore/dom/StyledElement.cpp -2 / +7 lines
Lines 206-212 bool StyledElement::setInlineStyleProper Source/WebCore/dom/StyledElement.cpp_sec1
206
206
207
bool StyledElement::setInlineStyleProperty(CSSPropertyID propertyID, const String& value, bool important)
207
bool StyledElement::setInlineStyleProperty(CSSPropertyID propertyID, const String& value, bool important)
208
{
208
{
209
    bool changes = ensureAttributeData()->ensureMutableInlineStyle(this)->setProperty(propertyID, value, important, document()->elementSheet());
209
    bool changes = ensureAttributeData()->ensureMutableInlineStyle(this)->setProperty(propertyID, value, important, document()->elementSheet()->internal());
210
    if (changes)
210
    if (changes)
211
        inlineStyleChanged();
211
        inlineStyleChanged();
212
    return changes;
212
    return changes;
Lines 226-232 bool StyledElement::removeInlineStylePro Source/WebCore/dom/StyledElement.cpp_sec2
226
void StyledElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
226
void StyledElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
227
{
227
{
228
    if (StylePropertySet* inlineStyle = attributeData() ? attributeData()->inlineStyle() : 0)
228
    if (StylePropertySet* inlineStyle = attributeData() ? attributeData()->inlineStyle() : 0)
229
        inlineStyle->addSubresourceStyleURLs(urls, document()->elementSheet());
229
        inlineStyle->addSubresourceStyleURLs(urls, document()->elementSheet()->internal());
230
}
230
}
231
231
232
static inline bool attributeNameSort(const pair<AtomicStringImpl*, AtomicString>& p1, const pair<AtomicStringImpl*, AtomicString>& p2)
232
static inline bool attributeNameSort(const pair<AtomicStringImpl*, AtomicString>& p1, const pair<AtomicStringImpl*, AtomicString>& p2)
Lines 333-337 void StyledElement::addPropertyToAttribu Source/WebCore/dom/StyledElement.cpp_sec3
333
{
333
{
334
    style->setProperty(propertyID, cssValuePool().createValue(value, unit));
334
    style->setProperty(propertyID, cssValuePool().createValue(value, unit));
335
}
335
}
336
    
337
void StyledElement::addPropertyToAttributeStyle(StylePropertySet* style, CSSPropertyID propertyID, const String& value)
338
{
339
    style->setProperty(propertyID, value, false, document()->elementSheet()->internal());
340
}
336
341
337
}
342
}
- Source/WebCore/dom/StyledElement.h -5 lines
Lines 113-123 inline StylePropertySet* StyledElement:: Source/WebCore/dom/StyledElement.h_sec1
113
    return attributeData() ? attributeData()->attributeStyle() : 0;
113
    return attributeData() ? attributeData()->attributeStyle() : 0;
114
}
114
}
115
115
116
inline void StyledElement::addPropertyToAttributeStyle(StylePropertySet* style, CSSPropertyID propertyID, const String& value)
117
{
118
    style->setProperty(propertyID, value, false, document()->elementSheet());
119
}
120
121
} //namespace
116
} //namespace
122
117
123
#endif
118
#endif
- Source/WebCore/html/HTMLFontElement.cpp -1 / +2 lines
Lines 25-30 Source/WebCore/html/HTMLFontElement.cpp_sec1
25
25
26
#include "Attribute.h"
26
#include "Attribute.h"
27
#include "CSSPropertyNames.h"
27
#include "CSSPropertyNames.h"
28
#include "CSSStyleSheet.h"
28
#include "CSSValueKeywords.h"
29
#include "CSSValueKeywords.h"
29
#include "CSSValueList.h"
30
#include "CSSValueList.h"
30
#include "CSSValuePool.h"
31
#include "CSSValuePool.h"
Lines 176-182 void HTMLFontElement::collectStyleForAtt Source/WebCore/html/HTMLFontElement.cpp_sec2
176
    } else if (attr->name() == colorAttr)
177
    } else if (attr->name() == colorAttr)
177
        addHTMLColorToStyle(style, CSSPropertyColor, attr->value());
178
        addHTMLColorToStyle(style, CSSPropertyColor, attr->value());
178
    else if (attr->name() == faceAttr) {
179
    else if (attr->name() == faceAttr) {
179
        if (RefPtr<CSSValueList> fontFaceValue = cssValuePool().createFontFaceValue(attr->value(), document()->elementSheet()))
180
        if (RefPtr<CSSValueList> fontFaceValue = cssValuePool().createFontFaceValue(attr->value(), document()->elementSheet()->internal()))
180
            style->setProperty(CSSProperty(CSSPropertyFontFamily, fontFaceValue.release()));
181
            style->setProperty(CSSProperty(CSSPropertyFontFamily, fontFaceValue.release()));
181
    } else
182
    } else
182
        HTMLElement::collectStyleForAttribute(attr, style);
183
        HTMLElement::collectStyleForAttribute(attr, style);
- Source/WebCore/html/HTMLLinkElement.cpp -14 / +14 lines
Lines 155-161 void HTMLLinkElement::parseAttribute(Att Source/WebCore/html/HTMLLinkElement.cpp_sec1
155
        setAttributeEventListener(eventNames().errorEvent, createAttributeEventListener(this, attr));
155
        setAttributeEventListener(eventNames().errorEvent, createAttributeEventListener(this, attr));
156
    else {
156
    else {
157
        if (attr->name() == titleAttr && m_sheet)
157
        if (attr->name() == titleAttr && m_sheet)
158
            m_sheet->setTitle(attr->value());
158
            m_sheet->internal()->setTitle(attr->value());
159
        HTMLElement::parseAttribute(attr);
159
        HTMLElement::parseAttribute(attr);
160
    }
160
    }
161
}
161
}
Lines 284-290 void HTMLLinkElement::setCSSStyleSheet(c Source/WebCore/html/HTMLLinkElement.cpp_sec2
284
        return;
284
        return;
285
    }
285
    }
286
286
287
    m_sheet = CSSStyleSheet::create(this, href, baseURL, charset);
287
    RefPtr<StyleSheetInternal> styleSheet = StyleSheetInternal::create(this, href, baseURL, charset);
288
288
289
    bool strictParsing = !document()->inQuirksMode();
289
    bool strictParsing = !document()->inQuirksMode();
290
    bool enforceMIMEType = strictParsing;
290
    bool enforceMIMEType = strictParsing;
Lines 306-312 void HTMLLinkElement::setCSSStyleSheet(c Source/WebCore/html/HTMLLinkElement.cpp_sec3
306
#endif
306
#endif
307
307
308
    String sheetText = sheet->sheetText(enforceMIMEType, &validMIMEType);
308
    String sheetText = sheet->sheetText(enforceMIMEType, &validMIMEType);
309
    m_sheet->parseString(sheetText, strictToCSSParserMode(strictParsing));
309
    styleSheet->parseString(sheetText, strictToCSSParserMode(strictParsing));
310
310
311
    // If we're loading a stylesheet cross-origin, and the MIME type is not
311
    // If we're loading a stylesheet cross-origin, and the MIME type is not
312
    // standard, require the CSS to at least start with a syntactically
312
    // standard, require the CSS to at least start with a syntactically
Lines 316-323 void HTMLLinkElement::setCSSStyleSheet(c Source/WebCore/html/HTMLLinkElement.cpp_sec4
316
    if (!document()->securityOrigin()->canRequest(baseURL))
316
    if (!document()->securityOrigin()->canRequest(baseURL))
317
        crossOriginCSS = true;
317
        crossOriginCSS = true;
318
318
319
    if (crossOriginCSS && !validMIMEType && !m_sheet->hasSyntacticallyValidCSSHeader())
319
    if (crossOriginCSS && !validMIMEType && !styleSheet->hasSyntacticallyValidCSSHeader())
320
        m_sheet = CSSStyleSheet::create(this, href, baseURL, charset);
320
        styleSheet = StyleSheetInternal::create(this, href, baseURL, charset);
321
321
322
    if (strictParsing && needsSiteSpecificQuirks) {
322
    if (strictParsing && needsSiteSpecificQuirks) {
323
        // Work around <https://bugs.webkit.org/show_bug.cgi?id=28350>.
323
        // Work around <https://bugs.webkit.org/show_bug.cgi?id=28350>.
Lines 327-346 void HTMLLinkElement::setCSSStyleSheet(c Source/WebCore/html/HTMLLinkElement.cpp_sec5
327
        // while the other lacks the second trailing newline.
327
        // while the other lacks the second trailing newline.
328
        if (baseURL.string().endsWith(slashKHTMLFixesDotCss) && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText)
328
        if (baseURL.string().endsWith(slashKHTMLFixesDotCss) && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText)
329
                && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1) {
329
                && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1) {
330
            ASSERT(m_sheet->length() == 1);
330
            ASSERT(styleSheet->ruleCount() == 1);
331
            ExceptionCode ec;
331
            styleSheet->clearRules();
332
            m_sheet->deleteRule(0, ec);
333
        }
332
        }
334
    }
333
    }
334
    m_sheet = CSSStyleSheet::create(styleSheet);
335
335
336
    m_sheet->setTitle(title());
336
    styleSheet->setTitle(title());
337
337
338
    RefPtr<MediaQuerySet> media = MediaQuerySet::createAllowingDescriptionSyntax(m_media);
338
    RefPtr<MediaQuerySet> media = MediaQuerySet::createAllowingDescriptionSyntax(m_media);
339
    m_sheet->setMediaQueries(media.release());
339
    styleSheet->setMediaQueries(media.release());
340
340
341
    m_loading = false;
341
    m_loading = false;
342
    m_sheet->notifyLoadedSheet(sheet);
342
    styleSheet->notifyLoadedSheet(sheet);
343
    m_sheet->checkLoaded();
343
    styleSheet->checkLoaded();
344
}
344
}
345
345
346
bool HTMLLinkElement::styleSheetIsLoading() const
346
bool HTMLLinkElement::styleSheetIsLoading() const
Lines 349-355 bool HTMLLinkElement::styleSheetIsLoadin Source/WebCore/html/HTMLLinkElement.cpp_sec6
349
        return true;
349
        return true;
350
    if (!m_sheet)
350
    if (!m_sheet)
351
        return false;
351
        return false;
352
    return m_sheet->isLoading();
352
    return m_sheet->internal()->isLoading();
353
}
353
}
354
354
355
void HTMLLinkElement::linkLoaded()
355
void HTMLLinkElement::linkLoaded()
Lines 442-448 void HTMLLinkElement::addSubresourceAttr Source/WebCore/html/HTMLLinkElement.cpp_sec7
442
    
442
    
443
    // Walk the URLs linked by the linked-to stylesheet.
443
    // Walk the URLs linked by the linked-to stylesheet.
444
    if (CSSStyleSheet* styleSheet = const_cast<HTMLLinkElement*>(this)->sheet())
444
    if (CSSStyleSheet* styleSheet = const_cast<HTMLLinkElement*>(this)->sheet())
445
        styleSheet->addSubresourceStyleURLs(urls);
445
        styleSheet->internal()->addSubresourceStyleURLs(urls);
446
}
446
}
447
447
448
void HTMLLinkElement::addPendingSheet(PendingSheetType type)
448
void HTMLLinkElement::addPendingSheet(PendingSheetType type)
- Source/WebCore/html/HTMLStyleElement.cpp -2 / +2 lines
Lines 73-79 PassRefPtr<HTMLStyleElement> HTMLStyleEl Source/WebCore/html/HTMLStyleElement.cpp_sec1
73
void HTMLStyleElement::parseAttribute(Attribute* attr)
73
void HTMLStyleElement::parseAttribute(Attribute* attr)
74
{
74
{
75
    if (attr->name() == titleAttr && m_sheet)
75
    if (attr->name() == titleAttr && m_sheet)
76
        m_sheet->setTitle(attr->value());
76
        m_sheet->internal()->setTitle(attr->value());
77
    else if (attr->name() == onloadAttr)
77
    else if (attr->name() == onloadAttr)
78
        setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
78
        setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
79
    else if (attr->name() == onerrorAttr)
79
    else if (attr->name() == onerrorAttr)
Lines 259-265 void HTMLStyleElement::addSubresourceAtt Source/WebCore/html/HTMLStyleElement.cpp_sec2
259
    HTMLElement::addSubresourceAttributeURLs(urls);
259
    HTMLElement::addSubresourceAttributeURLs(urls);
260
260
261
    if (CSSStyleSheet* styleSheet = const_cast<HTMLStyleElement*>(this)->sheet())
261
    if (CSSStyleSheet* styleSheet = const_cast<HTMLStyleElement*>(this)->sheet())
262
        styleSheet->addSubresourceStyleURLs(urls);
262
        styleSheet->internal()->addSubresourceStyleURLs(urls);
263
}
263
}
264
264
265
bool HTMLStyleElement::disabled() const
265
bool HTMLStyleElement::disabled() const
- Source/WebCore/inspector/InspectorStyleSheet.cpp -11 / +12 lines
Lines 206-212 static void fillMediaListChain(CSSRule* Source/WebCore/inspector/InspectorStyleSheet.cpp_sec1
206
            mediaList = 0;
206
            mediaList = 0;
207
207
208
        if (parentStyleSheet) {
208
        if (parentStyleSheet) {
209
            sourceURL = parentStyleSheet->finalURL();
209
            sourceURL = parentStyleSheet->internal()->finalURL();
210
            if (sourceURL.isEmpty())
210
            if (sourceURL.isEmpty())
211
                sourceURL = InspectorDOMAgent::documentURLString(parentStyleSheet->findDocument());
211
                sourceURL = InspectorDOMAgent::documentURLString(parentStyleSheet->findDocument());
212
        } else
212
        } else
Lines 225-232 static void fillMediaListChain(CSSRule* Source/WebCore/inspector/InspectorStyleSheet.cpp_sec2
225
                    Document* doc = styleSheet->findDocument();
225
                    Document* doc = styleSheet->findDocument();
226
                    if (doc)
226
                    if (doc)
227
                        sourceURL = doc->url();
227
                        sourceURL = doc->url();
228
                    else if (!styleSheet->finalURL().isEmpty())
228
                    else if (!styleSheet->internal()->finalURL().isEmpty())
229
                        sourceURL = styleSheet->finalURL();
229
                        sourceURL = styleSheet->internal()->finalURL();
230
                    else
230
                    else
231
                        sourceURL = "";
231
                        sourceURL = "";
232
                    mediaArray->addItem(buildMediaObject(mediaList, styleSheet->ownerNode() ? MediaListSourceLinkedSheet : MediaListSourceInlineSheet, sourceURL));
232
                    mediaArray->addItem(buildMediaObject(mediaList, styleSheet->ownerNode() ? MediaListSourceLinkedSheet : MediaListSourceInlineSheet, sourceURL));
Lines 314-320 bool InspectorStyle::setPropertyText(uns Source/WebCore/inspector/InspectorStyleSheet.cpp_sec3
314
        RefPtr<StylePropertySet> tempMutableStyle = StylePropertySet::create();
314
        RefPtr<StylePropertySet> tempMutableStyle = StylePropertySet::create();
315
        RefPtr<CSSStyleSourceData> sourceData = CSSStyleSourceData::create();
315
        RefPtr<CSSStyleSourceData> sourceData = CSSStyleSourceData::create();
316
        CSSParser p;
316
        CSSParser p;
317
        p.parseDeclaration(tempMutableStyle.get(), propertyText + " " + bogusPropertyName + ": none", &sourceData, m_style->parentStyleSheet());
317
        p.parseDeclaration(tempMutableStyle.get(), propertyText + " " + bogusPropertyName + ": none", &sourceData, m_style->parentStyleSheet()->internal());
318
        Vector<CSSPropertySourceData>& propertyData = sourceData->propertyData;
318
        Vector<CSSPropertySourceData>& propertyData = sourceData->propertyData;
319
        unsigned propertyCount = propertyData.size();
319
        unsigned propertyCount = propertyData.size();
320
320
Lines 689-696 PassRefPtr<InspectorStyleSheet> Inspecto Source/WebCore/inspector/InspectorStyleSheet.cpp_sec4
689
// static
689
// static
690
String InspectorStyleSheet::styleSheetURL(CSSStyleSheet* pageStyleSheet)
690
String InspectorStyleSheet::styleSheetURL(CSSStyleSheet* pageStyleSheet)
691
{
691
{
692
    if (pageStyleSheet && !pageStyleSheet->finalURL().isEmpty())
692
    if (pageStyleSheet && !pageStyleSheet->internal()->finalURL().isEmpty())
693
        return pageStyleSheet->finalURL().string();
693
        return pageStyleSheet->internal()->finalURL().string();
694
    return emptyString();
694
    return emptyString();
695
}
695
}
696
696
Lines 718-725 String InspectorStyleSheet::finalURL() c Source/WebCore/inspector/InspectorStyleSheet.cpp_sec5
718
718
719
void InspectorStyleSheet::reparseStyleSheet(const String& text)
719
void InspectorStyleSheet::reparseStyleSheet(const String& text)
720
{
720
{
721
    m_pageStyleSheet->clearRules();
721
    m_pageStyleSheet->internal()->clearRules();
722
    m_pageStyleSheet->parseString(text, m_pageStyleSheet->cssParserMode());
722
    m_pageStyleSheet->internal()->parseString(text, m_pageStyleSheet->internal()->cssParserMode());
723
    m_pageStyleSheet->clearChildRuleCSSOMWrappers();
723
    m_pageStyleSheet->styleSheetChanged();
724
    m_pageStyleSheet->styleSheetChanged();
724
    m_inspectorStyles.clear();
725
    m_inspectorStyles.clear();
725
    fireStyleSheetChanged();
726
    fireStyleSheetChanged();
Lines 1087-1100 bool InspectorStyleSheet::ensureSourceDa Source/WebCore/inspector/InspectorStyleSheet.cpp_sec6
1087
    if (!m_parsedStyleSheet->hasText())
1088
    if (!m_parsedStyleSheet->hasText())
1088
        return false;
1089
        return false;
1089
1090
1090
    RefPtr<CSSStyleSheet> newStyleSheet = CSSStyleSheet::create();
1091
    RefPtr<StyleSheetInternal> newStyleSheet = StyleSheetInternal::create();
1091
    CSSParser p;
1092
    CSSParser p;
1092
    StyleRuleRangeMap ruleRangeMap;
1093
    StyleRuleRangeMap ruleRangeMap;
1093
    p.parseSheet(newStyleSheet.get(), m_parsedStyleSheet->text(), 0, &ruleRangeMap);
1094
    p.parseSheet(newStyleSheet.get(), m_parsedStyleSheet->text(), 0, &ruleRangeMap);
1094
    OwnPtr<ParsedStyleSheet::SourceData> rangesVector(adoptPtr(new ParsedStyleSheet::SourceData));
1095
    OwnPtr<ParsedStyleSheet::SourceData> rangesVector(adoptPtr(new ParsedStyleSheet::SourceData));
1095
1096
1096
    Vector<CSSStyleRule*> rules;
1097
    Vector<CSSStyleRule*> rules;
1097
    RefPtr<CSSRuleList> ruleList = asCSSRuleList(newStyleSheet.get());
1098
    RefPtr<CSSRuleList> ruleList = asCSSRuleList(CSSStyleSheet::create(newStyleSheet).get());
1098
    collectFlatRules(ruleList, &rules);
1099
    collectFlatRules(ruleList, &rules);
1099
    for (unsigned i = 0, size = rules.size(); i < size; ++i) {
1100
    for (unsigned i = 0, size = rules.size(); i < size; ++i) {
1100
        StyleRuleRangeMap::iterator it = ruleRangeMap.find(rules.at(i)->styleRule());
1101
        StyleRuleRangeMap::iterator it = ruleRangeMap.find(rules.at(i)->styleRule());
Lines 1414-1420 bool InspectorStyleSheetForInlineStyle:: Source/WebCore/inspector/InspectorStyleSheet.cpp_sec7
1414
1415
1415
    RefPtr<StylePropertySet> tempDeclaration = StylePropertySet::create();
1416
    RefPtr<StylePropertySet> tempDeclaration = StylePropertySet::create();
1416
    CSSParser p;
1417
    CSSParser p;
1417
    p.parseDeclaration(tempDeclaration.get(), m_styleText, result, m_element->document()->elementSheet());
1418
    p.parseDeclaration(tempDeclaration.get(), m_styleText, result, m_element->document()->elementSheet()->internal());
1418
    return true;
1419
    return true;
1419
}
1420
}
1420
1421
- Source/WebCore/page/PageSerializer.cpp -1 / +1 lines
Lines 281-287 void PageSerializer::serializeCSSStyleSh Source/WebCore/page/PageSerializer.cpp_sec1
281
281
282
    if (url.isValid() && !m_resourceURLs.contains(url)) {
282
    if (url.isValid() && !m_resourceURLs.contains(url)) {
283
        // FIXME: We should check whether a charset has been specified and if none was found add one.
283
        // FIXME: We should check whether a charset has been specified and if none was found add one.
284
        TextEncoding textEncoding(styleSheet->charset());
284
        TextEncoding textEncoding(styleSheet->internal()->charset());
285
        ASSERT(textEncoding.isValid());
285
        ASSERT(textEncoding.isValid());
286
        String textString = cssText.toString();
286
        String textString = cssText.toString();
287
        CString text = textEncoding.encode(textString.characters(), textString.length(), EntitiesForUnencodables);
287
        CString text = textEncoding.encode(textString.characters(), textString.length(), EntitiesForUnencodables);
- Source/WebCore/svg/SVGStyleElement.cpp -1 / +1 lines
Lines 118-124 void SVGStyleElement::parseAttribute(Att Source/WebCore/svg/SVGStyleElement.cpp_sec1
118
118
119
    if (attr->name() == SVGNames::titleAttr) {
119
    if (attr->name() == SVGNames::titleAttr) {
120
        if (m_sheet)
120
        if (m_sheet)
121
            m_sheet->setTitle(attr->value());
121
            m_sheet->internal()->setTitle(attr->value());
122
        return;
122
        return;
123
    }
123
    }
124
124
- Source/WebCore/xml/XSLStyleSheet.h -4 / +20 lines
Lines 1-7 Source/WebCore/xml/XSLStyleSheet.h_sec1
1
/*
1
/*
2
 * This file is part of the XSL implementation.
2
 * This file is part of the XSL implementation.
3
 *
3
 *
4
 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
4
 * Copyright (C) 2004, 2006, 2008, 2012 Apple Inc. All rights reserved.
5
 *
5
 *
6
 * This library is free software; you can redistribute it and/or
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Library General Public
7
 * modify it under the terms of the GNU Library General Public
Lines 69-78 public: Source/WebCore/xml/XSLStyleSheet.h_sec2
69
69
70
    virtual String type() const { return "text/xml"; }
70
    virtual String type() const { return "text/xml"; }
71
71
72
    virtual bool parseString(const String&, CSSParserMode cssParseMode = CSSStrictMode);
72
    bool parseString(const String&, CSSParserMode cssParseMode = CSSStrictMode);
73
    
73
    
74
    virtual bool isLoading();
74
    virtual bool isLoading() const;
75
    void checkLoaded();
75
    void checkLoaded();
76
    
77
    const KURL& finalURL() const { return m_finalURL; }
76
78
77
    void loadChildSheets();
79
    void loadChildSheets();
78
    void loadChildSheet(const String& href);
80
    void loadChildSheet(const String& href);
Lines 80-86 public: Source/WebCore/xml/XSLStyleSheet.h_sec3
80
    CachedResourceLoader* cachedResourceLoader();
82
    CachedResourceLoader* cachedResourceLoader();
81
83
82
    Document* ownerDocument();
84
    Document* ownerDocument();
83
    XSLStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; }
85
    virtual XSLStyleSheet* parentStyleSheet() const OVERRIDE { return m_parentStyleSheet; }
84
    void setParentStyleSheet(XSLStyleSheet* parent);
86
    void setParentStyleSheet(XSLStyleSheet* parent);
85
87
86
#if USE(QXMLQUERY)
88
#if USE(QXMLQUERY)
Lines 95-106 public: Source/WebCore/xml/XSLStyleSheet.h_sec4
95
97
96
    void markAsProcessed();
98
    void markAsProcessed();
97
    bool processed() const { return m_processed; }
99
    bool processed() const { return m_processed; }
100
    
101
    virtual bool disabled() const OVERRIDE { return m_isDisabled; }
102
    virtual void setDisabled(bool b) OVERRIDE { m_isDisabled = b; }
103
    virtual Node* ownerNode() const OVERRIDE { return m_ownerNode; }
104
    virtual String href() const OVERRIDE { return m_originalURL; }
105
    virtual String title() const OVERRIDE { return emptyString(); }
106
107
    virtual void clearOwnerNode() OVERRIDE { m_ownerNode = 0; }
108
    virtual KURL baseURL() const OVERRIDE { return m_finalURL; }
98
109
99
private:
110
private:
100
    XSLStyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL, bool embedded);
111
    XSLStyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL, bool embedded);
101
#if !USE(QXMLQUERY)
112
#if !USE(QXMLQUERY)
102
    XSLStyleSheet(XSLImportRule* parentImport, const String& originalURL, const KURL& finalURL);
113
    XSLStyleSheet(XSLImportRule* parentImport, const String& originalURL, const KURL& finalURL);
103
#endif
114
#endif
115
    
116
    Node* m_ownerNode;
117
    String m_originalURL;
118
    KURL m_finalURL;
119
    bool m_isDisabled;
104
120
105
    Vector<OwnPtr<XSLImportRule> > m_children;
121
    Vector<OwnPtr<XSLImportRule> > m_children;
106
122
- Source/WebCore/xml/XSLStyleSheetLibxslt.cpp -4 / +10 lines
Lines 1-7 Source/WebCore/xml/XSLStyleSheetLibxslt.cpp_sec1
1
/*
1
/*
2
 * This file is part of the XSL implementation.
2
 * This file is part of the XSL implementation.
3
 *
3
 *
4
 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
4
 * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
5
 *
5
 *
6
 * This library is free software; you can redistribute it and/or
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Library General Public
7
 * modify it under the terms of the GNU Library General Public
Lines 55-61 SOFT_LINK(libxslt, xsltLoadStylesheetPI, Source/WebCore/xml/XSLStyleSheetLibxslt.cpp_sec2
55
namespace WebCore {
55
namespace WebCore {
56
56
57
XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& originalURL, const KURL& finalURL)
57
XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& originalURL, const KURL& finalURL)
58
    : StyleSheet(static_cast<Node*>(0), originalURL, finalURL)
58
    : m_ownerNode(0)
59
    , m_originalURL(originalURL)
60
    , m_finalURL(finalURL)
61
    , m_isDisabled(false)
59
    , m_embedded(false)
62
    , m_embedded(false)
60
    , m_processed(false) // Child sheets get marked as processed when the libxslt engine has finally seen them.
63
    , m_processed(false) // Child sheets get marked as processed when the libxslt engine has finally seen them.
61
    , m_stylesheetDoc(0)
64
    , m_stylesheetDoc(0)
Lines 65-71 XSLStyleSheet::XSLStyleSheet(XSLImportRu Source/WebCore/xml/XSLStyleSheetLibxslt.cpp_sec3
65
}
68
}
66
69
67
XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL,  bool embedded)
70
XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL,  bool embedded)
68
    : StyleSheet(parentNode, originalURL, finalURL)
71
    : m_ownerNode(parentNode)
72
    , m_originalURL(originalURL)
73
    , m_finalURL(finalURL)
74
    , m_isDisabled(false)
69
    , m_embedded(embedded)
75
    , m_embedded(embedded)
70
    , m_processed(true) // The root sheet starts off processed.
76
    , m_processed(true) // The root sheet starts off processed.
71
    , m_stylesheetDoc(0)
77
    , m_stylesheetDoc(0)
Lines 85-91 XSLStyleSheet::~XSLStyleSheet() Source/WebCore/xml/XSLStyleSheetLibxslt.cpp_sec4
85
    }
91
    }
86
}
92
}
87
93
88
bool XSLStyleSheet::isLoading()
94
bool XSLStyleSheet::isLoading() const
89
{
95
{
90
    for (unsigned i = 0; i < m_children.size(); ++i) {
96
    for (unsigned i = 0; i < m_children.size(); ++i) {
91
        if (m_children.at(i)->isLoading())
97
        if (m_children.at(i)->isLoading())
- Source/WebCore/xml/XSLStyleSheetQt.cpp -2 / +5 lines
Lines 34-40 Source/WebCore/xml/XSLStyleSheetQt.cpp_sec1
34
namespace WebCore {
34
namespace WebCore {
35
35
36
XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL,  bool embedded)
36
XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL,  bool embedded)
37
    : StyleSheet(parentNode, originalURL, finalURL)
37
    : m_ownerNode(parentNode)
38
    , m_originalURL(originalURL)
39
    , m_finalURL(finalURL)
40
    , m_isDisabled(false)
38
    , m_embedded(embedded)
41
    , m_embedded(embedded)
39
{
42
{
40
}
43
}
Lines 47-53 XSLStyleSheet::~XSLStyleSheet() Source/WebCore/xml/XSLStyleSheetQt.cpp_sec2
47
    }
50
    }
48
}
51
}
49
52
50
bool XSLStyleSheet::isLoading()
53
bool XSLStyleSheet::isLoading() const
51
{
54
{
52
    notImplemented();
55
    notImplemented();
53
    return false;
56
    return false;

Return to Bug 83612