| 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 <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete()); | 1246 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete()); |
| 1247 } | 1247 } |
| 1248 | 1248 |
| 1249 bool RenderViewImpl::DoesRenderWidgetHaveTouchEventHandlersAt( | 1249 bool RenderViewImpl::DoesRenderWidgetHaveTouchEventHandlersAt( |
| 1250 const gfx::Point& point) const { | 1250 const gfx::Point& point) const { |
| 1251 if (!webview()) | 1251 if (!webview()) |
| 1252 return false; | 1252 return false; |
| 1253 return webview()->hasTouchEventHandlersAt(point); | 1253 return webview()->hasTouchEventHandlersAt(point); |
| 1254 } | 1254 } |
| 1255 | 1255 |
| 1256 void RenderViewImpl::RenderWidgetDidHandleKeyEvent() { | |
| 1257 ClearEditCommands(); | |
| 1258 } | |
| 1259 | |
| 1260 bool RenderViewImpl::RenderWidgetWillHandleGestureEvent( | 1256 bool RenderViewImpl::RenderWidgetWillHandleGestureEvent( |
| 1261 const blink::WebGestureEvent& event) { | 1257 const blink::WebGestureEvent& event) { |
| 1262 possible_drag_event_info_.event_source = | 1258 possible_drag_event_info_.event_source = |
| 1263 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; | 1259 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; |
| 1264 possible_drag_event_info_.event_location = | 1260 possible_drag_event_info_.event_location = |
| 1265 gfx::Point(event.globalX, event.globalY); | 1261 gfx::Point(event.globalX, event.globalY); |
| 1266 return false; | 1262 return false; |
| 1267 } | 1263 } |
| 1268 | 1264 |
| 1269 bool RenderViewImpl::RenderWidgetWillHandleMouseEvent( | 1265 bool RenderViewImpl::RenderWidgetWillHandleMouseEvent( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1295 while ((observer = it.GetNext()) != NULL) | 1291 while ((observer = it.GetNext()) != NULL) |
| 1296 if (observer->OnMessageReceived(message)) | 1292 if (observer->OnMessageReceived(message)) |
| 1297 return true; | 1293 return true; |
| 1298 | 1294 |
| 1299 bool handled = true; | 1295 bool handled = true; |
| 1300 IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message) | 1296 IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message) |
| 1301 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand) | 1297 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand) |
| 1302 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret) | 1298 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret) |
| 1303 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, | 1299 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, |
| 1304 OnScrollFocusedEditableNodeIntoRect) | 1300 OnScrollFocusedEditableNodeIntoRect) |
| 1305 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, | |
| 1306 OnSetEditCommandsForNextKeyEvent) | |
| 1307 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) | 1301 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) |
| 1308 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 1302 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
| 1309 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, | 1303 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
| 1310 OnSetZoomLevelForLoadingURL) | 1304 OnSetZoomLevelForLoadingURL) |
| 1311 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) | 1305 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
| 1312 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) | 1306 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
| 1313 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) | 1307 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
| 1314 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) | 1308 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) |
| 1315 IPC_MESSAGE_HANDLER(DragMsg_SourceEnded, OnDragSourceEnded) | 1309 IPC_MESSAGE_HANDLER(DragMsg_SourceEnded, OnDragSourceEnded) |
| 1316 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, | 1310 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 | 1409 |
| 1416 if (!webview()->scrollFocusedEditableElementIntoRect(rect)) | 1410 if (!webview()->scrollFocusedEditableElementIntoRect(rect)) |
| 1417 return; | 1411 return; |
| 1418 | 1412 |
| 1419 rect_for_scrolled_focused_editable_node_ = rect; | 1413 rect_for_scrolled_focused_editable_node_ = rect; |
| 1420 has_scrolled_focused_editable_node_into_rect_ = true; | 1414 has_scrolled_focused_editable_node_into_rect_ = true; |
| 1421 if (!compositor()->hasPendingPageScaleAnimation()) | 1415 if (!compositor()->hasPendingPageScaleAnimation()) |
| 1422 GetWidget()->FocusChangeComplete(); | 1416 GetWidget()->FocusChangeComplete(); |
| 1423 } | 1417 } |
| 1424 | 1418 |
| 1425 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( | |
| 1426 const EditCommands& edit_commands) { | |
| 1427 edit_commands_ = edit_commands; | |
| 1428 } | |
| 1429 | |
| 1430 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, | 1419 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, |
| 1431 int history_length) { | 1420 int history_length) { |
| 1432 DCHECK_GE(history_offset, -1); | 1421 DCHECK_GE(history_offset, -1); |
| 1433 DCHECK_GE(history_length, 0); | 1422 DCHECK_GE(history_length, 0); |
| 1434 | 1423 |
| 1435 history_list_offset_ = history_offset; | 1424 history_list_offset_ = history_offset; |
| 1436 history_list_length_ = history_length; | 1425 history_list_length_ = history_length; |
| 1437 } | 1426 } |
| 1438 | 1427 |
| 1439 void RenderViewImpl::OnSetInitialFocus(bool reverse) { | 1428 void RenderViewImpl::OnSetInitialFocus(bool reverse) { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1659 page_zoom_level_ = zoom_level; | 1648 page_zoom_level_ = zoom_level; |
| 1660 | 1649 |
| 1661 webview()->setZoomLevel(zoom_level); | 1650 webview()->setZoomLevel(zoom_level); |
| 1662 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnZoomLevelChanged()); | 1651 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnZoomLevelChanged()); |
| 1663 } | 1652 } |
| 1664 | 1653 |
| 1665 void RenderViewImpl::didCancelCompositionOnSelectionChange() { | 1654 void RenderViewImpl::didCancelCompositionOnSelectionChange() { |
| 1666 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID())); | 1655 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID())); |
| 1667 } | 1656 } |
| 1668 | 1657 |
| 1669 bool RenderViewImpl::handleCurrentKeyboardEvent() { | |
| 1670 if (edit_commands_.empty()) | |
| 1671 return false; | |
| 1672 | |
| 1673 WebLocalFrame* frame = webview()->focusedFrame(); | |
| 1674 | |
| 1675 EditCommands::iterator it = edit_commands_.begin(); | |
| 1676 EditCommands::iterator end = edit_commands_.end(); | |
| 1677 | |
| 1678 bool did_execute_command = false; | |
| 1679 for (; it != end; ++it) { | |
| 1680 // In gtk and cocoa, it's possible to bind multiple edit commands to one | |
| 1681 // key (but it's the exception). Once one edit command is not executed, it | |
| 1682 // seems safest to not execute the rest. | |
| 1683 if (!frame->executeCommand(WebString::fromUTF8(it->name), | |
| 1684 WebString::fromUTF8(it->value))) | |
| 1685 break; | |
| 1686 did_execute_command = true; | |
| 1687 } | |
| 1688 | |
| 1689 return did_execute_command; | |
| 1690 } | |
| 1691 | |
| 1692 void RenderViewImpl::SetValidationMessageDirection( | 1658 void RenderViewImpl::SetValidationMessageDirection( |
| 1693 base::string16* wrapped_main_text, | 1659 base::string16* wrapped_main_text, |
| 1694 blink::WebTextDirection main_text_hint, | 1660 blink::WebTextDirection main_text_hint, |
| 1695 base::string16* wrapped_sub_text, | 1661 base::string16* wrapped_sub_text, |
| 1696 blink::WebTextDirection sub_text_hint) { | 1662 blink::WebTextDirection sub_text_hint) { |
| 1697 if (main_text_hint == blink::WebTextDirectionLeftToRight) { | 1663 if (main_text_hint == blink::WebTextDirectionLeftToRight) { |
| 1698 *wrapped_main_text = | 1664 *wrapped_main_text = |
| 1699 base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_main_text); | 1665 base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_main_text); |
| 1700 } else if (main_text_hint == blink::WebTextDirectionRightToLeft && | 1666 } else if (main_text_hint == blink::WebTextDirectionRightToLeft && |
| 1701 !base::i18n::IsRTL()) { | 1667 !base::i18n::IsRTL()) { |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2084 } | 2050 } |
| 2085 | 2051 |
| 2086 // blink::WebFrameClient ----------------------------------------------------- | 2052 // blink::WebFrameClient ----------------------------------------------------- |
| 2087 | 2053 |
| 2088 void RenderViewImpl::Repaint(const gfx::Size& size) { | 2054 void RenderViewImpl::Repaint(const gfx::Size& size) { |
| 2089 OnRepaint(size); | 2055 OnRepaint(size); |
| 2090 } | 2056 } |
| 2091 | 2057 |
| 2092 void RenderViewImpl::SetEditCommandForNextKeyEvent(const std::string& name, | 2058 void RenderViewImpl::SetEditCommandForNextKeyEvent(const std::string& name, |
| 2093 const std::string& value) { | 2059 const std::string& value) { |
| 2094 EditCommands edit_commands; | 2060 GetWidget()->SetEditCommandForNextKeyEvent(name, value); |
| 2095 edit_commands.push_back(EditCommand(name, value)); | |
| 2096 OnSetEditCommandsForNextKeyEvent(edit_commands); | |
| 2097 } | 2061 } |
| 2098 | 2062 |
| 2099 void RenderViewImpl::ClearEditCommands() { | 2063 void RenderViewImpl::ClearEditCommands() { |
| 2100 edit_commands_.clear(); | 2064 GetWidget()->ClearEditCommands(); |
| 2101 } | 2065 } |
| 2102 | 2066 |
| 2103 const std::string& RenderViewImpl::GetAcceptLanguages() const { | 2067 const std::string& RenderViewImpl::GetAcceptLanguages() const { |
| 2104 return renderer_preferences_.accept_languages; | 2068 return renderer_preferences_.accept_languages; |
| 2105 } | 2069 } |
| 2106 | 2070 |
| 2107 void RenderViewImpl::ConvertViewportToWindowViaWidget(blink::WebRect* rect) { | 2071 void RenderViewImpl::ConvertViewportToWindowViaWidget(blink::WebRect* rect) { |
| 2108 convertViewportToWindow(rect); | 2072 convertViewportToWindow(rect); |
| 2109 } | 2073 } |
| 2110 | 2074 |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3050 return render_frame->focused_pepper_plugin(); | 3014 return render_frame->focused_pepper_plugin(); |
| 3051 } | 3015 } |
| 3052 frame = frame->traverseNext(false); | 3016 frame = frame->traverseNext(false); |
| 3053 } | 3017 } |
| 3054 | 3018 |
| 3055 return nullptr; | 3019 return nullptr; |
| 3056 } | 3020 } |
| 3057 #endif | 3021 #endif |
| 3058 | 3022 |
| 3059 } // namespace content | 3023 } // namespace content |
| OLD | NEW |