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/PagePopupDriver.h"
35 #include "platform/geometry/IntPoint.h"
36 #include "platform/geometry/IntRect.h"
37 #include "platform/graphics/GraphicsLayer.h"
38 #include "public/platform/WebGestureCurveTarget.h"
39 #include "public/platform/WebLayer.h"
40 #include "public/platform/WebPoint.h"
41 #include "public/platform/WebRect.h"
42 #include "public/platform/WebSize.h"
43 #include "public/platform/WebString.h"
44 #include "public/web/WebInputEvent.h"
45 #include "public/web/WebNavigationPolicy.h"
46 #include "public/web/WebView.h"
47 #include "web/BackForwardClientImpl.h"
48 #include "web/ChromeClientImpl.h"
49 #include "web/ContextMenuClientImpl.h"
50 #include "web/DragClientImpl.h"
51 #include "web/EditorClientImpl.h"
52 #include "web/InspectorClientImpl.h"
53 #include "web/MediaKeysClientImpl.h"
54 #include "web/PageOverlayList.h"
55 #include "web/PageScaleConstraintsSet.h"
56 #include "web/PageWidgetDelegate.h"
57 #include "web/SpellCheckerClientImpl.h"
58 #include "web/StorageClientImpl.h"
59 #include "wtf/OwnPtr.h"
60 #include "wtf/RefCounted.h"
61 #include "wtf/Vector.h"
67 class FullscreenController;
70 class RenderLayerCompositor;
71 class UserGestureToken;
72 class WebActiveGestureAnimation;
73 class WebDevToolsAgentPrivate;
74 class WebLocalFrameImpl;
76 class WebPagePopupImpl;
78 class WebSettingsImpl;
80 class WebViewImpl FINAL : public WebView
81 , public RefCounted<WebViewImpl>
82 , public WebGestureCurveTarget
83 , public PagePopupDriver
84 , public PageWidgetEventHandler {
86 static WebViewImpl* create(WebViewClient*);
89 virtual void close() OVERRIDE;
90 virtual WebSize size() OVERRIDE;
91 virtual void willStartLiveResize() OVERRIDE;
92 virtual void resize(const WebSize&) OVERRIDE;
93 virtual void resizePinchViewport(const WebSize&) OVERRIDE;
94 virtual void willEndLiveResize() OVERRIDE;
95 virtual void willEnterFullScreen() OVERRIDE;
96 virtual void didEnterFullScreen() OVERRIDE;
97 virtual void willExitFullScreen() OVERRIDE;
98 virtual void didExitFullScreen() OVERRIDE;
100 virtual void beginFrame(const WebBeginFrameArgs&) OVERRIDE;
102 virtual void layout() OVERRIDE;
103 virtual void paint(WebCanvas*, const WebRect&) OVERRIDE;
105 virtual void paintCompositedDeprecated(WebCanvas*, const WebRect&) OVERRIDE;
107 virtual void compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback*) OVERRIDE;
108 virtual bool isTrackingRepaints() const OVERRIDE;
109 virtual void themeChanged() OVERRIDE;
110 virtual bool handleInputEvent(const WebInputEvent&) OVERRIDE;
111 virtual void setCursorVisibilityState(bool isVisible) OVERRIDE;
112 virtual bool hasTouchEventHandlersAt(const WebPoint&) OVERRIDE;
113 virtual void applyScrollAndScale(const WebSize&, float) OVERRIDE;
114 virtual void mouseCaptureLost() OVERRIDE;
115 virtual void setFocus(bool enable) OVERRIDE;
116 virtual bool setComposition(
117 const WebString& text,
118 const WebVector<WebCompositionUnderline>& underlines,
120 int selectionEnd) OVERRIDE;
121 virtual bool confirmComposition() OVERRIDE;
122 virtual bool confirmComposition(ConfirmCompositionBehavior selectionBehavior) OVERRIDE;
123 virtual bool confirmComposition(const WebString& text) OVERRIDE;
124 virtual bool compositionRange(size_t* location, size_t* length) OVERRIDE;
125 virtual WebTextInputInfo textInputInfo() OVERRIDE;
126 virtual WebColor backgroundColor() const OVERRIDE;
127 virtual bool selectionBounds(WebRect& anchor, WebRect& focus) const OVERRIDE;
128 virtual void didShowCandidateWindow() OVERRIDE;
129 virtual void didUpdateCandidateWindow() OVERRIDE;
130 virtual void didHideCandidateWindow() OVERRIDE;
131 virtual bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const OVERRIDE;
132 virtual bool isSelectionAnchorFirst() const OVERRIDE;
133 virtual bool caretOrSelectionRange(size_t* location, size_t* length) OVERRIDE;
134 virtual void setTextDirection(WebTextDirection) OVERRIDE;
135 virtual bool isAcceleratedCompositingActive() const OVERRIDE;
136 virtual void willCloseLayerTreeView() OVERRIDE;
137 virtual void didAcquirePointerLock() OVERRIDE;
138 virtual void didNotAcquirePointerLock() OVERRIDE;
139 virtual void didLosePointerLock() OVERRIDE;
140 virtual void didChangeWindowResizerRect() OVERRIDE;
143 virtual void setMainFrame(WebFrame*) OVERRIDE;
144 virtual void setAutofillClient(WebAutofillClient*) OVERRIDE;
145 virtual void setDevToolsAgentClient(WebDevToolsAgentClient*) OVERRIDE;
146 virtual void setPrerendererClient(WebPrerendererClient*) OVERRIDE;
147 virtual void setSpellCheckClient(WebSpellCheckClient*) OVERRIDE;
148 virtual WebSettings* settings() OVERRIDE;
149 virtual WebString pageEncoding() const OVERRIDE;
150 virtual void setPageEncoding(const WebString&) OVERRIDE;
151 virtual bool isTransparent() const OVERRIDE;
152 virtual void setIsTransparent(bool value) OVERRIDE;
153 virtual void setBaseBackgroundColor(WebColor) OVERRIDE;
154 virtual bool tabsToLinks() const OVERRIDE;
155 virtual void setTabsToLinks(bool value) OVERRIDE;
156 virtual bool tabKeyCyclesThroughElements() const OVERRIDE;
157 virtual void setTabKeyCyclesThroughElements(bool value) OVERRIDE;
158 virtual bool isActive() const OVERRIDE;
159 virtual void setIsActive(bool value) OVERRIDE;
160 virtual void setDomainRelaxationForbidden(bool, const WebString& scheme) OVERRIDE;
161 virtual void setWindowFeatures(const WebWindowFeatures&) OVERRIDE;
162 virtual void setOpenedByDOM() OVERRIDE;
163 virtual WebFrame* mainFrame() OVERRIDE;
164 virtual WebFrame* findFrameByName(
165 const WebString& name, WebFrame* relativeToFrame) OVERRIDE;
166 virtual WebFrame* focusedFrame() OVERRIDE;
167 virtual void setFocusedFrame(WebFrame*) OVERRIDE;
168 virtual void setInitialFocus(bool reverse) OVERRIDE;
169 virtual void clearFocusedElement() OVERRIDE;
170 virtual void scrollFocusedNodeIntoRect(const WebRect&) OVERRIDE;
171 virtual void zoomToFindInPageRect(const WebRect&) OVERRIDE;
172 virtual void advanceFocus(bool reverse) OVERRIDE;
173 virtual double zoomLevel() OVERRIDE;
174 virtual double setZoomLevel(double) OVERRIDE;
175 virtual void zoomLimitsChanged(double minimumZoomLevel, double maximumZoomLevel) OVERRIDE;
176 virtual float textZoomFactor() OVERRIDE;
177 virtual float setTextZoomFactor(float) OVERRIDE;
178 virtual void setInitialPageScaleOverride(float) OVERRIDE;
179 virtual bool zoomToMultipleTargetsRect(const WebRect&) OVERRIDE;
180 virtual float pageScaleFactor() const OVERRIDE;
181 virtual void setPageScaleFactorLimits(float minPageScale, float maxPageScale) OVERRIDE;
182 virtual void setMainFrameScrollOffset(const WebPoint&) OVERRIDE;
183 virtual void setPageScaleFactor(float) OVERRIDE;
184 virtual void setPinchViewportOffset(const WebFloatPoint&) OVERRIDE;
185 virtual WebFloatPoint pinchViewportOffset() const OVERRIDE;
186 virtual float minimumPageScaleFactor() const OVERRIDE;
187 virtual float maximumPageScaleFactor() const OVERRIDE;
188 virtual void resetScrollAndScaleState() OVERRIDE;
189 virtual void setIgnoreViewportTagScaleLimits(bool) OVERRIDE;
190 virtual WebSize contentsPreferredMinimumSize() OVERRIDE;
192 virtual float deviceScaleFactor() const OVERRIDE;
193 virtual void setDeviceScaleFactor(float) OVERRIDE;
195 virtual void setFixedLayoutSize(const WebSize&) OVERRIDE;
197 virtual void enableAutoResizeMode(
198 const WebSize& minSize,
199 const WebSize& maxSize) OVERRIDE;
200 virtual void disableAutoResizeMode() OVERRIDE;
201 virtual void performMediaPlayerAction(
202 const WebMediaPlayerAction& action,
203 const WebPoint& location) OVERRIDE;
204 virtual void performPluginAction(
205 const WebPluginAction&,
206 const WebPoint&) OVERRIDE;
207 virtual WebHitTestResult hitTestResultAt(const WebPoint&) OVERRIDE;
208 virtual void copyImageAt(const WebPoint&) OVERRIDE;
209 virtual void saveImageAt(const WebPoint&) OVERRIDE;
210 virtual void dragSourceEndedAt(
211 const WebPoint& clientPoint,
212 const WebPoint& screenPoint,
213 WebDragOperation) OVERRIDE;
214 virtual void dragSourceSystemDragEnded() OVERRIDE;
215 virtual WebDragOperation dragTargetDragEnter(
217 const WebPoint& clientPoint,
218 const WebPoint& screenPoint,
219 WebDragOperationsMask operationsAllowed,
220 int keyModifiers) OVERRIDE;
221 virtual WebDragOperation dragTargetDragOver(
222 const WebPoint& clientPoint,
223 const WebPoint& screenPoint,
224 WebDragOperationsMask operationsAllowed,
225 int keyModifiers) OVERRIDE;
226 virtual void dragTargetDragLeave() OVERRIDE;
227 virtual void dragTargetDrop(
228 const WebPoint& clientPoint,
229 const WebPoint& screenPoint,
230 int keyModifiers) OVERRIDE;
231 virtual void spellingMarkers(WebVector<uint32_t>* markers) OVERRIDE;
232 virtual unsigned long createUniqueIdentifierForRequest() OVERRIDE;
233 virtual void inspectElementAt(const WebPoint&) OVERRIDE;
234 virtual void setCompositorDeviceScaleFactorOverride(float) OVERRIDE;
235 virtual void setRootLayerTransform(const WebSize& offset, float scale) OVERRIDE;
236 virtual WebDevToolsAgent* devToolsAgent() OVERRIDE;
237 virtual WebAXObject accessibilityObject() OVERRIDE;
238 virtual void setSelectionColors(unsigned activeBackgroundColor,
239 unsigned activeForegroundColor,
240 unsigned inactiveBackgroundColor,
241 unsigned inactiveForegroundColor) OVERRIDE;
242 virtual void performCustomContextMenuAction(unsigned action) OVERRIDE;
243 virtual void showContextMenu() OVERRIDE;
244 virtual void extractSmartClipData(WebRect, WebString&, WebString&, WebRect&) OVERRIDE;
245 virtual void hidePopups() OVERRIDE;
246 virtual void addPageOverlay(WebPageOverlay*, int /* zOrder */) OVERRIDE;
247 virtual void removePageOverlay(WebPageOverlay*) OVERRIDE;
248 virtual void transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters&) OVERRIDE;
249 virtual bool endActiveFlingAnimation() OVERRIDE;
250 virtual void setShowPaintRects(bool) OVERRIDE;
251 void setShowDebugBorders(bool);
252 virtual void setShowFPSCounter(bool) OVERRIDE;
253 virtual void setContinuousPaintingEnabled(bool) OVERRIDE;
254 virtual void setShowScrollBottleneckRects(bool) OVERRIDE;
255 virtual void getSelectionRootBounds(WebRect& bounds) const OVERRIDE;
256 virtual void acceptLanguagesChanged() OVERRIDE;
260 HitTestResult coreHitTestResultAt(const WebPoint&);
261 void suppressInvalidations(bool enable);
262 void invalidateRect(const IntRect&);
264 void setIgnoreInputEvents(bool newValue);
265 void setBackgroundColorOverride(WebColor);
266 void setZoomFactorOverride(float);
267 WebDevToolsAgentPrivate* devToolsAgentPrivate() { return m_devToolsAgent.get(); }
269 Color baseBackgroundColor() const { return m_baseBackgroundColor; }
271 PageOverlayList* pageOverlays() const { return m_pageOverlays.get(); }
273 void setOverlayLayer(GraphicsLayer*);
275 const WebPoint& lastMouseDownPoint() const
277 return m_lastMouseDownPoint;
280 Frame* focusedCoreFrame() const;
282 // Returns the currently focused Element or null if no element has focus.
283 Element* focusedElement() const;
285 static WebViewImpl* fromPage(Page*);
287 WebViewClient* client()
292 WebAutofillClient* autofillClient()
294 return m_autofillClient;
297 WebSpellCheckClient* spellCheckClient()
299 return m_spellCheckClient;
302 // Returns the page object associated with this view. This may be null when
303 // the page is shutting down, but will be valid at all other times.
309 // Returns the main frame associated with this view. This may be null when
310 // the page is shutting down, but will be valid at all other times.
311 WebLocalFrameImpl* mainFrameImpl();
313 // FIXME: Temporary method to accommodate out-of-process frame ancestors;
314 // will be removed when there can be multiple WebWidgets for a single page.
315 WebLocalFrameImpl* localFrameRootTemporary() const;
317 // Event related methods:
318 void mouseContextMenu(const WebMouseEvent&);
319 void mouseDoubleClick(const WebMouseEvent&);
321 bool detectContentOnTouch(const WebPoint&);
322 bool startPageScaleAnimation(const IntPoint& targetPosition, bool useAnchor, float newScale, double durationInSeconds);
324 void hasTouchEventHandlers(bool);
326 // WebGestureCurveTarget implementation for fling.
327 virtual bool scrollBy(const WebFloatSize& delta, const WebFloatSize& velocity) OVERRIDE;
329 // Handles context menu events orignated via the the keyboard. These
330 // include the VK_APPS virtual key and the Shift+F10 combine. Code is
331 // based on the Webkit function bool WebView::handleContextMenuEvent(WPARAM
332 // wParam, LPARAM lParam) in webkit\webkit\win\WebView.cpp. The only
333 // significant change in this function is the code to convert from a
334 // Keyboard event to the Right Mouse button down event.
335 bool sendContextMenuEvent(const WebKeyboardEvent&);
337 void showContextMenuAtPoint(float x, float y, PassRefPtr<ContextMenuProvider>);
339 // Notifies the WebView that a load has been committed. isNewNavigation
340 // will be true if a new session history item should be created for that
341 // load. isNavigationWithinPage will be true if the navigation does
342 // not take the user away from the current page.
343 void didCommitLoad(bool isNewNavigation, bool isNavigationWithinPage);
345 // Indicates two things:
346 // 1) This view may have a new layout now.
347 // 2) Calling layout() is a no-op.
348 // After calling WebWidget::layout(), expect to get this notification
349 // unless the view did not need a layout.
350 void layoutUpdated(WebLocalFrameImpl*);
352 void willInsertBody(WebLocalFrameImpl*);
353 void didRemoveAllPendingStylesheet(WebLocalFrameImpl*);
354 void didChangeContentsSize();
355 void deviceOrPageScaleFactorChanged();
357 // Returns true if popup menus should be rendered by the browser, false if
358 // they should be rendered by WebKit (which is the default).
359 static bool useExternalPopupMenus();
361 bool contextMenuAllowed() const
363 return m_contextMenuAllowed;
366 bool shouldAutoResize() const
368 return m_shouldAutoResize;
371 IntSize minAutoSize() const
373 return m_minAutoSize;
376 IntSize maxAutoSize() const
378 return m_maxAutoSize;
381 void updateMainFrameLayoutSize();
382 void updatePageDefinedViewportConstraints(const ViewportDescription&);
384 // Start a system drag and drop operation.
387 const WebDragData& dragData,
388 WebDragOperationsMask mask,
389 const WebImage& dragImage,
390 const WebPoint& dragImageOffset);
392 // Notification that a popup was opened/closed.
393 void popupOpened(PopupContainer*);
394 void popupClosed(PopupContainer*);
395 // PagePopupDriver functions.
396 virtual PagePopup* openPagePopup(PagePopupClient*, const IntRect& originBoundsInRootView) OVERRIDE;
397 virtual void closePagePopup(PagePopup*) OVERRIDE;
399 // Returns the input event we're currently processing. This is used in some
400 // cases where the WebCore DOM event doesn't have the information we need.
401 static const WebInputEvent* currentInputEvent()
403 return m_currentInputEvent;
406 GraphicsLayer* rootGraphicsLayer();
407 void setRootGraphicsLayer(GraphicsLayer*);
408 void scheduleCompositingLayerSync();
409 void scrollRootLayer();
410 GraphicsLayerFactory* graphicsLayerFactory() const;
411 RenderLayerCompositor* compositor() const;
412 void registerForAnimations(WebLayer*);
413 void scheduleAnimation();
415 virtual void setVisibilityState(WebPageVisibilityState, bool) OVERRIDE;
417 PopupContainer* selectPopup() const { return m_selectPopup.get(); }
418 bool hasOpenedPopup() const { return m_selectPopup || m_pagePopup; }
420 // Returns true if the event leads to scrolling.
421 static bool mapKeyCodeForScroll(
426 // Called by a full frame plugin inside this view to inform it that its
427 // zoom level has been updated. The plugin should only call this function
428 // if the zoom change was triggered by the browser, it's only needed in case
429 // a plugin can update its own zoom, say because of its own UI.
430 void fullFramePluginZoomLevelChanged(double zoomLevel);
432 void computeScaleAndScrollForBlockRect(const WebPoint& hitPoint, const WebRect& blockRect, float padding, float defaultScaleWhenAlreadyLegible, float& scale, WebPoint& scroll);
433 Node* bestTapNode(const PlatformGestureEvent& tapEvent);
434 void enableTapHighlightAtPoint(const PlatformGestureEvent& tapEvent);
435 void enableTapHighlights(WillBeHeapVector<RawPtrWillBeMember<Node> >&);
436 void computeScaleAndScrollForFocusedNode(Node* focusedNode, float& scale, IntPoint& scroll, bool& needAnimation);
438 void animateDoubleTapZoom(const IntPoint&);
440 void enableFakePageScaleAnimationForTesting(bool);
441 bool fakeDoubleTapAnimationPendingForTesting() const { return m_doubleTapZoomPending; }
442 IntPoint fakePageScaleAnimationTargetPositionForTesting() const { return m_fakePageScaleAnimationTargetPosition; }
443 float fakePageScaleAnimationPageScaleForTesting() const { return m_fakePageScaleAnimationPageScaleFactor; }
444 bool fakePageScaleAnimationUseAnchorForTesting() const { return m_fakePageScaleAnimationUseAnchor; }
446 void enterFullScreenForElement(Element*);
447 void exitFullScreenForElement(Element*);
449 void clearCompositedSelectionBounds();
451 // Exposed for the purpose of overriding device metrics.
452 void sendResizeEventAndRepaint();
454 // Exposed for testing purposes.
455 bool hasHorizontalScrollbar();
456 bool hasVerticalScrollbar();
458 // Pointer Lock calls allow a page to capture all mouse events and
459 // disable the system cursor.
460 bool requestPointerLock();
461 void requestPointerUnlock();
462 bool isPointerLocked();
464 // Heuristic-based function for determining if we should disable workarounds
465 // for viewing websites that are not optimized for mobile devices.
466 bool shouldDisableDesktopWorkarounds();
468 // Exposed for tests.
469 unsigned numLinkHighlights() { return m_linkHighlights.size(); }
470 LinkHighlight* linkHighlight(int i) { return m_linkHighlights[i].get(); }
472 WebSettingsImpl* settingsImpl();
474 // Returns the bounding box of the block type node touched by the WebRect.
475 WebRect computeBlockBounds(const WebRect&, bool ignoreClipping);
477 IntPoint clampOffsetAtScale(const IntPoint& offset, float scale);
479 // Exposed for tests.
480 WebVector<WebCompositionUnderline> compositionUnderlines() const;
482 WebLayerTreeView* layerTreeView() const { return m_layerTreeView; }
484 bool pinchVirtualViewportEnabled() const;
486 bool matchesHeuristicsForGpuRasterizationForTesting() const { return m_matchesHeuristicsForGpuRasterization; }
489 // TODO(bokan): Remains for legacy pinch. Remove once it's gone. Made private to
490 // prevent external usage
491 virtual void setPageScaleFactor(float scaleFactor, const WebPoint& origin) OVERRIDE;
493 float legibleScale() const;
494 void refreshPageScaleFactorAfterLayout();
495 void resumeTreeViewCommits();
496 void setUserAgentPageScaleConstraints(PageScaleConstraints newConstraints);
497 float clampPageScaleFactorToLimits(float) const;
498 IntSize contentsSize() const;
500 void resetSavedScrollAndScaleState();
502 void updateMainFrameScrollPosition(const IntPoint& scrollPosition, bool programmaticScroll);
504 void performResize();
506 friend class WebView; // So WebView::Create can call our constructor
507 friend class WTF::RefCounted<WebViewImpl>;
508 friend void setCurrentInputEventForTest(const WebInputEvent*);
515 explicit WebViewImpl(WebViewClient*);
516 virtual ~WebViewImpl();
518 WebTextInputType textInputType();
519 int textInputFlags();
521 WebString inputModeOfFocusedElement();
523 // Returns true if the event was actually processed.
524 bool keyEventDefault(const WebKeyboardEvent&);
526 bool confirmComposition(const WebString& text, ConfirmCompositionBehavior);
528 // Returns true if the view was scrolled.
529 bool scrollViewWithKeyboard(int keyCode, int modifiers);
531 void hideSelectPopup();
533 // Converts |pos| from window coordinates to contents coordinates and gets
534 // the HitTestResult for it.
535 HitTestResult hitTestResultForWindowPos(const IntPoint&);
537 // Consolidate some common code between starting a drag over a target and
538 // updating a drag over a target. If we're starting a drag, |isEntering|
540 WebDragOperation dragTargetDragEnterOrOver(const WebPoint& clientPoint,
541 const WebPoint& screenPoint,
545 void configureAutoResizeMode();
547 void initializeLayerTreeView();
549 void setIsAcceleratedCompositingActive(bool);
551 void reallocateRenderer();
552 void updateLayerTreeViewport();
553 void updateLayerTreeBackgroundColor();
554 void updateRootLayerTransform();
555 void updateLayerTreeDeviceScaleFactor();
557 // Helper function: Widens the width of |source| by the specified margins
558 // while keeping it smaller than page width.
559 WebRect widenRectWithinPageBounds(const WebRect& source, int targetMargin, int minimumMargin);
561 void pointerLockMouseEvent(const WebInputEvent&);
563 // PageWidgetEventHandler functions
564 virtual void handleMouseLeave(LocalFrame&, const WebMouseEvent&) OVERRIDE;
565 virtual void handleMouseDown(LocalFrame&, const WebMouseEvent&) OVERRIDE;
566 virtual void handleMouseUp(LocalFrame&, const WebMouseEvent&) OVERRIDE;
567 virtual bool handleMouseWheel(LocalFrame&, const WebMouseWheelEvent&) OVERRIDE;
568 virtual bool handleGestureEvent(const WebGestureEvent&) OVERRIDE;
569 virtual bool handleKeyEvent(const WebKeyboardEvent&) OVERRIDE;
570 virtual bool handleCharEvent(const WebKeyboardEvent&) OVERRIDE;
572 InputMethodContext* inputMethodContext();
573 WebPlugin* focusedPluginIfInputMethodSupported(LocalFrame*);
575 WebViewClient* m_client; // Can be 0 (e.g. unittests, shared workers, etc.)
576 WebAutofillClient* m_autofillClient;
577 WebSpellCheckClient* m_spellCheckClient;
579 ChromeClientImpl m_chromeClientImpl;
580 ContextMenuClientImpl m_contextMenuClientImpl;
581 DragClientImpl m_dragClientImpl;
582 EditorClientImpl m_editorClientImpl;
583 InspectorClientImpl m_inspectorClientImpl;
584 BackForwardClientImpl m_backForwardClientImpl;
585 SpellCheckerClientImpl m_spellCheckerClientImpl;
586 StorageClientImpl m_storageClientImpl;
589 bool m_fixedLayoutSizeLock;
590 // If true, automatically resize the render view around its content.
591 bool m_shouldAutoResize;
592 // The lower bound on the size when auto-resizing.
593 IntSize m_minAutoSize;
594 // The upper bound on the size when auto-resizing.
595 IntSize m_maxAutoSize;
597 OwnPtrWillBePersistent<Page> m_page;
599 // An object that can be used to manipulate m_page->settings() without linking
600 // against WebCore. This is lazily allocated the first time GetWebSettings()
602 OwnPtr<WebSettingsImpl> m_webSettings;
604 // A copy of the web drop data object we received from the browser.
605 RefPtrWillBePersistent<DataObject> m_currentDragData;
607 // The point relative to the client area where the mouse was last pressed
608 // down. This is used by the drag client to determine what was under the
609 // mouse when the drag was initiated. We need to track this here in
610 // WebViewImpl since DragClient::startDrag does not pass the position the
611 // mouse was at when the drag was initiated, only the current point, which
612 // can be misleading as it is usually not over the element the user actually
613 // dragged by the time a drag is initiated.
614 WebPoint m_lastMouseDownPoint;
616 // Keeps track of the current zoom level. 0 means no zoom, positive numbers
617 // mean zoom in, negative numbers mean zoom out.
620 double m_minimumZoomLevel;
622 double m_maximumZoomLevel;
624 PageScaleConstraintsSet m_pageScaleConstraintsSet;
626 // The scale moved to by the latest double tap zoom, if any.
627 float m_doubleTapZoomPageScaleFactor;
628 // Have we sent a double-tap zoom and not yet heard back the scale?
629 bool m_doubleTapZoomPending;
631 // Used for testing purposes.
632 bool m_enableFakePageScaleAnimationForTesting;
633 IntPoint m_fakePageScaleAnimationTargetPosition;
634 float m_fakePageScaleAnimationPageScaleFactor;
635 bool m_fakePageScaleAnimationUseAnchor;
637 bool m_contextMenuAllowed;
639 bool m_doingDragAndDrop;
641 bool m_ignoreInputEvents;
643 float m_compositorDeviceScaleFactorOverride;
644 WebSize m_rootLayerOffset;
645 float m_rootLayerScale;
647 // Webkit expects keyPress events to be suppressed if the associated keyDown
648 // event was handled. Safari implements this behavior by peeking out the
649 // associated WM_CHAR event if the keydown was handled. We emulate
650 // this behavior by setting this flag if the keyDown was handled.
651 bool m_suppressNextKeypressEvent;
653 // Represents whether or not this object should process incoming IME events.
654 bool m_imeAcceptEvents;
656 // The available drag operations (copy, move link...) allowed by the source.
657 WebDragOperation m_operationsAllowed;
659 // The current drag operation as negotiated by the source and destination.
660 // When not equal to DragOperationNone, the drag data can be dropped onto the
661 // current drop target in this WebView (the drop target can accept the drop).
662 WebDragOperation m_dragOperation;
664 // The popup associated with a select element.
665 RefPtr<PopupContainer> m_selectPopup;
667 // The popup associated with an input element.
668 RefPtr<WebPagePopupImpl> m_pagePopup;
670 OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent;
671 OwnPtr<PageOverlayList> m_pageOverlays;
673 // Whether the webview is rendering transparently.
674 bool m_isTransparent;
676 // Whether the user can press tab to focus links.
679 // If set, the (plugin) node which has mouse capture.
680 RefPtrWillBePersistent<Node> m_mouseCaptureNode;
681 RefPtr<UserGestureToken> m_mouseCaptureGestureToken;
683 IntRect m_rootLayerScrollDamage;
684 WebLayerTreeView* m_layerTreeView;
685 WebLayer* m_rootLayer;
686 GraphicsLayer* m_rootGraphicsLayer;
687 GraphicsLayer* m_rootTransformLayer;
688 OwnPtr<GraphicsLayerFactory> m_graphicsLayerFactory;
689 bool m_isAcceleratedCompositingActive;
690 bool m_layerTreeViewCommitsDeferred;
691 bool m_layerTreeViewClosed;
692 bool m_matchesHeuristicsForGpuRasterization;
693 // If true, the graphics context is being restored.
694 bool m_recreatingGraphicsContext;
695 static const WebInputEvent* m_currentInputEvent;
697 MediaKeysClientImpl m_mediaKeysClientImpl;
698 OwnPtr<WebActiveGestureAnimation> m_gestureAnimation;
699 WebPoint m_positionOnFlingStart;
700 WebPoint m_globalPositionOnFlingStart;
702 bool m_flingSourceDevice;
703 Vector<OwnPtr<LinkHighlight> > m_linkHighlights;
704 OwnPtr<FullscreenController> m_fullscreenController;
706 bool m_showFPSCounter;
707 bool m_showPaintRects;
708 bool m_showDebugBorders;
709 bool m_continuousPaintingEnabled;
710 bool m_showScrollBottleneckRects;
711 WebColor m_baseBackgroundColor;
712 WebColor m_backgroundColorOverride;
713 float m_zoomFactorOverride;
715 bool m_userGestureObserved;
718 // We have no ways to check if the specified WebView is an instance of
719 // WebViewImpl because WebViewImpl is the only implementation of WebView.
720 DEFINE_TYPE_CASTS(WebViewImpl, WebView, webView, true, true);