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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 8399009: Add support for touch based zoom gesture on Windows. This change also handles the WM_POINTERDOWN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 static const int kDelaySecondsForContentStateSyncHidden = 5; 265 static const int kDelaySecondsForContentStateSyncHidden = 5;
266 static const int kDelaySecondsForContentStateSync = 1; 266 static const int kDelaySecondsForContentStateSync = 1;
267 267
268 static const size_t kExtraCharsBeforeAndAfterSelection = 100; 268 static const size_t kExtraCharsBeforeAndAfterSelection = 100;
269 269
270 // The maximum number of popups that can be spawned from one page. 270 // The maximum number of popups that can be spawned from one page.
271 static const int kMaximumNumberOfUnacknowledgedPopups = 25; 271 static const int kMaximumNumberOfUnacknowledgedPopups = 25;
272 272
273 static const float kScalingIncrement = 0.1f; 273 static const float kScalingIncrement = 0.1f;
274 274
275 static const float kScalingIncrementForGesture = 0.01f;
276
275 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { 277 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) {
276 WebVector<WebURL> urls; 278 WebVector<WebURL> urls;
277 ds->redirectChain(urls); 279 ds->redirectChain(urls);
278 result->reserve(urls.size()); 280 result->reserve(urls.size());
279 for (size_t i = 0; i < urls.size(); ++i) 281 for (size_t i = 0; i < urls.size(); ++i)
280 result->push_back(urls[i]); 282 result->push_back(urls[i]);
281 } 283 }
282 284
283 // If |data_source| is non-null and has a NavigationState associated with it, 285 // If |data_source| is non-null and has a NavigationState associated with it,
284 // the AltErrorPageResourceFetcher is reset. 286 // the AltErrorPageResourceFetcher is reset.
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) 594 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete)
593 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) 595 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll)
594 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) 596 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange)
595 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) 597 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
596 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) 598 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand)
597 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) 599 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
598 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) 600 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding)
599 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) 601 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck)
600 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) 602 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
601 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) 603 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel)
604 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor)
602 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, 605 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL,
603 OnSetZoomLevelForLoadingURL) 606 OnSetZoomLevelForLoadingURL)
604 IPC_MESSAGE_HANDLER(ViewMsg_ExitFullscreen, OnExitFullscreen) 607 IPC_MESSAGE_HANDLER(ViewMsg_ExitFullscreen, OnExitFullscreen)
605 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) 608 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
606 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, 609 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault,
607 OnResetPageEncodingToDefault) 610 OnResetPageEncodingToDefault)
608 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) 611 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest)
609 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) 612 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest)
610 IPC_MESSAGE_HANDLER(ViewMsg_ReservePageIDRange, OnReservePageIDRange) 613 IPC_MESSAGE_HANDLER(ViewMsg_ReservePageIDRange, OnReservePageIDRange)
611 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) 614 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
(...skipping 2938 matching lines...) Expand 10 before | Expand all | Expand 10 after
3550 if ((old_zoom_level > 1 && zoom > 0) || 3553 if ((old_zoom_level > 1 && zoom > 0) ||
3551 (old_zoom_level < 1 && zoom < 0)) { 3554 (old_zoom_level < 1 && zoom < 0)) {
3552 zoom_level = static_cast<int>(old_zoom_level + zoom); 3555 zoom_level = static_cast<int>(old_zoom_level + zoom);
3553 } else { 3556 } else {
3554 // We're going towards 100%, so first go to the next whole number. 3557 // We're going towards 100%, so first go to the next whole number.
3555 zoom_level = static_cast<int>(old_zoom_level); 3558 zoom_level = static_cast<int>(old_zoom_level);
3556 } 3559 }
3557 } 3560 }
3558 webview()->setZoomLevel(false, zoom_level); 3561 webview()->setZoomLevel(false, zoom_level);
3559 #else 3562 #else
3563 ZoomFactorHelper(function, 0, 0, kScalingIncrement);
3564 #endif
3565 zoomLevelChanged();
3566 }
3567
3568 void RenderViewImpl::OnZoomFactor(content::PageZoom zoom,
3569 int zoom_center_x, int zoom_center_y) {
3570 ZoomFactorHelper(zoom, zoom_center_x, zoom_center_y,
3571 kScalingIncrementForGesture);
3572 }
3573
3574 void RenderViewImpl::ZoomFactorHelper(content::PageZoom zoom,
3575 int zoom_center_x,
3576 int zoom_center_y,
3577 float scaling_increment) {
3578 if (!webview()) // Not sure if this can happen, but no harm in being safe.
3579 return;
3580
3560 double old_page_scale_factor = webview()->pageScaleFactor(); 3581 double old_page_scale_factor = webview()->pageScaleFactor();
3561 double page_scale_factor; 3582 double page_scale_factor;
3562 if (zoom == content::PAGE_ZOOM_RESET) { 3583 if (zoom == content::PAGE_ZOOM_RESET) {
3563 page_scale_factor = 1.0; 3584 page_scale_factor = 1.0;
3564 } else { 3585 } else {
3565 page_scale_factor = old_page_scale_factor + 3586 page_scale_factor = old_page_scale_factor +
3566 (zoom > 0 ? kScalingIncrement : -kScalingIncrement); 3587 (zoom > 0 ? scaling_increment : -scaling_increment);
3567 } 3588 }
3568 webview()->scalePage(page_scale_factor, WebPoint(0, 0)); 3589 if (page_scale_factor > 0) {
3569 #endif 3590 webview()->scalePage(page_scale_factor,
3570 zoomLevelChanged(); 3591 WebPoint(zoom_center_x, zoom_center_y));
3592 }
3571 } 3593 }
3572 3594
3573 void RenderViewImpl::OnSetZoomLevel(double zoom_level) { 3595 void RenderViewImpl::OnSetZoomLevel(double zoom_level) {
3574 // Don't set zoom level for full-page plugin since they don't use the same 3596 // Don't set zoom level for full-page plugin since they don't use the same
3575 // zoom settings. 3597 // zoom settings.
3576 if (webview()->mainFrame()->document().isPluginDocument()) 3598 if (webview()->mainFrame()->document().isPluginDocument())
3577 return; 3599 return;
3578 3600
3579 webview()->hidePopups(); 3601 webview()->hidePopups();
3580 webview()->setZoomLevel(false, zoom_level); 3602 webview()->setZoomLevel(false, zoom_level);
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
4674 return webview()->settings()->useThreadedCompositor(); 4696 return webview()->settings()->useThreadedCompositor();
4675 } 4697 }
4676 4698
4677 void RenderViewImpl::OnJavaBridgeInit( 4699 void RenderViewImpl::OnJavaBridgeInit(
4678 const IPC::ChannelHandle& channel_handle) { 4700 const IPC::ChannelHandle& channel_handle) {
4679 DCHECK(!java_bridge_dispatcher_.get()); 4701 DCHECK(!java_bridge_dispatcher_.get());
4680 #if defined(ENABLE_JAVA_BRIDGE) 4702 #if defined(ENABLE_JAVA_BRIDGE)
4681 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); 4703 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle));
4682 #endif 4704 #endif
4683 } 4705 }
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698