CSSOM rule wrappers always have a corresponding internal style object.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Oct 2014 04:38:19 +0000 (04:38 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Oct 2014 04:38:19 +0000 (04:38 +0000)
<https://webkit.org/b/137379>

Make the CSSOM rule wrapper classes use references & Ref instead of
raw pointers and RefPtr for pointing to the internal style rule.

Also changed the signature of reattach() to take a StyleRuleBase&
since it's never called with a null pointer.

Finally marked the rule classes final.

Reviewed by Geoffrey Garen.

* css/CSSCharsetRule.h:
* css/CSSFontFaceRule.cpp:
(WebCore::CSSFontFaceRule::CSSFontFaceRule):
(WebCore::CSSFontFaceRule::reattach):
* css/CSSFontFaceRule.h:
(WebCore::CSSFontFaceRule::create): Deleted.
* css/CSSGroupingRule.cpp:
(WebCore::CSSGroupingRule::CSSGroupingRule):
(WebCore::CSSGroupingRule::reattach):
* css/CSSGroupingRule.h:
* css/CSSImportRule.cpp:
(WebCore::CSSImportRule::CSSImportRule):
(WebCore::CSSImportRule::href):
(WebCore::CSSImportRule::media):
(WebCore::CSSImportRule::cssText):
(WebCore::CSSImportRule::styleSheet):
(WebCore::CSSImportRule::reattach):
* css/CSSImportRule.h:
(WebCore::CSSImportRule::create): Deleted.
* css/CSSMediaRule.cpp:
(WebCore::CSSMediaRule::CSSMediaRule):
(WebCore::CSSMediaRule::mediaQueries):
(WebCore::CSSMediaRule::reattach):
* css/CSSMediaRule.h:
(WebCore::CSSMediaRule::create): Deleted.
* css/CSSPageRule.cpp:
(WebCore::CSSPageRule::CSSPageRule):
(WebCore::CSSPageRule::reattach):
* css/CSSPageRule.h:
(WebCore::CSSPageRule::create): Deleted.
* css/CSSRule.h:
* css/CSSStyleRule.cpp:
(WebCore::CSSStyleRule::CSSStyleRule):
(WebCore::CSSStyleRule::reattach):
* css/CSSStyleRule.h:
(WebCore::CSSStyleRule::create): Deleted.
(WebCore::CSSStyleRule::styleRule): Deleted.
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::reattachChildRuleCSSOMWrappers):
* css/CSSSupportsRule.cpp:
(WebCore::CSSSupportsRule::CSSSupportsRule):
(WebCore::CSSSupportsRule::conditionText):
* css/CSSSupportsRule.h:
(WebCore::CSSSupportsRule::create):
* css/CSSUnknownRule.h:
* css/StyleRule.cpp:
(WebCore::StyleRuleBase::createCSSOMWrapper):
* css/StyleRuleImport.h:
(WebCore::StyleRuleImport::mediaQueries):
* css/WebKitCSSKeyframeRule.cpp:
(WebCore::WebKitCSSKeyframeRule::WebKitCSSKeyframeRule):
(WebCore::WebKitCSSKeyframeRule::reattach):
* css/WebKitCSSKeyframeRule.h:
* css/WebKitCSSKeyframesRule.cpp:
(WebCore::WebKitCSSKeyframesRule::WebKitCSSKeyframesRule):
(WebCore::WebKitCSSKeyframesRule::item):
(WebCore::WebKitCSSKeyframesRule::reattach):
* css/WebKitCSSKeyframesRule.h:
(WebCore::WebKitCSSKeyframesRule::create):
* css/WebKitCSSRegionRule.cpp:
(WebCore::WebKitCSSRegionRule::WebKitCSSRegionRule):
(WebCore::WebKitCSSRegionRule::cssText):
* css/WebKitCSSRegionRule.h:
(WebCore::WebKitCSSRegionRule::create):
* css/WebKitCSSViewportRule.cpp:
(WebCore::WebKitCSSViewportRule::reattach):
* css/WebKitCSSViewportRule.h:

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

29 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/CSSCharsetRule.h
Source/WebCore/css/CSSFontFaceRule.cpp
Source/WebCore/css/CSSFontFaceRule.h
Source/WebCore/css/CSSGroupingRule.cpp
Source/WebCore/css/CSSGroupingRule.h
Source/WebCore/css/CSSImportRule.cpp
Source/WebCore/css/CSSImportRule.h
Source/WebCore/css/CSSMediaRule.cpp
Source/WebCore/css/CSSMediaRule.h
Source/WebCore/css/CSSPageRule.cpp
Source/WebCore/css/CSSPageRule.h
Source/WebCore/css/CSSRule.h
Source/WebCore/css/CSSStyleRule.cpp
Source/WebCore/css/CSSStyleRule.h
Source/WebCore/css/CSSStyleSheet.cpp
Source/WebCore/css/CSSSupportsRule.cpp
Source/WebCore/css/CSSSupportsRule.h
Source/WebCore/css/CSSUnknownRule.h
Source/WebCore/css/StyleRule.cpp
Source/WebCore/css/StyleRuleImport.h
Source/WebCore/css/WebKitCSSKeyframeRule.cpp
Source/WebCore/css/WebKitCSSKeyframeRule.h
Source/WebCore/css/WebKitCSSKeyframesRule.cpp
Source/WebCore/css/WebKitCSSKeyframesRule.h
Source/WebCore/css/WebKitCSSRegionRule.cpp
Source/WebCore/css/WebKitCSSRegionRule.h
Source/WebCore/css/WebKitCSSViewportRule.cpp
Source/WebCore/css/WebKitCSSViewportRule.h

index 93bd084..4c97c66 100644 (file)
@@ -1,3 +1,86 @@
+2014-10-02  Andreas Kling  <akling@apple.com>
+
+        CSSOM rule wrappers always have a corresponding internal style object.
+        <https://webkit.org/b/137379>
+
+        Make the CSSOM rule wrapper classes use references & Ref instead of
+        raw pointers and RefPtr for pointing to the internal style rule.
+
+        Also changed the signature of reattach() to take a StyleRuleBase&
+        since it's never called with a null pointer.
+
+        Finally marked the rule classes final.
+
+        Reviewed by Geoffrey Garen.
+
+        * css/CSSCharsetRule.h:
+        * css/CSSFontFaceRule.cpp:
+        (WebCore::CSSFontFaceRule::CSSFontFaceRule):
+        (WebCore::CSSFontFaceRule::reattach):
+        * css/CSSFontFaceRule.h:
+        (WebCore::CSSFontFaceRule::create): Deleted.
+        * css/CSSGroupingRule.cpp:
+        (WebCore::CSSGroupingRule::CSSGroupingRule):
+        (WebCore::CSSGroupingRule::reattach):
+        * css/CSSGroupingRule.h:
+        * css/CSSImportRule.cpp:
+        (WebCore::CSSImportRule::CSSImportRule):
+        (WebCore::CSSImportRule::href):
+        (WebCore::CSSImportRule::media):
+        (WebCore::CSSImportRule::cssText):
+        (WebCore::CSSImportRule::styleSheet):
+        (WebCore::CSSImportRule::reattach):
+        * css/CSSImportRule.h:
+        (WebCore::CSSImportRule::create): Deleted.
+        * css/CSSMediaRule.cpp:
+        (WebCore::CSSMediaRule::CSSMediaRule):
+        (WebCore::CSSMediaRule::mediaQueries):
+        (WebCore::CSSMediaRule::reattach):
+        * css/CSSMediaRule.h:
+        (WebCore::CSSMediaRule::create): Deleted.
+        * css/CSSPageRule.cpp:
+        (WebCore::CSSPageRule::CSSPageRule):
+        (WebCore::CSSPageRule::reattach):
+        * css/CSSPageRule.h:
+        (WebCore::CSSPageRule::create): Deleted.
+        * css/CSSRule.h:
+        * css/CSSStyleRule.cpp:
+        (WebCore::CSSStyleRule::CSSStyleRule):
+        (WebCore::CSSStyleRule::reattach):
+        * css/CSSStyleRule.h:
+        (WebCore::CSSStyleRule::create): Deleted.
+        (WebCore::CSSStyleRule::styleRule): Deleted.
+        * css/CSSStyleSheet.cpp:
+        (WebCore::CSSStyleSheet::reattachChildRuleCSSOMWrappers):
+        * css/CSSSupportsRule.cpp:
+        (WebCore::CSSSupportsRule::CSSSupportsRule):
+        (WebCore::CSSSupportsRule::conditionText):
+        * css/CSSSupportsRule.h:
+        (WebCore::CSSSupportsRule::create):
+        * css/CSSUnknownRule.h:
+        * css/StyleRule.cpp:
+        (WebCore::StyleRuleBase::createCSSOMWrapper):
+        * css/StyleRuleImport.h:
+        (WebCore::StyleRuleImport::mediaQueries):
+        * css/WebKitCSSKeyframeRule.cpp:
+        (WebCore::WebKitCSSKeyframeRule::WebKitCSSKeyframeRule):
+        (WebCore::WebKitCSSKeyframeRule::reattach):
+        * css/WebKitCSSKeyframeRule.h:
+        * css/WebKitCSSKeyframesRule.cpp:
+        (WebCore::WebKitCSSKeyframesRule::WebKitCSSKeyframesRule):
+        (WebCore::WebKitCSSKeyframesRule::item):
+        (WebCore::WebKitCSSKeyframesRule::reattach):
+        * css/WebKitCSSKeyframesRule.h:
+        (WebCore::WebKitCSSKeyframesRule::create):
+        * css/WebKitCSSRegionRule.cpp:
+        (WebCore::WebKitCSSRegionRule::WebKitCSSRegionRule):
+        (WebCore::WebKitCSSRegionRule::cssText):
+        * css/WebKitCSSRegionRule.h:
+        (WebCore::WebKitCSSRegionRule::create):
+        * css/WebKitCSSViewportRule.cpp:
+        (WebCore::WebKitCSSViewportRule::reattach):
+        * css/WebKitCSSViewportRule.h:
+
 2014-10-02  Christophe Dumez  <cdumez@apple.com>
 
         Use is<>() / downcast<>() for CSSRule subclasses
index 86ea3f3..a2c5d99 100644 (file)
@@ -26,7 +26,7 @@
 
 namespace WebCore {
 
-class CSSCharsetRule : public CSSRule {
+class CSSCharsetRule final : public CSSRule {
 public:
     static PassRefPtr<CSSCharsetRule> create(CSSStyleSheet* parent, const String& encoding)
     {
@@ -37,7 +37,7 @@ public:
 
     virtual CSSRule::Type type() const override { return CHARSET_RULE; }
     virtual String cssText() const override;
-    virtual void reattach(StyleRuleBase* rule) override { ASSERT_UNUSED(rule, !rule); }
+    virtual void reattach(StyleRuleBase&) override { }
 
     const String& encoding() const { return m_encoding; }
     void setEncoding(const String& encoding, ExceptionCode&) { m_encoding = encoding; }
index 2bb945a..f64acd9 100644 (file)
@@ -29,7 +29,7 @@
 
 namespace WebCore {
 
-CSSFontFaceRule::CSSFontFaceRule(StyleRuleFontFace* fontFaceRule, CSSStyleSheet* parent)
+CSSFontFaceRule::CSSFontFaceRule(StyleRuleFontFace& fontFaceRule, CSSStyleSheet* parent)
     : CSSRule(parent)
     , m_fontFaceRule(fontFaceRule)
 {
@@ -60,11 +60,10 @@ String CSSFontFaceRule::cssText() const
     return result.toString();
 }
 
-void CSSFontFaceRule::reattach(StyleRuleBase* rule)
+void CSSFontFaceRule::reattach(StyleRuleBase& rule)
 {
-    ASSERT(rule);
-    ASSERT_WITH_SECURITY_IMPLICATION(rule->isFontFaceRule());
-    m_fontFaceRule = static_cast<StyleRuleFontFace*>(rule);
+    ASSERT_WITH_SECURITY_IMPLICATION(rule.isFontFaceRule());
+    m_fontFaceRule = static_cast<StyleRuleFontFace&>(rule);
     if (m_propertiesCSSOMWrapper)
         m_propertiesCSSOMWrapper->reattach(m_fontFaceRule->mutableProperties());
 }
index 638e898..9ffa404 100644 (file)
@@ -30,22 +30,22 @@ class CSSStyleDeclaration;
 class StyleRuleFontFace;
 class StyleRuleCSSStyleDeclaration;
 
-class CSSFontFaceRule : public CSSRule {
+class CSSFontFaceRule final : public CSSRule {
 public:
-    static PassRefPtr<CSSFontFaceRule> create(StyleRuleFontFace* rule, CSSStyleSheet* sheet) { return adoptRef(new CSSFontFaceRule(rule, sheet)); }
+    static PassRefPtr<CSSFontFaceRule> create(StyleRuleFontFace& rule, CSSStyleSheet* sheet) { return adoptRef(new CSSFontFaceRule(rule, sheet)); }
 
     virtual ~CSSFontFaceRule();
 
     virtual CSSRule::Type type() const override { return FONT_FACE_RULE; }
     virtual String cssText() const override;
-    virtual void reattach(StyleRuleBase*) override;
+    virtual void reattach(StyleRuleBase&) override;
 
     CSSStyleDeclaration& style();
 
 private:
-    CSSFontFaceRule(StyleRuleFontFace*, CSSStyleSheet* parent);
+    CSSFontFaceRule(StyleRuleFontFace&, CSSStyleSheet* parent);
 
-    RefPtr<StyleRuleFontFace> m_fontFaceRule;
+    Ref<StyleRuleFontFace> m_fontFaceRule;
     RefPtr<StyleRuleCSSStyleDeclaration> m_propertiesCSSOMWrapper;
 };
 
index 648fc22..993fb0e 100644 (file)
 
 namespace WebCore {
 
-CSSGroupingRule::CSSGroupingRule(StyleRuleGroup* groupRule, CSSStyleSheet* parent)
+CSSGroupingRule::CSSGroupingRule(StyleRuleGroup& groupRule, CSSStyleSheet* parent)
     : CSSRule(parent)
     , m_groupRule(groupRule)
-    , m_childRuleCSSOMWrappers(groupRule->childRules().size())
+    , m_childRuleCSSOMWrappers(groupRule.childRules().size())
 {
 }
 
@@ -148,13 +148,12 @@ CSSRuleList& CSSGroupingRule::cssRules() const
     return *m_ruleListCSSOMWrapper;
 }
 
-void CSSGroupingRule::reattach(StyleRuleBase* rule)
+void CSSGroupingRule::reattach(StyleRuleBase& rule)
 {
-    ASSERT(rule);
-    m_groupRule = static_cast<StyleRuleGroup*>(rule);
+    m_groupRule = static_cast<StyleRuleGroup&>(rule);
     for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) {
         if (m_childRuleCSSOMWrappers[i])
-            m_childRuleCSSOMWrappers[i]->reattach(m_groupRule->childRules()[i].get());
+            m_childRuleCSSOMWrappers[i]->reattach(*m_groupRule.get().childRules()[i]);
     }
 }
 
index 30f3042..640cede 100644 (file)
@@ -36,7 +36,7 @@ class CSSGroupingRule : public CSSRule {
 public:
     virtual ~CSSGroupingRule();
 
-    virtual void reattach(StyleRuleBase*) override;
+    virtual void reattach(StyleRuleBase&) override;
 
     CSSRuleList& cssRules() const;
 
@@ -48,11 +48,11 @@ public:
     CSSRule* item(unsigned index) const;
 
 protected:
-    CSSGroupingRule(StyleRuleGroup* groupRule, CSSStyleSheet* parent);
+    CSSGroupingRule(StyleRuleGroup& groupRule, CSSStyleSheet* parent);
     
     void appendCssTextForItems(StringBuilder&) const;
 
-    RefPtr<StyleRuleGroup> m_groupRule;
+    Ref<StyleRuleGroup> m_groupRule;
     mutable Vector<RefPtr<CSSRule>> m_childRuleCSSOMWrappers;
     mutable std::unique_ptr<CSSRuleList> m_ruleListCSSOMWrapper;
 };
index 5175756..77485e5 100644 (file)
@@ -34,7 +34,7 @@
 
 namespace WebCore {
 
-CSSImportRule::CSSImportRule(StyleRuleImport* importRule, CSSStyleSheet* parent)
+CSSImportRule::CSSImportRule(StyleRuleImport& importRule, CSSStyleSheet* parent)
     : CSSRule(parent)
     , m_importRule(importRule)
 {
@@ -50,13 +50,13 @@ CSSImportRule::~CSSImportRule()
 
 String CSSImportRule::href() const
 {
-    return m_importRule->href();
+    return m_importRule.get().href();
 }
 
 MediaList& CSSImportRule::media() const
 {
     if (!m_mediaCSSOMWrapper)
-        m_mediaCSSOMWrapper = MediaList::create(m_importRule->mediaQueries(), const_cast<CSSImportRule*>(this));
+        m_mediaCSSOMWrapper = MediaList::create(m_importRule.get().mediaQueries(), const_cast<CSSImportRule*>(this));
     return *m_mediaCSSOMWrapper;
 }
 
@@ -64,11 +64,11 @@ String CSSImportRule::cssText() const
 {
     StringBuilder result;
     result.appendLiteral("@import url(\"");
-    result.append(m_importRule->href());
+    result.append(m_importRule.get().href());
     result.appendLiteral("\")");
 
-    if (m_importRule->mediaQueries()) {
-        String mediaText = m_importRule->mediaQueries()->mediaText();
+    if (m_importRule.get().mediaQueries()) {
+        String mediaText = m_importRule.get().mediaQueries()->mediaText();
         if (!mediaText.isEmpty()) {
             result.append(' ');
             result.append(mediaText);
@@ -81,15 +81,15 @@ String CSSImportRule::cssText() const
 
 CSSStyleSheet* CSSImportRule::styleSheet() const
 { 
-    if (!m_importRule->styleSheet())
+    if (!m_importRule.get().styleSheet())
         return 0;
 
     if (!m_styleSheetCSSOMWrapper)
-        m_styleSheetCSSOMWrapper = CSSStyleSheet::create(*m_importRule->styleSheet(), const_cast<CSSImportRule*>(this));
+        m_styleSheetCSSOMWrapper = CSSStyleSheet::create(*m_importRule.get().styleSheet(), const_cast<CSSImportRule*>(this));
     return m_styleSheetCSSOMWrapper.get(); 
 }
 
-void CSSImportRule::reattach(StyleRuleBase*)
+void CSSImportRule::reattach(StyleRuleBase&)
 {
     // FIXME: Implement when enabling caching for stylesheets with import rules.
     ASSERT_NOT_REACHED();
index 4c4f262..7d0de27 100644 (file)
@@ -31,24 +31,24 @@ class MediaList;
 class MediaQuerySet;
 class StyleRuleImport;
 
-class CSSImportRule : public CSSRule {
+class CSSImportRule final : public CSSRule {
 public:
-    static PassRefPtr<CSSImportRule> create(StyleRuleImport* rule, CSSStyleSheet* sheet) { return adoptRef(new CSSImportRule(rule, sheet)); }
+    static PassRefPtr<CSSImportRule> create(StyleRuleImport& rule, CSSStyleSheet* sheet) { return adoptRef(new CSSImportRule(rule, sheet)); }
     
     virtual ~CSSImportRule();
 
     virtual CSSRule::Type type() const override { return IMPORT_RULE; }
     virtual String cssText() const override;
-    virtual void reattach(StyleRuleBase*) override;
+    virtual void reattach(StyleRuleBase&) override;
 
     String href() const;
     MediaList& media() const;
     CSSStyleSheet* styleSheet() const;
 
 private:
-    CSSImportRule(StyleRuleImport*, CSSStyleSheet*);
+    CSSImportRule(StyleRuleImport&, CSSStyleSheet*);
 
-    RefPtr<StyleRuleImport> m_importRule;
+    Ref<StyleRuleImport> m_importRule;
     mutable RefPtr<MediaList> m_mediaCSSOMWrapper;
     mutable RefPtr<CSSStyleSheet> m_styleSheetCSSOMWrapper;
 };
index 5e96e41..8cbe32f 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace WebCore {
 
-CSSMediaRule::CSSMediaRule(StyleRuleMedia* mediaRule, CSSStyleSheet* parent)
+CSSMediaRule::CSSMediaRule(StyleRuleMedia& mediaRule, CSSStyleSheet* parent)
     : CSSGroupingRule(mediaRule, parent)
 {
 }
@@ -45,7 +45,7 @@ CSSMediaRule::~CSSMediaRule()
 
 MediaQuerySet* CSSMediaRule::mediaQueries() const
 {
-    return toStyleRuleMedia(m_groupRule.get())->mediaQueries();
+    return toStyleRuleMedia(&m_groupRule.get())->mediaQueries();
 }
 
 String CSSMediaRule::cssText() const
@@ -71,7 +71,7 @@ MediaList* CSSMediaRule::media() const
     return m_mediaCSSOMWrapper.get();
 }
 
-void CSSMediaRule::reattach(StyleRuleBase* rule)
+void CSSMediaRule::reattach(StyleRuleBase& rule)
 {
     CSSGroupingRule::reattach(rule);
     if (m_mediaCSSOMWrapper && mediaQueries())
index a422070..8672153 100644 (file)
@@ -30,20 +30,20 @@ namespace WebCore {
 
 class StyleRuleMedia;
 
-class CSSMediaRule : public CSSGroupingRule {
+class CSSMediaRule final : public CSSGroupingRule {
 public:
-    static PassRefPtr<CSSMediaRule> create(StyleRuleMedia* rule, CSSStyleSheet* sheet) { return adoptRef(new CSSMediaRule(rule, sheet)); }
+    static PassRefPtr<CSSMediaRule> create(StyleRuleMedia& rule, CSSStyleSheet* sheet) { return adoptRef(new CSSMediaRule(rule, sheet)); }
 
     virtual ~CSSMediaRule();
 
     virtual CSSRule::Type type() const override { return MEDIA_RULE; }
-    virtual void reattach(StyleRuleBase*) override;
+    virtual void reattach(StyleRuleBase&) override;
     virtual String cssText() const override;
 
     MediaList* media() const;
 
 private:
-    CSSMediaRule(StyleRuleMedia*, CSSStyleSheet*);
+    CSSMediaRule(StyleRuleMedia&, CSSStyleSheet*);
 
     MediaQuerySet* mediaQueries() const;
     
index 3e4836b..f21430d 100644 (file)
@@ -34,7 +34,7 @@
 
 namespace WebCore {
 
-CSSPageRule::CSSPageRule(StyleRulePage* pageRule, CSSStyleSheet* parent)
+CSSPageRule::CSSPageRule(StyleRulePage& pageRule, CSSStyleSheet* parent)
     : CSSRule(parent)
     , m_pageRule(pageRule)
 {
@@ -94,13 +94,12 @@ String CSSPageRule::cssText() const
     return result.toString();
 }
 
-void CSSPageRule::reattach(StyleRuleBase* rule)
+void CSSPageRule::reattach(StyleRuleBase& rule)
 {
-    ASSERT(rule);
-    ASSERT_WITH_SECURITY_IMPLICATION(rule->isPageRule());
-    m_pageRule = static_cast<StyleRulePage*>(rule);
+    ASSERT_WITH_SECURITY_IMPLICATION(rule.isPageRule());
+    m_pageRule = static_cast<StyleRulePage&>(rule);
     if (m_propertiesCSSOMWrapper)
-        m_propertiesCSSOMWrapper->reattach(m_pageRule->mutableProperties());
+        m_propertiesCSSOMWrapper->reattach(m_pageRule.get().mutableProperties());
 }
 
 } // namespace WebCore
index 82e91aa..5df9aaf 100644 (file)
@@ -31,15 +31,15 @@ class CSSStyleSheet;
 class StyleRulePage;
 class StyleRuleCSSStyleDeclaration;
 
-class CSSPageRule : public CSSRule {
+class CSSPageRule final : public CSSRule {
 public:
-    static PassRefPtr<CSSPageRule> create(StyleRulePage* rule, CSSStyleSheet* sheet) { return adoptRef(new CSSPageRule(rule, sheet)); }
+    static PassRefPtr<CSSPageRule> create(StyleRulePage& rule, CSSStyleSheet* sheet) { return adoptRef(new CSSPageRule(rule, sheet)); }
 
     virtual ~CSSPageRule();
 
     virtual CSSRule::Type type() const override { return PAGE_RULE; }
     virtual String cssText() const override;
-    virtual void reattach(StyleRuleBase*) override;
+    virtual void reattach(StyleRuleBase&) override;
 
     CSSStyleDeclaration& style();
 
@@ -47,9 +47,9 @@ public:
     void setSelectorText(const String&);
 
 private:
-    CSSPageRule(StyleRulePage*, CSSStyleSheet*);
+    CSSPageRule(StyleRulePage&, CSSStyleSheet*);
     
-    RefPtr<StyleRulePage> m_pageRule;
+    Ref<StyleRulePage> m_pageRule;
     mutable RefPtr<StyleRuleCSSStyleDeclaration> m_propertiesCSSOMWrapper;
 };
 
index 2945b98..6c513b7 100644 (file)
@@ -64,7 +64,7 @@ public:
 
     virtual Type type() const = 0;
     virtual String cssText() const = 0;
-    virtual void reattach(StyleRuleBase*) = 0;
+    virtual void reattach(StyleRuleBase&) = 0;
 
     void setParentStyleSheet(CSSStyleSheet* styleSheet)
     {
index 85639b5..95a69cf 100644 (file)
@@ -42,7 +42,7 @@ static SelectorTextCache& selectorTextCache()
     return cache;
 }
 
-CSSStyleRule::CSSStyleRule(StyleRule* styleRule, CSSStyleSheet* parent)
+CSSStyleRule::CSSStyleRule(StyleRule& styleRule, CSSStyleSheet* parent)
     : CSSRule(parent)
     , m_styleRule(styleRule)
 {
@@ -131,11 +131,10 @@ String CSSStyleRule::cssText() const
     return result.toString();
 }
 
-void CSSStyleRule::reattach(StyleRuleBase* rule)
+void CSSStyleRule::reattach(StyleRuleBase& rule)
 {
-    ASSERT(rule);
-    ASSERT_WITH_SECURITY_IMPLICATION(rule->isStyleRule());
-    m_styleRule = static_cast<StyleRule*>(rule);
+    ASSERT_WITH_SECURITY_IMPLICATION(rule.isStyleRule());
+    m_styleRule = static_cast<StyleRule&>(rule);
     if (m_propertiesCSSOMWrapper)
         m_propertiesCSSOMWrapper->reattach(m_styleRule->mutableProperties());
 }
index 4d50fea..b8f24ce 100644 (file)
@@ -30,15 +30,15 @@ class CSSStyleDeclaration;
 class StyleRuleCSSStyleDeclaration;
 class StyleRule;
 
-class CSSStyleRule : public CSSRule {
+class CSSStyleRule final : public CSSRule {
 public:
-    static PassRefPtr<CSSStyleRule> create(StyleRule* rule, CSSStyleSheet* sheet) { return adoptRef(new CSSStyleRule(rule, sheet)); }
+    static PassRefPtr<CSSStyleRule> create(StyleRule& rule, CSSStyleSheet* sheet) { return adoptRef(new CSSStyleRule(rule, sheet)); }
 
     virtual ~CSSStyleRule();
 
     virtual CSSRule::Type type() const { return STYLE_RULE; }
     virtual String cssText() const override;
-    virtual void reattach(StyleRuleBase*) override;
+    virtual void reattach(StyleRuleBase&) override;
 
     String selectorText() const;
     void setSelectorText(const String&);
@@ -46,14 +46,14 @@ public:
     CSSStyleDeclaration& style();
 
     // FIXME: Not CSSOM. Remove.
-    StyleRule* styleRule() const { return m_styleRule.get(); }
+    StyleRule* styleRule() const { return &const_cast<StyleRule&>(m_styleRule.get()); }
 
 private:
-    CSSStyleRule(StyleRule*, CSSStyleSheet*);
+    CSSStyleRule(StyleRule&, CSSStyleSheet*);
 
     String generateSelectorText() const;
 
-    RefPtr<StyleRule> m_styleRule;    
+    Ref<StyleRule> m_styleRule;
     RefPtr<StyleRuleCSSStyleDeclaration> m_propertiesCSSOMWrapper;
 };
 
index bd4a3ff..229e37c 100644 (file)
@@ -201,7 +201,7 @@ void CSSStyleSheet::reattachChildRuleCSSOMWrappers()
     for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) {
         if (!m_childRuleCSSOMWrappers[i])
             continue;
-        m_childRuleCSSOMWrappers[i]->reattach(m_contents->ruleAt(i));
+        m_childRuleCSSOMWrappers[i]->reattach(*m_contents->ruleAt(i));
     }
 }
 
index a66ffa2..1aa7823 100644 (file)
@@ -41,7 +41,7 @@
 
 namespace WebCore {
 
-CSSSupportsRule::CSSSupportsRule(StyleRuleSupports* supportsRule, CSSStyleSheet* parent)
+CSSSupportsRule::CSSSupportsRule(StyleRuleSupports& supportsRule, CSSStyleSheet* parent)
     : CSSGroupingRule(supportsRule, parent)
 {
 }
@@ -61,7 +61,7 @@ String CSSSupportsRule::cssText() const
 
 String CSSSupportsRule::conditionText() const
 {
-    return toStyleRuleSupports(m_groupRule.get())->conditionText();
+    return toStyleRuleSupports(&m_groupRule.get())->conditionText();
 }
 
 } // namespace WebCore
index efe5ce6..47f504b 100644 (file)
@@ -38,9 +38,9 @@ namespace WebCore {
 class CSSRule;
 class StyleRuleSupports;
 
-class CSSSupportsRule : public CSSGroupingRule {
+class CSSSupportsRule final : public CSSGroupingRule {
 public:
-    static PassRefPtr<CSSSupportsRule> create(StyleRuleSupports* rule, CSSStyleSheet* sheet)
+    static PassRefPtr<CSSSupportsRule> create(StyleRuleSupports& rule, CSSStyleSheet* sheet)
     {
         return adoptRef(new CSSSupportsRule(rule, sheet));
     }
@@ -53,7 +53,7 @@ public:
     String conditionText() const;
 
 private:
-    CSSSupportsRule(StyleRuleSupports*, CSSStyleSheet*);
+    CSSSupportsRule(StyleRuleSupports&, CSSStyleSheet*);
 };
 
 } // namespace WebCore
index a74143a..995794a 100644 (file)
 
 namespace WebCore {
 
-class CSSUnknownRule : public CSSRule {
+class CSSUnknownRule final : public CSSRule {
 public:
     CSSUnknownRule() : CSSRule(0) { }
     virtual ~CSSUnknownRule() { }
 
     virtual CSSRule::Type type() const override { return UNKNOWN_RULE; }
     virtual String cssText() const override { return String(); }
-    virtual void reattach(StyleRuleBase*) override { }
+    virtual void reattach(StyleRuleBase&) override { }
 };
 
 } // namespace WebCore
index 83741a7..99c42ea 100644 (file)
@@ -147,39 +147,39 @@ PassRef<StyleRuleBase> StyleRuleBase::copy() const
 PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet, CSSRule* parentRule) const
 {
     RefPtr<CSSRule> rule;
-    StyleRuleBase* self = const_cast<StyleRuleBase*>(this);
+    StyleRuleBase& self = const_cast<StyleRuleBase&>(*this);
     switch (type()) {
     case Style:
-        rule = CSSStyleRule::create(static_cast<StyleRule*>(self), parentSheet);
+        rule = CSSStyleRule::create(static_cast<StyleRule&>(self), parentSheet);
         break;
     case Page:
-        rule = CSSPageRule::create(static_cast<StyleRulePage*>(self), parentSheet);
+        rule = CSSPageRule::create(static_cast<StyleRulePage&>(self), parentSheet);
         break;
     case FontFace:
-        rule = CSSFontFaceRule::create(static_cast<StyleRuleFontFace*>(self), parentSheet);
+        rule = CSSFontFaceRule::create(static_cast<StyleRuleFontFace&>(self), parentSheet);
         break;
     case Media:
-        rule = CSSMediaRule::create(static_cast<StyleRuleMedia*>(self), parentSheet);
+        rule = CSSMediaRule::create(static_cast<StyleRuleMedia&>(self), parentSheet);
         break;
 #if ENABLE(CSS3_CONDITIONAL_RULES)
     case Supports:
-        rule = CSSSupportsRule::create(static_cast<StyleRuleSupports*>(self), parentSheet);
+        rule = CSSSupportsRule::create(static_cast<StyleRuleSupports&>(self), parentSheet);
         break;
 #endif
 #if ENABLE(CSS_REGIONS)
     case Region:
-        rule = WebKitCSSRegionRule::create(static_cast<StyleRuleRegion*>(self), parentSheet);
+        rule = WebKitCSSRegionRule::create(static_cast<StyleRuleRegion&>(self), parentSheet);
         break;
 #endif
     case Import:
-        rule = CSSImportRule::create(static_cast<StyleRuleImport*>(self), parentSheet);
+        rule = CSSImportRule::create(static_cast<StyleRuleImport&>(self), parentSheet);
         break;
     case Keyframes:
-        rule = WebKitCSSKeyframesRule::create(static_cast<StyleRuleKeyframes*>(self), parentSheet);
+        rule = WebKitCSSKeyframesRule::create(static_cast<StyleRuleKeyframes&>(self), parentSheet);
         break;
 #if ENABLE(CSS_DEVICE_ADAPTATION)
     case Viewport:
-        rule = WebKitCSSViewportRule::create(static_cast<StyleRuleViewport*>(self), parentSheet);
+        rule = WebKitCSSViewportRule::create(static_cast<StyleRuleViewport&>(self), parentSheet);
         break;
 #endif
     case Unknown:
index dd7ca9e..28face7 100644 (file)
@@ -47,7 +47,7 @@ public:
     StyleSheetContents* styleSheet() const { return m_styleSheet.get(); }
 
     bool isLoading() const;
-    MediaQuerySet* mediaQueries() { return m_mediaQueries.get(); }
+    MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
 
     void requestStyleSheet();
 
index 3e56398..a5e3236 100644 (file)
@@ -92,7 +92,7 @@ String StyleKeyframe::cssText() const
     return result.toString();
 }
 
-WebKitCSSKeyframeRule::WebKitCSSKeyframeRule(StyleKeyframe* keyframe, WebKitCSSKeyframesRule* parent)
+WebKitCSSKeyframeRule::WebKitCSSKeyframeRule(StyleKeyframe& keyframe, WebKitCSSKeyframesRule* parent)
     : CSSRule(0)
     , m_keyframe(keyframe)
 {
@@ -112,7 +112,7 @@ CSSStyleDeclaration& WebKitCSSKeyframeRule::style()
     return *m_propertiesCSSOMWrapper;
 }
 
-void WebKitCSSKeyframeRule::reattach(StyleRuleBase*)
+void WebKitCSSKeyframeRule::reattach(StyleRuleBase&)
 {
     // No need to reattach, the underlying data is shareable on mutation.
     ASSERT_NOT_REACHED();
index 7aa5a2c..d36ebaf 100644 (file)
@@ -65,13 +65,13 @@ private:
     String m_key;
 };
 
-class WebKitCSSKeyframeRule : public CSSRule {
+class WebKitCSSKeyframeRule final : public CSSRule {
 public:
     virtual ~WebKitCSSKeyframeRule();
 
     virtual CSSRule::Type type() const override { return WEBKIT_KEYFRAME_RULE; }
     virtual String cssText() const override { return m_keyframe->cssText(); }
-    virtual void reattach(StyleRuleBase*) override;
+    virtual void reattach(StyleRuleBase&) override;
 
     String keyText() const { return m_keyframe->keyText(); }
     void setKeyText(const String& s) { m_keyframe->setKeyText(s); }
@@ -79,9 +79,9 @@ public:
     CSSStyleDeclaration& style();
 
 private:
-    WebKitCSSKeyframeRule(StyleKeyframe*, WebKitCSSKeyframesRule* parent);
+    WebKitCSSKeyframeRule(StyleKeyframe&, WebKitCSSKeyframesRule* parent);
 
-    RefPtr<StyleKeyframe> m_keyframe;
+    Ref<StyleKeyframe> m_keyframe;
     mutable RefPtr<StyleRuleCSSStyleDeclaration> m_propertiesCSSOMWrapper;
     
     friend class WebKitCSSKeyframesRule;
index e532bce..c32ba04 100644 (file)
@@ -86,10 +86,10 @@ int StyleRuleKeyframes::findKeyframeIndex(const String& key) const
     return -1;
 }
 
-WebKitCSSKeyframesRule::WebKitCSSKeyframesRule(StyleRuleKeyframes* keyframesRule, CSSStyleSheet* parent)
+WebKitCSSKeyframesRule::WebKitCSSKeyframesRule(StyleRuleKeyframes& keyframesRule, CSSStyleSheet* parent)
     : CSSRule(parent)
     , m_keyframesRule(keyframesRule)
-    , m_childRuleCSSOMWrappers(keyframesRule->keyframes().size())
+    , m_childRuleCSSOMWrappers(keyframesRule.keyframes().size())
 {
 }
 
@@ -180,7 +180,7 @@ WebKitCSSKeyframeRule* WebKitCSSKeyframesRule::item(unsigned index) const
     ASSERT(m_childRuleCSSOMWrappers.size() == m_keyframesRule->keyframes().size());
     RefPtr<WebKitCSSKeyframeRule>& rule = m_childRuleCSSOMWrappers[index];
     if (!rule)
-        rule = adoptRef(new WebKitCSSKeyframeRule(m_keyframesRule->keyframes()[index].get(), const_cast<WebKitCSSKeyframesRule*>(this)));
+        rule = adoptRef(new WebKitCSSKeyframeRule(*m_keyframesRule->keyframes()[index], const_cast<WebKitCSSKeyframesRule*>(this)));
 
     return rule.get(); 
 }
@@ -192,11 +192,10 @@ CSSRuleList& WebKitCSSKeyframesRule::cssRules()
     return *m_ruleListCSSOMWrapper;
 }
 
-void WebKitCSSKeyframesRule::reattach(StyleRuleBase* rule)
+void WebKitCSSKeyframesRule::reattach(StyleRuleBase& rule)
 {
-    ASSERT(rule);
-    ASSERT_WITH_SECURITY_IMPLICATION(rule->isKeyframesRule());
-    m_keyframesRule = static_cast<StyleRuleKeyframes*>(rule);
+    ASSERT_WITH_SECURITY_IMPLICATION(rule.isKeyframesRule());
+    m_keyframesRule = static_cast<StyleRuleKeyframes&>(rule);
 }
 
 } // namespace WebCore
index 93f86be..2c790cf 100644 (file)
@@ -65,15 +65,15 @@ private:
     AtomicString m_name;
 };
 
-class WebKitCSSKeyframesRule : public CSSRule {
+class WebKitCSSKeyframesRule final : public CSSRule {
 public:
-    static PassRefPtr<WebKitCSSKeyframesRule> create(StyleRuleKeyframes* rule, CSSStyleSheet* sheet) { return adoptRef(new WebKitCSSKeyframesRule(rule, sheet)); }
+    static PassRefPtr<WebKitCSSKeyframesRule> create(StyleRuleKeyframes& rule, CSSStyleSheet* sheet) { return adoptRef(new WebKitCSSKeyframesRule(rule, sheet)); }
 
     virtual ~WebKitCSSKeyframesRule();
 
     virtual CSSRule::Type type() const override { return WEBKIT_KEYFRAMES_RULE; }
     virtual String cssText() const override;
-    virtual void reattach(StyleRuleBase*) override;
+    virtual void reattach(StyleRuleBase&) override;
 
     String name() const { return m_keyframesRule->name(); }
     void setName(const String&);
@@ -90,9 +90,9 @@ public:
     WebKitCSSKeyframeRule* item(unsigned index) const;
 
 private:
-    WebKitCSSKeyframesRule(StyleRuleKeyframes*, CSSStyleSheet* parent);
+    WebKitCSSKeyframesRule(StyleRuleKeyframes&, CSSStyleSheet* parent);
 
-    RefPtr<StyleRuleKeyframes> m_keyframesRule;
+    Ref<StyleRuleKeyframes> m_keyframesRule;
     mutable Vector<RefPtr<WebKitCSSKeyframeRule>> m_childRuleCSSOMWrappers;
     mutable std::unique_ptr<CSSRuleList> m_ruleListCSSOMWrapper;
 };
index 35188b3..ec10e12 100644 (file)
@@ -40,7 +40,7 @@
 #if ENABLE(CSS_REGIONS)
 
 namespace WebCore {
-WebKitCSSRegionRule::WebKitCSSRegionRule(StyleRuleRegion* regionRule, CSSStyleSheet* parent)
+WebKitCSSRegionRule::WebKitCSSRegionRule(StyleRuleRegion& regionRule, CSSStyleSheet* parent)
     : CSSGroupingRule(regionRule, parent)
 {
 }
@@ -51,7 +51,7 @@ String WebKitCSSRegionRule::cssText() const
     result.appendLiteral("@-webkit-region ");
 
     // First add the selectors.
-    result.append(toStyleRuleRegion(m_groupRule.get())->selectorList().selectorsText());
+    result.append(toStyleRuleRegion(&m_groupRule.get())->selectorList().selectorsText());
 
     // Then add the rules.
     result.appendLiteral(" { \n");
index 4785842..516bca3 100644 (file)
@@ -39,15 +39,15 @@ namespace WebCore {
 
 class StyleRuleRegion;
 
-class WebKitCSSRegionRule : public CSSGroupingRule {
+class WebKitCSSRegionRule final : public CSSGroupingRule {
 public:
-    static PassRefPtr<WebKitCSSRegionRule> create(StyleRuleRegion* rule, CSSStyleSheet* sheet) { return adoptRef(new WebKitCSSRegionRule(rule, sheet)); }
+    static PassRefPtr<WebKitCSSRegionRule> create(StyleRuleRegion& rule, CSSStyleSheet* sheet) { return adoptRef(new WebKitCSSRegionRule(rule, sheet)); }
 
     virtual CSSRule::Type type() const override { return WEBKIT_REGION_RULE; }
     virtual String cssText() const override;
 
 private:
-    WebKitCSSRegionRule(StyleRuleRegion*, CSSStyleSheet* parent);
+    WebKitCSSRegionRule(StyleRuleRegion&, CSSStyleSheet* parent);
 };
 
 } // namespace WebCore
index c05960b..d6a17bc 100644 (file)
@@ -75,11 +75,10 @@ String WebKitCSSViewportRule::cssText() const
     return result.toString();
 }
 
-void WebKitCSSViewportRule::reattach(StyleRuleBase* rule)
+void WebKitCSSViewportRule::reattach(StyleRuleBase& rule)
 {
-    ASSERT(rule);
-    ASSERT_WITH_SECURITY_IMPLICATION(rule->isViewportRule());
-    m_viewportRule = static_cast<StyleRuleViewport*>(rule);
+    ASSERT_WITH_SECURITY_IMPLICATION(rule.isViewportRule());
+    m_viewportRule = static_cast<StyleRuleViewport&>(rule);
 
     if (m_propertiesCSSOMWrapper)
         m_propertiesCSSOMWrapper->reattach(m_viewportRule->mutableProperties());
index b1c924f..88fbf59 100644 (file)
@@ -41,9 +41,9 @@ class CSSStyleDeclaration;
 class StyleRuleViewport;
 class StyleRuleCSSStyleDeclaration;
 
-class WebKitCSSViewportRule: public CSSRule {
+class WebKitCSSViewportRule final : public CSSRule {
 public:
-    static PassRefPtr<WebKitCSSViewportRule> create(StyleRuleViewport* viewportRule, CSSStyleSheet* sheet)
+    static PassRefPtr<WebKitCSSViewportRule> create(StyleRuleViewport& viewportRule, CSSStyleSheet* sheet)
     {
         return adoptRef(new WebKitCSSViewportRule(viewportRule, sheet));
     }
@@ -51,14 +51,14 @@ public:
 
     virtual CSSRule::Type type() const override { return WEBKIT_VIEWPORT_RULE; }
     virtual String cssText() const override;
-    virtual void reattach(StyleRuleBase*) override;
+    virtual void reattach(StyleRuleBase&) override;
 
     CSSStyleDeclaration& style();
 
 private:
     WebKitCSSViewportRule(StyleRuleViewport*, CSSStyleSheet*);
 
-    RefPtr<StyleRuleViewport> m_viewportRule;
+    Ref<StyleRuleViewport> m_viewportRule;
     mutable RefPtr<StyleRuleCSSStyleDeclaration> m_propertiesCSSOMWrapper;
 };