diff --git a/ash/test/ash_test_helper.cc b/ash/test/ash_test_helper.cc index bd2e4da8..28d36c9 100644 --- a/ash/test/ash_test_helper.cc +++ b/ash/test/ash_test_helper.cc
@@ -45,6 +45,7 @@ #include "ui/base/material_design/material_design_controller.h" #include "ui/base/platform_window_defaults.h" #include "ui/base/test/material_design_controller_test_api.h" +#include "ui/base/ui_base_switches_util.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h" #include "ui/compositor/test/context_factories_for_test.h" #include "ui/display/display.h" @@ -286,6 +287,8 @@ window_tree_client_private_ = std::make_unique<aura::WindowTreeClientPrivate>(window_tree_client); window_tree_client_private_->CallOnConnect(); + if (!::switches::IsMusHostingViz()) + window_tree_client_setup_.NotifyClientAboutAcceleratedWidget(); } void AshTestHelper::CreateShell() {
diff --git a/build/android/pylib/utils/google_storage_helper.py b/build/android/pylib/utils/google_storage_helper.py index c48543fc..55e4882 100644 --- a/build/android/pylib/utils/google_storage_helper.py +++ b/build/android/pylib/utils/google_storage_helper.py
@@ -29,7 +29,8 @@ @decorators.NoRaiseException(default_return_value='') -def upload(name, filepath, bucket, content_type=None, authenticated_link=True): +def upload(name, filepath, bucket, gs_args=None, command_args=None, + content_type=None, authenticated_link=True): """Uploads data to Google Storage. Args: @@ -51,9 +52,10 @@ logging.info('Uploading %s to %s', filepath, gs_path) cmd = [_GSUTIL_PATH, '-q'] + cmd.extend(gs_args or []) if content_type: cmd.extend(['-h', 'Content-Type:%s' % content_type]) - cmd.extend(['cp', filepath, gs_path]) + cmd.extend(['cp'] + (command_args or []) + [filepath, gs_path]) cmd_helper.RunCmd(cmd)
diff --git a/cc/DEPS b/cc/DEPS index 166ef47..96ddcce4 100644 --- a/cc/DEPS +++ b/cc/DEPS
@@ -9,6 +9,7 @@ "+gpu/command_buffer/common/capabilities.h", "+gpu/command_buffer/common/discardable_handle.h", "+gpu/command_buffer/common/gpu_memory_allocation.h", + "+gpu/command_buffer/common/gpu_memory_buffer_support.h", "+gpu/command_buffer/common/mailbox.h", "+gpu/command_buffer/common/mailbox_holder.h", "+gpu/command_buffer/common/sync_token.h",
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 8ac47a7..7a1c23a4 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -84,8 +84,6 @@ settings.commit_to_active_tree = false; settings.layer_transforms_should_scale_layer_contents = true; settings.create_low_res_tiling = true; - settings.resource_settings.buffer_to_texture_target_map = - viz::DefaultBufferToTextureTargetMapForTesting(); settings.enable_image_animations = true; return settings; }
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index 630fbb6..0aef367 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc
@@ -33,6 +33,7 @@ #include "gpu/command_buffer/client/context_support.h" #include "gpu/command_buffer/client/gles2_interface.h" #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" +#include "gpu/command_buffer/common/gpu_memory_buffer_support.h" #include "skia/ext/texture_handle.h" #include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2ext.h" @@ -176,8 +177,8 @@ next_id_(next_id), next_child_(1), lost_context_provider_(false), - buffer_to_texture_target_map_( - resource_settings.buffer_to_texture_target_map), + texture_target_exception_list_( + resource_settings.texture_target_exception_list), tracing_id_(g_next_resource_provider_tracing_id.GetNext()) { DCHECK(resource_settings.texture_id_allocation_chunk_size); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); @@ -298,9 +299,7 @@ case viz::RGBA_8888: case viz::ETC1: case viz::RGBA_F16: - return buffer_to_texture_target_map_.find( - viz::BufferToTextureTargetKey(usage, BufferFormat(format))) != - buffer_to_texture_target_map_.end(); + return true; // These formats have no BufferFormat equivalent. case viz::ALPHA_8: case viz::LUMINANCE_8: @@ -1020,10 +1019,11 @@ gfx::BufferUsage usage, viz::ResourceFormat format) const { gfx::BufferFormat buffer_format = BufferFormat(format); - auto found = buffer_to_texture_target_map_.find( - viz::BufferToTextureTargetKey(usage, buffer_format)); - DCHECK(found != buffer_to_texture_target_map_.end()); - return found->second; + bool found = std::find(texture_target_exception_list_.begin(), + texture_target_exception_list_.end(), + std::make_pair(usage, buffer_format)) != + texture_target_exception_list_.end(); + return found ? gpu::GetPlatformSpecificTextureTarget() : GL_TEXTURE_2D; } GLES2Interface* ResourceProvider::ContextGL() const {
diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h index dee3fca..caf9726 100644 --- a/cc/resources/resource_provider.h +++ b/cc/resources/resource_provider.h
@@ -436,7 +436,7 @@ bool IsGLContextLost() const; std::unique_ptr<TextureIdAllocator> texture_id_allocator_; - viz::BufferToTextureTargetMap buffer_to_texture_target_map_; + viz::BufferUsageAndFormatList texture_target_exception_list_; // A process-unique ID used for disambiguating memory dumps from different // resource providers.
diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc index 39c3214ed..ff1ed9f 100644 --- a/cc/resources/resource_provider_unittest.cc +++ b/cc/resources/resource_provider_unittest.cc
@@ -99,8 +99,6 @@ texture_id_allocation_chunk_size; resource_settings.use_gpu_memory_buffer_resources = kUseGpuMemoryBufferResources; - resource_settings.buffer_to_texture_target_map = - viz::DefaultBufferToTextureTargetMapForTesting(); return resource_settings; }
diff --git a/cc/test/fake_resource_provider.h b/cc/test/fake_resource_provider.h index d5b217e..8c8afd6 100644 --- a/cc/test/fake_resource_provider.h +++ b/cc/test/fake_resource_provider.h
@@ -24,8 +24,6 @@ bool high_bit_for_testing = false) { viz::ResourceSettings resource_settings; resource_settings.texture_id_allocation_chunk_size = 1; - resource_settings.buffer_to_texture_target_map = - viz::DefaultBufferToTextureTargetMapForTesting(); resource_settings.high_bit_for_testing = high_bit_for_testing; return base::WrapUnique( new FakeResourceProvider(context_provider, shared_bitmap_manager, @@ -40,8 +38,6 @@ bool high_bit_for_testing = false) { viz::ResourceSettings resource_settings; resource_settings.texture_id_allocation_chunk_size = 1; - resource_settings.buffer_to_texture_target_map = - viz::DefaultBufferToTextureTargetMapForTesting(); resource_settings.high_bit_for_testing = high_bit_for_testing; return std::make_unique<LayerTreeResourceProvider>( context_provider, shared_bitmap_manager, gpu_memory_buffer_manager, @@ -54,8 +50,6 @@ gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = nullptr) { viz::ResourceSettings resource_settings; resource_settings.texture_id_allocation_chunk_size = 1; - resource_settings.buffer_to_texture_target_map = - viz::DefaultBufferToTextureTargetMapForTesting(); return std::make_unique<DisplayResourceProvider>( context_provider, shared_bitmap_manager, gpu_memory_buffer_manager, resource_settings); @@ -68,8 +62,6 @@ bool high_bit_for_testing = false) { viz::ResourceSettings resource_settings; resource_settings.texture_id_allocation_chunk_size = 1; - resource_settings.buffer_to_texture_target_map = - viz::DefaultBufferToTextureTargetMapForTesting(); resource_settings.high_bit_for_testing = high_bit_for_testing; return base::WrapUnique(new FakeResourceProvider( context_provider, shared_bitmap_manager, gpu_memory_buffer_manager,
diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index a047004..214b98a 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc
@@ -925,8 +925,6 @@ // Disable latency recovery to make the scheduler more predictable in its // actions and less dependent on timings to make decisions. settings_.enable_latency_recovery = false; - settings_.resource_settings.buffer_to_texture_target_map = - viz::DefaultBufferToTextureTargetMapForTesting(); InitializeSettings(&settings_); base::ThreadTaskRunnerHandle::Get()->PostTask( @@ -957,8 +955,6 @@ // Spend less time waiting for BeginFrame because the output is // mocked out. constexpr double refresh_rate = 200.0; - renderer_settings.resource_settings.buffer_to_texture_target_map = - viz::DefaultBufferToTextureTargetMapForTesting(); auto layer_tree_frame_sink = CreateLayerTreeFrameSink( renderer_settings, refresh_rate, std::move(shared_context_provider), std::move(worker_context_provider));
diff --git a/cc/tiles/tile_manager_unittest.cc b/cc/tiles/tile_manager_unittest.cc index 6a7c7bc..f713e67 100644 --- a/cc/tiles/tile_manager_unittest.cc +++ b/cc/tiles/tile_manager_unittest.cc
@@ -88,8 +88,6 @@ LayerTreeSettings CreateSettings() override { LayerTreeSettings settings; settings.create_low_res_tiling = true; - settings.resource_settings.buffer_to_texture_target_map = - viz::DefaultBufferToTextureTargetMapForTesting(); return settings; } @@ -2150,8 +2148,6 @@ LayerTreeSettings CreateSettings() override { LayerTreeSettings settings; - settings.resource_settings.buffer_to_texture_target_map = - viz::DefaultBufferToTextureTargetMapForTesting(); return settings; } @@ -2427,8 +2423,6 @@ LayerTreeSettings settings; settings.commit_to_active_tree = false; settings.enable_checker_imaging = true; - settings.resource_settings.buffer_to_texture_target_map = - viz::DefaultBufferToTextureTargetMapForTesting(); settings.min_image_bytes_to_checker = 512 * 1024; return settings; }
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 6d7e093..6f5dfd9 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -135,8 +135,6 @@ settings.enable_surface_synchronization = true; settings.minimum_occlusion_tracking_size = gfx::Size(); settings.resource_settings.texture_id_allocation_chunk_size = 1; - settings.resource_settings.buffer_to_texture_target_map = - viz::DefaultBufferToTextureTargetMapForTesting(); return settings; }
diff --git a/chrome/browser/component_updater/cros_component_installer.cc b/chrome/browser/component_updater/cros_component_installer.cc index 82c3ff47..9304f9cf 100644 --- a/chrome/browser/component_updater/cros_component_installer.cc +++ b/chrome/browser/component_updater/cros_component_installer.cc
@@ -46,6 +46,8 @@ {"sha2hashstr", \ "5714811c04f0a63aac96b39096faa759ace4c04e9b68291e7c9716128f5a2722"}}}}; +#define COMPONENTS_ROOT_PATH "cros-components" + using content::BrowserThread; namespace component_updater { @@ -79,10 +81,23 @@ return true; } +void CleanupOldInstalls(const std::string& name) { + // Clean up components installed at old path. + base::FilePath path; + if (!PathService::Get(DIR_COMPONENT_USER, &path)) + return; + path = path.Append(name); + if (base::PathExists(path)) + base::DeleteFile(path, true); +} + update_client::CrxInstaller::Result CrOSComponentInstallerPolicy::OnCustomInstall( const base::DictionaryValue& manifest, const base::FilePath& install_dir) { + // TODO(xiaochu): remove this at M66 (crbug.com/792203). + CleanupOldInstalls(name); + return update_client::CrxInstaller::Result(update_client::InstallError::NONE); } @@ -109,7 +124,8 @@ } base::FilePath CrOSComponentInstallerPolicy::GetRelativeInstallDir() const { - return base::FilePath(name); + base::FilePath path = base::FilePath(COMPONENTS_ROOT_PATH); + return path.Append(name); } void CrOSComponentInstallerPolicy::GetHash(std::vector<uint8_t>* hash) const { @@ -242,6 +258,7 @@ if (!PathService::Get(DIR_COMPONENT_USER, &root)) return configs; + root = root.Append(COMPONENTS_ROOT_PATH); const ConfigMap components = CONFIG_MAP_CONTENT; for (auto it : components) { const std::string& name = it.first;
diff --git a/chrome/browser/extensions/bookmark_app_navigation_throttle.cc b/chrome/browser/extensions/bookmark_app_navigation_throttle.cc index 2ca70d3b..fc6d2eb 100644 --- a/chrome/browser/extensions/bookmark_app_navigation_throttle.cc +++ b/chrome/browser/extensions/bookmark_app_navigation_throttle.cc
@@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/logging.h" +#include "base/metrics/histogram_macros.h" #include "base/threading/thread_task_runner_handle.h" #include "chrome/browser/extensions/launch_util.h" #include "chrome/browser/prerender/prerender_contents.h" @@ -39,6 +40,91 @@ namespace { +enum class ProcessNavigationResult { + kProceedStartedFromContextMenu, + kProceedTransitionTyped, + kProceedTransitionAutoBookmark, + kProceedTransitionAutoSubframe, + kProceedTransitionManualSubframe, + kProceedTransitionGenerated, + kProceedTransitionAutoToplevel, + kProceedTransitionReload, + kProceedTransitionKeyword, + kProceedTransitionKeywordGenerated, + kProceedTransitionForwardBack, + kProceedTransitionFromAddressBar, + kOpenInChromeProceedOutOfScopeLaunch, + kProceedInAppSameScope, + kProceedInBrowserFormSubmission, + kProceedInBrowserSameScope, + kCancelPrerenderContents, + kDeferOpenAppCloseEmptyWebContents, + kCancelOpenedApp, + kDeferOpenNewTabInAppOutOfScope, + // Add ProcessNavigation results immediately above this line. Also + // update the enum list in tools/metrics/enums.xml accordingly. + kCount, +}; + +// Non-app site navigations: The majority of navigations will be in-browser to +// sites for which there is no app installed. These navigations offer no insight +// so we avoid recording their outcome. + +void RecordProcessNavigationResult(ProcessNavigationResult result) { + UMA_HISTOGRAM_ENUMERATION("Extensions.BookmarkApp.NavigationResult", result, + ProcessNavigationResult::kCount); +} + +void RecordProceedWithTransitionType(ui::PageTransition transition_type) { + if (PageTransitionCoreTypeIs(transition_type, ui::PAGE_TRANSITION_LINK)) { + // Link navigations are a special case and shouldn't use this code path. + NOTREACHED(); + } else if (PageTransitionCoreTypeIs(transition_type, + ui::PAGE_TRANSITION_TYPED)) { + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedTransitionTyped); + } else if (PageTransitionCoreTypeIs(transition_type, + ui::PAGE_TRANSITION_AUTO_BOOKMARK)) { + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedTransitionAutoBookmark); + } else if (PageTransitionCoreTypeIs(transition_type, + ui::PAGE_TRANSITION_AUTO_SUBFRAME)) { + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedTransitionAutoSubframe); + } else if (PageTransitionCoreTypeIs(transition_type, + ui::PAGE_TRANSITION_MANUAL_SUBFRAME)) { + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedTransitionManualSubframe); + } else if (PageTransitionCoreTypeIs(transition_type, + ui::PAGE_TRANSITION_GENERATED)) { + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedTransitionGenerated); + } else if (PageTransitionCoreTypeIs(transition_type, + ui::PAGE_TRANSITION_AUTO_TOPLEVEL)) { + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedTransitionAutoToplevel); + } else if (PageTransitionCoreTypeIs(transition_type, + ui::PAGE_TRANSITION_FORM_SUBMIT)) { + // Form navigations are a special case and shouldn't use this code path. + // TODO(crbug.com/772803): Add NOTREACHED() once form navigations are + // handled. + } else if (PageTransitionCoreTypeIs(transition_type, + ui::PAGE_TRANSITION_RELOAD)) { + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedTransitionReload); + } else if (PageTransitionCoreTypeIs(transition_type, + ui::PAGE_TRANSITION_KEYWORD)) { + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedTransitionKeyword); + } else if (PageTransitionCoreTypeIs(transition_type, + ui::PAGE_TRANSITION_KEYWORD_GENERATED)) { + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedTransitionKeywordGenerated); + } else { + NOTREACHED(); + } +} + bool IsWindowedBookmarkApp(const Extension* app, content::BrowserContext* context) { if (!app || !app->from_bookmark()) @@ -122,8 +208,17 @@ content::NavigationThrottle::ThrottleCheckResult BookmarkAppNavigationThrottle::ProcessNavigation(bool is_redirect) { + scoped_refptr<const Extension> target_app = GetTargetApp(); + if (navigation_handle()->WasStartedFromContextMenu()) { DVLOG(1) << "Don't intercept: Navigation started from the context menu."; + + // See "Non-app site navigations" note above. + if (target_app) { + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedStartedFromContextMenu); + } + return content::NavigationThrottle::PROCEED; } @@ -146,10 +241,13 @@ // don't open a new tab. if (app_for_window && app_for_window != GetTargetApp()) { DVLOG(1) << "Out-of-scope navigation during launch. Opening in Chrome."; + RecordProcessNavigationResult( + ProcessNavigationResult::kOpenInChromeProceedOutOfScopeLaunch); Browser* browser = chrome::FindBrowserWithWebContents( navigation_handle()->GetWebContents()); DCHECK(browser); chrome::OpenInChrome(browser); + return content::NavigationThrottle::PROCEED; } } @@ -158,24 +256,57 @@ ui::PAGE_TRANSITION_FORM_SUBMIT)) { DVLOG(1) << "Don't intercept: Transition type is " << PageTransitionGetCoreTransitionString(transition_type); + // We are in one of three possible states: + // 1. In-browser no-target-app navigations, + // 2. In-browser same-scope navigations, or + // 3. In-app same-scope navigations + // Ignore (1) since that's the majority of navigations and offer no insight. + if (target_app) + RecordProceedWithTransitionType(transition_type); + return content::NavigationThrottle::PROCEED; } int32_t transition_qualifier = PageTransitionGetQualifier(transition_type); if (transition_qualifier & ui::PAGE_TRANSITION_FORWARD_BACK) { DVLOG(1) << "Don't intercept: Forward or back navigation."; + + // See "Non-app site navigations" note above. + if (target_app) { + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedTransitionForwardBack); + } return content::NavigationThrottle::PROCEED; } if (transition_qualifier & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR) { DVLOG(1) << "Don't intercept: Address bar navigation."; + + // See "Non-app site navigations" note above. + if (target_app) { + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedTransitionFromAddressBar); + } return content::NavigationThrottle::PROCEED; } scoped_refptr<const Extension> app_for_window = GetAppForWindow(); - scoped_refptr<const Extension> target_app = GetTargetApp(); if (app_for_window == target_app) { + if (app_for_window) { + DVLOG(1) << "Don't intercept: The target URL is in the same scope as the " + << "current app."; + + // We know we are navigating within the same app window (both + // |app_for_window| and |target_app| are the same and non-null). This is + // relevant, so record the result. + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedInAppSameScope); + } else { + DVLOG(1) << "No matching Bookmark App for URL: " + << navigation_handle()->GetURL(); + // See "Non-app site navigations" note above. + } DVLOG(1) << "Don't intercept: The target URL is in the same scope as the " << "current app."; return content::NavigationThrottle::PROCEED; @@ -187,6 +318,8 @@ PageTransitionCoreTypeIs(transition_type, ui::PAGE_TRANSITION_FORM_SUBMIT)) { DVLOG(1) << "Keep form submissions in the browser."; + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedInBrowserFormSubmission); return content::NavigationThrottle::PROCEED; } @@ -199,6 +332,8 @@ // app window if only the Maps app is installed. if (!app_for_window && target_app == GetAppForCurrentURL()) { DVLOG(1) << "Don't intercept: Keep same-app navigations in the browser."; + RecordProcessNavigationResult( + ProcessNavigationResult::kProceedInBrowserSameScope); return content::NavigationThrottle::PROCEED; } @@ -209,10 +344,31 @@ // If prerendering, don't launch the app but abort the navigation. prerender_contents->Destroy( prerender::FINAL_STATUS_NAVIGATION_INTERCEPTED); + RecordProcessNavigationResult( + ProcessNavigationResult::kCancelPrerenderContents); return content::NavigationThrottle::CANCEL_AND_IGNORE; } - return OpenInAppWindowAndCloseTabIfNecessary(target_app); + content::NavigationThrottle::ThrottleCheckResult result = + OpenInAppWindowAndCloseTabIfNecessary(target_app); + + ProcessNavigationResult open_in_app_result; + switch (result.action()) { + case content::NavigationThrottle::DEFER: + open_in_app_result = + ProcessNavigationResult::kDeferOpenAppCloseEmptyWebContents; + break; + case content::NavigationThrottle::CANCEL_AND_IGNORE: + open_in_app_result = ProcessNavigationResult::kCancelOpenedApp; + break; + default: + NOTREACHED(); + open_in_app_result = + ProcessNavigationResult::kDeferOpenAppCloseEmptyWebContents; + } + + RecordProcessNavigationResult(open_in_app_result); + return result; } if (app_for_window) { @@ -224,6 +380,8 @@ base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&BookmarkAppNavigationThrottle::OpenInNewTab, weak_ptr_factory_.GetWeakPtr())); + RecordProcessNavigationResult( + ProcessNavigationResult::kDeferOpenNewTabInAppOutOfScope); return content::NavigationThrottle::DEFER; }
diff --git a/chrome/browser/printing/cloud_print/privet_http_impl.cc b/chrome/browser/printing/cloud_print/privet_http_impl.cc index 15b15a2c..ec8b57c 100644 --- a/chrome/browser/printing/cloud_print/privet_http_impl.cc +++ b/chrome/browser/printing/cloud_print/privet_http_impl.cc
@@ -139,9 +139,8 @@ void PrivetRegisterOperationImpl::Start() { ongoing_ = true; - next_response_handler_ = - base::Bind(&PrivetRegisterOperationImpl::StartResponse, - base::Unretained(this)); + next_response_handler_ = base::BindOnce( + &PrivetRegisterOperationImpl::StartResponse, base::Unretained(this)); SendRequest(kPrivetActionStart); } @@ -160,9 +159,8 @@ } void PrivetRegisterOperationImpl::CompleteRegistration() { - next_response_handler_ = - base::Bind(&PrivetRegisterOperationImpl::CompleteResponse, - base::Unretained(this)); + next_response_handler_ = base::BindOnce( + &PrivetRegisterOperationImpl::CompleteResponse, base::Unretained(this)); SendRequest(kPrivetActionComplete); } @@ -208,7 +206,7 @@ // TODO(noamsml): Match the user&action with the user&action in the object, // and fail if different. - next_response_handler_.Run(value); + std::move(next_response_handler_).Run(value); } void PrivetRegisterOperationImpl::OnNeedPrivetToken( @@ -226,8 +224,8 @@ void PrivetRegisterOperationImpl::StartResponse( const base::DictionaryValue& value) { next_response_handler_ = - base::Bind(&PrivetRegisterOperationImpl::GetClaimTokenResponse, - base::Unretained(this)); + base::BindOnce(&PrivetRegisterOperationImpl::GetClaimTokenResponse, + base::Unretained(this)); SendRequest(kPrivetActionGetClaimToken); } @@ -388,7 +386,7 @@ // TODO(noamsml): Use cached info when available. info_operation_ = privet_client_->CreateInfoOperation( base::BindRepeating(&PrivetLocalPrintOperationImpl::OnPrivetInfoDone, - base::Unretained(this))); + weak_factory_.GetWeakPtr())); info_operation_->Start(); started_ = true; } @@ -445,9 +443,9 @@ } void PrivetLocalPrintOperationImpl::DoCreatejob() { - current_response_ = base::Bind( - &PrivetLocalPrintOperationImpl::OnCreatejobResponse, - base::Unretained(this)); + current_response_ = + base::BindOnce(&PrivetLocalPrintOperationImpl::OnCreatejobResponse, + weak_factory_.GetWeakPtr()); url_fetcher_ = privet_client_->CreateURLFetcher( CreatePrivetURL(kPrivetCreatejobPath), net::URLFetcher::POST, this); @@ -458,9 +456,9 @@ } void PrivetLocalPrintOperationImpl::DoSubmitdoc() { - current_response_ = base::Bind( - &PrivetLocalPrintOperationImpl::OnSubmitdocResponse, - base::Unretained(this)); + current_response_ = + base::BindOnce(&PrivetLocalPrintOperationImpl::OnSubmitdocResponse, + weak_factory_.GetWeakPtr()); GURL url = CreatePrivetURL(kPrivetSubmitdocPath); @@ -525,7 +523,7 @@ PWGRasterConverter::GetConversionSettings(capabilities_, page_size_), PWGRasterConverter::GetBitmapSettings(capabilities_, ticket_), base::Bind(&PrivetLocalPrintOperationImpl::OnPWGRasterConverted, - base::Unretained(this))); + weak_factory_.GetWeakPtr())); } void PrivetLocalPrintOperationImpl::OnSubmitdocResponse( @@ -613,8 +611,8 @@ int response_code, const base::DictionaryValue& value, bool has_error) { - DCHECK(!current_response_.is_null()); - current_response_.Run(has_error, &value); + DCHECK(current_response_); + std::move(current_response_).Run(has_error, &value); } void PrivetLocalPrintOperationImpl::OnNeedPrivetToken(
diff --git a/chrome/browser/printing/cloud_print/privet_http_impl.h b/chrome/browser/printing/cloud_print/privet_http_impl.h index cdc7901..0de18bb 100644 --- a/chrome/browser/printing/cloud_print/privet_http_impl.h +++ b/chrome/browser/printing/cloud_print/privet_http_impl.h
@@ -88,8 +88,8 @@ }; // Arguments is JSON value from request. - typedef base::Callback<void(const base::DictionaryValue&)> - ResponseHandler; + using ResponseHandler = + base::OnceCallback<void(const base::DictionaryValue&)>; void StartInfoOperation(); void OnPrivetInfoDone(const base::DictionaryValue* value); @@ -171,8 +171,9 @@ void OnNeedPrivetToken(PrivetURLFetcher::TokenCallback callback) override; private: - typedef base::Callback<void(bool, const base::DictionaryValue* value)> - ResponseCallback; + using ResponseCallback = + base::OnceCallback<void(/*has_error=*/bool, + const base::DictionaryValue* value)>; void StartInitialRequest(); void DoCreatejob();
diff --git a/components/component_updater/component_installer.cc b/components/component_updater/component_installer.cc index 33ad68b..499b32a 100644 --- a/components/component_updater/component_installer.cc +++ b/components/component_updater/component_installer.cc
@@ -274,10 +274,11 @@ // Then check for a higher-versioned user-wide installation. base::FilePath latest_path; std::unique_ptr<base::DictionaryValue> latest_manifest; - base::FilePath base_dir; - if (!PathService::Get(DIR_COMPONENT_USER, &base_dir)) + base::FilePath base_component_dir; + if (!PathService::Get(DIR_COMPONENT_USER, &base_component_dir)) return; - base_dir = base_dir.Append(installer_policy_->GetRelativeInstallDir()); + base::FilePath base_dir = + base_component_dir.Append(installer_policy_->GetRelativeInstallDir()); if (!base::PathExists(base_dir) && !base::CreateDirectory(base_dir)) { PLOG(ERROR) << "Could not create the base directory for " << installer_policy_->GetName() << " (" @@ -286,9 +287,15 @@ } #if defined(OS_CHROMEOS) - if (!base::SetPosixFilePermissions(base_dir, 0755)) { - PLOG(ERROR) << "SetPosixFilePermissions failed: " << base_dir.value(); - return; + base::FilePath base_dir_ = base_component_dir; + std::vector<base::FilePath::StringType> components; + installer_policy_->GetRelativeInstallDir().GetComponents(&components); + for (const base::FilePath::StringType component : components) { + base_dir_ = base_dir_.Append(component); + if (!base::SetPosixFilePermissions(base_dir_, 0755)) { + PLOG(ERROR) << "SetPosixFilePermissions failed: " << base_dir.value(); + return; + } } #endif // defined(OS_CHROMEOS)
diff --git a/components/viz/common/resources/buffer_to_texture_target_map.cc b/components/viz/common/resources/buffer_to_texture_target_map.cc index 4d3e66b9..4717763 100644 --- a/components/viz/common/resources/buffer_to_texture_target_map.cc +++ b/components/viz/common/resources/buffer_to_texture_target_map.cc
@@ -7,66 +7,43 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" -#include "third_party/khronos/GLES2/gl2.h" namespace viz { -BufferToTextureTargetMap StringToBufferToTextureTargetMap( +BufferUsageAndFormatList StringToBufferUsageAndFormatList( const std::string& str) { - BufferToTextureTargetMap map; + BufferUsageAndFormatList usage_format_list; std::vector<std::string> entries = base::SplitString(str, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); for (const auto& entry : entries) { std::vector<std::string> fields = base::SplitString( entry, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); - CHECK_EQ(fields.size(), 3u); + CHECK_EQ(fields.size(), 2u); uint32_t usage = 0; uint32_t format = 0; - uint32_t target = 0; bool succeeded = base::StringToUint(fields[0], &usage) && - base::StringToUint(fields[1], &format) && - base::StringToUint(fields[2], &target); + base::StringToUint(fields[1], &format); CHECK(succeeded); CHECK_LE(usage, static_cast<uint32_t>(gfx::BufferUsage::LAST)); CHECK_LE(format, static_cast<uint32_t>(gfx::BufferFormat::LAST)); - map.insert(BufferToTextureTargetMap::value_type( - BufferToTextureTargetKey(static_cast<gfx::BufferUsage>(usage), - static_cast<gfx::BufferFormat>(format)), - target)); + usage_format_list.push_back( + std::make_pair(static_cast<gfx::BufferUsage>(usage), + static_cast<gfx::BufferFormat>(format))); } - return map; + return usage_format_list; } -std::string BufferToTextureTargetMapToString( - const BufferToTextureTargetMap& map) { +std::string BufferUsageAndFormatListToString( + const BufferUsageAndFormatList& usage_format_list) { std::string str; - for (const auto& entry : map) { + for (const auto& entry : usage_format_list) { if (!str.empty()) str += ";"; - str += base::UintToString(static_cast<uint32_t>(entry.first.first)); + str += base::UintToString(static_cast<uint32_t>(entry.first)); str += ","; - str += base::UintToString(static_cast<uint32_t>(entry.first.second)); - str += ","; - str += base::UintToString(entry.second); + str += base::UintToString(static_cast<uint32_t>(entry.second)); } return str; } -BufferToTextureTargetMap DefaultBufferToTextureTargetMapForTesting() { - BufferToTextureTargetMap image_targets; - for (int usage_idx = 0; usage_idx <= static_cast<int>(gfx::BufferUsage::LAST); - ++usage_idx) { - gfx::BufferUsage usage = static_cast<gfx::BufferUsage>(usage_idx); - for (int format_idx = 0; - format_idx <= static_cast<int>(gfx::BufferFormat::LAST); - ++format_idx) { - gfx::BufferFormat format = static_cast<gfx::BufferFormat>(format_idx); - image_targets.insert(BufferToTextureTargetMap::value_type( - BufferToTextureTargetKey(usage, format), GL_TEXTURE_2D)); - } - } - - return image_targets; -} - } // namespace viz
diff --git a/components/viz/common/resources/buffer_to_texture_target_map.h b/components/viz/common/resources/buffer_to_texture_target_map.h index 27539475..9bf00e71 100644 --- a/components/viz/common/resources/buffer_to_texture_target_map.h +++ b/components/viz/common/resources/buffer_to_texture_target_map.h
@@ -7,30 +7,27 @@ #include <map> #include <string> +#include <vector> #include "components/viz/common/viz_common_export.h" #include "ui/gfx/buffer_types.h" namespace viz { -// A map of GPU Memory Buffer usage/format to GL texture target. -using BufferToTextureTargetKey = std::pair<gfx::BufferUsage, gfx::BufferFormat>; -using BufferToTextureTargetMap = std::map<BufferToTextureTargetKey, uint32_t>; +// A pair containing GPU Memory Buffer usage and format. +using BufferUsageAndFormat = std::pair<gfx::BufferUsage, gfx::BufferFormat>; +using BufferUsageAndFormatList = std::vector<BufferUsageAndFormat>; -// Converts a serialized ImageTextureTargetsMap back to the runtime format. -// Serialization takes the form: -// "usage,format,target;usage,format,target;...;usage,format,target" -VIZ_COMMON_EXPORT BufferToTextureTargetMap -StringToBufferToTextureTargetMap(const std::string& str); +// Converts a serialized list of BufferUsageAndFormat back to the runtime +// format. Serialization takes the form: +// "usage,format;usage,format;...;usage,format" +VIZ_COMMON_EXPORT BufferUsageAndFormatList +StringToBufferUsageAndFormatList(const std::string& str); -// Converts an ImageTextureTargetsMap to a string representation of the format: -// "usage,format,target;usage,format,target;...;usage,format,target" -VIZ_COMMON_EXPORT std::string BufferToTextureTargetMapToString( - const BufferToTextureTargetMap& map); - -// Returns a default-initialized BufferToTextureTargetsMap where every entry -// maps to GL_TEXTURE_2D. -VIZ_COMMON_EXPORT BufferToTextureTargetMap -DefaultBufferToTextureTargetMapForTesting(); +// Converts a vector of BufferUsageAndFormat to a string representation of the +// format: +// "usage,format;usage,format;...;usage,format" +VIZ_COMMON_EXPORT std::string BufferUsageAndFormatListToString( + const BufferUsageAndFormatList& usage_and_format); } // namespace viz
diff --git a/components/viz/common/resources/buffer_to_texture_target_map_unittest.cc b/components/viz/common/resources/buffer_to_texture_target_map_unittest.cc index f037b998..79f3805 100644 --- a/components/viz/common/resources/buffer_to_texture_target_map_unittest.cc +++ b/components/viz/common/resources/buffer_to_texture_target_map_unittest.cc
@@ -10,11 +10,10 @@ namespace viz { namespace { -// Ensures that a map populated with various values can be serialized to/from +// Ensures that a list populated with various values can be serialized to/from // string successfully. -TEST(BufferToTextureTargetMapTest, SerializeRoundTrip) { - BufferToTextureTargetMap test_map; - uint32_t next_value = 0; +TEST(BuffferUsageAndFormatList, SerializeRoundTrip) { + BufferUsageAndFormatList test_list; for (int usage_idx = 0; usage_idx <= static_cast<int>(gfx::BufferUsage::LAST); ++usage_idx) { gfx::BufferUsage usage = static_cast<gfx::BufferUsage>(usage_idx); @@ -22,15 +21,14 @@ format_idx <= static_cast<int>(gfx::BufferFormat::LAST); ++format_idx) { gfx::BufferFormat format = static_cast<gfx::BufferFormat>(format_idx); - test_map.insert(BufferToTextureTargetMap::value_type( - BufferToTextureTargetKey(usage, format), next_value++)); + test_list.push_back(std::make_pair(usage, format)); } } - std::string serialized_map = BufferToTextureTargetMapToString(test_map); - BufferToTextureTargetMap deserialized_map = - StringToBufferToTextureTargetMap(serialized_map); - EXPECT_EQ(test_map, deserialized_map); + std::string serialized_list = BufferUsageAndFormatListToString(test_list); + BufferUsageAndFormatList deserialized_list = + StringToBufferUsageAndFormatList(serialized_list); + EXPECT_EQ(test_list, deserialized_list); } } // namespace
diff --git a/components/viz/common/resources/resource_settings.h b/components/viz/common/resources/resource_settings.h index 4ace644..ec544006 100644 --- a/components/viz/common/resources/resource_settings.h +++ b/components/viz/common/resources/resource_settings.h
@@ -24,7 +24,9 @@ bool high_bit_for_testing = false; // TODO(riju): Remove after r16 is used without the flag. crbug.com/759456 bool use_r16_texture = false; - BufferToTextureTargetMap buffer_to_texture_target_map; + // A list of buffer usage/format for which a per platform specific texture + // target should be used, instead of TEXTURE_2D. + BufferUsageAndFormatList texture_target_exception_list; }; } // namespace viz
diff --git a/components/viz/host/renderer_settings_creation.cc b/components/viz/host/renderer_settings_creation.cc index f0b7646..661fec9 100644 --- a/components/viz/host/renderer_settings_creation.cc +++ b/components/viz/host/renderer_settings_creation.cc
@@ -36,14 +36,15 @@ } // namespace ResourceSettings CreateResourceSettings( - const BufferToTextureTargetMap& image_targets) { + const BufferUsageAndFormatList& texture_target_exception_list) { ResourceSettings resource_settings; - resource_settings.buffer_to_texture_target_map = image_targets; + resource_settings.texture_target_exception_list = + texture_target_exception_list; return resource_settings; } RendererSettings CreateRendererSettings( - const BufferToTextureTargetMap& image_targets) { + const BufferUsageAndFormatList& texture_target_exception_list) { RendererSettings renderer_settings; base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); renderer_settings.partial_swap_enabled = @@ -60,7 +61,8 @@ command_line->HasSwitch(switches::kShowOverdrawFeedback); renderer_settings.enable_draw_occlusion = command_line->HasSwitch(switches::kEnableDrawOcclusion); - renderer_settings.resource_settings = CreateResourceSettings(image_targets); + renderer_settings.resource_settings = + CreateResourceSettings(texture_target_exception_list); renderer_settings.disallow_non_exact_resource_reuse = command_line->HasSwitch(switches::kDisallowNonExactResourceReuse); renderer_settings.allow_antialiasing =
diff --git a/components/viz/host/renderer_settings_creation.h b/components/viz/host/renderer_settings_creation.h index 3c8459a..231ab940 100644 --- a/components/viz/host/renderer_settings_creation.h +++ b/components/viz/host/renderer_settings_creation.h
@@ -19,11 +19,11 @@ // |image_targets| is a map from every supported pair of GPU memory buffer // usage/format to its GL texture target. -VIZ_HOST_EXPORT ResourceSettings -CreateResourceSettings(const BufferToTextureTargetMap& image_targets); +VIZ_HOST_EXPORT ResourceSettings CreateResourceSettings( + const BufferUsageAndFormatList& texture_target_exception_list); -VIZ_HOST_EXPORT RendererSettings -CreateRendererSettings(const BufferToTextureTargetMap& image_targets); +VIZ_HOST_EXPORT RendererSettings CreateRendererSettings( + const BufferUsageAndFormatList& texture_target_exception_list); } // namespace viz
diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc index 496990c..d414fb7 100644 --- a/content/browser/compositor/gpu_process_transport_factory.cc +++ b/content/browser/compositor/gpu_process_transport_factory.cc
@@ -188,8 +188,8 @@ viz::CompositingModeReporterImpl* compositing_mode_reporter, scoped_refptr<base::SingleThreadTaskRunner> resize_task_runner) : frame_sink_id_allocator_(kDefaultClientId), - renderer_settings_( - viz::CreateRendererSettings(CreateBufferToTextureTargetMap())), + renderer_settings_(viz::CreateRendererSettings( + CreateBufferUsageAndFormatExceptionList())), resize_task_runner_(std::move(resize_task_runner)), task_graph_runner_(new cc::SingleThreadTaskGraphRunner), gpu_channel_factory_(gpu_channel_factory),
diff --git a/content/browser/compositor/viz_process_transport_factory.cc b/content/browser/compositor/viz_process_transport_factory.cc index 8fd77c1..2ce0aa2 100644 --- a/content/browser/compositor/viz_process_transport_factory.cc +++ b/content/browser/compositor/viz_process_transport_factory.cc
@@ -85,8 +85,8 @@ forwarding_mode_reporter_(forwarding_mode_reporter), frame_sink_id_allocator_(kBrowserClientId), task_graph_runner_(std::make_unique<cc::SingleThreadTaskGraphRunner>()), - renderer_settings_( - viz::CreateRendererSettings(CreateBufferToTextureTargetMap())), + renderer_settings_(viz::CreateRendererSettings( + CreateBufferUsageAndFormatExceptionList())), compositing_mode_watcher_binding_(this), weak_ptr_factory_(this) { DCHECK(gpu_channel_establish_factory_);
diff --git a/content/browser/devtools/protocol/page_handler.cc b/content/browser/devtools/protocol/page_handler.cc index bab5656..1b94897c 100644 --- a/content/browser/devtools/protocol/page_handler.cc +++ b/content/browser/devtools/protocol/page_handler.cc
@@ -355,14 +355,18 @@ Referrer(GURL(referrer.fromMaybe("")), blink::kWebReferrerPolicyDefault), type, std::string()); if (IsBrowserSideNavigationEnabled()) { + std::string frame_id = + web_contents->GetMainFrame()->GetDevToolsFrameToken().ToString(); if (navigate_callback_) { - std::string frame_id = - web_contents->GetMainFrame()->GetDevToolsFrameToken().ToString(); std::string error_string = net::ErrorToString(net::ERR_ABORTED); navigate_callback_->sendSuccess(frame_id, Maybe<std::string>(), Maybe<std::string>(error_string)); } - navigate_callback_ = std::move(callback); + if (web_contents->GetMainFrame()->frame_tree_node()->navigation_request()) + navigate_callback_ = std::move(callback); + else + callback->sendSuccess(frame_id, Maybe<std::string>(), + Maybe<std::string>()); return; } callback->fallThrough();
diff --git a/content/browser/gpu/compositor_util.cc b/content/browser/gpu/compositor_util.cc index 53031f3..f7ecab3c9 100644 --- a/content/browser/gpu/compositor_util.cc +++ b/content/browser/gpu/compositor_util.cc
@@ -22,6 +22,7 @@ #include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/public/common/content_features.h" #include "content/public/common/content_switches.h" +#include "gpu/command_buffer/common/gpu_memory_buffer_support.h" #include "gpu/config/gpu_feature_type.h" #include "gpu/config/gpu_finch_features.h" #include "gpu/ipc/host/gpu_memory_buffer_support.h" @@ -399,8 +400,8 @@ return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); } -viz::BufferToTextureTargetMap CreateBufferToTextureTargetMap() { - viz::BufferToTextureTargetMap image_targets; +viz::BufferUsageAndFormatList CreateBufferUsageAndFormatExceptionList() { + viz::BufferUsageAndFormatList usage_format_list; for (int usage_idx = 0; usage_idx <= static_cast<int>(gfx::BufferUsage::LAST); ++usage_idx) { gfx::BufferUsage usage = static_cast<gfx::BufferUsage>(usage_idx); @@ -408,11 +409,11 @@ format_idx <= static_cast<int>(gfx::BufferFormat::LAST); ++format_idx) { gfx::BufferFormat format = static_cast<gfx::BufferFormat>(format_idx); - uint32_t target = gpu::GetImageTextureTarget(format, usage); - image_targets[std::make_pair(usage, format)] = target; + if (gpu::GetImageNeedsPlatformSpecificTextureTarget(format, usage)) + usage_format_list.push_back(std::make_pair(usage, format)); } } - return image_targets; + return usage_format_list; } } // namespace content
diff --git a/content/browser/gpu/compositor_util.h b/content/browser/gpu/compositor_util.h index 139a9d7e..d8e8add3 100644 --- a/content/browser/gpu/compositor_util.h +++ b/content/browser/gpu/compositor_util.h
@@ -55,8 +55,10 @@ CONTENT_EXPORT std::unique_ptr<base::ListValue> GetProblems(); CONTENT_EXPORT std::vector<std::string> GetDriverBugWorkarounds(); -// Populate BufferToTextureTargetMap for all buffer usage/formats. -CONTENT_EXPORT viz::BufferToTextureTargetMap CreateBufferToTextureTargetMap(); +// Populate a list of buffer usage/format for which a per platform specific +// texture target must be used instead of GL_TEXTURE_2D. +CONTENT_EXPORT viz::BufferUsageAndFormatList +CreateBufferUsageAndFormatExceptionList(); } // namespace content
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc index 4e1f6938..6c623c7 100644 --- a/content/browser/renderer_host/compositor_impl_android.cc +++ b/content/browser/renderer_host/compositor_impl_android.cc
@@ -584,8 +584,8 @@ settings.initial_debug_state.show_fps_counter = command_line->HasSwitch(cc::switches::kUIShowFPSCounter); settings.single_thread_proxy_scheduler = true; - settings.resource_settings.buffer_to_texture_target_map = - CreateBufferToTextureTargetMap(); + settings.resource_settings.texture_target_exception_list = + CreateBufferUsageAndFormatExceptionList(); animation_host_ = cc::AnimationHost::CreateMainInstance();
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index f8c24b4..3dd28ae 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -2447,7 +2447,8 @@ command_line->AppendSwitchASCII( switches::kContentImageTextureTarget, - viz::BufferToTextureTargetMapToString(CreateBufferToTextureTargetMap())); + viz::BufferUsageAndFormatListToString( + CreateBufferUsageAndFormatExceptionList())); // Appending disable-gpu-feature switches due to software rendering list. GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance();
diff --git a/content/renderer/gpu/compositor_dependencies.h b/content/renderer/gpu/compositor_dependencies.h index 91f629e..83cdb1e14 100644 --- a/content/renderer/gpu/compositor_dependencies.h +++ b/content/renderer/gpu/compositor_dependencies.h
@@ -39,8 +39,8 @@ virtual bool IsPartialRasterEnabled() = 0; virtual bool IsGpuMemoryBufferCompositorResourcesEnabled() = 0; virtual bool IsElasticOverscrollEnabled() = 0; - virtual const viz::BufferToTextureTargetMap& - GetBufferToTextureTargetMap() = 0; + virtual const viz::BufferUsageAndFormatList& + GetTextureTargetExceptionList() = 0; virtual scoped_refptr<base::SingleThreadTaskRunner> GetCompositorMainThreadTaskRunner() = 0; // Returns null if the compositor is in single-threaded mode (ie. there is no
diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc index 3b266c56..4aa00c7 100644 --- a/content/renderer/gpu/render_widget_compositor.cc +++ b/content/renderer/gpu/render_widget_compositor.cc
@@ -426,8 +426,8 @@ compositor_deps->IsElasticOverscrollEnabled(); settings.resource_settings.use_gpu_memory_buffer_resources = compositor_deps->IsGpuMemoryBufferCompositorResourcesEnabled(); - settings.resource_settings.buffer_to_texture_target_map = - compositor_deps->GetBufferToTextureTargetMap(); + settings.resource_settings.texture_target_exception_list = + compositor_deps->GetTextureTargetExceptionList(); settings.enable_oop_rasterization = cmd.HasSwitch(switches::kEnableOOPRasterization);
diff --git a/content/renderer/media/gpu/gpu_video_accelerator_factories_impl.cc b/content/renderer/media/gpu/gpu_video_accelerator_factories_impl.cc index dfa9aa2..628bb99 100644 --- a/content/renderer/media/gpu/gpu_video_accelerator_factories_impl.cc +++ b/content/renderer/media/gpu/gpu_video_accelerator_factories_impl.cc
@@ -19,7 +19,9 @@ #include "content/renderer/render_thread_impl.h" #include "gpu/command_buffer/client/gles2_interface.h" #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" +#include "gpu/command_buffer/common/gpu_memory_buffer_support.h" #include "gpu/ipc/client/gpu_channel_host.h" +#include "gpu/ipc/common/gpu_memory_buffer_support.h" #include "media/gpu/gpu_video_accelerator_util.h" #include "media/gpu/ipc/client/gpu_video_decode_accelerator_host.h" #include "media/gpu/ipc/client/gpu_video_encode_accelerator_host.h" @@ -56,7 +58,7 @@ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, const scoped_refptr<ui::ContextProviderCommandBuffer>& context_provider, bool enable_gpu_memory_buffer_video_frames, - const viz::BufferToTextureTargetMap& image_texture_targets, + const viz::BufferUsageAndFormatList& texture_target_exception_list, bool enable_video_accelerator, media::mojom::VideoEncodeAcceleratorProviderPtrInfo unbound_vea_provider) { RecordContextProviderPhaseUmaEnum( @@ -64,7 +66,7 @@ return base::WrapUnique(new GpuVideoAcceleratorFactoriesImpl( std::move(gpu_channel_host), main_thread_task_runner, task_runner, context_provider, enable_gpu_memory_buffer_video_frames, - image_texture_targets, enable_video_accelerator, + texture_target_exception_list, enable_video_accelerator, std::move(unbound_vea_provider))); } @@ -74,7 +76,7 @@ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, const scoped_refptr<ui::ContextProviderCommandBuffer>& context_provider, bool enable_gpu_memory_buffer_video_frames, - const viz::BufferToTextureTargetMap& image_texture_targets, + const viz::BufferUsageAndFormatList& texture_target_exception_list, bool enable_video_accelerator, media::mojom::VideoEncodeAcceleratorProviderPtrInfo unbound_vea_provider) : main_thread_task_runner_(main_thread_task_runner), @@ -84,7 +86,7 @@ context_provider_(context_provider.get()), enable_gpu_memory_buffer_video_frames_( enable_gpu_memory_buffer_video_frames), - image_texture_targets_(image_texture_targets), + texture_target_exception_list_(texture_target_exception_list), video_accelerator_enabled_(enable_video_accelerator), gpu_memory_buffer_manager_( RenderThreadImpl::current()->GetGpuMemoryBufferManager()), @@ -294,10 +296,13 @@ unsigned GpuVideoAcceleratorFactoriesImpl::ImageTextureTarget( gfx::BufferFormat format) { - auto found = image_texture_targets_.find(viz::BufferToTextureTargetKey( - gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, format)); - DCHECK(found != image_texture_targets_.end()); - return found->second; + auto it = std::find(texture_target_exception_list_.begin(), + texture_target_exception_list_.end(), + viz::BufferUsageAndFormat( + gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, format)); + if (it == texture_target_exception_list_.end()) + return GL_TEXTURE_2D; + return gpu::GetPlatformSpecificTextureTarget(); } media::GpuVideoAcceleratorFactories::OutputFormat
diff --git a/content/renderer/media/gpu/gpu_video_accelerator_factories_impl.h b/content/renderer/media/gpu/gpu_video_accelerator_factories_impl.h index fddca97..b70c03b 100644 --- a/content/renderer/media/gpu/gpu_video_accelerator_factories_impl.h +++ b/content/renderer/media/gpu/gpu_video_accelerator_factories_impl.h
@@ -59,7 +59,7 @@ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, const scoped_refptr<ui::ContextProviderCommandBuffer>& context_provider, bool enable_gpu_memory_buffer_video_frames, - const viz::BufferToTextureTargetMap& image_texture_targets, + const viz::BufferUsageAndFormatList& texture_target_exception_list, bool enable_video_accelerator, media::mojom::VideoEncodeAcceleratorProviderPtrInfo unbound_vea_provider); @@ -117,7 +117,7 @@ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, const scoped_refptr<ui::ContextProviderCommandBuffer>& context_provider, bool enable_gpu_memory_buffer_video_frames, - const viz::BufferToTextureTargetMap& image_texture_targets, + const viz::BufferUsageAndFormatList& texture_target_exception_list, bool enable_video_accelerator, media::mojom::VideoEncodeAcceleratorProviderPtrInfo unbound_vea_provider); @@ -139,7 +139,7 @@ // Whether gpu memory buffers should be used to hold video frames data. bool enable_gpu_memory_buffer_video_frames_; - const viz::BufferToTextureTargetMap image_texture_targets_; + const viz::BufferUsageAndFormatList texture_target_exception_list_; // Whether video acceleration encoding/decoding should be enabled. const bool video_accelerator_enabled_;
diff --git a/content/renderer/pepper/pepper_graphics_2d_host.cc b/content/renderer/pepper/pepper_graphics_2d_host.cc index 4167235..e3b9a839 100644 --- a/content/renderer/pepper/pepper_graphics_2d_host.cc +++ b/content/renderer/pepper/pepper_graphics_2d_host.cc
@@ -30,6 +30,8 @@ #include "gpu/GLES2/gl2extchromium.h" #include "gpu/command_buffer/client/gles2_interface.h" #include "gpu/command_buffer/common/capabilities.h" +#include "gpu/command_buffer/common/gpu_memory_buffer_support.h" +#include "gpu/ipc/common/gpu_memory_buffer_support.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_rect.h" @@ -232,15 +234,22 @@ // image-backed textures for direct scanout (for use in overlays). RenderThreadImpl* rti = RenderThreadImpl::current(); if (rti && rti->IsGpuMemoryBufferCompositorResourcesEnabled()) { - const auto& map = rti->GetBufferToTextureTargetMap(); - auto target_it = map.find(viz::BufferToTextureTargetKey( - gfx::BufferUsage::SCANOUT, gfx::BufferFormat::BGRA_8888)); - if (target_it != map.end()) - scanout_texture_target_bgra_ = target_it->second; - target_it = map.find(viz::BufferToTextureTargetKey( - gfx::BufferUsage::SCANOUT, gfx::BufferFormat::RGBA_8888)); - if (target_it != map.end()) - scanout_texture_target_rgba_ = target_it->second; + const auto& list = rti->GetTextureTargetExceptionList(); + if (base::ContainsValue( + list, viz::BufferUsageAndFormat(gfx::BufferUsage::SCANOUT, + gfx::BufferFormat::BGRA_8888))) { + scanout_texture_target_bgra_ = gpu::GetPlatformSpecificTextureTarget(); + } else { + scanout_texture_target_bgra_ = GL_TEXTURE_2D; + } + + if (base::ContainsValue( + list, viz::BufferUsageAndFormat(gfx::BufferUsage::SCANOUT, + gfx::BufferFormat::RGBA_8888))) { + scanout_texture_target_rgba_ = gpu::GetPlatformSpecificTextureTarget(); + } else { + scanout_texture_target_rgba_ = GL_TEXTURE_2D; + } } return true;
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index ee79aaf2..ba46b442 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc
@@ -860,8 +860,8 @@ std::string image_texture_target_string = command_line.GetSwitchValueASCII(switches::kContentImageTextureTarget); - buffer_to_texture_target_map_ = - viz::StringToBufferToTextureTargetMap(image_texture_target_string); + texture_target_exception_list_ = + viz::StringToBufferUsageAndFormatList(image_texture_target_string); if (command_line.HasSwitch(switches::kDisableLCDText)) { is_lcd_text_enabled_ = false; @@ -1515,7 +1515,7 @@ gpu_factories_.push_back(GpuVideoAcceleratorFactoriesImpl::Create( std::move(gpu_channel_host), base::ThreadTaskRunnerHandle::Get(), media_task_runner, std::move(media_context_provider), - enable_gpu_memory_buffer_video_frames, buffer_to_texture_target_map_, + enable_gpu_memory_buffer_video_frames, texture_target_exception_list_, enable_video_accelerator, vea_provider.PassInterface())); return gpu_factories_.back().get(); } @@ -1655,9 +1655,9 @@ return is_elastic_overscroll_enabled_; } -const viz::BufferToTextureTargetMap& -RenderThreadImpl::GetBufferToTextureTargetMap() { - return buffer_to_texture_target_map_; +const viz::BufferUsageAndFormatList& +RenderThreadImpl::GetTextureTargetExceptionList() { + return texture_target_exception_list_; } scoped_refptr<base::SingleThreadTaskRunner>
diff --git a/content/renderer/render_thread_impl.h b/content/renderer/render_thread_impl.h index 379bdd3..fbc4ef2 100644 --- a/content/renderer/render_thread_impl.h +++ b/content/renderer/render_thread_impl.h
@@ -257,7 +257,7 @@ bool IsPartialRasterEnabled() override; bool IsGpuMemoryBufferCompositorResourcesEnabled() override; bool IsElasticOverscrollEnabled() override; - const viz::BufferToTextureTargetMap& GetBufferToTextureTargetMap() override; + const viz::BufferUsageAndFormatList& GetTextureTargetExceptionList() override; scoped_refptr<base::SingleThreadTaskRunner> GetCompositorMainThreadTaskRunner() override; scoped_refptr<base::SingleThreadTaskRunner> @@ -786,7 +786,7 @@ bool is_gpu_memory_buffer_compositor_resources_enabled_; bool is_partial_raster_enabled_; bool is_elastic_overscroll_enabled_; - viz::BufferToTextureTargetMap buffer_to_texture_target_map_; + viz::BufferUsageAndFormatList texture_target_exception_list_; bool is_threaded_animation_enabled_; bool is_scroll_animator_enabled_;
diff --git a/content/renderer/render_thread_impl_browsertest.cc b/content/renderer/render_thread_impl_browsertest.cc index d591bd6..8fdae8b 100644 --- a/content/renderer/render_thread_impl_browsertest.cc +++ b/content/renderer/render_thread_impl_browsertest.cc
@@ -215,8 +215,7 @@ cmd->AppendSwitchASCII(switches::kNumRasterThreads, "1"); cmd->AppendSwitchASCII( switches::kContentImageTextureTarget, - viz::BufferToTextureTargetMapToString( - viz::DefaultBufferToTextureTargetMapForTesting())); + viz::BufferUsageAndFormatListToString(viz::BufferUsageAndFormatList())); std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler = blink::scheduler::RendererScheduler::Create();
diff --git a/content/test/fake_compositor_dependencies.cc b/content/test/fake_compositor_dependencies.cc index ad987db..56863e3e 100644 --- a/content/test/fake_compositor_dependencies.cc +++ b/content/test/fake_compositor_dependencies.cc
@@ -57,9 +57,9 @@ return true; } -const viz::BufferToTextureTargetMap& -FakeCompositorDependencies::GetBufferToTextureTargetMap() { - return buffer_to_texture_target_map_; +const viz::BufferUsageAndFormatList& +FakeCompositorDependencies::GetTextureTargetExceptionList() { + return texture_target_exception_list_; } scoped_refptr<base::SingleThreadTaskRunner>
diff --git a/content/test/fake_compositor_dependencies.h b/content/test/fake_compositor_dependencies.h index f22d4db..f31a7ca4 100644 --- a/content/test/fake_compositor_dependencies.h +++ b/content/test/fake_compositor_dependencies.h
@@ -29,7 +29,7 @@ bool IsPartialRasterEnabled() override; bool IsGpuMemoryBufferCompositorResourcesEnabled() override; bool IsElasticOverscrollEnabled() override; - const viz::BufferToTextureTargetMap& GetBufferToTextureTargetMap() override; + const viz::BufferUsageAndFormatList& GetTextureTargetExceptionList() override; scoped_refptr<base::SingleThreadTaskRunner> GetCompositorMainThreadTaskRunner() override; scoped_refptr<base::SingleThreadTaskRunner> @@ -43,7 +43,7 @@ private: cc::TestTaskGraphRunner task_graph_runner_; blink::scheduler::FakeRendererScheduler renderer_scheduler_; - viz::BufferToTextureTargetMap buffer_to_texture_target_map_; + viz::BufferUsageAndFormatList texture_target_exception_list_; DISALLOW_COPY_AND_ASSIGN(FakeCompositorDependencies); };
diff --git a/gpu/command_buffer/common/gpu_memory_buffer_support.cc b/gpu/command_buffer/common/gpu_memory_buffer_support.cc index fb93ef88..9ef3050 100644 --- a/gpu/command_buffer/common/gpu_memory_buffer_support.cc +++ b/gpu/command_buffer/common/gpu_memory_buffer_support.cc
@@ -8,6 +8,7 @@ #include <GLES2/gl2extchromium.h> #include "base/logging.h" +#include "build/build_config.h" #include "gpu/command_buffer/common/capabilities.h" namespace gpu { @@ -165,4 +166,16 @@ return false; } +uint32_t GetPlatformSpecificTextureTarget() { +#if defined(OS_MACOSX) + return GL_TEXTURE_RECTANGLE_ARB; +#elif defined(OS_ANDROID) || defined(OS_LINUX) + return GL_TEXTURE_EXTERNAL_OES; +#elif defined(OS_WIN) + return GL_TEXTURE_2D; +#else + return 0; +#endif +} + } // namespace gpu
diff --git a/gpu/command_buffer/common/gpu_memory_buffer_support.h b/gpu/command_buffer/common/gpu_memory_buffer_support.h index 9f1dfbd..6e6de27e 100644 --- a/gpu/command_buffer/common/gpu_memory_buffer_support.h +++ b/gpu/command_buffer/common/gpu_memory_buffer_support.h
@@ -30,6 +30,9 @@ const gfx::Size& size, gfx::BufferFormat format); +// Returns the texture target to use with native GpuMemoryBuffers. +GPU_EXPORT uint32_t GetPlatformSpecificTextureTarget(); + } // namespace gpu #endif // GPU_COMMAND_BUFFER_COMMON_GPU_MEMORY_BUFFER_SUPPORT_H_
diff --git a/gpu/ipc/common/gpu_memory_buffer_support.cc b/gpu/ipc/common/gpu_memory_buffer_support.cc index 8747c09..6d4a1ec 100644 --- a/gpu/ipc/common/gpu_memory_buffer_support.cc +++ b/gpu/ipc/common/gpu_memory_buffer_support.cc
@@ -6,6 +6,7 @@ #include "base/logging.h" #include "build/build_config.h" +#include "ui/gl/gl_bindings.h" #if defined(OS_LINUX) #include "ui/gfx/client_native_pixmap_factory.h"
diff --git a/gpu/ipc/host/gpu_memory_buffer_support.cc b/gpu/ipc/host/gpu_memory_buffer_support.cc index 60cca21..78c7c82 100644 --- a/gpu/ipc/host/gpu_memory_buffer_support.cc +++ b/gpu/ipc/host/gpu_memory_buffer_support.cc
@@ -7,6 +7,7 @@ #include "base/command_line.h" #include "base/logging.h" #include "build/build_config.h" +#include "gpu/command_buffer/common/gpu_memory_buffer_support.h" #include "gpu/ipc/common/gpu_memory_buffer_support.h" #include "gpu/ipc/host/gpu_switches.h" #include "ui/gl/gl_bindings.h" @@ -86,36 +87,16 @@ return configurations; } -uint32_t GetImageTextureTarget(gfx::BufferFormat format, - gfx::BufferUsage usage) { +bool GetImageNeedsPlatformSpecificTextureTarget(gfx::BufferFormat format, + gfx::BufferUsage usage) { #if defined(USE_OZONE) || defined(OS_MACOSX) || defined(OS_WIN) || \ defined(OS_ANDROID) GpuMemoryBufferConfigurationSet native_configurations = GetNativeGpuMemoryBufferConfigurations(); - if (native_configurations.find(std::make_pair(format, usage)) == - native_configurations.end()) { - return GL_TEXTURE_2D; - } - - switch (GetNativeGpuMemoryBufferType()) { - case gfx::NATIVE_PIXMAP: - case gfx::ANDROID_HARDWARE_BUFFER: - // GPU memory buffers that are shared with the GL using EGLImages - // require TEXTURE_EXTERNAL_OES. - return GL_TEXTURE_EXTERNAL_OES; - case gfx::IO_SURFACE_BUFFER: - // IOSurface backed images require GL_TEXTURE_RECTANGLE_ARB. - return GL_TEXTURE_RECTANGLE_ARB; - case gfx::SHARED_MEMORY_BUFFER: - case gfx::EMPTY_BUFFER: - break; - case gfx::DXGI_SHARED_HANDLE: - return GL_TEXTURE_2D; - } - NOTREACHED(); - return GL_TEXTURE_2D; + return native_configurations.find(std::make_pair(format, usage)) != + native_configurations.end(); #else // defined(USE_OZONE) || defined(OS_MACOSX) - return GL_TEXTURE_2D; + return false; #endif }
diff --git a/gpu/ipc/host/gpu_memory_buffer_support.h b/gpu/ipc/host/gpu_memory_buffer_support.h index 14d396f..4645d7d 100644 --- a/gpu/ipc/host/gpu_memory_buffer_support.h +++ b/gpu/ipc/host/gpu_memory_buffer_support.h
@@ -37,9 +37,10 @@ // Returns the set of supported configurations. GpuMemoryBufferConfigurationSet GetNativeGpuMemoryBufferConfigurations(); -// Returns the OpenGL target to use for image textures. -uint32_t GetImageTextureTarget(gfx::BufferFormat format, - gfx::BufferUsage usage); +// Returns true of the OpenGL target to use for the combination of format/usage +// is not GL_TEXTURE_2D but a platform specific texture target. +bool GetImageNeedsPlatformSpecificTextureTarget(gfx::BufferFormat format, + gfx::BufferUsage usage); } // namespace gpu
diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.mm b/gpu/ipc/service/image_transport_surface_overlay_mac.mm index 2c5b91c..8cad9b0 100644 --- a/gpu/ipc/service/image_transport_surface_overlay_mac.mm +++ b/gpu/ipc/service/image_transport_surface_overlay_mac.mm
@@ -232,6 +232,7 @@ } params.ca_layer_params.pixel_size = pixel_size_; params.ca_layer_params.scale_factor = scale_factor_; + params.ca_layer_params.is_empty = false; params.swap_response.swap_id = swap_id_++; params.swap_response.result = gfx::SwapResult::SWAP_ACK; // TODO(brianderson): Tie swap_start to before_flush_time.
diff --git a/services/ui/ws/server_window.cc b/services/ui/ws/server_window.cc index 711cc03..9da355131 100644 --- a/services/ui/ws/server_window.cc +++ b/services/ui/ws/server_window.cc
@@ -105,7 +105,7 @@ // platforms. delegate_->GetVizHostProxy()->CreateRootCompositorFrameSink( frame_sink_id_, widget, - viz::CreateRendererSettings(viz::BufferToTextureTargetMap()), + viz::CreateRendererSettings(viz::BufferUsageAndFormatList()), std::move(sink_request), std::move(client), std::move(display_request)); }
diff --git a/services/viz/privileged/interfaces/struct_traits_unittest.cc b/services/viz/privileged/interfaces/struct_traits_unittest.cc index d714145..694edf5c 100644 --- a/services/viz/privileged/interfaces/struct_traits_unittest.cc +++ b/services/viz/privileged/interfaces/struct_traits_unittest.cc
@@ -25,8 +25,9 @@ ResourceSettings arbitrary_resource_settings; arbitrary_resource_settings.texture_id_allocation_chunk_size = kArbitrarySize; arbitrary_resource_settings.use_gpu_memory_buffer_resources = kArbitraryBool; - arbitrary_resource_settings.buffer_to_texture_target_map = - DefaultBufferToTextureTargetMapForTesting(); + arbitrary_resource_settings.texture_target_exception_list.push_back( + std::make_pair(gfx::BufferUsage::SCANOUT, gfx::BufferFormat::BGRX_8888)); + RendererSettings input; // Set |input| to non-default values. @@ -51,8 +52,8 @@ output.resource_settings.texture_id_allocation_chunk_size); EXPECT_EQ(input.resource_settings.use_gpu_memory_buffer_resources, output.resource_settings.use_gpu_memory_buffer_resources); - EXPECT_EQ(input.resource_settings.buffer_to_texture_target_map, - output.resource_settings.buffer_to_texture_target_map); + EXPECT_EQ(input.resource_settings.texture_target_exception_list, + output.resource_settings.texture_target_exception_list); EXPECT_EQ(input.allow_antialiasing, output.allow_antialiasing); EXPECT_EQ(input.force_antialiasing, output.force_antialiasing); EXPECT_EQ(input.force_blending_with_shaders,
diff --git a/services/viz/public/cpp/compositing/resource_settings.typemap b/services/viz/public/cpp/compositing/resource_settings.typemap index b0913ee..40b2068 100644 --- a/services/viz/public/cpp/compositing/resource_settings.typemap +++ b/services/viz/public/cpp/compositing/resource_settings.typemap
@@ -4,7 +4,9 @@ mojom = "//services/viz/public/interfaces/compositing/resource_settings.mojom" public_headers = [ "//components/viz/common/resources/resource_settings.h" ] -traits_headers = [ "//services/viz/public/cpp/compositing/resource_settings_struct_traits.h" ] +traits_headers = [ + "//services/viz/public/cpp/compositing/resource_settings_struct_traits.h", +] deps = [ "//cc", "//mojo/common:struct_traits", @@ -14,6 +16,6 @@ "//services/viz/public/cpp/compositing/resource_settings_struct_traits.cc", ] type_mappings = [ - "viz.mojom.BufferToTextureTargetKey=std::pair<gfx::BufferUsage, gfx::BufferFormat>", + "viz.mojom.BufferUsageAndFormat=std::pair<gfx::BufferUsage, gfx::BufferFormat>", "viz.mojom.ResourceSettings=viz::ResourceSettings", ]
diff --git a/services/viz/public/cpp/compositing/resource_settings_struct_traits.cc b/services/viz/public/cpp/compositing/resource_settings_struct_traits.cc index cd8a57b0..d085f28 100644 --- a/services/viz/public/cpp/compositing/resource_settings_struct_traits.cc +++ b/services/viz/public/cpp/compositing/resource_settings_struct_traits.cc
@@ -7,10 +7,10 @@ namespace mojo { // static -bool StructTraits<viz::mojom::BufferToTextureTargetKeyDataView, - viz::BufferToTextureTargetKey>:: - Read(viz::mojom::BufferToTextureTargetKeyDataView data, - viz::BufferToTextureTargetKey* out) { +bool StructTraits<viz::mojom::BufferUsageAndFormatDataView, + viz::BufferUsageAndFormat>:: + Read(viz::mojom::BufferUsageAndFormatDataView data, + viz::BufferUsageAndFormat* out) { return data.ReadUsage(&out->first) && data.ReadFormat(&out->second); } @@ -22,20 +22,20 @@ data.texture_id_allocation_chunk_size(); out->use_gpu_memory_buffer_resources = data.use_gpu_memory_buffer_resources(); - mojo::ArrayDataView<viz::mojom::BufferToTextureTargetPairDataView> - buffer_to_texture_target_array; - data.GetBufferToTextureTargetMapDataView(&buffer_to_texture_target_array); - for (size_t i = 0; i < buffer_to_texture_target_array.size(); ++i) { - viz::mojom::BufferToTextureTargetPairDataView buffer_to_texture_target_pair; - buffer_to_texture_target_array.GetDataView(i, - &buffer_to_texture_target_pair); - viz::BufferToTextureTargetKey key; - if (!buffer_to_texture_target_pair.ReadKey(&key)) + mojo::ArrayDataView<viz::mojom::BufferUsageAndFormatDataView> + usage_and_format_list; + data.GetTextureTargetExceptionListDataView(&usage_and_format_list); + for (size_t i = 0; i < usage_and_format_list.size(); ++i) { + viz::mojom::BufferUsageAndFormatDataView usage_format_view; + usage_and_format_list.GetDataView(i, &usage_format_view); + viz::BufferUsageAndFormat usage_format; + if (!usage_format_view.ReadUsage(&usage_format.first) || + !usage_format_view.ReadFormat(&usage_format.second)) return false; - auto& value = out->buffer_to_texture_target_map[key]; - value = buffer_to_texture_target_pair.value(); + out->texture_target_exception_list.push_back(usage_format); } + return true; }
diff --git a/services/viz/public/cpp/compositing/resource_settings_struct_traits.h b/services/viz/public/cpp/compositing/resource_settings_struct_traits.h index 3620d89..6dac8538 100644 --- a/services/viz/public/cpp/compositing/resource_settings_struct_traits.h +++ b/services/viz/public/cpp/compositing/resource_settings_struct_traits.h
@@ -15,65 +15,6 @@ namespace mojo { template <> -struct ArrayTraits<viz::BufferToTextureTargetMap> { - using Element = viz::BufferToTextureTargetMap::value_type; - using Iterator = viz::BufferToTextureTargetMap::iterator; - using ConstIterator = viz::BufferToTextureTargetMap::const_iterator; - - static ConstIterator GetBegin(const viz::BufferToTextureTargetMap& input) { - return input.begin(); - } - static Iterator GetBegin(viz::BufferToTextureTargetMap& input) { // NOLINT - return input.begin(); - } - - static void AdvanceIterator(ConstIterator& iterator) { // NOLINT - iterator++; - } - static void AdvanceIterator(Iterator& iterator) { // NOLINT - iterator++; - } - - static const Element& GetValue(ConstIterator& iterator) { // NOLINT - return *iterator; - } - static Element& GetValue(Iterator& iterator) { return *iterator; } // NOLINT - - static size_t GetSize(const viz::BufferToTextureTargetMap& input) { - return input.size(); - } -}; - -template <> -struct StructTraits<viz::mojom::BufferToTextureTargetKeyDataView, - std::pair<gfx::BufferUsage, gfx::BufferFormat>> { - static gfx::BufferUsage usage(const viz::BufferToTextureTargetKey& input) { - return input.first; - } - - static gfx::BufferFormat format(const viz::BufferToTextureTargetKey& input) { - return input.second; - } - - static bool Read(viz::mojom::BufferToTextureTargetKeyDataView data, - viz::BufferToTextureTargetKey* out); -}; - -template <> -struct StructTraits<viz::mojom::BufferToTextureTargetPairDataView, - viz::BufferToTextureTargetMap::value_type> { - static const std::pair<gfx::BufferUsage, gfx::BufferFormat>& key( - const viz::BufferToTextureTargetMap::value_type& input) { - return input.first; - } - - static uint32_t value( - const viz::BufferToTextureTargetMap::value_type& input) { - return input.second; - } -}; - -template <> struct StructTraits<viz::mojom::ResourceSettingsDataView, viz::ResourceSettings> { static size_t texture_id_allocation_chunk_size( @@ -86,15 +27,30 @@ return input.use_gpu_memory_buffer_resources; } - static const viz::BufferToTextureTargetMap& buffer_to_texture_target_map( + static const viz::BufferUsageAndFormatList& texture_target_exception_list( const viz::ResourceSettings& input) { - return input.buffer_to_texture_target_map; + return input.texture_target_exception_list; } static bool Read(viz::mojom::ResourceSettingsDataView data, viz::ResourceSettings* out); }; +template <> +struct StructTraits<viz::mojom::BufferUsageAndFormatDataView, + viz::BufferUsageAndFormat> { + static gfx::BufferUsage usage(const viz::BufferUsageAndFormat& input) { + return input.first; + } + + static gfx::BufferFormat format(const viz::BufferUsageAndFormat& input) { + return input.second; + } + + static bool Read(viz::mojom::BufferUsageAndFormatDataView data, + viz::BufferUsageAndFormat* out); +}; + } // namespace mojo #endif // SERVICES_VIZ_PUBLIC_CPP_COMPOSITING_RESOURCE_SETTINGS_STRUCT_TRAITS_H_
diff --git a/services/viz/public/cpp/compositing/struct_traits_unittest.cc b/services/viz/public/cpp/compositing/struct_traits_unittest.cc index 8204678..c442cea8 100644 --- a/services/viz/public/cpp/compositing/struct_traits_unittest.cc +++ b/services/viz/public/cpp/compositing/struct_traits_unittest.cc
@@ -390,8 +390,8 @@ ResourceSettings input; input.texture_id_allocation_chunk_size = kArbitrarySize; input.use_gpu_memory_buffer_resources = kArbitraryBool; - input.buffer_to_texture_target_map = - DefaultBufferToTextureTargetMapForTesting(); + input.texture_target_exception_list.push_back( + std::make_pair(gfx::BufferUsage::SCANOUT, gfx::BufferFormat::BGRX_8888)); ResourceSettings output; SerializeAndDeserialize<mojom::ResourceSettings>(input, &output); @@ -400,8 +400,8 @@ output.texture_id_allocation_chunk_size); EXPECT_EQ(input.use_gpu_memory_buffer_resources, output.use_gpu_memory_buffer_resources); - EXPECT_EQ(input.buffer_to_texture_target_map, - output.buffer_to_texture_target_map); + EXPECT_EQ(input.texture_target_exception_list, + output.texture_target_exception_list); } TEST_F(StructTraitsTest, Selection) {
diff --git a/services/viz/public/interfaces/compositing/resource_settings.mojom b/services/viz/public/interfaces/compositing/resource_settings.mojom index 4d66280..35446e2 100644 --- a/services/viz/public/interfaces/compositing/resource_settings.mojom +++ b/services/viz/public/interfaces/compositing/resource_settings.mojom
@@ -6,20 +6,15 @@ import "ui/gfx/mojo/buffer_types.mojom"; -struct BufferToTextureTargetKey { +struct BufferUsageAndFormat { gfx.mojom.BufferUsage usage; gfx.mojom.BufferFormat format; }; -struct BufferToTextureTargetPair { - BufferToTextureTargetKey key; - uint32 value; -}; - // Corresponds to |viz::ResourceSettings| in // components/viz/common/resources/resource_settings.h struct ResourceSettings { uint32 texture_id_allocation_chunk_size; bool use_gpu_memory_buffer_resources; - array<BufferToTextureTargetPair> buffer_to_texture_target_map; + array<BufferUsageAndFormat> texture_target_exception_list; };
diff --git a/testing/buildbot/scripts/upload_test_result_artifacts.py b/testing/buildbot/scripts/upload_test_result_artifacts.py new file mode 100755 index 0000000..a3ca0a1 --- /dev/null +++ b/testing/buildbot/scripts/upload_test_result_artifacts.py
@@ -0,0 +1,240 @@ +#!/usr/bin/env python +# Copyright 2017 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +"""Uploads test results artifacts. + +This script takes a list of json test results files, the format of which is +described in +https://chromium.googlesource.com/chromium/src/+/master/docs/testing/json_test_results_format.md. +For each file, it looks for test artifacts embedded in each test. It detects +this by looking for the top level "artifact_type_info" key. + +The script, by default, uploads every artifact stored on the local disk (a URI +with the 'file' scheme) to google storage. +""" + +import argparse +import collections +import copy +import itertools +import json +import hashlib +import os +import shutil +import subprocess +import sys +import tempfile +import urlparse +import uuid + +root_dir = os.path.abspath( + os.path.join(os.path.dirname(__file__), '..', '..', '..')) +sys.path.append(os.path.join(root_dir, 'build', 'android')) +from pylib.utils import google_storage_helper + + +def get_file_digest(filepath): + """Get the cloud storage path for uploading a file. + + Hashes the file contents to determine the filename. + """ + with open(filepath, 'rb') as f: + # TODO: switch to sha256. crbug.com/787113 + m = hashlib.sha1() + while True: + chunk = f.read(64 * 1024) + if not chunk: + break + m.update(chunk) + return m.hexdigest() + + +def get_tests(test_trie): + """Gets all tests in this test trie. + + It detects if an entry is a test by looking for the 'expected' and 'actual' + keys in the dictionary. + + The keys of the dictionary are tuples of the keys. A test trie like + "foo": { + "bar": { + "baz": { + "actual": "PASS", + "expected": "PASS", + } + } + } + + Would give you + { + ('foo', 'bar', 'baz'): { + "actual": "PASS", + "expected": "PASS", + } + } + + NOTE: If you are getting an error with a stack trace ending in this function, + file a bug with crbug.com/new and cc martiniss@. + """ + if not isinstance(test_trie, dict): + raise ValueError("expected %s to be a dict" % test_trie) + + tests = {} + + for k, v in test_trie.items(): + if 'expected' in v and 'actual' in v: + tests[(k,)] = v + else: + for key, val in get_tests(v).items(): + tests[(k,) + key] = val + + return tests + + +def upload_directory_to_gs(local_path, bucket, gs_path, dry_run): + if dry_run: + print 'would have uploaded %s to %s' % (local_path, gs_path) + return + + # -m does multithreaded uploads, which is needed because we upload multiple + # files. -r copies the whole directory. + google_storage_helper.upload( + gs_path, local_path, bucket, gs_args=['-m'], command_args=['-r']) + + +def hash_artifacts(tests, artifact_root): + """Hash artifacts in a set of tests. + + Args: + * tests: A dictionary containing tests which have some artifacts. Format is + a mapping of test name to test object. This object will have a key + 'artifacts' which should be a dictionary mapping artifact name to relative + location. This dictionary is mutated to rewrite locations to be the hashes + of the files. + * artifact_root: The local directory where the artifacts are located. + + Returns: + A list of tuples. Each tuple contains the file contents digest, and the + location of the file on disk. + """ + hashed_artifacts = [] + # Sort for testing consistency. + for test_obj in sorted(tests.values()): + for name, location in sorted( + test_obj.get('artifacts', {}).items(), + key=lambda pair: pair[0]): + absolute_filepath = os.path.join(artifact_root, location) + file_digest = get_file_digest(absolute_filepath) + # Location is set to file digest because it's relative to the google + # storage root. + test_obj['artifacts'][name] = file_digest + hashed_artifacts.append((file_digest, absolute_filepath)) + + return hashed_artifacts + + +def prep_artifacts_for_gs_upload(hashed_artifacts, tempdir): + """Prepare hashed artifacts for upload to google storage. + + Moves each file into the given temp directory. + """ + for file_digest, absolute_filepath in hashed_artifacts: + new_location = os.path.join(tempdir, file_digest) + + # Since the filename is the hash of the contents of the file, it might + # already exist. + if not os.path.exists(new_location): + shutil.copyfile(absolute_filepath, new_location) + + +def upload_artifacts(data, artifact_root, dry_run): + """Uploads artifacts to google storage. + + Args: + * data: The test results data to upload. Assumed to include 'tests' and + 'artifact_type_info' top level keys. + * artifact_root: The local directory where artifact locations are relative + to. + * dry_run: If true, this run is a test run, and no actual changes should be + made. This includes no uploading any data to cloud storage. + Returns: + The test results data, with rewritten artifact locations. + """ + local_data = copy.deepcopy(data) + type_info = local_data['artifact_type_info'] + + # TODO(martiniss): Add support for uploading to other buckets. + bucket = 'chromium-test-artifacts' + # Put the hashing algorithm as part of the filename, so that it's + # easier to change the algorithm if we need to in the future. + gs_path = 'sha1' + + tests = get_tests(local_data['tests']) + # Do a validation pass first. Makes sure no filesystem operations occur if + # there are invalid artifacts. + for test_obj in tests.values(): + for artifact_name in test_obj.get('artifacts', {}): + if artifact_name not in type_info: + raise ValueError( + 'Artifact %r type information not present' % artifact_name) + + tempdir = tempfile.mkdtemp(prefix='upload_test_artifacts') + try: + hashed_artifacts = hash_artifacts(tests, artifact_root) + prep_artifacts_for_gs_upload(hashed_artifacts, tempdir) + + # Add * to include all files in that directory. + upload_directory_to_gs( + os.path.join(tempdir, '*'), bucket, gs_path, dry_run) + + local_data['artifact_permanent_location'] = 'gs://%s/%s' % ( + bucket, gs_path) + return local_data + finally: + shutil.rmtree(tempdir) + +def main(): + parser = argparse.ArgumentParser() + # This would be test-result-file, but argparse doesn't translate + # test-result-file to args.test_result_file automatically, and dest doesn't + # seem to work on positional arguments. + parser.add_argument('test_result_file') + parser.add_argument('--output-file', type=os.path.realpath, + help='If set, the input json test results file will be' + ' rewritten to include new artifact location data, and' + ' dumped to this value.') + parser.add_argument('-n', '--dry-run', action='store_true', + help='If true, this script will not upload any files, and' + ' will instead just print to stdout what path it' + ' would have uploaded each file. Useful for testing.' + ) + parser.add_argument('--artifact-root', required=True, type=os.path.realpath, + help='The file path where artifact locations are rooted.') + parser.add_argument('-q', '--quiet', action='store_true', + help='If set, does not print the transformed json file' + ' to stdout.') + + args = parser.parse_args() + + with open(args.test_result_file) as f: + data = json.load(f) + + type_info = data.get('artifact_type_info') + if not type_info: + print 'File %r did not have %r top level key. Not processing.' % ( + args.test_result_file, 'artifact_type_info') + return 1 + + new_data = upload_artifacts(data, args.artifact_root, args.dry_run) + if args.output_file: + with open(args.output_file, 'w') as f: + json.dump(new_data, f) + + if new_data and not args.quiet: + print json.dumps( + new_data, indent=2, separators=(',', ': '), sort_keys=True) + return 0 + +if __name__ == '__main__': + sys.exit(main())
diff --git a/testing/buildbot/scripts/upload_test_result_artifacts_unittest.py b/testing/buildbot/scripts/upload_test_result_artifacts_unittest.py new file mode 100644 index 0000000..b5a5809 --- /dev/null +++ b/testing/buildbot/scripts/upload_test_result_artifacts_unittest.py
@@ -0,0 +1,302 @@ +# Copyright 2017 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +"""Tests for upload_test_result_artifacts.""" + +import json +import mock +import os +import random +import string +import tempfile +import unittest +import upload_test_result_artifacts as UTRA + + +class UploadTestResultArtifactsTest(unittest.TestCase): + def setUp(self): + # Used for load tests + self._temp_files = [] + + def tearDown(self): + # Used for load tests + for fname in self._temp_files: + os.unlink(fname) + + ### These are load tests useful for seeing how long it takes to upload + ### different kinds of test results files. They won't be run as part of + ### presubmit testing, since they take a while and talk to the network, + ### but the code will stay here in case anyone wants to edit the code + ### and wants to check performance. Change the test names from 'loadTestBlah' + ### to 'testBlah' to get them to run. + + def makeTemp(self, size): + _, fname = tempfile.mkstemp() + with open(fname, 'w') as f: + f.write(random.choice(string.ascii_letters) * size) + self._temp_files.append(fname) + + return os.path.basename(fname) + + def makeTestJson(self, num_tests, artifact_size): + return { + 'tests': { + 'suite': { + 'test%d' % i: { + 'artifacts': { + 'artifact': self.makeTemp(artifact_size), + }, + 'expected': 'PASS', + 'actual': 'PASS', + } for i in range(num_tests) + } + }, + 'artifact_type_info': { + 'artifact': 'text/plain' + } + } + + def _loadTest(self, json_data, upload): + return UTRA.upload_artifacts( + json_data, '/tmp', upload) + + + def loadTestEndToEndSimple(self): + test_data = self.makeTestJson(1, 10) + print self._loadTest(test_data, False) + + def loadTestEndToEndManySmall(self): + test_data = self.makeTestJson(1000, 10) + self._loadTest(test_data, False) + + def loadTestEndToEndSomeBig(self): + test_data = self.makeTestJson(100, 10000000) + self._loadTest(test_data, False) + + def loadTestEndToEndVeryBig(self): + test_data = self.makeTestJson(2, 1000000000) + self._loadTest(test_data, False) + + ### End load test section. + + def testGetTestsSimple(self): + self.assertEqual(UTRA.get_tests({ + 'foo': { + 'expected': 'PASS', + 'actual': 'PASS', + }, + }), { + ('foo',): { + 'actual': 'PASS', + 'expected': 'PASS', + } + }) + + def testGetTestsNested(self): + self.assertEqual(UTRA.get_tests({ + 'foo': { + 'bar': { + 'baz': { + 'actual': 'PASS', + 'expected': 'PASS', + }, + 'bam': { + 'actual': 'PASS', + 'expected': 'PASS', + }, + }, + }, + }), { + ('foo', 'bar', 'baz'): { + 'actual': 'PASS', + 'expected': 'PASS', + }, + ('foo', 'bar', 'bam'): { + 'actual': 'PASS', + 'expected': 'PASS', + } + }) + + def testGetTestsError(self): + with self.assertRaises(ValueError): + UTRA.get_tests([]) + + def testUploadArtifactsMissingType(self): + """Tests that the type information is used for validation.""" + data = { + 'artifact_type_info': { + 'log': 'text/plain' + }, + 'tests': { + 'foo': { + 'actual': 'PASS', + 'expected': 'PASS', + 'artifacts': { + 'screenshot': 'foo.png', + } + } + } + } + with self.assertRaises(ValueError): + UTRA.upload_artifacts(data, '/tmp', True) + + @mock.patch('upload_test_result_artifacts.get_file_digest') + @mock.patch('upload_test_result_artifacts.tempfile.mkdtemp') + @mock.patch('upload_test_result_artifacts.shutil.rmtree') + @mock.patch('upload_test_result_artifacts.shutil.copyfile') + def testUploadArtifactsNoUpload( + self, copy_patch, rmtree_patch, mkd_patch, digest_patch): + """Simple test; no artifacts, so data shouldn't change.""" + mkd_patch.return_value = 'foo_dir' + data = { + 'artifact_type_info': { + 'log': 'text/plain' + }, + 'tests': { + 'foo': { + 'actual': 'PASS', + 'expected': 'PASS', + } + } + } + self.assertEqual(UTRA.upload_artifacts(data, '/tmp', True), data) + mkd_patch.assert_called_once_with(prefix='upload_test_artifacts') + digest_patch.assert_not_called() + copy_patch.assert_not_called() + rmtree_patch.assert_called_once_with('foo_dir') + + @mock.patch('upload_test_result_artifacts.get_file_digest') + @mock.patch('upload_test_result_artifacts.tempfile.mkdtemp') + @mock.patch('upload_test_result_artifacts.shutil.rmtree') + @mock.patch('upload_test_result_artifacts.shutil.copyfile') + @mock.patch('upload_test_result_artifacts.os.path.exists') + def testUploadArtifactsBasic( + self, exists_patch, copy_patch, rmtree_patch, mkd_patch, digest_patch): + """Upload a single artifact.""" + mkd_patch.return_value = 'foo_dir' + exists_patch.return_value = False + digest_patch.return_value = 'deadbeef' + + data = { + 'artifact_type_info': { + 'log': 'text/plain' + }, + 'tests': { + 'foo': { + 'actual': 'PASS', + 'expected': 'PASS', + 'artifacts': { + 'log': 'foo.txt', + } + } + } + } + self.assertEqual(UTRA.upload_artifacts(data, '/tmp', True), { + 'artifact_type_info': { + 'log': 'text/plain' + }, + 'tests': { + 'foo': { + 'actual': 'PASS', + 'expected': 'PASS', + 'artifacts': { + 'log': 'deadbeef', + } + } + }, + 'artifact_permanent_location': 'gs://chromium-test-artifacts/sha1', + }) + mkd_patch.assert_called_once_with(prefix='upload_test_artifacts') + digest_patch.assert_called_once_with('/tmp/foo.txt') + copy_patch.assert_called_once_with('/tmp/foo.txt', 'foo_dir/deadbeef') + rmtree_patch.assert_called_once_with('foo_dir') + + @mock.patch('upload_test_result_artifacts.get_file_digest') + @mock.patch('upload_test_result_artifacts.tempfile.mkdtemp') + @mock.patch('upload_test_result_artifacts.shutil.rmtree') + @mock.patch('upload_test_result_artifacts.shutil.copyfile') + @mock.patch('upload_test_result_artifacts.os.path.exists') + def testUploadArtifactsComplex( + self, exists_patch, copy_patch, rmtree_patch, mkd_patch, digest_patch): + """Upload multiple artifacts.""" + mkd_patch.return_value = 'foo_dir' + exists_patch.return_value = False + digest_patch.side_effect = [ + 'deadbeef1', 'deadbeef2', 'deadbeef3', 'deadbeef4'] + + data = { + 'artifact_type_info': { + 'log': 'text/plain', + 'screenshot': 'image/png', + }, + 'tests': { + 'bar': { + 'baz': { + 'actual': 'PASS', + 'expected': 'PASS', + 'artifacts': { + 'log': 'baz.log.txt', + 'screenshot': 'baz.png', + } + } + }, + 'foo': { + 'actual': 'PASS', + 'expected': 'PASS', + 'artifacts': { + 'log': 'foo.log.txt', + 'screenshot': 'foo.png', + } + }, + } + } + self.assertEqual(UTRA.upload_artifacts(data, '/tmp', True), { + 'artifact_type_info': { + 'log': 'text/plain', + 'screenshot': 'image/png', + }, + 'tests': { + 'bar': { + 'baz': { + 'actual': 'PASS', + 'expected': 'PASS', + 'artifacts': { + 'log': 'deadbeef1', + 'screenshot': 'deadbeef2', + } + } + }, + 'foo': { + 'actual': 'PASS', + 'expected': 'PASS', + 'artifacts': { + 'log': 'deadbeef3', + 'screenshot': 'deadbeef4', + } + }, + }, + 'artifact_permanent_location': 'gs://chromium-test-artifacts/sha1', + }) + mkd_patch.assert_called_once_with(prefix='upload_test_artifacts') + digest_patch.assert_has_calls([ + mock.call('/tmp/baz.log.txt'), mock.call('/tmp/baz.png'), + mock.call('/tmp/foo.log.txt'), mock.call('/tmp/foo.png')]) + copy_patch.assert_has_calls([ + mock.call('/tmp/baz.log.txt', 'foo_dir/deadbeef1'), + mock.call('/tmp/baz.png', 'foo_dir/deadbeef2'), + mock.call('/tmp/foo.log.txt', 'foo_dir/deadbeef3'), + mock.call('/tmp/foo.png', 'foo_dir/deadbeef4'), + ]) + rmtree_patch.assert_called_once_with('foo_dir') + + def testFileDigest(self): + _, path = tempfile.mkstemp(prefix='file_digest_test') + with open(path, 'w') as f: + f.write('a') + + self.assertEqual( + UTRA.get_file_digest(path), + '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8') + +if __name__ == '__main__': + unittest.main()
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-animations/interfaces/Animatable/animate-expected.txt b/third_party/WebKit/LayoutTests/external/wpt/web-animations/interfaces/Animatable/animate-expected.txt index f3d45ba..f04b4c1 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/web-animations/interfaces/Animatable/animate-expected.txt +++ b/third_party/WebKit/LayoutTests/external/wpt/web-animations/interfaces/Animatable/animate-expected.txt
@@ -1,5 +1,5 @@ This is a testharness.js-based test. -Found 121 tests; 68 PASS, 53 FAIL, 0 TIMEOUT, 0 NOTRUN. +Found 121 tests; 75 PASS, 46 FAIL, 0 TIMEOUT, 0 NOTRUN. PASS Element.animate() creates an Animation object PASS Element.animate() creates an Animation object in the relevant realm of the target element PASS Element.animate() creates an Animation object with a KeyframeEffect @@ -53,18 +53,18 @@ PASS Element.animate() accepts a two property keyframe sequence where one property is missing from the first keyframe PASS Element.animate() accepts a two property keyframe sequence where one property is missing from the last keyframe PASS Element.animate() accepts a one property two keyframe sequence that needs to stringify its values -FAIL Element.animate() accepts a keyframe sequence with a CSS variable reference assert_equals: value for 'offset' on ComputedKeyframe #0 expected (object) null but got (number) NaN +PASS Element.animate() accepts a keyframe sequence with a CSS variable reference FAIL Element.animate() accepts a keyframe sequence with a CSS variable reference in a shorthand property assert_equals: properties on ComputedKeyframe #0 should match expected "computedOffset,easing,margin,offset" but got "computedOffset,easing,marginBottom,marginLeft,marginRight,marginTop,offset" PASS Element.animate() accepts a keyframe sequence with duplicate values for a given interior offset PASS Element.animate() accepts a keyframe sequence with duplicate values for offsets 0 and 1 PASS Element.animate() accepts a two property four keyframe sequence -FAIL Element.animate() accepts a single keyframe sequence with omitted offset assert_equals: value for 'offset' on ComputedKeyframe #0 expected (object) null but got (number) NaN -FAIL Element.animate() accepts a single keyframe sequence with null offset assert_equals: value for 'offset' on ComputedKeyframe #0 expected (object) null but got (number) NaN +PASS Element.animate() accepts a single keyframe sequence with omitted offset +PASS Element.animate() accepts a single keyframe sequence with null offset PASS Element.animate() accepts a single keyframe sequence with string offset -FAIL Element.animate() accepts a one property keyframe sequence with some omitted offsets assert_equals: value for 'offset' on ComputedKeyframe #2 expected (object) null but got (number) NaN -FAIL Element.animate() accepts a one property keyframe sequence with some null offsets assert_equals: value for 'offset' on ComputedKeyframe #2 expected (object) null but got (number) NaN -FAIL Element.animate() accepts a two property keyframe sequence with some omitted offsets assert_equals: value for 'offset' on ComputedKeyframe #2 expected (object) null but got (number) NaN -FAIL Element.animate() accepts a one property keyframe sequence with all omitted offsets assert_equals: value for 'offset' on ComputedKeyframe #0 expected (object) null but got (number) NaN +PASS Element.animate() accepts a one property keyframe sequence with some omitted offsets +PASS Element.animate() accepts a one property keyframe sequence with some null offsets +PASS Element.animate() accepts a two property keyframe sequence with some omitted offsets +PASS Element.animate() accepts a one property keyframe sequence with all omitted offsets PASS Element.animate() accepts a keyframe sequence with different easing values, but the same easing value for a given offset PASS Element.animate() accepts a keyframe sequence with different composite values, but the same composite value for a given offset PASS Element.animate() does not accept keyframes with an out-of-bounded positive offset
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-animations/interfaces/KeyframeEffect/constructor-expected.txt b/third_party/WebKit/LayoutTests/external/wpt/web-animations/interfaces/KeyframeEffect/constructor-expected.txt index b3e34b3..4c1e5766b 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/web-animations/interfaces/KeyframeEffect/constructor-expected.txt +++ b/third_party/WebKit/LayoutTests/external/wpt/web-animations/interfaces/KeyframeEffect/constructor-expected.txt
@@ -1,5 +1,5 @@ This is a testharness.js-based test. -Found 167 tests; 89 PASS, 78 FAIL, 0 TIMEOUT, 0 NOTRUN. +Found 167 tests; 103 PASS, 64 FAIL, 0 TIMEOUT, 0 NOTRUN. PASS A KeyframeEffectReadOnly can be constructed with no frames PASS easing values are parsed correctly when passed to the KeyframeEffectReadOnly constructor in KeyframeEffectOptions PASS Invalid easing values are correctly rejected when passed to the KeyframeEffectReadOnly constructor in KeyframeEffectOptions @@ -96,30 +96,30 @@ PASS A KeyframeEffectReadOnly constructed with a two property keyframe sequence where one property is missing from the last keyframe roundtrips PASS A KeyframeEffectReadOnly can be constructed with a one property two keyframe sequence that needs to stringify its values PASS A KeyframeEffectReadOnly constructed with a one property two keyframe sequence that needs to stringify its values roundtrips -FAIL A KeyframeEffectReadOnly can be constructed with a keyframe sequence with a CSS variable reference assert_equals: value for 'offset' on ComputedKeyframe #0 expected (object) null but got (number) NaN -FAIL A KeyframeEffectReadOnly constructed with a keyframe sequence with a CSS variable reference roundtrips Failed to construct 'KeyframeEffectReadOnly': Non numeric offset provided +PASS A KeyframeEffectReadOnly can be constructed with a keyframe sequence with a CSS variable reference +PASS A KeyframeEffectReadOnly constructed with a keyframe sequence with a CSS variable reference roundtrips FAIL A KeyframeEffectReadOnly can be constructed with a keyframe sequence with a CSS variable reference in a shorthand property assert_equals: properties on ComputedKeyframe #0 should match expected "computedOffset,easing,margin,offset" but got "computedOffset,easing,marginBottom,marginLeft,marginRight,marginTop,offset" -FAIL A KeyframeEffectReadOnly constructed with a keyframe sequence with a CSS variable reference in a shorthand property roundtrips Failed to construct 'KeyframeEffectReadOnly': Non numeric offset provided +FAIL A KeyframeEffectReadOnly constructed with a keyframe sequence with a CSS variable reference in a shorthand property roundtrips assert_equals: properties on ComputedKeyframe #0 should match expected "computedOffset,easing,marginBottom,marginLeft,marginRight,marginTop,offset" but got "computedOffset,easing,offset" PASS A KeyframeEffectReadOnly can be constructed with a keyframe sequence with duplicate values for a given interior offset PASS A KeyframeEffectReadOnly constructed with a keyframe sequence with duplicate values for a given interior offset roundtrips PASS A KeyframeEffectReadOnly can be constructed with a keyframe sequence with duplicate values for offsets 0 and 1 PASS A KeyframeEffectReadOnly constructed with a keyframe sequence with duplicate values for offsets 0 and 1 roundtrips PASS A KeyframeEffectReadOnly can be constructed with a two property four keyframe sequence PASS A KeyframeEffectReadOnly constructed with a two property four keyframe sequence roundtrips -FAIL A KeyframeEffectReadOnly can be constructed with a single keyframe sequence with omitted offset assert_equals: value for 'offset' on ComputedKeyframe #0 expected (object) null but got (number) NaN -FAIL A KeyframeEffectReadOnly constructed with a single keyframe sequence with omitted offset roundtrips Failed to construct 'KeyframeEffectReadOnly': Non numeric offset provided -FAIL A KeyframeEffectReadOnly can be constructed with a single keyframe sequence with null offset assert_equals: value for 'offset' on ComputedKeyframe #0 expected (object) null but got (number) NaN -FAIL A KeyframeEffectReadOnly constructed with a single keyframe sequence with null offset roundtrips Failed to construct 'KeyframeEffectReadOnly': Non numeric offset provided +PASS A KeyframeEffectReadOnly can be constructed with a single keyframe sequence with omitted offset +PASS A KeyframeEffectReadOnly constructed with a single keyframe sequence with omitted offset roundtrips +PASS A KeyframeEffectReadOnly can be constructed with a single keyframe sequence with null offset +PASS A KeyframeEffectReadOnly constructed with a single keyframe sequence with null offset roundtrips PASS A KeyframeEffectReadOnly can be constructed with a single keyframe sequence with string offset PASS A KeyframeEffectReadOnly constructed with a single keyframe sequence with string offset roundtrips -FAIL A KeyframeEffectReadOnly can be constructed with a one property keyframe sequence with some omitted offsets assert_equals: value for 'offset' on ComputedKeyframe #2 expected (object) null but got (number) NaN -FAIL A KeyframeEffectReadOnly constructed with a one property keyframe sequence with some omitted offsets roundtrips Failed to construct 'KeyframeEffectReadOnly': Non numeric offset provided -FAIL A KeyframeEffectReadOnly can be constructed with a one property keyframe sequence with some null offsets assert_equals: value for 'offset' on ComputedKeyframe #2 expected (object) null but got (number) NaN -FAIL A KeyframeEffectReadOnly constructed with a one property keyframe sequence with some null offsets roundtrips Failed to construct 'KeyframeEffectReadOnly': Non numeric offset provided -FAIL A KeyframeEffectReadOnly can be constructed with a two property keyframe sequence with some omitted offsets assert_equals: value for 'offset' on ComputedKeyframe #2 expected (object) null but got (number) NaN -FAIL A KeyframeEffectReadOnly constructed with a two property keyframe sequence with some omitted offsets roundtrips Failed to construct 'KeyframeEffectReadOnly': Non numeric offset provided -FAIL A KeyframeEffectReadOnly can be constructed with a one property keyframe sequence with all omitted offsets assert_equals: value for 'offset' on ComputedKeyframe #0 expected (object) null but got (number) NaN -FAIL A KeyframeEffectReadOnly constructed with a one property keyframe sequence with all omitted offsets roundtrips Failed to construct 'KeyframeEffectReadOnly': Non numeric offset provided +PASS A KeyframeEffectReadOnly can be constructed with a one property keyframe sequence with some omitted offsets +PASS A KeyframeEffectReadOnly constructed with a one property keyframe sequence with some omitted offsets roundtrips +PASS A KeyframeEffectReadOnly can be constructed with a one property keyframe sequence with some null offsets +PASS A KeyframeEffectReadOnly constructed with a one property keyframe sequence with some null offsets roundtrips +PASS A KeyframeEffectReadOnly can be constructed with a two property keyframe sequence with some omitted offsets +PASS A KeyframeEffectReadOnly constructed with a two property keyframe sequence with some omitted offsets roundtrips +PASS A KeyframeEffectReadOnly can be constructed with a one property keyframe sequence with all omitted offsets +PASS A KeyframeEffectReadOnly constructed with a one property keyframe sequence with all omitted offsets roundtrips PASS A KeyframeEffectReadOnly can be constructed with a keyframe sequence with different easing values, but the same easing value for a given offset PASS A KeyframeEffectReadOnly constructed with a keyframe sequence with different easing values, but the same easing value for a given offset roundtrips PASS A KeyframeEffectReadOnly can be constructed with a keyframe sequence with different composite values, but the same composite value for a given offset
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/inspector-protocol-test.js b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/inspector-protocol-test.js index 36ade06..6a945a4 100644 --- a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/inspector-protocol-test.js +++ b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/inspector-protocol-test.js
@@ -25,7 +25,7 @@ this._log.call(null, item); } - _logObject(object, title, stabilizeNames = ['id', 'nodeId', 'objectId', 'scriptId', 'timestamp', 'backendNodeId', 'parentId', 'frameId', 'baseURL', 'documentURL']) { + _logObject(object, title, stabilizeNames = ['id', 'nodeId', 'objectId', 'scriptId', 'timestamp', 'backendNodeId', 'parentId', 'frameId', 'loaderId', 'baseURL', 'documentURL']) { var lines = []; function dumpValue(value, prefix, prefixWithName) {
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/page/pageNavigateToFragment-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/page/pageNavigateToFragment-expected.txt new file mode 100644 index 0000000..90e7b564 --- /dev/null +++ b/third_party/WebKit/LayoutTests/inspector-protocol/page/pageNavigateToFragment-expected.txt
@@ -0,0 +1,16 @@ +Tests Page.navigate returns for fragment navigation. +{ + id : <number> + result : { + frameId : <string> + loaderId : <string> + } +} +{ + id : <number> + result : { + frameId : <string> + loaderId : <string> + } +} +
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/page/pageNavigateToFragment.js b/third_party/WebKit/LayoutTests/inspector-protocol/page/pageNavigateToFragment.js new file mode 100644 index 0000000..2dbcd6e --- /dev/null +++ b/third_party/WebKit/LayoutTests/inspector-protocol/page/pageNavigateToFragment.js
@@ -0,0 +1,11 @@ +(async function(testRunner) { + var {page, session, dp} = await testRunner.startBlank('Tests Page.navigate returns for fragment navigation.'); + + await dp.Page.enable(); + let result = await dp.Page.navigate({url: testRunner.url('../resources/blank.html')}); + testRunner.log(result); + result = await dp.Page.navigate({url: testRunner.url('../resources/blank.html#fragment')}); + testRunner.log(result); + + testRunner.completeTest(); +})
diff --git a/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp b/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp index 65a0e16..695c681 100644 --- a/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp +++ b/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp
@@ -167,7 +167,7 @@ bool DuplicateSingleKeyframeAndTestIsCandidateOnResult( StringKeyframe* frame) { - EXPECT_EQ(frame->Offset(), 0); + EXPECT_EQ(frame->CheckedOffset(), 0); StringKeyframeVector frames; scoped_refptr<Keyframe> second = frame->CloneWithOffset(1); @@ -260,7 +260,7 @@ scoped_refptr<StringKeyframe> to, scoped_refptr<StringKeyframe> c = nullptr, scoped_refptr<StringKeyframe> d = nullptr) { - EXPECT_EQ(from->Offset(), 0); + EXPECT_EQ(from->CheckedOffset(), 0); StringKeyframeVector frames; frames.push_back(from); EXPECT_LE(from->Offset(), to->Offset()); @@ -272,9 +272,9 @@ if (d) { frames.push_back(d); EXPECT_LE(c->Offset(), d->Offset()); - EXPECT_EQ(d->Offset(), 1.0); + EXPECT_EQ(d->CheckedOffset(), 1.0); } else { - EXPECT_EQ(to->Offset(), 1.0); + EXPECT_EQ(to->CheckedOffset(), 1.0); } if (!HasFatalFailure()) { return StringKeyframeEffectModel::Create(frames);
diff --git a/third_party/WebKit/Source/core/animation/EffectInputTest.cpp b/third_party/WebKit/Source/core/animation/EffectInputTest.cpp index 65939376..5899a3c 100644 --- a/third_party/WebKit/Source/core/animation/EffectInputTest.cpp +++ b/third_party/WebKit/Source/core/animation/EffectInputTest.cpp
@@ -48,7 +48,7 @@ DictionarySequenceOrDictionary::FromDictionarySequence(js_keyframes), EffectModel::kCompositeReplace, nullptr, scope.GetExceptionState()); EXPECT_FALSE(scope.GetExceptionState().HadException()); - EXPECT_EQ(1.0, effect->GetFrames()[1]->Offset()); + EXPECT_EQ(1.0, effect->GetFrames()[1]->CheckedOffset()); } TEST(AnimationEffectInputTest, UnsortedOffsets) { @@ -102,7 +102,7 @@ DictionarySequenceOrDictionary::FromDictionarySequence(js_keyframes), EffectModel::kCompositeReplace, nullptr, scope.GetExceptionState()); EXPECT_FALSE(scope.GetExceptionState().HadException()); - EXPECT_EQ(1, effect->GetFrames()[2]->Offset()); + EXPECT_EQ(1, effect->GetFrames()[2]->CheckedOffset()); } TEST(AnimationEffectInputTest, OutOfOrderWithNullOffsets) {
diff --git a/third_party/WebKit/Source/core/animation/Keyframe.cpp b/third_party/WebKit/Source/core/animation/Keyframe.cpp index 2108cb1..92d1397b 100644 --- a/third_party/WebKit/Source/core/animation/Keyframe.cpp +++ b/third_party/WebKit/Source/core/animation/Keyframe.cpp
@@ -22,7 +22,11 @@ void Keyframe::AddKeyframePropertiesToV8Object( V8ObjectBuilder& object_builder) const { - object_builder.Add("offset", offset_); + if (offset_) { + object_builder.Add("offset", offset_.value()); + } else { + object_builder.AddNull("offset"); + } object_builder.Add("easing", easing_->ToString()); if (composite_.has_value()) { object_builder.AddString( @@ -33,7 +37,9 @@ bool Keyframe::CompareOffsets(const scoped_refptr<Keyframe>& a, const scoped_refptr<Keyframe>& b) { - return a->Offset() < b->Offset(); + if (!a->Offset() || !b->Offset()) + return false; + return a->CheckedOffset() < b->CheckedOffset(); } } // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/Keyframe.h b/third_party/WebKit/Source/core/animation/Keyframe.h index cebed13..4c720637 100644 --- a/third_party/WebKit/Source/core/animation/Keyframe.h +++ b/third_party/WebKit/Source/core/animation/Keyframe.h
@@ -67,8 +67,9 @@ virtual ~Keyframe() {} // TODO(smcgruer): The keyframe offset should be immutable. - void SetOffset(double offset) { offset_ = offset; } - double Offset() const { return offset_; } + void SetOffset(WTF::Optional<double> offset) { offset_ = offset; } + WTF::Optional<double> Offset() const { return offset_; } + double CheckedOffset() const { return offset_.value(); } // TODO(smcgruer): The keyframe composite operation should be immutable. void SetComposite(EffectModel::CompositeOperation composite) { @@ -191,10 +192,8 @@ protected: Keyframe() - : offset_(NullValue()), - composite_(), - easing_(LinearTimingFunction::Shared()) {} - Keyframe(double offset, + : offset_(), composite_(), easing_(LinearTimingFunction::Shared()) {} + Keyframe(WTF::Optional<double> offset, WTF::Optional<EffectModel::CompositeOperation> composite, scoped_refptr<TimingFunction> easing) : offset_(offset), composite_(composite), easing_(std::move(easing)) { @@ -202,7 +201,7 @@ easing_ = LinearTimingFunction::Shared(); } - double offset_; + WTF::Optional<double> offset_; WTF::Optional<EffectModel::CompositeOperation> composite_; scoped_refptr<TimingFunction> easing_; DISALLOW_COPY_AND_ASSIGN(Keyframe);
diff --git a/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp b/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp index ace2422..9453df5 100644 --- a/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp +++ b/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp
@@ -154,35 +154,39 @@ Vector<double> KeyframeEffectModelBase::GetComputedOffsets( const KeyframeVector& keyframes) { + // To avoid having to create two vectors when converting from the nullable + // offsets to the non-nullable computed offsets, we keep the convention in + // this function that std::numeric_limits::quiet_NaN() represents null. double last_offset = 0; Vector<double> result; result.ReserveCapacity(keyframes.size()); for (const auto& keyframe : keyframes) { - double offset = keyframe->Offset(); - if (!IsNull(offset)) { - DCHECK_GE(offset, 0); - DCHECK_LE(offset, 1); - DCHECK_GE(offset, last_offset); - last_offset = offset; + WTF::Optional<double> offset = keyframe->Offset(); + if (offset) { + DCHECK_GE(offset.value(), 0); + DCHECK_LE(offset.value(), 1); + DCHECK_GE(offset.value(), last_offset); + last_offset = offset.value(); } - result.push_back(offset); + result.push_back(offset.value_or(std::numeric_limits<double>::quiet_NaN())); } if (result.IsEmpty()) return result; - if (IsNull(result.back())) + if (std::isnan(result.back())) result.back() = 1; - if (result.size() > 1 && IsNull(result[0])) + if (result.size() > 1 && std::isnan(result[0])) { result.front() = 0; + } size_t last_index = 0; last_offset = result.front(); for (size_t i = 1; i < result.size(); ++i) { double offset = result[i]; - if (!IsNull(offset)) { + if (!std::isnan(offset)) { for (size_t j = 1; j < i - last_index; ++j) { result[last_index + j] = last_offset + (offset - last_offset) * j / (i - last_index);
diff --git a/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp b/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp index d9bd67c..f333186 100644 --- a/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp +++ b/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp
@@ -123,8 +123,8 @@ const KeyframeVector keyframes = animation->Model()->GetFrames(); - EXPECT_EQ(0, keyframes[0]->Offset()); - EXPECT_EQ(1, keyframes[1]->Offset()); + EXPECT_EQ(0, keyframes[0]->CheckedOffset()); + EXPECT_EQ(1, keyframes[1]->CheckedOffset()); const CSSValue& keyframe1_width = ToStringKeyframe(keyframes[0].get())
diff --git a/third_party/WebKit/Source/core/animation/TransitionKeyframe.cpp b/third_party/WebKit/Source/core/animation/TransitionKeyframe.cpp index 8754132..7f5b72c0 100644 --- a/third_party/WebKit/Source/core/animation/TransitionKeyframe.cpp +++ b/third_party/WebKit/Source/core/animation/TransitionKeyframe.cpp
@@ -40,7 +40,7 @@ DCHECK(offset == offset_); EffectModel::CompositeOperation composite = composite_.value_or(effect_composite); - return PropertySpecificKeyframe::Create(Offset(), &Easing(), composite, + return PropertySpecificKeyframe::Create(CheckedOffset(), &Easing(), composite, value_->Clone(), compositor_value_); }
diff --git a/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp b/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp index ef68806..ecd465a9c 100644 --- a/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp +++ b/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp
@@ -150,7 +150,8 @@ Keyframe::CompareOffsets); size_t target_index = 0; for (size_t i = 1; i < keyframes.size(); i++) { - if (keyframes[i]->Offset() == keyframes[target_index]->Offset()) { + if (keyframes[i]->CheckedOffset() == + keyframes[target_index]->CheckedOffset()) { for (const auto& property : keyframes[i]->Properties()) { keyframes[target_index]->SetCSSPropertyValue( property.GetCSSProperty().PropertyID(), @@ -167,22 +168,22 @@ // Add 0% and 100% keyframes if absent. scoped_refptr<StringKeyframe> start_keyframe = keyframes.IsEmpty() ? nullptr : keyframes[0]; - if (!start_keyframe || keyframes[0]->Offset() != 0) { + if (!start_keyframe || keyframes[0]->CheckedOffset() != 0) { start_keyframe = StringKeyframe::Create(); start_keyframe->SetOffset(0); start_keyframe->SetEasing(default_timing_function); keyframes.push_front(start_keyframe); } scoped_refptr<StringKeyframe> end_keyframe = keyframes[keyframes.size() - 1]; - if (end_keyframe->Offset() != 1) { + if (end_keyframe->CheckedOffset() != 1) { end_keyframe = StringKeyframe::Create(); end_keyframe->SetOffset(1); end_keyframe->SetEasing(default_timing_function); keyframes.push_back(end_keyframe); } DCHECK_GE(keyframes.size(), 2U); - DCHECK(!keyframes.front()->Offset()); - DCHECK_EQ(keyframes.back()->Offset(), 1); + DCHECK_EQ(keyframes.front()->CheckedOffset(), 0); + DCHECK_EQ(keyframes.back()->CheckedOffset(), 1); StringKeyframeEffectModel* model = StringKeyframeEffectModel::Create( keyframes, EffectModel::kCompositeReplace, &keyframes[0]->Easing());
diff --git a/third_party/WebKit/Source/core/editing/BUILD.gn b/third_party/WebKit/Source/core/editing/BUILD.gn index f1f4117..08391ce 100644 --- a/third_party/WebKit/Source/core/editing/BUILD.gn +++ b/third_party/WebKit/Source/core/editing/BUILD.gn
@@ -345,6 +345,7 @@ "commands/EditingCommandTest.cpp", "commands/InsertIncrementalTextCommandTest.cpp", "commands/InsertListCommandTest.cpp", + "commands/InsertParagraphSeparatorCommandTest.cpp", "commands/InsertTextCommandTest.cpp", "commands/ReplaceSelectionCommandTest.cpp", "commands/SetCharacterDataCommandTest.cpp",
diff --git a/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp b/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp index e995c18..acd4086 100644 --- a/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp
@@ -444,7 +444,8 @@ visible_pos = CreateVisiblePosition(insertion_position); // If the insertion point is a break element, there is nothing else // we need to do. - if (visible_pos.DeepEquivalent().AnchorNode()->GetLayoutObject()->IsBR()) { + if (visible_pos.IsNotNull() && + visible_pos.DeepEquivalent().AnchorNode()->GetLayoutObject()->IsBR()) { SetEndingSelection(SelectionForUndoStep::From( SelectionInDOMTree::Builder() .Collapse(insertion_position) @@ -478,6 +479,7 @@ insertion_position = MostBackwardCaretPosition(insertion_position); } + ABORT_EDITING_COMMAND_IF(!IsEditablePosition(insertion_position)); // Make sure we do not cause a rendered space to become unrendered. // FIXME: We need the affinity for pos, but mostForwardCaretPosition does not // give it
diff --git a/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.h b/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.h index 783dac8..fc3e7fb8 100644 --- a/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.h +++ b/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.h
@@ -32,7 +32,8 @@ class EditingStyle; -class InsertParagraphSeparatorCommand final : public CompositeEditCommand { +class CORE_EXPORT InsertParagraphSeparatorCommand final + : public CompositeEditCommand { public: static InsertParagraphSeparatorCommand* Create( Document& document,
diff --git a/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommandTest.cpp b/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommandTest.cpp new file mode 100644 index 0000000..3ee7518 --- /dev/null +++ b/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommandTest.cpp
@@ -0,0 +1,58 @@ +// Copyright (c) 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "core/editing/commands/InsertParagraphSeparatorCommand.h" + +#include "core/editing/FrameSelection.h" +#include "core/editing/SelectionTemplate.h" +#include "core/editing/testing/EditingTestBase.h" + +namespace blink { + +class InsertParagraphSeparatorCommandTest : public EditingTestBase {}; + +// http://crbug.com/777378 +TEST_F(InsertParagraphSeparatorCommandTest, + CrashWithAppearanceStyleOnEmptyColgroup) { + Selection().SetSelection(SetSelectionTextToBody( + "<table contenteditable>" + " <colgroup style='-webkit-appearance:radio;'><!--|--></colgroup>" + "</table>")); + + InsertParagraphSeparatorCommand* command = + InsertParagraphSeparatorCommand::Create(GetDocument()); + // Crash should not be observed here. + command->Apply(); + + EXPECT_EQ( + "<table contenteditable>" + " <colgroup style=\"-webkit-appearance:radio;\">|<br></colgroup>" + "</table>", + GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); +} + +// http://crbug.com/777378 +TEST_F(InsertParagraphSeparatorCommandTest, + CrashWithAppearanceStyleOnEmptyColumn) { + Selection().SetSelection( + SetSelectionTextToBody("<table contenteditable>" + " <colgroup style='-webkit-appearance:radio;'>" + " <col><!--|--></col>" + " </colgroup>" + "</table>")); + + InsertParagraphSeparatorCommand* command = + InsertParagraphSeparatorCommand::Create(GetDocument()); + // Crash should not be observed here. + command->Apply(); + EXPECT_EQ( + "<table contenteditable>" + " <colgroup style=\"-webkit-appearance:radio;\">|<br>" + " <col>" + " </colgroup>" + "</table>", + GetSelectionTextFromBody(Selection().GetSelectionInDOMTree())); +} + +} // namespace blink
diff --git a/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp index c2f1a88..eb5a428 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp
@@ -107,8 +107,7 @@ DCHECK(effect->Model()->IsKeyframeEffectModel()); const KeyframeVector& keyframes = effect->Model()->GetFrames(); if (keyframes.size() == 3) { - DCHECK(!IsNull(keyframes.at(1)->Offset())); - delay = keyframes.at(1)->Offset() * duration; + delay = keyframes.at(1)->CheckedOffset() * duration; duration -= delay; easing = keyframes.at(1)->Easing().ToString(); } else {
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index be92b643..19474c6 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -3121,6 +3121,38 @@ <int value="3" label="LE with random address"/> </enum> +<enum name="BookmarkAppNavigationResult"> + <int value="0" label="From app or tab to new tab: Context Menu navigation"/> + <int value="1" + label="From probably omnibox to same context: Typed navigation"/> + <int value="2" + label="From probably launch surface e.g. NTP, Shelf, etc. to new app or + tab: Auto Bookmark navigation"/> + <int value="3" label="Keep in subframe: Auto subframe navigation"/> + <int value="4" label="Keep in subframe: Manual subframe navigation"/> + <int value="5" + label="From probably tab to same context: Generated entry navigation"/> + <int value="6" + label="From probably tab to same context: Auto top level navigation"/> + <int value="7" label="From app or tab to same context: Reload navigation"/> + <int value="8" label="From probably tab to same context: Keyword navigation"/> + <int value="9" + label="From probably tab to same context: Generated keyword navigation"/> + <int value="10" + label="From app or tab to same context: Forward/Back navigation"/> + <int value="11" + label="From probably omnibox to same context: Address bar navigation"/> + <int value="12" label="From app to new tab: Out of scope launch"/> + <int value="13" label="From app to same context: Same scope navigation"/> + <int value="14" label="From tab to same context: Form submission"/> + <int value="15" label="From tab to same context: Same scope navigation"/> + <int value="16" label="In app or tab, cancel prerender link navigation"/> + <int value="17" + label="From app or tab to new app context, close previous context"/> + <int value="18" label="From app or tab to new app context"/> + <int value="19" label="From app to new tab: Out of scope navigation"/> +</enum> + <enum name="BookmarkLaunchLocation"> <int value="0" label="Attached bookmark bar"/> <int value="1" label="Detached (floating) bookmark bar"/>
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 5ae479a8..c7a0782 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -22425,6 +22425,16 @@ </summary> </histogram> +<histogram name="Extensions.BookmarkApp.NavigationResult" + enum="BookmarkAppNavigationResult"> + <owner>mgiuca@chromium.org</owner> + <owner>ortuno@chromium.org</owner> + <summary> + Number of times navigations into and out of Bookmark Apps are processed, + grouped by their result. + </summary> +</histogram> + <histogram name="Extensions.BookmarkAppLaunchContainer" enum="AppLaunchContainer"> <owner>benwells@chromium.org</owner>
diff --git a/ui/aura/mus/mus_context_factory.cc b/ui/aura/mus/mus_context_factory.cc index 8ceac59..8d8103c 100644 --- a/ui/aura/mus/mus_context_factory.cc +++ b/ui/aura/mus/mus_context_factory.cc
@@ -8,6 +8,7 @@ #include "base/memory/ptr_util.h" #include "cc/base/switches.h" #include "components/viz/common/gpu/context_provider.h" +#include "components/viz/common/resources/buffer_to_texture_target_map.h" #include "components/viz/host/renderer_settings_creation.h" #include "services/ui/public/cpp/gpu/gpu.h" #include "ui/aura/mus/window_port_mus.h" @@ -19,28 +20,11 @@ namespace aura { -namespace { -viz::BufferToTextureTargetMap CreateBufferToTextureTargetMap() { - viz::BufferToTextureTargetMap image_targets; - for (int usage_idx = 0; usage_idx <= static_cast<int>(gfx::BufferUsage::LAST); - ++usage_idx) { - gfx::BufferUsage usage = static_cast<gfx::BufferUsage>(usage_idx); - for (int format_idx = 0; - format_idx <= static_cast<int>(gfx::BufferFormat::LAST); - ++format_idx) { - gfx::BufferFormat format = static_cast<gfx::BufferFormat>(format_idx); - // TODO(sad): http://crbug.com/675431 - image_targets[std::make_pair(usage, format)] = GL_TEXTURE_2D; - } - } - return image_targets; -} -} // namespace - MusContextFactory::MusContextFactory(ui::Gpu* gpu) : gpu_(gpu), resource_settings_( - viz::CreateResourceSettings(CreateBufferToTextureTargetMap())), + // TODO(sad): http://crbug.com/675431 + viz::CreateResourceSettings(viz::BufferUsageAndFormatList())), weak_ptr_factory_(this) {} MusContextFactory::~MusContextFactory() {}
diff --git a/ui/aura/test/mus/test_window_tree.cc b/ui/aura/test/mus/test_window_tree.cc index e875d7a..dae3b14e 100644 --- a/ui/aura/test/mus/test_window_tree.cc +++ b/ui/aura/test/mus/test_window_tree.cc
@@ -4,6 +4,7 @@ #include "ui/aura/test/mus/test_window_tree.h" +#include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" namespace aura { @@ -37,6 +38,20 @@ return std::move(last_new_window_properties_); } +void TestWindowTree::NotifyClientAboutAcceleratedWidget() { + // This magic value comes from managed_display_info.cc + const int64_t kSynthesizedDisplayIdStart = 2200000000LL; +#if defined(OS_WIN) + const gfx::AcceleratedWidget kSynthesizedAcceleratedWidget = + reinterpret_cast<gfx::AcceleratedWidget>(1); +#else + const gfx::AcceleratedWidget kSynthesizedAcceleratedWidget = + static_cast<gfx::AcceleratedWidget>(1); +#endif + window_manager_->WmOnAcceleratedWidgetForDisplay( + kSynthesizedDisplayIdStart, kSynthesizedAcceleratedWidget); +} + void TestWindowTree::AckAllChanges() { while (!changes_.empty()) { client_->OnChangeCompleted(changes_[0].id, true);
diff --git a/ui/aura/test/mus/test_window_tree.h b/ui/aura/test/mus/test_window_tree.h index b3c44d2..4ed17e0 100644 --- a/ui/aura/test/mus/test_window_tree.h +++ b/ui/aura/test/mus/test_window_tree.h
@@ -48,6 +48,9 @@ ~TestWindowTree() override; void set_client(ui::mojom::WindowTreeClient* client) { client_ = client; } + void set_window_manager(ui::mojom::WindowManager* window_manager) { + window_manager_ = window_manager; + } uint32_t window_id() const { return window_id_; } @@ -67,6 +70,10 @@ size_t number_of_changes() const { return changes_.size(); } + // Notifies the client about the accelerated widget when mus is not hosting + // viz. + void NotifyClientAboutAcceleratedWidget(); + // Acks all changes with a value of true. void AckAllChanges(); @@ -242,6 +249,7 @@ std::vector<Change> changes_; ui::mojom::WindowTreeClient* client_; + ui::mojom::WindowManager* window_manager_ = nullptr; base::Optional<std::unordered_map<std::string, std::vector<uint8_t>>> last_new_window_properties_;
diff --git a/ui/aura/test/mus/test_window_tree_client_setup.cc b/ui/aura/test/mus/test_window_tree_client_setup.cc index b36eb36f..fd94b5fb 100644 --- a/ui/aura/test/mus/test_window_tree_client_setup.cc +++ b/ui/aura/test/mus/test_window_tree_client_setup.cc
@@ -31,6 +31,7 @@ CommonInit(window_tree_delegate, window_manager_delegate); WindowTreeClientPrivate window_tree_client_private(window_tree_client_.get()); window_tree_client_private.SetTree(window_tree_.get()); + window_tree_->set_window_manager(window_tree_client_.get()); window_tree_client_private.SetWindowManagerClient( test_window_manager_client_.get()); } @@ -42,6 +43,10 @@ .SetTree(window_tree_.get()); } +void TestWindowTreeClientSetup::NotifyClientAboutAcceleratedWidget() { + window_tree_->NotifyClientAboutAcceleratedWidget(); +} + std::unique_ptr<WindowTreeClient> TestWindowTreeClientSetup::OwnWindowTreeClient() { DCHECK(window_tree_client_);
diff --git a/ui/aura/test/mus/test_window_tree_client_setup.h b/ui/aura/test/mus/test_window_tree_client_setup.h index d133415..c6aa996 100644 --- a/ui/aura/test/mus/test_window_tree_client_setup.h +++ b/ui/aura/test/mus/test_window_tree_client_setup.h
@@ -34,6 +34,10 @@ // The WindowTree that WindowTreeClient talks to. TestWindowTree* window_tree() { return window_tree_.get(); } + // Notifies the client about the accelerated widget when mus is not hosting + // viz. + void NotifyClientAboutAcceleratedWidget(); + // Returns ownership of WindowTreeClient to the caller. std::unique_ptr<WindowTreeClient> OwnWindowTreeClient();
diff --git a/ui/compositor/test/fake_context_factory.cc b/ui/compositor/test/fake_context_factory.cc index 4061d83..3b50eb14 100644 --- a/ui/compositor/test/fake_context_factory.cc +++ b/ui/compositor/test/fake_context_factory.cc
@@ -24,19 +24,6 @@ #elif defined(OS_MACOSX) renderer_settings_.release_overlay_resources_after_gpu_query = true; #endif - // Populate buffer_to_texture_target_map for all buffer usage/formats. - for (int usage_idx = 0; usage_idx <= static_cast<int>(gfx::BufferUsage::LAST); - ++usage_idx) { - gfx::BufferUsage usage = static_cast<gfx::BufferUsage>(usage_idx); - for (int format_idx = 0; - format_idx <= static_cast<int>(gfx::BufferFormat::LAST); - ++format_idx) { - gfx::BufferFormat format = static_cast<gfx::BufferFormat>(format_idx); - renderer_settings_.resource_settings - .buffer_to_texture_target_map[std::make_pair(usage, format)] = - GL_TEXTURE_2D; - } - } } FakeContextFactory::~FakeContextFactory() = default;
diff --git a/ui/compositor/test/in_process_context_factory.cc b/ui/compositor/test/in_process_context_factory.cc index 3a9faea..7aef1ee 100644 --- a/ui/compositor/test/in_process_context_factory.cc +++ b/ui/compositor/test/in_process_context_factory.cc
@@ -168,19 +168,6 @@ #elif defined(OS_MACOSX) renderer_settings_.release_overlay_resources_after_gpu_query = true; #endif - // Populate buffer_to_texture_target_map for all buffer usage/formats. - for (int usage_idx = 0; usage_idx <= static_cast<int>(gfx::BufferUsage::LAST); - ++usage_idx) { - gfx::BufferUsage usage = static_cast<gfx::BufferUsage>(usage_idx); - for (int format_idx = 0; - format_idx <= static_cast<int>(gfx::BufferFormat::LAST); - ++format_idx) { - gfx::BufferFormat format = static_cast<gfx::BufferFormat>(format_idx); - renderer_settings_.resource_settings - .buffer_to_texture_target_map[std::make_pair(usage, format)] = - GL_TEXTURE_2D; - } - } } InProcessContextFactory::~InProcessContextFactory() {
diff --git a/ui/gfx/ca_layer_params.h b/ui/gfx/ca_layer_params.h index d5ba764..4014e64 100644 --- a/ui/gfx/ca_layer_params.h +++ b/ui/gfx/ca_layer_params.h
@@ -6,6 +6,7 @@ #define UI_GFX_CA_LAYER_PARAMS_H_ #include "build/build_config.h" +#include "ui/gfx/geometry/size.h" #include "ui/gfx/gfx_export.h" #if defined(OS_MACOSX) && !defined(OS_IOS) @@ -24,24 +25,25 @@ CALayerParams& operator=(const CALayerParams& params); ~CALayerParams(); -#if defined(OS_MACOSX) && !defined(OS_IOS) // The |is_empty| flag is used to short-circuit code to handle CALayerParams // on non-macOS platforms. - bool is_empty = false; + bool is_empty = true; + // Can be used to instantiate a CALayerTreeHost in the browser process, which // will display a CALayerTree rooted in the GPU process. This is non-zero when // using remote CoreAnimation. uint32_t ca_context_id = 0; + // Used to set the contents of a CALayer in the browser to an IOSurface that // is specified by the GPU process. This is non-null iff |ca_context_id| is // zero. +#if defined(OS_MACOSX) && !defined(OS_IOS) gfx::ScopedRefCountedIOSurfaceMachPort io_surface_mach_port; - // The geometry of the +#endif + + // The geometry of the frame. gfx::Size pixel_size; float scale_factor = 1.f; -#else - bool is_empty = true; -#endif }; } // namespace gfx
diff --git a/ui/gfx/mojo/BUILD.gn b/ui/gfx/mojo/BUILD.gn index b71ee25..0e18fcc 100644 --- a/ui/gfx/mojo/BUILD.gn +++ b/ui/gfx/mojo/BUILD.gn
@@ -8,6 +8,7 @@ sources = [ "accelerated_widget.mojom", "buffer_types.mojom", + "ca_layer_params.mojom", "color_space.mojom", "icc_profile.mojom", "overlay_transform.mojom",
diff --git a/ui/gfx/mojo/ca_layer_params.mojom b/ui/gfx/mojo/ca_layer_params.mojom new file mode 100644 index 0000000..bdb8ef6 --- /dev/null +++ b/ui/gfx/mojo/ca_layer_params.mojom
@@ -0,0 +1,18 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module gfx.mojom; + +import "ui/gfx/geometry/mojo/geometry.mojom"; + +// gfx::CALayerParams +struct CALayerParams { + // TODO(676224): Use preprocessor to restrict platform-specific members to + // desired platform. + bool is_empty; + uint32 ca_context_id; + handle? io_surface_mach_port; + gfx.mojom.Size pixel_size; + float scale_factor; +};
diff --git a/ui/gfx/mojo/ca_layer_params.typemap b/ui/gfx/mojo/ca_layer_params.typemap new file mode 100644 index 0000000..215f58b3 --- /dev/null +++ b/ui/gfx/mojo/ca_layer_params.typemap
@@ -0,0 +1,14 @@ +# Copyright 2017 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +mojom = "//ui/gfx/mojo/ca_layer_params.mojom" +public_headers = [ "//ui/gfx/ca_layer_params.h" ] +traits_headers = [ "//ui/gfx/mojo/ca_layer_params_struct_traits.h" ] +sources = [ + "//ui/gfx/mojo/ca_layer_params_struct_traits.cc", +] +public_deps = [ + "//ui/gfx", +] +type_mappings = [ "gfx.mojom.CALayerParams=gfx::CALayerParams" ]
diff --git a/ui/gfx/mojo/ca_layer_params_struct_traits.cc b/ui/gfx/mojo/ca_layer_params_struct_traits.cc new file mode 100644 index 0000000..a2cb2a9 --- /dev/null +++ b/ui/gfx/mojo/ca_layer_params_struct_traits.cc
@@ -0,0 +1,44 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/gfx/mojo/ca_layer_params_struct_traits.h" + +#include "build/build_config.h" +#include "mojo/public/cpp/system/platform_handle.h" +#include "ui/gfx/geometry/mojo/geometry_struct_traits.h" + +namespace mojo { + +mojo::ScopedHandle +StructTraits<gfx::mojom::CALayerParamsDataView, gfx::CALayerParams>:: + io_surface_mach_port(const gfx::CALayerParams& ca_layer_params) { +#if defined(OS_MACOSX) && !defined(OS_IOS) + return mojo::WrapMachPort(ca_layer_params.io_surface_mach_port.get()); +#else + return mojo::ScopedHandle(); +#endif +} + +bool StructTraits<gfx::mojom::CALayerParamsDataView, gfx::CALayerParams>::Read( + gfx::mojom::CALayerParamsDataView data, + gfx::CALayerParams* out) { + out->is_empty = data.is_empty(); + out->ca_context_id = data.ca_context_id(); + +#if defined(OS_MACOSX) && !defined(OS_IOS) + mach_port_t io_surface_mach_port; + MojoResult unwrap_result = + mojo::UnwrapMachPort(data.TakeIoSurfaceMachPort(), &io_surface_mach_port); + if (unwrap_result != MOJO_RESULT_OK) + return false; + out->io_surface_mach_port.reset(io_surface_mach_port); +#endif + + if (!data.ReadPixelSize(&out->pixel_size)) + return false; + out->scale_factor = data.scale_factor(); + return true; +} + +} // namespace mojo
diff --git a/ui/gfx/mojo/ca_layer_params_struct_traits.h b/ui/gfx/mojo/ca_layer_params_struct_traits.h new file mode 100644 index 0000000..59a947cb --- /dev/null +++ b/ui/gfx/mojo/ca_layer_params_struct_traits.h
@@ -0,0 +1,40 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_GFX_MOJO_CA_LAYER_PARAMS_STRUCT_TRAITS_H_ +#define UI_GFX_MOJO_CA_LAYER_PARAMS_STRUCT_TRAITS_H_ + +#include "ui/gfx/ca_layer_params.h" +#include "ui/gfx/mojo/ca_layer_params.mojom.h" + +namespace mojo { + +template <> +struct StructTraits<gfx::mojom::CALayerParamsDataView, gfx::CALayerParams> { + static uint32_t is_empty(const gfx::CALayerParams& ca_layer_params) { + return ca_layer_params.is_empty; + } + + static uint32_t ca_context_id(const gfx::CALayerParams& ca_layer_params) { + return ca_layer_params.ca_context_id; + } + + static mojo::ScopedHandle io_surface_mach_port( + const gfx::CALayerParams& ca_layer_params); + + static gfx::Size pixel_size(const gfx::CALayerParams& ca_layer_params) { + return ca_layer_params.pixel_size; + } + + static float scale_factor(const gfx::CALayerParams& ca_layer_params) { + return ca_layer_params.scale_factor; + } + + static bool Read(gfx::mojom::CALayerParamsDataView data, + gfx::CALayerParams* out); +}; + +} // namespace mojo + +#endif // UI_GFX_MOJO_CA_LAYER_PARAMS_STRUCT_TRAITS_H_
diff --git a/ui/gfx/typemaps.gni b/ui/gfx/typemaps.gni index 375f74db..bc301d9 100644 --- a/ui/gfx/typemaps.gni +++ b/ui/gfx/typemaps.gni
@@ -7,6 +7,7 @@ "//ui/gfx/image/mojo/image.typemap", "//ui/gfx/mojo/accelerated_widget.typemap", "//ui/gfx/mojo/buffer_types.typemap", + "//ui/gfx/mojo/ca_layer_params.typemap", "//ui/gfx/mojo/color_space.typemap", "//ui/gfx/mojo/icc_profile.typemap", "//ui/gfx/mojo/overlay_transform.typemap",