Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 2349523002: Add support for edit commands in OOPIFs. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete()); 1254 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete());
1255 } 1255 }
1256 1256
1257 bool RenderViewImpl::DoesRenderWidgetHaveTouchEventHandlersAt( 1257 bool RenderViewImpl::DoesRenderWidgetHaveTouchEventHandlersAt(
1258 const gfx::Point& point) const { 1258 const gfx::Point& point) const {
1259 if (!webview()) 1259 if (!webview())
1260 return false; 1260 return false;
1261 return webview()->hasTouchEventHandlersAt(point); 1261 return webview()->hasTouchEventHandlersAt(point);
1262 } 1262 }
1263 1263
1264 void RenderViewImpl::RenderWidgetDidHandleKeyEvent() {
1265 ClearEditCommands();
1266 }
1267
1268 bool RenderViewImpl::RenderWidgetWillHandleGestureEvent( 1264 bool RenderViewImpl::RenderWidgetWillHandleGestureEvent(
1269 const blink::WebGestureEvent& event) { 1265 const blink::WebGestureEvent& event) {
1270 possible_drag_event_info_.event_source = 1266 possible_drag_event_info_.event_source =
1271 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; 1267 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH;
1272 possible_drag_event_info_.event_location = 1268 possible_drag_event_info_.event_location =
1273 gfx::Point(event.globalX, event.globalY); 1269 gfx::Point(event.globalX, event.globalY);
1274 return false; 1270 return false;
1275 } 1271 }
1276 1272
1277 bool RenderViewImpl::RenderWidgetWillHandleMouseEvent( 1273 bool RenderViewImpl::RenderWidgetWillHandleMouseEvent(
(...skipping 25 matching lines...) Expand all
1303 while ((observer = it.GetNext()) != NULL) 1299 while ((observer = it.GetNext()) != NULL)
1304 if (observer->OnMessageReceived(message)) 1300 if (observer->OnMessageReceived(message))
1305 return true; 1301 return true;
1306 1302
1307 bool handled = true; 1303 bool handled = true;
1308 IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message) 1304 IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message)
1309 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand) 1305 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand)
1310 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret) 1306 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret)
1311 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, 1307 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect,
1312 OnScrollFocusedEditableNodeIntoRect) 1308 OnScrollFocusedEditableNodeIntoRect)
1313 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent,
1314 OnSetEditCommandsForNextKeyEvent)
1315 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) 1309 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale)
1316 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) 1310 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
1317 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, 1311 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL,
1318 OnSetZoomLevelForLoadingURL) 1312 OnSetZoomLevelForLoadingURL)
1319 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) 1313 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
1320 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, 1314 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault,
1321 OnResetPageEncodingToDefault) 1315 OnResetPageEncodingToDefault)
1322 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) 1316 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
1323 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) 1317 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver)
1324 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) 1318 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave)
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 1421
1428 if (!webview()->scrollFocusedEditableElementIntoRect(rect)) 1422 if (!webview()->scrollFocusedEditableElementIntoRect(rect))
1429 return; 1423 return;
1430 1424
1431 rect_for_scrolled_focused_editable_node_ = rect; 1425 rect_for_scrolled_focused_editable_node_ = rect;
1432 has_scrolled_focused_editable_node_into_rect_ = true; 1426 has_scrolled_focused_editable_node_into_rect_ = true;
1433 if (!compositor()->hasPendingPageScaleAnimation()) 1427 if (!compositor()->hasPendingPageScaleAnimation())
1434 GetWidget()->FocusChangeComplete(); 1428 GetWidget()->FocusChangeComplete();
1435 } 1429 }
1436 1430
1437 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent(
1438 const EditCommands& edit_commands) {
1439 edit_commands_ = edit_commands;
1440 }
1441
1442 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, 1431 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset,
1443 int history_length) { 1432 int history_length) {
1444 DCHECK_GE(history_offset, -1); 1433 DCHECK_GE(history_offset, -1);
1445 DCHECK_GE(history_length, 0); 1434 DCHECK_GE(history_length, 0);
1446 1435
1447 history_list_offset_ = history_offset; 1436 history_list_offset_ = history_offset;
1448 history_list_length_ = history_length; 1437 history_list_length_ = history_length;
1449 } 1438 }
1450 1439
1451 void RenderViewImpl::OnSetInitialFocus(bool reverse) { 1440 void RenderViewImpl::OnSetInitialFocus(bool reverse) {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 page_zoom_level_ = zoom_level; 1659 page_zoom_level_ = zoom_level;
1671 1660
1672 webview()->setZoomLevel(zoom_level); 1661 webview()->setZoomLevel(zoom_level);
1673 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnZoomLevelChanged()); 1662 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnZoomLevelChanged());
1674 } 1663 }
1675 1664
1676 void RenderViewImpl::didCancelCompositionOnSelectionChange() { 1665 void RenderViewImpl::didCancelCompositionOnSelectionChange() {
1677 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID())); 1666 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID()));
1678 } 1667 }
1679 1668
1680 bool RenderViewImpl::handleCurrentKeyboardEvent() {
1681 if (edit_commands_.empty())
1682 return false;
1683
1684 WebLocalFrame* frame = webview()->focusedFrame();
1685
1686 EditCommands::iterator it = edit_commands_.begin();
1687 EditCommands::iterator end = edit_commands_.end();
1688
1689 bool did_execute_command = false;
1690 for (; it != end; ++it) {
1691 // In gtk and cocoa, it's possible to bind multiple edit commands to one
1692 // key (but it's the exception). Once one edit command is not executed, it
1693 // seems safest to not execute the rest.
1694 if (!frame->executeCommand(WebString::fromUTF8(it->name),
1695 WebString::fromUTF8(it->value)))
1696 break;
1697 did_execute_command = true;
1698 }
1699
1700 return did_execute_command;
1701 }
1702
1703 void RenderViewImpl::SetValidationMessageDirection( 1669 void RenderViewImpl::SetValidationMessageDirection(
1704 base::string16* wrapped_main_text, 1670 base::string16* wrapped_main_text,
1705 blink::WebTextDirection main_text_hint, 1671 blink::WebTextDirection main_text_hint,
1706 base::string16* wrapped_sub_text, 1672 base::string16* wrapped_sub_text,
1707 blink::WebTextDirection sub_text_hint) { 1673 blink::WebTextDirection sub_text_hint) {
1708 if (main_text_hint == blink::WebTextDirectionLeftToRight) { 1674 if (main_text_hint == blink::WebTextDirectionLeftToRight) {
1709 *wrapped_main_text = 1675 *wrapped_main_text =
1710 base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_main_text); 1676 base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_main_text);
1711 } else if (main_text_hint == blink::WebTextDirectionRightToLeft && 1677 } else if (main_text_hint == blink::WebTextDirectionRightToLeft &&
1712 !base::i18n::IsRTL()) { 1678 !base::i18n::IsRTL()) {
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 } 2061 }
2096 2062
2097 // blink::WebFrameClient ----------------------------------------------------- 2063 // blink::WebFrameClient -----------------------------------------------------
2098 2064
2099 void RenderViewImpl::Repaint(const gfx::Size& size) { 2065 void RenderViewImpl::Repaint(const gfx::Size& size) {
2100 OnRepaint(size); 2066 OnRepaint(size);
2101 } 2067 }
2102 2068
2103 void RenderViewImpl::SetEditCommandForNextKeyEvent(const std::string& name, 2069 void RenderViewImpl::SetEditCommandForNextKeyEvent(const std::string& name,
2104 const std::string& value) { 2070 const std::string& value) {
2105 EditCommands edit_commands; 2071 GetWidget()->SetEditCommandForNextKeyEvent(name, value);
2106 edit_commands.push_back(EditCommand(name, value));
2107 OnSetEditCommandsForNextKeyEvent(edit_commands);
2108 } 2072 }
2109 2073
2110 void RenderViewImpl::ClearEditCommands() { 2074 void RenderViewImpl::ClearEditCommands() {
2111 edit_commands_.clear(); 2075 GetWidget()->ClearEditCommands();
2112 } 2076 }
2113 2077
2114 const std::string& RenderViewImpl::GetAcceptLanguages() const { 2078 const std::string& RenderViewImpl::GetAcceptLanguages() const {
2115 return renderer_preferences_.accept_languages; 2079 return renderer_preferences_.accept_languages;
2116 } 2080 }
2117 2081
2118 void RenderViewImpl::ConvertViewportToWindowViaWidget(blink::WebRect* rect) { 2082 void RenderViewImpl::ConvertViewportToWindowViaWidget(blink::WebRect* rect) {
2119 convertViewportToWindow(rect); 2083 convertViewportToWindow(rect);
2120 } 2084 }
2121 2085
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
3082 return render_frame->focused_pepper_plugin(); 3046 return render_frame->focused_pepper_plugin();
3083 } 3047 }
3084 frame = frame->traverseNext(false); 3048 frame = frame->traverseNext(false);
3085 } 3049 }
3086 3050
3087 return nullptr; 3051 return nullptr;
3088 } 3052 }
3089 #endif 3053 #endif
3090 3054
3091 } // namespace content 3055 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698