[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

mitz at apple.com mitz at apple.com
Fri Feb 26 22:25:18 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 149d61d3a54a47bf306da7b7f3a16c9502143f58
Author: mitz at apple.com <mitz at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Feb 19 00:19:48 2010 +0000

    <rdar://problem/7658811> Multiple style recalcs due to getComputedStyle() on “display: none;” element
    when there are pending style sheets
    
    Reviewed by John Sullivan.
    
    WebCore:
    
    Test: fast/css/getComputedStyle/pending-stylesheet.html
    
    When querying a property of a computed style declaration for a non-rendered element,
    CSSStyleSelector::styleForElement() was called, and if there were pending style sheet, it
    would behave as if the lack of renderer is due to FOUC suppression, and set a flag on
    the document causing it to recalculate style. On the next computed style property access,
    style would be recalculated for the document, but then the flag would get set again if the
    element did not have a renderer.
    
    * dom/Document.cpp:
    (WebCore::Document::styleForElementIgnoringPendingStylesheets): Added. Temporarily sets
    m_ignorePendingStylesheets around the call to CSSStyleSelector::styleForElement().
    * dom/Document.h:
    * dom/Element.cpp:
    (WebCore::Element::computedStyle): Use Document::styleForElementIgnoringPendingStylesheets().
    
    LayoutTests:
    
    * fast/css/getComputedStyle/pending-stylesheet-expected.txt: Added.
    * fast/css/getComputedStyle/pending-stylesheet.html: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54992 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 7557608..fe3d6a4 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-02-18  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by John Sullivan.
+
+        <rdar://problem/7658811> Multiple style recalcs due to getComputedStyle() on “display: none;” element
+        when there are pending style sheets
+
+        * fast/css/getComputedStyle/pending-stylesheet-expected.txt: Added.
+        * fast/css/getComputedStyle/pending-stylesheet.html: Added.
+
 2010-02-18  Dirk Schulze  <krit at webkit.org>
 
         Reviewed by Nikolas Zimmermann.
diff --git a/LayoutTests/fast/css/getComputedStyle/pending-stylesheet-expected.txt b/LayoutTests/fast/css/getComputedStyle/pending-stylesheet-expected.txt
new file mode 100644
index 0000000..9c9632e
--- /dev/null
+++ b/LayoutTests/fast/css/getComputedStyle/pending-stylesheet-expected.txt
@@ -0,0 +1,3 @@
+Test the behavior of getComputedStyle when it is called on an element with display: none; while there are pending style sheets.
+
+PASS
diff --git a/LayoutTests/fast/css/getComputedStyle/pending-stylesheet.html b/LayoutTests/fast/css/getComputedStyle/pending-stylesheet.html
new file mode 100644
index 0000000..f071f65
--- /dev/null
+++ b/LayoutTests/fast/css/getComputedStyle/pending-stylesheet.html
@@ -0,0 +1,14 @@
+<p>
+    Test the behavior of <tt>getComputedStyle</tt> when it is called on an element with
+    <tt>display: none;</tt> while there are pending style sheets.
+</p>
+<link rel="stylesheet" href="data:text/css,">
+<div id="target" style="display: none; width: 100px; height: 100px;"></div>
+<div id="result"></div>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    var computedWidth = getComputedStyle(document.getElementById("target")).width;
+    document.getElementById("result").innerText = computedWidth === "100px" ? "PASS" : "FAIL"
+</script>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 5028ba8..ff0dff2 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2010-02-18  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by John Sullivan.
+
+        <rdar://problem/7658811> Multiple style recalcs due to getComputedStyle() on “display: none;” element
+        when there are pending style sheets
+
+        Test: fast/css/getComputedStyle/pending-stylesheet.html
+
+        When querying a property of a computed style declaration for a non-rendered element,
+        CSSStyleSelector::styleForElement() was called, and if there were pending style sheet, it
+        would behave as if the lack of renderer is due to FOUC suppression, and set a flag on
+        the document causing it to recalculate style. On the next computed style property access,
+        style would be recalculated for the document, but then the flag would get set again if the
+        element did not have a renderer.
+
+        * dom/Document.cpp:
+        (WebCore::Document::styleForElementIgnoringPendingStylesheets): Added. Temporarily sets
+        m_ignorePendingStylesheets around the call to CSSStyleSelector::styleForElement().
+        * dom/Document.h:
+        * dom/Element.cpp:
+        (WebCore::Element::computedStyle): Use Document::styleForElementIgnoringPendingStylesheets().
+
 2010-02-18  Dirk Schulze  <krit at webkit.org>
 
         Reviewed by Nikolas Zimmermann.
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 69a39d1..d0fe75f 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -1462,6 +1462,17 @@ void Document::updateLayoutIgnorePendingStylesheets()
     m_ignorePendingStylesheets = oldIgnore;
 }
 
+PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Element* element)
+{
+    ASSERT_ARG(element, element->document() == this);
+
+    bool oldIgnore = m_ignorePendingStylesheets;
+    m_ignorePendingStylesheets = true;
+    RefPtr<RenderStyle> style = styleSelector()->styleForElement(element, element->parent() ? element->parent()->computedStyle() : 0);
+    m_ignorePendingStylesheets = oldIgnore;
+    return style.release();
+}
+
 void Document::createStyleSelector()
 {
     bool matchAuthorAndUserStyles = true;
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h
index 7352fda..e8b3e6e 100644
--- a/WebCore/dom/Document.h
+++ b/WebCore/dom/Document.h
@@ -469,6 +469,7 @@ public:
     virtual void updateStyleIfNeeded();
     void updateLayout();
     void updateLayoutIgnorePendingStylesheets();
+    PassRefPtr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element*);
     static void updateStyleForAllDocuments(); // FIXME: Try to reduce the # of calls to this function.
     DocLoader* docLoader() { return m_docLoader.get(); }
 
diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp
index 0a1bc75..9e4b48d 100644
--- a/WebCore/dom/Element.cpp
+++ b/WebCore/dom/Element.cpp
@@ -1359,7 +1359,7 @@ RenderStyle* Element::computedStyle()
 
     ElementRareData* data = ensureRareData();
     if (!data->m_computedStyle)
-        data->m_computedStyle = document()->styleSelector()->styleForElement(this, parent() ? parent()->computedStyle() : 0);
+        data->m_computedStyle = document()->styleForElementIgnoringPendingStylesheets(this);
     return data->m_computedStyle.get();
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list