WebKit/win part of <rdar://problem/5336005> Calling window.print() on a subframe...
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jul 2007 22:01:35 +0000 (22:01 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jul 2007 22:01:35 +0000 (22:01 +0000)
WebKit/win:

        WebKit/win part of <rdar://problem/5336005> Calling window.print() on a subframe prints whole page, should only print that subframe

        Reviewed by Darin.

        * Interfaces/IWebUIDelegate.idl: Rename print to printFrame to closer
        match the Mac method, and copy more of the Mac API comments.
        * WebChromeClient.cpp:
        (WebChromeClient::print): Call printFrame instead of print.

WebCore:

        Added a manual test to test calling window.print on a subframe.

        Reviewed by Darin.

        * manual-tests/resources/print-subframe.html: Added.
        * manual-tests/window-print-subframe.html: Added.

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

WebCore/ChangeLog
WebCore/manual-tests/resources/print-subframe.html [new file with mode: 0755]
WebCore/manual-tests/window-print-subframe.html [new file with mode: 0755]
WebKit/win/ChangeLog
WebKit/win/Interfaces/IWebUIDelegate.idl
WebKit/win/WebChromeClient.cpp

index 5929cc571a6db4279c4381214b531305be3f874f..b90e5d7dc7b822ae28cbb447b60e86c062c89ce0 100644 (file)
@@ -1,3 +1,12 @@
+2007-07-16  Adam Roben  <aroben@apple.com>
+
+        Added a manual test to test calling window.print on a subframe.
+
+        Reviewed by Darin.
+
+        * manual-tests/resources/print-subframe.html: Added.
+        * manual-tests/window-print-subframe.html: Added.
+
 2007-07-16  Adam Roben  <aroben@apple.com>
 
         Replace Frame::print with Chrome::print
diff --git a/WebCore/manual-tests/resources/print-subframe.html b/WebCore/manual-tests/resources/print-subframe.html
new file mode 100755 (executable)
index 0000000..272b684
--- /dev/null
@@ -0,0 +1 @@
+<p>This text in the subframe should be printed.</p>
diff --git a/WebCore/manual-tests/window-print-subframe.html b/WebCore/manual-tests/window-print-subframe.html
new file mode 100755 (executable)
index 0000000..39047b3
--- /dev/null
@@ -0,0 +1,5 @@
+<script>
+    window.onload = function() { frames[0].print(); }
+</script>
+<p>This text in the main frame should not be printed.</p>
+<iframe src="resources/print-subframe.html">
index 98c8e50ea0958401d1fb9d550447fe12ebb3283c..1810709776bb4b43bf17866d2648f11dd03302a6 100644 (file)
@@ -1,3 +1,14 @@
+2007-07-16  Adam Roben  <aroben@apple.com>
+
+        WebKit/win part of <rdar://problem/5336005> Calling window.print() on a subframe prints whole page, should only print that subframe
+
+        Reviewed by Darin.
+
+        * Interfaces/IWebUIDelegate.idl: Rename print to printFrame to closer
+        match the Mac method, and copy more of the Mac API comments.
+        * WebChromeClient.cpp:
+        (WebChromeClient::print): Call printFrame instead of print.
+
 2007-07-16  Adam Roben  <aroben@apple.com>
 
         Updated WebChromeClient for ChromeClient changes.
index 93b36b27e76dd70cc2077ee5a5a4e51d82684f34..8dd773136a90eef3e9bc39a31168616ec9f6111a 100644 (file)
@@ -716,11 +716,14 @@ interface IWebUIDelegate : IUnknown
 ]
 interface IWebUIDelegate2 : IWebUIDelegate
 {
-    /*!
-        @method print:
-        @abstract Informs that a WebView needs to be printed
-        @param webView The WebView sending the delegate method and whose mainFrame needs to be printed
-    */
-    HRESULT print([in] IWebView* webView);
+/*!
+    @method webView:printFrame:
+    @abstract Informs that a WebFrame needs to be printed
+    @param webView The WebView sending the delegate method
+    @param frame The WebFrame needing to be printed
+    @discussion This method is called when a script or user requests the page to be printed.
+    In this method the delegate can prepare the WebFrame to be printed.
+*/
+    HRESULT printFrame([in] IWebView* webView, [in] IWebFrame* frame);
 
 }
index b81c00023229693614f5acb1e0bd5567984daba8..3a4520e29467ca91ce68ee23b97e0094b0f47c33 100644 (file)
@@ -443,12 +443,11 @@ void WebChromeClient::setToolTip(const String& toolTip)
     m_webView->setToolTip(toolTip);
 }
 
-void WebChromeClient::print(Frame*)
+void WebChromeClient::print(Frame* frame)
 {
     COMPtr<IWebUIDelegate> uiDelegate;
     COMPtr<IWebUIDelegate2> uiDelegate2;
-    if (SUCCEEDED(m_webView->uiDelegate(&uiDelegate))) {
-        if (SUCCEEDED(uiDelegate->QueryInterface(IID_IWebUIDelegate2, (void**) &uiDelegate2)) && uiDelegate2)
-            uiDelegate2->print(m_webView);
-    }
+    if (SUCCEEDED(m_webView->uiDelegate(&uiDelegate)))
+        if (SUCCEEDED(uiDelegate->QueryInterface(IID_IWebUIDelegate2, (void**)&uiDelegate2)))
+            uiDelegate2->printFrame(m_webView, kit(frame));
 }