Chromium Code Reviews| 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 "chrome/renderer/render_view.h" | 5 #include "chrome/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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 | 188 |
| 189 #if defined(OS_WIN) | 189 #if defined(OS_WIN) |
| 190 // TODO(port): these files are currently Windows only because they concern: | 190 // TODO(port): these files are currently Windows only because they concern: |
| 191 // * theming | 191 // * theming |
| 192 #include "gfx/native_theme_win.h" | 192 #include "gfx/native_theme_win.h" |
| 193 #elif defined(USE_X11) | 193 #elif defined(USE_X11) |
| 194 #include "gfx/native_theme_linux.h" | 194 #include "gfx/native_theme_linux.h" |
| 195 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebRenderTheme. h" | 195 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebRenderTheme. h" |
| 196 #elif defined(OS_MACOSX) | 196 #elif defined(OS_MACOSX) |
| 197 #include "skia/ext/skia_utils_mac.h" | 197 #include "skia/ext/skia_utils_mac.h" |
| 198 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebTextHelper.h" | |
| 198 #endif | 199 #endif |
| 199 | 200 |
| 200 using WebKit::WebAccessibilityCache; | 201 using WebKit::WebAccessibilityCache; |
| 201 using WebKit::WebAccessibilityNotification; | 202 using WebKit::WebAccessibilityNotification; |
| 202 using WebKit::WebAccessibilityObject; | 203 using WebKit::WebAccessibilityObject; |
| 203 using WebKit::WebApplicationCacheHost; | 204 using WebKit::WebApplicationCacheHost; |
| 204 using WebKit::WebApplicationCacheHostClient; | 205 using WebKit::WebApplicationCacheHostClient; |
| 205 using WebKit::WebCString; | 206 using WebKit::WebCString; |
| 206 using WebKit::WebColor; | 207 using WebKit::WebColor; |
| 207 using WebKit::WebColorName; | 208 using WebKit::WebColorName; |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1063 OnUpdateBrowserWindowId) | 1064 OnUpdateBrowserWindowId) |
| 1064 IPC_MESSAGE_HANDLER(ViewMsg_NotifyRenderViewType, | 1065 IPC_MESSAGE_HANDLER(ViewMsg_NotifyRenderViewType, |
| 1065 OnNotifyRendererViewType) | 1066 OnNotifyRendererViewType) |
| 1066 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) | 1067 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) |
| 1067 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) | 1068 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) |
| 1068 #if defined(OS_MACOSX) | 1069 #if defined(OS_MACOSX) |
| 1069 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) | 1070 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) |
| 1070 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) | 1071 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) |
| 1071 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionConfirmed, | 1072 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionConfirmed, |
| 1072 OnPluginImeCompositionConfirmed) | 1073 OnPluginImeCompositionConfirmed) |
| 1074 IPC_MESSAGE_HANDLER(ViewMsg_CharacterIndexForPoint, | |
| 1075 OnCharacterIndexForPoint) | |
| 1076 IPC_MESSAGE_HANDLER(ViewMsg_FirstRectForCharacterRange, | |
| 1077 OnFirstRectForCharacterRange) | |
| 1078 IPC_MESSAGE_HANDLER(ViewMsg_StringForRange, OnStringForRange) | |
| 1073 #endif | 1079 #endif |
| 1074 IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent, | 1080 IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent, |
| 1075 OnSetEditCommandsForNextKeyEvent) | 1081 OnSetEditCommandsForNextKeyEvent) |
| 1076 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCode, | 1082 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCode, |
| 1077 OnExecuteCode) | 1083 OnExecuteCode) |
| 1078 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, | 1084 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, |
| 1079 OnCustomContextMenuAction) | 1085 OnCustomContextMenuAction) |
| 1080 IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage) | 1086 IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage) |
| 1081 IPC_MESSAGE_HANDLER(ViewMsg_RevertTranslation, OnRevertTranslation) | 1087 IPC_MESSAGE_HANDLER(ViewMsg_RevertTranslation, OnRevertTranslation) |
| 1082 IPC_MESSAGE_HANDLER(ViewMsg_EnableAccessibility, OnEnableAccessibility) | 1088 IPC_MESSAGE_HANDLER(ViewMsg_EnableAccessibility, OnEnableAccessibility) |
| (...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2234 void RenderView::didChangeSelection(bool is_empty_selection) { | 2240 void RenderView::didChangeSelection(bool is_empty_selection) { |
| 2235 #if defined(OS_POSIX) | 2241 #if defined(OS_POSIX) |
| 2236 if (!handling_input_event_) | 2242 if (!handling_input_event_) |
| 2237 return; | 2243 return; |
| 2238 // TODO(estade): investigate incremental updates to the selection so that we | 2244 // TODO(estade): investigate incremental updates to the selection so that we |
| 2239 // don't send the entire selection over IPC every time. | 2245 // don't send the entire selection over IPC every time. |
| 2240 if (!is_empty_selection) { | 2246 if (!is_empty_selection) { |
| 2241 // Sometimes we get repeated didChangeSelection calls from webkit when | 2247 // Sometimes we get repeated didChangeSelection calls from webkit when |
| 2242 // the selection hasn't actually changed. We don't want to report these | 2248 // the selection hasn't actually changed. We don't want to report these |
| 2243 // because it will cause us to continually claim the X clipboard. | 2249 // because it will cause us to continually claim the X clipboard. |
| 2244 const std::string& this_selection = | 2250 WebFrame* frame = webview()->focusedFrame(); |
| 2245 webview()->focusedFrame()->selectionAsText().utf8(); | 2251 const std::string& this_selection = frame->selectionAsText().utf8(); |
| 2246 if (this_selection == last_selection_) | 2252 if (this_selection == last_selection_) |
| 2247 return; | 2253 return; |
| 2248 | 2254 |
| 2255 WebRange range = frame->selectionRange(); | |
| 2249 Send(new ViewHostMsg_SelectionChanged(routing_id_, | 2256 Send(new ViewHostMsg_SelectionChanged(routing_id_, |
| 2250 this_selection)); | 2257 this_selection, range.startOffset(), range.endOffset())); |
| 2251 last_selection_ = this_selection; | 2258 last_selection_ = this_selection; |
| 2252 } else { | 2259 } else { |
| 2253 last_selection_.clear(); | 2260 last_selection_.clear(); |
| 2254 Send(new ViewHostMsg_SelectionChanged(routing_id_, | 2261 Send(new ViewHostMsg_SelectionChanged(routing_id_, |
| 2255 last_selection_)); | 2262 last_selection_, 0, 0)); |
|
James Su
2011/01/20 23:46:06
As caretRect_ in RWHVM is not used anymore. We nee
| |
| 2256 } | 2263 } |
| 2257 #endif // defined(OS_POSIX) | 2264 #endif // defined(OS_POSIX) |
| 2258 } | 2265 } |
| 2259 | 2266 |
| 2260 void RenderView::didExecuteCommand(const WebString& command_name) { | 2267 void RenderView::didExecuteCommand(const WebString& command_name) { |
| 2261 const std::string& name = UTF16ToUTF8(command_name); | 2268 const std::string& name = UTF16ToUTF8(command_name); |
| 2262 if (StartsWithASCII(name, "Move", true) || | 2269 if (StartsWithASCII(name, "Move", true) || |
| 2263 StartsWithASCII(name, "Insert", true) || | 2270 StartsWithASCII(name, "Insert", true) || |
| 2264 StartsWithASCII(name, "Delete", true)) | 2271 StartsWithASCII(name, "Delete", true)) |
| 2265 return; | 2272 return; |
| (...skipping 3384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5650 // Crash reports from the field indicate that we can be notified with a | 5657 // Crash reports from the field indicate that we can be notified with a |
| 5651 // NULL external popup menu (we probably get notified twice). | 5658 // NULL external popup menu (we probably get notified twice). |
| 5652 // If you hit this please file a bug against jcivelli and include the page | 5659 // If you hit this please file a bug against jcivelli and include the page |
| 5653 // and steps to repro. | 5660 // and steps to repro. |
| 5654 NOTREACHED(); | 5661 NOTREACHED(); |
| 5655 return; | 5662 return; |
| 5656 } | 5663 } |
| 5657 external_popup_menu_->DidSelectItem(selected_index); | 5664 external_popup_menu_->DidSelectItem(selected_index); |
| 5658 external_popup_menu_.reset(); | 5665 external_popup_menu_.reset(); |
| 5659 } | 5666 } |
| 5667 | |
| 5668 void RenderView::OnCharacterIndexForPoint(gfx::Point point) { | |
| 5669 WebKit::WebTextHelper helper(webview()->mainFrame()); | |
| 5670 uint index = helper.characterIndexForPoint(point.x(), point.y()); | |
| 5671 Send(new ViewHostMsg_GotCharacterIndexForPoint(routing_id(), index)); | |
| 5672 } | |
| 5673 | |
| 5674 void RenderView::OnFirstRectForCharacterRange(uint location, uint length) { | |
| 5675 WebKit::WebTextHelper helper(webview()->mainFrame()); | |
| 5676 gfx::Rect rect(helper.firstRectForRange(location, length)); | |
| 5677 Send(new ViewHostMsg_GotFirstRectForRange(routing_id(), rect)); | |
| 5678 } | |
| 5679 | |
| 5680 void RenderView::OnStringForRange(uint location, uint length) { | |
| 5681 WebKit::WebTextHelper helper(webview()->mainFrame()); | |
| 5682 WebKit::WebString webstring(helper.substringInRange(location, length)); | |
| 5683 Send(new ViewHostMsg_GotStringForRange(routing_id(), webstring)); | |
| 5684 } | |
| 5660 #endif | 5685 #endif |
| 5661 | 5686 |
| 5662 void RenderView::AddErrorToRootConsole(const string16& message) { | 5687 void RenderView::AddErrorToRootConsole(const string16& message) { |
| 5663 if (webview() && webview()->mainFrame()) { | 5688 if (webview() && webview()->mainFrame()) { |
| 5664 webview()->mainFrame()->addMessageToConsole( | 5689 webview()->mainFrame()->addMessageToConsole( |
| 5665 WebConsoleMessage(WebConsoleMessage::LevelError, message)); | 5690 WebConsoleMessage(WebConsoleMessage::LevelError, message)); |
| 5666 } | 5691 } |
| 5667 } | 5692 } |
| 5668 | 5693 |
| 5669 #if defined(ENABLE_FLAPPER_HACKS) | 5694 #if defined(ENABLE_FLAPPER_HACKS) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 5684 if (cmd == kJavaScriptStressTestSetStressRunType) { | 5709 if (cmd == kJavaScriptStressTestSetStressRunType) { |
| 5685 v8::Testing::SetStressRunType(static_cast<v8::Testing::StressType>(param)); | 5710 v8::Testing::SetStressRunType(static_cast<v8::Testing::StressType>(param)); |
| 5686 } else if (cmd == kJavaScriptStressTestPrepareStressRun) { | 5711 } else if (cmd == kJavaScriptStressTestPrepareStressRun) { |
| 5687 v8::Testing::PrepareStressRun(param); | 5712 v8::Testing::PrepareStressRun(param); |
| 5688 } | 5713 } |
| 5689 } | 5714 } |
| 5690 | 5715 |
| 5691 void RenderView::OnContextMenuClosed() { | 5716 void RenderView::OnContextMenuClosed() { |
| 5692 context_menu_node_.reset(); | 5717 context_menu_node_.reset(); |
| 5693 } | 5718 } |
| OLD | NEW |