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

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

Issue 770223002: Remove lots of code from the WebWidget/WebView/WebFrame layer. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 class WebViewImpl final : public WebView 63 class WebViewImpl final : public WebView
64 , public RefCounted<WebViewImpl> 64 , public RefCounted<WebViewImpl>
65 , public WebGestureCurveTarget 65 , public WebGestureCurveTarget
66 , public PageWidgetEventHandler { 66 , public PageWidgetEventHandler {
67 public: 67 public:
68 static WebViewImpl* create(WebViewClient*); 68 static WebViewImpl* create(WebViewClient*);
69 69
70 // WebWidget methods: 70 // WebWidget methods:
71 virtual void close() override; 71 virtual void close() override;
72 virtual WebSize size() override; 72 virtual WebSize size() override;
73 virtual void willStartLiveResize() override; 73
74 virtual void resize(const WebSize&) override; 74 virtual void resize(const WebSize&) override;
75 virtual void willEndLiveResize() override;
76 75
77 virtual void beginFrame(const WebBeginFrameArgs&) override; 76 virtual void beginFrame(const WebBeginFrameArgs&) override;
78 virtual void didCommitFrameToCompositor() override;
79 77
80 virtual void layout() override; 78 virtual void layout() override;
81 virtual void paint(WebCanvas*, const WebRect&) override; 79 virtual void paint(WebCanvas*, const WebRect&) override;
82 virtual bool isTrackingRepaints() const override; 80 virtual bool isTrackingRepaints() const override;
83 virtual void themeChanged() override;
84 virtual bool handleInputEvent(const WebInputEvent&) override; 81 virtual bool handleInputEvent(const WebInputEvent&) override;
85 virtual void setCursorVisibilityState(bool isVisible) override; 82 virtual void setCursorVisibilityState(bool isVisible) override;
86 virtual void mouseCaptureLost() override; 83 virtual void mouseCaptureLost() override;
87 virtual void setFocus(bool enable) override; 84 virtual void setFocus(bool enable) override;
88 virtual bool setComposition( 85 virtual bool setComposition(
89 const WebString& text, 86 const WebString& text,
90 const WebVector<WebCompositionUnderline>& underlines, 87 const WebVector<WebCompositionUnderline>& underlines,
91 int selectionStart, 88 int selectionStart,
92 int selectionEnd) override; 89 int selectionEnd) override;
93 virtual bool confirmComposition() override; 90 virtual bool confirmComposition() override;
94 virtual bool confirmComposition(ConfirmCompositionBehavior selectionBehavior ) override; 91 virtual bool confirmComposition(ConfirmCompositionBehavior selectionBehavior ) override;
95 virtual bool confirmComposition(const WebString& text) override; 92 virtual bool confirmComposition(const WebString& text) override;
96 virtual bool compositionRange(size_t* location, size_t* length) override; 93 virtual bool compositionRange(size_t* location, size_t* length) override;
97 virtual WebTextInputInfo textInputInfo() override; 94 virtual WebTextInputInfo textInputInfo() override;
98 virtual WebColor backgroundColor() const override; 95 virtual WebColor backgroundColor() const override;
99 virtual bool selectionBounds(WebRect& anchor, WebRect& focus) const override ; 96
100 virtual void didShowCandidateWindow() override; 97 virtual void didShowCandidateWindow() override;
101 virtual void didUpdateCandidateWindow() override; 98 virtual void didUpdateCandidateWindow() override;
102 virtual void didHideCandidateWindow() override; 99 virtual void didHideCandidateWindow() override;
103 virtual bool selectionTextDirection(WebTextDirection& start, WebTextDirectio n& end) const override;
104 virtual bool isSelectionAnchorFirst() const override;
105 virtual bool caretOrSelectionRange(size_t* location, size_t* length) overrid e;
106 virtual void setTextDirection(WebTextDirection) override;
107 100
108 // WebView methods: 101 // WebView methods:
109 virtual void setMainFrame(WebFrame*) override; 102 virtual void setMainFrame(WebFrame*) override;
110 virtual void injectModule(const WebString&) override; 103 virtual void injectModule(const WebString&) override;
111 virtual void setSpellCheckClient(WebSpellCheckClient*) override; 104 virtual void setSpellCheckClient(WebSpellCheckClient*) override;
112 virtual WebSettings* settings() override; 105 virtual WebSettings* settings() override;
113 virtual WebString pageEncoding() const override; 106 virtual WebString pageEncoding() const override;
114 virtual void setPageEncoding(const WebString&) override; 107 virtual void setPageEncoding(const WebString&) override;
115 virtual bool isTransparent() const override; 108 virtual bool isTransparent() const override;
116 virtual void setIsTransparent(bool value) override; 109 virtual void setIsTransparent(bool value) override;
117 virtual void setBaseBackgroundColor(WebColor) override; 110 virtual void setBaseBackgroundColor(WebColor) override;
118 virtual bool tabsToLinks() const override; 111 virtual bool tabsToLinks() const override;
119 virtual void setTabsToLinks(bool value) override; 112 virtual void setTabsToLinks(bool value) override;
120 virtual bool tabKeyCyclesThroughElements() const override; 113 virtual bool tabKeyCyclesThroughElements() const override;
121 virtual void setTabKeyCyclesThroughElements(bool value) override; 114 virtual void setTabKeyCyclesThroughElements(bool value) override;
122 virtual bool isActive() const override; 115 virtual bool isActive() const override;
123 virtual void setIsActive(bool value) override; 116 virtual void setIsActive(bool value) override;
124 virtual void setDomainRelaxationForbidden(bool, const WebString& scheme) ove rride; 117 virtual void setDomainRelaxationForbidden(bool, const WebString& scheme) ove rride;
125 virtual void setOpenedByDOM() override;
126 virtual WebFrame* mainFrame() override; 118 virtual WebFrame* mainFrame() override;
127 virtual WebFrame* focusedFrame() override; 119 virtual WebFrame* focusedFrame() override;
128 virtual void setFocusedFrame(WebFrame*) override; 120 virtual void setFocusedFrame(WebFrame*) override;
129 virtual void setInitialFocus(bool reverse) override; 121 virtual void setInitialFocus(bool reverse) override;
130 virtual void clearFocusedElement() override; 122 virtual void clearFocusedElement() override;
131 virtual void scrollFocusedNodeIntoRect(const WebRect&) override;
132 virtual void advanceFocus(bool reverse) override; 123 virtual void advanceFocus(bool reverse) override;
133 virtual void setMainFrameScrollOffset(const WebPoint&) override;
134 virtual void resetScrollAndScaleState() override;
135 virtual WebSize contentsPreferredMinimumSize() override;
136 124
137 virtual float deviceScaleFactor() const override; 125 virtual float deviceScaleFactor() const override;
138 virtual void setDeviceScaleFactor(float) override; 126 virtual void setDeviceScaleFactor(float) override;
139 127
140 virtual void setFixedLayoutSize(const WebSize&) override;
141
142 virtual WebHitTestResult hitTestResultAt(const WebPoint&) override; 128 virtual WebHitTestResult hitTestResultAt(const WebPoint&) override;
143 virtual void copyImageAt(const WebPoint&) override;
144 virtual void saveImageAt(const WebPoint&) override;
145 virtual void dragSourceSystemDragEnded() override;
146 virtual void spellingMarkers(WebVector<uint32_t>* markers) override; 129 virtual void spellingMarkers(WebVector<uint32_t>* markers) override;
147 virtual void removeSpellingMarkersUnderWords(const WebVector<WebString>& wor ds) override; 130 virtual void removeSpellingMarkersUnderWords(const WebVector<WebString>& wor ds) override;
148 virtual void setCompositorDeviceScaleFactorOverride(float) override; 131 virtual void setCompositorDeviceScaleFactorOverride(float) override;
149 virtual void setRootLayerTransform(const WebSize& offset, float scale) overr ide; 132
150 virtual void setSelectionColors(unsigned activeBackgroundColor,
151 unsigned activeForegroundColor,
152 unsigned inactiveBackgroundColor,
153 unsigned inactiveForegroundColor) override;
154 virtual void extractSmartClipData(WebRect, WebString&, WebString&, WebRect&) override;
155 virtual void transferActiveWheelFlingAnimation(const WebActiveWheelFlingPara meters&) override; 133 virtual void transferActiveWheelFlingAnimation(const WebActiveWheelFlingPara meters&) override;
156 virtual bool endActiveFlingAnimation() override; 134 virtual bool endActiveFlingAnimation() override;
157 virtual void setShowPaintRects(bool) override; 135 virtual void setShowPaintRects(bool) override;
158 void setShowDebugBorders(bool); 136 void setShowDebugBorders(bool);
159 virtual void setShowFPSCounter(bool) override; 137 virtual void setShowFPSCounter(bool) override;
160 virtual void setContinuousPaintingEnabled(bool) override; 138 virtual void setContinuousPaintingEnabled(bool) override;
161 virtual void setShowScrollBottleneckRects(bool) override; 139 virtual void setShowScrollBottleneckRects(bool) override;
162 virtual void getSelectionRootBounds(WebRect& bounds) const override; 140
163 virtual void acceptLanguagesChanged() override; 141 virtual void acceptLanguagesChanged() override;
164 142
165 // WebViewImpl 143 // WebViewImpl
166 144
167 HitTestResult coreHitTestResultAt(const WebPoint&); 145 HitTestResult coreHitTestResultAt(const WebPoint&);
168 void suppressInvalidations(bool enable); 146 void suppressInvalidations(bool enable);
169 void invalidateRect(const IntRect&); 147 void invalidateRect(const IntRect&);
170 148
171 void setIgnoreInputEvents(bool newValue); 149 void setIgnoreInputEvents(bool newValue);
172 void setBackgroundColorOverride(WebColor); 150 void setBackgroundColorOverride(WebColor);
173 151
174 Color baseBackgroundColor() const { return m_baseBackgroundColor; } 152 Color baseBackgroundColor() const { return m_baseBackgroundColor; }
175 153
176 const WebPoint& lastMouseDownPoint() const
177 {
178 return m_lastMouseDownPoint;
179 }
180
181 LocalFrame* focusedCoreFrame() const; 154 LocalFrame* focusedCoreFrame() const;
182 155
183 // Returns the currently focused Element or null if no element has focus. 156 // Returns the currently focused Element or null if no element has focus.
184 Element* focusedElement() const; 157 Element* focusedElement() const;
185 158
186 static WebViewImpl* fromPage(Page*); 159 static WebViewImpl* fromPage(Page*);
187 160
188 WebViewClient* client() 161 WebViewClient* client()
189 { 162 {
190 return m_client; 163 return m_client;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 void scheduleAnimation(); 216 void scheduleAnimation();
244 217
245 virtual void setVisibilityState(WebPageVisibilityState, bool) override; 218 virtual void setVisibilityState(WebPageVisibilityState, bool) override;
246 219
247 // Returns true if the event leads to scrolling. 220 // Returns true if the event leads to scrolling.
248 static bool mapKeyCodeForScroll( 221 static bool mapKeyCodeForScroll(
249 int keyCode, 222 int keyCode,
250 ScrollDirection*, 223 ScrollDirection*,
251 ScrollGranularity*); 224 ScrollGranularity*);
252 225
253 void computeScaleAndScrollForBlockRect(const WebPoint& hitPoint, const WebRe ct& blockRect, float padding, float defaultScaleWhenAlreadyLegible, float& scale , WebPoint& scroll);
254 void computeScaleAndScrollForFocusedNode(Node* focusedNode, float& scale, In tPoint& scroll, bool& needAnimation);
255
256 // Exposed for the purpose of overriding device metrics. 226 // Exposed for the purpose of overriding device metrics.
257 void sendResizeEventAndRepaint(); 227 void sendResizeEventAndRepaint();
258 228
259 // Exposed for testing purposes. 229 // Exposed for testing purposes.
260 bool hasHorizontalScrollbar(); 230 bool hasHorizontalScrollbar();
261 bool hasVerticalScrollbar(); 231 bool hasVerticalScrollbar();
262 232
263 WebSettingsImpl* settingsImpl(); 233 WebSettingsImpl* settingsImpl();
264 234
265 // Returns the bounding box of the block type node touched by the WebRect.
266 WebRect computeBlockBounds(const WebRect&, bool ignoreClipping);
267
268 IntPoint clampOffsetAtScale(const IntPoint& offset, float scale); 235 IntPoint clampOffsetAtScale(const IntPoint& offset, float scale);
269 236
270 // Exposed for tests. 237 // Exposed for tests.
271 WebVector<WebCompositionUnderline> compositionUnderlines() const; 238 WebVector<WebCompositionUnderline> compositionUnderlines() const;
272 239
273 bool matchesHeuristicsForGpuRasterizationForTesting() const { return m_match esHeuristicsForGpuRasterization; } 240 bool matchesHeuristicsForGpuRasterizationForTesting() const { return m_match esHeuristicsForGpuRasterization; }
274 241
275 private: 242 private:
276 IntSize contentsSize() const; 243 IntSize contentsSize() const;
277 244
278 void resetSavedScrollAndScaleState(); 245 void resetSavedScrollAndScaleState();
279 246
280 void updateMainFrameScrollPosition(const IntPoint& scrollPosition, bool prog rammaticScroll);
281
282 void performResize(); 247 void performResize();
283 248
284 friend class WebView; // So WebView::Create can call our constructor 249 friend class WebView; // So WebView::Create can call our constructor
285 friend class WTF::RefCounted<WebViewImpl>; 250 friend class WTF::RefCounted<WebViewImpl>;
286 friend void setCurrentInputEventForTest(const WebInputEvent*); 251 friend void setCurrentInputEventForTest(const WebInputEvent*);
287 252
288 enum DragAction { 253 enum DragAction {
289 DragEnter, 254 DragEnter,
290 DragOver 255 DragOver
291 }; 256 };
(...skipping 13 matching lines...) Expand all
305 270
306 // Returns true if the view was scrolled. 271 // Returns true if the view was scrolled.
307 bool scrollViewWithKeyboard(int keyCode, int modifiers); 272 bool scrollViewWithKeyboard(int keyCode, int modifiers);
308 273
309 // Converts |pos| from window coordinates to contents coordinates and gets 274 // Converts |pos| from window coordinates to contents coordinates and gets
310 // the HitTestResult for it. 275 // the HitTestResult for it.
311 HitTestResult hitTestResultForWindowPos(const IntPoint&); 276 HitTestResult hitTestResultForWindowPos(const IntPoint&);
312 277
313 void doComposite(); 278 void doComposite();
314 void reallocateRenderer(); 279 void reallocateRenderer();
315 void updateRootLayerTransform();
316
317 // Helper function: Widens the width of |source| by the specified margins
318 // while keeping it smaller than page width.
319 WebRect widenRectWithinPageBounds(const WebRect& source, int targetMargin, i nt minimumMargin);
320 280
321 // PageWidgetEventHandler functions 281 // PageWidgetEventHandler functions
322 virtual void handleMouseLeave(LocalFrame&, const WebMouseEvent&) override; 282 virtual void handleMouseLeave(LocalFrame&, const WebMouseEvent&) override;
323 virtual void handleMouseDown(LocalFrame&, const WebMouseEvent&) override; 283 virtual void handleMouseDown(LocalFrame&, const WebMouseEvent&) override;
324 virtual void handleMouseUp(LocalFrame&, const WebMouseEvent&) override; 284 virtual void handleMouseUp(LocalFrame&, const WebMouseEvent&) override;
325 virtual bool handleMouseWheel(LocalFrame&, const WebMouseWheelEvent&) overri de; 285 virtual bool handleMouseWheel(LocalFrame&, const WebMouseWheelEvent&) overri de;
326 virtual bool handleGestureEvent(const WebGestureEvent&) override; 286 virtual bool handleGestureEvent(const WebGestureEvent&) override;
327 virtual bool handleKeyEvent(const WebKeyboardEvent&) override; 287 virtual bool handleKeyEvent(const WebKeyboardEvent&) override;
328 virtual bool handleCharEvent(const WebKeyboardEvent&) override; 288 virtual bool handleCharEvent(const WebKeyboardEvent&) override;
329 289
330 InputMethodContext* inputMethodContext(); 290 InputMethodContext* inputMethodContext();
331 291
332 WebViewClient* m_client; // Can be 0 (e.g. unittests, shared workers, etc.) 292 WebViewClient* m_client; // Can be 0 (e.g. unittests, shared workers, etc.)
333 WebSpellCheckClient* m_spellCheckClient; 293 WebSpellCheckClient* m_spellCheckClient;
334 294
335 ChromeClientImpl m_chromeClientImpl; 295 ChromeClientImpl m_chromeClientImpl;
336 EditorClientImpl m_editorClientImpl; 296 EditorClientImpl m_editorClientImpl;
337 SpellCheckerClientImpl m_spellCheckerClientImpl; 297 SpellCheckerClientImpl m_spellCheckerClientImpl;
338 298
339 WebSize m_size; 299 WebSize m_size;
340 bool m_fixedLayoutSizeLock; 300 bool m_fixedLayoutSizeLock;
341 301
342 OwnPtr<Page> m_page; 302 OwnPtr<Page> m_page;
343 303
344 // An object that can be used to manipulate m_page->settings() without linki ng 304 // An object that can be used to manipulate m_page->settings() without linki ng
345 // against WebCore. This is lazily allocated the first time GetWebSettings() 305 // against WebCore. This is lazily allocated the first time GetWebSettings()
346 // is called. 306 // is called.
347 OwnPtr<WebSettingsImpl> m_webSettings; 307 OwnPtr<WebSettingsImpl> m_webSettings;
348 308
349 // The point relative to the client area where the mouse was last pressed
350 // down. This is used by the drag client to determine what was under the
351 // mouse when the drag was initiated. We need to track this here in
352 // WebViewImpl since DragClient::startDrag does not pass the position the
353 // mouse was at when the drag was initiated, only the current point, which
354 // can be misleading as it is usually not over the element the user actually
355 // dragged by the time a drag is initiated.
356 WebPoint m_lastMouseDownPoint;
357
358 bool m_doingDragAndDrop;
359
360 bool m_ignoreInputEvents; 309 bool m_ignoreInputEvents;
361 310
362 float m_compositorDeviceScaleFactorOverride; 311 float m_compositorDeviceScaleFactorOverride;
363 WebSize m_rootLayerOffset; 312 WebSize m_rootLayerOffset;
364 float m_rootLayerScale; 313 float m_rootLayerScale;
365 314
366 // Webkit expects keyPress events to be suppressed if the associated keyDown 315 // Webkit expects keyPress events to be suppressed if the associated keyDown
367 // event was handled. Safari implements this behavior by peeking out the 316 // event was handled. Safari implements this behavior by peeking out the
368 // associated WM_CHAR event if the keydown was handled. We emulate 317 // associated WM_CHAR event if the keydown was handled. We emulate
369 // this behavior by setting this flag if the keyDown was handled. 318 // this behavior by setting this flag if the keyDown was handled.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 bool m_userGestureObserved; 355 bool m_userGestureObserved;
407 }; 356 };
408 357
409 // We have no ways to check if the specified WebView is an instance of 358 // We have no ways to check if the specified WebView is an instance of
410 // WebViewImpl because WebViewImpl is the only implementation of WebView. 359 // WebViewImpl because WebViewImpl is the only implementation of WebView.
411 DEFINE_TYPE_CASTS(WebViewImpl, WebView, webView, true, true); 360 DEFINE_TYPE_CASTS(WebViewImpl, WebView, webView, true, true);
412 361
413 } // namespace blink 362 } // namespace blink
414 363
415 #endif // SKY_ENGINE_WEB_WEBVIEWIMPL_H_ 364 #endif // SKY_ENGINE_WEB_WEBVIEWIMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698