• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
3  *
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef WXWEBFRAME_H
29 #define WXWEBFRAME_H
30 
31 #include "wx/wxprec.h"
32 #ifndef WX_PRECOMP
33     #include "wx/wx.h"
34 #endif
35 
36 #include "WebKitDefines.h"
37 
38 class WebFramePrivate;
39 class WebViewFrameData;
40 class wxWebView;
41 
42 namespace WebCore {
43     class ChromeClientWx;
44     class FrameLoaderClientWx;
45     class EditorClientWx;
46     class Frame;
47 }
48 
49 class WXDLLIMPEXP_WEBKIT wxWebViewDOMElementInfo
50 {
51 public:
52     wxWebViewDOMElementInfo();
53 
~wxWebViewDOMElementInfo()54     ~wxWebViewDOMElementInfo() { }
55 
GetTagName()56     wxString GetTagName() const { return m_tagName; }
SetTagName(const wxString & name)57     void SetTagName(const wxString& name) { m_tagName = name; }
58 
IsSelected()59     bool IsSelected() const { return m_isSelected; }
SetSelected(bool sel)60     void SetSelected(bool sel) { m_isSelected = sel; }
61 
GetText()62     wxString GetText() const { return m_text; }
SetText(const wxString & text)63     void SetText(const wxString& text) { m_text = text; }
64 
GetImageSrc()65     wxString GetImageSrc() const { return m_imageSrc; }
SetImageSrc(const wxString & src)66     void SetImageSrc(const wxString& src) { m_imageSrc = src; }
67 
GetLink()68     wxString GetLink() const { return m_link; }
SetLink(const wxString & link)69     void SetLink(const wxString& link) { m_link = link; }
70 
71 private:
72     void* m_domElement;
73     bool m_isSelected;
74     wxString m_tagName;
75     wxString m_text;
76     wxString m_imageSrc;
77     wxString m_link;
78 };
79 
80 // based on enums in WebCore/dom/Document.h
81 enum wxWebKitParseMode { Compat, AlmostStrict, Strict, NoDocument };
82 
83 class WXDLLIMPEXP_WEBKIT wxWebFrame
84 {
85     // ChromeClientWx needs to get the Page* stored by the wxWebView
86     // for the createWindow function.
87     friend class WebCore::ChromeClientWx;
88     friend class WebCore::FrameLoaderClientWx;
89     friend class WebCore::EditorClientWx;
90     friend class wxWebView;
91 
92 public:
93     wxWebFrame(wxWebView* container, wxWebFrame* parent = NULL, WebViewFrameData* data = NULL);
94 
95     ~wxWebFrame();
96 
97     void LoadURL(const wxString& url);
98     bool GoBack();
99     bool GoForward();
100     void Stop();
101     void Reload();
102 
103     bool CanGoBack();
104     bool CanGoForward();
105 
106     bool CanCut();
107     bool CanCopy();
108     bool CanPaste();
109 
110     void Cut();
111     void Copy();
112     void Paste();
113 
114     bool CanUndo();
115     bool CanRedo();
116 
117     void Undo();
118     void Redo();
119 
120     wxString GetPageSource();
121     void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString);
122 
123     wxString GetInnerText();
124     wxString GetAsMarkup();
125     wxString GetExternalRepresentation();
126 
127     wxString RunScript(const wxString& javascript);
128 
129     bool FindString(const wxString& string, bool forward = true,
130         bool caseSensitive = false, bool wrapSelection = true,
131         bool startInSelection = true);
132 
133     bool CanIncreaseTextSize() const;
134     void IncreaseTextSize();
135     bool CanDecreaseTextSize() const;
136     void DecreaseTextSize();
137     void ResetTextSize();
138     void MakeEditable(bool enable);
IsEditable()139     bool IsEditable() const { return m_isEditable; }
140 
141     WebCore::Frame* GetFrame();
142 
143     wxWebViewDOMElementInfo HitTest(const wxPoint& post) const;
144 
145     bool ShouldClose() const;
146 
147     wxWebKitParseMode GetParseMode() const;
148 
149 private:
150     float m_textMagnifier;
151     bool m_isEditable;
152     bool m_isInitialized;
153     bool m_beingDestroyed;
154     WebFramePrivate* m_impl;
155 
156 };
157 
158 #endif // ifndef WXWEBFRAME_H
159