Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(779)

Side by Side Diff: Source/WebKit/chromium/src/WebViewImpl.cpp

Issue 12330082: Merge 143355 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1410/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/WebKit/chromium/src/WebViewImpl.h ('k') | Source/WebKit/chromium/tests/WebFrameTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier)) 393 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier))
394 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) 394 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier))
395 , m_pageDefinedMinimumPageScaleFactor(-1) 395 , m_pageDefinedMinimumPageScaleFactor(-1)
396 , m_pageDefinedMaximumPageScaleFactor(-1) 396 , m_pageDefinedMaximumPageScaleFactor(-1)
397 , m_minimumPageScaleFactor(minPageScaleFactor) 397 , m_minimumPageScaleFactor(minPageScaleFactor)
398 , m_maximumPageScaleFactor(maxPageScaleFactor) 398 , m_maximumPageScaleFactor(maxPageScaleFactor)
399 , m_initialPageScaleFactor(-1) 399 , m_initialPageScaleFactor(-1)
400 , m_ignoreViewportTagMaximumScale(false) 400 , m_ignoreViewportTagMaximumScale(false)
401 , m_pageScaleFactorIsSet(false) 401 , m_pageScaleFactorIsSet(false)
402 , m_savedPageScaleFactor(0) 402 , m_savedPageScaleFactor(0)
403 , m_doubleTapZoomInEffect(false) 403 , m_doubleTapZoomPageScaleFactor(0)
404 , m_shouldUseDoubleTapTimeZero(false) 404 , m_doubleTapZoomPending(false)
405 , m_enableFakeDoubleTapAnimationForTesting(false)
406 , m_fakeDoubleTapPageScaleFactor(0)
407 , m_fakeDoubleTapUseAnchor(false)
405 , m_contextMenuAllowed(false) 408 , m_contextMenuAllowed(false)
406 , m_doingDragAndDrop(false) 409 , m_doingDragAndDrop(false)
407 , m_ignoreInputEvents(false) 410 , m_ignoreInputEvents(false)
408 , m_suppressNextKeypressEvent(false) 411 , m_suppressNextKeypressEvent(false)
409 , m_initialNavigationPolicy(WebNavigationPolicyIgnore) 412 , m_initialNavigationPolicy(WebNavigationPolicyIgnore)
410 , m_imeAcceptEvents(true) 413 , m_imeAcceptEvents(true)
411 , m_operationsAllowed(WebDragOperationNone) 414 , m_operationsAllowed(WebDragOperationNone)
412 , m_dragOperation(WebDragOperationNone) 415 , m_dragOperation(WebDragOperationNone)
413 , m_featureSwitchClient(adoptPtr(new ContextFeaturesClientImpl())) 416 , m_featureSwitchClient(adoptPtr(new ContextFeaturesClientImpl()))
414 , m_autofillPopupShowing(false) 417 , m_autofillPopupShowing(false)
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 TRACE_EVENT0("webkit", "WebViewImpl::transferActiveWheelFlingAnimation"); 853 TRACE_EVENT0("webkit", "WebViewImpl::transferActiveWheelFlingAnimation");
851 ASSERT(!m_gestureAnimation); 854 ASSERT(!m_gestureAnimation);
852 m_positionOnFlingStart = parameters.point; 855 m_positionOnFlingStart = parameters.point;
853 m_globalPositionOnFlingStart = parameters.globalPoint; 856 m_globalPositionOnFlingStart = parameters.globalPoint;
854 m_flingModifier = parameters.modifiers; 857 m_flingModifier = parameters.modifiers;
855 OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAni mationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters .cumulativeScroll)); 858 OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAni mationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters .cumulativeScroll));
856 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.r elease(), this, parameters.startTime); 859 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.r elease(), this, parameters.startTime);
857 scheduleAnimation(); 860 scheduleAnimation();
858 } 861 }
859 862
860 void WebViewImpl::startPageScaleAnimation(const IntPoint& targetPosition, bool u seAnchor, float newScale, double durationInSeconds) 863 bool WebViewImpl::startPageScaleAnimation(const IntPoint& targetPosition, bool u seAnchor, float newScale, double durationInSeconds)
861 { 864 {
862 WebPoint clampedPoint = targetPosition; 865 WebPoint clampedPoint = targetPosition;
863 if (!useAnchor) 866 if (!useAnchor) {
864 clampedPoint = clampOffsetAtScale(targetPosition, newScale); 867 clampedPoint = clampOffsetAtScale(targetPosition, newScale);
865 if ((!durationInSeconds && !useAnchor) || m_shouldUseDoubleTapTimeZero) { 868 if (!durationInSeconds) {
866 setPageScaleFactor(newScale, clampedPoint); 869 setPageScaleFactor(newScale, clampedPoint);
867 return; 870 return false;
871 }
868 } 872 }
869 if (!m_layerTreeView) 873 if (useAnchor && newScale == pageScaleFactor())
870 return; 874 return false;
871 875
872 m_layerTreeView->startPageScaleAnimation(targetPosition, useAnchor, newScale , durationInSeconds); 876 if (m_enableFakeDoubleTapAnimationForTesting) {
877 m_fakeDoubleTapTargetPosition = targetPosition;
878 m_fakeDoubleTapUseAnchor = useAnchor;
879 m_fakeDoubleTapPageScaleFactor = newScale;
880 } else {
881 if (!m_layerTreeView)
882 return false;
883 m_layerTreeView->startPageScaleAnimation(targetPosition, useAnchor, newS cale, durationInSeconds);
884 }
885 return true;
886 }
887
888 void WebViewImpl::enableFakeDoubleTapAnimationForTesting(bool enable)
889 {
890 m_enableFakeDoubleTapAnimationForTesting = enable;
873 } 891 }
874 #endif 892 #endif
875 893
876 WebViewBenchmarkSupport* WebViewImpl::benchmarkSupport() 894 WebViewBenchmarkSupport* WebViewImpl::benchmarkSupport()
877 { 895 {
878 return &m_benchmarkSupport; 896 return &m_benchmarkSupport;
879 } 897 }
880 898
881 void WebViewImpl::setShowFPSCounter(bool show) 899 void WebViewImpl::setShowFPSCounter(bool show)
882 { 900 {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 1165
1148 const int newWidth = source.width + leftMargin + rightMargin; 1166 const int newWidth = source.width + leftMargin + rightMargin;
1149 const int newX = source.x - leftMargin; 1167 const int newX = source.x - leftMargin;
1150 1168
1151 ASSERT(newWidth >= 0); 1169 ASSERT(newWidth >= 0);
1152 ASSERT(scrollOffset.width() + newX + newWidth <= maxSize.width); 1170 ASSERT(scrollOffset.width() + newX + newWidth <= maxSize.width);
1153 1171
1154 return WebRect(newX, source.y, newWidth, source.height); 1172 return WebRect(newX, source.y, newWidth, source.height);
1155 } 1173 }
1156 1174
1157 void WebViewImpl::shouldUseAnimateDoubleTapTimeZeroForTesting(bool setToZero)
1158 {
1159 m_shouldUseDoubleTapTimeZero = setToZero;
1160 }
1161
1162 void WebViewImpl::computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZo omType zoomType, float& scale, WebPoint& scroll, bool& isAnchor) 1175 void WebViewImpl::computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZo omType zoomType, float& scale, WebPoint& scroll, bool& isAnchor)
1163 { 1176 {
1164 scale = pageScaleFactor(); 1177 scale = pageScaleFactor();
1165 scroll.x = scroll.y = 0; 1178 scroll.x = scroll.y = 0;
1166 WebRect targetRect = hitRect; 1179 WebRect targetRect = hitRect;
1167 // Padding only depends on page scale when triggered by manually tapping 1180 // Padding only depends on page scale when triggered by manually tapping
1168 int padding = (zoomType == DoubleTap) ? touchPointPadding : nonUserInitiated PointPadding; 1181 int padding = (zoomType == DoubleTap) ? touchPointPadding : nonUserInitiated PointPadding;
1169 if (targetRect.isEmpty()) 1182 if (targetRect.isEmpty())
1170 targetRect.width = targetRect.height = padding; 1183 targetRect.width = targetRect.height = padding;
1171 WebRect rect = computeBlockBounds(targetRect, zoomType); 1184 WebRect rect = computeBlockBounds(targetRect, zoomType);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 if (settingsImpl()->applyPageScaleFactorInCompositor()) 1222 if (settingsImpl()->applyPageScaleFactorInCompositor())
1210 scale = static_cast<float>(m_size.width) / rect.width; 1223 scale = static_cast<float>(m_size.width) / rect.width;
1211 else 1224 else
1212 scale *= static_cast<float>(m_size.width) / rect.width; 1225 scale *= static_cast<float>(m_size.width) / rect.width;
1213 scale = min(scale, legibleScale); 1226 scale = min(scale, legibleScale);
1214 scale = clampPageScaleFactorToLimits(scale); 1227 scale = clampPageScaleFactorToLimits(scale);
1215 1228
1216 scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference; 1229 scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference;
1217 } 1230 }
1218 1231
1219 if (zoomType == DoubleTap && (rect.isEmpty() || scaleUnchanged || m_doubleTa pZoomInEffect)) { 1232 bool stillAtPreviousDoubleTapScale = (pageScaleFactor() == m_doubleTapZoomPa geScaleFactor
1233 && m_doubleTapZoomPageScaleFactor != m_minimumPageScaleFactor)
1234 || m_doubleTapZoomPending;
1235 if (zoomType == DoubleTap && (rect.isEmpty() || scaleUnchanged || stillAtPre viousDoubleTapScale)) {
1220 // Zoom out to minimum scale. 1236 // Zoom out to minimum scale.
1221 scale = m_minimumPageScaleFactor; 1237 scale = m_minimumPageScaleFactor;
1222 scroll = WebPoint(hitRect.x, hitRect.y); 1238 scroll = WebPoint(hitRect.x, hitRect.y);
1223 isAnchor = true; 1239 isAnchor = true;
1224 m_doubleTapZoomInEffect = false;
1225 } else { 1240 } else {
1226 if (zoomType == DoubleTap && scale != m_minimumPageScaleFactor)
1227 m_doubleTapZoomInEffect = true;
1228 else
1229 m_doubleTapZoomInEffect = false;
1230 // FIXME: If this is being called for auto zoom during find in page, 1241 // FIXME: If this is being called for auto zoom during find in page,
1231 // then if the user manually zooms in it'd be nice to preserve the 1242 // then if the user manually zooms in it'd be nice to preserve the
1232 // relative increase in zoom they caused (if they zoom out then it's ok 1243 // relative increase in zoom they caused (if they zoom out then it's ok
1233 // to zoom them back in again). This isn't compatible with our current 1244 // to zoom them back in again). This isn't compatible with our current
1234 // double-tap zoom strategy (fitting the containing block to the screen) 1245 // double-tap zoom strategy (fitting the containing block to the screen)
1235 // though. 1246 // though.
1236 1247
1237 float screenHeight = m_size.height / scale; 1248 float screenHeight = m_size.height / scale;
1238 float screenWidth = m_size.width / scale; 1249 float screenWidth = m_size.width / scale;
1239 if (!settingsImpl()->applyPageScaleFactorInCompositor()) { 1250 if (!settingsImpl()->applyPageScaleFactorInCompositor()) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 if (!mainFrameImpl()) 1349 if (!mainFrameImpl())
1339 return; 1350 return;
1340 1351
1341 float scale; 1352 float scale;
1342 WebPoint scroll; 1353 WebPoint scroll;
1343 bool isAnchor; 1354 bool isAnchor;
1344 WebPoint webPoint = point; 1355 WebPoint webPoint = point;
1345 computeScaleAndScrollForHitRect(WebRect(webPoint.x, webPoint.y, 0, 0), zoomT ype, scale, scroll, isAnchor); 1356 computeScaleAndScrollForHitRect(WebRect(webPoint.x, webPoint.y, 0, 0), zoomT ype, scale, scroll, isAnchor);
1346 1357
1347 bool isDoubleTap = (zoomType == DoubleTap); 1358 bool isDoubleTap = (zoomType == DoubleTap);
1348 double durationInSeconds = (isDoubleTap && !m_shouldUseDoubleTapTimeZero) ? doubleTapZoomAnimationDurationInSeconds : 0; 1359 double durationInSeconds = isDoubleTap ? doubleTapZoomAnimationDurationInSec onds : 0;
1349 startPageScaleAnimation(scroll, isAnchor, scale, durationInSeconds); 1360 bool isAnimating = startPageScaleAnimation(scroll, isAnchor, scale, duration InSeconds);
1361
1362 if (isDoubleTap && isAnimating) {
1363 m_doubleTapZoomPageScaleFactor = scale;
1364 m_doubleTapZoomPending = true;
1365 }
1350 #endif 1366 #endif
1351 } 1367 }
1352 1368
1353 void WebViewImpl::zoomToFindInPageRect(const WebRect& rect) 1369 void WebViewImpl::zoomToFindInPageRect(const WebRect& rect)
1354 { 1370 {
1355 animateZoomAroundPoint(IntRect(rect).center(), FindInPage); 1371 animateZoomAroundPoint(IntRect(rect).center(), FindInPage);
1356 } 1372 }
1357 1373
1358 void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandle rs) 1374 void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandle rs)
1359 { 1375 {
(...skipping 2399 matching lines...) Expand 10 before | Expand all | Expand 10 after
3759 { 3775 {
3760 if (isNewNavigation) 3776 if (isNewNavigation)
3761 *isNewNavigation = m_observedNewNavigation; 3777 *isNewNavigation = m_observedNewNavigation;
3762 3778
3763 #ifndef NDEBUG 3779 #ifndef NDEBUG
3764 ASSERT(!m_observedNewNavigation 3780 ASSERT(!m_observedNewNavigation
3765 || m_page->mainFrame()->loader()->documentLoader() == m_newNavigationLoa der); 3781 || m_page->mainFrame()->loader()->documentLoader() == m_newNavigationLoa der);
3766 m_newNavigationLoader = 0; 3782 m_newNavigationLoader = 0;
3767 #endif 3783 #endif
3768 m_observedNewNavigation = false; 3784 m_observedNewNavigation = false;
3769 if (*isNewNavigation && !isNavigationWithinPage) { 3785 if (*isNewNavigation && !isNavigationWithinPage)
3770 m_pageScaleFactorIsSet = false; 3786 m_pageScaleFactorIsSet = false;
3771 m_doubleTapZoomInEffect = false;
3772 }
3773 3787
3774 // Make sure link highlight from previous page is cleared. 3788 // Make sure link highlight from previous page is cleared.
3775 m_linkHighlight.clear(); 3789 m_linkHighlight.clear();
3776 m_gestureAnimation.clear(); 3790 m_gestureAnimation.clear();
3777 if (m_layerTreeView) 3791 if (m_layerTreeView)
3778 m_layerTreeView->didStopFlinging(); 3792 m_layerTreeView->didStopFlinging();
3779 resetSavedScrollAndScaleState(); 3793 resetSavedScrollAndScaleState();
3780 } 3794 }
3781 3795
3782 void WebViewImpl::layoutUpdated(WebFrameImpl* webframe) 3796 void WebViewImpl::layoutUpdated(WebFrameImpl* webframe)
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
4209 WebPoint scrollPoint(scrollOffset.width, scrollOffset.height); 4223 WebPoint scrollPoint(scrollOffset.width, scrollOffset.height);
4210 if (!m_page->settings()->applyPageScaleFactorInCompositor()) { 4224 if (!m_page->settings()->applyPageScaleFactorInCompositor()) {
4211 // The old scroll offset (and passed-in delta) are in the old 4225 // The old scroll offset (and passed-in delta) are in the old
4212 // coordinate space, so we first need to multiply them by the page 4226 // coordinate space, so we first need to multiply them by the page
4213 // scale delta. 4227 // scale delta.
4214 scrollPoint.x = scrollPoint.x * pageScaleDelta; 4228 scrollPoint.x = scrollPoint.x * pageScaleDelta;
4215 scrollPoint.y = scrollPoint.y * pageScaleDelta; 4229 scrollPoint.y = scrollPoint.y * pageScaleDelta;
4216 } 4230 }
4217 4231
4218 setPageScaleFactor(pageScaleFactor() * pageScaleDelta, scrollPoint); 4232 setPageScaleFactor(pageScaleFactor() * pageScaleDelta, scrollPoint);
4219 m_doubleTapZoomInEffect = false; 4233 m_doubleTapZoomPending = false;
4220 } 4234 }
4221 } 4235 }
4222 4236
4223 void WebViewImpl::willCommit() 4237 void WebViewImpl::willCommit()
4224 { 4238 {
4225 InspectorInstrumentation::willComposite(m_page.get()); 4239 InspectorInstrumentation::willComposite(m_page.get());
4226 } 4240 }
4227 4241
4228 void WebViewImpl::didCommit() 4242 void WebViewImpl::didCommit()
4229 { 4243 {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
4403 #endif 4417 #endif
4404 4418
4405 bool WebViewImpl::shouldDisableDesktopWorkarounds() 4419 bool WebViewImpl::shouldDisableDesktopWorkarounds()
4406 { 4420 {
4407 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); 4421 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments();
4408 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom 4422 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom
4409 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); 4423 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto);
4410 } 4424 }
4411 4425
4412 } // namespace WebKit 4426 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/WebViewImpl.h ('k') | Source/WebKit/chromium/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698