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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 virtual void clearFocusedNode(); | 214 virtual void clearFocusedNode(); |
219 virtual void scrollFocusedNodeIntoView(); | 215 virtual void scrollFocusedNodeIntoView(); |
220 virtual void scrollFocusedNodeIntoRect(const WebRect&); | 216 virtual void scrollFocusedNodeIntoRect(const WebRect&); |
221 virtual void zoomToFindInPageRect(const WebRect&); | 217 virtual void zoomToFindInPageRect(const WebRect&); |
222 virtual void advanceFocus(bool reverse); | 218 virtual void advanceFocus(bool reverse); |
223 virtual double zoomLevel(); | 219 virtual double zoomLevel(); |
224 virtual double setZoomLevel(bool textOnly, double zoomLevel); | 220 virtual double setZoomLevel(bool textOnly, double zoomLevel); |
225 virtual void zoomLimitsChanged(double minimumZoomLevel, | 221 virtual void zoomLimitsChanged(double minimumZoomLevel, |
226 double maximumZoomLevel); | 222 double maximumZoomLevel); |
227 virtual void setInitialPageScaleOverride(float); | 223 virtual void setInitialPageScaleOverride(float); |
| 224 virtual bool zoomToMultipleTargetsRect(const WebRect&); |
228 virtual float pageScaleFactor() const; | 225 virtual float pageScaleFactor() const; |
229 virtual void setPageScaleFactorPreservingScrollOffset(float); | 226 virtual void setPageScaleFactorPreservingScrollOffset(float); |
230 virtual void setPageScaleFactor(float scaleFactor, const WebPoint& origin); | 227 virtual void setPageScaleFactor(float scaleFactor, const WebPoint& origin); |
231 virtual void setPageScaleFactorLimits(float minPageScale, float maxPageScale
); | 228 virtual void setPageScaleFactorLimits(float minPageScale, float maxPageScale
); |
232 virtual float minimumPageScaleFactor() const; | 229 virtual float minimumPageScaleFactor() const; |
233 virtual float maximumPageScaleFactor() const; | 230 virtual float maximumPageScaleFactor() const; |
234 virtual void saveScrollAndScaleState(); | 231 virtual void saveScrollAndScaleState(); |
235 virtual void restoreScrollAndScaleState(); | 232 virtual void restoreScrollAndScaleState(); |
236 virtual void resetScrollAndScaleState(); | 233 virtual void resetScrollAndScaleState(); |
237 virtual void setIgnoreViewportTagScaleLimits(bool); | 234 virtual void setIgnoreViewportTagScaleLimits(bool); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 static bool mapKeyCodeForScroll(int keyCode, | 518 static bool mapKeyCodeForScroll(int keyCode, |
522 WebCore::ScrollDirection* scrollDirection, | 519 WebCore::ScrollDirection* scrollDirection, |
523 WebCore::ScrollGranularity* scrollGranularity
); | 520 WebCore::ScrollGranularity* scrollGranularity
); |
524 | 521 |
525 // Called by a full frame plugin inside this view to inform it that its | 522 // Called by a full frame plugin inside this view to inform it that its |
526 // zoom level has been updated. The plugin should only call this function | 523 // zoom level has been updated. The plugin should only call this function |
527 // if the zoom change was triggered by the browser, it's only needed in case | 524 // if the zoom change was triggered by the browser, it's only needed in case |
528 // a plugin can update its own zoom, say because of its own UI. | 525 // a plugin can update its own zoom, say because of its own UI. |
529 void fullFramePluginZoomLevelChanged(double zoomLevel); | 526 void fullFramePluginZoomLevelChanged(double zoomLevel); |
530 | 527 |
531 void computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZoomType, f
loat& scale, WebPoint& scroll, bool& isAnchor); | 528 void computeScaleAndScrollForBlockRect(const WebRect& blockRect, float paddi
ng, float& scale, WebPoint& scroll, bool& doubleTapShouldZoomOut); |
532 WebCore::Node* bestTapNode(const WebCore::PlatformGestureEvent& tapEvent); | 529 WebCore::Node* bestTapNode(const WebCore::PlatformGestureEvent& tapEvent); |
533 void enableTapHighlight(const WebCore::PlatformGestureEvent& tapEvent); | 530 void enableTapHighlight(const WebCore::PlatformGestureEvent& tapEvent); |
534 void computeScaleAndScrollForFocusedNode(WebCore::Node* focusedNode, float&
scale, WebCore::IntPoint& scroll, bool& needAnimation); | 531 void computeScaleAndScrollForFocusedNode(WebCore::Node* focusedNode, float&
scale, WebCore::IntPoint& scroll, bool& needAnimation); |
535 void animateZoomAroundPoint(const WebCore::IntPoint&, AutoZoomType); | |
536 | 532 |
537 void enableFakeDoubleTapAnimationForTesting(bool); | 533 void animateDoubleTapZoom(const WebCore::IntPoint&); |
| 534 |
| 535 void enableFakePageScaleAnimationForTesting(bool); |
538 bool fakeDoubleTapAnimationPendingForTesting() const { return m_doubleTapZoo
mPending; } | 536 bool fakeDoubleTapAnimationPendingForTesting() const { return m_doubleTapZoo
mPending; } |
539 WebCore::IntPoint fakeDoubleTapTargetPositionForTesting() const { return m_f
akeDoubleTapTargetPosition; } | 537 WebCore::IntPoint fakePageScaleAnimationTargetPositionForTesting() const { r
eturn m_fakePageScaleAnimationTargetPosition; } |
540 float fakeDoubleTapPageScaleFactorForTesting() const { return m_fakeDoubleTa
pPageScaleFactor; } | 538 float fakePageScaleAnimationPageScaleForTesting() const { return m_fakePageS
caleAnimationPageScaleFactor; } |
541 bool fakeDoubleTapUseAnchorForTesting() const { return m_fakeDoubleTapUseAnc
hor; } | 539 bool fakePageScaleAnimationUseAnchorForTesting() const { return m_fakePageSc
aleAnimationUseAnchor; } |
542 | 540 |
543 void enterFullScreenForElement(WebCore::Element*); | 541 void enterFullScreenForElement(WebCore::Element*); |
544 void exitFullScreenForElement(WebCore::Element*); | 542 void exitFullScreenForElement(WebCore::Element*); |
545 | 543 |
546 // Exposed for the purpose of overriding device metrics. | 544 // Exposed for the purpose of overriding device metrics. |
547 void sendResizeEventAndRepaint(); | 545 void sendResizeEventAndRepaint(); |
548 | 546 |
549 // Exposed for testing purposes. | 547 // Exposed for testing purposes. |
550 bool hasHorizontalScrollbar(); | 548 bool hasHorizontalScrollbar(); |
551 bool hasVerticalScrollbar(); | 549 bool hasVerticalScrollbar(); |
552 | 550 |
553 // Pointer Lock calls allow a page to capture all mouse events and | 551 // Pointer Lock calls allow a page to capture all mouse events and |
554 // disable the system cursor. | 552 // disable the system cursor. |
555 virtual bool requestPointerLock(); | 553 virtual bool requestPointerLock(); |
556 virtual void requestPointerUnlock(); | 554 virtual void requestPointerUnlock(); |
557 virtual bool isPointerLocked(); | 555 virtual bool isPointerLocked(); |
558 | 556 |
559 // Heuristic-based function for determining if we should disable workarounds | 557 // Heuristic-based function for determining if we should disable workarounds |
560 // for viewing websites that are not optimized for mobile devices. | 558 // for viewing websites that are not optimized for mobile devices. |
561 bool shouldDisableDesktopWorkarounds(); | 559 bool shouldDisableDesktopWorkarounds(); |
562 | 560 |
563 // Exposed for tests. | 561 // Exposed for tests. |
564 LinkHighlight* linkHighlight() { return m_linkHighlight.get(); } | 562 LinkHighlight* linkHighlight() { return m_linkHighlight.get(); } |
565 | 563 |
566 WebSettingsImpl* settingsImpl(); | 564 WebSettingsImpl* settingsImpl(); |
567 | 565 |
| 566 // Returns the bounding box of the block type node touched by the WebRect. |
| 567 WebRect computeBlockBounds(const WebRect&, bool ignoreClipping); |
| 568 |
| 569 WebCore::IntPoint clampOffsetAtScale(const WebCore::IntPoint& offset, float
scale); |
| 570 |
568 private: | 571 private: |
569 void refreshPageScaleFactorAfterLayout(); | 572 void refreshPageScaleFactorAfterLayout(); |
570 void setUserAgentPageScaleConstraints(WebCore::PageScaleConstraints newConst
raints); | 573 void setUserAgentPageScaleConstraints(WebCore::PageScaleConstraints newConst
raints); |
571 float clampPageScaleFactorToLimits(float) const; | 574 float clampPageScaleFactorToLimits(float) const; |
572 WebCore::IntPoint clampOffsetAtScale(const WebCore::IntPoint& offset, float
scale); | |
573 WebCore::IntSize contentsSize() const; | 575 WebCore::IntSize contentsSize() const; |
574 | 576 |
575 void resetSavedScrollAndScaleState(); | 577 void resetSavedScrollAndScaleState(); |
576 | 578 |
577 void updateMainFrameScrollPosition(const WebCore::IntPoint& scrollPosition,
bool programmaticScroll); | 579 void updateMainFrameScrollPosition(const WebCore::IntPoint& scrollPosition,
bool programmaticScroll); |
578 | 580 |
579 friend class WebView; // So WebView::Create can call our constructor | 581 friend class WebView; // So WebView::Create can call our constructor |
580 friend class WTF::RefCounted<WebViewImpl>; | 582 friend class WTF::RefCounted<WebViewImpl>; |
581 friend void setCurrentInputEventForTest(const WebInputEvent*); | 583 friend void setCurrentInputEventForTest(const WebInputEvent*); |
582 | 584 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 int keyModifiers); | 625 int keyModifiers); |
624 | 626 |
625 void configureAutoResizeMode(); | 627 void configureAutoResizeMode(); |
626 | 628 |
627 void setIsAcceleratedCompositingActive(bool); | 629 void setIsAcceleratedCompositingActive(bool); |
628 void doComposite(); | 630 void doComposite(); |
629 void doPixelReadbackToCanvas(WebCanvas*, const WebCore::IntRect&); | 631 void doPixelReadbackToCanvas(WebCanvas*, const WebCore::IntRect&); |
630 void reallocateRenderer(); | 632 void reallocateRenderer(); |
631 void updateLayerTreeViewport(); | 633 void updateLayerTreeViewport(); |
632 | 634 |
633 // Returns the bounding box of the block type node touched by the WebRect. | |
634 WebRect computeBlockBounds(const WebRect&, AutoZoomType); | |
635 | |
636 // Helper function: Widens the width of |source| by the specified margins | 635 // Helper function: Widens the width of |source| by the specified margins |
637 // while keeping it smaller than page width. | 636 // while keeping it smaller than page width. |
638 WebRect widenRectWithinPageBounds(const WebRect& source, int targetMargin, i
nt minimumMargin); | 637 WebRect widenRectWithinPageBounds(const WebRect& source, int targetMargin, i
nt minimumMargin); |
639 | 638 |
640 void pointerLockMouseEvent(const WebInputEvent&); | 639 void pointerLockMouseEvent(const WebInputEvent&); |
641 | 640 |
642 // PageWidgetEventHandler functions | 641 // PageWidgetEventHandler functions |
643 virtual void handleMouseDown(WebCore::Frame&, const WebMouseEvent&) OVERRIDE
; | 642 virtual void handleMouseDown(WebCore::Frame&, const WebMouseEvent&) OVERRIDE
; |
644 virtual void handleMouseUp(WebCore::Frame&, const WebMouseEvent&) OVERRIDE; | 643 virtual void handleMouseUp(WebCore::Frame&, const WebMouseEvent&) OVERRIDE; |
645 virtual bool handleMouseWheel(WebCore::Frame&, const WebMouseWheelEvent&) OV
ERRIDE; | 644 virtual bool handleMouseWheel(WebCore::Frame&, const WebMouseWheelEvent&) OV
ERRIDE; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 WebCore::IntSize m_savedScrollOffset; | 710 WebCore::IntSize m_savedScrollOffset; |
712 float m_exitFullscreenPageScaleFactor; | 711 float m_exitFullscreenPageScaleFactor; |
713 WebCore::IntSize m_exitFullscreenScrollOffset; | 712 WebCore::IntSize m_exitFullscreenScrollOffset; |
714 | 713 |
715 // The scale moved to by the latest double tap zoom, if any. | 714 // The scale moved to by the latest double tap zoom, if any. |
716 float m_doubleTapZoomPageScaleFactor; | 715 float m_doubleTapZoomPageScaleFactor; |
717 // Have we sent a double-tap zoom and not yet heard back the scale? | 716 // Have we sent a double-tap zoom and not yet heard back the scale? |
718 bool m_doubleTapZoomPending; | 717 bool m_doubleTapZoomPending; |
719 | 718 |
720 // Used for testing purposes. | 719 // Used for testing purposes. |
721 bool m_enableFakeDoubleTapAnimationForTesting; | 720 bool m_enableFakePageScaleAnimationForTesting; |
722 WebCore::IntPoint m_fakeDoubleTapTargetPosition; | 721 WebCore::IntPoint m_fakePageScaleAnimationTargetPosition; |
723 float m_fakeDoubleTapPageScaleFactor; | 722 float m_fakePageScaleAnimationPageScaleFactor; |
724 bool m_fakeDoubleTapUseAnchor; | 723 bool m_fakePageScaleAnimationUseAnchor; |
725 | 724 |
726 bool m_contextMenuAllowed; | 725 bool m_contextMenuAllowed; |
727 | 726 |
728 bool m_doingDragAndDrop; | 727 bool m_doingDragAndDrop; |
729 | 728 |
730 bool m_ignoreInputEvents; | 729 bool m_ignoreInputEvents; |
731 | 730 |
732 // Webkit expects keyPress events to be suppressed if the associated keyDown | 731 // Webkit expects keyPress events to be suppressed if the associated keyDown |
733 // event was handled. Safari implements this behavior by peeking out the | 732 // event was handled. Safari implements this behavior by peeking out the |
734 // associated WM_CHAR event if the keydown was handled. We emulate | 733 // associated WM_CHAR event if the keydown was handled. We emulate |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 bool m_showPaintRects; | 835 bool m_showPaintRects; |
837 bool m_showDebugBorders; | 836 bool m_showDebugBorders; |
838 bool m_continuousPaintingEnabled; | 837 bool m_continuousPaintingEnabled; |
839 bool m_showScrollBottleneckRects; | 838 bool m_showScrollBottleneckRects; |
840 WebColor m_baseBackgroundColor; | 839 WebColor m_baseBackgroundColor; |
841 }; | 840 }; |
842 | 841 |
843 } // namespace WebKit | 842 } // namespace WebKit |
844 | 843 |
845 #endif | 844 #endif |
OLD | NEW |