1 /* 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 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 13 * distribution. 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. 17 * 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. 29 */ 30 31 #ifndef WebViewImpl_h 32 #define WebViewImpl_h 33 34 #include "BackForwardClientImpl.h" 35 #include "ChromeClientImpl.h" 36 #include "ContextMenuClientImpl.h" 37 #include "DragClientImpl.h" 38 #include "EditorClientImpl.h" 39 #include "InspectorClientImpl.h" 40 #include "MIDIClientImpl.h" 41 #include "NotificationPresenterImpl.h" 42 #include "PageOverlayList.h" 43 #include "PageWidgetDelegate.h" 44 #include "UserMediaClientImpl.h" 45 #include "WebInputEvent.h" 46 #include "WebNavigationPolicy.h" 47 #include "WebView.h" 48 #include "WebViewBenchmarkSupportImpl.h" 49 #include "core/page/PagePopupDriver.h" 50 #include "core/page/PageScaleConstraintsSet.h" 51 #include "core/platform/Timer.h" 52 #include "core/platform/graphics/FloatSize.h" 53 #include "core/platform/graphics/GraphicsContext3D.h" 54 #include "core/platform/graphics/GraphicsLayer.h" 55 #include "core/platform/graphics/IntPoint.h" 56 #include "core/platform/graphics/IntRect.h" 57 #include "public/platform/WebFloatQuad.h" 58 #include "public/platform/WebGestureCurveTarget.h" 59 #include "public/platform/WebLayer.h" 60 #include "public/platform/WebPoint.h" 61 #include "public/platform/WebRect.h" 62 #include "public/platform/WebSize.h" 63 #include "public/platform/WebString.h" 64 #include "wtf/OwnPtr.h" 65 #include "wtf/RefCounted.h" 66 #include "wtf/Vector.h" 67 68 namespace WebCore { 69 class ChromiumDataObject; 70 class Color; 71 class DocumentLoader; 72 class FloatSize; 73 class Frame; 74 class GraphicsContext3D; 75 class GraphicsLayerFactory; 76 class HistoryItem; 77 class HitTestResult; 78 class KeyboardEvent; 79 class Page; 80 class PageGroup; 81 class PagePopup; 82 class PagePopupClient; 83 class PlatformKeyboardEvent; 84 class PopupContainer; 85 class PopupMenuClient; 86 class Range; 87 class RenderLayerCompositor; 88 class RenderTheme; 89 class Widget; 90 } 91 92 namespace WebKit { 93 class AutocompletePopupMenuClient; 94 class AutofillPopupMenuClient; 95 class ContextFeaturesClientImpl; 96 class ContextMenuClientImpl; 97 class DeviceOrientationClientProxy; 98 class GeolocationClientProxy; 99 class LinkHighlight; 100 class PinchViewports; 101 class PrerendererClientImpl; 102 class SpeechInputClientImpl; 103 class SpeechRecognitionClientProxy; 104 class UserMediaClientImpl; 105 class ValidationMessageClientImpl; 106 class WebAccessibilityObject; 107 class WebActiveGestureAnimation; 108 class WebCompositorImpl; 109 class WebDevToolsAgentClient; 110 class WebDevToolsAgentPrivate; 111 class WebDocument; 112 class WebFrameImpl; 113 class WebGestureEvent; 114 class WebHelperPluginImpl; 115 class WebImage; 116 class WebKeyboardEvent; 117 class WebLayerTreeView; 118 class WebMouseEvent; 119 class WebMouseWheelEvent; 120 class WebPagePopupImpl; 121 class WebPrerendererClient; 122 class WebSettingsImpl; 123 class WebTouchEvent; 124 class WebViewBenchmarkSupport; 125 class FullscreenController; 126 127 class WebViewImpl : public WebView 128 , public RefCounted<WebViewImpl> 129 , public WebGestureCurveTarget 130 , public WebCore::PagePopupDriver 131 , public PageWidgetEventHandler { 132 public: 133 134 // WebWidget methods: 135 virtual void close(); 136 virtual WebSize size(); 137 virtual void willStartLiveResize(); 138 virtual void resize(const WebSize&); 139 virtual void willEndLiveResize(); 140 virtual void willEnterFullScreen(); 141 virtual void didEnterFullScreen(); 142 virtual void willExitFullScreen(); 143 virtual void didExitFullScreen(); 144 virtual void animate(double); 145 virtual void layout(); 146 virtual void enterForceCompositingMode(bool enable) OVERRIDE; 147 virtual void paint(WebCanvas*, const WebRect&, PaintOptions = ReadbackFromCompositorIfAvailable); 148 virtual bool isTrackingRepaints() const OVERRIDE; 149 virtual void themeChanged(); 150 virtual void setNeedsRedraw(); 151 virtual bool handleInputEvent(const WebInputEvent&); 152 virtual void setCursorVisibilityState(bool isVisible); 153 virtual bool hasTouchEventHandlersAt(const WebPoint&); 154 virtual void applyScrollAndScale(const WebSize&, float); 155 virtual void mouseCaptureLost(); 156 virtual void setFocus(bool enable); 157 virtual bool setComposition( 158 const WebString& text, 159 const WebVector<WebCompositionUnderline>& underlines, 160 int selectionStart, 161 int selectionEnd); 162 virtual bool confirmComposition(); 163 virtual bool confirmComposition(ConfirmCompositionBehavior selectionBehavior); 164 virtual bool confirmComposition(const WebString& text); 165 virtual bool compositionRange(size_t* location, size_t* length); 166 virtual WebTextInputInfo textInputInfo(); 167 virtual bool setEditableSelectionOffsets(int start, int end); 168 virtual bool setCompositionFromExistingText(int compositionStart, int compositionEnd, const WebVector<WebCompositionUnderline>& underlines); 169 virtual void extendSelectionAndDelete(int before, int after); 170 virtual bool isSelectionEditable() const; 171 virtual WebColor backgroundColor() const; 172 virtual bool selectionBounds(WebRect& anchor, WebRect& focus) const; 173 virtual bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const; 174 virtual bool isSelectionAnchorFirst() const; 175 virtual bool caretOrSelectionRange(size_t* location, size_t* length); 176 virtual void setTextDirection(WebTextDirection direction); 177 virtual bool isAcceleratedCompositingActive() const; 178 virtual void willCloseLayerTreeView(); 179 virtual void didAcquirePointerLock(); 180 virtual void didNotAcquirePointerLock(); 181 virtual void didLosePointerLock(); 182 virtual void didChangeWindowResizerRect(); 183 virtual void didExitCompositingMode(); 184 185 // WebView methods: 186 virtual void initializeMainFrame(WebFrameClient*); 187 virtual void initializeHelperPluginFrame(WebFrameClient*); 188 virtual void setAutofillClient(WebAutofillClient*); 189 virtual void setDevToolsAgentClient(WebDevToolsAgentClient*); 190 virtual void setPermissionClient(WebPermissionClient*); 191 virtual void setPrerendererClient(WebPrerendererClient*) OVERRIDE; 192 virtual void setSpellCheckClient(WebSpellCheckClient*); 193 virtual void setValidationMessageClient(WebValidationMessageClient*) OVERRIDE; 194 virtual void setPasswordGeneratorClient(WebPasswordGeneratorClient*) OVERRIDE; 195 virtual WebSettings* settings(); 196 virtual WebString pageEncoding() const; 197 virtual void setPageEncoding(const WebString& encoding); 198 virtual bool isTransparent() const; 199 virtual void setIsTransparent(bool value); 200 virtual void setBaseBackgroundColor(WebColor); 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 void setWindowFeatures(const WebWindowFeatures&); 209 virtual bool dispatchBeforeUnloadEvent(); 210 virtual void dispatchUnloadEvent(); 211 virtual WebFrame* mainFrame(); 212 virtual WebFrame* findFrameByName( 213 const WebString& name, WebFrame* relativeToFrame); 214 virtual WebFrame* focusedFrame(); 215 virtual void setFocusedFrame(WebFrame* frame); 216 virtual void setInitialFocus(bool reverse); 217 virtual void clearFocusedNode(); 218 virtual void scrollFocusedNodeIntoView(); 219 virtual void scrollFocusedNodeIntoRect(const WebRect&); 220 virtual void zoomToFindInPageRect(const WebRect&); 221 virtual void advanceFocus(bool reverse); 222 virtual double zoomLevel(); 223 virtual double setZoomLevel(double); 224 virtual double setZoomLevel(bool textOnly, double zoomLevel); 225 virtual void zoomLimitsChanged(double minimumZoomLevel, 226 double maximumZoomLevel); 227 virtual float textZoomFactor(); 228 virtual float setTextZoomFactor(float); 229 virtual void setInitialPageScaleOverride(float); 230 virtual bool zoomToMultipleTargetsRect(const WebRect&); 231 virtual float pageScaleFactor() const; 232 virtual void setPageScaleFactorPreservingScrollOffset(float); 233 virtual void setPageScaleFactor(float scaleFactor, const WebPoint& origin); 234 virtual void setPageScaleFactorLimits(float minPageScale, float maxPageScale); 235 virtual float minimumPageScaleFactor() const; 236 virtual float maximumPageScaleFactor() const; 237 virtual void saveScrollAndScaleState(); 238 virtual void restoreScrollAndScaleState(); 239 virtual void resetScrollAndScaleState(); 240 virtual void setIgnoreViewportTagScaleLimits(bool); 241 virtual WebSize contentsPreferredMinimumSize(); 242 243 virtual float deviceScaleFactor() const; 244 virtual void setDeviceScaleFactor(float); 245 virtual bool isFixedLayoutModeEnabled() const; 246 virtual void enableFixedLayoutMode(bool enable); 247 virtual WebSize fixedLayoutSize() const; 248 virtual void setFixedLayoutSize(const WebSize&); 249 virtual void enableAutoResizeMode( 250 const WebSize& minSize, 251 const WebSize& maxSize); 252 virtual void disableAutoResizeMode(); 253 virtual void performMediaPlayerAction( 254 const WebMediaPlayerAction& action, 255 const WebPoint& location); 256 virtual void performPluginAction( 257 const WebPluginAction&, 258 const WebPoint&); 259 virtual WebHitTestResult hitTestResultAt(const WebPoint&); 260 virtual void copyImageAt(const WebPoint& point); 261 virtual void dragSourceEndedAt( 262 const WebPoint& clientPoint, 263 const WebPoint& screenPoint, 264 WebDragOperation operation); 265 virtual void dragSourceMovedTo( 266 const WebPoint& clientPoint, 267 const WebPoint& screenPoint, 268 WebDragOperation operation); 269 virtual void dragSourceSystemDragEnded(); 270 virtual WebDragOperation dragTargetDragEnter( 271 const WebDragData&, 272 const WebPoint& clientPoint, 273 const WebPoint& screenPoint, 274 WebDragOperationsMask operationsAllowed, 275 int keyModifiers); 276 virtual WebDragOperation dragTargetDragOver( 277 const WebPoint& clientPoint, 278 const WebPoint& screenPoint, 279 WebDragOperationsMask operationsAllowed, 280 int keyModifiers); 281 virtual void dragTargetDragLeave(); 282 virtual void dragTargetDrop( 283 const WebPoint& clientPoint, 284 const WebPoint& screenPoint, 285 int keyModifiers); 286 virtual void spellingMarkers(WebVector<uint32_t>* markers); 287 virtual unsigned long createUniqueIdentifierForRequest(); 288 virtual void inspectElementAt(const WebPoint& point); 289 virtual WebString inspectorSettings() const; 290 virtual void setInspectorSettings(const WebString& settings); 291 virtual bool inspectorSetting(const WebString& key, WebString* value) const; 292 virtual void setInspectorSetting(const WebString& key, 293 const WebString& value); 294 virtual WebDevToolsAgent* devToolsAgent(); 295 virtual WebAccessibilityObject accessibilityObject(); 296 virtual void applyAutofillSuggestions( 297 const WebNode&, 298 const WebVector<WebString>& names, 299 const WebVector<WebString>& labels, 300 const WebVector<WebString>& icons, 301 const WebVector<int>& itemIDs, 302 int separatorIndex); 303 virtual void hidePopups(); 304 virtual void selectAutofillSuggestionAtIndex(unsigned listIndex); 305 virtual void setScrollbarColors(unsigned inactiveColor, 306 unsigned activeColor, 307 unsigned trackColor); 308 virtual void setSelectionColors(unsigned activeBackgroundColor, 309 unsigned activeForegroundColor, 310 unsigned inactiveBackgroundColor, 311 unsigned inactiveForegroundColor); 312 virtual void performCustomContextMenuAction(unsigned action); 313 virtual void showContextMenu(); 314 virtual void addPageOverlay(WebPageOverlay*, int /* zOrder */); 315 virtual void removePageOverlay(WebPageOverlay*); 316 virtual void transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters&); 317 virtual WebViewBenchmarkSupport* benchmarkSupport(); 318 virtual void setShowPaintRects(bool); 319 virtual void setShowDebugBorders(bool); 320 virtual void setShowFPSCounter(bool); 321 virtual void setContinuousPaintingEnabled(bool); 322 virtual void setShowScrollBottleneckRects(bool); 323 324 // WebViewImpl 325 326 void suppressInvalidations(bool enable); 327 void invalidateRect(const WebCore::IntRect&); 328 329 void setIgnoreInputEvents(bool newValue); 330 WebDevToolsAgentPrivate* devToolsAgentPrivate() { return m_devToolsAgent.get(); } 331 332 WebCore::Color baseBackgroundColor() const { return m_baseBackgroundColor; } 333 334 PageOverlayList* pageOverlays() const { return m_pageOverlays.get(); } 335 336 void setOverlayLayer(WebCore::GraphicsLayer*); 337 338 const WebPoint& lastMouseDownPoint() const 339 { 340 return m_lastMouseDownPoint; 341 } 342 343 WebCore::Frame* focusedWebCoreFrame() const; 344 345 // Returns the currently focused Element or null if no element has focus. 346 WebCore::Element* focusedElement(); 347 348 static WebViewImpl* fromPage(WebCore::Page*); 349 350 WebViewClient* client() 351 { 352 return m_client; 353 } 354 355 WebAutofillClient* autofillClient() 356 { 357 return m_autofillClient; 358 } 359 360 WebPermissionClient* permissionClient() 361 { 362 return m_permissionClient; 363 } 364 365 WebSpellCheckClient* spellCheckClient() 366 { 367 return m_spellCheckClient; 368 } 369 370 WebPasswordGeneratorClient* passwordGeneratorClient() const 371 { 372 return m_passwordGeneratorClient; 373 } 374 375 // Returns the page object associated with this view. This may be null when 376 // the page is shutting down, but will be valid at all other times. 377 WebCore::Page* page() const 378 { 379 return m_page.get(); 380 } 381 382 WebCore::RenderTheme* theme() const; 383 384 // Returns the main frame associated with this view. This may be null when 385 // the page is shutting down, but will be valid at all other times. 386 WebFrameImpl* mainFrameImpl(); 387 388 // History related methods: 389 void observeNewNavigation(); 390 391 // Event related methods: 392 void mouseContextMenu(const WebMouseEvent&); 393 void mouseDoubleClick(const WebMouseEvent&); 394 395 bool detectContentOnTouch(const WebPoint&); 396 bool startPageScaleAnimation(const WebCore::IntPoint& targetPosition, bool useAnchor, float newScale, double durationInSeconds); 397 398 void numberOfWheelEventHandlersChanged(unsigned); 399 void hasTouchEventHandlers(bool); 400 401 // WebGestureCurveTarget implementation for fling. 402 virtual void scrollBy(const WebFloatSize&); 403 404 // Handles context menu events orignated via the the keyboard. These 405 // include the VK_APPS virtual key and the Shift+F10 combine. Code is 406 // based on the Webkit function bool WebView::handleContextMenuEvent(WPARAM 407 // wParam, LPARAM lParam) in webkit\webkit\win\WebView.cpp. The only 408 // significant change in this function is the code to convert from a 409 // Keyboard event to the Right Mouse button down event. 410 bool sendContextMenuEvent(const WebKeyboardEvent&); 411 412 // Notifies the WebView that a load has been committed. isNewNavigation 413 // will be true if a new session history item should be created for that 414 // load. isNavigationWithinPage will be true if the navigation does 415 // not take the user away from the current page. 416 void didCommitLoad(bool* isNewNavigation, bool isNavigationWithinPage); 417 418 // Indicates two things: 419 // 1) This view may have a new layout now. 420 // 2) Calling layout() is a no-op. 421 // After calling WebWidget::layout(), expect to get this notification 422 // unless the view did not need a layout. 423 void layoutUpdated(WebFrameImpl*); 424 425 void didChangeContentsSize(); 426 void deviceOrPageScaleFactorChanged(); 427 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(); 431 432 bool contextMenuAllowed() const 433 { 434 return m_contextMenuAllowed; 435 } 436 437 bool shouldAutoResize() const 438 { 439 return m_shouldAutoResize; 440 } 441 442 WebCore::IntSize minAutoSize() const 443 { 444 return m_minAutoSize; 445 } 446 447 WebCore::IntSize maxAutoSize() const 448 { 449 return m_maxAutoSize; 450 } 451 452 void updatePageDefinedPageScaleConstraints(const WebCore::ViewportArguments&); 453 454 // Start a system drag and drop operation. 455 void startDragging( 456 WebCore::Frame*, 457 const WebDragData& dragData, 458 WebDragOperationsMask mask, 459 const WebImage& dragImage, 460 const WebPoint& dragImageOffset); 461 462 void autofillPopupDidHide() 463 { 464 m_autofillPopupShowing = false; 465 } 466 467 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) 468 // Returns the provider of desktop notifications. 469 NotificationPresenterImpl* notificationPresenterImpl(); 470 #endif 471 472 // Tries to scroll a frame or any parent of a frame. Returns true if the view 473 // was scrolled. 474 bool propagateScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity); 475 476 // Notification that a popup was opened/closed. 477 void popupOpened(WebCore::PopupContainer* popupContainer); 478 void popupClosed(WebCore::PopupContainer* popupContainer); 479 // PagePopupDriver functions. 480 virtual WebCore::PagePopup* openPagePopup(WebCore::PagePopupClient*, const WebCore::IntRect& originBoundsInRootView) OVERRIDE; 481 virtual void closePagePopup(WebCore::PagePopup*) OVERRIDE; 482 483 void hideAutofillPopup(); 484 485 // Creates a Helper Plugin of |pluginType| for |hostDocument|. 486 WebHelperPluginImpl* createHelperPlugin(const String& pluginType, const WebDocument& hostDocument); 487 void closeHelperPluginSoon(PassRefPtr<WebHelperPluginImpl>); 488 489 // Returns the input event we're currently processing. This is used in some 490 // cases where the WebCore DOM event doesn't have the information we need. 491 static const WebInputEvent* currentInputEvent() 492 { 493 return m_currentInputEvent; 494 } 495 496 WebCore::GraphicsLayer* rootGraphicsLayer(); 497 bool allowsAcceleratedCompositing(); 498 void setRootGraphicsLayer(WebCore::GraphicsLayer*); 499 void scheduleCompositingLayerSync(); 500 void scrollRootLayerRect(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& clipRect); 501 WebCore::GraphicsLayerFactory* graphicsLayerFactory() const; 502 WebCore::RenderLayerCompositor* compositor() const; 503 void registerForAnimations(WebLayer*); 504 void scheduleAnimation(); 505 506 void didProgrammaticallyScroll(const WebCore::IntPoint& scrollPoint); 507 508 virtual void setVisibilityState(WebPageVisibilityState, bool); 509 510 WebCore::PopupContainer* selectPopup() const { return m_selectPopup.get(); } 511 bool hasOpenedPopup() const { return m_selectPopup || m_pagePopup; } 512 513 // Returns true if the event leads to scrolling. 514 static bool mapKeyCodeForScroll(int keyCode, 515 WebCore::ScrollDirection* scrollDirection, 516 WebCore::ScrollGranularity* scrollGranularity); 517 518 // Called by a full frame plugin inside this view to inform it that its 519 // zoom level has been updated. The plugin should only call this function 520 // if the zoom change was triggered by the browser, it's only needed in case 521 // a plugin can update its own zoom, say because of its own UI. 522 void fullFramePluginZoomLevelChanged(double zoomLevel); 523 524 void computeScaleAndScrollForBlockRect(const WebPoint& hitPoint, const WebRect& blockRect, float padding, float& scale, WebPoint& scroll, bool& doubleTapShouldZoomOut); 525 WebCore::Node* bestTapNode(const WebCore::PlatformGestureEvent& tapEvent); 526 void enableTapHighlight(const WebCore::PlatformGestureEvent& tapEvent); 527 void computeScaleAndScrollForFocusedNode(WebCore::Node* focusedNode, float& scale, WebCore::IntPoint& scroll, bool& needAnimation); 528 529 void animateDoubleTapZoom(const WebCore::IntPoint&); 530 531 void enableFakePageScaleAnimationForTesting(bool); 532 bool fakeDoubleTapAnimationPendingForTesting() const { return m_doubleTapZoomPending; } 533 WebCore::IntPoint fakePageScaleAnimationTargetPositionForTesting() const { return m_fakePageScaleAnimationTargetPosition; } 534 float fakePageScaleAnimationPageScaleForTesting() const { return m_fakePageScaleAnimationPageScaleFactor; } 535 bool fakePageScaleAnimationUseAnchorForTesting() const { return m_fakePageScaleAnimationUseAnchor; } 536 537 void enterFullScreenForElement(WebCore::Element*); 538 void exitFullScreenForElement(WebCore::Element*); 539 540 // Exposed for the purpose of overriding device metrics. 541 void sendResizeEventAndRepaint(); 542 543 // Exposed for testing purposes. 544 bool hasHorizontalScrollbar(); 545 bool hasVerticalScrollbar(); 546 547 // Pointer Lock calls allow a page to capture all mouse events and 548 // disable the system cursor. 549 virtual bool requestPointerLock(); 550 virtual void requestPointerUnlock(); 551 virtual bool isPointerLocked(); 552 553 // Heuristic-based function for determining if we should disable workarounds 554 // for viewing websites that are not optimized for mobile devices. 555 bool shouldDisableDesktopWorkarounds(); 556 557 // Exposed for tests. 558 LinkHighlight* linkHighlight() { return m_linkHighlight.get(); } 559 560 WebSettingsImpl* settingsImpl(); 561 562 // Returns the bounding box of the block type node touched by the WebRect. 563 WebRect computeBlockBounds(const WebRect&, bool ignoreClipping); 564 565 WebCore::IntPoint clampOffsetAtScale(const WebCore::IntPoint& offset, float scale); 566 567 // Exposed for tests. 568 WebVector<WebCompositionUnderline> compositionUnderlines() const; 569 570 private: 571 void refreshPageScaleFactorAfterLayout(); 572 void setUserAgentPageScaleConstraints(WebCore::PageScaleConstraints newConstraints); 573 float clampPageScaleFactorToLimits(float) const; 574 WebCore::IntSize contentsSize() const; 575 576 void resetSavedScrollAndScaleState(); 577 578 void updateMainFrameScrollPosition(const WebCore::IntPoint& scrollPosition, bool programmaticScroll); 579 580 friend class WebView; // So WebView::Create can call our constructor 581 friend class WTF::RefCounted<WebViewImpl>; 582 friend void setCurrentInputEventForTest(const WebInputEvent*); 583 584 enum DragAction { 585 DragEnter, 586 DragOver 587 }; 588 589 WebViewImpl(WebViewClient*); 590 virtual ~WebViewImpl(); 591 592 WebTextInputType textInputType(); 593 594 WebString inputModeOfFocusedElement(); 595 596 // Returns true if the event was actually processed. 597 bool keyEventDefault(const WebKeyboardEvent&); 598 599 // Returns true if the autocomple has consumed the event. 600 bool autocompleteHandleKeyEvent(const WebKeyboardEvent&); 601 602 // Repaints the Autofill popup. Should be called when the suggestions 603 // have changed. Note that this should only be called when the Autofill 604 // popup is showing. 605 void refreshAutofillPopup(); 606 607 bool confirmComposition(const WebString& text, ConfirmCompositionBehavior); 608 609 // Returns true if the view was scrolled. 610 bool scrollViewWithKeyboard(int keyCode, int modifiers); 611 612 void hideSelectPopup(); 613 614 // Converts |pos| from window coordinates to contents coordinates and gets 615 // the HitTestResult for it. 616 WebCore::HitTestResult hitTestResultForWindowPos(const WebCore::IntPoint&); 617 618 // Consolidate some common code between starting a drag over a target and 619 // updating a drag over a target. If we're starting a drag, |isEntering| 620 // should be true. 621 WebDragOperation dragTargetDragEnterOrOver(const WebPoint& clientPoint, 622 const WebPoint& screenPoint, 623 DragAction, 624 int keyModifiers); 625 626 void configureAutoResizeMode(); 627 628 void setIsAcceleratedCompositingActive(bool); 629 void doComposite(); 630 void doPixelReadbackToCanvas(WebCanvas*, const WebCore::IntRect&); 631 void reallocateRenderer(); 632 void updateLayerTreeViewport(); 633 634 // Helper function: Widens the width of |source| by the specified margins 635 // while keeping it smaller than page width. 636 WebRect widenRectWithinPageBounds(const WebRect& source, int targetMargin, int minimumMargin); 637 638 void pointerLockMouseEvent(const WebInputEvent&); 639 640 // PageWidgetEventHandler functions 641 virtual void handleMouseLeave(WebCore::Frame&, const WebMouseEvent&) OVERRIDE; 642 virtual void handleMouseDown(WebCore::Frame&, const WebMouseEvent&) OVERRIDE; 643 virtual void handleMouseUp(WebCore::Frame&, const WebMouseEvent&) OVERRIDE; 644 virtual bool handleMouseWheel(WebCore::Frame&, const WebMouseWheelEvent&) OVERRIDE; 645 virtual bool handleGestureEvent(const WebGestureEvent&) OVERRIDE; 646 virtual bool handleKeyEvent(const WebKeyboardEvent&) OVERRIDE; 647 virtual bool handleCharEvent(const WebKeyboardEvent&) OVERRIDE; 648 649 void closePendingHelperPlugins(WebCore::Timer<WebViewImpl>*); 650 651 WebViewClient* m_client; // Can be 0 (e.g. unittests, shared workers, etc.) 652 WebAutofillClient* m_autofillClient; 653 WebPermissionClient* m_permissionClient; 654 WebSpellCheckClient* m_spellCheckClient; 655 WebPasswordGeneratorClient* m_passwordGeneratorClient; 656 657 ChromeClientImpl m_chromeClientImpl; 658 ContextMenuClientImpl m_contextMenuClientImpl; 659 DragClientImpl m_dragClientImpl; 660 EditorClientImpl m_editorClientImpl; 661 InspectorClientImpl m_inspectorClientImpl; 662 BackForwardClientImpl m_backForwardClientImpl; 663 664 WebSize m_size; 665 bool m_fixedLayoutSizeLock; 666 // If true, automatically resize the render view around its content. 667 bool m_shouldAutoResize; 668 // The lower bound on the size when auto-resizing. 669 WebCore::IntSize m_minAutoSize; 670 // The upper bound on the size when auto-resizing. 671 WebCore::IntSize m_maxAutoSize; 672 673 OwnPtr<WebCore::Page> m_page; 674 675 // This flag is set when a new navigation is detected. It is used to satisfy 676 // the corresponding argument to WebFrameClient::didCommitProvisionalLoad. 677 bool m_observedNewNavigation; 678 #ifndef NDEBUG 679 // Used to assert that the new navigation we observed is the same navigation 680 // when we make use of m_observedNewNavigation. 681 const WebCore::DocumentLoader* m_newNavigationLoader; 682 #endif 683 684 // An object that can be used to manipulate m_page->settings() without linking 685 // against WebCore. This is lazily allocated the first time GetWebSettings() 686 // is called. 687 OwnPtr<WebSettingsImpl> m_webSettings; 688 689 // A copy of the web drop data object we received from the browser. 690 RefPtr<WebCore::ChromiumDataObject> m_currentDragData; 691 692 // The point relative to the client area where the mouse was last pressed 693 // down. This is used by the drag client to determine what was under the 694 // mouse when the drag was initiated. We need to track this here in 695 // WebViewImpl since DragClient::startDrag does not pass the position the 696 // mouse was at when the drag was initiated, only the current point, which 697 // can be misleading as it is usually not over the element the user actually 698 // dragged by the time a drag is initiated. 699 WebPoint m_lastMouseDownPoint; 700 701 // Keeps track of the current zoom level. 0 means no zoom, positive numbers 702 // mean zoom in, negative numbers mean zoom out. 703 double m_zoomLevel; 704 705 double m_minimumZoomLevel; 706 707 double m_maximumZoomLevel; 708 709 WebCore::PageScaleConstraintsSet m_pageScaleConstraintsSet; 710 711 // Saved page scale state. 712 float m_savedPageScaleFactor; // 0 means that no page scale factor is saved. 713 WebCore::IntSize m_savedScrollOffset; 714 715 // The scale moved to by the latest double tap zoom, if any. 716 float m_doubleTapZoomPageScaleFactor; 717 // Have we sent a double-tap zoom and not yet heard back the scale? 718 bool m_doubleTapZoomPending; 719 720 // Used for testing purposes. 721 bool m_enableFakePageScaleAnimationForTesting; 722 WebCore::IntPoint m_fakePageScaleAnimationTargetPosition; 723 float m_fakePageScaleAnimationPageScaleFactor; 724 bool m_fakePageScaleAnimationUseAnchor; 725 726 bool m_contextMenuAllowed; 727 728 bool m_doingDragAndDrop; 729 730 bool m_ignoreInputEvents; 731 732 // Webkit expects keyPress events to be suppressed if the associated keyDown 733 // event was handled. Safari implements this behavior by peeking out the 734 // associated WM_CHAR event if the keydown was handled. We emulate 735 // this behavior by setting this flag if the keyDown was handled. 736 bool m_suppressNextKeypressEvent; 737 738 // Represents whether or not this object should process incoming IME events. 739 bool m_imeAcceptEvents; 740 741 // The available drag operations (copy, move link...) allowed by the source. 742 WebDragOperation m_operationsAllowed; 743 744 // The current drag operation as negotiated by the source and destination. 745 // When not equal to DragOperationNone, the drag data can be dropped onto the 746 // current drop target in this WebView (the drop target can accept the drop). 747 WebDragOperation m_dragOperation; 748 749 // Context-based feature switches. 750 OwnPtr<ContextFeaturesClientImpl> m_featureSwitchClient; 751 752 // Whether an Autofill popup is currently showing. 753 bool m_autofillPopupShowing; 754 755 // The Autofill popup client. 756 OwnPtr<AutofillPopupMenuClient> m_autofillPopupClient; 757 758 // The Autofill popup. 759 RefPtr<WebCore::PopupContainer> m_autofillPopup; 760 761 // The popup associated with a select element. 762 RefPtr<WebCore::PopupContainer> m_selectPopup; 763 764 // The popup associated with an input element. 765 RefPtr<WebPagePopupImpl> m_pagePopup; 766 767 OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent; 768 OwnPtr<PageOverlayList> m_pageOverlays; 769 770 // Whether the webview is rendering transparently. 771 bool m_isTransparent; 772 773 // Whether the user can press tab to focus links. 774 bool m_tabsToLinks; 775 776 // Inspector settings. 777 WebString m_inspectorSettings; 778 779 typedef HashMap<WTF::String, WTF::String> SettingsMap; 780 OwnPtr<SettingsMap> m_inspectorSettingsMap; 781 782 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) 783 // The provider of desktop notifications; 784 NotificationPresenterImpl m_notificationPresenter; 785 #endif 786 787 // If set, the (plugin) node which has mouse capture. 788 RefPtr<WebCore::Node> m_mouseCaptureNode; 789 790 WebViewBenchmarkSupportImpl m_benchmarkSupport; 791 792 WebCore::IntRect m_rootLayerScrollDamage; 793 WebLayerTreeView* m_layerTreeView; 794 WebLayer* m_rootLayer; 795 WebCore::GraphicsLayer* m_rootGraphicsLayer; 796 OwnPtr<WebCore::GraphicsLayerFactory> m_graphicsLayerFactory; 797 bool m_isAcceleratedCompositingActive; 798 bool m_layerTreeViewCommitsDeferred; 799 bool m_compositorCreationFailed; 800 // If true, the graphics context is being restored. 801 bool m_recreatingGraphicsContext; 802 static const WebInputEvent* m_currentInputEvent; 803 OwnPtr<PinchViewports> m_pinchViewports; 804 805 #if ENABLE(INPUT_SPEECH) 806 OwnPtr<SpeechInputClientImpl> m_speechInputClient; 807 #endif 808 OwnPtr<SpeechRecognitionClientProxy> m_speechRecognitionClient; 809 810 OwnPtr<DeviceOrientationClientProxy> m_deviceOrientationClientProxy; 811 OwnPtr<GeolocationClientProxy> m_geolocationClientProxy; 812 813 UserMediaClientImpl m_userMediaClientImpl; 814 MIDIClientImpl m_midiClientImpl; 815 #if ENABLE(NAVIGATOR_CONTENT_UTILS) 816 OwnPtr<NavigatorContentUtilsClientImpl> m_navigatorContentUtilsClient; 817 #endif 818 OwnPtr<WebActiveGestureAnimation> m_gestureAnimation; 819 WebPoint m_positionOnFlingStart; 820 WebPoint m_globalPositionOnFlingStart; 821 int m_flingModifier; 822 bool m_flingSourceDevice; 823 OwnPtr<LinkHighlight> m_linkHighlight; 824 OwnPtr<ValidationMessageClientImpl> m_validationMessage; 825 OwnPtr<FullscreenController> m_fullscreenController; 826 827 bool m_showFPSCounter; 828 bool m_showPaintRects; 829 bool m_showDebugBorders; 830 bool m_continuousPaintingEnabled; 831 bool m_showScrollBottleneckRects; 832 WebColor m_baseBackgroundColor; 833 834 WebCore::Timer<WebViewImpl> m_helperPluginCloseTimer; 835 Vector<RefPtr<WebHelperPluginImpl> > m_helperPluginsPendingClose; 836 }; 837 838 } // namespace WebKit 839 840 #endif 841