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 "ChromeClientImpl.h"
35 #include "ContextMenuClientImpl.h"
36 #include "DragClientImpl.h"
37 #include "EditorClientImpl.h"
38 #include "FloatSize.h"
39 #include "GraphicsContext3D.h"
40 #include "GraphicsLayer.h"
41 #include "InspectorClientImpl.h"
44 #include "NotificationPresenterImpl.h"
45 #include "PageOverlayList.h"
46 #include "PagePopupDriver.h"
47 #include "PageWidgetDelegate.h"
48 #include "UserMediaClientImpl.h"
49 #include "WebInputEvent.h"
50 #include "WebNavigationPolicy.h"
52 #include "WebViewBenchmarkSupportImpl.h"
53 #include <public/WebFloatQuad.h>
54 #include <public/WebGestureCurveTarget.h>
55 #include <public/WebLayer.h>
56 #include <public/WebLayerTreeViewClient.h>
57 #include <public/WebPoint.h>
58 #include <public/WebRect.h>
59 #include <public/WebSize.h>
60 #include <public/WebString.h>
61 #include <wtf/OwnPtr.h>
62 #include <wtf/RefCounted.h>
65 class ChromiumDataObject;
70 class GraphicsContext3D;
71 class GraphicsLayerFactory;
78 class PagePopupClient;
79 class PlatformKeyboardEvent;
81 class PopupMenuClient;
84 class TextFieldDecorator;
89 class AutocompletePopupMenuClient;
90 class AutofillPopupMenuClient;
91 class BatteryClientImpl;
92 class ContextFeaturesClientImpl;
93 class ContextMenuClientImpl;
94 class DeviceOrientationClientProxy;
95 class GeolocationClientProxy;
97 class NonCompositedContentHost;
98 class PrerendererClientImpl;
99 class SpeechInputClientImpl;
100 class SpeechRecognitionClientProxy;
101 class UserMediaClientImpl;
102 class ValidationMessageClientImpl;
103 class WebAccessibilityObject;
104 class WebActiveGestureAnimation;
105 class WebCompositorImpl;
106 class WebDevToolsAgentClient;
107 class WebDevToolsAgentPrivate;
109 class WebGestureEvent;
110 class WebHelperPluginImpl;
112 class WebKeyboardEvent;
113 class WebLayerTreeView;
115 class WebMouseWheelEvent;
116 class WebPagePopupImpl;
117 class WebPrerendererClient;
118 class WebSettingsImpl;
120 class WebViewBenchmarkSupport;
122 class WebViewImpl : public WebView
123 , public WebLayerTreeViewClient
124 , public RefCounted<WebViewImpl>
125 , public WebGestureCurveTarget
126 #if ENABLE(PAGE_POPUP)
127 , public WebCore::PagePopupDriver
129 , public PageWidgetEventHandler {
136 // WebWidget methods:
137 virtual void close();
138 virtual WebSize size();
139 virtual void willStartLiveResize();
140 virtual void resize(const WebSize&);
141 virtual void willEndLiveResize();
142 virtual void willEnterFullScreen();
143 virtual void didEnterFullScreen();
144 virtual void willExitFullScreen();
145 virtual void didExitFullScreen();
146 virtual void animate(double);
147 virtual void layout();
148 virtual void enterForceCompositingMode(bool enable) OVERRIDE;
149 virtual void paint(WebCanvas*, const WebRect&, PaintOptions = ReadbackFromCompositorIfAvailable);
150 virtual bool isTrackingRepaints() const OVERRIDE;
151 virtual void themeChanged();
152 virtual void setNeedsRedraw();
153 virtual bool handleInputEvent(const WebInputEvent&);
154 virtual bool hasTouchEventHandlersAt(const WebPoint&);
155 virtual WebInputHandler* createInputHandler() OVERRIDE;
156 virtual void applyScrollAndScale(const WebSize&, float);
157 virtual void mouseCaptureLost();
158 virtual void setFocus(bool enable);
159 virtual bool setComposition(
160 const WebString& text,
161 const WebVector<WebCompositionUnderline>& underlines,
164 virtual bool confirmComposition();
165 virtual bool confirmComposition(const WebString& text);
166 virtual bool compositionRange(size_t* location, size_t* length);
167 virtual WebTextInputInfo textInputInfo();
168 virtual WebTextInputType textInputType();
169 virtual bool setEditableSelectionOffsets(int start, int end);
170 virtual bool setCompositionFromExistingText(int compositionStart, int compositionEnd, const WebVector<WebCompositionUnderline>& underlines);
171 virtual void extendSelectionAndDelete(int before, int after);
172 virtual bool isSelectionEditable() const;
173 virtual WebColor backgroundColor() const;
174 virtual bool selectionBounds(WebRect& anchor, WebRect& focus) const;
175 virtual bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const;
176 virtual bool isSelectionAnchorFirst() const;
177 virtual bool caretOrSelectionRange(size_t* location, size_t* length);
178 virtual void setTextDirection(WebTextDirection direction);
179 virtual bool isAcceleratedCompositingActive() const;
180 virtual void willCloseLayerTreeView();
181 virtual void didAcquirePointerLock();
182 virtual void didNotAcquirePointerLock();
183 virtual void didLosePointerLock();
184 virtual void didChangeWindowResizerRect();
185 virtual void didExitCompositingMode();
188 virtual void initializeMainFrame(WebFrameClient*);
189 virtual void initializeHelperPluginFrame(WebFrameClient*);
190 virtual void setAutofillClient(WebAutofillClient*);
191 virtual void setDevToolsAgentClient(WebDevToolsAgentClient*);
192 virtual void setPermissionClient(WebPermissionClient*);
193 virtual void setPrerendererClient(WebPrerendererClient*) OVERRIDE;
194 virtual void setSpellCheckClient(WebSpellCheckClient*);
195 virtual void addTextFieldDecoratorClient(WebTextFieldDecoratorClient*) OVERRIDE;
196 virtual WebSettings* settings();
197 virtual WebString pageEncoding() const;
198 virtual void setPageEncoding(const WebString& encoding);
199 virtual bool isTransparent() const;
200 virtual void setIsTransparent(bool value);
201 virtual bool tabsToLinks() const;
202 virtual void setTabsToLinks(bool value);
203 virtual bool tabKeyCyclesThroughElements() const;
204 virtual void setTabKeyCyclesThroughElements(bool value);
205 virtual bool isActive() const;
206 virtual void setIsActive(bool value);
207 virtual void setDomainRelaxationForbidden(bool, const WebString& scheme);
208 virtual bool dispatchBeforeUnloadEvent();
209 virtual void dispatchUnloadEvent();
210 virtual WebFrame* mainFrame();
211 virtual WebFrame* findFrameByName(
212 const WebString& name, WebFrame* relativeToFrame);
213 virtual WebFrame* focusedFrame();
214 virtual void setFocusedFrame(WebFrame* frame);
215 virtual void setInitialFocus(bool reverse);
216 virtual void clearFocusedNode();
217 virtual void scrollFocusedNodeIntoView();
218 virtual void scrollFocusedNodeIntoRect(const WebRect&);
219 virtual void zoomToFindInPageRect(const WebRect&);
220 virtual void advanceFocus(bool reverse);
221 virtual double zoomLevel();
222 virtual double setZoomLevel(bool textOnly, double zoomLevel);
223 virtual void zoomLimitsChanged(double minimumZoomLevel,
224 double maximumZoomLevel);
225 virtual void setInitialPageScaleOverride(float);
226 virtual float pageScaleFactor() const;
227 virtual bool isPageScaleFactorSet() const;
228 virtual void setPageScaleFactorPreservingScrollOffset(float);
229 virtual void setPageScaleFactor(float scaleFactor, const WebPoint& origin);
230 virtual void setPageScaleFactorLimits(float minPageScale, float maxPageScale);
231 virtual float minimumPageScaleFactor() const;
232 virtual float maximumPageScaleFactor() const;
233 virtual void saveScrollAndScaleState();
234 virtual void restoreScrollAndScaleState();
235 virtual void resetScrollAndScaleState();
236 virtual void setIgnoreViewportTagMaximumScale(bool);
238 virtual float deviceScaleFactor() const;
239 virtual void setDeviceScaleFactor(float);
240 virtual bool isFixedLayoutModeEnabled() const;
241 virtual void enableFixedLayoutMode(bool enable);
242 virtual WebSize fixedLayoutSize() const;
243 virtual void setFixedLayoutSize(const WebSize&);
244 virtual void enableAutoResizeMode(
245 const WebSize& minSize,
246 const WebSize& maxSize);
247 virtual void disableAutoResizeMode();
248 virtual void performMediaPlayerAction(
249 const WebMediaPlayerAction& action,
250 const WebPoint& location);
251 virtual void performPluginAction(
252 const WebPluginAction&,
254 virtual WebHitTestResult hitTestResultAt(const WebPoint&);
255 virtual void copyImageAt(const WebPoint& point);
256 virtual void dragSourceEndedAt(
257 const WebPoint& clientPoint,
258 const WebPoint& screenPoint,
259 WebDragOperation operation);
260 virtual void dragSourceMovedTo(
261 const WebPoint& clientPoint,
262 const WebPoint& screenPoint,
263 WebDragOperation operation);
264 virtual void dragSourceSystemDragEnded();
265 virtual WebDragOperation dragTargetDragEnter(
267 const WebPoint& clientPoint,
268 const WebPoint& screenPoint,
269 WebDragOperationsMask operationsAllowed,
271 virtual WebDragOperation dragTargetDragOver(
272 const WebPoint& clientPoint,
273 const WebPoint& screenPoint,
274 WebDragOperationsMask operationsAllowed,
276 virtual void dragTargetDragLeave();
277 virtual void dragTargetDrop(
278 const WebPoint& clientPoint,
279 const WebPoint& screenPoint,
281 virtual unsigned long createUniqueIdentifierForRequest();
282 virtual void inspectElementAt(const WebPoint& point);
283 virtual WebString inspectorSettings() const;
284 virtual void setInspectorSettings(const WebString& settings);
285 virtual bool inspectorSetting(const WebString& key, WebString* value) const;
286 virtual void setInspectorSetting(const WebString& key,
287 const WebString& value);
288 virtual WebDevToolsAgent* devToolsAgent();
289 virtual WebAccessibilityObject accessibilityObject();
290 virtual void applyAutofillSuggestions(
292 const WebVector<WebString>& names,
293 const WebVector<WebString>& labels,
294 const WebVector<WebString>& icons,
295 const WebVector<int>& itemIDs,
297 virtual void hidePopups();
298 virtual void selectAutofillSuggestionAtIndex(unsigned listIndex);
299 virtual void setScrollbarColors(unsigned inactiveColor,
300 unsigned activeColor,
301 unsigned trackColor);
302 virtual void setSelectionColors(unsigned activeBackgroundColor,
303 unsigned activeForegroundColor,
304 unsigned inactiveBackgroundColor,
305 unsigned inactiveForegroundColor);
306 virtual void performCustomContextMenuAction(unsigned action);
307 virtual void showContextMenu();
308 virtual void addPageOverlay(WebPageOverlay*, int /* zOrder */);
309 virtual void removePageOverlay(WebPageOverlay*);
310 #if ENABLE(BATTERY_STATUS)
311 virtual void updateBatteryStatus(const WebBatteryStatus&);
313 virtual void transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters&);
314 virtual WebViewBenchmarkSupport* benchmarkSupport();
315 virtual void setShowPaintRects(bool);
316 virtual void setShowDebugBorders(bool);
317 virtual void setShowFPSCounter(bool);
318 virtual void setContinuousPaintingEnabled(bool);
320 // WebLayerTreeViewClient
321 virtual void updateAnimations(double monotonicFrameBeginTime);
322 virtual void didRecreateOutputSurface(bool success);
326 void suppressInvalidations(bool enable);
327 void invalidateRect(const WebCore::IntRect&);
329 void setIgnoreInputEvents(bool newValue);
330 WebDevToolsAgentPrivate* devToolsAgentPrivate() { return m_devToolsAgent.get(); }
332 PageOverlayList* pageOverlays() const { return m_pageOverlays.get(); }
334 void setOverlayLayer(WebCore::GraphicsLayer*);
336 const WebPoint& lastMouseDownPoint() const
338 return m_lastMouseDownPoint;
341 WebCore::Frame* focusedWebCoreFrame() const;
343 // Returns the currently focused Node or null if no node has focus.
344 WebCore::Node* focusedWebCoreNode();
346 static WebViewImpl* fromPage(WebCore::Page*);
348 // A pageGroup identifies a namespace of pages. Page groups are used on PLATFORM(MAC)
349 // for some programs that use HTML views to display things that don't seem like
350 // web pages to the user (so shouldn't have visited link coloring). We only use
352 static WebCore::PageGroup* defaultPageGroup();
354 WebViewClient* client()
359 WebAutofillClient* autofillClient()
361 return m_autofillClient;
364 WebPermissionClient* permissionClient()
366 return m_permissionClient;
369 WebSpellCheckClient* spellCheckClient()
371 return m_spellCheckClient;
374 const Vector<OwnPtr<WebCore::TextFieldDecorator> >& textFieldDecorators() const { return m_textFieldDecorators; }
376 // Returns the page object associated with this view. This may be null when
377 // the page is shutting down, but will be valid at all other times.
378 WebCore::Page* page() const
383 WebCore::RenderTheme* theme() const;
385 // Returns the main frame associated with this view. This may be null when
386 // the page is shutting down, but will be valid at all other times.
387 WebFrameImpl* mainFrameImpl();
389 // History related methods:
390 void observeNewNavigation();
392 // Event related methods:
393 void mouseContextMenu(const WebMouseEvent&);
394 void mouseDoubleClick(const WebMouseEvent&);
396 bool detectContentOnTouch(const WebPoint&);
397 bool startPageScaleAnimation(const WebCore::IntPoint& targetPosition, bool useAnchor, float newScale, double durationInSeconds);
399 void numberOfWheelEventHandlersChanged(unsigned);
400 void hasTouchEventHandlers(bool);
402 // WebGestureCurveTarget implementation for fling.
403 virtual void scrollBy(const WebPoint&);
405 // Handles context menu events orignated via the the keyboard. These
406 // include the VK_APPS virtual key and the Shift+F10 combine. Code is
407 // based on the Webkit function bool WebView::handleContextMenuEvent(WPARAM
408 // wParam, LPARAM lParam) in webkit\webkit\win\WebView.cpp. The only
409 // significant change in this function is the code to convert from a
410 // Keyboard event to the Right Mouse button down event.
411 bool sendContextMenuEvent(const WebKeyboardEvent&);
413 // Notifies the WebView that a load has been committed. isNewNavigation
414 // will be true if a new session history item should be created for that
415 // load. isNavigationWithinPage will be true if the navigation does
416 // not take the user away from the current page.
417 void didCommitLoad(bool* isNewNavigation, bool isNavigationWithinPage);
419 // Indicates two things:
420 // 1) This view may have a new layout now.
421 // 2) Calling layout() is a no-op.
422 // After calling WebWidget::layout(), expect to get this notification
423 // unless the view did not need a layout.
424 void layoutUpdated(WebFrameImpl*);
426 void didChangeContentsSize();
428 // Returns true if popup menus should be rendered by the browser, false if
429 // they should be rendered by WebKit (which is the default).
430 static bool useExternalPopupMenus();
432 bool contextMenuAllowed() const
434 return m_contextMenuAllowed;
437 bool shouldAutoResize() const
439 return m_shouldAutoResize;
442 WebCore::IntSize minAutoSize() const
444 return m_minAutoSize;
447 WebCore::IntSize maxAutoSize() const
449 return m_maxAutoSize;
452 WebCore::IntSize dipSize() const;
453 WebCore::IntSize scaledSize(float) const;
455 // Set the disposition for how this webview is to be initially shown.
456 void setInitialNavigationPolicy(WebNavigationPolicy policy)
458 m_initialNavigationPolicy = policy;
460 WebNavigationPolicy initialNavigationPolicy() const
462 return m_initialNavigationPolicy;
465 // Sets the emulated text zoom factor
466 // (may not be 1 in the device metrics emulation mode).
467 void setEmulatedTextZoomFactor(float);
469 // Returns the emulated text zoom factor
470 // (which may not be 1 in the device metrics emulation mode).
471 float emulatedTextZoomFactor() const
473 return m_emulatedTextZoomFactor;
476 void setInitialPageScaleFactor(float initialPageScaleFactor) { m_initialPageScaleFactor = initialPageScaleFactor; }
477 bool ignoreViewportTagMaximumScale() const { return m_ignoreViewportTagMaximumScale; }
479 // Determines whether a page should e.g. be opened in a background tab.
480 // Returns false if it has no opinion, in which case it doesn't set *policy.
481 static bool navigationPolicyFromMouseEvent(
482 unsigned short button,
487 WebNavigationPolicy*);
489 // Start a system drag and drop operation.
492 const WebDragData& dragData,
493 WebDragOperationsMask mask,
494 const WebImage& dragImage,
495 const WebPoint& dragImageOffset);
497 void autofillPopupDidHide()
499 m_autofillPopupShowing = false;
502 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
503 // Returns the provider of desktop notifications.
504 NotificationPresenterImpl* notificationPresenterImpl();
507 // Tries to scroll a frame or any parent of a frame. Returns true if the view
509 bool propagateScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
511 // Notification that a popup was opened/closed.
512 void popupOpened(WebCore::PopupContainer* popupContainer);
513 void popupClosed(WebCore::PopupContainer* popupContainer);
514 #if ENABLE(PAGE_POPUP)
515 // PagePopupDriver functions.
516 virtual WebCore::PagePopup* openPagePopup(WebCore::PagePopupClient*, const WebCore::IntRect& originBoundsInRootView) OVERRIDE;
517 virtual void closePagePopup(WebCore::PagePopup*) OVERRIDE;
520 void hideAutofillPopup();
522 WebHelperPluginImpl* createHelperPlugin(const String& pluginType);
524 // Returns the input event we're currently processing. This is used in some
525 // cases where the WebCore DOM event doesn't have the information we need.
526 static const WebInputEvent* currentInputEvent()
528 return m_currentInputEvent;
531 WebCore::GraphicsLayer* rootGraphicsLayer();
532 #if USE(ACCELERATED_COMPOSITING)
533 bool allowsAcceleratedCompositing();
534 void setRootGraphicsLayer(WebCore::GraphicsLayer*);
535 void scheduleCompositingLayerSync();
536 void scrollRootLayerRect(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& clipRect);
537 void paintRootLayer(WebCore::GraphicsContext&, const WebCore::IntRect& contentRect);
538 NonCompositedContentHost* nonCompositedContentHost();
539 void setBackgroundColor(const WebCore::Color&);
540 WebCore::GraphicsLayerFactory* graphicsLayerFactory() const;
541 void registerForAnimations(WebLayer*);
543 #if ENABLE(REQUEST_ANIMATION_FRAME)
544 void scheduleAnimation();
547 virtual WebGraphicsContext3D* sharedGraphicsContext3D();
549 virtual void setVisibilityState(WebPageVisibilityState, bool);
551 WebCore::PopupContainer* selectPopup() const { return m_selectPopup.get(); }
552 #if ENABLE(PAGE_POPUP)
553 bool hasOpenedPopup() const { return m_selectPopup || m_pagePopup; }
555 bool hasOpenedPopup() const { return m_selectPopup; }
558 // Returns true if the event leads to scrolling.
559 static bool mapKeyCodeForScroll(int keyCode,
560 WebCore::ScrollDirection* scrollDirection,
561 WebCore::ScrollGranularity* scrollGranularity);
563 // Called by a full frame plugin inside this view to inform it that its
564 // zoom level has been updated. The plugin should only call this function
565 // if the zoom change was triggered by the browser, it's only needed in case
566 // a plugin can update its own zoom, say because of its own UI.
567 void fullFramePluginZoomLevelChanged(double zoomLevel);
569 #if ENABLE(GESTURE_EVENTS)
570 void computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZoomType, float& scale, WebPoint& scroll, bool& isAnchor);
571 WebCore::Node* bestTapNode(const WebCore::PlatformGestureEvent& tapEvent);
572 void enableTapHighlight(const WebCore::PlatformGestureEvent& tapEvent);
573 void computeScaleAndScrollForFocusedNode(WebCore::Node* focusedNode, float& scale, WebCore::IntPoint& scroll, bool& needAnimation);
575 void animateZoomAroundPoint(const WebCore::IntPoint&, AutoZoomType);
577 void enableFakeDoubleTapAnimationForTesting(bool);
578 bool fakeDoubleTapAnimationPendingForTesting() const { return m_doubleTapZoomPending; }
579 WebCore::IntPoint fakeDoubleTapTargetPositionForTesting() const { return m_fakeDoubleTapTargetPosition; }
580 float fakeDoubleTapPageScaleFactorForTesting() const { return m_fakeDoubleTapPageScaleFactor; }
581 bool fakeDoubleTapUseAnchorForTesting() const { return m_fakeDoubleTapUseAnchor; }
583 void enterFullScreenForElement(WebCore::Element*);
584 void exitFullScreenForElement(WebCore::Element*);
586 // Exposed for the purpose of overriding device metrics.
587 void sendResizeEventAndRepaint();
589 // Exposed for testing purposes.
590 bool hasHorizontalScrollbar();
591 bool hasVerticalScrollbar();
593 // Pointer Lock calls allow a page to capture all mouse events and
594 // disable the system cursor.
595 #if ENABLE(POINTER_LOCK)
596 virtual bool requestPointerLock();
597 virtual void requestPointerUnlock();
598 virtual bool isPointerLocked();
601 // Heuristic-based function for determining if we should disable workarounds
602 // for viewing websites that are not optimized for mobile devices.
603 bool shouldDisableDesktopWorkarounds();
605 #if ENABLE(GESTURE_EVENTS)
606 // Exposed for tests.
607 LinkHighlight* linkHighlight() { return m_linkHighlight.get(); }
610 WebSettingsImpl* settingsImpl();
613 void computePageScaleFactorLimits();
614 float clampPageScaleFactorToLimits(float scale);
615 WebCore::IntPoint clampOffsetAtScale(const WebCore::IntPoint& offset, float scale) const;
616 WebCore::IntSize contentsSize() const;
618 void resetSavedScrollAndScaleState();
620 friend class WebView; // So WebView::Create can call our constructor
621 friend class WTF::RefCounted<WebViewImpl>;
622 friend void setCurrentInputEventForTest(const WebInputEvent*);
629 WebViewImpl(WebViewClient*);
630 virtual ~WebViewImpl();
632 // Returns true if the event was actually processed.
633 bool keyEventDefault(const WebKeyboardEvent&);
635 // Returns true if the autocomple has consumed the event.
636 bool autocompleteHandleKeyEvent(const WebKeyboardEvent&);
638 // Repaints the Autofill popup. Should be called when the suggestions
639 // have changed. Note that this should only be called when the Autofill
641 void refreshAutofillPopup();
643 // Returns true if the view was scrolled.
644 bool scrollViewWithKeyboard(int keyCode, int modifiers);
646 void hideSelectPopup();
648 // Converts |pos| from window coordinates to contents coordinates and gets
649 // the HitTestResult for it.
650 WebCore::HitTestResult hitTestResultForWindowPos(const WebCore::IntPoint&);
652 // Consolidate some common code between starting a drag over a target and
653 // updating a drag over a target. If we're starting a drag, |isEntering|
655 WebDragOperation dragTargetDragEnterOrOver(const WebPoint& clientPoint,
656 const WebPoint& screenPoint,
660 void configureAutoResizeMode();
662 #if USE(ACCELERATED_COMPOSITING)
663 void setIsAcceleratedCompositingActive(bool);
665 void doPixelReadbackToCanvas(WebCanvas*, const WebCore::IntRect&);
666 void reallocateRenderer();
667 void updateLayerTreeViewport();
670 #if ENABLE(GESTURE_EVENTS)
671 // Returns the bounding box of the block type node touched by the WebRect.
672 WebRect computeBlockBounds(const WebRect&, AutoZoomType);
674 // Helper function: Widens the width of |source| by the specified margins
675 // while keeping it smaller than page width.
676 WebRect widenRectWithinPageBounds(const WebRect& source, int targetMargin, int minimumMargin);
679 #if ENABLE(POINTER_LOCK)
680 void pointerLockMouseEvent(const WebInputEvent&);
683 // PageWidgetEventHandler functions
684 virtual void handleMouseLeave(WebCore::Frame&, const WebMouseEvent&) OVERRIDE;
685 virtual void handleMouseDown(WebCore::Frame&, const WebMouseEvent&) OVERRIDE;
686 virtual void handleMouseUp(WebCore::Frame&, const WebMouseEvent&) OVERRIDE;
687 virtual bool handleMouseWheel(WebCore::Frame&, const WebMouseWheelEvent&) OVERRIDE;
688 virtual bool handleGestureEvent(const WebGestureEvent&) OVERRIDE;
689 virtual bool handleKeyEvent(const WebKeyboardEvent&) OVERRIDE;
690 virtual bool handleCharEvent(const WebKeyboardEvent&) OVERRIDE;
692 WebViewClient* m_client;
693 WebAutofillClient* m_autofillClient;
694 WebPermissionClient* m_permissionClient;
695 WebSpellCheckClient* m_spellCheckClient;
696 Vector<OwnPtr<WebCore::TextFieldDecorator> > m_textFieldDecorators;
698 ChromeClientImpl m_chromeClientImpl;
699 ContextMenuClientImpl m_contextMenuClientImpl;
700 DragClientImpl m_dragClientImpl;
701 EditorClientImpl m_editorClientImpl;
702 InspectorClientImpl m_inspectorClientImpl;
705 // If true, automatically resize the render view around its content.
706 bool m_shouldAutoResize;
707 // The lower bound on the size when auto-resizing.
708 WebCore::IntSize m_minAutoSize;
709 // The upper bound on the size when auto-resizing.
710 WebCore::IntSize m_maxAutoSize;
712 OwnPtr<WebCore::Page> m_page;
714 // This flag is set when a new navigation is detected. It is used to satisfy
715 // the corresponding argument to WebFrameClient::didCommitProvisionalLoad.
716 bool m_observedNewNavigation;
718 // Used to assert that the new navigation we observed is the same navigation
719 // when we make use of m_observedNewNavigation.
720 const WebCore::DocumentLoader* m_newNavigationLoader;
723 // An object that can be used to manipulate m_page->settings() without linking
724 // against WebCore. This is lazily allocated the first time GetWebSettings()
726 OwnPtr<WebSettingsImpl> m_webSettings;
728 // A copy of the web drop data object we received from the browser.
729 RefPtr<WebCore::ChromiumDataObject> m_currentDragData;
731 // The point relative to the client area where the mouse was last pressed
732 // down. This is used by the drag client to determine what was under the
733 // mouse when the drag was initiated. We need to track this here in
734 // WebViewImpl since DragClient::startDrag does not pass the position the
735 // mouse was at when the drag was initiated, only the current point, which
736 // can be misleading as it is usually not over the element the user actually
737 // dragged by the time a drag is initiated.
738 WebPoint m_lastMouseDownPoint;
740 // Keeps track of the current zoom level. 0 means no zoom, positive numbers
741 // mean zoom in, negative numbers mean zoom out.
744 double m_minimumZoomLevel;
746 double m_maximumZoomLevel;
748 // State related to the page scale
749 float m_pageDefinedMinimumPageScaleFactor;
750 float m_pageDefinedMaximumPageScaleFactor;
751 float m_minimumPageScaleFactor;
752 float m_maximumPageScaleFactor;
753 float m_initialPageScaleFactorOverride;
754 float m_initialPageScaleFactor;
755 bool m_ignoreViewportTagMaximumScale;
756 bool m_pageScaleFactorIsSet;
758 // Saved page scale state.
759 float m_savedPageScaleFactor; // 0 means that no page scale factor is saved.
760 WebCore::IntSize m_savedScrollOffset;
762 // The scale moved to by the latest double tap zoom, if any.
763 float m_doubleTapZoomPageScaleFactor;
764 // Have we sent a double-tap zoom and not yet heard back the scale?
765 bool m_doubleTapZoomPending;
767 // Used for testing purposes.
768 bool m_enableFakeDoubleTapAnimationForTesting;
769 WebCore::IntPoint m_fakeDoubleTapTargetPosition;
770 float m_fakeDoubleTapPageScaleFactor;
771 bool m_fakeDoubleTapUseAnchor;
773 bool m_contextMenuAllowed;
775 bool m_doingDragAndDrop;
777 bool m_ignoreInputEvents;
779 // Webkit expects keyPress events to be suppressed if the associated keyDown
780 // event was handled. Safari implements this behavior by peeking out the
781 // associated WM_CHAR event if the keydown was handled. We emulate
782 // this behavior by setting this flag if the keyDown was handled.
783 bool m_suppressNextKeypressEvent;
785 // The policy for how this webview is to be initially shown.
786 WebNavigationPolicy m_initialNavigationPolicy;
788 // Represents whether or not this object should process incoming IME events.
789 bool m_imeAcceptEvents;
791 // The available drag operations (copy, move link...) allowed by the source.
792 WebDragOperation m_operationsAllowed;
794 // The current drag operation as negotiated by the source and destination.
795 // When not equal to DragOperationNone, the drag data can be dropped onto the
796 // current drop target in this WebView (the drop target can accept the drop).
797 WebDragOperation m_dragOperation;
799 // Context-based feature switches.
800 OwnPtr<ContextFeaturesClientImpl> m_featureSwitchClient;
802 // Whether an Autofill popup is currently showing.
803 bool m_autofillPopupShowing;
805 // The Autofill popup client.
806 OwnPtr<AutofillPopupMenuClient> m_autofillPopupClient;
808 // The Autofill popup.
809 RefPtr<WebCore::PopupContainer> m_autofillPopup;
811 // The popup associated with a select element.
812 RefPtr<WebCore::PopupContainer> m_selectPopup;
814 #if ENABLE(PAGE_POPUP)
815 // The popup associated with an input element.
816 RefPtr<WebPagePopupImpl> m_pagePopup;
819 OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent;
820 OwnPtr<PageOverlayList> m_pageOverlays;
822 // Whether the webview is rendering transparently.
823 bool m_isTransparent;
825 // Whether the user can press tab to focus links.
828 // Inspector settings.
829 WebString m_inspectorSettings;
831 typedef HashMap<WTF::String, WTF::String> SettingsMap;
832 OwnPtr<SettingsMap> m_inspectorSettingsMap;
834 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
835 // The provider of desktop notifications;
836 NotificationPresenterImpl m_notificationPresenter;
839 // If set, the (plugin) node which has mouse capture.
840 RefPtr<WebCore::Node> m_mouseCaptureNode;
842 // If set, the WebView is transitioning to fullscreen for this element.
843 RefPtr<WebCore::Element> m_provisionalFullScreenElement;
845 // If set, the WebView is in fullscreen mode for an element in this frame.
846 RefPtr<WebCore::Frame> m_fullScreenFrame;
847 bool m_isCancelingFullScreen;
849 WebViewBenchmarkSupportImpl m_benchmarkSupport;
851 #if USE(ACCELERATED_COMPOSITING)
852 WebCore::IntRect m_rootLayerScrollDamage;
853 OwnPtr<NonCompositedContentHost> m_nonCompositedContentHost;
854 WebLayerTreeView* m_layerTreeView;
855 WebLayer* m_rootLayer;
856 WebCore::GraphicsLayer* m_rootGraphicsLayer;
857 OwnPtr<WebCore::GraphicsLayerFactory> m_graphicsLayerFactory;
858 bool m_isAcceleratedCompositingActive;
859 bool m_layerTreeViewCommitsDeferred;
860 bool m_compositorCreationFailed;
861 // If true, the graphics context is being restored.
862 bool m_recreatingGraphicsContext;
863 int m_inputHandlerIdentifier;
865 static const WebInputEvent* m_currentInputEvent;
867 #if ENABLE(INPUT_SPEECH)
868 OwnPtr<SpeechInputClientImpl> m_speechInputClient;
870 #if ENABLE(SCRIPTED_SPEECH)
871 OwnPtr<SpeechRecognitionClientProxy> m_speechRecognitionClient;
874 OwnPtr<DeviceOrientationClientProxy> m_deviceOrientationClientProxy;
875 OwnPtr<GeolocationClientProxy> m_geolocationClientProxy;
876 #if ENABLE(BATTERY_STATUS)
877 OwnPtr<BatteryClientImpl> m_batteryClient;
880 float m_emulatedTextZoomFactor;
882 #if ENABLE(MEDIA_STREAM)
883 UserMediaClientImpl m_userMediaClientImpl;
885 #if ENABLE(NAVIGATOR_CONTENT_UTILS)
886 OwnPtr<NavigatorContentUtilsClientImpl> m_navigatorContentUtilsClient;
888 OwnPtr<WebActiveGestureAnimation> m_gestureAnimation;
889 WebPoint m_positionOnFlingStart;
890 WebPoint m_globalPositionOnFlingStart;
892 bool m_flingSourceDevice;
893 #if ENABLE(GESTURE_EVENTS)
894 OwnPtr<LinkHighlight> m_linkHighlight;
896 OwnPtr<ValidationMessageClientImpl> m_validationMessage;
898 bool m_showFPSCounter;
899 bool m_showPaintRects;
900 bool m_showDebugBorders;
901 bool m_continuousPaintingEnabled;
904 } // namespace WebKit