From bf6722ab4fdee82533d9e223a5e7cad9fd8777b5 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 31 Aug 2014 17:44:07 +0800 Subject: [PATCH 1/8] Upgrade libchromiumcontent to chrome37. --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index a88222442d2..887f3b7895c 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit a88222442d2a85345d9a208c23456956c208571d +Subproject commit 887f3b7895c55625d20d7ea06fa041dcacdb8b47 From f0e46a472893b0b94543bf9bae592461860008eb Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 31 Aug 2014 18:28:53 +0800 Subject: [PATCH 2/8] Add skia related defines. --- brightray/brightray.gypi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/brightray/brightray.gypi b/brightray/brightray.gypi index c155782c7d0..1856ec978e7 100644 --- a/brightray/brightray.gypi +++ b/brightray/brightray.gypi @@ -62,6 +62,14 @@ 'NDEBUG', 'USING_V8_SHARED', 'WEBKIT_DLL', + # From skia_for_chromium_defines.gypi: + 'SK_SUPPORT_LEGACY_GETTOPDEVICE', + 'SK_SUPPORT_LEGACY_BITMAP_CONFIG', + 'SK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE', + 'SK_SUPPORT_LEGACY_N32_NAME', + 'SK_SUPPORT_LEGACY_SETCONFIG', + 'SK_IGNORE_ETC1_SUPPORT', + 'SK_IGNORE_GPU_DITHER', ], 'msvs_configuration_attributes': { 'OutputDirectory': '<(DEPTH)\\build\\$(ConfigurationName)', From dca1c51b3214c287914258570d5db406aa1299ec Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 31 Aug 2014 18:43:01 +0800 Subject: [PATCH 3/8] Fix API changes of Chrome37. --- brightray/browser/browser_client.cc | 2 +- brightray/browser/browser_client.h | 2 +- brightray/browser/browser_context.cc | 45 +++---------------- brightray/browser/browser_context.h | 36 +++------------ brightray/browser/devtools_delegate.cc | 5 ++- .../browser/inspectable_web_contents_impl.cc | 3 +- .../browser/url_request_context_getter.cc | 16 +++---- .../browser/url_request_context_getter.h | 6 +-- .../inspectable_web_contents_view_views.cc | 1 - 9 files changed, 30 insertions(+), 86 deletions(-) diff --git a/brightray/browser/browser_client.cc b/brightray/browser/browser_client.cc index 3c7377d6d9a..c306bfc26c7 100644 --- a/brightray/browser/browser_client.cc +++ b/brightray/browser/browser_client.cc @@ -61,7 +61,7 @@ content::BrowserMainParts* BrowserClient::CreateBrowserMainParts( net::URLRequestContextGetter* BrowserClient::CreateRequestContext( content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers, - content::ProtocolHandlerScopedVector protocol_interceptors) { + content::URLRequestInterceptorScopedVector protocol_interceptors) { auto context = static_cast(browser_context); return context->CreateRequestContext(protocol_handlers, protocol_interceptors.Pass()); } diff --git a/brightray/browser/browser_client.h b/brightray/browser/browser_client.h index 6d1944ca026..565ff18cc9c 100644 --- a/brightray/browser/browser_client.h +++ b/brightray/browser/browser_client.h @@ -36,7 +36,7 @@ class BrowserClient : public content::ContentBrowserClient { virtual net::URLRequestContextGetter* CreateRequestContext( content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers, - content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE; + content::URLRequestInterceptorScopedVector protocol_interceptors) OVERRIDE; private: virtual content::BrowserMainParts* CreateBrowserMainParts( diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index 3396531ed35..26eba048b30 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -101,7 +101,7 @@ void BrowserContext::RegisterInternalPrefs(PrefRegistrySimple* registry) { net::URLRequestContextGetter* BrowserContext::CreateRequestContext( content::ProtocolHandlerMap* protocol_handlers, - content::ProtocolHandlerScopedVector protocol_interceptors) { + content::URLRequestInterceptorScopedVector protocol_interceptors) { DCHECK(!url_request_getter_); url_request_getter_ = new URLRequestContextGetter( this, @@ -120,7 +120,7 @@ net::NetworkDelegate* BrowserContext::CreateNetworkDelegate() { net::URLRequestJobFactory* BrowserContext::CreateURLRequestJobFactory( content::ProtocolHandlerMap* protocol_handlers, - content::ProtocolHandlerScopedVector* protocol_interceptors) { + content::URLRequestInterceptorScopedVector* protocol_interceptors) { return NULL; } @@ -158,36 +158,6 @@ net::URLRequestContextGetter* return GetRequestContext(); } -void BrowserContext::RequestMidiSysExPermission( - int render_process_id, - int render_view_id, - int bridge_id, - const GURL& requesting_frame, - bool user_gesture, - const MidiSysExPermissionCallback& callback) { - callback.Run(false); -} - -void BrowserContext::CancelMidiSysExPermissionRequest( - int render_process_id, - int render_view_id, - int bridge_id, - const GURL& requesting_frame) { -} - -void BrowserContext::RequestProtectedMediaIdentifierPermission( - int render_process_id, - int render_view_id, - int bridge_id, - int group_id, - const GURL& requesting_frame, - const ProtectedMediaIdentifierPermissionCallback& callback) { - callback.Run(false); -} - -void BrowserContext::CancelProtectedMediaIdentifierPermissionRequests(int group_id) { -} - content::ResourceContext* BrowserContext::GetResourceContext() { return resource_context_.get(); } @@ -198,17 +168,16 @@ content::DownloadManagerDelegate* BrowserContext::GetDownloadManagerDelegate() { return download_manager_delegate_.get(); } -content::GeolocationPermissionContext* - BrowserContext::GetGeolocationPermissionContext() { - return nullptr; +content::BrowserPluginGuestManager* BrowserContext::GetGuestManager() { + return NULL; } quota::SpecialStoragePolicy* BrowserContext::GetSpecialStoragePolicy() { - return nullptr; + return NULL; } -content::BrowserPluginGuestManagerDelegate* BrowserContext::GetGuestManagerDelegate() { - return nullptr; +content::PushMessagingService* BrowserContext::GetPushMessagingService() { + return NULL; } } // namespace brightray diff --git a/brightray/browser/browser_context.h b/brightray/browser/browser_context.h index 6bd2a1b81d9..8ed7bc1a3c0 100644 --- a/brightray/browser/browser_context.h +++ b/brightray/browser/browser_context.h @@ -26,7 +26,7 @@ class BrowserContext : public content::BrowserContext, net::URLRequestContextGetter* CreateRequestContext( content::ProtocolHandlerMap* protocol_handlers, - content::ProtocolHandlerScopedVector protocol_interceptors); + content::URLRequestInterceptorScopedVector protocol_interceptors); net::URLRequestContextGetter* url_request_context_getter() const { return url_request_getter_.get(); @@ -42,7 +42,7 @@ class BrowserContext : public content::BrowserContext, virtual net::NetworkDelegate* CreateNetworkDelegate() OVERRIDE; virtual net::URLRequestJobFactory* CreateURLRequestJobFactory( content::ProtocolHandlerMap* protocol_handlers, - content::ProtocolHandlerScopedVector* protocol_interceptors) OVERRIDE; + content::URLRequestInterceptorScopedVector* protocol_interceptors) OVERRIDE; virtual base::FilePath GetPath() const OVERRIDE; @@ -61,35 +61,11 @@ class BrowserContext : public content::BrowserContext, virtual net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition( const base::FilePath& partition_path, bool in_memory); - virtual void RequestMidiSysExPermission( - int render_process_id, - int render_view_id, - int bridge_id, - const GURL& requesting_frame, - bool user_gesture, - const MidiSysExPermissionCallback& callback) OVERRIDE; - virtual void CancelMidiSysExPermissionRequest( - int render_process_id, - int render_view_id, - int bridge_id, - const GURL& requesting_frame) OVERRIDE; - virtual void RequestProtectedMediaIdentifierPermission( - int render_process_id, - int render_view_id, - int bridge_id, - int group_id, - const GURL& requesting_frame, - const ProtectedMediaIdentifierPermissionCallback& callback) OVERRIDE; - virtual void CancelProtectedMediaIdentifierPermissionRequests(int group_id) OVERRIDE; virtual content::ResourceContext* GetResourceContext() OVERRIDE; - virtual content::DownloadManagerDelegate* - GetDownloadManagerDelegate() OVERRIDE; - virtual content::GeolocationPermissionContext* - GetGeolocationPermissionContext() OVERRIDE; - virtual content::BrowserPluginGuestManagerDelegate* - GetGuestManagerDelegate() OVERRIDE; - virtual quota::SpecialStoragePolicy* - GetSpecialStoragePolicy() OVERRIDE; + virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE; + virtual content::BrowserPluginGuestManager* GetGuestManager() OVERRIDE; + virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; + virtual content::PushMessagingService* GetPushMessagingService() OVERRIDE; base::FilePath path_; scoped_ptr resource_context_; diff --git a/brightray/browser/devtools_delegate.cc b/brightray/browser/devtools_delegate.cc index ded349dce67..d6ef0144711 100644 --- a/brightray/browser/devtools_delegate.cc +++ b/brightray/browser/devtools_delegate.cc @@ -68,6 +68,7 @@ class Target : public content::DevToolsTarget { explicit Target(WebContents* web_contents); virtual std::string GetId() const OVERRIDE { return id_; } + virtual std::string GetParentId() const { return std::string(); } virtual std::string GetType() const OVERRIDE { return kTargetTypePage; } virtual std::string GetTitle() const OVERRIDE { return title_; } virtual std::string GetDescription() const OVERRIDE { return std::string(); } @@ -134,8 +135,8 @@ DevToolsDelegate::DevToolsDelegate( content::BrowserContext* browser_context) : browser_context_(browser_context) { std::string frontend_url; - devtools_http_handler_ = - DevToolsHttpHandler::Start(CreateSocketFactory(), frontend_url, this); + devtools_http_handler_ = DevToolsHttpHandler::Start( + CreateSocketFactory(), frontend_url, this, base::FilePath()); } DevToolsDelegate::~DevToolsDelegate() { diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 4938b355db9..c512d2eb2e9 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -156,8 +156,7 @@ void InspectableWebContentsImpl::ShowDevTools() { embedder_message_dispatcher_.reset( new DevToolsEmbedderMessageDispatcher(this)); - auto create_params = content::WebContents::CreateParams( - web_contents_->GetBrowserContext()); + content::WebContents::CreateParams create_params(web_contents_->GetBrowserContext()); devtools_web_contents_.reset(content::WebContents::Create(create_params)); Observe(devtools_web_contents_.get()); diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index da57591ed95..a366c7918d0 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -15,7 +15,6 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/cookie_store_factory.h" #include "content/public/common/content_switches.h" -#include "content/public/common/url_constants.h" #include "net/base/host_mapping_rules.h" #include "net/cert/cert_verifier.h" #include "net/cookies/cookie_monster.h" @@ -33,11 +32,12 @@ #include "net/ssl/ssl_config_service_defaults.h" #include "net/url_request/data_protocol_handler.h" #include "net/url_request/file_protocol_handler.h" -#include "net/url_request/protocol_intercept_job_factory.h" #include "net/url_request/static_http_user_agent_settings.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_storage.h" +#include "net/url_request/url_request_intercepting_job_factory.h" #include "net/url_request/url_request_job_factory_impl.h" +#include "url/url_constants.h" #include "webkit/browser/quota/special_storage_policy.h" using content::BrowserThread; @@ -75,24 +75,24 @@ const char kProxyServer[] = "proxy-server"; net::URLRequestJobFactory* URLRequestContextGetter::Delegate::CreateURLRequestJobFactory( content::ProtocolHandlerMap* protocol_handlers, - content::ProtocolHandlerScopedVector* protocol_interceptors) { + content::URLRequestInterceptorScopedVector* protocol_interceptors) { scoped_ptr job_factory(new net::URLRequestJobFactoryImpl); for (auto it = protocol_handlers->begin(); it != protocol_handlers->end(); ++it) job_factory->SetProtocolHandler(it->first, it->second.release()); protocol_handlers->clear(); - job_factory->SetProtocolHandler(content::kDataScheme, new net::DataProtocolHandler); - job_factory->SetProtocolHandler(content::kFileScheme, new net::FileProtocolHandler( + job_factory->SetProtocolHandler(url::kDataScheme, new net::DataProtocolHandler); + job_factory->SetProtocolHandler(url::kFileScheme, new net::FileProtocolHandler( BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); // Set up interceptors in the reverse order. scoped_ptr top_job_factory = job_factory.PassAs(); - for (content::ProtocolHandlerScopedVector::reverse_iterator i = protocol_interceptors->rbegin(); + for (content::URLRequestInterceptorScopedVector::reverse_iterator i = protocol_interceptors->rbegin(); i != protocol_interceptors->rend(); ++i) - top_job_factory.reset(new net::ProtocolInterceptJobFactory( + top_job_factory.reset(new net::URLRequestInterceptingJobFactory( top_job_factory.Pass(), make_scoped_ptr(*i))); protocol_interceptors->weak_clear(); @@ -105,7 +105,7 @@ URLRequestContextGetter::URLRequestContextGetter( base::MessageLoop* io_loop, base::MessageLoop* file_loop, content::ProtocolHandlerMap* protocol_handlers, - content::ProtocolHandlerScopedVector protocol_interceptors) + content::URLRequestInterceptorScopedVector protocol_interceptors) : delegate_(delegate), base_path_(base_path), io_loop_(io_loop), diff --git a/brightray/browser/url_request_context_getter.h b/brightray/browser/url_request_context_getter.h index c7379f2248a..970d4b8458a 100644 --- a/brightray/browser/url_request_context_getter.h +++ b/brightray/browser/url_request_context_getter.h @@ -35,7 +35,7 @@ class URLRequestContextGetter : public net::URLRequestContextGetter { virtual net::NetworkDelegate* CreateNetworkDelegate() { return NULL; } virtual net::URLRequestJobFactory* CreateURLRequestJobFactory( content::ProtocolHandlerMap* protocol_handlers, - content::ProtocolHandlerScopedVector* protocol_interceptors); + content::URLRequestInterceptorScopedVector* protocol_interceptors); }; URLRequestContextGetter( @@ -44,7 +44,7 @@ class URLRequestContextGetter : public net::URLRequestContextGetter { base::MessageLoop* io_loop, base::MessageLoop* file_loop, content::ProtocolHandlerMap* protocol_handlers, - content::ProtocolHandlerScopedVector protocol_interceptors); + content::URLRequestInterceptorScopedVector protocol_interceptors); virtual ~URLRequestContextGetter(); // net::URLRequestContextGetter: @@ -66,7 +66,7 @@ class URLRequestContextGetter : public net::URLRequestContextGetter { scoped_ptr url_request_context_; scoped_ptr host_mapping_rules_; content::ProtocolHandlerMap protocol_handlers_; - content::ProtocolHandlerScopedVector protocol_interceptors_; + content::URLRequestInterceptorScopedVector protocol_interceptors_; DISALLOW_COPY_AND_ASSIGN(URLRequestContextGetter); }; diff --git a/brightray/browser/views/inspectable_web_contents_view_views.cc b/brightray/browser/views/inspectable_web_contents_view_views.cc index e810414e0d2..5a5e1d9ff3e 100644 --- a/brightray/browser/views/inspectable_web_contents_view_views.cc +++ b/brightray/browser/views/inspectable_web_contents_view_views.cc @@ -138,7 +138,6 @@ void InspectableWebContentsViewViews::SetIsDocked(bool docked) { params.delegate = new DevToolsWindowDelegate(this, devtools_window_web_view_, devtools_window_.get()); - params.top_level = true; params.bounds = inspectable_web_contents()->GetDevToolsBounds(); #if defined(USE_X11) // In X11 the window frame is drawn by the application. From 6010539914b3eb055f633678786f57b729378a82 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 31 Aug 2014 19:57:15 +0800 Subject: [PATCH 4/8] Don't create empty url request job factory. --- brightray/browser/browser_context.cc | 6 ------ brightray/browser/browser_context.h | 3 --- 2 files changed, 9 deletions(-) diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index 26eba048b30..d539ccbcced 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -118,12 +118,6 @@ net::NetworkDelegate* BrowserContext::CreateNetworkDelegate() { return new NetworkDelegate; } -net::URLRequestJobFactory* BrowserContext::CreateURLRequestJobFactory( - content::ProtocolHandlerMap* protocol_handlers, - content::URLRequestInterceptorScopedVector* protocol_interceptors) { - return NULL; -} - base::FilePath BrowserContext::GetPath() const { return path_; } diff --git a/brightray/browser/browser_context.h b/brightray/browser/browser_context.h index 8ed7bc1a3c0..9dfd03d9e2d 100644 --- a/brightray/browser/browser_context.h +++ b/brightray/browser/browser_context.h @@ -40,9 +40,6 @@ class BrowserContext : public content::BrowserContext, // URLRequestContextGetter::Delegate: virtual net::NetworkDelegate* CreateNetworkDelegate() OVERRIDE; - virtual net::URLRequestJobFactory* CreateURLRequestJobFactory( - content::ProtocolHandlerMap* protocol_handlers, - content::URLRequestInterceptorScopedVector* protocol_interceptors) OVERRIDE; virtual base::FilePath GetPath() const OVERRIDE; From f8c8c415ebaf65619e92128f96aedc72df26896e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 31 Aug 2014 20:04:48 +0800 Subject: [PATCH 5/8] Fix cpplint warnings. --- brightray/browser/url_request_context_getter.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index a366c7918d0..167228beca5 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -90,8 +90,8 @@ net::URLRequestJobFactory* URLRequestContextGetter::Delegate::CreateURLRequestJo // Set up interceptors in the reverse order. scoped_ptr top_job_factory = job_factory.PassAs(); - for (content::URLRequestInterceptorScopedVector::reverse_iterator i = protocol_interceptors->rbegin(); - i != protocol_interceptors->rend(); ++i) + content::URLRequestInterceptorScopedVector::reverse_iterator i; + for (i = protocol_interceptors->rbegin(); i != protocol_interceptors->rend(); ++i) top_job_factory.reset(new net::URLRequestInterceptingJobFactory( top_job_factory.Pass(), make_scoped_ptr(*i))); protocol_interceptors->weak_clear(); From 410708936377097310d8ae2e9a228618cf095e4b Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 1 Sep 2014 19:15:07 +0800 Subject: [PATCH 6/8] Use new devtools resizing strategy from Chrome 37. --- .../devtools_contents_resizing_strategy.cc | 62 +++++-------------- .../devtools_contents_resizing_strategy.h | 20 ++---- .../devtools_embedder_message_dispatcher.cc | 31 +++------- .../devtools_embedder_message_dispatcher.h | 4 +- .../browser/inspectable_web_contents_impl.cc | 5 +- .../browser/inspectable_web_contents_impl.h | 3 +- 6 files changed, 35 insertions(+), 90 deletions(-) diff --git a/brightray/browser/devtools_contents_resizing_strategy.cc b/brightray/browser/devtools_contents_resizing_strategy.cc index 15d7a5253f1..30ee028669e 100644 --- a/brightray/browser/devtools_contents_resizing_strategy.cc +++ b/brightray/browser/devtools_contents_resizing_strategy.cc @@ -6,80 +6,48 @@ #include -DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy() { -} - -DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy( - const gfx::Insets& insets, const gfx::Size& min_size) - : insets_(insets), - min_size_(min_size) { +DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy() + : hide_inspected_contents_(false) { } DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy( const gfx::Rect& bounds) - : bounds_(bounds) { + : bounds_(bounds), + hide_inspected_contents_(bounds_.IsEmpty() && !bounds_.x() && + !bounds_.y()) { } void DevToolsContentsResizingStrategy::CopyFrom( const DevToolsContentsResizingStrategy& strategy) { - insets_ = strategy.insets(); - min_size_ = strategy.min_size(); bounds_ = strategy.bounds(); + hide_inspected_contents_ = strategy.hide_inspected_contents(); } bool DevToolsContentsResizingStrategy::Equals( const DevToolsContentsResizingStrategy& strategy) { - return insets_ == strategy.insets() && min_size_ == strategy.min_size() && - bounds_ == strategy.bounds(); + return bounds_ == strategy.bounds() && + hide_inspected_contents_ == strategy.hide_inspected_contents(); } void ApplyDevToolsContentsResizingStrategy( const DevToolsContentsResizingStrategy& strategy, const gfx::Size& container_size, - const gfx::Rect& old_devtools_bounds, - const gfx::Rect& old_contents_bounds, gfx::Rect* new_devtools_bounds, gfx::Rect* new_contents_bounds) { new_devtools_bounds->SetRect( 0, 0, container_size.width(), container_size.height()); - const gfx::Insets& insets = strategy.insets(); - const gfx::Size& min_size = strategy.min_size(); const gfx::Rect& bounds = strategy.bounds(); - - if (!bounds.size().IsEmpty()) { - int left = std::min(bounds.x(), container_size.width()); - int top = std::min(bounds.y(), container_size.height()); - int width = std::min(bounds.width(), container_size.width() - left); - int height = std::min(bounds.height(), container_size.height() - top); - new_contents_bounds->SetRect(left, top, width, height); + if (bounds.size().IsEmpty() && !strategy.hide_inspected_contents()) { + new_contents_bounds->SetRect( + 0, 0, container_size.width(), container_size.height()); return; } - int width = std::max(0, container_size.width() - insets.width()); - int left = insets.left(); - if (width < min_size.width() && insets.width() > 0) { - int min_width = std::min(min_size.width(), container_size.width()); - int insets_width = container_size.width() - min_width; - int insets_decrease = insets.width() - insets_width; - // Decrease both left and right insets proportionally. - left -= insets_decrease * insets.left() / insets.width(); - width = min_width; - } - left = std::max(0, std::min(container_size.width(), left)); - - int height = std::max(0, container_size.height() - insets.height()); - int top = insets.top(); - if (height < min_size.height() && insets.height() > 0) { - int min_height = std::min(min_size.height(), container_size.height()); - int insets_height = container_size.height() - min_height; - int insets_decrease = insets.height() - insets_height; - // Decrease both top and bottom insets proportionally. - top -= insets_decrease * insets.top() / insets.height(); - height = min_height; - } - top = std::max(0, std::min(container_size.height(), top)); - + int left = std::min(bounds.x(), container_size.width()); + int top = std::min(bounds.y(), container_size.height()); + int width = std::min(bounds.width(), container_size.width() - left); + int height = std::min(bounds.height(), container_size.height() - top); new_contents_bounds->SetRect(left, top, width, height); } diff --git a/brightray/browser/devtools_contents_resizing_strategy.h b/brightray/browser/devtools_contents_resizing_strategy.h index 86ea260c71a..806d78a7156 100644 --- a/brightray/browser/devtools_contents_resizing_strategy.h +++ b/brightray/browser/devtools_contents_resizing_strategy.h @@ -15,28 +15,22 @@ class DevToolsContentsResizingStrategy { public: DevToolsContentsResizingStrategy(); - DevToolsContentsResizingStrategy( - const gfx::Insets& insets, - const gfx::Size& min_size); - explicit DevToolsContentsResizingStrategy(const gfx::Rect& bounds); + explicit DevToolsContentsResizingStrategy( + const gfx::Rect& bounds); void CopyFrom(const DevToolsContentsResizingStrategy& strategy); bool Equals(const DevToolsContentsResizingStrategy& strategy); - const gfx::Insets& insets() const { return insets_; } - const gfx::Size& min_size() const { return min_size_; } const gfx::Rect& bounds() const { return bounds_; } + bool hide_inspected_contents() const { return hide_inspected_contents_; } private: - // Insets of contents inside DevTools. - gfx::Insets insets_; - - // Minimum size of contents. - gfx::Size min_size_; - // Contents bounds. When non-empty, used instead of insets. gfx::Rect bounds_; + // Determines whether inspected contents is visible. + bool hide_inspected_contents_; + DISALLOW_COPY_AND_ASSIGN(DevToolsContentsResizingStrategy); }; @@ -48,8 +42,6 @@ class DevToolsContentsResizingStrategy { void ApplyDevToolsContentsResizingStrategy( const DevToolsContentsResizingStrategy& strategy, const gfx::Size& container_size, - const gfx::Rect& old_devtools_bounds, - const gfx::Rect& old_contents_bounds, gfx::Rect* new_devtools_bounds, gfx::Rect* new_contents_bounds); diff --git a/brightray/browser/devtools_embedder_message_dispatcher.cc b/brightray/browser/devtools_embedder_message_dispatcher.cc index c4e87fcf7e6..bb64846320b 100644 --- a/brightray/browser/devtools_embedder_message_dispatcher.cc +++ b/brightray/browser/devtools_embedder_message_dispatcher.cc @@ -23,33 +23,20 @@ bool GetValue(const base::ListValue& list, int pos, bool& value) { return list.GetBoolean(pos, &value); } -bool GetValue(const base::ListValue& list, int pos, gfx::Insets& insets) { - const base::DictionaryValue* dict; - if (!list.GetDictionary(pos, &dict)) - return false; - int top = 0; - int left = 0; - int bottom = 0; - int right = 0; - if (!dict->GetInteger("top", &top) || - !dict->GetInteger("left", &left) || - !dict->GetInteger("bottom", &bottom) || - !dict->GetInteger("right", &right)) - return false; - insets.Set(top, left, bottom, right); - return true; -} - -bool GetValue(const base::ListValue& list, int pos, gfx::Size& size) { +bool GetValue(const base::ListValue& list, int pos, gfx::Rect& rect) { const base::DictionaryValue* dict; if (!list.GetDictionary(pos, &dict)) return false; + int x = 0; + int y = 0; int width = 0; int height = 0; - if (!dict->GetInteger("width", &width) || + if (!dict->GetInteger("x", &x) || + !dict->GetInteger("y", &y) || + !dict->GetInteger("width", &width) || !dict->GetInteger("height", &height)) return false; - size.SetSize(width, height); + rect.SetRect(x, y, width, height); return true; } @@ -191,8 +178,8 @@ DevToolsEmbedderMessageDispatcher::DevToolsEmbedderMessageDispatcher( RegisterHandler("closeWindow", BindToListParser(base::Bind(&Delegate::CloseWindow, base::Unretained(delegate)))); - RegisterHandler("setContentsResizingStrategy", - BindToListParser(base::Bind(&Delegate::SetContentsResizingStrategy, + RegisterHandler("setInspectedPageBounds", + BindToListParser(base::Bind(&Delegate::SetInspectedPageBounds, base::Unretained(delegate)))); RegisterHandler("inspectElementCompleted", BindToListParser(base::Bind(&Delegate::InspectElementCompleted, diff --git a/brightray/browser/devtools_embedder_message_dispatcher.h b/brightray/browser/devtools_embedder_message_dispatcher.h index 0448f86aa16..1b0bf9e3a02 100644 --- a/brightray/browser/devtools_embedder_message_dispatcher.h +++ b/brightray/browser/devtools_embedder_message_dispatcher.h @@ -10,6 +10,7 @@ #include "base/callback.h" #include "ui/gfx/insets.h" +#include "ui/gfx/rect.h" #include "ui/gfx/size.h" namespace base { @@ -32,8 +33,7 @@ class DevToolsEmbedderMessageDispatcher { virtual void ActivateWindow() = 0; virtual void CloseWindow() = 0; - virtual void SetContentsResizingStrategy( - const gfx::Insets& insets, const gfx::Size& min_size) = 0; + virtual void SetInspectedPageBounds(const gfx::Rect& rect) = 0; virtual void InspectElementCompleted() = 0; virtual void MoveWindow(int x, int y) = 0; virtual void SetIsDocked(bool docked) = 0; diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index c512d2eb2e9..94b1069ebfa 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -212,9 +212,8 @@ void InspectableWebContentsImpl::CloseWindow() { devtools_web_contents()->DispatchBeforeUnload(false); } -void InspectableWebContentsImpl::SetContentsResizingStrategy( - const gfx::Insets& insets, const gfx::Size& min_size) { - DevToolsContentsResizingStrategy strategy(insets, min_size); +void InspectableWebContentsImpl::SetInspectedPageBounds(const gfx::Rect& rect) { + DevToolsContentsResizingStrategy strategy(rect); if (contents_resizing_strategy_.Equals(strategy)) return; diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index 8bbf70273b2..bae3cf865f1 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -64,8 +64,7 @@ class InspectableWebContentsImpl : virtual void ActivateWindow() OVERRIDE; virtual void CloseWindow() OVERRIDE; - virtual void SetContentsResizingStrategy( - const gfx::Insets& insets, const gfx::Size& min_size) OVERRIDE; + virtual void SetInspectedPageBounds(const gfx::Rect& rect) OVERRIDE; virtual void InspectElementCompleted() OVERRIDE; virtual void MoveWindow(int x, int y) OVERRIDE; virtual void SetIsDocked(bool docked) OVERRIDE; From 2a8691d98133adc8df2c6dd359f571f7276bc1a4 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 1 Sep 2014 19:18:12 +0800 Subject: [PATCH 7/8] mac: Use new devtools resizing strategy. --- .../mac/bry_inspectable_web_contents_view.h | 3 --- .../mac/bry_inspectable_web_contents_view.mm | 19 +------------------ 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/brightray/browser/mac/bry_inspectable_web_contents_view.h b/brightray/browser/mac/bry_inspectable_web_contents_view.h index 977d6fdd939..8cf7540b60f 100644 --- a/brightray/browser/mac/bry_inspectable_web_contents_view.h +++ b/brightray/browser/mac/bry_inspectable_web_contents_view.h @@ -28,7 +28,4 @@ using brightray::InspectableWebContentsViewMac; - (void)setIsDocked:(BOOL)docked; - (void)setContentsResizingStrategy:(const DevToolsContentsResizingStrategy&)strategy; -// Adjust docked devtools to the contents resizing strategy. -- (void)update; - @end diff --git a/brightray/browser/mac/bry_inspectable_web_contents_view.mm b/brightray/browser/mac/bry_inspectable_web_contents_view.mm index a0e44633810..0fa06f2077d 100644 --- a/brightray/browser/mac/bry_inspectable_web_contents_view.mm +++ b/brightray/browser/mac/bry_inspectable_web_contents_view.mm @@ -54,13 +54,12 @@ using namespace brightray; // Place the devToolsView under contentsView, notice that we didn't set // sizes for them until the setContentsResizingStrategy message. [self addSubview:devToolsView positioned:NSWindowBelow relativeTo:nil]; - [self update]; + [self adjustSubviews]; // Focus on web view. devToolsWebContents->RestoreFocus(); } else { gfx::ScopedNSDisableScreenUpdates disabler; - devToolsWebContents->RemoveOverlayView(); [devToolsView removeFromSuperview]; [self adjustSubviews]; } @@ -115,20 +114,6 @@ using namespace brightray; - (void)setContentsResizingStrategy:(const DevToolsContentsResizingStrategy&)strategy { strategy_.CopyFrom(strategy); - [self update]; -} - -- (void)update { - if (!devtools_docked_) - return; - - auto contents = inspectableWebContentsView_->inspectable_web_contents()->GetWebContents(); - auto devToolsWebContents = inspectableWebContentsView_->inspectable_web_contents()->devtools_web_contents(); - - gfx::ScopedNSDisableScreenUpdates disabler; - devToolsWebContents->SetOverlayView( - contents, - gfx::Point(strategy_.insets().left(), strategy_.insets().top())); [self adjustSubviews]; } @@ -152,8 +137,6 @@ using namespace brightray; gfx::Rect new_contents_bounds; ApplyDevToolsContentsResizingStrategy( strategy_, gfx::Size(NSSizeToCGSize([self bounds].size)), - [self flipNSRectToRect:[devToolsView bounds]], - [self flipNSRectToRect:[contentsView bounds]], &new_devtools_bounds, &new_contents_bounds); [devToolsView setFrame:[self flipRectToNSRect:new_devtools_bounds]]; [contentsView setFrame:[self flipRectToNSRect:new_contents_bounds]]; From f013a98920a267fbb4262ed07b8c51119ffd2884 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 1 Sep 2014 20:08:31 +0800 Subject: [PATCH 8/8] views: Use new devtools resizing strategy. --- brightray/browser/views/inspectable_web_contents_view_views.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/brightray/browser/views/inspectable_web_contents_view_views.cc b/brightray/browser/views/inspectable_web_contents_view_views.cc index 5a5e1d9ff3e..d76e8efafa0 100644 --- a/brightray/browser/views/inspectable_web_contents_view_views.cc +++ b/brightray/browser/views/inspectable_web_contents_view_views.cc @@ -162,12 +162,9 @@ void InspectableWebContentsViewViews::Layout() { } gfx::Size container_size(width(), height()); - gfx::Rect old_devtools_bounds(devtools_web_view_->bounds()); - gfx::Rect old_contents_bounds(contents_web_view_->bounds()); gfx::Rect new_devtools_bounds; gfx::Rect new_contents_bounds; ApplyDevToolsContentsResizingStrategy(strategy_, container_size, - old_devtools_bounds, old_contents_bounds, &new_devtools_bounds, &new_contents_bounds); // DevTools cares about the specific position, so we have to compensate RTL