| 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_widget.h" | 5 #include "content/renderer/render_widget.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 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 WebSize visual_viewport_size; | 1064 WebSize visual_viewport_size; |
| 1065 | 1065 |
| 1066 if (IsUseZoomForDSFEnabled()) { | 1066 if (IsUseZoomForDSFEnabled()) { |
| 1067 visual_viewport_size = gfx::ScaleToCeiledSize( | 1067 visual_viewport_size = gfx::ScaleToCeiledSize( |
| 1068 params.visible_viewport_size, | 1068 params.visible_viewport_size, |
| 1069 GetOriginalDeviceScaleFactor()); | 1069 GetOriginalDeviceScaleFactor()); |
| 1070 } else { | 1070 } else { |
| 1071 visual_viewport_size = visible_viewport_size_; | 1071 visual_viewport_size = visible_viewport_size_; |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 webwidget()->resizeVisualViewport(visual_viewport_size); | 1074 GetWebWidget()->resizeVisualViewport(visual_viewport_size); |
| 1075 | 1075 |
| 1076 // When resizing, we want to wait to paint before ACK'ing the resize. This | 1076 // When resizing, we want to wait to paint before ACK'ing the resize. This |
| 1077 // ensures that we only resize as fast as we can paint. We only need to | 1077 // ensures that we only resize as fast as we can paint. We only need to |
| 1078 // send an ACK if we are resized to a non-empty rect. | 1078 // send an ACK if we are resized to a non-empty rect. |
| 1079 if (params.new_size.IsEmpty() || params.physical_backing_size.IsEmpty()) { | 1079 if (params.new_size.IsEmpty() || params.physical_backing_size.IsEmpty()) { |
| 1080 // In this case there is no paint/composite and therefore no | 1080 // In this case there is no paint/composite and therefore no |
| 1081 // ViewHostMsg_UpdateRect to send the resize ack with. We'd need to send the | 1081 // ViewHostMsg_UpdateRect to send the resize ack with. We'd need to send the |
| 1082 // ack through a fake ViewHostMsg_UpdateRect or a different message. | 1082 // ack through a fake ViewHostMsg_UpdateRect or a different message. |
| 1083 DCHECK(!params.needs_resize_ack); | 1083 DCHECK(!params.needs_resize_ack); |
| 1084 } | 1084 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 | 1137 |
| 1138 void RenderWidget::WillCloseLayerTreeView() { | 1138 void RenderWidget::WillCloseLayerTreeView() { |
| 1139 if (host_closing_) | 1139 if (host_closing_) |
| 1140 return; | 1140 return; |
| 1141 | 1141 |
| 1142 // Prevent new compositors or output surfaces from being created. | 1142 // Prevent new compositors or output surfaces from being created. |
| 1143 host_closing_ = true; | 1143 host_closing_ = true; |
| 1144 | 1144 |
| 1145 // Always send this notification to prevent new layer tree views from | 1145 // Always send this notification to prevent new layer tree views from |
| 1146 // being created, even if one hasn't been created yet. | 1146 // being created, even if one hasn't been created yet. |
| 1147 if (webwidget_) | 1147 if (GetWebWidget()) |
| 1148 webwidget_->willCloseLayerTreeView(); | 1148 GetWebWidget()->willCloseLayerTreeView(); |
| 1149 } | 1149 } |
| 1150 | 1150 |
| 1151 blink::WebLayerTreeView* RenderWidget::layerTreeView() { | 1151 blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
| 1152 return compositor_.get(); | 1152 return compositor_.get(); |
| 1153 } | 1153 } |
| 1154 | 1154 |
| 1155 void RenderWidget::didMeaningfulLayout(blink::WebMeaningfulLayout layout_type) { | 1155 void RenderWidget::didMeaningfulLayout(blink::WebMeaningfulLayout layout_type) { |
| 1156 if (layout_type == blink::WebMeaningfulLayout::VisuallyNonEmpty) { | 1156 if (layout_type == blink::WebMeaningfulLayout::VisuallyNonEmpty) { |
| 1157 QueueMessage(new ViewHostMsg_DidFirstVisuallyNonEmptyPaint(routing_id_), | 1157 QueueMessage(new ViewHostMsg_DidFirstVisuallyNonEmptyPaint(routing_id_), |
| 1158 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); | 1158 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 const gfx::Range& replacement_range, | 1374 const gfx::Range& replacement_range, |
| 1375 int selection_start, int selection_end) { | 1375 int selection_start, int selection_end) { |
| 1376 #if defined(ENABLE_PLUGINS) | 1376 #if defined(ENABLE_PLUGINS) |
| 1377 if (focused_pepper_plugin_) { | 1377 if (focused_pepper_plugin_) { |
| 1378 focused_pepper_plugin_->render_frame()->OnImeSetComposition( | 1378 focused_pepper_plugin_->render_frame()->OnImeSetComposition( |
| 1379 text, underlines, selection_start, selection_end); | 1379 text, underlines, selection_start, selection_end); |
| 1380 return; | 1380 return; |
| 1381 } | 1381 } |
| 1382 #endif | 1382 #endif |
| 1383 if (replacement_range.IsValid()) { | 1383 if (replacement_range.IsValid()) { |
| 1384 webwidget_->applyReplacementRange(replacement_range.start(), | 1384 GetWebWidget()->applyReplacementRange(replacement_range.start(), |
| 1385 replacement_range.length()); | 1385 replacement_range.length()); |
| 1386 } | 1386 } |
| 1387 | 1387 |
| 1388 if (!ShouldHandleImeEvent()) | 1388 if (!ShouldHandleImeEvent()) |
| 1389 return; | 1389 return; |
| 1390 ImeEventGuard guard(this); | 1390 ImeEventGuard guard(this); |
| 1391 if (!webwidget_->setComposition( | 1391 if (!GetWebWidget()->setComposition( |
| 1392 text, WebVector<WebCompositionUnderline>(underlines), | 1392 text, WebVector<WebCompositionUnderline>(underlines), selection_start, |
| 1393 selection_start, selection_end)) { | 1393 selection_end)) { |
| 1394 // If we failed to set the composition text, then we need to let the browser | 1394 // If we failed to set the composition text, then we need to let the browser |
| 1395 // process to cancel the input method's ongoing composition session, to make | 1395 // process to cancel the input method's ongoing composition session, to make |
| 1396 // sure we are in a consistent state. | 1396 // sure we are in a consistent state. |
| 1397 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 1397 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
| 1398 } | 1398 } |
| 1399 UpdateCompositionInfo(false /* not an immediate request */); | 1399 UpdateCompositionInfo(false /* not an immediate request */); |
| 1400 } | 1400 } |
| 1401 | 1401 |
| 1402 void RenderWidget::OnImeConfirmComposition(const base::string16& text, | 1402 void RenderWidget::OnImeConfirmComposition(const base::string16& text, |
| 1403 const gfx::Range& replacement_range, | 1403 const gfx::Range& replacement_range, |
| 1404 bool keep_selection) { | 1404 bool keep_selection) { |
| 1405 #if defined(ENABLE_PLUGINS) | 1405 #if defined(ENABLE_PLUGINS) |
| 1406 if (focused_pepper_plugin_) { | 1406 if (focused_pepper_plugin_) { |
| 1407 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition( | 1407 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition( |
| 1408 text, replacement_range, keep_selection); | 1408 text, replacement_range, keep_selection); |
| 1409 return; | 1409 return; |
| 1410 } | 1410 } |
| 1411 #endif | 1411 #endif |
| 1412 if (replacement_range.IsValid()) { | 1412 if (replacement_range.IsValid()) { |
| 1413 webwidget_->applyReplacementRange(replacement_range.start(), | 1413 GetWebWidget()->applyReplacementRange(replacement_range.start(), |
| 1414 replacement_range.length()); | 1414 replacement_range.length()); |
| 1415 } | 1415 } |
| 1416 | 1416 |
| 1417 if (!ShouldHandleImeEvent()) | 1417 if (!ShouldHandleImeEvent()) |
| 1418 return; | 1418 return; |
| 1419 ImeEventGuard guard(this); | 1419 ImeEventGuard guard(this); |
| 1420 input_handler_->set_handling_input_event(true); | 1420 input_handler_->set_handling_input_event(true); |
| 1421 if (text.length()) | 1421 if (text.length()) |
| 1422 webwidget_->confirmComposition(text); | 1422 GetWebWidget()->confirmComposition(text); |
| 1423 else if (keep_selection) | 1423 else if (keep_selection) |
| 1424 webwidget_->confirmComposition(WebWidget::KeepSelection); | 1424 GetWebWidget()->confirmComposition(WebWidget::KeepSelection); |
| 1425 else | 1425 else |
| 1426 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection); | 1426 GetWebWidget()->confirmComposition(WebWidget::DoNotKeepSelection); |
| 1427 input_handler_->set_handling_input_event(false); | 1427 input_handler_->set_handling_input_event(false); |
| 1428 UpdateCompositionInfo(false /* not an immediate request */); | 1428 UpdateCompositionInfo(false /* not an immediate request */); |
| 1429 } | 1429 } |
| 1430 | 1430 |
| 1431 void RenderWidget::OnDeviceScaleFactorChanged() { | 1431 void RenderWidget::OnDeviceScaleFactorChanged() { |
| 1432 if (!compositor_) | 1432 if (!compositor_) |
| 1433 return; | 1433 return; |
| 1434 if (IsUseZoomForDSFEnabled()) | 1434 if (IsUseZoomForDSFEnabled()) |
| 1435 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor()); | 1435 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor()); |
| 1436 else | 1436 else |
| 1437 compositor_->setDeviceScaleFactor(device_scale_factor_); | 1437 compositor_->setDeviceScaleFactor(device_scale_factor_); |
| 1438 } | 1438 } |
| 1439 | 1439 |
| 1440 void RenderWidget::OnRepaint(gfx::Size size_to_paint) { | 1440 void RenderWidget::OnRepaint(gfx::Size size_to_paint) { |
| 1441 // During shutdown we can just ignore this message. | 1441 // During shutdown we can just ignore this message. |
| 1442 if (!webwidget_) | 1442 if (!GetWebWidget()) |
| 1443 return; | 1443 return; |
| 1444 | 1444 |
| 1445 // Even if the browser provides an empty damage rect, it's still expecting to | 1445 // Even if the browser provides an empty damage rect, it's still expecting to |
| 1446 // receive a repaint ack so just damage the entire widget bounds. | 1446 // receive a repaint ack so just damage the entire widget bounds. |
| 1447 if (size_to_paint.IsEmpty()) { | 1447 if (size_to_paint.IsEmpty()) { |
| 1448 size_to_paint = size_; | 1448 size_to_paint = size_; |
| 1449 } | 1449 } |
| 1450 | 1450 |
| 1451 set_next_paint_is_repaint_ack(); | 1451 set_next_paint_is_repaint_ack(); |
| 1452 if (compositor_) | 1452 if (compositor_) |
| 1453 compositor_->SetNeedsRedrawRect(gfx::Rect(size_to_paint)); | 1453 compositor_->SetNeedsRedrawRect(gfx::Rect(size_to_paint)); |
| 1454 } | 1454 } |
| 1455 | 1455 |
| 1456 void RenderWidget::OnSyntheticGestureCompleted() { | 1456 void RenderWidget::OnSyntheticGestureCompleted() { |
| 1457 DCHECK(!pending_synthetic_gesture_callbacks_.empty()); | 1457 DCHECK(!pending_synthetic_gesture_callbacks_.empty()); |
| 1458 | 1458 |
| 1459 pending_synthetic_gesture_callbacks_.front().Run(); | 1459 pending_synthetic_gesture_callbacks_.front().Run(); |
| 1460 pending_synthetic_gesture_callbacks_.pop(); | 1460 pending_synthetic_gesture_callbacks_.pop(); |
| 1461 } | 1461 } |
| 1462 | 1462 |
| 1463 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { | 1463 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { |
| 1464 if (!webwidget_) | 1464 if (!GetWebWidget()) |
| 1465 return; | 1465 return; |
| 1466 webwidget_->setTextDirection(direction); | 1466 GetWebWidget()->setTextDirection(direction); |
| 1467 } | 1467 } |
| 1468 | 1468 |
| 1469 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, | 1469 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, |
| 1470 const gfx::Rect& window_screen_rect) { | 1470 const gfx::Rect& window_screen_rect) { |
| 1471 if (screen_metrics_emulator_) { | 1471 if (screen_metrics_emulator_) { |
| 1472 screen_metrics_emulator_->OnUpdateScreenRects(view_screen_rect, | 1472 screen_metrics_emulator_->OnUpdateScreenRects(view_screen_rect, |
| 1473 window_screen_rect); | 1473 window_screen_rect); |
| 1474 } else { | 1474 } else { |
| 1475 SetScreenRects(view_screen_rect, window_screen_rect); | 1475 SetScreenRects(view_screen_rect, window_screen_rect); |
| 1476 } | 1476 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1498 | 1498 |
| 1499 void RenderWidget::showImeIfNeeded() { | 1499 void RenderWidget::showImeIfNeeded() { |
| 1500 OnShowImeIfNeeded(); | 1500 OnShowImeIfNeeded(); |
| 1501 } | 1501 } |
| 1502 | 1502 |
| 1503 ui::TextInputType RenderWidget::GetTextInputType() { | 1503 ui::TextInputType RenderWidget::GetTextInputType() { |
| 1504 #if defined(ENABLE_PLUGINS) | 1504 #if defined(ENABLE_PLUGINS) |
| 1505 if (focused_pepper_plugin_) | 1505 if (focused_pepper_plugin_) |
| 1506 return focused_pepper_plugin_->text_input_type(); | 1506 return focused_pepper_plugin_->text_input_type(); |
| 1507 #endif | 1507 #endif |
| 1508 if (webwidget_) | 1508 if (GetWebWidget()) |
| 1509 return WebKitToUiTextInputType(webwidget_->textInputType()); | 1509 return WebKitToUiTextInputType(GetWebWidget()->textInputType()); |
| 1510 return ui::TEXT_INPUT_TYPE_NONE; | 1510 return ui::TEXT_INPUT_TYPE_NONE; |
| 1511 } | 1511 } |
| 1512 | 1512 |
| 1513 void RenderWidget::UpdateCompositionInfo(bool immediate_request) { | 1513 void RenderWidget::UpdateCompositionInfo(bool immediate_request) { |
| 1514 if (!monitor_composition_info_ && !immediate_request) | 1514 if (!monitor_composition_info_ && !immediate_request) |
| 1515 return; // Do not calculate composition info if not requested. | 1515 return; // Do not calculate composition info if not requested. |
| 1516 | 1516 |
| 1517 TRACE_EVENT0("renderer", "RenderWidget::UpdateCompositionInfo"); | 1517 TRACE_EVENT0("renderer", "RenderWidget::UpdateCompositionInfo"); |
| 1518 gfx::Range range; | 1518 gfx::Range range; |
| 1519 std::vector<gfx::Rect> character_bounds; | 1519 std::vector<gfx::Rect> character_bounds; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request, | 1591 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request, |
| 1592 bool monitor_request) { | 1592 bool monitor_request) { |
| 1593 monitor_composition_info_ = monitor_request; | 1593 monitor_composition_info_ = monitor_request; |
| 1594 if (!immediate_request) | 1594 if (!immediate_request) |
| 1595 return; | 1595 return; |
| 1596 UpdateCompositionInfo(true /* immediate request */); | 1596 UpdateCompositionInfo(true /* immediate request */); |
| 1597 } | 1597 } |
| 1598 | 1598 |
| 1599 bool RenderWidget::ShouldHandleImeEvent() { | 1599 bool RenderWidget::ShouldHandleImeEvent() { |
| 1600 #if defined(OS_ANDROID) | 1600 #if defined(OS_ANDROID) |
| 1601 if (!webwidget_) | 1601 if (!GetWebWidget()) |
| 1602 return false; | 1602 return false; |
| 1603 if (IsUsingImeThread()) | 1603 if (IsUsingImeThread()) |
| 1604 return true; | 1604 return true; |
| 1605 | 1605 |
| 1606 // We cannot handle IME events if there is any chance that the event we are | 1606 // We cannot handle IME events if there is any chance that the event we are |
| 1607 // receiving here from the browser is based on the state that is different | 1607 // receiving here from the browser is based on the state that is different |
| 1608 // from our current one as indicated by |text_input_info_|. | 1608 // from our current one as indicated by |text_input_info_|. |
| 1609 // The states the browser might be in are: | 1609 // The states the browser might be in are: |
| 1610 // text_input_info_history_[0] - current state ack'd by browser | 1610 // text_input_info_history_[0] - current state ack'd by browser |
| 1611 // text_input_info_history_[1...N] - pending state changes | 1611 // text_input_info_history_[1...N] - pending state changes |
| 1612 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) { | 1612 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) { |
| 1613 if (text_input_info_history_[i] != text_input_info_) | 1613 if (text_input_info_history_[i] != text_input_info_) |
| 1614 return false; | 1614 return false; |
| 1615 } | 1615 } |
| 1616 return true; | 1616 return true; |
| 1617 #else | 1617 #else |
| 1618 return !!webwidget_; | 1618 return !!GetWebWidget(); |
| 1619 #endif | 1619 #endif |
| 1620 } | 1620 } |
| 1621 | 1621 |
| 1622 void RenderWidget::OnSetDeviceScaleFactor(float device_scale_factor) { | 1622 void RenderWidget::OnSetDeviceScaleFactor(float device_scale_factor) { |
| 1623 if (device_scale_factor_ == device_scale_factor) | 1623 if (device_scale_factor_ == device_scale_factor) |
| 1624 return; | 1624 return; |
| 1625 | 1625 |
| 1626 device_scale_factor_ = device_scale_factor; | 1626 device_scale_factor_ = device_scale_factor; |
| 1627 | 1627 |
| 1628 OnDeviceScaleFactorChanged(); | 1628 OnDeviceScaleFactorChanged(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 if (is_hidden_) | 1664 if (is_hidden_) |
| 1665 RenderThreadImpl::current()->WidgetHidden(); | 1665 RenderThreadImpl::current()->WidgetHidden(); |
| 1666 else | 1666 else |
| 1667 RenderThreadImpl::current()->WidgetRestored(); | 1667 RenderThreadImpl::current()->WidgetRestored(); |
| 1668 | 1668 |
| 1669 if (render_widget_scheduling_state_) | 1669 if (render_widget_scheduling_state_) |
| 1670 render_widget_scheduling_state_->SetHidden(hidden); | 1670 render_widget_scheduling_state_->SetHidden(hidden); |
| 1671 } | 1671 } |
| 1672 | 1672 |
| 1673 void RenderWidget::DidToggleFullscreen() { | 1673 void RenderWidget::DidToggleFullscreen() { |
| 1674 if (!webwidget_) | 1674 if (!GetWebWidget()) |
| 1675 return; | 1675 return; |
| 1676 | 1676 |
| 1677 if (is_fullscreen_granted_) { | 1677 if (is_fullscreen_granted_) { |
| 1678 webwidget_->didEnterFullscreen(); | 1678 GetWebWidget()->didEnterFullscreen(); |
| 1679 } else { | 1679 } else { |
| 1680 webwidget_->didExitFullscreen(); | 1680 GetWebWidget()->didExitFullscreen(); |
| 1681 } | 1681 } |
| 1682 } | 1682 } |
| 1683 | 1683 |
| 1684 bool RenderWidget::next_paint_is_resize_ack() const { | 1684 bool RenderWidget::next_paint_is_resize_ack() const { |
| 1685 return ViewHostMsg_UpdateRect_Flags::is_resize_ack(next_paint_flags_); | 1685 return ViewHostMsg_UpdateRect_Flags::is_resize_ack(next_paint_flags_); |
| 1686 } | 1686 } |
| 1687 | 1687 |
| 1688 void RenderWidget::set_next_paint_is_resize_ack() { | 1688 void RenderWidget::set_next_paint_is_resize_ack() { |
| 1689 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK; | 1689 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK; |
| 1690 } | 1690 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1741 // after Pepper API equips features related to surrounding text retrieval. | 1741 // after Pepper API equips features related to surrounding text retrieval. |
| 1742 blink::WebRect caret(focused_pepper_plugin_->GetCaretBounds()); | 1742 blink::WebRect caret(focused_pepper_plugin_->GetCaretBounds()); |
| 1743 convertViewportToWindow(&caret); | 1743 convertViewportToWindow(&caret); |
| 1744 *focus = caret; | 1744 *focus = caret; |
| 1745 *anchor = caret; | 1745 *anchor = caret; |
| 1746 return; | 1746 return; |
| 1747 } | 1747 } |
| 1748 #endif | 1748 #endif |
| 1749 WebRect focus_webrect; | 1749 WebRect focus_webrect; |
| 1750 WebRect anchor_webrect; | 1750 WebRect anchor_webrect; |
| 1751 webwidget_->selectionBounds(focus_webrect, anchor_webrect); | 1751 GetWebWidget()->selectionBounds(focus_webrect, anchor_webrect); |
| 1752 convertViewportToWindow(&focus_webrect); | 1752 convertViewportToWindow(&focus_webrect); |
| 1753 convertViewportToWindow(&anchor_webrect); | 1753 convertViewportToWindow(&anchor_webrect); |
| 1754 *focus = focus_webrect; | 1754 *focus = focus_webrect; |
| 1755 *anchor = anchor_webrect; | 1755 *anchor = anchor_webrect; |
| 1756 } | 1756 } |
| 1757 | 1757 |
| 1758 void RenderWidget::UpdateSelectionBounds() { | 1758 void RenderWidget::UpdateSelectionBounds() { |
| 1759 TRACE_EVENT0("renderer", "RenderWidget::UpdateSelectionBounds"); | 1759 TRACE_EVENT0("renderer", "RenderWidget::UpdateSelectionBounds"); |
| 1760 if (!webwidget_) | 1760 if (!GetWebWidget()) |
| 1761 return; | 1761 return; |
| 1762 if (ime_event_guard_) | 1762 if (ime_event_guard_) |
| 1763 return; | 1763 return; |
| 1764 | 1764 |
| 1765 #if defined(USE_AURA) | 1765 #if defined(USE_AURA) |
| 1766 // TODO(mohsen): For now, always send explicit selection IPC notifications for | 1766 // TODO(mohsen): For now, always send explicit selection IPC notifications for |
| 1767 // Aura beucause composited selection updates are not working for webview tags | 1767 // Aura beucause composited selection updates are not working for webview tags |
| 1768 // which regresses IME inside webview. Remove this when composited selection | 1768 // which regresses IME inside webview. Remove this when composited selection |
| 1769 // updates are fixed for webviews. See, http://crbug.com/510568. | 1769 // updates are fixed for webviews. See, http://crbug.com/510568. |
| 1770 bool send_ipc = true; | 1770 bool send_ipc = true; |
| 1771 #else | 1771 #else |
| 1772 // With composited selection updates, the selection bounds will be reported | 1772 // With composited selection updates, the selection bounds will be reported |
| 1773 // directly by the compositor, in which case explicit IPC selection | 1773 // directly by the compositor, in which case explicit IPC selection |
| 1774 // notifications should be suppressed. | 1774 // notifications should be suppressed. |
| 1775 bool send_ipc = | 1775 bool send_ipc = |
| 1776 !blink::WebRuntimeFeatures::isCompositedSelectionUpdateEnabled(); | 1776 !blink::WebRuntimeFeatures::isCompositedSelectionUpdateEnabled(); |
| 1777 #endif | 1777 #endif |
| 1778 if (send_ipc) { | 1778 if (send_ipc) { |
| 1779 ViewHostMsg_SelectionBounds_Params params; | 1779 ViewHostMsg_SelectionBounds_Params params; |
| 1780 GetSelectionBounds(¶ms.anchor_rect, ¶ms.focus_rect); | 1780 GetSelectionBounds(¶ms.anchor_rect, ¶ms.focus_rect); |
| 1781 if (selection_anchor_rect_ != params.anchor_rect || | 1781 if (selection_anchor_rect_ != params.anchor_rect || |
| 1782 selection_focus_rect_ != params.focus_rect) { | 1782 selection_focus_rect_ != params.focus_rect) { |
| 1783 selection_anchor_rect_ = params.anchor_rect; | 1783 selection_anchor_rect_ = params.anchor_rect; |
| 1784 selection_focus_rect_ = params.focus_rect; | 1784 selection_focus_rect_ = params.focus_rect; |
| 1785 webwidget_->selectionTextDirection(params.focus_dir, params.anchor_dir); | 1785 GetWebWidget()->selectionTextDirection(params.focus_dir, |
| 1786 params.is_anchor_first = webwidget_->isSelectionAnchorFirst(); | 1786 params.anchor_dir); |
| 1787 params.is_anchor_first = GetWebWidget()->isSelectionAnchorFirst(); |
| 1787 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params)); | 1788 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params)); |
| 1788 } | 1789 } |
| 1789 } | 1790 } |
| 1790 | 1791 |
| 1791 UpdateCompositionInfo(false /* not an immediate request */); | 1792 UpdateCompositionInfo(false /* not an immediate request */); |
| 1792 } | 1793 } |
| 1793 | 1794 |
| 1794 void RenderWidget::SetDeviceColorProfileForTesting( | 1795 void RenderWidget::SetDeviceColorProfileForTesting( |
| 1795 const std::vector<char>& color_profile) { | 1796 const std::vector<char>& color_profile) { |
| 1796 SetDeviceColorProfile(color_profile); | 1797 SetDeviceColorProfile(color_profile); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1854 void RenderWidget::GetCompositionCharacterBounds( | 1855 void RenderWidget::GetCompositionCharacterBounds( |
| 1855 std::vector<gfx::Rect>* bounds) { | 1856 std::vector<gfx::Rect>* bounds) { |
| 1856 DCHECK(bounds); | 1857 DCHECK(bounds); |
| 1857 bounds->clear(); | 1858 bounds->clear(); |
| 1858 | 1859 |
| 1859 #if defined(ENABLE_PLUGINS) | 1860 #if defined(ENABLE_PLUGINS) |
| 1860 if (focused_pepper_plugin_) | 1861 if (focused_pepper_plugin_) |
| 1861 return; | 1862 return; |
| 1862 #endif | 1863 #endif |
| 1863 | 1864 |
| 1864 if (!webwidget_) | 1865 if (!GetWebWidget()) |
| 1865 return; | 1866 return; |
| 1866 blink::WebVector<blink::WebRect> bounds_from_blink; | 1867 blink::WebVector<blink::WebRect> bounds_from_blink; |
| 1867 if (!webwidget_->getCompositionCharacterBounds(bounds_from_blink)) | 1868 if (!GetWebWidget()->getCompositionCharacterBounds(bounds_from_blink)) |
| 1868 return; | 1869 return; |
| 1869 | 1870 |
| 1870 for (size_t i = 0; i < bounds_from_blink.size(); ++i) { | 1871 for (size_t i = 0; i < bounds_from_blink.size(); ++i) { |
| 1871 convertViewportToWindow(&bounds_from_blink[i]); | 1872 convertViewportToWindow(&bounds_from_blink[i]); |
| 1872 bounds->push_back(bounds_from_blink[i]); | 1873 bounds->push_back(bounds_from_blink[i]); |
| 1873 } | 1874 } |
| 1874 } | 1875 } |
| 1875 | 1876 |
| 1876 void RenderWidget::GetCompositionRange(gfx::Range* range) { | 1877 void RenderWidget::GetCompositionRange(gfx::Range* range) { |
| 1877 #if defined(ENABLE_PLUGINS) | 1878 #if defined(ENABLE_PLUGINS) |
| 1878 if (focused_pepper_plugin_) | 1879 if (focused_pepper_plugin_) |
| 1879 return; | 1880 return; |
| 1880 #endif | 1881 #endif |
| 1881 size_t location, length; | 1882 size_t location, length; |
| 1882 if (webwidget_->compositionRange(&location, &length)) { | 1883 if (GetWebWidget()->compositionRange(&location, &length)) { |
| 1883 range->set_start(location); | 1884 range->set_start(location); |
| 1884 range->set_end(location + length); | 1885 range->set_end(location + length); |
| 1885 } else { | 1886 } else { |
| 1886 WebRange web_range = webwidget_->caretOrSelectionRange(); | 1887 WebRange web_range = webwidget_->caretOrSelectionRange(); |
| 1887 range->set_start(web_range.startOffset()); | 1888 range->set_start(web_range.startOffset()); |
| 1888 range->set_end(web_range.endOffset()); | 1889 range->set_end(web_range.endOffset()); |
| 1889 } | 1890 } |
| 1890 } | 1891 } |
| 1891 | 1892 |
| 1892 bool RenderWidget::ShouldUpdateCompositionInfo( | 1893 bool RenderWidget::ShouldUpdateCompositionInfo( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1915 return screen_info_; | 1916 return screen_info_; |
| 1916 } | 1917 } |
| 1917 | 1918 |
| 1918 void RenderWidget::resetInputMethod() { | 1919 void RenderWidget::resetInputMethod() { |
| 1919 ImeEventGuard guard(this); | 1920 ImeEventGuard guard(this); |
| 1920 // If the last text input type is not None, then we should finish any | 1921 // If the last text input type is not None, then we should finish any |
| 1921 // ongoing composition regardless of the new text input type. | 1922 // ongoing composition regardless of the new text input type. |
| 1922 if (text_input_info_.type != blink::WebTextInputTypeNone) { | 1923 if (text_input_info_.type != blink::WebTextInputTypeNone) { |
| 1923 // If a composition text exists, then we need to let the browser process | 1924 // If a composition text exists, then we need to let the browser process |
| 1924 // to cancel the input method's ongoing composition session. | 1925 // to cancel the input method's ongoing composition session. |
| 1925 if (webwidget_->confirmComposition()) | 1926 if (GetWebWidget()->confirmComposition()) |
| 1926 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 1927 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
| 1927 } | 1928 } |
| 1928 | 1929 |
| 1929 UpdateCompositionInfo(false /* not an immediate request */); | 1930 UpdateCompositionInfo(false /* not an immediate request */); |
| 1930 } | 1931 } |
| 1931 | 1932 |
| 1932 #if defined(OS_ANDROID) | 1933 #if defined(OS_ANDROID) |
| 1933 void RenderWidget::showUnhandledTapUIIfNeeded( | 1934 void RenderWidget::showUnhandledTapUIIfNeeded( |
| 1934 const WebPoint& tapped_position, | 1935 const WebPoint& tapped_position, |
| 1935 const WebNode& tapped_node, | 1936 const WebNode& tapped_node, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1947 | 1948 |
| 1948 void RenderWidget::didHandleGestureEvent( | 1949 void RenderWidget::didHandleGestureEvent( |
| 1949 const WebGestureEvent& event, | 1950 const WebGestureEvent& event, |
| 1950 bool event_cancelled) { | 1951 bool event_cancelled) { |
| 1951 #if defined(OS_ANDROID) || defined(USE_AURA) | 1952 #if defined(OS_ANDROID) || defined(USE_AURA) |
| 1952 if (event_cancelled) | 1953 if (event_cancelled) |
| 1953 return; | 1954 return; |
| 1954 if (event.type == WebInputEvent::GestureTap) { | 1955 if (event.type == WebInputEvent::GestureTap) { |
| 1955 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); | 1956 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); |
| 1956 } else if (event.type == WebInputEvent::GestureLongPress) { | 1957 } else if (event.type == WebInputEvent::GestureLongPress) { |
| 1957 DCHECK(webwidget_); | 1958 DCHECK(GetWebWidget()); |
| 1958 if (webwidget_->textInputInfo().value.isEmpty()) | 1959 if (GetWebWidget()->textInputInfo().value.isEmpty()) |
| 1959 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); | 1960 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); |
| 1960 else | 1961 else |
| 1961 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); | 1962 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); |
| 1962 } | 1963 } |
| 1963 #endif | 1964 #endif |
| 1964 } | 1965 } |
| 1965 | 1966 |
| 1966 void RenderWidget::didOverscroll( | 1967 void RenderWidget::didOverscroll( |
| 1967 const blink::WebFloatSize& overscrollDelta, | 1968 const blink::WebFloatSize& overscrollDelta, |
| 1968 const blink::WebFloatSize& accumulatedOverscroll, | 1969 const blink::WebFloatSize& accumulatedOverscroll, |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2086 | 2087 |
| 2087 void RenderWidget::requestPointerUnlock() { | 2088 void RenderWidget::requestPointerUnlock() { |
| 2088 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); | 2089 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); |
| 2089 } | 2090 } |
| 2090 | 2091 |
| 2091 bool RenderWidget::isPointerLocked() { | 2092 bool RenderWidget::isPointerLocked() { |
| 2092 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2093 return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 2093 webwidget_mouse_lock_target_.get()); | 2094 webwidget_mouse_lock_target_.get()); |
| 2094 } | 2095 } |
| 2095 | 2096 |
| 2097 blink::WebWidget* RenderWidget::GetWebWidget() const { |
| 2098 return webwidget_; |
| 2099 } |
| 2100 |
| 2096 } // namespace content | 2101 } // namespace content |
| OLD | NEW |