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