Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 1521853002: Revert of Use Window coordinates for IME composition bounds, auto resize (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
2663 auto_resize_mode_ = true; 2662 auto_resize_mode_ = true;
2664 if (IsUseZoomForDSFEnabled()) { 2663 webview()->enableAutoResizeMode(min_size, max_size);
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 }
2671 } 2664 }
2672 2665
2673 void RenderViewImpl::OnDisableAutoResize(const gfx::Size& new_size) { 2666 void RenderViewImpl::OnDisableAutoResize(const gfx::Size& new_size) {
2674 DCHECK(disable_scrollbars_size_limit_.IsEmpty()); 2667 DCHECK(disable_scrollbars_size_limit_.IsEmpty());
2675 if (!webview()) 2668 if (!webview())
2676 return; 2669 return;
2677 auto_resize_mode_ = false; 2670 auto_resize_mode_ = false;
2678 webview()->disableAutoResizeMode(); 2671 webview()->disableAutoResizeMode();
2679 2672
2680 if (!new_size.IsEmpty()) { 2673 if (!new_size.IsEmpty()) {
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
3245 return RenderWidget::GetTextInputType(); 3238 return RenderWidget::GetTextInputType();
3246 } 3239 }
3247 3240
3248 void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { 3241 void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) {
3249 #if defined(ENABLE_PLUGINS) 3242 #if defined(ENABLE_PLUGINS)
3250 if (focused_pepper_plugin_) { 3243 if (focused_pepper_plugin_) {
3251 // TODO(kinaba) http://crbug.com/101101 3244 // TODO(kinaba) http://crbug.com/101101
3252 // Current Pepper IME API does not handle selection bounds. So we simply 3245 // Current Pepper IME API does not handle selection bounds. So we simply
3253 // use the caret position as an empty range for now. It will be updated 3246 // use the caret position as an empty range for now. It will be updated
3254 // after Pepper API equips features related to surrounding text retrieval. 3247 // after Pepper API equips features related to surrounding text retrieval.
3255 blink::WebRect caret(focused_pepper_plugin_->GetCaretBounds()); 3248 gfx::Rect caret = focused_pepper_plugin_->GetCaretBounds();
3256 convertViewportToWindow(&caret);
3257 *start = caret; 3249 *start = caret;
3258 *end = caret; 3250 *end = caret;
3259 return; 3251 return;
3260 } 3252 }
3261 #endif 3253 #endif
3262 RenderWidget::GetSelectionBounds(start, end); 3254 RenderWidget::GetSelectionBounds(start, end);
3263 } 3255 }
3264 3256
3265 void RenderViewImpl::FocusChangeComplete() { 3257 void RenderViewImpl::FocusChangeComplete() {
3266 RenderWidget::FocusChangeComplete(); 3258 RenderWidget::FocusChangeComplete();
3267 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete()); 3259 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete());
3268 } 3260 }
3269 3261
3270 void RenderViewImpl::GetCompositionCharacterBounds( 3262 void RenderViewImpl::GetCompositionCharacterBounds(
3271 std::vector<gfx::Rect>* bounds_in_window) { 3263 std::vector<gfx::Rect>* bounds) {
3272 DCHECK(bounds_in_window); 3264 DCHECK(bounds);
3273 bounds_in_window->clear(); 3265 bounds->clear();
3274 3266
3275 #if defined(ENABLE_PLUGINS) 3267 #if defined(ENABLE_PLUGINS)
3276 if (focused_pepper_plugin_) { 3268 if (focused_pepper_plugin_) {
3277 return; 3269 return;
3278 } 3270 }
3279 #endif 3271 #endif
3280 3272
3281 if (!webview()) 3273 if (!webview())
3282 return; 3274 return;
3283 size_t start_offset = 0; 3275 size_t start_offset = 0;
3284 size_t character_count = 0; 3276 size_t character_count = 0;
3285 if (!webview()->compositionRange(&start_offset, &character_count)) 3277 if (!webview()->compositionRange(&start_offset, &character_count))
3286 return; 3278 return;
3287 if (character_count == 0) 3279 if (character_count == 0)
3288 return; 3280 return;
3289 3281
3290 blink::WebFrame* frame = webview()->focusedFrame(); 3282 blink::WebFrame* frame = webview()->focusedFrame();
3291 if (!frame) 3283 if (!frame)
3292 return; 3284 return;
3293 3285
3294 bounds_in_window->reserve(character_count); 3286 bounds->reserve(character_count);
3295 blink::WebRect webrect; 3287 blink::WebRect webrect;
3296 for (size_t i = 0; i < character_count; ++i) { 3288 for (size_t i = 0; i < character_count; ++i) {
3297 if (!frame->firstRectForCharacterRange(start_offset + i, 1, webrect)) { 3289 if (!frame->firstRectForCharacterRange(start_offset + i, 1, webrect)) {
3298 DLOG(ERROR) << "Could not retrieve character rectangle at " << i; 3290 DLOG(ERROR) << "Could not retrieve character rectangle at " << i;
3299 bounds_in_window->clear(); 3291 bounds->clear();
3300 return; 3292 return;
3301 } 3293 }
3302 convertViewportToWindow(&webrect); 3294 bounds->push_back(webrect);
3303 bounds_in_window->push_back(webrect);
3304 } 3295 }
3305 } 3296 }
3306 3297
3307 void RenderViewImpl::GetCompositionRange(gfx::Range* range) { 3298 void RenderViewImpl::GetCompositionRange(gfx::Range* range) {
3308 #if defined(ENABLE_PLUGINS) 3299 #if defined(ENABLE_PLUGINS)
3309 if (focused_pepper_plugin_) { 3300 if (focused_pepper_plugin_) {
3310 return; 3301 return;
3311 } 3302 }
3312 #endif 3303 #endif
3313 RenderWidget::GetCompositionRange(range); 3304 RenderWidget::GetCompositionRange(range);
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
3719 if (IsUseZoomForDSFEnabled()) { 3710 if (IsUseZoomForDSFEnabled()) {
3720 compositor_->SetPaintedDeviceScaleFactor(device_scale_factor_); 3711 compositor_->SetPaintedDeviceScaleFactor(device_scale_factor_);
3721 webview()->setZoomFactorForDeviceScaleFactor( 3712 webview()->setZoomFactorForDeviceScaleFactor(
3722 device_scale_factor_); 3713 device_scale_factor_);
3723 } else { 3714 } else {
3724 webview()->setDeviceScaleFactor(device_scale_factor_); 3715 webview()->setDeviceScaleFactor(device_scale_factor_);
3725 } 3716 }
3726 } 3717 }
3727 3718
3728 } // namespace content 3719 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698