| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 resize_params.physical_backing_size = physical_backing_size_; | 582 resize_params.physical_backing_size = physical_backing_size_; |
| 583 resize_params.visible_viewport_size = visible_viewport_size_; | 583 resize_params.visible_viewport_size = visible_viewport_size_; |
| 584 resize_params.top_controls_shrink_blink_size = | 584 resize_params.top_controls_shrink_blink_size = |
| 585 top_controls_shrink_blink_size_; | 585 top_controls_shrink_blink_size_; |
| 586 resize_params.top_controls_height = top_controls_height_; | 586 resize_params.top_controls_height = top_controls_height_; |
| 587 resize_params.resizer_rect = resizer_rect_; | 587 resize_params.resizer_rect = resizer_rect_; |
| 588 resize_params.is_fullscreen_granted = is_fullscreen_granted_; | 588 resize_params.is_fullscreen_granted = is_fullscreen_granted_; |
| 589 resize_params.display_mode = display_mode_; | 589 resize_params.display_mode = display_mode_; |
| 590 screen_metrics_emulator_.reset(new RenderWidgetScreenMetricsEmulator( | 590 screen_metrics_emulator_.reset(new RenderWidgetScreenMetricsEmulator( |
| 591 this, params, resize_params, view_screen_rect_, window_screen_rect_)); | 591 this, params, resize_params, view_screen_rect_, window_screen_rect_)); |
| 592 screen_metrics_emulator_->Apply(); |
| 592 } else { | 593 } else { |
| 593 screen_metrics_emulator_->ChangeEmulationParams(params); | 594 screen_metrics_emulator_->ChangeEmulationParams(params); |
| 594 } | 595 } |
| 595 } | 596 } |
| 596 | 597 |
| 597 void RenderWidget::OnDisableDeviceEmulation() { | 598 void RenderWidget::OnDisableDeviceEmulation() { |
| 598 screen_metrics_emulator_.reset(); | 599 screen_metrics_emulator_.reset(); |
| 599 } | 600 } |
| 600 | 601 |
| 601 void RenderWidget::OnColorProfile(const std::vector<char>& color_profile) { | 602 void RenderWidget::OnColorProfile(const std::vector<char>& color_profile) { |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 // NOTE: We may have entered fullscreen mode without changing our size. | 1094 // NOTE: We may have entered fullscreen mode without changing our size. |
| 1094 bool fullscreen_change = | 1095 bool fullscreen_change = |
| 1095 is_fullscreen_granted_ != params.is_fullscreen_granted; | 1096 is_fullscreen_granted_ != params.is_fullscreen_granted; |
| 1096 is_fullscreen_granted_ = params.is_fullscreen_granted; | 1097 is_fullscreen_granted_ = params.is_fullscreen_granted; |
| 1097 display_mode_ = params.display_mode; | 1098 display_mode_ = params.display_mode; |
| 1098 | 1099 |
| 1099 webwidget_->setTopControlsHeight(params.top_controls_height, | 1100 webwidget_->setTopControlsHeight(params.top_controls_height, |
| 1100 top_controls_shrink_blink_size_); | 1101 top_controls_shrink_blink_size_); |
| 1101 | 1102 |
| 1102 if (resized) { | 1103 if (resized) { |
| 1103 gfx::Size new_widget_size = | 1104 gfx::Size new_widget_size = size_; |
| 1104 IsUseZoomForDSFEnabled() ? physical_backing_size_ : size_; | 1105 if (IsUseZoomForDSFEnabled()) { |
| 1106 new_widget_size = gfx::ScaleToCeiledSize(new_widget_size, |
| 1107 GetOriginalDeviceScaleFactor()); |
| 1108 } |
| 1105 // When resizing, we want to wait to paint before ACK'ing the resize. This | 1109 // When resizing, we want to wait to paint before ACK'ing the resize. This |
| 1106 // ensures that we only resize as fast as we can paint. We only need to | 1110 // ensures that we only resize as fast as we can paint. We only need to |
| 1107 // send an ACK if we are resized to a non-empty rect. | 1111 // send an ACK if we are resized to a non-empty rect. |
| 1108 webwidget_->resize(new_widget_size); | 1112 webwidget_->resize(new_widget_size); |
| 1109 } | 1113 } |
| 1110 WebSize visual_viewport_size; | 1114 WebSize visual_viewport_size; |
| 1111 | 1115 |
| 1112 if (IsUseZoomForDSFEnabled()) { | 1116 if (IsUseZoomForDSFEnabled()) { |
| 1113 visual_viewport_size = gfx::ScaleToCeiledSize(params.visible_viewport_size, | 1117 visual_viewport_size = gfx::ScaleToCeiledSize( |
| 1114 device_scale_factor_); | 1118 params.visible_viewport_size, |
| 1119 GetOriginalDeviceScaleFactor()); |
| 1115 } else { | 1120 } else { |
| 1116 visual_viewport_size = visible_viewport_size_; | 1121 visual_viewport_size = visible_viewport_size_; |
| 1117 } | 1122 } |
| 1118 | 1123 |
| 1119 webwidget()->resizeVisualViewport(visual_viewport_size); | 1124 webwidget()->resizeVisualViewport(visual_viewport_size); |
| 1120 | 1125 |
| 1121 if (params.new_size.IsEmpty() || params.physical_backing_size.IsEmpty()) { | 1126 if (params.new_size.IsEmpty() || params.physical_backing_size.IsEmpty()) { |
| 1122 // In this case there is no paint/composite and therefore no | 1127 // In this case there is no paint/composite and therefore no |
| 1123 // ViewHostMsg_UpdateRect to send the resize ack with. We'd need to send the | 1128 // ViewHostMsg_UpdateRect to send the resize ack with. We'd need to send the |
| 1124 // ack through a fake ViewHostMsg_UpdateRect or a different message. | 1129 // ack through a fake ViewHostMsg_UpdateRect or a different message. |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 webwidget_->confirmComposition(WebWidget::KeepSelection); | 1476 webwidget_->confirmComposition(WebWidget::KeepSelection); |
| 1472 else | 1477 else |
| 1473 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection); | 1478 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection); |
| 1474 input_handler_->set_handling_input_event(false); | 1479 input_handler_->set_handling_input_event(false); |
| 1475 UpdateCompositionInfo(true); | 1480 UpdateCompositionInfo(true); |
| 1476 } | 1481 } |
| 1477 | 1482 |
| 1478 void RenderWidget::OnDeviceScaleFactorChanged() { | 1483 void RenderWidget::OnDeviceScaleFactorChanged() { |
| 1479 if (!compositor_) | 1484 if (!compositor_) |
| 1480 return; | 1485 return; |
| 1481 | |
| 1482 if (IsUseZoomForDSFEnabled()) | 1486 if (IsUseZoomForDSFEnabled()) |
| 1483 compositor_->SetPaintedDeviceScaleFactor(device_scale_factor_); | 1487 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor()); |
| 1484 else | 1488 else |
| 1485 compositor_->setDeviceScaleFactor(device_scale_factor_); | 1489 compositor_->setDeviceScaleFactor(device_scale_factor_); |
| 1486 } | 1490 } |
| 1487 | 1491 |
| 1488 void RenderWidget::OnRepaint(gfx::Size size_to_paint) { | 1492 void RenderWidget::OnRepaint(gfx::Size size_to_paint) { |
| 1489 // During shutdown we can just ignore this message. | 1493 // During shutdown we can just ignore this message. |
| 1490 if (!webwidget_) | 1494 if (!webwidget_) |
| 1491 return; | 1495 return; |
| 1492 | 1496 |
| 1493 // Even if the browser provides an empty damage rect, it's still expecting to | 1497 // Even if the browser provides an empty damage rect, it's still expecting to |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 return; | 1568 return; |
| 1565 composition_character_bounds_ = character_bounds; | 1569 composition_character_bounds_ = character_bounds; |
| 1566 composition_range_ = range; | 1570 composition_range_ = range; |
| 1567 Send(new InputHostMsg_ImeCompositionRangeChanged( | 1571 Send(new InputHostMsg_ImeCompositionRangeChanged( |
| 1568 routing_id(), composition_range_, composition_character_bounds_)); | 1572 routing_id(), composition_range_, composition_character_bounds_)); |
| 1569 #endif | 1573 #endif |
| 1570 } | 1574 } |
| 1571 | 1575 |
| 1572 void RenderWidget::convertViewportToWindow(blink::WebRect* rect) { | 1576 void RenderWidget::convertViewportToWindow(blink::WebRect* rect) { |
| 1573 if (IsUseZoomForDSFEnabled()) { | 1577 if (IsUseZoomForDSFEnabled()) { |
| 1574 float reverse = 1 / device_scale_factor_; | 1578 float reverse = 1 / GetOriginalDeviceScaleFactor(); |
| 1575 // TODO(oshima): We may need to allow pixel precision here as the the | 1579 // TODO(oshima): We may need to allow pixel precision here as the the |
| 1576 // anchor element can be placed at half pixel. | 1580 // anchor element can be placed at half pixel. |
| 1577 gfx::Rect window_rect = | 1581 gfx::Rect window_rect = |
| 1578 gfx::ScaleToEnclosedRect(gfx::Rect(*rect), reverse); | 1582 gfx::ScaleToEnclosedRect(gfx::Rect(*rect), reverse); |
| 1579 rect->x = window_rect.x(); | 1583 rect->x = window_rect.x(); |
| 1580 rect->y = window_rect.y(); | 1584 rect->y = window_rect.y(); |
| 1581 rect->width = window_rect.width(); | 1585 rect->width = window_rect.width(); |
| 1582 rect->height = window_rect.height(); | 1586 rect->height = window_rect.height(); |
| 1583 } | 1587 } |
| 1584 } | 1588 } |
| 1585 | 1589 |
| 1586 void RenderWidget::convertWindowToViewport(blink::WebFloatRect* rect) { | 1590 void RenderWidget::convertWindowToViewport(blink::WebFloatRect* rect) { |
| 1587 if (IsUseZoomForDSFEnabled()) { | 1591 if (IsUseZoomForDSFEnabled()) { |
| 1588 rect->x *= device_scale_factor_; | 1592 rect->x *= GetOriginalDeviceScaleFactor(); |
| 1589 rect->y *= device_scale_factor_; | 1593 rect->y *= GetOriginalDeviceScaleFactor(); |
| 1590 rect->width *= device_scale_factor_; | 1594 rect->width *= GetOriginalDeviceScaleFactor(); |
| 1591 rect->height *= device_scale_factor_; | 1595 rect->height *= GetOriginalDeviceScaleFactor(); |
| 1592 } | 1596 } |
| 1593 } | 1597 } |
| 1594 | 1598 |
| 1595 void RenderWidget::OnShowImeIfNeeded() { | 1599 void RenderWidget::OnShowImeIfNeeded() { |
| 1596 #if defined(OS_ANDROID) || defined(USE_AURA) | 1600 #if defined(OS_ANDROID) || defined(USE_AURA) |
| 1597 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); | 1601 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); |
| 1598 #endif | 1602 #endif |
| 1599 | 1603 |
| 1600 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with | 1604 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with |
| 1601 // virtual keyboard. | 1605 // virtual keyboard. |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2112 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2116 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2113 video_hole_frames_.RemoveObserver(frame); | 2117 video_hole_frames_.RemoveObserver(frame); |
| 2114 } | 2118 } |
| 2115 #endif // defined(VIDEO_HOLE) | 2119 #endif // defined(VIDEO_HOLE) |
| 2116 | 2120 |
| 2117 void RenderWidget::OnWaitNextFrameForTests(int routing_id) { | 2121 void RenderWidget::OnWaitNextFrameForTests(int routing_id) { |
| 2118 QueueMessage(new ViewHostMsg_WaitForNextFrameForTests_ACK(routing_id), | 2122 QueueMessage(new ViewHostMsg_WaitForNextFrameForTests_ACK(routing_id), |
| 2119 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); | 2123 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); |
| 2120 } | 2124 } |
| 2121 | 2125 |
| 2126 float RenderWidget::GetOriginalDeviceScaleFactor() const { |
| 2127 return |
| 2128 screen_metrics_emulator_ ? |
| 2129 screen_metrics_emulator_->original_screen_info().deviceScaleFactor : |
| 2130 device_scale_factor_; |
| 2131 } |
| 2132 |
| 2122 } // namespace content | 2133 } // namespace content |
| OLD | NEW |