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.h" | 5 #include "content/renderer/render_view.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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 send_preferred_size_changes_(false), | 346 send_preferred_size_changes_(false), |
347 is_loading_(false), | 347 is_loading_(false), |
348 navigation_gesture_(NavigationGestureUnknown), | 348 navigation_gesture_(NavigationGestureUnknown), |
349 opened_by_user_gesture_(true), | 349 opened_by_user_gesture_(true), |
350 opener_suppressed_(false), | 350 opener_suppressed_(false), |
351 page_id_(-1), | 351 page_id_(-1), |
352 last_page_id_sent_to_browser_(-1), | 352 last_page_id_sent_to_browser_(-1), |
353 history_list_offset_(-1), | 353 history_list_offset_(-1), |
354 history_list_length_(0), | 354 history_list_length_(0), |
355 target_url_status_(TARGET_NONE), | 355 target_url_status_(TARGET_NONE), |
| 356 cached_is_main_frame_pinned_to_left_(false), |
| 357 cached_is_main_frame_pinned_to_right_(false), |
| 358 cached_has_main_frame_horizontal_scrollbar_(false), |
| 359 cached_has_main_frame_vertical_scrollbar_(false), |
356 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), | 360 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), |
357 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), | 361 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), |
358 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 362 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
359 geolocation_dispatcher_(NULL), | 363 geolocation_dispatcher_(NULL), |
360 speech_input_dispatcher_(NULL), | 364 speech_input_dispatcher_(NULL), |
361 device_orientation_dispatcher_(NULL), | 365 device_orientation_dispatcher_(NULL), |
362 accessibility_ack_pending_(false), | 366 accessibility_ack_pending_(false), |
363 p2p_socket_dispatcher_(NULL), | 367 p2p_socket_dispatcher_(NULL), |
364 devtools_agent_(NULL), | 368 devtools_agent_(NULL), |
365 session_storage_namespace_id_(session_storage_namespace_id), | 369 session_storage_namespace_id_(session_storage_namespace_id), |
(...skipping 2511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2877 size.set_height(static_cast<int>(size.height() * zoom_factor)); | 2881 size.set_height(static_cast<int>(size.height() * zoom_factor)); |
2878 | 2882 |
2879 if (size == preferred_size_) | 2883 if (size == preferred_size_) |
2880 return; | 2884 return; |
2881 | 2885 |
2882 preferred_size_ = size; | 2886 preferred_size_ = size; |
2883 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, | 2887 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, |
2884 preferred_size_)); | 2888 preferred_size_)); |
2885 } | 2889 } |
2886 | 2890 |
| 2891 void RenderView::didChangeContentsSize(WebFrame* frame, const WebSize& size) { |
| 2892 if (webview()->mainFrame() != frame) |
| 2893 return; |
| 2894 WebView* frameView = frame->view(); |
| 2895 if (!frameView) |
| 2896 return; |
| 2897 |
| 2898 bool has_horizontal_scrollbar = frame->hasHorizontalScrollbar(); |
| 2899 bool has_vertical_scrollbar = frame->hasVerticalScrollbar(); |
| 2900 |
| 2901 if (has_horizontal_scrollbar != cached_has_main_frame_horizontal_scrollbar_ || |
| 2902 has_vertical_scrollbar != cached_has_main_frame_vertical_scrollbar_) { |
| 2903 Send(new ViewHostMsg_DidChangeScrollbarsForMainFrame( |
| 2904 routing_id_, has_horizontal_scrollbar, has_vertical_scrollbar)); |
| 2905 |
| 2906 cached_has_main_frame_horizontal_scrollbar_ = has_horizontal_scrollbar; |
| 2907 cached_has_main_frame_vertical_scrollbar_ = has_vertical_scrollbar; |
| 2908 } |
| 2909 } |
| 2910 |
| 2911 void RenderView::UpdateScrollState(WebFrame* frame) { |
| 2912 WebSize offset = frame->scrollOffset(); |
| 2913 WebSize minimum_offset = frame->minimumScrollOffset(); |
| 2914 WebSize maximum_offset = frame->maximumScrollOffset(); |
| 2915 |
| 2916 bool is_pinned_to_left = offset.width <= minimum_offset.width; |
| 2917 bool is_pinned_to_right = offset.width >= maximum_offset.width; |
| 2918 |
| 2919 if (is_pinned_to_left != cached_is_main_frame_pinned_to_left_ || |
| 2920 is_pinned_to_right != cached_is_main_frame_pinned_to_right_) { |
| 2921 Send(new ViewHostMsg_DidChangeScrollOffsetPinningForMainFrame( |
| 2922 routing_id_, is_pinned_to_left, is_pinned_to_right)); |
| 2923 |
| 2924 cached_is_main_frame_pinned_to_left_ = is_pinned_to_left; |
| 2925 cached_is_main_frame_pinned_to_right_ = is_pinned_to_right; |
| 2926 } |
| 2927 } |
| 2928 |
2887 void RenderView::didChangeScrollOffset(WebFrame* frame) { | 2929 void RenderView::didChangeScrollOffset(WebFrame* frame) { |
2888 StartNavStateSyncTimerIfNecessary(); | 2930 StartNavStateSyncTimerIfNecessary(); |
| 2931 |
| 2932 if (webview()->mainFrame() == frame) |
| 2933 UpdateScrollState(frame); |
| 2934 } |
| 2935 |
| 2936 void RenderView::numberOfWheelEventHandlersChanged(unsigned num_handlers) { |
| 2937 Send(new ViewHostMsg_DidChangeNumWheelEvents(routing_id_, num_handlers)); |
2889 } | 2938 } |
2890 | 2939 |
2891 void RenderView::reportFindInPageMatchCount(int request_id, int count, | 2940 void RenderView::reportFindInPageMatchCount(int request_id, int count, |
2892 bool final_update) { | 2941 bool final_update) { |
2893 int active_match_ordinal = -1; // -1 = don't update active match ordinal | 2942 int active_match_ordinal = -1; // -1 = don't update active match ordinal |
2894 if (!count) | 2943 if (!count) |
2895 active_match_ordinal = 0; | 2944 active_match_ordinal = 0; |
2896 | 2945 |
2897 IPC::Message* msg = new ViewHostMsg_Find_Reply( | 2946 IPC::Message* msg = new ViewHostMsg_Find_Reply( |
2898 routing_id_, | 2947 routing_id_, |
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3872 } | 3921 } |
3873 | 3922 |
3874 void RenderView::OnResize(const gfx::Size& new_size, | 3923 void RenderView::OnResize(const gfx::Size& new_size, |
3875 const gfx::Rect& resizer_rect) { | 3924 const gfx::Rect& resizer_rect) { |
3876 if (webview()) { | 3925 if (webview()) { |
3877 webview()->hidePopups(); | 3926 webview()->hidePopups(); |
3878 if (send_preferred_size_changes_) { | 3927 if (send_preferred_size_changes_) { |
3879 webview()->mainFrame()->setCanHaveScrollbars( | 3928 webview()->mainFrame()->setCanHaveScrollbars( |
3880 should_display_scrollbars(new_size.width(), new_size.height())); | 3929 should_display_scrollbars(new_size.width(), new_size.height())); |
3881 } | 3930 } |
| 3931 UpdateScrollState(webview()->mainFrame()); |
3882 } | 3932 } |
3883 | 3933 |
3884 RenderWidget::OnResize(new_size, resizer_rect); | 3934 RenderWidget::OnResize(new_size, resizer_rect); |
3885 } | 3935 } |
3886 | 3936 |
3887 void RenderView::DidInitiatePaint() { | 3937 void RenderView::DidInitiatePaint() { |
3888 // Notify the pepper plugins that we started painting. | 3938 // Notify the pepper plugins that we started painting. |
3889 pepper_delegate_.ViewInitiatedPaint(); | 3939 pepper_delegate_.ViewInitiatedPaint(); |
3890 } | 3940 } |
3891 | 3941 |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4489 } | 4539 } |
4490 #endif | 4540 #endif |
4491 | 4541 |
4492 void RenderView::OnContextMenuClosed( | 4542 void RenderView::OnContextMenuClosed( |
4493 const webkit_glue::CustomContextMenuContext& custom_context) { | 4543 const webkit_glue::CustomContextMenuContext& custom_context) { |
4494 if (custom_context.is_pepper_menu) | 4544 if (custom_context.is_pepper_menu) |
4495 pepper_delegate_.OnContextMenuClosed(custom_context); | 4545 pepper_delegate_.OnContextMenuClosed(custom_context); |
4496 else | 4546 else |
4497 context_menu_node_.reset(); | 4547 context_menu_node_.reset(); |
4498 } | 4548 } |
OLD | NEW |