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_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 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 2641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2652 Send(new ViewHostMsg_RunFileChooser(routing_id_, | 2652 Send(new ViewHostMsg_RunFileChooser(routing_id_, |
2653 file_chooser_completions_.front()->params)); | 2653 file_chooser_completions_.front()->params)); |
2654 } | 2654 } |
2655 } | 2655 } |
2656 | 2656 |
2657 void RenderViewImpl::OnEnableAutoResize(const gfx::Size& min_size, | 2657 void RenderViewImpl::OnEnableAutoResize(const gfx::Size& min_size, |
2658 const gfx::Size& max_size) { | 2658 const gfx::Size& max_size) { |
2659 DCHECK(disable_scrollbars_size_limit_.IsEmpty()); | 2659 DCHECK(disable_scrollbars_size_limit_.IsEmpty()); |
2660 if (!webview()) | 2660 if (!webview()) |
2661 return; | 2661 return; |
| 2662 |
2662 auto_resize_mode_ = true; | 2663 auto_resize_mode_ = true; |
2663 webview()->enableAutoResizeMode(min_size, max_size); | 2664 if (IsUseZoomForDSFEnabled()) { |
| 2665 webview()->enableAutoResizeMode( |
| 2666 gfx::ScaleToCeiledSize(min_size, device_scale_factor_), |
| 2667 gfx::ScaleToCeiledSize(max_size, device_scale_factor_)); |
| 2668 } else { |
| 2669 webview()->enableAutoResizeMode(min_size, max_size); |
| 2670 } |
2664 } | 2671 } |
2665 | 2672 |
2666 void RenderViewImpl::OnDisableAutoResize(const gfx::Size& new_size) { | 2673 void RenderViewImpl::OnDisableAutoResize(const gfx::Size& new_size) { |
2667 DCHECK(disable_scrollbars_size_limit_.IsEmpty()); | 2674 DCHECK(disable_scrollbars_size_limit_.IsEmpty()); |
2668 if (!webview()) | 2675 if (!webview()) |
2669 return; | 2676 return; |
2670 auto_resize_mode_ = false; | 2677 auto_resize_mode_ = false; |
2671 webview()->disableAutoResizeMode(); | 2678 webview()->disableAutoResizeMode(); |
2672 | 2679 |
2673 if (!new_size.IsEmpty()) { | 2680 if (!new_size.IsEmpty()) { |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3238 return RenderWidget::GetTextInputType(); | 3245 return RenderWidget::GetTextInputType(); |
3239 } | 3246 } |
3240 | 3247 |
3241 void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { | 3248 void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { |
3242 #if defined(ENABLE_PLUGINS) | 3249 #if defined(ENABLE_PLUGINS) |
3243 if (focused_pepper_plugin_) { | 3250 if (focused_pepper_plugin_) { |
3244 // TODO(kinaba) http://crbug.com/101101 | 3251 // TODO(kinaba) http://crbug.com/101101 |
3245 // Current Pepper IME API does not handle selection bounds. So we simply | 3252 // Current Pepper IME API does not handle selection bounds. So we simply |
3246 // use the caret position as an empty range for now. It will be updated | 3253 // use the caret position as an empty range for now. It will be updated |
3247 // after Pepper API equips features related to surrounding text retrieval. | 3254 // after Pepper API equips features related to surrounding text retrieval. |
3248 gfx::Rect caret = focused_pepper_plugin_->GetCaretBounds(); | 3255 blink::WebRect caret(focused_pepper_plugin_->GetCaretBounds()); |
| 3256 convertViewportToWindow(&caret); |
3249 *start = caret; | 3257 *start = caret; |
3250 *end = caret; | 3258 *end = caret; |
3251 return; | 3259 return; |
3252 } | 3260 } |
3253 #endif | 3261 #endif |
3254 RenderWidget::GetSelectionBounds(start, end); | 3262 RenderWidget::GetSelectionBounds(start, end); |
3255 } | 3263 } |
3256 | 3264 |
3257 void RenderViewImpl::FocusChangeComplete() { | 3265 void RenderViewImpl::FocusChangeComplete() { |
3258 RenderWidget::FocusChangeComplete(); | 3266 RenderWidget::FocusChangeComplete(); |
3259 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete()); | 3267 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete()); |
3260 } | 3268 } |
3261 | 3269 |
3262 void RenderViewImpl::GetCompositionCharacterBounds( | 3270 void RenderViewImpl::GetCompositionCharacterBounds( |
3263 std::vector<gfx::Rect>* bounds) { | 3271 std::vector<gfx::Rect>* bounds_in_window) { |
3264 DCHECK(bounds); | 3272 DCHECK(bounds_in_window); |
3265 bounds->clear(); | 3273 bounds_in_window->clear(); |
3266 | 3274 |
3267 #if defined(ENABLE_PLUGINS) | 3275 #if defined(ENABLE_PLUGINS) |
3268 if (focused_pepper_plugin_) { | 3276 if (focused_pepper_plugin_) { |
3269 return; | 3277 return; |
3270 } | 3278 } |
3271 #endif | 3279 #endif |
3272 | 3280 |
3273 if (!webview()) | 3281 if (!webview()) |
3274 return; | 3282 return; |
3275 size_t start_offset = 0; | 3283 size_t start_offset = 0; |
3276 size_t character_count = 0; | 3284 size_t character_count = 0; |
3277 if (!webview()->compositionRange(&start_offset, &character_count)) | 3285 if (!webview()->compositionRange(&start_offset, &character_count)) |
3278 return; | 3286 return; |
3279 if (character_count == 0) | 3287 if (character_count == 0) |
3280 return; | 3288 return; |
3281 | 3289 |
3282 blink::WebFrame* frame = webview()->focusedFrame(); | 3290 blink::WebFrame* frame = webview()->focusedFrame(); |
3283 if (!frame) | 3291 if (!frame) |
3284 return; | 3292 return; |
3285 | 3293 |
3286 bounds->reserve(character_count); | 3294 bounds_in_window->reserve(character_count); |
3287 blink::WebRect webrect; | 3295 blink::WebRect webrect; |
3288 for (size_t i = 0; i < character_count; ++i) { | 3296 for (size_t i = 0; i < character_count; ++i) { |
3289 if (!frame->firstRectForCharacterRange(start_offset + i, 1, webrect)) { | 3297 if (!frame->firstRectForCharacterRange(start_offset + i, 1, webrect)) { |
3290 DLOG(ERROR) << "Could not retrieve character rectangle at " << i; | 3298 DLOG(ERROR) << "Could not retrieve character rectangle at " << i; |
3291 bounds->clear(); | 3299 bounds_in_window->clear(); |
3292 return; | 3300 return; |
3293 } | 3301 } |
3294 bounds->push_back(webrect); | 3302 convertViewportToWindow(&webrect); |
| 3303 bounds_in_window->push_back(webrect); |
3295 } | 3304 } |
3296 } | 3305 } |
3297 | 3306 |
3298 void RenderViewImpl::GetCompositionRange(gfx::Range* range) { | 3307 void RenderViewImpl::GetCompositionRange(gfx::Range* range) { |
3299 #if defined(ENABLE_PLUGINS) | 3308 #if defined(ENABLE_PLUGINS) |
3300 if (focused_pepper_plugin_) { | 3309 if (focused_pepper_plugin_) { |
3301 return; | 3310 return; |
3302 } | 3311 } |
3303 #endif | 3312 #endif |
3304 RenderWidget::GetCompositionRange(range); | 3313 RenderWidget::GetCompositionRange(range); |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3710 if (IsUseZoomForDSFEnabled()) { | 3719 if (IsUseZoomForDSFEnabled()) { |
3711 compositor_->SetPaintedDeviceScaleFactor(device_scale_factor_); | 3720 compositor_->SetPaintedDeviceScaleFactor(device_scale_factor_); |
3712 webview()->setZoomFactorForDeviceScaleFactor( | 3721 webview()->setZoomFactorForDeviceScaleFactor( |
3713 device_scale_factor_); | 3722 device_scale_factor_); |
3714 } else { | 3723 } else { |
3715 webview()->setDeviceScaleFactor(device_scale_factor_); | 3724 webview()->setDeviceScaleFactor(device_scale_factor_); |
3716 } | 3725 } |
3717 } | 3726 } |
3718 | 3727 |
3719 } // namespace content | 3728 } // namespace content |
OLD | NEW |