Chromium Code Reviews| Index: content/renderer/render_view_impl.cc |
| =================================================================== |
| --- content/renderer/render_view_impl.cc (revision 107314) |
| +++ content/renderer/render_view_impl.cc (working copy) |
| @@ -273,6 +273,8 @@ |
| static const float kScalingIncrement = 0.1f; |
| +static const float kScalingIncrementForGesture = 0.01f; |
| + |
| static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { |
| WebVector<WebURL> urls; |
| ds->redirectChain(urls); |
| @@ -595,6 +597,7 @@ |
| IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) |
| IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
| IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) |
| + IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) |
| IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
| OnSetZoomLevelForLoadingURL) |
| IPC_MESSAGE_HANDLER(ViewMsg_ExitFullscreen, OnExitFullscreen) |
| @@ -3552,18 +3555,38 @@ |
| } |
| } |
| webview()->setZoomLevel(false, zoom_level); |
| + zoomLevelChanged(); |
| #else |
| + ZoomFactorHelper(function, 0, 0, kScalingIncrement); |
| +#endif |
| +} |
|
cpu_(ooo_6.6-7.5)
2011/10/28 02:30:03
is it ok to put zoomLevelChanged() in line 3561 an
ananta
2011/10/28 18:42:03
We need to call zoomLevelChanged in the OnZoomFact
|
| + |
| +void RenderViewImpl::OnZoomFactor(PageZoom::Function function, |
| + int zoom_center_x, int zoom_center_y) { |
| + ZoomFactorHelper(function, zoom_center_x, zoom_center_y, |
| + kScalingIncrementForGesture); |
| +} |
| + |
| +void RenderViewImpl::ZoomFactorHelper(PageZoom::Function function, |
| + int zoom_center_x, |
| + int zoom_center_y, |
| + float scaling_increment) { |
| + if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| + return; |
| + |
| double old_page_scale_factor = webview()->pageScaleFactor(); |
| double page_scale_factor; |
| if (function == PageZoom::RESET) { |
| page_scale_factor = 1.0; |
| } else { |
| page_scale_factor = old_page_scale_factor + |
| - (function > 0 ? kScalingIncrement : -kScalingIncrement); |
| + (function > 0 ? scaling_increment : -scaling_increment); |
| } |
| - webview()->scalePage(page_scale_factor, WebPoint(0, 0)); |
| -#endif |
| - zoomLevelChanged(); |
| + if (page_scale_factor > 0) { |
| + webview()->scalePage(page_scale_factor, |
| + WebPoint(zoom_center_x, zoom_center_y)); |
| + zoomLevelChanged(); |
| + } |
| } |
| void RenderViewImpl::OnSetZoomLevel(double zoom_level) { |