Split CSSStyleSheet into internal and CSSOM type
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2012 23:20:55 +0000 (23:20 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2012 23:20:55 +0000 (23:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83612

Reviewed by Andreas Kling.

This will complete the separation of our style sheet data structures from CSSOM.

The internal parts of CSSStyleSheet move to StyleSheetInternal. CSS parser
and style selector will now operate on internal types. Unlike other CSSOM types
CSSStyleSheets are still always instantiated to hold the top level author stylesheets
(by Nodes).

* css/CSSFontFaceSrcValue.cpp:
(WebCore::CSSFontFaceSrcValue::addSubresourceStyleURLs):
* css/CSSFontFaceSrcValue.h:
(CSSFontFaceSrcValue):
* css/CSSImportRule.cpp:
(WebCore::StyleRuleImport::create):
(WebCore::StyleRuleImport::StyleRuleImport):
(WebCore::StyleRuleImport::setCSSStyleSheet):
(WebCore::StyleRuleImport::requestStyleSheet):
(WebCore::CSSImportRule::~CSSImportRule):
(WebCore):
(WebCore::CSSImportRule::styleSheet):
* css/CSSImportRule.h:
(WebCore):
(StyleRuleImport):
(WebCore::StyleRuleImport::parentStyleSheet):
(WebCore::StyleRuleImport::styleSheet):
(CSSImportRule):
* css/CSSMediaRule.cpp:
(WebCore::CSSMediaRule::insertRule):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseSheet):
(WebCore::CSSParser::parseRule):
(WebCore::CSSParser::parseKeyframeRule):
(WebCore::CSSParser::parseFontFaceValue):
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseSelector):
(WebCore::CSSParser::parseDeclaration):
(WebCore::CSSParser::setStyleSheet):
(WebCore::CSSParser::parseFlowThread):
* css/CSSParser.h:
(WebCore):
(CSSParser):
* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::addSubresourceStyleURLs):
* css/CSSPrimitiveValue.h:
(CSSPrimitiveValue):
* css/CSSReflectValue.cpp:
(WebCore::CSSReflectValue::addSubresourceStyleURLs):
* css/CSSReflectValue.h:
(CSSReflectValue):
* css/CSSRule.h:
(CSSRule):
* css/CSSStyleSelector.cpp:
(RuleSet):
(WebCore):
(WebCore::CSSStyleSelector::CSSStyleSelector):
(WebCore::CSSStyleSelector::addAuthorRulesAndCollectUserRulesFromSheets):
(WebCore::CSSStyleSelector::determineScope):
(WebCore::CSSStyleSelector::appendAuthorStylesheets):
(WebCore::parseUASheet):
(WebCore::CSSStyleSelector::collectMatchingRulesForList):
* css/CSSStyleSelector.h:
(CSSStyleSelector):

    Add a set for root CSSStyleSheet objects so that the wrappers created in ensureFullCSSOMWrapperForInspector
    stay valid.

* css/CSSStyleSheet.cpp:
(WebCore::StyleSheetInternal::StyleSheetInternal):
(WebCore::StyleSheetInternal::~StyleSheetInternal):
(WebCore::StyleSheetInternal::parserAppendRule):
(WebCore::StyleSheetInternal::createChildRuleCSSOMWrapper):
(WebCore::StyleSheetInternal::ruleCount):
(WebCore::StyleSheetInternal::clearCharsetRule):
(WebCore::StyleSheetInternal::clearRules):
(WebCore::StyleSheetInternal::parserSetEncodingFromCharsetRule):
(WebCore::StyleSheetInternal::wrapperInsertRule):
(WebCore::StyleSheetInternal::wrapperDeleteRule):
(WebCore::StyleSheetInternal::addNamespace):
(WebCore::StyleSheetInternal::determineNamespace):
(WebCore::StyleSheetInternal::parseString):
(WebCore::StyleSheetInternal::parseStringAtLine):
(WebCore::StyleSheetInternal::isLoading):
(WebCore::StyleSheetInternal::checkLoaded):
(WebCore::StyleSheetInternal::notifyLoadedSheet):
(WebCore::StyleSheetInternal::startLoadingDynamicSheet):
(WebCore::StyleSheetInternal::findStyleSheetOwnerNode):
(WebCore::StyleSheetInternal::findDocument):
(WebCore::StyleSheetInternal::setMediaQueries):
(WebCore::StyleSheetInternal::styleSheetChanged):
(WebCore):
(WebCore::StyleSheetInternal::baseURL):
(WebCore::StyleSheetInternal::completeURL):
(WebCore::StyleSheetInternal::addSubresourceStyleURLs):
(WebCore::StyleSheetInternal::parentStyleSheet):
(WebCore::CSSStyleSheet::CSSStyleSheet):
(WebCore::CSSStyleSheet::~CSSStyleSheet):
(WebCore::CSSStyleSheet::setDisabled):
(WebCore::CSSStyleSheet::length):
(WebCore::CSSStyleSheet::item):
(WebCore::CSSStyleSheet::rules):
(WebCore::CSSStyleSheet::insertRule):
(WebCore::CSSStyleSheet::addRule):
(WebCore::CSSStyleSheet::cssRules):
(WebCore::CSSStyleSheet::deleteRule):
(WebCore::CSSStyleSheet::media):
(WebCore::CSSStyleSheet::parentStyleSheet):
* css/CSSStyleSheet.h:
(WebCore):
(WebCore::StyleSheetInternal::create):
(WebCore::StyleSheetInternal::createInline):
(StyleSheetInternal):
(WebCore::StyleSheetInternal::ownerNode):
(WebCore::StyleSheetInternal::clearOwnerNode):
(WebCore::StyleSheetInternal::ownerRule):
(WebCore::StyleSheetInternal::originalURL):
(WebCore::StyleSheetInternal::title):
(WebCore::StyleSheetInternal::setTitle):
(WebCore::StyleSheetInternal::setFinalURL):
(WebCore::StyleSheetInternal::finalURL):
(CSSStyleSheet):
(WebCore::CSSStyleSheet::create):
(WebCore::CSSStyleSheet::removeRule):
(WebCore::CSSStyleSheet::clearOwnerRule):
(WebCore::CSSStyleSheet::styleSheetChanged):
(WebCore::CSSStyleSheet::findDocument):
(WebCore::CSSStyleSheet::internal):
(WebCore::CSSStyleSheet::isCSSStyleSheet):
(WebCore::CSSStyleSheet::type):
* css/CSSValue.cpp:
(WebCore::CSSValue::addSubresourceStyleURLs):
* css/CSSValue.h:
(WebCore):
(CSSValue):
* css/CSSValueList.cpp:
(WebCore::CSSValueList::addSubresourceStyleURLs):
* css/CSSValueList.h:
(CSSValueList):
* css/CSSValuePool.cpp:
(WebCore::CSSValuePool::createFontFaceValue):
* css/CSSValuePool.h:
(WebCore):
(CSSValuePool):
* css/PropertySetCSSStyleDeclaration.cpp:
(WebCore::PropertySetCSSStyleDeclaration::setCssText):
(WebCore::PropertySetCSSStyleDeclaration::setProperty):
(WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal):
* css/PropertySetCSSStyleDeclaration.h:
(WebCore):
* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::setProperty):
(WebCore::StylePropertySet::parseDeclaration):
(WebCore::StylePropertySet::addSubresourceStyleURLs):
* css/StylePropertySet.h:
(WebCore):
(StylePropertySet):
* css/StyleSheet.cpp:
(WebCore):
* css/StyleSheet.h:
(StyleSheet):
(WebCore::StyleSheet::media):
(WebCore::StyleSheet::ownerRule):
(WebCore::StyleSheet::isXSLStyleSheet):
* css/WebKitCSSKeyframesRule.cpp:
(WebCore::WebKitCSSKeyframesRule::insertRule):
* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createCSSStyleSheet):
* dom/Document.cpp:
(WebCore::Document::updateBaseURL):
(WebCore::Document::pageUserSheet):
(WebCore::Document::pageGroupUserSheets):
(WebCore::Document::addUserSheet):
(WebCore::Document::elementSheet):
(WebCore::Document::testAddedStylesheetRequiresStyleRecalc):
(WebCore::Document::analyzeStylesheetChange):
* dom/Document.h:
(WebCore):
(Document):
(WebCore::Document::documentUserSheets):
* dom/ElementAttributeData.cpp:
(WebCore::ElementAttributeData::updateInlineStyleAvoidingMutation):
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::setCSSStyleSheet):
(WebCore::ProcessingInstruction::parseStyleSheet):
* dom/StyleElement.cpp:
(WebCore::StyleElement::createSheet):
* dom/StyledElement.cpp:
(WebCore::StyledElement::setInlineStyleProperty):
(WebCore::StyledElement::addSubresourceAttributeURLs):
(WebCore):
(WebCore::StyledElement::addPropertyToAttributeStyle):
* dom/StyledElement.h:
(WebCore):
* html/HTMLFontElement.cpp:
(WebCore::HTMLFontElement::collectStyleForAttribute):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::parseAttribute):
(WebCore::HTMLLinkElement::setCSSStyleSheet):
(WebCore::HTMLLinkElement::styleSheetIsLoading):
(WebCore::HTMLLinkElement::addSubresourceAttributeURLs):
* html/HTMLStyleElement.cpp:
(WebCore::HTMLStyleElement::parseAttribute):
(WebCore::HTMLStyleElement::addSubresourceAttributeURLs):
* inspector/InspectorStyleSheet.cpp:
(WebCore::fillMediaListChain):
(WebCore::InspectorStyle::setPropertyText):
(WebCore::InspectorStyleSheet::styleSheetURL):
(WebCore::InspectorStyleSheet::reparseStyleSheet):
(WebCore::InspectorStyleSheet::ensureSourceData):
(WebCore::InspectorStyleSheetForInlineStyle::getStyleAttributeRanges):
* page/PageSerializer.cpp:
(WebCore::PageSerializer::serializeCSSStyleSheet):
* svg/SVGStyleElement.cpp:
(WebCore::SVGStyleElement::parseAttribute):
* xml/XSLStyleSheet.h:
(XSLStyleSheet):
(WebCore::XSLStyleSheet::finalURL):
* xml/XSLStyleSheetLibxslt.cpp:
(WebCore::XSLStyleSheet::XSLStyleSheet):
(WebCore::XSLStyleSheet::isLoading):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113922 268f45cc-cd09-0410-ab3c-d52691b4dbfc

48 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/CSSFontFaceSrcValue.cpp
Source/WebCore/css/CSSFontFaceSrcValue.h
Source/WebCore/css/CSSImportRule.cpp
Source/WebCore/css/CSSImportRule.h
Source/WebCore/css/CSSMediaRule.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/CSSPrimitiveValue.cpp
Source/WebCore/css/CSSPrimitiveValue.h
Source/WebCore/css/CSSReflectValue.cpp
Source/WebCore/css/CSSReflectValue.h
Source/WebCore/css/CSSRule.h
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/css/CSSStyleSelector.h
Source/WebCore/css/CSSStyleSheet.cpp
Source/WebCore/css/CSSStyleSheet.h
Source/WebCore/css/CSSValue.cpp
Source/WebCore/css/CSSValue.h
Source/WebCore/css/CSSValueList.cpp
Source/WebCore/css/CSSValueList.h
Source/WebCore/css/CSSValuePool.cpp
Source/WebCore/css/CSSValuePool.h
Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
Source/WebCore/css/PropertySetCSSStyleDeclaration.h
Source/WebCore/css/StylePropertySet.cpp
Source/WebCore/css/StylePropertySet.h
Source/WebCore/css/StyleSheet.cpp
Source/WebCore/css/StyleSheet.h
Source/WebCore/css/WebKitCSSKeyframesRule.cpp
Source/WebCore/dom/DOMImplementation.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/ElementAttributeData.cpp
Source/WebCore/dom/ProcessingInstruction.cpp
Source/WebCore/dom/StyleElement.cpp
Source/WebCore/dom/StyledElement.cpp
Source/WebCore/dom/StyledElement.h
Source/WebCore/html/HTMLFontElement.cpp
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/html/HTMLStyleElement.cpp
Source/WebCore/inspector/InspectorStyleSheet.cpp
Source/WebCore/page/PageSerializer.cpp
Source/WebCore/svg/SVGStyleElement.cpp
Source/WebCore/xml/XSLStyleSheet.h
Source/WebCore/xml/XSLStyleSheetLibxslt.cpp
Source/WebCore/xml/XSLStyleSheetQt.cpp
Source/WebKit/chromium/src/WebDocument.cpp

index 524539d..b4393f1 100644 (file)
@@ -1,3 +1,229 @@
+2012-04-11  Antti Koivisto  <antti@apple.com>
+
+        Split CSSStyleSheet into internal and CSSOM type
+        https://bugs.webkit.org/show_bug.cgi?id=83612
+        
+        Reviewed by Andreas Kling.
+
+        This will complete the separation of our style sheet data structures from CSSOM.
+        
+        The internal parts of CSSStyleSheet move to StyleSheetInternal. CSS parser
+        and style selector will now operate on internal types. Unlike other CSSOM types
+        CSSStyleSheets are still always instantiated to hold the top level author stylesheets
+        (by Nodes).
+
+        * css/CSSFontFaceSrcValue.cpp:
+        (WebCore::CSSFontFaceSrcValue::addSubresourceStyleURLs):
+        * css/CSSFontFaceSrcValue.h:
+        (CSSFontFaceSrcValue):
+        * css/CSSImportRule.cpp:
+        (WebCore::StyleRuleImport::create):
+        (WebCore::StyleRuleImport::StyleRuleImport):
+        (WebCore::StyleRuleImport::setCSSStyleSheet):
+        (WebCore::StyleRuleImport::requestStyleSheet):
+        (WebCore::CSSImportRule::~CSSImportRule):
+        (WebCore):
+        (WebCore::CSSImportRule::styleSheet):
+        * css/CSSImportRule.h:
+        (WebCore):
+        (StyleRuleImport):
+        (WebCore::StyleRuleImport::parentStyleSheet):
+        (WebCore::StyleRuleImport::styleSheet):
+        (CSSImportRule):
+        * css/CSSMediaRule.cpp:
+        (WebCore::CSSMediaRule::insertRule):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseSheet):
+        (WebCore::CSSParser::parseRule):
+        (WebCore::CSSParser::parseKeyframeRule):
+        (WebCore::CSSParser::parseFontFaceValue):
+        (WebCore::CSSParser::parseValue):
+        (WebCore::CSSParser::parseSelector):
+        (WebCore::CSSParser::parseDeclaration):
+        (WebCore::CSSParser::setStyleSheet):
+        (WebCore::CSSParser::parseFlowThread):
+        * css/CSSParser.h:
+        (WebCore):
+        (CSSParser):
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::CSSPrimitiveValue::addSubresourceStyleURLs):
+        * css/CSSPrimitiveValue.h:
+        (CSSPrimitiveValue):
+        * css/CSSReflectValue.cpp:
+        (WebCore::CSSReflectValue::addSubresourceStyleURLs):
+        * css/CSSReflectValue.h:
+        (CSSReflectValue):
+        * css/CSSRule.h:
+        (CSSRule):
+        * css/CSSStyleSelector.cpp:
+        (RuleSet):
+        (WebCore):
+        (WebCore::CSSStyleSelector::CSSStyleSelector):
+        (WebCore::CSSStyleSelector::addAuthorRulesAndCollectUserRulesFromSheets):
+        (WebCore::CSSStyleSelector::determineScope):
+        (WebCore::CSSStyleSelector::appendAuthorStylesheets):
+        (WebCore::parseUASheet):
+        (WebCore::CSSStyleSelector::collectMatchingRulesForList):
+        * css/CSSStyleSelector.h:
+        (CSSStyleSelector):
+        
+            Add a set for root CSSStyleSheet objects so that the wrappers created in ensureFullCSSOMWrapperForInspector
+            stay valid.
+        
+        * css/CSSStyleSheet.cpp:
+        (WebCore::StyleSheetInternal::StyleSheetInternal):
+        (WebCore::StyleSheetInternal::~StyleSheetInternal):
+        (WebCore::StyleSheetInternal::parserAppendRule):
+        (WebCore::StyleSheetInternal::createChildRuleCSSOMWrapper):
+        (WebCore::StyleSheetInternal::ruleCount):
+        (WebCore::StyleSheetInternal::clearCharsetRule):
+        (WebCore::StyleSheetInternal::clearRules):
+        (WebCore::StyleSheetInternal::parserSetEncodingFromCharsetRule):
+        (WebCore::StyleSheetInternal::wrapperInsertRule):
+        (WebCore::StyleSheetInternal::wrapperDeleteRule):
+        (WebCore::StyleSheetInternal::addNamespace):
+        (WebCore::StyleSheetInternal::determineNamespace):
+        (WebCore::StyleSheetInternal::parseString):
+        (WebCore::StyleSheetInternal::parseStringAtLine):
+        (WebCore::StyleSheetInternal::isLoading):
+        (WebCore::StyleSheetInternal::checkLoaded):
+        (WebCore::StyleSheetInternal::notifyLoadedSheet):
+        (WebCore::StyleSheetInternal::startLoadingDynamicSheet):
+        (WebCore::StyleSheetInternal::findStyleSheetOwnerNode):
+        (WebCore::StyleSheetInternal::findDocument):
+        (WebCore::StyleSheetInternal::setMediaQueries):
+        (WebCore::StyleSheetInternal::styleSheetChanged):
+        (WebCore):
+        (WebCore::StyleSheetInternal::baseURL):
+        (WebCore::StyleSheetInternal::completeURL):
+        (WebCore::StyleSheetInternal::addSubresourceStyleURLs):
+        (WebCore::StyleSheetInternal::parentStyleSheet):
+        (WebCore::CSSStyleSheet::CSSStyleSheet):
+        (WebCore::CSSStyleSheet::~CSSStyleSheet):
+        (WebCore::CSSStyleSheet::setDisabled):
+        (WebCore::CSSStyleSheet::length):
+        (WebCore::CSSStyleSheet::item):
+        (WebCore::CSSStyleSheet::rules):
+        (WebCore::CSSStyleSheet::insertRule):
+        (WebCore::CSSStyleSheet::addRule):
+        (WebCore::CSSStyleSheet::cssRules):
+        (WebCore::CSSStyleSheet::deleteRule):
+        (WebCore::CSSStyleSheet::media):
+        (WebCore::CSSStyleSheet::parentStyleSheet):
+        * css/CSSStyleSheet.h:
+        (WebCore):
+        (WebCore::StyleSheetInternal::create):
+        (WebCore::StyleSheetInternal::createInline):
+        (StyleSheetInternal):
+        (WebCore::StyleSheetInternal::ownerNode):
+        (WebCore::StyleSheetInternal::clearOwnerNode):
+        (WebCore::StyleSheetInternal::ownerRule):
+        (WebCore::StyleSheetInternal::originalURL):
+        (WebCore::StyleSheetInternal::title):
+        (WebCore::StyleSheetInternal::setTitle):
+        (WebCore::StyleSheetInternal::setFinalURL):
+        (WebCore::StyleSheetInternal::finalURL):
+        (CSSStyleSheet):
+        (WebCore::CSSStyleSheet::create):
+        (WebCore::CSSStyleSheet::removeRule):
+        (WebCore::CSSStyleSheet::clearOwnerRule):
+        (WebCore::CSSStyleSheet::styleSheetChanged):
+        (WebCore::CSSStyleSheet::findDocument):
+        (WebCore::CSSStyleSheet::internal):
+        (WebCore::CSSStyleSheet::isCSSStyleSheet):
+        (WebCore::CSSStyleSheet::type):
+        * css/CSSValue.cpp:
+        (WebCore::CSSValue::addSubresourceStyleURLs):
+        * css/CSSValue.h:
+        (WebCore):
+        (CSSValue):
+        * css/CSSValueList.cpp:
+        (WebCore::CSSValueList::addSubresourceStyleURLs):
+        * css/CSSValueList.h:
+        (CSSValueList):
+        * css/CSSValuePool.cpp:
+        (WebCore::CSSValuePool::createFontFaceValue):
+        * css/CSSValuePool.h:
+        (WebCore):
+        (CSSValuePool):
+        * css/PropertySetCSSStyleDeclaration.cpp:
+        (WebCore::PropertySetCSSStyleDeclaration::setCssText):
+        (WebCore::PropertySetCSSStyleDeclaration::setProperty):
+        (WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal):
+        * css/PropertySetCSSStyleDeclaration.h:
+        (WebCore):
+        * css/StylePropertySet.cpp:
+        (WebCore::StylePropertySet::setProperty):
+        (WebCore::StylePropertySet::parseDeclaration):
+        (WebCore::StylePropertySet::addSubresourceStyleURLs):
+        * css/StylePropertySet.h:
+        (WebCore):
+        (StylePropertySet):
+        * css/StyleSheet.cpp:
+        (WebCore):
+        * css/StyleSheet.h:
+        (StyleSheet):
+        (WebCore::StyleSheet::media):
+        (WebCore::StyleSheet::ownerRule):
+        (WebCore::StyleSheet::isXSLStyleSheet):
+        * css/WebKitCSSKeyframesRule.cpp:
+        (WebCore::WebKitCSSKeyframesRule::insertRule):
+        * dom/DOMImplementation.cpp:
+        (WebCore::DOMImplementation::createCSSStyleSheet):
+        * dom/Document.cpp:
+        (WebCore::Document::updateBaseURL):
+        (WebCore::Document::pageUserSheet):
+        (WebCore::Document::pageGroupUserSheets):
+        (WebCore::Document::addUserSheet):
+        (WebCore::Document::elementSheet):
+        (WebCore::Document::testAddedStylesheetRequiresStyleRecalc):
+        (WebCore::Document::analyzeStylesheetChange):
+        * dom/Document.h:
+        (WebCore):
+        (Document):
+        (WebCore::Document::documentUserSheets):
+        * dom/ElementAttributeData.cpp:
+        (WebCore::ElementAttributeData::updateInlineStyleAvoidingMutation):
+        * dom/ProcessingInstruction.cpp:
+        (WebCore::ProcessingInstruction::setCSSStyleSheet):
+        (WebCore::ProcessingInstruction::parseStyleSheet):
+        * dom/StyleElement.cpp:
+        (WebCore::StyleElement::createSheet):
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::setInlineStyleProperty):
+        (WebCore::StyledElement::addSubresourceAttributeURLs):
+        (WebCore):
+        (WebCore::StyledElement::addPropertyToAttributeStyle):
+        * dom/StyledElement.h:
+        (WebCore):
+        * html/HTMLFontElement.cpp:
+        (WebCore::HTMLFontElement::collectStyleForAttribute):
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::parseAttribute):
+        (WebCore::HTMLLinkElement::setCSSStyleSheet):
+        (WebCore::HTMLLinkElement::styleSheetIsLoading):
+        (WebCore::HTMLLinkElement::addSubresourceAttributeURLs):
+        * html/HTMLStyleElement.cpp:
+        (WebCore::HTMLStyleElement::parseAttribute):
+        (WebCore::HTMLStyleElement::addSubresourceAttributeURLs):
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::fillMediaListChain):
+        (WebCore::InspectorStyle::setPropertyText):
+        (WebCore::InspectorStyleSheet::styleSheetURL):
+        (WebCore::InspectorStyleSheet::reparseStyleSheet):
+        (WebCore::InspectorStyleSheet::ensureSourceData):
+        (WebCore::InspectorStyleSheetForInlineStyle::getStyleAttributeRanges):
+        * page/PageSerializer.cpp:
+        (WebCore::PageSerializer::serializeCSSStyleSheet):
+        * svg/SVGStyleElement.cpp:
+        (WebCore::SVGStyleElement::parseAttribute):
+        * xml/XSLStyleSheet.h:
+        (XSLStyleSheet):
+        (WebCore::XSLStyleSheet::finalURL):
+        * xml/XSLStyleSheetLibxslt.cpp:
+        (WebCore::XSLStyleSheet::XSLStyleSheet):
+        (WebCore::XSLStyleSheet::isLoading):
+
 2012-04-11  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r113912.
index 3cdece8..83eab39 100644 (file)
@@ -73,7 +73,7 @@ String CSSFontFaceSrcValue::customCssText() const
     return result;
 }
 
-void CSSFontFaceSrcValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const CSSStyleSheet* styleSheet)
+void CSSFontFaceSrcValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
 {
     if (!isLocal())
         addSubresourceURL(urls, styleSheet->completeURL(m_resource));
index a5f54de..670d82a 100644 (file)
@@ -65,7 +65,7 @@ public:
 
     String customCssText() const;
 
-    void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
+    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
 
     CachedFont* cachedFont(Document*);
 
index 04edf6a..6b1e7b7 100644 (file)
 
 namespace WebCore {
 
-PassRefPtr<StyleRuleImport> StyleRuleImport::create(CSSStyleSheet* parent, const String& href, PassRefPtr<MediaQuerySet> media)
+PassRefPtr<StyleRuleImport> StyleRuleImport::create(StyleSheetInternal* parent, const String& href, PassRefPtr<MediaQuerySet> media)
 {
     return adoptRef(new StyleRuleImport(parent, href, media));
 }
 
-StyleRuleImport::StyleRuleImport(CSSStyleSheet* parent, const String& href, PassRefPtr<MediaQuerySet> media)
+StyleRuleImport::StyleRuleImport(StyleSheetInternal* parent, const String& href, PassRefPtr<MediaQuerySet> media)
     : StyleRuleBase(Import, 0)
     , m_parentStyleSheet(parent)
     , m_styleSheetClient(this)
@@ -64,7 +64,7 @@ void StyleRuleImport::setCSSStyleSheet(const String& href, const KURL& baseURL,
 {
     if (m_styleSheet)
         m_styleSheet->clearOwnerRule();
-    m_styleSheet = CSSStyleSheet::create(this, href, baseURL, charset);
+    m_styleSheet = StyleSheetInternal::create(this, href, baseURL, charset);
 
     bool crossOriginCSS = false;
     bool validMIMEType = false;
@@ -88,7 +88,7 @@ void StyleRuleImport::setCSSStyleSheet(const String& href, const KURL& baseURL,
         crossOriginCSS = true;
 
     if (crossOriginCSS && !validMIMEType && !m_styleSheet->hasSyntacticallyValidCSSHeader())
-        m_styleSheet = CSSStyleSheet::create(this, href, baseURL, charset);
+        m_styleSheet = StyleSheetInternal::create(this, href, baseURL, charset);
 
     if (isStrictParserMode(cssParserMode) && needsSiteSpecificQuirks) {
         // Work around <https://bugs.webkit.org/show_bug.cgi?id=28350>.
@@ -98,9 +98,8 @@ void StyleRuleImport::setCSSStyleSheet(const String& href, const KURL& baseURL,
         // while the other lacks the second trailing newline.
         if (baseURL.string().endsWith(slashKHTMLFixesDotCss) && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText)
                 && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1) {
-            ASSERT(m_styleSheet->length() == 1);
-            ExceptionCode ec;
-            m_styleSheet->deleteRule(0, ec);
+            ASSERT(m_styleSheet->childRules().size() == 1);
+            m_styleSheet->clearRules();
         }
     }
 
@@ -136,8 +135,8 @@ void StyleRuleImport::requestStyleSheet()
 
     // Check for a cycle in our import chain.  If we encounter a stylesheet
     // in our parent chain with the same URL, then just bail.
-    CSSStyleSheet* rootSheet = m_parentStyleSheet;
-    for (CSSStyleSheet* sheet = m_parentStyleSheet; sheet; sheet = sheet->parentStyleSheet()) {
+    StyleSheetInternal* rootSheet = m_parentStyleSheet;
+    for (StyleSheetInternal* sheet = m_parentStyleSheet; sheet; sheet = sheet->parentStyleSheet()) {
         // FIXME: This is wrong if the finalURL was updated via document::updateBaseURL.
         if (absHref == sheet->finalURL().string())
             return;
@@ -166,6 +165,12 @@ CSSImportRule::CSSImportRule(StyleRuleImport* importRule, CSSStyleSheet* parent)
 {
 }
 
+CSSImportRule::~CSSImportRule()
+{
+    if (m_styleSheetCSSOMWrapper)
+        m_styleSheetCSSOMWrapper->clearOwnerRule();
+}
+
 MediaList* CSSImportRule::media()
 {
     return m_importRule->mediaQueries()->ensureMediaList(parentStyleSheet());
@@ -187,4 +192,15 @@ String CSSImportRule::cssText() const
     return result.toString();
 }
 
+CSSStyleSheet* CSSImportRule::styleSheet() const
+{ 
+    if (!m_importRule->styleSheet())
+        return 0;
+
+    if (!m_styleSheetCSSOMWrapper)
+        m_styleSheetCSSOMWrapper = CSSStyleSheet::create(m_importRule->styleSheet(), const_cast<CSSImportRule*>(this));
+    return m_styleSheetCSSOMWrapper.get(); 
+}
+
+
 } // namespace WebCore
index 3661b7f..8414181 100644 (file)
@@ -33,18 +33,19 @@ namespace WebCore {
 class CachedCSSStyleSheet;
 class MediaList;
 class MediaQuerySet;
+class StyleSheetInternal;
 
 class StyleRuleImport : public StyleRuleBase {
 public:
-    static PassRefPtr<StyleRuleImport> create(CSSStyleSheet* parent, const String& href, PassRefPtr<MediaQuerySet>);
+    static PassRefPtr<StyleRuleImport> create(StyleSheetInternal* parent, const String& href, PassRefPtr<MediaQuerySet>);
 
     ~StyleRuleImport();
     
-    CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; }
+    StyleSheetInternal* parentStyleSheet() const { return m_parentStyleSheet; }
     void clearParentStyleSheet() { m_parentStyleSheet = 0; }
 
     String href() const { return m_strHref; }
-    CSSStyleSheet* styleSheet() const { return m_styleSheet.get(); }
+    StyleSheetInternal* styleSheet() const { return m_styleSheet.get(); }
 
     // Not part of the CSSOM.
     bool isLoading() const;
@@ -70,15 +71,14 @@ private:
     void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*);
     friend class ImportedStyleSheetClient;
 
-    StyleRuleImport(CSSStyleSheet* parent, const String& href, PassRefPtr<MediaQuerySet>);
+    StyleRuleImport(StyleSheetInternal* parent, const String& href, PassRefPtr<MediaQuerySet>);
 
-    // FXIME: This needs to go away.
-    CSSStyleSheet* m_parentStyleSheet;
+    StyleSheetInternal* m_parentStyleSheet;
 
     ImportedStyleSheetClient m_styleSheetClient;
     String m_strHref;
     RefPtr<MediaQuerySet> m_mediaQueries;
-    RefPtr<CSSStyleSheet> m_styleSheet;
+    RefPtr<StyleSheetInternal> m_styleSheet;
     CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
     bool m_loading;
 };
@@ -86,10 +86,12 @@ private:
 class CSSImportRule : public CSSRule {
 public:
     static PassRefPtr<CSSImportRule> create(StyleRuleImport* rule, CSSStyleSheet* sheet) { return adoptRef(new CSSImportRule(rule, sheet)); }
+    
+    ~CSSImportRule();
 
     String href() const { return m_importRule->href(); }
     MediaList* media();
-    CSSStyleSheet* styleSheet() const { return m_importRule->styleSheet(); }
+    CSSStyleSheet* styleSheet() const;
     
     String cssText() const;
 
@@ -97,6 +99,8 @@ private:
     CSSImportRule(StyleRuleImport*, CSSStyleSheet*);
 
     RefPtr<StyleRuleImport> m_importRule;
+
+    mutable RefPtr<CSSStyleSheet> m_styleSheetCSSOMWrapper;
 };
 
 } // namespace WebCore
index ec88ade..b059cfe 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
  * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2002, 2005, 2006 Apple Computer, Inc.
+ * Copyright (C) 2002, 2005, 2006, 2012 Apple Computer, Inc.
  * Copyright (C) 2006 Samuel Weinig (sam@webkit.org)
  *
  * This library is free software; you can redistribute it and/or
@@ -58,8 +58,9 @@ unsigned CSSMediaRule::insertRule(const String& ruleString, unsigned index, Exce
         return 0;
     }
 
-    CSSParser p(cssParserMode());
-    RefPtr<StyleRuleBase> newRule = p.parseRule(parentStyleSheet(), ruleString);
+    CSSStyleSheet* styleSheet = parentStyleSheet();
+    CSSParser parser(styleSheet ? styleSheet->internal()->cssParserMode() : CSSStrictMode);
+    RefPtr<StyleRuleBase> newRule = parser.parseRule(styleSheet ? styleSheet->internal() : 0, ruleString);
     if (!newRule) {
         // SYNTAX_ERR: Raised if the specified rule has a syntax error and is unparsable.
         ec = SYNTAX_ERR;
index 84881d3..5fade0c 100644 (file)
@@ -252,7 +252,7 @@ void CSSParser::setupParser(const char* prefix, const String& string, const char
     resetRuleBodyMarks();
 }
 
-void CSSParser::parseSheet(CSSStyleSheet* sheet, const String& string, int startLineNumber, StyleRuleRangeMap* ruleRangeMap)
+void CSSParser::parseSheet(StyleSheetInternal* sheet, const String& string, int startLineNumber, StyleRuleRangeMap* ruleRangeMap)
 {
     setStyleSheet(sheet);
     m_defaultNamespace = starAtom; // Reset the default namespace.
@@ -270,7 +270,7 @@ void CSSParser::parseSheet(CSSStyleSheet* sheet, const String& string, int start
     m_rule = 0;
 }
 
-PassRefPtr<StyleRuleBase> CSSParser::parseRule(CSSStyleSheet* sheet, const String& string)
+PassRefPtr<StyleRuleBase> CSSParser::parseRule(StyleSheetInternal* sheet, const String& string)
 {
     setStyleSheet(sheet);
     m_allowNamespaceDeclarations = false;
@@ -279,7 +279,7 @@ PassRefPtr<StyleRuleBase> CSSParser::parseRule(CSSStyleSheet* sheet, const Strin
     return m_rule.release();
 }
 
-PassRefPtr<StyleKeyframe> CSSParser::parseKeyframeRule(CSSStyleSheet *sheet, const String &string)
+PassRefPtr<StyleKeyframe> CSSParser::parseKeyframeRule(StyleSheetInternal* sheet, const String &string)
 {
     setStyleSheet(sheet);
     setupParser("@-webkit-keyframe-rule{ ", string, "} ");
@@ -909,7 +909,7 @@ static bool parseKeywordValue(StylePropertySet* declaration, CSSPropertyID prope
     return true;
 }
 
-PassRefPtr<CSSValueList> CSSParser::parseFontFaceValue(const AtomicString& string, CSSStyleSheet* contextStyleSheet)
+PassRefPtr<CSSValueList> CSSParser::parseFontFaceValue(const AtomicString& string, StyleSheetInternal* contextStyleSheet)
 {
     RefPtr<StylePropertySet> dummyStyle = StylePropertySet::create();
     if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, CSSQuirksMode, contextStyleSheet))
@@ -917,7 +917,7 @@ PassRefPtr<CSSValueList> CSSParser::parseFontFaceValue(const AtomicString& strin
     return static_pointer_cast<CSSValueList>(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily));
 }
 
-bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode cssParserMode, CSSStyleSheet* contextStyleSheet)
+bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode cssParserMode, StyleSheetInternal* contextStyleSheet)
 {
     if (parseSimpleLengthValue(declaration, propertyID, string, important, cssParserMode))
         return true;
@@ -929,7 +929,7 @@ bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID property
     return parser.parseValue(declaration, propertyID, string, important, contextStyleSheet);
 }
 
-bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSStyleSheet* contextStyleSheet)
+bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, StyleSheetInternal* contextStyleSheet)
 {
     setStyleSheet(contextStyleSheet);
 
@@ -1007,7 +1007,7 @@ bool CSSParser::parseSystemColor(RGBA32& color, const String& string, Document*
 
 void CSSParser::parseSelector(const String& string, Document* doc, CSSSelectorList& selectorList)
 {
-    RefPtr<CSSStyleSheet> dummyStyleSheet = CSSStyleSheet::create(doc);
+    RefPtr<StyleSheetInternal> dummyStyleSheet = StyleSheetInternal::create(doc);
 
     setStyleSheet(dummyStyleSheet.get());
     m_selectorListForParseSelector = &selectorList;
@@ -1022,7 +1022,7 @@ void CSSParser::parseSelector(const String& string, Document* doc, CSSSelectorLi
     ASSERT(dummyStyleSheet->hasOneRef());
 }
 
-bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& string, RefPtr<CSSStyleSourceData>* styleSourceData, CSSStyleSheet* contextStyleSheet)
+bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& string, RefPtr<CSSStyleSourceData>* styleSourceData, StyleSheetInternal* contextStyleSheet)
 {
     // Length of the "@-webkit-decls{" prefix.
     static const unsigned prefixLength = 15;
@@ -1099,7 +1099,7 @@ void CSSParser::clearProperties()
     m_hasFontFaceOnlyValues = false;
 }
 
-void CSSParser::setStyleSheet(CSSStyleSheet* styleSheet)
+void CSSParser::setStyleSheet(StyleSheetInternal* styleSheet)
 {
     m_styleSheet = styleSheet;
 }
@@ -7282,7 +7282,7 @@ bool CSSParser::parseFlowThread(const String& flowName, Document* doc)
     ASSERT(doc);
     ASSERT(doc->cssRegionsEnabled());
 
-    RefPtr<CSSStyleSheet> dummyStyleSheet = CSSStyleSheet::create(doc);
+    RefPtr<StyleSheetInternal> dummyStyleSheet = StyleSheetInternal::create(doc);
     setStyleSheet(dummyStyleSheet.get());
 
     setupParser("@-webkit-decls{-webkit-flow-into:", flowName, "}");
index 9052670..e4aebb2 100644 (file)
@@ -49,7 +49,6 @@ class CSSBorderImageSliceValue;
 class CSSPrimitiveValue;
 class CSSProperty;
 class CSSSelectorList;
-class CSSStyleSheet;
 class CSSValue;
 class CSSValueList;
 class CSSWrapShape;
@@ -62,6 +61,7 @@ class StylePropertyShorthand;
 class StyleRuleBase;
 class StyleRuleKeyframes;
 class StyleKeyframe;
+class StyleSheetInternal;
 class StyledElement;
 
 class CSSParser {
@@ -70,15 +70,15 @@ public:
 
     ~CSSParser();
 
-    void parseSheet(CSSStyleSheet*, const String&, int startLineNumber = 0, StyleRuleRangeMap* ruleRangeMap = 0);
-    PassRefPtr<StyleRuleBase> parseRule(CSSStyleSheet*, const String&);
-    PassRefPtr<StyleKeyframe> parseKeyframeRule(CSSStyleSheet*, const String&);
-    static bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, CSSParserMode, CSSStyleSheet*);
+    void parseSheet(StyleSheetInternal*, const String&, int startLineNumber = 0, StyleRuleRangeMap* = 0);
+    PassRefPtr<StyleRuleBase> parseRule(StyleSheetInternal*, const String&);
+    PassRefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetInternal*, const String&);
+    static bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, CSSParserMode, StyleSheetInternal*);
     static bool parseColor(RGBA32& color, const String&, bool strict = false);
     static bool parseSystemColor(RGBA32& color, const String&, Document*);
-    static PassRefPtr<CSSValueList> parseFontFaceValue(const AtomicString&, CSSStyleSheet* contextStyleSheet);
+    static PassRefPtr<CSSValueList> parseFontFaceValue(const AtomicString&, StyleSheetInternal* contextStyleSheet);
     PassRefPtr<CSSPrimitiveValue> parseValidPrimitive(int ident, CSSParserValue*);
-    bool parseDeclaration(StylePropertySet*, const String&, RefPtr<CSSStyleSourceData>*, CSSStyleSheet* contextStyleSheet);
+    bool parseDeclaration(StylePropertySet*, const String&, RefPtr<CSSStyleSourceData>*, StyleSheetInternal* contextStyleSheet);
     PassOwnPtr<MediaQuery> parseMediaQuery(const String&);
 
     Document* findDocument() const;
@@ -286,7 +286,7 @@ public:
     CSSParserMode m_cssParserMode;
     bool m_important;
     CSSPropertyID m_id;
-    CSSStyleSheet* m_styleSheet;
+    StyleSheetInternal* m_styleSheet;
     RefPtr<StyleRuleBase> m_rule;
     RefPtr<StyleKeyframe> m_keyframe;
     OwnPtr<MediaQuery> m_mediaQuery;
@@ -345,7 +345,7 @@ private:
     inline void detectDashToken(int);
     inline void detectAtToken(int, bool);
 
-    void setStyleSheet(CSSStyleSheet*);
+    void setStyleSheet(StyleSheetInternal*);
 
     inline bool inStrictMode() const { return m_cssParserMode == CSSStrictMode || m_cssParserMode == SVGAttributeMode; }
     inline bool inQuirksMode() const { return m_cssParserMode == CSSQuirksMode; }
@@ -363,7 +363,7 @@ private:
     bool isGeneratedImageValue(CSSParserValue*) const;
     bool parseGeneratedImage(CSSParserValueList*, RefPtr<CSSValue>&);
 
-    bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, CSSStyleSheet* contextStyleSheet);
+    bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, StyleSheetInternal* contextStyleSheet);
 
     enum SizeParameterType {
         None,
index 50cc88a..8531740 100644 (file)
@@ -1060,7 +1060,7 @@ String CSSPrimitiveValue::customCssText() const
     return text;
 }
 
-void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const CSSStyleSheet* styleSheet)
+void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
 {
     if (m_primitiveUnitType == CSS_URI)
         addSubresourceURL(urls, styleSheet->completeURL(m_value.string));
index d8499ea..a86f9e2 100644 (file)
@@ -272,7 +272,7 @@ public:
 
     bool isQuirkValue() { return m_isQuirkValue; }
 
-    void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
+    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
 
     Length viewportPercentageLength();
     
index 911d110..bc786b5 100644 (file)
@@ -59,7 +59,7 @@ String CSSReflectValue::customCssText() const
     return result;
 }
 
-void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const CSSStyleSheet* styleSheet)
+void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
 {
     if (m_mask)
         m_mask->addSubresourceStyleURLs(urls, styleSheet);
index 5b03efe..1514775 100644 (file)
@@ -49,7 +49,7 @@ public:
 
     String customCssText() const;
 
-    void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
+    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
 
 private:
     CSSReflectValue(CSSReflectionDirection direction, PassRefPtr<CSSPrimitiveValue> offset, PassRefPtr<CSSValue> mask)
index 1fb206b..028ab30 100644 (file)
@@ -69,15 +69,6 @@ public:
     bool isRegionRule() const { return type() == WEBKIT_REGION_RULE; }
     bool isImportRule() const { return type() == IMPORT_RULE; }
 
-    CSSParserMode cssParserMode() const
-    {
-        if (parentRule())
-            return parentRule()->cssParserMode();
-        if (parentStyleSheet())
-            return parentStyleSheet()->cssParserMode();
-        return CSSStrictMode;
-    }
-
     void setParentStyleSheet(CSSStyleSheet* styleSheet)
     {
         m_parentIsRule = false;
@@ -102,13 +93,6 @@ public:
     String cssText() const;
     void setCssText(const String&, ExceptionCode&);
 
-    KURL baseURL() const
-    {
-        if (CSSStyleSheet* parentSheet = parentStyleSheet())
-            return parentSheet->baseURL();
-        return KURL();
-    }
-
 protected:
     CSSRule(CSSStyleSheet* parent, Type type)
         : m_hasCachedSelectorText(false)
index 0ee4cf4..5ce77e1 100644 (file)
@@ -235,7 +235,7 @@ public:
 
     typedef HashMap<AtomicStringImpl*, OwnPtr<Vector<RuleData> > > AtomRuleMap;
 
-    void addRulesFromSheet(CSSStyleSheet*, const MediaQueryEvaluator&, CSSStyleSelector* = 0, const ContainerNode* = 0);
+    void addRulesFromSheet(StyleSheetInternal*, const MediaQueryEvaluator&, CSSStyleSelector* = 0, const ContainerNode* = 0);
 
     void addStyleRule(StyleRule*, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool isInRegionRule = false);
     void addRule(StyleRule*, CSSSelector*, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool isInRegionRule = false);
@@ -285,13 +285,13 @@ static RuleSet* defaultStyle;
 static RuleSet* defaultQuirksStyle;
 static RuleSet* defaultPrintStyle;
 static RuleSet* defaultViewSourceStyle;
-static CSSStyleSheet* simpleDefaultStyleSheet;
-static CSSStyleSheet* defaultStyleSheet;
-static CSSStyleSheet* quirksStyleSheet;
-static CSSStyleSheet* svgStyleSheet;
-static CSSStyleSheet* mathMLStyleSheet;
-static CSSStyleSheet* mediaControlsStyleSheet;
-static CSSStyleSheet* fullscreenStyleSheet;
+static StyleSheetInternal* simpleDefaultStyleSheet;
+static StyleSheetInternal* defaultStyleSheet;
+static StyleSheetInternal* quirksStyleSheet;
+static StyleSheetInternal* svgStyleSheet;
+static StyleSheetInternal* mathMLStyleSheet;
+static StyleSheetInternal* mediaControlsStyleSheet;
+static StyleSheetInternal* fullscreenStyleSheet;
 
 RenderStyle* CSSStyleSelector::s_styleNotYetAvailable;
 
@@ -399,7 +399,7 @@ CSSStyleSelector::CSSStyleSelector(Document* document, bool matchAuthorAndUserSt
 
     // FIXME: This sucks! The user sheet is reparsed every time!
     OwnPtr<RuleSet> tempUserStyle = RuleSet::create();
-    if (CSSStyleSheet* pageUserSheet = document->pageUserSheet())
+    if (StyleSheetInternal* pageUserSheet = document->pageUserSheet())
         tempUserStyle->addRulesFromSheet(pageUserSheet, *m_medium, this);
     addAuthorRulesAndCollectUserRulesFromSheets(document->pageGroupUserSheets(), *tempUserStyle);
     addAuthorRulesAndCollectUserRulesFromSheets(document->documentUserSheets(), *tempUserStyle);
@@ -418,14 +418,14 @@ CSSStyleSelector::CSSStyleSelector(Document* document, bool matchAuthorAndUserSt
     appendAuthorStylesheets(0, document->styleSheets()->vector());
 }
 
-void CSSStyleSelector::addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<CSSStyleSheet> >* userSheets, RuleSet& userStyle)
+void CSSStyleSelector::addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<StyleSheetInternal> >* userSheets, RuleSet& userStyle)
 {
     if (!userSheets)
         return;
 
     unsigned length = userSheets->size();
     for (unsigned i = 0; i < length; i++) {
-        const RefPtr<CSSStyleSheet>& sheet = userSheets->at(i);
+        const RefPtr<StyleSheetInternal>& sheet = userSheets->at(i);
         if (sheet->isUserStyleSheet())
             userStyle.addRulesFromSheet(sheet.get(), *m_medium, this);
         else
@@ -464,7 +464,7 @@ void CSSStyleSelector::collectFeatures()
 }
 
 #if ENABLE(STYLE_SCOPED)
-const ContainerNode* CSSStyleSelector::determineScope(const CSSStyleSheet* sheet)
+const ContainerNode* CSSStyleSelector::determineScope(const StyleSheetInternal* sheet)
 {
     ASSERT(sheet);
 
@@ -504,17 +504,18 @@ void CSSStyleSelector::appendAuthorStylesheets(unsigned firstNew, const Vector<R
         if (!stylesheets[i]->isCSSStyleSheet() || stylesheets[i]->disabled())
             continue;
         CSSStyleSheet* cssSheet = static_cast<CSSStyleSheet*>(stylesheets[i].get());
+        StyleSheetInternal* sheet = cssSheet->internal();
 #if ENABLE(STYLE_SCOPED)
-        const ContainerNode* scope = determineScope(cssSheet);
+        const ContainerNode* scope = determineScope(sheet);
         if (scope) {
             ScopedRuleSetMap::AddResult addResult = m_scopedAuthorStyles.add(scope, nullptr);
             if (addResult.isNewEntry)
                 addResult.iterator->second = RuleSet::create();
-            addResult.iterator->second->addRulesFromSheet(cssSheet, *m_medium, this, scope);
+            addResult.iterator->second->addRulesFromSheet(sheet, *m_medium, this, scope);
             continue;
         }
 #endif
-        m_authorStyle->addRulesFromSheet(cssSheet, *m_medium, this);
+        m_authorStyle->addRulesFromSheet(sheet, *m_medium, this);
         if (!m_styleRuleToCSSOMWrapperMap.isEmpty())
             collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, cssSheet);
     }
@@ -680,14 +681,14 @@ void CSSStyleSelector::Features::clear()
     usesLinkRules = false;
 }
 
-static CSSStyleSheet* parseUASheet(const String& str)
+static StyleSheetInternal* parseUASheet(const String& str)
 {
-    CSSStyleSheet* sheet = CSSStyleSheet::create().leakRef(); // leak the sheet on purpose
+    StyleSheetInternal* sheet = StyleSheetInternal::create().leakRef(); // leak the sheet on purpose
     sheet->parseString(str);
     return sheet;
 }
 
-static CSSStyleSheet* parseUASheet(const char* characters, unsigned size)
+static StyleSheetInternal* parseUASheet(const char* characters, unsigned size)
 {
     return parseUASheet(String(characters, size));
 }
@@ -2237,7 +2238,7 @@ bool CSSStyleSelector::checkRegionSelector(CSSSelector* regionSelector, Element*
     return false;
 }
     
-bool CSSStyleSelector::determineStylesheetSelectorScopes(CSSStyleSheet* stylesheet, HashSet<AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes)
+bool CSSStyleSelector::determineStylesheetSelectorScopes(StyleSheetInternal* stylesheet, HashSet<AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes)
 {
     ASSERT(!stylesheet->isLoading());
 
@@ -2462,7 +2463,7 @@ void RuleSet::addRegionRule(StyleRuleRegion* regionRule, bool hasDocumentSecurit
     m_regionSelectorsAndRuleSets.append(RuleSetSelectorPair(regionRule->selectorList().first(), regionRuleSet.release()));
 }
 
-void RuleSet::addRulesFromSheet(CSSStyleSheet* sheet, const MediaQueryEvaluator& medium, CSSStyleSelector* styleSelector, const ContainerNode* scope)
+void RuleSet::addRulesFromSheet(StyleSheetInternal* sheet, const MediaQueryEvaluator& medium, CSSStyleSelector* styleSelector, const ContainerNode* scope)
 {
     ASSERT(sheet);
 
@@ -2903,7 +2904,16 @@ static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wra
     }
 }
 
-static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wrapperMap, Document* document)
+static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wrapperMap, HashSet<RefPtr<CSSStyleSheet> >& sheetWrapperSet, StyleSheetInternal* styleSheet)
+{
+    if (!styleSheet)
+        return;
+    RefPtr<CSSStyleSheet> styleSheetWrapper = CSSStyleSheet::create(styleSheet);
+    sheetWrapperSet.add(styleSheetWrapper);
+    collectCSSOMWrappers(wrapperMap, styleSheetWrapper.get());
+}
+
+static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wrapperMap, HashSet<RefPtr<CSSStyleSheet> >& sheetWrapperSet, Document* document)
 {
     const Vector<RefPtr<StyleSheet> >& styleSheets = document->styleSheets()->vector();
     for (unsigned i = 0; i < styleSheets.size(); ++i) {
@@ -2912,21 +2922,21 @@ static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wra
             continue;
         collectCSSOMWrappers(wrapperMap, static_cast<CSSStyleSheet*>(styleSheet));
     }
-    collectCSSOMWrappers(wrapperMap, document->pageUserSheet());
+    collectCSSOMWrappers(wrapperMap, sheetWrapperSet, document->pageUserSheet());
 }
 
 CSSStyleRule* CSSStyleSelector::ensureFullCSSOMWrapperForInspector(StyleRule* rule)
 {
     if (m_styleRuleToCSSOMWrapperMap.isEmpty()) {
-        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, simpleDefaultStyleSheet);
-        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, defaultStyleSheet);
-        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, quirksStyleSheet);
-        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, svgStyleSheet);
-        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, mathMLStyleSheet);
-        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, mediaControlsStyleSheet);
-        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, fullscreenStyleSheet);
-
-        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, document());
+        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, simpleDefaultStyleSheet);
+        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, defaultStyleSheet);
+        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, quirksStyleSheet);
+        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, svgStyleSheet);
+        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, mathMLStyleSheet);
+        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, mediaControlsStyleSheet);
+        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, fullscreenStyleSheet);
+
+        collectCSSOMWrappers(m_styleRuleToCSSOMWrapperMap, m_styleSheetCSSOMWrapperSet, document());
     }
     return m_styleRuleToCSSOMWrapperMap.get(rule).get();
 }
index d703ba4..b47a24f 100644 (file)
@@ -80,6 +80,7 @@ class StyleRulePage;
 class StyleRuleRegion;
 class StyleShader;
 class StyleSheet;
+class StyleSheetInternal;
 class StyleSheetList;
 class StyledElement;
 class WebKitCSSFilterValue;
@@ -156,7 +157,7 @@ public:
     void appendAuthorStylesheets(unsigned firstNew, const Vector<RefPtr<StyleSheet> >&);
     
     // 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.
-    static bool determineStylesheetSelectorScopes(CSSStyleSheet*, HashSet<AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes);
+    static bool determineStylesheetSelectorScopes(StyleSheetInternal*, HashSet<AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes);
 
 private:
     void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO);
@@ -399,7 +400,7 @@ public:
 private:
     static RenderStyle* s_styleNotYetAvailable;
 
-    void addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<CSSStyleSheet> >*, RuleSet& userStyle);
+    void addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<StyleSheetInternal> >*, RuleSet& userStyle);
 
     void cacheBorderAndBackground();
 
@@ -496,13 +497,14 @@ private:
     const CSSStyleApplyProperty& m_applyProperty;
     
     HashMap<StyleRule*, RefPtr<CSSStyleRule> > m_styleRuleToCSSOMWrapperMap;
+    HashSet<RefPtr<CSSStyleSheet> > m_styleSheetCSSOMWrapperSet;
 
 #if ENABLE(CSS_SHADERS)
     bool m_hasPendingShaders;
 #endif
 
 #if ENABLE(STYLE_SCOPED)
-    static const ContainerNode* determineScope(const CSSStyleSheet*);
+    static const ContainerNode* determineScope(const StyleSheetInternal*);
 
     typedef HashMap<const ContainerNode*, OwnPtr<RuleSet> > ScopedRuleSetMap;
 
index 4f617ed..2de1ae6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -74,9 +74,11 @@ static bool isAcceptableCSSStyleSheetParent(Node* parentNode)
 }
 #endif
 
-CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const KURL& baseURL, const String& charset)
-    : StyleSheet(parentNode, href, baseURL)
+StyleSheetInternal::StyleSheetInternal(Node* parentNode, const String& originalURL, const KURL& finalURL, const String& charset)
+    : m_ownerNode(parentNode)
     , m_ownerRule(0)
+    , m_originalURL(originalURL)
+    , m_finalURL(finalURL)
     , m_charset(charset)
     , m_loadCompleted(false)
     , m_cssParserMode(CSSQuirksMode)
@@ -87,25 +89,27 @@ CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const KURL& b
     ASSERT(isAcceptableCSSStyleSheetParent(parentNode));
 }
 
-CSSStyleSheet::CSSStyleSheet(StyleRuleImport* ownerRule, const String& href, const KURL& baseURL, const String& charset)
-    : StyleSheet(href, baseURL)
+StyleSheetInternal::StyleSheetInternal(StyleRuleImport* ownerRule, const String& originalURL, const KURL& finalURL, const String& charset)
+    : m_ownerNode(0)
     , m_ownerRule(ownerRule)
+    , m_originalURL(originalURL)
+    , m_finalURL(finalURL)
     , m_charset(charset)
     , m_loadCompleted(false)
     , m_cssParserMode((ownerRule && ownerRule->parentStyleSheet()) ? ownerRule->parentStyleSheet()->cssParserMode() : CSSStrictMode)
     , m_hasSyntacticallyValidCSSHeader(true)
     , m_didLoadErrorOccur(false)
 {
-    CSSStyleSheet* parentSheet = ownerRule ? ownerRule->parentStyleSheet() : 0;
+    StyleSheetInternal* parentSheet = ownerRule ? ownerRule->parentStyleSheet() : 0;
     m_isUserStyleSheet = parentSheet ? parentSheet->isUserStyleSheet() : false;
 }
 
-CSSStyleSheet::~CSSStyleSheet()
+StyleSheetInternal::~StyleSheetInternal()
 {
     clearRules();
 }
 
-void CSSStyleSheet::parserAppendRule(PassRefPtr<StyleRuleBase> rule)
+void StyleSheetInternal::parserAppendRule(PassRefPtr<StyleRuleBase> rule)
 {
     ASSERT(!rule->isCharsetRule());
     if (rule->isImportRule()) {
@@ -118,24 +122,24 @@ void CSSStyleSheet::parserAppendRule(PassRefPtr<StyleRuleBase> rule)
     m_childRules.append(rule);
 }
 
-PassRefPtr<CSSRule> CSSStyleSheet::createChildRuleCSSOMWrapper(unsigned index)
+PassRefPtr<CSSRule> StyleSheetInternal::createChildRuleCSSOMWrapper(unsigned index, CSSStyleSheet* parentWrapper)
 {
-    ASSERT(index < length());
+    ASSERT(index < ruleCount());
     
     unsigned childVectorIndex = index;
     if (hasCharsetRule()) {
         if (index == 0)
-            return CSSCharsetRule::create(this, m_encodingFromCharsetRule);
+            return CSSCharsetRule::create(parentWrapper, m_encodingFromCharsetRule);
         --childVectorIndex;
     }
     if (childVectorIndex < m_importRules.size())
-        return m_importRules[childVectorIndex]->createCSSOMWrapper(this);
+        return m_importRules[childVectorIndex]->createCSSOMWrapper(parentWrapper);
     
     childVectorIndex -= m_importRules.size();
-    return m_childRules[childVectorIndex]->createCSSOMWrapper(this);
+    return m_childRules[childVectorIndex]->createCSSOMWrapper(parentWrapper);
 }
 
-unsigned CSSStyleSheet::length() const
+unsigned StyleSheetInternal::ruleCount() const
 {
     unsigned result = 0;
     result += hasCharsetRule() ? 1 : 0;
@@ -144,38 +148,13 @@ unsigned CSSStyleSheet::length() const
     return result;
 }
 
-CSSRule* CSSStyleSheet::item(unsigned index)
-{
-    unsigned ruleCount = length();
-    if (index >= ruleCount)
-        return 0;
-    
-    if (m_childRuleCSSOMWrappers.isEmpty())
-        m_childRuleCSSOMWrappers.grow(ruleCount);
-    ASSERT(m_childRuleCSSOMWrappers.size() == ruleCount);
-
-    RefPtr<CSSRule>& cssRule = m_childRuleCSSOMWrappers[index];
-    if (!cssRule)
-        cssRule = createChildRuleCSSOMWrapper(index);
-    return cssRule.get();
-}
-
-void CSSStyleSheet::clearCharsetRule()
+void StyleSheetInternal::clearCharsetRule()
 {
     m_encodingFromCharsetRule = String();
 }
 
-void CSSStyleSheet::clearRules()
+void StyleSheetInternal::clearRules()
 {
-    // For style rules outside the document, .parentStyleSheet can become null even if the style rule
-    // is still observable from JavaScript. This matches the behavior of .parentNode for nodes, but
-    // it's not ideal because it makes the CSSOM's behavior depend on the timing of garbage collection.
-    for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) {
-        if (m_childRuleCSSOMWrappers[i])
-            m_childRuleCSSOMWrappers[i]->setParentStyleSheet(0);
-    }
-    m_childRuleCSSOMWrappers.clear();
-
     for (unsigned i = 0; i < m_importRules.size(); ++i) {
         ASSERT(m_importRules.at(i)->parentStyleSheet() == this);
         m_importRules[i]->clearParentStyleSheet();
@@ -185,45 +164,16 @@ void CSSStyleSheet::clearRules()
     clearCharsetRule();
 }
 
-void CSSStyleSheet::parserSetEncodingFromCharsetRule(const String& encoding)
+void StyleSheetInternal::parserSetEncodingFromCharsetRule(const String& encoding)
 {
     // Parser enforces that there is ever only one @charset.
     ASSERT(m_encodingFromCharsetRule.isNull());
     m_encodingFromCharsetRule = encoding; 
 }
 
-PassRefPtr<CSSRuleList> CSSStyleSheet::rules()
-{
-    KURL url = finalURL();
-    Document* document = findDocument();
-    if (!url.isEmpty() && document && !document->securityOrigin()->canRequest(url))
-        return 0;
-    // IE behavior.
-    RefPtr<StaticCSSRuleList> nonCharsetRules = StaticCSSRuleList::create();
-    unsigned ruleCount = length();
-    for (unsigned i = 0; i < ruleCount; ++i) {
-        CSSRule* rule = item(i);
-        if (rule->isCharsetRule())
-            continue;
-        nonCharsetRules->rules().append(rule);
-    }
-    return nonCharsetRules.release();
-}
-
-unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, ExceptionCode& ec)
+bool StyleSheetInternal::wrapperInsertRule(PassRefPtr<StyleRuleBase> rule, unsigned index)
 {
-    ec = 0;
-    if (index > length()) {
-        ec = INDEX_SIZE_ERR;
-        return 0;
-    }
-    CSSParser p(cssParserMode());
-    RefPtr<StyleRuleBase> rule = p.parseRule(this, ruleString);
-
-    if (!rule) {
-        ec = SYNTAX_ERR;
-        return 0;
-    }
+    ASSERT(index <= ruleCount());
     // Parser::parseRule doesn't currently allow @charset so we don't need to deal with it.
     ASSERT(!rule->isCharsetRule());
     
@@ -232,100 +182,58 @@ unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
     if (hasCharsetRule()) {
         if (childVectorIndex == 0) {
             // Nothing can be inserted before @charset.
-            ec = HIERARCHY_REQUEST_ERR;
-            return 0;
+            return false;
         }
         --childVectorIndex;
     }
     
     if (childVectorIndex < m_importRules.size() || (childVectorIndex == m_importRules.size() && rule->isImportRule())) {
         // Inserting non-import rule before @import is not allowed.
-        if (!rule->isImportRule()) {
-            ec = HIERARCHY_REQUEST_ERR;
-            return 0;
-        }
+        if (!rule->isImportRule())
+            return false;
         m_importRules.insert(childVectorIndex, static_cast<StyleRuleImport*>(rule.get()));
         m_importRules[childVectorIndex]->requestStyleSheet();
-        goto success;
+        // FIXME: Stylesheet doesn't actually change meaningfully before the imported sheets are loaded.
+        styleSheetChanged();
+        return true;
     }
     // Inserting @import rule after a non-import rule is not allowed.
-    if (rule->isImportRule()) {
-        ec = HIERARCHY_REQUEST_ERR;
-        return 0;
-    }
+    if (rule->isImportRule())
+        return false;
     childVectorIndex -= m_importRules.size();
  
-    m_childRules.insert(childVectorIndex, rule.release());
+    m_childRules.insert(childVectorIndex, rule);
     
-success:
-    if (!m_childRuleCSSOMWrappers.isEmpty())
-        m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>());
-
-    // FIXME: Stylesheet doesn't actually change meaningfully before the imported sheets are loaded.
     styleSheetChanged();
-    return index;
-}
-
-int CSSStyleSheet::addRule(const String& selector, const String& style, int index, ExceptionCode& ec)
-{
-    insertRule(selector + " { " + style + " }", index, ec);
-
-    // As per Microsoft documentation, always return -1.
-    return -1;
-}
-
-int CSSStyleSheet::addRule(const String& selector, const String& style, ExceptionCode& ec)
-{
-    return addRule(selector, style, length(), ec);
+    return true;
 }
 
-PassRefPtr<CSSRuleList> CSSStyleSheet::cssRules()
+void StyleSheetInternal::wrapperDeleteRule(unsigned index)
 {
-    KURL url = finalURL();
-    Document* document = findDocument();
-    if (!url.isEmpty() && document && !document->securityOrigin()->canRequest(url))
-        return 0;
-    if (!m_ruleListCSSOMWrapper)
-        m_ruleListCSSOMWrapper = adoptPtr(new StyleSheetCSSRuleList(this));
-    return m_ruleListCSSOMWrapper.get();
-}
+    ASSERT(index < ruleCount());
 
-void CSSStyleSheet::deleteRule(unsigned index, ExceptionCode& ec)
-{
-    if (index >= length()) {
-        ec = INDEX_SIZE_ERR;
-        return;
-    }
-    
-    ec = 0;
     unsigned childVectorIndex = index;
     if (hasCharsetRule()) {
         if (childVectorIndex == 0) {
             clearCharsetRule();
-            goto success;
+            styleSheetChanged();
+            return;
         }
         --childVectorIndex;
     }
     if (childVectorIndex < m_importRules.size()) {
         m_importRules[childVectorIndex]->clearParentStyleSheet();
         m_importRules.remove(childVectorIndex);
-        goto success;
+        styleSheetChanged();
+        return;
     }
     childVectorIndex -= m_importRules.size();
 
     m_childRules.remove(childVectorIndex);
-
-success:
-    if (!m_childRuleCSSOMWrappers.isEmpty()) {
-        if (m_childRuleCSSOMWrappers[index])
-            m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0);
-        m_childRuleCSSOMWrappers.remove(index);
-    }
-
     styleSheetChanged();
 }
 
-void CSSStyleSheet::addNamespace(CSSParser* p, const AtomicString& prefix, const AtomicString& uri)
+void StyleSheetInternal::addNamespace(CSSParser* p, const AtomicString& prefix, const AtomicString& uri)
 {
     if (uri.isNull())
         return;
@@ -338,7 +246,7 @@ void CSSStyleSheet::addNamespace(CSSParser* p, const AtomicString& prefix, const
         p->m_defaultNamespace = uri;
 }
 
-const AtomicString& CSSStyleSheet::determineNamespace(const AtomicString& prefix)
+const AtomicString& StyleSheetInternal::determineNamespace(const AtomicString& prefix)
 {
     if (prefix.isNull())
         return nullAtom; // No namespace. If an element/attribute has a namespace, we won't match it.
@@ -351,12 +259,12 @@ const AtomicString& CSSStyleSheet::determineNamespace(const AtomicString& prefix
     return nullAtom; // Assume we won't match any namespaces.
 }
 
-bool CSSStyleSheet::parseString(const String &string, CSSParserMode cssParserMode)
+bool StyleSheetInternal::parseString(const String &string, CSSParserMode cssParserMode)
 {
     return parseStringAtLine(string, cssParserMode, 0);
 }
 
-bool CSSStyleSheet::parseStringAtLine(const String& string, CSSParserMode cssParserMode, int startLineNumber)
+bool StyleSheetInternal::parseStringAtLine(const String& string, CSSParserMode cssParserMode, int startLineNumber)
 {
     setCSSParserMode(cssParserMode);
     CSSParser p(cssParserMode);
@@ -364,7 +272,7 @@ bool CSSStyleSheet::parseStringAtLine(const String& string, CSSParserMode cssPar
     return true;
 }
 
-bool CSSStyleSheet::isLoading()
+bool StyleSheetInternal::isLoading() const
 {
     for (unsigned i = 0; i < m_importRules.size(); ++i) {
         if (m_importRules[i]->isLoading())
@@ -373,7 +281,7 @@ bool CSSStyleSheet::isLoading()
     return false;
 }
 
-void CSSStyleSheet::checkLoaded()
+void StyleSheetInternal::checkLoaded()
 {
     if (isLoading())
         return;
@@ -381,8 +289,8 @@ void CSSStyleSheet::checkLoaded()
     // Avoid |this| being deleted by scripts that run via
     // ScriptableDocumentParser::executeScriptsWaitingForStylesheets().
     // See <rdar://problem/6622300>.
-    RefPtr<CSSStyleSheet> protector(this);
-    if (CSSStyleSheet* styleSheet = parentStyleSheet())
+    RefPtr<StyleSheetInternal> protector(this);
+    if (StyleSheetInternal* styleSheet = parentStyleSheet())
         styleSheet->checkLoaded();
 
     RefPtr<Node> owner = ownerNode();
@@ -395,50 +303,43 @@ void CSSStyleSheet::checkLoaded()
     }
 }
 
-void CSSStyleSheet::notifyLoadedSheet(const CachedCSSStyleSheet* sheet)
+void StyleSheetInternal::notifyLoadedSheet(const CachedCSSStyleSheet* sheet)
 {
     ASSERT(sheet);
     m_didLoadErrorOccur |= sheet->errorOccurred();
 }
 
-void CSSStyleSheet::startLoadingDynamicSheet()
+void StyleSheetInternal::startLoadingDynamicSheet()
 {
     if (Node* owner = ownerNode())
         owner->startLoadingDynamicSheet();
 }
 
-Node* CSSStyleSheet::findStyleSheetOwnerNode() const
+Node* StyleSheetInternal::findStyleSheetOwnerNode() const
 {
-    for (const CSSStyleSheet* sheet = this; sheet; sheet = sheet->parentStyleSheet()) {
+    for (const StyleSheetInternal* sheet = this; sheet; sheet = sheet->parentStyleSheet()) {
         if (Node* ownerNode = sheet->ownerNode())
             return ownerNode;
     }
     return 0;
 }
 
-Document* CSSStyleSheet::findDocument()
+Document* StyleSheetInternal::findDocument()
 {
     Node* ownerNode = findStyleSheetOwnerNode();
 
     return ownerNode ? ownerNode->document() : 0;
 }
-    
-MediaList* CSSStyleSheet::media() const 
-{ 
-    if (!m_mediaQueries)
-        return 0;
-    return m_mediaQueries->ensureMediaList(const_cast<CSSStyleSheet*>(this));
-}
 
-void CSSStyleSheet::setMediaQueries(PassRefPtr<MediaQuerySet> mediaQueries)
+void StyleSheetInternal::setMediaQueries(PassRefPtr<MediaQuerySet> mediaQueries)
 {
     m_mediaQueries = mediaQueries;
 }
 
-void CSSStyleSheet::styleSheetChanged()
+void StyleSheetInternal::styleSheetChanged()
 {
-    CSSStyleSheet* rootSheet = this;
-    while (CSSStyleSheet* parent = rootSheet->parentStyleSheet())
+    StyleSheetInternal* rootSheet = this;
+    while (StyleSheetInternal* parent = rootSheet->parentStyleSheet())
         rootSheet = parent;
 
     /* FIXME: We don't need to do everything updateStyleSelector does,
@@ -448,8 +349,19 @@ void CSSStyleSheet::styleSheetChanged()
     if (Document* documentToUpdate = rootSheet->findDocument())
         documentToUpdate->styleSelectorChanged(DeferRecalcStyle);
 }
+    
+KURL StyleSheetInternal::baseURL() const
+{
+    if (!m_finalURL.isNull())
+        return m_finalURL;
+    if (StyleSheetInternal* parentSheet = parentStyleSheet())
+        return parentSheet->baseURL();
+    if (!m_ownerNode)
+        return KURL();
+    return m_ownerNode->document()->baseURL();
+}
 
-KURL CSSStyleSheet::completeURL(const String& url) const
+KURL StyleSheetInternal::completeURL(const String& url) const
 {
     // Always return a null URL when passed a null string.
     // FIXME: Should we change the KURL constructor to have this behavior?
@@ -462,13 +374,13 @@ KURL CSSStyleSheet::completeURL(const String& url) const
     return KURL(baseURL(), url, encoding);
 }
 
-void CSSStyleSheet::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
+void StyleSheetInternal::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
 {
-    Deque<CSSStyleSheet*> styleSheetQueue;
+    Deque<StyleSheetInternal*> styleSheetQueue;
     styleSheetQueue.append(this);
 
     while (!styleSheetQueue.isEmpty()) {
-        CSSStyleSheet* styleSheet = styleSheetQueue.takeFirst();
+        StyleSheetInternal* styleSheet = styleSheetQueue.takeFirst();
         
         for (unsigned i = 0; i < styleSheet->m_importRules.size(); ++i) {
             StyleRuleImport* importRule = styleSheet->m_importRules[i].get();
@@ -487,25 +399,160 @@ void CSSStyleSheet::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
     }
 }
 
-CSSImportRule* CSSStyleSheet::ensureCSSOMWrapper(StyleRuleImport* importRule)
+StyleSheetInternal* StyleSheetInternal::parentStyleSheet() const
 {
-     for (unsigned i = 0; i < m_importRules.size(); ++i) {
-         if (m_importRules[i] == importRule)
-             return static_cast<CSSImportRule*>(item(i));
-     }
-    ASSERT_NOT_REACHED();
-    return 0;
+    return m_ownerRule ? m_ownerRule->parentStyleSheet() : 0;
 }
 
-CSSImportRule* CSSStyleSheet::ownerRule() const 
-{  
-    return parentStyleSheet() ? parentStyleSheet()->ensureCSSOMWrapper(m_ownerRule) : 0; 
+CSSStyleSheet::CSSStyleSheet(PassRefPtr<StyleSheetInternal> styleSheet, CSSImportRule* ownerRule)
+    : m_internal(styleSheet)
+    , m_isDisabled(false)
+    , m_ownerRule(ownerRule)
+{
 }
 
-CSSStyleSheet* CSSStyleSheet::parentStyleSheet() const
+CSSStyleSheet::~CSSStyleSheet()
 {
-    ASSERT(isCSSStyleSheet());
-    return m_ownerRule ? m_ownerRule->parentStyleSheet() : 0;
+    // For style rules outside the document, .parentStyleSheet can become null even if the style rule
+    // is still observable from JavaScript. This matches the behavior of .parentNode for nodes, but
+    // it's not ideal because it makes the CSSOM's behavior depend on the timing of garbage collection.
+    for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) {
+        if (m_childRuleCSSOMWrappers[i])
+            m_childRuleCSSOMWrappers[i]->setParentStyleSheet(0);
+    }
+}
+
+void CSSStyleSheet::setDisabled(bool disabled)
+{ 
+    if (disabled == m_isDisabled)
+        return;
+    m_isDisabled = disabled; 
+    m_internal->styleSheetChanged();
+}
+
+unsigned CSSStyleSheet::length() const
+{
+    return m_internal->ruleCount();
+}
+
+CSSRule* CSSStyleSheet::item(unsigned index)
+{
+    unsigned ruleCount = length();
+    if (index >= ruleCount)
+        return 0;
+
+    if (m_childRuleCSSOMWrappers.isEmpty())
+        m_childRuleCSSOMWrappers.grow(ruleCount);
+    ASSERT(m_childRuleCSSOMWrappers.size() == ruleCount);
+    
+    RefPtr<CSSRule>& cssRule = m_childRuleCSSOMWrappers[index];
+    if (!cssRule)
+        cssRule = m_internal->createChildRuleCSSOMWrapper(index, this);
+    return cssRule.get();
+}
+
+PassRefPtr<CSSRuleList> CSSStyleSheet::rules()
+{
+    KURL url = m_internal->finalURL();
+    Document* document = m_internal->findDocument();
+    if (!url.isEmpty() && document && !document->securityOrigin()->canRequest(url))
+        return 0;
+    // IE behavior.
+    RefPtr<StaticCSSRuleList> nonCharsetRules = StaticCSSRuleList::create();
+    unsigned ruleCount = length();
+    for (unsigned i = 0; i < ruleCount; ++i) {
+        CSSRule* rule = item(i);
+        if (rule->isCharsetRule())
+            continue;
+        nonCharsetRules->rules().append(rule);
+    }
+    return nonCharsetRules.release();
+}
+
+unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, ExceptionCode& ec)
+{
+    ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size() == m_internal->ruleCount());
+
+    ec = 0;
+    if (index > length()) {
+        ec = INDEX_SIZE_ERR;
+        return 0;
+    }
+    CSSParser p(m_internal->cssParserMode());
+    RefPtr<StyleRuleBase> rule = p.parseRule(m_internal.get(), ruleString);
+
+    if (!rule) {
+        ec = SYNTAX_ERR;
+        return 0;
+    }
+    bool success = m_internal->wrapperInsertRule(rule, index);
+    if (!success) {
+        ec = HIERARCHY_REQUEST_ERR;
+        return 0;
+    }        
+    if (!m_childRuleCSSOMWrappers.isEmpty())
+        m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>());
+    return index;
+}
+
+void CSSStyleSheet::deleteRule(unsigned index, ExceptionCode& ec)
+{
+    ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size() == m_internal->ruleCount());
+
+    ec = 0;
+    if (index >= length()) {
+        ec = INDEX_SIZE_ERR;
+        return;
+    }
+    m_internal->wrapperDeleteRule(index);
+
+    if (!m_childRuleCSSOMWrappers.isEmpty()) {
+        if (m_childRuleCSSOMWrappers[index])
+            m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0);
+        m_childRuleCSSOMWrappers.remove(index);
+    }
+}
+
+int CSSStyleSheet::addRule(const String& selector, const String& style, int index, ExceptionCode& ec)
+{
+    insertRule(selector + " { " + style + " }", index, ec);
+    
+    // As per Microsoft documentation, always return -1.
+    return -1;
+}
+
+int CSSStyleSheet::addRule(const String& selector, const String& style, ExceptionCode& ec)
+{
+    return addRule(selector, style, length(), ec);
+}
+
+
+PassRefPtr<CSSRuleList> CSSStyleSheet::cssRules()
+{
+    KURL url = m_internal->finalURL();
+    Document* document = m_internal->findDocument();
+    if (!url.isEmpty() && document && !document->securityOrigin()->canRequest(url))
+        return 0;
+    if (!m_ruleListCSSOMWrapper)
+        m_ruleListCSSOMWrapper = adoptPtr(new StyleSheetCSSRuleList(this));
+    return m_ruleListCSSOMWrapper.get();
+}
+
+MediaList* CSSStyleSheet::media() const 
+{ 
+    if (!m_internal->mediaQueries())
+        return 0;
+    return m_internal->mediaQueries()->ensureMediaList(const_cast<CSSStyleSheet*>(this));
+}
+
+CSSStyleSheet* CSSStyleSheet::parentStyleSheet() const 
+{ 
+    return m_ownerRule ? m_ownerRule->parentStyleSheet() : 0; 
+}
+
+void CSSStyleSheet::clearChildRuleCSSOMWrappers()
+{
+    m_childRuleCSSOMWrappers.clear();
 }
 
 }
index 097af35..98f36f7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -31,6 +31,7 @@ class CSSImportRule;
 class CSSParser;
 class CSSRule;
 class CSSRuleList;
+class CSSStyleSheet;
 class CachedCSSStyleSheet;
 class CachedResourceLoader;
 class Document;
@@ -41,53 +42,41 @@ struct CSSNamespace;
 
 typedef int ExceptionCode;
 
-class CSSStyleSheet : public StyleSheet {
+class StyleSheetInternal : public RefCounted<StyleSheetInternal> {
 public:
-    static PassRefPtr<CSSStyleSheet> create()
+    static PassRefPtr<StyleSheetInternal> create()
     {
-        return adoptRef(new CSSStyleSheet(static_cast<StyleRuleImport*>(0), String(), KURL(), String()));
+        return adoptRef(new StyleSheetInternal(static_cast<StyleRuleImport*>(0), String(), KURL(), String()));
     }
-    static PassRefPtr<CSSStyleSheet> create(Node* ownerNode)
+    static PassRefPtr<StyleSheetInternal> create(Node* ownerNode)
     {
-        return adoptRef(new CSSStyleSheet(ownerNode, String(), KURL(), String()));
+        return adoptRef(new StyleSheetInternal(ownerNode, String(), KURL(), String()));
     }
-    static PassRefPtr<CSSStyleSheet> create(Node* ownerNode, const String& originalURL, const KURL& finalURL, const String& charset)
+    static PassRefPtr<StyleSheetInternal> create(Node* ownerNode, const String& originalURL, const KURL& finalURL, const String& charset)
     {
-        return adoptRef(new CSSStyleSheet(ownerNode, originalURL, finalURL, charset));
+        return adoptRef(new StyleSheetInternal(ownerNode, originalURL, finalURL, charset));
     }
-    static PassRefPtr<CSSStyleSheet> create(StyleRuleImport* ownerRule, const String& originalURL, const KURL& finalURL, const String& charset)
+    static PassRefPtr<StyleSheetInternal> create(StyleRuleImport* ownerRule, const String& originalURL, const KURL& finalURL, const String& charset)
     {
-        return adoptRef(new CSSStyleSheet(ownerRule, originalURL, finalURL, charset));
+        return adoptRef(new StyleSheetInternal(ownerRule, originalURL, finalURL, charset));
     }
-    static PassRefPtr<CSSStyleSheet> createInline(Node* ownerNode, const KURL& finalURL)
+    static PassRefPtr<StyleSheetInternal> createInline(Node* ownerNode, const KURL& finalURL)
     {
-        return adoptRef(new CSSStyleSheet(ownerNode, finalURL.string(), finalURL, String()));
+        return adoptRef(new StyleSheetInternal(ownerNode, finalURL.string(), finalURL, String()));
     }
 
-    virtual ~CSSStyleSheet();
-
-    virtual CSSStyleSheet* parentStyleSheet() const OVERRIDE;
-
-    PassRefPtr<CSSRuleList> cssRules();
-    unsigned insertRule(const String& rule, unsigned index, ExceptionCode&);
-    void deleteRule(unsigned index, ExceptionCode&);
-
-    // IE Extensions
-    PassRefPtr<CSSRuleList> rules();
-    int addRule(const String& selector, const String& style, int index, ExceptionCode&);
-    int addRule(const String& selector, const String& style, ExceptionCode&);
-    void removeRule(unsigned index, ExceptionCode& ec) { deleteRule(index, ec); }
+    ~StyleSheetInternal();
 
     void addNamespace(CSSParser*, const AtomicString& prefix, const AtomicString& uri);
     const AtomicString& determineNamespace(const AtomicString& prefix);
 
     void styleSheetChanged();
 
-    virtual bool parseString(const String&, CSSParserMode = CSSStrictMode);
+    bool parseString(const String&, CSSParserMode = CSSStrictMode);
 
     bool parseStringAtLine(const String&, CSSParserMode, int startLineNumber);
 
-    virtual bool isLoading();
+    bool isLoading() const;
 
     void checkLoaded();
     void startLoadingDynamicSheet();
@@ -115,38 +104,53 @@ public:
 
     void clearRules();
 
-    unsigned length() const;
-    CSSRule* item(unsigned index);
-
     // Rules other than @charset and @import.
     const Vector<RefPtr<StyleRuleBase> >& childRules() const { return m_childRules; }
     const Vector<RefPtr<StyleRuleImport> >& importRules() const { return m_importRules; }
 
-    virtual MediaList* media() const OVERRIDE;
-
     MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
     void setMediaQueries(PassRefPtr<MediaQuerySet>);
 
     void notifyLoadedSheet(const CachedCSSStyleSheet*);
     
-    virtual CSSImportRule* ownerRule() const OVERRIDE;
+    StyleSheetInternal* parentStyleSheet() const;
+    Node* ownerNode() const { return m_ownerNode; }
+    void clearOwnerNode() { m_ownerNode = 0; }
+    StyleRuleImport* ownerRule() const { return m_ownerRule; }
     void clearOwnerRule() { m_ownerRule = 0; }
     
-    CSSImportRule* ensureCSSOMWrapper(StyleRuleImport*);
+    // Note that href is the URL that started the redirect chain that led to
+    // this style sheet. This property probably isn't useful for much except
+    // the JavaScript binding (which needs to use this value for security).
+    String originalURL() const { return m_originalURL; }
+    String title() const { return m_title; }
+    void setTitle(const String& title) { m_title = title; }
+    
+    void setFinalURL(const KURL& finalURL) { m_finalURL = finalURL; }
+    const KURL& finalURL() const { return m_finalURL; }
+    KURL baseURL() const;
 
-private:
-    CSSStyleSheet(Node* ownerNode, const String& originalURL, const KURL& finalURL, const String& charset);
-    CSSStyleSheet(StyleRuleImport* ownerRule, const String& originalURL, const KURL& finalURL, const String& charset);
+    unsigned ruleCount() const;
+    
+    bool wrapperInsertRule(PassRefPtr<StyleRuleBase>, unsigned index);
+    void wrapperDeleteRule(unsigned index);
 
-    virtual bool isCSSStyleSheet() const { return true; }
-    virtual String type() const { return "text/css"; }
+    PassRefPtr<CSSRule> createChildRuleCSSOMWrapper(unsigned index, CSSStyleSheet* parentWrapper);
+
+private:
+    StyleSheetInternal(Node* ownerNode, const String& originalURL, const KURL& finalURL, const String& charset);
+    StyleSheetInternal(StyleRuleImport* ownerRule, const String& originalURL, const KURL& finalURL, const String& charset);
     
     void clearCharsetRule();
     bool hasCharsetRule() const { return !m_encodingFromCharsetRule.isNull(); }
 
-    PassRefPtr<CSSRule> createChildRuleCSSOMWrapper(unsigned index);
-
+    Node* m_ownerNode;
     StyleRuleImport* m_ownerRule;
+
+    String m_originalURL;
+    KURL m_finalURL;
+    String m_title;
+
     String m_encodingFromCharsetRule;
     Vector<RefPtr<StyleRuleImport> > m_importRules;
     Vector<RefPtr<StyleRuleBase> > m_childRules;
@@ -159,7 +163,62 @@ private:
     bool m_isUserStyleSheet : 1;
     bool m_hasSyntacticallyValidCSSHeader : 1;
     bool m_didLoadErrorOccur : 1;
+};
+
+class CSSStyleSheet : public StyleSheet {
+public:
+    static RefPtr<CSSStyleSheet> create(PassRefPtr<StyleSheetInternal> sheet, CSSImportRule* ownerRule = 0) 
+    { 
+        return adoptRef(new CSSStyleSheet(sheet, ownerRule));
+    }
+
+    virtual ~CSSStyleSheet();
+
+    virtual CSSStyleSheet* parentStyleSheet() const OVERRIDE;
+    virtual Node* ownerNode() const OVERRIDE { return m_internal->ownerNode(); }
+    virtual MediaList* media() const OVERRIDE;
+    virtual String href() const OVERRIDE { return m_internal->originalURL(); }  
+    virtual String title() const OVERRIDE { return m_internal->title(); }
+    virtual bool disabled() const OVERRIDE { return m_isDisabled; }
+    virtual void setDisabled(bool) OVERRIDE;
+    
+    PassRefPtr<CSSRuleList> cssRules();
+    unsigned insertRule(const String& rule, unsigned index, ExceptionCode&);
+    void deleteRule(unsigned index, ExceptionCode&);
+    
+    // IE Extensions
+    PassRefPtr<CSSRuleList> rules();
+    int addRule(const String& selector, const String& style, int index, ExceptionCode&);
+    int addRule(const String& selector, const String& style, ExceptionCode&);
+    void removeRule(unsigned index, ExceptionCode& ec) { deleteRule(index, ec); }
+    
+    // For CSSRuleList.
+    unsigned length() const;
+    CSSRule* item(unsigned index);
+
+    virtual void clearOwnerNode() OVERRIDE { m_internal->clearOwnerNode(); }
+    virtual CSSImportRule* ownerRule() const OVERRIDE { return m_ownerRule; }
+    virtual KURL baseURL() const OVERRIDE { return m_internal->baseURL(); }
+    virtual bool isLoading() const OVERRIDE { return m_internal->isLoading(); }
+    
+    void clearOwnerRule() { m_ownerRule = 0; }
+    void styleSheetChanged() { m_internal->styleSheetChanged(); }
+    Document* findDocument() { return m_internal->findDocument(); }
+    
+    void clearChildRuleCSSOMWrappers();
+
+    StyleSheetInternal* internal() const { return m_internal.get(); }
+
+private:
+    CSSStyleSheet(PassRefPtr<StyleSheetInternal>, CSSImportRule* ownerRule);
+
+    virtual bool isCSSStyleSheet() const { return true; }
+    virtual String type() const { return "text/css"; }
+    
+    RefPtr<StyleSheetInternal> m_internal;
+    bool m_isDisabled;
 
+    CSSImportRule* m_ownerRule;
     mutable Vector<RefPtr<CSSRule> > m_childRuleCSSOMWrappers;
     mutable OwnPtr<CSSRuleList> m_ruleListCSSOMWrapper;
 };
index 602416a..652183c 100644 (file)
@@ -99,7 +99,7 @@ CSSValue::Type CSSValue::cssValueType() const
     return CSS_CUSTOM;
 }
 
-void CSSValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const CSSStyleSheet* styleSheet)
+void CSSValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
 {
     // This should get called for internal instances only.
     ASSERT(!isCSSOMSafe());
index 6491131..8207c51 100644 (file)
@@ -29,7 +29,7 @@
 
 namespace WebCore {
 
-class CSSStyleSheet;
+class StyleSheetInternal;
     
 // FIXME: The current CSSValue and subclasses should be turned into internal types (StyleValue).
 // The few subtypes that are actually exposed in CSSOM can be seen in the cloneForCSSOM() function.
@@ -107,7 +107,7 @@ public:
 
     PassRefPtr<CSSValue> cloneForCSSOM() const;
 
-    void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
+    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
 
 protected:
 
index 3b3e6cf..6377391 100644 (file)
@@ -136,7 +136,7 @@ String CSSValueList::customCssText() const
     return result.toString();
 }
 
-void CSSValueList::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const CSSStyleSheet* styleSheet)
+void CSSValueList::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
 {
     size_t size = m_values.size();
     for (size_t i = 0; i < size; ++i)
index 8a6bbb9..3d23a60 100644 (file)
@@ -60,7 +60,7 @@ public:
 
     String customCssText() const;
 
-    void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
+    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
     
     PassRefPtr<CSSValueList> cloneForCSSOM() const;
 
index 6b4e92d..8762bb4 100644 (file)
@@ -133,7 +133,7 @@ PassRefPtr<CSSPrimitiveValue> CSSValuePool::createFontFamilyValue(const String&
     return value;
 }
 
-PassRefPtr<CSSValueList> CSSValuePool::createFontFaceValue(const AtomicString& string, CSSStyleSheet* contextStyleSheet)
+PassRefPtr<CSSValueList> CSSValuePool::createFontFaceValue(const AtomicString& string, StyleSheetInternal* contextStyleSheet)
 {
     // Just wipe out the cache and start rebuilding if it gets too big.
     const int maximumFontFaceCacheSize = 128;
index 577009d..d95358f 100644 (file)
 namespace WebCore {
 
 class CSSValueList;
+class StyleSheetInternal;
 
 class CSSValuePool {
 public:
-    PassRefPtr<CSSValueList> createFontFaceValue(const AtomicString&, CSSStyleSheet* contextStyleSheet);
+    PassRefPtr<CSSValueList> createFontFaceValue(const AtomicString&, StyleSheetInternal* contextStyleSheet);
     PassRefPtr<CSSPrimitiveValue> createFontFamilyValue(const String&);
     PassRefPtr<CSSInheritedValue> createInheritedValue() { return m_inheritedValue; }
     PassRefPtr<CSSInitialValue> createImplicitInitialValue() { return m_implicitInitialValue; }
index b01da68..53d474c 100644 (file)
@@ -292,9 +292,10 @@ CSSValue* PropertySetCSSStyleDeclaration::cloneAndCacheForCSSOM(CSSValue* intern
     return clonedValue.get();
 }
 
-CSSStyleSheet* PropertySetCSSStyleDeclaration::parentStyleSheet() const
+StyleSheetInternal* PropertySetCSSStyleDeclaration::contextStyleSheet() const
 { 
-    return contextStyleSheet(); 
+    CSSStyleSheet* cssStyleSheet = parentStyleSheet();
+    return cssStyleSheet ? cssStyleSheet->internal() : 0;
 }
 
 PassRefPtr<StylePropertySet> PropertySetCSSStyleDeclaration::copy() const
@@ -339,13 +340,13 @@ void StyleRuleCSSStyleDeclaration::deref()
 
 void StyleRuleCSSStyleDeclaration::setNeedsStyleRecalc()
 {
-    if (CSSStyleSheet* styleSheet = contextStyleSheet()) {
+    if (CSSStyleSheet* styleSheet = parentStyleSheet()) {
         if (Document* document = styleSheet->findDocument())
             document->styleSelectorChanged(DeferRecalcStyle);
     }
 }
-    
-CSSStyleSheet* StyleRuleCSSStyleDeclaration::contextStyleSheet() const
+
+CSSStyleSheet* StyleRuleCSSStyleDeclaration::parentStyleSheet() const
 {
     return m_parentRule ? m_parentRule->parentStyleSheet() : 0;
 }
@@ -360,7 +361,7 @@ void InlineCSSStyleDeclaration::setNeedsStyleRecalc()
     return;
 }
 
-CSSStyleSheet* InlineCSSStyleDeclaration::contextStyleSheet() const
+CSSStyleSheet* InlineCSSStyleDeclaration::parentStyleSheet() const
 {
     return m_parentElement ? m_parentElement->document()->elementSheet() : 0;
 }
index 649bd76..2b8f412 100644 (file)
@@ -32,9 +32,9 @@ namespace WebCore {
 
 class CSSRule;
 class CSSProperty;
-class CSSStyleSheet;
 class CSSValue;
 class StylePropertySet;
+class StyleSheetInternal;
 class StyledElement;
 
 class PropertySetCSSStyleDeclaration : public CSSStyleDeclaration {
@@ -43,7 +43,7 @@ public:
     
     virtual StyledElement* parentElement() const { return 0; }
     virtual void clearParentElement() { ASSERT_NOT_REACHED(); }
-    virtual CSSStyleSheet* contextStyleSheet() const { return 0; }
+    StyleSheetInternal* contextStyleSheet() const;
     
     virtual void ref() OVERRIDE;
     virtual void deref() OVERRIDE;
@@ -66,7 +66,6 @@ private:
     virtual void setPropertyInternal(CSSPropertyID, const String& value, bool important, ExceptionCode&) OVERRIDE;
     
     virtual bool cssPropertyMatches(const CSSProperty*) const OVERRIDE;
-    virtual CSSStyleSheet* parentStyleSheet() const OVERRIDE;
     virtual PassRefPtr<StylePropertySet> copy() const OVERRIDE;
     virtual PassRefPtr<StylePropertySet> makeMutable() OVERRIDE;
     virtual void setNeedsStyleRecalc() { }
@@ -96,9 +95,10 @@ private:
     StyleRuleCSSStyleDeclaration(StylePropertySet*, CSSRule*);
     virtual ~StyleRuleCSSStyleDeclaration();
 
+    virtual CSSStyleSheet* parentStyleSheet() const OVERRIDE;
+
     virtual CSSRule* parentRule() const OVERRIDE { return m_parentRule;  }
     virtual void setNeedsStyleRecalc() OVERRIDE;
-    virtual CSSStyleSheet* contextStyleSheet() const OVERRIDE;
     
     unsigned m_refCount;
     CSSRule* m_parentRule;
@@ -114,10 +114,10 @@ public:
     }
     
 private:
+    virtual CSSStyleSheet* parentStyleSheet() const OVERRIDE;
     virtual StyledElement* parentElement() const OVERRIDE { return m_parentElement; }
     virtual void clearParentElement() OVERRIDE { m_parentElement = 0; }
     virtual void setNeedsStyleRecalc() OVERRIDE;
-    virtual CSSStyleSheet* contextStyleSheet() const OVERRIDE;
     
     StyledElement* m_parentElement;
 };
index 58e4aec..6027a6e 100644 (file)
@@ -484,7 +484,7 @@ bool StylePropertySet::isPropertyImplicit(CSSPropertyID propertyID) const
     return property ? property->isImplicit() : false;
 }
 
-bool StylePropertySet::setProperty(CSSPropertyID propertyID, const String& value, bool important, CSSStyleSheet* contextStyleSheet)
+bool StylePropertySet::setProperty(CSSPropertyID propertyID, const String& value, bool important, StyleSheetInternal* contextStyleSheet)
 {
     // Setting the value to an empty string just removes the property in both IE and Gecko.
     // Setting it to null seems to produce less consistent results, but we treat it just the same.
@@ -531,7 +531,7 @@ bool StylePropertySet::setProperty(CSSPropertyID propertyID, int identifier, boo
     return true;
 }
 
-void StylePropertySet::parseDeclaration(const String& styleDeclaration, CSSStyleSheet* contextStyleSheet)
+void StylePropertySet::parseDeclaration(const String& styleDeclaration, StyleSheetInternal* contextStyleSheet)
 {
     m_properties.clear();
     CSSParser parser(cssParserMode());
@@ -793,7 +793,7 @@ void StylePropertySet::merge(const StylePropertySet* other, bool argOverridesOnC
     }
 }
 
-void StylePropertySet::addSubresourceStyleURLs(ListHashSet<KURL>& urls, CSSStyleSheet* contextStyleSheet)
+void StylePropertySet::addSubresourceStyleURLs(ListHashSet<KURL>& urls, StyleSheetInternal* contextStyleSheet)
 {
     size_t size = m_properties.size();
     for (size_t i = 0; i < size; ++i)
index 7e46ced..d47ac52 100644 (file)
@@ -37,6 +37,7 @@ class KURL;
 class PropertySetCSSStyleDeclaration;
 class StyledElement;
 class StylePropertyShorthand;
+class StyleSheetInternal;
 
 class StylePropertySet : public RefCounted<StylePropertySet> {
 public:
@@ -68,7 +69,7 @@ public:
     bool isPropertyImplicit(CSSPropertyID) const;
 
     // These expand shorthand properties into multiple properties.
-    bool setProperty(CSSPropertyID, const String& value, bool important = false, CSSStyleSheet* contextStyleSheet = 0);
+    bool setProperty(CSSPropertyID, const String& value, bool important = false, StyleSheetInternal* contextStyleSheet = 0);
     void setProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important = false);
 
     // These do not. FIXME: This is too messy, we can do better.
@@ -77,7 +78,7 @@ public:
     
     bool removeProperty(CSSPropertyID, String* returnText = 0);
 
-    void parseDeclaration(const String& styleDeclaration, CSSStyleSheet* contextStyleSheet);
+    void parseDeclaration(const String& styleDeclaration, StyleSheetInternal* contextStyleSheet);
 
     void addParsedProperties(const CSSProperty*, int numProperties);
     void addParsedProperty(const CSSProperty&);
@@ -91,7 +92,7 @@ public:
     void setCSSParserMode(CSSParserMode cssParserMode) { m_cssParserMode = cssParserMode; }
     CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); }
 
-    void addSubresourceStyleURLs(ListHashSet<KURL>&, CSSStyleSheet* contextStyleSheet);
+    void addSubresourceStyleURLs(ListHashSet<KURL>&, StyleSheetInternal* contextStyleSheet);
 
     PassRefPtr<StylePropertySet> copy() const;
     // Used by StyledElement::copyNonAttributeProperties().
index 6b65413..20ff566 100644 (file)
 #include "config.h"
 #include "StyleSheet.h"
 
-#include "CSSImportRule.h"
-#include "CSSStyleSheet.h"
-#include "Document.h"
-#include "Node.h"
-
 namespace WebCore {
 
-StyleSheet::StyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL)
-    : m_disabled(false)
-    , m_ownerNode(parentNode)
-    , m_originalURL(originalURL)
-    , m_finalURL(finalURL)
-{
-}
-
-StyleSheet::StyleSheet(const String& originalURL, const KURL& finalURL)
-    : m_disabled(false)
-    , m_ownerNode(0)
-    , m_originalURL(originalURL)
-    , m_finalURL(finalURL)
-{
-}
-
 StyleSheet::~StyleSheet()
 {
 }
 
-KURL StyleSheet::baseURL() const
-{
-    if (!m_finalURL.isNull())
-        return m_finalURL;
-    if (StyleSheet* parentSheet = parentStyleSheet())
-        return parentSheet->baseURL();
-    if (!m_ownerNode)
-        return KURL();
-    return m_ownerNode->document()->baseURL();
-}
-
-void StyleSheet::setDisabled(bool disabled)
-{
-     m_disabled = disabled;
-     if (isCSSStyleSheet())
-         static_cast<CSSStyleSheet*>(this)->styleSheetChanged();
-}
-
 }
index e715c38..7b41375 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2008, 2012 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -39,48 +39,21 @@ class StyleSheet : public RefCounted<StyleSheet> {
 public:
     virtual ~StyleSheet();
 
-    bool disabled() const { return m_disabled; }
-    void setDisabled(bool);
-
-    Node* ownerNode() const { return m_ownerNode; }
-    void clearOwnerNode() { m_ownerNode = 0; }
-
-    virtual CSSImportRule* ownerRule() const { return 0; }
-
+    virtual bool disabled() const = 0;
+    virtual void setDisabled(bool) = 0;
+    virtual Node* ownerNode() const = 0;
     virtual StyleSheet* parentStyleSheet() const { return 0; }
-
-    // Note that href is the URL that started the redirect chain that led to
-    // this style sheet. This property probably isn't useful for much except
-    // the JavaScript binding (which needs to use this value for security).
-    const String& href() const { return m_originalURL; }
-
-    void setFinalURL(const KURL& finalURL) { m_finalURL = finalURL; }
-    const KURL& finalURL() const { return m_finalURL; }
-
-    const String& title() const { return m_strTitle; }
-    void setTitle(const String& s) { m_strTitle = s; }
+    virtual String href() const = 0;
+    virtual String title() const = 0;
     virtual MediaList* media() const { return 0; }
-
     virtual String type() const = 0;
-    virtual bool isLoading() = 0;
-
-    virtual bool parseString(const String&, CSSParserMode = CSSStrictMode) = 0;
 
+    virtual CSSImportRule* ownerRule() const { return 0; }
+    virtual void clearOwnerNode() = 0;
+    virtual KURL baseURL() const = 0;
+    virtual bool isLoading() const = 0;
     virtual bool isCSSStyleSheet() const { return false; }
     virtual bool isXSLStyleSheet() const { return false; }
-
-    KURL baseURL() const;
-
-protected:
-    StyleSheet(Node* ownerNode, const String& href, const KURL& finalURL);
-    StyleSheet(const String& href, const KURL& finalURL);
-
-private:
-    bool m_disabled;
-    Node* m_ownerNode;
-    String m_originalURL;
-    KURL m_finalURL;
-    String m_strTitle;
 };
 
 } // namespace
index ad766f7..228097c 100644 (file)
@@ -109,8 +109,9 @@ void WebKitCSSKeyframesRule::insertRule(const String& ruleText)
 {
     ASSERT(m_childRuleCSSOMWrappers.size() == m_keyframesRule->keyframes().size());
 
-    CSSParser p(cssParserMode());
-    RefPtr<StyleKeyframe> keyframe = p.parseKeyframeRule(parentStyleSheet(), ruleText);
+    CSSStyleSheet* styleSheet = parentStyleSheet();
+    CSSParser parser(styleSheet ? styleSheet->internal()->cssParserMode() : CSSStrictMode);
+    RefPtr<StyleKeyframe> keyframe = parser.parseKeyframeRule(styleSheet ? styleSheet->internal() : 0, ruleText);
     if (!keyframe)
         return;
 
index 9b12010..b5bdb4d 100644 (file)
@@ -307,9 +307,9 @@ PassRefPtr<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&,
 {
     // FIXME: Title should be set.
     // FIXME: Media could have wrong syntax, in which case we should generate an exception.
-    RefPtr<CSSStyleSheet> sheet = CSSStyleSheet::create();
+    RefPtr<StyleSheetInternal> sheet = StyleSheetInternal::create();
     sheet->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(media));
-    return sheet.release();
+    return CSSStyleSheet::create(sheet);
 }
 
 static const char* const validXMLMIMETypeChars = "[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]"; // per RFCs: 3023, 2045
index bbe9443..aee04e0 100644 (file)
@@ -3,7 +3,7 @@
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
  *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved.
  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved.
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
@@ -2557,7 +2557,7 @@ void Document::updateBaseURL()
         m_baseURL = KURL();
 
     if (m_elemSheet)
-        m_elemSheet->setFinalURL(m_baseURL);
+        m_elemSheet->internal()->setFinalURL(m_baseURL);
     
     if (!equalIgnoringFragmentIdentifier(oldBaseURL, m_baseURL)) {
         // Base URL change changes any relative visited links.
@@ -2688,7 +2688,7 @@ bool Document::canBeAccessedByEveryAncestorFrame()
     return true;
 }
 
-CSSStyleSheet* Document::pageUserSheet()
+StyleSheetInternal* Document::pageUserSheet()
 {
     if (m_pageUserSheet)
         return m_pageUserSheet.get();
@@ -2702,7 +2702,7 @@ CSSStyleSheet* Document::pageUserSheet()
         return 0;
     
     // Parse the sheet and cache it.
-    m_pageUserSheet = CSSStyleSheet::createInline(this, settings()->userStyleSheetLocation());
+    m_pageUserSheet = StyleSheetInternal::createInline(this, settings()->userStyleSheetLocation());
     m_pageUserSheet->setIsUserStyleSheet(true);
     m_pageUserSheet->parseString(userSheetText, strictToCSSParserMode(!inQuirksMode()));
     return m_pageUserSheet.get();
@@ -2723,7 +2723,7 @@ void Document::updatePageUserSheet()
         styleSelectorChanged(RecalcStyleImmediately);
 }
 
-const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const
+const Vector<RefPtr<StyleSheetInternal> >* Document::pageGroupUserSheets() const
 {
     if (m_pageGroupUserSheetCacheValid)
         return m_pageGroupUserSheets.get();
@@ -2748,11 +2748,11 @@ const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const
                 continue;
             if (!UserContentURLPattern::matchesPatterns(url(), sheet->whitelist(), sheet->blacklist()))
                 continue;
-            RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::createInline(const_cast<Document*>(this), sheet->url());
+            RefPtr<StyleSheetInternal> parsedSheet = StyleSheetInternal::createInline(const_cast<Document*>(this), sheet->url());
             parsedSheet->setIsUserStyleSheet(sheet->level() == UserStyleUserLevel);
             parsedSheet->parseString(sheet->source(), strictToCSSParserMode(!inQuirksMode()));
             if (!m_pageGroupUserSheets)
-                m_pageGroupUserSheets = adoptPtr(new Vector<RefPtr<CSSStyleSheet> >);
+                m_pageGroupUserSheets = adoptPtr(new Vector<RefPtr<StyleSheetInternal> >);
             m_pageGroupUserSheets->append(parsedSheet.release());
         }
     }
@@ -2776,10 +2776,10 @@ void Document::updatePageGroupUserSheets()
         styleSelectorChanged(RecalcStyleImmediately);
 }
 
-void Document::addUserSheet(PassRefPtr<CSSStyleSheet> userSheet)
+void Document::addUserSheet(PassRefPtr<StyleSheetInternal> userSheet)
 {
     if (!m_userSheets)
-        m_userSheets = adoptPtr(new Vector<RefPtr<CSSStyleSheet> >);
+        m_userSheets = adoptPtr(new Vector<RefPtr<StyleSheetInternal> >);
     m_userSheets->append(userSheet);
     styleSelectorChanged(RecalcStyleImmediately);
 }
@@ -2787,7 +2787,7 @@ void Document::addUserSheet(PassRefPtr<CSSStyleSheet> userSheet)
 CSSStyleSheet* Document::elementSheet()
 {
     if (!m_elemSheet)
-        m_elemSheet = CSSStyleSheet::createInline(this, m_baseURL);
+        m_elemSheet = CSSStyleSheet::create(StyleSheetInternal::createInline(this, m_baseURL));
     return m_elemSheet.get();
 }
 
@@ -3316,10 +3316,8 @@ void Document::collectActiveStylesheets(Vector<RefPtr<StyleSheet> >& sheets)
     }
 }
 
-bool Document::testAddedStylesheetRequiresStyleRecalc(CSSStyleSheet* stylesheet)
+bool Document::testAddedStylesheetRequiresStyleRecalc(StyleSheetInternal* stylesheet)
 {
-    if (stylesheet->disabled())
-        return false;
     // See if all rules on the sheet are scoped to some specific ids or classes.
     // Then test if we actually have any of those in the tree at the moment.
     // FIXME: Even we if we find some, we could just invalidate those subtrees instead of invalidating the entire style.
@@ -3391,7 +3389,9 @@ void Document::analyzeStylesheetChange(StyleSelectorUpdateFlag updateFlag, const
     for (unsigned i = oldStylesheetCount; i < newStylesheetCount; ++i) {
         if (!newStylesheets[i]->isCSSStyleSheet())
             return;
-        if (testAddedStylesheetRequiresStyleRecalc(static_cast<CSSStyleSheet*>(newStylesheets[i].get())))
+        if (newStylesheets[i]->disabled())
+            continue;
+        if (testAddedStylesheetRequiresStyleRecalc(static_cast<CSSStyleSheet*>(newStylesheets[i].get())->internal()))
             return;
     }
     requiresFullStyleRecalc = false;
index d66241b..2352b74 100644 (file)
@@ -3,7 +3,7 @@
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
  *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
  * Copyright (C) 2011 Google Inc. All rights reserved.
@@ -127,6 +127,7 @@ class SerializedScriptValue;
 class SegmentedString;
 class Settings;
 class StyleSheet;
+class StyleSheetInternal;
 class StyleSheetList;
 class Text;
 class TextResourceDecoder;
@@ -623,16 +624,16 @@ public:
     bool canNavigate(Frame* targetFrame);
     bool canBeAccessedByEveryAncestorFrame();
 
-    CSSStyleSheet* pageUserSheet();
+    StyleSheetInternal* pageUserSheet();
     void clearPageUserSheet();
     void updatePageUserSheet();
 
-    const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets() const;
+    const Vector<RefPtr<StyleSheetInternal> >* pageGroupUserSheets() const;
     void clearPageGroupUserSheets();
     void updatePageGroupUserSheets();
 
-    const Vector<RefPtr<CSSStyleSheet> >* documentUserSheets() const { return m_userSheets.get(); }
-    void addUserSheet(PassRefPtr<CSSStyleSheet> userSheet);
+    const Vector<RefPtr<StyleSheetInternal> >* documentUserSheets() const { return m_userSheets.get(); }
+    void addUserSheet(PassRefPtr<StyleSheetInternal> userSheet);
 
     CSSStyleSheet* elementSheet();
     
@@ -1181,7 +1182,7 @@ private:
     
     bool updateActiveStylesheets(StyleSelectorUpdateFlag);
     void collectActiveStylesheets(Vector<RefPtr<StyleSheet> >&);
-    bool testAddedStylesheetRequiresStyleRecalc(CSSStyleSheet*);
+    bool testAddedStylesheetRequiresStyleRecalc(StyleSheetInternal*);
     void analyzeStylesheetChange(StyleSelectorUpdateFlag, const Vector<RefPtr<StyleSheet> >& newStylesheets, bool& requiresStyleSelectorReset, bool& requiresFullStyleRecalc);
 
     void deleteCustomFonts();
@@ -1257,9 +1258,9 @@ private:
     bool m_hasNodesWithPlaceholderStyle;
 
     RefPtr<CSSStyleSheet> m_elemSheet;
-    RefPtr<CSSStyleSheet> m_pageUserSheet;
-    mutable OwnPtr<Vector<RefPtr<CSSStyleSheet> > > m_pageGroupUserSheets;
-    OwnPtr<Vector<RefPtr<CSSStyleSheet> > > m_userSheets;
+    RefPtr<StyleSheetInternal> m_pageUserSheet;
+    mutable OwnPtr<Vector<RefPtr<StyleSheetInternal> > > m_pageGroupUserSheets;
+    OwnPtr<Vector<RefPtr<StyleSheetInternal> > > m_userSheets;
     mutable bool m_pageGroupUserSheetCacheValid;
 
     bool m_printing;
index d732b6e..e3b3866 100644 (file)
@@ -3,7 +3,7 @@
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Peter Kelly (pmk@post.com)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010, 2012 Apple Inc. All rights reserved.
  * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
  *
  * This library is free software; you can redistribute it and/or
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "ElementAttributeData.h"
 
+#include "CSSStyleSheet.h"
 #include "StyledElement.h"
 
 namespace WebCore {
@@ -82,7 +83,7 @@ void ElementAttributeData::updateInlineStyleAvoidingMutation(StyledElement* elem
         m_inlineStyleDecl = StylePropertySet::create();
         m_inlineStyleDecl->setCSSParserMode(strictToCSSParserMode(element->isHTMLElement() && !element->document()->inQuirksMode()));
     }
-    m_inlineStyleDecl->parseDeclaration(text, element->document()->elementSheet());
+    m_inlineStyleDecl->parseDeclaration(text, element->document()->elementSheet()->internal());
 }
 
 void ElementAttributeData::destroyInlineStyle(StyledElement* element)
index 018004b..123aecc 100644 (file)
@@ -211,15 +211,16 @@ void ProcessingInstruction::setCSSStyleSheet(const String& href, const KURL& bas
     }
 
     ASSERT(m_isCSS);
-    RefPtr<CSSStyleSheet> newSheet = CSSStyleSheet::create(this, href, baseURL, charset);
-    m_sheet = newSheet;
+    RefPtr<StyleSheetInternal> newSheet = StyleSheetInternal::create(this, href, baseURL, charset);
+    m_sheet = CSSStyleSheet::create(newSheet);
     // We don't need the cross-origin security check here because we are
     // getting the sheet text in "strict" mode. This enforces a valid CSS MIME
     // type.
-    parseStyleSheet(sheet->sheetText(true));
     newSheet->setTitle(m_title);
     newSheet->setMediaQueries(MediaQuerySet::create(m_media));
-    newSheet->setDisabled(m_alternate);
+    m_sheet->setDisabled(m_alternate);
+
+    parseStyleSheet(sheet->sheetText(true));
 }
 
 #if ENABLE(XSLT)
@@ -233,7 +234,11 @@ void ProcessingInstruction::setXSLStyleSheet(const String& href, const KURL& bas
 
 void ProcessingInstruction::parseStyleSheet(const String& sheet)
 {
-    m_sheet->parseString(sheet, CSSStrictMode);
+    if (m_isCSS)
+        static_cast<CSSStyleSheet*>(m_sheet.get())->internal()->parseString(sheet, CSSStrictMode);
+    else if (m_isXSL)
+        static_cast<XSLStyleSheet*>(m_sheet.get())->parseString(sheet);
+
     if (m_cachedSheet)
         m_cachedSheet->removeClient(this);
     m_cachedSheet = 0;
@@ -241,7 +246,7 @@ void ProcessingInstruction::parseStyleSheet(const String& sheet)
     m_loading = false;
 
     if (m_isCSS)
-        static_cast<CSSStyleSheet*>(m_sheet.get())->checkLoaded();
+        static_cast<CSSStyleSheet*>(m_sheet.get())->internal()->checkLoaded();
 #if ENABLE(XSLT)
     else if (m_isXSL)
         static_cast<XSLStyleSheet*>(m_sheet.get())->checkLoaded();
@@ -253,8 +258,8 @@ void ProcessingInstruction::setCSSStyleSheet(PassRefPtr<CSSStyleSheet> sheet)
     ASSERT(!m_cachedSheet);
     ASSERT(!m_loading);
     m_sheet = sheet;
-    m_sheet->setTitle(m_title);
-    m_sheet->setDisabled(m_alternate);
+    sheet->internal()->setTitle(m_title);
+    sheet->setDisabled(m_alternate);
 }
 
 bool ProcessingInstruction::offsetInCharacters() const
index 11a6236..aeea51f 100644 (file)
@@ -168,16 +168,17 @@ void StyleElement::createSheet(Element* e, int startLineNumber, const String& te
         if (screenEval.eval(mediaQueries.get()) || printEval.eval(mediaQueries.get())) {
             document->addPendingSheet();
             m_loading = true;
-            m_sheet = CSSStyleSheet::create(e, String(), KURL(), document->inputEncoding());
-            m_sheet->parseStringAtLine(text, strictToCSSParserMode(!document->inQuirksMode()), startLineNumber);
-            m_sheet->setMediaQueries(mediaQueries.release());
-            m_sheet->setTitle(e->title());
+            RefPtr<StyleSheetInternal> styleSheet = StyleSheetInternal::create(e, String(), KURL(), document->inputEncoding());
+            styleSheet->parseStringAtLine(text, strictToCSSParserMode(!document->inQuirksMode()), startLineNumber);
+            styleSheet->setMediaQueries(mediaQueries.release());
+            styleSheet->setTitle(e->title());
+            m_sheet = CSSStyleSheet::create(styleSheet);
             m_loading = false;
         }
     }
 
     if (m_sheet)
-        m_sheet->checkLoaded();
+        m_sheet->internal()->checkLoaded();
 }
 
 bool StyleElement::isLoading() const
index 8de69f4..67692af 100644 (file)
@@ -206,7 +206,7 @@ bool StyledElement::setInlineStyleProperty(CSSPropertyID propertyID, double valu
 
 bool StyledElement::setInlineStyleProperty(CSSPropertyID propertyID, const String& value, bool important)
 {
-    bool changes = ensureAttributeData()->ensureMutableInlineStyle(this)->setProperty(propertyID, value, important, document()->elementSheet());
+    bool changes = ensureAttributeData()->ensureMutableInlineStyle(this)->setProperty(propertyID, value, important, document()->elementSheet()->internal());
     if (changes)
         inlineStyleChanged();
     return changes;
@@ -226,7 +226,7 @@ bool StyledElement::removeInlineStyleProperty(CSSPropertyID propertyID)
 void StyledElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
 {
     if (StylePropertySet* inlineStyle = attributeData() ? attributeData()->inlineStyle() : 0)
-        inlineStyle->addSubresourceStyleURLs(urls, document()->elementSheet());
+        inlineStyle->addSubresourceStyleURLs(urls, document()->elementSheet()->internal());
 }
 
 static inline bool attributeNameSort(const pair<AtomicStringImpl*, AtomicString>& p1, const pair<AtomicStringImpl*, AtomicString>& p2)
@@ -333,5 +333,10 @@ void StyledElement::addPropertyToAttributeStyle(StylePropertySet* style, CSSProp
 {
     style->setProperty(propertyID, cssValuePool().createValue(value, unit));
 }
+    
+void StyledElement::addPropertyToAttributeStyle(StylePropertySet* style, CSSPropertyID propertyID, const String& value)
+{
+    style->setProperty(propertyID, value, false, document()->elementSheet()->internal());
+}
 
 }
index 82083be..1cf2987 100644 (file)
@@ -113,11 +113,6 @@ inline StylePropertySet* StyledElement::attributeStyle()
     return attributeData() ? attributeData()->attributeStyle() : 0;
 }
 
-inline void StyledElement::addPropertyToAttributeStyle(StylePropertySet* style, CSSPropertyID propertyID, const String& value)
-{
-    style->setProperty(propertyID, value, false, document()->elementSheet());
-}
-
 } //namespace
 
 #endif
index 38a591f..fed8bb6 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "Attribute.h"
 #include "CSSPropertyNames.h"
+#include "CSSStyleSheet.h"
 #include "CSSValueKeywords.h"
 #include "CSSValueList.h"
 #include "CSSValuePool.h"
@@ -176,7 +177,7 @@ void HTMLFontElement::collectStyleForAttribute(Attribute* attr, StylePropertySet
     } else if (attr->name() == colorAttr)
         addHTMLColorToStyle(style, CSSPropertyColor, attr->value());
     else if (attr->name() == faceAttr) {
-        if (RefPtr<CSSValueList> fontFaceValue = cssValuePool().createFontFaceValue(attr->value(), document()->elementSheet()))
+        if (RefPtr<CSSValueList> fontFaceValue = cssValuePool().createFontFaceValue(attr->value(), document()->elementSheet()->internal()))
             style->setProperty(CSSProperty(CSSPropertyFontFamily, fontFaceValue.release()));
     } else
         HTMLElement::collectStyleForAttribute(attr, style);
index 0db57b9..683fcf8 100644 (file)
@@ -155,7 +155,7 @@ void HTMLLinkElement::parseAttribute(Attribute* attr)
         setAttributeEventListener(eventNames().errorEvent, createAttributeEventListener(this, attr));
     else {
         if (attr->name() == titleAttr && m_sheet)
-            m_sheet->setTitle(attr->value());
+            m_sheet->internal()->setTitle(attr->value());
         HTMLElement::parseAttribute(attr);
     }
 }
@@ -289,7 +289,7 @@ void HTMLLinkElement::setCSSStyleSheet(const String& href, const KURL& baseURL,
         return;
     }
 
-    m_sheet = CSSStyleSheet::create(this, href, baseURL, charset);
+    RefPtr<StyleSheetInternal> styleSheet = StyleSheetInternal::create(this, href, baseURL, charset);
 
     bool strictParsing = !document()->inQuirksMode();
     bool enforceMIMEType = strictParsing;
@@ -311,7 +311,7 @@ void HTMLLinkElement::setCSSStyleSheet(const String& href, const KURL& baseURL,
 #endif
 
     String sheetText = sheet->sheetText(enforceMIMEType, &validMIMEType);
-    m_sheet->parseString(sheetText, strictToCSSParserMode(strictParsing));
+    styleSheet->parseString(sheetText, strictToCSSParserMode(strictParsing));
 
     // If we're loading a stylesheet cross-origin, and the MIME type is not
     // standard, require the CSS to at least start with a syntactically
@@ -321,8 +321,8 @@ void HTMLLinkElement::setCSSStyleSheet(const String& href, const KURL& baseURL,
     if (!document()->securityOrigin()->canRequest(baseURL))
         crossOriginCSS = true;
 
-    if (crossOriginCSS && !validMIMEType && !m_sheet->hasSyntacticallyValidCSSHeader())
-        m_sheet = CSSStyleSheet::create(this, href, baseURL, charset);
+    if (crossOriginCSS && !validMIMEType && !styleSheet->hasSyntacticallyValidCSSHeader())
+        styleSheet = StyleSheetInternal::create(this, href, baseURL, charset);
 
     if (strictParsing && needsSiteSpecificQuirks) {
         // Work around <https://bugs.webkit.org/show_bug.cgi?id=28350>.
@@ -332,20 +332,20 @@ void HTMLLinkElement::setCSSStyleSheet(const String& href, const KURL& baseURL,
         // while the other lacks the second trailing newline.
         if (baseURL.string().endsWith(slashKHTMLFixesDotCss) && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText)
                 && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1) {
-            ASSERT(m_sheet->length() == 1);
-            ExceptionCode ec;
-            m_sheet->deleteRule(0, ec);
+            ASSERT(styleSheet->ruleCount() == 1);
+            styleSheet->clearRules();
         }
     }
+    m_sheet = CSSStyleSheet::create(styleSheet);
 
-    m_sheet->setTitle(title());
+    styleSheet->setTitle(title());
 
     RefPtr<MediaQuerySet> media = MediaQuerySet::createAllowingDescriptionSyntax(m_media);
-    m_sheet->setMediaQueries(media.release());
+    styleSheet->setMediaQueries(media.release());
 
     m_loading = false;
-    m_sheet->notifyLoadedSheet(sheet);
-    m_sheet->checkLoaded();
+    styleSheet->notifyLoadedSheet(sheet);
+    styleSheet->checkLoaded();
 }
 
 bool HTMLLinkElement::styleSheetIsLoading() const
@@ -354,7 +354,7 @@ bool HTMLLinkElement::styleSheetIsLoading() const
         return true;
     if (!m_sheet)
         return false;
-    return m_sheet->isLoading();
+    return m_sheet->internal()->isLoading();
 }
 
 void HTMLLinkElement::linkLoaded()
@@ -447,7 +447,7 @@ void HTMLLinkElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
     
     // Walk the URLs linked by the linked-to stylesheet.
     if (CSSStyleSheet* styleSheet = const_cast<HTMLLinkElement*>(this)->sheet())
-        styleSheet->addSubresourceStyleURLs(urls);
+        styleSheet->internal()->addSubresourceStyleURLs(urls);
 }
 
 void HTMLLinkElement::addPendingSheet(PendingSheetType type)
index b911262..b327b15 100644 (file)
@@ -73,7 +73,7 @@ PassRefPtr<HTMLStyleElement> HTMLStyleElement::create(const QualifiedName& tagNa
 void HTMLStyleElement::parseAttribute(Attribute* attr)
 {
     if (attr->name() == titleAttr && m_sheet)
-        m_sheet->setTitle(attr->value());
+        m_sheet->internal()->setTitle(attr->value());
     else if (attr->name() == onloadAttr)
         setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
     else if (attr->name() == onerrorAttr)
@@ -259,7 +259,7 @@ void HTMLStyleElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) cons
     HTMLElement::addSubresourceAttributeURLs(urls);
 
     if (CSSStyleSheet* styleSheet = const_cast<HTMLStyleElement*>(this)->sheet())
-        styleSheet->addSubresourceStyleURLs(urls);
+        styleSheet->internal()->addSubresourceStyleURLs(urls);
 }
 
 bool HTMLStyleElement::disabled() const
index ab89667..85a9a3c 100644 (file)
@@ -206,7 +206,7 @@ static void fillMediaListChain(CSSRule* rule, Array<TypeBuilder::CSS::CSSMedia>*
             mediaList = 0;
 
         if (parentStyleSheet) {
-            sourceURL = parentStyleSheet->finalURL();
+            sourceURL = parentStyleSheet->internal()->finalURL();
             if (sourceURL.isEmpty())
                 sourceURL = InspectorDOMAgent::documentURLString(parentStyleSheet->findDocument());
         } else
@@ -225,8 +225,8 @@ static void fillMediaListChain(CSSRule* rule, Array<TypeBuilder::CSS::CSSMedia>*
                     Document* doc = styleSheet->findDocument();
                     if (doc)
                         sourceURL = doc->url();
-                    else if (!styleSheet->finalURL().isEmpty())
-                        sourceURL = styleSheet->finalURL();
+                    else if (!styleSheet->internal()->finalURL().isEmpty())
+                        sourceURL = styleSheet->internal()->finalURL();
                     else
                         sourceURL = "";
                     mediaArray->addItem(buildMediaObject(mediaList, styleSheet->ownerNode() ? MediaListSourceLinkedSheet : MediaListSourceInlineSheet, sourceURL));
@@ -314,7 +314,7 @@ bool InspectorStyle::setPropertyText(unsigned index, const String& propertyText,
         RefPtr<StylePropertySet> tempMutableStyle = StylePropertySet::create();
         RefPtr<CSSStyleSourceData> sourceData = CSSStyleSourceData::create();
         CSSParser p;
-        p.parseDeclaration(tempMutableStyle.get(), propertyText + " " + bogusPropertyName + ": none", &sourceData, m_style->parentStyleSheet());
+        p.parseDeclaration(tempMutableStyle.get(), propertyText + " " + bogusPropertyName + ": none", &sourceData, m_style->parentStyleSheet()->internal());
         Vector<CSSPropertySourceData>& propertyData = sourceData->propertyData;
         unsigned propertyCount = propertyData.size();
 
@@ -689,8 +689,8 @@ PassRefPtr<InspectorStyleSheet> InspectorStyleSheet::create(const String& id, Pa
 // static
 String InspectorStyleSheet::styleSheetURL(CSSStyleSheet* pageStyleSheet)
 {
-    if (pageStyleSheet && !pageStyleSheet->finalURL().isEmpty())
-        return pageStyleSheet->finalURL().string();
+    if (pageStyleSheet && !pageStyleSheet->internal()->finalURL().isEmpty())
+        return pageStyleSheet->internal()->finalURL().string();
     return emptyString();
 }
 
@@ -718,8 +718,9 @@ String InspectorStyleSheet::finalURL() const
 
 void InspectorStyleSheet::reparseStyleSheet(const String& text)
 {
-    m_pageStyleSheet->clearRules();
-    m_pageStyleSheet->parseString(text, m_pageStyleSheet->cssParserMode());
+    m_pageStyleSheet->internal()->clearRules();
+    m_pageStyleSheet->internal()->parseString(text, m_pageStyleSheet->internal()->cssParserMode());
+    m_pageStyleSheet->clearChildRuleCSSOMWrappers();
     m_pageStyleSheet->styleSheetChanged();
     m_inspectorStyles.clear();
     fireStyleSheetChanged();
@@ -1087,14 +1088,14 @@ bool InspectorStyleSheet::ensureSourceData()
     if (!m_parsedStyleSheet->hasText())
         return false;
 
-    RefPtr<CSSStyleSheet> newStyleSheet = CSSStyleSheet::create();
+    RefPtr<StyleSheetInternal> newStyleSheet = StyleSheetInternal::create();
     CSSParser p;
     StyleRuleRangeMap ruleRangeMap;
     p.parseSheet(newStyleSheet.get(), m_parsedStyleSheet->text(), 0, &ruleRangeMap);
     OwnPtr<ParsedStyleSheet::SourceData> rangesVector(adoptPtr(new ParsedStyleSheet::SourceData));
 
     Vector<CSSStyleRule*> rules;
-    RefPtr<CSSRuleList> ruleList = asCSSRuleList(newStyleSheet.get());
+    RefPtr<CSSRuleList> ruleList = asCSSRuleList(CSSStyleSheet::create(newStyleSheet).get());
     collectFlatRules(ruleList, &rules);
     for (unsigned i = 0, size = rules.size(); i < size; ++i) {
         StyleRuleRangeMap::iterator it = ruleRangeMap.find(rules.at(i)->styleRule());
@@ -1414,7 +1415,7 @@ bool InspectorStyleSheetForInlineStyle::getStyleAttributeRanges(RefPtr<CSSStyleS
 
     RefPtr<StylePropertySet> tempDeclaration = StylePropertySet::create();
     CSSParser p;
-    p.parseDeclaration(tempDeclaration.get(), m_styleText, result, m_element->document()->elementSheet());
+    p.parseDeclaration(tempDeclaration.get(), m_styleText, result, m_element->document()->elementSheet()->internal());
     return true;
 }
 
index 9d50211..9c77ade 100644 (file)
@@ -281,7 +281,7 @@ void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet* styleSheet, const KUR
 
     if (url.isValid() && !m_resourceURLs.contains(url)) {
         // FIXME: We should check whether a charset has been specified and if none was found add one.
-        TextEncoding textEncoding(styleSheet->charset());
+        TextEncoding textEncoding(styleSheet->internal()->charset());
         ASSERT(textEncoding.isValid());
         String textString = cssText.toString();
         CString text = textEncoding.encode(textString.characters(), textString.length(), EntitiesForUnencodables);
index e00f66d..85d6df2 100644 (file)
@@ -118,7 +118,7 @@ void SVGStyleElement::parseAttribute(Attribute* attr)
 
     if (attr->name() == SVGNames::titleAttr) {
         if (m_sheet)
-            m_sheet->setTitle(attr->value());
+            m_sheet->internal()->setTitle(attr->value());
         return;
     }
 
index 3f701ce..e6bd9bc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the XSL implementation.
  *
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2008, 2012 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -64,15 +64,12 @@ public:
     }
 
     virtual ~XSLStyleSheet();
-    
-    virtual bool isXSLStyleSheet() const { return true; }
-
-    virtual String type() const { return "text/xml"; }
 
-    virtual bool parseString(const String&, CSSParserMode cssParseMode = CSSStrictMode);
+    bool parseString(const String&);
     
-    virtual bool isLoading();
     void checkLoaded();
+    
+    const KURL& finalURL() const { return m_finalURL; }
 
     void loadChildSheets();
     void loadChildSheet(const String& href);
@@ -80,7 +77,7 @@ public:
     CachedResourceLoader* cachedResourceLoader();
 
     Document* ownerDocument();
-    XSLStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; }
+    virtual XSLStyleSheet* parentStyleSheet() const OVERRIDE { return m_parentStyleSheet; }
     void setParentStyleSheet(XSLStyleSheet* parent);
 
 #if USE(QXMLQUERY)
@@ -95,12 +92,30 @@ public:
 
     void markAsProcessed();
     bool processed() const { return m_processed; }
+    
+    virtual String type() const OVERRIDE { return "text/xml"; }
+    virtual bool disabled() const OVERRIDE { return m_isDisabled; }
+    virtual void setDisabled(bool b) OVERRIDE { m_isDisabled = b; }
+    virtual Node* ownerNode() const OVERRIDE { return m_ownerNode; }
+    virtual String href() const OVERRIDE { return m_originalURL; }
+    virtual String title() const OVERRIDE { return emptyString(); }
+
+    virtual void clearOwnerNode() OVERRIDE { m_ownerNode = 0; }
+    virtual KURL baseURL() const OVERRIDE { return m_finalURL; }
+    virtual bool isLoading() const OVERRIDE;
+
+    virtual bool isXSLStyleSheet() const OVERRIDE { return true; }
 
 private:
     XSLStyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL, bool embedded);
 #if !USE(QXMLQUERY)
     XSLStyleSheet(XSLImportRule* parentImport, const String& originalURL, const KURL& finalURL);
 #endif
+    
+    Node* m_ownerNode;
+    String m_originalURL;
+    KURL m_finalURL;
+    bool m_isDisabled;
 
     Vector<OwnPtr<XSLImportRule> > m_children;
 
index 4936de1..a18b7b1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the XSL implementation.
  *
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -55,7 +55,10 @@ SOFT_LINK(libxslt, xsltLoadStylesheetPI, xsltStylesheetPtr, (xmlDocPtr doc), (do
 namespace WebCore {
 
 XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& originalURL, const KURL& finalURL)
-    : StyleSheet(static_cast<Node*>(0), originalURL, finalURL)
+    : m_ownerNode(0)
+    , m_originalURL(originalURL)
+    , m_finalURL(finalURL)
+    , m_isDisabled(false)
     , m_embedded(false)
     , m_processed(false) // Child sheets get marked as processed when the libxslt engine has finally seen them.
     , m_stylesheetDoc(0)
@@ -65,7 +68,10 @@ XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& originalUR
 }
 
 XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL,  bool embedded)
-    : StyleSheet(parentNode, originalURL, finalURL)
+    : m_ownerNode(parentNode)
+    , m_originalURL(originalURL)
+    , m_finalURL(finalURL)
+    , m_isDisabled(false)
     , m_embedded(embedded)
     , m_processed(true) // The root sheet starts off processed.
     , m_stylesheetDoc(0)
@@ -85,7 +91,7 @@ XSLStyleSheet::~XSLStyleSheet()
     }
 }
 
-bool XSLStyleSheet::isLoading()
+bool XSLStyleSheet::isLoading() const
 {
     for (unsigned i = 0; i < m_children.size(); ++i) {
         if (m_children.at(i)->isLoading())
@@ -129,7 +135,7 @@ CachedResourceLoader* XSLStyleSheet::cachedResourceLoader()
     return document->cachedResourceLoader();
 }
 
-bool XSLStyleSheet::parseString(const String& string, CSSParserMode)
+bool XSLStyleSheet::parseString(const String& string)
 {
     // Parse in a single chunk into an xmlDocPtr
     const UChar BOM = 0xFEFF;
index 6baf175..d7802ad 100644 (file)
 namespace WebCore {
 
 XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL,  bool embedded)
-    : StyleSheet(parentNode, originalURL, finalURL)
+    : m_ownerNode(parentNode)
+    , m_originalURL(originalURL)
+    , m_finalURL(finalURL)
+    , m_isDisabled(false)
     , m_embedded(embedded)
 {
 }
@@ -47,7 +50,7 @@ XSLStyleSheet::~XSLStyleSheet()
     }
 }
 
-bool XSLStyleSheet::isLoading()
+bool XSLStyleSheet::isLoading() const
 {
     notImplemented();
     return false;
@@ -72,7 +75,7 @@ CachedResourceLoader* XSLStyleSheet::cachedResourceLoader()
     return document->cachedResourceLoader();
 }
 
-bool XSLStyleSheet::parseString(const String& string, CSSParserMode)
+bool XSLStyleSheet::parseString(const String& string)
 {
     // FIXME: Fix QXmlQuery so that it allows compiling the stylesheet before setting the document
     // to be transformed. This way we could not only check if the stylesheet is correct before using it
index 32781d4..3c0f9f6 100644 (file)
@@ -178,7 +178,7 @@ void WebDocument::insertUserStyleSheet(const WebString& sourceCode, UserStyleLev
 {
     RefPtr<Document> document = unwrap<Document>();
 
-    RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::create(document.get());
+    RefPtr<StyleSheetInternal> parsedSheet = StyleSheetInternal::create(document.get());
     parsedSheet->setIsUserStyleSheet(level == UserStyleUserLevel);
     parsedSheet->parseString(sourceCode, strictToCSSParserMode(!document->inQuirksMode()));
     document->addUserSheet(parsedSheet.release());