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"
66 class RenderLayerCompositor;
67 class UserGestureToken;
71 class GeolocationClientProxy;
74 class WebActiveGestureAnimation;
75 class WebDevToolsAgentPrivate;
76 class WebLocalFrameImpl;
78 class WebPagePopupImpl;
80 class WebSettingsImpl;
81 class FullscreenController;
83 class WebViewImpl FINAL : public WebView
84 , public RefCounted<WebViewImpl>
85 , public WebGestureCurveTarget
86 , public WebCore::PagePopupDriver
87 , public PageWidgetEventHandler {
89 static WebViewImpl* create(WebViewClient*);
92 virtual void close() OVERRIDE;
93 virtual WebSize size() OVERRIDE;
94 virtual void willStartLiveResize() OVERRIDE;
95 virtual void resize(const WebSize&) OVERRIDE;
96 virtual void resizePinchViewport(const WebSize&) OVERRIDE;
97 virtual void willEndLiveResize() OVERRIDE;
98 virtual void willEnterFullScreen() OVERRIDE;
99 virtual void didEnterFullScreen() OVERRIDE;
100 virtual void willExitFullScreen() OVERRIDE;
101 virtual void didExitFullScreen() OVERRIDE;
102 virtual void animate(double) OVERRIDE;
103 virtual void layout() OVERRIDE;
104 virtual void enterForceCompositingMode(bool enable) OVERRIDE;
105 virtual void paint(WebCanvas*, const WebRect&, PaintOptions = ReadbackFromCompositorIfAvailable) OVERRIDE;
107 virtual void paintCompositedDeprecated(WebCanvas*, const WebRect&) OVERRIDE;
109 virtual void compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback*) OVERRIDE;
110 virtual bool isTrackingRepaints() const OVERRIDE;
111 virtual void themeChanged() OVERRIDE;
112 virtual bool handleInputEvent(const WebInputEvent&) OVERRIDE;
113 virtual void setCursorVisibilityState(bool isVisible) OVERRIDE;
114 virtual bool hasTouchEventHandlersAt(const WebPoint&) OVERRIDE;
115 virtual void applyScrollAndScale(const WebSize&, float) OVERRIDE;
116 virtual void mouseCaptureLost() OVERRIDE;
117 virtual void setFocus(bool enable) OVERRIDE;
118 virtual bool setComposition(
119 const WebString& text,
120 const WebVector<WebCompositionUnderline>& underlines,
122 int selectionEnd) OVERRIDE;
123 virtual bool confirmComposition() OVERRIDE;
124 virtual bool confirmComposition(ConfirmCompositionBehavior selectionBehavior) OVERRIDE;
125 virtual bool confirmComposition(const WebString& text) OVERRIDE;
126 virtual bool compositionRange(size_t* location, size_t* length) OVERRIDE;
127 virtual WebTextInputInfo textInputInfo() OVERRIDE;
128 virtual WebColor backgroundColor() const OVERRIDE;
129 virtual bool selectionBounds(WebRect& anchor, WebRect& focus) const OVERRIDE;
130 virtual void didShowCandidateWindow() OVERRIDE;
131 virtual void didUpdateCandidateWindow() OVERRIDE;
132 virtual void didHideCandidateWindow() OVERRIDE;
133 virtual bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const OVERRIDE;
134 virtual bool isSelectionAnchorFirst() const OVERRIDE;
135 virtual bool caretOrSelectionRange(size_t* location, size_t* length) OVERRIDE;
136 virtual void setTextDirection(WebTextDirection) OVERRIDE;
137 virtual bool isAcceleratedCompositingActive() const OVERRIDE;
138 virtual void willCloseLayerTreeView() OVERRIDE;
139 virtual void didAcquirePointerLock() OVERRIDE;
140 virtual void didNotAcquirePointerLock() OVERRIDE;
141 virtual void didLosePointerLock() OVERRIDE;
142 virtual void didChangeWindowResizerRect() OVERRIDE;
145 virtual void setMainFrame(WebFrame*) OVERRIDE;
146 virtual void setAutofillClient(WebAutofillClient*) OVERRIDE;
147 virtual void setDevToolsAgentClient(WebDevToolsAgentClient*) OVERRIDE;
148 virtual void setPrerendererClient(WebPrerendererClient*) OVERRIDE;
149 virtual void setSpellCheckClient(WebSpellCheckClient*) OVERRIDE;
150 virtual void setPasswordGeneratorClient(WebPasswordGeneratorClient*) OVERRIDE;
151 virtual WebSettings* settings() OVERRIDE;
152 virtual WebString pageEncoding() const OVERRIDE;
153 virtual void setPageEncoding(const WebString&) OVERRIDE;
154 virtual bool isTransparent() const OVERRIDE;
155 virtual void setIsTransparent(bool value) OVERRIDE;
156 virtual void setBaseBackgroundColor(WebColor) OVERRIDE;
157 virtual bool tabsToLinks() const OVERRIDE;
158 virtual void setTabsToLinks(bool value) OVERRIDE;
159 virtual bool tabKeyCyclesThroughElements() const OVERRIDE;
160 virtual void setTabKeyCyclesThroughElements(bool value) OVERRIDE;
161 virtual bool isActive() const OVERRIDE;
162 virtual void setIsActive(bool value) OVERRIDE;
163 virtual void setDomainRelaxationForbidden(bool, const WebString& scheme) OVERRIDE;
164 virtual void setWindowFeatures(const WebWindowFeatures&) OVERRIDE;
165 virtual void setOpenedByDOM() OVERRIDE;
166 virtual WebFrame* mainFrame() OVERRIDE;
167 virtual WebFrame* findFrameByName(
168 const WebString& name, WebFrame* relativeToFrame) OVERRIDE;
169 virtual WebFrame* focusedFrame() OVERRIDE;
170 virtual void setFocusedFrame(WebFrame*) OVERRIDE;
171 virtual void setInitialFocus(bool reverse) OVERRIDE;
172 virtual void clearFocusedElement() OVERRIDE;
173 virtual void scrollFocusedNodeIntoRect(const WebRect&) OVERRIDE;
174 virtual void zoomToFindInPageRect(const WebRect&) OVERRIDE;
175 virtual void advanceFocus(bool reverse) OVERRIDE;
176 virtual double zoomLevel() OVERRIDE;
177 virtual double setZoomLevel(double) OVERRIDE;
178 virtual void zoomLimitsChanged(double minimumZoomLevel, double maximumZoomLevel) OVERRIDE;
179 virtual float textZoomFactor() OVERRIDE;
180 virtual float setTextZoomFactor(float) OVERRIDE;
181 virtual void setInitialPageScaleOverride(float) OVERRIDE;
182 virtual bool zoomToMultipleTargetsRect(const WebRect&) OVERRIDE;
183 virtual float pageScaleFactor() const OVERRIDE;
184 virtual void setPageScaleFactorLimits(float minPageScale, float maxPageScale) OVERRIDE;
185 virtual void setMainFrameScrollOffset(const WebPoint&) OVERRIDE;
186 virtual void setPageScaleFactor(float) OVERRIDE;
187 virtual void setPinchViewportOffset(const WebFloatPoint&) OVERRIDE;
188 virtual WebFloatPoint pinchViewportOffset() const OVERRIDE;
189 virtual float minimumPageScaleFactor() const OVERRIDE;
190 virtual float maximumPageScaleFactor() const OVERRIDE;
191 virtual void resetScrollAndScaleState() OVERRIDE;
192 virtual void setIgnoreViewportTagScaleLimits(bool) OVERRIDE;
193 virtual WebSize contentsPreferredMinimumSize() OVERRIDE;
195 virtual float deviceScaleFactor() const OVERRIDE;
196 virtual void setDeviceScaleFactor(float) OVERRIDE;
198 virtual void setFixedLayoutSize(const WebSize&) OVERRIDE;
200 virtual void enableAutoResizeMode(
201 const WebSize& minSize,
202 const WebSize& maxSize) OVERRIDE;
203 virtual void disableAutoResizeMode() OVERRIDE;
204 virtual void performMediaPlayerAction(
205 const WebMediaPlayerAction& action,
206 const WebPoint& location) OVERRIDE;
207 virtual void performPluginAction(
208 const WebPluginAction&,
209 const WebPoint&) OVERRIDE;
210 virtual WebHitTestResult hitTestResultAt(const WebPoint&) OVERRIDE;
211 virtual void copyImageAt(const WebPoint&) OVERRIDE;
212 virtual void saveImageAt(const WebPoint&) OVERRIDE;
213 virtual void dragSourceEndedAt(
214 const WebPoint& clientPoint,
215 const WebPoint& screenPoint,
216 WebDragOperation) OVERRIDE;
217 virtual void dragSourceSystemDragEnded() OVERRIDE;
218 virtual WebDragOperation dragTargetDragEnter(
220 const WebPoint& clientPoint,
221 const WebPoint& screenPoint,
222 WebDragOperationsMask operationsAllowed,
223 int keyModifiers) OVERRIDE;
224 virtual WebDragOperation dragTargetDragOver(
225 const WebPoint& clientPoint,
226 const WebPoint& screenPoint,
227 WebDragOperationsMask operationsAllowed,
228 int keyModifiers) OVERRIDE;
229 virtual void dragTargetDragLeave() OVERRIDE;
230 virtual void dragTargetDrop(
231 const WebPoint& clientPoint,
232 const WebPoint& screenPoint,
233 int keyModifiers) OVERRIDE;
234 virtual void spellingMarkers(WebVector<uint32_t>* markers) OVERRIDE;
235 virtual unsigned long createUniqueIdentifierForRequest() OVERRIDE;
236 virtual void inspectElementAt(const WebPoint&) OVERRIDE;
237 virtual WebString inspectorSettings() const OVERRIDE;
238 virtual void setInspectorSettings(const WebString&) OVERRIDE;
239 virtual bool inspectorSetting(const WebString& key, WebString* value) const OVERRIDE;
240 virtual void setInspectorSetting(const WebString& key, const WebString& value) OVERRIDE;
241 virtual void setCompositorDeviceScaleFactorOverride(float) OVERRIDE;
242 virtual void setRootLayerTransform(const WebSize& offset, float scale) OVERRIDE;
243 virtual WebDevToolsAgent* devToolsAgent() OVERRIDE;
244 virtual WebAXObject accessibilityObject() OVERRIDE;
245 virtual void setSelectionColors(unsigned activeBackgroundColor,
246 unsigned activeForegroundColor,
247 unsigned inactiveBackgroundColor,
248 unsigned inactiveForegroundColor) OVERRIDE;
249 virtual void performCustomContextMenuAction(unsigned action) OVERRIDE;
250 virtual void showContextMenu() OVERRIDE;
251 virtual WebString getSmartClipData(WebRect) OVERRIDE;
252 virtual void hidePopups() OVERRIDE;
253 virtual void addPageOverlay(WebPageOverlay*, int /* zOrder */) OVERRIDE;
254 virtual void removePageOverlay(WebPageOverlay*) OVERRIDE;
255 virtual void transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters&) OVERRIDE;
256 virtual bool endActiveFlingAnimation() OVERRIDE;
257 virtual void setShowPaintRects(bool) OVERRIDE;
258 void setShowDebugBorders(bool);
259 virtual void setShowFPSCounter(bool) OVERRIDE;
260 virtual void setContinuousPaintingEnabled(bool) OVERRIDE;
261 virtual void setShowScrollBottleneckRects(bool) OVERRIDE;
262 virtual void getSelectionRootBounds(WebRect& bounds) const OVERRIDE;
266 void suppressInvalidations(bool enable);
267 void invalidateRect(const WebCore::IntRect&);
269 void setIgnoreInputEvents(bool newValue);
270 void setBackgroundColorOverride(WebColor);
271 void setZoomFactorOverride(float);
272 WebDevToolsAgentPrivate* devToolsAgentPrivate() { return m_devToolsAgent.get(); }
274 WebCore::Color baseBackgroundColor() const { return m_baseBackgroundColor; }
276 PageOverlayList* pageOverlays() const { return m_pageOverlays.get(); }
278 void setOverlayLayer(WebCore::GraphicsLayer*);
280 const WebPoint& lastMouseDownPoint() const
282 return m_lastMouseDownPoint;
285 WebCore::Frame* focusedWebCoreFrame() const;
287 // Returns the currently focused Element or null if no element has focus.
288 WebCore::Element* focusedElement() const;
290 static WebViewImpl* fromPage(WebCore::Page*);
292 WebViewClient* client()
297 WebAutofillClient* autofillClient()
299 return m_autofillClient;
302 WebSpellCheckClient* spellCheckClient()
304 return m_spellCheckClient;
307 WebPasswordGeneratorClient* passwordGeneratorClient() const
309 return m_passwordGeneratorClient;
312 // Returns the page object associated with this view. This may be null when
313 // the page is shutting down, but will be valid at all other times.
314 WebCore::Page* page() const
319 // Returns the main frame associated with this view. This may be null when
320 // the page is shutting down, but will be valid at all other times.
321 WebLocalFrameImpl* mainFrameImpl();
323 // Event related methods:
324 void mouseContextMenu(const WebMouseEvent&);
325 void mouseDoubleClick(const WebMouseEvent&);
327 bool detectContentOnTouch(const WebPoint&);
328 bool startPageScaleAnimation(const WebCore::IntPoint& targetPosition, bool useAnchor, float newScale, double durationInSeconds);
330 void numberOfWheelEventHandlersChanged(unsigned);
331 void hasTouchEventHandlers(bool);
333 // WebGestureCurveTarget implementation for fling.
334 virtual bool scrollBy(const WebFloatSize& delta, const WebFloatSize& velocity) OVERRIDE;
336 // Handles context menu events orignated via the the keyboard. These
337 // include the VK_APPS virtual key and the Shift+F10 combine. Code is
338 // based on the Webkit function bool WebView::handleContextMenuEvent(WPARAM
339 // wParam, LPARAM lParam) in webkit\webkit\win\WebView.cpp. The only
340 // significant change in this function is the code to convert from a
341 // Keyboard event to the Right Mouse button down event.
342 bool sendContextMenuEvent(const WebKeyboardEvent&);
344 // Notifies the WebView that a load has been committed. isNewNavigation
345 // will be true if a new session history item should be created for that
346 // load. isNavigationWithinPage will be true if the navigation does
347 // not take the user away from the current page.
348 void didCommitLoad(bool isNewNavigation, bool isNavigationWithinPage);
350 // Indicates two things:
351 // 1) This view may have a new layout now.
352 // 2) Calling layout() is a no-op.
353 // After calling WebWidget::layout(), expect to get this notification
354 // unless the view did not need a layout.
355 void layoutUpdated(WebLocalFrameImpl*);
357 void willInsertBody(WebLocalFrameImpl*);
358 void didChangeContentsSize();
359 void deviceOrPageScaleFactorChanged();
361 // Returns true if popup menus should be rendered by the browser, false if
362 // they should be rendered by WebKit (which is the default).
363 static bool useExternalPopupMenus();
365 bool contextMenuAllowed() const
367 return m_contextMenuAllowed;
370 bool shouldAutoResize() const
372 return m_shouldAutoResize;
375 WebCore::IntSize minAutoSize() const
377 return m_minAutoSize;
380 WebCore::IntSize maxAutoSize() const
382 return m_maxAutoSize;
385 void updateMainFrameLayoutSize();
386 void updatePageDefinedViewportConstraints(const WebCore::ViewportDescription&);
388 // Start a system drag and drop operation.
390 WebCore::LocalFrame*,
391 const WebDragData& dragData,
392 WebDragOperationsMask mask,
393 const WebImage& dragImage,
394 const WebPoint& dragImageOffset);
396 // Tries to scroll the currently focused element and bubbles up through the
397 // DOM and frame hierarchies. Returns true if something was scrolled.
398 bool bubblingScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
400 // Notification that a popup was opened/closed.
401 void popupOpened(PopupContainer*);
402 void popupClosed(PopupContainer*);
403 // PagePopupDriver functions.
404 virtual WebCore::PagePopup* openPagePopup(WebCore::PagePopupClient*, const WebCore::IntRect& originBoundsInRootView) OVERRIDE;
405 virtual void closePagePopup(WebCore::PagePopup*) OVERRIDE;
407 // Returns the input event we're currently processing. This is used in some
408 // cases where the WebCore DOM event doesn't have the information we need.
409 static const WebInputEvent* currentInputEvent()
411 return m_currentInputEvent;
414 WebCore::GraphicsLayer* rootGraphicsLayer();
415 void setRootGraphicsLayer(WebCore::GraphicsLayer*);
416 void scheduleCompositingLayerSync();
417 void scrollRootLayer();
418 WebCore::GraphicsLayerFactory* graphicsLayerFactory() const;
419 WebCore::RenderLayerCompositor* compositor() const;
420 void registerForAnimations(WebLayer*);
421 void scheduleAnimation();
423 virtual void setVisibilityState(WebPageVisibilityState, bool) OVERRIDE;
425 PopupContainer* selectPopup() const { return m_selectPopup.get(); }
426 bool hasOpenedPopup() const { return m_selectPopup || m_pagePopup; }
428 // Returns true if the event leads to scrolling.
429 static bool mapKeyCodeForScroll(int keyCode,
430 WebCore::ScrollDirection* scrollDirection,
431 WebCore::ScrollGranularity* scrollGranularity);
433 // Called by a full frame plugin inside this view to inform it that its
434 // zoom level has been updated. The plugin should only call this function
435 // if the zoom change was triggered by the browser, it's only needed in case
436 // a plugin can update its own zoom, say because of its own UI.
437 void fullFramePluginZoomLevelChanged(double zoomLevel);
439 void computeScaleAndScrollForBlockRect(const WebPoint& hitPoint, const WebRect& blockRect, float padding, float defaultScaleWhenAlreadyLegible, float& scale, WebPoint& scroll);
440 WebCore::Node* bestTapNode(const WebCore::PlatformGestureEvent& tapEvent);
441 void enableTapHighlightAtPoint(const WebCore::PlatformGestureEvent& tapEvent);
442 void enableTapHighlights(Vector<WebCore::Node*>&);
443 void computeScaleAndScrollForFocusedNode(WebCore::Node* focusedNode, float& scale, WebCore::IntPoint& scroll, bool& needAnimation);
445 void animateDoubleTapZoom(const WebCore::IntPoint&);
447 void enableFakePageScaleAnimationForTesting(bool);
448 bool fakeDoubleTapAnimationPendingForTesting() const { return m_doubleTapZoomPending; }
449 WebCore::IntPoint fakePageScaleAnimationTargetPositionForTesting() const { return m_fakePageScaleAnimationTargetPosition; }
450 float fakePageScaleAnimationPageScaleForTesting() const { return m_fakePageScaleAnimationPageScaleFactor; }
451 bool fakePageScaleAnimationUseAnchorForTesting() const { return m_fakePageScaleAnimationUseAnchor; }
453 void enterFullScreenForElement(WebCore::Element*);
454 void exitFullScreenForElement(WebCore::Element*);
456 // Exposed for the purpose of overriding device metrics.
457 void sendResizeEventAndRepaint();
459 // Exposed for testing purposes.
460 bool hasHorizontalScrollbar();
461 bool hasVerticalScrollbar();
463 // Pointer Lock calls allow a page to capture all mouse events and
464 // disable the system cursor.
465 bool requestPointerLock();
466 void requestPointerUnlock();
467 bool isPointerLocked();
469 // Heuristic-based function for determining if we should disable workarounds
470 // for viewing websites that are not optimized for mobile devices.
471 bool shouldDisableDesktopWorkarounds();
473 // Exposed for tests.
474 unsigned numLinkHighlights() { return m_linkHighlights.size(); }
475 LinkHighlight* linkHighlight(int i) { return m_linkHighlights[i].get(); }
477 WebSettingsImpl* settingsImpl();
479 // Returns the bounding box of the block type node touched by the WebRect.
480 WebRect computeBlockBounds(const WebRect&, bool ignoreClipping);
482 WebCore::IntPoint clampOffsetAtScale(const WebCore::IntPoint& offset, float scale);
484 // Exposed for tests.
485 WebVector<WebCompositionUnderline> compositionUnderlines() const;
487 WebLayerTreeView* layerTreeView() const { return m_layerTreeView; }
489 bool pinchVirtualViewportEnabled() const;
491 bool matchesHeuristicsForGpuRasterizationForTesting() const { return m_matchesHeuristicsForGpuRasterization; }
494 // TODO(bokan): Remains for legacy pinch. Remove once it's gone. Made private to
495 // prevent external usage
496 virtual void setPageScaleFactor(float scaleFactor, const WebPoint& origin) OVERRIDE;
498 float legibleScale() const;
499 void refreshPageScaleFactorAfterLayout();
500 void resumeTreeViewCommits();
501 void setUserAgentPageScaleConstraints(WebCore::PageScaleConstraints newConstraints);
502 float clampPageScaleFactorToLimits(float) const;
503 WebCore::IntSize contentsSize() const;
505 void resetSavedScrollAndScaleState();
507 void updateMainFrameScrollPosition(const WebCore::IntPoint& scrollPosition, bool programmaticScroll);
509 friend class WebView; // So WebView::Create can call our constructor
510 friend class WTF::RefCounted<WebViewImpl>;
511 friend void setCurrentInputEventForTest(const WebInputEvent*);
518 explicit WebViewImpl(WebViewClient*);
519 virtual ~WebViewImpl();
521 WebTextInputType textInputType();
523 WebString inputModeOfFocusedElement();
525 // Returns true if the event was actually processed.
526 bool keyEventDefault(const WebKeyboardEvent&);
528 bool confirmComposition(const WebString& text, ConfirmCompositionBehavior);
530 // Returns true if the view was scrolled.
531 bool scrollViewWithKeyboard(int keyCode, int modifiers);
533 void hideSelectPopup();
535 // Converts |pos| from window coordinates to contents coordinates and gets
536 // the HitTestResult for it.
537 WebCore::HitTestResult hitTestResultForWindowPos(const WebCore::IntPoint&);
539 // Consolidate some common code between starting a drag over a target and
540 // updating a drag over a target. If we're starting a drag, |isEntering|
542 WebDragOperation dragTargetDragEnterOrOver(const WebPoint& clientPoint,
543 const WebPoint& screenPoint,
547 void configureAutoResizeMode();
549 void setIsAcceleratedCompositingActive(bool);
551 void doPixelReadbackToCanvas(WebCanvas*, const WebCore::IntRect&);
552 void reallocateRenderer();
553 void updateLayerTreeViewport();
554 void updateLayerTreeBackgroundColor();
555 void updateRootLayerTransform();
556 void updateLayerTreeDeviceScaleFactor();
558 // Helper function: Widens the width of |source| by the specified margins
559 // while keeping it smaller than page width.
560 WebRect widenRectWithinPageBounds(const WebRect& source, int targetMargin, int minimumMargin);
562 void pointerLockMouseEvent(const WebInputEvent&);
564 // PageWidgetEventHandler functions
565 virtual void handleMouseLeave(WebCore::LocalFrame&, const WebMouseEvent&) OVERRIDE;
566 virtual void handleMouseDown(WebCore::LocalFrame&, const WebMouseEvent&) OVERRIDE;
567 virtual void handleMouseUp(WebCore::LocalFrame&, const WebMouseEvent&) OVERRIDE;
568 virtual bool handleMouseWheel(WebCore::LocalFrame&, const WebMouseWheelEvent&) OVERRIDE;
569 virtual bool handleGestureEvent(const WebGestureEvent&) OVERRIDE;
570 virtual bool handleKeyEvent(const WebKeyboardEvent&) OVERRIDE;
571 virtual bool handleCharEvent(const WebKeyboardEvent&) OVERRIDE;
573 WebCore::InputMethodContext* inputMethodContext();
574 WebPlugin* focusedPluginIfInputMethodSupported(WebCore::LocalFrame*);
576 WebViewClient* m_client; // Can be 0 (e.g. unittests, shared workers, etc.)
577 WebAutofillClient* m_autofillClient;
578 WebSpellCheckClient* m_spellCheckClient;
579 WebPasswordGeneratorClient* m_passwordGeneratorClient;
581 ChromeClientImpl m_chromeClientImpl;
582 ContextMenuClientImpl m_contextMenuClientImpl;
583 DragClientImpl m_dragClientImpl;
584 EditorClientImpl m_editorClientImpl;
585 InspectorClientImpl m_inspectorClientImpl;
586 BackForwardClientImpl m_backForwardClientImpl;
587 SpellCheckerClientImpl m_spellCheckerClientImpl;
588 StorageClientImpl m_storageClientImpl;
591 bool m_fixedLayoutSizeLock;
592 // If true, automatically resize the render view around its content.
593 bool m_shouldAutoResize;
594 // The lower bound on the size when auto-resizing.
595 WebCore::IntSize m_minAutoSize;
596 // The upper bound on the size when auto-resizing.
597 WebCore::IntSize m_maxAutoSize;
599 OwnPtrWillBePersistent<WebCore::Page> m_page;
601 // An object that can be used to manipulate m_page->settings() without linking
602 // against WebCore. This is lazily allocated the first time GetWebSettings()
604 OwnPtr<WebSettingsImpl> m_webSettings;
606 // A copy of the web drop data object we received from the browser.
607 RefPtrWillBePersistent<WebCore::DataObject> m_currentDragData;
609 // The point relative to the client area where the mouse was last pressed
610 // down. This is used by the drag client to determine what was under the
611 // mouse when the drag was initiated. We need to track this here in
612 // WebViewImpl since DragClient::startDrag does not pass the position the
613 // mouse was at when the drag was initiated, only the current point, which
614 // can be misleading as it is usually not over the element the user actually
615 // dragged by the time a drag is initiated.
616 WebPoint m_lastMouseDownPoint;
618 // Keeps track of the current zoom level. 0 means no zoom, positive numbers
619 // mean zoom in, negative numbers mean zoom out.
622 double m_minimumZoomLevel;
624 double m_maximumZoomLevel;
626 PageScaleConstraintsSet m_pageScaleConstraintsSet;
628 // The scale moved to by the latest double tap zoom, if any.
629 float m_doubleTapZoomPageScaleFactor;
630 // Have we sent a double-tap zoom and not yet heard back the scale?
631 bool m_doubleTapZoomPending;
633 // Used for testing purposes.
634 bool m_enableFakePageScaleAnimationForTesting;
635 WebCore::IntPoint m_fakePageScaleAnimationTargetPosition;
636 float m_fakePageScaleAnimationPageScaleFactor;
637 bool m_fakePageScaleAnimationUseAnchor;
639 bool m_contextMenuAllowed;
641 bool m_doingDragAndDrop;
643 bool m_ignoreInputEvents;
645 float m_compositorDeviceScaleFactorOverride;
646 WebSize m_rootLayerOffset;
647 float m_rootLayerScale;
649 // Webkit expects keyPress events to be suppressed if the associated keyDown
650 // event was handled. Safari implements this behavior by peeking out the
651 // associated WM_CHAR event if the keydown was handled. We emulate
652 // this behavior by setting this flag if the keyDown was handled.
653 bool m_suppressNextKeypressEvent;
655 // Represents whether or not this object should process incoming IME events.
656 bool m_imeAcceptEvents;
658 // The available drag operations (copy, move link...) allowed by the source.
659 WebDragOperation m_operationsAllowed;
661 // The current drag operation as negotiated by the source and destination.
662 // When not equal to DragOperationNone, the drag data can be dropped onto the
663 // current drop target in this WebView (the drop target can accept the drop).
664 WebDragOperation m_dragOperation;
666 // The popup associated with a select element.
667 RefPtr<PopupContainer> m_selectPopup;
669 // The popup associated with an input element.
670 RefPtr<WebPagePopupImpl> m_pagePopup;
672 OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent;
673 OwnPtr<PageOverlayList> m_pageOverlays;
675 // Whether the webview is rendering transparently.
676 bool m_isTransparent;
678 // Whether the user can press tab to focus links.
681 // Inspector settings.
682 WebString m_inspectorSettings;
684 typedef HashMap<WTF::String, WTF::String> SettingsMap;
685 OwnPtr<SettingsMap> m_inspectorSettingsMap;
687 // If set, the (plugin) node which has mouse capture.
688 RefPtr<WebCore::Node> m_mouseCaptureNode;
689 RefPtr<WebCore::UserGestureToken> m_mouseCaptureGestureToken;
691 WebCore::IntRect m_rootLayerScrollDamage;
692 WebLayerTreeView* m_layerTreeView;
693 WebLayer* m_rootLayer;
694 WebCore::GraphicsLayer* m_rootGraphicsLayer;
695 WebCore::GraphicsLayer* m_rootTransformLayer;
696 OwnPtr<WebCore::GraphicsLayerFactory> m_graphicsLayerFactory;
697 bool m_isAcceleratedCompositingActive;
698 bool m_layerTreeViewCommitsDeferred;
699 bool m_matchesHeuristicsForGpuRasterization;
700 // If true, the graphics context is being restored.
701 bool m_recreatingGraphicsContext;
702 static const WebInputEvent* m_currentInputEvent;
704 OwnPtr<GeolocationClientProxy> m_geolocationClientProxy;
706 MediaKeysClientImpl m_mediaKeysClientImpl;
707 OwnPtr<WebActiveGestureAnimation> m_gestureAnimation;
708 WebPoint m_positionOnFlingStart;
709 WebPoint m_globalPositionOnFlingStart;
711 bool m_flingSourceDevice;
712 Vector<OwnPtr<LinkHighlight> > m_linkHighlights;
713 OwnPtr<FullscreenController> m_fullscreenController;
715 bool m_showFPSCounter;
716 bool m_showPaintRects;
717 bool m_showDebugBorders;
718 bool m_continuousPaintingEnabled;
719 bool m_showScrollBottleneckRects;
720 WebColor m_baseBackgroundColor;
721 WebColor m_backgroundColorOverride;
722 float m_zoomFactorOverride;
724 bool m_userGestureObserved;
727 // We have no ways to check if the specified WebView is an instance of
728 // WebViewImpl because WebViewImpl is the only implementation of WebView.
729 DEFINE_TYPE_CASTS(WebViewImpl, WebView, webView, true, true);