OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 class WebSettingsImpl; | 120 class WebSettingsImpl; |
121 class WebTouchEvent; | 121 class WebTouchEvent; |
122 class WebViewBenchmarkSupport; | 122 class WebViewBenchmarkSupport; |
123 | 123 |
124 class WebViewImpl : public WebView | 124 class WebViewImpl : public WebView |
125 , public RefCounted<WebViewImpl> | 125 , public RefCounted<WebViewImpl> |
126 , public WebGestureCurveTarget | 126 , public WebGestureCurveTarget |
127 , public WebCore::PagePopupDriver | 127 , public WebCore::PagePopupDriver |
128 , public PageWidgetEventHandler { | 128 , public PageWidgetEventHandler { |
129 public: | 129 public: |
130 enum AutoZoomType { | |
131 DoubleTap, | |
132 FindInPage, | |
133 }; | |
134 | 130 |
135 // WebWidget methods: | 131 // WebWidget methods: |
136 virtual void close(); | 132 virtual void close(); |
137 virtual WebSize size(); | 133 virtual WebSize size(); |
138 virtual void willStartLiveResize(); | 134 virtual void willStartLiveResize(); |
139 virtual void resize(const WebSize&); | 135 virtual void resize(const WebSize&); |
140 virtual void willEndLiveResize(); | 136 virtual void willEndLiveResize(); |
141 virtual void willEnterFullScreen(); | 137 virtual void willEnterFullScreen(); |
142 virtual void didEnterFullScreen(); | 138 virtual void didEnterFullScreen(); |
143 virtual void willExitFullScreen(); | 139 virtual void willExitFullScreen(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 virtual void clearFocusedNode(); | 212 virtual void clearFocusedNode(); |
217 virtual void scrollFocusedNodeIntoView(); | 213 virtual void scrollFocusedNodeIntoView(); |
218 virtual void scrollFocusedNodeIntoRect(const WebRect&); | 214 virtual void scrollFocusedNodeIntoRect(const WebRect&); |
219 virtual void zoomToFindInPageRect(const WebRect&); | 215 virtual void zoomToFindInPageRect(const WebRect&); |
220 virtual void advanceFocus(bool reverse); | 216 virtual void advanceFocus(bool reverse); |
221 virtual double zoomLevel(); | 217 virtual double zoomLevel(); |
222 virtual double setZoomLevel(bool textOnly, double zoomLevel); | 218 virtual double setZoomLevel(bool textOnly, double zoomLevel); |
223 virtual void zoomLimitsChanged(double minimumZoomLevel, | 219 virtual void zoomLimitsChanged(double minimumZoomLevel, |
224 double maximumZoomLevel); | 220 double maximumZoomLevel); |
225 virtual void setInitialPageScaleOverride(float); | 221 virtual void setInitialPageScaleOverride(float); |
| 222 virtual bool zoomToMultipleTargetsRect(const WebRect&); |
226 virtual float pageScaleFactor() const; | 223 virtual float pageScaleFactor() const; |
227 virtual void setPageScaleFactorPreservingScrollOffset(float); | 224 virtual void setPageScaleFactorPreservingScrollOffset(float); |
228 virtual void setPageScaleFactor(float scaleFactor, const WebPoint& origin); | 225 virtual void setPageScaleFactor(float scaleFactor, const WebPoint& origin); |
229 virtual void setPageScaleFactorLimits(float minPageScale, float maxPageScale
); | 226 virtual void setPageScaleFactorLimits(float minPageScale, float maxPageScale
); |
230 virtual float minimumPageScaleFactor() const; | 227 virtual float minimumPageScaleFactor() const; |
231 virtual float maximumPageScaleFactor() const; | 228 virtual float maximumPageScaleFactor() const; |
232 virtual void saveScrollAndScaleState(); | 229 virtual void saveScrollAndScaleState(); |
233 virtual void restoreScrollAndScaleState(); | 230 virtual void restoreScrollAndScaleState(); |
234 virtual void resetScrollAndScaleState(); | 231 virtual void resetScrollAndScaleState(); |
235 virtual void setIgnoreViewportTagScaleLimits(bool); | 232 virtual void setIgnoreViewportTagScaleLimits(bool); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 static bool mapKeyCodeForScroll(int keyCode, | 514 static bool mapKeyCodeForScroll(int keyCode, |
518 WebCore::ScrollDirection* scrollDirection, | 515 WebCore::ScrollDirection* scrollDirection, |
519 WebCore::ScrollGranularity* scrollGranularity
); | 516 WebCore::ScrollGranularity* scrollGranularity
); |
520 | 517 |
521 // Called by a full frame plugin inside this view to inform it that its | 518 // Called by a full frame plugin inside this view to inform it that its |
522 // zoom level has been updated. The plugin should only call this function | 519 // zoom level has been updated. The plugin should only call this function |
523 // if the zoom change was triggered by the browser, it's only needed in case | 520 // if the zoom change was triggered by the browser, it's only needed in case |
524 // a plugin can update its own zoom, say because of its own UI. | 521 // a plugin can update its own zoom, say because of its own UI. |
525 void fullFramePluginZoomLevelChanged(double zoomLevel); | 522 void fullFramePluginZoomLevelChanged(double zoomLevel); |
526 | 523 |
527 void computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZoomType, f
loat& scale, WebPoint& scroll, bool& isAnchor); | 524 void computeScaleAndScrollForHitRect( |
| 525 const WebRect& hitRect, |
| 526 float padding, |
| 527 float& scale, |
| 528 WebPoint& scroll, |
| 529 bool& doubleTapShouldZoomOut); |
528 WebCore::Node* bestTapNode(const WebCore::PlatformGestureEvent& tapEvent); | 530 WebCore::Node* bestTapNode(const WebCore::PlatformGestureEvent& tapEvent); |
529 void enableTapHighlight(const WebCore::PlatformGestureEvent& tapEvent); | 531 void enableTapHighlight(const WebCore::PlatformGestureEvent& tapEvent); |
530 void computeScaleAndScrollForFocusedNode(WebCore::Node* focusedNode, float&
scale, WebCore::IntPoint& scroll, bool& needAnimation); | 532 void computeScaleAndScrollForFocusedNode(WebCore::Node* focusedNode, float&
scale, WebCore::IntPoint& scroll, bool& needAnimation); |
531 void animateZoomAroundPoint(const WebCore::IntPoint&, AutoZoomType); | |
532 | 533 |
533 void enableFakeDoubleTapAnimationForTesting(bool); | 534 void animateDoubleTapZoom(const WebCore::IntPoint&); |
534 bool fakeDoubleTapAnimationPendingForTesting() const { return m_doubleTapZoo
mPending; } | 535 bool animateZoomToRect( |
535 WebCore::IntPoint fakeDoubleTapTargetPositionForTesting() const { return m_f
akeDoubleTapTargetPosition; } | 536 const WebCore::IntRect&, |
536 float fakeDoubleTapPageScaleFactorForTesting() const { return m_fakeDoubleTa
pPageScaleFactor; } | 537 double durationInSeconds, |
537 bool fakeDoubleTapUseAnchorForTesting() const { return m_fakeDoubleTapUseAnc
hor; } | 538 bool& isAnimating, |
| 539 float& scale); |
| 540 |
| 541 void enableFakePageScaleAnimationForTesting(bool); |
| 542 bool fakeDoubleTapAnimationPendingForTesting() const |
| 543 { |
| 544 return m_doubleTapZoomPending; |
| 545 } |
| 546 WebCore::IntPoint fakePageScaleAnimationTargetPositionForTesting() const |
| 547 { |
| 548 return m_fakePageScaleAnimationTargetPosition; |
| 549 } |
| 550 float fakePageScaleAnimationPageScaleForTesting() const |
| 551 { |
| 552 return m_fakePageScaleAnimationPageScaleFactor; |
| 553 } |
| 554 bool fakePageScaleAnimationUseAnchorForTesting() const |
| 555 { |
| 556 return m_fakePageScaleAnimationUseAnchor; |
| 557 } |
538 | 558 |
539 void enterFullScreenForElement(WebCore::Element*); | 559 void enterFullScreenForElement(WebCore::Element*); |
540 void exitFullScreenForElement(WebCore::Element*); | 560 void exitFullScreenForElement(WebCore::Element*); |
541 | 561 |
542 // Exposed for the purpose of overriding device metrics. | 562 // Exposed for the purpose of overriding device metrics. |
543 void sendResizeEventAndRepaint(); | 563 void sendResizeEventAndRepaint(); |
544 | 564 |
545 // Exposed for testing purposes. | 565 // Exposed for testing purposes. |
546 bool hasHorizontalScrollbar(); | 566 bool hasHorizontalScrollbar(); |
547 bool hasVerticalScrollbar(); | 567 bool hasVerticalScrollbar(); |
548 | 568 |
549 // Pointer Lock calls allow a page to capture all mouse events and | 569 // Pointer Lock calls allow a page to capture all mouse events and |
550 // disable the system cursor. | 570 // disable the system cursor. |
551 virtual bool requestPointerLock(); | 571 virtual bool requestPointerLock(); |
552 virtual void requestPointerUnlock(); | 572 virtual void requestPointerUnlock(); |
553 virtual bool isPointerLocked(); | 573 virtual bool isPointerLocked(); |
554 | 574 |
555 // Heuristic-based function for determining if we should disable workarounds | 575 // Heuristic-based function for determining if we should disable workarounds |
556 // for viewing websites that are not optimized for mobile devices. | 576 // for viewing websites that are not optimized for mobile devices. |
557 bool shouldDisableDesktopWorkarounds(); | 577 bool shouldDisableDesktopWorkarounds(); |
558 | 578 |
559 // Exposed for tests. | 579 // Exposed for tests. |
560 LinkHighlight* linkHighlight() { return m_linkHighlight.get(); } | 580 LinkHighlight* linkHighlight() { return m_linkHighlight.get(); } |
561 | 581 |
562 WebSettingsImpl* settingsImpl(); | 582 WebSettingsImpl* settingsImpl(); |
563 | 583 |
| 584 // Returns the bounding box of the block type node touched by the WebRect. |
| 585 WebRect computeBlockBounds(const WebRect&, bool ignoreClipping); |
| 586 |
| 587 WebCore::IntPoint clampOffsetAtScale( |
| 588 const WebCore::IntPoint& offset, |
| 589 float scale); |
| 590 |
564 private: | 591 private: |
565 void refreshPageScaleFactorAfterLayout(); | 592 void refreshPageScaleFactorAfterLayout(); |
566 void setUserAgentPageScaleConstraints(WebCore::PageScaleConstraints newConst
raints); | 593 void setUserAgentPageScaleConstraints(WebCore::PageScaleConstraints newConst
raints); |
567 float clampPageScaleFactorToLimits(float) const; | 594 float clampPageScaleFactorToLimits(float) const; |
568 WebCore::IntPoint clampOffsetAtScale(const WebCore::IntPoint& offset, float
scale); | |
569 WebCore::IntSize contentsSize() const; | 595 WebCore::IntSize contentsSize() const; |
570 | 596 |
571 void resetSavedScrollAndScaleState(); | 597 void resetSavedScrollAndScaleState(); |
572 | 598 |
573 void updateMainFrameScrollPosition(const WebCore::IntPoint& scrollPosition,
bool programmaticScroll); | 599 void updateMainFrameScrollPosition(const WebCore::IntPoint& scrollPosition,
bool programmaticScroll); |
574 | 600 |
575 friend class WebView; // So WebView::Create can call our constructor | 601 friend class WebView; // So WebView::Create can call our constructor |
576 friend class WTF::RefCounted<WebViewImpl>; | 602 friend class WTF::RefCounted<WebViewImpl>; |
577 friend void setCurrentInputEventForTest(const WebInputEvent*); | 603 friend void setCurrentInputEventForTest(const WebInputEvent*); |
578 | 604 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 int keyModifiers); | 645 int keyModifiers); |
620 | 646 |
621 void configureAutoResizeMode(); | 647 void configureAutoResizeMode(); |
622 | 648 |
623 void setIsAcceleratedCompositingActive(bool); | 649 void setIsAcceleratedCompositingActive(bool); |
624 void doComposite(); | 650 void doComposite(); |
625 void doPixelReadbackToCanvas(WebCanvas*, const WebCore::IntRect&); | 651 void doPixelReadbackToCanvas(WebCanvas*, const WebCore::IntRect&); |
626 void reallocateRenderer(); | 652 void reallocateRenderer(); |
627 void updateLayerTreeViewport(); | 653 void updateLayerTreeViewport(); |
628 | 654 |
629 // Returns the bounding box of the block type node touched by the WebRect. | |
630 WebRect computeBlockBounds(const WebRect&, AutoZoomType); | |
631 | |
632 // Helper function: Widens the width of |source| by the specified margins | 655 // Helper function: Widens the width of |source| by the specified margins |
633 // while keeping it smaller than page width. | 656 // while keeping it smaller than page width. |
634 WebRect widenRectWithinPageBounds(const WebRect& source, int targetMargin, i
nt minimumMargin); | 657 WebRect widenRectWithinPageBounds(const WebRect& source, int targetMargin, i
nt minimumMargin); |
635 | 658 |
636 void pointerLockMouseEvent(const WebInputEvent&); | 659 void pointerLockMouseEvent(const WebInputEvent&); |
637 | 660 |
638 // PageWidgetEventHandler functions | 661 // PageWidgetEventHandler functions |
639 virtual void handleMouseLeave(WebCore::Frame&, const WebMouseEvent&) OVERRID
E; | 662 virtual void handleMouseLeave(WebCore::Frame&, const WebMouseEvent&) OVERRID
E; |
640 virtual void handleMouseDown(WebCore::Frame&, const WebMouseEvent&) OVERRIDE
; | 663 virtual void handleMouseDown(WebCore::Frame&, const WebMouseEvent&) OVERRIDE
; |
641 virtual void handleMouseUp(WebCore::Frame&, const WebMouseEvent&) OVERRIDE; | 664 virtual void handleMouseUp(WebCore::Frame&, const WebMouseEvent&) OVERRIDE; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 WebCore::IntSize m_savedScrollOffset; | 731 WebCore::IntSize m_savedScrollOffset; |
709 float m_exitFullscreenPageScaleFactor; | 732 float m_exitFullscreenPageScaleFactor; |
710 WebCore::IntSize m_exitFullscreenScrollOffset; | 733 WebCore::IntSize m_exitFullscreenScrollOffset; |
711 | 734 |
712 // The scale moved to by the latest double tap zoom, if any. | 735 // The scale moved to by the latest double tap zoom, if any. |
713 float m_doubleTapZoomPageScaleFactor; | 736 float m_doubleTapZoomPageScaleFactor; |
714 // Have we sent a double-tap zoom and not yet heard back the scale? | 737 // Have we sent a double-tap zoom and not yet heard back the scale? |
715 bool m_doubleTapZoomPending; | 738 bool m_doubleTapZoomPending; |
716 | 739 |
717 // Used for testing purposes. | 740 // Used for testing purposes. |
718 bool m_enableFakeDoubleTapAnimationForTesting; | 741 bool m_enableFakePageScaleAnimationForTesting; |
719 WebCore::IntPoint m_fakeDoubleTapTargetPosition; | 742 WebCore::IntPoint m_fakePageScaleAnimationTargetPosition; |
720 float m_fakeDoubleTapPageScaleFactor; | 743 float m_fakePageScaleAnimationPageScaleFactor; |
721 bool m_fakeDoubleTapUseAnchor; | 744 bool m_fakePageScaleAnimationUseAnchor; |
722 | 745 |
723 bool m_contextMenuAllowed; | 746 bool m_contextMenuAllowed; |
724 | 747 |
725 bool m_doingDragAndDrop; | 748 bool m_doingDragAndDrop; |
726 | 749 |
727 bool m_ignoreInputEvents; | 750 bool m_ignoreInputEvents; |
728 | 751 |
729 // Webkit expects keyPress events to be suppressed if the associated keyDown | 752 // Webkit expects keyPress events to be suppressed if the associated keyDown |
730 // event was handled. Safari implements this behavior by peeking out the | 753 // event was handled. Safari implements this behavior by peeking out the |
731 // associated WM_CHAR event if the keydown was handled. We emulate | 754 // associated WM_CHAR event if the keydown was handled. We emulate |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 bool m_showFPSCounter; | 855 bool m_showFPSCounter; |
833 bool m_showPaintRects; | 856 bool m_showPaintRects; |
834 bool m_showDebugBorders; | 857 bool m_showDebugBorders; |
835 bool m_continuousPaintingEnabled; | 858 bool m_continuousPaintingEnabled; |
836 bool m_showScrollBottleneckRects; | 859 bool m_showScrollBottleneckRects; |
837 }; | 860 }; |
838 | 861 |
839 } // namespace WebKit | 862 } // namespace WebKit |
840 | 863 |
841 #endif | 864 #endif |
OLD | NEW |