Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 static const int kDelaySecondsForContentStateSyncHidden = 5; | 266 static const int kDelaySecondsForContentStateSyncHidden = 5; |
| 267 static const int kDelaySecondsForContentStateSync = 1; | 267 static const int kDelaySecondsForContentStateSync = 1; |
| 268 | 268 |
| 269 static const size_t kExtraCharsBeforeAndAfterSelection = 100; | 269 static const size_t kExtraCharsBeforeAndAfterSelection = 100; |
| 270 | 270 |
| 271 // The maximum number of popups that can be spawned from one page. | 271 // The maximum number of popups that can be spawned from one page. |
| 272 static const int kMaximumNumberOfUnacknowledgedPopups = 25; | 272 static const int kMaximumNumberOfUnacknowledgedPopups = 25; |
| 273 | 273 |
| 274 static const float kScalingIncrement = 0.1f; | 274 static const float kScalingIncrement = 0.1f; |
| 275 | 275 |
| 276 static const float kScalingIncrementForGesture = 0.01f; | |
| 277 | |
| 276 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { | 278 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { |
| 277 WebVector<WebURL> urls; | 279 WebVector<WebURL> urls; |
| 278 ds->redirectChain(urls); | 280 ds->redirectChain(urls); |
| 279 result->reserve(urls.size()); | 281 result->reserve(urls.size()); |
| 280 for (size_t i = 0; i < urls.size(); ++i) | 282 for (size_t i = 0; i < urls.size(); ++i) |
| 281 result->push_back(urls[i]); | 283 result->push_back(urls[i]); |
| 282 } | 284 } |
| 283 | 285 |
| 284 // If |data_source| is non-null and has a NavigationState associated with it, | 286 // If |data_source| is non-null and has a NavigationState associated with it, |
| 285 // the AltErrorPageResourceFetcher is reset. | 287 // the AltErrorPageResourceFetcher is reset. |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) | 590 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) |
| 589 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) | 591 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) |
| 590 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) | 592 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) |
| 591 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) | 593 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
| 592 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) | 594 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) |
| 593 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) | 595 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
| 594 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) | 596 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
| 595 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) | 597 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) |
| 596 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 598 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
| 597 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) | 599 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) |
| 600 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) | |
| 598 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, | 601 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
| 599 OnSetZoomLevelForLoadingURL) | 602 OnSetZoomLevelForLoadingURL) |
| 600 IPC_MESSAGE_HANDLER(ViewMsg_ExitFullscreen, OnExitFullscreen) | 603 IPC_MESSAGE_HANDLER(ViewMsg_ExitFullscreen, OnExitFullscreen) |
| 601 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) | 604 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) |
| 602 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, | 605 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, |
| 603 OnResetPageEncodingToDefault) | 606 OnResetPageEncodingToDefault) |
| 604 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) | 607 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) |
| 605 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) | 608 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) |
| 606 IPC_MESSAGE_HANDLER(ViewMsg_ReservePageIDRange, OnReservePageIDRange) | 609 IPC_MESSAGE_HANDLER(ViewMsg_ReservePageIDRange, OnReservePageIDRange) |
| 607 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) | 610 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
| (...skipping 2937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3545 // 100% with the keyboard/menu. | 3548 // 100% with the keyboard/menu. |
| 3546 if ((old_zoom_level > 1 && function > 0) || | 3549 if ((old_zoom_level > 1 && function > 0) || |
| 3547 (old_zoom_level < 1 && function < 0)) { | 3550 (old_zoom_level < 1 && function < 0)) { |
| 3548 zoom_level = static_cast<int>(old_zoom_level + function); | 3551 zoom_level = static_cast<int>(old_zoom_level + function); |
| 3549 } else { | 3552 } else { |
| 3550 // We're going towards 100%, so first go to the next whole number. | 3553 // We're going towards 100%, so first go to the next whole number. |
| 3551 zoom_level = static_cast<int>(old_zoom_level); | 3554 zoom_level = static_cast<int>(old_zoom_level); |
| 3552 } | 3555 } |
| 3553 } | 3556 } |
| 3554 webview()->setZoomLevel(false, zoom_level); | 3557 webview()->setZoomLevel(false, zoom_level); |
| 3558 zoomLevelChanged(); | |
| 3555 #else | 3559 #else |
| 3560 ZoomFactorHelper(function, 0, 0, kScalingIncrement); | |
| 3561 #endif | |
| 3562 } | |
|
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
| |
| 3563 | |
| 3564 void RenderViewImpl::OnZoomFactor(PageZoom::Function function, | |
| 3565 int zoom_center_x, int zoom_center_y) { | |
| 3566 ZoomFactorHelper(function, zoom_center_x, zoom_center_y, | |
| 3567 kScalingIncrementForGesture); | |
| 3568 } | |
| 3569 | |
| 3570 void RenderViewImpl::ZoomFactorHelper(PageZoom::Function function, | |
| 3571 int zoom_center_x, | |
| 3572 int zoom_center_y, | |
| 3573 float scaling_increment) { | |
| 3574 if (!webview()) // Not sure if this can happen, but no harm in being safe. | |
| 3575 return; | |
| 3576 | |
| 3556 double old_page_scale_factor = webview()->pageScaleFactor(); | 3577 double old_page_scale_factor = webview()->pageScaleFactor(); |
| 3557 double page_scale_factor; | 3578 double page_scale_factor; |
| 3558 if (function == PageZoom::RESET) { | 3579 if (function == PageZoom::RESET) { |
| 3559 page_scale_factor = 1.0; | 3580 page_scale_factor = 1.0; |
| 3560 } else { | 3581 } else { |
| 3561 page_scale_factor = old_page_scale_factor + | 3582 page_scale_factor = old_page_scale_factor + |
| 3562 (function > 0 ? kScalingIncrement : -kScalingIncrement); | 3583 (function > 0 ? scaling_increment : -scaling_increment); |
| 3563 } | 3584 } |
| 3564 webview()->scalePage(page_scale_factor, WebPoint(0, 0)); | 3585 if (page_scale_factor > 0) { |
| 3565 #endif | 3586 webview()->scalePage(page_scale_factor, |
| 3566 zoomLevelChanged(); | 3587 WebPoint(zoom_center_x, zoom_center_y)); |
| 3588 zoomLevelChanged(); | |
| 3589 } | |
| 3567 } | 3590 } |
| 3568 | 3591 |
| 3569 void RenderViewImpl::OnSetZoomLevel(double zoom_level) { | 3592 void RenderViewImpl::OnSetZoomLevel(double zoom_level) { |
| 3570 // Don't set zoom level for full-page plugin since they don't use the same | 3593 // Don't set zoom level for full-page plugin since they don't use the same |
| 3571 // zoom settings. | 3594 // zoom settings. |
| 3572 if (webview()->mainFrame()->document().isPluginDocument()) | 3595 if (webview()->mainFrame()->document().isPluginDocument()) |
| 3573 return; | 3596 return; |
| 3574 | 3597 |
| 3575 webview()->hidePopups(); | 3598 webview()->hidePopups(); |
| 3576 webview()->setZoomLevel(false, zoom_level); | 3599 webview()->setZoomLevel(false, zoom_level); |
| (...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4667 return webview()->settings()->useThreadedCompositor(); | 4690 return webview()->settings()->useThreadedCompositor(); |
| 4668 } | 4691 } |
| 4669 | 4692 |
| 4670 void RenderViewImpl::OnJavaBridgeInit( | 4693 void RenderViewImpl::OnJavaBridgeInit( |
| 4671 const IPC::ChannelHandle& channel_handle) { | 4694 const IPC::ChannelHandle& channel_handle) { |
| 4672 DCHECK(!java_bridge_dispatcher_.get()); | 4695 DCHECK(!java_bridge_dispatcher_.get()); |
| 4673 #if defined(ENABLE_JAVA_BRIDGE) | 4696 #if defined(ENABLE_JAVA_BRIDGE) |
| 4674 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); | 4697 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); |
| 4675 #endif | 4698 #endif |
| 4676 } | 4699 } |
| OLD | NEW |