| 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 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 RenderViewObserver* observer; | 1064 RenderViewObserver* observer; |
| 1065 while ((observer = it.GetNext()) != NULL) | 1065 while ((observer = it.GetNext()) != NULL) |
| 1066 if (observer->OnMessageReceived(message)) | 1066 if (observer->OnMessageReceived(message)) |
| 1067 return true; | 1067 return true; |
| 1068 | 1068 |
| 1069 bool handled = true; | 1069 bool handled = true; |
| 1070 bool msg_is_ok = true; | 1070 bool msg_is_ok = true; |
| 1071 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok) | 1071 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok) |
| 1072 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand) | 1072 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand) |
| 1073 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret) | 1073 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret) |
| 1074 IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace) | |
| 1075 IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling) | |
| 1076 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, | 1074 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, |
| 1077 OnScrollFocusedEditableNodeIntoRect) | 1075 OnScrollFocusedEditableNodeIntoRect) |
| 1078 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, | 1076 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, |
| 1079 OnSetEditCommandsForNextKeyEvent) | 1077 OnSetEditCommandsForNextKeyEvent) |
| 1080 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) | 1078 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) |
| 1081 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) | 1079 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) |
| 1082 IPC_MESSAGE_HANDLER(ViewMsg_SetName, OnSetName) | 1080 IPC_MESSAGE_HANDLER(ViewMsg_SetName, OnSetName) |
| 1083 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) | 1081 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
| 1084 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) | 1082 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
| 1085 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) | 1083 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 | 1245 |
| 1248 void RenderViewImpl::OnMoveCaret(const gfx::Point& point) { | 1246 void RenderViewImpl::OnMoveCaret(const gfx::Point& point) { |
| 1249 if (!webview()) | 1247 if (!webview()) |
| 1250 return; | 1248 return; |
| 1251 | 1249 |
| 1252 Send(new ViewHostMsg_MoveCaret_ACK(routing_id_)); | 1250 Send(new ViewHostMsg_MoveCaret_ACK(routing_id_)); |
| 1253 | 1251 |
| 1254 webview()->focusedFrame()->moveCaretSelection(point); | 1252 webview()->focusedFrame()->moveCaretSelection(point); |
| 1255 } | 1253 } |
| 1256 | 1254 |
| 1257 void RenderViewImpl::OnReplace(const base::string16& text) { | |
| 1258 if (!webview()) | |
| 1259 return; | |
| 1260 | |
| 1261 WebFrame* frame = webview()->focusedFrame(); | |
| 1262 if (!frame->hasSelection()) | |
| 1263 frame->selectWordAroundCaret(); | |
| 1264 | |
| 1265 frame->replaceSelection(text); | |
| 1266 } | |
| 1267 | |
| 1268 void RenderViewImpl::OnReplaceMisspelling(const base::string16& text) { | |
| 1269 if (!webview()) | |
| 1270 return; | |
| 1271 | |
| 1272 WebFrame* frame = webview()->focusedFrame(); | |
| 1273 if (!frame->hasSelection()) | |
| 1274 return; | |
| 1275 | |
| 1276 frame->replaceMisspelledRange(text); | |
| 1277 } | |
| 1278 | |
| 1279 void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( | 1255 void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( |
| 1280 const gfx::Rect& rect) { | 1256 const gfx::Rect& rect) { |
| 1281 if (has_scrolled_focused_editable_node_into_rect_ && | 1257 if (has_scrolled_focused_editable_node_into_rect_ && |
| 1282 rect == rect_for_scrolled_focused_editable_node_) { | 1258 rect == rect_for_scrolled_focused_editable_node_) { |
| 1283 return; | 1259 return; |
| 1284 } | 1260 } |
| 1285 | 1261 |
| 1286 blink::WebElement element = GetFocusedElement(); | 1262 blink::WebElement element = GetFocusedElement(); |
| 1287 if (!element.isNull() && IsEditableNode(element)) { | 1263 if (!element.isNull() && IsEditableNode(element)) { |
| 1288 rect_for_scrolled_focused_editable_node_ = rect; | 1264 rect_for_scrolled_focused_editable_node_ = rect; |
| (...skipping 3538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4827 std::vector<gfx::Size> sizes(icon_urls[i].sizes().size()); | 4803 std::vector<gfx::Size> sizes(icon_urls[i].sizes().size()); |
| 4828 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4804 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
| 4829 if (!url.isEmpty()) | 4805 if (!url.isEmpty()) |
| 4830 urls.push_back( | 4806 urls.push_back( |
| 4831 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4807 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
| 4832 } | 4808 } |
| 4833 SendUpdateFaviconURL(urls); | 4809 SendUpdateFaviconURL(urls); |
| 4834 } | 4810 } |
| 4835 | 4811 |
| 4836 } // namespace content | 4812 } // namespace content |
| OLD | NEW |