Changeset 89284 in webkit


Ignore:
Timestamp:
Jun 20, 2011 1:22:33 PM (13 years ago)
Author:
kevino@webkit.org
Message:

Reviewed by Kevin Ollivier.

Make showing the dialog optional, and add handling for Javascript print() calls.

https://bugs.webkit.org/show_bug.cgi?id=63008

Location:
trunk/Source/WebKit/wx
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/wx/ChangeLog

    r89274 r89284  
     12011-06-20  Robin Dunn  <robin@alldunn.com>
     2
     3        Reviewed by Kevin Ollivier.
     4
     5        Make showing the dialog optional, and add handling for Javascript print() calls.
     6       
     7        https://bugs.webkit.org/show_bug.cgi?id=63008
     8
     9        * WebFrame.cpp:
     10        (kit):
     11        (wxWebFrame::Print):
     12        * WebFrame.h:
     13        * WebKitSupport/ChromeClientWx.cpp:
     14        (WebCore::ChromeClientWx::print):
     15        * WebKitSupport/FrameLoaderClientWx.h:
     16        (WebCore::FrameLoaderClientWx::webFrame):
     17        (WebCore::FrameLoaderClientWx::webView):
     18        * WebView.cpp:
     19        (wxWebViewPrintFrameEvent::wxWebViewPrintFrameEvent):
     20        * WebView.h:
     21        * bindings/python/webview.i:
     22
    1232011-06-20  Kevin Ollivier  <kevino@theolliviers.com>
    224
  • trunk/Source/WebKit/wx/WebFrame.cpp

    r87745 r89284  
    3333#include "Frame.h"
    3434#include "FrameLoader.h"
     35#include "FrameLoaderClientWx.h"
    3536#include "FrameView.h"
    3637#include "GraphicsContext.h"
     
    175176};
    176177#endif
     178
     179wxWebFrame* kit(WebCore::Frame* frame)
     180{
     181    if (!frame)
     182        return 0;
     183    if (!frame->loader())
     184        return 0;
     185   
     186    WebCore::FrameLoaderClientWx* loaderClient = dynamic_cast<WebCore::FrameLoaderClientWx*>(frame->loader()->client());
     187    if (loaderClient)
     188        return loaderClient->webFrame();
     189   
     190    return 0;
     191}
    177192
    178193wxWebFrame::wxWebFrame(wxWebView* container, wxWebFrame* parent, WebViewFrameData* data) :
     
    557572}
    558573
    559 void wxWebFrame::Print()
     574void wxWebFrame::Print(bool showDialog)
    560575{
    561576#if wxCHECK_VERSION(2, 9, 1)
     
    584599    printdata.SetToPage(printout->GetPageCount());
    585600
    586     wxPrintDialog dialog(0, &printdata);
    587     if (dialog.ShowModal() == wxID_OK) {   
    588         wxPrintDialogData data(dialog.GetPrintDialogData());
    589         printout->SetFirstPage(data.GetFromPage());
    590         printout->SetLastPage(data.GetToPage());
    591         wxPrinter printer(&data);
    592        
    593         printer.Print(0, printout, false);
    594     }
     601    wxPrintDialogData data(printdata);
     602
     603    if (showDialog) {
     604        wxPrintDialog dialog(0, &data);
     605        if (dialog.ShowModal() == wxID_OK) {
     606            data = dialog.GetPrintDialogData();
     607            printout->SetFirstPage(data.GetFromPage());
     608            printout->SetLastPage(data.GetToPage());
     609        } else
     610            return;
     611    }
     612   
     613    wxPrinter printer(&data);
     614       
     615    printer.Print(0, printout, false);
     616       
    595617#else
    596618    wxFAIL_MSG(wxT("Printing is only supported in wxWidgets 2.9.1 and above."));
  • trunk/Source/WebKit/wx/WebFrame.h

    r87745 r89284  
    116116    void Stop();
    117117    void Reload();
    118     void Print();
     118    void Print(bool showDialog = true);
    119119   
    120120    bool CanGoBack();
     
    181181};
    182182
     183wxWebFrame* kit(WebCore::Frame*);
     184
    183185#endif // ifndef WXWEBFRAME_H
  • trunk/Source/WebKit/wx/WebKitSupport/ChromeClientWx.cpp

    r89274 r89284  
    416416}
    417417
    418 void ChromeClientWx::print(Frame*)
    419 {
    420     notImplemented();
     418void ChromeClientWx::print(Frame* frame)
     419{
     420    wxWebFrame* webFrame = kit(frame);
     421    if (webFrame) {
     422        wxWebViewPrintFrameEvent event(m_webView);
     423        event.SetWebFrame(webFrame);
     424        if (!m_webView->GetEventHandler()->ProcessEvent(event))
     425            webFrame->Print(true);
     426    }
    421427}
    422428
  • trunk/Source/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h

    r88628 r89284  
    5656        FrameLoaderClientWx();
    5757        ~FrameLoaderClientWx();
     58       
     59        wxWebFrame* webFrame() { return m_webFrame; }
    5860        void setFrame(wxWebFrame *frame);
     61        wxWebView* webView() { return m_webView; }
    5962        void setWebView(wxWebView *webview);
    6063
  • trunk/Source/WebKit/wx/WebView.cpp

    r86068 r89284  
    248248{
    249249    SetEventType(wxEVT_WEBVIEW_SELECTION_CHANGED);
     250    SetEventObject(win);
     251    if (win)
     252        SetId(win->GetId());
     253}
     254
     255IMPLEMENT_DYNAMIC_CLASS(wxWebViewPrintFrameEvent, wxCommandEvent)
     256
     257DEFINE_EVENT_TYPE(wxEVT_WEBVIEW_PRINT_FRAME)
     258
     259wxWebViewPrintFrameEvent::wxWebViewPrintFrameEvent(wxWindow* win)
     260{
     261    SetEventType(wxEVT_WEBVIEW_PRINT_FRAME);
    250262    SetEventObject(win);
    251263    if (win)
  • trunk/Source/WebKit/wx/WebView.h

    r86068 r89284  
    546546};
    547547
     548class WXDLLIMPEXP_WEBKIT wxWebViewPrintFrameEvent : public wxCommandEvent {
     549#ifndef SWIG
     550    DECLARE_DYNAMIC_CLASS(wxWebViewPrintFrameEvent)
     551#endif
     552   
     553public:
     554    wxWebViewPrintFrameEvent(wxWindow* win = 0);
     555    wxEvent *Clone(void) const { return new wxWebViewPrintFrameEvent(*this); }
     556   
     557    wxWebFrame* GetWebFrame() { return m_webFrame; }
     558    void SetWebFrame(wxWebFrame* frame) { m_webFrame = frame; }
     559private:
     560    wxWebFrame* m_webFrame;
     561};
     562
    548563typedef void (wxEvtHandler::*wxWebViewLoadEventFunction)(wxWebViewLoadEvent&);
    549564typedef void (wxEvtHandler::*wxWebViewBeforeLoadEventFunction)(wxWebViewBeforeLoadEvent&);
     
    558573typedef void (wxEvtHandler::*wxWebViewContentsChangedFunction)(wxWebViewContentsChangedEvent&);
    559574typedef void (wxEvtHandler::*wxWebViewSelectionChangedFunction)(wxWebViewSelectionChangedEvent&);
     575typedef void (wxEvtHandler::*wxWebViewPrintFrameFunction)(wxWebViewPrintFrameEvent&);
    560576
    561577#define wxWebViewLoadEventHandler(func) \
     
    583599#define wxWebViewSelectionChangedEventHandler(func) \
    584600    (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxWebViewSelectionChangedEventFunction, &func)
    585    
     601#define wxWebViewPrintFrameEventHandler(func) \
     602    (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxWebViewPrintFrameEventFunction, &func)
     603
    586604#ifndef SWIG
    587605BEGIN_DECLARE_EVENT_TYPES()
     
    598616    DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_CONTENTS_CHANGED, wxID_ANY)
    599617    DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_SELECTION_CHANGED, wxID_ANY)
     618    DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBKIT, wxEVT_WEBVIEW_PRINT_FRAME, wxID_ANY)
    600619END_DECLARE_EVENT_TYPES()
    601620#endif
     
    696715                            (wxWebViewSelectionChangedEventFunction) & func, \
    697716                            static_cast<wxObject*>(0)),
    698                            
     717
     718#define EVT_WEBVIEW_PRINT_FRAME(winid, func)                       \
     719            DECLARE_EVENT_TABLE_ENTRY(wxEVT_WEBVIEW_PRINT_FRAME, \
     720                            winid, \
     721                            wxID_ANY, \
     722                            (wxObjectEventFunction)   \
     723                            (wxWebViewPrintFrameEventFunction) & func, \
     724                            static_cast<wxObject*>(0)),
    699725                           
    700726#endif // ifndef WXWEBVIEW_H
  • trunk/Source/WebKit/wx/bindings/python/webview.i

    r81135 r89284  
    171171%constant wxEventType wxEVT_WEBVIEW_CONTENTS_CHANGED;
    172172%constant wxEventType wxEVT_WEBVIEW_SELECTION_CHANGED;
     173%constant wxEventType wxEVT_WEBVIEW_PRINT_FRAME;
    173174
    174175%pythoncode {
     
    181182EVT_WEBVIEW_CONTENTS_CHANGED = wx.PyEventBinder( wxEVT_WEBVIEW_CONTENTS_CHANGED, 1 )
    182183EVT_WEBVIEW_SELECTION_CHANGED = wx.PyEventBinder( wxEVT_WEBVIEW_SELECTION_CHANGED, 1 )
     184EVT_WEBVIEW_PRINT_FRAME = wx.PyEventBinder( wxEVT_WEBVIEW_PRINT_FRAME, 1 )
    183185}
Note: See TracChangeset for help on using the changeset viewer.