Title: [95548] trunk
Revision
95548
Author
commit-qu...@webkit.org
Date
2011-09-20 09:41:59 -0700 (Tue, 20 Sep 2011)

Log Message

Source/WebCore: [Qt] Permit qrc resources to load in QWebSettings::setUserStyleSheetUrl()
https://bugs.webkit.org/show_bug.cgi?id=51159

Permit any URL with a local scheme to set a user style sheet. Allow qrc
resource URLs as arguments to QWebSettings::setUserStyleSheetUrl().

Patch by Jarred Nicholls <jar...@sencha.com> on 2011-09-20
Reviewed by Kenneth Rohde Christiansen.

* page/Page.cpp:
(WebCore::Page::userStyleSheetLocationChanged):
* platform/qt/KURLQt.cpp:
(WebCore::KURL::fileSystemPath):

Source/WebKit/qt: [Qt] Permit qrc resources to load in QWebSettings::setUserStyleSheetUrl()
https://bugs.webkit.org/show_bug.cgi?id=51159

Permit any URL with a local scheme to set a user style sheet. Allow qrc
resource URLs as arguments to QWebSettings::setUserStyleSheetUrl().

New test case makes sure a qrc URL will properly load a user stylesheet.

Patch by Jarred Nicholls <jar...@sencha.com> on 2011-09-20
Reviewed by Kenneth Rohde Christiansen.

(tst_QWebPage::userStyleSheetFromQrcUrl):
* tests/qwebpage/tst_qwebpage.qrc:

Tools: [Qt] Permit qrc resources to load in QWebSettings::setUserStyleSheetUrl()
https://bugs.webkit.org/show_bug.cgi?id=51159

Permit any URL with a local scheme to set a user style sheet. Allow qrc
resource URLs as arguments to QWebSettings::setUserStyleSheetUrl().

Add DRT/WKTR qrc resource to test loading user style sheets from a qrc URL.

Patch by Jarred Nicholls <jar...@sencha.com> on 2011-09-20
Reviewed by Kenneth Rohde Christiansen.

* DumpRenderTree/qt/DumpRenderTree.pro:
* DumpRenderTree/qt/DumpRenderTree.qrc: Added.
* DumpRenderTree/qt/resources/user.css: Added.
(body):
* WebKitTestRunner/qt/WebKitTestRunner.pro:
* WebKitTestRunner/qt/WebKitTestRunner.qrc: Added.
* WebKitTestRunner/qt/resources/user.css: Added.
(body):

LayoutTests: [Qt] Permit qrc resources to load in QWebSettings::setUserStyleSheetUrl()
https://bugs.webkit.org/show_bug.cgi?id=51159

Permit any URL with a local scheme to set a user style sheet. Allow qrc
resource URLs as arguments to QWebSettings::setUserStyleSheetUrl().

New platform layout test since user style sheet is testable from DRT.

Patch by Jarred Nicholls <jar...@sencha.com> on 2011-09-20
Reviewed by Kenneth Rohde Christiansen.

* platform/qt/fast/loader/user-stylesheet-qrc-path-expected.txt: Added.
* platform/qt/fast/loader/user-stylesheet-qrc-path.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (95547 => 95548)


--- trunk/LayoutTests/ChangeLog	2011-09-20 16:31:16 UTC (rev 95547)
+++ trunk/LayoutTests/ChangeLog	2011-09-20 16:41:59 UTC (rev 95548)
@@ -1,3 +1,18 @@
+2011-09-20  Jarred Nicholls  <jar...@sencha.com>
+
+        [Qt] Permit qrc resources to load in QWebSettings::setUserStyleSheetUrl()
+        https://bugs.webkit.org/show_bug.cgi?id=51159
+
+        Permit any URL with a local scheme to set a user style sheet. Allow qrc
+        resource URLs as arguments to QWebSettings::setUserStyleSheetUrl().
+
+        New platform layout test since user style sheet is testable from DRT.
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * platform/qt/fast/loader/user-stylesheet-qrc-path-expected.txt: Added.
+        * platform/qt/fast/loader/user-stylesheet-qrc-path.html: Added.
+
 2011-09-20  Dmitry Lomov  <dslo...@google.com>
 
         [Chromium] Rebaseline expectationd and file WK68445.

Added: trunk/LayoutTests/platform/qt/fast/loader/user-stylesheet-qrc-path-expected.txt (0 => 95548)


--- trunk/LayoutTests/platform/qt/fast/loader/user-stylesheet-qrc-path-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/qt/fast/loader/user-stylesheet-qrc-path-expected.txt	2011-09-20 16:41:59 UTC (rev 95548)
@@ -0,0 +1,3 @@
+This tests that a qrc URL is properly loaded as a user style sheet.
+
+PASS 50px rgb(255, 255, 0)

Added: trunk/LayoutTests/platform/qt/fast/loader/user-stylesheet-qrc-path.html (0 => 95548)


--- trunk/LayoutTests/platform/qt/fast/loader/user-stylesheet-qrc-path.html	                        (rev 0)
+++ trunk/LayoutTests/platform/qt/fast/loader/user-stylesheet-qrc-path.html	2011-09-20 16:41:59 UTC (rev 95548)
@@ -0,0 +1,18 @@
+<p>
+    This tests that a qrc URL is properly loaded as a user style sheet.
+</p>
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.setUserStyleSheetEnabled(true);
+        layoutTestController.setUserStyleSheetLocation('qrc:///resources/user.css');
+        
+        var computedStyle = getComputedStyle(document.body),
+            result = computedStyle.fontSize == '50px' && computedStyle.backgroundColor == 'rgb(255, 255, 0)',
+            message = (result ? 'PASS' : 'FAIL') + ' ' + computedStyle.fontSize + ' ' + computedStyle.backgroundColor;
+
+        document.write(message);
+    } else {
+        document.write("This test can only be run in DumpRenderTree.");
+    }
+</script>

Modified: trunk/Source/WebCore/ChangeLog (95547 => 95548)


--- trunk/Source/WebCore/ChangeLog	2011-09-20 16:31:16 UTC (rev 95547)
+++ trunk/Source/WebCore/ChangeLog	2011-09-20 16:41:59 UTC (rev 95548)
@@ -1,3 +1,18 @@
+2011-09-20  Jarred Nicholls  <jar...@sencha.com>
+
+        [Qt] Permit qrc resources to load in QWebSettings::setUserStyleSheetUrl()
+        https://bugs.webkit.org/show_bug.cgi?id=51159
+        
+        Permit any URL with a local scheme to set a user style sheet. Allow qrc
+        resource URLs as arguments to QWebSettings::setUserStyleSheetUrl().
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * page/Page.cpp:
+        (WebCore::Page::userStyleSheetLocationChanged):
+        * platform/qt/KURLQt.cpp:
+        (WebCore::KURL::fileSystemPath):
+
 2011-09-20  Csaba Osztrogonác  <o...@webkit.org>
 
         [Qt][Mac] Buildfix after r95513.

Modified: trunk/Source/WebCore/page/Page.cpp (95547 => 95548)


--- trunk/Source/WebCore/page/Page.cpp	2011-09-20 16:31:16 UTC (rev 95547)
+++ trunk/Source/WebCore/page/Page.cpp	2011-09-20 16:41:59 UTC (rev 95548)
@@ -63,6 +63,7 @@
 #include "RenderTheme.h"
 #include "RenderWidget.h"
 #include "RuntimeEnabledFeatures.h"
+#include "SchemeRegistry.h"
 #include "Settings.h"
 #include "SharedBuffer.h"
 #include "SpeechInput.h"
@@ -686,7 +687,9 @@
     // FIXME: Eventually we will move to a model of just being handed the sheet
     // text instead of loading the URL ourselves.
     KURL url = ""
-    if (url.isLocalFile())
+    
+    // Allow any local file URL scheme to be loaded.
+    if (SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol()))
         m_userStyleSheetPath = url.fileSystemPath();
     else
         m_userStyleSheetPath = String();

Modified: trunk/Source/WebCore/platform/qt/KURLQt.cpp (95547 => 95548)


--- trunk/Source/WebCore/platform/qt/KURLQt.cpp	2011-09-20 16:31:16 UTC (rev 95547)
+++ trunk/Source/WebCore/platform/qt/KURLQt.cpp	2011-09-20 16:41:59 UTC (rev 95548)
@@ -43,10 +43,17 @@
 
 String KURL::fileSystemPath() const
 {
-    if (!isValid() || !protocolIs("file"))
+    if (!isValid())
         return String();
 
-    return static_cast<QUrl>(*this).toLocalFile();
+    if (isLocalFile())
+        return static_cast<QUrl>(*this).toLocalFile();
+
+    // A valid qrc resource path begins with a colon.
+    if (protocolIs("qrc"))
+        return ":" + path();
+
+    return String();
 }
 
 }

Modified: trunk/Source/WebKit/qt/ChangeLog (95547 => 95548)


--- trunk/Source/WebKit/qt/ChangeLog	2011-09-20 16:31:16 UTC (rev 95547)
+++ trunk/Source/WebKit/qt/ChangeLog	2011-09-20 16:41:59 UTC (rev 95548)
@@ -1,3 +1,18 @@
+2011-09-20  Jarred Nicholls  <jar...@sencha.com>
+
+        [Qt] Permit qrc resources to load in QWebSettings::setUserStyleSheetUrl()
+        https://bugs.webkit.org/show_bug.cgi?id=51159
+        
+        Permit any URL with a local scheme to set a user style sheet. Allow qrc
+        resource URLs as arguments to QWebSettings::setUserStyleSheetUrl().
+        
+        New test case makes sure a qrc URL will properly load a user stylesheet.
+
+        Reviewed by Kenneth Rohde Christiansen.
+        
+        (tst_QWebPage::userStyleSheetFromQrcUrl):
+        * tests/qwebpage/tst_qwebpage.qrc:
+
 2011-09-20  Adenilson Cavalcanti  <adenilson.si...@openbossa.org>
 
         [Qt] resizeToContent seems to trigger infinite resize on some pages

Modified: trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp (95547 => 95548)


--- trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp	2011-09-20 16:31:16 UTC (rev 95547)
+++ trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp	2011-09-20 16:41:59 UTC (rev 95548)
@@ -103,6 +103,7 @@
     void acceptNavigationRequestWithNewWindow();
     void userStyleSheet();
     void userStyleSheetFromLocalFileUrl();
+    void userStyleSheetFromQrcUrl();
     void loadHtml5Video();
     void modified();
     void contextMenuCrash();
@@ -504,6 +505,19 @@
     QCOMPARE(networkManager->requestedUrls.at(0), QUrl("http://does.not/exist.png"));
 }
 
+void tst_QWebPage::userStyleSheetFromQrcUrl()
+{
+    TestNetworkManager* networkManager = new TestNetworkManager(m_page);
+    m_page->setNetworkAccessManager(networkManager);
+
+    m_page->settings()->setUserStyleSheetUrl(QUrl("qrc:///resources/user.css"));
+    m_view->setHtml("<p>hello world</p>");
+    QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool))));
+
+    QVERIFY(networkManager->requestedUrls.count() >= 1);
+    QCOMPARE(networkManager->requestedUrls.at(0), QUrl("http://does.not/exist.png"));
+}
+
 void tst_QWebPage::loadHtml5Video()
 {
 #if defined(WTF_USE_QT_MULTIMEDIA) && WTF_USE_QT_MULTIMEDIA

Modified: trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.qrc (95547 => 95548)


--- trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.qrc	2011-09-20 16:31:16 UTC (rev 95547)
+++ trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.qrc	2011-09-20 16:41:59 UTC (rev 95548)
@@ -9,6 +9,7 @@
     <file>resources/framedindex.html</file>
     <file>resources/content.html</file>
     <file>resources/script.html</file>
+    <file>resources/user.css</file>
 </qresource>
 </RCC>
 

Modified: trunk/Tools/ChangeLog (95547 => 95548)


--- trunk/Tools/ChangeLog	2011-09-20 16:31:16 UTC (rev 95547)
+++ trunk/Tools/ChangeLog	2011-09-20 16:41:59 UTC (rev 95548)
@@ -1,3 +1,24 @@
+2011-09-20  Jarred Nicholls  <jar...@sencha.com>
+
+        [Qt] Permit qrc resources to load in QWebSettings::setUserStyleSheetUrl()
+        https://bugs.webkit.org/show_bug.cgi?id=51159
+
+        Permit any URL with a local scheme to set a user style sheet. Allow qrc
+        resource URLs as arguments to QWebSettings::setUserStyleSheetUrl().
+        
+        Add DRT/WKTR qrc resource to test loading user style sheets from a qrc URL.
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * DumpRenderTree/qt/DumpRenderTree.pro:
+        * DumpRenderTree/qt/DumpRenderTree.qrc: Added.
+        * DumpRenderTree/qt/resources/user.css: Added.
+        (body):
+        * WebKitTestRunner/qt/WebKitTestRunner.pro:
+        * WebKitTestRunner/qt/WebKitTestRunner.qrc: Added.
+        * WebKitTestRunner/qt/resources/user.css: Added.
+        (body):
+
 2011-09-20  Leandro Pereira  <lean...@profusion.mobi>
 
         ChangeLogEntry class should contain a list of touched files

Modified: trunk/Tools/DumpRenderTree/qt/DumpRenderTree.pro (95547 => 95548)


--- trunk/Tools/DumpRenderTree/qt/DumpRenderTree.pro	2011-09-20 16:31:16 UTC (rev 95547)
+++ trunk/Tools/DumpRenderTree/qt/DumpRenderTree.pro	2011-09-20 16:41:59 UTC (rev 95548)
@@ -53,3 +53,5 @@
 
 DEFINES += USE_SYSTEM_MALLOC=1
 DEFINES -= QT_ASCII_CAST_WARNINGS
+
+RESOURCES = DumpRenderTree.qrc
\ No newline at end of file

Added: trunk/Tools/DumpRenderTree/qt/DumpRenderTree.qrc (0 => 95548)


--- trunk/Tools/DumpRenderTree/qt/DumpRenderTree.qrc	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/qt/DumpRenderTree.qrc	2011-09-20 16:41:59 UTC (rev 95548)
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/">
+        <file>resources/user.css</file>
+    </qresource>
+</RCC>

Added: trunk/Tools/DumpRenderTree/qt/resources/user.css (0 => 95548)


--- trunk/Tools/DumpRenderTree/qt/resources/user.css	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/qt/resources/user.css	2011-09-20 16:41:59 UTC (rev 95548)
@@ -0,0 +1,4 @@
+body {
+    font-size: 50px;
+    background-color: rgb(255, 255, 0);
+}
\ No newline at end of file

Modified: trunk/Tools/WebKitTestRunner/qt/WebKitTestRunner.pro (95547 => 95548)


--- trunk/Tools/WebKitTestRunner/qt/WebKitTestRunner.pro	2011-09-20 16:31:16 UTC (rev 95547)
+++ trunk/Tools/WebKitTestRunner/qt/WebKitTestRunner.pro	2011-09-20 16:41:59 UTC (rev 95548)
@@ -65,3 +65,5 @@
 
 include(../../../Source/_javascript_Core/_javascript_Core.pri)
 prependJavaScriptCoreLib(../../_javascript_Core)
+
+RESOURCES = WebKitTestRunner.qrc
\ No newline at end of file

Added: trunk/Tools/WebKitTestRunner/qt/WebKitTestRunner.qrc (0 => 95548)


--- trunk/Tools/WebKitTestRunner/qt/WebKitTestRunner.qrc	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/qt/WebKitTestRunner.qrc	2011-09-20 16:41:59 UTC (rev 95548)
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/">
+        <file>resources/user.css</file>
+    </qresource>
+</RCC>

Added: trunk/Tools/WebKitTestRunner/qt/resources/user.css (0 => 95548)


--- trunk/Tools/WebKitTestRunner/qt/resources/user.css	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/qt/resources/user.css	2011-09-20 16:41:59 UTC (rev 95548)
@@ -0,0 +1,4 @@
+body {
+    font-size: 50px;
+    background-color: rgb(255, 255, 0);
+}
\ No newline at end of file
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to