| 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_FindMatchRects, |
| 971 OnFindMatchRects) |
| 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 3669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4641 WebDocument doc = focused_frame->document(); | 4652 WebDocument doc = focused_frame->document(); |
| 4642 if (!doc.isNull()) { | 4653 if (!doc.isNull()) { |
| 4643 WebNode node = doc.focusedNode(); | 4654 WebNode node = doc.focusedNode(); |
| 4644 if (!node.isNull()) | 4655 if (!node.isNull()) |
| 4645 node.simulateClick(); | 4656 node.simulateClick(); |
| 4646 } | 4657 } |
| 4647 } | 4658 } |
| 4648 } | 4659 } |
| 4649 } | 4660 } |
| 4650 | 4661 |
| 4662 #if defined(OS_ANDROID) |
| 4663 void RenderViewImpl::OnActivateNearestFindResult(int request_id, |
| 4664 float x, float y) { |
| 4665 if (!webview()) |
| 4666 return; |
| 4667 |
| 4668 WebFrame* main_frame = webview()->mainFrame(); |
| 4669 WebRect selection_rect; |
| 4670 int ordinal = main_frame->selectNearestFindMatch(WebFloatPoint(x, y), |
| 4671 &selection_rect); |
| 4672 if (ordinal == -1) { |
| 4673 // Something went wrong, so send a no-op reply (force the main_frame to |
| 4674 // report the current match count) in case the host is waiting for a |
| 4675 // response due to rate-limiting). |
| 4676 main_frame->increaseMatchCount(0, request_id); |
| 4677 return; |
| 4678 } |
| 4679 |
| 4680 Send(new ViewHostMsg_Find_Reply(routing_id_, |
| 4681 request_id, |
| 4682 -1 /* number_of_matches */, |
| 4683 selection_rect, |
| 4684 ordinal, |
| 4685 true /* final_update */)); |
| 4686 } |
| 4687 |
| 4688 void RenderViewImpl::OnFindMatchRects(int current_version) { |
| 4689 if (!webview()) |
| 4690 return; |
| 4691 |
| 4692 WebFrame* main_frame = webview()->mainFrame(); |
| 4693 std::vector<gfx::RectF> match_rects; |
| 4694 |
| 4695 int rects_version = main_frame->findMatchMarkersVersion(); |
| 4696 if (current_version != rects_version) { |
| 4697 WebVector<WebFloatRect> web_match_rects; |
| 4698 main_frame->findMatchRects(web_match_rects); |
| 4699 match_rects.reserve(web_match_rects.size()); |
| 4700 for (size_t i = 0; i < web_match_rects.size(); ++i) |
| 4701 match_rects.push_back(gfx::RectF(web_match_rects[i])); |
| 4702 } |
| 4703 |
| 4704 gfx::RectF active_rect = main_frame->activeFindMatchRect(); |
| 4705 Send(new ViewHostMsg_FindMatchRects_Reply(routing_id_, |
| 4706 rects_version, |
| 4707 match_rects, |
| 4708 active_rect)); |
| 4709 } |
| 4710 #endif |
| 4711 |
| 4651 void RenderViewImpl::OnZoom(content::PageZoom zoom) { | 4712 void RenderViewImpl::OnZoom(content::PageZoom zoom) { |
| 4652 if (!webview()) // Not sure if this can happen, but no harm in being safe. | 4713 if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 4653 return; | 4714 return; |
| 4654 | 4715 |
| 4655 webview()->hidePopups(); | 4716 webview()->hidePopups(); |
| 4656 | 4717 |
| 4657 double old_zoom_level = webview()->zoomLevel(); | 4718 double old_zoom_level = webview()->zoomLevel(); |
| 4658 double zoom_level; | 4719 double zoom_level; |
| 4659 if (zoom == content::PAGE_ZOOM_RESET) { | 4720 if (zoom == content::PAGE_ZOOM_RESET) { |
| 4660 zoom_level = 0; | 4721 zoom_level = 0; |
| (...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6059 | 6120 |
| 6060 updating_frame_tree_ = true; | 6121 updating_frame_tree_ = true; |
| 6061 active_frame_id_map_.clear(); | 6122 active_frame_id_map_.clear(); |
| 6062 | 6123 |
| 6063 target_process_id_ = process_id; | 6124 target_process_id_ = process_id; |
| 6064 target_routing_id_ = route_id; | 6125 target_routing_id_ = route_id; |
| 6065 CreateFrameTree(webview()->mainFrame(), frames); | 6126 CreateFrameTree(webview()->mainFrame(), frames); |
| 6066 | 6127 |
| 6067 updating_frame_tree_ = false; | 6128 updating_frame_tree_ = false; |
| 6068 } | 6129 } |
| OLD | NEW |