| 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/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 : renderer_initialized_(false), | 182 : renderer_initialized_(false), |
| 183 destroyed_(false), | 183 destroyed_(false), |
| 184 delegate_(delegate), | 184 delegate_(delegate), |
| 185 owner_delegate_(nullptr), | 185 owner_delegate_(nullptr), |
| 186 process_(process), | 186 process_(process), |
| 187 routing_id_(routing_id), | 187 routing_id_(routing_id), |
| 188 is_loading_(false), | 188 is_loading_(false), |
| 189 is_hidden_(hidden), | 189 is_hidden_(hidden), |
| 190 repaint_ack_pending_(false), | 190 repaint_ack_pending_(false), |
| 191 resize_ack_pending_(false), | 191 resize_ack_pending_(false), |
| 192 color_profile_out_of_date_(false), | |
| 193 auto_resize_enabled_(false), | 192 auto_resize_enabled_(false), |
| 194 waiting_for_screen_rects_ack_(false), | 193 waiting_for_screen_rects_ack_(false), |
| 195 needs_repainting_on_restore_(false), | 194 needs_repainting_on_restore_(false), |
| 196 is_unresponsive_(false), | 195 is_unresponsive_(false), |
| 197 in_flight_event_count_(0), | 196 in_flight_event_count_(0), |
| 198 in_get_backing_store_(false), | 197 in_get_backing_store_(false), |
| 199 ignore_input_events_(false), | 198 ignore_input_events_(false), |
| 200 text_direction_updated_(false), | 199 text_direction_updated_(false), |
| 201 text_direction_(blink::WebTextDirectionLeftToRight), | 200 text_direction_(blink::WebTextDirectionLeftToRight), |
| 202 text_direction_canceled_(false), | 201 text_direction_canceled_(false), |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 resize_ack_pending_ = resize_params.needs_resize_ack; | 617 resize_ack_pending_ = resize_params.needs_resize_ack; |
| 619 | 618 |
| 620 old_resize_params_ = base::WrapUnique(new ResizeParams(resize_params)); | 619 old_resize_params_ = base::WrapUnique(new ResizeParams(resize_params)); |
| 621 } | 620 } |
| 622 | 621 |
| 623 void RenderWidgetHostImpl::WasResized() { | 622 void RenderWidgetHostImpl::WasResized() { |
| 624 // Skip if the |delegate_| has already been detached because | 623 // Skip if the |delegate_| has already been detached because |
| 625 // it's web contents is being deleted. | 624 // it's web contents is being deleted. |
| 626 if (resize_ack_pending_ || !process_->HasConnection() || !view_ || | 625 if (resize_ack_pending_ || !process_->HasConnection() || !view_ || |
| 627 !renderer_initialized_ || auto_resize_enabled_ || !delegate_) { | 626 !renderer_initialized_ || auto_resize_enabled_ || !delegate_) { |
| 628 if (resize_ack_pending_ && color_profile_out_of_date_) | |
| 629 DispatchColorProfile(); | |
| 630 return; | 627 return; |
| 631 } | 628 } |
| 632 | 629 |
| 633 std::unique_ptr<ResizeParams> params(new ResizeParams); | 630 std::unique_ptr<ResizeParams> params(new ResizeParams); |
| 634 if (color_profile_out_of_date_) | |
| 635 DispatchColorProfile(); | |
| 636 if (!GetResizeParams(params.get())) | 631 if (!GetResizeParams(params.get())) |
| 637 return; | 632 return; |
| 638 | 633 |
| 639 bool width_changed = | 634 bool width_changed = |
| 640 !old_resize_params_ || | 635 !old_resize_params_ || |
| 641 old_resize_params_->new_size.width() != params->new_size.width(); | 636 old_resize_params_->new_size.width() != params->new_size.width(); |
| 642 if (Send(new ViewMsg_Resize(routing_id_, *params))) { | 637 if (Send(new ViewMsg_Resize(routing_id_, *params))) { |
| 643 resize_ack_pending_ = params->needs_resize_ack; | 638 resize_ack_pending_ = params->needs_resize_ack; |
| 644 old_resize_params_.swap(params); | 639 old_resize_params_.swap(params); |
| 645 } | 640 } |
| 646 | 641 |
| 647 if (delegate_) | 642 if (delegate_) |
| 648 delegate_->RenderWidgetWasResized(this, width_changed); | 643 delegate_->RenderWidgetWasResized(this, width_changed); |
| 649 } | 644 } |
| 650 | 645 |
| 651 void RenderWidgetHostImpl::DispatchColorProfile() { | |
| 652 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | |
| 653 static bool image_profiles = base::CommandLine::ForCurrentProcess()-> | |
| 654 HasSwitch(switches::kEnableImageColorProfiles); | |
| 655 if (!image_profiles) | |
| 656 return; | |
| 657 #if defined(OS_WIN) | |
| 658 // Windows will read disk to get the color profile data if needed, so | |
| 659 // dispatch the SendColorProfile() work off the UI thread. | |
| 660 BrowserThread::PostBlockingPoolTask( | |
| 661 FROM_HERE, | |
| 662 base::Bind(&RenderWidgetHostImpl::SendColorProfile, | |
| 663 weak_factory_.GetWeakPtr())); | |
| 664 #elif !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | |
| 665 // Only support desktop Mac and Linux at this time. | |
| 666 SendColorProfile(); | |
| 667 #endif | |
| 668 #endif | |
| 669 } | |
| 670 | |
| 671 void RenderWidgetHostImpl::SendColorProfile() { | |
| 672 if (!view_ || !delegate_) | |
| 673 return; | |
| 674 DCHECK(!view_->GetRequestedRendererSize().IsEmpty()); | |
| 675 #if defined(OS_WIN) | |
| 676 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 677 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 678 #endif | |
| 679 std::vector<char> color_profile; | |
| 680 if (!GetScreenColorProfile(&color_profile)) | |
| 681 return; | |
| 682 if (!renderer_initialized_ || !process_->HasConnection()) | |
| 683 return; | |
| 684 if (!Send(new ViewMsg_ColorProfile(routing_id_, color_profile))) | |
| 685 return; | |
| 686 color_profile_out_of_date_ = false; | |
| 687 } | |
| 688 | |
| 689 void RenderWidgetHostImpl::ResizeRectChanged(const gfx::Rect& new_rect) { | 646 void RenderWidgetHostImpl::ResizeRectChanged(const gfx::Rect& new_rect) { |
| 690 Send(new ViewMsg_ChangeResizeRect(routing_id_, new_rect)); | 647 Send(new ViewMsg_ChangeResizeRect(routing_id_, new_rect)); |
| 691 } | 648 } |
| 692 | 649 |
| 693 void RenderWidgetHostImpl::GotFocus() { | 650 void RenderWidgetHostImpl::GotFocus() { |
| 694 Focus(); | 651 Focus(); |
| 695 if (owner_delegate_) | 652 if (owner_delegate_) |
| 696 owner_delegate_->RenderWidgetGotFocus(); | 653 owner_delegate_->RenderWidgetGotFocus(); |
| 697 if (delegate_) | 654 if (delegate_) |
| 698 delegate_->RenderWidgetGotFocus(this); | 655 delegate_->RenderWidgetGotFocus(this); |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 view_->GetScreenInfo(result); | 1207 view_->GetScreenInfo(result); |
| 1251 else | 1208 else |
| 1252 RenderWidgetHostViewBase::GetDefaultScreenInfo(result); | 1209 RenderWidgetHostViewBase::GetDefaultScreenInfo(result); |
| 1253 // TODO(sievers): find a way to make this done another way so the method | 1210 // TODO(sievers): find a way to make this done another way so the method |
| 1254 // can be const. | 1211 // can be const. |
| 1255 latency_tracker_.set_device_scale_factor(result->deviceScaleFactor); | 1212 latency_tracker_.set_device_scale_factor(result->deviceScaleFactor); |
| 1256 if (IsUseZoomForDSFEnabled()) | 1213 if (IsUseZoomForDSFEnabled()) |
| 1257 input_router_->SetDeviceScaleFactor(result->deviceScaleFactor); | 1214 input_router_->SetDeviceScaleFactor(result->deviceScaleFactor); |
| 1258 } | 1215 } |
| 1259 | 1216 |
| 1260 bool RenderWidgetHostImpl::GetScreenColorProfile( | |
| 1261 std::vector<char>* color_profile) { | |
| 1262 DCHECK(color_profile->empty()); | |
| 1263 if (view_) | |
| 1264 return view_->GetScreenColorProfile(color_profile); | |
| 1265 return false; | |
| 1266 } | |
| 1267 | |
| 1268 void RenderWidgetHostImpl::HandleCompositorProto( | 1217 void RenderWidgetHostImpl::HandleCompositorProto( |
| 1269 const std::vector<uint8_t>& proto) { | 1218 const std::vector<uint8_t>& proto) { |
| 1270 DCHECK(!proto.empty()); | 1219 DCHECK(!proto.empty()); |
| 1271 Send(new ViewMsg_HandleCompositorProto(GetRoutingID(), proto)); | 1220 Send(new ViewMsg_HandleCompositorProto(GetRoutingID(), proto)); |
| 1272 } | 1221 } |
| 1273 | 1222 |
| 1274 void RenderWidgetHostImpl::NotifyScreenInfoChanged() { | 1223 void RenderWidgetHostImpl::NotifyScreenInfoChanged() { |
| 1275 color_profile_out_of_date_ = true; | |
| 1276 | |
| 1277 if (delegate_) | 1224 if (delegate_) |
| 1278 delegate_->ScreenInfoChanged(); | 1225 delegate_->ScreenInfoChanged(); |
| 1279 | 1226 |
| 1280 // The resize message (which may not happen immediately) will carry with it | 1227 // The resize message (which may not happen immediately) will carry with it |
| 1281 // the screen info as well as the new size (if the screen has changed scale | 1228 // the screen info as well as the new size (if the screen has changed scale |
| 1282 // factor). | 1229 // factor). |
| 1283 WasResized(); | 1230 WasResized(); |
| 1284 } | 1231 } |
| 1285 | 1232 |
| 1286 void RenderWidgetHostImpl::GetSnapshotFromBrowser( | 1233 void RenderWidgetHostImpl::GetSnapshotFromBrowser( |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2199 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | 2146 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
| 2200 } | 2147 } |
| 2201 | 2148 |
| 2202 BrowserAccessibilityManager* | 2149 BrowserAccessibilityManager* |
| 2203 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2150 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
| 2204 return delegate_ ? | 2151 return delegate_ ? |
| 2205 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2152 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
| 2206 } | 2153 } |
| 2207 | 2154 |
| 2208 } // namespace content | 2155 } // namespace content |
| OLD | NEW |