Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: sky/engine/web/WebViewImpl.h

Issue 1210153009: Remove (almost all of) //sky/engine/web (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/web/WebTextRun.cpp ('k') | sky/engine/web/WebViewImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef SKY_ENGINE_WEB_WEBVIEWIMPL_H_
32 #define SKY_ENGINE_WEB_WEBVIEWIMPL_H_
33
34 #include "sky/engine/core/rendering/HitTestResult.h"
35 #include "sky/engine/platform/geometry/IntPoint.h"
36 #include "sky/engine/platform/geometry/IntRect.h"
37 #include "sky/engine/platform/graphics/Color.h"
38 #include "sky/engine/public/platform/WebInputEvent.h"
39 #include "sky/engine/public/platform/WebLayer.h"
40 #include "sky/engine/public/platform/WebPoint.h"
41 #include "sky/engine/public/platform/WebRect.h"
42 #include "sky/engine/public/platform/WebSize.h"
43 #include "sky/engine/public/platform/WebString.h"
44 #include "sky/engine/public/web/WebNavigationPolicy.h"
45 #include "sky/engine/public/web/WebView.h"
46 #include "sky/engine/web/ChromeClientImpl.h"
47 #include "sky/engine/web/EditorClientImpl.h"
48 #include "sky/engine/web/SpellCheckerClientImpl.h"
49 #include "sky/engine/wtf/OwnPtr.h"
50 #include "sky/engine/wtf/RefCounted.h"
51 #include "sky/engine/wtf/Vector.h"
52
53 namespace blink {
54
55 class Frame;
56 class WebLocalFrameImpl;
57 class WebImage;
58 class WebSettingsImpl;
59 class Page;
60
61 class WebViewImpl final : public WebView, public RefCounted<WebViewImpl> {
62 public:
63 static WebViewImpl* create(WebViewClient*);
64
65 // WebWidget methods:
66 virtual void close() override;
67 virtual WebSize size() override;
68
69 virtual void resize(const WebSize&) override;
70
71 virtual void beginFrame(const WebBeginFrameArgs&) override;
72
73 virtual void layout() override;
74 virtual void paint(WebCanvas*, const WebRect&) override;
75 virtual bool handleInputEvent(const WebInputEvent&) override;
76 virtual void setFocus(bool enable) override;
77 virtual bool setComposition(
78 const WebString& text,
79 const WebVector<WebCompositionUnderline>& underlines,
80 int selectionStart,
81 int selectionEnd) override;
82 virtual bool confirmComposition() override;
83 virtual bool confirmComposition(ConfirmCompositionBehavior selectionBehavior ) override;
84 virtual bool confirmComposition(const WebString& text) override;
85 virtual WebTextInputInfo textInputInfo() override;
86
87 // WebView methods:
88 virtual void setMainFrame(WebFrame*) override;
89 virtual void injectModule(const WebString&) override;
90 virtual void setSpellCheckClient(WebSpellCheckClient*) override;
91 virtual WebSettings* settings() override;
92 virtual bool isTransparent() const override;
93 virtual void setIsTransparent(bool value) override;
94 virtual void setBaseBackgroundColor(WebColor) override;
95 virtual bool isActive() const override;
96 virtual void setIsActive(bool value) override;
97 virtual WebFrame* mainFrame() override;
98 virtual WebFrame* focusedFrame() override;
99 virtual void setFocusedFrame(WebFrame*) override;
100 virtual void setInitialFocus(bool reverse) override;
101 virtual void clearFocusedElement() override;
102 virtual void advanceFocus(bool reverse) override;
103
104 virtual float deviceScaleFactor() const override;
105 virtual void setDeviceScaleFactor(float) override;
106
107 virtual void spellingMarkers(WebVector<uint32_t>* markers) override;
108 virtual void removeSpellingMarkersUnderWords(const WebVector<WebString>& wor ds) override;
109
110 virtual void setShowPaintRects(bool) override;
111 void setShowDebugBorders(bool);
112
113 virtual void acceptLanguagesChanged() override;
114
115 // WebViewImpl
116 void setBackgroundColorOverride(WebColor);
117
118 Color baseBackgroundColor() const { return m_baseBackgroundColor; }
119
120 LocalFrame* focusedCoreFrame() const;
121
122 // Returns the currently focused Element or null if no element has focus.
123 Element* focusedElement() const;
124
125 static WebViewImpl* fromPage(Page*);
126
127 WebViewClient* client()
128 {
129 return m_client;
130 }
131
132 WebSpellCheckClient* spellCheckClient()
133 {
134 return m_spellCheckClient;
135 }
136
137 // Returns the page object associated with this view. This may be null when
138 // the page is shutting down, but will be valid at all other times.
139 Page* page() const
140 {
141 return m_page.get();
142 }
143
144 // Returns the main frame associated with this view. This may be null when
145 // the page is shutting down, but will be valid at all other times.
146 WebLocalFrameImpl* mainFrameImpl();
147
148 // Notifies the WebView that a load has been committed. isNewNavigation
149 // will be true if a new session history item should be created for that
150 // load. isNavigationWithinPage will be true if the navigation does
151 // not take the user away from the current page.
152 void didCommitLoad(bool isNewNavigation, bool isNavigationWithinPage);
153
154 void updateMainFrameLayoutSize();
155
156 void scheduleVisualUpdate();
157
158 virtual void setVisibilityState(WebPageVisibilityState, bool) override;
159
160 // Exposed for the purpose of overriding device metrics.
161 void sendResizeEventAndRepaint();
162
163 WebSettingsImpl* settingsImpl();
164
165 IntPoint clampOffsetAtScale(const IntPoint& offset, float scale);
166
167 // Exposed for tests.
168 WebVector<WebCompositionUnderline> compositionUnderlines() const;
169
170 bool matchesHeuristicsForGpuRasterizationForTesting() const { return m_match esHeuristicsForGpuRasterization; }
171
172 private:
173 IntSize contentsSize() const;
174
175 void performResize();
176
177 friend class WebView; // So WebView::Create can call our constructor
178 friend class WTF::RefCounted<WebViewImpl>;
179 friend void setCurrentInputEventForTest(const WebInputEvent*);
180
181 enum DragAction {
182 DragEnter,
183 DragOver
184 };
185
186 explicit WebViewImpl(WebViewClient*);
187 virtual ~WebViewImpl();
188
189 WebTextInputType textInputType();
190 int textInputFlags();
191
192 WebString inputModeOfFocusedElement();
193
194 bool confirmComposition(const WebString& text, ConfirmCompositionBehavior);
195
196 // Converts |pos| from window coordinates to contents coordinates and gets
197 // the HitTestResult for it.
198 HitTestResult hitTestResultForWindowPos(const IntPoint&);
199
200 void doComposite();
201 void reallocateRenderer();
202
203 WebViewClient* m_client; // Can be 0 (e.g. unittests, shared workers, etc.)
204 WebSpellCheckClient* m_spellCheckClient;
205
206 ChromeClientImpl m_chromeClientImpl;
207 EditorClientImpl m_editorClientImpl;
208 SpellCheckerClientImpl m_spellCheckerClientImpl;
209
210 WebSize m_size;
211 bool m_fixedLayoutSizeLock;
212
213 OwnPtr<Page> m_page;
214
215 // An object that can be used to manipulate m_page->settings() without linki ng
216 // against WebCore. This is lazily allocated the first time GetWebSettings()
217 // is called.
218 OwnPtr<WebSettingsImpl> m_webSettings;
219
220 WebSize m_rootLayerOffset;
221 float m_rootLayerScale;
222
223 // Webkit expects keyPress events to be suppressed if the associated keyDown
224 // event was handled. Safari implements this behavior by peeking out the
225 // associated WM_CHAR event if the keydown was handled. We emulate
226 // this behavior by setting this flag if the keyDown was handled.
227 bool m_suppressNextKeypressEvent;
228
229 // Represents whether or not this object should process incoming IME events.
230 bool m_imeAcceptEvents;
231
232 // Whether the webview is rendering transparently.
233 bool m_isTransparent;
234
235 WebLayer* m_rootLayer;
236 bool m_matchesHeuristicsForGpuRasterization;
237 // If true, the graphics context is being restored.
238 bool m_recreatingGraphicsContext;
239 static const WebInputEvent* m_currentInputEvent;
240
241 WebPoint m_positionOnFlingStart;
242 WebPoint m_globalPositionOnFlingStart;
243 int m_flingModifier;
244 bool m_flingSourceDevice;
245
246 bool m_showPaintRects;
247 bool m_showDebugBorders;
248 WebColor m_baseBackgroundColor;
249 WebColor m_backgroundColorOverride;
250 };
251
252 // We have no ways to check if the specified WebView is an instance of
253 // WebViewImpl because WebViewImpl is the only implementation of WebView.
254 DEFINE_TYPE_CASTS(WebViewImpl, WebView, webView, true, true);
255
256 } // namespace blink
257
258 #endif // SKY_ENGINE_WEB_WEBVIEWIMPL_H_
OLDNEW
« no previous file with comments | « sky/engine/web/WebTextRun.cpp ('k') | sky/engine/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698