diff --git a/.gn b/.gn index a98d422..4f3a26c 100644 --- a/.gn +++ b/.gn
@@ -106,7 +106,6 @@ "//chrome/browser/client_hints/*", "//chrome/browser/clipboard/*", "//chrome/browser/component_updater/*", - "//chrome/browser/conflicts/*", "//chrome/browser/consent_auditor/*", "//chrome/browser/content_settings/*", "//chrome/browser/crash_upload_list/*",
diff --git a/DEPS b/DEPS index c6a8388..10752de 100644 --- a/DEPS +++ b/DEPS
@@ -133,7 +133,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Skia # and whatever else without interference from each other. - 'skia_revision': 'e5b3e400b6e960814e55cd0e737dce14cb5c199a', + 'skia_revision': 'b45ee83cc7c0f08be3e6bf6a2c9e3442da05a95d', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. @@ -145,15 +145,15 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. - 'angle_revision': 'cafd7736490e2cfeca38397301853e76dfce91c4', + 'angle_revision': '52bfbd35fc969f1fa2366e0cd28a8d832cbdddc0', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling SwiftShader # and whatever else without interference from each other. - 'swiftshader_revision': '0559bc475569285c4499c46af575b3d8ef19b346', + 'swiftshader_revision': '62ad1eeb0e6b85ff703ea2a6c6c2edd07ad2494d', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling PDFium # and whatever else without interference from each other. - 'pdfium_revision': 'c5202e607426f86888d1c5fd33e7603d32b2d6f0', + 'pdfium_revision': 'b6220d071585a765b9ae8a626a5975e4d6fb4ab7', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling BoringSSL # and whatever else without interference from each other. @@ -196,7 +196,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling catapult # and whatever else without interference from each other. - 'catapult_revision': 'b1d937f4218ece4f194f35e0d2475f51ce4493c7', + 'catapult_revision': '6ea34ccba4c6ae51128efad41523d6616b152e36', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libFuzzer # and whatever else without interference from each other. @@ -802,7 +802,7 @@ # Build tools for Chrome OS. Note: This depends on third_party/pyelftools. 'src/third_party/chromite': { - 'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + '23e25e0bb4dc715701aa4477e66ce908649999e6', + 'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + 'fdbb15913346db795e7a7c9288feaf79c92e2cf4', 'condition': 'checkout_linux', }, @@ -822,12 +822,12 @@ }, 'src/third_party/custom_tabs_client/src': { - 'url': Var('chromium_git') + '/custom-tabs-client.git' + '@' + 'b0d6c6e86d8046fa62135cebb7bc59d9feac9f89', + 'url': Var('chromium_git') + '/custom-tabs-client.git' + '@' + '1663ae63d21b24f9de7e07c46013a6ff1c03f49c', 'condition': 'checkout_android', }, 'src/third_party/depot_tools': - Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '0e405d1ac6adc90fcb7082270363d9e11758e28c', + Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + 'd7e41546c030e9eb41bede1d4acfaa2a31b1c509', 'src/third_party/devtools-node-modules': Var('chromium_git') + '/external/github.com/ChromeDevTools/devtools-node-modules' + '@' + Var('devtools_node_modules_revision'), @@ -1247,7 +1247,7 @@ 'packages': [ { 'package': 'chromium/third_party/r8', - 'version': '-hqyjKgjGWSfNsdcPJAnYNVOb96JOv0pJM82vtRo9M8C', + 'version': 'jfE9VkwFvzhAgaBwY40d5HnUk_gcPl8H5vqsTQtb7DYC', }, ], 'condition': 'checkout_android', @@ -1263,7 +1263,7 @@ 'packages': [ { 'package': 'chromium/third_party/robolectric', - 'version': 'iRFT1e5YFmRn5cbV0cAkQ5vDUXFmQ4qPYqStmmDfiMMC', + 'version': '1KXoOiNP1a_uZNdM2ybWKwAQNow1dHTXTig-ZK4Xgq8C', }, ], 'condition': 'checkout_android', @@ -1386,7 +1386,7 @@ Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@c05031d35df81197b8d4c21138acb045b3de88fe', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@bbaaf61f1d995681f17a25bc2c19c0e32b63a526', 'condition': 'checkout_src_internal', },
diff --git a/android_webview/browser/aw_content_browser_overlay_manifest.cc b/android_webview/browser/aw_content_browser_overlay_manifest.cc index 34c0910c..a86c7b24 100644 --- a/android_webview/browser/aw_content_browser_overlay_manifest.cc +++ b/android_webview/browser/aw_content_browser_overlay_manifest.cc
@@ -10,6 +10,7 @@ #include "components/services/heap_profiling/public/mojom/heap_profiling_client.mojom.h" #include "components/spellcheck/common/spellcheck.mojom.h" #include "components/web_restrictions/interfaces/web_restrictions.mojom.h" +#include "content/public/common/service_names.mojom.h" #include "services/service_manager/public/cpp/manifest_builder.h" #include "third_party/blink/public/mojom/input/input_host.mojom.h" @@ -25,7 +26,8 @@ .ExposeCapability("profiling_client", service_manager::Manifest::InterfaceList< heap_profiling::mojom::ProfilingClient>()) - .RequireCapability("content_browser", "profiling_client") + .RequireCapability(content::mojom::kSystemServiceName, + "profiling_client") .RequireCapability("heap_profiling", "profiling") .RequireCapability("heap_profiling", "heap_profiler") .ExposeInterfaceFilterCapability_Deprecated(
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentCaptureTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentCaptureTest.java index 99ed9c61..4dfca95 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentCaptureTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentCaptureTest.java
@@ -69,8 +69,9 @@ private final static long DEFAULT_TIMEOUT_IN_SECONDS = 10; public final static int CONTENT_CAPTURED = 1; - public final static int CONTENT_REMOVED = 2; - public final static int SESSION_REMOVED = 3; + public final static int CONTENT_UPDATED = 2; + public final static int CONTENT_REMOVED = 3; + public final static int SESSION_REMOVED = 4; public TestAwContentCaptureConsumer(WebContents webContents) { super(webContents); @@ -90,6 +91,15 @@ } @Override + public void onContentUpdated( + FrameSession parentFrame, ContentCaptureData contentCaptureData) { + mParentFrame = parentFrame; + mUpdatedContent = contentCaptureData; + mCallbacks.add(CONTENT_UPDATED); + mCallbackHelper.notifyCalled(); + } + + @Override public void onSessionRemoved(FrameSession session) { mCallbacks.add(SESSION_REMOVED); mCallbackHelper.notifyCalled(); @@ -113,6 +123,10 @@ return mCapturedContent; } + public ContentCaptureData getUpdatedContent() { + return mUpdatedContent; + } + public FrameSession getCurrentFrameSession() { return mCurrentFrameSession; } @@ -124,6 +138,7 @@ public void reset() { mParentFrame = null; mCapturedContent = null; + mUpdatedContent = null; mCurrentFrameSession = null; mRemovedIds = null; mCallbacks.clear(); @@ -160,6 +175,7 @@ private volatile Set<Long> mCapturedContentIds; private volatile FrameSession mParentFrame; private volatile ContentCaptureData mCapturedContent; + private volatile ContentCaptureData mUpdatedContent; private volatile FrameSession mCurrentFrameSession; private volatile long[] mRemovedIds; private volatile ArrayList<Integer> mCallbacks = new ArrayList<Integer>(); @@ -240,6 +256,12 @@ () -> { mContainerView.scrollTo(0, mContainerView.getHeight()); }); } + private void changeContent(String id, String content) { + String script = "var el = document.getElementById('" + id + "');" + + "el.firstChild.textContent = '" + content + "';"; + runScript(script); + } + private void scrollToTop() { TestThreadUtils.runOnUiThreadBlocking(() -> { mContainerView.scrollTo(0, 0); }); } @@ -259,14 +281,20 @@ throws Exception {} private static void verifyContent(Set<String> expectedContent, Set<Long> unexpectedIds, - ContentCaptureData result) throws Exception { + Set<Long> expectedIds, ContentCaptureData result) throws Exception { Assert.assertEquals(expectedContent.size(), result.getChildren().size()); + if (expectedIds != null) { + Assert.assertEquals(expectedIds.size(), result.getChildren().size()); + } for (ContentCaptureData child : result.getChildren()) { Assert.assertTrue(expectedContent.contains(child.getValue())); expectedContent.remove(child.getValue()); if (unexpectedIds != null) { Assert.assertFalse(unexpectedIds.contains(child.getId())); } + if (expectedIds != null) { + Assert.assertTrue(expectedIds.contains(child.getId())); + } Assert.assertFalse(child.getBounds().isEmpty()); } Assert.assertTrue(expectedContent.isEmpty()); @@ -278,7 +306,16 @@ throws Exception { verifyFrameSesion(expectedParentSession, parentResult); verifyFrame(expectedFrameId, expectedUrl, result); - verifyContent(expectedContent, unexpectedContentIds, result); + verifyContent(expectedContent, unexpectedContentIds, null, result); + } + + private static void verifyUpdatedContent(FrameSession expectedParentSession, + Long expectedFrameId, String expectedUrl, Set<String> expectedContent, + Set<Long> expectedContentIds, FrameSession parentResult, ContentCaptureData result) + throws Exception { + verifyFrameSesion(expectedParentSession, parentResult); + verifyFrame(expectedFrameId, expectedUrl, result); + verifyContent(expectedContent, null, expectedContentIds, result); } private static void verifyRemovedIds(Set<Long> expectedIds, long[] result) throws Exception { @@ -394,4 +431,32 @@ verifyRemovedContent(frameId, url, toLongSet(removedContentId), mConsumer.getCurrentFrameSession(), mConsumer.getRemovedIds()); } + + @Test + @SmallTest + @Feature({"AndroidWebView"}) + public void testChangeContent() throws Throwable { + final String response = "<html><head></head><body>" + + "<div id='editable_id'>Hello</div>" + + "</div></body></html>"; + final String url = mWebServer.setResponse(MAIN_FRAME_FILE, response, null); + runAndWaitForCallback(() -> { loadUrlSync(url); }); + verifyCallbacks(toIntArray(TestAwContentCaptureConsumer.CONTENT_CAPTURED), + mConsumer.getCallbacks()); + Long frameId = null; + Set<Long> capturedContentIds = null; + // Verify only on-screen content is captured. + verifyCapturedContent(null, frameId, url, toStringSet("Hello"), capturedContentIds, + mConsumer.getParentFrame(), mConsumer.getCapturedContent()); + + // Change the content, we shall get content updated callback. + frameId = Long.valueOf(mConsumer.getCapturedContent().getId()); + capturedContentIds = mConsumer.cloneCaptureContentIds(); + final String changeContent = "Hello world"; + runAndWaitForCallback(() -> { changeContent("editable_id", changeContent); }); + verifyCallbacks( + toIntArray(TestAwContentCaptureConsumer.CONTENT_UPDATED), mConsumer.getCallbacks()); + verifyUpdatedContent(null, frameId, url, toStringSet(changeContent), capturedContentIds, + mConsumer.getParentFrame(), mConsumer.getUpdatedContent()); + } }
diff --git a/ash/BUILD.gn b/ash/BUILD.gn index 65c9105..2458dc3 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn
@@ -453,8 +453,9 @@ "media/media_notification_background.h", "media/media_notification_constants.cc", "media/media_notification_constants.h", - "media/media_notification_controller.cc", "media/media_notification_controller.h", + "media/media_notification_controller_impl.cc", + "media/media_notification_controller_impl.h", "media/media_notification_item.cc", "media/media_notification_item.h", "media/media_notification_view.cc", @@ -1285,7 +1286,6 @@ "//services/device/public/mojom", "//services/media_session/public/mojom", "//services/service_manager/public/cpp", - "//services/ws/common", "//services/ws/public/cpp", "//services/ws/public/cpp/input_devices", "//services/ws/public/mojom", @@ -1694,7 +1694,7 @@ "magnifier/partial_magnification_controller_unittest.cc", "media/media_controller_unittest.cc", "media/media_notification_background_unittest.cc", - "media/media_notification_controller_unittest.cc", + "media/media_notification_controller_impl_unittest.cc", "media/media_notification_view_unittest.cc", "metrics/demo_session_metrics_recorder_unittest.cc", "metrics/desktop_task_switch_metric_recorder_unittest.cc",
diff --git a/ash/app_list/app_list_view_delegate.h b/ash/app_list/app_list_view_delegate.h index 781c87bf..a2f88b65 100644 --- a/ash/app_list/app_list_view_delegate.h +++ b/ash/app_list/app_list_view_delegate.h
@@ -13,7 +13,6 @@ #include "ash/public/cpp/ash_public_export.h" #include "ash/public/interfaces/app_list.mojom.h" #include "ash/public/interfaces/app_list_view.mojom.h" -#include "ash/public/interfaces/menu.mojom.h" #include "base/callback_forward.h" #include "base/strings/string16.h" #include "mojo/public/cpp/bindings/pending_receiver.h" @@ -25,6 +24,7 @@ namespace ui { class GestureEvent; +class SimpleMenuModel; } // namespace ui namespace app_list { @@ -88,7 +88,7 @@ // or NULL if there is currently no menu for the result. // Note the returned menu model is owned by that result. using GetContextMenuModelCallback = - base::OnceCallback<void(std::vector<ash::mojom::MenuItemPtr>)>; + base::OnceCallback<void(std::unique_ptr<ui::SimpleMenuModel>)>; virtual void GetSearchResultContextMenuModel( const std::string& result_id, GetContextMenuModelCallback callback) = 0;
diff --git a/ash/app_list/test/app_list_test_model.cc b/ash/app_list/test/app_list_test_model.cc index 21941f1..40fe54f 100644 --- a/ash/app_list/test/app_list_test_model.cc +++ b/ash/app_list/test/app_list_test_model.cc
@@ -46,15 +46,13 @@ model_->ItemActivated(this); } -ui::MenuModel* AppListTestModel::AppListTestItem::GetContextMenuModel() { - if (menu_model_) - return menu_model_.get(); - - menu_model_ = std::make_unique<ui::SimpleMenuModel>( +std::unique_ptr<ui::SimpleMenuModel> +AppListTestModel::AppListTestItem::CreateContextMenuModel() { + auto menu_model = std::make_unique<ui::SimpleMenuModel>( nullptr /*no SimpleMenuModelDelegate for tests*/); - menu_model_->AddItem(0, base::ASCIIToUTF16("0")); - menu_model_->AddItem(1, base::ASCIIToUTF16("1")); - return menu_model_.get(); + menu_model->AddItem(0, base::ASCIIToUTF16("0")); + menu_model->AddItem(1, base::ASCIIToUTF16("1")); + return menu_model; } const char* AppListTestModel::AppListTestItem::GetItemType() const {
diff --git a/ash/app_list/test/app_list_test_model.h b/ash/app_list/test/app_list_test_model.h index df6f9009..f952788 100644 --- a/ash/app_list/test/app_list_test_model.h +++ b/ash/app_list/test/app_list_test_model.h
@@ -14,7 +14,6 @@ #include "base/macros.h" namespace ui { -class MenuModel; class SimpleMenuModel; } // namespace ui @@ -30,16 +29,13 @@ AppListTestItem(const std::string& id, AppListTestModel* model); ~AppListTestItem() override; void Activate(int event_flags); - ui::MenuModel* GetContextMenuModel(); + std::unique_ptr<ui::SimpleMenuModel> CreateContextMenuModel(); const char* GetItemType() const override; void SetPosition(const syncer::StringOrdinal& new_position); private: - AppListTestModel* model_; - - // The menu that holds context menu options. - std::unique_ptr<ui::SimpleMenuModel> menu_model_; + AppListTestModel* const model_; DISALLOW_COPY_AND_ASSIGN(AppListTestItem); };
diff --git a/ash/app_list/test/app_list_test_view_delegate.cc b/ash/app_list/test/app_list_test_view_delegate.cc index d7391dd..e7d9de63 100644 --- a/ash/app_list/test/app_list_test_view_delegate.cc +++ b/ash/app_list/test/app_list_test_view_delegate.cc
@@ -11,7 +11,6 @@ #include "ash/app_list/model/app_list_model.h" #include "ash/public/cpp/app_list/app_list_features.h" #include "ash/public/cpp/app_list/app_list_switches.h" -#include "ash/public/cpp/menu_utils.h" #include "base/callback.h" #include "base/files/file_path.h" #include "base/strings/utf_string_conversions.h" @@ -22,8 +21,7 @@ AppListTestViewDelegate::AppListTestViewDelegate() : model_(std::make_unique<AppListTestModel>()), - search_model_(std::make_unique<SearchModel>()), - search_result_context_menu_model_(this) {} + search_model_(std::make_unique<SearchModel>()) {} AppListTestViewDelegate::~AppListTestViewDelegate() {} @@ -102,12 +100,12 @@ GetContextMenuModelCallback callback) { app_list::AppListItem* item = model_->FindItem(id); // TODO(stevenjb/jennyz): Implement this for folder items - ui::MenuModel* menu = nullptr; + std::unique_ptr<ui::SimpleMenuModel> menu_model; if (item && !item->is_folder()) { - menu = static_cast<AppListTestModel::AppListTestItem*>(item) - ->GetContextMenuModel(); + menu_model = static_cast<AppListTestModel::AppListTestItem*>(item) + ->CreateContextMenuModel(); } - std::move(callback).Run(ash::menu_utils::GetMojoMenuItemsFromModel(menu)); + std::move(callback).Run(std::move(menu_model)); } void AppListTestViewDelegate::ShowWallpaperContextMenu( @@ -134,13 +132,12 @@ void AppListTestViewDelegate::GetSearchResultContextMenuModel( const std::string& result_id, GetContextMenuModelCallback callback) { - ui::SimpleMenuModel* menu = &search_result_context_menu_model_; - menu->Clear(); + auto menu = std::make_unique<ui::SimpleMenuModel>(this); // Change items if needed. int command_id = 0; menu->AddItem(command_id++, base::ASCIIToUTF16("Item0")); menu->AddItem(command_id++, base::ASCIIToUTF16("Item1")); - std::move(callback).Run(ash::menu_utils::GetMojoMenuItemsFromModel(menu)); + std::move(callback).Run(std::move(menu)); } ash::AssistantViewDelegate*
diff --git a/ash/app_list/test/app_list_test_view_delegate.h b/ash/app_list/test/app_list_test_view_delegate.h index b606e627..3d8c16b 100644 --- a/ash/app_list/test/app_list_test_view_delegate.h +++ b/ash/app_list/test/app_list_test_view_delegate.h
@@ -138,7 +138,6 @@ std::unique_ptr<AppListTestModel> model_; std::unique_ptr<SearchModel> search_model_; std::vector<SkColor> wallpaper_prominent_colors_; - ui::SimpleMenuModel search_result_context_menu_model_; content::FakeNavigableContentsFactory fake_navigable_contents_factory_; DISALLOW_COPY_AND_ASSIGN(AppListTestViewDelegate);
diff --git a/ash/app_list/test/test_app_list_client.cc b/ash/app_list/test/test_app_list_client.cc index eb64a4f..30b9f901 100644 --- a/ash/app_list/test/test_app_list_client.cc +++ b/ash/app_list/test/test_app_list_client.cc
@@ -14,14 +14,14 @@ void TestAppListClient::GetSearchResultContextMenuModel( const std::string& result_id, GetContextMenuModelCallback callback) { - std::move(callback).Run({}); + std::move(callback).Run(nullptr); } void TestAppListClient::GetContextMenuModel( int profile_id, const std::string& id, GetContextMenuModelCallback callback) { - std::move(callback).Run({}); + std::move(callback).Run(nullptr); } } // namespace ash
diff --git a/ash/app_list/views/app_list_item_view.cc b/ash/app_list/views/app_list_item_view.cc index f368820..507fcb9 100644 --- a/ash/app_list/views/app_list_item_view.cc +++ b/ash/app_list/views/app_list_item_view.cc
@@ -448,9 +448,9 @@ void AppListItemView::OnContextMenuModelReceived( const gfx::Point& point, ui::MenuSourceType source_type, - std::vector<ash::mojom::MenuItemPtr> menu) { + std::unique_ptr<ui::SimpleMenuModel> menu_model) { waiting_for_context_menu_options_ = false; - if (menu.empty() || (context_menu_ && context_menu_->IsShowingMenu())) + if (!menu_model || (context_menu_ && context_menu_->IsShowingMenu())) return; // GetContextMenuModel is asynchronous and takes a nontrivial amount of time @@ -480,12 +480,11 @@ views::View::ConvertRectToScreen(apps_grid_view_, &anchor_rect); context_menu_ = std::make_unique<AppListMenuModelAdapter>( - item_weak_->GetMetadata()->id, GetWidget(), source_type, this, - AppListMenuModelAdapter::FULLSCREEN_APP_GRID, + item_weak_->GetMetadata()->id, std::move(menu_model), GetWidget(), + source_type, this, AppListMenuModelAdapter::FULLSCREEN_APP_GRID, base::BindOnce(&AppListItemView::OnMenuClosed, weak_ptr_factory_.GetWeakPtr()), apps_grid_view_->IsTabletMode()); - context_menu_->Build(std::move(menu)); context_menu_->Run(anchor_rect, views::MenuAnchorPosition::kBubbleRight, run_types); apps_grid_view_->SetSelectedView(this);
diff --git a/ash/app_list/views/app_list_item_view.h b/ash/app_list/views/app_list_item_view.h index 7ae0281..cb3e405 100644 --- a/ash/app_list/views/app_list_item_view.h +++ b/ash/app_list/views/app_list_item_view.h
@@ -13,7 +13,6 @@ #include "ash/app_list/app_list_export.h" #include "ash/app_list/model/app_list_item_observer.h" #include "ash/app_list/views/app_list_menu_model_adapter.h" -#include "ash/public/interfaces/menu.mojom.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/strings/string16.h" @@ -169,9 +168,10 @@ // Callback invoked when a context menu is received after calling // |AppListViewDelegate::GetContextMenuModel|. - void OnContextMenuModelReceived(const gfx::Point& point, - ui::MenuSourceType source_type, - std::vector<ash::mojom::MenuItemPtr> menu); + void OnContextMenuModelReceived( + const gfx::Point& point, + ui::MenuSourceType source_type, + std::unique_ptr<ui::SimpleMenuModel> menu_model); // views::ContextMenuController overrides: void ShowContextMenuForViewImpl(views::View* source,
diff --git a/ash/app_list/views/app_list_menu_model_adapter.cc b/ash/app_list/views/app_list_menu_model_adapter.cc index ff84ba89..3ff32e54 100644 --- a/ash/app_list/views/app_list_menu_model_adapter.cc +++ b/ash/app_list/views/app_list_menu_model_adapter.cc
@@ -7,7 +7,6 @@ #include <utility> #include "ash/public/cpp/app_menu_constants.h" -#include "ash/public/cpp/menu_utils.h" #include "base/metrics/histogram_macros.h" #include "ui/views/controls/menu/menu_runner.h" @@ -15,6 +14,7 @@ AppListMenuModelAdapter::AppListMenuModelAdapter( const std::string& app_id, + std::unique_ptr<ui::SimpleMenuModel> menu_model, views::Widget* widget_owner, ui::MenuSourceType source_type, Delegate* delegate, @@ -22,7 +22,7 @@ base::OnceClosure on_menu_closed_callback, bool is_tablet_mode) : ash::AppMenuModelAdapter(app_id, - std::make_unique<ui::SimpleMenuModel>(nullptr), + std::move(menu_model), widget_owner, source_type, std::move(on_menu_closed_callback), @@ -35,15 +35,6 @@ AppListMenuModelAdapter::~AppListMenuModelAdapter() = default; -void AppListMenuModelAdapter::Build( - std::vector<ash::mojom::MenuItemPtr> items) { - DCHECK(!items.empty() && !IsShowingMenu()); - - ash::menu_utils::PopulateMenuFromMojoMenuItems(model(), nullptr, items, - &submenu_models_); - menu_items_ = std::move(items); -} - void AppListMenuModelAdapter::RecordHistogramOnMenuClosed() { const base::TimeDelta user_journey_time = base::TimeTicks::Now() - menu_open_time(); @@ -149,18 +140,14 @@ } } -bool AppListMenuModelAdapter::IsItemChecked(int id) const { - return ash::menu_utils::GetMenuItemByCommandId(menu_items_, id)->checked; -} - bool AppListMenuModelAdapter::IsCommandEnabled(int id) const { // NOTIFICATION_CONTAINER is always enabled. It is added to this model by - // NotificationMenuController, but it is not added to |menu_items_|, so check - // for it first. + // NotificationMenuController. It is not known by model()'s delegate (i.e. + // an instance of AppContextMenu). Check for it first. if (id == ash::NOTIFICATION_CONTAINER) return true; - return ash::menu_utils::GetMenuItemByCommandId(menu_items_, id)->enabled; + return ash::AppMenuModelAdapter::IsCommandEnabled(id); } void AppListMenuModelAdapter::ExecuteCommand(int id, int mouse_event_flags) {
diff --git a/ash/app_list/views/app_list_menu_model_adapter.h b/ash/app_list/views/app_list_menu_model_adapter.h index eba00af3..53081eb 100644 --- a/ash/app_list/views/app_list_menu_model_adapter.h +++ b/ash/app_list/views/app_list_menu_model_adapter.h
@@ -11,7 +11,6 @@ #include "ash/app_list/app_list_export.h" #include "ash/app_menu/app_menu_model_adapter.h" -#include "ash/public/interfaces/menu.mojom.h" #include "ui/base/models/simple_menu_model.h" #include "ui/base/ui_base_types.h" #include "ui/views/controls/menu/menu_types.h" @@ -44,6 +43,7 @@ }; AppListMenuModelAdapter(const std::string& app_id, + std::unique_ptr<ui::SimpleMenuModel> menu_model, views::Widget* widget_owner, ui::MenuSourceType source_type, Delegate* delegate, @@ -52,14 +52,10 @@ bool is_tablet_mode); ~AppListMenuModelAdapter() override; - // Builds the menu model from |items|. - void Build(std::vector<ash::mojom::MenuItemPtr> items); - // Overridden from AppMenuModelAdapter: void RecordHistogramOnMenuClosed() override; // Overridden from views::MenuModelAdapter: - bool IsItemChecked(int id) const override; bool IsCommandEnabled(int id) const override; void ExecuteCommand(int id, int mouse_event_flags) override; @@ -70,10 +66,6 @@ // The type of app which is using this object to show a menu. const AppListViewAppType type_; - // The mojo version of the model of items which are shown in a menu. - std::vector<ash::mojom::MenuItemPtr> menu_items_; - std::vector<std::unique_ptr<ui::MenuModel>> submenu_models_; - DISALLOW_COPY_AND_ASSIGN(AppListMenuModelAdapter); };
diff --git a/ash/app_list/views/app_list_menu_model_adapter_unittest.cc b/ash/app_list/views/app_list_menu_model_adapter_unittest.cc index f9533c2..f1e3351 100644 --- a/ash/app_list/views/app_list_menu_model_adapter_unittest.cc +++ b/ash/app_list/views/app_list_menu_model_adapter_unittest.cc
@@ -36,7 +36,8 @@ mock_app_list_menu_model_adapter_delegate_ = std::make_unique<MockAppListMenuModelAdapterDelegate>(); app_list_menu_model_adapter_ = std::make_unique<AppListMenuModelAdapter>( - "test-app-id", nullptr, ui::MenuSourceType::MENU_SOURCE_TYPE_LAST, + "test-app-id", std::make_unique<ui::SimpleMenuModel>(nullptr), nullptr, + ui::MenuSourceType::MENU_SOURCE_TYPE_LAST, mock_app_list_menu_model_adapter_delegate_.get(), AppListMenuModelAdapter::FULLSCREEN_APP_GRID, base::OnceClosure(), false /* is_tablet_mode */);
diff --git a/ash/app_list/views/search_result_tile_item_view.cc b/ash/app_list/views/search_result_tile_item_view.cc index 5e0a2b23c..11b5a67b 100644 --- a/ash/app_list/views/search_result_tile_item_view.cc +++ b/ash/app_list/views/search_result_tile_item_view.cc
@@ -354,8 +354,8 @@ views::View* source, const gfx::Point& point, ui::MenuSourceType source_type, - std::vector<ash::mojom::MenuItemPtr> menu) { - if (menu.empty() || (context_menu_ && context_menu_->IsShowingMenu())) + std::unique_ptr<ui::SimpleMenuModel> menu_model) { + if (!menu_model || (context_menu_ && context_menu_->IsShowingMenu())) return; gfx::Rect anchor_rect = source->GetBoundsInScreen(); @@ -363,11 +363,11 @@ anchor_rect.ClampToCenteredSize(AppListConfig::instance().grid_focus_size()); context_menu_ = std::make_unique<AppListMenuModelAdapter>( - result()->id(), GetWidget(), source_type, this, GetAppType(), + result()->id(), std::move(menu_model), GetWidget(), source_type, this, + GetAppType(), base::BindOnce(&SearchResultTileItemView::OnMenuClosed, weak_ptr_factory_.GetWeakPtr()), view_delegate_->GetSearchModel()->tablet_mode()); - context_menu_->Build(std::move(menu)); context_menu_->Run(anchor_rect, views::MenuAnchorPosition::kBubbleRight, views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::USE_TOUCHABLE_LAYOUT |
diff --git a/ash/app_list/views/search_result_tile_item_view.h b/ash/app_list/views/search_result_tile_item_view.h index 8afa742..86a4f15 100644 --- a/ash/app_list/views/search_result_tile_item_view.h +++ b/ash/app_list/views/search_result_tile_item_view.h
@@ -11,7 +11,6 @@ #include "ash/app_list/app_list_export.h" #include "ash/app_list/views/app_list_menu_model_adapter.h" #include "ash/app_list/views/search_result_base_view.h" -#include "ash/public/interfaces/menu.mojom.h" #include "base/macros.h" #include "ui/views/context_menu_controller.h" @@ -81,7 +80,7 @@ void OnGetContextMenuModel(views::View* source, const gfx::Point& point, ui::MenuSourceType source_type, - std::vector<ash::mojom::MenuItemPtr> menu); + std::unique_ptr<ui::SimpleMenuModel> menu_model); // The callback used when a menu closes. void OnMenuClosed();
diff --git a/ash/app_list/views/search_result_view.cc b/ash/app_list/views/search_result_view.cc index cae7c46..d3299553 100644 --- a/ash/app_list/views/search_result_view.cc +++ b/ash/app_list/views/search_result_view.cc
@@ -454,15 +454,14 @@ views::View* source, const gfx::Point& point, ui::MenuSourceType source_type, - std::vector<ash::mojom::MenuItemPtr> menu) { - if (menu.empty() || context_menu_->IsShowingMenu()) + std::unique_ptr<ui::SimpleMenuModel> menu_model) { + if (!menu_model || context_menu_->IsShowingMenu()) return; context_menu_ = std::make_unique<AppListMenuModelAdapter>( - std::string(), GetWidget(), source_type, this, + std::string(), std::move(menu_model), GetWidget(), source_type, this, AppListMenuModelAdapter::SEARCH_RESULT, base::OnceClosure(), view_delegate_->GetSearchModel()->tablet_mode()); - context_menu_->Build(std::move(menu)); context_menu_->Run(gfx::Rect(point, gfx::Size()), views::MenuAnchorPosition::kTopLeft, views::MenuRunner::HAS_MNEMONICS);
diff --git a/ash/app_list/views/search_result_view.h b/ash/app_list/views/search_result_view.h index 3dde73d..beba147 100644 --- a/ash/app_list/views/search_result_view.h +++ b/ash/app_list/views/search_result_view.h
@@ -15,7 +15,6 @@ #include "ash/app_list/views/app_list_menu_model_adapter.h" #include "ash/app_list/views/search_result_actions_view_delegate.h" #include "ash/app_list/views/search_result_base_view.h" -#include "ash/public/interfaces/menu.mojom.h" #include "base/compiler_specific.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" @@ -105,7 +104,7 @@ void OnGetContextMenu(views::View* source, const gfx::Point& point, ui::MenuSourceType source_type, - std::vector<ash::mojom::MenuItemPtr> menu); + std::unique_ptr<ui::SimpleMenuModel> menu_model); // SearchResultObserver overrides: void OnMetadataChanged() override;
diff --git a/ash/media/media_notification_controller.h b/ash/media/media_notification_controller.h index f3b16cb..ae36a2c 100644 --- a/ash/media/media_notification_controller.h +++ b/ash/media/media_notification_controller.h
@@ -1,79 +1,24 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. +// Copyright 2019 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 ASH_MEDIA_MEDIA_NOTIFICATION_CONTROLLER_H_ #define ASH_MEDIA_MEDIA_NOTIFICATION_CONTROLLER_H_ -#include <map> -#include <memory> #include <string> #include "ash/ash_export.h" -#include "ash/media/media_notification_item.h" -#include "base/macros.h" -#include "mojo/public/cpp/bindings/binding.h" -#include "services/media_session/public/mojom/audio_focus.mojom.h" -#include "services/media_session/public/mojom/media_controller.mojom.h" - -namespace service_manager { -class Connector; -} // namespace service_manager namespace ash { -namespace { -class MediaNotificationBlocker; -} // namespace - -class MediaNotificationItem; -class MediaNotificationView; - -// MediaNotificationController will show/hide media notifications when media -// sessions are active. These notifications will show metadata and playback -// controls. -class ASH_EXPORT MediaNotificationController - : public media_session::mojom::AudioFocusObserver { +// MediaNotificationController does the actual hiding and showing of the media +// notification. +class ASH_EXPORT MediaNotificationController { public: - // The name of the histogram used to record the number of concurrent media - // notifications. - static const char kCountHistogramName[]; - - explicit MediaNotificationController(service_manager::Connector* connector); - ~MediaNotificationController() override; - - // media_session::mojom::AudioFocusObserver: - void OnFocusGained( - media_session::mojom::AudioFocusRequestStatePtr session) override; - void OnFocusLost( - media_session::mojom::AudioFocusRequestStatePtr session) override; - - void SetView(const std::string& id, MediaNotificationView* view); - - MediaNotificationItem* GetItem(const std::string& id) { - auto it = notifications_.find(id); - DCHECK(it != notifications_.end()); - return &it->second; - } - - // Called by |MediaNotificationItem| when it displays a new media - // notification. It will record the concurrent number of media notifications - // displayed. - void RecordConcurrentNotificationCount(); - - private: - media_session::mojom::MediaControllerManagerPtr controller_manager_ptr_; - - mojo::Binding<media_session::mojom::AudioFocusObserver> - audio_focus_observer_binding_{this}; - - // Stores a |MediaNotificationItem| for each media session keyed by its - // |request_id| in string format. - std::map<const std::string, MediaNotificationItem> notifications_; - - std::unique_ptr<MediaNotificationBlocker> blocker_; - - DISALLOW_COPY_AND_ASSIGN(MediaNotificationController); + // Shows/hides a notification with the given request id. Called by + // MediaNotificationItem when the notification should be shown/hidden. + virtual void ShowNotification(const std::string& id) = 0; + virtual void HideNotification(const std::string& id) = 0; }; } // namespace ash
diff --git a/ash/media/media_notification_controller.cc b/ash/media/media_notification_controller_impl.cc similarity index 65% rename from ash/media/media_notification_controller.cc rename to ash/media/media_notification_controller_impl.cc index fd9913b..14a27af41 100644 --- a/ash/media/media_notification_controller.cc +++ b/ash/media/media_notification_controller_impl.cc
@@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/media/media_notification_controller.h" +#include "ash/media/media_notification_controller_impl.h" #include "ash/media/media_notification_constants.h" +#include "ash/media/media_notification_item.h" #include "ash/media/media_notification_view.h" +#include "ash/public/cpp/notification_utils.h" #include "ash/session/session_controller_impl.h" #include "ash/session/session_observer.h" #include "ash/shell.h" @@ -16,6 +18,8 @@ #include "services/service_manager/public/cpp/connector.h" #include "ui/message_center/message_center.h" #include "ui/message_center/notification_blocker.h" +#include "ui/message_center/public/cpp/notification.h" +#include "ui/message_center/public/cpp/notifier_id.h" #include "ui/message_center/views/message_view_factory.h" namespace ash { @@ -26,7 +30,10 @@ const message_center::Notification& notification) { DCHECK_EQ(kMediaSessionNotificationCustomViewType, notification.custom_view_type()); - return std::make_unique<MediaNotificationView>(notification); + auto* controller = Shell::Get()->media_notification_controller(); + if (controller) + return controller->CreateMediaNotification(notification); + return nullptr; } // The maximum number of media notifications to count when recording the @@ -95,10 +102,10 @@ } // namespace // static -const char MediaNotificationController::kCountHistogramName[] = +const char MediaNotificationControllerImpl::kCountHistogramName[] = "Media.Notification.Count"; -MediaNotificationController::MediaNotificationController( +MediaNotificationControllerImpl::MediaNotificationControllerImpl( service_manager::Connector* connector) : blocker_(std::make_unique<MediaNotificationBlocker>( message_center::MessageCenter::Get(), @@ -125,9 +132,9 @@ audio_focus_ptr->AddObserver(std::move(audio_focus_observer)); } -MediaNotificationController::~MediaNotificationController() = default; +MediaNotificationControllerImpl::~MediaNotificationControllerImpl() = default; -void MediaNotificationController::OnFocusGained( +void MediaNotificationControllerImpl::OnFocusGained( media_session::mojom::AudioFocusRequestStatePtr session) { const std::string id = session->request_id->ToString(); @@ -145,25 +152,60 @@ notifications_.emplace( std::piecewise_construct, std::forward_as_tuple(id), - std::forward_as_tuple(id, session->source_name.value_or(std::string()), - std::move(controller), - std::move(session->session_info))); + std::forward_as_tuple( + this, id, session->source_name.value_or(std::string()), + std::move(controller), std::move(session->session_info))); } -void MediaNotificationController::OnFocusLost( +void MediaNotificationControllerImpl::OnFocusLost( media_session::mojom::AudioFocusRequestStatePtr session) { notifications_.erase(session->request_id->ToString()); } -void MediaNotificationController::SetView(const std::string& id, - MediaNotificationView* view) { - auto it = notifications_.find(id); - if (it == notifications_.end()) +void MediaNotificationControllerImpl::ShowNotification(const std::string& id) { + // If a notification already exists, do nothing. + if (message_center::MessageCenter::Get()->FindVisibleNotificationById(id)) return; - it->second.SetView(view); + + std::unique_ptr<message_center::Notification> notification = + ash::CreateSystemNotification( + message_center::NotificationType::NOTIFICATION_TYPE_CUSTOM, id, + base::string16(), base::string16(), base::string16(), GURL(), + message_center::NotifierId( + message_center::NotifierType::SYSTEM_COMPONENT, + kMediaSessionNotifierId), + message_center::RichNotificationData(), nullptr, gfx::VectorIcon(), + message_center::SystemNotificationWarningLevel::NORMAL); + + // Set the priority to low to prevent the notification showing as a popup and + // keep it at the bottom of the list. + notification->set_priority(message_center::LOW_PRIORITY); + + notification->set_custom_view_type(kMediaSessionNotificationCustomViewType); + + message_center::MessageCenter::Get()->AddNotification( + std::move(notification)); + + RecordConcurrentNotificationCount(); } -void MediaNotificationController::RecordConcurrentNotificationCount() { +void MediaNotificationControllerImpl::HideNotification(const std::string& id) { + message_center::MessageCenter::Get()->RemoveNotification(id, false); +} + +std::unique_ptr<MediaNotificationView> +MediaNotificationControllerImpl::CreateMediaNotification( + const message_center::Notification& notification) { + base::WeakPtr<MediaNotificationItem> item; + + auto it = notifications_.find(notification.id()); + if (it != notifications_.end()) + item = it->second.GetWeakPtr(); + + return std::make_unique<MediaNotificationView>(notification, std::move(item)); +} + +void MediaNotificationControllerImpl::RecordConcurrentNotificationCount() { UMA_HISTOGRAM_EXACT_LINEAR( kCountHistogramName, message_center::MessageCenter::Get()
diff --git a/ash/media/media_notification_controller_impl.h b/ash/media/media_notification_controller_impl.h new file mode 100644 index 0000000..85a3d84 --- /dev/null +++ b/ash/media/media_notification_controller_impl.h
@@ -0,0 +1,91 @@ +// Copyright 2018 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 ASH_MEDIA_MEDIA_NOTIFICATION_CONTROLLER_IMPL_H_ +#define ASH_MEDIA_MEDIA_NOTIFICATION_CONTROLLER_IMPL_H_ + +#include <map> +#include <memory> +#include <string> + +#include "ash/ash_export.h" +#include "ash/media/media_notification_controller.h" +#include "ash/media/media_notification_item.h" +#include "base/macros.h" +#include "mojo/public/cpp/bindings/binding.h" +#include "services/media_session/public/mojom/audio_focus.mojom.h" +#include "services/media_session/public/mojom/media_controller.mojom.h" + +namespace service_manager { +class Connector; +} // namespace service_manager + +namespace message_center { +class Notification; +} // namespace message_center + +namespace ash { + +namespace { +class MediaNotificationBlocker; +} // namespace + +class MediaNotificationView; + +// MediaNotificationControllerImpl will show/hide media notifications when media +// sessions are active. These notifications will show metadata and playback +// controls. +class ASH_EXPORT MediaNotificationControllerImpl + : public media_session::mojom::AudioFocusObserver, + public MediaNotificationController { + public: + // The name of the histogram used to record the number of concurrent media + // notifications. + static const char kCountHistogramName[]; + + explicit MediaNotificationControllerImpl( + service_manager::Connector* connector); + ~MediaNotificationControllerImpl() override; + + // media_session::mojom::AudioFocusObserver: + void OnFocusGained( + media_session::mojom::AudioFocusRequestStatePtr session) override; + void OnFocusLost( + media_session::mojom::AudioFocusRequestStatePtr session) override; + + // MediaNotificationController: + void ShowNotification(const std::string& id) override; + void HideNotification(const std::string& id) override; + + std::unique_ptr<MediaNotificationView> CreateMediaNotification( + const message_center::Notification& notification); + + ash::MediaNotificationItem* GetItem(const std::string& id) { + auto it = notifications_.find(id); + DCHECK(it != notifications_.end()); + return &it->second; + } + + private: + // Called when we display a new media notification. It will record the + // concurrent number of media notifications displayed. + void RecordConcurrentNotificationCount(); + + media_session::mojom::MediaControllerManagerPtr controller_manager_ptr_; + + mojo::Binding<media_session::mojom::AudioFocusObserver> + audio_focus_observer_binding_{this}; + + // Stores a |MediaNotificationItem| for each media session keyed by its + // |request_id| in string format. + std::map<const std::string, MediaNotificationItem> notifications_; + + std::unique_ptr<MediaNotificationBlocker> blocker_; + + DISALLOW_COPY_AND_ASSIGN(MediaNotificationControllerImpl); +}; + +} // namespace ash + +#endif // ASH_MEDIA_MEDIA_NOTIFICATION_CONTROLLER_IMPL_H_
diff --git a/ash/media/media_notification_controller_unittest.cc b/ash/media/media_notification_controller_impl_unittest.cc similarity index 89% rename from ash/media/media_notification_controller_unittest.cc rename to ash/media/media_notification_controller_impl_unittest.cc index d4b924f..95ad4c8 100644 --- a/ash/media/media_notification_controller_unittest.cc +++ b/ash/media/media_notification_controller_impl_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/media/media_notification_controller.h" +#include "ash/media/media_notification_controller_impl.h" #include <memory> @@ -44,10 +44,10 @@ } // namespace -class MediaNotificationControllerTest : public AshTestBase { +class MediaNotificationControllerImplTest : public AshTestBase { public: - MediaNotificationControllerTest() = default; - ~MediaNotificationControllerTest() override = default; + MediaNotificationControllerImplTest() = default; + ~MediaNotificationControllerImplTest() override = default; // AshTestBase void SetUp() override { @@ -77,7 +77,7 @@ void ExpectHistogramCountRecorded(int count, int size) { histogram_tester_.ExpectBucketCount( - MediaNotificationController::kCountHistogramName, count, size); + MediaNotificationControllerImpl::kCountHistogramName, count, size); } void ExpectHistogramSourceRecorded(MediaNotificationItem::Source source) { @@ -98,12 +98,12 @@ base::HistogramTester histogram_tester_; - DISALLOW_COPY_AND_ASSIGN(MediaNotificationControllerTest); + DISALLOW_COPY_AND_ASSIGN(MediaNotificationControllerImplTest); }; // Test toggling the notification multiple times with the same ID. Since the // notification is keyed by ID we should only ever show one. -TEST_F(MediaNotificationControllerTest, OnFocusGainedLost_SameId) { +TEST_F(MediaNotificationControllerImplTest, OnFocusGainedLost_SameId) { base::UnguessableToken id = base::UnguessableToken::Create(); ExpectNotificationCount(0); @@ -133,7 +133,7 @@ // Test toggling the notification multiple times with different IDs. This should // show one notification per ID. -TEST_F(MediaNotificationControllerTest, OnFocusGainedLost_MultipleIds) { +TEST_F(MediaNotificationControllerImplTest, OnFocusGainedLost_MultipleIds) { base::UnguessableToken id1 = base::UnguessableToken::Create(); base::UnguessableToken id2 = base::UnguessableToken::Create(); @@ -169,8 +169,9 @@ } // Test that a notification is hidden when it becomes uncontrollable. We still -// keep the MediaNotificationItem around in case it becomes controllable again. -TEST_F(MediaNotificationControllerTest, +// keep the MediaNotificationItem around in case it becomes +// controllable again. +TEST_F(MediaNotificationControllerImplTest, OnFocusGained_ControllableBecomesUncontrollable) { base::UnguessableToken id = base::UnguessableToken::Create(); @@ -196,7 +197,7 @@ } // Test that a notification is shown when it becomes controllable. -TEST_F(MediaNotificationControllerTest, +TEST_F(MediaNotificationControllerImplTest, OnFocusGained_NotControllableBecomesControllable) { base::UnguessableToken id = base::UnguessableToken::Create(); @@ -225,7 +226,7 @@ } // Test hiding a notification with an invalid ID. -TEST_F(MediaNotificationControllerTest, OnFocusLost_Noop) { +TEST_F(MediaNotificationControllerImplTest, OnFocusLost_Noop) { ExpectNotificationCount(0); Shell::Get()->media_notification_controller()->OnFocusLost( @@ -235,7 +236,7 @@ } // Test that media notifications have the correct custom view type. -TEST_F(MediaNotificationControllerTest, NotificationHasCustomViewType) { +TEST_F(MediaNotificationControllerImplTest, NotificationHasCustomViewType) { ExpectNotificationCount(0); base::UnguessableToken id = base::UnguessableToken::Create(); @@ -262,7 +263,7 @@ // Test that if we recieve a null media session info that we hide the // notification. -TEST_F(MediaNotificationControllerTest, HandleNullMediaSessionInfo) { +TEST_F(MediaNotificationControllerImplTest, HandleNullMediaSessionInfo) { ExpectNotificationCount(0); base::UnguessableToken id = base::UnguessableToken::Create(); @@ -286,7 +287,7 @@ ExpectNotificationCount(0); } -TEST_F(MediaNotificationControllerTest, MediaMetadata_NoArtist) { +TEST_F(MediaNotificationControllerImplTest, MediaMetadata_NoArtist) { base::UnguessableToken id = base::UnguessableToken::Create(); ExpectNotificationCount(0); @@ -305,7 +306,7 @@ ExpectNotificationCount(0); } -TEST_F(MediaNotificationControllerTest, MediaMetadata_NoTitle) { +TEST_F(MediaNotificationControllerImplTest, MediaMetadata_NoTitle) { base::UnguessableToken id = base::UnguessableToken::Create(); ExpectNotificationCount(0); @@ -324,7 +325,7 @@ ExpectNotificationCount(0); } -TEST_F(MediaNotificationControllerTest, MediaMetadataUpdated_MissingInfo) { +TEST_F(MediaNotificationControllerImplTest, MediaMetadataUpdated_MissingInfo) { base::UnguessableToken id = base::UnguessableToken::Create(); ExpectNotificationCount(0); @@ -348,7 +349,7 @@ ExpectNotificationCount(0); } -TEST_F(MediaNotificationControllerTest, RecordHistogramSource_Unknown) { +TEST_F(MediaNotificationControllerImplTest, RecordHistogramSource_Unknown) { base::UnguessableToken id = base::UnguessableToken::Create(); ExpectNotificationCount(0); @@ -365,7 +366,7 @@ ExpectHistogramSourceRecorded(MediaNotificationItem::Source::kUnknown); } -TEST_F(MediaNotificationControllerTest, RecordHistogramSource_Web) { +TEST_F(MediaNotificationControllerImplTest, RecordHistogramSource_Web) { base::UnguessableToken id = base::UnguessableToken::Create(); ExpectNotificationCount(0); @@ -386,7 +387,7 @@ ExpectHistogramSourceRecorded(MediaNotificationItem::Source::kWeb); } -TEST_F(MediaNotificationControllerTest, RecordHistogramSource_Assistant) { +TEST_F(MediaNotificationControllerImplTest, RecordHistogramSource_Assistant) { base::UnguessableToken id = base::UnguessableToken::Create(); ExpectNotificationCount(0); @@ -407,7 +408,7 @@ ExpectHistogramSourceRecorded(MediaNotificationItem::Source::kAssistant); } -TEST_F(MediaNotificationControllerTest, RecordHistogramSource_Arc) { +TEST_F(MediaNotificationControllerImplTest, RecordHistogramSource_Arc) { base::UnguessableToken id = base::UnguessableToken::Create(); ExpectNotificationCount(0); @@ -430,7 +431,7 @@ // Test that locking the screen will hide the media notifications. Unlocking the // screen should re-show the notifications. -TEST_F(MediaNotificationControllerTest, HideWhenScreenLocked) { +TEST_F(MediaNotificationControllerImplTest, HideWhenScreenLocked) { message_center::MessageCenter* message_center = message_center::MessageCenter::Get();
diff --git a/ash/media/media_notification_item.cc b/ash/media/media_notification_item.cc index b186114..810be2df 100644 --- a/ash/media/media_notification_item.cc +++ b/ash/media/media_notification_item.cc
@@ -7,22 +7,14 @@ #include "ash/media/media_notification_constants.h" #include "ash/media/media_notification_controller.h" #include "ash/media/media_notification_view.h" -#include "ash/public/cpp/notification_utils.h" -#include "ash/shell.h" #include "base/bind.h" #include "base/metrics/histogram_macros.h" -#include "base/strings/string16.h" #include "base/time/time.h" #include "services/media_session/public/mojom/constants.mojom.h" #include "services/media_session/public/mojom/media_controller.mojom.h" #include "services/media_session/public/mojom/media_session.mojom.h" #include "ui/gfx/image/image.h" -#include "ui/message_center/message_center.h" #include "ui/message_center/public/cpp/message_center_constants.h" -#include "ui/message_center/public/cpp/notification.h" -#include "ui/message_center/public/cpp/notification_delegate.h" -#include "ui/message_center/public/cpp/notifier_id.h" -#include "url/gurl.h" namespace ash { @@ -57,14 +49,18 @@ "Media.Notification.UserAction"; MediaNotificationItem::MediaNotificationItem( - const std::string& id, + MediaNotificationController* notification_controller, + const std::string& request_id, const std::string& source_name, media_session::mojom::MediaControllerPtr controller, media_session::mojom::MediaSessionInfoPtr session_info) - : id_(id), + : controller_(notification_controller), + request_id_(request_id), source_(GetSource(source_name)), media_controller_ptr_(std::move(controller)), session_info_(std::move(session_info)) { + DCHECK(controller_); + if (media_controller_ptr_.is_bound()) { // Bind an observer to the associated media controller. media_session::mojom::MediaControllerObserverPtr media_controller_observer; @@ -93,7 +89,7 @@ } MediaNotificationItem::~MediaNotificationItem() { - HideNotification(); + controller_->HideNotification(request_id_); } void MediaNotificationItem::MediaSessionInfoChanged( @@ -110,10 +106,19 @@ const base::Optional<media_session::MediaMetadata>& metadata) { session_metadata_ = metadata.value_or(media_session::MediaMetadata()); + view_needs_metadata_update_ = true; + MaybeHideOrShowNotification(); - if (view_) + // |MaybeHideOrShowNotification()| can synchronously create a + // MediaNotificationView that calls |SetView()|. If that happens, then we + // don't want to call |view_->UpdateWithMediaMetadata()| below since |view_| + // will have already received the metadata when calling |SetView()|. + // |view_needs_metadata_update_| is set to false in |SetView()|. + if (view_ && view_needs_metadata_update_) view_->UpdateWithMediaMetadata(session_metadata_); + + view_needs_metadata_update_ = false; } void MediaNotificationItem::MediaSessionActionsChanged( @@ -150,6 +155,7 @@ view_ = view; if (view) { + view_needs_metadata_update_ = false; view_->UpdateWithMediaSessionInfo(session_info_); view_->UpdateWithMediaMetadata(session_metadata_); view_->UpdateWithMediaActions(session_actions_); @@ -167,61 +173,28 @@ // If the |is_controllable| bit is set in MediaSessionInfo then we should show // a media notification. if (!session_info_ || !session_info_->is_controllable) { - HideNotification(); + controller_->HideNotification(request_id_); return; } // If we do not have a title and an artist then we should hide the // notification. if (session_metadata_.title.empty() || session_metadata_.artist.empty()) { - HideNotification(); + controller_->HideNotification(request_id_); return; } - if (message_center::MessageCenter::Get()->FindVisibleNotificationById(id_)) + // If we have an existing view, then we don't need to create a new one. + if (view_) return; - std::unique_ptr<message_center::Notification> notification = - ash::CreateSystemNotification( - message_center::NotificationType::NOTIFICATION_TYPE_CUSTOM, id_, - base::string16(), base::string16(), base::string16(), GURL(), - message_center::NotifierId( - message_center::NotifierType::SYSTEM_COMPONENT, - kMediaSessionNotifierId), - message_center::RichNotificationData(), - base::MakeRefCounted<message_center::HandleNotificationClickDelegate>( - base::BindRepeating(&MediaNotificationItem::OnNotificationClicked, - weak_ptr_factory_.GetWeakPtr())), - gfx::VectorIcon(), - message_center::SystemNotificationWarningLevel::NORMAL); - - // Set the priority to low to prevent the notification showing as a popup and - // keep it at the bottom of the list. - notification->set_priority(message_center::LOW_PRIORITY); - - notification->set_custom_view_type(kMediaSessionNotificationCustomViewType); - - message_center::MessageCenter::Get()->AddNotification( - std::move(notification)); - - Shell::Get() - ->media_notification_controller() - ->RecordConcurrentNotificationCount(); + controller_->ShowNotification(request_id_); UMA_HISTOGRAM_ENUMERATION(kSourceHistogramName, source_); } -void MediaNotificationItem::HideNotification() { - message_center::MessageCenter::Get()->RemoveNotification(id_, false); -} - -void MediaNotificationItem::OnNotificationClicked( - base::Optional<int> button_id) { - if (!button_id) - return; - - const MediaSessionAction action = static_cast<MediaSessionAction>(*button_id); - +void MediaNotificationItem::OnMediaSessionActionButtonPressed( + MediaSessionAction action) { UMA_HISTOGRAM_ENUMERATION(kUserActionHistogramName, action); switch (action) {
diff --git a/ash/media/media_notification_item.h b/ash/media/media_notification_item.h index 6ca10b7..c5d461b9 100644 --- a/ash/media/media_notification_item.h +++ b/ash/media/media_notification_item.h
@@ -19,6 +19,7 @@ namespace ash { +class MediaNotificationController; class MediaNotificationView; // MediaNotificationItem manages hiding/showing a media notification and @@ -43,7 +44,8 @@ kMaxValue = kArc, }; - MediaNotificationItem(const std::string& id, + MediaNotificationItem(MediaNotificationController* notification_controller, + const std::string& request_id, const std::string& source_name, media_session::mojom::MediaControllerPtr controller, media_session::mojom::MediaSessionInfoPtr session_info); @@ -65,8 +67,16 @@ media_session::mojom::MediaSessionImageType type, const SkBitmap& bitmap) override; + // Called by MediaNotificationView when created or destroyed. void SetView(MediaNotificationView* view); + void OnMediaSessionActionButtonPressed( + media_session::mojom::MediaSessionAction action); + + base::WeakPtr<MediaNotificationItem> GetWeakPtr() { + return weak_ptr_factory_.GetWeakPtr(); + } + void FlushForTesting(); void SetMediaControllerForTesting( @@ -79,15 +89,14 @@ void HideNotification(); + MediaNotificationController* controller_; + // Weak reference to the view of the currently shown media notification. MediaNotificationView* view_ = nullptr; - void OnNotificationClicked(base::Optional<int> button_id); - - // The id is the |request_id| of the media session and is guaranteed to be - // globally unique. It is also used as the id of the notification for this - // media session. - const std::string id_; + // The |request_id_| is the request id of the media session and is guaranteed + // to be globally unique. + const std::string request_id_; // The source of the media session (e.g. arc, web). const Source source_; @@ -104,6 +113,10 @@ gfx::ImageSkia session_icon_; + // True if the metadata needs to be updated on |view_|. Used to prevent + // updating |view_|'s metadata twice on a single change. + bool view_needs_metadata_update_ = false; + mojo::Binding<media_session::mojom::MediaControllerObserver> observer_binding_{this};
diff --git a/ash/media/media_notification_view.cc b/ash/media/media_notification_view.cc index 0187e8e..e43b827 100644 --- a/ash/media/media_notification_view.cc +++ b/ash/media/media_notification_view.cc
@@ -6,7 +6,7 @@ #include "ash/media/media_notification_background.h" #include "ash/media/media_notification_constants.h" -#include "ash/media/media_notification_controller.h" +#include "ash/media/media_notification_item.h" #include "ash/shell.h" #include "ash/strings/grit/ash_strings.h" #include "base/metrics/histogram_macros.h" @@ -108,8 +108,9 @@ "Media.Notification.MetadataPresent"; MediaNotificationView::MediaNotificationView( - const message_center::Notification& notification) - : message_center::MessageView(notification) { + const message_center::Notification& notification, + base::WeakPtr<MediaNotificationItem> item) + : message_center::MessageView(notification), item_(std::move(item)) { SetLayoutManager(std::make_unique<views::BoxLayout>( views::BoxLayout::kVertical, gfx::Insets(), 0)); @@ -209,13 +210,13 @@ message_center::kNotificationCornerRadius); UpdateViewForExpandedState(); - Shell::Get()->media_notification_controller()->SetView(notification_id(), - this); + if (item_) + item_->SetView(this); } MediaNotificationView::~MediaNotificationView() { - Shell::Get()->media_notification_controller()->SetView(notification_id(), - nullptr); + if (item_) + item_->SetView(nullptr); } void MediaNotificationView::UpdateWithNotification( @@ -284,8 +285,10 @@ } if (sender->parent() == button_row_) { - message_center::MessageCenter::Get()->ClickOnNotificationButton( - notification_id(), sender->tag()); + if (item_) { + item_->OnMediaSessionActionButtonPressed( + static_cast<MediaSessionAction>(sender->tag())); + } return; }
diff --git a/ash/media/media_notification_view.h b/ash/media/media_notification_view.h index ab1b4bb0..b793fcac 100644 --- a/ash/media/media_notification_view.h +++ b/ash/media/media_notification_view.h
@@ -6,6 +6,7 @@ #define ASH_MEDIA_MEDIA_NOTIFICATION_VIEW_H_ #include "ash/ash_export.h" +#include "base/memory/weak_ptr.h" #include "services/media_session/public/mojom/media_session.mojom.h" #include "ui/message_center/views/message_view.h" #include "ui/views/controls/button/button.h" @@ -18,9 +19,6 @@ namespace media_session { struct MediaMetadata; -} // namespace media_session - -namespace media_session { enum class MediaSessionAction; } // namespace media_session @@ -37,6 +35,7 @@ namespace ash { class MediaNotificationBackground; +class MediaNotificationItem; // MediaNotificationView will show up as a custom notification. It will show the // currently playing media and provide playback controls. There will also be @@ -63,8 +62,8 @@ kMaxValue = kCount, }; - explicit MediaNotificationView( - const message_center::Notification& notification); + MediaNotificationView(const message_center::Notification& notification, + base::WeakPtr<MediaNotificationItem> item); ~MediaNotificationView() override; // message_center::MessageView: @@ -115,6 +114,8 @@ void UpdateForegroundColor(); + base::WeakPtr<MediaNotificationItem> item_; + // View containing close and settings buttons. std::unique_ptr<message_center::NotificationControlButtonsView> control_buttons_view_;
diff --git a/ash/media/media_notification_view_unittest.cc b/ash/media/media_notification_view_unittest.cc index 15d05b4..f41b17b1c 100644 --- a/ash/media/media_notification_view_unittest.cc +++ b/ash/media/media_notification_view_unittest.cc
@@ -9,7 +9,7 @@ #include "ash/focus_cycler.h" #include "ash/media/media_notification_background.h" #include "ash/media/media_notification_constants.h" -#include "ash/media/media_notification_controller.h" +#include "ash/media/media_notification_controller_impl.h" #include "ash/media/media_notification_item.h" #include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/shell_window_ids.h" @@ -262,7 +262,8 @@ private: std::unique_ptr<message_center::MessageView> CreateAndCaptureCustomView( const message_center::Notification& notification) { - auto view = std::make_unique<MediaNotificationView>(notification); + auto view = std::make_unique<MediaNotificationView>( + notification, GetItem()->GetWeakPtr()); view_ = view.get(); return view; }
diff --git a/ash/mojo_interface_factory.cc b/ash/mojo_interface_factory.cc index 00e4f175..dc54cfc8 100644 --- a/ash/mojo_interface_factory.cc +++ b/ash/mojo_interface_factory.cc
@@ -47,7 +47,6 @@ #include "base/lazy_instance.h" #include "base/single_thread_task_runner.h" #include "chromeos/constants/chromeos_switches.h" -#include "services/ws/common/switches.h" namespace ash { namespace mojo_interface_factory { @@ -328,7 +327,7 @@ main_thread_task_runner); if (base::CommandLine::ForCurrentProcess()->HasSwitch( - ws::switches::kUseTestConfig)) { + switches::kAshEnableTestInterfaces)) { registry->AddInterface( base::BindRepeating(&BindShelfIntegrationTestApiRequestOnMainThread), main_thread_task_runner);
diff --git a/ash/public/cpp/BUILD.gn b/ash/public/cpp/BUILD.gn index a0df3b7..f89bfac0 100644 --- a/ash/public/cpp/BUILD.gn +++ b/ash/public/cpp/BUILD.gn
@@ -86,8 +86,6 @@ "lock_screen_widget_factory.cc", "lock_screen_widget_factory.h", "login_constants.h", - "menu_utils.cc", - "menu_utils.h", "network_icon_image_source.cc", "network_icon_image_source.h", "notification_utils.cc", @@ -243,7 +241,6 @@ testonly = true sources = [ "default_scale_factor_retriever_unittest.cc", - "menu_utils_unittest.cc", "pagination/pagination_model_unittest.cc", "power_utils_unittest.cc", "rounded_corner_decorator_unittest.cc",
diff --git a/ash/public/cpp/app_list/app_list_client.h b/ash/public/cpp/app_list/app_list_client.h index 0f23e71..db76d5d1b 100644 --- a/ash/public/cpp/app_list/app_list_client.h +++ b/ash/public/cpp/app_list/app_list_client.h
@@ -12,12 +12,10 @@ #include "ash/public/cpp/ash_public_export.h" #include "ash/public/interfaces/app_list.mojom.h" -// TODO(crbug.com/958208): Remove menu.mojom.h -#include "ash/public/interfaces/menu.mojom.h" #include "base/callback_forward.h" #include "base/strings/string16.h" #include "components/sync/model/string_ordinal.h" -#include "ui/base/models/menu_model.h" +#include "ui/base/models/simple_menu_model.h" namespace app_list { @@ -64,7 +62,7 @@ // Returns the context menu model for the search result with |result_id|, or // an empty array if there is currently no menu for the result. using GetSearchResultContextMenuModelCallback = - base::OnceCallback<void(std::vector<::ash::mojom::MenuItemPtr>)>; + base::OnceCallback<void(std::unique_ptr<ui::SimpleMenuModel>)>; virtual void GetSearchResultContextMenuModel( const std::string& result_id, GetSearchResultContextMenuModelCallback callback) = 0; @@ -98,7 +96,7 @@ // Returns the context menu model for the item with |id|, or an empty array if // there is currently no menu for the item (e.g. during install). using GetContextMenuModelCallback = - base::OnceCallback<void(std::vector<::ash::mojom::MenuItemPtr>)>; + base::OnceCallback<void(std::unique_ptr<ui::SimpleMenuModel>)>; virtual void GetContextMenuModel(int profile_id, const std::string& id, GetContextMenuModelCallback callback) = 0;
diff --git a/ash/public/cpp/ash_switches.cc b/ash/public/cpp/ash_switches.cc index 61e56bb..efe2ea7f 100644 --- a/ash/public/cpp/ash_switches.cc +++ b/ash/public/cpp/ash_switches.cc
@@ -47,6 +47,15 @@ // enter tablet mode. const char kAshEnableTabletMode[] = "enable-touchview"; +// Used to expose additional test-only interfaces. +// Historical note: this name was originally used by the window-service to +// enable additional test only interfaces, which also enabled test functionality +// in ash. While the window-service is no more, autotest lives on. The string +// value matches that used by the window-service. +// TODO(crbug.com/958247): this is only necessary because of +// ShelfIntegrationTestApi, that likely can be removed. +const char kAshEnableTestInterfaces[] = "use-test-config"; + // Enable the wayland server. const char kAshEnableWaylandServer[] = "enable-wayland-server";
diff --git a/ash/public/cpp/ash_switches.h b/ash/public/cpp/ash_switches.h index 0a4984b..f373a06d 100644 --- a/ash/public/cpp/ash_switches.h +++ b/ash/public/cpp/ash_switches.h
@@ -25,6 +25,7 @@ ASH_PUBLIC_EXPORT extern const char kAshEnableMagnifierKeyScroller[]; ASH_PUBLIC_EXPORT extern const char kAshEnablePaletteOnAllDisplays[]; ASH_PUBLIC_EXPORT extern const char kAshEnableTabletMode[]; +ASH_PUBLIC_EXPORT extern const char kAshEnableTestInterfaces[]; ASH_PUBLIC_EXPORT extern const char kAshEnableWaylandServer[]; ASH_PUBLIC_EXPORT extern const char kAshForceEnableStylusTools[]; ASH_PUBLIC_EXPORT extern const char kAshPowerButtonPosition[];
diff --git a/ash/public/cpp/menu_utils.cc b/ash/public/cpp/menu_utils.cc deleted file mode 100644 index e06cc16..0000000 --- a/ash/public/cpp/menu_utils.cc +++ /dev/null
@@ -1,111 +0,0 @@ -// Copyright 2018 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 "ash/public/cpp/menu_utils.h" - -#include <memory> -#include <utility> - -#include "base/no_destructor.h" -#include "ui/gfx/image/image.h" - -namespace ash { -namespace menu_utils { - -MenuItemList GetMojoMenuItemsFromModel(ui::MenuModel* model) { - MenuItemList items; - if (!model) - return items; - for (int i = 0; i < model->GetItemCount(); ++i) { - mojom::MenuItemPtr item(mojom::MenuItem::New()); - DCHECK_NE(ui::MenuModel::TYPE_BUTTON_ITEM, model->GetTypeAt(i)); - item->type = model->GetTypeAt(i); - item->command_id = model->GetCommandIdAt(i); - item->label = model->GetLabelAt(i); - item->checked = model->IsItemCheckedAt(i); - item->enabled = model->IsEnabledAt(i); - item->radio_group_id = model->GetGroupIdAt(i); - if (item->type == ui::MenuModel::TYPE_SUBMENU || - item->type == ui::MenuModel::TYPE_ACTIONABLE_SUBMENU) { - item->submenu = GetMojoMenuItemsFromModel(model->GetSubmenuModelAt(i)); - } - item->separator_type = model->GetSeparatorTypeAt(i); - gfx::Image icon; - if (model->GetIconAt(i, &icon)) - item->image = icon.AsImageSkia(); - items.push_back(std::move(item)); - } - return items; -} - -void PopulateMenuFromMojoMenuItems(ui::SimpleMenuModel* model, - ui::SimpleMenuModel::Delegate* delegate, - const MenuItemList& items, - SubmenuList* submenus) { - for (const mojom::MenuItemPtr& item : items) { - switch (item->type) { - case ui::MenuModel::TYPE_COMMAND: - model->AddItem(item->command_id, item->label); - break; - case ui::MenuModel::TYPE_CHECK: - model->AddCheckItem(item->command_id, item->label); - break; - case ui::MenuModel::TYPE_RADIO: - model->AddRadioItem(item->command_id, item->label, - item->radio_group_id); - break; - case ui::MenuModel::TYPE_SEPARATOR: - model->AddSeparator(item->separator_type); - break; - case ui::MenuModel::TYPE_BUTTON_ITEM: - NOTREACHED() << "TYPE_BUTTON_ITEM is not yet supported."; - break; - case ui::MenuModel::TYPE_SUBMENU: - case ui::MenuModel::TYPE_ACTIONABLE_SUBMENU: - if (item->submenu.has_value()) { - std::unique_ptr<ui::SimpleMenuModel> submenu = - std::make_unique<ui::SimpleMenuModel>(delegate); - PopulateMenuFromMojoMenuItems(submenu.get(), delegate, - item->submenu.value(), submenus); - if (item->type == ui::MenuModel::TYPE_SUBMENU) { - model->AddSubMenu(item->command_id, item->label, submenu.get()); - } else { - model->AddActionableSubMenu(item->command_id, item->label, - submenu.get()); - } - submenus->push_back(std::move(submenu)); - } - break; - case ui::MenuModel::TYPE_HIGHLIGHTED: - NOTREACHED() << "TYPE_HIGHLIGHTED is not yet supported."; - break; - } - if (!item->image.isNull()) { - model->SetIcon(model->GetIndexOfCommandId(item->command_id), - gfx::Image(item->image)); - } - } -} - -const mojom::MenuItemPtr& GetMenuItemByCommandId(const MenuItemList& items, - int command_id) { - static const base::NoDestructor<mojom::MenuItemPtr> item_not_found( - mojom::MenuItem::New()); - for (const mojom::MenuItemPtr& item : items) { - if (item->command_id == command_id) - return item; - if ((item->type == ui::MenuModel::TYPE_SUBMENU || - (item->type == ui::MenuModel::TYPE_ACTIONABLE_SUBMENU)) && - item->submenu.has_value()) { - const mojom::MenuItemPtr& submenu_item = - GetMenuItemByCommandId(item->submenu.value(), command_id); - if (submenu_item->command_id == command_id) - return submenu_item; - } - } - return *item_not_found; -} - -} // namespace menu_utils -} // namespace ash
diff --git a/ash/public/cpp/menu_utils.h b/ash/public/cpp/menu_utils.h deleted file mode 100644 index c1b1547..0000000 --- a/ash/public/cpp/menu_utils.h +++ /dev/null
@@ -1,42 +0,0 @@ -// Copyright 2018 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 ASH_PUBLIC_CPP_MENU_UTILS_H_ -#define ASH_PUBLIC_CPP_MENU_UTILS_H_ - -#include <memory> -#include <vector> - -#include "ash/public/cpp/ash_public_export.h" -#include "ash/public/interfaces/menu.mojom.h" -#include "ui/base/models/simple_menu_model.h" - -namespace ash { -namespace menu_utils { - -using MenuItemList = std::vector<mojom::MenuItemPtr>; -using SubmenuList = std::vector<std::unique_ptr<ui::MenuModel>>; - -// Gets a serialized list of mojo MenuItemPtr objects to transport a menu model. -// NOTE: This does not support button items, some separator types, sublabels, -// minor text, dynamic items, label fonts, accelerators, visibility, etc. -ASH_PUBLIC_EXPORT MenuItemList GetMojoMenuItemsFromModel(ui::MenuModel* model); - -// Populates a simple menu model with a list of mojo menu items. This can be -// considered as an inverse operation of |GetMojoMenuItemsFromModel|. -ASH_PUBLIC_EXPORT void PopulateMenuFromMojoMenuItems( - ui::SimpleMenuModel* model, - ui::SimpleMenuModel::Delegate* delegate, - const MenuItemList& items, - SubmenuList* submenus); - -// Finds a menu item by command id; returns a stub item if no match was found. -ASH_PUBLIC_EXPORT const mojom::MenuItemPtr& GetMenuItemByCommandId( - const MenuItemList& items, - int command_id); - -} // namespace menu_utils -} // namespace ash - -#endif // ASH_PUBLIC_CPP_MENU_UTILS_H_
diff --git a/ash/public/cpp/menu_utils_unittest.cc b/ash/public/cpp/menu_utils_unittest.cc deleted file mode 100644 index c818536..0000000 --- a/ash/public/cpp/menu_utils_unittest.cc +++ /dev/null
@@ -1,159 +0,0 @@ -// Copyright 2018 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 "ash/public/cpp/menu_utils.h" - -#include <utility> - -#include "base/logging.h" -#include "base/strings/utf_string_conversions.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/base/models/menu_model.h" -#include "ui/base/models/menu_separator_types.h" -#include "ui/base/models/simple_menu_model.h" - -using base::ASCIIToUTF16; - -namespace ash { -namespace menu_utils { - -using MenuModelList = std::vector<std::unique_ptr<ui::SimpleMenuModel>>; - -class MenuUtilsTest : public testing::Test, - public ui::SimpleMenuModel::Delegate { - public: - MenuUtilsTest() {} - ~MenuUtilsTest() override {} - - // testing::Test overrides: - void SetUp() override { - menu_model_ = std::make_unique<ui::SimpleMenuModel>(this); - } - - protected: - ui::SimpleMenuModel* root_menu() { return menu_model_.get(); } - MenuModelList* submenus() { return &submenu_models_; } - - ui::SimpleMenuModel* CreateSubmenu() { - std::unique_ptr<ui::SimpleMenuModel> submenu = - std::make_unique<ui::SimpleMenuModel>(this); - ui::SimpleMenuModel* submenu_ptr = submenu.get(); - submenu_models_.push_back(std::move(submenu)); - return submenu_ptr; - } - - bool IsCommandIdChecked(int command_id) const override { - // Assume that we have a checked item in every 3 items. - return command_id % 3 == 0; - } - - bool IsCommandIdEnabled(int command_id) const override { - // Assume that we have a enabled item in every 4 items. - return command_id % 4 == 0; - } - - void ExecuteCommand(int command_id, int event_flags) override {} - - void CheckMenuItemsMatched(const MenuItemList& mojo_menu, - const ui::MenuModel* menu) { - EXPECT_EQ(mojo_menu.size(), static_cast<size_t>(menu->GetItemCount())); - for (size_t i = 0; i < mojo_menu.size(); i++) { - VLOG(1) << "Checking item at " << i; - mojom::MenuItem* mojo_item = mojo_menu[i].get(); - EXPECT_EQ(mojo_item->type, menu->GetTypeAt(i)); - EXPECT_EQ(mojo_item->command_id, menu->GetCommandIdAt(i)); - EXPECT_EQ(mojo_item->label, menu->GetLabelAt(i)); - if (mojo_item->type == ui::MenuModel::TYPE_SUBMENU) { - VLOG(1) << "It's a submenu, let's do a recursion."; - CheckMenuItemsMatched(mojo_item->submenu.value(), - menu->GetSubmenuModelAt(i)); - continue; - } - EXPECT_EQ(mojo_item->enabled, menu->IsEnabledAt(i)); - EXPECT_EQ(mojo_item->checked, menu->IsItemCheckedAt(i)); - EXPECT_EQ(mojo_item->radio_group_id, menu->GetGroupIdAt(i)); - } - } - - private: - std::unique_ptr<ui::SimpleMenuModel> menu_model_; - MenuModelList submenu_models_; - - DISALLOW_COPY_AND_ASSIGN(MenuUtilsTest); -}; - -TEST_F(MenuUtilsTest, Basic) { - ui::SimpleMenuModel* menu = root_menu(); - - // Populates items into |menu| for testing. - int command_id = 0; - menu->AddItem(command_id++, ASCIIToUTF16("Item0")); - menu->AddItem(command_id++, ASCIIToUTF16("Item1")); - menu->AddSeparator(ui::NORMAL_SEPARATOR); - menu->AddCheckItem(command_id++, ASCIIToUTF16("CheckItem0")); - menu->AddCheckItem(command_id++, ASCIIToUTF16("CheckItem1")); - menu->AddRadioItem(command_id++, ASCIIToUTF16("RadioItem0"), - 0 /* group_id */); - menu->AddRadioItem(command_id++, ASCIIToUTF16("RadioItem1"), - 0 /* group_id */); - // Creates a submenu. - ui::SimpleMenuModel* submenu = CreateSubmenu(); - submenu->AddItem(command_id++, ASCIIToUTF16("SubMenu-Item0")); - submenu->AddItem(command_id++, ASCIIToUTF16("SubMenu-Item1")); - submenu->AddSeparator(ui::NORMAL_SEPARATOR); - submenu->AddCheckItem(command_id++, ASCIIToUTF16("SubMenu-CheckItem0")); - submenu->AddCheckItem(command_id++, ASCIIToUTF16("SubMenu-CheckItem1")); - submenu->AddRadioItem(command_id++, ASCIIToUTF16("SubMenu-RadioItem0"), - 1 /* group_id */); - submenu->AddRadioItem(command_id++, ASCIIToUTF16("SubMenu-RadioItem1"), - 1 /* group_id */); - menu->AddSubMenu(command_id++, ASCIIToUTF16("SubMenu"), submenu); - - // Converts the menu into mojo format. - MenuItemList mojo_menu_items = GetMojoMenuItemsFromModel(menu); - CheckMenuItemsMatched(mojo_menu_items, menu); - - // Converts backwards. - ui::SimpleMenuModel new_menu(this); - SubmenuList new_submenus; - PopulateMenuFromMojoMenuItems(&new_menu, this, mojo_menu_items, - &new_submenus); - CheckMenuItemsMatched(mojo_menu_items, &new_menu); - - // Tests |GetMenuItemByCommandId|. - for (int command_to_find = 0; command_to_find < command_id; - command_to_find++) { - // Gets the mojo item. - const mojom::MenuItemPtr& mojo_item = - GetMenuItemByCommandId(mojo_menu_items, command_to_find); - - // Gets the item index with this command from the original root menu. - int index = menu->GetIndexOfCommandId(command_to_find); - ui::MenuModel* menu_to_find = menu; - if (index < 0) { - // We cannot find it from the original root menu. Then it should be in the - // submenu. - index = submenu->GetIndexOfCommandId(command_to_find); - EXPECT_LE(0, index); - menu_to_find = submenu; - } - // Checks whether they match. - EXPECT_EQ(mojo_item->type, menu_to_find->GetTypeAt(index)); - EXPECT_EQ(mojo_item->command_id, menu_to_find->GetCommandIdAt(index)); - EXPECT_EQ(mojo_item->label, menu_to_find->GetLabelAt(index)); - EXPECT_EQ(mojo_item->enabled, menu_to_find->IsEnabledAt(index)); - EXPECT_EQ(mojo_item->checked, menu_to_find->IsItemCheckedAt(index)); - EXPECT_EQ(mojo_item->radio_group_id, menu_to_find->GetGroupIdAt(index)); - } - - // For unknown command ids, we'll get a singleton stub item. - const mojom::MenuItemPtr& item_not_found_1 = - GetMenuItemByCommandId(mojo_menu_items, command_id + 1); - const mojom::MenuItemPtr& item_not_found_2 = - GetMenuItemByCommandId(mojo_menu_items, command_id + 2); - EXPECT_EQ(item_not_found_1.get(), item_not_found_2.get()); -} - -} // namespace menu_utils -} // namespace ash
diff --git a/ash/public/interfaces/BUILD.gn b/ash/public/interfaces/BUILD.gn index e42f4996..856bb4b5 100644 --- a/ash/public/interfaces/BUILD.gn +++ b/ash/public/interfaces/BUILD.gn
@@ -41,7 +41,6 @@ "login_screen.mojom", "login_user_info.mojom", "media.mojom", - "menu.mojom", "new_window.mojom", "night_light_controller.mojom", "note_taking_controller.mojom",
diff --git a/ash/public/interfaces/menu.mojom b/ash/public/interfaces/menu.mojom deleted file mode 100644 index 0c444989..0000000 --- a/ash/public/interfaces/menu.mojom +++ /dev/null
@@ -1,74 +0,0 @@ -// Copyright 2018 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 ash.mojom; - -import "mojo/public/mojom/base/string16.mojom"; -import "ui/gfx/image/mojo/image.mojom"; - -// The types of menu items shown in shelf context and application list menus. -// These values roughly match ui::MenuModel::ItemType (sans TYPE_BUTTON_ITEM). -enum MenuItemType { - COMMAND, // Performs an action when selected. - CHECK, // Can be selected/checked to toggle a boolean state. - RADIO, // Can be selected/checked among a group of choices. - SEPARATOR, // Shows a horizontal line separator. - SUBMENU, // Presents a submenu within another menu. - ACTIONABLE_SUBMENU, // A SUBMENU that is also a COMMAND. -}; - -// For a separator we have the following types. -enum MenuSeparatorType { - // Normal - top to bottom: Spacing, line, spacing. - NORMAL_SEPARATOR = 0, - - // Double thickness - top to bottom: Spacing, line, spacing. - DOUBLE_SEPARATOR, - - // Upper - top to bottom: Line, spacing. - UPPER_SEPARATOR, - - // Lower - top to bottom: Spacing, line. - LOWER_SEPARATOR, - - // Spacing - top to bottom: Spacing only. - SPACING_SEPARATOR, - - // Vertical separator within a row. - VERTICAL_SEPARATOR, - - // Separator with left padding - top to bottom: Line only, - // horizontal: Starts after left padding. - PADDED_SEPARATOR, -}; - -// MenuItems are used to populate application menus for shelf items. -// Note: Some menu item types only support a subset of these item features. -// Please update comments below (MenuItemType -> [fields expected for usage]) -// when anything changed to MenuItemType or MenuItem. -// -// COMMAND -> [command_id, label, image, enabled, checked]. -// CHECK -> [command_id, label, image, enabled, checked]. -// RADIO -> [command_id, label, image, enabled, checked, radio_group_id]. -// SEPARATOR -> [separator_type]. -// SUBMENU -> [command_id, label, image, enabled, submenu]. -// ACTIONABLE_SUBMENU -> [command_id, label, image, enabled, submenu]. -// -struct MenuItem { - MenuItemType type; // The type of the menu item. - int32 command_id; // The client's arbitrary item command id. - mojo_base.mojom.String16 label; // The string label, may be empty. - gfx.mojom.ImageSkia? image; // The image icon, may be null. - array<MenuItem>? submenu; // The optional nested submenu item list. - bool enabled; // The enabled state. - bool checked; // The checked state. - int64 radio_group_id; // The radio group id. - MenuSeparatorType separator_type; // The separator type. -}; - -// An interface implemented by clients to handle interaction with menus run in -// Ash. -interface MenuDelegate { - MenuItemActivated(int32 command_id); -};
diff --git a/ash/public/interfaces/menu.typemap b/ash/public/interfaces/menu.typemap deleted file mode 100644 index 6f8b8eed..0000000 --- a/ash/public/interfaces/menu.typemap +++ /dev/null
@@ -1,18 +0,0 @@ -# Copyright 2018 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 = "//ash/public/interfaces/menu.mojom" -public_headers = [ - "//ui/base/models/menu_model.h", - "//ui/base/models/menu_separator_types.h", -] -traits_headers = [ "//ash/public/cpp/menu_struct_mojom_traits.h" ] -public_deps = [ - "//ui/base", - "//ui/gfx/image/mojo:struct_traits", -] -type_mappings = [ - "ash.mojom.MenuItemType=ui::MenuModel::ItemType", - "ash.mojom.MenuSeparatorType=ui::MenuSeparatorType", -]
diff --git a/ash/public/interfaces/shelf.mojom b/ash/public/interfaces/shelf.mojom deleted file mode 100644 index b048e03..0000000 --- a/ash/public/interfaces/shelf.mojom +++ /dev/null
@@ -1,147 +0,0 @@ -// Copyright 2016 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 ash.mojom; - -import "ash/public/interfaces/menu.mojom"; -import "mojo/public/mojom/base/string16.mojom"; -import "ui/events/mojo/event.mojom"; -import "ui/gfx/image/mojo/image.mojom"; - -// The actions that may be performed when a shelf item is selected. -// These values match ash::ShelfAction. -enum ShelfAction { - NONE, // No action was taken. - WINDOW_CREATED, // A new window was created. - WINDOW_ACTIVATED, // An existing inactive window was activated. - WINDOW_MINIMIZED, // The currently active window was minimized. - APP_LIST_SHOWN, // The app list launcher menu was shown. - APP_LIST_DISMISSED,// The app list launcher menu was dismissed. -}; - -// Represents the status of items in the shelf. -// These values match ash::ShelfItemStatus. -enum ShelfItemStatus { - CLOSED, // A closed shelf item, i.e. has no live instance. - RUNNING, // A shelf item that has live instance. - ATTENTION, // A shelf item that needs user's attention. -}; - -// The type of a shelf item. -// These values match ash::ShelfItemType. -enum ShelfItemType { - PINNED_APP, // A pinned app, which may be running or not. - APP_LIST, // An item that toggles visiblity of the app list. - BROWSER, // The browser shortcut, the browser may be running or not. - APP, // An unpinned running app window. Supports these app types: - // - Extension "V1" (legacy packaged and hosted) apps, - // - Extension "V2" (platform) apps, - // - ARC (App Runtime for Chrome - Android Play Store) apps. - DIALOG, // An open dialog. - BACK_BUTTON, // The back button, which is shown in tablet mode. - UNDEFINED, // Default value. -}; - -// Source of the launch or activation request, for tracking. -// These values match ash::ShelfLaunchSource. -enum ShelfLaunchSource { - UNKNOWN, // The item was launched from elsewhere. - APP_LIST, // The item was launched from a generic app list view. - APP_LIST_SEARCH, // The item was launched from an app list search view. - SHELF, // The item was launched from the shelf. -}; - -// The Shelf controller allows clients (eg. Chrome) to control the ash shelf. -interface ShelfController { - // Observers are immediately notified of the current shelf states when added. - AddObserver(associated ShelfObserver observer); - - // Note: ShelfObservers are not notified of ShelfModel changes made by the - // ShelfItem functions below. Chrome is the solitary ShelfObserver and client - // of these functions, so notifications would be cyclical and problematic. - - // Add |item| at |index|, which is clamped to be greater than 0 (AppList's - // index) and not exceeding the item count. Use a negative |index| to append. - AddShelfItem(int32 index, ShelfItem item); - // Remove the item with |id|. Bails if |id| is unknown or for the AppList. - RemoveShelfItem(ShelfID id); - // Moves item with |id| to |index|, which is in terms of the model after the - // item is removed, and is clamped to be greater than 0 (AppList's index) and - // not exceeding the item count. Bails if |id| is unknown or for the AppList. - MoveShelfItem(ShelfID id, int32 target_index); - // Updates |item| via ShelfID. Bails if the id is unknown or for the AppList. - // Clients may pass null images to signal no change and avoid transport costs. - UpdateShelfItem(ShelfItem item); - // Sets the |delegate| for the item with |id|. - SetShelfItemDelegate(ShelfID id, ShelfItemDelegate delegate); -}; - -// A Shelf observer, used to persist profile settings and cache a ShelfModel. -interface ShelfObserver { - // Called when the |item| has been added at |index|. - // This passes null images to avoid transport costs; clients don't use images. - OnShelfItemAdded(int32 index, ShelfItem item); - // Called when the item with |id| has been removed. - OnShelfItemRemoved(ShelfID id); - // Called when the item with |id| has been moved to |index|. - OnShelfItemMoved(ShelfID id, int32 index); - // Called when the |item| with matching ShelfID has been updated. - // This passes null images to avoid transport costs; clients don't use images. - OnShelfItemUpdated(ShelfItem item); - // Called when |delegate| for the item with |id| has been changed. - OnShelfItemDelegateChanged(ShelfID id, ShelfItemDelegate delegate); -}; - -// ShelfItemDelegate handles shelf item selection, menu command execution, etc. -interface ShelfItemDelegate { - // Called when the user selects a shelf item. The event, display, and source - // info should be provided if known; some implementations use these arguments. - // Defaults: (nullptr, kInvalidDisplayId, LAUNCH_FROM_UNKNOWN) - // The callback reports the action taken and any app menu items to show. - // - // NOTE: This codepath is not currently used for context menu triggering. - // TODO(crbug.com/691099): Remove |display_id| once panels are removed. - ItemSelected(ui.mojom.Event event, - int64 display_id, - ShelfLaunchSource source) => (ShelfAction action, - array<MenuItem>? menu_items); - - // Called when spawning a shelf item context menu, returns custom menu items. - // TODO(mash): Clients should push context menu items to Ash's shelf model. - GetContextMenuItems(int64 display_id) => (array<MenuItem> items); - - // Called on invocation of a shelf item's context or application menu command. - // |from_context_menu| is true if the command came from a context menu, or - // false if the command came from an application menu. If the |display_id| is - // unknown or irrelevant, callers may pass |display::kInvalidDisplayId|. - ExecuteCommand(bool from_context_menu, - int64 command_id, - int32 event_flags, - int64 display_id); - - // Closes all windows associated with this shelf item. - Close(); -}; - -// Identifier for shelf items and their windows. -// This structure matches ash::ShelfID. -struct ShelfID { - string app_id; // An app id string, used to match app windows. - // (eg. extension ids, arc ids, "AppList", etc.) - string launch_id; // A string used to support multiple items per app. - // (eg. Citrix may use 'Word' or 'Excel' launch ids) -}; - -// ShelfItems are used to populate the shelf. -// This structure matches ash::ShelfItem. -struct ShelfItem { - ShelfItemType type; // The type of the shelf item. - gfx.mojom.ImageSkia? image; // The icon shown on the shelf; null for updates - // with no icon change, null for ShelfObservers. - ShelfItemStatus status; // The running/closed/etc. status of the item. - ShelfID shelf_id; // The id for the shelf item and its windows. - mojo_base.mojom.String16 title; // The title to display for tooltips, etc. - bool pinned_by_policy; // Whether the item is pinned by policy prefs, - // the user cannot un-pin these items. -};
diff --git a/ash/public/interfaces/shelf.typemap b/ash/public/interfaces/shelf.typemap deleted file mode 100644 index e25b71e..0000000 --- a/ash/public/interfaces/shelf.typemap +++ /dev/null
@@ -1,25 +0,0 @@ -# Copyright 2016 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 = "//ash/public/interfaces/shelf.mojom" -public_headers = [ - "//ash/public/cpp/shelf_item.h", - "//ash/public/cpp/shelf_types.h", - "//ui/base/models/menu_model.h", -] -traits_headers = [ "//ash/public/cpp/shelf_struct_mojom_traits.h" ] -sources = [ - "//ash/public/cpp/shelf_struct_mojom_traits.cc", -] -public_deps = [ - "//ui/gfx/image/mojo:struct_traits", -] -type_mappings = [ - "ash.mojom.ShelfAction=ash::ShelfAction", - "ash.mojom.ShelfID=ash::ShelfID", - "ash.mojom.ShelfItem=ash::ShelfItem", - "ash.mojom.ShelfItemStatus=ash::ShelfItemStatus", - "ash.mojom.ShelfItemType=ash::ShelfItemType", - "ash.mojom.ShelfLaunchSource=ash::ShelfLaunchSource", -]
diff --git a/ash/public/interfaces/typemaps.gni b/ash/public/interfaces/typemaps.gni index c3c281d..a250f1c1 100644 --- a/ash/public/interfaces/typemaps.gni +++ b/ash/public/interfaces/typemaps.gni
@@ -4,8 +4,6 @@ typemaps = [ "//ash/public/interfaces/app_list.typemap", - "//ash/public/interfaces/menu.typemap", - "//ash/public/interfaces/shelf.typemap", "//ash/public/interfaces/shelf_integration_test_api.typemap", "//ash/public/interfaces/user_info.typemap", "//ash/public/interfaces/wallpaper.typemap",
diff --git a/ash/shell.cc b/ash/shell.cc index dcfdf0e6..b863acb 100644 --- a/ash/shell.cc +++ b/ash/shell.cc
@@ -65,7 +65,7 @@ #include "ash/magnifier/magnification_controller.h" #include "ash/magnifier/partial_magnification_controller.h" #include "ash/media/media_controller.h" -#include "ash/media/media_notification_controller.h" +#include "ash/media/media_notification_controller_impl.h" #include "ash/multi_device_setup/multi_device_notification_presenter.h" #include "ash/new_window_controller.h" #include "ash/note_taking_controller.h" @@ -849,8 +849,8 @@ // before it. detachable_base_handler_.reset(); - // MediaNotificationController depends on MessageCenter and must be destructed - // before it. + // MediaNotificationControllerImpl depends on MessageCenter and must be + // destructed before it. media_notification_controller_.reset(); // Destroys the MessageCenter singleton, so must happen late. @@ -1154,7 +1154,7 @@ if (base::FeatureList::IsEnabled(features::kMediaSessionNotification)) { media_notification_controller_ = - std::make_unique<MediaNotificationController>(connector_); + std::make_unique<MediaNotificationControllerImpl>(connector_); } for (auto& observer : shell_observers_)
diff --git a/ash/shell.h b/ash/shell.h index d602d35..9f74d31 100644 --- a/ash/shell.h +++ b/ash/shell.h
@@ -140,7 +140,7 @@ class MagnificationController; class TabletModeController; class MediaController; -class MediaNotificationController; +class MediaNotificationControllerImpl; class MessageCenterController; class MouseCursorEventFilter; class MruWindowTracker; @@ -414,7 +414,7 @@ return magnification_controller_.get(); } MediaController* media_controller() { return media_controller_.get(); } - MediaNotificationController* media_notification_controller() { + MediaNotificationControllerImpl* media_notification_controller() { return media_notification_controller_.get(); } MessageCenterController* message_center_controller() { @@ -695,7 +695,8 @@ std::unique_ptr<LogoutConfirmationController> logout_confirmation_controller_; std::unique_ptr<TabletModeController> tablet_mode_controller_; std::unique_ptr<MediaController> media_controller_; - std::unique_ptr<MediaNotificationController> media_notification_controller_; + std::unique_ptr<MediaNotificationControllerImpl> + media_notification_controller_; std::unique_ptr<MruWindowTracker> mru_window_tracker_; std::unique_ptr<MultiDeviceNotificationPresenter> multidevice_notification_presenter_;
diff --git a/ash/system/network/network_tray_view.cc b/ash/system/network/network_tray_view.cc index e30d665..ec42e54 100644 --- a/ash/system/network/network_tray_view.cc +++ b/ash/system/network/network_tray_view.cc
@@ -56,7 +56,8 @@ } void NetworkTrayView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->SetName(connection_status_string_); + node_data->SetName(accessible_name_); + node_data->SetDescription(accessible_description_); node_data->role = ax::mojom::Role::kButton; } @@ -120,9 +121,8 @@ bool notify_a11y) { using SignalStrength = network_icon::SignalStrength; - base::string16 new_connection_status_string; if (connected_network) { - new_connection_status_string = l10n_util::GetStringFUTF16( + base::string16 new_accessible_name = l10n_util::GetStringFUTF16( IDS_ASH_STATUS_TRAY_NETWORK_CONNECTED, base::UTF8ToUTF16(connected_network->name())); @@ -148,28 +148,31 @@ break; } + accessible_description_ = signal_strength_string; + if (!signal_strength_string.empty()) { - new_connection_status_string = l10n_util::GetStringFUTF16( + connection_status_tooltip_ = l10n_util::GetStringFUTF16( IDS_ASH_STATUS_TRAY_NETWORK_CONNECTED_ACCESSIBLE, base::UTF8ToUTF16(connected_network->name()), signal_strength_string); + } else { + // Use shorter description like "Disconnected" instead of "disconnected + // from network" for the tooltip, because the visual icon tells that + // this is about the network status. + connection_status_tooltip_ = l10n_util::GetStringUTF16( + IDS_ASH_STATUS_TRAY_NETWORK_DISCONNECTED_TOOLTIP); } + } else { + accessible_description_.clear(); } - connection_status_tooltip_ = new_connection_status_string; - } else { - new_connection_status_string = l10n_util::GetStringUTF16( - IDS_ASH_STATUS_TRAY_NETWORK_NOT_CONNECTED_A11Y); - // Use shorter desription like "Disconnected" instead of "disconnected from - // netrowk" for the tooltip, because the visual icon tells that this is - // about the network status. - connection_status_tooltip_ = l10n_util::GetStringUTF16( - IDS_ASH_STATUS_TRAY_NETWORK_DISCONNECTED_TOOLTIP); - } - if (new_connection_status_string != connection_status_string_) { - connection_status_string_ = new_connection_status_string; - if (notify_a11y && !connection_status_string_.empty()) + + if (accessible_name_ == new_accessible_name) + return; + + accessible_name_ = new_accessible_name; + + if (notify_a11y && !accessible_name_.empty()) NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); - image_view()->SetAccessibleName(connection_status_string_); } }
diff --git a/ash/system/network/network_tray_view.h b/ash/system/network/network_tray_view.h index 82d3efd..6ecfbe3 100644 --- a/ash/system/network/network_tray_view.h +++ b/ash/system/network/network_tray_view.h
@@ -67,7 +67,8 @@ void UpdateConnectionStatus(const chromeos::NetworkState* connected_network, bool notify_a11y); - base::string16 connection_status_string_; + base::string16 accessible_name_; + base::string16 accessible_description_; base::string16 connection_status_tooltip_; std::unique_ptr<TrayNetworkStateObserver> network_state_observer_;
diff --git a/base/allocator/partition_allocator/page_allocator_internals_posix.h b/base/allocator/partition_allocator/page_allocator_internals_posix.h index 1a1850c..c3b668b 100644 --- a/base/allocator/partition_allocator/page_allocator_internals_posix.h +++ b/base/allocator/partition_allocator/page_allocator_internals_posix.h
@@ -12,6 +12,8 @@ #include "build/build_config.h" #if defined(OS_MACOSX) +#include "base/mac/mac_util.h" + #include <mach/mach.h> #endif #if defined(OS_LINUX) @@ -66,12 +68,21 @@ int access_flag = GetAccessFlags(accessibility); int map_flags = MAP_ANONYMOUS | MAP_PRIVATE; - // TODO(https://crbug.com/927411): Remove once Fuchsia uses a native page - // allocator, rather than relying on POSIX compatibility. + // TODO(https://crbug.com/927411): Remove OS_FUCHSIA once Fuchsia uses a + // native page allocator, rather than relying on POSIX compatibility. #if defined(OS_FUCHSIA) if (page_tag == PageTag::kV8) { map_flags |= MAP_JIT; } +#elif defined(OS_MACOSX) + // On macOS 10.14 and higher, executables that are code signed with the + // "runtime" option cannot execute writable memory by default. They can opt + // into this capability by specifying the "com.apple.security.cs.allow-jit" + // code signing entitlement and allocating the region with the MAP_JIT flag. + static const bool kNeedMapJIT = mac::IsAtLeastOS10_14(); + if (page_tag == PageTag::kV8 && kNeedMapJIT) { + map_flags |= MAP_JIT; + } #endif void* ret =
diff --git a/base/test/android/junit/src/org/chromium/base/test/util/MinAndroidSdkLevelSkipCheckTest.java b/base/test/android/junit/src/org/chromium/base/test/util/MinAndroidSdkLevelSkipCheckTest.java index c9832c0..b317868 100644 --- a/base/test/android/junit/src/org/chromium/base/test/util/MinAndroidSdkLevelSkipCheckTest.java +++ b/base/test/android/junit/src/org/chromium/base/test/util/MinAndroidSdkLevelSkipCheckTest.java
@@ -21,16 +21,15 @@ /** Unit tests for MinAndroidSdkLevelSkipCheck. */ @RunWith(BaseRobolectricTestRunner.class) -@Config(manifest = Config.NONE, sdk = 18) +@Config(manifest = Config.NONE, sdk = 21) public class MinAndroidSdkLevelSkipCheckTest { public static class UnannotatedBaseClass { - @Test @MinAndroidSdkLevel(17) public void min17Method() {} - @Test @MinAndroidSdkLevel(20) public void min20Method() {} - } - - @MinAndroidSdkLevel(17) - public static class Min17Class extends UnannotatedBaseClass { - @Test public void unannotatedMethod() {} + @Test + @MinAndroidSdkLevel(20) + public void min20Method() {} + @Test + @MinAndroidSdkLevel(22) + public void min22Method() {} } @MinAndroidSdkLevel(20) @@ -38,8 +37,8 @@ @Test public void unannotatedMethod() {} } - public static class ExtendsMin17Class extends Min17Class { - @Override + @MinAndroidSdkLevel(22) + public static class Min22Class extends UnannotatedBaseClass { @Test public void unannotatedMethod() {} } @@ -48,6 +47,11 @@ @Test public void unannotatedMethod() {} } + public static class ExtendsMin22Class extends Min22Class { + @Override + @Test public void unannotatedMethod() {} + } + private static final MinAndroidSdkLevelSkipCheck sSkipCheck = new MinAndroidSdkLevelSkipCheck(); private static class InnerTestRunner extends BlockJUnit4ClassRunner { @@ -76,31 +80,31 @@ @Test public void testAnnotatedMethodAboveMin() throws Exception { - expectShouldSkip(UnannotatedBaseClass.class, "min17Method", false); + expectShouldSkip(UnannotatedBaseClass.class, "min20Method", false); } @Test public void testAnnotatedMethodBelowMin() throws Exception { - expectShouldSkip(UnannotatedBaseClass.class, "min20Method", true); + expectShouldSkip(UnannotatedBaseClass.class, "min22Method", true); } @Test public void testAnnotatedClassAboveMin() throws Exception { - expectShouldSkip(Min17Class.class, "unannotatedMethod", false); + expectShouldSkip(Min20Class.class, "unannotatedMethod", false); } @Test public void testAnnotatedClassBelowMin() throws Exception { - expectShouldSkip(Min20Class.class, "unannotatedMethod", true); + expectShouldSkip(Min22Class.class, "unannotatedMethod", true); } @Test public void testAnnotatedSuperclassAboveMin() throws Exception { - expectShouldSkip(ExtendsMin17Class.class, "unannotatedMethod", false); + expectShouldSkip(ExtendsMin20Class.class, "unannotatedMethod", false); } @Test public void testAnnotatedSuperclassBelowMin() throws Exception { - expectShouldSkip(ExtendsMin20Class.class, "unannotatedMethod", true); + expectShouldSkip(ExtendsMin22Class.class, "unannotatedMethod", true); } }
diff --git a/build/android/BUILD.gn b/build/android/BUILD.gn index ba93db0..60c3ec8 100644 --- a/build/android/BUILD.gn +++ b/build/android/BUILD.gn
@@ -73,6 +73,7 @@ } python_library("test_runner_py") { + testonly = true pydeps_file = "test_runner.pydeps" data = [ "pylib/gtest/filter/",
diff --git a/build/android/gyp/compile_resources.py b/build/android/gyp/compile_resources.py index 721e1a81..6e224b26e 100755 --- a/build/android/gyp/compile_resources.py +++ b/build/android/gyp/compile_resources.py
@@ -95,8 +95,12 @@ help='Package name that will be used to determine package ID.') input_opts.add_argument( + '--rename-manifest-package', help='Package name to force AAPT to use.') + + input_opts.add_argument( '--arsc-package-name', - help='Package name to use for resources.arsc file.') + help='Package name to set in manifest of resources.arsc file. This is ' + 'only used for apks under test.') input_opts.add_argument( '--shared-resources-whitelist', @@ -180,8 +184,10 @@ output_opts.add_argument( '--info-path', help='Path to output info file for the partial apk.') - output_opts.add_argument('--srcjar-out', - help='Path to srcjar to contain generated R.java.') + output_opts.add_argument( + '--srcjar-out', + required=True, + help='Path to srcjar to contain generated R.java.') output_opts.add_argument('--r-text-out', help='Path to store the generated R.txt file.') @@ -674,16 +680,16 @@ link_command = [ options.aapt2_path, 'link', - '--version-code', - options.version_code, - '--version-name', - options.version_name, '--auto-add-overlay', '--no-version-vectors', ] for j in options.include_resources: link_command += ['-I', j] + if options.version_code: + link_command += ['--version-code', options.version_code] + if options.version_name: + link_command += ['--version-name', options.version_name] if options.proguard_file: link_command += ['--proguard', build.proguard_path] if options.proguard_file_main_dex: @@ -707,16 +713,20 @@ if package_id is not None: link_command += ['--package-id', package_id, '--allow-reserved-package-id'] - fixed_manifest, orig_package = _FixManifest(options, build.temp_dir) + fixed_manifest, desired_manifest_package_name = _FixManifest( + options, build.temp_dir) + if options.rename_manifest_package: + desired_manifest_package_name = options.rename_manifest_package link_command += [ - '--manifest', fixed_manifest, '--rename-manifest-package', orig_package + '--manifest', fixed_manifest, '--rename-manifest-package', + desired_manifest_package_name ] # Creates a .zip with AndroidManifest.xml, resources.arsc, res/* # Also creates R.txt if options.use_resource_ids_path: _CreateStableIdsFile(options.use_resource_ids_path, build.stable_ids_path, - orig_package) + desired_manifest_package_name) link_command += ['--stable-ids', build.stable_ids_path] partials = _CompileDeps(options.aapt2_path, dep_subdirs, build.temp_dir) @@ -888,8 +898,7 @@ build.srcjar_dir, None, build.r_txt_path, options.extra_res_packages, options.extra_r_text_files, rjava_build_options) - if options.srcjar_out: - build_utils.ZipDir(build.srcjar_path, build.srcjar_dir) + build_utils.ZipDir(build.srcjar_path, build.srcjar_dir) # Sanity check that the created resources have the expected package ID. expected_id = _PackageIdFromOptions(options) @@ -908,7 +917,7 @@ if options.depfile: build_utils.WriteDepfile( options.depfile, - options.arsc_path or options.proto_path, + options.srcjar_out, inputs=options.dependencies_res_zips + options.extra_r_text_files, add_pydeps=False)
diff --git a/build/android/pylib/junit/junit_test_instance.py b/build/android/pylib/junit/junit_test_instance.py index e5dc2a7..5e150dd 100644 --- a/build/android/pylib/junit/junit_test_instance.py +++ b/build/android/pylib/junit/junit_test_instance.py
@@ -11,13 +11,11 @@ def __init__(self, args, _): super(JunitTestInstance, self).__init__() - self._android_manifest_path = args.android_manifest_path self._coverage_dir = args.coverage_dir self._debug_socket = args.debug_socket self._coverage_on_the_fly = args.coverage_on_the_fly self._package_filter = args.package_filter - self._package_name = args.package_name - self._resource_zips = args.resource_zips + self._resource_apk = args.resource_apk self._robolectric_runtime_deps_dir = args.robolectric_runtime_deps_dir self._runner_filter = args.runner_filter self._test_filter = test_filter.InitializeFilterFromArgs(args) @@ -36,10 +34,6 @@ pass @property - def android_manifest_path(self): - return self._android_manifest_path - - @property def coverage_dir(self): return self._coverage_dir @@ -56,12 +50,8 @@ return self._package_filter @property - def package_name(self): - return self._package_name - - @property - def resource_zips(self): - return self._resource_zips + def resource_apk(self): + return self._resource_apk @property def robolectric_runtime_deps_dir(self):
diff --git a/build/android/pylib/local/device/local_device_environment.py b/build/android/pylib/local/device/local_device_environment.py index bb958140c5..4d7aa82 100644 --- a/build/android/pylib/local/device/local_device_environment.py +++ b/build/android/pylib/local/device/local_device_environment.py
@@ -152,7 +152,7 @@ @handle_shard_failures_with(on_failure=self.BlacklistDevice) def prepare_device(d): - d.WaitUntilFullyBooted(timeout=120) + d.WaitUntilFullyBooted() if self._enable_device_cache: cache_path = _DeviceCachePath(d)
diff --git a/build/android/pylib/local/machine/local_machine_junit_test_run.py b/build/android/pylib/local/machine/local_machine_junit_test_run.py index 2b6cc8d..312bf9c 100644 --- a/build/android/pylib/local/machine/local_machine_junit_test_run.py +++ b/build/android/pylib/local/machine/local_machine_junit_test_run.py
@@ -5,10 +5,8 @@ import json import logging import os -import zipfile from devil.utils import cmd_helper -from devil.utils import reraiser_thread from pylib import constants from pylib.base import base_test_result from pylib.base import test_run @@ -34,21 +32,6 @@ with tempfile_ext.NamedTemporaryDirectory() as temp_dir: json_file_path = os.path.join(temp_dir, 'results.json') - # Extract resources needed for test. - # TODO(mikecase): Investigate saving md5sums of zipfiles, and only - # extract zipfiles when they change. - def extract_resource_zip(resource_zip, filename): - def helper(): - extract_dest = os.path.join(temp_dir, filename) - with zipfile.ZipFile(resource_zip, 'r') as zf: - zf.extractall(extract_dest) - return extract_dest - return helper - - resource_dirs = reraiser_thread.RunAsync( - extract_resource_zip(resource_zip, 'resources_%d' % index) for index, - resource_zip in enumerate(self._test_instance.resource_zips)) - java_script = os.path.join( constants.GetOutDirectory(), 'bin', 'helper', self._test_instance.suite) @@ -67,21 +50,14 @@ command.extend(['--jar-args', '"%s"' % ' '.join(jar_args)]) # Add JVM arguments. - jvm_args = ['-Drobolectric.dependency.dir=%s' % - self._test_instance.robolectric_runtime_deps_dir, - '-Ddir.source.root=%s' % constants.DIR_SOURCE_ROOT,] - - if self._test_instance.android_manifest_path: - jvm_args += ['-Dchromium.robolectric.manifest=%s' % - self._test_instance.android_manifest_path] - - if self._test_instance.package_name: - jvm_args += ['-Dchromium.robolectric.package.name=%s' % - self._test_instance.package_name] - - if resource_dirs: - jvm_args += ['-Dchromium.robolectric.resource.dirs=%s' % - ':'.join(resource_dirs)] + jvm_args = [ + '-Drobolectric.dependency.dir=%s' % + self._test_instance.robolectric_runtime_deps_dir, + '-Ddir.source.root=%s' % constants.DIR_SOURCE_ROOT, + '-Drobolectric.resourcesMode=binary', + '-Dchromium.robolectric.resource.ap_=%s' % + self._test_instance.resource_apk + ] if logging.getLogger().isEnabledFor(logging.INFO): jvm_args += ['-Drobolectric.logging=stdout']
diff --git a/build/android/test_runner.py b/build/android/test_runner.py index eb516acb..729aa849 100755 --- a/build/android/test_runner.py +++ b/build/android/test_runner.py
@@ -536,18 +536,12 @@ # These arguments are for Android Robolectric tests. parser.add_argument( - '--android-manifest-path', - help='Path to Android Manifest to configure Robolectric.') - parser.add_argument( - '--package-name', - help='Default app package name for Robolectric tests.') - parser.add_argument( - '--resource-zip', - action='append', dest='resource_zips', default=[], - help='Path to resource zips to configure Robolectric.') - parser.add_argument( '--robolectric-runtime-deps-dir', help='Path to runtime deps for Robolectric.') + parser.add_argument( + '--resource-apk', + required=True, + help='Path to .ap_ containing binary resources for Robolectric.') def AddLinkerTestOptions(parser):
diff --git a/build/config/android/internal_rules.gni b/build/config/android/internal_rules.gni index 74b531c8..737495b 100644 --- a/build/config/android/internal_rules.gni +++ b/build/config/android/internal_rules.gni
@@ -777,33 +777,18 @@ "--test-suite", invoker.test_suite, ] - if (defined(invoker.android_manifest_path)) { - _rebased_android_manifest_path = - rebase_path(invoker.android_manifest_path, root_build_dir) - executable_args += [ - "--android-manifest-path", - "@WrappedPath(${_rebased_android_manifest_path})", - ] - } else if (defined(invoker.package_name)) { - executable_args += [ - "--package-name", - invoker.package_name, - ] - } else { - assert(false, "Must specify a package_name or android_manifest_path") - } deps += [ ":${invoker.test_suite}$build_config_target_suffix" ] _junit_binary_build_config = "${target_gen_dir}/${invoker.test_suite}.build_config" - _rebased_build_config = - rebase_path("$_junit_binary_build_config", root_build_dir) - executable_args += [ "@WrappedPathList(--resource-zip, @FileArg($_rebased_build_config:resources:dependency_zips))" ] _rebased_robolectric_runtime_deps_dir = rebase_path("$root_build_dir/lib.java/third_party/robolectric", root_build_dir) + _rebased_resource_apk = rebase_path(invoker.resource_apk, root_build_dir) executable_args += [ + "--resource-apk", + "@WrappedPath(${_rebased_resource_apk})", "--robolectric-runtime-deps-dir", "@WrappedPath(${_rebased_robolectric_runtime_deps_dir})", ] @@ -2184,9 +2169,7 @@ if (defined(invoker.optimized_arsc_output)) { _optimized_arsc_output = invoker.optimized_arsc_output } - if (defined(invoker.srcjar_path)) { - _srcjar_path = invoker.srcjar_path - } + _srcjar_path = invoker.srcjar_path if (defined(invoker.post_process_script)) { _compile_resources_target_name = "${target_name}__intermediate" _srcjar_path = "${_srcjar_path}.intermediate.srcjar" @@ -2219,9 +2202,7 @@ "visibility", ]) script = "//build/android/gyp/compile_resources.py" - depfile = "$target_gen_dir/${invoker.target_name}_1.d" - outputs = [] inputs = [ invoker.build_config, @@ -2242,9 +2223,14 @@ ] inputs += [ invoker.android_manifest ] + outputs = [ + _srcjar_path, + ] args += [ "--android-manifest", rebase_path(invoker.android_manifest, root_build_dir), + "--srcjar-out", + rebase_path(_srcjar_path, root_build_dir), ] if (defined(invoker.no_xml_namespaces) && invoker.no_xml_namespaces) { args += [ "--no-xml-namespaces" ] @@ -2333,18 +2319,10 @@ ] } - if (defined(_srcjar_path)) { - outputs += [ _srcjar_path ] + if (defined(invoker.rename_manifest_package)) { args += [ - "--srcjar-out", - rebase_path(_srcjar_path, root_build_dir), - ] - } - - if (defined(invoker.custom_package)) { - args += [ - "--custom-package", - invoker.custom_package, + "--rename-manifest-package", + invoker.rename_manifest_package, ] }
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni index ef398fd..562ce09 100644 --- a/build/config/android/rules.gni +++ b/build/config/android/rules.gni
@@ -1370,19 +1370,21 @@ _package_name = "org.chromium.test" } - _prepare_resources_target = "${target_name}__prepare_resources" - prepare_resources(_prepare_resources_target) { + _resource_arsc_output = "${target_gen_dir}/${target_name}.ap_" + _compile_resources_target = "${target_name}__compile_resources" + compile_resources(_compile_resources_target) { deps = _deps + [ ":$_build_config_target_name" ] build_config = _build_config srcjar_path = "${target_gen_dir}/${target_name}.srcjar" if (defined(_package_name)) { - custom_package = _package_name + rename_manifest_package = _package_name } if (defined(invoker.android_manifest_path)) { android_manifest = invoker.android_manifest_path } else { android_manifest = "//build/android/AndroidManifest.xml" } + arsc_output = _resource_arsc_output } _jni_srcjar_target = "${target_name}__final_jni" @@ -1413,7 +1415,7 @@ } srcjar_deps += [ ":$_jni_srcjar_target", - ":$_prepare_resources_target", + ":$_compile_resources_target", # This dep is required for any targets that depend on //base:base_java. "//base:base_build_config_gen", @@ -1426,9 +1428,7 @@ test_type = "junit" ignore_all_data_deps = true forward_variables_from(invoker, [ "android_manifest_path" ]) - if (defined(_package_name)) { - package_name = _package_name - } + resource_apk = _resource_arsc_output } group(target_name) {
diff --git a/cc/test/layer_tree_pixel_resource_test.cc b/cc/test/layer_tree_pixel_resource_test.cc index bbaf9e0f6..f3880c7b 100644 --- a/cc/test/layer_tree_pixel_resource_test.cc +++ b/cc/test/layer_tree_pixel_resource_test.cc
@@ -17,6 +17,21 @@ namespace cc { +namespace { + +LayerTreeTest::RendererType GetRendererType(PixelResourceTestCase test_case) { + switch (test_case) { + case SOFTWARE: + return LayerTreeTest::RENDERER_SOFTWARE; + case SKIA_GL: + return LayerTreeTest::RENDERER_SKIA_GL; + default: + return LayerTreeTest::RENDERER_GL; + } +} + +} // namespace + LayerTreeHostPixelResourceTest::LayerTreeHostPixelResourceTest( PixelResourceTestCase test_case, Layer::LayerMaskType mask_type) @@ -30,16 +45,6 @@ PixelResourceTestCase test_case) { DCHECK(!initialized_); test_case_ = test_case; - switch (test_case) { - case SOFTWARE: - SetPixelTestType(PIXEL_TEST_SOFTWARE); - break; - case SKIA_GL: - SetPixelTestType(PIXEL_TEST_SKIA_GL); - break; - default: - SetPixelTestType(PIXEL_TEST_GL); - } initialized_ = true; } @@ -80,14 +85,14 @@ switch (test_case_) { case SOFTWARE: EXPECT_FALSE(compositor_context_provider); - EXPECT_EQ(PIXEL_TEST_SOFTWARE, test_type_); + EXPECT_EQ(RENDERER_SOFTWARE, renderer_type_); return std::make_unique<BitmapRasterBufferProvider>( host_impl->layer_tree_frame_sink()); case GPU: EXPECT_TRUE(compositor_context_provider); EXPECT_TRUE(worker_context_provider); - EXPECT_EQ(PIXEL_TEST_GL, test_type_); + EXPECT_EQ(RENDERER_GL, renderer_type_); return std::make_unique<GpuRasterBufferProvider>( compositor_context_provider, worker_context_provider, false, 0, @@ -95,7 +100,7 @@ case ZERO_COPY: EXPECT_TRUE(compositor_context_provider); EXPECT_TRUE(gpu_memory_buffer_manager); - EXPECT_EQ(PIXEL_TEST_GL, test_type_); + EXPECT_EQ(RENDERER_GL, renderer_type_); return std::make_unique<ZeroCopyRasterBufferProvider>( gpu_memory_buffer_manager, compositor_context_provider, @@ -103,7 +108,7 @@ case ONE_COPY: EXPECT_TRUE(compositor_context_provider); EXPECT_TRUE(worker_context_provider); - EXPECT_EQ(PIXEL_TEST_GL, test_type_); + EXPECT_EQ(RENDERER_GL, renderer_type_); return std::make_unique<OneCopyRasterBufferProvider>( task_runner, compositor_context_provider, worker_context_provider, @@ -112,7 +117,7 @@ case SKIA_GL: EXPECT_TRUE(compositor_context_provider); EXPECT_TRUE(worker_context_provider); - EXPECT_EQ(PIXEL_TEST_SKIA_GL, test_type_); + EXPECT_EQ(RENDERER_SKIA_GL, renderer_type_); return std::make_unique<GpuRasterBufferProvider>( compositor_context_provider, worker_context_provider, false, 0, @@ -124,20 +129,21 @@ void LayerTreeHostPixelResourceTest::RunPixelResourceTest( scoped_refptr<Layer> content_root, base::FilePath file_name) { - RunPixelTest(test_type_, content_root, file_name); + RunPixelTest(GetRendererType(test_case_), content_root, file_name); } void LayerTreeHostPixelResourceTest::RunPixelResourceTest( scoped_refptr<Layer> content_root, const SkBitmap& expected_bitmap) { - RunPixelTest(test_type_, content_root, expected_bitmap); + RunPixelTest(GetRendererType(test_case_), content_root, expected_bitmap); } void LayerTreeHostPixelResourceTest::RunPixelResourceTestWithLayerList( scoped_refptr<Layer> root_layer, base::FilePath file_name, PropertyTrees* property_trees) { - RunPixelTestWithLayerList(test_type_, root_layer, file_name, property_trees); + RunPixelTestWithLayerList(GetRendererType(test_case_), root_layer, file_name, + property_trees); } ParameterizedPixelResourceTest::ParameterizedPixelResourceTest()
diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc index 485ea31..85d3a2f5 100644 --- a/cc/test/layer_tree_pixel_test.cc +++ b/cc/test/layer_tree_pixel_test.cc
@@ -38,7 +38,6 @@ LayerTreePixelTest::LayerTreePixelTest() : pixel_comparator_(new ExactPixelComparator(true)), - test_type_(PIXEL_TEST_GL), property_trees_(nullptr), pending_texture_mailbox_callbacks_(0) {} @@ -52,7 +51,7 @@ scoped_refptr<viz::RasterContextProvider>) { scoped_refptr<TestInProcessContextProvider> compositor_context_provider; scoped_refptr<TestInProcessContextProvider> worker_context_provider; - if (test_type_ == PIXEL_TEST_GL || test_type_ == PIXEL_TEST_SKIA_GL) { + if (renderer_type_ == RENDERER_GL || renderer_type_ == RENDERER_SKIA_GL) { compositor_context_provider = new TestInProcessContextProvider( /*enable_oop_rasterization=*/false, /*support_locking=*/false); worker_context_provider = new TestInProcessContextProvider( @@ -94,7 +93,7 @@ LayerTreePixelTest::CreateDisplayOutputSurfaceOnThread( scoped_refptr<viz::ContextProvider> compositor_context_provider) { std::unique_ptr<PixelTestOutputSurface> display_output_surface; - if (test_type_ == PIXEL_TEST_GL) { + if (renderer_type_ == RENDERER_GL) { // Pixel tests use a separate context for the Display to more closely // mimic texture transport from the renderer process to the Display // compositor. @@ -108,7 +107,7 @@ display_output_surface = std::make_unique<PixelTestOutputSurface>( std::move(display_context_provider), flipped_output_surface); } else { - EXPECT_EQ(PIXEL_TEST_SOFTWARE, test_type_); + EXPECT_EQ(RENDERER_SOFTWARE, renderer_type_); display_output_surface = std::make_unique<PixelTestOutputSurface>( std::make_unique<viz::SoftwareOutputDevice>()); } @@ -234,20 +233,20 @@ return layer; } -void LayerTreePixelTest::RunPixelTest(PixelTestType test_type, +void LayerTreePixelTest::RunPixelTest(RendererType renderer_type, scoped_refptr<Layer> content_root, base::FilePath file_name) { - SetPixelTestType(test_type); + renderer_type_ = renderer_type; content_root_ = content_root; readback_target_ = nullptr; ref_file_ = file_name; RunTest(CompositorMode::THREADED); } -void LayerTreePixelTest::RunPixelTest(PixelTestType test_type, +void LayerTreePixelTest::RunPixelTest(RendererType renderer_type, scoped_refptr<Layer> content_root, const SkBitmap& expected_bitmap) { - SetPixelTestType(test_type); + renderer_type_ = renderer_type; content_root_ = content_root; readback_target_ = nullptr; ref_file_ = base::FilePath(); @@ -256,11 +255,11 @@ } void LayerTreePixelTest::RunPixelTestWithLayerList( - PixelTestType test_type, + RendererType renderer_type, scoped_refptr<Layer> root_layer, base::FilePath file_name, PropertyTrees* property_trees) { - SetPixelTestType(test_type); + renderer_type_ = renderer_type; content_root_ = root_layer; property_trees_ = property_trees; readback_target_ = nullptr; @@ -298,10 +297,10 @@ } void LayerTreePixelTest::RunSingleThreadedPixelTest( - PixelTestType test_type, + RendererType renderer_type, scoped_refptr<Layer> content_root, base::FilePath file_name) { - SetPixelTestType(test_type); + renderer_type_ = renderer_type; content_root_ = content_root; readback_target_ = nullptr; ref_file_ = file_name; @@ -309,11 +308,11 @@ } void LayerTreePixelTest::RunPixelTestWithReadbackTarget( - PixelTestType test_type, + RendererType renderer_type, scoped_refptr<Layer> content_root, Layer* target, base::FilePath file_name) { - SetPixelTestType(test_type); + renderer_type_ = renderer_type; content_root_ = content_root; readback_target_ = target; ref_file_ = file_name;
diff --git a/cc/test/layer_tree_pixel_test.h b/cc/test/layer_tree_pixel_test.h index fb9fe725..df548aa 100644 --- a/cc/test/layer_tree_pixel_test.h +++ b/cc/test/layer_tree_pixel_test.h
@@ -42,26 +42,6 @@ class TextureLayer; class LayerTreePixelTest : public LayerTreeTest { - public: - // TODO(sgilhuly): Once the pixel tests are working on skia gl, add the option - // for skia vulkan. - enum PixelTestType { - PIXEL_TEST_GL, - PIXEL_TEST_SKIA_GL, - PIXEL_TEST_SOFTWARE, - }; - - static std::string TestTypeToString(PixelTestType test_type) { - switch (test_type) { - case PIXEL_TEST_GL: - return "GL"; - case PIXEL_TEST_SKIA_GL: - return "Skia GL"; - case PIXEL_TEST_SOFTWARE: - return "Software"; - } - } - protected: LayerTreePixelTest(); ~LayerTreePixelTest() override; @@ -104,32 +84,28 @@ void InitializeForLayerListMode(scoped_refptr<Layer>* root_layer, PropertyTrees* property_trees); - void RunPixelTest(PixelTestType type, + void RunPixelTest(RendererType renderer_type, scoped_refptr<Layer> content_root, base::FilePath file_name); - void RunPixelTest(PixelTestType type, + + void RunPixelTest(RendererType renderer_type, scoped_refptr<Layer> content_root, const SkBitmap& expected_bitmap); - void RunPixelTestWithLayerList(PixelTestType type, + void RunPixelTestWithLayerList(RendererType renderer_type, scoped_refptr<Layer> root_layer, base::FilePath file_name, PropertyTrees* property_trees); - void RunSingleThreadedPixelTest(PixelTestType test_type, + void RunSingleThreadedPixelTest(RendererType renderer_type, scoped_refptr<Layer> content_root, base::FilePath file_name); - void RunPixelTestWithReadbackTarget(PixelTestType type, + void RunPixelTestWithReadbackTarget(RendererType renderer_type, scoped_refptr<Layer> content_root, Layer* target, base::FilePath file_name); - void SetPixelTestType(PixelTestType test_type) { - test_type_ = test_type; - use_skia_renderer_ = test_type == PIXEL_TEST_SKIA_GL; - } - SkBitmap CopyMailboxToBitmap(const gfx::Size& size, const gpu::Mailbox& mailbox, const gpu::SyncToken& sync_token, @@ -152,7 +128,6 @@ gl::DisableNullDrawGLBindings enable_pixel_output_; std::unique_ptr<PixelComparator> pixel_comparator_; - PixelTestType test_type_; scoped_refptr<Layer> content_root_; PropertyTrees* property_trees_; Layer* readback_target_;
diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index f8ea01f..4530874 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc
@@ -1085,16 +1085,16 @@ void LayerTreeTest::RequestNewLayerTreeFrameSink() { scoped_refptr<viz::TestContextProvider> shared_context_provider = - use_software_renderer_ ? nullptr : viz::TestContextProvider::Create(); + use_software_renderer() ? nullptr : viz::TestContextProvider::Create(); scoped_refptr<viz::TestContextProvider> worker_context_provider = - use_software_renderer_ ? nullptr - : viz::TestContextProvider::CreateWorker(); + use_software_renderer() ? nullptr + : viz::TestContextProvider::CreateWorker(); viz::RendererSettings renderer_settings; // Spend less time waiting for BeginFrame because the output is // mocked out. constexpr double refresh_rate = 200.0; - renderer_settings.use_skia_renderer = use_skia_renderer_; + renderer_settings.use_skia_renderer = use_skia_renderer(); auto layer_tree_frame_sink = CreateLayerTreeFrameSink( renderer_settings, refresh_rate, std::move(shared_context_provider), std::move(worker_context_provider)); @@ -1120,7 +1120,7 @@ return std::make_unique<SynchronousLayerTreeFrameSink>( compositor_context_provider, std::move(worker_context_provider), gpu_memory_buffer_manager(), renderer_settings, impl_task_runner_, - refresh_rate, begin_frame_source_, use_software_renderer_); + refresh_rate, begin_frame_source_, use_software_renderer()); } return std::make_unique<viz::TestLayerTreeFrameSink>( @@ -1139,7 +1139,7 @@ LayerTreeTest::CreateDisplayOutputSurfaceOnThread( scoped_refptr<viz::ContextProvider> compositor_context_provider) { // By default the Display shares a context with the LayerTreeHostImpl. - if (use_software_renderer_) { + if (use_software_renderer()) { return viz::FakeOutputSurface::CreateSoftware( std::make_unique<viz::SoftwareOutputDevice>()); }
diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h index a439eff..3dda7ce 100644 --- a/cc/test/layer_tree_test.h +++ b/cc/test/layer_tree_test.h
@@ -67,6 +67,25 @@ // thread, but be aware that ending the test is an asynchronous process. class LayerTreeTest : public testing::Test, public TestHooks { public: + // TODO(sgilhuly): Once the pixel tests are working on skia gl, add the option + // for skia vulkan. + enum RendererType { + RENDERER_GL, + RENDERER_SKIA_GL, + RENDERER_SOFTWARE, + }; + + static std::string TestTypeToString(RendererType renderer_type) { + switch (renderer_type) { + case RENDERER_GL: + return "GL"; + case RENDERER_SKIA_GL: + return "Skia GL"; + case RENDERER_SOFTWARE: + return "Software"; + } + } + ~LayerTreeTest() override; virtual void EndTest(); @@ -178,8 +197,10 @@ begin_frame_source_ = begin_frame_source; } - bool use_skia_renderer_ = false; - bool use_software_renderer_ = false; + bool use_skia_renderer() { return renderer_type_ == RENDERER_SKIA_GL; } + bool use_software_renderer() { return renderer_type_ == RENDERER_SOFTWARE; } + + RendererType renderer_type_ = RENDERER_GL; private: virtual void DispatchAddNoDamageAnimation(
diff --git a/cc/trees/layer_tree_host_pixeltest_blending.cc b/cc/trees/layer_tree_host_pixeltest_blending.cc index 188d146..d9e4994 100644 --- a/cc/trees/layer_tree_host_pixeltest_blending.cc +++ b/cc/trees/layer_tree_host_pixeltest_blending.cc
@@ -213,10 +213,10 @@ InitializeFromTestCase(resource_type()); // Force shaders only applies to gl renderer. - if (test_type_ != PIXEL_TEST_GL && flags & kForceShaders) + if (renderer_type_ != RENDERER_GL && flags & kForceShaders) return; - SCOPED_TRACE(TestTypeToString(test_type_)); + SCOPED_TRACE(TestTypeToString(renderer_type_)); SCOPED_TRACE(SkBlendMode_Name(current_blend_mode())); scoped_refptr<SolidColorLayer> root = CreateSolidColorLayer( @@ -232,7 +232,7 @@ this->force_antialiasing_ = (flags & kUseAntialiasing); this->force_blending_with_shaders_ = (flags & kForceShaders); - if ((flags & kUseAntialiasing) && (test_type_ == PIXEL_TEST_GL)) { + if ((flags & kUseAntialiasing) && (renderer_type_ == RENDERER_GL)) { // Blending results might differ with one pixel. // Don't allow large errors here, only off by ones. // However, large error still has to be specified to satisfy
diff --git a/cc/trees/layer_tree_host_pixeltest_filters.cc b/cc/trees/layer_tree_host_pixeltest_filters.cc index ff3b2353..6826aac 100644 --- a/cc/trees/layer_tree_host_pixeltest_filters.cc +++ b/cc/trees/layer_tree_host_pixeltest_filters.cc
@@ -19,7 +19,7 @@ class LayerTreeHostFiltersPixelTest : public LayerTreePixelTest, - public ::testing::WithParamInterface<LayerTreePixelTest::PixelTestType> { + public ::testing::WithParamInterface<LayerTreeTest::RendererType> { protected: void InitializeSettings(LayerTreeSettings* settings) override { LayerTreePixelTest::InitializeSettings(settings); @@ -29,17 +29,17 @@ layer_transforms_should_scale_layer_contents_; } - LayerTreePixelTest::PixelTestType GetPixelTestType() { return GetParam(); } + RendererType renderer_type() { return GetParam(); } // Text string for graphics backend of the RendererType. Suitable for // generating separate base line file paths. const char* GetRendererSuffix() { - switch (GetPixelTestType()) { - case LayerTreePixelTest::PIXEL_TEST_GL: + switch (renderer_type()) { + case RENDERER_GL: return "gl"; - case LayerTreePixelTest::PIXEL_TEST_SKIA_GL: + case RENDERER_SKIA_GL: return "skia"; - case LayerTreePixelTest::PIXEL_TEST_SOFTWARE: + case RENDERER_SOFTWARE: return "sw"; } } @@ -75,36 +75,33 @@ bool layer_transforms_should_scale_layer_contents_ = true; }; -INSTANTIATE_TEST_SUITE_P( - , - LayerTreeHostFiltersPixelTest, - ::testing::Values(LayerTreePixelTest::PIXEL_TEST_GL, - LayerTreePixelTest::PIXEL_TEST_SKIA_GL, - LayerTreePixelTest::PIXEL_TEST_SOFTWARE)); +INSTANTIATE_TEST_SUITE_P(, + LayerTreeHostFiltersPixelTest, + ::testing::Values(LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL, + LayerTreeTest::RENDERER_SOFTWARE)); using LayerTreeHostFiltersPixelTestNonSkia = LayerTreeHostFiltersPixelTest; // TODO(crbug.com/948128): Enable these tests for Skia. -INSTANTIATE_TEST_SUITE_P( - , - LayerTreeHostFiltersPixelTestNonSkia, - ::testing::Values(LayerTreePixelTest::PIXEL_TEST_GL, - LayerTreePixelTest::PIXEL_TEST_SOFTWARE)); +INSTANTIATE_TEST_SUITE_P(, + LayerTreeHostFiltersPixelTestNonSkia, + ::testing::Values(LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SOFTWARE)); using LayerTreeHostFiltersPixelTestGL = LayerTreeHostFiltersPixelTest; // TODO(crbug.com/948128): Enable these tests for Skia. INSTANTIATE_TEST_SUITE_P(, LayerTreeHostFiltersPixelTestGL, - ::testing::Values(LayerTreePixelTest::PIXEL_TEST_GL)); + ::testing::Values(LayerTreeTest::RENDERER_GL)); using LayerTreeHostFiltersPixelTestGPU = LayerTreeHostFiltersPixelTest; -INSTANTIATE_TEST_SUITE_P( - , - LayerTreeHostFiltersPixelTestGPU, - ::testing::Values(LayerTreePixelTest::PIXEL_TEST_GL, - LayerTreePixelTest::PIXEL_TEST_SKIA_GL)); +INSTANTIATE_TEST_SUITE_P(, + LayerTreeHostFiltersPixelTestGPU, + ::testing::Values(LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL)); TEST_P(LayerTreeHostFiltersPixelTestGPU, BackdropFilterBlurRect) { scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( @@ -142,7 +139,7 @@ small_error_allowed)); #endif - RunPixelTest(GetPixelTestType(), background, + RunPixelTest(renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("backdrop_filter_blur.png"))); } @@ -184,7 +181,7 @@ #endif RunPixelTest( - GetPixelTestType(), background, + renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("backdrop_filter_blur_rounded.png"))); } @@ -233,7 +230,7 @@ #endif RunPixelTest( - GetPixelTestType(), background, + renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("backdrop_filter_blur_outsets.png"))); } @@ -305,7 +302,7 @@ #endif RunPixelTest( - GetPixelTestType(), background, + renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("backdrop_filter_blur_off_axis.png"))); } @@ -340,7 +337,7 @@ device_scale_factor_ = device_scale_factor; RunPixelTest( - GetPixelTestType(), background, + renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } @@ -348,11 +345,10 @@ }; // TODO(crbug.com/948128): Enable these tests for Skia. -INSTANTIATE_TEST_SUITE_P( - , - LayerTreeHostFiltersScaledPixelTest, - ::testing::Values(LayerTreePixelTest::PIXEL_TEST_GL, - LayerTreePixelTest::PIXEL_TEST_SOFTWARE)); +INSTANTIATE_TEST_SUITE_P(, + LayerTreeHostFiltersScaledPixelTest, + ::testing::Values(LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SOFTWARE)); TEST_P(LayerTreeHostFiltersScaledPixelTest, StandardDpi) { RunPixelTestType(100, 1.f); @@ -372,7 +368,7 @@ filters.Append(FilterOperation::CreateReferenceFilter(nullptr)); foreground->SetFilters(filters); - RunPixelTest(GetPixelTestType(), foreground, + RunPixelTest(renderer_type(), foreground, base::FilePath(FILE_PATH_LITERAL("green.png"))); } @@ -391,7 +387,7 @@ filters.Append(FilterOperation::CreateReferenceFilter(offset)); foreground->SetFilters(filters); - RunPixelTest(GetPixelTestType(), foreground, + RunPixelTest(renderer_type(), foreground, base::FilePath(FILE_PATH_LITERAL("white.png"))); } @@ -427,7 +423,7 @@ transform.Translate(0.0, -100.0); foreground->SetTransform(transform); - RunPixelTest(GetPixelTestType(), background, + RunPixelTest(renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("blue_yellow.png"))); } @@ -459,7 +455,7 @@ // applied only to the top 100 pixels, not the bottom. foreground->SetFiltersOrigin(gfx::PointF(0.0f, -100.0f)); - RunPixelTest(GetPixelTestType(), background, + RunPixelTest(renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("blue_yellow.png"))); } @@ -526,7 +522,7 @@ #endif RunPixelTest( - GetPixelTestType(), background, + renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("backdrop_filter_on_scaled_layer_.png")) .InsertBeforeExtensionASCII(GetRendererSuffix())); } @@ -582,7 +578,7 @@ average_error_allowed_in_bad_pixels, large_error_allowed, small_error_allowed)); - RunPixelTest(GetPixelTestType(), background, + RunPixelTest(renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("backdrop_filter_rotated_.png")) .InsertBeforeExtensionASCII(GetRendererSuffix())); } @@ -619,7 +615,7 @@ // Software has some huge differences in the AA'd pixels on the different // trybots. See crbug.com/452198. - if (GetPixelTestType() == LayerTreePixelTest::PIXEL_TEST_SOFTWARE) { + if (renderer_type() == LayerTreeTest::RENDERER_SOFTWARE) { float percentage_pixels_large_error = 0.686f; float percentage_pixels_small_error = 0.0f; float average_error_allowed_in_bad_pixels = 16.f; @@ -633,7 +629,7 @@ } RunPixelTest( - GetPixelTestType(), background, + renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("scaled_render_surface_layer_.png")) .InsertBeforeExtensionASCII(GetRendererSuffix())); } @@ -702,7 +698,7 @@ small_error_allowed)); #endif - RunPixelTest(GetPixelTestType(), std::move(root), + RunPixelTest(renderer_type(), std::move(root), base::FilePath(FILE_PATH_LITERAL("zoom_filter_.png")) .InsertBeforeExtensionASCII(GetRendererSuffix())); } @@ -743,7 +739,7 @@ small_error_allowed)); #endif - RunPixelTest(GetPixelTestType(), background, + RunPixelTest(renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("rotated_filter_.png")) .InsertBeforeExtensionASCII(GetRendererSuffix())); } @@ -790,7 +786,7 @@ #endif RunPixelTest( - GetPixelTestType(), background, + renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("rotated_drop_shadow_filter_.png")) .InsertBeforeExtensionASCII(GetRendererSuffix())); } @@ -830,7 +826,7 @@ clip->AddChild(parent); RunPixelTest( - GetPixelTestType(), clip, + renderer_type(), clip, base::FilePath(FILE_PATH_LITERAL("translated_blue_green_alpha_.png")) .InsertBeforeExtensionASCII(GetRendererSuffix())); } @@ -871,7 +867,7 @@ set_enlarge_texture_amount(gfx::Size(50, 50)); RunPixelTest( - GetPixelTestType(), background, + renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("enlarged_texture_on_threshold.png"))); } @@ -909,7 +905,7 @@ set_enlarge_texture_amount(gfx::Size(50, 50)); RunPixelTest( - GetPixelTestType(), background, + renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("enlarged_texture_on_crop_offset.png"))); } @@ -959,7 +955,7 @@ small_error_allowed)); #endif - RunPixelTest(GetPixelTestType(), filter_layer, + RunPixelTest(renderer_type(), filter_layer, base::FilePath(FILE_PATH_LITERAL("blur_filter_with_clip_.png")) .InsertBeforeExtensionASCII(GetRendererSuffix())); } @@ -967,14 +963,14 @@ TEST_P(LayerTreeHostFiltersPixelTestGPU, FilterWithGiantCropRect) { scoped_refptr<SolidColorLayer> tree = BuildFilterWithGiantCropRect(true); RunPixelTest( - GetPixelTestType(), tree, + renderer_type(), tree, base::FilePath(FILE_PATH_LITERAL("filter_with_giant_crop_rect.png"))); } TEST_P(LayerTreeHostFiltersPixelTestGPU, FilterWithGiantCropRectNoClip) { scoped_refptr<SolidColorLayer> tree = BuildFilterWithGiantCropRect(false); RunPixelTest( - GetPixelTestType(), tree, + renderer_type(), tree, base::FilePath(FILE_PATH_LITERAL("filter_with_giant_crop_rect.png"))); } @@ -1004,7 +1000,7 @@ // This should appear as a grid of 4 100x100 squares which are: // BLACK WHITE // DARK GREEN LIGHT GREEN - RunPixelTest(GetPixelTestType(), std::move(root), expected_result); + RunPixelTest(renderer_type(), std::move(root), expected_result); } private: @@ -1018,11 +1014,10 @@ }; // TODO(crbug.com/948128): Enable these tests for Skia. -INSTANTIATE_TEST_SUITE_P( - , - BackdropFilterWithDeviceScaleFactorTest, - ::testing::Values(LayerTreePixelTest::PIXEL_TEST_GL, - LayerTreePixelTest::PIXEL_TEST_SOFTWARE)); +INSTANTIATE_TEST_SUITE_P(, + BackdropFilterWithDeviceScaleFactorTest, + ::testing::Values(LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SOFTWARE)); TEST_P(BackdropFilterWithDeviceScaleFactorTest, StandardDpi) { RunPixelTestType(
diff --git a/cc/trees/layer_tree_host_pixeltest_masks.cc b/cc/trees/layer_tree_host_pixeltest_masks.cc index 7d85a9f..e9cd22ea 100644 --- a/cc/trees/layer_tree_host_pixeltest_masks.cc +++ b/cc/trees/layer_tree_host_pixeltest_masks.cc
@@ -960,7 +960,7 @@ average_error_allowed_in_bad_pixels = 3.5f; large_error_allowed = 15; small_error_allowed = 1; - } else if (test_type_ != PIXEL_TEST_SOFTWARE) { + } else if (test_case_ != SOFTWARE) { percentage_pixels_small_error = 0.9f; percentage_pixels_error = 6.5f; average_error_allowed_in_bad_pixels = 3.5f; @@ -1213,7 +1213,7 @@ mask_isolation->AddChild(mask_layer); base::FilePath image_name = - (test_type_ == PIXEL_TEST_SOFTWARE) + (test_case_ == SOFTWARE) ? base::FilePath( FILE_PATH_LITERAL("mask_as_blending_rotated_circle.png")) : base::FilePath( @@ -1260,7 +1260,7 @@ mask_isolation->AddChild(mask_layer); base::FilePath image_name = - (test_type_ == PIXEL_TEST_SOFTWARE) + (test_case_ == SOFTWARE) ? base::FilePath(FILE_PATH_LITERAL( "mask_as_blending_rotated_circle_underflow.png")) : base::FilePath(FILE_PATH_LITERAL(
diff --git a/cc/trees/layer_tree_host_pixeltest_readback.cc b/cc/trees/layer_tree_host_pixeltest_readback.cc index 98e88e99..26998bb1 100644 --- a/cc/trees/layer_tree_host_pixeltest_readback.cc +++ b/cc/trees/layer_tree_host_pixeltest_readback.cc
@@ -29,10 +29,10 @@ }; struct ReadbackTestConfig { - ReadbackTestConfig(LayerTreePixelTest::PixelTestType pixel_test_type_, + ReadbackTestConfig(LayerTreePixelTest::RendererType renderer_type_, ReadbackType readback_type_) - : pixel_test_type(pixel_test_type_), readback_type(readback_type_) {} - LayerTreePixelTest::PixelTestType pixel_test_type; + : renderer_type(renderer_type_), readback_type(readback_type_) {} + LayerTreePixelTest::RendererType renderer_type; ReadbackType readback_type; }; @@ -43,9 +43,7 @@ LayerTreeHostReadbackPixelTest() : insert_copy_request_after_frame_count_(0) {} - LayerTreePixelTest::PixelTestType pixel_test_type() const { - return GetParam().pixel_test_type; - } + RendererType renderer_type() const { return GetParam().renderer_type; } ReadbackType readback_type() const { return GetParam().readback_type; } @@ -59,7 +57,7 @@ &LayerTreeHostReadbackPixelTest::ReadbackResultAsBitmap, base::Unretained(this))); } else { - DCHECK_NE(test_type_, PIXEL_TEST_SOFTWARE); + DCHECK_NE(renderer_type_, RENDERER_SOFTWARE); request = std::make_unique<viz::CopyOutputRequest>( viz::CopyOutputRequest::ResultFormat::RGBA_TEXTURE, base::BindOnce( @@ -130,7 +128,7 @@ CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); background->AddChild(green); - RunPixelTest(pixel_test_type(), background, + RunPixelTest(renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("green.png"))); } @@ -146,7 +144,7 @@ CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); green->AddChild(blue); - RunPixelTest(pixel_test_type(), background, + RunPixelTest(renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); } @@ -159,7 +157,7 @@ background->AddChild(green); RunPixelTestWithReadbackTarget( - pixel_test_type(), background, green.get(), + renderer_type(), background, green.get(), base::FilePath(FILE_PATH_LITERAL("green.png"))); } @@ -172,7 +170,7 @@ background->AddChild(green); RunPixelTestWithReadbackTarget( - pixel_test_type(), background, green.get(), + renderer_type(), background, green.get(), base::FilePath(FILE_PATH_LITERAL("green_small.png"))); } @@ -189,7 +187,7 @@ green->AddChild(blue); RunPixelTestWithReadbackTarget( - pixel_test_type(), background, green.get(), + renderer_type(), background, green.get(), base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } @@ -211,7 +209,7 @@ copy_subrect_ = gfx::Rect(0, 0, 100, 100); RunPixelTestWithReadbackTarget( - pixel_test_type(), background, target.get(), + renderer_type(), background, target.get(), base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } @@ -234,7 +232,7 @@ copy_subrect_ = gfx::Rect(50, 50, 100, 100); RunPixelTestWithReadbackTarget( - pixel_test_type(), background, target.get(), + renderer_type(), background, target.get(), base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } @@ -252,7 +250,7 @@ hidden_target->AddChild(blue); RunPixelTestWithReadbackTarget( - pixel_test_type(), background, hidden_target.get(), + renderer_type(), background, hidden_target.get(), base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); } @@ -272,7 +270,7 @@ hidden_target->RequestCopyOfOutput( viz::CopyOutputRequest::CreateStubForTesting()); - RunPixelTest(pixel_test_type(), background, + RunPixelTest(renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("black.png"))); } @@ -292,7 +290,7 @@ copy_subrect_ = gfx::Rect(50, 50, 100, 100); RunPixelTest( - pixel_test_type(), background, + renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } @@ -312,7 +310,7 @@ copy_subrect_ = gfx::Rect(25, 25, 100, 100); RunPixelTestWithReadbackTarget( - pixel_test_type(), background, green.get(), + renderer_type(), background, green.get(), base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } @@ -334,7 +332,7 @@ insert_copy_request_after_frame_count_ = 1; RunPixelTestWithReadbackTarget( - pixel_test_type(), background, target.get(), + renderer_type(), background, target.get(), base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } @@ -357,7 +355,7 @@ insert_copy_request_after_frame_count_ = 1; RunPixelTestWithReadbackTarget( - pixel_test_type(), background, target.get(), + renderer_type(), background, target.get(), base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } @@ -377,7 +375,7 @@ green->AddChild(blue); RunPixelTestWithReadbackTarget( - pixel_test_type(), background, green.get(), + renderer_type(), background, green.get(), base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); } @@ -395,7 +393,7 @@ background->AddChild(blue); RunPixelTestWithReadbackTarget( - pixel_test_type(), background, background.get(), + renderer_type(), background, background.get(), base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); } @@ -413,7 +411,7 @@ viz::CopyOutputRequest::CreateStubForTesting()); RunPixelTestWithReadbackTarget( - pixel_test_type(), background, background.get(), + renderer_type(), background, background.get(), base::FilePath(FILE_PATH_LITERAL("green.png"))); } @@ -423,14 +421,10 @@ , LayerTreeHostReadbackPixelTest, ::testing::Values( - ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_SOFTWARE, - READBACK_BITMAP), - ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, - READBACK_TEXTURE), - ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, - READBACK_BITMAP), - ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_SKIA_GL, - READBACK_BITMAP))); + ReadbackTestConfig(LayerTreeTest::RENDERER_SOFTWARE, READBACK_BITMAP), + ReadbackTestConfig(LayerTreeTest::RENDERER_GL, READBACK_TEXTURE), + ReadbackTestConfig(LayerTreeTest::RENDERER_GL, READBACK_BITMAP), + ReadbackTestConfig(LayerTreeTest::RENDERER_SKIA_GL, READBACK_BITMAP))); class LayerTreeHostReadbackDeviceScalePixelTest : public LayerTreeHostReadbackPixelTest { @@ -485,7 +479,7 @@ copy_subrect_ = gfx::Rect(25, 25, 50, 50); device_scale_factor_ = 2.f; RunPixelTest( - pixel_test_type(), background, + renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } @@ -513,7 +507,7 @@ copy_subrect_ = gfx::Rect(25, 25, 50, 50); device_scale_factor_ = 2.f; RunPixelTestWithReadbackTarget( - pixel_test_type(), background, green.get(), + renderer_type(), background, green.get(), base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } @@ -523,14 +517,10 @@ , LayerTreeHostReadbackDeviceScalePixelTest, ::testing::Values( - ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_SOFTWARE, - READBACK_BITMAP), - ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, - READBACK_TEXTURE), - ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, - READBACK_BITMAP), - ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_SKIA_GL, - READBACK_BITMAP))); + ReadbackTestConfig(LayerTreeTest::RENDERER_SOFTWARE, READBACK_BITMAP), + ReadbackTestConfig(LayerTreeTest::RENDERER_GL, READBACK_TEXTURE), + ReadbackTestConfig(LayerTreeTest::RENDERER_GL, READBACK_BITMAP), + ReadbackTestConfig(LayerTreeTest::RENDERER_SKIA_GL, READBACK_BITMAP))); class LayerTreeHostReadbackColorSpacePixelTest : public LayerTreeHostReadbackPixelTest { @@ -564,7 +554,7 @@ background->SetIsDrawable(true); // The sRGB green should be converted into P3. - RunPixelTest(pixel_test_type(), background, + RunPixelTest(renderer_type(), background, base::FilePath(FILE_PATH_LITERAL("srgb_green_in_p3.png"))); } @@ -574,14 +564,10 @@ , LayerTreeHostReadbackColorSpacePixelTest, ::testing::Values( - ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_SOFTWARE, - READBACK_BITMAP), - ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, - READBACK_TEXTURE), - ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, - READBACK_BITMAP), - ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_SKIA_GL, - READBACK_BITMAP))); + ReadbackTestConfig(LayerTreeTest::RENDERER_SOFTWARE, READBACK_BITMAP), + ReadbackTestConfig(LayerTreeTest::RENDERER_GL, READBACK_TEXTURE), + ReadbackTestConfig(LayerTreeTest::RENDERER_GL, READBACK_BITMAP), + ReadbackTestConfig(LayerTreeTest::RENDERER_SKIA_GL, READBACK_BITMAP))); } // namespace } // namespace cc
diff --git a/cc/trees/layer_tree_host_pixeltest_scrollbars.cc b/cc/trees/layer_tree_host_pixeltest_scrollbars.cc index 1c94cf3..d029d3d 100644 --- a/cc/trees/layer_tree_host_pixeltest_scrollbars.cc +++ b/cc/trees/layer_tree_host_pixeltest_scrollbars.cc
@@ -95,7 +95,7 @@ layer->SetBounds(gfx::Size(200, 200)); background->AddChild(layer); - RunPixelTest(PIXEL_TEST_GL, background, + RunPixelTest(RENDERER_GL, background, base::FilePath(FILE_PATH_LITERAL("spiral.png"))); } @@ -114,7 +114,7 @@ layer->SetBounds(gfx::Size(100, 100)); background->AddChild(layer); - RunPixelTest(PIXEL_TEST_GL, background, + RunPixelTest(RENDERER_GL, background, base::FilePath(FILE_PATH_LITERAL("spiral_double_scale.png"))); } @@ -135,7 +135,7 @@ scale_transform.Scale(2.0, 2.0); layer->SetTransform(scale_transform); - RunPixelTest(PIXEL_TEST_GL, background, + RunPixelTest(RENDERER_GL, background, base::FilePath(FILE_PATH_LITERAL("spiral_double_scale.png"))); } @@ -179,7 +179,7 @@ scale_transform.Scale(scale, scale); layer->SetTransform(scale_transform); - RunPixelTest(PIXEL_TEST_GL, background, + RunPixelTest(RENDERER_GL, background, base::FilePath(FILE_PATH_LITERAL("spiral_64_scale.png"))); } @@ -261,7 +261,7 @@ layer->SetPosition(gfx::PointF(185, 10)); RunPixelTest( - PIXEL_TEST_GL, background, + RENDERER_GL, background, base::FilePath(FILE_PATH_LITERAL("overlay_scrollbar_scaled_up.png"))); } @@ -285,7 +285,7 @@ layer->SetPosition(gfx::PointF(185, 10)); RunPixelTest( - PIXEL_TEST_GL, background, + RENDERER_GL, background, base::FilePath(FILE_PATH_LITERAL("overlay_scrollbar_scaled_down.png"))); }
diff --git a/cc/trees/layer_tree_host_pixeltest_synchronous.cc b/cc/trees/layer_tree_host_pixeltest_synchronous.cc index 8785df24..fac28b3 100644 --- a/cc/trees/layer_tree_host_pixeltest_synchronous.cc +++ b/cc/trees/layer_tree_host_pixeltest_synchronous.cc
@@ -18,7 +18,7 @@ class LayerTreeHostSynchronousPixelTest : public LayerTreePixelTest, - public ::testing::WithParamInterface<LayerTreePixelTest::PixelTestType> { + public ::testing::WithParamInterface<LayerTreeTest::RendererType> { protected: void InitializeSettings(LayerTreeSettings* settings) override { LayerTreePixelTest::InitializeSettings(settings); @@ -27,7 +27,7 @@ settings->use_zero_copy = use_zero_copy_; } - LayerTreePixelTest::PixelTestType pixel_test_type() { return GetParam(); } + LayerTreeTest::RendererType renderer_type() { return GetParam(); } void BeginTest() override { LayerTreePixelTest::BeginTest(); @@ -46,7 +46,7 @@ root->SetBounds(bounds); root->SetIsDrawable(true); - RunSingleThreadedPixelTest(pixel_test_type(), root, + RunSingleThreadedPixelTest(renderer_type(), root, base::FilePath(FILE_PATH_LITERAL("green.png"))); } @@ -54,11 +54,10 @@ bool use_zero_copy_ = false; }; -INSTANTIATE_TEST_SUITE_P( - , - LayerTreeHostSynchronousPixelTest, - ::testing::Values(LayerTreePixelTest::PIXEL_TEST_GL, - LayerTreePixelTest::PIXEL_TEST_SKIA_GL)); +INSTANTIATE_TEST_SUITE_P(, + LayerTreeHostSynchronousPixelTest, + ::testing::Values(LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL)); TEST_P(LayerTreeHostSynchronousPixelTest, OneContentLayerZeroCopy) { use_zero_copy_ = true;
diff --git a/cc/trees/layer_tree_host_pixeltest_tiles.cc b/cc/trees/layer_tree_host_pixeltest_tiles.cc index 8ed832e..91788324 100644 --- a/cc/trees/layer_tree_host_pixeltest_tiles.cc +++ b/cc/trees/layer_tree_host_pixeltest_tiles.cc
@@ -90,7 +90,7 @@ base::FilePath file_name) { raster_mode_ = mode; - PixelTestType test_type = PIXEL_TEST_SOFTWARE; + RendererType renderer_type = RENDERER_SOFTWARE; switch (mode) { case PARTIAL_ONE_COPY: case FULL_ONE_COPY: @@ -98,17 +98,17 @@ case FULL_GPU: case PARTIAL_GPU_LOW_BIT_DEPTH: case FULL_GPU_LOW_BIT_DEPTH: - test_type = PIXEL_TEST_GL; + renderer_type = RENDERER_GL; break; case PARTIAL_BITMAP: case FULL_BITMAP: - test_type = PIXEL_TEST_SOFTWARE; + renderer_type = RENDERER_SOFTWARE; } if (threaded) - RunPixelTest(test_type, content_root, file_name); + RunPixelTest(renderer_type, content_root, file_name); else - RunSingleThreadedPixelTest(test_type, content_root, file_name); + RunSingleThreadedPixelTest(renderer_type, content_root, file_name); } base::FilePath ref_file_;
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 54f5029..f10dada 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc
@@ -8683,7 +8683,7 @@ void InitializeSettings(LayerTreeSettings* settings) override { LayerTreeHostTestImageAnimationSynchronousScheduling::InitializeSettings( settings); - use_software_renderer_ = true; + renderer_type_ = RENDERER_SOFTWARE; } void AfterTest() override {
diff --git a/cc/trees/layer_tree_host_unittest_copyrequest.cc b/cc/trees/layer_tree_host_unittest_copyrequest.cc index be57da1..0034598 100644 --- a/cc/trees/layer_tree_host_unittest_copyrequest.cc +++ b/cc/trees/layer_tree_host_unittest_copyrequest.cc
@@ -26,9 +26,8 @@ namespace cc { namespace { -enum CopyRequestTestType { TEST_GL, TEST_SKIA, TEST_SOFTWARE }; - -auto CombineWithCompositorModes(const std::vector<CopyRequestTestType>& types) { +auto CombineWithCompositorModes( + const std::vector<LayerTreeTest::RendererType>& types) { return ::testing::Combine(::testing::ValuesIn(types), ::testing::Values(CompositorMode::SINGLE_THREADED, CompositorMode::THREADED)); @@ -37,20 +36,13 @@ class LayerTreeHostCopyRequestTest : public LayerTreeTest, public ::testing::WithParamInterface< - ::testing::tuple<CopyRequestTestType, CompositorMode>> { + ::testing::tuple<LayerTreeTest::RendererType, CompositorMode>> { public: - CopyRequestTestType test_type() const { - return ::testing::get<0>(GetParam()); - } + RendererType renderer_type() const { return ::testing::get<0>(GetParam()); } CompositorMode compositor_mode() const { return ::testing::get<1>(GetParam()); } - - void InitializeFromTestType() { - use_skia_renderer_ = test_type() == TEST_SKIA; - use_software_renderer_ = test_type() == TEST_SOFTWARE; - } }; class LayerTreeHostCopyRequestTestMultipleRequests @@ -167,13 +159,15 @@ scoped_refptr<FakePictureLayer> grand_child; }; -INSTANTIATE_TEST_SUITE_P(, - LayerTreeHostCopyRequestTestMultipleRequests, - CombineWithCompositorModes({TEST_GL, TEST_SKIA, - TEST_SOFTWARE})); +INSTANTIATE_TEST_SUITE_P( + , + LayerTreeHostCopyRequestTestMultipleRequests, + CombineWithCompositorModes({LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL, + LayerTreeTest::RENDERER_SOFTWARE})); TEST_P(LayerTreeHostCopyRequestTestMultipleRequests, Test) { - InitializeFromTestType(); + renderer_type_ = renderer_type(); RunTest(compositor_mode()); } @@ -202,12 +196,14 @@ } }; -INSTANTIATE_TEST_SUITE_P(, - LayerTreeHostCopyRequestTestMultipleRequestsOutOfOrder, - CombineWithCompositorModes({TEST_GL, TEST_SKIA})); +INSTANTIATE_TEST_SUITE_P( + , + LayerTreeHostCopyRequestTestMultipleRequestsOutOfOrder, + CombineWithCompositorModes({LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL})); TEST_P(LayerTreeHostCopyRequestTestMultipleRequestsOutOfOrder, Test) { - InitializeFromTestType(); + renderer_type_ = renderer_type(); RunTest(compositor_mode()); } @@ -264,12 +260,14 @@ scoped_refptr<FakePictureLayer> layer_; }; -INSTANTIATE_TEST_SUITE_P(, - LayerTreeHostCopyRequestCompletionCausesCommit, - CombineWithCompositorModes({TEST_GL, TEST_SKIA})); +INSTANTIATE_TEST_SUITE_P( + , + LayerTreeHostCopyRequestCompletionCausesCommit, + CombineWithCompositorModes({LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL})); TEST_P(LayerTreeHostCopyRequestCompletionCausesCommit, Test) { - InitializeFromTestType(); + renderer_type_ = renderer_type(); RunTest(compositor_mode()); } @@ -369,12 +367,14 @@ scoped_refptr<FakePictureLayer> impl_destroyed_; }; -INSTANTIATE_TEST_SUITE_P(, - LayerTreeHostCopyRequestTestLayerDestroyed, - CombineWithCompositorModes({TEST_GL, TEST_SKIA})); +INSTANTIATE_TEST_SUITE_P( + , + LayerTreeHostCopyRequestTestLayerDestroyed, + CombineWithCompositorModes({LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL})); TEST_P(LayerTreeHostCopyRequestTestLayerDestroyed, Test) { - InitializeFromTestType(); + renderer_type_ = renderer_type(); RunTest(compositor_mode()); } @@ -476,12 +476,14 @@ scoped_refptr<FakePictureLayer> copy_layer_; }; -INSTANTIATE_TEST_SUITE_P(, - LayerTreeHostCopyRequestTestInHiddenSubtree, - CombineWithCompositorModes({TEST_GL, TEST_SKIA})); +INSTANTIATE_TEST_SUITE_P( + , + LayerTreeHostCopyRequestTestInHiddenSubtree, + CombineWithCompositorModes({LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL})); TEST_P(LayerTreeHostCopyRequestTestInHiddenSubtree, Test) { - InitializeFromTestType(); + renderer_type_ = renderer_type(); RunTest(compositor_mode()); } @@ -599,10 +601,11 @@ INSTANTIATE_TEST_SUITE_P( , LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest, - CombineWithCompositorModes({TEST_GL, TEST_SKIA})); + CombineWithCompositorModes({LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL})); TEST_P(LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest, Test) { - InitializeFromTestType(); + renderer_type_ = renderer_type(); RunTest(compositor_mode()); } @@ -654,12 +657,14 @@ scoped_refptr<FakePictureLayer> copy_layer_; }; -INSTANTIATE_TEST_SUITE_P(, - LayerTreeHostCopyRequestTestClippedOut, - CombineWithCompositorModes({TEST_GL, TEST_SKIA})); +INSTANTIATE_TEST_SUITE_P( + , + LayerTreeHostCopyRequestTestClippedOut, + CombineWithCompositorModes({LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL})); TEST_P(LayerTreeHostCopyRequestTestClippedOut, Test) { - InitializeFromTestType(); + renderer_type_ = renderer_type(); RunTest(compositor_mode()); } @@ -719,12 +724,14 @@ scoped_refptr<FakePictureLayer> child_layer_; }; -INSTANTIATE_TEST_SUITE_P(, - LayerTreeHostCopyRequestTestScaledLayer, - CombineWithCompositorModes({TEST_GL, TEST_SKIA})); +INSTANTIATE_TEST_SUITE_P( + , + LayerTreeHostCopyRequestTestScaledLayer, + CombineWithCompositorModes({LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL})); TEST_P(LayerTreeHostCopyRequestTestScaledLayer, Test) { - InitializeFromTestType(); + renderer_type_ = renderer_type(); RunTest(compositor_mode()); } @@ -812,12 +819,14 @@ scoped_refptr<FakePictureLayer> copy_layer_; }; -INSTANTIATE_TEST_SUITE_P(, - LayerTreeHostTestAsyncTwoReadbacksWithoutDraw, - CombineWithCompositorModes({TEST_GL, TEST_SKIA})); +INSTANTIATE_TEST_SUITE_P( + , + LayerTreeHostTestAsyncTwoReadbacksWithoutDraw, + CombineWithCompositorModes({LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL})); TEST_P(LayerTreeHostTestAsyncTwoReadbacksWithoutDraw, Test) { - InitializeFromTestType(); + renderer_type_ = renderer_type(); RunTest(compositor_mode()); } @@ -950,12 +959,13 @@ }; // TODO(crbug.com/948128): Enable this test for SkiaRenderer. -INSTANTIATE_TEST_SUITE_P(, - LayerTreeHostCopyRequestTestDeleteSharedImage, - CombineWithCompositorModes({TEST_GL})); +INSTANTIATE_TEST_SUITE_P( + , + LayerTreeHostCopyRequestTestDeleteSharedImage, + CombineWithCompositorModes({LayerTreeTest::RENDERER_GL})); TEST_P(LayerTreeHostCopyRequestTestDeleteSharedImage, Test) { - InitializeFromTestType(); + renderer_type_ = renderer_type(); RunTest(compositor_mode()); } @@ -1082,12 +1092,13 @@ }; // TODO(crbug.com/948128): Enable this test for SkiaRenderer. -INSTANTIATE_TEST_SUITE_P(, - LayerTreeHostCopyRequestTestCreatesSharedImage, - CombineWithCompositorModes({TEST_GL})); +INSTANTIATE_TEST_SUITE_P( + , + LayerTreeHostCopyRequestTestCreatesSharedImage, + CombineWithCompositorModes({LayerTreeTest::RENDERER_GL})); TEST_P(LayerTreeHostCopyRequestTestCreatesSharedImage, Test) { - InitializeFromTestType(); + renderer_type_ = renderer_type(); RunTest(compositor_mode()); } @@ -1170,12 +1181,14 @@ scoped_refptr<FakePictureLayer> copy_layer_; }; -INSTANTIATE_TEST_SUITE_P(, - LayerTreeHostCopyRequestTestDestroyBeforeCopy, - CombineWithCompositorModes({TEST_GL, TEST_SKIA})); +INSTANTIATE_TEST_SUITE_P( + , + LayerTreeHostCopyRequestTestDestroyBeforeCopy, + CombineWithCompositorModes({LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL})); TEST_P(LayerTreeHostCopyRequestTestDestroyBeforeCopy, Test) { - InitializeFromTestType(); + renderer_type_ = renderer_type(); RunTest(compositor_mode()); } @@ -1252,12 +1265,14 @@ scoped_refptr<FakePictureLayer> copy_layer_; }; -INSTANTIATE_TEST_SUITE_P(, - LayerTreeHostCopyRequestTestShutdownBeforeCopy, - CombineWithCompositorModes({TEST_GL, TEST_SKIA})); +INSTANTIATE_TEST_SUITE_P( + , + LayerTreeHostCopyRequestTestShutdownBeforeCopy, + CombineWithCompositorModes({LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL})); TEST_P(LayerTreeHostCopyRequestTestShutdownBeforeCopy, Test) { - InitializeFromTestType(); + renderer_type_ = renderer_type(); RunTest(compositor_mode()); } @@ -1388,10 +1403,11 @@ INSTANTIATE_TEST_SUITE_P( , LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest, - CombineWithCompositorModes({TEST_GL, TEST_SKIA})); + CombineWithCompositorModes({LayerTreeTest::RENDERER_GL, + LayerTreeTest::RENDERER_SKIA_GL})); TEST_P(LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest, Test) { - InitializeFromTestType(); + renderer_type_ = renderer_type(); RunTest(compositor_mode()); }
diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn index 17e97f3..6fe72d0 100644 --- a/chrome/android/BUILD.gn +++ b/chrome/android/BUILD.gn
@@ -2116,7 +2116,7 @@ if (!is_java_debug) { proguard_enabled = true } - enable_language_splits = enable_chrome_language_splits + enable_language_splits = true compress_shared_libraries = true min_sdk_version = 21 if (enable_vr) { @@ -2272,7 +2272,7 @@ verify_proguard_flags = true } } - enable_language_splits = enable_chrome_language_splits + enable_language_splits = true min_sdk_version = _min_sdk_version if (trichrome_synchronized_proguard) { @@ -2609,6 +2609,7 @@ "java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfAndroidBridge.java", "java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfEntry.java", "java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfInfoBar.java", + "java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfModelObserverBridge.java", "java/src/org/chromium/chrome/browser/sessions/SessionTabHelper.java", "java/src/org/chromium/chrome/browser/signin/IdentityServicesProvider.java", "java/src/org/chromium/chrome/browser/signin/ProfileDownloader.java",
diff --git a/chrome/android/chrome_java_sources.gni b/chrome/android/chrome_java_sources.gni index 290a307..8c78b1d3 100644 --- a/chrome/android/chrome_java_sources.gni +++ b/chrome/android/chrome_java_sources.gni
@@ -1348,6 +1348,7 @@ "java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfEntry.java", "java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfInfoBar.java", "java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfInfoBarController.java", + "java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfModelObserverBridge.java", "java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfShareActivity.java", "java/src/org/chromium/chrome/browser/services/AccountsChangedReceiver.java", "java/src/org/chromium/chrome/browser/services/AndroidEduAndChildAccountHelper.java",
diff --git a/chrome/android/chrome_junit_test_java_sources.gni b/chrome/android/chrome_junit_test_java_sources.gni index 65b5527b..d8a57fb 100644 --- a/chrome/android/chrome_junit_test_java_sources.gni +++ b/chrome/android/chrome_junit_test_java_sources.gni
@@ -49,6 +49,7 @@ "junit/src/org/chromium/chrome/browser/cookies/CanonicalCookieTest.java", "junit/src/org/chromium/chrome/browser/crash/LogcatExtractionRunnableUnitTest.java", "junit/src/org/chromium/chrome/browser/customtabs/CloseButtonNavigatorTest.java", + "junit/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProviderTest.java", "junit/src/org/chromium/chrome/browser/customtabs/NavigationInfoCaptureTriggerTest.java", "junit/src/org/chromium/chrome/browser/customtabs/content/CustomTabActivityContentTestEnvironment.java", "junit/src/org/chromium/chrome/browser/customtabs/content/CustomTabActivityNavigationControllerTest.java",
diff --git a/chrome/android/chrome_public_apk_tmpl.gni b/chrome/android/chrome_public_apk_tmpl.gni index b9f7a1f..6eea5be 100644 --- a/chrome/android/chrome_public_apk_tmpl.gni +++ b/chrome/android/chrome_public_apk_tmpl.gni
@@ -21,9 +21,6 @@ # Experimental only. Causes .dex files to be store in the APK uncompressed. # Only affects monochrome_public_apk and trichrome_chrome_apk. use_uncompressed_dex = false - - # Enable language splits in the Chrome bundles. - enable_chrome_language_splits = true } default_chrome_public_jinja_variables = [
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java index d7058b1..1a0703f6 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java
@@ -4,6 +4,9 @@ package org.chromium.chrome.browser.customtabs; +import static android.support.customtabs.CustomTabsIntent.COLOR_SCHEME_DARK; +import static android.support.customtabs.CustomTabsIntent.COLOR_SCHEME_LIGHT; + import static org.chromium.chrome.browser.customtabs.content.CustomTabActivityNavigationController.FinishReason.USER_NAVIGATION; import android.app.Activity; @@ -83,7 +86,6 @@ import org.chromium.chrome.browser.util.FeatureUtilities; import org.chromium.chrome.browser.util.IntentUtils; import org.chromium.content_public.browser.LoadUrlParams; -import org.chromium.content_public.browser.NavigationController; import org.chromium.content_public.browser.NavigationEntry; import org.chromium.content_public.browser.WebContents; @@ -212,7 +214,9 @@ public void performPreInflationStartup() { // Parse the data from the Intent before calling super to allow the Intent to customize // the Activity parameters, including the background of the page. - mIntentDataProvider = new CustomTabIntentDataProvider(getIntent(), this); + // Note that color scheme is fixed for the lifetime of Activity: if the system setting + // changes, we recreate the activity. + mIntentDataProvider = new CustomTabIntentDataProvider(getIntent(), this, getColorScheme()); super.performPreInflationStartup(); mTabProvider.addObserver(mTabChangeObserver); @@ -228,6 +232,15 @@ initalizePreviewsObserver(); } + private int getColorScheme() { + if (mNightModeStateController != null) { + return mNightModeStateController.isInNightMode() ? COLOR_SCHEME_DARK : + COLOR_SCHEME_LIGHT; + } + assert false : "NightModeStateController should have been already created"; + return COLOR_SCHEME_LIGHT; + } + private void initializeIncognito() { mIncognitoTabHost = new IncognitoCustomTabHost(); IncognitoTabHostRegistry.getInstance().register(mIncognitoTabHost); @@ -239,14 +252,6 @@ } } - @Nullable - private NavigationController getNavigationController() { - if (getActivityTab() == null) return null; - - WebContents webContents = getActivityTab().getWebContents(); - return webContents == null ? null : webContents.getNavigationController(); - } - @Override public boolean shouldAllocateChildConnection() { return mTabController.shouldAllocateChildConnection();
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java index 79ffd006..282f2c6 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java
@@ -4,6 +4,9 @@ package org.chromium.chrome.browser.customtabs; +import static android.support.customtabs.CustomTabsIntent.COLOR_SCHEME_LIGHT; +import static android.support.customtabs.CustomTabsIntent.COLOR_SCHEME_SYSTEM; + import android.app.PendingIntent; import android.app.PendingIntent.CanceledException; import android.content.ComponentName; @@ -16,7 +19,9 @@ import android.net.Uri; import android.os.Bundle; import android.support.annotation.IntDef; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.customtabs.CustomTabColorSchemeParams; import android.support.customtabs.CustomTabsIntent; import android.support.customtabs.CustomTabsSessionToken; import android.support.customtabs.TrustedWebUtils; @@ -53,6 +58,10 @@ /** * A model class that parses the incoming intent for Custom Tabs specific customization data. + * + * Lifecycle: is activity-scoped, i.e. one instance per CustomTabActivity instance. Must be + * re-created when color scheme changes, which happens automatically since color scheme change leads + * to activity re-creation. */ public class CustomTabIntentDataProvider extends BrowserSessionDataProvider { private static final String TAG = "CustomTabIntentData"; @@ -245,9 +254,25 @@ } /** - * Constructs a {@link CustomTabIntentDataProvider}. + * Deprecated: use the constructor below. + * TODO(pshmakov): remove once no longer used downstream. */ + @Deprecated public CustomTabIntentDataProvider(Intent intent, Context context) { + this(intent, context, COLOR_SCHEME_LIGHT); + } + + /** + * Constructs a {@link CustomTabIntentDataProvider}. + * + * The colorScheme parameter specifies which color scheme the Custom Tab should use. + * It can currently be either {@link CustomTabsIntent#COLOR_SCHEME_LIGHT} or + * {@link CustomTabsIntent#COLOR_SCHEME_DARK}. + * If Custom Tab was launched with {@link CustomTabsIntent#COLOR_SCHEME_SYSTEM}, colorScheme + * must reflect the current system setting. When the system setting changes, a new + * CustomTabIntentDataProvider object must be created. + */ + public CustomTabIntentDataProvider(Intent intent, Context context, int colorScheme) { super(intent); if (intent == null) assert false; @@ -261,9 +286,10 @@ mIsIncognito = isIncognitoForPaymentsFlow(intent) || isValidExternalIncognitoIntent(intent); + CustomTabColorSchemeParams params = getColorSchemeParams(intent, colorScheme); retrieveCustomButtons(intent, context); - retrieveToolbarColor(intent, context); - retrieveBottomBarColor(intent); + retrieveToolbarColor(params, context); + retrieveBottomBarColor(params); mInitialBackgroundColor = retrieveInitialBackgroundColor(intent); mEnableUrlBarHiding = IntentUtils.safeGetBooleanExtra( @@ -355,6 +381,22 @@ } } + @NonNull + private CustomTabColorSchemeParams getColorSchemeParams(Intent intent, int colorScheme) { + if (colorScheme == COLOR_SCHEME_SYSTEM) { + assert false : "Color scheme passed to IntentDataProvider should not be " + + "COLOR_SCHEME_SYSTEM"; + colorScheme = COLOR_SCHEME_LIGHT; + } + try { + return CustomTabsIntent.getColorSchemeParams(intent, colorScheme); + } catch (Throwable e) { + // Catch any un-parceling exceptions, like in IntentUtils#safe* methods + Log.e(TAG, "Failed to parse CustomTabColorSchemeParams"); + return new CustomTabColorSchemeParams.Builder().build(); // Empty params + } + } + private boolean isIncognitoForPaymentsFlow(Intent intent) { return incognitoRequested(intent) && isTrustedIntent() && isOpenedByChrome() && isForPaymentRequest(); @@ -435,28 +477,27 @@ /** * Processes the color passed from the client app and updates {@link #mToolbarColor}. */ - private void retrieveToolbarColor(Intent intent, Context context) { + private void retrieveToolbarColor(CustomTabColorSchemeParams schemeParams, Context context) { int defaultColor = ColorUtils.getDefaultThemeColor(context.getResources(), isIncognito()); if (isIncognito()) { mToolbarColor = defaultColor; return; // Don't allow toolbar color customization for incognito tabs. } - int color = IntentUtils.safeGetIntExtra( - intent, CustomTabsIntent.EXTRA_TOOLBAR_COLOR, defaultColor); + int color = schemeParams.toolbarColor != null ? schemeParams.toolbarColor : defaultColor; mToolbarColor = removeTransparencyFromColor(color); } /** - * Must be called after calling {@link #retrieveToolbarColor(Intent, Context)}. + * Must be called after calling {@link #retrieveToolbarColor}. */ - private void retrieveBottomBarColor(Intent intent) { + private void retrieveBottomBarColor(CustomTabColorSchemeParams schemeParams) { if (isIncognito()) { mBottomBarColor = mToolbarColor; return; } int defaultColor = mToolbarColor; - int color = IntentUtils.safeGetIntExtra( - intent, CustomTabsIntent.EXTRA_SECONDARY_TOOLBAR_COLOR, defaultColor); + int color = schemeParams.secondaryToolbarColor != null ? schemeParams.secondaryToolbarColor + : defaultColor; mBottomBarColor = removeTransparencyFromColor(color); }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryCardView.java b/chrome/android/java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryCardView.java index e2ba055..43c4878c 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryCardView.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryCardView.java
@@ -4,7 +4,6 @@ package org.chromium.chrome.browser.explore_sites; -import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Rect; @@ -40,6 +39,7 @@ private static final int MAX_TILE_COUNT = 8; private static final int MAX_ROWS = 2; + private final ExploreSitesSiteViewBinder mSiteViewBinder; private TextView mTitleView; private TileGridLayout mTileView; private RoundedIconGenerator mIconGenerator; @@ -148,6 +148,11 @@ } } + protected CategoryCardInteractionDelegate createInteractionDelegate(PropertyModel model) { + return new CategoryCardInteractionDelegate( + model.get(ExploreSitesSite.URL_KEY), model.get(ExploreSitesSite.TILE_INDEX_KEY)); + } + // We use the MVC paradigm for the site tiles inside the category card. We don't use the MVC // paradigm for the category card view itself since it is mismatched to the needs of the // recycler view that we use for category cards. The controller for MVC is actually here, the @@ -172,16 +177,12 @@ view.setOnFocusChangeListener(interactionDelegate); } } - - protected CategoryCardInteractionDelegate createInteractionDelegate(PropertyModel model) { - return new CategoryCardInteractionDelegate(model.get(ExploreSitesSite.URL_KEY), - model.get(ExploreSitesSite.TILE_INDEX_KEY)); - } } public ExploreSitesCategoryCardView(Context context, AttributeSet attrs) { super(context, attrs); mModelChangeProcessors = new ArrayList<>(MAX_TILE_COUNT); + mSiteViewBinder = new ExploreSitesSiteViewBinder(); } @Override @@ -254,8 +255,8 @@ siteModel.set(ExploreSitesSite.TILE_INDEX_KEY, tileIndex); - mModelChangeProcessors.add(PropertyModelChangeProcessor.create( - siteModel, tileView, createViewBinder((Activity) getContext()))); + mModelChangeProcessors.add( + PropertyModelChangeProcessor.create(siteModel, tileView, mSiteViewBinder)); // Fetch icon if not present already. if (siteModel.get(ExploreSitesSite.ICON_KEY) == null) { @@ -286,8 +287,4 @@ RecordHistogram.recordLinearCountHistogram("ExploreSites.SiteTilesClickIndex", cardIndex * MAX_TILE_COUNT + tileIndex, 1, 100, 100); } - - protected ExploreSitesSiteViewBinder createViewBinder(Activity activity) { - return new ExploreSitesSiteViewBinder(); - } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfModelObserverBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfModelObserverBridge.java new file mode 100644 index 0000000..d8a8e79 --- /dev/null +++ b/chrome/android/java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfModelObserverBridge.java
@@ -0,0 +1,160 @@ +// Copyright 2019 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. + +package org.chromium.chrome.browser.send_tab_to_self; + +import org.chromium.base.annotations.CalledByNative; +import org.chromium.base.annotations.JCaller; +import org.chromium.base.annotations.JNINamespace; +import org.chromium.base.annotations.NativeMethods; +import org.chromium.chrome.browser.profiles.Profile; + +import java.util.ArrayList; +import java.util.List; + +/** + * Bridge to interface with send_tab_to_self_model_observer_bridge which interacts with the + * corresponding model observer. This is used by the SendTabToSelfInfobarController to listen + * for model changes and show an infobar to the user. + */ +@JNINamespace("send_tab_to_self") +public class SendTabToSelfModelObserverBridge { + private long mNativeModelObserverBridge; + + private final List<SendTabToSelfObserver> mObservers; + + /** + * Java version of the observer that implementors can use to listen for model changes. + */ + public abstract class SendTabToSelfObserver { + /** + * Corresponds to the EntriesAddedRemotely function in SendTabToSelfModelObserver. + * @param entries Entries removed remotely. + */ + public abstract void entriesAddedRemotely(List<SendTabToSelfEntry> entries); + + /** + * Corresponds to the EntriesRemovedRemotely function in SendTabToSelfModelObserver. + * @param guids Guids of the entries that were removed. + */ + public abstract void entriesRemovedRemotely(List<String> guids); + + /** + * Corresponds to the ModelLoaded function in SendTabToSelfModelObserver. + * @return whether the model is loaded or not. + */ + public abstract boolean modelLoaded(); + } + + /** + * Constructs a new bridge for the profile provided. + * @param profile Profile to construct the bridge for. + */ + public SendTabToSelfModelObserverBridge(Profile profile) { + Natives jni = SendTabToSelfModelObserverBridgeJni.get(); + mNativeModelObserverBridge = jni.init(this, profile); + mObservers = new ArrayList<SendTabToSelfObserver>(); + } + + /** Destroys this instance so no further calls can be executed. */ + public void destroy() { + if (mNativeModelObserverBridge != 0) { + Natives jni = SendTabToSelfModelObserverBridgeJni.get(); + jni.destroy(this, mNativeModelObserverBridge); + mNativeModelObserverBridge = 0; + } + } + + /** + * Adds an observer to listen for model changes. + * @param observer Observer to listen for model changes. + */ + public void addObserver(SendTabToSelfObserver observer) { + mObservers.add(observer); + } + + /** + * Removes an observer to no longer listen for model changes. + * @param observer Observer to remove. + */ + public void removeObserver(SendTabToSelfObserver observer) { + mObservers.remove(observer); + } + + /** + * @return An empty array list to be populated by native code with SendTabToSelfEntries. + */ + @CalledByNative + private List<SendTabToSelfEntry> createEmptyJavaEntryList() { + return new ArrayList<SendTabToSelfEntry>(); + } + + /** + * Adds an entry to the list of entries. Called by native code. + * @param entries List to add to. + * @param entry Entry to add to the list. + */ + @CalledByNative + private void addToEntryList(List<SendTabToSelfEntry> entries, SendTabToSelfEntry entry) { + entries.add(entry); + } + + /** + * @return An empty array list to be populated by native code with Guids (strings). + */ + @CalledByNative + private List<String> createEmptyJavaGuidList() { + return new ArrayList<String>(); + } + + /** + * Adds a guid to the list of Guids. Called by native code. + * @param guids List to add to. + * @param guid Guid to add to the list. + */ + @CalledByNative + private void addToGuidList(List<String> guids, String guid) { + guids.add(guid); + } + + /** + * Called by native code in send_tab_to_self_model_observer when the model has a new entry. + * @param newEntries The new entries pushed by the model. + */ + @CalledByNative + private void entriesAddedRemotely(List<SendTabToSelfEntry> newEntries) { + for (SendTabToSelfObserver observer : mObservers) { + observer.entriesAddedRemotely(newEntries); + } + } + + /** + * Called by the native code in send_tab_to_self_model_observer when the model has a deletion + * update. + * @param guids Guids corresponding to the entries that were removed. + */ + @CalledByNative + private void entriesRemovedRemotely(List<String> guids) { + for (SendTabToSelfObserver observer : mObservers) { + observer.entriesRemovedRemotely(guids); + } + } + /** + * Called by the native code in send_tab_to_self_model_observer when the model is loaded. + */ + @CalledByNative + private void modelLoaded() { + for (SendTabToSelfObserver observer : mObservers) { + observer.modelLoaded(); + } + } + + @NativeMethods + interface Natives { + long init(@JCaller SendTabToSelfModelObserverBridge bridge, Profile profile); + + void destroy(@JCaller SendTabToSelfModelObserverBridge bridge, + long nativeSendTabToSelfModelObserverBridge); + } +}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/AddToHomescreenDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/AddToHomescreenDialog.java index fe78b8c2..4b1a8b9 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/AddToHomescreenDialog.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/AddToHomescreenDialog.java
@@ -5,7 +5,7 @@ package org.chromium.chrome.browser.webapps; import android.annotation.TargetApi; -import android.app.Activity; +import android.content.Context; import android.content.DialogInterface; import android.graphics.Bitmap; import android.graphics.drawable.Icon; @@ -14,6 +14,7 @@ import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; +import android.view.LayoutInflater; import android.view.View; import android.widget.Button; import android.widget.EditText; @@ -72,13 +73,13 @@ private RatingBar mAppRatingBar; private ImageView mPlayLogoView; - private Activity mActivity; + private Context mContext; private Delegate mDelegate; private boolean mHasIcon; - public AddToHomescreenDialog(Activity activity, Delegate delegate) { - mActivity = activity; + public AddToHomescreenDialog(Context context, Delegate delegate) { + mContext = context; mDelegate = delegate; } @@ -89,12 +90,11 @@ /** * Shows the dialog for adding a shortcut to the home screen. - * @param activity The current activity in which to create the dialog. */ public void show() { - View view = mActivity.getLayoutInflater().inflate(R.layout.add_to_homescreen_dialog, null); + View view = LayoutInflater.from(mContext).inflate(R.layout.add_to_homescreen_dialog, null); AlertDialog.Builder builder = - new AlertDialog.Builder(mActivity, R.style.Theme_Chromium_AlertDialog) + new AlertDialog.Builder(mContext, R.style.Theme_Chromium_AlertDialog) .setTitle(AppBannerManager.getHomescreenLanguageOption()) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override @@ -154,7 +154,7 @@ mDialog.setView(view); mDialog.setButton(DialogInterface.BUTTON_POSITIVE, - mActivity.getResources().getString(R.string.add), + mContext.getResources().getString(R.string.add), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { @@ -222,7 +222,7 @@ // Update the text on the primary button. Button button = mDialog.getButton(DialogInterface.BUTTON_POSITIVE); button.setText(installText); - button.setContentDescription(mActivity.getString( + button.setContentDescription(mContext.getString( R.string.app_banner_view_native_app_install_accessibility, installText)); // Clicking on the app title or the icon will open the Play Store for more details.
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/sync/BookmarksTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/sync/BookmarksTest.java index 4d89d3e..960cd3f 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/sync/BookmarksTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/sync/BookmarksTest.java
@@ -16,6 +16,7 @@ import org.junit.runner.RunWith; import org.chromium.base.test.util.CommandLineFlags; +import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.Feature; import org.chromium.chrome.browser.ChromeSwitches; import org.chromium.chrome.browser.bookmarks.BookmarkBridge; @@ -384,6 +385,7 @@ @Test @LargeTest @Feature({"Sync"}) + @DisabledTest(message = "https://crbug.com/964342") public void testDisabledNoDownloadBookmark() throws Exception { mSyncTestRule.disableDataType(ModelType.BOOKMARKS); addServerBookmark(TITLE, URL); @@ -395,6 +397,7 @@ @Test @LargeTest @Feature({"Sync"}) + @DisabledTest(message = "https://crbug.com/964342") public void testDisabledNoUploadBookmark() throws Exception { mSyncTestRule.disableDataType(ModelType.BOOKMARKS); addClientBookmark(TITLE, URL);
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProviderTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProviderTest.java new file mode 100644 index 0000000..91ce75c --- /dev/null +++ b/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProviderTest.java
@@ -0,0 +1,56 @@ +// Copyright 2019 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. + +package org.chromium.chrome.browser.customtabs; + +import static android.support.customtabs.CustomTabsIntent.COLOR_SCHEME_DARK; +import static android.support.customtabs.CustomTabsIntent.COLOR_SCHEME_LIGHT; + +import static org.junit.Assert.assertEquals; + +import android.content.Intent; +import android.support.customtabs.CustomTabColorSchemeParams; +import android.support.customtabs.CustomTabsIntent; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RuntimeEnvironment; +import org.robolectric.annotation.Config; + +import org.chromium.base.test.BaseRobolectricTestRunner; + +/** Tests for {@link CustomTabIntentDataProvider}. */ +@RunWith(BaseRobolectricTestRunner.class) +@Config(manifest = Config.NONE) +public class CustomTabIntentDataProviderTest { + + @Test + public void colorSchemeParametersAreRetrieved() { + CustomTabColorSchemeParams lightParams = new CustomTabColorSchemeParams.Builder() + .setToolbarColor(0xff0000ff) + .setSecondaryToolbarColor(0xff00aaff) + .build(); + CustomTabColorSchemeParams darkParams = new CustomTabColorSchemeParams.Builder() + .setToolbarColor(0xffff0000) + .setSecondaryToolbarColor(0xffff8800) + .build(); + Intent intent = new CustomTabsIntent.Builder() + .setColorSchemeParams(COLOR_SCHEME_LIGHT, lightParams) + .setColorSchemeParams(COLOR_SCHEME_DARK, darkParams) + .build() + .intent; + + CustomTabIntentDataProvider lightProvider = new CustomTabIntentDataProvider(intent, + RuntimeEnvironment.application, COLOR_SCHEME_LIGHT); + CustomTabIntentDataProvider darkProvider = new CustomTabIntentDataProvider(intent, + RuntimeEnvironment.application, COLOR_SCHEME_DARK); + + assertEquals((int) lightParams.toolbarColor, lightProvider.getToolbarColor()); + assertEquals((int) darkParams.toolbarColor, darkProvider.getToolbarColor()); + + assertEquals((int) lightParams.secondaryToolbarColor, lightProvider.getBottomBarColor()); + assertEquals((int) darkParams.secondaryToolbarColor, darkProvider.getBottomBarColor()); + } +} +
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/notifications/NotificationSystemStatusUtilUnitTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/notifications/NotificationSystemStatusUtilUnitTest.java index d36dcfd..5f28d33 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/notifications/NotificationSystemStatusUtilUnitTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/notifications/NotificationSystemStatusUtilUnitTest.java
@@ -10,7 +10,6 @@ import android.app.NotificationManager; import android.content.Context; -import android.os.Build; import org.junit.Test; import org.junit.runner.RunWith; @@ -41,20 +40,8 @@ is(NotificationSystemStatusUtil.APP_NOTIFICATIONS_STATUS_DISABLED)); } - @Config(sdk = Build.VERSION_CODES.JELLY_BEAN_MR2, manifest = Config.NONE) - @Test - public void testAppNotificationStatusPreKitKat() { - getShadowNotificationManager().setNotificationsEnabled(true); - assertThat(NotificationSystemStatusUtil.getAppNotificationStatus(), - is(NotificationSystemStatusUtil.APP_NOTIFICATIONS_STATUS_UNDETERMINABLE)); - - getShadowNotificationManager().setNotificationsEnabled(false); - assertThat(NotificationSystemStatusUtil.getAppNotificationStatus(), - is(NotificationSystemStatusUtil.APP_NOTIFICATIONS_STATUS_UNDETERMINABLE)); - } - private ShadowNotificationManager getShadowNotificationManager() { return shadowOf((NotificationManager) RuntimeEnvironment.application.getSystemService( Context.NOTIFICATION_SERVICE)); } -} \ No newline at end of file +}
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessAddToHomescreenManager.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessAddToHomescreenManager.java index 6cd2923..8fe926ac 100644 --- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessAddToHomescreenManager.java +++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessAddToHomescreenManager.java
@@ -4,7 +4,7 @@ package org.chromium.chrome.browser.touchless; -import android.app.Activity; +import android.content.Context; import android.graphics.Bitmap; import org.chromium.chrome.browser.ShortcutHelper; @@ -14,16 +14,14 @@ * Add to homescreen manager specifically for touchless devices. */ class TouchlessAddToHomescreenManager implements AddToHomescreenDialog.Delegate { - protected final Activity mActivity; + private final Context mContext; private final String mUrl; private final String mTitle; private final Bitmap mIconBitmap; - protected AddToHomescreenDialog mDialog; - public TouchlessAddToHomescreenManager( - Activity activity, String url, String title, Bitmap iconBitmap) { - mActivity = activity; + Context context, String url, String title, Bitmap iconBitmap) { + mContext = context; mUrl = url; mTitle = title; mIconBitmap = iconBitmap; @@ -31,10 +29,10 @@ // Starts the process of showing the dialog and adding the shortcut. public void start() { - mDialog = new AddToHomescreenDialog(mActivity, this); - mDialog.show(); - mDialog.onUserTitleAvailable(mTitle, mUrl, false); - mDialog.onIconAvailable(mIconBitmap); + AddToHomescreenDialog dialog = new AddToHomescreenDialog(mContext, this); + dialog.show(); + dialog.onUserTitleAvailable(mTitle, mUrl, false); + dialog.onIconAvailable(mIconBitmap); } @Override @@ -43,12 +41,8 @@ } @Override - public void onNativeAppDetailsRequested() { - return; - } + public void onNativeAppDetailsRequested() {} @Override - public void onDialogDismissed() { - mDialog = null; - } + public void onDialogDismissed() {} }
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessContextMenuManager.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessContextMenuManager.java index 2b346e7..19b3841 100644 --- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessContextMenuManager.java +++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessContextMenuManager.java
@@ -4,7 +4,6 @@ package org.chromium.chrome.browser.touchless; -import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.support.annotation.DrawableRes; @@ -34,11 +33,6 @@ */ public interface Delegate extends ContextMenuManager.Delegate { /** - * @return Activity associated with this delegate. Used to display prompts. - */ - Activity getActivity(); - - /** * @return Title associated with this delegate. */ String getTitle(); @@ -49,41 +43,42 @@ Bitmap getIconBitmap(); } + private final Context mContext; private PropertyModel mTouchlessMenuModel; private ModalDialogManager mModalDialogManager; - public TouchlessContextMenuManager(NativePageNavigationDelegate navigationDelegate, + public TouchlessContextMenuManager(Context context, + NativePageNavigationDelegate navigationDelegate, TouchEnabledDelegate touchEnabledDelegate, Runnable closeContextMenuCallback, String userActionPrefix) { super(navigationDelegate, touchEnabledDelegate, closeContextMenuCallback, userActionPrefix); + mContext = context; } /** * Creates PropertyModel for touchless context menu and displays it through modalDialogManager. * * @param modalDialogManager The ModalDialogManager to display context menu. - * @param context The Context used for loading resources (strings, drawables). * @param delegate Delegate defines filter for displayed menu items and behavior for selects * item. */ - public void showTouchlessContextMenu(ModalDialogManager modalDialogManager, Context context, - ContextMenuManager.Delegate delegate) { + public void showTouchlessContextMenu( + ModalDialogManager modalDialogManager, ContextMenuManager.Delegate delegate) { ArrayList<PropertyModel> menuItems = new ArrayList(); for (@ContextMenuItemId int itemId = 0; itemId < ContextMenuItemId.NUM_ENTRIES; itemId++) { if (!shouldShowItem(itemId, delegate)) continue; // Each menu item is assigned its own instance of TouchlessItemClickListener where // itemId of this item is maintained. - PropertyModel menuItem = buildMenuItem( - context, itemId, new TouchlessItemClickListener(delegate, itemId)); + PropertyModel menuItem = + buildMenuItem(itemId, new TouchlessItemClickListener(delegate, itemId)); menuItems.add(menuItem); } if (menuItems.size() == 0) return; PropertyModel[] menuItemsArray = new PropertyModel[menuItems.size()]; menuItemsArray = menuItems.toArray(menuItemsArray); - mTouchlessMenuModel = - buildMenuModel(context, delegate.getContextMenuTitle(), menuItemsArray); + mTouchlessMenuModel = buildMenuModel(delegate.getContextMenuTitle(), menuItemsArray); mModalDialogManager = modalDialogManager; mModalDialogManager.showDialog(mTouchlessMenuModel, ModalDialogManager.ModalDialogType.APP); @@ -105,9 +100,8 @@ if (itemId == ContextMenuItemId.ADD_TO_MY_APPS) { Delegate touchlessDelegate = (Delegate) delegate; TouchlessAddToHomescreenManager touchlessAddToHomescreenManager = - new TouchlessAddToHomescreenManager(touchlessDelegate.getActivity(), - touchlessDelegate.getUrl(), touchlessDelegate.getTitle(), - touchlessDelegate.getIconBitmap()); + new TouchlessAddToHomescreenManager(mContext, touchlessDelegate.getUrl(), + touchlessDelegate.getTitle(), touchlessDelegate.getIconBitmap()); touchlessAddToHomescreenManager.start(); return false; } @@ -143,18 +137,17 @@ * Builds PropertyModel for individual menu item. String for item's label is loaded from * resources by PropertyModel.Builder. */ - private PropertyModel buildMenuItem( - Context context, @ContextMenuItemId int itemId, OnClickListener listener) { + private PropertyModel buildMenuItem(@ContextMenuItemId int itemId, OnClickListener listener) { return new PropertyModel.Builder(DialogListItemProperties.ALL_KEYS) - .with(DialogListItemProperties.TEXT, context.getResources(), + .with(DialogListItemProperties.TEXT, mContext.getResources(), getResourceIdForMenuItem(itemId)) - .with(DialogListItemProperties.ICON, context, getIconIdForMenuItem(itemId)) + .with(DialogListItemProperties.ICON, mContext, getIconIdForMenuItem(itemId)) .with(DialogListItemProperties.CLICK_LISTENER, listener) .build(); } /** Builds PropertyModel for context menu from list of PropertyModels for individual items. */ - private PropertyModel buildMenuModel(Context context, String title, PropertyModel[] menuItems) { + private PropertyModel buildMenuModel(String title, PropertyModel[] menuItems) { PropertyModel.Builder builder = new PropertyModel.Builder(TouchlessDialogProperties.ALL_DIALOG_KEYS); ActionNames names = new ActionNames();
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessExploreSitesCategoryCardView.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessExploreSitesCategoryCardView.java index 6d982fb..7c91e7b 100644 --- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessExploreSitesCategoryCardView.java +++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessExploreSitesCategoryCardView.java
@@ -4,57 +4,30 @@ package org.chromium.chrome.browser.touchless; -import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.util.AttributeSet; -import org.chromium.chrome.browser.ChromeActivity; import org.chromium.chrome.browser.explore_sites.ExploreSitesCategoryCardView; import org.chromium.chrome.browser.explore_sites.ExploreSitesSite; import org.chromium.chrome.browser.native_page.ContextMenuManager; import org.chromium.ui.modelutil.PropertyModel; class TouchlessExploreSitesCategoryCardView extends ExploreSitesCategoryCardView { - public TouchlessExploreSitesCategoryCardView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - protected class TouchlessExploreSitesSiteViewBinder - extends ExploreSitesCategoryCardView.ExploreSitesSiteViewBinder { - Activity mActivity; - public TouchlessExploreSitesSiteViewBinder(Activity activity) { - mActivity = activity; - } - - @Override - protected ExploreSitesCategoryCardView.CategoryCardInteractionDelegate - createInteractionDelegate(PropertyModel model) { - return new TouchlessCategoryCardInteractionDelegate((ChromeActivity) mActivity, model); - } - } /** * Delegate that's aware of fields necessary for the touchless context menu. */ - protected class TouchlessCategoryCardInteractionDelegate - extends ExploreSitesCategoryCardView.CategoryCardInteractionDelegate + protected class TouchlessCategoryCardInteractionDelegate extends CategoryCardInteractionDelegate implements TouchlessContextMenuManager.Delegate { - private ChromeActivity mActivity; private PropertyModel mModel; - TouchlessCategoryCardInteractionDelegate(ChromeActivity activity, PropertyModel model) { + TouchlessCategoryCardInteractionDelegate(PropertyModel model) { super(model.get(ExploreSitesSite.URL_KEY), model.get(ExploreSitesSite.TILE_INDEX_KEY)); - mActivity = activity; mModel = model; } @Override - public Activity getActivity() { - return mActivity; - } - - @Override public String getTitle() { return mModel.get(ExploreSitesSite.TITLE_KEY); } @@ -76,8 +49,12 @@ } } + public TouchlessExploreSitesCategoryCardView(Context context, AttributeSet attrs) { + super(context, attrs); + } + @Override - protected ExploreSitesSiteViewBinder createViewBinder(Activity activity) { - return new TouchlessExploreSitesSiteViewBinder(activity); + protected CategoryCardInteractionDelegate createInteractionDelegate(PropertyModel model) { + return new TouchlessCategoryCardInteractionDelegate(model); } }
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessExploreSitesPage.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessExploreSitesPage.java index 23d398ba..8d9a7c20 100644 --- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessExploreSitesPage.java +++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessExploreSitesPage.java
@@ -19,23 +19,28 @@ * A variant of {@see ExploreSitesPage} that handles touchless context menus. */ public class TouchlessExploreSitesPage extends ExploreSitesPage { - private TouchlessContextMenuManager mTouchlessContextMenuManager; + private final ModalDialogManager mModalDialogManager; private Context mContext; - private ModalDialogManager mModalDialogManager; + private TouchlessContextMenuManager mTouchlessContextMenuManager; /** * Create a new instance of the explore sites page. */ public TouchlessExploreSitesPage(ChromeActivity activity, NativePageHost host) { super(activity, host); - mContext = activity; mModalDialogManager = activity.getModalDialogManager(); } @Override + protected void initialize(ChromeActivity activity, final NativePageHost host) { + mContext = activity; + super.initialize(activity, host); + } + + @Override protected ContextMenuManager createContextMenuManager(NativePageNavigationDelegate navDelegate, Runnable closeContextMenuCallback, String contextMenuUserActionPrefix) { - mTouchlessContextMenuManager = new TouchlessContextMenuManager(navDelegate, + mTouchlessContextMenuManager = new TouchlessContextMenuManager(mContext, navDelegate, (enabled) -> {}, closeContextMenuCallback, contextMenuUserActionPrefix); return mTouchlessContextMenuManager; } @@ -47,8 +52,7 @@ ContextMenuManager.Delegate delegate = ContextMenuManager.getDelegateFromFocusedView(focusedView); if (delegate == null) return; - mTouchlessContextMenuManager.showTouchlessContextMenu( - mModalDialogManager, mContext, delegate); + mTouchlessContextMenuManager.showTouchlessContextMenu(mModalDialogManager, delegate); } @Override
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessNewTabPage.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessNewTabPage.java index cfe7303..2878135 100644 --- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessNewTabPage.java +++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessNewTabPage.java
@@ -4,7 +4,6 @@ package org.chromium.chrome.browser.touchless; -import android.content.Context; import android.support.v4.view.ViewCompat; import android.view.LayoutInflater; import android.view.View; @@ -45,7 +44,6 @@ public class TouchlessNewTabPage extends BasicNativePage { private static final String TAG = "TouchlessNewTabPage"; - private Context mContext; private ModalDialogManager mModalDialogManager; private String mTitle; private int mBackgroundColor; @@ -68,7 +66,6 @@ protected void initialize(ChromeActivity activity, NativePageHost nativePageHost) { TraceEvent.begin(TAG); - mContext = activity; mModalDialogManager = activity.getModalDialogManager(); mTab = activity.getActivityTab(); Profile profile = mTab.getProfile(); @@ -127,7 +124,7 @@ // Don't store a direct reference to the activity, because it might change later if the tab // is reparented. Runnable closeContextMenuCallback = () -> mTab.getActivity().closeContextMenu(); - mContextMenuManager = new TouchlessContextMenuManager( + mContextMenuManager = new TouchlessContextMenuManager(activity, suggestionsUiDelegate.getNavigationDelegate(), mRecyclerView::setTouchEnabled, closeContextMenuCallback, NewTabPage.CONTEXT_MENU_USER_ACTION_PREFIX); mTab.getWindowAndroid().addContextMenuCloseListener(mContextMenuManager); @@ -198,6 +195,6 @@ ContextMenuManager.Delegate delegate = ContextMenuManager.getDelegateFromFocusedView(focusedView); if (delegate == null) return; - mContextMenuManager.showTouchlessContextMenu(mModalDialogManager, mContext, delegate); + mContextMenuManager.showTouchlessContextMenu(mModalDialogManager, delegate); } }
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessUiCoordinatorImpl.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessUiCoordinatorImpl.java index e9a6e39..1d35dc8 100644 --- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessUiCoordinatorImpl.java +++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessUiCoordinatorImpl.java
@@ -14,6 +14,7 @@ import org.chromium.chrome.browser.lifecycle.Destroyable; import org.chromium.chrome.browser.lifecycle.InflationObserver; import org.chromium.chrome.browser.lifecycle.NativeInitObserver; +import org.chromium.chrome.browser.lifecycle.PauseResumeWithNativeObserver; import org.chromium.chrome.browser.snackbar.SnackbarManager; import org.chromium.chrome.browser.touchless.dialog.TouchlessDialogPresenter; import org.chromium.chrome.browser.touchless.snackbar.BlackHoleSnackbarManager; @@ -25,8 +26,9 @@ import org.chromium.ui.modaldialog.ModalDialogManager.ModalDialogType; /** A coordinator for touchless UI. */ -public class TouchlessUiCoordinatorImpl - implements Destroyable, NativeInitObserver, InflationObserver, TouchlessUiCoordinator { +public class TouchlessUiCoordinatorImpl implements Destroyable, NativeInitObserver, + InflationObserver, PauseResumeWithNativeObserver, + TouchlessUiCoordinator { private ChromeActivity mActivity; private TouchlessModelCoordinator mModelCoordinator; @@ -76,6 +78,14 @@ } @Override + public void onResumeWithNative() { + mProgressBarCoordinator.onActivityResume(); + } + + @Override + public void onPauseWithNative() {} + + @Override public KeyEvent processKeyEvent(KeyEvent event) { if (mProgressBarCoordinator != null) mProgressBarCoordinator.onKeyEvent(); if (mModelCoordinator == null) return event;
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/ui/progressbar/ProgressBarCoordinator.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/ui/progressbar/ProgressBarCoordinator.java index 7150b47..916c9f04 100644 --- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/ui/progressbar/ProgressBarCoordinator.java +++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/ui/progressbar/ProgressBarCoordinator.java
@@ -28,6 +28,10 @@ mMediator = new ProgressBarMediator(model, activityTabProvider); } + public void onActivityResume() { + mMediator.onActivityResume(); + } + public void onKeyEvent() { mMediator.onKeyEvent(); }
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/ui/progressbar/ProgressBarMediator.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/ui/progressbar/ProgressBarMediator.java index d23520e..ca11fde 100644 --- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/ui/progressbar/ProgressBarMediator.java +++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/ui/progressbar/ProgressBarMediator.java
@@ -32,6 +32,10 @@ mModel = model; } + void onActivityResume() { + if (mModel.get(ProgressBarProperties.IS_ENABLED)) show(); + } + void onKeyEvent() { mCanHideProgressBar = true; hide();
diff --git a/chrome/android/webapk/libs/client/junit/src/org/chromium/webapk/lib/client/WebApkIdentityServiceClientTest.java b/chrome/android/webapk/libs/client/junit/src/org/chromium/webapk/lib/client/WebApkIdentityServiceClientTest.java index 42cdedc..2b21ef4c 100644 --- a/chrome/android/webapk/libs/client/junit/src/org/chromium/webapk/lib/client/WebApkIdentityServiceClientTest.java +++ b/chrome/android/webapk/libs/client/junit/src/org/chromium/webapk/lib/client/WebApkIdentityServiceClientTest.java
@@ -31,9 +31,9 @@ * Unit tests for {@link org.chromium.webapk.lib.client.WebApkIdentityServiceClient}. */ @RunWith(LocalRobolectricTestRunner.class) -@Config(manifest = Config.NONE, packageName = WebApkIdentityServiceClientTest.BROWSER_PACKAGE_NAME) +@Config(manifest = Config.NONE) public class WebApkIdentityServiceClientTest { - static final String BROWSER_PACKAGE_NAME = "browser"; + static final String BROWSER_PACKAGE_NAME = "org.chromium.test"; private static final String WEBAPK_PACKAGE_NAME = "org.chromium.webapk.test_package"; private static final String ANOTHER_BROWSER_PACKAGE_NAME = "another.browser";
diff --git a/chrome/android/webapk/shell_apk/BUILD.gn b/chrome/android/webapk/shell_apk/BUILD.gn index 58194d4..41c5299e 100644 --- a/chrome/android/webapk/shell_apk/BUILD.gn +++ b/chrome/android/webapk/shell_apk/BUILD.gn
@@ -351,5 +351,4 @@ data_deps = [ ":${h2o_junit_manifest_target_name}", ] - android_manifest_path = h2o_junit_manifest_output }
diff --git a/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/MainActivityTest.java b/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/MainActivityTest.java index ff79fe2..386207c6 100644 --- a/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/MainActivityTest.java +++ b/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/MainActivityTest.java
@@ -35,7 +35,7 @@ * together. */ @RunWith(LocalRobolectricTestRunner.class) -@Config(manifest = Config.NONE, packageName = WebApkUtilsTest.WEBAPK_PACKAGE_NAME) +@Config(manifest = Config.NONE) public final class MainActivityTest { private PackageManager mPackageManager; private static final String BROWSER_PACKAGE_NAME = "com.android.chrome";
diff --git a/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/WebApkUtilsTest.java b/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/WebApkUtilsTest.java index dda3c99..de7d0e3 100644 --- a/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/WebApkUtilsTest.java +++ b/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/WebApkUtilsTest.java
@@ -23,9 +23,9 @@ /** Tests for WebApkUtils. */ @RunWith(LocalRobolectricTestRunner.class) -@Config(manifest = Config.NONE, packageName = WebApkUtilsTest.WEBAPK_PACKAGE_NAME) +@Config(manifest = Config.NONE) public class WebApkUtilsTest { - protected static final String WEBAPK_PACKAGE_NAME = "org.chromium.webapk.test_package"; + protected static final String WEBAPK_PACKAGE_NAME = "org.chromium.test"; private Context mContext; private ShadowPackageManager mPackageManager;
diff --git a/chrome/app/chrome_content_browser_overlay_manifest.cc b/chrome/app/chrome_content_browser_overlay_manifest.cc index eb265ef..634c1a2 100644 --- a/chrome/app/chrome_content_browser_overlay_manifest.cc +++ b/chrome/app/chrome_content_browser_overlay_manifest.cc
@@ -148,7 +148,7 @@ // Only used in the classic Ash case .RequireCapability("chrome", "input_device_controller") .RequireCapability("chrome_printing", "converter") - .RequireCapability("content_browser", "profiling_client") + .RequireCapability("content_system", "profiling_client") .RequireCapability("cups_ipp_parser", "ipp_parser") .RequireCapability("device", "device:fingerprint") .RequireCapability("device", "device:geolocation_config")
diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp index 066ae8f..ef5a52e 100644 --- a/chrome/app/chromeos_strings.grdp +++ b/chrome/app/chromeos_strings.grdp
@@ -193,6 +193,9 @@ <message name="IDS_CHECKING_FOR_UPDATES" desc="Notification for checking for update"> Checking for updates </message> + <message name="IDS_QUICK_FIX_RELEASE_BUILD" desc="Quick Fix build which is Chrome OS release build displayed string instead of canary/dev/beta."> + QuickFix + </message> <message name="IDS_UPDATE_VERIFYING" desc="Message that the system is verifying an update"> Verifying... </message>
diff --git a/chrome/app/onboarding_welcome_strings.grdp b/chrome/app/onboarding_welcome_strings.grdp index 491695f..eb5f4cc8 100644 --- a/chrome/app/onboarding_welcome_strings.grdp +++ b/chrome/app/onboarding_welcome_strings.grdp
@@ -47,8 +47,8 @@ </message> <!-- NUX NTP background selection module --> - <message name="IDS_ONBOARDING_WELCOME_NTP_BACKGROUND_DESCRIPTION" desc="Description of what this section in the onboarding workflow does. This section lets a user change the wallpaper for their 'start page', which refers to the New Tab Page"> - Pick a wallpaper for your start page + <message name="IDS_ONBOARDING_WELCOME_NTP_BACKGROUND_DESCRIPTION" desc="Description of what this section in the onboarding workflow does. This section lets a user change the background for the New Tab Page"> + Pick a background </message> <message name="IDS_ONBOARDING_WELCOME_NTP_BACKGROUND_DEFAULT_TITLE" desc="Label for the default option when selecting a background. The default is to not have a background."> Default @@ -108,7 +108,7 @@ <!-- Sign-in view --> <message name="IDS_ONBOARDING_WELCOME_SIGNIN_VIEW_HEADER" desc="Header for the page that prompts user to sign in to chrome."> - Save your progress + Your Chrome, Everywhere </message> <message name="IDS_ONBOARDING_WELCOME_SIGNIN_VIEW_SUB_HEADER" desc="Sub-header for the page that prompts user to sign in to chrome."> Sign in and turn on sync to get your bookmarks, passwords and more on all devices
diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp index 359f239..c455badf 100644 --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp
@@ -556,20 +556,19 @@ </message> <!-- Plugin VM Page --> - <!-- TODO(timloh): Remove transleatable flag after strings are finalized. --> - <message name="IDS_SETTINGS_PLUGIN_VM_PAGE_TITLE" desc="The title of Plugin VM section." translateable="false"> + <message name="IDS_SETTINGS_PLUGIN_VM_PAGE_TITLE" desc="The title of Plugin VM section."> Plugin VM </message> - <message name="IDS_SETTINGS_PLUGIN_VM_PAGE_LABEL" desc="The text associated with the primary section setting for Plugin VM." translateable="false"> + <message name="IDS_SETTINGS_PLUGIN_VM_PAGE_LABEL" desc="The text associated with the primary section setting for Plugin VM."> Plugin VM </message> - <message name="IDS_SETTINGS_PLUGIN_VM_PAGE_SUBTEXT" desc="Description for the section for enabling and managing Crostini." translateable="false"> - Run Plugin VM apps on your <ph name="DEVICE_TYPE">$1<ex>Chromebook</ex></ph> + <message name="IDS_SETTINGS_PLUGIN_VM_PAGE_SUBTEXT" desc="Description for the section for managing Plugin VM."> + Manage settings for running Plugin VM on your <ph name="DEVICE_TYPE">$1<ex>Chromebook</ex></ph> </message> - <message name="IDS_SETTINGS_PLUGIN_VM_PRINTER_ACCESS" desc="The text associated with the primary section setting for Plugin VM." translateable="false"> + <message name="IDS_SETTINGS_PLUGIN_VM_PRINTER_ACCESS" desc="The text in the settings page for allowing printer access from Plugin VM."> Give access to printers </message> - <message name="IDS_SETTINGS_PLUGIN_VM_SHARED_PATHS" desc="Label for managing shared folders in Crostini."> + <message name="IDS_SETTINGS_PLUGIN_VM_SHARED_PATHS" desc="Label for managing shared folders for Plugin VM."> Manage shared folders </message> <message name="IDS_SETTINGS_PLUGIN_VM_SHARED_PATHS_LIST_HEADING" desc="Label for list of shared folders."> @@ -578,10 +577,10 @@ <message name="IDS_SETTINGS_PLUGIN_VM_SHARED_PATHS_INSTRUCTIONS_ADD" desc="Instructions for how to add shared folders in Plugin VM."> To share, right-click on a folder in Files app, then select "Share with Plugin VM". </message> - <message name="IDS_SETTINGS_PLUGIN_VM_SHARED_PATHS_INSTRUCTIONS_REMOVE" desc="Instructions for removing shared folders in Crostini."> + <message name="IDS_SETTINGS_PLUGIN_VM_SHARED_PATHS_INSTRUCTIONS_REMOVE" desc="Instructions for removing shared folders in Plugin VM."> Removing folders from here will stop sharing but will not delete files. </message> - <message name="IDS_SETTINGS_PLUGIN_VM_SHARED_PATHS_REMOVE_SHARING" desc="Tooltip to show when hovering on the remove icon for a crostini shared folder."> + <message name="IDS_SETTINGS_PLUGIN_VM_SHARED_PATHS_REMOVE_SHARING" desc="Tooltip to show when hovering on the remove icon for a Plugin VM shared folder."> Remove sharing </message>
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 50d90a7..a31ebbf7 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -343,21 +343,6 @@ "component_updater/supervised_user_whitelist_installer.h", "component_updater/sw_reporter_installer_win.cc", "component_updater/sw_reporter_installer_win.h", - "conflicts/enumerate_input_method_editors_win.cc", - "conflicts/enumerate_input_method_editors_win.h", - "conflicts/enumerate_shell_extensions_win.cc", - "conflicts/enumerate_shell_extensions_win.h", - "conflicts/inspection_results_cache_win.cc", - "conflicts/inspection_results_cache_win.h", - "conflicts/module_database_observer_win.h", - "conflicts/module_database_win.cc", - "conflicts/module_database_win.h", - "conflicts/module_event_sink_impl_win.cc", - "conflicts/module_event_sink_impl_win.h", - "conflicts/module_inspector_win.cc", - "conflicts/module_inspector_win.h", - "conflicts/third_party_metrics_recorder_win.cc", - "conflicts/third_party_metrics_recorder_win.h", "consent_auditor/consent_auditor_factory.cc", "consent_auditor/consent_auditor_factory.h", "content_settings/chrome_content_settings_utils.cc", @@ -815,8 +800,6 @@ "metrics/network_quality_estimator_provider_impl.h", "metrics/oom/out_of_memory_reporter.cc", "metrics/oom/out_of_memory_reporter.h", - "metrics/persistent_histograms.cc", - "metrics/persistent_histograms.h", "metrics/power_metrics_provider_mac.h", "metrics/power_metrics_provider_mac.mm", "metrics/process_memory_metrics_emitter.cc", @@ -1780,6 +1763,21 @@ "win/chrome_elf_init.h", "win/chrome_select_file_dialog_factory.cc", "win/chrome_select_file_dialog_factory.h", + "win/conflicts/enumerate_input_method_editors.cc", + "win/conflicts/enumerate_input_method_editors.h", + "win/conflicts/enumerate_shell_extensions.cc", + "win/conflicts/enumerate_shell_extensions.h", + "win/conflicts/inspection_results_cache.cc", + "win/conflicts/inspection_results_cache.h", + "win/conflicts/module_database.cc", + "win/conflicts/module_database.h", + "win/conflicts/module_database_observer.h", + "win/conflicts/module_event_sink_impl.cc", + "win/conflicts/module_event_sink_impl.h", + "win/conflicts/module_inspector.cc", + "win/conflicts/module_inspector.h", + "win/conflicts/third_party_metrics_recorder.cc", + "win/conflicts/third_party_metrics_recorder.h", "win/jumplist.cc", "win/jumplist.h", "win/jumplist_factory.cc", @@ -2525,8 +2523,12 @@ "android/send_tab_to_self/android_notification_handler.cc", "android/send_tab_to_self/android_notification_handler.h", "android/send_tab_to_self/send_tab_to_self_android_bridge.cc", + "android/send_tab_to_self/send_tab_to_self_entry_bridge.cc", + "android/send_tab_to_self/send_tab_to_self_entry_bridge.h", "android/send_tab_to_self/send_tab_to_self_infobar.cc", "android/send_tab_to_self/send_tab_to_self_infobar.h", + "android/send_tab_to_self/send_tab_to_self_model_observer_bridge.cc", + "android/send_tab_to_self/send_tab_to_self_model_observer_bridge.h", "android/service_tab_launcher.cc", "android/service_tab_launcher.h", "android/sessions/session_tab_helper_android.cc", @@ -3572,7 +3574,7 @@ deps += [ ":chrome_process_finder", "//chrome:file_pre_reader", - "//chrome/browser/conflicts:module_info", + "//chrome/browser/win/conflicts:module_info", "//chrome/chrome_elf:blacklist", "//chrome/chrome_elf:constants", "//chrome/chrome_elf:dll_hash", @@ -3614,7 +3616,7 @@ if (is_chrome_branded) { deps += [ - "//chrome/browser/conflicts:module_list_proto", + "//chrome/browser/win/conflicts:module_list_proto", "//chrome/chrome_elf:sha1", "//chrome/chrome_elf:third_party_shared_defines", "//google_update", @@ -3623,32 +3625,32 @@ sources += [ "component_updater/third_party_module_list_component_installer_win.cc", "component_updater/third_party_module_list_component_installer_win.h", - "conflicts/incompatible_applications_updater_win.cc", - "conflicts/incompatible_applications_updater_win.h", - "conflicts/installed_applications_win.cc", - "conflicts/installed_applications_win.h", - "conflicts/module_blacklist_cache_updater_win.cc", - "conflicts/module_blacklist_cache_updater_win.h", - "conflicts/module_blacklist_cache_util_win.cc", - "conflicts/module_blacklist_cache_util_win.h", - "conflicts/module_list_component_updater_win.cc", - "conflicts/module_list_component_updater_win.h", - "conflicts/module_list_filter_win.cc", - "conflicts/module_list_filter_win.h", - "conflicts/module_load_attempt_log_listener_win.cc", - "conflicts/module_load_attempt_log_listener_win.h", - "conflicts/msi_util_win.cc", - "conflicts/msi_util_win.h", - "conflicts/registry_key_watcher_win.cc", - "conflicts/registry_key_watcher_win.h", - "conflicts/third_party_conflicts_manager_win.cc", - "conflicts/third_party_conflicts_manager_win.h", - "conflicts/token_util_win.cc", - "conflicts/token_util_win.h", - "conflicts/uninstall_application_win.cc", - "conflicts/uninstall_application_win.h", "google/google_update_win.cc", "google/google_update_win.h", + "win/conflicts/incompatible_applications_updater.cc", + "win/conflicts/incompatible_applications_updater.h", + "win/conflicts/installed_applications.cc", + "win/conflicts/installed_applications.h", + "win/conflicts/module_blacklist_cache_updater.cc", + "win/conflicts/module_blacklist_cache_updater.h", + "win/conflicts/module_blacklist_cache_util.cc", + "win/conflicts/module_blacklist_cache_util.h", + "win/conflicts/module_list_component_updater.cc", + "win/conflicts/module_list_component_updater.h", + "win/conflicts/module_list_filter.cc", + "win/conflicts/module_list_filter.h", + "win/conflicts/module_load_attempt_log_listener.cc", + "win/conflicts/module_load_attempt_log_listener.h", + "win/conflicts/msi_util.cc", + "win/conflicts/msi_util.h", + "win/conflicts/registry_key_watcher.cc", + "win/conflicts/registry_key_watcher.h", + "win/conflicts/third_party_conflicts_manager.cc", + "win/conflicts/third_party_conflicts_manager.h", + "win/conflicts/token_util.cc", + "win/conflicts/token_util.h", + "win/conflicts/uninstall_application.cc", + "win/conflicts/uninstall_application.h", ] } } else {
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 087fb4c..a9f0efa 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc
@@ -2477,55 +2477,6 @@ flag_descriptions::kOmniboxUISwapTitleAndUrlDescription, kOsDesktop, FEATURE_VALUE_TYPE(omnibox::kUIExperimentSwapTitleAndUrl)}, - {"omnibox-ui-blue-search-loop-and-search-query", - flag_descriptions::kOmniboxUIBlueSearchLoopAndSearchQueryName, - flag_descriptions::kOmniboxUIBlueSearchLoopAndSearchQueryDescription, - kOsDesktop, - FEATURE_VALUE_TYPE(omnibox::kUIExperimentBlueSearchLoopAndSearchQuery)}, - - {"omnibox-ui-blue-titles-and-gray-urls-on-page-suggestions", - flag_descriptions::kOmniboxUIBlueTitlesAndGrayUrlsOnPageSuggestionsName, - flag_descriptions:: - kOmniboxUIBlueTitlesAndGrayUrlsOnPageSuggestionsDescription, - kOsDesktop, - FEATURE_VALUE_TYPE( - omnibox::kUIExperimentBlueTitlesAndGrayUrlsOnPageSuggestions)}, - - {"omnibox-ui-blue-titles-on-page-suggestions", - flag_descriptions::kOmniboxUIBlueTitlesOnPageSuggestionsName, - flag_descriptions::kOmniboxUIBlueTitlesOnPageSuggestionsDescription, - kOsDesktop, - FEATURE_VALUE_TYPE(omnibox::kUIExperimentBlueTitlesOnPageSuggestions)}, - - {"omnibox-ui-show-suffix-on-all-search-suggestions", - flag_descriptions::kOmniboxUIShowSuffixOnAllSearchSuggestionsName, - flag_descriptions::kOmniboxUIShowSuffixOnAllSearchSuggestionsDescription, - kOsDesktop, - FEATURE_VALUE_TYPE( - omnibox::kUIExperimentShowSuffixOnAllSearchSuggestions)}, - - {"omnibox-ui-white-background-on-blur", - flag_descriptions::kOmniboxUIWhiteBackgroundOnBlurName, - flag_descriptions::kOmniboxUIWhiteBackgroundOnBlurDescription, kOsDesktop, - FEATURE_VALUE_TYPE(omnibox::kUIExperimentWhiteBackgroundOnBlur)}, - - {"omnibox-ui-use-generic-search-engine-icon", - flag_descriptions::kOmniboxUIUseGenericSearchEngineIconName, - flag_descriptions::kOmniboxUIUseGenericSearchEngineIconDescription, - kOsDesktop, - FEATURE_VALUE_TYPE(omnibox::kUIExperimentUseGenericSearchEngineIcon)}, - - {"omnibox-ui-bold-user-text-on-search-suggestions", - flag_descriptions::kOmniboxUIBoldUserTextOnSearchSuggestionsName, - flag_descriptions::kOmniboxUIBoldUserTextOnSearchSuggestionsDescription, - kOsDesktop, - FEATURE_VALUE_TYPE(omnibox::kUIExperimentBoldUserTextOnSearchSuggestions)}, - - {"omnibox-ui-unbold-suggestion-text", - flag_descriptions::kOmniboxUIUnboldSuggestionTextName, - flag_descriptions::kOmniboxUIUnboldSuggestionTextDescription, kOsDesktop, - FEATURE_VALUE_TYPE(omnibox::kUIExperimentUnboldSuggestionText)}, - #if defined(OS_ANDROID) {"omnibox-zero-suggestions-on-ntp", flag_descriptions::kOmniboxZeroSuggestionsOnNTPName,
diff --git a/chrome/browser/android/send_tab_to_self/send_tab_to_self_android_bridge.cc b/chrome/browser/android/send_tab_to_self/send_tab_to_self_android_bridge.cc index cb8cf81..e09af95 100644 --- a/chrome/browser/android/send_tab_to_self/send_tab_to_self_android_bridge.cc +++ b/chrome/browser/android/send_tab_to_self/send_tab_to_self_android_bridge.cc
@@ -9,10 +9,10 @@ #include "base/android/jni_string.h" #include "base/metrics/histogram_macros.h" #include "base/time/time.h" +#include "chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.h" #include "chrome/browser/android/send_tab_to_self/send_tab_to_self_infobar.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" -#include "chrome/browser/send_tab_to_self/send_tab_to_self_client_service.h" #include "chrome/browser/send_tab_to_self/send_tab_to_self_client_service_factory.h" #include "chrome/browser/send_tab_to_self/send_tab_to_self_util.h" #include "chrome/browser/sync/send_tab_to_self_sync_service_factory.h" @@ -22,7 +22,6 @@ #include "components/send_tab_to_self/send_tab_to_self_sync_service.h" #include "content/public/browser/web_contents.h" #include "jni/SendTabToSelfAndroidBridge_jni.h" -#include "jni/SendTabToSelfEntry_jni.h" #include "url/gurl.h" using base::android::AttachCurrentThread; @@ -39,19 +38,6 @@ namespace { -ScopedJavaLocalRef<jobject> CreateJavaSendTabToSelfEntry( - JNIEnv* env, - const SendTabToSelfEntry* entry) { - return Java_SendTabToSelfEntry_createSendTabToSelfEntry( - env, ConvertUTF8ToJavaString(env, entry->GetGUID()), - ConvertUTF8ToJavaString(env, entry->GetURL().spec()), - ConvertUTF8ToJavaString(env, entry->GetTitle()), - entry->GetSharedTime().ToJavaTime(), - entry->GetOriginalNavigationTime().ToJavaTime(), - ConvertUTF8ToJavaString(env, entry->GetDeviceName()), - ConvertUTF8ToJavaString(env, entry->GetTargetDeviceSyncCacheGuid())); -} - void LogModelLoadedInTime(bool status) { UMA_HISTOGRAM_BOOLEAN("SendTabToSelf.Sync.ModelLoadedInTime", status); } @@ -120,7 +106,6 @@ if (persisted_entry == nullptr) { return nullptr; } - return CreateJavaSendTabToSelfEntry(env, persisted_entry); }
diff --git a/chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.cc b/chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.cc new file mode 100644 index 0000000..d408b8f --- /dev/null +++ b/chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.cc
@@ -0,0 +1,34 @@ +// Copyright 2019 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 "chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.h" + +#include "base/android/jni_array.h" +#include "base/android/jni_string.h" +#include "components/send_tab_to_self/send_tab_to_self_entry.h" +#include "jni/SendTabToSelfEntry_jni.h" + +using base::android::AttachCurrentThread; +using base::android::ConvertUTF8ToJavaString; +using base::android::JavaParamRef; +using base::android::JavaRef; +using base::android::ScopedJavaGlobalRef; +using base::android::ScopedJavaLocalRef; + +namespace send_tab_to_self { + +ScopedJavaLocalRef<jobject> CreateJavaSendTabToSelfEntry( + JNIEnv* env, + const SendTabToSelfEntry* entry) { + return Java_SendTabToSelfEntry_createSendTabToSelfEntry( + env, ConvertUTF8ToJavaString(env, entry->GetGUID()), + ConvertUTF8ToJavaString(env, entry->GetURL().spec()), + ConvertUTF8ToJavaString(env, entry->GetTitle()), + entry->GetSharedTime().ToJavaTime(), + entry->GetOriginalNavigationTime().ToJavaTime(), + ConvertUTF8ToJavaString(env, entry->GetDeviceName()), + ConvertUTF8ToJavaString(env, entry->GetTargetDeviceSyncCacheGuid())); +} + +} // namespace send_tab_to_self
diff --git a/chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.h b/chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.h new file mode 100644 index 0000000..dbe8bb6 --- /dev/null +++ b/chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.h
@@ -0,0 +1,22 @@ +// Copyright 2019 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 CHROME_BROWSER_ANDROID_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_ENTRY_BRIDGE_H_ +#define CHROME_BROWSER_ANDROID_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_ENTRY_BRIDGE_H_ + +#include "base/android/jni_android.h" +#include "base/macros.h" + +namespace send_tab_to_self { +class SendTabToSelfEntry; + +// Function to convert the native version of SendTabToSelfEntry into the Java +// version. +base::android::ScopedJavaLocalRef<jobject> CreateJavaSendTabToSelfEntry( + JNIEnv* env, + const SendTabToSelfEntry* entry); + +} // namespace send_tab_to_self + +#endif // CHROME_BROWSER_ANDROID_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_ENTRY_BRIDGE_H_
diff --git a/chrome/browser/android/send_tab_to_self/send_tab_to_self_model_observer_bridge.cc b/chrome/browser/android/send_tab_to_self/send_tab_to_self_model_observer_bridge.cc new file mode 100644 index 0000000..fe2af45 --- /dev/null +++ b/chrome/browser/android/send_tab_to_self/send_tab_to_self_model_observer_bridge.cc
@@ -0,0 +1,113 @@ +// Copyright 2019 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 "chrome/browser/android/send_tab_to_self/send_tab_to_self_model_observer_bridge.h" + +#include <string> +#include <vector> + +#include "base/android/jni_array.h" +#include "base/android/jni_string.h" +#include "base/time/time.h" +#include "chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_android.h" +#include "chrome/browser/sync/send_tab_to_self_sync_service_factory.h" +#include "components/send_tab_to_self/send_tab_to_self_entry.h" +#include "components/send_tab_to_self/send_tab_to_self_model.h" +#include "components/send_tab_to_self/send_tab_to_self_sync_service.h" +#include "content/public/browser/web_contents.h" +#include "jni/SendTabToSelfModelObserverBridge_jni.h" +#include "url/gurl.h" + +using base::android::AttachCurrentThread; +using base::android::ConvertUTF8ToJavaString; +using base::android::JavaParamRef; +using base::android::JavaRef; +using base::android::ScopedJavaGlobalRef; +using base::android::ScopedJavaLocalRef; + +namespace send_tab_to_self { + +SendTabToSelfModelObserverBridge::SendTabToSelfModelObserverBridge( + JNIEnv* env, + const JavaRef<jobject>& obj, + const JavaRef<jobject>& j_profile) + : weak_java_ref_(env, obj), send_tab_to_self_model_(nullptr) { + Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); + send_tab_to_self_model_ = SendTabToSelfSyncServiceFactory::GetInstance() + ->GetForProfile(profile) + ->GetSendTabToSelfModel(); + send_tab_to_self_model_->AddObserver(this); +} + +static jlong JNI_SendTabToSelfModelObserverBridge_Init( + JNIEnv* env, + const JavaParamRef<jobject>& obj, + const JavaParamRef<jobject>& j_profile) { + SendTabToSelfModelObserverBridge* bridge = + new SendTabToSelfModelObserverBridge(env, obj, j_profile); + return reinterpret_cast<intptr_t>(bridge); +} + +void SendTabToSelfModelObserverBridge::Destroy(JNIEnv*, + const JavaParamRef<jobject>&) { + delete this; +} + +SendTabToSelfModelObserverBridge::~SendTabToSelfModelObserverBridge() { + send_tab_to_self_model_->RemoveObserver(this); +} + +void SendTabToSelfModelObserverBridge::SendTabToSelfModelLoaded() { + JNIEnv* env = AttachCurrentThread(); + ScopedJavaLocalRef<jobject> obj = weak_java_ref_.get(env); + if (obj.is_null()) { + return; + } + + Java_SendTabToSelfModelObserverBridge_modelLoaded(env, obj); +} + +void SendTabToSelfModelObserverBridge::EntriesAddedRemotely( + const std::vector<const SendTabToSelfEntry*>& new_entries) { + JNIEnv* env = AttachCurrentThread(); + ScopedJavaLocalRef<jobject> obj = weak_java_ref_.get(env); + if (obj.is_null()) { + return; + } + + ScopedJavaLocalRef<jobject> j_entry_list = + Java_SendTabToSelfModelObserverBridge_createEmptyJavaEntryList(env, obj); + + for (std::vector<const SendTabToSelfEntry*>::const_iterator it = + new_entries.begin(); + it != new_entries.end(); ++it) { + Java_SendTabToSelfModelObserverBridge_addToEntryList( + env, obj, j_entry_list, CreateJavaSendTabToSelfEntry(env, *it)); + } + Java_SendTabToSelfModelObserverBridge_entriesAddedRemotely(env, obj, + j_entry_list); +} + +void SendTabToSelfModelObserverBridge::EntriesRemovedRemotely( + const std::vector<std::string>& guids) { + JNIEnv* env = AttachCurrentThread(); + ScopedJavaLocalRef<jobject> obj = weak_java_ref_.get(env); + if (obj.is_null()) { + return; + } + ScopedJavaLocalRef<jobject> j_guid_list = + Java_SendTabToSelfModelObserverBridge_createEmptyJavaGuidList(env, obj); + + for (std::vector<const std::string>::iterator it = guids.begin(); + it != guids.end(); ++it) { + ScopedJavaLocalRef<jstring> j_guid = ConvertUTF8ToJavaString(env, *it); + Java_SendTabToSelfModelObserverBridge_addToGuidList(env, obj, j_guid_list, + j_guid); + } + Java_SendTabToSelfModelObserverBridge_entriesRemovedRemotely(env, obj, + j_guid_list); +} +} // namespace send_tab_to_self
diff --git a/chrome/browser/android/send_tab_to_self/send_tab_to_self_model_observer_bridge.h b/chrome/browser/android/send_tab_to_self/send_tab_to_self_model_observer_bridge.h new file mode 100644 index 0000000..b33ddec --- /dev/null +++ b/chrome/browser/android/send_tab_to_self/send_tab_to_self_model_observer_bridge.h
@@ -0,0 +1,50 @@ +// Copyright 2019 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 CHROME_BROWSER_ANDROID_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_MODEL_OBSERVER_BRIDGE_H_ +#define CHROME_BROWSER_ANDROID_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_MODEL_OBSERVER_BRIDGE_H_ + +#include "base/android/jni_android.h" +#include "base/android/jni_weak_ref.h" +#include "base/macros.h" +#include "components/send_tab_to_self/send_tab_to_self_model_observer.h" + +namespace send_tab_to_self { + +class SendTabToSelfModel; + +// The delegate to observe for SendTabToSelf model changes and forward them to +// observers of this class. The class is owned by the SendTabToSelf Java +// counterpart and lives for the duration of the life of that class. +class SendTabToSelfModelObserverBridge : public SendTabToSelfModelObserver { + public: + SendTabToSelfModelObserverBridge( + JNIEnv* env, + const base::android::JavaRef<jobject>& obj, + const base::android::JavaRef<jobject>& j_profile); + + void Destroy(JNIEnv*, const base::android::JavaParamRef<jobject>&); + + // SendTabToSelfModelObserver implementation. + void SendTabToSelfModelLoaded() override; + void EntriesAddedRemotely( + const std::vector<const SendTabToSelfEntry*>& new_entries) override; + void EntriesRemovedRemotely(const std::vector<std::string>& guids) override; + + protected: + ~SendTabToSelfModelObserverBridge() override; + + private: + JavaObjectWeakGlobalRef weak_java_ref_; + // Set during the constructor and owned by the SendTabToSelfSyncServiceFactory + // is based off the KeyedServiceFactory which lives for the length of the + // profile. SendTabToSelf is not supported for the Incognito profile. + SendTabToSelfModel* send_tab_to_self_model_; + + DISALLOW_COPY_AND_ASSIGN(SendTabToSelfModelObserverBridge); +}; + +} // namespace send_tab_to_self + +#endif // CHROME_BROWSER_ANDROID_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_MODEL_OBSERVER_BRIDGE_H_
diff --git a/chrome/browser/browser_switcher/ieem_sitelist_parser.cc b/chrome/browser/browser_switcher/ieem_sitelist_parser.cc index bf38a66f..436d5597 100644 --- a/chrome/browser/browser_switcher/ieem_sitelist_parser.cc +++ b/chrome/browser/browser_switcher/ieem_sitelist_parser.cc
@@ -121,7 +121,9 @@ GetXmlElementText(*open_in_node, &mode); } base::TrimWhitespaceASCII(mode, base::TRIM_ALL, &mode); - std::string prefix = (mode.empty() || mode == "none") ? "!" : ""; + std::string prefix = + (mode.empty() || !base::CompareCaseInsensitiveASCII(mode, "none")) ? "!" + : ""; result->rules.push_back(prefix + url); } }
diff --git a/chrome/browser/browser_switcher/ieem_sitelist_parser_browsertest.cc b/chrome/browser/browser_switcher/ieem_sitelist_parser_browsertest.cc index 1d9501a4..57651fc 100644 --- a/chrome/browser/browser_switcher/ieem_sitelist_parser_browsertest.cc +++ b/chrome/browser/browser_switcher/ieem_sitelist_parser_browsertest.cc
@@ -152,7 +152,7 @@ "</somethings></site><!-- good sites --> <site url=\"www.cpandl.com\">" "<compat-mode>IE8Enterprise</compat-mode><open-in>MSEdge</open-in></site>" "<site url=\"contoso.com\"><compat-mode>default</compat-mode><open-in>" - "none</open-in></site><site url=\"relecloud.com\"/><site " + "None</open-in></site><site url=\"relecloud.com\"/><site " "url=\"relecloud.com/about\"><compat-mode>IE8Enterprise</compat-mode>" "</site></site-list><!-- trailing gibberish <trailing><site " "url=\"ignore after site list!\"> <compat-mode>IE8Enterprise\""
diff --git a/chrome/browser/chrome_browser_field_trials.cc b/chrome/browser/chrome_browser_field_trials.cc index 79a490e6..c05b0ac6 100644 --- a/chrome/browser/chrome_browser_field_trials.cc +++ b/chrome/browser/chrome_browser_field_trials.cc
@@ -10,17 +10,19 @@ #include "base/feature_list.h" #include "base/files/file_util.h" #include "base/metrics/field_trial.h" +#include "base/path_service.h" #include "base/strings/string_util.h" #include "base/time/time.h" #include "build/build_config.h" #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" #include "chrome/browser/metrics/chrome_metrics_service_client.h" #include "chrome/browser/metrics/chrome_metrics_services_manager_client.h" -#include "chrome/browser/metrics/persistent_histograms.h" #include "chrome/browser/search/local_ntp_first_run_field_trial_handler.h" #include "chrome/common/channel_info.h" +#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "components/metrics/metrics_pref_names.h" +#include "components/metrics/persistent_histograms.h" #include "components/ukm/ukm_recorder_impl.h" #include "components/version_info/version_info.h" @@ -126,5 +128,8 @@ void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { // Persistent histograms must be enabled as soon as possible. - InstantiatePersistentHistograms(); + base::FilePath metrics_dir; + if (base::PathService::Get(chrome::DIR_USER_DATA, &metrics_dir)) { + InstantiatePersistentHistograms(metrics_dir); + } }
diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc index ad2a2f1d..9fac9e63 100644 --- a/chrome/browser/chrome_browser_main_win.cc +++ b/chrome/browser/chrome_browser_main_win.cc
@@ -39,10 +39,6 @@ #include "base/win/win_util.h" #include "base/win/wrapped_window_proc.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/conflicts/enumerate_input_method_editors_win.h" -#include "chrome/browser/conflicts/enumerate_shell_extensions_win.h" -#include "chrome/browser/conflicts/module_database_win.h" -#include "chrome/browser/conflicts/module_event_sink_impl_win.h" #include "chrome/browser/first_run/first_run.h" #include "chrome/browser/memory/memory_pressure_monitor.h" #include "chrome/browser/memory/swap_thrashing_monitor.h" @@ -55,6 +51,10 @@ #include "chrome/browser/ui/uninstall_browser_prompt.h" #include "chrome/browser/win/browser_util.h" #include "chrome/browser/win/chrome_elf_init.h" +#include "chrome/browser/win/conflicts/enumerate_input_method_editors.h" +#include "chrome/browser/win/conflicts/enumerate_shell_extensions.h" +#include "chrome/browser/win/conflicts/module_database.h" +#include "chrome/browser/win/conflicts/module_event_sink_impl.h" #include "chrome/chrome_watcher/chrome_watcher_main_api.h" #include "chrome/common/channel_info.h" #include "chrome/common/chrome_constants.h" @@ -96,7 +96,7 @@ #include "ui/strings/grit/app_locale_settings.h" #if defined(GOOGLE_CHROME_BUILD) -#include "chrome/browser/conflicts/third_party_conflicts_manager_win.h" +#include "chrome/browser/win/conflicts/third_party_conflicts_manager.h" #endif namespace {
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index e59f7cfd..5f11e8a 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc
@@ -375,8 +375,8 @@ #if defined(OS_WIN) #include "base/strings/string_tokenizer.h" #include "chrome/browser/chrome_browser_main_win.h" -#include "chrome/browser/conflicts/module_database_win.h" -#include "chrome/browser/conflicts/module_event_sink_impl_win.h" +#include "chrome/browser/win/conflicts/module_database.h" +#include "chrome/browser/win/conflicts/module_event_sink_impl.h" #include "chrome/install_static/install_util.h" #include "chrome/services/util_win/public/mojom/constants.mojom.h" #include "chrome/services/wifi_util_win/public/mojom/constants.mojom.h" @@ -428,7 +428,6 @@ #include "chromeos/services/secure_channel/secure_channel_service.h" #include "components/user_manager/user_manager.h" #include "services/service_manager/public/mojom/interface_provider_spec.mojom.h" -#include "services/ws/common/switches.h" #elif defined(OS_LINUX) #include "chrome/browser/chrome_browser_main_linux.h" #elif defined(OS_ANDROID)
diff --git a/chrome/browser/chromeos/arc/app_shortcuts/arc_app_shortcuts_menu_builder_unittest.cc b/chrome/browser/chromeos/arc/app_shortcuts/arc_app_shortcuts_menu_builder_unittest.cc index a2c3ff7..560218e 100644 --- a/chrome/browser/chromeos/arc/app_shortcuts/arc_app_shortcuts_menu_builder_unittest.cc +++ b/chrome/browser/chromeos/arc/app_shortcuts/arc_app_shortcuts_menu_builder_unittest.cc
@@ -60,7 +60,7 @@ TEST_F(ArcAppShortcutsMenuBuilderTest, Basic) { base::RunLoop run_loop; - std::unique_ptr<ui::MenuModel> menu; + std::unique_ptr<ui::SimpleMenuModel> menu; auto simple_menu_model = std::make_unique<ui::SimpleMenuModel>(nullptr); const base::string16 first_item_label = base::UTF8ToUTF16("FirstItemLabel"); simple_menu_model->AddItem(1, first_item_label);
diff --git a/chrome/browser/chromeos/arc/tracing/arc_cpu_event.cc b/chrome/browser/chromeos/arc/tracing/arc_cpu_event.cc index 9d42620..2f1a7feb 100644 --- a/chrome/browser/chromeos/arc/tracing/arc_cpu_event.cc +++ b/chrome/browser/chromeos/arc/tracing/arc_cpu_event.cc
@@ -8,7 +8,7 @@ namespace arc { -ArcCpuEvent::ArcCpuEvent(int64_t timestamp, Type type, uint32_t tid) +ArcCpuEvent::ArcCpuEvent(uint64_t timestamp, Type type, uint32_t tid) : timestamp(timestamp), type(type), tid(tid) {} bool ArcCpuEvent::operator==(const ArcCpuEvent& other) const { @@ -16,7 +16,7 @@ } bool AddCpuEvent(CpuEvents* cpu_events, - int64_t timestamp, + uint64_t timestamp, ArcCpuEvent::Type type, uint32_t tid) { // Base validation. @@ -112,7 +112,7 @@ bool AddAllCpuEvent(AllCpuEvents* all_cpu_events, uint32_t cpu_id, - int64_t timestamp, + uint64_t timestamp, ArcCpuEvent::Type type, uint32_t tid) { if (all_cpu_events->size() <= cpu_id) @@ -144,7 +144,7 @@ if (!value || !value->is_list()) return false; - int64_t previous_timestamp = 0; + uint64_t previous_timestamp = 0; for (const auto& entry : value->GetList()) { if (!entry.is_list() || entry.GetList().size() != 3) return false; @@ -163,7 +163,7 @@ } if (!entry.GetList()[1].is_double() && !entry.GetList()[1].is_int()) return false; - const int64_t timestamp = entry.GetList()[1].GetDouble(); + const uint64_t timestamp = entry.GetList()[1].GetDouble(); if (timestamp < previous_timestamp) return false; if (!entry.GetList()[2].is_int())
diff --git a/chrome/browser/chromeos/arc/tracing/arc_cpu_event.h b/chrome/browser/chromeos/arc/tracing/arc_cpu_event.h index 92ddf0c..d5e330b1 100644 --- a/chrome/browser/chromeos/arc/tracing/arc_cpu_event.h +++ b/chrome/browser/chromeos/arc/tracing/arc_cpu_event.h
@@ -21,11 +21,11 @@ kActive, // Task is started on CPU. }; - ArcCpuEvent(int64_t timestamp, Type type, uint32_t tid); + ArcCpuEvent(uint64_t timestamp, Type type, uint32_t tid); bool operator==(const ArcCpuEvent& other) const; - int64_t timestamp; + uint64_t timestamp; Type type; uint32_t tid; }; @@ -38,7 +38,7 @@ // Helper that adds CPU event into |cpu_events|. Returns true in case event was // created and added or false if it breaks any constraint. bool AddCpuEvent(CpuEvents* cpu_events, - int64_t timestamp, + uint64_t timestamp, ArcCpuEvent::Type type, uint32_t tid); @@ -47,7 +47,7 @@ // created and added or false if it breaks any constraint. bool AddAllCpuEvent(AllCpuEvents* all_cpu_events, uint32_t cpu_id, - int64_t timestamp, + uint64_t timestamp, ArcCpuEvent::Type type, uint32_t tid);
diff --git a/chrome/browser/chromeos/arc/tracing/arc_system_model.cc b/chrome/browser/chromeos/arc/tracing/arc_system_model.cc index 38061164..2e1e8f3 100644 --- a/chrome/browser/chromeos/arc/tracing/arc_system_model.cc +++ b/chrome/browser/chromeos/arc/tracing/arc_system_model.cc
@@ -86,7 +86,7 @@ memory_events_.clear(); } -void ArcSystemModel::Trim(int64_t trim_timestamp) { +void ArcSystemModel::Trim(uint64_t trim_timestamp) { const ArcCpuEvent cpu_trim_point( trim_timestamp, ArcCpuEvent::Type::kActive /* does not matter */, 0 /* tid, does not matter */);
diff --git a/chrome/browser/chromeos/arc/tracing/arc_system_model.h b/chrome/browser/chromeos/arc/tracing/arc_system_model.h index b996f31..d36ca80 100644 --- a/chrome/browser/chromeos/arc/tracing/arc_system_model.h +++ b/chrome/browser/chromeos/arc/tracing/arc_system_model.h
@@ -42,7 +42,7 @@ // |trim_timestamp| are consolidated with their timestamps aligned // to |trim_timestamp|. Events on or after |trim_timestamp| are left // in the model unchanged. - void Trim(int64_t trim_timestamp); + void Trim(uint64_t trim_timestamp); void CopyFrom(const ArcSystemModel& other); base::DictionaryValue Serialize() const;
diff --git a/chrome/browser/chromeos/arc/tracing/arc_system_model_unittest.cc b/chrome/browser/chromeos/arc/tracing/arc_system_model_unittest.cc index 6d7951d..0576259 100644 --- a/chrome/browser/chromeos/arc/tracing/arc_system_model_unittest.cc +++ b/chrome/browser/chromeos/arc/tracing/arc_system_model_unittest.cc
@@ -13,7 +13,7 @@ TEST_F(ArcSystemModelTest, TrimByTimestampCPU) { ArcSystemModel model; - constexpr int64_t trim_timestamp = 25; + constexpr uint64_t trim_timestamp = 25; constexpr int idle_tid = 0; constexpr int non_idle_tid = 100; @@ -66,7 +66,7 @@ ASSERT_EQ(3U, cpu_events_1.size()); EXPECT_EQ(ArcCpuEvent::Type::kIdleIn, cpu_events_1[0].type); - EXPECT_EQ(32, cpu_events_1[0].timestamp); + EXPECT_EQ(32u, cpu_events_1[0].timestamp); ASSERT_EQ(2U, cpu_events_2.size()); EXPECT_EQ(ArcCpuEvent::Type::kWakeUp, cpu_events_2[0].type); @@ -80,7 +80,7 @@ TEST_F(ArcSystemModelTest, TrimByTimestampMemory) { ArcSystemModel model; - constexpr int64_t trim_timestamp = 25; + constexpr uint64_t trim_timestamp = 25; // First of ArcValueEvent::Type::kMemTotal should be clamped to // |trim_timestamp|.
diff --git a/chrome/browser/chromeos/arc/tracing/arc_tracing_event.cc b/chrome/browser/chromeos/arc/tracing/arc_tracing_event.cc index 3f6e22df..2adbcfa 100644 --- a/chrome/browser/chromeos/arc/tracing/arc_tracing_event.cc +++ b/chrome/browser/chromeos/arc/tracing/arc_tracing_event.cc
@@ -120,25 +120,26 @@ dictionary_.SetKey(kKeyPhase, base::Value(std::string() + phase)); } -int64_t ArcTracingEvent::GetTimestamp() const { +uint64_t ArcTracingEvent::GetTimestamp() const { return GetDoubleFromDictionary(GetDictionary(), kKeyTimestamp, 0.0 /* default_value */); } -void ArcTracingEvent::SetTimestamp(double timestamp) { - dictionary_.SetKey(kKeyTimestamp, base::Value(timestamp)); +void ArcTracingEvent::SetTimestamp(uint64_t timestamp) { + dictionary_.SetKey(kKeyTimestamp, + base::Value(static_cast<double>(timestamp))); } -int64_t ArcTracingEvent::GetDuration() const { +uint64_t ArcTracingEvent::GetDuration() const { return GetDoubleFromDictionary(GetDictionary(), kKeyDuration, 0.0 /* default_value */); } -void ArcTracingEvent::SetDuration(double duration) { - dictionary_.SetKey(kKeyDuration, base::Value(duration)); +void ArcTracingEvent::SetDuration(uint64_t duration) { + dictionary_.SetKey(kKeyDuration, base::Value(static_cast<double>(duration))); } -int64_t ArcTracingEvent::GetEndTimestamp() const { +uint64_t ArcTracingEvent::GetEndTimestamp() const { return GetTimestamp() + GetDuration(); }
diff --git a/chrome/browser/chromeos/arc/tracing/arc_tracing_event.h b/chrome/browser/chromeos/arc/tracing/arc_tracing_event.h index 5bfe0bc..cea41d0 100644 --- a/chrome/browser/chromeos/arc/tracing/arc_tracing_event.h +++ b/chrome/browser/chromeos/arc/tracing/arc_tracing_event.h
@@ -63,18 +63,18 @@ void SetPhase(char phase); // Gets timestamp of the start of the event. Return 0 if not set. - int64_t GetTimestamp() const; + uint64_t GetTimestamp() const; // Sets timestamp of the start of the event. - void SetTimestamp(double timestamp); + void SetTimestamp(uint64_t timestamp); // Gets duration of the event. Return 0 if not set. It is optional for some // events. - int64_t GetDuration() const; + uint64_t GetDuration() const; // Sets duration of the event. - void SetDuration(double duration); + void SetDuration(uint64_t duration); // Gets timestamp of the end of the event. - int64_t GetEndTimestamp() const; + uint64_t GetEndTimestamp() const; // Returns base representation of the event as a |base::DictionaryValue|. const base::DictionaryValue* GetDictionary() const;
diff --git a/chrome/browser/chromeos/arc/tracing/arc_tracing_graphics_model.cc b/chrome/browser/chromeos/arc/tracing/arc_tracing_graphics_model.cc index ea30156..ddc24f29 100644 --- a/chrome/browser/chromeos/arc/tracing/arc_tracing_graphics_model.cc +++ b/chrome/browser/chromeos/arc/tracing/arc_tracing_graphics_model.cc
@@ -659,7 +659,7 @@ // |timestamp|. Returns |kInvalidBufferIndex| in case event is not found. ssize_t FindNotLaterThan(const ArcTracingGraphicsModel::BufferEvents& events, BufferEventType type, - int64_t timestamp) { + uint64_t timestamp) { if (events.empty() || events[0].timestamp > timestamp) return kInvalidBufferIndex; @@ -1146,8 +1146,8 @@ all_buffers.emplace_back(&buffer); all_buffers.emplace_back(&chrome_top_level_.global_events()); - int64_t min = std::numeric_limits<int64_t>::max(); - int64_t max = std::numeric_limits<int64_t>::min(); + uint64_t min = std::numeric_limits<uint64_t>::max(); + uint64_t max = std::numeric_limits<uint64_t>::min(); for (const BufferEvents* buffer : all_buffers) { if (!buffer->empty()) { min = std::min(min, buffer->front().timestamp);
diff --git a/chrome/browser/chromeos/arc/tracing/arc_tracing_graphics_model.h b/chrome/browser/chromeos/arc/tracing/arc_tracing_graphics_model.h index e17c34c7..4b166e1 100644 --- a/chrome/browser/chromeos/arc/tracing/arc_tracing_graphics_model.h +++ b/chrome/browser/chromeos/arc/tracing/arc_tracing_graphics_model.h
@@ -92,7 +92,7 @@ bool operator==(const BufferEvent& other) const; BufferEventType type; - int64_t timestamp; + uint64_t timestamp; std::string content; };
diff --git a/chrome/browser/chromeos/arc/tracing/arc_tracing_model.cc b/chrome/browser/chromeos/arc/tracing/arc_tracing_model.cc index 5d7cf80..25f57a2 100644 --- a/chrome/browser/chromeos/arc/tracing/arc_tracing_model.cc +++ b/chrome/browser/chromeos/arc/tracing/arc_tracing_model.cc
@@ -102,7 +102,7 @@ }; bool HandleGraphicsEvent(GraphicsEventsContext* context, - double timestamp, + uint64_t timestamp, uint32_t tid, const std::string& line, size_t event_position) { @@ -166,7 +166,7 @@ } bool HandleCpuIdle(AllCpuEvents* all_cpu_events, - double timestamp, + uint64_t timestamp, uint32_t cpu_id, uint32_t tid, const std::string& line, @@ -191,7 +191,7 @@ } bool HandleSchedWakeUp(AllCpuEvents* all_cpu_events, - double timestamp, + uint64_t timestamp, uint32_t cpu_id, uint32_t tid, const std::string& line, @@ -247,7 +247,7 @@ } bool HandleSchedSwitch(AllCpuEvents* all_cpu_events, - double timestamp, + uint64_t timestamp, uint32_t cpu_id, uint32_t tid, const std::string& line, @@ -266,7 +266,7 @@ } bool HandleGpuFreq(ValueEvents* value_events, - double timestamp, + uint64_t timestamp, const std::string& line, size_t event_position) { int new_freq = -1; @@ -402,8 +402,8 @@ // for others may appear after children. Sort by ts time. std::sort(parsed_events.begin(), parsed_events.end(), [](const auto& lhs, const auto& rhs) { - const int64_t lhs_timestamp = lhs->GetTimestamp(); - const int64_t rhs_timestamp = rhs->GetTimestamp(); + const uint64_t lhs_timestamp = lhs->GetTimestamp(); + const uint64_t rhs_timestamp = rhs->GetTimestamp(); if (lhs_timestamp != rhs_timestamp) return lhs_timestamp < rhs->GetTimestamp(); return lhs->GetDuration() > rhs->GetDuration(); @@ -496,12 +496,14 @@ } const size_t separator_position = ParseUint32(line, pos_dot + 1, ':', ×tamp_low); - if (separator_position == std::string::npos) { + // We expect to have parsed exactly six digits after the decimal point, to + // match the scaling factor used just below. + if (separator_position != pos_dot + 7) { LOG(ERROR) << "Cannot parse timestamp in trace event: " << line; return false; } - const double timestamp = 1000000L * timestamp_high + timestamp_low; + const uint64_t timestamp = 1000000LL * timestamp_high + timestamp_low; if (timestamp < min_timestamp_ || timestamp >= max_timestamp_) continue;
diff --git a/chrome/browser/chromeos/arc/tracing/arc_tracing_model_unittest.cc b/chrome/browser/chromeos/arc/tracing/arc_tracing_model_unittest.cc index 543e077..3fe0f3e3 100644 --- a/chrome/browser/chromeos/arc/tracing/arc_tracing_model_unittest.cc +++ b/chrome/browser/chromeos/arc/tracing/arc_tracing_model_unittest.cc
@@ -76,7 +76,7 @@ const std::set<GraphicsEventType>& allowed_types) { if (events.empty()) return false; - int64_t previous_timestamp = 0; + uint64_t previous_timestamp = 0; std::set<GraphicsEventType> used_types; for (const auto& event : events) { if (event.timestamp < previous_timestamp) { @@ -190,7 +190,8 @@ // Check trimmed by VSYNC. EXPECT_EQ(GraphicsEventType::kVsync, graphics_model.android_top_level().global_events()[0].type); - EXPECT_EQ(0, graphics_model.android_top_level().global_events()[0].timestamp); + EXPECT_EQ(0U, + graphics_model.android_top_level().global_events()[0].timestamp); EXPECT_EQ(2U, graphics_model.chrome_top_level().buffer_events().size()); for (const auto& chrome_top_level_band : @@ -256,6 +257,91 @@ EnsureGraphicsModelsEqual(graphics_model, graphics_model_loaded); } +// Validates basic system event timestamp processing +TEST_F(ArcTracingModelTest, SystemTraceEventTimestampParsing) { + { + std::string tracing_data = + "{\"traceEvents\":[],\"systemTraceEvents\":\"" + // clang-format off + " surfaceflinger-9772 [000] ...0 80156.539255: tracing_mark_write: B|15|acquireBuffer\n" + // clang-format on + "\"}"; + + ArcTracingModel model; + ASSERT_TRUE(model.Build(tracing_data)); + + const ArcTracingModel::TracingEventPtrs events = + model.Select("android:acquireBuffer"); + ASSERT_EQ(1u, events.size()); + EXPECT_EQ(15, events[0]->GetPid()); + EXPECT_EQ("android", events[0]->GetCategory()); + EXPECT_EQ("acquireBuffer", events[0]->GetName()); + EXPECT_EQ('X', events[0]->GetPhase()); + EXPECT_EQ(80156539255UL, events[0]->GetTimestamp()); + EXPECT_EQ(0U, events[0]->GetDuration()); + } + + { + // Too few digits after the timestamp decimal point should be an error + std::string bad_tracing_data_1 = + "{\"traceEvents\":[],\"systemTraceEvents\":\"" + // clang-format off + " surfaceflinger-9772 [000] ...0 999.12345: tracing_mark_write: B|15|acquireBuffer\n" + // clang-format on + "\"}"; + ArcTracingModel model; + EXPECT_FALSE(model.Build(bad_tracing_data_1)); + } + + { + // Too many digits after the timestamp decimal point should be an error + std::string bad_tracing_data_2 = + "{\"traceEvents\":[],\"systemTraceEvents\":\"" + // clang-format off + " surfaceflinger-9772 [000] ...0 999.1234567: tracing_mark_write: B|15|acquireBuffer\n" + // clang-format on + "\"}"; + ArcTracingModel model; + EXPECT_FALSE(model.Build(bad_tracing_data_2)); + } +} + +TEST_F(ArcTracingModelTest, SystemTraceEventCpuEventProcessing) { + std::string tracing_data = + "{\"traceEvents\":[],\"systemTraceEvents\":\"" + // clang-format off + " <idle>-0 [000] d..0 123.000001: cpu_idle: state=0 cpu_id=0\n" + " <idle>-0 [000] dn.0 123.000002: cpu_idle: state=4294967295 cpu_id=0\n" + " <idle>-0 [000] dnh3 123.000003: sched_wakeup: comm=foo pid=15821 prio=115 target_cpu=000\n" + " <idle>-0 [000] d..3 123.000004: sched_switch: prev_comm=bar prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=baz next_pid=15821 next_prio=115\n" + // clang-format on + "\"}"; + + ArcTracingModel model; + ASSERT_TRUE(model.Build(tracing_data)); + + const AllCpuEvents& cpu_events = model.system_model().all_cpu_events(); + ASSERT_EQ(1u, cpu_events.size()); + CpuEvents cpu0_events = cpu_events[0]; + ASSERT_EQ(4u, cpu0_events.size()); + + EXPECT_EQ(123000001UL, cpu0_events[0].timestamp); + EXPECT_EQ(ArcCpuEvent::Type::kIdleIn, cpu0_events[0].type); + EXPECT_EQ(0u, cpu0_events[0].tid); + + EXPECT_EQ(123000002UL, cpu0_events[1].timestamp); + EXPECT_EQ(ArcCpuEvent::Type::kIdleOut, cpu0_events[1].type); + EXPECT_EQ(0u, cpu0_events[1].tid); + + EXPECT_EQ(123000003UL, cpu0_events[2].timestamp); + EXPECT_EQ(ArcCpuEvent::Type::kWakeUp, cpu0_events[2].type); + EXPECT_EQ(15821u, cpu0_events[2].tid); + + EXPECT_EQ(123000004UL, cpu0_events[3].timestamp); + EXPECT_EQ(ArcCpuEvent::Type::kActive, cpu0_events[3].type); + EXPECT_EQ(15821u, cpu0_events[3].tid); +} + TEST_F(ArcTracingModelTest, Event) { const ArcTracingEvent event(base::JSONReader::Read(kTestEvent).value()); @@ -265,9 +351,9 @@ EXPECT_EQ(kExo, event.GetCategory()); EXPECT_EQ(kSurfaceAttach, event.GetName()); EXPECT_EQ(kPhaseX, event.GetPhase()); - EXPECT_EQ(14241877057L, event.GetTimestamp()); - EXPECT_EQ(10, event.GetDuration()); - EXPECT_EQ(14241877067L, event.GetEndTimestamp()); + EXPECT_EQ(14241877057UL, event.GetTimestamp()); + EXPECT_EQ(10U, event.GetDuration()); + EXPECT_EQ(14241877067UL, event.GetEndTimestamp()); EXPECT_NE(nullptr, event.GetDictionary()); EXPECT_EQ(kBufferIdValue, event.GetArgAsString(kBufferId, std::string())); EXPECT_EQ(kDefault, event.GetArgAsString(kBufferIdBad, kDefault)); @@ -411,8 +497,8 @@ model_with_time_filter.SetMinMaxTime(100001L, 100003L); EXPECT_TRUE(model_with_time_filter.Build(tracing_data)); ASSERT_EQ(2U, model_with_time_filter.GetRoots().size()); - EXPECT_EQ(100001L, model_with_time_filter.GetRoots()[0]->GetTimestamp()); - EXPECT_EQ(100002L, model_with_time_filter.GetRoots()[1]->GetTimestamp()); + EXPECT_EQ(100001UL, model_with_time_filter.GetRoots()[0]->GetTimestamp()); + EXPECT_EQ(100002UL, model_with_time_filter.GetRoots()[1]->GetTimestamp()); ArcTracingModel model_with_empty_time_filter; model_with_empty_time_filter.SetMinMaxTime(99999L, 100000L); @@ -468,10 +554,10 @@ &events, trim_timestamp, {ArcTracingGraphicsModel::BufferEventType::kChromeOSDraw}); ASSERT_EQ(3U, events.global_events().size()); - EXPECT_EQ(25, events.global_events()[0].timestamp); + EXPECT_EQ(25U, events.global_events()[0].timestamp); ASSERT_EQ(1U, events.buffer_events().size()); ASSERT_EQ(2U, events.buffer_events()[0].size()); - EXPECT_EQ(40, events.buffer_events()[0][0].timestamp); + EXPECT_EQ(40U, events.buffer_events()[0][0].timestamp); EXPECT_EQ(ArcTracingGraphicsModel::BufferEventType::kChromeOSDraw, events.buffer_events()[0][0].type); }
diff --git a/chrome/browser/chromeos/arc/tracing/arc_value_event.h b/chrome/browser/chromeos/arc/tracing/arc_value_event.h index ef05cd0..652e70d 100644 --- a/chrome/browser/chromeos/arc/tracing/arc_value_event.h +++ b/chrome/browser/chromeos/arc/tracing/arc_value_event.h
@@ -30,7 +30,7 @@ bool operator==(const ArcValueEvent& other) const; - int64_t timestamp; + uint64_t timestamp; Type type; /** * kMemTotal - kb.
diff --git a/chrome/browser/chromeos/extensions/autotest_private/autotest_private_apitest.cc b/chrome/browser/chromeos/extensions/autotest_private/autotest_private_apitest.cc index 5730af88..0327d4a 100644 --- a/chrome/browser/chromeos/extensions/autotest_private/autotest_private_apitest.cc +++ b/chrome/browser/chromeos/extensions/autotest_private/autotest_private_apitest.cc
@@ -4,6 +4,7 @@ #include "base/macros.h" +#include "ash/public/cpp/ash_switches.h" #include "build/build_config.h" #include "chrome/browser/chromeos/arc/arc_session_manager.h" #include "chrome/browser/chromeos/arc/arc_util.h" @@ -16,7 +17,6 @@ #include "components/arc/test/connection_holder_util.h" #include "components/arc/test/fake_app_instance.h" #include "components/prefs/pref_service.h" -#include "services/ws/common/switches.h" namespace extensions { @@ -30,7 +30,7 @@ // Make ARC enabled for tests. arc::SetArcAvailableCommandLineForTesting(command_line); // Enable certain Mojo services like ShelfIntegrationTestApi. - command_line->AppendSwitch(ws::switches::kUseTestConfig); + command_line->AppendSwitch(ash::switches::kAshEnableTestInterfaces); } void SetUpInProcessBrowserTestFixture() override {
diff --git a/chrome/browser/chromeos/printing/automatic_usb_printer_configurer_unittest.cc b/chrome/browser/chromeos/printing/automatic_usb_printer_configurer_unittest.cc index 4b3be9e..78a4b35 100644 --- a/chrome/browser/chromeos/printing/automatic_usb_printer_configurer_unittest.cc +++ b/chrome/browser/chromeos/printing/automatic_usb_printer_configurer_unittest.cc
@@ -138,6 +138,10 @@ open_notifications_.insert(printer.id()); } + void ShowSavedNotification(const Printer& printer) override { + NOTIMPLEMENTED(); + } + void RemoveNotification(const std::string& printer_id) override { open_notifications_.erase(printer_id); }
diff --git a/chrome/browser/chromeos/printing/cups_printers_manager_unittest.cc b/chrome/browser/chromeos/printing/cups_printers_manager_unittest.cc index 796549e8..b9c73fd 100644 --- a/chrome/browser/chromeos/printing/cups_printers_manager_unittest.cc +++ b/chrome/browser/chromeos/printing/cups_printers_manager_unittest.cc
@@ -306,13 +306,18 @@ void ShowEphemeralNotification(const Printer& printer) override { NOTIMPLEMENTED(); } + void ShowSavedNotification(const Printer& printer) override { + open_notifications_.insert(printer.id()); + } void RemoveNotification(const std::string& printer_id) override { - NOTIMPLEMENTED(); + open_notifications_.erase(printer_id); } bool IsNotification(const std::string& printer_id) const override { - NOTIMPLEMENTED(); - return false; + return open_notifications_.contains(printer_id); } + + private: + base::flat_set<std::string> open_notifications_; }; class CupsPrintersManagerTest : public testing::Test,
diff --git a/chrome/browser/chromeos/printing/usb_printer_notification.cc b/chrome/browser/chromeos/printing/usb_printer_notification.cc index 230d492..4f77464 100644 --- a/chrome/browser/chromeos/printing/usb_printer_notification.cc +++ b/chrome/browser/chromeos/printing/usb_printer_notification.cc
@@ -94,6 +94,7 @@ void UsbPrinterNotification::UpdateContents() { switch (type_) { case Type::kEphemeral: + case Type::kSaved: notification_->set_title(l10n_util::GetStringUTF16( IDS_USB_PRINTER_NOTIFICATION_CONNECTED_TITLE)); notification_->set_message(l10n_util::GetStringFUTF16(
diff --git a/chrome/browser/chromeos/printing/usb_printer_notification.h b/chrome/browser/chromeos/printing/usb_printer_notification.h index 9c5eab45..f0a2161f 100644 --- a/chrome/browser/chromeos/printing/usb_printer_notification.h +++ b/chrome/browser/chromeos/printing/usb_printer_notification.h
@@ -26,7 +26,7 @@ // according to its state and respond to the user's action. class UsbPrinterNotification : public message_center::NotificationObserver { public: - enum class Type { kEphemeral }; + enum class Type { kEphemeral, kSaved }; UsbPrinterNotification(const Printer& printer, const std::string& notification_id,
diff --git a/chrome/browser/chromeos/printing/usb_printer_notification_controller.cc b/chrome/browser/chromeos/printing/usb_printer_notification_controller.cc index fd86eb8..154b95f 100644 --- a/chrome/browser/chromeos/printing/usb_printer_notification_controller.cc +++ b/chrome/browser/chromeos/printing/usb_printer_notification_controller.cc
@@ -44,6 +44,20 @@ return base::ContainsKey(notifications_, printer_id); } + void ShowSavedNotification(const Printer& printer) override { + if (!base::FeatureList::IsEnabled(features::kStreamlinedUsbPrinterSetup)) { + return; + } + + if (base::ContainsKey(notifications_, printer.id())) { + return; + } + + notifications_[printer.id()] = std::make_unique<UsbPrinterNotification>( + printer, GetUniqueNotificationId(), + UsbPrinterNotification::Type::kSaved, profile_); + } + private: std::string GetUniqueNotificationId() { return base::StringPrintf("usb_printer_notification_%d",
diff --git a/chrome/browser/chromeos/printing/usb_printer_notification_controller.h b/chrome/browser/chromeos/printing/usb_printer_notification_controller.h index 7990cd9..7b33be85 100644 --- a/chrome/browser/chromeos/printing/usb_printer_notification_controller.h +++ b/chrome/browser/chromeos/printing/usb_printer_notification_controller.h
@@ -29,6 +29,10 @@ // is already an existing notification for |printer|. virtual void ShowEphemeralNotification(const Printer& printer) = 0; + // Creates a notification for a saved printer. This is a no-op if there + // is already an existing notification for |printer|. + virtual void ShowSavedNotification(const Printer& printer) = 0; + // Closes the notification for |printer_id|. This is a no-op if the // notification has already been closed by the user. virtual void RemoveNotification(const std::string& printer_id) = 0;
diff --git a/chrome/browser/component_updater/third_party_module_list_component_installer_win.cc b/chrome/browser/component_updater/third_party_module_list_component_installer_win.cc index 1f1ef7b..64089ce 100644 --- a/chrome/browser/component_updater/third_party_module_list_component_installer_win.cc +++ b/chrome/browser/component_updater/third_party_module_list_component_installer_win.cc
@@ -14,9 +14,9 @@ #include "base/memory/ref_counted.h" #include "base/values.h" #include "base/version.h" -#include "chrome/browser/conflicts/module_blacklist_cache_util_win.h" -#include "chrome/browser/conflicts/module_database_win.h" -#include "chrome/browser/conflicts/third_party_conflicts_manager_win.h" +#include "chrome/browser/win/conflicts/module_blacklist_cache_util.h" +#include "chrome/browser/win/conflicts/module_database.h" +#include "chrome/browser/win/conflicts/third_party_conflicts_manager.h" namespace component_updater {
diff --git a/chrome/browser/component_updater/third_party_module_list_component_installer_win.h b/chrome/browser/component_updater/third_party_module_list_component_installer_win.h index bd42a3d..f30be382 100644 --- a/chrome/browser/component_updater/third_party_module_list_component_installer_win.h +++ b/chrome/browser/component_updater/third_party_module_list_component_installer_win.h
@@ -21,7 +21,7 @@ // Component for receiving Third Party Module Lists. The lists are in proto // format, corresponding to the proto definition in -// chrome/browser/conflicts/proto/module_list.proto +// chrome/browser/win/conflicts/proto/module_list.proto // // Notifications of a new version of the module list are sent to the // ThirdPartyConflictsManager instance in the ModuleDatabase, if it exists.
diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc index 04892b85..36fa4727 100644 --- a/chrome/browser/download/chrome_download_manager_delegate.cc +++ b/chrome/browser/download/chrome_download_manager_delegate.cc
@@ -596,15 +596,6 @@ return false; } -bool ChromeDownloadManagerDelegate::GenerateFileHash() { -#if defined(FULL_SAFE_BROWSING) - return profile_->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled) && - g_browser_process->safe_browsing_service()->DownloadBinHashNeeded(); -#else - return false; -#endif -} - void ChromeDownloadManagerDelegate::GetSaveDir( content::BrowserContext* browser_context, base::FilePath* website_save_dir,
diff --git a/chrome/browser/download/chrome_download_manager_delegate.h b/chrome/browser/download/chrome_download_manager_delegate.h index e34a0af2..672eb50 100644 --- a/chrome/browser/download/chrome_download_manager_delegate.h +++ b/chrome/browser/download/chrome_download_manager_delegate.h
@@ -99,7 +99,6 @@ const std::string& request_origin, int64_t content_length, content::WebContents* web_contents) override; - bool GenerateFileHash() override; void GetSaveDir(content::BrowserContext* browser_context, base::FilePath* website_save_dir, base::FilePath* download_save_dir,
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json index f24c991..6282019 100644 --- a/chrome/browser/flag-metadata.json +++ b/chrome/browser/flag-metadata.json
@@ -2496,46 +2496,6 @@ "expiry_milestone": 80 }, { - "name": "omnibox-ui-blue-search-loop-and-search-query", - "owners": [ "tommycli", "chrome-omnibox-team@google.com" ], - "expiry_milestone": 80 - }, - { - "name": "omnibox-ui-blue-titles-and-gray-urls-on-page-suggestions", - "owners": [ "tommycli", "chrome-omnibox-team@google.com" ], - "expiry_milestone": 80 - }, - { - "name": "omnibox-ui-blue-titles-on-page-suggestions", - "owners": [ "tommycli", "chrome-omnibox-team@google.com" ], - "expiry_milestone": 80 - }, - { - "name": "omnibox-ui-show-suffix-on-all-search-suggestions", - "owners": [ "tommycli", "chrome-omnibox-team@google.com" ], - "expiry_milestone": 80 - }, - { - "name": "omnibox-ui-white-background-on-blur", - "owners": [ "tommycli", "chrome-omnibox-team@google.com" ], - "expiry_milestone": 80 - }, - { - "name": "omnibox-ui-use-generic-search-engine-icon", - "owners": [ "tommycli", "chrome-omnibox-team@google.com" ], - "expiry_milestone": 80 - }, - { - "name": "omnibox-ui-bold-user-text-on-search-suggestions", - "owners": [ "tommycli", "chrome-omnibox-team@google.com" ], - "expiry_milestone": 80 - }, - { - "name": "omnibox-ui-unbold-suggestion-text", - "owners": [ "tommycli", "chrome-omnibox-team@google.com" ], - "expiry_milestone": 80 - }, - { "name": "omnibox-ui-vertical-margin", "owners": [ "tommycli", "chrome-omnibox-team@google.com" ], "expiry_milestone": 80
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc index ec07d37a..d8bd2e4 100644 --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc
@@ -1274,26 +1274,6 @@ "When the omnibox is focused, start an empty spare renderer. This can " "speed up the load of the navigation from the omnibox."; -const char kOmniboxUIBlueSearchLoopAndSearchQueryName[] = - "Omnibox UI Blue Search Loop and Search Query"; -const char kOmniboxUIBlueSearchLoopAndSearchQueryDescription[] = - "Color the generic search icon and search terms blue."; - -const char kOmniboxUIBlueTitlesAndGrayUrlsOnPageSuggestionsName[] = - "Omnibox UI Blue Titles And Gray Urls On Page Suggestions"; -const char kOmniboxUIBlueTitlesAndGrayUrlsOnPageSuggestionsDescription[] = - "Displays navigation suggestions with blue titles and gray URLs."; - -const char kOmniboxUIBlueTitlesOnPageSuggestionsName[] = - "Omnibox UI Blue Titles On Page Suggestions"; -const char kOmniboxUIBlueTitlesOnPageSuggestionsDescription[] = - "Displays navigation suggestions with blue titles."; - -const char kOmniboxUIBoldUserTextOnSearchSuggestionsName[] = - "Omnibox UI Bold User Text On Search Suggestions"; -const char kOmniboxUIBoldUserTextOnSearchSuggestionsDescription[] = - "Bolds the user text instead of autocomplete text for search suggestions."; - const char kOmniboxUICuesForSearchHistoryMatchesName[] = "Omnibox UI Cues to Differentiate Search History Matches"; const char kOmniboxUICuesForSearchHistoryMatchesDescription[] = @@ -1335,12 +1315,6 @@ "Shows the \"Search Google or type a URL\" placeholder text in the " "omnibox when it's focused / the caret cursor is showing."; -const char kOmniboxUIShowSuffixOnAllSearchSuggestionsName[] = - "Omnibox UI Show Suffix On All Search Suggestions"; -const char kOmniboxUIShowSuffixOnAllSearchSuggestionsDescription[] = - "Shows the search suffix (e.g. \" - Google Search\") on all search " - "suggestions in the omnibox."; - const char kOmniboxUIShowSuggestionFaviconsName[] = "Omnibox UI Show Suggestion Favicons"; const char kOmniboxUIShowSuggestionFaviconsDescription[] = @@ -1352,17 +1326,6 @@ "In the omnibox dropdown, shows titles before URLs when both are " "available."; -const char kOmniboxUIUnboldSuggestionTextName[] = - "Omnibox UI Unbold Suggestion Text"; -const char kOmniboxUIUnboldSuggestionTextDescription[] = - "Displays search suggestions without bolding."; - -const char kOmniboxUIUseGenericSearchEngineIconName[] = - "Omnibox UI Use Generic Search Engine Icon"; -const char kOmniboxUIUseGenericSearchEngineIconDescription[] = - "In the omnibox and NTP, shows a generic magnifying glass icon instead of " - "the Search Provider favicon."; - const char kOmniboxUIVerticalMarginName[] = "Omnibox UI Vertical Margin"; const char kOmniboxUIVerticalMarginDescription[] = "Changes the vertical margin in the Omnibox UI."; @@ -1373,11 +1336,6 @@ "Limits the vertical margin UI experiment to non-touch devices only. Has " "no effect if the Omnibox Vertical Margin experiment is not enabled."; -const char kOmniboxUIWhiteBackgroundOnBlurName[] = - "Omnibox UI White Background On Blur"; -const char kOmniboxUIWhiteBackgroundOnBlurDescription[] = - "Set the omnibox background white when it's unfocused"; - const char kOmniboxZeroSuggestionsOnNTPName[] = "Omnibox Zero Suggestions on New Tab Page"; const char kOmniboxZeroSuggestionsOnNTPDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h index 2837f15..51ce1f68 100644 --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h
@@ -784,18 +784,6 @@ extern const char kOmniboxSpareRendererName[]; extern const char kOmniboxSpareRendererDescription[]; -extern const char kOmniboxUIBlueSearchLoopAndSearchQueryName[]; -extern const char kOmniboxUIBlueSearchLoopAndSearchQueryDescription[]; - -extern const char kOmniboxUIBlueTitlesAndGrayUrlsOnPageSuggestionsName[]; -extern const char kOmniboxUIBlueTitlesAndGrayUrlsOnPageSuggestionsDescription[]; - -extern const char kOmniboxUIBlueTitlesOnPageSuggestionsName[]; -extern const char kOmniboxUIBlueTitlesOnPageSuggestionsDescription[]; - -extern const char kOmniboxUIBoldUserTextOnSearchSuggestionsName[]; -extern const char kOmniboxUIBoldUserTextOnSearchSuggestionsDescription[]; - extern const char kOmniboxUICuesForSearchHistoryMatchesName[]; extern const char kOmniboxUICuesForSearchHistoryMatchesDescription[]; @@ -817,30 +805,18 @@ extern const char kOmniboxUIShowPlaceholderWhenCaretShowingName[]; extern const char kOmniboxUIShowPlaceholderWhenCaretShowingDescription[]; -extern const char kOmniboxUIShowSuffixOnAllSearchSuggestionsName[]; -extern const char kOmniboxUIShowSuffixOnAllSearchSuggestionsDescription[]; - extern const char kOmniboxUIShowSuggestionFaviconsName[]; extern const char kOmniboxUIShowSuggestionFaviconsDescription[]; extern const char kOmniboxUISwapTitleAndUrlName[]; extern const char kOmniboxUISwapTitleAndUrlDescription[]; -extern const char kOmniboxUIUnboldSuggestionTextName[]; -extern const char kOmniboxUIUnboldSuggestionTextDescription[]; - -extern const char kOmniboxUIUseGenericSearchEngineIconName[]; -extern const char kOmniboxUIUseGenericSearchEngineIconDescription[]; - extern const char kOmniboxUIVerticalMarginName[]; extern const char kOmniboxUIVerticalMarginDescription[]; extern const char kOmniboxUIVerticalMarginLimitToNonTouchOnlyName[]; extern const char kOmniboxUIVerticalMarginLimitToNonTouchOnlyDescription[]; -extern const char kOmniboxUIWhiteBackgroundOnBlurName[]; -extern const char kOmniboxUIWhiteBackgroundOnBlurDescription[]; - extern const char kOmniboxZeroSuggestionsOnNTPName[]; extern const char kOmniboxZeroSuggestionsOnNTPDescription[];
diff --git a/chrome/browser/mac/install.sh b/chrome/browser/mac/install.sh index a7c2a3d7..ab514bb 100755 --- a/chrome/browser/mac/install.sh +++ b/chrome/browser/mac/install.sh
@@ -49,7 +49,7 @@ fi # Do the copy. -rsync -lrpt "${SRC}/" "${DEST}" +rsync --links --recursive --perms --times "${SRC}/" "${DEST}" # The remaining steps are not considered critical. set +e
diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc index d1abf84..d0fa1197 100644 --- a/chrome/browser/metrics/chrome_metrics_service_client.cc +++ b/chrome/browser/metrics/chrome_metrics_service_client.cc
@@ -43,7 +43,6 @@ #include "chrome/browser/metrics/https_engagement_metrics_provider.h" #include "chrome/browser/metrics/metrics_reporting_state.h" #include "chrome/browser/metrics/network_quality_estimator_provider_impl.h" -#include "chrome/browser/metrics/persistent_histograms.h" #include "chrome/browser/metrics/process_memory_metrics_emitter.h" #include "chrome/browser/metrics/sampling_metrics_provider.h" #include "chrome/browser/metrics/subprocess_metrics_provider.h" @@ -78,6 +77,7 @@ #include "components/metrics/net/cellular_logic_helper.h" #include "components/metrics/net/net_metrics_log_uploader.h" #include "components/metrics/net/network_metrics_provider.h" +#include "components/metrics/persistent_histograms.h" #include "components/metrics/stability_metrics_helper.h" #include "components/metrics/ui/screen_info_metrics_provider.h" #include "components/metrics/url_constants.h"
diff --git a/chrome/browser/metrics/metrics_service_browsertest.cc b/chrome/browser/metrics/metrics_service_browsertest.cc index 2782549..f78d368 100644 --- a/chrome/browser/metrics/metrics_service_browsertest.cc +++ b/chrome/browser/metrics/metrics_service_browsertest.cc
@@ -23,7 +23,6 @@ #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" #include "chrome/browser/metrics/chrome_metrics_service_client.h" #include "chrome/browser/metrics/chrome_metrics_services_manager_client.h" -#include "chrome/browser/metrics/persistent_histograms.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_paths.h" @@ -33,6 +32,7 @@ #include "components/metrics/metrics_pref_names.h" #include "components/metrics/metrics_reporting_default_state.h" #include "components/metrics/metrics_switches.h" +#include "components/metrics/persistent_histograms.h" #include "components/prefs/json_pref_store.h" #include "components/prefs/pref_service.h" #include "content/public/test/browser_test_utils.h"
diff --git a/chrome/browser/metrics/perf/process_type_collector.cc b/chrome/browser/metrics/perf/process_type_collector.cc index eee93f98..fa8b6e5 100644 --- a/chrome/browser/metrics/perf/process_type_collector.cc +++ b/chrome/browser/metrics/perf/process_type_collector.cc
@@ -170,6 +170,12 @@ base::StartsWith(cmd, "VizCompositorTh", base::CompareCase::SENSITIVE)) { thread = Thread::COMPOSITOR_THREAD; + } else if (base::StartsWith(cmd, "TaskScheduler", + base::CompareCase::SENSITIVE)) { + thread = Thread::SCHEDULER_WORKER_THREAD; + } else if (base::StartsWith(cmd, "CompositorTileW", + base::CompareCase::SENSITIVE)) { + thread = Thread::COMPOSITOR_TILE_WORKER_THREAD; } thread_types.emplace(tid, thread);
diff --git a/chrome/browser/metrics/perf/process_type_collector_unittest.cc b/chrome/browser/metrics/perf/process_type_collector_unittest.cc index 24279b5..9c90495 100644 --- a/chrome/browser/metrics/perf/process_type_collector_unittest.cc +++ b/chrome/browser/metrics/perf/process_type_collector_unittest.cc
@@ -62,6 +62,8 @@ 10000 12107 Chrome_ChildIOT /opt/google/chrome/chrome --type=gpu-process 11000 12207 VizCompositorTh /opt/google/chrome/chrome --type=gpu-process 12103 12112 Compositor /opt/google/chrome/chrome --type=gpu-process + 15000 15112 TaskSchedulerFo /opt/google/chrome/chrome --type=renderer + 16000 16112 CompositorTileW /opt/google/chrome/chrome --type=renderer 12345 12456 OtherThread /opt/google/chrome/chrome --ppapi-flash-path=... 13456 13566 Compositor non_chrome_exec --some-flag=foo)text"; thread_types->insert( @@ -74,6 +76,10 @@ 12207, Thread::COMPOSITOR_THREAD)); thread_types->insert(google::protobuf::MapPair<uint32_t, Thread>( 12112, Thread::COMPOSITOR_THREAD)); + thread_types->insert(google::protobuf::MapPair<uint32_t, Thread>( + 15112, Thread::SCHEDULER_WORKER_THREAD)); + thread_types->insert(google::protobuf::MapPair<uint32_t, Thread>( + 16112, Thread::COMPOSITOR_TILE_WORKER_THREAD)); thread_types->insert( google::protobuf::MapPair<uint32_t, Thread>(12456, Thread::OTHER_THREAD)); }
diff --git a/chrome/browser/picture_in_picture/picture_in_picture_window_controller_browsertest.cc b/chrome/browser/picture_in_picture/picture_in_picture_window_controller_browsertest.cc index d1a0480..f258175 100644 --- a/chrome/browser/picture_in_picture/picture_in_picture_window_controller_browsertest.cc +++ b/chrome/browser/picture_in_picture/picture_in_picture_window_controller_browsertest.cc
@@ -2046,6 +2046,10 @@ EXPECT_TRUE( overlay_window->next_track_controls_view_for_testing()->IsDrawn()); + gfx::Rect next_track_bounds = + overlay_window->next_track_controls_view_for_testing() + ->GetContentsBounds(); + // Unset action handler and check that Next Track button is not displayed when // video plays and mouse is hovering over the window. ASSERT_TRUE(content::ExecuteScript( @@ -2054,6 +2058,11 @@ MoveMouseOver(overlay_window); EXPECT_FALSE( overlay_window->next_track_controls_view_for_testing()->IsDrawn()); + + // Next Track button is still at the same previous location. + EXPECT_EQ(next_track_bounds, + overlay_window->next_track_controls_view_for_testing() + ->GetContentsBounds()); } // Tests that a Previous Track button is displayed in the Picture-in-Picture @@ -2092,6 +2101,10 @@ EXPECT_TRUE( overlay_window->previous_track_controls_view_for_testing()->IsDrawn()); + gfx::Rect previous_track_bounds = + overlay_window->previous_track_controls_view_for_testing() + ->GetContentsBounds(); + // Unset action handler and check that Previous Track button is not displayed // when video plays and mouse is hovering over the window. ASSERT_TRUE(content::ExecuteScript( @@ -2100,6 +2113,11 @@ MoveMouseOver(overlay_window); EXPECT_FALSE( overlay_window->previous_track_controls_view_for_testing()->IsDrawn()); + + // Previous Track button is still at the same previous location. + EXPECT_EQ(previous_track_bounds, + overlay_window->previous_track_controls_view_for_testing() + ->GetContentsBounds()); } // Tests that clicking the Skip Ad button in the Picture-in-Picture window
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc index ad8ac8e..9ae3aaba 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc
@@ -327,9 +327,9 @@ #if defined(OS_WIN) #include "chrome/browser/component_updater/sw_reporter_installer_win.h" #if defined(GOOGLE_CHROME_BUILD) -#include "chrome/browser/conflicts/incompatible_applications_updater_win.h" -#include "chrome/browser/conflicts/module_database_win.h" -#include "chrome/browser/conflicts/third_party_conflicts_manager_win.h" +#include "chrome/browser/win/conflicts/incompatible_applications_updater.h" +#include "chrome/browser/win/conflicts/module_database.h" +#include "chrome/browser/win/conflicts/third_party_conflicts_manager.h" #endif // defined(GOOGLE_CHROME_BUILD) #include "chrome/browser/safe_browsing/chrome_cleaner/settings_resetter_win.h" #include "chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_prefs_manager.h"
diff --git a/chrome/browser/printing/cloud_print/privet_url_loader.cc b/chrome/browser/printing/cloud_print/privet_url_loader.cc index 9a12c71..e033ccb 100644 --- a/chrome/browser/printing/cloud_print/privet_url_loader.cc +++ b/chrome/browser/printing/cloud_print/privet_url_loader.cc
@@ -155,8 +155,8 @@ request->url = url_; request->method = request_type_; // Privet requests are relevant to hosts on local network only. - request->load_flags = net::LOAD_BYPASS_PROXY | net::LOAD_DISABLE_CACHE | - net::LOAD_DO_NOT_SEND_COOKIES; + request->load_flags = net::LOAD_BYPASS_PROXY | net::LOAD_DISABLE_CACHE; + request->allow_credentials = false; std::string token = GetPrivetAccessToken(); if (token.empty())
diff --git a/chrome/browser/printing/print_preview_dialog_controller.cc b/chrome/browser/printing/print_preview_dialog_controller.cc index ab6f9f4..c26ddaa 100644 --- a/chrome/browser/printing/print_preview_dialog_controller.cc +++ b/chrome/browser/printing/print_preview_dialog_controller.cc
@@ -47,7 +47,7 @@ #include "ui/web_dialogs/web_dialog_delegate.h" #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) -#include "chrome/browser/conflicts/module_database_win.h" +#include "chrome/browser/win/conflicts/module_database.h" #endif using content::NavigationController;
diff --git a/chrome/browser/printing/printing_message_filter.cc b/chrome/browser/printing/printing_message_filter.cc index 0291dfde..1f79e7b 100644 --- a/chrome/browser/printing/printing_message_filter.cc +++ b/chrome/browser/printing/printing_message_filter.cc
@@ -32,7 +32,7 @@ #endif #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) -#include "chrome/browser/conflicts/module_database_win.h" +#include "chrome/browser/win/conflicts/module_database.h" #endif using content::BrowserThread;
diff --git a/chrome/browser/resources/bookmarks/command_manager.js b/chrome/browser/resources/bookmarks/command_manager.js index 8f153dd..a1675b32 100644 --- a/chrome/browser/resources/bookmarks/command_manager.js +++ b/chrome/browser/resources/bookmarks/command_manager.js
@@ -358,11 +358,7 @@ this.openUrls_(this.expandUrls_(itemIds), command); break; case Command.OPEN: - const isFolder = itemIds.size == 1 && - this.containsMatchingNode_(itemIds, function(node) { - return !node.url; - }); - if (isFolder) { + if (this.isFolder_(itemIds)) { const folderId = Array.from(itemIds)[0]; this.dispatch( bookmarks.actions.selectFolder(folderId, state.nodes)); @@ -414,9 +410,8 @@ default: assert(false); } - - bookmarks.util.recordEnumHistogram( - 'BookmarkManager.CommandExecuted', command, Command.MAX_VALUE); + this.recordCommandHistogram_( + itemIds, 'BookmarkManager.CommandExecuted', command); }, /** @@ -433,9 +428,8 @@ if (shortcut.matchesEvent(e) && this.canExecute(command, itemIds)) { this.handle(command, itemIds); - bookmarks.util.recordEnumHistogram( - 'BookmarkManager.CommandExecutedFromKeyboard', command, - Command.MAX_VALUE); + this.recordCommandHistogram_( + itemIds, 'BookmarkManager.CommandExecutedFromKeyboard', command); e.stopPropagation(); e.preventDefault(); return true; @@ -579,6 +573,7 @@ * @param {!Set<string>} itemIds * @return {boolean} True if |itemIds| is a single bookmark (non-folder) * node. + * @private */ isSingleBookmark_: function(itemIds) { return itemIds.size == 1 && @@ -588,6 +583,16 @@ }, /** + * @param {!Set<string>} itemIds + * @return {boolean} + * @private + */ + isFolder_: function(itemIds) { + return itemIds.size == 1 && + this.containsMatchingNode_(itemIds, node => !node.url); + }, + + /** * @param {Command} command * @return {string} * @private @@ -722,6 +727,7 @@ /** * @param {Command} command + * @param {!Set<string>} itemIds * @return {boolean} * @private */ @@ -734,6 +740,21 @@ }, /** + * @param {!Set<string>} itemIds + * @param {string} histogram + * @param {number} command + * @private + */ + recordCommandHistogram_: function(itemIds, histogram, command) { + if (command == Command.OPEN) { + command = this.isFolder_(itemIds) ? Command.OPEN_FOLDER : + Command.OPEN_BOOKMARK; + } + + bookmarks.util.recordEnumHistogram(histogram, command, Command.MAX_VALUE); + }, + + /** * Show a toast with a bookmark |title| inserted into a label, with the * title ellipsised if necessary. * @param {!Promise<string>} labelPromise Promise which resolves with the
diff --git a/chrome/browser/resources/bookmarks/constants.js b/chrome/browser/resources/bookmarks/constants.js index 87f3d5e..45b3f85 100644 --- a/chrome/browser/resources/bookmarks/constants.js +++ b/chrome/browser/resources/bookmarks/constants.js
@@ -32,7 +32,7 @@ OPEN_INCOGNITO: 6, UNDO: 7, REDO: 8, - // OPEN triggers when you double-click an item. + // OPEN triggers when you double-click an item. NOT USED FOR METRICS. OPEN: 9, SELECT_ALL: 10, DESELECT_ALL: 11, @@ -46,8 +46,12 @@ EXPORT: 19, HELP_CENTER: 20, + // Added for more precise metrics purposes. OPEN is re-mapped to one of these. + OPEN_BOOKMARK: 21, + OPEN_FOLDER: 22, + // Append new values to the end of the enum. - MAX_VALUE: 21, + MAX_VALUE: 23, }; /**
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js index d5298b9..870f266 100644 --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js
@@ -2046,6 +2046,10 @@ if (!this.enableHints_ || localStorage['useVerboseMode'] != 'true') return; + // No hints for alerts, which can be targeted at controls. + if (type == EventType.ALERT) + return; + // Hints are not yet specialized for braille. if (this.formatOptions_.braille) return;
diff --git a/chrome/browser/resources/conflicts/OWNERS b/chrome/browser/resources/conflicts/OWNERS index 4495bb1..736d632 100644 --- a/chrome/browser/resources/conflicts/OWNERS +++ b/chrome/browser/resources/conflicts/OWNERS
@@ -1 +1 @@ -file://chrome/browser/conflicts/OWNERS +file://chrome/browser/win/conflicts/OWNERS
diff --git a/chrome/browser/resources/local_ntp/custom_backgrounds.js b/chrome/browser/resources/local_ntp/custom_backgrounds.js index d9c4afc..29e2594b 100644 --- a/chrome/browser/resources/local_ntp/custom_backgrounds.js +++ b/chrome/browser/resources/local_ntp/custom_backgrounds.js
@@ -617,8 +617,16 @@ customBackgrounds.selectedTile = null; $(customBackgrounds.IDS.MENU_DONE).tabIndex = -1; - // Remove selected check. - tile.innerHTML = ''; + // Remove selected check and circle. + for (let i = 0; i < tile.children.length; ++i) { + if (tile.children[i].classList.contains( + customBackgrounds.CLASSES.SELECTED_CHECK) || + tile.children[i].classList.contains( + customBackgrounds.CLASSES.SELECTED_CIRCLE)) { + tile.removeChild(tile.children[i]); + --i; + } + } };
diff --git a/chrome/browser/resources/local_ntp/icons/header.svg b/chrome/browser/resources/local_ntp/icons/header.svg new file mode 100644 index 0000000..dc6ba05 --- /dev/null +++ b/chrome/browser/resources/local_ntp/icons/header.svg
@@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg width="130px" height="40px" viewBox="0 0 130 40" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> + <!-- Generator: Sketch 54.1 (76490) - https://sketchapp.com --> + <title>ic-ntp-shortcuts-header</title> + <desc>Created with Sketch.</desc> + <g id="ic-ntp-shortcuts-header" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> + <path d="M39.9720015,16.9685185 C35.2874047,16.9685185 31.3516129,13.1592593 31.3516129,8.48425926 C31.3516129,3.80925926 35.2874047,0 39.9720015,0 C42.5654235,0 44.4100406,1.01154971 45.7980692,2.34205653 L44.1634828,3.97329435 C43.1681202,3.04376218 41.8166186,2.31471735 39.9720015,2.31471735 C36.5475887,2.31471735 33.8719808,5.0668616 33.8719808,8.48425926 C33.8719808,11.9007456 36.5475887,14.6538012 39.9720015,14.6538012 C42.191021,14.6538012 43.451205,13.7598099 44.2639323,12.9587719 C44.9305513,12.2935185 45.3597444,11.3457602 45.5241162,10.0425926 L39.9720015,10.0425926 L39.9720015,7.71876218 L47.7887946,7.71876218 C47.8709805,8.1288499 47.9166393,8.63006823 47.9166393,9.16773879 C47.9166393,10.9083333 47.4417874,13.0590156 45.9076504,14.5900097 C44.4100406,16.13923 42.5106329,16.9685185 39.9720015,16.9685185 Z M57.7623449,11.6019069 C57.7623449,9.61860141 56.3528333,8.26885183 54.7236576,8.26885183 C53.0944819,8.26885183 51.6849704,9.62778338 51.6849704,11.6019069 C51.6849704,13.5576665 53.0944819,14.934962 54.7236576,14.934962 C56.3528333,14.934962 57.7623449,13.5668485 57.7623449,11.6019069 Z M60.132887,11.6019069 C60.132887,14.7696866 57.7074288,17.1019069 54.7236576,17.1019069 C51.7398864,17.1019069 49.3144282,14.7696866 49.3144282,11.6019069 C49.3144282,8.41576335 51.7398864,6.10190692 54.7236576,6.10190692 C57.7074288,6.10190692 60.132887,8.41576335 60.132887,11.6019069 Z M69.8146875,11.6019069 C69.8146875,9.61860141 68.405176,8.26885183 66.7760003,8.26885183 C65.1468246,8.26885183 63.737313,9.62778338 63.737313,11.6019069 C63.737313,13.5576665 65.1468246,14.934962 66.7760003,14.934962 C68.405176,14.944144 69.8146875,13.5668485 69.8146875,11.6019069 Z M72.176077,11.6019069 C72.176077,14.7696866 69.7506188,17.1019069 66.7668476,17.1019069 C63.7922291,17.1019069 61.3576182,14.7696866 61.3576182,11.6019069 C61.3576182,8.41576335 63.7830764,6.10190692 66.7668476,6.10190692 C69.7506188,6.10190692 72.176077,8.41576335 72.176077,11.6019069 Z M81.7090477,11.6177388 C81.7090477,9.68765502 80.4315539,8.26982095 78.8097711,8.26982095 C77.1608075,8.26982095 75.7836511,9.6785077 75.7836511,11.6177388 C75.7836511,13.529528 77.1608075,14.9199201 78.8097711,14.9199201 C80.4315539,14.9199201 81.7090477,13.529528 81.7090477,11.6177388 Z M83.8110232,6.44035763 L83.8110232,16.2828703 C83.8110232,20.3351315 81.4463007,21.9907958 78.6466868,21.9907958 C76.0101571,21.9907958 74.4345815,20.2070691 73.8366057,18.7526457 L75.9114005,17.8836507 C76.2828703,18.7810024 77.1888943,19.8320291 78.6466868,19.8320291 C80.4415202,19.8320291 81.5459634,18.7069092 81.5459634,16.6121737 L81.5459634,15.8255044 L81.4644212,15.8255044 C80.9307731,16.4941733 79.8969998,17.0695395 78.6013856,17.0695395 C75.8833138,17.0695395 73.4008082,14.6820899 73.4008082,11.6085915 C73.4008082,8.5167985 75.892374,6.10190692 78.6013856,6.10190692 C79.8969998,6.10190692 80.9307731,6.68733518 81.4644212,7.32764734 L81.5459634,7.32764734 L81.5459634,6.44035763 L83.8110232,6.44035763 Z M85.8522419,16.6944995 L85.8522419,0.60190692 L88.3017042,0.60190692 L88.3017042,16.6944995 L85.8522419,16.6944995 Z M91.8324784,11.4274495 L96.71994,9.38905216 C96.4472999,8.70040442 95.6448808,8.22294198 94.6865371,8.22294198 C93.4646717,8.22294198 91.7695614,9.30641443 91.8324784,11.4274495 Z M97.5679511,13.410755 L99.4281043,14.6595029 C98.82629,15.559336 97.3764647,17.1019069 94.8689051,17.1019069 C91.7595312,17.1019069 89.5264354,14.6870488 89.5264354,11.6019069 C89.5264354,8.33312562 91.7868864,6.10190692 94.6044715,6.10190692 C97.4402935,6.10190692 98.82629,8.3698535 99.28221,9.60023747 L99.5284067,10.2246114 L92.2254814,13.2730255 C92.7807918,14.3748618 93.6561581,14.944144 94.8780235,14.944144 C96.1008007,14.944144 96.9479,14.328952 97.5679511,13.410755 Z" id="Combined-Shape" fill="#000000"></path> + <rect id="Rectangle" fill="#000000" x="0" y="30" width="130" height="10" rx="5"></rect> + </g> +</svg> \ No newline at end of file
diff --git a/chrome/browser/resources/local_ntp/icons/shortcut-circles.svg b/chrome/browser/resources/local_ntp/icons/shortcut-circles.svg new file mode 100644 index 0000000..18b8c40 --- /dev/null +++ b/chrome/browser/resources/local_ntp/icons/shortcut-circles.svg
@@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg width="116px" height="42px" viewBox="0 0 116 42" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> + <!-- Generator: Sketch 54.1 (76490) - https://sketchapp.com --> + <title>ic-ntp-shortcuts-shortcuts</title> + <desc>Created with Sketch.</desc> + <g id="ic-ntp-shortcuts-shortcuts" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> + <path d="M6.00869565,11.3801242 C2.92962241,11.3801242 0.433540373,8.88404218 0.433540373,5.80496894 C0.433540373,2.72589571 2.92962241,0.229813665 6.00869565,0.229813665 C9.08776889,0.229813665 11.5838509,2.72589571 11.5838509,5.80496894 C11.5838509,8.88404218 9.08776889,11.3801242 6.00869565,11.3801242 Z M58.0434783,11.3801242 C54.964405,11.3801242 52.468323,8.88404218 52.468323,5.80496894 C52.468323,2.72589571 54.964405,0.229813665 58.0434783,0.229813665 C61.1225515,0.229813665 63.6186335,2.72589571 63.6186335,5.80496894 C63.6186335,8.88404218 61.1225515,11.3801242 58.0434783,11.3801242 Z M32.026087,11.3801242 C28.9470137,11.3801242 26.4509317,8.88404218 26.4509317,5.80496894 C26.4509317,2.72589571 28.9470137,0.229813665 32.026087,0.229813665 C35.1051602,0.229813665 37.6012422,2.72589571 37.6012422,5.80496894 C37.6012422,8.88404218 35.1051602,11.3801242 32.026087,11.3801242 Z M84.0608696,11.3801242 C80.9817963,11.3801242 78.4857143,8.88404218 78.4857143,5.80496894 C78.4857143,2.72589571 80.9817963,0.229813665 84.0608696,0.229813665 C87.1399428,0.229813665 89.6360248,2.72589571 89.6360248,5.80496894 C89.6360248,8.88404218 87.1399428,11.3801242 84.0608696,11.3801242 Z M110.078261,11.3801242 C106.999188,11.3801242 104.503106,8.88404218 104.503106,5.80496894 C104.503106,2.72589571 106.999188,0.229813665 110.078261,0.229813665 C113.157334,0.229813665 115.653416,2.72589571 115.653416,5.80496894 C115.653416,8.88404218 113.157334,11.3801242 110.078261,11.3801242 Z M6.00869565,41.1142857 C2.92962241,41.1142857 0.433540373,38.6182037 0.433540373,35.5391304 C0.433540373,32.4600572 2.92962241,29.9639752 6.00869565,29.9639752 C9.08776889,29.9639752 11.5838509,32.4600572 11.5838509,35.5391304 C11.5838509,38.6182037 9.08776889,41.1142857 6.00869565,41.1142857 Z M58.0434783,41.1142857 C54.964405,41.1142857 52.468323,38.6182037 52.468323,35.5391304 C52.468323,32.4600572 54.964405,29.9639752 58.0434783,29.9639752 C61.1225515,29.9639752 63.6186335,32.4600572 63.6186335,35.5391304 C63.6186335,38.6182037 61.1225515,41.1142857 58.0434783,41.1142857 Z M32.026087,41.1142857 C28.9470137,41.1142857 26.4509317,38.6182037 26.4509317,35.5391304 C26.4509317,32.4600572 28.9470137,29.9639752 32.026087,29.9639752 C35.1051602,29.9639752 37.6012422,32.4600572 37.6012422,35.5391304 C37.6012422,38.6182037 35.1051602,41.1142857 32.026087,41.1142857 Z M84.0608696,41.1142857 C80.9817963,41.1142857 78.4857143,38.6182037 78.4857143,35.5391304 C78.4857143,32.4600572 80.9817963,29.9639752 84.0608696,29.9639752 C87.1399428,29.9639752 89.6360248,32.4600572 89.6360248,35.5391304 C89.6360248,38.6182037 87.1399428,41.1142857 84.0608696,41.1142857 Z M110.078261,41.1142857 C106.999188,41.1142857 104.503106,38.6182037 104.503106,35.5391304 C104.503106,32.4600572 106.999188,29.9639752 110.078261,29.9639752 C113.157334,29.9639752 115.653416,32.4600572 115.653416,35.5391304 C115.653416,38.6182037 113.157334,41.1142857 110.078261,41.1142857 Z" id="Combined-Shape" fill="#000000"></path> + </g> +</svg> \ No newline at end of file
diff --git a/chrome/browser/resources/local_ntp/local_ntp.css b/chrome/browser/resources/local_ntp/local_ntp.css index 37ad14e..3336ba1 100644 --- a/chrome/browser/resources/local_ntp/local_ntp.css +++ b/chrome/browser/resources/local_ntp/local_ntp.css
@@ -1165,13 +1165,42 @@ #backgrounds-default-icon { background-color: white; - background-image: url(icons/upload.svg); background-repeat: no-repeat; height: 174px; opacity: 1; width: 174px; } +#backgrounds-default-icon-header { + -webkit-mask-image: url(icons/header.svg); + -webkit-mask-repeat: no-repeat; + -webkit-mask-size: 100%; + background-color: rgb(var(--GG500-rgb)); + height: 50px; + margin-inline-start: 17px; + margin-top: 24px; + position: absolute; + width: 140px; +} + +#backgrounds-default-icon-shortcuts { + -webkit-mask-image: url(icons/shortcut-circles.svg); + -webkit-mask-repeat: no-repeat; + -webkit-mask-size: 100%; + background-color: rgb(var(--GG500-rgb)); + height: 50px; + margin-inline-start: 17px; + margin-top: 86px; + position: absolute; + width: 140px; +} + +.selected #backgrounds-default-icon-header, +.selected #backgrounds-default-icon-shortcuts { + margin-inline-start: 14px; + width: 116px; +} + #shortcuts-menu { line-height: 20px; overflow-y: unset;
diff --git a/chrome/browser/resources/local_ntp/local_ntp.html b/chrome/browser/resources/local_ntp/local_ntp.html index f94487d6..1071e24 100644 --- a/chrome/browser/resources/local_ntp/local_ntp.html +++ b/chrome/browser/resources/local_ntp/local_ntp.html
@@ -205,7 +205,10 @@ <div id="backgrounds-upload-text">$i18n{uploadImage}</div> </div> <div id="backgrounds-default" class="bg-sel-tile-bg"> - <div id="backgrounds-default-icon" class="bg-sel-tile"></div> + <div id="backgrounds-default-icon" class="bg-sel-tile"> + <div id="backgrounds-default-icon-header"></div> + <div id="backgrounds-default-icon-shortcuts"></div> + </div> <div class="bg-sel-tile-title">Default</div> </div> </div>
diff --git a/chrome/browser/resources/management/management_ui.html b/chrome/browser/resources/management/management_ui.html index ad480d5..a46ab223 100644 --- a/chrome/browser/resources/management/management_ui.html +++ b/chrome/browser/resources/management/management_ui.html
@@ -219,7 +219,7 @@ if="[[showDeviceReportingInfo_(deviceReportingInfo_)]]"> <section> <h2>$i18n{deviceReporting}</h2> - <div class="subtitle content-indented"> + <div class="subtitle"> $i18n{deviceConfiguration} </div> <div class="content-indented">
diff --git a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html index 57c1eebb..a1acb22 100644 --- a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html +++ b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html
@@ -1,13 +1,12 @@ <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/cr_elements/paper_tabs_style_css.html"> +<link rel="import" href="chrome://resources/cr_elements/cr_tabs/cr_tabs.html"> <link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> <link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-pages/iron-pages.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-tabs/paper-tabs.html"> <link rel="import" href="../i18n_setup.html"> <link rel="import" href="clear_browsing_data_browser_proxy.html"> <link rel="import" href="history_deletion_dialog.html"> @@ -19,7 +18,7 @@ <dom-module id="settings-clear-browsing-data-dialog"> <template> - <style include="settings-shared paper-tabs-style"> + <style include="settings-shared"> :host { /* Fixed height to allow multiple tabs with different height. * The last entry in the advanced tab should show half an entry. @@ -84,11 +83,9 @@ --settings-checkbox-margin-top: 12px; } - paper-tabs { - --paper-tabs: { - font-size: 100%; - height: 40px; - } + cr-tabs { + --cr-tabs-font-size: 100%; + --cr-tabs-height: 40px; } .time-range-row { @@ -121,11 +118,9 @@ <div>$i18n{clearBrowsingData}</div> </div> <div slot="header"> - <paper-tabs noink on-selected-changed="recordTabChange_" autoselect - selected="{{prefs.browser.last_clear_browsing_data_tab.value}}"> - <paper-tab id="basicTabTitle">$i18n{basicPageTitle}</paper-tab> - <paper-tab id="advancedTabTitle">$i18n{advancedPageTitle}</paper-tab> - </paper-tabs> + <cr-tabs tab-names="[[tabsNames_]]" + selected="{{prefs.browser.last_clear_browsing_data_tab.value}}" + on-selected-changed="recordTabChange_"></cr-tabs> </div> <div slot="body"> <iron-pages id="tabs"
diff --git a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js index 64f57b5..fc53faa 100644 --- a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js +++ b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js
@@ -9,7 +9,10 @@ Polymer({ is: 'settings-clear-browsing-data-dialog', - behaviors: [WebUIListenerBehavior, settings.RouteObserverBehavior], + behaviors: [ + WebUIListenerBehavior, + settings.RouteObserverBehavior, + ], properties: { /** @@ -145,7 +148,16 @@ dialogOpenedTime_: { type: Number, value: 0, - } + }, + + /** @private {Array<string>} */ + tabsNames_: { + type: Array, + value: () => + [loadTimeData.getString('basicPageTitle'), + loadTimeData.getString('advancedPageTitle'), +], + }, }, listeners: {'settings-boolean-control-change': 'updateClearButtonState_'},
diff --git a/chrome/browser/resources/settings/device_page/display.html b/chrome/browser/resources/settings/device_page/display.html index fb78b2d..9d3fbdf0 100644 --- a/chrome/browser/resources/settings/device_page/display.html +++ b/chrome/browser/resources/settings/device_page/display.html
@@ -2,8 +2,8 @@ <link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html"> <link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html"> +<link rel="import" href="chrome://resources/cr_elements/cr_tabs/cr_tabs.html"> <link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html"> -<link rel="import" href="chrome://resources/cr_elements/paper_tabs_style_css.html"> <link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html"> <link rel="import" href="chrome://resources/html/assert.html"> <link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html"> @@ -11,7 +11,6 @@ <link rel="import" href="chrome://resources/html/md_select_css.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-tabs/paper-tabs.html"> <link rel="import" href="display_layout.html"> <link rel="import" href="display_overscan_dialog.html"> <link rel="import" href="night_light_slider.html"> @@ -23,7 +22,7 @@ <dom-module id="settings-display"> <template> - <style include="settings-shared md-select iron-flex iron-flex-alignment paper-tabs-style"> + <style include="settings-shared md-select iron-flex iron-flex-alignment"> .indented { align-self: stretch; margin-inline-start: var(--cr-section-indent-padding); @@ -93,12 +92,9 @@ </div> <div hidden="[[!hasMultipleDisplays_(displays)]]" class="settings-box"> - <paper-tabs noink selected="[[selectedDisplay.id]]" class="display-tabs" - on-iron-select="onSelectDisplayTab_" attr-for-selected="display-id"> - <template is="dom-repeat" items="[[displays]]"> - <paper-tab display-id="[[item.id]]">[[item.name]]</paper-tab> - </template> - </paper-tabs> + <cr-tabs selected="[[selectedTab_]]" class="display-tabs" + on-selected-changed="onSelectDisplayTab_" + tab-names="[[displayTabNames_]]"></cr-tabs> </div> <div hidden="[[hasMultipleDisplays_(displays)]]" class="settings-box line-only"></div>
diff --git a/chrome/browser/resources/settings/device_page/display.js b/chrome/browser/resources/settings/device_page/display.js index 84613d21..e15ae9e 100644 --- a/chrome/browser/resources/settings/device_page/display.js +++ b/chrome/browser/resources/settings/device_page/display.js
@@ -182,6 +182,12 @@ /** @private */ logicalResolutionText_: String, + + /** @private {!Array<string>} */ + displayTabNames_: Array, + + /** @private */ + selectedTab_: Number, }, observers: [ @@ -275,6 +281,7 @@ displayLayoutFetched_: function(displays, layouts) { this.layouts = layouts; this.displays = displays; + this.displayTabNames_ = displays.map(({name}) => name); this.updateDisplayInfo_(); }, @@ -458,6 +465,7 @@ // Set |selectedDisplay| first since only the resolution slider depends // on |selectedModePref_|. this.selectedDisplay = selectedDisplay; + this.selectedTab_ = this.displays.indexOf(this.selectedDisplay); // Now that everything is in sync, set the selected mode to its correct // value right before updating the pref. @@ -739,14 +747,12 @@ } }, - /** - * Handles event when a display tab is selected. - * @param {!CustomEvent<!{item: !{displayId: string}}>} e - * @private - */ - onSelectDisplayTab_: function(e) { - this.onSelectDisplay_( - new CustomEvent('select-display', {detail: e.detail.item.displayId})); + /** @private */ + onSelectDisplayTab_: function() { + const {selected} = this.$$('cr-tabs'); + if (this.selectedTab_ != selected) { + this.setSelectedDisplay_(this.displays[selected]); + } }, /**
diff --git a/chrome/browser/resources/settings/incompatible_applications_page/incompatible_application_item.js b/chrome/browser/resources/settings/incompatible_applications_page/incompatible_application_item.js index 9bed971..2a8916a 100644 --- a/chrome/browser/resources/settings/incompatible_applications_page/incompatible_application_item.js +++ b/chrome/browser/resources/settings/incompatible_applications_page/incompatible_application_item.js
@@ -6,7 +6,7 @@ * @fileoverview * 'incompatible-application-item' represents one item in a "list-box" of * incompatible applications, as defined in - * chrome/browser/conflicts/incompatible_applications_updater_win.h. + * chrome/browser/win/conflicts/incompatible_applications_updater_win.h. * This element contains a button that can be used to remove or update the * incompatible application, depending on the value of the action-type property. * @@ -49,7 +49,7 @@ /** * The type of the action to be taken on this incompatible application. Must * be one of BlacklistMessageType in - * chrome/browser/conflicts/proto/module_list.proto. + * chrome/browser/win/conflicts/proto/module_list.proto. * @type {!settings.ActionTypes} */ actionType: Number,
diff --git a/chrome/browser/resources/settings/incompatible_applications_page/incompatible_applications_browser_proxy.js b/chrome/browser/resources/settings/incompatible_applications_page/incompatible_applications_browser_proxy.js index 4eb017b..5dcc1b1 100644 --- a/chrome/browser/resources/settings/incompatible_applications_page/incompatible_applications_browser_proxy.js +++ b/chrome/browser/resources/settings/incompatible_applications_page/incompatible_applications_browser_proxy.js
@@ -13,7 +13,7 @@ * All possible actions to take on an incompatible application. * * Must be kept in sync with BlacklistMessageType in - * chrome/browser/conflicts/proto/module_list.proto + * chrome/browser/win/conflicts/proto/module_list.proto * @readonly * @enum {number} */
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc index b4fd0ec..206e9c4 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
@@ -211,18 +211,6 @@ url_request_context_getter_ = nullptr; } -bool SafeBrowsingService::DownloadBinHashNeeded() const { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - -#if defined(FULL_SAFE_BROWSING) - return database_manager()->IsDownloadProtectionEnabled() || - (download_protection_service() && - download_protection_service()->enabled()); -#else - return false; -#endif -} - scoped_refptr<net::URLRequestContextGetter> SafeBrowsingService::url_request_context() { DCHECK_CURRENTLY_ON(BrowserThread::UI);
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.h b/chrome/browser/safe_browsing/safe_browsing_service.h index 9f0fc34..73032a5 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.h +++ b/chrome/browser/safe_browsing/safe_browsing_service.h
@@ -96,10 +96,6 @@ // Called on the main thread to let us know that the io_thread is going away. void ShutDown(); - // Called on UI thread to decide if the download file's sha256 hash - // should be calculated for safebrowsing. - bool DownloadBinHashNeeded() const; - // NOTE(vakh): This is not the most reliable way to find out if extended // reporting has been enabled. That's why it starts with estimated_. It // returns true if any of the profiles have extended reporting enabled. It may
diff --git a/chrome/browser/send_tab_to_self/desktop_notification_handler.cc b/chrome/browser/send_tab_to_self/desktop_notification_handler.cc index 037c959..fd42ddc 100644 --- a/chrome/browser/send_tab_to_self/desktop_notification_handler.cc +++ b/chrome/browser/send_tab_to_self/desktop_notification_handler.cc
@@ -112,13 +112,15 @@ } void DesktopNotificationHandler::DisplaySendingConfirmation( - const SendTabToSelfEntry& entry) { + const SendTabToSelfEntry& entry, + const std::string& target_device_name) { + const base::string16 confirm_str = l10n_util::GetStringFUTF16( + IDS_MESSAGE_NOTIFICATION_SEND_TAB_TO_SELF_CONFIRMATION_SUCCESS, + base::UTF8ToUTF16(target_device_name)); const GURL& url = entry.GetURL(); message_center::Notification notification( message_center::NOTIFICATION_TYPE_SIMPLE, - kDesktopNotificationSharedPrefix + entry.GetGUID(), - l10n_util::GetStringUTF16( - IDS_MESSAGE_NOTIFICATION_SEND_TAB_TO_SELF_CONFIRMATION_SUCCESS), + kDesktopNotificationSharedPrefix + entry.GetGUID(), confirm_str, base::UTF8ToUTF16(entry.GetTitle()), GetImageForNotification(), base::UTF8ToUTF16(url.host()), url, message_center::NotifierId(url), message_center::RichNotificationData(), /*delegate=*/nullptr);
diff --git a/chrome/browser/send_tab_to_self/desktop_notification_handler.h b/chrome/browser/send_tab_to_self/desktop_notification_handler.h index 3c7944a5..e258daf 100644 --- a/chrome/browser/send_tab_to_self/desktop_notification_handler.h +++ b/chrome/browser/send_tab_to_self/desktop_notification_handler.h
@@ -47,7 +47,8 @@ // When the user share a tab, a confirmation notification will be shown. // Displays a notification telling the user that the tab was successfully // sent. - void DisplaySendingConfirmation(const SendTabToSelfEntry& entry); + void DisplaySendingConfirmation(const SendTabToSelfEntry& entry, + const std::string& target_device_name); // Displays a notification telling the user that the tab could not be sent. void DisplayFailureMessage(const GURL& url);
diff --git a/chrome/browser/send_tab_to_self/send_tab_to_self_desktop_util.cc b/chrome/browser/send_tab_to_self/send_tab_to_self_desktop_util.cc index b2e7cde..e4943d6 100644 --- a/chrome/browser/send_tab_to_self/send_tab_to_self_desktop_util.cc +++ b/chrome/browser/send_tab_to_self/send_tab_to_self_desktop_util.cc
@@ -36,7 +36,8 @@ base::Time navigation_time = navigation_entry->GetTimestamp(); // TODO(crbug/946804) Add target device. - std::string target_device; + std::string target_device_guid; + std::string target_device_name; SendTabToSelfModel* model = SendTabToSelfSyncServiceFactory::GetForProfile(profile) ->GetSendTabToSelfModel(); @@ -51,13 +52,14 @@ const SendTabToSelfEntry* entry; if (link_url.is_valid()) { // When share a link. - entry = model->AddEntry(link_url, "", base::Time(), target_device); + entry = model->AddEntry(link_url, "", base::Time(), target_device_guid); } else { // When share a tab. - entry = model->AddEntry(url, title, navigation_time, target_device); + entry = model->AddEntry(url, title, navigation_time, target_device_guid); } if (entry) { - DesktopNotificationHandler(profile).DisplaySendingConfirmation(*entry); + DesktopNotificationHandler(profile).DisplaySendingConfirmation( + *entry, target_device_name); } else { DesktopNotificationHandler(profile).DisplayFailureMessage(url); }
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index d7e63d5..e2ce1741 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -2291,7 +2291,7 @@ "//ui/views/controls/webview", ] deps += [ - "//chrome/browser/conflicts:module_info", + "//chrome/browser/win/conflicts:module_info", "//chrome/credential_provider/common:common_constants", "//components/search_engines", "//third_party/iaccessible2",
diff --git a/chrome/browser/ui/app_list/app_list_client_impl.cc b/chrome/browser/ui/app_list/app_list_client_impl.cc index 9fb1e8f..400e24c 100644 --- a/chrome/browser/ui/app_list/app_list_client_impl.cc +++ b/chrome/browser/ui/app_list/app_list_client_impl.cc
@@ -10,7 +10,6 @@ #include <vector> #include "ash/public/cpp/app_list/app_list_controller.h" -#include "ash/public/cpp/menu_utils.h" #include "ash/public/interfaces/constants.mojom.h" #include "base/bind.h" #include "base/metrics/histogram_functions.h" @@ -149,19 +148,18 @@ const std::string& result_id, GetContextMenuModelCallback callback) { if (!search_controller_) { - std::move(callback).Run(std::vector<ash::mojom::MenuItemPtr>()); + std::move(callback).Run(nullptr); return; } ChromeSearchResult* result = search_controller_->FindSearchResult(result_id); if (!result) { - std::move(callback).Run(std::vector<ash::mojom::MenuItemPtr>()); + std::move(callback).Run(nullptr); return; } result->GetContextMenuModel(base::BindOnce( [](GetContextMenuModelCallback callback, std::unique_ptr<ui::SimpleMenuModel> menu_model) { - std::move(callback).Run( - ash::menu_utils::GetMojoMenuItemsFromModel(menu_model.get())); + std::move(callback).Run(std::move(menu_model)); }, std::move(callback))); } @@ -226,18 +224,16 @@ auto* requested_model_updater = profile_model_mappings_[profile_id]; if (requested_model_updater != current_model_updater_ || !requested_model_updater) { - std::move(callback).Run(std::vector<ash::mojom::MenuItemPtr>()); + std::move(callback).Run(nullptr); return; } requested_model_updater->GetContextMenuModel( - id, - base::BindOnce( - [](GetContextMenuModelCallback callback, - std::unique_ptr<ui::SimpleMenuModel> menu_model) { - std::move(callback).Run( - ash::menu_utils::GetMojoMenuItemsFromModel(menu_model.get())); - }, - std::move(callback))); + id, base::BindOnce( + [](GetContextMenuModelCallback callback, + std::unique_ptr<ui::SimpleMenuModel> menu_model) { + std::move(callback).Run(std::move(menu_model)); + }, + std::move(callback))); } void AppListClientImpl::ContextMenuItemSelected(int profile_id,
diff --git a/chrome/browser/ui/app_list/app_list_client_impl_browsertest.cc b/chrome/browser/ui/app_list/app_list_client_impl_browsertest.cc index 6da486b8..1c10efd 100644 --- a/chrome/browser/ui/app_list/app_list_client_impl_browsertest.cc +++ b/chrome/browser/ui/app_list/app_list_client_impl_browsertest.cc
@@ -53,7 +53,7 @@ #include "extensions/browser/extension_prefs.h" #include "extensions/common/constants.h" #include "ui/aura/window.h" -#include "ui/base/models/menu_model.h" +#include "ui/base/models/simple_menu_model.h" // Browser Test for AppListClientImpl. using AppListClientImplBrowserTest = extensions::PlatformAppBrowserTest;
diff --git a/chrome/browser/ui/app_list/search/chrome_search_result.h b/chrome/browser/ui/app_list/search/chrome_search_result.h index eab733f..0be59cb 100644 --- a/chrome/browser/ui/app_list/search/chrome_search_result.h +++ b/chrome/browser/ui/app_list/search/chrome_search_result.h
@@ -14,7 +14,7 @@ #include "ash/public/interfaces/app_list.mojom.h" #include "base/macros.h" #include "chrome/browser/ui/app_list/app_list_model_updater.h" -#include "ui/base/models/menu_model.h" +#include "ui/base/models/simple_menu_model.h" namespace app_list { class AppContextMenu;
diff --git a/chrome/browser/ui/ash/multi_user/multi_profile_support_unittest.cc b/chrome/browser/ui/ash/multi_user/multi_profile_support_unittest.cc index 2d68ed3..4123c2a 100644 --- a/chrome/browser/ui/ash/multi_user/multi_profile_support_unittest.cc +++ b/chrome/browser/ui/ash/multi_user/multi_profile_support_unittest.cc
@@ -59,7 +59,6 @@ #include "components/user_manager/scoped_user_manager.h" #include "components/user_manager/user_info.h" #include "components/user_manager/user_manager.h" -#include "services/ws/common/util.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/test/env_test_helper.h" #include "ui/aura/window.h"
diff --git a/chrome/browser/ui/omnibox/chrome_omnibox_client.cc b/chrome/browser/ui/omnibox/chrome_omnibox_client.cc index 86ac71e1..1d84a0df 100644 --- a/chrome/browser/ui/omnibox/chrome_omnibox_client.cc +++ b/chrome/browser/ui/omnibox/chrome_omnibox_client.cc
@@ -398,13 +398,6 @@ gfx::Image ChromeOmniboxClient::GetFaviconForDefaultSearchProvider( FaviconFetchedCallback on_favicon_fetched) { - if (base::FeatureList::IsEnabled( - omnibox::kUIExperimentUseGenericSearchEngineIcon)) { - // Returning an empty image and never calling |on_favicon_fetched| will - // keep the generic icon showing for the default search provider. - return gfx::Image(); - } - const TemplateURL* const default_provider = GetTemplateURLService()->GetDefaultSearchProvider(); if (!default_provider)
diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc index 7734bed..efe2e09 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc
@@ -79,7 +79,7 @@ #if defined(OS_WIN) #if defined(GOOGLE_CHROME_BUILD) -#include "chrome/browser/conflicts/incompatible_applications_updater_win.h" +#include "chrome/browser/win/conflicts/incompatible_applications_updater.h" #endif // defined(GOOGLE_CHROME_BUILD) #include "chrome/browser/notifications/notification_platform_bridge_win.h" #include "chrome/browser/shell_integration_win.h"
diff --git a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc index 56c586c..ddb33ec 100644 --- a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc +++ b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" #include "base/memory/ref_counted.h" +#include "chrome/browser/complex_tasks/task_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/buildflags.h" #include "components/sessions/content/content_serialized_navigation_builder.h" @@ -149,6 +150,16 @@ return false; } +int64_t TabContentsSyncedTabDelegate::GetTaskIdForNavigationId( + int nav_id) const { + const tasks::TaskTabHelper* task_tab_helper = this->task_tab_helper(); + if (task_tab_helper && + task_tab_helper->get_context_record_task_id(nav_id) != nullptr) { + return task_tab_helper->get_context_record_task_id(nav_id)->task_id(); + } + return -1; +} + const content::WebContents* TabContentsSyncedTabDelegate::web_contents() const { return web_contents_; } @@ -161,3 +172,10 @@ content::WebContents* web_contents) { web_contents_ = web_contents; } + +const tasks::TaskTabHelper* TabContentsSyncedTabDelegate::task_tab_helper() + const { + if (web_contents_ == nullptr) + return nullptr; + return tasks::TaskTabHelper::FromWebContents(web_contents_); +}
diff --git a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h index a04482c..c500cde 100644 --- a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h +++ b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h
@@ -17,6 +17,10 @@ class WebContents; } +namespace tasks { +class TaskTabHelper; +} + // Partial implementation of SyncedTabDelegate for the cases where the tab has // (either initially or late) a WebContents. class TabContentsSyncedTabDelegate : public sync_sessions::SyncedTabDelegate { @@ -40,6 +44,7 @@ const std::vector<std::unique_ptr<const sessions::SerializedNavigationEntry>>* GetBlockedNavigations() const override; bool ShouldSync(sync_sessions::SyncSessionsClient* sessions_client) override; + int64_t GetTaskIdForNavigationId(int nav_id) const override; protected: const content::WebContents* web_contents() const; @@ -47,6 +52,8 @@ void SetWebContents(content::WebContents* web_contents); private: + const tasks::TaskTabHelper* task_tab_helper() const; + content::WebContents* web_contents_; DISALLOW_COPY_AND_ASSIGN(TabContentsSyncedTabDelegate);
diff --git a/chrome/browser/ui/tabs/tab_strip_model.cc b/chrome/browser/ui/tabs/tab_strip_model.cc index d7cf0f3..bda509d 100644 --- a/chrome/browser/ui/tabs/tab_strip_model.cc +++ b/chrome/browser/ui/tabs/tab_strip_model.cc
@@ -21,6 +21,7 @@ #include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/lifetime/browser_shutdown.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/resource_coordinator/tab_helper.h" #include "chrome/browser/send_tab_to_self/send_tab_to_self_desktop_util.h" #include "chrome/browser/send_tab_to_self/send_tab_to_self_util.h" #include "chrome/browser/ui/browser.h" @@ -1624,8 +1625,12 @@ tab_switch_event_latency_recorder_.input_event_timestamp(); // input_event_timestamp may be null in some cases, e.g. in tests. selection.new_contents->GetRenderWidgetHostView() - ->SetLastTabChangeStartTime( - !input_event_timestamp.is_null() ? input_event_timestamp : now); + ->SetRecordTabSwitchTimeRequest( + !input_event_timestamp.is_null() ? input_event_timestamp : now, + resource_coordinator::ResourceCoordinatorTabHelper::IsLoaded( + selection.new_contents), + resource_coordinator::ResourceCoordinatorTabHelper::IsFrozen( + selection.new_contents)); } tab_switch_event_latency_recorder_.OnWillChangeActiveTab(now); }
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index 1a55ff4d..9e8443f 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -813,16 +813,8 @@ if (omnibox_view_->model()->is_caret_visible()) { background_color = border_color = GetColor(OmniboxPart::RESULTS_BACKGROUND); } else { - // If the white omnibox background experiment is enabled, use the color of - // the results box rather than the normal location bar background color. - OmniboxPart normal_color_part = - base::FeatureList::IsEnabled( - omnibox::kUIExperimentWhiteBackgroundOnBlur) - ? OmniboxPart::RESULTS_BACKGROUND - : OmniboxPart::LOCATION_BAR_BACKGROUND; - const SkColor normal = - GetOmniboxColor(normal_color_part, tint(), OmniboxPartState::NORMAL); - + const SkColor normal = GetOmniboxColor(OmniboxPart::LOCATION_BAR_BACKGROUND, + tint(), OmniboxPartState::NORMAL); const SkColor hovered = GetOmniboxColor(OmniboxPart::LOCATION_BAR_BACKGROUND, tint(), OmniboxPartState::HOVERED); @@ -839,11 +831,6 @@ if (GetNativeTheme()->UsesHighContrastColors()) { // High contrast schemes get a border stroke even on a rounded omnibox. stroke_color = border_color; - } else if (base::FeatureList::IsEnabled( - omnibox::kUIExperimentWhiteBackgroundOnBlur)) { - const double opacity = hover_animation_.GetCurrentValue(); - stroke_color = gfx::Tween::ColorValueBetween(opacity, border_color, - SK_ColorTRANSPARENT); } SetBackground(CreateRoundRectBackground(background_color, stroke_color)); @@ -1323,7 +1310,6 @@ return omnibox_view() ? omnibox_view()->GetIcon( GetLayoutConstant(LOCATION_BAR_ICON_SIZE), GetSecurityChipColor(level), - GetColor(OmniboxPart::RESULTS_TEXT_URL), std::move(on_icon_fetched)) : gfx::ImageSkia(); }
diff --git a/chrome/browser/ui/views/media_router/cast_dialog_sink_button.cc b/chrome/browser/ui/views/media_router/cast_dialog_sink_button.cc index d5065072..fc2eef3 100644 --- a/chrome/browser/ui/views/media_router/cast_dialog_sink_button.cc +++ b/chrome/browser/ui/views/media_router/cast_dialog_sink_button.cc
@@ -4,6 +4,9 @@ #include "chrome/browser/ui/views/media_router/cast_dialog_sink_button.h" +#include <memory> + +#include "base/debug/stack_trace.h" #include "base/strings/utf_string_conversions.h" #include "chrome/app/vector_icons/vector_icons.h" #include "chrome/browser/ui/views/chrome_layout_provider.h" @@ -12,6 +15,7 @@ #include "chrome/common/media_router/issue.h" #include "chrome/grit/generated_resources.h" #include "components/vector_icons/vector_icons.h" +#include "content/public/browser/browser_thread.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/ui_base_types.h" #include "ui/gfx/color_palette.h" @@ -198,6 +202,15 @@ } void CastDialogSinkButton::RequestFocus() { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + static bool requesting_focus = false; + if (requesting_focus) { + // TODO(jrw): Figure out why this happens. + DLOG(ERROR) << "Recursive call to RequestFocus\n" + << base::debug::StackTrace(); + return; + } + requesting_focus = true; if (GetEnabled()) { HoverButton::RequestFocus(); } else { @@ -205,6 +218,7 @@ // want focus. icon_view()->RequestFocus(); } + requesting_focus = false; } void CastDialogSinkButton::OnFocus() {
diff --git a/chrome/browser/ui/views/omnibox/omnibox_result_view.cc b/chrome/browser/ui/views/omnibox/omnibox_result_view.cc index d64998fe..82435884 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_result_view.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_result_view.cc
@@ -78,24 +78,6 @@ OmniboxResultView::~OmniboxResultView() {} SkColor OmniboxResultView::GetColor(OmniboxPart part) const { - if (!AutocompleteMatch::IsSearchType(match_.type)) { - // These recoloring experiments affect all non-search matches. - bool color_titles_blue = - base::FeatureList::IsEnabled( - omnibox::kUIExperimentBlueTitlesAndGrayUrlsOnPageSuggestions) || - base::FeatureList::IsEnabled( - omnibox::kUIExperimentBlueTitlesOnPageSuggestions); - bool color_urls_gray = base::FeatureList::IsEnabled( - omnibox::kUIExperimentBlueTitlesAndGrayUrlsOnPageSuggestions); - - // If these recoloring experiments are enabled, change |part| to fetch an - // alternate color for this text. - if (color_titles_blue && part == OmniboxPart::RESULTS_TEXT_DEFAULT) - part = OmniboxPart::RESULTS_TEXT_URL; - else if (color_urls_gray && part == OmniboxPart::RESULTS_TEXT_URL) - part = OmniboxPart::RESULTS_TEXT_DIMMED; - } - return GetOmniboxColor(part, GetTint(), GetThemeState()); } @@ -168,8 +150,6 @@ // Answers use their own styling for additional content text and the // description text, whereas non-answer suggestions use the match text and // calculated classifications for the description text. - bool blue_search_query = base::FeatureList::IsEnabled( - omnibox::kUIExperimentBlueSearchLoopAndSearchQuery); if (match_.answer) { const bool reverse = OmniboxFieldTrial::IsReverseAnswersEnabled() && !match_.answer->IsExceptedFromLineReversal(); @@ -178,16 +158,14 @@ suggestion_view_->description()->SetText(match_.contents, match_.contents_class, true); suggestion_view_->description()->ApplyTextColor( - blue_search_query ? OmniboxPart::RESULTS_TEXT_URL - : OmniboxPart::RESULTS_TEXT_DIMMED); + OmniboxPart::RESULTS_TEXT_DIMMED); suggestion_view_->description()->AppendExtraText( match_.answer->first_line()); } else { suggestion_view_->content()->SetText(match_.contents, match_.contents_class); suggestion_view_->content()->ApplyTextColor( - blue_search_query ? OmniboxPart::RESULTS_TEXT_URL - : OmniboxPart::RESULTS_TEXT_DEFAULT); + OmniboxPart::RESULTS_TEXT_DEFAULT); suggestion_view_->content()->AppendExtraText(match_.answer->first_line()); suggestion_view_->description()->SetText(match_.answer->second_line(), true); @@ -198,10 +176,6 @@ // adjustments like answers above. Pedals do likewise. suggestion_view_->content()->SetText(match_.contents, match_.contents_class); - if (blue_search_query) { - suggestion_view_->content()->ApplyTextColor( - OmniboxPart::RESULTS_TEXT_URL); - } suggestion_view_->description()->SetText(match_.description, match_.description_class, -1); suggestion_view_->description()->ApplyTextColor( @@ -220,13 +194,6 @@ suggestion_view_->content()->ReapplyStyling(); suggestion_view_->description()->ReapplyStyling(); } - - // If the blue search query experiment is on, search suggestions are - // recolored at the end. - if (blue_search_query && AutocompleteMatch::IsSearchType(match_.type)) { - suggestion_view_->content()->ApplyTextColor( - OmniboxPart::RESULTS_TEXT_URL); - } } AutocompleteMatch* keyword_match = match_.associated_keyword.get(); @@ -502,17 +469,8 @@ // OmniboxResultView, private: gfx::Image OmniboxResultView::GetIcon() const { - SkColor color = GetColor(OmniboxPart::RESULTS_ICON); - - // If the blue search loop experiment is enabled, set the color of search - // match icons to be the same as result URLs (conventionally blue). - if (base::FeatureList::IsEnabled( - omnibox::kUIExperimentBlueSearchLoopAndSearchQuery) && - AutocompleteMatch::IsSearchType(match_.type)) { - color = GetColor(OmniboxPart::RESULTS_TEXT_URL); - } - - return popup_contents_view_->GetMatchIcon(match_, color); + return popup_contents_view_->GetMatchIcon( + match_, GetColor(OmniboxPart::RESULTS_ICON)); } void OmniboxResultView::SetHovered(bool hovered) {
diff --git a/chrome/browser/ui/views/omnibox/omnibox_text_view.cc b/chrome/browser/ui/views/omnibox/omnibox_text_view.cc index c847c913..5ba34ce 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_text_view.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_text_view.cc
@@ -100,10 +100,6 @@ case SuggestionAnswer::TextStyle::BOLD: style = {part_color, .baseline = gfx::NORMAL_BASELINE, .weight = gfx::Font::Weight::BOLD}; - if (base::FeatureList::IsEnabled( - omnibox::kUIExperimentUnboldSuggestionText)) { - style.weight = gfx::Font::Weight::NORMAL; - } break; case SuggestionAnswer::TextStyle::NORMAL: case SuggestionAnswer::TextStyle::NORMAL_DIM: @@ -263,12 +259,9 @@ : text_length; const gfx::Range current_range(text_start, text_end); - if (!base::FeatureList::IsEnabled( - omnibox::kUIExperimentUnboldSuggestionText)) { - // Calculate style-related data. - if (classifications[i].style & ACMatchClassification::MATCH) - render_text_->ApplyWeight(gfx::Font::Weight::BOLD, current_range); - } + // Calculate style-related data. + if (classifications[i].style & ACMatchClassification::MATCH) + render_text_->ApplyWeight(gfx::Font::Weight::BOLD, current_range); OmniboxPart part = OmniboxPart::RESULTS_TEXT_DEFAULT; if (classifications[i].style & ACMatchClassification::URL) {
diff --git a/chrome/browser/ui/views/overlay/overlay_window_views.cc b/chrome/browser/ui/views/overlay/overlay_window_views.cc index 40754ab..f5c77139 100644 --- a/chrome/browser/ui/views/overlay/overlay_window_views.cc +++ b/chrome/browser/ui/views/overlay/overlay_window_views.cc
@@ -79,6 +79,10 @@ // Margin between controls. const int kControlMargin = 32; +// Delay in milliseconds before controls bounds are updated. It is the same as +// HIDE_NOTIFICATION_DELAY_MILLIS in MediaSessionTabHelper.java +const int kUpdateControlsBoundsDelayMs = 1000; + // Returns the quadrant the OverlayWindowViews is primarily in on the current // work area. OverlayWindowViews::WindowQuadrant GetCurrentWindowQuadrant( @@ -511,6 +515,15 @@ } void OverlayWindowViews::UpdateControlsBounds() { + update_controls_bounds_timer_.reset(new base::OneShotTimer()); + update_controls_bounds_timer_->Start( + FROM_HERE, + base::TimeDelta::FromMilliseconds(kUpdateControlsBoundsDelayMs), + base::BindOnce(&OverlayWindowViews::OnUpdateControlsBounds, + base::Unretained(this))); +} + +void OverlayWindowViews::OnUpdateControlsBounds() { // Adding an extra pixel to width/height makes sure the scrim covers the // entire window when the platform has fractional scaling applied. gfx::Rect larger_window_bounds = @@ -689,6 +702,9 @@ } #endif + // Update immediately controls bounds. + OnUpdateControlsBounds(); + // If this is not the first time the window is shown, this will be a no-op. has_been_shown_ = true; }
diff --git a/chrome/browser/ui/views/overlay/overlay_window_views.h b/chrome/browser/ui/views/overlay/overlay_window_views.h index be17397..4c3ce6d4 100644 --- a/chrome/browser/ui/views/overlay/overlay_window_views.h +++ b/chrome/browser/ui/views/overlay/overlay_window_views.h
@@ -121,6 +121,9 @@ // Updates the bounds of the controls. void UpdateControlsBounds(); + // Called when the bounds of the controls should be updated. + void OnUpdateControlsBounds(); + // Update the size of each controls view as the size of the window changes. void UpdateButtonControlsSize(); @@ -218,6 +221,9 @@ // Automatically hides the controls a few seconds after user tap gesture. base::RetainingOneShotTimer hide_controls_timer_; + // Timer used to update controls bounds. + std::unique_ptr<base::OneShotTimer> update_controls_bounds_timer_; + // Current playback state on the video in Picture-in-Picture window. It is // used to toggle play/pause/replay button. PlaybackState playback_state_for_testing_ = kEndOfVideo;
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc index 808c705..fde2737 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
@@ -650,7 +650,7 @@ if (!CanDetachFromTabStrip(GetContextForWindow(widget->GetNativeWindow()))) return; #if defined(USE_AURA) - aura::Env* env = widget->GetNativeWindow()->env(); + aura::Env* env = aura::Env::GetInstance(); // WidgetBoundsChanged happens as a step of ending a drag, but Drag() doesn't // have to be called -- GetCursorScreenPoint() may return an incorrect // location in such case and causes a weird effect. See
diff --git a/chrome/browser/ui/views/tabs/tab_hover_card_bubble_view.cc b/chrome/browser/ui/views/tabs/tab_hover_card_bubble_view.cc index e0427f1b..26b9301 100644 --- a/chrome/browser/ui/views/tabs/tab_hover_card_bubble_view.cc +++ b/chrome/browser/ui/views/tabs/tab_hover_card_bubble_view.cc
@@ -379,10 +379,10 @@ } void TabHoverCardBubbleView::FadeOutToHide() { + delayed_show_timer_.Stop(); if (!widget_->IsVisible()) return; slide_animation_delegate_->StopAnimation(); - delayed_show_timer_.Stop(); last_visible_timestamp_ = base::TimeTicks::Now(); if (disable_animations_for_testing_) { widget_->Hide();
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc index 70bda794..644c4d04 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -143,7 +143,7 @@ protected: // ui::EventTarget: void OnKeyEvent(ui::KeyEvent* event) override { - if (!TabStripIsKeyboardFocused()) + if (!tab_strip_->pane_has_focus()) hover_card_->FadeOutToHide(); } @@ -153,10 +153,6 @@ } private: - bool TabStripIsKeyboardFocused() { - return tab_strip_->GetPaneFocusTraversable() != nullptr; - } - TabHoverCardBubbleView* const hover_card_; TabStrip* tab_strip_; views::Widget* widget_;
diff --git a/chrome/browser/ui/views/webauthn/authenticator_request_dialog_view.cc b/chrome/browser/ui/views/webauthn/authenticator_request_dialog_view.cc index 2247c9c..0677674 100644 --- a/chrome/browser/ui/views/webauthn/authenticator_request_dialog_view.cc +++ b/chrome/browser/ui/views/webauthn/authenticator_request_dialog_view.cc
@@ -26,10 +26,6 @@ #include "ui/views/vector_icons.h" #include "ui/views/window/dialog_client_view.h" -#if defined(USE_AURA) -#include "ui/wm/core/window_animations.h" -#endif - // static void ShowAuthenticatorRequestDialog( content::WebContents* web_contents, @@ -260,21 +256,6 @@ if (!first_shown_) { constrained_window::ShowWebModalDialogViews(this, web_contents()); DCHECK(GetWidget()); - -#if defined(USE_AURA) - // TODO(agl): remove this to revert back to the default "rotate" animations. - // - // It appears that the rotate animation fails to handle layer visibility - // correctly and thus triggers DCHECKs and other issues. Using "fade" works - // around this until "rotate" can be fixed. - // https://chromium-review.googlesource.com/c/chromium/src/+/1610462 - // - // When removing this, also remove the #include of window_animations.h. - wm::SetWindowVisibilityAnimationType( - GetWidget()->GetNativeWindow(), - wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); -#endif - first_shown_ = true; } else { GetWidget()->Show();
diff --git a/chrome/browser/ui/webui/conflicts/OWNERS b/chrome/browser/ui/webui/conflicts/OWNERS index 4495bb1..736d632 100644 --- a/chrome/browser/ui/webui/conflicts/OWNERS +++ b/chrome/browser/ui/webui/conflicts/OWNERS
@@ -1 +1 @@ -file://chrome/browser/conflicts/OWNERS +file://chrome/browser/win/conflicts/OWNERS
diff --git a/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc b/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc index a795fe90..0b218719 100644 --- a/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc +++ b/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc
@@ -9,15 +9,15 @@ #include "base/task/post_task.h" #include "base/win/windows_version.h" -#include "chrome/browser/conflicts/module_database_win.h" +#include "chrome/browser/win/conflicts/module_database.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #if defined(GOOGLE_CHROME_BUILD) #include "base/enterprise_util.h" #include "base/win/win_util.h" -#include "chrome/browser/conflicts/incompatible_applications_updater_win.h" -#include "chrome/browser/conflicts/module_blacklist_cache_updater_win.h" +#include "chrome/browser/win/conflicts/incompatible_applications_updater.h" +#include "chrome/browser/win/conflicts/module_blacklist_cache_updater.h" #endif namespace {
diff --git a/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h b/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h index e1d0533..3064922 100644 --- a/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h +++ b/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h
@@ -12,10 +12,10 @@ #include "base/sequence_checker.h" #include "base/sequenced_task_runner.h" #include "build/build_config.h" -#include "chrome/browser/conflicts/module_database_observer_win.h" +#include "chrome/browser/win/conflicts/module_database_observer.h" #if defined(GOOGLE_CHROME_BUILD) -#include "chrome/browser/conflicts/third_party_conflicts_manager_win.h" +#include "chrome/browser/win/conflicts/third_party_conflicts_manager.h" #endif namespace base {
diff --git a/chrome/browser/ui/webui/management_ui_handler.cc b/chrome/browser/ui/webui/management_ui_handler.cc index 900c76a..3e284c8 100644 --- a/chrome/browser/ui/webui/management_ui_handler.cc +++ b/chrome/browser/ui/webui/management_ui_handler.cc
@@ -342,9 +342,10 @@ auto handler = std::make_unique<ManagementUIHandler>(); #if defined(OS_CHROMEOS) - handler->managed_ = IsProfileManaged(profile) || IsDeviceManaged(); + handler->account_managed_ = IsProfileManaged(profile); + handler->device_managed_ = IsDeviceManaged(); #else - handler->managed_ = IsProfileManaged(profile) || IsBrowserManaged(); + handler->account_managed_ = IsProfileManaged(profile) || IsBrowserManaged(); #endif // defined(OS_CHROMEOS) web_ui->AddMessageHandler(std::move(handler)); @@ -484,17 +485,18 @@ base::DictionaryValue ManagementUIHandler::GetContextualManagedData( Profile* profile) const { base::DictionaryValue response; - #if defined(OS_CHROMEOS) - policy::BrowserPolicyConnectorChromeOS* connector = - g_browser_process->platform_part()->browser_policy_connector_chromeos(); - std::string management_domain = connector->GetEnterpriseDisplayDomain(); - if (management_domain.empty()) - management_domain = connector->GetRealm(); + std::string management_domain = GetDeviceDomain(); if (management_domain.empty()) management_domain = GetAccountDomain(profile); #else std::string management_domain = GetAccountDomain(profile); + + response.SetString("browserManagementNotice", + l10n_util::GetStringFUTF16( + managed_() ? IDS_MANAGEMENT_BROWSER_NOTICE + : IDS_MANAGEMENT_NOT_MANAGED_NOTICE, + base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl))); #endif if (management_domain.empty()) { @@ -503,24 +505,20 @@ l10n_util::GetStringUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED)); #if !defined(OS_CHROMEOS) - response.SetString("browserManagementNotice", - l10n_util::GetStringFUTF16( - managed_ ? IDS_MANAGEMENT_BROWSER_NOTICE - : IDS_MANAGEMENT_NOT_MANAGED_NOTICE, - base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl))); response.SetString("pageSubtitle", l10n_util::GetStringUTF16( - managed_ ? IDS_MANAGEMENT_SUBTITLE - : IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE)); + managed_() ? IDS_MANAGEMENT_SUBTITLE + : IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE)); #else const auto device_type = ui::GetChromeOSDeviceTypeResourceId(); - response.SetString("pageSubtitle", - managed_ ? l10n_util::GetStringFUTF16( - IDS_MANAGEMENT_SUBTITLE_MANAGED, - l10n_util::GetStringUTF16(device_type)) - : l10n_util::GetStringFUTF16( - IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE, - l10n_util::GetStringUTF16(device_type))); + response.SetString( + "pageSubtitle", + managed_() + ? l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED, + l10n_util::GetStringUTF16(device_type)) + : l10n_util::GetStringFUTF16( + IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE, + l10n_util::GetStringUTF16(device_type))); #endif // !defined(OS_CHROMEOS) } else { @@ -531,33 +529,25 @@ #if !defined(OS_CHROMEOS) response.SetString( - "browserManagementNotice", - managed_ ? l10n_util::GetStringFUTF16( - IDS_MANAGEMENT_MANAGEMENT_BY_NOTICE, - base::UTF8ToUTF16(management_domain), - base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl)) - : l10n_util::GetStringFUTF16( - IDS_MANAGEMENT_NOT_MANAGED_NOTICE, - base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl))); - response.SetString( "pageSubtitle", - managed_ + managed_() ? l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED_BY, base::UTF8ToUTF16(management_domain)) : l10n_util::GetStringUTF16(IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE)); #else const auto device_type = ui::GetChromeOSDeviceTypeResourceId(); - response.SetString("pageSubtitle", - managed_ ? l10n_util::GetStringFUTF16( - IDS_MANAGEMENT_SUBTITLE_MANAGED_BY, - l10n_util::GetStringUTF16(device_type), - base::UTF8ToUTF16(management_domain)) - : l10n_util::GetStringFUTF16( - IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE, - l10n_util::GetStringUTF16(device_type))); + response.SetString( + "pageSubtitle", + managed_() + ? l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED_BY, + l10n_util::GetStringUTF16(device_type), + base::UTF8ToUTF16(management_domain)) + : l10n_util::GetStringFUTF16( + IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE, + l10n_util::GetStringUTF16(device_type))); #endif // !defined(OS_CHROMEOS) } - response.SetBoolean("managed", managed_); + response.SetBoolean("managed", managed_()); GetManagementStatus(profile, &response); return response; } @@ -576,36 +566,6 @@ } #endif // BUILDFLAG(ENABLE_EXTENSIONS) -#if defined(OS_CHROMEOS) -void AddStatusDeviceManagedInfo(base::Value* status, - const std::string& device_domain) { - base::Value info(base::Value::Type::DICTIONARY); - info.SetKey(kOverview, base::Value(l10n_util::GetStringFUTF16( - IDS_MANAGEMENT_DEVICE_MANAGED_CLARIFICATION, - base::UTF8ToUTF16(device_domain)))); - info.SetKey(kSetup, base::Value(l10n_util::GetStringUTF16( - IDS_MANAGEMENT_DEVICE_MANAGED_SETUP))); - info.SetKey(kData, base::Value(l10n_util::GetStringUTF16( - IDS_MANAGEMENT_DEVICE_MANAGED_DATA))); - status->SetKey(kDeviceManagedInfo, std::move(info)); -} - -void AddStatusDeviceAndAccountManagedInfo( - base::Value* status, - const std::string& device_and_account_domain) { - base::Value info(base::Value::Type::DICTIONARY); - info.SetKey(kOverview, - base::Value(l10n_util::GetStringFUTF16( - IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_CLARIFICATION, - base::UTF8ToUTF16(device_and_account_domain)))); - info.SetKey(kSetup, base::Value(l10n_util::GetStringUTF16( - IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_SETUP))); - info.SetKey(kData, base::Value(l10n_util::GetStringUTF16( - IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_DATA))); - status->SetKey(kDeviceManagedInfo, std::move(info)); -} -#endif // defined(OS_CHROMEOS) - void AddStatusAccountManagedInfo(base::Value* status, const std::string& account_domain) { base::Value info(base::Value::Type::DICTIONARY); @@ -629,117 +589,106 @@ #if defined(OS_CHROMEOS) void AddStatusOverviewManagedDeviceAndAccount( base::Value* status, + bool device_managed, + bool account_managed, const std::string& device_domain, const std::string& account_domain) { - status->SetKey(kOverview, - base::Value(l10n_util::GetStringFUTF16( - IDS_MANAGEMENT_DEVICE_MANAGED_BY_ACCOUNT_MANAGED_BY, - base::UTF8ToUTF16(device_domain), - base::UTF8ToUTF16(account_domain)))); - AddStatusDeviceManagedInfo(status, device_domain); - AddStatusAccountManagedInfo(status, account_domain); -} + if (device_managed && account_managed && + (account_domain.empty() || account_domain == device_domain)) { + status->SetKey(kOverview, base::Value(l10n_util::GetStringFUTF16( + IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_BY, + base::UTF8ToUTF16(device_domain)))); + base::Value info(base::Value::Type::DICTIONARY); + info.SetKey(kOverview, + base::Value(l10n_util::GetStringFUTF16( + IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_CLARIFICATION, + base::UTF8ToUTF16(device_domain)))); + info.SetKey(kSetup, base::Value(l10n_util::GetStringUTF16( + IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_SETUP))); + info.SetKey(kData, base::Value(l10n_util::GetStringUTF16( + IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_DATA))); + status->SetKey(kDeviceManagedInfo, std::move(info)); -void AddStatusOverviewManagedDeviceAndAccount( - base::Value* status, - const std::string& device_and_account_domain) { - status->SetKey(kOverview, base::Value(l10n_util::GetStringFUTF16( - IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_BY, - base::UTF8ToUTF16(device_and_account_domain)))); - AddStatusDeviceAndAccountManagedInfo(status, device_and_account_domain); - status->SetKey(kAccountManagedInfo, base::Value()); -} + return; + } -void AddStatusOverviewManagedDevice(base::Value* status, - const std::string& device_domain) { - status->SetKey(kOverview, base::Value(l10n_util::GetStringFUTF16( - IDS_MANAGEMENT_DEVICE_MANAGED_BY, - base::UTF8ToUTF16(device_domain)))); - AddStatusDeviceManagedInfo(status, device_domain); - status->SetKey(kAccountManagedInfo, base::Value()); -} - -#endif // defined(OS_CHROMEOS) - -void AddStatusOverviewManagedAccount(base::Value* status, - const std::string& account_domain) { -#if defined(OS_CHROMEOS) - status->SetKey(kOverview, base::Value(l10n_util::GetStringFUTF16( - IDS_MANAGEMENT_ACCOUNT_MANAGED_BY, - base::UTF8ToUTF16(account_domain)))); - status->SetKey(kDeviceManagedInfo, base::Value()); -#endif // defined(OS_CHROMEOS) - AddStatusAccountManagedInfo(status, account_domain); -} - -#if defined(OS_CHROMEOS) -void AddStatusOverviewNotManaged(base::Value* status) { - status->SetKey(kOverview, base::Value(l10n_util::GetStringUTF16( - IDS_MANAGEMENT_DEVICE_NOT_MANAGED))); - status->SetKey(kAccountManagedInfo, base::Value()); - status->SetKey(kDeviceManagedInfo, base::Value()); -} -#endif // defined(OS_CHROMEOS) - -void ManagementUIHandler::GetManagementStatus(Profile* profile, - base::Value* status) const { - const std::string account_domain = GetAccountDomain(profile); -#if defined(OS_CHROMEOS) - const bool account_managed = IsProfileManaged(profile); - const bool profile_associated_with_gaia_account = - chromeos::IsProfileAssociatedWithGaiaAccount(profile); - - std::string device_domain; - policy::BrowserPolicyConnectorChromeOS* connector = - g_browser_process->platform_part()->browser_policy_connector_chromeos(); - const bool device_managed = connector->IsEnterpriseManaged(); - if (device_managed) - device_domain = connector->GetEnterpriseDisplayDomain(); - if (device_domain.empty() && connector->IsActiveDirectoryManaged()) - device_domain = connector->GetRealm(); - - bool primary_user_managed = false; - std::string primary_user_account_domain; - auto* primary_user = user_manager::UserManager::Get()->GetPrimaryUser(); - if (primary_user) { - auto* primary_profile = - chromeos::ProfileHelper::Get()->GetProfileByUser(primary_user); - if (primary_profile) { - primary_user_managed = IsProfileManaged(primary_profile); - primary_user_account_domain = GetAccountDomain(primary_profile); + if (account_managed) { + AddStatusAccountManagedInfo( + status, !account_domain.empty() ? account_domain : device_domain); + if (!account_domain.empty()) { + status->SetKey(kOverview, base::Value(l10n_util::GetStringFUTF16( + IDS_MANAGEMENT_ACCOUNT_MANAGED_BY, + base::UTF8ToUTF16(account_domain)))); } } if (device_managed) { - DCHECK(!device_domain.empty()); - if (account_managed) { - if (device_domain == account_domain || - !profile_associated_with_gaia_account) { - AddStatusOverviewManagedDeviceAndAccount(status, device_domain); - return; - } - DCHECK(!account_domain.empty()); - AddStatusOverviewManagedDeviceAndAccount(status, device_domain, - account_domain); - return; - } - AddStatusOverviewManagedDevice(status, device_domain); - return; + base::Value info(base::Value::Type::DICTIONARY); + info.SetKey(kOverview, base::Value(l10n_util::GetStringFUTF16( + IDS_MANAGEMENT_DEVICE_MANAGED_CLARIFICATION, + base::UTF8ToUTF16(device_domain)))); + info.SetKey(kSetup, base::Value(l10n_util::GetStringUTF16( + IDS_MANAGEMENT_DEVICE_MANAGED_SETUP))); + info.SetKey(kData, base::Value(l10n_util::GetStringUTF16( + IDS_MANAGEMENT_DEVICE_MANAGED_DATA))); + status->SetKey(kDeviceManagedInfo, std::move(info)); } - if (primary_user_managed) { - AddStatusOverviewManagedAccount(status, primary_user_account_domain); - return; + if (account_managed && device_managed && !account_domain.empty() && + account_domain != device_domain) { + status->SetKey(kOverview, + base::Value(l10n_util::GetStringFUTF16( + IDS_MANAGEMENT_DEVICE_MANAGED_BY_ACCOUNT_MANAGED_BY, + base::UTF8ToUTF16(device_domain), + base::UTF8ToUTF16(account_domain)))); } +} + +const std::string ManagementUIHandler::GetDeviceDomain() const { + std::string device_domain; + policy::BrowserPolicyConnectorChromeOS* connector = + g_browser_process->platform_part()->browser_policy_connector_chromeos(); + if (device_managed_) + device_domain = connector->GetEnterpriseDisplayDomain(); + if (device_domain.empty() && connector->IsActiveDirectoryManaged()) + device_domain = connector->GetRealm(); + return device_domain; +} + #endif // defined(OS_CHROMEOS) - if (managed_) { - AddStatusOverviewManagedAccount(status, account_domain); +void ManagementUIHandler::GetManagementStatus(Profile* profile, + base::Value* status) const { +#if defined(OS_CHROMEOS) + status->SetKey(kDeviceManagedInfo, base::Value()); + status->SetKey(kAccountManagedInfo, base::Value()); + status->SetKey(kOverview, base::Value()); + if (!managed_()) { + status->SetKey(kOverview, base::Value(l10n_util::GetStringUTF16( + IDS_MANAGEMENT_DEVICE_NOT_MANAGED))); return; } -#if defined(OS_CHROMEOS) - AddStatusOverviewNotManaged(status); + std::string account_domain = GetAccountDomain(profile); + auto* primary_user = user_manager::UserManager::Get()->GetPrimaryUser(); + auto* primary_profile = + primary_user + ? chromeos::ProfileHelper::Get()->GetProfileByUser(primary_user) + : nullptr; + const bool primary_user_managed = + primary_profile ? IsProfileManaged(primary_profile) : false; + + if (primary_user_managed) + account_domain = GetAccountDomain(primary_profile); + + std::string device_domain = GetDeviceDomain(); + + AddStatusOverviewManagedDeviceAndAccount( + status, device_managed_, account_managed_ || primary_user_managed, + device_domain, account_domain); +#else + if (managed_()) + AddStatusAccountManagedInfo(status, GetAccountDomain(profile)); #endif // defined(OS_CHROMEOS) } @@ -835,27 +784,29 @@ } } -void ManagementUIHandler::OnManagedStateChanged() { +void ManagementUIHandler::UpdateManagedState() { auto* profile = Profile::FromWebUI(web_ui()); + bool managed_state_changed = false; #if defined(OS_CHROMEOS) - bool managed = IsProfileManaged(profile) || IsDeviceManaged(); + managed_state_changed |= account_managed_ != IsProfileManaged(profile); + managed_state_changed |= device_managed_ != IsDeviceManaged(); + account_managed_ = IsProfileManaged(profile); + device_managed_ = IsDeviceManaged(); #else - bool managed = IsProfileManaged(profile) || IsBrowserManaged(); + managed_state_changed |= + account_managed_ != (IsProfileManaged(profile) || IsBrowserManaged()); + account_managed_ = IsProfileManaged(profile) || IsBrowserManaged(); #endif // defined(OS_CHROMEOS) - if (managed == managed_) - return; - - managed_ = managed; - - FireWebUIListener("managed_state_changed"); + if (managed_state_changed) + FireWebUIListener("managed_state_changed"); } void ManagementUIHandler::OnPolicyUpdated( const policy::PolicyNamespace& /*ns*/, const policy::PolicyMap& /*previous*/, const policy::PolicyMap& /*current*/) { - OnManagedStateChanged(); + UpdateManagedState(); NotifyBrowserReportingInfoUpdated(); } @@ -876,7 +827,7 @@ pref_registrar_.Add( prefs::kSupervisedUserId, - base::BindRepeating(&ManagementUIHandler::OnManagedStateChanged, + base::BindRepeating(&ManagementUIHandler::UpdateManagedState, base::Unretained(this))); }
diff --git a/chrome/browser/ui/webui/management_ui_handler.h b/chrome/browser/ui/webui/management_ui_handler.h index daca8ea..27d6edc 100644 --- a/chrome/browser/ui/webui/management_ui_handler.h +++ b/chrome/browser/ui/webui/management_ui_handler.h
@@ -98,15 +98,18 @@ // content::WebUIMessageHandler implementation. void RegisterMessages() override; - void SetManagedForTesting(bool managed) { managed_ = managed; } + void SetAccountManagedForTesting(bool managed) { account_managed_ = managed; } + void SetDeviceManagedForTesting(bool managed) { device_managed_ = managed; } static std::string GetAccountDomain(Profile* profile); #if BUILDFLAG(ENABLE_EXTENSIONS) void OnJavascriptAllowed() override; void OnJavascriptDisallowed() override; +#endif // BUILDFLAG(ENABLE_EXTENSIONS) protected: +#if BUILDFLAG(ENABLE_EXTENSIONS) // Protected for testing. static void InitializeInternal(content::WebUI* web_ui, content::WebUIDataSource* source, @@ -119,6 +122,10 @@ const std::string& extensionId) const; #endif // BUILDFLAG(ENABLE_EXTENSIONS) +#if defined(OS_CHROMEOS) + // Protected for testing. + virtual const std::string GetDeviceDomain() const; +#endif // defined(OS_CHROMEOS) private: void GetManagementStatus(Profile* profile, base::Value* status) const; @@ -145,7 +152,7 @@ const extensions::Extension* extension, extensions::UnloadedExtensionReason reason) override; - void OnManagedStateChanged(); + void UpdateManagedState(); // policy::PolicyService::Observer void OnPolicyUpdated(const policy::PolicyNamespace& ns, @@ -155,10 +162,12 @@ void AddObservers(); void RemoveObservers(); + bool managed_() const { return account_managed_ || device_managed_; } + bool account_managed_ = false; + bool device_managed_ = false; // To avoid double-removing the observers, which would cause a DCHECK() // failure. bool has_observers_ = false; - bool managed_ = false; std::string web_ui_data_source_name_; PrefChangeRegistrar pref_registrar_;
diff --git a/chrome/browser/ui/webui/management_ui_handler_unittest.cc b/chrome/browser/ui/webui/management_ui_handler_unittest.cc index f081a56..ee7a380 100644 --- a/chrome/browser/ui/webui/management_ui_handler_unittest.cc +++ b/chrome/browser/ui/webui/management_ui_handler_unittest.cc
@@ -34,11 +34,18 @@ struct ContextualManagementSourceUpdate { base::string16* extension_reporting_title; - base::string16* browser_management_notice; base::string16* subtitle; + base::string16* management_account_overview; + base::string16* management_account_overview_data_notice; + base::string16* management_account_overview_setup_notice; +#if defined(OS_CHROMEOS) + base::string16* management_device_overview; + base::string16* management_device_overview_data_notice; + base::string16* management_device_overview_setup_notice; base::string16* management_overview; - base::string16* management_overview_data_notice; - base::string16* management_overview_setup_notice; +#else + base::string16* browser_management_notice; +#endif // defined(OS_CHROMEOS) bool* managed; }; @@ -75,18 +82,27 @@ return nullptr; } +#if defined(OS_CHROMEOS) + const std::string GetDeviceDomain() const override { return device_domain; } + void SetDeviceDomain(const std::string& domain) { device_domain = domain; } +#endif // defined(OS_CHROMEOS) + private: bool cloud_reporting_extension_exists_ = false; policy::PolicyService* policy_service_ = nullptr; + std::string device_domain = "devicedomain.com"; }; class ManagementUIHandlerTests : public testing::Test { public: - ManagementUIHandlerTests() : handler_(&policy_service_) { + ManagementUIHandlerTests() + : handler_(&policy_service_), + device_domain_(base::UTF8ToUTF16("devicedomain.com")) { ON_CALL(policy_service_, GetPolicies(_)) .WillByDefault(ReturnRef(empty_policy_map_)); } + base::string16 device_domain() { return device_domain_; } void EnablePolicy(const char* policy_key, policy::PolicyMap& policies) { policies.Set(policy_key, policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_MACHINE, policy::POLICY_SOURCE_CLOUD, @@ -98,15 +114,25 @@ const ContextualManagementSourceUpdate& extracted) { data.GetString("extensionReportingTitle", extracted.extension_reporting_title); - data.GetString("browserManagementNotice", - extracted.browser_management_notice); data.GetString("pageSubtitle", extracted.subtitle); data.GetString("accountManagedInfo.overview", - extracted.management_overview); + extracted.management_account_overview); data.GetString("accountManagedInfo.data", - extracted.management_overview_data_notice); + extracted.management_account_overview_data_notice); data.GetString("accountManagedInfo.setup", - extracted.management_overview_setup_notice); + extracted.management_account_overview_setup_notice); +#if defined(OS_CHROMEOS) + data.GetString("deviceManagedInfo.overview", + extracted.management_device_overview); + data.GetString("deviceManagedInfo.data", + extracted.management_device_overview_data_notice); + data.GetString("deviceManagedInfo.setup", + extracted.management_device_overview_setup_notice); + data.GetString("overview", extracted.management_overview); +#else + data.GetString("browserManagementNotice", + extracted.browser_management_notice); +#endif // defined(OS_CHROMEOS) data.GetBoolean("managed", extracted.managed); } @@ -115,6 +141,7 @@ content::TestBrowserThreadBundle thread_bundle_; policy::MockPolicyService policy_service_; policy::PolicyMap empty_policy_map_; + base::string16 device_domain_; }; #if !defined(OS_CHROMEOS) @@ -123,21 +150,22 @@ auto profile = TestingProfile::Builder().Build(); base::string16 extension_reporting_title; - base::string16 browser_management_notice; base::string16 subtitle; - base::string16 management_overview; - base::string16 management_overview_data_notice; - base::string16 management_overview_setup_notice; + base::string16 management_account_overview; + base::string16 management_account_overview_data_notice; + base::string16 management_account_overview_setup_notice; + base::string16 browser_management_notice; bool managed; - ContextualManagementSourceUpdate extracted{&extension_reporting_title, - &browser_management_notice, - &subtitle, - &management_overview, - &management_overview_data_notice, - &management_overview_setup_notice, - &managed}; + ContextualManagementSourceUpdate extracted{ + &extension_reporting_title, + &subtitle, + &management_account_overview, + &management_account_overview_data_notice, + &management_account_overview_setup_notice, + &browser_management_notice, + &managed}; - handler_.SetManagedForTesting(false); + handler_.SetAccountManagedForTesting(false); auto data = handler_.GetContextualManagedDataForTesting(profile.get()); ExtractContextualSourceUpdate(data, extracted); @@ -150,9 +178,9 @@ base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl))); EXPECT_EQ(subtitle, l10n_util::GetStringUTF16(IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE)); - EXPECT_EQ(management_overview, base::string16()); - EXPECT_EQ(management_overview_data_notice, base::string16()); - EXPECT_EQ(management_overview_setup_notice, base::string16()); + EXPECT_EQ(management_account_overview, base::string16()); + EXPECT_EQ(management_account_overview_data_notice, base::string16()); + EXPECT_EQ(management_account_overview_setup_notice, base::string16()); } TEST_F(ManagementUIHandlerTests, @@ -160,21 +188,22 @@ auto profile = TestingProfile::Builder().Build(); base::string16 extension_reporting_title; - base::string16 browser_management_notice; base::string16 subtitle; - base::string16 management_overview; - base::string16 management_overview_data_notice; - base::string16 management_overview_setup_notice; + base::string16 management_account_overview; + base::string16 management_account_overview_data_notice; + base::string16 management_account_overview_setup_notice; + base::string16 browser_management_notice; bool managed; - ContextualManagementSourceUpdate extracted{&extension_reporting_title, - &browser_management_notice, - &subtitle, - &management_overview, - &management_overview_data_notice, - &management_overview_setup_notice, - &managed}; + ContextualManagementSourceUpdate extracted{ + &extension_reporting_title, + &subtitle, + &management_account_overview, + &management_account_overview_data_notice, + &management_account_overview_setup_notice, + &browser_management_notice, + &managed}; - handler_.SetManagedForTesting(true); + handler_.SetAccountManagedForTesting(true); auto data = handler_.GetContextualManagedDataForTesting(profile.get()); ExtractContextualSourceUpdate(data, extracted); @@ -186,12 +215,12 @@ IDS_MANAGEMENT_BROWSER_NOTICE, base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl))); EXPECT_EQ(subtitle, l10n_util::GetStringUTF16(IDS_MANAGEMENT_SUBTITLE)); - EXPECT_EQ(management_overview, + EXPECT_EQ(management_account_overview, l10n_util::GetStringUTF16( IDS_MANAGEMENT_ACCOUNT_MANAGED_CLARIFICATION_UNKNOWN_DOMAIN)); - EXPECT_EQ(management_overview_data_notice, + EXPECT_EQ(management_account_overview_data_notice, l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_DATA)); - EXPECT_EQ(management_overview_setup_notice, + EXPECT_EQ(management_account_overview_setup_notice, l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_SETUP)); EXPECT_TRUE(managed); } @@ -203,21 +232,22 @@ auto profile = builder.Build(); base::string16 extensions_installed; - base::string16 browser_management_notice; base::string16 subtitle; - base::string16 management_overview; - base::string16 management_overview_data_notice; - base::string16 management_overview_setup_notice; + base::string16 management_account_overview; + base::string16 management_account_overview_data_notice; + base::string16 management_account_overview_setup_notice; + base::string16 browser_management_notice; bool managed; - ContextualManagementSourceUpdate extracted{&extensions_installed, - &browser_management_notice, - &subtitle, - &management_overview, - &management_overview_data_notice, - &management_overview_setup_notice, - &managed}; + ContextualManagementSourceUpdate extracted{ + &extensions_installed, + &subtitle, + &management_account_overview, + &management_account_overview_data_notice, + &management_account_overview_setup_notice, + &browser_management_notice, + &managed}; - handler_.SetManagedForTesting(true); + handler_.SetAccountManagedForTesting(true); auto data = handler_.GetContextualManagedDataForTesting(profile.get()); ExtractContextualSourceUpdate(data, extracted); @@ -229,12 +259,12 @@ IDS_MANAGEMENT_BROWSER_NOTICE, base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl))); EXPECT_EQ(subtitle, l10n_util::GetStringUTF16(IDS_MANAGEMENT_SUBTITLE)); - EXPECT_EQ(management_overview, + EXPECT_EQ(management_account_overview, l10n_util::GetStringUTF16( IDS_MANAGEMENT_ACCOUNT_MANAGED_CLARIFICATION_UNKNOWN_DOMAIN)); - EXPECT_EQ(management_overview_data_notice, + EXPECT_EQ(management_account_overview_data_notice, l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_DATA)); - EXPECT_EQ(management_overview_setup_notice, + EXPECT_EQ(management_account_overview_setup_notice, l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_SETUP)); EXPECT_TRUE(managed); } @@ -246,21 +276,22 @@ auto profile = builder.Build(); base::string16 extension_reporting_title; - base::string16 browser_management_notice; base::string16 subtitle; - base::string16 management_overview; - base::string16 management_overview_data_notice; - base::string16 management_overview_setup_notice; + base::string16 management_account_overview; + base::string16 management_account_overview_data_notice; + base::string16 management_account_overview_setup_notice; + base::string16 browser_management_notice; bool managed; - ContextualManagementSourceUpdate extracted{&extension_reporting_title, - &browser_management_notice, - &subtitle, - &management_overview, - &management_overview_data_notice, - &management_overview_setup_notice, - &managed}; + ContextualManagementSourceUpdate extracted{ + &extension_reporting_title, + &subtitle, + &management_account_overview, + &management_account_overview_data_notice, + &management_account_overview_setup_notice, + &browser_management_notice, + &managed}; - handler_.SetManagedForTesting(false); + handler_.SetAccountManagedForTesting(false); auto data = handler_.GetContextualManagedDataForTesting(profile.get()); ExtractContextualSourceUpdate(data, extracted); @@ -275,9 +306,9 @@ base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl))); EXPECT_EQ(subtitle, l10n_util::GetStringUTF16(IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE)); - EXPECT_EQ(management_overview, base::string16()); - EXPECT_EQ(management_overview_data_notice, base::string16()); - EXPECT_EQ(management_overview_setup_notice, base::string16()); + EXPECT_EQ(management_account_overview, base::string16()); + EXPECT_EQ(management_account_overview_data_notice, base::string16()); + EXPECT_EQ(management_account_overview_setup_notice, base::string16()); EXPECT_FALSE(managed); } @@ -288,21 +319,22 @@ auto profile = builder.Build(); base::string16 extension_reporting_title; - base::string16 browser_management_notice; base::string16 subtitle; - base::string16 management_overview; - base::string16 management_overview_data_notice; - base::string16 management_overview_setup_notice; + base::string16 management_account_overview; + base::string16 management_account_overview_data_notice; + base::string16 management_account_overview_setup_notice; + base::string16 browser_management_notice; bool managed; - ContextualManagementSourceUpdate extracted{&extension_reporting_title, - &browser_management_notice, - &subtitle, - &management_overview, - &management_overview_data_notice, - &management_overview_setup_notice, - &managed}; + ContextualManagementSourceUpdate extracted{ + &extension_reporting_title, + &subtitle, + &management_account_overview, + &management_account_overview_data_notice, + &management_account_overview_setup_notice, + &browser_management_notice, + &managed}; - handler_.SetManagedForTesting(false); + handler_.SetAccountManagedForTesting(false); auto data = handler_.GetContextualManagedDataForTesting(profile.get()); ExtractContextualSourceUpdate(data, extracted); @@ -316,9 +348,9 @@ base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl))); EXPECT_EQ(subtitle, l10n_util::GetStringUTF16(IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE)); - EXPECT_EQ(management_overview, base::string16()); - EXPECT_EQ(management_overview_data_notice, base::string16()); - EXPECT_EQ(management_overview_setup_notice, base::string16()); + EXPECT_EQ(management_account_overview, base::string16()); + EXPECT_EQ(management_account_overview_data_notice, base::string16()); + EXPECT_EQ(management_account_overview_setup_notice, base::string16()); EXPECT_FALSE(managed); } @@ -329,21 +361,23 @@ auto profile = builder.Build(); base::string16 extension_reporting_title; - base::string16 browser_management_notice; base::string16 subtitle; - base::string16 management_overview; - base::string16 management_overview_data_notice; - base::string16 management_overview_setup_notice; + base::string16 management_account_overview; + base::string16 management_account_overview_data_notice; + base::string16 management_account_overview_setup_notice; + base::string16 browser_management_notice; bool managed; - ContextualManagementSourceUpdate extracted{&extension_reporting_title, - &browser_management_notice, - &subtitle, - &management_overview, - &management_overview_data_notice, - &management_overview_setup_notice, - &managed}; + ContextualManagementSourceUpdate extracted{ + &extension_reporting_title, + &subtitle, + &management_account_overview, + &management_account_overview_data_notice, + &management_account_overview_setup_notice, + &browser_management_notice, + &managed}; - handler_.SetManagedForTesting(true); + handler_.SetAccountManagedForTesting(true); + handler_.SetDeviceManagedForTesting(false); auto data = handler_.GetContextualManagedDataForTesting(profile.get()); ExtractContextualSourceUpdate(data, extracted); @@ -351,21 +385,20 @@ EXPECT_EQ(extension_reporting_title, l10n_util::GetStringFUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED_BY, base::UTF8ToUTF16("manager.com"))); - EXPECT_EQ( - browser_management_notice, - l10n_util::GetStringFUTF16( - IDS_MANAGEMENT_MANAGEMENT_BY_NOTICE, base::UTF8ToUTF16("manager.com"), - base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl))); + EXPECT_EQ(browser_management_notice, + l10n_util::GetStringFUTF16( + IDS_MANAGEMENT_BROWSER_NOTICE, + base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl))); EXPECT_EQ(subtitle, l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED_BY, base::UTF8ToUTF16("manager.com"))); EXPECT_EQ( - management_overview, + management_account_overview, l10n_util::GetStringFUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_CLARIFICATION, base::UTF8ToUTF16("manager.com"))); - EXPECT_EQ(management_overview_data_notice, + EXPECT_EQ(management_account_overview_data_notice, l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_DATA)); - EXPECT_EQ(management_overview_setup_notice, + EXPECT_EQ(management_account_overview_setup_notice, l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_SETUP)); EXPECT_TRUE(managed); } @@ -380,29 +413,279 @@ auto profile = builder.Build(); const auto device_type = ui::GetChromeOSDeviceTypeResourceId(); - base::string16 extensions_installed; - base::string16 browser_management_notice; + base::string16 extension_reporting_title; base::string16 subtitle; + base::string16 management_account_overview; + base::string16 management_account_overview_data_notice; + base::string16 management_account_overview_setup_notice; + base::string16 management_device_overview; + base::string16 management_device_overview_data_notice; + base::string16 management_device_overview_setup_notice; base::string16 management_overview; - base::string16 management_overview_data_notice; - base::string16 management_overview_setup_notice; bool managed; - ContextualManagementSourceUpdate extracted{&extensions_installed, - &browser_management_notice, - &subtitle, - &management_overview, - &management_overview_data_notice, - &management_overview_setup_notice, - &managed}; + ContextualManagementSourceUpdate extracted{ + &extension_reporting_title, + &subtitle, + &management_account_overview, + &management_account_overview_data_notice, + &management_account_overview_setup_notice, + &management_device_overview, + &management_device_overview_data_notice, + &management_device_overview_setup_notice, + &management_overview, + &managed}; - handler_.SetManagedForTesting(true); + handler_.SetAccountManagedForTesting(true); + handler_.SetDeviceManagedForTesting(false); + handler_.SetDeviceDomain(""); + auto data = handler_.GetContextualManagedDataForTesting(profile.get()); + ExtractContextualSourceUpdate(data, extracted); + + EXPECT_EQ(extension_reporting_title, + l10n_util::GetStringFUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED_BY, + base::UTF8ToUTF16("manager.com"))); + EXPECT_EQ(subtitle, + l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED_BY, + l10n_util::GetStringUTF16(device_type), + base::UTF8ToUTF16("manager.com"))); + EXPECT_EQ( + management_account_overview, + l10n_util::GetStringFUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_CLARIFICATION, + base::UTF8ToUTF16("manager.com"))); + EXPECT_EQ(management_account_overview_data_notice, + l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_DATA)); + EXPECT_EQ(management_account_overview_setup_notice, + l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_SETUP)); + EXPECT_EQ(management_device_overview, base::string16()); + EXPECT_EQ(management_device_overview_data_notice, base::string16()); + EXPECT_EQ(management_device_overview_setup_notice, base::string16()); + EXPECT_EQ(management_overview, + l10n_util::GetStringFUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_BY, + base::UTF8ToUTF16("manager.com"))); + EXPECT_TRUE(managed); +} + +TEST_F(ManagementUIHandlerTests, + ManagementContextualSourceUpdateManagedAccountUnknownDomain) { + TestingProfile::Builder builder; + auto profile = builder.Build(); + const auto device_type = ui::GetChromeOSDeviceTypeResourceId(); + + base::string16 extension_reporting_title; + base::string16 subtitle; + base::string16 management_account_overview; + base::string16 management_account_overview_data_notice; + base::string16 management_account_overview_setup_notice; + base::string16 management_device_overview; + base::string16 management_device_overview_data_notice; + base::string16 management_device_overview_setup_notice; + base::string16 management_overview; + bool managed; + ContextualManagementSourceUpdate extracted{ + &extension_reporting_title, + &subtitle, + &management_account_overview, + &management_account_overview_data_notice, + &management_account_overview_setup_notice, + &management_device_overview, + &management_device_overview_data_notice, + &management_device_overview_setup_notice, + &management_overview, + &managed}; + + handler_.SetAccountManagedForTesting(true); + handler_.SetDeviceManagedForTesting(false); + handler_.SetDeviceDomain(""); + auto data = handler_.GetContextualManagedDataForTesting(profile.get()); + ExtractContextualSourceUpdate(data, extracted); + + EXPECT_EQ(extension_reporting_title, + l10n_util::GetStringUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED)); + EXPECT_EQ(subtitle, + l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED, + l10n_util::GetStringUTF16(device_type))); + EXPECT_EQ(management_account_overview_data_notice, + l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_DATA)); + EXPECT_EQ(management_account_overview_setup_notice, + l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_SETUP)); + EXPECT_EQ(management_device_overview, base::string16()); + EXPECT_EQ(management_device_overview_data_notice, base::string16()); + EXPECT_EQ(management_device_overview_setup_notice, base::string16()); + EXPECT_EQ(management_overview, base::string16()); + EXPECT_TRUE(managed); +} + +TEST_F(ManagementUIHandlerTests, + ManagementContextualSourceUpdateManagedDevice) { + TestingProfile::Builder builder; + builder.SetProfileName("managed@manager.com"); + auto profile = builder.Build(); + const auto device_type = ui::GetChromeOSDeviceTypeResourceId(); + + base::string16 extension_reporting_title; + base::string16 subtitle; + base::string16 management_account_overview; + base::string16 management_account_overview_data_notice; + base::string16 management_account_overview_setup_notice; + base::string16 management_device_overview; + base::string16 management_device_overview_data_notice; + base::string16 management_device_overview_setup_notice; + base::string16 management_overview; + bool managed; + ContextualManagementSourceUpdate extracted{ + &extension_reporting_title, + &subtitle, + &management_account_overview, + &management_account_overview_data_notice, + &management_account_overview_setup_notice, + &management_device_overview, + &management_device_overview_data_notice, + &management_device_overview_setup_notice, + &management_overview, + &managed}; + + handler_.SetAccountManagedForTesting(false); + handler_.SetDeviceManagedForTesting(true); auto data = handler_.GetContextualManagedDataForTesting(profile.get()); ExtractContextualSourceUpdate(data, extracted); EXPECT_EQ(subtitle, l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED_BY, l10n_util::GetStringUTF16(device_type), - base::UTF8ToUTF16("manager.com"))); + device_domain())); + EXPECT_EQ(extension_reporting_title, + l10n_util::GetStringFUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED_BY, + device_domain())); + EXPECT_EQ(management_account_overview, base::string16()); + EXPECT_EQ(management_account_overview_data_notice, base::string16()); + EXPECT_EQ(management_account_overview_setup_notice, base::string16()); + EXPECT_EQ(management_device_overview, + l10n_util::GetStringFUTF16( + IDS_MANAGEMENT_DEVICE_MANAGED_CLARIFICATION, device_domain())); + EXPECT_EQ(management_device_overview_data_notice, + l10n_util::GetStringUTF16(IDS_MANAGEMENT_DEVICE_MANAGED_DATA)); + EXPECT_EQ(management_device_overview_setup_notice, + l10n_util::GetStringUTF16(IDS_MANAGEMENT_DEVICE_MANAGED_SETUP)); + EXPECT_EQ(management_overview, base::string16()); + EXPECT_TRUE(managed); +} + +TEST_F(ManagementUIHandlerTests, + ManagementContextualSourceUpdateManagedDeviceAndAccount) { + TestingProfile::Builder builder; + builder.SetProfileName("managed@devicedomain.com"); + auto profile = builder.Build(); + const auto device_type = ui::GetChromeOSDeviceTypeResourceId(); + + base::string16 extension_reporting_title; + base::string16 subtitle; + base::string16 management_account_overview; + base::string16 management_account_overview_data_notice; + base::string16 management_account_overview_setup_notice; + base::string16 management_device_overview; + base::string16 management_device_overview_data_notice; + base::string16 management_device_overview_setup_notice; + base::string16 management_overview; + bool managed; + ContextualManagementSourceUpdate extracted{ + &extension_reporting_title, + &subtitle, + &management_account_overview, + &management_account_overview_data_notice, + &management_account_overview_setup_notice, + &management_device_overview, + &management_device_overview_data_notice, + &management_device_overview_setup_notice, + &management_overview, + &managed}; + + handler_.SetAccountManagedForTesting(true); + handler_.SetDeviceManagedForTesting(true); + auto data = handler_.GetContextualManagedDataForTesting(profile.get()); + ExtractContextualSourceUpdate(data, extracted); + + EXPECT_EQ(subtitle, + l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED_BY, + l10n_util::GetStringUTF16(device_type), + device_domain())); + EXPECT_EQ(extension_reporting_title, + l10n_util::GetStringFUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED_BY, + device_domain())); + EXPECT_EQ(management_account_overview, base::string16()); + EXPECT_EQ(management_account_overview_data_notice, base::string16()); + EXPECT_EQ(management_account_overview_setup_notice, base::string16()); + EXPECT_EQ(management_device_overview, + l10n_util::GetStringFUTF16( + IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_CLARIFICATION, + device_domain())); + EXPECT_EQ(management_device_overview_data_notice, + l10n_util::GetStringUTF16( + IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_DATA)); + EXPECT_EQ(management_device_overview_setup_notice, + l10n_util::GetStringUTF16( + IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_SETUP)); + EXPECT_EQ(management_overview, + l10n_util::GetStringFUTF16( + IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_BY, device_domain())); + EXPECT_TRUE(managed); +} + +TEST_F(ManagementUIHandlerTests, + ManagementContextualSourceUpdateManagedDeviceAndAccountMultipleDomains) { + TestingProfile::Builder builder; + builder.SetProfileName("managed@manager.com"); + auto profile = builder.Build(); + const auto device_type = ui::GetChromeOSDeviceTypeResourceId(); + + base::string16 extension_reporting_title; + base::string16 subtitle; + base::string16 management_account_overview; + base::string16 management_account_overview_data_notice; + base::string16 management_account_overview_setup_notice; + base::string16 management_device_overview; + base::string16 management_device_overview_data_notice; + base::string16 management_device_overview_setup_notice; + base::string16 management_overview; + bool managed; + ContextualManagementSourceUpdate extracted{ + &extension_reporting_title, + &subtitle, + &management_account_overview, + &management_account_overview_data_notice, + &management_account_overview_setup_notice, + &management_device_overview, + &management_device_overview_data_notice, + &management_device_overview_setup_notice, + &management_overview, + &managed}; + + handler_.SetAccountManagedForTesting(true); + handler_.SetDeviceManagedForTesting(true); + auto data = handler_.GetContextualManagedDataForTesting(profile.get()); + ExtractContextualSourceUpdate(data, extracted); + + EXPECT_EQ(subtitle, + l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED_BY, + l10n_util::GetStringUTF16(device_type), + device_domain())); + EXPECT_EQ(extension_reporting_title, + l10n_util::GetStringFUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED_BY, + device_domain())); + EXPECT_EQ(management_account_overview_data_notice, + l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_DATA)); + EXPECT_EQ(management_account_overview_setup_notice, + l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_SETUP)); + EXPECT_EQ(management_device_overview, + l10n_util::GetStringFUTF16( + IDS_MANAGEMENT_DEVICE_MANAGED_CLARIFICATION, device_domain())); + EXPECT_EQ(management_device_overview_data_notice, + l10n_util::GetStringUTF16(IDS_MANAGEMENT_DEVICE_MANAGED_DATA)); + EXPECT_EQ(management_device_overview_setup_notice, + l10n_util::GetStringUTF16(IDS_MANAGEMENT_DEVICE_MANAGED_SETUP)); + EXPECT_EQ(management_overview, + l10n_util::GetStringFUTF16( + IDS_MANAGEMENT_DEVICE_MANAGED_BY_ACCOUNT_MANAGED_BY, + device_domain(), base::UTF8ToUTF16("manager.com"))); EXPECT_TRUE(managed); } @@ -411,26 +694,44 @@ const auto device_type = ui::GetChromeOSDeviceTypeResourceId(); base::string16 extension_reporting_title; - base::string16 browser_management_notice; base::string16 subtitle; + base::string16 management_account_overview; + base::string16 management_account_overview_data_notice; + base::string16 management_account_overview_setup_notice; + base::string16 management_device_overview; + base::string16 management_device_overview_data_notice; + base::string16 management_device_overview_setup_notice; base::string16 management_overview; - base::string16 management_overview_data_notice; - base::string16 management_overview_setup_notice; bool managed; - ContextualManagementSourceUpdate extracted{&extension_reporting_title, - &browser_management_notice, - &subtitle, - &management_overview, - &management_overview_data_notice, - &management_overview_setup_notice, - &managed}; + ContextualManagementSourceUpdate extracted{ + &extension_reporting_title, + &subtitle, + &management_account_overview, + &management_account_overview_data_notice, + &management_account_overview_setup_notice, + &management_device_overview, + &management_device_overview_data_notice, + &management_device_overview_setup_notice, + &management_overview, + &managed}; - handler_.SetManagedForTesting(false); + handler_.SetAccountManagedForTesting(false); + handler_.SetDeviceDomain(""); auto data = handler_.GetContextualManagedDataForTesting(profile.get()); ExtractContextualSourceUpdate(data, extracted); EXPECT_EQ(subtitle, l10n_util::GetStringFUTF16(IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE, l10n_util::GetStringUTF16(device_type))); + EXPECT_EQ(extension_reporting_title, + l10n_util::GetStringUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED)); + EXPECT_EQ(management_account_overview, base::string16()); + EXPECT_EQ(management_account_overview_data_notice, base::string16()); + EXPECT_EQ(management_account_overview_setup_notice, base::string16()); + EXPECT_EQ(management_device_overview, base::string16()); + EXPECT_EQ(management_device_overview_data_notice, base::string16()); + EXPECT_EQ(management_device_overview_setup_notice, base::string16()); + EXPECT_EQ(management_overview, + l10n_util::GetStringUTF16(IDS_MANAGEMENT_DEVICE_NOT_MANAGED)); EXPECT_FALSE(managed); } #endif
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc index 5ab0801..4c3a8dd 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
@@ -926,8 +926,7 @@ #endif void PrintPreviewHandler::GetNumberFormatAndMeasurementSystem( - base::DictionaryValue* settings) { - + base::Value* settings) { // Getting the measurement system based on the locale. UErrorCode errorCode = U_ZERO_ERROR; const char* locale = g_browser_process->GetApplicationLocale().c_str(); @@ -941,9 +940,9 @@ // Getting the number formatting based on the locale and writing to // dictionary. base::string16 number_format = base::FormatDouble(123456.78, 2); - settings->SetString(kDecimalDelimeter, number_format.substr(7, 1)); - settings->SetString(kThousandsDelimeter, number_format.substr(3, 1)); - settings->SetInteger(kUnitType, system); + settings->SetStringKey(kDecimalDelimeter, number_format.substr(7, 1)); + settings->SetStringKey(kThousandsDelimeter, number_format.substr(3, 1)); + settings->SetIntKey(kUnitType, system); } void PrintPreviewHandler::HandleGetInitialSettings( @@ -962,22 +961,22 @@ void PrintPreviewHandler::SendInitialSettings( const std::string& callback_id, const std::string& default_printer) { - base::DictionaryValue initial_settings; - initial_settings.SetString(kDocumentTitle, - print_preview_ui()->initiator_title()); - initial_settings.SetBoolean(kSettingPreviewModifiable, + base::Value initial_settings(base::Value::Type::DICTIONARY); + initial_settings.SetStringKey(kDocumentTitle, + print_preview_ui()->initiator_title()); + initial_settings.SetBoolKey(kSettingPreviewModifiable, print_preview_ui()->source_is_modifiable()); - initial_settings.SetString(kSettingPrinterName, default_printer); - initial_settings.SetBoolean(kDocumentHasSelection, + initial_settings.SetStringKey(kSettingPrinterName, default_printer); + initial_settings.SetBoolKey(kDocumentHasSelection, print_preview_ui()->source_has_selection()); - initial_settings.SetBoolean(kSettingShouldPrintSelectionOnly, + initial_settings.SetBoolKey(kSettingShouldPrintSelectionOnly, print_preview_ui()->print_selection_only()); PrefService* prefs = GetPrefs(); StickySettings* sticky_settings = GetStickySettings(); sticky_settings->RestoreFromPrefs(prefs); if (sticky_settings->printer_app_state()) { - initial_settings.SetString(kAppState, - *sticky_settings->printer_app_state()); + initial_settings.SetStringKey(kAppState, + *sticky_settings->printer_app_state()); } else { initial_settings.SetKey(kAppState, base::Value()); } @@ -985,29 +984,29 @@ if (prefs->HasPrefPath(prefs::kPrintHeaderFooter)) { // Don't override sticky settings, unless kPrintHeaderFooter is actually // customized. - initial_settings.SetBoolean(kHeaderFooter, + initial_settings.SetBoolKey(kHeaderFooter, prefs->GetBoolean(prefs::kPrintHeaderFooter)); } if (prefs->GetBoolean(prefs::kCloudPrintSubmitEnabled) && !base::FeatureList::IsEnabled(features::kCloudPrinterHandler)) { - initial_settings.SetString(kCloudPrintURL, - GURL(cloud_devices::GetCloudPrintURL()).spec()); + initial_settings.SetStringKey( + kCloudPrintURL, GURL(cloud_devices::GetCloudPrintURL()).spec()); } - initial_settings.SetBoolean( + initial_settings.SetBoolKey( kIsHeaderFooterManaged, prefs->IsManagedPreference(prefs::kPrintHeaderFooter)); base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); - initial_settings.SetBoolean(kIsInKioskAutoPrintMode, + initial_settings.SetBoolKey(kIsInKioskAutoPrintMode, cmdline->HasSwitch(switches::kKioskModePrinting)); - initial_settings.SetBoolean(kIsInAppKioskMode, + initial_settings.SetBoolKey(kIsInAppKioskMode, chrome::IsRunningInForcedAppMode()); const std::string rules_str = prefs->GetString(prefs::kPrintPreviewDefaultDestinationSelectionRules); if (rules_str.empty()) { initial_settings.SetKey(kDefaultDestinationSelectionRules, base::Value()); } else { - initial_settings.SetString(kDefaultDestinationSelectionRules, rules_str); + initial_settings.SetStringKey(kDefaultDestinationSelectionRules, rules_str); } GetNumberFormatAndMeasurementSystem(&initial_settings);
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.h b/chrome/browser/ui/webui/print_preview/print_preview_handler.h index 90d25d37..8467e7b 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler.h +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.h
@@ -277,7 +277,7 @@ void ClearInitiatorDetails(); // Populates |settings| according to the current locale. - void GetNumberFormatAndMeasurementSystem(base::DictionaryValue* settings); + void GetNumberFormatAndMeasurementSystem(base::Value* settings); PdfPrinterHandler* GetPdfPrinterHandler();
diff --git a/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc b/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc index 16bed878..79d5c9c 100644 --- a/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc +++ b/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc
@@ -15,9 +15,9 @@ #include "base/strings/utf_string_conversions.h" #include "base/values.h" #include "base/win/registry.h" -#include "chrome/browser/conflicts/incompatible_applications_updater_win.h" -#include "chrome/browser/conflicts/registry_key_watcher_win.h" -#include "chrome/browser/conflicts/uninstall_application_win.h" +#include "chrome/browser/win/conflicts/incompatible_applications_updater.h" +#include "chrome/browser/win/conflicts/registry_key_watcher.h" +#include "chrome/browser/win/conflicts/uninstall_application.h" #include "chrome/grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h"
diff --git a/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.h b/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.h index 114fdb9..630c2f9f 100644 --- a/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.h +++ b/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.h
@@ -9,8 +9,8 @@ #include <memory> #include "base/macros.h" -#include "chrome/browser/conflicts/installed_applications_win.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" +#include "chrome/browser/win/conflicts/installed_applications.h" class RegistryKeyWatcher;
diff --git a/chrome/browser/ui/webui/settings/settings_ui.cc b/chrome/browser/ui/webui/settings/settings_ui.cc index a874eca..fbee7b1 100644 --- a/chrome/browser/ui/webui/settings/settings_ui.cc +++ b/chrome/browser/ui/webui/settings/settings_ui.cc
@@ -64,9 +64,9 @@ #include "chrome/browser/safe_browsing/chrome_cleaner/srt_field_trial_win.h" #include "chrome/browser/ui/webui/settings/chrome_cleanup_handler.h" #if defined(GOOGLE_CHROME_BUILD) -#include "chrome/browser/conflicts/incompatible_applications_updater_win.h" -#include "chrome/browser/conflicts/token_util_win.h" #include "chrome/browser/ui/webui/settings/incompatible_applications_handler_win.h" +#include "chrome/browser/win/conflicts/incompatible_applications_updater.h" +#include "chrome/browser/win/conflicts/token_util.h" #endif #endif // defined(OS_WIN)
diff --git a/chrome/browser/conflicts/BUILD.gn b/chrome/browser/win/conflicts/BUILD.gn similarity index 67% rename from chrome/browser/conflicts/BUILD.gn rename to chrome/browser/win/conflicts/BUILD.gn index 4d3659f..36ea28c 100644 --- a/chrome/browser/conflicts/BUILD.gn +++ b/chrome/browser/win/conflicts/BUILD.gn
@@ -18,10 +18,10 @@ source_set("module_info") { sources = [ - "module_info_util_win.cc", - "module_info_util_win.h", - "module_info_win.cc", - "module_info_win.h", + "module_info.cc", + "module_info.h", + "module_info_util.cc", + "module_info_util.h", ] public_deps = [ @@ -45,14 +45,14 @@ source_set("unit_tests") { testonly = true sources = [ - "enumerate_input_method_editors_win_unittest.cc", - "enumerate_shell_extensions_win_unittest.cc", - "inspection_results_cache_win_unittest.cc", - "module_database_win_unittest.cc", - "module_event_sink_impl_win_unittest.cc", - "module_info_util_win_unittest.cc", - "module_info_win_unittest.cc", - "module_inspector_win_unittest.cc", + "enumerate_input_method_editors_unittest.cc", + "enumerate_shell_extensions_unittest.cc", + "inspection_results_cache_unittest.cc", + "module_database_unittest.cc", + "module_event_sink_impl_unittest.cc", + "module_info_unittest.cc", + "module_info_util_unittest.cc", + "module_inspector_unittest.cc", ] deps = [ @@ -68,14 +68,14 @@ if (is_chrome_branded) { sources += [ - "incompatible_applications_updater_win_unittest.cc", - "installed_applications_win_unittest.cc", - "module_blacklist_cache_updater_win_unittest.cc", - "module_blacklist_cache_util_win_unittest.cc", - "module_list_filter_win_unittest.cc", - "module_load_attempt_log_listener_win_unittest.cc", - "registry_key_watcher_win_unittest.cc", - "third_party_conflicts_manager_win_unittest.cc", + "incompatible_applications_updater_unittest.cc", + "installed_applications_unittest.cc", + "module_blacklist_cache_updater_unittest.cc", + "module_blacklist_cache_util_unittest.cc", + "module_list_filter_unittest.cc", + "module_load_attempt_log_listener_unittest.cc", + "registry_key_watcher_unittest.cc", + "third_party_conflicts_manager_unittest.cc", ] deps += [
diff --git a/chrome/browser/conflicts/DEPS b/chrome/browser/win/conflicts/DEPS similarity index 100% rename from chrome/browser/conflicts/DEPS rename to chrome/browser/win/conflicts/DEPS
diff --git a/chrome/browser/conflicts/OWNERS b/chrome/browser/win/conflicts/OWNERS similarity index 100% rename from chrome/browser/conflicts/OWNERS rename to chrome/browser/win/conflicts/OWNERS
diff --git a/chrome/browser/conflicts/README.md b/chrome/browser/win/conflicts/README.md similarity index 100% rename from chrome/browser/conflicts/README.md rename to chrome/browser/win/conflicts/README.md
diff --git a/chrome/browser/conflicts/enumerate_input_method_editors_win.cc b/chrome/browser/win/conflicts/enumerate_input_method_editors.cc similarity index 96% rename from chrome/browser/conflicts/enumerate_input_method_editors_win.cc rename to chrome/browser/win/conflicts/enumerate_input_method_editors.cc index 45883b6..d665cba 100644 --- a/chrome/browser/conflicts/enumerate_input_method_editors_win.cc +++ b/chrome/browser/win/conflicts/enumerate_input_method_editors.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/enumerate_input_method_editors_win.h" +#include "chrome/browser/win/conflicts/enumerate_input_method_editors.h" #include <algorithm> #include <iterator> @@ -19,7 +19,7 @@ #include "base/task/post_task.h" #include "base/threading/sequenced_task_runner_handle.h" #include "base/win/registry.h" -#include "chrome/browser/conflicts/module_info_util_win.h" +#include "chrome/browser/win/conflicts/module_info_util.h" namespace {
diff --git a/chrome/browser/conflicts/enumerate_input_method_editors_win.h b/chrome/browser/win/conflicts/enumerate_input_method_editors.h similarity index 79% rename from chrome/browser/conflicts/enumerate_input_method_editors_win.h rename to chrome/browser/win/conflicts/enumerate_input_method_editors.h index db1fdcc..0b2da83 100644 --- a/chrome/browser/conflicts/enumerate_input_method_editors_win.h +++ b/chrome/browser/win/conflicts/enumerate_input_method_editors.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_ENUMERATE_INPUT_METHOD_EDITORS_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_ENUMERATE_INPUT_METHOD_EDITORS_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_ENUMERATE_INPUT_METHOD_EDITORS_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_ENUMERATE_INPUT_METHOD_EDITORS_H_ #include <stdint.h> @@ -24,4 +24,4 @@ void EnumerateInputMethodEditors(OnImeEnumeratedCallback on_ime_enumerated, base::OnceClosure on_enumeration_finished); -#endif // CHROME_BROWSER_CONFLICTS_ENUMERATE_INPUT_METHOD_EDITORS_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_ENUMERATE_INPUT_METHOD_EDITORS_H_
diff --git a/chrome/browser/conflicts/enumerate_input_method_editors_win_unittest.cc b/chrome/browser/win/conflicts/enumerate_input_method_editors_unittest.cc similarity index 96% rename from chrome/browser/conflicts/enumerate_input_method_editors_win_unittest.cc rename to chrome/browser/win/conflicts/enumerate_input_method_editors_unittest.cc index 3ad64cd..3552532 100644 --- a/chrome/browser/conflicts/enumerate_input_method_editors_win_unittest.cc +++ b/chrome/browser/win/conflicts/enumerate_input_method_editors_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/enumerate_input_method_editors_win.h" +#include "chrome/browser/win/conflicts/enumerate_input_method_editors.h" #include <vector> @@ -13,7 +13,7 @@ #include "base/strings/stringprintf.h" #include "base/test/scoped_task_environment.h" #include "base/test/test_reg_util_win.h" -#include "chrome/browser/conflicts/module_info_util_win.h" +#include "chrome/browser/win/conflicts/module_info_util.h" #include "testing/gtest/include/gtest/gtest.h" namespace {
diff --git a/chrome/browser/conflicts/enumerate_shell_extensions_win.cc b/chrome/browser/win/conflicts/enumerate_shell_extensions.cc similarity index 96% rename from chrome/browser/conflicts/enumerate_shell_extensions_win.cc rename to chrome/browser/win/conflicts/enumerate_shell_extensions.cc index ed63111..3ce0a68 100644 --- a/chrome/browser/conflicts/enumerate_shell_extensions_win.cc +++ b/chrome/browser/win/conflicts/enumerate_shell_extensions.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/enumerate_shell_extensions_win.h" +#include "chrome/browser/win/conflicts/enumerate_shell_extensions.h" #include <utility> @@ -17,7 +17,7 @@ #include "base/threading/scoped_blocking_call.h" #include "base/threading/sequenced_task_runner_handle.h" #include "base/win/registry.h" -#include "chrome/browser/conflicts/module_info_util_win.h" +#include "chrome/browser/win/conflicts/module_info_util.h" // The following link explains how Shell extensions are registered on Windows. // Different types of handlers can be applied to different types of Shell @@ -129,7 +129,8 @@ void ReadCopyHookHandlers( const base::RepeatingCallback<void(const base::FilePath&)>& callback) { static constexpr const wchar_t* kSupportedShellObjects[] = { - kDirectory, kPrinters, + kDirectory, + kPrinters, }; for (const auto* shell_object : kSupportedShellObjects) @@ -140,7 +141,9 @@ void ReadDragDropHandlers( const base::RepeatingCallback<void(const base::FilePath&)>& callback) { static constexpr const wchar_t* kSupportedShellObjects[] = { - kDirectory, kDrive, kFolder, + kDirectory, + kDrive, + kFolder, }; for (const auto* shell_object : kSupportedShellObjects) @@ -152,7 +155,8 @@ void ReadContextMenuAndPropertySheetHandlers( const base::RepeatingCallback<void(const base::FilePath&)>& callback) { static constexpr const wchar_t* kHandlerTypes[] = { - L"ContextMenuHandlers", L"PropertySheetHandlers", + L"ContextMenuHandlers", + L"PropertySheetHandlers", }; // This list is not exhaustive and does not cover cases where a shell
diff --git a/chrome/browser/conflicts/enumerate_shell_extensions_win.h b/chrome/browser/win/conflicts/enumerate_shell_extensions.h similarity index 85% rename from chrome/browser/conflicts/enumerate_shell_extensions_win.h rename to chrome/browser/win/conflicts/enumerate_shell_extensions.h index 85de7ef..b7439a0 100644 --- a/chrome/browser/conflicts/enumerate_shell_extensions_win.h +++ b/chrome/browser/win/conflicts/enumerate_shell_extensions.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_ENUMERATE_SHELL_EXTENSIONS_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_ENUMERATE_SHELL_EXTENSIONS_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_ENUMERATE_SHELL_EXTENSIONS_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_ENUMERATE_SHELL_EXTENSIONS_H_ #include <stdint.h> @@ -35,4 +35,4 @@ } // namespace internal -#endif // CHROME_BROWSER_CONFLICTS_ENUMERATE_SHELL_EXTENSIONS_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_ENUMERATE_SHELL_EXTENSIONS_H_
diff --git a/chrome/browser/conflicts/enumerate_shell_extensions_win_unittest.cc b/chrome/browser/win/conflicts/enumerate_shell_extensions_unittest.cc similarity index 97% rename from chrome/browser/conflicts/enumerate_shell_extensions_win_unittest.cc rename to chrome/browser/win/conflicts/enumerate_shell_extensions_unittest.cc index 083c749..18c8c998 100644 --- a/chrome/browser/conflicts/enumerate_shell_extensions_win_unittest.cc +++ b/chrome/browser/win/conflicts/enumerate_shell_extensions_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/enumerate_shell_extensions_win.h" +#include "chrome/browser/win/conflicts/enumerate_shell_extensions.h" #include <vector> @@ -13,7 +13,7 @@ #include "base/strings/stringprintf.h" #include "base/test/scoped_task_environment.h" #include "base/test/test_reg_util_win.h" -#include "chrome/browser/conflicts/module_info_util_win.h" +#include "chrome/browser/win/conflicts/module_info_util.h" #include "testing/gtest/include/gtest/gtest.h" namespace {
diff --git a/chrome/browser/conflicts/incompatible_applications_browsertest.cc b/chrome/browser/win/conflicts/incompatible_applications_browsertest.cc similarity index 96% rename from chrome/browser/conflicts/incompatible_applications_browsertest.cc rename to chrome/browser/win/conflicts/incompatible_applications_browsertest.cc index 48a773eb..d9adf51 100644 --- a/chrome/browser/conflicts/incompatible_applications_browsertest.cc +++ b/chrome/browser/win/conflicts/incompatible_applications_browsertest.cc
@@ -18,10 +18,10 @@ #include "base/win/win_util.h" #include "base/win/windows_version.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/conflicts/incompatible_applications_updater_win.h" -#include "chrome/browser/conflicts/module_database_win.h" -#include "chrome/browser/conflicts/proto/module_list.pb.h" -#include "chrome/browser/conflicts/third_party_conflicts_manager_win.h" +#include "chrome/browser/win/conflicts/incompatible_applications_updater.h" +#include "chrome/browser/win/conflicts/module_database.h" +#include "chrome/browser/win/conflicts/proto/module_list.pb.h" +#include "chrome/browser/win/conflicts/third_party_conflicts_manager.h" #include "chrome/common/chrome_features.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/in_process_browser_test.h"
diff --git a/chrome/browser/conflicts/incompatible_applications_updater_win.cc b/chrome/browser/win/conflicts/incompatible_applications_updater.cc similarity index 97% rename from chrome/browser/conflicts/incompatible_applications_updater_win.cc rename to chrome/browser/win/conflicts/incompatible_applications_updater.cc index cab4e519e..2ec157e 100644 --- a/chrome/browser/conflicts/incompatible_applications_updater_win.cc +++ b/chrome/browser/win/conflicts/incompatible_applications_updater.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/incompatible_applications_updater_win.h" +#include "chrome/browser/win/conflicts/incompatible_applications_updater.h" #include <string> #include <utility> @@ -18,11 +18,11 @@ #include "base/win/registry.h" #include "base/win/windows_version.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/conflicts/module_database_win.h" -#include "chrome/browser/conflicts/module_info_util_win.h" -#include "chrome/browser/conflicts/module_info_win.h" -#include "chrome/browser/conflicts/module_list_filter_win.h" -#include "chrome/browser/conflicts/third_party_metrics_recorder_win.h" +#include "chrome/browser/win/conflicts/module_database.h" +#include "chrome/browser/win/conflicts/module_info.h" +#include "chrome/browser/win/conflicts/module_info_util.h" +#include "chrome/browser/win/conflicts/module_list_filter.h" +#include "chrome/browser/win/conflicts/third_party_metrics_recorder.h" #include "chrome/common/chrome_features.h" #include "chrome/common/pref_names.h" #include "components/prefs/pref_registry_simple.h"
diff --git a/chrome/browser/conflicts/incompatible_applications_updater_win.h b/chrome/browser/win/conflicts/incompatible_applications_updater.h similarity index 92% rename from chrome/browser/conflicts/incompatible_applications_updater_win.h rename to chrome/browser/win/conflicts/incompatible_applications_updater.h index a6a5fb43..2894a9f 100644 --- a/chrome/browser/conflicts/incompatible_applications_updater_win.h +++ b/chrome/browser/win/conflicts/incompatible_applications_updater.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_INCOMPATIBLE_APPLICATIONS_UPDATER_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_INCOMPATIBLE_APPLICATIONS_UPDATER_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_INCOMPATIBLE_APPLICATIONS_UPDATER_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_INCOMPATIBLE_APPLICATIONS_UPDATER_H_ #include <memory> #include <vector> @@ -12,9 +12,9 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/sequence_checker.h" -#include "chrome/browser/conflicts/installed_applications_win.h" -#include "chrome/browser/conflicts/module_database_observer_win.h" -#include "chrome/browser/conflicts/proto/module_list.pb.h" +#include "chrome/browser/win/conflicts/installed_applications.h" +#include "chrome/browser/win/conflicts/module_database_observer.h" +#include "chrome/browser/win/conflicts/proto/module_list.pb.h" class ModuleListFilter; class PrefRegistrySimple; @@ -150,4 +150,4 @@ DISALLOW_COPY_AND_ASSIGN(IncompatibleApplicationsUpdater); }; -#endif // CHROME_BROWSER_CONFLICTS_INCOMPATIBLE_APPLICATIONS_UPDATER_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_INCOMPATIBLE_APPLICATIONS_UPDATER_H_
diff --git a/chrome/browser/conflicts/incompatible_applications_updater_win_unittest.cc b/chrome/browser/win/conflicts/incompatible_applications_updater_unittest.cc similarity index 98% rename from chrome/browser/conflicts/incompatible_applications_updater_win_unittest.cc rename to chrome/browser/win/conflicts/incompatible_applications_updater_unittest.cc index 158fbde..a1e3a57 100644 --- a/chrome/browser/conflicts/incompatible_applications_updater_win_unittest.cc +++ b/chrome/browser/win/conflicts/incompatible_applications_updater_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/incompatible_applications_updater_win.h" +#include "chrome/browser/win/conflicts/incompatible_applications_updater.h" #include <map> #include <string> @@ -15,8 +15,8 @@ #include "base/test/test_reg_util_win.h" #include "base/win/registry.h" #include "base/win/windows_version.h" -#include "chrome/browser/conflicts/module_info_win.h" -#include "chrome/browser/conflicts/module_list_filter_win.h" +#include "chrome/browser/win/conflicts/module_info.h" +#include "chrome/browser/win/conflicts/module_list_filter.h" #include "chrome/test/base/scoped_testing_local_state.h" #include "chrome/test/base/testing_browser_process.h" #include "content/public/common/process_type.h"
diff --git a/chrome/browser/conflicts/inspection_results_cache_win.cc b/chrome/browser/win/conflicts/inspection_results_cache.cc similarity index 98% rename from chrome/browser/conflicts/inspection_results_cache_win.cc rename to chrome/browser/win/conflicts/inspection_results_cache.cc index 10bd9de..739b0580 100644 --- a/chrome/browser/conflicts/inspection_results_cache_win.cc +++ b/chrome/browser/win/conflicts/inspection_results_cache.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/inspection_results_cache_win.h" +#include "chrome/browser/win/conflicts/inspection_results_cache.h" #include <algorithm> #include <string>
diff --git a/chrome/browser/conflicts/inspection_results_cache_win.h b/chrome/browser/win/conflicts/inspection_results_cache.h similarity index 91% rename from chrome/browser/conflicts/inspection_results_cache_win.h rename to chrome/browser/win/conflicts/inspection_results_cache.h index 170cf05..297491e 100644 --- a/chrome/browser/conflicts/inspection_results_cache_win.h +++ b/chrome/browser/win/conflicts/inspection_results_cache.h
@@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_INSPECTION_RESULTS_CACHE_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_INSPECTION_RESULTS_CACHE_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_INSPECTION_RESULTS_CACHE_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_INSPECTION_RESULTS_CACHE_H_ #include <map> #include <utility> #include "base/feature_list.h" #include "base/optional.h" -#include "chrome/browser/conflicts/module_info_win.h" +#include "chrome/browser/win/conflicts/module_info.h" namespace base { class FilePath; @@ -78,4 +78,4 @@ const base::FilePath& file_path, const InspectionResultsCache& inspection_results_cache); -#endif // CHROME_BROWSER_CONFLICTS_INSPECTION_RESULTS_CACHE_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_INSPECTION_RESULTS_CACHE_H_
diff --git a/chrome/browser/conflicts/inspection_results_cache_win_unittest.cc b/chrome/browser/win/conflicts/inspection_results_cache_unittest.cc similarity index 98% rename from chrome/browser/conflicts/inspection_results_cache_win_unittest.cc rename to chrome/browser/win/conflicts/inspection_results_cache_unittest.cc index d2afdd2..6f7ad63 100644 --- a/chrome/browser/conflicts/inspection_results_cache_win_unittest.cc +++ b/chrome/browser/win/conflicts/inspection_results_cache_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/inspection_results_cache_win.h" +#include "chrome/browser/win/conflicts/inspection_results_cache.h" #include <memory> #include <tuple>
diff --git a/chrome/browser/conflicts/installed_applications_win.cc b/chrome/browser/win/conflicts/installed_applications.cc similarity index 98% rename from chrome/browser/conflicts/installed_applications_win.cc rename to chrome/browser/win/conflicts/installed_applications.cc index d698b09b..032b23ba 100644 --- a/chrome/browser/conflicts/installed_applications_win.cc +++ b/chrome/browser/win/conflicts/installed_applications.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/installed_applications_win.h" +#include "chrome/browser/win/conflicts/installed_applications.h" #include <algorithm> @@ -13,7 +13,7 @@ #include "base/win/registry.h" #include "base/win/win_util.h" #include "base/win/windows_version.h" -#include "chrome/browser/conflicts/msi_util_win.h" +#include "chrome/browser/win/conflicts/msi_util.h" namespace {
diff --git a/chrome/browser/conflicts/installed_applications_win.h b/chrome/browser/win/conflicts/installed_applications.h similarity index 95% rename from chrome/browser/conflicts/installed_applications_win.h rename to chrome/browser/win/conflicts/installed_applications.h index 166c3176..98acf535 100644 --- a/chrome/browser/conflicts/installed_applications_win.h +++ b/chrome/browser/win/conflicts/installed_applications.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_INSTALLED_APPLICATIONS_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_INSTALLED_APPLICATIONS_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_INSTALLED_APPLICATIONS_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_INSTALLED_APPLICATIONS_H_ #include <memory> #include <utility> @@ -119,4 +119,4 @@ bool operator<(const InstalledApplications::ApplicationInfo& lhs, const InstalledApplications::ApplicationInfo& rhs); -#endif // CHROME_BROWSER_CONFLICTS_INSTALLED_APPLICATIONS_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_INSTALLED_APPLICATIONS_H_
diff --git a/chrome/browser/conflicts/installed_applications_win_unittest.cc b/chrome/browser/win/conflicts/installed_applications_unittest.cc similarity index 90% rename from chrome/browser/conflicts/installed_applications_win_unittest.cc rename to chrome/browser/win/conflicts/installed_applications_unittest.cc index b3f90aa..467543fc 100644 --- a/chrome/browser/conflicts/installed_applications_win_unittest.cc +++ b/chrome/browser/win/conflicts/installed_applications_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/installed_applications_win.h" +#include "chrome/browser/win/conflicts/installed_applications.h" #include <algorithm> #include <map> @@ -11,7 +11,7 @@ #include "base/strings/stringprintf.h" #include "base/test/test_reg_util_win.h" #include "base/win/registry.h" -#include "chrome/browser/conflicts/msi_util_win.h" +#include "chrome/browser/win/conflicts/msi_util.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -147,27 +147,41 @@ InstallLocationApplicationInfo kTestCases[] = { { { - L"Is SystemComponent", true, false, kValidDisplayName, + L"Is SystemComponent", + true, + false, + kValidDisplayName, kValidUninstallString, }, kInstallLocation, }, { { - L"Is Microsoft published", false, true, kValidDisplayName, + L"Is Microsoft published", + false, + true, + kValidDisplayName, kValidUninstallString, }, kInstallLocation, }, { { - L"Missing DisplayName", false, false, L"", kValidUninstallString, + L"Missing DisplayName", + false, + false, + L"", + kValidUninstallString, }, kInstallLocation, }, { { - L"Missing UninstallString", false, false, kValidDisplayName, L"", + L"Missing UninstallString", + false, + false, + kValidDisplayName, + L"", }, kInstallLocation, }, @@ -196,7 +210,10 @@ InstallLocationApplicationInfo kTestCase = { { - L"Completely valid", false, false, kValidDisplayName, + L"Completely valid", + false, + false, + kValidDisplayName, kValidUninstallString, }, kInstallLocation, @@ -234,7 +251,10 @@ MsiApplicationInfo kTestCase = { { - L"Completely valid", false, false, kValidDisplayName, + L"Completely valid", + false, + false, + kValidDisplayName, kValidUninstallString, }, { @@ -283,7 +303,10 @@ InstallLocationApplicationInfo kInstallLocationFakeApplication = { { - L"GUID1", false, false, kInstallLocationDisplayName, + L"GUID1", + false, + false, + kInstallLocationDisplayName, kValidUninstallString, }, kInstallLocation, @@ -291,7 +314,11 @@ MsiApplicationInfo kMsiFakeApplication = { { - L"GUID2", false, false, kMsiDisplayName, kValidUninstallString, + L"GUID2", + false, + false, + kMsiDisplayName, + kValidUninstallString, }, { kMsiComponent, @@ -327,13 +354,21 @@ InstallLocationApplicationInfo kFakeApplication1 = { { - L"GUID1", false, false, kDisplayName1, kValidUninstallString, + L"GUID1", + false, + false, + kDisplayName1, + kValidUninstallString, }, kInstallLocationParent, }; InstallLocationApplicationInfo kFakeApplication2 = { { - L"GUID2", false, false, kDisplayName2, kValidUninstallString, + L"GUID2", + false, + false, + kDisplayName2, + kValidUninstallString, }, kInstallLocationChild, };
diff --git a/chrome/browser/conflicts/module_blacklist_cache_updater_win.cc b/chrome/browser/win/conflicts/module_blacklist_cache_updater.cc similarity index 97% rename from chrome/browser/conflicts/module_blacklist_cache_updater_win.cc rename to chrome/browser/win/conflicts/module_blacklist_cache_updater.cc index 2332495..298a078d 100644 --- a/chrome/browser/conflicts/module_blacklist_cache_updater_win.cc +++ b/chrome/browser/win/conflicts/module_blacklist_cache_updater.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_blacklist_cache_updater_win.h" +#include "chrome/browser/win/conflicts/module_blacklist_cache_updater.h" #include <memory> #include <string> @@ -23,10 +23,10 @@ #include "base/time/time.h" #include "base/win/registry.h" #include "base/win/windows_version.h" -#include "chrome/browser/conflicts/module_blacklist_cache_util_win.h" -#include "chrome/browser/conflicts/module_database_win.h" -#include "chrome/browser/conflicts/module_info_util_win.h" -#include "chrome/browser/conflicts/module_list_filter_win.h" +#include "chrome/browser/win/conflicts/module_blacklist_cache_util.h" +#include "chrome/browser/win/conflicts/module_database.h" +#include "chrome/browser/win/conflicts/module_info_util.h" +#include "chrome/browser/win/conflicts/module_list_filter.h" #include "chrome/common/chrome_features.h" #include "chrome/common/chrome_paths.h" #include "chrome/install_static/install_util.h"
diff --git a/chrome/browser/conflicts/module_blacklist_cache_updater_win.h b/chrome/browser/win/conflicts/module_blacklist_cache_updater.h similarity index 95% rename from chrome/browser/conflicts/module_blacklist_cache_updater_win.h rename to chrome/browser/win/conflicts/module_blacklist_cache_updater.h index bf8a07c..f1a7fdf 100644 --- a/chrome/browser/conflicts/module_blacklist_cache_updater_win.h +++ b/chrome/browser/win/conflicts/module_blacklist_cache_updater.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_MODULE_BLACKLIST_CACHE_UPDATER_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_MODULE_BLACKLIST_CACHE_UPDATER_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_MODULE_BLACKLIST_CACHE_UPDATER_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_MODULE_BLACKLIST_CACHE_UPDATER_H_ #include <vector> @@ -15,8 +15,8 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" -#include "chrome/browser/conflicts/module_database_observer_win.h" -#include "chrome/browser/conflicts/proto/module_list.pb.h" +#include "chrome/browser/win/conflicts/module_database_observer.h" +#include "chrome/browser/win/conflicts/proto/module_list.pb.h" #include "chrome/chrome_elf/third_party_dlls/packed_list_format.h" class ModuleListFilter; @@ -250,4 +250,4 @@ DISALLOW_COPY_AND_ASSIGN(ModuleBlacklistCacheUpdater); }; -#endif // CHROME_BROWSER_CONFLICTS_MODULE_BLACKLIST_CACHE_UPDATER_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_MODULE_BLACKLIST_CACHE_UPDATER_H_
diff --git a/chrome/browser/conflicts/module_blacklist_cache_updater_win_unittest.cc b/chrome/browser/win/conflicts/module_blacklist_cache_updater_unittest.cc similarity index 97% rename from chrome/browser/conflicts/module_blacklist_cache_updater_win_unittest.cc rename to chrome/browser/win/conflicts/module_blacklist_cache_updater_unittest.cc index c46ebe9..29c459b 100644 --- a/chrome/browser/conflicts/module_blacklist_cache_updater_win_unittest.cc +++ b/chrome/browser/win/conflicts/module_blacklist_cache_updater_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_blacklist_cache_updater_win.h" +#include "chrome/browser/win/conflicts/module_blacklist_cache_updater.h" #include <windows.h> @@ -27,9 +27,9 @@ #include "base/test/test_reg_util_win.h" #include "base/win/pe_image.h" #include "base/win/registry.h" -#include "chrome/browser/conflicts/module_blacklist_cache_util_win.h" -#include "chrome/browser/conflicts/module_info_win.h" -#include "chrome/browser/conflicts/module_list_filter_win.h" +#include "chrome/browser/win/conflicts/module_blacklist_cache_util.h" +#include "chrome/browser/win/conflicts/module_info.h" +#include "chrome/browser/win/conflicts/module_list_filter.h" #include "chrome/common/chrome_paths.h" #include "chrome/install_static/install_util.h" #include "content/public/common/process_type.h"
diff --git a/chrome/browser/conflicts/module_blacklist_cache_util_win.cc b/chrome/browser/win/conflicts/module_blacklist_cache_util.cc similarity index 98% rename from chrome/browser/conflicts/module_blacklist_cache_util_win.cc rename to chrome/browser/win/conflicts/module_blacklist_cache_util.cc index 08c2165..69a972c5 100644 --- a/chrome/browser/conflicts/module_blacklist_cache_util_win.cc +++ b/chrome/browser/win/conflicts/module_blacklist_cache_util.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_blacklist_cache_util_win.h" +#include "chrome/browser/win/conflicts/module_blacklist_cache_util.h" #include <algorithm> #include <functional> @@ -20,7 +20,7 @@ #include "base/logging.h" #include "base/stl_util.h" #include "base/time/time.h" -#include "chrome/browser/conflicts/module_list_filter_win.h" +#include "chrome/browser/win/conflicts/module_list_filter.h" #include "chrome/chrome_elf/third_party_dlls/packed_list_format.h" namespace {
diff --git a/chrome/browser/conflicts/module_blacklist_cache_util_win.h b/chrome/browser/win/conflicts/module_blacklist_cache_util.h similarity index 96% rename from chrome/browser/conflicts/module_blacklist_cache_util_win.h rename to chrome/browser/win/conflicts/module_blacklist_cache_util.h index 6a4a9e1..8d59fd58 100644 --- a/chrome/browser/conflicts/module_blacklist_cache_util_win.h +++ b/chrome/browser/win/conflicts/module_blacklist_cache_util.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_MODULE_BLACKLIST_CACHE_UTIL_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_MODULE_BLACKLIST_CACHE_UTIL_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_MODULE_BLACKLIST_CACHE_UTIL_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_MODULE_BLACKLIST_CACHE_UTIL_H_ #include <stddef.h> #include <stdint.h> @@ -160,4 +160,4 @@ } // namespace internal -#endif // CHROME_BROWSER_CONFLICTS_MODULE_BLACKLIST_CACHE_UTIL_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_MODULE_BLACKLIST_CACHE_UTIL_H_
diff --git a/chrome/browser/conflicts/module_blacklist_cache_util_win_unittest.cc b/chrome/browser/win/conflicts/module_blacklist_cache_util_unittest.cc similarity index 92% rename from chrome/browser/conflicts/module_blacklist_cache_util_win_unittest.cc rename to chrome/browser/win/conflicts/module_blacklist_cache_util_unittest.cc index fd38330..76c1d191 100644 --- a/chrome/browser/conflicts/module_blacklist_cache_util_win_unittest.cc +++ b/chrome/browser/win/conflicts/module_blacklist_cache_util_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_blacklist_cache_util_win.h" +#include "chrome/browser/win/conflicts/module_blacklist_cache_util.h" #include <algorithm> #include <memory> @@ -18,7 +18,7 @@ #include "base/macros.h" #include "base/stl_util.h" #include "base/time/time.h" -#include "chrome/browser/conflicts/module_list_filter_win.h" +#include "chrome/browser/win/conflicts/module_list_filter.h" #include "chrome/chrome_elf/sha1/sha1.h" #include "chrome/chrome_elf/third_party_dlls/packed_list_format.h" #include "testing/gtest/include/gtest/gtest.h" @@ -226,11 +226,12 @@ // Mark a few modules as whitelisted. std::vector<third_party_dlls::PackedListModule> whitelisted_modules; - SampleBlacklistedModules(kWhitelistedModulesCount, - [&whitelisted_modules](const auto& element) { - whitelisted_modules.push_back(element); - }, - &blacklisted_modules); + SampleBlacklistedModules( + kWhitelistedModulesCount, + [&whitelisted_modules](const auto& element) { + whitelisted_modules.push_back(element); + }, + &blacklisted_modules); auto module_list_filter = base::MakeRefCounted<FakeModuleListFilter>(); for (const auto& module : whitelisted_modules) module_list_filter->AddWhitelistedModule(module); @@ -261,11 +262,12 @@ // (which is [5u, 10u]). const uint32_t kNewTimeDateStamp = 15u; std::vector<third_party_dlls::PackedListModule> updated_modules; - SampleBlacklistedModules(kModulesToRemove, - [&updated_modules](const auto& element) { - updated_modules.push_back(element); - }, - &blacklisted_modules); + SampleBlacklistedModules( + kModulesToRemove, + [&updated_modules](const auto& element) { + updated_modules.push_back(element); + }, + &blacklisted_modules); for (auto& module : updated_modules) module.time_date_stamp = kNewTimeDateStamp; @@ -295,12 +297,13 @@ // Set the time date stamp of 5 modules to an expired value. const uint32_t kExpiredTimeDateStamp = 1u; std::vector<third_party_dlls::PackedListModule> expired_modules; - SampleBlacklistedModules(kModulesToRemove, - [&expired_modules](auto& element) { - expired_modules.push_back(element); - element.time_date_stamp = kExpiredTimeDateStamp; - }, - &blacklisted_modules); + SampleBlacklistedModules( + kModulesToRemove, + [&expired_modules](auto& element) { + expired_modules.push_back(element); + element.time_date_stamp = kExpiredTimeDateStamp; + }, + &blacklisted_modules); std::sort(blacklisted_modules.begin(), blacklisted_modules.end(), internal::ModuleTimeDateStampGreater()); @@ -422,11 +425,12 @@ // Create kDuplicateCount duplicate modules and set their time_date_stamp to a // greater value so that the duplicate is kept instead of the original. std::vector<third_party_dlls::PackedListModule> duplicated_modules; - SampleBlacklistedModules(kDuplicateCount, - [&duplicated_modules](auto& element) { - duplicated_modules.push_back(element); - }, - &blacklisted_modules); + SampleBlacklistedModules( + kDuplicateCount, + [&duplicated_modules](auto& element) { + duplicated_modules.push_back(element); + }, + &blacklisted_modules); for (auto& module : duplicated_modules) module.time_date_stamp += 10u;
diff --git a/chrome/browser/conflicts/module_database_win.cc b/chrome/browser/win/conflicts/module_database.cc similarity index 97% rename from chrome/browser/conflicts/module_database_win.cc rename to chrome/browser/win/conflicts/module_database.cc index 95bc78f7..7d7dee7 100644 --- a/chrome/browser/conflicts/module_database_win.cc +++ b/chrome/browser/win/conflicts/module_database.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_database_win.h" +#include "chrome/browser/win/conflicts/module_database.h" #include <tuple> #include <utility> @@ -13,16 +13,16 @@ #include "base/sequenced_task_runner.h" #include "base/task/lazy_task_runner.h" #include "base/task/post_task.h" -#include "chrome/browser/conflicts/module_database_observer_win.h" +#include "chrome/browser/win/conflicts/module_database_observer.h" #include "content/public/browser/browser_task_traits.h" #if defined(GOOGLE_CHROME_BUILD) #include "base/enterprise_util.h" #include "base/feature_list.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/conflicts/incompatible_applications_updater_win.h" -#include "chrome/browser/conflicts/module_load_attempt_log_listener_win.h" -#include "chrome/browser/conflicts/third_party_conflicts_manager_win.h" +#include "chrome/browser/win/conflicts/incompatible_applications_updater.h" +#include "chrome/browser/win/conflicts/module_load_attempt_log_listener.h" +#include "chrome/browser/win/conflicts/third_party_conflicts_manager.h" #include "chrome/chrome_elf/third_party_dlls/public_api.h" #include "chrome/common/chrome_features.h" #include "chrome/common/pref_names.h"
diff --git a/chrome/browser/conflicts/module_database_win.h b/chrome/browser/win/conflicts/module_database.h similarity index 96% rename from chrome/browser/conflicts/module_database_win.h rename to chrome/browser/win/conflicts/module_database.h index a81bc9e..236fe8ae 100644 --- a/chrome/browser/conflicts/module_database_win.h +++ b/chrome/browser/win/conflicts/module_database.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_MODULE_DATABASE_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_MODULE_DATABASE_H_ #include <map> #include <memory> @@ -13,9 +13,9 @@ #include "base/sequence_checker.h" #include "base/time/time.h" #include "base/timer/timer.h" -#include "chrome/browser/conflicts/module_info_win.h" -#include "chrome/browser/conflicts/module_inspector_win.h" -#include "chrome/browser/conflicts/third_party_metrics_recorder_win.h" +#include "chrome/browser/win/conflicts/module_info.h" +#include "chrome/browser/win/conflicts/module_inspector.h" +#include "chrome/browser/win/conflicts/third_party_metrics_recorder.h" #include "content/public/common/process_type.h" #include "services/service_manager/public/cpp/connector.h" @@ -284,4 +284,4 @@ DISALLOW_COPY_AND_ASSIGN(ModuleDatabase); }; -#endif // CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_MODULE_DATABASE_H_
diff --git a/chrome/browser/conflicts/module_database_observer_win.h b/chrome/browser/win/conflicts/module_database_observer.h similarity index 87% rename from chrome/browser/conflicts/module_database_observer_win.h rename to chrome/browser/win/conflicts/module_database_observer.h index cadd1a7..879dea3 100644 --- a/chrome/browser/conflicts/module_database_observer_win.h +++ b/chrome/browser/win/conflicts/module_database_observer.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_OBSERVER_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_OBSERVER_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_MODULE_DATABASE_OBSERVER_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_MODULE_DATABASE_OBSERVER_H_ struct ModuleInfoKey; struct ModuleInfoData; @@ -39,4 +39,4 @@ virtual ~ModuleDatabaseEventSource() = default; }; -#endif // CHROME_BROWSER_CONFLICTS_MODULE_DATABASE_OBSERVER_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_MODULE_DATABASE_OBSERVER_H_
diff --git a/chrome/browser/conflicts/module_database_win_unittest.cc b/chrome/browser/win/conflicts/module_database_unittest.cc similarity index 97% rename from chrome/browser/conflicts/module_database_win_unittest.cc rename to chrome/browser/win/conflicts/module_database_unittest.cc index 574cce2..c037b40a 100644 --- a/chrome/browser/conflicts/module_database_win_unittest.cc +++ b/chrome/browser/win/conflicts/module_database_unittest.cc
@@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_database_win.h" +#include "chrome/browser/win/conflicts/module_database.h" #include <memory> #include "base/bind.h" #include "base/task/post_task.h" #include "base/time/time.h" -#include "chrome/browser/conflicts/module_database_observer_win.h" -#include "chrome/browser/conflicts/module_info_win.h" +#include "chrome/browser/win/conflicts/module_database_observer.h" +#include "chrome/browser/win/conflicts/module_info.h" #include "chrome/test/base/scoped_testing_local_state.h" #include "chrome/test/base/testing_browser_process.h" #include "content/public/test/test_browser_thread_bundle.h"
diff --git a/chrome/browser/conflicts/module_event_sink_impl_win.cc b/chrome/browser/win/conflicts/module_event_sink_impl.cc similarity index 97% rename from chrome/browser/conflicts/module_event_sink_impl_win.cc rename to chrome/browser/win/conflicts/module_event_sink_impl.cc index 22d630b..bb34168 100644 --- a/chrome/browser/conflicts/module_event_sink_impl_win.cc +++ b/chrome/browser/win/conflicts/module_event_sink_impl.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_event_sink_impl_win.h" +#include "chrome/browser/win/conflicts/module_event_sink_impl.h" #include <windows.h> @@ -19,7 +19,7 @@ #include "base/strings/string_piece.h" #include "base/task/post_task.h" #include "base/threading/sequenced_task_runner_handle.h" -#include "chrome/browser/conflicts/module_database_win.h" +#include "chrome/browser/win/conflicts/module_database.h" #include "content/public/browser/browser_thread.h" #include "mojo/public/cpp/bindings/strong_binding.h"
diff --git a/chrome/browser/conflicts/module_event_sink_impl_win.h b/chrome/browser/win/conflicts/module_event_sink_impl.h similarity index 92% rename from chrome/browser/conflicts/module_event_sink_impl_win.h rename to chrome/browser/win/conflicts/module_event_sink_impl.h index 785e3a78..712cef9 100644 --- a/chrome/browser/conflicts/module_event_sink_impl_win.h +++ b/chrome/browser/win/conflicts/module_event_sink_impl.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_MODULE_EVENT_SINK_IMPL_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_MODULE_EVENT_SINK_IMPL_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_MODULE_EVENT_SINK_IMPL_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_MODULE_EVENT_SINK_IMPL_H_ #include <stdint.h> @@ -71,4 +71,4 @@ DISALLOW_COPY_AND_ASSIGN(ModuleEventSinkImpl); }; -#endif // CHROME_BROWSER_CONFLICTS_MODULE_EVENT_SINK_IMPL_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_MODULE_EVENT_SINK_IMPL_H_
diff --git a/chrome/browser/conflicts/module_event_sink_impl_win_unittest.cc b/chrome/browser/win/conflicts/module_event_sink_impl_unittest.cc similarity index 97% rename from chrome/browser/conflicts/module_event_sink_impl_win_unittest.cc rename to chrome/browser/win/conflicts/module_event_sink_impl_unittest.cc index 9e1cf6b..3471818 100644 --- a/chrome/browser/conflicts/module_event_sink_impl_win_unittest.cc +++ b/chrome/browser/win/conflicts/module_event_sink_impl_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_event_sink_impl_win.h" +#include "chrome/browser/win/conflicts/module_event_sink_impl.h" #include <windows.h>
diff --git a/chrome/browser/conflicts/module_info_win.cc b/chrome/browser/win/conflicts/module_info.cc similarity index 98% rename from chrome/browser/conflicts/module_info_win.cc rename to chrome/browser/win/conflicts/module_info.cc index 1ddff6d..54a28bf 100644 --- a/chrome/browser/conflicts/module_info_win.cc +++ b/chrome/browser/win/conflicts/module_info.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_info_win.h" +#include "chrome/browser/win/conflicts/module_info.h" #include <windows.h>
diff --git a/chrome/browser/conflicts/module_info_win.h b/chrome/browser/win/conflicts/module_info.h similarity index 94% rename from chrome/browser/conflicts/module_info_win.h rename to chrome/browser/win/conflicts/module_info.h index a3c3213..4e6066a3 100644 --- a/chrome/browser/conflicts/module_info_win.h +++ b/chrome/browser/win/conflicts/module_info.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_MODULE_INFO_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_MODULE_INFO_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_MODULE_INFO_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_MODULE_INFO_H_ #include <string> @@ -11,7 +11,7 @@ #include "base/macros.h" #include "base/optional.h" #include "base/time/time.h" -#include "chrome/browser/conflicts/module_info_util_win.h" +#include "chrome/browser/win/conflicts/module_info_util.h" #include "content/public/common/process_type.h" // ModuleInfoKey and ModuleInfoData are used in pair by the ModuleDatabase to @@ -45,7 +45,7 @@ // // Note: Any modification to this structure should be reflected in // SerializeInspectionResult() and DeserializeInspectionResult() in -// chrome/browser/conflicts/inspection_results_cache_win.cc. +// chrome/browser/win/conflicts/inspection_results_cache.cc. struct ModuleInspectionResult { ModuleInspectionResult(); ModuleInspectionResult(const ModuleInspectionResult& other); @@ -150,4 +150,4 @@ } // namespace internal -#endif // CHROME_BROWSER_CONFLICTS_MODULE_INFO_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_MODULE_INFO_H_
diff --git a/chrome/browser/conflicts/module_info_win_unittest.cc b/chrome/browser/win/conflicts/module_info_unittest.cc similarity index 97% rename from chrome/browser/conflicts/module_info_win_unittest.cc rename to chrome/browser/win/conflicts/module_info_unittest.cc index d1215958..d7441a7 100644 --- a/chrome/browser/conflicts/module_info_win_unittest.cc +++ b/chrome/browser/win/conflicts/module_info_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_info_win.h" +#include "chrome/browser/win/conflicts/module_info.h" #include <memory> #include <string>
diff --git a/chrome/browser/conflicts/module_info_util_win.cc b/chrome/browser/win/conflicts/module_info_util.cc similarity index 98% rename from chrome/browser/conflicts/module_info_util_win.cc rename to chrome/browser/win/conflicts/module_info_util.cc index 45ac107..1d0a728 100644 --- a/chrome/browser/conflicts/module_info_util_win.cc +++ b/chrome/browser/win/conflicts/module_info_util.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_info_util_win.h" +#include "chrome/browser/win/conflicts/module_info_util.h" #include <windows.h>
diff --git a/chrome/browser/conflicts/module_info_util_win.h b/chrome/browser/win/conflicts/module_info_util.h similarity index 94% rename from chrome/browser/conflicts/module_info_util_win.h rename to chrome/browser/win/conflicts/module_info_util.h index 8bd90ea..84f5b5a 100644 --- a/chrome/browser/conflicts/module_info_util_win.h +++ b/chrome/browser/win/conflicts/module_info_util.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_MODULE_INFO_UTIL_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_MODULE_INFO_UTIL_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_MODULE_INFO_UTIL_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_MODULE_INFO_UTIL_H_ #include <utility> #include <vector> @@ -86,4 +86,4 @@ } // namespace internal -#endif // CHROME_BROWSER_CONFLICTS_MODULE_INFO_UTIL_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_MODULE_INFO_UTIL_H_
diff --git a/chrome/browser/conflicts/module_info_util_win_unittest.cc b/chrome/browser/win/conflicts/module_info_util_unittest.cc similarity index 97% rename from chrome/browser/conflicts/module_info_util_win_unittest.cc rename to chrome/browser/win/conflicts/module_info_util_unittest.cc index d5ebb45..e9c06e8 100644 --- a/chrome/browser/conflicts/module_info_util_win_unittest.cc +++ b/chrome/browser/win/conflicts/module_info_util_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_info_util_win.h" +#include "chrome/browser/win/conflicts/module_info_util.h" #include <windows.h> @@ -84,7 +84,8 @@ // The mapping for these variables will be retrieved. std::vector<base::string16> environment_variables = { - L"foo", L"SYSTEMROOT", + L"foo", + L"SYSTEMROOT", }; StringMapping string_mapping = GetEnvironmentVariablesMapping(environment_variables);
diff --git a/chrome/browser/conflicts/module_inspector_win.cc b/chrome/browser/win/conflicts/module_inspector.cc similarity index 97% rename from chrome/browser/conflicts/module_inspector_win.cc rename to chrome/browser/win/conflicts/module_inspector.cc index 68ff760..4b5e013 100644 --- a/chrome/browser/conflicts/module_inspector_win.cc +++ b/chrome/browser/win/conflicts/module_inspector.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_inspector_win.h" +#include "chrome/browser/win/conflicts/module_inspector.h" #include <utility> @@ -13,7 +13,7 @@ #include "base/task_runner_util.h" #include "base/threading/sequenced_task_runner_handle.h" #include "base/time/time.h" -#include "chrome/browser/conflicts/module_info_util_win.h" +#include "chrome/browser/win/conflicts/module_info_util.h" #include "chrome/common/chrome_paths.h" #include "chrome/services/util_win/public/mojom/constants.mojom.h" #include "content/public/browser/browser_thread.h" @@ -29,8 +29,14 @@ StringMapping GetPathMapping() { return GetEnvironmentVariablesMapping({ - L"LOCALAPPDATA", L"ProgramFiles", L"ProgramData", L"USERPROFILE", - L"SystemRoot", L"TEMP", L"TMP", L"CommonProgramFiles", + L"LOCALAPPDATA", + L"ProgramFiles", + L"ProgramData", + L"USERPROFILE", + L"SystemRoot", + L"TEMP", + L"TMP", + L"CommonProgramFiles", }); }
diff --git a/chrome/browser/conflicts/module_inspector_win.h b/chrome/browser/win/conflicts/module_inspector.h similarity index 94% rename from chrome/browser/conflicts/module_inspector_win.h rename to chrome/browser/win/conflicts/module_inspector.h index 1080ad9..c3d396ff 100644 --- a/chrome/browser/conflicts/module_inspector_win.h +++ b/chrome/browser/win/conflicts/module_inspector.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_MODULE_INSPECTOR_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_MODULE_INSPECTOR_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_MODULE_INSPECTOR_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_MODULE_INSPECTOR_H_ #include <map> #include <memory> @@ -17,9 +17,9 @@ #include "base/sequence_checker.h" #include "base/task/task_traits.h" #include "base/timer/timer.h" -#include "chrome/browser/conflicts/inspection_results_cache_win.h" -#include "chrome/browser/conflicts/module_database_observer_win.h" -#include "chrome/browser/conflicts/module_info_win.h" +#include "chrome/browser/win/conflicts/inspection_results_cache.h" +#include "chrome/browser/win/conflicts/module_database_observer.h" +#include "chrome/browser/win/conflicts/module_info.h" #include "chrome/services/util_win/public/mojom/util_win.mojom.h" namespace base { @@ -191,4 +191,4 @@ DISALLOW_COPY_AND_ASSIGN(ModuleInspector); }; -#endif // CHROME_BROWSER_CONFLICTS_MODULE_INSPECTOR_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_MODULE_INSPECTOR_H_
diff --git a/chrome/browser/conflicts/module_inspector_win_unittest.cc b/chrome/browser/win/conflicts/module_inspector_unittest.cc similarity index 98% rename from chrome/browser/conflicts/module_inspector_win_unittest.cc rename to chrome/browser/win/conflicts/module_inspector_unittest.cc index 0dec2938..5eb256b 100644 --- a/chrome/browser/conflicts/module_inspector_win_unittest.cc +++ b/chrome/browser/win/conflicts/module_inspector_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_inspector_win.h" +#include "chrome/browser/win/conflicts/module_inspector.h" #include <memory> #include <string>
diff --git a/chrome/browser/conflicts/module_list_component_updater_win.cc b/chrome/browser/win/conflicts/module_list_component_updater.cc similarity index 95% rename from chrome/browser/conflicts/module_list_component_updater_win.cc rename to chrome/browser/win/conflicts/module_list_component_updater.cc index 6f858839..7d88efb 100644 --- a/chrome/browser/conflicts/module_list_component_updater_win.cc +++ b/chrome/browser/win/conflicts/module_list_component_updater.cc
@@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_list_component_updater_win.h" +#include "chrome/browser/win/conflicts/module_list_component_updater.h" #include <utility> #include "base/task/post_task.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/conflicts/module_database_win.h" +#include "chrome/browser/win/conflicts/module_database.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h"
diff --git a/chrome/browser/conflicts/module_list_component_updater_win.h b/chrome/browser/win/conflicts/module_list_component_updater.h similarity index 90% rename from chrome/browser/conflicts/module_list_component_updater_win.h rename to chrome/browser/win/conflicts/module_list_component_updater.h index 8269cc79..968310a 100644 --- a/chrome/browser/conflicts/module_list_component_updater_win.h +++ b/chrome/browser/win/conflicts/module_list_component_updater.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_MODULE_LIST_COMPONENT_UPDATER_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_MODULE_LIST_COMPONENT_UPDATER_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_MODULE_LIST_COMPONENT_UPDATER_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_MODULE_LIST_COMPONENT_UPDATER_H_ #include <memory> #include <string> @@ -55,4 +55,4 @@ DISALLOW_COPY_AND_ASSIGN(ModuleListComponentUpdater); }; -#endif // CHROME_BROWSER_CONFLICTS_MODULE_LIST_COMPONENT_UPDATER_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_MODULE_LIST_COMPONENT_UPDATER_H_
diff --git a/chrome/browser/conflicts/module_list_filter_win.cc b/chrome/browser/win/conflicts/module_list_filter.cc similarity index 96% rename from chrome/browser/conflicts/module_list_filter_win.cc rename to chrome/browser/win/conflicts/module_list_filter.cc index 0de10c3..215f5771 100644 --- a/chrome/browser/conflicts/module_list_filter_win.cc +++ b/chrome/browser/win/conflicts/module_list_filter.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_list_filter_win.h" +#include "chrome/browser/win/conflicts/module_list_filter.h" #include <string> @@ -12,7 +12,7 @@ #include "base/i18n/case_conversion.h" #include "base/logging.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/conflicts/module_info_win.h" +#include "chrome/browser/win/conflicts/module_info.h" namespace {
diff --git a/chrome/browser/conflicts/module_list_filter_win.h b/chrome/browser/win/conflicts/module_list_filter.h similarity index 89% rename from chrome/browser/conflicts/module_list_filter_win.h rename to chrome/browser/win/conflicts/module_list_filter.h index bcde3941..28450f6 100644 --- a/chrome/browser/conflicts/module_list_filter_win.h +++ b/chrome/browser/win/conflicts/module_list_filter.h
@@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_MODULE_LIST_FILTER_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_MODULE_LIST_FILTER_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_MODULE_LIST_FILTER_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_MODULE_LIST_FILTER_H_ #include <memory> #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/strings/string_piece.h" -#include "chrome/browser/conflicts/proto/module_list.pb.h" +#include "chrome/browser/win/conflicts/proto/module_list.pb.h" struct ModuleInfoKey; struct ModuleInfoData; @@ -71,4 +71,4 @@ DISALLOW_COPY_AND_ASSIGN(ModuleListFilter); }; -#endif // CHROME_BROWSER_CONFLICTS_MODULE_LIST_FILTER_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_MODULE_LIST_FILTER_H_
diff --git a/chrome/browser/conflicts/module_list_filter_win_unittest.cc b/chrome/browser/win/conflicts/module_list_filter_unittest.cc similarity index 97% rename from chrome/browser/conflicts/module_list_filter_win_unittest.cc rename to chrome/browser/win/conflicts/module_list_filter_unittest.cc index 6706a87..d0d194a 100644 --- a/chrome/browser/conflicts/module_list_filter_win_unittest.cc +++ b/chrome/browser/win/conflicts/module_list_filter_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_list_filter_win.h" +#include "chrome/browser/win/conflicts/module_list_filter.h" #include <string> #include <utility> @@ -16,8 +16,8 @@ #include "base/strings/string16.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/conflicts/module_info_win.h" -#include "chrome/browser/conflicts/proto/module_list.pb.h" +#include "chrome/browser/win/conflicts/module_info.h" +#include "chrome/browser/win/conflicts/proto/module_list.pb.h" #include "testing/gtest/include/gtest/gtest.h" namespace {
diff --git a/chrome/browser/conflicts/module_load_attempt_log_listener_win.cc b/chrome/browser/win/conflicts/module_load_attempt_log_listener.cc similarity index 96% rename from chrome/browser/conflicts/module_load_attempt_log_listener_win.cc rename to chrome/browser/win/conflicts/module_load_attempt_log_listener.cc index cdb5291..1f6cb8d8 100644 --- a/chrome/browser/conflicts/module_load_attempt_log_listener_win.cc +++ b/chrome/browser/win/conflicts/module_load_attempt_log_listener.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_load_attempt_log_listener_win.h" +#include "chrome/browser/win/conflicts/module_load_attempt_log_listener.h" #include <algorithm> #include <memory> @@ -16,7 +16,7 @@ #include "base/strings/utf_string_conversions.h" #include "base/task/post_task.h" #include "base/task_runner_util.h" -#include "chrome/browser/conflicts/module_blacklist_cache_util_win.h" +#include "chrome/browser/win/conflicts/module_blacklist_cache_util.h" #include "chrome/chrome_elf/third_party_dlls/public_api.h" namespace {
diff --git a/chrome/browser/conflicts/module_load_attempt_log_listener_win.h b/chrome/browser/win/conflicts/module_load_attempt_log_listener.h similarity index 91% rename from chrome/browser/conflicts/module_load_attempt_log_listener_win.h rename to chrome/browser/win/conflicts/module_load_attempt_log_listener.h index 124b1de..1676fe3 100644 --- a/chrome/browser/conflicts/module_load_attempt_log_listener_win.h +++ b/chrome/browser/win/conflicts/module_load_attempt_log_listener.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_MODULE_LOAD_ATTEMPT_LOG_LISTENER_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_MODULE_LOAD_ATTEMPT_LOG_LISTENER_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_MODULE_LOAD_ATTEMPT_LOG_LISTENER_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_MODULE_LOAD_ATTEMPT_LOG_LISTENER_H_ #include <tuple> #include <utility> @@ -76,4 +76,4 @@ DISALLOW_COPY_AND_ASSIGN(ModuleLoadAttemptLogListener); }; -#endif // CHROME_BROWSER_CONFLICTS_MODULE_LOAD_ATTEMPT_LOG_LISTENER_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_MODULE_LOAD_ATTEMPT_LOG_LISTENER_H_
diff --git a/chrome/browser/conflicts/module_load_attempt_log_listener_win_unittest.cc b/chrome/browser/win/conflicts/module_load_attempt_log_listener_unittest.cc similarity index 96% rename from chrome/browser/conflicts/module_load_attempt_log_listener_win_unittest.cc rename to chrome/browser/win/conflicts/module_load_attempt_log_listener_unittest.cc index dc0a6b9..58a74e2 100644 --- a/chrome/browser/conflicts/module_load_attempt_log_listener_win_unittest.cc +++ b/chrome/browser/win/conflicts/module_load_attempt_log_listener_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/module_load_attempt_log_listener_win.h" +#include "chrome/browser/win/conflicts/module_load_attempt_log_listener.h" #include <memory> #include <tuple>
diff --git a/chrome/browser/conflicts/msi_util_win.cc b/chrome/browser/win/conflicts/msi_util.cc similarity index 98% rename from chrome/browser/conflicts/msi_util_win.cc rename to chrome/browser/win/conflicts/msi_util.cc index f5b8a2b6..5523ea9 100644 --- a/chrome/browser/conflicts/msi_util_win.cc +++ b/chrome/browser/win/conflicts/msi_util.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/msi_util_win.h" +#include "chrome/browser/win/conflicts/msi_util.h" #include <windows.h>
diff --git a/chrome/browser/conflicts/msi_util_win.h b/chrome/browser/win/conflicts/msi_util.h similarity index 85% rename from chrome/browser/conflicts/msi_util_win.h rename to chrome/browser/win/conflicts/msi_util.h index d1ed1bf..e31e551 100644 --- a/chrome/browser/conflicts/msi_util_win.h +++ b/chrome/browser/win/conflicts/msi_util.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_MSI_UTIL_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_MSI_UTIL_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_MSI_UTIL_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_MSI_UTIL_H_ #include <vector> @@ -29,4 +29,4 @@ std::vector<base::string16>* component_paths) const; }; -#endif // CHROME_BROWSER_CONFLICTS_MSI_UTIL_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_MSI_UTIL_H_
diff --git a/chrome/browser/conflicts/proto/module_list.proto b/chrome/browser/win/conflicts/proto/module_list.proto similarity index 100% rename from chrome/browser/conflicts/proto/module_list.proto rename to chrome/browser/win/conflicts/proto/module_list.proto
diff --git a/chrome/browser/conflicts/registry_key_watcher_win.cc b/chrome/browser/win/conflicts/registry_key_watcher.cc similarity index 96% rename from chrome/browser/conflicts/registry_key_watcher_win.cc rename to chrome/browser/win/conflicts/registry_key_watcher.cc index bb64949d..536ab77 100644 --- a/chrome/browser/conflicts/registry_key_watcher_win.cc +++ b/chrome/browser/win/conflicts/registry_key_watcher.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/registry_key_watcher_win.h" +#include "chrome/browser/win/conflicts/registry_key_watcher.h" #include <windows.h>
diff --git a/chrome/browser/conflicts/registry_key_watcher_win.h b/chrome/browser/win/conflicts/registry_key_watcher.h similarity index 87% rename from chrome/browser/conflicts/registry_key_watcher_win.h rename to chrome/browser/win/conflicts/registry_key_watcher.h index 1be7789..e8e045c 100644 --- a/chrome/browser/conflicts/registry_key_watcher_win.h +++ b/chrome/browser/win/conflicts/registry_key_watcher.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_REGISTRY_KEY_WATCHER_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_REGISTRY_KEY_WATCHER_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_REGISTRY_KEY_WATCHER_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_REGISTRY_KEY_WATCHER_H_ #include <memory> @@ -49,4 +49,4 @@ DISALLOW_COPY_AND_ASSIGN(RegistryKeyWatcher); }; -#endif // CHROME_BROWSER_CONFLICTS_REGISTRY_KEY_WATCHER_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_REGISTRY_KEY_WATCHER_H_
diff --git a/chrome/browser/conflicts/registry_key_watcher_win_unittest.cc b/chrome/browser/win/conflicts/registry_key_watcher_unittest.cc similarity index 96% rename from chrome/browser/conflicts/registry_key_watcher_win_unittest.cc rename to chrome/browser/win/conflicts/registry_key_watcher_unittest.cc index 4a4262f..dff7e0b 100644 --- a/chrome/browser/conflicts/registry_key_watcher_win_unittest.cc +++ b/chrome/browser/win/conflicts/registry_key_watcher_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/registry_key_watcher_win.h" +#include "chrome/browser/win/conflicts/registry_key_watcher.h" #include "base/run_loop.h" #include "base/test/scoped_task_environment.h"
diff --git a/chrome/browser/conflicts/test/conflicts_dll.cc b/chrome/browser/win/conflicts/test/conflicts_dll.cc similarity index 100% rename from chrome/browser/conflicts/test/conflicts_dll.cc rename to chrome/browser/win/conflicts/test/conflicts_dll.cc
diff --git a/chrome/browser/conflicts/third_party_blocking_browsertest.cc b/chrome/browser/win/conflicts/third_party_blocking_browsertest.cc similarity index 95% rename from chrome/browser/conflicts/third_party_blocking_browsertest.cc rename to chrome/browser/win/conflicts/third_party_blocking_browsertest.cc index 13cded3..9c4374f 100644 --- a/chrome/browser/conflicts/third_party_blocking_browsertest.cc +++ b/chrome/browser/win/conflicts/third_party_blocking_browsertest.cc
@@ -15,11 +15,11 @@ #include "base/win/registry.h" #include "base/win/win_util.h" #include "base/win/windows_version.h" -#include "chrome/browser/conflicts/module_blacklist_cache_updater_win.h" -#include "chrome/browser/conflicts/module_blacklist_cache_util_win.h" -#include "chrome/browser/conflicts/module_database_win.h" -#include "chrome/browser/conflicts/proto/module_list.pb.h" -#include "chrome/browser/conflicts/third_party_conflicts_manager_win.h" +#include "chrome/browser/win/conflicts/module_blacklist_cache_updater.h" +#include "chrome/browser/win/conflicts/module_blacklist_cache_util.h" +#include "chrome/browser/win/conflicts/module_database.h" +#include "chrome/browser/win/conflicts/proto/module_list.pb.h" +#include "chrome/browser/win/conflicts/third_party_conflicts_manager.h" #include "chrome/chrome_elf/third_party_dlls/packed_list_format.h" #include "chrome/common/chrome_features.h" #include "chrome/install_static/install_util.h"
diff --git a/chrome/browser/conflicts/third_party_conflicts_manager_win.cc b/chrome/browser/win/conflicts/third_party_conflicts_manager.cc similarity index 96% rename from chrome/browser/conflicts/third_party_conflicts_manager_win.cc rename to chrome/browser/win/conflicts/third_party_conflicts_manager.cc index 7865f55f..16f88ce 100644 --- a/chrome/browser/conflicts/third_party_conflicts_manager_win.cc +++ b/chrome/browser/win/conflicts/third_party_conflicts_manager.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/third_party_conflicts_manager_win.h" +#include "chrome/browser/win/conflicts/third_party_conflicts_manager.h" #include <string> #include <utility> @@ -22,13 +22,13 @@ #include "base/version.h" #include "base/win/registry.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/conflicts/incompatible_applications_updater_win.h" -#include "chrome/browser/conflicts/installed_applications_win.h" -#include "chrome/browser/conflicts/module_blacklist_cache_updater_win.h" -#include "chrome/browser/conflicts/module_blacklist_cache_util_win.h" -#include "chrome/browser/conflicts/module_info_util_win.h" -#include "chrome/browser/conflicts/module_info_win.h" -#include "chrome/browser/conflicts/module_list_filter_win.h" +#include "chrome/browser/win/conflicts/incompatible_applications_updater.h" +#include "chrome/browser/win/conflicts/installed_applications.h" +#include "chrome/browser/win/conflicts/module_blacklist_cache_updater.h" +#include "chrome/browser/win/conflicts/module_blacklist_cache_util.h" +#include "chrome/browser/win/conflicts/module_info.h" +#include "chrome/browser/win/conflicts/module_info_util.h" +#include "chrome/browser/win/conflicts/module_list_filter.h" #include "chrome/chrome_elf/third_party_dlls/status_codes.h" #include "chrome/common/pref_names.h" #include "chrome/install_static/install_util.h"
diff --git a/chrome/browser/conflicts/third_party_conflicts_manager_win.h b/chrome/browser/win/conflicts/third_party_conflicts_manager.h similarity index 95% rename from chrome/browser/conflicts/third_party_conflicts_manager_win.h rename to chrome/browser/win/conflicts/third_party_conflicts_manager.h index 2e4451c..7e1e633 100644 --- a/chrome/browser/conflicts/third_party_conflicts_manager_win.h +++ b/chrome/browser/win/conflicts/third_party_conflicts_manager.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_THIRD_PARTY_CONFLICTS_MANAGER_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_THIRD_PARTY_CONFLICTS_MANAGER_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_THIRD_PARTY_CONFLICTS_MANAGER_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_THIRD_PARTY_CONFLICTS_MANAGER_H_ #include <memory> #include <string> @@ -15,9 +15,9 @@ #include "base/memory/weak_ptr.h" #include "base/optional.h" #include "base/strings/string_piece_forward.h" -#include "chrome/browser/conflicts/module_blacklist_cache_updater_win.h" -#include "chrome/browser/conflicts/module_database_observer_win.h" -#include "chrome/browser/conflicts/module_list_component_updater_win.h" +#include "chrome/browser/win/conflicts/module_blacklist_cache_updater.h" +#include "chrome/browser/win/conflicts/module_database_observer.h" +#include "chrome/browser/win/conflicts/module_list_component_updater.h" #include "chrome/chrome_elf/third_party_dlls/packed_list_format.h" class IncompatibleApplicationsUpdater; @@ -31,7 +31,7 @@ class SequencedTaskRunner; class TaskRunner; class Version; -} +} // namespace base // This class is responsible for the initialization of the // IncompatibleApplicationsWarning and ThirdPartyModulesBlocking features. Each @@ -248,4 +248,4 @@ DISALLOW_COPY_AND_ASSIGN(ThirdPartyConflictsManager); }; -#endif // CHROME_BROWSER_CONFLICTS_THIRD_PARTY_CONFLICTS_MANAGER_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_THIRD_PARTY_CONFLICTS_MANAGER_H_
diff --git a/chrome/browser/conflicts/third_party_conflicts_manager_win_unittest.cc b/chrome/browser/win/conflicts/third_party_conflicts_manager_unittest.cc similarity index 96% rename from chrome/browser/conflicts/third_party_conflicts_manager_win_unittest.cc rename to chrome/browser/win/conflicts/third_party_conflicts_manager_unittest.cc index dd79a5b..2329a977 100644 --- a/chrome/browser/conflicts/third_party_conflicts_manager_win_unittest.cc +++ b/chrome/browser/win/conflicts/third_party_conflicts_manager_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/third_party_conflicts_manager_win.h" +#include "chrome/browser/win/conflicts/third_party_conflicts_manager.h" #include <utility> @@ -17,8 +17,8 @@ #include "base/test/scoped_feature_list.h" #include "base/threading/sequenced_task_runner_handle.h" #include "base/win/windows_version.h" -#include "chrome/browser/conflicts/module_info_win.h" -#include "chrome/browser/conflicts/proto/module_list.pb.h" +#include "chrome/browser/win/conflicts/module_info.h" +#include "chrome/browser/win/conflicts/proto/module_list.pb.h" #include "chrome/common/chrome_features.h" #include "chrome/test/base/scoped_testing_local_state.h" #include "chrome/test/base/testing_browser_process.h"
diff --git a/chrome/browser/conflicts/third_party_metrics_recorder_win.cc b/chrome/browser/win/conflicts/third_party_metrics_recorder.cc similarity index 96% rename from chrome/browser/conflicts/third_party_metrics_recorder_win.cc rename to chrome/browser/win/conflicts/third_party_metrics_recorder.cc index c1a8b92..972a69f 100644 --- a/chrome/browser/conflicts/third_party_metrics_recorder_win.cc +++ b/chrome/browser/win/conflicts/third_party_metrics_recorder.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/third_party_metrics_recorder_win.h" +#include "chrome/browser/win/conflicts/third_party_metrics_recorder.h" #include <algorithm> #include <limits> @@ -13,8 +13,8 @@ #include "base/strings/string16.h" #include "base/strings/string_piece.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/conflicts/module_info_util_win.h" -#include "chrome/browser/conflicts/module_info_win.h" +#include "chrome/browser/win/conflicts/module_info.h" +#include "chrome/browser/win/conflicts/module_info_util.h" #include "components/crash/core/common/crash_key.h" #if defined(GOOGLE_CHROME_BUILD)
diff --git a/chrome/browser/conflicts/third_party_metrics_recorder_win.h b/chrome/browser/win/conflicts/third_party_metrics_recorder.h similarity index 90% rename from chrome/browser/conflicts/third_party_metrics_recorder_win.h rename to chrome/browser/win/conflicts/third_party_metrics_recorder.h index 7507671..7bd5ef48 100644 --- a/chrome/browser/conflicts/third_party_metrics_recorder_win.h +++ b/chrome/browser/win/conflicts/third_party_metrics_recorder.h
@@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_THIRD_PARTY_METRICS_RECORDER_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_THIRD_PARTY_METRICS_RECORDER_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_THIRD_PARTY_METRICS_RECORDER_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_THIRD_PARTY_METRICS_RECORDER_H_ #include <string> #include "base/macros.h" #include "base/strings/string16.h" -#include "chrome/browser/conflicts/module_database_observer_win.h" +#include "chrome/browser/win/conflicts/module_database_observer.h" #if defined(GOOGLE_CHROME_BUILD) #include "base/timer/timer.h" @@ -86,4 +86,4 @@ DISALLOW_COPY_AND_ASSIGN(ThirdPartyMetricsRecorder); }; -#endif // CHROME_BROWSER_CONFLICTS_THIRD_PARTY_METRICS_RECORDER_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_THIRD_PARTY_METRICS_RECORDER_H_
diff --git a/chrome/browser/conflicts/token_util_win.cc b/chrome/browser/win/conflicts/token_util.cc similarity index 96% rename from chrome/browser/conflicts/token_util_win.cc rename to chrome/browser/win/conflicts/token_util.cc index d4c37ffd..3fa78776 100644 --- a/chrome/browser/conflicts/token_util_win.cc +++ b/chrome/browser/win/conflicts/token_util.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/token_util_win.h" +#include "chrome/browser/win/conflicts/token_util.h" #include <windows.h>
diff --git a/chrome/browser/conflicts/token_util_win.h b/chrome/browser/win/conflicts/token_util.h similarity index 69% rename from chrome/browser/conflicts/token_util_win.h rename to chrome/browser/win/conflicts/token_util.h index 48a8421..c3a0a17 100644 --- a/chrome/browser/conflicts/token_util_win.h +++ b/chrome/browser/win/conflicts/token_util.h
@@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_TOKEN_UTIL_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_TOKEN_UTIL_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_TOKEN_UTIL_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_TOKEN_UTIL_H_ // Returns true if the current thread token is part of the built-in // Administrators group, which is a proxy for determining if the current user // has administrator rights. bool HasAdminRights(); -#endif // CHROME_BROWSER_CONFLICTS_TOKEN_UTIL_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_TOKEN_UTIL_H_
diff --git a/chrome/browser/conflicts/uninstall_application_win.cc b/chrome/browser/win/conflicts/uninstall_application.cc similarity index 98% rename from chrome/browser/conflicts/uninstall_application_win.cc rename to chrome/browser/win/conflicts/uninstall_application.cc index 04e22a4..bec37f5 100644 --- a/chrome/browser/conflicts/uninstall_application_win.cc +++ b/chrome/browser/win/conflicts/uninstall_application.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/conflicts/uninstall_application_win.h" +#include "chrome/browser/win/conflicts/uninstall_application.h" #include <wrl/client.h>
diff --git a/chrome/browser/conflicts/uninstall_application_win.h b/chrome/browser/win/conflicts/uninstall_application.h similarity index 72% rename from chrome/browser/conflicts/uninstall_application_win.h rename to chrome/browser/win/conflicts/uninstall_application.h index a12c2517..123373a7 100644 --- a/chrome/browser/conflicts/uninstall_application_win.h +++ b/chrome/browser/win/conflicts/uninstall_application.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CONFLICTS_UNINSTALL_APPLICATION_WIN_H_ -#define CHROME_BROWSER_CONFLICTS_UNINSTALL_APPLICATION_WIN_H_ +#ifndef CHROME_BROWSER_WIN_CONFLICTS_UNINSTALL_APPLICATION_H_ +#define CHROME_BROWSER_WIN_CONFLICTS_UNINSTALL_APPLICATION_H_ #include "base/strings/string16.h" @@ -15,4 +15,4 @@ } // namespace uninstall_application -#endif // CHROME_BROWSER_CONFLICTS_UNINSTALL_APPLICATION_WIN_H_ +#endif // CHROME_BROWSER_WIN_CONFLICTS_UNINSTALL_APPLICATION_H_
diff --git a/chrome/common/conflicts/remote_module_watcher_win.cc b/chrome/common/conflicts/remote_module_watcher_win.cc index 50cb691..8e73b2a 100644 --- a/chrome/common/conflicts/remote_module_watcher_win.cc +++ b/chrome/common/conflicts/remote_module_watcher_win.cc
@@ -60,7 +60,7 @@ std::unique_ptr<service_manager::Connector> connector) { DCHECK(task_runner_->RunsTasksInCurrentSequence()); - connector->BindInterface(content::mojom::kBrowserServiceName, + connector->BindInterface(content::mojom::kSystemServiceName, &module_event_sink_); module_watcher_ = ModuleWatcher::Create(base::BindRepeating(
diff --git a/chrome/common/conflicts/remote_module_watcher_win_unittest.cc b/chrome/common/conflicts/remote_module_watcher_win_unittest.cc index 7096c6e..4c27722 100644 --- a/chrome/common/conflicts/remote_module_watcher_win_unittest.cc +++ b/chrome/common/conflicts/remote_module_watcher_win_unittest.cc
@@ -35,7 +35,7 @@ MAIN_THREAD_MOCK_TIME), service_binding_(this, test_connector_factory_.RegisterInstance( - content::mojom::kBrowserServiceName)), + content::mojom::kSystemServiceName)), binding_(this) {} ~RemoteModuleWatcherTest() override = default;
diff --git a/chrome/common/thread_profiler.cc b/chrome/common/thread_profiler.cc index 84d2b11..f9bf3a582 100644 --- a/chrome/common/thread_profiler.cc +++ b/chrome/common/thread_profiler.cc
@@ -196,7 +196,7 @@ DCHECK_NE(CallStackProfileParams::BROWSER_PROCESS, GetProcess()); metrics::mojom::CallStackProfileCollectorPtr browser_interface; - connector->BindInterface(content::mojom::kBrowserServiceName, + connector->BindInterface(content::mojom::kSystemServiceName, &browser_interface); CallStackProfileBuilder::SetParentProfileCollectorForChildProcess( std::move(browser_interface));
diff --git a/chrome/installer/mac/dirdiffer.sh b/chrome/installer/mac/dirdiffer.sh index cd8f673f..70a70bb 100755 --- a/chrome/installer/mac/dirdiffer.sh +++ b/chrome/installer/mac/dirdiffer.sh
@@ -341,7 +341,7 @@ # Use rsync instead of the above, as it's the only way to preserve the # timestamp of a symbolic link using shell tools. - if ! rsync -lt "${new_file}" "${patch_file}"; then + if ! rsync --links --times "${new_file}" "${patch_file}"; then exit 10 fi @@ -406,7 +406,8 @@ # rsync will print a line for any file, directory, or symbolic link that # differs or exists only in one directory. As used here, it correctly # considers link targets, file contents, permissions, and timestamps. - local rsync_command=(rsync -clprt --delete --out-format=%n \ + local rsync_command=(rsync --checksum --delete --links --out-format=%n \ + --perms --recursive --times \ "${new_dir}/" "${verify_dir}") if [[ ${#g_verify_exclude[@]} -gt 0 ]]; then local exclude @@ -414,7 +415,7 @@ # ${g_verify_exclude[@]} contains paths in ${new_dir}. Strip off # ${new_dir} from the beginning of each, but leave a leading "/" so that # rsync treats them as being at the root of the "transfer." - rsync_command+=("--exclude" "${exclude:${#new_dir}}") + rsync_command+=("--exclude=${exclude:${#new_dir}}") done fi
diff --git a/chrome/installer/mac/dirpatcher.sh b/chrome/installer/mac/dirpatcher.sh index b4d0620a..679f263 100755 --- a/chrome/installer/mac/dirpatcher.sh +++ b/chrome/installer/mac/dirpatcher.sh
@@ -239,7 +239,7 @@ # Use rsync instead of the above, as it's the only way to preserve the # timestamp of a symbolic link using shell tools. - if ! rsync -lt "${patch_file}" "${new_file}"; then + if ! rsync --links --times "${patch_file}" "${new_file}"; then exit 10 fi
diff --git a/chrome/installer/mac/dmgdiffer.sh b/chrome/installer/mac/dmgdiffer.sh index dbdeb9b..f03f208a 100755 --- a/chrome/installer/mac/dmgdiffer.sh +++ b/chrome/installer/mac/dmgdiffer.sh
@@ -146,13 +146,15 @@ readonly KS_VERSION_KEY="KSVersion" readonly KS_PRODUCT_KEY="KSProductID" readonly KS_CHANNEL_KEY="KSChannelID" - readonly VERSIONS_DIR="Contents/Versions" + readonly VERSIONS_DIR_NEW=\ +"Contents/Frameworks/${product_name} Framework.framework/Versions" + readonly VERSIONS_DIR_OLD="Contents/Versions" readonly BUILD_RE="^[0-9]+\\.[0-9]+\\.([0-9]+)\\.[0-9]+\$" readonly MIN_BUILD=434 - local product_url="http://www.google.com/chrome/" + local product_url="https://www.google.com/chrome/" if [[ "${product_name}" = "Google Chrome Canary" ]]; then - product_url="http://tools.google.com/dlpage/chromesxs" + product_url="https://www.google.com/chrome/canary/" fi local old_app_path="${old_fs}/${APP_NAME}" @@ -234,8 +236,21 @@ name_extra=" ${new_ks_channel}" fi - local old_versioned_dir="${old_app_path}/${VERSIONS_DIR}/${old_app_version}" - local new_versioned_dir="${new_app_path}/${VERSIONS_DIR}/${new_app_version}" + local old_versioned_dir + if [[ -e "${old_app_path}/${VERSIONS_DIR_NEW}" ]]; then + old_versioned_dir="${old_app_path}/${VERSIONS_DIR_NEW}/${old_app_version}" + else + old_versioned_dir="${old_app_path}/${VERSIONS_DIR_OLD}/${old_app_version}" + fi + + local new_versioned_dir + local layout_new + if [[ -e "${new_app_path}/${VERSIONS_DIR_NEW}" ]]; then + new_versioned_dir="${new_app_path}/${VERSIONS_DIR_NEW}/${new_app_version}" + layout_new="y" + else + new_versioned_dir="${new_app_path}/${VERSIONS_DIR_OLD}/${new_app_version}" + fi if ! cp -p "${SCRIPT_DIR}/keystone_install.sh" \ "${patch_fs}/.keystone_install"; then @@ -282,7 +297,7 @@ # The only visible contents of the disk image will be a README file that # explains the image's purpose. local new_app_version_extra="${new_app_version}${name_extra}" - cat > "${patch_fs}/README.txt" << __EOF__ || \ + cat > "${patch_fs}/README.txt" << __EOF__ || (err "could not write README.txt" && exit 13) This disk image contains a differential updater that can update ${product_name} from version ${old_app_version} to ${new_app_version_extra}. @@ -290,12 +305,21 @@ This image is part of the auto-update system and is not independently useful. -To install ${product_name}, please visit -<${product_url}>. +To install ${product_name}, please visit ${product_url}. __EOF__ - local patch_versioned_dir="\ -${patch_dotpatch_dir}/version_${old_app_version}_${new_app_version}.dirpatch" + # version_patch_name is how keystone_install.sh distinguishes between diff + # updates intended to place the versioned directory in the new layout + # ("framework") and the old ("version"). + local version_patch_name + if [[ -n "${layout_new}" ]]; then + version_patch_name="framework" + else + version_patch_name="version" + fi + + local patch_versioned_dir="${patch_dotpatch_dir}/\ +${version_patch_name}_${old_app_version}_${new_app_version}.dirpatch" if ! "${DIRDIFFER}" "${old_versioned_dir}" \ "${new_versioned_dir}" \ @@ -308,12 +332,24 @@ # Set DIRDIFFER_EXCLUDE to exclude the contents of the Versions directory, # but to include an empty Versions directory. The versioned directory was # already addressed in the preceding dirpatch. - export DIRDIFFER_EXCLUDE="/${APP_NAME_RE}/Contents/Versions/" + if [[ -n "${layout_new}" ]]; then + # Transform VERSIONS_DIR_NEW into a regular expression pattern by + # backslashing the dot. + # + # This exclude pattern omits the Current symbolic link, which will be fixed + # up after dirdiffer creates this dirpatch. + export DIRDIFFER_EXCLUDE=\ +"/${APP_NAME_RE}/$(echo "${VERSIONS_DIR_NEW}" | sed -e 's/\./\\./g')/" + else + # VERSIONS_DIR_OLD doesn't contain anything that a regular expression parser + # would misinterpret. + export DIRDIFFER_EXCLUDE="/${APP_NAME_RE}/${VERSIONS_DIR_OLD}/" + fi # Set DIRDIFFER_NO_DIFF to exclude files introduced by or modified by # Keystone channel and brand tagging and subsequent code signing. - export DIRDIFFER_NO_DIFF="\ -/${APP_NAME_RE}/Contents/\ + export DIRDIFFER_NO_DIFF=\ +"/${APP_NAME_RE}/Contents/\ (CodeResources|Info\\.plist|MacOS/${product_name}|_CodeSignature/.*)$" local patch_app_dir="${patch_dotpatch_dir}/application.dirpatch" @@ -328,6 +364,14 @@ unset DIRDIFFER_EXCLUDE DIRDIFFER_NO_DIFF + if [[ -n "${layout_new}" ]]; then + # The Current symbolic link in the framework's Versions directory was + # excluded by DIRDIFFER_EXCLUDE, but its presence is critical. + rsync --links --perms --times \ + "${new_app_path}/${VERSIONS_DIR_NEW}/Current" \ + "${patch_app_dir}/${VERSIONS_DIR_NEW}/Current" + fi + echo "${product_name} ${old_app_version}-${new_app_version_extra} Update" }
diff --git a/chrome/installer/mac/keystone_install.sh b/chrome/installer/mac/keystone_install.sh index f4a69817..ea5f1073 100755 --- a/chrome/installer/mac/keystone_install.sh +++ b/chrome/installer/mac/keystone_install.sh
@@ -15,6 +15,10 @@ # actions will be logged to stderr. The same debugging information will # also be enabled when "Library/Google/Google Chrome Updater Debug" in the # root directory or in ${HOME} exists. +# GOOGLE_CHROME_UPDATER_TEST_PATH +# When set to a non-empty value, the product at this path will be updated. +# ksadmin will not be consulted to locate the installed product, nor will it +# be called to update any tickets. # # Exit codes: # 0 Happiness @@ -64,9 +68,13 @@ readonly KS_CHANNEL_KEY="KSChannelID" -# Workaround for http://code.google.com/p/chromium/issues/detail?id=83180#c3 -# In bash 4.0, "declare VAR" no longer initializes VAR if not already set. +# Workaround for https://crbug.com/83180#c3: in bash 4.0, "declare VAR" no +# longer initializes VAR if not already set. (Apple has never shipped a bash +# newer than 3.2, but a small number of people seem to have replaced their +# system /bin/sh with a newer bash, probably all before SIP became a thing.) : ${GOOGLE_CHROME_UPDATER_DEBUG:=} +: ${GOOGLE_CHROME_UPDATER_TEST_PATH:=} + err() { local error="${1}" @@ -222,8 +230,8 @@ fi temp_link="${temp_link_dir}/$(basename "${symlink}")" - (ln -fhs "${target}" "${temp_link}" && \ - chmod -h 755 "${temp_link}" && \ + (ln -fhs "${target}" "${temp_link}" && + chmod -h 755 "${temp_link}" && mv -f "${temp_link}" "${symlink_dir}/") || true rm -rf "${temp_link_dir}" fi @@ -351,7 +359,16 @@ ksadmin_version() { if [[ -z "${g_checked_ksadmin_version}" ]]; then g_checked_ksadmin_version="y" - g_ksadmin_version="$(ksadmin --ksadmin-version || true)" + if [[ -n "${GOOGLE_CHROME_UPDATER_TEST_PATH}" ]]; then + note "test mode: not calling Keystone, g_ksadmin_version is fake" + + # This isn't very special, it's just what happens to be current as this is + # written. It's new enough that all of the feature checks + # (ksadmin_supports_*) pass. + g_ksadmin_version="1.2.13.41" + else + g_ksadmin_version="$(ksadmin --ksadmin-version || true)" + fi note "g_ksadmin_version = ${g_ksadmin_version}" fi echo "${g_ksadmin_version}" @@ -552,7 +569,9 @@ note "ksadmin_args = ${ksadmin_args[*]}" - if ! ksadmin "${ksadmin_args[@]}"; then + if [[ -n "${GOOGLE_CHROME_UPDATER_TEST_PATH}" ]]; then + note "test mode: not calling Keystone to mark failed patch update" + elif ! ksadmin "${ksadmin_args[@]}"; then err "ksadmin failed to mark failed patch update" else note "marked failed patch update" @@ -584,7 +603,9 @@ readonly PATCH_DIR=".patch" readonly CONTENTS_DIR="Contents" readonly APP_PLIST="${CONTENTS_DIR}/Info" - readonly VERSIONS_DIR="${CONTENTS_DIR}/Versions" + readonly VERSIONS_DIR_NEW=\ +"${CONTENTS_DIR}/Frameworks/${FRAMEWORK_DIR}/Versions" + readonly VERSIONS_DIR_OLD="${CONTENTS_DIR}/Versions" readonly UNROOTED_BRAND_PLIST="Library/Google/Google Chrome Brand" readonly UNROOTED_DEBUG_FILE="Library/Google/Google Chrome Updater Debug" @@ -597,17 +618,17 @@ readonly QUARANTINE_ATTR="com.apple.quarantine" - # Don't use rsync -a, because -a expands to -rlptgoD. -g and -o copy owners - # and groups, respectively, from the source, and that is undesirable in this - # case. -D copies devices and special files; copying devices only works - # when running as root, so for consistency between privileged and - # unprivileged operation, this option is omitted as well. - # -I, --ignore-times don't skip files that match in size and mod-time - # -l, --links copy symlinks as symlinks - # -r, --recursive recurse into directories - # -p, --perms preserve permissions - # -t, --times preserve times - readonly RSYNC_FLAGS="-Ilprt" + # Don't use rsync --archive, because --archive includes --group and --owner, + # which copy groups and owners, respectively, from the source, and that is + # undesirable in this case (often, this script will have permission to set + # those attributes). --archive also includes --devices and --specials, which + # copy files that should never occur in the transfer; --devices only works + # when running as root, so for consistency between privileged and unprivileged + # operation, this option is omitted as well. --archive does not include + # --ignore-times, which is desirable, as it forces rsync to copy files even + # when their sizes and modification times are identical, as their content + # still may be different. + readonly RSYNC_FLAGS="--ignore-times --links --perms --recursive --times" # It's difficult to get GOOGLE_CHROME_UPDATER_DEBUG set in the environment # when this script is called from Keystone. If a "debug file" exists in @@ -680,7 +701,7 @@ local patch_app_dir= local patch_versioned_dir= - local update_version_app update_version_ks product_id + local update_version_app update_version_ks product_id update_layout_new if [[ -z "${is_patch}" ]]; then update_app="${update_dmg_mount_point}/${APP_DIR}" note "update_app = ${update_app}" @@ -737,6 +758,11 @@ exit 2 fi note "product_id = ${product_id}" + + if [[ -d "${update_app}/${VERSIONS_DIR_NEW}" ]]; then + update_layout_new="y" + fi + note "update_layout_new = ${update_layout_new}" else # [[ -n "${is_patch}" ]] # Get some information about the update. note "reading update values" @@ -776,13 +802,20 @@ fi note "patch_app_dir = ${patch_app_dir}" - patch_versioned_dir=\ + patch_versioned_dir="${patch_dir}/\ +framework_${update_version_app_old}_${update_version_app}.dirpatch" + if [[ -d "${patch_versioned_dir}" ]]; then + update_layout_new="y" + else + patch_versioned_dir=\ "${patch_dir}/version_${update_version_app_old}_${update_version_app}.dirpatch" - if ! [[ -d "${patch_versioned_dir}" ]]; then - err "couldn't locate patch_versioned_dir" - exit 6 + if ! [[ -d "${patch_versioned_dir}" ]]; then + err "couldn't locate patch_versioned_dir" + exit 6 + fi fi note "patch_versioned_dir = ${patch_versioned_dir}" + note "update_layout_new = ${update_layout_new}" fi # ksadmin is required. Keystone should have set a ${PATH} that includes it. @@ -790,12 +823,16 @@ # unlikely event that ksadmin is missing. note "checking Keystone" - local ksadmin_path - if ! ksadmin_path="$(type -p ksadmin)" || [[ -z "${ksadmin_path}" ]]; then - err "couldn't locate ksadmin_path" - exit 3 + if [[ -n "${GOOGLE_CHROME_UPDATER_TEST_PATH}" ]]; then + note "test mode: not setting ksadmin_path" + else + local ksadmin_path + if ! ksadmin_path="$(type -p ksadmin)" || [[ -z "${ksadmin_path}" ]]; then + err "couldn't locate ksadmin_path" + exit 3 + fi + note "ksadmin_path = ${ksadmin_path}" fi - note "ksadmin_path = ${ksadmin_path}" # Call ksadmin_version once to prime the global state. This is needed # because subsequent calls to ksadmin_version that occur in $(...) @@ -810,7 +847,10 @@ # Figure out where to install. local installed_app - if ! installed_app="$(ksadmin -pP "${product_id}" | sed -Ene \ + if [[ -n "${GOOGLE_CHROME_UPDATER_TEST_PATH}" ]]; then + note "test mode: not calling Keystone, installed_app is from environment" + installed_app="${GOOGLE_CHROME_UPDATER_TEST_PATH}" + elif ! installed_app="$(ksadmin -pP "${product_id}" | sed -Ene \ "s%^[[:space:]]+xc=<KSPathExistenceChecker:.* path=(/.+)>\$%\\1%p")" || [[ -z "${installed_app}" ]]; then err "couldn't locate installed_app" @@ -851,7 +891,8 @@ # sufficiently recent ksadmin. Older ksadmins are tolerated: the update will # likely fail for another reason and the user ticket will hang around until # something is eventually able to remove it. - if [[ -z "${system_ticket}" ]] && + if [[ -z "${GOOGLE_CHROME_UPDATER_TEST_PATH}" ]] && + [[ -z "${system_ticket}" ]] && ksadmin -S --print-tickets --productid "${product_id}" >& /dev/null; then ksadmin --delete --productid "${product_id}" || true err "can't update on a user ticket when a system ticket is also present" @@ -889,14 +930,28 @@ fi fi - local installed_versions_dir="${installed_app}/${VERSIONS_DIR}" + local installed_versions_dir_new="${installed_app}/${VERSIONS_DIR_NEW}" + note "installed_versions_dir_new = ${installed_versions_dir_new}" + local installed_versions_dir_old="${installed_app}/${VERSIONS_DIR_OLD}" + note "installed_versions_dir_old = ${installed_versions_dir_old}" + + local installed_versions_dir + if [[ -n "${update_layout_new}" ]]; then + installed_versions_dir="${installed_versions_dir_new}" + else + installed_versions_dir="${installed_versions_dir_old}" + fi note "installed_versions_dir = ${installed_versions_dir}" - # If the installed application is incredibly old, old_versioned_dir may not - # exist. + # If the installed application is incredibly old, or in a skeleton bootstrap + # installation, old_versioned_dir may not exist. local old_versioned_dir if [[ -n "${old_version_app}" ]]; then - old_versioned_dir="${installed_versions_dir}/${old_version_app}" + if [[ -d "${installed_versions_dir_new}/${old_version_app}" ]]; then + old_versioned_dir="${installed_versions_dir_new}/${old_version_app}" + elif [[ -d "${installed_versions_dir_old}/${old_version_app}" ]]; then + old_versioned_dir="${installed_versions_dir_old}/${old_version_app}" + fi fi note "old_versioned_dir = ${old_versioned_dir}" @@ -912,7 +967,13 @@ local update_versioned_dir= if [[ -z "${is_patch}" ]]; then - update_versioned_dir="${update_app}/${VERSIONS_DIR}/${update_version_app}" + if [[ -n "${update_layout_new}" ]]; then + update_versioned_dir=\ +"${update_app}/${VERSIONS_DIR_NEW}/${update_version_app}" + else + update_versioned_dir=\ +"${update_app}/${VERSIONS_DIR_OLD}/${update_version_app}" + fi note "update_versioned_dir = ${update_versioned_dir}" fi @@ -924,8 +985,8 @@ # Make sure that ${installed_versions_dir} exists, so that it can receive # the versioned directory. It may not exist if updating from an older - # version that did not use the versioned layout on disk. Later, during the - # rsync to copy the application directory, the mode bits and timestamp on + # version that did not use the same versioned layout on disk. Later, during + # the rsync to copy the application directory, the mode bits and timestamp on # ${installed_versions_dir} will be set to conform to whatever is present in # the update. # @@ -990,6 +1051,19 @@ "${old_ks_plist}" \ "${old_version_app}" \ "${system_ticket}" + + if [[ -n "${update_layout_new}" ]] && + [[ "${versioned_dir_target}" = "${new_versioned_dir}" ]]; then + # If the dirpatcher of a new-layout versioned directory failed while + # writing directly to the target location, remove it. The incomplete + # version would break code signature validation under the new layout. + # If it was being staged in a temporary directory, there's nothing to + # clean up beyond cleaning up the temporary directory, which will happen + # normally at exit. + note "cleaning up new_versioned_dir" + rm -rf "${new_versioned_dir}" + fi + exit 12 fi fi @@ -1016,6 +1090,14 @@ if ! rsync ${RSYNC_FLAGS} --delete-before "${update_versioned_dir}/" \ "${new_versioned_dir}"; then err "rsync of versioned directory failed, status ${PIPESTATUS[0]}" + + if [[ -n "${update_layout_new}" ]]; then + # If the rsync of a new-layout versioned directory failed, remove it. + # The incomplete version would break code signature validation. + note "cleaning up new_versioned_dir" + rm -rf "${new_versioned_dir}" + fi + exit 7 fi fi @@ -1072,10 +1154,14 @@ # much to copy in this step, because most of the application is in the # versioned directory. This step only accounts for around 50 files, most of # which are small localized InfoPlist.strings files. Note that - # ${VERSIONS_DIR} is included to copy its mode bits and timestamp, but its - # contents are excluded, having already been installed above. + # ${VERSIONS_DIR_NEW} or ${VERSIONS_DIR_OLD} are included to copy their mode + # bits and timestamps, but their contents are excluded, having already been + # installed above. The ${VERSIONS_DIR_NEW}/Current symbolic link is updated + # or created in this step, however. note "rsyncing app directory" - if ! rsync ${RSYNC_FLAGS} --delete-after --exclude "/${VERSIONS_DIR}/*" \ + if ! rsync ${RSYNC_FLAGS} --delete-after \ + --include="/${VERSIONS_DIR_NEW}/Current" \ + --exclude="/${VERSIONS_DIR_NEW}/*" --exclude="/${VERSIONS_DIR_OLD}/*" \ "${update_app}/" "${installed_app}"; then err "rsync of app directory failed, status ${PIPESTATUS[0]}" exit 8 @@ -1246,7 +1332,7 @@ ksadmin_brand_plist_path="${brand_plist_path}" ksadmin_brand_key="${KS_BRAND_KEY}" - if [[ ! -f "${ksadmin_brand_plist_path}" ]]; then + if ! [[ -f "${ksadmin_brand_plist_path}" ]]; then # Clear any branding information. ksadmin_brand_plist_path= ksadmin_brand_key= @@ -1295,7 +1381,9 @@ note "ksadmin_args = ${ksadmin_args[*]}" - if ! ksadmin "${ksadmin_args[@]}"; then + if [[ -n "${GOOGLE_CHROME_UPDATER_TEST_PATH}" ]]; then + note "test mode: not calling Keystone to update ticket" + elif ! ksadmin "${ksadmin_args[@]}"; then err "ksadmin failed" exit 11 fi @@ -1336,10 +1424,12 @@ note "cleaning up old versioned directories" local versioned_dir - for versioned_dir in "${installed_versions_dir}/"*; do + for versioned_dir in "${installed_versions_dir_new}/"* \ + "${installed_versions_dir_old}/"*; do note "versioned_dir = ${versioned_dir}" - if [[ "${versioned_dir}" = "${new_versioned_dir}" ]] || \ - [[ "${versioned_dir}" = "${old_versioned_dir}" ]]; then + if [[ "${versioned_dir}" = "${new_versioned_dir}" ]] || + [[ "${versioned_dir}" = "${old_versioned_dir}" ]] || + [[ "${versioned_dir}" = "${installed_versions_dir_new}/Current" ]]; then # This is the versioned directory corresponding to the update that was # just applied or the version that was previously in use. Leave it # alone. @@ -1356,7 +1446,14 @@ # Look for any processes using the framework dylib. This will catch # browser processes where the ps check will not, but it is limited to # processes running as the effective user. - local lsof_file="${versioned_dir}/${FRAMEWORK_DIR}/${FRAMEWORK_NAME}" + local lsof_file + if [[ -e "${versioned_dir}/${FRAMEWORK_DIR}/${FRAMEWORK_NAME}" ]]; then + # Old layout. + lsof_file="${versioned_dir}/${FRAMEWORK_DIR}/${FRAMEWORK_NAME}" + else + # New layout. + lsof_file="${versioned_dir}/${FRAMEWORK_NAME}" + fi note "lsof_file = ${lsof_file}" # ps -e displays all users' processes, -ww causes ps to not truncate @@ -1386,6 +1483,27 @@ fi done + # When the last old-layout version is gone, remove the old-layout Versions + # directory. Note that this isn't attempted when the last new-layout Versions + # directory disappears, because hopefully there won't ever be an "upgrade" (at + # least not long-term) that needs to revert from the new to the old layout. If + # this does become necessary, the rmdir should attempt to remove, from + # innermost to outermost, ${installed_versions_dir_new} out to + # ${installed_app}/${CONTENTS_DIR}/Frameworks. Even though that removal isn't + # attempted here, a subsequent update will do this cleanup as a side effect of + # the outer app rsync, which will remove these directories if empty when + # "updating" to another old-layout version. + if [[ -n "${update_layout_new}" ]] && + [[ -d "${installed_versions_dir_old}" ]]; then + note "attempting removal of installed_versions_dir_old" + rmdir "${installed_versions_dir_old}" >& /dev/null + if [[ -d "${installed_versions_dir_old}" ]]; then + note "removal of installed_versions_dir_old failed" + else + note "removal of installed_versions_dir_old succeeded" + fi + fi + # If this script is being driven by a user Keystone ticket, it is not # running as root. If the application is installed somewhere under # /Applications, try to make it writable by all admin users. This will
diff --git a/chrome/installer/mac/pkg-dmg b/chrome/installer/mac/pkg-dmg index 82b9010..f3e100c 100755 --- a/chrome/installer/mac/pkg-dmg +++ b/chrome/installer/mac/pkg-dmg
@@ -567,8 +567,9 @@ # treated as the volume root itself. rsync will do this by default, if no # trailing '/' is present. With a trailing '/', $sourceFolder becomes # $tempRoot, instead of becoming an entry in $tempRoot. -if(command($gConfig{'cmd_rsync'}, '-aC', '--include', '*.so', - '--copy-unsafe-links', $sourceFolder.($sourceFile?'':'/'),$tempRoot) != 0) { +if(command($gConfig{'cmd_rsync'}, '--archive', '--copy-unsafe-links', + '--cvs-exclude', '--include=*.so', + $sourceFolder.($sourceFile?'':'/'), $tempRoot) != 0) { cleanupDie('rsync failed'); } @@ -598,8 +599,9 @@ } if(defined($iconFile)) { - if(command($gConfig{'cmd_rsync'}, '-aC', '--include', '*.so', - '--copy-unsafe-links', $iconFile, $tempRoot.'/.VolumeIcon.icns') != 0) { + if(command($gConfig{'cmd_rsync'}, '--archive', '--copy-unsafe-links', + '--cvs-exclude', '--include=*.so', + $iconFile, $tempRoot.'/.VolumeIcon.icns') != 0) { cleanupDie('rsync failed for volume icon'); } @@ -898,8 +900,10 @@ $success = commandInternal('symlink', $source, $target); } else { - $success = !command($gConfig{'cmd_rsync'}, '-aC', '--include', '*.so', - '--copy-unsafe-links', $source, $target); + $success = !command($gConfig{'cmd_rsync'}, '--archive', + '--copy-unsafe-links', '--cvs-exclude', + '--include=*.so', + $source, $target); } if(!$success) { cleanupDie('copyFiles failed for method '.$method); @@ -1163,8 +1167,9 @@ # the volume is mounted, copy the files. --copy-unsafe-links is # unnecessary since it was used to copy everything to the staging # area. There can be no more unsafe links. - if(command($gConfig{'cmd_rsync'}, '-aC', '--include', '*.so', - $source.'/',$partitionMountPoint) != 0) { + if(command($gConfig{'cmd_rsync'}, '--archive', '--cvs-exclude', + '--include=*.so', + $source.'/', $partitionMountPoint) != 0) { cleanupDie('rsync to new volume failed'); }
diff --git a/chrome/renderer/extensions/cast_streaming_native_handler.cc b/chrome/renderer/extensions/cast_streaming_native_handler.cc index 3a1c8bf3..ebc8848 100644 --- a/chrome/renderer/extensions/cast_streaming_native_handler.cc +++ b/chrome/renderer/extensions/cast_streaming_native_handler.cc
@@ -31,7 +31,6 @@ #include "chrome/renderer/media/cast_rtp_stream.h" #include "chrome/renderer/media/cast_session.h" #include "chrome/renderer/media/cast_udp_transport.h" -#include "content/public/renderer/media_stream_utils.h" #include "content/public/renderer/v8_value_converter.h" #include "extensions/common/extension.h" #include "extensions/renderer/native_extension_bindings_system.h"
diff --git a/chrome/services/util_win/BUILD.gn b/chrome/services/util_win/BUILD.gn index 6bff327..e614ae5 100644 --- a/chrome/services/util_win/BUILD.gn +++ b/chrome/services/util_win/BUILD.gn
@@ -16,7 +16,7 @@ deps = [ "//base", - "//chrome/browser/conflicts:module_info", + "//chrome/browser/win/conflicts:module_info", "//chrome/common", "//components/variations", "//components/version_info",
diff --git a/chrome/services/util_win/DEPS b/chrome/services/util_win/DEPS index eb5cfa8..f1c6172b 100644 --- a/chrome/services/util_win/DEPS +++ b/chrome/services/util_win/DEPS
@@ -1,6 +1,6 @@ include_rules = [ - "+chrome/browser/conflicts/module_info_util_win.h", - "+chrome/browser/conflicts/module_info_win.h", + "+chrome/browser/win/conflicts/module_info.h", + "+chrome/browser/win/conflicts/module_info_util.h", "+chrome/installer/util/install_util.h", "+content/public/utility/utility_thread.h", "+third_party/metrics_proto/system_profile.pb.h",
diff --git a/chrome/services/util_win/public/mojom/util_win.typemap b/chrome/services/util_win/public/mojom/util_win.typemap index 4b45cdc..b32b8e9 100644 --- a/chrome/services/util_win/public/mojom/util_win.typemap +++ b/chrome/services/util_win/public/mojom/util_win.typemap
@@ -7,8 +7,8 @@ public_headers = [ "//base/files/file_path.h", "//base/strings/string16.h", - "//chrome/browser/conflicts/module_info_util_win.h", - "//chrome/browser/conflicts/module_info_win.h", + "//chrome/browser/win/conflicts/module_info_util.h", + "//chrome/browser/win/conflicts/module_info.h", "//third_party/metrics_proto/system_profile.pb.h", "//ui/shell_dialogs/execute_select_file_win.h", "//ui/shell_dialogs/select_file_dialog.h", @@ -23,7 +23,7 @@ deps = [ "//base", - "//chrome/browser/conflicts:module_info", + "//chrome/browser/win/conflicts:module_info", "//third_party/metrics_proto", "//ui/shell_dialogs", ]
diff --git a/chrome/services/util_win/public/mojom/util_win_mojom_traits.h b/chrome/services/util_win/public/mojom/util_win_mojom_traits.h index 74af27f..f870522 100644 --- a/chrome/services/util_win/public/mojom/util_win_mojom_traits.h +++ b/chrome/services/util_win/public/mojom/util_win_mojom_traits.h
@@ -9,8 +9,8 @@ #include "base/files/file_path.h" #include "base/strings/string16.h" -#include "chrome/browser/conflicts/module_info_util_win.h" -#include "chrome/browser/conflicts/module_info_win.h" +#include "chrome/browser/win/conflicts/module_info.h" +#include "chrome/browser/win/conflicts/module_info_util.h" #include "chrome/services/util_win/public/mojom/util_win.mojom.h" #include "third_party/metrics_proto/system_profile.pb.h" #include "ui/shell_dialogs/execute_select_file_win.h"
diff --git a/chrome/services/util_win/util_win_impl.cc b/chrome/services/util_win/util_win_impl.cc index e3247e5..4f19605 100644 --- a/chrome/services/util_win/util_win_impl.cc +++ b/chrome/services/util_win/util_win_impl.cc
@@ -21,7 +21,7 @@ #include "base/win/scoped_variant.h" #include "base/win/shortcut.h" #include "base/win/win_util.h" -#include "chrome/browser/conflicts/module_info_util_win.h" +#include "chrome/browser/win/conflicts/module_info_util.h" #include "chrome/installer/util/install_util.h" #include "chrome/services/util_win/av_products.h" #include "mojo/public/cpp/bindings/strong_binding.h"
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index 2f90e3b..2f8baaed 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -2244,7 +2244,7 @@ ] if (is_chrome_branded) { - deps += [ "//chrome/browser/conflicts:browser_tests" ] + deps += [ "//chrome/browser/win/conflicts:browser_tests" ] } } else { # Not Windows. sources -= [ "../app/chrome_version.rc.version" ] @@ -3254,7 +3254,7 @@ assert(toolkit_views) sources += [ "../browser/ui/startup/credential_provider_signin_info_fetcher_win_unittest.cc" ] deps += [ - "//chrome/browser/conflicts:unit_tests", + "//chrome/browser/win/conflicts:unit_tests", "//chrome/test:credential_provider_test_utils", ] }
diff --git a/chrome/test/data/local_ntp/local_ntp_browsertest.html b/chrome/test/data/local_ntp/local_ntp_browsertest.html index e8fd20a4..36c9856c 100644 --- a/chrome/test/data/local_ntp/local_ntp_browsertest.html +++ b/chrome/test/data/local_ntp/local_ntp_browsertest.html
@@ -191,7 +191,10 @@ <div id="backgrounds-upload-text">$i18n{uploadImage}</div> </div> <div id="backgrounds-default" class="bg-sel-tile-bg"> - <div id="backgrounds-default-icon" class="bg-sel-tile"></div> + <div id="backgrounds-default-icon" class="bg-sel-tile"> + <div id="backgrounds-default-icon-header"></div> + <div id="backgrounds-default-icon-shortcuts"></div> + </div> <div class="bg-sel-tile-title">Default</div> </div> </div>
diff --git a/chrome/test/data/webrtc/peerconnection_getstats.js b/chrome/test/data/webrtc/peerconnection_getstats.js index c268da0..a1e2ff1f 100644 --- a/chrome/test/data/webrtc/peerconnection_getstats.js +++ b/chrome/test/data/webrtc/peerconnection_getstats.js
@@ -179,6 +179,7 @@ framesEncoded: 'number', qpSum: 'number', totalEncodeTime: 'number', + totalPacketSendDelay: 'number', averageRtcpInterval: 'number', qualityLimitationReason: 'string', qualityLimitationDurations: 'object',
diff --git a/chrome/test/data/webui/cr_elements/cr_tabs_test.js b/chrome/test/data/webui/cr_elements/cr_tabs_test.js index 6ba1caf..bf445d81 100644 --- a/chrome/test/data/webui/cr_elements/cr_tabs_test.js +++ b/chrome/test/data/webui/cr_elements/cr_tabs_test.js
@@ -40,7 +40,13 @@ const tabElement = getTabElement(expectedSelection); assertTrue(!!tabElement); assertTrue(tabElement.classList.contains('selected')); + assertEquals('0', tabElement.getAttribute('tabindex')); assertEquals(getDeepActiveElement(), tabElement); + const notSelected = tabs.shadowRoot.querySelectorAll('.tab:not(.selected)'); + assertEquals(2, notSelected.length); + notSelected.forEach(tab => { + assertEquals('-1', tab.getAttribute('tabindex')); + }); } /**
diff --git a/chrome/test/data/webui/settings/certificate_manager_test.js b/chrome/test/data/webui/settings/certificate_manager_test.js index 785dcba..7f722a0 100644 --- a/chrome/test/data/webui/settings/certificate_manager_test.js +++ b/chrome/test/data/webui/settings/certificate_manager_test.js
@@ -648,7 +648,7 @@ */ test('Initialization', function() { // Trigger all category tabs to be added to the DOM. - const paperTabsElement = page.shadowRoot.querySelector('paper-tabs'); + const paperTabsElement = page.shadowRoot.querySelector('cr-tabs'); paperTabsElement.selected = CertificateCategoryIndex.PERSONAL; Polymer.dom.flush(); paperTabsElement.selected = CertificateCategoryIndex.SERVER;
diff --git a/chrome/test/data/webui/settings/privacy_page_test.js b/chrome/test/data/webui/settings/privacy_page_test.js index d1953f9..26bad30 100644 --- a/chrome/test/data/webui/settings/privacy_page_test.js +++ b/chrome/test/data/webui/settings/privacy_page_test.js
@@ -477,10 +477,6 @@ assertTrue(!!actionButton); const cookieCheckboxBasic = element.$$('#cookiesCheckboxBasic'); assertTrue(!!cookieCheckboxBasic); - const basicTab = element.$$('#basicTabTitle'); - assertTrue(!!basicTab); - const advancedTab = element.$$('#advancedTabTitle'); - assertTrue(!!advancedTab); // Initially the button is disabled because all checkboxes are off. assertTrue(actionButton.disabled); // The button gets enabled if any checkbox is selected. @@ -488,10 +484,10 @@ assertTrue(cookieCheckboxBasic.checked); assertFalse(actionButton.disabled); // Switching to advanced disables the button. - advancedTab.click(); + element.$$('cr-tabs').selected = 1; assertTrue(actionButton.disabled); // Switching back enables it again. - basicTab.click(); + element.$$('cr-tabs').selected = 0; assertFalse(actionButton.disabled); });
diff --git a/chrome/test/data/xr/e2e_test_files/html/test_webxr_gamepad_support.html b/chrome/test/data/xr/e2e_test_files/html/test_webxr_gamepad_support.html index edd47f40..ca6a230 100644 --- a/chrome/test/data/xr/e2e_test_files/html/test_webxr_gamepad_support.html +++ b/chrome/test/data/xr/e2e_test_files/html/test_webxr_gamepad_support.html
@@ -51,12 +51,12 @@ } function inputSourceCount() { - return currentImmersiveSession().getInputSources().length; + return currentImmersiveSession().inputSources.length; } function inputSourceWithGamepadCount() { let numGamepads = 0; - for (source of currentImmersiveSession().getInputSources()) { + for (source of currentImmersiveSession().inputSources) { if (source.gamepad !== null) { numGamepads++; } @@ -107,7 +107,7 @@ } if (verificationFunction) { - let gamepad = currentImmersiveSession().getInputSources()[0].gamepad; + let gamepad = currentImmersiveSession().inputSources[0].gamepad; if (!verificationFunction(gamepad)) { return false; }
diff --git a/chrome/test/data/xr/e2e_test_files/html/test_webxr_input_same_object.html b/chrome/test/data/xr/e2e_test_files/html/test_webxr_input_same_object.html index 218d149..d79d64a8 100644 --- a/chrome/test/data/xr/e2e_test_files/html/test_webxr_input_same_object.html +++ b/chrome/test/data/xr/e2e_test_files/html/test_webxr_input_same_object.html
@@ -26,7 +26,7 @@ function getCurrentInputSources() { let currentSession = sessionInfos[sessionTypes.IMMERSIVE].currentSession; - return currentSession.getInputSources(); + return Array.from(currentSession.inputSources.values()); } let cached_input_source = null;
diff --git a/chrome/test/data/xr/e2e_test_files/html/test_webxr_input_sources_change_event.html b/chrome/test/data/xr/e2e_test_files/html/test_webxr_input_sources_change_event.html index edca160..a9121a3 100644 --- a/chrome/test/data/xr/e2e_test_files/html/test_webxr_input_sources_change_event.html +++ b/chrome/test/data/xr/e2e_test_files/html/test_webxr_input_sources_change_event.html
@@ -30,7 +30,7 @@ function getCurrentInputSources() { let currentSession = sessionInfos[sessionTypes.IMMERSIVE].currentSession; - return currentSession.getInputSources(); + return Array.from(currentSession.inputSources.values()); } let cached_input_source = null;
diff --git a/chromecast/browser/cast_overlay_manifests.cc b/chromecast/browser/cast_overlay_manifests.cc index 3edf4831..fbcf86d 100644 --- a/chromecast/browser/cast_overlay_manifests.cc +++ b/chromecast/browser/cast_overlay_manifests.cc
@@ -39,7 +39,7 @@ #if !defined(OS_FUCHSIA) .RequireCapability("heap_profiling", "heap_profiler") .RequireCapability("heap_profiling", "profiling") - .RequireCapability("content_browser", "profiling_client") + .RequireCapability("content_system", "profiling_client") .ExposeCapability("profiling_client", service_manager::Manifest::InterfaceList< heap_profiling::mojom::ProfilingClient>())
diff --git a/components/content_capture/android/content_capture_receiver_manager_android.cc b/components/content_capture/android/content_capture_receiver_manager_android.cc index e514dc3..bd5c043 100644 --- a/components/content_capture/android/content_capture_receiver_manager_android.cc +++ b/components/content_capture/android/content_capture_receiver_manager_android.cc
@@ -113,6 +113,21 @@ jdata); } +void ContentCaptureReceiverManagerAndroid::DidUpdateContent( + const ContentCaptureSession& parent_session, + const ContentCaptureData& data) { + JNIEnv* env = AttachCurrentThread(); + DCHECK(java_ref_.obj()); + + ScopedJavaLocalRef<jobject> jdata = + ToJavaObjectOfContentCaptureData(env, data, JavaRef<jobject>()); + if (jdata.is_null()) + return; + Java_ContentCaptureReceiverManager_didUpdateContent( + env, java_ref_, ToJavaArrayOfContentCaptureData(env, parent_session), + jdata); +} + void ContentCaptureReceiverManagerAndroid::DidRemoveContent( const ContentCaptureSession& session, const std::vector<int64_t>& data) {
diff --git a/components/content_capture/android/content_capture_receiver_manager_android.h b/components/content_capture/android/content_capture_receiver_manager_android.h index 12a9b32..1223e44 100644 --- a/components/content_capture/android/content_capture_receiver_manager_android.h +++ b/components/content_capture/android/content_capture_receiver_manager_android.h
@@ -24,6 +24,8 @@ void DidCaptureContent(const ContentCaptureSession& parent_session, const ContentCaptureData& data) override; + void DidUpdateContent(const ContentCaptureSession& parent_session, + const ContentCaptureData& data) override; void DidRemoveContent(const ContentCaptureSession& session, const std::vector<int64_t>& data) override; void DidRemoveSession(const ContentCaptureSession& session) override;
diff --git a/components/content_capture/android/java/src/org/chromium/components/content_capture/ContentCaptureConsumer.java b/components/content_capture/android/java/src/org/chromium/components/content_capture/ContentCaptureConsumer.java index aacf65d..f4f8d46 100644 --- a/components/content_capture/android/java/src/org/chromium/components/content_capture/ContentCaptureConsumer.java +++ b/components/content_capture/android/java/src/org/chromium/components/content_capture/ContentCaptureConsumer.java
@@ -24,6 +24,13 @@ FrameSession parentFrame, ContentCaptureData contentCaptureData); /** + * Invoked when the content is updated in a frame. + * @param parentFrame is the parent of the frame from that the content captured. + * @param contentCaptureData is the captured content tree, its root is the frame. + */ + public void onContentUpdated(FrameSession parentFrame, ContentCaptureData contentCaptureData) {} + + /** * Invoked when the session is removed * @param session is the removed frame. */
diff --git a/components/content_capture/android/java/src/org/chromium/components/content_capture/ContentCaptureReceiverManager.java b/components/content_capture/android/java/src/org/chromium/components/content_capture/ContentCaptureReceiverManager.java index f6d7e8f..3654a5e 100644 --- a/components/content_capture/android/java/src/org/chromium/components/content_capture/ContentCaptureReceiverManager.java +++ b/components/content_capture/android/java/src/org/chromium/components/content_capture/ContentCaptureReceiverManager.java
@@ -41,6 +41,14 @@ } @CalledByNative + private void didUpdateContent(Object[] session, ContentCaptureData data) { + if (mContentCaptureConsumer != null) { + mContentCaptureConsumer.onContentUpdated(toFrameSession(session), data); + } + if (sDump.booleanValue()) Log.i(TAG, "Updated Content: %s", data); + } + + @CalledByNative private void didRemoveContent(Object[] session, long[] data) { FrameSession frameSession = toFrameSession(session); if (mContentCaptureConsumer != null)
diff --git a/components/content_capture/browser/content_capture_receiver.cc b/components/content_capture/browser/content_capture_receiver.cc index b0573e95..6c74d643 100644 --- a/components/content_capture/browser/content_capture_receiver.cc +++ b/components/content_capture/browser/content_capture_receiver.cc
@@ -49,7 +49,7 @@ frame_content_capture_data_.value = data.value; frame_content_capture_data_.bounds = data.bounds; } - // We can't avoid copy the data here, because id need to be overriden. + // We can't avoid copy the data here, because id need to be overridden. ContentCaptureData content(data); content.id = id_; // Always have frame URL attached, since the ContentCaptureConsumer will @@ -59,6 +59,16 @@ manager->DidCaptureContent(this, content); } +void ContentCaptureReceiver::DidUpdateContent(const ContentCaptureData& data) { + auto* manager = ContentCaptureReceiverManager::FromWebContents( + content::WebContents::FromRenderFrameHost(rfh_)); + // We can't avoid copy the data here, because id need to be overridden. + ContentCaptureData content(data); + content.id = id_; + content.value = frame_content_capture_data_.value; + manager->DidUpdateContent(this, content); +} + void ContentCaptureReceiver::DidRemoveContent( const std::vector<int64_t>& data) { auto* manager = ContentCaptureReceiverManager::FromWebContents(
diff --git a/components/content_capture/browser/content_capture_receiver.h b/components/content_capture/browser/content_capture_receiver.h index f3a6522..66184a94 100644 --- a/components/content_capture/browser/content_capture_receiver.h +++ b/components/content_capture/browser/content_capture_receiver.h
@@ -32,6 +32,7 @@ // mojom::ContentCaptureReceiver void DidCaptureContent(const ContentCaptureData& data, bool first_data) override; + void DidUpdateContent(const ContentCaptureData& data) override; void DidRemoveContent(const std::vector<int64_t>& data) override; void StartCapture(); void StopCapture();
diff --git a/components/content_capture/browser/content_capture_receiver_manager.cc b/components/content_capture/browser/content_capture_receiver_manager.cc index 98bcbe1..56441eed 100644 --- a/components/content_capture/browser/content_capture_receiver_manager.cc +++ b/components/content_capture/browser/content_capture_receiver_manager.cc
@@ -105,6 +105,15 @@ DidCaptureContent(parent_session, data); } +void ContentCaptureReceiverManager::DidUpdateContent( + ContentCaptureReceiver* content_capture_receiver, + const ContentCaptureData& data) { + ContentCaptureSession parent_session; + BuildContentCaptureSession(content_capture_receiver, true /* ancestor_only */, + &parent_session); + DidUpdateContent(parent_session, data); +} + void ContentCaptureReceiverManager::DidRemoveContent( ContentCaptureReceiver* content_capture_receiver, const std::vector<int64_t>& data) {
diff --git a/components/content_capture/browser/content_capture_receiver_manager.h b/components/content_capture/browser/content_capture_receiver_manager.h index 2e16c4d..79bb2cf2 100644 --- a/components/content_capture/browser/content_capture_receiver_manager.h +++ b/components/content_capture/browser/content_capture_receiver_manager.h
@@ -43,6 +43,8 @@ // The methods called by ContentCaptureReceiver. void DidCaptureContent(ContentCaptureReceiver* content_capture_receiver, const ContentCaptureData& data); + void DidUpdateContent(ContentCaptureReceiver* content_capture_receiver, + const ContentCaptureData& data); void DidRemoveContent(ContentCaptureReceiver* content_capture_receiver, const std::vector<int64_t>& data); void DidRemoveSession(ContentCaptureReceiver* content_capture_receiver); @@ -62,6 +64,10 @@ // received. virtual void DidCaptureContent(const ContentCaptureSession& parent_session, const ContentCaptureData& data) = 0; + // Invoked when the updated content |data| from the |parent_session| was + // received. + virtual void DidUpdateContent(const ContentCaptureSession& parent_session, + const ContentCaptureData& data) = 0; // Invoked when the list of content |ids| of the given |session| was removed. virtual void DidRemoveContent(const ContentCaptureSession& session, const std::vector<int64_t>& ids) = 0;
diff --git a/components/content_capture/browser/content_capture_receiver_test.cc b/components/content_capture/browser/content_capture_receiver_test.cc index 7c411e0..fcb66dd 100644 --- a/components/content_capture/browser/content_capture_receiver_test.cc +++ b/components/content_capture/browser/content_capture_receiver_test.cc
@@ -32,6 +32,10 @@ content_capture_receiver_->DidCaptureContent(captured_content, first_data); } + void DidUpdateContent(const ContentCaptureData& captured_content) { + content_capture_receiver_->DidUpdateContent(captured_content); + } + void DidRemoveContent(const std::vector<int64_t>& data) { content_capture_receiver_->DidRemoveContent(data); } @@ -64,6 +68,12 @@ captured_data_ = data; } + void DidUpdateContent(const ContentCaptureSession& parent_session, + const ContentCaptureData& data) override { + updated_parent_session_ = parent_session; + updated_data_ = data; + } + void DidRemoveContent(const ContentCaptureSession& session, const std::vector<int64_t>& ids) override { session_ = session; @@ -80,10 +90,16 @@ return parent_session_; } + const ContentCaptureSession& updated_parent_session() const { + return updated_parent_session_; + } + const ContentCaptureSession& session() const { return session_; } const ContentCaptureData& captured_data() const { return captured_data_; } + const ContentCaptureData& updated_data() const { return updated_data_; } + const ContentCaptureSession& removed_session() const { return removed_session_; } @@ -92,8 +108,10 @@ private: ContentCaptureSession parent_session_; + ContentCaptureSession updated_parent_session_; ContentCaptureSession session_; ContentCaptureData captured_data_; + ContentCaptureData updated_data_; std::vector<int64_t> removed_ids_; ContentCaptureSession removed_session_; }; @@ -127,6 +145,16 @@ test_data2_.value = base::ASCIIToUTF16(kChildFrameUrl); test_data2_.bounds = gfx::Rect(10, 10); test_data2_.children.push_back(child); + + ContentCaptureData child_change; + // Same ID with child. + child_change.id = 2; + child_change.value = base::ASCIIToUTF16("Hello World"); + child_change.bounds = gfx::Rect(5, 5, 5, 5); + test_data_change_.value = base::ASCIIToUTF16(kMainFrameUrl); + test_data_change_.bounds = gfx::Rect(10, 10); + test_data_change_.children.push_back(child_change); + // Update to test_data_. ContentCaptureData child2; // Have the unique id for text content. @@ -162,6 +190,9 @@ } const ContentCaptureData& test_data() const { return test_data_; } + const ContentCaptureData& test_data_change() const { + return test_data_change_; + } const ContentCaptureData& test_data2() const { return test_data2_; } const ContentCaptureData& test_data_update() const { return test_data_update_; @@ -178,6 +209,13 @@ return expected; } + ContentCaptureData GetExpectedTestDataChange(int64_t expected_id) const { + ContentCaptureData expected(test_data_change_); + // Replaces the id with expected id. + expected.id = expected_id; + return expected; + } + ContentCaptureData GetExpectedTestData2(bool main_frame) const { ContentCaptureData expected(test_data2_); // Replaces the id with expected id. @@ -226,6 +264,12 @@ run_loop.RunUntilIdle(); } + void DidUpdateContent(const ContentCaptureData& updated_content) { + base::RunLoop run_loop; + content_capture_sender()->DidUpdateContent(updated_content); + run_loop.RunUntilIdle(); + } + void DidRemoveContent(const std::vector<int64_t>& data) { base::RunLoop run_loop; content_capture_sender()->DidRemoveContent(data); @@ -244,6 +288,7 @@ content::RenderFrameHost* main_frame_ = nullptr; content::RenderFrameHost* child_frame_ = nullptr; ContentCaptureData test_data_; + ContentCaptureData test_data_change_; ContentCaptureData test_data2_; ContentCaptureData test_data_update_; // Expected removed Ids. @@ -281,6 +326,27 @@ content_capture_receiver_manager_helper()->captured_data()); } +TEST_F(ContentCaptureReceiverTest, DidUpdateContent) { + DidCaptureContent(test_data(), true /* first_data */); + EXPECT_TRUE( + content_capture_receiver_manager_helper()->parent_session().empty()); + EXPECT_TRUE( + content_capture_receiver_manager_helper()->removed_session().empty()); + ContentCaptureData expected_data = GetExpectedTestData(true /* main_frame */); + EXPECT_EQ(expected_data, + content_capture_receiver_manager_helper()->captured_data()); + + // Simulate content change. + DidUpdateContent(test_data_change()); + EXPECT_TRUE(content_capture_receiver_manager_helper() + ->updated_parent_session() + .empty()); + EXPECT_TRUE( + content_capture_receiver_manager_helper()->removed_session().empty()); + EXPECT_EQ(GetExpectedTestDataChange(expected_data.id), + content_capture_receiver_manager_helper()->updated_data()); +} + TEST_F(ContentCaptureReceiverTest, DidRemoveSession) { DidCaptureContent(test_data(), true /* first_data */); // Verifies to get test_data() with correct frame content id.
diff --git a/components/content_capture/common/content_capture.mojom b/components/content_capture/common/content_capture.mojom index a659142..6344a3d 100644 --- a/components/content_capture/common/content_capture.mojom +++ b/components/content_capture/common/content_capture.mojom
@@ -6,13 +6,20 @@ import "components/content_capture/common/content_capture_data.mojom"; -// The interface has one instance per RenderFrameHost in the browser -// process. All methods are called by renderer. +// This interface helps extract the data of the current page from the +// renderer, each ContentCaptureData represents the on-screen text +// content. The interface has one instance per RenderFrameHost in the +// browser process. All methods are called by renderer. interface ContentCaptureReceiver { // Invoked when the |data| is captured, |first_data| indicates if // this is first data from the document. DidCaptureContent(ContentCaptureData data, bool first_data); + // Invoked to notify that the |data| which has already been captured is + // updated, if |data| hasn't previously been captured, it will simply be + // ignored. + DidUpdateContent(ContentCaptureData data); + // Invoked to notify that a list of content |ids| has been removed. DidRemoveContent(array<int64> ids); };
diff --git a/components/content_capture/renderer/content_capture_sender.cc b/components/content_capture/renderer/content_capture_sender.cc index 15f4bdd0..d7b87cb 100644 --- a/components/content_capture/renderer/content_capture_sender.cc +++ b/components/content_capture/renderer/content_capture_sender.cc
@@ -51,26 +51,16 @@ const std::vector<scoped_refptr<blink::WebContentHolder>>& data, bool first_data) { ContentCaptureData frame_data; - FillContentCaptureData(&frame_data, first_data /* set_url */); - - frame_data.children.reserve(data.size()); - base::TimeTicks start = base::TimeTicks::Now(); - for (auto holder : data) { - ContentCaptureData child; - child.id = holder->GetId(); - child.value = holder->GetValue().Utf16(); - child.bounds = holder->GetBoundingBox(); - frame_data.children.push_back(child); - } - UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES( - "ContentCapture.GetBoundingBox", base::TimeTicks::Now() - start, - base::TimeDelta::FromMicroseconds(1), - base::TimeDelta::FromMilliseconds(10), 50); + FillContentCaptureData(data, &frame_data, first_data /* set_url */); GetContentCaptureReceiver()->DidCaptureContent(frame_data, first_data); } void ContentCaptureSender::DidUpdateContent( - const std::vector<scoped_refptr<blink::WebContentHolder>>& data) {} + const std::vector<scoped_refptr<blink::WebContentHolder>>& data) { + ContentCaptureData frame_data; + FillContentCaptureData(data, &frame_data, false /* set_url */); + GetContentCaptureReceiver()->DidUpdateContent(frame_data); +} void ContentCaptureSender::DidRemoveContent(const std::vector<int64_t>& data) { GetContentCaptureReceiver()->DidRemoveContent(data); @@ -88,13 +78,28 @@ base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); } -void ContentCaptureSender::FillContentCaptureData(ContentCaptureData* data, - bool set_url) { +void ContentCaptureSender::FillContentCaptureData( + const std::vector<scoped_refptr<blink::WebContentHolder>>& node_holders, + ContentCaptureData* data, + bool set_url) { data->bounds = render_frame()->GetWebFrame()->VisibleContentRect(); if (set_url) { data->value = render_frame()->GetWebFrame()->GetDocument().Url().GetString().Utf16(); } + data->children.reserve(node_holders.size()); + base::TimeTicks start = base::TimeTicks::Now(); + for (auto holder : node_holders) { + ContentCaptureData child; + child.id = holder->GetId(); + child.value = holder->GetValue().Utf16(); + child.bounds = holder->GetBoundingBox(); + data->children.push_back(child); + } + UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES( + "ContentCapture.GetBoundingBox", base::TimeTicks::Now() - start, + base::TimeDelta::FromMicroseconds(1), + base::TimeDelta::FromMilliseconds(10), 50); } const mojom::ContentCaptureReceiverAssociatedPtr&
diff --git a/components/content_capture/renderer/content_capture_sender.h b/components/content_capture/renderer/content_capture_sender.h index bf82396..5634b52 100644 --- a/components/content_capture/renderer/content_capture_sender.h +++ b/components/content_capture/renderer/content_capture_sender.h
@@ -54,7 +54,10 @@ void OnDestruct() override; private: - void FillContentCaptureData(ContentCaptureData* data, bool set_url); + void FillContentCaptureData( + const std::vector<scoped_refptr<blink::WebContentHolder>>& node_holders, + ContentCaptureData* data, + bool set_url); const mojom::ContentCaptureReceiverAssociatedPtr& GetContentCaptureReceiver(); mojom::ContentCaptureReceiverAssociatedPtr content_capture_receiver_ =
diff --git a/components/cronet/ios/BUILD.gn b/components/cronet/ios/BUILD.gn index f326fa7..4a5711e 100644 --- a/components/cronet/ios/BUILD.gn +++ b/components/cronet/ios/BUILD.gn
@@ -47,7 +47,8 @@ "//components/cronet/native:cronet_native_impl", "//components/grpc_support", "//components/prefs:prefs", - "//ios/net:net", + "//ios/net", + "//ios/net:network_protocol", "//ios/web/public:user_agent", "//ios/web/public/global_state", "//net",
diff --git a/components/heap_profiling/client_connection_manager.cc b/components/heap_profiling/client_connection_manager.cc index 59865ba..3aa5383 100644 --- a/components/heap_profiling/client_connection_manager.cc +++ b/components/heap_profiling/client_connection_manager.cc
@@ -49,7 +49,7 @@ // Binds to the local connector to get the browser process' ProfilingClient. explicit ProfilingClientBinder(service_manager::Connector* connector) : ProfilingClientBinder() { - connector->BindInterface(content::mojom::kBrowserServiceName, + connector->BindInterface(content::mojom::kSystemServiceName, std::move(request_)); }
diff --git a/components/management_strings.grdp b/components/management_strings.grdp index d3dd19d..d3e355f 100644 --- a/components/management_strings.grdp +++ b/components/management_strings.grdp
@@ -47,15 +47,12 @@ <!-- Browser managed status section --> <if expr="not chromeos"> - <message name="IDS_MANAGEMENT_BROWSER_NOTICE" desc="Message indicating that the browser is managed by an unknown organization"> - This browser is managed by a company, school or other organization. Your administrator can change your browser setup remotely. Activity on this device may also be managed outside of Chrome. <ph name="BEGIN_LINK"><a target="_blank" href="$1"></ph>Learn More<ph name="END_LINK"></a></ph> + <message name="IDS_MANAGEMENT_BROWSER_NOTICE" desc="Message shown when the browser is managed, it indicates what the administrator can do on the browser."> + Your administrator can change your browser setup remotely. Activity on this device may also be managed outside of Chrome. <ph name="BEGIN_LINK"><a target="_blank" href="$1"></ph>Learn More<ph name="END_LINK"></a></ph> </message> <message name="IDS_MANAGEMENT_NOT_MANAGED_NOTICE" desc="Message indicating that the browser is not managed"> This browser is not managed by a company or other organization. Activity on this device may be managed outside of Chrome. <ph name="BEGIN_LINK"><a target="_blank" href="$1"></ph>Learn More<ph name="END_LINK"></a></ph> </message> - <message name="IDS_MANAGEMENT_MANAGEMENT_BY_NOTICE" desc="Message indicating that the browser is managed by a known organization"> - This browser is managed by <ph name="ENROLLMENT_DOMAIN">$1<ex>example.com</ex></ph>. Your administrator can change your browser setup remotely. Activity on this device may also be managed outside of Chrome. <ph name="BEGIN_LINK"><a target="_blank" href="$2"></ph>Learn More<ph name="END_LINK"></a></ph> - </message> </if> <!-- Chrome OS managed status section --> @@ -63,9 +60,6 @@ <message name="IDS_MANAGEMENT_DEVICE_NOT_MANAGED" desc="Message indicating that the device and account are not managed"> This device and account are not managed by a company or other organization. </message> - <message name="IDS_MANAGEMENT_DEVICE_MANAGED_BY" desc="Message indicating that the device is enterprise enrolled to be managed by an administrator, from a specific domain"> - Your device is managed by <ph name="ENROLLMENT_DOMAIN">$1<ex>example.com</ex></ph>. - </message> <message name="IDS_MANAGEMENT_DEVICE_MANAGED_BY_ACCOUNT_MANAGED_BY" desc="Message indicating that the device is enterprise enrolled to be managed by an administrator, from a specific domain. And account is managed by an administrator, from another specific domain."> Your device is managed by <ph name="ENROLLMENT_DOMAIN">$1<ex>example.com</ex></ph> and your account is managed by <ph name="ACCOUNT_DOMAIN">$2<ex>example.com</ex></ph>. </message>
diff --git a/components/metrics/BUILD.gn b/components/metrics/BUILD.gn index 8832d0c..2936b894 100644 --- a/components/metrics/BUILD.gn +++ b/components/metrics/BUILD.gn
@@ -81,11 +81,8 @@ "metrics_switches.h", "metrics_upload_scheduler.cc", "metrics_upload_scheduler.h", - "unsent_log_store.cc", - "unsent_log_store.h", - "unsent_log_store_metrics.h", - "unsent_log_store_metrics_impl.cc", - "unsent_log_store_metrics_impl.h", + "persistent_histograms.cc", + "persistent_histograms.h", "persistent_system_profile.cc", "persistent_system_profile.h", "reporting_service.cc", @@ -99,6 +96,11 @@ "system_memory_stats_recorder_win.cc", "system_session_analyzer_win.cc", "system_session_analyzer_win.h", + "unsent_log_store.cc", + "unsent_log_store.h", + "unsent_log_store_metrics.h", + "unsent_log_store_metrics_impl.cc", + "unsent_log_store_metrics_impl.h", "url_constants.cc", "url_constants.h", "version_utils.cc", @@ -380,7 +382,6 @@ "metrics_state_manager_unittest.cc", "net/net_metrics_log_uploader_unittest.cc", "net/network_metrics_provider_unittest.cc", - "unsent_log_store_unittest.cc", "persistent_system_profile_unittest.cc", "reporting_service_unittest.cc", "single_sample_metrics_factory_impl_unittest.cc", @@ -388,6 +389,7 @@ "stability_metrics_provider_unittest.cc", "system_session_analyzer_win_unittest.cc", "ui/screen_info_metrics_provider_unittest.cc", + "unsent_log_store_unittest.cc", ] deps = [
diff --git a/chrome/browser/metrics/persistent_histograms.cc b/components/metrics/persistent_histograms.cc similarity index 95% rename from chrome/browser/metrics/persistent_histograms.cc rename to components/metrics/persistent_histograms.cc index 492414c..4be700d2 100644 --- a/chrome/browser/metrics/persistent_histograms.cc +++ b/components/metrics/persistent_histograms.cc
@@ -2,20 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/metrics/persistent_histograms.h" +#include "components/metrics/persistent_histograms.h" #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram_macros.h" #include "base/metrics/persistent_histogram_allocator.h" -#include "base/path_service.h" #include "base/system/sys_info.h" #include "base/task/post_task.h" #include "build/build_config.h" -#include "chrome/common/chrome_paths.h" #include "components/metrics/persistent_system_profile.h" #include "components/variations/variations_associated_data.h" @@ -41,11 +38,7 @@ // Check for feature enabling the use of persistent histogram storage and // enable the global allocator if so. -void InstantiatePersistentHistograms() { - base::FilePath metrics_dir; - if (!base::PathService::Get(chrome::DIR_USER_DATA, &metrics_dir)) - return; - +void InstantiatePersistentHistograms(const base::FilePath& metrics_dir) { // Create a directory for storing completed metrics files. Files in this // directory must have embedded system profiles. If the directory can't be // created, the file will just be deleted below.
diff --git a/chrome/browser/metrics/persistent_histograms.h b/components/metrics/persistent_histograms.h similarity index 61% rename from chrome/browser/metrics/persistent_histograms.h rename to components/metrics/persistent_histograms.h index 0bae8f76..72ef923d 100644 --- a/chrome/browser/metrics/persistent_histograms.h +++ b/components/metrics/persistent_histograms.h
@@ -2,17 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_METRICS_PERSISTENT_HISTOGRAMS_H_ -#define CHROME_BROWSER_METRICS_PERSISTENT_HISTOGRAMS_H_ +#ifndef COMPONENTS_METRICS_PERSISTENT_HISTOGRAMS_H_ +#define COMPONENTS_METRICS_PERSISTENT_HISTOGRAMS_H_ + +#include "base/files/file_path.h" // Persistent browser metrics need to be persisted somewhere. This constant // provides a known string to be used for both the allocator's internal name -// and for a file on disk (relative to chrome::DIR_USER_DATA) to which they +// and for a file on disk (relative to metrics_dir) to which they // can be saved. This is exported so the name can also be used as a "pref" // during configuration. extern const char kBrowserMetricsName[]; // Do all the checking and work necessary to enable persistent histograms. -void InstantiatePersistentHistograms(); +void InstantiatePersistentHistograms(const base::FilePath& metrics_dir); -#endif // CHROME_BROWSER_METRICS_PERSISTENT_HISTOGRAMS_H_ +#endif // COMPONENTS_METRICS_PERSISTENT_HISTOGRAMS_H_
diff --git a/components/mirroring/service/manifest.cc b/components/mirroring/service/manifest.cc index eda50b24..357a325 100644 --- a/components/mirroring/service/manifest.cc +++ b/components/mirroring/service/manifest.cc
@@ -22,7 +22,7 @@ .ExposeCapability("mirroring", service_manager::Manifest::InterfaceList< mojom::MirroringService>()) - .RequireCapability("content_browser", "gpu_client") + .RequireCapability("content_system", "gpu_client") .RequireCapability("ui", "gpu_client") .Build()};
diff --git a/components/mirroring/service/mirroring_service.cc b/components/mirroring/service/mirroring_service.cc index 7d18f84f..4bb1e26 100644 --- a/components/mirroring/service/mirroring_service.cc +++ b/components/mirroring/service/mirroring_service.cc
@@ -60,7 +60,7 @@ if (params->type != mojom::SessionType::AUDIO_ONLY) { gpu = ws::Gpu::Create( service_binding_.GetConnector(), - features::IsUsingWindowService() ? "ui" : "content_browser", + features::IsUsingWindowService() ? "ui" : "content_system", io_task_runner_); } session_ = std::make_unique<Session>(
diff --git a/components/nacl/common/nacl_service.cc b/components/nacl/common/nacl_service.cc index 74d8b64c..4648333 100644 --- a/components/nacl/common/nacl_service.cc +++ b/components/nacl/common/nacl_service.cc
@@ -87,7 +87,7 @@ void OnBindInterface(const service_manager::BindSourceInfo& source_info, const std::string& interface_name, mojo::ScopedMessagePipeHandle interface_pipe) override { - if (source_info.identity.name() == content::mojom::kBrowserServiceName && + if (source_info.identity.name() == content::mojom::kSystemServiceName && interface_name == IPC::mojom::ChannelBootstrap::Name_ && !connected_) { connected_ = true; mojo::FuseInterface(
diff --git a/components/net_log/net_export_file_writer.cc b/components/net_log/net_export_file_writer.cc index 6f26a179..462818e 100644 --- a/components/net_log/net_export_file_writer.cc +++ b/components/net_log/net_export_file_writer.cc
@@ -184,20 +184,11 @@ if (!net_log_exporter_) return; - network::mojom::NetLogCaptureMode rpc_capture_mode = - network::mojom::NetLogCaptureMode::DEFAULT; - if (capture_mode.include_socket_bytes()) { - rpc_capture_mode = network::mojom::NetLogCaptureMode::INCLUDE_SOCKET_BYTES; - } else if (capture_mode.include_cookies_and_credentials()) { - rpc_capture_mode = - network::mojom::NetLogCaptureMode::INCLUDE_COOKIES_AND_CREDENTIALS; - } - // base::Unretained(this) is safe here since |net_log_exporter_| is owned by // |this| and is a mojo InterfacePtr, which guarantees callback cancellation // upon its destruction. net_log_exporter_->Start( - std::move(output_file), std::move(custom_constants), rpc_capture_mode, + std::move(output_file), std::move(custom_constants), capture_mode, max_file_size, base::BindOnce(&NetExportFileWriter::OnStartResult, base::Unretained(this), capture_mode));
diff --git a/components/net_log/net_export_file_writer_unittest.cc b/components/net_log/net_export_file_writer_unittest.cc index f5e6d3d..2d628d7 100644 --- a/components/net_log/net_export_file_writer_unittest.cc +++ b/components/net_log/net_export_file_writer_unittest.cc
@@ -68,7 +68,7 @@ void Start(base::File destination, base::Value extra_constants, - network::mojom::NetLogCaptureMode capture_mode, + net::NetLogCaptureMode capture_mode, uint64_t max_file_size, StartCallback callback) override { std::move(callback).Run(net::OK);
diff --git a/components/omnibox/browser/autocomplete_controller.cc b/components/omnibox/browser/autocomplete_controller.cc index c1e692d..40100e56 100644 --- a/components/omnibox/browser/autocomplete_controller.cc +++ b/components/omnibox/browser/autocomplete_controller.cc
@@ -653,9 +653,6 @@ void AutocompleteController::UpdateKeywordDescriptions( AutocompleteResult* result) { - bool show_suffix_on_all_search_suggestions = base::FeatureList::IsEnabled( - omnibox::kUIExperimentShowSuffixOnAllSearchSuggestions); - base::string16 last_keyword; for (auto i(result->begin()); i != result->end(); ++i) { if (AutocompleteMatch::IsSearchType(i->type)) { @@ -664,8 +661,7 @@ i->description.clear(); i->description_class.clear(); DCHECK(!i->keyword.empty()); - if (show_suffix_on_all_search_suggestions || - (i->keyword != last_keyword && + if ((i->keyword != last_keyword && !ShouldCurbKeywordDescriptions(i->keyword))) { const TemplateURL* template_url = i->GetTemplateURL(template_url_service_, false);
diff --git a/components/omnibox/browser/omnibox_view.cc b/components/omnibox/browser/omnibox_view.cc index 7ea1a21f3..8ac77da 100644 --- a/components/omnibox/browser/omnibox_view.cc +++ b/components/omnibox/browser/omnibox_view.cc
@@ -110,7 +110,6 @@ // want to consider reusing the same code for both the popup and omnibox icons. gfx::ImageSkia OmniboxView::GetIcon(int dip_size, SkColor color, - SkColor search_alternate_color, IconFetchedCallback on_icon_fetched) const { #if defined(OS_ANDROID) || defined(OS_IOS) // This is used on desktop only. @@ -168,15 +167,6 @@ const gfx::VectorIcon& vector_icon = match.GetVectorIcon(is_bookmarked); - // When the blue search loop experiment is enabled, the in-omnibox vector - // icon for search type matches should be blue as well. This icon is used if - // the default search engine favicon has not yet been fetched, or is disabled. - if (base::FeatureList::IsEnabled( - omnibox::kUIExperimentBlueSearchLoopAndSearchQuery) && - AutocompleteMatch::IsSearchType(match.type)) { - return gfx::CreateVectorIcon(vector_icon, dip_size, search_alternate_color); - } - return gfx::CreateVectorIcon(vector_icon, dip_size, color); #endif // defined(OS_ANDROID) || defined(OS_IOS) }
diff --git a/components/omnibox/browser/omnibox_view.h b/components/omnibox/browser/omnibox_view.h index 535089c8..4f8d682 100644 --- a/components/omnibox/browser/omnibox_view.h +++ b/components/omnibox/browser/omnibox_view.h
@@ -91,11 +91,8 @@ // Returns the icon to display as the location icon. If a favicon is // available, |on_icon_fetched| may be called later asynchronously. - // |search_alternate_color| should match the color used for URL text, and may - // be used for search suggestions depending on some flags. gfx::ImageSkia GetIcon(int dip_size, SkColor color, - SkColor search_alternate_color, IconFetchedCallback on_icon_fetched) const; // The user text is the text the user has manually keyed in. When present,
diff --git a/components/omnibox/browser/omnibox_view_unittest.cc b/components/omnibox/browser/omnibox_view_unittest.cc index 628b261..1d3c68d 100644 --- a/components/omnibox/browser/omnibox_view_unittest.cc +++ b/components/omnibox/browser/omnibox_view_unittest.cc
@@ -145,9 +145,8 @@ gfx::ImageSkia expected_icon = gfx::CreateVectorIcon( vector_icons::kSearchIcon, gfx::kFaviconSize, gfx::kPlaceholderColor); - gfx::ImageSkia icon = - view()->GetIcon(gfx::kFaviconSize, gfx::kPlaceholderColor, - gfx::kPlaceholderColor, base::DoNothing()); + gfx::ImageSkia icon = view()->GetIcon( + gfx::kFaviconSize, gfx::kPlaceholderColor, base::DoNothing()); EXPECT_EQ(icon.bitmap(), expected_icon.bitmap()); } @@ -166,9 +165,8 @@ gfx::ImageSkia expected_icon = gfx::CreateVectorIcon( omnibox::kBookmarkIcon, gfx::kFaviconSize, gfx::kPlaceholderColor); - gfx::ImageSkia icon = - view()->GetIcon(gfx::kFaviconSize, gfx::kPlaceholderColor, - gfx::kPlaceholderColor, base::DoNothing()); + gfx::ImageSkia icon = view()->GetIcon( + gfx::kFaviconSize, gfx::kPlaceholderColor, base::DoNothing()); EXPECT_EQ(icon.bitmap(), expected_icon.bitmap()); } @@ -182,8 +180,7 @@ match.destination_url = kUrl; model()->SetCurrentMatchForTest(match); - view()->GetIcon(gfx::kFaviconSize, gfx::kPlaceholderColor, - gfx::kPlaceholderColor, base::DoNothing()); + view()->GetIcon(gfx::kFaviconSize, gfx::kPlaceholderColor, base::DoNothing()); EXPECT_EQ(client()->GetPageUrlForLastFaviconRequest(), kUrl); }
diff --git a/components/omnibox/common/omnibox_features.cc b/components/omnibox/common/omnibox_features.cc index 7821bc40..920563a2 100644 --- a/components/omnibox/common/omnibox_features.cc +++ b/components/omnibox/common/omnibox_features.cc
@@ -228,61 +228,6 @@ "OmniboxUIExperimentVerticalMarginLimitToNonTouchOnly", base::FEATURE_DISABLED_BY_DEFAULT}; -// Feature used to color "blue" the generic search icon and search terms. -// Technically, this makes the search icon and search terms match the color of -// Omnibox link text, which is blue by convention. -const base::Feature kUIExperimentBlueSearchLoopAndSearchQuery{ - "OmniboxUIExperimentBlueSearchLoopAndSearchQuery", - base::FEATURE_DISABLED_BY_DEFAULT}; - -// Feature used to change the color of text in navigation suggestions. It -// changes title text from black to blue, and URL text from blue to gray. -const base::Feature kUIExperimentBlueTitlesAndGrayUrlsOnPageSuggestions{ - "OmniboxUIExperimentBlueTitlesAndGrayUrlsOnPageSuggestions", - base::FEATURE_DISABLED_BY_DEFAULT}; - -// Feature used to change the color of text in navigation suggestions. It -// changes title text from black to blue. -const base::Feature kUIExperimentBlueTitlesOnPageSuggestions{ - "OmniboxUIExperimentBlueTitlesOnPageSuggestions", - base::FEATURE_DISABLED_BY_DEFAULT}; - -// Feature used to show a " - Google Search", " - Bing Search", etc. suffix on -// all search suggestions instead of just the first one in each cluster. -const base::Feature kUIExperimentShowSuffixOnAllSearchSuggestions{ - "OmniboxUIExperimentShowSuffixOnAllSearchSuggestions", - base::FEATURE_DISABLED_BY_DEFAULT}; - -// Feature used to show a white background in the omnibox while it's unfocused. -// More technically, with this flag on, it uses the same background color as -// the results popup (conventionally white). -const base::Feature kUIExperimentWhiteBackgroundOnBlur{ - "OmniboxUIExperimentWhiteBackgroundOnBlur", - base::FEATURE_DISABLED_BY_DEFAULT}; - -// Feature used to show a generic vector icon for omnibox search instead of the -// search engine favicon. -// -// This feature flag's string has a typo: "Omnibox" => "Ominbox". -// Do not correct this typo, because this misspelled string is being used -// as-is in field trials. -const base::Feature kUIExperimentUseGenericSearchEngineIcon{ - "OminboxUIExperimentUseGenericSearchEngineIcon", - base::FEATURE_DISABLED_BY_DEFAULT}; - -// Feature used to bold the "user text" part of search suggestions instead -// of the "autocomplete" part. For example, if the user typed "point reyes", -// and the search suggestion was "point reyes weather", this feature makes -// the "point reyes" part of the suggestion bold, instead of "weather". -const base::Feature kUIExperimentBoldUserTextOnSearchSuggestions{ - "OmniboxUIExperimentBoldUserTextOnSearchSuggestions", - base::FEATURE_DISABLED_BY_DEFAULT}; - -// Feature used to unbold suggestion text. -const base::Feature kUIExperimentUnboldSuggestionText{ - "OmniboxUIExperimentUnboldSuggestionText", - base::FEATURE_DISABLED_BY_DEFAULT}; - // Shows the "Search Google or type a URL" omnibox placeholder even when the // caret (text edit cursor) is showing / when focused. views::Textfield works // this way, as does <input placeholder="">. Omnibox and the NTP's "fakebox"
diff --git a/components/omnibox/common/omnibox_features.h b/components/omnibox/common/omnibox_features.h index 24650684..aa4d0ad 100644 --- a/components/omnibox/common/omnibox_features.h +++ b/components/omnibox/common/omnibox_features.h
@@ -40,14 +40,6 @@ extern const base::Feature kUIExperimentSwapTitleAndUrl; extern const base::Feature kUIExperimentVerticalMargin; extern const base::Feature kUIExperimentVerticalMarginLimitToNonTouchOnly; -extern const base::Feature kUIExperimentBlueSearchLoopAndSearchQuery; -extern const base::Feature kUIExperimentBlueTitlesAndGrayUrlsOnPageSuggestions; -extern const base::Feature kUIExperimentBlueTitlesOnPageSuggestions; -extern const base::Feature kUIExperimentShowSuffixOnAllSearchSuggestions; -extern const base::Feature kUIExperimentBoldUserTextOnSearchSuggestions; -extern const base::Feature kUIExperimentWhiteBackgroundOnBlur; -extern const base::Feature kUIExperimentUseGenericSearchEngineIcon; -extern const base::Feature kUIExperimentUnboldSuggestionText; extern const base::Feature kUIExperimentShowPlaceholderWhenCaretShowing; extern const base::Feature kSpeculativeServiceWorkerStartOnQueryInput; extern const base::Feature kDocumentProvider;
diff --git a/components/safe_browsing/triggers/suspicious_site_trigger.cc b/components/safe_browsing/triggers/suspicious_site_trigger.cc index ad16a77..7d338b81 100644 --- a/components/safe_browsing/triggers/suspicious_site_trigger.cc +++ b/components/safe_browsing/triggers/suspicious_site_trigger.cc
@@ -94,7 +94,7 @@ security_interstitials::UnsafeResource resource; resource.threat_type = SB_THREAT_TYPE_SUSPICIOUS_SITE; - resource.url = web_contents()->GetURL(); + resource.url = web_contents()->GetLastCommittedURL(); resource.web_contents_getter = resource.GetWebContentsGetter( web_contents()->GetMainFrame()->GetProcess()->GetID(), web_contents()->GetMainFrame()->GetRoutingID());
diff --git a/components/safe_browsing/triggers/suspicious_site_trigger_unittest.cc b/components/safe_browsing/triggers/suspicious_site_trigger_unittest.cc index 48490da..17f8fdb0 100644 --- a/components/safe_browsing/triggers/suspicious_site_trigger_unittest.cc +++ b/components/safe_browsing/triggers/suspicious_site_trigger_unittest.cc
@@ -4,6 +4,8 @@ #include "components/safe_browsing/triggers/suspicious_site_trigger.h" +#include <string> + #include "base/test/metrics/histogram_tester.h" #include "base/test/test_simple_task_runner.h" #include "components/prefs/testing_pref_service.h" @@ -28,6 +30,12 @@ namespace { const char kSuspiciousUrl[] = "https://suspicious.com/"; const char kCleanUrl[] = "https://foo.com/"; +const char kCleanUrl2[] = "https://bar.com/"; + +// A matcher for the VisibleURLChangeMidLoad_Suspicious test. +MATCHER_P(ResourceHasUrl, gurl, "") { + return arg.url == gurl; +} } // namespace class SuspiciousSiteTriggerTest : public content::RenderViewHostTestHarness { @@ -79,6 +87,14 @@ return NavigateFrame(url, subframe); } + // Changes the visible URL (in the URL bar) without committing a navigation. + void ChangeVisibleURLWithoutNavigation(const std::string& url) { + GURL gurl(url); + auto navigation_simulator = + NavigationSimulator::CreateBrowserInitiated(gurl, web_contents()); + navigation_simulator->Start(); + } + void StartNewFakeLoad() { // This fakes a new LoadStart event in the trigger, since the navigation // simulator doesn't restart the load when we start a new navigation. @@ -422,4 +438,81 @@ ExpectEventHistogramCount(SuspiciousSiteTriggerEvent::REPORT_DELAY_TIMER, 0); ExpectNoReportRejection(); } -} // namespace safe_browsing \ No newline at end of file + +TEST_F(SuspiciousSiteTriggerTest, VisibleURLChangeMidLoad_NotSuspicious) { + // Exercise what happens when the visible URL changes during load and no + // suspicious site was detected. + CreateTrigger(/*monitor_mode=*/false); + + EXPECT_CALL(*get_trigger_manager(), + StartCollectingThreatDetailsWithReason(_, _, _, _, _, _, _)) + .Times(0); + EXPECT_CALL(*get_trigger_manager(), + FinishCollectingThreatDetails(_, _, _, _, _, _)) + .Times(0); + + NavigateMainFrame(kCleanUrl); + // Change visible URL by starting a new navigation without committing it. + // Sanity check the visible URL changed. + ChangeVisibleURLWithoutNavigation(kCleanUrl2); + GURL expected_clean_url_2(kCleanUrl2); + EXPECT_EQ(expected_clean_url_2, web_contents()->GetVisibleURL()); + FinishAllNavigations(); + + WaitForTaskRunnerIdle(); + + // One page load start and finish. No suspicious sites and no reports sent. + ExpectEventHistogramCount(SuspiciousSiteTriggerEvent::PAGE_LOAD_START, 1); + ExpectEventHistogramCount(SuspiciousSiteTriggerEvent::PAGE_LOAD_FINISH, 1); + ExpectEventHistogramCount( + SuspiciousSiteTriggerEvent::SUSPICIOUS_SITE_DETECTED, 0); + ExpectEventHistogramCount(SuspiciousSiteTriggerEvent::REPORT_STARTED, 0); + ExpectNoReportRejection(); +} + +TEST_F(SuspiciousSiteTriggerTest, VisibleURLChangeMidLoad_Suspicious) { + // Exercise what happens when the visible URL changes after a suspicious site + // has already been detected. + CreateTrigger(/*monitor_mode=*/false); + + NavigateMainFrame(kSuspiciousUrl); + + // The resource eventually sent to the trigger manager should include the + // original (suspicious) URL. + GURL suspicious_url(kSuspiciousUrl); + EXPECT_CALL(*get_trigger_manager(), + StartCollectingThreatDetailsWithReason( + _, _, ResourceHasUrl(suspicious_url), _, _, _, _)) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*get_trigger_manager(), + FinishCollectingThreatDetails(_, _, _, _, _, _)) + .Times(1) + .WillOnce(Return(true)); + + // Change visible URL by starting a new navigation without committing it. + // Sanity check the visible URL changed. + ChangeVisibleURLWithoutNavigation(kCleanUrl); + GURL expected_clean_url(kCleanUrl); + EXPECT_EQ(expected_clean_url, web_contents()->GetVisibleURL()); + TriggerSuspiciousSite(); + FinishAllNavigations(); + + WaitForTaskRunnerIdle(); + + // One page load start and finish. One suspicious site detected and one + // report started and sent after the page finished loading. + ExpectEventHistogramCount(SuspiciousSiteTriggerEvent::PAGE_LOAD_START, 1); + ExpectEventHistogramCount(SuspiciousSiteTriggerEvent::PAGE_LOAD_FINISH, 1); + ExpectEventHistogramCount( + SuspiciousSiteTriggerEvent::SUSPICIOUS_SITE_DETECTED, 1); + ExpectEventHistogramCount(SuspiciousSiteTriggerEvent::REPORT_STARTED, 1); + + // Ensure the delay timer fired and it happened in the REPORT_STARTED state + ExpectEventHistogramCount(SuspiciousSiteTriggerEvent::REPORT_DELAY_TIMER, 1); + ExpectDelayStateHistogramCount( + SuspiciousSiteTrigger::TriggerState::REPORT_STARTED, 1); + ExpectEventHistogramCount(SuspiciousSiteTriggerEvent::REPORT_FINISHED, 1); + ExpectNoReportRejection(); +} +} // namespace safe_browsing
diff --git a/components/services/pdf_compositor/pdf_compositor_service.cc b/components/services/pdf_compositor/pdf_compositor_service.cc index d7a44dc5..517ed845 100644 --- a/components/services/pdf_compositor/pdf_compositor_service.cc +++ b/components/services/pdf_compositor/pdf_compositor_service.cc
@@ -19,7 +19,6 @@ #include "mojo/public/cpp/bindings/strong_binding.h" #include "services/service_manager/public/cpp/connector.h" #include "services/ws/public/mojom/constants.mojom.h" -#include "ui/base/ui_base_features.h" #if defined(OS_WIN) #include "content/public/child/dwrite_font_proxy_init_win.h" @@ -73,17 +72,8 @@ // Set up discardable memory manager. discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; - if (features::IsMultiProcessMash()) { -#if defined(USE_AURA) - binding_.GetConnector()->BindInterface(ws::mojom::kServiceName, - &manager_ptr); -#else - NOTREACHED(); -#endif - } else { - binding_.GetConnector()->BindInterface(content::mojom::kBrowserServiceName, - &manager_ptr); - } + binding_.GetConnector()->BindInterface(content::mojom::kSystemServiceName, + &manager_ptr); discardable_shared_memory_manager_ = std::make_unique< discardable_memory::ClientDiscardableSharedMemoryManager>( std::move(manager_ptr), content::UtilityThread::Get()->GetIOTaskRunner());
diff --git a/components/services/pdf_compositor/public/cpp/manifest.cc b/components/services/pdf_compositor/public/cpp/manifest.cc index 87c2108..400254cb 100644 --- a/components/services/pdf_compositor/public/cpp/manifest.cc +++ b/components/services/pdf_compositor/public/cpp/manifest.cc
@@ -24,8 +24,8 @@ .ExposeCapability( "compositor", service_manager::Manifest::InterfaceList<mojom::PdfCompositor>()) - .RequireCapability("content_browser", "app") - .RequireCapability("content_browser", "sandbox_support") + .RequireCapability("content_system", "app") + .RequireCapability("content_system", "sandbox_support") .RequireCapability("ui", "discardable_memory") .Build()}; return *manifest;
diff --git a/components/sync_sessions/synced_tab_delegate.h b/components/sync_sessions/synced_tab_delegate.h index d4043df..45ee11ab 100644 --- a/components/sync_sessions/synced_tab_delegate.h +++ b/components/sync_sessions/synced_tab_delegate.h
@@ -69,6 +69,11 @@ // tab should be preserved. virtual bool IsPlaceholderTab() const = 0; + // Task IDs represent navigations and relationships between navigations. -1 + // indicates the Task ID is unknown. A Navigation ID is a Unique ID and + // is stored on a NavigationEntry and SerialiedNavigationEntry. + virtual int64_t GetTaskIdForNavigationId(int nav_id) const = 0; + protected: SyncedTabDelegate(); };
diff --git a/components/sync_sessions/test_synced_window_delegates_getter.cc b/components/sync_sessions/test_synced_window_delegates_getter.cc index 8736388..4add4ea 100644 --- a/components/sync_sessions/test_synced_window_delegates_getter.cc +++ b/components/sync_sessions/test_synced_window_delegates_getter.cc
@@ -152,6 +152,12 @@ return SessionID::InvalidValue(); } +int64_t TestSyncedTabDelegate::GetTaskIdForNavigationId(int nav_id) const { + // Task IDs are currently not used in the tests. -1 signals an unknown Task + // ID. + return -1; +} + PlaceholderTabDelegate::PlaceholderTabDelegate(SessionID tab_id) : tab_id_(tab_id) {} @@ -236,6 +242,13 @@ return SessionID::InvalidValue(); } +int64_t PlaceholderTabDelegate::GetTaskIdForNavigationId(int nav_id) const { + // Task IDs are currently not used in the tests. -1 signals an unknown Task + // ID. + NOTREACHED() << "Task IDs are not used for Placeholder Tabs"; + return -1; +} + TestSyncedWindowDelegate::TestSyncedWindowDelegate( SessionID window_id, sync_pb::SessionWindow_BrowserType type)
diff --git a/components/sync_sessions/test_synced_window_delegates_getter.h b/components/sync_sessions/test_synced_window_delegates_getter.h index 20564f6..621beaf 100644 --- a/components/sync_sessions/test_synced_window_delegates_getter.h +++ b/components/sync_sessions/test_synced_window_delegates_getter.h
@@ -60,6 +60,7 @@ bool IsPlaceholderTab() const override; bool ShouldSync(SyncSessionsClient* sessions_client) override; SessionID GetSourceTabID() const override; + int64_t GetTaskIdForNavigationId(int nav_id) const override; private: const SessionID window_id_; @@ -106,6 +107,7 @@ GetBlockedNavigations() const override; bool ShouldSync(SyncSessionsClient* sessions_client) override; SessionID GetSourceTabID() const override; + int64_t GetTaskIdForNavigationId(int nav_id) const override; private: const SessionID tab_id_;
diff --git a/components/viz/host/host_display_client.cc b/components/viz/host/host_display_client.cc index ca788f5..f5e18df 100644 --- a/components/viz/host/host_display_client.cc +++ b/components/viz/host/host_display_client.cc
@@ -59,4 +59,10 @@ } #endif +#if defined(USE_X11) +void HostDisplayClient::DidCompleteSwapWithNewSize(const gfx::Size& size) { + NOTIMPLEMENTED(); +} +#endif + } // namespace viz
diff --git a/components/viz/host/host_display_client.h b/components/viz/host/host_display_client.h index af64385..5e5c5da4 100644 --- a/components/viz/host/host_display_client.h +++ b/components/viz/host/host_display_client.h
@@ -42,6 +42,10 @@ mojom::LayeredWindowUpdaterRequest request) override; #endif +#if defined(USE_X11) + void DidCompleteSwapWithNewSize(const gfx::Size& size) override; +#endif + mojo::Binding<mojom::DisplayClient> binding_; #if defined(OS_MACOSX) || defined(OS_WIN) gfx::AcceleratedWidget widget_;
diff --git a/components/viz/service/display/software_output_device.cc b/components/viz/service/display/software_output_device.cc index 6508266d..90b65bc 100644 --- a/components/viz/service/display/software_output_device.cc +++ b/components/viz/service/display/software_output_device.cc
@@ -4,6 +4,7 @@ #include "components/viz/service/display/software_output_device.h" +#include "base/bind.h" #include "base/logging.h" #include "base/threading/sequenced_task_runner_handle.h" #include "third_party/skia/include/core/SkCanvas.h" @@ -49,8 +50,10 @@ return vsync_provider_.get(); } -void SoftwareOutputDevice::OnSwapBuffers(base::OnceClosure swap_ack_callback) { - task_runner_->PostTask(FROM_HERE, std::move(swap_ack_callback)); +void SoftwareOutputDevice::OnSwapBuffers( + SwapBuffersCallback swap_ack_callback) { + task_runner_->PostTask(FROM_HERE, base::BindOnce(std::move(swap_ack_callback), + viewport_pixel_size_)); } } // namespace viz
diff --git a/components/viz/service/display/software_output_device.h b/components/viz/service/display/software_output_device.h index ac80d971..f7ad234 100644 --- a/components/viz/service/display/software_output_device.h +++ b/components/viz/service/display/software_output_device.h
@@ -66,11 +66,12 @@ // hardware vsync. Return null if a provider doesn't exist. virtual gfx::VSyncProvider* GetVSyncProvider(); + using SwapBuffersCallback = base::OnceCallback<void(const gfx::Size&)>; // Called from OutputSurface::SwapBuffers(). The default implementation will // immediately run |swap_ack_callback| via PostTask. If swap isn't synchronous // this can be overriden so that |swap_ack_callback| is run after swap // completes. - virtual void OnSwapBuffers(base::OnceClosure swap_ack_callback); + virtual void OnSwapBuffers(SwapBuffersCallback swap_ack_callback); protected: scoped_refptr<base::SequencedTaskRunner> task_runner_;
diff --git a/components/viz/service/display_embedder/software_output_device_win.cc b/components/viz/service/display_embedder/software_output_device_win.cc index 0fcded1..4e3f0255 100644 --- a/components/viz/service/display_embedder/software_output_device_win.cc +++ b/components/viz/service/display_embedder/software_output_device_win.cc
@@ -183,7 +183,7 @@ ~SoftwareOutputDeviceWinProxy() override = default; // SoftwareOutputDevice implementation. - void OnSwapBuffers(base::OnceClosure swap_ack_callback) override; + void OnSwapBuffers(SwapBuffersCallback swap_ack_callback) override; // SoftwareOutputDeviceWinBase implementation. void ResizeDelegated() override; @@ -212,16 +212,19 @@ } void SoftwareOutputDeviceWinProxy::OnSwapBuffers( - base::OnceClosure swap_ack_callback) { + SwapBuffersCallback swap_ack_callback) { DCHECK(swap_ack_callback_.is_null()); // We aren't waiting on DrawAck() and can immediately run the callback. if (!waiting_on_draw_ack_) { - task_runner_->PostTask(FROM_HERE, std::move(swap_ack_callback)); + task_runner_->PostTask( + FROM_HERE, + base::BindOnce(std::move(swap_ack_callback), viewport_pixel_size_)); return; } - swap_ack_callback_ = std::move(swap_ack_callback); + swap_ack_callback_ = + base::BindOnce(std::move(swap_ack_callback), viewport_pixel_size_); } void SoftwareOutputDeviceWinProxy::ResizeDelegated() {
diff --git a/components/viz/service/display_embedder/software_output_surface.cc b/components/viz/service/display_embedder/software_output_surface.cc index c6d272b..45ab3cf 100644 --- a/components/viz/service/display_embedder/software_output_surface.cc +++ b/components/viz/service/display_embedder/software_output_surface.cc
@@ -112,7 +112,7 @@ return 0; } -void SoftwareOutputSurface::SwapBuffersCallback() { +void SoftwareOutputSurface::SwapBuffersCallback(const gfx::Size& pixel_size) { latency_tracker_.OnGpuSwapBuffersCompleted(stored_latency_info_); client_->DidFinishLatencyInfo(stored_latency_info_); std::vector<ui::LatencyInfo>().swap(stored_latency_info_); @@ -121,7 +121,10 @@ base::TimeTicks now = base::TimeTicks::Now(); base::TimeDelta interval_to_next_refresh = now.SnappedToNextTick(refresh_timebase_, refresh_interval_) - now; - +#if defined(USE_X11) + if (needs_swap_size_notifications_) + client_->DidSwapWithSize(pixel_size); +#endif client_->DidReceivePresentationFeedback( gfx::PresentationFeedback(now, interval_to_next_refresh, 0u)); } @@ -147,4 +150,11 @@ return gfx::OVERLAY_TRANSFORM_NONE; } +#if defined(USE_X11) +void SoftwareOutputSurface::SetNeedsSwapSizeNotifications( + bool needs_swap_size_notifications) { + needs_swap_size_notifications_ = needs_swap_size_notifications; +} +#endif + } // namespace viz
diff --git a/components/viz/service/display_embedder/software_output_surface.h b/components/viz/service/display_embedder/software_output_surface.h index 5436eba..8699803 100644 --- a/components/viz/service/display_embedder/software_output_surface.h +++ b/components/viz/service/display_embedder/software_output_surface.h
@@ -48,9 +48,13 @@ UpdateVSyncParametersCallback callback) override; void SetDisplayTransformHint(gfx::OverlayTransform transform) override {} gfx::OverlayTransform GetDisplayTransform() override; +#if defined(USE_X11) + void SetNeedsSwapSizeNotifications( + bool needs_swap_size_notifications) override; +#endif private: - void SwapBuffersCallback(); + void SwapBuffersCallback(const gfx::Size& pixel_size); void UpdateVSyncParameters(base::TimeTicks timebase, base::TimeDelta interval); @@ -63,6 +67,10 @@ std::vector<ui::LatencyInfo> stored_latency_info_; ui::LatencyTracker latency_tracker_; +#if defined(USE_X11) + bool needs_swap_size_notifications_ = false; +#endif + base::WeakPtrFactory<SoftwareOutputSurface> weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(SoftwareOutputSurface);
diff --git a/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc b/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc index a594b5c..d76296e 100644 --- a/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc +++ b/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc
@@ -49,6 +49,12 @@ output_surface->SetNeedsSwapSizeNotifications( params->send_swap_size_notifications); +#if defined(USE_X11) + // For X11, we need notify client about swap completion after resizing, so the + // client can use it for synchronize with X11 WM. + output_surface->SetNeedsSwapSizeNotifications(true); +#endif + // Create some sort of a BeginFrameSource, depending on the platform and // |params|. std::unique_ptr<ExternalBeginFrameSource> external_begin_frame_source; @@ -348,6 +354,11 @@ #if defined(OS_ANDROID) if (display_client_) display_client_->DidCompleteSwapWithSize(pixel_size); +#elif defined(USE_X11) + if (display_client_ && pixel_size != last_swap_pixel_size_) { + last_swap_pixel_size_ = pixel_size; + display_client_->DidCompleteSwapWithNewSize(last_swap_pixel_size_); + } #else NOTREACHED(); ALLOW_UNUSED_LOCAL(display_client_);
diff --git a/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h b/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h index b649b25..455b60d64 100644 --- a/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h +++ b/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h
@@ -132,6 +132,10 @@ // to the BFS. std::unique_ptr<Display> display_; +#if defined(USE_X11) + gfx::Size last_swap_pixel_size_; +#endif + DISALLOW_COPY_AND_ASSIGN(RootCompositorFrameSinkImpl); };
diff --git a/components/viz/test/fake_display_client.cc b/components/viz/test/fake_display_client.cc index 9f41365..55a1ae0 100644 --- a/components/viz/test/fake_display_client.cc +++ b/components/viz/test/fake_display_client.cc
@@ -25,4 +25,8 @@ mojom::LayeredWindowUpdaterRequest request) {} #endif +#if defined(USE_X11) +void FakeDisplayClient::DidCompleteSwapWithNewSize(const gfx::Size& size) {} +#endif + } // namespace viz
diff --git a/components/viz/test/fake_display_client.h b/components/viz/test/fake_display_client.h index c9b55eb..73f9d511 100644 --- a/components/viz/test/fake_display_client.h +++ b/components/viz/test/fake_display_client.h
@@ -31,6 +31,10 @@ mojom::LayeredWindowUpdaterRequest request) override; #endif +#if defined(USE_X11) + void DidCompleteSwapWithNewSize(const gfx::Size& size) override; +#endif + private: mojo::Binding<mojom::DisplayClient> binding_;
diff --git a/components/viz/test/fake_output_surface.cc b/components/viz/test/fake_output_surface.cc index 18b9d5be..6362f551 100644 --- a/components/viz/test/fake_output_surface.cc +++ b/components/viz/test/fake_output_surface.cc
@@ -112,4 +112,9 @@ return gfx::OVERLAY_TRANSFORM_NONE; } +#if defined(USE_X11) +void FakeOutputSurface::SetNeedsSwapSizeNotifications( + bool needs_swap_size_notifications) {} +#endif + } // namespace viz
diff --git a/components/viz/test/fake_output_surface.h b/components/viz/test/fake_output_surface.h index 6d2a86e..f629e35 100644 --- a/components/viz/test/fake_output_surface.h +++ b/components/viz/test/fake_output_surface.h
@@ -79,6 +79,10 @@ UpdateVSyncParametersCallback callback) override; void SetDisplayTransformHint(gfx::OverlayTransform transform) override {} gfx::OverlayTransform GetDisplayTransform() override; +#if defined(USE_X11) + void SetNeedsSwapSizeNotifications( + bool needs_swap_size_notifications) override; +#endif void set_framebuffer(GLint framebuffer, GLenum format) { framebuffer_ = framebuffer;
diff --git a/components/viz/test/mock_display_client.h b/components/viz/test/mock_display_client.h index cd691c0..f43156e 100644 --- a/components/viz/test/mock_display_client.h +++ b/components/viz/test/mock_display_client.h
@@ -34,6 +34,9 @@ void(gpu::ContextResult)); MOCK_METHOD1(SetPreferredRefreshRate, void(float refresh_rate)); #endif +#if defined(USE_X11) + MOCK_METHOD1(DidCompleteSwapWithNewSize, void(const gfx::Size&)); +#endif private: mojo::Binding<mojom::DisplayClient> binding_;
diff --git a/content/browser/accessibility/browser_accessibility_manager_android.cc b/content/browser/accessibility/browser_accessibility_manager_android.cc index 17db74e..9794721 100644 --- a/content/browser/accessibility/browser_accessibility_manager_android.cc +++ b/content/browser/accessibility/browser_accessibility_manager_android.cc
@@ -241,6 +241,7 @@ case ui::AXEventGenerator::Event::SELECTED_CHANGED: case ui::AXEventGenerator::Event::SELECTED_CHILDREN_CHANGED: case ui::AXEventGenerator::Event::SET_SIZE_CHANGED: + case ui::AXEventGenerator::Event::SORT_CHANGED: case ui::AXEventGenerator::Event::STATE_CHANGED: case ui::AXEventGenerator::Event::SUBTREE_CREATED: case ui::AXEventGenerator::Event::VALUE_MAX_CHANGED:
diff --git a/content/browser/accessibility/browser_accessibility_manager_mac.mm b/content/browser/accessibility/browser_accessibility_manager_mac.mm index e44929e..8ccb8d2 100644 --- a/content/browser/accessibility/browser_accessibility_manager_mac.mm +++ b/content/browser/accessibility/browser_accessibility_manager_mac.mm
@@ -409,6 +409,7 @@ case ui::AXEventGenerator::Event::SCROLL_VERTICAL_POSITION_CHANGED: case ui::AXEventGenerator::Event::SELECTED_CHANGED: case ui::AXEventGenerator::Event::SET_SIZE_CHANGED: + case ui::AXEventGenerator::Event::SORT_CHANGED: case ui::AXEventGenerator::Event::STATE_CHANGED: case ui::AXEventGenerator::Event::SUBTREE_CREATED: case ui::AXEventGenerator::Event::VALUE_MAX_CHANGED:
diff --git a/content/browser/accessibility/browser_accessibility_manager_win.cc b/content/browser/accessibility/browser_accessibility_manager_win.cc index f801491d..f479c6a 100644 --- a/content/browser/accessibility/browser_accessibility_manager_win.cc +++ b/content/browser/accessibility/browser_accessibility_manager_win.cc
@@ -333,6 +333,10 @@ break; case ui::AXEventGenerator::Event::SET_SIZE_CHANGED: FireUiaPropertyChangedEvent(UIA_SizeOfSetPropertyId, node); + aria_properties_events_.insert(node); + break; + case ui::AXEventGenerator::Event::SORT_CHANGED: + aria_properties_events_.insert(node); break; case ui::AXEventGenerator::Event::SUBTREE_CREATED: FireWinAccessibilityEvent(EVENT_OBJECT_SHOW, node); @@ -340,18 +344,24 @@ break; case ui::AXEventGenerator::Event::VALUE_CHANGED: FireWinAccessibilityEvent(EVENT_OBJECT_VALUECHANGE, node); - if (ui::IsRangeValueSupported(node->GetData())) + if (ui::IsRangeValueSupported(node->GetData())) { FireUiaPropertyChangedEvent(UIA_RangeValueValuePropertyId, node); - else if (ui::IsValuePatternSupported(node)) + aria_properties_events_.insert(node); + } else if (ui::IsValuePatternSupported(node)) { FireUiaPropertyChangedEvent(UIA_ValueValuePropertyId, node); + } break; case ui::AXEventGenerator::Event::VALUE_MAX_CHANGED: - if (IsRangeValueSupported(node->GetData())) + if (IsRangeValueSupported(node->GetData())) { FireUiaPropertyChangedEvent(UIA_RangeValueMaximumPropertyId, node); + aria_properties_events_.insert(node); + } break; case ui::AXEventGenerator::Event::VALUE_MIN_CHANGED: - if (IsRangeValueSupported(node->GetData())) + if (IsRangeValueSupported(node->GetData())) { FireUiaPropertyChangedEvent(UIA_RangeValueMinimumPropertyId, node); + aria_properties_events_.insert(node); + } break; case ui::AXEventGenerator::Event::VALUE_STEP_CHANGED: if (IsRangeValueSupported(node->GetData())) {
diff --git a/content/browser/accessibility/dump_accessibility_events_browsertest.cc b/content/browser/accessibility/dump_accessibility_events_browsertest.cc index 73dc997..db1f1bfc 100644 --- a/content/browser/accessibility/dump_accessibility_events_browsertest.cc +++ b/content/browser/accessibility/dump_accessibility_events_browsertest.cc
@@ -301,6 +301,16 @@ } IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest, + AccessibilityEventsAriaSetSizeChanged) { + RunEventTest(FILE_PATH_LITERAL("aria-setsize-changed.html")); +} + +IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest, + AccessibilityEventsAriaSortChanged) { + RunEventTest(FILE_PATH_LITERAL("aria-sort-changed.html")); +} + +IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest, AccessibilityEventsAriaTreeCollapse) { RunEventTest(FILE_PATH_LITERAL("aria-tree-collapse.html")); }
diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc index 54c922b..7d51895 100644 --- a/content/browser/compositor/gpu_process_transport_factory.cc +++ b/content/browser/compositor/gpu_process_transport_factory.cc
@@ -113,6 +113,35 @@ constexpr gpu::SchedulingPriority kStreamPriority = content::kGpuStreamPriorityUI; +#if defined(USE_X11) +class HostDisplayClient : public viz::HostDisplayClient { + public: + explicit HostDisplayClient(ui::Compositor* compositor) + : viz::HostDisplayClient(compositor->widget()), compositor_(compositor) {} + ~HostDisplayClient() override = default; + + // viz::HostDisplayClient: + void DidCompleteSwapWithNewSize(const gfx::Size& size) override { + compositor_->OnCompleteSwapWithNewSize(size); + } + + private: + ui::Compositor* const compositor_; + + DISALLOW_COPY_AND_ASSIGN(HostDisplayClient); +}; +#else +class HostDisplayClient : public viz::HostDisplayClient { + public: + explicit HostDisplayClient(ui::Compositor* compositor) + : viz::HostDisplayClient(compositor->widget()) {} + ~HostDisplayClient() override = default; + + private: + DISALLOW_COPY_AND_ASSIGN(HostDisplayClient); +}; +#endif + } // namespace namespace content { @@ -476,8 +505,7 @@ server_shared_bitmap_manager_, viz::CreateRendererSettings(), compositor->frame_sink_id(), std::move(display_output_surface), std::move(scheduler), compositor->task_runner()); - data->display_client = - std::make_unique<viz::HostDisplayClient>(compositor->widget()); + data->display_client = std::make_unique<HostDisplayClient>(compositor.get()); GetFrameSinkManager()->RegisterBeginFrameSource(begin_frame_source, compositor->frame_sink_id()); // Note that we are careful not to destroy prior BeginFrameSource objects
diff --git a/content/browser/compositor/software_browser_compositor_output_surface.cc b/content/browser/compositor/software_browser_compositor_output_surface.cc index 22412d9..d48e93f 100644 --- a/content/browser/compositor/software_browser_compositor_output_surface.cc +++ b/content/browser/compositor/software_browser_compositor_output_surface.cc
@@ -85,9 +85,14 @@ } void SoftwareBrowserCompositorOutputSurface::SwapBuffersCallback( - const std::vector<ui::LatencyInfo>& latency_info) { + const std::vector<ui::LatencyInfo>& latency_info, + const gfx::Size& pixel_size) { latency_tracker_.OnGpuSwapBuffersCompleted(latency_info); client_->DidReceiveSwapBuffersAck(); +#if defined(USE_X11) + if (needs_swap_size_notifications_) + client_->DidSwapWithSize(pixel_size); +#endif client_->DidReceivePresentationFeedback( gfx::PresentationFeedback(base::TimeTicks::Now(), refresh_interval_, 0u)); } @@ -124,4 +129,11 @@ return 0; } +#if defined(USE_X11) +void SoftwareBrowserCompositorOutputSurface::SetNeedsSwapSizeNotifications( + bool needs_swap_size_notifications) { + needs_swap_size_notifications_ = needs_swap_size_notifications; +} +#endif + } // namespace content
diff --git a/content/browser/compositor/software_browser_compositor_output_surface.h b/content/browser/compositor/software_browser_compositor_output_surface.h index 012ba86..9a838454 100644 --- a/content/browser/compositor/software_browser_compositor_output_surface.h +++ b/content/browser/compositor/software_browser_compositor_output_surface.h
@@ -39,15 +39,25 @@ gfx::BufferFormat GetOverlayBufferFormat() const override; uint32_t GetFramebufferCopyTextureFormat() override; unsigned UpdateGpuFence() override; +#if defined(USE_X11) + void SetNeedsSwapSizeNotifications( + bool needs_swap_size_notifications) override; +#endif private: - void SwapBuffersCallback(const std::vector<ui::LatencyInfo>& latency_info); + void SwapBuffersCallback(const std::vector<ui::LatencyInfo>& latency_info, + const gfx::Size& pixel_size); void UpdateVSyncCallback(const base::TimeTicks timebase, const base::TimeDelta interval); viz::OutputSurfaceClient* client_ = nullptr; base::TimeDelta refresh_interval_; ui::LatencyTracker latency_tracker_; + +#if defined(USE_X11) + bool needs_swap_size_notifications_ = false; +#endif + base::WeakPtrFactory<SoftwareBrowserCompositorOutputSurface> weak_factory_; DISALLOW_COPY_AND_ASSIGN(SoftwareBrowserCompositorOutputSurface);
diff --git a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc index 643ba01..248c9702 100644 --- a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc +++ b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
@@ -1998,8 +1998,6 @@ return true; } - bool GenerateFileHash() override { return true; } - void SetDelayedOpen(bool delay) { delay_download_open_ = delay; } void GetDelayedCallbacks(
diff --git a/content/browser/download/download_browsertest.cc b/content/browser/download/download_browsertest.cc index c95b83bb..4583042 100644 --- a/content/browser/download/download_browsertest.cc +++ b/content/browser/download/download_browsertest.cc
@@ -522,8 +522,6 @@ return true; } - bool GenerateFileHash() override { return true; } - void SetDelayedOpen(bool delay) { delay_download_open_ = delay; }
diff --git a/content/browser/frame_host/render_widget_host_view_guest.cc b/content/browser/frame_host/render_widget_host_view_guest.cc index fa47a994..1384d8b 100644 --- a/content/browser/frame_host/render_widget_host_view_guest.cc +++ b/content/browser/frame_host/render_widget_host_view_guest.cc
@@ -157,7 +157,7 @@ // the renderer. SendSurfaceInfoToEmbedder(); } - host()->WasShown(false /* record_presentation_time */); + host()->WasShown(base::nullopt /* record_tab_switch_time_request */); } void RenderWidgetHostViewGuest::Hide() {
diff --git a/content/browser/network_service_instance.cc b/content/browser/network_service_instance.cc index 3b8f4483..c3c7336f 100644 --- a/content/browser/network_service_instance.cc +++ b/content/browser/network_service_instance.cc
@@ -186,7 +186,7 @@ // TODO(mmenke): Get capture mode from the command line. (*g_network_service_ptr) ->StartNetLog(std::move(file), - network::mojom::NetLogCaptureMode::DEFAULT, + net::NetLogCaptureMode::Default(), std::move(client_constants)); } }
diff --git a/content/browser/portal/portal.cc b/content/browser/portal/portal.cc index ada87ca..b45333f 100644 --- a/content/browser/portal/portal.cc +++ b/content/browser/portal/portal.cc
@@ -163,6 +163,15 @@ } void Portal::Navigate(const GURL& url) { + if (!url.SchemeIsHTTPOrHTTPS()) { + mojo::ReportBadMessage("Portal::Navigate tried to use non-HTTP protocol."); + binding_->Close(); // Also deletes |this|. + return; + } + + // TODO(lfg): Investigate which other restrictions we might need when + // navigating portals. See http://crbug.com/964395. + NavigationController::LoadURLParams load_url_params(url); portal_contents_impl_->GetController().LoadURLWithParams(load_url_params); }
diff --git a/content/browser/portal/portal_browsertest.cc b/content/browser/portal/portal_browsertest.cc index a3f3892..a0088ca 100644 --- a/content/browser/portal/portal_browsertest.cc +++ b/content/browser/portal/portal_browsertest.cc
@@ -22,6 +22,7 @@ #include "content/public/test/hit_test_region_observer.h" #include "content/public/test/test_navigation_observer.h" #include "content/shell/browser/shell.h" +#include "content/test/content_browser_test_utils_internal.h" #include "mojo/public/cpp/bindings/strong_associated_binding.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" @@ -59,6 +60,15 @@ portal_->Activate(std::move(data), std::move(callback)); } + void Navigate(const GURL& url) override { + if (navigate_callback_) { + navigate_callback_.Run(url); + return; + } + + portal_->Navigate(url); + } + void WaitForActivate() { if (portal_activated_) return; @@ -72,6 +82,9 @@ content::Portal* GetPortal() { return portal_.get(); } WebContents* GetPortalContents() { return portal_->GetPortalContents(); } + // IPC callbacks + base::RepeatingCallback<void(const GURL&)> navigate_callback_; + private: PortalInterceptorForTesting(RenderFrameHostImpl* render_frame_host_impl) : portal_(content::Portal::CreateForTesting(render_frame_host_impl)) {} @@ -487,6 +500,39 @@ << "Note: The portal's FrameSinkId is " << portal_view->GetFrameSinkId(); } +// Tests that trying to navigate to a chrome:// URL kills the renderer. +IN_PROC_BROWSER_TEST_F(PortalBrowserTest, NavigateToChrome) { + EXPECT_TRUE(NavigateToURL( + shell(), embedded_test_server()->GetURL("portal.test", "/title1.html"))); + WebContentsImpl* web_contents_impl = + static_cast<WebContentsImpl*>(shell()->web_contents()); + RenderFrameHostImpl* main_frame = web_contents_impl->GetMainFrame(); + + // Create portal. + PortalCreatedObserver portal_created_observer(main_frame); + EXPECT_TRUE(ExecJs(main_frame, + "var portal = document.createElement('portal');" + "document.body.appendChild(portal);")); + Portal* portal = portal_created_observer.WaitUntilPortalCreated(); + PortalInterceptorForTesting* portal_interceptor = + PortalInterceptorForTesting::From(portal); + WebContentsImpl* portal_contents = portal->GetPortalContents(); + + // Try to navigate to chrome://settings and wait for the process to die. + portal_interceptor->navigate_callback_ = base::BindRepeating( + [](Portal* portal, const GURL& url) { + GURL chrome_url("chrome://settings"); + portal->Navigate(chrome_url); + }, + portal); + RenderProcessHostKillWaiter kill_waiter( + portal_contents->GetMainFrame()->GetProcess()); + GURL a_url(embedded_test_server()->GetURL("a.com", "/title1.html")); + EXPECT_TRUE(ExecJs(main_frame, JsReplace("portal.src = $1;", a_url))); + + EXPECT_EQ(base::nullopt, kill_waiter.Wait()); +} + class PortalOOPIFBrowserTest : public PortalBrowserTest { protected: PortalOOPIFBrowserTest() {}
diff --git a/content/browser/renderer_host/browser_compositor_view_mac.mm b/content/browser/renderer_host/browser_compositor_view_mac.mm index 625566d..4b3f3c7 100644 --- a/content/browser/renderer_host/browser_compositor_view_mac.mm +++ b/content/browser/renderer_host/browser_compositor_view_mac.mm
@@ -11,6 +11,7 @@ #include "base/command_line.h" #include "base/containers/circular_deque.h" #include "base/lazy_instance.h" +#include "base/optional.h" #include "base/trace_event/trace_event.h" #include "components/viz/common/features.h" #include "components/viz/common/surfaces/local_surface_id_allocation.h" @@ -293,7 +294,7 @@ delegated_frame_host_->HasSavedFrame(); delegated_frame_host_->WasShown( GetRendererLocalSurfaceIdAllocation().local_surface_id(), dfh_size_dip_, - false /* record_presentation_time */); + base::nullopt /* record_tab_switch_time_request */); } // static
diff --git a/content/browser/renderer_host/delegated_frame_host.cc b/content/browser/renderer_host/delegated_frame_host.cc index 378b790..cd3f355 100644 --- a/content/browser/renderer_host/delegated_frame_host.cc +++ b/content/browser/renderer_host/delegated_frame_host.cc
@@ -92,18 +92,17 @@ void DelegatedFrameHost::WasShown( const viz::LocalSurfaceId& new_local_surface_id, const gfx::Size& new_dip_size, - bool record_presentation_time, - base::TimeTicks tab_switch_start_time) { + const base::Optional<RecordTabSwitchTimeRequest>& + record_tab_switch_time_request) { // Cancel any pending frame eviction and unpause it if paused. frame_eviction_state_ = FrameEvictionState::kNotStarted; frame_evictor_->SetVisible(true); - if (record_presentation_time && compositor_ && - !tab_switch_start_time.is_null()) { + if (record_tab_switch_time_request && compositor_) { compositor_->RequestPresentationTimeForNextFrame( - tab_switch_time_recorder_.TabWasShown(true /* has_saved_frames */, - tab_switch_start_time, - base::TimeTicks::Now())); + tab_switch_time_recorder_.TabWasShown( + true /* has_saved_frames */, record_tab_switch_time_request.value(), + base::TimeTicks::Now())); } // Use the default deadline to synchronize web content with browser UI.
diff --git a/content/browser/renderer_host/delegated_frame_host.h b/content/browser/renderer_host/delegated_frame_host.h index ec22ddd..3e69e97 100644 --- a/content/browser/renderer_host/delegated_frame_host.h +++ b/content/browser/renderer_host/delegated_frame_host.h
@@ -111,8 +111,8 @@ // TODO(ccameron): Include device scale factor here. void WasShown(const viz::LocalSurfaceId& local_surface_id, const gfx::Size& dip_size, - bool record_presentation_time, - base::TimeTicks tab_switch_start_time = base::TimeTicks()); + const base::Optional<RecordTabSwitchTimeRequest>& + record_tab_switch_time_request); void EmbedSurface(const viz::LocalSurfaceId& local_surface_id, const gfx::Size& dip_size, cc::DeadlinePolicy deadline_policy);
diff --git a/content/browser/renderer_host/direct_manipulation_event_handler_win.cc b/content/browser/renderer_host/direct_manipulation_event_handler_win.cc index c98d4507..eec54fc 100644 --- a/content/browser/renderer_host/direct_manipulation_event_handler_win.cc +++ b/content/browser/renderer_host/direct_manipulation_event_handler_win.cc
@@ -28,15 +28,19 @@ } // namespace DirectManipulationEventHandler::DirectManipulationEventHandler( - ui::WindowEventTarget* event_target) - : event_target_(event_target) {} + DirectManipulationHelper* helper) + : helper_(helper) {} -bool DirectManipulationEventHandler::SetViewportSizeInPixels( - const gfx::Size& viewport_size_in_pixels) { - if (viewport_size_in_pixels_ == viewport_size_in_pixels) - return false; - viewport_size_in_pixels_ = viewport_size_in_pixels; - return true; +void DirectManipulationEventHandler::SetWindowEventTarget( + ui::WindowEventTarget* event_target) { + if (!event_target && LoggingEnabled()) { + DebugLogging("Event target is null.", S_OK); + if (event_target_) + DebugLogging("Previous event target is not null", S_OK); + else + DebugLogging("Previous event target is null", S_OK); + } + event_target_ = event_target; } void DirectManipulationEventHandler::SetDeviceScaleFactor( @@ -171,29 +175,19 @@ if (current != DIRECTMANIPULATION_READY) return S_OK; - // Normally gesture sequence will receive 2 READY message, the first one is - // gesture end, the second one is from viewport reset. We don't have content - // transform in the second RUNNING -> READY. We should not reset on an empty - // RUNNING -> READY sequence. - if (!FloatEquals(1.0f, last_scale_) || last_x_offset_ != 0 || - last_y_offset_ != 0) { - HRESULT hr = viewport->ZoomToRect( - static_cast<float>(0), static_cast<float>(0), - static_cast<float>(viewport_size_in_pixels_.width()), - static_cast<float>(viewport_size_in_pixels_.height()), FALSE); - if (!SUCCEEDED(hr)) { - DebugLogging("Viewport zoom to rect failed.", hr); - return hr; - } - } - + // Reset the viewport when we're idle, so the content transforms always start + // at identity. + // Every animation will receive 2 ready message, we should stop request + // compositor animation at the second ready. + first_ready_ = !first_ready_; + HRESULT hr = helper_->Reset(first_ready_); last_scale_ = 1.0f; last_x_offset_ = 0.0f; last_y_offset_ = 0.0f; TransitionToState(GestureState::kNone); - return S_OK; + return hr; } HRESULT DirectManipulationEventHandler::OnViewportUpdated(
diff --git a/content/browser/renderer_host/direct_manipulation_event_handler_win.h b/content/browser/renderer_host/direct_manipulation_event_handler_win.h index e06c680..270e85a 100644 --- a/content/browser/renderer_host/direct_manipulation_event_handler_win.h +++ b/content/browser/renderer_host/direct_manipulation_event_handler_win.h
@@ -11,7 +11,6 @@ #include <wrl.h> #include "base/macros.h" -#include "ui/gfx/geometry/size.h" namespace ui { @@ -21,6 +20,7 @@ namespace content { +class DirectManipulationHelper; class DirectManipulationUnitTest; // DirectManipulationEventHandler receives status update and gesture events from @@ -35,10 +35,11 @@ Microsoft::WRL::FtmBase, IDirectManipulationViewportEventHandler>> { public: - explicit DirectManipulationEventHandler(ui::WindowEventTarget* event_target); + explicit DirectManipulationEventHandler(DirectManipulationHelper* helper); - // Return true if viewport_size_in_pixels_ changed. - bool SetViewportSizeInPixels(const gfx::Size& viewport_size_in_pixels); + // WindowEventTarget updates for every DM_POINTERHITTEST in case window + // hierarchy changed. + void SetWindowEventTarget(ui::WindowEventTarget* event_target); void SetDeviceScaleFactor(float device_scale_factor); @@ -64,18 +65,18 @@ OnContentUpdated(_In_ IDirectManipulationViewport* viewport, _In_ IDirectManipulationContent* content) override; + DirectManipulationHelper* helper_ = nullptr; ui::WindowEventTarget* event_target_ = nullptr; float device_scale_factor_ = 1.0f; float last_scale_ = 1.0f; int last_x_offset_ = 0; int last_y_offset_ = 0; + bool first_ready_ = false; bool should_send_scroll_begin_ = false; // Current recognized gesture from Direct Manipulation. GestureState gesture_state_ = GestureState::kNone; - gfx::Size viewport_size_in_pixels_; - DISALLOW_COPY_AND_ASSIGN(DirectManipulationEventHandler); };
diff --git a/content/browser/renderer_host/direct_manipulation_helper_win.cc b/content/browser/renderer_host/direct_manipulation_helper_win.cc index d986731..cc62fd6 100644 --- a/content/browser/renderer_host/direct_manipulation_helper_win.cc +++ b/content/browser/renderer_host/direct_manipulation_helper_win.cc
@@ -14,8 +14,6 @@ #include "base/win/windows_version.h" #include "ui/base/ui_base_features.h" #include "ui/base/win/window_event_target.h" -#include "ui/compositor/compositor.h" -#include "ui/compositor/compositor_animation_observer.h" #include "ui/display/win/screen_win.h" #include "ui/gfx/geometry/rect.h" @@ -41,9 +39,8 @@ // static std::unique_ptr<DirectManipulationHelper> DirectManipulationHelper::CreateInstance(HWND window, - ui::Compositor* compositor, ui::WindowEventTarget* event_target) { - if (!::IsWindow(window) || !compositor || !event_target) + if (!::IsWindow(window)) return nullptr; if (!base::FeatureList::IsEnabled(features::kPrecisionTouchpad)) @@ -54,7 +51,8 @@ return nullptr; std::unique_ptr<DirectManipulationHelper> instance = - base::WrapUnique(new DirectManipulationHelper(window, compositor)); + base::WrapUnique(new DirectManipulationHelper()); + instance->window_ = window; if (instance->Initialize(event_target)) return instance; @@ -75,10 +73,11 @@ return nullptr; std::unique_ptr<DirectManipulationHelper> instance = - base::WrapUnique(new DirectManipulationHelper(0, nullptr)); + base::WrapUnique(new DirectManipulationHelper()); instance->event_handler_ = - Microsoft::WRL::Make<DirectManipulationEventHandler>(event_target); + Microsoft::WRL::Make<DirectManipulationEventHandler>(instance.get()); + instance->event_handler_->SetWindowEventTarget(event_target); instance->viewport_ = viewport; @@ -86,25 +85,11 @@ } DirectManipulationHelper::~DirectManipulationHelper() { - Destroy(); + if (viewport_) + viewport_->Abandon(); } -DirectManipulationHelper::DirectManipulationHelper(HWND window, - ui::Compositor* compositor) - : window_(window), compositor_(compositor) {} - -void DirectManipulationHelper::OnAnimationStep(base::TimeTicks timestamp) { - // Simulate 1 frame in update_manager_. - HRESULT hr = update_manager_->Update(nullptr); - if (!SUCCEEDED(hr)) - DebugLogging("UpdateManager update failed.", hr); -} - -void DirectManipulationHelper::OnCompositingShuttingDown( - ui::Compositor* compositor) { - DCHECK_EQ(compositor, compositor_); - Destroy(); -} +DirectManipulationHelper::DirectManipulationHelper() {} bool DirectManipulationHelper::Initialize(ui::WindowEventTarget* event_target) { // IDirectManipulationUpdateManager is the first COM object created by the @@ -157,8 +142,8 @@ return false; } - event_handler_ = - Microsoft::WRL::Make<DirectManipulationEventHandler>(event_target); + event_handler_ = Microsoft::WRL::Make<DirectManipulationEventHandler>(this); + event_handler_->SetWindowEventTarget(event_target); // We got Direct Manipulation transform from // IDirectManipulationViewportEventHandler. @@ -170,9 +155,8 @@ } // Set default rect for viewport before activate. - gfx::Size viewport_size_in_pixels = {1000, 1000}; - event_handler_->SetViewportSizeInPixels(viewport_size_in_pixels); - RECT rect = gfx::Rect(viewport_size_in_pixels).ToRECT(); + viewport_size_in_pixels_ = {1000, 1000}; + RECT rect = gfx::Rect(viewport_size_in_pixels_).ToRECT(); hr = viewport_->SetViewportRect(&rect); if (!SUCCEEDED(hr)) { DebugLogging("Viewport set rect failed.", hr); @@ -197,16 +181,37 @@ return false; } - DCHECK(compositor_); - compositor_->AddAnimationObserver(this); - DebugLogging("DirectManipulation initialization complete", S_OK); return true; } +void DirectManipulationHelper::Activate() { + HRESULT hr = viewport_->Stop(); + if (!SUCCEEDED(hr)) { + DebugLogging("Viewport stop failed.", hr); + return; + } + + hr = manager_->Activate(window_); + if (!SUCCEEDED(hr)) + DebugLogging("DirectManipulationManager activate failed.", hr); +} + +void DirectManipulationHelper::Deactivate() { + HRESULT hr = viewport_->Stop(); + if (!SUCCEEDED(hr)) { + DebugLogging("Viewport stop failed.", hr); + return; + } + + hr = manager_->Deactivate(window_); + if (!SUCCEEDED(hr)) + DebugLogging("DirectManipulationManager deactivate failed.", hr); +} + void DirectManipulationHelper::SetSizeInPixels( const gfx::Size& size_in_pixels) { - if (!event_handler_->SetViewportSizeInPixels(size_in_pixels)) + if (viewport_size_in_pixels_ == size_in_pixels) return; HRESULT hr = viewport_->Stop(); @@ -215,13 +220,16 @@ return; } - RECT rect = gfx::Rect(size_in_pixels).ToRECT(); + viewport_size_in_pixels_ = size_in_pixels; + RECT rect = gfx::Rect(viewport_size_in_pixels_).ToRECT(); hr = viewport_->SetViewportRect(&rect); if (!SUCCEEDED(hr)) DebugLogging("Viewport set rect failed.", hr); } -void DirectManipulationHelper::OnPointerHitTest(WPARAM w_param) { +bool DirectManipulationHelper::OnPointerHitTest( + WPARAM w_param, + ui::WindowEventTarget* event_target) { // Update the device scale factor. event_handler_->SetDeviceScaleFactor( display::win::ScreenWin::GetScaleFactorForHWND(window_)); @@ -232,50 +240,53 @@ // For WM_POINTER, the pointer type will show the event from mouse. // For WM_POINTERACTIVATE, the pointer id will be different with the following // message. + event_handler_->SetWindowEventTarget(event_target); + using GetPointerTypeFn = BOOL(WINAPI*)(UINT32, POINTER_INPUT_TYPE*); UINT32 pointer_id = GET_POINTERID_WPARAM(w_param); POINTER_INPUT_TYPE pointer_type; static const auto get_pointer_type = reinterpret_cast<GetPointerTypeFn>( base::win::GetUser32FunctionPointer("GetPointerType")); if (get_pointer_type && get_pointer_type(pointer_id, &pointer_type) && - pointer_type == PT_TOUCHPAD) { + pointer_type == PT_TOUCHPAD && event_target) { HRESULT hr = viewport_->SetContact(pointer_id); - if (!SUCCEEDED(hr)) + if (!SUCCEEDED(hr)) { DebugLogging("Viewport set contact failed.", hr); + return false; + } + + // Request begin frame for fake viewport. + need_poll_events_ = true; } + return need_poll_events_; +} + +HRESULT DirectManipulationHelper::Reset(bool need_poll_events) { + // By zooming the primary content to a rect that match the viewport rect, we + // reset the content's transform to identity. + HRESULT hr = viewport_->ZoomToRect( + static_cast<float>(0), static_cast<float>(0), + static_cast<float>(viewport_size_in_pixels_.width()), + static_cast<float>(viewport_size_in_pixels_.height()), FALSE); + if (!SUCCEEDED(hr)) { + DebugLogging("Viewport zoom to rect failed.", hr); + return hr; + } + + need_poll_events_ = need_poll_events; + return S_OK; +} + +bool DirectManipulationHelper::PollForNextEvent() { + // Simulate 1 frame in update_manager_. + HRESULT hr = update_manager_->Update(nullptr); + if (!SUCCEEDED(hr)) + DebugLogging("UpdateManager update failed.", hr); + return need_poll_events_; } void DirectManipulationHelper::SetDeviceScaleFactorForTesting(float factor) { event_handler_->SetDeviceScaleFactor(factor); } -void DirectManipulationHelper::Destroy() { - if (!compositor_) - return; - - compositor_->RemoveAnimationObserver(this); - compositor_ = nullptr; - - HRESULT hr; - if (viewport_) { - hr = viewport_->Stop(); - if (!SUCCEEDED(hr)) - DebugLogging("Viewport stop failed.", hr); - - hr = viewport_->RemoveEventHandler(view_port_handler_cookie_); - if (!SUCCEEDED(hr)) - DebugLogging("Viewport remove event handler failed.", hr); - - hr = viewport_->Abandon(); - if (!SUCCEEDED(hr)) - DebugLogging("Viewport abandon failed.", hr); - } - - if (manager_) { - hr = manager_->Deactivate(window_); - if (!SUCCEEDED(hr)) - DebugLogging("DirectManipulationManager deactivate failed.", hr); - } -} - } // namespace content
diff --git a/content/browser/renderer_host/direct_manipulation_helper_win.h b/content/browser/renderer_host/direct_manipulation_helper_win.h index c644d4c4..76c889b 100644 --- a/content/browser/renderer_host/direct_manipulation_helper_win.h +++ b/content/browser/renderer_host/direct_manipulation_helper_win.h
@@ -16,12 +16,10 @@ #include "base/macros.h" #include "content/browser/renderer_host/direct_manipulation_event_handler_win.h" #include "content/common/content_export.h" -#include "ui/compositor/compositor_animation_observer.h" #include "ui/gfx/geometry/size.h" namespace ui { -class Compositor; class WindowEventTarget; } // namespace ui @@ -46,15 +44,13 @@ // when DM_POINTERHITTEST. // 3. OnViewportStatusChanged will be called when the gesture phase change. // OnContentUpdated will be called when the gesture update. -class CONTENT_EXPORT DirectManipulationHelper - : public ui::CompositorAnimationObserver { +class CONTENT_EXPORT DirectManipulationHelper { public: // Creates and initializes an instance of this class if Direct Manipulation is // enabled on the platform. Returns nullptr if it disabled or failed on // initialization. static std::unique_ptr<DirectManipulationHelper> CreateInstance( HWND window, - ui::Compositor* compositor, ui::WindowEventTarget* event_target); // Creates and initializes an instance for testing. @@ -62,41 +58,49 @@ ui::WindowEventTarget* event_target, Microsoft::WRL::ComPtr<IDirectManipulationViewport> viewport); - ~DirectManipulationHelper() override; + ~DirectManipulationHelper(); - // CompositorAnimationObserver implements. - // DirectManipulation needs to poll for new events every frame while finger - // gesturing on touchpad. - void OnAnimationStep(base::TimeTicks timestamp) override; - void OnCompositingShuttingDown(ui::Compositor* compositor) override; + // Actives Direct Manipulation, call when window show. + void Activate(); + + // Deactivates Direct Manipulation, call when window show. + void Deactivate(); // Updates viewport size. Call it when window bounds updated. void SetSizeInPixels(const gfx::Size& size_in_pixels); - // Pass the pointer hit test to Direct Manipulation. - void OnPointerHitTest(WPARAM w_param); + // Reset for gesture end. + HRESULT Reset(bool need_animtation); + + // Pass the pointer hit test to Direct Manipulation. Return true indicated we + // need poll for new events every frame from here. + bool OnPointerHitTest(WPARAM w_param, ui::WindowEventTarget* event_target); + + // On each frame poll new Direct Manipulation events. Return true if we still + // need poll for new events on next frame, otherwise stop request need begin + // frame. + bool PollForNextEvent(); private: friend class content::DirectManipulationBrowserTest; friend class DirectManipulationUnitTest; - DirectManipulationHelper(HWND window, ui::Compositor* compositor); + DirectManipulationHelper(); // This function instantiates Direct Manipulation and creates a viewport for - // |window_|. Return false if initialize failed. + // the passed in |window|. Return false if initialize failed. bool Initialize(ui::WindowEventTarget* event_target); void SetDeviceScaleFactorForTesting(float factor); - void Destroy(); - Microsoft::WRL::ComPtr<IDirectManipulationManager> manager_; Microsoft::WRL::ComPtr<IDirectManipulationUpdateManager> update_manager_; Microsoft::WRL::ComPtr<IDirectManipulationViewport> viewport_; Microsoft::WRL::ComPtr<DirectManipulationEventHandler> event_handler_; HWND window_; - ui::Compositor* compositor_ = nullptr; DWORD view_port_handler_cookie_; + bool need_poll_events_ = false; + gfx::Size viewport_size_in_pixels_; DISALLOW_COPY_AND_ASSIGN(DirectManipulationHelper); };
diff --git a/content/browser/renderer_host/direct_manipulation_win_browsertest.cc b/content/browser/renderer_host/direct_manipulation_win_browsertest.cc index ac8b18e..7648cf1 100644 --- a/content/browser/renderer_host/direct_manipulation_win_browsertest.cc +++ b/content/browser/renderer_host/direct_manipulation_win_browsertest.cc
@@ -49,12 +49,35 @@ return rwhva->legacy_render_widget_host_HWND_; } + HWND GetSubWindowHWND() { + LegacyRenderWidgetHostHWND* lrwhh = GetLegacyRenderWidgetHostHWND(); + + return lrwhh->hwnd(); + } + ui::WindowEventTarget* GetWindowEventTarget() { LegacyRenderWidgetHostHWND* lrwhh = GetLegacyRenderWidgetHostHWND(); return lrwhh->GetWindowEventTarget(lrwhh->GetParent()); } + void SimulatePointerHitTest() { + LegacyRenderWidgetHostHWND* lrwhh = GetLegacyRenderWidgetHostHWND(); + + lrwhh->direct_manipulation_helper_->need_poll_events_ = true; + lrwhh->CreateAnimationObserver(); + } + + void UpdateParent(HWND hwnd) { + LegacyRenderWidgetHostHWND* lrwhh = GetLegacyRenderWidgetHostHWND(); + + lrwhh->UpdateParent(hwnd); + } + + bool HasCompositorAnimationObserver(LegacyRenderWidgetHostHWND* lrwhh) { + return lrwhh->compositor_animation_observer_ != nullptr; + } + private: base::test::ScopedFeatureList scoped_feature_list_; @@ -65,6 +88,37 @@ DirectManipulationBrowserTest, testing::Bool()); +// Ensure the AnimationObserver destroy when hwnd reparent to other hwnd. +IN_PROC_BROWSER_TEST_P(DirectManipulationBrowserTest, HWNDReparent) { + if (base::win::GetVersion() < base::win::Version::WIN10) + return; + + NavigateToURL(shell(), GURL(url::kAboutBlankURL)); + + LegacyRenderWidgetHostHWND* lrwhh = GetLegacyRenderWidgetHostHWND(); + ASSERT_TRUE(lrwhh); + + // The observer should not create before it needed. + ASSERT_TRUE(!HasCompositorAnimationObserver(lrwhh)); + + // Add AnimationObserver to tab to simulate direct manipulation start. + SimulatePointerHitTest(); + ASSERT_TRUE(HasCompositorAnimationObserver(lrwhh)); + + // Create another browser. + Shell* shell2 = CreateBrowser(); + NavigateToURL(shell2, GURL(url::kAboutBlankURL)); + + // Move to the tab to browser2. + UpdateParent( + shell2->window()->GetRootWindow()->GetHost()->GetAcceleratedWidget()); + + // The animation observer should be removed. + EXPECT_FALSE(HasCompositorAnimationObserver(lrwhh)); + + shell2->Close(); +} + // EventLogger is to observe the events sent from WindowEventTarget (the root // window). class EventLogger : public ui::EventRewriter {
diff --git a/content/browser/renderer_host/direct_manipulation_win_unittest.cc b/content/browser/renderer_host/direct_manipulation_win_unittest.cc index 322cf32..3bf1b555 100644 --- a/content/browser/renderer_host/direct_manipulation_win_unittest.cc +++ b/content/browser/renderer_host/direct_manipulation_win_unittest.cc
@@ -31,12 +31,6 @@ ~MockDirectManipulationViewport() override {} - bool IsZoomToRectCalled() { - bool called = zoom_to_rect_called_; - zoom_to_rect_called_ = false; - return called; - } - HRESULT STDMETHODCALLTYPE Enable() override { return S_OK; } HRESULT STDMETHODCALLTYPE Disable() override { return S_OK; } @@ -81,7 +75,6 @@ _In_ const float right, _In_ const float bottom, _In_ BOOL animate) override { - zoom_to_rect_called_ = true; return S_OK; } @@ -168,8 +161,6 @@ HRESULT STDMETHODCALLTYPE Abandon() override { return S_OK; } private: - bool zoom_to_rect_called_ = false; - DISALLOW_COPY_AND_ASSIGN(MockDirectManipulationViewport); }; @@ -406,7 +397,13 @@ viewport_.Get(), content_.Get()); } - bool IsZoomToRectCalled() { return viewport_->IsZoomToRectCalled(); } + void SetNeedAnimation(bool need_poll_events) { + direct_manipulation_helper_->need_poll_events_ = need_poll_events; + } + + bool NeedAnimation() { + return direct_manipulation_helper_->need_poll_events_; + } void SetDeviceScaleFactor(float factor) { direct_manipulation_helper_->SetDeviceScaleFactorForTesting(factor); @@ -724,19 +721,21 @@ } TEST_F(DirectManipulationUnitTest, - ZoomToRectShouldNotBeCalledInEmptyRunningReadySequence) { + NeedAnimtationShouldBeFalseAfterSecondReset) { if (!GetDirectManipulationHelper()) return; - ContentUpdated(1.0f, 5, 0); + // Direct Manipulation will set need_poll_events_ true when DM_POINTERTEST + // from touchpad. + SetNeedAnimation(true); // Receive first ready when gesture end. ViewportStatusChanged(DIRECTMANIPULATION_READY, DIRECTMANIPULATION_RUNNING); - EXPECT_TRUE(IsZoomToRectCalled()); + EXPECT_TRUE(NeedAnimation()); // Receive second ready from ZoomToRect. ViewportStatusChanged(DIRECTMANIPULATION_READY, DIRECTMANIPULATION_RUNNING); - EXPECT_FALSE(IsZoomToRectCalled()); + EXPECT_FALSE(NeedAnimation()); } TEST_F(DirectManipulationUnitTest, HiDPIScroll) {
diff --git a/content/browser/renderer_host/legacy_render_widget_host_win.cc b/content/browser/renderer_host/legacy_render_widget_host_win.cc index e32f482..b781869 100644 --- a/content/browser/renderer_host/legacy_render_widget_host_win.cc +++ b/content/browser/renderer_host/legacy_render_widget_host_win.cc
@@ -27,6 +27,7 @@ #include "ui/base/view_prop.h" #include "ui/base/win/internal_constants.h" #include "ui/base/win/window_event_target.h" +#include "ui/compositor/compositor.h" #include "ui/display/win/screen_win.h" #include "ui/gfx/geometry/rect.h" @@ -37,6 +38,47 @@ // accessibility support. const int kIdScreenReaderHoneyPot = 1; +// DirectManipulation needs to poll for new events every frame while finger +// gesturing on touchpad. +class CompositorAnimationObserverForDirectManipulation + : public ui::CompositorAnimationObserver { + public: + CompositorAnimationObserverForDirectManipulation( + LegacyRenderWidgetHostHWND* render_widget_host_hwnd, + ui::Compositor* compositor) + : render_widget_host_hwnd_(render_widget_host_hwnd), + compositor_(compositor) { + DCHECK(compositor_); + compositor_->AddAnimationObserver(this); + DebugLogging("Add AnimationObserverForDirectManipulation."); + } + + ~CompositorAnimationObserverForDirectManipulation() override { + if (compositor_) { + compositor_->RemoveAnimationObserver(this); + DebugLogging("Remove AnimationObserverForDirectManipulation."); + } + } + + // ui::CompositorAnimationObserver + void OnAnimationStep(base::TimeTicks timestamp) override { + render_widget_host_hwnd_->PollForNextEvent(); + } + + // ui::CompositorAnimationObserver + void OnCompositingShuttingDown(ui::Compositor* compositor) override { + DebugLogging("OnCompositingShuttingDown."); + compositor->RemoveAnimationObserver(this); + compositor_ = nullptr; + } + + private: + LegacyRenderWidgetHostHWND* render_widget_host_hwnd_; + ui::Compositor* compositor_; + + DISALLOW_COPY_AND_ASSIGN(CompositorAnimationObserverForDirectManipulation); +}; + // static LegacyRenderWidgetHostHWND* LegacyRenderWidgetHostHWND::Create( HWND parent) { @@ -61,6 +103,8 @@ } void LegacyRenderWidgetHostHWND::Destroy() { + // Stop the AnimationObserver when window close. + DestroyAnimationObserver(); host_ = nullptr; if (::IsWindow(hwnd())) ::DestroyWindow(hwnd()); @@ -69,16 +113,10 @@ void LegacyRenderWidgetHostHWND::UpdateParent(HWND parent) { if (GetWindowEventTarget(GetParent())) GetWindowEventTarget(GetParent())->HandleParentChanged(); - + // Stop the AnimationObserver when window hide. eg. tab switch, move tab to + // another window. + DestroyAnimationObserver(); ::SetParent(hwnd(), parent); - - // Direct Manipulation is enabled on Windows 10+. The CreateInstance function - // returns NULL if Direct Manipulation is not available. Recreate - // |direct_manipulation_helper_| when parent changed (compositor and window - // event target updated). - direct_manipulation_helper_ = DirectManipulationHelper::CreateInstance( - hwnd(), host_->GetNativeView()->GetHost()->compositor(), - GetWindowEventTarget(GetParent())); } HWND LegacyRenderWidgetHostHWND::GetParent() { @@ -87,10 +125,14 @@ void LegacyRenderWidgetHostHWND::Show() { ::ShowWindow(hwnd(), SW_SHOW); + if (direct_manipulation_helper_) + direct_manipulation_helper_->Activate(); } void LegacyRenderWidgetHostHWND::Hide() { ::ShowWindow(hwnd(), SW_HIDE); + if (direct_manipulation_helper_) + direct_manipulation_helper_->Deactivate(); } void LegacyRenderWidgetHostHWND::SetBounds(const gfx::Rect& bounds) { @@ -149,6 +191,11 @@ CHILDID_SELF); } + // Direct Manipulation is enabled on Windows 10+. The CreateInstance function + // returns NULL if Direct Manipulation is not available. + direct_manipulation_helper_ = DirectManipulationHelper::CreateInstance( + hwnd(), GetWindowEventTarget(GetParent())); + // Disable pen flicks (http://crbug.com/506977) base::win::DisableFlicks(hwnd()); @@ -454,6 +501,21 @@ return 0; } +LRESULT LegacyRenderWidgetHostHWND::OnWindowPosChanged(UINT message, + WPARAM w_param, + LPARAM l_param) { + WINDOWPOS* window_pos = reinterpret_cast<WINDOWPOS*>(l_param); + if (direct_manipulation_helper_) { + if (window_pos->flags & SWP_SHOWWINDOW) { + direct_manipulation_helper_->Activate(); + } else if (window_pos->flags & SWP_HIDEWINDOW) { + direct_manipulation_helper_->Deactivate(); + } + } + SetMsgHandled(FALSE); + return 0; +} + LRESULT LegacyRenderWidgetHostHWND::OnDestroy(UINT message, WPARAM w_param, LPARAM l_param) { @@ -472,12 +534,30 @@ return 0; DebugLogging("Receive DM_POINTERHITTEST."); + // Update window event target for each DM_POINTERHITTEST. + if (direct_manipulation_helper_->OnPointerHitTest( + w_param, GetWindowEventTarget(GetParent()))) { + if (compositor_animation_observer_) { + // This is reach if Windows send a DM_POINTERHITTEST before the last + // DM_POINTERHITTEST receive READY status. We never see this but still + // worth to handle it. + DebugLogging("AnimationObserverForDirectManipulation exists."); + return 0; + } - direct_manipulation_helper_->OnPointerHitTest(w_param); + CreateAnimationObserver(); + } return 0; } +void LegacyRenderWidgetHostHWND::PollForNextEvent() { + DCHECK(direct_manipulation_helper_); + + if (!direct_manipulation_helper_->PollForNextEvent()) + DestroyAnimationObserver(); +} + gfx::NativeViewAccessible LegacyRenderWidgetHostHWND::GetOrCreateWindowRootAccessible() { if (!host_) @@ -509,4 +589,20 @@ return root->GetNativeViewAccessible(); } +void LegacyRenderWidgetHostHWND::CreateAnimationObserver() { + DCHECK(!compositor_animation_observer_); + DCHECK(host_); + DCHECK(host_->GetNativeView()->GetHost()); + DCHECK(host_->GetNativeView()->GetHost()->compositor()); + + compositor_animation_observer_ = + std::make_unique<CompositorAnimationObserverForDirectManipulation>( + this, host_->GetNativeView()->GetHost()->compositor()); +} + +void LegacyRenderWidgetHostHWND::DestroyAnimationObserver() { + DebugLogging("DestroyAnimationObserver."); + compositor_animation_observer_.reset(); +} + } // namespace content
diff --git a/content/browser/renderer_host/legacy_render_widget_host_win.h b/content/browser/renderer_host/legacy_render_widget_host_win.h index 6c06a240..950515b4 100644 --- a/content/browser/renderer_host/legacy_render_widget_host_win.h +++ b/content/browser/renderer_host/legacy_render_widget_host_win.h
@@ -14,6 +14,7 @@ #include "base/macros.h" #include "base/win/atl.h" #include "content/common/content_export.h" +#include "ui/compositor/compositor_animation_observer.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/native_widget_types.h" @@ -95,6 +96,7 @@ OnMouseRange) MESSAGE_HANDLER_EX(WM_NCCALCSIZE, OnNCCalcSize) MESSAGE_HANDLER_EX(WM_SIZE, OnSize) + MESSAGE_HANDLER_EX(WM_WINDOWPOSCHANGED, OnWindowPosChanged) MESSAGE_HANDLER_EX(WM_DESTROY, OnDestroy) MESSAGE_HANDLER_EX(DM_POINTERHITTEST, OnPointerHitTest) END_MSG_MAP() @@ -121,6 +123,10 @@ host_ = host; } + // DirectManipulation needs to poll for new events every frame while finger + // gesturing on touchpad. + void PollForNextEvent(); + // Return the root accessible object for either MSAA or UI Automation. gfx::NativeViewAccessible GetOrCreateWindowRootAccessible(); @@ -157,10 +163,15 @@ LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param); LRESULT OnNCCalcSize(UINT message, WPARAM w_param, LPARAM l_param); LRESULT OnSize(UINT message, WPARAM w_param, LPARAM l_param); + LRESULT OnWindowPosChanged(UINT message, WPARAM w_param, LPARAM l_param); LRESULT OnDestroy(UINT message, WPARAM w_param, LPARAM l_param); LRESULT OnPointerHitTest(UINT message, WPARAM w_param, LPARAM l_param); + void CreateAnimationObserver(); + + void DestroyAnimationObserver(); + Microsoft::WRL::ComPtr<IAccessible> window_accessible_; // Set to true if we turned on mouse tracking. @@ -179,6 +190,9 @@ // in Chrome on Windows 10. std::unique_ptr<DirectManipulationHelper> direct_manipulation_helper_; + std::unique_ptr<ui::CompositorAnimationObserver> + compositor_animation_observer_; + DISALLOW_COPY_AND_ASSIGN(LegacyRenderWidgetHostHWND); };
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index 4e97551..525bb5e 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -764,8 +764,9 @@ observer.RenderWidgetHostVisibilityChanged(this, false); } -void RenderWidgetHostImpl::WasShown(bool record_presentation_time, - base::TimeTicks tab_switch_start_time) { +void RenderWidgetHostImpl::WasShown( + const base::Optional<RecordTabSwitchTimeRequest>& + record_tab_switch_time_request) { if (!is_hidden_) return; @@ -782,9 +783,9 @@ Send(new WidgetMsg_WasShown( routing_id_, - record_presentation_time ? base::TimeTicks::Now() : base::TimeTicks(), - view_->is_evicted(), - record_presentation_time ? tab_switch_start_time : base::TimeTicks())); + record_tab_switch_time_request ? base::TimeTicks::Now() + : base::TimeTicks(), + view_->is_evicted(), record_tab_switch_time_request)); view_->reset_is_evicted(); process_->UpdateClientPriority(this);
diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 09dad0b..551ee2b2 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h
@@ -313,8 +313,8 @@ // Called to notify the RenderWidget that it has been hidden or restored from // having been hidden. void WasHidden(); - void WasShown(bool record_presentation_time, - base::TimeTicks tab_switch_start_time = base::TimeTicks()); + void WasShown(const base::Optional<RecordTabSwitchTimeRequest>& + record_tab_switch_time_request); // Send a WidgetMsg_WasHidden message to the RenderWidget, without caring // about the visibility state of the RenderWidgetHostImpl. This is used to
diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc index 010fe06..f235629 100644 --- a/content/browser/renderer_host/render_widget_host_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_unittest.cc
@@ -1017,7 +1017,7 @@ // Now unhide. process_->sink().ClearMessages(); - host_->WasShown(false /* record_presentation_time */); + host_->WasShown(base::nullopt /* record_tab_switch_time_request */); EXPECT_FALSE(host_->is_hidden_); // It should have sent out a restored message. @@ -1322,7 +1322,7 @@ // Showing the widget should restore the timeout, as the events have // not yet been ack'ed. - host_->WasShown(false /* record_presentation_time */); + host_->WasShown(base::nullopt /* record_tab_switch_time_request */); RunLoopFor(TimeDelta::FromMicroseconds(2)); EXPECT_TRUE(delegate_->unresponsive_timer_fired()); } @@ -1628,7 +1628,7 @@ TEST_F(RenderWidgetHostTest, RendererExitedResetsIsHidden) { // RendererExited will delete the view. host_->SetView(new TestView(host_.get())); - host_->WasShown(false /* record_presentation_time */); + host_->WasShown(base::nullopt /* record_tab_switch_time_request */); ASSERT_FALSE(host_->is_hidden()); host_->RendererExited(); @@ -2038,20 +2038,20 @@ TEST_F(RenderWidgetHostTest, NavigateInBackgroundShowsBlank) { // When visible, navigation does not immediately call into // ClearDisplayedGraphics. - host_->WasShown(false /* record_presentation_time */); + host_->WasShown(base::nullopt /* record_tab_switch_time_request */); host_->DidNavigate(5); EXPECT_FALSE(host_->new_content_rendering_timeout_fired()); // Hide then show. ClearDisplayedGraphics must be called. host_->WasHidden(); - host_->WasShown(false /* record_presentation_time */); + host_->WasShown(base::nullopt /* record_tab_switch_time_request */); EXPECT_TRUE(host_->new_content_rendering_timeout_fired()); host_->reset_new_content_rendering_timeout_fired(); // Hide, navigate, then show. ClearDisplayedGraphics must be called. host_->WasHidden(); host_->DidNavigate(6); - host_->WasShown(false /* record_presentation_time */); + host_->WasShown(base::nullopt /* record_tab_switch_time_request */); EXPECT_TRUE(host_->new_content_rendering_timeout_fired()); }
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc index c8374dc3..b92a6027 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -1431,7 +1431,7 @@ } } - host()->WasShown(false /* record_presentation_time */); + host()->WasShown(base::nullopt /* record_tab_switch_time_request */); if (delegated_frame_host_) { delegated_frame_host_->WasShown(
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 566575e7..00c623e6 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -638,13 +638,11 @@ if (!host_->is_hidden()) return; - auto tab_switch_start_time = GetAndResetLastTabChangeStartTime(); + auto tab_switch_start_state = TakeRecordTabSwitchTimeRequest(); bool has_saved_frame = delegated_frame_host_ ? delegated_frame_host_->HasSavedFrame() : false; - const bool renderer_should_record_presentation_time = !has_saved_frame; - host()->WasShown(renderer_should_record_presentation_time, - tab_switch_start_time); + host()->WasShown(has_saved_frame ? base::nullopt : tab_switch_start_state); aura::Window* root = window_->GetRootWindow(); if (root) { @@ -657,11 +655,10 @@ if (delegated_frame_host_) { // If the frame for the renderer is already available, then the // tab-switching time is the presentation time for the browser-compositor. - const bool record_presentation_time = has_saved_frame; delegated_frame_host_->WasShown( GetLocalSurfaceIdAllocation().local_surface_id(), - window_->bounds().size(), record_presentation_time, - tab_switch_start_time); + window_->bounds().size(), + has_saved_frame ? tab_switch_start_state : base::nullopt); } #if defined(OS_WIN)
diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc index 90a2587..3291e61a2 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.cc +++ b/content/browser/renderer_host/render_widget_host_view_base.cc
@@ -823,15 +823,19 @@ return nullptr; } -void RenderWidgetHostViewBase::SetLastTabChangeStartTime( - base::TimeTicks start_time) { - last_tab_switch_start_time_ = start_time; +void RenderWidgetHostViewBase::SetRecordTabSwitchTimeRequest( + base::TimeTicks start_time, + bool destination_is_loaded, + bool destination_is_frozen) { + last_record_tab_switch_time_request_.emplace( + start_time, destination_is_loaded, destination_is_frozen); } -base::TimeTicks RenderWidgetHostViewBase::GetAndResetLastTabChangeStartTime() { - auto stored_time = last_tab_switch_start_time_; - last_tab_switch_start_time_ = base::TimeTicks(); - return stored_time; +base::Optional<RecordTabSwitchTimeRequest> +RenderWidgetHostViewBase::TakeRecordTabSwitchTimeRequest() { + auto stored_state = std::move(last_record_tab_switch_time_request_); + last_record_tab_switch_time_request_.reset(); + return stored_state; } void RenderWidgetHostViewBase::SynchronizeVisualProperties() {
diff --git a/content/browser/renderer_host/render_widget_host_view_base.h b/content/browser/renderer_host/render_widget_host_view_base.h index bb55ecca..903131f 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.h +++ b/content/browser/renderer_host/render_widget_host_view_base.h
@@ -14,6 +14,7 @@ #include "base/callback_forward.h" #include "base/macros.h" #include "base/observer_list.h" +#include "base/optional.h" #include "base/process/kill.h" #include "base/strings/string16.h" #include "base/time/time.h" @@ -24,6 +25,7 @@ #include "components/viz/host/hit_test/hit_test_query.h" #include "content/browser/renderer_host/event_with_latency_info.h" #include "content/common/content_export.h" +#include "content/common/tab_switch_time_recorder.h" #include "content/public/browser/render_frame_metadata_provider.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/common/input_event_ack_state.h" @@ -130,7 +132,9 @@ float GetDeviceScaleFactor() final; TouchSelectionControllerClientManager* GetTouchSelectionControllerClientManager() override; - void SetLastTabChangeStartTime(base::TimeTicks start_time) final; + void SetRecordTabSwitchTimeRequest(base::TimeTicks start_time, + bool destination_is_loaded, + bool destination_is_frozen) final; // This only needs to be overridden by RenderWidgetHostViewBase subclasses // that handle content embedded within other RenderWidgetHostViews. @@ -190,10 +194,12 @@ virtual viz::ScopedSurfaceIdAllocator DidUpdateVisualProperties( const cc::RenderFrameMetadata& metadata); - // Returns the time set by SetLastTabChangeStartTime. If this was not - // preceded by a call to SetLastTabChangeStartTime, this will return null. - // Calling this will reset the stored time to null. - base::TimeTicks GetAndResetLastTabChangeStartTime(); + // Returns the time set by SetLastRecordTabSwitchTimeRequest. If this was not + // preceded by a call to SetLastRecordTabSwitchTimeRequest the + // |tab_switch_start_time| field of the returned struct will have a null + // timestamp. Calling this will reset + // |last_tab_switch_start_state_.tab_switch_start_time| to null. + base::Optional<RecordTabSwitchTimeRequest> TakeRecordTabSwitchTimeRequest(); base::WeakPtr<RenderWidgetHostViewBase> GetWeakPtr(); @@ -701,10 +707,11 @@ base::Optional<blink::WebGestureEvent> pending_touchpad_pinch_begin_; - // The last tab switch processing start time. This should only be set and - // retrieved using SetLastTabChangeStartTime and - // GetAndResetLastTabChangeStartTime. - base::TimeTicks last_tab_switch_start_time_; + // The last tab switch processing start request. This should only be set and + // retrieved using SetRecordTabSwitchTimeRequest and + // TakeRecordTabSwitchTimeRequest. + base::Optional<RecordTabSwitchTimeRequest> + last_record_tab_switch_time_request_; // True when StopFlingingIfNecessary() calls StopFling(). bool view_stopped_flinging_for_test_ = false;
diff --git a/content/browser/renderer_host/render_widget_host_view_child_frame.cc b/content/browser/renderer_host/render_widget_host_view_child_frame.cc index 38294aa..a04ca192 100644 --- a/content/browser/renderer_host/render_widget_host_view_child_frame.cc +++ b/content/browser/renderer_host/render_widget_host_view_child_frame.cc
@@ -229,7 +229,7 @@ if (!CanBecomeVisible()) return; - host()->WasShown(false /* record_presentation_time */); + host()->WasShown(base::nullopt /* record_tab_switch_time_request */); if (frame_connector_) frame_connector_->SetVisibilityForChildViews(true);
diff --git a/content/browser/renderer_host/render_widget_host_view_child_frame_browsertest.cc b/content/browser/renderer_host/render_widget_host_view_child_frame_browsertest.cc index 83dfaa1..4e5c2189 100644 --- a/content/browser/renderer_host/render_widget_host_view_child_frame_browsertest.cc +++ b/content/browser/renderer_host/render_widget_host_view_child_frame_browsertest.cc
@@ -176,8 +176,9 @@ // Hide the frame and make it visible again, to force it to record the // tab-switch time, which is generated from presentation-feedback. child_rwh_impl->WasHidden(); - child_rwh_impl->WasShown(true /* record_presentation_time */, - base::TimeTicks::Now()); + child_rwh_impl->WasShown(RecordTabSwitchTimeRequest{ + base::TimeTicks::Now(), /* destination_is_loaded */ true, + /* destination_is_frozen */ false}); // Force the child to submit a new frame. ASSERT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), "document.write('Force a new frame.');"));
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 01341832..c1ec9d0 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -16,6 +16,7 @@ #include "base/mac/mac_util.h" #include "base/mac/scoped_cftyperef.h" #include "base/macros.h" +#include "base/optional.h" #include "base/strings/sys_string_conversions.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" @@ -459,11 +460,12 @@ bool has_saved_frame = browser_compositor_->has_saved_frame_before_state_transition(); - auto tab_switch_start_time = GetAndResetLastTabChangeStartTime(); + auto tab_switch_start_state = TakeRecordTabSwitchTimeRequest(); const bool renderer_should_record_presentation_time = !has_saved_frame; - host()->WasShown(renderer_should_record_presentation_time, - tab_switch_start_time); + host()->WasShown(renderer_should_record_presentation_time + ? tab_switch_start_state + : base::nullopt); if (delegated_frame_host) { // If the frame for the renderer is already available, then the @@ -472,8 +474,8 @@ delegated_frame_host->WasShown( browser_compositor_->GetRendererLocalSurfaceIdAllocation() .local_surface_id(), - browser_compositor_->GetRendererSize(), record_presentation_time, - tab_switch_start_time); + browser_compositor_->GetRendererSize(), + record_presentation_time ? tab_switch_start_state : base::nullopt); } }
diff --git a/content/browser/service_manager/service_manager_context.cc b/content/browser/service_manager/service_manager_context.cc index 52d2e47..9fbc46d 100644 --- a/content/browser/service_manager/service_manager_context.cc +++ b/content/browser/service_manager/service_manager_context.cc
@@ -134,6 +134,25 @@ #endif }; +service_manager::Manifest GetContentSystemManifest() { + // TODO(https://crbug.com/961869): This is a bit of a temporary hack so that + // we can make the global service instance a singleton. For now we just mirror + // the per-BrowserContext manifest (formerly also used for the global + // singleton instance), sans packaged services, since those are only meant to + // be tied to a BrowserContext. The per-BrowserContext service should go away + // soon, and then this can be removed. + service_manager::Manifest manifest = GetContentBrowserManifest(); + manifest.Amend(GetContentClient() + ->browser() + ->GetServiceManifestOverlay(mojom::kBrowserServiceName) + .value_or(service_manager::Manifest())); + manifest.service_name = mojom::kSystemServiceName; + manifest.packaged_services.clear(); + manifest.options.instance_sharing_policy = + service_manager::Manifest::InstanceSharingPolicy::kSingleton; + return manifest; +} + void DestroyConnectorOnIOThread() { g_io_thread_connector.Get().reset(); } // Launch a process for a service once its sandbox type is known. @@ -465,7 +484,8 @@ std::vector<service_manager::Manifest> manifests{ GetContentBrowserManifest(), GetContentGpuManifest(), GetContentPackagedServicesManifest(), GetContentPluginManifest(), - GetContentRendererManifest(), GetContentUtilityManifest(), + GetContentRendererManifest(), GetContentSystemManifest(), + GetContentUtilityManifest(), }; for (auto& manifest : manifests) { base::Optional<service_manager::Manifest> overlay = @@ -501,18 +521,18 @@ base::BindRepeating(&ServiceManagerContext::OnUnhandledServiceRequest, weak_ptr_factory_.GetWeakPtr())); - service_manager::mojom::ServicePtrInfo root_browser_service; - ServiceManagerConnection::SetForProcess( - ServiceManagerConnection::Create(mojo::MakeRequest(&root_browser_service), - service_manager_thread_task_runner_)); - auto* browser_connection = ServiceManagerConnection::GetForProcess(); + mojo::PendingRemote<service_manager::mojom::Service> system_remote; + ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create( + system_remote.InitWithNewPipeAndPassReceiver(), + service_manager_thread_task_runner_)); + auto* system_connection = ServiceManagerConnection::GetForProcess(); mojo::Remote<service_manager::mojom::ProcessMetadata> metadata; packaged_services_connection_->GetConnector()->RegisterServiceInstance( - service_manager::Identity(mojom::kBrowserServiceName, - service_manager::kSystemInstanceGroup, - base::Token{}, base::Token::CreateRandom()), - std::move(root_browser_service), metadata.BindNewPipeAndPassReceiver()); + service_manager::Identity(mojom::kSystemServiceName, + base::Token::CreateRandom(), base::Token{}, + base::Token::CreateRandom()), + std::move(system_remote), metadata.BindNewPipeAndPassReceiver()); metadata->SetPID(base::GetCurrentProcId()); RegisterInProcessService( @@ -563,7 +583,7 @@ // This is safe to assign directly from any thread, because // ServiceManagerContext must be constructed before anyone can call // GetConnectorForIOThread(). - g_io_thread_connector.Get() = browser_connection->GetConnector()->Clone(); + g_io_thread_connector.Get() = system_connection->GetConnector()->Clone(); ContentBrowserClient::OutOfProcessServiceMap out_of_process_services; GetContentClient()->browser()->RegisterOutOfProcessServices( @@ -702,9 +722,9 @@ // static void ServiceManagerContext::StartBrowserConnection() { - auto* browser_connection = ServiceManagerConnection::GetForProcess(); - RegisterCommonBrowserInterfaces(browser_connection); - browser_connection->Start(); + auto* system_connection = ServiceManagerConnection::GetForProcess(); + RegisterCommonBrowserInterfaces(system_connection); + system_connection->Start(); if (base::FeatureList::IsEnabled(network::features::kNetworkService)) return;
diff --git a/content/browser/webauth/authenticator_impl_unittest.cc b/content/browser/webauth/authenticator_impl_unittest.cc index 8d292a1..4942a43f 100644 --- a/content/browser/webauth/authenticator_impl_unittest.cc +++ b/content/browser/webauth/authenticator_impl_unittest.cc
@@ -999,6 +999,35 @@ EXPECT_EQ(true, callback_receiver.value()->echo_appid_extension); EXPECT_EQ(true, callback_receiver.value()->appid_extension); } + + { + // AppID should still work when the authenticator supports credProtect. + device::VirtualCtap2Device::Config config; + config.u2f_support = true; + config.pin_support = true; + config.resident_key_support = true; + config.cred_protect_support = true; + + device::test::ScopedVirtualFidoDevice virtual_device; + virtual_device.SetCtap2Config(config); + + // Inject a registration for the URL (which is a U2F AppID). + PublicKeyCredentialRequestOptionsPtr options = + GetTestPublicKeyCredentialRequestOptions(); + ASSERT_TRUE(virtual_device.mutable_state()->InjectRegistration( + options->allow_credentials[0]->id, kTestOrigin1)); + + options->appid = kTestOrigin1; + + TestGetAssertionCallback callback_receiver; + authenticator->GetAssertion(std::move(options), + callback_receiver.callback()); + callback_receiver.WaitForCallback(); + ASSERT_EQ(AuthenticatorStatus::SUCCESS, callback_receiver.status()); + + EXPECT_EQ(true, callback_receiver.value()->echo_appid_extension); + EXPECT_EQ(true, callback_receiver.value()->appid_extension); + } } TEST_F(AuthenticatorImplTest, TestGetAssertionTimeout) {
diff --git a/content/child/child_process_sandbox_support_impl_mac.cc b/content/child/child_process_sandbox_support_impl_mac.cc index 2eb514c6..bb5559dea 100644 --- a/content/child/child_process_sandbox_support_impl_mac.cc +++ b/content/child/child_process_sandbox_support_impl_mac.cc
@@ -21,7 +21,7 @@ WebSandboxSupportMac::WebSandboxSupportMac( service_manager::Connector* connector) { - connector->BindInterface(content::mojom::kBrowserServiceName, + connector->BindInterface(content::mojom::kSystemServiceName, mojo::MakeRequest(&sandbox_support_)); sandbox_support_->GetSystemColors(base::BindOnce( &WebSandboxSupportMac::OnGotSystemColors, base::Unretained(this)));
diff --git a/content/child/child_thread_impl.cc b/content/child/child_thread_impl.cc index caab65d3..e7807e56 100644 --- a/content/child/child_thread_impl.cc +++ b/content/child/child_thread_impl.cc
@@ -240,8 +240,10 @@ const std::string& interface_name, mojo::ScopedMessagePipeHandle* interface_pipe, service_manager::Connector* connector) override { - if (source_info.identity.name() != mojom::kBrowserServiceName) + if (source_info.identity.name() != mojom::kBrowserServiceName && + source_info.identity.name() != mojom::kSystemServiceName) { return; + } if (interface_name == IPC::mojom::ChannelBootstrap::Name_) { DCHECK(bootstrap_.is_valid()); @@ -367,7 +369,7 @@ const std::string& trial_name, const std::string& group_name) { mojom::FieldTrialRecorderPtr field_trial_recorder; - GetConnector()->BindInterface(mojom::kBrowserServiceName, + GetConnector()->BindInterface(mojom::kSystemServiceName, &field_trial_recorder); field_trial_recorder->FieldTrialActivated(trial_name); } @@ -614,7 +616,7 @@ mojom::FontCacheWin* ChildThreadImpl::GetFontCacheWin() { if (!font_cache_win_ptr_) { - GetConnector()->BindInterface(mojom::kBrowserServiceName, + GetConnector()->BindInterface(mojom::kSystemServiceName, &font_cache_win_ptr_); } return font_cache_win_ptr_.get();
diff --git a/content/child/dwrite_font_proxy/dwrite_font_proxy_init_impl_win.cc b/content/child/dwrite_font_proxy/dwrite_font_proxy_init_impl_win.cc index 29d8f1f..f9166904 100644 --- a/content/child/dwrite_font_proxy/dwrite_font_proxy_init_impl_win.cc +++ b/content/child/dwrite_font_proxy/dwrite_font_proxy_init_impl_win.cc
@@ -59,7 +59,7 @@ if (g_connection_callback_override) { dwrite_font_proxy = g_connection_callback_override->Run(); } else if (connector) { - connector->BindInterface(mojom::kBrowserServiceName, + connector->BindInterface(mojom::kSystemServiceName, mojo::MakeRequest(&dwrite_font_proxy)); } // If |connector| is not provided, the connection to the browser will be
diff --git a/content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc b/content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc index c28736e..8b0ed34d 100644 --- a/content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc +++ b/content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc
@@ -369,13 +369,13 @@ blink::mojom::DWriteFontProxyPtrInfo dwrite_font_proxy; if (main_task_runner_->RunsTasksInCurrentSequence()) { ChildThread::Get()->GetConnector()->BindInterface( - mojom::kBrowserServiceName, mojo::MakeRequest(&dwrite_font_proxy)); + mojom::kSystemServiceName, mojo::MakeRequest(&dwrite_font_proxy)); } else { main_task_runner_->PostTask( FROM_HERE, base::BindOnce( [](blink::mojom::DWriteFontProxyRequest request) { ChildThread::Get()->GetConnector()->BindInterface( - mojom::kBrowserServiceName, std::move(request)); + mojom::kSystemServiceName, std::move(request)); }, mojo::MakeRequest(&dwrite_font_proxy))); }
diff --git a/content/common/content_param_traits.cc b/content/common/content_param_traits.cc index 5b67990..2791cb8 100644 --- a/content/common/content_param_traits.cc +++ b/content/common/content_param_traits.cc
@@ -14,6 +14,7 @@ #include "components/viz/common/surfaces/surface_id.h" #include "components/viz/common/surfaces/surface_info.h" #include "content/common/frame_message_structs.h" +#include "content/common/tab_switch_time_recorder.h" #include "ipc/ipc_mojo_message_helper.h" #include "ipc/ipc_mojo_param_traits.h" #include "net/base/ip_endpoint.h" @@ -539,6 +540,32 @@ l->append("<SHA256HashValue>"); } +void ParamTraits<content::RecordTabSwitchTimeRequest>::Write( + base::Pickle* m, + const param_type& p) { + WriteParam(m, p.tab_switch_start_time); + WriteParam(m, p.destination_is_loaded); + WriteParam(m, p.destination_is_frozen); +} + +bool ParamTraits<content::RecordTabSwitchTimeRequest>::Read( + const base::Pickle* m, + base::PickleIterator* iter, + param_type* r) { + if (!ReadParam(m, iter, &r->tab_switch_start_time) || + !ReadParam(m, iter, &r->destination_is_loaded) || + !ReadParam(m, iter, &r->destination_is_frozen)) { + return false; + } + + return true; +} + +void ParamTraits<content::RecordTabSwitchTimeRequest>::Log(const param_type& p, + std::string* l) { + l->append("<content::RecordTabSwitchTimeRequest>"); +} + } // namespace IPC // Generate param traits write methods.
diff --git a/content/common/content_param_traits.h b/content/common/content_param_traits.h index e66ca9f..cc59887e 100644 --- a/content/common/content_param_traits.h +++ b/content/common/content_param_traits.h
@@ -30,6 +30,7 @@ namespace content { struct FrameMsg_ViewChanged_Params; +struct RecordTabSwitchTimeRequest; } namespace viz { @@ -186,6 +187,16 @@ static void Log(const param_type& p, std::string* l); }; +template <> +struct CONTENT_EXPORT ParamTraits<content::RecordTabSwitchTimeRequest> { + using param_type = content::RecordTabSwitchTimeRequest; + static void Write(base::Pickle* m, const param_type& p); + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r); + static void Log(const param_type& p, std::string* l); +}; + } // namespace IPC #endif // CONTENT_COMMON_CONTENT_PARAM_TRAITS_H_
diff --git a/content/common/service_manager/service_manager_connection_impl.cc b/content/common/service_manager/service_manager_connection_impl.cc index 494afe3c..6424062 100644 --- a/content/common/service_manager/service_manager_connection_impl.cc +++ b/content/common/service_manager/service_manager_connection_impl.cc
@@ -250,7 +250,8 @@ const std::string& interface_name, mojo::ScopedMessagePipeHandle interface_pipe) override { DCHECK(io_thread_checker_.CalledOnValidThread()); - if (source_info.identity.name() == mojom::kBrowserServiceName && + if ((source_info.identity.name() == mojom::kBrowserServiceName || + source_info.identity.name() == mojom::kSystemServiceName) && interface_name == mojom::Child::Name_) { DCHECK(!child_binding_.is_bound()); child_binding_.Bind(mojom::ChildRequest(std::move(interface_pipe)));
diff --git a/content/common/tab_switch_time_recorder.cc b/content/common/tab_switch_time_recorder.cc index b176a62..d188865 100644 --- a/content/common/tab_switch_time_recorder.cc +++ b/content/common/tab_switch_time_recorder.cc
@@ -22,12 +22,32 @@ // TabSwitchTimeRecorder can generate multiple overlapping events. int g_num_trace_events_in_process = 0; -const char* GetHistogramSuffix(bool has_saved_frames) { - return has_saved_frames ? "WithSavedFrames" : "NoSavedFrames"; +const char* GetHistogramSuffix(bool has_saved_frames, + const RecordTabSwitchTimeRequest& start_state) { + if (has_saved_frames) + return "WithSavedFrames"; + + if (start_state.destination_is_loaded) { + if (start_state.destination_is_frozen) { + return "NoSavedFrames_Loaded_Frozen"; + } else { + return "NoSavedFrames_Loaded_NotFrozen"; + } + } else { + return "NoSavedFrames_NotLoaded"; + } } } // namespace +RecordTabSwitchTimeRequest::RecordTabSwitchTimeRequest( + base::TimeTicks tab_switch_start_time, + bool destination_is_loaded, + bool destination_is_frozen) + : tab_switch_start_time(tab_switch_start_time), + destination_is_loaded(destination_is_loaded), + destination_is_frozen(destination_is_frozen) {} + TabSwitchTimeRecorder::TabSwitchTimeRecorder() : weak_ptr_factory_(this) {} TabSwitchTimeRecorder::~TabSwitchTimeRecorder() {} @@ -35,25 +55,27 @@ base::OnceCallback<void(const gfx::PresentationFeedback&)> TabSwitchTimeRecorder::TabWasShown( bool has_saved_frames, - base::TimeTicks tab_switch_start_time, + const RecordTabSwitchTimeRequest& start_state, base::TimeTicks render_widget_visibility_request_timestamp) { - DCHECK(!tab_switch_start_time.is_null()); + DCHECK(!start_state.tab_switch_start_time.is_null()); DCHECK(!render_widget_visibility_request_timestamp.is_null()); - DCHECK(tab_switch_start_time_.is_null()); + DCHECK(!tab_switch_start_state_); DCHECK(render_widget_visibility_request_timestamp_.is_null()); has_saved_frames_ = has_saved_frames; - tab_switch_start_time_ = tab_switch_start_time; + tab_switch_start_state_ = start_state; render_widget_visibility_request_timestamp_ = render_widget_visibility_request_timestamp; + // |tab_switch_start_state_| is only reset by RecordHistogramsAndTraceEvents + // once the metrics have been emitted. return base::BindOnce(&TabSwitchTimeRecorder::RecordHistogramsAndTraceEvents, weak_ptr_factory_.GetWeakPtr(), false /* is_incomplete */); } void TabSwitchTimeRecorder::TabWasHidden() { - if (!tab_switch_start_time_.is_null()) { + if (tab_switch_start_state_) { RecordHistogramsAndTraceEvents(true /* is_incomplete */, gfx::PresentationFeedback::Failure()); weak_ptr_factory_.InvalidateWeakPtrs(); @@ -63,7 +85,7 @@ void TabSwitchTimeRecorder::RecordHistogramsAndTraceEvents( bool is_incomplete, const gfx::PresentationFeedback& feedback) { - DCHECK(!tab_switch_start_time_.is_null()); + DCHECK(tab_switch_start_state_); DCHECK(!render_widget_visibility_request_timestamp_.is_null()); auto tab_switch_result = TabSwitchResult::kSuccess; @@ -72,12 +94,14 @@ else if (feedback.flags & gfx::PresentationFeedback::kFailure) tab_switch_result = TabSwitchResult::kPresentationFailure; - const auto tab_switch_duration = feedback.timestamp - tab_switch_start_time_; + const auto tab_switch_duration = + feedback.timestamp - tab_switch_start_state_->tab_switch_start_time; // Record trace events. TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0( "latency", "TabSwitching::Latency", - TRACE_ID_LOCAL(g_num_trace_events_in_process), tab_switch_start_time_); + TRACE_ID_LOCAL(g_num_trace_events_in_process), + tab_switch_start_state_->tab_switch_start_time); TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP2( "latency", "TabSwitching::Latency", TRACE_ID_LOCAL(g_num_trace_events_in_process), feedback.timestamp, @@ -86,22 +110,27 @@ ++g_num_trace_events_in_process; // Record result histogram. - base::UmaHistogramEnumeration(std::string("Browser.Tabs.TabSwitchResult.") + - GetHistogramSuffix(has_saved_frames_), - tab_switch_result); + base::UmaHistogramEnumeration( + std::string("Browser.Tabs.TabSwitchResult.") + + GetHistogramSuffix(has_saved_frames_, + tab_switch_start_state_.value()), + tab_switch_result); // Record latency histogram. switch (tab_switch_result) { case TabSwitchResult::kSuccess: { - base::UmaHistogramTimes(std::string("Browser.Tabs.TotalSwitchDuration.") + - GetHistogramSuffix(has_saved_frames_), - tab_switch_duration); + base::UmaHistogramTimes( + std::string("Browser.Tabs.TotalSwitchDuration.") + + GetHistogramSuffix(has_saved_frames_, + tab_switch_start_state_.value()), + tab_switch_duration); break; } case TabSwitchResult::kIncomplete: { base::UmaHistogramTimes( std::string("Browser.Tabs.TotalIncompleteSwitchDuration.") + - GetHistogramSuffix(has_saved_frames_), + GetHistogramSuffix(has_saved_frames_, + tab_switch_start_state_.value()), tab_switch_duration); break; } @@ -117,7 +146,7 @@ // Reset tab switch information. has_saved_frames_ = false; - tab_switch_start_time_ = base::TimeTicks(); + tab_switch_start_state_.reset(); render_widget_visibility_request_timestamp_ = base::TimeTicks(); }
diff --git a/content/common/tab_switch_time_recorder.h b/content/common/tab_switch_time_recorder.h index 54185c9..f8dc11e 100644 --- a/content/common/tab_switch_time_recorder.h +++ b/content/common/tab_switch_time_recorder.h
@@ -7,6 +7,7 @@ #include "base/callback.h" #include "base/memory/weak_ptr.h" +#include "base/optional.h" #include "base/time/time.h" #include "content/common/content_export.h" @@ -16,6 +17,22 @@ namespace content { +struct CONTENT_EXPORT RecordTabSwitchTimeRequest { + RecordTabSwitchTimeRequest() = default; + ~RecordTabSwitchTimeRequest() = default; + + RecordTabSwitchTimeRequest(base::TimeTicks tab_switch_start_time, + bool destination_is_loaded, + bool destination_is_frozen); + + // The time at which the tab switch has been initiated. + base::TimeTicks tab_switch_start_time = base::TimeTicks(); + // Indicates if the destination tab is loaded when initiating the tab switch. + bool destination_is_loaded = false; + // Indicates if the destination tab is frozen when initiating the tab switch. + bool destination_is_frozen = false; +}; + // Generates UMA metric to track the duration of tab switching from when the // active tab is changed until the frame presentation time. The metric will be // separated into two whether the tab switch has saved frames or not. @@ -39,7 +56,7 @@ // callback to invoke the next time a frame is presented for this tab. base::OnceCallback<void(const gfx::PresentationFeedback&)> TabWasShown( bool has_saved_frames, - base::TimeTicks tab_switch_start_time, + const RecordTabSwitchTimeRequest& start_state, base::TimeTicks render_widget_visibility_request_timestamp); // Indicates that the tab associated with this recorder was hidden. If no @@ -55,9 +72,9 @@ // Whether there was a saved frame for the last tab switch. bool has_saved_frames_; - // The timestamp of the input event for the last tab switch, or null if there - // is no incomplete tab switch. - base::TimeTicks tab_switch_start_time_; + // The information about the last tab switch request, or nullopt if there is + // no incomplete tab switch. + base::Optional<RecordTabSwitchTimeRequest> tab_switch_start_state_; // The render widget visibility request timestamp for the last tab switch, or // null if there is no incomplete tab switch.
diff --git a/content/common/tab_switch_time_recorder_unittest.cc b/content/common/tab_switch_time_recorder_unittest.cc index 63569a7..0002022 100644 --- a/content/common/tab_switch_time_recorder_unittest.cc +++ b/content/common/tab_switch_time_recorder_unittest.cc
@@ -15,15 +15,23 @@ constexpr char kDurationWithSavedFramesHistogram[] = "Browser.Tabs.TotalSwitchDuration.WithSavedFrames"; constexpr char kDurationNoSavedFramesHistogram[] = - "Browser.Tabs.TotalSwitchDuration.NoSavedFrames"; + "Browser.Tabs.TotalSwitchDuration.NoSavedFrames_Loaded_NotFrozen"; +constexpr char kDurationNoSavedFramesFrozenHistogram[] = + "Browser.Tabs.TotalSwitchDuration.NoSavedFrames_Loaded_Frozen"; +constexpr char kDurationNoSavedFramesUnloadedHistogram[] = + "Browser.Tabs.TotalSwitchDuration.NoSavedFrames_NotLoaded"; constexpr char kIncompleteDurationWithSavedFramesHistogram[] = "Browser.Tabs.TotalIncompleteSwitchDuration.WithSavedFrames"; constexpr char kIncompleteDurationNoSavedFramesHistogram[] = - "Browser.Tabs.TotalIncompleteSwitchDuration.NoSavedFrames"; + "Browser.Tabs.TotalIncompleteSwitchDuration.NoSavedFrames_Loaded_NotFrozen"; constexpr char kResultWithSavedFramesHistogram[] = "Browser.Tabs.TabSwitchResult.WithSavedFrames"; constexpr char kResultNoSavedFramesHistogram[] = - "Browser.Tabs.TabSwitchResult.NoSavedFrames"; + "Browser.Tabs.TabSwitchResult.NoSavedFrames_Loaded_NotFrozen"; +constexpr char kResultNoSavedFramesFrozenHistogram[] = + "Browser.Tabs.TabSwitchResult.NoSavedFrames_Loaded_Frozen"; +constexpr char kResultNoSavedFramesUnloadedHistogram[] = + "Browser.Tabs.TabSwitchResult.NoSavedFrames_NotLoaded"; constexpr base::TimeDelta kDuration = base::TimeDelta::FromMilliseconds(42); constexpr base::TimeDelta kOtherDuration = base::TimeDelta::FromMilliseconds(4242); @@ -36,6 +44,8 @@ ExpectTotalSamples(kDurationWithSavedFramesHistogram, 0); ExpectTotalSamples(kDurationNoSavedFramesHistogram, 0); + ExpectTotalSamples(kDurationNoSavedFramesFrozenHistogram, 0); + ExpectTotalSamples(kDurationNoSavedFramesUnloadedHistogram, 0); } void ExpectTotalSamples(const char* histogram_name, int expected_count) { @@ -68,7 +78,10 @@ TEST_F(TabSwitchTimeRecorderTest, TimeIsRecordedWithSavedFrames) { const auto start = base::TimeTicks::Now(); auto callback = tab_switch_time_recorder_.TabWasShown( - true /* has_saved_frames */, start, start); + true /* has_saved_frames */, + {start, /* destination_is_loaded */ true, + /* destination_is_frozen */ false}, + start); const auto end = start + kDuration; auto presentation_feedback = gfx::PresentationFeedback( end, end - start, gfx::PresentationFeedback::Flags::kHWCompletion); @@ -81,7 +94,6 @@ TabSwitchTimeRecorder::TabSwitchResult::kSuccess, 1); ExpectTotalSamples(kIncompleteDurationWithSavedFramesHistogram, 0); - ExpectTotalSamples(kDurationNoSavedFramesHistogram, 0); ExpectTotalSamples(kResultNoSavedFramesHistogram, 0); ExpectTotalSamples(kIncompleteDurationNoSavedFramesHistogram, 0); } @@ -91,7 +103,10 @@ TEST_F(TabSwitchTimeRecorderTest, TimeIsRecordedNoSavedFrame) { const auto start = base::TimeTicks::Now(); auto callback = tab_switch_time_recorder_.TabWasShown( - false /* has_saved_frames */, start, start); + false /* has_saved_frames */, + {start, /* destination_is_loaded */ true, + /* destination_is_frozen */ false}, + start); const auto end = start + kDuration; auto presentation_feedback = gfx::PresentationFeedback( end, end - start, gfx::PresentationFeedback::Flags::kHWCompletion); @@ -103,9 +118,71 @@ ExpectTotalSamples(kDurationNoSavedFramesHistogram, 1); ExpectTimeBucketCount(kDurationNoSavedFramesHistogram, kDuration, 1); + ExpectTotalSamples(kDurationNoSavedFramesFrozenHistogram, 0); + ExpectTotalSamples(kDurationNoSavedFramesUnloadedHistogram, 0); ExpectTotalSamples(kResultNoSavedFramesHistogram, 1); ExpectResultBucketCount(kResultNoSavedFramesHistogram, TabSwitchTimeRecorder::TabSwitchResult::kSuccess, 1); + ExpectTotalSamples(kResultNoSavedFramesFrozenHistogram, 0); + ExpectTotalSamples(kResultNoSavedFramesUnloadedHistogram, 0); + ExpectTotalSamples(kIncompleteDurationNoSavedFramesHistogram, 0); +} + +// Same as TimeIsRecordedNoSavedFrame but with the destination frame frozen. +TEST_F(TabSwitchTimeRecorderTest, TimeIsRecordedNoSavedFrameAndFrozen) { + const auto start = base::TimeTicks::Now(); + auto callback = tab_switch_time_recorder_.TabWasShown( + false /* has_saved_frames */, + {start, /* destination_is_loaded */ true, + /* destination_is_frozen */ true}, + start); + const auto end = start + kDuration; + auto presentation_feedback = gfx::PresentationFeedback( + end, end - start, gfx::PresentationFeedback::Flags::kHWCompletion); + std::move(callback).Run(presentation_feedback); + + ExpectTotalSamples(kDurationWithSavedFramesHistogram, 0); + ExpectTotalSamples(kResultWithSavedFramesHistogram, 0); + ExpectTotalSamples(kIncompleteDurationWithSavedFramesHistogram, 0); + + ExpectTotalSamples(kDurationNoSavedFramesHistogram, 0); + ExpectTotalSamples(kDurationNoSavedFramesFrozenHistogram, 1); + ExpectTimeBucketCount(kDurationNoSavedFramesFrozenHistogram, kDuration, 1); + ExpectTotalSamples(kDurationNoSavedFramesUnloadedHistogram, 0); + ExpectTotalSamples(kResultNoSavedFramesHistogram, 0); + ExpectTotalSamples(kResultNoSavedFramesFrozenHistogram, 1); + ExpectResultBucketCount(kResultNoSavedFramesFrozenHistogram, + TabSwitchTimeRecorder::TabSwitchResult::kSuccess, 1); + ExpectTotalSamples(kResultNoSavedFramesUnloadedHistogram, 0); + ExpectTotalSamples(kIncompleteDurationNoSavedFramesHistogram, 0); +} + +// Same as TimeIsRecordedNoSavedFrame but with the destination frame unloaded. +TEST_F(TabSwitchTimeRecorderTest, TimeIsRecordedNoSavedFrameUnloaded) { + const auto start = base::TimeTicks::Now(); + auto callback = tab_switch_time_recorder_.TabWasShown( + false /* has_saved_frames */, + {start, /* destination_is_loaded */ false, + /* destination_is_frozen */ false}, + start); + const auto end = start + kDuration; + auto presentation_feedback = gfx::PresentationFeedback( + end, end - start, gfx::PresentationFeedback::Flags::kHWCompletion); + std::move(callback).Run(presentation_feedback); + + ExpectTotalSamples(kDurationWithSavedFramesHistogram, 0); + ExpectTotalSamples(kResultWithSavedFramesHistogram, 0); + ExpectTotalSamples(kIncompleteDurationWithSavedFramesHistogram, 0); + + ExpectTotalSamples(kDurationNoSavedFramesHistogram, 0); + ExpectTotalSamples(kDurationNoSavedFramesFrozenHistogram, 0); + ExpectTotalSamples(kDurationNoSavedFramesUnloadedHistogram, 1); + ExpectTimeBucketCount(kDurationNoSavedFramesUnloadedHistogram, kDuration, 1); + ExpectTotalSamples(kResultNoSavedFramesHistogram, 0); + ExpectTotalSamples(kResultNoSavedFramesFrozenHistogram, 0); + ExpectTotalSamples(kResultNoSavedFramesUnloadedHistogram, 1); + ExpectResultBucketCount(kResultNoSavedFramesUnloadedHistogram, + TabSwitchTimeRecorder::TabSwitchResult::kSuccess, 1); ExpectTotalSamples(kIncompleteDurationNoSavedFramesHistogram, 0); } @@ -114,7 +191,10 @@ TEST_F(TabSwitchTimeRecorderTest, PresentationFailureWithSavedFrames) { const auto start = base::TimeTicks::Now(); auto callback = tab_switch_time_recorder_.TabWasShown( - true /* has_saved_frames */, start, start); + true /* has_saved_frames */, + {start, /* destination_is_loaded */ true, + /* destination_is_frozen */ false}, + start); std::move(callback).Run(gfx::PresentationFeedback::Failure()); ExpectTotalSamples(kDurationWithSavedFramesHistogram, 0); @@ -134,7 +214,10 @@ TEST_F(TabSwitchTimeRecorderTest, PresentationFailureNoSavedFrames) { const auto start = base::TimeTicks::Now(); auto callback = tab_switch_time_recorder_.TabWasShown( - false /* has_saved_frames */, start, start); + false /* has_saved_frames */, + {start, /* destination_is_loaded */ true, + /* destination_is_frozen */ false}, + start); std::move(callback).Run(gfx::PresentationFeedback::Failure()); ExpectTotalSamples(kDurationWithSavedFramesHistogram, 0); @@ -154,7 +237,10 @@ TEST_F(TabSwitchTimeRecorderTest, HideBeforePresentFrameWithSavedFrames) { const auto start1 = base::TimeTicks::Now(); auto callback1 = tab_switch_time_recorder_.TabWasShown( - true /* has_saved_frames */, start1, start1); + true /* has_saved_frames */, + {start1, /* destination_is_loaded */ true, + /* destination_is_frozen */ false}, + start1); scoped_task_environment_.FastForwardBy(kDuration); tab_switch_time_recorder_.TabWasHidden(); @@ -174,9 +260,11 @@ const auto start2 = base::TimeTicks::Now(); auto callback2 = tab_switch_time_recorder_.TabWasShown( - true /* has_saved_frames */, start2, start2); + true /* has_saved_frames */, + {start2, /* destination_is_loaded */ true, + /* destination_is_frozen */ false}, + start2); const auto end2 = start2 + kOtherDuration; - auto presentation_feedback = gfx::PresentationFeedback( end2, end2 - start2, gfx::PresentationFeedback::Flags::kHWCompletion); std::move(callback2).Run(presentation_feedback); @@ -201,7 +289,10 @@ TEST_F(TabSwitchTimeRecorderTest, HideBeforePresentFrameNoSavedFrames) { const auto start1 = base::TimeTicks::Now(); auto callback1 = tab_switch_time_recorder_.TabWasShown( - false /* has_saved_frames */, start1, start1); + false /* has_saved_frames */, + {start1, /* destination_is_loaded */ true, + /* destination_is_frozen */ false}, + start1); scoped_task_environment_.FastForwardBy(kDuration); tab_switch_time_recorder_.TabWasHidden(); @@ -221,7 +312,10 @@ const auto start2 = base::TimeTicks::Now(); auto callback2 = tab_switch_time_recorder_.TabWasShown( - false /* has_saved_frames */, start2, start2); + false /* has_saved_frames */, + {start2, /* destination_is_loaded */ true, + /* destination_is_frozen */ false}, + start2); const auto end2 = start2 + kOtherDuration; auto presentation_feedback = gfx::PresentationFeedback(
diff --git a/content/common/widget_messages.h b/content/common/widget_messages.h index fcda7ced..39e2b6b 100644 --- a/content/common/widget_messages.h +++ b/content/common/widget_messages.h
@@ -7,10 +7,12 @@ // IPC messages for controlling painting and input events. +#include "base/optional.h" #include "base/time/time.h" #include "cc/input/touch_action.h" #include "content/common/content_param_traits.h" #include "content/common/cursors/webcursor.h" +#include "content/common/tab_switch_time_recorder.h" #include "content/common/text_input_state.h" #include "content/common/visual_properties.h" #include "content/public/common/common_param_traits.h" @@ -157,10 +159,13 @@ IPC_MESSAGE_ROUTED0(WidgetMsg_WasHidden) // Tells the render view that it is no longer hidden (see WasHidden). -IPC_MESSAGE_ROUTED3(WidgetMsg_WasShown, - base::TimeTicks /* show_request_timestamp */, - bool /* was_evicted */, - base::TimeTicks /* tab_switch_start_time */) +IPC_MESSAGE_ROUTED3( + WidgetMsg_WasShown, + base::TimeTicks /* show_request_timestamp */, + bool /* was_evicted */, + base::Optional< + content:: + RecordTabSwitchTimeRequest> /* record_tab_switch_time_request */) // Activate/deactivate the RenderWidget (i.e., set its controls' tint // accordingly, etc.).
diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc index 55499d9d..1cde925a3 100644 --- a/content/gpu/gpu_child_thread.cc +++ b/content/gpu/gpu_child_thread.cc
@@ -384,12 +384,12 @@ media::mojom::AndroidOverlayProviderPtr overlay_provider; if (main_task_runner->RunsTasksInCurrentSequence()) { ChildThread::Get()->GetConnector()->BindInterface( - content::mojom::kBrowserServiceName, &overlay_provider); + content::mojom::kSystemServiceName, &overlay_provider); } else { // Create a connector on this sequence and bind it on the main thread. service_manager::mojom::ConnectorRequest request; auto connector = service_manager::Connector::Create(&request); - connector->BindInterface(content::mojom::kBrowserServiceName, + connector->BindInterface(content::mojom::kSystemServiceName, &overlay_provider); auto bind_connector_request = [](service_manager::mojom::ConnectorRequest request) {
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc index c4620ab..258e8b31 100644 --- a/content/ppapi_plugin/ppapi_thread.cc +++ b/content/ppapi_plugin/ppapi_thread.cc
@@ -122,7 +122,7 @@ if (!command_line.HasSwitch(switches::kSingleProcess)) { discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; ChildThread::Get()->GetConnector()->BindInterface( - mojom::kBrowserServiceName, mojo::MakeRequest(&manager_ptr)); + mojom::kSystemServiceName, mojo::MakeRequest(&manager_ptr)); discardable_shared_memory_manager_ = std::make_unique< discardable_memory::ClientDiscardableSharedMemoryManager>( std::move(manager_ptr), GetIOTaskRunner());
diff --git a/content/public/android/junit/src/org/chromium/content/browser/picker/DateDialogNormalizerTest.java b/content/public/android/junit/src/org/chromium/content/browser/picker/DateDialogNormalizerTest.java index 5429f608..32ec176d 100644 --- a/content/public/android/junit/src/org/chromium/content/browser/picker/DateDialogNormalizerTest.java +++ b/content/public/android/junit/src/org/chromium/content/browser/picker/DateDialogNormalizerTest.java
@@ -23,8 +23,7 @@ * Tests for DateDialogNormalizer. */ @RunWith(BaseRobolectricTestRunner.class) -// sdk 18 is used due to a bug in Robolectric, crbug.com/635199 -@Config(manifest = Config.NONE, sdk = 18) +@Config(manifest = Config.NONE, sdk = 21) public class DateDialogNormalizerTest { private static final long MILLIS_PER_MINUTE = 60 * 1000; private static final long MILLIS_PER_HOUR = 60 * 60 * 1000;
diff --git a/content/public/app/content_browser_manifest.h b/content/public/app/content_browser_manifest.h index 535c140..63b46d9 100644 --- a/content/public/app/content_browser_manifest.h +++ b/content/public/app/content_browser_manifest.h
@@ -10,10 +10,9 @@ namespace content { // Returns the service manifest for the "content_browser" service. There are -// multiple instances of this service embedded within the browser process: a -// global instance which establishes a process-wide connection to the Service -// Manager, and one instance per BrowserContext which can be used to connect to -// service instances isolated on a per-BrowserContext basis. +// multiple instances of this service embedded within the browser process: one +// instance per BrowserContext which can be used to connect to service instances +// isolated on a per-BrowserContext basis. // // In-process services whose instances should each be bound to the lifetime of // some BrowserContext are typically packaged within this manifest. For all
diff --git a/content/public/app/content_gpu_manifest.cc b/content/public/app/content_gpu_manifest.cc index b9926a5..b75ec025 100644 --- a/content/public/app/content_gpu_manifest.cc +++ b/content/public/app/content_gpu_manifest.cc
@@ -31,9 +31,9 @@ "viz.mojom.VizMain", }) .RequireCapability("device", "device:power_monitor") - .RequireCapability(mojom::kBrowserServiceName, "dwrite_font_proxy") - .RequireCapability(mojom::kBrowserServiceName, "field_trials") - .RequireCapability(mojom::kBrowserServiceName, "gpu") + .RequireCapability(mojom::kSystemServiceName, "dwrite_font_proxy") + .RequireCapability(mojom::kSystemServiceName, "field_trials") + .RequireCapability(mojom::kSystemServiceName, "gpu") .RequireCapability("ui", "discardable_memory") .RequireCapability("*", "app") .RequireCapability("metrics", "url_keyed_metrics")
diff --git a/content/public/app/content_packaged_services_manifest.cc b/content/public/app/content_packaged_services_manifest.cc index 0bf10f26..486cbb4 100644 --- a/content/public/app/content_packaged_services_manifest.cc +++ b/content/public/app/content_packaged_services_manifest.cc
@@ -48,6 +48,7 @@ .CanRegisterOtherServiceInstances(true) .Build()) .RequireCapability(mojom::kBrowserServiceName, "") + .RequireCapability(mojom::kSystemServiceName, "") .RequireCapability("*", "app") .PackageService(heap_profiling::GetManifest()) .PackageService(media::GetCdmManifest())
diff --git a/content/public/app/content_plugin_manifest.cc b/content/public/app/content_plugin_manifest.cc index 4f7618a..6d17755 100644 --- a/content/public/app/content_plugin_manifest.cc +++ b/content/public/app/content_plugin_manifest.cc
@@ -25,11 +25,11 @@ "IPC.mojom.ChannelBootstrap", }) .RequireCapability("device", "device:power_monitor") - .RequireCapability(mojom::kBrowserServiceName, "dwrite_font_proxy") - .RequireCapability(mojom::kBrowserServiceName, "field_trials") - .RequireCapability(mojom::kBrowserServiceName, "font_cache") - .RequireCapability(mojom::kBrowserServiceName, "plugin") - .RequireCapability(mojom::kBrowserServiceName, "sandbox_support") + .RequireCapability(mojom::kSystemServiceName, "dwrite_font_proxy") + .RequireCapability(mojom::kSystemServiceName, "field_trials") + .RequireCapability(mojom::kSystemServiceName, "font_cache") + .RequireCapability(mojom::kSystemServiceName, "plugin") + .RequireCapability(mojom::kSystemServiceName, "sandbox_support") .RequireCapability("ui", "discardable_memory") .RequireCapability("*", "app") .RequireCapability("font_service", "font_service")
diff --git a/content/public/app/content_renderer_manifest.cc b/content/public/app/content_renderer_manifest.cc index 92519a9..6d6781a2 100644 --- a/content/public/app/content_renderer_manifest.cc +++ b/content/public/app/content_renderer_manifest.cc
@@ -46,9 +46,11 @@ .RequireCapability("device", "device:screen_orientation") .RequireCapability("device", "device:time_zone_monitor") .RequireCapability(mojom::kBrowserServiceName, "dwrite_font_proxy") - .RequireCapability(mojom::kBrowserServiceName, "field_trials") + .RequireCapability(mojom::kSystemServiceName, "dwrite_font_proxy") + .RequireCapability(mojom::kSystemServiceName, "field_trials") .RequireCapability(mojom::kBrowserServiceName, "renderer") - .RequireCapability(mojom::kBrowserServiceName, "sandbox_support") + .RequireCapability(mojom::kSystemServiceName, "renderer") + .RequireCapability(mojom::kSystemServiceName, "sandbox_support") .RequireInterfaceFilterCapability_Deprecated( mojom::kBrowserServiceName, "navigation:shared_worker", "renderer")
diff --git a/content/public/app/content_utility_manifest.cc b/content/public/app/content_utility_manifest.cc index 42d17724..e3eafb7 100644 --- a/content/public/app/content_utility_manifest.cc +++ b/content/public/app/content_utility_manifest.cc
@@ -29,10 +29,10 @@ }) .RequireCapability("device", "device:power_monitor") .RequireCapability("device", "device:time_zone_monitor") - .RequireCapability(mojom::kBrowserServiceName, "dwrite_font_proxy") - .RequireCapability(mojom::kBrowserServiceName, "field_trials") - .RequireCapability(mojom::kBrowserServiceName, "font_cache") - .RequireCapability(mojom::kBrowserServiceName, "sandbox_support") + .RequireCapability(mojom::kSystemServiceName, "dwrite_font_proxy") + .RequireCapability(mojom::kSystemServiceName, "field_trials") + .RequireCapability(mojom::kSystemServiceName, "font_cache") + .RequireCapability(mojom::kSystemServiceName, "sandbox_support") .RequireCapability("*", "app") .RequireCapability("font_service", "font_service") .Build()
diff --git a/content/public/browser/download_manager_delegate.cc b/content/public/browser/download_manager_delegate.cc index 6aca5afa..5c85ac4 100644 --- a/content/public/browser/download_manager_delegate.cc +++ b/content/public/browser/download_manager_delegate.cc
@@ -53,10 +53,6 @@ return true; } -bool DownloadManagerDelegate::GenerateFileHash() { - return false; -} - std::string DownloadManagerDelegate::ApplicationClientIdForFileScanning() const { return std::string();
diff --git a/content/public/browser/download_manager_delegate.h b/content/public/browser/download_manager_delegate.h index faeeb685..3db1c15 100644 --- a/content/public/browser/download_manager_delegate.h +++ b/content/public/browser/download_manager_delegate.h
@@ -132,9 +132,6 @@ int64_t content_length, WebContents* web_contents); - // Returns true if we need to generate a binary hash for downloads. - virtual bool GenerateFileHash(); - // Retrieve the directories to save html pages and downloads to. virtual void GetSaveDir(BrowserContext* browser_context, base::FilePath* website_save_dir,
diff --git a/content/public/browser/render_widget_host_view.h b/content/public/browser/render_widget_host_view.h index ebe6ae7..07d4351 100644 --- a/content/public/browser/render_widget_host_view.h +++ b/content/public/browser/render_widget_host_view.h
@@ -263,7 +263,9 @@ // Set the last time a tab change starts to be processed for this // RenderWidgetHostView. Will overwrite any previously stored value. - virtual void SetLastTabChangeStartTime(base::TimeTicks start_time) = 0; + virtual void SetRecordTabSwitchTimeRequest(base::TimeTicks start_time, + bool destination_is_loaded, + bool destination_is_frozen) = 0; }; } // namespace content
diff --git a/content/public/common/service_names.mojom b/content/public/common/service_names.mojom index 86cf8c5..d51243a5 100644 --- a/content/public/common/service_names.mojom +++ b/content/public/common/service_names.mojom
@@ -4,8 +4,15 @@ module content.mojom; -// The default service name the browser identifies as when connecting to -// the Service Manager. +// The name of the global singleton service hosted within the Content browser +// process. This service is generally granted unfettered access to arbitrary +// capabilities. Its global instance can be used to access other services by +// using the |ServiceManagerConnection::GetForProcess()| API. +const string kSystemServiceName = "content_system"; + +// The name for service instances spawned per BrowserContext in a unique +// instance group, to isolate incoming interface requests from renderers spawned +// for that BrowserContext. const string kBrowserServiceName = "content_browser"; // The default service name used to identify the gpu process when connecting it
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index 2f635880..9d641eda 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc
@@ -1182,11 +1182,16 @@ // gesture after processing has finished here. if (WebUserGestureIndicator::IsProcessingUserGesture( render_frame_->GetWebFrame())) { - pending_user_gesture_ = - ppapi::TimeTicksToPPTimeTicks(base::TimeTicks::Now()); - pending_user_gesture_token_ = + auto user_gesture_token = WebUserGestureIndicator::CurrentUserGestureToken(); - WebUserGestureIndicator::ExtendTimeout(); + // Checking user_gesture_token.HasGestures() to make sure we are + // processing user geasture. + if (user_gesture_token.HasGestures()) { + pending_user_gesture_ = + ppapi::TimeTicksToPPTimeTicks(base::TimeTicks::Now()); + pending_user_gesture_token_ = user_gesture_token; + WebUserGestureIndicator::ExtendTimeout(); + } } // Each input event may generate more than one PP_InputEvent.
diff --git a/content/renderer/render_frame_impl_browsertest.cc b/content/renderer/render_frame_impl_browsertest.cc index 6a5c000..e195be8 100644 --- a/content/renderer/render_frame_impl_browsertest.cc +++ b/content/renderer/render_frame_impl_browsertest.cc
@@ -10,6 +10,7 @@ #include "base/bind_helpers.h" #include "base/command_line.h" #include "base/debug/leak_annotations.h" +#include "base/optional.h" #include "base/run_loop.h" #include "base/stl_util.h" #include "base/strings/utf_string_conversions.h" @@ -230,7 +231,7 @@ WidgetMsg_WasShown was_shown_message( 0, base::TimeTicks(), false /* was_evicted */, - base::TimeTicks() /* tab_switch_start_time */); + base::nullopt /* tab_switch_start_state */); frame_widget()->OnMessageReceived(was_shown_message); EXPECT_FALSE(frame_widget()->is_hidden()); @@ -269,7 +270,7 @@ WidgetMsg_WasShown was_shown_message( 0, base::TimeTicks(), false /* was_evicted */, - base::TimeTicks() /* tab_switch_start_time */); + base::nullopt /* tab_switch_start_state */); frame_widget()->OnMessageReceived(was_shown_message); EXPECT_FALSE(frame_widget()->is_hidden());
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc index 50c1595..641c9db 100644 --- a/content/renderer/render_view_browsertest.cc +++ b/content/renderer/render_view_browsertest.cc
@@ -578,13 +578,7 @@ EXPECT_FALSE(child_proxy_1->is_pinch_gesture_active_for_testing()); // Set the |is_pinch_gesture_active| flag. - cc::ApplyViewportChangesArgs args; - args.page_scale_delta = 1.f; - args.is_pinch_gesture_active = true; - args.browser_controls_delta = 0.f; - args.scroll_gesture_did_end = false; - - view()->webview()->MainFrameWidget()->ApplyViewportChanges(args); + view()->PageScaleFactorChanged(1.f, true); EXPECT_TRUE(child_proxy_1->is_pinch_gesture_active_for_testing()); // Create a new remote child, and get its proxy. Swapping out will force @@ -600,8 +594,7 @@ EXPECT_TRUE(child_proxy_2->is_pinch_gesture_active_for_testing()); // Reset the flag, make sure both children respond. - args.is_pinch_gesture_active = false; - view()->webview()->MainFrameWidget()->ApplyViewportChanges(args); + view()->PageScaleFactorChanged(1.f, false); EXPECT_FALSE(child_proxy_1->is_pinch_gesture_active_for_testing()); EXPECT_FALSE(child_proxy_2->is_pinch_gesture_active_for_testing()); }
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 25ab2ac..6a00f40 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc
@@ -2063,12 +2063,17 @@ maximum_percent)); } -void RenderViewImpl::PageScaleFactorChanged(float page_scale_factor) { +void RenderViewImpl::PageScaleFactorChanged(float page_scale_factor, + bool is_pinch_gesture_active) { if (!webview()) return; Send(new ViewHostMsg_PageScaleFactorChanged(GetRoutingID(), page_scale_factor)); + // TODO(wjmaclean): Merge this into RenderWidget's + // SetPageScaleFactorAndLimits(). + GetWidget()->PageScaleFactorChanged(page_scale_factor, + is_pinch_gesture_active); } void RenderViewImpl::PageImportanceSignalsChanged() {
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index 561588c..3a5d85b 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h
@@ -243,7 +243,8 @@ int HistoryBackListCount() override; int HistoryForwardListCount() override; void ZoomLimitsChanged(double minimum_level, double maximum_level) override; - void PageScaleFactorChanged(float page_scale_factor) override; + void PageScaleFactorChanged(float page_scale_factor, + bool is_pinch_gesture_active) override; void PageImportanceSignalsChanged() override; void DidAutoResize(const blink::WebSize& newSize) override; void DidFocus(blink::WebLocalFrame* calling_frame) override;
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 1f7e8695..b5d8bca9 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc
@@ -924,9 +924,11 @@ observer.WasHidden(); } -void RenderWidget::OnWasShown(base::TimeTicks show_request_timestamp, - bool was_evicted, - base::TimeTicks tab_switch_start_time) { +void RenderWidget::OnWasShown( + base::TimeTicks show_request_timestamp, + bool was_evicted, + const base::Optional<content::RecordTabSwitchTimeRequest>& + record_tab_switch_time_request) { // A frozen main frame widget does not become shown, since it has no frame // associated with it. It must be thawed before changing visibility. DCHECK(!is_frozen_); @@ -937,11 +939,11 @@ was_shown_time_ = base::TimeTicks::Now(); SetHidden(false); - if (!tab_switch_start_time.is_null()) { + if (record_tab_switch_time_request) { layer_tree_view_->layer_tree_host()->RequestPresentationTimeForNextFrame( - tab_switch_time_recorder_.TabWasShown(false /* has_saved_frames */, - tab_switch_start_time, - show_request_timestamp)); + tab_switch_time_recorder_.TabWasShown( + false /* has_saved_frames */, + record_tab_switch_time_request.value(), show_request_timestamp)); } for (auto& observer : render_frames_) @@ -3296,35 +3298,11 @@ allow_gpu_raster); } -void RenderWidget::SetPageScaleStateAndLimits(float page_scale_factor, - bool is_pinch_gesture_active, - float minimum, - float maximum) { +void RenderWidget::SetPageScaleFactorAndLimits(float page_scale_factor, + float minimum, + float maximum) { layer_tree_view_->layer_tree_host()->SetPageScaleFactorAndLimits( page_scale_factor, minimum, maximum); - - // Only continue if this is a mainframe, or something's actually changed. - if (!delegate() || - (page_scale_factor == page_scale_factor_from_mainframe_ && - is_pinch_gesture_active == is_pinch_gesture_active_from_mainframe_)) { - return; - } - - // The page scale is controlled by the WebView for the local main frame of - // the Page. So this is called from blink by for the RenderWidget of that - // local main frame. We forward the value on to each child RenderWidget (each - // of which will be via proxy child frame). These will each in turn forward - // the message to their child RenderWidgets (through their proxy child - // frames). - DCHECK(!is_frozen_); - - for (auto& observer : render_frame_proxies_) { - observer.OnPageScaleFactorChanged(page_scale_factor, - is_pinch_gesture_active); - } - // Store the value to give to any new RenderFrameProxy that is registered. - page_scale_factor_from_mainframe_ = page_scale_factor; - is_pinch_gesture_active_from_mainframe_ = is_pinch_gesture_active; } void RenderWidget::StartPageScaleAnimation(const gfx::Vector2d& target_offset, @@ -3604,6 +3582,26 @@ layer_tree_view_->IsSurfaceSynchronizationEnabled(); } +void RenderWidget::PageScaleFactorChanged(float page_scale_factor, + bool is_pinch_gesture_active) { + // The page scale is controlled by the WebView for the local main frame of + // the Page. So this is called from blink by for the RenderWidget of that + // local main frame. We forward the value on to each child RenderWidget (each + // of which will be via proxy child frame). These will each in turn forward + // the message to their child RenderWidgets (through their proxy child + // frames). + DCHECK(!is_frozen_); + DCHECK(delegate()); + + for (auto& observer : render_frame_proxies_) { + observer.OnPageScaleFactorChanged(page_scale_factor, + is_pinch_gesture_active); + } + // Store the value to give to any new RenderFrameProxy that is registered. + page_scale_factor_from_mainframe_ = page_scale_factor; + is_pinch_gesture_active_from_mainframe_ = is_pinch_gesture_active; +} + void RenderWidget::UseSynchronousResizeModeForTesting(bool enable) { synchronous_resize_mode_for_testing_ = enable; }
diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index 3379eec..4b0d56aa 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h
@@ -440,10 +440,9 @@ bool down) override; void FallbackCursorModeSetCursorVisibility(bool visible) override; void SetAllowGpuRasterization(bool allow_gpu_raster) override; - void SetPageScaleStateAndLimits(float page_scale_factor, - bool is_pinch_gesture_active, - float minimum, - float maximum) override; + void SetPageScaleFactorAndLimits(float page_scale_factor, + float minimum, + float maximum) override; void StartPageScaleAnimation(const gfx::Vector2d& destination, bool use_anchor, float new_page_scale, @@ -620,6 +619,9 @@ bool IsSurfaceSynchronizationEnabled() const; + void PageScaleFactorChanged(float page_scale_factor, + bool is_pinch_gesture_active); + void UseSynchronousResizeModeForTesting(bool enable); void SetDeviceScaleFactorForTesting(float factor); void SetDeviceColorSpaceForTesting(const gfx::ColorSpace& color_space); @@ -737,7 +739,8 @@ void OnWasHidden(); void OnWasShown(base::TimeTicks show_request_timestamp, bool was_evicted, - base::TimeTicks tab_switch_start_time); + const base::Optional<content::RecordTabSwitchTimeRequest>& + record_tab_switch_time_request); void OnCreateVideoAck(int32_t video_id); void OnUpdateVideoAck(int32_t video_id); void OnRequestSetBoundsAck();
diff --git a/content/shell/renderer/web_test/blink_test_runner.cc b/content/shell/renderer/web_test/blink_test_runner.cc index f2fd9f1..45347247 100644 --- a/content/shell/renderer/web_test/blink_test_runner.cc +++ b/content/shell/renderer/web_test/blink_test_runner.cc
@@ -36,7 +36,6 @@ #include "content/public/common/url_constants.h" #include "content/public/common/use_zoom_for_dsf_policy.h" #include "content/public/common/web_preferences.h" -#include "content/public/renderer/media_stream_utils.h" #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_thread.h" #include "content/public/renderer/render_view.h"
diff --git a/content/test/data/accessibility/event/aria-setsize-changed-expected-uia-win.txt b/content/test/data/accessibility/event/aria-setsize-changed-expected-uia-win.txt new file mode 100644 index 0000000..8a46dbf2 --- /dev/null +++ b/content/test/data/accessibility/event/aria-setsize-changed-expected-uia-win.txt
@@ -0,0 +1,6 @@ +AriaProperties changed on role=option, name=Li1 +AriaProperties changed on role=option, name=Li2 +AriaProperties changed on role=option, name=Li3 +SizeOfSet changed on role=option, name=Li1 +SizeOfSet changed on role=option, name=Li2 +SizeOfSet changed on role=option, name=Li3
diff --git a/content/test/data/accessibility/event/aria-setsize-changed-expected-uia-win7.txt b/content/test/data/accessibility/event/aria-setsize-changed-expected-uia-win7.txt new file mode 100644 index 0000000..6877448 --- /dev/null +++ b/content/test/data/accessibility/event/aria-setsize-changed-expected-uia-win7.txt
@@ -0,0 +1,3 @@ +AriaProperties changed on role=option, name=Li1 +AriaProperties changed on role=option, name=Li2 +AriaProperties changed on role=option, name=Li3
diff --git a/content/test/data/accessibility/event/aria-setsize-changed.html b/content/test/data/accessibility/event/aria-setsize-changed.html new file mode 100644 index 0000000..aaca1d9 --- /dev/null +++ b/content/test/data/accessibility/event/aria-setsize-changed.html
@@ -0,0 +1,22 @@ +<!DOCTYPE html> +<html> +<body> + <ul role="listbox"> + <li id="li1" role="option">Li1</li> + <li id="li2" role="option">Li2</li> + <li id="li3" role="option" aria-setsize="5">Li3</li> + </ul>> + <script> + function go() { + // Set aria-setsize to '4'; should fire an event. + document.getElementById('li1').setAttribute('aria-setsize', '4'); + + // Set aria-setsize to -1'; should fire an event. + document.getElementById('li2').setAttribute('aria-setsize', '-1'); + + // Set aria-setsize from '5'->[removed]; should fire an event. + document.getElementById('li3').removeAttribute('aria-setsize'); + } + </script> +</body> +</html>
diff --git a/content/test/data/accessibility/event/aria-slider-value-both-change-expected-uia-win.txt b/content/test/data/accessibility/event/aria-slider-value-both-change-expected-uia-win.txt new file mode 100644 index 0000000..6253bba --- /dev/null +++ b/content/test/data/accessibility/event/aria-slider-value-both-change-expected-uia-win.txt
@@ -0,0 +1,2 @@ +AriaProperties changed on role=slider +RangeValueValue changed on role=slider
diff --git a/content/test/data/accessibility/event/aria-slider-value-change-expected-uia-win.txt b/content/test/data/accessibility/event/aria-slider-value-change-expected-uia-win.txt new file mode 100644 index 0000000..6253bba --- /dev/null +++ b/content/test/data/accessibility/event/aria-slider-value-change-expected-uia-win.txt
@@ -0,0 +1,2 @@ +AriaProperties changed on role=slider +RangeValueValue changed on role=slider
diff --git a/content/test/data/accessibility/event/aria-slider-valuetext-change-expected-uia-win.txt b/content/test/data/accessibility/event/aria-slider-valuetext-change-expected-uia-win.txt new file mode 100644 index 0000000..6253bba --- /dev/null +++ b/content/test/data/accessibility/event/aria-slider-valuetext-change-expected-uia-win.txt
@@ -0,0 +1,2 @@ +AriaProperties changed on role=slider +RangeValueValue changed on role=slider
diff --git a/content/test/data/accessibility/event/aria-sort-changed-expected-uia-win.txt b/content/test/data/accessibility/event/aria-sort-changed-expected-uia-win.txt new file mode 100644 index 0000000..7b55295 --- /dev/null +++ b/content/test/data/accessibility/event/aria-sort-changed-expected-uia-win.txt
@@ -0,0 +1,4 @@ +AriaProperties changed on role=columnheader, name=columnheader2 +AriaProperties changed on role=columnheader, name=columnheader3 +AriaProperties changed on role=columnheader, name=columnheader4 +AriaProperties changed on role=columnheader, name=columnheader5
diff --git a/content/test/data/accessibility/event/aria-sort-changed.html b/content/test/data/accessibility/event/aria-sort-changed.html new file mode 100644 index 0000000..86b11a3 --- /dev/null +++ b/content/test/data/accessibility/event/aria-sort-changed.html
@@ -0,0 +1,28 @@ +<!DOCTYPE html> +<html> +<body> + <div id="ch1" aria-label="columnheader1" role="columnheader"></div> + <div id="ch2" aria-label="columnheader2" role="columnheader"></div> + <div id="ch3" aria-label="columnheader3" role="columnheader"></div> + <div id="ch4" aria-label="columnheader4" role="columnheader"></div> + <div id="ch5" aria-label="columnheader5" role="columnheader" aria-sort="ascending"></div> + <script> + function go() { + // Set aria-sort from default 'none'->'none'; should not fire an event. + document.getElementById('ch1').setAttribute('aria-sort', 'none'); + + // Set aria-sort from default 'none'->'ascending'; should fire an event. + document.getElementById('ch2').setAttribute('aria-sort', 'ascending'); + + // Set aria-sort from default 'none'->'descending'; should fire an event. + document.getElementById('ch3').setAttribute('aria-sort', 'descending'); + + // Set aria-sort from default 'none'->'other'; should fire an event. + document.getElementById('ch4').setAttribute('aria-sort', 'other'); + + // Set aria-sort from 'ascending'->[removed]; should fire an event. + document.getElementById('ch5').removeAttribute('aria-sort'); + } + </script> +</body> +</html>
diff --git a/content/test/data/accessibility/event/aria-spinbutton-value-both-change-expected-uia-win.txt b/content/test/data/accessibility/event/aria-spinbutton-value-both-change-expected-uia-win.txt new file mode 100644 index 0000000..78c3df70 --- /dev/null +++ b/content/test/data/accessibility/event/aria-spinbutton-value-both-change-expected-uia-win.txt
@@ -0,0 +1,2 @@ +AriaProperties changed on role=spinbutton +RangeValueValue changed on role=spinbutton
diff --git a/content/test/data/accessibility/event/aria-spinbutton-value-change-expected-uia-win.txt b/content/test/data/accessibility/event/aria-spinbutton-value-change-expected-uia-win.txt new file mode 100644 index 0000000..78c3df70 --- /dev/null +++ b/content/test/data/accessibility/event/aria-spinbutton-value-change-expected-uia-win.txt
@@ -0,0 +1,2 @@ +AriaProperties changed on role=spinbutton +RangeValueValue changed on role=spinbutton
diff --git a/content/test/data/accessibility/event/aria-spinbutton-valuetext-change-expected-uia-win.txt b/content/test/data/accessibility/event/aria-spinbutton-valuetext-change-expected-uia-win.txt new file mode 100644 index 0000000..78c3df70 --- /dev/null +++ b/content/test/data/accessibility/event/aria-spinbutton-valuetext-change-expected-uia-win.txt
@@ -0,0 +1,2 @@ +AriaProperties changed on role=spinbutton +RangeValueValue changed on role=spinbutton
diff --git a/content/test/data/accessibility/event/aria-spinbutton-valuetext-change.html b/content/test/data/accessibility/event/aria-spinbutton-valuetext-change.html index b0f299e..19f8ff43 100644 --- a/content/test/data/accessibility/event/aria-spinbutton-valuetext-change.html +++ b/content/test/data/accessibility/event/aria-spinbutton-valuetext-change.html
@@ -2,6 +2,9 @@ <!-- @WIN-DENY:* @WIN-ALLOW:EVENT_OBJECT_VALUECHANGE* +@UIA-WIN-DENY:* +@UIA-WIN-ALLOW:AriaProperties* +@UIA-WIN-ALLOW:RangeValueValue* @MAC-DENY:AXLayoutComplete* --> <html>
diff --git a/content/test/data/accessibility/event/range-value-maximum-changed-expected-uia-win.txt b/content/test/data/accessibility/event/range-value-maximum-changed-expected-uia-win.txt index f2fc13a..4a94fe82 100644 --- a/content/test/data/accessibility/event/range-value-maximum-changed-expected-uia-win.txt +++ b/content/test/data/accessibility/event/range-value-maximum-changed-expected-uia-win.txt
@@ -1,7 +1,11 @@ +AriaProperties changed on role=slider RangeValueMaximum changed on role=slider === Start Continuation === +AriaProperties changed on role=slider RangeValueMaximum changed on role=slider === Start Continuation === +AriaProperties changed on role=slider RangeValueMaximum changed on role=slider === Start Continuation === +AriaProperties changed on role=slider RangeValueMaximum changed on role=slider
diff --git a/content/test/data/accessibility/event/range-value-minimum-changed-expected-uia-win.txt b/content/test/data/accessibility/event/range-value-minimum-changed-expected-uia-win.txt index 7082fc9..417717b 100644 --- a/content/test/data/accessibility/event/range-value-minimum-changed-expected-uia-win.txt +++ b/content/test/data/accessibility/event/range-value-minimum-changed-expected-uia-win.txt
@@ -1,7 +1,11 @@ +AriaProperties changed on role=slider RangeValueMinimum changed on role=slider === Start Continuation === +AriaProperties changed on role=slider RangeValueMinimum changed on role=slider === Start Continuation === +AriaProperties changed on role=slider RangeValueMinimum changed on role=slider === Start Continuation === +AriaProperties changed on role=slider RangeValueMinimum changed on role=slider
diff --git a/content/test/data/accessibility/event/range-value-step-changed-expected-uia-win.txt b/content/test/data/accessibility/event/range-value-step-changed-expected-uia-win.txt index 1b554de..44b0c33 100644 --- a/content/test/data/accessibility/event/range-value-step-changed-expected-uia-win.txt +++ b/content/test/data/accessibility/event/range-value-step-changed-expected-uia-win.txt
@@ -4,6 +4,7 @@ RangeValueLargeChange changed on role=slider RangeValueSmallChange changed on role=slider === Start Continuation === +AriaProperties changed on role=slider RangeValueLargeChange changed on role=slider RangeValueSmallChange changed on role=slider RangeValueValue changed on role=slider
diff --git a/content/test/data/accessibility/event/range-value-value-changed-expected-uia-win.txt b/content/test/data/accessibility/event/range-value-value-changed-expected-uia-win.txt index 40fa0e8..5363079 100644 --- a/content/test/data/accessibility/event/range-value-value-changed-expected-uia-win.txt +++ b/content/test/data/accessibility/event/range-value-value-changed-expected-uia-win.txt
@@ -1,7 +1,11 @@ +AriaProperties changed on role=slider RangeValueValue changed on role=slider === Start Continuation === +AriaProperties changed on role=slider RangeValueValue changed on role=slider === Start Continuation === +AriaProperties changed on role=slider RangeValueValue changed on role=slider === Start Continuation === +AriaProperties changed on role=slider RangeValueValue changed on role=slider
diff --git a/content/test/gpu/gpu_tests/test_expectations/webgl_conformance_expectations.txt b/content/test/gpu/gpu_tests/test_expectations/webgl_conformance_expectations.txt index 239d96e..257bf61c 100644 --- a/content/test/gpu/gpu_tests/test_expectations/webgl_conformance_expectations.txt +++ b/content/test/gpu/gpu_tests/test_expectations/webgl_conformance_expectations.txt
@@ -1,8 +1,9 @@ # tags: [ android chromeos linux mac win win10 win7 ] # tags: [ android-chromium android-webview-instrumentation debug release ] # tags: [ amd amd-0x6613 amd-0x699f intel intel-0xa011 intel-0xa2e nvidia -# nvidia-0x1cb3 nvidia-0xfe9 qualcomm qualcomm-adreno-(tm)-330 -# qualcomm-adreno-(tm)-418 qualcomm-adreno-(tm)-420 qualcomm-adreno-(tm)-430 ] +# nvidia-0x1cb3 nvidia-0x2184 nvidia-0xfe9 qualcomm +# qualcomm-adreno-(tm)-330 qualcomm-adreno-(tm)-418 +# qualcomm-adreno-(tm)-420 qualcomm-adreno-(tm)-430 ] # tags: [ d3d11 d3d9 no-angle opengl opengles vulkan ] # tags: [ no-passthrough passthrough ] # tags: [ webgl-version-1 ] @@ -249,7 +250,7 @@ crbug.com/angleproject/2192 [ win d3d9 passthrough ] conformance/textures/webgl_canvas/tex-2d-luminance-luminance-unsigned_byte.html [ Failure ] crbug.com/angleproject/2192 [ win d3d9 passthrough ] conformance/textures/webgl_canvas/tex-2d-luminance_alpha-luminance_alpha-unsigned_byte.html [ Failure ] -# Vulkan / Win / Passthough command decoder +# Vulkan / Win / Passthrough command decoder crbug.com/angleproject/2708 [ win vulkan passthrough ] conformance/attribs/gl-vertex-attrib-unconsumed-out-of-bounds.html [ Failure ] crbug.com/angleproject/2929 [ win vulkan passthrough ] conformance/canvas/canvas-test.html [ Failure ] crbug.com/angleproject/2918 [ win vulkan passthrough ] conformance/canvas/draw-static-webgl-to-multiple-canvas-test.html [ Failure ] @@ -296,10 +297,11 @@ crbug.com/angleproject/2394 [ win vulkan passthrough ] WebglExtension_WEBGL_draw_buffers [ Failure ] crbug.com/angleproject/3111 [ win vulkan passthrough ] deqp/data/gles2/shaders/swizzles.html [ Skip ] -# Vulkan / Win / NVIDIA / Passthough command decoder +# Vulkan / Win / NVIDIA / Passthrough command decoder crbug.com/angleproject/2918 [ win nvidia vulkan passthrough ] conformance/canvas/to-data-url-test.html [ Failure ] crbug.com/angleproject/2922 [ win nvidia vulkan passthrough ] conformance/context/premultiplyalpha-test.html [ Failure ] crbug.com/963205 [ win nvidia vulkan passthrough ] conformance/extensions/webgl-compressed-texture-s3tc-srgb.html [ Failure ] +crbug.com/964321 [ win nvidia vulkan passthrough ] conformance/extensions/webgl-compressed-texture-s3tc.html [ RetryOnFailure ] crbug.com/963217 [ win nvidia vulkan passthrough ] conformance/glsl/samplers/glsl-function-texture2dprojlod.html [ Failure ] crbug.com/angleproject/2915 [ win nvidia vulkan passthrough ] conformance/limits/gl-max-texture-dimensions.html [ Failure ] crbug.com/angleproject/2939 [ win nvidia vulkan passthrough ] conformance/rendering/gl-scissor-fbo-test.html [ RetryOnFailure ] @@ -308,10 +310,14 @@ crbug.com/angleproject/2930 [ win nvidia vulkan passthrough ] conformance/textures/misc/texture-size-cube-maps.html [ Failure ] crbug.com/angleproject/2926 [ win nvidia vulkan passthrough ] deqp/data/gles2/shaders/conversions.html [ Failure ] -# Vulkan / Win / Intel / Passthough command decoder +# Vulkan / Win10 / NVIDIA GeForce GTX 1660 / Passthrough command decoder +crbug.com/964331 [ win10 nvidia-0x2184 vulkan passthrough ] conformance/ogles/GL/pow/pow_009_to_016.html [ Failure ] +crbug.com/964331 [ win10 nvidia-0x2184 vulkan passthrough ] conformance/ogles/GL/pow/pow_017_to_024.html [ Failure ] + +# Vulkan / Win / Intel / Passthrough command decoder crbug.com/angleproject/2722 [ win intel vulkan passthrough ] conformance/rendering/clipping-wide-points.html [ Failure ] -# Vulkan / Win / AMD / Passthough command decoder +# Vulkan / Win / AMD / Passthrough command decoder crbug.com/angleproject/2931 [ win amd vulkan passthrough ] conformance/buffers/buffer-data-dynamic-delay.html [ Failure ] crbug.com/angleproject/2918 [ win amd vulkan passthrough ] conformance/canvas/to-data-url-test.html [ Failure ] crbug.com/angleproject/2922 [ win amd vulkan passthrough ] conformance/context/premultiplyalpha-test.html [ Failure ]
diff --git a/content/test/test_render_view_host.cc b/content/test/test_render_view_host.cc index ca53952..f0af4a6 100644 --- a/content/test/test_render_view_host.cc +++ b/content/test/test_render_view_host.cc
@@ -6,6 +6,7 @@ #include <memory> +#include "base/optional.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "components/viz/common/surfaces/parent_local_surface_id_allocator.h" @@ -300,7 +301,7 @@ } void TestRenderViewHost::SimulateWasShown() { - GetWidget()->WasShown(false /* record_presentation_time */); + GetWidget()->WasShown(base::nullopt /* record_tab_switch_time_request */); } WebPreferences TestRenderViewHost::TestComputeWebPreferences() {
diff --git a/device/fido/get_assertion_task.cc b/device/fido/get_assertion_task.cc index 6bba57c..e0824c5 100644 --- a/device/fido/get_assertion_task.cc +++ b/device/fido/get_assertion_task.cc
@@ -92,18 +92,18 @@ // authenticators rejecting lists over a certain size. Also probe silently if // the request may fall back to U2F and the authenticator doesn't recognize // any of the provided credential IDs. - if ((request_.allow_list.size() > 1 || + if (((request_.allow_list.size() > 1 && + // If the device supports credProtect then it might have UV-required + // credentials which it'll pretend don't exist for silent requests. + // TODO(agl): should support batching of, and filtering over-long, + // credentials based on GetInfo data. Also should support + // PIN-authenticated silent requests. + !device()->device_info()->options.supports_cred_protect) || MayFallbackToU2fWithAppIdExtension(*device(), request_)) && // caBLE devices might not support silent probing so don't do it with // them. device()->DeviceTransport() != - FidoTransportProtocol::kCloudAssistedBluetoothLowEnergy && - // If the device supports credProtect then it might have UV-required - // credentials which it'll pretend don't exist for silent requests. - // TODO(agl): should support batching of, and filtering over-long, - // credentials based on GetInfo data. Also should support - // PIN-authenticated silent requests. - !device()->device_info()->options.supports_cred_protect) { + FidoTransportProtocol::kCloudAssistedBluetoothLowEnergy) { sign_operation_ = std::make_unique<Ctap2DeviceOperation< CtapGetAssertionRequest, AuthenticatorGetAssertionResponse>>( device(), NextSilentRequest(),
diff --git a/docs/login/fingerprint.md b/docs/login/fingerprint.md new file mode 100644 index 0000000..b40f6fe --- /dev/null +++ b/docs/login/fingerprint.md
@@ -0,0 +1,31 @@ +# Fingerprint Enrollment + +Fingerprint scanners are an easy way for users to authenticate to their devices. +As per current policy, up to 3 fingerprints can be enrolled per user per device. +On devices that have fingerprint sensors, users can enroll their fingerprints: +1. during the user login OOBE in the Fingerprint Enrollment screen +2. in lock screen settings page (chrome://settings/lockScreen). + +The OOBE Fingerprint Enrollment screen is shown in the middle of OOBE flow and +can be skipped. It prompts the user to enroll a fingerprint up to 3 times and +shows progress during enrollment. + +The lock screen settings page is hidden behind a password prompt that creates +an authentication token. This auth token is needed to successfully enroll +fingerprints. Enrollment can only be started if the user has less than 3 +fingerprints enrolled. + +While fingerprint setup depends on biod system dbus service, Chromium implements +a fake dbus client (`FakeBiodClient`) that fakes interactions with the biod +dbus service. Tests can use `FakeBiodClient` to create an enrollment session and +simulate fingerprint enrollment scan progress. + +Fingerprint unlock policy is dependent on device policy and hardware specs. +Fingerprint can be manually enabled for testing by calling: +chromeos::quick_unlock::EnabledForTesting(true) to force enable fingerprint features. + +Fingerprint unlock is not considered strong authentication. This means that, +under certain policies, fingerprint cannot be the only method of authentication +used over an extended period of time. After a designated amount of time, the +user's is notified that a password must be used to login which will mark strong +auth and re-enable fingerprint unlock.
diff --git a/extensions/renderer/api/automation/automation_ax_tree_wrapper.cc b/extensions/renderer/api/automation/automation_ax_tree_wrapper.cc index c733f4158..fc73a8a 100644 --- a/extensions/renderer/api/automation/automation_ax_tree_wrapper.cc +++ b/extensions/renderer/api/automation/automation_ax_tree_wrapper.cc
@@ -213,6 +213,7 @@ case ui::AXEventGenerator::Event::READONLY_CHANGED: case ui::AXEventGenerator::Event::REQUIRED_STATE_CHANGED: case ui::AXEventGenerator::Event::SET_SIZE_CHANGED: + case ui::AXEventGenerator::Event::SORT_CHANGED: case ui::AXEventGenerator::Event::SUBTREE_CREATED: case ui::AXEventGenerator::Event::VALUE_MAX_CHANGED: case ui::AXEventGenerator::Event::VALUE_MIN_CHANGED:
diff --git a/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.cc b/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.cc index cedd584..81e42bcf 100644 --- a/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.cc +++ b/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.cc
@@ -9,7 +9,6 @@ #include "base/rand_util.h" #include "base/task_runner_util.h" #include "base/threading/thread_task_runner_handle.h" -#include "content/public/renderer/media_stream_utils.h" #include "content/public/renderer/media_stream_video_sink.h" #include "content/public/renderer/render_thread.h" #include "content/public/renderer/video_encode_accelerator.h"
diff --git a/infra/config/cr-buildbucket.cfg b/infra/config/cr-buildbucket.cfg index b8e5b09..c6edc3b 100644 --- a/infra/config/cr-buildbucket.cfg +++ b/infra/config/cr-buildbucket.cfg
@@ -2355,19 +2355,6 @@ dimensions: "os:Ubuntu-14.04" mixins: "fuzz-ci" } - # TODO(crbug.com/888810): Remove once these bots are migrated. - builders { - name: "win-dbg" - dimensions: "os:Windows-10" - dimensions: "cores:32" - mixins: "chromium-ci" - } - builders { - name: "win-rel" - dimensions: "os:Windows-10" - dimensions: "cores:32" - mixins: "chromium-ci" - } builders { name: "win-archive-dbg" dimensions: "os:Windows-10" @@ -2390,20 +2377,6 @@ dimensions: "os:Ubuntu-14.04" mixins: "memory-ci" } - # TODO(crbug.com/888810): Remove once these bots are migrated. - builders { - name: "android-dbg" - dimensions: "os:Ubuntu-14.04" - # Bump to 32 if needed. - dimensions: "cores:8" - mixins: "chromium-ci" - } - builders { - name: "android-rel" - dimensions: "os:Ubuntu-14.04" - dimensions: "cores:32" - mixins: "chromium-ci" - } builders { name: "android-archive-dbg" dimensions: "os:Ubuntu-14.04" @@ -2575,20 +2548,6 @@ dimensions: "cores:4" mixins: "fyi-ci" } - # TODO(crbug.com/888810): Remove once these bots are migrated. - builders { - name: "linux-dbg" - dimensions: "os:Ubuntu-14.04" - # Bump to 32 if needed. - dimensions: "cores:8" - mixins: "chromium-ci" - } - builders { - name: "linux-rel" - dimensions: "os:Ubuntu-14.04" - dimensions: "cores:32" - mixins: "chromium-ci" - } builders { name: "linux-archive-dbg" dimensions: "os:Ubuntu-14.04" @@ -2705,19 +2664,6 @@ dimensions: "os:Windows-10" mixins: "fuzz-ci" } - # TODO(crbug.com/888810): Remove once these bots are migrated. - builders { - name: "mac-dbg" - dimensions: "os:Mac-10.13" - # Bump to 8 cores if needed. - dimensions: "cores:4" - mixins: "chromium-ci" - } - builders { - name: "mac-rel" - dimensions: "os:Mac-10.13" - mixins: "chromium-ci" - } builders { name: "mac-archive-dbg" dimensions: "os:Mac-10.13" @@ -2769,19 +2715,6 @@ dimensions: "os:Windows-10" mixins: "win-ci" } - # TODO(crbug.com/888810): Remove once these bots are migrated. - builders { - name: "win32-dbg" - dimensions: "os:Windows-10" - dimensions: "cores:32" - mixins: "chromium-ci" - } - builders { - name: "win32-rel" - dimensions: "os:Windows-10" - dimensions: "cores:32" - mixins: "chromium-ci" - } builders { name: "win32-archive-dbg" dimensions: "os:Windows-10"
diff --git a/infra/config/luci-milo.cfg b/infra/config/luci-milo.cfg index 1051d56..18f7af0d 100644 --- a/infra/config/luci-milo.cfg +++ b/infra/config/luci-milo.cfg
@@ -4104,10 +4104,6 @@ builders { name: "buildbucket/luci.chromium.try/mac_chromium_dbg_ng" } - # TODO(https://crbug.com/888810): Remove in Q2 2019 - builders { - name: "buildbucket/luci.chromium.try/mac_chromium_rel_ng" - } builders { name: "buildbucket/luci.chromium.try/mac_chromium_10.13_rel_ng" } @@ -4224,10 +4220,6 @@ builders { name: "buildbucket/luci.chromium.try/win7_chromium_rel_loc_exp" } - # TODO(https://crbug.com/888810): Remove in Q2 2019 - builders { - name: "buildbucket/luci.chromium.try/win7_chromium_rel_ng" - } builders { name: "buildbucket/luci.chromium.try/win_archive" } @@ -4689,10 +4681,6 @@ builders { name: "buildbucket/luci.chromium.try/linux_chromium_msan_rel_ng" } - # TODO(https://crbug.com/888810): Remove in Q2 2019 - builders { - name: "buildbucket/luci.chromium.try/linux_chromium_rel_ng" - } builders { name: "buildbucket/luci.chromium.try/linux_chromium_tsan_rel_ng" } @@ -4777,10 +4765,6 @@ builders { name: "buildbucket/luci.chromium.try/mac_chromium_dbg_ng" } - # TODO(https://crbug.com/888810): Remove in Q2 2019 - builders { - name: "buildbucket/luci.chromium.try/mac_chromium_rel_ng" - } builders { name: "buildbucket/luci.chromium.try/mac_optional_gpu_tests_rel" } @@ -4802,10 +4786,6 @@ builders { name: "buildbucket/luci.chromium.try/win10_chromium_x64_rel_ng_exp" } - # TODO(https://crbug.com/888810): Remove in Q2 2019 - builders { - name: "buildbucket/luci.chromium.try/win7_chromium_rel_ng" - } builders { name: "buildbucket/luci.chromium.try/win7_chromium_rel_loc_exp" }
diff --git a/ios/chrome/browser/infobars/infobar_badge_tab_helper.h b/ios/chrome/browser/infobars/infobar_badge_tab_helper.h index d12c8d4..8429b44 100644 --- a/ios/chrome/browser/infobars/infobar_badge_tab_helper.h +++ b/ios/chrome/browser/infobars/infobar_badge_tab_helper.h
@@ -39,6 +39,8 @@ // Returns wheter an Infobar badge is being displayed for the TabHelper // Webstate. bool is_infobar_displaying(); + // Returns whether the Infobar badge is active. + bool is_badge_active(); // Returns the type of the Infobar being displayed. InfobarType infobar_type(); @@ -64,6 +66,8 @@ bool is_infobar_displaying_; // The type of the Infobar being displayed. InfobarType infobar_type_; + // Returns whether the Infobar badge is active. + bool is_badge_active_ = false; WEB_STATE_USER_DATA_KEY_DECL(); DISALLOW_COPY_AND_ASSIGN(InfobarBadgeTabHelper);
diff --git a/ios/chrome/browser/infobars/infobar_badge_tab_helper.mm b/ios/chrome/browser/infobars/infobar_badge_tab_helper.mm index 383390b..9a76364a 100644 --- a/ios/chrome/browser/infobars/infobar_badge_tab_helper.mm +++ b/ios/chrome/browser/infobars/infobar_badge_tab_helper.mm
@@ -45,6 +45,7 @@ void InfobarBadgeTabHelper::UpdateBadgeForInfobarAccepted() { delegate_.badgeState |= InfobarBadgeStateAccepted; + is_badge_active_ = true; } bool InfobarBadgeTabHelper::is_infobar_displaying() { @@ -55,6 +56,10 @@ return infobar_type_; } +bool InfobarBadgeTabHelper::is_badge_active() { + return is_badge_active_; +} + InfobarBadgeTabHelper::~InfobarBadgeTabHelper() = default; #pragma mark - Private
diff --git a/ios/chrome/browser/infobars/infobar_metrics_recorder.h b/ios/chrome/browser/infobars/infobar_metrics_recorder.h index 30cb4dd..cdaa336 100644 --- a/ios/chrome/browser/infobars/infobar_metrics_recorder.h +++ b/ios/chrome/browser/infobars/infobar_metrics_recorder.h
@@ -59,6 +59,18 @@ kMaxValue = SettingsOpened, }; +// Values for the UMA Mobile.Messages.Badge.Tapped histogram. These values +// are persisted to logs. Entries should not be renumbered and numeric values +// should never be reused. +enum class MobileMessagesBadgeState { + // Infobar Badge is inactive. + Inactive = 0, + // Infobar Badge is active. + Active = 1, + // Highest enumerator. Recommended by Histogram metrics best practices. + kMaxValue = Active, +}; + // Used to record metrics related to Infobar events. @interface InfobarMetricsRecorder : NSObject @@ -76,6 +88,9 @@ // Records histogram for Modal |event|. - (void)recordModalEvent:(MobileMessagesModalEvent)event; +// Records histogram for Badge Tapped in |state|. +- (void)recordBadgeTappedInState:(MobileMessagesBadgeState)state; + @end #endif // IOS_CHROME_BROWSER_INFOBARS_INFOBAR_METRICS_RECORDER_H_
diff --git a/ios/chrome/browser/infobars/infobar_metrics_recorder.mm b/ios/chrome/browser/infobars/infobar_metrics_recorder.mm index 8b90820f..68c744f 100644 --- a/ios/chrome/browser/infobars/infobar_metrics_recorder.mm +++ b/ios/chrome/browser/infobars/infobar_metrics_recorder.mm
@@ -21,6 +21,9 @@ // Modal. const char kInfobarConfirmModalEventHistogram[] = "Mobile.Messages.Modal.Event.InfobarTypeConfirm"; +// Badge. +const char kInfobarConfirmBadgeTappedHistogram[] = + "Mobile.Messages.Badge.Tapped.InfobarTypeConfirm"; // Histogram names for InfobarTypePasswordSave. // Banner. @@ -31,6 +34,9 @@ // Modal. const char kInfobarPasswordSaveModalEventHistogram[] = "Mobile.Messages.Modal.Event.InfobarTypePasswordSave"; +// Badge. +const char kInfobarPasswordSaveBadgeTappedHistogram[] = + "Mobile.Messages.Badge.Tapped.InfobarTypePasswordSave"; // Histogram names for InfobarTypePasswordUpdate. // Banner. @@ -41,6 +47,9 @@ // Modal. const char kInfobarPasswordUpdateModalEventHistogram[] = "Mobile.Messages.Modal.Event.InfobarTypePasswordUpdate"; +// Badge. +const char kInfobarPasswordUpdateBadgeTappedHistogram[] = + "Mobile.Messages.Badge.Tapped.InfobarTypePasswordUpdate"; } // namespace @@ -109,4 +118,20 @@ } } +- (void)recordBadgeTappedInState:(MobileMessagesBadgeState)state { + switch (self.infobarType) { + case InfobarType::kInfobarTypeConfirm: + UMA_HISTOGRAM_ENUMERATION(kInfobarConfirmBadgeTappedHistogram, state); + break; + case InfobarType::kInfobarTypePasswordSave: + UMA_HISTOGRAM_ENUMERATION(kInfobarPasswordSaveBadgeTappedHistogram, + state); + break; + case InfobarType::kInfobarTypePasswordUpdate: + UMA_HISTOGRAM_ENUMERATION(kInfobarPasswordUpdateBadgeTappedHistogram, + state); + break; + } +} + @end
diff --git a/ios/chrome/browser/metrics/tab_usage_recorder_egtest.mm b/ios/chrome/browser/metrics/tab_usage_recorder_egtest.mm index db28015..9c6da2f 100644 --- a/ios/chrome/browser/metrics/tab_usage_recorder_egtest.mm +++ b/ios/chrome/browser/metrics/tab_usage_recorder_egtest.mm
@@ -20,7 +20,6 @@ #import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/histogram_test_util.h" -#include "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/app/tab_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h" #import "ios/chrome/test/earl_grey/chrome_actions.h" @@ -396,7 +395,8 @@ // A blank tab needed to switch to it after reloading. CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]); CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]); - chrome_test_util::LoadUrl(slowURL); + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:slowURL + waitForCompletion:NO]); CHROME_EG_ASSERT_NO_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs()); web::test::SetUpHttpServer(std::make_unique<web::DelayedResponseProvider>( @@ -416,7 +416,7 @@ GREYAssert( [[GREYCondition conditionWithName:@"Wait for tab to restart loading." block:^BOOL() { - return chrome_test_util::IsLoading(); + return [ChromeEarlGrey isLoading]; }] waitWithTimeout:kWaitElementTimeout], @"Tab did not start loading."); [[GREYConfiguration sharedInstance] @@ -528,8 +528,8 @@ chrome_test_util::HistogramTester histogramTester; CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]); - chrome_test_util::LoadUrl(slowURL); - + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:slowURL + waitForCompletion:NO]); CHROME_EG_ASSERT_NO_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs()); web::test::SetUpHttpServer(std::make_unique<web::DelayedResponseProvider>( @@ -585,7 +585,8 @@ [[GREYConfiguration sharedInstance] setValue:@(NO) forConfigKey:kGREYConfigKeySynchronizationEnabled]; - chrome_test_util::LoadUrl(slowURL); + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:slowURL + waitForCompletion:NO]); // Ensure loading starts but is not finished. base::test::ios::SpinRunLoopWithMaxDelay(base::TimeDelta::FromSeconds(1));
diff --git a/ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h b/ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h index 209f1b7..e8aaeed 100644 --- a/ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h +++ b/ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h
@@ -41,6 +41,7 @@ GetBlockedNavigations() const override; bool IsPlaceholderTab() const override; bool ShouldSync(sync_sessions::SyncSessionsClient* sessions_client) override; + int64_t GetTaskIdForNavigationId(int nav_id) const override; private: explicit IOSChromeSyncedTabDelegate(web::WebState* web_state);
diff --git a/ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.mm b/ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.mm index 5b1f3f8..af9d7c9 100644 --- a/ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.mm +++ b/ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.mm
@@ -135,4 +135,9 @@ return false; } +int64_t IOSChromeSyncedTabDelegate::GetTaskIdForNavigationId(int nav_id) const { + // TODO: (davidjm) Implement for iOS - bug 964356 + return -1; +} + WEB_STATE_USER_DATA_KEY_IMPL(IOSChromeSyncedTabDelegate)
diff --git a/ios/chrome/browser/tabs/tab.h b/ios/chrome/browser/tabs/tab.h index 3e1de85..13da8d44 100644 --- a/ios/chrome/browser/tabs/tab.h +++ b/ios/chrome/browser/tabs/tab.h
@@ -10,7 +10,6 @@ #include <memory> #include <vector> -#include "ios/net/request_tracker.h" #include "ios/web/public/user_agent.h" #include "ui/base/page_transition_types.h"
diff --git a/ios/chrome/browser/tabs/tab_private.h b/ios/chrome/browser/tabs/tab_private.h index 0957a0e..4abd1f6 100644 --- a/ios/chrome/browser/tabs/tab_private.h +++ b/ios/chrome/browser/tabs/tab_private.h
@@ -5,8 +5,6 @@ #ifndef IOS_CHROME_BROWSER_TABS_TAB_PRIVATE_H_ #define IOS_CHROME_BROWSER_TABS_TAB_PRIVATE_H_ -#include "ios/net/request_tracker.h" - @class CRWWebController; // Exposed private methods for testing purpose.
diff --git a/ios/chrome/browser/translate/legacy_translate_infobar_egtest.mm b/ios/chrome/browser/translate/legacy_translate_infobar_egtest.mm index 30320a4..af95c022 100644 --- a/ios/chrome/browser/translate/legacy_translate_infobar_egtest.mm +++ b/ios/chrome/browser/translate/legacy_translate_infobar_egtest.mm
@@ -27,7 +27,6 @@ #include "ios/chrome/browser/translate/chrome_ios_translate_client.h" #include "ios/chrome/browser/ui/translate/language_selection_view_controller.h" #import "ios/chrome/test/app/chrome_test_util.h" -#include "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/app/tab_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
diff --git a/ios/chrome/browser/ui/browser_view/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view/browser_view_controller.mm index 727a0c38..17650d8a 100644 --- a/ios/chrome/browser/ui/browser_view/browser_view_controller.mm +++ b/ios/chrome/browser/ui/browser_view/browser_view_controller.mm
@@ -1447,8 +1447,6 @@ [self.commandDispatcher stopDispatchingToTarget:self]; self.commandDispatcher = nil; - [self.tabStripCoordinator stop]; - self.tabStripCoordinator = nil; [self.primaryToolbarCoordinator stop]; self.primaryToolbarCoordinator = nil; [self.secondaryToolbarContainerCoordinator stop]; @@ -1458,7 +1456,6 @@ [_downloadManagerCoordinator stop]; _downloadManagerCoordinator = nil; self.toolbarInterface = nil; - self.tabStripView = nil; [self.infobarContainerCoordinator stop]; self.infobarContainerCoordinator = nil; // SideSwipeController is a tab model observer, so it needs to stop observing
diff --git a/ios/chrome/browser/ui/location_bar/location_bar_mediator.mm b/ios/chrome/browser/ui/location_bar/location_bar_mediator.mm index cc07e15..1d0a7b6 100644 --- a/ios/chrome/browser/ui/location_bar/location_bar_mediator.mm +++ b/ios/chrome/browser/ui/location_bar/location_bar_mediator.mm
@@ -195,6 +195,8 @@ [self.consumer displayInfobarBadge:infobarBadgeTabHelper->is_infobar_displaying() type:infobarBadgeTabHelper->infobar_type()]; + [self.consumer + activeInfobarBadge:infobarBadgeTabHelper->is_badge_active()]; } }
diff --git a/ios/chrome/browser/ui/location_bar/location_bar_view_controller.mm b/ios/chrome/browser/ui/location_bar/location_bar_view_controller.mm index e21c90a..06350f4 100644 --- a/ios/chrome/browser/ui/location_bar/location_bar_view_controller.mm +++ b/ios/chrome/browser/ui/location_bar/location_bar_view_controller.mm
@@ -67,6 +67,10 @@ // Used to build and record Infobar metrics. @property(nonatomic, strong) InfobarMetricsRecorder* infobarMetricsRecorder; +// Whether the InfobarBadge is active or not. +// TODO(crbug.com/961343): Move this into a future BadgeContainer. +@property(nonatomic, assign) BOOL activeBadge; + // Starts voice search, updating the NamedGuide to be constrained to the // trailing button. - (void)startVoiceSearch; @@ -461,18 +465,27 @@ DCHECK(IsInfobarUIRebootEnabled()); [self.locationBarSteadyView.leadingButton - addTarget:self.dispatcher + addTarget:self action:@selector(displayModalInfobar) forControlEvents:UIControlEventTouchUpInside]; // Set as hidden as it should only be shown by |displayInfobarButton:| self.locationBarSteadyView.leadingButton.hidden = YES; } +- (void)displayModalInfobar { + MobileMessagesBadgeState state = self.activeBadge + ? MobileMessagesBadgeState::Active + : MobileMessagesBadgeState::Inactive; + [self.infobarMetricsRecorder recordBadgeTappedInState:state]; + [self.dispatcher displayModalInfobar]; +} + - (void)setInfobarButtonStyleSelected:(BOOL)selected { [self.locationBarSteadyView.leadingButton setSelected:selected animated:YES]; } - (void)setInfobarButtonStyleActive:(BOOL)active { + self.activeBadge = active; [self.locationBarSteadyView.leadingButton setActive:active animated:YES]; }
diff --git a/ios/chrome/browser/ui/print/print_controller_egtest.mm b/ios/chrome/browser/ui/print/print_controller_egtest.mm index bdff2940..46e448b5 100644 --- a/ios/chrome/browser/ui/print/print_controller_egtest.mm +++ b/ios/chrome/browser/ui/print/print_controller_egtest.mm
@@ -10,7 +10,6 @@ #import "ios/chrome/browser/ui/util/uikit_ui_util.h" #include "ios/chrome/grit/ios_strings.h" #import "ios/chrome/test/app/chrome_test_util.h" -#include "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_error_util.h" @@ -58,7 +57,7 @@ responses[url] = response; web::test::SetUpSimpleHttpServer(responses); - chrome_test_util::LoadUrl(url); + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:url]); CHROME_EG_ASSERT_NO_ERROR( [ChromeEarlGrey waitForWebViewContainingText:response]); @@ -72,7 +71,7 @@ web::test::SetUpFileBasedHttpServer(); GURL url = web::test::HttpServer::MakeUrl(kPDFURL); - chrome_test_util::LoadUrl(url); + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:url waitForCompletion:NO]); [self printCurrentPage]; }
diff --git a/ios/chrome/browser/ui/reading_list/reading_list_egtest.mm b/ios/chrome/browser/ui/reading_list/reading_list_egtest.mm index 7cada1d..4bf0762 100644 --- a/ios/chrome/browser/ui/reading_list/reading_list_egtest.mm +++ b/ios/chrome/browser/ui/reading_list/reading_list_egtest.mm
@@ -28,7 +28,6 @@ #include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_theme_resources.h" #import "ios/chrome/test/app/chrome_test_util.h" -#include "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/app/tab_test_util.h" #import "ios/chrome/test/earl_grey/accessibility_util.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
diff --git a/ios/chrome/browser/ui/sad_tab/sad_tab_view_egtest.mm b/ios/chrome/browser/ui/sad_tab/sad_tab_view_egtest.mm index e2afb81..431b9f33 100644 --- a/ios/chrome/browser/ui/sad_tab/sad_tab_view_egtest.mm +++ b/ios/chrome/browser/ui/sad_tab/sad_tab_view_egtest.mm
@@ -8,7 +8,6 @@ #include "components/strings/grit/components_strings.h" #import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h" #import "ios/chrome/test/app/chrome_test_util.h" -#import "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_error_util.h" @@ -105,10 +104,9 @@ loadAndCheckSimpleURL(); // Navigate to the chrome://crash URL which should show the Sad Tab. - // Use chrome_test_util::LoadURL() directly to avoid ChomeEarlGrey helper - // methods which expect to wait for web content. const GURL crash_URL = GURL("chrome://crash"); - chrome_test_util::LoadUrl(crash_URL); + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:crash_URL + waitForCompletion:NO]); [[EarlGrey selectElementWithMatcher:reloadSadTabTitleText()] assertWithMatcher:grey_notNil()]; @@ -119,7 +117,8 @@ // A second visit to the crashing URL should show a feedback message. // It should also show help messages including an invitation to use // Incognito Mode. - chrome_test_util::LoadUrl(crash_URL); + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:crash_URL + waitForCompletion:NO]); [[EarlGrey selectElementWithMatcher:feedbackSadTabTitleContainsText()] assertWithMatcher:grey_notNil()]; [[EarlGrey selectElementWithMatcher:incognitoHelpContainsText()] @@ -141,10 +140,12 @@ // Test an initial crash, and then a second crash in Incognito mode, as above. // Incognito mode should not be suggested if already in Incognito mode. - chrome_test_util::LoadUrl(crash_URL); + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:crash_URL + waitForCompletion:NO]); [[EarlGrey selectElementWithMatcher:reloadSadTabTitleText()] assertWithMatcher:grey_notNil()]; - chrome_test_util::LoadUrl(crash_URL); + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:crash_URL + waitForCompletion:NO]); [[EarlGrey selectElementWithMatcher:feedbackSadTabTitleContainsText()] assertWithMatcher:grey_notNil()]; [[EarlGrey selectElementWithMatcher:incognitoHelpContainsText()]
diff --git a/ios/chrome/browser/ui/settings/block_popups_egtest.mm b/ios/chrome/browser/ui/settings/block_popups_egtest.mm index ccc7d863..7326627f 100644 --- a/ios/chrome/browser/ui/settings/block_popups_egtest.mm +++ b/ios/chrome/browser/ui/settings/block_popups_egtest.mm
@@ -12,7 +12,6 @@ #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.h" #include "ios/chrome/grit/ios_strings.h" #import "ios/chrome/test/app/chrome_test_util.h" -#include "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h" #include "ios/chrome/test/earl_grey/accessibility_util.h" #import "ios/chrome/test/earl_grey/chrome_actions.h"
diff --git a/ios/chrome/browser/ui/settings/settings_egtest.mm b/ios/chrome/browser/ui/settings/settings_egtest.mm index 989b627b5..a83e85d3 100644 --- a/ios/chrome/browser/ui/settings/settings_egtest.mm +++ b/ios/chrome/browser/ui/settings/settings_egtest.mm
@@ -27,7 +27,6 @@ #include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_theme_resources.h" #import "ios/chrome/test/app/chrome_test_util.h" -#include "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/app/tab_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h" #include "ios/chrome/test/earl_grey/accessibility_util.h"
diff --git a/ios/chrome/browser/ui/webui/web_ui_egtest.mm b/ios/chrome/browser/ui/webui/web_ui_egtest.mm index 7b63d26..5ffd7cc 100644 --- a/ios/chrome/browser/ui/webui/web_ui_egtest.mm +++ b/ios/chrome/browser/ui/webui/web_ui_egtest.mm
@@ -13,7 +13,6 @@ #include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/system_flags.h" #import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h" -#include "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" @@ -198,7 +197,7 @@ - (void)testChromeURLInvalid { // Navigate to the native error page chrome://invalidchromeurl. const std::string kChromeInvalidURL = "chrome://invalidchromeurl"; - chrome_test_util::LoadUrl(GURL(kChromeInvalidURL)); + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:GURL(kChromeInvalidURL)]); // Verify that the resulting page is an error page. [[EarlGrey selectElementWithMatcher:WaitForOmniboxText(kChromeInvalidURL)]
diff --git a/ios/chrome/browser/web/BUILD.gn b/ios/chrome/browser/web/BUILD.gn index 88094051..4167817 100644 --- a/ios/chrome/browser/web/BUILD.gn +++ b/ios/chrome/browser/web/BUILD.gn
@@ -345,6 +345,7 @@ "//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/popup_menu:constants", "//ios/chrome/browser/ui/util", + "//ios/chrome/test:eg_test_support", "//ios/chrome/test:test_support", "//ios/chrome/test/app:test_support", "//ios/chrome/test/earl_grey:test_support",
diff --git a/ios/chrome/browser/web/cache_egtest.mm b/ios/chrome/browser/web/cache_egtest.mm index 506af88..e2ea843 100644 --- a/ios/chrome/browser/web/cache_egtest.mm +++ b/ios/chrome/browser/web/cache_egtest.mm
@@ -10,7 +10,6 @@ #include "base/strings/stringprintf.h" #include "ios/chrome/browser/ui/util/ui_util.h" #import "ios/chrome/test/app/chrome_test_util.h" -#include "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
diff --git a/ios/chrome/browser/web/forms_egtest.mm b/ios/chrome/browser/web/forms_egtest.mm index eb21cac..ce500d28 100644 --- a/ios/chrome/browser/web/forms_egtest.mm +++ b/ios/chrome/browser/web/forms_egtest.mm
@@ -14,7 +14,6 @@ #import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h" #include "ios/chrome/browser/ui/util/ui_util.h" #import "ios/chrome/test/app/chrome_test_util.h" -#include "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
diff --git a/ios/chrome/browser/web/http_auth_egtest.mm b/ios/chrome/browser/web/http_auth_egtest.mm index df0e1e9..cf6459ba 100644 --- a/ios/chrome/browser/web/http_auth_egtest.mm +++ b/ios/chrome/browser/web/http_auth_egtest.mm
@@ -11,7 +11,6 @@ #include "components/strings/grit/components_strings.h" #include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/grit/ios_strings.h" -#include "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_error_util.h" #import "ios/chrome/test/earl_grey/chrome_matchers.h" @@ -87,7 +86,7 @@ GURL URL = web::test::HttpServer::MakeUrl("http://good-auth"); web::test::SetUpHttpServer(std::make_unique<web::HttpAuthResponseProvider>( URL, "GoodRealm", "gooduser", "goodpass")); - chrome_test_util::LoadUrl(URL); + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:URL waitForCompletion:NO]); WaitForHttpAuthDialog(); // Enter valid username and password. @@ -114,7 +113,7 @@ GURL URL = web::test::HttpServer::MakeUrl("http://bad-auth"); web::test::SetUpHttpServer(std::make_unique<web::HttpAuthResponseProvider>( URL, "BadRealm", "baduser", "badpass")); - chrome_test_util::LoadUrl(URL); + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:URL waitForCompletion:NO]); WaitForHttpAuthDialog(); // Enter invalid username and password. @@ -140,7 +139,7 @@ GURL URL = web::test::HttpServer::MakeUrl("http://cancel-auth"); web::test::SetUpHttpServer(std::make_unique<web::HttpAuthResponseProvider>( URL, "CancellingRealm", "", "")); - chrome_test_util::LoadUrl(URL); + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:URL waitForCompletion:NO]); WaitForHttpAuthDialog(); [[EarlGrey selectElementWithMatcher:chrome_test_util::CancelButton()]
diff --git a/ios/chrome/browser/web/progress_indicator_egtest.mm b/ios/chrome/browser/web/progress_indicator_egtest.mm index 28d5612..c63c266f 100644 --- a/ios/chrome/browser/web/progress_indicator_egtest.mm +++ b/ios/chrome/browser/web/progress_indicator_egtest.mm
@@ -15,7 +15,6 @@ #include "base/threading/thread_restrictions.h" #include "base/time/time.h" #include "ios/chrome/browser/ui/util/ui_util.h" -#include "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" @@ -188,7 +187,8 @@ web::test::SetUpHttpServer(std::move(uniqueInfinitePendingProvider)); // The page being loaded never completes, so call the LoadUrl helper that // does not wait for the page to complete loading. - chrome_test_util::LoadUrl(infinitePendingURL); + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:infinitePendingURL + waitForCompletion:NO]); // Wait until the page is half loaded. CHROME_EG_ASSERT_NO_ERROR(
diff --git a/ios/chrome/browser/web/stop_loading_egtest.mm b/ios/chrome/browser/web/stop_loading_egtest.mm index f48b124..6dcf85f 100644 --- a/ios/chrome/browser/web/stop_loading_egtest.mm +++ b/ios/chrome/browser/web/stop_loading_egtest.mm
@@ -9,12 +9,12 @@ #include "base/strings/stringprintf.h" #include "base/time/time.h" #include "ios/chrome/browser/ui/util/ui_util.h" -#include "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_error_util.h" #import "ios/chrome/test/earl_grey/chrome_matchers.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h" +#import "ios/chrome/test/scoped_eg_synchronization_disabler.h" #include "ios/web/public/test/http_server/html_response_provider.h" #import "ios/web/public/test/http_server/http_server.h" #include "ios/web/public/test/http_server/http_server_util.h" @@ -95,9 +95,16 @@ web::test::SetUpHttpServer( std::make_unique<InfinitePendingResponseProvider>(infinitePendingURL)); - // The page being loaded never completes, so call the LoadUrl helper that - // does not wait for the page to complete loading. - chrome_test_util::LoadUrl(infinitePendingURL); + if (IsIPadIdiom()) { + // TODO(crbug.com/960508): Investigate why test fails on iPad if + // synchronization is enabled. + ScopedSynchronizationDisabler disabler; + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:infinitePendingURL + waitForCompletion:NO]); + } else { + CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:infinitePendingURL + waitForCompletion:NO]); + } if (IsIPadIdiom()) { // Disable EG synchronization so the framework does not wait until the tab @@ -127,8 +134,8 @@ [[EarlGrey selectElementWithMatcher:chrome_test_util::StopButton()] performAction:grey_tap()]; - // Enable synchronization back. The spinner should become idle and test should - // wait for it. + // Enable synchronization back. The spinner should become idle and test + // should wait for it. [[GREYConfiguration sharedInstance] setValue:@YES forConfigKey:kGREYConfigKeySynchronizationEnabled];
diff --git a/ios/chrome/browser/web/visible_url_egtest.mm b/ios/chrome/browser/web/visible_url_egtest.mm index f6e16e3..dc8533c 100644 --- a/ios/chrome/browser/web/visible_url_egtest.mm +++ b/ios/chrome/browser/web/visible_url_egtest.mm
@@ -14,7 +14,6 @@ #include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/ui/util/ui_util.h" #import "ios/chrome/test/app/chrome_test_util.h" -#include "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_error_util.h"
diff --git a/ios/chrome/test/earl_grey/chrome_earl_grey.h b/ios/chrome/test/earl_grey/chrome_earl_grey.h index 6ce7e38..2392729 100644 --- a/ios/chrome/test/earl_grey/chrome_earl_grey.h +++ b/ios/chrome/test/earl_grey/chrome_earl_grey.h
@@ -61,14 +61,26 @@ #pragma mark - Navigation Utilities // Loads |URL| in the current WebState with transition type +// ui::PAGE_TRANSITION_TYPED, and if waitForCompletion is YES +// waits for the loading to complete within a timeout. +// Returns nil on success, or else an NSError indicating why the operation +// failed. +- (NSError*)loadURL:(const GURL&)URL waitForCompletion:(BOOL)wait; + +// Loads |URL| in the current WebState with transition type // ui::PAGE_TRANSITION_TYPED, and waits for the loading to complete within a -// timeout, or a GREYAssert is induced. +// timeout. Returns nil on success, or else an NSError indicating why the +// operation failed. // TODO(crbug.com/963613): Change return type to avoid when // CHROME_EG_ASSERT_NO_ERROR is removed. - (NSError*)loadURL:(const GURL&)URL; -// Reloads the page and waits for the loading to complete within a timeout, or a -// GREYAssert is induced. +// Checks whether current WebState is loading. +- (BOOL)isLoading WARN_UNUSED_RESULT; + +// Reloads the page and waits for the loading to complete within a timeout. +// If the condition is not met within a timeout returns an NSError indicating +// why the operation failed, otherwise nil. - (NSError*)reload WARN_UNUSED_RESULT; // Navigates back to the previous page and waits for the loading to complete
diff --git a/ios/chrome/test/earl_grey/chrome_earl_grey.mm b/ios/chrome/test/earl_grey/chrome_earl_grey.mm index 6a76ba3..fe391f2 100644 --- a/ios/chrome/test/earl_grey/chrome_earl_grey.mm +++ b/ios/chrome/test/earl_grey/chrome_earl_grey.mm
@@ -130,8 +130,12 @@ #pragma mark - Navigation Utilities -- (NSError*)loadURL:(const GURL&)URL { +- (NSError*)loadURL:(const GURL&)URL waitForCompletion:(BOOL)wait { chrome_test_util::LoadUrl(URL); + if (!wait) { + return nil; + } + bool pageLoaded = chrome_test_util::WaitForPageToFinishLoading(); EG_TEST_HELPER_ASSERT_TRUE(pageLoaded, @"Page did not complete loading"); @@ -144,6 +148,14 @@ return nil; } +- (NSError*)loadURL:(const GURL&)URL { + return [ChromeEarlGrey loadURL:URL waitForCompletion:YES]; +} + +- (BOOL)isLoading { + return chrome_test_util::IsLoading(); +} + - (NSError*)reload { [chrome_test_util::BrowserCommandDispatcherForMainBVC() reload]; return [ChromeEarlGrey waitForPageToFinishLoading];
diff --git a/ios/chrome/test/earl_grey/chrome_earl_grey_ui.mm b/ios/chrome/test/earl_grey/chrome_earl_grey_ui.mm index 134ed83..9d68b4d 100644 --- a/ios/chrome/test/earl_grey/chrome_earl_grey_ui.mm +++ b/ios/chrome/test/earl_grey/chrome_earl_grey_ui.mm
@@ -18,7 +18,6 @@ #import "ios/chrome/browser/ui/util/uikit_ui_util.h" #include "ios/chrome/grit/ios_strings.h" #import "ios/chrome/test/app/chrome_test_util.h" -#include "ios/chrome/test/app/navigation_test_util.h" #import "ios/chrome/test/earl_grey/chrome_matchers.h" #import "ios/testing/nserror_util.h" #import "ios/web/public/test/earl_grey/js_test_util.h"
diff --git a/ios/net/BUILD.gn b/ios/net/BUILD.gn index 0861b62..1461b07 100644 --- a/ios/net/BUILD.gn +++ b/ios/net/BUILD.gn
@@ -31,9 +31,6 @@ configs += [ "//build/config/compiler:enable_arc" ] sources = [ - "chunked_data_stream_uploader.cc", - "chunked_data_stream_uploader.h", - "clients/crn_network_client_protocol.h", "cookies/cookie_cache.cc", "cookies/cookie_cache.h", "cookies/cookie_creation_time_manager.h", @@ -50,27 +47,16 @@ "cookies/system_cookie_store.mm", "cookies/system_cookie_util.h", "cookies/system_cookie_util.mm", - "crn_http_protocol_handler.h", - "crn_http_protocol_handler.mm", - "crn_http_protocol_handler_proxy.h", - "crn_http_protocol_handler_proxy_with_client_thread.h", - "crn_http_protocol_handler_proxy_with_client_thread.mm", "crn_http_url_response.h", "crn_http_url_response.mm", "empty_nsurlcache.h", "empty_nsurlcache.mm", "http_cache_helper.cc", "http_cache_helper.h", - "http_protocol_logging.h", - "http_protocol_logging.mm", "http_response_headers_util.h", "http_response_headers_util.mm", - "nsurlrequest_util.h", - "nsurlrequest_util.mm", "protocol_handler_util.h", "protocol_handler_util.mm", - "request_tracker.h", - "request_tracker.mm", "url_scheme_util.h", "url_scheme_util.mm", ] @@ -80,6 +66,39 @@ } } +source_set("network_protocol") { + deps = [ + ":ios_net_buildflags", + ":net", + "//base", + "//net", + "//url:buildflags", + ] + + configs += [ "//build/config/compiler:enable_arc" ] + + sources = [ + "chunked_data_stream_uploader.cc", + "chunked_data_stream_uploader.h", + "clients/crn_network_client_protocol.h", + "crn_http_protocol_handler.h", + "crn_http_protocol_handler.mm", + "crn_http_protocol_handler_proxy.h", + "crn_http_protocol_handler_proxy_with_client_thread.h", + "crn_http_protocol_handler_proxy_with_client_thread.mm", + "http_protocol_logging.h", + "http_protocol_logging.mm", + "nsurlrequest_util.h", + "nsurlrequest_util.mm", + "request_tracker.h", + "request_tracker.mm", + ] + + if (!use_platform_icu_alternatives) { + deps += [ "//base:i18n" ] + } +} + source_set("test_support") { testonly = true configs += [ "//build/config/compiler:enable_arc" ] @@ -103,6 +122,7 @@ configs += [ "//build/config/compiler:enable_arc" ] deps = [ ":net", + ":network_protocol", ":test_support", "//base", "//base/test:run_all_unittests",
diff --git a/ios/web/public/service_names.mojom b/ios/web/public/service_names.mojom index 409ac49d..661a03c 100644 --- a/ios/web/public/service_names.mojom +++ b/ios/web/public/service_names.mojom
@@ -4,8 +4,12 @@ module web.mojom; -// The default service name the browser identifies as when connecting to -// the Service Manager. +// The service name the browser identifies as when connecting to the Service +// Manager for its privileged global singleton instance. +const string kSystemServiceName = "web_system"; + +// The service name the browser identifies as when connecting to the Service +// Manager for each BrowserState instance. const string kBrowserServiceName = "web_browser"; // The service name used to identify the browser process's singleton service
diff --git a/ios/web/service_manager_context.mm b/ios/web/service_manager_context.mm index 1d966b7..65bcd72 100644 --- a/ios/web/service_manager_context.mm +++ b/ios/web/service_manager_context.mm
@@ -46,6 +46,21 @@ int resource_id; }; +service_manager::Manifest GetWebSystemManifest() { + // TODO(crbug.com/961869): This is a bit of a temporary hack so that we can + // make the global service instance a singleton. For now we just mirror the + // per-BrowserState manifest (formerly also used for the global singleton + // instance), sans packaged services, since those are only meant to be tied to + // a BrowserState. The per-BrowserState service should go away soon, and then + // this can be removed. + service_manager::Manifest manifest = GetWebBrowserManifest(); + manifest.service_name = mojom::kSystemServiceName; + manifest.packaged_services.clear(); + manifest.options.instance_sharing_policy = + service_manager::Manifest::InstanceSharingPolicy::kSingleton; + return manifest; +} + } // namespace // State which lives on the IO thread and drives the ServiceManager. @@ -104,7 +119,8 @@ ServiceManagerContext::ServiceManagerContext() { const std::vector<service_manager::Manifest> manifests = { - GetWebBrowserManifest(), GetWebPackagedServicesManifest()}; + GetWebSystemManifest(), GetWebBrowserManifest(), + GetWebPackagedServicesManifest()}; in_process_context_ = base::MakeRefCounted<InProcessServiceManagerContext>(); service_manager::mojom::ServicePtr packaged_services_service; @@ -128,7 +144,7 @@ mojo::Remote<service_manager::mojom::ProcessMetadata> metadata; packaged_services_connection_->GetConnector()->RegisterServiceInstance( - service_manager::Identity(mojom::kBrowserServiceName, + service_manager::Identity(mojom::kSystemServiceName, service_manager::kSystemInstanceGroup, base::Token{}, base::Token::CreateRandom()), std::move(root_browser_service), metadata.BindNewPipeAndPassReceiver());
diff --git a/ios/web/web_browser_manifest.mm b/ios/web/web_browser_manifest.mm index 0c87f00b..20a42b8 100644 --- a/ios/web/web_browser_manifest.mm +++ b/ios/web/web_browser_manifest.mm
@@ -27,6 +27,7 @@ .CanRegisterOtherServiceInstances(true) .Build()) .RequireCapability(mojom::kBrowserServiceName, "") + .RequireCapability(mojom::kSystemServiceName, "") .RequireCapability(service_manager::mojom::kServiceName, "service_manager:service_manager") .Build()
diff --git a/ios/web/web_packaged_services_manifest.mm b/ios/web/web_packaged_services_manifest.mm index 93a56155..07806b8 100644 --- a/ios/web/web_packaged_services_manifest.mm +++ b/ios/web/web_packaged_services_manifest.mm
@@ -29,6 +29,7 @@ .CanRegisterOtherServiceInstances(true) .Build()) .RequireCapability(mojom::kBrowserServiceName, "") + .RequireCapability(mojom::kSystemServiceName, "") .Build() .Amend(GetWebClient() ->GetServiceManifestOverlay(
diff --git a/media/capture/video/win/video_capture_device_win.cc b/media/capture/video/win/video_capture_device_win.cc index 905726f7..9f59899 100644 --- a/media/capture/video/win/video_capture_device_win.cc +++ b/media/capture/video/win/video_capture_device_win.cc
@@ -29,6 +29,19 @@ using base::win::ScopedVariant; using Microsoft::WRL::ComPtr; +namespace { +const int kSecondsTo100MicroSeconds = 10000; + +// Windows platform stores exposure time (min, max and current) in log base 2 +// seconds. If value is n, exposure time is 2^n seconds. Spec expects exposure +// times in 100 micro seconds. +// https://docs.microsoft.com/en-us/previous-versions/ms784800(v%3Dvs.85) +// spec: https://w3c.github.io/mediacapture-image/#exposure-time +long ConvertWindowsTimeToSpec(long seconds) { + return (std::exp2(seconds) * kSecondsTo100MicroSeconds); +} +} // namespace + namespace media { #if DCHECK_IS_ON() @@ -389,6 +402,7 @@ state_(kIdle), white_balance_mode_manual_(false), exposure_mode_manual_(false), + focus_mode_manual_(false), enable_get_photo_state_( base::FeatureList::IsEnabled(media::kDirectShowGetPhotoState)) { // TODO(mcasas): Check that CoInitializeEx() has been called with the @@ -654,7 +668,7 @@ auto photo_capabilities = mojo::CreateEmptyPhotoState(); - photo_capabilities->exposure_compensation = RetrieveControlRangeAndCurrent( + photo_capabilities->exposure_time = RetrieveControlRangeAndCurrent( [this](auto... args) { return this->camera_control_->getRange_Exposure(args...); }, @@ -664,6 +678,17 @@ &photo_capabilities->supported_exposure_modes, &photo_capabilities->current_exposure_mode); + // Windows returns the exposure time in log base 2 seconds. + // If value is n, exposure time is 2^n seconds. + photo_capabilities->exposure_time->min = + ConvertWindowsTimeToSpec(photo_capabilities->exposure_time->min); + photo_capabilities->exposure_time->max = + ConvertWindowsTimeToSpec(photo_capabilities->exposure_time->max); + photo_capabilities->exposure_time->step = + std::exp2(photo_capabilities->exposure_time->step); + photo_capabilities->exposure_time->current = + ConvertWindowsTimeToSpec(photo_capabilities->exposure_time->current); + photo_capabilities->color_temperature = RetrieveControlRangeAndCurrent( [this](auto... args) { return this->video_control_->getRange_WhiteBalance(args...); @@ -674,8 +699,7 @@ &photo_capabilities->supported_white_balance_modes, &photo_capabilities->current_white_balance_mode); - // Ignore the returned Focus control range and status. - RetrieveControlRangeAndCurrent( + photo_capabilities->focus_distance = RetrieveControlRangeAndCurrent( [this](auto... args) { return this->camera_control_->getRange_Focus(args...); }, @@ -775,6 +799,26 @@ return; } + if (settings->has_focus_mode) { + if (settings->focus_mode == mojom::MeteringMode::CONTINUOUS) { + hr = camera_control_->put_Focus(0L, VideoProcAmp_Flags_Auto); + DLOG_IF_FAILED_WITH_HRESULT("Auto focus config failed", hr); + if (FAILED(hr)) + return; + + focus_mode_manual_ = false; + } else { + focus_mode_manual_ = true; + } + } + if (focus_mode_manual_ && settings->has_focus_distance) { + hr = camera_control_->put_Focus(settings->focus_distance, + CameraControl_Flags_Manual); + DLOG_IF_FAILED_WITH_HRESULT("Focus Distance config failed", hr); + if (FAILED(hr)) + return; + } + if (settings->has_exposure_mode) { if (settings->exposure_mode == mojom::MeteringMode::CONTINUOUS) { hr = camera_control_->put_Exposure(0L, VideoProcAmp_Flags_Auto); @@ -787,14 +831,15 @@ exposure_mode_manual_ = true; } } - if (exposure_mode_manual_ && settings->has_exposure_compensation) { - hr = camera_control_->put_Exposure(settings->exposure_compensation, - CameraControl_Flags_Manual); - DLOG_IF_FAILED_WITH_HRESULT("Exposure Compensation config failed", hr); + if (exposure_mode_manual_ && settings->has_exposure_time) { + // Windows expects the exposure time in log base 2 seconds. + hr = camera_control_->put_Exposure( + std::log2(settings->exposure_time / kSecondsTo100MicroSeconds), + CameraControl_Flags_Manual); + DLOG_IF_FAILED_WITH_HRESULT("Exposure Time config failed", hr); if (FAILED(hr)) return; } - if (settings->has_brightness) { hr = video_control_->put_Brightness(settings->brightness, CameraControl_Flags_Manual);
diff --git a/media/capture/video/win/video_capture_device_win.h b/media/capture/video/win/video_capture_device_win.h index e135f07761..cae1391 100644 --- a/media/capture/video/win/video_capture_device_win.h +++ b/media/capture/video/win/video_capture_device_win.h
@@ -139,6 +139,7 @@ // These flags keep the manual/auto mode between cycles of SetPhotoOptions(). bool white_balance_mode_manual_; bool exposure_mode_manual_; + bool focus_mode_manual_; base::TimeTicks first_ref_time_;
diff --git a/net/cert/cert_verify_proc_unittest.cc b/net/cert/cert_verify_proc_unittest.cc index 9d00776..484db21 100644 --- a/net/cert/cert_verify_proc_unittest.cc +++ b/net/cert/cert_verify_proc_unittest.cc
@@ -2274,7 +2274,6 @@ #if defined(OS_IOS) && !TARGET_IPHONE_SIMULATOR if (verify_proc_type() == CERT_VERIFY_PROC_IOS) { - // TODO(crbug.com/964323): Verify which version this should work for. if (__builtin_available(iOS 12.2, *)) { // TODO(mattm): Check if this can this be mapped to some better error. EXPECT_THAT(error, IsError(ERR_CERT_INVALID));
diff --git a/net/docs/proxy.md b/net/docs/proxy.md index b5e4645..c6f2ce1 100644 --- a/net/docs/proxy.md +++ b/net/docs/proxy.md
@@ -245,8 +245,62 @@ are skipped over. Link-local or loopback address will only be returned as a last resort when no other IP address was found by following these steps. -Also note that this sequence of steps explicitly favors IPv4 over IPv6 results. +This sequence of steps explicitly favors IPv4 over IPv6 results. + +*Historical note*: Prior to M72, Chrome's implementation of `myIpAddress()` was +effectively just `getaddrinfo(gethostname)`. This is now step 2 of the heuristic. + +### What about `var pacUseMultihomedDNS`? + +In Firefox, if you define a global named `pacUseMultihomedDNS` in your PAC +script, it causes `myIpAddress()` to report the IP address of the interface +that would (likely) have been used had we connected to it DIRECT. + +In particular, it will do a DNS resolution of the target host (the hostname of +the URL that the proxy resolution is being done for), and then +connect a datagram socket to get the source address. + +Chrome does not recognize the `pacUseMultihomedDNS` global as having special +meaning. A PAC script is free to define such a global, and it won't have +side-effects. Chrome has no APIs or settings to change `myIpAddress()`'s +algorithm. ## Resolving client's IP address within a PAC script using `myIpAddressEx()` -TODO +Chrome supports the [Microsoft PAC +extension](https://docs.microsoft.com/en-us/windows/desktop/winhttp/myipaddressex) +`myIpAddressEx()`. + +This is like `myIpAddress()`, but instead of returning a single IP address, it +can return multiple IP addresses. It returns a string containing a semi-colon +separated list of addresses. On failure it returns an empty string to indicate +no results (whereas `myIpAddress()` returns `127.0.0.1`). + +There are some differences with Chrome's implementation: + +* In Chrome the function is unconditionally defined, whereas in Internet + Explorer one must have used the `FindProxyForURLEx` entrypoint. +* Chrome does not enumerate all of the host's network interfaces +* Chrome does not return link-local or loopback addresses (except if no other + addresses were found). + +The algorithm that Chrome uses is nearly identical to that of `myIpAddress()` +described earlier. The main difference is that we don't short-circuit +after finding the first candidate IP, so multiple IPs may be returned. + +1. Select all the IPs of interfaces that can route to public Internet: + * Probe for route to `8.8.8.8`. + * Probe for route to `2001:4860:4860::8888`. + * If any IPs were found, return them, and finish. +2. Select an IP by doing a DNS resolve of the machine's hostname: + * If any IPs were found, return them, and finish. +3. Select the IP of an interface that can route to private IP space: + * Probe for route to `10.0.0.0`. + * Probe for route to `172.16.0.0`. + * Probe for route to `192.168.0.0`. + * Probe for route to `FC00::`. + * If any IPs were found, return them, and finish. + +Note that short-circuiting happens whenever steps 1-3 find a candidate IP. So +for example if at least one IP address was discovered by checking routes to +public Internet, only those IPs will be returned, and steps 2-3 will not run.
diff --git a/remoting/client/chromoting_session.cc b/remoting/client/chromoting_session.cc index f416b4a..c6c961a5 100644 --- a/remoting/client/chromoting_session.cc +++ b/remoting/client/chromoting_session.cc
@@ -35,6 +35,7 @@ #include "remoting/protocol/performance_tracker.h" #include "remoting/protocol/transport_context.h" #include "remoting/protocol/video_renderer.h" +#include "remoting/signaling/ftl_client_uuid_device_id_provider.h" #include "remoting/signaling/ftl_signal_strategy.h" #include "remoting/signaling/server_log_entry.h" #include "services/network/public/cpp/shared_url_loader_factory.h" @@ -86,7 +87,6 @@ audio_player_weak_factory; std::unique_ptr<protocol::CursorShapeStub> cursor_shape_stub; std::unique_ptr<protocol::VideoRenderer> video_renderer; - std::unique_ptr<FtlDeviceIdProvider> device_id_provider; ConnectToHostInfo info; }; @@ -496,7 +496,7 @@ if (!session_context_->info.host_ftl_id.empty()) { signaling_ = std::make_unique<FtlSignalStrategy>( runtime_->CreateOAuthTokenGetter(), - std::move(session_context_->device_id_provider)); + std::make_unique<FtlClientUuidDeviceIdProvider>()); logger_->SetSignalStrategyType(ChromotingEvent::SignalStrategyType::FTL); } else { signaling_ = std::make_unique<XmppSignalStrategy>( @@ -636,7 +636,6 @@ std::unique_ptr<protocol::CursorShapeStub> cursor_shape_stub, std::unique_ptr<protocol::VideoRenderer> video_renderer, std::unique_ptr<protocol::AudioStub> audio_player, - std::unique_ptr<FtlDeviceIdProvider> device_id_provider, const ConnectToHostInfo& info) : runtime_(ChromotingClientRuntime::GetInstance()) { DCHECK(delegate); @@ -654,7 +653,6 @@ session_context->audio_player.get()); session_context->cursor_shape_stub = std::move(cursor_shape_stub); session_context->video_renderer = std::move(video_renderer); - session_context->device_id_provider = std::move(device_id_provider); session_context->info = info; auto logger = std::make_unique<ClientTelemetryLogger>(
diff --git a/remoting/client/chromoting_session.h b/remoting/client/chromoting_session.h index 7d0f0d3..bfc6bec 100644 --- a/remoting/client/chromoting_session.h +++ b/remoting/client/chromoting_session.h
@@ -93,7 +93,6 @@ std::unique_ptr<protocol::CursorShapeStub> cursor_stub, std::unique_ptr<protocol::VideoRenderer> video_renderer, std::unique_ptr<protocol::AudioStub> audio_player, - std::unique_ptr<FtlDeviceIdProvider> device_id_provider, const ConnectToHostInfo& info); ~ChromotingSession() override;
diff --git a/remoting/client/jni/jni_client.cc b/remoting/client/jni/jni_client.cc index fb0afb0..87ed4299 100644 --- a/remoting/client/jni/jni_client.cc +++ b/remoting/client/jni/jni_client.cc
@@ -50,8 +50,7 @@ session_.reset(new ChromotingSession( weak_ptr_, display_handler_->CreateCursorShapeStub(), display_handler_->CreateVideoRenderer(), - std::make_unique<AudioPlayerAndroid>(), /* device_id_provider */ nullptr, - info)); + std::make_unique<AudioPlayerAndroid>(), info)); } void JniClient::DisconnectFromHost() {
diff --git a/remoting/host/BUILD.gn b/remoting/host/BUILD.gn index aed0f05..9c019c2f 100644 --- a/remoting/host/BUILD.gn +++ b/remoting/host/BUILD.gn
@@ -245,10 +245,11 @@ "process_stats_agent.h", "process_stats_sender.cc", "process_stats_sender.h", - "register_support_host_request.cc", "register_support_host_request.h", "remote_input_filter.cc", "remote_input_filter.h", + "remoting_register_support_host_request.cc", + "remoting_register_support_host_request.h", "resizing_host_observer.cc", "resizing_host_observer.h", "resources.h", @@ -293,6 +294,8 @@ "username.h", "xmpp_heartbeat_sender.cc", "xmpp_heartbeat_sender.h", + "xmpp_register_support_host_request.cc", + "xmpp_register_support_host_request.h", ] libs = [] @@ -317,6 +320,7 @@ "//remoting/host/input_monitor", "//remoting/host/security_key", "//remoting/proto/remoting/v1:directory_grpc_library", + "//remoting/proto/remoting/v1:remote_support_host_grpc_library", "//remoting/protocol", "//remoting/resources", "//services/network:network_service", @@ -500,7 +504,6 @@ "pin_hash_unittest.cc", "policy_watcher_unittest.cc", "process_stats_sender_unittest.cc", - "register_support_host_request_unittest.cc", "remote_input_filter_unittest.cc", "resizing_host_observer_unittest.cc", "resources_unittest.cc", @@ -513,6 +516,7 @@ "token_validator_factory_impl_unittest.cc", "touch_injector_win_unittest.cc", "xmpp_heartbeat_sender_unittest.cc", + "xmpp_register_support_host_request_unittest.cc", ] if (use_ozone || is_chromeos) {
diff --git a/remoting/host/it2me/it2me_host.cc b/remoting/host/it2me/it2me_host.cc index e0d198e1..4b93df3f 100644 --- a/remoting/host/it2me/it2me_host.cc +++ b/remoting/host/it2me/it2me_host.cc
@@ -29,7 +29,6 @@ #include "remoting/host/host_status_logger.h" #include "remoting/host/it2me/it2me_confirmation_dialog.h" #include "remoting/host/it2me_desktop_environment.h" -#include "remoting/host/register_support_host_request.h" #include "remoting/protocol/auth_util.h" #include "remoting/protocol/chromium_port_allocator_factory.h" #include "remoting/protocol/ice_transport.h" @@ -78,6 +77,7 @@ std::unique_ptr<ChromotingHostContext> host_context, std::unique_ptr<base::DictionaryValue> policies, std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory, + std::unique_ptr<RegisterSupportHostRequest> register_request, base::WeakPtr<It2MeHost::Observer> observer, std::unique_ptr<SignalStrategy> signal_strategy, const std::string& username, @@ -101,7 +101,8 @@ // Switch to the network thread to start the actual connection. host_context_->network_task_runner()->PostTask( FROM_HERE, base::BindOnce(&It2MeHost::ConnectOnNetworkThread, this, - username, directory_bot_jid, ice_config)); + username, directory_bot_jid, ice_config, + std::move(register_request))); } void It2MeHost::Disconnect() { @@ -110,9 +111,11 @@ FROM_HERE, base::BindOnce(&It2MeHost::DisconnectOnNetworkThread, this)); } -void It2MeHost::ConnectOnNetworkThread(const std::string& username, - const std::string& directory_bot_jid, - const protocol::IceConfig& ice_config) { +void It2MeHost::ConnectOnNetworkThread( + const std::string& username, + const std::string& directory_bot_jid, + const protocol::IceConfig& ice_config, + std::unique_ptr<RegisterSupportHostRequest> register_request) { DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); DCHECK_EQ(kDisconnected, state_); @@ -139,11 +142,9 @@ host_key_pair_ = RsaKeyPair::Generate(); // Request registration of the host for support. - std::unique_ptr<RegisterSupportHostRequest> register_request( - new RegisterSupportHostRequest( - signal_strategy_.get(), host_key_pair_, directory_bot_jid, - base::Bind(&It2MeHost::OnReceivedSupportID, base::Unretained(this)))); - + register_request->StartRequest( + signal_strategy_.get(), host_key_pair_, + base::BindOnce(&It2MeHost::OnReceivedSupportID, base::Unretained(this))); // Beyond this point nothing can fail, so save the config and request. register_request_ = std::move(register_request);
diff --git a/remoting/host/it2me/it2me_host.h b/remoting/host/it2me/it2me_host.h index 26d34798..c16ccaf 100644 --- a/remoting/host/it2me/it2me_host.h +++ b/remoting/host/it2me/it2me_host.h
@@ -16,6 +16,7 @@ #include "remoting/host/host_status_observer.h" #include "remoting/host/it2me/it2me_confirmation_dialog.h" #include "remoting/host/it2me/it2me_confirmation_dialog_proxy.h" +#include "remoting/host/register_support_host_request.h" #include "remoting/protocol/errors.h" #include "remoting/protocol/port_range.h" #include "remoting/protocol/validating_authenticator.h" @@ -80,6 +81,7 @@ std::unique_ptr<ChromotingHostContext> context, std::unique_ptr<base::DictionaryValue> policies, std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory, + std::unique_ptr<RegisterSupportHostRequest> register_request, base::WeakPtr<It2MeHost::Observer> observer, std::unique_ptr<SignalStrategy> signal_strategy, const std::string& username, @@ -131,9 +133,11 @@ It2MeConfirmationDialog::Result result); // Task posted to the network thread from Connect(). - void ConnectOnNetworkThread(const std::string& username, - const std::string& directory_bot_jid, - const protocol::IceConfig& ice_config); + void ConnectOnNetworkThread( + const std::string& username, + const std::string& directory_bot_jid, + const protocol::IceConfig& ice_config, + std::unique_ptr<RegisterSupportHostRequest> register_request); // Called when the support host registration completes. void OnReceivedSupportID(const std::string& support_id,
diff --git a/remoting/host/it2me/it2me_host_unittest.cc b/remoting/host/it2me/it2me_host_unittest.cc index ebc1dfd..322bb2a 100644 --- a/remoting/host/it2me/it2me_host_unittest.cc +++ b/remoting/host/it2me/it2me_host_unittest.cc
@@ -25,6 +25,7 @@ #include "remoting/host/chromoting_host_context.h" #include "remoting/host/it2me/it2me_confirmation_dialog.h" #include "remoting/host/policy_watcher.h" +#include "remoting/host/xmpp_register_support_host_request.h" #include "remoting/protocol/errors.h" #include "remoting/protocol/transport_context.h" #include "remoting/signaling/fake_signal_strategy.h" @@ -291,10 +292,13 @@ // false should only be run on ChromeOS. it2me_host_->set_enable_dialogs(enable_dialogs); } - it2me_host_->Connect(host_context_->Copy(), policies_->CreateDeepCopy(), - std::move(dialog_factory), weak_factory_.GetWeakPtr(), - std::move(fake_signal_strategy), kTestUserName, - "fake_bot_jid", ice_config); + auto register_host_request = + std::make_unique<XmppRegisterSupportHostRequest>("fake_bot_jid"); + it2me_host_->Connect( + host_context_->Copy(), policies_->CreateDeepCopy(), + std::move(dialog_factory), std::move(register_host_request), + weak_factory_.GetWeakPtr(), std::move(fake_signal_strategy), + kTestUserName, "fake_bot_jid", ice_config); base::RunLoop run_loop; state_change_callback_ =
diff --git a/remoting/host/it2me/it2me_native_messaging_host.cc b/remoting/host/it2me/it2me_native_messaging_host.cc index 05e3846..214345b 100644 --- a/remoting/host/it2me/it2me_native_messaging_host.cc +++ b/remoting/host/it2me/it2me_native_messaging_host.cc
@@ -31,6 +31,7 @@ #include "remoting/host/host_exit_codes.h" #include "remoting/host/it2me/it2me_confirmation_dialog.h" #include "remoting/host/policy_watcher.h" +#include "remoting/host/xmpp_register_support_host_request.h" #include "remoting/protocol/ice_config.h" #include "remoting/signaling/delegating_signal_strategy.h" @@ -287,10 +288,13 @@ #if defined(OS_CHROMEOS) || !defined(NDEBUG) it2me_host_->set_enable_dialogs(!no_dialogs); #endif + auto register_host_request = + std::make_unique<XmppRegisterSupportHostRequest>(directory_bot_jid); it2me_host_->Connect(host_context_->Copy(), std::move(policies), std::make_unique<It2MeConfirmationDialogFactory>(), - weak_ptr_, std::move(signal_strategy), username, - directory_bot_jid, ice_config); + std::move(register_host_request), weak_ptr_, + std::move(signal_strategy), username, directory_bot_jid, + ice_config); SendMessageToClient(std::move(response)); }
diff --git a/remoting/host/it2me/it2me_native_messaging_host_unittest.cc b/remoting/host/it2me/it2me_native_messaging_host_unittest.cc index 7514d63..fce9f42 100644 --- a/remoting/host/it2me/it2me_native_messaging_host_unittest.cc +++ b/remoting/host/it2me/it2me_native_messaging_host_unittest.cc
@@ -118,6 +118,7 @@ void Connect(std::unique_ptr<ChromotingHostContext> context, std::unique_ptr<base::DictionaryValue> policies, std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory, + std::unique_ptr<RegisterSupportHostRequest> register_request, base::WeakPtr<It2MeHost::Observer> observer, std::unique_ptr<SignalStrategy> signal_strategy, const std::string& username, @@ -137,6 +138,7 @@ std::unique_ptr<ChromotingHostContext> context, std::unique_ptr<base::DictionaryValue> policies, std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory, + std::unique_ptr<RegisterSupportHostRequest> register_request, base::WeakPtr<It2MeHost::Observer> observer, std::unique_ptr<SignalStrategy> signal_strategy, const std::string& username, @@ -152,6 +154,7 @@ host_context_ = std::move(context); observer_ = std::move(observer); signal_strategy_ = std::move(signal_strategy); + register_request_ = std::move(register_request); OnPolicyUpdate(std::move(policies)); @@ -640,7 +643,7 @@ connect_message.SetBoolean("noDialogs", true); WriteMessageToInputPipe(connect_message); VerifyConnectResponses(next_id); -#if defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) || !defined(NDEBUG) EXPECT_FALSE(factory_raw_ptr_->host->enable_dialogs()); #else EXPECT_TRUE(factory_raw_ptr_->host->enable_dialogs());
diff --git a/remoting/host/register_support_host_request.h b/remoting/host/register_support_host_request.h index 0233bda..4204180 100644 --- a/remoting/host/register_support_host_request.h +++ b/remoting/host/register_support_host_request.h
@@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2019 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. @@ -8,83 +8,38 @@ #include <memory> #include <string> -#include "base/callback.h" +#include "base/callback_forward.h" #include "base/macros.h" #include "base/memory/ref_counted.h" +#include "base/time/time.h" #include "remoting/base/rsa_key_pair.h" #include "remoting/protocol/errors.h" -#include "remoting/signaling/signal_strategy.h" -#include "testing/gtest/include/gtest/gtest_prod.h" - -namespace jingle_xmpp { -class XmlElement; -} // namespace jingle_xmpp - -namespace base { -class TimeDelta; -} // namespace base namespace remoting { -class IqRequest; -class IqSender; +class SignalStrategy; // RegisterSupportHostRequest sends a request to register the host for -// a SupportID, as soon as the associated SignalStrategy becomes -// connected. When a response is received from the bot, it calls the -// callback specified in the Init() method. -class RegisterSupportHostRequest : public SignalStrategy::Listener { +// a SupportID. When a response is received, it calls the callback specified in +// the StartRequest() method. +class RegisterSupportHostRequest { public: // First parameter is the new SessionID received from the bot. Second // parameter is the amount of time until that id expires. Third parameter // is an error message if the request failed, or null if it succeeded. - typedef base::Callback<void(const std::string&, + using RegisterCallback = + base::OnceCallback<void(const std::string&, const base::TimeDelta&, - protocol::ErrorCode error_code)> - RegisterCallback; + protocol::ErrorCode error_code)>; - // |signal_strategy| and |key_pair| must outlive this - // object. |callback| is called when registration response is - // received from the server. Callback is never called if the bot - // malfunctions and doesn't respond to the request. - // - // TODO(sergeyu): This class should have timeout for the bot - // response. - RegisterSupportHostRequest(SignalStrategy* signal_strategy, - scoped_refptr<RsaKeyPair> key_pair, - const std::string& directory_bot_jid, - const RegisterCallback& callback); - ~RegisterSupportHostRequest() override; + RegisterSupportHostRequest() = default; + virtual ~RegisterSupportHostRequest() = default; - // HostStatusObserver implementation. - void OnSignalStrategyStateChange(SignalStrategy::State state) override; - bool OnSignalStrategyIncomingStanza(const jingle_xmpp::XmlElement* stanza) override; + virtual void StartRequest(SignalStrategy* signal_strategy, + scoped_refptr<RsaKeyPair> key_pair, + RegisterCallback callback) = 0; private: - void DoSend(); - - std::unique_ptr<jingle_xmpp::XmlElement> CreateRegistrationRequest( - const std::string& jid); - std::unique_ptr<jingle_xmpp::XmlElement> CreateSignature(const std::string& jid); - - void ProcessResponse(IqRequest* request, const jingle_xmpp::XmlElement* response); - void ParseResponse(const jingle_xmpp::XmlElement* response, - std::string* support_id, - base::TimeDelta* lifetime, - protocol::ErrorCode* error_code); - - void CallCallback(const std::string& support_id, - base::TimeDelta lifetime, - protocol::ErrorCode error_code); - - SignalStrategy* signal_strategy_; - scoped_refptr<RsaKeyPair> key_pair_; - std::string directory_bot_jid_; - RegisterCallback callback_; - - std::unique_ptr<IqSender> iq_sender_; - std::unique_ptr<IqRequest> request_; - DISALLOW_COPY_AND_ASSIGN(RegisterSupportHostRequest); };
diff --git a/remoting/host/remoting_register_support_host_request.cc b/remoting/host/remoting_register_support_host_request.cc new file mode 100644 index 0000000..fbadc62 --- /dev/null +++ b/remoting/host/remoting_register_support_host_request.cc
@@ -0,0 +1,136 @@ +// Copyright 2019 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 "remoting/host/remoting_register_support_host_request.h" + +#include "base/strings/stringize_macros.h" +#include "remoting/base/grpc_support/grpc_async_unary_request.h" +#include "remoting/base/grpc_support/grpc_channel.h" +#include "remoting/base/grpc_support/grpc_util.h" +#include "remoting/base/oauth_token_getter.h" +#include "remoting/base/service_urls.h" +#include "remoting/host/host_details.h" +#include "remoting/signaling/ftl_signal_strategy.h" +#include "remoting/signaling/signaling_address.h" +#include "remoting/signaling/xmpp_signal_strategy.h" + +namespace remoting { + +namespace { + +protocol::ErrorCode MapError(grpc::StatusCode status_code) { + switch (status_code) { + case grpc::StatusCode::OK: + return protocol::ErrorCode::OK; + case grpc::StatusCode::DEADLINE_EXCEEDED: + return protocol::ErrorCode::SIGNALING_TIMEOUT; + case grpc::StatusCode::PERMISSION_DENIED: + case grpc::StatusCode::UNAUTHENTICATED: + return protocol::ErrorCode::AUTHENTICATION_FAILED; + default: + return protocol::ErrorCode::SIGNALING_ERROR; + } +} + +} // namespace + +RemotingRegisterSupportHostRequest::RemotingRegisterSupportHostRequest( + std::unique_ptr<OAuthTokenGetter> token_getter) + : token_getter_(std::move(token_getter)), + grpc_executor_(token_getter_.get()) { + remote_support_ = RemoteSupportService::NewStub(CreateSslChannelForEndpoint( + ServiceUrls::GetInstance()->remoting_server_endpoint())); +} + +RemotingRegisterSupportHostRequest::~RemotingRegisterSupportHostRequest() { + if (signal_strategy_) { + signal_strategy_->RemoveListener(this); + } +} + +void RemotingRegisterSupportHostRequest::StartRequest( + SignalStrategy* signal_strategy, + scoped_refptr<RsaKeyPair> key_pair, + RegisterCallback callback) { + DCHECK(signal_strategy); + DCHECK(key_pair); + DCHECK(callback); + signal_strategy_ = static_cast<MuxingSignalStrategy*>(signal_strategy); + key_pair_ = key_pair; + callback_ = std::move(callback); + + signal_strategy_->AddListener(this); +} + +void RemotingRegisterSupportHostRequest::OnSignalStrategyStateChange( + SignalStrategy::State state) { + switch (state) { + case SignalStrategy::State::CONNECTED: + RegisterHost(); + break; + case SignalStrategy::State::DISCONNECTED: + RunCallback({}, {}, protocol::ErrorCode::SIGNALING_ERROR); + break; + default: + // Do nothing. + break; + } +} + +bool RemotingRegisterSupportHostRequest::OnSignalStrategyIncomingStanza( + const jingle_xmpp::XmlElement* stanza) { + return false; +} + +void RemotingRegisterSupportHostRequest::RegisterHost() { + apis::v1::RegisterSupportHostRequest request; + request.set_public_key(key_pair_->GetPublicKey()); + if (signal_strategy_->ftl_signal_strategy()->GetState() == + SignalStrategy::State::CONNECTED) { + request.set_tachyon_id( + signal_strategy_->ftl_signal_strategy()->GetLocalAddress().jid()); + } + if (signal_strategy_->xmpp_signal_strategy()->GetState() == + SignalStrategy::State::CONNECTED) { + request.set_jabber_id( + signal_strategy_->xmpp_signal_strategy()->GetLocalAddress().jid()); + } + request.set_host_version(STRINGIZE(VERSION)); + request.set_host_os_name(GetHostOperatingSystemName()); + request.set_host_os_version(GetHostOperatingSystemVersion()); + + auto grpc_request = CreateGrpcAsyncUnaryRequest( + base::BindOnce(&RemoteSupportService::Stub::AsyncRegisterSupportHost, + base::Unretained(remote_support_.get())), + request, + base::BindOnce(&RemotingRegisterSupportHostRequest::OnRegisterHostResult, + base::Unretained(this))); + grpc_executor_.ExecuteRpc(std::move(grpc_request)); +} + +void RemotingRegisterSupportHostRequest::OnRegisterHostResult( + const grpc::Status& status, + const apis::v1::RegisterSupportHostResponse& response) { + if (!status.ok()) { + RunCallback({}, {}, MapError(status.error_code())); + return; + } + base::TimeDelta lifetime = + base::TimeDelta::FromSeconds(response.support_id_lifetime_seconds()); + RunCallback(response.support_id(), lifetime, protocol::ErrorCode::OK); +} + +void RemotingRegisterSupportHostRequest::RunCallback( + const std::string& support_id, + base::TimeDelta lifetime, + protocol::ErrorCode error_code) { + // Cleanup state before calling the callback. + grpc_executor_.CancelPendingRequests(); + signal_strategy_->RemoveListener(this); + signal_strategy_ = nullptr; + + std::move(callback_).Run(support_id, lifetime, error_code); +} + +} // namespace remoting
diff --git a/remoting/host/remoting_register_support_host_request.h b/remoting/host/remoting_register_support_host_request.h new file mode 100644 index 0000000..cec180e --- /dev/null +++ b/remoting/host/remoting_register_support_host_request.h
@@ -0,0 +1,67 @@ +// Copyright 2019 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 REMOTING_HOST_REMOTING_REGISTER_SUPPORT_HOST_REQUEST_H_ +#define REMOTING_HOST_REMOTING_REGISTER_SUPPORT_HOST_REQUEST_H_ + +#include "base/callback.h" +#include "base/macros.h" +#include "base/memory/ref_counted.h" +#include "remoting/base/grpc_support/grpc_authenticated_executor.h" +#include "remoting/host/register_support_host_request.h" +#include "remoting/proto/remoting/v1/remote_support_host_service.grpc.pb.h" +#include "remoting/signaling/muxing_signal_strategy.h" + +namespace remoting { + +class OAuthTokenGetter; + +// A RegisterSupportHostRequest implementation that uses Remoting API to +// register the host. +// +// Note that IT ONLY WORKS WITH MuxingSignalStrategy. +class RemotingRegisterSupportHostRequest final + : public RegisterSupportHostRequest, + public SignalStrategy::Listener { + public: + explicit RemotingRegisterSupportHostRequest( + std::unique_ptr<OAuthTokenGetter> token_getter); + ~RemotingRegisterSupportHostRequest() override; + + // RegisterSupportHostRequest implementation. + void StartRequest(SignalStrategy* signal_strategy, + scoped_refptr<RsaKeyPair> key_pair, + RegisterCallback callback) override; + + private: + using RemoteSupportService = apis::v1::RemoteSupportService; + + // SignalStrategy::Listener interface. + void OnSignalStrategyStateChange(SignalStrategy::State state) override; + bool OnSignalStrategyIncomingStanza( + const jingle_xmpp::XmlElement* stanza) override; + + void RegisterHost(); + void OnRegisterHostResult( + const grpc::Status& status, + const apis::v1::RegisterSupportHostResponse& response); + + void RunCallback(const std::string& support_id, + base::TimeDelta lifetime, + protocol::ErrorCode error_code); + + MuxingSignalStrategy* signal_strategy_ = nullptr; + scoped_refptr<RsaKeyPair> key_pair_; + RegisterCallback callback_; + std::unique_ptr<OAuthTokenGetter> token_getter_; + GrpcAuthenticatedExecutor grpc_executor_; + + std::unique_ptr<RemoteSupportService::Stub> remote_support_; + + DISALLOW_COPY_AND_ASSIGN(RemotingRegisterSupportHostRequest); +}; + +} // namespace remoting + +#endif // REMOTING_HOST_REMOTING_REGISTER_SUPPORT_HOST_REQUEST_H_
diff --git a/remoting/host/register_support_host_request.cc b/remoting/host/xmpp_register_support_host_request.cc similarity index 77% rename from remoting/host/register_support_host_request.cc rename to remoting/host/xmpp_register_support_host_request.cc index 543567c..9fda0c5b 100644 --- a/remoting/host/register_support_host_request.cc +++ b/remoting/host/xmpp_register_support_host_request.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/host/register_support_host_request.h" +#include "remoting/host/xmpp_register_support_host_request.h" #include <stdint.h> @@ -48,29 +48,32 @@ // The signaling timeout for register support host requests. constexpr int kRegisterRequestTimeoutInSeconds = 10; -} +} // namespace -RegisterSupportHostRequest::RegisterSupportHostRequest( - SignalStrategy* signal_strategy, - scoped_refptr<RsaKeyPair> key_pair, - const std::string& directory_bot_jid, - const RegisterCallback& callback) - : signal_strategy_(signal_strategy), - key_pair_(key_pair), - directory_bot_jid_(directory_bot_jid), - callback_(callback) { - DCHECK(signal_strategy_); - DCHECK(key_pair_.get()); - signal_strategy_->AddListener(this); - iq_sender_.reset(new IqSender(signal_strategy_)); -} +XmppRegisterSupportHostRequest::XmppRegisterSupportHostRequest( + const std::string& directory_bot_jid) + : directory_bot_jid_(directory_bot_jid) {} -RegisterSupportHostRequest::~RegisterSupportHostRequest() { +XmppRegisterSupportHostRequest::~XmppRegisterSupportHostRequest() { if (signal_strategy_) signal_strategy_->RemoveListener(this); } -void RegisterSupportHostRequest::OnSignalStrategyStateChange( +void XmppRegisterSupportHostRequest::StartRequest( + SignalStrategy* signal_strategy, + scoped_refptr<RsaKeyPair> key_pair, + RegisterCallback callback) { + DCHECK(signal_strategy); + DCHECK(key_pair.get()); + DCHECK(callback); + signal_strategy_ = signal_strategy; + key_pair_ = key_pair; + callback_ = std::move(callback); + signal_strategy_->AddListener(this); + iq_sender_.reset(new IqSender(signal_strategy_)); +} + +void XmppRegisterSupportHostRequest::OnSignalStrategyStateChange( SignalStrategy::State state) { if (state == SignalStrategy::CONNECTED) { DCHECK(!callback_.is_null()); @@ -79,9 +82,10 @@ // remoting bot JID. std::string host_jid = signal_strategy_->GetLocalAddress().id(); request_ = iq_sender_->SendIq( - jingle_xmpp::STR_SET, directory_bot_jid_, CreateRegistrationRequest(host_jid), - base::Bind(&RegisterSupportHostRequest::ProcessResponse, - base::Unretained(this))); + jingle_xmpp::STR_SET, directory_bot_jid_, + CreateRegistrationRequest(host_jid), + base::BindRepeating(&XmppRegisterSupportHostRequest::ProcessResponse, + base::Unretained(this))); if (!request_) { LOG(ERROR) << "Error sending the register-support-host request."; CallCallback(std::string(), base::TimeDelta(), @@ -99,13 +103,14 @@ } } -bool RegisterSupportHostRequest::OnSignalStrategyIncomingStanza( +bool XmppRegisterSupportHostRequest::OnSignalStrategyIncomingStanza( const jingle_xmpp::XmlElement* stanza) { return false; } std::unique_ptr<XmlElement> -RegisterSupportHostRequest::CreateRegistrationRequest(const std::string& jid) { +XmppRegisterSupportHostRequest::CreateRegistrationRequest( + const std::string& jid) { auto query = std::make_unique<XmlElement>( QName(kChromotingXmlNamespace, kRegisterQueryTag)); @@ -137,15 +142,15 @@ return query; } -std::unique_ptr<XmlElement> RegisterSupportHostRequest::CreateSignature( +std::unique_ptr<XmlElement> XmppRegisterSupportHostRequest::CreateSignature( const std::string& jid) { std::unique_ptr<XmlElement> signature_tag( new XmlElement(QName(kChromotingXmlNamespace, kSignatureTag))); int64_t time = static_cast<int64_t>(base::Time::Now().ToDoubleT()); std::string time_str(base::NumberToString(time)); - signature_tag->AddAttr( - QName(kChromotingXmlNamespace, kSignatureTimeAttr), time_str); + signature_tag->AddAttr(QName(kChromotingXmlNamespace, kSignatureTimeAttr), + time_str); std::string message = NormalizeJid(jid) + ' ' + time_str; std::string signature(key_pair_->SignMessage(message)); @@ -154,10 +159,10 @@ return signature_tag; } -void RegisterSupportHostRequest::ParseResponse(const XmlElement* response, - std::string* support_id, - base::TimeDelta* lifetime, - ErrorCode* error_code) { +void XmppRegisterSupportHostRequest::ParseResponse(const XmlElement* response, + std::string* support_id, + base::TimeDelta* lifetime, + ErrorCode* error_code) { if (!response) { LOG(ERROR) << "register-support-host request timed out."; *error_code = ErrorCode::SIGNALING_TIMEOUT; @@ -179,8 +184,8 @@ return; } - const XmlElement* result_element = response->FirstNamed(QName( - kChromotingXmlNamespace, kRegisterQueryResultTag)); + const XmlElement* result_element = response->FirstNamed( + QName(kChromotingXmlNamespace, kRegisterQueryResultTag)); if (!result_element) { LOG(ERROR) << "<" << kRegisterQueryResultTag << "> is missing in the host registration response: " @@ -199,9 +204,8 @@ return; } - const XmlElement* lifetime_element = - result_element->FirstNamed(QName(kChromotingXmlNamespace, - kSupportIdLifetimeTag)); + const XmlElement* lifetime_element = result_element->FirstNamed( + QName(kChromotingXmlNamespace, kSupportIdLifetimeTag)); if (!lifetime_element) { LOG(ERROR) << "<" << kSupportIdLifetimeTag << "> is missing in the host registration response: " @@ -225,8 +229,9 @@ return; } -void RegisterSupportHostRequest::ProcessResponse(IqRequest* request, - const XmlElement* response) { +void XmppRegisterSupportHostRequest::ProcessResponse( + IqRequest* request, + const XmlElement* response) { std::string support_id; base::TimeDelta lifetime; ErrorCode error_code = ErrorCode::OK; @@ -234,9 +239,9 @@ CallCallback(support_id, lifetime, error_code); } -void RegisterSupportHostRequest::CallCallback(const std::string& support_id, - base::TimeDelta lifetime, - ErrorCode error_code) { +void XmppRegisterSupportHostRequest::CallCallback(const std::string& support_id, + base::TimeDelta lifetime, + ErrorCode error_code) { // Cleanup state before calling the callback. request_.reset(); iq_sender_.reset();
diff --git a/remoting/host/xmpp_register_support_host_request.h b/remoting/host/xmpp_register_support_host_request.h new file mode 100644 index 0000000..de954fd5 --- /dev/null +++ b/remoting/host/xmpp_register_support_host_request.h
@@ -0,0 +1,89 @@ +// Copyright 2019 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 REMOTING_HOST_XMPP_REGISTER_SUPPORT_HOST_REQUEST_H_ +#define REMOTING_HOST_XMPP_REGISTER_SUPPORT_HOST_REQUEST_H_ + +#include <memory> +#include <string> + +#include "base/callback.h" +#include "base/macros.h" +#include "base/memory/ref_counted.h" +#include "remoting/base/rsa_key_pair.h" +#include "remoting/host/register_support_host_request.h" +#include "remoting/protocol/errors.h" +#include "remoting/signaling/signal_strategy.h" +#include "testing/gtest/include/gtest/gtest_prod.h" + +namespace jingle_xmpp { +class XmlElement; +} // namespace jingle_xmpp + +namespace base { +class TimeDelta; +} // namespace base + +namespace remoting { + +class IqRequest; +class IqSender; + +// XmppRegisterSupportHostRequest sends a request to register the host for +// a SupportID, as soon as the associated SignalStrategy becomes +// connected. When a response is received from the bot, it calls the +// callback specified in the Init() method. +class XmppRegisterSupportHostRequest : public RegisterSupportHostRequest, + public SignalStrategy::Listener { + public: + // |signal_strategy| and |key_pair| must outlive this + // object. |callback| is called when registration response is + // received from the server. Callback is never called if the bot + // malfunctions and doesn't respond to the request. + explicit XmppRegisterSupportHostRequest(const std::string& directory_bot_jid); + ~XmppRegisterSupportHostRequest() override; + + // RegisterSupportHostRequest implementation. + void StartRequest(SignalStrategy* signal_strategy, + scoped_refptr<RsaKeyPair> key_pair, + RegisterCallback callback) override; + + // HostStatusObserver implementation. + void OnSignalStrategyStateChange(SignalStrategy::State state) override; + bool OnSignalStrategyIncomingStanza( + const jingle_xmpp::XmlElement* stanza) override; + + private: + void DoSend(); + + std::unique_ptr<jingle_xmpp::XmlElement> CreateRegistrationRequest( + const std::string& jid); + std::unique_ptr<jingle_xmpp::XmlElement> CreateSignature( + const std::string& jid); + + void ProcessResponse(IqRequest* request, + const jingle_xmpp::XmlElement* response); + void ParseResponse(const jingle_xmpp::XmlElement* response, + std::string* support_id, + base::TimeDelta* lifetime, + protocol::ErrorCode* error_code); + + void CallCallback(const std::string& support_id, + base::TimeDelta lifetime, + protocol::ErrorCode error_code); + + SignalStrategy* signal_strategy_ = nullptr; + scoped_refptr<RsaKeyPair> key_pair_; + std::string directory_bot_jid_; + RegisterCallback callback_; + + std::unique_ptr<IqSender> iq_sender_; + std::unique_ptr<IqRequest> request_; + + DISALLOW_COPY_AND_ASSIGN(XmppRegisterSupportHostRequest); +}; + +} // namespace remoting + +#endif // REMOTING_HOST_XMPP_REGISTER_SUPPORT_HOST_REQUEST_H_
diff --git a/remoting/host/register_support_host_request_unittest.cc b/remoting/host/xmpp_register_support_host_request_unittest.cc similarity index 81% rename from remoting/host/register_support_host_request_unittest.cc rename to remoting/host/xmpp_register_support_host_request_unittest.cc index 5f10998..ce011bc 100644 --- a/remoting/host/register_support_host_request_unittest.cc +++ b/remoting/host/xmpp_register_support_host_request_unittest.cc
@@ -2,18 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/host/register_support_host_request.h" +#include "remoting/host/xmpp_register_support_host_request.h" #include <stdint.h> #include "base/bind.h" #include "base/memory/ref_counted.h" -#include "base/message_loop/message_loop.h" #include "base/observer_list.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringize_macros.h" #include "base/test/mock_callback.h" -#include "base/test/scoped_mock_time_message_loop_task_runner.h" +#include "base/test/scoped_task_environment.h" #include "remoting/base/constants.h" #include "remoting/base/rsa_key_pair.h" #include "remoting/base/test_rsa_key_pair.h" @@ -31,11 +30,11 @@ using jingle_xmpp::XmlElement; using testing::_; +using testing::DeleteArg; using testing::Invoke; using testing::NotNull; using testing::Return; using testing::SaveArg; -using testing::DeleteArg; namespace remoting { @@ -58,10 +57,10 @@ } // namespace -class RegisterSupportHostRequestTest : public testing::Test { +class XmppRegisterSupportHostRequestTest : public testing::Test { public: protected: - RegisterSupportHostRequestTest() + XmppRegisterSupportHostRequestTest() : signal_strategy_(SignalingAddress(kTestJid)) {} void SetUp() override { @@ -74,18 +73,17 @@ .WillRepeatedly(RemoveListener(&signal_strategy_listeners_)); } - base::MessageLoop message_loop_; - base::ScopedMockTimeMessageLoopTaskRunner mock_time_task_runner_; + base::test::ScopedTaskEnvironment scoped_task_environment_{ + base::test::ScopedTaskEnvironment::MainThreadType::MOCK_TIME}; MockSignalStrategy signal_strategy_; base::ObserverList<SignalStrategy::Listener, true> signal_strategy_listeners_; scoped_refptr<RsaKeyPair> key_pair_; base::MockCallback<RegisterSupportHostRequest::RegisterCallback> callback_; }; -TEST_F(RegisterSupportHostRequestTest, Timeout) { - std::unique_ptr<RegisterSupportHostRequest> request( - new RegisterSupportHostRequest(&signal_strategy_, key_pair_, kTestBotJid, - callback_.Get())); +TEST_F(XmppRegisterSupportHostRequestTest, Timeout) { + auto request = std::make_unique<XmppRegisterSupportHostRequest>(kTestBotJid); + request->StartRequest(&signal_strategy_, key_pair_, callback_.Get()); EXPECT_CALL(signal_strategy_, GetNextId()).WillOnce(Return(kStanzaId)); EXPECT_CALL(signal_strategy_, SendStanzaPtr(NotNull())) .WillOnce(DoAll(DeleteArg<0>(), Return(true))); @@ -96,25 +94,23 @@ EXPECT_CALL(callback_, Run("", base::TimeDelta::FromSeconds(0), ErrorCode::SIGNALING_TIMEOUT)); - mock_time_task_runner_->FastForwardBy(base::TimeDelta::FromSeconds(15)); + scoped_task_environment_.FastForwardBy(base::TimeDelta::FromSeconds(15)); } -TEST_F(RegisterSupportHostRequestTest, Send) { - // |iq_request| is freed by RegisterSupportHostRequest. +TEST_F(XmppRegisterSupportHostRequestTest, Send) { + // |iq_request| is freed by XmppRegisterSupportHostRequest. int64_t start_time = static_cast<int64_t>(base::Time::Now().ToDoubleT()); - std::unique_ptr<RegisterSupportHostRequest> request( - new RegisterSupportHostRequest(&signal_strategy_, key_pair_, kTestBotJid, - callback_.Get())); + auto request = std::make_unique<XmppRegisterSupportHostRequest>(kTestBotJid); + request->StartRequest(&signal_strategy_, key_pair_, callback_.Get()); XmlElement* sent_iq = nullptr; - EXPECT_CALL(signal_strategy_, GetNextId()) - .WillOnce(Return(kStanzaId)); + EXPECT_CALL(signal_strategy_, GetNextId()).WillOnce(Return(kStanzaId)); EXPECT_CALL(signal_strategy_, SendStanzaPtr(NotNull())) .WillOnce(DoAll(SaveArg<0>(&sent_iq), Return(true))); request->OnSignalStrategyStateChange(SignalStrategy::CONNECTED); - mock_time_task_runner_->RunUntilIdle(); + scoped_task_environment_.RunUntilIdle(); // Verify format of the query. std::unique_ptr<XmlElement> stanza(sent_iq); @@ -172,13 +168,13 @@ QName(kChromotingXmlNamespace, "register-support-host-result")); response->AddElement(result); - XmlElement* support_id = new XmlElement( - QName(kChromotingXmlNamespace, "support-id")); + XmlElement* support_id = + new XmlElement(QName(kChromotingXmlNamespace, "support-id")); support_id->AddText(kSupportId); result->AddElement(support_id); - XmlElement* support_id_lifetime = new XmlElement( - QName(kChromotingXmlNamespace, "support-id-lifetime")); + XmlElement* support_id_lifetime = + new XmlElement(QName(kChromotingXmlNamespace, "support-id-lifetime")); support_id_lifetime->AddText(kSupportIdLifetime); result->AddElement(support_id_lifetime); @@ -189,7 +185,7 @@ } EXPECT_EQ(1, consumed); - mock_time_task_runner_->RunUntilIdle(); + scoped_task_environment_.RunUntilIdle(); } } // namespace remoting
diff --git a/remoting/ios/facade/BUILD.gn b/remoting/ios/facade/BUILD.gn index 5940978..970cc5a 100644 --- a/remoting/ios/facade/BUILD.gn +++ b/remoting/ios/facade/BUILD.gn
@@ -10,8 +10,6 @@ sources = [ "directory_client.cc", "directory_client.h", - "ftl_device_id_provider_ios.h", - "ftl_device_id_provider_ios.mm", "host_list_service.h", "host_list_service.mm", "ios_client_runtime_delegate.h",
diff --git a/remoting/ios/facade/ftl_device_id_provider_ios.h b/remoting/ios/facade/ftl_device_id_provider_ios.h deleted file mode 100644 index 580f4b961..0000000 --- a/remoting/ios/facade/ftl_device_id_provider_ios.h +++ /dev/null
@@ -1,30 +0,0 @@ -// Copyright 2019 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 REMOTING_IOS_FACADE_FTL_DEVICE_ID_PROVIDER_IOS_H_ -#define REMOTING_IOS_FACADE_FTL_DEVICE_ID_PROVIDER_IOS_H_ - -#include <string> - -#include "base/macros.h" -#include "remoting/signaling/ftl_device_id_provider.h" - -namespace remoting { - -class FtlDeviceIdProviderIos final : public FtlDeviceIdProvider { - public: - FtlDeviceIdProviderIos(); - ~FtlDeviceIdProviderIos() override; - - ftl::DeviceId GetDeviceId() override; - - private: - ftl::DeviceId device_id_; - - DISALLOW_COPY_AND_ASSIGN(FtlDeviceIdProviderIos); -}; - -} // namespace remoting - -#endif // REMOTING_IOS_FACADE_FTL_DEVICE_ID_PROVIDER_IOS_H_
diff --git a/remoting/ios/facade/ftl_device_id_provider_ios.mm b/remoting/ios/facade/ftl_device_id_provider_ios.mm deleted file mode 100644 index 8159057..0000000 --- a/remoting/ios/facade/ftl_device_id_provider_ios.mm +++ /dev/null
@@ -1,30 +0,0 @@ -// Copyright 2019 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. - -#if !defined(__has_feature) || !__has_feature(objc_arc) -#error "This file requires ARC support." -#endif - -#include "remoting/ios/facade/ftl_device_id_provider_ios.h" - -#import <UIKit/UIKit.h> - -#include "base/strings/sys_string_conversions.h" - -namespace remoting { - -FtlDeviceIdProviderIos::FtlDeviceIdProviderIos() { - std::string vendor_id = base::SysNSStringToUTF8( - UIDevice.currentDevice.identifierForVendor.UUIDString); - device_id_.set_type(ftl::DeviceIdType_Type_IOS_VENDOR_ID); - device_id_.set_id(vendor_id); -} - -FtlDeviceIdProviderIos::~FtlDeviceIdProviderIos() = default; - -ftl::DeviceId FtlDeviceIdProviderIos::GetDeviceId() { - return device_id_; -} - -} // namespace remoting
diff --git a/remoting/ios/session/remoting_client.mm b/remoting/ios/session/remoting_client.mm index 84e7eda..efc2691 100644 --- a/remoting/ios/session/remoting_client.mm +++ b/remoting/ios/session/remoting_client.mm
@@ -26,7 +26,6 @@ #include "remoting/client/connect_to_host_info.h" #include "remoting/client/gesture_interpreter.h" #include "remoting/client/input/keyboard_interpreter.h" -#include "remoting/ios/facade/ftl_device_id_provider_ios.h" #import "remoting/ios/facade/remoting_authentication.h" #import "remoting/ios/facade/remoting_service.h" #include "remoting/ios/session/remoting_client_session_delegate.h" @@ -141,13 +140,9 @@ _displayHandler = [[GlDisplayHandler alloc] init]; _displayHandler.delegate = self; - auto device_id_provider = - std::make_unique<remoting::FtlDeviceIdProviderIos>(); - _session = std::make_unique<remoting::ChromotingSession>( _sessonDelegate->GetWeakPtr(), [_displayHandler createCursorShapeStub], - [_displayHandler createVideoRenderer], std::move(audioStream), - std::move(device_id_provider), info); + [_displayHandler createVideoRenderer], std::move(audioStream), info); _gestureInterpreter.SetContext(_displayHandler.rendererProxy, _session.get()); _keyboardInterpreter.SetContext(_session.get()); }
diff --git a/remoting/proto/ftl/v1/ftl_messages.proto b/remoting/proto/ftl/v1/ftl_messages.proto index ffbfb70..731d15f 100644 --- a/remoting/proto/ftl/v1/ftl_messages.proto +++ b/remoting/proto/ftl/v1/ftl_messages.proto
@@ -46,10 +46,9 @@ message DeviceIdType { enum Type { UNKNOWN = 0; - ANDROID_IID_TOKEN = 1; - IOS_VENDOR_ID = 2; WEB_UUID = 3; CHROMOTING_HOST_ID = 6; + CLIENT_UUID = 7; } }
diff --git a/remoting/proto/remoting/v1/BUILD.gn b/remoting/proto/remoting/v1/BUILD.gn index 4eff495..7ee1ee6c 100644 --- a/remoting/proto/remoting/v1/BUILD.gn +++ b/remoting/proto/remoting/v1/BUILD.gn
@@ -5,10 +5,18 @@ import("//third_party/grpc/grpc_library.gni") import("//third_party/protobuf/proto_library.gni") +proto_library("host_info_proto") { + sources = [ + "host_info.proto", + ] +} + proto_library("directory_proto") { sources = [ "directory_messages.proto", - "host_info.proto", + ] + deps = [ + ":host_info_proto", ] } @@ -47,3 +55,13 @@ ":network_traversal_proto", ] } + +cc_grpc_library("remote_support_host_grpc_library") { + sources = [ + "remote_support_host_messages.proto", + "remote_support_host_service.proto", + ] + deps = [ + ":host_info_proto", + ] +}
diff --git a/remoting/proto/remoting/v1/remote_support_host_messages.proto b/remoting/proto/remoting/v1/remote_support_host_messages.proto new file mode 100644 index 0000000..93f8913 --- /dev/null +++ b/remoting/proto/remoting/v1/remote_support_host_messages.proto
@@ -0,0 +1,49 @@ +syntax = "proto2"; + +package remoting.apis.v1; + +import "host_info.proto"; + +option optimize_for = LITE_RUNTIME; + +// Request host info for a specific support host instance. +message GetSupportHostRequest { + // The unique identifier for the host being requested. + optional string support_id = 1; +} + +// The response to a GetSupportHostRequest. +message GetSupportHostResponse { + // The connection info for the host associated with the given support_id. + optional HostInfo support_host = 1; +} + +// Registers a support host instance. +message RegisterSupportHostRequest { + // Public key for the host. Must be a 2048-bit RSA key encoded with BASE64. + optional string public_key = 1; + + // The ID associated with the host on the Talk network. + optional string jabber_id = 2; + + // The ID associated with the host on the Tachyon network. + optional string tachyon_id = 3; + + // Version of the It2Me host software installed on the host. + optional string host_version = 4; + + // Operating system type of the host. + optional string host_os_name = 5; + + // Operating system version of the host. + optional string host_os_version = 6; +} + +// The response to a RegisterSupportHostRequest. +message RegisterSupportHostResponse { + // A unique identifier for the registered host. + optional string support_id = 1; + + // The length of time |support_id| will remain valid. + optional int32 support_id_lifetime_seconds = 2; +}
diff --git a/remoting/proto/remoting/v1/remote_support_host_service.proto b/remoting/proto/remoting/v1/remote_support_host_service.proto new file mode 100644 index 0000000..0c2777b3 --- /dev/null +++ b/remoting/proto/remoting/v1/remote_support_host_service.proto
@@ -0,0 +1,14 @@ +syntax = "proto2"; + +package remoting.apis.v1; + +import "remote_support_host_messages.proto"; + +option optimize_for = LITE_RUNTIME; + +// A set of RPC services which provide remote support functionality. +service RemoteSupportService { + // RPC service which registers a remote support host. + rpc RegisterSupportHost(RegisterSupportHostRequest) + returns (RegisterSupportHostResponse) {} +}
diff --git a/remoting/signaling/BUILD.gn b/remoting/signaling/BUILD.gn index 2902eaa..3b126b4 100644 --- a/remoting/signaling/BUILD.gn +++ b/remoting/signaling/BUILD.gn
@@ -6,6 +6,8 @@ sources = [ "delegating_signal_strategy.cc", "delegating_signal_strategy.h", + "ftl_client_uuid_device_id_provider.cc", + "ftl_client_uuid_device_id_provider.h", "ftl_device_id_provider.h", "ftl_grpc_context.cc", "ftl_grpc_context.h", @@ -72,6 +74,8 @@ if (is_nacl) { sources -= [ + "ftl_client_uuid_device_id_provider.cc", + "ftl_client_uuid_device_id_provider.h", "ftl_grpc_context.cc", "ftl_grpc_context.h", "ftl_host_device_id_provider.cc",
diff --git a/remoting/signaling/ftl_client_uuid_device_id_provider.cc b/remoting/signaling/ftl_client_uuid_device_id_provider.cc new file mode 100644 index 0000000..4ae2313 --- /dev/null +++ b/remoting/signaling/ftl_client_uuid_device_id_provider.cc
@@ -0,0 +1,23 @@ +// Copyright 2019 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 "remoting/signaling/ftl_client_uuid_device_id_provider.h" + +#include "base/guid.h" + +namespace remoting { + +FtlClientUuidDeviceIdProvider::FtlClientUuidDeviceIdProvider() + : client_uuid_(base::GenerateGUID()) {} + +FtlClientUuidDeviceIdProvider::~FtlClientUuidDeviceIdProvider() = default; + +ftl::DeviceId FtlClientUuidDeviceIdProvider::GetDeviceId() { + ftl::DeviceId device_id; + device_id.set_type(ftl::DeviceIdType_Type_CLIENT_UUID); + device_id.set_id(client_uuid_); + return device_id; +} + +} // namespace remoting
diff --git a/remoting/signaling/ftl_client_uuid_device_id_provider.h b/remoting/signaling/ftl_client_uuid_device_id_provider.h new file mode 100644 index 0000000..b884afe5 --- /dev/null +++ b/remoting/signaling/ftl_client_uuid_device_id_provider.h
@@ -0,0 +1,29 @@ +// Copyright 2019 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 REMOTING_SIGNALING_FTL_CLIENT_UUID_DEVICE_ID_PROVIDER_H_ +#define REMOTING_SIGNALING_FTL_CLIENT_UUID_DEVICE_ID_PROVIDER_H_ + +#include <string> + +#include "remoting/signaling/ftl_device_id_provider.h" + +namespace remoting { + +// A device ID provider using ephemeral client UUIDs. A random UUID will be +// generated on construction. +class FtlClientUuidDeviceIdProvider : public FtlDeviceIdProvider { + public: + FtlClientUuidDeviceIdProvider(); + ~FtlClientUuidDeviceIdProvider() override; + + ftl::DeviceId GetDeviceId() override; + + private: + std::string client_uuid_; +}; + +} // namespace remoting + +#endif // REMOTING_SIGNALING_FTL_CLIENT_UUID_DEVICE_ID_PROVIDER_H_
diff --git a/services/network/BUILD.gn b/services/network/BUILD.gn index eb12610..2001fbc5 100644 --- a/services/network/BUILD.gn +++ b/services/network/BUILD.gn
@@ -61,8 +61,6 @@ "loader_util.h", "mojo_host_resolver_impl.cc", "mojo_host_resolver_impl.h", - "net_log_capture_mode_type_converter.cc", - "net_log_capture_mode_type_converter.h", "net_log_exporter.cc", "net_log_exporter.h", "network_change_manager.cc",
diff --git a/services/network/net_log_capture_mode_type_converter.cc b/services/network/net_log_capture_mode_type_converter.cc deleted file mode 100644 index b9447f4..0000000 --- a/services/network/net_log_capture_mode_type_converter.cc +++ /dev/null
@@ -1,24 +0,0 @@ -// Copyright 2018 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 "services/network/net_log_capture_mode_type_converter.h" - -namespace mojo { - -net::NetLogCaptureMode -TypeConverter<net::NetLogCaptureMode, network::mojom::NetLogCaptureMode>:: - Convert(const network::mojom::NetLogCaptureMode capture_mode) { - switch (capture_mode) { - case network::mojom::NetLogCaptureMode::DEFAULT: - return net::NetLogCaptureMode::Default(); - case network::mojom::NetLogCaptureMode::INCLUDE_COOKIES_AND_CREDENTIALS: - return net::NetLogCaptureMode::IncludeCookiesAndCredentials(); - case network::mojom::NetLogCaptureMode::INCLUDE_SOCKET_BYTES: - return net::NetLogCaptureMode::IncludeSocketBytes(); - } - NOTREACHED(); - return net::NetLogCaptureMode::Default(); -} - -} // namespace mojo
diff --git a/services/network/net_log_capture_mode_type_converter.h b/services/network/net_log_capture_mode_type_converter.h deleted file mode 100644 index 3a10c80..0000000 --- a/services/network/net_log_capture_mode_type_converter.h +++ /dev/null
@@ -1,24 +0,0 @@ -// Copyright 2018 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 SERVICES_NETWORK_NET_LOG_CAPTURE_MODE_TYPE_CONVERTER_H_ -#define SERVICES_NETWORK_NET_LOG_CAPTURE_MODE_TYPE_CONVERTER_H_ - -#include "mojo/public/cpp/bindings/type_converter.h" -#include "net/log/net_log_capture_mode.h" -#include "services/network/public/mojom/net_log.mojom.h" - -namespace mojo { - -// Converts a network::mojom::NetLogCaptureMode to a net::NetLogCaptureMode. -template <> -struct TypeConverter<net::NetLogCaptureMode, - network::mojom::NetLogCaptureMode> { - static net::NetLogCaptureMode Convert( - network::mojom::NetLogCaptureMode capture_mode); -}; - -} // namespace mojo - -#endif // SERVICES_NETWORK_NET_LOG_CAPTURE_MODE_TYPE_CONVERTER_H_
diff --git a/services/network/net_log_exporter.cc b/services/network/net_log_exporter.cc index c875499b..cc22a62 100644 --- a/services/network/net_log_exporter.cc +++ b/services/network/net_log_exporter.cc
@@ -13,11 +13,9 @@ #include "base/task/post_task.h" #include "base/task/task_traits.h" #include "base/values.h" -#include "mojo/public/cpp/bindings/type_converter.h" #include "net/log/file_net_log_observer.h" #include "net/log/net_log_util.h" #include "net/url_request/url_request_context.h" -#include "services/network/net_log_capture_mode_type_converter.h" #include "services/network/network_context.h" #include "services/network/network_service.h" #include "services/network/public/cpp/network_switches.h" @@ -42,7 +40,7 @@ void NetLogExporter::Start(base::File destination, base::Value extra_constants, - mojom::NetLogCaptureMode capture_mode, + net::NetLogCaptureMode capture_mode, uint64_t max_file_size, StartCallback callback) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); @@ -58,9 +56,6 @@ // be carefully controlled. destination_ = std::move(destination); - net::NetLogCaptureMode net_capture_mode = - mojo::ConvertTo<net::NetLogCaptureMode>(capture_mode); - state_ = STATE_WAITING_DIR; static_assert(kUnlimitedFileSize == net::FileNetLogObserver::kNoLimit, "Inconsistent unbounded size constants"); @@ -74,11 +69,11 @@ // Note: this a static method which takes a weak pointer as an argument, // so it will run if |this| is deleted. base::BindOnce(&NetLogExporter::StartWithScratchDirOrCleanup, - AsWeakPtr(), std::move(extra_constants), - net_capture_mode, max_file_size, std::move(callback))); + AsWeakPtr(), std::move(extra_constants), capture_mode, + max_file_size, std::move(callback))); } else { - StartWithScratchDir(std::move(extra_constants), net_capture_mode, - max_file_size, std::move(callback), base::FilePath()); + StartWithScratchDir(std::move(extra_constants), capture_mode, max_file_size, + std::move(callback), base::FilePath()); } }
diff --git a/services/network/net_log_exporter.h b/services/network/net_log_exporter.h index ce73afa1..a8542be 100644 --- a/services/network/net_log_exporter.h +++ b/services/network/net_log_exporter.h
@@ -35,7 +35,7 @@ void Start(base::File destination, base::Value extra_constants, - network::mojom::NetLogCaptureMode capture_mode, + net::NetLogCaptureMode capture_mode, uint64_t max_file_size, StartCallback callback) override; void Stop(base::Value polled_data, StopCallback callback) override;
diff --git a/services/network/network_context_unittest.cc b/services/network/network_context_unittest.cc index d5410bd..69259fb 100644 --- a/services/network/network_context_unittest.cc +++ b/services/network/network_context_unittest.cc
@@ -2473,7 +2473,7 @@ net::TestCompletionCallback start_callback; net_log_exporter->Start(std::move(out_file), std::move(dict_start), - mojom::NetLogCaptureMode::DEFAULT, 100 * 1024, + net::NetLogCaptureMode::Default(), 100 * 1024, start_callback.callback()); EXPECT_EQ(net::OK, start_callback.WaitForResult()); @@ -2518,7 +2518,7 @@ net::TestCompletionCallback start_callback; net_log_exporter->Start( std::move(out_file), base::Value(base::Value::Type::DICTIONARY), - mojom::NetLogCaptureMode::DEFAULT, + net::NetLogCaptureMode::Default(), mojom::NetLogExporter::kUnlimitedFileSize, start_callback.callback()); EXPECT_EQ(net::OK, start_callback.WaitForResult()); @@ -2560,7 +2560,7 @@ net::TestCompletionCallback start_callback; net_log_exporter->Start( std::move(temp_file), base::Value(base::Value::Type::DICTIONARY), - mojom::NetLogCaptureMode::DEFAULT, 100 * 1024, start_callback.callback()); + net::NetLogCaptureMode::Default(), 100 * 1024, start_callback.callback()); EXPECT_EQ(net::OK, start_callback.WaitForResult()); // Can't start twice. @@ -2573,7 +2573,7 @@ net::TestCompletionCallback start_callback2; net_log_exporter->Start(std::move(temp_file2), base::Value(base::Value::Type::DICTIONARY), - mojom::NetLogCaptureMode::DEFAULT, 100 * 1024, + net::NetLogCaptureMode::Default(), 100 * 1024, start_callback2.callback()); EXPECT_EQ(net::ERR_UNEXPECTED, start_callback2.WaitForResult()); @@ -2618,7 +2618,7 @@ net_log_exporter->Start( std::move(temp_file), base::Value(base::Value::Type::DICTIONARY), - mojom::NetLogCaptureMode::DEFAULT, 100, base::BindOnce([](int) {})); + net::NetLogCaptureMode::Default(), 100, base::BindOnce([](int) {})); net_log_exporter = nullptr; block_mktemp.Signal(); @@ -3946,7 +3946,7 @@ net_log_exporter->Start( std::move(net_log_file), /*extra_constants=*/base::Value(base::Value::Type::DICTIONARY), - network::mojom::NetLogCaptureMode::DEFAULT, + net::NetLogCaptureMode::Default(), network::mojom::NetLogExporter::kUnlimitedFileSize, start_callback); run_loop.Run(); EXPECT_EQ(net::OK, start_param);
diff --git a/services/network/network_service.cc b/services/network/network_service.cc index f48318957..66a4e206 100644 --- a/services/network/network_service.cc +++ b/services/network/network_service.cc
@@ -24,7 +24,6 @@ #include "components/os_crypt/os_crypt.h" #include "mojo/core/embedder/embedder.h" #include "mojo/public/cpp/bindings/strong_binding.h" -#include "mojo/public/cpp/bindings/type_converter.h" #include "net/base/logging_network_change_observer.h" #include "net/base/network_change_notifier.h" #include "net/base/network_change_notifier_posix.h" @@ -47,7 +46,6 @@ #include "services/network/cross_origin_read_blocking.h" #include "services/network/dns_config_change_manager.h" #include "services/network/http_auth_cache_copier.h" -#include "services/network/net_log_capture_mode_type_converter.h" #include "services/network/net_log_exporter.h" #include "services/network/network_context.h" #include "services/network/network_usage_accumulator.h" @@ -428,7 +426,7 @@ } void NetworkService::StartNetLog(base::File file, - mojom::NetLogCaptureMode capture_mode, + net::NetLogCaptureMode capture_mode, base::Value client_constants) { DCHECK(client_constants.is_dict()); std::unique_ptr<base::DictionaryValue> constants = net::GetNetConstants(); @@ -436,8 +434,7 @@ file_net_log_observer_ = net::FileNetLogObserver::CreateUnboundedPreExisting( std::move(file), std::move(constants)); - file_net_log_observer_->StartObserving( - net_log_, mojo::ConvertTo<net::NetLogCaptureMode>(capture_mode)); + file_net_log_observer_->StartObserving(net_log_, capture_mode); } void NetworkService::SetSSLKeyLogFile(const base::FilePath& file) {
diff --git a/services/network/network_service.h b/services/network/network_service.h index 1db705e..ff159f1 100644 --- a/services/network/network_service.h +++ b/services/network/network_service.h
@@ -150,7 +150,7 @@ void SetClient(mojom::NetworkServiceClientPtr client, mojom::NetworkServiceParamsPtr params) override; void StartNetLog(base::File file, - mojom::NetLogCaptureMode capture_mode, + net::NetLogCaptureMode capture_mode, base::Value constants) override; void SetSSLKeyLogFile(const base::FilePath& file) override; void CreateNetworkContext(mojom::NetworkContextRequest request,
diff --git a/services/network/network_service_unittest.cc b/services/network/network_service_unittest.cc index e7a81510..f6858114 100644 --- a/services/network/network_service_unittest.cc +++ b/services/network/network_service_unittest.cc
@@ -694,9 +694,8 @@ base::File log_file(log_path, base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); - network_service_->StartNetLog(std::move(log_file), - network::mojom::NetLogCaptureMode::DEFAULT, - std::move(dict)); + network_service_->StartNetLog( + std::move(log_file), net::NetLogCaptureMode::Default(), std::move(dict)); CreateNetworkContext(); LoadURL(test_server()->GetURL("/echo")); EXPECT_EQ(net::OK, client()->completion_status().error_code);
diff --git a/services/network/public/cpp/net_log.typemap b/services/network/public/cpp/net_log.typemap new file mode 100644 index 0000000..860d4b6 --- /dev/null +++ b/services/network/public/cpp/net_log.typemap
@@ -0,0 +1,14 @@ +# Copyright 2019 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 = "//services/network/public/mojom/net_log.mojom" +public_headers = [ "//net/log/net_log_capture_mode.h" ] +traits_headers = [ "/services/network/public/cpp/net_log_mojom_traits.h" ] +sources = [ + "//services/network/public/cpp/net_log_mojom_traits.cc", +] +type_mappings = [ "network.mojom.NetLogCaptureMode=net::NetLogCaptureMode" ] +public_deps = [ + "//net", +]
diff --git a/services/network/public/cpp/net_log_mojom_traits.cc b/services/network/public/cpp/net_log_mojom_traits.cc new file mode 100644 index 0000000..c1648f2b --- /dev/null +++ b/services/network/public/cpp/net_log_mojom_traits.cc
@@ -0,0 +1,40 @@ +// Copyright 2019 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 "services/network/public/cpp/net_log_mojom_traits.h" + +namespace mojo { + +// static +bool EnumTraits<network::mojom::NetLogCaptureMode, net::NetLogCaptureMode>:: + FromMojom(network::mojom::NetLogCaptureMode capture_mode, + net::NetLogCaptureMode* out) { + switch (capture_mode) { + case network::mojom::NetLogCaptureMode::DEFAULT: + *out = net::NetLogCaptureMode::Default(); + return true; + case network::mojom::NetLogCaptureMode::INCLUDE_COOKIES_AND_CREDENTIALS: + *out = net::NetLogCaptureMode::IncludeCookiesAndCredentials(); + return true; + case network::mojom::NetLogCaptureMode::INCLUDE_SOCKET_BYTES: + *out = net::NetLogCaptureMode::IncludeSocketBytes(); + return true; + } + return false; +} + +// static +network::mojom::NetLogCaptureMode +EnumTraits<network::mojom::NetLogCaptureMode, net::NetLogCaptureMode>::ToMojom( + net::NetLogCaptureMode capture_mode) { + if (capture_mode.include_cookies_and_credentials()) + return network::mojom::NetLogCaptureMode::INCLUDE_COOKIES_AND_CREDENTIALS; + if (capture_mode.include_socket_bytes()) + return network::mojom::NetLogCaptureMode::INCLUDE_SOCKET_BYTES; + + // TODO(eroman): Should fail if unrecognized mode rather than defaulting. + return network::mojom::NetLogCaptureMode::DEFAULT; +} + +} // namespace mojo
diff --git a/services/network/public/cpp/net_log_mojom_traits.h b/services/network/public/cpp/net_log_mojom_traits.h new file mode 100644 index 0000000..870a87b --- /dev/null +++ b/services/network/public/cpp/net_log_mojom_traits.h
@@ -0,0 +1,23 @@ +// Copyright 2019 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 SERVICES_NETWORK_PUBLIC_CPP_NET_LOG_MOJOM_TRAITS_H_ +#define SERVICES_NETWORK_PUBLIC_CPP_NET_LOG_MOJOM_TRAITS_H_ + +#include "mojo/public/cpp/bindings/enum_traits.h" +#include "services/network/public/mojom/net_log.mojom.h" + +namespace mojo { + +template <> +struct EnumTraits<network::mojom::NetLogCaptureMode, net::NetLogCaptureMode> { + static network::mojom::NetLogCaptureMode ToMojom( + net::NetLogCaptureMode capture_mode); + static bool FromMojom(network::mojom::NetLogCaptureMode capture_mode, + net::NetLogCaptureMode* out); +}; + +} // namespace mojo + +#endif // SERVICES_NETWORK_PUBLIC_CPP_NET_LOG_MOJOM_TRAITS_H_
diff --git a/services/network/public/cpp/typemaps.gni b/services/network/public/cpp/typemaps.gni index 8ff9d36..06a2827 100644 --- a/services/network/public/cpp/typemaps.gni +++ b/services/network/public/cpp/typemaps.gni
@@ -16,6 +16,7 @@ "//services/network/public/cpp/ip_endpoint.typemap", "//services/network/public/cpp/mutable_network_traffic_annotation_tag.typemap", "//services/network/public/cpp/mutable_partial_network_traffic_annotation_tag.typemap", + "//services/network/public/cpp/net_log.typemap", "//services/network/public/cpp/network_interface.typemap", "//services/network/public/cpp/network_param.typemap", "//services/network/public/cpp/network_types.typemap",
diff --git a/services/viz/privileged/interfaces/compositing/BUILD.gn b/services/viz/privileged/interfaces/compositing/BUILD.gn index 2a43c3c..0ac5848 100644 --- a/services/viz/privileged/interfaces/compositing/BUILD.gn +++ b/services/viz/privileged/interfaces/compositing/BUILD.gn
@@ -33,4 +33,7 @@ if (use_ozone) { enabled_features += [ "use_ozone" ] } + if (use_x11) { + enabled_features += [ "use_x11" ] + } }
diff --git a/services/viz/privileged/interfaces/compositing/display_private.mojom b/services/viz/privileged/interfaces/compositing/display_private.mojom index 77789a5e77..deb327b 100644 --- a/services/viz/privileged/interfaces/compositing/display_private.mojom +++ b/services/viz/privileged/interfaces/compositing/display_private.mojom
@@ -90,6 +90,10 @@ [EnableIf=is_android] DidCompleteSwapWithSize(gfx.mojom.Size size); + // Notifies that a swap has occurred with a new size. + [EnableIf=use_x11] + DidCompleteSwapWithNewSize(gfx.mojom.Size size); + // Notifies that context creation failed. On Android we can't fall back to // SW in these cases, so we need to handle this specifically. [EnableIf=is_android]
diff --git a/services/ws/client_root.cc b/services/ws/client_root.cc index dba4cde..71ae8234 100644 --- a/services/ws/client_root.cc +++ b/services/ws/client_root.cc
@@ -120,14 +120,18 @@ display::Screen::GetScreen()->RemoveObserver(this); viz::HostFrameSinkManager* host_frame_sink_manager = - window_->env()->context_factory_private()->GetHostFrameSinkManager(); + aura::Env::GetInstance() + ->context_factory_private() + ->GetHostFrameSinkManager(); host_frame_sink_manager->InvalidateFrameSinkId(proxy_window->frame_sink_id()); } void ClientRoot::RegisterVizEmbeddingSupport() { // This function should only be called once. viz::HostFrameSinkManager* host_frame_sink_manager = - window_->env()->context_factory_private()->GetHostFrameSinkManager(); + aura::Env::GetInstance() + ->context_factory_private() + ->GetHostFrameSinkManager(); viz::FrameSinkId frame_sink_id = ProxyWindow::GetMayBeNull(window_)->frame_sink_id(); // This code only needs first-surface-activation for tests. @@ -238,7 +242,9 @@ DCHECK(proxy_window->attached_frame_sink_id().is_valid()); DCHECK(ProxyWindow::GetMayBeNull(window_)->frame_sink_id().is_valid()); viz::HostFrameSinkManager* host_frame_sink_manager = - window_->env()->context_factory_private()->GetHostFrameSinkManager(); + aura::Env::GetInstance() + ->context_factory_private() + ->GetHostFrameSinkManager(); const viz::FrameSinkId& frame_sink_id = proxy_window->attached_frame_sink_id(); if (host_frame_sink_manager->IsFrameSinkIdRegistered(frame_sink_id)) { @@ -251,7 +257,9 @@ DCHECK(proxy_window->attached_frame_sink_id().is_valid()); DCHECK(ProxyWindow::GetMayBeNull(window_)->frame_sink_id().is_valid()); viz::HostFrameSinkManager* host_frame_sink_manager = - window_->env()->context_factory_private()->GetHostFrameSinkManager(); + aura::Env::GetInstance() + ->context_factory_private() + ->GetHostFrameSinkManager(); const viz::FrameSinkId& root_frame_sink_id = ProxyWindow::GetMayBeNull(window_)->frame_sink_id(); const viz::FrameSinkId& window_frame_sink_id =
diff --git a/services/ws/injected_event_handler.cc b/services/ws/injected_event_handler.cc index 7bf38646..315e116 100644 --- a/services/ws/injected_event_handler.cc +++ b/services/ws/injected_event_handler.cc
@@ -39,7 +39,7 @@ : window_service_(window_service), window_tree_host_(window_tree_host) { window_service_->AddObserver(this); window_tree_host_->window()->AddObserver(this); - window_tree_host_->window()->env()->AddWindowEventDispatcherObserver(this); + aura::Env::GetInstance()->AddWindowEventDispatcherObserver(this); } InjectedEventHandler::~InjectedEventHandler() { @@ -78,7 +78,7 @@ if (!window_service_) return; - window_tree_host_->window()->env()->RemoveWindowEventDispatcherObserver(this); + aura::Env::GetInstance()->RemoveWindowEventDispatcherObserver(this); window_tree_host_->window()->RemoveObserver(this); window_service_->RemoveObserver(this); window_service_ = nullptr;
diff --git a/services/ws/proxy_window.cc b/services/ws/proxy_window.cc index d9a690e..45b3f8c 100644 --- a/services/ws/proxy_window.cc +++ b/services/ws/proxy_window.cc
@@ -546,7 +546,9 @@ viz::mojom::CompositorFrameSinkClientPtr client) { attached_compositor_frame_sink_ = true; viz::HostFrameSinkManager* host_frame_sink_manager = - window_->env()->context_factory_private()->GetHostFrameSinkManager(); + aura::Env::GetInstance() + ->context_factory_private() + ->GetHostFrameSinkManager(); host_frame_sink_manager->CreateCompositorFrameSink( frame_sink_id_, std::move(compositor_frame_sink), std::move(client)); }
diff --git a/services/ws/topmost_window_observer.cc b/services/ws/topmost_window_observer.cc index 219ee76..aef7dbd 100644 --- a/services/ws/topmost_window_observer.cc +++ b/services/ws/topmost_window_observer.cc
@@ -21,29 +21,27 @@ TopmostWindowObserver::TopmostWindowObserver(WindowTree* window_tree, mojom::MoveLoopSource source, aura::Window* initial_target) - : window_tree_(window_tree), - source_(source), - last_target_(initial_target), - env_(initial_target->env()) { + : window_tree_(window_tree), source_(source), last_target_(initial_target) { std::set<ui::EventType> types; + aura::Env* env = aura::Env::GetInstance(); if (source == mojom::MoveLoopSource::MOUSE) { types.insert(ui::ET_MOUSE_MOVED); types.insert(ui::ET_MOUSE_DRAGGED); - last_location_ = env_->last_mouse_location(); + last_location_ = env->last_mouse_location(); } else { types.insert(ui::ET_TOUCH_MOVED); gfx::PointF point; - ui::GestureRecognizer* gesture_recognizer = env_->gesture_recognizer(); + ui::GestureRecognizer* gesture_recognizer = env->gesture_recognizer(); if (gesture_recognizer->GetLastTouchPointForTarget(last_target_, &point)) last_location_ = gfx::Point(point.x(), point.y()); ::wm::ConvertPointToScreen(last_target_, &last_location_); } - env_->AddEventObserver(this, env_, types); + env->AddEventObserver(this, env, types); UpdateTopmostWindows(); } TopmostWindowObserver::~TopmostWindowObserver() { - env_->RemoveEventObserver(this); + aura::Env::GetInstance()->RemoveEventObserver(this); if (topmost_) topmost_->RemoveObserver(this); if (real_topmost_ && topmost_ != real_topmost_)
diff --git a/services/ws/topmost_window_observer.h b/services/ws/topmost_window_observer.h index 14bc244..19a1497 100644 --- a/services/ws/topmost_window_observer.h +++ b/services/ws/topmost_window_observer.h
@@ -11,7 +11,6 @@ #include "ui/gfx/geometry/point.h" namespace aura { -class Env; class Window; } @@ -72,8 +71,6 @@ // The topmost window (including |last_target_|) under the cursor/touch. aura::Window* real_topmost_ = nullptr; - aura::Env* env_; - DISALLOW_COPY_AND_ASSIGN(TopmostWindowObserver); };
diff --git a/services/ws/window_tree.cc b/services/ws/window_tree.cc index 66979c8..ce77401 100644 --- a/services/ws/window_tree.cc +++ b/services/ws/window_tree.cc
@@ -2183,7 +2183,7 @@ } if (source == mojom::MoveLoopSource::MOUSE && - !window->env()->IsMouseButtonDown()) { + !aura::Env::GetInstance()->IsMouseButtonDown()) { DVLOG(1) << "PerformWindowMove failed (mouse not down)"; window_tree_client_->OnChangeCompleted(change_id, false); return;
diff --git a/services/ws/window_tree_unittest.cc b/services/ws/window_tree_unittest.cc index 359f8d7a4..6dc180e 100644 --- a/services/ws/window_tree_unittest.cc +++ b/services/ws/window_tree_unittest.cc
@@ -2263,7 +2263,9 @@ ASSERT_TRUE(child_window); viz::FrameSinkId test_frame_sink_id(101, 102); viz::HostFrameSinkManager* host_frame_sink_manager = - child_window->env()->context_factory_private()->GetHostFrameSinkManager(); + aura::Env::GetInstance() + ->context_factory_private() + ->GetHostFrameSinkManager(); // Attach a frame sink to |child_window|. This shouldn't immediately register. setup.window_tree_test_helper()->window_tree()->AttachFrameSinkId(
diff --git a/testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java b/testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java index 1d346f6..be2d424 100644 --- a/testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java +++ b/testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java
@@ -12,55 +12,22 @@ import java.io.File; import java.net.MalformedURLException; -import java.util.ArrayList; -import java.util.List; /** * Class that manages passing Android manifest information to Robolectric. */ public class GNManifestFactory implements ManifestFactory { - private static final String CHROMIUM_MANIFEST_PATH = "chromium.robolectric.manifest"; - private static final String CHROMIUM_RES_DIRECTORIES = "chromium.robolectric.resource.dirs"; + private static final String CHROMIUM_RES_APK = "chromium.robolectric.resource.ap_"; @Override public ManifestIdentifier identify(Config config) { - if (config.resourceDir() != null - && !config.resourceDir().equals(Config.DEFAULT_RES_FOLDER)) { - throw new RuntimeException("Resource dirs should be generated automatically by GN. " - + "Make sure you specify the correct app package_name in the GN build file. " - + "Make sure you run the tests using the generated run_<test name> scripts."); + String resourceApk = System.getProperty(CHROMIUM_RES_APK); + + FsFile apkFile = null; + try { + apkFile = Fs.fromURL(new File(resourceApk).toURI().toURL()); + } catch (MalformedURLException e) { } - - if (config.manifest() != null && !config.manifest().equals(Config.NONE)) { - throw new RuntimeException("Specify manifest path in GN build file."); - } - - String manifestPath = System.getProperty(CHROMIUM_MANIFEST_PATH); - String resourceDirs = System.getProperty(CHROMIUM_RES_DIRECTORIES); - - FsFile manifestFile = null; - if (manifestPath != null) { - try { - manifestFile = Fs.fromURL(new File(manifestPath).toURI().toURL()); - } catch (MalformedURLException e) { - } - } - - final List<FsFile> resourceDirsList = new ArrayList<FsFile>(); - if (resourceDirs != null) { - for (String resourceDir : resourceDirs.split(":")) { - try { - resourceDirsList.add(Fs.fromURL(new File(resourceDir).toURI().toURL())); - } catch (MalformedURLException e) { - } - } - } - - List<ManifestIdentifier> libraries = new ArrayList<>(); - for (FsFile resDir : resourceDirsList) { - libraries.add(new ManifestIdentifier(config.packageName(), null, resDir, null, null)); - } - - return new ManifestIdentifier(config.packageName(), manifestFile, null, null, libraries); + return new ManifestIdentifier(config.packageName(), null, null, null, null, apkFile); } }
diff --git a/testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java b/testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java index 6ecb3e7..bd9992e 100644 --- a/testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java +++ b/testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java
@@ -28,12 +28,8 @@ @Override protected Config buildGlobalConfig() { - String packageName = - System.getProperty("chromium.robolectric.package.name", DEFAULT_PACKAGE_NAME); - return new Config.Builder() .setSdk(DEFAULT_SDK) - .setPackageName(packageName) // Shadows to fix robolectric shortcomings. .setShadows(new Class[] {CustomShadowApplicationPackageManager.class}) .build();
diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json index baf5af26..117e24a 100644 --- a/testing/variations/fieldtrial_testing_config.json +++ b/testing/variations/fieldtrial_testing_config.json
@@ -1749,6 +1749,21 @@ ] } ], + "DirectCompositionGpuVSync": [ + { + "platforms": [ + "windows" + ], + "experiments": [ + { + "name": "Enabled", + "enable_features": [ + "DirectCompositionGpuVSync" + ] + } + ] + } + ], "DirectCompositionPreferNV12Overlays": [ { "platforms": [
diff --git a/third_party/blink/public/web/web_view_client.h b/third_party/blink/public/web/web_view_client.h index 3bfbc776..cb8f2c2 100644 --- a/third_party/blink/public/web/web_view_client.h +++ b/third_party/blink/public/web/web_view_client.h
@@ -183,7 +183,8 @@ // Informs the browser that the page scale has changed and/or a pinch gesture // has started or ended. - virtual void PageScaleFactorChanged(float page_scale_factor) {} + virtual void PageScaleFactorChanged(float page_scale_factor, + bool is_pinch_gesture_active) {} // Gestures -------------------------------------------------------------
diff --git a/third_party/blink/public/web/web_widget_client.h b/third_party/blink/public/web/web_widget_client.h index 3118d32..6b92ded 100644 --- a/third_party/blink/public/web/web_widget_client.h +++ b/third_party/blink/public/web/web_widget_client.h
@@ -245,10 +245,9 @@ // Sets the current page scale factor and minimum / maximum limits. Both // limits are initially 1 (no page scale allowed). - virtual void SetPageScaleStateAndLimits(float page_scale_factor, - bool is_pinch_gesture_active, - float minimum, - float maximum) {} + virtual void SetPageScaleFactorAndLimits(float page_scale_factor, + float minimum, + float maximum) {} // Starts an animation of the page scale to a target scale factor and scroll // offset.
diff --git a/third_party/blink/renderer/core/accessibility/apply_dark_mode.cc b/third_party/blink/renderer/core/accessibility/apply_dark_mode.cc index 7ab0c06..bde3c0b1 100644 --- a/third_party/blink/renderer/core/accessibility/apply_dark_mode.cc +++ b/third_party/blink/renderer/core/accessibility/apply_dark_mode.cc
@@ -54,6 +54,7 @@ dark_mode_settings.grayscale = frame_settings.GetDarkModeGrayscale(); dark_mode_settings.contrast = frame_settings.GetDarkModeContrast(); dark_mode_settings.image_policy = frame_settings.GetDarkModeImagePolicy(); + dark_mode_settings.text_policy = frame_settings.GetDarkModeTextPolicy(); dark_mode_settings.image_grayscale_percent = frame_settings.GetDarkModeImageGrayscale(); return dark_mode_settings;
diff --git a/third_party/blink/renderer/core/clipboard/data_transfer.cc b/third_party/blink/renderer/core/clipboard/data_transfer.cc index e135a2d6..c83f49dbc 100644 --- a/third_party/blink/renderer/core/clipboard/data_transfer.cc +++ b/third_party/blink/renderer/core/clipboard/data_transfer.cc
@@ -124,7 +124,7 @@ .BoundingBox(); PaintLayerPaintingInfo painting_info( layer, CullRect(EnclosingIntRect(bounding_box)), - kGlobalPaintFlattenCompositingLayers, LayoutSize()); + kGlobalPaintFlattenCompositingLayers, PhysicalOffset()); PaintLayerFlags flags = kPaintLayerHaveTransparency | kPaintLayerUncachedClipRects; PaintRecordBuilder builder;
diff --git a/third_party/blink/renderer/core/dom/layout_tree_builder.h b/third_party/blink/renderer/core/dom/layout_tree_builder.h index 135ecf94..f3f1bf9 100644 --- a/third_party/blink/renderer/core/dom/layout_tree_builder.h +++ b/third_party/blink/renderer/core/dom/layout_tree_builder.h
@@ -84,8 +84,7 @@ // AddChild() implementations to walk up the tree to find the correct // layout tree parent/siblings. if (next && next->IsText() && next->Parent()->IsAnonymous() && - next->Parent()->IsInline() && - !ToLayoutInline(next->Parent())->IsFirstLineAnonymous()) { + next->Parent()->IsInline()) { return next->Parent(); } return next;
diff --git a/third_party/blink/renderer/core/editing/caret_display_item_client.cc b/third_party/blink/renderer/core/editing/caret_display_item_client.cc index f4d611c..fd39799 100644 --- a/third_party/blink/renderer/core/editing/caret_display_item_client.cc +++ b/third_party/blink/renderer/core/editing/caret_display_item_client.cc
@@ -257,14 +257,14 @@ void CaretDisplayItemClient::PaintCaret( GraphicsContext& context, - const LayoutPoint& paint_offset, + const PhysicalOffset& paint_offset, DisplayItem::Type display_item_type) const { if (DrawingRecorder::UseCachedDrawingIfPossible(context, *this, display_item_type)) return; - auto drawing_rect = local_rect_.ToLayoutRect(); - drawing_rect.MoveBy(paint_offset); + PhysicalRect drawing_rect = local_rect_; + drawing_rect.Move(paint_offset); DrawingRecorder recorder(context, *this, display_item_type); IntRect paint_rect = PixelSnappedIntRect(drawing_rect);
diff --git a/third_party/blink/renderer/core/editing/caret_display_item_client.h b/third_party/blink/renderer/core/editing/caret_display_item_client.h index e1f0e753..bd2400b2 100644 --- a/third_party/blink/renderer/core/editing/caret_display_item_client.h +++ b/third_party/blink/renderer/core/editing/caret_display_item_client.h
@@ -63,7 +63,7 @@ return &block == layout_block_; } void PaintCaret(GraphicsContext&, - const LayoutPoint& paint_offset, + const PhysicalOffset& paint_offset, DisplayItem::Type) const; // DisplayItemClient methods.
diff --git a/third_party/blink/renderer/core/editing/drag_caret.cc b/third_party/blink/renderer/core/editing/drag_caret.cc index 07933b4..de2bf34 100644 --- a/third_party/blink/renderer/core/editing/drag_caret.cc +++ b/third_party/blink/renderer/core/editing/drag_caret.cc
@@ -103,7 +103,7 @@ void DragCaret::PaintDragCaret(const LocalFrame* frame, GraphicsContext& context, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { if (position_.AnchorNode()->GetDocument().GetFrame() != frame) return; display_item_client_->PaintCaret(context, paint_offset,
diff --git a/third_party/blink/renderer/core/editing/drag_caret.h b/third_party/blink/renderer/core/editing/drag_caret.h index 4d2bdb98..f49b242 100644 --- a/third_party/blink/renderer/core/editing/drag_caret.h +++ b/third_party/blink/renderer/core/editing/drag_caret.h
@@ -57,7 +57,7 @@ bool ShouldPaintCaret(const LayoutBlock&) const; void PaintDragCaret(const LocalFrame*, GraphicsContext&, - const LayoutPoint&) const; + const PhysicalOffset&) const; bool IsContentRichlyEditable() const;
diff --git a/third_party/blink/renderer/core/editing/frame_caret.cc b/third_party/blink/renderer/core/editing/frame_caret.cc index e72679e7..b078ed88 100644 --- a/third_party/blink/renderer/core/editing/frame_caret.cc +++ b/third_party/blink/renderer/core/editing/frame_caret.cc
@@ -182,7 +182,7 @@ } void FrameCaret::PaintCaret(GraphicsContext& context, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { display_item_client_->PaintCaret(context, paint_offset, DisplayItem::kCaret); }
diff --git a/third_party/blink/renderer/core/editing/frame_caret.h b/third_party/blink/renderer/core/editing/frame_caret.h index f07b800..c7ee700 100644 --- a/third_party/blink/renderer/core/editing/frame_caret.h +++ b/third_party/blink/renderer/core/editing/frame_caret.h
@@ -46,6 +46,7 @@ class LocalFrame; class SelectionEditor; struct PaintInvalidatorContext; +struct PhysicalOffset; enum class CaretVisibility { kVisible, kHidden }; @@ -80,7 +81,7 @@ void InvalidatePaint(const LayoutBlock&, const PaintInvalidatorContext&); bool ShouldPaintCaret(const LayoutBlock&) const; - void PaintCaret(GraphicsContext&, const LayoutPoint&) const; + void PaintCaret(GraphicsContext&, const PhysicalOffset&) const; // For unit tests. const DisplayItemClient& CaretDisplayItemClientForTesting() const;
diff --git a/third_party/blink/renderer/core/editing/frame_selection.cc b/third_party/blink/renderer/core/editing/frame_selection.cc index 8b768a4..f78ea42 100644 --- a/third_party/blink/renderer/core/editing/frame_selection.cc +++ b/third_party/blink/renderer/core/editing/frame_selection.cc
@@ -564,7 +564,7 @@ } void FrameSelection::PaintCaret(GraphicsContext& context, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { frame_caret_->PaintCaret(context, paint_offset); }
diff --git a/third_party/blink/renderer/core/editing/frame_selection.h b/third_party/blink/renderer/core/editing/frame_selection.h index 6dc0e1cf..bfaba5d4 100644 --- a/third_party/blink/renderer/core/editing/frame_selection.h +++ b/third_party/blink/renderer/core/editing/frame_selection.h
@@ -59,6 +59,7 @@ enum class SelectionState; class TextIteratorBehavior; struct PaintInvalidatorContext; +struct PhysicalOffset; enum RevealExtentOption { kRevealExtent, kDoNotRevealExtent }; @@ -220,7 +221,7 @@ void UpdateStyleAndLayoutIfNeeded(); void InvalidatePaint(const LayoutBlock&, const PaintInvalidatorContext&); - void PaintCaret(GraphicsContext&, const LayoutPoint&); + void PaintCaret(GraphicsContext&, const PhysicalOffset&); // Used to suspend caret blinking while the mouse is down. void SetCaretBlinkingSuspended(bool);
diff --git a/third_party/blink/renderer/core/editing/frame_selection_test.cc b/third_party/blink/renderer/core/editing/frame_selection_test.cc index 24cf1038..444efad 100644 --- a/third_party/blink/renderer/core/editing/frame_selection_test.cc +++ b/third_party/blink/renderer/core/editing/frame_selection_test.cc
@@ -147,7 +147,7 @@ GraphicsContext context(*paint_controller); paint_controller->UpdateCurrentPaintChunkProperties( root_paint_chunk_id_, PropertyTreeState::Root()); - Selection().PaintCaret(context, LayoutPoint()); + Selection().PaintCaret(context, PhysicalOffset()); } paint_controller->CommitNewDisplayItems(); EXPECT_EQ(start_count, LayoutCount());
diff --git a/third_party/blink/renderer/core/events/mouse_event.cc b/third_party/blink/renderer/core/events/mouse_event.cc index a074002e5..24cb5ff 100644 --- a/third_party/blink/renderer/core/events/mouse_event.cc +++ b/third_party/blink/renderer/core/events/mouse_event.cc
@@ -518,8 +518,8 @@ // FIXME: Does this differ from PaintLayer::ConvertToLayerCoords? for (PaintLayer* layer = n->GetLayoutObject()->EnclosingLayer(); layer; layer = layer->ContainingLayer()) { - layer_location_ -= DoubleSize(layer->Location().X().ToDouble(), - layer->Location().Y().ToDouble()); + layer_location_ -= DoubleSize(layer->Location().left.ToDouble(), + layer->Location().top.ToDouble()); } if (inverse_zoom_factor != 1.0f) layer_location_.Scale(inverse_zoom_factor, inverse_zoom_factor);
diff --git a/third_party/blink/renderer/core/exported/web_plugin_container_impl.cc b/third_party/blink/renderer/core/exported/web_plugin_container_impl.cc index 9b765109..7f098e19 100644 --- a/third_party/blink/renderer/core/exported/web_plugin_container_impl.cc +++ b/third_party/blink/renderer/core/exported/web_plugin_container_impl.cc
@@ -202,7 +202,7 @@ (layout_object->BorderLeft() + layout_object->PaddingLeft()).ToInt(), (layout_object->BorderTop() + layout_object->PaddingTop()).ToInt()); - layout_object->InvalidatePaintRectangle(LayoutRect(dirty_rect)); + layout_object->InvalidatePaintRectangle(PhysicalRect(dirty_rect)); } void WebPluginContainerImpl::SetFocused(bool focused, WebFocusType focus_type) {
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc index 0203d2a..d4abf56 100644 --- a/third_party/blink/renderer/core/exported/web_view_impl.cc +++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
@@ -2023,10 +2023,8 @@ if (does_composite_) { // When attaching a local main frame, set up any state on the compositor. AsWidget().client->SetBackgroundColor(BackgroundColor()); - auto& viewport = GetPage()->GetVisualViewport(); - AsWidget().client->SetPageScaleStateAndLimits( - viewport.Scale(), viewport.IsPinchGestureActive(), - MinimumPageScaleFactor(), MaximumPageScaleFactor()); + AsWidget().client->SetPageScaleFactorAndLimits( + PageScaleFactor(), MinimumPageScaleFactor(), MaximumPageScaleFactor()); } } @@ -2569,10 +2567,8 @@ // so we must update those even though SetPageScaleFactor() may do the same if // the scale factor is changed. if (does_composite_) { - auto& viewport = GetPage()->GetVisualViewport(); - AsWidget().client->SetPageScaleStateAndLimits( - viewport.Scale(), viewport.IsPinchGestureActive(), - MinimumPageScaleFactor(), MaximumPageScaleFactor()); + AsWidget().client->SetPageScaleFactorAndLimits( + PageScaleFactor(), MinimumPageScaleFactor(), MaximumPageScaleFactor()); } } @@ -2826,10 +2822,8 @@ // A resized main frame can change the page scale limits. if (does_composite_) { - auto& viewport = GetPage()->GetVisualViewport(); - AsWidget().client->SetPageScaleStateAndLimits( - viewport.Scale(), viewport.IsPinchGestureActive(), - MinimumPageScaleFactor(), MaximumPageScaleFactor()); + AsWidget().client->SetPageScaleFactorAndLimits( + PageScaleFactor(), MinimumPageScaleFactor(), MaximumPageScaleFactor()); } } @@ -3096,13 +3090,14 @@ DCHECK(does_composite_); GetPageScaleConstraintsSet().SetNeedsReset(false); - // Set up the compositor and inform the browser of the PageScaleFactor, - // which is tracked per-view. + // Set up the compositor. + AsWidget().client->SetPageScaleFactorAndLimits( + PageScaleFactor(), MinimumPageScaleFactor(), MaximumPageScaleFactor()); + // Also inform the browser of the PageScaleFactor, which is tracked + // per-view. auto& viewport = GetPage()->GetVisualViewport(); - AsWidget().client->SetPageScaleStateAndLimits( - viewport.Scale(), viewport.IsPinchGestureActive(), - MinimumPageScaleFactor(), MaximumPageScaleFactor()); - AsView().client->PageScaleFactorChanged(viewport.Scale()); + AsView().client->PageScaleFactorChanged(viewport.Scale(), + viewport.IsPinchGestureActive()); dev_tools_emulator_->MainFrameScrollOrScaleChanged(); }
diff --git a/third_party/blink/renderer/core/exported/web_view_test.cc b/third_party/blink/renderer/core/exported/web_view_test.cc index a90d95be..2d6f6fd 100644 --- a/third_party/blink/renderer/core/exported/web_view_test.cc +++ b/third_party/blink/renderer/core/exported/web_view_test.cc
@@ -531,8 +531,8 @@ LocalFrameView* view = web_view_helper_.LocalMainFrame()->GetFrameView(); PaintLayer* root_layer = view->GetLayoutView()->Layer(); CullRect paint_rect(IntRect(0, 0, kWidth, kHeight)); - PaintLayerPaintingInfo painting_info(root_layer, paint_rect, - kGlobalPaintNormalPhase, LayoutSize()); + PaintLayerPaintingInfo painting_info( + root_layer, paint_rect, kGlobalPaintNormalPhase, PhysicalOffset()); view->GetLayoutView()->GetDocument().Lifecycle().AdvanceTo( DocumentLifecycle::kInPaint);
diff --git a/third_party/blink/renderer/core/frame/deprecation.h b/third_party/blink/renderer/core/frame/deprecation.h index 7c43e29..560a44c 100644 --- a/third_party/blink/renderer/core/frame/deprecation.h +++ b/third_party/blink/renderer/core/frame/deprecation.h
@@ -19,7 +19,7 @@ class DocumentLoader; class LocalFrame; -class CORE_EXPORT Deprecation { +class CORE_EXPORT Deprecation final { DISALLOW_NEW(); public: @@ -52,7 +52,7 @@ // Note: this is only public for tests. bool IsSuppressed(CSSPropertyID unresolved_property); - protected: + private: void Suppress(CSSPropertyID unresolved_property); void SetReported(WebFeature feature); bool GetReported(WebFeature feature) const;
diff --git a/third_party/blink/renderer/core/frame/frame_test_helpers.cc b/third_party/blink/renderer/core/frame/frame_test_helpers.cc index 0178359..91f49117 100644 --- a/third_party/blink/renderer/core/frame/frame_test_helpers.cc +++ b/third_party/blink/renderer/core/frame/frame_test_helpers.cc
@@ -641,11 +641,9 @@ layer_tree_host()->SetHasGpuRasterizationTrigger(allow); } -void TestWebWidgetClient::SetPageScaleStateAndLimits( - float page_scale_factor, - bool is_pinch_gesture_active, - float minimum, - float maximum) { +void TestWebWidgetClient::SetPageScaleFactorAndLimits(float page_scale_factor, + float minimum, + float maximum) { layer_tree_host()->SetPageScaleFactorAndLimits(page_scale_factor, minimum, maximum); }
diff --git a/third_party/blink/renderer/core/frame/frame_test_helpers.h b/third_party/blink/renderer/core/frame/frame_test_helpers.h index 07482cf..5cc66d2 100644 --- a/third_party/blink/renderer/core/frame/frame_test_helpers.h +++ b/third_party/blink/renderer/core/frame/frame_test_helpers.h
@@ -205,10 +205,9 @@ void RegisterSelection(const cc::LayerSelection& selection) override; void SetBackgroundColor(SkColor color) override; void SetAllowGpuRasterization(bool allow) override; - void SetPageScaleStateAndLimits(float page_scale_factor, - bool is_pinch_gesture_active, - float minimum, - float maximum) override; + void SetPageScaleFactorAndLimits(float page_scale_factor, + float minimum, + float maximum) override; content::LayerTreeView* layer_tree_view() { return layer_tree_view_; } cc::LayerTreeHost* layer_tree_host() {
diff --git a/third_party/blink/renderer/core/frame/local_frame_ukm_aggregator.cc b/third_party/blink/renderer/core/frame/local_frame_ukm_aggregator.cc index 9843f8c6..0cacf6a 100644 --- a/third_party/blink/renderer/core/frame/local_frame_ukm_aggregator.cc +++ b/third_party/blink/renderer/core/frame/local_frame_ukm_aggregator.cc
@@ -139,8 +139,14 @@ auto& record = absolute_metric_records_[metric_index]; record.interval_duration += duration; // Record the UMA - if (record.uma_counter) + // ForcedStyleAndLayout happen so frequently on some pages that we overflow + // the signed 32 counter for number of events in a 30 minute period. So + // randomly record with probability 1/100. + if (record.uma_counter && + (metric_index != static_cast<MetricId>(kForcedStyleAndLayout) || + base::RandInt(0, 99) == 0)) { record.uma_counter->CountMicroseconds(duration); + } // Only record ratios when inside a main frame. if (in_main_frame_update_) {
diff --git a/third_party/blink/renderer/core/frame/local_frame_view.cc b/third_party/blink/renderer/core/frame/local_frame_view.cc index 6daea19..99bee766 100644 --- a/third_party/blink/renderer/core/frame/local_frame_view.cc +++ b/third_party/blink/renderer/core/frame/local_frame_view.cc
@@ -53,7 +53,6 @@ #include "third_party/blink/renderer/core/events/error_event.h" #include "third_party/blink/renderer/core/exported/web_plugin_container_impl.h" #include "third_party/blink/renderer/core/frame/browser_controls.h" -#include "third_party/blink/renderer/core/frame/event_handler_registry.h" #include "third_party/blink/renderer/core/frame/find_in_page.h" #include "third_party/blink/renderer/core/frame/frame_overlay.h" #include "third_party/blink/renderer/core/frame/frame_view_auto_size_info.h" @@ -442,7 +441,8 @@ paint_invalidation_rect.Move( (layout_object->BorderLeft() + layout_object->PaddingLeft()).ToInt(), (layout_object->BorderTop() + layout_object->PaddingTop()).ToInt()); - layout_object->InvalidatePaintRectangle(LayoutRect(paint_invalidation_rect)); + layout_object->InvalidatePaintRectangle( + PhysicalRect(paint_invalidation_rect)); } void LocalFrameView::FrameRectsChanged(const IntRect& old_rect) { @@ -1069,7 +1069,7 @@ bool did_need_layout = NeedsLayout(); PhysicalRect new_frame = layout->ReplacedContentRect(); - DCHECK_EQ(new_frame.size, PhysicalSize(RoundedIntSize(new_frame.size))); + DCHECK(!new_frame.size.HasFraction()); bool bounds_will_change = PhysicalSize(Size()) != new_frame.size; // If frame bounds are changing mark the view for layout. Also check the @@ -4020,11 +4020,10 @@ if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) GraphicsLayersDidChange(); - ScrollingCoordinator* scrolling_coordinator = this->GetScrollingCoordinator(); if (!CanThrottleRendering()) { // ScrollingCoordinator needs to update according to the new throttling // status. - if (scrolling_coordinator) + if (auto* scrolling_coordinator = GetScrollingCoordinator()) scrolling_coordinator->NotifyGeometryChanged(this); // Start ticking animation frames again if necessary. if (GetPage()) @@ -4042,20 +4041,6 @@ } } - if (scrolling_coordinator) { - EventHandlerRegistry& registry = frame_->GetEventHandlerRegistry(); - bool has_handlers = - (registry.HasEventHandlers(EventHandlerRegistry::kTouchAction) || - registry.HasEventHandlers( - EventHandlerRegistry::kTouchStartOrMoveEventBlocking) || - registry.HasEventHandlers( - EventHandlerRegistry::kTouchStartOrMoveEventBlockingLowLatency)); - if (has_handlers) { - scrolling_coordinator->TouchEventTargetRectsDidChange( - &GetFrame().LocalFrameRoot()); - } - } - if (FrameScheduler* frame_scheduler = frame_->GetFrameScheduler()) { frame_scheduler->SetFrameVisible(!IsHiddenForThrottling()); frame_scheduler->SetCrossOrigin(frame_->IsCrossOriginSubframe());
diff --git a/third_party/blink/renderer/core/frame/remote_frame_view.cc b/third_party/blink/renderer/core/frame/remote_frame_view.cc index 04bf31a..eae54cf 100644 --- a/third_party/blink/renderer/core/frame/remote_frame_view.cc +++ b/third_party/blink/renderer/core/frame/remote_frame_view.cc
@@ -178,9 +178,9 @@ if (!object) return; - LayoutRect repaint_rect(rect); - repaint_rect.Move(object->BorderLeft() + object->PaddingLeft(), - object->BorderTop() + object->PaddingTop()); + PhysicalRect repaint_rect(rect); + repaint_rect.Move(PhysicalOffset(object->BorderLeft() + object->PaddingLeft(), + object->BorderTop() + object->PaddingTop())); object->InvalidatePaintRectangle(repaint_rect); }
diff --git a/third_party/blink/renderer/core/frame/settings.json5 b/third_party/blink/renderer/core/frame/settings.json5 index b0484ec..90b072c 100644 --- a/third_party/blink/renderer/core/frame/settings.json5 +++ b/third_party/blink/renderer/core/frame/settings.json5
@@ -913,6 +913,12 @@ invalidate: "Paint", }, { + name: "darkModeTextPolicy", + initial: "DarkModeTextPolicy::kInvertAll", + type: "DarkModeTextPolicy", + invalidate: "Paint", + }, + { name: "darkModeImageGrayscale", initial: "0.0", type: "float",
diff --git a/third_party/blink/renderer/core/frame/visual_viewport.cc b/third_party/blink/renderer/core/frame/visual_viewport.cc index 85c3d1e..ab9f8af5 100644 --- a/third_party/blink/renderer/core/frame/visual_viewport.cc +++ b/third_party/blink/renderer/core/frame/visual_viewport.cc
@@ -552,13 +552,17 @@ // SVG runs with accelerated compositing disabled so no // ScrollingCoordinator. - // TODO(bokan): This can go away with BGPT because it's used only to - // propagate scroll offsets to the cc::Layers. In BGPT, scroll offsets are - // set directly on the TransformPaintPropertyNodes so this becomes a no-op. - if (!RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) { - if (ScrollingCoordinator* coordinator = - GetPage().GetScrollingCoordinator()) + if (ScrollingCoordinator* coordinator = + GetPage().GetScrollingCoordinator()) { + // In BGPT, scroll offsets and related properties are set directly on the + // property trees so all we need to do is update the scroll offset on the + // corresponding cc::Layer. Pre-BGPT we used ScrollLayerDidChange but + // since all we need this for is to update the cc::Layer's offset, we now + // use the more purpose-built UpdateCompositedScrollOffset, as in PLSA. + if (!RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) coordinator->ScrollableAreaScrollLayerDidChange(this); + else + coordinator->UpdateCompositedScrollOffset(this); } EnqueueScrollEvent();
diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc b/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc index d8a9895..ec350a64 100644 --- a/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc +++ b/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc
@@ -228,9 +228,9 @@ // TODO(wjmaclean): This is updating when the size of the *child frame* // have changed which are completely independent of the WebView, and in an // OOPIF where the main frame is remote, are these limits even useful? - Client()->SetPageScaleStateAndLimits( - 1.f, false /* is_pinch_gesture_active */, - View()->MinimumPageScaleFactor(), View()->MaximumPageScaleFactor()); + Client()->SetPageScaleFactorAndLimits(1.f, + View()->MinimumPageScaleFactor(), + View()->MaximumPageScaleFactor()); } } } @@ -1037,9 +1037,8 @@ Client()->SetBackgroundColor(SK_ColorTRANSPARENT); // Pass the limits even though this is for subframes, as the limits will // be needed in setting the raster scale. - Client()->SetPageScaleStateAndLimits(1.f, false /* is_pinch_gesture_active */, - View()->MinimumPageScaleFactor(), - View()->MaximumPageScaleFactor()); + Client()->SetPageScaleFactorAndLimits(1.f, View()->MinimumPageScaleFactor(), + View()->MaximumPageScaleFactor()); // TODO(kenrb): Currently GPU rasterization is always enabled for OOPIFs. // This is okay because it is only necessarily to set the trigger to false
diff --git a/third_party/blink/renderer/core/html/anchor_element_metrics.cc b/third_party/blink/renderer/core/html/anchor_element_metrics.cc index 4624e5d6..51acc5b 100644 --- a/third_party/blink/renderer/core/html/anchor_element_metrics.cc +++ b/third_party/blink/renderer/core/html/anchor_element_metrics.cc
@@ -128,9 +128,8 @@ // Returns the bounding box rect of a layout object, including visual // overflows. IntRect AbsoluteElementBoundingBoxRect(const LayoutObject* layout_object) { - Vector<LayoutRect> rects; - layout_object->AddOutlineRects(rects, LayoutPoint(), - NGOutlineType::kIncludeBlockVisualOverflow); + Vector<PhysicalRect> rects = layout_object->OutlineRects( + PhysicalOffset(), NGOutlineType::kIncludeBlockVisualOverflow); return layout_object ->LocalToAbsoluteQuad(FloatQuad(FloatRect(UnionRect(rects)))) .EnclosingBoundingBox();
diff --git a/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc b/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc index 439af3e7..8a1fbec 100644 --- a/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc +++ b/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc
@@ -550,7 +550,7 @@ } dirty_rect_.Intersect(src_rect); - LayoutRect mapped_dirty_rect( + PhysicalRect mapped_dirty_rect( EnclosingIntRect(MapRect(dirty_rect_, src_rect, content_rect))); // For querying PaintLayer::GetCompositingState() // FIXME: is this invalidation using the correct compositing state? @@ -693,7 +693,7 @@ // In some instances we don't actually want to paint to the parent layer // We still might want to set filter quality and MarkFirstContentfulPaint though void HTMLCanvasElement::Paint(GraphicsContext& context, - const LayoutRect& r, + const PhysicalRect& r, bool flatten_composited_layers) { if (context_creation_was_blocked_ || (context_ && context_->isContextLost())) { @@ -708,7 +708,7 @@ // for image elements. Offset it a bit from the upper corner. FloatSize icon_size(broken_canvas->Size()); FloatPoint upper_left = - FloatPoint(r.PixelSnappedLocation()) + icon_size.ScaledBy(0.5f); + FloatPoint(r.PixelSnappedOffset()) + icon_size.ScaledBy(0.5f); context.DrawImage(broken_canvas, Image::kSyncDecode, FloatRect(upper_left, icon_size)); context.Restore(); @@ -748,7 +748,7 @@ } void HTMLCanvasElement::PaintInternal(GraphicsContext& context, - const LayoutRect& r) { + const PhysicalRect& r) { context_->PaintRenderingResultsToCanvas(kFrontBuffer); if (HasResourceProvider()) { if (!context.ContextDisabled()) {
diff --git a/third_party/blink/renderer/core/html/canvas/html_canvas_element.h b/third_party/blink/renderer/core/html/canvas/html_canvas_element.h index 3bfbd2e..23ab41c 100644 --- a/third_party/blink/renderer/core/html/canvas/html_canvas_element.h +++ b/third_party/blink/renderer/core/html/canvas/html_canvas_element.h
@@ -156,7 +156,7 @@ void DidDraw() override; void Paint(GraphicsContext&, - const LayoutRect&, + const PhysicalRect&, bool flatten_composited_layers); void DisableDeferral(DisableDeferralReason); @@ -321,7 +321,7 @@ private: void Dispose(); - void PaintInternal(GraphicsContext&, const LayoutRect&); + void PaintInternal(GraphicsContext&, const PhysicalRect&); using ContextFactoryVector = Vector<std::unique_ptr<CanvasRenderingContextFactory>>;
diff --git a/third_party/blink/renderer/core/html/portal/html_portal_element.cc b/third_party/blink/renderer/core/html/portal/html_portal_element.cc index 8b56786..3711241 100644 --- a/third_party/blink/renderer/core/html/portal/html_portal_element.cc +++ b/third_party/blink/renderer/core/html/portal/html_portal_element.cc
@@ -67,9 +67,18 @@ void HTMLPortalElement::Navigate() { KURL url = GetNonEmptyURLAttribute(html_names::kSrcAttr); - if (!url.IsEmpty() && portal_ptr_) { - portal_ptr_->Navigate(url); + if (!portal_ptr_ || url.IsEmpty()) + return; + + if (!url.ProtocolIsInHTTPFamily()) { + GetDocument().AddConsoleMessage(ConsoleMessage::Create( + mojom::ConsoleMessageSource::kRendering, + mojom::ConsoleMessageLevel::kWarning, + "Portals only allow navigation to protocols in the HTTP family.")); + return; } + + portal_ptr_->Navigate(url); } void HTMLPortalElement::ConsumePortal() {
diff --git a/third_party/blink/renderer/core/input/scroll_manager.cc b/third_party/blink/renderer/core/input/scroll_manager.cc index b7b861e..ad72acd8 100644 --- a/third_party/blink/renderer/core/input/scroll_manager.cc +++ b/third_party/blink/renderer/core/input/scroll_manager.cc
@@ -381,8 +381,9 @@ if (!scrollable_area || !scrollable_area->ScrollsOverflow()) continue; - DCHECK(!scrollable_area->UsesCompositedScrolling() || - !scrollable_area->GetNonCompositedMainThreadScrollingReasons()); + // TODO(bokan): This DCHECK is occasionally tripped. See crbug.com/944706. + // DCHECK(!scrollable_area->UsesCompositedScrolling() || + // !scrollable_area->GetNonCompositedMainThreadScrollingReasons()); *non_composited_main_thread_scrolling_reasons |= scrollable_area->GetNonCompositedMainThreadScrollingReasons(); }
diff --git a/third_party/blink/renderer/core/layout/geometry/physical_offset.h b/third_party/blink/renderer/core/layout/geometry/physical_offset.h index a67124b..ef88130 100644 --- a/third_party/blink/renderer/core/layout/geometry/physical_offset.h +++ b/third_party/blink/renderer/core/layout/geometry/physical_offset.h
@@ -43,7 +43,10 @@ PhysicalSize outer_size, PhysicalSize inner_size) const; - bool IsZero() const { return !left && !top; } + constexpr bool IsZero() const { return !left && !top; } + constexpr bool HasFraction() const { + return left.HasFraction() || top.HasFraction(); + } PhysicalOffset operator+(const PhysicalOffset& other) const { return PhysicalOffset{this->left + other.left, this->top + other.top};
diff --git a/third_party/blink/renderer/core/layout/geometry/physical_rect.cc b/third_party/blink/renderer/core/layout/geometry/physical_rect.cc index 93e73f8..1dee4cc 100644 --- a/third_party/blink/renderer/core/layout/geometry/physical_rect.cc +++ b/third_party/blink/renderer/core/layout/geometry/physical_rect.cc
@@ -144,6 +144,18 @@ return result; } +PhysicalRect UnionRectEvenIfEmpty(const Vector<PhysicalRect>& rects) { + wtf_size_t count = rects.size(); + if (!count) + return PhysicalRect(); + + PhysicalRect result = rects[0]; + for (wtf_size_t i = 1; i < count; ++i) + result.UniteEvenIfEmpty(rects[i]); + + return result; +} + std::ostream& operator<<(std::ostream& os, const PhysicalRect& value) { return os << value.ToString(); }
diff --git a/third_party/blink/renderer/core/layout/geometry/physical_rect.h b/third_party/blink/renderer/core/layout/geometry/physical_rect.h index 0e62f18..a5476da 100644 --- a/third_party/blink/renderer/core/layout/geometry/physical_rect.h +++ b/third_party/blink/renderer/core/layout/geometry/physical_rect.h
@@ -132,6 +132,25 @@ void Move(const PhysicalOffset& o) { offset += o; } + void ShiftLeftEdgeTo(LayoutUnit edge) { + LayoutUnit delta = edge - X(); + SetX(edge); + SetWidth((Width() - delta).ClampNegativeToZero()); + } + void ShiftRightEdgeTo(LayoutUnit edge) { + LayoutUnit delta = edge - Right(); + SetWidth((Width() + delta).ClampNegativeToZero()); + } + void ShiftTopEdgeTo(LayoutUnit edge) { + LayoutUnit delta = edge - Y(); + SetY(edge); + SetHeight((Height() - delta).ClampNegativeToZero()); + } + void ShiftBottomEdgeTo(LayoutUnit edge) { + LayoutUnit delta = edge - Bottom(); + SetHeight((Height() + delta).ClampNegativeToZero()); + } + // TODO(crbug.com/962299): These functions should upgraded to force correct // pixel snapping in a type-safe way. IntPoint PixelSnappedOffset() const { return RoundedIntPoint(offset); } @@ -210,6 +229,8 @@ } CORE_EXPORT PhysicalRect UnionRect(const Vector<PhysicalRect>& rects); +CORE_EXPORT PhysicalRect +UnionRectEvenIfEmpty(const Vector<PhysicalRect>& rects); CORE_EXPORT std::ostream& operator<<(std::ostream&, const PhysicalRect&); CORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, const PhysicalRect&);
diff --git a/third_party/blink/renderer/core/layout/geometry/physical_size.h b/third_party/blink/renderer/core/layout/geometry/physical_size.h index c067a434..427e026 100644 --- a/third_party/blink/renderer/core/layout/geometry/physical_size.h +++ b/third_party/blink/renderer/core/layout/geometry/physical_size.h
@@ -68,6 +68,9 @@ constexpr bool IsZero() const { return width == LayoutUnit() && height == LayoutUnit(); } + constexpr bool HasFraction() const { + return width.HasFraction() || height.HasFraction(); + } void Scale(float s) { width *= s;
diff --git a/third_party/blink/renderer/core/layout/layout_block.cc b/third_party/blink/renderer/core/layout/layout_block.cc index b0ad90c4..d11613a 100644 --- a/third_party/blink/renderer/core/layout/layout_block.cc +++ b/third_party/blink/renderer/core/layout/layout_block.cc
@@ -304,9 +304,7 @@ // If the requested insertion point is not one of our children, then this is // because there is an anonymous container within this object that contains // the beforeDescendant. - if (before_descendant_container->IsAnonymousBlock() || - (before_descendant_container->IsLayoutInline() && - ToLayoutInline(before_descendant_container)->IsFirstLineAnonymous())) { + if (before_descendant_container->IsAnonymousBlock()) { // Insert the child into the anonymous block box instead of here. if (new_child->IsInline() || (new_child->IsFloatingOrOutOfFlowPositioned() && @@ -948,12 +946,12 @@ } void LayoutBlock::PaintChildren(const PaintInfo& paint_info, - const LayoutPoint&) const { + const PhysicalOffset&) const { BlockPainter(*this).PaintChildren(paint_info); } void LayoutBlock::PaintObject(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { BlockPainter(*this).PaintObject(paint_info, paint_offset); } @@ -1971,11 +1969,11 @@ return caret_rect; } -void LayoutBlock::AddOutlineRects(Vector<LayoutRect>& rects, - const LayoutPoint& additional_offset, +void LayoutBlock::AddOutlineRects(Vector<PhysicalRect>& rects, + const PhysicalOffset& additional_offset, NGOutlineType include_block_overflows) const { if (!IsAnonymous()) // For anonymous blocks, the children add outline rects. - rects.push_back(LayoutRect(additional_offset, Size())); + rects.emplace_back(additional_offset, Size()); if (include_block_overflows == NGOutlineType::kIncludeBlockVisualOverflow && !HasOverflowClip() && !HasControlClip()) {
diff --git a/third_party/blink/renderer/core/layout/layout_block.h b/third_party/blink/renderer/core/layout/layout_block.h index de7529f..d1081896 100644 --- a/third_party/blink/renderer/core/layout/layout_block.h +++ b/third_party/blink/renderer/core/layout/layout_block.h
@@ -392,9 +392,9 @@ public: void Paint(const PaintInfo&) const override; virtual void PaintObject(const PaintInfo&, - const LayoutPoint& paint_offset) const; + const PhysicalOffset& paint_offset) const; virtual void PaintChildren(const PaintInfo&, - const LayoutPoint& paint_offset) const; + const PhysicalOffset& paint_offset) const; void UpdateAfterLayout() override; protected: @@ -461,8 +461,8 @@ virtual void AddLayoutOverflowFromChildren(); void AddVisualOverflowFromChildren(); - void AddOutlineRects(Vector<LayoutRect>&, - const LayoutPoint& additional_offset, + void AddOutlineRects(Vector<PhysicalRect>&, + const PhysicalOffset& additional_offset, NGOutlineType) const override; void UpdateBlockChildDirtyBitsBeforeLayout(bool relayout_children,
diff --git a/third_party/blink/renderer/core/layout/layout_block_flow.cc b/third_party/blink/renderer/core/layout/layout_block_flow.cc index ecb7e00..03e23be 100644 --- a/third_party/blink/renderer/core/layout/layout_block_flow.cc +++ b/third_party/blink/renderer/core/layout/layout_block_flow.cc
@@ -3085,20 +3085,6 @@ : nullptr; } -bool LayoutBlockFlow::NeedsAnonymousInlineWrapper() const { - // If ::first-line has background properties, create an anonymous inline - // wrapper. This helps paint code to handle it. - DCHECK(RuntimeEnabledFeatures::LayoutNGEnabled()); - if (!GetDocument().GetStyleEngine().UsesFirstLineRules()) - return false; - // We need an anonymous inline wrapper only if ::first-line has different - // background, but excessive anonymous inline will not harm much. To simplify, - // create the wrapper whenever ::first-line is applied. - const ComputedStyle& first_line_style = FirstLineStyleRef(); - const ComputedStyle& style = StyleRef(); - return &first_line_style != &style; -} - void LayoutBlockFlow::AddChild(LayoutObject* new_child, LayoutObject* before_child) { if (LayoutMultiColumnFlowThread* flow_thread = MultiColumnFlowThread()) { @@ -3135,22 +3121,6 @@ DCHECK(before_child->IsAnonymousBlock()); DCHECK_EQ(before_child->Parent(), this); } - } else if (UNLIKELY(RuntimeEnabledFeatures::LayoutNGEnabled() && - IsLayoutNGContainingBlock(this) && - NeedsAnonymousInlineWrapper())) { - LayoutObject* after_child = - before_child ? before_child->PreviousSibling() : LastChild(); - if (after_child && after_child->IsFirstLineAnonymous()) { - after_child->AddChild(new_child); - return; - } - LayoutInline* new_wrapper = - LayoutInline::CreateAnonymousForFirstLine(&GetDocument()); - new_wrapper->SetStyle(ComputedStyle::CreateAnonymousStyleWithDisplay( - StyleRef(), EDisplay::kInline)); - LayoutBox::AddChild(new_wrapper, before_child); - new_wrapper->AddChild(new_child); - return; } } else if (!child_is_block_level) { // This block has block children. We may want to put the new child into an @@ -4801,8 +4771,8 @@ #endif void LayoutBlockFlow::AddOutlineRects( - Vector<LayoutRect>& rects, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>& rects, + const PhysicalOffset& additional_offset, NGOutlineType include_block_overflows) const { // For blocks inside inlines, we go ahead and include margins so that we run // right up to the inline boxes above and below us (thus getting merged with @@ -4823,7 +4793,7 @@ LayoutUnit bottom_margin = next_inline_has_line_box ? CollapsedMarginAfter() : LayoutUnit(); if (top_margin || bottom_margin) { - LayoutRect rect(additional_offset, Size()); + PhysicalRect rect(additional_offset, Size()); rect.ExpandEdges(top_margin, LayoutUnit(), bottom_margin, LayoutUnit()); rects.push_back(rect); } @@ -4836,23 +4806,37 @@ !HasOverflowClip() && !HasControlClip()) { for (RootInlineBox* curr = FirstRootBox(); curr; curr = curr->NextRootBox()) { - LayoutUnit top = std::max<LayoutUnit>(curr->LineTop(), curr->Y()); - LayoutUnit bottom = - std::min<LayoutUnit>(curr->LineBottom(), curr->Y() + curr->Height()); - LayoutRect rect(additional_offset.X() + curr->X(), - additional_offset.Y() + top, curr->Width(), bottom - top); - if (!rect.IsEmpty()) - rects.push_back(rect); + LayoutUnit flipped_left = curr->X(); + LayoutUnit flipped_right = curr->X() + curr->Width(); + LayoutUnit top = curr->Y(); + LayoutUnit bottom = curr->Y() + curr->Height(); + if (IsHorizontalWritingMode()) { + top = std::max(curr->LineTop(), top); + bottom = std::min(curr->LineBottom(), bottom); + } else { + flipped_left = std::max(curr->LineTop(), flipped_left); + flipped_right = std::min(curr->LineBottom(), flipped_right); + } + LayoutRect rect(flipped_left, top, flipped_right - flipped_left, + bottom - top); + if (!rect.IsEmpty()) { + FlipForWritingMode(rect); + PhysicalRect physical_rect(rect); + physical_rect.Move(additional_offset); + rects.push_back(physical_rect); + } } } - if (inline_element_continuation) + if (const LayoutInline* inline_element_continuation = + InlineElementContinuation()) { inline_element_continuation->AddOutlineRects( rects, - additional_offset + - (inline_element_continuation->ContainingBlock()->Location() - - Location()), + additional_offset + (inline_element_continuation->ContainingBlock() + ->PhysicalLocation() - + PhysicalLocation()), include_block_overflows); + } } void LayoutBlockFlow::InvalidateDisplayItemClients(
diff --git a/third_party/blink/renderer/core/layout/layout_block_flow.h b/third_party/blink/renderer/core/layout/layout_block_flow.h index 295f06d..a951ce1 100644 --- a/third_party/blink/renderer/core/layout/layout_block_flow.h +++ b/third_party/blink/renderer/core/layout/layout_block_flow.h
@@ -518,8 +518,8 @@ void SetLogicalTopForChild(LayoutBox& child, LayoutUnit logical_top); void DetermineLogicalLeftPositionForChild(LayoutBox& child); - void AddOutlineRects(Vector<LayoutRect>&, - const LayoutPoint& additional_offset, + void AddOutlineRects(Vector<PhysicalRect>&, + const PhysicalOffset& additional_offset, NGOutlineType) const override; bool PaintedOutputOfObjectHasNoEffectRegardlessOfSize() const override; @@ -638,7 +638,6 @@ void ReparentSubsequentFloatingOrOutOfFlowSiblings(); void ReparentPrecedingFloatingOrOutOfFlowSiblings(); - bool NeedsAnonymousInlineWrapper() const; void MakeChildrenInlineIfPossible(); void MakeChildrenNonInline(LayoutObject* insertion_point = nullptr);
diff --git a/third_party/blink/renderer/core/layout/layout_block_flow_line.cc b/third_party/blink/renderer/core/layout/layout_block_flow_line.cc index 74631c1..57167c8f 100644 --- a/third_party/blink/renderer/core/layout/layout_block_flow_line.cc +++ b/third_party/blink/renderer/core/layout/layout_block_flow_line.cc
@@ -2344,7 +2344,7 @@ PhysicalRect child_rect = child->InkOverflow(); if (!child_rect.IsEmpty()) { child_rect.offset += child->Offset(); - AddContentsVisualOverflow(child_rect.ToLayoutRect()); + AddContentsVisualOverflow(child_rect); } } } else { @@ -2361,19 +2361,19 @@ // Add outline rects of continuations of descendant inlines into visual // overflow of this block. - LayoutRect outline_bounds_of_all_continuations; + PhysicalRect outline_bounds_of_all_continuations; for (InlineWalker walker(LineLayoutBlockFlow(this)); !walker.AtEnd(); walker.Advance()) { const LayoutObject& o = *walker.Current().GetLayoutObject(); if (!IsInlineWithOutlineAndContinuation(o)) continue; - Vector<LayoutRect> outline_rects; + Vector<PhysicalRect> outline_rects; ToLayoutInline(o).AddOutlineRectsForContinuations( - outline_rects, LayoutPoint(), + outline_rects, PhysicalOffset(), o.OutlineRectsShouldIncludeBlockVisualOverflow()); if (!outline_rects.IsEmpty()) { - LayoutRect outline_bounds = UnionRectEvenIfEmpty(outline_rects); + PhysicalRect outline_bounds = UnionRectEvenIfEmpty(outline_rects); outline_bounds.Inflate(LayoutUnit(o.StyleRef().OutlineOutsetExtent())); outline_bounds_of_all_continuations.Unite(outline_bounds); }
diff --git a/third_party/blink/renderer/core/layout/layout_block_test.cc b/third_party/blink/renderer/core/layout/layout_block_test.cc index 33cac11..88eabb366 100644 --- a/third_party/blink/renderer/core/layout/layout_block_test.cc +++ b/third_party/blink/renderer/core/layout/layout_block_test.cc
@@ -75,26 +75,33 @@ } TEST_F(LayoutBlockTest, NestedInlineVisualOverflow) { - // Only exercises legacy code. - if (RuntimeEnabledFeatures::LayoutNGEnabled()) - return; SetBodyInnerHTML(R"HTML( - <label style="font-size: 0px"> - <input type="radio" style="margin-left: -15px"> - </label> + <div id="target" style="width: 0; height: 0"> + <span style="font-size: 10px/10px"> + <img style="margin-left: -15px; width: 40px; height: 40px"> + </span> + </div> )HTML"); - auto* body = To<LayoutBlockFlow>(GetDocument().body()->GetLayoutObject()); - RootInlineBox* box = body->FirstRootBox(); -#if defined(OS_MACOSX) - EXPECT_EQ(LayoutRect(-17, 0, 16, 19), - box->VisualOverflowRect(box->LineTop(), box->LineBottom())); -#elif defined(OS_ANDROID) - EXPECT_EQ(LayoutRect(-15, 3, 19, 16), - box->VisualOverflowRect(box->LineTop(), box->LineBottom())); -#else - EXPECT_EQ(LayoutRect(-15, 3, 16, 13), - box->VisualOverflowRect(box->LineTop(), box->LineBottom())); -#endif + + auto* target = ToLayoutBox(GetLayoutObjectByElementId("target")); + EXPECT_EQ(LayoutRect(-15, 0, 40, 40), target->VisualOverflowRect()); + EXPECT_EQ(PhysicalRect(-15, 0, 40, 40), target->PhysicalVisualOverflowRect()); +} + +TEST_F(LayoutBlockTest, NestedInlineVisualOverflowVerticalRL) { + SetBodyInnerHTML(R"HTML( + <div style="width: 100px; writing-mode: vertical-rl"> + <div id="target" style="width: 0; height: 0"> + <span style="font-size: 10px/10px"> + <img style="margin-right: -15px; width: 40px; height: 40px"> + </span> + </div> + </div> + )HTML"); + + auto* target = ToLayoutBox(GetLayoutObjectByElementId("target")); + EXPECT_EQ(LayoutRect(-15, 0, 40, 40), target->VisualOverflowRect()); + EXPECT_EQ(PhysicalRect(-25, 0, 40, 40), target->PhysicalVisualOverflowRect()); } TEST_F(LayoutBlockTest, ContainmentStyleChange) {
diff --git a/third_party/blink/renderer/core/layout/layout_box.cc b/third_party/blink/renderer/core/layout/layout_box.cc index b7e51bcb..fa1e796 100644 --- a/third_party/blink/renderer/core/layout/layout_box.cc +++ b/third_party/blink/renderer/core/layout/layout_box.cc
@@ -958,10 +958,10 @@ return PhysicalRect(); } -void LayoutBox::AddOutlineRects(Vector<LayoutRect>& rects, - const LayoutPoint& additional_offset, +void LayoutBox::AddOutlineRects(Vector<PhysicalRect>& rects, + const PhysicalOffset& additional_offset, NGOutlineType) const { - rects.push_back(LayoutRect(additional_offset, Size())); + rects.emplace_back(additional_offset, Size()); } bool LayoutBox::CanResize() const { @@ -1591,19 +1591,19 @@ // If we have clipping, then we can't have any spillout. // TODO(pdr): Why is this optimization not valid for the effective root? if (!IsEffectiveRootScroller()) { - LayoutRect overflow_box; + PhysicalRect overflow_box; if (result.GetHitTestRequest().GetType() & HitTestRequest::kHitTestVisualOverflow) { - overflow_box = - PhysicalVisualOverflowRectIncludingFilters().ToLayoutRect(); + overflow_box = PhysicalVisualOverflowRectIncludingFilters(); } else { overflow_box = (HasOverflowClip() || ShouldApplyPaintContainment()) - ? BorderBoxRect() - : PhysicalVisualOverflowRect().ToLayoutRect(); + ? PhysicalBorderBoxRect() + : PhysicalVisualOverflowRect(); } - LayoutPoint adjusted_location = accumulated_offset + Location(); - overflow_box.MoveBy(adjusted_location); - if (!location_in_container.Intersects(overflow_box)) + + LayoutRect adjusted_overflow_box = overflow_box.ToLayoutRect(); + adjusted_overflow_box.MoveBy(accumulated_offset + Location()); + if (!location_in_container.Intersects(adjusted_overflow_box)) return false; } return LayoutObject::HitTestAllPhases(result, location_in_container, @@ -1704,18 +1704,18 @@ void LayoutBox::PaintBoxDecorationBackground( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { BoxPainter(*this).PaintBoxDecorationBackground(paint_info, paint_offset); } -bool LayoutBox::GetBackgroundPaintedExtent(LayoutRect& painted_extent) const { +bool LayoutBox::GetBackgroundPaintedExtent(PhysicalRect& painted_extent) const { DCHECK(StyleRef().HasBackground()); // LayoutView is special in the sense that it expands to the whole canvas, // thus can't be handled by this function. DCHECK(!IsLayoutView()); - LayoutRect background_rect(BorderBoxRect()); + PhysicalRect background_rect(PhysicalBorderBoxRect()); Color background_color = ResolveColor(GetCSSPropertyBackgroundColor()); if (background_color.Alpha()) { @@ -1738,12 +1738,12 @@ background_rect); if (geometry.HasNonLocalGeometry()) return false; - painted_extent = LayoutRect(geometry.SnappedDestRect()); + painted_extent = PhysicalRect(geometry.SnappedDestRect()); return true; } bool LayoutBox::BackgroundIsKnownToBeOpaqueInRect( - const LayoutRect& local_rect) const { + const PhysicalRect& local_rect) const { // If the background transfers to view, the used background of this object // is transparent. if (BackgroundTransfersToView()) @@ -1765,7 +1765,7 @@ if (StyleRef().HasBlendMode()) return false; return PhysicalBackgroundRect(kBackgroundKnownOpaqueRect) - .Contains(PhysicalRectToBeNoop(local_rect)); + .Contains(local_rect); } static bool IsCandidateForOpaquenessTest(const LayoutBox& child_box) { @@ -1799,7 +1799,7 @@ } bool LayoutBox::ForegroundIsKnownToBeOpaqueInRect( - const LayoutRect& local_rect, + const PhysicalRect& local_rect, unsigned max_depth_to_test) const { if (!max_depth_to_test) return false; @@ -1810,11 +1810,11 @@ LayoutBox* child_box = ToLayoutBox(child); if (!IsCandidateForOpaquenessTest(*child_box)) continue; - LayoutPoint child_location = child_box->PhysicalLocation().ToLayoutPoint(); + PhysicalOffset child_location = child_box->PhysicalLocation(); if (child_box->IsInFlowPositioned()) - child_location.Move(child_box->OffsetForInFlowPosition().ToLayoutSize()); - LayoutRect child_local_rect = local_rect; - child_local_rect.MoveBy(-child_location); + child_location += child_box->OffsetForInFlowPosition(); + PhysicalRect child_local_rect = local_rect; + child_local_rect.Move(-child_location); if (child_local_rect.Y() < 0 || child_local_rect.X() < 0) { // If there is unobscured area above/left of a static positioned box then // the rect is probably not covered. This can cause false-negative in @@ -1823,8 +1823,8 @@ return false; continue; } - if (child_local_rect.MaxY() > child_box->Size().Height() || - child_local_rect.MaxX() > child_box->Size().Width()) + if (child_local_rect.Bottom() > child_box->Size().Height() || + child_local_rect.Right() > child_box->Size().Width()) continue; if (child_box->BackgroundIsKnownToBeOpaqueInRect(child_local_rect)) return true; @@ -1848,7 +1848,7 @@ // FIXME: box-shadow is painted while background painting. if (StyleRef().BoxShadow()) return false; - LayoutRect background_rect; + PhysicalRect background_rect; if (!GetBackgroundPaintedExtent(background_rect)) return false; return ForegroundIsKnownToBeOpaqueInRect(background_rect, @@ -1856,7 +1856,7 @@ } void LayoutBox::PaintMask(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { BoxPainter(*this).PaintMask(paint_info, paint_offset); } @@ -5454,7 +5454,7 @@ return; // Add in the final overflow with shadows, outsets and outline combined. - LayoutRect visual_effect_overflow = BorderBoxRect(); + PhysicalRect visual_effect_overflow = PhysicalBorderBoxRect(); LayoutRectOutsets outsets = ComputeVisualEffectOverflowOutsets(); visual_effect_overflow.Expand(outsets); AddSelfVisualOverflow(visual_effect_overflow); @@ -5472,21 +5472,16 @@ LayoutRectOutsets outsets = style.BoxDecorationOutsets(); - // Box-shadow and border-image-outsets are in physical direction. Flip into - // block direction. - if (UNLIKELY(HasFlippedBlocksWritingMode())) - outsets.FlipHorizontally(); - if (style.HasOutline()) { - Vector<LayoutRect> outline_rects; - // The result rects are in coordinates of this object's border box. - AddOutlineRects(outline_rects, LayoutPoint(), - OutlineRectsShouldIncludeBlockVisualOverflow()); - LayoutRect rect = UnionRectEvenIfEmpty(outline_rects); - bool outline_affected = rect.Size() != Size(); + Vector<PhysicalRect> outline_rects = OutlineRects( + PhysicalOffset(), OutlineRectsShouldIncludeBlockVisualOverflow()); + PhysicalRect rect = UnionRectEvenIfEmpty(outline_rects); + bool outline_affected = rect.size != PhysicalSizeToBeNoop(Size()); SetOutlineMayBeAffectedByDescendants(outline_affected); - rect.Inflate(style.OutlineOutsetExtent()); - outsets.Unite(rect.ToOutsets(Size())); + rect.Inflate(LayoutUnit(style.OutlineOutsetExtent())); + outsets.Unite(LayoutRectOutsets(-rect.Y(), rect.Right() - Size().Width(), + rect.Bottom() - Size().Height(), + -rect.X())); } return outsets; @@ -5601,6 +5596,13 @@ overflow_->layout_overflow->AddLayoutOverflow(overflow_rect); } +void LayoutBox::AddSelfVisualOverflow(const PhysicalRect& rect) { + LayoutRect layout_rect = rect.ToLayoutRect(); + if (UNLIKELY(HasFlippedBlocksWritingMode())) + FlipForWritingMode(layout_rect); + AddSelfVisualOverflow(layout_rect); +} + void LayoutBox::AddSelfVisualOverflow(const LayoutRect& rect) { if (rect.IsEmpty()) return; @@ -5619,6 +5621,13 @@ overflow_->visual_overflow->AddSelfVisualOverflow(rect); } +void LayoutBox::AddContentsVisualOverflow(const PhysicalRect& rect) { + LayoutRect layout_rect = rect.ToLayoutRect(); + if (UNLIKELY(HasFlippedBlocksWritingMode())) + FlipForWritingMode(layout_rect); + AddContentsVisualOverflow(layout_rect); +} + void LayoutBox::AddContentsVisualOverflow(const LayoutRect& rect) { if (rect.IsEmpty()) return;
diff --git a/third_party/blink/renderer/core/layout/layout_box.h b/third_party/blink/renderer/core/layout/layout_box.h index 113be10..8ea6a5b 100644 --- a/third_party/blink/renderer/core/layout/layout_box.h +++ b/third_party/blink/renderer/core/layout/layout_box.h
@@ -230,7 +230,7 @@ PaintLayerType LayerTypeRequired() const override; bool BackgroundIsKnownToBeOpaqueInRect( - const LayoutRect& local_rect) const override; + const PhysicalRect& local_rect) const override; virtual bool BackgroundShouldAlwaysBeClipped() const { return false; } @@ -465,8 +465,8 @@ ClientHeight() - ComputedCSSPaddingTop() - ComputedCSSPaddingBottom()); } - void AddOutlineRects(Vector<LayoutRect>&, - const LayoutPoint& additional_offset, + void AddOutlineRects(Vector<PhysicalRect>&, + const PhysicalOffset& additional_offset, NGOutlineType) const override; // Use this with caution! No type checking is done! @@ -550,7 +550,9 @@ virtual bool HasLeftOverflow() const; void AddLayoutOverflow(const LayoutRect&); + void AddSelfVisualOverflow(const PhysicalRect&); void AddSelfVisualOverflow(const LayoutRect&); + void AddContentsVisualOverflow(const PhysicalRect&); void AddContentsVisualOverflow(const LayoutRect&); void AddVisualEffectOverflow(); @@ -1211,9 +1213,6 @@ kIgnorePlatformOverlayScrollbarSize) const { return OverflowClipRect(PhysicalOffset(location), behavior).ToLayoutRect(); } - LayoutRect ClipRect(const LayoutPoint& location) const { - return ClipRect(PhysicalOffset(location)).ToLayoutRect(); - } // Returns the combination of overflow clip, contain: paint clip and CSS clip // for this object. @@ -1221,9 +1220,9 @@ virtual void PaintBoxDecorationBackground( const PaintInfo&, - const LayoutPoint& paint_offset) const; + const PhysicalOffset& paint_offset) const; virtual void PaintMask(const PaintInfo&, - const LayoutPoint& paint_offset) const; + const PhysicalOffset& paint_offset) const; void ImageChanged(WrappedImagePtr, CanDeferInvalidation) override; ResourcePriority ComputeResourcePriority() const final; @@ -1608,9 +1607,9 @@ // Returns false if it could not cheaply compute the extent (e.g. fixed // background), in which case the returned rect may be incorrect. - bool GetBackgroundPaintedExtent(LayoutRect&) const; + bool GetBackgroundPaintedExtent(PhysicalRect&) const; virtual bool ForegroundIsKnownToBeOpaqueInRect( - const LayoutRect& local_rect, + const PhysicalRect& local_rect, unsigned max_depth_to_test) const; virtual bool ComputeBackgroundIsKnownToBeObscured() const;
diff --git a/third_party/blink/renderer/core/layout/layout_box_model_object.cc b/third_party/blink/renderer/core/layout/layout_box_model_object.cc index f2767d6..19ed3307 100644 --- a/third_party/blink/renderer/core/layout/layout_box_model_object.cc +++ b/third_party/blink/renderer/core/layout/layout_box_model_object.cc
@@ -519,19 +519,19 @@ } void LayoutBoxModelObject::AddOutlineRectsForNormalChildren( - Vector<LayoutRect>& rects, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>& rects, + const PhysicalOffset& additional_offset, NGOutlineType include_block_overflows) const { for (LayoutObject* child = SlowFirstChild(); child; child = child->NextSibling()) { // Outlines of out-of-flow positioned descendants are handled in - // LayoutBlock::addOutlineRects(). + // LayoutBlock::AddOutlineRects(). if (child->IsOutOfFlowPositioned()) continue; // Outline of an element continuation or anonymous block continuation is // added when we iterate the continuation chain. - // See LayoutBlock::addOutlineRects() and LayoutInline::addOutlineRects(). + // See LayoutBlock::AddOutlineRects() and LayoutInline::AddOutlineRects(). auto* child_block_flow = DynamicTo<LayoutBlockFlow>(child); if (child->IsElementContinuation() || (child_block_flow && child_block_flow->IsAnonymousBlockContinuation())) @@ -544,17 +544,17 @@ void LayoutBoxModelObject::AddOutlineRectsForDescendant( const LayoutObject& descendant, - Vector<LayoutRect>& rects, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>& rects, + const PhysicalOffset& additional_offset, NGOutlineType include_block_overflows) const { if (descendant.IsText() || descendant.IsListMarker()) return; if (descendant.HasLayer()) { - Vector<LayoutRect> layer_outline_rects; - descendant.AddOutlineRects(layer_outline_rects, LayoutPoint(), + Vector<PhysicalRect> layer_outline_rects; + descendant.AddOutlineRects(layer_outline_rects, PhysicalOffset(), include_block_overflows); - descendant.LocalToAncestorRects(layer_outline_rects, this, LayoutPoint(), + descendant.LocalToAncestorRects(layer_outline_rects, this, PhysicalOffset(), additional_offset); rects.AppendVector(layer_outline_rects); return; @@ -562,7 +562,7 @@ if (descendant.IsBox()) { descendant.AddOutlineRects( - rects, additional_offset + ToLayoutBox(descendant).LocationOffset(), + rects, additional_offset + ToLayoutBox(descendant).PhysicalLocation(), include_block_overflows); return; }
diff --git a/third_party/blink/renderer/core/layout/layout_box_model_object.h b/third_party/blink/renderer/core/layout/layout_box_model_object.h index 13276224..6aaea9d 100644 --- a/third_party/blink/renderer/core/layout/layout_box_model_object.h +++ b/third_party/blink/renderer/core/layout/layout_box_model_object.h
@@ -415,7 +415,7 @@ // Returns true if the background is painted opaque in the given rect. // The query rect is given in local coordinate system. - virtual bool BackgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const { + virtual bool BackgroundIsKnownToBeOpaqueInRect(const PhysicalRect&) const { return false; } @@ -488,12 +488,12 @@ LayoutBlock* ContainingBlockForAutoHeightDetection( const Length& logical_height) const; - void AddOutlineRectsForNormalChildren(Vector<LayoutRect>&, - const LayoutPoint& additional_offset, + void AddOutlineRectsForNormalChildren(Vector<PhysicalRect>&, + const PhysicalOffset& additional_offset, NGOutlineType) const; void AddOutlineRectsForDescendant(const LayoutObject& descendant, - Vector<LayoutRect>&, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>&, + const PhysicalOffset& additional_offset, NGOutlineType) const; void StyleWillChange(StyleDifference,
diff --git a/third_party/blink/renderer/core/layout/layout_box_test.cc b/third_party/blink/renderer/core/layout/layout_box_test.cc index bf1fb72..ada8f7b1 100644 --- a/third_party/blink/renderer/core/layout/layout_box_test.cc +++ b/third_party/blink/renderer/core/layout/layout_box_test.cc
@@ -27,7 +27,7 @@ } bool ForegroundIsKnownToBeOpaqueInRect(const LayoutBox& box, - const LayoutRect& rect) { + const PhysicalRect& rect) { return box.ForegroundIsKnownToBeOpaqueInRect(rect, 10); } }; @@ -132,21 +132,21 @@ auto& target = *GetLayoutBoxByElementId("target"); // Covered by the first child which is opaque. EXPECT_TRUE( - ForegroundIsKnownToBeOpaqueInRect(target, LayoutRect(0, 0, 10, 10))); + ForegroundIsKnownToBeOpaqueInRect(target, PhysicalRect(0, 0, 10, 10))); // Covered by the first child of the second child is translucent. EXPECT_FALSE( - ForegroundIsKnownToBeOpaqueInRect(target, LayoutRect(0, 10, 10, 10))); + ForegroundIsKnownToBeOpaqueInRect(target, PhysicalRect(0, 10, 10, 10))); // Covered by the second child of the second child which is opaque. EXPECT_TRUE( - ForegroundIsKnownToBeOpaqueInRect(target, LayoutRect(20, 20, 10, 10))); + ForegroundIsKnownToBeOpaqueInRect(target, PhysicalRect(20, 20, 10, 10))); // Not covered by any child. EXPECT_FALSE( - ForegroundIsKnownToBeOpaqueInRect(target, LayoutRect(0, 20, 10, 10))); + ForegroundIsKnownToBeOpaqueInRect(target, PhysicalRect(0, 20, 10, 10))); // Partly covered by opaque children. EXPECT_FALSE( - ForegroundIsKnownToBeOpaqueInRect(target, LayoutRect(0, 0, 30, 30))); + ForegroundIsKnownToBeOpaqueInRect(target, PhysicalRect(0, 0, 30, 30))); EXPECT_FALSE( - ForegroundIsKnownToBeOpaqueInRect(target, LayoutRect(0, 0, 10, 30))); + ForegroundIsKnownToBeOpaqueInRect(target, PhysicalRect(0, 0, 10, 30))); } TEST_P(LayoutBoxTest, ForegroundIsKnownToBeOpaqueInRectVerticalRL) { @@ -166,23 +166,23 @@ auto& target = *GetLayoutBoxByElementId("target"); // Covered by the first child which is opaque. EXPECT_TRUE( - ForegroundIsKnownToBeOpaqueInRect(target, LayoutRect(20, 0, 10, 10))); + ForegroundIsKnownToBeOpaqueInRect(target, PhysicalRect(20, 0, 10, 10))); // Covered by the first child of the second child is translucent. EXPECT_FALSE( - ForegroundIsKnownToBeOpaqueInRect(target, LayoutRect(10, 0, 10, 10))); + ForegroundIsKnownToBeOpaqueInRect(target, PhysicalRect(10, 0, 10, 10))); // Covered by the second child of the second child which is opaque. // However, the algorithm is optimized for horizontal-tb writing mode and has // false-negative (which is allowed) in this case. EXPECT_FALSE( - ForegroundIsKnownToBeOpaqueInRect(target, LayoutRect(0, 20, 10, 10))); + ForegroundIsKnownToBeOpaqueInRect(target, PhysicalRect(0, 20, 10, 10))); // Not covered by any child. EXPECT_FALSE( - ForegroundIsKnownToBeOpaqueInRect(target, LayoutRect(0, 0, 10, 10))); + ForegroundIsKnownToBeOpaqueInRect(target, PhysicalRect(0, 0, 10, 10))); // Partly covered by opaque children. EXPECT_FALSE( - ForegroundIsKnownToBeOpaqueInRect(target, LayoutRect(0, 0, 30, 30))); + ForegroundIsKnownToBeOpaqueInRect(target, PhysicalRect(0, 0, 30, 30))); EXPECT_FALSE( - ForegroundIsKnownToBeOpaqueInRect(target, LayoutRect(20, 0, 30, 10))); + ForegroundIsKnownToBeOpaqueInRect(target, PhysicalRect(20, 0, 30, 10))); } TEST_P(LayoutBoxTest, BackgroundRect) {
diff --git a/third_party/blink/renderer/core/layout/layout_embedded_content.cc b/third_party/blink/renderer/core/layout/layout_embedded_content.cc index fbf4930..8d17c82 100644 --- a/third_party/blink/renderer/core/layout/layout_embedded_content.cc +++ b/third_party/blink/renderer/core/layout/layout_embedded_content.cc
@@ -278,7 +278,7 @@ void LayoutEmbeddedContent::PaintReplaced( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { EmbeddedContentPainter(*this).PaintReplaced(paint_info, paint_offset); }
diff --git a/third_party/blink/renderer/core/layout/layout_embedded_content.h b/third_party/blink/renderer/core/layout/layout_embedded_content.h index bb742464..35801d7 100644 --- a/third_party/blink/renderer/core/layout/layout_embedded_content.h +++ b/third_party/blink/renderer/core/layout/layout_embedded_content.h
@@ -72,7 +72,7 @@ void StyleDidChange(StyleDifference, const ComputedStyle* old_style) final; void UpdateLayout() override; void PaintReplaced(const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; void InvalidatePaint(const PaintInvalidatorContext&) const final; CursorDirective GetCursor(const LayoutPoint&, Cursor&) const final;
diff --git a/third_party/blink/renderer/core/layout/layout_embedded_object.cc b/third_party/blink/renderer/core/layout/layout_embedded_object.cc index 4798dbb..d44c66f 100644 --- a/third_party/blink/renderer/core/layout/layout_embedded_object.cc +++ b/third_party/blink/renderer/core/layout/layout_embedded_object.cc
@@ -81,7 +81,7 @@ void LayoutEmbeddedObject::PaintReplaced( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { EmbeddedObjectPainter(*this).PaintReplaced(paint_info, paint_offset); }
diff --git a/third_party/blink/renderer/core/layout/layout_embedded_object.h b/third_party/blink/renderer/core/layout/layout_embedded_object.h index 42cd2a20..31657ba 100644 --- a/third_party/blink/renderer/core/layout/layout_embedded_object.h +++ b/third_party/blink/renderer/core/layout/layout_embedded_object.h
@@ -51,7 +51,7 @@ private: void PaintReplaced(const PaintInfo&, - const LayoutPoint& paint_offset) const final; + const PhysicalOffset& paint_offset) const final; void UpdateLayout() final;
diff --git a/third_party/blink/renderer/core/layout/layout_fieldset.cc b/third_party/blink/renderer/core/layout/layout_fieldset.cc index 3db99ab1..9f3d438 100644 --- a/third_party/blink/renderer/core/layout/layout_fieldset.cc +++ b/third_party/blink/renderer/core/layout/layout_fieldset.cc
@@ -164,17 +164,17 @@ void LayoutFieldset::PaintBoxDecorationBackground( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { FieldsetPainter(*this).PaintBoxDecorationBackground(paint_info, paint_offset); } void LayoutFieldset::PaintMask(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { FieldsetPainter(*this).PaintMask(paint_info, paint_offset); } bool LayoutFieldset::BackgroundIsKnownToBeOpaqueInRect( - const LayoutRect& local_rect) const { + const PhysicalRect& local_rect) const { // If the field set has a legend, then it probably does not completely fill // its background. if (FindInFlowLegend())
diff --git a/third_party/blink/renderer/core/layout/layout_fieldset.h b/third_party/blink/renderer/core/layout/layout_fieldset.h index 9079019..16db91b 100644 --- a/third_party/blink/renderer/core/layout/layout_fieldset.h +++ b/third_party/blink/renderer/core/layout/layout_fieldset.h
@@ -39,7 +39,7 @@ bool CreatesNewFormattingContext() const final { return true; } - bool BackgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const override; + bool BackgroundIsKnownToBeOpaqueInRect(const PhysicalRect&) const override; private: bool IsOfType(LayoutObjectType type) const override { @@ -53,9 +53,9 @@ void PaintBoxDecorationBackground( const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; void PaintMask(const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; }; DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutFieldset, IsFieldset());
diff --git a/third_party/blink/renderer/core/layout/layout_file_upload_control.cc b/third_party/blink/renderer/core/layout/layout_file_upload_control.cc index 2d33750..f2786b5 100644 --- a/third_party/blink/renderer/core/layout/layout_file_upload_control.cc +++ b/third_party/blink/renderer/core/layout/layout_file_upload_control.cc
@@ -74,7 +74,7 @@ void LayoutFileUploadControl::PaintObject( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { FileUploadControlPainter(*this).PaintObject(paint_info, paint_offset); }
diff --git a/third_party/blink/renderer/core/layout/layout_file_upload_control.h b/third_party/blink/renderer/core/layout/layout_file_upload_control.h index 5c365b1b..5232c77 100644 --- a/third_party/blink/renderer/core/layout/layout_file_upload_control.h +++ b/third_party/blink/renderer/core/layout/layout_file_upload_control.h
@@ -66,7 +66,7 @@ LayoutUnit& max_logical_width) const override; void ComputePreferredLogicalWidths() override; void PaintObject(const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; int MaxFilenameWidth() const;
diff --git a/third_party/blink/renderer/core/layout/layout_flexible_box.cc b/third_party/blink/renderer/core/layout/layout_flexible_box.cc index f2243d61..19076ba8 100644 --- a/third_party/blink/renderer/core/layout/layout_flexible_box.cc +++ b/third_party/blink/renderer/core/layout/layout_flexible_box.cc
@@ -404,7 +404,7 @@ } void LayoutFlexibleBox::PaintChildren(const PaintInfo& paint_info, - const LayoutPoint&) const { + const PhysicalOffset&) const { BlockPainter(*this).PaintChildrenAtomically(this->GetOrderIterator(), paint_info); }
diff --git a/third_party/blink/renderer/core/layout/layout_flexible_box.h b/third_party/blink/renderer/core/layout/layout_flexible_box.h index 49a7292..71339bd 100644 --- a/third_party/blink/renderer/core/layout/layout_flexible_box.h +++ b/third_party/blink/renderer/core/layout/layout_flexible_box.h
@@ -70,7 +70,7 @@ bool HasLeftOverflow() const override; void PaintChildren(const PaintInfo&, - const LayoutPoint& paint_offset) const final; + const PhysicalOffset& paint_offset) const final; bool IsHorizontalFlow() const;
diff --git a/third_party/blink/renderer/core/layout/layout_flow_thread.cc b/third_party/blink/renderer/core/layout/layout_flow_thread.cc index 332d147..f52bfb2 100644 --- a/third_party/blink/renderer/core/layout/layout_flow_thread.cc +++ b/third_party/blink/renderer/core/layout/layout_flow_thread.cc
@@ -158,10 +158,10 @@ } void LayoutFlowThread::AddOutlineRects( - Vector<LayoutRect>& rects, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>& rects, + const PhysicalOffset& additional_offset, NGOutlineType include_block_overflows) const { - Vector<LayoutRect> rects_in_flowthread; + Vector<PhysicalRect> rects_in_flowthread; LayoutBlockFlow::AddOutlineRects(rects_in_flowthread, additional_offset, include_block_overflows); // Convert the rectangles from the flow thread coordinate space to the visual @@ -173,10 +173,8 @@ // block direction anyway. As far as the inline direction (the column // progression direction) is concerned, we'll just include the full height of // each column involved. Should be good enough. - LayoutRect union_rect; - for (const auto& rect : rects_in_flowthread) - union_rect.Unite(rect); - rects.push_back(FragmentsBoundingBox(union_rect)); + rects.push_back(PhysicalRectToBeNoop( + FragmentsBoundingBox(UnionRect(rects_in_flowthread).ToLayoutRect()))); } bool LayoutFlowThread::NodeAtPoint(HitTestResult& result,
diff --git a/third_party/blink/renderer/core/layout/layout_flow_thread.h b/third_party/blink/renderer/core/layout/layout_flow_thread.h index 8a67a78..2cc0d54 100644 --- a/third_party/blink/renderer/core/layout/layout_flow_thread.h +++ b/third_party/blink/renderer/core/layout/layout_flow_thread.h
@@ -120,8 +120,8 @@ Vector<FloatQuad>&, MapCoordinatesFlags mode = 0); - void AddOutlineRects(Vector<LayoutRect>&, - const LayoutPoint& additional_offset, + void AddOutlineRects(Vector<PhysicalRect>&, + const PhysicalOffset& additional_offset, NGOutlineType) const override; bool NodeAtPoint(HitTestResult&,
diff --git a/third_party/blink/renderer/core/layout/layout_geometry_map.cc b/third_party/blink/renderer/core/layout/layout_geometry_map.cc index d7805147..341f758 100644 --- a/third_party/blink/renderer/core/layout/layout_geometry_map.cc +++ b/third_party/blink/renderer/core/layout/layout_geometry_map.cc
@@ -255,7 +255,7 @@ #endif if (can_convert_in_layer_tree) { - LayoutPoint layer_offset; + PhysicalOffset layer_offset; layer->ConvertToLayerCoords(ancestor_layer, layer_offset); // The LayoutView must be pushed first. @@ -269,7 +269,7 @@ bool accumulating_transform = layout_object.StyleRef().Preserves3D() || ancestor_layer->GetLayoutObject().StyleRef().Preserves3D(); - Push(&layout_object, PhysicalOffsetToBeNoop(layer_offset), + Push(&layout_object, layer_offset, accumulating_transform ? kAccumulatingTransform : 0); return; }
diff --git a/third_party/blink/renderer/core/layout/layout_grid.cc b/third_party/blink/renderer/core/layout/layout_grid.cc index d1aaefb6..f8ba8a6 100644 --- a/third_party/blink/renderer/core/layout/layout_grid.cc +++ b/third_party/blink/renderer/core/layout/layout_grid.cc
@@ -2360,7 +2360,7 @@ } void LayoutGrid::PaintChildren(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { DCHECK(!grid_->NeedsItemsPlacement()); if (grid_->HasGridItems()) { BlockPainter(*this).PaintChildrenAtomically(grid_->GetOrderIterator(),
diff --git a/third_party/blink/renderer/core/layout/layout_grid.h b/third_party/blink/renderer/core/layout/layout_grid.h index 6e5a589c..57387ce 100644 --- a/third_party/blink/renderer/core/layout/layout_grid.h +++ b/third_party/blink/renderer/core/layout/layout_grid.h
@@ -235,7 +235,7 @@ GridTrackSizingDirection) const; void PaintChildren(const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; LayoutUnit AvailableAlignmentSpaceForChildBeforeStretching( LayoutUnit grid_area_breadth_for_child,
diff --git a/third_party/blink/renderer/core/layout/layout_html_canvas.cc b/third_party/blink/renderer/core/layout/layout_html_canvas.cc index 28aa60f..2847ccf 100644 --- a/third_party/blink/renderer/core/layout/layout_html_canvas.cc +++ b/third_party/blink/renderer/core/layout/layout_html_canvas.cc
@@ -44,7 +44,7 @@ } void LayoutHTMLCanvas::PaintReplaced(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { HTMLCanvasPainter(*this).PaintReplaced(paint_info, paint_offset); }
diff --git a/third_party/blink/renderer/core/layout/layout_html_canvas.h b/third_party/blink/renderer/core/layout/layout_html_canvas.h index d0d2845..b76f0847 100644 --- a/third_party/blink/renderer/core/layout/layout_html_canvas.h +++ b/third_party/blink/renderer/core/layout/layout_html_canvas.h
@@ -51,7 +51,7 @@ private: void PaintReplaced(const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; void IntrinsicSizeChanged() override { CanvasSizeChanged(); } CompositingReasons AdditionalCompositingReasons() const override;
diff --git a/third_party/blink/renderer/core/layout/layout_image.cc b/third_party/blink/renderer/core/layout/layout_image.cc index e4f985f..ff5f4cf 100644 --- a/third_party/blink/renderer/core/layout/layout_image.cc +++ b/third_party/blink/renderer/core/layout/layout_image.cc
@@ -219,7 +219,7 @@ } void LayoutImage::PaintReplaced(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { ImagePainter(*this).PaintReplaced(paint_info, paint_offset); } @@ -237,14 +237,14 @@ } bool LayoutImage::ForegroundIsKnownToBeOpaqueInRect( - const LayoutRect& local_rect, + const PhysicalRect& local_rect, unsigned) const { if (!image_resource_->HasImage() || image_resource_->ErrorOccurred()) return false; ImageResourceContent* image_content = image_resource_->CachedImage(); if (!image_content || !image_content->IsLoaded()) return false; - if (!PhysicalContentBoxRect().ToLayoutRect().Contains(local_rect)) + if (!PhysicalContentBoxRect().Contains(local_rect)) return false; EFillBox background_clip = StyleRef().BackgroundClip(); // Background paints under borders. @@ -275,7 +275,7 @@ if (!StyleRef().HasBackground()) return false; - LayoutRect painted_extent; + PhysicalRect painted_extent; if (!GetBackgroundPaintedExtent(painted_extent)) return false; return ForegroundIsKnownToBeOpaqueInRect(painted_extent, 0);
diff --git a/third_party/blink/renderer/core/layout/layout_image.h b/third_party/blink/renderer/core/layout/layout_image.h index 89f28ec..39bc5ed 100644 --- a/third_party/blink/renderer/core/layout/layout_image.h +++ b/third_party/blink/renderer/core/layout/layout_image.h
@@ -112,10 +112,10 @@ bool IsImage() const override { return true; } void PaintReplaced(const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; bool ForegroundIsKnownToBeOpaqueInRect( - const LayoutRect& local_rect, + const PhysicalRect& local_rect, unsigned max_depth_to_test) const final; bool ComputeBackgroundIsKnownToBeObscured() const final;
diff --git a/third_party/blink/renderer/core/layout/layout_inline.cc b/third_party/blink/renderer/core/layout/layout_inline.cc index 3be4f56..ae3543ee 100644 --- a/third_party/blink/renderer/core/layout/layout_inline.cc +++ b/third_party/blink/renderer/core/layout/layout_inline.cc
@@ -104,22 +104,6 @@ return layout_inline; } -// A private class to distinguish anonymous inline box for ::first-line from -// other inline boxes. -class LayoutInlineForFirstLine : public LayoutInline { - public: - LayoutInlineForFirstLine(Element* element) : LayoutInline(element) {} - - protected: - bool VirtualIsFirstLineAnonymous() const final { return true; } -}; - -LayoutInline* LayoutInline::CreateAnonymousForFirstLine(Document* document) { - LayoutInline* layout_inline = new LayoutInlineForFirstLine(nullptr); - layout_inline->SetDocumentForAnonymous(document); - return layout_inline; -} - void LayoutInline::WillBeDestroyed() { // Make sure to destroy anonymous children first while they are still // connected to the rest of the tree, so that they will properly dirty line @@ -568,13 +552,8 @@ } LayoutInline* LayoutInline::Clone() const { - LayoutInline* clone_inline = nullptr; - if (UNLIKELY(IsFirstLineAnonymous())) { - clone_inline = CreateAnonymousForFirstLine(&GetDocument()); - } else { - DCHECK(!IsAnonymous()); - clone_inline = new LayoutInline(GetNode()); - } + DCHECK(!IsAnonymous()); + LayoutInline* clone_inline = new LayoutInline(GetNode()); clone_inline->SetStyle(MutableStyle()); clone_inline->SetIsInsideFlowThread(IsInsideFlowThread()); return clone_inline; @@ -583,8 +562,8 @@ void LayoutInline::MoveChildrenToIgnoringContinuation( LayoutInline* to, LayoutObject* start_child) { - DCHECK(!IsAnonymous() || IsFirstLineAnonymous()); - DCHECK(!to->IsAnonymous() || to->IsFirstLineAnonymous()); + DCHECK(!IsAnonymous()); + DCHECK(!to->IsAnonymous()); LayoutObject* child = start_child; while (child) { LayoutObject* current_child = child; @@ -600,7 +579,7 @@ LayoutObject* before_child, LayoutBoxModelObject* old_cont) { DCHECK(IsDescendantOf(from_block)); - DCHECK(!IsAnonymous() || IsFirstLineAnonymous()); + DCHECK(!IsAnonymous()); // FIXME: Because splitting is O(n^2) as tags nest pathologically, we cap the // depth at which we're willing to clone. @@ -798,34 +777,44 @@ InlinePainter(*this).Paint(paint_info); } -template <typename GeneratorContext> -void LayoutInline::GenerateLineBoxRects(GeneratorContext& yield) const { +template <typename PhysicalRectCollector> +void LayoutInline::CollectLineBoxRects( + const PhysicalRectCollector& yield) const { if (IsInLayoutNGInlineFormattingContext()) { - const NGPhysicalBoxFragment* box_fragment = - ContainingBlockFlowFragmentOf(*this); + const auto* box_fragment = ContainingBlockFlowFragmentOf(*this); if (!box_fragment) return; - const auto& descendants = - NGInlineFragmentTraversal::SelfFragmentsOf(*box_fragment, this); - const LayoutBlock* block_for_flipping = nullptr; - if (UNLIKELY(HasFlippedBlocksWritingMode())) - block_for_flipping = ContainingBlock(); - for (const auto& descendant : descendants) { - LayoutRect rect = descendant.RectInContainerBox().ToLayoutRect(); - if (UNLIKELY(block_for_flipping)) - block_for_flipping->FlipForWritingMode(rect); - yield(rect); - } + for (const auto& fragment : + NGInlineFragmentTraversal::SelfFragmentsOf(*box_fragment, this)) + yield(fragment.RectInContainerBox()); return; } if (!AlwaysCreateLineBoxes()) { - GenerateCulledLineBoxRects(yield, this); + CollectCulledLineBoxRects(yield); } else { - for (InlineFlowBox* curr : *LineBoxes()) - yield(LayoutRect(curr->Location(), curr->Size())); + const LayoutBlock* block_for_flipping = + NeedsFlipForWritingMode() ? ContainingBlock() : nullptr; + for (InlineFlowBox* curr : *LineBoxes()) { + yield(FlipForWritingMode(LayoutRect(curr->Location(), curr->Size()), + block_for_flipping)); + } } } +template <typename PhysicalRectCollector> +void LayoutInline::CollectCulledLineBoxRects( + const PhysicalRectCollector& yield) const { + DCHECK(!IsInLayoutNGInlineFormattingContext()); + const LayoutBlock* block_for_flipping = + NeedsFlipForWritingMode() ? ContainingBlock() : nullptr; + CollectCulledLineBoxRectsInFlippedBlocksDirection( + [this, block_for_flipping, &yield](const LayoutRect& r) { + PhysicalRect rect = FlipForWritingMode(r, block_for_flipping); + yield(rect); + }, + this); +} + static inline void ComputeItemTopHeight(const LayoutInline* container, const RootInlineBox& root_box, LayoutUnit* top, @@ -849,9 +838,9 @@ *height = LayoutUnit(container_metrics.Height()); } -template <typename GeneratorContext> -void LayoutInline::GenerateCulledLineBoxRects( - GeneratorContext& yield, +template <typename FlippedRectCollector> +void LayoutInline::CollectCulledLineBoxRectsInFlippedBlocksDirection( + const FlippedRectCollector& yield, const LayoutInline* container) const { if (!CulledInlineFirstLineBox()) return; @@ -889,7 +878,8 @@ // If the child doesn't need line boxes either, then we can recur. LayoutInline* curr_inline = ToLayoutInline(curr); if (!curr_inline->AlwaysCreateLineBoxes()) { - curr_inline->GenerateCulledLineBoxRects(yield, container); + curr_inline->CollectCulledLineBoxRectsInFlippedBlocksDirection( + yield, container); } else { for (InlineFlowBox* child_line : *curr_inline->LineBoxes()) { RootInlineBox& root_box = child_line->Root(); @@ -926,35 +916,20 @@ } } -namespace { - -class AbsoluteQuadsGeneratorContext { - public: - AbsoluteQuadsGeneratorContext(const LayoutInline* layout_object, - Vector<FloatQuad>& quads, - MapCoordinatesFlags mode) - : quads_(quads), geometry_map_(mode) { - geometry_map_.PushMappingsToAncestor(layout_object, nullptr); - } - - void operator()(const FloatRect& rect) { - quads_.push_back(geometry_map_.AbsoluteRect(rect)); - } - void operator()(const LayoutRect& rect) { operator()(FloatRect(rect)); } - - private: - Vector<FloatQuad>& quads_; - LayoutGeometryMap geometry_map_; -}; - -} // unnamed namespace - void LayoutInline::AbsoluteQuadsForSelf(Vector<FloatQuad>& quads, MapCoordinatesFlags mode) const { - AbsoluteQuadsGeneratorContext context(this, quads, mode); - GenerateLineBoxRects(context); + LayoutGeometryMap geometry_map(mode); + geometry_map.PushMappingsToAncestor(this, nullptr); + const LayoutBlock* block_for_flipping = + NeedsFlipForWritingMode() ? ContainingBlock() : nullptr; + CollectLineBoxRects( + [this, &quads, &geometry_map, block_for_flipping](const PhysicalRect& r) { + // LayoutGeometryMap requires flipped rect as the input. + LayoutRect rect = FlipForWritingMode(r, block_for_flipping); + quads.push_back(geometry_map.AbsoluteRect(FloatRect(rect))); + }); if (quads.IsEmpty()) - context(FloatRect()); + quads.push_back(geometry_map.AbsoluteRect(FloatRect())); } base::Optional<PhysicalOffset> LayoutInline::FirstLineBoxTopLeftInternal() @@ -972,7 +947,7 @@ } if (const InlineBox* first_box = FirstLineBoxIncludingCulling()) { LayoutPoint location = first_box->Location(); - if (UNLIKELY(HasFlippedBlocksWritingMode())) { + if (UNLIKELY(NeedsFlipForWritingMode())) { location = ContainingBlock()->FlipForWritingMode(location); location.Move(-first_box->Width(), LayoutUnit()); } @@ -1004,20 +979,17 @@ } PhysicalRect LayoutInline::AbsoluteBoundingBoxRectHandlingEmptyInline() const { - Vector<LayoutRect> rects; - AddOutlineRects(rects, LayoutPoint(), - NGOutlineType::kIncludeBlockVisualOverflow); - LayoutRect rect = UnionRect(rects); - if (rects.IsEmpty()) { - auto location = AnchorPhysicalLocation().ToLayoutPoint(); - // AnchorPhysicalLocation is pure physical, while LocalToAbsolute() requires - // physical coordinates with flipped block direction. - if (UNLIKELY(HasFlippedBlocksWritingMode())) - location = ContainingBlock()->FlipForWritingMode(location); - rect.SetLocation(location); - } - return PhysicalRect(LocalToAbsoluteQuad(FloatRect(rect), kUseTransforms) - .EnclosingBoundingBox()); + Vector<PhysicalRect> rects = OutlineRects( + PhysicalOffset(), NGOutlineType::kIncludeBlockVisualOverflow); + PhysicalRect rect = UnionRect(rects); + if (rects.IsEmpty()) + rect.offset = AnchorPhysicalLocation(); + + // rect is pure physical, while LocalToAbsolute() requires physical + // coordinates with flipped block direction. + FloatRect flipped_rect(FlipForWritingMode(rect)); + return PhysicalRect( + LocalToAbsoluteQuad(flipped_rect, kUseTransforms).EnclosingBoundingBox()); } LayoutUnit LayoutInline::OffsetLeft(const Element* parent) const { @@ -1085,29 +1057,6 @@ hit_test_action); } -namespace { - -class HitTestCulledInlinesGeneratorContext { - public: - HitTestCulledInlinesGeneratorContext(Region& region, - const HitTestLocation& location) - : intersected_(false), region_(region), location_(location) {} - void operator()(const LayoutRect& rect) { - if (location_.Intersects(rect)) { - intersected_ = true; - region_.Unite(EnclosingIntRect(rect)); - } - } - bool Intersected() const { return intersected_; } - - private: - bool intersected_; - Region& region_; - const HitTestLocation& location_; -}; - -} // unnamed namespace - bool LayoutInline::HitTestCulledInline( HitTestResult& result, const HitTestLocation& location_in_container, @@ -1119,10 +1068,15 @@ HitTestLocation adjusted_location(location_in_container, -ToLayoutSize(accumulated_offset)); - Region region_result; - HitTestCulledInlinesGeneratorContext context(region_result, - adjusted_location); + bool intersected = false; + auto yield = [&adjusted_location, ®ion_result, + &intersected](const PhysicalRect& rect) { + if (adjusted_location.Intersects(rect.ToLayoutRect())) { + intersected = true; + region_result.Unite(EnclosingIntRect(rect)); + } + }; // NG generates purely physical rectangles here, while legacy sets the block // offset on the rectangles relatively to the block-start. NG is doing the @@ -1134,21 +1088,21 @@ const auto& traversal_root = To<NGPhysicalContainerFragment>(container_fragment->PhysicalFragment()); DCHECK(traversal_root.IsInline() || traversal_root.IsLineBox()); - const LayoutPoint root_offset = - container_fragment->InlineOffsetToContainerBox().ToLayoutPoint(); + PhysicalOffset root_offset = + container_fragment->InlineOffsetToContainerBox(); const auto& descendants = NGInlineFragmentTraversal::SelfFragmentsOf(traversal_root, this); for (const auto& descendant : descendants) { - LayoutRect rect = descendant.RectInContainerBox().ToLayoutRect(); - rect.MoveBy(root_offset); - context(rect); + PhysicalRect rect = descendant.RectInContainerBox(); + rect.Move(root_offset); + yield(rect); } } else { DCHECK(!ContainingNGBlockFlow()); - GenerateCulledLineBoxRects(context, this); + CollectCulledLineBoxRects(yield); } - if (context.Intersected()) { + if (intersected) { UpdateHitTestResult(result, adjusted_location.Point()); if (result.AddNodeToListBasedTestResult(GetNode(), adjusted_location, region_result) == kStopHitTesting) @@ -1188,20 +1142,6 @@ return LayoutBoxModelObject::PositionForPoint(point); } -namespace { - -class LinesBoundingBoxGeneratorContext { - public: - LinesBoundingBoxGeneratorContext(FloatRect& rect) : rect_(rect) {} - void operator()(const FloatRect& rect) { rect_.UniteIfNonZero(rect); } - void operator()(const LayoutRect& rect) { operator()(FloatRect(rect)); } - - private: - FloatRect& rect_; -}; - -} // unnamed namespace - PhysicalRect LayoutInline::PhysicalLinesBoundingBox() const { if (IsInLayoutNGInlineFormattingContext()) { const NGPhysicalBoxFragment* box_fragment = @@ -1218,12 +1158,11 @@ if (!AlwaysCreateLineBoxes()) { DCHECK(!FirstLineBox()); - FloatRect float_result; - LinesBoundingBoxGeneratorContext context(float_result); - GenerateCulledLineBoxRects(context, this); - if (UNLIKELY(HasFlippedBlocksWritingMode())) - ContainingBlock()->FlipForWritingMode(float_result); - return PhysicalRect::EnclosingRect(float_result); + PhysicalRect bounding_box; + CollectLineBoxRects([&bounding_box](const PhysicalRect& rect) { + bounding_box.UniteIfNonZero(rect); + }); + return bounding_box; } LayoutRect result; @@ -1258,9 +1197,7 @@ result = LayoutRect(x, y, width, height); } - if (UNLIKELY(HasFlippedBlocksWritingMode())) - ContainingBlock()->FlipForWritingMode(result); - return PhysicalRect(result); + return FlipForWritingMode(result); } InlineBox* LayoutInline::CulledInlineFirstLineBox() const { @@ -1312,10 +1249,9 @@ } LayoutRect LayoutInline::CulledInlineVisualOverflowBoundingBox() const { - FloatRect float_result; - LinesBoundingBoxGeneratorContext context(float_result); - GenerateCulledLineBoxRects(context, this); - LayoutRect result(EnclosingLayoutRect(float_result)); + LayoutRect result; + CollectCulledLineBoxRectsInFlippedBlocksDirection( + [&result](const LayoutRect& r) { result.UniteIfNonZero(r); }, this); bool is_horizontal = StyleRef().IsHorizontalWritingMode(); for (LayoutObject* curr = FirstChild(); curr; curr = curr->NextSibling()) { if (curr->IsFloatingOrOutOfFlowPositioned()) @@ -1363,10 +1299,7 @@ result->Unite(child_rect); }, &result); - LayoutRect rect = result.ToLayoutRect(); - if (HasFlippedBlocksWritingMode()) - ContainingBlock()->FlipForWritingMode(rect); - return rect; + return FlipForWritingMode(result); } if (!AlwaysCreateLineBoxes()) @@ -1403,21 +1336,16 @@ } PhysicalRect LayoutInline::VisualRectInDocument(VisualRectFlags flags) const { - LayoutRect rect; + PhysicalRect rect; if (!Continuation()) { - rect = VisualOverflowRect(); + rect = FlipForWritingMode(VisualOverflowRect()); } else { // Should also cover continuations. - Vector<LayoutRect> outlines; - AddOutlineRects(outlines, LayoutPoint(), - NGOutlineType::kIncludeBlockVisualOverflow); - rect = UnionRect(outlines); + rect = UnionRect(OutlineRects(PhysicalOffset(), + NGOutlineType::kIncludeBlockVisualOverflow)); } - if (UNLIKELY(HasFlippedBlocksWritingMode())) - ContainingBlock()->FlipForWritingMode(rect); - PhysicalRect physical_rect = PhysicalRectToBeNoop(rect); - MapToVisualRectInAncestorSpace(View(), physical_rect, flags); - return physical_rect; + MapToVisualRectInAncestorSpace(View(), rect, flags); + return rect; } PhysicalRect LayoutInline::LocalVisualRectIgnoringVisibility() const { @@ -1432,33 +1360,31 @@ // VisualOverflowRect() is in "physical coordinates with flipped blocks // direction", while all "VisualRect"s are in pure physical coordinates. - auto rect = VisualOverflowRect(); - if (UNLIKELY(HasFlippedBlocksWritingMode())) - ContainingBlock()->FlipForWritingMode(rect); - return PhysicalRect(rect); + return FlipForWritingMode(VisualOverflowRect()); } LayoutRect LayoutInline::VisualOverflowRect() const { LayoutRect overflow_rect = LinesVisualOverflowBoundingBox(); LayoutUnit outline_outset(StyleRef().OutlineOutsetExtent()); if (outline_outset) { - Vector<LayoutRect> rects; + Vector<PhysicalRect> rects; if (GetDocument().InNoQuirksMode()) { // We have already included outline extents of line boxes in // linesVisualOverflowBoundingBox(), so the following just add outline // rects for children and continuations. AddOutlineRectsForChildrenAndContinuations( - rects, LayoutPoint(), OutlineRectsShouldIncludeBlockVisualOverflow()); + rects, PhysicalOffset(), + OutlineRectsShouldIncludeBlockVisualOverflow()); } else { // In non-standard mode, because the difference in // LayoutBlock::minLineHeightForReplacedObject(), // linesVisualOverflowBoundingBox() may not cover outline rects of lines // containing replaced objects. - AddOutlineRects(rects, LayoutPoint(), + AddOutlineRects(rects, PhysicalOffset(), OutlineRectsShouldIncludeBlockVisualOverflow()); } if (!rects.IsEmpty()) { - LayoutRect outline_rect = UnionRectEvenIfEmpty(rects); + LayoutRect outline_rect = FlipForWritingMode(UnionRectEvenIfEmpty(rects)); outline_rect.Inflate(outline_outset); overflow_rect.Unite(outline_rect); } @@ -1466,22 +1392,19 @@ return overflow_rect; } -LayoutRect LayoutInline::ReferenceBoxForClipPath() const { +PhysicalRect LayoutInline::ReferenceBoxForClipPath() const { // The spec just says to use the border box as clip-path reference box. It // doesn't say what to do if there are multiple lines. Gecko uses the first // fragment in that case. We'll do the same here (but correctly with respect // to writing-mode - Gecko has some issues there). // See crbug.com/641907 - LayoutRect bounding_box; if (const NGPaintFragment* fragment = FirstInlineFragment()) { - bounding_box.SetLocation( - fragment->InlineOffsetToContainerBox().ToLayoutPoint()); - bounding_box.SetSize(fragment->Size().ToLayoutSize()); - } else if (const InlineFlowBox* flow_box = FirstLineBox()) { - bounding_box = flow_box->FrameRect(); - ContainingBlock()->FlipForWritingMode(bounding_box); + return PhysicalRect(fragment->InlineOffsetToContainerBox(), + fragment->Size()); } - return bounding_box; + if (const InlineFlowBox* flow_box = FirstLineBox()) + return FlipForWritingMode(flow_box->FrameRect()); + return PhysicalRect(); } bool LayoutInline::MapToVisualRectInAncestorSpaceInternal( @@ -1719,41 +1642,22 @@ SetShouldDoFullPaintInvalidation(PaintInvalidationReason::kImage); } -namespace { - -class AbsoluteLayoutRectsGeneratorContext { - public: - AbsoluteLayoutRectsGeneratorContext(Vector<LayoutRect>& rects, - const LayoutPoint& accumulated_offset) - : rects_(rects), accumulated_offset_(accumulated_offset) {} - - void operator()(const FloatRect& rect) { operator()(LayoutRect(rect)); } - void operator()(const LayoutRect& rect) { - LayoutRect layout_rect(rect); - layout_rect.MoveBy(accumulated_offset_); - rects_.push_back(layout_rect); - } - - private: - Vector<LayoutRect>& rects_; - const LayoutPoint& accumulated_offset_; -}; - -} // unnamed namespace - void LayoutInline::AddOutlineRects( - Vector<LayoutRect>& rects, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>& rects, + const PhysicalOffset& additional_offset, NGOutlineType include_block_overflows) const { - AbsoluteLayoutRectsGeneratorContext context(rects, additional_offset); - GenerateLineBoxRects(context); + CollectLineBoxRects([&rects, &additional_offset](const PhysicalRect& r) { + auto rect = r; + rect.Move(additional_offset); + rects.push_back(rect); + }); AddOutlineRectsForChildrenAndContinuations(rects, additional_offset, include_block_overflows); } void LayoutInline::AddOutlineRectsForChildrenAndContinuations( - Vector<LayoutRect>& rects, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>& rects, + const PhysicalOffset& additional_offset, NGOutlineType include_block_overflows) const { AddOutlineRectsForNormalChildren(rects, additional_offset, include_block_overflows); @@ -1762,8 +1666,8 @@ } void LayoutInline::AddOutlineRectsForContinuations( - Vector<LayoutRect>& rects, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>& rects, + const PhysicalOffset& additional_offset, NGOutlineType include_block_overflows) const { if (LayoutBoxModelObject* continuation = Continuation()) { if (continuation->NeedsLayout()) { @@ -1777,21 +1681,20 @@ // all. Yet, here we are. Bail. return; } - LayoutPoint offset = additional_offset; + PhysicalOffset offset = additional_offset; if (continuation->IsInline()) - offset += continuation->ContainingBlock()->Location(); + offset += continuation->ContainingBlock()->PhysicalLocation(); else - offset += ToLayoutBox(continuation)->Location(); - offset -= ContainingBlock()->Location(); + offset += ToLayoutBox(continuation)->PhysicalLocation(); + offset -= ContainingBlock()->PhysicalLocation(); continuation->AddOutlineRects(rects, offset, include_block_overflows); } } FloatRect LayoutInline::LocalBoundingBoxRectForAccessibility() const { - Vector<LayoutRect> rects; - AddOutlineRects(rects, LayoutPoint(), - NGOutlineType::kIncludeBlockVisualOverflow); - return FloatRect(UnionRect(rects)); + Vector<PhysicalRect> rects = OutlineRects( + PhysicalOffset(), NGOutlineType::kIncludeBlockVisualOverflow); + return FloatRect(FlipForWritingMode(UnionRect(rects).ToLayoutRect())); } void LayoutInline::AddAnnotatedRegions(Vector<AnnotatedRegionValue>& regions) { @@ -1850,6 +1753,30 @@ LayoutBoxModelObject::MapLocalToAncestor(ancestor, transform_state, mode); } +LayoutRect LayoutInline::FlipForWritingMode( + const PhysicalRect& r, + const LayoutBlock* block_for_flipping) const { + LayoutRect rect = r.ToLayoutRect(); + if (UNLIKELY(NeedsFlipForWritingMode())) { + DCHECK(!block_for_flipping || block_for_flipping == ContainingBlock()); + (block_for_flipping ? block_for_flipping : ContainingBlock()) + ->FlipForWritingMode(rect); + } + return rect; +} + +PhysicalRect LayoutInline::FlipForWritingMode( + const LayoutRect& r, + const LayoutBlock* block_for_flipping) const { + LayoutRect rect = r; + if (UNLIKELY(NeedsFlipForWritingMode())) { + DCHECK(!block_for_flipping || block_for_flipping == ContainingBlock()); + (block_for_flipping ? block_for_flipping : ContainingBlock()) + ->FlipForWritingMode(rect); + } + return PhysicalRect(rect); +} + PhysicalRect LayoutInline::DebugRect() const { return PhysicalRect(EnclosingIntRect(PhysicalLinesBoundingBox())); }
diff --git a/third_party/blink/renderer/core/layout/layout_inline.h b/third_party/blink/renderer/core/layout/layout_inline.h index db3ea86f..96519324 100644 --- a/third_party/blink/renderer/core/layout/layout_inline.h +++ b/third_party/blink/renderer/core/layout/layout_inline.h
@@ -119,10 +119,6 @@ static LayoutInline* CreateAnonymous(Document*); - // Create an anonymous inline box for ::first-line. The instance created by - // this function has IsFirstLineAnonymous() == true. - static LayoutInline* CreateAnonymousForFirstLine(Document*); - LayoutObject* FirstChild() const { DCHECK_EQ(Children(), VirtualChildren()); return Children()->FirstChild(); @@ -152,7 +148,7 @@ PhysicalRect PhysicalLinesBoundingBox() const; LayoutRect VisualOverflowRect() const final; - LayoutRect ReferenceBoxForClipPath() const; + PhysicalRect ReferenceBoxForClipPath() const; InlineFlowBox* CreateAndAppendInlineFlowBox(); @@ -190,17 +186,17 @@ PhysicalOffset OffsetForInFlowPositionedInline(const LayoutBox& child) const; - void AddOutlineRects(Vector<LayoutRect>&, - const LayoutPoint& additional_offset, + void AddOutlineRects(Vector<PhysicalRect>&, + const PhysicalOffset& additional_offset, NGOutlineType) const final; // The following methods are called from the container if it has already added // outline rects for line boxes and/or children of this LayoutInline. void AddOutlineRectsForChildrenAndContinuations( - Vector<LayoutRect>&, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>&, + const PhysicalOffset& additional_offset, NGOutlineType) const; - void AddOutlineRectsForContinuations(Vector<LayoutRect>&, - const LayoutPoint& additional_offset, + void AddOutlineRectsForContinuations(Vector<PhysicalRect>&, + const PhysicalOffset& additional_offset, NGOutlineType) const; using LayoutBoxModelObject::Continuation; @@ -299,11 +295,19 @@ // line boxes. LayoutRect LinesVisualOverflowBoundingBox() const; - template <typename GeneratorContext> - void GenerateLineBoxRects(GeneratorContext& yield) const; - template <typename GeneratorContext> - void GenerateCulledLineBoxRects(GeneratorContext& yield, - const LayoutInline* container) const; + // PhysicalRectCollector should be like a function: + // void (const PhysicalRect&). + template <typename PhysicalRectCollector> + void CollectLineBoxRects(const PhysicalRectCollector&) const; + template <typename PhysicalRectCollector> + void CollectCulledLineBoxRects(const PhysicalRectCollector&) const; + + // FlippedRectCollector should be like a function: + // void (const LayoutRect&); + template <typename FlippedRectCollector> + void CollectCulledLineBoxRectsInFlippedBlocksDirection( + const FlippedRectCollector&, + const LayoutInline* container) const; void AddChildToContinuation(LayoutObject* new_child, LayoutObject* before_child); @@ -395,6 +399,22 @@ base::Optional<PhysicalOffset> FirstLineBoxTopLeftInternal() const; PhysicalOffset AnchorPhysicalLocation() const; + bool NeedsFlipForWritingMode() const { + return HasFlippedBlocksWritingMode() && !IsSVG(); + } + // These functions flip the input rect in ContainingBlock() if + // NeedsFlipForWritingMode() is true. If |block_for_flipping| is not null, + // it should be ContainingBlock(), otherwise the function will call + // ContainingBlock() by themselves. The caller should prepare + // |block_for_flipping| if it will loop through many rects to flip to avoid + // the cost of repeated ContainingBlock() calls. + ALWAYS_INLINE WARN_UNUSED_RESULT LayoutRect + FlipForWritingMode(const PhysicalRect& r, + const LayoutBlock* block_for_flipping = nullptr) const; + ALWAYS_INLINE WARN_UNUSED_RESULT PhysicalRect + FlipForWritingMode(const LayoutRect& r, + const LayoutBlock* block_for_flipping = nullptr) const; + LayoutObjectChildList children_; union {
diff --git a/third_party/blink/renderer/core/layout/layout_inline_test.cc b/third_party/blink/renderer/core/layout/layout_inline_test.cc index efeb91a..5aa2986 100644 --- a/third_party/blink/renderer/core/layout/layout_inline_test.cc +++ b/third_party/blink/renderer/core/layout/layout_inline_test.cc
@@ -285,7 +285,7 @@ </style> <div> <span>xx<br> - <span id="target" tabindex="-1">yy + <span id="target">yy <div style="width:111px;height:222px;background:yellow"></div> yy </span> @@ -325,6 +325,51 @@ EXPECT_EQ(expected, target->VisualRectInDocument(kUseGeometryMapper)); } +TEST_P(ParameterizedLayoutInlineTest, VisualRectInDocumentSVGTspan) { + LoadAhem(); + SetBodyInnerHTML(R"HTML( + <style> + body { + margin:0px; + font: 20px/20px Ahem; + } + </style> + <svg> + <text x="10" y="50" width="100"> + <tspan id="target" dx="15" dy="25">tspan</tspan> + </text> + </svg> + )HTML"); + + LayoutInline* target = ToLayoutInline(GetLayoutObjectByElementId("target")); + const int ascent = 16; + PhysicalRect expected(10 + 15, 50 + 25 - ascent, 20 * 5, 20); + EXPECT_EQ(expected, target->VisualRectInDocument()); + EXPECT_EQ(expected, target->VisualRectInDocument(kUseGeometryMapper)); +} + +TEST_P(ParameterizedLayoutInlineTest, VisualRectInDocumentSVGTspanTB) { + LoadAhem(); + SetBodyInnerHTML(R"HTML( + <style> + body { + margin:0px; + font: 20px/20px Ahem; + } + </style> + <svg> + <text x="50" y="10" width="100" writing-mode="tb"> + <tspan id="target" dx="15" dy="25">tspan</tspan> + </text> + </svg> + )HTML"); + + LayoutInline* target = ToLayoutInline(GetLayoutObjectByElementId("target")); + PhysicalRect expected(50 + 15 - 20 / 2, 10 + 25, 20, 20 * 5); + EXPECT_EQ(expected, target->VisualRectInDocument()); + EXPECT_EQ(expected, target->VisualRectInDocument(kUseGeometryMapper)); +} + // When adding focus ring rects, we should avoid adding duplicated rect for // continuations. TEST_P(ParameterizedLayoutInlineTest, FocusRingRecursiveContinuations) { @@ -349,16 +394,90 @@ </span> )HTML"); - Vector<LayoutRect> rects; - GetLayoutObjectByElementId("target")->AddOutlineRects( - rects, LayoutPoint(), NGOutlineType::kIncludeBlockVisualOverflow); + auto rects = GetLayoutObjectByElementId("target")->OutlineRects( + PhysicalOffset(), NGOutlineType::kIncludeBlockVisualOverflow); - EXPECT_THAT(rects, - UnorderedElementsAre(LayoutRect(0, 0, 100, 20), // 'SPAN0' - LayoutRect(0, 20, 800, 40), // div DIV1 - LayoutRect(0, 20, 200, 20), // 'DIV1 SPAN1' - LayoutRect(0, 40, 800, 20), // div DIV2 - LayoutRect(0, 40, 80, 20))); // 'DIV2' + EXPECT_THAT( + rects, UnorderedElementsAre(PhysicalRect(0, 0, 100, 20), // 'SPAN0' + PhysicalRect(0, 20, 800, 40), // div DIV1 + PhysicalRect(0, 20, 200, 20), // 'DIV1 SPAN1' + PhysicalRect(0, 40, 800, 20), // div DIV2 + PhysicalRect(0, 40, 80, 20))); // 'DIV2' +} + +// When adding focus ring rects, we should avoid adding line box rects of +// recursive inlines repeatedly. +TEST_P(ParameterizedLayoutInlineTest, FocusRingRecursiveInlinesVerticalRL) { + // TODO(crbug.com/835484): The test is broken for LayoutNG. + if (RuntimeEnabledFeatures::LayoutNGEnabled()) + return; + + LoadAhem(); + SetBodyInnerHTML(R"HTML( + <style> + body { + margin: 0; + font: 20px/20px Ahem; + } + </style> + <div style="width: 200px; height: 200px; writing-mode: vertical-rl"> + <span id="target"> + <b><b><b><i><i><i>INLINE</i></i> <i><i>TEXT</i></i> + <div style="position: relative; top: -5px"> + <b><b>BLOCK</b> <i>CONTENTS</i></b> + </div> + </i></b></b></b> + </span> + </div> + )HTML"); + + auto* target = GetLayoutObjectByElementId("target"); + auto rects = target->OutlineRects(target->FirstFragment().PaintOffset(), + NGOutlineType::kIncludeBlockVisualOverflow); + EXPECT_THAT(rects, UnorderedElementsAre( + PhysicalRect(180, 0, 20, 120), // 'INLINE' + PhysicalRect(160, 0, 20, 80), // 'TEXT' + PhysicalRect(120, -5, 40, 200), // the inner div + PhysicalRect(140, -5, 20, 100), // 'BLOCK' + PhysicalRect(120, -5, 20, 160))); // 'CONTENTS' +} + +// When adding focus ring rects, we should avoid adding duplicated rect for +// continuations. +TEST_P(ParameterizedLayoutInlineTest, + FocusRingRecursiveContinuationsVerticalRL) { + // TODO(crbug.com/835484): The test is broken for LayoutNG. + if (RuntimeEnabledFeatures::LayoutNGEnabled()) + return; + + LoadAhem(); + SetBodyInnerHTML(R"HTML( + <style> + body { + margin: 0; + font: 20px/20px Ahem; + } + </style> + <div style="width: 200px; height: 400px; writing-mode: vertical-rl"> + <span id="target">SPAN0 + <div>DIV1 + <span>SPAN1 + <div>DIV2</div> + </span> + </div> + </span> + </div> + )HTML"); + + auto* target = GetLayoutObjectByElementId("target"); + auto rects = target->OutlineRects(target->FirstFragment().PaintOffset(), + NGOutlineType::kIncludeBlockVisualOverflow); + EXPECT_THAT(rects, UnorderedElementsAre( + PhysicalRect(180, 0, 20, 100), // 'SPAN0' + PhysicalRect(140, 0, 40, 400), // div DIV1 + PhysicalRect(160, 0, 20, 200), // 'DIV1 SPAN1' + PhysicalRect(140, 0, 20, 400), // div DIV2 + PhysicalRect(140, 0, 20, 80))); // 'DIV2' } // When adding focus ring rects, we should avoid adding line box rects of @@ -387,16 +506,15 @@ </div> )HTML"); - Vector<LayoutRect> rects; - GetLayoutObjectByElementId("target")->AddOutlineRects( - rects, LayoutPoint(), NGOutlineType::kIncludeBlockVisualOverflow); + auto rects = GetLayoutObjectByElementId("target")->OutlineRects( + PhysicalOffset(), NGOutlineType::kIncludeBlockVisualOverflow); - EXPECT_THAT(rects, - UnorderedElementsAre(LayoutRect(0, 0, 120, 20), // 'INLINE' - LayoutRect(0, 20, 80, 20), // 'TEXT' - LayoutRect(0, 35, 200, 40), // the inner div - LayoutRect(0, 35, 100, 20), // 'BLOCK' - LayoutRect(0, 55, 160, 20))); // 'CONTENTS' + EXPECT_THAT(rects, UnorderedElementsAre( + PhysicalRect(0, 0, 120, 20), // 'INLINE' + PhysicalRect(0, 20, 80, 20), // 'TEXT' + PhysicalRect(0, 35, 200, 40), // the inner div + PhysicalRect(0, 35, 100, 20), // 'BLOCK' + PhysicalRect(0, 55, 160, 20))); // 'CONTENTS' } TEST_P(ParameterizedLayoutInlineTest,
diff --git a/third_party/blink/renderer/core/layout/layout_media.cc b/third_party/blink/renderer/core/layout/layout_media.cc index 4c2efff..a20f7b19 100644 --- a/third_party/blink/renderer/core/layout/layout_media.cc +++ b/third_party/blink/renderer/core/layout/layout_media.cc
@@ -130,7 +130,7 @@ } void LayoutMedia::PaintReplaced(const PaintInfo&, - const LayoutPoint& paint_offset) const {} + const PhysicalOffset& paint_offset) const {} LayoutUnit LayoutMedia::ComputePanelWidth(const LayoutRect& media_rect) const { // TODO(mlamouri): we don't know if the main frame has an horizontal scrollbar
diff --git a/third_party/blink/renderer/core/layout/layout_media.h b/third_party/blink/renderer/core/layout/layout_media.h index ac235d2..98d8a95 100644 --- a/third_party/blink/renderer/core/layout/layout_media.h +++ b/third_party/blink/renderer/core/layout/layout_media.h
@@ -80,7 +80,7 @@ bool IsImage() const final { return false; } void PaintReplaced(const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; bool BackgroundShouldAlwaysBeClipped() const final { return false; }
diff --git a/third_party/blink/renderer/core/layout/layout_multi_column_set.cc b/third_party/blink/renderer/core/layout/layout_multi_column_set.cc index d232f3c8..b17a217 100644 --- a/third_party/blink/renderer/core/layout/layout_multi_column_set.cc +++ b/third_party/blink/renderer/core/layout/layout_multi_column_set.cc
@@ -504,8 +504,9 @@ return FirstFragmentainerGroup().ActualColumnCount(); } -void LayoutMultiColumnSet::PaintObject(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { +void LayoutMultiColumnSet::PaintObject( + const PaintInfo& paint_info, + const PhysicalOffset& paint_offset) const { MultiColumnSetPainter(*this).PaintObject(paint_info, paint_offset); }
diff --git a/third_party/blink/renderer/core/layout/layout_multi_column_set.h b/third_party/blink/renderer/core/layout/layout_multi_column_set.h index af3f952..505e0bf 100644 --- a/third_party/blink/renderer/core/layout/layout_multi_column_set.h +++ b/third_party/blink/renderer/core/layout/layout_multi_column_set.h
@@ -253,7 +253,7 @@ PositionWithAffinity PositionForPoint(const LayoutPoint&) const override; void PaintObject(const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; void ComputeVisualOverflow(bool recompute_floats) final;
diff --git a/third_party/blink/renderer/core/layout/layout_object.cc b/third_party/blink/renderer/core/layout/layout_object.cc index 85e9860..b9ade64 100644 --- a/third_party/blink/renderer/core/layout/layout_object.cc +++ b/third_party/blink/renderer/core/layout/layout_object.cc
@@ -338,10 +338,6 @@ return false; } -bool LayoutObject::VirtualIsFirstLineAnonymous() const { - return false; -} - bool LayoutObject::IsHR() const { return IsHTMLHRElement(GetNode()); } @@ -1505,7 +1501,7 @@ this != &paint_invalidation_container; } -void LayoutObject::InvalidatePaintRectangle(const LayoutRect& dirty_rect) { +void LayoutObject::InvalidatePaintRectangle(const PhysicalRect& dirty_rect) { DCHECK_NE(GetDocument().Lifecycle().GetState(), DocumentLifecycle::kInPaint); if (dirty_rect.IsEmpty()) @@ -1604,7 +1600,7 @@ // FirstFragment().PaintOffset() is relative to the transform space defined by // FirstFragment().LocalBorderBoxProperties() (if this == property_container) // or property_container->FirstFragment().ContentsProperties(). - rect.Move(PhysicalOffsetToBeNoop(FirstFragment().PaintOffset())); + rect.Move(FirstFragment().PaintOffset()); if (property_container != ancestor) { FloatClipRect clip_rect((FloatRect(rect))); const auto& local_state = @@ -1618,7 +1614,7 @@ : kNonInclusiveIntersect); rect = PhysicalRect::EnclosingRect(clip_rect.Rect()); } - rect.Move(-PhysicalOffsetToBeNoop(ancestor->FirstFragment().PaintOffset())); + rect.offset -= ancestor->FirstFragment().PaintOffset(); return true; } @@ -2799,21 +2795,23 @@ return transform_state.LastPlanarPoint(); } -void LayoutObject::LocalToAncestorRects(Vector<LayoutRect>& rects, - const LayoutBoxModelObject* ancestor, - const LayoutPoint& pre_offset, - const LayoutPoint& post_offset) const { +void LayoutObject::LocalToAncestorRects( + Vector<PhysicalRect>& rects, + const LayoutBoxModelObject* ancestor, + const PhysicalOffset& pre_offset, + const PhysicalOffset& post_offset) const { for (wtf_size_t i = 0; i < rects.size(); ++i) { - LayoutRect& rect = rects[i]; - rect.MoveBy(pre_offset); + PhysicalRect& rect = rects[i]; + rect.Move(pre_offset); FloatQuad container_quad = LocalToAncestorQuad(FloatQuad(FloatRect(rect)), ancestor); - LayoutRect container_rect = LayoutRect(container_quad.BoundingBox()); + PhysicalRect container_rect = + PhysicalRect::EnclosingRect(container_quad.BoundingBox()); if (container_rect.IsEmpty()) { rects.EraseAt(i--); continue; } - container_rect.MoveBy(post_offset); + container_rect.Move(post_offset); rects[i] = container_rect; } } @@ -3390,25 +3388,10 @@ return first_line_block->GetUncachedPseudoStyle( PseudoStyleRequest(kPseudoIdFirstLine), style); } - } else if (layout_object_for_first_line_style->IsLayoutInline()) { - if (layout_object_for_first_line_style->IsAnonymous()) { - // Anonymous inline box for ::first-line should inherit background. - if (ToLayoutInline(layout_object_for_first_line_style) - ->IsFirstLineAnonymous()) { - // TODO(kojii): This function must return a style that is referred by - // someone else, and that we can't create an inherited style here. - // Returning parent's style seems to work for now. - return FirstLineStyleForCachedUncachedType( - type, layout_object->Parent(), style); - } - // TODO(kojii): This does not look correct, but creating a first-line - // style for anonymous inline box does not seem easy for now. - return nullptr; - } - if (layout_object_for_first_line_style->GetNode() - ->IsFirstLetterPseudoElement()) { - return nullptr; - } + } else if (!layout_object_for_first_line_style->IsAnonymous() && + layout_object_for_first_line_style->IsLayoutInline() && + !layout_object_for_first_line_style->GetNode() + ->IsFirstLetterPseudoElement()) { const ComputedStyle* parent_style = layout_object_for_first_line_style->Parent()->FirstLineStyle(); if (parent_style != layout_object_for_first_line_style->Parent()->Style()) { @@ -3873,7 +3856,7 @@ #if DCHECK_IS_ON() DCHECK(!ShouldCheckForPaintInvalidation() || PaintInvalidationStateIsDirty()); #endif - fragment_.SetPartialInvalidationLocalRect(LayoutRect()); + fragment_.SetPartialInvalidationLocalRect(PhysicalRect()); if (!ShouldDelayFullPaintInvalidation()) { full_paint_invalidation_reason_ = PaintInvalidationReason::kNone; bitfields_.SetBackgroundNeedsFullPaintInvalidation(false); @@ -4066,21 +4049,11 @@ return visual_rect; } -Vector<LayoutRect> LayoutObject::PhysicalOutlineRects( - const LayoutPoint& additional_offset, +Vector<PhysicalRect> LayoutObject::OutlineRects( + const PhysicalOffset& additional_offset, NGOutlineType outline_type) const { - Vector<LayoutRect> outline_rects; + Vector<PhysicalRect> outline_rects; AddOutlineRects(outline_rects, additional_offset, outline_type); - if (IsSVGChild() || !HasFlippedBlocksWritingMode()) - return outline_rects; - - const auto* writing_mode_container = - IsBox() ? ToLayoutBox(this) : ContainingBlock(); - for (auto& r : outline_rects) { - r.MoveBy(-additional_offset); - writing_mode_container->FlipForWritingMode(r); - r.MoveBy(additional_offset); - } return outline_rects; }
diff --git a/third_party/blink/renderer/core/layout/layout_object.h b/third_party/blink/renderer/core/layout/layout_object.h index fe56663..a0fddf6 100644 --- a/third_party/blink/renderer/core/layout/layout_object.h +++ b/third_party/blink/renderer/core/layout/layout_object.h
@@ -877,11 +877,6 @@ !IsListMarker() && !IsLayoutFlowThread() && !IsLayoutMultiColumnSet(); } - // True if this is an anonymous inline box for ::first-line that wraps the - // whole inline formatting context. - bool IsFirstLineAnonymous() const { - return IsAnonymous() && VirtualIsFirstLineAnonymous(); - } // If node has been split into continuations, it returns the first layout // object generated for the node. const LayoutObject* ContinuationRoot() const { @@ -1542,10 +1537,10 @@ FloatPoint LocalToAncestorPoint(const FloatPoint&, const LayoutBoxModelObject* ancestor, MapCoordinatesFlags = 0) const; - void LocalToAncestorRects(Vector<LayoutRect>&, + void LocalToAncestorRects(Vector<PhysicalRect>&, const LayoutBoxModelObject* ancestor, - const LayoutPoint& pre_offset, - const LayoutPoint& post_offset) const; + const PhysicalOffset& pre_offset, + const PhysicalOffset& post_offset) const; // Convert a local quad into the coordinate system of container, not // include transforms. See localToAncestorQuad for details. @@ -1669,7 +1664,7 @@ // Invalidate the raster of a specific sub-rectangle within the object. The // rect is in the object's local coordinate space. This is useful e.g. when // a small region of a canvas changes. - void InvalidatePaintRectangle(const LayoutRect&); + void InvalidatePaintRectangle(const PhysicalRect&); // Returns the rect that should have raster invalidated whenever this object // changes. The rect is in the coordinate space of the document's scrolling @@ -1890,16 +1885,16 @@ HasFilterInducingProperty() || StyleRef().HasBlendMode(); } + Vector<PhysicalRect> OutlineRects(const PhysicalOffset& additional_offset, + NGOutlineType) const; + // Collects rectangles that the outline of this object would be drawing along // the outside of, even if the object isn't styled with a outline for now. The // rects also cover continuations. - virtual void AddOutlineRects(Vector<LayoutRect>&, - const LayoutPoint& additional_offset, + virtual void AddOutlineRects(Vector<PhysicalRect>&, + const PhysicalOffset& additional_offset, NGOutlineType) const {} - Vector<LayoutRect> PhysicalOutlineRects(const LayoutPoint& additional_offset, - NGOutlineType) const; - // For history and compatibility reasons, we draw outline:auto (for focus // rings) and normal style outline differently. // Focus rings enclose block visual overflows (of line boxes and descendants), @@ -2272,7 +2267,7 @@ IntRect SelectionVisualRect() const { return fragment_.SelectionVisualRect(); } - LayoutRect PartialInvalidationLocalRect() const { + PhysicalRect PartialInvalidationLocalRect() const { return fragment_.PartialInvalidationLocalRect(); } @@ -2414,11 +2409,6 @@ }; virtual bool IsOfType(LayoutObjectType type) const { return false; } - // True if this is an anonymous inline box for ::first-line that wraps the - // whole inline formatting context. This is for subclasses to override. - // Callers should use |IsFirstLineAnonymous()|. - virtual bool VirtualIsFirstLineAnonymous() const; - // Updates only the local style ptr of the object. Does not update the state // of the object, and so only should be called when the style is known not to // have changed (or from SetStyle).
diff --git a/third_party/blink/renderer/core/layout/layout_object_test.cc b/third_party/blink/renderer/core/layout/layout_object_test.cc index ae2f36e..248959a8 100644 --- a/third_party/blink/renderer/core/layout/layout_object_test.cc +++ b/third_party/blink/renderer/core/layout/layout_object_test.cc
@@ -978,15 +978,10 @@ static_cast<ImageObserver*>(image_resource_content) ->Changed(image_resource_content->GetImage()); - if (RuntimeEnabledFeatures::LayoutNGEnabled()) { - // The block itself doesn't paint the first line, so we don't need to - // invalidate it for the image change in the first line style. - EXPECT_FALSE(target_object->ShouldDoFullPaintInvalidation()); - } else { - // In legacy layout mode, the block is the layout object of the first line's - // root line box, so we invalidate it. - EXPECT_TRUE(target_object->ShouldDoFullPaintInvalidation()); - } + // The block is the layout object of the first line's root line box, so we + // invalidate it. + EXPECT_TRUE(target_object->ShouldDoFullPaintInvalidation()); + auto* first_line1 = GetDocument().getElementById("first-line1")->GetLayoutObject(); EXPECT_TRUE(first_line1->ShouldDoFullPaintInvalidation());
diff --git a/third_party/blink/renderer/core/layout/layout_replaced.h b/third_party/blink/renderer/core/layout/layout_replaced.h index 41f4a41..8ced526 100644 --- a/third_party/blink/renderer/core/layout/layout_replaced.h +++ b/third_party/blink/renderer/core/layout/layout_replaced.h
@@ -79,7 +79,7 @@ static const int kDefaultHeight; bool CanHaveChildren() const override { return false; } virtual void PaintReplaced(const PaintInfo&, - const LayoutPoint& paint_offset) const {} + const PhysicalOffset& paint_offset) const {} PhysicalRect LocalSelectionVisualRect() const final;
diff --git a/third_party/blink/renderer/core/layout/layout_table.cc b/third_party/blink/renderer/core/layout/layout_table.cc index d185bf6..039731d9 100644 --- a/third_party/blink/renderer/core/layout/layout_table.cc +++ b/third_party/blink/renderer/core/layout/layout_table.cc
@@ -1012,11 +1012,11 @@ } void LayoutTable::PaintObject(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { TablePainter(*this).PaintObject(paint_info, paint_offset); } -void LayoutTable::SubtractCaptionRect(LayoutRect& rect) const { +void LayoutTable::SubtractCaptionRect(PhysicalRect& rect) const { for (unsigned i = 0; i < captions_.size(); i++) { LayoutUnit caption_logical_height = captions_[i]->LogicalHeight() + captions_[i]->MarginBefore() + @@ -1025,13 +1025,13 @@ (captions_[i]->StyleRef().CaptionSide() != ECaptionSide::kBottom) ^ StyleRef().IsFlippedBlocksWritingMode(); if (StyleRef().IsHorizontalWritingMode()) { - rect.SetHeight(rect.Height() - caption_logical_height); + rect.size.height -= caption_logical_height; if (caption_is_before) - rect.Move(LayoutUnit(), caption_logical_height); + rect.offset.top += caption_logical_height; } else { - rect.SetWidth(rect.Width() - caption_logical_height); + rect.size.width -= caption_logical_height; if (caption_is_before) - rect.Move(caption_logical_height, LayoutUnit()); + rect.offset.left += caption_logical_height; } } } @@ -1049,12 +1049,12 @@ void LayoutTable::PaintBoxDecorationBackground( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { TablePainter(*this).PaintBoxDecorationBackground(paint_info, paint_offset); } void LayoutTable::PaintMask(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { TablePainter(*this).PaintMask(paint_info, paint_offset); }
diff --git a/third_party/blink/renderer/core/layout/layout_table.h b/third_party/blink/renderer/core/layout/layout_table.h index 01f4dc5..4b1e853 100644 --- a/third_party/blink/renderer/core/layout/layout_table.h +++ b/third_party/blink/renderer/core/layout/layout_table.h
@@ -389,11 +389,12 @@ void PaintBoxDecorationBackground( const PaintInfo&, - const LayoutPoint& paint_offset) const final; + const PhysicalOffset& paint_offset) const final; - void PaintMask(const PaintInfo&, const LayoutPoint& paint_offset) const final; + void PaintMask(const PaintInfo&, + const PhysicalOffset& paint_offset) const final; - void SubtractCaptionRect(LayoutRect&) const; + void SubtractCaptionRect(PhysicalRect&) const; bool IsLogicalWidthAuto() const; @@ -409,7 +410,7 @@ // Whether a table has opaque foreground depends on many factors, e.g. border // spacing, missing cells, etc. For simplicity, just conservatively assume // foreground of all tables are not opaque. - bool ForegroundIsKnownToBeOpaqueInRect(const LayoutRect&, + bool ForegroundIsKnownToBeOpaqueInRect(const PhysicalRect&, unsigned) const override { return false; } @@ -441,7 +442,7 @@ } void PaintObject(const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; void UpdateLayout() override; void ComputeIntrinsicLogicalWidths(LayoutUnit& min_width, LayoutUnit& max_width) const override;
diff --git a/third_party/blink/renderer/core/layout/layout_table_cell.cc b/third_party/blink/renderer/core/layout/layout_table_cell.cc index 310f5f0..e18a62e 100644 --- a/third_party/blink/renderer/core/layout/layout_table_cell.cc +++ b/third_party/blink/renderer/core/layout/layout_table_cell.cc
@@ -1097,13 +1097,13 @@ void LayoutTableCell::PaintBoxDecorationBackground( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { TableCellPainter(*this).PaintBoxDecorationBackground(paint_info, paint_offset); } void LayoutTableCell::PaintMask(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { TableCellPainter(*this).PaintMask(paint_info, paint_offset); } @@ -1168,7 +1168,7 @@ } bool LayoutTableCell::BackgroundIsKnownToBeOpaqueInRect( - const LayoutRect& local_rect) const { + const PhysicalRect& local_rect) const { // If this object has layer, the area of collapsed borders should be // transparent to expose the collapsed borders painted on the underlying // layer.
diff --git a/third_party/blink/renderer/core/layout/layout_table_cell.h b/third_party/blink/renderer/core/layout/layout_table_cell.h index e87fea55..b950297 100644 --- a/third_party/blink/renderer/core/layout/layout_table_cell.h +++ b/third_party/blink/renderer/core/layout/layout_table_cell.h
@@ -263,7 +263,7 @@ const char* GetName() const override { return "LayoutTableCell"; } - bool BackgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const override; + bool BackgroundIsKnownToBeOpaqueInRect(const PhysicalRect&) const override; const CollapsedBorderValues* GetCollapsedBorderValues() const { UpdateCollapsedBorderValues(); @@ -366,9 +366,9 @@ void PaintBoxDecorationBackground( const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; void PaintMask(const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; bool ComputeShouldClipOverflow() const override;
diff --git a/third_party/blink/renderer/core/layout/layout_table_cell_test.cc b/third_party/blink/renderer/core/layout/layout_table_cell_test.cc index 1c8b033a..263d0f7 100644 --- a/third_party/blink/renderer/core/layout/layout_table_cell_test.cc +++ b/third_party/blink/renderer/core/layout/layout_table_cell_test.cc
@@ -115,7 +115,7 @@ </table> )HTML"); EXPECT_FALSE(GetCellByElementId("cell")->BackgroundIsKnownToBeOpaqueInRect( - LayoutRect(0, 0, 1, 1))); + PhysicalRect(0, 0, 1, 1))); } TEST_F(LayoutTableCellTest, RepaintContentInTableCell) {
diff --git a/third_party/blink/renderer/core/layout/layout_table_row.h b/third_party/blink/renderer/core/layout/layout_table_row.h index 99f2a62c..86d8d15 100644 --- a/third_party/blink/renderer/core/layout/layout_table_row.h +++ b/third_party/blink/renderer/core/layout/layout_table_row.h
@@ -115,11 +115,11 @@ // Whether a row has opaque background depends on many factors, e.g. border // spacing, border collapsing, missing cells, etc. // For simplicity, just conservatively assume all table rows are not opaque. - bool ForegroundIsKnownToBeOpaqueInRect(const LayoutRect&, + bool ForegroundIsKnownToBeOpaqueInRect(const PhysicalRect&, unsigned) const override { return false; } - bool BackgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const override { + bool BackgroundIsKnownToBeOpaqueInRect(const PhysicalRect&) const override { return false; } bool PaintedOutputOfObjectHasNoEffectRegardlessOfSize() const override;
diff --git a/third_party/blink/renderer/core/layout/layout_table_row_test.cc b/third_party/blink/renderer/core/layout/layout_table_row_test.cc index 079c875..72f44554 100644 --- a/third_party/blink/renderer/core/layout/layout_table_row_test.cc +++ b/third_party/blink/renderer/core/layout/layout_table_row_test.cc
@@ -87,7 +87,7 @@ )HTML"); EXPECT_FALSE(GetRowByElementId("row")->BackgroundIsKnownToBeOpaqueInRect( - LayoutRect(0, 0, 1, 1))); + PhysicalRect(0, 0, 1, 1))); } TEST_F(LayoutTableRowTest, BackgroundIsKnownToBeOpaqueWithBorderSpacing) { @@ -98,7 +98,7 @@ )HTML"); EXPECT_FALSE(GetRowByElementId("row")->BackgroundIsKnownToBeOpaqueInRect( - LayoutRect(0, 0, 1, 1))); + PhysicalRect(0, 0, 1, 1))); } TEST_F(LayoutTableRowTest, BackgroundIsKnownToBeOpaqueWithEmptyCell) { @@ -110,7 +110,7 @@ )HTML"); EXPECT_FALSE(GetRowByElementId("row")->BackgroundIsKnownToBeOpaqueInRect( - LayoutRect(0, 0, 1, 1))); + PhysicalRect(0, 0, 1, 1))); } TEST_F(LayoutTableRowTest, VisualOverflow) {
diff --git a/third_party/blink/renderer/core/layout/layout_table_section.h b/third_party/blink/renderer/core/layout/layout_table_section.h index 027a0bb..4085fb5 100644 --- a/third_party/blink/renderer/core/layout/layout_table_section.h +++ b/third_party/blink/renderer/core/layout/layout_table_section.h
@@ -250,11 +250,11 @@ // Whether a section has opaque background depends on many factors, e.g. // border spacing, border collapsing, missing cells, etc. For simplicity, // just conservatively assume all table sections are not opaque. - bool ForegroundIsKnownToBeOpaqueInRect(const LayoutRect&, + bool ForegroundIsKnownToBeOpaqueInRect(const PhysicalRect&, unsigned) const override { return false; } - bool BackgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const override { + bool BackgroundIsKnownToBeOpaqueInRect(const PhysicalRect&) const override { return false; }
diff --git a/third_party/blink/renderer/core/layout/layout_table_section_test.cc b/third_party/blink/renderer/core/layout/layout_table_section_test.cc index f26085d5..f155749 100644 --- a/third_party/blink/renderer/core/layout/layout_table_section_test.cc +++ b/third_party/blink/renderer/core/layout/layout_table_section_test.cc
@@ -47,7 +47,7 @@ auto* section = GetSectionByElementId("section"); EXPECT_TRUE(section); EXPECT_FALSE( - section->BackgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1))); + section->BackgroundIsKnownToBeOpaqueInRect(PhysicalRect(0, 0, 1, 1))); } TEST_F(LayoutTableSectionTest, BackgroundIsKnownToBeOpaqueWithBorderSpacing) { @@ -62,7 +62,7 @@ auto* section = GetSectionByElementId("section"); EXPECT_TRUE(section); EXPECT_FALSE( - section->BackgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1))); + section->BackgroundIsKnownToBeOpaqueInRect(PhysicalRect(0, 0, 1, 1))); } TEST_F(LayoutTableSectionTest, BackgroundIsKnownToBeOpaqueWithEmptyCell) { @@ -78,7 +78,7 @@ auto* section = GetSectionByElementId("section"); EXPECT_TRUE(section); EXPECT_FALSE( - section->BackgroundIsKnownToBeOpaqueInRect(LayoutRect(0, 0, 1, 1))); + section->BackgroundIsKnownToBeOpaqueInRect(PhysicalRect(0, 0, 1, 1))); } TEST_F(LayoutTableSectionTest, EmptySectionDirtiedRowsAndEffeciveColumns) {
diff --git a/third_party/blink/renderer/core/layout/layout_text_control.cc b/third_party/blink/renderer/core/layout/layout_text_control.cc index d30a5332..9b095640 100644 --- a/third_party/blink/renderer/core/layout/layout_text_control.cc +++ b/third_party/blink/renderer/core/layout/layout_text_control.cc
@@ -300,10 +300,10 @@ ClearPreferredLogicalWidthsDirty(); } -void LayoutTextControl::AddOutlineRects(Vector<LayoutRect>& rects, - const LayoutPoint& additional_offset, +void LayoutTextControl::AddOutlineRects(Vector<PhysicalRect>& rects, + const PhysicalOffset& additional_offset, NGOutlineType) const { - rects.push_back(LayoutRect(additional_offset, Size())); + rects.emplace_back(additional_offset, Size()); } LayoutObject* LayoutTextControl::LayoutSpecialExcludedChild(
diff --git a/third_party/blink/renderer/core/layout/layout_text_control.h b/third_party/blink/renderer/core/layout/layout_text_control.h index b4be797e..1d26fd5 100644 --- a/third_party/blink/renderer/core/layout/layout_text_control.h +++ b/third_party/blink/renderer/core/layout/layout_text_control.h
@@ -98,8 +98,8 @@ void ComputePreferredLogicalWidths() final; void RemoveLeftoverAnonymousBlock(LayoutBlock*) final {} - void AddOutlineRects(Vector<LayoutRect>&, - const LayoutPoint& additional_offset, + void AddOutlineRects(Vector<PhysicalRect>&, + const PhysicalOffset& additional_offset, NGOutlineType) const final; bool CanBeProgramaticallyScrolled() const final { return true; }
diff --git a/third_party/blink/renderer/core/layout/layout_tree_as_text.cc b/third_party/blink/renderer/core/layout/layout_tree_as_text.cc index 85ac6162..822d80d 100644 --- a/third_party/blink/renderer/core/layout/layout_tree_as_text.cc +++ b/third_party/blink/renderer/core/layout/layout_tree_as_text.cc
@@ -596,9 +596,9 @@ static void Write(WTF::TextStream& ts, PaintLayer& layer, - const LayoutRect& layer_bounds, - const LayoutRect& background_clip_rect, - const LayoutRect& clip_rect, + const PhysicalRect& layer_bounds, + const PhysicalRect& background_clip_rect, + const PhysicalRect& clip_rect, LayerPaintPhase paint_phase = kLayerPaintPhaseAll, int indent = 0, LayoutAsTextBehavior behavior = kLayoutAsTextBehaviorNormal, @@ -706,7 +706,7 @@ LayoutAsTextBehavior behavior, const PaintLayer* marked_layer) { // Calculate the clip rects we should use. - LayoutRect layer_bounds; + PhysicalRect layer_bounds; ClipRect damage_rect, clip_rect_to_apply; if (layer->GetLayoutObject().FirstFragment().HasLocalBorderBoxProperties()) { layer->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) @@ -723,7 +723,7 @@ nullptr, layer_bounds, damage_rect, clip_rect_to_apply); } - LayoutPoint offset_from_root; + PhysicalOffset offset_from_root; layer->ConvertToLayerCoords(root_layer, offset_from_root); bool should_paint = (behavior & kLayoutAsTextShowAllLayers)
diff --git a/third_party/blink/renderer/core/layout/layout_video.cc b/third_party/blink/renderer/core/layout/layout_video.cc index e599a7c..bd0965b 100644 --- a/third_party/blink/renderer/core/layout/layout_video.cc +++ b/third_party/blink/renderer/core/layout/layout_video.cc
@@ -122,7 +122,7 @@ } void LayoutVideo::PaintReplaced(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { VideoPainter(*this).PaintReplaced(paint_info, paint_offset); }
diff --git a/third_party/blink/renderer/core/layout/layout_video.h b/third_party/blink/renderer/core/layout/layout_video.h index 706a4a3..0b7623c 100644 --- a/third_party/blink/renderer/core/layout/layout_video.h +++ b/third_party/blink/renderer/core/layout/layout_video.h
@@ -65,7 +65,7 @@ } void PaintReplaced(const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; void UpdateLayout() override;
diff --git a/third_party/blink/renderer/core/layout/layout_view.cc b/third_party/blink/renderer/core/layout/layout_view.cc index cb70aa23..9f92e98 100644 --- a/third_party/blink/renderer/core/layout/layout_view.cc +++ b/third_party/blink/renderer/core/layout/layout_view.cc
@@ -438,7 +438,7 @@ } void LayoutView::PaintBoxDecorationBackground(const PaintInfo& paint_info, - const LayoutPoint&) const { + const PhysicalOffset&) const { ViewPainter(*this).PaintBoxDecorationBackground(paint_info); } @@ -817,7 +817,7 @@ return interval_arena_.get(); } -bool LayoutView::BackgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const { +bool LayoutView::BackgroundIsKnownToBeOpaqueInRect(const PhysicalRect&) const { // FIXME: Remove this main frame check. Same concept applies to subframes too. if (!GetFrame()->IsMainFrame()) return false;
diff --git a/third_party/blink/renderer/core/layout/layout_view.h b/third_party/blink/renderer/core/layout/layout_view.h index 88ef6db..86f6712 100644 --- a/third_party/blink/renderer/core/layout/layout_view.h +++ b/third_party/blink/renderer/core/layout/layout_view.h
@@ -144,7 +144,7 @@ void Paint(const PaintInfo&) const override; void PaintBoxDecorationBackground( const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; void CommitPendingSelection(); @@ -214,7 +214,7 @@ void UpdateCounters(); bool BackgroundIsKnownToBeOpaqueInRect( - const LayoutRect& local_rect) const override; + const PhysicalRect& local_rect) const override; // Returns the viewport size in (CSS pixels) that vh and vw units are // calculated from. @@ -256,17 +256,17 @@ // The visible background area, in the local coordinates. The view background // will be painted in this rect. It's also the positioning area of fixed- // attachment backgrounds. - LayoutRect BackgroundRect() const { - return OverflowClipRect(PhysicalOffset()).ToLayoutRect(); + PhysicalRect BackgroundRect() const { + return OverflowClipRect(PhysicalOffset()); } // The previous BackgroundRect after the previous paint invalidation. - LayoutRect PreviousBackgroundRect() const { + PhysicalRect PreviousBackgroundRect() const { DCHECK_EQ(GetDocument().Lifecycle().GetState(), DocumentLifecycle::kInPrePaint); return previous_background_rect_; } - void SetPreviousBackgroundRect(const LayoutRect& r) const { + void SetPreviousBackgroundRect(const PhysicalRect& r) const { DCHECK_EQ(GetDocument().Lifecycle().GetState(), DocumentLifecycle::kInPrePaint); previous_background_rect_ = r; @@ -339,7 +339,7 @@ Vector<IntRect> tickmarks_override_; - mutable LayoutRect previous_background_rect_; + mutable PhysicalRect previous_background_rect_; }; DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutView, IsLayoutView());
diff --git a/third_party/blink/renderer/core/layout/ng/inline/ng_inline_node.cc b/third_party/blink/renderer/core/layout/ng/inline/ng_inline_node.cc index 0ac9104..cc3c4d4 100644 --- a/third_party/blink/renderer/core/layout/ng/inline/ng_inline_node.cc +++ b/third_party/blink/renderer/core/layout/ng/inline/ng_inline_node.cc
@@ -836,22 +836,6 @@ item.SetStyleVariant(NGStyleVariant::kFirstLine); } - // Check if we have a first-line anonymous inline box. It is the first - // open-tag if we have. - for (auto& item : first_line_items->items) { - if (item.Type() == NGInlineItem::kOpenTag) { - if (item.layout_object_->IsAnonymous() && - item.layout_object_->IsLayoutInline() && - item.layout_object_->Parent() == GetLayoutBox() && - ToLayoutInline(item.layout_object_)->IsFirstLineAnonymous()) { - item.SetShouldCreateBoxFragment(); - } - break; - } - if (item.Type() != NGInlineItem::kBidiControl) - break; - } - // Re-shape if the font is different. if (needs_reshape || FirstLineNeedsReshape(*first_line_style, *block_style)) ShapeText(first_line_items.get());
diff --git a/third_party/blink/renderer/core/layout/ng/inline/ng_line_breaker.cc b/third_party/blink/renderer/core/layout/ng/inline/ng_line_breaker.cc index 7867e5e..ef2507d 100644 --- a/third_party/blink/renderer/core/layout/ng/inline/ng_line_breaker.cc +++ b/third_party/blink/renderer/core/layout/ng/inline/ng_line_breaker.cc
@@ -157,6 +157,14 @@ } // namespace +LayoutUnit NGLineBreaker::ComputeAvailableWidth() const { + LayoutUnit available_width = line_opportunity_.AvailableInlineSize(); + // Available width must be smaller than |LayoutUnit::Max()| so that the + // position can be larger. + available_width = std::min(available_width, LayoutUnit::NearlyMax()); + return available_width; +} + NGLineBreaker::NGLineBreaker(NGInlineNode node, NGLineBreakerMode mode, const NGConstraintSpace& space, @@ -184,6 +192,7 @@ leading_floats_(leading_floats), handled_leading_floats_index_(handled_leading_floats_index), base_direction_(node_.BaseDirection()) { + available_width_ = ComputeAvailableWidth(); break_iterator_.SetBreakSpace(BreakSpaceType::kBeforeSpaceRun); if (break_token) { @@ -235,20 +244,23 @@ max_size_cache_ = max_size_cache; } -void NGLineBreaker::SetLineEndFragment( +LayoutUnit NGLineBreaker::SetLineEndFragment( scoped_refptr<const NGPhysicalTextFragment> fragment, NGLineInfo* line_info) { + LayoutUnit inline_size; bool is_horizontal = IsHorizontalWritingMode(constraint_space_.GetWritingMode()); if (line_info->LineEndFragment()) { const PhysicalSize& size = line_info->LineEndFragment()->Size(); - position_ -= is_horizontal ? size.width : size.height; + inline_size = is_horizontal ? -size.width : -size.height; } if (fragment) { const PhysicalSize& size = fragment->Size(); - position_ += is_horizontal ? size.width : size.height; + inline_size = is_horizontal ? size.width : size.height; } line_info->SetLineEndFragment(std::move(fragment)); + position_ += inline_size; + return inline_size; } // Compute the base direction for bidi algorithm for this line. @@ -519,17 +531,18 @@ // Try to break inside of this text item. LayoutUnit available_width = AvailableWidthToFit(); - BreakText(item_result, item, shape_result, available_width - position_, - line_info); - - LayoutUnit next_position = position_ + item_result->inline_size; - bool is_overflow = next_position > available_width; - DCHECK(is_overflow || item_result->shape_result); - position_ = next_position; - item_result->may_break_inside = !is_overflow; + BreakResult break_result = + BreakText(item_result, item, shape_result, available_width - position_, + line_info); + DCHECK(item_result->shape_result || + (break_result == kOverflow && break_anywhere_if_overflow_ && + !override_break_anywhere_)); + position_ += item_result->inline_size; + DCHECK_EQ(break_result == kSuccess, position_ <= available_width); + item_result->may_break_inside = break_result == kSuccess; MoveToNextOf(*item_result); - if (!is_overflow || + if (break_result == kSuccess || (state_ == LineBreakState::kTrailing && item_result->shape_result)) { if (item_result->end_offset < item.EndOffset()) { // The break point found, and text follows. Break here, after trailing @@ -542,6 +555,7 @@ return; } + DCHECK_EQ(break_result, kOverflow); return HandleOverflow(line_info); } @@ -570,11 +584,12 @@ MoveToNextOf(item); } -void NGLineBreaker::BreakText(NGInlineItemResult* item_result, - const NGInlineItem& item, - const ShapeResult& item_shape_result, - LayoutUnit available_width, - NGLineInfo* line_info) { +NGLineBreaker::BreakResult NGLineBreaker::BreakText( + NGInlineItemResult* item_result, + const NGInlineItem& item, + const ShapeResult& item_shape_result, + LayoutUnit available_width, + NGLineInfo* line_info) { DCHECK(item.Type() == NGInlineItem::kText || (item.Type() == NGInlineItem::kControl && Text()[item.StartOffset()] == kTabulationCharacter)); @@ -600,7 +615,6 @@ shape_callback, &shape_callback_context); if (!enable_soft_hyphen_) breaker.DisableSoftHyphen(); - available_width = std::max(LayoutUnit(0), available_width); // Use kStartShouldBeSafe if at the beginning of a line. unsigned options = ShapingLineBreaker::kDefaultOptions; @@ -621,7 +635,8 @@ ShapingLineBreaker::Result result; scoped_refptr<const ShapeResultView> shape_result = breaker.ShapeLine( - item_result->start_offset, available_width, options, &result); + item_result->start_offset, available_width.ClampNegativeToZero(), options, + &result); // If this item overflows and 'break-word' is set, this line will be // rewinded. Making this item long enough to overflow is enough. @@ -629,13 +644,15 @@ DCHECK(options & ShapingLineBreaker::kNoResultIfOverflow); item_result->inline_size = available_width + 1; item_result->end_offset = item.EndOffset(); - return; + return kOverflow; } DCHECK_EQ(shape_result->NumCharacters(), result.break_offset - item_result->start_offset); + LayoutUnit inline_size = shape_result->SnappedWidth().ClampNegativeToZero(); + item_result->inline_size = inline_size; if (result.is_hyphenated) { - SetLineEndFragment( + inline_size += SetLineEndFragment( CreateHyphenFragment(node_, constraint_space_.GetWritingMode(), item), line_info); @@ -673,6 +690,7 @@ break_iterator_.IsBreakable(item_result->end_offset); trailing_whitespace_ = WhitespaceState::kUnknown; } + return inline_size <= available_width ? kSuccess : kOverflow; } // This function handles text item for min-content. The specialized logic is @@ -1288,6 +1306,7 @@ line_opportunity_ = opportunity.ComputeLineLayoutOpportunity( constraint_space_, line_opportunity_.line_block_size, LayoutUnit()); + available_width_ = ComputeAvailableWidth(); DCHECK_GE(AvailableWidth(), LayoutUnit()); } @@ -1441,14 +1460,18 @@ LayoutUnit item_available_width = std::min(-width_to_rewind, item_result->inline_size - 1); SetCurrentStyle(*item.Style()); - BreakText(item_result, item, *item.TextShapeResult(), - item_available_width, line_info); + BreakResult break_result = + BreakText(item_result, item, *item.TextShapeResult(), + item_available_width, line_info); #if DCHECK_IS_ON() item_result->CheckConsistency(true); #endif // If BreakText() changed this item small enough to fit, break here. - if (item_result->inline_size <= item_available_width) { - DCHECK(item_result->end_offset < item.EndOffset()); + DCHECK_EQ(break_result == kSuccess, + item_result->inline_size <= item_available_width); + if (break_result == kSuccess) { + DCHECK_LE(item_result->inline_size, item_available_width); + DCHECK_LT(item_result->end_offset, item.EndOffset()); DCHECK(item_result->can_break_after); DCHECK_LE(i + 1, item_results->size()); if (i + 1 == item_results->size()) {
diff --git a/third_party/blink/renderer/core/layout/ng/inline/ng_line_breaker.h b/third_party/blink/renderer/core/layout/ng/inline/ng_line_breaker.h index 161689cc..0ee10b8 100644 --- a/third_party/blink/renderer/core/layout/ng/inline/ng_line_breaker.h +++ b/third_party/blink/renderer/core/layout/ng/inline/ng_line_breaker.h
@@ -98,8 +98,8 @@ unsigned end_offset, NGLineInfo*); NGInlineItemResult* AddItem(const NGInlineItem&, NGLineInfo*); - void SetLineEndFragment(scoped_refptr<const NGPhysicalTextFragment>, - NGLineInfo*); + LayoutUnit SetLineEndFragment(scoped_refptr<const NGPhysicalTextFragment>, + NGLineInfo*); void BreakLine(LayoutUnit percentage_resolution_block_size_for_min_max, Vector<LayoutObject*>* out_floats_for_min_max, @@ -126,11 +126,12 @@ HandleText(item, *item.TextShapeResult(), line_info); } void HandleText(const NGInlineItem& item, const ShapeResult&, NGLineInfo*); - void BreakText(NGInlineItemResult*, - const NGInlineItem&, - const ShapeResult&, - LayoutUnit available_width, - NGLineInfo*); + enum BreakResult { kSuccess, kOverflow }; + BreakResult BreakText(NGInlineItemResult*, + const NGInlineItem&, + const ShapeResult&, + LayoutUnit available_width, + NGLineInfo*); bool HandleTextForFastMinContent(NGInlineItemResult*, const NGInlineItem&, const ShapeResult&, @@ -179,11 +180,13 @@ void ComputeBaseDirection(); LayoutUnit AvailableWidth() const { - return line_opportunity_.AvailableInlineSize(); + DCHECK_EQ(available_width_, ComputeAvailableWidth()); + return available_width_; } LayoutUnit AvailableWidthToFit() const { return AvailableWidth().AddEpsilon(); } + LayoutUnit ComputeAvailableWidth() const; // Represents the current offset of the input. LineBreakState state_; @@ -197,6 +200,7 @@ // The current position from inline_start. Unlike NGInlineLayoutAlgorithm // that computes position in visual order, this position in logical order. LayoutUnit position_; + LayoutUnit available_width_; NGLineLayoutOpportunity line_opportunity_; NGInlineNode node_;
diff --git a/third_party/blink/renderer/core/layout/ng/layout_ng_mixin.cc b/third_party/blink/renderer/core/layout/ng/layout_ng_mixin.cc index e835ae20..55a268d7 100644 --- a/third_party/blink/renderer/core/layout/ng/layout_ng_mixin.cc +++ b/third_party/blink/renderer/core/layout/ng/layout_ng_mixin.cc
@@ -189,17 +189,27 @@ template <typename Base> void LayoutNGMixin<Base>::AddOutlineRects( - Vector<LayoutRect>& rects, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>& rects, + const PhysicalOffset& additional_offset, NGOutlineType include_block_overflows) const { if (PaintFragment()) { - PaintFragment()->AddSelfOutlineRect(&rects, additional_offset, - include_block_overflows); + PaintFragment()->AddSelfOutlineRects(&rects, additional_offset, + include_block_overflows); } else { Base::AddOutlineRects(rects, additional_offset, include_block_overflows); } } +template <typename Base> +bool LayoutNGMixin<Base>::PaintedOutputOfObjectHasNoEffectRegardlessOfSize() + const { + // LayoutNGMixin is in charge of paint invalidation of the first line. + if (PaintFragment()) + return false; + + return Base::PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); +} + // Retrieve NGBaseline from the current fragment. template <typename Base> base::Optional<LayoutUnit> LayoutNGMixin<Base>::FragmentBaseline( @@ -265,21 +275,6 @@ } template <typename Base> -void LayoutNGMixin<Base>::InvalidateDisplayItemClients( - PaintInvalidationReason invalidation_reason) const { - if (NGPaintFragment* fragment = PaintFragment()) { - // TODO(koji): Should be in the PaintInvalidator, possibly with more logic - // ported from BlockFlowPaintInvalidator. - ObjectPaintInvalidator object_paint_invalidator(*this); - object_paint_invalidator.InvalidateDisplayItemClient(*fragment, - invalidation_reason); - return; - } - - LayoutBlockFlow::InvalidateDisplayItemClients(invalidation_reason); -} - -template <typename Base> void LayoutNGMixin<Base>::Paint(const PaintInfo& paint_info) const { if (const NGPaintFragment* paint_fragment = PaintFragment()) NGBoxFragmentPainter(*paint_fragment).Paint(paint_info);
diff --git a/third_party/blink/renderer/core/layout/ng/layout_ng_mixin.h b/third_party/blink/renderer/core/layout/ng/layout_ng_mixin.h index 48afe150..0a585db 100644 --- a/third_party/blink/renderer/core/layout/ng/layout_ng_mixin.h +++ b/third_party/blink/renderer/core/layout/ng/layout_ng_mixin.h
@@ -41,8 +41,6 @@ LayoutUnit FirstLineBoxBaseline() const final; LayoutUnit InlineBlockBaseline(LineDirectionMode) const final; - void InvalidateDisplayItemClients(PaintInvalidationReason) const final; - void Paint(const PaintInfo&) const final; bool NodeAtPoint(HitTestResult&, @@ -57,7 +55,9 @@ // Safer option here is to return nullptr only if // Lifecycle > DocumentLifecycle::kAfterPerformLayout, but this breaks // some layout tests. - return Base::NeedsLayout() ? nullptr : paint_fragment_.get(); + if (Base::NeedsLayout()) + return nullptr; + return paint_fragment_.get(); } void SetPaintFragment(const NGBlockBreakToken*, scoped_refptr<const NGPhysicalFragment>) final; @@ -73,10 +73,12 @@ void AddLayoutOverflowFromChildren() final; - void AddOutlineRects(Vector<LayoutRect>&, - const LayoutPoint& additional_offset, + void AddOutlineRects(Vector<PhysicalRect>&, + const PhysicalOffset& additional_offset, NGOutlineType) const final; + bool PaintedOutputOfObjectHasNoEffectRegardlessOfSize() const final; + const NGPhysicalBoxFragment* CurrentFragment() const final; base::Optional<LayoutUnit> FragmentBaseline(NGBaselineAlgorithmType) const;
diff --git a/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.cc b/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.cc index 7ffdb719..2fe1fcb 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.cc
@@ -88,8 +88,8 @@ ->HasSelfPaintingLayer(); } -LayoutRect NGPhysicalBoxFragment::OverflowClipRect( - const LayoutPoint& location, +PhysicalRect NGPhysicalBoxFragment::OverflowClipRect( + const PhysicalOffset& location, OverlayScrollbarClipBehavior overlay_scrollbar_clip_behavior) const { DCHECK(GetLayoutObject() && GetLayoutObject()->IsBox()); const LayoutBox* box = ToLayoutBox(GetLayoutObject()); @@ -134,16 +134,16 @@ return box->ScrolledContentOffset(); } -LayoutSize NGPhysicalBoxFragment::ScrollSize() const { +PhysicalSize NGPhysicalBoxFragment::ScrollSize() const { DCHECK(GetLayoutObject() && GetLayoutObject()->IsBox()); const LayoutBox* box = ToLayoutBox(GetLayoutObject()); - return LayoutSize(box->ScrollWidth(), box->ScrollHeight()); + return {box->ScrollWidth(), box->ScrollHeight()}; } PhysicalRect NGPhysicalBoxFragment::ComputeSelfInkOverflow() const { CheckCanUpdateInkOverflow(); const ComputedStyle& style = Style(); - LayoutRect ink_overflow({}, Size().ToLayoutSize()); + PhysicalRect ink_overflow({}, Size().ToLayoutSize()); DCHECK(GetLayoutObject()); if (style.HasVisualOverflowingEffect()) { @@ -151,22 +151,22 @@ if (NGOutlineUtils::HasPaintedOutline(style, GetLayoutObject()->GetNode()) && !NGOutlineUtils::IsInlineOutlineNonpaintingFragment(*this)) { - Vector<LayoutRect> outline_rects; + Vector<PhysicalRect> outline_rects; // The result rects are in coordinates of this object's border box. AddSelfOutlineRects( - &outline_rects, LayoutPoint(), + &outline_rects, PhysicalOffset(), GetLayoutObject()->OutlineRectsShouldIncludeBlockVisualOverflow()); - LayoutRect rect = UnionRectEvenIfEmpty(outline_rects); - rect.Inflate(style.OutlineOutsetExtent()); + PhysicalRect rect = UnionRectEvenIfEmpty(outline_rects); + rect.Inflate(LayoutUnit(style.OutlineOutsetExtent())); ink_overflow.Unite(rect); } } - return PhysicalRect(ink_overflow); + return ink_overflow; } void NGPhysicalBoxFragment::AddSelfOutlineRects( - Vector<LayoutRect>* outline_rects, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>* outline_rects, + const PhysicalOffset& additional_offset, NGOutlineType outline_type) const { // TODO(kojii): Needs inline_element_continuation logic from // LayoutBlockFlow::AddOutlineRects? @@ -174,17 +174,18 @@ const LayoutObject* layout_object = GetLayoutObject(); DCHECK(layout_object); if (layout_object->IsLayoutInline()) { - Vector<LayoutRect> blockflow_outline_rects = - layout_object->PhysicalOutlineRects(LayoutPoint(), outline_type); + Vector<PhysicalRect> blockflow_outline_rects = + layout_object->OutlineRects(PhysicalOffset(), outline_type); // The rectangles returned are offset from the containing block. We need the // offset from this fragment. if (blockflow_outline_rects.size() > 0) { - LayoutPoint first_fragment_offset = blockflow_outline_rects[0].Location(); - LayoutSize corrected_offset = additional_offset - first_fragment_offset; + PhysicalOffset first_fragment_offset = blockflow_outline_rects[0].offset; + PhysicalOffset corrected_offset = + additional_offset - first_fragment_offset; for (auto& outline : blockflow_outline_rects) { - // Skip if both width and height are zero. Contaning blocks in empty + // Skip if both width and height are zero. Containing blocks in empty // linebox is one such case. - if (outline.Size().IsZero()) + if (outline.size.IsZero()) continue; outline.Move(corrected_offset); outline_rects->push_back(outline);
diff --git a/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h b/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h index 9e5b1e66..7451bba 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h +++ b/third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h
@@ -49,19 +49,19 @@ // TODO(layout-dev): These three methods delegate to legacy layout for now, // update them to use LayoutNG based overflow information from the fragment // and change them to use NG geometry types once LayoutNG supports overflow. - LayoutRect OverflowClipRect( - const LayoutPoint& location, + PhysicalRect OverflowClipRect( + const PhysicalOffset& location, OverlayScrollbarClipBehavior = kIgnorePlatformOverlayScrollbarSize) const; IntSize ScrolledContentOffset() const; - LayoutSize ScrollSize() const; + PhysicalSize ScrollSize() const; // Compute visual overflow of this box in the local coordinate. PhysicalRect ComputeSelfInkOverflow() const; // Fragment offset is this fragment's offset from parent. // Needed to compensate for LayoutInline Legacy code offsets. - void AddSelfOutlineRects(Vector<LayoutRect>* outline_rects, - const LayoutPoint& additional_offset, + void AddSelfOutlineRects(Vector<PhysicalRect>* outline_rects, + const PhysicalOffset& additional_offset, NGOutlineType include_block_overflows) const; UBiDiLevel BidiLevel() const;
diff --git a/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.cc b/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.cc index bb59112..0ca7aba3 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.cc
@@ -63,8 +63,8 @@ NGPhysicalContainerFragment::~NGPhysicalContainerFragment() = default; void NGPhysicalContainerFragment::AddOutlineRectsForNormalChildren( - Vector<LayoutRect>* outline_rects, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>* outline_rects, + const PhysicalOffset& additional_offset, NGOutlineType outline_type, const LayoutBoxModelObject* containing_block) const { for (const auto& child : Children()) { @@ -92,8 +92,8 @@ void NGPhysicalContainerFragment::AddOutlineRectsForDescendant( const NGLink& descendant, - Vector<LayoutRect>* outline_rects, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>* outline_rects, + const PhysicalOffset& additional_offset, NGOutlineType outline_type, const LayoutBoxModelObject* containing_block) const { if (descendant->IsText() || descendant->IsListMarker()) @@ -105,12 +105,12 @@ DCHECK(descendant_layout_object); if (descendant_box->HasLayer()) { - Vector<LayoutRect> layer_outline_rects; - descendant_box->AddSelfOutlineRects(&layer_outline_rects, LayoutPoint(), - outline_type); + Vector<PhysicalRect> layer_outline_rects; + descendant_box->AddSelfOutlineRects(&layer_outline_rects, + PhysicalOffset(), outline_type); descendant_layout_object->LocalToAncestorRects( - layer_outline_rects, containing_block, LayoutPoint(), + layer_outline_rects, containing_block, PhysicalOffset(), additional_offset); outline_rects->AppendVector(layer_outline_rects); return; @@ -118,9 +118,7 @@ if (descendant_layout_object->IsBox()) { descendant_box->AddSelfOutlineRects( - outline_rects, - additional_offset + descendant.Offset().ToLayoutPoint(), - outline_type); + outline_rects, additional_offset + descendant.Offset(), outline_type); return; } @@ -143,8 +141,8 @@ if (const auto* descendant_line_box = DynamicTo<NGPhysicalLineBoxFragment>(descendant.get())) { descendant_line_box->AddOutlineRectsForNormalChildren( - outline_rects, additional_offset + descendant.Offset().ToLayoutPoint(), - outline_type, containing_block); + outline_rects, additional_offset + descendant.Offset(), outline_type, + containing_block); if (!descendant_line_box->Size().IsEmpty()) { outline_rects->emplace_back(additional_offset,
diff --git a/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.h b/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.h index d9be9ad..97a9611 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.h +++ b/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.h
@@ -78,14 +78,14 @@ unsigned sub_type); void AddOutlineRectsForNormalChildren( - Vector<LayoutRect>* outline_rects, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>* outline_rects, + const PhysicalOffset& additional_offset, NGOutlineType outline_type, const LayoutBoxModelObject* containing_block) const; void AddOutlineRectsForDescendant( const NGLink& descendant, - Vector<LayoutRect>* rects, - const LayoutPoint& additional_offset, + Vector<PhysicalRect>* rects, + const PhysicalOffset& additional_offset, NGOutlineType outline_type, const LayoutBoxModelObject* containing_block) const;
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_model_object.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_model_object.cc index f919658..e578f5d 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_model_object.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_model_object.cc
@@ -80,10 +80,11 @@ // This method is called from inside PaintOutline(), and since we call // PaintOutline() while transformed to our coord system, return local coords. -void LayoutSVGModelObject::AddOutlineRects(Vector<LayoutRect>& rects, - const LayoutPoint&, +void LayoutSVGModelObject::AddOutlineRects(Vector<PhysicalRect>& rects, + const PhysicalOffset&, NGOutlineType) const { - rects.push_back(LayoutRect(VisualRectInLocalSVGCoordinates())); + rects.push_back( + PhysicalRect::EnclosingRect(VisualRectInLocalSVGCoordinates())); } FloatRect LayoutSVGModelObject::LocalBoundingBoxRectForAccessibility() const {
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_model_object.h b/third_party/blink/renderer/core/layout/svg/layout_svg_model_object.h index 1f1d965a..8da88b3 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_model_object.h +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_model_object.h
@@ -86,8 +86,8 @@ // LayoutSVGModelObject subclasses should use GetElement() instead. void GetNode() const = delete; - void AddOutlineRects(Vector<LayoutRect>&, - const LayoutPoint& additional_offset, + void AddOutlineRects(Vector<PhysicalRect>&, + const PhysicalOffset& additional_offset, NGOutlineType) const final; protected:
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc index 704fac1..6d0c762 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc
@@ -263,7 +263,7 @@ } void LayoutSVGRoot::PaintReplaced(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { SVGRootPainter(*this).PaintReplaced(paint_info, paint_offset); }
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_root.h b/third_party/blink/renderer/core/layout/svg/layout_svg_root.h index 8c057a1..22da63bd 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_root.h +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_root.h
@@ -117,7 +117,7 @@ LayoutUnit estimated_used_width = LayoutUnit()) const override; void UpdateLayout() override; void PaintReplaced(const PaintInfo&, - const LayoutPoint& paint_offset) const override; + const PhysicalOffset& paint_offset) const override; void WillBeDestroyed() override; void StyleDidChange(StyleDifference, const ComputedStyle* old_style) override;
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_text.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_text.cc index c047d95..334d7644 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_text.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_text.cc
@@ -415,10 +415,10 @@ return visual_rect; } -void LayoutSVGText::AddOutlineRects(Vector<LayoutRect>& rects, - const LayoutPoint&, +void LayoutSVGText::AddOutlineRects(Vector<PhysicalRect>& rects, + const PhysicalOffset&, NGOutlineType) const { - rects.push_back(LayoutRect(ObjectBoundingBox())); + rects.push_back(PhysicalRect::EnclosingRect(ObjectBoundingBox())); } bool LayoutSVGText::IsObjectBoundingBoxValid() const {
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_text.h b/third_party/blink/renderer/core/layout/svg/layout_svg_text.h index bf9845c..852d90e20 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_text.h +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_text.h
@@ -46,8 +46,8 @@ FloatRect StrokeBoundingBox() const override; bool IsObjectBoundingBoxValid() const; - void AddOutlineRects(Vector<LayoutRect>&, - const LayoutPoint& additional_offset, + void AddOutlineRects(Vector<PhysicalRect>&, + const PhysicalOffset& additional_offset, NGOutlineType) const override; static LayoutSVGText* LocateLayoutSVGTextAncestor(LayoutObject*);
diff --git a/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.cc b/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.cc index 550fb87e..aefc9e1 100644 --- a/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.cc +++ b/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.cc
@@ -544,19 +544,17 @@ // TODO(bokan): This method shouldn't be resizing the layer geometry. That // happens in CompositedLayerMapping::UpdateScrollingLayerGeometry. - LayoutSize subpixel_accumulation = + PhysicalOffset subpixel_accumulation = scrollable_area->Layer() ? scrollable_area->Layer()->SubpixelAccumulation() - : LayoutSize(); - LayoutSize contents_size = + : PhysicalOffset(); + PhysicalSize contents_size = scrollable_area->GetLayoutBox() - ? LayoutSize(scrollable_area->GetLayoutBox()->ScrollWidth(), - scrollable_area->GetLayoutBox()->ScrollHeight()) - : LayoutSize(scrollable_area->ContentsSize()); + ? PhysicalSize(scrollable_area->GetLayoutBox()->ScrollWidth(), + scrollable_area->GetLayoutBox()->ScrollHeight()) + : PhysicalSize(scrollable_area->ContentsSize()); IntSize scroll_contents_size = - PixelSnappedIntRect( - LayoutRect(LayoutPoint(subpixel_accumulation), contents_size)) - .Size(); + PhysicalRect(subpixel_accumulation, contents_size).PixelSnappedSize(); if (scrollable_area != &page_->GetVisualViewport()) { // The scrolling contents layer must be at least as large as its clip.
diff --git a/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator_test.cc b/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator_test.cc index cc9d811..d9da75de 100644 --- a/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator_test.cc +++ b/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator_test.cc
@@ -1672,6 +1672,39 @@ EXPECT_EQ(gfx::ScrollOffset(), cc_layer->CurrentScrollOffset()); } +TEST_P(ScrollingCoordinatorTest, UpdateVisualViewportScrollLayer) { + // This test fails without BGPT enabled. https://crbug.com/930636. + if (!RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) + return; + LoadHTML(R"HTML( + <!DOCTYPE html> + <style> + #box { + width: 300px; + height: 1000px; + background-color: red; + } + </style> + <div id="box"> + </div> + )HTML"); + ForceFullCompositingUpdate(); + + Page* page = GetFrame()->GetPage(); + cc::Layer* inner_viewport_scroll_layer = + page->GetVisualViewport().ScrollLayer()->CcLayer(); + + page->GetVisualViewport().SetScale(2); + + EXPECT_EQ(gfx::ScrollOffset(0, 0), + inner_viewport_scroll_layer->CurrentScrollOffset()); + + page->GetVisualViewport().SetLocation(FloatPoint(10, 20)); + + EXPECT_EQ(gfx::ScrollOffset(10, 20), + inner_viewport_scroll_layer->CurrentScrollOffset()); +} + TEST_P(ScrollingCoordinatorTest, UpdateUMAMetricUpdated) { HistogramTester histogram_tester; LoadHTML(R"HTML(
diff --git a/third_party/blink/renderer/core/page/scrolling/snap_coordinator.cc b/third_party/blink/renderer/core/page/scrolling/snap_coordinator.cc index 842a965..971d619 100644 --- a/third_party/blink/renderer/core/page/scrolling/snap_coordinator.cc +++ b/third_party/blink/renderer/core/page/scrolling/snap_coordinator.cc
@@ -173,8 +173,7 @@ // https://drafts.csswg.org/css-overflow-3/#scrollport. So we use the // LayoutRect of the padding box here. The coordinate is relative to the // container's border box. - LayoutRect container_rect( - snap_container.PhysicalPaddingBoxRect().ToLayoutRect()); + PhysicalRect container_rect(snap_container.PhysicalPaddingBoxRect()); const ComputedStyle* container_style = snap_container.Style(); LayoutRectOutsets container_padding( @@ -204,9 +203,9 @@ if (snap_container_data.scroll_snap_type().strictness == cc::SnapStrictness::kProximity) { - LayoutSize size = container_rect.Size(); + PhysicalSize size = container_rect.size; size.Scale(kProximityRatio); - gfx::ScrollOffset range(size.Width().ToFloat(), size.Height().ToFloat()); + gfx::ScrollOffset range(size.width.ToFloat(), size.height.ToFloat()); snap_container_data.set_proximity_range(range); }
diff --git a/third_party/blink/renderer/core/paint/background_image_geometry.cc b/third_party/blink/renderer/core/paint/background_image_geometry.cc index 6a8673a..16844cf 100644 --- a/third_party/blink/renderer/core/paint/background_image_geometry.cc +++ b/third_party/blink/renderer/core/paint/background_image_geometry.cc
@@ -316,7 +316,7 @@ LayoutSize(border_spacing.Width(), LayoutUnit()); } - LayoutRect sections_rect(LayoutPoint(), cell.Table()->Size()); + PhysicalRect sections_rect(PhysicalOffset(), cell.Table()->Size()); cell.Table()->SubtractCaptionRect(sections_rect); LayoutUnit height_of_captions = cell.Table()->Size().Height() - sections_rect.Height(); @@ -355,7 +355,7 @@ } DCHECK(positioning_box.IsLayoutTableCol()); - LayoutRect sections_rect(LayoutPoint(), cell.Table()->Size()); + PhysicalRect sections_rect(PhysicalOffset(), cell.Table()->Size()); cell.Table()->SubtractCaptionRect(sections_rect); LayoutUnit column_height = sections_rect.Height() - cell.Table()->BorderBefore() - @@ -431,7 +431,7 @@ if (container) { DCHECK_GE(container->GetDocument().Lifecycle().GetState(), DocumentLifecycle::kPrePaintClean); - rect.MoveBy(container->FirstFragment().PaintOffset()); + rect.MoveBy(container->FirstFragment().PaintOffset().ToLayoutPoint()); } return rect; @@ -872,7 +872,8 @@ PaintPhase paint_phase, GlobalPaintFlags flags, const FillLayer& fill_layer, - const LayoutRect& paint_rect) { + const PhysicalRect& paint_rect_arg) { + LayoutRect paint_rect = paint_rect_arg.ToLayoutRect(); // Unsnapped positioning area is used to derive quantities // that reference source image maps and define non-integer values, such // as phase and position.
diff --git a/third_party/blink/renderer/core/paint/background_image_geometry.h b/third_party/blink/renderer/core/paint/background_image_geometry.h index a4a19a5..e4e7678b9 100644 --- a/third_party/blink/renderer/core/paint/background_image_geometry.h +++ b/third_party/blink/renderer/core/paint/background_image_geometry.h
@@ -5,6 +5,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_BACKGROUND_IMAGE_GEOMETRY_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_BACKGROUND_IMAGE_GEOMETRY_H_ +#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" #include "third_party/blink/renderer/core/paint/paint_phase.h" #include "third_party/blink/renderer/platform/geometry/layout_point.h" #include "third_party/blink/renderer/platform/geometry/layout_rect.h" @@ -44,7 +45,7 @@ PaintPhase, GlobalPaintFlags, const FillLayer&, - const LayoutRect& paint_rect); + const PhysicalRect& paint_rect); // Destination rects define the area into which the image will paint. // For cases where no explicit background size is requested, the destination @@ -56,8 +57,12 @@ // unsnapped rectangle is the size and location intended by the content // author, and is needed to correctly subset images when no background-size // size is given. - const LayoutRect& UnsnappedDestRect() const { return unsnapped_dest_rect_; } - const LayoutRect& SnappedDestRect() const { return snapped_dest_rect_; } + PhysicalRect UnsnappedDestRect() const { + return PhysicalRectToBeNoop(unsnapped_dest_rect_); + } + PhysicalRect SnappedDestRect() const { + return PhysicalRectToBeNoop(snapped_dest_rect_); + } // Tile size is the area into which to draw one copy of the image. It // need not be the same as the intrinsic size of the image; if not,
diff --git a/third_party/blink/renderer/core/paint/block_flow_paint_invalidator.cc b/third_party/blink/renderer/core/paint/block_flow_paint_invalidator.cc index 3ed613fa..7d02121 100644 --- a/third_party/blink/renderer/core/paint/block_flow_paint_invalidator.cc +++ b/third_party/blink/renderer/core/paint/block_flow_paint_invalidator.cc
@@ -7,6 +7,7 @@ #include "third_party/blink/renderer/core/layout/layout_block_flow.h" #include "third_party/blink/renderer/core/layout/layout_inline.h" #include "third_party/blink/renderer/core/paint/box_paint_invalidator.h" +#include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h" #include "third_party/blink/renderer/core/paint/paint_invalidator.h" namespace blink { @@ -44,6 +45,12 @@ ObjectPaintInvalidator object_paint_invalidator(block_flow_); object_paint_invalidator.InvalidateDisplayItemClient(block_flow_, reason); + NGPaintFragment* paint_fragment = block_flow_.PaintFragment(); + if (paint_fragment) { + object_paint_invalidator.InvalidateDisplayItemClient(*paint_fragment, + reason); + } + // PaintInvalidationRectangle happens when we invalidate the caret. // The later conditions don't apply when we invalidate the caret or the // selection. @@ -51,13 +58,19 @@ reason == PaintInvalidationReason::kSelection) return; - RootInlineBox* line = block_flow_.FirstRootBox(); - if (line && line->IsFirstLineStyle()) { - // It's the RootInlineBox that paints the ::first-line background. Note that - // since it may be expensive to figure out if the first line is affected by - // any ::first-line selectors at all, we just invalidate it unconditionally - // which is typically cheaper. - object_paint_invalidator.InvalidateDisplayItemClient(*line, reason); + // It's the RootInlineBox that paints the ::first-line background. Note that + // since it may be expensive to figure out if the first line is affected by + // any ::first-line selectors at all, we just invalidate it unconditionally + // which is typically cheaper. + if (RootInlineBox* line = block_flow_.FirstRootBox()) { + if (line->IsFirstLineStyle()) { + object_paint_invalidator.InvalidateDisplayItemClient(*line, reason); + } + } else if (paint_fragment) { + NGPaintFragment* line = paint_fragment->FirstLineBox(); + if (line && line->PhysicalFragment().UsesFirstLineStyle()) { + object_paint_invalidator.InvalidateDisplayItemClient(*line, reason); + } } if (block_flow_.MultiColumnFlowThread()) {
diff --git a/third_party/blink/renderer/core/paint/block_painter.cc b/third_party/blink/renderer/core/paint/block_painter.cc index fb676ef..0cbbf1c 100644 --- a/third_party/blink/renderer/core/paint/block_painter.cc +++ b/third_party/blink/renderer/core/paint/block_painter.cc
@@ -121,7 +121,7 @@ void BlockPainter::PaintOverflowControlsIfNeeded( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { if (layout_block_.HasOverflowClip() && layout_block_.StyleRef().Visibility() == EVisibility::kVisible && ShouldPaintSelfBlockBackground(paint_info.phase)) { @@ -234,7 +234,7 @@ DISABLE_CFI_PERF void BlockPainter::PaintObject(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { const PaintPhase paint_phase = paint_info.phase; // This function implements some of the painting order algorithm (described // within the description of stacking context, here @@ -291,7 +291,7 @@ } void BlockPainter::PaintBlockFlowContents(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { DCHECK(layout_block_.IsLayoutBlockFlow()); if (!layout_block_.ChildrenInline()) { PaintContents(paint_info, paint_offset); @@ -299,7 +299,7 @@ ObjectPainter(layout_block_).PaintInlineChildrenOutlines(paint_info); } else { LineBoxListPainter(To<LayoutBlockFlow>(layout_block_).LineBoxes()) - .Paint(layout_block_, paint_info, paint_offset); + .Paint(layout_block_, paint_info, paint_offset.ToLayoutPoint()); } // If we don't have any floats to paint, or we're in the wrong paint phase, @@ -339,7 +339,7 @@ } void BlockPainter::PaintCarets(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { LocalFrame* frame = layout_block_.GetFrame(); if (layout_block_.ShouldPaintCursorCaret()) @@ -351,9 +351,9 @@ } } -LayoutRect BlockPainter::OverflowRectForCullRectTesting( +PhysicalRect BlockPainter::OverflowRectForCullRectTesting( bool is_printing) const { - LayoutRect overflow_rect; + PhysicalRect overflow_rect; if (is_printing && layout_block_.IsAnonymousBlock() && layout_block_.ChildrenInline()) { // For case <a href="..."><div>...</div></a>, when layout_block_ is the @@ -361,11 +361,11 @@ // empty, but we need to continue painting to output <a>'s PDF URL rect // which covers the continuations, as if we included <a>'s PDF URL rect into // layout_block_'s visual overflow. - auto rects = layout_block_.PhysicalOutlineRects( - LayoutPoint(), NGOutlineType::kIncludeBlockVisualOverflow); + auto rects = layout_block_.OutlineRects( + PhysicalOffset(), NGOutlineType::kIncludeBlockVisualOverflow); overflow_rect = UnionRect(rects); } - overflow_rect.Unite(layout_block_.VisualOverflowRect()); + overflow_rect.Unite(layout_block_.PhysicalVisualOverflowRect()); bool include_layout_overflow = layout_block_.ScrollsOverflow() && @@ -373,12 +373,8 @@ RuntimeEnabledFeatures::CompositeAfterPaintEnabled()); if (include_layout_overflow) { - LayoutRect layout_overflow_rect = layout_block_.LayoutOverflowRect(); - overflow_rect.Unite(layout_overflow_rect); - layout_block_.FlipForWritingMode(overflow_rect); - overflow_rect.Move(-layout_block_.ScrolledContentOffset()); - } else { - layout_block_.FlipForWritingMode(overflow_rect); + overflow_rect.Unite(layout_block_.PhysicalLayoutOverflowRect()); + overflow_rect.Move(-PhysicalOffset(layout_block_.ScrolledContentOffset())); } return overflow_rect; } @@ -398,7 +394,7 @@ } void BlockPainter::PaintContents(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { DCHECK(!layout_block_.ChildrenInline()); PaintInfo paint_info_for_descendants = paint_info.ForDescendants(); layout_block_.PaintChildren(paint_info_for_descendants, paint_offset);
diff --git a/third_party/blink/renderer/core/paint/block_painter.h b/third_party/blink/renderer/core/paint/block_painter.h index 93966cb..a4a0776c 100644 --- a/third_party/blink/renderer/core/paint/block_painter.h +++ b/third_party/blink/renderer/core/paint/block_painter.h
@@ -13,12 +13,13 @@ namespace blink { -struct PaintInfo; -class ScopedPaintState; class InlineBox; class LayoutBlock; class LayoutBox; -class LayoutPoint; +class ScopedPaintState; +struct PaintInfo; +struct PhysicalOffset; +struct PhysicalRect; class BlockPainter { STACK_ALLOCATED(); @@ -27,12 +28,12 @@ BlockPainter(const LayoutBlock& block) : layout_block_(block) {} void Paint(const PaintInfo&); - void PaintObject(const PaintInfo&, const LayoutPoint& paint_offset); - void PaintContents(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintObject(const PaintInfo&, const PhysicalOffset& paint_offset); + void PaintContents(const PaintInfo&, const PhysicalOffset& paint_offset); void PaintChildren(const PaintInfo&); void PaintChild(const LayoutBox&, const PaintInfo&); void PaintOverflowControlsIfNeeded(const PaintInfo&, - const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); // See ObjectPainter::PaintAllPhasesAtomically(). void PaintAllChildPhasesAtomically(const LayoutBox&, const PaintInfo&); @@ -43,12 +44,13 @@ // Paint scroll hit test placeholders in the correct paint order (see: // ScrollHitTestDisplayItem.h). void PaintScrollHitTestDisplayItem(const PaintInfo&); - void PaintBlockFlowContents(const PaintInfo&, const LayoutPoint&); - void PaintCarets(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintBlockFlowContents(const PaintInfo&, const PhysicalOffset&); + void PaintCarets(const PaintInfo&, const PhysicalOffset& paint_offset); bool ShouldPaint(const ScopedPaintState&) const; - CORE_EXPORT LayoutRect OverflowRectForCullRectTesting(bool is_printing) const; + CORE_EXPORT PhysicalRect + OverflowRectForCullRectTesting(bool is_printing) const; FRIEND_TEST_ALL_PREFIXES(BlockPainterTest, OverflowRectForCullRectTesting); FRIEND_TEST_ALL_PREFIXES(BlockPainterTest,
diff --git a/third_party/blink/renderer/core/paint/block_painter_test.cc b/third_party/blink/renderer/core/paint/block_painter_test.cc index 3f69844..3736f579 100644 --- a/third_party/blink/renderer/core/paint/block_painter_test.cc +++ b/third_party/blink/renderer/core/paint/block_painter_test.cc
@@ -194,10 +194,10 @@ )HTML"); auto* scroller = To<LayoutBlock>(GetLayoutObjectByElementId("scroller")); if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { - EXPECT_EQ(LayoutRect(0, 0, 50, 5000), + EXPECT_EQ(PhysicalRect(0, 0, 50, 5000), BlockPainter(*scroller).OverflowRectForCullRectTesting(false)); } else { - EXPECT_EQ(LayoutRect(0, 0, 50, 50), + EXPECT_EQ(PhysicalRect(0, 0, 50, 50), BlockPainter(*scroller).OverflowRectForCullRectTesting(false)); } } @@ -209,7 +209,7 @@ </div> )HTML"); auto* scroller = To<LayoutBlock>(GetLayoutObjectByElementId("scroller")); - EXPECT_EQ(LayoutRect(0, 0, 50, 5000), + EXPECT_EQ(PhysicalRect(0, 0, 50, 5000), BlockPainter(*scroller).OverflowRectForCullRectTesting(false)); }
diff --git a/third_party/blink/renderer/core/paint/box_border_painter.cc b/third_party/blink/renderer/core/paint/box_border_painter.cc index e3a41fc..a15c271 100644 --- a/third_party/blink/renderer/core/paint/box_border_painter.cc +++ b/third_party/blink/renderer/core/paint/box_border_painter.cc
@@ -511,7 +511,7 @@ }; void BoxBorderPainter::DrawDoubleBorder(GraphicsContext& context, - const LayoutRect& border_rect) const { + const PhysicalRect& border_rect) const { DCHECK(is_uniform_color_); DCHECK(is_uniform_style_); DCHECK(FirstEdge().BorderStyle() == EBorderStyle::kDouble); @@ -526,8 +526,8 @@ const LayoutRectOutsets outer_third_insets = DoubleStripeInsets(edges_, BorderEdge::kDoubleBorderStripeOuter); FloatRoundedRect outer_third_rect = style_.GetRoundedInnerBorderFor( - border_rect, outer_third_insets, include_logical_left_edge_, - include_logical_right_edge_); + border_rect.ToLayoutRect(), outer_third_insets, + include_logical_left_edge_, include_logical_right_edge_); if (force_rectangular) outer_third_rect.SetRadii(FloatRoundedRect::Radii()); DrawBleedAdjustedDRRect(context, bleed_avoidance_, outer_, outer_third_rect, @@ -537,8 +537,8 @@ const LayoutRectOutsets inner_third_insets = DoubleStripeInsets(edges_, BorderEdge::kDoubleBorderStripeInner); FloatRoundedRect inner_third_rect = style_.GetRoundedInnerBorderFor( - border_rect, inner_third_insets, include_logical_left_edge_, - include_logical_right_edge_); + border_rect.ToLayoutRect(), inner_third_insets, + include_logical_left_edge_, include_logical_right_edge_); if (force_rectangular) inner_third_rect.SetRadii(FloatRoundedRect::Radii()); context.FillDRRect(inner_third_rect, inner_, color); @@ -546,7 +546,7 @@ bool BoxBorderPainter::PaintBorderFastPath( GraphicsContext& context, - const LayoutRect& border_rect) const { + const PhysicalRect& border_rect) const { if (!is_uniform_color_ || !is_uniform_style_ || !inner_.IsRenderable()) return false; @@ -598,7 +598,7 @@ return false; } -BoxBorderPainter::BoxBorderPainter(const LayoutRect& border_rect, +BoxBorderPainter::BoxBorderPainter(const PhysicalRect& border_rect, const ComputedStyle& style, BackgroundBleedAvoidance bleed_avoidance, bool include_logical_left_edge, @@ -623,10 +623,12 @@ if (!visible_edge_set_) return; - outer_ = style_.GetRoundedBorderFor(border_rect, include_logical_left_edge, + outer_ = style_.GetRoundedBorderFor(border_rect.ToLayoutRect(), + include_logical_left_edge, include_logical_right_edge); - inner_ = style_.GetRoundedInnerBorderFor( - border_rect, include_logical_left_edge, include_logical_right_edge); + inner_ = style_.GetRoundedInnerBorderFor(border_rect.ToLayoutRect(), + include_logical_left_edge, + include_logical_right_edge); // Make sure that the border width isn't larger than the border box, which // can pixel snap smaller. @@ -641,8 +643,8 @@ } BoxBorderPainter::BoxBorderPainter(const ComputedStyle& style, - const LayoutRect& outer, - const LayoutRect& inner, + const PhysicalRect& outer, + const PhysicalRect& inner, const BorderEdge& uniform_edge_info) : style_(style), bleed_avoidance_(kBackgroundBleedNone), @@ -697,7 +699,7 @@ } void BoxBorderPainter::PaintBorder(const PaintInfo& info, - const LayoutRect& rect) const { + const PhysicalRect& rect) const { if (!visible_edge_count_ || outer_.Rect().IsEmpty()) return; @@ -992,7 +994,8 @@ float stroke_thickness = std::max(std::max(edge_to_render.Width(), adjacent_edge1.Width()), adjacent_edge2.Width()); - DrawBoxSideFromPath(graphics_context, LayoutRect(outer_.Rect()), *path, + DrawBoxSideFromPath(graphics_context, + PhysicalRect::EnclosingRect(outer_.Rect()), *path, edge_to_render.Width(), stroke_thickness, side, color, edge_to_render.BorderStyle()); } else { @@ -1021,7 +1024,7 @@ } void BoxBorderPainter::DrawBoxSideFromPath(GraphicsContext& graphics_context, - const LayoutRect& border_rect, + const PhysicalRect& border_rect, const Path& border_path, float border_thickness, float stroke_thickness, @@ -1077,7 +1080,7 @@ void BoxBorderPainter::DrawDashedDottedBoxSideFromPath( GraphicsContext& graphics_context, - const LayoutRect& border_rect, + const PhysicalRect& border_rect, float border_thickness, float stroke_thickness, Color color, @@ -1090,7 +1093,7 @@ -edges_[static_cast<unsigned>(BoxSide::kLeft)].UsedWidth() * 0.5); Path centerline_path; centerline_path.AddRoundedRect(style_.GetRoundedInnerBorderFor( - border_rect, center_offsets, include_logical_left_edge_, + border_rect.ToLayoutRect(), center_offsets, include_logical_left_edge_, include_logical_right_edge_)); graphics_context.SetStrokeColor(color); @@ -1135,7 +1138,7 @@ void BoxBorderPainter::DrawDoubleBoxSideFromPath( GraphicsContext& graphics_context, - const LayoutRect& border_rect, + const PhysicalRect& border_rect, const Path& border_path, float border_thickness, float stroke_thickness, @@ -1147,7 +1150,7 @@ const LayoutRectOutsets inner_insets = DoubleStripeInsets(edges_, BorderEdge::kDoubleBorderStripeInner); FloatRoundedRect inner_clip = style_.GetRoundedInnerBorderFor( - border_rect, inner_insets, include_logical_left_edge_, + border_rect.ToLayoutRect(), inner_insets, include_logical_left_edge_, include_logical_right_edge_); graphics_context.ClipRoundedRect(inner_clip); @@ -1159,12 +1162,12 @@ // Draw outer border line { GraphicsContextStateSaver state_saver(graphics_context); - LayoutRect outer_rect = border_rect; + PhysicalRect outer_rect = border_rect; LayoutRectOutsets outer_insets = DoubleStripeInsets(edges_, BorderEdge::kDoubleBorderStripeOuter); if (BleedAvoidanceIsClipping(bleed_avoidance_)) { - outer_rect.Inflate(1); + outer_rect.Inflate(LayoutUnit(1)); outer_insets.SetTop(outer_insets.Top() - 1); outer_insets.SetRight(outer_insets.Right() - 1); outer_insets.SetBottom(outer_insets.Bottom() - 1); @@ -1172,7 +1175,7 @@ } FloatRoundedRect outer_clip = style_.GetRoundedInnerBorderFor( - outer_rect, outer_insets, include_logical_left_edge_, + outer_rect.ToLayoutRect(), outer_insets, include_logical_left_edge_, include_logical_right_edge_); graphics_context.ClipOutRoundedRect(outer_clip); DrawBoxSideFromPath(graphics_context, border_rect, border_path, @@ -1183,7 +1186,7 @@ void BoxBorderPainter::DrawRidgeGrooveBoxSideFromPath( GraphicsContext& graphics_context, - const LayoutRect& border_rect, + const PhysicalRect& border_rect, const Path& border_path, float border_thickness, float stroke_thickness, @@ -1215,7 +1218,7 @@ edges_[static_cast<unsigned>(BoxSide::kRight)].UsedWidth() / 2; FloatRoundedRect clip_rect = style_.GetRoundedInnerBorderFor( - border_rect, + border_rect.ToLayoutRect(), LayoutRectOutsets(-top_width, -right_width, -bottom_width, -left_width), include_logical_left_edge_, include_logical_right_edge_); @@ -1246,8 +1249,8 @@ FloatPoint bound_quad2; // Point 2 of the rectilinear bounding box of EdgeQuad - const LayoutRect outer_rect(outer_.Rect()); - const LayoutRect inner_rect(inner_.Rect()); + const PhysicalRect outer_rect = PhysicalRect::EnclosingRect(outer_.Rect()); + const PhysicalRect inner_rect = PhysicalRect::EnclosingRect(inner_.Rect()); // For each side, create a quad that encompasses all parts of that side that // may draw, including areas inside the innerBorder.
diff --git a/third_party/blink/renderer/core/paint/box_border_painter.h b/third_party/blink/renderer/core/paint/box_border_painter.h index b8891a3..f5846f5 100644 --- a/third_party/blink/renderer/core/paint/box_border_painter.h +++ b/third_party/blink/renderer/core/paint/box_border_painter.h
@@ -13,9 +13,9 @@ class ComputedStyle; class GraphicsContext; -class LayoutRect; -struct PaintInfo; class Path; +struct PaintInfo; +struct PhysicalRect; typedef unsigned BorderEdgeFlags; @@ -23,18 +23,18 @@ STACK_ALLOCATED(); public: - BoxBorderPainter(const LayoutRect& border_rect, + BoxBorderPainter(const PhysicalRect& border_rect, const ComputedStyle&, BackgroundBleedAvoidance, bool include_logical_left_edge, bool include_logical_right_edge); BoxBorderPainter(const ComputedStyle&, - const LayoutRect& outer, - const LayoutRect& inner, + const PhysicalRect& outer, + const PhysicalRect& inner, const BorderEdge& uniform_edge_info); - void PaintBorder(const PaintInfo&, const LayoutRect& border_rect) const; + void PaintBorder(const PaintInfo&, const PhysicalRect& border_rect) const; private: struct ComplexBorderInfo; @@ -65,11 +65,12 @@ Color, BorderEdgeFlags) const; bool PaintBorderFastPath(GraphicsContext&, - const LayoutRect& border_rect) const; - void DrawDoubleBorder(GraphicsContext&, const LayoutRect& border_rect) const; + const PhysicalRect& border_rect) const; + void DrawDoubleBorder(GraphicsContext&, + const PhysicalRect& border_rect) const; void DrawBoxSideFromPath(GraphicsContext&, - const LayoutRect&, + const PhysicalRect&, const Path&, float thickness, float draw_thickness, @@ -77,7 +78,7 @@ Color, EBorderStyle) const; void DrawDashedDottedBoxSideFromPath(GraphicsContext&, - const LayoutRect&, + const PhysicalRect&, float thickness, float draw_thickness, Color, @@ -86,14 +87,14 @@ const Path&, float thickness) const; void DrawDoubleBoxSideFromPath(GraphicsContext&, - const LayoutRect&, + const PhysicalRect&, const Path&, float thickness, float draw_thickness, BoxSide, Color) const; void DrawRidgeGrooveBoxSideFromPath(GraphicsContext&, - const LayoutRect&, + const PhysicalRect&, const Path&, float thickness, float draw_thickness,
diff --git a/third_party/blink/renderer/core/paint/box_decoration_data.h b/third_party/blink/renderer/core/paint/box_decoration_data.h index e81df54..9e1687f 100644 --- a/third_party/blink/renderer/core/paint/box_decoration_data.h +++ b/third_party/blink/renderer/core/paint/box_decoration_data.h
@@ -23,10 +23,15 @@ : BoxDecorationData(paint_info, layout_box, layout_box.StyleRef()) {} BoxDecorationData(const PaintInfo& paint_info, - const NGPhysicalBoxFragment& fragment) + const NGPhysicalFragment& fragment, + const ComputedStyle& style) : BoxDecorationData(paint_info, ToLayoutBox(*fragment.GetLayoutObject()), - fragment.Style()) {} + style) {} + + BoxDecorationData(const PaintInfo& paint_info, + const NGPhysicalFragment& fragment) + : BoxDecorationData(paint_info, fragment, fragment.Style()) {} bool IsPaintingScrollingBackground() const { return is_painting_scrolling_background_;
diff --git a/third_party/blink/renderer/core/paint/box_model_object_painter.cc b/third_party/blink/renderer/core/paint/box_model_object_painter.cc index 78c4fc7..1c667c7 100644 --- a/third_party/blink/renderer/core/paint/box_model_object_painter.cc +++ b/third_party/blink/renderer/core/paint/box_model_object_painter.cc
@@ -57,10 +57,11 @@ box_model_(box), flow_box_(flow_box) {} -void BoxModelObjectPainter::PaintTextClipMask(GraphicsContext& context, - const IntRect& mask_rect, - const LayoutPoint& paint_offset, - bool object_has_multiple_boxes) { +void BoxModelObjectPainter::PaintTextClipMask( + GraphicsContext& context, + const IntRect& mask_rect, + const PhysicalOffset& paint_offset, + bool object_has_multiple_boxes) { PaintInfo paint_info(context, mask_rect, PaintPhase::kTextClip, kGlobalPaintNormalPhase, 0); if (flow_box_) { @@ -71,8 +72,8 @@ local_offset -= LogicalOffsetOnLine(*flow_box_); } const RootInlineBox& root = flow_box_->Root(); - flow_box_->Paint(paint_info, paint_offset - local_offset, root.LineTop(), - root.LineBottom()); + flow_box_->Paint(paint_info, paint_offset.ToLayoutPoint() - local_offset, + root.LineTop(), root.LineBottom()); } else if (auto* layout_block = DynamicTo<LayoutBlock>(box_model_)) { layout_block->PaintObject(paint_info, paint_offset); } else { @@ -83,10 +84,10 @@ } } -LayoutRect BoxModelObjectPainter::AdjustRectForScrolledContent( +PhysicalRect BoxModelObjectPainter::AdjustRectForScrolledContent( const PaintInfo& paint_info, const BoxPainterBase::FillLayerInfo& info, - const LayoutRect& rect) { + const PhysicalRect& rect) { if (!info.is_clipped_with_local_scrolling) return rect; @@ -94,15 +95,15 @@ if (BoxDecorationData::IsPaintingScrollingBackground(paint_info, this_box)) return rect; - LayoutRect scrolled_paint_rect = rect; + PhysicalRect scrolled_paint_rect = rect; GraphicsContext& context = paint_info.context; // Clip to the overflow area. // TODO(chrishtr): this should be pixel-snapped. - context.Clip(FloatRect(this_box.OverflowClipRect(rect.Location()))); + context.Clip(FloatRect(this_box.OverflowClipRect(rect.offset))); // Adjust the paint rect to reflect a scrolled content box with borders at // the ends. - IntSize offset = this_box.ScrolledContentOffset(); + PhysicalOffset offset(this_box.ScrolledContentOffset()); scrolled_paint_rect.Move(-offset); LayoutRectOutsets border = AdjustedBorderOutsets(info); scrolled_paint_rect.SetWidth(border.Left() + this_box.ScrollWidth() +
diff --git a/third_party/blink/renderer/core/paint/box_model_object_painter.h b/third_party/blink/renderer/core/paint/box_model_object_painter.h index 8515ce7..682ce2ee 100644 --- a/third_party/blink/renderer/core/paint/box_model_object_painter.h +++ b/third_party/blink/renderer/core/paint/box_model_object_painter.h
@@ -14,9 +14,9 @@ class FillLayer; class InlineFlowBox; -class LayoutRect; -struct PaintInfo; class LayoutBoxModelObject; +struct PaintInfo; +struct PhysicalRect; // BoxModelObjectPainter is a class that can paint either a LayoutBox or a // LayoutInline and allows code sharing between block and inline block painting. @@ -37,11 +37,12 @@ void PaintTextClipMask(GraphicsContext&, const IntRect& mask_rect, - const LayoutPoint& paint_offset, + const PhysicalOffset& paint_offset, bool object_has_multiple_boxes) override; - LayoutRect AdjustRectForScrolledContent(const PaintInfo&, - const BoxPainterBase::FillLayerInfo&, - const LayoutRect&) override; + PhysicalRect AdjustRectForScrolledContent( + const PaintInfo&, + const BoxPainterBase::FillLayerInfo&, + const PhysicalRect&) override; private: const LayoutBoxModelObject& box_model_;
diff --git a/third_party/blink/renderer/core/paint/box_paint_invalidator.cc b/third_party/blink/renderer/core/paint/box_paint_invalidator.cc index 8701a582..6b4217c3 100644 --- a/third_party/blink/renderer/core/paint/box_paint_invalidator.cc +++ b/third_party/blink/renderer/core/paint/box_paint_invalidator.cc
@@ -108,11 +108,11 @@ // old_size and new_size are the old and new sizes of the positioning area. bool ShouldFullyInvalidateFillLayersOnSizeChange(const FillLayer& layer, - const LayoutSize& old_size, - const LayoutSize& new_size) { - return (old_size.Width() != new_size.Width() && + const PhysicalSize& old_size, + const PhysicalSize& new_size) { + return (old_size.width != new_size.width && ShouldFullyInvalidateFillLayersOnWidthChange(layer)) || - (old_size.Height() != new_size.Height() && + (old_size.height != new_size.height && ShouldFullyInvalidateFillLayersOnHeightChange(layer)); } @@ -140,10 +140,10 @@ // - pixel snapping, or not snapping e.g. for some visual overflowing effects, // - scale, rotate, skew etc. transforms, // - visual (ink) overflows. - if (LayoutRect(context_.old_visual_rect) != - LayoutRect(context_.old_paint_offset, box_.PreviousSize()) || - LayoutRect(context_.fragment_data->VisualRect()) != - LayoutRect(context_.fragment_data->PaintOffset(), box_.Size())) { + if (PhysicalRect(context_.old_visual_rect) != + PhysicalRect(context_.old_paint_offset, box_.PreviousSize()) || + PhysicalRect(context_.fragment_data->VisualRect()) != + PhysicalRect(context_.fragment_data->PaintOffset(), box_.Size())) { return PaintInvalidationReason::kGeometry; } @@ -208,8 +208,8 @@ } bool BoxPaintInvalidator::ShouldFullyInvalidateBackgroundOnLayoutOverflowChange( - const LayoutRect& old_layout_overflow, - const LayoutRect& new_layout_overflow) { + const PhysicalRect& old_layout_overflow, + const PhysicalRect& new_layout_overflow) { if (new_layout_overflow == old_layout_overflow) return false; @@ -217,12 +217,12 @@ return false; // The background should invalidate on most location changes. - if (new_layout_overflow.Location() != old_layout_overflow.Location()) + if (new_layout_overflow.offset != old_layout_overflow.offset) return true; return ShouldFullyInvalidateFillLayersOnSizeChange( - box_.StyleRef().BackgroundLayers(), old_layout_overflow.Size(), - new_layout_overflow.Size()); + box_.StyleRef().BackgroundLayers(), old_layout_overflow.size, + new_layout_overflow.size); } BoxPaintInvalidator::BackgroundInvalidationType @@ -237,9 +237,9 @@ // BackgroundRect is the positioning area of all fixed attachment backgrounds, // including the LayoutView's and descendants'. bool background_location_changed = - new_background_rect.Location() != old_background_rect.Location(); + new_background_rect.offset != old_background_rect.offset; bool background_size_changed = - new_background_rect.Size() != old_background_rect.Size(); + new_background_rect.size != old_background_rect.size; if (background_location_changed || background_size_changed) { for (auto* object : layout_view.GetFrameView()->BackgroundAttachmentFixedObjects()) @@ -260,10 +260,8 @@ if (document_background && document_background->IsBox()) { const auto* document_background_box = ToLayoutBox(document_background); if (ShouldFullyInvalidateBackgroundOnLayoutOverflowChange( - document_background_box->PreviousPhysicalLayoutOverflowRect() - .ToLayoutRect(), - document_background_box->PhysicalLayoutOverflowRect() - .ToLayoutRect())) { + document_background_box->PreviousPhysicalLayoutOverflowRect(), + document_background_box->PhysicalLayoutOverflowRect())) { return BackgroundInvalidationType::kFull; } } @@ -300,7 +298,8 @@ const auto& background_layers = box_.StyleRef().BackgroundLayers(); if (background_layers.AnyLayerHasDefaultAttachmentImage() && ShouldFullyInvalidateFillLayersOnSizeChange( - background_layers, box_.PreviousSize(), box_.Size())) + background_layers, PhysicalSizeToBeNoop(box_.PreviousSize()), + PhysicalSizeToBeNoop(box_.Size()))) return BackgroundInvalidationType::kFull; if (background_layers.AnyLayerUsesContentBox() && @@ -317,8 +316,7 @@ const auto& old_layout_overflow = box_.PreviousPhysicalLayoutOverflowRect(); auto new_layout_overflow = box_.PhysicalLayoutOverflowRect(); if (ShouldFullyInvalidateBackgroundOnLayoutOverflowChange( - old_layout_overflow.ToLayoutRect(), - new_layout_overflow.ToLayoutRect())) + old_layout_overflow, new_layout_overflow)) return BackgroundInvalidationType::kFull; if (new_layout_overflow != old_layout_overflow) {
diff --git a/third_party/blink/renderer/core/paint/box_paint_invalidator.h b/third_party/blink/renderer/core/paint/box_paint_invalidator.h index 2935f46..2954491 100644 --- a/third_party/blink/renderer/core/paint/box_paint_invalidator.h +++ b/third_party/blink/renderer/core/paint/box_paint_invalidator.h
@@ -12,8 +12,8 @@ namespace blink { class LayoutBox; -class LayoutRect; struct PaintInvalidatorContext; +struct PhysicalRect; class CORE_EXPORT BoxPaintInvalidator { STACK_ALLOCATED(); @@ -35,8 +35,8 @@ bool BackgroundPaintsOntoScrollingContentsLayer(); bool BackgroundPaintsOntoMainGraphicsLayer(); bool ShouldFullyInvalidateBackgroundOnLayoutOverflowChange( - const LayoutRect& old_layout_overflow, - const LayoutRect& new_layout_overflow); + const PhysicalRect& old_layout_overflow, + const PhysicalRect& new_layout_overflow); enum BackgroundInvalidationType { kNone = 0, kIncremental, kFull }; BackgroundInvalidationType ComputeViewBackgroundInvalidation();
diff --git a/third_party/blink/renderer/core/paint/box_paint_invalidator_test.cc b/third_party/blink/renderer/core/paint/box_paint_invalidator_test.cc index be3ff037..985b129 100644 --- a/third_party/blink/renderer/core/paint/box_paint_invalidator_test.cc +++ b/third_party/blink/renderer/core/paint/box_paint_invalidator_test.cc
@@ -28,7 +28,7 @@ PaintInvalidationReason ComputePaintInvalidationReason( const LayoutBox& box, const IntRect& old_visual_rect, - const LayoutPoint& old_paint_offset) { + const PhysicalOffset& old_paint_offset) { FragmentData fragment_data; PaintInvalidatorContext context; context.old_visual_rect = old_visual_rect; @@ -39,6 +39,16 @@ return BoxPaintInvalidator(box, context).ComputePaintInvalidationReason(); } + // Accepts old_paint_offset as an IntPoint for convenience of passing it + // based on visual rect offset. + PaintInvalidationReason ComputePaintInvalidationReason( + const LayoutBox& box, + const IntRect& old_visual_rect, + const IntPoint& old_paint_offset) { + return ComputePaintInvalidationReason(box, old_visual_rect, + PhysicalOffset(old_paint_offset)); + } + // This applies when the target is set to meet conditions that we should do // full paint invalidation instead of incremental invalidation on geometry // change. @@ -111,14 +121,14 @@ auto visual_rect = box.FirstFragment().VisualRect(); // No geometry change. - EXPECT_EQ(PaintInvalidationReason::kNone, - ComputePaintInvalidationReason( - box, visual_rect, LayoutPoint(visual_rect.Location()))); + EXPECT_EQ( + PaintInvalidationReason::kNone, + ComputePaintInvalidationReason(box, visual_rect, visual_rect.Location())); // Paint offset change. EXPECT_EQ(PaintInvalidationReason::kNone, ComputePaintInvalidationReason( - box, visual_rect, visual_rect.Location() + LayoutSize(10, 20))); + box, visual_rect, visual_rect.Location() + IntSize(10, 20))); // Visual rect size change. auto old_visual_rect = visual_rect; @@ -129,8 +139,8 @@ IntRect(visual_rect.Location(), RoundedIntSize(box.Size()))); EXPECT_EQ(PaintInvalidationReason::kNone, - ComputePaintInvalidationReason( - box, old_visual_rect, LayoutPoint(old_visual_rect.Location()))); + ComputePaintInvalidationReason(box, old_visual_rect, + old_visual_rect.Location())); } TEST_P(BoxPaintInvalidatorTest, ComputePaintInvalidationReasonBasic) { @@ -147,9 +157,9 @@ EXPECT_EQ(IntRect(0, 0, 50, 100), visual_rect); // No geometry change. - EXPECT_EQ(PaintInvalidationReason::kNone, - ComputePaintInvalidationReason( - box, visual_rect, LayoutPoint(visual_rect.Location()))); + EXPECT_EQ( + PaintInvalidationReason::kNone, + ComputePaintInvalidationReason(box, visual_rect, visual_rect.Location())); // Visual rect size change. auto old_visual_rect = visual_rect; @@ -160,13 +170,13 @@ IntRect(visual_rect.Location(), RoundedIntSize(box.Size()))); EXPECT_EQ(PaintInvalidationReason::kIncremental, - ComputePaintInvalidationReason( - box, old_visual_rect, LayoutPoint(old_visual_rect.Location()))); + ComputePaintInvalidationReason(box, old_visual_rect, + old_visual_rect.Location())); // Visual rect size change, with paint offset different from location of // visual rect. - LayoutPoint fake_paint_offset = - LayoutPoint(visual_rect.Location()) + LayoutSize(10, 20); + PhysicalOffset fake_paint_offset = + PhysicalOffset(visual_rect.Location()) + PhysicalOffset(10, 20); box.GetMutableForPainting().FirstFragment().SetPaintOffset(fake_paint_offset); EXPECT_EQ( PaintInvalidationReason::kGeometry, @@ -175,13 +185,12 @@ // Should use the existing full paint invalidation reason regardless of // geometry change. box.SetShouldDoFullPaintInvalidation(PaintInvalidationReason::kStyle); + EXPECT_EQ( + PaintInvalidationReason::kStyle, + ComputePaintInvalidationReason(box, visual_rect, visual_rect.Location())); EXPECT_EQ(PaintInvalidationReason::kStyle, ComputePaintInvalidationReason( - box, visual_rect, LayoutPoint(visual_rect.Location()))); - EXPECT_EQ(PaintInvalidationReason::kStyle, - ComputePaintInvalidationReason( - box, visual_rect, - LayoutPoint(visual_rect.Location()) + LayoutSize(10, 20))); + box, visual_rect, visual_rect.Location() + IntSize(10, 20))); } TEST_P(BoxPaintInvalidatorTest, ComputePaintInvalidationReasonOtherCases) {
diff --git a/third_party/blink/renderer/core/paint/box_painter.cc b/third_party/blink/renderer/core/paint/box_painter.cc index 7da0a329..634d771 100644 --- a/third_party/blink/renderer/core/paint/box_painter.cc +++ b/third_party/blink/renderer/core/paint/box_painter.cc
@@ -51,9 +51,10 @@ } } -void BoxPainter::PaintBoxDecorationBackground(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { - LayoutRect paint_rect; +void BoxPainter::PaintBoxDecorationBackground( + const PaintInfo& paint_info, + const PhysicalOffset& paint_offset) { + PhysicalRect paint_rect; const DisplayItemClient* background_client = nullptr; base::Optional<ScopedBoxContentsPaintState> contents_paint_state; if (BoxDecorationData::IsPaintingScrollingBackground(paint_info, @@ -61,9 +62,9 @@ // For the case where we are painting the background into the scrolling // contents layer of a composited scroller we need to include the entire // overflow rect. - paint_rect = layout_box_.PhysicalLayoutOverflowRect().ToLayoutRect(); + paint_rect = layout_box_.PhysicalLayoutOverflowRect(); contents_paint_state.emplace(paint_info, paint_offset, layout_box_); - paint_rect.MoveBy(contents_paint_state->PaintOffset()); + paint_rect.Move(contents_paint_state->PaintOffset()); // The background painting code assumes that the borders are part of the // paint_rect so we expand the paint_rect by the border size when painting @@ -73,8 +74,8 @@ background_client = &layout_box_.GetScrollableArea() ->GetScrollingBackgroundDisplayItemClient(); } else { - paint_rect = layout_box_.BorderBoxRect(); - paint_rect.MoveBy(paint_offset); + paint_rect = layout_box_.PhysicalBorderBoxRect(); + paint_rect.Move(paint_offset); background_client = &layout_box_; } @@ -99,16 +100,16 @@ if (layout_box_.FirstFragment().NextFragment()) return false; - LayoutRect bounds = + PhysicalRect bounds = BoxDecorationData::IsPaintingScrollingBackground(paint_info, layout_box_) - ? layout_box_.LayoutOverflowRect() - : layout_box_.SelfVisualOverflowRect(); + ? layout_box_.PhysicalLayoutOverflowRect() + : layout_box_.PhysicalSelfVisualOverflowRect(); return layout_box_.BackgroundIsKnownToBeOpaqueInRect(bounds); } void BoxPainter::PaintBoxDecorationBackgroundWithRect( const PaintInfo& paint_info, - const LayoutRect& paint_rect, + const PhysicalRect& paint_rect, const DisplayItemClient& background_client) { const ComputedStyle& style = layout_box_.StyleRef(); @@ -139,7 +140,7 @@ GraphicsContextStateSaver state_saver(paint_info.context, false); if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() && - LayoutRect(EnclosingIntRect(paint_rect)) == paint_rect && + paint_rect.EdgesOnPixelBoundaries() && BackgroundIsKnownToBeOpaque(paint_info)) recorder.SetKnownToBeOpaque(); @@ -156,7 +157,8 @@ if (BleedAvoidanceIsClipping( box_decoration_data.GetBackgroundBleedAvoidance())) { state_saver.Save(); - FloatRoundedRect border = style.GetRoundedBorderFor(paint_rect); + FloatRoundedRect border = + style.GetRoundedBorderFor(paint_rect.ToLayoutRect()); paint_info.context.ClipRoundedRect(border); if (box_decoration_data.GetBackgroundBleedAvoidance() == @@ -214,7 +216,7 @@ } void BoxPainter::PaintBackground(const PaintInfo& paint_info, - const LayoutRect& paint_rect, + const PhysicalRect& paint_rect, const Color& background_color, BackgroundBleedAvoidance bleed_avoidance) { if (layout_box_.BackgroundTransfersToView()) @@ -229,7 +231,7 @@ } void BoxPainter::PaintMask(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { DCHECK_EQ(PaintPhase::kMask, paint_info.phase); if (!layout_box_.HasMask() || @@ -241,12 +243,12 @@ return; DrawingRecorder recorder(paint_info.context, layout_box_, paint_info.phase); - LayoutRect paint_rect = LayoutRect(paint_offset, layout_box_.Size()); + PhysicalRect paint_rect(paint_offset, layout_box_.Size()); PaintMaskImages(paint_info, paint_rect); } void BoxPainter::PaintMaskImages(const PaintInfo& paint_info, - const LayoutRect& paint_rect) { + const PhysicalRect& paint_rect) { // For mask images legacy layout painting handles multi-line boxes by giving // the full width of the element, not the current line box, thereby clipping // the offending edges. @@ -261,7 +263,7 @@ } void BoxPainter::RecordHitTestData(const PaintInfo& paint_info, - const LayoutRect& paint_rect, + const PhysicalRect& paint_rect, const DisplayItemClient& background_client) { // Hit test display items are only needed for compositing. This flag is used // for for printing and drag images which do not need hit testing. @@ -276,8 +278,9 @@ if (touch_action == TouchAction::kTouchActionAuto) return; - HitTestDisplayItem::Record(paint_info.context, background_client, - HitTestRect(paint_rect, touch_action)); + HitTestDisplayItem::Record( + paint_info.context, background_client, + HitTestRect(paint_rect.ToLayoutRect(), touch_action)); } } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/box_painter.h b/third_party/blink/renderer/core/paint/box_painter.h index 89f67ee..ccabfa3 100644 --- a/third_party/blink/renderer/core/paint/box_painter.h +++ b/third_party/blink/renderer/core/paint/box_painter.h
@@ -13,12 +13,12 @@ namespace blink { -struct PaintInfo; class Color; class DisplayItemClient; class LayoutBox; -class LayoutPoint; -class LayoutRect; +struct PaintInfo; +struct PhysicalOffset; +struct PhysicalRect; class BoxPainter { STACK_ALLOCATED(); @@ -29,26 +29,26 @@ void PaintChildren(const PaintInfo&); void PaintBoxDecorationBackground(const PaintInfo&, - const LayoutPoint& paint_offset); - void PaintMask(const PaintInfo&, const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); + void PaintMask(const PaintInfo&, const PhysicalOffset& paint_offset); - void PaintMaskImages(const PaintInfo&, const LayoutRect&); + void PaintMaskImages(const PaintInfo&, const PhysicalRect&); void PaintBoxDecorationBackgroundWithRect( const PaintInfo&, - const LayoutRect&, + const PhysicalRect&, const DisplayItemClient& background_client); // Paint a hit test display item and record hit test data. This should be // called in the background paint phase even if there is no other painted // content. void RecordHitTestData(const PaintInfo&, - const LayoutRect& paint_rect, + const PhysicalRect& paint_rect, const DisplayItemClient& background_client); private: bool BackgroundIsKnownToBeOpaque(const PaintInfo&); void PaintBackground(const PaintInfo&, - const LayoutRect&, + const PhysicalRect&, const Color& background_color, BackgroundBleedAvoidance = kBackgroundBleedNone);
diff --git a/third_party/blink/renderer/core/paint/box_painter_base.cc b/third_party/blink/renderer/core/paint/box_painter_base.cc index 96936207..ef09329 100644 --- a/third_party/blink/renderer/core/paint/box_painter_base.cc +++ b/third_party/blink/renderer/core/paint/box_painter_base.cc
@@ -30,7 +30,7 @@ void BoxPainterBase::PaintFillLayers(const PaintInfo& paint_info, const Color& c, const FillLayer& fill_layer, - const LayoutRect& rect, + const PhysicalRect& rect, BackgroundImageGeometry& geometry, BackgroundBleedAvoidance bleed) { FillLayerOcclusionOutputList reversed_paint_list; @@ -54,7 +54,7 @@ } void BoxPainterBase::PaintNormalBoxShadow(const PaintInfo& info, - const LayoutRect& paint_rect, + const PhysicalRect& paint_rect, const ComputedStyle& style, bool include_logical_left_edge, bool include_logical_right_edge, @@ -64,7 +64,8 @@ GraphicsContext& context = info.context; FloatRoundedRect border = style.GetRoundedBorderFor( - paint_rect, include_logical_left_edge, include_logical_right_edge); + paint_rect.ToLayoutRect(), include_logical_left_edge, + include_logical_right_edge); bool has_border_radius = style.HasBorderRadius(); bool has_opaque_background = @@ -155,25 +156,27 @@ void BoxPainterBase::PaintInsetBoxShadowWithBorderRect( const PaintInfo& info, - const LayoutRect& border_rect, + const PhysicalRect& border_rect, const ComputedStyle& style, bool include_logical_left_edge, bool include_logical_right_edge) { if (!style.BoxShadow()) return; - auto bounds = style.GetRoundedInnerBorderFor( - border_rect, include_logical_left_edge, include_logical_right_edge); + auto bounds = style.GetRoundedInnerBorderFor(border_rect.ToLayoutRect(), + include_logical_left_edge, + include_logical_right_edge); PaintInsetBoxShadow(info, bounds, style, include_logical_left_edge, include_logical_right_edge); } void BoxPainterBase::PaintInsetBoxShadowWithInnerRect( const PaintInfo& info, - const LayoutRect& inner_rect, + const PhysicalRect& inner_rect, const ComputedStyle& style) { if (!style.BoxShadow()) return; - auto bounds = style.GetRoundedInnerBorderFor(inner_rect, LayoutRectOutsets()); + auto bounds = style.GetRoundedInnerBorderFor(inner_rect.ToLayoutRect(), + LayoutRectOutsets()); PaintInsetBoxShadow(info, bounds, style); } @@ -422,7 +425,7 @@ inline bool PaintFastBottomLayer(Node* node, const PaintInfo& paint_info, const BoxPainterBase::FillLayerInfo& info, - const LayoutRect& rect, + const PhysicalRect& rect, const FloatRoundedRect& border_rect, BackgroundImageGeometry& geometry, Image* image, @@ -470,12 +473,12 @@ // Phase calculation uses the actual painted location, given by the // border-snapped destination rect. image_tile = ComputePhaseForBackground( - FloatPoint(geometry.SnappedDestRect().Location()), + FloatPoint(geometry.SnappedDestRect().offset), FloatSize(geometry.TileSize()), geometry.Phase(), FloatSize(geometry.SpaceSize())); // Force the image tile to LayoutUnit precision, which is the precision - // it was calcuated in. This avoids bleeding due to values very close to + // it was calculated in. This avoids bleeding due to values very close to // integers. // The test images/sprite-no-bleed.html fails on two of the sub-cases // due to this rounding still not being enough to make the Contains check @@ -520,9 +523,9 @@ // this is a generated image sized according to the tile size (which is a // snapped value), use the snapped dest rect instead. FloatRect dest_rect_for_subset( - FloatPoint(geometry.SnappedDestRect().Location()), - !has_intrinsic_size ? FloatSize(geometry.SnappedDestRect().Size()) - : FloatSize(geometry.UnsnappedDestRect().Size())); + FloatPoint(geometry.SnappedDestRect().offset), + !has_intrinsic_size ? FloatSize(geometry.SnappedDestRect().size) + : FloatSize(geometry.UnsnappedDestRect().size)); // Content providers almost always choose source pixels at integer locations, // so snap to integers. This is particuarly important for sprite maps. // Calculation up to this point, in LayoutUnits, can lead to small variations @@ -570,7 +573,7 @@ // border styles, 1/6 border-width for double borders. FloatRoundedRect BackgroundRoundedRectAdjustedForBleedAvoidance( const ComputedStyle& style, - const LayoutRect& border_rect, + const PhysicalRect& border_rect, bool object_has_multiple_boxes, bool include_logical_left_edge, bool include_logical_right_edge, @@ -610,16 +613,16 @@ const ComputedStyle& style, const BoxPainterBase::FillLayerInfo& info, const FillLayer& bg_layer, - const LayoutRect& rect, + const PhysicalRect& rect, bool object_has_multiple_boxes, - const LayoutSize& flow_box_size, + const PhysicalSize& flow_box_size, BackgroundBleedAvoidance bleed_avoidance, LayoutRectOutsets border_padding_insets) { if (!info.is_rounded_fill) return FloatRoundedRect(); FloatRoundedRect border = style.GetRoundedBorderFor( - rect, info.include_left_edge, info.include_right_edge); + rect.ToLayoutRect(), info.include_left_edge, info.include_right_edge); if (object_has_multiple_boxes) { FloatRoundedRect segment_border = style.GetRoundedBorderFor( LayoutRect(LayoutPoint(), LayoutSize(FlooredIntSize(flow_box_size))), @@ -653,7 +656,7 @@ Image* image, SkBlendMode composite_op, const BackgroundImageGeometry& geometry, - LayoutRect scrolled_paint_rect) { + const PhysicalRect& scrolled_paint_rect) { // Paint the color first underneath all images, culled if background image // occludes it. // TODO(trchen): In the !bgLayer.hasRepeatXY() case, we could improve the @@ -675,7 +678,7 @@ node, *info.image, FloatRect(image->Rect()), FloatRect(scrolled_paint_rect))); DrawTiledBackground(context, image, - FloatSize(geometry.UnsnappedDestRect().Size()), + FloatSize(geometry.UnsnappedDestRect().size), FloatRect(geometry.SnappedDestRect()), geometry.Phase(), FloatSize(geometry.TileSize()), composite_op, FloatSize(geometry.SpaceSize())); @@ -725,11 +728,11 @@ void BoxPainterBase::PaintFillLayer(const PaintInfo& paint_info, const Color& color, const FillLayer& bg_layer, - const LayoutRect& rect, + const PhysicalRect& rect, BackgroundBleedAvoidance bleed_avoidance, BackgroundImageGeometry& geometry, bool object_has_multiple_boxes, - const LayoutSize flow_box_size) { + const PhysicalSize& flow_box_size) { GraphicsContext& context = paint_info.context; if (rect.IsEmpty()) return; @@ -809,7 +812,7 @@ break; // Clip to the padding or content boxes as necessary. - LayoutRect clip_rect = scrolled_paint_rect; + PhysicalRect clip_rect = scrolled_paint_rect; clip_rect.Contract(AdjustOutsetsForEdgeInclusion(border, info)); if (bg_layer.Clip() == EFillBox::kContent) clip_rect.Contract(AdjustOutsetsForEdgeInclusion(padding, info)); @@ -836,8 +839,8 @@ Image* image, SkBlendMode composite_op, const BackgroundImageGeometry& geometry, - const LayoutRect& rect, - const LayoutRect& scrolled_paint_rect, + const PhysicalRect& rect, + const PhysicalRect& scrolled_paint_rect, bool object_has_multiple_boxes) { // First figure out how big the mask has to be. It should be no bigger // than what we need to actually render, so we should intersect the dirty @@ -859,7 +862,7 @@ // they should just add their contents to the clip. context.BeginLayer(1, SkBlendMode::kDstIn); - PaintTextClipMask(context, mask_rect, scrolled_paint_rect.Location(), + PaintTextClipMask(context, mask_rect, scrolled_paint_rect.offset, object_has_multiple_boxes); context.EndLayer(); // Text mask layer. @@ -870,7 +873,7 @@ const Document& document, Node* node, const PaintInfo& info, - const LayoutRect& rect, + const PhysicalRect& rect, const ComputedStyle& style, BackgroundBleedAvoidance bleed_avoidance, bool include_logical_left_edge, @@ -888,7 +891,7 @@ } void BoxPainterBase::PaintMaskImages(const PaintInfo& paint_info, - const LayoutRect& paint_rect, + const PhysicalRect& paint_rect, const ImageResourceObserver& obj, BackgroundImageGeometry& geometry, bool include_logical_left_edge,
diff --git a/third_party/blink/renderer/core/paint/box_painter_base.h b/third_party/blink/renderer/core/paint/box_painter_base.h index d4b0d7f..ec244ad 100644 --- a/third_party/blink/renderer/core/paint/box_painter_base.h +++ b/third_party/blink/renderer/core/paint/box_painter_base.h
@@ -6,9 +6,9 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_BOX_PAINTER_BASE_H_ #include "third_party/blink/renderer/core/layout/background_bleed_avoidance.h" +#include "third_party/blink/renderer/core/layout/geometry/physical_size.h" #include "third_party/blink/renderer/core/style/style_image.h" #include "third_party/blink/renderer/platform/geometry/layout_rect_outsets.h" -#include "third_party/blink/renderer/platform/geometry/layout_size.h" #include "third_party/blink/renderer/platform/graphics/color.h" #include "third_party/blink/renderer/platform/wtf/allocator.h" #include "third_party/skia/include/core/SkBlendMode.h" @@ -23,9 +23,9 @@ class GraphicsContext; class ImageResourceObserver; class IntRect; -class LayoutPoint; -class LayoutRect; struct PaintInfo; +struct PhysicalOffset; +struct PhysicalRect; // Base class for box painting. Has no dependencies on the layout tree and thus // provides functionality and definitions that can be shared between both legacy @@ -42,28 +42,28 @@ void PaintFillLayers(const PaintInfo&, const Color&, const FillLayer&, - const LayoutRect&, + const PhysicalRect&, BackgroundImageGeometry&, BackgroundBleedAvoidance = kBackgroundBleedNone); void PaintFillLayer(const PaintInfo&, const Color&, const FillLayer&, - const LayoutRect&, + const PhysicalRect&, BackgroundBleedAvoidance, BackgroundImageGeometry&, bool object_has_multiple_boxes = false, - const LayoutSize flow_box_size = LayoutSize()); + const PhysicalSize& flow_box_size = PhysicalSize()); void PaintMaskImages(const PaintInfo&, - const LayoutRect&, + const PhysicalRect&, const ImageResourceObserver&, BackgroundImageGeometry&, bool include_logical_left_edge, bool include_logical_right_edge); static void PaintNormalBoxShadow(const PaintInfo&, - const LayoutRect&, + const PhysicalRect&, const ComputedStyle&, bool include_logical_left_edge = true, bool include_logical_right_edge = true, @@ -71,20 +71,20 @@ static void PaintInsetBoxShadowWithBorderRect( const PaintInfo&, - const LayoutRect&, + const PhysicalRect&, const ComputedStyle&, bool include_logical_left_edge = true, bool include_logical_right_edge = true); static void PaintInsetBoxShadowWithInnerRect(const PaintInfo&, - const LayoutRect&, + const PhysicalRect&, const ComputedStyle&); static void PaintBorder(const ImageResourceObserver&, const Document&, Node*, const PaintInfo&, - const LayoutRect&, + const PhysicalRect&, const ComputedStyle&, BackgroundBleedAvoidance = kBackgroundBleedNone, bool include_logical_left_edge = true, @@ -140,17 +140,17 @@ Image*, SkBlendMode composite_op, const BackgroundImageGeometry&, - const LayoutRect&, - const LayoutRect& scrolled_paint_rect, + const PhysicalRect&, + const PhysicalRect& scrolled_paint_rect, bool object_has_multiple_boxes); virtual void PaintTextClipMask(GraphicsContext&, const IntRect& mask_rect, - const LayoutPoint& paint_offset, + const PhysicalOffset& paint_offset, bool object_has_multiple_boxes) = 0; - virtual LayoutRect AdjustRectForScrolledContent(const PaintInfo&, - const FillLayerInfo&, - const LayoutRect&) = 0; + virtual PhysicalRect AdjustRectForScrolledContent(const PaintInfo&, + const FillLayerInfo&, + const PhysicalRect&) = 0; virtual FillLayerInfo GetFillLayerInfo(const Color&, const FillLayer&, BackgroundBleedAvoidance) const = 0;
diff --git a/third_party/blink/renderer/core/paint/box_reflection_utils.cc b/third_party/blink/renderer/core/paint/box_reflection_utils.cc index 520c388..17996f4d 100644 --- a/third_party/blink/renderer/core/paint/box_reflection_utils.cc +++ b/third_party/blink/renderer/core/paint/box_reflection_utils.cc
@@ -7,9 +7,6 @@ #include "third_party/blink/renderer/core/layout/layout_box.h" #include "third_party/blink/renderer/core/paint/nine_piece_image_painter.h" #include "third_party/blink/renderer/core/paint/paint_layer.h" -#include "third_party/blink/renderer/platform/geometry/float_rect.h" -#include "third_party/blink/renderer/platform/geometry/layout_point.h" -#include "third_party/blink/renderer/platform/geometry/layout_rect.h" #include "third_party/blink/renderer/platform/geometry/length_functions.h" #include "third_party/blink/renderer/platform/graphics/box_reflection.h" #include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h" @@ -55,8 +52,8 @@ if (!mask_nine_piece.HasImage()) return BoxReflection(direction, offset, nullptr, FloatRect()); - LayoutRect mask_rect(LayoutPoint(), frame_layout_rect.Size()); - LayoutRect mask_bounding_rect(mask_rect); + PhysicalRect mask_rect(PhysicalOffset(), frame_layout_rect.Size()); + PhysicalRect mask_bounding_rect(mask_rect); mask_bounding_rect.Expand(style.ImageOutsets(mask_nine_piece)); PaintRecordBuilder builder;
diff --git a/third_party/blink/renderer/core/paint/clip_path_clipper.cc b/third_party/blink/renderer/core/paint/clip_path_clipper.cc index 0cfc8b16..9e1eed1 100644 --- a/third_party/blink/renderer/core/paint/clip_path_clipper.cc +++ b/third_party/blink/renderer/core/paint/clip_path_clipper.cc
@@ -135,7 +135,7 @@ ClipPathClipper::ClipPathClipper(GraphicsContext& context, const LayoutObject& layout_object, - const LayoutPoint& paint_offset) + const PhysicalOffset& paint_offset) : context_(context), layout_object_(layout_object), paint_offset_(paint_offset) { @@ -177,7 +177,7 @@ return; DrawingRecorder recorder(context_, layout_object_, DisplayItem::kSVGClip); context_.Save(); - context_.Translate(paint_offset_.X(), paint_offset_.Y()); + context_.Translate(paint_offset_.left, paint_offset_.top); SVGClipExpansionCycleHelper locks; bool is_first = true;
diff --git a/third_party/blink/renderer/core/paint/clip_path_clipper.h b/third_party/blink/renderer/core/paint/clip_path_clipper.h index 7674aaa..c852040e 100644 --- a/third_party/blink/renderer/core/paint/clip_path_clipper.h +++ b/third_party/blink/renderer/core/paint/clip_path_clipper.h
@@ -7,8 +7,8 @@ #include "base/optional.h" #include "third_party/blink/renderer/core/core_export.h" +#include "third_party/blink/renderer/core/layout/geometry/physical_offset.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h" -#include "third_party/blink/renderer/platform/geometry/layout_point.h" #include "third_party/blink/renderer/platform/graphics/path.h" namespace blink { @@ -22,7 +22,7 @@ public: ClipPathClipper(GraphicsContext&, const LayoutObject&, - const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); ~ClipPathClipper(); // Returns the reference box used by CSS clip-path. For HTML objects, @@ -52,7 +52,7 @@ private: GraphicsContext& context_; const LayoutObject& layout_object_; - LayoutPoint paint_offset_; + PhysicalOffset paint_offset_; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/clip_rect.cc b/third_party/blink/renderer/core/paint/clip_rect.cc index dacca1a8..b72162b 100644 --- a/third_party/blink/renderer/core/paint/clip_rect.cc +++ b/third_party/blink/renderer/core/paint/clip_rect.cc
@@ -27,6 +27,7 @@ #include "third_party/blink/renderer/core/paint/clip_rect.h" #include "third_party/blink/renderer/core/layout/hit_test_location.h" +#include "third_party/blink/renderer/platform/geometry/layout_rect.h" #include "third_party/blink/renderer/platform/graphics/paint/float_clip_rect.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" @@ -38,25 +39,25 @@ is_infinite_(true) {} ClipRect::ClipRect(const FloatClipRect& rect) - : rect_(rect.Rect()), + : rect_(PhysicalRect::EnclosingRect(rect.Rect())), has_radius_(rect.HasRadius()), is_infinite_(rect.IsInfinite()) {} void ClipRect::SetRect(const FloatClipRect& rect) { if (rect.IsInfinite() && IsInfinite()) return; - rect_ = LayoutRect(rect.Rect()); + rect_ = PhysicalRect::EnclosingRect(rect.Rect()); has_radius_ = rect.HasRadius(); is_infinite_ = rect.IsInfinite(); } -void ClipRect::SetRect(const LayoutRect& rect) { +void ClipRect::SetRect(const PhysicalRect& rect) { rect_ = rect; has_radius_ = false; is_infinite_ = false; } -void ClipRect::Intersect(const LayoutRect& other) { +void ClipRect::Intersect(const PhysicalRect& other) { if (IsInfinite()) { rect_ = other; is_infinite_ = false; @@ -76,7 +77,7 @@ bool ClipRect::Intersects(const HitTestLocation& hit_test_location) const { if (is_infinite_) return true; - return hit_test_location.Intersects(rect_); + return hit_test_location.Intersects(rect_.ToLayoutRect()); } void ClipRect::Reset() { @@ -84,7 +85,7 @@ return; has_radius_ = true; is_infinite_ = true; - rect_ = LayoutRect(LayoutRect::InfiniteIntRect()); + rect_ = PhysicalRect(LayoutRect::InfiniteIntRect()); } String ClipRect::ToString() const {
diff --git a/third_party/blink/renderer/core/paint/clip_rect.h b/third_party/blink/renderer/core/paint/clip_rect.h index 31d0520..8813c67 100644 --- a/third_party/blink/renderer/core/paint/clip_rect.h +++ b/third_party/blink/renderer/core/paint/clip_rect.h
@@ -27,7 +27,7 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_CLIP_RECT_H_ #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/platform/geometry/layout_rect.h" +#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" #include "third_party/blink/renderer/platform/wtf/allocator.h" namespace blink { @@ -40,12 +40,12 @@ public: ClipRect(); - ClipRect(const LayoutRect& rect) + ClipRect(const PhysicalRect& rect) : rect_(rect), has_radius_(false), is_infinite_(false) {} ClipRect(const FloatClipRect& rect); - void SetRect(const LayoutRect& rect); - const LayoutRect& Rect() const { return rect_; } + void SetRect(const PhysicalRect& rect); + const PhysicalRect& Rect() const { return rect_; } void SetRect(const FloatClipRect& rect); // HasRadius is true if the clip this ClipRect has rounded corners. @@ -67,16 +67,14 @@ bool operator!=(const ClipRect& other) const { return Rect() != other.Rect() || HasRadius() != other.HasRadius(); } - bool operator!=(const LayoutRect& other_rect) const { + bool operator!=(const PhysicalRect& other_rect) const { return Rect() != other_rect; } - void Intersect(const LayoutRect& other); + void Intersect(const PhysicalRect& other); void Intersect(const ClipRect& other); - void Move(const LayoutSize& size) { rect_.Move(size); } - void Move(const IntSize& size) { rect_.Move(size); } - void MoveBy(const LayoutPoint& point) { rect_.MoveBy(point); } + void Move(const PhysicalOffset& offset) { rect_.offset += offset; } bool IsEmpty() const { return rect_.IsEmpty(); } bool Intersects(const HitTestLocation&) const; @@ -86,7 +84,7 @@ String ToString() const; private: - LayoutRect rect_; + PhysicalRect rect_; bool has_radius_ : 1; bool is_infinite_ : 1; };
diff --git a/third_party/blink/renderer/core/paint/clip_rect_test.cc b/third_party/blink/renderer/core/paint/clip_rect_test.cc index 50111a4e..b515eb7 100644 --- a/third_party/blink/renderer/core/paint/clip_rect_test.cc +++ b/third_party/blink/renderer/core/paint/clip_rect_test.cc
@@ -3,11 +3,12 @@ // found in the LICENSE file. #include "third_party/blink/renderer/core/paint/clip_rect.h" -#include "third_party/blink/renderer/core/layout/hit_test_location.h" -#include "third_party/blink/renderer/platform/graphics/paint/float_clip_rect.h" -#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/renderer/core/layout/hit_test_location.h" +#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h" +#include "third_party/blink/renderer/platform/graphics/paint/float_clip_rect.h" +#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" namespace blink { @@ -20,7 +21,7 @@ rect.SetRect(FloatClipRect()); EXPECT_TRUE(rect.IsInfinite()); - rect.SetRect(LayoutRect()); + rect.SetRect(PhysicalRect()); EXPECT_FALSE(rect.IsInfinite()); } @@ -36,7 +37,7 @@ rect.SetRect(float_clip_rect); EXPECT_TRUE(rect.HasRadius()); - rect.SetRect(LayoutRect()); + rect.SetRect(PhysicalRect()); EXPECT_FALSE(rect.HasRadius()); rect.SetHasRadius(true); @@ -49,23 +50,21 @@ TEST_F(ClipRectTest, IntersectClipRect) { ClipRect rect; - rect.SetRect(LayoutRect(100, 200, 300, 400)); + rect.SetRect(PhysicalRect(100, 200, 300, 400)); EXPECT_FALSE(rect.HasRadius()); ClipRect rect2; - rect2.SetRect(LayoutRect(100, 100, 200, 300)); + rect2.SetRect(PhysicalRect(100, 100, 200, 300)); rect2.SetHasRadius(true); rect.Intersect(rect2); EXPECT_TRUE(rect.HasRadius()); EXPECT_FALSE(rect.IsInfinite()); - EXPECT_EQ(LayoutRect(100, 200, 200, 200), rect.Rect()); + EXPECT_EQ(PhysicalRect(100, 200, 200, 200), rect.Rect()); } -TEST_F(ClipRectTest, IntersectLayoutRect) { +TEST_F(ClipRectTest, IntersectEmptyRect) { ClipRect rect; - LayoutRect layout_rect; - - rect.Intersect(layout_rect); + rect.Intersect(PhysicalRect()); EXPECT_FALSE(rect.IsInfinite()); } @@ -77,7 +76,7 @@ TEST_F(ClipRectTest, ToString) { ClipRect rect; - rect.SetRect(LayoutRect(0, 0, 100, 100)); + rect.SetRect(PhysicalRect(0, 0, 100, 100)); EXPECT_EQ(String("0,0 100x100 noRadius notInfinite"), rect.ToString()); rect.SetHasRadius(true);
diff --git a/third_party/blink/renderer/core/paint/clip_rects.h b/third_party/blink/renderer/core/paint/clip_rects.h index 5dd4f2b..a4d3bc0 100644 --- a/third_party/blink/renderer/core/paint/clip_rects.h +++ b/third_party/blink/renderer/core/paint/clip_rects.h
@@ -44,7 +44,7 @@ ClipRects() : fixed_(0) {} - void Reset(const LayoutRect& r) { + void Reset(const PhysicalRect& r) { overflow_clip_rect_ = r; fixed_clip_rect_ = r; pos_clip_rect_ = r; @@ -80,7 +80,7 @@ } private: - ClipRects(const LayoutRect& r) + ClipRects(const PhysicalRect& r) : overflow_clip_rect_(r), fixed_clip_rect_(r), pos_clip_rect_(r),
diff --git a/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc b/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc index ed07989..30aadbd 100644 --- a/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc +++ b/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc
@@ -483,9 +483,7 @@ // this for solid color backgrounds the answer will be the same. scrolling_contents_layer_->SetContentsOpaque( owning_layer_.BackgroundIsKnownToBeOpaqueInRect( - ToLayoutBox(GetLayoutObject()) - .PhysicalPaddingBoxRect() - .ToLayoutRect(), + ToLayoutBox(GetLayoutObject()).PhysicalPaddingBoxRect(), should_check_children)); if (GetLayoutObject().GetBackgroundPaintLocation() & @@ -572,8 +570,9 @@ child_containment_layer_ ? FloatPoint(child_containment_layer_->GetPosition()) : FloatPoint(); - document_layer->SetPosition(FloatPoint(RoundedIntSize( - ContentsBox().Location() - LayoutPoint(parent_position)))); + document_layer->SetPosition(FloatPoint(RoundedIntPoint( + ContentsBox().offset - + PhysicalOffset::FromFloatPointRound(parent_position)))); } } } @@ -616,7 +615,7 @@ layer->GetLayoutObject().IsLayoutEmbeddedContent()) && layer->GetLayoutObject().StyleRef().HasBorderRadius() && InContainingBlockChain(&owning_layer_, layer)) { - LayoutPoint delta; + PhysicalOffset delta; layer->ConvertToLayerCoords(clip_inheritance_ancestor_, delta); // The PaintLayer's size is pixel-snapped if it is a LayoutBox. We can't @@ -627,7 +626,7 @@ : LayoutSize(layer->Size())); auto clip_rect = layer->GetLayoutObject().StyleRef().GetRoundedInnerBorderFor( - LayoutRect(delta, size)); + LayoutRect(delta.ToLayoutPoint(), size)); auto inner_clip_rect = clip_rect.RadiusCenterRect(); // The first condition catches cases where the child is certainly inside @@ -672,7 +671,7 @@ owning_layer_ .Clipper(PaintLayer::GeometryMapperOption::kDoNotUseGeometryMapper) .CalculateBackgroundClipRect(clip_rects_context, clip_rect); - if (clip_rect.Rect() == LayoutRect(LayoutRect::InfiniteIntRect())) + if (clip_rect.Rect() == PhysicalRect(LayoutRect::InfiniteIntRect())) return; owning_layer_is_clipped = true; @@ -813,7 +812,7 @@ // It has no parent or child GraphicsLayer. For that reason, we process it // here, after the hierarchy has been updated. bool has_mask = - CSSMaskPainter::MaskBoundingBox(GetLayoutObject(), LayoutPoint()) + CSSMaskPainter::MaskBoundingBox(GetLayoutObject(), PhysicalOffset()) .has_value(); bool has_clip_path = ClipPathClipper::LocalClipPathBoundingBox(GetLayoutObject()).has_value(); @@ -915,10 +914,10 @@ return layer_config_changed; } -static LayoutPoint ComputeOffsetFromCompositedAncestor( +static PhysicalOffset ComputeOffsetFromCompositedAncestor( const PaintLayer* layer, const PaintLayer* composited_ancestor, - const LayoutPoint& local_representative_point_for_fragmentation, + const PhysicalOffset& local_representative_point_for_fragmentation, const FloatPoint& offset_for_sticky_position) { // Add in the offset of the composited bounds from the coordinate space of // the PaintLayer, since visualOffsetFromAncestor() requires the pre-offset @@ -937,12 +936,12 @@ // the representative fragment for layer position purpose. // For layers that are not fragmented, the point doesn't affect behavior as // there is one and only one fragment. - LayoutPoint offset = layer->VisualOffsetFromAncestor( + PhysicalOffset offset = layer->VisualOffsetFromAncestor( composited_ancestor, local_representative_point_for_fragmentation); if (composited_ancestor) - offset.Move(composited_ancestor->SubpixelAccumulation()); - offset.MoveBy(-local_representative_point_for_fragmentation); - offset.MoveBy(-LayoutPoint(offset_for_sticky_position)); + offset += composited_ancestor->SubpixelAccumulation(); + offset -= local_representative_point_for_fragmentation; + offset -= PhysicalOffset::FromFloatPointRound(offset_for_sticky_position); return offset; } @@ -950,15 +949,13 @@ const PaintLayer* composited_ancestor, IntRect& local_bounds, IntRect& compositing_bounds_relative_to_composited_ancestor, - LayoutPoint& offset_from_composited_ancestor, + PhysicalOffset& offset_from_composited_ancestor, IntPoint& snapped_offset_from_composited_ancestor) { // HACK(chrishtr): adjust for position of inlines. - LayoutPoint local_representative_point_for_fragmentation; + PhysicalOffset local_representative_point_for_fragmentation; if (owning_layer_.GetLayoutObject().IsLayoutInline()) { local_representative_point_for_fragmentation = - ToLayoutInline(owning_layer_.GetLayoutObject()) - .FirstLineBoxTopLeft() - .ToLayoutPoint(); + ToLayoutInline(owning_layer_.GetLayoutObject()).FirstLineBoxTopLeft(); } // Blink will already have applied any necessary offset for sticky positioned // elements. If the compositor is handling sticky offsets for this layer, we @@ -969,14 +966,14 @@ &owning_layer_, composited_ancestor, local_representative_point_for_fragmentation, offset_for_sticky_position); snapped_offset_from_composited_ancestor = - IntPoint(offset_from_composited_ancestor.X().Round(), - offset_from_composited_ancestor.Y().Round()); + RoundedIntPoint(offset_from_composited_ancestor); - LayoutSize subpixel_accumulation; + PhysicalOffset subpixel_accumulation; if (!owning_layer_.Transform() || owning_layer_.Transform()->IsIdentityOrTranslation()) { - subpixel_accumulation = offset_from_composited_ancestor - - snapped_offset_from_composited_ancestor; + subpixel_accumulation = + offset_from_composited_ancestor - + PhysicalOffset(snapped_offset_from_composited_ancestor); } // Invalidate the whole layer when subpixel accumulation changes, since @@ -997,8 +994,8 @@ // transformed by a non-translation transform. owning_layer_.SetSubpixelAccumulation(subpixel_accumulation); - base::Optional<IntRect> mask_bounding_box = CSSMaskPainter::MaskBoundingBox( - GetLayoutObject(), LayoutPoint(subpixel_accumulation)); + base::Optional<IntRect> mask_bounding_box = + CSSMaskPainter::MaskBoundingBox(GetLayoutObject(), subpixel_accumulation); base::Optional<FloatRect> clip_path_bounding_box = ClipPathClipper::LocalClipPathBoundingBox(GetLayoutObject()); if (clip_path_bounding_box) @@ -1016,7 +1013,7 @@ } else { // Move the bounds by the subpixel accumulation so that it pixel-snaps // relative to absolute pixels instead of local coordinates. - LayoutRect local_raw_compositing_bounds = CompositedBounds(); + PhysicalRect local_raw_compositing_bounds = CompositedBounds(); local_raw_compositing_bounds.Move(subpixel_accumulation); local_bounds = PixelSnappedIntRect(local_raw_compositing_bounds); } @@ -1035,8 +1032,8 @@ if (!squashing_layer_) return; - LayoutPoint compositing_container_offset_from_parent_graphics_layer = - -graphics_layer_parent_location; + PhysicalOffset compositing_container_offset_from_parent_graphics_layer( + -graphics_layer_parent_location); if (compositing_container) { compositing_container_offset_from_parent_graphics_layer += compositing_container->SubpixelAccumulation(); @@ -1053,16 +1050,16 @@ } // FIXME: Cache these offsets. - LayoutPoint compositing_container_offset_from_transformed_ancestor; + PhysicalOffset compositing_container_offset_from_transformed_ancestor; if (compositing_container) { compositing_container_offset_from_transformed_ancestor = compositing_container->ComputeOffsetFromAncestor( *common_transform_ancestor); } - LayoutRect total_squash_bounds; + PhysicalRect total_squash_bounds; for (wtf_size_t i = 0; i < layers.size(); ++i) { - LayoutRect squashed_bounds = + PhysicalRect squashed_bounds = layers[i].paint_layer->BoundingBoxForCompositing(); // Store the local bounds of the Layer subtree before applying the offset. @@ -1071,10 +1068,10 @@ DCHECK(&layers[i].paint_layer->TransformAncestorOrRoot() == common_transform_ancestor); - LayoutPoint squashed_layer_offset_from_transformed_ancestor = + PhysicalOffset squashed_layer_offset_from_transformed_ancestor = layers[i].paint_layer->ComputeOffsetFromAncestor( *common_transform_ancestor); - LayoutSize squashed_layer_offset_from_compositing_container = + PhysicalOffset squashed_layer_offset_from_compositing_container = squashed_layer_offset_from_transformed_ancestor - compositing_container_offset_from_transformed_ancestor; @@ -1087,12 +1084,12 @@ // graphicsLayerParent. The conversion between compositingContainer and the // graphicsLayerParent is already computed as // compositingContainerOffsetFromParentGraphicsLayer. - total_squash_bounds.MoveBy( + total_squash_bounds.Move( compositing_container_offset_from_parent_graphics_layer); const IntRect squash_layer_bounds = EnclosingIntRect(total_squash_bounds); const IntPoint squash_layer_origin = squash_layer_bounds.Location(); - const LayoutSize squash_layer_origin_in_compositing_container_space = - squash_layer_origin - + const PhysicalOffset squash_layer_origin_in_compositing_container_space = + PhysicalOffset(squash_layer_origin) - compositing_container_offset_from_parent_graphics_layer; // Now that the squashing bounds are known, we can convert the PaintLayer @@ -1107,19 +1104,19 @@ // offset overall needs to be negated because that's the direction that the // painting code expects the offset to be. for (wtf_size_t i = 0; i < layers.size(); ++i) { - const LayoutPoint squashed_layer_offset_from_transformed_ancestor = + const PhysicalOffset squashed_layer_offset_from_transformed_ancestor = layers[i].paint_layer->ComputeOffsetFromAncestor( *common_transform_ancestor); - const LayoutSize offset_from_squash_layer_origin = + const PhysicalOffset offset_from_squash_layer_origin = (squashed_layer_offset_from_transformed_ancestor - compositing_container_offset_from_transformed_ancestor) - squash_layer_origin_in_compositing_container_space; IntSize new_offset_from_layout_object = - -IntSize(offset_from_squash_layer_origin.Width().Round(), - offset_from_squash_layer_origin.Height().Round()); - LayoutSize subpixel_accumulation = - offset_from_squash_layer_origin + new_offset_from_layout_object; + -ToIntSize(RoundedIntPoint(offset_from_squash_layer_origin)); + PhysicalOffset subpixel_accumulation = + offset_from_squash_layer_origin + + PhysicalOffset(new_offset_from_layout_object); if (layers[i].offset_from_layout_object_set && layers[i].offset_from_layout_object != new_offset_from_layout_object) { ObjectPaintInvalidator(layers[i].paint_layer->GetLayoutObject()) @@ -1186,7 +1183,7 @@ IntRect local_compositing_bounds; IntRect relative_compositing_bounds; - LayoutPoint offset_from_composited_ancestor; + PhysicalOffset offset_from_composited_ancestor; IntPoint snapped_offset_from_composited_ancestor; ComputeBoundsOfOwningLayer(compositing_container, local_compositing_bounds, relative_compositing_bounds, @@ -1404,16 +1401,16 @@ // now. Scroll offset is excluded so that we do not need to invalidate // the clip rect cache on scroll. if (clip_inheritance_ancestor_->GetScrollableArea()) { - clip_rect.Move(LayoutSize( + clip_rect.Move(PhysicalOffset::FromFloatSizeRound( -clip_inheritance_ancestor_->GetScrollableArea()->GetScrollOffset())); } - DCHECK(clip_rect.Rect() != LayoutRect(LayoutRect::InfiniteIntRect())); + DCHECK(clip_rect.Rect() != PhysicalRect(LayoutRect::InfiniteIntRect())); // The accumulated clip rect is in the space of clip_inheritance_ancestor_. // It needs to be converted to the space of our compositing container because // our layer position is based on that. - LayoutRect clip_rect_in_compositing_container_space = clip_rect.Rect(); + PhysicalRect clip_rect_in_compositing_container_space = clip_rect.Rect(); // The following two branches are doing exact the same conversion, but // ConvertToLayerCoords can only handle descendant-to-ancestor conversion. // Inversion needs to be done manually if clip_inheritance_container is not @@ -1435,15 +1432,15 @@ // the clip parent must be some ancestor of our compositing container. DCHECK(compositing_container->GetLayoutObject().IsDescendantOf( &clip_inheritance_ancestor_->GetLayoutObject())); - LayoutPoint compositing_container_origin_in_clip_ancestor_space; + PhysicalOffset compositing_container_origin_in_clip_ancestor_space; compositing_container->ConvertToLayerCoords( clip_inheritance_ancestor_, compositing_container_origin_in_clip_ancestor_space); - clip_rect_in_compositing_container_space.MoveBy( - -compositing_container_origin_in_clip_ancestor_space); + clip_rect_in_compositing_container_space.offset -= + compositing_container_origin_in_clip_ancestor_space; } - clip_rect_in_compositing_container_space.Move( - compositing_container->SubpixelAccumulation()); + clip_rect_in_compositing_container_space.offset += + compositing_container->SubpixelAccumulation(); IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect_in_compositing_container_space); @@ -1518,7 +1515,7 @@ // graphicsLayerParentLocation is the location of // m_ancestorClippingLayer relative to compositingContainer (including // any offset from compositingContainer's m_childContainmentLayer). - LayoutPoint offset = LayoutPoint(graphics_layer_parent_location); + PhysicalOffset offset(graphics_layer_parent_location); compositing_container->ConvertToLayerCoords( compositing_stacking_context, offset); position = @@ -1587,8 +1584,7 @@ } else { IntRect clipping_box = PixelSnappedIntRect( ToLayoutBox(GetLayoutObject()) - .ClippingRect(PhysicalOffsetToBeNoop(SubpixelAccumulation())) - .ToLayoutRect()); + .ClippingRect(owning_layer_.SubpixelAccumulation())); child_containment_layer_->SetSize(gfx::Size(clipping_box.Size())); child_containment_layer_->SetOffsetFromLayoutObject( ToIntSize(clipping_box.Location())); @@ -1614,12 +1610,12 @@ if (!child_transform_layer_) return; - LayoutRect border_box = - ToLayoutBox(owning_layer_.GetLayoutObject()).BorderBoxRect(); + PhysicalRect border_box = + ToLayoutBox(owning_layer_.GetLayoutObject()).PhysicalBorderBoxRect(); border_box.Move(ContentOffsetInCompositingLayer()); child_transform_layer_->SetSize(gfx::Size(border_box.PixelSnappedSize())); child_transform_layer_->SetOffsetFromLayoutObject(IntSize()); - child_transform_layer_->SetPosition(FloatPoint(border_box.Location())); + child_transform_layer_->SetPosition(FloatPoint(border_box.offset)); } void CompositedLayerMapping::UpdateMaskLayerGeometry() { @@ -1645,7 +1641,7 @@ // Get layout bounds in the coords of compositingContainer to match // relativeCompositingBounds. IntRect layer_bounds = PixelSnappedIntRect( - ToLayoutPoint(owning_layer_.SubpixelAccumulation()), border_box.Size()); + PhysicalRect(owning_layer_.SubpixelAccumulation(), border_box.Size())); layer_bounds.MoveBy(snapped_offset_from_composited_ancestor); // Update properties that depend on layer dimensions @@ -1673,8 +1669,8 @@ DCHECK(scrolling_contents_layer_); LayoutBox& layout_box = ToLayoutBox(GetLayoutObject()); - IntRect overflow_clip_rect = PixelSnappedIntRect(layout_box.OverflowClipRect( - LayoutPoint(owning_layer_.SubpixelAccumulation()))); + IntRect overflow_clip_rect = PixelSnappedIntRect( + layout_box.OverflowClipRect(owning_layer_.SubpixelAccumulation())); // When a m_childTransformLayer exists, local content offsets for the // m_scrollingLayer have already been applied. Otherwise, we apply them here. @@ -1708,7 +1704,7 @@ PaintLayerScrollableArea* scrollable_area = owning_layer_.GetScrollableArea(); IntSize scroll_size = scrollable_area->PixelSnappedContentsSize( - LayoutPoint(owning_layer_.SubpixelAccumulation())); + owning_layer_.SubpixelAccumulation()); // Ensure scrolling contents are at least as large as the scroll clip scroll_size = scroll_size.ExpandedTo(overflow_clip_rect.Size()); @@ -2944,13 +2940,13 @@ // Return the offset from the top-left of this compositing layer at which the // LayoutObject's contents are painted. -LayoutSize CompositedLayerMapping::ContentOffsetInCompositingLayer() const { +PhysicalOffset CompositedLayerMapping::ContentOffsetInCompositingLayer() const { return owning_layer_.SubpixelAccumulation() - - LayoutSize(graphics_layer_->OffsetFromLayoutObject()); + PhysicalOffset(graphics_layer_->OffsetFromLayoutObject()); } -LayoutRect CompositedLayerMapping::ContentsBox() const { - LayoutRect contents_box = ContentsRect(GetLayoutObject()).ToLayoutRect(); +PhysicalRect CompositedLayerMapping::ContentsBox() const { + PhysicalRect contents_box = ContentsRect(GetLayoutObject()); contents_box.Move(ContentOffsetInCompositingLayer()); return contents_box; } @@ -3097,8 +3093,8 @@ paint_info.paint_layer->ClippingContainer(); if (clipping_container == reference_layer.ClippingContainer()) { paint_info.local_clip_rect_for_squashed_layer = - ClipRect(LayoutRect(LayoutRect::InfiniteIntRect())); - paint_info.offset_from_clip_rect_root = LayoutPoint(); + ClipRect(PhysicalRect(LayoutRect::InfiniteIntRect())); + paint_info.offset_from_clip_rect_root = PhysicalOffset(); paint_info.local_clip_rect_root = paint_info.paint_layer; return; } @@ -3127,10 +3123,10 @@ IntSize ancestor_to_local_offset = paint_info.offset_from_layout_object - ancestor_paint_info->offset_from_layout_object; - parent_clip_rect.Move(ancestor_to_local_offset); + parent_clip_rect.Move(PhysicalOffset(ancestor_to_local_offset)); paint_info.local_clip_rect_for_squashed_layer = parent_clip_rect; - paint_info.offset_from_clip_rect_root = LayoutPoint( - ancestor_to_local_offset.Width(), ancestor_to_local_offset.Height()); + paint_info.offset_from_clip_rect_root = + PhysicalOffset(ancestor_to_local_offset); paint_info.local_clip_rect_root = ancestor_paint_info->paint_layer; } @@ -3149,10 +3145,10 @@ if (paint_layer_flags & (kPaintLayerPaintingOverflowContents | kPaintLayerPaintingAncestorClippingMaskPhase)) { - dirty_rect.Move( - RoundedIntSize(paint_info.paint_layer->SubpixelAccumulation())); + dirty_rect.MoveBy( + RoundedIntPoint(paint_info.paint_layer->SubpixelAccumulation())); } else { - LayoutRect bounds = paint_info.composited_bounds; + PhysicalRect bounds = paint_info.composited_bounds; bounds.Move(paint_info.paint_layer->SubpixelAccumulation()); dirty_rect.Intersect(PixelSnappedIntRect(bounds)); } @@ -3345,7 +3341,7 @@ } LayoutSize CompositedLayerMapping::SubpixelAccumulation() const { - return owning_layer_.SubpixelAccumulation(); + return owning_layer_.SubpixelAccumulation().ToLayoutSize(); } bool CompositedLayerMapping::NeedsRepaint(
diff --git a/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h b/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h index cd139ff..6247d22 100644 --- a/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h +++ b/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h
@@ -48,13 +48,13 @@ DISALLOW_NEW(); PaintLayer* paint_layer; - LayoutRect composited_bounds; + PhysicalRect composited_bounds; // The clip rect to apply, in the local coordinate space of the squashed // layer, when painting it. ClipRect local_clip_rect_for_squashed_layer; PaintLayer* local_clip_rect_root; - LayoutPoint offset_from_clip_rect_root; + PhysicalOffset offset_from_clip_rect_root; // Offset describing where this squashed Layer paints into the shared // GraphicsLayer backing. @@ -181,7 +181,7 @@ // Notification from the layoutObject that its content changed. void ContentChanged(ContentChangeType); - LayoutRect CompositedBounds() const { return composited_bounds_; } + PhysicalRect CompositedBounds() const { return composited_bounds_; } void PositionOverflowControlsLayers(); @@ -221,7 +221,7 @@ void VerifyNotPainting() override; #endif - LayoutRect ContentsBox() const; + PhysicalRect ContentsBox() const; GraphicsLayer* LayerForHorizontalScrollbar() const { return layer_for_horizontal_scrollbar_.get(); @@ -279,7 +279,7 @@ const ScrollableArea* GetScrollableAreaForTesting( const GraphicsLayer*) const override; - LayoutSize ContentOffsetInCompositingLayer() const; + PhysicalOffset ContentOffsetInCompositingLayer() const; // If there is a squashed layer painting into this CLM that is an ancestor of // the given LayoutObject, return it. Otherwise return nullptr. @@ -430,7 +430,7 @@ const PaintLayer* composited_ancestor, IntRect& local_compositing_bounds, IntRect& compositing_bounds_relative_to_composited_ancestor, - LayoutPoint& offset_from_composited_ancestor, + PhysicalOffset& offset_from_composited_ancestor, IntPoint& snapped_offset_from_composited_ancestor); GraphicsLayerPaintingPhase PaintingPhaseForPrimaryLayer() const; @@ -663,7 +663,7 @@ Vector<GraphicsLayerPaintInfo> squashed_layers_; IntSize squashing_layer_offset_from_layout_object_; - LayoutRect composited_bounds_; + PhysicalRect composited_bounds_; // We keep track of the scrolling contents offset, so that when it changes we // can notify the ScrollingCoordinator, which passes on main-thread scrolling
diff --git a/third_party/blink/renderer/core/paint/compositing/compositing_layer_property_updater.cc b/third_party/blink/renderer/core/paint/compositing/compositing_layer_property_updater.cc index 99c22da..a9618a7 100644 --- a/third_party/blink/renderer/core/paint/compositing/compositing_layer_property_updater.cc +++ b/third_party/blink/renderer/core/paint/compositing/compositing_layer_property_updater.cc
@@ -42,8 +42,8 @@ // during printing. object.GetDocument().Printing()); - LayoutPoint layout_snapped_paint_offset = - fragment_data.PaintOffset() - mapping->SubpixelAccumulation(); + PhysicalOffset layout_snapped_paint_offset = + fragment_data.PaintOffset() - paint_layer->SubpixelAccumulation(); IntPoint snapped_paint_offset = RoundedIntPoint(layout_snapped_paint_offset); #if DCHECK_IS_ON() @@ -54,7 +54,7 @@ // resulted in the paint offset used by CompositedLayerMapping to mismatch. bool subpixel_accumulation_may_be_bogus = paint_layer->SubtreeIsInvisible(); if (!subpixel_accumulation_may_be_bogus && - layout_snapped_paint_offset != snapped_paint_offset) { + layout_snapped_paint_offset != PhysicalOffset(snapped_paint_offset)) { // TODO(crbug.com/925377): Fix the root cause. DLOG(ERROR) << "Paint offset pixel snapping error for " << object << " expected: " << snapped_paint_offset
diff --git a/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.cc b/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.cc index 4833043..8412d3f 100644 --- a/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.cc +++ b/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.cc
@@ -183,7 +183,7 @@ compositing_reasons_stats.assumed_overlap_layers, 1, 1000, 5); UMA_HISTOGRAM_CUSTOM_COUNTS( "Blink.Compositing.LayerPromotionCount.IndirectComposited", - compositing_reasons_stats.indirect_composited_layers, 1, 1000, 5); + compositing_reasons_stats.indirect_composited_layers, 1, 10000, 10); UMA_HISTOGRAM_CUSTOM_COUNTS( "Blink.Compositing.LayerPromotionCount.TotalComposited", compositing_reasons_stats.total_composited_layers, 1, 1000, 10);
diff --git a/third_party/blink/renderer/core/paint/css_mask_painter.cc b/third_party/blink/renderer/core/paint/css_mask_painter.cc index 4e8f0cff..25432d2 100644 --- a/third_party/blink/renderer/core/paint/css_mask_painter.cc +++ b/third_party/blink/renderer/core/paint/css_mask_painter.cc
@@ -14,7 +14,7 @@ base::Optional<IntRect> CSSMaskPainter::MaskBoundingBox( const LayoutObject& object, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { if (!object.IsBoxModelObject() && !object.IsSVGChild()) return base::nullopt; @@ -35,24 +35,23 @@ if (!style.HasMask()) return base::nullopt; - LayoutRect maximum_mask_region; + PhysicalRect maximum_mask_region; // For HTML/CSS objects, the extent of the mask is known as "mask // painting area", which is determined by CSS mask-clip property. // We don't implement mask-clip:margin-box or no-clip currently, // so the maximum we can get is border-box. if (object.IsBox()) { - maximum_mask_region = ToLayoutBox(object).BorderBoxRect(); + maximum_mask_region = ToLayoutBox(object).PhysicalBorderBoxRect(); } else { // For inline elements, depends on the value of box-decoration-break // there could be one box in multiple fragments or multiple boxes. // Either way here we are only interested in the bounding box of them. DCHECK(object.IsLayoutInline()); - maximum_mask_region = - ToLayoutInline(object).PhysicalLinesBoundingBox().ToLayoutRect(); + maximum_mask_region = ToLayoutInline(object).PhysicalLinesBoundingBox(); } if (style.HasMaskBoxImageOutsets()) maximum_mask_region.Expand(style.MaskBoxImageOutsets()); - maximum_mask_region.MoveBy(paint_offset); + maximum_mask_region.offset += paint_offset; return PixelSnappedIntRect(maximum_mask_region); }
diff --git a/third_party/blink/renderer/core/paint/css_mask_painter.h b/third_party/blink/renderer/core/paint/css_mask_painter.h index 118b0f4..469bc4d 100644 --- a/third_party/blink/renderer/core/paint/css_mask_painter.h +++ b/third_party/blink/renderer/core/paint/css_mask_painter.h
@@ -14,7 +14,7 @@ namespace blink { class LayoutObject; -class LayoutPoint; +struct PhysicalOffset; class CORE_EXPORT CSSMaskPainter { STATIC_ONLY(CSSMaskPainter); @@ -25,7 +25,7 @@ // there is no mask or the mask is invalid. static base::Optional<IntRect> MaskBoundingBox( const LayoutObject&, - const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); // Returns the color filter used to interpret mask pixel values as opaqueness. // The return value is undefined if there is no mask or the mask is invalid.
diff --git a/third_party/blink/renderer/core/paint/css_mask_painter_test.cc b/third_party/blink/renderer/core/paint/css_mask_painter_test.cc index 7f5d6a3..5625d19 100644 --- a/third_party/blink/renderer/core/paint/css_mask_painter_test.cc +++ b/third_party/blink/renderer/core/paint/css_mask_painter_test.cc
@@ -26,7 +26,7 @@ )HTML"); auto& masked = *GetLayoutObjectByElementId("masked"); base::Optional<IntRect> mask_bounding_box = - CSSMaskPainter::MaskBoundingBox(masked, LayoutPoint()); + CSSMaskPainter::MaskBoundingBox(masked, PhysicalOffset()); ASSERT_TRUE(mask_bounding_box.has_value()); EXPECT_EQ(IntRect(75, 75, 100, 100), *mask_bounding_box); } @@ -38,7 +38,7 @@ )HTML"); auto& masked = *GetLayoutObjectByElementId("masked"); base::Optional<IntRect> mask_bounding_box = - CSSMaskPainter::MaskBoundingBox(masked, LayoutPoint(8, 8)); + CSSMaskPainter::MaskBoundingBox(masked, PhysicalOffset(8, 8)); ASSERT_TRUE(mask_bounding_box.has_value()); EXPECT_EQ(IntRect(8, 8, 300, 200), *mask_bounding_box); } @@ -51,7 +51,7 @@ )HTML"); auto& masked = *GetLayoutObjectByElementId("masked"); base::Optional<IntRect> mask_bounding_box = - CSSMaskPainter::MaskBoundingBox(masked, LayoutPoint(8, 8)); + CSSMaskPainter::MaskBoundingBox(masked, PhysicalOffset(8, 8)); ASSERT_TRUE(mask_bounding_box.has_value()); EXPECT_EQ(IntRect(-2, -2, 320, 220), *mask_bounding_box); } @@ -69,7 +69,7 @@ )HTML"); auto& masked = *GetLayoutObjectByElementId("masked"); base::Optional<IntRect> mask_bounding_box = - CSSMaskPainter::MaskBoundingBox(masked, LayoutPoint(8, 8)); + CSSMaskPainter::MaskBoundingBox(masked, PhysicalOffset(8, 8)); ASSERT_TRUE(mask_bounding_box.has_value()); EXPECT_EQ(IntRect(8, 8, 260, 20), *mask_bounding_box); }
diff --git a/third_party/blink/renderer/core/paint/details_marker_painter.cc b/third_party/blink/renderer/core/paint/details_marker_painter.cc index 0e61fda..a802d05 100644 --- a/third_party/blink/renderer/core/paint/details_marker_painter.cc +++ b/third_party/blink/renderer/core/paint/details_marker_painter.cc
@@ -37,7 +37,7 @@ local_paint_info.context.SetFillColor(color); auto box_origin = paint_state.PaintOffset(); - box_origin.Move( + box_origin += PhysicalOffset( layout_details_marker_.BorderLeft() + layout_details_marker_.PaddingLeft(), layout_details_marker_.BorderTop() + layout_details_marker_.PaddingTop()); @@ -91,12 +91,12 @@ return Path(); } -Path DetailsMarkerPainter::GetPath(const LayoutPoint& origin) const { +Path DetailsMarkerPainter::GetPath(const PhysicalOffset& origin) const { Path result = GetCanonicalPath(); result.Transform(AffineTransform().Scale( layout_details_marker_.ContentWidth().ToFloat(), layout_details_marker_.ContentHeight().ToFloat())); - result.Translate(FloatSize(origin.X().ToFloat(), origin.Y().ToFloat())); + result.Translate(FloatSize(origin)); return result; }
diff --git a/third_party/blink/renderer/core/paint/details_marker_painter.h b/third_party/blink/renderer/core/paint/details_marker_painter.h index a681ac3..c60447c 100644 --- a/third_party/blink/renderer/core/paint/details_marker_painter.h +++ b/third_party/blink/renderer/core/paint/details_marker_painter.h
@@ -9,10 +9,10 @@ namespace blink { -struct PaintInfo; class Path; -class LayoutPoint; class LayoutDetailsMarker; +struct PaintInfo; +struct PhysicalOffset; class DetailsMarkerPainter { STACK_ALLOCATED(); @@ -25,7 +25,7 @@ private: Path GetCanonicalPath() const; - Path GetPath(const LayoutPoint& origin) const; + Path GetPath(const PhysicalOffset& origin) const; const LayoutDetailsMarker& layout_details_marker_; };
diff --git a/third_party/blink/renderer/core/paint/document_marker_painter.cc b/third_party/blink/renderer/core/paint/document_marker_painter.cc index c4037c7..a0b9fdd 100644 --- a/third_party/blink/renderer/core/paint/document_marker_painter.cc +++ b/third_party/blink/renderer/core/paint/document_marker_painter.cc
@@ -6,6 +6,7 @@ #include "build/build_config.h" #include "third_party/blink/renderer/core/editing/markers/document_marker_controller.h" +#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" #include "third_party/blink/renderer/core/layout/layout_theme.h" #include "third_party/blink/renderer/core/paint/text_paint_style.h" #include "third_party/blink/renderer/core/style/computed_style.h" @@ -143,7 +144,7 @@ void DocumentMarkerPainter::PaintStyleableMarkerUnderline( GraphicsContext& context, - const LayoutPoint& box_origin, + const PhysicalOffset& box_origin, const StyleableMarker& marker, const ComputedStyle& style, const FloatRect& marker_rect, @@ -188,17 +189,17 @@ context.SetStrokeThickness(line_thickness); context.DrawLineForText( FloatPoint( - box_origin.X() + start, - (box_origin.Y() + logical_height.ToInt() - line_thickness).ToFloat()), + box_origin.left + start, + (box_origin.top + logical_height.ToInt() - line_thickness).ToFloat()), width); } void DocumentMarkerPainter::PaintDocumentMarker( GraphicsContext& context, - const LayoutPoint& box_origin, + const PhysicalOffset& box_origin, const ComputedStyle& style, DocumentMarker::MarkerType marker_type, - const LayoutRect& local_rect) { + const PhysicalRect& local_rect) { // IMPORTANT: The misspelling underline is not considered when calculating the // text bounds, so we have to make sure to fit within those bounds. This // means the top pixel(s) of the underline will overlap the bottom pixel(s) of @@ -226,8 +227,8 @@ underline_offset = baseline + 2 * zoom; } DrawDocumentMarker(context, - FloatPoint((box_origin.X() + local_rect.X()).ToFloat(), - (box_origin.Y() + underline_offset).ToFloat()), + FloatPoint((box_origin.left + local_rect.X()).ToFloat(), + (box_origin.top + underline_offset).ToFloat()), local_rect.Width().ToFloat(), marker_type, zoom); }
diff --git a/third_party/blink/renderer/core/paint/document_marker_painter.h b/third_party/blink/renderer/core/paint/document_marker_painter.h index 928baad..4880a10 100644 --- a/third_party/blink/renderer/core/paint/document_marker_painter.h +++ b/third_party/blink/renderer/core/paint/document_marker_painter.h
@@ -13,12 +13,12 @@ class ComputedStyle; class FloatRect; class GraphicsContext; -class LayoutPoint; -class LayoutRect; class LayoutUnit; class StyleableMarker; class TextMatchMarker; struct TextPaintStyle; +struct PhysicalOffset; +struct PhysicalRect; // Document marker painter for both LayoutNG and legacy layout. // This paints text decorations for spell/grammer check, find-in-page, and @@ -28,16 +28,16 @@ public: static void PaintStyleableMarkerUnderline(GraphicsContext& context, - const LayoutPoint& box_origin, + const PhysicalOffset& box_origin, const StyleableMarker& marker, const ComputedStyle& style, const FloatRect& marker_rect, LayoutUnit logical_height); static void PaintDocumentMarker(GraphicsContext& context, - const LayoutPoint& box_origin, + const PhysicalOffset& box_origin, const ComputedStyle& style, DocumentMarker::MarkerType marker_type, - const LayoutRect& local_rect); + const PhysicalRect& local_rect); static TextPaintStyle ComputeTextPaintStyleFrom( const ComputedStyle& style, const TextMatchMarker& marker);
diff --git a/third_party/blink/renderer/core/paint/ellipsis_box_painter.cc b/third_party/blink/renderer/core/paint/ellipsis_box_painter.cc index 831f915..a8e2bf07 100644 --- a/third_party/blink/renderer/core/paint/ellipsis_box_painter.cc +++ b/third_party/blink/renderer/core/paint/ellipsis_box_painter.cc
@@ -49,8 +49,10 @@ ellipsis_box_.VirtualLogicalHeight())); GraphicsContextStateSaver state_saver(context); - if (!ellipsis_box_.IsHorizontal()) - context.ConcatCTM(TextPainter::Rotation(box_rect, TextPainter::kClockwise)); + if (!ellipsis_box_.IsHorizontal()) { + context.ConcatCTM(TextPainter::Rotation(PhysicalRectToBeNoop(box_rect), + TextPainter::kClockwise)); + } const Font& font = style.GetFont(); const SimpleFontData* font_data = font.PrimaryFont();
diff --git a/third_party/blink/renderer/core/paint/embedded_content_painter.cc b/third_party/blink/renderer/core/paint/embedded_content_painter.cc index 03bd0c3d..3154af6 100644 --- a/third_party/blink/renderer/core/paint/embedded_content_painter.cc +++ b/third_party/blink/renderer/core/paint/embedded_content_painter.cc
@@ -20,15 +20,14 @@ namespace blink { void EmbeddedContentPainter::PaintReplaced(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { EmbeddedContentView* embedded_content_view = layout_embedded_content_.GetEmbeddedContentView(); if (!embedded_content_view) return; IntPoint paint_location(RoundedIntPoint( - paint_offset + - layout_embedded_content_.ReplacedContentRect().offset.ToLayoutPoint())); + paint_offset + layout_embedded_content_.ReplacedContentRect().offset)); IntSize view_paint_offset = paint_location - embedded_content_view->FrameRect().Location();
diff --git a/third_party/blink/renderer/core/paint/embedded_content_painter.h b/third_party/blink/renderer/core/paint/embedded_content_painter.h index b72a09d..643802e 100644 --- a/third_party/blink/renderer/core/paint/embedded_content_painter.h +++ b/third_party/blink/renderer/core/paint/embedded_content_painter.h
@@ -9,9 +9,9 @@ namespace blink { -struct PaintInfo; -class LayoutPoint; class LayoutEmbeddedContent; +struct PaintInfo; +struct PhysicalOffset; class EmbeddedContentPainter { STACK_ALLOCATED(); @@ -20,7 +20,7 @@ EmbeddedContentPainter(const LayoutEmbeddedContent& layout_embedded_content) : layout_embedded_content_(layout_embedded_content) {} - void PaintReplaced(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintReplaced(const PaintInfo&, const PhysicalOffset& paint_offset); private: const LayoutEmbeddedContent& layout_embedded_content_;
diff --git a/third_party/blink/renderer/core/paint/embedded_object_painter.cc b/third_party/blink/renderer/core/paint/embedded_object_painter.cc index 410776b..4366383 100644 --- a/third_party/blink/renderer/core/paint/embedded_object_painter.cc +++ b/third_party/blink/renderer/core/paint/embedded_object_painter.cc
@@ -36,7 +36,7 @@ } void EmbeddedObjectPainter::PaintReplaced(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { if (!layout_embedded_object_.ShowsUnavailablePluginIndicator()) { EmbeddedContentPainter(layout_embedded_object_) .PaintReplaced(paint_info, paint_offset); @@ -51,9 +51,8 @@ context, layout_embedded_object_, paint_info.phase)) return; - LayoutRect content_rect( - layout_embedded_object_.PhysicalContentBoxRect().ToLayoutRect()); - content_rect.MoveBy(paint_offset); + PhysicalRect content_rect = layout_embedded_object_.PhysicalContentBoxRect(); + content_rect.Move(paint_offset); DrawingRecorder recorder(context, layout_embedded_object_, paint_info.phase); Font font = ReplacementTextFont(); @@ -66,13 +65,13 @@ FloatSize text_geometry(font.Width(text_run), font_data->GetFontMetrics().Height()); - LayoutRect background_rect( - 0, 0, - text_geometry.Width() + - 2 * kReplacementTextRoundedRectLeftRightTextMargin, - kReplacementTextRoundedRectHeight); - background_rect.Move(content_rect.Center() - background_rect.Center()); - background_rect = LayoutRect(PixelSnappedIntRect(background_rect)); + PhysicalRect background_rect( + LayoutUnit(), LayoutUnit(), + LayoutUnit(text_geometry.Width() + + 2 * kReplacementTextRoundedRectLeftRightTextMargin), + LayoutUnit(kReplacementTextRoundedRectHeight)); + background_rect.offset += content_rect.Center() - background_rect.Center(); + background_rect = PhysicalRect(PixelSnappedIntRect(background_rect)); Path rounded_background_rect; FloatRect float_background_rect(background_rect); rounded_background_rect.AddRoundedRect(
diff --git a/third_party/blink/renderer/core/paint/embedded_object_painter.h b/third_party/blink/renderer/core/paint/embedded_object_painter.h index ff45f68..3a78245 100644 --- a/third_party/blink/renderer/core/paint/embedded_object_painter.h +++ b/third_party/blink/renderer/core/paint/embedded_object_painter.h
@@ -9,9 +9,9 @@ namespace blink { -struct PaintInfo; class LayoutEmbeddedObject; -class LayoutPoint; +struct PaintInfo; +struct PhysicalOffset; class EmbeddedObjectPainter { STACK_ALLOCATED(); @@ -20,7 +20,7 @@ EmbeddedObjectPainter(const LayoutEmbeddedObject& layout_embedded_object) : layout_embedded_object_(layout_embedded_object) {} - void PaintReplaced(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintReplaced(const PaintInfo&, const PhysicalOffset& paint_offset); private: const LayoutEmbeddedObject& layout_embedded_object_;
diff --git a/third_party/blink/renderer/core/paint/fieldset_paint_info.cc b/third_party/blink/renderer/core/paint/fieldset_paint_info.cc index 4f49214..832352d 100644 --- a/third_party/blink/renderer/core/paint/fieldset_paint_info.cc +++ b/third_party/blink/renderer/core/paint/fieldset_paint_info.cc
@@ -9,19 +9,19 @@ namespace blink { FieldsetPaintInfo::FieldsetPaintInfo(const ComputedStyle& fieldset_style, - LayoutSize fieldset_size, - LayoutRectOutsets fieldset_borders, - LayoutRect legend_border_box) { + const PhysicalSize& fieldset_size, + const LayoutRectOutsets& fieldset_borders, + const PhysicalRect& legend_border_box) { if (fieldset_style.IsHorizontalWritingMode()) { // horizontal-tb - LayoutUnit legend_size = legend_border_box.Height(); + LayoutUnit legend_size = legend_border_box.size.height; LayoutUnit border_size = fieldset_borders.Top(); LayoutUnit legend_excess_size = legend_size - border_size; if (legend_excess_size > LayoutUnit()) border_outsets.SetTop(legend_excess_size / 2); - legend_cutout_rect = LayoutRect(legend_border_box.X(), LayoutUnit(), - legend_border_box.Width(), - std::max(legend_size, border_size)); + legend_cutout_rect = PhysicalRect(legend_border_box.X(), LayoutUnit(), + legend_border_box.Width(), + std::max(legend_size, border_size)); } else { LayoutUnit legend_size = legend_border_box.Width(); LayoutUnit border_size; @@ -40,12 +40,12 @@ } LayoutUnit legend_total_block_size = std::max(legend_size, border_size); legend_cutout_rect = - LayoutRect(LayoutUnit(), legend_border_box.Y(), legend_total_block_size, - legend_border_box.Height()); + PhysicalRect(LayoutUnit(), legend_border_box.offset.top, + legend_total_block_size, legend_border_box.size.height); if (fieldset_style.IsFlippedBlocksWritingMode()) { // Offset cutout to right fieldset edge for vertical-rl - LayoutUnit clip_x = fieldset_size.Width() - legend_total_block_size; - legend_cutout_rect.Move(clip_x, LayoutUnit()); + LayoutUnit clip_x = fieldset_size.width - legend_total_block_size; + legend_cutout_rect.offset.left += clip_x; } } }
diff --git a/third_party/blink/renderer/core/paint/fieldset_paint_info.h b/third_party/blink/renderer/core/paint/fieldset_paint_info.h index c8442df..19d13e2f 100644 --- a/third_party/blink/renderer/core/paint/fieldset_paint_info.h +++ b/third_party/blink/renderer/core/paint/fieldset_paint_info.h
@@ -5,7 +5,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_FIELDSET_PAINT_INFO_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_FIELDSET_PAINT_INFO_H_ -#include "third_party/blink/renderer/platform/geometry/layout_rect.h" +#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" #include "third_party/blink/renderer/platform/geometry/layout_rect_outsets.h" namespace blink { @@ -16,9 +16,9 @@ // Calculate the fieldset block-start border offset and the cut-out rectangle // caused by the rendered legend. FieldsetPaintInfo(const ComputedStyle& fieldset_style, - LayoutSize fieldset_size, - LayoutRectOutsets fieldset_borders, - LayoutRect legend_border_box); + const PhysicalSize& fieldset_size, + const LayoutRectOutsets& fieldset_borders, + const PhysicalRect& legend_border_box); // Block-start border outset caused by the rendered legend. LayoutRectOutsets border_outsets; @@ -27,7 +27,7 @@ // the legend. Note that this may intersect with other border sides than the // block-start one, if the legend happens to overlap with any of the other // borders. - LayoutRect legend_cutout_rect; + PhysicalRect legend_cutout_rect; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/fieldset_painter.cc b/third_party/blink/renderer/core/paint/fieldset_painter.cc index 770b76ba..8b05aba 100644 --- a/third_party/blink/renderer/core/paint/fieldset_painter.cc +++ b/third_party/blink/renderer/core/paint/fieldset_painter.cc
@@ -24,16 +24,19 @@ fieldset.BorderTop(), fieldset.BorderRight(), LayoutUnit(), // bottom border will always be left alone. fieldset.BorderLeft()); - return FieldsetPaintInfo(fieldset.StyleRef(), fieldset.Size(), - fieldset_borders, legend.FrameRect()); + // Using legend.FrameRect() is incorrect in vertical-rl mode, but we probably + // won't fix this here which is for legacy layout. + return FieldsetPaintInfo(fieldset.StyleRef(), + PhysicalSizeToBeNoop(fieldset.Size()), + fieldset_borders, PhysicalRect(legend.FrameRect())); } } // anonymous namespace void FieldsetPainter::PaintBoxDecorationBackground( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { - LayoutRect paint_rect(paint_offset, layout_fieldset_.Size()); + const PhysicalOffset& paint_offset) { + PhysicalRect paint_rect(paint_offset, layout_fieldset_.Size()); LayoutBox* legend = layout_fieldset_.FindInFlowLegend(); if (!legend) { return BoxPainter(layout_fieldset_) @@ -73,8 +76,8 @@ GraphicsContext& graphics_context = paint_info.context; GraphicsContextStateSaver state_saver(graphics_context); - LayoutRect legend_cutout_rect = fieldset_paint_info.legend_cutout_rect; - legend_cutout_rect.MoveBy(paint_offset); + PhysicalRect legend_cutout_rect = fieldset_paint_info.legend_cutout_rect; + legend_cutout_rect.Move(paint_offset); graphics_context.ClipOut(PixelSnappedIntRect(legend_cutout_rect)); Node* node = nullptr; @@ -92,12 +95,12 @@ } void FieldsetPainter::PaintMask(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { if (layout_fieldset_.StyleRef().Visibility() != EVisibility::kVisible || paint_info.phase != PaintPhase::kMask) return; - LayoutRect paint_rect = LayoutRect(paint_offset, layout_fieldset_.Size()); + PhysicalRect paint_rect(paint_offset, layout_fieldset_.Size()); LayoutBox* legend = layout_fieldset_.FindInFlowLegend(); if (!legend) return BoxPainter(layout_fieldset_).PaintMask(paint_info, paint_offset);
diff --git a/third_party/blink/renderer/core/paint/fieldset_painter.h b/third_party/blink/renderer/core/paint/fieldset_painter.h index 66195e03..7a810a13 100644 --- a/third_party/blink/renderer/core/paint/fieldset_painter.h +++ b/third_party/blink/renderer/core/paint/fieldset_painter.h
@@ -9,9 +9,9 @@ namespace blink { -struct PaintInfo; -class LayoutPoint; class LayoutFieldset; +struct PaintInfo; +struct PhysicalOffset; class FieldsetPainter { STACK_ALLOCATED(); @@ -21,8 +21,8 @@ : layout_fieldset_(layout_fieldset) {} void PaintBoxDecorationBackground(const PaintInfo&, - const LayoutPoint& paint_offset); - void PaintMask(const PaintInfo&, const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); + void PaintMask(const PaintInfo&, const PhysicalOffset& paint_offset); private: const LayoutFieldset& layout_fieldset_;
diff --git a/third_party/blink/renderer/core/paint/file_upload_control_painter.cc b/third_party/blink/renderer/core/paint/file_upload_control_painter.cc index 24060347..17ce65de 100644 --- a/third_party/blink/renderer/core/paint/file_upload_control_painter.cc +++ b/third_party/blink/renderer/core/paint/file_upload_control_painter.cc
@@ -16,7 +16,7 @@ namespace blink { void FileUploadControlPainter::PaintObject(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { if (layout_file_upload_control_.StyleRef().Visibility() != EVisibility::kVisible) return; @@ -33,7 +33,7 @@ text_run.SetExpansionBehavior(TextRun::kAllowTrailingExpansion); // Determine where the filename should be placed - LayoutUnit content_left = paint_offset.X() + + LayoutUnit content_left = paint_offset.left + layout_file_upload_control_.BorderLeft() + layout_file_upload_control_.PaddingLeft(); Node* button = layout_file_upload_control_.UploadButton(); @@ -59,7 +59,7 @@ // FIXME: Make this work with transforms. if (LayoutButton* button_layout_object = ToLayoutButton(button->GetLayoutObject())) - text_y = paint_offset.Y() + layout_file_upload_control_.BorderTop() + + text_y = paint_offset.top + layout_file_upload_control_.BorderTop() + layout_file_upload_control_.PaddingTop() + button_layout_object->BaselinePosition( kAlphabeticBaseline, true, kHorizontalLine,
diff --git a/third_party/blink/renderer/core/paint/file_upload_control_painter.h b/third_party/blink/renderer/core/paint/file_upload_control_painter.h index 2935b6f..90378eba 100644 --- a/third_party/blink/renderer/core/paint/file_upload_control_painter.h +++ b/third_party/blink/renderer/core/paint/file_upload_control_painter.h
@@ -9,9 +9,9 @@ namespace blink { -struct PaintInfo; -class LayoutPoint; class LayoutFileUploadControl; +struct PaintInfo; +struct PhysicalOffset; class FileUploadControlPainter { STACK_ALLOCATED(); @@ -21,7 +21,7 @@ const LayoutFileUploadControl& layout_file_upload_control) : layout_file_upload_control_(layout_file_upload_control) {} - void PaintObject(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintObject(const PaintInfo&, const PhysicalOffset& paint_offset); private: const LayoutFileUploadControl& layout_file_upload_control_;
diff --git a/third_party/blink/renderer/core/paint/find_paint_offset_and_visual_rect_needing_update.h b/third_party/blink/renderer/core/paint/find_paint_offset_and_visual_rect_needing_update.h index c3357af..7e73af9 100644 --- a/third_party/blink/renderer/core/paint/find_paint_offset_and_visual_rect_needing_update.h +++ b/third_party/blink/renderer/core/paint/find_paint_offset_and_visual_rect_needing_update.h
@@ -45,7 +45,7 @@ ~FindPaintOffsetNeedingUpdateScope() { if (is_actually_needed_) return; - LayoutPoint paint_offset = fragment_data_.PaintOffset(); + auto paint_offset = fragment_data_.PaintOffset(); DCHECK_EQ(old_paint_offset_, paint_offset) << object_.DebugName(); const TransformPaintPropertyNode* new_parent = nullptr; @@ -66,7 +66,7 @@ const LayoutObject& object_; const FragmentData& fragment_data_; const bool& is_actually_needed_; - LayoutPoint old_paint_offset_; + PhysicalOffset old_paint_offset_; const TransformPaintPropertyNode* old_parent_ = nullptr; base::Optional<FloatSize> old_translation_; };
diff --git a/third_party/blink/renderer/core/paint/fragment_data.cc b/third_party/blink/renderer/core/paint/fragment_data.cc index 5415892..ad011e8 100644 --- a/third_party/blink/renderer/core/paint/fragment_data.cc +++ b/third_party/blink/renderer/core/paint/fragment_data.cc
@@ -149,37 +149,15 @@ rare_data_->clip_path_path = std::move(path); } -template <typename Rect, typename PaintOffsetFunction> -static void MapRectBetweenFragment( - const FragmentData& from_fragment, - const FragmentData& to_fragment, - const PaintOffsetFunction& paint_offset_function, - Rect& rect) { - if (&from_fragment == &to_fragment) - return; - const auto& from_transform = - from_fragment.LocalBorderBoxProperties().Transform(); - const auto& to_transform = to_fragment.LocalBorderBoxProperties().Transform(); - rect.MoveBy(paint_offset_function(from_fragment.PaintOffset())); - GeometryMapper::SourceToDestinationRect(from_transform, to_transform, rect); - rect.MoveBy(-paint_offset_function(to_fragment.PaintOffset())); -} - void FragmentData::MapRectToFragment(const FragmentData& fragment, IntRect& rect) const { - MapRectBetweenFragment( - *this, fragment, - [](const LayoutPoint& paint_offset) { - return RoundedIntPoint(paint_offset); - }, - rect); -} - -void FragmentData::MapRectToFragment(const FragmentData& fragment, - LayoutRect& rect) const { - MapRectBetweenFragment( - *this, fragment, - [](const LayoutPoint& paint_offset) { return paint_offset; }, rect); + if (this == &fragment) + return; + const auto& from_transform = LocalBorderBoxProperties().Transform(); + const auto& to_transform = fragment.LocalBorderBoxProperties().Transform(); + rect.MoveBy(RoundedIntPoint(PaintOffset())); + GeometryMapper::SourceToDestinationRect(from_transform, to_transform, rect); + rect.MoveBy(-RoundedIntPoint(fragment.PaintOffset())); } } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/fragment_data.h b/third_party/blink/renderer/core/paint/fragment_data.h index 2eb6b7e..8a35b7b 100644 --- a/third_party/blink/renderer/core/paint/fragment_data.h +++ b/third_party/blink/renderer/core/paint/fragment_data.h
@@ -6,6 +6,7 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_FRAGMENT_DATA_H_ #include "base/optional.h" +#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" #include "third_party/blink/renderer/core/paint/object_paint_properties.h" #include "third_party/blink/renderer/platform/graphics/paint/ref_counted_property_tree_state.h" #include "third_party/blink/renderer/platform/wtf/allocator.h" @@ -30,8 +31,8 @@ // "paint offset root" which is the containing root PaintLayer of the root // LocalFrameView, or PaintLayer with a transform, whichever is nearer along // the containing block chain. - LayoutPoint PaintOffset() const { return paint_offset_; } - void SetPaintOffset(const LayoutPoint& paint_offset) { + PhysicalOffset PaintOffset() const { return paint_offset_; } + void SetPaintOffset(const PhysicalOffset& paint_offset) { paint_offset_ = paint_offset; } @@ -69,13 +70,13 @@ // object's local coordinate space. During PrePaint, the rect mapped into // visual rect space will be added into PartialInvalidationVisualRect(), and // cleared. - LayoutRect PartialInvalidationLocalRect() const { + PhysicalRect PartialInvalidationLocalRect() const { return rare_data_ ? rare_data_->partial_invalidation_local_rect - : LayoutRect(); + : PhysicalRect(); } // LayoutObject::InvalidatePaintRectangle() calls this method to accumulate // the sub-rectangles needing re-rasterization. - void SetPartialInvalidationLocalRect(const LayoutRect& r) { + void SetPartialInvalidationLocalRect(const PhysicalRect& r) { if (rare_data_ || !r.IsEmpty()) EnsureRareData().partial_invalidation_local_rect = r; } @@ -103,11 +104,11 @@ // The pagination offset is the additional factor to add in to map // from flow thread coordinates relative to the enclosing pagination // layer, to visual coordiantes relative to that pagination layer. - LayoutPoint PaginationOffset() const { - return rare_data_ ? rare_data_->pagination_offset : LayoutPoint(); + PhysicalOffset PaginationOffset() const { + return rare_data_ ? rare_data_->pagination_offset : PhysicalOffset(); } - void SetPaginationOffset(const LayoutPoint& pagination_offset) { - if (rare_data_ || pagination_offset != LayoutPoint()) + void SetPaginationOffset(const PhysicalOffset& pagination_offset) { + if (rare_data_ || pagination_offset != PhysicalOffset()) EnsureRareData().pagination_offset = pagination_offset; } @@ -224,7 +225,6 @@ // Map a rect from |this|'s local border box space to |fragment|'s local // border box space. Both fragments must have local border box properties. void MapRectToFragment(const FragmentData& fragment, IntRect&) const; - void MapRectToFragment(const FragmentData& fragment, LayoutRect&) const; ~FragmentData() { if (next_fragment_) @@ -249,11 +249,11 @@ std::unique_ptr<PaintLayer> layer; UniqueObjectId unique_id; IntRect selection_visual_rect; - LayoutRect partial_invalidation_local_rect; + PhysicalRect partial_invalidation_local_rect; IntRect partial_invalidation_visual_rect; // Fragment specific data. - LayoutPoint pagination_offset; + PhysicalOffset pagination_offset; LayoutUnit logical_top_in_flow_thread; std::unique_ptr<ObjectPaintProperties> paint_properties; std::unique_ptr<RefCountedPropertyTreeState> local_border_box_properties; @@ -267,7 +267,7 @@ RareData& EnsureRareData(); IntRect visual_rect_; - LayoutPoint paint_offset_; + PhysicalOffset paint_offset_; std::unique_ptr<RareData> rare_data_; std::unique_ptr<FragmentData> next_fragment_;
diff --git a/third_party/blink/renderer/core/paint/frame_set_painter.cc b/third_party/blink/renderer/core/paint/frame_set_painter.cc index 196fca5..8962aee 100644 --- a/third_party/blink/renderer/core/paint/frame_set_painter.cc +++ b/third_party/blink/renderer/core/paint/frame_set_painter.cc
@@ -82,7 +82,7 @@ } void FrameSetPainter::PaintBorders(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { if (DrawingRecorder::UseCachedDrawingIfPossible( paint_info.context, layout_frame_set_, paint_info.phase)) return; @@ -105,8 +105,8 @@ if (ShouldPaintBorderAfter(layout_frame_set_.Columns(), c)) { PaintColumnBorder( paint_info, - PixelSnappedIntRect(LayoutRect( - paint_offset.X() + x_pos, paint_offset.Y() + y_pos, + PixelSnappedIntRect(PhysicalRect( + paint_offset.left + x_pos, paint_offset.top + y_pos, border_thickness, layout_frame_set_.Size().Height() - y_pos))); x_pos += border_thickness; } @@ -117,8 +117,8 @@ y_pos += layout_frame_set_.Rows().sizes_[r]; if (ShouldPaintBorderAfter(layout_frame_set_.Rows(), r)) { PaintRowBorder(paint_info, - PixelSnappedIntRect(LayoutRect( - paint_offset.X(), paint_offset.Y() + y_pos, + PixelSnappedIntRect(PhysicalRect( + paint_offset.left, paint_offset.top + y_pos, layout_frame_set_.Size().Width(), border_thickness))); y_pos += border_thickness; }
diff --git a/third_party/blink/renderer/core/paint/frame_set_painter.h b/third_party/blink/renderer/core/paint/frame_set_painter.h index 126f26d4..5839aa7b 100644 --- a/third_party/blink/renderer/core/paint/frame_set_painter.h +++ b/third_party/blink/renderer/core/paint/frame_set_painter.h
@@ -9,10 +9,10 @@ namespace blink { -struct PaintInfo; class IntRect; class LayoutFrameSet; -class LayoutPoint; +struct PaintInfo; +struct PhysicalOffset; class FrameSetPainter { STACK_ALLOCATED(); @@ -24,7 +24,7 @@ void Paint(const PaintInfo&); private: - void PaintBorders(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintBorders(const PaintInfo&, const PhysicalOffset& paint_offset); void PaintChildren(const PaintInfo&); void PaintRowBorder(const PaintInfo&, const IntRect&); void PaintColumnBorder(const PaintInfo&, const IntRect&);
diff --git a/third_party/blink/renderer/core/paint/html_canvas_painter.cc b/third_party/blink/renderer/core/paint/html_canvas_painter.cc index 3fee18f..0d911dc2 100644 --- a/third_party/blink/renderer/core/paint/html_canvas_painter.cc +++ b/third_party/blink/renderer/core/paint/html_canvas_painter.cc
@@ -30,12 +30,11 @@ } // namespace void HTMLCanvasPainter::PaintReplaced(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { GraphicsContext& context = paint_info.context; - LayoutRect paint_rect = - layout_html_canvas_.ReplacedContentRect().ToLayoutRect(); - paint_rect.MoveBy(paint_offset); + PhysicalRect paint_rect = layout_html_canvas_.ReplacedContentRect(); + paint_rect.Move(paint_offset); HTMLCanvasElement* canvas = ToHTMLCanvasElement(layout_html_canvas_.GetNode());
diff --git a/third_party/blink/renderer/core/paint/html_canvas_painter.h b/third_party/blink/renderer/core/paint/html_canvas_painter.h index 764dd346..fdbaa3f 100644 --- a/third_party/blink/renderer/core/paint/html_canvas_painter.h +++ b/third_party/blink/renderer/core/paint/html_canvas_painter.h
@@ -9,9 +9,9 @@ namespace blink { -struct PaintInfo; -class LayoutPoint; class LayoutHTMLCanvas; +struct PaintInfo; +struct PhysicalOffset; class HTMLCanvasPainter { STACK_ALLOCATED(); @@ -19,7 +19,7 @@ public: HTMLCanvasPainter(const LayoutHTMLCanvas& layout_html_canvas) : layout_html_canvas_(layout_html_canvas) {} - void PaintReplaced(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintReplaced(const PaintInfo&, const PhysicalOffset& paint_offset); private: const LayoutHTMLCanvas& layout_html_canvas_;
diff --git a/third_party/blink/renderer/core/paint/image_painter.cc b/third_party/blink/renderer/core/paint/image_painter.cc index ccdf72f..eb2c560 100644 --- a/third_party/blink/renderer/core/paint/image_painter.cc +++ b/third_party/blink/renderer/core/paint/image_painter.cc
@@ -100,7 +100,7 @@ ScopedPaintState paint_state(layout_image_, paint_info); auto paint_offset = paint_state.PaintOffset(); - path.Translate(FloatSize(paint_offset.X(), paint_offset.Y())); + path.Translate(FloatSize(paint_offset)); if (DrawingRecorder::UseCachedDrawingIfPossible( paint_info.context, layout_image_, DisplayItem::kImageAreaFocusRing)) @@ -113,8 +113,8 @@ // https://crbug.com/251206 paint_info.context.Save(); - LayoutRect focus_rect = layout_image_.PhysicalContentBoxRect().ToLayoutRect(); - focus_rect.MoveBy(paint_offset); + PhysicalRect focus_rect = layout_image_.PhysicalContentBoxRect(); + focus_rect.Move(paint_offset); paint_info.context.Clip(PixelSnappedIntRect(focus_rect)); paint_info.context.DrawFocusRing( path, area_element_style.GetOutlineStrokeWidthForFocusRing(), @@ -125,7 +125,7 @@ } void ImagePainter::PaintReplaced(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { LayoutSize content_size = layout_image_.ContentSize(); bool has_image = layout_image_.ImageResource()->HasImage(); @@ -152,9 +152,9 @@ layout_image_.ImageResource()->MaybeAnimated()) cache_skipper.emplace(context); - LayoutRect content_rect( - paint_offset + layout_image_.PhysicalContentBoxOffset().ToLayoutPoint(), - content_size); + PhysicalRect content_rect( + paint_offset + layout_image_.PhysicalContentBoxOffset(), + PhysicalSizeToBeNoop(content_size)); if (!has_image) { // Draw an outline rect where the image should be. @@ -167,8 +167,8 @@ return; } - LayoutRect paint_rect = layout_image_.ReplacedContentRect().ToLayoutRect(); - paint_rect.MoveBy(paint_offset); + PhysicalRect paint_rect = layout_image_.ReplacedContentRect(); + paint_rect.offset += paint_offset; DrawingRecorder recorder(context, layout_image_, paint_info.phase); DCHECK(paint_info.PaintContainer()); @@ -176,8 +176,8 @@ } void ImagePainter::PaintIntoRect(GraphicsContext& context, - const LayoutRect& dest_rect, - const LayoutRect& content_rect) { + const PhysicalRect& dest_rect, + const PhysicalRect& content_rect) { if (!layout_image_.ImageResource()->HasImage() || layout_image_.ImageResource()->ErrorOccurred()) return; // FIXME: should we just ASSERT these conditions? (audit all
diff --git a/third_party/blink/renderer/core/paint/image_painter.h b/third_party/blink/renderer/core/paint/image_painter.h index fb08ac9c..35bf83a 100644 --- a/third_party/blink/renderer/core/paint/image_painter.h +++ b/third_party/blink/renderer/core/paint/image_painter.h
@@ -9,11 +9,11 @@ namespace blink { -struct PaintInfo; class GraphicsContext; -class LayoutPoint; -class LayoutRect; class LayoutImage; +struct PaintInfo; +struct PhysicalOffset; +struct PhysicalRect; class ImagePainter { STACK_ALLOCATED(); @@ -22,14 +22,14 @@ ImagePainter(const LayoutImage& layout_image) : layout_image_(layout_image) {} void Paint(const PaintInfo&); - void PaintReplaced(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintReplaced(const PaintInfo&, const PhysicalOffset& paint_offset); // Paint the image into |destRect|, after clipping by |contentRect|. Both // |destRect| and |contentRect| should be in local coordinates plus the paint // offset. void PaintIntoRect(GraphicsContext&, - const LayoutRect& dest_rect, - const LayoutRect& content_rect); + const PhysicalRect& dest_rect, + const PhysicalRect& content_rect); private: void PaintAreaElementFocusRing(const PaintInfo&);
diff --git a/third_party/blink/renderer/core/paint/inline_box_painter_base.cc b/third_party/blink/renderer/core/paint/inline_box_painter_base.cc index 4483ed5..9404988 100644 --- a/third_party/blink/renderer/core/paint/inline_box_painter_base.cc +++ b/third_party/blink/renderer/core/paint/inline_box_painter_base.cc
@@ -16,8 +16,8 @@ void InlineBoxPainterBase::PaintBoxDecorationBackground( BoxPainterBase& box_painter, const PaintInfo& paint_info, - const LayoutPoint& paint_offset, - LayoutRect adjusted_frame_rect, + const PhysicalOffset& paint_offset, + const PhysicalRect& adjusted_frame_rect, BackgroundImageGeometry geometry, bool object_has_multiple_boxes, bool include_logical_left_edge, @@ -49,7 +49,7 @@ // FIXME: What the heck do we do with RTL here? The math we're using is // obviously not right, but it isn't even clear how this should work at // all. - LayoutRect image_strip_paint_rect = + PhysicalRect image_strip_paint_rect = PaintRectForImageStrip(adjusted_frame_rect, TextDirection::kLtr); GraphicsContextStateSaver state_saver(paint_info.context); paint_info.context.Clip(adjusted_clip_rect); @@ -64,7 +64,7 @@ const PaintInfo& info, const Color& c, const FillLayer& layer, - const LayoutRect& rect, + const PhysicalRect& rect, BackgroundImageGeometry& geometry, bool object_has_multiple_boxes) { // FIXME: This should be a for loop or similar. It's a little non-trivial to @@ -81,7 +81,7 @@ const PaintInfo& paint_info, const Color& c, const FillLayer& fill_layer, - const LayoutRect& paint_rect, + const PhysicalRect& paint_rect, BackgroundImageGeometry& geometry, bool object_has_multiple_boxes) { StyleImage* img = fill_layer.GetImage(); @@ -97,14 +97,14 @@ // Handle fill images that clone or spans multiple lines. bool multi_line = object_has_multiple_boxes && style_.BoxDecorationBreak() != EBoxDecorationBreak::kClone; - LayoutRect rect = multi_line - ? PaintRectForImageStrip(paint_rect, style_.Direction()) - : paint_rect; + PhysicalRect rect = + multi_line ? PaintRectForImageStrip(paint_rect, style_.Direction()) + : paint_rect; GraphicsContextStateSaver state_saver(paint_info.context); paint_info.context.Clip(PixelSnappedIntRect(paint_rect)); box_painter.PaintFillLayer(paint_info, c, fill_layer, rect, kBackgroundBleedNone, geometry, multi_line, - paint_rect.Size()); + paint_rect.size); } } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/inline_box_painter_base.h b/third_party/blink/renderer/core/paint/inline_box_painter_base.h index 8452081..1e1794e 100644 --- a/third_party/blink/renderer/core/paint/inline_box_painter_base.h +++ b/third_party/blink/renderer/core/paint/inline_box_painter_base.h
@@ -14,12 +14,12 @@ namespace blink { class Color; +class ComputedStyle; class FillLayer; class IntRect; -class LayoutPoint; -class LayoutRect; struct PaintInfo; -class ComputedStyle; +struct PhysicalOffset; +struct PhysicalRect; // Common base class for InlineFlowBoxPainter and NGInlineBoxFragmentPainter. // Implements layout agnostic inline box painting behavior. @@ -40,8 +40,8 @@ void PaintBoxDecorationBackground(BoxPainterBase&, const PaintInfo&, - const LayoutPoint& paint_offset, - LayoutRect adjusted_frame_rect, + const PhysicalOffset& paint_offset, + const PhysicalRect& adjusted_frame_rect, BackgroundImageGeometry, bool object_has_multiple_boxes, bool include_logical_left_edge, @@ -52,25 +52,26 @@ const PaintInfo&, const Color&, const FillLayer&, - const LayoutRect&, + const PhysicalRect&, BackgroundImageGeometry& geometry, bool object_has_multiple_boxes); void PaintFillLayer(BoxPainterBase&, const PaintInfo&, const Color&, const FillLayer&, - const LayoutRect&, + const PhysicalRect&, BackgroundImageGeometry& geometry, bool object_has_multiple_boxes); virtual void PaintNormalBoxShadow(const PaintInfo&, const ComputedStyle&, - const LayoutRect& paint_rect) = 0; + const PhysicalRect& paint_rect) = 0; virtual void PaintInsetBoxShadow(const PaintInfo&, const ComputedStyle&, - const LayoutRect& paint_rect) = 0; + const PhysicalRect& paint_rect) = 0; - virtual LayoutRect PaintRectForImageStrip(const LayoutRect&, - TextDirection direction) const = 0; + virtual PhysicalRect PaintRectForImageStrip( + const PhysicalRect&, + TextDirection direction) const = 0; enum BorderPaintingType { kDontPaintBorders, @@ -78,7 +79,7 @@ kPaintBordersWithClip }; virtual BorderPaintingType GetBorderPaintType( - const LayoutRect& adjusted_frame_rect, + const PhysicalRect& adjusted_frame_rect, IntRect& adjusted_clip_rect, bool object_has_multiple_boxes) const = 0;
diff --git a/third_party/blink/renderer/core/paint/inline_flow_box_painter.cc b/third_party/blink/renderer/core/paint/inline_flow_box_painter.cc index 08fafb29..1c33d68 100644 --- a/third_party/blink/renderer/core/paint/inline_flow_box_painter.cc +++ b/third_party/blink/renderer/core/paint/inline_flow_box_painter.cc
@@ -223,10 +223,11 @@ LineLayoutAPIShim::LayoutObjectFrom(inline_flow_box_.BoxModelObject())); BackgroundImageGeometry geometry(box_model); BoxModelObjectPainter box_painter(box_model, &inline_flow_box_); - PaintBoxDecorationBackground(box_painter, paint_info, paint_offset, - paint_rect, geometry, object_has_multiple_boxes, - inline_flow_box_.IncludeLogicalLeftEdge(), - inline_flow_box_.IncludeLogicalRightEdge()); + PaintBoxDecorationBackground( + box_painter, paint_info, PhysicalOffsetToBeNoop(paint_offset), + PhysicalRectToBeNoop(paint_rect), geometry, object_has_multiple_boxes, + inline_flow_box_.IncludeLogicalLeftEdge(), + inline_flow_box_.IncludeLogicalRightEdge()); } void InlineFlowBoxPainter::PaintMask(const PaintInfo& paint_info, @@ -255,7 +256,8 @@ BackgroundImageGeometry geometry(box_model); BoxModelObjectPainter box_painter(box_model, &inline_flow_box_); PaintFillLayers(box_painter, paint_info, Color::kTransparent, - box_model.StyleRef().MaskLayers(), paint_rect, geometry, + box_model.StyleRef().MaskLayers(), + PhysicalRectToBeNoop(paint_rect), geometry, object_has_multiple_boxes); bool has_box_image = mask_box_image && mask_box_image->CanRender(); @@ -269,8 +271,8 @@ if (!object_has_multiple_boxes) { NinePieceImagePainter::Paint(paint_info.context, box_model, box_model.GetDocument(), GetNode(&box_model), - paint_rect, box_model.StyleRef(), - mask_nine_piece_image); + PhysicalRectToBeNoop(paint_rect), + box_model.StyleRef(), mask_nine_piece_image); } else { // We have a mask image that spans multiple lines. // FIXME: What the heck do we do with RTL here? The math we're using is @@ -285,8 +287,8 @@ paint_info.context.Clip(clip_rect); NinePieceImagePainter::Paint(paint_info.context, box_model, box_model.GetDocument(), GetNode(&box_model), - image_strip_paint_rect, box_model.StyleRef(), - mask_nine_piece_image); + PhysicalRectToBeNoop(image_strip_paint_rect), + box_model.StyleRef(), mask_nine_piece_image); } } @@ -355,7 +357,8 @@ const ComputedStyle& s, const LayoutRect& paint_rect) { BoxPainterBase::PaintNormalBoxShadow( - info, paint_rect, s, inline_flow_box_.IncludeLogicalLeftEdge(), + info, PhysicalRectToBeNoop(paint_rect), s, + inline_flow_box_.IncludeLogicalLeftEdge(), inline_flow_box_.IncludeLogicalRightEdge()); } @@ -363,7 +366,8 @@ const ComputedStyle& s, const LayoutRect& paint_rect) { BoxPainterBase::PaintInsetBoxShadowWithBorderRect( - info, paint_rect, s, inline_flow_box_.IncludeLogicalLeftEdge(), + info, PhysicalRectToBeNoop(paint_rect), s, + inline_flow_box_.IncludeLogicalLeftEdge(), inline_flow_box_.IncludeLogicalRightEdge()); }
diff --git a/third_party/blink/renderer/core/paint/inline_flow_box_painter.h b/third_party/blink/renderer/core/paint/inline_flow_box_painter.h index 9029b8d2..035b1356 100644 --- a/third_party/blink/renderer/core/paint/inline_flow_box_painter.h +++ b/third_party/blink/renderer/core/paint/inline_flow_box_painter.h
@@ -5,6 +5,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_INLINE_FLOW_BOX_PAINTER_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_INLINE_FLOW_BOX_PAINTER_H_ +#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" #include "third_party/blink/renderer/core/paint/box_model_object_painter.h" #include "third_party/blink/renderer/core/paint/inline_box_painter_base.h" #include "third_party/blink/renderer/core/style/shadow_data.h" @@ -34,26 +35,46 @@ LayoutRect FrameRectClampedToLineTopAndBottomIfNeeded() const; - protected: - LayoutRect PaintRectForImageStrip(const LayoutRect&, - TextDirection) const override; + private: + // LayoutNG version adapters. + PhysicalRect PaintRectForImageStrip(const PhysicalRect& rect, + TextDirection direction) const override { + return PhysicalRect(PaintRectForImageStrip(rect.ToLayoutRect(), direction)); + } + void PaintNormalBoxShadow(const PaintInfo& info, + const ComputedStyle& style, + const PhysicalRect& rect) override { + return PaintNormalBoxShadow(info, style, rect.ToLayoutRect()); + } + void PaintInsetBoxShadow(const PaintInfo& info, + const ComputedStyle& style, + const PhysicalRect& rect) override { + return PaintInsetBoxShadow(info, style, rect.ToLayoutRect()); + } + BorderPaintingType GetBorderPaintType( + const PhysicalRect& adjusted_frame_rect, + IntRect& adjusted_clip_rect, + bool object_has_multiple_boxes) const override { + return GetBorderPaintType(adjusted_frame_rect.ToLayoutRect(), + adjusted_clip_rect, object_has_multiple_boxes); + } + + // Legacy version. + LayoutRect PaintRectForImageStrip(const LayoutRect&, TextDirection) const; void PaintNormalBoxShadow(const PaintInfo&, const ComputedStyle&, - const LayoutRect& paint_rect) override; + const LayoutRect& paint_rect); void PaintInsetBoxShadow(const PaintInfo&, const ComputedStyle&, - const LayoutRect& paint_rect) override; + const LayoutRect& paint_rect); + BorderPaintingType GetBorderPaintType(const LayoutRect& adjusted_frame_rect, + IntRect& adjusted_clip_rect, + bool object_has_multiple_boxes) const; - private: void PaintBackgroundBorderShadow(const PaintInfo&, const LayoutPoint& paint_offset); void PaintMask(const PaintInfo&, const LayoutPoint& paint_offset); - BorderPaintingType GetBorderPaintType( - const LayoutRect& adjusted_frame_rect, - IntRect& adjusted_clip_rect, - bool object_has_multiple_boxes) const override; - LayoutRect AdjustedPaintRect(const LayoutPoint& paint_offset) const; // Paint a hit test display item and record hit test data. This should be
diff --git a/third_party/blink/renderer/core/paint/inline_painter.cc b/third_party/blink/renderer/core/paint/inline_painter.cc index ea90c7e..f208b0b 100644 --- a/third_party/blink/renderer/core/paint/inline_painter.cc +++ b/third_party/blink/renderer/core/paint/inline_painter.cc
@@ -38,10 +38,9 @@ if (layout_inline_.IsInLayoutNGInlineFormattingContext()) { for (const NGPaintFragment* fragment : NGPaintFragment::InlineFragmentsFor(&layout_inline_)) { - auto child_offset = - paint_offset + - (fragment->InlineOffsetToContainerBox() - fragment->Offset()) - .ToLayoutPoint(); + auto child_offset = paint_offset + + fragment->InlineOffsetToContainerBox() - + fragment->Offset(); if (fragment->PhysicalFragment().IsText()) { const auto& text_fragment = @@ -74,7 +73,7 @@ } LineBoxListPainter(*layout_inline_.LineBoxes()) - .Paint(layout_inline_, local_paint_info, paint_offset); + .Paint(layout_inline_, local_paint_info, paint_offset.ToLayoutPoint()); } } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/inline_text_box_painter.cc b/third_party/blink/renderer/core/paint/inline_text_box_painter.cc index 7afa56e..e19a7dae 100644 --- a/third_party/blink/renderer/core/paint/inline_text_box_painter.cc +++ b/third_party/blink/renderer/core/paint/inline_text_box_painter.cc
@@ -248,8 +248,8 @@ } } else { should_rotate = true; - context.ConcatCTM( - TextPainterBase::Rotation(box_rect, TextPainterBase::kClockwise)); + context.ConcatCTM(TextPainterBase::Rotation(PhysicalRect(box_rect), + TextPainterBase::kClockwise)); } } @@ -357,10 +357,11 @@ EnclosingUnderlineObject(&inline_text_box_); const ComputedStyle* decorating_box_style = decorating_box ? decorating_box.Style() : nullptr; - text_painter.ComputeDecorationInfo(decoration_info, box_origin, - local_origin, width, - inline_text_box_.Root().BaselineType(), - style_to_use, decorating_box_style); + text_painter.ComputeDecorationInfo( + decoration_info, PhysicalOffsetToBeNoop(box_origin), + PhysicalOffsetToBeNoop(local_origin), width, + inline_text_box_.Root().BaselineType(), style_to_use, + decorating_box_style); TextDecorationOffset decoration_offset(*decoration_info.style, &inline_text_box_, decorating_box); text_painter.PaintDecorationsExceptLineThrough( @@ -428,7 +429,7 @@ if (should_rotate) { context.ConcatCTM(TextPainterBase::Rotation( - box_rect, TextPainterBase::kCounterclockwise)); + PhysicalRectToBeNoop(box_rect), TextPainterBase::kCounterclockwise)); } if (RuntimeEnabledFeatures::FirstContentfulPaintPlusPlusEnabled() && !font.ShouldSkipDrawing()) { @@ -676,8 +677,9 @@ width = LayoutUnit(marker_rect.Width()); } DocumentMarkerPainter::PaintDocumentMarker( - context, box_origin, style, marker.GetType(), - LayoutRect(start, LayoutUnit(), width, inline_text_box_.LogicalHeight())); + context, PhysicalOffsetToBeNoop(box_origin), style, marker.GetType(), + PhysicalRect(start, LayoutUnit(), width, + inline_text_box_.LogicalHeight())); } template <InlineTextBoxPainter::PaintOptions options> @@ -821,7 +823,7 @@ const FloatRect& marker_rect = font.SelectionRectForText( run, FloatPoint(), 0, marker_offsets.start, marker_offsets.end); DocumentMarkerPainter::PaintStyleableMarkerUnderline( - context, box_origin, marker, style, marker_rect, + context, PhysicalOffsetToBeNoop(box_origin), marker, style, marker_rect, inline_text_box_.LogicalHeight()); }
diff --git a/third_party/blink/renderer/core/paint/line_box_list_painter.cc b/third_party/blink/renderer/core/paint/line_box_list_painter.cc index 1c21cfd..0910247 100644 --- a/third_party/blink/renderer/core/paint/line_box_list_painter.cc +++ b/third_party/blink/renderer/core/paint/line_box_list_painter.cc
@@ -24,7 +24,8 @@ if (!child->IsLayoutInline() || ToLayoutBoxModelObject(child)->HasSelfPaintingLayer()) continue; - ObjectPainter(*child).AddPDFURLRectIfNeeded(paint_info, paint_offset); + ObjectPainter(*child).AddPDFURLRectIfNeeded( + paint_info, PhysicalOffsetToBeNoop(paint_offset)); AddPDFURLRectsForInlineChildrenRecursively(*child, paint_info, paint_offset); }
diff --git a/third_party/blink/renderer/core/paint/link_highlight_impl.cc b/third_party/blink/renderer/core/paint/link_highlight_impl.cc index 0de51b15..66b914fa 100644 --- a/third_party/blink/renderer/core/paint/link_highlight_impl.cc +++ b/third_party/blink/renderer/core/paint/link_highlight_impl.cc
@@ -464,7 +464,7 @@ size_t index = 0; for (const auto* fragment = &object->FirstFragment(); fragment; fragment = fragment->NextFragment(), ++index) { - auto rects = object->PhysicalOutlineRects( + auto rects = object->OutlineRects( fragment->PaintOffset(), NGOutlineType::kIncludeBlockVisualOverflow); if (rects.size() > 1) use_rounded_rects = false;
diff --git a/third_party/blink/renderer/core/paint/list_marker_painter.cc b/third_party/blink/renderer/core/paint/list_marker_painter.cc index 4d6965f..38c587c 100644 --- a/third_party/blink/renderer/core/paint/list_marker_painter.cc +++ b/third_party/blink/renderer/core/paint/list_marker_painter.cc
@@ -67,7 +67,7 @@ return; const auto& local_paint_info = paint_state.GetPaintInfo(); - auto box_origin = paint_state.PaintOffset(); + auto box_origin = paint_state.PaintOffset().ToLayoutPoint(); DrawingRecorder recorder(local_paint_info.context, layout_list_marker_, local_paint_info.phase);
diff --git a/third_party/blink/renderer/core/paint/multi_column_set_painter.cc b/third_party/blink/renderer/core/paint/multi_column_set_painter.cc index 2f55be4..c9a4348d 100644 --- a/third_party/blink/renderer/core/paint/multi_column_set_painter.cc +++ b/third_party/blink/renderer/core/paint/multi_column_set_painter.cc
@@ -15,7 +15,7 @@ namespace blink { void MultiColumnSetPainter::PaintObject(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { if (layout_multi_column_set_.StyleRef().Visibility() != EVisibility::kVisible) return; @@ -35,11 +35,12 @@ PaintColumnRules(paint_info, paint_offset); } -void MultiColumnSetPainter::PaintColumnRules(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { +void MultiColumnSetPainter::PaintColumnRules( + const PaintInfo& paint_info, + const PhysicalOffset& paint_offset) { Vector<LayoutRect> column_rule_bounds; - if (!layout_multi_column_set_.ComputeColumnRuleBounds(paint_offset, - column_rule_bounds)) + if (!layout_multi_column_set_.ComputeColumnRuleBounds( + paint_offset.ToLayoutPoint(), column_rule_bounds)) return; if (DrawingRecorder::UseCachedDrawingIfPossible(paint_info.context,
diff --git a/third_party/blink/renderer/core/paint/multi_column_set_painter.h b/third_party/blink/renderer/core/paint/multi_column_set_painter.h index 0540a463..065ae54 100644 --- a/third_party/blink/renderer/core/paint/multi_column_set_painter.h +++ b/third_party/blink/renderer/core/paint/multi_column_set_painter.h
@@ -9,9 +9,9 @@ namespace blink { -struct PaintInfo; -class LayoutPoint; class LayoutMultiColumnSet; +struct PaintInfo; +struct PhysicalOffset; class MultiColumnSetPainter { STACK_ALLOCATED(); @@ -19,10 +19,10 @@ public: MultiColumnSetPainter(const LayoutMultiColumnSet& layout_multi_column_set) : layout_multi_column_set_(layout_multi_column_set) {} - void PaintObject(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintObject(const PaintInfo&, const PhysicalOffset& paint_offset); private: - void PaintColumnRules(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintColumnRules(const PaintInfo&, const PhysicalOffset& paint_offset); const LayoutMultiColumnSet& layout_multi_column_set_; };
diff --git a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc index ca20fa4..9fd41ae2 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc
@@ -153,7 +153,7 @@ return; PaintInfo& info = paint_state.MutablePaintInfo(); - LayoutPoint paint_offset = paint_state.PaintOffset(); + PhysicalOffset paint_offset = paint_state.PaintOffset(); PaintPhase original_phase = info.phase; if (original_phase == PaintPhase::kOutline) { @@ -203,7 +203,7 @@ PhysicalRect border_box = physical_fragment.LocalRect(); if (physical_fragment.IsInline()) border_box.offset += box_fragment_.InlineOffsetToContainerBox(); - border_box.offset += PhysicalOffset(paint_offset); + border_box.offset += PhysicalOffsetToBeNoop(paint_offset); HitTestDisplayItem::Record( paint_info.context, box_fragment_, HitTestRect(border_box.ToLayoutRect(), @@ -215,7 +215,7 @@ const LayoutPoint& paint_offset, const NGPaintFragment& line) { PhysicalRect border_box = line.PhysicalFragment().LocalRect(); - border_box.offset += PhysicalOffset(paint_offset); + border_box.offset += PhysicalOffsetToBeNoop(paint_offset); HitTestDisplayItem::Record( paint_info.context, line, HitTestRect(border_box.ToLayoutRect(), @@ -224,7 +224,7 @@ void NGBoxFragmentPainter::PaintObject( const PaintInfo& paint_info, - const LayoutPoint& paint_offset, + const PhysicalOffset& paint_offset, bool suppress_box_decoration_background) { const PaintPhase paint_phase = paint_info.phase; const NGPhysicalBoxFragment& physical_box_fragment = PhysicalFragment(); @@ -237,7 +237,7 @@ if (NGFragmentPainter::ShouldRecordHitTestData(paint_info, physical_box_fragment)) - RecordHitTestData(paint_info, paint_offset); + RecordHitTestData(paint_info, paint_offset.ToLayoutPoint()); // Record the scroll hit test after the background so background squashing // is not affected. Hit test order would be equivalent if this were @@ -297,7 +297,7 @@ } void NGBoxFragmentPainter::PaintCarets(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { LocalFrame* frame = box_fragment_.GetLayoutObject()->GetFrame(); if (box_fragment_.ShouldPaintCursorCaret()) @@ -311,7 +311,7 @@ void NGBoxFragmentPainter::PaintBlockFlowContents( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { const NGPhysicalBoxFragment& fragment = PhysicalFragment(); LayoutObject* layout_object = fragment.GetLayoutObject(); @@ -412,7 +412,7 @@ } void NGBoxFragmentPainter::PaintMask(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { DCHECK_EQ(PaintPhase::kMask, paint_info.phase); const ComputedStyle& style = box_fragment_.Style(); if (!style.HasMask() || style.Visibility() != EVisibility::kVisible) @@ -427,8 +427,7 @@ box_fragment_.GetLayoutObject())); DrawingRecorder recorder(paint_info.context, box_fragment_, paint_info.phase); - LayoutRect paint_rect = - LayoutRect(paint_offset, box_fragment_.Size().ToLayoutSize()); + PhysicalRect paint_rect(paint_offset, box_fragment_.Size()); const NGBorderEdges& border_edges = BorderEdges(); PaintMaskImages(paint_info, paint_rect, *box_fragment_.GetLayoutObject(), geometry, border_edges.line_left, border_edges.line_right); @@ -438,7 +437,7 @@ // eliminate LayoutObject dependency were done yet. void NGBoxFragmentPainter::PaintBoxDecorationBackground( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { if (box_fragment_.PhysicalFragment().IsFieldsetContainer()) { NGFieldsetPainter(box_fragment_) .PaintBoxDecorationBackground(paint_info, paint_offset); @@ -455,29 +454,25 @@ // TODO(mstensho): Break dependency on LayoutObject functionality. const LayoutObject& layout_object = *box_fragment_.GetLayoutObject(); - LayoutRect paint_rect; + PhysicalRect paint_rect; base::Optional<ScopedBoxContentsPaintState> contents_paint_state; if (IsPaintingScrollingBackground(box_fragment_, paint_info)) { // For the case where we are painting the background into the scrolling // contents layer of a composited scroller we need to include the entire // overflow rect. const LayoutBox& layout_box = ToLayoutBox(layout_object); - paint_rect = layout_box.PhysicalLayoutOverflowRect().ToLayoutRect(); + paint_rect = layout_box.PhysicalLayoutOverflowRect(); contents_paint_state.emplace(paint_info, paint_offset, layout_box); - paint_rect.MoveBy(contents_paint_state->PaintOffset()); + paint_rect.Move(contents_paint_state->PaintOffset()); // The background painting code assumes that the borders are part of the // paintRect so we expand the paintRect by the border size when painting the // background into the scrolling contents layer. paint_rect.Expand(layout_box.BorderBoxOutsets()); } else { - // TODO(eae): We need better converters for ng geometry types. Long term we - // probably want to change the paint code to take NGPhysical* but that is a - // much bigger change. - PhysicalSize size = box_fragment_.Size(); - paint_rect = LayoutRect(LayoutPoint(), LayoutSize(size.width, size.height)); - paint_rect.MoveBy(paint_offset); + paint_rect.offset = paint_offset; + paint_rect.size = box_fragment_.Size(); } PaintBoxDecorationBackgroundWithRect( @@ -497,9 +492,9 @@ if (layout_box.FirstFragment().NextFragment()) return false; - LayoutRect bounds = IsPaintingScrollingBackground(box_fragment_, paint_info) - ? layout_box.LayoutOverflowRect() - : layout_box.SelfVisualOverflowRect(); + PhysicalRect bounds = IsPaintingScrollingBackground(box_fragment_, paint_info) + ? layout_box.PhysicalLayoutOverflowRect() + : layout_box.PhysicalSelfVisualOverflowRect(); return layout_box.BackgroundIsKnownToBeOpaqueInRect(bounds); } @@ -507,7 +502,7 @@ // eliminate LayoutObject dependency were done yet. void NGBoxFragmentPainter::PaintBoxDecorationBackgroundWithRect( const PaintInfo& paint_info, - const LayoutRect& paint_rect) { + const PhysicalRect& paint_rect) { const LayoutObject& layout_object = *box_fragment_.GetLayoutObject(); const LayoutBox& layout_box = ToLayoutBox(layout_object); @@ -562,7 +557,7 @@ ToLayoutTableCell(layout_box).Table()->ShouldCollapseBorders()) { // We have to clip here because the background would paint on top of the // collapsed table borders otherwise, since this is a self-painting layer. - LayoutRect clip_rect = paint_rect; + PhysicalRect clip_rect = paint_rect; clip_rect.Expand(ToLayoutTableCell(layout_box).BorderInsets()); state_saver.Save(); paint_info.context.Clip(PixelSnappedIntRect(clip_rect)); @@ -570,7 +565,8 @@ box_decoration_data.GetBackgroundBleedAvoidance())) { state_saver.Save(); FloatRoundedRect border = style.GetRoundedBorderFor( - paint_rect, border_edges.line_left, border_edges.line_right); + paint_rect.ToLayoutRect(), border_edges.line_left, + border_edges.line_right); paint_info.context.ClipRoundedRect(border); if (box_decoration_data.GetBackgroundBleedAvoidance() == @@ -632,7 +628,7 @@ // eliminate LayoutObject dependency were done yet. void NGBoxFragmentPainter::PaintBackground( const PaintInfo& paint_info, - const LayoutRect& paint_rect, + const PhysicalRect& paint_rect, const Color& background_color, BackgroundBleedAvoidance bleed_avoidance) { const LayoutObject& layout_object = *box_fragment_.GetLayoutObject(); @@ -703,7 +699,7 @@ void NGBoxFragmentPainter::PaintLineBoxChildren( NGPaintFragment::ChildList line_boxes, const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { // Only paint during the foreground/selection phases. if (paint_info.phase != PaintPhase::kForeground && paint_info.phase != PaintPhase::kSelection && @@ -737,16 +733,15 @@ // Check if CullRect intersects with this child, only in block direction // because soft-wrap and <br> needs to paint outside of InkOverflow() in // inline direction. - const LayoutPoint child_offset = - paint_offset + line->Offset().ToLayoutPoint(); + const PhysicalOffset child_offset = paint_offset + line->Offset(); PhysicalRect child_rect = line->InkOverflow(); if (is_horizontal) { - LayoutUnit y = child_rect.offset.top + child_offset.Y(); + LayoutUnit y = child_rect.offset.top + child_offset.top; if (!paint_info.GetCullRect().IntersectsVerticalRange( y, y + child_rect.size.height)) continue; } else { - LayoutUnit x = child_rect.offset.left + child_offset.X(); + LayoutUnit x = child_rect.offset.left + child_offset.left; if (!paint_info.GetCullRect().IntersectsHorizontalRange( x, x + child_rect.size.width)) continue; @@ -758,10 +753,20 @@ } DCHECK(child_fragment.IsLineBox()); - if (paint_info.phase == PaintPhase::kForeground && - NGFragmentPainter::ShouldRecordHitTestData(paint_info, - PhysicalFragment())) - RecordHitTestDataForLine(paint_info, child_offset, *line); + if (paint_info.phase == PaintPhase::kForeground) { + if (NGFragmentPainter::ShouldRecordHitTestData(paint_info, + PhysicalFragment())) { + RecordHitTestDataForLine(paint_info, child_offset.ToLayoutPoint(), + *line); + } + + // Line boxes don't paint anything, except when its ::first-line style has + // a background. + if (UNLIKELY(NGLineBoxFragmentPainter::NeedsPaint(child_fragment))) { + NGLineBoxFragmentPainter line_box_painter(*line, box_fragment_); + line_box_painter.PaintBackgroundBorderShadow(paint_info, child_offset); + } + } PaintInlineChildren(line->Children(), paint_info, child_offset); } @@ -770,7 +775,7 @@ void NGBoxFragmentPainter::PaintInlineChildren( NGPaintFragment::ChildList inline_children, const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { // TODO(kojii): Move kOutline painting into a |PaintInlineChildrenOutlines()| // method instead as it would be more efficient. Would require repeating some // of the code below though. @@ -785,7 +790,7 @@ // Skip if this child does not intersect with CullRect. if (!paint_info.GetCullRect().Intersects( child->InkOverflow().ToLayoutRect(), - paint_offset + child->Offset().ToLayoutPoint()) && + (paint_offset + child->Offset()).ToLayoutPoint()) && // Don't skip empty size text in order to paint selection for <br>. !(child_fragment.IsText() && child_fragment.Size().IsEmpty())) continue; @@ -824,7 +829,7 @@ void NGBoxFragmentPainter::PaintTextChild(const NGPaintFragment& paint_fragment, const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { // Inline blocks should be painted by PaintAtomicInlineChild. DCHECK(!paint_fragment.PhysicalFragment().IsAtomicInline()); @@ -874,7 +879,7 @@ // Clone of BlockPainter::PaintOverflowControlsIfNeeded void NGBoxFragmentPainter::PaintOverflowControlsIfNeeded( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { if (box_fragment_.HasOverflowClip() && box_fragment_.Style().Visibility() == EVisibility::kVisible && ShouldPaintSelfBlockBackground(paint_info.phase)) { @@ -887,18 +892,17 @@ bool NGBoxFragmentPainter::ShouldPaint( const ScopedPaintState& paint_state) const { // TODO(layout-dev): Add support for scrolling, see BlockPainter::ShouldPaint. - return paint_state.LocalRectIntersectsCullRect( - box_fragment_.InkOverflow().ToLayoutRect()); + return paint_state.LocalRectIntersectsCullRect(box_fragment_.InkOverflow()); } void NGBoxFragmentPainter::PaintTextClipMask(GraphicsContext& context, const IntRect& mask_rect, - const LayoutPoint& paint_offset, + const PhysicalOffset& paint_offset, bool object_has_multiple_boxes) { PaintInfo paint_info(context, mask_rect, PaintPhase::kTextClip, kGlobalPaintNormalPhase, 0); if (object_has_multiple_boxes) { - LayoutSize local_offset = box_fragment_.Offset().ToLayoutSize(); + PhysicalOffset local_offset = box_fragment_.Offset(); NGInlineBoxFragmentPainter inline_box_painter(box_fragment_); if (box_fragment_.Style().BoxDecorationBreak() == EBoxDecorationBreak::kSlice) { @@ -907,9 +911,10 @@ inline_box_painter.ComputeFragmentOffsetOnLine( box_fragment_.Style().Direction(), &offset_on_line, &total_width); LayoutSize line_offset(offset_on_line, LayoutUnit()); - local_offset -= box_fragment_.Style().IsHorizontalWritingMode() - ? line_offset - : line_offset.TransposedSize(); + local_offset -= + PhysicalOffset(box_fragment_.Style().IsHorizontalWritingMode() + ? line_offset + : line_offset.TransposedSize()); } inline_box_painter.Paint(paint_info, paint_offset - local_offset); } else { @@ -917,25 +922,26 @@ } } -LayoutRect NGBoxFragmentPainter::AdjustRectForScrolledContent( +PhysicalRect NGBoxFragmentPainter::AdjustRectForScrolledContent( const PaintInfo& paint_info, const BoxPainterBase::FillLayerInfo& info, - const LayoutRect& rect) { - LayoutRect scrolled_paint_rect = rect; + const PhysicalRect& rect) { + PhysicalRect scrolled_paint_rect = rect; GraphicsContext& context = paint_info.context; const NGPhysicalBoxFragment& physical = PhysicalFragment(); // Clip to the overflow area. if (info.is_clipped_with_local_scrolling && !IsPaintingScrollingBackground(box_fragment_, paint_info)) { - context.Clip(FloatRect(physical.OverflowClipRect(rect.Location()))); + context.Clip(FloatRect(physical.OverflowClipRect(rect.offset))); // Adjust the paint rect to reflect a scrolled content box with borders at // the ends. - IntSize offset = physical.ScrolledContentOffset(); + PhysicalOffset offset(physical.ScrolledContentOffset()); scrolled_paint_rect.Move(-offset); LayoutRectOutsets borders = AdjustedBorderOutsets(info); - scrolled_paint_rect.SetSize(physical.ScrollSize() + borders.Size()); + scrolled_paint_rect.size = + physical.ScrollSize() + PhysicalSize(borders.Size()); } return scrolled_paint_rect; } @@ -996,8 +1002,11 @@ // foreground rect for intersection if a layer is self painting, // so only do the overflow clip check here for non-self-painting layers. if (!box_fragment_.HasSelfPaintingLayer() && - !location_in_container.Intersects(PhysicalFragment().OverflowClipRect( - physical_offset, kExcludeOverlayScrollbarSizeForHitTesting))) { + !location_in_container.Intersects( + PhysicalFragment() + .OverflowClipRect(PhysicalOffsetToBeNoop(physical_offset), + kExcludeOverlayScrollbarSizeForHitTesting) + .ToLayoutRect())) { skip_children = true; } if (!skip_children && style.HasBorderRadius()) {
diff --git a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.h b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.h index 2f2f6d5e..946cc95 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.h +++ b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.h
@@ -21,7 +21,6 @@ class HitTestLocation; class HitTestRequest; class HitTestResult; -class LayoutRect; class NGPhysicalFragment; class ScopedPaintState; struct PaintInfo; @@ -36,7 +35,7 @@ void Paint(const PaintInfo&); void PaintObject(const PaintInfo&, - const LayoutPoint&, + const PhysicalOffset&, bool suppress_box_decoration_background = false); // Hit tests this box fragment. @@ -57,20 +56,21 @@ void PaintTextClipMask(GraphicsContext&, const IntRect& mask_rect, - const LayoutPoint& paint_offset, + const PhysicalOffset& paint_offset, bool object_has_multiple_boxes) override; - LayoutRect AdjustRectForScrolledContent(const PaintInfo&, - const BoxPainterBase::FillLayerInfo&, - const LayoutRect&) override; + PhysicalRect AdjustRectForScrolledContent( + const PaintInfo&, + const BoxPainterBase::FillLayerInfo&, + const PhysicalRect&) override; private: bool IsPaintingScrollingBackground(const NGPaintFragment&, const PaintInfo&); bool ShouldPaint(const ScopedPaintState&) const; void PaintBoxDecorationBackground(const PaintInfo&, - const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); void PaintBoxDecorationBackgroundWithRect(const PaintInfo&, - const LayoutRect&); + const PhysicalRect&); bool BackgroundIsKnownToBeOpaque(const PaintInfo&); void PaintInternal(const PaintInfo&); @@ -78,29 +78,29 @@ void PaintBlockChildren(const PaintInfo&); void PaintLineBoxChildren(NGPaintFragment::ChildList, const PaintInfo&, - const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); void PaintInlineChildren(NGPaintFragment::ChildList, const PaintInfo&, - const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); void PaintInlineChildBoxUsingLegacyFallback(const NGPhysicalFragment&, const PaintInfo&); void PaintBlockFlowContents(const PaintInfo&, - const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); void PaintAtomicInlineChild(const NGPaintFragment&, const PaintInfo&); void PaintTextChild(const NGPaintFragment&, const PaintInfo&, - const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); void PaintFloatingChildren(NGPaintFragment::ChildList, const PaintInfo&); void PaintFloats(const PaintInfo&); - void PaintMask(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintMask(const PaintInfo&, const PhysicalOffset& paint_offset); void PaintOverflowControlsIfNeeded(const PaintInfo&, - const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); void PaintAtomicInline(const PaintInfo&); void PaintBackground(const PaintInfo&, - const LayoutRect&, + const PhysicalRect&, const Color& background_color, BackgroundBleedAvoidance = kBackgroundBleedNone); - void PaintCarets(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintCarets(const PaintInfo&, const PhysicalOffset& paint_offset); void RecordHitTestData(const PaintInfo& paint_info, const LayoutPoint& paint_offset);
diff --git a/third_party/blink/renderer/core/paint/ng/ng_fieldset_painter.cc b/third_party/blink/renderer/core/paint/ng/ng_fieldset_painter.cc index 157a58a..63089714 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_fieldset_painter.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_fieldset_painter.cc
@@ -21,7 +21,7 @@ void NGFieldsetPainter::PaintBoxDecorationBackground( const PaintInfo& paint_info, - const LayoutPoint paint_offset) { + const PhysicalOffset& paint_offset) { const NGPaintFragment* legend = nullptr; if (!fieldset_.Children().IsEmpty()) { const auto& first_child = fieldset_.Children().front(); @@ -42,9 +42,9 @@ void NGFieldsetPainter::PaintFieldsetDecorationBackground( const NGPaintFragment* legend, const PaintInfo& paint_info, - const LayoutPoint paint_offset) { - LayoutSize fieldset_size(fieldset_.Size().ToLayoutSize()); - LayoutRect paint_rect(paint_offset, fieldset_size); + const PhysicalOffset& paint_offset) { + PhysicalSize fieldset_size(fieldset_.Size()); + PhysicalRect paint_rect(paint_offset, fieldset_size); const auto& fragment = To<NGPhysicalBoxFragment>(fieldset_.PhysicalFragment()); BoxDecorationData box_decoration_data(paint_info, fragment); @@ -57,14 +57,14 @@ LayoutRectOutsets fieldset_borders = fragment.Borders().ToLayoutRectOutsets(); const ComputedStyle& style = fieldset_.Style(); - LayoutRect legend_border_box; + PhysicalRect legend_border_box; if (legend) { - legend_border_box.SetLocation(legend->Offset().ToLayoutPoint()); - legend_border_box.SetSize(legend->Size().ToLayoutSize()); + legend_border_box.offset = legend->Offset(); + legend_border_box.size = legend->Size(); } FieldsetPaintInfo fieldset_paint_info(style, fieldset_size, fieldset_borders, legend_border_box); - LayoutRect contracted_rect(paint_rect); + PhysicalRect contracted_rect(paint_rect); contracted_rect.Contract(fieldset_paint_info.border_outsets); DrawingRecorder recorder(paint_info.context, fieldset_, paint_info.phase); @@ -91,8 +91,8 @@ GraphicsContext& graphics_context = paint_info.context; GraphicsContextStateSaver state_saver(graphics_context); - LayoutRect legend_cutout_rect = fieldset_paint_info.legend_cutout_rect; - legend_cutout_rect.MoveBy(paint_rect.Location()); + PhysicalRect legend_cutout_rect = fieldset_paint_info.legend_cutout_rect; + legend_cutout_rect.Move(paint_rect.offset); graphics_context.ClipOut(PixelSnappedIntRect(legend_cutout_rect)); LayoutObject* layout_object = fieldset_.GetLayoutObject();
diff --git a/third_party/blink/renderer/core/paint/ng/ng_fieldset_painter.h b/third_party/blink/renderer/core/paint/ng/ng_fieldset_painter.h index 09540ac..b81aaf46 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_fieldset_painter.h +++ b/third_party/blink/renderer/core/paint/ng/ng_fieldset_painter.h
@@ -5,13 +5,13 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_NG_NG_FIELDSET_PAINTER_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_NG_NG_FIELDSET_PAINTER_H_ -#include "third_party/blink/renderer/platform/geometry/layout_point.h" #include "third_party/blink/renderer/platform/wtf/allocator.h" namespace blink { class NGPaintFragment; struct PaintInfo; +struct PhysicalOffset; class NGFieldsetPainter { STACK_ALLOCATED(); @@ -19,12 +19,12 @@ public: NGFieldsetPainter(const NGPaintFragment& fieldset) : fieldset_(fieldset) {} - void PaintBoxDecorationBackground(const PaintInfo&, const LayoutPoint); + void PaintBoxDecorationBackground(const PaintInfo&, const PhysicalOffset&); private: void PaintFieldsetDecorationBackground(const NGPaintFragment* legend, const PaintInfo&, - const LayoutPoint); + const PhysicalOffset&); void PaintLegend(const NGPaintFragment& legend, const PaintInfo&); const NGPaintFragment& fieldset_;
diff --git a/third_party/blink/renderer/core/paint/ng/ng_fragment_painter.cc b/third_party/blink/renderer/core/paint/ng/ng_fragment_painter.cc index ff0dfeaa..2e8ab758 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_fragment_painter.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_fragment_painter.cc
@@ -16,15 +16,15 @@ namespace blink { void NGFragmentPainter::PaintOutline(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { DCHECK(ShouldPaintSelfOutline(paint_info.phase)); if (!NGOutlineUtils::HasPaintedOutline(paint_fragment_.Style(), paint_fragment_.GetNode())) return; - Vector<LayoutRect> outline_rects; - paint_fragment_.AddSelfOutlineRect( + Vector<PhysicalRect> outline_rects; + paint_fragment_.AddSelfOutlineRects( &outline_rects, paint_offset, paint_fragment_.GetLayoutObject() ->OutlineRectsShouldIncludeBlockVisualOverflow()); @@ -40,8 +40,9 @@ PaintOutlineRects(paint_info, outline_rects, paint_fragment_.Style()); } -void NGFragmentPainter::AddPDFURLRectIfNeeded(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { +void NGFragmentPainter::AddPDFURLRectIfNeeded( + const PaintInfo& paint_info, + const PhysicalOffset& paint_offset) { DCHECK(paint_info.IsPrinting()); // TODO(layout-dev): Should use break token when NG has its own tree building.
diff --git a/third_party/blink/renderer/core/paint/ng/ng_fragment_painter.h b/third_party/blink/renderer/core/paint/ng/ng_fragment_painter.h index de46ce7..732350c 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_fragment_painter.h +++ b/third_party/blink/renderer/core/paint/ng/ng_fragment_painter.h
@@ -10,10 +10,10 @@ namespace blink { -class LayoutPoint; class NGPaintFragment; class NGPhysicalFragment; struct PaintInfo; +struct PhysicalOffset; // Generic fragment painter for paint logic shared between all types of // fragments. LayoutNG version of ObjectPainter, based on ObjectPainterBase. @@ -24,9 +24,10 @@ NGFragmentPainter(const NGPaintFragment& paint_fragment) : paint_fragment_(paint_fragment) {} - void PaintOutline(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintOutline(const PaintInfo&, const PhysicalOffset& paint_offset); - void AddPDFURLRectIfNeeded(const PaintInfo&, const LayoutPoint& paint_offset); + void AddPDFURLRectIfNeeded(const PaintInfo&, + const PhysicalOffset& paint_offset); static bool ShouldRecordHitTestData(const PaintInfo&, const NGPhysicalFragment&);
diff --git a/third_party/blink/renderer/core/paint/ng/ng_inline_box_fragment_painter.cc b/third_party/blink/renderer/core/paint/ng/ng_inline_box_fragment_painter.cc index 7320fdc..739b8e01 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_inline_box_fragment_painter.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_inline_box_fragment_painter.cc
@@ -19,41 +19,18 @@ namespace blink { -NGInlineBoxFragmentPainter::NGInlineBoxFragmentPainter( - const NGPaintFragment& inline_box_fragment, - const LayoutObject& layout_object, - const ComputedStyle& style, - const ComputedStyle& line_style) - : InlineBoxPainterBase(layout_object, - &layout_object.GetDocument(), - layout_object.GeneratingNode(), - style, - line_style), - inline_box_fragment_(inline_box_fragment), - border_edges_(NGBorderEdges::FromPhysical( - static_cast<const NGPhysicalBoxFragment&>( - inline_box_fragment.PhysicalFragment()) - .BorderEdges(), - style.GetWritingMode())) { - DCHECK_EQ(inline_box_fragment.PhysicalFragment().Type(), - NGPhysicalFragment::NGFragmentType::kFragmentBox); - DCHECK_EQ(inline_box_fragment.PhysicalFragment().BoxType(), - NGPhysicalFragment::NGBoxType::kInlineBox); +const NGBorderEdges NGInlineBoxFragmentPainter::BorderEdges() const { + if (border_edges_.has_value()) + return *border_edges_; + border_edges_ = NGBorderEdges::FromPhysical(PhysicalFragment().BorderEdges(), + style_.GetWritingMode()); + return *border_edges_; } -NGInlineBoxFragmentPainter::NGInlineBoxFragmentPainter( - const NGPaintFragment& inline_box_fragment) - : NGInlineBoxFragmentPainter( - inline_box_fragment, - *inline_box_fragment.GetLayoutObject(), - inline_box_fragment.Style(), - // TODO(layout-dev): Should be first-line style. - inline_box_fragment.Style()) {} - void NGInlineBoxFragmentPainter::Paint(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { - const LayoutPoint adjusted_paint_offset = - paint_offset + inline_box_fragment_.Offset().ToLayoutPoint(); + const PhysicalOffset& paint_offset) { + const PhysicalOffset adjusted_paint_offset = + paint_offset + inline_box_fragment_.Offset(); if (paint_info.phase == PaintPhase::kForeground) PaintBackgroundBorderShadow(paint_info, adjusted_paint_offset); @@ -63,9 +40,9 @@ suppress_box_decoration_background); } -void NGInlineBoxFragmentPainter::PaintBackgroundBorderShadow( +void NGInlineBoxFragmentPainterBase::PaintBackgroundBorderShadow( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { DCHECK(paint_info.phase == PaintPhase::kForeground); if (inline_box_fragment_.Style().Visibility() != EVisibility::kVisible) return; @@ -89,12 +66,10 @@ DrawingRecorder recorder(paint_info.context, inline_box_fragment_, DisplayItem::kBoxDecorationBackground); - LayoutRect frame_rect = - inline_box_fragment_.PhysicalFragment().LocalRect().ToLayoutRect(); - LayoutPoint adjusted_paint_offset = paint_offset; + PhysicalRect frame_rect = inline_box_fragment_.PhysicalFragment().LocalRect(); + PhysicalOffset adjusted_paint_offset = paint_offset; - LayoutRect adjusted_frame_rect = - LayoutRect(adjusted_paint_offset, frame_rect.Size()); + PhysicalRect adjusted_frame_rect(adjusted_paint_offset, frame_rect.size); NGPaintFragment::FragmentRange fragments = inline_box_fragment_.InlineFragmentsFor( @@ -108,13 +83,65 @@ BackgroundImageGeometry geometry(*static_cast<const LayoutBoxModelObject*>( inline_box_fragment_.GetLayoutObject())); NGBoxFragmentPainter box_painter(inline_box_fragment_); - PaintBoxDecorationBackground( - box_painter, paint_info, paint_offset, adjusted_frame_rect, geometry, - object_has_multiple_boxes, border_edges_.line_left, - border_edges_.line_right); + const NGBorderEdges& border_edges = BorderEdges(); + PaintBoxDecorationBackground(box_painter, paint_info, paint_offset, + adjusted_frame_rect, geometry, + object_has_multiple_boxes, + border_edges.line_left, border_edges.line_right); } -void NGInlineBoxFragmentPainter::ComputeFragmentOffsetOnLine( +void NGLineBoxFragmentPainter::PaintBackgroundBorderShadow( + const PaintInfo& paint_info, + const PhysicalOffset& paint_offset) { + DCHECK_EQ(paint_info.phase, PaintPhase::kForeground); + DCHECK_EQ(inline_box_fragment_.PhysicalFragment().Type(), + NGPhysicalFragment::kFragmentLineBox); + DCHECK(NeedsPaint(inline_box_fragment_.PhysicalFragment())); + + if (line_style_ == style_ || + line_style_.Visibility() != EVisibility::kVisible) + return; + + if (DrawingRecorder::UseCachedDrawingIfPossible( + paint_info.context, inline_box_fragment_, + DisplayItem::kBoxDecorationBackground)) + return; + + DrawingRecorder recorder(paint_info.context, inline_box_fragment_, + DisplayItem::kBoxDecorationBackground); + + // Compute the content box for the `::first-line` box. It's different from + // fragment size because the height of line box includes `line-height` while + // the height of inline box does not. The box "behaves similar to that of an + // inline-level element". + // https://drafts.csswg.org/css-pseudo-4/#first-line-styling + const NGPhysicalLineBoxFragment& line_box = PhysicalFragment(); + const NGLineHeightMetrics line_metrics = line_box.Metrics(); + const NGLineHeightMetrics text_metrics = NGLineHeightMetrics(line_style_); + const WritingMode writing_mode = line_style_.GetWritingMode(); + PhysicalRect rect; + if (IsHorizontalWritingMode(writing_mode)) { + rect.offset.top = line_metrics.ascent - text_metrics.ascent; + rect.size = {line_box.Size().width, text_metrics.LineHeight()}; + } else { + rect.offset.left = + line_box.Size().width - line_metrics.ascent - text_metrics.descent; + rect.size = {text_metrics.LineHeight(), line_box.Size().height}; + } + rect.offset += paint_offset; + + const NGPhysicalFragment& block_fragment = block_fragment_.PhysicalFragment(); + const LayoutBlockFlow& layout_block_flow = + *To<LayoutBlockFlow>(block_fragment.GetLayoutObject()); + BackgroundImageGeometry geometry(layout_block_flow); + NGBoxFragmentPainter box_painter(block_fragment_); + PaintBoxDecorationBackground( + box_painter, paint_info, paint_offset, rect, geometry, + /*object_has_multiple_boxes*/ false, /*include_logical_left_edge*/ true, + /*include_logical_right_edge*/ true); +} + +void NGInlineBoxFragmentPainterBase::ComputeFragmentOffsetOnLine( TextDirection direction, LayoutUnit* offset_on_line, LayoutUnit* total_width) const { @@ -146,8 +173,8 @@ *offset_on_line = direction == TextDirection::kLtr ? before : after; } -LayoutRect NGInlineBoxFragmentPainter::PaintRectForImageStrip( - const LayoutRect& paint_rect, +PhysicalRect NGInlineBoxFragmentPainterBase::PaintRectForImageStrip( + const PhysicalRect& paint_rect, TextDirection direction) const { // We have a fill/border/mask image that spans multiple lines. // We need to adjust the offset by the width of all previous lines. @@ -161,19 +188,19 @@ ComputeFragmentOffsetOnLine(direction, &offset_on_line, &total_width); if (inline_box_fragment_.Style().IsHorizontalWritingMode()) { - return LayoutRect(paint_rect.X() - offset_on_line, paint_rect.Y(), - total_width, paint_rect.Height()); + return PhysicalRect(paint_rect.X() - offset_on_line, paint_rect.Y(), + total_width, paint_rect.Height()); } - return LayoutRect(paint_rect.X(), paint_rect.Y() - offset_on_line, - paint_rect.Width(), total_width); + return PhysicalRect(paint_rect.X(), paint_rect.Y() - offset_on_line, + paint_rect.Width(), total_width); } -static LayoutRect NGClipRectForNinePieceImageStrip( +static PhysicalRect NGClipRectForNinePieceImageStrip( const ComputedStyle& style, const NGBorderEdges& border_edges, const NinePieceImage& image, - const LayoutRect& paint_rect) { - LayoutRect clip_rect(paint_rect); + const PhysicalRect& paint_rect) { + PhysicalRect clip_rect(paint_rect); LayoutRectOutsets outsets = style.ImageOutsets(image); if (style.IsHorizontalWritingMode()) { clip_rect.SetY(paint_rect.Y() - outsets.Top()); @@ -198,8 +225,8 @@ } InlineBoxPainterBase::BorderPaintingType -NGInlineBoxFragmentPainter::GetBorderPaintType( - const LayoutRect& adjusted_frame_rect, +NGInlineBoxFragmentPainterBase::GetBorderPaintType( + const PhysicalRect& adjusted_frame_rect, IntRect& adjusted_clip_rect, bool object_has_multiple_boxes) const { adjusted_clip_rect = PixelSnappedIntRect(adjusted_frame_rect); @@ -221,27 +248,29 @@ // We have a border image that spans multiple lines. adjusted_clip_rect = PixelSnappedIntRect(NGClipRectForNinePieceImageStrip( - inline_box_fragment_.Style(), border_edges_, border_image, + inline_box_fragment_.Style(), BorderEdges(), border_image, adjusted_frame_rect)); return kPaintBordersWithClip; } return kDontPaintBorders; } -void NGInlineBoxFragmentPainter::PaintNormalBoxShadow( +void NGInlineBoxFragmentPainterBase::PaintNormalBoxShadow( const PaintInfo& info, const ComputedStyle& s, - const LayoutRect& paint_rect) { + const PhysicalRect& paint_rect) { + const NGBorderEdges& border_edges = BorderEdges(); BoxPainterBase::PaintNormalBoxShadow( - info, paint_rect, s, border_edges_.line_left, border_edges_.line_right); + info, paint_rect, s, border_edges.line_left, border_edges.line_right); } -void NGInlineBoxFragmentPainter::PaintInsetBoxShadow( +void NGInlineBoxFragmentPainterBase::PaintInsetBoxShadow( const PaintInfo& info, const ComputedStyle& s, - const LayoutRect& paint_rect) { + const PhysicalRect& paint_rect) { + const NGBorderEdges& border_edges = BorderEdges(); BoxPainterBase::PaintInsetBoxShadowWithBorderRect( - info, paint_rect, s, border_edges_.line_left, border_edges_.line_right); + info, paint_rect, s, border_edges.line_left, border_edges.line_right); } } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/ng/ng_inline_box_fragment_painter.h b/third_party/blink/renderer/core/paint/ng/ng_inline_box_fragment_painter.h index f08bd538..235d8a9 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_inline_box_fragment_painter.h +++ b/third_party/blink/renderer/core/paint/ng/ng_inline_box_fragment_painter.h
@@ -6,55 +6,143 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_NG_NG_INLINE_BOX_FRAGMENT_PAINTER_H_ #include "third_party/blink/renderer/core/layout/ng/geometry/ng_border_edges.h" +#include "third_party/blink/renderer/core/layout/ng/inline/ng_physical_line_box_fragment.h" #include "third_party/blink/renderer/core/paint/inline_box_painter_base.h" #include "third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.h" #include "third_party/blink/renderer/platform/wtf/allocator.h" namespace blink { -class LayoutRect; class NGPaintFragment; struct PaintInfo; +struct PhysicalRect; -// Painter for LayoutNG inline box fragments. Delegates to NGBoxFragmentPainter -// for all box painting logic that isn't specific to inline boxes. -class NGInlineBoxFragmentPainter : public InlineBoxPainterBase { +// Common base class for NGInlineBoxFragmentPainter and +// NGLineBoxFragmentPainter. +class NGInlineBoxFragmentPainterBase : public InlineBoxPainterBase { STACK_ALLOCATED(); public: - NGInlineBoxFragmentPainter(const NGPaintFragment&); - - void Paint(const PaintInfo&, const LayoutPoint& paint_offset); void ComputeFragmentOffsetOnLine(TextDirection, LayoutUnit* offset_on_line, LayoutUnit* total_width) const; protected: - LayoutRect PaintRectForImageStrip(const LayoutRect&, - TextDirection direction) const override; + NGInlineBoxFragmentPainterBase(const NGPaintFragment& inline_box_fragment, + const LayoutObject& layout_object, + const ComputedStyle& style, + const ComputedStyle& line_style) + : InlineBoxPainterBase(layout_object, + &layout_object.GetDocument(), + layout_object.GeneratingNode(), + style, + line_style), + inline_box_fragment_(inline_box_fragment) {} + + const virtual NGBorderEdges BorderEdges() const = 0; + + PhysicalRect PaintRectForImageStrip(const PhysicalRect&, + TextDirection direction) const override; BorderPaintingType GetBorderPaintType( - const LayoutRect& adjusted_frame_rect, + const PhysicalRect& adjusted_frame_rect, IntRect& adjusted_clip_rect, bool object_has_multiple_boxes) const override; void PaintNormalBoxShadow(const PaintInfo&, const ComputedStyle&, - const LayoutRect& paint_rect) override; + const PhysicalRect& paint_rect) override; void PaintInsetBoxShadow(const PaintInfo&, const ComputedStyle&, - const LayoutRect& paint_rect) override; - - private: - NGInlineBoxFragmentPainter(const NGPaintFragment& inline_box_fragment, - const LayoutObject& layout_object, - const ComputedStyle& style, - const ComputedStyle& line_style); + const PhysicalRect& paint_rect) override; void PaintBackgroundBorderShadow(const PaintInfo&, - const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); const NGPaintFragment& inline_box_fragment_; - NGBorderEdges border_edges_; +}; + +// Painter for LayoutNG inline box fragments. Delegates to NGBoxFragmentPainter +// for all box painting logic that isn't specific to inline boxes. +class NGInlineBoxFragmentPainter : public NGInlineBoxFragmentPainterBase { + STACK_ALLOCATED(); + + public: + NGInlineBoxFragmentPainter(const NGPaintFragment& inline_box_fragment) + : NGInlineBoxFragmentPainterBase(inline_box_fragment, + *inline_box_fragment.GetLayoutObject(), + inline_box_fragment.Style(), + inline_box_fragment.Style()) { + DCHECK_EQ(inline_box_fragment.PhysicalFragment().Type(), + NGPhysicalFragment::NGFragmentType::kFragmentBox); + DCHECK_EQ(inline_box_fragment.PhysicalFragment().BoxType(), + NGPhysicalFragment::NGBoxType::kInlineBox); + } + + void Paint(const PaintInfo&, const PhysicalOffset& paint_offset); + + private: + const NGPhysicalBoxFragment& PhysicalFragment() const { + return static_cast<const NGPhysicalBoxFragment&>( + inline_box_fragment_.PhysicalFragment()); + } + + const NGBorderEdges BorderEdges() const final; + + mutable base::Optional<NGBorderEdges> border_edges_; +}; + +// Painter for LayoutNG line box fragments. Line boxes don't paint anything, +// except when ::first-line style has background properties specified. +// https://drafts.csswg.org/css-pseudo-4/#first-line-styling +class NGLineBoxFragmentPainter : public NGInlineBoxFragmentPainterBase { + STACK_ALLOCATED(); + + public: + NGLineBoxFragmentPainter(const NGPaintFragment& line, + const NGPaintFragment& block) + : NGLineBoxFragmentPainter(line, block, *block.GetLayoutObject()) {} + + static bool NeedsPaint(const NGPhysicalFragment& line_fragment) { + DCHECK_EQ(line_fragment.Type(), + NGPhysicalFragment::NGFragmentType::kFragmentLineBox); + return line_fragment.UsesFirstLineStyle(); + } + + // Borders are not part of ::first-line style and therefore not painted, but + // the function name is kept consistent with other classes. + void PaintBackgroundBorderShadow(const PaintInfo&, + const PhysicalOffset& paint_offset); + + private: + NGLineBoxFragmentPainter(const NGPaintFragment& line, + const NGPaintFragment& block, + const LayoutObject& layout_block_flow) + : NGInlineBoxFragmentPainterBase( + line, + layout_block_flow, + // Use the style from the containing block. |line_fragment.Style()| + // is a copy at the time of the last layout to reflect the line + // direction, and its paint properties may have been changed. + // TODO(kojii): Reconsider |line_fragment.Style()|. + layout_block_flow.StyleRef(), + layout_block_flow.FirstLineStyleRef()), + block_fragment_(block) { + DCHECK_EQ(line.PhysicalFragment().Type(), + NGPhysicalFragment::NGFragmentType::kFragmentLineBox); + DCHECK(NeedsPaint(line.PhysicalFragment())); + DCHECK_EQ(block.PhysicalFragment().Type(), + NGPhysicalFragment::NGFragmentType::kFragmentBox); + DCHECK(layout_block_flow.IsLayoutNGMixin()); + } + + const NGPhysicalLineBoxFragment& PhysicalFragment() const { + return static_cast<const NGPhysicalLineBoxFragment&>( + inline_box_fragment_.PhysicalFragment()); + } + + const NGBorderEdges BorderEdges() const final { return NGBorderEdges(); } + + const NGPaintFragment& block_fragment_; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.cc b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.cc index 4382c75..ed51cacfd 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.cc
@@ -684,9 +684,10 @@ return visual_rect; } -void NGPaintFragment::AddSelfOutlineRect(Vector<LayoutRect>* outline_rects, - const LayoutPoint& additional_offset, - NGOutlineType outline_type) const { +void NGPaintFragment::AddSelfOutlineRects( + Vector<PhysicalRect>* outline_rects, + const PhysicalOffset& additional_offset, + NGOutlineType outline_type) const { DCHECK(outline_rects); const NGPhysicalFragment& fragment = PhysicalFragment(); if (auto* box_fragment = DynamicTo<NGPhysicalBoxFragment>(fragment)) { @@ -823,8 +824,10 @@ DCHECK(PhysicalFragment().IsBox() && GetLayoutObject() && GetLayoutObject()->IsLayoutBlockFlow()); - if (NGPaintFragment* line_box = FirstLineBox()) + if (NGPaintFragment* line_box = FirstLineBox()) { line_box->SetShouldDoFullPaintInvalidationRecursively(); + GetLayoutObject()->SetShouldDoFullPaintInvalidation(); + } } PhysicalRect NGPaintFragment::ComputeLocalSelectionRectForText(
diff --git a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h index 3cb5780c..d71b3d1 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h +++ b/third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h
@@ -159,9 +159,9 @@ void RecalcInlineChildrenInkOverflow(); - void AddSelfOutlineRect(Vector<LayoutRect>*, - const LayoutPoint& offset, - NGOutlineType) const; + void AddSelfOutlineRects(Vector<PhysicalRect>*, + const PhysicalOffset& offset, + NGOutlineType) const; // TODO(layout-dev): Implement when we have oveflow support. // TODO(eae): Switch to using NG geometry types.
diff --git a/third_party/blink/renderer/core/paint/ng/ng_text_fragment_painter.cc b/third_party/blink/renderer/core/paint/ng/ng_text_fragment_painter.cc index c1178919..9270910 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_text_fragment_painter.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_text_fragment_painter.cc
@@ -109,9 +109,10 @@ context.FillRect(FloatRect(global_rect), color); } -LayoutRect MarkerRectForForeground(const NGPhysicalTextFragment& text_fragment, - unsigned start_offset, - unsigned end_offset) { +PhysicalRect MarkerRectForForeground( + const NGPhysicalTextFragment& text_fragment, + unsigned start_offset, + unsigned end_offset) { LayoutUnit start_position, end_position; std::tie(start_position, end_position) = text_fragment.LineLeftAndRightForOffsets(start_offset, end_offset); @@ -127,7 +128,7 @@ void PaintDocumentMarkers(GraphicsContext& context, const NGPaintFragment& paint_fragment, const DocumentMarkerVector& markers_to_paint, - const LayoutPoint& box_origin, + const PhysicalOffset& box_origin, const ComputedStyle& style, DocumentMarkerPaintPhase marker_paint_phase, NGTextPainter* text_painter) { @@ -234,7 +235,7 @@ const Document& document, const ComputedStyle& style, Color text_color, - const LayoutRect& box_rect, + const PhysicalRect& box_rect, const LayoutSelectionStatus& selection_status) { const auto& text_fragment = To<NGPhysicalTextFragment>(paint_fragment.PhysicalFragment()); @@ -242,17 +243,16 @@ SelectionBackgroundColor(document, style, text_fragment, text_color); const PhysicalRect selection_rect = paint_fragment.ComputeLocalSelectionRectForText(selection_status); - PaintRect(context, PhysicalOffset(box_rect.Location()), selection_rect, - color); + PaintRect(context, box_rect.offset, selection_rect, color); } void NGTextFragmentPainter::PaintSymbol(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { const ComputedStyle& style = fragment_.Style(); - LayoutRect marker_rect = - LayoutListMarker::RelativeSymbolMarkerRect(style, fragment_.Size().width); - marker_rect.MoveBy(fragment_.Offset().ToLayoutPoint()); - marker_rect.MoveBy(paint_offset); + PhysicalRect marker_rect(LayoutListMarker::RelativeSymbolMarkerRect( + style, fragment_.Size().width)); + marker_rect.Move(fragment_.Offset()); + marker_rect.Move(paint_offset); IntRect rect = PixelSnappedIntRect(marker_rect); ListMarkerPainter::PaintSymbol(paint_info, fragment_.GetLayoutObject(), style, @@ -262,7 +262,7 @@ // This is copied from InlineTextBoxPainter::PaintSelection() but lacks of // ltr, expanding new line wrap or so which uses InlineTextBox functions. void NGTextFragmentPainter::Paint(const PaintInfo& paint_info, - const LayoutPoint& paint_offset, + const PhysicalOffset& paint_offset, const NodeHolder& node_holder) { const auto& text_fragment = To<NGPhysicalTextFragment>(fragment_.PhysicalFragment()); @@ -323,12 +323,11 @@ } // We round the y-axis to ensure consistent line heights. - LayoutPoint adjusted_paint_offset = - LayoutPoint(paint_offset.X(), LayoutUnit(paint_offset.Y().Round())); + PhysicalOffset adjusted_paint_offset(paint_offset.left, + LayoutUnit(paint_offset.top.Round())); - PhysicalOffset offset = fragment_.Offset(); - LayoutPoint box_origin(offset.left, offset.top); - box_origin.Move(adjusted_paint_offset.X(), adjusted_paint_offset.Y()); + PhysicalOffset box_origin = fragment_.Offset(); + box_origin += adjusted_paint_offset; GraphicsContext& context = paint_info.context; @@ -347,7 +346,7 @@ const SimpleFontData* font_data = font.PrimaryFont(); DCHECK(font_data); - LayoutRect box_rect(box_origin, fragment_.Size().ToLayoutSize()); + PhysicalRect box_rect(box_origin, fragment_.Size()); base::Optional<GraphicsContextStateSaver> state_saver; // 1. Paint backgrounds behind text if needed. Examples of such backgrounds @@ -374,10 +373,10 @@ const NGLineOrientation orientation = text_fragment.LineOrientation(); if (orientation != NGLineOrientation::kHorizontal) { state_saver.emplace(context); - // Because we rotate the GraphicsContext to be logical, flip the - // |box_rect| to match to it. - box_rect.SetSize( - LayoutSize(fragment_.Size().height, fragment_.Size().width)); + // Because we rotate the GraphicsContext to match the logical direction, + // transpose the |box_rect| to match to it. + box_rect.size = + PhysicalSize(fragment_.Size().height, fragment_.Size().width); context.ConcatCTM(TextPainterBase::Rotation( box_rect, orientation == NGLineOrientation::kClockWiseVertical ? TextPainterBase::kClockwise @@ -386,7 +385,7 @@ // 2. Now paint the foreground, including text and decorations. int ascent = font_data ? font_data->GetFontMetrics().Ascent() : 0; - LayoutPoint text_origin(box_origin.X(), box_origin.Y() + ascent); + PhysicalOffset text_origin(box_origin.left, box_origin.top + ascent); NGTextPainter text_painter(context, font, text_fragment, text_origin, box_rect, text_fragment.IsHorizontal()); @@ -404,7 +403,7 @@ // Ellipsis should not have text decorations. This is not defined, but 4 // impls do this. !text_fragment.IsEllipsis()) { - LayoutPoint local_origin = LayoutPoint(box_origin); + PhysicalOffset local_origin = box_origin; LayoutUnit width = box_rect.Width(); const NGPhysicalBoxFragment* decorating_box = nullptr; const ComputedStyle* decorating_box_style =
diff --git a/third_party/blink/renderer/core/paint/ng/ng_text_fragment_painter.h b/third_party/blink/renderer/core/paint/ng/ng_text_fragment_painter.h index e16c60427..77d1c19c 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_text_fragment_painter.h +++ b/third_party/blink/renderer/core/paint/ng/ng_text_fragment_painter.h
@@ -12,9 +12,9 @@ namespace blink { -class LayoutPoint; class NGPaintFragment; struct PaintInfo; +struct PhysicalOffset; // Text fragment painter for LayoutNG. Operates on NGPhysicalTextFragments and // handles clipping, selection, etc. Delegates to NGTextPainter to paint the @@ -26,12 +26,12 @@ explicit NGTextFragmentPainter(const NGPaintFragment&); void Paint(const PaintInfo&, - const LayoutPoint& paint_offset, + const PhysicalOffset& paint_offset, const NodeHolder& node_holder); private: void PaintSymbol(const PaintInfo& paint_info, - const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); const NGPaintFragment& fragment_; };
diff --git a/third_party/blink/renderer/core/paint/ng/ng_text_painter.h b/third_party/blink/renderer/core/paint/ng/ng_text_painter.h index c785c580..a98af6a 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_text_painter.h +++ b/third_party/blink/renderer/core/paint/ng/ng_text_painter.h
@@ -26,8 +26,8 @@ NGTextPainter(GraphicsContext& context, const Font& font, const NGPhysicalTextFragment& text_fragment, - const LayoutPoint& text_origin, - const LayoutRect& text_bounds, + const PhysicalOffset& text_origin, + const PhysicalRect& text_bounds, bool horizontal) : TextPainterBase(context, font, text_origin, text_bounds, horizontal), fragment_(text_fragment) {}
diff --git a/third_party/blink/renderer/core/paint/nine_piece_image_painter.cc b/third_party/blink/renderer/core/paint/nine_piece_image_painter.cc index 0e2acf21..3d26d5c 100644 --- a/third_party/blink/renderer/core/paint/nine_piece_image_painter.cc +++ b/third_party/blink/renderer/core/paint/nine_piece_image_painter.cc
@@ -5,11 +5,11 @@ #include "third_party/blink/renderer/core/paint/nine_piece_image_painter.h" #include "third_party/blink/renderer/core/inspector/inspector_trace_events.h" +#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" #include "third_party/blink/renderer/core/paint/nine_piece_image_grid.h" #include "third_party/blink/renderer/core/style/computed_style.h" #include "third_party/blink/renderer/core/style/nine_piece_image.h" #include "third_party/blink/renderer/platform/geometry/int_size.h" -#include "third_party/blink/renderer/platform/geometry/layout_rect.h" #include "third_party/blink/renderer/platform/graphics/graphics_context.h" #include "third_party/blink/renderer/platform/graphics/scoped_interpolation_quality.h" @@ -76,7 +76,7 @@ } void PaintPieces(GraphicsContext& context, - const LayoutRect& border_image_rect, + const PhysicalRect& border_image_rect, const ComputedStyle& style, const NinePieceImage& nine_piece_image, Image* image, @@ -144,7 +144,7 @@ const ImageResourceObserver& observer, const Document& document, Node* node, - const LayoutRect& rect, + const PhysicalRect& rect, const ComputedStyle& style, const NinePieceImage& nine_piece_image, bool include_logical_left_edge, @@ -163,9 +163,9 @@ // FIXME: border-image is broken with full page zooming when tiling has to // happen, since the tiling function doesn't have any understanding of the // zoom that is in effect on the tile. - LayoutRect rect_with_outsets = rect; + PhysicalRect rect_with_outsets = rect; rect_with_outsets.Expand(style.ImageOutsets(nine_piece_image)); - LayoutRect border_image_rect = rect_with_outsets; + PhysicalRect border_image_rect = rect_with_outsets; // NinePieceImage returns the image slices without effective zoom applied and // thus we compute the nine piece grid on top of the image in unzoomed @@ -177,8 +177,8 @@ // is one. For generated images, the actual image data (gradient stops, etc.) // are scaled to effective zoom instead so we must take care not to cause // scale of them again. - IntSize image_size = RoundedIntSize( - style_image->ImageSize(document, 1, border_image_rect.Size())); + IntSize image_size = RoundedIntSize(style_image->ImageSize( + document, 1, border_image_rect.size.ToLayoutSize())); scoped_refptr<Image> image = style_image->GetImage(observer, document, style, FloatSize(image_size));
diff --git a/third_party/blink/renderer/core/paint/nine_piece_image_painter.h b/third_party/blink/renderer/core/paint/nine_piece_image_painter.h index 32e29b21..7426b30 100644 --- a/third_party/blink/renderer/core/paint/nine_piece_image_painter.h +++ b/third_party/blink/renderer/core/paint/nine_piece_image_painter.h
@@ -13,9 +13,9 @@ class GraphicsContext; class ImageResourceObserver; class Node; -class LayoutRect; class NinePieceImage; class Document; +struct PhysicalRect; class NinePieceImagePainter { STACK_ALLOCATED(); @@ -25,7 +25,7 @@ const ImageResourceObserver&, const Document&, Node*, - const LayoutRect&, + const PhysicalRect&, const ComputedStyle&, const NinePieceImage&, bool include_logical_left_edge = true,
diff --git a/third_party/blink/renderer/core/paint/object_paint_invalidator.cc b/third_party/blink/renderer/core/paint/object_paint_invalidator.cc index afb80e5..777fbb5 100644 --- a/third_party/blink/renderer/core/paint/object_paint_invalidator.cc +++ b/third_party/blink/renderer/core/paint/object_paint_invalidator.cc
@@ -334,8 +334,7 @@ if (IsFullPaintInvalidationReason(reason)) return reason; - auto local_rect = - PhysicalRectToBeNoop(object_.PartialInvalidationLocalRect()); + PhysicalRect local_rect = object_.PartialInvalidationLocalRect(); if (local_rect.IsEmpty()) return reason;
diff --git a/third_party/blink/renderer/core/paint/object_paint_invalidator_test.cc b/third_party/blink/renderer/core/paint/object_paint_invalidator_test.cc index b2f6b11e..6622d70 100644 --- a/third_party/blink/renderer/core/paint/object_paint_invalidator_test.cc +++ b/third_party/blink/renderer/core/paint/object_paint_invalidator_test.cc
@@ -280,24 +280,27 @@ GetDocument().View()->SetTracksPaintInvalidations(true); auto* target = GetLayoutObjectByElementId("target"); - target->InvalidatePaintRectangle(LayoutRect(10, 10, 50, 50)); - EXPECT_EQ(LayoutRect(10, 10, 50, 50), target->PartialInvalidationLocalRect()); - target->InvalidatePaintRectangle(LayoutRect(30, 30, 60, 60)); - EXPECT_EQ(LayoutRect(10, 10, 80, 80), target->PartialInvalidationLocalRect()); + target->InvalidatePaintRectangle(PhysicalRect(10, 10, 50, 50)); + EXPECT_EQ(PhysicalRect(10, 10, 50, 50), + target->PartialInvalidationLocalRect()); + target->InvalidatePaintRectangle(PhysicalRect(30, 30, 60, 60)); + EXPECT_EQ(PhysicalRect(10, 10, 80, 80), + target->PartialInvalidationLocalRect()); EXPECT_TRUE(target->ShouldCheckForPaintInvalidation()); GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint(); - EXPECT_EQ(LayoutRect(), target->PartialInvalidationLocalRect()); + EXPECT_EQ(PhysicalRect(), target->PartialInvalidationLocalRect()); EXPECT_EQ(IntRect(18, 18, 80, 80), target->PartialInvalidationVisualRect()); - target->InvalidatePaintRectangle(LayoutRect(30, 30, 50, 80)); - EXPECT_EQ(LayoutRect(30, 30, 50, 80), target->PartialInvalidationLocalRect()); + target->InvalidatePaintRectangle(PhysicalRect(30, 30, 50, 80)); + EXPECT_EQ(PhysicalRect(30, 30, 50, 80), + target->PartialInvalidationLocalRect()); GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint(); // PartialInvalidationVisualRect should accumulate until painting. EXPECT_EQ(IntRect(18, 18, 80, 100), target->PartialInvalidationVisualRect()); UpdateAllLifecyclePhasesForTest(); - EXPECT_EQ(LayoutRect(), target->PartialInvalidationLocalRect()); + EXPECT_EQ(PhysicalRect(), target->PartialInvalidationLocalRect()); EXPECT_EQ(IntRect(), target->PartialInvalidationVisualRect()); EXPECT_THAT(
diff --git a/third_party/blink/renderer/core/paint/object_painter.cc b/third_party/blink/renderer/core/paint/object_painter.cc index 112deedc..5e8436d 100644 --- a/third_party/blink/renderer/core/paint/object_painter.cc +++ b/third_party/blink/renderer/core/paint/object_painter.cc
@@ -19,7 +19,7 @@ namespace blink { void ObjectPainter::PaintOutline(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { DCHECK(ShouldPaintSelfOutline(paint_info.phase)); const ComputedStyle& style_to_use = layout_object_.StyleRef(); @@ -35,7 +35,7 @@ return; } - auto outline_rects = layout_object_.PhysicalOutlineRects( + auto outline_rects = layout_object_.OutlineRects( paint_offset, layout_object_.OutlineRectsShouldIncludeBlockVisualOverflow()); if (outline_rects.IsEmpty()) @@ -63,7 +63,7 @@ } void ObjectPainter::AddPDFURLRectIfNeeded(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { DCHECK(paint_info.IsPrinting()); if (layout_object_.IsElementContinuation() || !layout_object_.GetNode() || !layout_object_.GetNode()->IsLink() || @@ -74,7 +74,7 @@ if (!url.IsValid()) return; - auto outline_rects = layout_object_.PhysicalOutlineRects( + auto outline_rects = layout_object_.OutlineRects( paint_offset, NGOutlineType::kIncludeBlockVisualOverflow); IntRect rect = PixelSnappedIntRect(UnionRect(outline_rects)); if (rect.IsEmpty())
diff --git a/third_party/blink/renderer/core/paint/object_painter.h b/third_party/blink/renderer/core/paint/object_painter.h index 351c2e5a..7f05ee4 100644 --- a/third_party/blink/renderer/core/paint/object_painter.h +++ b/third_party/blink/renderer/core/paint/object_painter.h
@@ -12,9 +12,9 @@ namespace blink { -struct PaintInfo; class LayoutObject; -class LayoutPoint; +struct PaintInfo; +struct PhysicalOffset; class ObjectPainter : public ObjectPainterBase { STACK_ALLOCATED(); @@ -23,9 +23,10 @@ ObjectPainter(const LayoutObject& layout_object) : layout_object_(layout_object) {} - void PaintOutline(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintOutline(const PaintInfo&, const PhysicalOffset& paint_offset); void PaintInlineChildrenOutlines(const PaintInfo&); - void AddPDFURLRectIfNeeded(const PaintInfo&, const LayoutPoint& paint_offset); + void AddPDFURLRectIfNeeded(const PaintInfo&, + const PhysicalOffset& paint_offset); // Paints the object atomically as if it created a new stacking context, for: // - inline blocks, inline tables, inline-level replaced elements (Section
diff --git a/third_party/blink/renderer/core/paint/object_painter_base.cc b/third_party/blink/renderer/core/paint/object_painter_base.cc index 798fe7c6..8b91e11 100644 --- a/third_party/blink/renderer/core/paint/object_painter_base.cc +++ b/third_party/blink/renderer/core/paint/object_painter_base.cc
@@ -8,7 +8,6 @@ #include "third_party/blink/renderer/core/paint/paint_info.h" #include "third_party/blink/renderer/core/style/border_edge.h" #include "third_party/blink/renderer/core/style/computed_style.h" -#include "third_party/blink/renderer/platform/geometry/layout_point.h" #include "third_party/blink/renderer/platform/graphics/color.h" #include "third_party/blink/renderer/platform/graphics/graphics_context.h" #include "third_party/blink/renderer/platform/graphics/graphics_context_state_saver.h" @@ -189,10 +188,10 @@ const Color& color) { DCHECK(!style.OutlineStyleIsAuto()); - LayoutRect inner(rect); - inner.Inflate(style.OutlineOffset()); - LayoutRect outer(inner); - outer.Inflate(style.OutlineWidth()); + PhysicalRect inner(rect); + inner.Inflate(LayoutUnit(style.OutlineOffset())); + PhysicalRect outer(inner); + outer.Inflate(LayoutUnit(style.OutlineWidth())); const BorderEdge common_edge_info(style.OutlineWidth(), color, style.OutlineStyle()); BoxBorderPainter(style, outer, inner, common_edge_info) @@ -491,7 +490,7 @@ void ObjectPainterBase::PaintOutlineRects( const PaintInfo& paint_info, - const Vector<LayoutRect>& outline_rects, + const Vector<PhysicalRect>& outline_rects, const ComputedStyle& style) { Vector<IntRect> pixel_snapped_outline_rects; for (auto& r : outline_rects)
diff --git a/third_party/blink/renderer/core/paint/object_painter_base.h b/third_party/blink/renderer/core/paint/object_painter_base.h index 6031500e..2890d89 100644 --- a/third_party/blink/renderer/core/paint/object_painter_base.h +++ b/third_party/blink/renderer/core/paint/object_painter_base.h
@@ -6,7 +6,6 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_OBJECT_PAINTER_BASE_H_ #include "third_party/blink/renderer/core/style/computed_style_constants.h" -#include "third_party/blink/renderer/platform/geometry/layout_rect.h" #include "third_party/blink/renderer/platform/wtf/allocator.h" #include "third_party/blink/renderer/platform/wtf/vector.h" @@ -16,6 +15,7 @@ class Color; class GraphicsContext; struct PaintInfo; +struct PhysicalRect; // Base class for object painting. Has no dependencies on the layout tree and // thus provides functionality and definitions that can be shared between both @@ -39,7 +39,7 @@ protected: ObjectPainterBase() = default; void PaintOutlineRects(const PaintInfo&, - const Vector<LayoutRect>&, + const Vector<PhysicalRect>&, const ComputedStyle&); };
diff --git a/third_party/blink/renderer/core/paint/paint_and_raster_invalidation_test.cc b/third_party/blink/renderer/core/paint/paint_and_raster_invalidation_test.cc index 862b46d9..85d7346d 100644 --- a/third_party/blink/renderer/core/paint/paint_and_raster_invalidation_test.cc +++ b/third_party/blink/renderer/core/paint/paint_and_raster_invalidation_test.cc
@@ -1020,23 +1020,23 @@ const auto* sticky = GetLayoutObjectByElementId("sticky"); EXPECT_TRUE(sticky->NeedsPaintPropertyUpdate()); - EXPECT_EQ(LayoutPoint(0, 0), sticky->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), sticky->FirstFragment().PaintOffset()); EXPECT_EQ(FloatSize(0, 50), sticky->FirstFragment() .PaintProperties() ->StickyTranslation() ->Translation2D()); const auto* inner = GetLayoutObjectByElementId("inner"); - EXPECT_EQ(LayoutPoint(0, 0), inner->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), inner->FirstFragment().PaintOffset()); UpdateAllLifecyclePhasesForTest(); EXPECT_FALSE(sticky->NeedsPaintPropertyUpdate()); - EXPECT_EQ(LayoutPoint(0, 0), sticky->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), sticky->FirstFragment().PaintOffset()); EXPECT_EQ(FloatSize(0, 150), sticky->FirstFragment() .PaintProperties() ->StickyTranslation() ->Translation2D()); - EXPECT_EQ(LayoutPoint(0, 0), inner->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), inner->FirstFragment().PaintOffset()); } class PaintInvalidatorTestClient : public RenderingTestChromeClient {
diff --git a/third_party/blink/renderer/core/paint/paint_invalidator.cc b/third_party/blink/renderer/core/paint/paint_invalidator.cc index c63ba4d..e0b2fab 100644 --- a/third_party/blink/renderer/core/paint/paint_invalidator.cc +++ b/third_party/blink/renderer/core/paint/paint_invalidator.cc
@@ -83,15 +83,14 @@ // Usually it is done at layout object level and included as a part of // local visual overflow, but clip-path can be a reference to SVG, and we // have to wait until pre-paint to ensure clean layout. - LayoutRect rect = local_rect.ToLayoutRect(); + PhysicalRect rect = local_rect; if (base::Optional<FloatRect> clip_path_bounding_box = ClipPathClipper::LocalClipPathBoundingBox(object)) - rect.Unite(LayoutRect(EnclosingIntRect(*clip_path_bounding_box))); + rect.Unite(PhysicalRect(EnclosingIntRect(*clip_path_bounding_box))); - rect.MoveBy(fragment_data->PaintOffset()); - if (ShouldExcludeCompositedLayerSubpixelAccumulation(object)) { + rect.Move(fragment_data->PaintOffset()); + if (ShouldExcludeCompositedLayerSubpixelAccumulation(object)) rect.Move(-paint_invalidation_container->Layer()->SubpixelAccumulation()); - } // Use EnclosingIntRect to ensure the final visual rect will cover the rect // in source coordinates no matter if the painting will snap to pixels. return EnclosingIntRect(rect);
diff --git a/third_party/blink/renderer/core/paint/paint_invalidator.h b/third_party/blink/renderer/core/paint/paint_invalidator.h index 0d5fd70..6aa6908 100644 --- a/third_party/blink/renderer/core/paint/paint_invalidator.h +++ b/third_party/blink/renderer/core/paint/paint_invalidator.h
@@ -126,7 +126,7 @@ // The previous VisualRect and PaintOffset of FragmentData. IntRect old_visual_rect; - LayoutPoint old_paint_offset; + PhysicalOffset old_paint_offset; const FragmentData* fragment_data;
diff --git a/third_party/blink/renderer/core/paint/paint_layer.cc b/third_party/blink/renderer/core/paint/paint_layer.cc index 51480d2..bc17324 100644 --- a/third_party/blink/renderer/core/paint/paint_layer.cc +++ b/third_party/blink/renderer/core/paint/paint_layer.cc
@@ -283,13 +283,13 @@ GetCompositingState() != kPaintsIntoOwnBacking; } -LayoutSize PaintLayer::SubpixelAccumulation() const { - return rare_data_ ? rare_data_->subpixel_accumulation : LayoutSize(); +PhysicalOffset PaintLayer::SubpixelAccumulation() const { + return rare_data_ ? rare_data_->subpixel_accumulation : PhysicalOffset(); } -void PaintLayer::SetSubpixelAccumulation(const LayoutSize& size) { - if (rare_data_ || !size.IsZero()) { - EnsureRareData().subpixel_accumulation = size; +void PaintLayer::SetSubpixelAccumulation(const PhysicalOffset& accumulation) { + if (rare_data_ || !accumulation.IsZero()) { + EnsureRareData().subpixel_accumulation = accumulation; if (PaintLayerScrollableArea* scrollable_area = GetScrollableArea()) { scrollable_area->PositionOverflowControls(); } @@ -317,7 +317,7 @@ void PaintLayer::UpdateLayerPositionRecursive( UpdateLayerPositionBehavior behavior, bool dirty_compositing_if_needed) { - LayoutPoint old_location = location_; + auto old_location = location_; switch (behavior) { case AllLayers: UpdateLayerPosition(); @@ -522,7 +522,7 @@ void PaintLayer::ConvertFromFlowThreadToVisualBoundingBoxInAncestor( const PaintLayer* ancestor_layer, - LayoutRect& rect) const { + PhysicalRect& rect) const { PaintLayer* pagination_layer = EnclosingPaginationLayer(); DCHECK(pagination_layer); LayoutFlowThread& flow_thread = @@ -530,24 +530,25 @@ // First make the flow thread rectangle relative to the flow thread, not to // |layer|. - LayoutPoint offset_within_pagination_layer; + PhysicalOffset offset_within_pagination_layer; ConvertToLayerCoords(pagination_layer, offset_within_pagination_layer); - rect.MoveBy(offset_within_pagination_layer); + rect.Move(offset_within_pagination_layer); // Then make the rectangle visual, relative to the fragmentation context. // Split our box up into the actual fragment boxes that layout in the // columns/pages and unite those together to get our true bounding box. - rect = flow_thread.FragmentsBoundingBox(rect); + rect = PhysicalRectToBeNoop( + flow_thread.FragmentsBoundingBox(rect.ToLayoutRect())); // Finally, make the visual rectangle relative to |ancestorLayer|. if (ancestor_layer->EnclosingPaginationLayer() != pagination_layer) { - rect.MoveBy(pagination_layer->VisualOffsetFromAncestor(ancestor_layer)); + rect.Move(pagination_layer->VisualOffsetFromAncestor(ancestor_layer)); return; } // The ancestor layer is inside the same pagination layer as |layer|, so we // need to subtract the visual distance from the ancestor layer to the // pagination layer. - rect.MoveBy(-ancestor_layer->VisualOffsetFromAncestor(pagination_layer)); + rect.Move(-ancestor_layer->VisualOffsetFromAncestor(pagination_layer)); } void PaintLayer::UpdatePaginationRecursive(bool needs_pagination_update) { @@ -852,7 +853,7 @@ rare_data_->offset_for_in_flow_position = PhysicalOffset(); } - location_ = local_point.ToLayoutPoint(); + location_ = local_point; #if DCHECK_IS_ON() needs_position_update_ = false; @@ -961,7 +962,7 @@ return nullptr; } -LayoutPoint PaintLayer::ComputeOffsetFromAncestor( +PhysicalOffset PaintLayer::ComputeOffsetFromAncestor( const PaintLayer& ancestor_layer) const { TransformState transform_state(TransformState::kApplyTransformDirection, FloatPoint()); @@ -971,7 +972,7 @@ if (ancestor_object.UsesCompositedScrolling()) transform_state.Move(ToLayoutBox(ancestor_object).ScrolledContentOffset()); transform_state.Flatten(); - return LayoutPoint(transform_state.LastPlanarPoint()); + return PhysicalOffset::FromFloatPointRound(transform_state.LastPlanarPoint()); } PaintLayer* PaintLayer::CompositingContainer() const { @@ -1186,11 +1187,11 @@ } static void ExpandClipRectForDescendants( - LayoutRect& clip_rect, + PhysicalRect& clip_rect, const PaintLayer* layer, const PaintLayer* root_layer, PaintLayer::TransparencyClipBoxBehavior transparency_behavior, - const LayoutSize& sub_pixel_accumulation, + const PhysicalOffset& sub_pixel_accumulation, GlobalPaintFlags global_paint_flags) { // If we have a mask, then the clip is limited to the border box area (and // there is no need to examine child layers). @@ -1207,12 +1208,12 @@ } } -LayoutRect PaintLayer::TransparencyClipBox( +PhysicalRect PaintLayer::TransparencyClipBox( const PaintLayer* layer, const PaintLayer* root_layer, TransparencyClipBoxBehavior transparency_behavior, TransparencyClipBoxMode transparency_mode, - const LayoutSize& sub_pixel_accumulation, + const PhysicalOffset& sub_pixel_accumulation, GlobalPaintFlags global_paint_flags) { // FIXME: Although this function completely ignores CSS-imposed clipping, we // did already intersect with the paintDirtyRect, and that should cut down on @@ -1232,10 +1233,10 @@ : nullptr; const PaintLayer* root_layer_for_transform = pagination_layer ? pagination_layer : root_layer; - LayoutPoint delta; + PhysicalOffset delta; layer->ConvertToLayerCoords(root_layer_for_transform, delta); - delta.Move(sub_pixel_accumulation); + delta += sub_pixel_accumulation; IntPoint pixel_snapped_delta = RoundedIntPoint(delta); TransformationMatrix transform; transform.Translate(pixel_snapped_delta.X(), pixel_snapped_delta.Y()); @@ -1244,10 +1245,10 @@ // We don't use fragment boxes when collecting a transformed layer's // bounding box, since it always paints unfragmented. - LayoutRect clip_rect = layer->PhysicalBoundingBox(LayoutPoint()); + PhysicalRect clip_rect = layer->LocalBoundingBox(); ExpandClipRectForDescendants(clip_rect, layer, layer, transparency_behavior, sub_pixel_accumulation, global_paint_flags); - LayoutRect result = EnclosingLayoutRect( + PhysicalRect result = PhysicalRect::EnclosingRect( transform.MapRect(layer->MapRectForFilter(FloatRect(clip_rect)))); if (!pagination_layer) return result; @@ -1257,37 +1258,38 @@ // columns/pages and unite those together to get our true bounding box. LayoutFlowThread& enclosing_flow_thread = ToLayoutFlowThread(pagination_layer->GetLayoutObject()); - result = enclosing_flow_thread.FragmentsBoundingBox(result); + result = PhysicalRectToBeNoop( + enclosing_flow_thread.FragmentsBoundingBox(result.ToLayoutRect())); - LayoutPoint root_layer_delta; + PhysicalOffset root_layer_delta; pagination_layer->ConvertToLayerCoords(root_layer, root_layer_delta); - result.MoveBy(root_layer_delta); + result.Move(root_layer_delta); return result; } - LayoutRect clip_rect = layer->ShouldFragmentCompositedBounds(root_layer) - ? layer->FragmentsBoundingBox(root_layer) - : layer->PhysicalBoundingBox(root_layer); + PhysicalRect clip_rect = layer->ShouldFragmentCompositedBounds(root_layer) + ? layer->FragmentsBoundingBox(root_layer) + : layer->PhysicalBoundingBox(root_layer); ExpandClipRectForDescendants(clip_rect, layer, root_layer, transparency_behavior, sub_pixel_accumulation, global_paint_flags); // Convert clipRect into local coordinates for mapLayerRectForFilter(), and // convert back after. - LayoutPoint delta; + PhysicalOffset delta; layer->ConvertToLayerCoords(root_layer, delta); - clip_rect.MoveBy(-delta); - clip_rect = - layer->MapRectForFilter(PhysicalRectToBeNoop(clip_rect)).ToLayoutRect(); - clip_rect.MoveBy(delta); + clip_rect.Move(-delta); + clip_rect = layer->MapRectForFilter(clip_rect); + clip_rect.Move(delta); clip_rect.Move(sub_pixel_accumulation); return clip_rect; } -LayoutRect PaintLayer::PaintingExtent(const PaintLayer* root_layer, - const LayoutSize& sub_pixel_accumulation, - GlobalPaintFlags global_paint_flags) { +PhysicalRect PaintLayer::PaintingExtent( + const PaintLayer* root_layer, + const PhysicalOffset& sub_pixel_accumulation, + GlobalPaintFlags global_paint_flags) { return TransparencyClipBox(this, root_layer, kPaintingTransparencyClipBox, kRootOfTransparencyClipBox, sub_pixel_accumulation, global_paint_flags); @@ -1517,7 +1519,7 @@ static inline const PaintLayer* AccumulateOffsetTowardsAncestor( const PaintLayer* layer, const PaintLayer* ancestor_layer, - LayoutPoint& location) { + PhysicalOffset& location) { DCHECK(ancestor_layer != layer); const LayoutBoxModelObject& layout_object = layer->GetLayoutObject(); @@ -1527,7 +1529,7 @@ // If the fixed layer's container is the root, just add in the offset of the // view. We can obtain this by calling localToAbsolute() on the LayoutView. FloatPoint abs_pos = layout_object.LocalToAbsolute(); - location += LayoutSize(abs_pos.X(), abs_pos.Y()); + location += PhysicalOffset::FromFloatPointRound(abs_pos); return ancestor_layer; } @@ -1538,10 +1540,10 @@ if (found_ancestor_first) { // Found ancestorLayer before the containing layer, so compute offset of // both relative to the container and subtract. - LayoutPoint this_coords; + PhysicalOffset this_coords; layer->ConvertToLayerCoords(containing_layer, this_coords); - LayoutPoint ancestor_coords; + PhysicalOffset ancestor_coords; ancestor_layer->ConvertToLayerCoords(containing_layer, ancestor_coords); location += (this_coords - ancestor_coords); @@ -1556,7 +1558,7 @@ } void PaintLayer::ConvertToLayerCoords(const PaintLayer* ancestor_layer, - LayoutPoint& location) const { + PhysicalOffset& location) const { if (ancestor_layer == this) return; @@ -1567,15 +1569,15 @@ } void PaintLayer::ConvertToLayerCoords(const PaintLayer* ancestor_layer, - LayoutRect& rect) const { - LayoutPoint delta; + PhysicalRect& rect) const { + PhysicalOffset delta; ConvertToLayerCoords(ancestor_layer, delta); - rect.MoveBy(delta); + rect.Move(delta); } -LayoutPoint PaintLayer::VisualOffsetFromAncestor( +PhysicalOffset PaintLayer::VisualOffsetFromAncestor( const PaintLayer* ancestor_layer, - LayoutPoint offset) const { + PhysicalOffset offset) const { if (ancestor_layer == this) return offset; PaintLayer* pagination_layer = EnclosingPaginationLayer(); @@ -1589,17 +1591,18 @@ LayoutFlowThread& flow_thread = ToLayoutFlowThread(pagination_layer->GetLayoutObject()); ConvertToLayerCoords(pagination_layer, offset); - offset = flow_thread.FlowThreadPointToVisualPoint(offset); + offset = PhysicalOffsetToBeNoop( + flow_thread.FlowThreadPointToVisualPoint(offset.ToLayoutPoint())); if (ancestor_layer == pagination_layer) return offset; if (ancestor_layer->EnclosingPaginationLayer() != pagination_layer) { - offset.MoveBy(pagination_layer->VisualOffsetFromAncestor(ancestor_layer)); + offset += pagination_layer->VisualOffsetFromAncestor(ancestor_layer); } else { // The ancestor layer is also inside the pagination layer, so we need to // subtract the visual distance from the ancestor layer to the pagination // layer. - offset.MoveBy(-ancestor_layer->VisualOffsetFromAncestor(pagination_layer)); + offset -= ancestor_layer->VisualOffsetFromAncestor(pagination_layer); } return offset; } @@ -1657,8 +1660,8 @@ const CullRect* cull_rect, OverlayScrollbarClipBehavior overlay_scrollbar_clip_behavior, ShouldRespectOverflowClipType respect_overflow_clip, - const LayoutPoint* offset_from_root, - const LayoutSize& sub_pixel_accumulation) const { + const PhysicalOffset* offset_from_root, + const PhysicalOffset& sub_pixel_accumulation) const { PaintLayerFragment fragment; ClipRectsContext clip_rects_context( root_layer, &root_layer->GetLayoutObject().FirstFragment(), @@ -1698,8 +1701,8 @@ const CullRect* cull_rect, OverlayScrollbarClipBehavior overlay_scrollbar_clip_behavior, ShouldRespectOverflowClipType respect_overflow_clip, - const LayoutPoint* offset_from_root, - const LayoutSize& sub_pixel_accumulation) const { + const PhysicalOffset* offset_from_root, + const PhysicalOffset& sub_pixel_accumulation) const { PaintLayerFragment fragment; const auto& first_fragment_data = GetLayoutObject().FirstFragment(); const auto& first_root_fragment_data = @@ -1900,26 +1903,25 @@ recursion_data.location.TransformedRect(), FloatQuad(FloatRect(recursion_data.rect))); - LayoutPoint offset; + PhysicalOffset offset; if (container_transform_state) ConvertToLayerCoords(container_layer, offset); else ConvertToLayerCoords(root_layer, offset); - offset.MoveBy(translation_offset); + offset += PhysicalOffsetToBeNoop(translation_offset); LayoutObject* container_layout_object = container_layer ? &container_layer->GetLayoutObject() : nullptr; if (GetLayoutObject().ShouldUseTransformFromContainer( container_layout_object)) { TransformationMatrix container_transform; - GetLayoutObject().GetTransformFromContainer(container_layout_object, - PhysicalOffsetToBeNoop(offset), + GetLayoutObject().GetTransformFromContainer(container_layout_object, offset, container_transform); transform_state.ApplyTransform( container_transform, HitTestingTransformState::kAccumulateTransform); } else { - transform_state.Translate(offset.X().ToInt(), offset.Y().ToInt(), + transform_state.Translate(offset.left.ToInt(), offset.top.ToInt(), HitTestingTransformState::kAccumulateTransform); } @@ -2125,7 +2127,7 @@ layer_fragments.emplace(); if (applied_transform) { DCHECK(root_layer == this); - LayoutPoint ignored; + PhysicalOffset ignored; AppendSingleFragmentIgnoringPagination( *layer_fragments, root_layer, nullptr, kExcludeOverlayScrollbarSizeForHitTesting, clip_behavior, &ignored); @@ -2231,7 +2233,7 @@ continue; inside_clip_rect = true; LayoutPoint fragment_offset = offset; - fragment_offset.MoveBy(fragment.layer_bounds.Location()); + fragment_offset.MoveBy(fragment.layer_bounds.offset.ToLayoutPoint()); if (HitTestContents(result, fragment_offset, hit_test_location, hit_test_filter)) return true; @@ -2254,18 +2256,18 @@ EnclosingPaginationLayer()->CollectFragments( enclosing_pagination_fragments, root_layer, nullptr, kExcludeOverlayScrollbarSizeForHitTesting, clip_behavior, nullptr, - LayoutSize()); + PhysicalOffset()); for (const auto& fragment : enclosing_pagination_fragments) { // Apply the page/column clip for this fragment, as well as any clips // established by layers in between us and the enclosing pagination layer. - LayoutRect clip_rect = fragment.background_rect.Rect(); - if (!recursion_data.location.Intersects(clip_rect)) + PhysicalRect clip_rect = fragment.background_rect.Rect(); + if (!recursion_data.location.Intersects(clip_rect.ToLayoutRect())) continue; PaintLayer* hit_layer = HitTestLayerByApplyingTransform( root_layer, container_layer, result, recursion_data, transform_state, - z_offset, fragment.fragment_data->PaginationOffset()); + z_offset, fragment.fragment_data->PaginationOffset().ToLayoutPoint()); if (hit_layer) return hit_layer; } @@ -2443,7 +2445,7 @@ return; FloatRect reference_box = FloatRect(PhysicalBoundingBoxIncludingStackingChildren( - LayoutPoint(), + PhysicalOffset(), PaintLayer::kIncludeTransformsAndCompositedChildLayers)); float zoom = GetLayoutObject().StyleRef().EffectiveZoom(); if (zoom != 1) @@ -2498,13 +2500,13 @@ DCHECK(IsSelfPaintingLayer()); DCHECK(root_layer); - LayoutRect origin; + PhysicalRect origin; if (EnclosingPaginationLayer()) ConvertFromFlowThreadToVisualBoundingBoxInAncestor(root_layer, origin); else ConvertToLayerCoords(root_layer, origin); - FloatPoint point(hit_test_location.Point() - origin.Location()); + FloatPoint point(hit_test_location.Point() - origin.offset.ToLayoutPoint()); FloatRect reference_box( ClipPathClipper::LocalReferenceBox(GetLayoutObject())); @@ -2539,9 +2541,9 @@ } bool PaintLayer::IntersectsDamageRect( - const LayoutRect& layer_bounds, - const LayoutRect& damage_rect, - const LayoutPoint& offset_from_root) const { + const PhysicalRect& layer_bounds, + const PhysicalRect& damage_rect, + const PhysicalOffset& offset_from_root) const { // Always examine the canvas and the root. // FIXME: Could eliminate the isDocumentElement() check if we fix background // painting so that the LayoutView paints the root's background. @@ -2580,38 +2582,38 @@ return rect; } -LayoutRect PaintLayer::PhysicalBoundingBox( +PhysicalRect PaintLayer::PhysicalBoundingBox( const PaintLayer* ancestor_layer) const { - LayoutPoint offset_from_root; + PhysicalOffset offset_from_root; ConvertToLayerCoords(ancestor_layer, offset_from_root); return PhysicalBoundingBox(offset_from_root); } -LayoutRect PaintLayer::PhysicalBoundingBox( - const LayoutPoint& offset_from_root) const { - LayoutRect result = LocalBoundingBox().ToLayoutRect(); - result.MoveBy(offset_from_root); +PhysicalRect PaintLayer::PhysicalBoundingBox( + const PhysicalOffset& offset_from_root) const { + PhysicalRect result = LocalBoundingBox(); + result.Move(offset_from_root); return result; } -LayoutRect PaintLayer::FragmentsBoundingBox( +PhysicalRect PaintLayer::FragmentsBoundingBox( const PaintLayer* ancestor_layer) const { if (!EnclosingPaginationLayer()) return PhysicalBoundingBox(ancestor_layer); - LayoutRect result = LocalBoundingBox().ToLayoutRect(); + PhysicalRect result = LocalBoundingBox(); ConvertFromFlowThreadToVisualBoundingBoxInAncestor(ancestor_layer, result); return result; } -LayoutRect PaintLayer::BoundingBoxForCompositingOverlapTest() const { +PhysicalRect PaintLayer::BoundingBoxForCompositingOverlapTest() const { // Apply NeverIncludeTransformForAncestorLayer, because the geometry map in // CompositingInputsUpdater will take care of applying the transform of |this| // (== the ancestorLayer argument to boundingBoxForCompositing). // TODO(trchen): Layer fragmentation is inhibited across compositing boundary. // Should we return the unfragmented bounds for overlap testing? Or perhaps // assume fragmented layers always overlap? - LayoutRect bounding_box = + PhysicalRect bounding_box = OverlapBoundsIncludeChildren() ? BoundingBoxForCompositingInternal( *this, nullptr, kNeverIncludeTransformForAncestorLayer) @@ -2619,7 +2621,7 @@ const ComputedStyle& style = GetLayoutObject().StyleRef(); if (style.HasBackdropFilter() && style.BackdropFilter().HasFilterThatMovesPixels()) { - bounding_box = EnclosingLayoutRect( + bounding_box = PhysicalRect::EnclosingRect( style.BackdropFilter().MapRect(FloatRect(bounding_box))); } return bounding_box; @@ -2631,7 +2633,7 @@ void PaintLayer::ExpandRectForStackingChildren( const PaintLayer& composited_layer, - LayoutRect& result, + PhysicalRect& result, PaintLayer::CalculateBoundsOptions options) const { if (!StackingNode()) return; @@ -2660,17 +2662,17 @@ } } -LayoutRect PaintLayer::PhysicalBoundingBoxIncludingStackingChildren( - const LayoutPoint& offset_from_root, +PhysicalRect PaintLayer::PhysicalBoundingBoxIncludingStackingChildren( + const PhysicalOffset& offset_from_root, CalculateBoundsOptions options) const { - LayoutRect result = PhysicalBoundingBox(LayoutPoint()); + PhysicalRect result = LocalBoundingBox(); ExpandRectForStackingChildren(*this, result, options); - result.MoveBy(offset_from_root); + result.Move(offset_from_root); return result; } -LayoutRect PaintLayer::BoundingBoxForCompositing() const { +PhysicalRect PaintLayer::BoundingBoxForCompositing() const { return BoundingBoxForCompositingInternal( *this, nullptr, kMaybeIncludeTransformForAncestorLayer); } @@ -2691,18 +2693,18 @@ return false; } -LayoutRect PaintLayer::BoundingBoxForCompositingInternal( +PhysicalRect PaintLayer::BoundingBoxForCompositingInternal( const PaintLayer& composited_layer, const PaintLayer* stacking_parent, CalculateBoundsOptions options) const { if (!IsSelfPaintingLayer()) - return LayoutRect(); + return PhysicalRect(); // FIXME: This could be improved to do a check like // hasVisibleNonCompositingDescendantLayers() (bug 92580). if (this != &composited_layer && !HasVisibleContent() && !HasVisibleDescendant()) - return LayoutRect(); + return PhysicalRect(); if (GetLayoutObject().IsEffectiveRootScroller() || IsRootLayer()) { // In root layer scrolling mode, the main GraphicsLayer is the size of the @@ -2711,7 +2713,7 @@ IntRect result = IntRect(); if (LocalFrameView* frame_view = GetLayoutObject().GetFrameView()) result = IntRect(IntPoint(), frame_view->Size()); - return LayoutRect(result); + return PhysicalRect(result); } // The layer created for the LayoutFlowThread is just a helper for painting @@ -2719,24 +2721,26 @@ // LayoutMultiColumnSets will contribute the correct size for the layout // content of the multicol container. if (GetLayoutObject().IsLayoutFlowThread()) - return LayoutRect(); + return PhysicalRect(); // If there is a clip applied by an ancestor to this PaintLayer but below or // equal to |ancestorLayer|, apply that clip. - LayoutRect result = Clipper(GeometryMapperOption::kDoNotUseGeometryMapper) - .LocalClipRect(composited_layer); + PhysicalRect result = Clipper(GeometryMapperOption::kDoNotUseGeometryMapper) + .LocalClipRect(composited_layer); - result.Intersect(PhysicalBoundingBox(LayoutPoint())); + result.Intersect(LocalBoundingBox()); ExpandRectForStackingChildren(composited_layer, result, options); // Only enlarge by the filter outsets if we know the filter is going to be // rendered in software. Accelerated filters will handle their own outsets. if (PaintsWithFilters()) - result = MapRectForFilter(PhysicalRectToBeNoop(result)).ToLayoutRect(); + result = MapRectForFilter(result); - if (ShouldApplyTransformToBoundingBox(composited_layer, options)) - result = Transform()->MapRect(result); + if (ShouldApplyTransformToBoundingBox(composited_layer, options)) { + result = + PhysicalRect::EnclosingRect(Transform()->MapRect(FloatRect(result))); + } if (ShouldFragmentCompositedBounds(&composited_layer)) { ConvertFromFlowThreadToVisualBoundingBoxInAncestor(&composited_layer, @@ -2745,9 +2749,9 @@ } if (stacking_parent) { - LayoutPoint delta; + PhysicalOffset delta; ConvertToLayerCoords(stacking_parent, delta); - result.MoveBy(delta); + result.Move(delta); } return result; } @@ -2890,7 +2894,7 @@ } bool PaintLayer::BackgroundIsKnownToBeOpaqueInRect( - const LayoutRect& local_rect, + const PhysicalRect& local_rect, bool should_check_children) const { if (PaintsWithTransparency(kGlobalPaintNormalPhase)) return false; @@ -2938,7 +2942,7 @@ } bool PaintLayer::ChildBackgroundIsKnownToBeOpaqueInRect( - const LayoutRect& local_rect) const { + const PhysicalRect& local_rect) const { if (!stacking_node_) return false; @@ -2953,10 +2957,10 @@ if (!child_layer->CanUseConvertToLayerCoords()) continue; - LayoutPoint child_offset; - LayoutRect child_local_rect(local_rect); + PhysicalOffset child_offset; + PhysicalRect child_local_rect(local_rect); child_layer->ConvertToLayerCoords(this, child_offset); - child_local_rect.MoveBy(-child_offset); + child_local_rect.Move(-child_offset); if (child_layer->BackgroundIsKnownToBeOpaqueInRect(child_local_rect, true)) return true; @@ -3230,12 +3234,13 @@ } } -LayoutPoint PaintLayer::LocationInternal() const { - LayoutPoint result(location_); +PhysicalOffset PaintLayer::LocationInternal() const { + PhysicalOffset result = location_; PaintLayer* containing_layer = ContainingLayer(); if (containing_layer && containing_layer->IsRootLayer() && containing_layer->GetLayoutObject().HasOverflowClip()) { - result -= containing_layer->GetLayoutBox()->ScrolledContentOffset(); + result -= PhysicalOffset( + containing_layer->GetLayoutBox()->ScrolledContentOffset()); } return result; }
diff --git a/third_party/blink/renderer/core/paint/paint_layer.h b/third_party/blink/renderer/core/paint/paint_layer.h index 4913499..6084c153 100644 --- a/third_party/blink/renderer/core/paint/paint_layer.h +++ b/third_party/blink/renderer/core/paint/paint_layer.h
@@ -152,7 +152,7 @@ // The accumulated subpixel offset of a composited layer's composited bounds // compared to absolute coordinates. - LayoutSize subpixel_accumulation; + PhysicalOffset subpixel_accumulation; DISALLOW_COPY_AND_ASSIGN(PaintLayerRareData); }; @@ -277,7 +277,7 @@ return curr; } - LayoutPoint Location() const { + PhysicalOffset Location() const { #if DCHECK_IS_ON() DCHECK(!needs_position_update_); #endif @@ -396,9 +396,9 @@ } void ConvertToLayerCoords(const PaintLayer* ancestor_layer, - LayoutPoint&) const; + PhysicalOffset&) const; void ConvertToLayerCoords(const PaintLayer* ancestor_layer, - LayoutRect&) const; + PhysicalRect&) const; // Does the same as convertToLayerCoords() when not in multicol. For multicol, // however, convertToLayerCoords() calculates the offset in flow-thread @@ -407,9 +407,9 @@ // layer starts in and adds in the offset. See // http://www.chromium.org/developers/design-documents/multi-column-layout for // more info. - LayoutPoint VisualOffsetFromAncestor( + PhysicalOffset VisualOffsetFromAncestor( const PaintLayer* ancestor_layer, - LayoutPoint offset = LayoutPoint()) const; + PhysicalOffset offset = PhysicalOffset()) const; // Convert a bounding box from flow thread coordinates, relative to |this|, to // visual coordinates, relative to |ancestorLayer|. @@ -418,7 +418,7 @@ // to be paginated; i.e. it must have an enclosingPaginationLayer(). void ConvertFromFlowThreadToVisualBoundingBoxInAncestor( const PaintLayer* ancestor_layer, - LayoutRect&) const; + PhysicalRect&) const; // The hitTest() method looks for mouse events by walking layers that // intersect the point from front to back. @@ -428,9 +428,9 @@ HitTestResult&, const LayoutRect& hit_test_area); - bool IntersectsDamageRect(const LayoutRect& layer_bounds, - const LayoutRect& damage_rect, - const LayoutPoint& offset_from_root) const; + bool IntersectsDamageRect(const PhysicalRect& layer_bounds, + const PhysicalRect& damage_rect, + const PhysicalOffset& offset_from_root) const; // MaybeIncludeTransformForAncestorLayer means that a transform on // |ancestorLayer| may be applied to the bounding box, in particular if @@ -442,15 +442,16 @@ }; // Bounding box relative to some ancestor layer. Pass offsetFromRoot if known. - LayoutRect PhysicalBoundingBox(const LayoutPoint& offset_from_root) const; - LayoutRect PhysicalBoundingBox(const PaintLayer* ancestor_layer) const; - LayoutRect PhysicalBoundingBoxIncludingStackingChildren( - const LayoutPoint& offset_from_root, + PhysicalRect PhysicalBoundingBox( + const PhysicalOffset& offset_from_root) const; + PhysicalRect PhysicalBoundingBox(const PaintLayer* ancestor_layer) const; + PhysicalRect PhysicalBoundingBoxIncludingStackingChildren( + const PhysicalOffset& offset_from_root, CalculateBoundsOptions = kMaybeIncludeTransformForAncestorLayer) const; - LayoutRect FragmentsBoundingBox(const PaintLayer* ancestor_layer) const; + PhysicalRect FragmentsBoundingBox(const PaintLayer* ancestor_layer) const; - LayoutRect BoundingBoxForCompositingOverlapTest() const; - LayoutRect BoundingBoxForCompositing() const; + PhysicalRect BoundingBoxForCompositingOverlapTest() const; + PhysicalRect BoundingBoxForCompositing() const; // If true, this layer's children are included in its bounds for overlap // testing. We can't rely on the children's positions if this layer has a @@ -468,8 +469,8 @@ static_block_position_ = position; } - LayoutSize SubpixelAccumulation() const; - void SetSubpixelAccumulation(const LayoutSize&); + PhysicalOffset SubpixelAccumulation() const; + void SetSubpixelAccumulation(const PhysicalOffset&); bool HasTransformRelatedProperty() const { return GetLayoutObject().HasTransformRelatedProperty(); @@ -594,7 +595,7 @@ // The query rect is given in local coordinates. // if |should_check_children| is true, checks non-composited stacking children // recursively to see if they paint opaquely over the rect. - bool BackgroundIsKnownToBeOpaqueInRect(const LayoutRect&, + bool BackgroundIsKnownToBeOpaqueInRect(const PhysicalRect&, bool should_check_children) const; bool ContainsDirtyOverlayScrollbars() const { @@ -916,13 +917,14 @@ // Returned value does not include any composited scroll offset of // the transform ancestor. - LayoutPoint ComputeOffsetFromAncestor(const PaintLayer& ancestor_layer) const; + PhysicalOffset ComputeOffsetFromAncestor( + const PaintLayer& ancestor_layer) const; void DidUpdateScrollsOverflow(); - LayoutRect PaintingExtent(const PaintLayer* root_layer, - const LayoutSize& sub_pixel_accumulation, - GlobalPaintFlags); + PhysicalRect PaintingExtent(const PaintLayer* root_layer, + const PhysicalOffset& sub_pixel_accumulation, + GlobalPaintFlags); void AppendSingleFragmentIgnoringPagination( PaintLayerFragments&, @@ -930,8 +932,8 @@ const CullRect* cull_rect, OverlayScrollbarClipBehavior = kIgnorePlatformOverlayScrollbarSize, ShouldRespectOverflowClipType = kRespectOverflowClip, - const LayoutPoint* offset_from_root = nullptr, - const LayoutSize& sub_pixel_accumulation = LayoutSize()) const; + const PhysicalOffset* offset_from_root = nullptr, + const PhysicalOffset& sub_pixel_accumulation = PhysicalOffset()) const; void CollectFragments( PaintLayerFragments&, @@ -939,8 +941,8 @@ const CullRect* cull_rect, OverlayScrollbarClipBehavior = kIgnorePlatformOverlayScrollbarSize, ShouldRespectOverflowClipType = kRespectOverflowClip, - const LayoutPoint* offset_from_root = nullptr, - const LayoutSize& sub_pixel_accumulation = LayoutSize()) const; + const PhysicalOffset* offset_from_root = nullptr, + const PhysicalOffset& sub_pixel_accumulation = PhysicalOffset()) const; LayoutPoint LayoutBoxLocation() const { return GetLayoutObject().IsBox() ? ToLayoutBox(GetLayoutObject()).Location() @@ -957,12 +959,12 @@ kRootOfTransparencyClipBox }; - static LayoutRect TransparencyClipBox( + static PhysicalRect TransparencyClipBox( const PaintLayer*, const PaintLayer* root_layer, TransparencyClipBoxBehavior transparency_behavior, TransparencyClipBoxMode transparency_mode, - const LayoutSize& sub_pixel_accumulation, + const PhysicalOffset& sub_pixel_accumulation, GlobalPaintFlags = kGlobalPaintNormalPhase); bool NeedsRepaint() const { return needs_repaint_; } @@ -1173,7 +1175,7 @@ bool HitTestClippedOutByClipPath(PaintLayer* root_layer, const HitTestLocation&) const; - bool ChildBackgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const; + bool ChildBackgroundIsKnownToBeOpaqueInRect(const PhysicalRect&) const; bool ShouldBeSelfPaintingLayer() const; @@ -1224,12 +1226,12 @@ } void ExpandRectForStackingChildren(const PaintLayer& composited_layer, - LayoutRect& result, + PhysicalRect& result, PaintLayer::CalculateBoundsOptions) const; // The return value is in the space of |stackingParent|, if non-null, or // |this| otherwise. - LayoutRect BoundingBoxForCompositingInternal( + PhysicalRect BoundingBoxForCompositingInternal( const PaintLayer& composited_layer, const PaintLayer* stacking_parent, CalculateBoundsOptions) const; @@ -1238,7 +1240,7 @@ bool NeedsFilterReferenceBox() const; - LayoutPoint LocationInternal() const; + PhysicalOffset LocationInternal() const; AncestorDependentCompositingInputs& EnsureAncestorDependentCompositingInputs() const { @@ -1337,7 +1339,7 @@ PaintLayer* last_; // Our (x,y) coordinates are in our containing layer's coordinate space. - LayoutPoint location_; + PhysicalOffset location_; // The layer's size. //
diff --git a/third_party/blink/renderer/core/paint/paint_layer_clipper.cc b/third_party/blink/renderer/core/paint/paint_layer_clipper.cc index 7406b7e..b36844ff 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_clipper.cc +++ b/third_party/blink/renderer/core/paint/paint_layer_clipper.cc
@@ -88,7 +88,7 @@ static void ApplyClipRects(const ClipRectsContext& context, const LayoutBoxModelObject& layout_object, - LayoutPoint offset, + const PhysicalOffset& offset, ClipRects& clip_rects) { DCHECK(layout_object.IsBox()); const LayoutBox& box = *ToLayoutBox(&layout_object); @@ -114,7 +114,7 @@ Intersection(new_overflow_clip, clip_rects.PosClipRect())); } if (box.HasClip()) { - LayoutRect new_clip = box.ClipRect(offset); + PhysicalRect new_clip = box.ClipRect(offset); clip_rects.SetPosClipRect(Intersection(new_clip, clip_rects.PosClipRect())); clip_rects.SetOverflowClipRect( Intersection(new_clip, clip_rects.OverflowClipRect())); @@ -213,7 +213,7 @@ } } -LayoutRect PaintLayerClipper::LocalClipRect( +PhysicalRect PaintLayerClipper::LocalClipRect( const PaintLayer& clipping_root_layer) const { ClipRectsContext context( &clipping_root_layer, @@ -228,11 +228,11 @@ if (clip_rect.IsInfinite()) return clip_rect.Rect(); - LayoutRect premapped_rect = clip_rect.Rect(); + PhysicalRect premapped_rect = clip_rect.Rect(); // The rect now needs to be transformed to the local space of this // PaintLayer. // TODO(chrishtr): not correct for fragmentation. - premapped_rect.MoveBy(context.root_fragment->PaintOffset()); + premapped_rect.Move(context.root_fragment->PaintOffset()); const auto& clip_root_layer_transform = context.root_fragment->LocalBorderBoxProperties().Transform(); @@ -248,10 +248,10 @@ clipped_rect_in_local_space.MoveBy( -FloatPoint(layer_.GetLayoutObject().FirstFragment().PaintOffset())); - return LayoutRect(clipped_rect_in_local_space); + return PhysicalRect::EnclosingRect(clipped_rect_in_local_space); } - LayoutRect layer_bounds; + PhysicalRect layer_bounds; ClipRect background_rect, foreground_rect; CalculateRects(context, nullptr, nullptr, layer_bounds, background_rect, foreground_rect); @@ -259,10 +259,10 @@ if (background_rect.IsInfinite()) return background_rect.Rect(); - LayoutRect clip_rect = background_rect.Rect(); - LayoutPoint clipping_root_offset; + PhysicalRect clip_rect = background_rect.Rect(); + PhysicalOffset clipping_root_offset; layer_.ConvertToLayerCoords(&clipping_root_layer, clipping_root_offset); - clip_rect.MoveBy(-clipping_root_offset); + clip_rect.Move(-clipping_root_offset); return clip_rect; } @@ -271,24 +271,26 @@ const ClipRectsContext& context, const FragmentData& fragment_data, const CullRect* cull_rect, - LayoutRect& layer_bounds, + PhysicalRect& layer_bounds, ClipRect& background_rect, ClipRect& foreground_rect, - const LayoutPoint* offset_from_root) const { - layer_bounds.SetSize(LayoutSize(layer_.PixelSnappedSize())); + const PhysicalOffset* offset_from_root) const { + layer_bounds.size = PhysicalSize(layer_.PixelSnappedSize()); if (offset_from_root) { - layer_bounds.SetLocation(*offset_from_root); + layer_bounds.offset = *offset_from_root; } else { - layer_bounds.SetLocation(LayoutPoint(context.sub_pixel_accumulation)); + layer_bounds.offset = context.sub_pixel_accumulation; if (&layer_ == context.root_layer) { DCHECK_EQ(&fragment_data, context.root_fragment); } else { - layer_bounds.MoveBy(fragment_data.PaintOffset()); + layer_bounds.Move(fragment_data.PaintOffset()); + FloatRect float_bounds(layer_bounds); GeometryMapper::SourceToDestinationRect( fragment_data.PreTransform(), context.root_fragment->LocalBorderBoxProperties().Transform(), - layer_bounds); - layer_bounds.MoveBy(-context.root_fragment->PaintOffset()); + float_bounds); + layer_bounds = PhysicalRect::EnclosingRect(float_bounds); + layer_bounds.offset -= context.root_fragment->PaintOffset(); } } @@ -297,13 +299,13 @@ foreground_rect.Reset(); if (cull_rect) - background_rect.Intersect(LayoutRect(cull_rect->Rect())); + background_rect.Intersect(PhysicalRect(cull_rect->Rect())); if (ShouldClipOverflow(context)) { LayoutBoxModelObject& layout_object = layer_.GetLayoutObject(); foreground_rect = ToLayoutBox(layout_object) - .OverflowClipRect(layer_bounds.Location(), + .OverflowClipRect(layer_bounds.offset, context.overlay_scrollbar_clip_behavior); if (layout_object.StyleRef().HasBorderRadius()) foreground_rect.SetHasRadius(true); @@ -317,10 +319,10 @@ const ClipRectsContext& context, const FragmentData* fragment_data, const CullRect* cull_rect, - LayoutRect& layer_bounds, + PhysicalRect& layer_bounds, ClipRect& background_rect, ClipRect& foreground_rect, - const LayoutPoint* offset_from_root) const { + const PhysicalOffset* offset_from_root) const { // This feature is not supported for this method. DCHECK(context.respect_overflow_clip != kIgnoreOverflowClipAndScroll); if (use_geometry_mapper_) { @@ -344,20 +346,20 @@ background_rect.Move(context.sub_pixel_accumulation); } if (cull_rect) - background_rect.Intersect(LayoutRect(cull_rect->Rect())); + background_rect.Intersect(PhysicalRect(cull_rect->Rect())); foreground_rect = background_rect; - LayoutPoint offset(context.sub_pixel_accumulation); + PhysicalOffset offset(context.sub_pixel_accumulation); if (offset_from_root) offset = *offset_from_root; else layer_.ConvertToLayerCoords(context.root_layer, offset); - layer_bounds = LayoutRect(offset, LayoutSize(layer_.PixelSnappedSize())); + layer_bounds = PhysicalRect(offset, PhysicalSize(layer_.PixelSnappedSize())); // Update the clip rects that will be passed to child layers. if (ShouldClipOverflow(context)) { - LayoutRect overflow_and_clip_rect = + PhysicalRect overflow_and_clip_rect = ToLayoutBox(layout_object) .OverflowClipRect(offset, context.overlay_scrollbar_clip_behavior); foreground_rect.Intersect(overflow_and_clip_rect); @@ -367,8 +369,8 @@ // FIXME: Does not do the right thing with columns yet, since we don't yet // factor in the individual column boxes as overflow. - LayoutRect layer_bounds_with_visual_overflow = LocalVisualRect(context); - layer_bounds_with_visual_overflow.MoveBy(offset); + PhysicalRect layer_bounds_with_visual_overflow = LocalVisualRect(context); + layer_bounds_with_visual_overflow.Move(offset); background_rect.Intersect(layer_bounds_with_visual_overflow); } @@ -376,7 +378,7 @@ // even if it falls outside of the border box. if (layout_object.HasClip()) { // Clip applies to *us* as well, so go ahead and update the damageRect. - LayoutRect new_pos_clip = ToLayoutBox(layout_object).ClipRect(offset); + PhysicalRect new_pos_clip = ToLayoutBox(layout_object).ClipRect(offset); background_rect.Intersect(new_pos_clip); foreground_rect.Intersect(new_pos_clip); } @@ -388,7 +390,7 @@ bool is_clipping_root = &layer_ == context.root_layer; if (is_clipping_root && !context.ShouldRespectRootLayerClip()) { - clip_rects.Reset(LayoutRect(LayoutRect::InfiniteIntRect())); + clip_rects.Reset(PhysicalRect(LayoutRect::InfiniteIntRect())); if (layout_object.StyleRef().GetPosition() == EPosition::kFixed) clip_rects.SetFixed(true); return; @@ -404,7 +406,7 @@ PaintLayerClipper(*parent_layer, use_geometry_mapper_) .GetOrCalculateClipRects(context, clip_rects); } else { - clip_rects.Reset(LayoutRect(LayoutRect::InfiniteIntRect())); + clip_rects.Reset(PhysicalRect(LayoutRect::InfiniteIntRect())); } AdjustClipRectsForChildren(layout_object, clip_rects); @@ -416,16 +418,16 @@ // rootLayer may be across some transformed layer boundary, for example, in // the PaintLayerCompositor overlapMap, where clipRects are needed in view // space. - LayoutPoint offset(layout_object.LocalToAncestorPoint( - FloatPoint(), &context.root_layer->GetLayoutObject())); + FloatPoint offset = layout_object.LocalToAncestorPoint( + FloatPoint(), &context.root_layer->GetLayoutObject()); if (context.respect_overflow_clip == kIgnoreOverflowClipAndScroll && context.root_layer->GetScrollableArea() && layer_.IsAffectedByScrollOf(context.root_layer)) { - offset.Move(LayoutSize( - context.root_layer->GetScrollableArea()->GetScrollOffset())); + offset += context.root_layer->GetScrollableArea()->GetScrollOffset(); } - ApplyClipRects(context, layout_object, offset, clip_rects); + ApplyClipRects(context, layout_object, + PhysicalOffset::FromFloatPointRound(offset), clip_rects); } } @@ -503,12 +505,12 @@ if (!output.IsInfinite()) { // TODO(chrishtr): generalize to multiple fragments. - output.MoveBy(-context.root_fragment->PaintOffset()); + output.Move(-context.root_fragment->PaintOffset()); output.Move(context.sub_pixel_accumulation); } } -LayoutRect PaintLayerClipper::LocalVisualRect( +PhysicalRect PaintLayerClipper::LocalVisualRect( const ClipRectsContext& context) const { const LayoutObject& layout_object = layer_.GetLayoutObject(); // The LayoutView or Global Root Scroller is special since its overflow @@ -528,7 +530,7 @@ layer_bounds_with_visual_overflow = layer_.MapRectForFilter(layer_bounds_with_visual_overflow); } - return layer_bounds_with_visual_overflow.ToLayoutRect(); + return layer_bounds_with_visual_overflow; } void PaintLayerClipper::CalculateBackgroundClipRect( @@ -551,7 +553,7 @@ scoped_refptr<ClipRects> parent_clip_rects = ClipRects::Create(); if (&layer_ == context.root_layer) { - parent_clip_rects->Reset(LayoutRect(LayoutRect::InfiniteIntRect())); + parent_clip_rects->Reset(PhysicalRect(LayoutRect::InfiniteIntRect())); } else { PaintLayerClipper(*layer_.Parent(), use_geometry_mapper_) .GetOrCalculateClipRects(context, *parent_clip_rects); @@ -565,8 +567,8 @@ // accidentally no longer be considered infinite. if (parent_clip_rects->Fixed() && &context.root_layer->GetLayoutObject() == layout_view && - output != LayoutRect(LayoutRect::InfiniteIntRect())) - output.Move(layout_view->OffsetForFixedPosition().ToLayoutSize()); + output != PhysicalRect(LayoutRect::InfiniteIntRect())) + output.Move(layout_view->OffsetForFixedPosition()); } void PaintLayerClipper::GetOrCalculateClipRects(const ClipRectsContext& context,
diff --git a/third_party/blink/renderer/core/paint/paint_layer_clipper.h b/third_party/blink/renderer/core/paint/paint_layer_clipper.h index 86f9cc88..7f7f2c9 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_clipper.h +++ b/third_party/blink/renderer/core/paint/paint_layer_clipper.h
@@ -74,12 +74,12 @@ kIgnorePlatformOverlayScrollbarSize, ShouldRespectOverflowClipType root_layer_clip_behavior = kRespectOverflowClip, - const LayoutSize& accumulation = LayoutSize()) + const PhysicalOffset& sub_pixel_accumulation = PhysicalOffset()) : root_layer(root), root_fragment(fragment), overlay_scrollbar_clip_behavior(overlay_scrollbar_clip_behavior), cache_slot_(slot), - sub_pixel_accumulation(accumulation), + sub_pixel_accumulation(sub_pixel_accumulation), respect_overflow_clip(root_layer_clip_behavior) {} bool UsesCache() const { return cache_slot_ != kUncachedClipRects; } @@ -96,7 +96,7 @@ friend class PaintLayerClipper; ClipRectsCacheSlot cache_slot_; - LayoutSize sub_pixel_accumulation; + PhysicalOffset sub_pixel_accumulation; ShouldRespectOverflowClipType respect_overflow_clip; }; @@ -175,7 +175,7 @@ // Returns the background clip rect of the layer in the local coordinate // space. Only looks for clips up to the given ancestor. - LayoutRect LocalClipRect(const PaintLayer& ancestor_layer) const; + PhysicalRect LocalClipRect(const PaintLayer& ancestor_layer) const; // Computes the same thing as backgroundRect in calculateRects(), but skips // applying CSS clip and the visualOverflowRect() of |m_layer|. @@ -194,10 +194,10 @@ void CalculateRects(const ClipRectsContext&, const FragmentData*, const CullRect* cull_rect, - LayoutRect& layer_bounds, + PhysicalRect& layer_bounds, ClipRect& background_rect, ClipRect& foreground_rect, - const LayoutPoint* offset_from_root = nullptr) const; + const PhysicalOffset* offset_from_root = nullptr) const; private: void ClearCache(ClipRectsCacheSlot); @@ -225,14 +225,14 @@ const ClipRectsContext&, const FragmentData&, const CullRect* cull_rect, - LayoutRect& layer_bounds, + PhysicalRect& layer_bounds, ClipRect& background_rect, ClipRect& foreground_rect, - const LayoutPoint* offset_from_root = nullptr) const; + const PhysicalOffset* offset_from_root = nullptr) const; // Returns the visual rect of |layer_| in local space. This includes // filter effects if needed. - ALWAYS_INLINE LayoutRect LocalVisualRect(const ClipRectsContext&) const; + ALWAYS_INLINE PhysicalRect LocalVisualRect(const ClipRectsContext&) const; const PaintLayer& layer_; bool use_geometry_mapper_;
diff --git a/third_party/blink/renderer/core/paint/paint_layer_clipper_test.cc b/third_party/blink/renderer/core/paint/paint_layer_clipper_test.cc index eb611e3..d97067a 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_clipper_test.cc +++ b/third_party/blink/renderer/core/paint/paint_layer_clipper_test.cc
@@ -46,14 +46,15 @@ GetDocument().GetLayoutView()->Layer(), &GetDocument().GetLayoutView()->FirstFragment(), kUncachedClipRects, kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClip, - LayoutSize(FloatSize(0.25, 0.35))); + PhysicalOffset(LayoutUnit(0.25), LayoutUnit(0.35))); ClipRect background_rect_gm; target_paint_layer ->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) .CalculateBackgroundClipRect(context, background_rect_gm); - EXPECT_EQ(LayoutRect(FloatRect(8.25, 8.34375, 300, 300)), + EXPECT_EQ(PhysicalRect(LayoutUnit(8.25), LayoutUnit(8.34375), LayoutUnit(300), + LayoutUnit(300)), background_rect_gm.Rect()); ClipRect background_rect_nogm; @@ -61,7 +62,8 @@ ->Clipper(PaintLayer::GeometryMapperOption::kDoNotUseGeometryMapper) .CalculateBackgroundClipRect(context, background_rect_nogm); - EXPECT_EQ(LayoutRect(FloatRect(8.25, 8.34375, 300, 300)), + EXPECT_EQ(PhysicalRect(LayoutUnit(8.25), LayoutUnit(8.34375), LayoutUnit(300), + LayoutUnit(300)), background_rect_nogm.Rect()); } @@ -78,23 +80,23 @@ GetDocument().GetLayoutView()->Layer(), &GetDocument().GetLayoutView()->FirstFragment(), kUncachedClipRects, kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClip, - LayoutSize(FloatSize(0.25, 0.35))); + PhysicalOffset(LayoutUnit(0.25), LayoutUnit(0.35))); ClipRect background_rect_gm; target_paint_layer ->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) .CalculateBackgroundClipRect(context, background_rect_gm); - EXPECT_GE(background_rect_gm.Rect().Size().Width().ToInt(), 33554422); - EXPECT_GE(background_rect_gm.Rect().Size().Height().ToInt(), 33554422); + EXPECT_GE(background_rect_gm.Rect().Width().ToInt(), 33554422); + EXPECT_GE(background_rect_gm.Rect().Height().ToInt(), 33554422); ClipRect background_rect_nogm; target_paint_layer ->Clipper(PaintLayer::GeometryMapperOption::kDoNotUseGeometryMapper) .CalculateBackgroundClipRect(context, background_rect_nogm); - EXPECT_GE(background_rect_nogm.Rect().Size().Width().ToInt(), 33554422); - EXPECT_GE(background_rect_nogm.Rect().Size().Height().ToInt(), 33554422); + EXPECT_GE(background_rect_nogm.Rect().Width().ToInt(), 33554422); + EXPECT_GE(background_rect_nogm.Rect().Height().ToInt(), 33554422); } TEST_F(PaintLayerClipperTest, SVGBackgroundClipRectSubpixelAccumulation) { @@ -112,23 +114,23 @@ GetDocument().GetLayoutView()->Layer(), &GetDocument().GetLayoutView()->FirstFragment(), kUncachedClipRects, kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClip, - LayoutSize(FloatSize(0.25, 0.35))); + PhysicalOffset(LayoutUnit(0.25), LayoutUnit(0.35))); ClipRect background_rect_gm; target_paint_layer ->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) .CalculateBackgroundClipRect(context, background_rect_gm); - EXPECT_GE(background_rect_gm.Rect().Size().Width().ToInt(), 33554422); - EXPECT_GE(background_rect_gm.Rect().Size().Height().ToInt(), 33554422); + EXPECT_GE(background_rect_gm.Rect().Width().ToInt(), 33554422); + EXPECT_GE(background_rect_gm.Rect().Height().ToInt(), 33554422); ClipRect background_rect_nogm; target_paint_layer ->Clipper(PaintLayer::GeometryMapperOption::kDoNotUseGeometryMapper) .CalculateBackgroundClipRect(context, background_rect_nogm); - EXPECT_GE(background_rect_nogm.Rect().Size().Width().ToInt(), 33554422); - EXPECT_GE(background_rect_nogm.Rect().Size().Height().ToInt(), 33554422); + EXPECT_GE(background_rect_nogm.Rect().Width().ToInt(), 33554422); + EXPECT_GE(background_rect_nogm.Rect().Height().ToInt(), 33554422); } TEST_F(PaintLayerClipperTest, LayoutSVGRoot) { @@ -148,8 +150,8 @@ GetDocument().GetLayoutView()->Layer(), &GetDocument().GetLayoutView()->FirstFragment(), kUncachedClipRects, kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClip, - LayoutSize(FloatSize(0.25, 0.35))); - LayoutRect layer_bounds; + PhysicalOffset(LayoutUnit(0.25), LayoutUnit(0.35))); + PhysicalRect layer_bounds; ClipRect background_rect, foreground_rect; target_paint_layer @@ -158,11 +160,15 @@ &target_paint_layer->GetLayoutObject().FirstFragment(), nullptr, layer_bounds, background_rect, foreground_rect); - EXPECT_EQ(LayoutRect(FloatRect(8.25, 8.35, 200, 300)), + EXPECT_EQ(PhysicalRect(LayoutUnit(8.25), LayoutUnit(8.35), LayoutUnit(200), + LayoutUnit(300)), background_rect.Rect()); - EXPECT_EQ(LayoutRect(FloatRect(8.25, 8.35, 200, 300)), + EXPECT_EQ(PhysicalRect(LayoutUnit(8.25), LayoutUnit(8.35), LayoutUnit(200), + LayoutUnit(300)), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(FloatRect(8.25, 8.35, 200, 300)), layer_bounds); + EXPECT_EQ(PhysicalRect(LayoutUnit(8.25), LayoutUnit(8.35), LayoutUnit(200), + LayoutUnit(300)), + layer_bounds); } TEST_F(PaintLayerClipperTest, ControlClip) { @@ -180,7 +186,7 @@ GetDocument().GetLayoutView()->Layer(), &GetDocument().GetLayoutView()->FirstFragment(), kUncachedClipRects, kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClip); - LayoutRect layer_bounds; + PhysicalRect layer_bounds; ClipRect background_rect, foreground_rect; target_paint_layer @@ -191,17 +197,17 @@ #if defined(OS_MACOSX) // If the PaintLayer clips overflow, the background rect is intersected with // the PaintLayer bounds... - EXPECT_EQ(LayoutRect(3, 4, 210, 28), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(3, 4, 210, 28), background_rect.Rect()); // and the foreground rect is intersected with the control clip in this case. - EXPECT_EQ(LayoutRect(8, 8, 200, 18), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(8, 8, 200, 18), layer_bounds); + EXPECT_EQ(PhysicalRect(8, 8, 200, 18), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(8, 8, 200, 18), layer_bounds); #else // If the PaintLayer clips overflow, the background rect is intersected with // the PaintLayer bounds... - EXPECT_EQ(LayoutRect(8, 8, 200, 300), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(8, 8, 200, 300), background_rect.Rect()); // and the foreground rect is intersected with the control clip in this case. - EXPECT_EQ(LayoutRect(10, 10, 196, 296), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(8, 8, 200, 300), layer_bounds); + EXPECT_EQ(PhysicalRect(10, 10, 196, 296), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(8, 8, 200, 300), layer_bounds); #endif } @@ -221,7 +227,7 @@ &GetDocument().GetLayoutView()->FirstFragment(), kUncachedClipRects, kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClip); - LayoutRect layer_bounds; + PhysicalRect layer_bounds; ClipRect background_rect, foreground_rect; target_paint_layer @@ -232,11 +238,11 @@ // Only the foreground rect gets hasRadius set for overflow clipping // of descendants. - EXPECT_EQ(LayoutRect(8, 8, 200, 300), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(8, 8, 200, 300), background_rect.Rect()); EXPECT_FALSE(background_rect.HasRadius()); - EXPECT_EQ(LayoutRect(8, 8, 200, 300), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(8, 8, 200, 300), foreground_rect.Rect()); EXPECT_TRUE(foreground_rect.HasRadius()); - EXPECT_EQ(LayoutRect(8, 8, 200, 300), layer_bounds); + EXPECT_EQ(PhysicalRect(8, 8, 200, 300), layer_bounds); } TEST_F(PaintLayerClipperTest, RoundedClipNested) { @@ -263,7 +269,7 @@ &parent_paint_layer->GetLayoutObject().FirstFragment(), kUncachedClipRects); - LayoutRect layer_bounds; + PhysicalRect layer_bounds; ClipRect background_rect, foreground_rect; child_paint_layer @@ -272,11 +278,11 @@ &child_paint_layer->GetLayoutObject().FirstFragment(), nullptr, layer_bounds, background_rect, foreground_rect); - EXPECT_EQ(LayoutRect(0, 0, 200, 300), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 200, 300), background_rect.Rect()); EXPECT_TRUE(background_rect.HasRadius()); - EXPECT_EQ(LayoutRect(0, 0, 200, 300), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 200, 300), foreground_rect.Rect()); EXPECT_TRUE(foreground_rect.HasRadius()); - EXPECT_EQ(LayoutRect(0, 0, 500, 500), layer_bounds); + EXPECT_EQ(PhysicalRect(0, 0, 500, 500), layer_bounds); } // TODO(https://crbug.com/795645): This test is failing on the ChromeOS bot. @@ -301,7 +307,7 @@ &GetDocument().GetLayoutView()->FirstFragment(), kUncachedClipRects, kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClip); - LayoutRect layer_bounds; + PhysicalRect layer_bounds; ClipRect background_rect, foreground_rect; target_paint_layer @@ -311,11 +317,11 @@ nullptr, layer_bounds, background_rect, foreground_rect); // The control clip for a select excludes the area for the down arrow. #if defined(OS_MACOSX) - EXPECT_EQ(LayoutRect(16, 9, 79, 13), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(16, 9, 79, 13), foreground_rect.Rect()); #elif defined(OS_WIN) - EXPECT_EQ(LayoutRect(17, 9, 60, 16), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(17, 9, 60, 16), foreground_rect.Rect()); #else - EXPECT_EQ(LayoutRect(17, 9, 60, 15), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(17, 9, 60, 15), foreground_rect.Rect()); #endif } // namespace blink @@ -335,7 +341,7 @@ ClipRectsContext context(GetDocument().GetLayoutView()->Layer(), &GetDocument().GetLayoutView()->FirstFragment(), kUncachedClipRects); - LayoutRect layer_bounds; + PhysicalRect layer_bounds; ClipRect background_rect, foreground_rect; target_paint_layer @@ -343,9 +349,9 @@ .CalculateRects(context, &target_paint_layer->GetLayoutObject().FirstFragment(), nullptr, layer_bounds, background_rect, foreground_rect); - EXPECT_EQ(LayoutRect(8, 8, 200, 300), background_rect.Rect()); - EXPECT_EQ(LayoutRect(8, 8, 200, 300), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(8, 8, 400, 0), layer_bounds); + EXPECT_EQ(PhysicalRect(8, 8, 200, 300), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(8, 8, 200, 300), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(8, 8, 400, 0), layer_bounds); } TEST_F(PaintLayerClipperTest, ContainPaintClip) { @@ -362,16 +368,16 @@ kPaintingClipRectsIgnoringOverflowClip, kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClip); - LayoutRect layer_bounds; + PhysicalRect layer_bounds; ClipRect background_rect, foreground_rect; layer->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) .CalculateRects(context, &layer->GetLayoutObject().FirstFragment(), nullptr, layer_bounds, background_rect, foreground_rect); - EXPECT_GE(background_rect.Rect().Size().Width().ToInt(), 33554422); - EXPECT_GE(background_rect.Rect().Size().Height().ToInt(), 33554422); + EXPECT_GE(background_rect.Rect().Width().ToInt(), 33554422); + EXPECT_GE(background_rect.Rect().Height().ToInt(), 33554422); EXPECT_EQ(background_rect.Rect(), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 200, 200), layer_bounds); + EXPECT_EQ(PhysicalRect(0, 0, 200, 200), layer_bounds); ClipRectsContext context_clip( layer, &layer->GetLayoutObject().FirstFragment(), kUncachedClipRects); @@ -379,9 +385,9 @@ layer->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) .CalculateRects(context_clip, &layer->GetLayoutObject().FirstFragment(), nullptr, layer_bounds, background_rect, foreground_rect); - EXPECT_EQ(LayoutRect(0, 0, 200, 200), background_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 200, 200), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 200, 200), layer_bounds); + EXPECT_EQ(PhysicalRect(0, 0, 200, 200), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 200, 200), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 200, 200), layer_bounds); } TEST_F(PaintLayerClipperTest, NestedContainPaintClip) { @@ -399,15 +405,15 @@ layer->Parent(), &layer->Parent()->GetLayoutObject().FirstFragment(), kPaintingClipRectsIgnoringOverflowClip, kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClip); - LayoutRect layer_bounds; + PhysicalRect layer_bounds; ClipRect background_rect, foreground_rect; layer->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) .CalculateRects(context, &layer->GetLayoutObject().FirstFragment(), nullptr, layer_bounds, background_rect, foreground_rect); - EXPECT_EQ(LayoutRect(0, 0, 200, 400), background_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 200, 400), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 200, 400), layer_bounds); + EXPECT_EQ(PhysicalRect(0, 0, 200, 400), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 200, 400), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 200, 400), layer_bounds); ClipRectsContext context_clip( layer->Parent(), &layer->Parent()->GetLayoutObject().FirstFragment(), @@ -416,9 +422,9 @@ layer->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) .CalculateRects(context_clip, &layer->GetLayoutObject().FirstFragment(), nullptr, layer_bounds, background_rect, foreground_rect); - EXPECT_EQ(LayoutRect(0, 0, 200, 200), background_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 200, 200), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 200, 400), layer_bounds); + EXPECT_EQ(PhysicalRect(0, 0, 200, 200), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 200, 200), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 200, 400), layer_bounds); } TEST_F(PaintLayerClipperTest, LocalClipRectFixedUnderTransform) { @@ -440,10 +446,10 @@ ToLayoutBoxModelObject(GetLayoutObjectByElementId("fixed"))->Layer(); EXPECT_EQ( - LayoutRect(0, 0, 100, 100), + PhysicalRect(0, 0, 100, 100), transformed->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) .LocalClipRect(*transformed)); - EXPECT_EQ(LayoutRect(0, 50, 100, 100), + EXPECT_EQ(PhysicalRect(0, 50, 100, 100), fixed->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) .LocalClipRect(*transformed)); } @@ -534,16 +540,16 @@ ToLayoutBoxModelObject(GetLayoutObjectByElementId("target"))->Layer(); ClipRectsContext context(target, &target->GetLayoutObject().FirstFragment(), kUncachedClipRects); - LayoutRect infinite_rect(LayoutRect::InfiniteIntRect()); - LayoutRect layer_bounds(infinite_rect); + PhysicalRect infinite_rect(LayoutRect::InfiniteIntRect()); + PhysicalRect layer_bounds(infinite_rect); ClipRect background_rect(infinite_rect); ClipRect foreground_rect(infinite_rect); target->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) .CalculateRects(context, &target->GetLayoutObject().FirstFragment(), nullptr, layer_bounds, background_rect, foreground_rect); - EXPECT_EQ(LayoutRect(0, 0, 50, 100), background_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 50, 100), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 50, 100), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 50, 100), foreground_rect.Rect()); } TEST_F(PaintLayerClipperTest, Filter) { @@ -564,8 +570,8 @@ // First test clip rects in the target layer itself. ClipRectsContext context(target, &target->GetLayoutObject().FirstFragment(), kUncachedClipRects); - LayoutRect infinite_rect(LayoutRect::InfiniteIntRect()); - LayoutRect layer_bounds(infinite_rect); + PhysicalRect infinite_rect(LayoutRect::InfiniteIntRect()); + PhysicalRect layer_bounds(infinite_rect); ClipRect background_rect(infinite_rect); ClipRect foreground_rect(infinite_rect); target->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) @@ -575,10 +581,10 @@ // The background rect is used to clip stacking context (layer) output. // In this case, nothing is above us, thus the infinite rect. However we do // clip to the layer's after-filter visual rect as an optimization. - EXPECT_EQ(LayoutRect(-12, -9, 204, 304), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(-12, -9, 204, 304), background_rect.Rect()); // The foreground rect is used to clip the normal flow contents of the // stacking context (layer) thus including the overflow clip. - EXPECT_EQ(LayoutRect(40, 40, 100, 200), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(40, 40, 100, 200), foreground_rect.Rect()); // Test without GeometryMapper. background_rect = infinite_rect; @@ -588,8 +594,8 @@ foreground_rect); // The non-GeometryMapper path applies the immediate filter effect in // background rect. - EXPECT_EQ(LayoutRect(-12, -9, 204, 304), background_rect.Rect()); - EXPECT_EQ(LayoutRect(40, 40, 100, 200), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(-12, -9, 204, 304), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(40, 40, 100, 200), foreground_rect.Rect()); // Test mapping to the root layer. ClipRectsContext root_context(GetLayoutView().Layer(), @@ -602,8 +608,8 @@ nullptr, layer_bounds, background_rect, foreground_rect); // This includes the filter effect because it's applied before mapping the // background rect to the root layer. - EXPECT_EQ(LayoutRect(38, 41, 204, 304), background_rect.Rect()); - EXPECT_EQ(LayoutRect(90, 90, 100, 200), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(38, 41, 204, 304), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(90, 90, 100, 200), foreground_rect.Rect()); // Test mapping to the root layer without GeometryMapper. background_rect = infinite_rect; @@ -611,15 +617,15 @@ target->Clipper(PaintLayer::GeometryMapperOption::kDoNotUseGeometryMapper) .CalculateRects(root_context, nullptr, nullptr, layer_bounds, background_rect, foreground_rect); - EXPECT_EQ(LayoutRect(38, 41, 204, 304), background_rect.Rect()); - EXPECT_EQ(LayoutRect(90, 90, 100, 200), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(38, 41, 204, 304), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(90, 90, 100, 200), foreground_rect.Rect()); } // Computed infinite clip rects may not match LayoutRect::InfiniteIntRect() // due to floating point errors. -static bool IsInfinite(const LayoutRect& rect) { - return rect.X().Round() < -10000000 && rect.MaxX().Round() > 10000000 && - rect.Y().Round() < -10000000 && rect.MaxY().Round() > 10000000; +static bool IsInfinite(const PhysicalRect& rect) { + return rect.X().Round() < -10000000 && rect.Right().Round() > 10000000 && + rect.Y().Round() < -10000000 && rect.Bottom().Round() > 10000000; } TEST_F(PaintLayerClipperTest, IgnoreRootLayerClipWithCSSClip) { @@ -646,8 +652,8 @@ kPaintingClipRectsIgnoringOverflowClip, kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClip); - LayoutRect infinite_rect(LayoutRect::InfiniteIntRect()); - LayoutRect layer_bounds(infinite_rect); + PhysicalRect infinite_rect(LayoutRect::InfiniteIntRect()); + PhysicalRect layer_bounds(infinite_rect); ClipRect background_rect(infinite_rect); ClipRect foreground_rect(infinite_rect); target->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) @@ -682,8 +688,8 @@ kPaintingClipRectsIgnoringOverflowClip, kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClip); - LayoutRect infinite_rect(LayoutRect::InfiniteIntRect()); - LayoutRect layer_bounds(infinite_rect); + PhysicalRect infinite_rect(LayoutRect::InfiniteIntRect()); + PhysicalRect layer_bounds(infinite_rect); ClipRect background_rect(infinite_rect); ClipRect foreground_rect(infinite_rect); target->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) @@ -719,8 +725,8 @@ kPaintingClipRectsIgnoringOverflowClip, kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClip); - LayoutRect infinite_rect(LayoutRect::InfiniteIntRect()); - LayoutRect layer_bounds(infinite_rect); + PhysicalRect infinite_rect(LayoutRect::InfiniteIntRect()); + PhysicalRect layer_bounds(infinite_rect); ClipRect background_rect(infinite_rect); ClipRect foreground_rect(infinite_rect); target->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) @@ -748,7 +754,7 @@ ClipRectsContext context( root_paint_layer, &root_paint_layer->GetLayoutObject().FirstFragment(), kUncachedClipRects, kIgnorePlatformOverlayScrollbarSize); - LayoutRect layer_bounds; + PhysicalRect layer_bounds; ClipRect background_rect, foreground_rect; Element* target = GetDocument().getElementById("target"); @@ -767,11 +773,11 @@ &target_paint_layer->GetLayoutObject().FirstFragment(), nullptr, layer_bounds, background_rect, foreground_rect); - EXPECT_EQ(LayoutRect(FloatRect(-1.0e6, -1.0e6, 2.0000e6, 1.0001e6)), + EXPECT_EQ(PhysicalRect(-1000000, -1000000, 2000000, 1000100), background_rect.Rect()); - EXPECT_EQ(LayoutRect(FloatRect(-1.0e6, -1.0e6, 2.0000e6, 1.0001e6)), + EXPECT_EQ(PhysicalRect(-1000000, -1000000, 2000000, 1000100), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(FloatRect(0, 0, 100, 200)), layer_bounds); + EXPECT_EQ(PhysicalRect(0, 0, 100, 200), layer_bounds); target_paint_layer ->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) @@ -780,12 +786,10 @@ target_paint_layer->GetLayoutObject().FirstFragment().NextFragment(), nullptr, layer_bounds, background_rect, foreground_rect); - EXPECT_EQ(LayoutRect(FloatRect(-999900, 0, 2000000, 999900)), - background_rect.Rect()); - EXPECT_EQ(LayoutRect(FloatRect(-999900, 0, 2000000, 999900)), - foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(-999900, 0, 2000000, 999900), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(-999900, 0, 2000000, 999900), foreground_rect.Rect()); // Layer bounds adjusted for pagination offset of second fragment. - EXPECT_EQ(LayoutRect(FloatRect(100, -100, 100, 200)), layer_bounds); + EXPECT_EQ(PhysicalRect(100, -100, 100, 200), layer_bounds); } TEST_F(PaintLayerClipperTest, ScrollbarClipBehaviorChild) { @@ -812,7 +816,7 @@ &parent_paint_layer->GetLayoutObject().FirstFragment(), kUncachedClipRects, kExcludeOverlayScrollbarSizeForHitTesting); - LayoutRect layer_bounds; + PhysicalRect layer_bounds; ClipRect background_rect, foreground_rect; child_paint_layer ->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) @@ -821,9 +825,9 @@ nullptr, layer_bounds, background_rect, foreground_rect); // The background and foreground rect are clipped by the scrollbar size. - EXPECT_EQ(LayoutRect(0, 0, 193, 293), background_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 193, 293), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 500, 500), layer_bounds); + EXPECT_EQ(PhysicalRect(0, 0, 193, 293), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 193, 293), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 500, 500), layer_bounds); child_paint_layer ->Clipper(PaintLayer::GeometryMapperOption::kDoNotUseGeometryMapper) @@ -831,9 +835,9 @@ foreground_rect); // The background and foreground rect are clipped by the scrollbar size. - EXPECT_EQ(LayoutRect(0, 0, 193, 293), background_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 193, 293), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 500, 500), layer_bounds); + EXPECT_EQ(PhysicalRect(0, 0, 193, 293), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 193, 293), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 500, 500), layer_bounds); } TEST_F(PaintLayerClipperTest, ScrollbarClipBehaviorChildScrollBetween) { @@ -858,7 +862,7 @@ root_paint_layer, &root_paint_layer->GetLayoutObject().FirstFragment(), kUncachedClipRects, kExcludeOverlayScrollbarSizeForHitTesting); - LayoutRect layer_bounds; + PhysicalRect layer_bounds; ClipRect background_rect, foreground_rect; child_paint_layer ->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) @@ -867,9 +871,9 @@ nullptr, layer_bounds, background_rect, foreground_rect); // The background and foreground rect are clipped by the scrollbar size. - EXPECT_EQ(LayoutRect(8, 8, 193, 293), background_rect.Rect()); - EXPECT_EQ(LayoutRect(8, 8, 193, 293), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(8, 8, 500, 500), layer_bounds); + EXPECT_EQ(PhysicalRect(8, 8, 193, 293), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(8, 8, 193, 293), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(8, 8, 500, 500), layer_bounds); child_paint_layer ->Clipper(PaintLayer::GeometryMapperOption::kDoNotUseGeometryMapper) @@ -877,9 +881,9 @@ foreground_rect); // The background and foreground rect are clipped by the scrollbar size. - EXPECT_EQ(LayoutRect(8, 8, 193, 293), background_rect.Rect()); - EXPECT_EQ(LayoutRect(8, 8, 193, 293), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(8, 8, 500, 500), layer_bounds); + EXPECT_EQ(PhysicalRect(8, 8, 193, 293), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(8, 8, 193, 293), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(8, 8, 500, 500), layer_bounds); } TEST_F(PaintLayerClipperTest, ScrollbarClipBehaviorParent) { @@ -902,7 +906,7 @@ &parent_paint_layer->GetLayoutObject().FirstFragment(), kUncachedClipRects, kExcludeOverlayScrollbarSizeForHitTesting); - LayoutRect layer_bounds; + PhysicalRect layer_bounds; ClipRect background_rect, foreground_rect; parent_paint_layer ->Clipper(PaintLayer::GeometryMapperOption::kUseGeometryMapper) @@ -912,9 +916,9 @@ // Only the foreground is clipped by the scrollbar size, because we // called CalculateRects on the root layer. - EXPECT_EQ(LayoutRect(0, 0, 200, 300), background_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 193, 293), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 200, 300), layer_bounds); + EXPECT_EQ(PhysicalRect(0, 0, 200, 300), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 193, 293), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 200, 300), layer_bounds); parent_paint_layer ->Clipper(PaintLayer::GeometryMapperOption::kDoNotUseGeometryMapper) @@ -923,9 +927,9 @@ // Only the foreground is clipped by the scrollbar size, because we // called CalculateRects on the root layer. - EXPECT_EQ(LayoutRect(0, 0, 200, 300), background_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 193, 293), foreground_rect.Rect()); - EXPECT_EQ(LayoutRect(0, 0, 200, 300), layer_bounds); + EXPECT_EQ(PhysicalRect(0, 0, 200, 300), background_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 193, 293), foreground_rect.Rect()); + EXPECT_EQ(PhysicalRect(0, 0, 200, 300), layer_bounds); } TEST_F(PaintLayerClipperTest, FixedLayerClipRectInDocumentSpace) { @@ -958,7 +962,7 @@ kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClipAndScroll), clip_rect); - EXPECT_EQ(LayoutRect(100, 250, 300, 400), clip_rect.Rect()); + EXPECT_EQ(PhysicalRect(100, 250, 300, 400), clip_rect.Rect()); } GetDocument().domWindow()->scrollTo(0, 100); @@ -974,7 +978,7 @@ kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClipAndScroll), clip_rect); - EXPECT_EQ(LayoutRect(100, 300, 300, 400), clip_rect.Rect()); + EXPECT_EQ(PhysicalRect(100, 300, 300, 400), clip_rect.Rect()); } } @@ -1012,7 +1016,7 @@ kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClipAndScroll), clip_rect); - EXPECT_EQ(LayoutRect(100, 250, 200, 300), clip_rect.Rect()); + EXPECT_EQ(PhysicalRect(100, 250, 200, 300), clip_rect.Rect()); } GetDocument().domWindow()->scrollTo(0, 100); @@ -1028,7 +1032,7 @@ kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClipAndScroll), clip_rect); - EXPECT_EQ(LayoutRect(100, 300, 200, 300), clip_rect.Rect()); + EXPECT_EQ(PhysicalRect(100, 300, 200, 300), clip_rect.Rect()); } } @@ -1068,7 +1072,7 @@ kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClipAndScroll), clip_rect); - EXPECT_EQ(LayoutRect(100, 208, 200, 300), clip_rect.Rect()); + EXPECT_EQ(PhysicalRect(100, 208, 200, 300), clip_rect.Rect()); } // At 50, target is still scrolling - clip_rect shouldn't change. @@ -1084,7 +1088,7 @@ kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClipAndScroll), clip_rect); - EXPECT_EQ(LayoutRect(100, 208, 200, 300), clip_rect.Rect()); + EXPECT_EQ(PhysicalRect(100, 208, 200, 300), clip_rect.Rect()); } // At 150, target is fixed - clip_rect should now increase. @@ -1100,7 +1104,7 @@ kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClipAndScroll), clip_rect); - EXPECT_EQ(LayoutRect(100, 250, 200, 300), clip_rect.Rect()); + EXPECT_EQ(PhysicalRect(100, 250, 200, 300), clip_rect.Rect()); } // At 250, target is still fixed - clip_rect should keep increasing. @@ -1116,7 +1120,7 @@ kIgnorePlatformOverlayScrollbarSize, kIgnoreOverflowClipAndScroll), clip_rect); - EXPECT_EQ(LayoutRect(100, 350, 200, 300), clip_rect.Rect()); + EXPECT_EQ(PhysicalRect(100, 350, 200, 300), clip_rect.Rect()); } }
diff --git a/third_party/blink/renderer/core/paint/paint_layer_fragment.h b/third_party/blink/renderer/core/paint/paint_layer_fragment.h index ba4eebf..a159871a 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_fragment.h +++ b/third_party/blink/renderer/core/paint/paint_layer_fragment.h
@@ -54,7 +54,7 @@ // The PaintLayer's size in the space defined by |root_fragment_data|. // See PaintLayer::size_ for the exact rectangle. - LayoutRect layer_bounds; + PhysicalRect layer_bounds; // The rectangle used to clip the background. //
diff --git a/third_party/blink/renderer/core/paint/paint_layer_painter.cc b/third_party/blink/renderer/core/paint/paint_layer_painter.cc index f5df2c61..0fde0ba 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_painter.cc +++ b/third_party/blink/renderer/core/paint/paint_layer_painter.cc
@@ -30,7 +30,7 @@ const GlobalPaintFlags global_paint_flags, PaintLayerFlags paint_flags) { PaintLayerPaintingInfo painting_info(&paint_layer_, cull_rect, - global_paint_flags, LayoutSize()); + global_paint_flags, PhysicalOffset()); if (!paint_layer_.PaintsIntoOwnOrGroupedBacking(global_paint_flags)) Paint(context, painting_info, paint_flags); } @@ -294,8 +294,7 @@ if (first_fragment.PaintProperties() && first_fragment.PaintProperties()->PaintOffsetTranslation()) { - painting_info.sub_pixel_accumulation = - ToLayoutSize(first_fragment.PaintOffset()); + painting_info.sub_pixel_accumulation = first_fragment.PaintOffset(); } } @@ -357,7 +356,7 @@ (!is_painting_overflow_contents && !is_painting_mask)) && paint_layer_.GetLayoutObject().StyleRef().HasOutline(); - LayoutSize subpixel_accumulation = + PhysicalOffset subpixel_accumulation = paint_layer_.GetCompositingState() == kPaintsIntoOwnBacking ? paint_layer_.SubpixelAccumulation() : painting_info.sub_pixel_accumulation; @@ -379,12 +378,12 @@ subsequence_recorder.emplace(context, paint_layer_); } - LayoutPoint offset_from_root; + PhysicalOffset offset_from_root; paint_layer_.ConvertToLayerCoords(painting_info.root_layer, offset_from_root); - offset_from_root.Move(subpixel_accumulation); + offset_from_root += subpixel_accumulation; - LayoutRect bounds = paint_layer_.PhysicalBoundingBox(offset_from_root); - if (!LayoutRect(painting_info.cull_rect.Rect()).Contains(bounds)) + PhysicalRect bounds = paint_layer_.PhysicalBoundingBox(offset_from_root); + if (!PhysicalRect(painting_info.cull_rect.Rect()).Contains(bounds)) result = kMayBeClippedByCullRect; // These helpers output clip and compositing operations using a RAII pattern. @@ -394,10 +393,10 @@ bool should_paint_clip_path = is_painting_mask && paint_layer_.GetLayoutObject().HasClipPath(); if (should_paint_clip_path) { - LayoutPoint visual_offset_from_root = + PhysicalOffset visual_offset_from_root = paint_layer_.EnclosingPaginationLayer() - ? paint_layer_.VisualOffsetFromAncestor( - painting_info.root_layer, LayoutPoint(subpixel_accumulation)) + ? paint_layer_.VisualOffsetFromAncestor(painting_info.root_layer, + subpixel_accumulation) : offset_from_root; clip_path_clipper.emplace(context, paint_layer_.GetLayoutObject(), visual_offset_from_root); @@ -420,7 +419,7 @@ is_painting_overlay_scrollbars) { // Collect the fragments. This will compute the clip rectangles and paint // offsets for each layer fragment. - LayoutPoint offset_to_clipper; + PhysicalOffset offset_to_clipper; const PaintLayer* paint_layer_for_fragments = &paint_layer_; if (paint_flags & kPaintLayerPaintingAncestorClippingMaskPhase) { // Compute fragments and their clips with respect to the outermost @@ -436,8 +435,8 @@ local_painting_info.root_layer = paint_layer_for_fragments; paint_layer_.ConvertToLayerCoords(local_painting_info.root_layer, offset_to_clipper); - LayoutRect new_cull_rect(local_painting_info.cull_rect.Rect()); - new_cull_rect.MoveBy(offset_to_clipper); + PhysicalRect new_cull_rect(local_painting_info.cull_rect.Rect()); + new_cull_rect.Move(offset_to_clipper); local_painting_info.cull_rect = CullRect(EnclosingIntRect(new_cull_rect)); // Overflow clip of the compositing container is irrelevant. respect_overflow_clip = kIgnoreOverflowClip; @@ -460,8 +459,7 @@ // layer's coordinate system, but for the rest of painting we need // them in the layer coordinate. So move them and the // foreground/background rects that are also in the clipper's space. - LayoutSize negative_offset(-offset_to_clipper.X(), - -offset_to_clipper.Y()); + PhysicalOffset negative_offset = -offset_to_clipper; for (auto& fragment : layer_fragments) { fragment.background_rect.Move(negative_offset); fragment.foreground_rect.Move(negative_offset); @@ -606,9 +604,9 @@ const GraphicsLayer* mask_layer = paint_layer_.GetCompositedLayerMapping()->MaskLayer(); - ClipRect layer_rect = LayoutRect( - LayoutPoint(LayoutSize(mask_layer->OffsetFromLayoutObject())), - LayoutSize(IntSize(mask_layer->Size()))); + ClipRect layer_rect = + PhysicalRect(PhysicalOffset(mask_layer->OffsetFromLayoutObject()), + PhysicalSize(IntSize(mask_layer->Size()))); FillMaskingFragment(context, layer_rect, *mask_layer); } @@ -638,7 +636,7 @@ PaintLayerFragments& fragments, const PaintLayerPaintingInfo& local_painting_info, PaintLayerFlags local_paint_flags, - const LayoutPoint& offset_from_root) { + const PhysicalOffset& offset_from_root) { if (&paint_layer_ == local_painting_info.root_layer && (local_paint_flags & kPaintLayerPaintingOverflowContents)) return true; @@ -723,7 +721,7 @@ // We need to apply the same clips and transforms that // paintFragmentWithPhase would have. - LayoutRect cull_rect = fragment.background_rect.Rect(); + PhysicalRect cull_rect = fragment.background_rect.Rect(); PaintInfo paint_info( context, PixelSnappedIntRect(cull_rect), PaintPhase::kSelfBlockBackgroundOnly, @@ -767,12 +765,12 @@ context.GetPaintController(), chunk_properties, paint_layer_, DisplayItem::PaintPhaseToDrawingType(phase)); - LayoutRect new_cull_rect(clip_rect.Rect()); + PhysicalRect new_cull_rect(clip_rect.Rect()); // Now |new_cull_rect| is in the pixel-snapped border box space of // |fragment.root_fragment_data|. Adjust it to the containing transform node's // space in which we will paint. - new_cull_rect.MoveBy( - RoundedIntPoint(fragment.root_fragment_data->PaintOffset())); + new_cull_rect.Move(PhysicalOffset( + RoundedIntPoint(fragment.root_fragment_data->PaintOffset()))); PaintInfo paint_info(context, PixelSnappedIntRect(new_cull_rect), phase, painting_info.GetGlobalPaintFlags(), paint_flags, @@ -907,7 +905,7 @@ ScopedPaintChunkProperties properties(context.GetPaintController(), state, client, DisplayItem::kClippingMask); ClipRect mask_rect = fragment.background_rect; - mask_rect.MoveBy(layer_fragment.PaintOffset()); + mask_rect.Move(layer_fragment.PaintOffset()); FillMaskingFragment(context, mask_rect, client); } @@ -946,7 +944,7 @@ return; PaintLayerPaintingInfo painting_info(&paint_layer_, cull_rect, paint_flags, - LayoutSize()); + PhysicalOffset()); Paint(context, painting_info, kPaintLayerPaintingOverlayScrollbars); paint_layer_.SetContainsDirtyOverlayScrollbars(false);
diff --git a/third_party/blink/renderer/core/paint/paint_layer_painter.h b/third_party/blink/renderer/core/paint/paint_layer_painter.h index 1b14e1c3..263079da 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_painter.h +++ b/third_party/blink/renderer/core/paint/paint_layer_painter.h
@@ -19,7 +19,7 @@ class DisplayItemClient; class PaintLayer; class GraphicsContext; -class LayoutPoint; +struct PhysicalOffset; // This class is responsible for painting self-painting PaintLayer. // @@ -68,7 +68,7 @@ PaintLayerFragments&, const PaintLayerPaintingInfo&, PaintLayerFlags, - const LayoutPoint& offset_from_root); + const PhysicalOffset& offset_from_root); void PaintFragmentWithPhase(PaintPhase, const PaintLayerFragment&, GraphicsContext&,
diff --git a/third_party/blink/renderer/core/paint/paint_layer_painting_info.h b/third_party/blink/renderer/core/paint/paint_layer_painting_info.h index bee6fa8e..661f807b 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_painting_info.h +++ b/third_party/blink/renderer/core/paint/paint_layer_painting_info.h
@@ -46,6 +46,7 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_PAINT_LAYER_PAINTING_INFO_H_ #include "base/logging.h" +#include "third_party/blink/renderer/core/layout/geometry/physical_offset.h" #include "third_party/blink/renderer/core/paint/paint_phase.h" #include "third_party/blink/renderer/platform/graphics/paint/cull_rect.h" #include "third_party/blink/renderer/platform/wtf/allocator.h" @@ -91,7 +92,7 @@ PaintLayerPaintingInfo(PaintLayer* root_layer, const CullRect& cull_rect, GlobalPaintFlags global_paint_flags, - const LayoutSize& sub_pixel_accumulation) + const PhysicalOffset& sub_pixel_accumulation) : root_layer(root_layer), cull_rect(cull_rect), sub_pixel_accumulation(sub_pixel_accumulation), @@ -102,7 +103,7 @@ // TODO(jchaffraix): We should encapsulate all these fields. const PaintLayer* root_layer; CullRect cull_rect; // relative to rootLayer; - LayoutSize sub_pixel_accumulation; + PhysicalOffset sub_pixel_accumulation; private: const GlobalPaintFlags global_paint_flags_;
diff --git a/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.cc b/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.cc index 87ed93ff..4721c9b 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.cc +++ b/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.cc
@@ -668,15 +668,17 @@ } IntSize PaintLayerScrollableArea::ContentsSize() const { - LayoutPoint offset( + PhysicalOffset offset( GetLayoutBox()->ClientLeft() + GetLayoutBox()->Location().X(), GetLayoutBox()->ClientTop() + GetLayoutBox()->Location().Y()); + // TODO(crbug.com/962299): The pixel snapping is incorrect in some cases. return PixelSnappedContentsSize(offset); } IntSize PaintLayerScrollableArea::PixelSnappedContentsSize( - const LayoutPoint& paint_offset) const { - return PixelSnappedIntSize(overflow_rect_.Size(), paint_offset); + const PhysicalOffset& paint_offset) const { + return PixelSnappedIntRect(PhysicalRect(paint_offset, overflow_rect_.Size())) + .Size(); } void PaintLayerScrollableArea::ContentsResized() { @@ -2280,9 +2282,7 @@ &non_composited_main_thread_scrolling_reasons_) & kBackgroundPaintInScrollingContents && layer->BackgroundIsKnownToBeOpaqueInRect( - ToLayoutBox(layer->GetLayoutObject()) - .PhysicalPaddingBoxRect() - .ToLayoutRect(), + ToLayoutBox(layer->GetLayoutObject()).PhysicalPaddingBoxRect(), true) && !layer->CompositesWithTransform() && !layer->CompositesWithOpacity(); @@ -2301,9 +2301,7 @@ cc::MainThreadScrollingReason::kHasTransformAndLCDText; } if (!layer->BackgroundIsKnownToBeOpaqueInRect( - ToLayoutBox(layer->GetLayoutObject()) - .PhysicalPaddingBoxRect() - .ToLayoutRect(), + ToLayoutBox(layer->GetLayoutObject()).PhysicalPaddingBoxRect(), true)) { non_composited_main_thread_scrolling_reasons_ |= cc::MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText;
diff --git a/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h b/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h index 23c5038..ddd09a9 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h +++ b/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h
@@ -321,7 +321,7 @@ // Similar to |ContentsSize| but snapped considering |paint_offset| which can // have subpixel accumulation. - IntSize PixelSnappedContentsSize(const LayoutPoint& paint_offset) const; + IntSize PixelSnappedContentsSize(const PhysicalOffset& paint_offset) const; void ContentsResized() override; IntPoint LastKnownMousePosition() const override;
diff --git a/third_party/blink/renderer/core/paint/paint_layer_test.cc b/third_party/blink/renderer/core/paint/paint_layer_test.cc index 7c0919356..e833dc1 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_test.cc +++ b/third_party/blink/renderer/core/paint/paint_layer_test.cc
@@ -57,7 +57,7 @@ PaintLayer* parent_layer = GetPaintLayerByElementId("parent"); // Since "absposchild" is clipped by "parent", it should not expand the // composited bounds for "parent" beyond its intrinsic size of 150x150. - EXPECT_EQ(LayoutRect(0, 0, 150, 150), + EXPECT_EQ(PhysicalRect(0, 0, 150, 150), parent_layer->BoundingBoxForCompositing()); } @@ -77,14 +77,14 @@ )HTML"); PaintLayer* parent_layer = GetPaintLayerByElementId("parent"); - EXPECT_EQ(LayoutRect(0, 0, 784, 500), + EXPECT_EQ(PhysicalRect(0, 0, 784, 500), parent_layer->BoundingBoxForCompositing()); } TEST_P(PaintLayerTest, RootLayerCompositedBounds) { SetBodyInnerHTML( "<style> body { width: 1000px; height: 1000px; margin: 0 } </style>"); - EXPECT_EQ(LayoutRect(0, 0, 800, 600), + EXPECT_EQ(PhysicalRect(0, 0, 800, 600), GetLayoutView().Layer()->BoundingBoxForCompositing()); } @@ -117,9 +117,9 @@ )HTML"); PaintLayer* layer = GetPaintLayerByElementId("target"); - EXPECT_EQ(LayoutRect(60, 40, 110, 243), + EXPECT_EQ(PhysicalRect(60, 40, 110, 243), layer->PaintingExtent(GetDocument().GetLayoutView()->Layer(), - LayoutSize(), 0)); + PhysicalOffset(), 0)); } TEST_P(PaintLayerTest, PaintingExtentReflectionWithTransform) { @@ -131,9 +131,9 @@ )HTML"); PaintLayer* layer = GetPaintLayerByElementId("target"); - EXPECT_EQ(LayoutRect(90, 40, 110, 243), + EXPECT_EQ(PhysicalRect(90, 40, 110, 243), layer->PaintingExtent(GetDocument().GetLayoutView()->Layer(), - LayoutSize(), 0)); + PhysicalOffset(), 0)); } TEST_P(PaintLayerTest, ScrollsWithViewportRelativePosition) { @@ -226,12 +226,12 @@ PaintLayer* content_layer = GetPaintLayerByElementId("content"); EXPECT_EQ(kNotComposited, content_layer->GetCompositingState()); - EXPECT_EQ(LayoutPoint(), content_layer->Location()); + EXPECT_EQ(PhysicalOffset(), content_layer->Location()); scroll_layer->GetScrollableArea()->SetScrollOffset(ScrollOffset(1000, 1000), kProgrammaticScroll); GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint(); - EXPECT_EQ(LayoutPoint(-1000, -1000), content_layer->Location()); + EXPECT_EQ(PhysicalOffset(-1000, -1000), content_layer->Location()); EXPECT_FALSE(content_layer->NeedsRepaint()); EXPECT_FALSE(scroll_layer->NeedsRepaint()); UpdateAllLifecyclePhasesForTest(); @@ -256,12 +256,12 @@ PaintLayer* content_layer = GetPaintLayerByElementId("content"); EXPECT_EQ(kNotComposited, scroll_layer->GetCompositingState()); - EXPECT_EQ(LayoutPoint(), content_layer->Location()); + EXPECT_EQ(PhysicalOffset(), content_layer->Location()); scroll_layer->GetScrollableArea()->SetScrollOffset(ScrollOffset(1000, 1000), kProgrammaticScroll); GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint(); - EXPECT_EQ(LayoutPoint(-1000, -1000), content_layer->Location()); + EXPECT_EQ(PhysicalOffset(-1000, -1000), content_layer->Location()); EXPECT_TRUE(scroll_layer->NeedsRepaint()); EXPECT_FALSE(content_layer->NeedsRepaint()); UpdateAllLifecyclePhasesForTest(); @@ -1085,25 +1085,26 @@ EXPECT_EQ(container, span->ContainingLayer()); if (RuntimeEnabledFeatures::LayoutNGEnabled()) { - EXPECT_EQ(LayoutPoint(50, 50), floating->Location()); + EXPECT_EQ(PhysicalOffset(50, 50), floating->Location()); } else { - EXPECT_EQ(LayoutPoint(83, 83), floating->Location()); + EXPECT_EQ(PhysicalOffset(83, 83), floating->Location()); } - EXPECT_EQ(LayoutPoint(50, 50), absolute->Location()); - EXPECT_EQ(LayoutPoint(133, 133), span->Location()); - EXPECT_EQ(LayoutPoint(20, 20), container->Location()); + EXPECT_EQ(PhysicalOffset(50, 50), absolute->Location()); + EXPECT_EQ(PhysicalOffset(133, 133), span->Location()); + EXPECT_EQ(PhysicalOffset(20, 20), container->Location()); if (RuntimeEnabledFeatures::LayoutNGEnabled()) { - EXPECT_EQ(LayoutPoint(50, 50), floating->VisualOffsetFromAncestor(span)); - EXPECT_EQ(LayoutPoint(183, 183), + EXPECT_EQ(PhysicalOffset(50, 50), floating->VisualOffsetFromAncestor(span)); + EXPECT_EQ(PhysicalOffset(183, 183), floating->VisualOffsetFromAncestor(container)); } else { - EXPECT_EQ(LayoutPoint(-50, -50), floating->VisualOffsetFromAncestor(span)); - EXPECT_EQ(LayoutPoint(83, 83), + EXPECT_EQ(PhysicalOffset(-50, -50), + floating->VisualOffsetFromAncestor(span)); + EXPECT_EQ(PhysicalOffset(83, 83), floating->VisualOffsetFromAncestor(container)); } - EXPECT_EQ(LayoutPoint(50, 50), absolute->VisualOffsetFromAncestor(span)); - EXPECT_EQ(LayoutPoint(183, 183), + EXPECT_EQ(PhysicalOffset(50, 50), absolute->VisualOffsetFromAncestor(span)); + EXPECT_EQ(PhysicalOffset(183, 183), absolute->VisualOffsetFromAncestor(container)); } @@ -1134,16 +1135,17 @@ EXPECT_EQ(container, span->Parent()); EXPECT_EQ(container, span->ContainingLayer()); - EXPECT_EQ(LayoutPoint(100, -300), span->Location()); + EXPECT_EQ(PhysicalOffset(100, -300), span->Location()); if (RuntimeEnabledFeatures::LayoutNGEnabled()) { - EXPECT_EQ(LayoutPoint(50, 50), floating->Location()); - EXPECT_EQ(LayoutPoint(50, 50), floating->VisualOffsetFromAncestor(span)); - EXPECT_EQ(LayoutPoint(150, -250), + EXPECT_EQ(PhysicalOffset(50, 50), floating->Location()); + EXPECT_EQ(PhysicalOffset(50, 50), floating->VisualOffsetFromAncestor(span)); + EXPECT_EQ(PhysicalOffset(150, -250), floating->VisualOffsetFromAncestor(container)); } else { - EXPECT_EQ(LayoutPoint(50, -350), floating->Location()); - EXPECT_EQ(LayoutPoint(-50, -50), floating->VisualOffsetFromAncestor(span)); - EXPECT_EQ(LayoutPoint(50, -350), + EXPECT_EQ(PhysicalOffset(50, -350), floating->Location()); + EXPECT_EQ(PhysicalOffset(-50, -50), + floating->VisualOffsetFromAncestor(span)); + EXPECT_EQ(PhysicalOffset(50, -350), floating->VisualOffsetFromAncestor(container)); } } @@ -1166,11 +1168,12 @@ EXPECT_EQ(span, floating->Parent()); EXPECT_EQ(span, floating->ContainingLayer()); - EXPECT_EQ(LayoutPoint(83, 83), floating->Location()); - EXPECT_EQ(LayoutPoint(100, 100), span->Location()); - EXPECT_EQ(LayoutPoint(83, 83), floating->VisualOffsetFromAncestor(span)); - EXPECT_EQ(LayoutPoint(183, 183), floating->VisualOffsetFromAncestor( - GetDocument().GetLayoutView()->Layer())); + EXPECT_EQ(PhysicalOffset(83, 83), floating->Location()); + EXPECT_EQ(PhysicalOffset(100, 100), span->Location()); + EXPECT_EQ(PhysicalOffset(83, 83), floating->VisualOffsetFromAncestor(span)); + EXPECT_EQ(PhysicalOffset(183, 183), + floating->VisualOffsetFromAncestor( + GetDocument().GetLayoutView()->Layer())); } TEST_P(PaintLayerTest, FloatLayerUnderFloatUnderInlineLayer) { @@ -1195,17 +1198,19 @@ EXPECT_EQ(span->Parent(), floating->ContainingLayer()); } - EXPECT_EQ(LayoutPoint(83, 83), floating->Location()); - EXPECT_EQ(LayoutPoint(100, 100), span->Location()); + EXPECT_EQ(PhysicalOffset(83, 83), floating->Location()); + EXPECT_EQ(PhysicalOffset(100, 100), span->Location()); if (RuntimeEnabledFeatures::LayoutNGEnabled()) { - EXPECT_EQ(LayoutPoint(83, 83), floating->VisualOffsetFromAncestor(span)); - EXPECT_EQ(LayoutPoint(183, 183), + EXPECT_EQ(PhysicalOffset(83, 83), floating->VisualOffsetFromAncestor(span)); + EXPECT_EQ(PhysicalOffset(183, 183), floating->VisualOffsetFromAncestor( GetDocument().GetLayoutView()->Layer())); } else { - EXPECT_EQ(LayoutPoint(-17, -17), floating->VisualOffsetFromAncestor(span)); - EXPECT_EQ(LayoutPoint(83, 83), floating->VisualOffsetFromAncestor( - GetDocument().GetLayoutView()->Layer())); + EXPECT_EQ(PhysicalOffset(-17, -17), + floating->VisualOffsetFromAncestor(span)); + EXPECT_EQ(PhysicalOffset(83, 83), + floating->VisualOffsetFromAncestor( + GetDocument().GetLayoutView()->Layer())); } } @@ -1235,22 +1240,24 @@ EXPECT_EQ(span->Parent(), floating_parent->ContainingLayer()); } - EXPECT_EQ(LayoutPoint(50, 50), floating->Location()); - EXPECT_EQ(LayoutPoint(33, 33), floating_parent->Location()); - EXPECT_EQ(LayoutPoint(100, 100), span->Location()); + EXPECT_EQ(PhysicalOffset(50, 50), floating->Location()); + EXPECT_EQ(PhysicalOffset(33, 33), floating_parent->Location()); + EXPECT_EQ(PhysicalOffset(100, 100), span->Location()); if (RuntimeEnabledFeatures::LayoutNGEnabled()) { - EXPECT_EQ(LayoutPoint(83, 83), floating->VisualOffsetFromAncestor(span)); - EXPECT_EQ(LayoutPoint(33, 33), + EXPECT_EQ(PhysicalOffset(83, 83), floating->VisualOffsetFromAncestor(span)); + EXPECT_EQ(PhysicalOffset(33, 33), floating_parent->VisualOffsetFromAncestor(span)); - EXPECT_EQ(LayoutPoint(183, 183), + EXPECT_EQ(PhysicalOffset(183, 183), floating->VisualOffsetFromAncestor( GetDocument().GetLayoutView()->Layer())); } else { - EXPECT_EQ(LayoutPoint(-17, -17), floating->VisualOffsetFromAncestor(span)); - EXPECT_EQ(LayoutPoint(-67, -67), + EXPECT_EQ(PhysicalOffset(-17, -17), + floating->VisualOffsetFromAncestor(span)); + EXPECT_EQ(PhysicalOffset(-67, -67), floating_parent->VisualOffsetFromAncestor(span)); - EXPECT_EQ(LayoutPoint(83, 83), floating->VisualOffsetFromAncestor( - GetDocument().GetLayoutView()->Layer())); + EXPECT_EQ(PhysicalOffset(83, 83), + floating->VisualOffsetFromAncestor( + GetDocument().GetLayoutView()->Layer())); } } @@ -1277,18 +1284,19 @@ EXPECT_EQ(span->Parent(), child->ContainingLayer()); } - EXPECT_EQ(LayoutPoint(83, 83), child->Location()); - EXPECT_EQ(LayoutPoint(100, 100), span->Location()); + EXPECT_EQ(PhysicalOffset(83, 83), child->Location()); + EXPECT_EQ(PhysicalOffset(100, 100), span->Location()); if (RuntimeEnabledFeatures::LayoutNGEnabled()) { - EXPECT_EQ(LayoutPoint(83, 83), child->VisualOffsetFromAncestor(span)); - EXPECT_EQ(LayoutPoint(183, 183), + EXPECT_EQ(PhysicalOffset(83, 83), child->VisualOffsetFromAncestor(span)); + EXPECT_EQ(PhysicalOffset(183, 183), child->VisualOffsetFromAncestor( GetDocument().GetLayoutView()->Layer())); } else { - EXPECT_EQ(LayoutPoint(-17, -17), child->VisualOffsetFromAncestor(span)); - EXPECT_EQ(LayoutPoint(83, 83), child->VisualOffsetFromAncestor( - GetDocument().GetLayoutView()->Layer())); + EXPECT_EQ(PhysicalOffset(-17, -17), child->VisualOffsetFromAncestor(span)); + EXPECT_EQ(PhysicalOffset(83, 83), + child->VisualOffsetFromAncestor( + GetDocument().GetLayoutView()->Layer())); } } @@ -1377,13 +1385,14 @@ EXPECT_EQ(columns, extra_layer->Parent()->Parent()); EXPECT_EQ(columns, extra_layer->ContainingLayer()->Parent()); - EXPECT_EQ(LayoutPoint(-150, 50), spanner->Location()); - EXPECT_EQ(LayoutPoint(100, 100), extra_layer->Location()); + EXPECT_EQ(PhysicalOffset(-150, 50), spanner->Location()); + EXPECT_EQ(PhysicalOffset(100, 100), extra_layer->Location()); // -60 = 2nd-column-x(40) - scroll-offset-x(200) + x-location(100) // 20 = y-location(100) - column-height(80) - EXPECT_EQ(LayoutPoint(-60, 20), + EXPECT_EQ(PhysicalOffset(-60, 20), extra_layer->VisualOffsetFromAncestor(columns)); - EXPECT_EQ(LayoutPoint(-150, 50), spanner->VisualOffsetFromAncestor(columns)); + EXPECT_EQ(PhysicalOffset(-150, 50), + spanner->VisualOffsetFromAncestor(columns)); } TEST_P(PaintLayerTest, PaintLayerTransformUpdatedOnStyleTransformAnimation) { @@ -1562,8 +1571,8 @@ squashed->GetLayoutObject(), point); EXPECT_EQ(FloatPoint(), point); - EXPECT_EQ(LayoutPoint(0, 0), squashed->ComputeOffsetFromAncestor( - squashed->TransformAncestorOrRoot())); + EXPECT_EQ(PhysicalOffset(0, 0), squashed->ComputeOffsetFromAncestor( + squashed->TransformAncestorOrRoot())); GetDocument().View()->LayoutViewport()->ScrollBy(ScrollOffset(0, 25), kUserScroll); @@ -1573,8 +1582,8 @@ squashed->GetLayoutObject(), point); EXPECT_EQ(FloatPoint(), point); - EXPECT_EQ(LayoutPoint(0, 0), squashed->ComputeOffsetFromAncestor( - squashed->TransformAncestorOrRoot())); + EXPECT_EQ(PhysicalOffset(0, 0), squashed->ComputeOffsetFromAncestor( + squashed->TransformAncestorOrRoot())); } TEST_P(PaintLayerTest, HitTestWithIgnoreClipping) { @@ -1858,9 +1867,9 @@ PaintLayer* target_layer = GetPaintLayerByElementId("target"); EXPECT_TRUE(target_layer->BackgroundIsKnownToBeOpaqueInRect( - LayoutRect(0, 0, 100, 100), true)); + PhysicalRect(0, 0, 100, 100), true)); EXPECT_FALSE(target_layer->BackgroundIsKnownToBeOpaqueInRect( - LayoutRect(0, 0, 100, 100), false)); + PhysicalRect(0, 0, 100, 100), false)); } TEST_P(PaintLayerTest,
diff --git a/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc b/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc index 3042260..bad58dfe 100644 --- a/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc +++ b/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc
@@ -113,7 +113,7 @@ full_context.fragments.push_back(PaintPropertyTreeBuilderFragmentContext()); PaintPropertyTreeBuilderFragmentContext& context = full_context.fragments[0]; - context.current.paint_offset.MoveBy(frame_view.Location()); + context.current.paint_offset += PhysicalOffset(frame_view.Location()); context.current.rendering_context_id = 0; context.current.should_flatten_inherited_transform = true; context.absolute_position = context.current; @@ -433,15 +433,15 @@ // In pre-CompositeAfterPaint, if the object has layer, this corresponds to // PaintLayer::SubpixelAccumulation(). paint_offset_translation = RoundedIntPoint(context_.current.paint_offset); - LayoutPoint subpixel_accumulation; + PhysicalOffset subpixel_accumulation; // Don't propagate subpixel accumulation through paint isolation. In // pre-CompositeAfterPaint we still need to keep consistence with the legacy // compositing code. if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled() || !NeedsIsolationNodes(object_)) { - subpixel_accumulation = - LayoutPoint(context_.current.paint_offset - *paint_offset_translation); - if (subpixel_accumulation != LayoutPoint()) { + subpixel_accumulation = context_.current.paint_offset - + PhysicalOffset(*paint_offset_translation); + if (!subpixel_accumulation.IsZero()) { // If the object has a non-translation transform, discard the fractional // paint offset which can't be transformed by the transform. TransformationMatrix matrix; @@ -450,7 +450,7 @@ ComputedStyle::kIncludeMotionPath, ComputedStyle::kIncludeIndependentTransformProperties); if (!matrix.IsIdentityOrTranslation()) - subpixel_accumulation = LayoutPoint(); + subpixel_accumulation = PhysicalOffset(); } } context_.current.paint_offset = subpixel_accumulation; @@ -585,7 +585,7 @@ // SVG does not use paint offset internally, except for SVGForeignObject which // has different SVG and HTML coordinate spaces. DCHECK(object_.IsSVGForeignObject() || - context_.current.paint_offset == LayoutPoint()); + context_.current.paint_offset.IsZero()); if (NeedsPaintPropertyUpdate()) { AffineTransform transform = object_.LocalToSVGParentTransform(); @@ -1239,7 +1239,7 @@ } } -static FloatRoundedRect ToClipRect(const LayoutRect& rect) { +static FloatRoundedRect ToClipRect(const PhysicalRect& rect) { return FloatRoundedRect(FloatRect(PixelSnappedIntRect(rect))); } @@ -1419,8 +1419,8 @@ scroll_controls_bounds.Unite(scrollbar->FrameRect()); if (const auto* scrollbar = scrollable_area->VerticalScrollbar()) scroll_controls_bounds.Unite(scrollbar->FrameRect()); - auto pixel_snapped_border_box_rect = box.PixelSnappedBorderBoxRect( - ToLayoutSize(context_.current.paint_offset)); + auto pixel_snapped_border_box_rect = + box.PixelSnappedBorderBoxRect(context_.current.paint_offset); pixel_snapped_border_box_rect.SetLocation(IntPoint()); return !pixel_snapped_border_box_rect.Contains(scroll_controls_bounds); } @@ -1437,24 +1437,25 @@ NeedsOverflowClip(object); } -static LayoutPoint VisualOffsetFromPaintOffsetRoot( +static PhysicalOffset VisualOffsetFromPaintOffsetRoot( const PaintPropertyTreeBuilderFragmentContext& context, const PaintLayer* child) { const LayoutObject* paint_offset_root = context.current.paint_offset_root; PaintLayer* painting_layer = paint_offset_root->PaintingLayer(); - LayoutPoint result = child->VisualOffsetFromAncestor(painting_layer); + PhysicalOffset result = child->VisualOffsetFromAncestor(painting_layer); if (!paint_offset_root->HasLayer() || ToLayoutBoxModelObject(paint_offset_root)->Layer() != painting_layer) { - result.Move(-paint_offset_root - ->OffsetFromAncestor(&painting_layer->GetLayoutObject()) - .ToLayoutSize()); + result -= paint_offset_root->OffsetFromAncestor( + &painting_layer->GetLayoutObject()); } // Convert the result into the space of the scrolling contents space. if (const auto* properties = paint_offset_root->FirstFragment().PaintProperties()) { - if (const auto* scroll_translation = properties->ScrollTranslation()) - result += -LayoutSize(scroll_translation->Translation2D()); + if (const auto* scroll_translation = properties->ScrollTranslation()) { + result -= PhysicalOffset::FromFloatSizeRound( + scroll_translation->Translation2D()); + } } return result; } @@ -1472,8 +1473,8 @@ *context_.current.clip, ClipPaintPropertyNode::State{ context_.current.transform, - ToClipRect(LayoutRect(context_.current.paint_offset, - ToLayoutBox(object_).Size()))}); + ToClipRect(PhysicalRect(context_.current.paint_offset, + ToLayoutBox(object_).Size()))}); } else { properties_->ClearOverflowControlsClip(); } @@ -1492,8 +1493,8 @@ const LayoutBox& box = ToLayoutBox(object_); ClipPaintPropertyNode::State state; state.local_transform_space = context_.current.transform; - state.clip_rect = box.StyleRef().GetRoundedInnerBorderFor( - LayoutRect(context_.current.paint_offset, box.Size())); + state.clip_rect = box.StyleRef().GetRoundedInnerBorderFor(LayoutRect( + context_.current.paint_offset.ToLayoutPoint(), box.Size())); OnUpdateClip(properties_->UpdateInnerBorderRadiusClip( *context_.current.clip, std::move(state))); } else { @@ -1528,9 +1529,9 @@ // We need OverflowClip for hit-testing if the clip rect excluding overlay // scrollbars is different from the normal clip rect. - auto clip_rect = block->OverflowClipRect(LayoutPoint()); + auto clip_rect = block->OverflowClipRect(PhysicalOffset()); auto clip_rect_excluding_overlay_scrollbars = block->OverflowClipRect( - LayoutPoint(), kExcludeOverlayScrollbarSizeForHitTesting); + PhysicalOffset(), kExcludeOverlayScrollbarSizeForHitTesting); if (clip_rect != clip_rect_excluding_overlay_scrollbars) return false; @@ -1540,12 +1541,15 @@ // omit the clip if there are any PaintLayer descendants. if (block->HasLayer() && block->Layer()->FirstChild()) return false; - if (!clip_rect.Contains(block->ContentsVisualOverflowRect())) + + // TODO(wangxianzhu): It's incorrect to test the physical clip_rect against + // the flipped ContentsVisualOverflowRect and LayoutOverflowRect. + if (!clip_rect.ToLayoutRect().Contains(block->ContentsVisualOverflowRect())) return false; // Content can scroll, and needs to be clipped, if the layout overflow extends // beyond the clip rect. - return clip_rect.Contains(block->LayoutOverflowRect()); + return clip_rect.ToLayoutRect().Contains(block->LayoutOverflowRect()); } void FragmentPaintPropertyTreeBuilder::UpdateOverflowClip() { @@ -1562,16 +1566,15 @@ // Videos need to be pre-snapped so that they line up with the // display_rect and can enable hardware overlays. Adjust the base rect // here, before applying padding and corner rounding. - LayoutRect content_rect = - LayoutRect(context_.current.paint_offset, replaced.Size()); + PhysicalRect content_rect(context_.current.paint_offset, + replaced.Size()); if (replaced.IsVideo()) { - content_rect = LayoutReplaced::PreSnappedRectForPersistentSizing( - PhysicalRectToBeNoop(content_rect)) - .ToLayoutRect(); + content_rect = + LayoutReplaced::PreSnappedRectForPersistentSizing(content_rect); } // LayoutReplaced clips the foreground by rounded content box. state.clip_rect = replaced.StyleRef().GetRoundedInnerBorderFor( - content_rect, + content_rect.ToLayoutRect(), LayoutRectOutsets( -(replaced.PaddingTop() + replaced.BorderTop()), -(replaced.PaddingRight() + replaced.BorderRight()), @@ -1635,7 +1638,7 @@ TransformPaintPropertyNode::TransformAndOrigin( TransformationMatrix().ApplyPerspective(style.Perspective()), PerspectiveOrigin(ToLayoutBox(object_)) + - ToLayoutSize(context_.current.paint_offset))}; + FloatSize(context_.current.paint_offset))}; state.flattens_inherited_transform = context_.current.should_flatten_inherited_transform; if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() || @@ -1684,9 +1687,8 @@ .TransformToPixelSnappedBorderBox(context_.current.paint_offset); } else if (object_.IsImage()) { const LayoutImage& layout_image = ToLayoutImage(object_); - LayoutRect layout_replaced_rect = - layout_image.ReplacedContentRect().ToLayoutRect(); - layout_replaced_rect.MoveBy(context_.current.paint_offset); + PhysicalRect layout_replaced_rect = layout_image.ReplacedContentRect(); + layout_replaced_rect.Move(context_.current.paint_offset); IntRect replaced_rect = PixelSnappedIntRect(layout_replaced_rect); scoped_refptr<Image> image = layout_image.ImageResource()->GetImage(replaced_rect.Size()); @@ -1713,7 +1715,7 @@ if (object_.IsSVGRoot()) { // SVG painters don't use paint offset. The paint offset is baked into // the transform node instead. - context_.current.paint_offset = LayoutPoint(); + context_.current.paint_offset = PhysicalOffset(); // Only <svg> paints its subtree as replaced contents. Other replaced // element type may have shadow DOM that should not be affected by the @@ -1925,7 +1927,8 @@ context_.current.transform = properties_->ScrollTranslation(); // See comments for ScrollTranslation in object_paint_properties.h for the // reason of adding ScrollOrigin(). - context_.current.paint_offset += ToLayoutBox(object_).ScrollOrigin(); + context_.current.paint_offset += + PhysicalOffset(ToLayoutBox(object_).ScrollOrigin()); } } @@ -1953,7 +1956,7 @@ // Also undo the ScrollOrigin part in paint offset that was added when // ScrollTranslation was updated. context_.fixed_position.paint_offset -= - ToLayoutBox(object_).ScrollOrigin(); + PhysicalOffset(ToLayoutBox(object_).ScrollOrigin()); } } else if (object_.CanContainFixedPositionObjects()) { context_.fixed_position = context_.current; @@ -2026,16 +2029,16 @@ context_.current.clip = properties_->ClipIsolationNode(); } -static LayoutRect MapLocalRectToAncestorLayer( +static PhysicalRect MapLocalRectToAncestorLayer( const LayoutBox& box, - const LayoutRect& local_rect, + const PhysicalRect& local_rect, const PaintLayer& ancestor_layer) { TransformState transform_state(TransformState::kApplyTransformDirection, - FloatPoint(local_rect.Location())); + FloatPoint(local_rect.offset)); box.MapLocalToAncestor(&ancestor_layer.GetLayoutObject(), transform_state, 0); transform_state.Flatten(); - return LayoutRect(LayoutPoint(transform_state.LastPlanarPoint()), - local_rect.Size()); + return PhysicalRect::EnclosingRect( + FloatRect(transform_state.LastPlanarPoint(), FloatSize(local_rect.size))); } static bool IsRepeatingTableSection(const LayoutObject& object) { @@ -2045,7 +2048,7 @@ return section.IsRepeatingHeaderGroup() || section.IsRepeatingFooterGroup(); } -static LayoutRect BoundingBoxInPaginationContainer( +static PhysicalRect BoundingBoxInPaginationContainer( const LayoutObject& object, const PaintLayer& enclosing_pagination_layer) { // The special path for fragmented layers ensures that the bounding box also @@ -2069,28 +2072,29 @@ } } - LayoutRect local_bounds; + PhysicalRect local_bounds; const LayoutBox* local_space_object = nullptr; if (object.IsBox()) { local_space_object = ToLayoutBox(&object); - local_bounds = local_space_object->BorderBoxRect(); + local_bounds = local_space_object->PhysicalBorderBoxRect(); } else { // Non-boxes paint in the space of their containing block. local_space_object = object.ContainingBlock(); // For non-SVG we can get a more accurate result with LocalVisualRect, // instead of falling back to the bounds of the enclosing block. if (!object.IsSVG()) { - local_bounds = object.LocalVisualRect().ToLayoutRect(); + local_bounds = object.LocalVisualRect(); } else { - local_bounds = LayoutRect(SVGLayoutSupport::LocalVisualRect(object)); + local_bounds = PhysicalRect::EnclosingRect( + SVGLayoutSupport::LocalVisualRect(object)); } } // The link highlight covers block visual overflows, continuations, etc. which // may intersect with more fragments than the object itself. if (NeedsLinkHighlightEffect(object)) { - local_bounds.Unite(UnionRect(object.PhysicalOutlineRects( - LayoutPoint(), NGOutlineType::kIncludeBlockVisualOverflow))); + local_bounds.Unite(UnionRect(object.OutlineRects( + PhysicalOffset(), NGOutlineType::kIncludeBlockVisualOverflow))); } // Compute the bounding box without transforms. @@ -2109,7 +2113,7 @@ // intersect any fragment containing any row. if (const auto* bottom_section = table.BottomNonEmptySection()) { bounding_box.Unite(MapLocalRectToAncestorLayer( - *bottom_section, bottom_section->BorderBoxRect(), + *bottom_section, bottom_section->PhysicalBorderBoxRect(), enclosing_pagination_layer)); } return bounding_box; @@ -2119,14 +2123,14 @@ // Similar to repeating header, expand bounding_box to intersect any // fragment containing any row first. if (const auto* top_section = table.TopNonEmptySection()) { - bounding_box.Unite(MapLocalRectToAncestorLayer(*top_section, - top_section->BorderBoxRect(), - enclosing_pagination_layer)); + bounding_box.Unite(MapLocalRectToAncestorLayer( + *top_section, top_section->PhysicalBorderBoxRect(), + enclosing_pagination_layer)); // However, the first fragment intersecting the expanded bounding_box may // not have enough space to contain the repeating footer. Exclude the // total height of the first row and repeating footers from the top of // bounding_box to exclude the first fragment without enough space. - auto top_exclusion = table.RowOffsetFromRepeatingFooter(); + LayoutUnit top_exclusion = table.RowOffsetFromRepeatingFooter(); if (top_section != section) { top_exclusion += top_section->FirstRow()->LogicalHeight() + table.VBorderSpacing(); @@ -2135,12 +2139,12 @@ // one row plus space for the footer. if (top_exclusion) top_exclusion -= 1; - bounding_box.ShiftYEdgeTo(bounding_box.Y() + top_exclusion); + bounding_box.ShiftTopEdgeTo(bounding_box.Y() + top_exclusion); } return bounding_box; } -static LayoutPoint PaintOffsetInPaginationContainer( +static PhysicalOffset PaintOffsetInPaginationContainer( const LayoutObject& object, const PaintLayer& enclosing_pagination_layer) { // Non-boxes use their containing blocks' paint offset. @@ -2154,7 +2158,7 @@ object.MapLocalToAncestor(&enclosing_pagination_layer.GetLayoutObject(), transform_state, kApplyContainerFlip); transform_state.Flatten(); - return LayoutPoint(transform_state.LastPlanarPoint()); + return PhysicalOffset::FromFloatPointRound(transform_state.LastPlanarPoint()); } void FragmentPaintPropertyTreeBuilder::UpdatePaintOffset() { @@ -2168,19 +2172,19 @@ !context_.current.paint_offset_root->PaintingLayer() ->EnclosingPaginationLayer()) { // Set fragment visual paint offset. - LayoutPoint paint_offset = + PhysicalOffset paint_offset = PaintOffsetInPaginationContainer(object_, *enclosing_pagination_layer); - paint_offset.MoveBy(fragment_data_.PaginationOffset()); - paint_offset.Move(context_.repeating_paint_offset_adjustment); - paint_offset.MoveBy( - VisualOffsetFromPaintOffsetRoot(context_, enclosing_pagination_layer)); + paint_offset += fragment_data_.PaginationOffset(); + paint_offset += context_.repeating_paint_offset_adjustment; + paint_offset += + VisualOffsetFromPaintOffsetRoot(context_, enclosing_pagination_layer); // The paint offset root can have a subpixel paint offset adjustment. // The paint offset root always has one fragment. const auto& paint_offset_root_fragment = context_.current.paint_offset_root->FirstFragment(); - paint_offset.MoveBy(paint_offset_root_fragment.PaintOffset()); + paint_offset += paint_offset_root_fragment.PaintOffset(); context_.current.paint_offset = paint_offset; return; @@ -2204,7 +2208,7 @@ break; case EPosition::kRelative: context_.current.paint_offset += - box_model_object.OffsetForInFlowPosition().ToLayoutPoint(); + box_model_object.OffsetForInFlowPosition(); break; case EPosition::kAbsolute: { DCHECK(full_context_.container_for_absolute_position == @@ -2218,10 +2222,8 @@ DCHECK(container->CanContainAbsolutePositionObjects()); DCHECK(box_model_object.IsBox()); context_.current.paint_offset += - ToLayoutInline(container) - ->OffsetForInFlowPositionedInline( - ToLayoutBox(box_model_object)) - .ToLayoutPoint(); + ToLayoutInline(container)->OffsetForInFlowPositionedInline( + ToLayoutBox(box_model_object)); } break; } @@ -2242,10 +2244,8 @@ DCHECK(container->CanContainFixedPositionObjects()); DCHECK(box_model_object.IsBox()); context_.current.paint_offset += - ToLayoutInline(container) - ->OffsetForInFlowPositionedInline( - ToLayoutBox(box_model_object)) - .ToLayoutPoint(); + ToLayoutInline(container)->OffsetForInFlowPositionedInline( + ToLayoutBox(box_model_object)); } break; } @@ -2259,8 +2259,7 @@ // calculate containers (e.g., physicalLocation, offsetForInFlowPosition*). // The containing block and other containers can be stored on // PaintPropertyTreeBuilderFragmentContext instead of recomputing them. - context_.current.paint_offset.MoveBy( - ToLayoutBox(object_).PhysicalLocation().ToLayoutPoint()); + context_.current.paint_offset += ToLayoutBox(object_).PhysicalLocation(); // This is a weird quirk that table cells paint as children of table rows, // but their location have the row's location baked-in. @@ -2268,13 +2267,12 @@ if (object_.IsTableCell()) { LayoutObject* parent_row = object_.Parent(); DCHECK(parent_row && parent_row->IsTableRow()); - context_.current.paint_offset.MoveBy( - -ToLayoutBox(parent_row)->PhysicalLocation().ToLayoutPoint()); + context_.current.paint_offset -= + ToLayoutBox(parent_row)->PhysicalLocation(); } } - context_.current.paint_offset.Move( - context_.repeating_paint_offset_adjustment); + context_.current.paint_offset += context_.repeating_paint_offset_adjustment; } void FragmentPaintPropertyTreeBuilder::SetNeedsPaintPropertyUpdateIfNeeded() { @@ -2333,7 +2331,7 @@ UpdatePaintOffset(); UpdateForPaintOffsetTranslation(paint_offset_translation); - LayoutSize paint_offset_delta = + PhysicalOffset paint_offset_delta = fragment_data_.PaintOffset() - context_.current.paint_offset; if (!paint_offset_delta.IsZero()) { // Many paint properties depend on paint offset so we force an update of @@ -2341,7 +2339,7 @@ // isolation if subpixel accumulation doesn't change or CompositeAfterPaint // is enabled. if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() || - paint_offset_delta == RoundedIntSize(paint_offset_delta)) { + !paint_offset_delta.HasFraction()) { full_context_.force_subtree_update_reasons |= PaintPropertyTreeBuilderContext::kSubtreeUpdateIsolationBlocked; } else { @@ -2469,7 +2467,7 @@ void PaintPropertyTreeBuilder::InitFragmentPaintProperties( FragmentData& fragment, bool needs_paint_properties, - const LayoutPoint& pagination_offset, + const PhysicalOffset& pagination_offset, LayoutUnit logical_top_in_flow_thread) { if (needs_paint_properties) { fragment.EnsurePaintProperties(); @@ -2562,10 +2560,11 @@ // pagination layer. FragmentainerIterator iterator( ToLayoutFlowThread(enclosing_pagination_layer->GetLayoutObject()), - BoundingBoxInPaginationContainer(object_, *enclosing_pagination_layer)); + BoundingBoxInPaginationContainer(object_, *enclosing_pagination_layer) + .ToLayoutRect()); if (!iterator.AtEnd()) { first_fragment.SetPaginationOffset( - ToLayoutPoint(iterator.PaginationOffset())); + PhysicalOffsetToBeNoop(iterator.PaginationOffset())); first_fragment.SetLogicalTopInFlowThread( iterator.FragmentainerLogicalTopInFlowThread()); } @@ -2593,7 +2592,7 @@ // by descendants, so we only need to adjust point offset for the table // section. for (auto& fragment_context : context_.fragments) { - fragment_context.repeating_paint_offset_adjustment = LayoutSize(); + fragment_context.repeating_paint_offset_adjustment = PhysicalOffset(); } } @@ -2663,10 +2662,10 @@ for (wtf_size_t i = 0; i < context_.fragments.size(); ++i) { auto& fragment_context = context_.fragments[i]; - fragment_context.repeating_paint_offset_adjustment = LayoutSize(); + fragment_context.repeating_paint_offset_adjustment = PhysicalOffset(); // Adjust paint offsets of repeatings (not including the original). if (i) - fragment_context.repeating_paint_offset_adjustment.SetHeight(adjustment); + fragment_context.repeating_paint_offset_adjustment.top = adjustment; // Calculate the adjustment for the repeating which will appear in the next // fragment. @@ -2693,7 +2692,7 @@ LayoutUnit fragment_height; LayoutUnit original_offset_in_flow_thread = - context_.repeating_table_section_bounding_box.MaxY() - + context_.repeating_table_section_bounding_box.Bottom() - section.LogicalHeight(); LayoutUnit original_offset_in_fragment; const LayoutFlowThread* flow_thread = nullptr; @@ -2739,10 +2738,10 @@ original_offset_in_flow_thread - original_offset_in_fragment; for (auto i = context_.fragments.size(); i > 0; --i) { auto& fragment_context = context_.fragments[i - 1]; - fragment_context.repeating_paint_offset_adjustment = LayoutSize(); + fragment_context.repeating_paint_offset_adjustment = PhysicalOffset(); // Adjust paint offsets of repeatings. if (i != context_.fragments.size()) - fragment_context.repeating_paint_offset_adjustment.SetHeight(adjustment); + fragment_context.repeating_paint_offset_adjustment.top = adjustment; // Calculate the adjustment for the repeating which will appear in the // previous fragment. @@ -2800,7 +2799,7 @@ // to allow for correct property tree parenting of fragments. PaintPropertyTreeBuilderFragmentContext PaintPropertyTreeBuilder::ContextForFragment( - const base::Optional<LayoutRect>& fragment_clip, + const base::Optional<PhysicalRect>& fragment_clip, LayoutUnit logical_top_in_flow_thread) const { const auto& parent_fragments = context_.fragments; if (parent_fragments.IsEmpty()) @@ -2921,7 +2920,7 @@ const auto& flow_thread = ToLayoutFlowThread(enclosing_pagination_layer->GetLayoutObject()); - LayoutRect object_bounding_box_in_flow_thread; + PhysicalRect object_bounding_box_in_flow_thread; if (context_.repeating_table_section) { // The object is a descendant of a repeating object. It should use the // repeating bounding box to repeat in the same fragments as its @@ -2939,19 +2938,20 @@ } FragmentData* current_fragment_data = nullptr; - FragmentainerIterator iterator(flow_thread, - object_bounding_box_in_flow_thread); + FragmentainerIterator iterator( + flow_thread, object_bounding_box_in_flow_thread.ToLayoutRect()); bool fragments_changed = false; Vector<PaintPropertyTreeBuilderFragmentContext, 1> new_fragment_contexts; for (; !iterator.AtEnd(); iterator.Advance()) { - auto pagination_offset = ToLayoutPoint(iterator.PaginationOffset()); + auto pagination_offset = + PhysicalOffsetToBeNoop(iterator.PaginationOffset()); auto logical_top_in_flow_thread = iterator.FragmentainerLogicalTopInFlowThread(); - base::Optional<LayoutRect> fragment_clip; + base::Optional<PhysicalRect> fragment_clip; if (object_.HasLayer()) { // 1. Compute clip in flow thread space. - fragment_clip = iterator.ClipRectInFlowThread(); + fragment_clip = PhysicalRectToBeNoop(iterator.ClipRectInFlowThread()); // We skip empty clip fragments, since they can share the same logical top // with the subsequent fragments. Since we skip drawing empty fragments @@ -2961,20 +2961,21 @@ continue; // 2. Convert #1 to visual coordinates in the space of the flow thread. - fragment_clip->MoveBy(pagination_offset); + fragment_clip->Move(pagination_offset); // 3. Adjust #2 to visual coordinates in the containing "paint offset" // space. { DCHECK(context_.fragments[0].current.paint_offset_root); - LayoutPoint pagination_visual_offset = VisualOffsetFromPaintOffsetRoot( - context_.fragments[0], enclosing_pagination_layer); + PhysicalOffset pagination_visual_offset = + VisualOffsetFromPaintOffsetRoot(context_.fragments[0], + enclosing_pagination_layer); // Adjust for paint offset of the root, which may have a subpixel // component. The paint offset root never has more than one fragment. - pagination_visual_offset.MoveBy( + pagination_visual_offset += context_.fragments[0] .current.paint_offset_root->FirstFragment() - .PaintOffset()); - fragment_clip->MoveBy(pagination_visual_offset); + .PaintOffset(); + fragment_clip->Move(pagination_visual_offset); } } @@ -2996,7 +2997,7 @@ const ClipPaintPropertyNode* old_fragment_clip = nullptr; if (const auto* properties = current_fragment_data->PaintProperties()) old_fragment_clip = properties->FragmentClip(); - const base::Optional<LayoutRect>& new_fragment_clip = + const base::Optional<PhysicalRect>& new_fragment_clip = new_fragment_contexts.back().fragment_clip; fragments_changed = !!old_fragment_clip != !!new_fragment_clip || @@ -3056,12 +3057,10 @@ int page_count = ceilf(view->DocumentRect().Height() / page_height); context_.fragments.resize(page_count); - context_.fragments[0].fixed_position.paint_offset.Move(LayoutUnit(), - -view->ScrollTop()); + context_.fragments[0].fixed_position.paint_offset.top -= view->ScrollTop(); for (int page = 1; page < page_count; page++) { context_.fragments[page] = context_.fragments[page - 1]; - context_.fragments[page].fixed_position.paint_offset.Move(LayoutUnit(), - page_height); + context_.fragments[page].fixed_position.paint_offset.top += page_height; context_.fragments[page].logical_top_in_flow_thread += page_height; } } @@ -3076,13 +3075,12 @@ context_.repeating_table_section_bounding_box = BoundingBoxInPaginationContainer(object_, *view->Layer()); // Convert the bounding box into the scrolling contents space. - context_.repeating_table_section_bounding_box.Move(LayoutUnit(), - view->ScrollTop()); + context_.repeating_table_section_bounding_box.offset.top += view->ScrollTop(); auto page_height = view->PageLogicalHeight(); const auto& bounding_box = context_.repeating_table_section_bounding_box; int first_page = floorf(bounding_box.Y() / page_height); - int last_page = ceilf(bounding_box.MaxY() / page_height) - 1; + int last_page = ceilf(bounding_box.Bottom() / page_height) - 1; if (first_page >= last_page) return; @@ -3111,7 +3109,7 @@ ? &fragment_data->EnsureNextFragment() : &object_.GetMutableForPainting().FirstFragment(); InitFragmentPaintProperties(*fragment_data, needs_paint_properties, - LayoutPoint(), + PhysicalOffset(), fragment_context.logical_top_in_flow_thread); } DCHECK(fragment_data);
diff --git a/third_party/blink/renderer/core/paint/paint_property_tree_builder.h b/third_party/blink/renderer/core/paint/paint_property_tree_builder.h index bf0c35a..9b7c6d6 100644 --- a/third_party/blink/renderer/core/paint/paint_property_tree_builder.h +++ b/third_party/blink/renderer/core/paint/paint_property_tree_builder.h
@@ -7,7 +7,7 @@ #include "base/memory/scoped_refptr.h" #include "base/optional.h" -#include "third_party/blink/renderer/platform/geometry/layout_point.h" +#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" #include "third_party/blink/renderer/platform/graphics/paint/clip_paint_property_node.h" #include "third_party/blink/renderer/platform/graphics/paint/effect_paint_property_node.h" #include "third_party/blink/renderer/platform/graphics/paint/scroll_paint_property_node.h" @@ -41,9 +41,9 @@ // to refer the object's border box, then the callee will derive its own // border box by translating the space with its own layout location. const TransformPaintPropertyNode* transform = nullptr; - // Corresponds to LayoutObject::PaintOffset, which does not include + // Corresponds to FragmentData::PaintOffset, which does not include // fragmentation offsets. See FragmentContext for the fragmented version. - LayoutPoint paint_offset; + PhysicalOffset paint_offset; // The PaintLayer corresponding to the origin of |paint_offset|. const LayoutObject* paint_offset_root = nullptr; // Whether newly created children should flatten their inherited transform @@ -88,7 +88,7 @@ // This is the same as current.paintOffset except when a floating object has // non-block ancestors under its containing block. Paint offsets of the // non-block ancestors should not be accumulated for the floating object. - LayoutPoint paint_offset_for_float; + PhysicalOffset paint_offset_for_float; // The effect hierarchy is applied by the stacking context tree. It is // guaranteed that every DOM descendant is also a stacking context descendant. @@ -98,7 +98,7 @@ // If the object is a flow thread, this records the clip rect for this // fragment. - base::Optional<LayoutRect> fragment_clip; + base::Optional<PhysicalRect> fragment_clip; // If the object is fragmented, this records the logical top of this fragment // in the flow thread. @@ -107,9 +107,9 @@ // A repeating object paints at multiple places, once in each fragment. // The repeated paintings need to add an adjustment to the calculated paint // offset to paint at the desired place. - LayoutSize repeating_paint_offset_adjustment; + PhysicalOffset repeating_paint_offset_adjustment; - LayoutPoint old_paint_offset; + PhysicalOffset old_paint_offset; }; struct PaintPropertyTreeBuilderContext { @@ -124,7 +124,7 @@ // The physical bounding box of all appearances of the repeating table section // in the flow thread or the paged LayoutView. - LayoutRect repeating_table_section_bounding_box; + PhysicalRect repeating_table_section_bounding_box; #if DCHECK_IS_ON() // When DCHECK_IS_ON() we create PaintPropertyTreeBuilderContext even if not @@ -223,14 +223,14 @@ ALWAYS_INLINE void InitFragmentPaintProperties( FragmentData&, bool needs_paint_properties, - const LayoutPoint& pagination_offset = LayoutPoint(), + const PhysicalOffset& pagination_offset = PhysicalOffset(), LayoutUnit logical_top_in_flow_thread = LayoutUnit()); ALWAYS_INLINE void InitSingleFragmentFromParent(bool needs_paint_properties); ALWAYS_INLINE bool ObjectTypeMightNeedMultipleFragmentData() const; ALWAYS_INLINE bool ObjectTypeMightNeedPaintProperties() const; ALWAYS_INLINE void UpdateCompositedLayerPaginationOffset(); ALWAYS_INLINE PaintPropertyTreeBuilderFragmentContext - ContextForFragment(const base::Optional<LayoutRect>& fragment_clip, + ContextForFragment(const base::Optional<PhysicalRect>& fragment_clip, LayoutUnit logical_top_in_flow_thread) const; ALWAYS_INLINE void CreateFragmentContextsInFlowThread( bool needs_paint_properties);
diff --git a/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.cc b/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.cc index b5560f0..e064ff1 100644 --- a/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.cc +++ b/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.cc
@@ -363,9 +363,9 @@ // 10: border width. 85: container client size (== 100 - scrollbar width). EXPECT_EQ(IntRect(10, 10, 85, 85), scroll->ContainerRect()); EXPECT_EQ(IntSize(400, 400), scroll->ContentsSize()); - EXPECT_EQ(LayoutPoint(), scroller->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), scroller->FirstFragment().PaintOffset()); EXPECT_EQ(IntPoint(315, 0), scroller->ScrollOrigin()); - EXPECT_EQ(LayoutPoint(10, 10), content->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(10, 10), content->FirstFragment().PaintOffset()); EXPECT_EQ(DocContentClip(), overflow_clip->Parent()); EXPECT_EQ(properties->PaintOffsetTranslation(), @@ -381,9 +381,9 @@ EXPECT_EQ(scroll, scroll_translation->ScrollNode()); EXPECT_EQ(IntRect(10, 10, 85, 85), scroll->ContainerRect()); EXPECT_EQ(IntSize(400, 400), scroll->ContentsSize()); - EXPECT_EQ(LayoutPoint(), scroller->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), scroller->FirstFragment().PaintOffset()); EXPECT_EQ(IntPoint(315, 0), scroller->ScrollOrigin()); - EXPECT_EQ(LayoutPoint(10, 10), content->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(10, 10), content->FirstFragment().PaintOffset()); EXPECT_EQ(DocContentClip(), overflow_clip->Parent()); EXPECT_EQ(properties->PaintOffsetTranslation(), @@ -415,9 +415,9 @@ // 85: container client size (== 100 - scrollbar width). EXPECT_EQ(IntRect(25, 10, 85, 85), scroll->ContainerRect()); EXPECT_EQ(IntSize(400, 400), scroll->ContentsSize()); - EXPECT_EQ(LayoutPoint(), scroller->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), scroller->FirstFragment().PaintOffset()); EXPECT_EQ(IntPoint(315, 0), scroller->ScrollOrigin()); - EXPECT_EQ(LayoutPoint(25, 10), content->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(25, 10), content->FirstFragment().PaintOffset()); EXPECT_EQ(DocContentClip(), overflow_clip->Parent()); EXPECT_EQ(properties->PaintOffsetTranslation(), @@ -433,9 +433,9 @@ EXPECT_EQ(scroll, scroll_translation->ScrollNode()); EXPECT_EQ(IntRect(25, 10, 85, 85), scroll->ContainerRect()); EXPECT_EQ(IntSize(400, 400), scroll->ContentsSize()); - EXPECT_EQ(LayoutPoint(), scroller->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), scroller->FirstFragment().PaintOffset()); EXPECT_EQ(IntPoint(315, 0), scroller->ScrollOrigin()); - EXPECT_EQ(LayoutPoint(25, 10), content->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(25, 10), content->FirstFragment().PaintOffset()); EXPECT_EQ(DocContentClip(), overflow_clip->Parent()); EXPECT_EQ(properties->PaintOffsetTranslation(), @@ -467,14 +467,16 @@ ->ClipRect() .Rect() .X()); - EXPECT_EQ(LayoutPoint(360, 10), FragmentAt(flow_thread, 0).PaintOffset()); + EXPECT_EQ(PhysicalOffset(360, 10), + FragmentAt(flow_thread, 0).PaintOffset()); EXPECT_EQ(460, FragmentAt(flow_thread, 1) .PaintProperties() ->FragmentClip() ->ClipRect() .Rect() .MaxX()); - EXPECT_EQ(LayoutPoint(410, 210), FragmentAt(flow_thread, 1).PaintOffset()); + EXPECT_EQ(PhysicalOffset(410, 210), + FragmentAt(flow_thread, 1).PaintOffset()); }; check_fragments(); @@ -1392,11 +1394,12 @@ foreign_object.FirstFragment().PaintProperties(); EXPECT_EQ(TransformationMatrix().Scale(5), foreign_object_properties->Transform()->Matrix()); - EXPECT_EQ(LayoutPoint(10, 10), foreign_object.FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(10, 10), + foreign_object.FirstFragment().PaintOffset()); EXPECT_EQ(nullptr, foreign_object_properties->PaintOffsetTranslation()); LayoutObject& div = *GetLayoutObjectByElementId("div"); - EXPECT_EQ(LayoutPoint(10, 10), div.FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(10, 10), div.FirstFragment().PaintOffset()); } TEST_P(PaintPropertyTreeBuilderTest, ForeignObjectWithMask) { @@ -1583,7 +1586,7 @@ svg_properties->PaintOffsetTranslation()->Translation2D()); LayoutObject& div_with_columns = *GetLayoutObjectByElementId("divWithColumns")->SlowFirstChild(); - EXPECT_EQ(LayoutPoint(0, 0), div_with_columns.FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), div_with_columns.FirstFragment().PaintOffset()); } TEST_P(PaintPropertyTreeBuilderTest, @@ -2149,7 +2152,7 @@ )HTML"); LayoutObject& target = *GetLayoutObjectByElementId("target"); - EXPECT_EQ(LayoutPoint(170, 170), target.FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(170, 170), target.FirstFragment().PaintOffset()); // TODO(crbug.com/732611): CAP invalidations are incorrect if there is // scrolling. if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { @@ -2187,9 +2190,9 @@ </style> <div id='clip'><div id='fixed'></div></div> )HTML"); - LayoutRect local_clip_rect(40, 10, 40, 60); - LayoutRect absolute_clip_rect = local_clip_rect; - absolute_clip_rect.Move(123, 456); + PhysicalRect local_clip_rect(40, 10, 40, 60); + PhysicalRect absolute_clip_rect = local_clip_rect; + absolute_clip_rect.offset += PhysicalOffset(123, 456); LayoutObject& clip = *GetLayoutObjectByElementId("clip"); const ObjectPaintProperties* clip_properties = @@ -2206,7 +2209,7 @@ } EXPECT_EQ(FloatRoundedRect(FloatRect(absolute_clip_rect)), clip_properties->CssClip()->ClipRect()); - CHECK_VISUAL_RECT(PhysicalRectToBeNoop(absolute_clip_rect), &clip, + CHECK_VISUAL_RECT(absolute_clip_rect, &clip, GetDocument().View()->GetLayoutView(), // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() // doesn't apply css clip on the object itself. @@ -2217,7 +2220,7 @@ &fixed->FirstFragment().LocalBorderBoxProperties().Clip()); EXPECT_EQ(DocPreTranslation(), &fixed->FirstFragment().LocalBorderBoxProperties().Transform()); - EXPECT_EQ(LayoutPoint(654, 321), fixed->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(654, 321), fixed->FirstFragment().PaintOffset()); CHECK_VISUAL_RECT(PhysicalRect(), fixed, GetDocument().View()->GetLayoutView(), // TODO(crbug.com/599939): CSS clip of fixed-position @@ -2251,9 +2254,9 @@ <div id='clip'><div id='absolute'></div></div> )HTML"); - LayoutRect local_clip_rect(40, 10, 40, 60); - LayoutRect absolute_clip_rect = local_clip_rect; - absolute_clip_rect.Move(123, 456); + PhysicalRect local_clip_rect(40, 10, 40, 60); + PhysicalRect absolute_clip_rect = local_clip_rect; + absolute_clip_rect.offset += PhysicalOffset(123, 456); auto* clip = GetLayoutObjectByElementId("clip"); const ObjectPaintProperties* clip_properties = @@ -2274,7 +2277,7 @@ } EXPECT_EQ(FloatRoundedRect(FloatRect(absolute_clip_rect)), clip_properties->CssClip()->ClipRect()); - CHECK_VISUAL_RECT(PhysicalRectToBeNoop(absolute_clip_rect), clip, + CHECK_VISUAL_RECT(absolute_clip_rect, clip, GetDocument().View()->GetLayoutView(), // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() // doesn't apply css clip on the object itself. @@ -2296,7 +2299,7 @@ DocScrollTranslation(), &absolute->FirstFragment().LocalBorderBoxProperties().Transform()); } - EXPECT_EQ(LayoutPoint(777, 777), absolute->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(777, 777), absolute->FirstFragment().PaintOffset()); CHECK_VISUAL_RECT(PhysicalRect(), absolute, GetDocument().View()->GetLayoutView(), // TODO(crbug.com/599939): CSS clip of fixed-position @@ -2322,10 +2325,10 @@ <div id='clip'></div> )HTML"); - LayoutRect local_clip_rect(40, 10, 40, 60); - LayoutRect absolute_clip_rect = local_clip_rect; + PhysicalRect local_clip_rect(40, 10, 40, 60); + PhysicalRect absolute_clip_rect = local_clip_rect; // Moved by 124 pixels due to pixel-snapping. - absolute_clip_rect.Move(124, 456); + absolute_clip_rect.offset += PhysicalOffset(124, 456); auto* clip = GetLayoutObjectByElementId("clip"); const ObjectPaintProperties* clip_properties = @@ -2379,9 +2382,9 @@ </style> <div id='overflow'><div id='clip'><div id='fixed'></div></div></div> )HTML"); - LayoutRect local_clip_rect(40, 10, 40, 60); - LayoutRect absolute_clip_rect = local_clip_rect; - absolute_clip_rect.Move(123, 456); + PhysicalRect local_clip_rect(40, 10, 40, 60); + PhysicalRect absolute_clip_rect = local_clip_rect; + absolute_clip_rect.offset += PhysicalOffset(123, 456); LayoutObject& overflow = *GetLayoutObjectByElementId("overflow"); const ObjectPaintProperties* overflow_properties = @@ -2426,7 +2429,7 @@ &fixed->FirstFragment().LocalBorderBoxProperties().Clip()); EXPECT_EQ(DocPreTranslation(), &fixed->FirstFragment().LocalBorderBoxProperties().Transform()); - EXPECT_EQ(LayoutPoint(654, 321), fixed->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(654, 321), fixed->FirstFragment().PaintOffset()); CHECK_VISUAL_RECT(PhysicalRect(), fixed, GetDocument().View()->GetLayoutView(), // TODO(crbug.com/599939): CSS clip of fixed-position @@ -2452,7 +2455,7 @@ )HTML"); LayoutObject* spanner = GetLayoutObjectByElementId("spanner"); - EXPECT_EQ(LayoutPoint(55, 44), spanner->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(55, 44), spanner->FirstFragment().PaintOffset()); CHECK_EXACT_VISUAL_RECT(PhysicalRect(55, 44, 100, 100), spanner, GetDocument().View()->GetLayoutView()); } @@ -2482,15 +2485,15 @@ LocalFrameView* frame_view = GetDocument().View(); LayoutObject* a = GetLayoutObjectByElementId("a"); - LayoutPoint a_paint_offset = LayoutPoint(FloatPoint(0.1, 0.3)); + PhysicalOffset a_paint_offset(LayoutUnit(0.1), LayoutUnit(0.3)); EXPECT_EQ(a_paint_offset, a->FirstFragment().PaintOffset()); CHECK_EXACT_VISUAL_RECT(PhysicalRect(LayoutUnit(0.1), LayoutUnit(0.3), LayoutUnit(70), LayoutUnit(70)), a, frame_view->GetLayoutView()); LayoutObject* b = GetLayoutObjectByElementId("b"); - LayoutPoint b_paint_offset = - a_paint_offset + LayoutPoint(FloatPoint(0.5, 11.1)); + PhysicalOffset b_paint_offset = + a_paint_offset + PhysicalOffset(LayoutUnit(0.5), LayoutUnit(11.1)); EXPECT_EQ(b_paint_offset, b->FirstFragment().PaintOffset()); CHECK_EXACT_VISUAL_RECT(PhysicalRect(LayoutUnit(0.1), LayoutUnit(0.3), LayoutUnit(70), LayoutUnit(70)), @@ -2535,7 +2538,7 @@ // The paint offset transform should be snapped from (0.3,0.3) to (0,0). EXPECT_TRUE(b_properties->Transform()->Parent()->IsIdentity()); // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3). - LayoutPoint subpixel_accumulation = LayoutPoint(FloatPoint(0.3, 0.3)); + PhysicalOffset subpixel_accumulation(LayoutUnit(0.3), LayoutUnit(0.3)); EXPECT_EQ(subpixel_accumulation, b->FirstFragment().PaintOffset()); CHECK_EXACT_VISUAL_RECT(PhysicalRect(LayoutUnit(0.3), LayoutUnit(0.3), LayoutUnit(40), LayoutUnit(40)), @@ -2543,8 +2546,8 @@ // c's painted should start at subpixelAccumulation + (0.1,0.1) = (0.4,0.4). LayoutObject* c = GetLayoutObjectByElementId("c"); - LayoutPoint c_paint_offset = - subpixel_accumulation + LayoutPoint(FloatPoint(0.1, 0.1)); + PhysicalOffset c_paint_offset = + subpixel_accumulation + PhysicalOffset(LayoutUnit(0.1), LayoutUnit(0.1)); EXPECT_EQ(c_paint_offset, c->FirstFragment().PaintOffset()); // Visual rects via the non-paint properties system use enclosingIntRect // before applying transforms, because they are computed bottom-up and @@ -2594,8 +2597,8 @@ EXPECT_EQ(FloatSize(1, 1), b_properties->Transform()->Parent()->Translation2D()); // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3). - LayoutPoint subpixel_accumulation = - LayoutPoint(LayoutPoint(FloatPoint(0.7, 0.7)) - LayoutPoint(1, 1)); + PhysicalOffset subpixel_accumulation = + PhysicalOffset(LayoutUnit(0.7), LayoutUnit(0.7)) - PhysicalOffset(1, 1); EXPECT_EQ(subpixel_accumulation, b->FirstFragment().PaintOffset()); CHECK_EXACT_VISUAL_RECT(PhysicalRect(LayoutUnit(0.7), LayoutUnit(0.7), LayoutUnit(40), LayoutUnit(40)), @@ -2603,8 +2606,8 @@ // c's painting should start at subpixelAccumulation + (0.7,0.7) = (0.4,0.4). LayoutObject* c = GetLayoutObjectByElementId("c"); - LayoutPoint c_paint_offset = - subpixel_accumulation + LayoutPoint(FloatPoint(0.7, 0.7)); + PhysicalOffset c_paint_offset = + subpixel_accumulation + PhysicalOffset(LayoutUnit(0.7), LayoutUnit(0.7)); EXPECT_EQ(c_paint_offset, c->FirstFragment().PaintOffset()); // Visual rects via the non-paint properties system use enclosingIntRect // before applying transforms, because they are computed bottom-up and @@ -2656,7 +2659,7 @@ // The paint offset transform should not be snapped. EXPECT_EQ(FloatSize(1, 1), b_properties->Transform()->Parent()->Translation2D()); - EXPECT_EQ(LayoutPoint(), b->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), b->FirstFragment().PaintOffset()); // Visual rects via the non-paint properties system use enclosingIntRect // before applying transforms, because they are computed bottom-up and // therefore can't apply pixel snapping. Therefore apply a slop of 1px. @@ -2667,7 +2670,8 @@ // c's painting should start at c_offset. LayoutObject* c = GetLayoutObjectByElementId("c"); LayoutUnit c_offset = LayoutUnit(0.6); - EXPECT_EQ(LayoutPoint(c_offset, c_offset), c->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(c_offset, c_offset), + c->FirstFragment().PaintOffset()); // Visual rects via the non-paint properties system use enclosingIntRect // before applying transforms, because they are computed bottom-up and // therefore can't apply pixel snapping. Therefore apply a slop of 1px @@ -2725,8 +2729,8 @@ EXPECT_EQ(FloatSize(1, 1), b_properties->Transform()->Parent()->Translation2D()); // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3). - LayoutPoint subpixel_accumulation = - LayoutPoint(LayoutPoint(FloatPoint(0.7, 0.7)) - LayoutPoint(1, 1)); + PhysicalOffset subpixel_accumulation = + PhysicalOffset(LayoutUnit(0.7), LayoutUnit(0.7)) - PhysicalOffset(1, 1); EXPECT_EQ(subpixel_accumulation, b->FirstFragment().PaintOffset()); CHECK_EXACT_VISUAL_RECT(PhysicalRect(LayoutUnit(5.7), LayoutUnit(7.7), LayoutUnit(40), LayoutUnit(40)), @@ -2748,8 +2752,8 @@ // d should be painted starting at subpixelAccumulation + (0.7,0.7) = // (0.4,0.4). LayoutObject* d = GetLayoutObjectByElementId("d"); - LayoutPoint d_paint_offset = - subpixel_accumulation + LayoutPoint(FloatPoint(0.7, 0.7)); + PhysicalOffset d_paint_offset = + subpixel_accumulation + PhysicalOffset(LayoutUnit(0.7), LayoutUnit(0.7)); EXPECT_EQ(d_paint_offset, d->FirstFragment().PaintOffset()); // Visual rects via the non-paint properties system use enclosingIntRect // before applying transforms, because they are computed bottom-up and @@ -2806,8 +2810,8 @@ EXPECT_EQ(FloatSize(1, 0), b_properties->Transform()->Parent()->Translation2D()); // The residual subpixel adjustment should be (0.7,0) - (1,0) = (-0.3,0). - LayoutPoint subpixel_accumulation = - LayoutPoint(LayoutPoint(FloatPoint(0.7, 0)) - LayoutPoint(1, 0)); + PhysicalOffset subpixel_accumulation = + PhysicalOffset(LayoutUnit(0.7), LayoutUnit()) - PhysicalOffset(1, 0); EXPECT_EQ(subpixel_accumulation, b->FirstFragment().PaintOffset()); CHECK_EXACT_VISUAL_RECT(PhysicalRect(LayoutUnit(0.7), LayoutUnit(0), LayoutUnit(40), LayoutUnit(40)), @@ -2822,8 +2826,8 @@ // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0). LayoutObject* d = GetLayoutObjectByElementId("d"); - LayoutPoint d_paint_offset = - subpixel_accumulation + LayoutPoint(FloatPoint(0.7, 0)); + PhysicalOffset d_paint_offset = + subpixel_accumulation + PhysicalOffset(LayoutUnit(0.7), LayoutUnit()); EXPECT_EQ(d_paint_offset, d->FirstFragment().PaintOffset()); // Visual rects via the non-paint properties system use enclosingIntRect // before applying transforms, because they are computed bottom-up and @@ -2851,7 +2855,7 @@ const ObjectPaintProperties* svg_with_transform_properties = svg_with_transform.FirstFragment().PaintProperties(); EXPECT_TRUE(svg_with_transform_properties->Transform()->IsIdentity()); - EXPECT_EQ(LayoutPoint(FloatPoint(0.1, 0)), + EXPECT_EQ(PhysicalOffset(LayoutUnit(0.1), LayoutUnit()), svg_with_transform.FirstFragment().PaintOffset()); EXPECT_TRUE(svg_with_transform_properties->ReplacedContentTransform() == nullptr); @@ -2884,7 +2888,7 @@ // remains PaintOffset. EXPECT_EQ(FloatSize(9, 8), svg_properties->PaintOffsetTranslation()->Translation2D()); - EXPECT_EQ(LayoutPoint(LayoutUnit(-0.40625), LayoutUnit(0.3)), + EXPECT_EQ(PhysicalOffset(LayoutUnit(-0.40625), LayoutUnit(0.3)), svg->FirstFragment().PaintOffset()); EXPECT_EQ(nullptr, svg_properties->ReplacedContentTransform()); const auto* foreign_object = GetLayoutObjectByElementId("foreign"); @@ -2892,12 +2896,13 @@ foreign_object->FirstFragment().PaintProperties(); EXPECT_EQ(nullptr, foreign_object_properties->PaintOffsetTranslation()); - EXPECT_EQ(LayoutPoint(4, 5), foreign_object->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(4, 5), + foreign_object->FirstFragment().PaintOffset()); const auto* div = GetLayoutObjectByElementId("div"); // Paint offset of descendant of foreignObject accumulates on paint offset // of foreignObject. - EXPECT_EQ(LayoutPoint(LayoutUnit(4 + 5.6), LayoutUnit(5 + 7.3)), + EXPECT_EQ(PhysicalOffset(LayoutUnit(4 + 5.6), LayoutUnit(5 + 7.3)), div->FirstFragment().PaintOffset()); } @@ -3406,7 +3411,7 @@ &clipper->FirstFragment().LocalBorderBoxProperties().Clip()); auto contents_properties = clipper->FirstFragment().ContentsProperties(); - EXPECT_EQ(LayoutPoint(30, 20), clipper->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(30, 20), clipper->FirstFragment().PaintOffset()); // TODO(crbug.com/732611): CAP invalidations are incorrect if there is // scrolling. @@ -3551,7 +3556,7 @@ auto contents_properties = clipper->FirstFragment().ContentsProperties(); // Since the clipper is isolated, its paint offset should be 0, 0. - EXPECT_EQ(LayoutPoint(0, 0), clipper->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), clipper->FirstFragment().PaintOffset()); // Ensure that the contents properties match isolation nodes. EXPECT_EQ(clip_properties->TransformIsolationNode(), &contents_properties.Transform()); @@ -3605,7 +3610,7 @@ auto contents_properties = clipper->FirstFragment().ContentsProperties(); EXPECT_EQ(FloatSize(30, 20), clip_properties->PaintOffsetTranslation()->Translation2D()); - EXPECT_EQ(LayoutPoint(0, 0), clipper->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), clipper->FirstFragment().PaintOffset()); EXPECT_EQ(clip_properties->ScrollTranslation(), &contents_properties.Transform()); EXPECT_EQ(clip_properties->OverflowClip(), &contents_properties.Clip()); @@ -3700,7 +3705,7 @@ &clipper->FirstFragment().LocalBorderBoxProperties().Clip()); auto contents_properties = clipper->FirstFragment().ContentsProperties(); - EXPECT_EQ(LayoutPoint(30, 20), clipper->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(30, 20), clipper->FirstFragment().PaintOffset()); // TODO(crbug.com/732611): CAP invalidations are incorrect if there is // scrolling. if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { @@ -3749,7 +3754,7 @@ EXPECT_EQ(DocScrollTranslation(), paint_offset_translation->Parent()); } EXPECT_EQ(FloatSize(30, 20), paint_offset_translation->Translation2D()); - EXPECT_EQ(LayoutPoint(0, 0), svg_with_view_box.FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), svg_with_view_box.FirstFragment().PaintOffset()); const auto* replaced_content_transform = svg_with_view_box.FirstFragment() .PaintProperties() @@ -4198,12 +4203,12 @@ // Outline does not affect paint offset, since it is positioned to the // top-left of the border box. - EXPECT_EQ(LayoutPoint(8, 8), target1->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(8, 8), target1->FirstFragment().PaintOffset()); // |target1| is only in the first column. EXPECT_FALSE(target1->FirstFragment().NextFragment()); LayoutObject* target2 = GetLayoutObjectByElementId("target2"); - EXPECT_EQ(LayoutPoint(158, 8), target2->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(158, 8), target2->FirstFragment().PaintOffset()); // |target2| is only in the second column. EXPECT_FALSE(target2->FirstFragment().NextFragment()); } @@ -4222,12 +4227,12 @@ LayoutObject* parent = GetLayoutObjectByElementId("parent"); // Parent has 1 fragment regardless of the overflowing child. ASSERT_EQ(1u, NumFragments(parent)); - EXPECT_EQ(LayoutPoint(8, 8), FragmentAt(parent, 0).PaintOffset()); + EXPECT_EQ(PhysicalOffset(8, 8), FragmentAt(parent, 0).PaintOffset()); LayoutObject* child = GetLayoutObjectByElementId("child"); ASSERT_EQ(2u, NumFragments(child)); - EXPECT_EQ(LayoutPoint(8, 8), FragmentAt(child, 0).PaintOffset()); - EXPECT_EQ(LayoutPoint(158, -92), FragmentAt(child, 1).PaintOffset()); + EXPECT_EQ(PhysicalOffset(8, 8), FragmentAt(child, 0).PaintOffset()); + EXPECT_EQ(PhysicalOffset(158, -92), FragmentAt(child, 1).PaintOffset()); } TEST_P(PaintPropertyTreeBuilderTest, SpanFragmentsLimitedToSize) { @@ -4259,16 +4264,16 @@ ASSERT_FALSE( multicol_container->FirstFragment().NextFragment()->NextFragment()); if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { - EXPECT_EQ(LayoutPoint(8, 8), + EXPECT_EQ(PhysicalOffset(8, 8), multicol_container->FirstFragment().PaintOffset()); EXPECT_EQ( - LayoutPoint(59, -12), + PhysicalOffset(59, -12), multicol_container->FirstFragment().NextFragment()->PaintOffset()); } else { - EXPECT_EQ(LayoutPoint(0, 0), + EXPECT_EQ(PhysicalOffset(), multicol_container->FirstFragment().PaintOffset()); EXPECT_EQ( - LayoutPoint(51, -20), + PhysicalOffset(51, -20), multicol_container->FirstFragment().NextFragment()->PaintOffset()); } @@ -4281,10 +4286,10 @@ multicol_container->FirstFragment().NextFragment()->NextFragment()); if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { - EXPECT_EQ(LayoutPoint(8, 8), + EXPECT_EQ(PhysicalOffset(8, 8), multicol_container->FirstFragment().PaintOffset()); EXPECT_EQ( - LayoutPoint(59, -12), + PhysicalOffset(59, -12), multicol_container->FirstFragment().NextFragment()->PaintOffset()); } else { } @@ -4317,12 +4322,12 @@ EXPECT_EQ(4u, NumFragments(relpos)); EXPECT_EQ(4u, NumFragments(flowthread)); - EXPECT_EQ(LayoutPoint(0, 0), FragmentAt(relpos, 0).PaintOffset()); - EXPECT_EQ(LayoutPoint(0, 0), FragmentAt(relpos, 0).PaginationOffset()); + EXPECT_EQ(PhysicalOffset(), FragmentAt(relpos, 0).PaintOffset()); + EXPECT_EQ(PhysicalOffset(), FragmentAt(relpos, 0).PaginationOffset()); EXPECT_EQ(LayoutUnit(), FragmentAt(relpos, 0).LogicalTopInFlowThread()); EXPECT_EQ(nullptr, FragmentAt(relpos, 0).PaintProperties()); - EXPECT_EQ(LayoutPoint(0, 0), FragmentAt(flowthread, 0).PaintOffset()); - EXPECT_EQ(LayoutPoint(0, 0), FragmentAt(flowthread, 0).PaginationOffset()); + EXPECT_EQ(PhysicalOffset(), FragmentAt(flowthread, 0).PaintOffset()); + EXPECT_EQ(PhysicalOffset(), FragmentAt(flowthread, 0).PaginationOffset()); EXPECT_EQ(LayoutUnit(), FragmentAt(flowthread, 0).LogicalTopInFlowThread()); const auto* fragment_clip = FragmentAt(flowthread, 0).PaintProperties()->FragmentClip(); @@ -4332,12 +4337,12 @@ EXPECT_EQ(fragment_clip, &FragmentAt(relpos, 0).LocalBorderBoxProperties().Clip()); - EXPECT_EQ(LayoutPoint(100, -30), FragmentAt(relpos, 1).PaintOffset()); - EXPECT_EQ(LayoutPoint(100, -30), FragmentAt(relpos, 1).PaginationOffset()); + EXPECT_EQ(PhysicalOffset(100, -30), FragmentAt(relpos, 1).PaintOffset()); + EXPECT_EQ(PhysicalOffset(100, -30), FragmentAt(relpos, 1).PaginationOffset()); EXPECT_EQ(LayoutUnit(30), FragmentAt(relpos, 1).LogicalTopInFlowThread()); EXPECT_EQ(nullptr, FragmentAt(relpos, 1).PaintProperties()); - EXPECT_EQ(LayoutPoint(100, -30), FragmentAt(flowthread, 1).PaintOffset()); - EXPECT_EQ(LayoutPoint(100, -30), + EXPECT_EQ(PhysicalOffset(100, -30), FragmentAt(flowthread, 1).PaintOffset()); + EXPECT_EQ(PhysicalOffset(100, -30), FragmentAt(flowthread, 1).PaginationOffset()); EXPECT_EQ(LayoutUnit(30), FragmentAt(flowthread, 1).LogicalTopInFlowThread()); fragment_clip = FragmentAt(flowthread, 1).PaintProperties()->FragmentClip(); @@ -4347,12 +4352,13 @@ EXPECT_EQ(fragment_clip, &FragmentAt(relpos, 1).LocalBorderBoxProperties().Clip()); - EXPECT_EQ(LayoutPoint(0, 20), FragmentAt(relpos, 2).PaintOffset()); - EXPECT_EQ(LayoutPoint(0, 20), FragmentAt(relpos, 2).PaginationOffset()); + EXPECT_EQ(PhysicalOffset(0, 20), FragmentAt(relpos, 2).PaintOffset()); + EXPECT_EQ(PhysicalOffset(0, 20), FragmentAt(relpos, 2).PaginationOffset()); EXPECT_EQ(LayoutUnit(60), FragmentAt(relpos, 2).LogicalTopInFlowThread()); EXPECT_EQ(nullptr, FragmentAt(relpos, 2).PaintProperties()); - EXPECT_EQ(LayoutPoint(0, 20), FragmentAt(flowthread, 2).PaintOffset()); - EXPECT_EQ(LayoutPoint(0, 20), FragmentAt(flowthread, 2).PaginationOffset()); + EXPECT_EQ(PhysicalOffset(0, 20), FragmentAt(flowthread, 2).PaintOffset()); + EXPECT_EQ(PhysicalOffset(0, 20), + FragmentAt(flowthread, 2).PaginationOffset()); EXPECT_EQ(LayoutUnit(60), FragmentAt(flowthread, 2).LogicalTopInFlowThread()); fragment_clip = FragmentAt(flowthread, 2).PaintProperties()->FragmentClip(); ASSERT_NE(nullptr, fragment_clip); @@ -4361,12 +4367,12 @@ EXPECT_EQ(fragment_clip, &FragmentAt(relpos, 2).LocalBorderBoxProperties().Clip()); - EXPECT_EQ(LayoutPoint(100, -10), FragmentAt(relpos, 3).PaintOffset()); - EXPECT_EQ(LayoutPoint(100, -10), FragmentAt(relpos, 3).PaginationOffset()); + EXPECT_EQ(PhysicalOffset(100, -10), FragmentAt(relpos, 3).PaintOffset()); + EXPECT_EQ(PhysicalOffset(100, -10), FragmentAt(relpos, 3).PaginationOffset()); EXPECT_EQ(LayoutUnit(90), FragmentAt(relpos, 3).LogicalTopInFlowThread()); EXPECT_EQ(nullptr, FragmentAt(relpos, 3).PaintProperties()); - EXPECT_EQ(LayoutPoint(100, -10), FragmentAt(flowthread, 3).PaintOffset()); - EXPECT_EQ(LayoutPoint(100, -10), + EXPECT_EQ(PhysicalOffset(100, -10), FragmentAt(flowthread, 3).PaintOffset()); + EXPECT_EQ(PhysicalOffset(100, -10), FragmentAt(flowthread, 3).PaginationOffset()); EXPECT_EQ(LayoutUnit(90), FragmentAt(flowthread, 3).LogicalTopInFlowThread()); fragment_clip = FragmentAt(flowthread, 3).PaintProperties()->FragmentClip(); @@ -4381,31 +4387,31 @@ const auto* space1 = GetLayoutObjectByElementId("space1"); EXPECT_EQ(1u, NumFragments(space1)); EXPECT_EQ(nullptr, space1->FirstFragment().PaintProperties()); - EXPECT_EQ(LayoutPoint(), space1->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), space1->FirstFragment().PaintOffset()); const auto* space2 = GetLayoutObjectByElementId("space2"); EXPECT_EQ(1u, NumFragments(space2)); EXPECT_EQ(nullptr, space2->FirstFragment().PaintProperties()); - EXPECT_EQ(LayoutPoint(100, 0), space2->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(100, 0), space2->FirstFragment().PaintOffset()); // The spanner's normal flow. LayoutObject* spanner = GetLayoutObjectByElementId("spanner"); EXPECT_EQ(1u, NumFragments(spanner)); EXPECT_EQ(nullptr, spanner->FirstFragment().PaintProperties()); - EXPECT_EQ(LayoutPoint(0, 30), spanner->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(0, 30), spanner->FirstFragment().PaintOffset()); LayoutObject* normal = GetLayoutObjectByElementId("normal"); EXPECT_EQ(1u, NumFragments(normal)); EXPECT_EQ(nullptr, normal->FirstFragment().PaintProperties()); - EXPECT_EQ(LayoutPoint(0, 30), normal->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(0, 30), normal->FirstFragment().PaintOffset()); // Below the spanner. const auto* space3 = GetLayoutObjectByElementId("space3"); EXPECT_EQ(1u, NumFragments(space3)); EXPECT_EQ(nullptr, space3->FirstFragment().PaintProperties()); - EXPECT_EQ(LayoutPoint(0, 80), space3->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(0, 80), space3->FirstFragment().PaintOffset()); const auto* space4 = GetLayoutObjectByElementId("space4"); EXPECT_EQ(1u, NumFragments(space4)); EXPECT_EQ(nullptr, space4->FirstFragment().PaintProperties()); - EXPECT_EQ(LayoutPoint(100, 80), space4->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(100, 80), space4->FirstFragment().PaintOffset()); // Out-of-flow positioned descendants of the spanner. They are laid out in // the relative-position container. @@ -4413,7 +4419,7 @@ // "top-left" should be aligned to the top-left corner of space1. const auto* top_left = GetLayoutObjectByElementId("top-left"); EXPECT_EQ(1u, NumFragments(top_left)); - EXPECT_EQ(LayoutPoint(0, 0), top_left->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), top_left->FirstFragment().PaintOffset()); fragment_clip = top_left->FirstFragment().PaintProperties()->FragmentClip(); EXPECT_EQ(FragmentAt(flowthread, 0).PaintProperties()->FragmentClip(), fragment_clip->Parent()); @@ -4421,7 +4427,8 @@ // "bottom-right" should be aligned to the bottom-right corner of space4. const auto* bottom_right = GetLayoutObjectByElementId("bottom-right"); EXPECT_EQ(1u, NumFragments(bottom_right)); - EXPECT_EQ(LayoutPoint(180, 90), bottom_right->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(180, 90), + bottom_right->FirstFragment().PaintOffset()); fragment_clip = bottom_right->FirstFragment().PaintProperties()->FragmentClip(); EXPECT_EQ(FragmentAt(flowthread, 3).PaintProperties()->FragmentClip(), @@ -4444,20 +4451,21 @@ GetLayoutObjectByElementId("multicol")->SlowFirstChild(); EXPECT_TRUE(thread->IsLayoutFlowThread()); EXPECT_EQ(2u, NumFragments(thread)); - EXPECT_EQ(LayoutPoint(100, 0), FragmentAt(thread, 0).PaintOffset()); - EXPECT_EQ(LayoutPoint(0, 0), FragmentAt(thread, 0).PaginationOffset()); + EXPECT_EQ(PhysicalOffset(100, 0), FragmentAt(thread, 0).PaintOffset()); + EXPECT_EQ(PhysicalOffset(), FragmentAt(thread, 0).PaginationOffset()); EXPECT_EQ(LayoutUnit(), FragmentAt(thread, 0).LogicalTopInFlowThread()); - EXPECT_EQ(LayoutPoint(300, 100), FragmentAt(thread, 1).PaintOffset()); - EXPECT_EQ(LayoutPoint(200, 100), FragmentAt(thread, 1).PaginationOffset()); + EXPECT_EQ(PhysicalOffset(300, 100), FragmentAt(thread, 1).PaintOffset()); + EXPECT_EQ(PhysicalOffset(200, 100), FragmentAt(thread, 1).PaginationOffset()); EXPECT_EQ(LayoutUnit(200), FragmentAt(thread, 1).LogicalTopInFlowThread()); LayoutObject* content = GetLayoutObjectByElementId("content"); EXPECT_EQ(2u, NumFragments(content)); - EXPECT_EQ(LayoutPoint(-200, 0), FragmentAt(content, 0).PaintOffset()); - EXPECT_EQ(LayoutPoint(0, 0), FragmentAt(content, 0).PaginationOffset()); + EXPECT_EQ(PhysicalOffset(-200, 0), FragmentAt(content, 0).PaintOffset()); + EXPECT_EQ(PhysicalOffset(), FragmentAt(content, 0).PaginationOffset()); EXPECT_EQ(LayoutUnit(), FragmentAt(content, 0).LogicalTopInFlowThread()); - EXPECT_EQ(LayoutPoint(0, 100), FragmentAt(content, 1).PaintOffset()); - EXPECT_EQ(LayoutPoint(200, 100), FragmentAt(content, 1).PaginationOffset()); + EXPECT_EQ(PhysicalOffset(0, 100), FragmentAt(content, 1).PaintOffset()); + EXPECT_EQ(PhysicalOffset(200, 100), + FragmentAt(content, 1).PaginationOffset()); EXPECT_EQ(LayoutUnit(200), FragmentAt(content, 1).LogicalTopInFlowThread()); } @@ -4496,14 +4504,16 @@ GetLayoutObjectByElementId("multicol")->SlowFirstChild(); EXPECT_TRUE(thread->IsLayoutFlowThread()); EXPECT_EQ(3u, NumFragments(thread)); - EXPECT_EQ(LayoutPoint(0, 0), FragmentAt(thread, 0).PaintOffset()); - EXPECT_EQ(LayoutPoint(0, 0), FragmentAt(thread, 0).PaginationOffset()); + EXPECT_EQ(PhysicalOffset(), FragmentAt(thread, 0).PaintOffset()); + EXPECT_EQ(PhysicalOffset(), FragmentAt(thread, 0).PaginationOffset()); EXPECT_EQ(LayoutUnit(), FragmentAt(thread, 0).LogicalTopInFlowThread()); - EXPECT_EQ(LayoutPoint(100, -200), FragmentAt(thread, 1).PaintOffset()); - EXPECT_EQ(LayoutPoint(100, -200), FragmentAt(thread, 1).PaginationOffset()); + EXPECT_EQ(PhysicalOffset(100, -200), FragmentAt(thread, 1).PaintOffset()); + EXPECT_EQ(PhysicalOffset(100, -200), + FragmentAt(thread, 1).PaginationOffset()); EXPECT_EQ(LayoutUnit(200), FragmentAt(thread, 1).LogicalTopInFlowThread()); - EXPECT_EQ(LayoutPoint(200, -400), FragmentAt(thread, 2).PaintOffset()); - EXPECT_EQ(LayoutPoint(200, -400), FragmentAt(thread, 2).PaginationOffset()); + EXPECT_EQ(PhysicalOffset(200, -400), FragmentAt(thread, 2).PaintOffset()); + EXPECT_EQ(PhysicalOffset(200, -400), + FragmentAt(thread, 2).PaginationOffset()); EXPECT_EQ(LayoutUnit(400), FragmentAt(thread, 2).LogicalTopInFlowThread()); LayoutObject* composited = GetLayoutObjectByElementId("composited"); @@ -4514,55 +4524,58 @@ if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { // Compositing doesn't affect CAP fragmentation. EXPECT_EQ(2u, NumFragments(composited)); - EXPECT_EQ(LayoutPoint(100, 100), FragmentAt(composited, 0).PaintOffset()); - EXPECT_EQ(LayoutPoint(100, -200), + EXPECT_EQ(PhysicalOffset(100, 100), + FragmentAt(composited, 0).PaintOffset()); + EXPECT_EQ(PhysicalOffset(100, -200), FragmentAt(composited, 0).PaginationOffset()); EXPECT_EQ(LayoutUnit(200), FragmentAt(composited, 0).LogicalTopInFlowThread()); - EXPECT_EQ(LayoutPoint(200, -100), FragmentAt(composited, 1).PaintOffset()); - EXPECT_EQ(LayoutPoint(200, -400), + EXPECT_EQ(PhysicalOffset(200, -100), + FragmentAt(composited, 1).PaintOffset()); + EXPECT_EQ(PhysicalOffset(200, -400), FragmentAt(composited, 1).PaginationOffset()); EXPECT_EQ(LayoutUnit(400), FragmentAt(composited, 1).LogicalTopInFlowThread()); EXPECT_EQ(2u, NumFragments(non_composited_child)); - EXPECT_EQ(LayoutPoint(100, 100), + EXPECT_EQ(PhysicalOffset(100, 100), FragmentAt(non_composited_child, 0).PaintOffset()); - EXPECT_EQ(LayoutPoint(100, -200), + EXPECT_EQ(PhysicalOffset(100, -200), FragmentAt(non_composited_child, 0).PaginationOffset()); EXPECT_EQ(LayoutUnit(200), FragmentAt(non_composited_child, 0).LogicalTopInFlowThread()); - EXPECT_EQ(LayoutPoint(200, -100), + EXPECT_EQ(PhysicalOffset(200, -100), FragmentAt(non_composited_child, 1).PaintOffset()); - EXPECT_EQ(LayoutPoint(200, -400), + EXPECT_EQ(PhysicalOffset(200, -400), FragmentAt(non_composited_child, 1).PaginationOffset()); EXPECT_EQ(LayoutUnit(400), FragmentAt(non_composited_child, 1).LogicalTopInFlowThread()); EXPECT_EQ(1u, NumFragments(composited_child)); - EXPECT_EQ(LayoutPoint(200, 50), + EXPECT_EQ(PhysicalOffset(200, 50), FragmentAt(composited_child, 0).PaintOffset()); - EXPECT_EQ(LayoutPoint(200, -400), + EXPECT_EQ(PhysicalOffset(200, -400), FragmentAt(composited_child, 0).PaginationOffset()); EXPECT_EQ(LayoutUnit(400), FragmentAt(composited_child, 0).LogicalTopInFlowThread()); } else { // SPv1 forces single fragment for composited layers. EXPECT_EQ(1u, NumFragments(composited)); - EXPECT_EQ(LayoutPoint(100, 100), FragmentAt(composited, 0).PaintOffset()); - EXPECT_EQ(LayoutPoint(100, -200), + EXPECT_EQ(PhysicalOffset(100, 100), + FragmentAt(composited, 0).PaintOffset()); + EXPECT_EQ(PhysicalOffset(100, -200), FragmentAt(composited, 0).PaginationOffset()); EXPECT_EQ(LayoutUnit(200), FragmentAt(composited, 0).LogicalTopInFlowThread()); EXPECT_EQ(1u, NumFragments(non_composited_child)); - EXPECT_EQ(LayoutPoint(100, 100), + EXPECT_EQ(PhysicalOffset(100, 100), FragmentAt(non_composited_child, 0).PaintOffset()); - EXPECT_EQ(LayoutPoint(100, -200), + EXPECT_EQ(PhysicalOffset(100, -200), FragmentAt(non_composited_child, 0).PaginationOffset()); EXPECT_EQ(LayoutUnit(200), FragmentAt(non_composited_child, 0).LogicalTopInFlowThread()); EXPECT_EQ(1u, NumFragments(composited_child)); - EXPECT_EQ(LayoutPoint(100, 250), + EXPECT_EQ(PhysicalOffset(100, 250), FragmentAt(composited_child, 0).PaintOffset()); - EXPECT_EQ(LayoutPoint(100, -200), + EXPECT_EQ(PhysicalOffset(100, -200), FragmentAt(composited_child, 0).PaginationOffset()); EXPECT_EQ(LayoutUnit(200), FragmentAt(composited_child, 0).LogicalTopInFlowThread()); @@ -4661,14 +4674,14 @@ )HTML"); LayoutObject* target = GetLayoutObjectByElementId("target"); - EXPECT_EQ(LayoutPoint(LayoutUnit(392.5f), LayoutUnit(-20)), + EXPECT_EQ(PhysicalOffset(LayoutUnit(392.5f), LayoutUnit(-20)), target->FirstFragment().PaginationOffset()); EXPECT_EQ(LayoutUnit(20), target->FirstFragment().LogicalTopInFlowThread()); Element* target_element = GetDocument().getElementById("target"); target_element->setAttribute(html_names::kStyleAttr, "position: absolute"); UpdateAllLifecyclePhasesForTest(); - EXPECT_EQ(LayoutPoint(0, 0), target->FirstFragment().PaginationOffset()); + EXPECT_EQ(PhysicalOffset(), target->FirstFragment().PaginationOffset()); EXPECT_EQ(LayoutUnit(), target->FirstFragment().LogicalTopInFlowThread()); } @@ -4911,9 +4924,9 @@ LayoutObject* target = GetLayoutObjectByElementId("target"); if (RuntimeEnabledFeatures::LayoutNGEnabled()) { - EXPECT_EQ(LayoutPoint(266, 155), target->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(266, 155), target->FirstFragment().PaintOffset()); } else { - EXPECT_EQ(LayoutPoint(66, 55), target->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(66, 55), target->FirstFragment().PaintOffset()); } EXPECT_EQ(effect, &target->FirstFragment().LocalBorderBoxProperties().Effect()); @@ -4954,7 +4967,7 @@ const ObjectPaintProperties* clip_properties = clipper->FirstFragment().PaintProperties(); - EXPECT_EQ(LayoutPoint(FloatPoint(31.5, 20)), + EXPECT_EQ(PhysicalOffset(LayoutUnit(31.5), LayoutUnit(20)), clipper->FirstFragment().PaintOffset()); // Result is pixel-snapped. EXPECT_EQ(FloatRect(32, 20, 400, 300), @@ -5327,7 +5340,7 @@ target_properties->PaintOffsetTranslation(); if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { EXPECT_EQ(nullptr, paint_offset_translation); - EXPECT_EQ(LayoutPoint(60, 50), target->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(60, 50), target->FirstFragment().PaintOffset()); } else { // For SPv1, |target| is composited so we created PaintOffsetTranslation. ASSERT_NE(nullptr, paint_offset_translation); @@ -5349,7 +5362,7 @@ ToElement(target->GetNode())->setAttribute(html_names::kStyleAttr, ""); UpdateAllLifecyclePhasesForTest(); - EXPECT_EQ(LayoutPoint(60, 50), target->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(60, 50), target->FirstFragment().PaintOffset()); EXPECT_EQ(nullptr, target->FirstFragment().PaintProperties()); } @@ -5513,8 +5526,8 @@ const auto* second_fragment = first_fragment.NextFragment(); ASSERT_NE(nullptr, second_fragment); - EXPECT_EQ(LayoutPoint(), first_fragment.PaintOffset()); - EXPECT_EQ(LayoutPoint(390, -10), second_fragment->PaintOffset()); + EXPECT_EQ(PhysicalOffset(), first_fragment.PaintOffset()); + EXPECT_EQ(PhysicalOffset(390, -10), second_fragment->PaintOffset()); EXPECT_EQ(IntRect(0, 0, 20, 20), first_fragment.VisualRect()); EXPECT_EQ(IntRect(390, -10, 20, 20), second_fragment->VisualRect()); } @@ -5862,7 +5875,7 @@ EXPECT_EQ(3u, NumFragments(fixed)); for (int i = 0; i < 3; i++) { const auto& fragment = FragmentAt(fixed, i); - EXPECT_EQ(LayoutPoint(20, -180 + i * 400), fragment.PaintOffset()); + EXPECT_EQ(PhysicalOffset(20, -180 + i * 400), fragment.PaintOffset()); EXPECT_EQ(LayoutUnit(400 * i), fragment.LogicalTopInFlowThread()); } @@ -5870,7 +5883,7 @@ EXPECT_EQ(3u, NumFragments(fixed_child)); for (int i = 0; i < 3; i++) { const auto& fragment = FragmentAt(fixed_child, i); - EXPECT_EQ(LayoutPoint(20, -170 + i * 400), fragment.PaintOffset()); + EXPECT_EQ(PhysicalOffset(20, -170 + i * 400), fragment.PaintOffset()); EXPECT_EQ(LayoutUnit(i * 400), fragment.LogicalTopInFlowThread()); } @@ -5920,7 +5933,7 @@ EXPECT_EQ(3u, NumFragments(fixed)); for (int i = 0; i < 3; i++) { const auto& fragment = FragmentAt(fixed, i); - EXPECT_EQ(LayoutPoint(), fragment.PaintOffset()); + EXPECT_EQ(PhysicalOffset(), fragment.PaintOffset()); EXPECT_EQ(LayoutUnit(i * 400), fragment.LogicalTopInFlowThread()); const auto* properties = fragment.PaintProperties(); EXPECT_EQ(FloatSize(20, -180 + i * 400), @@ -5933,7 +5946,7 @@ EXPECT_FALSE(fixed_child->IsFixedPositionObjectInPagedMedia()); for (int i = 0; i < 3; i++) { const auto& fragment = FragmentAt(fixed_child, i); - EXPECT_EQ(LayoutPoint(0, 10), fragment.PaintOffset()); + EXPECT_EQ(PhysicalOffset(0, 10), fragment.PaintOffset()); EXPECT_EQ(LayoutUnit(i * 400), fragment.LogicalTopInFlowThread()); EXPECT_EQ(FragmentAt(fixed, i).PaintProperties()->Transform(), &fragment.LocalBorderBoxProperties().Transform()); @@ -6006,14 +6019,14 @@ // The first header is at its normal flow location (0, 100px) in its page. // The other repeated ones are at the top of the their pages. - EXPECT_EQ(LayoutPoint(0, 500), FragmentAt(head, 0).PaintOffset()); - EXPECT_EQ(LayoutPoint(0, 800), FragmentAt(head, 1).PaintOffset()); - EXPECT_EQ(LayoutPoint(0, 1200), FragmentAt(head, 2).PaintOffset()); + EXPECT_EQ(PhysicalOffset(0, 500), FragmentAt(head, 0).PaintOffset()); + EXPECT_EQ(PhysicalOffset(0, 800), FragmentAt(head, 1).PaintOffset()); + EXPECT_EQ(PhysicalOffset(0, 1200), FragmentAt(head, 2).PaintOffset()); // The last footer is at its normal flow location (0, 200px) in its page. // The other repeated ones are at the bottom of their pages. - EXPECT_EQ(LayoutPoint(0, 700), FragmentAt(foot, 0).PaintOffset()); - EXPECT_EQ(LayoutPoint(0, 1100), FragmentAt(foot, 1).PaintOffset()); - EXPECT_EQ(LayoutPoint(0, 1400), FragmentAt(foot, 2).PaintOffset()); + EXPECT_EQ(PhysicalOffset(0, 700), FragmentAt(foot, 0).PaintOffset()); + EXPECT_EQ(PhysicalOffset(0, 1100), FragmentAt(foot, 1).PaintOffset()); + EXPECT_EQ(PhysicalOffset(0, 1400), FragmentAt(foot, 2).PaintOffset()); const auto& painting_layer_object = head->PaintingLayer()->GetLayoutObject(); ASSERT_EQ(1u, NumFragments(&painting_layer_object)); @@ -6072,18 +6085,18 @@ auto paint_offset = [this](const char* id) { return GetLayoutObjectByElementId(id)->FirstFragment().PaintOffset(); }; - EXPECT_EQ(LayoutPoint(0, 0), paint_offset("float-left")); - EXPECT_EQ(LayoutPoint(85, 100), paint_offset("float-right")); - EXPECT_EQ(LayoutPoint(15, 0), paint_offset("float-left-rtl")); - EXPECT_EQ(LayoutPoint(100, 100), paint_offset("float-right-rtl")); - EXPECT_EQ(LayoutPoint(100, 0), paint_offset("float-left-vrl")); - EXPECT_EQ(LayoutPoint(0, 85), paint_offset("float-right-vrl")); - EXPECT_EQ(LayoutPoint(100, 0), paint_offset("float-left-rtl-vrl")); - EXPECT_EQ(LayoutPoint(0, 85), paint_offset("float-right-rtl-vrl")); - EXPECT_EQ(LayoutPoint(0, 0), paint_offset("float-left-vlr")); - EXPECT_EQ(LayoutPoint(100, 85), paint_offset("float-right-vlr")); - EXPECT_EQ(LayoutPoint(0, 0), paint_offset("float-left-rtl-vlr")); - EXPECT_EQ(LayoutPoint(100, 85), paint_offset("float-right-rtl-vlr")); + EXPECT_EQ(PhysicalOffset(), paint_offset("float-left")); + EXPECT_EQ(PhysicalOffset(85, 100), paint_offset("float-right")); + EXPECT_EQ(PhysicalOffset(15, 0), paint_offset("float-left-rtl")); + EXPECT_EQ(PhysicalOffset(100, 100), paint_offset("float-right-rtl")); + EXPECT_EQ(PhysicalOffset(100, 0), paint_offset("float-left-vrl")); + EXPECT_EQ(PhysicalOffset(0, 85), paint_offset("float-right-vrl")); + EXPECT_EQ(PhysicalOffset(100, 0), paint_offset("float-left-rtl-vrl")); + EXPECT_EQ(PhysicalOffset(0, 85), paint_offset("float-right-rtl-vrl")); + EXPECT_EQ(PhysicalOffset(), paint_offset("float-left-vlr")); + EXPECT_EQ(PhysicalOffset(100, 85), paint_offset("float-right-vlr")); + EXPECT_EQ(PhysicalOffset(), paint_offset("float-left-rtl-vlr")); + EXPECT_EQ(PhysicalOffset(100, 85), paint_offset("float-right-rtl-vlr")); } TEST_P(PaintPropertyTreeBuilderTest, SubpixelPositionedScrollNode) {
diff --git a/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.h b/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.h index 07115c9..367952b 100644 --- a/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.h +++ b/third_party/blink/renderer/core/paint/paint_property_tree_builder_test.h
@@ -12,10 +12,10 @@ namespace blink { -class TransformPaintPropertyNode; class ClipPaintPropertyNode; class ScrollPaintPropertyNode; -class LayoutPoint; +class TransformPaintPropertyNode; +struct PhysicalOffset; class PaintPropertyTreeBuilderTest : public PaintControllerPaintTest { public: @@ -37,7 +37,7 @@ // Return the local border box's paint offset. For more details, see // ObjectPaintProperties::localBorderBoxProperties(). - LayoutPoint PaintOffset(const LayoutObject*); + PhysicalOffset PaintOffset(const LayoutObject*); const ObjectPaintProperties* PaintPropertiesForElement(const char* name);
diff --git a/third_party/blink/renderer/core/paint/paint_property_tree_update_tests.cc b/third_party/blink/renderer/core/paint/paint_property_tree_update_tests.cc index fcf15ed..87ea6a3 100644 --- a/third_party/blink/renderer/core/paint/paint_property_tree_update_tests.cc +++ b/third_party/blink/renderer/core/paint/paint_property_tree_update_tests.cc
@@ -1590,28 +1590,28 @@ auto* parent = parent_element->GetLayoutObject(); auto* isolation_properties = PaintPropertiesForElement("isolation"); auto* child = GetLayoutObjectByElementId("child"); - EXPECT_EQ(LayoutPoint(LayoutUnit(10.25), LayoutUnit()), + EXPECT_EQ(PhysicalOffset(LayoutUnit(10.25), LayoutUnit()), parent->FirstFragment().PaintOffset()); EXPECT_EQ(FloatSize(10, 0), isolation_properties->PaintOffsetTranslation()->Translation2D()); if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { - EXPECT_EQ(LayoutPoint(), child->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), child->FirstFragment().PaintOffset()); } else { - EXPECT_EQ(LayoutPoint(LayoutUnit(0.25), LayoutUnit()), + EXPECT_EQ(PhysicalOffset(LayoutUnit(0.25), LayoutUnit()), child->FirstFragment().PaintOffset()); } parent_element->setAttribute(html_names::kStyleAttr, "margin-left: 12.75px"); UpdateAllLifecyclePhasesForTest(); - EXPECT_EQ(LayoutPoint(LayoutUnit(12.75), LayoutUnit()), + EXPECT_EQ(PhysicalOffset(LayoutUnit(12.75), LayoutUnit()), parent->FirstFragment().PaintOffset()); EXPECT_EQ(FloatSize(13, 0), isolation_properties->PaintOffsetTranslation()->Translation2D()); if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { - EXPECT_EQ(LayoutPoint(), child->FirstFragment().PaintOffset()); + EXPECT_EQ(PhysicalOffset(), child->FirstFragment().PaintOffset()); } else { - EXPECT_EQ(LayoutPoint(LayoutUnit(-0.25), LayoutUnit()), + EXPECT_EQ(PhysicalOffset(LayoutUnit(-0.25), LayoutUnit()), child->FirstFragment().PaintOffset()); } }
diff --git a/third_party/blink/renderer/core/paint/pre_paint_tree_walk.cc b/third_party/blink/renderer/core/paint/pre_paint_tree_walk.cc index d537a6c..638317a 100644 --- a/third_party/blink/renderer/core/paint/pre_paint_tree_walk.cc +++ b/third_party/blink/renderer/core/paint/pre_paint_tree_walk.cc
@@ -482,14 +482,11 @@ FrameView* frame_view = layout_embedded_content.ChildFrameView(); if (auto* local_frame_view = DynamicTo<LocalFrameView>(frame_view)) { if (context().tree_builder_context) { - context().tree_builder_context->fragments[0].current.paint_offset += - layout_embedded_content.ReplacedContentRect() - .offset.ToLayoutPoint() - - local_frame_view->FrameRect().Location(); - context() - .tree_builder_context->fragments[0] - .current.paint_offset = RoundedIntPoint( - context().tree_builder_context->fragments[0].current.paint_offset); + auto& offset = + context().tree_builder_context->fragments[0].current.paint_offset; + offset += layout_embedded_content.ReplacedContentRect().offset; + offset -= PhysicalOffset(local_frame_view->FrameRect().Location()); + offset = PhysicalOffset(RoundedIntPoint(offset)); } Walk(*local_frame_view); }
diff --git a/third_party/blink/renderer/core/paint/replaced_painter.cc b/third_party/blink/renderer/core/paint/replaced_painter.cc index 2cce90f..69265da39 100644 --- a/third_party/blink/renderer/core/paint/replaced_painter.cc +++ b/third_party/blink/renderer/core/paint/replaced_painter.cc
@@ -97,7 +97,7 @@ const auto& local_paint_info = paint_state.GetPaintInfo(); auto paint_offset = paint_state.PaintOffset(); - LayoutRect border_rect(paint_offset, layout_replaced_.Size()); + PhysicalRect border_rect(paint_offset, layout_replaced_.Size()); if (ShouldPaintBoxDecorationBackground(local_paint_info)) { bool should_paint_background = false; @@ -179,9 +179,9 @@ if (draw_selection_tint && !DrawingRecorder::UseCachedDrawingIfPossible( local_paint_info.context, layout_replaced_, DisplayItem::kSelectionTint)) { - LayoutRect selection_painting_rect = - layout_replaced_.LocalSelectionVisualRect().ToLayoutRect(); - selection_painting_rect.MoveBy(paint_offset); + PhysicalRect selection_painting_rect = + layout_replaced_.LocalSelectionVisualRect(); + selection_painting_rect.Move(paint_offset); IntRect selection_painting_int_rect = PixelSnappedIntRect(selection_painting_rect);
diff --git a/third_party/blink/renderer/core/paint/rounded_inner_rect_clipper.cc b/third_party/blink/renderer/core/paint/rounded_inner_rect_clipper.cc index a4d21f2..029cc2d 100644 --- a/third_party/blink/renderer/core/paint/rounded_inner_rect_clipper.cc +++ b/third_party/blink/renderer/core/paint/rounded_inner_rect_clipper.cc
@@ -4,15 +4,15 @@ #include "third_party/blink/renderer/core/paint/rounded_inner_rect_clipper.h" +#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" #include "third_party/blink/renderer/platform/geometry/float_rounded_rect.h" -#include "third_party/blink/renderer/platform/geometry/layout_rect.h" #include "third_party/blink/renderer/platform/graphics/graphics_context.h" namespace blink { RoundedInnerRectClipper::RoundedInnerRectClipper( GraphicsContext& context, - const LayoutRect& rect, + const PhysicalRect& rect, const FloatRoundedRect& clip_rect) : context_(context) { Vector<FloatRoundedRect> rounded_rect_clips; @@ -24,8 +24,8 @@ if (!clip_rect.GetRadii().TopLeft().IsEmpty() || !clip_rect.GetRadii().BottomRight().IsEmpty()) { FloatRect top_corner(clip_rect.Rect().X(), clip_rect.Rect().Y(), - rect.MaxX() - clip_rect.Rect().X(), - rect.MaxY() - clip_rect.Rect().Y()); + rect.Right() - clip_rect.Rect().X(), + rect.Bottom() - clip_rect.Rect().Y()); FloatRoundedRect::Radii top_corner_radii; top_corner_radii.SetTopLeft(clip_rect.GetRadii().TopLeft()); rounded_rect_clips.push_back( @@ -44,14 +44,14 @@ !clip_rect.GetRadii().BottomLeft().IsEmpty()) { FloatRect top_corner(rect.X().ToFloat(), clip_rect.Rect().Y(), clip_rect.Rect().MaxX() - rect.X().ToFloat(), - rect.MaxY() - clip_rect.Rect().Y()); + rect.Bottom() - clip_rect.Rect().Y()); FloatRoundedRect::Radii top_corner_radii; top_corner_radii.SetTopRight(clip_rect.GetRadii().TopRight()); rounded_rect_clips.push_back( FloatRoundedRect(top_corner, top_corner_radii)); FloatRect bottom_corner(clip_rect.Rect().X(), rect.Y().ToFloat(), - rect.MaxX() - clip_rect.Rect().X(), + rect.Right() - clip_rect.Rect().X(), clip_rect.Rect().MaxY() - rect.Y().ToFloat()); FloatRoundedRect::Radii bottom_corner_radii; bottom_corner_radii.SetBottomLeft(clip_rect.GetRadii().BottomLeft());
diff --git a/third_party/blink/renderer/core/paint/rounded_inner_rect_clipper.h b/third_party/blink/renderer/core/paint/rounded_inner_rect_clipper.h index 466740e..2a98bb7 100644 --- a/third_party/blink/renderer/core/paint/rounded_inner_rect_clipper.h +++ b/third_party/blink/renderer/core/paint/rounded_inner_rect_clipper.h
@@ -11,14 +11,14 @@ class FloatRoundedRect; class GraphicsContext; -class LayoutRect; +struct PhysicalRect; class RoundedInnerRectClipper { DISALLOW_NEW(); public: RoundedInnerRectClipper(GraphicsContext&, - const LayoutRect&, + const PhysicalRect&, const FloatRoundedRect& clip_rect); ~RoundedInnerRectClipper();
diff --git a/third_party/blink/renderer/core/paint/scoped_paint_state.cc b/third_party/blink/renderer/core/paint/scoped_paint_state.cc index 33b485a..759d8bd7 100644 --- a/third_party/blink/renderer/core/paint/scoped_paint_state.cc +++ b/third_party/blink/renderer/core/paint/scoped_paint_state.cc
@@ -66,7 +66,7 @@ // for the reason of adding ScrollOrigin(). contents_paint_offset will // be used only for the scrolling contents that are not painted through // descendant objects' Paint() method, e.g. inline boxes. - paint_offset_ += box.ScrollOrigin(); + paint_offset_ += PhysicalOffset(box.ScrollOrigin()); // If a LayoutView is using infinite cull rect, we are painting with viewport // clip disabled, so don't cull the scrolling contents. This is just for
diff --git a/third_party/blink/renderer/core/paint/scoped_paint_state.h b/third_party/blink/renderer/core/paint/scoped_paint_state.h index 8515af9..4fffbf9 100644 --- a/third_party/blink/renderer/core/paint/scoped_paint_state.h +++ b/third_party/blink/renderer/core/paint/scoped_paint_state.h
@@ -35,8 +35,8 @@ // The object has nothing to paint in the current fragment. // TODO(wangxianzhu): Use DCHECK(fragment_to_paint_) in PaintOffset() // when all painters check FragmentToPaint() before painting. - paint_offset_ = LayoutPoint( - LayoutPoint(LayoutUnit::NearlyMax(), LayoutUnit::NearlyMax())); + paint_offset_ = + PhysicalOffset(LayoutUnit::NearlyMax(), LayoutUnit::NearlyMax()); return; } paint_offset_ = fragment_to_paint_->PaintOffset(); @@ -73,24 +73,21 @@ return *adjusted_paint_info_; } - LayoutPoint PaintOffset() const { return paint_offset_; } + PhysicalOffset PaintOffset() const { return paint_offset_; } const FragmentData* FragmentToPaint() const { return fragment_to_paint_; } - LayoutRect LocalCullRect() const { - auto cull_rect = LayoutRect(GetPaintInfo().GetCullRect().Rect()); - cull_rect.MoveBy(-PaintOffset()); + PhysicalRect LocalCullRect() const { + PhysicalRect cull_rect(LayoutRect(GetPaintInfo().GetCullRect().Rect())); + cull_rect.Move(-PaintOffset()); return cull_rect; } - bool LocalRectIntersectsCullRect(const LayoutRect& local_rect) const { - LayoutRect rect_in_paint_info_space = local_rect; - rect_in_paint_info_space.MoveBy(PaintOffset()); - return GetPaintInfo().GetCullRect().Intersects(rect_in_paint_info_space); - } - bool LocalRectIntersectsCullRect(const PhysicalRect& local_rect) const { - return LocalRectIntersectsCullRect(local_rect.ToLayoutRect()); + PhysicalRect rect_in_paint_info_space = local_rect; + rect_in_paint_info_space.Move(PaintOffset()); + return GetPaintInfo().GetCullRect().Intersects( + rect_in_paint_info_space.ToLayoutRect()); } protected: @@ -102,7 +99,7 @@ // TODO(wangxianzhu): Remove this constructor when we pass ScopedPaintState to // PaintXXX() methods of the same object. ScopedPaintState(const PaintInfo& paint_info, - const LayoutPoint& paint_offset, + const PhysicalOffset& paint_offset, const LayoutObject& object) : fragment_to_paint_(paint_info.FragmentToPaint(object)), input_paint_info_(paint_info), @@ -118,7 +115,7 @@ protected: const FragmentData* fragment_to_paint_; const PaintInfo& input_paint_info_; - LayoutPoint paint_offset_; + PhysicalOffset paint_offset_; base::Optional<PaintInfo> adjusted_paint_info_; base::Optional<ScopedPaintChunkProperties> chunk_properties_; bool paint_offset_translation_as_drawing_ = false; @@ -137,7 +134,7 @@ // TODO(wangxianzhu): Remove this constructor when we pass ScopedPaintState to // PaintXXX() methods of the same object. ScopedBoxContentsPaintState(const PaintInfo& paint_info, - const LayoutPoint& paint_offset, + const PhysicalOffset& paint_offset, const LayoutBox& box) : ScopedPaintState(paint_info, paint_offset, box) { AdjustForBoxContents(box);
diff --git a/third_party/blink/renderer/core/paint/scoped_svg_paint_state.cc b/third_party/blink/renderer/core/paint/scoped_svg_paint_state.cc index 1a79dc9..406ff7d8 100644 --- a/third_party/blink/renderer/core/paint/scoped_svg_paint_state.cc +++ b/third_party/blink/renderer/core/paint/scoped_svg_paint_state.cc
@@ -131,8 +131,10 @@ } void ScopedSVGPaintState::ApplyClipIfNecessary() { - if (object_.StyleRef().ClipPath()) - clip_path_clipper_.emplace(GetPaintInfo().context, object_, LayoutPoint()); + if (object_.StyleRef().ClipPath()) { + clip_path_clipper_.emplace(GetPaintInfo().context, object_, + PhysicalOffset()); + } } bool ScopedSVGPaintState::ApplyMaskIfNecessary(SVGResources* resources) {
diff --git a/third_party/blink/renderer/core/paint/scrollable_area_painter.cc b/third_party/blink/renderer/core/paint/scrollable_area_painter.cc index e07b50a..2dc2294f 100644 --- a/third_party/blink/renderer/core/paint/scrollable_area_painter.cc +++ b/third_party/blink/renderer/core/paint/scrollable_area_painter.cc
@@ -38,8 +38,9 @@ if (const auto* resizer = GetScrollableArea().Resizer()) { if (!cull_rect.Intersects(abs_rect)) return; - ScrollbarPainter::PaintIntoRect(*resizer, context, paint_offset, - LayoutRect(abs_rect)); + ScrollbarPainter::PaintIntoRect(*resizer, context, + PhysicalOffset(paint_offset), + PhysicalRect(abs_rect)); return; } @@ -245,8 +246,9 @@ if (const auto* scroll_corner = GetScrollableArea().ScrollCorner()) { if (!adjusted_cull_rect.Intersects(abs_rect)) return; - ScrollbarPainter::PaintIntoRect(*scroll_corner, context, paint_offset, - LayoutRect(abs_rect)); + ScrollbarPainter::PaintIntoRect(*scroll_corner, context, + PhysicalOffset(paint_offset), + PhysicalRect(abs_rect)); return; }
diff --git a/third_party/blink/renderer/core/paint/scrollbar_painter.cc b/third_party/blink/renderer/core/paint/scrollbar_painter.cc index 38b1ff8..30bdae14 100644 --- a/third_party/blink/renderer/core/paint/scrollbar_painter.cc +++ b/third_party/blink/renderer/core/paint/scrollbar_painter.cc
@@ -20,29 +20,29 @@ if (!part_layout_object) return; PaintIntoRect(*part_layout_object, graphics_context, - layout_scrollbar_->Location(), LayoutRect(rect), - layout_scrollbar_.Get()); + PhysicalOffset(layout_scrollbar_->Location()), + PhysicalRect(rect), layout_scrollbar_.Get()); } void ScrollbarPainter::PaintIntoRect( const LayoutScrollbarPart& layout_scrollbar_part, GraphicsContext& graphics_context, - const LayoutPoint& paint_offset, - const LayoutRect& rect, + const PhysicalOffset& paint_offset, + const PhysicalRect& rect, const LayoutScrollbar* scrollbar) { // Make sure our dimensions match the rect. // TODO(crbug.com/856802): Setting these is a bad layering violation! // Move these into layout stage. const_cast<LayoutScrollbarPart&>(layout_scrollbar_part) - .SetLocation(rect.Location() - ToSize(paint_offset)); + .SetLocation((rect.offset - paint_offset).ToLayoutPoint()); const_cast<LayoutScrollbarPart&>(layout_scrollbar_part) - .SetWidth(rect.Width()); + .SetWidth(rect.size.width); const_cast<LayoutScrollbarPart&>(layout_scrollbar_part) - .SetHeight(rect.Height()); + .SetHeight(rect.size.height); // TODO(crbug.com/856802): Move this into PaintPropertyTreeBuilder. layout_scrollbar_part.GetMutableForPainting().FirstFragment().SetPaintOffset( - (scrollbar ? scrollbar->Location() : LayoutPoint()) + - layout_scrollbar_part.PhysicalLocation().ToLayoutPoint()); + (scrollbar ? PhysicalOffset(scrollbar->Location()) : PhysicalOffset()) + + layout_scrollbar_part.PhysicalLocation()); PaintInfo paint_info(graphics_context, PixelSnappedIntRect(rect), PaintPhase::kForeground, kGlobalPaintNormalPhase,
diff --git a/third_party/blink/renderer/core/paint/scrollbar_painter.h b/third_party/blink/renderer/core/paint/scrollbar_painter.h index e5962c33..cee75be 100644 --- a/third_party/blink/renderer/core/paint/scrollbar_painter.h +++ b/third_party/blink/renderer/core/paint/scrollbar_painter.h
@@ -13,10 +13,10 @@ class GraphicsContext; class IntRect; -class LayoutPoint; -class LayoutRect; class LayoutScrollbar; class LayoutScrollbarPart; +struct PhysicalOffset; +struct PhysicalRect; class ScrollbarPainter { STACK_ALLOCATED(); @@ -28,8 +28,8 @@ void PaintPart(GraphicsContext&, ScrollbarPart, const IntRect&); static void PaintIntoRect(const LayoutScrollbarPart&, GraphicsContext&, - const LayoutPoint& paint_offset, - const LayoutRect&, + const PhysicalOffset& paint_offset, + const PhysicalRect&, const LayoutScrollbar* = nullptr); private:
diff --git a/third_party/blink/renderer/core/paint/svg_container_painter.cc b/third_party/blink/renderer/core/paint/svg_container_painter.cc index 580014e..8d90950b 100644 --- a/third_party/blink/renderer/core/paint/svg_container_painter.cc +++ b/third_party/blink/renderer/core/paint/svg_container_painter.cc
@@ -98,7 +98,7 @@ if (paint_info_before_filtering.IsPrinting() && paint_info_before_filtering.phase == PaintPhase::kForeground) { ObjectPainter(layout_svg_container_) - .AddPDFURLRectIfNeeded(paint_info_before_filtering, LayoutPoint()); + .AddPDFURLRectIfNeeded(paint_info_before_filtering, PhysicalOffset()); } }
diff --git a/third_party/blink/renderer/core/paint/svg_foreign_object_painter.cc b/third_party/blink/renderer/core/paint/svg_foreign_object_painter.cc index cb53167f..5312cee1 100644 --- a/third_party/blink/renderer/core/paint/svg_foreign_object_painter.cc +++ b/third_party/blink/renderer/core/paint/svg_foreign_object_painter.cc
@@ -45,7 +45,7 @@ // cull rects under transform are intentionally reset to infinity, // to improve cache invalidation performance in the pre-paint tree // walk (see https://http://crrev.com/482854). - CullRect::Infinite(), paint_info.GetGlobalPaintFlags(), LayoutSize()); + CullRect::Infinite(), paint_info.GetGlobalPaintFlags(), PhysicalOffset()); PaintLayerPainter(*layout_svg_foreign_object_.Layer()) .Paint(paint_info.context, layer_painting_info, paint_info.PaintFlags()); }
diff --git a/third_party/blink/renderer/core/paint/svg_model_object_painter.cc b/third_party/blink/renderer/core/paint/svg_model_object_painter.cc index af119db4..dc21e16 100644 --- a/third_party/blink/renderer/core/paint/svg_model_object_painter.cc +++ b/third_party/blink/renderer/core/paint/svg_model_object_painter.cc
@@ -60,7 +60,8 @@ outline_paint_info.phase = PaintPhase::kSelfOutlineOnly; auto visual_rect = layout_svg_model_object_.VisualRectInLocalSVGCoordinates(); ObjectPainter(layout_svg_model_object_) - .PaintOutline(outline_paint_info, LayoutPoint(visual_rect.Location())); + .PaintOutline(outline_paint_info, PhysicalOffset::FromFloatPointRound( + visual_rect.Location())); } } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/svg_root_painter.cc b/third_party/blink/renderer/core/paint/svg_root_painter.cc index ae930b0..3e415f2f 100644 --- a/third_party/blink/renderer/core/paint/svg_root_painter.cc +++ b/third_party/blink/renderer/core/paint/svg_root_painter.cc
@@ -17,12 +17,13 @@ namespace blink { IntRect SVGRootPainter::PixelSnappedSize( - const LayoutPoint& paint_offset) const { - return PixelSnappedIntRect(paint_offset, layout_svg_root_.Size()); + const PhysicalOffset& paint_offset) const { + return PixelSnappedIntRect( + PhysicalRect(paint_offset, layout_svg_root_.Size())); } AffineTransform SVGRootPainter::TransformToPixelSnappedBorderBox( - const LayoutPoint& paint_offset) const { + const PhysicalOffset& paint_offset) const { const IntRect snapped_size = PixelSnappedSize(paint_offset); AffineTransform paint_offset_to_border_box = AffineTransform::Translation(snapped_size.X(), snapped_size.Y()); @@ -38,7 +39,7 @@ } void SVGRootPainter::PaintReplaced(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { // An empty viewport disables rendering. if (PixelSnappedSize(paint_offset).IsEmpty()) return;
diff --git a/third_party/blink/renderer/core/paint/svg_root_painter.h b/third_party/blink/renderer/core/paint/svg_root_painter.h index f267c2e6..7dfb8bc7 100644 --- a/third_party/blink/renderer/core/paint/svg_root_painter.h +++ b/third_party/blink/renderer/core/paint/svg_root_painter.h
@@ -9,11 +9,11 @@ namespace blink { -struct PaintInfo; class AffineTransform; class IntRect; -class LayoutPoint; class LayoutSVGRoot; +struct PaintInfo; +struct PhysicalOffset; class SVGRootPainter { STACK_ALLOCATED(); @@ -22,17 +22,17 @@ SVGRootPainter(const LayoutSVGRoot& layout_svg_root) : layout_svg_root_(layout_svg_root) {} - void PaintReplaced(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintReplaced(const PaintInfo&, const PhysicalOffset& paint_offset); // The embedded SVG document uses an unsnapped viewport box for layout, while // SVG root's border box ultimately gets snapped during paint. This // translate/scale transform is applied to compensate the difference, in // addition to applying the local to border box transform. AffineTransform TransformToPixelSnappedBorderBox( - const LayoutPoint& paint_offset) const; + const PhysicalOffset& paint_offset) const; private: - IntRect PixelSnappedSize(const LayoutPoint& paint_offset) const; + IntRect PixelSnappedSize(const PhysicalOffset& paint_offset) const; const LayoutSVGRoot& layout_svg_root_; };
diff --git a/third_party/blink/renderer/core/paint/table_cell_painter.cc b/third_party/blink/renderer/core/paint/table_cell_painter.cc index a6fd7f6..43ad0a4 100644 --- a/third_party/blink/renderer/core/paint/table_cell_painter.cc +++ b/third_party/blink/renderer/core/paint/table_cell_painter.cc
@@ -41,7 +41,7 @@ } void TableCellPainter::PaintBackground(const PaintInfo& paint_info, - const LayoutRect& paint_rect, + const PhysicalRect& paint_rect, const LayoutObject& background_object) { if (layout_table_cell_.BackgroundTransfersToView()) return; @@ -57,7 +57,7 @@ layout_table_cell_.Table()->ShouldCollapseBorders(); GraphicsContextStateSaver state_saver(paint_info.context, should_clip); if (should_clip) { - LayoutRect clip_rect(paint_rect.Location(), layout_table_cell_.Size()); + PhysicalRect clip_rect(paint_rect.offset, layout_table_cell_.Size()); clip_rect.Expand(layout_table_cell_.BorderInsets()); paint_info.context.Clip(PixelSnappedIntRect(clip_rect)); } @@ -69,7 +69,7 @@ void TableCellPainter::PaintBoxDecorationBackground( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { LayoutTable* table = layout_table_cell_.Table(); const ComputedStyle& style = layout_table_cell_.StyleRef(); if (!table->ShouldCollapseBorders() && @@ -80,14 +80,14 @@ BoxDecorationData box_decoration_data(paint_info, layout_table_cell_); const DisplayItemClient* client = nullptr; - LayoutRect paint_rect; + PhysicalRect paint_rect; base::Optional<ScopedBoxContentsPaintState> contents_paint_state; if (box_decoration_data.IsPaintingScrollingBackground()) { // See BoxPainter::PaintBoxDecorationBackground() for explanations. // TODO(wangxianzhu): Perhaps we can merge them for CompositeAfterPaint. - paint_rect = layout_table_cell_.PhysicalLayoutOverflowRect().ToLayoutRect(); + paint_rect = layout_table_cell_.PhysicalLayoutOverflowRect(); contents_paint_state.emplace(paint_info, paint_offset, layout_table_cell_); - paint_rect.MoveBy(contents_paint_state->PaintOffset()); + paint_rect.Move(contents_paint_state->PaintOffset()); paint_rect.Expand(layout_table_cell_.BorderBoxOutsets()); client = &layout_table_cell_.GetScrollableArea() ->GetScrollingBackgroundDisplayItemClient(); @@ -115,9 +115,7 @@ // from the overridden BorderXXX() methods). Otherwise the following code // is equivalent to BoxPainterBase::PaintInsetBoxShadowWithBorderRect(). auto inner_rect = paint_rect; - inner_rect.ContractEdges( - layout_table_cell_.BorderTop(), layout_table_cell_.BorderRight(), - layout_table_cell_.BorderBottom(), layout_table_cell_.BorderLeft()); + inner_rect.Contract(layout_table_cell_.BorderBoxOutsets()); BoxPainterBase::PaintInsetBoxShadowWithInnerRect( paint_info, inner_rect, layout_table_cell_.StyleRef()); } @@ -134,7 +132,7 @@ } void TableCellPainter::PaintMask(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { if (layout_table_cell_.StyleRef().Visibility() != EVisibility::kVisible || paint_info.phase != PaintPhase::kMask) return; @@ -151,17 +149,17 @@ DrawingRecorder recorder(paint_info.context, layout_table_cell_, paint_info.phase); - LayoutRect paint_rect = PaintRectNotIncludingVisualOverflow(paint_offset); + PhysicalRect paint_rect = PaintRectNotIncludingVisualOverflow(paint_offset); BoxPainter(layout_table_cell_).PaintMaskImages(paint_info, paint_rect); } // TODO(crbug.com/377847): When table cells fully support subpixel layout, we // should not snap the size to pixels here. We should remove this function and // snap to pixels for the rect with paint offset applied. -LayoutRect TableCellPainter::PaintRectNotIncludingVisualOverflow( - const LayoutPoint& paint_offset) { - return LayoutRect(paint_offset, - LayoutSize(layout_table_cell_.PixelSnappedSize())); +PhysicalRect TableCellPainter::PaintRectNotIncludingVisualOverflow( + const PhysicalOffset& paint_offset) { + return PhysicalRect(paint_offset, + PhysicalSize(layout_table_cell_.PixelSnappedSize())); } } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/table_cell_painter.h b/third_party/blink/renderer/core/paint/table_cell_painter.h index bfa5716..1d8d6a3a 100644 --- a/third_party/blink/renderer/core/paint/table_cell_painter.h +++ b/third_party/blink/renderer/core/paint/table_cell_painter.h
@@ -10,11 +10,11 @@ namespace blink { -struct PaintInfo; -class LayoutPoint; -class LayoutRect; class LayoutTableCell; class LayoutObject; +struct PaintInfo; +struct PhysicalOffset; +struct PhysicalRect; class TableCellPainter { STACK_ALLOCATED(); @@ -27,15 +27,15 @@ const PaintInfo&, const LayoutObject& background_object); void PaintBoxDecorationBackground(const PaintInfo&, - const LayoutPoint& paint_offset); - void PaintMask(const PaintInfo&, const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); + void PaintMask(const PaintInfo&, const PhysicalOffset& paint_offset); - LayoutRect PaintRectNotIncludingVisualOverflow( - const LayoutPoint& paint_offset); + PhysicalRect PaintRectNotIncludingVisualOverflow( + const PhysicalOffset& paint_offset); private: void PaintBackground(const PaintInfo&, - const LayoutRect&, + const PhysicalRect&, const LayoutObject& background_object); const LayoutTableCell& layout_table_cell_;
diff --git a/third_party/blink/renderer/core/paint/table_painter.cc b/third_party/blink/renderer/core/paint/table_painter.cc index 23a820c..a136ca85 100644 --- a/third_party/blink/renderer/core/paint/table_painter.cc +++ b/third_party/blink/renderer/core/paint/table_painter.cc
@@ -16,7 +16,7 @@ namespace blink { void TablePainter::PaintObject(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { PaintPhase paint_phase = paint_info.phase; if (ShouldPaintSelfBlockBackground(paint_phase)) { @@ -54,8 +54,8 @@ void TablePainter::PaintBoxDecorationBackground( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { - LayoutRect rect(paint_offset, layout_table_.Size()); + const PhysicalOffset& paint_offset) { + PhysicalRect rect(paint_offset, layout_table_.Size()); layout_table_.SubtractCaptionRect(rect); if (layout_table_.HasBoxDecorationBackground() && @@ -68,7 +68,7 @@ } void TablePainter::PaintMask(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { if (layout_table_.StyleRef().Visibility() != EVisibility::kVisible || paint_info.phase != PaintPhase::kMask) return; @@ -77,7 +77,7 @@ paint_info.context, layout_table_, paint_info.phase)) return; - LayoutRect rect(paint_offset, layout_table_.Size()); + PhysicalRect rect(paint_offset, layout_table_.Size()); layout_table_.SubtractCaptionRect(rect); DrawingRecorder recorder(paint_info.context, layout_table_, paint_info.phase);
diff --git a/third_party/blink/renderer/core/paint/table_painter.h b/third_party/blink/renderer/core/paint/table_painter.h index 3cea620..1a3d513 100644 --- a/third_party/blink/renderer/core/paint/table_painter.h +++ b/third_party/blink/renderer/core/paint/table_painter.h
@@ -9,9 +9,9 @@ namespace blink { -class LayoutPoint; class LayoutTable; struct PaintInfo; +struct PhysicalOffset; class TablePainter { STACK_ALLOCATED(); @@ -19,10 +19,10 @@ public: TablePainter(const LayoutTable& layout_table) : layout_table_(layout_table) {} - void PaintObject(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintObject(const PaintInfo&, const PhysicalOffset& paint_offset); void PaintBoxDecorationBackground(const PaintInfo&, - const LayoutPoint& paint_offset); - void PaintMask(const PaintInfo&, const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); + void PaintMask(const PaintInfo&, const PhysicalOffset& paint_offset); private: void PaintCollapsedBorders(const PaintInfo&);
diff --git a/third_party/blink/renderer/core/paint/table_row_painter.cc b/third_party/blink/renderer/core/paint/table_row_painter.cc index 58d9d24d..384e9a72 100644 --- a/third_party/blink/renderer/core/paint/table_row_painter.cc +++ b/third_party/blink/renderer/core/paint/table_row_painter.cc
@@ -69,7 +69,7 @@ } void TableRowPainter::RecordHitTestData(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { // Hit test display items are only needed for compositing. This flag is used // for for printing and drag images which do not need hit testing. if (paint_info.GetGlobalPaintFlags() & kGlobalPaintFlattenCompositingLayers) @@ -83,10 +83,10 @@ if (touch_action == TouchAction::kTouchActionAuto) return; - auto rect = layout_table_row_.BorderBoxRect(); - rect.MoveBy(paint_offset); + auto rect = layout_table_row_.PhysicalBorderBoxRect(); + rect.offset += paint_offset; HitTestDisplayItem::Record(paint_info.context, layout_table_row_, - HitTestRect(rect, touch_action)); + HitTestRect(rect.ToLayoutRect(), touch_action)); } void TableRowPainter::PaintBoxDecorationBackground( @@ -111,7 +111,7 @@ DrawingRecorder recorder(local_paint_info.context, layout_table_row_, DisplayItem::kBoxDecorationBackground); - LayoutRect paint_rect(paint_offset, layout_table_row_.Size()); + PhysicalRect paint_rect(paint_offset, layout_table_row_.Size()); if (has_box_shadow) { BoxPainterBase::PaintNormalBoxShadow(local_paint_info, paint_rect,
diff --git a/third_party/blink/renderer/core/paint/table_row_painter.h b/third_party/blink/renderer/core/paint/table_row_painter.h index 19ea79a..298526c 100644 --- a/third_party/blink/renderer/core/paint/table_row_painter.h +++ b/third_party/blink/renderer/core/paint/table_row_painter.h
@@ -10,10 +10,10 @@ namespace blink { -struct PaintInfo; class CellSpan; -class LayoutPoint; class LayoutTableRow; +struct PaintInfo; +struct PhysicalOffset; class TableRowPainter { STACK_ALLOCATED(); @@ -34,7 +34,7 @@ // Paint a hit test display item and record hit test data. This should be // called in the background paint phase even if there is no other painted // content. - void RecordHitTestData(const PaintInfo&, const LayoutPoint& paint_offset); + void RecordHitTestData(const PaintInfo&, const PhysicalOffset& paint_offset); const LayoutTableRow& layout_table_row_; };
diff --git a/third_party/blink/renderer/core/paint/table_section_painter.cc b/third_party/blink/renderer/core/paint/table_section_painter.cc index bd02fbf..f4fc4c8 100644 --- a/third_party/blink/renderer/core/paint/table_section_painter.cc +++ b/third_party/blink/renderer/core/paint/table_section_painter.cc
@@ -113,13 +113,13 @@ LayoutRect TableSectionPainter::TableAlignedRect( const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { - LayoutRect local_cull_rect = LayoutRect(paint_info.GetCullRect().Rect()); - local_cull_rect.MoveBy(-paint_offset); + const PhysicalOffset& paint_offset) { + PhysicalRect local_cull_rect(paint_info.GetCullRect().Rect()); + local_cull_rect.offset -= paint_offset; LayoutRect table_aligned_rect = layout_table_section_.LogicalRectForWritingModeAndDirection( - local_cull_rect); + local_cull_rect.ToLayoutRect()); return table_aligned_rect; } @@ -166,7 +166,7 @@ } void TableSectionPainter::PaintObject(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { CellSpan dirtied_rows; CellSpan dirtied_columns; layout_table_section_.DirtiedRowsAndEffectiveColumns( @@ -266,7 +266,7 @@ void TableSectionPainter::PaintBoxDecorationBackground( const PaintInfo& paint_info, - const LayoutPoint& paint_offset, + const PhysicalOffset& paint_offset, const CellSpan& dirtied_rows, const CellSpan& dirtied_columns) { bool may_have_background = layout_table_section_.Table()->HasColElements() || @@ -290,7 +290,7 @@ DrawingRecorder recorder(paint_info.context, layout_table_section_, DisplayItem::kBoxDecorationBackground); - LayoutRect paint_rect(paint_offset, layout_table_section_.Size()); + PhysicalRect paint_rect(paint_offset, layout_table_section_.Size()); if (has_box_shadow) { BoxPainterBase::PaintNormalBoxShadow(paint_info, paint_rect,
diff --git a/third_party/blink/renderer/core/paint/table_section_painter.h b/third_party/blink/renderer/core/paint/table_section_painter.h index eabff48..68159e9 100644 --- a/third_party/blink/renderer/core/paint/table_section_painter.h +++ b/third_party/blink/renderer/core/paint/table_section_painter.h
@@ -13,10 +13,10 @@ namespace blink { class CellSpan; -class LayoutPoint; class LayoutTableCell; class LayoutTableSection; struct PaintInfo; +struct PhysicalOffset; class TableSectionPainter { STACK_ALLOCATED(); @@ -29,10 +29,10 @@ void PaintCollapsedBorders(const PaintInfo&); private: - void PaintObject(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintObject(const PaintInfo&, const PhysicalOffset& paint_offset); void PaintBoxDecorationBackground(const PaintInfo&, - const LayoutPoint&, + const PhysicalOffset&, const CellSpan& dirtied_rows, const CellSpan& dirtied_columns); void PaintBackgroundsBehindCell(const LayoutTableCell&, const PaintInfo&); @@ -42,7 +42,7 @@ void PaintCollapsedSectionBorders(const PaintInfo&); LayoutRect TableAlignedRect(const PaintInfo& paint_info, - const LayoutPoint& paint_offset); + const PhysicalOffset& paint_offset); const LayoutTableSection& layout_table_section_; };
diff --git a/third_party/blink/renderer/core/paint/text_control_single_line_painter.cc b/third_party/blink/renderer/core/paint/text_control_single_line_painter.cc index 07d4c03..1bc1623f 100644 --- a/third_party/blink/renderer/core/paint/text_control_single_line_painter.cc +++ b/third_party/blink/renderer/core/paint/text_control_single_line_painter.cc
@@ -26,8 +26,7 @@ DrawingRecorder recorder(paint_info.context, text_control_, DisplayItem::kCapsLockIndicator); - LayoutRect contents_rect = - text_control_.PhysicalContentBoxRect().ToLayoutRect(); + PhysicalRect contents_rect = text_control_.PhysicalContentBoxRect(); // Center in the block progression direction. if (text_control_.IsHorizontalWritingMode()) { @@ -40,7 +39,7 @@ // Convert the rect into the coords used for painting the content. ScopedPaintState paint_state(text_control_, paint_info); - contents_rect.MoveBy(paint_state.PaintOffset()); + contents_rect.Move(paint_state.PaintOffset()); IntRect snapped_rect = PixelSnappedIntRect(contents_rect); LayoutTheme::GetTheme().Painter().PaintCapsLockIndicator( text_control_, paint_state.GetPaintInfo(), snapped_rect);
diff --git a/third_party/blink/renderer/core/paint/text_painter.cc b/third_party/blink/renderer/core/paint/text_painter.cc index 0414c5fa..9bf5699 100644 --- a/third_party/blink/renderer/core/paint/text_painter.cc +++ b/third_party/blink/renderer/core/paint/text_painter.cc
@@ -36,7 +36,7 @@ if (combined_text_) { graphics_context_.Save(); combined_text_->TransformToInlineCoordinates(graphics_context_, - text_bounds_); + text_bounds_.ToLayoutRect()); PaintInternal<kPaintText>(start_offset, end_offset, length, node_holder); graphics_context_.Restore(); } else {
diff --git a/third_party/blink/renderer/core/paint/text_painter.h b/third_party/blink/renderer/core/paint/text_painter.h index 976d1b8..8ab421041 100644 --- a/third_party/blink/renderer/core/paint/text_painter.h +++ b/third_party/blink/renderer/core/paint/text_painter.h
@@ -26,7 +26,11 @@ const LayoutPoint& text_origin, const LayoutRect& text_bounds, bool horizontal) - : TextPainterBase(context, font, text_origin, text_bounds, horizontal), + : TextPainterBase(context, + font, + PhysicalOffset(text_origin), + PhysicalRect(text_bounds), + horizontal), run_(run), combined_text_(nullptr) {} ~TextPainter() = default;
diff --git a/third_party/blink/renderer/core/paint/text_painter_base.cc b/third_party/blink/renderer/core/paint/text_painter_base.cc index f75868f..419b89ad 100644 --- a/third_party/blink/renderer/core/paint/text_painter_base.cc +++ b/third_party/blink/renderer/core/paint/text_painter_base.cc
@@ -22,8 +22,8 @@ TextPainterBase::TextPainterBase(GraphicsContext& context, const Font& font, - const LayoutPoint& text_origin, - const LayoutRect& text_bounds, + const PhysicalOffset& text_origin, + const PhysicalRect& text_bounds, bool horizontal) : graphics_context_(context), font_(font), @@ -347,8 +347,8 @@ void TextPainterBase::ComputeDecorationInfo( DecorationInfo& decoration_info, - const LayoutPoint& box_origin, - LayoutPoint local_origin, + const PhysicalOffset& box_origin, + PhysicalOffset local_origin, LayoutUnit width, FontBaseline baseline_type, const ComputedStyle& style,
diff --git a/third_party/blink/renderer/core/paint/text_painter_base.h b/third_party/blink/renderer/core/paint/text_painter_base.h index 4ccb353..4c6bf8bf 100644 --- a/third_party/blink/renderer/core/paint/text_painter_base.h +++ b/third_party/blink/renderer/core/paint/text_painter_base.h
@@ -6,11 +6,11 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_TEXT_PAINTER_BASE_H_ #include "third_party/blink/renderer/core/core_export.h" +#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" #include "third_party/blink/renderer/core/paint/decoration_info.h" #include "third_party/blink/renderer/core/paint/text_paint_style.h" #include "third_party/blink/renderer/core/style/applied_text_decoration.h" #include "third_party/blink/renderer/platform/fonts/font.h" -#include "third_party/blink/renderer/platform/geometry/layout_rect.h" #include "third_party/blink/renderer/platform/graphics/color.h" #include "third_party/blink/renderer/platform/transforms/affine_transform.h" #include "third_party/blink/renderer/platform/wtf/allocator.h" @@ -34,8 +34,8 @@ public: TextPainterBase(GraphicsContext&, const Font&, - const LayoutPoint& text_origin, - const LayoutRect& text_bounds, + const PhysicalOffset& text_origin, + const PhysicalRect& text_bounds, bool horizontal); ~TextPainterBase(); @@ -68,8 +68,8 @@ float decoration_offset); void ComputeDecorationInfo(DecorationInfo&, - const LayoutPoint& box_origin, - LayoutPoint local_origin, + const PhysicalOffset& box_origin, + PhysicalOffset local_origin, LayoutUnit width, FontBaseline, const ComputedStyle&, @@ -88,7 +88,7 @@ const TextPaintStyle& text_style); enum RotationDirection { kCounterclockwise, kClockwise }; - static AffineTransform Rotation(const LayoutRect& box_rect, + static AffineTransform Rotation(const PhysicalRect& box_rect, RotationDirection); protected: @@ -106,8 +106,8 @@ GraphicsContext& graphics_context_; const Font& font_; - LayoutPoint text_origin_; - LayoutRect text_bounds_; + PhysicalOffset text_origin_; + PhysicalRect text_bounds_; bool horizontal_; bool has_combined_text_; AtomicString emphasis_mark_; @@ -116,7 +116,7 @@ }; inline AffineTransform TextPainterBase::Rotation( - const LayoutRect& box_rect, + const PhysicalRect& box_rect, RotationDirection rotation_direction) { // Why this matrix is correct: consider the case of a clockwise rotation. @@ -134,10 +134,10 @@ // A similar argument derives the counter-clockwise case. return rotation_direction == kClockwise - ? AffineTransform(0, 1, -1, 0, box_rect.X() + box_rect.MaxY(), + ? AffineTransform(0, 1, -1, 0, box_rect.X() + box_rect.Bottom(), box_rect.Y() - box_rect.X()) : AffineTransform(0, -1, 1, 0, box_rect.X() - box_rect.Y(), - box_rect.X() + box_rect.MaxY()); + box_rect.X() + box_rect.Bottom()); } } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/theme_painter_default.cc b/third_party/blink/renderer/core/paint/theme_painter_default.cc index cc4261b..61a4d03 100644 --- a/third_party/blink/renderer/core/paint/theme_painter_default.cc +++ b/third_party/blink/renderer/core/paint/theme_painter_default.cc
@@ -124,15 +124,15 @@ IntRect ConvertToPaintingRect(const LayoutObject& input_layout_object, const LayoutObject& part_layout_object, - LayoutRect part_rect, + PhysicalRect part_rect, const IntRect& local_offset) { // Compute an offset between the partLayoutObject and the inputLayoutObject. PhysicalOffset offset_from_input_layout_object = -part_layout_object.OffsetFromAncestor(&input_layout_object); // Move the rect into partLayoutObject's coords. - part_rect.Move(offset_from_input_layout_object.ToLayoutSize()); + part_rect.Move(offset_from_input_layout_object); // Account for the local drawing offset. - part_rect.Move(local_offset.X(), local_offset.Y()); + part_rect.Move(PhysicalOffset(local_offset.Location())); return PixelSnappedIntRect(part_rect); } @@ -464,18 +464,17 @@ if (!base_layout_object.IsBox()) return false; const LayoutBox& input_layout_box = ToLayoutBox(base_layout_object); - LayoutRect input_content_box = - input_layout_box.PhysicalContentBoxRect().ToLayoutRect(); + PhysicalRect input_content_box = input_layout_box.PhysicalContentBoxRect(); // Make sure the scaled button stays square and will fit in its parent's box. LayoutUnit cancel_button_size = - std::min(input_content_box.Width(), - std::min(input_content_box.Height(), LayoutUnit(r.Height()))); + std::min(input_content_box.size.width, + std::min(input_content_box.size.height, LayoutUnit(r.Height()))); // Calculate cancel button's coordinates relative to the input element. // Center the button vertically. Round up though, so if it has to be one // pixel off-center, it will be one pixel closer to the bottom of the field. // This tends to look better with the text. - LayoutRect cancel_button_rect( + PhysicalRect cancel_button_rect( cancel_button_object.OffsetFromAncestor(&input_layout_box).left, input_content_box.Y() + (input_content_box.Height() - cancel_button_size + 1) / 2,
diff --git a/third_party/blink/renderer/core/paint/video_painter.cc b/third_party/blink/renderer/core/paint/video_painter.cc index 798f58f2..efc55f2 100644 --- a/third_party/blink/renderer/core/paint/video_painter.cc +++ b/third_party/blink/renderer/core/paint/video_painter.cc
@@ -18,7 +18,7 @@ namespace blink { void VideoPainter::PaintReplaced(const PaintInfo& paint_info, - const LayoutPoint& paint_offset) { + const PhysicalOffset& paint_offset) { WebMediaPlayer* media_player = layout_video_.MediaElement()->GetWebMediaPlayer(); bool displaying_poster = @@ -26,8 +26,8 @@ if (!displaying_poster && !media_player) return; - LayoutRect replaced_rect(layout_video_.ReplacedContentRect().ToLayoutRect()); - replaced_rect.MoveBy(paint_offset); + PhysicalRect replaced_rect = layout_video_.ReplacedContentRect(); + replaced_rect.Move(paint_offset); IntRect snapped_replaced_rect = PixelSnappedIntRect(replaced_rect); if (snapped_replaced_rect.IsEmpty()) @@ -38,9 +38,8 @@ return; GraphicsContext& context = paint_info.context; - LayoutRect content_box_rect = - layout_video_.PhysicalContentBoxRect().ToLayoutRect(); - content_box_rect.MoveBy(paint_offset); + PhysicalRect content_box_rect = layout_video_.PhysicalContentBoxRect(); + content_box_rect.Move(paint_offset); // Since we may have changed the location of the replaced content, we need to // notify PAC.
diff --git a/third_party/blink/renderer/core/paint/video_painter.h b/third_party/blink/renderer/core/paint/video_painter.h index bac0cbe..8dd89ea 100644 --- a/third_party/blink/renderer/core/paint/video_painter.h +++ b/third_party/blink/renderer/core/paint/video_painter.h
@@ -9,9 +9,9 @@ namespace blink { -struct PaintInfo; -class LayoutPoint; class LayoutVideo; +struct PaintInfo; +struct PhysicalOffset; class VideoPainter { STACK_ALLOCATED(); @@ -19,7 +19,7 @@ public: VideoPainter(const LayoutVideo& layout_video) : layout_video_(layout_video) {} - void PaintReplaced(const PaintInfo&, const LayoutPoint& paint_offset); + void PaintReplaced(const PaintInfo&, const PhysicalOffset& paint_offset); private: const LayoutVideo& layout_video_;
diff --git a/third_party/blink/renderer/core/paint/view_painter.cc b/third_party/blink/renderer/core/paint/view_painter.cc index 6485a81..0e72fb2 100644 --- a/third_party/blink/renderer/core/paint/view_painter.cc +++ b/third_party/blink/renderer/core/paint/view_painter.cc
@@ -73,7 +73,7 @@ } if (has_touch_action_rect) { BoxPainter(layout_view_) - .RecordHitTestData(paint_info, LayoutRect(background_rect), + .RecordHitTestData(paint_info, PhysicalRect(background_rect), *background_client); } } @@ -154,9 +154,9 @@ } const PaintLayer& root_layer = *ToLayoutBoxModelObject(root_object)->Layer(); - LayoutPoint offset; + PhysicalOffset offset; root_layer.ConvertToLayerCoords(nullptr, offset); - transform.Translate(offset.X(), offset.Y()); + transform.Translate(offset.left, offset.top); transform.Multiply( root_layer.RenderableTransform(paint_info.GetGlobalPaintFlags())); @@ -245,7 +245,7 @@ (*it)->Attachment() == EFillAttachment::kFixed; if (should_paint_in_viewport_space) { box_model_painter.PaintFillLayer(paint_info, Color(), **it, - LayoutRect(background_rect), + PhysicalRect(background_rect), kBackgroundBleedNone, geometry); } else { context.Save(); @@ -253,7 +253,7 @@ // background with slimming paint by using transform display items. context.ConcatCTM(transform.ToAffineTransform()); box_model_painter.PaintFillLayer(paint_info, Color(), **it, - LayoutRect(paint_rect), + PhysicalRect(paint_rect), kBackgroundBleedNone, geometry); context.Restore(); }
diff --git a/third_party/blink/renderer/core/scheduler/frame_throttling_test.cc b/third_party/blink/renderer/core/scheduler/frame_throttling_test.cc index eb6fb69..a85f62742 100644 --- a/third_party/blink/renderer/core/scheduler/frame_throttling_test.cc +++ b/third_party/blink/renderer/core/scheduler/frame_throttling_test.cc
@@ -804,7 +804,6 @@ DocumentLifecycle::AllowThrottlingScope throttling_scope( GetDocument().Lifecycle()); CompositeFrame(); // Throttle the frame. - CompositeFrame(); // Update touch handler regions. // In here, throttle iframe doesn't throttle the main frame. EXPECT_TRUE( @@ -825,7 +824,6 @@ // there is only one rectangle in total. frame_element->setAttribute(kStyleAttr, "transform: translateY(0px)"); CompositeFrame(); // Unthrottle the frame. - CompositeFrame(); // Update touch handler regions. EXPECT_EQ(1u, TouchHandlerRegionSize()); } @@ -858,7 +856,6 @@ DocumentLifecycle::AllowThrottlingScope throttling_scope( GetDocument().Lifecycle()); CompositeFrame(); // Throttle the frame. - CompositeFrame(); // Update touch handler regions. // In here, throttle iframe doesn't throttle the main frame. EXPECT_TRUE( @@ -877,7 +874,6 @@ // Unthrottling the frame makes the touch handler active again. frame_element->setAttribute(kStyleAttr, "transform: translateY(0px)"); CompositeFrame(); // Unthrottle the frame. - CompositeFrame(); // Update touch handler regions. EXPECT_EQ(1u, TouchHandlerRegionSize()); }
diff --git a/third_party/blink/renderer/devtools/front_end/emulation/DevicesSettingsTab.js b/third_party/blink/renderer/devtools/front_end/emulation/DevicesSettingsTab.js index 0b63f7d..c25cf53 100644 --- a/third_party/blink/renderer/devtools/front_end/emulation/DevicesSettingsTab.js +++ b/third_party/blink/renderer/devtools/front_end/emulation/DevicesSettingsTab.js
@@ -13,7 +13,7 @@ this.registerRequiredCSS('emulation/devicesSettingsTab.css'); const header = this.element.createChild('header'); - header.createChild('h3').createTextChild(Common.UIString('Emulated Devices')); + header.createChild('h1').createTextChild(ls`Emulated Devices`); this.containerElement = this.element.createChild('div', 'settings-container-wrapper') .createChild('div', 'settings-tab settings-content settings-container');
diff --git a/third_party/blink/renderer/devtools/front_end/network/ResourceWebSocketFrameView.js b/third_party/blink/renderer/devtools/front_end/network/ResourceWebSocketFrameView.js index 89ba17c..49ce176f 100644 --- a/third_party/blink/renderer/devtools/front_end/network/ResourceWebSocketFrameView.js +++ b/third_party/blink/renderer/devtools/front_end/network/ResourceWebSocketFrameView.js
@@ -46,7 +46,7 @@ this._dataGrid = new DataGrid.SortableDataGrid(columns); this._dataGrid.setRowContextMenuCallback(onRowContextMenu.bind(this)); this._dataGrid.setStickToBottom(true); - this._dataGrid.setCellClass('websocket-frame-view-td'); + this._dataGrid.setStriped(true); this._timeComparator = /** @type {function(!Network.ResourceWebSocketFrameNode, !Network.ResourceWebSocketFrameNode):number} */ ( Network.ResourceWebSocketFrameNodeTimeComparator); @@ -268,7 +268,11 @@ let description = Network.ResourceWebSocketFrameView.opCodeDescription(frame.opCode, frame.mask); const isTextFrame = frame.opCode === Network.ResourceWebSocketFrameView.OpCodes.TextFrame; - if (isTextFrame) { + if (frame.type === SDK.NetworkRequest.WebSocketFrameType.Error) { + description = dataText; + length = ls`N/A`; + + } else if (isTextFrame) { description = dataText; } else if (frame.opCode === Network.ResourceWebSocketFrameView.OpCodes.BinaryFrame) { @@ -298,7 +302,6 @@ 'websocket-frame-view-row-send', this._frame.type === SDK.NetworkRequest.WebSocketFrameType.Send); element.classList.toggle( 'websocket-frame-view-row-receive', this._frame.type === SDK.NetworkRequest.WebSocketFrameType.Receive); - element.classList.toggle('websocket-frame-view-row-opcode', !this._isTextFrame); super.createCells(element); } @@ -328,7 +331,7 @@ * @return {?Network.BinaryResourceView} */ binaryView() { - if (this._isTextFrame) + if (this._isTextFrame || this._frame.type === SDK.NetworkRequest.WebSocketFrameType.Error) return null; if (!this._binaryView)
diff --git a/third_party/blink/renderer/devtools/front_end/network/webSocketFrameView.css b/third_party/blink/renderer/devtools/front_end/network/webSocketFrameView.css index 9e95e84..ec662ef6 100644 --- a/third_party/blink/renderer/devtools/front_end/network/webSocketFrameView.css +++ b/third_party/blink/renderer/devtools/front_end/network/webSocketFrameView.css
@@ -17,10 +17,6 @@ background-image: none; } -.websocket-frame-view-td { - border-bottom: 1px solid #ccc; -} - .websocket-frame-view .data-grid tr.selected { background-color: #def; } @@ -31,13 +27,15 @@ } .websocket-frame-view-row-send td:first-child::before { - content: "\2B06 "; + content: "\2B06"; color: #080; + padding-right: 4px; } .websocket-frame-view-row-receive td:first-child::before { - content: "\2B07 "; + content: "\2B07"; color: #E65100; + padding-right: 4px; } .data-grid:focus .websocket-frame-view-row-send.selected td:first-child::before, @@ -45,17 +43,7 @@ color: white; } -.websocket-frame-view-row-send { - background-color: rgb(226, 247, 218); -} - -.websocket-frame-view-row-opcode { - background-color: rgb(255, 255, 232); - color: rgb(170, 111, 71); -} - .websocket-frame-view-row-error { - background-color: rgb(255, 237, 237); color: rgb(182, 0, 0); }
diff --git a/third_party/blink/renderer/devtools/front_end/settings/SettingsScreen.js b/third_party/blink/renderer/devtools/front_end/settings/SettingsScreen.js index 2f8d2c9..f07567f 100644 --- a/third_party/blink/renderer/devtools/front_end/settings/SettingsScreen.js +++ b/third_party/blink/renderer/devtools/front_end/settings/SettingsScreen.js
@@ -117,7 +117,7 @@ if (id) this.element.id = id; const header = this.element.createChild('header'); - header.createChild('h3').createTextChild(name); + header.createChild('h1').createTextChild(name); this.containerElement = this.element.createChild('div', 'settings-container-wrapper') .createChild('div', 'settings-tab settings-content settings-container'); } @@ -128,8 +128,15 @@ */ _appendSection(name) { const block = this.containerElement.createChild('div', 'settings-block'); - if (name) - block.createChild('div', 'settings-section-title').textContent = name; + if (name) { + UI.ARIAUtils.markAsGroup(block); + const title = block.createChild('div', 'settings-section-title'); + title.textContent = name; + UI.ARIAUtils.markAsHeading(title, 2); + const sectionTitleId = UI.ARIAUtils.nextId('settings-section-title'); + title.setAttribute('id', sectionTitleId); + block.setAttribute('aria-labelledby', sectionTitleId); + } return block; } };
diff --git a/third_party/blink/renderer/devtools/front_end/settings/settingsScreen.css b/third_party/blink/renderer/devtools/front_end/settings/settingsScreen.css index 9989041..32ba7c64 100644 --- a/third_party/blink/renderer/devtools/front_end/settings/settingsScreen.css +++ b/third_party/blink/renderer/devtools/front_end/settings/settingsScreen.css
@@ -183,7 +183,7 @@ margin-left: 0; } -.settings-tab-container header > h3 { +.settings-tab-container header > h1 { font-size: 18px; font-weight: normal; margin: 0;
diff --git a/third_party/blink/renderer/devtools/front_end/ui/SettingsUI.js b/third_party/blink/renderer/devtools/front_end/ui/SettingsUI.js index 8a78ab7..7e09206 100644 --- a/third_party/blink/renderer/devtools/front_end/ui/SettingsUI.js +++ b/third_party/blink/renderer/devtools/front_end/ui/SettingsUI.js
@@ -61,8 +61,12 @@ */ UI.SettingsUI.createSettingSelect = function(name, options, setting) { const p = createElement('p'); - p.createChild('label').textContent = name; + const label = p.createChild('label'); + label.textContent = name; const select = p.createChild('select', 'chrome-select'); + const selectId = UI.ARIAUtils.nextId('chrome-select'); + select.setAttribute('id', selectId); + label.setAttribute('for', selectId); for (let i = 0; i < options.length; ++i) { // The "raw" flag indicates text is non-i18n-izable. @@ -117,7 +121,11 @@ UI.SettingsUI.createCustomSetting = function(name, element) { const p = createElement('p'); const fieldsetElement = p.createChild('fieldset'); - fieldsetElement.createChild('label').textContent = name; + const label = fieldsetElement.createChild('label'); + label.textContent = name; + const elementId = UI.ARIAUtils.nextId('setting-element'); + element.setAttribute('id', elementId); + label.setAttribute('for', elementId); fieldsetElement.appendChild(element); return p; };
diff --git a/third_party/blink/renderer/devtools/front_end/ui/ShortcutsScreen.js b/third_party/blink/renderer/devtools/front_end/ui/ShortcutsScreen.js index 9bcd4f0..fb675543 100644 --- a/third_party/blink/renderer/devtools/front_end/ui/ShortcutsScreen.js +++ b/third_party/blink/renderer/devtools/front_end/ui/ShortcutsScreen.js
@@ -225,7 +225,7 @@ const widget = new UI.Widget(); widget.element.className = 'settings-tab-container'; // Override - widget.element.createChild('header').createChild('h3').createTextChild(Common.UIString('Shortcuts')); + widget.element.createChild('header').createChild('h1').createTextChild(ls`Shortcuts`); const scrollPane = widget.element.createChild('div', 'settings-container-wrapper'); const container = scrollPane.createChild('div'); container.className = 'settings-content settings-container';
diff --git a/third_party/blink/renderer/modules/credentialmanager/credential_manager_type_converters.cc b/third_party/blink/renderer/modules/credentialmanager/credential_manager_type_converters.cc index 54e44c5..7195e8a 100644 --- a/third_party/blink/renderer/modules/credentialmanager/credential_manager_type_converters.cc +++ b/third_party/blink/renderer/modules/credentialmanager/credential_manager_type_converters.cc
@@ -26,8 +26,8 @@ namespace { // Time to wait for an authenticator to successfully complete an operation. -constexpr TimeDelta kAdjustedTimeoutLower = TimeDelta::FromSeconds(1); -constexpr TimeDelta kAdjustedTimeoutUpper = TimeDelta::FromMinutes(1); +constexpr TimeDelta kAdjustedTimeoutLower = TimeDelta::FromSeconds(10); +constexpr TimeDelta kAdjustedTimeoutUpper = TimeDelta::FromMinutes(10); WTF::TimeDelta AdjustTimeout(uint32_t timeout) { WTF::TimeDelta adjusted_timeout;
diff --git a/third_party/blink/renderer/modules/mediastream/media_stream_video_source.cc b/third_party/blink/renderer/modules/mediastream/media_stream_video_source.cc index 954153a0..520ac9f 100644 --- a/third_party/blink/renderer/modules/mediastream/media_stream_video_source.cc +++ b/third_party/blink/renderer/modules/mediastream/media_stream_video_source.cc
@@ -397,7 +397,7 @@ base::Optional<media::VideoCaptureFormat> current_format = GetCurrentFormat(); double frame_rate = current_format ? current_format->frame_rate : 0.0; if (current_format && enable_device_rotation_detection_) { - track_adapter_->SetSourceFrameSize(IntSize(current_format->frame_size)); + track_adapter_->SetSourceFrameSize(current_format->frame_size); } track_adapter_->StartFrameMonitoring( frame_rate, WTF::BindRepeating(&MediaStreamVideoSource::SetMutedState,
diff --git a/third_party/blink/renderer/modules/mediastream/video_track_adapter.cc b/third_party/blink/renderer/modules/mediastream/video_track_adapter.cc index 543acab..775f4282 100644 --- a/third_party/blink/renderer/modules/mediastream/video_track_adapter.cc +++ b/third_party/blink/renderer/modules/mediastream/video_track_adapter.cc
@@ -117,8 +117,8 @@ } // anonymous namespace -// Template specialization of [1], needed to be able to pass WTF callbacks -// that have VideoTrackAdapterSettings parameters across threads. +// Template specializations of [1], needed to be able to pass WTF callbacks +// that have VideoTrackAdapterSettings or gfx::Size parameters across threads. // // [1] third_party/blink/renderer/platform/cross_thread_copier.h. template <> @@ -127,6 +127,12 @@ STATIC_ONLY(CrossThreadCopier); }; +template <> +struct CrossThreadCopier<gfx::Size> + : public CrossThreadCopierPassThrough<gfx::Size> { + STATIC_ONLY(CrossThreadCopier); +}; + // VideoFrameResolutionAdapter is created on and lives on the IO-thread. It does // the resolution adaptation and delivers frames to all registered tracks on the // IO-thread. All method calls must be on the IO-thread. @@ -588,7 +594,7 @@ WrapRefCounted(this))); } -void VideoTrackAdapter::SetSourceFrameSize(const IntSize& source_frame_size) { +void VideoTrackAdapter::SetSourceFrameSize(const gfx::Size& source_frame_size) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); PostCrossThreadTask( *io_task_runner_, FROM_HERE, @@ -686,7 +692,7 @@ } void VideoTrackAdapter::SetSourceFrameSizeOnIO( - const IntSize& source_frame_size) { + const gfx::Size& source_frame_size) { DCHECK(io_task_runner_->BelongsToCurrentThread()); source_frame_size_ = source_frame_size; } @@ -739,8 +745,8 @@ // TODO(guidou): Use actual device information instead of this heuristic to // detect frames from rotated devices. https://crbug.com/722748 if (source_frame_size_ && - frame->natural_size().width() == source_frame_size_->Height() && - frame->natural_size().height() == source_frame_size_->Width()) { + frame->natural_size().width() == source_frame_size_->height() && + frame->natural_size().height() == source_frame_size_->width()) { is_device_rotated = true; } if (adapters_.IsEmpty()) {
diff --git a/third_party/blink/renderer/modules/mediastream/video_track_adapter.h b/third_party/blink/renderer/modules/mediastream/video_track_adapter.h index 4c61150..051b5a8 100644 --- a/third_party/blink/renderer/modules/mediastream/video_track_adapter.h +++ b/third_party/blink/renderer/modules/mediastream/video_track_adapter.h
@@ -18,7 +18,6 @@ #include "third_party/blink/public/platform/web_common.h" #include "third_party/blink/public/web/modules/mediastream/media_stream_video_track.h" #include "third_party/blink/renderer/platform/cross_thread_functional.h" -#include "third_party/blink/renderer/platform/geometry/int_size.h" #include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h" #include "third_party/blink/renderer/platform/wtf/vector.h" @@ -76,7 +75,7 @@ const OnMutedCallback& on_muted_callback); void StopFrameMonitoring(); - void SetSourceFrameSize(const IntSize& source_frame_size); + void SetSourceFrameSize(const gfx::Size& source_frame_size); // Exported for testing. // @@ -118,7 +117,7 @@ void StartFrameMonitoringOnIO(OnMutedInternalCallback on_muted_state_callback, double source_frame_rate); void StopFrameMonitoringOnIO(); - void SetSourceFrameSizeOnIO(const IntSize& frame_size); + void SetSourceFrameSizeOnIO(const gfx::Size& frame_size); // Compare |frame_counter_snapshot| with the current |frame_counter_|, and // inform of the situation (muted, not muted) via |set_muted_state_callback|. @@ -158,7 +157,7 @@ float source_frame_rate_; // Resolution configured on the video source, accessed on the IO-thread. - base::Optional<IntSize> source_frame_size_; + base::Optional<gfx::Size> source_frame_size_; DISALLOW_COPY_AND_ASSIGN(VideoTrackAdapter); };
diff --git a/third_party/blink/renderer/modules/modules_idl_files.gni b/third_party/blink/renderer/modules/modules_idl_files.gni index 3aa40b5..299aa55d 100644 --- a/third_party/blink/renderer/modules/modules_idl_files.gni +++ b/third_party/blink/renderer/modules/modules_idl_files.gni
@@ -496,6 +496,7 @@ "xr/xr_frame.idl", "xr/xr_hit_result.idl", "xr/xr_input_source.idl", + "xr/xr_input_source_array.idl", "xr/xr_input_source_event.idl", "xr/xr_input_sources_change_event.idl", "xr/xr_layer.idl",
diff --git a/third_party/blink/renderer/modules/screen_orientation/lock_orientation_callback.cc b/third_party/blink/renderer/modules/screen_orientation/lock_orientation_callback.cc index 3afebe88..d80d64e 100644 --- a/third_party/blink/renderer/modules/screen_orientation/lock_orientation_callback.cc +++ b/third_party/blink/renderer/modules/screen_orientation/lock_orientation_callback.cc
@@ -4,9 +4,11 @@ #include "third_party/blink/renderer/modules/screen_orientation/lock_orientation_callback.h" +#include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" #include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/modules/screen_orientation/screen_orientation.h" +#include "third_party/blink/renderer/platform/wtf/functional.h" namespace blink { @@ -17,7 +19,16 @@ LockOrientationCallback::~LockOrientationCallback() = default; void LockOrientationCallback::OnSuccess() { - resolver_->Resolve(); + // Resolving the promise should be done after the event is fired which is + // delayed to avoid running script on the stack. We then have to delay + // resolving the promise. + resolver_->GetExecutionContext() + ->GetTaskRunner(TaskType::kMiscPlatformAPI) + ->PostTask(FROM_HERE, WTF::Bind( + [](ScriptPromiseResolver* resolver) { + resolver->Resolve(); + }, + std::move(resolver_))); } void LockOrientationCallback::OnError(WebLockOrientationError error) {
diff --git a/third_party/blink/renderer/modules/screen_orientation/screen_orientation_controller_impl.cc b/third_party/blink/renderer/modules/screen_orientation/screen_orientation_controller_impl.cc index 72c98e9..5ffd5ba3 100644 --- a/third_party/blink/renderer/modules/screen_orientation/screen_orientation_controller_impl.cc +++ b/third_party/blink/renderer/modules/screen_orientation/screen_orientation_controller_impl.cc
@@ -153,9 +153,17 @@ // Notify current orientation object. if (IsActive() && orientation_) { - ScopedAllowFullscreen allow_fullscreen( - ScopedAllowFullscreen::kOrientationChange); - orientation_->DispatchEvent(*Event::Create(event_type_names::kChange)); + GetExecutionContext() + ->GetTaskRunner(TaskType::kMiscPlatformAPI) + ->PostTask(FROM_HERE, + WTF::Bind( + [](ScreenOrientation* orientation) { + ScopedAllowFullscreen allow_fullscreen( + ScopedAllowFullscreen::kOrientationChange); + orientation->DispatchEvent( + *Event::Create(event_type_names::kChange)); + }, + WrapPersistent(orientation_.Get()))); } // ... and child frames, if they have a ScreenOrientationControllerImpl.
diff --git a/third_party/blink/renderer/modules/xr/BUILD.gn b/third_party/blink/renderer/modules/xr/BUILD.gn index b3f5fe5..bbe4478 100644 --- a/third_party/blink/renderer/modules/xr/BUILD.gn +++ b/third_party/blink/renderer/modules/xr/BUILD.gn
@@ -28,6 +28,8 @@ "xr_hit_result.h", "xr_input_source.cc", "xr_input_source.h", + "xr_input_source_array.cc", + "xr_input_source_array.h", "xr_input_source_event.cc", "xr_input_source_event.h", "xr_input_sources_change_event.cc",
diff --git a/third_party/blink/renderer/modules/xr/xr_input_source_array.cc b/third_party/blink/renderer/modules/xr/xr_input_source_array.cc new file mode 100644 index 0000000..68db4785 --- /dev/null +++ b/third_party/blink/renderer/modules/xr/xr_input_source_array.cc
@@ -0,0 +1,26 @@ +// Copyright 2018 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 "third_party/blink/renderer/modules/xr/xr_input_source_array.h" +#include "third_party/blink/renderer/platform/heap/heap_allocator.h" + +namespace blink { + +XRInputSource* XRInputSourceArray::AnonymousIndexedGetter( + unsigned index) const { + if (index >= input_sources_.size()) + return nullptr; + + return input_sources_[index]; +} + +void XRInputSourceArray::Add(XRInputSource* input_source) { + input_sources_.push_back(input_source); +} + +void XRInputSourceArray::Trace(blink::Visitor* visitor) { + visitor->Trace(input_sources_); + ScriptWrappable::Trace(visitor); +} +} // namespace blink
diff --git a/third_party/blink/renderer/modules/xr/xr_input_source_array.h b/third_party/blink/renderer/modules/xr/xr_input_source_array.h new file mode 100644 index 0000000..96f46f8 --- /dev/null +++ b/third_party/blink/renderer/modules/xr/xr_input_source_array.h
@@ -0,0 +1,30 @@ +// Copyright 2018 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 THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_INPUT_SOURCE_ARRAY_H_ +#define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_INPUT_SOURCE_ARRAY_H_ + +#include "third_party/blink/renderer/modules/xr/xr_input_source.h" +#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" + +namespace blink { + +class XRInputSourceArray : public ScriptWrappable { + DEFINE_WRAPPERTYPEINFO(); + + public: + unsigned length() const { return input_sources_.size(); } + XRInputSource* AnonymousIndexedGetter(unsigned index) const; + + void Add(XRInputSource* input_source); + + void Trace(blink::Visitor*) override; + + private: + HeapVector<Member<XRInputSource>> input_sources_; +}; + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_INPUT_SOURCE_ARRAY_H_
diff --git a/third_party/blink/renderer/modules/xr/xr_input_source_array.idl b/third_party/blink/renderer/modules/xr/xr_input_source_array.idl new file mode 100644 index 0000000..6d8dd26 --- /dev/null +++ b/third_party/blink/renderer/modules/xr/xr_input_source_array.idl
@@ -0,0 +1,13 @@ +// Copyright 2019 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. + +[ + SecureContext, + Exposed=Window, + RuntimeEnabled=WebXR +] interface XRInputSourceArray { + iterable<XRInputSource>; + readonly attribute unsigned long length; + getter XRInputSource(unsigned long index); +};
diff --git a/third_party/blink/renderer/modules/xr/xr_session.cc b/third_party/blink/renderer/modules/xr/xr_session.cc index b2573ad..f7ee117 100644 --- a/third_party/blink/renderer/modules/xr/xr_session.cc +++ b/third_party/blink/renderer/modules/xr/xr_session.cc
@@ -348,7 +348,7 @@ callback_collection_->CancelCallback(id); } -HeapVector<Member<XRInputSource>> XRSession::getInputSources() const { +XRInputSourceArray* XRSession::inputSources() const { Document* doc = To<Document>(GetExecutionContext()); if (!did_log_getInputSources_ && doc) { ukm::builders::XR_WebXR(xr_->GetSourceId()) @@ -357,15 +357,15 @@ did_log_getInputSources_ = true; } - HeapVector<Member<XRInputSource>> source_array; + XRInputSourceArray* source_array = MakeGarbageCollected<XRInputSourceArray>(); for (const auto& input_source : input_sources_.Values()) { - source_array.push_back(input_source); + source_array->Add(input_source); } if (canvas_input_provider_) { XRInputSource* input_source = canvas_input_provider_->GetInputSource(); if (input_source) { - source_array.push_back(input_source); + source_array->Add(input_source); } }
diff --git a/third_party/blink/renderer/modules/xr/xr_session.h b/third_party/blink/renderer/modules/xr/xr_session.h index 129a63a7..752795f 100644 --- a/third_party/blink/renderer/modules/xr/xr_session.h +++ b/third_party/blink/renderer/modules/xr/xr_session.h
@@ -13,6 +13,7 @@ #include "third_party/blink/renderer/core/typed_arrays/dom_typed_array.h" #include "third_party/blink/renderer/modules/xr/xr_frame_request_callback_collection.h" #include "third_party/blink/renderer/modules/xr/xr_input_source.h" +#include "third_party/blink/renderer/modules/xr/xr_input_source_array.h" #include "third_party/blink/renderer/platform/geometry/double_size.h" #include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/transforms/transformation_matrix.h" @@ -93,7 +94,7 @@ using InputSourceMap = HeapHashMap<uint32_t, Member<XRInputSource>>; - HeapVector<Member<XRInputSource>> getInputSources() const; + XRInputSourceArray* inputSources() const; ScriptPromise requestHitTest(ScriptState* script_state, XRRay* ray,
diff --git a/third_party/blink/renderer/modules/xr/xr_session.idl b/third_party/blink/renderer/modules/xr/xr_session.idl index 1037298..c6c4d8ae 100644 --- a/third_party/blink/renderer/modules/xr/xr_session.idl +++ b/third_party/blink/renderer/modules/xr/xr_session.idl
@@ -25,6 +25,7 @@ readonly attribute XREnvironmentBlendMode environmentBlendMode; [SameObject] readonly attribute XRRenderState renderState; [SameObject] readonly attribute XRSpace viewerSpace; + [MeasureAs=XRSessionGetInputSources] readonly attribute XRInputSourceArray inputSources; attribute EventHandler onblur; attribute EventHandler onfocus; @@ -41,7 +42,6 @@ long requestAnimationFrame(XRFrameRequestCallback callback); void cancelAnimationFrame(long handle); - [MeasureAs=XRSessionGetInputSources] FrozenArray<XRInputSource> getInputSources(); [RuntimeEnabled=WebXRHitTest, CallWith=ScriptState] Promise<FrozenArray<XRHitResult>> requestHitTest(XRRay ray, XRSpace space);
diff --git a/third_party/blink/renderer/platform/graphics/dark_mode_filter.cc b/third_party/blink/renderer/platform/graphics/dark_mode_filter.cc index afeb90c..be091cb 100644 --- a/third_party/blink/renderer/platform/graphics/dark_mode_filter.cc +++ b/third_party/blink/renderer/platform/graphics/dark_mode_filter.cc
@@ -139,4 +139,17 @@ static_cast<unsigned int>(rgb.Z() * 255 + 0.5), color.Alpha()); } +bool DarkModeFilter::ShouldInvertTextColor(const Color& color) const { + if (settings_.text_policy == DarkModeTextPolicy::kInvertAll) + return true; + + // Throw an error in debug mode if new values are added to the enum without + // updating this method. + DCHECK_EQ(settings_.text_policy, DarkModeTextPolicy::kInvertDarkOnly); + if (color == Color::kWhite) { + return false; + } + return true; +} + } // namespace blink
diff --git a/third_party/blink/renderer/platform/graphics/dark_mode_filter.h b/third_party/blink/renderer/platform/graphics/dark_mode_filter.h index da1114d..18bcdfa 100644 --- a/third_party/blink/renderer/platform/graphics/dark_mode_filter.h +++ b/third_party/blink/renderer/platform/graphics/dark_mode_filter.h
@@ -33,6 +33,8 @@ Color InvertColor(const Color& color) const; + bool ShouldInvertTextColor(const Color& color) const; + private: DarkModeSettings settings_;
diff --git a/third_party/blink/renderer/platform/graphics/dark_mode_settings.h b/third_party/blink/renderer/platform/graphics/dark_mode_settings.h index 91fa0c1..5ffb283 100644 --- a/third_party/blink/renderer/platform/graphics/dark_mode_settings.h +++ b/third_party/blink/renderer/platform/graphics/dark_mode_settings.h
@@ -33,12 +33,23 @@ kFilterByBackground, }; +// If adding new values to this enum, also update the logic in +// DarkModeFilter::ShouldInvertTextColor(). +enum class DarkModeTextPolicy { + kInvertAll, + kInvertDarkOnly, +}; + +// New variables added to this struct should also be added to +// BuildDarkModeSettings() in +// //src/third_party/blink/renderer/core/accessibility/apply_dark_mode.h struct DarkModeSettings { DarkMode mode = DarkMode::kOff; bool grayscale = false; float image_grayscale_percent = 0.0; // Valid range from 0.0 to 1.0 float contrast = 0.0; // Valid range from -1.0 to 1.0 DarkModeImagePolicy image_policy = DarkModeImagePolicy::kFilterAll; + DarkModeTextPolicy text_policy = DarkModeTextPolicy::kInvertAll; }; } // namespace blink
diff --git a/third_party/blink/renderer/platform/graphics/graphics_context.cc b/third_party/blink/renderer/platform/graphics/graphics_context.cc index fdd1c06..6c28903 100644 --- a/third_party/blink/renderer/platform/graphics/graphics_context.cc +++ b/third_party/blink/renderer/platform/graphics/graphics_context.cc
@@ -59,11 +59,10 @@ namespace blink { -// Effectively allows modifying the provided |flags| without technically -// violating its constness. +// Helper class that copies |flags| only when dark mode is enabled. // // TODO(gilmanmh): Investigate removing const from |flags| in the calling -// methods so that this isn't necessary. +// methods and modifying the variable directly instead of copying it. class GraphicsContext::DarkModeFlags final { STACK_ALLOCATED(); @@ -79,6 +78,7 @@ } operator const PaintFlags&() const { return *flags_; } + private: const PaintFlags* flags_; base::Optional<PaintFlags> dark_mode_flags_; @@ -811,11 +811,15 @@ if (ContextDisabled()) return; - DrawTextPasses( - [&font, &text_info, &point, this, node_holder](const PaintFlags& flags) { - font.DrawText(canvas_, text_info, point, device_scale_factor_, - node_holder, DarkModeFlags(this, flags)); - }); + DrawTextPasses([&](const PaintFlags& flags) { + if (dark_mode_filter_.ShouldInvertTextColor(flags.getColor())) { + font.DrawText(canvas_, text_info, point, device_scale_factor_, + node_holder, DarkModeFlags(this, flags)); + } else { + font.DrawText(canvas_, text_info, point, device_scale_factor_, + node_holder, flags); + } + }); } void GraphicsContext::DrawText(const Font& font,
diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5 index 5637280..ecdf61a 100644 --- a/third_party/blink/renderer/platform/runtime_enabled_features.json5 +++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5
@@ -310,7 +310,7 @@ }, { name: "CSSBackdropFilter", - status: "experimental", + status: "stable", }, { name: "CSSCalcAsInt",
diff --git a/third_party/blink/web_tests/NeverFixTests b/third_party/blink/web_tests/NeverFixTests index c0d6ebc..b85c407 100644 --- a/third_party/blink/web_tests/NeverFixTests +++ b/third_party/blink/web_tests/NeverFixTests
@@ -286,6 +286,12 @@ crbug.com/753080 external/wpt/css/css-transforms/ttwf-css-3d-polygon-cycle-mismatch.html [ WontFix ] crbug.com/753080 external/wpt/css/css-transforms/ttwf-css-3d-polygon-cycle.html [ WontFix ] +# We could fix this test for us and upstream it if the test shell user agent +# would let us differentiate test_shell and WebKit DumpTreeNode. +crbug.com/7482 [ Linux ] http/tests/misc/timer-vs-loading.html [ WontFix ] +crbug.com/7482 [ Win ] http/tests/misc/timer-vs-loading.html [ WontFix ] +crbug.com/7482 [ Mac ] http/tests/misc/timer-vs-loading.html [ WontFix ] + # On Linux bold emoji are already supported. crbug.com/551843 [ Linux ] fast/text/fallback-traits-fixup.html [ WontFix ] crbug.com/551843 [ Linux ] fast/text/emoji-font-weight-mac.html [ WontFix ]
diff --git a/third_party/blink/web_tests/StaleTestExpectations b/third_party/blink/web_tests/StaleTestExpectations index f934e0b..3c06553f 100644 --- a/third_party/blink/web_tests/StaleTestExpectations +++ b/third_party/blink/web_tests/StaleTestExpectations
@@ -6,3 +6,8 @@ # # Further documentation: # https://chromium.googlesource.com/chromium/src/+/master/docs/testing/web_test_expectations.md + +# We could fix this test for us and upstream it if the test shell user agent +# would let us differentiate test_shell and WebKit DumpTreeNode. +crbug.com/7482 [ Win Mac ] http/tests/misc/timer-vs-loading.html [ WontFix ] +
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index 9b89c5c..25c85c7 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -5621,3 +5621,6 @@ crbug.com/963764 [ Mac ] media/video-aspect-ratio.html [ Pass Failure ] crbug.com/963141 [ Linux ] media/video-object-fit.html [ Pass Failure ] crbug.com/963740 [ Win ] compositing/video-frame-size-change.html [ Pass Failure ] + +# Sheriff 2019-05-17 +crbug.com/964239 virtual/threaded/external/wpt/css/css-scroll-snap/scroll-margin.html [ Pass Failure ]
diff --git a/third_party/blink/web_tests/external/wpt/css/css-text/overflow-wrap/overflow-wrap-break-word-long-crash.html b/third_party/blink/web_tests/external/wpt/css/css-text/overflow-wrap/overflow-wrap-break-word-long-crash.html new file mode 100644 index 0000000..e318386 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-text/overflow-wrap/overflow-wrap-break-word-long-crash.html
@@ -0,0 +1,28 @@ +<!DOCTYPE html> +<title>CSS Text Test: very long line with `overflow-wrap: break-word` should not crash</title> +<link rel="help" href="https://crbug.com/961987"> +<link rel="author" title="Koji Ishii" href="kojii@chromium.org"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> +html, body { + margin: 0; +} +body { + overflow-wrap: break-word; + width: 2147483648px; +} +div { + /* Double the width in case CSS parser clamps the body width. */ + width: 200%; +} +span { + border-left: 2147483648px solid; +} +</style> +<body> + <div><span>x</span></div> +<script> +test(() => { document.body.offsetTop; }); +</script> +</body>
diff --git a/third_party/blink/web_tests/external/wpt/webxr/idlharness.https.window-expected.txt b/third_party/blink/web_tests/external/wpt/webxr/idlharness.https.window-expected.txt index 296a453..92da502 100644 --- a/third_party/blink/web_tests/external/wpt/webxr/idlharness.https.window-expected.txt +++ b/third_party/blink/web_tests/external/wpt/webxr/idlharness.https.window-expected.txt
@@ -1,5 +1,5 @@ This is a testharness.js-based test. -Found 217 tests; 207 PASS, 10 FAIL, 0 TIMEOUT, 0 NOTRUN. +Found 217 tests; 216 PASS, 1 FAIL, 0 TIMEOUT, 0 NOTRUN. PASS idl_test setup PASS Partial interface Navigator: original interface defined PASS Partial dictionary WebGLContextAttributes: original dictionary defined @@ -28,7 +28,7 @@ PASS XRSession interface: existence and properties of interface prototype object's @@unscopables property PASS XRSession interface: attribute environmentBlendMode PASS XRSession interface: attribute renderState -FAIL XRSession interface: attribute inputSources assert_true: The prototype object must have a property "inputSources" expected true got false +PASS XRSession interface: attribute inputSources PASS XRSession interface: operation updateRenderState(XRRenderStateInit) PASS XRSession interface: operation requestReferenceSpace(XRReferenceSpaceType) PASS XRSession interface: operation requestAnimationFrame(XRFrameRequestCallback) @@ -146,14 +146,14 @@ PASS XRInputSource interface: attribute targetRaySpace PASS XRInputSource interface: attribute gripSpace PASS XRInputSource interface: attribute gamepad -FAIL XRInputSourceArray interface: existence and properties of interface object assert_own_property: self does not have own property "XRInputSourceArray" expected property "XRInputSourceArray" missing -FAIL XRInputSourceArray interface object length assert_own_property: self does not have own property "XRInputSourceArray" expected property "XRInputSourceArray" missing -FAIL XRInputSourceArray interface object name assert_own_property: self does not have own property "XRInputSourceArray" expected property "XRInputSourceArray" missing -FAIL XRInputSourceArray interface: existence and properties of interface prototype object assert_own_property: self does not have own property "XRInputSourceArray" expected property "XRInputSourceArray" missing -FAIL XRInputSourceArray interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "XRInputSourceArray" expected property "XRInputSourceArray" missing -FAIL XRInputSourceArray interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "XRInputSourceArray" expected property "XRInputSourceArray" missing -FAIL XRInputSourceArray interface: iterable<XRInputSource> Cannot read property 'prototype' of undefined -FAIL XRInputSourceArray interface: attribute length assert_own_property: self does not have own property "XRInputSourceArray" expected property "XRInputSourceArray" missing +PASS XRInputSourceArray interface: existence and properties of interface object +PASS XRInputSourceArray interface object length +PASS XRInputSourceArray interface object name +PASS XRInputSourceArray interface: existence and properties of interface prototype object +PASS XRInputSourceArray interface: existence and properties of interface prototype object's "constructor" property +PASS XRInputSourceArray interface: existence and properties of interface prototype object's @@unscopables property +PASS XRInputSourceArray interface: iterable<XRInputSource> +PASS XRInputSourceArray interface: attribute length PASS XRLayer interface: existence and properties of interface object PASS XRLayer interface object length PASS XRLayer interface object name
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/http/tests/devtools/tracing/timeline-paint/timeline-paint-with-layout-invalidations-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/http/tests/devtools/tracing/timeline-paint/timeline-paint-with-layout-invalidations-expected.txt index 5fbcb30..68d64a25 100644 --- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/http/tests/devtools/tracing/timeline-paint/timeline-paint-with-layout-invalidations-expected.txt +++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/http/tests/devtools/tracing/timeline-paint/timeline-paint-with-layout-invalidations-expected.txt
@@ -14,6 +14,28 @@ selectorPart : undefined type : "StyleRecalcInvalidationTracking" } + { + cause : {reason: Inline CSS style declaration was mutated, stackTrace: test://evaluations/0/timeline-paint-with-layout-invalidations.js:18} + changedAttribute : undefined + changedClass : undefined + changedId : undefined + changedPseudo : undefined + extraData : "" + nodeName : "DIV id='testElement'" + selectorPart : undefined + type : "StyleRecalcInvalidationTracking" + } + { + cause : {reason: Style changed, stackTrace: test://evaluations/0/timeline-paint-with-layout-invalidations.js:19} + changedAttribute : undefined + changedClass : undefined + changedId : undefined + changedPseudo : undefined + extraData : undefined + nodeName : "DIV id='testElement'" + selectorPart : undefined + type : "LayoutInvalidationTracking" + } ] Running: testSubframe
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/push-block-with-first-line-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/push-block-with-first-line-expected.txt index c4ac18b8..8fba6b6 100644 --- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/push-block-with-first-line-expected.txt +++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/paint/invalidation/push-block-with-first-line-expected.txt
@@ -18,8 +18,13 @@ "backgroundColor": "#FFFFFF", "paintInvalidations": [ { - "object": "NGPhysicalBoxFragment LayoutInline (anonymous)", - "rect": [8, 68, 140, 20], + "object": "NGPhysicalLineBoxFragment", + "rect": [8, 68, 784, 20], + "reason": "geometry" + }, + { + "object": "NGPhysicalLineBoxFragment", + "rect": [8, 8, 784, 20], "reason": "geometry" }, { @@ -28,11 +33,6 @@ "reason": "geometry" }, { - "object": "NGPhysicalBoxFragment LayoutInline (anonymous)", - "rect": [8, 8, 140, 20], - "reason": "geometry" - }, - { "object": "NGPhysicalTextFragment 'JOCULAR'", "rect": [8, 8, 140, 20], "reason": "geometry"
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/basic-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/basic-a11y-test-expected.txt index 5a83a893..6d5fb9c1 100644 --- a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/basic-a11y-test-expected.txt +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/basic-a11y-test-expected.txt
@@ -7,4 +7,7 @@ Tests accessibility in the sensors view using the axe-core linter. aXe violations: [] +Tests accessibility in the preferences view using the axe-core linter. +aXe violations: [] +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/basic-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/basic-a11y-test.js index c9f853b..18d4dbd7 100644 --- a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/basic-a11y-test.js +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/basic-a11y-test.js
@@ -12,6 +12,8 @@ 'performance.monitor', // Sensors 'sensors', + // Settings + 'preferences', ];
diff --git a/third_party/blink/web_tests/http/tests/misc/resources/hang-connection-before-head.php b/third_party/blink/web_tests/http/tests/misc/resources/hang-connection-before-head.php deleted file mode 100644 index 82a693d..0000000 --- a/third_party/blink/web_tests/http/tests/misc/resources/hang-connection-before-head.php +++ /dev/null
@@ -1,5 +0,0 @@ -<?php -while (true) { - usleep(100000); -} -?>
diff --git a/third_party/blink/web_tests/http/tests/misc/timer-vs-loading.html b/third_party/blink/web_tests/http/tests/misc/timer-vs-loading.html index d5cad95..b12bd720 100644 --- a/third_party/blink/web_tests/http/tests/misc/timer-vs-loading.html +++ b/third_party/blink/web_tests/http/tests/misc/timer-vs-loading.html
@@ -28,7 +28,7 @@ <script> window.setTimeout("updateClock()", 100); - setTimeout('window.location = "resources/hang-connection-before-head.php"', 0); + setTimeout('window.location = "resources/hang-connection.php"', 0); </script> </body></html>
diff --git a/third_party/blink/web_tests/virtual/stable/webexposed/css-properties-as-js-properties-expected.txt b/third_party/blink/web_tests/virtual/stable/webexposed/css-properties-as-js-properties-expected.txt index 1fe2253..42df37b 100644 --- a/third_party/blink/web_tests/virtual/stable/webexposed/css-properties-as-js-properties-expected.txt +++ b/third_party/blink/web_tests/virtual/stable/webexposed/css-properties-as-js-properties-expected.txt
@@ -15,6 +15,7 @@ animationName animationPlayState animationTimingFunction +backdropFilter backfaceVisibility background backgroundAttachment
diff --git a/third_party/blink/web_tests/virtual/stable/webexposed/css-property-listing-expected.txt b/third_party/blink/web_tests/virtual/stable/webexposed/css-property-listing-expected.txt index 952c701..a72490f 100644 --- a/third_party/blink/web_tests/virtual/stable/webexposed/css-property-listing-expected.txt +++ b/third_party/blink/web_tests/virtual/stable/webexposed/css-property-listing-expected.txt
@@ -75,6 +75,7 @@ animation-name animation-play-state animation-timing-function + backdrop-filter backface-visibility background-attachment background-blend-mode
diff --git a/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt b/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt index 6dc19b2f..0862b48 100644 --- a/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt +++ b/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt
@@ -10599,6 +10599,15 @@ getter targetRayMode getter targetRaySpace method constructor +interface XRInputSourceArray + attribute @@toStringTag + getter length + method @@iterator + method constructor + method entries + method forEach + method keys + method values interface XRInputSourceEvent : Event attribute @@toStringTag getter buttonIndex @@ -10657,6 +10666,7 @@ interface XRSession : EventTarget attribute @@toStringTag getter environmentBlendMode + getter inputSources getter onblur getter onend getter onfocus @@ -10669,7 +10679,6 @@ method cancelAnimationFrame method constructor method end - method getInputSources method requestAnimationFrame method requestHitTest method requestReferenceSpace
diff --git a/third_party/blink/web_tests/xr/events_input_sources_change.html b/third_party/blink/web_tests/xr/events_input_sources_change.html index 520eb84..52eca34d 100644 --- a/third_party/blink/web_tests/xr/events_input_sources_change.html +++ b/third_party/blink/web_tests/xr/events_input_sources_change.html
@@ -46,7 +46,7 @@ if (inputChangeEvents === 1) { validateAdded(event.added, 1); validateRemoved(event.removed, 0); - cached_input_source = session.getInputSources()[0]; + cached_input_source = Array.from(session.inputSources.values())[0]; assert_not_equals(cached_input_source, null); } else if (inputChangeEvents === 2) { // The second event should be removing our controller. @@ -64,7 +64,7 @@ assert_equals(added.length, length, "Added length matches expectations"); - let currentSources = session.getInputSources(); + let currentSources = Array.from(session.inputSources.values()); added.forEach((source) => { assert_true(currentSources.includes(source), "Every element in added should be in the input source list"); @@ -78,7 +78,7 @@ assert_equals(removed.length, length, "Removed length matches expectations"); - let currentSources = session.getInputSources(); + let currentSources = Array.from(session.inputSources.values()); removed.forEach((source) => { assert_false(currentSources.includes(source), "No element in removed should be in the input source list");
diff --git a/third_party/blink/web_tests/xr/events_session_select.html b/third_party/blink/web_tests/xr/events_session_select.html index d1a8ca55..42238db 100644 --- a/third_party/blink/web_tests/xr/events_session_select.html +++ b/third_party/blink/web_tests/xr/events_session_select.html
@@ -50,7 +50,7 @@ function onSessionSelectStart(event) { t.step( () => { - let input_sources = session.getInputSources(); + let input_sources = session.inputSources; assert_equals(event.frame.session, session); assert_equals(event.inputSource, input_sources[0]); tryCallingFrameMethods(event.frame); @@ -59,7 +59,7 @@ function onSessionSelectEnd(event) { t.step( () => { - let input_sources = session.getInputSources(); + let input_sources = session.inputSources; assert_equals(event.frame.session, session); assert_equals(event.inputSource, input_sources[0]); tryCallingFrameMethods(event.frame); @@ -69,7 +69,7 @@ function onSessionSelect(event) { t.step( () => { - let input_sources = session.getInputSources(); + let input_sources = session.inputSources; assert_equals(event.frame.session, session); assert_equals(event.inputSource, input_sources[0]); tryCallingFrameMethods(event.frame);
diff --git a/third_party/blink/web_tests/xr/events_session_select_subframe.html b/third_party/blink/web_tests/xr/events_session_select_subframe.html index 358f58c7..621b716 100644 --- a/third_party/blink/web_tests/xr/events_session_select_subframe.html +++ b/third_party/blink/web_tests/xr/events_session_select_subframe.html
@@ -39,7 +39,7 @@ function onSessionSelectStart(event) { t.step( () => { - let input_sources = session.getInputSources(); + let input_sources = session.inputSources; assert_equals(event.frame.session, session); assert_equals(event.inputSource, input_sources[0]); }); @@ -47,7 +47,7 @@ function onSessionSelectEnd(event) { t.step( () => { - let input_sources = session.getInputSources(); + let input_sources = session.inputSources; assert_equals(event.frame.session, session); assert_equals(event.inputSource, input_sources[0]); }); @@ -55,7 +55,7 @@ function onSessionSelect(event) { t.step( () => { - let input_sources = session.getInputSources(); + let input_sources = session.inputSources; assert_equals(event.frame.session, session); assert_equals(event.inputSource, input_sources[0]); });
diff --git a/third_party/blink/web_tests/xr/getInputPose_hand.html b/third_party/blink/web_tests/xr/getInputPose_hand.html index f7841b2..8f5f310 100644 --- a/third_party/blink/web_tests/xr/getInputPose_hand.html +++ b/third_party/blink/web_tests/xr/getInputPose_hand.html
@@ -47,7 +47,7 @@ session.requestReferenceSpace({ type: "stationary", subtype: "eye-level" }).then( (referenceSpace) => { function CheckInvalidGrip(time, xrFrame) { - let source = session.getInputSources()[0]; + let source = session.inputSources[0]; let grip_pose = xrFrame.getPose(source.gripSpace, referenceSpace); t.step( () => { @@ -62,7 +62,7 @@ } function CheckValidGrip(time, xrFrame) { - let source = session.getInputSources()[0]; + let source = session.inputSources[0]; let grip_pose = xrFrame.getPose(source.gripSpace, referenceSpace); @@ -85,7 +85,7 @@ } function CheckValidGripAndPointer(time, xrFrame) { - let source = session.getInputSources()[0]; + let source = session.inputSources[0]; let grip_pose = xrFrame.getPose(source.gripSpace, referenceSpace); let input_pose = xrFrame.getPose(source.targetRaySpace, referenceSpace);
diff --git a/third_party/blink/web_tests/xr/getInputPose_handedness.html b/third_party/blink/web_tests/xr/getInputPose_handedness.html index 03a2536ca..a774537 100644 --- a/third_party/blink/web_tests/xr/getInputPose_handedness.html +++ b/third_party/blink/web_tests/xr/getInputPose_handedness.html
@@ -39,7 +39,7 @@ fakeDeviceController.addInputSource(input_source); function CheckNone(time, xrFrame) { - let source = session.getInputSources()[0]; + let source = session.inputSources[0]; t.step( () => { assert_not_equals(source, null); @@ -53,7 +53,7 @@ } function CheckRight(time, xrFrame) { - let source = session.getInputSources()[0]; + let source = session.inputSources[0]; t.step( () => { assert_not_equals(source, null); @@ -67,7 +67,7 @@ } function CheckLeft(time, xrFrame) { - let source = session.getInputSources()[0]; + let source = session.inputSources[0]; t.step( () => { assert_not_equals(source, null); @@ -81,7 +81,7 @@ } function CheckNoneAgain(time, xrFrame) { - let source = session.getInputSources()[0]; + let source = session.inputSources[0]; t.step( () => { assert_not_equals(source, null);
diff --git a/third_party/blink/web_tests/xr/getInputPose_ray.html b/third_party/blink/web_tests/xr/getInputPose_ray.html index 20e5653..4941061 100644 --- a/third_party/blink/web_tests/xr/getInputPose_ray.html +++ b/third_party/blink/web_tests/xr/getInputPose_ray.html
@@ -45,7 +45,7 @@ session.requestReferenceSpace({ type: "stationary", subtype: "eye-level" }).then( (referenceSpace) => { function CheckTargetRayNoOffset(time, xrFrame) { - let source = session.getInputSources()[0]; + let source = session.inputSources[0]; let grip_pose = xrFrame.getPose(source.gripSpace, referenceSpace); assert_not_equals(grip_pose, null); @@ -76,7 +76,7 @@ } function CheckTargetRayOffset(time, xrFrame) { - let source = session.getInputSources()[0]; + let source = session.inputSources[0]; let grip_pose = xrFrame.getPose(source.gripSpace, referenceSpace); assert_not_equals(grip_pose, null);
diff --git a/third_party/blink/web_tests/xr/xrInputSource_add_remove.html b/third_party/blink/web_tests/xr/xrInputSource_add_remove.html index 8036099a..993389f 100644 --- a/third_party/blink/web_tests/xr/xrInputSource_add_remove.html +++ b/third_party/blink/web_tests/xr/xrInputSource_add_remove.html
@@ -33,7 +33,7 @@ viewMatrix: VALID_VIEW_MATRIX }]); - let input_sources = session.getInputSources(); + let input_sources = session.inputSources; t.step( () => { assert_equals(input_sources.length, 0); @@ -46,7 +46,7 @@ fakeDeviceController.addInputSource(input_source_1); session.requestAnimationFrame((time, xrFrame) => { - let input_sources = session.getInputSources(); + let input_sources = session.inputSources; t.step( () => { assert_equals(input_sources.length, 1); @@ -60,7 +60,7 @@ fakeDeviceController.addInputSource(input_source_2); session.requestAnimationFrame((time, xrFrame) => { - let input_sources = session.getInputSources(); + let input_sources = session.inputSources; t.step( () => { assert_equals(input_sources.length, 2); @@ -71,7 +71,7 @@ fakeDeviceController.removeInputSource(input_source_1); session.requestAnimationFrame((time, xrFrame) => { - let input_sources = session.getInputSources(); + let input_sources = session.inputSources; t.step( () => { assert_equals(input_sources.length, 1);
diff --git a/third_party/blink/web_tests/xr/xrReferenceSpace_originOffset.html b/third_party/blink/web_tests/xr/xrReferenceSpace_originOffset.html index 4dbdb07..b907229 100644 --- a/third_party/blink/web_tests/xr/xrReferenceSpace_originOffset.html +++ b/third_party/blink/web_tests/xr/xrReferenceSpace_originOffset.html
@@ -81,7 +81,7 @@ // any transforms to the given matrix. session.requestReferenceSpace({ type: "stationary", subtype: "eye-level" }).then( (referenceSpace) => { function OnFrame(time, frame) { - let source = session.getInputSources()[0]; + let source = session.inputSources[0]; function CheckState(referenceSpace, expected_view_matrix, expected_grip_matrix, expected_ray_matrix) { let pose = frame.getViewerPose(referenceSpace);
diff --git a/third_party/custom_tabs_client/BUILD.gn b/third_party/custom_tabs_client/BUILD.gn index 0ed6e792..12d1b9c 100644 --- a/third_party/custom_tabs_client/BUILD.gn +++ b/third_party/custom_tabs_client/BUILD.gn
@@ -74,6 +74,7 @@ "src/customtabs/src/android/support/customtabs/CustomTabsServiceConnection.java", "src/customtabs/src/android/support/customtabs/CustomTabsSession.java", "src/customtabs/src/android/support/customtabs/CustomTabsSessionToken.java", + "src/customtabs/src/android/support/customtabs/CustomTabColorSchemeParams.java", "src/customtabs/src/android/support/customtabs/PostMessageBackend.java", "src/customtabs/src/android/support/customtabs/PostMessageService.java", "src/customtabs/src/android/support/customtabs/PostMessageServiceConnection.java",
diff --git a/third_party/r8/README.chromium b/third_party/r8/README.chromium index e06a41e..7d21e6b 100644 --- a/third_party/r8/README.chromium +++ b/third_party/r8/README.chromium
@@ -1,7 +1,7 @@ Name: R8 URL: https://r8.googlesource.com/r8 -Revision: 887271c359ed811656e4b116fb58d64fa9728e0a -Version: 1.5.20-dev +Revision: 3f76a8b25588c00095f8285e8f264d7dd0cab527 +Version: 1.6.1-dev License: BSD 3-Clause License File: NOT_SHIPPED Security Critical: no
diff --git a/third_party/robolectric/BUILD.gn b/third_party/robolectric/BUILD.gn index 50a63f4..1b04c49d 100644 --- a/third_party/robolectric/BUILD.gn +++ b/third_party/robolectric/BUILD.gn
@@ -20,14 +20,9 @@ ] } -java_prebuilt("android-all-4.1.2_r1-robolectric-r1_java") { +java_prebuilt("android-all-4.4_r1-robolectric-r2_java") { testonly = true - jar_path = "lib/android-all-4.1.2_r1-robolectric-r1.jar" -} - -java_prebuilt("android-all-4.3_r2-robolectric-r1_java") { - testonly = true - jar_path = "lib/android-all-4.3_r2-robolectric-r1.jar" + jar_path = "lib/android-all-4.4_r1-robolectric-r2.jar" } java_prebuilt("android-all-5.0.2_r3-robolectric-r0_java") { @@ -45,9 +40,9 @@ jar_path = "lib/android-all-8.0.0_r4-robolectric-r1.jar" } -java_prebuilt("android-all-8.1.0-robolectric-r4402310_java") { +java_prebuilt("android-all-8.1.0-robolectric-4611349_java") { testonly = true - jar_path = "lib/android-all-8.1.0-robolectric-r4402310.jar" + jar_path = "lib/android-all-8.1.0-robolectric-4611349.jar" } java_prebuilt("android-all-9-robolectric-4913185-2_java") { @@ -80,11 +75,11 @@ "//third_party/xstream:xstream_java", ] data_deps = [ - ":android-all-4.1.2_r1-robolectric-r1_java", - ":android-all-4.3_r2-robolectric-r1_java", + ":android-all-4.4_r1-robolectric-r2_java", ":android-all-5.0.2_r3-robolectric-r0_java", ":android-all-7.1.0_r7-robolectric-r1_java", ":android-all-8.0.0_r4-robolectric-r1_java", + ":android-all-8.1.0-robolectric-4611349_java", ":android-all-9-robolectric-4913185-2_java", ] java_files = [ @@ -219,12 +214,11 @@ # directory. Format is chosen as easliy importable by both python and bash. CR = "$0x0A" _data = "" - _data += rebase_path("lib/android-all-4.1.2_r1-robolectric-r1.jar") + CR - _data += rebase_path("lib/android-all-4.3_r2-robolectric-r1.jar") + CR + _data += rebase_path("lib/android-all-4.4_r1-robolectric-r2.jar") + CR _data += rebase_path("lib/android-all-5.0.2_r3-robolectric-r0.jar") + CR _data += rebase_path("lib/android-all-7.1.0_r7-robolectric-r1.jar") + CR _data += rebase_path("lib/android-all-8.0.0_r4-robolectric-r1.jar") + CR - _data += rebase_path("lib/android-all-8.1.0-robolectric-r4402310.jar") + CR + _data += rebase_path("lib/android-all-8.1.0-robolectric-4611349.jar") + CR _data += rebase_path("lib/android-all-9-robolectric-4913185-2.jar") + CR write_file(sdk_target_dir, _data) }
diff --git a/third_party/robolectric/cipd.yaml b/third_party/robolectric/cipd.yaml index a9e8a77..9ffe502 100644 --- a/third_party/robolectric/cipd.yaml +++ b/third_party/robolectric/cipd.yaml
@@ -3,14 +3,13 @@ # found in the LICENSE file. # To create CIPD package run the following command. -# cipd create --pkg-def cipd.yaml -tag version:$(cat version.txt) +# cipd create --pkg-def cipd.yaml package: chromium/third_party/robolectric description: robolectric modified Android SDKs data: - - file: lib/android-all-4.1.2_r1-robolectric-r1.jar - - file: lib/android-all-4.3_r2-robolectric-r1.jar + - file: lib/android-all-4.4_r1-robolectric-r2.jar - file: lib/android-all-5.0.2_r3-robolectric-r0.jar - file: lib/android-all-7.1.0_r7-robolectric-r1.jar - file: lib/android-all-8.0.0_r4-robolectric-r1.jar - - file: lib/android-all-8.1.0-robolectric-r4402310.jar + - file: lib/android-all-8.1.0-robolectric-4611349.jar - file: lib/android-all-9-robolectric-4913185-2.jar
diff --git a/third_party/webxr_test_pages/webxr-samples/input-selection.html b/third_party/webxr_test_pages/webxr-samples/input-selection.html index 61e84c4..9229d04 100644 --- a/third_party/webxr_test_pages/webxr-samples/input-selection.html +++ b/third_party/webxr_test_pages/webxr-samples/input-selection.html
@@ -476,7 +476,7 @@ } } - for (let source of session.getInputSources()) { + for (let source of session.inputSources) { let gamepad = source.gamepad; if (gamepad) { ProcessGamepad(gamepad, source);
diff --git a/third_party/webxr_test_pages/webxr-samples/input-tracking.html b/third_party/webxr_test_pages/webxr-samples/input-tracking.html index 97dd2cb..8004061 100644 --- a/third_party/webxr_test_pages/webxr-samples/input-tracking.html +++ b/third_party/webxr_test_pages/webxr-samples/input-tracking.html
@@ -180,7 +180,7 @@ } function updateInputSources(session, frame, refSpace) { - let inputSources = session.getInputSources(); + let inputSources = session.inputSources; for (let inputSource of inputSources) { // If we have a grip matrix use it to render a mesh showing the
diff --git a/third_party/webxr_test_pages/webxr-samples/js/cottontail/src/scenes/scene.js b/third_party/webxr_test_pages/webxr-samples/js/cottontail/src/scenes/scene.js index eadfdff..eb1ac3ac 100644 --- a/third_party/webxr_test_pages/webxr-samples/js/cottontail/src/scenes/scene.js +++ b/third_party/webxr_test_pages/webxr-samples/js/cottontail/src/scenes/scene.js
@@ -84,11 +84,11 @@ updateInputSources(frame, refSpace) { // FIXME: Check for the existence of the API first. This check should be // removed once the input API is part of the official spec. - if (!frame.session.getInputSources) { + if (!frame.session.inputSources) { return; } - let inputSources = frame.session.getInputSources(); + let inputSources = frame.session.inputSources; let newHoveredNodes = []; let lastHoverFrame = this._hoverFrame;
diff --git a/third_party/webxr_test_pages/webxr-samples/tests/pointer-painter.html b/third_party/webxr_test_pages/webxr-samples/tests/pointer-painter.html index 213dd0c..ecb8f0d4 100644 --- a/third_party/webxr_test_pages/webxr-samples/tests/pointer-painter.html +++ b/third_party/webxr_test_pages/webxr-samples/tests/pointer-painter.html
@@ -197,7 +197,7 @@ } function updateInputSources(session, frame, refSpace) { - let inputSources = session.getInputSources(); + let inputSources = session.inputSources; for (let inputSource of inputSources) { if (inputSource.gripSpace) {
diff --git a/tools/android/asan/third_party/BUILD.gn b/tools/android/asan/third_party/BUILD.gn index 172db265..9171f29 100644 --- a/tools/android/asan/third_party/BUILD.gn +++ b/tools/android/asan/third_party/BUILD.gn
@@ -7,6 +7,7 @@ import("//build/util/generate_wrapper.gni") generate_wrapper("asan_device_setup") { + testonly = true executable = "with_asan.py" wrapper_script = "$root_out_dir/bin/run_with_asan" @@ -38,6 +39,11 @@ ] data += _lib_paths + data_deps = [ + "//build/android:devil_chromium_py", + "//third_party/catapult/devil", + ] + _rebased_adb_path = rebase_path(_adb_path, root_build_dir) _rebased_lib_dir_path = rebase_path(_lib_dir, root_build_dir)
diff --git a/tools/android/asan/third_party/with_asan.py b/tools/android/asan/third_party/with_asan.py index 0c93a98..767a134c 100755 --- a/tools/android/asan/third_party/with_asan.py +++ b/tools/android/asan/third_party/with_asan.py
@@ -10,6 +10,15 @@ import subprocess import sys +_SRC_ROOT = os.path.abspath( + os.path.join(os.path.dirname(__file__), '..', '..', '..', '..')) + +sys.path.append(os.path.join(_SRC_ROOT, 'third_party', 'catapult', 'devil')) +from devil.android import device_utils +from devil.android.sdk import version_codes + +sys.path.append(os.path.join(_SRC_ROOT, 'build', 'android')) +import devil_chromium _SCRIPT_PATH = os.path.abspath( os.path.join( @@ -22,7 +31,13 @@ env = os.environ.copy() env['ADB'] = args.adb + device = device_utils.DeviceUtils.HealthyDevices( + device_arg=args.device)[0] + disable_verity = device.build_version_sdk >= version_codes.MARSHMALLOW try: + if disable_verity: + device.adb.DisableVerity() + device.Reboot() setup_cmd = [_SCRIPT_PATH, '--lib', args.lib] if args.device: setup_cmd += ['--device', args.device] @@ -33,6 +48,9 @@ if args.device: teardown_cmd += ['--device', args.device] subprocess.check_call(teardown_cmd, env=env) + if disable_verity: + device.adb.EnableVerity() + device.Reboot() def main(raw_args): @@ -51,6 +69,8 @@ help='Command to run with ASAN installed.') args = parser.parse_args() + devil_chromium.Initialize(adb_path=args.adb) + with Asan(args): if args.command: return subprocess.call(args.command)
diff --git a/tools/chrome_proxy/webdriver/proxy_connection.py b/tools/chrome_proxy/webdriver/proxy_connection.py index d95f406f..e46545e8 100644 --- a/tools/chrome_proxy/webdriver/proxy_connection.py +++ b/tools/chrome_proxy/webdriver/proxy_connection.py
@@ -14,6 +14,19 @@ class ProxyConnection(IntegrationTest): + def VerifyWarmupHistogram(self, test_driver, is_secure_proxy): + is_histogram_found = False + for histogram_part in ['Core', 'NonCore']: + histogram_name = 'DataReductionProxy.WarmupURLFetcherCallback.' + \ + 'SuccessfulFetch.%s.%s' % ( + 'SecureProxy' if is_secure_proxy else 'InsecureProxy', + histogram_part) + histogram = test_driver.GetBrowserHistogram(histogram_name) + if histogram: + self.assertEqual(1, histogram['count']) + is_histogram_found = True + self.assertTrue(is_histogram_found) + @ChromeVersionEqualOrAfterM(63) def testTLSInjectionAfterHandshake(self): port = common.GetOpenPort() @@ -35,10 +48,11 @@ self.assertEqual(2, len(responses)) for response in responses: self.assertNotHasChromeProxyViaHeader(response) - self.assertTrue(t.SleepUntilHistogramHasEntry('DataReductionProxy.' - 'InvalidResponseHeadersReceived.NetError')) + self.assertTrue( + t.SleepUntilHistogramHasEntry('DataReductionProxy.WarmupURL.NetError')) + self.VerifyWarmupHistogram(t, True) - @ChromeVersionEqualOrAfterM(75) + @ChromeVersionEqualOrAfterM(74) def testTCPReset(self): port = common.GetOpenPort() with TestDriver() as t: @@ -63,9 +77,7 @@ self.assertTrue( t.SleepUntilHistogramHasEntry('DataReductionProxy.WarmupURL.NetError', sleep_intervals=10)) - histogram = t.GetBrowserHistogram('DataReductionProxy.' - 'WarmupURLFetcherCallback.SuccessfulFetch.InsecureProxy.Core') - self.assertEqual(1, histogram['count']) + self.VerifyWarmupHistogram(t, False) @ChromeVersionEqualOrAfterM(63) def testTLSReset(self): @@ -90,7 +102,7 @@ for response in responses: self.assertNotHasChromeProxyViaHeader(response) - @ChromeVersionEqualOrAfterM(75) + @ChromeVersionEqualOrAfterM(74) def testTCPBlackhole(self): port = common.GetOpenPort() with TestDriver() as t: @@ -118,9 +130,7 @@ sleep_intervals=40)) # Check the WarmupURL Callback was called. - histogram = t.GetBrowserHistogram('DataReductionProxy.' - 'WarmupURLFetcherCallback.SuccessfulFetch.InsecureProxy.Core') - self.assertEqual(1, histogram['count']) + self.VerifyWarmupHistogram(t, False) # Verify DRP was not used. t.LoadURL('http://check.googlezip.net/test.html')
diff --git a/tools/chrome_proxy/webdriver/video.py b/tools/chrome_proxy/webdriver/video.py index e6b641b9..194344a4 100644 --- a/tools/chrome_proxy/webdriver/video.py +++ b/tools/chrome_proxy/webdriver/video.py
@@ -106,7 +106,7 @@ self.assertEqual(1, original_kb_histogram['count']) self.assertEqual(1, compression_percent_histogram['count']) # Verify the total page size is 3 KB, and compression ratio. - self.assertGreaterEqual(3, original_kb_histogram['sum']) + self.assertLessEqual(3, original_kb_histogram['sum']) self.assertEqual(compression_percent_histogram['sum'], compressed_full_content_length/ofcl*100) self.assertTrue(saw_range_response, 'No range request was seen in test!')
diff --git a/tools/json_schema_compiler/json_schema_api.gni b/tools/json_schema_compiler/json_schema_api.gni index 9e71801..d1d6ea18 100644 --- a/tools/json_schema_compiler/json_schema_api.gni +++ b/tools/json_schema_compiler/json_schema_api.gni
@@ -106,8 +106,7 @@ } # Compute the contents of the library/source set. - lib_sources = - invoker.sources + get_target_outputs(":$bundle_generator_schema_name") + lib_sources = get_target_outputs(":$bundle_generator_schema_name") lib_deps = [ ":$bundle_generator_schema_name" ] lib_public_deps = [ # For base::StringPiece. @@ -201,8 +200,7 @@ } # Compute the contents of the library/source set. - lib_sources = invoker.sources + - get_target_outputs(":$bundle_generator_registration_name") + lib_sources = get_target_outputs(":$bundle_generator_registration_name") lib_deps = [ ":$bundle_generator_registration_name" ] lib_extra_configs = [] if (defined(invoker.configs)) { @@ -271,7 +269,7 @@ } # Compute the contents of the library/source set. - lib_sources = invoker.sources + get_target_outputs(":$schema_generator_name") + lib_sources = get_target_outputs(":$schema_generator_name") lib_public_deps = [ ":$schema_generator_name" ] lib_deps = [ "//base",
diff --git a/tools/mb/mb_config.pyl b/tools/mb/mb_config.pyl index a695473e..0bf8312 100644 --- a/tools/mb/mb_config.pyl +++ b/tools/mb/mb_config.pyl
@@ -34,17 +34,6 @@ 'win32-archive-dbg': 'debug_bot_x86_minimal_symbols', 'win-archive-rel': 'release_bot_minimal_symbols_enable_archive_compression', 'win-archive-dbg': 'debug_bot_minimal_symbols', - # TODO(crbug.com/888810): Remove once bots are migrated. - 'android-rel': 'android_without_codecs_release_bot_minimal_symbols', - 'android-dbg': 'android_without_codecs_debug_bot_minimal_symbols', - 'linux-rel': 'release_bot', - 'linux-dbg': 'debug_bot', - 'mac-rel': 'release_bot_mac_strip', - 'mac-dbg': 'debug_bot', - 'win32-rel': 'release_bot_x86_minimal_symbols_enable_archive_compression', - 'win32-dbg': 'debug_bot_x86_minimal_symbols', - 'win-rel': 'release_bot_minimal_symbols_enable_archive_compression', - 'win-dbg': 'debug_bot_minimal_symbols', }, 'chromium.android': {
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 9ba279b..8a3f492 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -5173,7 +5173,7 @@ <int value="6" label="Open in incognito"/> <int value="7" label="Undo"/> <int value="8" label="Redo"/> - <int value="9" label="Open (double click/enter)"/> + <int value="9" label="Open bookmark or folder (deprecated)"/> <int value="10" label="Select all"/> <int value="11" label="Deselect all"/> <int value="12" label="Copy"/> @@ -5185,6 +5185,8 @@ <int value="18" label="Import"/> <int value="19" label="Export"/> <int value="20" label="Help center"/> + <int value="21" label="Open bookmark (via double-click / enter)"/> + <int value="22" label="Open folder (via double-click / enter)"/> </enum> <enum name="BookmarkManagerMenuSource"> @@ -38278,6 +38280,11 @@ <int value="4" label="Infobar dismissed after tab closed"/> </enum> +<enum name="MobileMessagesBadgeState"> + <int value="0" label="Inactive"/> + <int value="1" label="Active"/> +</enum> + <enum name="MobileMessagesBannerDismissType"> <int value="0" label="TimedOut"/> <int value="1" label="SwipedUp"/>
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 6e4ee9d8..35cb74e 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -60138,8 +60138,17 @@ <summary>Android: The number of system installed browsers.</summary> </histogram> -<histogram name="Mobile.Messages.Banner.Dismiss" - enum="MobileMessagesBannerDismissType" expires_after="2022-05-01"> +<histogram base="true" name="Mobile.Messages.Badge.Tapped" + enum="MobileMessagesBadgeState" expires_after="2020-02-01"> +<!-- Name completed by histogram_suffixes name="Mobile.Messages.Type" --> + + <owner>sczs@chromium.org</owner> + <owner>thegreenfrog@chromium.org</owner> + <summary>Records the state of a badge when it was tapped.</summary> +</histogram> + +<histogram base="true" name="Mobile.Messages.Banner.Dismiss" + enum="MobileMessagesBannerDismissType" expires_after="2020-02-01"> <!-- Name completed by histogram_suffixes name="Mobile.Messages.Type" --> <owner>sczs@chromium.org</owner> @@ -60147,8 +60156,8 @@ <summary>Records the reason why a Banner was dismissed.</summary> </histogram> -<histogram name="Mobile.Messages.Banner.Event" enum="MobileMessagesBannerEvent" - expires_after="2022-05-01"> +<histogram base="true" name="Mobile.Messages.Banner.Event" + enum="MobileMessagesBannerEvent" expires_after="2020-02-01"> <!-- Name completed by histogram_suffixes name="Mobile.Messages.Type" --> <owner>sczs@chromium.org</owner> @@ -60156,8 +60165,8 @@ <summary>Records Infobar Banner events.</summary> </histogram> -<histogram name="Mobile.Messages.Modal.Event" enum="MobileMessagesModalEvent" - expires_after="2022-05-01"> +<histogram base="true" name="Mobile.Messages.Modal.Event" + enum="MobileMessagesModalEvent" expires_after="2020-02-01"> <!-- Name completed by histogram_suffixes name="Mobile.Messages.Type" --> <owner>sczs@chromium.org</owner> @@ -60165,7 +60174,7 @@ <summary>Records generic Infobar Modal events.</summary> </histogram> -<histogram name="Mobile.Messages.Passwords.Modal.Dismiss" +<histogram base="true" name="Mobile.Messages.Passwords.Modal.Dismiss" enum="MobileMessagesPasswordsModalDismiss" expires_after="2022-05-01"> <!-- Name completed by histogram_suffixes name="Mobile.Messages.Password.Type" --> @@ -60174,8 +60183,8 @@ <summary>Records the reason why a Password Modal was dismissed.</summary> </histogram> -<histogram name="Mobile.Messages.Passwords.Modal.Event" - enum="MobileMessagesPasswordsModalEvent" expires_after="2022-05-01"> +<histogram base="true" name="Mobile.Messages.Passwords.Modal.Event" + enum="MobileMessagesPasswordsModalEvent" expires_after="2020-02-01"> <!-- Name completed by histogram_suffixes name="Mobile.Messages.Password.Type" --> <owner>sczs@chromium.org</owner> @@ -60183,8 +60192,8 @@ <summary>Records Password specific Infobar Modal events.</summary> </histogram> -<histogram name="Mobile.Messages.Passwords.Modal.Present" - enum="MobileMessagesPasswordsModalPresent" expires_after="2022-05-01"> +<histogram base="true" name="Mobile.Messages.Passwords.Modal.Present" + enum="MobileMessagesPasswordsModalPresent" expires_after="2020-02-01"> <!-- Name completed by histogram_suffixes name="Mobile.Messages.Password.Type" --> <owner>sczs@chromium.org</owner> @@ -158497,9 +158506,19 @@ <histogram_suffixes name="TabSwitchingType" separator="."> <suffix name="NoSavedFrames" - label="There is a saved frame in the cache when the tab switch starts."/> + label="The time from the input timestamp on a tab switch, until the + frame is presented on the screen when there is no saved frame in + the cache."/> + <suffix name="NoSavedFrames_Loaded_Frozen" + label="Same as NoSavedFrames with the destination tab being loaded and + frozen."/> + <suffix name="NoSavedFrames_Loaded_NotFrozen" + label="Same as NoSavedFrames with the destination tab being loaded and + not frozen."/> + <suffix name="NoSavedFrames_NotLoaded" + label="Same as WithSavedFrames with the destination tab being unloaded."/> <suffix name="WithSavedFrames" - label="There is no saved frame in the cache when the tab switch starts."/> + label="There is a saved frame in the cache when the tab switch starts."/> <affected-histogram name="Browser.Tabs.TabSwitchResult"/> <affected-histogram name="Browser.Tabs.TotalSwitchDuration"/> </histogram_suffixes>
diff --git a/ui/accessibility/ax_event_generator.cc b/ui/accessibility/ax_event_generator.cc index 55697a51..73dbb03b 100644 --- a/ui/accessibility/ax_event_generator.cc +++ b/ui/accessibility/ax_event_generator.cc
@@ -307,6 +307,12 @@ case ax::mojom::IntAttribute::kScrollY: AddEvent(node, Event::SCROLL_VERTICAL_POSITION_CHANGED); break; + case ax::mojom::IntAttribute::kSortDirection: + // Ignore sort direction changes on roles other than table headers and + // grid headers. + if (ui::IsTableHeader(node->data().role)) + AddEvent(node, Event::SORT_CHANGED); + break; case ax::mojom::IntAttribute::kImageAnnotationStatus: // The image annotation is reported as part of the accessible name. AddEvent(node, Event::IMAGE_ANNOTATION_CHANGED);
diff --git a/ui/accessibility/ax_event_generator.h b/ui/accessibility/ax_event_generator.h index 31137cb..f34480d 100644 --- a/ui/accessibility/ax_event_generator.h +++ b/ui/accessibility/ax_event_generator.h
@@ -73,6 +73,7 @@ SELECTED_CHANGED, SELECTED_CHILDREN_CHANGED, SET_SIZE_CHANGED, + SORT_CHANGED, STATE_CHANGED, SUBTREE_CREATED, VALUE_CHANGED,
diff --git a/ui/accessibility/ax_node_position_unittest.cc b/ui/accessibility/ax_node_position_unittest.cc index dd3f9cec..39a1f7c 100644 --- a/ui/accessibility/ax_node_position_unittest.cc +++ b/ui/accessibility/ax_node_position_unittest.cc
@@ -1672,6 +1672,128 @@ EXPECT_EQ(0, test_position->text_offset()); } +TEST_F(AXPositionTest, AsPositionBeforeAndAfterCharacterWithNullPosition) { + TestPositionType null_position = AXNodePosition::CreateNullPosition(); + ASSERT_NE(nullptr, null_position); + ASSERT_TRUE(null_position->IsNullPosition()); + TestPositionType test_position = null_position->AsPositionBeforeCharacter(); + EXPECT_NE(nullptr, test_position); + EXPECT_TRUE(test_position->IsNullPosition()); + test_position = null_position->AsPositionAfterCharacter(); + EXPECT_NE(nullptr, test_position); + EXPECT_TRUE(test_position->IsNullPosition()); +} + +TEST_F(AXPositionTest, AsPositionBeforeCharacter) { + TestPositionType text_position = AXNodePosition::CreateTextPosition( + tree_.data().tree_id, root_.id, 0 /* text_offset */, + ax::mojom::TextAffinity::kDownstream); + ASSERT_NE(nullptr, text_position); + ASSERT_TRUE(text_position->IsTextPosition()); + TestPositionType test_position = text_position->AsPositionBeforeCharacter(); + EXPECT_NE(nullptr, test_position); + EXPECT_TRUE(test_position->IsTextPosition()); + EXPECT_EQ(inline_box1_.id, test_position->anchor_id()); + EXPECT_EQ(0, test_position->text_offset()); + + text_position = AXNodePosition::CreateTextPosition( + tree_.data().tree_id, inline_box1_.id, 3 /* text_offset */, + ax::mojom::TextAffinity::kDownstream); + ASSERT_NE(nullptr, text_position); + ASSERT_TRUE(text_position->IsTextPosition()); + test_position = text_position->AsPositionBeforeCharacter(); + EXPECT_NE(nullptr, test_position); + EXPECT_TRUE(test_position->IsTextPosition()); + EXPECT_EQ(inline_box1_.id, test_position->anchor_id()); + EXPECT_EQ(3, test_position->text_offset()); + + text_position = AXNodePosition::CreateTextPosition( + tree_.data().tree_id, line_break_.id, 1 /* text_offset */, + ax::mojom::TextAffinity::kDownstream); + ASSERT_NE(nullptr, text_position); + ASSERT_TRUE(text_position->IsTextPosition()); + test_position = text_position->AsPositionBeforeCharacter(); + EXPECT_NE(nullptr, test_position); + EXPECT_TRUE(test_position->IsTextPosition()); + EXPECT_EQ(inline_box2_.id, test_position->anchor_id()); + EXPECT_EQ(0, test_position->text_offset()); + + text_position = AXNodePosition::CreateTextPosition( + tree_.data().tree_id, inline_box2_.id, 0 /* text_offset */, + ax::mojom::TextAffinity::kDownstream); + ASSERT_NE(nullptr, text_position); + ASSERT_TRUE(text_position->IsTextPosition()); + test_position = text_position->AsPositionBeforeCharacter(); + EXPECT_NE(nullptr, test_position); + EXPECT_TRUE(test_position->IsTextPosition()); + EXPECT_EQ(inline_box2_.id, test_position->anchor_id()); + EXPECT_EQ(0, test_position->text_offset()); + + text_position = AXNodePosition::CreateTextPosition( + tree_.data().tree_id, inline_box2_.id, 6 /* text_offset */, + ax::mojom::TextAffinity::kDownstream); + ASSERT_NE(nullptr, text_position); + ASSERT_TRUE(text_position->IsTextPosition()); + test_position = text_position->AsPositionBeforeCharacter(); + EXPECT_NE(nullptr, test_position); + EXPECT_TRUE(test_position->IsNullPosition()); +} + +TEST_F(AXPositionTest, AsPositionAfterCharacter) { + TestPositionType text_position = AXNodePosition::CreateTextPosition( + tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */, + ax::mojom::TextAffinity::kDownstream); + ASSERT_NE(nullptr, text_position); + ASSERT_TRUE(text_position->IsTextPosition()); + TestPositionType test_position = text_position->AsPositionAfterCharacter(); + EXPECT_NE(nullptr, test_position); + EXPECT_TRUE(test_position->IsNullPosition()); + + text_position = AXNodePosition::CreateTextPosition( + tree_.data().tree_id, inline_box1_.id, 5 /* text_offset */, + ax::mojom::TextAffinity::kDownstream); + ASSERT_NE(nullptr, text_position); + ASSERT_TRUE(text_position->IsTextPosition()); + test_position = text_position->AsPositionAfterCharacter(); + EXPECT_NE(nullptr, test_position); + EXPECT_TRUE(test_position->IsTextPosition()); + EXPECT_EQ(inline_box1_.id, test_position->anchor_id()); + EXPECT_EQ(5, test_position->text_offset()); + + text_position = AXNodePosition::CreateTextPosition( + tree_.data().tree_id, line_break_.id, 1 /* text_offset */, + ax::mojom::TextAffinity::kDownstream); + ASSERT_NE(nullptr, text_position); + ASSERT_TRUE(text_position->IsTextPosition()); + test_position = text_position->AsPositionAfterCharacter(); + EXPECT_NE(nullptr, test_position); + EXPECT_TRUE(test_position->IsTextPosition()); + EXPECT_EQ(line_break_.id, test_position->anchor_id()); + EXPECT_EQ(1, test_position->text_offset()); + + text_position = AXNodePosition::CreateTextPosition( + tree_.data().tree_id, inline_box2_.id, 0 /* text_offset */, + ax::mojom::TextAffinity::kDownstream); + ASSERT_NE(nullptr, text_position); + ASSERT_TRUE(text_position->IsTextPosition()); + test_position = text_position->AsPositionAfterCharacter(); + EXPECT_NE(nullptr, test_position); + EXPECT_TRUE(test_position->IsTextPosition()); + EXPECT_EQ(line_break_.id, test_position->anchor_id()); + EXPECT_EQ(1, test_position->text_offset()); + + text_position = AXNodePosition::CreateTextPosition( + tree_.data().tree_id, root_.id, 13 /* text_offset */, + ax::mojom::TextAffinity::kDownstream); + ASSERT_NE(nullptr, text_position); + ASSERT_TRUE(text_position->IsTextPosition()); + test_position = text_position->AsPositionAfterCharacter(); + EXPECT_NE(nullptr, test_position); + EXPECT_TRUE(test_position->IsTextPosition()); + EXPECT_EQ(inline_box2_.id, test_position->anchor_id()); + EXPECT_EQ(6, test_position->text_offset()); +} + TEST_F(AXPositionTest, CreateNextAndPreviousCharacterPositionWithNullPosition) { TestPositionType null_position = AXNodePosition::CreateNullPosition(); ASSERT_NE(nullptr, null_position); @@ -1763,7 +1885,7 @@ AXBoundaryBehavior::CrossBoundary); EXPECT_NE(nullptr, test_position); EXPECT_TRUE(test_position->IsTextPosition()); - EXPECT_EQ(text_field_.id, test_position->anchor_id()); + EXPECT_EQ(inline_box1_.id, test_position->anchor_id()); EXPECT_EQ(1, test_position->text_offset()); // Affinity should have been reset to downstream. EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); @@ -1777,8 +1899,8 @@ AXBoundaryBehavior::CrossBoundary); EXPECT_NE(nullptr, test_position); EXPECT_TRUE(test_position->IsTextPosition()); - EXPECT_EQ(text_field_.id, test_position->anchor_id()); - EXPECT_EQ(13, test_position->text_offset()); + EXPECT_EQ(inline_box2_.id, test_position->anchor_id()); + EXPECT_EQ(6, test_position->text_offset()); // Affinity should have been reset to downstream. EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); } @@ -1860,7 +1982,7 @@ AXBoundaryBehavior::CrossBoundary); EXPECT_NE(nullptr, test_position); EXPECT_TRUE(test_position->IsTextPosition()); - EXPECT_EQ(text_field_.id, test_position->anchor_id()); + EXPECT_EQ(inline_box1_.id, test_position->anchor_id()); EXPECT_EQ(0, test_position->text_offset()); // Affinity should have been reset to downstream. EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
diff --git a/ui/accessibility/ax_position.h b/ui/accessibility/ax_position.h index 7ba094a1..876fe54 100644 --- a/ui/accessibility/ax_position.h +++ b/ui/accessibility/ax_position.h
@@ -796,31 +796,47 @@ return previous_leaf->AsTextPosition(); } + // Returns a text position located right before the next character (from this + // position) on the tree's text representation, following these conditions: + // - If this position is at the end of its anchor, normalize it to the start + // of the next text anchor. Both positions are equal when compared, but we + // consider the start of an anchor to be a position BEFORE its first + // character and the end to be AFTER its last character. + // - Skip any empty text anchors; they're "invisible" to the text + // representation and the next character could be ahead. + // - Return a null position if there is no next character forward. + AXPositionInstance AsPositionBeforeCharacter() const { + AXPositionInstance text_position = AsLeafTextPosition(); + + // This loop satisfies all the conditions described above. + while (text_position->AtEndOfAnchor()) + text_position = text_position->CreateNextTextAnchorPosition(); + return text_position; + } + + // Returns a text position located right after the previous character (from + // this position) on the tree's text representation. + // See `AsPositionBeforeCharacter`, as this is its "reversed" version. + AXPositionInstance AsPositionAfterCharacter() const { + AXPositionInstance text_position = AsLeafTextPosition(); + while (text_position->AtStartOfAnchor()) { + text_position = text_position->CreatePreviousTextAnchorPosition(); + text_position = text_position->CreatePositionAtEndOfAnchor(); + } + return text_position; + } + AXPositionInstance CreateNextCharacterPosition( AXBoundaryBehavior boundary_behavior) const { DCHECK_NE(boundary_behavior, AXBoundaryBehavior::StopIfAlreadyAtBoundary) << "StopIfAlreadyAtBoundary is unreasonable for character boundaries."; - if (boundary_behavior == AXBoundaryBehavior::StopAtAnchorBoundary && AtEndOfAnchor()) return Clone(); const bool was_tree_position = IsTreePosition(); - AXPositionInstance text_position = AsTextPosition(); - - // Being at the end of a text anchor could mean: - // - We're in the position between this anchor's end and the next text - // anchor's start. Normalize it to the next anchor's start so we can reach - // the next character by simply increasing its offset. - // - We're at an empty anchor. Skip it, such anchor is "invisible" to the - // text representation and the next character could be ahead. - // - We're at the end of the last anchor and there is no next character, - // let CreateNextTextAnchorPosition return a null position. - while (text_position->AtEndOfAnchor()) - text_position = text_position->CreateNextTextAnchorPosition(); - - // Either we couldn't get this position as a text position or we reached the - // last anchor and there is no next character position to create. + AXPositionInstance text_position = AsPositionBeforeCharacter(); + // There is no next character position. if (text_position->IsNullPosition()) return text_position; @@ -839,29 +855,13 @@ AXBoundaryBehavior boundary_behavior) const { DCHECK_NE(boundary_behavior, AXBoundaryBehavior::StopIfAlreadyAtBoundary) << "StopIfAlreadyAtBoundary is unreasonable for character boundaries."; - if (boundary_behavior == AXBoundaryBehavior::StopAtAnchorBoundary && AtStartOfAnchor()) return Clone(); const bool was_tree_position = IsTreePosition(); - AXPositionInstance text_position = AsTextPosition(); - - // Being at the start of a text anchor could mean: - // - We're in the position between this anchor's start and the previous - // text anchor's end. Normalize it to the previous anchor's end so we can - // reach the previous character by simply decreasing its offset. - // - We're at an empty anchor. Skip it, such anchor is "invisible" to the - // text representation and the previous character could be behind. - // - We're at the start of the first anchor and there is no previous - // character, let CreatePreviousTextAnchorPosition return a null position. - while (text_position->AtStartOfAnchor()) { - text_position = text_position->CreatePreviousTextAnchorPosition(); - text_position = text_position->CreatePositionAtEndOfAnchor(); - } - - // Either we couldn't get this position as a text position or we reached the - // first anchor and there is no previous character position to create. + AXPositionInstance text_position = AsPositionAfterCharacter(); + // There is no previous character position. if (text_position->IsNullPosition()) return text_position;
diff --git a/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.cc b/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.cc index 3b615d5..fc30f378 100644 --- a/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.cc +++ b/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.cc
@@ -124,33 +124,49 @@ // is on the next TextUnit boundary, if one exists. switch (unit) { case TextUnit_Character: { - // For characters, start_ will always be on a TextUnit boundary. - // Thus, end_ is the only position that needs to be moved. - AXNodePosition::AXPositionInstance next = - start_->CreateNextCharacterPosition( - ui::AXBoundaryBehavior::CrossBoundary); - if (!next->IsNullPosition()) - end_ = next->Clone(); - return S_OK; + // For characters, the start endpoint will always be on a TextUnit + // boundary, thus we only need to move the end position. + AXPositionInstance end_backup = end_->Clone(); + end_ = start_->CreateNextCharacterPosition( + ui::AXBoundaryBehavior::CrossBoundary); + + if (end_->IsNullPosition()) { + // The previous could fail if the start is at the end of the last anchor + // of the tree, try expanding to the previous character instead. + AXPositionInstance start_backup = start_->Clone(); + start_ = start_->CreatePreviousCharacterPosition( + ui::AXBoundaryBehavior::CrossBoundary); + + if (start_->IsNullPosition()) { + // Text representation is empty, undo everything and exit. + start_ = std::move(start_backup); + end_ = std::move(end_backup); + return S_OK; + } + end_ = start_->CreateNextCharacterPosition( + ui::AXBoundaryBehavior::CrossBoundary); + DCHECK(!end_->IsNullPosition()); + } + break; } case TextUnit_Format: start_ = start_->CreatePreviousFormatStartPosition( ui::AXBoundaryBehavior::StopIfAlreadyAtBoundary); end_ = start_->CreateNextFormatEndPosition( ui::AXBoundaryBehavior::StopIfAlreadyAtBoundary); - return S_OK; + break; case TextUnit_Word: start_ = start_->CreatePreviousWordStartPosition( ui::AXBoundaryBehavior::StopIfAlreadyAtBoundary); end_ = start_->CreateNextWordEndPosition( ui::AXBoundaryBehavior::StopIfAlreadyAtBoundary); - return S_OK; + break; case TextUnit_Line: start_ = start_->CreatePreviousLineStartPosition( ui::AXBoundaryBehavior::StopIfAlreadyAtBoundary); end_ = start_->CreateNextLineEndPosition( ui::AXBoundaryBehavior::StopIfAlreadyAtBoundary); - return S_OK; + break; case TextUnit_Paragraph: return E_NOTIMPL; // Since web content is not paginated, TextUnit_Page is not supported. @@ -159,10 +175,26 @@ case TextUnit_Document: start_ = start_->CreatePositionAtStartOfDocument()->AsLeafTextPosition(); end_ = start_->CreatePositionAtEndOfDocument(); - return S_OK; + break; default: return UIA_E_NOTSUPPORTED; } + + // Some text positions are equal when compared, but they could be located at + // different anchors, affecting how `GetEnclosingElement` works. Normalize the + // endpoints to correctly enclose characters of the text representation. + AXPositionInstance normalized_start = start_->AsPositionBeforeCharacter(); + AXPositionInstance normalized_end = end_->AsPositionBeforeCharacter(); + + if (!normalized_start->IsNullPosition()) { + DCHECK_EQ(*start_, *normalized_start); + start_ = std::move(normalized_start); + } + if (!normalized_end->IsNullPosition()) { + DCHECK_EQ(*end_, *normalized_end); + end_ = std::move(normalized_end); + } + return S_OK; } STDMETHODIMP AXPlatformNodeTextRangeProviderWin::FindAttribute(
diff --git a/ui/accessibility/platform/ax_platform_node_textrangeprovider_win_unittest.cc b/ui/accessibility/platform/ax_platform_node_textrangeprovider_win_unittest.cc index a8d64341..a63e48c 100644 --- a/ui/accessibility/platform/ax_platform_node_textrangeprovider_win_unittest.cc +++ b/ui/accessibility/platform/ax_platform_node_textrangeprovider_win_unittest.cc
@@ -696,9 +696,10 @@ TestITextRangeProviderExpandToEnclosingCharacter) { Init(BuildTextDocument({"some text", "more text"})); AXNodePosition::SetTreeForTesting(tree_.get()); + AXNode* root_node = GetRootNode(); ComPtr<ITextRangeProvider> text_range_provider; - GetTextRangeProviderFromTextNode(text_range_provider, GetRootNode()); + GetTextRangeProviderFromTextNode(text_range_provider, root_node); ASSERT_HRESULT_SUCCEEDED( text_range_provider->ExpandToEnclosingUnit(TextUnit_Character)); EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"s"); @@ -739,16 +740,33 @@ ASSERT_HRESULT_SUCCEEDED( text_range_provider->ExpandToEnclosingUnit(TextUnit_Character)); - EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L""); + EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"t"); - // Move both endpoints to the position between the end of the first text - // anchor and before the start of the next anchor. + // Move both endpoints to the position before the start of the "more text" + // anchor. Then, force the start to be on the position after the end of + // "some text" by moving one character backward and one forward. ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit( TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ -9, &count)); ASSERT_EQ(-9, count); + ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit( + TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ -1, + &count)); + ASSERT_EQ(-1, count); + ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit( + TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 1, &count)); + ASSERT_EQ(1, count); ASSERT_HRESULT_SUCCEEDED( text_range_provider->ExpandToEnclosingUnit(TextUnit_Character)); EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"m"); + + // Check that the enclosing element of the range matches ATs expectations. + ComPtr<IRawElementProviderSimple> more_text_provider = + QueryInterfaceFromNode<IRawElementProviderSimple>( + root_node->children()[1]); + ComPtr<IRawElementProviderSimple> enclosing_element; + ASSERT_HRESULT_SUCCEEDED( + text_range_provider->GetEnclosingElement(&enclosing_element)); + EXPECT_EQ(more_text_provider.Get(), enclosing_element.Get()); } TEST_F(AXPlatformNodeTextRangeProviderTest,
diff --git a/ui/android/junit/src/org/chromium/ui/drawable/StateListDrawableBuilderTest.java b/ui/android/junit/src/org/chromium/ui/drawable/StateListDrawableBuilderTest.java index 48911eb..4b033999 100644 --- a/ui/android/junit/src/org/chromium/ui/drawable/StateListDrawableBuilderTest.java +++ b/ui/android/junit/src/org/chromium/ui/drawable/StateListDrawableBuilderTest.java
@@ -31,7 +31,7 @@ private static final int DEFAULT_DRAWABLE = 45678; @Test - @Config(sdk = 18) + @Config(sdk = 19) public void testPreL() { StateListDrawableBuilder b = new StateListDrawableBuilder(RuntimeEnvironment.application); b.addState(CHECKED_DRAWABLE, android.R.attr.state_checked);
diff --git a/ui/aura/BUILD.gn b/ui/aura/BUILD.gn index 18561989..2429001 100644 --- a/ui/aura/BUILD.gn +++ b/ui/aura/BUILD.gn
@@ -124,7 +124,6 @@ "//gpu/ipc/client", "//mojo/public/cpp/system", "//services/service_manager/public/cpp", - "//services/ws/common", "//services/ws/public/cpp", "//services/ws/public/mojom", "//skia", @@ -230,7 +229,6 @@ public_deps = [ ":aura", - "//services/ws/common", # Must be public as headers include buildflags.h. "//ui/base:buildflags", @@ -339,7 +337,6 @@ "//cc/mojo_embedder", "//components/viz/client", "//mojo/core/embedder", - "//services/ws/common:task_runner_test_base", "//services/ws/public/cpp", "//skia", "//testing/gtest",
diff --git a/ui/aura/DEPS b/ui/aura/DEPS index cc3414a..206209eb 100644 --- a/ui/aura/DEPS +++ b/ui/aura/DEPS
@@ -10,7 +10,6 @@ "+mojo/public/cpp", "+services/service_manager/public/cpp", "+services/service_manager/public/mojom", - "+services/ws/common", "+services/ws/public/mojom", "+skia/ext", "+third_party/skia", @@ -20,8 +19,6 @@ "+ui/events", "+ui/gfx", "+ui/gl/test", - "+ui/metro_viewer", # TODO(beng): investigate moving remote_root_window_host - # to ui/metro_viewer. "+ui/ozone/public", "+ui/platform_window", ]
diff --git a/ui/aura/client/default_capture_client.cc b/ui/aura/client/default_capture_client.cc index 498407be..0ce9d550 100644 --- a/ui/aura/client/default_capture_client.cc +++ b/ui/aura/client/default_capture_client.cc
@@ -36,7 +36,7 @@ if (capture_window_ == window) return; if (window) - window->env()->gesture_recognizer()->CancelActiveTouchesExcept(window); + Env::GetInstance()->gesture_recognizer()->CancelActiveTouchesExcept(window); Window* old_capture_window = capture_window_; capture_window_ = window;
diff --git a/ui/aura/client/visibility_client.h b/ui/aura/client/visibility_client.h index b36cddc..04de3b0 100644 --- a/ui/aura/client/visibility_client.h +++ b/ui/aura/client/visibility_client.h
@@ -16,8 +16,8 @@ class AURA_EXPORT VisibilityClient { public: // Called when |window|'s visibility is changing to |visible|. The implementor - // can decide whether or not to pass on the visibility to the underlying - // layer. + // can perform additional actions before reflecting the visibility change on + // the underlying layer. virtual void UpdateLayerVisibility(Window* window, bool visible) = 0; protected:
diff --git a/ui/aura/local/window_port_local.cc b/ui/aura/local/window_port_local.cc index 0167af0..45eb7bc 100644 --- a/ui/aura/local/window_port_local.cc +++ b/ui/aura/local/window_port_local.cc
@@ -32,7 +32,7 @@ if (!window_->IsRootWindow()) return; const bool cursor_is_in_bounds = window_->GetBoundsInScreen().Contains( - window->env()->last_mouse_location()); + Env::GetInstance()->last_mouse_location()); client::CursorClient* cursor_client = client::GetCursorClient(window_); if (cursor_is_in_bounds && cursor_client && cursor_client->IsCursorVisible()) { @@ -73,7 +73,8 @@ WindowPortLocal::~WindowPortLocal() { if (frame_sink_id_.is_valid()) { - auto* context_factory_private = window_->env()->context_factory_private(); + auto* context_factory_private = + Env::GetInstance()->context_factory_private(); auto* host_frame_sink_manager = context_factory_private->GetHostFrameSinkManager(); host_frame_sink_manager->InvalidateFrameSinkId(frame_sink_id_); @@ -143,7 +144,7 @@ std::unique_ptr<cc::LayerTreeFrameSink> WindowPortLocal::CreateLayerTreeFrameSink() { - auto* context_factory_private = window_->env()->context_factory_private(); + auto* context_factory_private = Env::GetInstance()->context_factory_private(); auto* host_frame_sink_manager = context_factory_private->GetHostFrameSinkManager(); @@ -167,7 +168,7 @@ cc::mojo_embedder::AsyncLayerTreeFrameSink::InitParams params; params.gpu_memory_buffer_manager = - window_->env()->context_factory()->GetGpuMemoryBufferManager(); + Env::GetInstance()->context_factory()->GetGpuMemoryBufferManager(); params.pipes.compositor_frame_sink_info = std::move(sink_info); params.pipes.client_request = std::move(client_request); params.enable_surface_synchronization = true; @@ -232,7 +233,7 @@ } void WindowPortLocal::TrackOcclusionState() { - window_->env()->GetWindowOcclusionTracker()->Track(window_); + Env::GetInstance()->GetWindowOcclusionTracker()->Track(window_); } void WindowPortLocal::OnFirstSurfaceActivation(
diff --git a/ui/aura/mus/DEPS b/ui/aura/mus/DEPS index f9f1f16..de43abf4 100644 --- a/ui/aura/mus/DEPS +++ b/ui/aura/mus/DEPS
@@ -15,8 +15,6 @@ "+mojo/public/cpp/system/buffer.h", "+mojo/public/cpp/system/platform_handle.h", "+services/viz/public/interfaces/compositing/compositor_frame_sink.mojom.h", - "+services/ws/common/accelerator_util.h", - "+services/ws/common/task_runner_test_base.h", "+services/ws/public", "+ui/gl/gl_bindings.h", ]
diff --git a/ui/aura/native_window_occlusion_tracker_win_interactive_test.cc b/ui/aura/native_window_occlusion_tracker_win_interactive_test.cc index b4b6416..8c27a9d9 100644 --- a/ui/aura/native_window_occlusion_tracker_win_interactive_test.cc +++ b/ui/aura/native_window_occlusion_tracker_win_interactive_test.cc
@@ -168,7 +168,7 @@ Window* window = CreateNormalWindow(1, host()->window(), nullptr); window->SetBounds(bounds); - window->env()->GetWindowOcclusionTracker()->Track(window); + Env::GetInstance()->GetWindowOcclusionTracker()->Track(window); } int GetNumVisibleRootWindows() {
diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc index 24f4db9..c7acadf7 100644 --- a/ui/aura/test/test_screen.cc +++ b/ui/aura/test/test_screen.cc
@@ -150,10 +150,7 @@ } gfx::Point TestScreen::GetCursorScreenPoint() { - // This may be hit during shutdown, after |host_| has been destroyed. - return host_ && host_->window() - ? host_->window()->env()->last_mouse_location() - : gfx::Point(); + return Env::GetInstance()->last_mouse_location(); } bool TestScreen::IsWindowUnderCursor(gfx::NativeWindow window) {
diff --git a/ui/aura/test/ui_controls_factory_aurax11.cc b/ui/aura/test/ui_controls_factory_aurax11.cc index 1b4db34..6334c74 100644 --- a/ui/aura/test/ui_controls_factory_aurax11.cc +++ b/ui/aura/test/ui_controls_factory_aurax11.cc
@@ -144,7 +144,7 @@ int accelerator_state) override { XEvent xevent = {0}; XButtonEvent* xbutton = &xevent.xbutton; - gfx::Point mouse_loc = host_->window()->env()->last_mouse_location(); + gfx::Point mouse_loc = Env::GetInstance()->last_mouse_location(); aura::client::ScreenPositionClient* screen_position_client = aura::client::GetScreenPositionClient(host_->window()); if (screen_position_client) {
diff --git a/ui/aura/test/ui_controls_factory_ozone.cc b/ui/aura/test/ui_controls_factory_ozone.cc index 130aaf07..09c0aec5 100644 --- a/ui/aura/test/ui_controls_factory_ozone.cc +++ b/ui/aura/test/ui_controls_factory_ozone.cc
@@ -144,7 +144,7 @@ int button_state, base::OnceClosure closure, int accelerator_state) override { - gfx::PointF host_location(host_->window()->env()->last_mouse_location()); + gfx::PointF host_location(Env::GetInstance()->last_mouse_location()); int64_t display_id = display::kInvalidDisplayId; if (!ScreenDIPToHostPixels(&host_location, &display_id)) return false;
diff --git a/ui/aura/window.cc b/ui/aura/window.cc index 97d8517..19a3906 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc
@@ -60,8 +60,7 @@ Window::Window(WindowDelegate* delegate, std::unique_ptr<WindowPort> port, client::WindowType type) - : env_(Env::GetInstance()), - port_owner_(std::move(port)), + : port_owner_(std::move(port)), port_(port_owner_.get()), host_(nullptr), type_(type), @@ -153,7 +152,7 @@ WindowOcclusionTracker::ScopedPause pause_occlusion_tracking; if (!port_owner_) { - port_owner_ = env_->CreateWindowPort(this); + port_owner_ = Env::GetInstance()->CreateWindowPort(this); port_ = port_owner_.get(); } SetLayer(std::make_unique<ui::Layer>(layer_type)); @@ -162,7 +161,7 @@ layer()->set_delegate(this); UpdateLayerName(); layer()->SetFillsBoundsOpaquely(!transparent_); - env_->NotifyWindowInitialized(this); + Env::GetInstance()->NotifyWindowInitialized(this); } void Window::SetType(client::WindowType type) { @@ -375,8 +374,6 @@ DCHECK(layer()) << "Parent has not been Init()ed yet."; DCHECK(child->layer()) << "Child has not been Init()ed yt."; - DCHECK_EQ(env_, child->env_) << "All windows in a hierarchy must share the " - " same Env."; WindowObserver::HierarchyChangeParams params; params.target = child; params.new_parent = this; @@ -1093,8 +1090,9 @@ base::AutoReset<bool> in_cleanup(&cleaning_up_gesture_state_, true); bool state_modified = false; - state_modified |= env_->gesture_recognizer()->CancelActiveTouches(this); - state_modified |= env_->gesture_recognizer()->CleanupStateForConsumer(this); + Env* env = Env::GetInstance(); + state_modified |= env->gesture_recognizer()->CancelActiveTouches(this); + state_modified |= env->gesture_recognizer()->CleanupStateForConsumer(this); // Potentially event handlers for CancelActiveTouches() within // CleanupGestureState may change the window hierarchy (or reorder the // |children_|), and therefore iterating over |children_| is not safe. Use @@ -1307,7 +1305,7 @@ if (IsRootWindow()) { return client::GetEventClient(this) ? client::GetEventClient(this)->GetToplevelEventTarget() - : env_; + : Env::GetInstance(); } return parent_; }
diff --git a/ui/aura/window.h b/ui/aura/window.h index 2cbf7f2..10c53084 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h
@@ -62,7 +62,6 @@ namespace aura { -class Env; class LayoutManager; class ScopedKeyboardHook; class WindowDelegate; @@ -453,9 +452,6 @@ // Starts occlusion state tracking. void TrackOcclusionState(); - Env* env() { return env_; } - const Env* env() const { return env_; } - // Notifies observers of the state of a resize loop. void NotifyResizeLoopStarted(); void NotifyResizeLoopEnded(); @@ -622,10 +618,6 @@ void RegisterFrameSinkId(); void UnregisterFrameSinkId(); - // Env this window was created with. Env::GetInstance() if a null Env was - // supplied. - Env* const env_; - bool registered_frame_sink_id_ = false; bool disable_frame_sink_id_registration_ = false;
diff --git a/ui/aura/window_event_dispatcher.cc b/ui/aura/window_event_dispatcher.cc index 5e52cacb..1c983947 100644 --- a/ui/aura/window_event_dispatcher.cc +++ b/ui/aura/window_event_dispatcher.cc
@@ -71,16 +71,16 @@ WindowEventDispatcher::ObserverNotifier::ObserverNotifier( WindowEventDispatcher* dispatcher, const ui::Event& event) - : env_(dispatcher->host()->window()->env()), dispatcher_(dispatcher) { + : dispatcher_(dispatcher) { for (WindowEventDispatcherObserver& observer : - env_->window_event_dispatcher_observers()) { + Env::GetInstance()->window_event_dispatcher_observers()) { observer.OnWindowEventDispatcherStartedProcessing(dispatcher, event); } } WindowEventDispatcher::ObserverNotifier::~ObserverNotifier() { for (WindowEventDispatcherObserver& observer : - env_->window_event_dispatcher_observers()) { + Env::GetInstance()->window_event_dispatcher_observers()) { observer.OnWindowEventDispatcherFinishedProcessingEvent(dispatcher_); } } @@ -90,19 +90,18 @@ WindowEventDispatcher::WindowEventDispatcher(WindowTreeHost* host, bool are_events_in_pixels) - : env_(host->window()->env()), - host_(host), + : host_(host), are_events_in_pixels_(are_events_in_pixels), observer_manager_(this), event_targeter_(std::make_unique<WindowTargeter>()) { - env_->gesture_recognizer()->AddGestureEventHelper(this); - env_->AddObserver(this); + Env::GetInstance()->gesture_recognizer()->AddGestureEventHelper(this); + Env::GetInstance()->AddObserver(this); } WindowEventDispatcher::~WindowEventDispatcher() { TRACE_EVENT0("shutdown", "WindowEventDispatcher::Destructor"); - env_->gesture_recognizer()->RemoveGestureEventHelper(this); - env_->RemoveObserver(this); + Env::GetInstance()->gesture_recognizer()->RemoveGestureEventHelper(this); + Env::GetInstance()->RemoveObserver(this); } void WindowEventDispatcher::Shutdown() { @@ -189,7 +188,7 @@ ui::EventResult result, bool is_source_touch_event_set_non_blocking) { ui::GestureRecognizer::Gestures gestures = - env_->gesture_recognizer()->AckTouchEvent( + Env::GetInstance()->gesture_recognizer()->AckTouchEvent( unique_event_id, result, is_source_touch_event_set_non_blocking, window); DispatchDetails details = ProcessGestures(window, std::move(gestures)); @@ -229,7 +228,7 @@ } gfx::Point WindowEventDispatcher::GetLastMouseLocationInRoot() const { - gfx::Point location = host_->window()->env()->last_mouse_location(); + gfx::Point location = Env::GetInstance()->last_mouse_location(); ConvertPointFromScreen(&location); return location; } @@ -241,8 +240,8 @@ void WindowEventDispatcher::OnCursorMovedToRootLocation( const gfx::Point& root_location) { - host_->window()->env()->env_controller()->SetLastMouseLocation(window(), - root_location); + Env::GetInstance()->env_controller()->SetLastMouseLocation(window(), + root_location); // Synthesize a mouse move in case the cursor's location in root coordinates // changed but its position in WindowTreeHost coordinates did not. @@ -303,8 +302,8 @@ Window* target, const ui::MouseEvent& event, ui::EventType type) { - host_->window()->env()->env_controller()->UpdateStateForMouseEvent(window(), - event); + Env::GetInstance()->env_controller()->UpdateStateForMouseEvent(window(), + event); if (!mouse_moved_handler_ || !mouse_moved_handler_->HasTargetHandler() || !window()->Contains(mouse_moved_handler_)) return DispatchDetails(); @@ -408,7 +407,7 @@ if (old_capture && old_capture->GetRootWindow() == window() && old_capture->delegate()) { // Send a capture changed event with the most recent mouse screen location. - const gfx::Point location = host_->window()->env()->last_mouse_location(); + const gfx::Point location = Env::GetInstance()->last_mouse_location(); ui::MouseEvent event(ui::ET_MOUSE_CAPTURE_CHANGED, location, location, ui::EventTimeForNow(), 0, 0); @@ -423,7 +422,7 @@ if (new_capture) { // Make all subsequent mouse events go to the capture window. We shouldn't // need to send an event here as OnCaptureLost() should take care of that. - if (mouse_moved_handler_ || host_->window()->env()->IsMouseButtonDown()) + if (mouse_moved_handler_ || Env::GetInstance()->IsMouseButtonDown()) mouse_moved_handler_ = new_capture; } else { // Make sure mouse_moved_handler gets updated. @@ -568,7 +567,7 @@ if (!touchevent.synchronous_handling_disabled()) { Window* window = static_cast<Window*>(target); ui::GestureRecognizer::Gestures gestures = - env_->gesture_recognizer()->AckTouchEvent( + Env::GetInstance()->gesture_recognizer()->AckTouchEvent( touchevent.unique_event_id(), event.result(), false /* is_source_touch_event_set_non_blocking */, window); @@ -781,7 +780,7 @@ if (!dispatch_details.dispatcher_destroyed) { dispatching_held_event_ = nullptr; for (WindowEventDispatcherObserver& observer : - host_->window()->env()->window_event_dispatcher_observers()) { + Env::GetInstance()->window_event_dispatcher_observers()) { observer.OnWindowEventDispatcherDispatchedHeldEvents(this); } if (did_dispatch_held_move_event_callback_) @@ -837,7 +836,7 @@ // instead of a MOVED event, but in multi-display/multi-host scenarios, the // DRAGGED event can be synthesized in the incorrect host. So avoid // synthesizing any events at all. - if (host_->window()->env()->mouse_button_flags()) + if (Env::GetInstance()->mouse_button_flags()) return details; // Do not use GetLastMouseLocationInRoot here because it's not updated when @@ -887,8 +886,8 @@ return DispatchDetails(); } - host_->window()->env()->env_controller()->UpdateStateForMouseEvent(window(), - *event); + Env::GetInstance()->env_controller()->UpdateStateForMouseEvent(window(), + *event); if (IsEventCandidateForHold(*event) && !dispatching_held_event_) { if (move_hold_count_) { @@ -1003,16 +1002,17 @@ return DispatchDetails(); } - host_->window()->env()->env_controller()->UpdateStateForTouchEvent(*event); + Env::GetInstance()->env_controller()->UpdateStateForTouchEvent(*event); ui::TouchEvent root_relative_event(*event); root_relative_event.set_location_f(event->root_location_f()); - if (!env_->gesture_recognizer()->ProcessTouchEventPreDispatch( + Env* env = Env::GetInstance(); + if (!env->gesture_recognizer()->ProcessTouchEventPreDispatch( &root_relative_event, target)) { // The event is invalid - ignore it. event->StopPropagation(); event->DisableSynchronousHandling(); - for (auto& observer : env_->window_event_dispatcher_observers()) + for (auto& observer : env->window_event_dispatcher_observers()) observer.OnWindowEventDispatcherIgnoredEvent(this); return DispatchDetails(); }
diff --git a/ui/aura/window_event_dispatcher.h b/ui/aura/window_event_dispatcher.h index 3984ed5..680ff3e 100644 --- a/ui/aura/window_event_dispatcher.h +++ b/ui/aura/window_event_dispatcher.h
@@ -38,7 +38,6 @@ } namespace aura { -class Env; class TestScreen; class WindowTargeter; class WindowTreeHost; @@ -160,7 +159,6 @@ ~ObserverNotifier(); private: - Env* env_; WindowEventDispatcher* dispatcher_; DISALLOW_COPY_AND_ASSIGN(ObserverNotifier); @@ -288,10 +286,6 @@ ui::TouchEvent* event); ui::EventDispatchDetails PreDispatchKeyEvent(ui::KeyEvent* event); - // Comes from host_->window()->env(). Cached as it's needed in the destructor - // and at that time the window has been deleted. - Env* env_; - WindowTreeHost* host_; const bool are_events_in_pixels_;
diff --git a/ui/aura/window_occlusion_tracker.cc b/ui/aura/window_occlusion_tracker.cc index 875202e..642250f 100644 --- a/ui/aura/window_occlusion_tracker.cc +++ b/ui/aura/window_occlusion_tracker.cc
@@ -166,7 +166,7 @@ WindowOcclusionTracker::ScopedExclude::ScopedExclude(Window* window) : window_(window) { window->AddObserver(this); - window->env()->GetWindowOcclusionTracker()->Exclude(window_); + Env::GetInstance()->GetWindowOcclusionTracker()->Exclude(window_); } WindowOcclusionTracker::ScopedExclude::~ScopedExclude() { @@ -181,7 +181,7 @@ void WindowOcclusionTracker::ScopedExclude::Shutdown() { if (window_) { window_->RemoveObserver(this); - window_->env()->GetWindowOcclusionTracker()->Unexclude(window_); + Env::GetInstance()->GetWindowOcclusionTracker()->Unexclude(window_); window_ = nullptr; } } @@ -189,7 +189,7 @@ WindowOcclusionTracker::ScopedForceVisible::ScopedForceVisible(Window* window) : window_(window) { window_->AddObserver(this); - window->env()->GetWindowOcclusionTracker()->ForceWindowVisible(window_); + Env::GetInstance()->GetWindowOcclusionTracker()->ForceWindowVisible(window_); } WindowOcclusionTracker::ScopedForceVisible::~ScopedForceVisible() { @@ -205,7 +205,7 @@ void WindowOcclusionTracker::ScopedForceVisible::Shutdown() { if (window_) { window_->RemoveObserver(this); - window_->env()->GetWindowOcclusionTracker()->RemoveForceWindowVisible( + Env::GetInstance()->GetWindowOcclusionTracker()->RemoveForceWindowVisible( window_); window_ = nullptr; }
diff --git a/ui/aura/window_occlusion_tracker_unittest.cc b/ui/aura/window_occlusion_tracker_unittest.cc index 8bac1414..d91dbca1 100644 --- a/ui/aura/window_occlusion_tracker_unittest.cc +++ b/ui/aura/window_occlusion_tracker_unittest.cc
@@ -98,7 +98,7 @@ } WindowOcclusionTracker& GetOcclusionTracker() { - return *root_window()->env()->GetWindowOcclusionTracker(); + return *Env::GetInstance()->GetWindowOcclusionTracker(); } private: @@ -975,7 +975,8 @@ EXPECT_FALSE(delegate_b->is_expecting_call()); // Use customized WindowHasContent callback to mark b as opaque. - window_b->env()->GetWindowOcclusionTracker()->set_window_has_content_callback( + Env* env = Env::GetInstance(); + env->GetWindowOcclusionTracker()->set_window_has_content_callback( base::BindLambdaForTesting([window_b](const Window* window) -> bool { return window == window_b; })); @@ -987,7 +988,7 @@ EXPECT_FALSE(delegate_a->is_expecting_call()); EXPECT_FALSE(delegate_b->is_expecting_call()); - window_b->env()->GetWindowOcclusionTracker()->set_window_has_content_callback( + env->GetWindowOcclusionTracker()->set_window_has_content_callback( base::NullCallback()); } @@ -1647,7 +1648,7 @@ // its occlusion state changed, a DCHECK occurs. TEST_F(WindowOcclusionTrackerTest, OcclusionStatesDontBecomeStable) { test::WindowOcclusionTrackerTestApi test_api( - root_window()->env()->GetWindowOcclusionTracker()); + Env::GetInstance()->GetWindowOcclusionTracker()); // Create 2 superposed tracked windows. MockWindowDelegate* delegate_a = new MockWindowDelegate(); @@ -1876,7 +1877,7 @@ TEST_F(WindowOcclusionTrackerTest, HideWindowWithHiddenParentOnOcclusionChange) { test::WindowOcclusionTrackerTestApi test_api( - root_window()->env()->GetWindowOcclusionTracker()); + Env::GetInstance()->GetWindowOcclusionTracker()); auto* delegate_a = new WindowDelegateAddingAndHidingChild(this); delegate_a->set_expectation(Window::OcclusionState::VISIBLE, SkRegion());
diff --git a/ui/aura/window_targeter.cc b/ui/aura/window_targeter.cc index 4adab334..9a36335d 100644 --- a/ui/aura/window_targeter.cc +++ b/ui/aura/window_targeter.cc
@@ -95,7 +95,7 @@ // Query the gesture-recognizer to find targets for touch events. const ui::TouchEvent& touch = *event.AsTouchEvent(); ui::GestureConsumer* consumer = - root_window->env()->gesture_recognizer()->GetTouchLockedTarget(touch); + Env::GetInstance()->gesture_recognizer()->GetTouchLockedTarget(touch); if (consumer) return static_cast<Window*>(consumer); } @@ -116,7 +116,7 @@ const ui::TouchEvent& touch = *event.AsTouchEvent(); // GetTouchLockedTarget() is handled in GetPriorityTargetInRootWindow(). ui::GestureRecognizer* gesture_recognizer = - root_window->env()->gesture_recognizer(); + Env::GetInstance()->gesture_recognizer(); DCHECK(!gesture_recognizer->GetTouchLockedTarget(touch)); ui::GestureConsumer* consumer = gesture_recognizer->GetTargetForLocation( event.location_f(), touch.source_device_id());
diff --git a/ui/aura/window_tree_host.cc b/ui/aura/window_tree_host.cc index d4b3fd7d7..29941baa 100644 --- a/ui/aura/window_tree_host.cc +++ b/ui/aura/window_tree_host.cc
@@ -114,7 +114,7 @@ UpdateRootWindowSizeInPixels(); InitCompositor(); - window()->env()->NotifyHostInitialized(this); + Env::GetInstance()->NotifyHostInitialized(this); } void WindowTreeHost::AddObserver(WindowTreeHostObserver* observer) { @@ -388,8 +388,7 @@ ui::ExternalBeginFrameClient* external_begin_frame_client, bool are_events_in_pixels, const char* trace_environment_name) { - DCHECK(window()->env()); - Env* env = window()->env(); + Env* env = Env::GetInstance(); ui::ContextFactory* context_factory = env->context_factory(); DCHECK(context_factory); ui::ContextFactoryPrivate* context_factory_private = @@ -402,7 +401,7 @@ base::ThreadTaskRunnerHandle::Get(), ui::IsPixelCanvasRecordingEnabled(), external_begin_frame_client, force_software_compositor, trace_environment_name); -#if defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) || defined(USE_X11) compositor_->AddObserver(this); #endif if (!dispatcher()) { @@ -551,7 +550,7 @@ } void WindowTreeHost::OnCompositingChildResizing(ui::Compositor* compositor) { - if (!window()->env()->throttle_input_on_resize() || holding_pointer_moves_) + if (!Env::GetInstance()->throttle_input_on_resize() || holding_pointer_moves_) return; synchronization_start_time_ = base::TimeTicks::Now(); dispatcher_->HoldPointerMoves();
diff --git a/ui/base/ime/init/input_method_factory.cc b/ui/base/ime/init/input_method_factory.cc index 43dfbeb..b79ccae 100644 --- a/ui/base/ime/init/input_method_factory.cc +++ b/ui/base/ime/init/input_method_factory.cc
@@ -6,7 +6,6 @@ #include "base/command_line.h" #include "base/memory/ptr_util.h" -#include "base/win/windows_version.h" #include "build/build_config.h" #include "ui/base/ime/mock_input_method.h" #include "ui/base/ui_base_features.h" @@ -60,10 +59,8 @@ #if defined(OS_CHROMEOS) return std::make_unique<InputMethodChromeOS>(delegate); #elif defined(OS_WIN) - if (base::FeatureList::IsEnabled(features::kTSFImeSupport) && - base::win::GetVersion() > base::win::Version::WIN7) { + if (base::FeatureList::IsEnabled(features::kTSFImeSupport)) return std::make_unique<InputMethodWinTSF>(delegate, widget); - } return std::make_unique<InputMethodWinImm32>(delegate, widget); #elif defined(OS_MACOSX) return std::make_unique<InputMethodMac>(delegate);
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index 7a10483..544d5fdb 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc
@@ -1299,6 +1299,14 @@ return icc_profile; } +bool IsSyncExtensionAvailable() { + auto* display = gfx::GetXDisplay(); + int unused; + static bool result = XSyncQueryExtension(display, &unused, &unused) && + XSyncInitialize(display, &unused, &unused); + return result; +} + XRefcountedMemory::XRefcountedMemory(unsigned char* x11_data, size_t length) : x11_data_(length ? x11_data : nullptr), length_(length) { }
diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h index ee36758..daf755e 100644 --- a/ui/base/x/x11_util.h +++ b/ui/base/x/x11_util.h
@@ -301,6 +301,9 @@ // Returns the ICCProfile corresponding to |monitor| using XGetWindowProperty. UI_BASE_X_EXPORT gfx::ICCProfile GetICCProfileForMonitor(int monitor); +// Return true if the display supports SYNC extension. +UI_BASE_X_EXPORT bool IsSyncExtensionAvailable(); + // Manages a piece of X11 allocated memory as a RefCountedMemory segment. This // object takes ownership over the passed in memory and will free it with the // X11 allocator when done.
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc index d101328..8bd8f200 100644 --- a/ui/compositor/compositor.cc +++ b/ui/compositor/compositor.cc
@@ -707,6 +707,13 @@ NOTREACHED(); } +#if defined(USE_X11) +void Compositor::OnCompleteSwapWithNewSize(const gfx::Size& size) { + for (auto& observer : observer_list_) + observer.OnCompositingCompleteSwapWithNewSize(this, size); +} +#endif + void Compositor::SetOutputIsSecure(bool output_is_secure) { if (context_factory_private_) context_factory_private_->SetOutputIsSecure(this, output_is_secure);
diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h index d1352c0..ce87db9 100644 --- a/ui/compositor/compositor.h +++ b/ui/compositor/compositor.h
@@ -425,6 +425,10 @@ void OnFirstSurfaceActivation(const viz::SurfaceInfo& surface_info) override; void OnFrameTokenChanged(uint32_t frame_token) override; +#if defined(USE_X11) + void OnCompleteSwapWithNewSize(const gfx::Size& size); +#endif + bool IsLocked() { return lock_manager_.IsLocked(); } void SetOutputIsSecure(bool output_is_secure);
diff --git a/ui/compositor/compositor_observer.h b/ui/compositor/compositor_observer.h index 5745c3cb..a67c005 100644 --- a/ui/compositor/compositor_observer.h +++ b/ui/compositor/compositor_observer.h
@@ -8,6 +8,10 @@ #include "base/time/time.h" #include "ui/compositor/compositor_export.h" +namespace gfx { +class Size; +} + namespace viz { class LocalSurfaceIdAllocation; } @@ -41,6 +45,12 @@ // Called when a child of the compositor is resizing. virtual void OnCompositingChildResizing(Compositor* compositor) {} +#if defined(USE_X11) + // Called when a swap with new size is completed. + virtual void OnCompositingCompleteSwapWithNewSize(ui::Compositor* compositor, + const gfx::Size& size) {} +#endif + // Called at the top of the compositor's destructor, to give observers a // chance to remove themselves. virtual void OnCompositingShuttingDown(Compositor* compositor) {}
diff --git a/ui/compositor/host/host_context_factory_private.cc b/ui/compositor/host/host_context_factory_private.cc index f8b1e4b..0ff1e052 100644 --- a/ui/compositor/host/host_context_factory_private.cc +++ b/ui/compositor/host/host_context_factory_private.cc
@@ -28,7 +28,38 @@ namespace ui { namespace { + static const char* kBrowser = "Browser"; + +#if defined(USE_X11) +class HostDisplayClient : public viz::HostDisplayClient { + public: + explicit HostDisplayClient(ui::Compositor* compositor) + : viz::HostDisplayClient(compositor->widget()), compositor_(compositor) {} + ~HostDisplayClient() override = default; + + // viz::HostDisplayClient: + void DidCompleteSwapWithNewSize(const gfx::Size& size) override { + compositor_->OnCompleteSwapWithNewSize(size); + } + + private: + ui::Compositor* const compositor_; + + DISALLOW_COPY_AND_ASSIGN(HostDisplayClient); +}; +#else +class HostDisplayClient : public viz::HostDisplayClient { + public: + explicit HostDisplayClient(ui::Compositor* compositor) + : viz::HostDisplayClient(compositor->widget()) {} + ~HostDisplayClient() override = default; + + private: + DISALLOW_COPY_AND_ASSIGN(HostDisplayClient); +}; +#endif + } // namespace HostContextFactoryPrivate::HostContextFactoryPrivate( @@ -58,11 +89,9 @@ gfx::RenderingWindowManager::GetInstance()->RegisterParent( compositor->widget()); #endif - auto& compositor_data = compositor_data_map_[compositor]; auto root_params = viz::mojom::RootCompositorFrameSinkParams::New(); - // Create interfaces for a root CompositorFrameSink. viz::mojom::CompositorFrameSinkAssociatedPtrInfo sink_info; root_params->compositor_frame_sink = mojo::MakeRequest(&sink_info); @@ -71,7 +100,7 @@ root_params->display_private = mojo::MakeRequest(&compositor_data.display_private); compositor_data.display_client = - std::make_unique<viz::HostDisplayClient>(compositor->widget()); + std::make_unique<HostDisplayClient>(compositor); root_params->display_client = compositor_data.display_client->GetBoundPtr(resize_task_runner_) .PassInterface();
diff --git a/ui/gfx/x/x11.h b/ui/gfx/x/x11.h index 4bce2bc..3a93a98 100644 --- a/ui/gfx/x/x11.h +++ b/ui/gfx/x/x11.h
@@ -36,6 +36,7 @@ #include <X11/extensions/record.h> #include <X11/extensions/scrnsaver.h> #include <X11/extensions/shape.h> +#include <X11/extensions/sync.h> // Define XK_xxx before the #include of <X11/keysym.h> so that <X11/keysym.h> // defines all KeySyms we need.
diff --git a/ui/gfx/x/x11_atom_cache.cc b/ui/gfx/x/x11_atom_cache.cc index 7405b88..2c87436 100644 --- a/ui/gfx/x/x11_atom_cache.cc +++ b/ui/gfx/x/x11_atom_cache.cc
@@ -91,6 +91,7 @@ }; constexpr const char* kAtomsToCache[] = { + "ATOM_PAIR", "Abs Dbl End Timestamp", "Abs Dbl Fling X Velocity", "Abs Dbl Fling Y Velocity", @@ -101,7 +102,6 @@ "Abs Dbl Start Timestamp", "Abs Finger Count", "Abs Fling State", - "Abs Metrics Type", "Abs MT Orientation", "Abs MT Position X", "Abs MT Position Y", @@ -109,25 +109,11 @@ "Abs MT Touch Major", "Abs MT Touch Minor", "Abs MT Tracking ID", - "application/octet-stream", - "application/vnd.chromium.test", - "ATOM_PAIR", + "Abs Metrics Type", "CHECK", - "_CHROME_DISPLAY_INTERNAL", - "_CHROME_DISPLAY_ROTATION", - "_CHROME_DISPLAY_SCALE_FACTOR", "CHOME_SELECTION", "CHROME_SELECTION", - "_CHROMIUM_DRAG_RECEIVER", - "chromium/filename", "CHROMIUM_TIMESTAMP", - "chromium/x-bookmark-entries", - "chromium/x-browser-actions", - "chromium/x-file-system-files", - "chromium/x-pepper-custom-data", - "chromium/x-renderer-taint", - "chromium/x-web-custom-data", - "chromium/x-webkit-paste", "CLIPBOARD", "CLIPBOARD_MANAGER", "Content Protection", @@ -138,74 +124,26 @@ "Enabled", "FAKE_SELECTION", "Full aspect", - "_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED", - "_GTK_THEME_VARIANT", - "_ICC_PROFILE", - "image/png", "INCR", "KEYBOARD", "LOCK", - "marker_event", - "_MOTIF_WM_HINTS", "MOUSE", "MULTIPLE", - "_NET_ACTIVE_WINDOW", - "_NET_CLIENT_LIST_STACKING", - "_NET_CURRENT_DESKTOP", - "_NET_FRAME_EXTENTS", - "_NETSCAPE_URL", - "_NET_SUPPORTED", - "_NET_SUPPORTING_WM_CHECK", - "_NET_WM_BYPASS_COMPOSITOR", - "_NET_WM_CM_S0", - "_NET_WM_DESKTOP", - "_NET_WM_ICON", - "_NET_WM_MOVERESIZE", - "_NET_WM_NAME", - "_NET_WM_PID", - "_NET_WM_PING", - "_NET_WM_STATE", - "_NET_WM_STATE_ABOVE", - "_NET_WM_STATE_FOCUSED", - "_NET_WM_STATE_FULLSCREEN", - "_NET_WM_STATE_HIDDEN", - "_NET_WM_STATE_MAXIMIZED_HORZ", - "_NET_WM_STATE_MAXIMIZED_VERT", - "_NET_WM_STATE_SKIP_TASKBAR", - "_NET_WM_STATE_STICKY", - "_NET_WM_USER_TIME", - "_NET_WM_WINDOW_OPACITY", - "_NET_WM_WINDOW_TYPE", - "_NET_WM_WINDOW_TYPE_DND", - "_NET_WM_WINDOW_TYPE_MENU", - "_NET_WM_WINDOW_TYPE_NORMAL", - "_NET_WM_WINDOW_TYPE_NOTIFICATION", - "_NET_WM_WINDOW_TYPE_TOOLTIP", - "_NET_WORKAREA", "Rel Horiz Wheel", "Rel Vert Wheel", "SAVE_TARGETS", - "_SCREENSAVER_STATUS", - "_SCREENSAVER_VERSION", - "scaling mode", "SELECTION_STRING", - "Tap Paused", - "TARGETS", "TARGET1", "TARGET2", + "TARGETS", "TEXT", - "text/html", - "text/plain", - "text/plain;charset=utf-8", - "text/uri-list", - "text/rtf", - "text/x-moz-url", "TIMESTAMP", "TOUCHPAD", "TOUCHSCREEN", + "Tap Paused", "Touch Timestamp", - "Undesired", "UTF8_STRING", + "Undesired", "WM_DELETE_WINDOW", "WM_PROTOCOLS", "WM_WINDOW_ROLE", @@ -227,6 +165,70 @@ "XdndSelection", "XdndStatus", "XdndTypeList", + "_CHROME_DISPLAY_INTERNAL", + "_CHROME_DISPLAY_ROTATION", + "_CHROME_DISPLAY_SCALE_FACTOR", + "_CHROMIUM_DRAG_RECEIVER", + "_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED", + "_GTK_THEME_VARIANT", + "_ICC_PROFILE", + "_MOTIF_WM_HINTS", + "_NETSCAPE_URL", + "_NET_ACTIVE_WINDOW", + "_NET_CLIENT_LIST_STACKING", + "_NET_CURRENT_DESKTOP", + "_NET_FRAME_EXTENTS", + "_NET_SUPPORTED", + "_NET_SUPPORTING_WM_CHECK", + "_NET_WM_BYPASS_COMPOSITOR", + "_NET_WM_CM_S0", + "_NET_WM_DESKTOP", + "_NET_WM_ICON", + "_NET_WM_MOVERESIZE", + "_NET_WM_NAME", + "_NET_WM_PID", + "_NET_WM_PING", + "_NET_WM_STATE", + "_NET_WM_STATE_ABOVE", + "_NET_WM_STATE_FOCUSED", + "_NET_WM_STATE_FULLSCREEN", + "_NET_WM_STATE_HIDDEN", + "_NET_WM_STATE_MAXIMIZED_HORZ", + "_NET_WM_STATE_MAXIMIZED_VERT", + "_NET_WM_STATE_SKIP_TASKBAR", + "_NET_WM_STATE_STICKY", + "_NET_WM_SYNC_REQUEST", + "_NET_WM_SYNC_REQUEST_COUNTER", + "_NET_WM_USER_TIME", + "_NET_WM_WINDOW_OPACITY", + "_NET_WM_WINDOW_TYPE", + "_NET_WM_WINDOW_TYPE_DND", + "_NET_WM_WINDOW_TYPE_MENU", + "_NET_WM_WINDOW_TYPE_NORMAL", + "_NET_WM_WINDOW_TYPE_NOTIFICATION", + "_NET_WM_WINDOW_TYPE_TOOLTIP", + "_NET_WORKAREA", + "_SCREENSAVER_STATUS", + "_SCREENSAVER_VERSION", + "application/octet-stream", + "application/vnd.chromium.test", + "chromium/filename", + "chromium/x-bookmark-entries", + "chromium/x-browser-actions", + "chromium/x-file-system-files", + "chromium/x-pepper-custom-data", + "chromium/x-renderer-taint", + "chromium/x-web-custom-data", + "chromium/x-webkit-paste", + "image/png", + "marker_event", + "scaling mode", + "text/html", + "text/plain", + "text/plain;charset=utf-8", + "text/rtf", + "text/uri-list", + "text/x-moz-url", }; constexpr int kCacheCount = base::size(kAtomsToCache);
diff --git a/ui/gfx/x/x11_atom_cache.h b/ui/gfx/x/x11_atom_cache.h index 19bebbe..cc97b5a 100644 --- a/ui/gfx/x/x11_atom_cache.h +++ b/ui/gfx/x/x11_atom_cache.h
@@ -5,9 +5,9 @@ #ifndef UI_GFX_X_X11_ATOM_CACHE_H_ #define UI_GFX_X_X11_ATOM_CACHE_H_ -#include <map> #include <string> +#include "base/containers/flat_map.h" #include "base/macros.h" #include "ui/gfx/gfx_export.h" #include "ui/gfx/x/x11_types.h" @@ -42,7 +42,7 @@ XDisplay* xdisplay_; - mutable std::map<std::string, XAtom> cached_atoms_; + mutable base::flat_map<std::string, XAtom> cached_atoms_; DISALLOW_COPY_AND_ASSIGN(X11AtomCache); };
diff --git a/ui/ozone/platform/scenic/sysmem_buffer_collection.cc b/ui/ozone/platform/scenic/sysmem_buffer_collection.cc index a34f069..344799cb 100644 --- a/ui/ozone/platform/scenic/sysmem_buffer_collection.cc +++ b/ui/ozone/platform/scenic/sysmem_buffer_collection.cc
@@ -362,7 +362,8 @@ nullptr); } - collection_->Close(); + if (collection_) + collection_->Close(); if (on_deleted_) std::move(on_deleted_).Run();
diff --git a/ui/strings/ui_strings.grd b/ui/strings/ui_strings.grd index 4a48971..d908726 100644 --- a/ui/strings/ui_strings.grd +++ b/ui/strings/ui_strings.grd
@@ -768,7 +768,7 @@ Shared from <ph name="DEVICE_NAME">$1<ex>Ted's Pixel 2</ex></ph> </message> <message name="IDS_MESSAGE_NOTIFICATION_SEND_TAB_TO_SELF_CONFIRMATION_SUCCESS" desc="The title text for the comformation notification when the user successfully share a tab to other devices."> - Sending tab... + Sending to <ph name="DEVICE_NAME">$1<ex>Ted's Pixel 2</ex></ph> </message> <message name="IDS_MESSAGE_NOTIFICATION_SEND_TAB_TO_SELF_CONFIRMATION_FAILURE_TITLE" desc="The title text for the comformation notification when the user failed to share a tab to other devices."> Failed to send
diff --git a/ui/strings/ui_strings_grd/IDS_MESSAGE_NOTIFICATION_SEND_TAB_TO_SELF_CONFIRMATION_SUCCESS.png.sha1 b/ui/strings/ui_strings_grd/IDS_MESSAGE_NOTIFICATION_SEND_TAB_TO_SELF_CONFIRMATION_SUCCESS.png.sha1 index 78cca86..1ee2c7e 100644 --- a/ui/strings/ui_strings_grd/IDS_MESSAGE_NOTIFICATION_SEND_TAB_TO_SELF_CONFIRMATION_SUCCESS.png.sha1 +++ b/ui/strings/ui_strings_grd/IDS_MESSAGE_NOTIFICATION_SEND_TAB_TO_SELF_CONFIRMATION_SUCCESS.png.sha1
@@ -1 +1 @@ -81ac47988e7b25274c7281f2ccb43b3e12f7ecfb \ No newline at end of file +54efb176961f4a490a8a9d231694b23568fe5278 \ No newline at end of file
diff --git a/ui/views/accessible_pane_view.h b/ui/views/accessible_pane_view.h index 73bb0de..d4d0c8ab 100644 --- a/ui/views/accessible_pane_view.h +++ b/ui/views/accessible_pane_view.h
@@ -35,6 +35,8 @@ // the pane was able to receive focus. virtual bool SetPaneFocus(View* initial_focus); + bool pane_has_focus() const { return pane_has_focus_; } + // Set focus to the pane with complete keyboard access, with the // focus initially set to the default child. Focus will be restored // to the last focused view if the user escapes.
diff --git a/ui/views/controls/image_view_base.cc b/ui/views/controls/image_view_base.cc index dacfde1..b9df5092b5 100644 --- a/ui/views/controls/image_view_base.cc +++ b/ui/views/controls/image_view_base.cc
@@ -61,7 +61,11 @@ } void ImageViewBase::SetAccessibleName(const base::string16& accessible_name) { + if (accessible_name_ == accessible_name) + return; + accessible_name_ = accessible_name; + OnPropertyChanged(&accessible_name_, kPropertyEffectsNone); } const base::string16& ImageViewBase::GetAccessibleName() const { @@ -153,6 +157,7 @@ METADATA_PARENT_CLASS(View) ADD_PROPERTY_METADATA(ImageViewBase, Alignment, HorizontalAlignment) ADD_PROPERTY_METADATA(ImageViewBase, Alignment, VerticalAlignment) +ADD_PROPERTY_METADATA(ImageViewBase, base::string16, AccessibleName) END_METADATA() } // namespace views
diff --git a/ui/views/metadata/metadata_macros_internal.h b/ui/views/metadata/metadata_macros_internal.h index 5c99e3a8..d29da82 100644 --- a/ui/views/metadata/metadata_macros_internal.h +++ b/ui/views/metadata/metadata_macros_internal.h
@@ -5,6 +5,8 @@ #ifndef UI_VIEWS_METADATA_METADATA_MACROS_INTERNAL_H_ #define UI_VIEWS_METADATA_METADATA_MACROS_INTERNAL_H_ +#include <utility> + #include "base/compiler_specific.h" #include "ui/views/metadata/metadata_types.h" @@ -33,15 +35,18 @@ DISALLOW_COPY_AND_ASSIGN(METADATA_CLASS_NAME_INTERNAL(class_name)); \ } -#define METADATA_PROPERTY_TYPE_INTERNAL(class_name, property_type, \ - property_name) \ - views::metadata::ClassPropertyMetaData<class_name, property_type, \ - &class_name::Set##property_name, \ - &class_name::Get##property_name> +#define METADATA_PROPERTY_TYPE_INTERNAL(class_name, property_type, \ + property_name) \ + views::metadata::ClassPropertyMetaData< \ + class_name, property_type, &class_name::Set##property_name, \ + decltype(std::declval<class_name>().Get##property_name()), \ + &class_name::Get##property_name> #define METADATA_READONLY_PROPERTY_TYPE_INTERNAL(class_name, property_type, \ property_name) \ views::metadata::ClassPropertyReadOnlyMetaData< \ - class_name, property_type, &class_name::Get##property_name> + class_name, property_type, \ + decltype(std::declval<class_name>().Get##property_name()), \ + &class_name::Get##property_name> #endif // UI_VIEWS_METADATA_METADATA_MACROS_INTERNAL_H_
diff --git a/ui/views/metadata/property_metadata.h b/ui/views/metadata/property_metadata.h index afec95e5..b3199e9 100644 --- a/ui/views/metadata/property_metadata.h +++ b/ui/views/metadata/property_metadata.h
@@ -19,7 +19,12 @@ // Represents meta data for a specific read-only property member of class // |TClass|, with underlying type |TValue|, as the type of the actual member. -template <typename TClass, typename TValue, TValue (TClass::*Get)() const> +// Using a separate |TRet| type for the getter function's return type to allow +// it to return a type with qualifier and by reference. +template <typename TClass, + typename TValue, + typename TRet, + TRet (TClass::*Get)() const> class ClassPropertyReadOnlyMetaData : public MemberMetaDataBase { public: ClassPropertyReadOnlyMetaData() {} @@ -45,9 +50,10 @@ template <typename TClass, typename TValue, void (TClass::*Set)(ArgType<TValue>), - TValue (TClass::*Get)() const> + typename TRet, + TRet (TClass::*Get)() const> class ClassPropertyMetaData - : public ClassPropertyReadOnlyMetaData<TClass, TValue, Get> { + : public ClassPropertyReadOnlyMetaData<TClass, TValue, TRet, Get> { public: ClassPropertyMetaData() {} ~ClassPropertyMetaData() override = default;
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc index fb996ff..9d57971 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
@@ -128,6 +128,12 @@ return 0; } +bool SyncSetCounter(XDisplay* display, XID counter, int64_t value) { + XSyncValue sync_value; + XSyncIntsToValue(&sync_value, value & 0xFFFFFFFF, value >> 32); + return XSyncSetCounter(display, counter, sync_value) == x11::True; +} + } // namespace //////////////////////////////////////////////////////////////////////////////// @@ -486,6 +492,13 @@ XDestroyWindow(xdisplay_, xwindow_); xwindow_ = x11::None; + if (update_counter_ != x11::None) { + XSyncDestroyCounter(xdisplay_, update_counter_); + XSyncDestroyCounter(xdisplay_, extended_update_counter_); + update_counter_ = x11::None; + extended_update_counter_ = x11::None; + } + desktop_native_widget_aura_->OnHostClosed(); } @@ -1337,6 +1350,31 @@ // the same tap-to-click disabling here that chromeos does. } +void DesktopWindowTreeHostX11::OnCompositingCompleteSwapWithNewSize( + ui::Compositor* compositor, + const gfx::Size& size) { + if (update_counter_ == x11::None) + return; + + if (configure_counter_value_is_extended_) { + if ((current_counter_value_ % 2) == 1) { + // An increase 3 means that the frame was not drawn as fast as possible. + // This can trigger different handling from the compositor. + // Setting an even number to |extended_update_counter_| will trigger a + // new resize. + current_counter_value_ += 3; + SyncSetCounter(xdisplay_, extended_update_counter_, + current_counter_value_); + } + return; + } + + if (configure_counter_value_ != 0) { + SyncSetCounter(xdisplay_, update_counter_, configure_counter_value_); + configure_counter_value_ = 0; + } +} + //////////////////////////////////////////////////////////////////////////////// // DesktopWindowTreeHostX11, display::DisplayObserver implementation: @@ -1476,10 +1514,27 @@ // TODO(erg): We currently only request window deletion events. We also // should listen for activation events and anything else that GTK+ listens // for, and do something useful. - XAtom protocols[2]; - protocols[0] = gfx::GetAtom("WM_DELETE_WINDOW"); - protocols[1] = gfx::GetAtom("_NET_WM_PING"); - XSetWMProtocols(xdisplay_, xwindow_, protocols, 2); + // Request the _NET_WM_SYNC_REQUEST protocol which is used for synchronizing + // between chrome and desktop compositor (or WM) during resizing. + // The resizing behavior with _NET_WM_SYNC_REQUEST is: + // 1. Desktop compositor (or WM) sends client message _NET_WM_SYNC_REQUEST + // with a 64 bits counter to notify about an incoming resize. + // 2. Desktop compositor resizes chrome browser window. + // 3. Desktop compositor waits on an alert on value change of XSyncCounter on + // chrome window. + // 4. Chrome handles the ConfigureNotify event, and renders a new frame with + // the new size. + // 5. Chrome increases the XSyncCounter on chrome window + // 6. Desktop compositor gets the alert of counter change, and draws a new + // frame with new content from chrome. + // 7. Desktop compositor responses user mouse move events, and starts a new + // resize process, go to step 1. + XAtom protocols[] = { + gfx::GetAtom("WM_DELETE_WINDOW"), + gfx::GetAtom("_NET_WM_PING"), + gfx::GetAtom("_NET_WM_SYNC_REQUEST"), + }; + XSetWMProtocols(xdisplay_, xwindow_, protocols, base::size(protocols)); // We need a WM_CLIENT_MACHINE and WM_LOCALE_NAME value so we integrate with // the desktop environment. @@ -1566,6 +1621,24 @@ kDarkGtkThemeVariant, base::size(kDarkGtkThemeVariant) - 1); } + if (ui::IsSyncExtensionAvailable()) { + XSyncValue value; + XSyncIntToValue(&value, 0); + update_counter_ = XSyncCreateCounter(xdisplay_, value); + extended_update_counter_ = XSyncCreateCounter(xdisplay_, value); + XID counters[2] = { + update_counter_, + extended_update_counter_, + }; + + // Set XSyncCounter as window property _NET_WM_SYNC_REQUEST_COUNTER. the + // compositor will listen on them during resizing. + XChangeProperty( + xdisplay_, xwindow_, gfx::GetAtom("_NET_WM_SYNC_REQUEST_COUNTER"), + XA_CARDINAL, 32, PropModeReplace, + reinterpret_cast<const unsigned char*>(counters), base::size(counters)); + } + // Always composite Chromium windows if a compositing WM is used. Sometimes, // WMs will not composite fullscreen windows as an optimization, but this can // lead to tearing of fullscreen videos. @@ -2077,6 +2150,11 @@ case ConfigureNotify: { DCHECK_EQ(xwindow_, xev->xconfigure.window); DCHECK_EQ(xwindow_, xev->xconfigure.event); + + configure_counter_value_ = pending_counter_value_; + configure_counter_value_is_extended_ = pending_counter_value_is_extended_; + pending_counter_value_ = 0; + // It's possible that the X window may be resized by some other means than // from within aura (e.g. the X window manager can change the size). Make // sure the root window size is maintained properly. @@ -2239,6 +2317,11 @@ XSendEvent(xdisplay_, reply_event.xclient.window, x11::False, SubstructureRedirectMask | SubstructureNotifyMask, &reply_event); + } else if (protocol == gfx::GetAtom("_NET_WM_SYNC_REQUEST")) { + pending_counter_value_ = + xev->xclient.data.l[2] + + (static_cast<int64_t>(xev->xclient.data.l[3]) << 32); + pending_counter_value_is_extended_ = xev->xclient.data.l[4] != 0; } } else if (message_type == gfx::GetAtom("XdndEnter")) { drag_drop_client_->OnXdndEnter(xev->xclient); @@ -2315,6 +2398,15 @@ } void DesktopWindowTreeHostX11::DelayedResize(const gfx::Size& size_in_pixels) { + if (configure_counter_value_is_extended_ && + (current_counter_value_ % 2) == 0) { + // Increase the |extended_update_counter_|, so the compositor will know we + // are not frozen and re-enable _NET_WM_SYNC_REQUEST, if it was disabled. + // Increase the |extended_update_counter_| to an odd number will not trigger + // a new resize. + SyncSetCounter(xdisplay_, extended_update_counter_, + ++current_counter_value_); + } OnHostResizedInPixels(size_in_pixels); ResetWindowRegion(); delayed_resize_task_.Cancel(); @@ -2363,11 +2455,30 @@ } void DesktopWindowTreeHostX11::RestartDelayedResizeTask() { - delayed_resize_task_.Reset(base::BindOnce( - &DesktopWindowTreeHostX11::DelayedResize, - close_widget_factory_.GetWeakPtr(), bounds_in_pixels_.size())); - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, delayed_resize_task_.callback()); + if (update_counter_ == x11::None || configure_counter_value_ == 0) { + // WM doesn't support _NET_WM_SYNC_REQUEST. + // Or we are too slow, so _NET_WM_SYNC_REQUEST is disabled by the + // compositor. + delayed_resize_task_.Reset(base::BindOnce( + &DesktopWindowTreeHostX11::DelayedResize, + close_widget_factory_.GetWeakPtr(), bounds_in_pixels_.size())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, delayed_resize_task_.callback()); + return; + } + + if (configure_counter_value_is_extended_) { + current_counter_value_ = configure_counter_value_; + configure_counter_value_ = 0; + // Make sure the counter is even number. + if ((current_counter_value_ % 2) == 1) + ++current_counter_value_; + } + + // If _NET_WM_SYNC_REQUEST is used to synchronize with compositor during + // resizing, the compositor will not resize the window, until last resize is + // handled, so we don't need accumulate resize events. + DelayedResize(bounds_in_pixels_.size()); } aura::Window* DesktopWindowTreeHostX11::content_window() {
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h index 593cdfb..a855397 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
@@ -180,6 +180,8 @@ void MoveCursorToScreenLocationInPixels( const gfx::Point& location_in_pixels) override; void OnCursorVisibilityChangedNative(bool show) override; + void OnCompositingCompleteSwapWithNewSize(ui::Compositor* compositor, + const gfx::Size& size) override; // Overridden from display::DisplayObserver via aura::WindowTreeHost: void OnDisplayMetricsChanged(const display::Display& display, @@ -461,6 +463,16 @@ uint32_t modal_dialog_counter_ = 0; + // Used for synchronizing between |xwindow_| between desktop compositor during + // resizing. + XID update_counter_ = x11::None; + XID extended_update_counter_ = x11::None; + int64_t pending_counter_value_ = 0; + int64_t configure_counter_value_ = 0; + int64_t current_counter_value_ = 0; + bool pending_counter_value_is_extended_ = false; + bool configure_counter_value_is_extended_ = false; + base::WeakPtrFactory<DesktopWindowTreeHostX11> close_widget_factory_{this}; base::WeakPtrFactory<DesktopWindowTreeHostX11> weak_factory_{this};
diff --git a/ui/webui/resources/cr_components/certificate_manager/certificate_manager.html b/ui/webui/resources/cr_components/certificate_manager/certificate_manager.html index 77b6860..10ffddf 100644 --- a/ui/webui/resources/cr_components/certificate_manager/certificate_manager.html +++ b/ui/webui/resources/cr_components/certificate_manager/certificate_manager.html
@@ -1,13 +1,12 @@ <link rel="import" href="chrome://resources/html/polymer.html"> +<link rel="import" href="chrome://resources/cr_elements/cr_tabs/cr_tabs.html"> <link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/paper_tabs_style_css.html"> <link rel="import" href="chrome://resources/html/assert.html"> <link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html"> <link rel="import" href="chrome://resources/html/i18n_behavior.html"> <link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-pages/iron-pages.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-tabs/paper-tabs.html"> <link rel="import" href="ca_trust_edit_dialog.html"> <link rel="import" href="certificate_delete_confirmation_dialog.html"> <link rel="import" href="certificate_list.html"> @@ -19,10 +18,10 @@ <dom-module id="certificate-manager"> <template> - <style include="cr-hidden-style paper-tabs-style"> - paper-tabs { - font-size: inherit; - height: 40px; + <style include="cr-hidden-style"> + cr-tabs { + --cr-tabs-font-size: inherit; + --cr-tabs-height: 40px; margin-bottom: 24px; } </style> @@ -51,14 +50,7 @@ </certificates-error-dialog> </template> - <paper-tabs noink selected="{{selected}}"> - <paper-tab>[[i18n('certificateManagerYourCertificates')]]</paper-tab> - <paper-tab hidden="[[isKiosk_]]">[[i18n('certificateManagerServers')]] - </paper-tab> - <paper-tab hidden="[[isKiosk_]]">[[i18n('certificateManagerAuthorities')]] - </paper-tab> - <paper-tab>[[i18n('certificateManagerOthers')]]</paper-tab> - </paper-tabs> + <cr-tabs selected="{{selected}}" tab-names="[[tabNames_]]"></cr-tabs> <iron-pages selected="[[selected]]"> <div> <certificate-list id="personalCerts"
diff --git a/ui/webui/resources/cr_components/certificate_manager/certificate_manager.js b/ui/webui/resources/cr_components/certificate_manager/certificate_manager.js index c0297fb..72d0ed9 100644 --- a/ui/webui/resources/cr_components/certificate_manager/certificate_manager.js +++ b/ui/webui/resources/cr_components/certificate_manager/certificate_manager.js
@@ -115,6 +115,12 @@ loadTimeData.getBoolean('isKiosk'); }, }, + + /** @private {!Array<string>} */ + tabNames_: { + type: Array, + computed: 'computeTabNames_(isKiosk_)', + }, }, /** @override */ @@ -214,4 +220,21 @@ }); }); }, + + /** + * @return {!Array<string>} + * @private + */ + computeTabNames_: function() { + return [ + loadTimeData.getString('certificateManagerYourCertificates'), + ...(this.isKiosk_ ? + [] : + [ + loadTimeData.getString('certificateManagerServers'), + loadTimeData.getString('certificateManagerAuthorities'), + ]), + loadTimeData.getString('certificateManagerOthers'), + ]; + }, });
diff --git a/ui/webui/resources/cr_elements/cr_tabs/cr_tabs.html b/ui/webui/resources/cr_elements/cr_tabs/cr_tabs.html index c0b077d..19e6fbb 100644 --- a/ui/webui/resources/cr_elements/cr_tabs/cr_tabs.html +++ b/ui/webui/resources/cr_elements/cr_tabs/cr_tabs.html
@@ -72,13 +72,8 @@ transition-timing-function: cubic-bezier(0, 0, .2, 1); } </style> - <template is="dom-repeat" items="[[tabNames]]" - on-dom-change="updateSelectionBar_"> - <div class$="tab [[getCssClass_(index, selected)]]" role="tab" - aria-selected$="[[getAriaSelected_(index, selected)]]" - tabindex$="[[getTabIndex_(index, selected)]]" on-click="onTabClick_"> - [[item]] - </div> + <template is="dom-repeat" items="[[tabNames]]" on-dom-change="updateUi_"> + <div class="tab" role="tab" on-click="onTabClick_">[[item]]</div> </template> <div id="selectionBar"></div> </template>
diff --git a/ui/webui/resources/cr_elements/cr_tabs/cr_tabs.js b/ui/webui/resources/cr_elements/cr_tabs/cr_tabs.js index be0ca2c..5e63d0a0 100644 --- a/ui/webui/resources/cr_elements/cr_tabs/cr_tabs.js +++ b/ui/webui/resources/cr_elements/cr_tabs/cr_tabs.js
@@ -36,7 +36,7 @@ selected: { type: Number, notify: true, - observer: 'updateSelectionBar_', + observer: 'updateUi_', }, }, @@ -60,33 +60,6 @@ }, /** - * @param {number} index - * @return {string} - * @private - */ - getAriaSelected_: function(index) { - return this.selected == index ? 'true' : 'false'; - }, - - /** - * @param {number} index - * @return {string} - * @private - */ - getCssClass_: function(index) { - return this.selected == index ? 'selected' : ''; - }, - - /** - * @param {number} index - * @return {number} - * @private - */ - getTabIndex_: function(index) { - return this.selected == index ? 0 : -1; - }, - - /** * @param {!KeyboardEvent} e * @private */ @@ -122,7 +95,7 @@ * @param {number} width * @private */ - transformSelectionBar_: function(left, width) { + updateSelectionBar_: function(left, width) { const containerWidth = this.offsetWidth; const leftPercent = 100 * left / containerWidth; const widthRatio = width / containerWidth; @@ -131,38 +104,59 @@ }, /** @private */ - updateSelectionBar_: function() { - const selectedTab = this.$$('.selected'); - if (!selectedTab) { + updateUi_: function() { + const tabs = this.shadowRoot.querySelectorAll('.tab'); + // Tabs are not rendered yet by dom-repeat. Skip this update since + // dom-repeat will fire a dom-change event when it is ready. + if (tabs.length == 0) { return; } - selectedTab.focus(); + tabs.forEach((tab, i) => { + const isSelected = this.selected == i; + if (isSelected) { + tab.focus(); + } + tab.classList.toggle('selected', isSelected); + tab.setAttribute('aria-selected', isSelected); + tab.setAttribute('tabindex', isSelected ? 0 : -1); + }); + + if (this.selected == undefined) { + return; + } + this.$.selectionBar.classList.remove('expand', 'contract'); - const {offsetLeft: selectedLeft, offsetWidth: selectedWidth} = selectedTab; const oldValue = this.lastSelected_; this.lastSelected_ = this.selected; // If there is no previously selected tab or the tab has not changed, // underline the selected tab instantly. if (oldValue == null || oldValue == this.selected) { - this.transformSelectionBar_(selectedLeft, selectedWidth); + // When handling the initial 'dom-change' event, it's possible for the + // selected tab to exist and not yet be fully rendered. This will result + // in the selection bar not rendering correctly. + setTimeout(() => { + const {offsetLeft, offsetWidth} = tabs[this.selected]; + this.updateSelectionBar_(offsetLeft, offsetWidth); + }); return; } + const {offsetLeft: newLeft, offsetWidth: newWidth} = tabs[this.selected]; + const {offsetLeft: oldLeft, offsetWidth: oldWidth} = tabs[oldValue]; + // Expand bar to underline the last selected tab, the newly selected tab and // everything in between. After expansion is complete, contract bar to // underline the selected tab. this.$.selectionBar.classList.add('expand'); this.$.selectionBar.addEventListener('transitionend', () => { this.$.selectionBar.classList.replace('expand', 'contract'); - this.transformSelectionBar_(selectedLeft, selectedWidth); + this.updateSelectionBar_(newLeft, newWidth); }, {once: true}); - const {offsetLeft: lastLeft, offsetWidth: lastWidth} = - this.$$(`.tab:nth-of-type(${oldValue + 1})`); - const left = Math.min(selectedLeft, lastLeft); - const right = Math.max(selectedLeft + selectedWidth, lastLeft + lastWidth); - this.transformSelectionBar_(left, right - left); + const left = Math.min(newLeft, oldLeft); + const right = Math.max(newLeft + newWidth, oldLeft + oldWidth); + this.updateSelectionBar_(left, right - left); }, });
diff --git a/ui/wm/core/window_animations.cc b/ui/wm/core/window_animations.cc index d61a35a..2d5b023 100644 --- a/ui/wm/core/window_animations.cc +++ b/ui/wm/core/window_animations.cc
@@ -491,6 +491,8 @@ observer->SetLastSequence(last_sequence); observer->DetachAndRecreateLayers(); } + + window->layer()->SetVisible(show); } void AnimateShowWindow_Rotate(aura::Window* window) {