[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

inferno at chromium.org inferno at chromium.org
Sun Feb 20 23:56:06 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 9c05a61a1c17a218322502d2ad112834517785d8
Author: inferno at chromium.org <inferno at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jan 26 23:43:02 2011 +0000

    2011-01-26  Emil A Eklund  <eae at chromium.org>
    
            Reviewed by Alexey Proskuryakov.
    
            Remove cached document reference from CSSStyleSheet and XSLStyleSheet.
            https://bugs.webkit.org/show_bug.cgi?id=52084
    
            Test: fast/dom/css-delete-doc.html
    
            * css/CSSMediaRule.cpp:
            (WebCore::CSSMediaRule::insertRule):
            (WebCore::CSSMediaRule::deleteRule):
            * css/CSSStyleSheet.cpp:
            (WebCore::CSSStyleSheet::CSSStyleSheet):
            (WebCore::CSSStyleSheet::document):
            * css/CSSStyleSheet.h:
            * xml/XSLStyleSheet.h:
            (WebCore::XSLStyleSheet::parentStyleSheet):
            * xml/XSLStyleSheetLibxslt.cpp:
            (WebCore::XSLStyleSheet::XSLStyleSheet):
            (WebCore::XSLStyleSheet::cachedResourceLoader):
            (WebCore::XSLStyleSheet::setParentStyleSheet):
            (WebCore::XSLStyleSheet::ownerDocument):
            * xml/XSLStyleSheetQt.cpp:
            (WebCore::XSLStyleSheet::XSLStyleSheet):
            (WebCore::XSLStyleSheet::cachedResourceLoader):
            (WebCore::XSLStyleSheet::ownerDocument):
    2011-01-26  Emil A Eklund  <eae at chromium.org>
    
            Reviewed by Alexey Proskuryakov.
    
            Remove cached document reference from CSSStyleSheet and XSLStyleSheet.
            https://bugs.webkit.org/show_bug.cgi?id=52084
    
            Added test for accessing a style sheet associated with a document that
            has been removed.
    
            * fast/dom/css-delete-doc-expected.txt: Added.
            * fast/dom/css-delete-doc.html: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76728 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 7aacfde..aa16f83 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2011-01-26  Emil A Eklund  <eae at chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Remove cached document reference from CSSStyleSheet and XSLStyleSheet.
+        https://bugs.webkit.org/show_bug.cgi?id=52084
+
+        Added test for accessing a style sheet associated with a document that
+        has been removed.
+
+        * fast/dom/css-delete-doc-expected.txt: Added.
+        * fast/dom/css-delete-doc.html: Added.
+
 2011-01-26  Dave Hyatt  <hyatt at apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/LayoutTests/compositing/overflow/get-transform-from-non-box-container-expected.txt b/LayoutTests/fast/dom/css-delete-doc-expected.txt
similarity index 100%
copy from LayoutTests/compositing/overflow/get-transform-from-non-box-container-expected.txt
copy to LayoutTests/fast/dom/css-delete-doc-expected.txt
diff --git a/LayoutTests/fast/dom/css-delete-doc.html b/LayoutTests/fast/dom/css-delete-doc.html
new file mode 100644
index 0000000..51b4e82
--- /dev/null
+++ b/LayoutTests/fast/dom/css-delete-doc.html
@@ -0,0 +1,78 @@
+<html>
+<head>
+<script src="../js/resources/js-test-pre.js"></script>
+<script>
+
+window.jsTestIsAsync = true;
+
+var iteration = 0;
+var sheet, rules;
+
+function step1(opt_media)
+{
+    var doc = document.implementation.createHTMLDocument();
+    var style = doc.createElement('style');
+    doc.head.appendChild(style);
+    sheet = style.sheet;
+    if (opt_media) {
+        sheet.insertRule('@media screen { body { background: red; } p { color: white; } }', 0);
+        rules = sheet.rules[0];
+        sheet.removeRule(0);
+        sheet = 0;
+    }
+
+    doc.head.removeChild(style);
+    document.adoptNode(style);
+    delete doc;
+    gc();
+    setTimeout(opt_media ? step2a : step2b, 10);
+}
+
+function step2a()
+{
+    try {
+        rules.insertRule('a { }', 1);
+        if (iteration++ == 10) {
+            iteration = 0;
+            step1(true);
+            return;
+        }
+        
+        setTimeout('step1(false)', 0);
+    }
+    catch(e) {
+        document.body.innerText = 'FAIL, threw exception.';
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+
+    }    
+}
+
+function step2b()
+{
+    try {
+        sheet.insertRule('a { }', 0);
+        if (iteration++ == 10) {
+            document.body.innerText = 'PASS';
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
+            return;
+        }
+        
+        setTimeout('step1(true)', 0);
+    }
+    catch(e) {
+        document.body.innerText = 'FAIL, threw exception.';
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+
+    }
+}
+
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</head>
+<body onload="step1()">
+    Running...
+</body>
+</html>
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index b16e581..b2ce4ff 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,31 @@
+2011-01-26  Emil A Eklund  <eae at chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Remove cached document reference from CSSStyleSheet and XSLStyleSheet.
+        https://bugs.webkit.org/show_bug.cgi?id=52084
+
+        Test: fast/dom/css-delete-doc.html
+
+        * css/CSSMediaRule.cpp:
+        (WebCore::CSSMediaRule::insertRule):
+        (WebCore::CSSMediaRule::deleteRule):
+        * css/CSSStyleSheet.cpp:
+        (WebCore::CSSStyleSheet::CSSStyleSheet):
+        (WebCore::CSSStyleSheet::document):
+        * css/CSSStyleSheet.h:
+        * xml/XSLStyleSheet.h:
+        (WebCore::XSLStyleSheet::parentStyleSheet):
+        * xml/XSLStyleSheetLibxslt.cpp:
+        (WebCore::XSLStyleSheet::XSLStyleSheet):
+        (WebCore::XSLStyleSheet::cachedResourceLoader):
+        (WebCore::XSLStyleSheet::setParentStyleSheet):
+        (WebCore::XSLStyleSheet::ownerDocument):
+        * xml/XSLStyleSheetQt.cpp:
+        (WebCore::XSLStyleSheet::XSLStyleSheet):
+        (WebCore::XSLStyleSheet::cachedResourceLoader):
+        (WebCore::XSLStyleSheet::ownerDocument):
+
 2011-01-25  Dimitri Glazkov  <dglazkov at chromium.org>
 
         Reviewed by Kent Tamura.
diff --git a/Source/WebCore/css/CSSMediaRule.cpp b/Source/WebCore/css/CSSMediaRule.cpp
index 6348762..46dc780 100644
--- a/Source/WebCore/css/CSSMediaRule.cpp
+++ b/Source/WebCore/css/CSSMediaRule.cpp
@@ -88,8 +88,8 @@ unsigned CSSMediaRule::insertRule(const String& rule, unsigned index, ExceptionC
     newRule->setParent(this);
     unsigned returnedIndex = m_lstCSSRules->insertRule(newRule.get(), index);
 
-    // stylesheet() can only return 0 for computed style declarations.
-    stylesheet()->styleSheetChanged();
+    if (stylesheet())
+        stylesheet()->styleSheetChanged();
 
     return returnedIndex;
 }
@@ -105,8 +105,8 @@ void CSSMediaRule::deleteRule(unsigned index, ExceptionCode& ec)
 
     m_lstCSSRules->deleteRule(index);
 
-    // stylesheet() can only return 0 for computed style declarations.
-    stylesheet()->styleSheetChanged();
+    if (stylesheet())
+        stylesheet()->styleSheetChanged();
 }
 
 String CSSMediaRule::cssText() const
diff --git a/Source/WebCore/css/CSSStyleSheet.cpp b/Source/WebCore/css/CSSStyleSheet.cpp
index d5487a1..16c2ba8 100644
--- a/Source/WebCore/css/CSSStyleSheet.cpp
+++ b/Source/WebCore/css/CSSStyleSheet.cpp
@@ -53,7 +53,6 @@ static bool isAcceptableCSSStyleSheetParent(Node* parentNode)
 
 CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const KURL& baseURL, const String& charset)
     : StyleSheet(parentSheet, href, baseURL)
-    , m_document(parentSheet ? parentSheet->document() : 0)
     , m_charset(charset)
     , m_loadCompleted(false)
     , m_strictParsing(!parentSheet || parentSheet->useStrictParsing())
@@ -64,7 +63,6 @@ CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, con
 
 CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const KURL& baseURL, const String& charset)
     : StyleSheet(parentNode, href, baseURL)
-    , m_document(parentNode->document())
     , m_charset(charset)
     , m_loadCompleted(false)
     , m_strictParsing(false)
@@ -82,7 +80,6 @@ CSSStyleSheet::CSSStyleSheet(CSSRule* ownerRule, const String& href, const KURL&
     , m_hasSyntacticallyValidCSSHeader(true)
 {
     CSSStyleSheet* parentSheet = ownerRule ? ownerRule->parentStyleSheet() : 0;
-    m_document = parentSheet ? parentSheet->document() : 0;
     m_isUserStyleSheet = parentSheet ? parentSheet->isUserStyleSheet() : false;
 }
 
@@ -233,6 +230,24 @@ void CSSStyleSheet::checkLoaded()
     m_loadCompleted = ownerNode() ? ownerNode()->sheetLoaded() : true;
 }
 
+Document* CSSStyleSheet::document()
+{
+    StyleBase* styleObject = this;
+    while (styleObject) {
+        if (styleObject->isCSSStyleSheet()) {
+            Node* ownerNode = static_cast<CSSStyleSheet*>(styleObject)->ownerNode();
+            if (ownerNode)
+                return ownerNode->document();
+        }
+        if (styleObject->isRule())
+            styleObject = static_cast<CSSRule*>(styleObject)->parentStyleSheet();
+        else
+            styleObject = styleObject->parent();
+    }
+
+    return 0;
+}
+
 void CSSStyleSheet::styleSheetChanged()
 {
     StyleBase* root = this;
diff --git a/Source/WebCore/css/CSSStyleSheet.h b/Source/WebCore/css/CSSStyleSheet.h
index 725518f..062886a 100644
--- a/Source/WebCore/css/CSSStyleSheet.h
+++ b/Source/WebCore/css/CSSStyleSheet.h
@@ -87,7 +87,7 @@ public:
 
     virtual void checkLoaded();
 
-    Document* document() { return m_document; }
+    Document* document();
 
     const String& charset() const { return m_charset; }
 
@@ -112,7 +112,6 @@ private:
     virtual bool isCSSStyleSheet() const { return true; }
     virtual String type() const { return "text/css"; }
 
-    Document* m_document;
     OwnPtr<CSSNamespace> m_namespaces;
     String m_charset;
     bool m_loadCompleted : 1;
diff --git a/Source/WebCore/xml/XSLStyleSheet.h b/Source/WebCore/xml/XSLStyleSheet.h
index 4312771..b36ac1d 100644
--- a/Source/WebCore/xml/XSLStyleSheet.h
+++ b/Source/WebCore/xml/XSLStyleSheet.h
@@ -79,7 +79,8 @@ public:
 
     CachedResourceLoader* cachedResourceLoader();
 
-    Document* ownerDocument() { return m_ownerDocument; }
+    Document* ownerDocument();
+    XSLStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; }
     void setParentStyleSheet(XSLStyleSheet* parent);
 
 #if USE(QXMLQUERY)
diff --git a/Source/WebCore/xml/XSLStyleSheetLibxslt.cpp b/Source/WebCore/xml/XSLStyleSheetLibxslt.cpp
index eb735f4..a519023 100644
--- a/Source/WebCore/xml/XSLStyleSheetLibxslt.cpp
+++ b/Source/WebCore/xml/XSLStyleSheetLibxslt.cpp
@@ -56,7 +56,6 @@ namespace WebCore {
 
 XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& originalURL, const KURL& finalURL)
     : StyleSheet(parentRule, originalURL, finalURL)
-    , m_ownerDocument(0)
     , m_embedded(false)
     , m_processed(false) // Child sheets get marked as processed when the libxslt engine has finally seen them.
     , m_stylesheetDoc(0)
@@ -67,7 +66,6 @@ XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& originalUR
 
 XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL,  bool embedded)
     : StyleSheet(parentNode, originalURL, finalURL)
-    , m_ownerDocument(parentNode->document())
     , m_embedded(embedded)
     , m_processed(true) // The root sheet starts off processed.
     , m_stylesheetDoc(0)
@@ -129,9 +127,10 @@ void XSLStyleSheet::clearDocuments()
 
 CachedResourceLoader* XSLStyleSheet::cachedResourceLoader()
 {
-    if (!m_ownerDocument)
+    Document* document = ownerDocument();
+    if (!document)
         return 0;
-    return m_ownerDocument->cachedResourceLoader();
+    return document->cachedResourceLoader();
 }
 
 bool XSLStyleSheet::parseString(const String& string, bool)
@@ -257,8 +256,16 @@ xsltStylesheetPtr XSLStyleSheet::compileStyleSheet()
 void XSLStyleSheet::setParentStyleSheet(XSLStyleSheet* parent)
 {
     m_parentStyleSheet = parent;
-    if (parent)
-        m_ownerDocument = parent->ownerDocument();
+}
+
+Document* XSLStyleSheet::ownerDocument()
+{
+    for (XSLStyleSheet* styleSheet = this; styleSheet; styleSheet = styleSheet->parentStyleSheet()) {
+        Node* node = styleSheet->ownerNode();
+        if (node)
+            return node->document();
+    }
+    return 0;
 }
 
 xmlDocPtr XSLStyleSheet::locateStylesheetSubResource(xmlDocPtr parentDoc, const xmlChar* uri)
diff --git a/Source/WebCore/xml/XSLStyleSheetQt.cpp b/Source/WebCore/xml/XSLStyleSheetQt.cpp
index 855d6ba..6026285 100644
--- a/Source/WebCore/xml/XSLStyleSheetQt.cpp
+++ b/Source/WebCore/xml/XSLStyleSheetQt.cpp
@@ -34,7 +34,6 @@ namespace WebCore {
 
 XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL,  bool embedded)
     : StyleSheet(parentNode, originalURL, finalURL)
-    , m_ownerDocument(parentNode->document())
     , m_embedded(embedded)
 {
 }
@@ -62,9 +61,10 @@ void XSLStyleSheet::clearDocuments()
 
 CachedResourceLoader* XSLStyleSheet::cachedResourceLoader()
 {
-    if (!m_ownerDocument)
+    Document* document = ownerDocument();
+    if (!document)
         return 0;
-    return m_ownerDocument->cachedResourceLoader();
+    return document->cachedResourceLoader();
 }
 
 bool XSLStyleSheet::parseString(const String& string, bool)
@@ -87,6 +87,12 @@ void XSLStyleSheet::loadChildSheet(const String&)
     notImplemented();
 }
 
+Document* XSLStyleSheet::ownerDocument()
+{
+    Node* node = ownerNode();
+    return node ? node->document() : 0;
+}
+
 void XSLStyleSheet::setParentStyleSheet(XSLStyleSheet*)
 {
     notImplemented();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list