summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/src/WebViewImpl.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-07-30 11:37:48 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-07-30 11:38:52 +0200
commit89e2486a48b739f8d771d69ede5a6a1b244a10fc (patch)
tree503b1a7812cf97d93704c32437eb5f62dc1a1ff9 /Source/WebKit/chromium/src/WebViewImpl.cpp
parent625f028249cb37c55bbbd153f3902afd0b0756d9 (diff)
downloadqtwebkit-89e2486a48b739f8d771d69ede5a6a1b244a10fc.tar.gz
Imported WebKit commit 0282df8ca7c11d8c8a66ea18543695c69f545a27 (http://svn.webkit.org/repository/webkit/trunk@124002)
New snapshot with prospective Mountain Lion build fix
Diffstat (limited to 'Source/WebKit/chromium/src/WebViewImpl.cpp')
-rw-r--r--Source/WebKit/chromium/src/WebViewImpl.cpp56
1 files changed, 52 insertions, 4 deletions
diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp
index 6a253f8e3..7c6da60d9 100644
--- a/Source/WebKit/chromium/src/WebViewImpl.cpp
+++ b/Source/WebKit/chromium/src/WebViewImpl.cpp
@@ -197,6 +197,8 @@ static const float doubleTapZoomContentDefaultMargin = 5;
static const float doubleTapZoomContentMinimumMargin = 2;
static const double doubleTabZoomAnimationDurationInSeconds = 0.25;
+// Constants for zooming in on a focused text field.
+static const double scrollAndScaleAnimationDurationInSeconds = 0.2;
namespace WebKit {
@@ -392,6 +394,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
, m_maximumPageScaleFactor(maxPageScaleFactor)
, m_ignoreViewportTagMaximumScale(false)
, m_pageScaleFactorIsSet(false)
+ , m_savedPageScaleFactor(0)
, m_contextMenuAllowed(false)
, m_doingDragAndDrop(false)
, m_ignoreInputEvents(false)
@@ -522,14 +525,23 @@ void WebViewImpl::handleMouseLeave(Frame& mainFrame, const WebMouseEvent& event)
void WebViewImpl::handleMouseDown(Frame& mainFrame, const WebMouseEvent& event)
{
- // If there is a select popup open, close it as the user is clicking on
- // the page (outside of the popup). We also save it so we can prevent a
- // click on the select element from immediately reopening the popup.
+ // If there is a popup open, close it as the user is clicking on the page (outside of the
+ // popup). We also save it so we can prevent a click on an element from immediately
+ // reopening the same popup.
RefPtr<WebCore::PopupContainer> selectPopup;
+#if ENABLE(PAGE_POPUP)
+ RefPtr<WebPagePopupImpl> pagePopup;
+#endif
if (event.button == WebMouseEvent::ButtonLeft) {
selectPopup = m_selectPopup;
- hideSelectPopup();
+#if ENABLE(PAGE_POPUP)
+ pagePopup = m_pagePopup;
+#endif
+ hidePopups();
ASSERT(!m_selectPopup);
+#if ENABLE(PAGE_POPUP)
+ ASSERT(!m_pagePopup);
+#endif
}
m_lastMouseDownPoint = WebPoint(event.x, event.y);
@@ -555,6 +567,14 @@ void WebViewImpl::handleMouseDown(Frame& mainFrame, const WebMouseEvent& event)
hideSelectPopup();
}
+#if ENABLE(PAGE_POPUP)
+ if (m_pagePopup && pagePopup && m_pagePopup->hasSamePopupClient(pagePopup.get())) {
+ // That click triggered a page popup that is the same as the one we just closed.
+ // It needs to be closed.
+ closePagePopup(m_pagePopup.get());
+ }
+#endif
+
// Dispatch the contextmenu event regardless of if the click was swallowed.
// On Windows, we handle it on mouse up, not down.
#if OS(DARWIN)
@@ -2713,6 +2733,33 @@ float WebViewImpl::maximumPageScaleFactor() const
return m_maximumPageScaleFactor;
}
+void WebViewImpl::saveScrollAndScaleState()
+{
+ m_savedPageScaleFactor = pageScaleFactor();
+ m_savedScrollOffset = mainFrame()->scrollOffset();
+}
+
+void WebViewImpl::restoreScrollAndScaleState()
+{
+ if (!m_savedPageScaleFactor)
+ return;
+
+#if ENABLE(GESTURE_EVENTS)
+ startPageScaleAnimation(IntPoint(m_savedScrollOffset), false, m_savedPageScaleFactor, scrollAndScaleAnimationDurationInSeconds);
+#else
+ setPageScaleFactor(m_savedPageScaleFactor, WebPoint());
+ mainFrame()->setScrollOffset(m_savedScrollOffset);
+#endif
+
+ resetSavedScrollAndScaleState();
+}
+
+void WebViewImpl::resetSavedScrollAndScaleState()
+{
+ m_savedPageScaleFactor = 0;
+ m_savedScrollOffset = IntSize();
+}
+
WebSize WebViewImpl::fixedLayoutSize() const
{
if (!page())
@@ -3246,6 +3293,7 @@ void WebViewImpl::didCommitLoad(bool* isNewNavigation, bool isNavigationWithinPa
m_pageScaleFactorIsSet = false;
m_gestureAnimation.clear();
+ resetSavedScrollAndScaleState();
}
void WebViewImpl::layoutUpdated(WebFrameImpl* webframe)