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