2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
34 #include "core/page/EventWithHitTestResults.h"
35 #include "core/page/PagePopupDriver.h"
36 #include "platform/geometry/IntPoint.h"
37 #include "platform/geometry/IntRect.h"
38 #include "platform/graphics/GraphicsLayer.h"
39 #include "platform/heap/Handle.h"
40 #include "public/platform/WebGestureCurveTarget.h"
41 #include "public/platform/WebLayer.h"
42 #include "public/platform/WebPoint.h"
43 #include "public/platform/WebRect.h"
44 #include "public/platform/WebSize.h"
45 #include "public/platform/WebString.h"
46 #include "public/platform/WebVector.h"
47 #include "public/web/WebInputEvent.h"
48 #include "public/web/WebNavigationPolicy.h"
49 #include "public/web/WebView.h"
50 #include "web/ChromeClientImpl.h"
51 #include "web/ContextMenuClientImpl.h"
52 #include "web/DragClientImpl.h"
53 #include "web/EditorClientImpl.h"
54 #include "web/InspectorClientImpl.h"
55 #include "web/MediaKeysClientImpl.h"
56 #include "web/PageOverlayList.h"
57 #include "web/PageScaleConstraintsSet.h"
58 #include "web/PageWidgetDelegate.h"
59 #include "web/SpellCheckerClientImpl.h"
60 #include "web/StorageClientImpl.h"
61 #include "wtf/OwnPtr.h"
62 #include "wtf/RefCounted.h"
63 #include "wtf/Vector.h"
69 class FullscreenController;
72 class RenderLayerCompositor;
73 class UserGestureToken;
74 class WebActiveGestureAnimation;
75 class WebDevToolsAgentPrivate;
76 class WebLocalFrameImpl;
78 class WebPagePopupImpl;
80 class WebSettingsImpl;
82 struct WebSelectionBound;
84 class WebViewImpl final : public WebView
85 , public RefCounted<WebViewImpl>
86 , public WebGestureCurveTarget
87 , public PagePopupDriver
88 , public PageWidgetEventHandler {
90 static WebViewImpl* create(WebViewClient*);
93 virtual void close() override;
94 virtual WebSize size() override;
95 virtual void willStartLiveResize() override;
96 virtual void resize(const WebSize&) override;
97 virtual void resizePinchViewport(const WebSize&) override;
98 virtual void willEndLiveResize() override;
99 virtual void didEnterFullScreen() override;
100 virtual void didExitFullScreen() override;
102 virtual void beginFrame(const WebBeginFrameArgs&) override;
103 virtual void didCommitFrameToCompositor() override;
105 virtual void layout() override;
106 virtual void paint(WebCanvas*, const WebRect&) override;
108 virtual void paintCompositedDeprecated(WebCanvas*, const WebRect&) override;
110 virtual void compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback*) override;
111 virtual bool isTrackingRepaints() const override;
112 virtual void themeChanged() override;
113 virtual bool handleInputEvent(const WebInputEvent&) override;
114 virtual void setCursorVisibilityState(bool isVisible) override;
115 virtual bool hasTouchEventHandlersAt(const WebPoint&) override;
117 // FIXME(bokan): Old pinch path only - This should be removed once old pinch
119 virtual void applyViewportDeltas(
120 const WebSize& scrollDelta,
121 float pageScaleDelta,
122 float topControlsDelta) override;
123 virtual void applyViewportDeltas(
124 const WebSize& pinchViewportDelta,
125 const WebSize& mainFrameDelta,
126 float pageScaleDelta,
127 float topControlsDelta) override;
128 virtual void mouseCaptureLost() override;
129 virtual void setFocus(bool enable) override;
130 virtual bool setComposition(
131 const WebString& text,
132 const WebVector<WebCompositionUnderline>& underlines,
134 int selectionEnd) override;
135 virtual bool confirmComposition() override;
136 virtual bool confirmComposition(ConfirmCompositionBehavior selectionBehavior) override;
137 virtual bool confirmComposition(const WebString& text) override;
138 virtual bool compositionRange(size_t* location, size_t* length) override;
139 virtual WebTextInputInfo textInputInfo() override;
140 virtual WebColor backgroundColor() const override;
141 virtual WebPagePopup* pagePopup() const override;
142 virtual bool selectionBounds(WebRect& anchor, WebRect& focus) const override;
143 virtual void didShowCandidateWindow() override;
144 virtual void didUpdateCandidateWindow() override;
145 virtual void didHideCandidateWindow() override;
146 virtual bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const override;
147 virtual bool isSelectionAnchorFirst() const override;
148 virtual bool caretOrSelectionRange(size_t* location, size_t* length) override;
149 virtual void setTextDirection(WebTextDirection) override;
150 virtual bool isAcceleratedCompositingActive() const override;
151 virtual void willCloseLayerTreeView() override;
152 virtual void didAcquirePointerLock() override;
153 virtual void didNotAcquirePointerLock() override;
154 virtual void didLosePointerLock() override;
155 virtual void didChangeWindowResizerRect() override;
158 virtual void setMainFrame(WebFrame*) override;
159 virtual void setAutofillClient(WebAutofillClient*) override;
160 virtual void setCredentialManagerClient(WebCredentialManagerClient*) override;
161 virtual void setDevToolsAgentClient(WebDevToolsAgentClient*) override;
162 virtual void setPrerendererClient(WebPrerendererClient*) override;
163 virtual void setSpellCheckClient(WebSpellCheckClient*) override;
164 virtual WebSettings* settings() override;
165 virtual WebString pageEncoding() const override;
166 virtual void setPageEncoding(const WebString&) override;
167 virtual bool isTransparent() const override;
168 virtual void setIsTransparent(bool value) override;
169 virtual void setBaseBackgroundColor(WebColor) override;
170 virtual bool tabsToLinks() const override;
171 virtual void setTabsToLinks(bool value) override;
172 virtual bool tabKeyCyclesThroughElements() const override;
173 virtual void setTabKeyCyclesThroughElements(bool value) override;
174 virtual bool isActive() const override;
175 virtual void setIsActive(bool value) override;
176 virtual void setDomainRelaxationForbidden(bool, const WebString& scheme) override;
177 virtual void setWindowFeatures(const WebWindowFeatures&) override;
178 virtual void setOpenedByDOM() override;
179 virtual WebFrame* mainFrame() override;
180 virtual WebFrame* findFrameByName(
181 const WebString& name, WebFrame* relativeToFrame) override;
182 virtual WebFrame* focusedFrame() override;
183 virtual void setFocusedFrame(WebFrame*) override;
184 virtual void setInitialFocus(bool reverse) override;
185 virtual void clearFocusedElement() override;
186 virtual void scrollFocusedNodeIntoRect(const WebRect&) override;
187 virtual void zoomToFindInPageRect(const WebRect&) override;
188 virtual void advanceFocus(bool reverse) override;
189 virtual double zoomLevel() override;
190 virtual double setZoomLevel(double) override;
191 virtual void zoomLimitsChanged(double minimumZoomLevel, double maximumZoomLevel) override;
192 virtual float textZoomFactor() override;
193 virtual float setTextZoomFactor(float) override;
194 virtual void setInitialPageScaleOverride(float) override;
195 virtual bool zoomToMultipleTargetsRect(const WebRect&) override;
196 virtual float pageScaleFactor() const override;
197 virtual void setPageScaleFactorLimits(float minPageScale, float maxPageScale) override;
198 virtual void setMainFrameScrollOffset(const WebPoint&) override;
199 virtual void setPageScaleFactor(float) override;
200 virtual void setPinchViewportOffset(const WebFloatPoint&) override;
201 virtual WebFloatPoint pinchViewportOffset() const override;
202 virtual float minimumPageScaleFactor() const override;
203 virtual float maximumPageScaleFactor() const override;
204 virtual void resetScrollAndScaleState() override;
205 virtual void setIgnoreViewportTagScaleLimits(bool) override;
206 virtual WebSize contentsPreferredMinimumSize() override;
208 virtual float deviceScaleFactor() const override;
209 virtual void setDeviceScaleFactor(float) override;
210 virtual void setDeviceColorProfile(const WebVector<char>&) override;
211 virtual void resetDeviceColorProfile() override;
213 virtual void enableAutoResizeMode(
214 const WebSize& minSize,
215 const WebSize& maxSize) override;
216 virtual void disableAutoResizeMode() override;
217 virtual void performMediaPlayerAction(
218 const WebMediaPlayerAction& action,
219 const WebPoint& location) override;
220 virtual void performPluginAction(
221 const WebPluginAction&,
222 const WebPoint&) override;
223 virtual WebHitTestResult hitTestResultAt(const WebPoint&) override;
224 virtual void copyImageAt(const WebPoint&) override;
225 virtual void saveImageAt(const WebPoint&) override;
226 virtual void dragSourceEndedAt(
227 const WebPoint& clientPoint,
228 const WebPoint& screenPoint,
229 WebDragOperation) override;
230 virtual void dragSourceSystemDragEnded() override;
231 virtual WebDragOperation dragTargetDragEnter(
233 const WebPoint& clientPoint,
234 const WebPoint& screenPoint,
235 WebDragOperationsMask operationsAllowed,
236 int keyModifiers) override;
237 virtual WebDragOperation dragTargetDragOver(
238 const WebPoint& clientPoint,
239 const WebPoint& screenPoint,
240 WebDragOperationsMask operationsAllowed,
241 int keyModifiers) override;
242 virtual void dragTargetDragLeave() override;
243 virtual void dragTargetDrop(
244 const WebPoint& clientPoint,
245 const WebPoint& screenPoint,
246 int keyModifiers) override;
247 virtual void spellingMarkers(WebVector<uint32_t>* markers) override;
248 virtual void removeSpellingMarkersUnderWords(const WebVector<WebString>& words) override;
249 virtual unsigned long createUniqueIdentifierForRequest() override;
250 virtual void inspectElementAt(const WebPoint&) override;
251 virtual void setCompositorDeviceScaleFactorOverride(float) override;
252 virtual void setRootLayerTransform(const WebSize& offset, float scale) override;
253 virtual WebDevToolsAgent* devToolsAgent() override;
254 virtual WebAXObject accessibilityObject() override;
255 virtual void setSelectionColors(unsigned activeBackgroundColor,
256 unsigned activeForegroundColor,
257 unsigned inactiveBackgroundColor,
258 unsigned inactiveForegroundColor) override;
259 virtual void performCustomContextMenuAction(unsigned action) override;
260 virtual void showContextMenu() override;
261 virtual void extractSmartClipData(WebRect, WebString&, WebString&, WebRect&) override;
262 virtual void hidePopups() override;
263 virtual void addPageOverlay(WebPageOverlay*, int /* zOrder */) override;
264 virtual void removePageOverlay(WebPageOverlay*) override;
265 virtual void transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters&) override;
266 virtual bool endActiveFlingAnimation() override;
267 virtual void setShowPaintRects(bool) override;
268 void setShowDebugBorders(bool);
269 virtual void setShowFPSCounter(bool) override;
270 virtual void setContinuousPaintingEnabled(bool) override;
271 virtual void setShowScrollBottleneckRects(bool) override;
272 virtual void getSelectionRootBounds(WebRect& bounds) const override;
273 virtual void acceptLanguagesChanged() override;
277 HitTestResult coreHitTestResultAt(const WebPoint&);
278 void suppressInvalidations(bool enable);
279 void invalidateRect(const IntRect&);
281 void setIgnoreInputEvents(bool newValue);
282 void setBackgroundColorOverride(WebColor);
283 void setZoomFactorOverride(float);
284 WebDevToolsAgentPrivate* devToolsAgentPrivate() { return m_devToolsAgent.get(); }
286 Color baseBackgroundColor() const { return m_baseBackgroundColor; }
288 PageOverlayList* pageOverlays() const { return m_pageOverlays.get(); }
290 void setOverlayLayer(GraphicsLayer*);
292 const WebPoint& lastMouseDownPoint() const
294 return m_lastMouseDownPoint;
297 Frame* focusedCoreFrame() const;
299 // Returns the currently focused Element or null if no element has focus.
300 Element* focusedElement() const;
302 static WebViewImpl* fromPage(Page*);
304 WebViewClient* client()
309 WebAutofillClient* autofillClient()
311 return m_autofillClient;
314 WebSpellCheckClient* spellCheckClient()
316 return m_spellCheckClient;
319 // Returns the page object associated with this view. This may be null when
320 // the page is shutting down, but will be valid at all other times.
326 // Returns the main frame associated with this view. This may be null when
327 // the page is shutting down, but will be valid at all other times.
328 WebLocalFrameImpl* mainFrameImpl();
330 // FIXME: Temporary method to accommodate out-of-process frame ancestors;
331 // will be removed when there can be multiple WebWidgets for a single page.
332 WebLocalFrameImpl* localFrameRootTemporary() const;
334 // Event related methods:
335 void mouseContextMenu(const WebMouseEvent&);
336 void mouseDoubleClick(const WebMouseEvent&);
338 bool detectContentOnTouch(const GestureEventWithHitTestResults& targetedEvent);
339 bool startPageScaleAnimation(const IntPoint& targetPosition, bool useAnchor, float newScale, double durationInSeconds);
341 void hasTouchEventHandlers(bool);
343 // WebGestureCurveTarget implementation for fling.
344 virtual bool scrollBy(const WebFloatSize& delta, const WebFloatSize& velocity) override;
346 // Handles context menu events orignated via the the keyboard. These
347 // include the VK_APPS virtual key and the Shift+F10 combine. Code is
348 // based on the Webkit function bool WebView::handleContextMenuEvent(WPARAM
349 // wParam, LPARAM lParam) in webkit\webkit\win\WebView.cpp. The only
350 // significant change in this function is the code to convert from a
351 // Keyboard event to the Right Mouse button down event.
352 bool sendContextMenuEvent(const WebKeyboardEvent&);
354 void showContextMenuAtPoint(float x, float y, PassRefPtrWillBeRawPtr<ContextMenuProvider>);
356 // Notifies the WebView that a load has been committed. isNewNavigation
357 // will be true if a new session history item should be created for that
358 // load. isNavigationWithinPage will be true if the navigation does
359 // not take the user away from the current page.
360 void didCommitLoad(bool isNewNavigation, bool isNavigationWithinPage);
362 // Indicates two things:
363 // 1) This view may have a new layout now.
364 // 2) Calling layout() is a no-op.
365 // After calling WebWidget::layout(), expect to get this notification
366 // unless the view did not need a layout.
367 void layoutUpdated(WebLocalFrameImpl*);
369 void willInsertBody(WebLocalFrameImpl*);
370 void didRemoveAllPendingStylesheet(WebLocalFrameImpl*);
371 void didChangeContentsSize();
372 void deviceOrPageScaleFactorChanged();
374 // Returns true if popup menus should be rendered by the browser, false if
375 // they should be rendered by WebKit (which is the default).
376 static bool useExternalPopupMenus();
378 bool contextMenuAllowed() const
380 return m_contextMenuAllowed;
383 bool shouldAutoResize() const
385 return m_shouldAutoResize;
388 IntSize minAutoSize() const
390 return m_minAutoSize;
393 IntSize maxAutoSize() const
395 return m_maxAutoSize;
398 void updateMainFrameLayoutSize();
399 void updatePageDefinedViewportConstraints(const ViewportDescription&);
401 // Start a system drag and drop operation.
404 const WebDragData& dragData,
405 WebDragOperationsMask mask,
406 const WebImage& dragImage,
407 const WebPoint& dragImageOffset);
409 // Notification that a popup was opened/closed.
410 void popupOpened(PopupContainer*);
411 void popupClosed(PopupContainer*);
412 // PagePopupDriver functions.
413 virtual PagePopup* openPagePopup(PagePopupClient*, const IntRect& originBoundsInRootView) override;
414 virtual void closePagePopup(PagePopup*) override;
415 virtual LocalDOMWindow* pagePopupWindow() override;
417 // Returns the input event we're currently processing. This is used in some
418 // cases where the WebCore DOM event doesn't have the information we need.
419 static const WebInputEvent* currentInputEvent()
421 return m_currentInputEvent;
424 GraphicsLayer* rootGraphicsLayer();
425 void setRootGraphicsLayer(GraphicsLayer*);
426 void scheduleCompositingLayerSync();
427 GraphicsLayerFactory* graphicsLayerFactory() const;
428 RenderLayerCompositor* compositor() const;
429 void registerForAnimations(WebLayer*);
430 void scheduleAnimation();
432 virtual void setVisibilityState(WebPageVisibilityState, bool) override;
434 PopupContainer* selectPopup() const { return m_selectPopup.get(); }
435 bool hasOpenedPopup() const { return m_selectPopup || m_pagePopup; }
437 // Returns true if the event leads to scrolling.
438 static bool mapKeyCodeForScroll(
443 // Called by a full frame plugin inside this view to inform it that its
444 // zoom level has been updated. The plugin should only call this function
445 // if the zoom change was triggered by the browser, it's only needed in case
446 // a plugin can update its own zoom, say because of its own UI.
447 void fullFramePluginZoomLevelChanged(double zoomLevel);
449 void computeScaleAndScrollForBlockRect(const WebPoint& hitPoint, const WebRect& blockRect, float padding, float defaultScaleWhenAlreadyLegible, float& scale, WebPoint& scroll);
450 Node* bestTapNode(const GestureEventWithHitTestResults& targetedTapEvent);
451 void enableTapHighlightAtPoint(const GestureEventWithHitTestResults& targetedTapEvent);
452 void enableTapHighlights(WillBeHeapVector<RawPtrWillBeMember<Node> >&);
453 void computeScaleAndScrollForFocusedNode(Node* focusedNode, float& scale, IntPoint& scroll, bool& needAnimation);
455 void animateDoubleTapZoom(const IntPoint&);
457 void enableFakePageScaleAnimationForTesting(bool);
458 bool fakeDoubleTapAnimationPendingForTesting() const { return m_doubleTapZoomPending; }
459 IntPoint fakePageScaleAnimationTargetPositionForTesting() const { return m_fakePageScaleAnimationTargetPosition; }
460 float fakePageScaleAnimationPageScaleForTesting() const { return m_fakePageScaleAnimationPageScaleFactor; }
461 bool fakePageScaleAnimationUseAnchorForTesting() const { return m_fakePageScaleAnimationUseAnchor; }
463 void enterFullScreenForElement(Element*);
464 void exitFullScreenForElement(Element*);
466 void clearCompositedSelectionBounds();
467 void updateCompositedSelectionBounds(const WebSelectionBound& anchor, const WebSelectionBound& focus);
469 // Exposed for the purpose of overriding device metrics.
470 void sendResizeEventAndRepaint();
472 // Exposed for testing purposes.
473 bool hasHorizontalScrollbar();
474 bool hasVerticalScrollbar();
476 // Pointer Lock calls allow a page to capture all mouse events and
477 // disable the system cursor.
478 bool requestPointerLock();
479 void requestPointerUnlock();
480 bool isPointerLocked();
482 // Heuristic-based function for determining if we should disable workarounds
483 // for viewing websites that are not optimized for mobile devices.
484 bool shouldDisableDesktopWorkarounds();
486 // Exposed for tests.
487 unsigned numLinkHighlights() { return m_linkHighlights.size(); }
488 LinkHighlight* linkHighlight(int i) { return m_linkHighlights[i].get(); }
490 WebSettingsImpl* settingsImpl();
492 // Returns the bounding box of the block type node touched by the WebRect.
493 WebRect computeBlockBounds(const WebRect&, bool ignoreClipping);
495 // FIXME(bokan): Replace with PinchViewport::clampDocumentOffsetAtScale once
497 IntPoint clampOffsetAtScale(const IntPoint& offset, float scale);
499 // Exposed for tests.
500 WebVector<WebCompositionUnderline> compositionUnderlines() const;
502 WebLayerTreeView* layerTreeView() const { return m_layerTreeView; }
504 bool pinchVirtualViewportEnabled() const;
506 bool matchesHeuristicsForGpuRasterizationForTesting() const { return m_matchesHeuristicsForGpuRasterization; }
508 virtual void setTopControlsLayoutHeight(float) override;
510 IntSize mainFrameSize();
513 void didUpdateTopControls();
514 void setTopControlsContentOffset(float);
516 // TODO(bokan): Remains for legacy pinch. Remove once it's gone. Made private to
517 // prevent external usage
518 virtual void setPageScaleFactor(float scaleFactor, const WebPoint& origin) override;
519 void setPageScaleFactorAndLocation(float, const FloatPoint&);
521 void scrollAndRescaleViewports(float scaleFactor, const IntPoint& mainFrameOrigin, const FloatPoint& pinchViewportOrigin);
523 IntRect visibleRectInDocument() const;
525 float legibleScale() const;
526 void refreshPageScaleFactorAfterLayout();
527 void resumeTreeViewCommits();
528 void setUserAgentPageScaleConstraints(PageScaleConstraints newConstraints);
529 float clampPageScaleFactorToLimits(float) const;
530 IntSize contentsSize() const;
532 void updateMainFrameScrollPosition(const IntPoint& scrollPosition, bool programmaticScroll);
534 void performResize();
536 friend class WebView; // So WebView::Create can call our constructor
537 friend class WTF::RefCounted<WebViewImpl>;
538 friend void setCurrentInputEventForTest(const WebInputEvent*);
545 explicit WebViewImpl(WebViewClient*);
546 virtual ~WebViewImpl();
548 WebTextInputType textInputType();
549 int textInputFlags();
551 WebString inputModeOfFocusedElement();
553 // Returns true if the event was actually processed.
554 bool keyEventDefault(const WebKeyboardEvent&);
556 bool confirmComposition(const WebString& text, ConfirmCompositionBehavior);
558 // Returns true if the view was scrolled.
559 bool scrollViewWithKeyboard(int keyCode, int modifiers);
561 void hideSelectPopup();
563 // Converts |pos| from window coordinates to contents coordinates and gets
564 // the HitTestResult for it.
565 HitTestResult hitTestResultForWindowPos(const IntPoint&);
567 // Consolidate some common code between starting a drag over a target and
568 // updating a drag over a target. If we're starting a drag, |isEntering|
570 WebDragOperation dragTargetDragEnterOrOver(const WebPoint& clientPoint,
571 const WebPoint& screenPoint,
575 void configureAutoResizeMode();
577 void initializeLayerTreeView();
579 void setIsAcceleratedCompositingActive(bool);
581 void reallocateRenderer();
582 void updateLayerTreeViewport();
583 void updateLayerTreeBackgroundColor();
584 void updateRootLayerTransform();
585 void updateLayerTreeDeviceScaleFactor();
587 // Helper function: Widens the width of |source| by the specified margins
588 // while keeping it smaller than page width.
589 WebRect widenRectWithinPageBounds(const WebRect& source, int targetMargin, int minimumMargin);
591 void pointerLockMouseEvent(const WebInputEvent&);
593 // PageWidgetEventHandler functions
594 virtual void handleMouseLeave(LocalFrame&, const WebMouseEvent&) override;
595 virtual void handleMouseDown(LocalFrame&, const WebMouseEvent&) override;
596 virtual void handleMouseUp(LocalFrame&, const WebMouseEvent&) override;
597 virtual bool handleMouseWheel(LocalFrame&, const WebMouseWheelEvent&) override;
598 virtual bool handleGestureEvent(const WebGestureEvent&) override;
599 virtual bool handleKeyEvent(const WebKeyboardEvent&) override;
600 virtual bool handleCharEvent(const WebKeyboardEvent&) override;
602 InputMethodContext* inputMethodContext();
603 WebPlugin* focusedPluginIfInputMethodSupported(LocalFrame*);
605 WebViewClient* m_client; // Can be 0 (e.g. unittests, shared workers, etc.)
606 WebAutofillClient* m_autofillClient;
607 WebSpellCheckClient* m_spellCheckClient;
609 ChromeClientImpl m_chromeClientImpl;
610 ContextMenuClientImpl m_contextMenuClientImpl;
611 DragClientImpl m_dragClientImpl;
612 EditorClientImpl m_editorClientImpl;
613 InspectorClientImpl m_inspectorClientImpl;
614 SpellCheckerClientImpl m_spellCheckerClientImpl;
615 StorageClientImpl m_storageClientImpl;
618 // If true, automatically resize the render view around its content.
619 bool m_shouldAutoResize;
620 // The lower bound on the size when auto-resizing.
621 IntSize m_minAutoSize;
622 // The upper bound on the size when auto-resizing.
623 IntSize m_maxAutoSize;
625 OwnPtrWillBePersistent<Page> m_page;
627 // An object that can be used to manipulate m_page->settings() without linking
628 // against WebCore. This is lazily allocated the first time GetWebSettings()
630 OwnPtr<WebSettingsImpl> m_webSettings;
632 // A copy of the web drop data object we received from the browser.
633 RefPtrWillBePersistent<DataObject> m_currentDragData;
635 // The point relative to the client area where the mouse was last pressed
636 // down. This is used by the drag client to determine what was under the
637 // mouse when the drag was initiated. We need to track this here in
638 // WebViewImpl since DragClient::startDrag does not pass the position the
639 // mouse was at when the drag was initiated, only the current point, which
640 // can be misleading as it is usually not over the element the user actually
641 // dragged by the time a drag is initiated.
642 WebPoint m_lastMouseDownPoint;
644 // Keeps track of the current zoom level. 0 means no zoom, positive numbers
645 // mean zoom in, negative numbers mean zoom out.
648 double m_minimumZoomLevel;
650 double m_maximumZoomLevel;
652 PageScaleConstraintsSet m_pageScaleConstraintsSet;
654 // The scale moved to by the latest double tap zoom, if any.
655 float m_doubleTapZoomPageScaleFactor;
656 // Have we sent a double-tap zoom and not yet heard back the scale?
657 bool m_doubleTapZoomPending;
659 // Used for testing purposes.
660 bool m_enableFakePageScaleAnimationForTesting;
661 IntPoint m_fakePageScaleAnimationTargetPosition;
662 float m_fakePageScaleAnimationPageScaleFactor;
663 bool m_fakePageScaleAnimationUseAnchor;
665 bool m_contextMenuAllowed;
667 bool m_doingDragAndDrop;
669 bool m_ignoreInputEvents;
671 float m_compositorDeviceScaleFactorOverride;
672 WebSize m_rootLayerOffset;
673 float m_rootLayerScale;
675 // Webkit expects keyPress events to be suppressed if the associated keyDown
676 // event was handled. Safari implements this behavior by peeking out the
677 // associated WM_CHAR event if the keydown was handled. We emulate
678 // this behavior by setting this flag if the keyDown was handled.
679 bool m_suppressNextKeypressEvent;
681 // Represents whether or not this object should process incoming IME events.
682 bool m_imeAcceptEvents;
684 // The available drag operations (copy, move link...) allowed by the source.
685 WebDragOperation m_operationsAllowed;
687 // The current drag operation as negotiated by the source and destination.
688 // When not equal to DragOperationNone, the drag data can be dropped onto the
689 // current drop target in this WebView (the drop target can accept the drop).
690 WebDragOperation m_dragOperation;
692 // The popup associated with a select element.
693 RefPtrWillBePersistent<PopupContainer> m_selectPopup;
695 // The popup associated with an input element.
696 RefPtr<WebPagePopupImpl> m_pagePopup;
698 OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent;
699 OwnPtr<PageOverlayList> m_pageOverlays;
701 // Whether the webview is rendering transparently.
702 bool m_isTransparent;
704 // Whether the user can press tab to focus links.
707 // If set, the (plugin) node which has mouse capture.
708 RefPtrWillBePersistent<Node> m_mouseCaptureNode;
709 RefPtr<UserGestureToken> m_mouseCaptureGestureToken;
711 RefPtr<UserGestureToken> m_pointerLockGestureToken;
713 IntRect m_rootLayerScrollDamage;
714 WebLayerTreeView* m_layerTreeView;
715 WebLayer* m_rootLayer;
716 GraphicsLayer* m_rootGraphicsLayer;
717 GraphicsLayer* m_rootTransformLayer;
718 OwnPtr<GraphicsLayerFactory> m_graphicsLayerFactory;
719 bool m_isAcceleratedCompositingActive;
720 bool m_layerTreeViewCommitsDeferred;
721 bool m_layerTreeViewClosed;
722 bool m_matchesHeuristicsForGpuRasterization;
723 // If true, the graphics context is being restored.
724 bool m_recreatingGraphicsContext;
725 static const WebInputEvent* m_currentInputEvent;
727 MediaKeysClientImpl m_mediaKeysClientImpl;
728 OwnPtr<WebActiveGestureAnimation> m_gestureAnimation;
729 WebPoint m_positionOnFlingStart;
730 WebPoint m_globalPositionOnFlingStart;
732 bool m_flingSourceDevice;
733 Vector<OwnPtr<LinkHighlight> > m_linkHighlights;
734 OwnPtrWillBePersistent<FullscreenController> m_fullscreenController;
736 bool m_showFPSCounter;
737 bool m_showPaintRects;
738 bool m_showDebugBorders;
739 bool m_continuousPaintingEnabled;
740 bool m_showScrollBottleneckRects;
741 WebColor m_baseBackgroundColor;
742 WebColor m_backgroundColorOverride;
743 float m_zoomFactorOverride;
745 bool m_userGestureObserved;
747 // The top controls offset since the last compositor commit.
748 float m_topControlsContentOffset;
750 // The top controls offset at the time of the last Resize event. This is the
751 // amount that the viewport was shrunk by to accomodate the top controls.
752 float m_topControlsLayoutHeight;
755 // We have no ways to check if the specified WebView is an instance of
756 // WebViewImpl because WebViewImpl is the only implementation of WebView.
757 DEFINE_TYPE_CASTS(WebViewImpl, WebView, webView, true, true);