| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" | 199 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" |
| 200 | 200 |
| 201 #if defined(OS_ANDROID) | 201 #if defined(OS_ANDROID) |
| 202 #include "content/common/android/device_info.h" | 202 #include "content/common/android/device_info.h" |
| 203 #include "content/renderer/android/address_detector.h" | 203 #include "content/renderer/android/address_detector.h" |
| 204 #include "content/renderer/android/content_detector.h" | 204 #include "content/renderer/android/content_detector.h" |
| 205 #include "content/renderer/android/email_detector.h" | 205 #include "content/renderer/android/email_detector.h" |
| 206 #include "content/renderer/android/phone_number_detector.h" | 206 #include "content/renderer/android/phone_number_detector.h" |
| 207 #include "content/renderer/media/stream_texture_factory_impl_android.h" | 207 #include "content/renderer/media/stream_texture_factory_impl_android.h" |
| 208 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHitTestResult.h" | 208 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHitTestResult.h" |
| 209 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatPoin
t.h" |
| 210 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatRect
.h" |
| 211 #include "ui/gfx/rect_f.h" |
| 209 #include "webkit/media/android/webmediaplayer_android.h" | 212 #include "webkit/media/android/webmediaplayer_android.h" |
| 210 #include "webkit/media/android/webmediaplayer_manager_android.h" | 213 #include "webkit/media/android/webmediaplayer_manager_android.h" |
| 211 #elif defined(OS_WIN) | 214 #elif defined(OS_WIN) |
| 212 // TODO(port): these files are currently Windows only because they concern: | 215 // TODO(port): these files are currently Windows only because they concern: |
| 213 // * theming | 216 // * theming |
| 214 #include "ui/base/native_theme/native_theme_win.h" | 217 #include "ui/base/native_theme/native_theme_win.h" |
| 215 #elif defined(USE_X11) | 218 #elif defined(USE_X11) |
| 216 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebRenderTheme.
h" | 219 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebRenderTheme.
h" |
| 217 #include "ui/base/native_theme/native_theme.h" | 220 #include "ui/base/native_theme/native_theme.h" |
| 218 #elif defined(OS_MACOSX) | 221 #elif defined(OS_MACOSX) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 using webkit_glue::ResourceFetcher; | 326 using webkit_glue::ResourceFetcher; |
| 324 using webkit_glue::WebPreferences; | 327 using webkit_glue::WebPreferences; |
| 325 using webkit_glue::WebURLResponseExtraDataImpl; | 328 using webkit_glue::WebURLResponseExtraDataImpl; |
| 326 | 329 |
| 327 #if defined(OS_ANDROID) | 330 #if defined(OS_ANDROID) |
| 328 using content::AddressDetector; | 331 using content::AddressDetector; |
| 329 using content::ContentDetector; | 332 using content::ContentDetector; |
| 330 using content::EmailDetector; | 333 using content::EmailDetector; |
| 331 using content::PhoneNumberDetector; | 334 using content::PhoneNumberDetector; |
| 332 using WebKit::WebContentDetectionResult; | 335 using WebKit::WebContentDetectionResult; |
| 336 using WebKit::WebFloatPoint; |
| 337 using WebKit::WebFloatRect; |
| 333 using WebKit::WebHitTestResult; | 338 using WebKit::WebHitTestResult; |
| 334 #endif | 339 #endif |
| 335 | 340 |
| 336 //----------------------------------------------------------------------------- | 341 //----------------------------------------------------------------------------- |
| 337 | 342 |
| 338 typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap; | 343 typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap; |
| 339 static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER; | 344 static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER; |
| 340 | 345 |
| 341 // Time, in seconds, we delay before sending content state changes (such as form | 346 // Time, in seconds, we delay before sending content state changes (such as form |
| 342 // state and scroll position) to the browser. We delay sending changes to avoid | 347 // state and scroll position) to the browser. We delay sending changes to avoid |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) | 957 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) |
| 953 IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) | 958 IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) |
| 954 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) | 959 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) |
| 955 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) | 960 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) |
| 956 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) | 961 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) |
| 957 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) | 962 IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) |
| 958 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) | 963 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
| 959 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) | 964 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) |
| 960 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) | 965 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
| 961 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) | 966 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
| 967 #if defined(OS_ANDROID) |
| 968 IPC_MESSAGE_HANDLER(ViewMsg_ActivateNearestFindResult, |
| 969 OnActivateNearestFindResult) |
| 970 IPC_MESSAGE_HANDLER(ViewMsg_GetFindMatchRects, |
| 971 OnGetFindMatchRects) |
| 972 #endif |
| 962 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 973 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
| 963 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) | 974 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) |
| 964 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) | 975 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) |
| 965 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, | 976 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
| 966 OnSetZoomLevelForLoadingURL) | 977 OnSetZoomLevelForLoadingURL) |
| 967 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) | 978 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) |
| 968 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, | 979 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, |
| 969 OnResetPageEncodingToDefault) | 980 OnResetPageEncodingToDefault) |
| 970 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) | 981 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) |
| 971 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) | 982 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) |
| (...skipping 3660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4632 WebDocument doc = focused_frame->document(); | 4643 WebDocument doc = focused_frame->document(); |
| 4633 if (!doc.isNull()) { | 4644 if (!doc.isNull()) { |
| 4634 WebNode node = doc.focusedNode(); | 4645 WebNode node = doc.focusedNode(); |
| 4635 if (!node.isNull()) | 4646 if (!node.isNull()) |
| 4636 node.simulateClick(); | 4647 node.simulateClick(); |
| 4637 } | 4648 } |
| 4638 } | 4649 } |
| 4639 } | 4650 } |
| 4640 } | 4651 } |
| 4641 | 4652 |
| 4653 #if defined(OS_ANDROID) |
| 4654 void RenderViewImpl::OnActivateNearestFindResult(int request_id, |
| 4655 float x, float y) { |
| 4656 if (!webview()) |
| 4657 return; |
| 4658 |
| 4659 WebFrame* main_frame = webview()->mainFrame(); |
| 4660 WebRect selection_rect; |
| 4661 int ordinal = main_frame->selectNearestFindMatch(WebFloatPoint(x, y), |
| 4662 &selection_rect); |
| 4663 if (ordinal == -1) { |
| 4664 // Something went wrong, so send a no-op reply (force the main_frame to |
| 4665 // report the current match count) in case the host is waiting for a |
| 4666 // response due to rate-limiting). |
| 4667 main_frame->increaseMatchCount(0, request_id); |
| 4668 return; |
| 4669 } |
| 4670 |
| 4671 Send(new ViewHostMsg_Find_Reply(routing_id_, |
| 4672 request_id, |
| 4673 -1 /* number_of_matches */, |
| 4674 selection_rect, |
| 4675 ordinal, |
| 4676 true /* final_update */)); |
| 4677 } |
| 4678 |
| 4679 void RenderViewImpl::OnGetFindMatchRects(int current_version) { |
| 4680 if (!webview()) |
| 4681 return; |
| 4682 |
| 4683 WebFrame* main_frame = webview()->mainFrame(); |
| 4684 std::vector<gfx::RectF> match_rects; |
| 4685 |
| 4686 int rects_version = main_frame->findMatchMarkersVersion(); |
| 4687 if (current_version != rects_version) { |
| 4688 WebVector<WebFloatRect> web_match_rects; |
| 4689 main_frame->findMatchRects(web_match_rects); |
| 4690 match_rects.reserve(web_match_rects.size()); |
| 4691 for (size_t i = 0; i < web_match_rects.size(); ++i) |
| 4692 match_rects.push_back(gfx::RectF(web_match_rects[i])); |
| 4693 } |
| 4694 |
| 4695 gfx::RectF active_rect = main_frame->activeFindMatchRect(); |
| 4696 Send(new ViewHostMsg_GetFindMatchRects_Reply(routing_id_, |
| 4697 rects_version, |
| 4698 match_rects, |
| 4699 active_rect)); |
| 4700 } |
| 4701 #endif |
| 4702 |
| 4642 void RenderViewImpl::OnZoom(content::PageZoom zoom) { | 4703 void RenderViewImpl::OnZoom(content::PageZoom zoom) { |
| 4643 if (!webview()) // Not sure if this can happen, but no harm in being safe. | 4704 if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 4644 return; | 4705 return; |
| 4645 | 4706 |
| 4646 webview()->hidePopups(); | 4707 webview()->hidePopups(); |
| 4647 | 4708 |
| 4648 double old_zoom_level = webview()->zoomLevel(); | 4709 double old_zoom_level = webview()->zoomLevel(); |
| 4649 double zoom_level; | 4710 double zoom_level; |
| 4650 if (zoom == content::PAGE_ZOOM_RESET) { | 4711 if (zoom == content::PAGE_ZOOM_RESET) { |
| 4651 zoom_level = 0; | 4712 zoom_level = 0; |
| (...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6050 | 6111 |
| 6051 updating_frame_tree_ = true; | 6112 updating_frame_tree_ = true; |
| 6052 active_frame_id_map_.clear(); | 6113 active_frame_id_map_.clear(); |
| 6053 | 6114 |
| 6054 target_process_id_ = process_id; | 6115 target_process_id_ = process_id; |
| 6055 target_routing_id_ = route_id; | 6116 target_routing_id_ = route_id; |
| 6056 CreateFrameTree(webview()->mainFrame(), frames); | 6117 CreateFrameTree(webview()->mainFrame(), frames); |
| 6057 | 6118 |
| 6058 updating_frame_tree_ = false; | 6119 updating_frame_tree_ = false; |
| 6059 } | 6120 } |
| OLD | NEW |