| 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 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2030 return true; | 2030 return true; |
| 2031 #else | 2031 #else |
| 2032 return false; | 2032 return false; |
| 2033 #endif | 2033 #endif |
| 2034 } | 2034 } |
| 2035 | 2035 |
| 2036 void RenderView::didChangeSelection(bool is_empty_selection) { | 2036 void RenderView::didChangeSelection(bool is_empty_selection) { |
| 2037 #if defined(OS_POSIX) | 2037 #if defined(OS_POSIX) |
| 2038 if (!handling_input_event_) | 2038 if (!handling_input_event_) |
| 2039 return; | 2039 return; |
| 2040 // TODO(estade): investigate incremental updates to the selection so that we | 2040 |
| 2041 // don't send the entire selection over IPC every time. | 2041 if (is_empty_selection) { |
| 2042 if (!is_empty_selection) { | 2042 last_selection_.clear(); |
| 2043 } else { |
| 2043 // Sometimes we get repeated didChangeSelection calls from webkit when | 2044 // Sometimes we get repeated didChangeSelection calls from webkit when |
| 2044 // the selection hasn't actually changed. We don't want to report these | 2045 // the selection hasn't actually changed. We don't want to report these |
| 2045 // because it will cause us to continually claim the X clipboard. | 2046 // because it will cause us to continually claim the X clipboard. |
| 2046 const std::string& this_selection = | 2047 WebFrame* frame = webview()->focusedFrame(); |
| 2047 webview()->focusedFrame()->selectionAsText().utf8(); | 2048 const std::string& this_selection = frame->selectionAsText().utf8(); |
| 2048 if (this_selection == last_selection_) | 2049 if (this_selection == last_selection_) |
| 2049 return; | 2050 return; |
| 2051 last_selection_ = this_selection; |
| 2052 } |
| 2050 | 2053 |
| 2051 Send(new ViewHostMsg_SelectionChanged(routing_id_, | 2054 ui::Range range(ui::Range::InvalidRange()); |
| 2052 this_selection)); | 2055 size_t location, length; |
| 2053 last_selection_ = this_selection; | 2056 if (webview()->caretOrSelectionRange(&location, &length)) { |
| 2054 } else { | 2057 range.set_start(location); |
| 2055 last_selection_.clear(); | 2058 range.set_end(location + length); |
| 2056 Send(new ViewHostMsg_SelectionChanged(routing_id_, | |
| 2057 last_selection_)); | |
| 2058 } | 2059 } |
| 2060 Send(new ViewHostMsg_SelectionChanged(routing_id_, last_selection_, range)); |
| 2059 #endif // defined(OS_POSIX) | 2061 #endif // defined(OS_POSIX) |
| 2060 } | 2062 } |
| 2061 | 2063 |
| 2062 void RenderView::didExecuteCommand(const WebString& command_name) { | 2064 void RenderView::didExecuteCommand(const WebString& command_name) { |
| 2063 const std::string& name = UTF16ToUTF8(command_name); | 2065 const std::string& name = UTF16ToUTF8(command_name); |
| 2064 if (StartsWithASCII(name, "Move", true) || | 2066 if (StartsWithASCII(name, "Move", true) || |
| 2065 StartsWithASCII(name, "Insert", true) || | 2067 StartsWithASCII(name, "Insert", true) || |
| 2066 StartsWithASCII(name, "Delete", true)) | 2068 StartsWithASCII(name, "Delete", true)) |
| 2067 return; | 2069 return; |
| 2068 UserMetricsRecordAction(name); | 2070 UserMetricsRecordAction(name); |
| (...skipping 2978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5047 const webkit_glue::CustomContextMenuContext& custom_context) { | 5049 const webkit_glue::CustomContextMenuContext& custom_context) { |
| 5048 if (custom_context.is_pepper_menu) | 5050 if (custom_context.is_pepper_menu) |
| 5049 pepper_delegate_.OnContextMenuClosed(custom_context); | 5051 pepper_delegate_.OnContextMenuClosed(custom_context); |
| 5050 else | 5052 else |
| 5051 context_menu_node_.reset(); | 5053 context_menu_node_.reset(); |
| 5052 } | 5054 } |
| 5053 | 5055 |
| 5054 void RenderView::OnNetworkStateChanged(bool online) { | 5056 void RenderView::OnNetworkStateChanged(bool online) { |
| 5055 WebNetworkStateNotifier::setOnLine(online); | 5057 WebNetworkStateNotifier::setOnLine(online); |
| 5056 } | 5058 } |
| OLD | NEW |