LayoutTests:
authorantti <antti@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jul 2007 23:26:48 +0000 (23:26 +0000)
committerantti <antti@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jul 2007 23:26:48 +0000 (23:26 +0000)
        Reviewed by Darin.

        HTTP test for <rdar://problem/5305788>
        REGRESSION: Safari sometimes loads IE-specific stylesheet on www.apaema.org

        Test that order style sheets arrive has no impact to selection of preferred style sheet set.

        * http/tests/local/fail.css: Added.
        * http/tests/local/link-stylesheet-preferred-expected.txt: Added.
        * http/tests/local/link-stylesheet-preferred.html: Added.
        * http/tests/local/slow-css-pass.cgi: Added.

WebCore:

        Reviewed by Darin.

        Fix <rdar://problem/5305788>
        REGRESSION: Safari sometimes loads IE-specific stylesheet on www.apaema.org

        Pick the preferred style sheet set based on document order even if the sheet is still loading. Previously
        the set was chosen based on which stylesheet happened to arrive first. Just fix the problem at hand
        and resist urge to start refactoring this function.

        * dom/Document.cpp:
        (WebCore::Document::recalcStyleSelector):

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

LayoutTests/ChangeLog
LayoutTests/http/tests/local/fail.css [new file with mode: 0644]
LayoutTests/http/tests/local/link-stylesheet-preferred-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/local/link-stylesheet-preferred.html [new file with mode: 0644]
LayoutTests/http/tests/local/slow-css-pass.cgi [new file with mode: 0755]
WebCore/ChangeLog
WebCore/dom/Document.cpp

index 77b2ba5..9e96fa5 100644 (file)
@@ -1,3 +1,17 @@
+2007-07-21  Antti  <antti@apple.com>
+
+        Reviewed by Darin.
+        
+        HTTP test for <rdar://problem/5305788>
+        REGRESSION: Safari sometimes loads IE-specific stylesheet on www.apaema.org
+        
+        Test that order style sheets arrive has no impact to selection of preferred style sheet set.
+
+        * http/tests/local/fail.css: Added.
+        * http/tests/local/link-stylesheet-preferred-expected.txt: Added.
+        * http/tests/local/link-stylesheet-preferred.html: Added.
+        * http/tests/local/slow-css-pass.cgi: Added.
+
 2007-07-20  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Darin.
diff --git a/LayoutTests/http/tests/local/fail.css b/LayoutTests/http/tests/local/fail.css
new file mode 100644 (file)
index 0000000..b305c65
--- /dev/null
@@ -0,0 +1,2 @@
+#fail { display: inline }
+#pass { display: none }
\ No newline at end of file
diff --git a/LayoutTests/http/tests/local/link-stylesheet-preferred-expected.txt b/LayoutTests/http/tests/local/link-stylesheet-preferred-expected.txt
new file mode 100644 (file)
index 0000000..8dbd1b0
--- /dev/null
@@ -0,0 +1,3 @@
+Test that load order of stylesheets does not affect resolution of preferred style sheet set. This test works only as DRT HTTP test.
+
+PASS
diff --git a/LayoutTests/http/tests/local/link-stylesheet-preferred.html b/LayoutTests/http/tests/local/link-stylesheet-preferred.html
new file mode 100644 (file)
index 0000000..88a33ad
--- /dev/null
@@ -0,0 +1,17 @@
+<html>
+<head>
+    <script>  
+        if (window.layoutTestController)
+            layoutTestController.dumpAsText();
+    </script>
+    <style>
+        #pass { display: none }
+    </style>
+    <link rel=stylesheet title=thisSetShouldBeSelected href="http://127.0.0.1:8000/local/slow-css-pass.cgi">
+    <link rel=stylesheet title=thisSetShouldNotBeSelected href="fail.css">
+</head>
+<body>
+<p>Test that load order of stylesheets does not affect resolution of preferred style sheet set. This test works only as DRT HTTP test.</p>
+<span id=pass>PASS</span><span id=fail>FAIL</span>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/local/slow-css-pass.cgi b/LayoutTests/http/tests/local/slow-css-pass.cgi
new file mode 100755 (executable)
index 0000000..8f74cd7
--- /dev/null
@@ -0,0 +1,7 @@
+#!/usr/bin/perl -w
+
+print "Content-type: text/css\n\n"; 
+sleep(0.5);
+print "#pass { display: inline }\n";
+print "#fail { display: none }\n";
+
index 1ae6a44..e932c27 100644 (file)
@@ -1,3 +1,17 @@
+2007-07-21  Antti  <antti@apple.com>
+
+        Reviewed by Darin.
+        
+        Fix <rdar://problem/5305788>
+        REGRESSION: Safari sometimes loads IE-specific stylesheet on www.apaema.org
+        
+        Pick the preferred style sheet set based on document order even if the sheet is still loading. Previously 
+        the set was chosen based on which stylesheet happened to arrive first. Just fix the problem at hand 
+        and resist urge to start refactoring this function.
+
+        * dom/Document.cpp:
+        (WebCore::Document::recalcStyleSelector):
+
 2007-07-20  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Darin.
index 331aed0..6461c0d 100644 (file)
@@ -2019,11 +2019,22 @@ void Document::recalcStyleSelector()
             if (e->hasLocalName(linkTag)) {
                 // <LINK> element
                 HTMLLinkElement* l = static_cast<HTMLLinkElement*>(n);
-                if (l->isLoading() || l->isDisabled())
+                if (l->isDisabled())
                     continue;
+                enabledViaScript = l->isEnabledViaScript();
+                if (l->isLoading()) {
+                    // it is loading but we should still decide which style sheet set to use
+                    if (!enabledViaScript && !title.isEmpty() && m_preferredStylesheetSet.isEmpty()) {
+                        const AtomicString& rel = e->getAttribute(relAttr);
+                        if (!rel.domString().contains("alternate")) {
+                            m_preferredStylesheetSet = title;
+                            m_selectedStylesheetSet = title;
+                        }
+                    }
+                    continue;
+                }
                 if (!l->sheet())
                     title = DeprecatedString::null;
-                enabledViaScript = l->isEnabledViaScript();
             }
 
             // Get the current preferred styleset.  This is the