diff --git a/DEPS b/DEPS index 789f0d8..b381a79 100644 --- a/DEPS +++ b/DEPS
@@ -234,11 +234,11 @@ # 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': 'f1660bf1baecb787f5d541c1973f2c7f2ded13dd', + 'skia_revision': '688cb15faa641680346f7510bbf6e5d77053bc0e', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. - 'v8_revision': '1a4ea6de5ad3d3303d5fad4d3b390d3a618795d6', + 'v8_revision': '99489318d40626fb10047f33c4f7fd893fd89bc9', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. @@ -265,7 +265,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling googletest # and whatever else without interference from each other. - 'googletest_revision': '1b18723e874b256c1e39378c6774a90701d70f7a', + 'googletest_revision': '1a3e2a265f35e604378156cd675b11ef0a184627', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling lighttpd # and whatever else without interference from each other. @@ -349,7 +349,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'dawn_revision': '8ce15b3ce97efbb175ba67ae1df9a10cdc3ea4af', + 'dawn_revision': '4b7ba255c3a62edb99182f17a3de7c77720313fd', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -397,7 +397,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'libunwind_revision': '51ffc5ed5cd9f28b064434bf2e55e1b6bb139a21', + 'libunwind_revision': '7f068e554e0405da7759c315fdc5e1ae956bb19c', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -791,7 +791,7 @@ 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'wnPOPNFDdq5pVsm7Lj0o7NWefxqLo5x-WUBlmrrO9_0C', + 'version': 'KaJVIPBjh2qbCob6hsVzLk1brSl4iuZVYNpUH0sgg20C', }, ], 'condition': 'checkout_android', @@ -1030,14 +1030,11 @@ }, 'src/third_party/depot_tools': - Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '64cb3ee4cddbb44a7fa474a8f08cff4d52897181', + Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '176a9e8764598a6da911e6be2fd12e46def8d6f5', 'src/third_party/devtools-frontend/src': Var('chromium_git') + '/devtools/devtools-frontend' + '@' + Var('devtools_frontend_revision'), - 'src/third_party/distributed_point_functions/src': - Var('chromium_git') + '/external/github.com/google/distributed_point_functions.git' + '@' + 'ea175a91e6eda5b22392fdae82080eb9709cd0eb', - 'src/third_party/dom_distiller_js/dist': Var('chromium_git') + '/chromium/dom-distiller/dist.git' + '@' + 'f339eb9463714c3d31657c8ee1bd53d1c7e5c555', @@ -1695,7 +1692,7 @@ Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@513581ec6efd484d480f32d702d12234168c2338', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@8e7e2748ffff032f17357340acccfa37a8f10364', 'condition': 'checkout_src_internal', },
diff --git a/android_webview/docs/test-instructions.md b/android_webview/docs/test-instructions.md index 9bb9232..82a97b7 100644 --- a/android_webview/docs/test-instructions.md +++ b/android_webview/docs/test-instructions.md
@@ -93,15 +93,16 @@ `//android_webview/tools/system_webview_shell/`. *** note -**Important:** because these tests run against the WebView installed on the -system, both these test targets automatically compile and install -`system_webview_apk` and switch the WebView provider. This means you need to -configure this target to be compatible with your system by following the -[full build instructions](build-instructions.md). +**Important:** these tests compile and install both `system_webview_apk` and +`system_webview_shell_apk`. -**Note:** we do not currently support running these tests on the emulator due to -signing key mismatches with the preinstalled WebView shell -(https://crbug.com/1205665 tracks supporting this). +You will need to configure GN args to make sure `system_webview_apk` is a valid +WebView provider for your system. Please see the [full build +instructions](build-instructions.md). + +If you are using an **emulator**, you will also need to configure the +`system_webview_shell_package_name` GN arg. See [WebView shell +docs](webview-shell.md#setting-up-the-build) for details. *** ```sh
diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java index 3ce9a05..7a33684f 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java
@@ -442,7 +442,7 @@ if (mPictureListener != null) { PostTask.postDelayedTask(UiThreadTaskTraits.DEFAULT, () -> { if (mPictureListener != null) { - if (TRACE) Log.i(TAG, "onPageFinished-fake"); + if (TRACE) Log.i(TAG, "onNewPicture - from onPageFinished workaround."); mPictureListener.onNewPicture( mWebView, mPictureListenerInvalidateOnly ? null : new Picture()); }
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java index 14bd819..9ea6cfe9 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -2242,7 +2242,7 @@ } public void setBackgroundColor(int color) { - if (TRACE) Log.i(TAG, "%s setBackgroundColor=%d", this, color); + if (TRACE) Log.i(TAG, "%s setBackgroundColor=%x", this, color); mBaseBackgroundColor = color; mDidInitBackground = true; if (!isDestroyed(WARN)) { @@ -3121,7 +3121,9 @@ public void onConfigurationChanged(Configuration newConfig) { if (TRACE) Log.i(TAG, "%s onConfigurationChanged", this); mAwViewMethods.onConfigurationChanged(newConfig); - AwContentsJni.get().onConfigurationChanged(mNativeAwContents); + if (!isDestroyed(NO_WARN)) { + AwContentsJni.get().onConfigurationChanged(mNativeAwContents); + } } /**
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java index de2f8930..4c1f61e 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java
@@ -2562,11 +2562,10 @@ } } - // Test an assert URL (file:///android_asset/) + // Test an Android asset URL (file:///android_asset/) @Test @SmallTest @Feature({"AndroidWebView", "Navigation"}) - @DisabledTest(message = "https://crbug.com/1144938") public void testAssetUrl() throws Throwable { // Note: this text needs to be kept in sync with the contents of the html file referenced // below. @@ -2580,7 +2579,7 @@ Assert.assertEquals(expectedTitle, mActivityTestRule.getTitleOnUiThread(awContents)); } - // Test a resource URL (file:///android_res/). + // Test an Android resource URL (file:///android_res/). @Test @SmallTest @Feature({"AndroidWebView", "Navigation"})
diff --git a/android_webview/tools/system_webview_shell/BUILD.gn b/android_webview/tools/system_webview_shell/BUILD.gn index eb02524..0a955e5 100644 --- a/android_webview/tools/system_webview_shell/BUILD.gn +++ b/android_webview/tools/system_webview_shell/BUILD.gn
@@ -26,6 +26,8 @@ system_webview_shell_android_manifest = "$root_gen_dir/android_webview/system_webview_shell_apk/AndroidManifest.xml" +layout_tests_android_manifest = "$root_gen_dir/android_webview/system_webview_shell_apk/layout_tests/AndroidManifest.xml" +page_cycler_tests_android_manifest = "$root_gen_dir/android_webview/system_webview_shell_apk/page_cycler/AndroidManifest.xml" android_apk("system_webview_shell_apk") { apk_name = "SystemWebViewShell" @@ -75,6 +77,18 @@ variables = [ "manifest_package=$system_webview_shell_package_name" ] } +jinja_template("layout_tests_manifest") { + input = "layout_tests/AndroidManifest.xml" + output = layout_tests_android_manifest + variables = [ "target_package=$system_webview_shell_package_name" ] +} + +jinja_template("page_cycler_tests_manifest") { + input = "page_cycler/AndroidManifest.xml" + output = page_cycler_tests_android_manifest + variables = [ "target_package=$system_webview_shell_package_name" ] +} + android_resources("system_webview_shell_apk_resources") { sources = [ "apk/res/drawable-mdpi/breadcrumb_arrow_black.png", @@ -100,7 +114,8 @@ instrumentation_test_apk("system_webview_shell_page_cycler_apk") { apk_name = "SystemWebViewShellPageCycler" apk_under_test = ":system_webview_shell_apk" - android_manifest = "page_cycler/AndroidManifest.xml" + android_manifest = page_cycler_tests_android_manifest + android_manifest_dep = ":page_cycler_tests_manifest" sources = [ "page_cycler/src/org/chromium/webview_shell/page_cycler/PageCyclerTest.java" ] deps = [ ":system_webview_shell_apk_java", @@ -118,7 +133,8 @@ instrumentation_test_apk("system_webview_shell_layout_test_apk") { apk_name = "SystemWebViewShellLayoutTest" apk_under_test = ":system_webview_shell_apk" - android_manifest = "layout_tests/AndroidManifest.xml" + android_manifest = layout_tests_android_manifest + android_manifest_dep = ":layout_tests_manifest" sources = [ "layout_tests/src/org/chromium/webview_shell/test/WebPlatformTestsActivityTest.java", "layout_tests/src/org/chromium/webview_shell/test/WebViewLayoutTest.java",
diff --git a/android_webview/tools/system_webview_shell/layout_tests/AndroidManifest.xml b/android_webview/tools/system_webview_shell/layout_tests/AndroidManifest.xml index 8147ad1..9333644a 100644 --- a/android_webview/tools/system_webview_shell/layout_tests/AndroidManifest.xml +++ b/android_webview/tools/system_webview_shell/layout_tests/AndroidManifest.xml
@@ -29,6 +29,7 @@ </application> <instrumentation android:name="org.chromium.base.test.BaseChromiumAndroidJUnitRunner" - android:targetPackage="org.chromium.webview_shell" + android:targetPackage="{{target_package|default('org.chromium.webview_shell')}}" android:label="Layout tests for org.chromium.webview_shell"/> + </manifest>
diff --git a/android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewLayoutTest.java b/android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewLayoutTest.java index 69e95ce..bd4a105 100644 --- a/android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewLayoutTest.java +++ b/android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewLayoutTest.java
@@ -245,7 +245,6 @@ @Test @MediumTest - @DisabledTest(message = "crbug.com/1266967") public void testRequestMIDIAccess() throws Exception { runWebViewLayoutTest("blink-apis/webmidi/requestmidiaccess.html", "blink-apis/webmidi/requestmidiaccess-expected.txt");
diff --git a/android_webview/tools/system_webview_shell/page_cycler/AndroidManifest.xml b/android_webview/tools/system_webview_shell/page_cycler/AndroidManifest.xml index eb5ca7d..66b2e62 100644 --- a/android_webview/tools/system_webview_shell/page_cycler/AndroidManifest.xml +++ b/android_webview/tools/system_webview_shell/page_cycler/AndroidManifest.xml
@@ -18,6 +18,6 @@ <uses-permission android:name="android.permission.READ_LOGS"/> <instrumentation android:name="org.chromium.base.test.BaseChromiumAndroidJUnitRunner" - android:targetPackage="org.chromium.webview_shell" + android:targetPackage="{{target_package|default('org.chromium.webview_shell')}}" android:label="Page cycler for org.chromium.webview_shell"/> </manifest>
diff --git a/android_webview/tools/system_webview_shell/test/data/blink-apis/webmidi/requestmidiaccess-expected.txt b/android_webview/tools/system_webview_shell/test/data/blink-apis/webmidi/requestmidiaccess-expected.txt index d84035c..de2d598e 100644 --- a/android_webview/tools/system_webview_shell/test/data/blink-apis/webmidi/requestmidiaccess-expected.txt +++ b/android_webview/tools/system_webview_shell/test/data/blink-apis/webmidi/requestmidiaccess-expected.txt
@@ -1,5 +1,4 @@ Test navigator.requestMIDIAccess API in WebView -Web MIDI will ask a permission to use even if the sysex is not specified in the MIDIOptions since around M82, around May 2020. See https://www.chromestatus.com/feature/5138066234671104 for more details. PASS: access.sysexEnabled is false PASS: requestMIDIAccess without option succeeded. TEST FINISHED
diff --git a/ash/BUILD.gn b/ash/BUILD.gn index b6526a3..6bf8776c 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn
@@ -905,8 +905,6 @@ "style/element_style.h", "style/highlight_border.cc", "style/highlight_border.h", - "style/icon_button.cc", - "style/icon_button.h", "style/pill_button.cc", "style/pill_button.h", "style/scoped_light_mode_as_default.cc", @@ -1520,6 +1518,8 @@ "system/unified/page_indicator_view.h", "system/unified/quiet_mode_feature_pod_controller.cc", "system/unified/quiet_mode_feature_pod_controller.h", + "system/unified/top_shortcut_button.cc", + "system/unified/top_shortcut_button.h", "system/unified/top_shortcuts_view.cc", "system/unified/top_shortcuts_view.h", "system/unified/unified_notifier_settings_controller.cc",
diff --git a/ash/app_list/views/continue_section_view.cc b/ash/app_list/views/continue_section_view.cc index f0956071..c2464ef 100644 --- a/ash/app_list/views/continue_section_view.cc +++ b/ash/app_list/views/continue_section_view.cc
@@ -40,7 +40,7 @@ // Suggested tasks layout constants. Should this change, we should update the // Layout to leave out empty rows. -constexpr int kMinFilesForContinueSection = 3; +constexpr size_t kMinFilesForContinueSection = 3; std::unique_ptr<views::Label> CreateContinueLabel(const std::u16string& text) { auto label = std::make_unique<views::Label>(text); @@ -61,7 +61,9 @@ views::BoxLayout::Orientation::kVertical, gfx::Insets(kSectionVerticalPadding, kSectionHorizontalPadding), kHeaderVerticalSpacing)); - layout->set_main_axis_alignment(views::BoxLayout::MainAxisAlignment::kStart); + layout->set_main_axis_alignment( + tablet_mode ? views::BoxLayout::MainAxisAlignment::kCenter + : views::BoxLayout::MainAxisAlignment::kStart); layout->set_cross_axis_alignment( views::BoxLayout::CrossAxisAlignment::kStretch); @@ -94,7 +96,7 @@ } size_t ContinueSectionView::GetTasksSuggestionsCount() const { - return static_cast<size_t>(suggestions_container_->num_results()); + return suggestions_container_->num_results(); } void ContinueSectionView::DisableFocusForShowingActiveFolder(bool disabled) {
diff --git a/ash/app_list/views/continue_section_view_unittest.cc b/ash/app_list/views/continue_section_view_unittest.cc index 0f08fc9..7e6ad7a 100644 --- a/ash/app_list/views/continue_section_view_unittest.cc +++ b/ash/app_list/views/continue_section_view_unittest.cc
@@ -55,6 +55,8 @@ void SetUp() override { AshTestBase::SetUp(); } ContinueSectionView* GetContinueSectionView() { + if (Shell::Get()->tablet_mode_controller()->InTabletMode()) + return GetAppListTestHelper()->GetFullscreenContinueSectionView(); return GetAppListTestHelper()->GetBubbleContinueSectionView(); } @@ -307,7 +309,18 @@ RemoveSearchResultAt(3); VerifyResultViewsUpdated(); - EXPECT_FALSE(continue_task_view->IsMenuShowing()); + ASSERT_EQ(std::vector<std::string>({"id1", "id2", "id3"}), GetResultIds()); + + // Click on another result and verify it activates the item to confirm the + // event is not consumed by a context menu. + EXPECT_EQ(GetResultViewAt(0)->result()->id(), "id1"); + GetEventGenerator()->MoveMouseTo( + GetResultViewAt(0)->GetBoundsInScreen().CenterPoint()); + GetEventGenerator()->ClickLeftButton(); + + // The item was activated. + TestAppListClient* client = GetAppListTestHelper()->app_list_client(); + EXPECT_EQ("id1", client->last_opened_search_result()); } TEST_F(ContinueSectionViewTest, UpdateAppsOnModelChange) { @@ -351,5 +364,50 @@ EXPECT_EQ(std::vector<std::string>{}, GetResultIds()); } +TEST_F(ContinueSectionViewTest, TabletModeLayoutWithThreeSuggestions) { + AddSearchResult("id1", AppListSearchResultType::kFileChip); + AddSearchResult("id2", AppListSearchResultType::kDriveChip); + AddSearchResult("id3", AppListSearchResultType::kDriveChip); + + Shell::Get()->tablet_mode_controller()->SetEnabledForTest(true); + VerifyResultViewsUpdated(); + + ASSERT_TRUE(GetContinueSectionView()->GetVisible()); + ASSERT_EQ(3u, GetContinueSectionView()->GetTasksSuggestionsCount()); + + const int width = GetResultViewAt(0)->width(); + const int vertical_position = GetResultViewAt(0)->y(); + + for (int i = 1; i < 3; i++) { + EXPECT_EQ(width, GetResultViewAt(i)->width()); + EXPECT_EQ(vertical_position, GetResultViewAt(i)->y()); + EXPECT_GT(GetResultViewAt(i)->x(), + GetResultViewAt(i - 1)->bounds().right()); + } +} + +TEST_F(ContinueSectionViewTest, TabletModeLayoutWithFourSuggestions) { + AddSearchResult("id1", AppListSearchResultType::kFileChip); + AddSearchResult("id2", AppListSearchResultType::kDriveChip); + AddSearchResult("id3", AppListSearchResultType::kDriveChip); + AddSearchResult("id4", AppListSearchResultType::kFileChip); + + Shell::Get()->tablet_mode_controller()->SetEnabledForTest(true); + VerifyResultViewsUpdated(); + + ASSERT_TRUE(GetContinueSectionView()->GetVisible()); + ASSERT_EQ(4u, GetContinueSectionView()->GetTasksSuggestionsCount()); + + const int width = GetResultViewAt(0)->width(); + const int vertical_position = GetResultViewAt(0)->y(); + + for (int i = 1; i < 4; i++) { + EXPECT_EQ(width, GetResultViewAt(i)->width()); + EXPECT_EQ(vertical_position, GetResultViewAt(i)->y()); + EXPECT_GT(GetResultViewAt(i)->x(), + GetResultViewAt(i - 1)->bounds().right()); + } +} + } // namespace } // namespace ash
diff --git a/ash/app_list/views/continue_task_container_view.cc b/ash/app_list/views/continue_task_container_view.cc index 562387db..24555d9 100644 --- a/ash/app_list/views/continue_task_container_view.cc +++ b/ash/app_list/views/continue_task_container_view.cc
@@ -20,13 +20,15 @@ #include "ui/views/border.h" #include "ui/views/controls/label.h" #include "ui/views/layout/box_layout.h" +#include "ui/views/layout/flex_layout.h" #include "ui/views/layout/table_layout.h" +using views::BoxLayout; +using views::FlexLayout; +using views::TableLayout; + namespace ash { namespace { -// Suggested tasks padding in dips -constexpr int kSuggestedTasksHorizontalPadding = 6; - // Suggested tasks layout constants. constexpr int kColumnSpacingClamshell = 8; constexpr int kColumnSpacingTablet = 16; @@ -67,39 +69,16 @@ int columns, OnResultsChanged update_callback, bool tablet_mode) - : view_delegate_(view_delegate), update_callback_(update_callback) { + : view_delegate_(view_delegate), + update_callback_(update_callback), + tablet_mode_(tablet_mode) { DCHECK(!update_callback_.is_null()); - SetBorder(views::CreateEmptyBorder( - gfx::Insets(0, kSuggestedTasksHorizontalPadding))); - - auto* layout = SetLayoutManager(std::make_unique<views::TableLayout>()); - for (int i = 0; i < columns; i++) { - if (i > 0) { - layout->AddPaddingColumn( - views::TableLayout::kFixedSize, - tablet_mode ? kColumnSpacingTablet : kColumnSpacingClamshell); - } - layout->AddColumn( - views::LayoutAlignment::kStretch, views::LayoutAlignment::kCenter, - /*resize_percent=*/1.0f, views::TableLayout::ColumnSize::kUsePreferred, - /*fixed_width=*/0, /*min_width=*/0); - } - - for (size_t i = 0; i < kMaxFilesForContinueSection; ++i) { - if (i % columns == 0) { - if (i > 0) - layout->AddPaddingRow(views::TableLayout::kFixedSize, kRowSpacing); - layout->AddRows(1, views::TableLayout::kFixedSize); - } - ContinueTaskView* task = AddChildView( - std::make_unique<ContinueTaskView>(view_delegate, tablet_mode)); - // This view has a predefined number of placeholder tasks views which toggle - // visibility depending on the result being null or not. The container's - // visibility is handled on the parent view. - task->SetVisible(false); - task->set_index_in_container(i); - suggestion_tasks_views_.emplace_back(task); + if (tablet_mode_) { + InitializeFlexLayout(); + } else { + columns_ = columns; + InitializeTableLayout(); } } @@ -128,10 +107,18 @@ std::vector<SearchResult*> tasks = GetTasksResultsForContinueSection(results_); - // Update search results here. - for (size_t i = 0; i < suggestion_tasks_views_.size(); ++i) { - suggestion_tasks_views_[i]->SetResult(i < tasks.size() ? tasks[i] - : nullptr); + RemoveAllChildViews(); + suggestion_tasks_views_.clear(); + num_results_ = std::min(kMaxFilesForContinueSection, tasks.size()); + + for (size_t i = 0; i < num_results_; ++i) { + auto task = + std::make_unique<ContinueTaskView>(view_delegate_, tablet_mode_); + task->set_index_in_container(i); + task->SetResult(tasks[i]); + suggestion_tasks_views_.emplace_back(task.get()); + MaybeAddNewRowToLayout(i); + AddChildView(std::move(task)); } auto* notifier = view_delegate_->GetNotifier(); @@ -139,10 +126,9 @@ std::vector<AppListNotifier::Result> notifier_results; for (const auto* task : tasks) notifier_results.emplace_back(task->id(), task->metrics_type()); - notifier->NotifyResultsUpdated(SearchResultDisplayType::kChip, + notifier->NotifyResultsUpdated(SearchResultDisplayType::kList, notifier_results); } - num_results_ = std::min(kMaxFilesForContinueSection, tasks.size()); if (!update_callback_.is_null()) update_callback_.Run(); } @@ -174,6 +160,56 @@ } } +void ContinueTaskContainerView::MaybeAddNewRowToLayout(int task_index) { + if (!table_layout_) + return; + + // Only adds a new row if the columns have been filled by previous views. + if (task_index % columns_) + return; + + if (task_index > 0) + table_layout_->AddPaddingRow(views::TableLayout::kFixedSize, kRowSpacing); + table_layout_->AddRows(1, views::TableLayout::kFixedSize); +} + +void ContinueTaskContainerView::InitializeFlexLayout() { + DCHECK(tablet_mode_); + DCHECK(!table_layout_); + DCHECK(!columns_); + + flex_layout_ = SetLayoutManager(std::make_unique<FlexLayout>()); + flex_layout_->SetOrientation(views::LayoutOrientation::kHorizontal) + .SetMainAxisAlignment(views::LayoutAlignment::kCenter) + .SetDefault(views::kMarginsKey, + gfx::Insets(0, kColumnSpacingTablet, 0, 0)) + .SetDefault(views::kFlexBehaviorKey, + views::FlexSpecification( + views::MinimumFlexSizeRule::kScaleToMinimum, + views::MaximumFlexSizeRule::kScaleToMaximum)); +} + +void ContinueTaskContainerView::InitializeTableLayout() { + DCHECK(!tablet_mode_); + DCHECK(!flex_layout_); + DCHECK_GT(columns_, 0); + + table_layout_ = SetLayoutManager(std::make_unique<views::TableLayout>()); + std::vector<size_t> linked_columns; + for (int i = 0; i < columns_; i++) { + if (i > 0) { + table_layout_->AddPaddingColumn(views::TableLayout::kFixedSize, + kColumnSpacingClamshell); + } + table_layout_->AddColumn( + views::LayoutAlignment::kStretch, views::LayoutAlignment::kCenter, + /*resize_percent=*/1.0f, views::TableLayout::ColumnSize::kFixed, + /*fixed_width=*/0, /*min_width=*/0); + linked_columns.push_back(2 * i); + } + table_layout_->LinkColumnSizes(linked_columns); +} + BEGIN_METADATA(ContinueTaskContainerView, views::View) END_METADATA
diff --git a/ash/app_list/views/continue_task_container_view.h b/ash/app_list/views/continue_task_container_view.h index 5ae7635..5ea32a04 100644 --- a/ash/app_list/views/continue_task_container_view.h +++ b/ash/app_list/views/continue_task_container_view.h
@@ -15,6 +15,11 @@ #include "ui/base/models/list_model_observer.h" #include "ui/views/view.h" +namespace views { +class FlexLayout; +class TableLayout; +} // namespace views + namespace ash { class AppListViewDelegate; @@ -23,7 +28,7 @@ // The container for the Continue Tasks results view. The view contains a preset // number of ContinueTaskViews that get populated based on the list of results // passed in SetResult. -// ContinueTaskContainerView will accommodate Continue Task views in a table +// ContinueTaskContainerView will accommodate Continue Task views in a grid-like // layout with the number of columns specified at construction. class ASH_EXPORT ContinueTaskContainerView : public ui::ListModelObserver, public views::View { @@ -49,7 +54,7 @@ void ListItemsChanged(size_t start, size_t count) override; void Update(); - int num_results() const { return num_results_; } + size_t num_results() const { return num_results_; } void SetResults(SearchModel::SearchResults* results); @@ -59,15 +64,49 @@ private: void ScheduleUpdate(); + // Adds a new row to `table_layout_` to make space for extra views. A new row + // need to be added if the number of views for the current row is already + // filling up the available `columns_`. This will be no-op if `table_layout_` + // is nullptr. + void MaybeAddNewRowToLayout(int task_index); + + // Initializes the view's layout manager to use |flex_layout_|. FlexLayout is + // used in tablet mode only. Views will be laid out in a single row centered + // in the container. Number of items displayed will depend on available space. + // This will not enforce any number of `columns_`. + void InitializeFlexLayout(); + + // Initializes the view's layout manager to use |table_layout_|. TableLayout + // is used in clamshell mode only. Views are laid out in a table with a + // specific number of `columns_`. This displays views to stretch as to use + // all vertical space available in the container. Extra views are added in + // multiple rows. + void InitializeTableLayout(); + AppListViewDelegate* const view_delegate_; // A callback to be invoked after an Update request finishes. OnResultsChanged update_callback_; SearchModel::SearchResults* results_ = nullptr; // Owned by SearchModel. + // Only one of the layouts is to be set. + // `flex_layout_` aligns the views as a single row centered in the container. + // Used in tablet mode. + views::FlexLayout* flex_layout_ = nullptr; + // `table_layout_` aligns the views as a table with multiple rows stretched + // to fill the container. Used in clamshell mode. + views::TableLayout* table_layout_ = nullptr; + // The list of tasks views for the container. std::vector<ContinueTaskView*> suggestion_tasks_views_; // The number of results shown on the container. Each result has one view. - int num_results_ = 0; + size_t num_results_ = 0; + + // The number of columns available for the view. This is ignored in tablet + // mode. + int columns_ = 0; + + // Whether or not the view is showing for a table mode launcher or not. + bool tablet_mode_ = false; base::ScopedObservation<SearchModel::SearchResults, ui::ListModelObserver> list_model_observation_{this};
diff --git a/ash/app_list/views/continue_task_view.cc b/ash/app_list/views/continue_task_view.cc index 46cbaa9..b09babbad 100644 --- a/ash/app_list/views/continue_task_view.cc +++ b/ash/app_list/views/continue_task_view.cc
@@ -48,6 +48,8 @@ constexpr int kViewCornerRadiusClamshell = 8; constexpr int kViewCornerRadiusTablet = 20; +constexpr int kTaskMinWidth = 204; +constexpr int kTaskMaxWidth = 264; gfx::ImageSkia CreateIconWithCircleBackground(const gfx::ImageSkia& icon) { // The icon with circular background should only be styled when dark light @@ -120,11 +122,15 @@ std::make_unique<views::Label>(std::u16string())); title_->SetAccessibleName(std::u16string()); title_->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT); + title_->SetElideBehavior(gfx::ElideBehavior::ELIDE_MIDDLE); subtitle_ = label_container->AddChildView( std::make_unique<views::Label>(std::u16string())); subtitle_->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT); - UpdateResult(); + subtitle_->SetElideBehavior(gfx::ElideBehavior::ELIDE_MIDDLE); + layout_manager->SetFlexForView(label_container, 1); + + UpdateResult(); set_context_menu_controller(this); } ContinueTaskView::~ContinueTaskView() {} @@ -135,6 +141,24 @@ bubble_utils::ApplyStyle(subtitle_, bubble_utils::LabelStyle::kSubtitle); } +gfx::Size ContinueTaskView::GetMaximumSize() const { + return gfx::Size(kTaskMaxWidth, + GetLayoutManager()->GetPreferredSize(this).height()); +} + +gfx::Size ContinueTaskView::GetMinimumSize() const { + return gfx::Size(kTaskMinWidth, + GetLayoutManager()->GetPreferredSize(this).height()); +} + +gfx::Size ContinueTaskView::CalculatePreferredSize() const { + gfx::Size preferred_size = GetLayoutManager()->GetPreferredSize(this); + + return gfx::Size( + base::clamp(preferred_size.width(), kTaskMinWidth, kTaskMaxWidth), + preferred_size.height()); +} + void ContinueTaskView::OnButtonPressed(const ui::Event& event) { OpenResult(event.flags()); }
diff --git a/ash/app_list/views/continue_task_view.h b/ash/app_list/views/continue_task_view.h index bd8f2c8..7f3729e0 100644 --- a/ash/app_list/views/continue_task_view.h +++ b/ash/app_list/views/continue_task_view.h
@@ -44,6 +44,9 @@ ~ContinueTaskView() override; // views::View: + gfx::Size CalculatePreferredSize() const override; + gfx::Size GetMinimumSize() const override; + gfx::Size GetMaximumSize() const override; void OnThemeChanged() override; // SearchResultObserver:
diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd index 3664b0fc..1d795c6 100644 --- a/ash/ash_strings.grd +++ b/ash/ash_strings.grd
@@ -3399,6 +3399,9 @@ <message name="IDS_ASH_ASSISTANT_CHIP_SET_A_REMINDER" desc="Message shown on suggestion chip in Assistant UI to initiate a query to set a reminder."> Set a reminder </message> + <message name="IDS_ASH_ASSISTANT_CHIP_TELL_ME_A_JOKE" desc="Message shown on suggestion chip in Assistant UI to initiate a query to tell a joke."> + Tell me a joke + </message> <message name="IDS_ASH_ASSISTANT_CHIP_WHAT_CAN_YOU_DO" desc="Message shown on suggestion chip in Assistant UI to initiate a query for Assistant capabilities."> What can you do? </message>
diff --git a/ash/ash_strings_grd/IDS_ASH_ASSISTANT_CHIP_TELL_ME_A_JOKE.png.sha1 b/ash/ash_strings_grd/IDS_ASH_ASSISTANT_CHIP_TELL_ME_A_JOKE.png.sha1 new file mode 100644 index 0000000..f0b0110 --- /dev/null +++ b/ash/ash_strings_grd/IDS_ASH_ASSISTANT_CHIP_TELL_ME_A_JOKE.png.sha1
@@ -0,0 +1 @@ +757be580114ef6ab908f9b76ac117d6aea9c6a9a \ No newline at end of file
diff --git a/ash/assistant/assistant_controller_impl.cc b/ash/assistant/assistant_controller_impl.cc index e7c6fbee..1fce05cf 100644 --- a/ash/assistant/assistant_controller_impl.cc +++ b/ash/assistant/assistant_controller_impl.cc
@@ -233,7 +233,6 @@ case DeepLinkType::kQuery: case DeepLinkType::kReminders: case DeepLinkType::kSettings: - case DeepLinkType::kWhatsOnMyScreen: // No action needed. break; }
diff --git a/ash/assistant/assistant_interaction_controller_impl.cc b/ash/assistant/assistant_interaction_controller_impl.cc index 443a4d6..0051ed29 100644 --- a/ash/assistant/assistant_interaction_controller_impl.cc +++ b/ash/assistant/assistant_interaction_controller_impl.cc
@@ -164,20 +164,6 @@ using assistant::util::DeepLinkParam; using assistant::util::DeepLinkType; - if (type == DeepLinkType::kWhatsOnMyScreen) { - DCHECK(AssistantState::Get()->IsScreenContextAllowed()); - - // Explicitly call ShowUi() to set the correct Assistant entry point. - // ShowUi() will no-op if UI is already shown. - AssistantUiController::Get()->ShowUi(AssistantEntryPoint::kDeepLink); - - // The "What's on my screen" chip initiates a screen context interaction. - StartScreenContextInteraction( - /*include_assistant_structure=*/true, - /*region=*/gfx::Rect(), AssistantQuerySource::kWhatsOnMyScreen); - return; - } - if (type == DeepLinkType::kReminders) { using ReminderAction = assistant::util::ReminderAction; const absl::optional<ReminderAction>& action =
diff --git a/ash/assistant/assistant_suggestions_controller_impl.cc b/ash/assistant/assistant_suggestions_controller_impl.cc index 11d5c08..6fcc467 100644 --- a/ash/assistant/assistant_suggestions_controller_impl.cc +++ b/ash/assistant/assistant_suggestions_controller_impl.cc
@@ -106,12 +106,6 @@ // Always show the "What can you do?" conversation starter. AddConversationStarter(IDS_ASH_ASSISTANT_CHIP_WHAT_CAN_YOU_DO); - // If enabled, always show the "What's on my screen?" conversation starter. - if (AssistantState::Get()->context_enabled().value_or(false)) { - AddConversationStarter(IDS_ASH_ASSISTANT_CHIP_WHATS_ON_MY_SCREEN, - assistant::util::CreateWhatsOnMyScreenDeepLink()); - } - // The rest of the conversation starters will be shuffled... std::vector<int> shuffled_message_ids; @@ -120,6 +114,7 @@ shuffled_message_ids.push_back(IDS_ASH_ASSISTANT_CHIP_PLAY_MUSIC); shuffled_message_ids.push_back(IDS_ASH_ASSISTANT_CHIP_SEND_AN_EMAIL); shuffled_message_ids.push_back(IDS_ASH_ASSISTANT_CHIP_SET_A_REMINDER); + shuffled_message_ids.push_back(IDS_ASH_ASSISTANT_CHIP_TELL_ME_A_JOKE); shuffled_message_ids.push_back(IDS_ASH_ASSISTANT_CHIP_WHATS_ON_MY_CALENDAR); shuffled_message_ids.push_back(IDS_ASH_ASSISTANT_CHIP_WHATS_THE_WEATHER);
diff --git a/ash/assistant/util/deep_link_util.cc b/ash/assistant/util/deep_link_util.cc index f922775..4f714b76 100644 --- a/ash/assistant/util/deep_link_util.cc +++ b/ash/assistant/util/deep_link_util.cc
@@ -68,8 +68,6 @@ "googleassistant://take-screenshot"; constexpr char kAssistantSettingsPrefix[] = "googleassistant://settings"; constexpr char kAssistantTaskManagerPrefix[] = "googleassistant://task-manager"; -constexpr char kAssistantWhatsOnMyScreenPrefix[] = - "googleassistant://whats-on-my-screen"; // Helpers --------------------------------------------------------------------- @@ -197,10 +195,6 @@ return GURL(kAssistantSettingsPrefix); } -GURL CreateWhatsOnMyScreenDeepLink() { - return GURL(kAssistantWhatsOnMyScreenPrefix); -} - std::map<std::string, std::string> GetDeepLinkParams(const GURL& deep_link) { std::map<std::string, std::string> params; @@ -366,7 +360,7 @@ {DeepLinkType::kScreenshot, kAssistantScreenshotPrefix}, {DeepLinkType::kSettings, kAssistantSettingsPrefix}, {DeepLinkType::kTaskManager, kAssistantTaskManagerPrefix}, - {DeepLinkType::kWhatsOnMyScreen, kAssistantWhatsOnMyScreenPrefix}}; + }; for (const auto& supported_deep_link : kSupportedDeepLinks) { if (base::StartsWith(url.spec(), supported_deep_link.second, @@ -480,7 +474,6 @@ case DeepLinkType::kQuery: case DeepLinkType::kScreenshot: case DeepLinkType::kTaskManager: - case DeepLinkType::kWhatsOnMyScreen: NOTREACHED(); return absl::nullopt; }
diff --git a/ash/assistant/util/deep_link_util.h b/ash/assistant/util/deep_link_util.h index ab3783a..6aeb7d2 100644 --- a/ash/assistant/util/deep_link_util.h +++ b/ash/assistant/util/deep_link_util.h
@@ -39,7 +39,6 @@ kScreenshot, kSettings, kTaskManager, - kWhatsOnMyScreen, }; // Enumeration of deep link parameters. @@ -105,9 +104,6 @@ // Returns a deep link to top level Assistant Settings. COMPONENT_EXPORT(ASSISTANT_UTIL) GURL CreateAssistantSettingsDeepLink(); -// Returns a deep link to initiate a screen context interaction. -COMPONENT_EXPORT(ASSISTANT_UTIL) GURL CreateWhatsOnMyScreenDeepLink(); - // Returns the parsed parameters for the specified |deep_link|. If the supplied // argument is not a supported deep link or if no parameters are found, an empty // map is returned.
diff --git a/ash/assistant/util/deep_link_util_unittest.cc b/ash/assistant/util/deep_link_util_unittest.cc index 6f72179..a6c03b0 100644 --- a/ash/assistant/util/deep_link_util_unittest.cc +++ b/ash/assistant/util/deep_link_util_unittest.cc
@@ -157,11 +157,6 @@ CreateAssistantSettingsDeepLink()); } -TEST_F(DeepLinkUtilTest, CreateWhatsOnMyScreenDeepLink) { - ASSERT_EQ(GURL("googleassistant://whats-on-my-screen"), - CreateWhatsOnMyScreenDeepLink()); -} - TEST_F(DeepLinkUtilTest, GetDeepLinkParams) { std::map<std::string, std::string> params; @@ -489,7 +484,6 @@ {"googleassistant://settings", DeepLinkType::kSettings}, {"googleassistant://take-screenshot", DeepLinkType::kScreenshot}, {"googleassistant://task-manager", DeepLinkType::kTaskManager}, - {"googleassistant://whats-on-my-screen", DeepLinkType::kWhatsOnMyScreen}, // OK: Parameterized deep links. {"googleassistant://alarm-timer?param=true", DeepLinkType::kAlarmTimer}, @@ -505,8 +499,6 @@ {"googleassistant://take-screenshot?param=true", DeepLinkType::kScreenshot}, {"googleassistant://task-manager?param=true", DeepLinkType::kTaskManager}, - {"googleassistant://whats-on-my-screen?param=true", - DeepLinkType::kWhatsOnMyScreen}, // UNSUPPORTED: Deep links are case sensitive. {"GOOGLEASSISTANT://ALARM-TIMER", DeepLinkType::kUnsupported}, @@ -521,7 +513,6 @@ {"GOOGLEASSISTANT://SETTINGS", DeepLinkType::kUnsupported}, {"GOOGLEASSISTANT://TAKE-SCREENSHOT", DeepLinkType::kUnsupported}, {"GOOGLEASSISTANT://TASK-MANAGER", DeepLinkType::kUnsupported}, - {"GOOGLEASSISTANT://WHATS-ON-MY-SCREEN", DeepLinkType::kUnsupported}, // UNSUPPORTED: Unknown deep links. {"googleassistant://", DeepLinkType::kUnsupported}, @@ -549,7 +540,6 @@ {"googleassistant://settings", DeepLinkType::kSettings}, {"googleassistant://take-screenshot", DeepLinkType::kScreenshot}, {"googleassistant://task-manager", DeepLinkType::kTaskManager}, - {"googleassistant://whats-on-my-screen", DeepLinkType::kWhatsOnMyScreen}, // OK: Parameterized deep link types. {"googleassistant://alarm-timer?param=true", DeepLinkType::kAlarmTimer}, @@ -565,8 +555,6 @@ {"googleassistant://take-screenshot?param=true", DeepLinkType::kScreenshot}, {"googleassistant://task-manager?param=true", DeepLinkType::kTaskManager}, - {"googleassistant://whats-on-my-screen?param=true", - DeepLinkType::kWhatsOnMyScreen}, // UNSUPPORTED: Deep links are case sensitive. {"GOOGLEASSISTANT://ALARM-TIMER", DeepLinkType::kUnsupported}, @@ -606,7 +594,6 @@ {"googleassistant://settings", true}, {"googleassistant://take-screenshot", true}, {"googleassistant://task-manager", true}, - {"googleassistant://whats-on-my-screen", true}, // OK: Parameterized deep links. {"googleassistant://alarm-timer?param=true", true}, @@ -620,7 +607,6 @@ {"googleassistant://settings?param=true", true}, {"googleassistant://take-screenshot?param=true", true}, {"googleassistant://task-manager?param=true", true}, - {"googleassistant://whats-on-my-screen?param=true", true}, // FAIL: Deep links are case sensitive. {"GOOGLEASSISTANT://ALARM-TIMER", false}, @@ -634,7 +620,6 @@ {"GOOGLEASSISTANT://SETTINGS", false}, {"GOOGLEASSISTANT://TAKE-SCREENSHOT", false}, {"GOOGLEASSISTANT://TASK-MANAGER", false}, - {"GOOGLEASSISTANT://WHATS-ON-MY-SCREEN", false}, // FAIL: Unknown deep links. {"googleassistant://", false}, @@ -766,11 +751,7 @@ CreateIgnoreCase(DeepLinkType::kTaskManager, /*params=*/ {{"eid", "112233"}, {"id", "123456"}}), - CreateIgnoreCase(DeepLinkType::kWhatsOnMyScreen, - /*params=*/{}), - CreateIgnoreCase(DeepLinkType::kWhatsOnMyScreen, - /*params=*/ - {{"eid", "112233"}, {"id", "123456"}})}; + }; // For deep links that are not one of type {kLists, kNotes, kReminders}, we // will hit NOTREACHED since this API isn't meant to be used in such cases. @@ -863,7 +844,6 @@ {"googleassistant://send-query", absl::nullopt}, {"googleassistant://take-screenshot", absl::nullopt}, {"googleassistant://task-manager", absl::nullopt}, - {"googleassistant://whats-on-my-screen", absl::nullopt}, // FAIL: Non-deep link URLs. {std::string(), absl::nullopt}, @@ -946,7 +926,6 @@ {CreateTestCase(DeepLinkType::kQuery), absl::nullopt}, {CreateTestCase(DeepLinkType::kScreenshot), absl::nullopt}, {CreateTestCase(DeepLinkType::kTaskManager), absl::nullopt}, - {CreateTestCase(DeepLinkType::kWhatsOnMyScreen), absl::nullopt}, // FAIL: Unsupported deep link types. {CreateTestCase(DeepLinkType::kUnsupported), absl::nullopt}}; @@ -993,7 +972,6 @@ {"googleassistant://send-query", false}, {"googleassistant://take-screenshot", false}, {"googleassistant://task-manager", false}, - {"googleassistant://whats-on-my-screen", false}, {"googleassistant://reminders?action=create", false}, {"googleassistant://reminders?action=edit", false}, @@ -1020,7 +998,6 @@ {DeepLinkType::kQuery, false}, {DeepLinkType::kScreenshot, false}, {DeepLinkType::kTaskManager, false}, - {DeepLinkType::kWhatsOnMyScreen, false}, // FAIL: Unsupported deep link types. {DeepLinkType::kUnsupported, false}};
diff --git a/ash/capture_mode/capture_mode_session_focus_cycler.cc b/ash/capture_mode/capture_mode_session_focus_cycler.cc index 3678474..bd01c5ac 100644 --- a/ash/capture_mode/capture_mode_session_focus_cycler.cc +++ b/ash/capture_mode/capture_mode_session_focus_cycler.cc
@@ -352,10 +352,32 @@ } std::vector<HighlightableView*> views = GetGroupItems(current_focus_group_); - if (!views.empty()) { - DCHECK_LT(focus_index_, views.size()); - views[focus_index_]->PseudoBlur(); + if (views.empty()) + return; + + const size_t current_focus_index = + std::find_if(views.begin(), views.end(), + [](CaptureModeSessionFocusCycler::HighlightableView* item) { + return item->has_focus(); + }) - + views.begin(); + + // If current focused view doesn't exist, skip clearing focus. + if (current_focus_index == views.size()) { + // If `focus_index_` is out of bound, update it to the last index of the + // `views`. + if (focus_index_ >= views.size()) + focus_index_ = views.size() - 1; + return; } + + // Update `focus_index_` to ensure it's up to date, since highlightable views + // of `current_focus_group_` can be updated during keyboard navigation, for + // example, the custom folder option can be added or removed via the select + // folder menu item. + focus_index_ = current_focus_index; + DCHECK_LT(focus_index_, views.size()); + views[focus_index_]->PseudoBlur(); } CaptureModeSessionFocusCycler::FocusGroup
diff --git a/ash/capture_mode/capture_mode_session_focus_cycler.h b/ash/capture_mode/capture_mode_session_focus_cycler.h index 49a2fefa..732d54c 100644 --- a/ash/capture_mode/capture_mode_session_focus_cycler.h +++ b/ash/capture_mode/capture_mode_session_focus_cycler.h
@@ -62,6 +62,8 @@ // to override this class, which manages a custom focus ring. class HighlightableView { public: + bool has_focus() const { return has_focus_; } + // Get the view class associated with |this|. virtual views::View* GetView() = 0;
diff --git a/ash/capture_mode/capture_mode_unittests.cc b/ash/capture_mode/capture_mode_unittests.cc index 20580f6..1466f6e 100644 --- a/ash/capture_mode/capture_mode_unittests.cc +++ b/ash/capture_mode/capture_mode_unittests.cc
@@ -5861,6 +5861,103 @@ advanced_settings_test_api.GetSelectFolderMenuItem()); } +// Tests that selecting the default `Downloads` folder as the custom folder via +// keyboard navigation doesn't lead to a crash. Regression test for +// https://crbug.com/1269373. +TEST_F(CaptureModeAdvancedSettingsTest, + KeyboardNavigationForRemovingCustomFolderOption) { + // Begin a new session with a pre-configured custom folder. + auto* controller = CaptureModeController::Get(); + const base::FilePath custom_folder(CreateCustomFolder("test")); + controller->SetCustomCaptureFolder(custom_folder); + StartImageRegionCapture(); + + using FocusGroup = CaptureModeSessionFocusCycler::FocusGroup; + CaptureModeSessionTestApi test_api(controller->capture_mode_session()); + + // Tab six times to focus the settings button, then enter space to open the + // setting menu. Wait for the setting menu to be refreshed. + auto* event_generator = GetEventGenerator(); + SendKey(ui::VKEY_TAB, event_generator, /*shift_down=*/false, /*count=*/6); + SendKey(ui::VKEY_SPACE, event_generator); + WaitForSettingsMenuToBeRefreshed(); + EXPECT_EQ(FocusGroup::kPendingSettings, test_api.GetCurrentFocusGroup()); + CaptureModeAdvancedSettingsView* settings_menu = + GetCaptureModeAdvancedSettingsView(); + ASSERT_TRUE(settings_menu); + + // Tab five times to focus the `Select folder...` menu item and enter space + // to open the selection window. + SendKey(ui::VKEY_TAB, event_generator, /*shift_down=*/false, /*count=*/5); + SendKey(ui::VKEY_SPACE, event_generator); + EXPECT_TRUE(IsFolderSelectionDialogShown()); + // The current focus group is `FocusGroup::kSettingsMenu` and focus index is + // 4u. + EXPECT_EQ(FocusGroup::kSettingsMenu, test_api.GetCurrentFocusGroup()); + EXPECT_EQ(4u, test_api.GetCurrentFocusIndex()); + + // Select the default `Downloads` folder as the custom folder which will + // have custom folder option get removed. + auto* test_delegate = controller->delegate_for_testing(); + const auto default_downloads_folder = + test_delegate->GetUserDefaultDownloadsFolder(); + auto* dialog_factory = FakeFolderSelectionDialogFactory::Get(); + dialog_factory->AcceptPath(default_downloads_folder); + + // Tab once to make sure there's no crash and the focus gets moved to + // settings button. + SendKey(ui::VKEY_TAB, event_generator); + EXPECT_EQ(FocusGroup::kSettingsClose, test_api.GetCurrentFocusGroup()); + EXPECT_EQ(0u, test_api.GetCurrentFocusIndex()); +} + +// Tests that first time selecting a custom folder via keyboard navigation. +// After the custom folder is selected, tabbing one more time will move focus +// from the settings menu to the settings button. +TEST_F(CaptureModeAdvancedSettingsTest, + KeyboardNavigationForAddingCustomFolderOption) { + auto* controller = CaptureModeController::Get(); + StartImageRegionCapture(); + + using FocusGroup = CaptureModeSessionFocusCycler::FocusGroup; + CaptureModeSessionTestApi test_api(controller->capture_mode_session()); + + // Tab six times to focus the settings button, then enter space to open the + // setting menu. + auto* event_generator = GetEventGenerator(); + SendKey(ui::VKEY_TAB, event_generator, /*shift_down=*/false, /*count=*/6); + SendKey(ui::VKEY_SPACE, event_generator); + EXPECT_EQ(FocusGroup::kPendingSettings, test_api.GetCurrentFocusGroup()); + CaptureModeAdvancedSettingsView* settings_menu = + GetCaptureModeAdvancedSettingsView(); + ASSERT_TRUE(settings_menu); + + // Tab four times to focus the `Select folder...` menu item and enter space + // to open the selection window. + SendKey(ui::VKEY_TAB, event_generator, /*shift_down=*/false, /*count=*/4); + SendKey(ui::VKEY_SPACE, event_generator); + EXPECT_TRUE(IsFolderSelectionDialogShown()); + // The current focus group is `FocusGroup::kSettingsMenu` and focus index is + // 3u. + EXPECT_EQ(FocusGroup::kSettingsMenu, test_api.GetCurrentFocusGroup()); + EXPECT_EQ(3u, test_api.GetCurrentFocusIndex()); + + // Select the custom folder. Wait for the settings menu to be refreshed. The + // custom folder option should be added to the settings menu and checked. + const base::FilePath custom_folder(CreateCustomFolder("test")); + controller->SetCustomCaptureFolder(custom_folder); + auto* dialog_factory = FakeFolderSelectionDialogFactory::Get(); + dialog_factory->AcceptPath(custom_folder); + WaitForSettingsMenuToBeRefreshed(); + CaptureModeAdvancedSettingsTestApi advanced_test_api; + EXPECT_TRUE(advanced_test_api.GetCustomFolderOptionIfAny()); + + // Tab once to make sure the focus gets moved to settings button. + SendKey(ui::VKEY_TAB, event_generator); + EXPECT_EQ(FocusGroup::kSettingsClose, test_api.GetCurrentFocusGroup()); + EXPECT_EQ(0u, test_api.GetCurrentFocusIndex()); +} + // ----------------------------------------------------------------------------- // CaptureModeHistogramTest:
diff --git a/ash/components/arc/BUILD.gn b/ash/components/arc/BUILD.gn index bc84d60..92d29de 100644 --- a/ash/components/arc/BUILD.gn +++ b/ash/components/arc/BUILD.gn
@@ -57,6 +57,37 @@ "metrics/stability_metrics_manager.h", "midis/arc_midis_bridge.cc", "midis/arc_midis_bridge.h", + "net/always_on_vpn_manager.cc", + "net/always_on_vpn_manager.h", + "net/arc_net_host_impl.cc", + "net/arc_net_host_impl.h", + "obb_mounter/arc_obb_mounter_bridge.cc", + "obb_mounter/arc_obb_mounter_bridge.h", + "pay/arc_digital_goods_bridge.cc", + "pay/arc_digital_goods_bridge.h", + "pay/arc_payment_app_bridge.cc", + "pay/arc_payment_app_bridge.h", + "power/arc_power_bridge.cc", + "power/arc_power_bridge.h", + "property/arc_property_bridge.cc", + "property/arc_property_bridge.h", + "rotation_lock/arc_rotation_lock_bridge.cc", + "rotation_lock/arc_rotation_lock_bridge.h", + "sensor/arc_iio_sensor_bridge.cc", + "sensor/arc_iio_sensor_bridge.h", + "sensor/arc_sensor_bridge.cc", + "sensor/arc_sensor_bridge.h", + "storage_manager/arc_storage_manager.cc", + "storage_manager/arc_storage_manager.h", + "timer/arc_timer_bridge.cc", + "timer/arc_timer_bridge.h", + "usb/usb_host_bridge.cc", + "usb/usb_host_bridge.h", + "usb/usb_host_ui_delegate.h", + "volume_mounter/arc_volume_mounter_bridge.cc", + "volume_mounter/arc_volume_mounter_bridge.h", + "wake_lock/arc_wake_lock_bridge.cc", + "wake_lock/arc_wake_lock_bridge.h", ] public_deps = [ @@ -402,6 +433,7 @@ "wake_lock/arc_wake_lock_bridge_unittest.cc", ] + # TODO(b/129295708): Clean up unused deps. Update users of this target. deps = [ "//ash/components/arc:arc_test_support", "//ash/constants",
diff --git a/components/arc/net/DEPS b/ash/components/arc/net/DEPS similarity index 100% rename from components/arc/net/DEPS rename to ash/components/arc/net/DEPS
diff --git a/components/arc/net/OWNERS b/ash/components/arc/net/OWNERS similarity index 100% rename from components/arc/net/OWNERS rename to ash/components/arc/net/OWNERS
diff --git a/components/arc/net/always_on_vpn_manager.cc b/ash/components/arc/net/always_on_vpn_manager.cc similarity index 97% rename from components/arc/net/always_on_vpn_manager.cc rename to ash/components/arc/net/always_on_vpn_manager.cc index 56b6854e..e60bb39 100644 --- a/components/arc/net/always_on_vpn_manager.cc +++ b/ash/components/arc/net/always_on_vpn_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 "components/arc/net/always_on_vpn_manager.h" +#include "ash/components/arc/net/always_on_vpn_manager.h" #include <string>
diff --git a/components/arc/net/always_on_vpn_manager.h b/ash/components/arc/net/always_on_vpn_manager.h similarity index 79% rename from components/arc/net/always_on_vpn_manager.h rename to ash/components/arc/net/always_on_vpn_manager.h index cf1f013..1c25cbd 100644 --- a/components/arc/net/always_on_vpn_manager.h +++ b/ash/components/arc/net/always_on_vpn_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 COMPONENTS_ARC_NET_ALWAYS_ON_VPN_MANAGER_H_ -#define COMPONENTS_ARC_NET_ALWAYS_ON_VPN_MANAGER_H_ +#ifndef ASH_COMPONENTS_ARC_NET_ALWAYS_ON_VPN_MANAGER_H_ +#define ASH_COMPONENTS_ARC_NET_ALWAYS_ON_VPN_MANAGER_H_ #include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_service.h" @@ -28,4 +28,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_NET_ALWAYS_ON_VPN_MANAGER_H_ +#endif // ASH_COMPONENTS_ARC_NET_ALWAYS_ON_VPN_MANAGER_H_
diff --git a/ash/components/arc/net/always_on_vpn_manager_unittest.cc b/ash/components/arc/net/always_on_vpn_manager_unittest.cc index 872f785..7432b897 100644 --- a/ash/components/arc/net/always_on_vpn_manager_unittest.cc +++ b/ash/components/arc/net/always_on_vpn_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 "components/arc/net/always_on_vpn_manager.h" +#include "ash/components/arc/net/always_on_vpn_manager.h" #include "ash/components/arc/arc_prefs.h" #include "base/bind.h"
diff --git a/components/arc/net/arc_net_host_impl.cc b/ash/components/arc/net/arc_net_host_impl.cc similarity index 99% rename from components/arc/net/arc_net_host_impl.cc rename to ash/components/arc/net/arc_net_host_impl.cc index 2193f6e..42c580f 100644 --- a/components/arc/net/arc_net_host_impl.cc +++ b/ash/components/arc/net/arc_net_host_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 "components/arc/net/arc_net_host_impl.h" +#include "ash/components/arc/net/arc_net_host_impl.h" #include <utility> @@ -246,7 +246,8 @@ mojo->wifi->security = TranslateWiFiSecurity(network_state->security_class()); mojo->wifi->frequency = network_state->frequency(); - mojo->wifi->hidden_ssid = shill_dict && + mojo->wifi->hidden_ssid = + shill_dict && shill_dict->FindBoolPath(shill::kWifiHiddenSsid).value_or(false); mojo->wifi->signal_strength = network_state->signal_strength(); }
diff --git a/components/arc/net/arc_net_host_impl.h b/ash/components/arc/net/arc_net_host_impl.h similarity index 97% rename from components/arc/net/arc_net_host_impl.h rename to ash/components/arc/net/arc_net_host_impl.h index 34ca027a..c69b3fdc 100644 --- a/components/arc/net/arc_net_host_impl.h +++ b/ash/components/arc/net/arc_net_host_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 COMPONENTS_ARC_NET_ARC_NET_HOST_IMPL_H_ -#define COMPONENTS_ARC_NET_ARC_NET_HOST_IMPL_H_ +#ifndef ASH_COMPONENTS_ARC_NET_ARC_NET_HOST_IMPL_H_ +#define ASH_COMPONENTS_ARC_NET_ARC_NET_HOST_IMPL_H_ #include <stdint.h> #include <map> @@ -181,4 +181,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_NET_ARC_NET_HOST_IMPL_H_ +#endif // ASH_COMPONENTS_ARC_NET_ARC_NET_HOST_IMPL_H_
diff --git a/ash/components/arc/net/arc_net_host_impl_unittest.cc b/ash/components/arc/net/arc_net_host_impl_unittest.cc index dd24d37..aca31074 100644 --- a/ash/components/arc/net/arc_net_host_impl_unittest.cc +++ b/ash/components/arc/net/arc_net_host_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 "components/arc/net/arc_net_host_impl.h" +#include "ash/components/arc/net/arc_net_host_impl.h" #include <string>
diff --git a/components/arc/obb_mounter/OWNERS b/ash/components/arc/obb_mounter/OWNERS similarity index 100% rename from components/arc/obb_mounter/OWNERS rename to ash/components/arc/obb_mounter/OWNERS
diff --git a/components/arc/obb_mounter/arc_obb_mounter_bridge.cc b/ash/components/arc/obb_mounter/arc_obb_mounter_bridge.cc similarity index 97% rename from components/arc/obb_mounter/arc_obb_mounter_bridge.cc rename to ash/components/arc/obb_mounter/arc_obb_mounter_bridge.cc index 1d52e87..06d806ac 100644 --- a/components/arc/obb_mounter/arc_obb_mounter_bridge.cc +++ b/ash/components/arc/obb_mounter/arc_obb_mounter_bridge.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 "components/arc/obb_mounter/arc_obb_mounter_bridge.h" +#include "ash/components/arc/obb_mounter/arc_obb_mounter_bridge.h" #include <utility>
diff --git a/components/arc/obb_mounter/arc_obb_mounter_bridge.h b/ash/components/arc/obb_mounter/arc_obb_mounter_bridge.h similarity index 83% rename from components/arc/obb_mounter/arc_obb_mounter_bridge.h rename to ash/components/arc/obb_mounter/arc_obb_mounter_bridge.h index 36e9934..c1e968c 100644 --- a/components/arc/obb_mounter/arc_obb_mounter_bridge.h +++ b/ash/components/arc/obb_mounter/arc_obb_mounter_bridge.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 COMPONENTS_ARC_OBB_MOUNTER_ARC_OBB_MOUNTER_BRIDGE_H_ -#define COMPONENTS_ARC_OBB_MOUNTER_ARC_OBB_MOUNTER_BRIDGE_H_ +#ifndef ASH_COMPONENTS_ARC_OBB_MOUNTER_ARC_OBB_MOUNTER_BRIDGE_H_ +#define ASH_COMPONENTS_ARC_OBB_MOUNTER_ARC_OBB_MOUNTER_BRIDGE_H_ #include <string> @@ -19,9 +19,7 @@ class ArcBridgeService; // This class handles OBB mount/unmount requests from Android. -class ArcObbMounterBridge - : public KeyedService, - public mojom::ObbMounterHost { +class ArcObbMounterBridge : public KeyedService, public mojom::ObbMounterHost { public: // Returns singleton instance for the given BrowserContext, // or nullptr if the browser |context| is not allowed to use ARC. @@ -50,4 +48,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_OBB_MOUNTER_ARC_OBB_MOUNTER_BRIDGE_H_ +#endif // ASH_COMPONENTS_ARC_OBB_MOUNTER_ARC_OBB_MOUNTER_BRIDGE_H_
diff --git a/components/arc/pay/OWNERS b/ash/components/arc/pay/OWNERS similarity index 100% rename from components/arc/pay/OWNERS rename to ash/components/arc/pay/OWNERS
diff --git a/components/arc/pay/arc_digital_goods_bridge.cc b/ash/components/arc/pay/arc_digital_goods_bridge.cc similarity index 98% rename from components/arc/pay/arc_digital_goods_bridge.cc rename to ash/components/arc/pay/arc_digital_goods_bridge.cc index 86a1f5a9d..04c18c5 100644 --- a/components/arc/pay/arc_digital_goods_bridge.cc +++ b/ash/components/arc/pay/arc_digital_goods_bridge.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 "components/arc/pay/arc_digital_goods_bridge.h" +#include "ash/components/arc/pay/arc_digital_goods_bridge.h" #include <utility>
diff --git a/components/arc/pay/arc_digital_goods_bridge.h b/ash/components/arc/pay/arc_digital_goods_bridge.h similarity index 93% rename from components/arc/pay/arc_digital_goods_bridge.h rename to ash/components/arc/pay/arc_digital_goods_bridge.h index 53c4636..ece2e53 100644 --- a/components/arc/pay/arc_digital_goods_bridge.h +++ b/ash/components/arc/pay/arc_digital_goods_bridge.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 COMPONENTS_ARC_PAY_ARC_DIGITAL_GOODS_BRIDGE_H_ -#define COMPONENTS_ARC_PAY_ARC_DIGITAL_GOODS_BRIDGE_H_ +#ifndef ASH_COMPONENTS_ARC_PAY_ARC_DIGITAL_GOODS_BRIDGE_H_ +#define ASH_COMPONENTS_ARC_PAY_ARC_DIGITAL_GOODS_BRIDGE_H_ #include <string> #include <vector> @@ -74,4 +74,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_PAY_ARC_DIGITAL_GOODS_BRIDGE_H_ +#endif // ASH_COMPONENTS_ARC_PAY_ARC_DIGITAL_GOODS_BRIDGE_H_
diff --git a/components/arc/pay/arc_payment_app_bridge.cc b/ash/components/arc/pay/arc_payment_app_bridge.cc similarity index 98% rename from components/arc/pay/arc_payment_app_bridge.cc rename to ash/components/arc/pay/arc_payment_app_bridge.cc index 0ceff0b1..098cd7e5 100644 --- a/components/arc/pay/arc_payment_app_bridge.cc +++ b/ash/components/arc/pay/arc_payment_app_bridge.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 "components/arc/pay/arc_payment_app_bridge.h" +#include "ash/components/arc/pay/arc_payment_app_bridge.h" #include <utility>
diff --git a/components/arc/pay/arc_payment_app_bridge.h b/ash/components/arc/pay/arc_payment_app_bridge.h similarity index 93% rename from components/arc/pay/arc_payment_app_bridge.h rename to ash/components/arc/pay/arc_payment_app_bridge.h index d0b5c55..8fd84dcf 100644 --- a/components/arc/pay/arc_payment_app_bridge.h +++ b/ash/components/arc/pay/arc_payment_app_bridge.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 COMPONENTS_ARC_PAY_ARC_PAYMENT_APP_BRIDGE_H_ -#define COMPONENTS_ARC_PAY_ARC_PAYMENT_APP_BRIDGE_H_ +#ifndef ASH_COMPONENTS_ARC_PAY_ARC_PAYMENT_APP_BRIDGE_H_ +#define ASH_COMPONENTS_ARC_PAY_ARC_PAYMENT_APP_BRIDGE_H_ #include <string> @@ -71,4 +71,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_PAY_ARC_PAYMENT_APP_BRIDGE_H_ +#endif // ASH_COMPONENTS_ARC_PAY_ARC_PAYMENT_APP_BRIDGE_H_
diff --git a/ash/components/arc/pay/arc_payment_app_bridge_unittest.cc b/ash/components/arc/pay/arc_payment_app_bridge_unittest.cc index e376772..3145f13 100644 --- a/ash/components/arc/pay/arc_payment_app_bridge_unittest.cc +++ b/ash/components/arc/pay/arc_payment_app_bridge_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 "components/arc/pay/arc_payment_app_bridge.h" +#include "ash/components/arc/pay/arc_payment_app_bridge.h" #include <utility>
diff --git a/components/arc/power/DEPS b/ash/components/arc/power/DEPS similarity index 100% rename from components/arc/power/DEPS rename to ash/components/arc/power/DEPS
diff --git a/components/arc/power/arc_power_bridge.cc b/ash/components/arc/power/arc_power_bridge.cc similarity index 99% rename from components/arc/power/arc_power_bridge.cc rename to ash/components/arc/power/arc_power_bridge.cc index f060c83..0247d24 100644 --- a/components/arc/power/arc_power_bridge.cc +++ b/ash/components/arc/power/arc_power_bridge.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 "components/arc/power/arc_power_bridge.h" +#include "ash/components/arc/power/arc_power_bridge.h" #include <algorithm> #include <utility>
diff --git a/components/arc/power/arc_power_bridge.h b/ash/components/arc/power/arc_power_bridge.h similarity index 97% rename from components/arc/power/arc_power_bridge.h rename to ash/components/arc/power/arc_power_bridge.h index cd11063..a4c587e7 100644 --- a/components/arc/power/arc_power_bridge.h +++ b/ash/components/arc/power/arc_power_bridge.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 COMPONENTS_ARC_POWER_ARC_POWER_BRIDGE_H_ -#define COMPONENTS_ARC_POWER_ARC_POWER_BRIDGE_H_ +#ifndef ASH_COMPONENTS_ARC_POWER_ARC_POWER_BRIDGE_H_ +#define ASH_COMPONENTS_ARC_POWER_ARC_POWER_BRIDGE_H_ #include <map> #include <memory> @@ -160,4 +160,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_POWER_ARC_POWER_BRIDGE_H_ +#endif // ASH_COMPONENTS_ARC_POWER_ARC_POWER_BRIDGE_H_
diff --git a/ash/components/arc/power/arc_power_bridge_unittest.cc b/ash/components/arc/power/arc_power_bridge_unittest.cc index c8c1414..1c7315148 100644 --- a/ash/components/arc/power/arc_power_bridge_unittest.cc +++ b/ash/components/arc/power/arc_power_bridge_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 "components/arc/power/arc_power_bridge.h" +#include "ash/components/arc/power/arc_power_bridge.h" #include <utility>
diff --git a/components/arc/property/arc_property_bridge.cc b/ash/components/arc/property/arc_property_bridge.cc similarity index 97% rename from components/arc/property/arc_property_bridge.cc rename to ash/components/arc/property/arc_property_bridge.cc index e37fd5a..39e3905 100644 --- a/components/arc/property/arc_property_bridge.cc +++ b/ash/components/arc/property/arc_property_bridge.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 "components/arc/property/arc_property_bridge.h" +#include "ash/components/arc/property/arc_property_bridge.h" #include <string> #include <utility>
diff --git a/components/arc/property/arc_property_bridge.h b/ash/components/arc/property/arc_property_bridge.h similarity index 91% rename from components/arc/property/arc_property_bridge.h rename to ash/components/arc/property/arc_property_bridge.h index 7d4e816d..87b4c796 100644 --- a/components/arc/property/arc_property_bridge.h +++ b/ash/components/arc/property/arc_property_bridge.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 COMPONENTS_ARC_PROPERTY_ARC_PROPERTY_BRIDGE_H_ -#define COMPONENTS_ARC_PROPERTY_ARC_PROPERTY_BRIDGE_H_ +#ifndef ASH_COMPONENTS_ARC_PROPERTY_ARC_PROPERTY_BRIDGE_H_ +#define ASH_COMPONENTS_ARC_PROPERTY_ARC_PROPERTY_BRIDGE_H_ #include <vector> @@ -62,4 +62,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_PROPERTY_ARC_PROPERTY_BRIDGE_H_ +#endif // ASH_COMPONENTS_ARC_PROPERTY_ARC_PROPERTY_BRIDGE_H_
diff --git a/ash/components/arc/property/arc_property_bridge_unittest.cc b/ash/components/arc/property/arc_property_bridge_unittest.cc index 72197ba..8ce752b 100644 --- a/ash/components/arc/property/arc_property_bridge_unittest.cc +++ b/ash/components/arc/property/arc_property_bridge_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 "components/arc/property/arc_property_bridge.h" +#include "ash/components/arc/property/arc_property_bridge.h" #include <memory>
diff --git a/components/arc/rotation_lock/DEPS b/ash/components/arc/rotation_lock/DEPS similarity index 100% rename from components/arc/rotation_lock/DEPS rename to ash/components/arc/rotation_lock/DEPS
diff --git a/components/arc/rotation_lock/arc_rotation_lock_bridge.cc b/ash/components/arc/rotation_lock/arc_rotation_lock_bridge.cc similarity index 97% rename from components/arc/rotation_lock/arc_rotation_lock_bridge.cc rename to ash/components/arc/rotation_lock/arc_rotation_lock_bridge.cc index 10567da..b72e0d8 100644 --- a/components/arc/rotation_lock/arc_rotation_lock_bridge.cc +++ b/ash/components/arc/rotation_lock/arc_rotation_lock_bridge.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 "components/arc/rotation_lock/arc_rotation_lock_bridge.h" +#include "ash/components/arc/rotation_lock/arc_rotation_lock_bridge.h" #include "ash/components/arc/arc_browser_context_keyed_service_factory_base.h" #include "ash/shell.h"
diff --git a/components/arc/rotation_lock/arc_rotation_lock_bridge.h b/ash/components/arc/rotation_lock/arc_rotation_lock_bridge.h similarity index 90% rename from components/arc/rotation_lock/arc_rotation_lock_bridge.h rename to ash/components/arc/rotation_lock/arc_rotation_lock_bridge.h index 2ba13c8..1b8579b 100644 --- a/components/arc/rotation_lock/arc_rotation_lock_bridge.h +++ b/ash/components/arc/rotation_lock/arc_rotation_lock_bridge.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 COMPONENTS_ARC_ROTATION_LOCK_ARC_ROTATION_LOCK_BRIDGE_H_ -#define COMPONENTS_ARC_ROTATION_LOCK_ARC_ROTATION_LOCK_BRIDGE_H_ +#ifndef ASH_COMPONENTS_ARC_ROTATION_LOCK_ARC_ROTATION_LOCK_BRIDGE_H_ +#define ASH_COMPONENTS_ARC_ROTATION_LOCK_ARC_ROTATION_LOCK_BRIDGE_H_ #include "ash/display/screen_orientation_controller.h" #include "ash/public/cpp/tablet_mode_observer.h" @@ -62,4 +62,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_ROTATION_LOCK_ARC_ROTATION_LOCK_BRIDGE_H_ +#endif // ASH_COMPONENTS_ARC_ROTATION_LOCK_ARC_ROTATION_LOCK_BRIDGE_H_
diff --git a/ash/components/arc/rotation_lock/arc_rotation_lock_bridge_unittest.cc b/ash/components/arc/rotation_lock/arc_rotation_lock_bridge_unittest.cc index 11a58291..1b6ad1b2 100644 --- a/ash/components/arc/rotation_lock/arc_rotation_lock_bridge_unittest.cc +++ b/ash/components/arc/rotation_lock/arc_rotation_lock_bridge_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 "components/arc/rotation_lock/arc_rotation_lock_bridge.h" +#include "ash/components/arc/rotation_lock/arc_rotation_lock_bridge.h" #include "ash/components/arc/test/test_browser_context.h" #include "components/arc/session/arc_service_manager.h"
diff --git a/components/arc/sensor/OWNERS b/ash/components/arc/sensor/OWNERS similarity index 100% rename from components/arc/sensor/OWNERS rename to ash/components/arc/sensor/OWNERS
diff --git a/components/arc/sensor/arc_iio_sensor_bridge.cc b/ash/components/arc/sensor/arc_iio_sensor_bridge.cc similarity index 97% rename from components/arc/sensor/arc_iio_sensor_bridge.cc rename to ash/components/arc/sensor/arc_iio_sensor_bridge.cc index d36b1c9e..9db5068 100644 --- a/components/arc/sensor/arc_iio_sensor_bridge.cc +++ b/ash/components/arc/sensor/arc_iio_sensor_bridge.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 "components/arc/sensor/arc_iio_sensor_bridge.h" +#include "ash/components/arc/sensor/arc_iio_sensor_bridge.h" #include <utility>
diff --git a/components/arc/sensor/arc_iio_sensor_bridge.h b/ash/components/arc/sensor/arc_iio_sensor_bridge.h similarity index 92% rename from components/arc/sensor/arc_iio_sensor_bridge.h rename to ash/components/arc/sensor/arc_iio_sensor_bridge.h index 2ddca326..679ecd5 100644 --- a/components/arc/sensor/arc_iio_sensor_bridge.h +++ b/ash/components/arc/sensor/arc_iio_sensor_bridge.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 COMPONENTS_ARC_SENSOR_ARC_IIO_SENSOR_BRIDGE_H_ -#define COMPONENTS_ARC_SENSOR_ARC_IIO_SENSOR_BRIDGE_H_ +#ifndef ASH_COMPONENTS_ARC_SENSOR_ARC_IIO_SENSOR_BRIDGE_H_ +#define ASH_COMPONENTS_ARC_SENSOR_ARC_IIO_SENSOR_BRIDGE_H_ #include "base/memory/weak_ptr.h" #include "chromeos/dbus/power/power_manager_client.h" @@ -68,4 +68,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_SENSOR_ARC_IIO_SENSOR_BRIDGE_H_ +#endif // ASH_COMPONENTS_ARC_SENSOR_ARC_IIO_SENSOR_BRIDGE_H_
diff --git a/ash/components/arc/sensor/arc_iio_sensor_bridge_unittest.cc b/ash/components/arc/sensor/arc_iio_sensor_bridge_unittest.cc index 8ed6078..fa09e38 100644 --- a/ash/components/arc/sensor/arc_iio_sensor_bridge_unittest.cc +++ b/ash/components/arc/sensor/arc_iio_sensor_bridge_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 "components/arc/sensor/arc_iio_sensor_bridge.h" +#include "ash/components/arc/sensor/arc_iio_sensor_bridge.h" #include "ash/components/arc/test/connection_holder_util.h" #include "ash/components/arc/test/fake_iio_sensor_instance.h"
diff --git a/components/arc/sensor/arc_sensor_bridge.cc b/ash/components/arc/sensor/arc_sensor_bridge.cc similarity index 97% rename from components/arc/sensor/arc_sensor_bridge.cc rename to ash/components/arc/sensor/arc_sensor_bridge.cc index ace1625..12fdcaa 100644 --- a/components/arc/sensor/arc_sensor_bridge.cc +++ b/ash/components/arc/sensor/arc_sensor_bridge.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 "components/arc/sensor/arc_sensor_bridge.h" +#include "ash/components/arc/sensor/arc_sensor_bridge.h" #include <utility>
diff --git a/components/arc/sensor/arc_sensor_bridge.h b/ash/components/arc/sensor/arc_sensor_bridge.h similarity index 87% rename from components/arc/sensor/arc_sensor_bridge.h rename to ash/components/arc/sensor/arc_sensor_bridge.h index 77e0481..c498a09 100644 --- a/components/arc/sensor/arc_sensor_bridge.h +++ b/ash/components/arc/sensor/arc_sensor_bridge.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 COMPONENTS_ARC_SENSOR_ARC_SENSOR_BRIDGE_H_ -#define COMPONENTS_ARC_SENSOR_ARC_SENSOR_BRIDGE_H_ +#ifndef ASH_COMPONENTS_ARC_SENSOR_ARC_SENSOR_BRIDGE_H_ +#define ASH_COMPONENTS_ARC_SENSOR_ARC_SENSOR_BRIDGE_H_ #include "components/arc/mojom/sensor.mojom.h" #include "components/keyed_service/core/keyed_service.h" @@ -40,4 +40,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_SENSOR_ARC_SENSOR_BRIDGE_H_ +#endif // ASH_COMPONENTS_ARC_SENSOR_ARC_SENSOR_BRIDGE_H_
diff --git a/components/arc/storage_manager/OWNERS b/ash/components/arc/storage_manager/OWNERS similarity index 100% rename from components/arc/storage_manager/OWNERS rename to ash/components/arc/storage_manager/OWNERS
diff --git a/components/arc/storage_manager/arc_storage_manager.cc b/ash/components/arc/storage_manager/arc_storage_manager.cc similarity index 97% rename from components/arc/storage_manager/arc_storage_manager.cc rename to ash/components/arc/storage_manager/arc_storage_manager.cc index 1594783..05288c8 100644 --- a/components/arc/storage_manager/arc_storage_manager.cc +++ b/ash/components/arc/storage_manager/arc_storage_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 "components/arc/storage_manager/arc_storage_manager.h" +#include "ash/components/arc/storage_manager/arc_storage_manager.h" #include <utility>
diff --git a/components/arc/storage_manager/arc_storage_manager.h b/ash/components/arc/storage_manager/arc_storage_manager.h similarity index 89% rename from components/arc/storage_manager/arc_storage_manager.h rename to ash/components/arc/storage_manager/arc_storage_manager.h index 10f8e61..9dba14d3 100644 --- a/components/arc/storage_manager/arc_storage_manager.h +++ b/ash/components/arc/storage_manager/arc_storage_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 COMPONENTS_ARC_STORAGE_MANAGER_ARC_STORAGE_MANAGER_H_ -#define COMPONENTS_ARC_STORAGE_MANAGER_ARC_STORAGE_MANAGER_H_ +#ifndef ASH_COMPONENTS_ARC_STORAGE_MANAGER_ARC_STORAGE_MANAGER_H_ +#define ASH_COMPONENTS_ARC_STORAGE_MANAGER_ARC_STORAGE_MANAGER_H_ #include "base/callback.h" #include "components/arc/mojom/storage_manager.mojom.h" @@ -53,4 +53,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_STORAGE_MANAGER_ARC_STORAGE_MANAGER_H_ +#endif // ASH_COMPONENTS_ARC_STORAGE_MANAGER_ARC_STORAGE_MANAGER_H_
diff --git a/ash/components/arc/storage_manager/arc_storage_manager_unittest.cc b/ash/components/arc/storage_manager/arc_storage_manager_unittest.cc index 82c6e87..72a183d1 100644 --- a/ash/components/arc/storage_manager/arc_storage_manager_unittest.cc +++ b/ash/components/arc/storage_manager/arc_storage_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 "components/arc/storage_manager/arc_storage_manager.h" +#include "ash/components/arc/storage_manager/arc_storage_manager.h" #include "ash/components/arc/test/connection_holder_util.h" #include "ash/components/arc/test/fake_storage_manager_instance.h"
diff --git a/ash/components/arc/test/arc_payment_app_bridge_test_support.h b/ash/components/arc/test/arc_payment_app_bridge_test_support.h index 69305b2..4b9d183 100644 --- a/ash/components/arc/test/arc_payment_app_bridge_test_support.h +++ b/ash/components/arc/test/arc_payment_app_bridge_test_support.h
@@ -8,9 +8,9 @@ #include <memory> #include <string> +#include "ash/components/arc/pay/arc_payment_app_bridge.h" #include "ash/components/arc/test/test_browser_context.h" #include "components/arc/mojom/payment_app.mojom.h" -#include "components/arc/pay/arc_payment_app_bridge.h" #include "components/arc/session/arc_service_manager.h" #include "content/public/test/browser_task_environment.h" #include "testing/gmock/include/gmock/gmock.h"
diff --git a/components/arc/timer/OWNERS b/ash/components/arc/timer/OWNERS similarity index 100% rename from components/arc/timer/OWNERS rename to ash/components/arc/timer/OWNERS
diff --git a/components/arc/timer/arc_timer_bridge.cc b/ash/components/arc/timer/arc_timer_bridge.cc similarity index 98% rename from components/arc/timer/arc_timer_bridge.cc rename to ash/components/arc/timer/arc_timer_bridge.cc index 25d65c4e..197924fe 100644 --- a/components/arc/timer/arc_timer_bridge.cc +++ b/ash/components/arc/timer/arc_timer_bridge.cc
@@ -5,6 +5,8 @@ #include <set> #include "ash/components/arc/arc_browser_context_keyed_service_factory_base.h" +#include "ash/components/arc/timer/arc_timer_bridge.h" +#include "ash/components/arc/timer/arc_timer_mojom_traits.h" #include "base/bind.h" #include "base/containers/flat_set.h" #include "base/logging.h" @@ -15,8 +17,6 @@ #include "chromeos/dbus/power/power_manager_client.h" #include "components/arc/session/arc_bridge_service.h" #include "components/arc/session/arc_service_manager.h" -#include "components/arc/timer/arc_timer_bridge.h" -#include "components/arc/timer/arc_timer_mojom_traits.h" #include "mojo/public/cpp/system/handle.h" #include "mojo/public/cpp/system/platform_handle.h"
diff --git a/components/arc/timer/arc_timer_bridge.h b/ash/components/arc/timer/arc_timer_bridge.h similarity index 94% rename from components/arc/timer/arc_timer_bridge.h rename to ash/components/arc/timer/arc_timer_bridge.h index fbf1ae4b..b70b0d18 100644 --- a/components/arc/timer/arc_timer_bridge.h +++ b/ash/components/arc/timer/arc_timer_bridge.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 COMPONENTS_ARC_TIMER_ARC_TIMER_BRIDGE_H_ -#define COMPONENTS_ARC_TIMER_ARC_TIMER_BRIDGE_H_ +#ifndef ASH_COMPONENTS_ARC_TIMER_ARC_TIMER_BRIDGE_H_ +#define ASH_COMPONENTS_ARC_TIMER_ARC_TIMER_BRIDGE_H_ #include <map> #include <memory> @@ -95,4 +95,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_TIMER_ARC_TIMER_BRIDGE_H_ +#endif // ASH_COMPONENTS_ARC_TIMER_ARC_TIMER_BRIDGE_H_
diff --git a/ash/components/arc/timer/arc_timer_bridge_unittest.cc b/ash/components/arc/timer/arc_timer_bridge_unittest.cc index 7e85018..c6b85f0675 100644 --- a/ash/components/arc/timer/arc_timer_bridge_unittest.cc +++ b/ash/components/arc/timer/arc_timer_bridge_unittest.cc
@@ -10,6 +10,8 @@ #include "ash/components/arc/test/connection_holder_util.h" #include "ash/components/arc/test/fake_timer_instance.h" #include "ash/components/arc/test/test_browser_context.h" +#include "ash/components/arc/timer/arc_timer_bridge.h" +#include "ash/components/arc/timer/arc_timer_mojom_traits.h" #include "base/bind.h" #include "base/callback_helpers.h" #include "base/files/file_descriptor_watcher_posix.h" @@ -22,8 +24,6 @@ #include "components/arc/session/arc_bridge_service.h" #include "components/arc/session/arc_service_manager.h" #include "components/arc/session/connection_holder.h" -#include "components/arc/timer/arc_timer_bridge.h" -#include "components/arc/timer/arc_timer_mojom_traits.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h" #include "content/public/test/browser_task_environment.h" #include "mojo/public/cpp/system/handle.h"
diff --git a/components/arc/timer/arc_timer_mojom_traits.cc b/ash/components/arc/timer/arc_timer_mojom_traits.cc similarity index 93% rename from components/arc/timer/arc_timer_mojom_traits.cc rename to ash/components/arc/timer/arc_timer_mojom_traits.cc index c6360545..b5357a38 100644 --- a/components/arc/timer/arc_timer_mojom_traits.cc +++ b/ash/components/arc/timer/arc_timer_mojom_traits.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 "components/arc/timer/arc_timer_mojom_traits.h" +#include "ash/components/arc/timer/arc_timer_mojom_traits.h" #include <utility>
diff --git a/components/arc/timer/arc_timer_mojom_traits.h b/ash/components/arc/timer/arc_timer_mojom_traits.h similarity index 72% rename from components/arc/timer/arc_timer_mojom_traits.h rename to ash/components/arc/timer/arc_timer_mojom_traits.h index ce910a50..38ca351 100644 --- a/components/arc/timer/arc_timer_mojom_traits.h +++ b/ash/components/arc/timer/arc_timer_mojom_traits.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 COMPONENTS_ARC_TIMER_ARC_TIMER_MOJOM_TRAITS_H_ -#define COMPONENTS_ARC_TIMER_ARC_TIMER_MOJOM_TRAITS_H_ +#ifndef ASH_COMPONENTS_ARC_TIMER_ARC_TIMER_MOJOM_TRAITS_H_ +#define ASH_COMPONENTS_ARC_TIMER_ARC_TIMER_MOJOM_TRAITS_H_ #include <time.h> @@ -19,4 +19,4 @@ } // namespace mojo -#endif // COMPONENTS_ARC_TIMER_ARC_TIMER_MOJOM_TRAITS_H_ +#endif // ASH_COMPONENTS_ARC_TIMER_ARC_TIMER_MOJOM_TRAITS_H_
diff --git a/components/arc/usb/DEPS b/ash/components/arc/usb/DEPS similarity index 100% rename from components/arc/usb/DEPS rename to ash/components/arc/usb/DEPS
diff --git a/components/arc/usb/usb_host_bridge.cc b/ash/components/arc/usb/usb_host_bridge.cc similarity index 98% rename from components/arc/usb/usb_host_bridge.cc rename to ash/components/arc/usb/usb_host_bridge.cc index 61867d6..ad58f03 100644 --- a/components/arc/usb/usb_host_bridge.cc +++ b/ash/components/arc/usb/usb_host_bridge.cc
@@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/arc/usb/usb_host_bridge.h" +#include "ash/components/arc/usb/usb_host_bridge.h" #include <unordered_set> #include <utility> #include "ash/components/arc/arc_browser_context_keyed_service_factory_base.h" #include "ash/components/arc/arc_features.h" +#include "ash/components/arc/usb/usb_host_ui_delegate.h" #include "base/bind.h" #include "base/callback_helpers.h" #include "base/containers/contains.h" @@ -17,7 +18,6 @@ #include "base/strings/stringprintf.h" #include "chromeos/dbus/permission_broker/permission_broker_client.h" #include "components/arc/session/arc_bridge_service.h" -#include "components/arc/usb/usb_host_ui_delegate.h" #include "content/public/browser/device_service.h" #include "mojo/public/cpp/system/platform_handle.h"
diff --git a/components/arc/usb/usb_host_bridge.h b/ash/components/arc/usb/usb_host_bridge.h similarity index 96% rename from components/arc/usb/usb_host_bridge.h rename to ash/components/arc/usb/usb_host_bridge.h index 595aa23..683cb31 100644 --- a/components/arc/usb/usb_host_bridge.h +++ b/ash/components/arc/usb/usb_host_bridge.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 COMPONENTS_ARC_USB_USB_HOST_BRIDGE_H_ -#define COMPONENTS_ARC_USB_USB_HOST_BRIDGE_H_ +#ifndef ASH_COMPONENTS_ARC_USB_USB_HOST_BRIDGE_H_ +#define ASH_COMPONENTS_ARC_USB_USB_HOST_BRIDGE_H_ #include <map> #include <string> @@ -131,4 +131,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_USB_USB_HOST_BRIDGE_H_ +#endif // ASH_COMPONENTS_ARC_USB_USB_HOST_BRIDGE_H_
diff --git a/ash/components/arc/usb/usb_host_bridge_unittest.cc b/ash/components/arc/usb/usb_host_bridge_unittest.cc index aa5bd2cc..560b440 100644 --- a/ash/components/arc/usb/usb_host_bridge_unittest.cc +++ b/ash/components/arc/usb/usb_host_bridge_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 "components/arc/usb/usb_host_bridge.h" +#include "ash/components/arc/usb/usb_host_bridge.h" #include "ash/components/arc/test/test_browser_context.h" #include "components/arc/session/arc_service_manager.h"
diff --git a/components/arc/usb/usb_host_ui_delegate.h b/ash/components/arc/usb/usb_host_ui_delegate.h similarity index 93% rename from components/arc/usb/usb_host_ui_delegate.h rename to ash/components/arc/usb/usb_host_ui_delegate.h index 5fd4826f..810c146 100644 --- a/components/arc/usb/usb_host_ui_delegate.h +++ b/ash/components/arc/usb/usb_host_ui_delegate.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 COMPONENTS_ARC_USB_USB_HOST_UI_DELEGATE_H_ -#define COMPONENTS_ARC_USB_USB_HOST_UI_DELEGATE_H_ +#ifndef ASH_COMPONENTS_ARC_USB_USB_HOST_UI_DELEGATE_H_ +#define ASH_COMPONENTS_ARC_USB_USB_HOST_UI_DELEGATE_H_ #include <string> @@ -69,4 +69,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_USB_USB_HOST_UI_DELEGATE_H_ +#endif // ASH_COMPONENTS_ARC_USB_USB_HOST_UI_DELEGATE_H_
diff --git a/components/arc/volume_mounter/DEPS b/ash/components/arc/volume_mounter/DEPS similarity index 100% rename from components/arc/volume_mounter/DEPS rename to ash/components/arc/volume_mounter/DEPS
diff --git a/components/arc/volume_mounter/OWNERS b/ash/components/arc/volume_mounter/OWNERS similarity index 100% rename from components/arc/volume_mounter/OWNERS rename to ash/components/arc/volume_mounter/OWNERS
diff --git a/components/arc/volume_mounter/arc_volume_mounter_bridge.cc b/ash/components/arc/volume_mounter/arc_volume_mounter_bridge.cc similarity index 99% rename from components/arc/volume_mounter/arc_volume_mounter_bridge.cc rename to ash/components/arc/volume_mounter/arc_volume_mounter_bridge.cc index 6b8d1d61..e75d81d 100644 --- a/components/arc/volume_mounter/arc_volume_mounter_bridge.cc +++ b/ash/components/arc/volume_mounter/arc_volume_mounter_bridge.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 "components/arc/volume_mounter/arc_volume_mounter_bridge.h" +#include "ash/components/arc/volume_mounter/arc_volume_mounter_bridge.h" #include "ash/components/arc/arc_browser_context_keyed_service_factory_base.h" #include "ash/components/arc/arc_features.h"
diff --git a/components/arc/volume_mounter/arc_volume_mounter_bridge.h b/ash/components/arc/volume_mounter/arc_volume_mounter_bridge.h similarity index 94% rename from components/arc/volume_mounter/arc_volume_mounter_bridge.h rename to ash/components/arc/volume_mounter/arc_volume_mounter_bridge.h index edd13a9..e12e80c6 100644 --- a/components/arc/volume_mounter/arc_volume_mounter_bridge.h +++ b/ash/components/arc/volume_mounter/arc_volume_mounter_bridge.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 COMPONENTS_ARC_VOLUME_MOUNTER_ARC_VOLUME_MOUNTER_BRIDGE_H_ -#define COMPONENTS_ARC_VOLUME_MOUNTER_ARC_VOLUME_MOUNTER_BRIDGE_H_ +#ifndef ASH_COMPONENTS_ARC_VOLUME_MOUNTER_ARC_VOLUME_MOUNTER_BRIDGE_H_ +#define ASH_COMPONENTS_ARC_VOLUME_MOUNTER_ARC_VOLUME_MOUNTER_BRIDGE_H_ #include <string> @@ -107,4 +107,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_VOLUME_MOUNTER_ARC_VOLUME_MOUNTER_BRIDGE_H_ +#endif // ASH_COMPONENTS_ARC_VOLUME_MOUNTER_ARC_VOLUME_MOUNTER_BRIDGE_H_
diff --git a/ash/components/arc/volume_mounter/arc_volume_mounter_bridge_unittest.cc b/ash/components/arc/volume_mounter/arc_volume_mounter_bridge_unittest.cc index 100f886..4ba6a8b 100644 --- a/ash/components/arc/volume_mounter/arc_volume_mounter_bridge_unittest.cc +++ b/ash/components/arc/volume_mounter/arc_volume_mounter_bridge_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 "components/arc/volume_mounter/arc_volume_mounter_bridge.h" +#include "ash/components/arc/volume_mounter/arc_volume_mounter_bridge.h" #include "ash/components/arc/test/test_browser_context.h" #include "chromeos/disks/disk_mount_manager.h"
diff --git a/components/arc/volume_mounter/volume_mounter_mojom_traits.cc b/ash/components/arc/volume_mounter/volume_mounter_mojom_traits.cc similarity index 97% rename from components/arc/volume_mounter/volume_mounter_mojom_traits.cc rename to ash/components/arc/volume_mounter/volume_mounter_mojom_traits.cc index 606d4510..70ada6e 100644 --- a/components/arc/volume_mounter/volume_mounter_mojom_traits.cc +++ b/ash/components/arc/volume_mounter/volume_mounter_mojom_traits.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 "components/arc/volume_mounter/volume_mounter_mojom_traits.h" +#include "ash/components/arc/volume_mounter/volume_mounter_mojom_traits.h" #include "base/notreached.h"
diff --git a/components/arc/volume_mounter/volume_mounter_mojom_traits.h b/ash/components/arc/volume_mounter/volume_mounter_mojom_traits.h similarity index 80% rename from components/arc/volume_mounter/volume_mounter_mojom_traits.h rename to ash/components/arc/volume_mounter/volume_mounter_mojom_traits.h index 6e4ee75..6024c43f7a 100644 --- a/components/arc/volume_mounter/volume_mounter_mojom_traits.h +++ b/ash/components/arc/volume_mounter/volume_mounter_mojom_traits.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 COMPONENTS_ARC_VOLUME_MOUNTER_VOLUME_MOUNTER_MOJOM_TRAITS_H_ -#define COMPONENTS_ARC_VOLUME_MOUNTER_VOLUME_MOUNTER_MOJOM_TRAITS_H_ +#ifndef ASH_COMPONENTS_ARC_VOLUME_MOUNTER_VOLUME_MOUNTER_MOJOM_TRAITS_H_ +#define ASH_COMPONENTS_ARC_VOLUME_MOUNTER_VOLUME_MOUNTER_MOJOM_TRAITS_H_ #include "chromeos/disks/disk_mount_manager.h" #include "components/arc/mojom/volume_mounter.mojom-shared.h" @@ -28,4 +28,4 @@ } // namespace mojo -#endif // COMPONENTS_ARC_VOLUME_MOUNTER_VOLUME_MOUNTER_MOJOM_TRAITS_H_ +#endif // ASH_COMPONENTS_ARC_VOLUME_MOUNTER_VOLUME_MOUNTER_MOJOM_TRAITS_H_
diff --git a/components/arc/wake_lock/DEPS b/ash/components/arc/wake_lock/DEPS similarity index 100% rename from components/arc/wake_lock/DEPS rename to ash/components/arc/wake_lock/DEPS
diff --git a/components/arc/wake_lock/arc_wake_lock_bridge.cc b/ash/components/arc/wake_lock/arc_wake_lock_bridge.cc similarity index 98% rename from components/arc/wake_lock/arc_wake_lock_bridge.cc rename to ash/components/arc/wake_lock/arc_wake_lock_bridge.cc index e590a46..7efc1ef4 100644 --- a/components/arc/wake_lock/arc_wake_lock_bridge.cc +++ b/ash/components/arc/wake_lock/arc_wake_lock_bridge.cc
@@ -6,13 +6,13 @@ #include <utility> #include "ash/components/arc/arc_browser_context_keyed_service_factory_base.h" +#include "ash/components/arc/wake_lock/arc_wake_lock_bridge.h" #include "base/bind.h" #include "base/logging.h" #include "base/memory/singleton.h" #include "chromeos/dbus/power/power_policy_controller.h" #include "components/arc/session/arc_bridge_service.h" #include "components/arc/session/arc_service_manager.h" -#include "components/arc/wake_lock/arc_wake_lock_bridge.h" #include "content/public/browser/device_service.h" #include "mojo/public/cpp/bindings/remote.h" #include "services/device/public/mojom/wake_lock_provider.mojom.h"
diff --git a/components/arc/wake_lock/arc_wake_lock_bridge.h b/ash/components/arc/wake_lock/arc_wake_lock_bridge.h similarity index 94% rename from components/arc/wake_lock/arc_wake_lock_bridge.h rename to ash/components/arc/wake_lock/arc_wake_lock_bridge.h index 8e005a3..64c8ea0 100644 --- a/components/arc/wake_lock/arc_wake_lock_bridge.h +++ b/ash/components/arc/wake_lock/arc_wake_lock_bridge.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 COMPONENTS_ARC_WAKE_LOCK_ARC_WAKE_LOCK_BRIDGE_H_ -#define COMPONENTS_ARC_WAKE_LOCK_ARC_WAKE_LOCK_BRIDGE_H_ +#ifndef ASH_COMPONENTS_ARC_WAKE_LOCK_ARC_WAKE_LOCK_BRIDGE_H_ +#define ASH_COMPONENTS_ARC_WAKE_LOCK_ARC_WAKE_LOCK_BRIDGE_H_ #include <map> #include <memory> @@ -89,4 +89,4 @@ } // namespace arc -#endif // COMPONENTS_ARC_WAKE_LOCK_ARC_WAKE_LOCK_BRIDGE_H_ +#endif // ASH_COMPONENTS_ARC_WAKE_LOCK_ARC_WAKE_LOCK_BRIDGE_H_
diff --git a/ash/components/arc/wake_lock/arc_wake_lock_bridge_unittest.cc b/ash/components/arc/wake_lock/arc_wake_lock_bridge_unittest.cc index 91e5346..e4fa5bd 100644 --- a/ash/components/arc/wake_lock/arc_wake_lock_bridge_unittest.cc +++ b/ash/components/arc/wake_lock/arc_wake_lock_bridge_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 "components/arc/wake_lock/arc_wake_lock_bridge.h" +#include "ash/components/arc/wake_lock/arc_wake_lock_bridge.h" #include <memory> #include <utility>
diff --git a/ash/constants/ash_pref_names.cc b/ash/constants/ash_pref_names.cc index fe50efca..dd0cf59 100644 --- a/ash/constants/ash_pref_names.cc +++ b/ash/constants/ash_pref_names.cc
@@ -884,8 +884,12 @@ const char kProjectorCreationFlowLanguage[] = "ash.projector.projectorCreationFlowLanguage"; -// NOTE: New prefs should start with the "ash." prefix. Existing prefs -// moved into this file should not be renamed, since they may be synced. +// List of Drive Folder Shortcuts in the Files app. Used to sync the shortcuts +// across devices. +const char kFilesAppFolderShortcuts[] = "ash.filesapp.folder_shortcuts"; + +// NOTE: New prefs should start with the "ash." prefix. Existing prefs moved +// into this file should not be renamed, since they may be synced. } // namespace prefs } // namespace ash
diff --git a/ash/constants/ash_pref_names.h b/ash/constants/ash_pref_names.h index 8273144..153eb66 100644 --- a/ash/constants/ash_pref_names.h +++ b/ash/constants/ash_pref_names.h
@@ -404,6 +404,8 @@ COMPONENT_EXPORT(ASH_CONSTANTS) extern const char kProjectorCreationFlowLanguage[]; +COMPONENT_EXPORT(ASH_CONSTANTS) extern const char kFilesAppFolderShortcuts[]; + } // namespace prefs } // namespace ash
diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc index 2cdd6aed..38e0c27 100644 --- a/ash/display/display_manager_unittest.cc +++ b/ash/display/display_manager_unittest.cc
@@ -60,6 +60,7 @@ #include "ui/events/test/event_generator.h" #include "ui/gfx/font_render_params.h" #include "ui/gfx/geometry/rect_conversions.h" +#include "ui/gfx/overlay_transform.h" namespace ash { @@ -140,6 +141,7 @@ void OnDidProcessDisplayChanges() override { ++did_process_count_; } void OnDisplayMetricsChanged(const display::Display& display, uint32_t changed_metrics) override { + LOG(ERROR) << "Changed:" << changed_metrics; changed_.push_back(display); changed_metrics_ |= changed_metrics; } @@ -152,7 +154,8 @@ // aura::WindowObserver overrides: void OnWindowDestroying(aura::Window* window) override { - ASSERT_EQ(Shell::GetPrimaryRootWindow(), window); + if (check_root_window_on_destruction_) + ASSERT_EQ(Shell::GetPrimaryRootWindow(), window); root_window_destroyed_ = true; } @@ -179,6 +182,10 @@ base::RunLoop().RunUntilIdle(); } + void disable_check_root_window_on_destruction() { + check_root_window_on_destruction_ = false; + } + private: vector<display::Display> changed_; vector<display::Display> added_; @@ -187,6 +194,7 @@ size_t did_process_count_ = 0u; bool root_window_destroyed_ = false; uint32_t changed_metrics_ = 0u; + bool check_root_window_on_destruction_ = true; absl::optional<display::ScopedDisplayObserver> display_observer_; }; @@ -3074,6 +3082,64 @@ app_list_controller->IsVisible(display_manager()->first_display_id())); } +TEST_F(DisplayManagerTest, UnifiedDesktopPrimarySizeWithRotatedDisplays) { + MirrorWindowTestApi test_api; + + // RootWidow for primary changes during unified desktop transition. + disable_check_root_window_on_destruction(); + + display::test::DisplayManagerTestApi(display_manager()) + .SetFirstDisplayAsInternalDisplay(); + display_manager()->SetUnifiedDesktopEnabled(true); + + UpdateDisplay("1000x700/r"); + base::RunLoop().RunUntilIdle(); + EXPECT_EQ(gfx::Size(700, 1000), + display::Screen::GetScreen()->GetPrimaryDisplay().size()); + + UpdateDisplay("1000x700/r,1000x700/r"); + base::RunLoop().RunUntilIdle(); + EXPECT_EQ(gfx::Size(1400, 1000), + display::Screen::GetScreen()->GetPrimaryDisplay().size()); + + std::vector<aura::WindowTreeHost*> host_list = test_api.GetHosts(); + EXPECT_EQ(gfx::Size(700, 1000), host_list[0]->window()->bounds().size()); + EXPECT_EQ(gfx::OVERLAY_TRANSFORM_ROTATE_90, + host_list[0]->compositor()->display_transform_hint()); + EXPECT_EQ(gfx::Size(700, 1000), host_list[1]->window()->bounds().size()); + EXPECT_EQ(gfx::OVERLAY_TRANSFORM_ROTATE_90, + host_list[1]->compositor()->display_transform_hint()); + + UpdateDisplay("1000x700/r,1000x700"); + base::RunLoop().RunUntilIdle(); + // width = 1000 / 700 * 1000 + 700 ~= 2128 + EXPECT_EQ(gfx::Size(2128, 1000), + display::Screen::GetScreen()->GetPrimaryDisplay().size()); + host_list = test_api.GetHosts(); + EXPECT_EQ(gfx::Size(700, 1000), host_list[0]->window()->bounds().size()); + EXPECT_EQ(gfx::OVERLAY_TRANSFORM_ROTATE_90, + host_list[0]->compositor()->display_transform_hint()); + EXPECT_EQ(gfx::Size(1000, 700), host_list[1]->window()->bounds().size()); + EXPECT_EQ(gfx::OVERLAY_TRANSFORM_NONE, + host_list[1]->compositor()->display_transform_hint()); + + // Three displays + UpdateDisplay("1000x700/l,1000x700/r, 1000x700/l"); + base::RunLoop().RunUntilIdle(); + EXPECT_EQ(gfx::Size(2100, 1000), + display::Screen::GetScreen()->GetPrimaryDisplay().size()); + host_list = test_api.GetHosts(); + EXPECT_EQ(gfx::Size(700, 1000), host_list[0]->window()->bounds().size()); + EXPECT_EQ(gfx::OVERLAY_TRANSFORM_ROTATE_270, + host_list[0]->compositor()->display_transform_hint()); + EXPECT_EQ(gfx::Size(700, 1000), host_list[1]->window()->bounds().size()); + EXPECT_EQ(gfx::OVERLAY_TRANSFORM_ROTATE_90, + host_list[1]->compositor()->display_transform_hint()); + EXPECT_EQ(gfx::Size(700, 1000), host_list[2]->window()->bounds().size()); + EXPECT_EQ(gfx::OVERLAY_TRANSFORM_ROTATE_270, + host_list[2]->compositor()->display_transform_hint()); +} + TEST_F(DisplayManagerTest, DisplayPrefsAndForcedMirrorMode) { UpdateDisplay("400x300,800x700"); base::RunLoop().RunUntilIdle();
diff --git a/ash/display/display_util.cc b/ash/display/display_util.cc index ec36a3b..6db9bdac 100644 --- a/ash/display/display_util.cc +++ b/ash/display/display_util.cc
@@ -211,11 +211,7 @@ } bool ShouldUndoRotationForMirror() { - return Shell::Get() - ->display_manager() - ->layout_store() - ->forced_mirror_mode_for_tablet() || - Shell::Get()->tablet_mode_controller()->is_in_tablet_physical_state(); + return Shell::Get()->tablet_mode_controller()->is_in_tablet_physical_state(); } } // namespace ash
diff --git a/ash/display/mirror_window_controller.cc b/ash/display/mirror_window_controller.cc index 29166d7..59ecaf1 100644 --- a/ash/display/mirror_window_controller.cc +++ b/ash/display/mirror_window_controller.cc
@@ -235,6 +235,12 @@ mirror_window->Init(ui::LAYER_SOLID_COLOR); host->window()->AddChild(mirror_window); host_info->ash_host->SetRootWindowTransformer(std::move(transformer)); + + const display::Display::Rotation effective_rotation = + display_info.GetLogicalActiveRotation(); + host->SetDisplayTransformHint( + display::DisplayRotationToOverlayTransform(effective_rotation)); + // The accelerated widget is created synchronously. DCHECK_NE(gfx::kNullAcceleratedWidget, host->GetAcceleratedWidget()); } else { @@ -244,6 +250,12 @@ GetRootWindowSettings(host->window())->display_id = display_info.id(); ash_host->SetRootWindowTransformer(std::move(transformer)); host->SetBoundsInPixels(display_info.bounds_in_native()); + + // TODO(oshima): Consolidate the code above. + const display::Display::Rotation effective_rotation = + display_info.GetLogicalActiveRotation(); + host->SetDisplayTransformHint( + display::DisplayRotationToOverlayTransform(effective_rotation)); } // |mirror_size| is the size of the compositor of the mirror source in @@ -258,7 +270,8 @@ auto* mirroring_host_info = mirroring_host_info_map_[display_info.id()]; const bool should_undo_rotation = ShouldUndoRotationForMirror(); - if (!should_undo_rotation) { + + if (!should_undo_rotation && !display_manager->IsInUnifiedMode()) { // Use the rotation from source display without panel orientation // applied instead of the display transform hint in |source_compositor| // so that panel orientation is not applied to the mirror host.
diff --git a/ash/display/root_window_transformers.cc b/ash/display/root_window_transformers.cc index 419b982..b9b618f 100644 --- a/ash/display/root_window_transformers.cc +++ b/ash/display/root_window_transformers.cc
@@ -304,6 +304,14 @@ // Physical root bounds. root_bounds_ = gfx::Rect(display_info.bounds_in_native().size()); + display::Display::Rotation active_root_rotation = + display_info.GetActiveRotation(); + const bool need_transpose = + active_root_rotation == display::Display::ROTATE_90 || + active_root_rotation == display::Display::ROTATE_270; + if (need_transpose) + root_bounds_.Transpose(); + // |screen_bounds| is the unified desktop logical bounds. // Calculate the unified height scale value, and apply the same scale on the // row physical height to get the row logical height. @@ -327,6 +335,8 @@ transform_.Scale(scale, scale); transform_.Translate(-SkIntToScalar(display.bounds().x()), -SkIntToScalar(display.bounds().y())); + gfx::Transform rotation = CreateRootWindowRotationTransform(display); + CHECK((rotation * transform_).GetInverse(&invert_transform_)); } PartialBoundsRootWindowTransformer( @@ -337,9 +347,7 @@ // RootWindowTransformer: gfx::Transform GetTransform() const override { return transform_; } gfx::Transform GetInverseTransform() const override { - gfx::Transform invert; - CHECK(transform_.GetInverse(&invert)); - return invert; + return invert_transform_; } gfx::Rect GetRootWindowBounds(const gfx::Size& host_size) const override { return root_bounds_; @@ -351,6 +359,7 @@ private: gfx::Transform transform_; + gfx::Transform invert_transform_; gfx::Rect root_bounds_; };
diff --git a/ash/login/ui/auth_factor_model.h b/ash/login/ui/auth_factor_model.h index 567f859..924beeb49 100644 --- a/ash/login/ui/auth_factor_model.h +++ b/ash/login/ui/auth_factor_model.h
@@ -111,6 +111,10 @@ // is tapped or clicked. virtual void OnArrowButtonTapOrClickEvent(); + // This will be called after the latest error has been shown to the user to + // signal that any transient error state should be cleared out. + virtual void OnErrorTimeout() = 0; + protected: // Should be called whenever the internal state of the auth model changes to // invoke the |on_state_changed_callback_| if set. Calls UpdateIcon().
diff --git a/ash/login/ui/fingerprint_auth_factor_model.cc b/ash/login/ui/fingerprint_auth_factor_model.cc index 17c1d5ec..8df0e76 100644 --- a/ash/login/ui/fingerprint_auth_factor_model.cc +++ b/ash/login/ui/fingerprint_auth_factor_model.cc
@@ -22,9 +22,6 @@ constexpr int kFingerprintIconSizeDp = 32; constexpr int kFingerprintFailedAnimationDurationMs = 700; constexpr int kFingerprintFailedAnimationNumFrames = 45; -constexpr base::TimeDelta kResetToDefaultMessageDelayMs = - base::Milliseconds(3000); -constexpr int kResetToDefaultIconDelayMs = 1300; } // namespace @@ -36,28 +33,13 @@ if (state_ == state) return; - reset_state_.Stop(); - if (auth_result_.has_value() && !auth_result_.value()) { - // Clear failed auth attempt to allow retry. - auth_result_.reset(); - } state_ = state; NotifyOnStateChanged(); } void FingerprintAuthFactorModel::NotifyFingerprintAuthResult(bool result) { - reset_state_.Stop(); auth_result_ = result; NotifyOnStateChanged(); - - if (!result) { - // Clear failed auth attempt after a delay to allow retry. base::Unretained - // is safe because |reset_state_| is owned by |this|. - reset_state_.Start(FROM_HERE, - base::Milliseconds(kResetToDefaultIconDelayMs), - base::BindOnce(&FingerprintAuthFactorModel::OnResetState, - base::Unretained(this))); - } } void FingerprintAuthFactorModel::SetCanUsePin(bool can_use_pin) { @@ -67,18 +49,29 @@ AuthFactorModel::AuthFactorState FingerprintAuthFactorModel::GetAuthFactorState() { - // TODO(crbug.com/1233614): Calculate the correct AuthFactorState based on the - // current FingerprintState. if (!available_) return AuthFactorState::kUnavailable; if (auth_result_.has_value()) { - return auth_result_.value() ? AuthFactorState::kAuthenticated - : AuthFactorState::kErrorTemporary; + if (auth_result_.value()) { + return AuthFactorState::kAuthenticated; + } else if (state_ != FingerprintState::DISABLED_FROM_ATTEMPTS) { + return AuthFactorState::kErrorTemporary; + } } - return state_ == FingerprintState::UNAVAILABLE ? AuthFactorState::kUnavailable - : AuthFactorState::kReady; + switch (state_) { + case FingerprintState::UNAVAILABLE: + return AuthFactorState::kUnavailable; + case FingerprintState::AVAILABLE_DEFAULT: + return AuthFactorState::kReady; + case FingerprintState::AVAILABLE_WITH_TOUCH_SENSOR_WARNING: + return AuthFactorState::kErrorTemporary; + case FingerprintState::DISABLED_FROM_ATTEMPTS: + FALLTHROUGH; + case FingerprintState::DISABLED_FROM_TIMEOUT: + return AuthFactorState::kErrorPermanent; + } } AuthFactorType FingerprintAuthFactorModel::GetType() { @@ -87,8 +80,11 @@ int FingerprintAuthFactorModel::GetLabelId() { if (auth_result_.has_value()) { - return auth_result_.value() ? IDS_ASH_LOGIN_FINGERPRINT_UNLOCK_AUTH_SUCCESS - : IDS_ASH_LOGIN_FINGERPRINT_UNLOCK_AUTH_FAILED; + if (auth_result_.value()) { + return IDS_ASH_LOGIN_FINGERPRINT_UNLOCK_AUTH_SUCCESS; + } else if (state_ != FingerprintState::DISABLED_FROM_ATTEMPTS) { + return IDS_ASH_LOGIN_FINGERPRINT_UNLOCK_AUTH_FAILED; + } } switch (state_) { @@ -99,8 +95,12 @@ case FingerprintState::AVAILABLE_WITH_TOUCH_SENSOR_WARNING: return IDS_ASH_LOGIN_FINGERPRINT_UNLOCK_TOUCH_SENSOR; case FingerprintState::DISABLED_FROM_ATTEMPTS: + // TODO(crbug.com/1233614): Update this string: "Too many attempts" -> + // "Too many fingerprint attempts". return IDS_ASH_LOGIN_FINGERPRINT_UNLOCK_DISABLED_FROM_ATTEMPTS; case FingerprintState::DISABLED_FROM_TIMEOUT: + // TODO(crbug.com/1233614): Merge these "password required" strings with + // those used by Smart Lock. if (can_use_pin_) return IDS_ASH_LOGIN_FINGERPRINT_UNLOCK_PIN_OR_PASSWORD_REQUIRED; return IDS_ASH_LOGIN_FINGERPRINT_UNLOCK_PASSWORD_REQUIRED; @@ -166,22 +166,26 @@ } void FingerprintAuthFactorModel::OnTapOrClickEvent() { - if (state_ == FingerprintState::AVAILABLE_DEFAULT || - state_ == FingerprintState::AVAILABLE_WITH_TOUCH_SENSOR_WARNING) { - SetFingerprintState(FingerprintState::AVAILABLE_WITH_TOUCH_SENSOR_WARNING); - reset_state_.Start( - FROM_HERE, kResetToDefaultMessageDelayMs, - base::BindOnce(&FingerprintAuthFactorModel::SetFingerprintState, - base::Unretained(this), - FingerprintState::AVAILABLE_DEFAULT)); + if (state_ == FingerprintState::AVAILABLE_DEFAULT) { + state_ = FingerprintState::AVAILABLE_WITH_TOUCH_SENSOR_WARNING; } + + // TODO(crbug.com/1233614): Move this call into the AuthFactorModel base class + // so that the derived classes don't have to call it. + NotifyOnStateChanged(); } -void FingerprintAuthFactorModel::OnResetState() { +void FingerprintAuthFactorModel::OnErrorTimeout() { if (auth_result_.has_value() && !auth_result_.value()) { // Clear failed auth attempt to allow retry. auth_result_.reset(); } + if (GetAuthFactorState() == AuthFactorState::kErrorTemporary) { + state_ = FingerprintState::AVAILABLE_DEFAULT; + } + + // TODO(crbug.com/1233614): Move this call into the AuthFactorModel base class + // so that the derived classes don't have to call it. NotifyOnStateChanged(); }
diff --git a/ash/login/ui/fingerprint_auth_factor_model.h b/ash/login/ui/fingerprint_auth_factor_model.h index 423ce70..adc7feb 100644 --- a/ash/login/ui/fingerprint_auth_factor_model.h +++ b/ash/login/ui/fingerprint_auth_factor_model.h
@@ -7,7 +7,6 @@ #include "ash/login/ui/auth_factor_model.h" #include "ash/public/cpp/login_types.h" -#include "base/timer/timer.h" namespace ash { @@ -39,15 +38,12 @@ bool ShouldAnnounceLabel() override; int GetAccessibleNameId() override; void OnTapOrClickEvent() override; + void OnErrorTimeout() override; void UpdateIcon(AuthIconView* icon) override; - void OnResetState(); - FingerprintState state_ = FingerprintState::AVAILABLE_DEFAULT; absl::optional<bool> auth_result_; - base::OneShotTimer reset_state_; - // Affects DISABLED_FROM_TIMEOUT message. bool can_use_pin_ = false; bool available_ = true;
diff --git a/ash/login/ui/login_auth_factors_view.cc b/ash/login/ui/login_auth_factors_view.cc index d981642..ee16b12 100644 --- a/ash/login/ui/login_auth_factors_view.cc +++ b/ash/login/ui/login_auth_factors_view.cc
@@ -7,13 +7,13 @@ #include "ash/login/ui/login_auth_factors_view.h" #include "ash/login/ui/arrow_button_view.h" -#include "ash/login/ui/auth_factor_model.h" #include "ash/login/ui/auth_icon_view.h" #include "ash/resources/vector_icons/vector_icons.h" #include "ash/strings/grit/ash_strings.h" #include "ash/style/ash_color_provider.h" #include "base/callback.h" #include "base/logging.h" +#include "base/time/time.h" #include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #include "ui/base/l10n/l10n_util.h" @@ -28,14 +28,13 @@ namespace { -using AuthFactorState = AuthFactorModel::AuthFactorState; - constexpr int kAuthFactorsViewWidthDp = 204; constexpr int kSpacingBetweenIconsAndLabelDp = 15; constexpr int kIconTopSpacingDp = 20; constexpr int kArrowButtonSizeDp = 32; constexpr int kSpacingBetweenIconsDp = 28; constexpr int kIconSizeDp = 32; +constexpr base::TimeDelta kErrorTimeout = base::Seconds(3); // Return the AuthFactorModel whose AuthFactorState has the highest priority. // "Priority" here roughly corresponds with how close the given state is to @@ -208,11 +207,18 @@ } SetVisible(true); + if (active_auth_factor->GetAuthFactorState() != + AuthFactorState::kErrorTemporary) { + error_timer_.Stop(); + } + int ready_label_id; switch (active_auth_factor->GetAuthFactorState()) { case AuthFactorState::kAuthenticated: // An auth factor has successfully authenticated. Show a green checkmark. ShowCheckmark(); + // TODO(crbug.com/1233614): If we're on the login page, show "Signed in" + // instead of "Unlocked" SetLabelTextAndAccessibleName(IDS_AUTH_FACTOR_LABEL_UNLOCKED, IDS_AUTH_FACTOR_LABEL_UNLOCKED); return; @@ -237,8 +243,22 @@ case AuthFactorState::kErrorTemporary: // An auth factor has an error to show temporarily. Show the error for a // period of time. - // TODO(crbug.com/1233614): Handle error timeout - FALLTHROUGH; + + // Do not replace the current error if an error is already showing. + if (error_timer_.IsRunning()) + return; + + error_timer_.Start(FROM_HERE, kErrorTimeout, + base::BindOnce(&LoginAuthFactorsView::OnErrorTimeout, + base::Unretained(this))); + + ShowSingleAuthFactor(active_auth_factor); + SetLabelTextAndAccessibleName(active_auth_factor->GetLabelId(), + active_auth_factor->GetAccessibleNameId()); + if (active_auth_factor->ShouldAnnounceLabel()) { + FireAlert(); + } + return; case AuthFactorState::kAvailable: // At least one auth factor is available, but none are ready. Show first // available auth factor. @@ -365,4 +385,15 @@ } } +void LoginAuthFactorsView::OnErrorTimeout() { + for (auto& factor : auth_factors_) { + // If additional errors occur during the error timeout, then mark all + // errors timed out instead of trying to queue them. The user can still get + // the error messages by clicking on the icons. + if (factor->GetAuthFactorState() == AuthFactorState::kErrorTemporary) { + factor->OnErrorTimeout(); + } + } +} + } // namespace ash
diff --git a/ash/login/ui/login_auth_factors_view.h b/ash/login/ui/login_auth_factors_view.h index e8d85b2..7750c740 100644 --- a/ash/login/ui/login_auth_factors_view.h +++ b/ash/login/ui/login_auth_factors_view.h
@@ -8,7 +8,9 @@ #include <memory> #include "ash/ash_export.h" +#include "ash/login/ui/auth_factor_model.h" #include "base/callback.h" +#include "base/timer/timer.h" #include "ui/views/view.h" namespace views { @@ -26,6 +28,8 @@ // login screens. class ASH_EXPORT LoginAuthFactorsView : public views::View { public: + using AuthFactorState = AuthFactorModel::AuthFactorState; + // TestApi is used for tests to get internal implementation details. class ASH_EXPORT TestApi { public: @@ -59,10 +63,6 @@ gfx::Size CalculatePreferredSize() const override; void OnThemeChanged() override; - // TODO(crbug.com/1233614): Many more methods will be added here to facilitate - // state management, especially after multiple auth factors have been - // implemented. See go/cros-smartlock-ui-revamp. - private: // Recomputes the state and updates the label and icons. Should be called // whenever any auth factor's state changes so that those changes can be @@ -88,6 +88,10 @@ // Should be called when the "click to enter" button is pressed. void ArrowButtonPressed(const ui::Event& event); + // Should be called when the error timer expires. Communicates the timeout to + // the auth factor models. + void OnErrorTimeout(); + ///////////////////////////////////////////////////////////////////////////// // Child views, owned by the Views hierarchy @@ -113,6 +117,7 @@ std::vector<std::unique_ptr<AuthFactorModel>> auth_factors_; base::RepeatingClosure on_click_to_enter_callback_; + base::OneShotTimer error_timer_; }; } // namespace ash
diff --git a/ash/login/ui/login_auth_factors_view_unittest.cc b/ash/login/ui/login_auth_factors_view_unittest.cc index baba5bf..98f1c6f 100644 --- a/ash/login/ui/login_auth_factors_view_unittest.cc +++ b/ash/login/ui/login_auth_factors_view_unittest.cc
@@ -26,6 +26,8 @@ namespace { +constexpr base::TimeDelta kErrorTimeout = base::Seconds(3); + using AuthFactorState = AuthFactorModel::AuthFactorState; class FakeAuthFactorModel : public AuthFactorModel { @@ -36,20 +38,30 @@ FakeAuthFactorModel& operator=(const FakeAuthFactorModel&) = delete; ~FakeAuthFactorModel() override = default; + // AuthFactorModel: AuthFactorState GetAuthFactorState() override { return state_; } + // AuthFactorModel: AuthFactorType GetType() override { return type_; } + // AuthFactorModel: int GetLabelId() override { return IDS_SMART_LOCK_LABEL_LOOKING_FOR_PHONE; } + // AuthFactorModel: bool ShouldAnnounceLabel() override { return should_announce_label_; } + // AuthFactorModel: int GetAccessibleNameId() override { return IDS_SMART_LOCK_LABEL_LOOKING_FOR_PHONE; } + // AuthFactorModel: void OnTapOrClickEvent() override { on_tap_or_click_event_called_ = true; } + // AuthFactorModel: + void OnErrorTimeout() override { on_error_timeout_called_ = true; } + + // AuthFactorModel: void UpdateIcon(AuthIconView* icon) override { ASSERT_TRUE(icon); icon_ = icon; @@ -62,6 +74,7 @@ AuthIconView* icon_ = nullptr; bool on_tap_or_click_event_called_ = false; bool should_announce_label_ = false; + bool on_error_timeout_called_ = false; }; class ScopedAXEventObserver : public views::AXEventObserver { @@ -92,14 +105,15 @@ } // namespace -class LoginAuthFactorsViewUnittest : public LoginTestBase { +class LoginAuthFactorsViewUnittest : public AshTestBase { public: LoginAuthFactorsViewUnittest(const LoginAuthFactorsViewUnittest&) = delete; LoginAuthFactorsViewUnittest& operator=(const LoginAuthFactorsViewUnittest&) = delete; protected: - LoginAuthFactorsViewUnittest() { + LoginAuthFactorsViewUnittest() + : AshTestBase(base::test::TaskEnvironment::TimeSource::MOCK_TIME) { feature_list_.InitAndEnableFeature(features::kSmartLockUIRevamp); } @@ -107,8 +121,7 @@ // LoginTestBase: void SetUp() override { - LoginTestBase::SetUp(); - user_ = CreateUser("user@domain.com"); + AshTestBase::SetUp(); view_ = new LoginAuthFactorsView(base::BindRepeating( &LoginAuthFactorsViewUnittest::set_click_to_enter_called, @@ -121,7 +134,6 @@ container_->SetLayoutManager(std::make_unique<views::BoxLayout>( views::BoxLayout::Orientation::kVertical)); container_->AddChildView(view_); - SetWidget(CreateWidgetWithContent(container_)); } void AddAuthFactors(std::vector<AuthFactorType> types) { @@ -132,12 +144,22 @@ } } + size_t GetVisibleIconCount() { + LoginAuthFactorsView::TestApi test_api(view_); + size_t count = 0; + for (auto* icon : test_api.auth_factor_icon_row()->children()) { + if (icon->GetVisible()) { + count++; + } + } + return count; + } + void set_click_to_enter_called(bool called) { click_to_enter_called_ = called; } base::test::ScopedFeatureList feature_list_; - LoginUserInfo user_; views::View* container_ = nullptr; // Owned by test widget view hierarchy. LoginAuthFactorsView* view_ = nullptr; // Owned by test widget view hierarchy. @@ -217,22 +239,16 @@ auth_factors_[2]->state_ = AuthFactorState::kUnavailable; test_api.UpdateState(); - EXPECT_EQ(true, test_api.auth_factor_icon_row()->GetVisible()); - EXPECT_EQ(false, test_api.checkmark_icon()->GetVisible()); - EXPECT_EQ(false, test_api.arrow_button()->GetVisible()); + EXPECT_TRUE(test_api.auth_factor_icon_row()->GetVisible()); + EXPECT_FALSE(test_api.checkmark_icon()->GetVisible()); + EXPECT_FALSE(test_api.arrow_button()->GetVisible()); // The number of icons should match the number of auth factors initialized. EXPECT_EQ(auth_factors_.size(), test_api.auth_factor_icon_row()->children().size()); // Only a single icon should be visible in the Available state. - size_t visible_icon_count = 0; - for (auto* icon : test_api.auth_factor_icon_row()->children()) { - if (icon->GetVisible()) { - visible_icon_count++; - } - } - EXPECT_EQ(1u, visible_icon_count); + EXPECT_EQ(1u, GetVisibleIconCount()); } TEST_F(LoginAuthFactorsViewUnittest, MultipleAuthFactorsInReadyState) { @@ -246,22 +262,16 @@ auth_factors_[2]->state_ = AuthFactorState::kReady; test_api.UpdateState(); - EXPECT_EQ(true, test_api.auth_factor_icon_row()->GetVisible()); - EXPECT_EQ(false, test_api.checkmark_icon()->GetVisible()); - EXPECT_EQ(false, test_api.arrow_button()->GetVisible()); + EXPECT_TRUE(test_api.auth_factor_icon_row()->GetVisible()); + EXPECT_FALSE(test_api.checkmark_icon()->GetVisible()); + EXPECT_FALSE(test_api.arrow_button()->GetVisible()); // The number of icons should match the number of auth factors initialized. EXPECT_EQ(auth_factors_.size(), test_api.auth_factor_icon_row()->children().size()); // Only the two ready auth factors should be visible. - size_t visible_icon_count = 0; - for (auto* icon : test_api.auth_factor_icon_row()->children()) { - if (icon->GetVisible()) { - visible_icon_count++; - } - } - EXPECT_EQ(2u, visible_icon_count); + EXPECT_EQ(2u, GetVisibleIconCount()); // Check that the combined label for Smart Lock and Fingerprint is chosen. EXPECT_EQ( @@ -278,9 +288,9 @@ // Check that only the arrow button is shown and that the label has been // updated. - EXPECT_EQ(true, test_api.arrow_button()->GetVisible()); - EXPECT_EQ(false, test_api.checkmark_icon()->GetVisible()); - EXPECT_EQ(false, test_api.auth_factor_icon_row()->GetVisible()); + EXPECT_TRUE(test_api.arrow_button()->GetVisible()); + EXPECT_FALSE(test_api.checkmark_icon()->GetVisible()); + EXPECT_FALSE(test_api.auth_factor_icon_row()->GetVisible()); EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTH_FACTOR_LABEL_CLICK_TO_ENTER), test_api.label()->GetText()); } @@ -294,14 +304,31 @@ // Check that only the arrow button is shown and that the label has been // updated. - EXPECT_EQ(true, test_api.checkmark_icon()->GetVisible()); - EXPECT_EQ(false, test_api.arrow_button()->GetVisible()); - EXPECT_EQ(false, test_api.auth_factor_icon_row()->GetVisible()); + EXPECT_TRUE(test_api.checkmark_icon()->GetVisible()); + EXPECT_FALSE(test_api.arrow_button()->GetVisible()); + EXPECT_FALSE(test_api.auth_factor_icon_row()->GetVisible()); EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTH_FACTOR_LABEL_UNLOCKED), test_api.label()->GetText()); } -// TODO(crbug.com/1233614): Test adding multiple auth factors and switching -// between them once the functionality has been implemented. +TEST_F(LoginAuthFactorsViewUnittest, ErrorTemporary) { + AddAuthFactors({AuthFactorType::kFingerprint, AuthFactorType::kSmartLock}); + LoginAuthFactorsView::TestApi test_api(view_); + auth_factors_[0]->state_ = AuthFactorState::kErrorTemporary; + auth_factors_[1]->state_ = AuthFactorState::kReady; + test_api.UpdateState(); + + EXPECT_TRUE(test_api.auth_factor_icon_row()->GetVisible()); + EXPECT_FALSE(test_api.checkmark_icon()->GetVisible()); + EXPECT_FALSE(test_api.arrow_button()->GetVisible()); + + // Only the error should be visible for the first three seconds after the + // state update. + EXPECT_EQ(1u, GetVisibleIconCount()); + + ASSERT_FALSE(auth_factors_[0]->on_error_timeout_called_); + task_environment()->FastForwardBy(kErrorTimeout); + EXPECT_TRUE(auth_factors_[0]->on_error_timeout_called_); +} } // namespace ash
diff --git a/ash/login/ui/smart_lock_auth_factor_model.cc b/ash/login/ui/smart_lock_auth_factor_model.cc index 3e69ea6..87e42d6 100644 --- a/ash/login/ui/smart_lock_auth_factor_model.cc +++ b/ash/login/ui/smart_lock_auth_factor_model.cc
@@ -67,10 +67,9 @@ AuthFactorModel::AuthFactorState SmartLockAuthFactorModel::GetAuthFactorState() { - // TODO(crbug.com/1233614): Handle all SmartLockState values appropriately. if (auth_result_.has_value()) { return auth_result_.value() ? AuthFactorState::kAuthenticated - : AuthFactorState::kErrorTemporary; + : AuthFactorState::kErrorPermanent; } switch (state_) { @@ -88,8 +87,18 @@ return AuthFactorState::kAvailable; case SmartLockState::kPhoneAuthenticated: return AuthFactorState::kClickRequired; - default: + case SmartLockState::kPhoneFoundLockedAndProximate: return AuthFactorState::kReady; + case SmartLockState::kPasswordReentryRequired: + FALLTHROUGH; + case SmartLockState::kPrimaryUserAbsent: + FALLTHROUGH; + case SmartLockState::kPhoneNotAuthenticated: + FALLTHROUGH; + case SmartLockState::kBluetoothDisabled: + FALLTHROUGH; + case SmartLockState::kPhoneNotLockable: + return AuthFactorState::kErrorPermanent; } } @@ -146,9 +155,24 @@ } void SmartLockAuthFactorModel::UpdateIcon(AuthIconView* icon) { - const SkColor icon_color = AshColorProvider::Get()->GetContentLayerColor( + const SkColor primary_color = AshColorProvider::Get()->GetContentLayerColor( AshColorProvider::ContentLayerType::kIconColorPrimary); - const gfx::VectorIcon* vector_icon; + const SkColor disabled_color = + AshColorProvider::Get()->GetDisabledColor(primary_color); + + // TODO(crbug.com/1233614): Either find a system color to match the color in + // the Fingerprint animation png sequence, or upload new png files with the + // right color. + const SkColor alert_color = AshColorProvider::Get()->GetContentLayerColor( + AshColorProvider::ContentLayerType::kIconColorAlert); + + if (auth_result_.has_value() && !auth_result_.value()) { + // TODO(crbug.com/1233614): Get actual failure icon once asset is ready. + icon->SetImage(gfx::CreateVectorIcon(kLockScreenSmartCardFailureIcon, + kSmartLockIconSizeDp, alert_color)); + return; + } + switch (state_) { case SmartLockState::kPhoneNotFound: FALLTHROUGH; @@ -157,38 +181,39 @@ case SmartLockState::kPhoneFoundUnlockedAndDistant: FALLTHROUGH; case SmartLockState::kConnectingToPhone: - vector_icon = &kLockScreenSmartLockBluetoothIcon; - break; + icon->SetImage(gfx::CreateVectorIcon(kLockScreenSmartLockBluetoothIcon, + kSmartLockIconSizeDp, + primary_color)); + return; case SmartLockState::kPhoneFoundLockedAndProximate: - vector_icon = &kLockScreenSmartLockPhoneIcon; - break; - case SmartLockState::kPhoneAuthenticated: - // Click to enter, icon doesn't matter. - FALLTHROUGH; - case SmartLockState::kDisabled: - FALLTHROUGH; - case SmartLockState::kInactive: - FALLTHROUGH; - case SmartLockState::kBluetoothDisabled: - FALLTHROUGH; - case SmartLockState::kPhoneNotLockable: + icon->SetImage(gfx::CreateVectorIcon( + kLockScreenSmartLockPhoneIcon, kSmartLockIconSizeDp, primary_color)); + return; + case SmartLockState::kPrimaryUserAbsent: FALLTHROUGH; case SmartLockState::kPhoneNotAuthenticated: FALLTHROUGH; case SmartLockState::kPasswordReentryRequired: FALLTHROUGH; - case SmartLockState::kPrimaryUserAbsent: - vector_icon = &kLockScreenSmartLockDisabledIcon; - break; + case SmartLockState::kPhoneNotLockable: + FALLTHROUGH; + case SmartLockState::kBluetoothDisabled: + icon->SetImage(gfx::CreateVectorIcon(kLockScreenSmartLockDisabledIcon, + kSmartLockIconSizeDp, + disabled_color)); + return; + case SmartLockState::kPhoneAuthenticated: + // Click to enter -- icon handled by parent view. + FALLTHROUGH; + case SmartLockState::kDisabled: + FALLTHROUGH; + case SmartLockState::kInactive: + // Intentionally blank. + return; } - icon->SetImage( - gfx::CreateVectorIcon(*vector_icon, kSmartLockIconSizeDp, icon_color)); } -void SmartLockAuthFactorModel::OnTapOrClickEvent() { - // TODO(crbug.com/1233614): If Smart Lock is not available because of an error - // and the icon is pressed, show the particular error message. -} +void SmartLockAuthFactorModel::OnTapOrClickEvent() {} void SmartLockAuthFactorModel::OnArrowButtonTapOrClickEvent() { if (state_ == SmartLockState::kPhoneAuthenticated) { @@ -196,4 +221,6 @@ } } +void SmartLockAuthFactorModel::OnErrorTimeout() {} + } // namespace ash
diff --git a/ash/login/ui/smart_lock_auth_factor_model.h b/ash/login/ui/smart_lock_auth_factor_model.h index 1bd0c1c..7ab7cc1 100644 --- a/ash/login/ui/smart_lock_auth_factor_model.h +++ b/ash/login/ui/smart_lock_auth_factor_model.h
@@ -42,6 +42,7 @@ int GetAccessibleNameId() override; void UpdateIcon(AuthIconView* icon) override; void OnTapOrClickEvent() override; + void OnErrorTimeout() override; base::RepeatingCallback<void()> arrow_button_tap_callback_; SmartLockState state_ = SmartLockState::kInactive;
diff --git a/ash/login/ui/smart_lock_auth_factor_model_unittest.cc b/ash/login/ui/smart_lock_auth_factor_model_unittest.cc index 6777ae61..d3b6ff286 100644 --- a/ash/login/ui/smart_lock_auth_factor_model_unittest.cc +++ b/ash/login/ui/smart_lock_auth_factor_model_unittest.cc
@@ -75,27 +75,15 @@ } TEST_F(SmartLockAuthFactorModelUnittest, AvailableStates) { - smart_lock_model_->SetSmartLockState(SmartLockState::kPhoneNotFound); - EXPECT_TRUE(on_state_changed_called_); - on_state_changed_called_ = false; - EXPECT_EQ(AuthFactorState::kAvailable, model_->GetAuthFactorState()); - - smart_lock_model_->SetSmartLockState(SmartLockState::kConnectingToPhone); - EXPECT_TRUE(on_state_changed_called_); - on_state_changed_called_ = false; - EXPECT_EQ(AuthFactorState::kAvailable, model_->GetAuthFactorState()); - - smart_lock_model_->SetSmartLockState( - SmartLockState::kPhoneFoundLockedAndDistant); - EXPECT_TRUE(on_state_changed_called_); - on_state_changed_called_ = false; - EXPECT_EQ(AuthFactorState::kAvailable, model_->GetAuthFactorState()); - - smart_lock_model_->SetSmartLockState( - SmartLockState::kPhoneFoundUnlockedAndDistant); - EXPECT_TRUE(on_state_changed_called_); - on_state_changed_called_ = false; - EXPECT_EQ(AuthFactorState::kAvailable, model_->GetAuthFactorState()); + for (SmartLockState state : + {SmartLockState::kPhoneNotFound, SmartLockState::kConnectingToPhone, + SmartLockState::kPhoneFoundLockedAndDistant, + SmartLockState::kPhoneFoundUnlockedAndDistant}) { + smart_lock_model_->SetSmartLockState(state); + EXPECT_TRUE(on_state_changed_called_); + on_state_changed_called_ = false; + EXPECT_EQ(AuthFactorState::kAvailable, model_->GetAuthFactorState()); + } } TEST_F(SmartLockAuthFactorModelUnittest, ReadyStates) { @@ -142,4 +130,15 @@ false); } +TEST_F(SmartLockAuthFactorModelUnittest, NotifySmartLockAuthResult) { + smart_lock_model_->NotifySmartLockAuthResult(/*result=*/true); + EXPECT_TRUE(on_state_changed_called_); + EXPECT_EQ(AuthFactorState::kAuthenticated, model_->GetAuthFactorState()); + + on_state_changed_called_ = false; + smart_lock_model_->NotifySmartLockAuthResult(/*result=*/false); + EXPECT_TRUE(on_state_changed_called_); + EXPECT_EQ(AuthFactorState::kErrorPermanent, model_->GetAuthFactorState()); +} + } // namespace ash
diff --git a/ash/public/cpp/external_arc/BUILD.gn b/ash/public/cpp/external_arc/BUILD.gn index 94069b3..80bf86a 100644 --- a/ash/public/cpp/external_arc/BUILD.gn +++ b/ash/public/cpp/external_arc/BUILD.gn
@@ -51,7 +51,6 @@ "//ui/aura", "//ui/color", "//ui/message_center", - "//ui/native_theme", "//ui/views", "//ui/wm", ]
diff --git a/ash/public/cpp/external_arc/message_center/arc_notification_content_view.cc b/ash/public/cpp/external_arc/message_center/arc_notification_content_view.cc index 32dce49b..5d4868a 100644 --- a/ash/public/cpp/external_arc/message_center/arc_notification_content_view.cc +++ b/ash/public/cpp/external_arc/message_center/arc_notification_content_view.cc
@@ -661,9 +661,8 @@ const gfx::Size surface_size = surface_->GetSize(); if (!surface_size.IsEmpty()) { const float factor = - static_cast<float>(message_center::kNotificationWidth - - kScrollBarWidth) / - (surface_size.width()); + static_cast<float>(message_center::kNotificationWidth) / + surface_size.width(); transform.Scale(factor, factor); }
diff --git a/ash/public/cpp/external_arc/message_center/arc_notification_content_view.h b/ash/public/cpp/external_arc/message_center/arc_notification_content_view.h index f54f01a08..910cdbd 100644 --- a/ash/public/cpp/external_arc/message_center/arc_notification_content_view.h +++ b/ash/public/cpp/external_arc/message_center/arc_notification_content_view.h
@@ -15,8 +15,6 @@ #include "ui/base/metadata/metadata_header_macros.h" #include "ui/message_center/views/notification_background_painter.h" #include "ui/message_center/views/notification_control_buttons_view.h" -#include "ui/native_theme/native_theme.h" -#include "ui/native_theme/overlay_scrollbar_constants_aura.h" #include "ui/views/controls/native/native_view_host.h" #include "ui/views/widget/widget_observer.h" @@ -49,6 +47,7 @@ public: METADATA_HEADER(ArcNotificationContentView); + ArcNotificationContentView(ArcNotificationItem* item, const message_center::Notification& notification, message_center::MessageView* message_view); @@ -56,10 +55,6 @@ ArcNotificationContentView& operator=(const ArcNotificationContentView&) = delete; ~ArcNotificationContentView() override; - // Width of scrollbar, to reduce the notification content width. - constexpr static int kScrollBarWidth = - ui::kOverlayScrollbarThumbWidthPressed + ui::kOverlayScrollbarStrokeWidth; - void Update(const message_center::Notification& notification); message_center::NotificationControlButtonsView* GetControlButtonsView(); void UpdateControlButtonsVisibility();
diff --git a/ash/public/cpp/external_arc/message_center/arc_notification_view.cc b/ash/public/cpp/external_arc/message_center/arc_notification_view.cc index 299aa52a0..6eca3b5 100644 --- a/ash/public/cpp/external_arc/message_center/arc_notification_view.cc +++ b/ash/public/cpp/external_arc/message_center/arc_notification_view.cc
@@ -196,11 +196,7 @@ void ArcNotificationView::Layout() { // Setting the bounds before calling the parent to prevent double Layout. - gfx::Rect content_bounds = GetContentsBounds(); - content_bounds.set_width(content_bounds.width() - - ArcNotificationContentView::kScrollBarWidth); - - content_view_->SetBoundsRect(content_bounds); + content_view_->SetBoundsRect(GetContentsBounds()); message_center::MessageView::Layout();
diff --git a/ash/style/icon_button.cc b/ash/style/icon_button.cc deleted file mode 100644 index 6fe7f3a..0000000 --- a/ash/style/icon_button.cc +++ /dev/null
@@ -1,118 +0,0 @@ -// Copyright 2021 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/style/icon_button.h" - -#include "ash/style/ash_color_provider.h" -#include "ash/style/style_util.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/metadata/metadata_impl_macros.h" -#include "ui/gfx/canvas.h" -#include "ui/gfx/paint_vector_icon.h" -#include "ui/views/controls/highlight_path_generator.h" - -namespace ash { -namespace { - -constexpr int kSmallButtonSize = 32; -constexpr int kMediumButtonSize = 36; -constexpr int kLargeButtonSize = 48; - -// Icon size of the IconButton. Though the button has different sizes, the icon -// inside will be kept the same size. -constexpr int kIconSize = 20; - -int GetButtonSizeOnType(IconButton::Type type) { - switch (type) { - case IconButton::Type::kSmall: - case IconButton::Type::kSmallFloating: - return kSmallButtonSize; - case IconButton::Type::kMedium: - case IconButton::Type::kMediumFloating: - return kMediumButtonSize; - case IconButton::Type::kLarge: - case IconButton::Type::kLargeFloating: - return kLargeButtonSize; - } -} - -bool IsFloatingIconButton(IconButton::Type type) { - return type == IconButton::Type::kSmallFloating || - type == IconButton::Type::kMediumFloating || - type == IconButton::Type::kLargeFloating; -} - -} // namespace - -IconButton::IconButton(PressedCallback callback, - IconButton::Type type, - const gfx::VectorIcon& icon, - int accessible_name_id) - : views::ImageButton(std::move(callback)), type_(type), icon_(icon) { - const int button_size = GetButtonSizeOnType(type); - SetPreferredSize(gfx::Size(button_size, button_size)); - - SetImageHorizontalAlignment(ALIGN_CENTER); - SetImageVerticalAlignment(ALIGN_MIDDLE); - if (accessible_name_id) - SetTooltipText(l10n_util::GetStringUTF16(accessible_name_id)); - StyleUtil::SetUpInkDropForButton(this, gfx::Insets(), - /*highlight_on_hover=*/false, - /*highlight_on_focus=*/false); - views::InstallCircleHighlightPathGenerator(this); -} - -IconButton::~IconButton() = default; - -void IconButton::PaintButtonContents(gfx::Canvas* canvas) { - if (!IsFloatingIconButton(type_)) { - const gfx::Rect rect(GetContentsBounds()); - cc::PaintFlags flags; - flags.setAntiAlias(true); - flags.setColor(AshColorProvider::Get()->GetControlsLayerColor( - AshColorProvider::ControlsLayerType::kControlBackgroundColorInactive)); - flags.setStyle(cc::PaintFlags::kFill_Style); - canvas->DrawCircle(gfx::PointF(rect.CenterPoint()), rect.width() / 2, - flags); - } - - views::ImageButton::PaintButtonContents(canvas); -} - -void IconButton::OnThemeChanged() { - views::ImageButton::OnThemeChanged(); - - auto* color_provider = AshColorProvider::Get(); - const SkColor icon_color = color_provider->GetContentLayerColor( - AshColorProvider::ContentLayerType::kButtonIconColor); - - // Skip repainting if the incoming icon is the same as the current icon. If - // the icon has been painted before, |gfx::CreateVectorIcon()| will simply - // grab the ImageSkia from a cache, so it will be cheap. Note that this - // assumes that toggled/disabled images changes at the same time as the normal - // image, which it currently does. - const gfx::ImageSkia new_normal_image = - gfx::CreateVectorIcon(icon_, kIconSize, icon_color); - const gfx::ImageSkia& old_normal_image = - GetImage(views::Button::STATE_NORMAL); - if (!new_normal_image.isNull() && !old_normal_image.isNull() && - new_normal_image.BackedBySameObjectAs(old_normal_image)) { - return; - } - - SetImage(views::Button::STATE_NORMAL, new_normal_image); - SetImage( - views::Button::STATE_DISABLED, - gfx::CreateVectorIcon(icon_, kIconSize, - AshColorProvider::GetDisabledColor(icon_color))); - - views::FocusRing::Get(this)->SetColor( - AshColorProvider::Get()->GetControlsLayerColor( - AshColorProvider::ControlsLayerType::kFocusRingColor)); -} - -BEGIN_METADATA(IconButton, views::ImageButton) -END_METADATA - -} // namespace ash
diff --git a/ash/style/icon_button.h b/ash/style/icon_button.h deleted file mode 100644 index 642b4921..0000000 --- a/ash/style/icon_button.h +++ /dev/null
@@ -1,48 +0,0 @@ -// Copyright 2021 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_STYLE_ICON_BUTTON_H_ -#define ASH_STYLE_ICON_BUTTON_H_ - -#include "ui/base/metadata/metadata_header_macros.h" -#include "ui/gfx/vector_icon_types.h" -#include "ui/views/controls/button/image_button.h" - -namespace ash { - -// A circular ImageButton that can have small/medium/large different sizes. Each -// of them has the floating version, which do not have the background. -class IconButton : public views::ImageButton { - public: - METADATA_HEADER(IconButton); - - enum class Type { - kSmall, - kMedium, - kLarge, - kSmallFloating, - kMediumFloating, - kLargeFloating - }; - - IconButton(PressedCallback callback, - Type type, - const gfx::VectorIcon& icon, - int accessible_name_id); - IconButton(const IconButton&) = delete; - IconButton& operator=(const IconButton&) = delete; - ~IconButton() override; - - // views::ImageButton: - void PaintButtonContents(gfx::Canvas* canvas) override; - void OnThemeChanged() override; - - private: - const Type type_; - const gfx::VectorIcon& icon_; -}; - -} // namespace ash - -#endif // ASH_STYLE_ICON_BUTTON_H_
diff --git a/ash/system/accessibility/autoclick_menu_view.cc b/ash/system/accessibility/autoclick_menu_view.cc index d24260a..98f6a6d 100644 --- a/ash/system/accessibility/autoclick_menu_view.cc +++ b/ash/system/accessibility/autoclick_menu_view.cc
@@ -11,6 +11,7 @@ #include "ash/style/ash_color_provider.h" #include "ash/system/accessibility/floating_menu_button.h" #include "ash/system/tray/tray_constants.h" +#include "ash/system/unified/top_shortcut_button.h" #include "base/bind.h" #include "base/metrics/histogram_macros.h" #include "base/metrics/user_metrics.h"
diff --git a/ash/system/bluetooth/bluetooth_detailed_view_impl.cc b/ash/system/bluetooth/bluetooth_detailed_view_impl.cc index 23c5fa4..d2f4292 100644 --- a/ash/system/bluetooth/bluetooth_detailed_view_impl.cc +++ b/ash/system/bluetooth/bluetooth_detailed_view_impl.cc
@@ -12,7 +12,6 @@ #include "ash/shell.h" #include "ash/strings/grit/ash_strings.h" #include "ash/style/ash_color_provider.h" -#include "ash/style/icon_button.h" #include "ash/system/bluetooth/bluetooth_device_list_item_view.h" #include "ash/system/bluetooth/bluetooth_disabled_detailed_view.h" #include "ash/system/model/system_tray_model.h" @@ -21,6 +20,7 @@ #include "ash/system/tray/tray_popup_utils.h" #include "ash/system/tray/tray_toggle_button.h" #include "ash/system/tray/tri_view.h" +#include "ash/system/unified/top_shortcut_button.h" #include "base/check.h" #include "base/memory/ptr_util.h" #include "ui/base/l10n/l10n_util.h" @@ -151,10 +151,10 @@ hover_highlight_view->SetID(static_cast<int>( BluetoothDetailedViewChildId::kPairNewDeviceClickableView)); - std::unique_ptr<ash::IconButton> button = std::make_unique<ash::IconButton>( - views::Button::PressedCallback(), IconButton::Type::kSmall, - kSystemMenuBluetoothPlusIcon, - IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIR_NEW_DEVICE); + std::unique_ptr<ash::TopShortcutButton> button = + std::make_unique<ash::TopShortcutButton>( + views::Button::PressedCallback(), kSystemMenuBluetoothPlusIcon, + IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIR_NEW_DEVICE); button->SetCanProcessEventsWithinSubtree(/*can_process=*/false); button->SetFocusBehavior( /*focus_behavior=*/views::View::FocusBehavior::NEVER);
diff --git a/ash/system/bluetooth/bluetooth_detailed_view_unittest.cc b/ash/system/bluetooth/bluetooth_detailed_view_unittest.cc index c489baf..1e4a2f9d 100644 --- a/ash/system/bluetooth/bluetooth_detailed_view_unittest.cc +++ b/ash/system/bluetooth/bluetooth_detailed_view_unittest.cc
@@ -9,11 +9,11 @@ #include "ash/constants/ash_features.h" #include "ash/public/cpp/test/test_system_tray_client.h" #include "ash/strings/grit/ash_strings.h" -#include "ash/style/icon_button.h" #include "ash/system/bluetooth/bluetooth_detailed_view_impl.h" #include "ash/system/bluetooth/bluetooth_device_list_item_view.h" #include "ash/system/bluetooth/bluetooth_disabled_detailed_view.h" #include "ash/system/tray/detailed_view_delegate.h" +#include "ash/system/unified/top_shortcut_button.h" #include "ash/test/ash_test_base.h" #include "base/run_loop.h" #include "base/test/scoped_feature_list.h" @@ -127,8 +127,8 @@ AshTestBase::TearDown(); } - ash::IconButton* FindPairNewDeviceClickableView() { - return FindViewById<ash::IconButton*>( + ash::TopShortcutButton* FindPairNewDeviceClickableView() { + return FindViewById<ash::TopShortcutButton*>( BluetoothDetailedViewImpl::BluetoothDetailedViewChildId:: kPairNewDeviceClickableView); } @@ -251,7 +251,8 @@ } TEST_F(BluetoothDetailedViewTest, PressingPairNewDeviceNotifiesDelegate) { - IconButton* pair_new_device_button = FindPairNewDeviceClickableView(); + ash::TopShortcutButton* pair_new_device_button = + FindPairNewDeviceClickableView(); views::View* pair_new_device_view = FindPairNewDeviceView(); EXPECT_FALSE(pair_new_device_view->GetVisible()); @@ -265,7 +266,8 @@ } TEST_F(BluetoothDetailedViewTest, PairNewDeviceButtonIsCentered) { - IconButton* pair_new_device_button = FindPairNewDeviceClickableView(); + ash::TopShortcutButton* pair_new_device_button = + FindPairNewDeviceClickableView(); views::View* pair_new_device_view = FindPairNewDeviceView(); bluetooth_detailed_view()->UpdateBluetoothEnabledState(true);
diff --git a/ash/system/ime_menu/ime_menu_tray.cc b/ash/system/ime_menu/ime_menu_tray.cc index 867f523..44300131 100644 --- a/ash/system/ime_menu/ime_menu_tray.cc +++ b/ash/system/ime_menu/ime_menu_tray.cc
@@ -17,7 +17,6 @@ #include "ash/shell.h" #include "ash/strings/grit/ash_strings.h" #include "ash/style/ash_color_provider.h" -#include "ash/style/icon_button.h" #include "ash/system/ime_menu/ime_list_view.h" #include "ash/system/model/system_tray_model.h" #include "ash/system/tray/detailed_view_delegate.h" @@ -28,6 +27,7 @@ #include "ash/system/tray/tray_container.h" #include "ash/system/tray/tray_popup_utils.h" #include "ash/system/tray/tray_utils.h" +#include "ash/system/unified/top_shortcut_button.h" #include "base/bind.h" #include "base/metrics/histogram_macros.h" #include "base/metrics/user_metrics.h" @@ -149,14 +149,13 @@ TrayPopupUtils::FontStyle::kPodMenuHeader); SetFlexForView(title_label, 1); - settings_button_ = AddChildView(std::make_unique<IconButton>( + settings_button_ = AddChildView(std::make_unique<TopShortcutButton>( base::BindRepeating([]() { base::RecordAction( base::UserMetricsAction("StatusArea_IME_Detailed")); Shell::Get()->system_tray_model()->client()->ShowIMESettings(); }), - IconButton::Type::kSmall, kSystemMenuSettingsIcon, - IDS_ASH_STATUS_TRAY_IME_SETTINGS)); + kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS)); settings_button_->SetEnabled(TrayPopupUtils::CanOpenWebUISettings()); } ImeTitleView(const ImeTitleView&) = delete; @@ -165,7 +164,7 @@ ~ImeTitleView() override = default; private: - IconButton* settings_button_ = nullptr; + TopShortcutButton* settings_button_ = nullptr; }; BEGIN_METADATA(ImeTitleView, views::BoxLayoutView)
diff --git a/ash/system/media/media_tray.cc b/ash/system/media/media_tray.cc index 94695a4..824e361 100644 --- a/ash/system/media/media_tray.cc +++ b/ash/system/media/media_tray.cc
@@ -172,10 +172,9 @@ } MediaTray::PinButton::PinButton() - : IconButton( + : TopShortcutButton( base::BindRepeating(&PinButton::ButtonPressed, base::Unretained(this)), - IconButton::Type::kSmall, MediaTray::IsPinnedToShelf() ? kPinnedIcon : kUnpinnedIcon, MediaTray::IsPinnedToShelf() ? IDS_ASH_GLOBAL_MEDIA_CONTROLS_PINNED_BUTTON_TOOLTIP_TEXT
diff --git a/ash/system/media/media_tray.h b/ash/system/media/media_tray.h index 1e12e0bc..b58b69ce 100644 --- a/ash/system/media/media_tray.h +++ b/ash/system/media/media_tray.h
@@ -7,9 +7,9 @@ #include "ash/ash_export.h" #include "ash/public/cpp/session/session_observer.h" -#include "ash/style/icon_button.h" #include "ash/system/media/media_notification_provider_observer.h" #include "ash/system/tray/tray_background_view.h" +#include "ash/system/unified/top_shortcut_button.h" class PrefChangeRegistrar; class PrefRegistrySimple; @@ -39,7 +39,7 @@ // Pin button showed in media tray bubble's title view and media controls // detailed view's title view. - class PinButton : public IconButton { + class PinButton : public TopShortcutButton { public: PinButton(); ~PinButton() override = default;
diff --git a/ash/system/message_center/ash_notification_view.cc b/ash/system/message_center/ash_notification_view.cc index e0b6d49..6f20cb74 100644 --- a/ash/system/message_center/ash_notification_view.cc +++ b/ash/system/message_center/ash_notification_view.cc
@@ -387,7 +387,8 @@ : kGroupedNotificationsCollapsedSpacing) .Build()); - AddChildView(CreateActionsRow()); + AddChildView(CreateActionsRow(std::make_unique<views::BoxLayout>( + views::BoxLayout::Orientation::kHorizontal))); // Custom paddings for `AshNotificationView`. static_cast<views::BoxLayout*>(action_buttons_row()->GetLayoutManager())
diff --git a/ash/system/network/network_section_header_view.cc b/ash/system/network/network_section_header_view.cc index aae428c..33e762b 100644 --- a/ash/system/network/network_section_header_view.cc +++ b/ash/system/network/network_section_header_view.cc
@@ -10,7 +10,6 @@ #include "ash/session/session_controller_impl.h" #include "ash/shell.h" #include "ash/strings/grit/ash_strings.h" -#include "ash/style/icon_button.h" #include "ash/system/bluetooth/bluetooth_power_controller.h" #include "ash/system/model/system_tray_model.h" #include "ash/system/network/tray_network_state_model.h" @@ -359,10 +358,10 @@ can_add_esim_button_be_enabled_ = enabled; const gfx::VectorIcon& icon = base::i18n::IsRTL() ? kAddCellularNetworkRtlIcon : kAddCellularNetworkIcon; - add_esim_button_ = new IconButton( + add_esim_button_ = new TopShortcutButton( base::BindRepeating(&MobileSectionHeaderView::AddCellularButtonPressed, base::Unretained(this)), - IconButton::Type::kSmall, icon, GetAddESimTooltipMessageId()); + icon, GetAddESimTooltipMessageId()); add_esim_button_->SetEnabled(enabled && !IsCellularDeviceInhibited()); @@ -420,11 +419,10 @@ } void WifiSectionHeaderView::AddExtraButtons(bool enabled) { - auto* join_button = new IconButton( + auto* join_button = new TopShortcutButton( base::BindRepeating(&WifiSectionHeaderView::JoinButtonPressed, base::Unretained(this)), - IconButton::Type::kSmall, vector_icons::kWifiAddIcon, - IDS_ASH_STATUS_TRAY_OTHER_WIFI); + vector_icons::kWifiAddIcon, IDS_ASH_STATUS_TRAY_OTHER_WIFI); join_button->SetEnabled(enabled); container()->AddView(TriView::Container::END, join_button); join_button_ = join_button;
diff --git a/ash/system/network/network_section_header_view.h b/ash/system/network/network_section_header_view.h index 96ab31d7..b00b78a 100644 --- a/ash/system/network/network_section_header_view.h +++ b/ash/system/network/network_section_header_view.h
@@ -9,6 +9,7 @@ #include "ash/system/network/tray_network_state_observer.h" #include "ash/system/tray/tray_popup_utils.h" #include "ash/system/tray/tri_view.h" +#include "ash/system/unified/top_shortcut_button.h" #include "base/memory/weak_ptr.h" #include "base/timer/timer.h" #include "chromeos/services/network_config/public/mojom/cros_network_config.mojom-forward.h" @@ -18,7 +19,6 @@ namespace ash { -class IconButton; class TrayNetworkStateModel; namespace tray { @@ -132,7 +132,7 @@ // Button that navigates to the Settings mobile data subpage with the eSIM // setup dialog open. This is null when the device is not eSIM-capable. - IconButton* add_esim_button_ = nullptr; + TopShortcutButton* add_esim_button_ = nullptr; // Indicates whether add_esim_button_ should be enabled when the device is // not inhibited. @@ -164,7 +164,7 @@ void JoinButtonPressed(); // A button to invoke "Join Wi-Fi network" dialog. - IconButton* join_button_ = nullptr; + views::Button* join_button_ = nullptr; }; } // namespace tray
diff --git a/ash/system/palette/palette_tray.cc b/ash/system/palette/palette_tray.cc index 674b3c0..7aa0433 100644 --- a/ash/system/palette/palette_tray.cc +++ b/ash/system/palette/palette_tray.cc
@@ -18,7 +18,6 @@ #include "ash/shell.h" #include "ash/strings/grit/ash_strings.h" #include "ash/style/ash_color_provider.h" -#include "ash/style/icon_button.h" #include "ash/system/model/system_tray_model.h" #include "ash/system/palette/palette_tool_manager.h" #include "ash/system/palette/palette_utils.h" @@ -29,6 +28,7 @@ #include "ash/system/tray/tray_container.h" #include "ash/system/tray/tray_popup_utils.h" #include "ash/system/tray/tray_utils.h" +#include "ash/system/unified/top_shortcut_button.h" #include "base/bind.h" #include "base/metrics/histogram_macros.h" #include "components/pref_registry/pref_registry_syncable.h" @@ -168,24 +168,22 @@ AshColorProvider::ContentLayerType::kSeparatorColor)); } - help_button_ = AddChildView(std::make_unique<IconButton>( + help_button_ = AddChildView(std::make_unique<TopShortcutButton>( base::BindRepeating( &TitleView::ButtonPressed, base::Unretained(this), PaletteTrayOptions::PALETTE_HELP_BUTTON, base::BindRepeating( &SystemTrayClient::ShowPaletteHelp, base::Unretained(Shell::Get()->system_tray_model()->client()))), - IconButton::Type::kSmall, kSystemMenuHelpIcon, - IDS_ASH_STATUS_TRAY_HELP)); - settings_button_ = AddChildView(std::make_unique<IconButton>( + kSystemMenuHelpIcon, IDS_ASH_STATUS_TRAY_HELP)); + settings_button_ = AddChildView(std::make_unique<TopShortcutButton>( base::BindRepeating( &TitleView::ButtonPressed, base::Unretained(this), PaletteTrayOptions::PALETTE_SETTINGS_BUTTON, base::BindRepeating( &SystemTrayClient::ShowPaletteSettings, base::Unretained(Shell::Get()->system_tray_model()->client()))), - IconButton::Type::kSmall, kSystemMenuSettingsIcon, - IDS_ASH_PALETTE_SETTINGS)); + kSystemMenuSettingsIcon, IDS_ASH_PALETTE_SETTINGS)); } TitleView(const TitleView&) = delete;
diff --git a/ash/system/phonehub/phone_status_view.cc b/ash/system/phonehub/phone_status_view.cc index fb181e01..2beb275 100644 --- a/ash/system/phonehub/phone_status_view.cc +++ b/ash/system/phonehub/phone_status_view.cc
@@ -12,7 +12,6 @@ #include "ash/root_window_controller.h" #include "ash/strings/grit/ash_strings.h" #include "ash/style/ash_color_provider.h" -#include "ash/style/icon_button.h" #include "ash/system/phonehub/phone_hub_tray.h" #include "ash/system/phonehub/phone_hub_view_ids.h" #include "ash/system/status_area_widget.h" @@ -135,10 +134,10 @@ separator_->SetPreferredHeight(kSeparatorHeight); AddView(TriView::Container::CENTER, separator_); - settings_button_ = new IconButton( + settings_button_ = new TopShortcutButton( base::BindRepeating(&Delegate::OpenConnectedDevicesSettings, base::Unretained(delegate)), - IconButton::Type::kSmall, kSystemMenuSettingsIcon, + kSystemMenuSettingsIcon, IDS_ASH_PHONE_HUB_CONNECTED_DEVICE_SETTINGS_LABEL); AddView(TriView::Container::END, settings_button_);
diff --git a/ash/system/phonehub/phone_status_view.h b/ash/system/phonehub/phone_status_view.h index 0a7d7fd..736bcc3 100644 --- a/ash/system/phonehub/phone_status_view.h +++ b/ash/system/phonehub/phone_status_view.h
@@ -9,6 +9,7 @@ #include "ash/components/phonehub/phone_model.h" #include "ash/system/power/power_status.h" #include "ash/system/tray/tri_view.h" +#include "ash/system/unified/top_shortcut_button.h" #include "base/gtest_prod_util.h" namespace views { @@ -19,8 +20,6 @@ namespace ash { -class IconButton; - // The header row at the top of the Phone Hub panel, showing phone title and // status (wifi, volime, etc.). class ASH_EXPORT PhoneStatusView : public TriView, @@ -67,7 +66,7 @@ views::ImageView* battery_icon_ = nullptr; views::Label* battery_label_ = nullptr; views::Separator* separator_ = nullptr; - IconButton* settings_button_ = nullptr; + TopShortcutButton* settings_button_ = nullptr; }; } // namespace ash
diff --git a/ash/system/phonehub/phone_status_view_unittest.cc b/ash/system/phonehub/phone_status_view_unittest.cc index 3b0d49ab9..e7b4ab75 100644 --- a/ash/system/phonehub/phone_status_view_unittest.cc +++ b/ash/system/phonehub/phone_status_view_unittest.cc
@@ -6,7 +6,6 @@ #include "ash/components/phonehub/mutable_phone_model.h" #include "ash/constants/ash_features.h" -#include "ash/style/icon_button.h" #include "ash/test/ash_test_base.h" #include "base/strings/utf_string_conversions.h" #include "base/test/scoped_feature_list.h"
diff --git a/ash/system/time/calendar_view.cc b/ash/system/time/calendar_view.cc index 72d6a55b4..d67a399 100644 --- a/ash/system/time/calendar_view.cc +++ b/ash/system/time/calendar_view.cc
@@ -6,7 +6,6 @@ #include "ash/public/cpp/ash_typography.h" #include "ash/strings/grit/ash_strings.h" -#include "ash/style/icon_button.h" #include "ash/style/pill_button.h" #include "ash/system/time/calendar_month_view.h" #include "ash/system/time/calendar_utils.h" @@ -71,6 +70,24 @@ IDS_ASH_CALENDAR_SUN, IDS_ASH_CALENDAR_MON, IDS_ASH_CALENDAR_TUE, IDS_ASH_CALENDAR_WED, IDS_ASH_CALENDAR_THU, IDS_ASH_CALENDAR_FRI, IDS_ASH_CALENDAR_SAT}; + +// The button on the header view. +class HeaderButton : public TopShortcutButton { + public: + HeaderButton(views::Button::PressedCallback callback, + const gfx::VectorIcon& icon, + int accessible_name_id) + : TopShortcutButton(std::move(callback), icon, accessible_name_id) {} + HeaderButton(const HeaderButton&) = delete; + HeaderButton& operator=(const HeaderButton&) = delete; + ~HeaderButton() override = default; + + // Does not need the background color from `TopShortcutButton`. + void PaintButtonContents(gfx::Canvas* canvas) override { + views::ImageButton::PaintButtonContents(canvas); + } +}; + // The overridden `Label` view used in `CalendarView`. class CalendarLabel : public views::Label { public: @@ -267,15 +284,15 @@ kContentHorizontalPadding)); tri_view->AddView(TriView::Container::START, header_); - down_button_ = new IconButton( + down_button_ = new HeaderButton( base::BindRepeating(&CalendarView::ScrollOneMonthWithAnimation, base::Unretained(this), /*is_scrolling_up=*/false), - IconButton::Type::kSmallFloating, vector_icons::kCaretDownIcon, + vector_icons::kCaretDownIcon, IDS_ASH_CALENDAR_DOWN_BUTTON_ACCESSIBLE_DESCRIPTION); - up_button_ = new IconButton( + up_button_ = new HeaderButton( base::BindRepeating(&CalendarView::ScrollOneMonthWithAnimation, base::Unretained(this), /*is_scrolling_up=*/true), - IconButton::Type::kSmallFloating, vector_icons::kCaretUpIcon, + vector_icons::kCaretUpIcon, IDS_ASH_CALENDAR_UP_BUTTON_ACCESSIBLE_DESCRIPTION); tri_view->AddView(TriView::Container::END, down_button_);
diff --git a/ash/system/time/calendar_view.h b/ash/system/time/calendar_view.h index cf64138..afe9cb9 100644 --- a/ash/system/time/calendar_view.h +++ b/ash/system/time/calendar_view.h
@@ -28,7 +28,6 @@ namespace ash { class CalendarMonthView; -class IconButton; // The header of the calendar view, which shows the current month and year. class CalendarHeaderView : public views::View { @@ -188,8 +187,8 @@ CalendarHeaderView* header_ = nullptr; views::Button* reset_to_today_button_ = nullptr; views::Button* settings_button_ = nullptr; - IconButton* up_button_ = nullptr; - IconButton* down_button_ = nullptr; + TopShortcutButton* up_button_ = nullptr; + TopShortcutButton* down_button_ = nullptr; // If it `is_resetting_scroll_`, we don't calculate the scroll position and we // don't need to check if we need to update the month or not.
diff --git a/ash/system/time/calendar_view_unittest.cc b/ash/system/time/calendar_view_unittest.cc index 3cda9db..c8fb3f36 100644 --- a/ash/system/time/calendar_view_unittest.cc +++ b/ash/system/time/calendar_view_unittest.cc
@@ -5,7 +5,6 @@ #include "ash/system/time/calendar_view.h" #include "ash/shell.h" -#include "ash/style/icon_button.h" #include "ash/system/time/calendar_month_view.h" #include "ash/system/time/calendar_view_controller.h" #include "ash/system/tray/detailed_view_delegate.h" @@ -110,8 +109,8 @@ return calendar_view_->reset_to_today_button_; } views::Button* settings_button() { return calendar_view_->settings_button_; } - IconButton* up_button() { return calendar_view_->up_button_; } - IconButton* down_button() { return calendar_view_->down_button_; } + TopShortcutButton* up_button() { return calendar_view_->up_button_; } + TopShortcutButton* down_button() { return calendar_view_->down_button_; } void ScrollUpOneMonth() { calendar_view_->ScrollUpOneMonthAndAutoScroll(); } void ScrollDownOneMonth() {
diff --git a/ash/system/tray/detailed_view_delegate.cc b/ash/system/tray/detailed_view_delegate.cc index b17cb70..8aff889 100644 --- a/ash/system/tray/detailed_view_delegate.cc +++ b/ash/system/tray/detailed_view_delegate.cc
@@ -7,10 +7,10 @@ #include "ash/resources/vector_icons/vector_icons.h" #include "ash/strings/grit/ash_strings.h" #include "ash/style/ash_color_provider.h" -#include "ash/style/icon_button.h" #include "ash/system/tray/hover_highlight_view.h" #include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_popup_utils.h" +#include "ash/system/unified/top_shortcut_button.h" #include "ash/system/unified/unified_system_tray_controller.h" #include "components/vector_icons/vector_icons.h" #include "ui/base/l10n/l10n_util.h" @@ -63,13 +63,12 @@ gfx::Size(0, kUnifiedDetailedViewTitleRowHeight)); } -class BackButton : public IconButton { +class BackButton : public TopShortcutButton { public: BackButton(views::Button::PressedCallback callback) - : IconButton(std::move(callback), - IconButton::Type::kSmallFloating, - kUnifiedMenuExpandIcon, - IDS_ASH_STATUS_TRAY_PREVIOUS_MENU) {} + : TopShortcutButton(std::move(callback), + kUnifiedMenuExpandIcon, + IDS_ASH_STATUS_TRAY_PREVIOUS_MENU) {} BackButton(const BackButton&) = delete; BackButton& operator=(const BackButton&) = delete; ~BackButton() override = default; @@ -183,16 +182,16 @@ views::Button* DetailedViewDelegate::CreateInfoButton( views::Button::PressedCallback callback, int info_accessible_name_id) { - return new IconButton(std::move(callback), IconButton::Type::kSmall, - kUnifiedMenuInfoIcon, info_accessible_name_id); + return new TopShortcutButton(std::move(callback), kUnifiedMenuInfoIcon, + info_accessible_name_id); } views::Button* DetailedViewDelegate::CreateSettingsButton( views::Button::PressedCallback callback, int setting_accessible_name_id) { auto* button = - new IconButton(std::move(callback), IconButton::Type::kSmall, - kUnifiedMenuSettingsIcon, setting_accessible_name_id); + new TopShortcutButton(std::move(callback), kUnifiedMenuSettingsIcon, + setting_accessible_name_id); if (!TrayPopupUtils::CanOpenWebUISettings()) button->SetEnabled(false); return button; @@ -201,8 +200,8 @@ views::Button* DetailedViewDelegate::CreateHelpButton( views::Button::PressedCallback callback) { auto* button = - new IconButton(std::move(callback), IconButton::Type::kSmall, - vector_icons::kHelpOutlineIcon, IDS_ASH_STATUS_TRAY_HELP); + new TopShortcutButton(std::move(callback), vector_icons::kHelpOutlineIcon, + IDS_ASH_STATUS_TRAY_HELP); // Help opens a web page, so treat it like Web UI settings. if (!TrayPopupUtils::CanOpenWebUISettings()) button->SetEnabled(false);
diff --git a/ash/system/unified/collapse_button.cc b/ash/system/unified/collapse_button.cc index f729ee9..4e729021 100644 --- a/ash/system/unified/collapse_button.cc +++ b/ash/system/unified/collapse_button.cc
@@ -6,18 +6,25 @@ #include "ash/resources/vector_icons/vector_icons.h" #include "ash/strings/grit/ash_strings.h" -#include "ash/style/icon_button.h" +#include "ash/style/ash_color_provider.h" +#include "ash/style/element_style.h" +#include "ash/system/tray/tray_constants.h" +#include "ash/system/tray/tray_popup_utils.h" #include "ui/base/l10n/l10n_util.h" -#include "ui/base/metadata/metadata_impl_macros.h" +#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/scoped_canvas.h" +#include "ui/views/animation/flood_fill_ink_drop_ripple.h" +#include "ui/views/animation/ink_drop_impl.h" +#include "ui/views/controls/focus_ring.h" +#include "ui/views/controls/highlight_path_generator.h" namespace ash { CollapseButton::CollapseButton(PressedCallback callback) - : IconButton(std::move(callback), - IconButton::Type::kSmallFloating, - kUnifiedMenuExpandIcon, - IDS_ASH_STATUS_TRAY_COLLAPSE) {} + : ImageButton(std::move(callback)) { + views::InstallCircleHighlightPathGenerator(this); + TrayPopupUtils::ConfigureTrayPopupButton(this); +} CollapseButton::~CollapseButton() = default; @@ -31,6 +38,10 @@ SchedulePaint(); } +gfx::Size CollapseButton::CalculatePreferredSize() const { + return gfx::Size(kTrayItemSize, kTrayItemSize); +} + void CollapseButton::PaintButtonContents(gfx::Canvas* canvas) { gfx::ScopedCanvas scoped(canvas); canvas->Translate(gfx::Vector2d(size().width() / 2, size().height() / 2)); @@ -39,7 +50,16 @@ canvas->DrawImageInt(image, -image.width() / 2, -image.height() / 2); } -BEGIN_METADATA(CollapseButton, IconButton) -END_METADATA +const char* CollapseButton::GetClassName() const { + return "CollapseButton"; +} + +void CollapseButton::OnThemeChanged() { + views::ImageButton::OnThemeChanged(); + element_style::DecorateFloatingIconButton(this, kUnifiedMenuExpandIcon); + views::FocusRing::Get(this)->SetColor( + AshColorProvider::Get()->GetControlsLayerColor( + AshColorProvider::ControlsLayerType::kFocusRingColor)); +} } // namespace ash
diff --git a/ash/system/unified/collapse_button.h b/ash/system/unified/collapse_button.h index a995aaa..239c048 100644 --- a/ash/system/unified/collapse_button.h +++ b/ash/system/unified/collapse_button.h
@@ -5,18 +5,15 @@ #ifndef ASH_SYSTEM_UNIFIED_COLLAPSE_BUTTON_H_ #define ASH_SYSTEM_UNIFIED_COLLAPSE_BUTTON_H_ -#include "ash/style/icon_button.h" -#include "ui/base/metadata/metadata_header_macros.h" +#include "ui/views/controls/button/image_button.h" namespace ash { // The button with `kUnifiedMenuExpandIcon`. This button can be set as expanded // or collapsed through SetExpandedAmount and the icon will be rotated on the // `expanded_amount_`. Expanded is the default state. -class CollapseButton : public IconButton { +class CollapseButton : public views::ImageButton { public: - METADATA_HEADER(CollapseButton); - explicit CollapseButton(PressedCallback callback); CollapseButton(const CollapseButton&) = delete; @@ -27,8 +24,11 @@ // Change the expanded state. The icon will change. void SetExpandedAmount(double expanded_amount); - // IconButton: + // views::ImageButton: + gfx::Size CalculatePreferredSize() const override; void PaintButtonContents(gfx::Canvas* canvas) override; + const char* GetClassName() const override; + void OnThemeChanged() override; private: double expanded_amount_ = 1.0;
diff --git a/ash/system/unified/top_shortcut_button.cc b/ash/system/unified/top_shortcut_button.cc new file mode 100644 index 0000000..aba140d --- /dev/null +++ b/ash/system/unified/top_shortcut_button.cc
@@ -0,0 +1,63 @@ +// 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/system/unified/top_shortcut_button.h" + +#include "ash/style/ash_color_provider.h" +#include "ash/style/element_style.h" +#include "ash/system/tray/tray_popup_utils.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" +#include "ui/gfx/canvas.h" +#include "ui/gfx/paint_vector_icon.h" +#include "ui/views/animation/flood_fill_ink_drop_ripple.h" +#include "ui/views/animation/ink_drop_highlight.h" +#include "ui/views/animation/ink_drop_impl.h" +#include "ui/views/animation/ink_drop_mask.h" +#include "ui/views/controls/focus_ring.h" +#include "ui/views/controls/highlight_path_generator.h" +#include "ui/views/view_class_properties.h" + +namespace ash { + +TopShortcutButton::TopShortcutButton(PressedCallback callback, + const gfx::VectorIcon& icon, + int accessible_name_id) + : views::ImageButton(std::move(callback)), icon_(icon) { + SetImageHorizontalAlignment(ALIGN_CENTER); + SetImageVerticalAlignment(ALIGN_MIDDLE); + if (accessible_name_id) + SetTooltipText(l10n_util::GetStringUTF16(accessible_name_id)); + TrayPopupUtils::ConfigureTrayPopupButton(this); + views::InstallCircleHighlightPathGenerator(this); +} + +TopShortcutButton::~TopShortcutButton() = default; + +void TopShortcutButton::PaintButtonContents(gfx::Canvas* canvas) { + cc::PaintFlags flags; + flags.setAntiAlias(true); + flags.setColor(AshColorProvider::Get()->GetControlsLayerColor( + AshColorProvider::ControlsLayerType::kControlBackgroundColorInactive)); + flags.setStyle(cc::PaintFlags::kFill_Style); + canvas->DrawPath(views::GetHighlightPath(this), flags); + + views::ImageButton::PaintButtonContents(canvas); +} + +void TopShortcutButton::OnThemeChanged() { + views::ImageButton::OnThemeChanged(); + element_style::DecorateSmallIconButton(this, icon_, + /*toggled_=*/false, + /*has_border=*/false); + views::FocusRing::Get(this)->SetColor( + AshColorProvider::Get()->GetControlsLayerColor( + AshColorProvider::ControlsLayerType::kFocusRingColor)); + SchedulePaint(); +} + +BEGIN_METADATA(TopShortcutButton, views::ImageButton) +END_METADATA + +} // namespace ash
diff --git a/ash/system/unified/top_shortcut_button.h b/ash/system/unified/top_shortcut_button.h new file mode 100644 index 0000000..5d51402 --- /dev/null +++ b/ash/system/unified/top_shortcut_button.h
@@ -0,0 +1,40 @@ +// 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_SYSTEM_UNIFIED_TOP_SHORTCUT_BUTTON_H_ +#define ASH_SYSTEM_UNIFIED_TOP_SHORTCUT_BUTTON_H_ + +#include "ui/base/metadata/metadata_header_macros.h" +#include "ui/gfx/vector_icon_types.h" +#include "ui/views/controls/button/image_button.h" + +namespace ash { + +// A button used in top shortcuts. Top shortcuts are small circular buttons +// shown on top of the UnifiedSystemTrayView that allows quick access to +// frequently used features e.g. lock screen, settings, and shutdown. +class TopShortcutButton : public views::ImageButton { + public: + METADATA_HEADER(TopShortcutButton); + + TopShortcutButton(PressedCallback callback, + const gfx::VectorIcon& icon, + int accessible_name_id); + + TopShortcutButton(const TopShortcutButton&) = delete; + TopShortcutButton& operator=(const TopShortcutButton&) = delete; + + ~TopShortcutButton() override; + + // views::ImageButton: + void PaintButtonContents(gfx::Canvas* canvas) override; + void OnThemeChanged() override; + + private: + const gfx::VectorIcon& icon_; +}; + +} // namespace ash + +#endif // ASH_SYSTEM_UNIFIED_TOP_SHORTCUT_BUTTON_H_
diff --git a/ash/system/unified/top_shortcuts_view.cc b/ash/system/unified/top_shortcuts_view.cc index bdb44f2..fb3609c 100644 --- a/ash/system/unified/top_shortcuts_view.cc +++ b/ash/system/unified/top_shortcuts_view.cc
@@ -15,11 +15,11 @@ #include "ash/shutdown_controller_impl.h" #include "ash/strings/grit/ash_strings.h" #include "ash/style/ash_color_provider.h" -#include "ash/style/icon_button.h" #include "ash/style/pill_button.h" #include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_popup_utils.h" #include "ash/system/unified/collapse_button.h" +#include "ash/system/unified/top_shortcut_button.h" #include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/user_chooser_detailed_view_controller.h" #include "ash/system/unified/user_chooser_view.h" @@ -202,30 +202,27 @@ } bool reboot = shell->shutdown_controller()->reboot_on_shutdown(); - - power_button_ = new IconButton( + power_button_ = new TopShortcutButton( base::BindRepeating(&UnifiedSystemTrayController::HandlePowerAction, base::Unretained(controller)), - IconButton::Type::kSmall, kUnifiedMenuPowerIcon, + kUnifiedMenuPowerIcon, reboot ? IDS_ASH_STATUS_TRAY_REBOOT : IDS_ASH_STATUS_TRAY_SHUTDOWN); power_button_->SetID(VIEW_ID_POWER_BUTTON); container_->AddChildView(power_button_); if (can_show_settings && can_lock_screen) { - lock_button_ = new IconButton( + lock_button_ = new TopShortcutButton( base::BindRepeating(&UnifiedSystemTrayController::HandleLockAction, base::Unretained(controller)), - IconButton::Type::kSmall, kUnifiedMenuLockIcon, - IDS_ASH_STATUS_TRAY_LOCK); + kUnifiedMenuLockIcon, IDS_ASH_STATUS_TRAY_LOCK); container_->AddChildView(lock_button_); } if (can_show_settings) { - settings_button_ = new IconButton( + settings_button_ = new TopShortcutButton( base::BindRepeating(&UnifiedSystemTrayController::HandleSettingsAction, base::Unretained(controller)), - IconButton::Type::kSmall, kUnifiedMenuSettingsIcon, - IDS_ASH_STATUS_TRAY_SETTINGS); + kUnifiedMenuSettingsIcon, IDS_ASH_STATUS_TRAY_SETTINGS); container_->AddChildView(settings_button_); local_state_pref_change_registrar_.Init(Shell::Get()->local_state()); local_state_pref_change_registrar_.Add(
diff --git a/ash/system/unified/top_shortcuts_view.h b/ash/system/unified/top_shortcuts_view.h index 07e7b54c..74ef741 100644 --- a/ash/system/unified/top_shortcuts_view.h +++ b/ash/system/unified/top_shortcuts_view.h
@@ -19,7 +19,7 @@ namespace ash { class CollapseButton; -class IconButton; +class TopShortcutButton; class TopShortcutsViewTest; class UnifiedSystemTrayController; @@ -76,9 +76,9 @@ views::Button* user_avatar_button_ = nullptr; views::Button* sign_out_button_ = nullptr; TopShortcutButtonContainer* container_ = nullptr; - IconButton* lock_button_ = nullptr; - IconButton* settings_button_ = nullptr; - IconButton* power_button_ = nullptr; + TopShortcutButton* lock_button_ = nullptr; + TopShortcutButton* settings_button_ = nullptr; + TopShortcutButton* power_button_ = nullptr; CollapseButton* collapse_button_ = nullptr; PrefChangeRegistrar local_state_pref_change_registrar_;
diff --git a/ash/system/unified/top_shortcuts_view_unittest.cc b/ash/system/unified/top_shortcuts_view_unittest.cc index 0fc0dbb..f93a20af 100644 --- a/ash/system/unified/top_shortcuts_view_unittest.cc +++ b/ash/system/unified/top_shortcuts_view_unittest.cc
@@ -6,8 +6,8 @@ #include "ash/constants/ash_pref_names.h" #include "ash/session/test_session_controller_client.h" -#include "ash/style/icon_button.h" #include "ash/system/unified/collapse_button.h" +#include "ash/system/unified/top_shortcut_button.h" #include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_model.h" #include "ash/test/ash_test_base.h"
diff --git a/ash/system/unified/unified_slider_view.h b/ash/system/unified/unified_slider_view.h index c0a0165..fdda64c 100644 --- a/ash/system/unified/unified_slider_view.h +++ b/ash/system/unified/unified_slider_view.h
@@ -5,8 +5,9 @@ #ifndef ASH_SYSTEM_UNIFIED_UNIFIED_SLIDER_VIEW_H_ #define ASH_SYSTEM_UNIFIED_UNIFIED_SLIDER_VIEW_H_ +#include "ash/system/unified/top_shortcut_button.h" #include "ui/gfx/vector_icon_types.h" -#include "ui/views/controls/button/image_button.h" +#include "ui/views/controls/button/button.h" #include "ui/views/controls/slider.h" #include "ui/views/view.h"
diff --git a/ash/system/unified/user_chooser_view.cc b/ash/system/unified/user_chooser_view.cc index 3d0d0c3..58bab84c 100644 --- a/ash/system/unified/user_chooser_view.cc +++ b/ash/system/unified/user_chooser_view.cc
@@ -15,12 +15,12 @@ #include "ash/shell.h" #include "ash/strings/grit/ash_strings.h" #include "ash/style/ash_color_provider.h" -#include "ash/style/icon_button.h" #include "ash/system/model/enterprise_domain_model.h" #include "ash/system/model/system_tray_model.h" #include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_popup_utils.h" #include "ash/system/tray/tri_view.h" +#include "ash/system/unified/top_shortcut_button.h" #include "ash/system/unified/top_shortcuts_view.h" #include "ash/system/unified/user_chooser_detailed_view_controller.h" #include "base/bind.h" @@ -126,9 +126,9 @@ if (user_session->user_info.type == user_manager::USER_TYPE_GUEST) { // In guest mode, the user avatar is just a disabled button pod. - auto* image_view = new IconButton( - views::Button::PressedCallback(), IconButton::Type::kSmall, - kSystemMenuGuestIcon, IDS_ASH_STATUS_TRAY_GUEST_LABEL); + auto* image_view = new TopShortcutButton(views::Button::PressedCallback(), + kSystemMenuGuestIcon, + IDS_ASH_STATUS_TRAY_GUEST_LABEL); image_view->SetEnabled(false); return image_view; } @@ -235,11 +235,11 @@ AddChildView(capture_icon_); if (has_close_button) { - AddChildView(std::make_unique<IconButton>( + AddChildView(std::make_unique<TopShortcutButton>( base::BindRepeating( &UserChooserDetailedViewController::TransitionToMainView, base::Unretained(controller)), - IconButton::Type::kSmall, views::kIcCloseIcon, IDS_APP_ACCNAME_CLOSE)); + views::kIcCloseIcon, IDS_APP_ACCNAME_CLOSE)); } SetTooltipText(GetUserItemAccessibleString(user_index));
diff --git a/ash/webui/eche_app_ui/eche_notification_click_handler.cc b/ash/webui/eche_app_ui/eche_notification_click_handler.cc index fe5b0ea..215d276 100644 --- a/ash/webui/eche_app_ui/eche_notification_click_handler.cc +++ b/ash/webui/eche_app_ui/eche_notification_click_handler.cc
@@ -44,7 +44,7 @@ app_metadata.visible_app_name, app_metadata.user_id); } else { launch_app_helper_->ShowNotification( - /* title= */ absl::nullopt, /* message= */ absl::nullopt, + app_metadata.visible_app_name, /* message= */ absl::nullopt, std::make_unique<LaunchAppHelper::NotificationInfo>( LaunchAppHelper::NotificationInfo::Category::kNative, LaunchAppHelper::NotificationInfo::NotificationType::kScreenLock));
diff --git a/ash/webui/firmware_update_ui/resources/peripheral_updates_list.html b/ash/webui/firmware_update_ui/resources/peripheral_updates_list.html index b4d3344..15b479b5 100644 --- a/ash/webui/firmware_update_ui/resources/peripheral_updates_list.html +++ b/ash/webui/firmware_update_ui/resources/peripheral_updates_list.html
@@ -4,6 +4,9 @@ } </style> <div id="container"> + <template is="dom-if" if="[[!hasFirmwareUpdates_(firmwareUpdates_)]]"> + <div id="upToDateText">All firmwares are up to date</div> + </template> <dom-repeat id="updateList" items="[[firmwareUpdates_]]" as="update"> <template> <update-card update="[[update]]"></update-card>
diff --git a/ash/webui/firmware_update_ui/resources/peripheral_updates_list.js b/ash/webui/firmware_update_ui/resources/peripheral_updates_list.js index d7f49c1..86065e9 100644 --- a/ash/webui/firmware_update_ui/resources/peripheral_updates_list.js +++ b/ash/webui/firmware_update_ui/resources/peripheral_updates_list.js
@@ -54,6 +54,14 @@ onUpdateListChanged(firmwareUpdates) { this.firmwareUpdates_ = firmwareUpdates; } + + /** + * @protected + * @return {boolean} + */ + hasFirmwareUpdates_() { + return this.firmwareUpdates_.length > 0; + } } customElements.define(
diff --git a/ash/webui/shimless_rma/resources/fake_shimless_rma_service.js b/ash/webui/shimless_rma/resources/fake_shimless_rma_service.js index d6184da..1e6d18f 100644 --- a/ash/webui/shimless_rma/resources/fake_shimless_rma_service.js +++ b/ash/webui/shimless_rma/resources/fake_shimless_rma_service.js
@@ -886,8 +886,9 @@ remote.onPowerCableStateChanged(/** @type {boolean} */ (pluggedIn)); }); if (this.automaticallyTriggerPowerCableStateObservation_) { - this.triggerPowerCableObserver(true, 1000); - this.triggerPowerCableObserver(false, 5000); + this.triggerPowerCableObserver(false, 1000); + this.triggerPowerCableObserver(true, 10000); + this.triggerPowerCableObserver(false, 15000); } }
diff --git a/ash/webui/shimless_rma/resources/wrapup_repair_complete_page.html b/ash/webui/shimless_rma/resources/wrapup_repair_complete_page.html index b9622a7..14737db 100644 --- a/ash/webui/shimless_rma/resources/wrapup_repair_complete_page.html +++ b/ash/webui/shimless_rma/resources/wrapup_repair_complete_page.html
@@ -46,7 +46,6 @@ </style> <base-page orientation="column"> - <!-- TODO(joonbug): Update text for i18n --> <div slot="header"> <h1>[[i18n('repairCompletedTitleText')]]</h1> <div>[[i18n('repairCompletedDescriptionText')]]</div> @@ -101,30 +100,41 @@ </div> </base-page> -<!-- TODO(joonbug): Update for i18n --> <cr-dialog id="logsDialog" close-text="close"> <div slot="title"> - RMA Logs + [[i18n('rmaLogsTitleText')]] </div> <div slot="body"> <div class="log">[[log_]]</div> </div> <div slot="footer"> - <cr-button id="closeLogDialogButton" on-click="onCancelClick_">Cancel</cr-button> - <cr-button id="rmaLogButton" on-click="onRmaLogButtonClick_">Save to ...</cr-button> + <cr-button id="closeLogDialogButton" on-click="onCancelClick_"> + [[i18n('rmaLogsCancelButtonText')]] + </cr-button> + <cr-button id="rmaLogButton" on-click="onRmaLogButtonClick_"> + [[i18n('rmaLogsSaveToUsbButtonText')]] + </cr-button> </div> </cr-dialog> -<!-- TODO(joonbug): Update for i18n --> +<!-- TODO(gavindodd): Confirm we need this. The cutoff button is guarded by + a check for power cable state so it could immediately shut down. --> <cr-dialog id="batteryCutDialog" close-text="close"> <div slot="title"> - Unplug your cord to cut off battery + [[i18n('batteryShutoffTitleText')]] </div> <div slot="body"> - Shut down your device to complete battery cut off + <div> + [[batteryCutInstructions_(pluggedIn_)]] + </div> </div> <div slot="footer"> - <cr-button id="closeBatteryDialogButton" on-click="onCancelClick_">Cancel</cr-button> - <cr-button id="shutdownButton" on-click="onShutdownClick_">Shut down</cr-button> + <cr-button id="closeBatteryDialogButton" on-click="onCancelClick_"> + [[i18n('batteryShutoffCancelButtonText')]] + </cr-button> + <cr-button id="shutdownButton" on-click="onShutdownClick_" + disabled$="[[pluggedIn_]]"> + [[i18n('batteryShutoffShutdownButtonText')]] + </cr-button> </div> </cr-dialog>
diff --git a/ash/webui/shimless_rma/resources/wrapup_repair_complete_page.js b/ash/webui/shimless_rma/resources/wrapup_repair_complete_page.js index 7812124..3b7603c 100644 --- a/ash/webui/shimless_rma/resources/wrapup_repair_complete_page.js +++ b/ash/webui/shimless_rma/resources/wrapup_repair_complete_page.js
@@ -95,6 +95,12 @@ } /** @protected */ + batteryCutInstructions_() { + return this.pluggedIn_ ? this.i18n('batteryShutoffUnplugMessageText') : + this.i18n('batteryShutoffShutdownMessageText'); + } + + /** @protected */ onCancelClick_() { const dialogs = /** @type {!NodeList<!CrDialogElement>} */ ( this.shadowRoot.querySelectorAll('cr-dialog'));
diff --git a/ash/webui/shimless_rma/shimless_rma.cc b/ash/webui/shimless_rma/shimless_rma.cc index 3a34671..f9b3a67 100644 --- a/ash/webui/shimless_rma/shimless_rma.cc +++ b/ash/webui/shimless_rma/shimless_rma.cc
@@ -203,6 +203,19 @@ IDS_SHIMLESS_RMA_REPAIR_COMPLETED_BATTERY_CUTOFF_DESCRIPTION}, {"repairCompletedShutoffInstructionsText", IDS_SHIMLESS_RMA_REPAIR_COMPLETED_BATTERY_CUTOFF_INSTRUCTIONS}, + {"rmaLogsTitleText", IDS_SHIMLESS_RMA_LOGS_TITLE}, + {"rmaLogsCancelButtonText", IDS_SHIMLESS_RMA_LOGS_CANCEL_BUTTON}, + {"rmaLogsSaveToUsbButtonText", IDS_SHIMLESS_RMA_LOGS_SAVE_BUTTON}, + {"batteryShutoffTitleText", IDS_SHIMLESS_BATTERY_CUTOFF_TITLE}, + {"batteryShutoffUnplugMessageText", + IDS_SHIMLESS_BATTERY_SHUTOFF_UNPLUG_MESSAGE}, + {"batteryShutoffShutdownMessageText", + IDS_SHIMLESS_BATTERY_SHUTOFF_SHUTDOWN_MESSAGE}, + {"batteryShutoffCancelButtonText", + IDS_SHIMLESS_BATTERY_SHUTOFF_CANCEL_BUTTON}, + {"batteryShutoffShutdownButtonText", + IDS_SHIMLESS_BATTERY_SHUTOFF_SHUTDOWN_BUTTON}, + // Manual disable wp page {"manuallyDisableWpTitleText", IDS_SHIMLESS_RMA_MANUALLY_DISABLE_WP_TITLE},
diff --git a/build/fuchsia/linux.sdk.sha1 b/build/fuchsia/linux.sdk.sha1 index a4b561c..846c419 100644 --- a/build/fuchsia/linux.sdk.sha1 +++ b/build/fuchsia/linux.sdk.sha1
@@ -1 +1 @@ -7.20211117.1.1 +7.20211117.2.1
diff --git a/build/fuchsia/mac.sdk.sha1 b/build/fuchsia/mac.sdk.sha1 index a4b561c..846c419 100644 --- a/build/fuchsia/mac.sdk.sha1 +++ b/build/fuchsia/mac.sdk.sha1
@@ -1 +1 @@ -7.20211117.1.1 +7.20211117.2.1
diff --git a/cc/paint/BUILD.gn b/cc/paint/BUILD.gn index 10f3a93..c408f081 100644 --- a/cc/paint/BUILD.gn +++ b/cc/paint/BUILD.gn
@@ -87,6 +87,7 @@ "skottie_resource_metadata.h", "skottie_transfer_cache_entry.cc", "skottie_transfer_cache_entry.h", + "skottie_wrapper.cc", "skottie_wrapper.h", "solid_color_analyzer.cc", "solid_color_analyzer.h",
diff --git a/cc/paint/paint_op_buffer.cc b/cc/paint/paint_op_buffer.cc index 692ac3b..ebf995a 100644 --- a/cc/paint/paint_op_buffer.cc +++ b/cc/paint/paint_op_buffer.cc
@@ -9,6 +9,7 @@ #include <utility> #include <vector> +#include "base/bind.h" #include "base/stl_util.h" #include "cc/paint/decoded_draw_image.h" #include "cc/paint/display_item_list.h" @@ -19,7 +20,6 @@ #include "cc/paint/paint_op_writer.h" #include "cc/paint/paint_record.h" #include "cc/paint/scoped_raster_flags.h" -#include "cc/paint/skottie_wrapper.h" #include "third_party/skia/include/core/SkAnnotation.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkImage.h" @@ -1639,27 +1639,25 @@ void DrawSkottieOp::Raster(const DrawSkottieOp* op, SkCanvas* canvas, const PlaybackParams& params) { - for (const auto& image_asset_pair : op->images) { - const SkottieResourceIdHash& asset_id_hash = image_asset_pair.first; - const SkottieFrameData& frame_data = image_asset_pair.second; - sk_sp<SkImage> sk_image = - GetImageAssetForRaster(frame_data, canvas, params); - DCHECK(sk_image) << "Failed to fetch SkImage for Skottie image asset " - << asset_id_hash; - if (!op->skottie->SetImageForAsset( - asset_id_hash, std::move(sk_image), - PaintFlags::FilterQualityToSkSamplingOptions(frame_data.quality))) { - NOTREACHED() << "Unknown skottie image asset received: " << asset_id_hash; - } - } - op->skottie->Draw(canvas, op->t, op->dst); + // Binding unretained references in the callback is safe because Draw()'s API + // guarantees that the callback is invoked synchronously. + op->skottie->Draw( + canvas, op->t, op->dst, + base::BindRepeating(&DrawSkottieOp::GetImageAssetForRaster, + base::Unretained(op), canvas, std::cref(params))); } -sk_sp<SkImage> DrawSkottieOp::GetImageAssetForRaster( - const SkottieFrameData& frame_data, +SkottieWrapper::FrameDataFetchResult DrawSkottieOp::GetImageAssetForRaster( SkCanvas* canvas, - const PlaybackParams& params) { - sk_sp<SkImage> sk_image; + const PlaybackParams& params, + SkottieResourceIdHash asset_id, + sk_sp<SkImage>& sk_image, + SkSamplingOptions& sampling_out) const { + auto images_iter = images.find(asset_id); + if (images_iter == images.end()) + return SkottieWrapper::FrameDataFetchResult::NO_UPDATE; + + const SkottieFrameData& frame_data = images_iter->second; if (params.image_provider) { // There is no use case for applying dark mode filters to skottie images // currently. @@ -1680,7 +1678,11 @@ if (!sk_image) sk_image = frame_data.image.GetSwSkImage(); } - return sk_image; + DCHECK(sk_image) << "Failed to fetch SkImage for Skottie image asset " + << asset_id; + sampling_out = + PaintFlags::FilterQualityToSkSamplingOptions(frame_data.quality); + return SkottieWrapper::FrameDataFetchResult::NEW_DATA_AVAILABLE; } void DrawTextBlobOp::RasterWithFlags(const DrawTextBlobOp* op,
diff --git a/cc/paint/paint_op_buffer.h b/cc/paint/paint_op_buffer.h index 11997f7..9e362309 100644 --- a/cc/paint/paint_op_buffer.h +++ b/cc/paint/paint_op_buffer.h
@@ -29,6 +29,7 @@ #include "cc/paint/paint_flags.h" #include "cc/paint/skottie_frame_data.h" #include "cc/paint/skottie_resource_metadata.h" +#include "cc/paint/skottie_wrapper.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkPath.h" @@ -49,7 +50,6 @@ class ClientPaintCache; class ImageProvider; class ServicePaintCache; -class SkottieWrapper; class TransferCacheDeserializeHelper; class TransferCacheSerializeHelper; @@ -828,10 +828,12 @@ SkottieFrameDataMap images; private: - static sk_sp<SkImage> GetImageAssetForRaster( - const SkottieFrameData& frame_data, + SkottieWrapper::FrameDataFetchResult GetImageAssetForRaster( SkCanvas* canvas, - const PlaybackParams& params); + const PlaybackParams& params, + SkottieResourceIdHash asset_id, + sk_sp<SkImage>& image_out, + SkSamplingOptions& sampling_out) const; DrawSkottieOp(); };
diff --git a/cc/paint/paint_op_buffer_unittest.cc b/cc/paint/paint_op_buffer_unittest.cc index 6a991ea3..f59f090f 100644 --- a/cc/paint/paint_op_buffer_unittest.cc +++ b/cc/paint/paint_op_buffer_unittest.cc
@@ -10,6 +10,7 @@ #include "base/cxx17_backports.h" #include "base/memory/scoped_refptr.h" #include "base/strings/stringprintf.h" +#include "base/test/bind.h" #include "cc/paint/decoded_draw_image.h" #include "cc/paint/display_item_list.h" #include "cc/paint/image_provider.h" @@ -42,6 +43,7 @@ using testing::_; using testing::AtLeast; using testing::Contains; +using testing::Key; using testing::Mock; using testing::NiceMock; using testing::NotNull; @@ -1536,18 +1538,22 @@ ValidateOps<DrawRRectOp>(buffer); } -SkottieFrameDataMap GetTestImagesForSkottie(const SkottieWrapper& skottie, +SkottieFrameDataMap GetTestImagesForSkottie(SkottieWrapper& skottie, const SkRect& skottie_rect, - PaintFlags::FilterQuality quality) { + PaintFlags::FilterQuality quality, + float t) { SkottieFrameDataMap images; - for (const auto& asset_pair : - skottie.GetImageAssetMetadata().asset_storage()) { - SkottieFrameData frame_data; - frame_data.image = CreateBitmapImage( - gfx::Size(skottie_rect.width() / 2, skottie_rect.height() / 2)); - frame_data.quality = quality; - images[HashSkottieResourceId(asset_pair.first)] = std::move(frame_data); - } + skottie.Seek( + t, base::BindLambdaForTesting([&](SkottieResourceIdHash asset_id, + sk_sp<SkImage>& image_out, + SkSamplingOptions& sampling_out) { + SkottieFrameData frame_data; + frame_data.image = CreateBitmapImage( + gfx::Size(skottie_rect.width() / 2, skottie_rect.height() / 2)); + frame_data.quality = quality; + images[asset_id] = std::move(frame_data); + return SkottieWrapper::FrameDataFetchResult::NO_UPDATE; + })); return images; } @@ -1557,7 +1563,7 @@ buffer->push<DrawSkottieOp>( test_skotties[i], test_skottie_rects[i], test_skottie_floats[i], GetTestImagesForSkottie(*test_skotties[i], test_skottie_rects[i], - PaintFlags::FilterQuality::kHigh)); + PaintFlags::FilterQuality::kHigh, /*t=*/0)); } ValidateOps<DrawSkottieOp>(buffer); } @@ -3476,7 +3482,7 @@ buffer.push<DrawSkottieOp>( skottie, input_rect, input_t, GetTestImagesForSkottie(*skottie, input_rect, - PaintFlags::FilterQuality::kHigh)); + PaintFlags::FilterQuality::kHigh, input_t)); // Serialize TestOptionsProvider options_provider; @@ -3498,29 +3504,6 @@ ASSERT_FALSE(deserialized_buffer); } -TEST(PaintOpBufferTest, DrawSkottieOpConstructorInitializesImages) { - scoped_refptr<SkottieWrapper> skottie = - CreateSkottieFromString(kLottieDataWith2Assets); - SkRect skottie_rect = SkRect::MakeWH(100, 100); - SkottieFrameDataMap images_in = GetTestImagesForSkottie( - *skottie, skottie_rect, PaintFlags::FilterQuality::kHigh); - ASSERT_EQ(images_in.size(), 2u); - ASSERT_TRUE(images_in.contains(HashSkottieResourceId("image_0"))); - ASSERT_TRUE(images_in.contains(HashSkottieResourceId("image_1"))); - DrawSkottieOp skottie_op(skottie, skottie_rect, /*t=*/0.1, images_in); - ASSERT_EQ(skottie_op.images.size(), 2u); - ASSERT_TRUE(skottie_op.images.contains(HashSkottieResourceId("image_0"))); - EXPECT_EQ(skottie_op.images.at(HashSkottieResourceId("image_0")).image, - images_in.at(HashSkottieResourceId("image_0")).image); - EXPECT_EQ(skottie_op.images.at(HashSkottieResourceId("image_0")).quality, - PaintFlags::FilterQuality::kHigh); - ASSERT_TRUE(skottie_op.images.contains(HashSkottieResourceId("image_1"))); - EXPECT_EQ(skottie_op.images.at(HashSkottieResourceId("image_1")).image, - images_in.at(HashSkottieResourceId("image_1")).image); - EXPECT_EQ(skottie_op.images.at(HashSkottieResourceId("image_1")).quality, - PaintFlags::FilterQuality::kHigh); -} - TEST(PaintOpBufferTest, DrawSkottieOpRasterWithoutImageAssets) { scoped_refptr<SkottieWrapper> skottie = CreateSkottie(gfx::Size(100, 100), /*duration_secs=*/5); @@ -3540,7 +3523,7 @@ CreateSkottieFromString(kLottieDataWith2Assets); SkRect skottie_rect = SkRect::MakeWH(100, 100); SkottieFrameDataMap images_in = GetTestImagesForSkottie( - *skottie, skottie_rect, PaintFlags::FilterQuality::kHigh); + *skottie, skottie_rect, PaintFlags::FilterQuality::kHigh, /*t=*/0.1f); ASSERT_FALSE(images_in.empty()); DrawSkottieOp skottie_op(skottie, skottie_rect, /*t=*/0.1, images_in); PlaybackParams playback_params(/*image_provider=*/nullptr); @@ -3559,10 +3542,6 @@ scoped_refptr<SkottieWrapper> skottie = CreateSkottieFromString(kLottieDataWith2Assets); SkRect skottie_rect = SkRect::MakeWH(100, 100); - SkottieFrameDataMap images_in = GetTestImagesForSkottie( - *skottie, skottie_rect, PaintFlags::FilterQuality::kHigh); - ASSERT_FALSE(images_in.empty()); - DrawSkottieOp skottie_op(skottie, skottie_rect, /*t=*/0.1, images_in); std::vector<SkSize> src_rect_offset = {SkSize::Make(2.0f, 2.0f), SkSize::Make(3.0f, 3.0f)}; std::vector<SkSize> scale_adjustment = {SkSize::Make(0.2f, 0.2f), @@ -3574,15 +3553,29 @@ PlaybackParams playback_params(&image_provider); ASSERT_TRUE(image_provider.decoded_images().empty()); { + SkottieFrameDataMap images_in = GetTestImagesForSkottie( + *skottie, skottie_rect, PaintFlags::FilterQuality::kHigh, /*t=*/0.25f); + ASSERT_THAT(images_in, Contains(Key(HashSkottieResourceId("image_0")))); + DrawSkottieOp skottie_op(skottie, skottie_rect, /*t=*/0.25, images_in); + NiceMock<MockCanvas> canvas; + EXPECT_CALL(canvas, onDrawImage2(NotNull(), _, _, _, _)).Times(AtLeast(1)); + DrawSkottieOp::Raster(&skottie_op, &canvas, playback_params); + ASSERT_EQ(image_provider.decoded_images().size(), 1u); + EXPECT_THAT(image_provider.decoded_images(), + Contains(MatchesPaintImage( + images_in.at(HashSkottieResourceId("image_0")).image))); + } + { + SkottieFrameDataMap images_in = GetTestImagesForSkottie( + *skottie, skottie_rect, PaintFlags::FilterQuality::kHigh, /*t=*/0.75f); + ASSERT_THAT(images_in, Contains(Key(HashSkottieResourceId("image_1")))); + DrawSkottieOp skottie_op(skottie, skottie_rect, /*t=*/0.75, images_in); NiceMock<MockCanvas> canvas; EXPECT_CALL(canvas, onDrawImage2(NotNull(), _, _, _, _)).Times(AtLeast(1)); DrawSkottieOp::Raster(&skottie_op, &canvas, playback_params); ASSERT_EQ(image_provider.decoded_images().size(), 2u); EXPECT_THAT(image_provider.decoded_images(), Contains(MatchesPaintImage( - images_in.at(HashSkottieResourceId("image_0")).image))); - EXPECT_THAT(image_provider.decoded_images(), - Contains(MatchesPaintImage( images_in.at(HashSkottieResourceId("image_1")).image))); } } @@ -3601,7 +3594,7 @@ CreateSkottieFromString(kLottieDataWith2Assets); SkRect skottie_rect = SkRect::MakeWH(100, 100); SkottieFrameDataMap images_in = GetTestImagesForSkottie( - *skottie, skottie_rect, PaintFlags::FilterQuality::kHigh); + *skottie, skottie_rect, PaintFlags::FilterQuality::kHigh, /*t=*/0.1f); ASSERT_FALSE(images_in.empty()); buffer.push<DrawSkottieOp>(skottie, skottie_rect, /*t=*/0.1f, images_in); EXPECT_TRUE(buffer.HasDiscardableImages()); @@ -3619,7 +3612,7 @@ CreateSkottieFromString(kLottieDataWith2Assets); SkRect skottie_rect = SkRect::MakeWH(100, 100); SkottieFrameDataMap images_in = GetTestImagesForSkottie( - *skottie, skottie_rect, PaintFlags::FilterQuality::kHigh); + *skottie, skottie_rect, PaintFlags::FilterQuality::kHigh, /*t=*/0.1f); ASSERT_FALSE(images_in.empty()); DrawSkottieOp op(skottie, skottie_rect, /*t=*/0.1f, images_in); EXPECT_TRUE(PaintOp::OpHasDiscardableImages(&op));
diff --git a/cc/paint/skia_paint_canvas.cc b/cc/paint/skia_paint_canvas.cc index f1aa6fe..e0fd5b66 100644 --- a/cc/paint/skia_paint_canvas.cc +++ b/cc/paint/skia_paint_canvas.cc
@@ -329,7 +329,7 @@ << "Rendering skottie frames with image assets directly to a " "SkiaPaintCanvas is currently not supported."; } - skottie->Draw(canvas_, t, dst); + skottie->Draw(canvas_, t, dst, SkottieWrapper::FrameDataCallback()); } void SkiaPaintCanvas::drawTextBlob(sk_sp<SkTextBlob> blob,
diff --git a/cc/paint/skottie_mru_resource_provider.cc b/cc/paint/skottie_mru_resource_provider.cc index 44331a6..5a0c59d 100644 --- a/cc/paint/skottie_mru_resource_provider.cc +++ b/cc/paint/skottie_mru_resource_provider.cc
@@ -8,38 +8,50 @@ #include "base/check.h" #include "base/logging.h" +#include "third_party/skia/include/core/SkImage.h" +#include "third_party/skia/include/core/SkRefCnt.h" namespace cc { +namespace { -SkottieMRUResourceProvider::ImageAsset::ImageAsset( - base::StringPiece resource_id) - : resource_id_(resource_id) { - // The thread on which the animation is loaded may not necessarily match the - // thread on which rendering occurs; hence, detach the SequenceChecker. - DETACH_FROM_SEQUENCE(render_sequence_checker_); -} +class ImageAssetImpl : public skresources::ImageAsset { + public: + using FrameData = skresources::ImageAsset::FrameData; + using FrameDataCallback = SkottieWrapper::FrameDataCallback; -SkottieMRUResourceProvider::ImageAsset::~ImageAsset() = default; + ImageAssetImpl(SkottieResourceIdHash asset_id, + FrameDataCallback frame_data_cb) + : asset_id_(asset_id), frame_data_cb_(std::move(frame_data_cb)) { + DCHECK(frame_data_cb_); + } -void SkottieMRUResourceProvider::ImageAsset::SetCurrentFrameData( - FrameData frame_data) { - DCHECK_CALLED_ON_VALID_SEQUENCE(render_sequence_checker_); - current_frame_data_ = std::move(frame_data); -} + bool isMultiFrame() override { return true; } -bool SkottieMRUResourceProvider::ImageAsset::isMultiFrame() { - return true; -} + FrameData getFrameData(float t) override { + FrameData new_frame_data; + SkottieWrapper::FrameDataFetchResult result = frame_data_cb_.Run( + asset_id_, new_frame_data.image, new_frame_data.sampling); + switch (result) { + case SkottieWrapper::FrameDataFetchResult::NEW_DATA_AVAILABLE: + current_frame_data_ = std::move(new_frame_data); + break; + case SkottieWrapper::FrameDataFetchResult::NO_UPDATE: + break; + } + return current_frame_data_; + } -SkottieMRUResourceProvider::FrameData -SkottieMRUResourceProvider::ImageAsset::getFrameData(float t) { - DCHECK_CALLED_ON_VALID_SEQUENCE(render_sequence_checker_); - DCHECK(current_frame_data_.image) - << "No image available for asset " << resource_id_ << " at time " << t; - return current_frame_data_; -} + private: + const SkottieResourceIdHash asset_id_; + const FrameDataCallback frame_data_cb_; + FrameData current_frame_data_; +}; -SkottieMRUResourceProvider::SkottieMRUResourceProvider() = default; +} // namespace + +SkottieMRUResourceProvider::SkottieMRUResourceProvider( + FrameDataCallback frame_data_cb) + : frame_data_cb_(std::move(frame_data_cb)) {} SkottieMRUResourceProvider::~SkottieMRUResourceProvider() = default; @@ -49,12 +61,6 @@ return image_asset_metadata_; } -const SkottieMRUResourceProvider::ImageAssetMap& -SkottieMRUResourceProvider::GetImageAssetMap() const { - DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - return image_asset_map_; -} - sk_sp<skresources::ImageAsset> SkottieMRUResourceProvider::loadImageAsset( const char resource_path[], const char resource_name[], @@ -64,9 +70,8 @@ resource_id)) { return nullptr; } - auto new_asset = sk_sp<ImageAsset>(new ImageAsset(resource_id)); - image_asset_map_[HashSkottieResourceId(resource_id)] = new_asset; - return new_asset; + return sk_make_sp<ImageAssetImpl>(HashSkottieResourceId(resource_id), + frame_data_cb_); } } // namespace cc
diff --git a/cc/paint/skottie_mru_resource_provider.h b/cc/paint/skottie_mru_resource_provider.h index 38cfa808..3140d27 100644 --- a/cc/paint/skottie_mru_resource_provider.h +++ b/cc/paint/skottie_mru_resource_provider.h
@@ -5,71 +5,27 @@ #ifndef CC_PAINT_SKOTTIE_MRU_RESOURCE_PROVIDER_H_ #define CC_PAINT_SKOTTIE_MRU_RESOURCE_PROVIDER_H_ -#include <string> - -#include "base/containers/flat_map.h" #include "base/sequence_checker.h" -#include "base/strings/string_piece.h" #include "cc/paint/paint_export.h" #include "cc/paint/skottie_resource_metadata.h" -#include "third_party/skia/include/core/SkImage.h" -#include "third_party/skia/include/core/SkRefCnt.h" +#include "cc/paint/skottie_wrapper.h" #include "third_party/skia/modules/skresources/include/SkResources.h" namespace cc { -// Provides Skottie the most recent SkImage that was "set" by the caller for -// each ImageAsset. Note this is a "multi-frame" ResourceProvider, so the caller -// is capable of supporting animations where the image assets do/don't change -// between frames. +// Provides Skottie the most recent SkImage that was returned by a +// SkottieWrapper::FrameDataCallback for each ImageAsset. Note this is a +// "multi-frame" ResourceProvider, so the caller is capable of supporting +// animations where the image assets do/don't change between frames. // -// Not thread-safe. All methods must be called from the same sequence. +// Not thread-safe. All public methods must be called from the sequence that +// SkottieMRUResourceProvider is constructed on. class CC_PAINT_EXPORT SkottieMRUResourceProvider : public skresources::ResourceProvider { public: - using FrameData = skresources::ImageAsset::FrameData; + using FrameDataCallback = SkottieWrapper::FrameDataCallback; - // Not thread-safe. All methods must be called from the same sequence; this - // should be the sequence on which skottie::Animation::render() is called. - // Note however that this may be a different sequence than the one that the - // ImageAsset was originally constructed/loaded on. - class CC_PAINT_EXPORT ImageAsset : public skresources::ImageAsset { - public: - ImageAsset(const ImageAsset&) = delete; - ImageAsset& operator=(const ImageAsset&) = delete; - - ~ImageAsset() override; - - // Sets the |frame_data| to be used for this asset in all future animation - // frames until the next SetCurrentFrameData() call overwrites it. - // - // There are no requirements for |frame_data.image|'s backing; it is up to - // the caller to decide. - // - // It is an error if no FrameData has ever been set for an asset and Skottie - // requests FrameData for it (i.e. the caller should ensure all ImageAssets - // are "set" with the appropriate FrameData before requesting Skottie render - // the next frame of interest). - void SetCurrentFrameData(FrameData frame_data); - - private: - friend class SkottieMRUResourceProvider; - - // skresources::ImageAsset implementation: - bool isMultiFrame() override; - FrameData getFrameData(float t) override; - - explicit ImageAsset(base::StringPiece resource_id); - - const std::string resource_id_; - FrameData current_frame_data_ GUARDED_BY_CONTEXT(render_sequence_checker_); - SEQUENCE_CHECKER(render_sequence_checker_); - }; - - using ImageAssetMap = - base::flat_map<SkottieResourceIdHash, sk_sp<ImageAsset>>; - - SkottieMRUResourceProvider(); + explicit SkottieMRUResourceProvider(FrameDataCallback frame_data_cb); SkottieMRUResourceProvider(const SkottieMRUResourceProvider&) = delete; SkottieMRUResourceProvider& operator=(const SkottieMRUResourceProvider&) = delete; @@ -78,9 +34,6 @@ // Contains the metadata for all currently known ImageAssets in the animation. const SkottieResourceMetadataMap& GetImageAssetMetadata() const; - // Contains all ImageAssets in the animation that Skottie has loaded thus far. - const ImageAssetMap& GetImageAssetMap() const; - private: // skresources::ResourceProvider implementation: sk_sp<skresources::ImageAsset> loadImageAsset( @@ -88,12 +41,12 @@ const char resource_name[], const char resource_id[]) const override; + const SkottieWrapper::FrameDataCallback frame_data_cb_; // SkResources.h declares loadImageAsset() as a "const" method. Although the // method is logically const, these book-keeping members need to be updated in // that method. Hence, they're marked "mutable". mutable SkottieResourceMetadataMap image_asset_metadata_ GUARDED_BY_CONTEXT(sequence_checker_); - mutable ImageAssetMap image_asset_map_ GUARDED_BY_CONTEXT(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_); };
diff --git a/cc/paint/skottie_mru_resource_provider_unittest.cc b/cc/paint/skottie_mru_resource_provider_unittest.cc index 600308e..39f0d7a 100644 --- a/cc/paint/skottie_mru_resource_provider_unittest.cc +++ b/cc/paint/skottie_mru_resource_provider_unittest.cc
@@ -4,7 +4,12 @@ #include "cc/paint/skottie_mru_resource_provider.h" +#include <utility> + +#include "base/bind.h" +#include "base/containers/flat_map.h" #include "base/files/file_path.h" +#include "base/strings/string_piece.h" #include "cc/paint/paint_image.h" #include "cc/paint/skottie_resource_metadata.h" #include "cc/test/skia_common.h" @@ -24,12 +29,51 @@ using ::testing::SizeIs; using ::testing::UnorderedElementsAre; +class FrameDataStub { + public: + using FrameData = skresources::ImageAsset::FrameData; + + void SetAssetFrameData(base::StringPiece asset_id, + FrameData current_frame_data) { + asset_to_frame_data_[HashSkottieResourceId(asset_id)] = + std::move(current_frame_data); + asset_to_result_[HashSkottieResourceId(asset_id)] = + SkottieWrapper::FrameDataFetchResult::NEW_DATA_AVAILABLE; + } + + void SetAssetResult(base::StringPiece asset_id, + SkottieWrapper::FrameDataFetchResult current_result) { + asset_to_result_[HashSkottieResourceId(asset_id)] = current_result; + } + + SkottieWrapper::FrameDataFetchResult GetFrameDataForAsset( + SkottieResourceIdHash asset_id, + sk_sp<SkImage>& image_out, + SkSamplingOptions& sampling_out) const { + if (asset_to_frame_data_.contains(asset_id)) { + image_out = asset_to_frame_data_.at(asset_id).image; + sampling_out = asset_to_frame_data_.at(asset_id).sampling; + } + return asset_to_result_.contains(asset_id) + ? asset_to_result_.at(asset_id) + : SkottieWrapper::FrameDataFetchResult::NO_UPDATE; + } + + private: + base::flat_map<SkottieResourceIdHash, FrameData> asset_to_frame_data_; + base::flat_map<SkottieResourceIdHash, SkottieWrapper::FrameDataFetchResult> + asset_to_result_; +}; + class SkottieMRUResourceProviderTest : public ::testing::Test { protected: SkottieMRUResourceProviderTest() - : provider_(sk_make_sp<SkottieMRUResourceProvider>()), + : provider_(sk_make_sp<SkottieMRUResourceProvider>( + base::BindRepeating(&FrameDataStub::GetFrameDataForAsset, + base::Unretained(&frame_data_stub_)))), provider_base_(provider_.get()) {} + FrameDataStub frame_data_stub_; const sk_sp<SkottieMRUResourceProvider> provider_; skresources::ResourceProvider* const provider_base_; }; @@ -38,18 +82,17 @@ sk_sp<skresources::ImageAsset> asset = provider_base_->loadImageAsset( "test-resource-path", "test-resource-name", "test-resource-id"); PaintImage image_1 = CreateBitmapImage(gfx::Size(10, 10)); - SkottieMRUResourceProvider::ImageAssetMap assets = - provider_->GetImageAssetMap(); - ASSERT_THAT(assets, Contains(Key(HashSkottieResourceId("test-resource-id")))); - assets[HashSkottieResourceId("test-resource-id")]->SetCurrentFrameData( - {.image = image_1.GetSwSkImage()}); + frame_data_stub_.SetAssetFrameData("test-resource-id", + {.image = image_1.GetSwSkImage()}); EXPECT_THAT(asset->getFrameData(/*t=*/0).image, Eq(image_1.GetSwSkImage())); // The same image should be re-used for the next timestamp. + frame_data_stub_.SetAssetResult( + "test-resource-id", SkottieWrapper::FrameDataFetchResult::NO_UPDATE); EXPECT_THAT(asset->getFrameData(/*t=*/0.1).image, Eq(image_1.GetSwSkImage())); // Now the new image should be used. PaintImage image_2 = CreateBitmapImage(gfx::Size(20, 20)); - assets[HashSkottieResourceId("test-resource-id")]->SetCurrentFrameData( - {.image = image_2.GetSwSkImage()}); + frame_data_stub_.SetAssetFrameData("test-resource-id", + {.image = image_2.GetSwSkImage()}); EXPECT_THAT(asset->getFrameData(/*t=*/0.2).image, Eq(image_2.GetSwSkImage())); } @@ -59,18 +102,11 @@ sk_sp<skresources::ImageAsset> asset_2 = provider_base_->loadImageAsset( "test-resource-path", "test-resource-name", "test-resource-id-2"); PaintImage image_1 = CreateBitmapImage(gfx::Size(10, 10)); - SkottieMRUResourceProvider::ImageAssetMap assets = - provider_->GetImageAssetMap(); - ASSERT_THAT(assets, SizeIs(2)); - ASSERT_THAT(assets, - Contains(Key(HashSkottieResourceId("test-resource-id-1")))); - assets[HashSkottieResourceId("test-resource-id-1")]->SetCurrentFrameData( - {.image = image_1.GetSwSkImage()}); + frame_data_stub_.SetAssetFrameData("test-resource-id-1", + {.image = image_1.GetSwSkImage()}); PaintImage image_2 = CreateBitmapImage(gfx::Size(20, 20)); - ASSERT_THAT(assets, - Contains(Key(HashSkottieResourceId("test-resource-id-2")))); - assets[HashSkottieResourceId("test-resource-id-2")]->SetCurrentFrameData( - {.image = image_2.GetSwSkImage()}); + frame_data_stub_.SetAssetFrameData("test-resource-id-2", + {.image = image_2.GetSwSkImage()}); EXPECT_THAT(asset_1->getFrameData(/*t=*/0).image, Eq(image_1.GetSwSkImage())); EXPECT_THAT(asset_2->getFrameData(/*t=*/0).image, Eq(image_2.GetSwSkImage())); }
diff --git a/cc/paint/skottie_wrapper.cc b/cc/paint/skottie_wrapper.cc new file mode 100644 index 0000000..1c12844 --- /dev/null +++ b/cc/paint/skottie_wrapper.cc
@@ -0,0 +1,17 @@ +// Copyright 2021 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 "cc/paint/skottie_wrapper.h" + +namespace cc { + +void SkottieWrapper::Seek(float t) { + Seek(t, FrameDataCallback()); +} + +void SkottieWrapper::Draw(SkCanvas* canvas, float t, const SkRect& rect) { + Draw(canvas, t, rect, FrameDataCallback()); +} + +} // namespace cc
diff --git a/cc/paint/skottie_wrapper.h b/cc/paint/skottie_wrapper.h index 3ede881..2cbcda1d 100644 --- a/cc/paint/skottie_wrapper.h +++ b/cc/paint/skottie_wrapper.h
@@ -7,6 +7,7 @@ #include <vector> +#include "base/callback.h" #include "base/containers/span.h" #include "base/memory/ref_counted.h" #include "cc/paint/paint_export.h" @@ -51,38 +52,48 @@ // does not change during SkottieWrapper's lifetime. virtual const SkottieResourceMetadataMap& GetImageAssetMetadata() const = 0; - // Sets the |image| to use for the asset in the animation with the given - // |asset_id_hash| (use GetImageAssetMetadata() to get all available assets). - // Returns false if the |asset_id_hash| is unknown. This should be invoked - // before each call to Draw(): - // - // (Set images for frame 1) - // SetImageForAsset(<asset_a>, <image_a_1>) - // SetImageForAsset(<asset_b>, <image_b_1>) - // Draw(<frame_1>) - // (Set images for frame 2) - // SetImageForAsset(<asset_a>, <image_a_2>) - // SetImageForAsset(<asset_b>, <image_b_2>) - // Draw(<frame_2>) - // ... - // - // If an image is not set for an asset before a call to Draw(), the most - // recently set image is reused for that animation frame. It is an error if no - // image has ever been set for an asset, and Draw() requires one. - // - // |sampling| controls the resampling quality when resizing the |image| for - // the animation. Skottie also supports a - // skresources::ImageAsset::FrameData::matrix field, but there is no use case - // for that currently. - // - // Must be called from the same thread as Draw(). - virtual bool SetImageForAsset(SkottieResourceIdHash asset_id_hash, - sk_sp<SkImage> image, - SkSamplingOptions sampling) = 0; + // FrameDataCallback is implemented by the caller and invoked + // synchronously during calls to Seek() and Draw(). The callback is used by + // SkottieWrapper to fetch the corresponding image for each asset that is + // present in the frame with the desired timestamp. It is invoked once for + // each asset. A null callback may be passed to Seek() and Draw() if the + // animation is known to not have any image assets. + enum class FrameDataFetchResult { + // A new image is available for the given asset, and the callback's output + // parameters have been filled with the new frame data. + NEW_DATA_AVAILABLE, + // The callback's output parameters have not been filled and will be + // ignored by SkottieWrapper. In this case, SkottieWrapper will reuse the + // frame data that was most recently provided for the given asset (it caches + // this internally). If no frame data has ever been provided for this asset, + // a null image will be passed to Skottie's Animation during Seek(); this + // is acceptable if there's no rendering. + NO_UPDATE, + }; + // The callback's implementation must synchronously fill the output + // arguments. |asset_id| is guaranteed to be a valid asset that's present + // in GetImageAssetMetadata(). + using FrameDataCallback = base::RepeatingCallback<FrameDataFetchResult( + SkottieResourceIdHash asset_id, + sk_sp<SkImage>& image_out, + SkSamplingOptions& sampling_out)>; + + // Seeks to the normalized time instant |t|, but does not render. This method + // is thread safe. + virtual void Seek(float t, FrameDataCallback frame_data_cb) = 0; + // Variant with null FrameDataCallback() if the animation does not have image + // assets. + void Seek(float t); // A thread safe call that will draw an image with bounds |rect| for the // frame at normalized time instant |t| onto the |canvas|. - virtual void Draw(SkCanvas* canvas, float t, const SkRect& rect) = 0; + virtual void Draw(SkCanvas* canvas, + float t, + const SkRect& rect, + FrameDataCallback frame_data_cb) = 0; + // Variant with null FrameDataCallback() if the animation does not have image + // assets. + void Draw(SkCanvas* canvas, float t, const SkRect& rect); virtual float duration() const = 0; virtual SkSize size() const = 0;
diff --git a/cc/paint/skottie_wrapper_impl.cc b/cc/paint/skottie_wrapper_impl.cc index 5c56c97..e031564 100644 --- a/cc/paint/skottie_wrapper_impl.cc +++ b/cc/paint/skottie_wrapper_impl.cc
@@ -4,12 +4,16 @@ #include "cc/paint/skottie_wrapper.h" +#include <functional> #include <utility> #include <vector> +#include "base/bind.h" +#include "base/callback.h" #include "base/hash/hash.h" #include "base/logging.h" #include "base/synchronization/lock.h" +#include "base/thread_annotations.h" #include "base/trace_event/trace_event.h" #include "cc/paint/skottie_mru_resource_provider.h" #include "third_party/skia/include/core/SkImage.h" @@ -39,25 +43,19 @@ class SkottieWrapperImpl : public SkottieWrapper { public: - static scoped_refptr<SkottieWrapperImpl> Create( - base::span<const uint8_t> data, - std::vector<uint8_t> owned_data) { - // The underlying assumption here is that |skottie::Animation::Builder| - // loads image assets on initialization rather than doing so lazily at - // |render()| time. This is the case currently, and there will be unit test - // failures if this does not hold at some point in the future. - const auto mru_resource_provider = sk_make_sp<SkottieMRUResourceProvider>(); - sk_sp<skottie::Animation> animation = - skottie::Animation::Builder() - .setLogger(sk_make_sp<SkottieLogWriter>()) - .setResourceProvider(skresources::CachingResourceProvider::Make( - mru_resource_provider)) - .make(reinterpret_cast<const char*>(data.data()), data.size()); - return base::WrapRefCounted(new SkottieWrapperImpl( - animation, std::move(owned_data), base::FastHash(data), - mru_resource_provider->GetImageAssetMetadata(), - mru_resource_provider->GetImageAssetMap())); - } + SkottieWrapperImpl(base::span<const uint8_t> data, + std::vector<uint8_t> owned_data) + : SkottieWrapperImpl( + data, + owned_data, + // * Unretained is safe because SkottieMRUResourceProvider cannot + // outlive SkottieWrapperImpl. + // * Binding "this" in the constructor is safe because the frame + // data callback is only triggered during calls to + // |animation_->seek()|. + sk_make_sp<SkottieMRUResourceProvider>(base::BindRepeating( + &SkottieWrapperImpl::RunCurrentFrameDataCallback, + base::Unretained(this)))) {} SkottieWrapperImpl(const SkottieWrapperImpl&) = delete; SkottieWrapperImpl& operator=(const SkottieWrapperImpl&) = delete; @@ -69,25 +67,22 @@ return image_asset_metadata_; } - bool SetImageForAsset(SkottieResourceIdHash asset_id_hash, - sk_sp<SkImage> image, - SkSamplingOptions sampling) override { - auto asset_iter = image_assets_.find(asset_id_hash); - if (asset_iter == image_assets_.end()) { - LOG(ERROR) << "Failed to set image for unknown asset with id: " - << asset_id_hash; - return false; - } - SkottieMRUResourceProvider::FrameData frame_data; - frame_data.image = std::move(image); - frame_data.sampling = sampling; - SkottieMRUResourceProvider::ImageAsset& asset = *asset_iter->second; - asset.SetCurrentFrameData(std::move(frame_data)); - return true; + void Seek(float t, FrameDataCallback frame_data_cb) override + LOCKS_EXCLUDED(lock_) { + base::AutoLock lock(lock_); + // There's no need to reset |current_frame_data_cb_| to null when finished. + // The callback is guaranteed to only be invoked synchronously during calls + // to |animation_->seek/render()|, and not thereafter. + current_frame_data_cb_ = std::move(frame_data_cb); + animation_->seek(t); } - void Draw(SkCanvas* canvas, float t, const SkRect& rect) override { + void Draw(SkCanvas* canvas, + float t, + const SkRect& rect, + FrameDataCallback frame_data_cb) override LOCKS_EXCLUDED(lock_) { base::AutoLock lock(lock_); + current_frame_data_cb_ = std::move(frame_data_cb); animation_->seek(t); animation_->render(canvas, &rect); } @@ -105,20 +100,36 @@ private: SkottieWrapperImpl( - sk_sp<skottie::Animation> animation, + base::span<const uint8_t> data, std::vector<uint8_t> raw_data, - uint32_t id, - const SkottieResourceMetadataMap& image_asset_metadata, - const SkottieMRUResourceProvider::ImageAssetMap& image_assets) - : animation_(animation), + const sk_sp<SkottieMRUResourceProvider>& mru_resource_provider) + : animation_( + skottie::Animation::Builder() + .setLogger(sk_make_sp<SkottieLogWriter>()) + .setResourceProvider(skresources::CachingResourceProvider::Make( + mru_resource_provider)) + .make(reinterpret_cast<const char*>(data.data()), data.size())), raw_data_(std::move(raw_data)), - id_(id), - image_asset_metadata_(image_asset_metadata), - image_assets_(image_assets) {} + id_(base::FastHash(data)), + // The underlying assumption here is that |skottie::Animation::Builder| + // loads image assets on initialization rather than doing so lazily at + // |render()| time. This is the case currently, and there will be unit + // test failures if this does not hold at some point in the future. + image_asset_metadata_(mru_resource_provider->GetImageAssetMetadata()) {} ~SkottieWrapperImpl() override = default; + FrameDataFetchResult RunCurrentFrameDataCallback( + SkottieResourceIdHash asset_id_hash, + sk_sp<SkImage>& image_out, + SkSamplingOptions& sampling_out) EXCLUSIVE_LOCKS_REQUIRED(lock_) { + lock_.AssertAcquired(); + DCHECK(current_frame_data_cb_); + return current_frame_data_cb_.Run(asset_id_hash, image_out, sampling_out); + } + base::Lock lock_; + FrameDataCallback current_frame_data_cb_ GUARDED_BY(lock_); sk_sp<skottie::Animation> animation_; // The raw byte data is stored for serialization across OOP-R. This is only @@ -131,7 +142,6 @@ const uint32_t id_; const SkottieResourceMetadataMap image_asset_metadata_; - const SkottieMRUResourceProvider::ImageAssetMap image_assets_; }; } // namespace @@ -140,14 +150,16 @@ scoped_refptr<SkottieWrapper> SkottieWrapper::CreateSerializable( std::vector<uint8_t> data) { base::span<const uint8_t> data_span(data); - return SkottieWrapperImpl::Create(data_span, std::move(data)); + return base::WrapRefCounted( + new SkottieWrapperImpl(data_span, std::move(data))); } // static scoped_refptr<SkottieWrapper> SkottieWrapper::CreateNonSerializable( base::span<const uint8_t> data) { - return SkottieWrapperImpl::Create(data, - /*owned_data=*/std::vector<uint8_t>()); + return base::WrapRefCounted( + new SkottieWrapperImpl(data, + /*owned_data=*/std::vector<uint8_t>())); } } // namespace cc
diff --git a/cc/paint/skottie_wrapper_unittest.cc b/cc/paint/skottie_wrapper_unittest.cc index efdab31..eff4215e 100644 --- a/cc/paint/skottie_wrapper_unittest.cc +++ b/cc/paint/skottie_wrapper_unittest.cc
@@ -8,6 +8,7 @@ #include <string> #include <vector> +#include "base/bind.h" #include "base/containers/span.h" #include "base/files/file_path.h" #include "base/memory/scoped_refptr.h" @@ -24,15 +25,32 @@ namespace cc { namespace { +using ::testing::_; using ::testing::Contains; using ::testing::Eq; +using ::testing::IsEmpty; using ::testing::Key; +using ::testing::Mock; using ::testing::Ne; using ::testing::NotNull; using ::testing::Pair; using ::testing::SizeIs; using ::testing::UnorderedElementsAre; +class MockFrameDataCallback { + public: + MOCK_METHOD(SkottieWrapper::FrameDataFetchResult, + OnAssetLoaded, + (SkottieResourceIdHash asset_id_hash, + sk_sp<SkImage>& image_out, + SkSamplingOptions& sampling_out)); + + SkottieWrapper::FrameDataCallback Get() { + return base::BindRepeating(&MockFrameDataCallback::OnAssetLoaded, + base::Unretained(this)); + } +}; + TEST(SkottieWrapperTest, LoadsValidLottieFileNonSerializable) { scoped_refptr<SkottieWrapper> skottie = SkottieWrapper::CreateNonSerializable(base::span<const uint8_t>( @@ -104,43 +122,50 @@ .NormalizePathSeparators()))); } -TEST(SkottieWrapperTest, SetImageForAsset) { +TEST(SkottieWrapperTest, LoadsCorrectAssetsForDraw) { scoped_refptr<SkottieWrapper> skottie = - SkottieWrapper::CreateNonSerializable(base::span<const uint8_t>( - reinterpret_cast<const uint8_t*>(kLottieDataWith2Assets.data()), - kLottieDataWith2Assets.length())); + CreateSkottieFromString(kLottieDataWith2Assets); ASSERT_TRUE(skottie->is_valid()); ::testing::NiceMock<MockCanvas> canvas; - EXPECT_TRUE(skottie->SetImageForAsset( - HashSkottieResourceId("image_0"), - CreateBitmapImage(gfx::Size(100, 100)).GetSwSkImage(), - SkSamplingOptions())); - EXPECT_TRUE(skottie->SetImageForAsset( - HashSkottieResourceId("image_1"), - CreateBitmapImage(gfx::Size(100, 100)).GetSwSkImage(), - SkSamplingOptions())); - skottie->Draw(&canvas, /*t=*/0.1, SkRect::MakeWH(500, 500)); - EXPECT_TRUE(skottie->SetImageForAsset( - HashSkottieResourceId("image_0"), - CreateBitmapImage(gfx::Size(200, 200)).GetSwSkImage(), - SkSamplingOptions())); - EXPECT_TRUE(skottie->SetImageForAsset( - HashSkottieResourceId("image_1"), - CreateBitmapImage(gfx::Size(200, 200)).GetSwSkImage(), - SkSamplingOptions())); - skottie->Draw(&canvas, /*t=*/0.2, SkRect::MakeWH(500, 500)); + MockFrameDataCallback mock_callback; + EXPECT_CALL(mock_callback, + OnAssetLoaded(HashSkottieResourceId("image_0"), _, _)); + skottie->Draw(&canvas, /*t=*/0.25, SkRect::MakeWH(500, 500), + mock_callback.Get()); + Mock::VerifyAndClearExpectations(&mock_callback); + + EXPECT_CALL(mock_callback, + OnAssetLoaded(HashSkottieResourceId("image_1"), _, _)); + skottie->Draw(&canvas, /*t=*/0.75, SkRect::MakeWH(500, 500), + mock_callback.Get()); + Mock::VerifyAndClearExpectations(&mock_callback); } -TEST(SkottieWrapperTest, SetImageForUnknownAsset) { +TEST(SkottieWrapperTest, AllowsNullFrameDataCallbackForDraw) { scoped_refptr<SkottieWrapper> skottie = - SkottieWrapper::CreateNonSerializable(base::span<const uint8_t>( - reinterpret_cast<const uint8_t*>(kLottieDataWith2Assets.data()), - kLottieDataWith2Assets.length())); + CreateSkottieFromString(kLottieDataWithoutAssets1); ASSERT_TRUE(skottie->is_valid()); - EXPECT_FALSE(skottie->SetImageForAsset( - HashSkottieResourceId("unknown-asset"), - CreateBitmapImage(gfx::Size(100, 100)).GetSwSkImage(), - SkSamplingOptions())); + // Just verify that this call does not cause a CHECK failure. + ::testing::NiceMock<MockCanvas> canvas; + skottie->Draw(&canvas, /*t=*/0, SkRect::MakeWH(500, 500), + SkottieWrapper::FrameDataCallback()); +} + +TEST(SkottieWrapperTest, LoadsCorrectAssetsForSeek) { + scoped_refptr<SkottieWrapper> skottie = + CreateSkottieFromString(kLottieDataWith2Assets); + ASSERT_TRUE(skottie->is_valid()); + ::testing::NiceMock<MockCanvas> canvas; + MockFrameDataCallback mock_callback; + EXPECT_CALL(mock_callback, + OnAssetLoaded(HashSkottieResourceId("image_0"), _, _)); + skottie->Seek(/*t=*/0.25, mock_callback.Get()); + Mock::VerifyAndClearExpectations(&mock_callback); + + EXPECT_CALL(mock_callback, + OnAssetLoaded(HashSkottieResourceId("image_1"), _, _)); + skottie->Seek(/*t=*/0.75, mock_callback.Get()); + Mock::VerifyAndClearExpectations(&mock_callback); } } // namespace
diff --git a/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantCollectUserDataIntegrationTest.java b/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantCollectUserDataIntegrationTest.java index a763b7f8..422ac78 100644 --- a/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantCollectUserDataIntegrationTest.java +++ b/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantCollectUserDataIntegrationTest.java
@@ -47,6 +47,7 @@ import static org.chromium.chrome.browser.autofill_assistant.ProtoTestUtil.toCssSelector; import static org.chromium.chrome.browser.autofill_assistant.ProtoTestUtil.toVisibleCssSelector; +import android.os.Build; import android.widget.DatePicker; import android.widget.RadioButton; @@ -63,6 +64,7 @@ import org.chromium.base.LocaleUtils; import org.chromium.base.test.util.CommandLineFlags; +import org.chromium.base.test.util.DisableIf; import org.chromium.chrome.autofill_assistant.R; import org.chromium.chrome.browser.autofill.PersonalDataManager; import org.chromium.chrome.browser.autofill_assistant.carousel.ButtonView; @@ -720,6 +722,8 @@ */ @Test @MediumTest + @DisableIf.Build( + message = "https://crbug.com/1271300", sdk_is_less_than = Build.VERSION_CODES.Q) public void testPopupListSection() { ArrayList<ActionProto> list = new ArrayList<>();
diff --git a/chrome/android/features/start_surface/internal/BUILD.gn b/chrome/android/features/start_surface/internal/BUILD.gn index 9a84263..67549829 100644 --- a/chrome/android/features/start_surface/internal/BUILD.gn +++ b/chrome/android/features/start_surface/internal/BUILD.gn
@@ -42,6 +42,7 @@ android_library("java") { sources = [ + "java/src/org/chromium/chrome/features/start_surface/BackgroundTabAnimation.java", "java/src/org/chromium/chrome/features/start_surface/BottomBarCoordinator.java", "java/src/org/chromium/chrome/features/start_surface/BottomBarView.java", "java/src/org/chromium/chrome/features/start_surface/BottomBarViewBinder.java", @@ -85,6 +86,7 @@ "//chrome/browser/version:java", "//chrome/browser/xsurface:java", "//components/browser_ui/bottomsheet/android:java", + "//components/browser_ui/styles/android:java", "//components/browser_ui/widget/android:java", "//components/prefs/android:java", "//components/user_prefs/android:java",
diff --git a/chrome/android/features/start_surface/internal/java/src/org/chromium/chrome/features/start_surface/BackgroundTabAnimation.java b/chrome/android/features/start_surface/internal/java/src/org/chromium/chrome/features/start_surface/BackgroundTabAnimation.java new file mode 100644 index 0000000..01f7c25 --- /dev/null +++ b/chrome/android/features/start_surface/internal/java/src/org/chromium/chrome/features/start_surface/BackgroundTabAnimation.java
@@ -0,0 +1,175 @@ +// Copyright 2021 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.features.start_surface; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.AnimatorSet; +import android.animation.ObjectAnimator; +import android.animation.TimeInterpolator; +import android.content.Context; +import android.graphics.drawable.GradientDrawable; +import android.util.Property; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import androidx.appcompat.widget.AppCompatImageView; + +import org.chromium.chrome.browser.compositor.layouts.Layout; +import org.chromium.components.browser_ui.styles.ChromeColors; +import org.chromium.components.browser_ui.widget.animation.Interpolators; + +import java.util.ArrayList; +import java.util.Collection; + +/** + * Creates an Animator for the tab-opened-in-background animation on Start Surface. + * Based on {@link SimpleAnimationLayout#tabCreatedInBackground}. + */ +public class BackgroundTabAnimation { + /** Duration of the first step of the background animation: zooming out, rotating in */ + private static final long BACKGROUND_STEP1_DURATION = 300; + /** Duration of the second step of the background animation: pause */ + private static final long BACKGROUND_STEP2_DURATION = 150; + /** Duration of the third step of the background animation: zooming in, sliding out */ + private static final long BACKGROUND_STEP3_DURATION = 300; + /** Percentage of the screen covered by the new tab */ + private static final float BACKGROUND_COVER_PCTG = 0.5f; + + /** Factor by which to scale tasks surface when it briefly shrinks to the center. */ + private static final float TASKS_SURFACE_SCALE = 0.9f; + + private static final float TASKS_SURFACE_Z = 12f; + + /** + * Create an animation to show that a tab has been created in the background. + * @param layout {@link Layout} from which the tab was created. + * @param view View that will appear to momentarily shrink. + * @param lastTapX X position of the last touch down event. + * @param lastTapY Y position of the last touch down event. + * @param portrait True for portrait mode, false for landscape. + * @return An @{link Animator} for the background tab animation. + */ + public static Animator create( + Layout layout, ViewGroup view, float lastTapX, float lastTapY, boolean portrait) { + Context context = layout.getContext(); + final float margin = Math.min(layout.getWidth(), layout.getHeight()) + * (1.0f - TASKS_SURFACE_SCALE) / 2.0f; + + Collection<Animator> animationList = new ArrayList<>(5); + + // Step 1: zoom out the source tab and bring in the new tab + animationList.add( + animate(view, View.SCALE_X, 1f, TASKS_SURFACE_SCALE, BACKGROUND_STEP1_DURATION)); + animationList.add( + animate(view, View.SCALE_Y, 1f, TASKS_SURFACE_SCALE, BACKGROUND_STEP1_DURATION)); + + animationList.add(animate(view, View.X, 0f, margin, BACKGROUND_STEP1_DURATION)); + animationList.add(animate(view, View.Y, 0f, margin, BACKGROUND_STEP1_DURATION)); + animationList.add(animate(view, View.Z, 0f, TASKS_SURFACE_Z, BACKGROUND_STEP1_DURATION)); + + AnimatorSet step1Source = new AnimatorSet(); + step1Source.setInterpolator(Interpolators.FAST_OUT_SLOW_IN_INTERPOLATOR); + step1Source.playTogether(animationList); + + float pauseX = margin; + float pauseY = margin; + + if (portrait) { + pauseY = BACKGROUND_COVER_PCTG * layout.getHeight(); + } else { + pauseX = BACKGROUND_COVER_PCTG * layout.getWidth(); + } + + // Make a rectangle to represent the new tab. + GradientDrawable rectDrawable = new GradientDrawable(); + rectDrawable.setShape(GradientDrawable.RECTANGLE); + rectDrawable.setSize(view.getWidth(), view.getHeight()); + rectDrawable.setColor( + ChromeColors.getPrimaryBackgroundColor(context, /*isIncognito=*/false)); + + ImageView newTabView = new AppCompatImageView(context); + newTabView.setImageDrawable(rectDrawable); + + view.addView(newTabView); + + animationList = new ArrayList<>(5); + animationList.add(animate(newTabView, View.ALPHA, 0f, 1f, BACKGROUND_STEP1_DURATION / 2)); + animationList.add(animate( + newTabView, View.SCALE_X, 0f, TASKS_SURFACE_SCALE, BACKGROUND_STEP1_DURATION)); + animationList.add(animate( + newTabView, View.SCALE_Y, 0f, TASKS_SURFACE_SCALE, BACKGROUND_STEP1_DURATION)); + animationList.add(animate(newTabView, View.X, lastTapX, pauseX, BACKGROUND_STEP1_DURATION)); + animationList.add(animate(newTabView, View.Y, lastTapY, pauseY, BACKGROUND_STEP1_DURATION)); + + AnimatorSet step1New = new AnimatorSet(); + step1New.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN_INTERPOLATOR); + step1New.playTogether(animationList); + + AnimatorSet step1 = new AnimatorSet(); + step1.playTogether(step1New, step1Source); + + // step 2: pause + + // step 3: zoom in the source tab and slide down the new tab + animationList = new ArrayList<>(7); + + TimeInterpolator interpolator = Interpolators.FAST_OUT_SLOW_IN_INTERPOLATOR; + + animationList.add(animate(view, View.SCALE_X, TASKS_SURFACE_SCALE, 1f, + BACKGROUND_STEP3_DURATION, interpolator)); + animationList.add(animate(view, View.SCALE_Y, TASKS_SURFACE_SCALE, 1f, + BACKGROUND_STEP3_DURATION, interpolator)); + animationList.add( + animate(view, View.X, margin, 0f, BACKGROUND_STEP3_DURATION, interpolator)); + animationList.add( + animate(view, View.Y, margin, 0f, BACKGROUND_STEP3_DURATION, interpolator)); + animationList.add(animate( + view, View.Z, TASKS_SURFACE_Z, 0f, BACKGROUND_STEP3_DURATION, interpolator)); + + animationList.add(animate(newTabView, View.ALPHA, 1f, 0f, BACKGROUND_STEP3_DURATION)); + + // Rectangle flies away toward the tab switcher button. + if (portrait) { + animationList.add(animate(newTabView, View.Y, pauseY, -view.getHeight(), + BACKGROUND_STEP3_DURATION, Interpolators.FAST_OUT_LINEAR_IN_INTERPOLATOR)); + } else { + animationList.add(animate(newTabView, View.X, pauseX, view.getWidth(), + BACKGROUND_STEP3_DURATION, Interpolators.FAST_OUT_LINEAR_IN_INTERPOLATOR)); + } + + AnimatorSet step3 = new AnimatorSet(); + step3.setStartDelay(BACKGROUND_STEP2_DURATION); + step3.playTogether(animationList); + + AnimatorSet tabCreatedBackgroundAnimation = new AnimatorSet(); + tabCreatedBackgroundAnimation.playSequentially(step1, step3); + + // Remove the flying rectangle view when the animation ends so they don't accumulate. + tabCreatedBackgroundAnimation.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + view.removeView(newTabView); + } + }); + return tabCreatedBackgroundAnimation; + } + + private static Animator animate( + View view, Property<View, Float> property, float a, float b, long duration) { + return animate(view, property, a, b, duration, /*interpolator=*/null); + } + + private static Animator animate(View view, Property<View, Float> property, float a, float b, + long duration, TimeInterpolator interpolator) { + ObjectAnimator animator = + ObjectAnimator.ofFloat(view, property, a, b).setDuration(duration); + if (interpolator != null) { + animator.setInterpolator(interpolator); + } + return animator; + } +} \ No newline at end of file
diff --git a/chrome/android/features/start_surface/internal/java/src/org/chromium/chrome/features/start_surface/StartSurfaceCoordinator.java b/chrome/android/features/start_surface/internal/java/src/org/chromium/chrome/features/start_surface/StartSurfaceCoordinator.java index 3ab5997..ff79bb2 100644 --- a/chrome/android/features/start_surface/internal/java/src/org/chromium/chrome/features/start_surface/StartSurfaceCoordinator.java +++ b/chrome/android/features/start_surface/internal/java/src/org/chromium/chrome/features/start_surface/StartSurfaceCoordinator.java
@@ -492,6 +492,12 @@ } } + @Override + @Nullable + public TasksSurface getPrimaryTasksSurface() { + return mTasksSurface; + } + @VisibleForTesting public boolean isInitPendingForTesting() { return mIsInitPending;
diff --git a/chrome/android/features/start_surface/internal/java/src/org/chromium/chrome/features/start_surface/StartSurfaceLayout.java b/chrome/android/features/start_surface/internal/java/src/org/chromium/chrome/features/start_surface/StartSurfaceLayout.java index 5a7e32d..787f1ff 100644 --- a/chrome/android/features/start_surface/internal/java/src/org/chromium/chrome/features/start_surface/StartSurfaceLayout.java +++ b/chrome/android/features/start_surface/internal/java/src/org/chromium/chrome/features/start_surface/StartSurfaceLayout.java
@@ -12,6 +12,7 @@ import android.graphics.RectF; import android.os.Handler; import android.os.SystemClock; +import android.view.ViewGroup; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; @@ -40,6 +41,7 @@ import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.tasks.ReturnToChromeExperimentsUtil; +import org.chromium.chrome.browser.tasks.TasksSurface; import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher; import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher.TabListDelegate; import org.chromium.chrome.browser.tasks.tab_management.TabUiFeatureUtilities; @@ -96,6 +98,8 @@ private boolean mAndroidViewFinishedShowing; + private Animator mBackgroundTabAnimation; + interface PerfListener { void onAnimationDone( int frameRendered, long elapsedMs, long maxFrameInterval, int dirtySpan); @@ -377,6 +381,26 @@ } } + @Override + public void onTabCreated(long time, int id, int index, int sourceId, boolean newIsIncognito, + boolean background, float originX, float originY) { + super.onTabCreated(time, id, index, sourceId, newIsIncognito, background, originX, originY); + if (!background || newIsIncognito + || mController.getStartSurfaceState() != StartSurfaceState.SHOWN_HOMEPAGE) { + return; + } + TasksSurface primaryTasksSurface = mStartSurface.getPrimaryTasksSurface(); + assert primaryTasksSurface != null; + + if (mBackgroundTabAnimation != null && mBackgroundTabAnimation.isStarted()) { + mBackgroundTabAnimation.end(); + } + mBackgroundTabAnimation = + BackgroundTabAnimation.create(this, (ViewGroup) primaryTasksSurface.getView(), + originX, originY, getOrientation() == Orientation.PORTRAIT); + mBackgroundTabAnimation.start(); + } + /** * Animate shrinking a tab to a target {@link Rect} area. * @param animate Whether to play an entry animation.
diff --git a/chrome/android/features/start_surface/public/java/src/org/chromium/chrome/features/start_surface/StartSurface.java b/chrome/android/features/start_surface/public/java/src/org/chromium/chrome/features/start_surface/StartSurface.java index d258132..5ebdf55 100644 --- a/chrome/android/features/start_surface/public/java/src/org/chromium/chrome/features/start_surface/StartSurface.java +++ b/chrome/android/features/start_surface/public/java/src/org/chromium/chrome/features/start_surface/StartSurface.java
@@ -6,10 +6,13 @@ import android.os.SystemClock; +import androidx.annotation.Nullable; + import com.google.android.material.appbar.AppBarLayout; import org.chromium.base.supplier.Supplier; import org.chromium.chrome.browser.ntp.NewTabPageLaunchOrigin; +import org.chromium.chrome.browser.tasks.TasksSurface; import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher; /** Interface to communicate with the start surface. */ @@ -224,4 +227,11 @@ */ void onOverviewShownAtLaunch( boolean isOverviewShownOnStartup, final long activityCreationTimeMs); + + /** + * Returns the primary {@link TasksSurface} (omnibox, most visited, feed, etc.). Can be null if + * grid tab switcher is enabled but Start surface is disabled. + */ + @Nullable + TasksSurface getPrimaryTasksSurface(); }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchContext.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchContext.java index ff352f9..c684b6a 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchContext.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchContext.java
@@ -50,8 +50,8 @@ // The offset of an initial Tap gesture within the text content. private int mTapOffset = INVALID_OFFSET; - // The initial word selected by a Tap, or null. - private String mInitialSelectedWord; + // The selection being resolved, or null if no resolve has started. + private String mSelectionBeingResolved; // The original encoding of the base page. private String mEncoding; @@ -166,9 +166,8 @@ && !hasAnalyzedTap()) { analyzeTap(startOffset); } - // Notify of an initial selection if it's not empty. + // Notify of a changed selection if it's not empty. if (endOffset > startOffset) { - updateInitialSelectedWord(); onSelectionChanged(); } // Detect the language of the surroundings or the selection. @@ -214,10 +213,12 @@ } /** - * @return The initial word selected by a Tap. + * @return The selection being resolved, or {@code null} if no resolve has been + * requested. */ - String getInitialSelectedWord() { - return mInitialSelectedWord; + @Nullable + String getSelectionBeingResolved() { + return mSelectionBeingResolved; } /** @@ -250,6 +251,7 @@ * be requested. */ void prepareToResolve(boolean isExactSearch, String relatedSearchesStamp) { + mSelectionBeingResolved = getCurrentSelection(); mRelatedSearchesStamp = relatedSearchesStamp; ContextualSearchContextJni.get().prepareToResolve( mNativePointer, this, isExactSearch, relatedSearchesStamp); @@ -266,25 +268,19 @@ // Fully track the selection as it changes. mSelectionStartOffset += startAdjust; mSelectionEndOffset += endAdjust; - updateInitialSelectedWord(); ContextualSearchContextJni.get().adjustSelection( getNativePointer(), this, startAdjust, endAdjust); // Notify of changes. onSelectionChanged(); } - /** Updates the initial selected word if it has not yet been set. */ - private void updateInitialSelectedWord() { - if (TextUtils.isEmpty(mInitialSelectedWord) && !TextUtils.isEmpty(mSurroundingText)) { - // TODO(donnd): investigate the root cause of crbug.com/725027 that requires this - // additional validation to prevent this substring call from crashing! - if (mSelectionEndOffset < mSelectionStartOffset || mSelectionStartOffset < 0 - || mSelectionEndOffset > mSurroundingText.length()) { - return; - } - mInitialSelectedWord = - mSurroundingText.substring(mSelectionStartOffset, mSelectionEndOffset); + /** Returns the current selection, or an empty string if there is no valid selection. */ + private String getCurrentSelection() { + if (TextUtils.isEmpty(mSurroundingText) || mSelectionEndOffset < mSelectionStartOffset + || mSelectionStartOffset < 0 || mSelectionEndOffset > mSurroundingText.length()) { + return ""; } + return mSurroundingText.substring(mSelectionStartOffset, mSelectionEndOffset); } /** @return the current selection, or an empty string if data is invalid or nothing selected. */
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java index d801c1c8..d37ac6f7 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java
@@ -802,7 +802,8 @@ && (mSelectionController.getSelectionType() == SelectionType.TAP || mSelectionController.getSelectionType() == SelectionType.RESOLVING_LONG_PRESS)) { - String originalSelection = mContext == null ? null : mContext.getInitialSelectedWord(); + String originalSelection = + mContext == null ? null : mContext.getSelectionBeingResolved(); String currentSelection = mSelectionController.getSelectedText(); if (currentSelection != null) currentSelection = currentSelection.trim(); if (originalSelection != null && originalSelection.trim().equals(currentSelection)) {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java index 609f2ca..0b6a8390 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java
@@ -341,8 +341,15 @@ handleSelection(selection, mSelectionType); mWasTapGestureDetected = false; } else { - boolean isValidSelection = validateSelectionSuppression(selection); - mHandler.handleSelectionModification(selection, isValidSelection, mX, mY); + // If the user is dragging the handles just update the Bar, otherwise make a new search. + if (mAreSelectionHandlesBeingDragged) { + boolean isValidSelection = validateSelectionSuppression(selection); + mHandler.handleSelectionModification(selection, isValidSelection, mX, mY); + } else { + // Smart Selection can cause a longpress selection change without the handles + // being dragged. In that case do a full handling of the new selection. + handleSelection(selection, mSelectionType); + } } mLastValidSelectionType = mSelectionType; } @@ -378,23 +385,6 @@ case SelectionEventType.SELECTION_HANDLE_DRAG_STARTED: mAreSelectionHandlesBeingDragged = true; break; - case SelectionEventType.SELECTION_HANDLES_MOVED: - // If we're in the middle of a drag operation then we can wait for the drag to end, - // otherwise we need to process this right away. - if (mAreSelectionHandlesBeingDragged) break; - - // Smart text selection generates MOVED without STARTED and since that's not a user - // gesture we should not consider it an adjusted selection requiring an exact - // search. MOVED events are also sent on simple scroll operations that hide and then - // show the selection handles so we need to differentiate based on whether the - // selection changed. - String previousSelection = mSelectedText; - if (getSelectionPopupController() != null) { - mSelectedText = getSelectionPopupController().getSelectedText(); - } - shouldHandleSelection = - (mSelectedText != null && !mSelectedText.equals(previousSelection)); - break; case SelectionEventType.SELECTION_HANDLE_DRAG_STOPPED: mAreSelectionHandlesBeingDragged = false; shouldHandleSelection = true;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/signin/SigninFirstRunFragment.java b/chrome/android/java/src/org/chromium/chrome/browser/signin/SigninFirstRunFragment.java index 5b19fbd..2c7d098 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/signin/SigninFirstRunFragment.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/signin/SigninFirstRunFragment.java
@@ -10,8 +10,6 @@ import android.content.Intent; import android.content.res.Configuration; import android.os.Bundle; -import android.text.SpannableString; -import android.text.method.LinkMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -22,7 +20,6 @@ import androidx.annotation.VisibleForTesting; import androidx.fragment.app.Fragment; -import org.chromium.base.Callback; import org.chromium.chrome.R; import org.chromium.chrome.browser.customtabs.CustomTabActivity; import org.chromium.chrome.browser.firstrun.FirstRunFragment; @@ -34,9 +31,6 @@ import org.chromium.ui.base.LocalizationUtils; import org.chromium.ui.modaldialog.ModalDialogManager; import org.chromium.ui.modaldialog.ModalDialogManagerHolder; -import org.chromium.ui.text.NoUnderlineClickableSpan; -import org.chromium.ui.text.SpanApplier; -import org.chromium.ui.widget.TextViewWithClickableSpans; /** * This fragment handles the sign-in without sync consent during the FRE. @@ -96,6 +90,17 @@ mSigninFirstRunCoordinator.destroy(); } + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == ADD_ACCOUNT_REQUEST_CODE && resultCode == Activity.RESULT_OK + && data != null) { + String addedAccountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); + if (addedAccountName != null) { + mSigninFirstRunCoordinator.onAccountSelected(addedAccountName); + } + } + } + /** Implements {@link FirstRunFragment}. */ @Override public void setInitialA11yFocus() { @@ -136,23 +141,26 @@ getPageDelegate().recordFreProgressHistogram(state); } - @Override - public void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == ADD_ACCOUNT_REQUEST_CODE && resultCode == Activity.RESULT_OK - && data != null) { - String addedAccountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); - if (addedAccountName != null) { - mSigninFirstRunCoordinator.onAccountSelected(addedAccountName); - } - } - } - /** Implements {@link SigninFirstRunCoordinator.Delegate}. */ @Override public void acceptTermsOfService() { getPageDelegate().acceptTermsOfService(mAllowCrashUpload); } + /** Implements {@link SigninFirstRunCoordinator.Delegate}. */ + @Override + public void openTermsOfService() { + CustomTabActivity.showInfoPage(requireContext(), + LocalizationUtils.substituteLocalePlaceholder( + getString(R.string.google_terms_of_service_url))); + } + + /** Implements {@link SigninFirstRunCoordinator.Delegate}. */ + @Override + public void openUmaDialog() { + new FreUMADialogCoordinator(requireContext(), mModalDialogManager, this, mAllowCrashUpload); + } + /** Implements {@link FreUMADialogCoordinator.Listener} */ @Override public void onAllowCrashUploadChecked(boolean allowCrashUpload) { @@ -176,29 +184,6 @@ mSigninFirstRunCoordinator = new SigninFirstRunCoordinator(requireContext(), view, mModalDialogManager, this); notifyCoordinatorWhenNativeAndPolicyAreLoaded(); - setUpFooter(view.findViewById(R.id.signin_fre_footer)); return view; } - - private void setUpFooter(TextViewWithClickableSpans footerView) { - final Callback<View> onTermsOfServiceSpanClickListener = view -> { - CustomTabActivity.showInfoPage(requireContext(), - LocalizationUtils.substituteLocalePlaceholder( - getString(R.string.google_terms_of_service_url))); - }; - final Callback<View> onUmaDialogSpanClickListener = view -> { - new FreUMADialogCoordinator( - requireContext(), mModalDialogManager, this, mAllowCrashUpload); - }; - final NoUnderlineClickableSpan clickableTermsOfServiceSpan = - new NoUnderlineClickableSpan(getResources(), onTermsOfServiceSpanClickListener); - final NoUnderlineClickableSpan clickableUMADialogSpan = - new NoUnderlineClickableSpan(getResources(), onUmaDialogSpanClickListener); - final SpannableString footerString = SpanApplier.applySpans( - getString(R.string.signin_fre_footer), - new SpanApplier.SpanInfo("<LINK1>", "</LINK1>", clickableTermsOfServiceSpan), - new SpanApplier.SpanInfo("<LINK2>", "</LINK2>", clickableUMADialogSpan)); - footerView.setText(footerString); - footerView.setMovementMethod(LinkMovementMethod.getInstance()); - } }
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java index ba67648..ca7d04a 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java
@@ -341,7 +341,7 @@ mActivityMonitor = null; mLatestSlowResolveSearch = null; if (mActionTester != null) mActionTester.tearDown(); - InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> forgetHistograms()); + forgetHistograms(); FeatureList.setTestFeatures(null); CompositorAnimationHandler.setTestingMode(false); }
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/site_settings/SiteSettingsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/site_settings/SiteSettingsTest.java index 62094af1..ce6fd4d 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/site_settings/SiteSettingsTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/site_settings/SiteSettingsTest.java
@@ -1376,8 +1376,8 @@ @Test @MediumTest @Feature({"Preferences"}) - @DisableIf.Build(message = "EME not working before M", sdk_is_less_than = Build.VERSION_CODES.M, - sdk_is_greater_than = Build.VERSION_CODES.Q) + @DisableIf.Build(message = "https://crbug.com/1269556", + sdk_is_greater_than = Build.VERSION_CODES.P) @DisableIf.Device(type = {UiDisableIf.TABLET}) // https://crbug.com/1234530 public void testProtectedContentAllowThenBlock() throws Exception { initializeUpdateWaiter(true /* expectGranted */);
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchContextTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchContextTest.java index 987892e..4164f5c 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchContextTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchContextTest.java
@@ -110,7 +110,6 @@ assertEquals(INVALID, mContext.getSelectionStartOffset()); assertEquals(INVALID, mContext.getSelectionEndOffset()); assertNull(mContext.getEncoding()); - assertNull(mContext.getInitialSelectedWord()); assertEquals("", mContext.getTextContentFollowingSelection()); } @@ -141,11 +140,9 @@ assertTrue(mContext.getSelectionStartOffset() >= 0); assertTrue(mContext.getSelectionEndOffset() >= 0); assertNotNull(mContext.getEncoding()); - assertNull(mContext.getInitialSelectedWord()); assertFalse(mDidSelectionChange); simulateSelectWordAroundCaret(-"Ba".length(), "rack".length()); - assertEquals("Barack", mContext.getInitialSelectedWord()); assertEquals("Barack".length(), mContext.getSelectionEndOffset() - mContext.getSelectionStartOffset()); assertTrue(mDidSelectionChange); @@ -162,7 +159,6 @@ assertTrue(mContext.canResolve()); simulateResolve(0, " Obama".length()); - assertEquals("Barack", mContext.getInitialSelectedWord()); assertEquals("Barack Obama".length(), mContext.getSelectionEndOffset() - mContext.getSelectionStartOffset()); }
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionControllerTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionControllerTest.java index 39f2b32..59c6315 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionControllerTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionControllerTest.java
@@ -7,7 +7,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; import android.app.Activity; @@ -15,8 +14,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import org.robolectric.Robolectric; import org.robolectric.annotation.Config; import org.robolectric.annotation.Implementation; @@ -24,7 +21,6 @@ import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.base.test.util.Feature; -import org.chromium.content_public.browser.SelectionPopupController; import org.chromium.ui.touch_selection.SelectionEventType; /** @@ -41,11 +37,6 @@ .class}) public final class ContextualSearchSelectionControllerTest { private static final String USER_SELECTION = "user selection"; - private static final String POPUP_CONTROLLER_SELECTION = "popup controller selection"; - - /** A SelectionPopupController that always returns POPUP_CONTROLLER_SELECTION. */ - @Mock - private static SelectionPopupController sMockSelectionPopupController; /** Stores the selection set by ContextualSearchSelectionController#handleSelection. */ private static String sSelectionSetByHandleSelection; @@ -55,9 +46,6 @@ @Before public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - when(sMockSelectionPopupController.getSelectedText()) - .thenReturn(POPUP_CONTROLLER_SELECTION); Activity activity = Robolectric.buildActivity(Activity.class).setup().get(); mSelectionControllerUnderTest = new ContextualSearchSelectionController(activity, null, null, null); @@ -104,15 +92,6 @@ sSelectionSetByHandleSelection = selection; } - /** - * Returns the mock popup controller, which always returns a fixed string from - * #getSelectedText. - */ - @Implementation - protected SelectionPopupController getSelectionPopupController() { - return sMockSelectionPopupController; - } - /** Returns the selection that was set by the call to #handleSelection. */ static String getSelectionSetByHandleSelection() { return sSelectionSetByHandleSelection; @@ -159,12 +138,12 @@ // SELECTION_HANDLE_DRAG_STARTED event. mSelectionControllerUnderTest.handleSelectionEvent( SelectionEventType.SELECTION_HANDLES_MOVED, 0f, 0f); - // Make sure we grabbed the selection from the SelectionPopupController. - Assert.assertEquals("Smart Text Selection interaction with Contextual Search " + // Make sure we did not establish any selection. + Assert.assertNull("Smart Text Selection interaction with Contextual Search " + "through the ContextualSearchSelectionController#handleSelectionEvent " + "sent a selection to the Manager that was unexpected. Smart Text " + "Selection with the intelligent Long-press gesture may be broken.", - POPUP_CONTROLLER_SELECTION, getSelectionSetByHandleSelection()); + getSelectionSetByHandleSelection()); } //============================================================================================
diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp index 588a79c..069b3fb 100644 --- a/chrome/app/chromeos_strings.grdp +++ b/chrome/app/chromeos_strings.grdp
@@ -4055,6 +4055,12 @@ <message name="IDS_LACROS_DATA_MIGRATION_SCREEN_SUBTITLE" desc="Shows the % of progress."> <ph name="PERCENT">$1<ex>100</ex></ph>% completed </message> + <message name="IDS_LACROS_DATA_MIGRATION_SCREEN_SKIP_BUTTON" desc="Skip button for data migration."> + Skip + </message> + <message name="IDS_LACROS_DATA_MIGRATION_SCREEN_SKIP_SUGGESTION" desc="Message shown when skip button is visible."> + This is taking longer than expected, you can skip or wait until it's done. + </message> <!-- Print Job Notification --> <message name="IDS_PRINT_JOB_NOTIFICATION_DISPLAY_SOURCE" desc="The context title of printing notification."> @@ -4876,7 +4882,7 @@ Help </message> <message name="IDS_ECHE_APP_SCREEN_LOCK_NOTIFICATION_TITLE" desc="Title for notification shown when screen lock is not enabled while using app stream of EcheApp."> - Couldn’t open the App + Couldn’t open <ph name="APP_NAME">$1<ex>the app</ex></ph> </message> <message name="IDS_ECHE_APP_SCREEN_LOCK_NOTIFICATION_MESSAGE" desc="Message for the notification shown when screen lock is not enabled while using app stream of EcheApp."> Set a pin or password on this Chromebook to protect access to your phone’s apps.
diff --git a/chrome/app/chromeos_strings_grdp/IDS_ECHE_APP_SCREEN_LOCK_NOTIFICATION_TITLE.png.sha1 b/chrome/app/chromeos_strings_grdp/IDS_ECHE_APP_SCREEN_LOCK_NOTIFICATION_TITLE.png.sha1 index f7fc0077..e1d752f 100644 --- a/chrome/app/chromeos_strings_grdp/IDS_ECHE_APP_SCREEN_LOCK_NOTIFICATION_TITLE.png.sha1 +++ b/chrome/app/chromeos_strings_grdp/IDS_ECHE_APP_SCREEN_LOCK_NOTIFICATION_TITLE.png.sha1
@@ -1 +1 @@ -bf284f3dc923008482ba763eb9d056f1ab69f8e9 \ No newline at end of file +47e595c88427adfe5662c60dadfa357d01e0e2d4 \ No newline at end of file
diff --git a/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_SKIP_BUTTON.png.sha1 b/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_SKIP_BUTTON.png.sha1 new file mode 100644 index 0000000..ab72be9 --- /dev/null +++ b/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_SKIP_BUTTON.png.sha1
@@ -0,0 +1 @@ +362e221fcf529324e0e6fa25e2790fc5e6b70f26 \ No newline at end of file
diff --git a/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_SKIP_SUGGESTION.png.sha1 b/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_SKIP_SUGGESTION.png.sha1 new file mode 100644 index 0000000..ab72be9 --- /dev/null +++ b/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_SKIP_SUGGESTION.png.sha1
@@ -0,0 +1 @@ +362e221fcf529324e0e6fa25e2790fc5e6b70f26 \ No newline at end of file
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 81363939..62e39820 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -5689,6 +5689,8 @@ "enterprise/connectors/device_trust/attestation/desktop/desktop_attestation_service.h", "enterprise/connectors/device_trust/attestation/desktop/google_keys.cc", "enterprise/connectors/device_trust/attestation/desktop/google_keys.h", + "enterprise/connectors/device_trust/browser/browser_device_trust_connector_service.cc", + "enterprise/connectors/device_trust/browser/browser_device_trust_connector_service.h", "enterprise/connectors/device_trust/signals/decorators/browser/browser_signals_decorator.cc", "enterprise/connectors/device_trust/signals/decorators/browser/browser_signals_decorator.h", ]
diff --git a/chrome/browser/apps/digital_goods/digital_goods_impl.h b/chrome/browser/apps/digital_goods/digital_goods_impl.h index edc9e004..0a63bc6 100644 --- a/chrome/browser/apps/digital_goods/digital_goods_impl.h +++ b/chrome/browser/apps/digital_goods/digital_goods_impl.h
@@ -8,7 +8,7 @@ #include <string> #include <vector> -#include "components/arc/pay/arc_digital_goods_bridge.h" +#include "ash/components/arc/pay/arc_digital_goods_bridge.h" #include "content/public/browser/document_user_data.h" #include "content/public/browser/render_widget_host.h" #include "mojo/public/cpp/bindings/receiver.h"
diff --git a/chrome/browser/ash/arc/file_system_watcher/arc_file_system_watcher_service.cc b/chrome/browser/ash/arc/file_system_watcher/arc_file_system_watcher_service.cc index 5c825e43..a972469 100644 --- a/chrome/browser/ash/arc/file_system_watcher/arc_file_system_watcher_service.cc +++ b/chrome/browser/ash/arc/file_system_watcher/arc_file_system_watcher_service.cc
@@ -55,7 +55,7 @@ // TODO(crbug.com/929031): Move this to arc_volume_mounter_bridge.h. // The MyFiles path inside ARC container. This will be the path that is used in // MediaScanner.scanFile request. UUID for the MyFiles volume is taken from -// components/arc/volume_mounter/arc_volume_mounter_bridge.cc. +// ash/components/arc/volume_mounter/arc_volume_mounter_bridge.cc. constexpr base::FilePath::CharType kAndroidMyFilesDir[] = FILE_PATH_LITERAL("/storage/0000000000000000000000000000CAFEF00D2019");
diff --git a/chrome/browser/ash/arc/file_system_watcher/arc_file_system_watcher_service.h b/chrome/browser/ash/arc/file_system_watcher/arc_file_system_watcher_service.h index 113eba13..d842a5c 100644 --- a/chrome/browser/ash/arc/file_system_watcher/arc_file_system_watcher_service.h +++ b/chrome/browser/ash/arc/file_system_watcher/arc_file_system_watcher_service.h
@@ -10,12 +10,12 @@ #include <string> #include <vector> +#include "ash/components/arc/volume_mounter/arc_volume_mounter_bridge.h" #include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "components/arc/mojom/file_system.mojom-forward.h" #include "components/arc/session/connection_observer.h" -#include "components/arc/volume_mounter/arc_volume_mounter_bridge.h" #include "components/keyed_service/core/keyed_service.h" namespace base {
diff --git a/chrome/browser/ash/arc/instance_throttle/arc_instance_throttle_unittest.cc b/chrome/browser/ash/arc/instance_throttle/arc_instance_throttle_unittest.cc index 4c23d7d..1c2ab31 100644 --- a/chrome/browser/ash/arc/instance_throttle/arc_instance_throttle_unittest.cc +++ b/chrome/browser/ash/arc/instance_throttle/arc_instance_throttle_unittest.cc
@@ -10,6 +10,7 @@ #include "ash/components/arc/arc_features.h" #include "ash/components/arc/arc_prefs.h" +#include "ash/components/arc/power/arc_power_bridge.h" #include "ash/components/arc/test/arc_util_test_support.h" #include "ash/components/arc/test/connection_holder_util.h" #include "ash/components/arc/test/fake_arc_session.h" @@ -25,7 +26,6 @@ #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/power/power_manager_client.h" #include "components/arc/mojom/power.mojom.h" -#include "components/arc/power/arc_power_bridge.h" #include "components/arc/session/arc_bridge_service.h" #include "components/arc/session/arc_service_manager.h" #include "components/sync_preferences/testing_pref_service_syncable.h"
diff --git a/chrome/browser/ash/arc/instance_throttle/arc_power_throttle_observer.h b/chrome/browser/ash/arc/instance_throttle/arc_power_throttle_observer.h index 28fdbca..0765559f 100644 --- a/chrome/browser/ash/arc/instance_throttle/arc_power_throttle_observer.h +++ b/chrome/browser/ash/arc/instance_throttle/arc_power_throttle_observer.h
@@ -5,9 +5,9 @@ #ifndef CHROME_BROWSER_ASH_ARC_INSTANCE_THROTTLE_ARC_POWER_THROTTLE_OBSERVER_H_ #define CHROME_BROWSER_ASH_ARC_INSTANCE_THROTTLE_ARC_POWER_THROTTLE_OBSERVER_H_ +#include "ash/components/arc/power/arc_power_bridge.h" #include "base/timer/timer.h" #include "chrome/browser/ash/throttle_observer.h" -#include "components/arc/power/arc_power_bridge.h" namespace arc {
diff --git a/chrome/browser/ash/arc/session/arc_service_launcher.cc b/chrome/browser/ash/arc/session/arc_service_launcher.cc index 9cb5e53..5a2d978 100644 --- a/chrome/browser/ash/arc/session/arc_service_launcher.cc +++ b/chrome/browser/ash/arc/session/arc_service_launcher.cc
@@ -22,6 +22,20 @@ #include "ash/components/arc/memory_pressure/arc_memory_pressure_bridge.h" #include "ash/components/arc/metrics/arc_metrics_service.h" #include "ash/components/arc/midis/arc_midis_bridge.h" +#include "ash/components/arc/net/arc_net_host_impl.h" +#include "ash/components/arc/obb_mounter/arc_obb_mounter_bridge.h" +#include "ash/components/arc/pay/arc_digital_goods_bridge.h" +#include "ash/components/arc/pay/arc_payment_app_bridge.h" +#include "ash/components/arc/power/arc_power_bridge.h" +#include "ash/components/arc/property/arc_property_bridge.h" +#include "ash/components/arc/rotation_lock/arc_rotation_lock_bridge.h" +#include "ash/components/arc/sensor/arc_iio_sensor_bridge.h" +#include "ash/components/arc/sensor/arc_sensor_bridge.h" +#include "ash/components/arc/storage_manager/arc_storage_manager.h" +#include "ash/components/arc/timer/arc_timer_bridge.h" +#include "ash/components/arc/usb/usb_host_bridge.h" +#include "ash/components/arc/volume_mounter/arc_volume_mounter_bridge.h" +#include "ash/components/arc/wake_lock/arc_wake_lock_bridge.h" #include "ash/constants/ash_features.h" #include "base/bind.h" #include "base/check_op.h" @@ -79,23 +93,9 @@ #include "components/arc/input_overlay/arc_input_overlay_manager.h" #include "components/arc/intent_helper/arc_intent_helper_bridge.h" #include "components/arc/media_session/arc_media_session_bridge.h" -#include "components/arc/net/arc_net_host_impl.h" -#include "components/arc/obb_mounter/arc_obb_mounter_bridge.h" -#include "components/arc/pay/arc_digital_goods_bridge.h" -#include "components/arc/pay/arc_payment_app_bridge.h" -#include "components/arc/power/arc_power_bridge.h" -#include "components/arc/property/arc_property_bridge.h" -#include "components/arc/rotation_lock/arc_rotation_lock_bridge.h" -#include "components/arc/sensor/arc_iio_sensor_bridge.h" -#include "components/arc/sensor/arc_sensor_bridge.h" #include "components/arc/session/arc_service_manager.h" #include "components/arc/session/arc_session.h" #include "components/arc/session/arc_session_runner.h" -#include "components/arc/storage_manager/arc_storage_manager.h" -#include "components/arc/timer/arc_timer_bridge.h" -#include "components/arc/usb/usb_host_bridge.h" -#include "components/arc/volume_mounter/arc_volume_mounter_bridge.h" -#include "components/arc/wake_lock/arc_wake_lock_bridge.h" #include "components/prefs/pref_member.h" #include "mojo/public/cpp/bindings/pending_remote.h"
diff --git a/chrome/browser/ash/arc/survey/arc_survey_service.cc b/chrome/browser/ash/arc/survey/arc_survey_service.cc index cde72a1..b5292e8 100644 --- a/chrome/browser/ash/arc/survey/arc_survey_service.cc +++ b/chrome/browser/ash/arc/survey/arc_survey_service.cc
@@ -8,9 +8,13 @@ #include <utility> #include "ash/components/arc/arc_browser_context_keyed_service_factory_base.h" +#include "base/json/json_reader.h" #include "base/logging.h" #include "base/memory/singleton.h" #include "base/time/time.h" +#include "chrome/browser/ash/hats/hats_config.h" +#include "chrome/browser/ash/hats/hats_finch_helper.h" +#include "chrome/browser/ash/hats/hats_notification_controller.h" #include "chrome/browser/profiles/profile.h" namespace arc { @@ -18,6 +22,8 @@ namespace { const int kArcGameSurveyTriggerTimeInMinutes = 10; +constexpr char kKeyPackageNames[] = "package_names"; +constexpr char kKeyMostRecentAndroidGame[] = "mostRecentAndroidGame"; // Singleton factory for ArcSurveyServiceFactory. class ArcSurveyServiceFactory @@ -53,14 +59,28 @@ } ArcSurveyService::ArcSurveyService(content::BrowserContext* context, - ArcBridgeService* arc_bridge_service) { + ArcBridgeService* arc_bridge_service) + : profile_(Profile::FromBrowserContext(context)) { VLOG(1) << "ArcSurveyService created"; - ArcAppListPrefs* prefs = - ArcAppListPrefs::Get(Profile::FromBrowserContext(context)); + + if (!base::FeatureList::IsEnabled(ash::kHatsArcGamesSurvey.feature)) { + VLOG(1) << "ARC Games HaTS survey feature is not enabled"; + return; + } + const std::string survey_data = + ash::HatsFinchHelper::GetCustomClientDataAsString( + ash::kHatsArcGamesSurvey); + if (survey_data.length() == 0) { + VLOG(1) << "No HaTS config found for ARC Games."; + return; + } + if (!LoadPackageNames(survey_data)) { + VLOG(1) << "List of package names not loaded."; + return; + } + ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_); if (prefs) arc_prefs_observer_.Observe(prefs); - // TODO(b:204572472): Populate |allowed_packages_| from - // HatsConfig::kHatsArcGamesSurvey. } ArcSurveyService::~ArcSurveyService() { @@ -68,6 +88,30 @@ task_id_map_.clear(); } +bool ArcSurveyService::LoadPackageNames(const std::string& survey_data) { + const absl::optional<base::Value> root = base::JSONReader::Read(survey_data); + if (!root) { + VLOG(2) << "Error reading survey data"; + return false; + } + const base::Value* list = root->FindListKey(kKeyPackageNames); + if (!list) { + VLOG(2) << "Package name list not found in survey data."; + return false; + } + for (const auto& item : list->GetList()) { + const std::string* package_name = item.GetIfString(); + if (!package_name) { + VLOG(2) << "Non-string value found in list"; + allowed_packages_.clear(); + return false; + } + allowed_packages_.emplace(*package_name); + } + DVLOG(1) << "Added " << allowed_packages_.size() << " entries"; + return true; +} + void ArcSurveyService::OnTaskCreated(int32_t task_id, const std::string& package_name, const std::string& activity, @@ -79,17 +123,21 @@ } // Add |task_id| to TaskIdMap + DVLOG(1) << "Adding new entry in task ID map: {" << task_id << ", " + << package_name << "}"; task_id_map_.emplace(task_id, package_name); // Add or update the respective entry in PackageNameMap PackageNameMap::iterator entry = package_name_map_.find(package_name); if (entry == package_name_map_.end()) { // Add new entry + DVLOG(1) << "Adding new entry to package name map:" << package_name; package_name_map_.emplace( package_name, std::make_pair(1, base::Time::NowFromSystemTime())); } else { // Update the count for the existing entry. entry->second.first++; + DVLOG(1) << "Updating package name map: " << package_name; } } @@ -102,6 +150,8 @@ return; } const std::string package_name = task_id_iterator->second; + DVLOG(1) << "Removing entry from task ID map: {" << task_id_iterator->first + << ", " << task_id_iterator->second << "}"; task_id_map_.erase(task_id_iterator); // Update PackageNameMap @@ -115,6 +165,7 @@ if (package_name_iterator->second.first == 0) { const base::Time on_task_create_timestamp = package_name_iterator->second.second; + DVLOG(1) << "Removing from package name map: " << package_name; package_name_map_.erase(package_name_iterator); // Trigger ArcGames survey if it's been active for at least @@ -122,9 +173,17 @@ base::TimeDelta elapsedTime = base::Time::NowFromSystemTime() - on_task_create_timestamp; if (elapsedTime.InMinutes() >= kArcGameSurveyTriggerTimeInMinutes) { - VLOG(1) << "~~~ Elapsed time is more than 10: " + VLOG(1) << "~~~ Elapsed time is more than " + << kArcGameSurveyTriggerTimeInMinutes << ": " << elapsedTime.InMinutes(); - // TODO(b:204572472): Trigger HatsConfig::kHatsArcGamesSurvey + if (ash::HatsNotificationController::ShouldShowSurveyToProfile( + profile_, ash::kHatsArcGamesSurvey)) { + const base::flat_map<std::string, std::string> product_specific_data = { + {kKeyMostRecentAndroidGame, package_name}}; + hats_notification_controller_ = + base::MakeRefCounted<ash::HatsNotificationController>( + profile_, ash::kHatsArcGamesSurvey, product_specific_data); + } } } }
diff --git a/chrome/browser/ash/arc/survey/arc_survey_service.h b/chrome/browser/ash/arc/survey/arc_survey_service.h index ab627a6..5bbb625 100644 --- a/chrome/browser/ash/arc/survey/arc_survey_service.h +++ b/chrome/browser/ash/arc/survey/arc_survey_service.h
@@ -18,9 +18,14 @@ class BrowserContext; } // namespace content +namespace ash { +class HatsNotificationController; +} // namespace ash + namespace arc { class ArcBridgeService; +class ArcSurveyServiceTest; // This service monitors as ARC apps are created/destroyed and determines when // to show ARC++ Games Survey. @@ -64,6 +69,9 @@ void AddAllowedPackageNameForTesting(const std::string package_name); private: + friend class ArcSurveyServiceTest; + bool LoadPackageNames(const std::string& survey_data); + base::ScopedObservation<ArcAppListPrefs, ArcAppListPrefs::Observer> arc_prefs_observer_{this}; @@ -88,6 +96,11 @@ // List of package names for which to show the survey. std::set<std::string> allowed_packages_; + + // Unowned pointer. + Profile* const profile_; + + scoped_refptr<ash::HatsNotificationController> hats_notification_controller_; }; } // namespace arc
diff --git a/chrome/browser/ash/arc/survey/arc_survey_service_unittest.cc b/chrome/browser/ash/arc/survey/arc_survey_service_unittest.cc index 32c88f3..9113bea7 100644 --- a/chrome/browser/ash/arc/survey/arc_survey_service_unittest.cc +++ b/chrome/browser/ash/arc/survey/arc_survey_service_unittest.cc
@@ -21,6 +21,7 @@ constexpr char kPackageB[] = "package B"; } // namespace + class ArcSurveyServiceTest : public testing::Test { public: ArcSurveyServiceTest() = default; @@ -54,6 +55,14 @@ return arc_survey_service_->GetTaskIdMapForTesting(); } + bool LoadPackageNames(const std::string package_names) { + return arc_survey_service_->LoadPackageNames(package_names); + } + + std::set<std::string>& GetAllowedPackageNameSet() { + return arc_survey_service_->allowed_packages_; + } + private: content::BrowserTaskEnvironment task_environment_; TestingProfile testing_profile_; @@ -140,4 +149,32 @@ EXPECT_EQ(0, getTaskIdMap()->size()); } +TEST_F(ArcSurveyServiceTest, LoadPackageNames) { + // Clear any existing entries. + GetAllowedPackageNameSet().clear(); + EXPECT_EQ(0, GetAllowedPackageNameSet().size()); + + // INVALID: No JSON String + EXPECT_FALSE(LoadPackageNames("foobar1234")); + EXPECT_EQ(0, GetAllowedPackageNameSet().size()); + + // Invalid JSON String: |package_names| as the key and a string as the value. + EXPECT_FALSE(LoadPackageNames(R"({"package_names":"com.android.vending")")); + EXPECT_EQ(0, GetAllowedPackageNameSet().size()); + + // Invalid JSON format: |package_names| as the key and not all the items in + // the list are strings. + EXPECT_FALSE( + LoadPackageNames(R"({"package_names":["com.android.vending",123]})")); + EXPECT_EQ(0, GetAllowedPackageNameSet().size()); + + // Valid JSON Format: |package_names| as the key and ALL the items in the list + // are strings. + EXPECT_TRUE(LoadPackageNames( + R"({"package_names":["com.android.vending","com.android.settings"]})")); + EXPECT_EQ(2, GetAllowedPackageNameSet().size()); + EXPECT_EQ(1, GetAllowedPackageNameSet().count("com.android.vending")); + EXPECT_EQ(1, GetAllowedPackageNameSet().count("com.android.settings")); +} + } // namespace arc
diff --git a/chrome/browser/ash/arc/usb/arc_usb_host_bridge_delegate.h b/chrome/browser/ash/arc/usb/arc_usb_host_bridge_delegate.h index f3847fb..b755af6 100644 --- a/chrome/browser/ash/arc/usb/arc_usb_host_bridge_delegate.h +++ b/chrome/browser/ash/arc/usb/arc_usb_host_bridge_delegate.h
@@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_ASH_ARC_USB_ARC_USB_HOST_BRIDGE_DELEGATE_H_ #define CHROME_BROWSER_ASH_ARC_USB_ARC_USB_HOST_BRIDGE_DELEGATE_H_ -#include "components/arc/usb/usb_host_bridge.h" +#include "ash/components/arc/usb/usb_host_bridge.h" namespace arc {
diff --git a/chrome/browser/ash/file_manager/path_util.cc b/chrome/browser/ash/file_manager/path_util.cc index 0c596fe07..3fd49743 100644 --- a/chrome/browser/ash/file_manager/path_util.cc +++ b/chrome/browser/ash/file_manager/path_util.cc
@@ -85,7 +85,7 @@ constexpr char kArcRemovableMediaContentUrlPrefix[] = "content://org.chromium.arc.volumeprovider/"; // The dummy UUID of the MyFiles volume is taken from -// components/arc/volume_mounter/arc_volume_mounter_bridge.cc. +// ash/components/arc/volume_mounter/arc_volume_mounter_bridge.cc. // TODO(crbug.com/929031): Move MyFiles constants to a common place. constexpr char kArcMyFilesContentUrlPrefix[] = "content://org.chromium.arc.volumeprovider/"
diff --git a/chrome/browser/ash/login/screens/lacros_data_migration_screen.cc b/chrome/browser/ash/login/screens/lacros_data_migration_screen.cc index c767b43..fbea6ef 100644 --- a/chrome/browser/ash/login/screens/lacros_data_migration_screen.cc +++ b/chrome/browser/ash/login/screens/lacros_data_migration_screen.cc
@@ -8,6 +8,8 @@ #include "base/command_line.h" #include "base/task/bind_post_task.h" #include "base/threading/sequenced_task_runner_handle.h" +#include "base/threading/thread_task_runner_handle.h" +#include "base/time/time.h" #include "chrome/browser/ash/crosapi/browser_data_migrator.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "content/public/browser/browser_thread.h" @@ -17,13 +19,27 @@ namespace ash { namespace { constexpr char kUserActionCancel[] = "cancel"; -} +constexpr base::TimeDelta kShowSkipButtonDuration = base::Seconds(20); + +class MigratorDelegateImpl + : public LacrosDataMigrationScreen::MigratorDelegate { + base::OnceClosure Migrate( + const std::string& user_id_hash, + const base::RepeatingCallback<void(int)>& progress_callback) override { + return BrowserDataMigrator::Migrate( + user_id_hash, progress_callback, + base::BindOnce(&chrome::AttemptRestart)); + } +}; + +} // namespace LacrosDataMigrationScreen::LacrosDataMigrationScreen( LacrosDataMigrationScreenView* view) : BaseScreen(LacrosDataMigrationScreenView::kScreenId, OobeScreenPriority::SCREEN_DEVICE_DEVELOPER_MODIFICATION), - view_(view) { + view_(view), + migrator_delegate_(std::make_unique<MigratorDelegateImpl>()) { DCHECK(view_); if (view_) view_->Bind(this); @@ -44,29 +60,45 @@ if (!view_) return; - const std::string user_id_hash = - base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - switches::kBrowserDataMigrationForUser); + // user_id_hash_ is not empty if it is already set by + // `SetUserIdHashForTesting()`. + if (user_id_hash_.empty()) { + user_id_hash_ = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + switches::kBrowserDataMigrationForUser); + } + DCHECK(!user_id_hash_.empty()) << "user_id_hash_ should not be empty."; + base::RepeatingCallback<void(int)> progress_callback = base::BindPostTask( base::SequencedTaskRunnerHandle::Get(), base::BindRepeating(&LacrosDataMigrationScreen::OnProgressUpdate, weak_factory_.GetWeakPtr()), FROM_HERE); - // TODO(crbug.com/1178702): Hide skip button and only show it after 10s. - // Start browser data migration. - cancel_callback_ = BrowserDataMigrator::Migrate( - user_id_hash, progress_callback, base::BindOnce(&chrome::AttemptRestart)); + + cancel_callback_ = + migrator_delegate_->Migrate(user_id_hash_, progress_callback); // Show the screen. view_->Show(); GetWakeLock()->RequestWakeLock(); + + // Post a delayed task to show the skip button after + // `kShowSkipButtonDuration`. + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, + base::BindOnce(&LacrosDataMigrationScreen::ShowSkipButton, + weak_factory_.GetWeakPtr()), + kShowSkipButtonDuration); } void LacrosDataMigrationScreen::OnProgressUpdate(int progress) { view_->SetProgressValue(progress); } +void LacrosDataMigrationScreen::ShowSkipButton() { + view_->ShowSkipButton(); +} + void LacrosDataMigrationScreen::OnUserAction(const std::string& action_id) { if (action_id == kUserActionCancel) { if (cancel_callback_) { @@ -102,4 +134,14 @@ return wake_lock_.get(); } +void LacrosDataMigrationScreen::SetMigratorDelegateForTesting( + std::unique_ptr<MigratorDelegate> migrator_delegate) { + migrator_delegate_ = std::move(migrator_delegate); +} + +void LacrosDataMigrationScreen::SetUserIdHashForTesting( + const std::string& user_id_hash) { + user_id_hash_ = user_id_hash; +} + } // namespace ash
diff --git a/chrome/browser/ash/login/screens/lacros_data_migration_screen.h b/chrome/browser/ash/login/screens/lacros_data_migration_screen.h index 5680ba2..1ec5835 100644 --- a/chrome/browser/ash/login/screens/lacros_data_migration_screen.h +++ b/chrome/browser/ash/login/screens/lacros_data_migration_screen.h
@@ -18,6 +18,17 @@ // directory. The screen is shown during login. class LacrosDataMigrationScreen : public BaseScreen { public: + // MigratorDelegate initiates the migration. A fake migrator delegate can be + // set for testing. + class MigratorDelegate { + public: + // Calls the actual migrator method `ash::BrowserDataMigrator::Migrate()`. + virtual base::OnceClosure Migrate( + const std::string& user_id_hash, + const base::RepeatingCallback<void(int)>& progress_callback) = 0; + virtual ~MigratorDelegate() = default; + }; + explicit LacrosDataMigrationScreen(LacrosDataMigrationScreenView* view); ~LacrosDataMigrationScreen() override; LacrosDataMigrationScreen(const LacrosDataMigrationScreen&) = delete; @@ -36,6 +47,17 @@ // value. `progress` is then passed to `LacrosDataMigrationView`. void OnProgressUpdate(int progress); + // Posted as a delayed task from `ShowImpl()`. It calls the method of the same + // name on `LacrosDataMigrationScreenView`. + void ShowSkipButton(); + + // Set `migrator_delegate_` for testing. + void SetMigratorDelegateForTesting( + std::unique_ptr<MigratorDelegate> migrator_delegate); + + // Set `user_id_hash_` for testing. + void SetUserIdHashForTesting(const std::string& user_id_hash); + private: // BaseScreen: void ShowImpl() override; @@ -48,8 +70,10 @@ LacrosDataMigrationScreenView* view_; // Callback to cancel migration. Stores the return value from - // `BrowserDataMigrator::Migrate()`. + // `migrator_delegate->Migrate()`. base::OnceClosure cancel_callback_; + std::unique_ptr<MigratorDelegate> migrator_delegate_; + std::string user_id_hash_; base::WeakPtrFactory<LacrosDataMigrationScreen> weak_factory_{this}; };
diff --git a/chrome/browser/ash/login/screens/lacros_data_migration_screen_browsertest.cc b/chrome/browser/ash/login/screens/lacros_data_migration_screen_browsertest.cc new file mode 100644 index 0000000..8e12009 --- /dev/null +++ b/chrome/browser/ash/login/screens/lacros_data_migration_screen_browsertest.cc
@@ -0,0 +1,109 @@ +// Copyright 2021 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/ash/login/screens/lacros_data_migration_screen.h" + +#include "ash/constants/ash_switches.h" +#include "base/memory/ptr_util.h" +#include "base/test/task_environment.h" +#include "chrome/browser/ash/crosapi/browser_data_migrator.h" +#include "chrome/browser/ash/login/test/device_state_mixin.h" +#include "chrome/browser/ash/login/test/js_checker.h" +#include "chrome/browser/ash/login/test/login_manager_mixin.h" +#include "chrome/browser/ash/login/test/oobe_base_test.h" +#include "chrome/browser/ash/login/test/oobe_screen_waiter.h" +#include "chrome/browser/ash/login/ui/login_display_host_mojo.h" +#include "chrome/browser/ash/login/wizard_controller.h" +#include "chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.h" +#include "chrome/test/base/in_process_browser_test.h" +#include "chrome/test/base/mixin_based_in_process_browser_test.h" +#include "content/public/test/browser_test.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace ash { +namespace { +constexpr char kLacrosDataMigrationId[] = "lacros-data-migration"; +const test::UIPath kSkipButton = {kLacrosDataMigrationId, "cancelButton"}; + +class FakeMigrator : public LacrosDataMigrationScreen::MigratorDelegate { + public: + base::OnceClosure Migrate( + const std::string& user_id_hash, + const base::RepeatingCallback<void(int)>& progress_callback) override { + return base::BindOnce([](bool* cancel_called) { *cancel_called = true; }, + &cancel_called_); + } + + // Checks if the returned function from `Migrate()` is called. + bool IsCancelCalled() { return cancel_called_; } + + private: + bool cancel_called_ = false; +}; + +class LacrosDataMigrationScreenTest : public OobeBaseTest { + public: + LacrosDataMigrationScreenTest() { + // Adding a user and marking OOBE completed with DeviceStateMixin ensures + // that chrome://oobe/login is loaded instead of chrome://oobe/oobe and that + // LoginDisplayHostMojo is created instead of LoginDisplayHostWebUI. + login_mixin_.AppendRegularUsers(1); + } + LacrosDataMigrationScreenTest(const LacrosDataMigrationScreenTest&) = delete; + LacrosDataMigrationScreenTest& operator=( + const LacrosDataMigrationScreenTest&) = delete; + ~LacrosDataMigrationScreenTest() override = default; + + void SetUpOnMainThread() override { + LoginDisplayHostMojo* login_display_host = + static_cast<LoginDisplayHostMojo*>(LoginDisplayHost::default_host()); + // Call `StartWizard()` with any screen to ensure that + // `LoginDisplayHostMojo::EnsureOobeDialogLoaded()` is called but do not + // show `LacrosDataMigrationScreen` yet because that will start the + // migration before stubbing certain methonds. + login_display_host->StartWizard(GaiaView::kScreenId); + LacrosDataMigrationScreen* lacros_data_migration_screen = + static_cast<LacrosDataMigrationScreen*>( + WizardController::default_controller()->GetScreen( + LacrosDataMigrationScreenView::kScreenId)); + fake_migrator_ = new FakeMigrator(); + lacros_data_migration_screen->SetMigratorDelegateForTesting( + base::WrapUnique(fake_migrator_)); + lacros_data_migration_screen->SetUserIdHashForTesting("user"); + OobeBaseTest::SetUpOnMainThread(); + } + + protected: + FakeMigrator* fake_migrator() { return fake_migrator_; } + + private: + // This is owned by `LacrosDataMigrationScreen`. + FakeMigrator* fake_migrator_; + DeviceStateMixin device_state_{ + &mixin_host_, DeviceStateMixin::State::OOBE_COMPLETED_CONSUMER_OWNED}; + LoginManagerMixin login_mixin_{&mixin_host_}; +}; + +IN_PROC_BROWSER_TEST_F(LacrosDataMigrationScreenTest, SkipButton) { + OobeScreenWaiter waiter(LacrosDataMigrationScreenView::kScreenId); + WizardController::default_controller()->AdvanceToScreen( + LacrosDataMigrationScreenView::kScreenId); + waiter.Wait(); + + test::OobeJS().ExpectHiddenPath(kSkipButton); + + LacrosDataMigrationScreen* lacros_data_migration_screen = + static_cast<LacrosDataMigrationScreen*>( + WizardController::default_controller()->GetScreen( + LacrosDataMigrationScreenView::kScreenId)); + lacros_data_migration_screen->ShowSkipButton(); + + test::OobeJS().ExpectVisiblePath(kSkipButton); + + EXPECT_FALSE(fake_migrator()->IsCancelCalled()); + test::OobeJS().TapOnPath(kSkipButton); + EXPECT_TRUE(fake_migrator()->IsCancelCalled()); +} +} // namespace +} // namespace ash
diff --git a/chrome/browser/ash/login/screens/recommend_apps/recommend_apps_fetcher_impl.cc b/chrome/browser/ash/login/screens/recommend_apps/recommend_apps_fetcher_impl.cc index 7bef2d9..a863d77 100644 --- a/chrome/browser/ash/login/screens/recommend_apps/recommend_apps_fetcher_impl.cc +++ b/chrome/browser/ash/login/screens/recommend_apps/recommend_apps_fetcher_impl.cc
@@ -50,6 +50,9 @@ constexpr const int kMaxAppCount = 21; +// Fake gpu info for test. +const gpu::GPUInfo* g_gpu_info_for_test = nullptr; + enum RecommendAppsResponseParseResult { // These values are persisted to logs. Entries should not be renumbered and // numeric values should never be reused. @@ -186,13 +189,15 @@ } const gpu::GPUInfo GetGPUInfo() { + if (g_gpu_info_for_test) + return *g_gpu_info_for_test; + return content::GpuDataManager::GetInstance()->GetGPUInfo(); } // This function converts the major and minor versions to the proto accepted // value. For example, if the version is 3.2, the return value is 0x00030002. -unsigned GetGLVersionInfo() { - const gpu::GPUInfo gpu_info = GetGPUInfo(); +unsigned GetGLVersionInfo(const gpu::GPUInfo& gpu_info) { gfx::ExtensionSet extensionSet(gfx::MakeExtensionSet(gpu_info.gl_extensions)); gl::GLVersionInfo glVersionInfo(gpu_info.gl_version.c_str(), gpu_info.gl_renderer.c_str(), extensionSet); @@ -206,8 +211,7 @@ return version; } -gfx::ExtensionSet GetGLExtensions() { - const gpu::GPUInfo gpu_info = GetGPUInfo(); +gfx::ExtensionSet GetGLExtensions(const gpu::GPUInfo& gpu_info) { gfx::ExtensionSet extensionSet(gfx::MakeExtensionSet(gpu_info.gl_extensions)); return extensionSet; @@ -259,6 +263,16 @@ } // namespace +RecommendAppsFetcherImpl::ScopedGpuInfoForTest::ScopedGpuInfoForTest( + const gpu::GPUInfo* gpu_info) { + DCHECK(!g_gpu_info_for_test); + g_gpu_info_for_test = gpu_info; +} + +RecommendAppsFetcherImpl::ScopedGpuInfoForTest::~ScopedGpuInfoForTest() { + g_gpu_info_for_test = nullptr; +} + RecommendAppsFetcherImpl::RecommendAppsFetcherImpl( RecommendAppsFetcherDelegate* delegate, mojo::PendingRemote<mojom::CrosDisplayConfigController> display_config, @@ -307,9 +321,10 @@ DeviceConfigurationProto_Navigation_NONAV); device_config_.set_has_five_way_navigation(false); - device_config_.set_gl_es_version(GetGLVersionInfo()); + const gpu::GPUInfo gpu_info = GetGPUInfo(); + device_config_.set_gl_es_version(GetGLVersionInfo(gpu_info)); - for (const base::StringPiece& gl_extension : GetGLExtensions()) { + for (const base::StringPiece& gl_extension : GetGLExtensions(gpu_info)) { if (!gl_extension.empty()) device_config_.add_gl_extension(std::string(gl_extension)); }
diff --git a/chrome/browser/ash/login/screens/recommend_apps/recommend_apps_fetcher_impl.h b/chrome/browser/ash/login/screens/recommend_apps/recommend_apps_fetcher_impl.h index 536d396..1af26ae5 100644 --- a/chrome/browser/ash/login/screens/recommend_apps/recommend_apps_fetcher_impl.h +++ b/chrome/browser/ash/login/screens/recommend_apps/recommend_apps_fetcher_impl.h
@@ -24,6 +24,10 @@ class Value; } +namespace gpu { +struct GPUInfo; +} + namespace network { namespace mojom { class URLLoaderFactory; @@ -57,6 +61,12 @@ // 13. gl_extension class RecommendAppsFetcherImpl : public RecommendAppsFetcher { public: + class ScopedGpuInfoForTest { + public: + explicit ScopedGpuInfoForTest(const gpu::GPUInfo* gpu_info); + ~ScopedGpuInfoForTest(); + }; + RecommendAppsFetcherImpl( RecommendAppsFetcherDelegate* delegate, mojo::PendingRemote<mojom::CrosDisplayConfigController> display_config,
diff --git a/chrome/browser/ash/login/screens/recommend_apps/recommend_apps_fetcher_impl_unittest.cc b/chrome/browser/ash/login/screens/recommend_apps/recommend_apps_fetcher_impl_unittest.cc index b245a09d..57a43d7 100644 --- a/chrome/browser/ash/login/screens/recommend_apps/recommend_apps_fetcher_impl_unittest.cc +++ b/chrome/browser/ash/login/screens/recommend_apps/recommend_apps_fetcher_impl_unittest.cc
@@ -23,6 +23,7 @@ #include "chrome/test/base/testing_profile_manager.h" #include "components/user_manager/scoped_user_manager.h" #include "content/public/test/browser_task_environment.h" +#include "gpu/config/gpu_info.h" #include "mojo/public/cpp/bindings/pending_associated_remote.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/receiver.h" @@ -1363,4 +1364,19 @@ delegate_.WaitForResult()); } +TEST_F(RecommendAppsFetcherImplTest, GpuInfo) { + ASSERT_TRUE(recommend_apps_fetcher_); + + gpu::GPUInfo gpu_info; + gpu_info.gl_version = "OpenGL ES 3.2 Mesa 21.2.3"; + gpu_info.gl_renderer = "Mesa DRI"; + gpu_info.gl_extensions = + "GL_EXT_texture_format_BGRA8888 GL_EXT_read_format_bgra"; + + RecommendAppsFetcherImpl::ScopedGpuInfoForTest scoped(&gpu_info); + + // `gpu_info` should be parsed without causing use-after-free. + recommend_apps_fetcher_->Start(); +} + } // namespace ash
diff --git a/chrome/browser/ash/login/session/user_session_manager.h b/chrome/browser/ash/login/session/user_session_manager.h index 51d7ad76..f1ba995 100644 --- a/chrome/browser/ash/login/session/user_session_manager.h +++ b/chrome/browser/ash/login/session/user_session_manager.h
@@ -12,6 +12,7 @@ #include <string> #include <vector> +#include "ash/components/arc/net/always_on_vpn_manager.h" #include "base/callback.h" #include "base/containers/flat_map.h" #include "base/memory/ref_counted.h" @@ -45,7 +46,6 @@ // TODO(https://crbug.com/1164001): move to forward declaration. #include "chromeos/login/auth/stub_authenticator_builder.h" #include "chromeos/login/auth/user_context.h" -#include "components/arc/net/always_on_vpn_manager.h" #include "components/user_manager/user.h" #include "components/user_manager/user_manager.h" #include "services/network/public/cpp/network_connection_tracker.h"
diff --git a/chrome/browser/ash/preferences.cc b/chrome/browser/ash/preferences.cc index 645c585c..b8f4140 100644 --- a/chrome/browser/ash/preferences.cc +++ b/chrome/browser/ash/preferences.cc
@@ -484,6 +484,10 @@ registry->RegisterListPref( ::prefs::kRestrictedManagedGuestSessionExtensionCleanupExemptList); + + registry->RegisterListPref( + prefs::kFilesAppFolderShortcuts, + user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); } void Preferences::InitUserPrefs(sync_preferences::PrefServiceSyncable* prefs) {
diff --git a/chrome/browser/ash/system/fake_input_device_settings.cc b/chrome/browser/ash/system/fake_input_device_settings.cc index 27add54..39a68af 100644 --- a/chrome/browser/ash/system/fake_input_device_settings.cc +++ b/chrome/browser/ash/system/fake_input_device_settings.cc
@@ -37,6 +37,11 @@ UpdateTouchpadSettings(settings); } +void FakeInputDeviceSettings::HapticTouchpadExists( + DeviceExistsCallback callback) { + std::move(callback).Run(haptic_touchpad_exists_); +} + void FakeInputDeviceSettings::SetTouchpadHapticFeedback(bool enabled) { TouchpadSettings settings; settings.SetHapticFeedback(enabled); @@ -175,6 +180,10 @@ touchpad_exists_ = exists; } +void FakeInputDeviceSettings::set_haptic_touchpad_exists(bool exists) { + haptic_touchpad_exists_ = exists; +} + void FakeInputDeviceSettings::set_mouse_exists(bool exists) { mouse_exists_ = exists; }
diff --git a/chrome/browser/ash/system/fake_input_device_settings.h b/chrome/browser/ash/system/fake_input_device_settings.h index 2613e27..8f04761a 100644 --- a/chrome/browser/ash/system/fake_input_device_settings.h +++ b/chrome/browser/ash/system/fake_input_device_settings.h
@@ -27,6 +27,7 @@ void UpdateTouchpadSettings(const TouchpadSettings& settings) override; void SetTouchpadSensitivity(int value) override; void SetTouchpadScrollSensitivity(int value) override; + void HapticTouchpadExists(DeviceExistsCallback callback) override; void SetTouchpadHapticFeedback(bool enabled) override; void SetTouchpadHapticClickSensitivity(int value) override; void SetTapToClick(bool enabled) override; @@ -56,6 +57,7 @@ // Overridden from InputDeviceSettings::FakeInterface. void set_touchpad_exists(bool exists) override; + void set_haptic_touchpad_exists(bool exists) override; void set_mouse_exists(bool exists) override; void set_pointing_stick_exists(bool exists) override; const TouchpadSettings& current_touchpad_settings() const override; @@ -68,6 +70,7 @@ PointingStickSettings current_pointing_stick_settings_; bool touchpad_exists_ = true; + bool haptic_touchpad_exists_ = true; bool mouse_exists_ = true; bool pointing_stick_exists_ = true; };
diff --git a/chrome/browser/ash/system/input_device_settings.h b/chrome/browser/ash/system/input_device_settings.h index 790ee95..13b6e36 100644 --- a/chrome/browser/ash/system/input_device_settings.h +++ b/chrome/browser/ash/system/input_device_settings.h
@@ -198,6 +198,7 @@ class FakeInterface { public: virtual void set_touchpad_exists(bool exists) = 0; + virtual void set_haptic_touchpad_exists(bool exists) = 0; virtual void set_mouse_exists(bool exists) = 0; virtual void set_pointing_stick_exists(bool exists) = 0; virtual const TouchpadSettings& current_touchpad_settings() const = 0; @@ -232,6 +233,10 @@ // kMaxPointerSensitivity]. virtual void SetTouchpadScrollSensitivity(int value) = 0; + // Calls |callback|, possibly asynchronously, after determining if at least + // one touchpad that supports haptics is connected. + virtual void HapticTouchpadExists(DeviceExistsCallback callback) = 0; + // Turns touchpad haptic feedback on/off. virtual void SetTouchpadHapticFeedback(bool enabled) = 0;
diff --git a/chrome/browser/ash/system/input_device_settings_impl_ozone.cc b/chrome/browser/ash/system/input_device_settings_impl_ozone.cc index 4c1085d1..7ee6135 100644 --- a/chrome/browser/ash/system/input_device_settings_impl_ozone.cc +++ b/chrome/browser/ash/system/input_device_settings_impl_ozone.cc
@@ -37,6 +37,7 @@ void UpdateTouchpadSettings(const TouchpadSettings& settings) override; void SetTouchpadSensitivity(int value) override; void SetTouchpadScrollSensitivity(int value) override; + void HapticTouchpadExists(DeviceExistsCallback callback) override; void SetTouchpadHapticFeedback(bool enabled) override; void SetTouchpadHapticClickSensitivity(int value) override; void SetTapToClick(bool enabled) override; @@ -104,6 +105,12 @@ input_controller()->SetTouchpadScrollSensitivity(value); } +void InputDeviceSettingsImplOzone::HapticTouchpadExists( + DeviceExistsCallback callback) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + std::move(callback).Run(input_controller()->HasHapticTouchpad()); +} + void InputDeviceSettingsImplOzone::SetTouchpadHapticFeedback(bool enabled) { current_touchpad_settings_.SetHapticFeedback(enabled); input_controller()->SetTouchpadHapticFeedback(enabled);
diff --git a/chrome/browser/ash/system/pointer_device_observer.cc b/chrome/browser/ash/system/pointer_device_observer.cc index 368b97b9..8b72b4c 100644 --- a/chrome/browser/ash/system/pointer_device_observer.cc +++ b/chrome/browser/ash/system/pointer_device_observer.cc
@@ -29,6 +29,7 @@ CheckMouseExists(); CheckPointingStickExists(); CheckTouchpadExists(); + CheckHapticTouchpadExists(); } void PointerDeviceObserver::AddObserver(Observer* observer) { @@ -52,6 +53,12 @@ &PointerDeviceObserver::OnTouchpadExists, weak_factory_.GetWeakPtr())); } +void PointerDeviceObserver::CheckHapticTouchpadExists() { + InputDeviceSettings::Get()->HapticTouchpadExists( + base::BindOnce(&PointerDeviceObserver::OnHapticTouchpadExists, + weak_factory_.GetWeakPtr())); +} + void PointerDeviceObserver::CheckMouseExists() { InputDeviceSettings::Get()->MouseExists(base::BindOnce( &PointerDeviceObserver::OnMouseExists, weak_factory_.GetWeakPtr())); @@ -68,6 +75,11 @@ observer.TouchpadExists(exists); } +void PointerDeviceObserver::OnHapticTouchpadExists(bool exists) { + for (auto& observer : observers_) + observer.HapticTouchpadExists(exists); +} + void PointerDeviceObserver::OnMouseExists(bool exists) { for (auto& observer : observers_) observer.MouseExists(exists);
diff --git a/chrome/browser/ash/system/pointer_device_observer.h b/chrome/browser/ash/system/pointer_device_observer.h index 5bff742..2b854ed9 100644 --- a/chrome/browser/ash/system/pointer_device_observer.h +++ b/chrome/browser/ash/system/pointer_device_observer.h
@@ -30,6 +30,7 @@ class Observer { public: virtual void TouchpadExists(bool exists) = 0; + virtual void HapticTouchpadExists(bool exists) = 0; virtual void MouseExists(bool exists) = 0; virtual void PointingStickExists(bool exists) = 0; @@ -46,11 +47,13 @@ // Check for pointer devices. void CheckTouchpadExists(); + void CheckHapticTouchpadExists(); void CheckMouseExists(); void CheckPointingStickExists(); // Callback for pointer device checks. void OnTouchpadExists(bool exists); + void OnHapticTouchpadExists(bool exists); void OnMouseExists(bool exists); void OnPointingStickExists(bool exists);
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 7c6061f1..fbda6f6 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc
@@ -241,7 +241,6 @@ #include "components/variations/variations_associated_data.h" #include "components/variations/variations_switches.h" #include "content/public/browser/browser_child_process_host.h" -#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_main_parts.h" #include "content/public/browser/browser_ppapi_host.h" #include "content/public/browser/browser_task_traits.h" @@ -1314,9 +1313,6 @@ true); registry->RegisterDictionaryPref( policy::policy_prefs::kCopyPreventionSettings); - registry->RegisterIntegerPref( - prefs::kUserAgentReduction, - UserAgentReductionEnterprisePolicyState::kDefault); } // static @@ -5313,7 +5309,7 @@ cert_verifier_creation_params); } else { // Set default params. - network_context_params->user_agent = GetUserAgentBasedOnPolicy(context); + network_context_params->user_agent = GetUserAgent(); network_context_params->accept_language = GetApplicationLocale(); } } @@ -5792,19 +5788,6 @@ return embedder_support::GetUserAgent(); } -std::string ChromeContentBrowserClient::GetUserAgentBasedOnPolicy( - content::BrowserContext* context) { - switch (GetUserAgentReductionEnterprisePolicyState(context)) { - case UserAgentReductionEnterprisePolicyState::kForceDisabled: - return embedder_support::GetFullUserAgent(); - case UserAgentReductionEnterprisePolicyState::kForceEnabled: - return GetReducedUserAgent(); - case UserAgentReductionEnterprisePolicyState::kDefault: - default: - return GetUserAgent(); - } -} - std::string ChromeContentBrowserClient::GetReducedUserAgent() { return embedder_support::GetReducedUserAgent(); } @@ -6325,20 +6308,3 @@ } } #endif - -ChromeContentBrowserClient::UserAgentReductionEnterprisePolicyState -ChromeContentBrowserClient::GetUserAgentReductionEnterprisePolicyState( - content::BrowserContext* context) { - int policy = Profile::FromBrowserContext(context)->GetPrefs()->GetInteger( - prefs::kUserAgentReduction); - switch (policy) { - case 0: - return UserAgentReductionEnterprisePolicyState::kDefault; - case 1: - return UserAgentReductionEnterprisePolicyState::kForceDisabled; - case 2: - return UserAgentReductionEnterprisePolicyState::kForceEnabled; - } - - return UserAgentReductionEnterprisePolicyState::kDefault; -}
diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h index 9c4089f..a4f28371 100644 --- a/chrome/browser/chrome_content_browser_client.h +++ b/chrome/browser/chrome_content_browser_client.h
@@ -634,8 +634,6 @@ std::string GetProduct() override; std::string GetUserAgent() override; - std::string GetUserAgentBasedOnPolicy( - content::BrowserContext* context) override; std::string GetReducedUserAgent() override; blink::UserAgentMetadata GetUserAgentMetadata() override; @@ -756,12 +754,6 @@ bool IsFindInPageDisabledForOrigin(const url::Origin& origin) override; - enum UserAgentReductionEnterprisePolicyState { - kDefault = 0, - kForceDisabled = 1, - kForceEnabled = 2, - }; - protected: static bool HandleWebUI(GURL* url, content::BrowserContext* browser_context); static bool HandleWebUIReverse(GURL* url, @@ -848,9 +840,6 @@ std::unique_ptr<ScopedKeepAlive> keep_alive_handle); #endif - UserAgentReductionEnterprisePolicyState - GetUserAgentReductionEnterprisePolicyState(content::BrowserContext* context); - // Vector of additional ChromeContentBrowserClientParts. // Parts are deleted in the reverse order they are added. std::vector<ChromeContentBrowserClientParts*> extra_parts_;
diff --git a/chrome/browser/chromeos/eche_app/eche_app_manager_factory.cc b/chrome/browser/chromeos/eche_app/eche_app_manager_factory.cc index 8e1641f..0fe0cecb 100644 --- a/chrome/browser/chromeos/eche_app/eche_app_manager_factory.cc +++ b/chrome/browser/chromeos/eche_app/eche_app_manager_factory.cc
@@ -149,7 +149,7 @@ if (absl::get<LaunchAppHelper::NotificationInfo::NotificationType>( info->type()) == LaunchAppHelper::NotificationInfo::NotificationType::kScreenLock) { - weak_ptr->notification_controller_->ShowScreenLockNotification(); + weak_ptr->notification_controller_->ShowScreenLockNotification(title); } } else if (info->category() == LaunchAppHelper::NotificationInfo::Category::kWebUI) {
diff --git a/chrome/browser/chromeos/eche_app/eche_app_notification_controller.cc b/chrome/browser/chromeos/eche_app/eche_app_notification_controller.cc index e74fd94..984dc47 100644 --- a/chrome/browser/chromeos/eche_app/eche_app_notification_controller.cc +++ b/chrome/browser/chromeos/eche_app/eche_app_notification_controller.cc
@@ -109,7 +109,8 @@ } } -void EcheAppNotificationController::ShowScreenLockNotification() { +void EcheAppNotificationController::ShowScreenLockNotification( + const absl::optional<std::u16string>& title) { message_center::RichNotificationData rich_notification_data; rich_notification_data.buttons.push_back(message_center::ButtonInfo( l10n_util::GetStringUTF16(IDS_ECHE_APP_SCREEN_LOCK_SETTINGS_BUTTON))); @@ -118,7 +119,8 @@ ShowNotification(CreateNotification( kEcheAppScreenLockNotifierId, - l10n_util::GetStringUTF16(IDS_ECHE_APP_SCREEN_LOCK_NOTIFICATION_TITLE), + l10n_util::GetStringFUTF16(IDS_ECHE_APP_SCREEN_LOCK_NOTIFICATION_TITLE, + title.value()), l10n_util::GetStringUTF16(IDS_ECHE_APP_SCREEN_LOCK_NOTIFICATION_MESSAGE), gfx::Image(), rich_notification_data, new NotificationDelegate(kEcheAppScreenLockNotifierId,
diff --git a/chrome/browser/chromeos/eche_app/eche_app_notification_controller.h b/chrome/browser/chromeos/eche_app/eche_app_notification_controller.h index 9f4ad8c1..7aadfc9 100644 --- a/chrome/browser/chromeos/eche_app/eche_app_notification_controller.h +++ b/chrome/browser/chromeos/eche_app/eche_app_notification_controller.h
@@ -32,7 +32,7 @@ // Shows the notification when screen lock is already enabled on the phone, // but the ChromeOS is not enabled. - void ShowScreenLockNotification(); + void ShowScreenLockNotification(const absl::optional<std::u16string>& title); // Shows the notification which was generated from WebUI and carry title and // message. void ShowNotificationFromWebUI(
diff --git a/chrome/browser/chromeos/eche_app/eche_app_notification_controller_unittest.cc b/chrome/browser/chromeos/eche_app/eche_app_notification_controller_unittest.cc index 69ce3a7..f8cafce 100644 --- a/chrome/browser/chromeos/eche_app/eche_app_notification_controller_unittest.cc +++ b/chrome/browser/chromeos/eche_app/eche_app_notification_controller_unittest.cc
@@ -74,7 +74,8 @@ }; TEST_F(EcheAppNotificationControllerTest, ShowScreenLockNotification) { - notification_controller_->ShowScreenLockNotification(); + absl::optional<std::u16string> title = u"title"; + notification_controller_->ShowScreenLockNotification(title); absl::optional<message_center::Notification> notification = display_service_->GetNotification(kEcheAppScreenLockNotifierId); ASSERT_TRUE(notification);
diff --git a/chrome/browser/chromeos/extensions/file_manager/event_router.cc b/chrome/browser/chromeos/extensions/file_manager/event_router.cc index 6a08fa22..de9d2b0 100644 --- a/chrome/browser/chromeos/extensions/file_manager/event_router.cc +++ b/chrome/browser/chromeos/extensions/file_manager/event_router.cc
@@ -14,6 +14,7 @@ #include "ash/components/arc/arc_prefs.h" #include "ash/components/drivefs/drivefs_host.h" #include "ash/constants/ash_features.h" +#include "ash/constants/ash_pref_names.h" #include "ash/public/cpp/tablet_mode.h" #include "base/bind.h" #include "base/command_line.h" @@ -653,6 +654,7 @@ pref_change_registrar_->Add(arc::prefs::kArcEnabled, callback); pref_change_registrar_->Add(arc::prefs::kArcHasAccessToRemovableMedia, callback); + pref_change_registrar_->Add(ash::prefs::kFilesAppFolderShortcuts, callback); auto plugin_vm_callback = base::BindRepeating(&EventRouter::OnPluginVmChanged, weak_factory_.GetWeakPtr());
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc index ac6358e..93bb958 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc
@@ -13,6 +13,7 @@ #include "ash/components/arc/arc_prefs.h" #include "ash/components/settings/timezone_settings.h" +#include "ash/constants/ash_pref_names.h" #include "ash/public/cpp/multi_user_window_manager.h" #include "ash/public/cpp/tablet_mode.h" #include "base/bind.h" @@ -242,6 +243,13 @@ result.arc_enabled = service->GetBoolean(arc::prefs::kArcEnabled); result.arc_removable_media_access_enabled = service->GetBoolean(arc::prefs::kArcHasAccessToRemovableMedia); + std::vector<std::string> folder_shortcuts; + const auto& value_list = + service->GetList(ash::prefs::kFilesAppFolderShortcuts)->GetList(); + for (const base::Value& value : value_list) { + folder_shortcuts.push_back(value.is_string() ? value.GetString() : ""); + } + result.folder_shortcuts = folder_shortcuts; return RespondNow( OneArgument(base::Value::FromUniquePtrValue(result.ToValue()))); @@ -269,6 +277,14 @@ arc::prefs::kArcHasAccessToRemovableMedia, *params->change_info.arc_removable_media_access_enabled); } + if (params->change_info.folder_shortcuts) { + std::vector<base::Value> folder_shortcuts; + for (auto& shortcut : *params->change_info.folder_shortcuts) { + folder_shortcuts.push_back(base::Value(shortcut)); + } + service->Set(ash::prefs::kFilesAppFolderShortcuts, + base::Value(std::move(folder_shortcuts))); + } return RespondNow(NoArguments()); }
diff --git a/chrome/browser/chromeos/fileapi/recent_arc_media_source.cc b/chrome/browser/chromeos/fileapi/recent_arc_media_source.cc index f28aae4b..df44729e 100644 --- a/chrome/browser/chromeos/fileapi/recent_arc_media_source.cc +++ b/chrome/browser/chromeos/fileapi/recent_arc_media_source.cc
@@ -35,7 +35,7 @@ const char kAndroidDownloadDirPrefix[] = "/storage/emulated/0/Download/"; // The path of the MyFiles directory inside Android. The UUID "0000....2019" is -// defined in components/arc/volume_mounter/arc_volume_mounter_bridge.cc. +// defined in ash/components/arc/volume_mounter/arc_volume_mounter_bridge.cc. // TODO(crbug.com/929031): Move MyFiles constants to a common place. const char kAndroidMyFilesDirPrefix[] = "/storage/0000000000000000000000000000CAFEF00D2019/";
diff --git a/chrome/browser/enterprise/connectors/device_trust/browser/browser_device_trust_connector_service.cc b/chrome/browser/enterprise/connectors/device_trust/browser/browser_device_trust_connector_service.cc new file mode 100644 index 0000000..5d629ae --- /dev/null +++ b/chrome/browser/enterprise/connectors/device_trust/browser/browser_device_trust_connector_service.cc
@@ -0,0 +1,26 @@ +// Copyright 2021 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/enterprise/connectors/device_trust/browser/browser_device_trust_connector_service.h" + +#include "components/enterprise/browser/device_trust/device_trust_key_manager.h" +#include "components/prefs/pref_service.h" + +namespace enterprise_connectors { + +BrowserDeviceTrustConnectorService::BrowserDeviceTrustConnectorService( + DeviceTrustKeyManager* key_manager, + PrefService* profile_prefs) + : DeviceTrustConnectorService(profile_prefs), key_manager_(key_manager) { + DCHECK(key_manager_); +} + +BrowserDeviceTrustConnectorService::~BrowserDeviceTrustConnectorService() = + default; + +void BrowserDeviceTrustConnectorService::OnConnectorEnabled() { + key_manager_->StartInitialization(); +} + +} // namespace enterprise_connectors
diff --git a/chrome/browser/enterprise/connectors/device_trust/browser/browser_device_trust_connector_service.h b/chrome/browser/enterprise/connectors/device_trust/browser/browser_device_trust_connector_service.h new file mode 100644 index 0000000..5202d4c --- /dev/null +++ b/chrome/browser/enterprise/connectors/device_trust/browser/browser_device_trust_connector_service.h
@@ -0,0 +1,42 @@ +// Copyright 2021 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_ENTERPRISE_CONNECTORS_DEVICE_TRUST_BROWSER_BROWSER_DEVICE_TRUST_CONNECTOR_SERVICE_H_ +#define CHROME_BROWSER_ENTERPRISE_CONNECTORS_DEVICE_TRUST_BROWSER_BROWSER_DEVICE_TRUST_CONNECTOR_SERVICE_H_ + +#include "chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service.h" + +class PrefService; + +namespace enterprise_connectors { + +class DeviceTrustKeyManager; + +// Browser-specific service in charge of monitoring the status of the Device +// Trust connector (e.g. enabled or not). +class BrowserDeviceTrustConnectorService : public DeviceTrustConnectorService { + public: + explicit BrowserDeviceTrustConnectorService( + DeviceTrustKeyManager* key_manager, + PrefService* profile_prefs); + + BrowserDeviceTrustConnectorService( + const BrowserDeviceTrustConnectorService&) = delete; + BrowserDeviceTrustConnectorService& operator=( + const BrowserDeviceTrustConnectorService&) = delete; + + ~BrowserDeviceTrustConnectorService() override; + + protected: + // Hook that can is called to notify that the policy changed and the connector + // became, or is still, enabled. + void OnConnectorEnabled() override; + + private: + DeviceTrustKeyManager* key_manager_; +}; + +} // namespace enterprise_connectors + +#endif // CHROME_BROWSER_ENTERPRISE_CONNECTORS_DEVICE_TRUST_BROWSER_BROWSER_DEVICE_TRUST_CONNECTOR_SERVICE_H_
diff --git a/chrome/browser/enterprise/connectors/device_trust/device_trust_browsertest.cc b/chrome/browser/enterprise/connectors/device_trust/device_trust_browsertest.cc index 49662bf..859c791a 100644 --- a/chrome/browser/enterprise/connectors/device_trust/device_trust_browsertest.cc +++ b/chrome/browser/enterprise/connectors/device_trust/device_trust_browsertest.cc
@@ -15,6 +15,7 @@ #include "chrome/browser/enterprise/connectors/connectors_prefs.h" #include "chrome/browser/enterprise/connectors/connectors_service.h" #include "chrome/browser/enterprise/connectors/device_trust/device_trust_features.h" +#include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/scoped_key_rotation_command_factory.h" #include "chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence/scoped_key_persistence_delegate_factory.h" #include "chrome/browser/enterprise/signals/device_info_fetcher.h" #include "chrome/browser/policy/chrome_browser_policy_connector.h" @@ -100,6 +101,7 @@ InProcessBrowserTest::SetUpOnMainThread(); scoped_persistence_delegate_factory_.emplace(); + scoped_rotation_command_factory_.emplace(); enterprise_signals::DeviceInfoFetcher::SetForceStubForTesting(true); auto* browser_policy_manager = @@ -208,6 +210,8 @@ challenge_response_request_; absl::optional<test::ScopedKeyPersistenceDelegateFactory> scoped_persistence_delegate_factory_; + absl::optional<ScopedKeyRotationCommandFactory> + scoped_rotation_command_factory_; }; // Tests that the whole attestation flow occurs when navigating to an allowed
diff --git a/chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service.cc b/chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service.cc index d88756c..6470f95d 100644 --- a/chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service.cc +++ b/chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service.cc
@@ -16,10 +16,6 @@ namespace { -bool IsFeatureEnabled() { - return base::FeatureList::IsEnabled(kDeviceTrustConnectorEnabled); -} - const base::ListValue* GetPolicyUrlPatterns(PrefService* prefs) { return prefs->GetList(kContextAwareAccessSignalsAllowlistPref); } @@ -34,7 +30,7 @@ // static bool DeviceTrustConnectorService::IsConnectorEnabled( PrefService* profile_prefs) { - if (!IsFeatureEnabled() || !profile_prefs) { + if (!IsDeviceTrustConnectorFeatureEnabled() || !profile_prefs) { return false; } @@ -46,7 +42,7 @@ : profile_prefs_(profile_prefs), matcher_(std::make_unique<url_matcher::URLMatcher>()) { DCHECK(profile_prefs_); - if (!IsFeatureEnabled()) { + if (!IsDeviceTrustConnectorFeatureEnabled()) { return; } @@ -75,7 +71,7 @@ } void DeviceTrustConnectorService::OnPolicyUpdated() { - DCHECK(IsFeatureEnabled()); + DCHECK(IsDeviceTrustConnectorFeatureEnabled()); const base::ListValue* url_patterns = GetPolicyUrlPatterns(profile_prefs_);
diff --git a/chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service_factory.cc b/chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service_factory.cc index cda6d44..f93b496 100644 --- a/chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service_factory.cc +++ b/chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service_factory.cc
@@ -5,11 +5,21 @@ #include "chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service_factory.h" #include "base/memory/singleton.h" +#include "build/build_config.h" #include "chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service.h" +#include "chrome/browser/enterprise/connectors/device_trust/device_trust_features.h" #include "chrome/browser/profiles/profile.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/core/keyed_service.h" +#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#include "chrome/browser/browser_process.h" +#include "chrome/browser/enterprise/connectors/device_trust/browser/browser_device_trust_connector_service.h" +#include "chrome/browser/policy/chrome_browser_policy_connector.h" +#include "components/enterprise/browser/controller/chrome_browser_cloud_management_controller.h" +#include "components/enterprise/browser/device_trust/device_trust_key_manager.h" +#endif // defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) + namespace enterprise_connectors { // static @@ -27,8 +37,11 @@ bool DeviceTrustConnectorServiceFactory::ServiceIsCreatedWithBrowserContext() const { - // TODO(b/204914180): Change this when ready to initialize the DT Key Manager. +#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) + return IsDeviceTrustConnectorFeatureEnabled(); +#else return false; +#endif // defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) } DeviceTrustConnectorServiceFactory::DeviceTrustConnectorServiceFactory() @@ -42,6 +55,16 @@ KeyedService* DeviceTrustConnectorServiceFactory::BuildServiceInstanceFor( content::BrowserContext* context) const { auto* profile = Profile::FromBrowserContext(context); + +#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) + if (IsDeviceTrustConnectorFeatureEnabled()) { + auto* key_manager = g_browser_process->browser_policy_connector() + ->chrome_browser_cloud_management_controller() + ->GetDeviceTrustKeyManager(); + return new BrowserDeviceTrustConnectorService(key_manager, + profile->GetPrefs()); + } +#endif // defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) return new DeviceTrustConnectorService(profile->GetPrefs()); }
diff --git a/chrome/browser/enterprise/connectors/device_trust/device_trust_features.cc b/chrome/browser/enterprise/connectors/device_trust/device_trust_features.cc index 82ada04..b909f59a 100644 --- a/chrome/browser/enterprise/connectors/device_trust/device_trust_features.cc +++ b/chrome/browser/enterprise/connectors/device_trust/device_trust_features.cc
@@ -9,4 +9,8 @@ const base::Feature kDeviceTrustConnectorEnabled{ "DeviceTrustConnectorEnabled", base::FEATURE_DISABLED_BY_DEFAULT}; +bool IsDeviceTrustConnectorFeatureEnabled() { + return base::FeatureList::IsEnabled(kDeviceTrustConnectorEnabled); +} + } // namespace enterprise_connectors
diff --git a/chrome/browser/enterprise/connectors/device_trust/device_trust_features.h b/chrome/browser/enterprise/connectors/device_trust/device_trust_features.h index 76cd6fc..f3f780524 100644 --- a/chrome/browser/enterprise/connectors/device_trust/device_trust_features.h +++ b/chrome/browser/enterprise/connectors/device_trust/device_trust_features.h
@@ -12,6 +12,9 @@ // Controls whether the Device Trust connector client code is enabled or not. extern const base::Feature kDeviceTrustConnectorEnabled; +// Return true if the device trust connector Finch feature is enabled. +bool IsDeviceTrustConnectorFeatureEnabled(); + } // namespace enterprise_connectors #endif // CHROME_BROWSER_ENTERPRISE_CONNECTORS_DEVICE_TRUST_DEVICE_TRUST_FEATURES_H_
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/key_rotation_command.h b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/key_rotation_command.h index a36a343..ec8c1595 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/key_rotation_command.h +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/key_rotation_command.h
@@ -37,7 +37,7 @@ // Kicks off a platform-specific key rotation command using the given // `params`. Invokes `callback` upon completion. - virtual bool Trigger(const Params& params, Callback callback) = 0; + virtual void Trigger(const Params& params, Callback callback) = 0; }; } // namespace enterprise_connectors
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/mock_key_rotation_command.h b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/mock_key_rotation_command.h index f22837b..f1f245d 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/mock_key_rotation_command.h +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/mock_key_rotation_command.h
@@ -17,7 +17,7 @@ ~MockKeyRotationCommand() override; // KeyRotationCommand: - MOCK_METHOD(bool, Trigger, (const Params&, Callback), (override)); + MOCK_METHOD(void, Trigger, (const Params&, Callback), (override)); }; } // namespace test
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/scoped_key_rotation_command_factory.cc b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/scoped_key_rotation_command_factory.cc index 33c65aac..1f125b3 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/scoped_key_rotation_command_factory.cc +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/scoped_key_rotation_command_factory.cc
@@ -26,10 +26,10 @@ std::unique_ptr<KeyRotationCommand> ScopedKeyRotationCommandFactory::CreateCommand() { - DCHECK(mock_key_rotation_command_); - auto temp = std::move(mock_key_rotation_command_); - mock_key_rotation_command_ = nullptr; - return temp; + if (mock_key_rotation_command_) { + return std::move(mock_key_rotation_command_); + } + return std::make_unique<testing::StrictMock<test::MockKeyRotationCommand>>(); } } // namespace enterprise_connectors
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.cc b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.cc index 27f30523..88f3b6ee 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.cc +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.cc
@@ -143,7 +143,7 @@ WinKeyRotationCommand::~WinKeyRotationCommand() = default; -bool WinKeyRotationCommand::Trigger(const KeyRotationCommand::Params& params, +void WinKeyRotationCommand::Trigger(const KeyRotationCommand::Params& params, Callback callback) { DCHECK(!callback.is_null()); @@ -202,8 +202,6 @@ }, params, run_elevated_command, waiting_enabled_), std::move(callback)); - - return true; } } // namespace enterprise_connectors
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.h b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.h index 0b93b0f..26ab0b2 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.h +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.h
@@ -35,7 +35,7 @@ ~WinKeyRotationCommand() override; // KeyRotationCommand: - bool Trigger(const Params& params, Callback callback) override; + void Trigger(const Params& params, Callback callback) override; // Enable or disable wait/sleep in tests to keep them from taking too long. void enable_waiting_for_testing(bool enabled) { waiting_enabled_ = enabled; }
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl.cc b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl.cc index 113e1e6..1a1a005 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl.cc +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl.cc
@@ -8,9 +8,11 @@ #include "base/check.h" #include "base/containers/span.h" #include "base/notreached.h" +#include "base/task/bind_post_task.h" #include "base/task/post_task.h" #include "base/task/task_traits.h" #include "base/task/thread_pool.h" +#include "base/threading/sequenced_task_runner_handle.h" #include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher.h" #include "chrome/browser/enterprise/connectors/device_trust/key_management/core/signing_key_pair.h" #include "crypto/unexportable_key.h" @@ -18,6 +20,19 @@ namespace enterprise_connectors { +namespace { + +absl::optional<std::vector<uint8_t>> SignString( + const std::string& str, + crypto::UnexportableSigningKey* key) { + if (!key) { + return absl::nullopt; + } + return key->SignSlowly(base::as_bytes(base::make_span(str))); +} + +} // namespace + DeviceTrustKeyManagerImpl::DeviceTrustKeyManagerImpl( std::unique_ptr<KeyRotationLauncher> key_rotation_launcher) : key_rotation_launcher_(std::move(key_rotation_launcher)), @@ -34,7 +49,10 @@ // Initialization is only needed when the manager is in its default state // with no loaded key. if (state_ == InitializationState::kDefault && !key_pair_) { - LoadKey(); + // Create a key upon loading failure iff a key was not already successfully + // created/rotated to prevent trying to re-create a key after failing to + // load it. + LoadKey(/*create_on_fail=*/!key_rotation_succeeded_); } } @@ -52,9 +70,9 @@ return; } - // TODO(b/204914180): Handle the requests based on the current state (queue, - // up requests, or retry loading the key). - std::move(callback).Run(absl::nullopt); + AddPendingRequest( + base::BindOnce(&DeviceTrustKeyManagerImpl::ResumeExportPublicKey, + weak_factory_.GetWeakPtr(), std::move(callback))); } void DeviceTrustKeyManagerImpl::SignStringAsync(const std::string& str, @@ -62,59 +80,130 @@ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (is_fully_initialized()) { background_task_runner_->PostTaskAndReplyWithResult( - FROM_HERE, - base::BindOnce(&crypto::UnexportableSigningKey::SignSlowly, - base::Unretained(key_pair_->key()), - base::as_bytes(base::make_span(str))), + FROM_HERE, base::BindOnce(&SignString, str, key_pair_->key()), std::move(callback)); return; } - // TODO(b/204914180): Handle the requests based on the current state (queue, - // up requests, or retry loading the key). - std::move(callback).Run(absl::nullopt); + AddPendingRequest(base::BindOnce(&DeviceTrustKeyManagerImpl::ResumeSignString, + weak_factory_.GetWeakPtr(), str, + std::move(callback))); } -void DeviceTrustKeyManagerImpl::LoadKey() { +void DeviceTrustKeyManagerImpl::AddPendingRequest( + base::OnceClosure pending_request) { + if (pending_request.is_null()) { + return; + } + + // Unsafe is fine as long as the pending closures are bound to a weak pointer. + pending_client_requests_.AddUnsafe(std::move(pending_request)); + + // Hook to allow the manager to fix itself if it is in a bad state. + StartInitialization(); +} + +void DeviceTrustKeyManagerImpl::LoadKey(bool create_on_fail) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); state_ = InitializationState::kLoadingKey; background_task_runner_->PostTaskAndReplyWithResult( FROM_HERE, base::BindOnce(&SigningKeyPair::LoadPersistedKey), base::BindOnce(&DeviceTrustKeyManagerImpl::OnKeyLoaded, - weak_factory_.GetWeakPtr())); + weak_factory_.GetWeakPtr(), create_on_fail)); } void DeviceTrustKeyManagerImpl::OnKeyLoaded( + bool create_on_fail, std::unique_ptr<SigningKeyPair> loaded_key_pair) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - if (loaded_key_pair) { + + if (loaded_key_pair && !loaded_key_pair->is_empty()) { key_pair_ = std::move(loaded_key_pair); - state_ = InitializationState::kDefault; + } else { + key_pair_.reset(); + } + + state_ = InitializationState::kDefault; + + if (!is_fully_initialized() && create_on_fail) { + // Key loading failed, so we can kick-off the key creation. This is + // guarded by a flag to make sure not to loop infinitely over: + // create succeeds -> load fails -> create again... + StartKeyRotationInner(/*nonce=*/std::string()); return; } - // Key loading failed, so we can kick-off the key creation. - StartKeyRotationInner(std::string()); + // Respond to callbacks. If a key was loaded, these callbacks will be + // successfully answered to. If a key was not loaded, then might as well + // respond with a failure instead of keeping them waiting even longer. + ResumePendingCallbacks(); } void DeviceTrustKeyManagerImpl::StartKeyRotationInner( const std::string& nonce) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - // TODO(b/204914180): Update logic once key creation can provide status - // updates. - state_ = InitializationState::kStartingKeyRotation; - background_task_runner_->PostTaskAndReplyWithResult( + state_ = InitializationState::kRotatingKey; + key_rotation_succeeded_ = false; + + KeyRotationCommand::Callback rotation_finished_callback = + base::BindOnce(&DeviceTrustKeyManagerImpl::OnKeyRotationFinished, + weak_factory_.GetWeakPtr()); + + background_task_runner_->PostTask( FROM_HERE, - base::BindOnce(&KeyRotationLauncher::LaunchKeyRotation, - base::Unretained(key_rotation_launcher_.get()), nonce, - base::DoNothing()), - base::BindOnce(&DeviceTrustKeyManagerImpl::OnKeyRotationStarted, - weak_factory_.GetWeakPtr())); + base::BindOnce( + &KeyRotationLauncher::LaunchKeyRotation, + base::Unretained(key_rotation_launcher_.get()), nonce, + base::BindPostTask(base::SequencedTaskRunnerHandle::Get(), + std::move(rotation_finished_callback)))); } -void DeviceTrustKeyManagerImpl::OnKeyRotationStarted(bool rotation_started) { +void DeviceTrustKeyManagerImpl::OnKeyRotationFinished( + KeyRotationCommand::Status result_status) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - state_ = InitializationState::kWaitingForKeyRotation; + key_rotation_succeeded_ = + result_status == KeyRotationCommand::Status::SUCCEEDED; + state_ = InitializationState::kDefault; + + if (key_rotation_succeeded_) { + LoadKey(/*create_on_fail=*/false); + return; + } + + // Two possible failure scenarios: + // - Either there was no key before and key creation failed, + // - Or there was a previous key and creation of a new key failed, so the old + // key was restored. + // In both cases, the manager doesn't need to try and reload the key (its + // loaded key is already either null or the old key). + // Just respond to the pending callbacks - if a key is still set, it will + // successfully respond to them. + ResumePendingCallbacks(); +} + +void DeviceTrustKeyManagerImpl::ResumePendingCallbacks() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + pending_client_requests_.Notify(); +} + +void DeviceTrustKeyManagerImpl::ResumeExportPublicKey( + ExportPublicKeyCallback callback) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + if (is_fully_initialized()) { + ExportPublicKeyAsync(std::move(callback)); + } else { + std::move(callback).Run(absl::nullopt); + } +} + +void DeviceTrustKeyManagerImpl::ResumeSignString(const std::string& str, + SignStringCallback callback) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + if (is_fully_initialized()) { + SignStringAsync(str, std::move(callback)); + } else { + std::move(callback).Run(absl::nullopt); + } } } // namespace enterprise_connectors
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl.h b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl.h index 750e039..bf1ee13 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl.h +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl.h
@@ -6,11 +6,15 @@ #define CHROME_BROWSER_ENTERPRISE_CONNECTORS_DEVICE_TRUST_KEY_MANAGEMENT_BROWSER_DEVICE_TRUST_KEY_MANAGER_IMPL_H_ #include <memory> +#include <vector> +#include "base/callback_forward.h" +#include "base/callback_list.h" #include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" #include "base/task/sequenced_task_runner.h" +#include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/key_rotation_command.h" #include "components/enterprise/browser/device_trust/device_trust_key_manager.h" namespace enterprise_connectors { @@ -41,24 +45,55 @@ } private: - enum class InitializationState { - kDefault, - kLoadingKey, - kStartingKeyRotation, - kWaitingForKeyRotation - }; + enum class InitializationState { kDefault, kLoadingKey, kRotatingKey }; - void LoadKey(); - void OnKeyLoaded(std::unique_ptr<SigningKeyPair> loaded_key_pair); + // Starts a background task to try and load the key. If `create_on_fail` is + // true, a key-creation task will be started if key loading fails. If it's + // false, the manager will simply respond to all pending callbacks. + void LoadKey(bool create_on_fail); + void OnKeyLoaded(bool create_on_fail, + std::unique_ptr<SigningKeyPair> loaded_key_pair); + // Starts a background task to try and rotate the key. Forwards `nonce` to + // the process in charge of handling the key rotation and upload. An empty + // nonce can be used to represent a key creation task, which means no key + // previously existed. void StartKeyRotationInner(const std::string& nonce); - void OnKeyRotationStarted(bool rotation_started); + void OnKeyRotationFinished(KeyRotationCommand::Status result_status); + // Adds `pending_request` to the list of pending client requests. Also calls + // the idempotent initialization process. If the manager is currently is + // a bad state, it will attempt to fix itself. A bad state example could be + // that the first initialization's create key process failed - this hook will + // attempt to retry. If the manager is already in the process of being + // initialized (or doing a key rotation), this call will effectively be a + // no-op. + // `pending_request` must not be bound a strong pointer. + void AddPendingRequest(base::OnceClosure pending_request); + + // Runs all of the pending callbacks. Will reply with valid values if the + // manager is fully initialized. Will reply with empty values if not. + void ResumePendingCallbacks(); + void ResumeExportPublicKey(ExportPublicKeyCallback callback); + void ResumeSignString(const std::string& str, SignStringCallback callback); + + // Owned instance in charge of creating and launching key rotation commands. std::unique_ptr<KeyRotationLauncher> key_rotation_launcher_; + // The manager's current initialization state. Depending on its value, + // incoming client requests can be marked as pending. InitializationState state_ = InitializationState::kDefault; + + // Currently loaded device-trust key pair. If nullptr, it effectively means + // that a key hasn't been loaded into memory yet. std::unique_ptr<SigningKeyPair> key_pair_; + // List of pending client requests. + base::OnceClosureList pending_client_requests_; + + // Represents whether the last key rotation process was successful or not. + bool key_rotation_succeeded_{false}; + // Runner for tasks needed to be run in the background. scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl_unittest.cc b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl_unittest.cc index c230e3bf..284fb20 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl_unittest.cc +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl_unittest.cc
@@ -4,6 +4,9 @@ #include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl.h" +#include "base/barrier_closure.h" +#include "base/callback_forward.h" +#include "base/run_loop.h" #include "base/test/bind.h" #include "base/test/task_environment.h" #include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher.h" @@ -15,6 +18,9 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" +using testing::_; +using testing::Invoke; +using testing::Return; using testing::StrictMock; namespace enterprise_connectors { @@ -23,6 +29,8 @@ namespace { +constexpr char kFakeData[] = "some fake string"; + enterprise_connectors::test::MockKeyPersistenceDelegate::KeyInfo CreateEmptyKey() { return {enterprise_management::BrowserPublicKeyUploadRequest:: @@ -74,8 +82,7 @@ private: base::test::TaskEnvironment task_environment_{ - base::test::TaskEnvironment::TimeSource::MOCK_TIME, - base::test::TaskEnvironment::ThreadPoolExecutionMode::QUEUED}; + base::test::TaskEnvironment::TimeSource::MOCK_TIME}; test::ScopedKeyPersistenceDelegateFactory persistence_delegate_factory_; StrictMock<MockKeyRotationLauncher>* mock_launcher_; @@ -90,54 +97,257 @@ key_manager()->StartInitialization(); - absl::optional<std::string> captured_str; - bool callback_called; + base::RunLoop run_loop; key_manager()->ExportPublicKeyAsync(base::BindLambdaForTesting( - [&captured_str, &callback_called](absl::optional<std::string> value) { - captured_str = value; - callback_called = true; + [&run_loop](absl::optional<std::string> value) { + EXPECT_TRUE(value); + EXPECT_FALSE(value->empty()); + run_loop.Quit(); })); - EXPECT_TRUE(callback_called); - EXPECT_FALSE(captured_str.has_value()); - - // Reset. - callback_called = false; - - RunUntilIdle(); - - key_manager()->ExportPublicKeyAsync(base::BindLambdaForTesting( - [&captured_str, &callback_called](absl::optional<std::string> value) { - captured_str = value; - callback_called = true; - })); - - EXPECT_TRUE(callback_called); - EXPECT_TRUE(captured_str.has_value()); + run_loop.Run(); } -// Tests that StartInitialization will trigger key creation if key loading was -// not successful. -TEST_F(DeviceTrustKeyManagerImplTest, Initialization_WithoutPersistedKey) { +// Tests that: +// - StartInitialization will trigger key creation if key loading was not +// successful. +// - Key creation succeeds and a key gets loaded successfully, +// - Then a client request gets replied successfully. +TEST_F(DeviceTrustKeyManagerImplTest, + Initialization_CreatesKey_LoadKeySuccess) { SetUpNoKey(); - EXPECT_CALL(*mock_launcher(), LaunchKeyRotation(std::string(), testing::_)) - .WillOnce(testing::Return(true)); + base::RunLoop create_key_loop; + KeyRotationCommand::Callback key_rotation_callback; + EXPECT_CALL(*mock_launcher(), LaunchKeyRotation(std::string(), _)) + .WillOnce(Invoke( + [&](const std::string& nonce, KeyRotationCommand::Callback callback) { + key_rotation_callback = std::move(callback); + create_key_loop.Quit(); + })); key_manager()->StartInitialization(); - RunUntilIdle(); - // Key creation will have been launched, but no key is yet loaded. - absl::optional<std::string> captured_str; - bool callback_called; + create_key_loop.Run(); + + // Mimic that the key is now loadable. + SetUpPersistedKey(); + ASSERT_FALSE(key_rotation_callback.is_null()); + std::move(key_rotation_callback).Run(KeyRotationCommand::Status::SUCCEEDED); + + // The manager should now respond to the callback as soon as the key is + // loaded. + base::RunLoop run_loop; key_manager()->ExportPublicKeyAsync(base::BindLambdaForTesting( - [&captured_str, &callback_called](absl::optional<std::string> value) { - captured_str = value; - callback_called = true; + [&run_loop](absl::optional<std::string> value) { + ASSERT_TRUE(value); + EXPECT_FALSE(value->empty()); + run_loop.Quit(); + })); + run_loop.Run(); +} + +// Tests that: +// - StartInitialization will trigger key creation if key loading was not +// successful. +// - Key creation succeeds, but the subsequent key loading fails. +// - Then a client request makes the key loading retry, but fail. +// - But no key creation happens again +// - Then a second client request makes the key load successfully. +TEST_F(DeviceTrustKeyManagerImplTest, + Initialization_CreatesKey_LoadKeyFail_Retry) { + SetUpNoKey(); + + KeyRotationCommand::Callback key_rotation_callback; + base::RunLoop create_key_loop; + EXPECT_CALL(*mock_launcher(), LaunchKeyRotation(std::string(), _)) + .WillOnce(Invoke( + [&](const std::string& nonce, KeyRotationCommand::Callback callback) { + key_rotation_callback = std::move(callback); + create_key_loop.Quit(); + })); + + key_manager()->StartInitialization(); + + create_key_loop.Run(); + + // Mimic that the key creation was successful, however set key loading mocks + // to mimic a loading failure. + SetUpNoKey(); + ASSERT_FALSE(key_rotation_callback.is_null()); + std::move(key_rotation_callback).Run(KeyRotationCommand::Status::SUCCEEDED); + + // The manager should now try to load the key upon receiving the client + // request, but will fail to do so. It will then reply with a failure to the + // client requests. + base::RunLoop fail_loop; + key_manager()->ExportPublicKeyAsync(base::BindLambdaForTesting( + [&fail_loop](absl::optional<std::string> value) { + EXPECT_FALSE(value); + fail_loop.Quit(); })); - EXPECT_TRUE(callback_called); - EXPECT_FALSE(captured_str.has_value()); + fail_loop.Run(); + + // Retry, but with a successful key loading this time. + SetUpPersistedKey(); + + base::RunLoop success_loop; + key_manager()->ExportPublicKeyAsync(base::BindLambdaForTesting( + [&success_loop](absl::optional<std::string> value) { + ASSERT_TRUE(value); + EXPECT_FALSE(value->empty()); + success_loop.Quit(); + })); + + success_loop.Run(); +} + +// Tests that: +// - StartInitialization will trigger key creation if key loading was not +// successful. +// - Key creation fails, +// - Subsequent client requests will retry key creation, +// - Key creation then succeeds, +// - Key loading succeeds, +// - The client request gets fulfilled. +TEST_F(DeviceTrustKeyManagerImplTest, Initialization_CreateFails_Retry) { + SetUpNoKey(); + + KeyRotationCommand::Callback failed_rotation_callback; + base::RunLoop create_key_fail_loop; + EXPECT_CALL(*mock_launcher(), LaunchKeyRotation(std::string(), _)) + .WillOnce(Invoke( + [&](const std::string& nonce, KeyRotationCommand::Callback callback) { + failed_rotation_callback = std::move(callback); + create_key_fail_loop.Quit(); + })); + + key_manager()->StartInitialization(); + + create_key_fail_loop.Run(); + + // Mimic that key creation failed. + SetUpNoKey(); + ASSERT_FALSE(failed_rotation_callback.is_null()); + std::move(failed_rotation_callback).Run(KeyRotationCommand::Status::FAILED); + RunUntilIdle(); + + KeyRotationCommand::Callback success_rotation_callback; + base::RunLoop create_key_success_loop; + EXPECT_CALL(*mock_launcher(), LaunchKeyRotation(std::string(), _)) + .WillOnce(Invoke( + [&](const std::string& nonce, KeyRotationCommand::Callback callback) { + success_rotation_callback = std::move(callback); + create_key_success_loop.Quit(); + })); + + // This client request will try to load the key, then fail (since key creation + // failed previously), and then trigger a successful key creation followed + // by a successful key loading. + base::RunLoop request_loop; + key_manager()->ExportPublicKeyAsync(base::BindLambdaForTesting( + [&request_loop](absl::optional<std::string> value) { + ASSERT_TRUE(value); + EXPECT_FALSE(value->empty()); + request_loop.Quit(); + })); + + create_key_success_loop.Run(); + + // Make the key creation return a successful status and fake that a key is + // loadable. + SetUpPersistedKey(); + ASSERT_FALSE(success_rotation_callback.is_null()); + std::move(success_rotation_callback) + .Run(KeyRotationCommand::Status::SUCCEEDED); + + // The client request should be responded to. + request_loop.Run(); +} + +// Tests a long and specific chain of events which are, in sequence: +// - Key Manager initialization started, +// - Key loading starts, +// - Client requests (batch 1) come in and are pending, +// - Key loading fails, +// - Key creation process is launched, +// - New client requests (batch 2) come in and are pending, +// - Key creation process succeeds. +// - Key loading starts, +// - New client requests (batch 3) come in and are pending, +// - Key loading succeeds. +// - All pending requests (batches 1, 2 and 3) are successfully answered. +// <end of test> +// This test also covers both client APIs (ExportPublicKeyAsync and +// SignStringAsync). +TEST_F(DeviceTrustKeyManagerImplTest, + Initialization_CreatesKey_SubsequentConcurrentCalls) { + SetUpNoKey(); + + KeyRotationCommand::Callback key_rotation_callback; + base::RunLoop create_key_loop; + EXPECT_CALL(*mock_launcher(), LaunchKeyRotation(std::string(), _)) + .WillOnce(Invoke( + [&](const std::string& nonce, KeyRotationCommand::Callback callback) { + key_rotation_callback = std::move(callback); + create_key_loop.Quit(); + })); + + key_manager()->StartInitialization(); + + // A total of 6 callbacks will be marked as pending during this whole test. + base::RunLoop barrier_loop; + base::RepeatingClosure barrier_closure = + base::BarrierClosure(6, barrier_loop.QuitClosure()); + + auto export_key_counter = 0; + auto export_key_callback = + base::BindLambdaForTesting([&export_key_counter, &barrier_closure]( + absl::optional<std::string> value) { + ASSERT_TRUE(value); + EXPECT_FALSE(value->empty()); + ++export_key_counter; + barrier_closure.Run(); + }); + + auto sign_string_counter = 0; + auto sign_string_callback = base::BindLambdaForTesting( + [&sign_string_counter, + &barrier_closure](absl::optional<std::vector<uint8_t>> value) { + ASSERT_TRUE(value); + EXPECT_FALSE(value->empty()); + ++sign_string_counter; + barrier_closure.Run(); + }); + + // These initial requests should be queued-up since the key is currently being + // created. + key_manager()->ExportPublicKeyAsync(export_key_callback); + key_manager()->SignStringAsync(kFakeData, sign_string_callback); + + create_key_loop.Run(); + + // Key creation should not be triggered again. + EXPECT_CALL(*mock_launcher(), LaunchKeyRotation(_, _)).Times(0); + + // Queue-up more requests, which should also be set as pending since key + // creation is still running. + key_manager()->ExportPublicKeyAsync(export_key_callback); + key_manager()->SignStringAsync(kFakeData, sign_string_callback); + + // Prepare for another key load, but with a valid key this time. + SetUpPersistedKey(); + ASSERT_FALSE(key_rotation_callback.is_null()); + std::move(key_rotation_callback).Run(KeyRotationCommand::Status::SUCCEEDED); + RunUntilIdle(); + + // Queue-up more requests, which should be executed normally. + key_manager()->ExportPublicKeyAsync(export_key_callback); + key_manager()->SignStringAsync(kFakeData, sign_string_callback); + + // All pending callbacks should get called now. + barrier_loop.Run(); } } // namespace enterprise_connectors
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher.h b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher.h index 66f75ca..757b5b4b 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher.h +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher.h
@@ -27,10 +27,9 @@ virtual ~KeyRotationLauncher() = default; // Builds a key rotation payload using `nonce`, and then kicks off a key - // rotation command. Returns true if the command was correctly triggered. - virtual bool LaunchKeyRotation(const std::string& nonce, - KeyRotationCommand::Callback callback) - WARN_UNUSED_RESULT = 0; + // rotation command. + virtual void LaunchKeyRotation(const std::string& nonce, + KeyRotationCommand::Callback callback) = 0; }; } // namespace enterprise_connectors
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher_impl.cc b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher_impl.cc index 8e49a46b..36ae3e8 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher_impl.cc +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher_impl.cc
@@ -26,11 +26,12 @@ } KeyRotationLauncherImpl::~KeyRotationLauncherImpl() = default; -bool KeyRotationLauncherImpl::LaunchKeyRotation( +void KeyRotationLauncherImpl::LaunchKeyRotation( const std::string& nonce, KeyRotationCommand::Callback callback) { if (!dm_token_storage_ || !device_management_service_) { - return false; + std::move(callback).Run(KeyRotationCommand::Status::FAILED); + return; } // Get the CBCM DM token. This will be needed later to send the new key's @@ -38,8 +39,10 @@ auto client_id = dm_token_storage_->RetrieveClientId(); auto dm_token = dm_token_storage_->RetrieveDMToken(); - if (!dm_token.is_valid()) - return false; + if (!dm_token.is_valid()) { + std::move(callback).Run(KeyRotationCommand::Status::FAILED); + return; + } // Get the DM server URL to upload the public key. Reuse // DMServerJobConfiguration to reuse the URL building steps. @@ -52,7 +55,7 @@ std::string dm_server_url = config.GetResourceRequest(false, 0)->url.spec(); KeyRotationCommand::Params params{dm_token.value(), dm_server_url, nonce}; - return KeyRotationCommandFactory::GetInstance()->CreateCommand()->Trigger( + KeyRotationCommandFactory::GetInstance()->CreateCommand()->Trigger( params, std::move(callback)); }
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher_impl.h b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher_impl.h index aaf68c1..739354b 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher_impl.h +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher_impl.h
@@ -22,7 +22,7 @@ ~KeyRotationLauncherImpl() override; // KeyRotationLauncher: - bool LaunchKeyRotation(const std::string& nonce, + void LaunchKeyRotation(const std::string& nonce, KeyRotationCommand::Callback callback) override; private:
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher_unittest.cc b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher_unittest.cc index 7fd19f2..8ce6caa 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher_unittest.cc +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher_unittest.cc
@@ -6,6 +6,7 @@ #include "base/callback_helpers.h" #include "base/check.h" +#include "base/test/bind.h" #include "base/test/task_environment.h" #include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/key_rotation_command.h" #include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/key_rotation_command_factory.h" @@ -66,11 +67,11 @@ [¶ms](const KeyRotationCommand::Params given_params, KeyRotationCommand::Callback callback) { params = given_params; - return true; + std::move(callback).Run(KeyRotationCommand::Status::SUCCEEDED); })); auto launcher = CreateLauncher(); - EXPECT_TRUE(launcher->LaunchKeyRotation(kNonce, base::DoNothing())); + launcher->LaunchKeyRotation(kNonce, base::DoNothing()); ASSERT_TRUE(params.has_value()); EXPECT_EQ(kNonce, params->nonce); @@ -83,7 +84,14 @@ fake_dm_token_storage_.SetDMToken(""); auto launcher = CreateLauncher(); - EXPECT_FALSE(launcher->LaunchKeyRotation(kNonce, base::DoNothing())); + bool callback_called; + launcher->LaunchKeyRotation( + kNonce, base::BindLambdaForTesting( + [&callback_called](KeyRotationCommand::Status status) { + EXPECT_EQ(KeyRotationCommand::Status::FAILED, status); + callback_called = true; + })); + EXPECT_TRUE(callback_called); } } // namespace enterprise_connectors
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/mock_key_rotation_launcher.h b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/mock_key_rotation_launcher.h index e1227c0..44b7298 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/mock_key_rotation_launcher.h +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/mock_key_rotation_launcher.h
@@ -16,7 +16,7 @@ MockKeyRotationLauncher(); ~MockKeyRotationLauncher() override; - MOCK_METHOD(bool, + MOCK_METHOD(void, LaunchKeyRotation, (const std::string&, KeyRotationCommand::Callback), (override));
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/core/signing_key_pair.h b/chrome/browser/enterprise/connectors/device_trust/key_management/core/signing_key_pair.h index 04342eae..9286990 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/core/signing_key_pair.h +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/core/signing_key_pair.h
@@ -47,6 +47,13 @@ ~SigningKeyPair(); + bool is_empty() const { + return trust_level_ == + enterprise_management::BrowserPublicKeyUploadRequest:: + KEY_TRUST_LEVEL_UNSPECIFIED || + !key(); + } + crypto::UnexportableSigningKey* key() const { return key_pair_ ? key_pair_.get() : nullptr; }
diff --git a/chrome/browser/extensions/updater/extension_updater.cc b/chrome/browser/extensions/updater/extension_updater.cc index 01737b3c..31a7e270 100644 --- a/chrome/browser/extensions/updater/extension_updater.cc +++ b/chrome/browser/extensions/updater/extension_updater.cc
@@ -53,6 +53,11 @@ #include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_url_handlers.h" +#if BUILDFLAG(IS_CHROMEOS_ASH) +#include "ash/components/settings/cros_settings_names.h" +#include "chrome/browser/ash/settings/cros_settings.h" +#endif // BUILDFLAG(IS_CHROMEOS_ASH) + using base::RandDouble; using base::RandInt; typedef extensions::ExtensionDownloaderDelegate::Error Error; @@ -297,6 +302,19 @@ ManifestFetchData::FetchPriority fetch_priority, ExtensionUpdateCheckParams* update_check_params) { DCHECK(update_service_); + + // In Kiosk mode extensions are downloaded and updated by the ExternalCache. + // Therefore we skip updates here to avoid conflicts. + bool kiosk_crx_manifest_update_url_ignored = false; +#if BUILDFLAG(IS_CHROMEOS_ASH) + user_manager::UserManager* user_manager = user_manager::UserManager::Get(); + if (user_manager && user_manager->IsLoggedInAsKioskApp()) { + ash::CrosSettings::Get()->GetBoolean( + ash::kKioskCRXManifestUpdateURLIgnored, + &kiosk_crx_manifest_update_url_ignored); + } +#endif + InProgressCheck& request = requests_in_progress_[request_id]; for (ExtensionSet::const_iterator extension_iter = extensions->begin(); extension_iter != extensions->end(); ++extension_iter) { @@ -309,13 +327,19 @@ // An extension might be overwritten by policy, and have its update url // changed. Make sure existing extensions aren't fetched again, if a // pending fetch for an extension with the same id already exists. - if (!base::Contains(pending_ids, extension_id)) { - if (CanUseUpdateService(extension_id)) { - update_check_params->update_info[extension_id] = ExtensionUpdateData(); - } else if (AddExtensionToDownloader(extension, request_id, - fetch_priority)) { - request.in_progress_ids.insert(extension_id); - } + if (base::Contains(pending_ids, extension_id)) + continue; + + if (extension.location() == mojom::ManifestLocation::kExternalPolicy && + kiosk_crx_manifest_update_url_ignored) { + continue; + } + + if (CanUseUpdateService(extension_id)) { + update_check_params->update_info[extension_id] = ExtensionUpdateData(); + } else if (AddExtensionToDownloader(extension, request_id, + fetch_priority)) { + request.in_progress_ids.insert(extension_id); } } }
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json index 38d55149..7fc5488 100644 --- a/chrome/browser/flag-metadata.json +++ b/chrome/browser/flag-metadata.json
@@ -5315,7 +5315,7 @@ { "name": "traffic-counters-settings-ui", "owners": ["khegde", "stevenjb"], - "expiry_milestone": 95 + "expiry_milestone": 101 }, { "name": "translate-assist-content",
diff --git a/chrome/browser/net/cookie_store_sameparty_browsertest.cc b/chrome/browser/net/cookie_store_sameparty_browsertest.cc new file mode 100644 index 0000000..2d8c3f1 --- /dev/null +++ b/chrome/browser/net/cookie_store_sameparty_browsertest.cc
@@ -0,0 +1,155 @@ +// Copyright (c) 2021 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 "base/path_service.h" +#include "base/strings/strcat.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/test/base/in_process_browser_test.h" +#include "chrome/test/base/ui_test_utils.h" +#include "content/public/common/content_paths.h" +#include "content/public/common/content_switches.h" +#include "content/public/test/browser_test.h" +#include "content/public/test/browser_test_utils.h" +#include "net/cookies/canonical_cookie_test_helpers.h" +#include "net/dns/mock_host_resolver.h" +#include "net/test/embedded_test_server/embedded_test_server.h" +#include "services/network/public/cpp/network_switches.h" +#include "services/network/public/mojom/cookie_manager.mojom.h" +#include "testing/gmock/include/gmock/gmock-matchers.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +const char* kSamePartySameSiteLaxCookieName = "sameparty_samesite_lax_cookie"; +const char* kSamePartySameSiteNoneCookieName = "sameparty_samesite_none_cookie"; +const char* kSamePartySameSiteUnspecifiedCookieName = + "sameparty_samesite_unspecified_cookie"; +const char* kSameSiteNoneCookieName = "samesite_none_cookie"; + +class CookieStoreSamePartyTest : public InProcessBrowserTest { + public: + CookieStoreSamePartyTest() + : https_server_(net::EmbeddedTestServer::TYPE_HTTPS) {} + + CookieStoreSamePartyTest(const CookieStoreSamePartyTest&) = delete; + CookieStoreSamePartyTest& operator=(const CookieStoreSamePartyTest&) = delete; + + void SetUpCommandLine(base::CommandLine* command_line) override { + InProcessBrowserTest::SetUpCommandLine(command_line); + command_line->AppendSwitchASCII(network::switches::kUseFirstPartySet, + "https://a.test,https://b.test"); + } + + void SetUpOnMainThread() override { + host_resolver()->AddRule("*", "127.0.0.1"); + base::FilePath path; + base::PathService::Get(content::DIR_TEST_DATA, &path); + https_server_.ServeFilesFromDirectory(path); + https_server_.AddDefaultHandlers(GetChromeTestDataDir()); + https_server_.SetSSLConfig(net::EmbeddedTestServer::CERT_TEST_NAMES); + ASSERT_TRUE(https_server_.Start()); + } + + content::WebContents* contents() { + return browser()->tab_strip_model()->GetActiveWebContents(); + } + + content::RenderFrameHost* GetDescendantFrame( + const std::vector<int>& indices) { + content::RenderFrameHost* frame = contents()->GetMainFrame(); + for (int index : indices) { + frame = ChildFrameAt(frame, index); + } + return frame; + } + + std::string GetCookiesViaCookieStore(content::RenderFrameHost* frame) { + std::string script = R"( + (async () => { + const cookies = await cookieStore.getAll(); + return cookies.map(c => `${c.name}=${c.value}`).join(';'); + })(); + )"; + return content::EvalJs(frame, script).ExtractString(); + } + + void SetSamePartyCookies(const std::string& host) { + Profile* profile = browser()->profile(); + ASSERT_TRUE(content::SetCookie( + profile, https_server().GetURL(host, "/"), + base::StrCat({kSamePartySameSiteLaxCookieName, + "=1; samesite=lax; secure; sameparty"}))); + ASSERT_TRUE(content::SetCookie( + profile, https_server().GetURL(host, "/"), + base::StrCat({kSamePartySameSiteNoneCookieName, + "=1; samesite=none; secure; sameparty"}))); + ASSERT_TRUE(content::SetCookie( + profile, https_server().GetURL(host, "/"), + base::StrCat({kSamePartySameSiteUnspecifiedCookieName, + "=1; secure; sameparty"}))); + ASSERT_TRUE(content::SetCookie( + profile, https_server().GetURL(host, "/"), + base::StrCat({kSameSiteNoneCookieName, "=1; samesite=none; secure"}))); + } + + const net::test_server::EmbeddedTestServer& https_server() const { + return https_server_; + } + + private: + net::test_server::EmbeddedTestServer https_server_; +}; + +IN_PROC_BROWSER_TEST_F(CookieStoreSamePartyTest, ReadCookies_SamePartyContext) { + SetSamePartyCookies("b.test"); + ASSERT_TRUE(NavigateToURL( + contents(), + https_server().GetURL("a.test", + base::StrCat({"/cross_site_iframe_factory.html?", + "a.test(b.test)"})))); + + EXPECT_THAT(GetCookiesViaCookieStore(GetDescendantFrame({0})), + net::CookieStringIs(testing::UnorderedElementsAre( + testing::Key(kSamePartySameSiteLaxCookieName), + testing::Key(kSamePartySameSiteNoneCookieName), + testing::Key(kSamePartySameSiteUnspecifiedCookieName), + testing::Key(kSameSiteNoneCookieName)))); +} + +IN_PROC_BROWSER_TEST_F(CookieStoreSamePartyTest, + ReadCookies_CrossPartyContext) { + SetSamePartyCookies("c.test"); + ASSERT_TRUE(NavigateToURL( + contents(), + https_server().GetURL("a.test", + base::StrCat({"/cross_site_iframe_factory.html?", + "a.test(c.test)"})))); + + // c.test isn't in the FPS, so SameParty is ignored, so we get SameSite=None + // cookies. + EXPECT_THAT(GetCookiesViaCookieStore(GetDescendantFrame({0})), + net::CookieStringIs(testing::UnorderedElementsAre( + testing::Key(kSamePartySameSiteNoneCookieName), + testing::Key(kSameSiteNoneCookieName)))); + + ASSERT_EQ(4U, content::DeleteCookies(browser()->profile(), + network::mojom::CookieDeletionFilter())); + + SetSamePartyCookies("b.test"); + ASSERT_TRUE(NavigateToURL( + contents(), + https_server().GetURL("a.test", + base::StrCat({"/cross_site_iframe_factory.html?", + "a.test(c.test(b.test))"})))); + + // SameParty is not ignored, so we get the SameSite=None cookie. + EXPECT_THAT(GetCookiesViaCookieStore(GetDescendantFrame({0, 0})), + net::CookieStringIs(testing::UnorderedElementsAre( + testing::Key(kSameSiteNoneCookieName)))); +} + +} // namespace
diff --git a/chrome/browser/new_tab_page/promos/promo_service.cc b/chrome/browser/new_tab_page/promos/promo_service.cc index 8b1673a..0893ff2 100644 --- a/chrome/browser/new_tab_page/promos/promo_service.cc +++ b/chrome/browser/new_tab_page/promos/promo_service.cc
@@ -234,6 +234,10 @@ registry->RegisterDictionaryPref(prefs::kNtpPromoBlocklist); } +const absl::optional<PromoData>& PromoService::promo_data() const { + return promo_data_; +} + void PromoService::AddObserver(PromoServiceObserver* observer) { observers_.AddObserver(observer); }
diff --git a/chrome/browser/new_tab_page/promos/promo_service.h b/chrome/browser/new_tab_page/promos/promo_service.h index 9db950b..731123f6 100644 --- a/chrome/browser/new_tab_page/promos/promo_service.h +++ b/chrome/browser/new_tab_page/promos/promo_service.h
@@ -57,8 +57,9 @@ static void RegisterProfilePrefs(PrefRegistrySimple* registry); - // Returns the currently cached middle-slot PromoData, if any. - const absl::optional<PromoData>& promo_data() const { return promo_data_; } + // Returns the currently cached middle-slot PromoData, if any. Virtual for + // testing. + virtual const absl::optional<PromoData>& promo_data() const; Status promo_status() const { return promo_status_; } // Requests an asynchronous refresh from the network. After the update @@ -66,8 +67,8 @@ virtual void Refresh(); // Add/remove observers. All observers must unregister themselves before the - // PromoService is destroyed. - void AddObserver(PromoServiceObserver* observer); + // PromoService is destroyed. Virtual for testing. + virtual void AddObserver(PromoServiceObserver* observer); void RemoveObserver(PromoServiceObserver* observer); // Marks |promo_id| as blocked from being shown again.
diff --git a/chrome/browser/page_load_metrics/observers/core/ukm_page_load_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/core/ukm_page_load_metrics_observer.cc index f4cee6c4..fd5fa795 100644 --- a/chrome/browser/page_load_metrics/observers/core/ukm_page_load_metrics_observer.cc +++ b/chrome/browser/page_load_metrics/observers/core/ukm_page_load_metrics_observer.cc
@@ -1045,8 +1045,8 @@ total_foreground_duration_); builder->SetPageVisitFinalStatus(static_cast<int>(page_visit_status)) - .SetExperimental_TotalForegroundDuration( - ukm::GetExponentialBucketMinForUserTiming( + .SetPageTiming_TotalForegroundDuration( + ukm::GetSemanticBucketMinForDurationTiming( total_foreground_duration_.InMilliseconds())); }
diff --git a/chrome/browser/page_load_metrics/observers/core/ukm_page_load_metrics_observer_unittest.cc b/chrome/browser/page_load_metrics/observers/core/ukm_page_load_metrics_observer_unittest.cc index 06ed626..6dd2493 100644 --- a/chrome/browser/page_load_metrics/observers/core/ukm_page_load_metrics_observer_unittest.cc +++ b/chrome/browser/page_load_metrics/observers/core/ukm_page_load_metrics_observer_unittest.cc
@@ -533,7 +533,7 @@ entry, PageLoad::kNavigation_PageTransitionName, ui::PAGE_TRANSITION_LINK); tester()->test_ukm_recorder().ExpectEntryMetric( - entry, PageLoad::kExperimental_TotalForegroundDurationName, 0); + entry, PageLoad::kPageTiming_TotalForegroundDurationName, 0); } TEST_F(UkmPageLoadMetricsObserverTest, FCPPlusPlus_DiscardBackgroundResult) {
diff --git a/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc b/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc index 6796e2a..c0f4bfb 100644 --- a/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc +++ b/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc
@@ -51,13 +51,16 @@ #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) #if defined(OS_WIN) -#include "chrome/browser/enterprise/connectors/device_trust/device_trust_features.h" -#include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl.h" -#include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher.h" #include "chrome/browser/policy/browser_dm_token_storage_win.h" #include "chrome/install_static/install_util.h" #endif // defined(OS_WIN) +#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MAC) +#include "chrome/browser/enterprise/connectors/device_trust/device_trust_features.h" +#include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl.h" +#include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher.h" +#endif // defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MAC) + #if defined(OS_FUCHSIA) #include "chrome/browser/policy/browser_dm_token_storage_fuchsia.h" #endif // defined(OS_FUCHSIA) @@ -240,16 +243,15 @@ std::unique_ptr<enterprise_connectors::DeviceTrustKeyManager> ChromeBrowserCloudManagementControllerDesktop::CreateDeviceTrustKeyManager() { -#if defined(OS_WIN) - if (base::FeatureList::IsEnabled( - enterprise_connectors::kDeviceTrustConnectorEnabled)) { +#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MAC) + if (enterprise_connectors::IsDeviceTrustConnectorFeatureEnabled()) { auto key_rotation_launcher = enterprise_connectors::KeyRotationLauncher::Create( BrowserDMTokenStorage::Get(), GetDeviceManagementService()); return std::make_unique<enterprise_connectors::DeviceTrustKeyManagerImpl>( std::move(key_rotation_launcher)); } -#endif // defined(OS_WIN) +#endif // defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MAC) return nullptr; }
diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc index 33ffa515..258e187 100644 --- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc +++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
@@ -1544,6 +1544,7 @@ { key::kWebSQLInThirdPartyContextEnabled, policy_prefs::kWebSQLInThirdPartyContextEnabled, base::Value::Type::BOOLEAN }, + { key::kCORSNonWildcardRequestHeadersSupport, prefs::kCorsNonWildcardRequestHeadersSupport, base::Value::Type::BOOLEAN }, @@ -1553,9 +1554,6 @@ { key::kCopyPreventionSettings, policy_prefs::kCopyPreventionSettings, base::Value::Type::DICTIONARY}, - { key::kUserAgentReduction, - prefs::kUserAgentReduction, - base::Value::Type::INTEGER}, }; // clang-format on
diff --git a/chrome/browser/prefetch/prefetch_proxy/chrome_speculation_host_delegate.cc b/chrome/browser/prefetch/prefetch_proxy/chrome_speculation_host_delegate.cc index 8e36c7a..61e5f0a 100644 --- a/chrome/browser/prefetch/prefetch_proxy/chrome_speculation_host_delegate.cc +++ b/chrome/browser/prefetch/prefetch_proxy/chrome_speculation_host_delegate.cc
@@ -52,16 +52,16 @@ // extracts the candidate's URL. auto should_process_entry = [&](const blink::mojom::SpeculationCandidatePtr& candidate) { + bool is_same_origin = + url::Origin::Create(candidate->url).IsSameOriginWith(origin); bool private_prefetch = candidate->requires_anonymous_client_ip_when_cross_origin && - !origin.IsSameOriginWith(url::Origin::Create(candidate->url)); - bool same_origin_prefetch = - url::Origin::Create(candidate->url).IsSameOriginWith(origin); + !is_same_origin; - if (!private_prefetch && !same_origin_prefetch) + if (!private_prefetch && !is_same_origin) return false; - if (same_origin_prefetch) { + if (is_same_origin) { DCHECK(!private_prefetch); if (candidate->action == blink::mojom::SpeculationAction::kPrefetchWithSubresources) {
diff --git a/chrome/browser/resources/chromeos/login/debug/debug.js b/chrome/browser/resources/chromeos/login/debug/debug.js index 51e0945..f8280213 100644 --- a/chrome/browser/resources/chromeos/login/debug/debug.js +++ b/chrome/browser/resources/chromeos/login/debug/debug.js
@@ -846,6 +846,14 @@ { id: 'lacros-data-migration', kind: ScreenKind.OTHER, + defaultState: 'default', + handledSteps: 'skip-revealed', + states: [{ + id: 'skip-revealed', + trigger: (screen) => { + screen.showSkipButton(); + } + }], }, { id: 'terms-of-service',
diff --git a/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.html b/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.html index 36b62aa..327d90601 100644 --- a/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.html +++ b/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.html
@@ -23,17 +23,23 @@ value="[[progressValue_]]"> </paper-progress> <div slot="subtitle"> - [[i18nDynamic(locale, 'lacrosDataMigrationSubtitle', progressValue_)]] + <p> + [[i18nDynamic(locale, 'lacrosDataMigrationSubtitle', progressValue_)]] + </p> + <p hidden="[[!canCancel_]]"> + [[i18nDynamic(locale, 'lacrosDataMigrationSkipSuggestion')]] + </p> </div> <div slot="content" class="flex layout vertical center center-justified"> <img src="/images/update_boot.svg" class="oobe-illustration" aria-hidden="true"> </div> <!-- Cancel button --> - <div slot="bottom-buttons" hidden="[[!canCancel]]" + <div slot="bottom-buttons" class="flex layout horizontal"> - <oobe-text-button id="cancelButton" on-click="onCancelButtonClicked_" - text-key="cancelButton"> + <oobe-text-button id="cancelButton" hidden="[[!canCancel_]]" + on-click="onCancelButtonClicked_" + text-key="lacrosDataMigrationSkipButton"> </oobe-text-button> </div> </oobe-adaptive-dialog>
diff --git a/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.js b/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.js index 7b58000..db53f8fce 100644 --- a/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.js +++ b/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.js
@@ -27,16 +27,19 @@ constructor() { super(); this.progressValue_ = 0; + this.canCancel_ = false; } static get properties() { return { progressValue_: {type: Number}, + + canCancel_: {type: Boolean} }; } get EXTERNAL_API() { - return ['setProgressValue']; + return ['setProgressValue', 'showSkipButton']; } /** @@ -47,6 +50,13 @@ this.progressValue_ = progress; } + /** + * Called to make the skip button visible. + */ + showSkipButton() { + this.canCancel_ = true; + } + ready() { super.ready(); this.initializeLoginScreen('LacrosDataMigrationScreen', { @@ -55,6 +65,7 @@ } onCancelButtonClicked_() { + assert(this.canCancel_); this.userActed('cancel'); } }
diff --git a/chrome/browser/resources/history/history_clusters/shared_style.html b/chrome/browser/resources/history/history_clusters/shared_style.html index ab0dc5cc..7be4d24 100644 --- a/chrome/browser/resources/history/history_clusters/shared_style.html +++ b/chrome/browser/resources/history/history_clusters/shared_style.html
@@ -13,7 +13,7 @@ box-sizing: border-box; font-size: 0.875rem; /* 14px */ height: var(--pill-height); - line-height: 22px; + line-height: 1.5; /* 21px */ } .pill-icon-start {
diff --git a/chrome/browser/resources/history/history_clusters/url_visit.html b/chrome/browser/resources/history/history_clusters/url_visit.html index 1abcd2ef..d5afe35 100644 --- a/chrome/browser/resources/history/history_clusters/url_visit.html +++ b/chrome/browser/resources/history/history_clusters/url_visit.html
@@ -3,7 +3,7 @@ align-items: center; cursor: pointer; display: flex; - height: 64px; + min-height: 64px; } :host(:hover) { @@ -49,14 +49,17 @@ } #title-and-annotations { + align-items: center; display: flex; - line-height: 28px; + line-height: 2; /* 28px */ } .annotation { + align-items: center; background-color: var(--annotation-background-color); border-radius: 4px; color: var(--annotation-text-color); + display: inline-flex; flex-shrink: 0; font-weight: 500; margin-inline-start: 12px; @@ -80,7 +83,7 @@ #hostname { color: var(--url-hostname-color); - line-height: 20px; + line-height: 1.5; /* 21px */ } #debug-info {
diff --git a/chrome/browser/resources/settings/chromeos/BUILD.gn b/chrome/browser/resources/settings/chromeos/BUILD.gn index 1540af35..d0bb6f67 100644 --- a/chrome/browser/resources/settings/chromeos/BUILD.gn +++ b/chrome/browser/resources/settings/chromeos/BUILD.gn
@@ -66,6 +66,7 @@ "chrome://resources/mojo/url/mojom/url.mojom-lite.js", "chrome://resources/mojo/skia/public/mojom/bitmap.mojom-lite.js", "chrome://resources/mojo/skia/public/mojom/image_info.mojom-lite.js", + "chrome://resources/mojo/skia/public/mojom/skcolor.mojom-webui.js", "app-management/app_management.mojom-lite.js", "os_apps_page/app_notification_handler.mojom-lite.js", "app-management/bitmap.mojom-lite.js",
diff --git a/chrome/browser/resources/settings/chromeos/crostini_page/BUILD.gn b/chrome/browser/resources/settings/chromeos/crostini_page/BUILD.gn index f98f7ca..250c8d0 100644 --- a/chrome/browser/resources/settings/chromeos/crostini_page/BUILD.gn +++ b/chrome/browser/resources/settings/chromeos/crostini_page/BUILD.gn
@@ -58,6 +58,7 @@ js_library("crostini_browser_proxy") { deps = [ + "//skia/public/mojom:mojom_js_library_for_compile", "//ui/webui/resources/cr_elements/cr_input:cr_input.m", "//ui/webui/resources/js:cr.m", "//ui/webui/resources/js:load_time_data.m",
diff --git a/chrome/browser/resources/settings/chromeos/crostini_page/crostini_browser_proxy.js b/chrome/browser/resources/settings/chromeos/crostini_page/crostini_browser_proxy.js index b21a859c..8980cef 100644 --- a/chrome/browser/resources/settings/chromeos/crostini_page/crostini_browser_proxy.js +++ b/chrome/browser/resources/settings/chromeos/crostini_page/crostini_browser_proxy.js
@@ -259,6 +259,12 @@ requestContainerInfo() {} /** + * @param {!ContainerId} containerId container id to update. + * @param {!skia.mojom.SkColor} badge_color new badge color for the container. + */ + setContainerBadgeColor(containerId, badge_color) {} + + /** * @param {!ContainerId} containerId id of container to stop, recovering * CPU and other resources. */ @@ -424,6 +430,11 @@ } /** @override */ + setContainerBadgeColor(containerId, badge_color) { + chrome.send('setContainerBadgeColor', [containerId, badge_color]); + } + + /** @override */ stopContainer(containerId) { chrome.send('stopContainer', [containerId]); }
diff --git a/chrome/browser/resources/settings/chromeos/crostini_page/crostini_extra_containers.html b/chrome/browser/resources/settings/chromeos/crostini_page/crostini_extra_containers.html index c7da4fc..ef3069e8 100644 --- a/chrome/browser/resources/settings/chromeos/crostini_page/crostini_extra_containers.html +++ b/chrome/browser/resources/settings/chromeos/crostini_page/crostini_extra_containers.html
@@ -46,6 +46,10 @@ aria-hidden="true"> $i18n{crostiniExtraContainersContainerIpLabel} </div> + <div id="color" + class="column-title vm-column" + aria-hidden="true"> + </div> </div> <template is="dom-repeat" items="[[allContainers_]]"> <div class="list-item"> @@ -58,6 +62,13 @@ <div class="vm-column" aria-hidden="true"> [[item.ipv4]] </div> + <div class="vm-column" + aria-hidden="true"> + <input type="color" + data-container-id="[[item.id]]" + value="[[item.badge_color]]" + on-change="onContainerColorChange_"> + </div> <cr-icon-button id="showContainerMenu[[index]]" class="icon-more-vert" title="$i18n{moreActions}"
diff --git a/chrome/browser/resources/settings/chromeos/crostini_page/crostini_extra_containers.js b/chrome/browser/resources/settings/chromeos/crostini_page/crostini_extra_containers.js index 064c7b8..1cfa2133 100644 --- a/chrome/browser/resources/settings/chromeos/crostini_page/crostini_extra_containers.js +++ b/chrome/browser/resources/settings/chromeos/crostini_page/crostini_extra_containers.js
@@ -16,6 +16,7 @@ import {CrActionMenuElement} from '//resources/cr_elements/cr_action_menu/cr_action_menu.js'; import {assert} from '//resources/js/assert.m.js'; +import {hexColorToSkColor} from '//resources/js/color_utils.js'; import {loadTimeData} from '//resources/js/load_time_data.m.js'; import {WebUIListenerBehavior, WebUIListenerBehaviorInterface} from '//resources/js/web_ui_listener_behavior.m.js'; import {html, mixinBehaviors, PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; @@ -138,6 +139,18 @@ } /** + * @param {!Event} event + * @private + */ + onContainerColorChange_(event) { + const containerId = + /** @type {ContainerId} */ (event.currentTarget['dataContainerId']); + + CrostiniBrowserProxyImpl.getInstance().setContainerBadgeColor( + containerId, hexColorToSkColor(event.target.value)); + } + + /** * @param {!ContainerInfo} info * @private */
diff --git a/chrome/browser/resources/settings/chromeos/device_page/device_page.html b/chrome/browser/resources/settings/chromeos/device_page/device_page.html index aa594a05..2134544 100644 --- a/chrome/browser/resources/settings/chromeos/device_page/device_page.html +++ b/chrome/browser/resources/settings/chromeos/device_page/device_page.html
@@ -34,7 +34,8 @@ <settings-pointers prefs="{{prefs}}" has-mouse="[[hasMouse_]]" has-pointing-stick="[[hasPointingStick_]]" - has-touchpad="[[hasTouchpad_]]"> + has-touchpad="[[hasTouchpad_]]" + has-haptic-touchpad="[[hasHapticTouchpad_]]"> </settings-pointers> </settings-subpage> </template>
diff --git a/chrome/browser/resources/settings/chromeos/device_page/device_page.js b/chrome/browser/resources/settings/chromeos/device_page/device_page.js index a55a846..4b892ab 100644 --- a/chrome/browser/resources/settings/chromeos/device_page/device_page.js +++ b/chrome/browser/resources/settings/chromeos/device_page/device_page.js
@@ -65,6 +65,13 @@ hasTouchpad_: Boolean, /** + * Whether the device has a haptic touchpad. If this is true, |hasTouchpad_| + * will also be true. + * @private + */ + hasHapticTouchpad_: Boolean, + + /** * |hasStylus_| is initialized to false so that dom-if behaves correctly. * @private */ @@ -140,6 +147,9 @@ 'has-pointing-stick-changed', this.set.bind(this, 'hasPointingStick_')); this.addWebUIListener( 'has-touchpad-changed', this.set.bind(this, 'hasTouchpad_')); + this.addWebUIListener( + 'has-haptic-touchpad-changed', + this.set.bind(this, 'hasHapticTouchpad_')); DevicePageBrowserProxyImpl.getInstance().initializePointers(); this.addWebUIListener(
diff --git a/chrome/browser/resources/settings/chromeos/device_page/pointers.html b/chrome/browser/resources/settings/chromeos/device_page/pointers.html index f889a153..784760cb 100644 --- a/chrome/browser/resources/settings/chromeos/device_page/pointers.html +++ b/chrome/browser/resources/settings/chromeos/device_page/pointers.html
@@ -188,42 +188,43 @@ </settings-slider> </div> </template> - <!--TODO(gavinwill): Check if device has a haptic touchpad.--> - <template is="dom-if" if="[[allowTouchpadHapticClickSettings_]]"> - <div class="settings-box"> - <div class="start" id="touchpadHapticClickSensitivityLabel" - aria-hidden="true"> - $i18n{touchpadHapticClickSensitivityLabel} - </div> + <template is="dom-if" if="[[hasHapticTouchpad]]"> + <template is="dom-if" if="[[allowTouchpadHapticClickSettings_]]"> + <div class="settings-box"> + <div class="start" id="touchpadHapticClickSensitivityLabel" + aria-hidden="true"> + $i18n{touchpadHapticClickSensitivityLabel} + </div> <settings-slider id="touchpadHapticClickSensitivity" pref="{{prefs.settings.touchpad.haptic_click_sensitivity}}" ticks="[[hapticClickSensitivityValues_]]" label-aria="$i18n{touchpadHapticClickSensitivityLabel}" label-min="$i18n{touchpadHapticLightClickLabel}" label-max="$i18n{touchpadHapticFirmClickLabel}" - deep-link-focus-id$="[[Setting.kTouchpadHapticClickSensitivity]]"> + deep-link-focus-id$= + "[[Setting.kTouchpadHapticClickSensitivity]]"> </settings-slider> - </div> - </template> - <!--TODO(gavinwill): Check if device has a haptic touchpad.--> - <template is="dom-if" if="[[allowTouchpadHapticFeedback_]]"> - <div class="settings-box" id="touchpadHapticFeedbackRow" - on-click="onTouchpadHapticFeedbackRowClicked_"> - <div class="start settings-box-text"> - <!--TODO(gavinwill): Add haptic feedback help link URL.--> - <localized-link - on-click="onLearnMoreLinkClicked_" - id="touchpadHapticFeedbackLabel" - localized-string="$i18n{touchpadHapticFeedbackLabel}" - link-url="#"> - </localized-link> </div> - <cr-toggle id="touchpadHapticFeedbackToggle" - checked="{{prefs.settings.touchpad.haptic_feedback.value}}" - aria-labelledby="touchpadHapticFeedbackRow" - deep-link-focus-id$="[[Setting.kTouchpadHapticFeedback]]"> - </cr-toggle> - </div> + </template> + <template is="dom-if" if="[[allowTouchpadHapticFeedback_]]"> + <div class="settings-box" id="touchpadHapticFeedbackRow" + on-click="onTouchpadHapticFeedbackRowClicked_"> + <div class="start settings-box-text"> + <!--TODO(gavinwill): Add haptic feedback help link URL.--> + <localized-link + on-click="onLearnMoreLinkClicked_" + id="touchpadHapticFeedbackLabel" + localized-string="$i18n{touchpadHapticFeedbackLabel}" + link-url="#"> + </localized-link> + </div> + <cr-toggle id="touchpadHapticFeedbackToggle" + checked="{{prefs.settings.touchpad.haptic_feedback.value}}" + aria-labelledby="touchpadHapticFeedbackRow" + deep-link-focus-id$="[[Setting.kTouchpadHapticFeedback]]"> + </cr-toggle> + </div> + </template> </template> <div class="settings-box" id="reverseScrollRow" on-click="onTouchpadReverseScrollRowClicked_">
diff --git a/chrome/browser/resources/settings/chromeos/device_page/pointers.js b/chrome/browser/resources/settings/chromeos/device_page/pointers.js index bb534b7..807e7d4d 100644 --- a/chrome/browser/resources/settings/chromeos/device_page/pointers.js +++ b/chrome/browser/resources/settings/chromeos/device_page/pointers.js
@@ -47,6 +47,8 @@ hasTouchpad: Boolean, + hasHapticTouchpad: Boolean, + swapPrimaryOptions: { readOnly: true, type: Array,
diff --git a/chrome/browser/signin/process_dice_header_delegate_impl.cc b/chrome/browser/signin/process_dice_header_delegate_impl.cc index 8b86090..8890ceb 100644 --- a/chrome/browser/signin/process_dice_header_delegate_impl.cc +++ b/chrome/browser/signin/process_dice_header_delegate_impl.cc
@@ -43,11 +43,10 @@ content::WebContents* web_contents, EnableSyncCallback enable_sync_callback, ShowSigninErrorCallback show_signin_error_callback) - : content::WebContentsObserver(web_contents), + : web_contents_(web_contents->GetWeakPtr()), profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), enable_sync_callback_(std::move(enable_sync_callback)), show_signin_error_callback_(std::move(show_signin_error_callback)) { - DCHECK(web_contents); DCHECK(profile_); DiceTabHelper* tab_helper = DiceTabHelper::FromWebContents(web_contents); @@ -86,13 +85,14 @@ // sync signin, but it is not always the case: the user may abandon the sync // signin and do a simple web signin in the same tab instead. DiceWebSigninInterceptorFactory::GetForProfile(profile_) - ->MaybeInterceptWebSignin(web_contents(), account_id, is_new_account, + ->MaybeInterceptWebSignin(web_contents_.get(), account_id, is_new_account, is_sync_signin_tab_); } void ProcessDiceHeaderDelegateImpl::EnableSync( const CoreAccountId& account_id) { - DiceTabHelper* tab_helper = GetDiceTabHelperFromWebContents(web_contents()); + DiceTabHelper* tab_helper = + GetDiceTabHelperFromWebContents(web_contents_.get()); if (tab_helper) tab_helper->OnSyncSigninFlowComplete(); @@ -101,7 +101,7 @@ return; } - content::WebContents* web_contents = this->web_contents(); + content::WebContents* web_contents = web_contents_.get(); VLOG(1) << "Start sync after web sign-in."; std::move(enable_sync_callback_) .Run(profile_, access_point_, promo_action_, reason_, web_contents, @@ -127,13 +127,14 @@ const std::string& email, const GoogleServiceAuthError& error) { DCHECK_NE(GoogleServiceAuthError::NONE, error.state()); - DiceTabHelper* tab_helper = GetDiceTabHelperFromWebContents(web_contents()); + DiceTabHelper* tab_helper = + GetDiceTabHelperFromWebContents(web_contents_.get()); if (tab_helper) tab_helper->OnSyncSigninFlowComplete(); bool should_enable_sync = ShouldEnableSync(); - content::WebContents* web_contents = this->web_contents(); + content::WebContents* web_contents = web_contents_.get(); if (should_enable_sync && web_contents) RedirectToNtp(web_contents);
diff --git a/chrome/browser/signin/process_dice_header_delegate_impl.h b/chrome/browser/signin/process_dice_header_delegate_impl.h index 6d515a27..1c911ff 100644 --- a/chrome/browser/signin/process_dice_header_delegate_impl.h +++ b/chrome/browser/signin/process_dice_header_delegate_impl.h
@@ -11,8 +11,8 @@ #include <string> #include "base/callback_forward.h" +#include "base/memory/weak_ptr.h" #include "components/signin/public/base/signin_metrics.h" -#include "content/public/browser/web_contents_observer.h" namespace content { class WebContents; @@ -21,8 +21,7 @@ class Profile; class SigninUIError; -class ProcessDiceHeaderDelegateImpl : public ProcessDiceHeaderDelegate, - public content::WebContentsObserver { +class ProcessDiceHeaderDelegateImpl : public ProcessDiceHeaderDelegate { public: // Callback starting Sync. using EnableSyncCallback = @@ -61,6 +60,7 @@ // Returns true if sync should be enabled after the user signs in. bool ShouldEnableSync(); + const base::WeakPtr<content::WebContents> web_contents_; Profile* profile_; EnableSyncCallback enable_sync_callback_; ShowSigninErrorCallback show_signin_error_callback_;
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index 078aade2..5e0423f 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -2139,6 +2139,8 @@ "ash/network/tether_notification_presenter.h", "ash/notification_badge_color_cache.cc", "ash/notification_badge_color_cache.h", + "ash/projector/pending_screencast_manager.cc", + "ash/projector/pending_screencast_manager.h", "ash/projector/projector_app_client_impl.cc", "ash/projector/projector_app_client_impl.h", "ash/projector/projector_client_impl.cc",
diff --git a/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunCoordinator.java b/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunCoordinator.java index 343e654..1be896c 100644 --- a/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunCoordinator.java +++ b/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunCoordinator.java
@@ -32,6 +32,16 @@ * @param state FRE state to record. */ void recordFreProgressHistogram(@MobileFreProgress int state); + + /** + * Opens google terms of service page in a CCT. + */ + void openTermsOfService(); + + /** + * Opens a dialog to get consent for recording UMA data. + */ + void openUmaDialog(); } private final SigninFirstRunMediator mMediator;
diff --git a/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunMediator.java b/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunMediator.java index 0fac5dc..47d1437 100644 --- a/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunMediator.java +++ b/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunMediator.java
@@ -6,6 +6,7 @@ import android.accounts.Account; import android.content.Context; +import android.text.SpannableString; import android.text.TextUtils; import androidx.annotation.Nullable; @@ -32,6 +33,8 @@ import org.chromium.components.signin.metrics.SignoutReason; import org.chromium.ui.modaldialog.ModalDialogManager; import org.chromium.ui.modelutil.PropertyModel; +import org.chromium.ui.text.NoUnderlineClickableSpan; +import org.chromium.ui.text.SpanApplier; import java.util.List; @@ -55,7 +58,7 @@ mProfileDataCache = ProfileDataCache.createWithDefaultImageSizeAndNoBadge(mContext); mModel = SigninFirstRunProperties.createModel(this::onSelectedAccountClicked, this::onContinueAsClicked, this::onDismissClicked, - ExternalAuthUtils.getInstance().canUseGooglePlayServices()); + ExternalAuthUtils.getInstance().canUseGooglePlayServices(), getFooterString()); mProfileDataCache.addObserver(this); @@ -217,4 +220,14 @@ // Selected account data will be updated in {@link #onProfileDataUpdated} mProfileDataCache.setBadge(isChild ? R.drawable.ic_account_child_20dp : 0); } + + private SpannableString getFooterString() { + final NoUnderlineClickableSpan clickableTermsOfServiceSpan = new NoUnderlineClickableSpan( + mContext.getResources(), view -> mDelegate.openTermsOfService()); + final NoUnderlineClickableSpan clickableUMADialogSpan = new NoUnderlineClickableSpan( + mContext.getResources(), view -> mDelegate.openUmaDialog()); + return SpanApplier.applySpans(mContext.getString(R.string.signin_fre_footer), + new SpanApplier.SpanInfo("<LINK1>", "</LINK1>", clickableTermsOfServiceSpan), + new SpanApplier.SpanInfo("<LINK2>", "</LINK2>", clickableUMADialogSpan)); + } }
diff --git a/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunProperties.java b/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunProperties.java index 2f006e03..d77b8e0 100644 --- a/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunProperties.java +++ b/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunProperties.java
@@ -4,6 +4,7 @@ package org.chromium.chrome.browser.ui.signin.fre; +import android.text.SpannableString; import android.view.View.OnClickListener; import org.chromium.chrome.browser.signin.services.DisplayableProfileData; @@ -45,6 +46,9 @@ static final WritableBooleanPropertyKey IS_SIGNIN_SUPPORTED = new WritableBooleanPropertyKey("is_signin_supported"); + static final WritableObjectPropertyKey<CharSequence> FOOTER_STRING = + new WritableObjectPropertyKey<>("footer_string"); + static final PropertyKey[] ALL_KEYS = new PropertyKey[] { ON_SELECTED_ACCOUNT_CLICKED, SELECTED_ACCOUNT_DATA, @@ -54,13 +58,15 @@ ARE_NATIVE_AND_POLICY_LOADED, FRE_POLICY, IS_SIGNIN_SUPPORTED, + FOOTER_STRING, }; /** * Creates a default model for FRE bottom group. */ static PropertyModel createModel(Runnable onSelectedAccountClicked, - Runnable onContinueAsClicked, Runnable onDismissClicked, boolean isSigninSupported) { + Runnable onContinueAsClicked, Runnable onDismissClicked, boolean isSigninSupported, + SpannableString footerString) { return new PropertyModel.Builder(ALL_KEYS) .with(ON_SELECTED_ACCOUNT_CLICKED, v -> onSelectedAccountClicked.run()) .with(SELECTED_ACCOUNT_DATA, null) @@ -70,6 +76,7 @@ .with(ARE_NATIVE_AND_POLICY_LOADED, false) .with(FRE_POLICY, null) .with(IS_SIGNIN_SUPPORTED, isSigninSupported) + .with(FOOTER_STRING, footerString) .build(); }
diff --git a/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunViewBinder.java b/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunViewBinder.java index b44cefc8..a13bda8 100644 --- a/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunViewBinder.java +++ b/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fre/SigninFirstRunViewBinder.java
@@ -4,9 +4,11 @@ package org.chromium.chrome.browser.ui.signin.fre; +import android.text.method.LinkMovementMethod; import android.transition.TransitionManager; import android.view.View; import android.view.ViewGroup; +import android.widget.TextView; import androidx.annotation.Nullable; @@ -57,6 +59,10 @@ button.setText(R.string.continue_button); updateVisibility(view, model); } + } else if (propertyKey == SigninFirstRunProperties.FOOTER_STRING) { + final TextView footerView = view.findViewById(R.id.signin_fre_footer); + footerView.setText(model.get(SigninFirstRunProperties.FOOTER_STRING)); + footerView.setMovementMethod(LinkMovementMethod.getInstance()); } else { throw new IllegalArgumentException("Unknown property key:" + propertyKey); }
diff --git a/chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager.cc b/chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager.cc index a1f6633..6e109528 100644 --- a/chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager.cc +++ b/chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager.cc
@@ -7,13 +7,13 @@ #include <utility> #include "ash/components/arc/arc_util.h" +#include "ash/components/arc/usb/usb_host_bridge.h" #include "base/bind.h" #include "base/containers/cxx20_erase.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/app_list/arc/arc_app_dialog.h" #include "chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager_factory.h" -#include "components/arc/usb/usb_host_bridge.h" #include "extensions/browser/api/device_permissions_manager.h" namespace arc {
diff --git a/chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager.h b/chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager.h index 4b83fec..a279589 100644 --- a/chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager.h +++ b/chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager.h
@@ -10,10 +10,10 @@ #include <unordered_set> #include <vector> +#include "ash/components/arc/usb/usb_host_ui_delegate.h" #include "base/callback.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" -#include "components/arc/usb/usb_host_ui_delegate.h" #include "components/keyed_service/core/keyed_service.h" class Profile;
diff --git a/chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager_factory.cc b/chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager_factory.cc index 66f3ef6b..2009f298 100644 --- a/chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager_factory.cc +++ b/chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager_factory.cc
@@ -4,10 +4,10 @@ #include "chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager_factory.h" +#include "ash/components/arc/usb/usb_host_bridge.h" #include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" #include "chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager.h" -#include "components/arc/usb/usb_host_bridge.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "content/public/browser/browser_context.h"
diff --git a/chrome/browser/ui/ash/projector/pending_screencast_manager.cc b/chrome/browser/ui/ash/projector/pending_screencast_manager.cc new file mode 100644 index 0000000..ddc00f8 --- /dev/null +++ b/chrome/browser/ui/ash/projector/pending_screencast_manager.cc
@@ -0,0 +1,209 @@ +// Copyright 2021 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/ui/ash/projector/pending_screencast_manager.h" + +#include "ash/components/drivefs/mojom/drivefs.mojom.h" +#include "ash/public/cpp/projector/projector_controller.h" +#include "ash/webui/projector_app/projector_app_client.h" +#include "base/files/file_enumerator.h" +#include "base/files/file_path.h" +#include "base/files/file_util.h" +#include "base/strings/strcat.h" +#include "base/task/bind_post_task.h" +#include "base/task/task_traits.h" +#include "base/task/thread_pool.h" +#include "chrome/browser/ash/drive/drive_integration_service.h" +#include "chrome/browser/ash/profiles/profile_helper.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_manager.h" +#include "content/public/browser/browser_thread.h" +#include "third_party/abseil-cpp/absl/types/optional.h" + +namespace { + +constexpr base::FilePath::CharType kMediaExtension[] = + FILE_PATH_LITERAL(".webm"); + +const std::string GetMetadataFileExtension() { + return base::StrCat({".", ash::kProjectorMetadataFileExtension}); +} + +bool IsWebmOrProjectorFile(const base::FilePath& path) { + return path.MatchesExtension(kMediaExtension) || + path.MatchesExtension(GetMetadataFileExtension()); +} + +drive::DriveIntegrationService* GetDriveIntegrationServiceForPrimaryProfile() { + return drive::DriveIntegrationServiceFactory::FindForProfile( + ProfileManager::GetPrimaryUserProfile()); +} + +drivefs::DriveFsHost* GetDriveFsHostForPrimaryProfile() { + auto* drivefs_integration = GetDriveIntegrationServiceForPrimaryProfile(); + return drivefs_integration ? drivefs_integration->GetDriveFsHost() : nullptr; +} + +// Verifies whether `relative_path` is a valid screencast container. A valid +// screencast should have at least 1 media file and 1 metadata file. The +// 'relative_path' looks like +// "/{drivefs mounted point}/root/{folder path in drive}" +bool IsScreencastContainer(const base::FilePath& relative_path) { + DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + if (!base::PathExists(relative_path)) + return false; + + int number_of_metadata_files = 0; + int number_of_media_files = 0; + base::FileEnumerator files(relative_path, /* recursive */ false, + base::FileEnumerator::FILES); + const std::string metadata_extension = GetMetadataFileExtension(); + for (base::FilePath path = files.Next(); !path.empty(); path = files.Next()) { + if (path.MatchesExtension(metadata_extension)) + number_of_metadata_files++; + + if (path.MatchesExtension(kMediaExtension)) + number_of_media_files++; + + if (number_of_media_files > 0 && number_of_metadata_files > 0) + return true; + } + + return number_of_media_files > 0 && number_of_metadata_files > 0; +} + +// The `pending_webm_or_projector_files` are new pending ".webm" or ".projector" +// files. Checks whether these files are valid screencast files and returns +// valid pending screencasts. +std::set<ash::PendingScreencast> ProcessAndGenerateNewScreencasts( + const std::vector<base::FilePath>& pending_webm_or_projector_files, + const base::FilePath drivefs_mounted_point) { + DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + + // The valid screencasts set. + std::set<ash::PendingScreencast> screencasts; + if (!base::PathExists(drivefs_mounted_point)) + return screencasts; + + // `pending_file` is a relative path to DriveFs mounted folder. It looks like + // "/root/{folder path in drive}/{file name}". + for (const auto& pending_file : pending_webm_or_projector_files) { + // `container_dir` is the parent folder of `pending_file` in drive. It looks + // like "/root/{folder path in drive}". + const base::FilePath container_dir = pending_file.DirName(); + ash::PendingScreencast screencast; + screencast.container_dir = container_dir; + // The display name of the a pending screencast is the name of the container + // folder name of this screencast. + screencast.name = container_dir.BaseName().value(); + + // During this loop, items of multiple events might be under the same + // folder. Skips folders that have been validated before. + if (screencasts.find(screencast) != screencasts.end()) + continue; + + base::FilePath root("/"); + base::FilePath container_absolute_dir(drivefs_mounted_point); + root.AppendRelativePath(container_dir, &container_absolute_dir); + if (IsScreencastContainer(container_absolute_dir)) + screencasts.emplace(screencast); + } + + return screencasts; +} + +} // namespace + +PendingSreencastManager::PendingSreencastManager( + PendingScreencastChangeCallback pending_screencast_change_callback) + : pending_screencast_change_callback_(pending_screencast_change_callback), + blocking_task_runner_(base::ThreadPool::CreateSequencedTaskRunner( + {base::MayBlock(), base::TaskPriority::BEST_EFFORT, + base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})) { + session_manager::SessionManager* session_manager = + session_manager::SessionManager::Get(); + if (session_manager) + session_manager->AddObserver(this); +} + +PendingSreencastManager::~PendingSreencastManager() { + session_manager::SessionManager* session_manager = + session_manager::SessionManager::Get(); + if (session_manager) { + session_manager->RemoveObserver(this); + auto* drivefs_host = GetDriveFsHostForPrimaryProfile(); + if (drivefs_host) + drivefs_host->RemoveObserver(this); + } +} + +void PendingSreencastManager::OnUnmounted() { + if (pending_screencast_cache_.empty()) { + pending_screencast_cache_.clear(); + // Since DriveFS is unmounted, screencasts stop uploading. Notifies pending + // screencast status has changed. + pending_screencast_change_callback_.Run(pending_screencast_cache_); + } +} + +// TODO(b/200343894): OnSyncingStatusUpdate() gets called for both upload and +// download event. Find a way to filter out the upload event. +void PendingSreencastManager::OnSyncingStatusUpdate( + const drivefs::mojom::SyncingStatus& status) { + std::vector<base::FilePath> pending_webm_or_projector_files; + + for (const auto& event : status.item_events) { + base::FilePath pending_file = base::FilePath(event->path); + bool pending = + event->state == drivefs::mojom::ItemEvent::State::kQueued || + event->state == drivefs::mojom::ItemEvent::State::kInProgress; + // Filters pending ".webm" or ".projector". + if (!pending || !IsWebmOrProjectorFile(pending_file)) { + continue; + } + + pending_webm_or_projector_files.push_back(pending_file); + } + + // The `task` is a blocking I/O operation while `reply` runs on current + // thread. + blocking_task_runner_->PostTaskAndReplyWithResult( + FROM_HERE, + base::BindOnce( + ProcessAndGenerateNewScreencasts, + std::move(pending_webm_or_projector_files), + GetDriveIntegrationServiceForPrimaryProfile()->GetMountPointPath()), + base::BindOnce( + &PendingSreencastManager::OnProcessAndGenerateNewScreencastsFinished, + weak_ptr_factory_.GetWeakPtr())); +} + +// TODO(b/200179137): Handle drive full cannot upload error. Maybe send +// Notification and show failed file on gallery? +void PendingSreencastManager::OnError(const drivefs::mojom::DriveError& error) { +} + +void PendingSreencastManager::OnUserSessionStarted(bool is_primary_user) { + if (!is_primary_user) + return; + auto* drivefs_host = GetDriveFsHostForPrimaryProfile(); + if (drivefs_host) + GetDriveFsHostForPrimaryProfile()->AddObserver(this); +} + +const std::set<ash::PendingScreencast>& +PendingSreencastManager::GetPendingScreencasts() const { + return pending_screencast_cache_; +} + +void PendingSreencastManager::OnProcessAndGenerateNewScreencastsFinished( + const std::set<ash::PendingScreencast>& screencasts) { + // Return if pending screencasts didn't change. + if (screencasts == pending_screencast_cache_) + return; + pending_screencast_cache_ = screencasts; + + // Notifies pending screencast status changed. + pending_screencast_change_callback_.Run(pending_screencast_cache_); +}
diff --git a/chrome/browser/ui/ash/projector/pending_screencast_manager.h b/chrome/browser/ui/ash/projector/pending_screencast_manager.h new file mode 100644 index 0000000..b1a47fbd --- /dev/null +++ b/chrome/browser/ui/ash/projector/pending_screencast_manager.h
@@ -0,0 +1,75 @@ +// Copyright 2021 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_UI_ASH_PROJECTOR_PENDING_SCREENCAST_MANAGER_H_ +#define CHROME_BROWSER_UI_ASH_PROJECTOR_PENDING_SCREENCAST_MANAGER_H_ + +#include <set> + +#include "ash/components/drivefs/drivefs_host.h" +#include "ash/components/drivefs/drivefs_host_observer.h" +#include "base/callback.h" +#include "base/memory/scoped_refptr.h" +#include "base/memory/weak_ptr.h" +#include "base/observer_list.h" +#include "components/session_manager/core/session_manager.h" +#include "components/session_manager/core/session_manager_observer.h" + +namespace drivefs { +namespace mojom { +class SyncingStatus; +class DriveError; +} // namespace mojom +} // namespace drivefs + +namespace ash { +struct PendingScreencast; +} + +// A callback to notify the change of pending screencasts to +// ProjectorAppClient::Observer. The argument is the set of pending screencasts +// owned by PendingSreencastManager. +using PendingScreencastChangeCallback = + base::RepeatingCallback<void(const std::set<ash::PendingScreencast>&)>; + +// A class that handles pending screencast events. +class PendingSreencastManager : public session_manager::SessionManagerObserver, + public drivefs::DriveFsHostObserver { + public: + explicit PendingSreencastManager( + PendingScreencastChangeCallback pending_screencast_change_callback); + PendingSreencastManager(const PendingSreencastManager&) = delete; + PendingSreencastManager& operator=(const PendingSreencastManager&) = delete; + ~PendingSreencastManager() override; + + // drivefs::DriveFsHostObserver: + void OnUnmounted() override; + void OnSyncingStatusUpdate( + const drivefs::mojom::SyncingStatus& status) override; + void OnError(const drivefs::mojom::DriveError& error) override; + + // session_manager::SessionManagerObserver: + void OnUserSessionStarted(bool is_primary_user) override; + + // Returns a list of pending screencast from `pending_screencast_cache_`. + const std::set<ash::PendingScreencast>& GetPendingScreencasts() const; + + private: + // Updates `pending_screencast_cache_` and notifies pending screencast change. + void OnProcessAndGenerateNewScreencastsFinished( + const std::set<ash::PendingScreencast>& screencasts); + + // A set that caches current pending screencast. + std::set<ash::PendingScreencast> pending_screencast_cache_; + + // A callback to notify pending screencast status change. + PendingScreencastChangeCallback pending_screencast_change_callback_; + + // A blocking task runner for file IO operations. + scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; + + base::WeakPtrFactory<PendingSreencastManager> weak_ptr_factory_{this}; +}; + +#endif // CHROME_BROWSER_UI_ASH_PROJECTOR_PENDING_SCREENCAST_MANAGER_H_
diff --git a/chrome/browser/ui/ash/projector/pending_screencast_manager_browsertest.cc b/chrome/browser/ui/ash/projector/pending_screencast_manager_browsertest.cc new file mode 100644 index 0000000..456081b --- /dev/null +++ b/chrome/browser/ui/ash/projector/pending_screencast_manager_browsertest.cc
@@ -0,0 +1,291 @@ +// Copyright 2021 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/ui/ash/projector/pending_screencast_manager.h" + +#include "ash/components/drivefs/mojom/drivefs.mojom.h" +#include "ash/webui/projector_app/projector_app_client.h" +#include "base/files/file.h" +#include "base/files/file_path.h" +#include "base/files/file_util.h" +#include "base/strings/strcat.h" +#include "base/strings/string_number_conversions.h" +#include "base/test/bind.h" +#include "base/threading/thread_restrictions.h" +#include "chrome/browser/ash/drive/drive_integration_service.h" +#include "chrome/browser/ash/drive/drivefs_test_support.h" +#include "chrome/browser/ash/file_manager/fileapi_util.h" +#include "chrome/browser/ash/profiles/profile_helper.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/ui/ash/projector/projector_app_client_impl.h" +#include "chrome/test/base/in_process_browser_test.h" +#include "content/public/test/browser_test.h" +#include "content/public/test/test_utils.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace ash { + +namespace { + +constexpr char kTestScreencastPath[] = "/root/test_screencast"; +constexpr char kTestScreencastName[] = "test_screencast"; +constexpr char kTestMediaFile[] = "test_screencast.webm"; +constexpr char kTestMetadataFile[] = "test_screencast.projector"; + +} // namespace + +class PendingScreencastMangerBrowserTest : public InProcessBrowserTest { + public: + bool SetUpUserDataDirectory() override { + return drive::SetUpUserDataDirectoryForDriveFsTest(); + } + + void SetUpInProcessBrowserTestFixture() override { + create_drive_integration_service_ = base::BindRepeating( + &PendingScreencastMangerBrowserTest::CreateDriveIntegrationService, + base::Unretained(this)); + service_factory_for_test_ = std::make_unique< + drive::DriveIntegrationServiceFactory::ScopedFactoryForTest>( + &create_drive_integration_service_); + } + + void SetUpOnMainThread() override { + InProcessBrowserTest::SetUpOnMainThread(); + pending_screencast_manager_ = std::make_unique< + PendingSreencastManager>(base::BindRepeating( + &PendingScreencastMangerBrowserTest::PendingScreencastChangeCallback, + base::Unretained(this))); + } + + protected: + virtual drive::DriveIntegrationService* CreateDriveIntegrationService( + Profile* profile) { + if (!ProfileHelper::IsPrimaryProfile(profile)) + return nullptr; + + base::ScopedAllowBlockingForTesting allow_blocking; + base::FilePath mount_path = profile->GetPath().Append("drivefs"); + + fake_drivefs_helper_ = + std::make_unique<drive::FakeDriveFsHelper>(profile, mount_path); + auto* integration_service = new drive::DriveIntegrationService( + profile, std::string(), mount_path, + fake_drivefs_helper_->CreateFakeDriveFsListenerFactory()); + return integration_service; + } + + void CreateFile(const std::string& file_path) { + base::ScopedAllowBlockingForTesting allow_blocking; + + drive::DriveIntegrationService* service = + drive::DriveIntegrationServiceFactory::FindForProfile( + ProfileManager::GetPrimaryUserProfile()); + EXPECT_TRUE(service->IsMounted()); + EXPECT_TRUE(base::PathExists(service->GetMountPointPath())); + + base::FilePath root("/"); + base::FilePath path(file_path); + base::FilePath folder_path(service->GetMountPointPath()); + root.AppendRelativePath(path.DirName(), &folder_path); + + // base::CreateDirectory returns 'true' on successful creation, or if the + // directory already exists. + EXPECT_TRUE(base::CreateDirectory(folder_path)); + + base::File file(folder_path.Append(path.BaseName()), + base::File::FLAG_CREATE | base::File::FLAG_READ); + + EXPECT_TRUE(file.IsValid()); + file.Close(); + } + + void AddTransferItemEvent(drivefs::mojom::SyncingStatus& syncing_status, + bool completed, + const std::string& path) { + syncing_status.item_events.emplace_back( + base::in_place, /*stable_id*/ 1, /*group_id*/ 1, path, + completed ? drivefs::mojom::ItemEvent::State::kCompleted + : drivefs::mojom::ItemEvent::State::kInProgress, + /*bytes_transferred*/ completed ? 100 : 50, /*bytes_to_transfer*/ 100, + drivefs::mojom::ItemEventReason::kTransfer); + } + + MOCK_METHOD1(PendingScreencastChangeCallback, + void(const std::set<ash::PendingScreencast>&)); + + PendingSreencastManager* pending_screencast_manager() { + return pending_screencast_manager_.get(); + } + + private: + drive::DriveIntegrationServiceFactory::FactoryCallback + create_drive_integration_service_; + std::unique_ptr<drive::DriveIntegrationServiceFactory::ScopedFactoryForTest> + service_factory_for_test_; + + std::unique_ptr<drive::FakeDriveFsHelper> fake_drivefs_helper_; + std::unique_ptr<PendingSreencastManager> pending_screencast_manager_; +}; + +IN_PROC_BROWSER_TEST_F(PendingScreencastMangerBrowserTest, ValidScreencast) { + const std::string media_file = + base::StrCat({kTestScreencastPath, "/", kTestMediaFile}); + const std::string metadata_file = + base::StrCat({kTestScreencastPath, "/", kTestMetadataFile}); + { + // Create a valid pending screencast. + CreateFile(media_file); + CreateFile(metadata_file); + } + drivefs::mojom::SyncingStatus syncing_status; + AddTransferItemEvent(syncing_status, /*completed*/ false, + /*path*/ media_file); + + EXPECT_CALL(*this, PendingScreencastChangeCallback(testing::_)).Times(1); + pending_screencast_manager()->OnSyncingStatusUpdate(syncing_status); + content::RunAllTasksUntilIdle(); + + const std::set<ash::PendingScreencast> pending_screencasts = + pending_screencast_manager()->GetPendingScreencasts(); + EXPECT_EQ(pending_screencasts.size(), 1); + ash::PendingScreencast ps = *(pending_screencasts.begin()); + EXPECT_EQ(ps.container_dir, base::FilePath(kTestScreencastPath)); + EXPECT_EQ(ps.name, kTestScreencastName); + + // Tests PendingScreencastChangeCallback won't be invoked if pending + // screencast status doesn't change. + EXPECT_CALL(*this, PendingScreencastChangeCallback(testing::_)).Times(0); + pending_screencast_manager()->OnSyncingStatusUpdate(syncing_status); + content::RunAllTasksUntilIdle(); + + // Tests PendingScreencastChangeCallback will be invoked if pending + // screencast status changes. + EXPECT_CALL(*this, PendingScreencastChangeCallback(testing::_)).Times(1); + syncing_status.item_events.clear(); + pending_screencast_manager()->OnSyncingStatusUpdate(syncing_status); +} + +IN_PROC_BROWSER_TEST_F(PendingScreencastMangerBrowserTest, InvalidScreencasts) { + const std::string media_only_path = "/root/media_only/example.webm"; + const std::string metadata_only_path = + "/root/metadata_only/example.projector"; + const std::string avi = "/root/non_screencast_files/example.avi"; + const std::string mov = "/root/non_screencast_files/example.mov"; + const std::string mp4 = "/root/non_screencast_files/example.mp4"; + + { + // Create an invalid screencast that only has webm medida file. + CreateFile(media_only_path); + + // Create an invalid screencast that only has metadata file. + CreateFile(metadata_only_path); + + // Create an invalid screencast that does not have webm media and metadata + // files but have other media files. + CreateFile(avi); + CreateFile(mov); + CreateFile(mp4); + } + + drivefs::mojom::SyncingStatus syncing_status; + AddTransferItemEvent(syncing_status, /*completed*/ false, + /*path*/ media_only_path); + AddTransferItemEvent(syncing_status, /*completed*/ false, + /*path*/ metadata_only_path); + AddTransferItemEvent(syncing_status, /*completed*/ false, /*path*/ avi); + AddTransferItemEvent(syncing_status, /*completed*/ false, /*path*/ mov); + AddTransferItemEvent(syncing_status, /*completed*/ false, /*path*/ mp4); + + EXPECT_CALL(*this, PendingScreencastChangeCallback(testing::_)).Times(0); + pending_screencast_manager()->OnSyncingStatusUpdate(syncing_status); + + content::RunAllTasksUntilIdle(); + + EXPECT_TRUE(pending_screencast_manager()->GetPendingScreencasts().empty()); +} + +IN_PROC_BROWSER_TEST_F(PendingScreencastMangerBrowserTest, + IgnoreCompletedEvent) { + const std::string media_file = + base::StrCat({kTestScreencastPath, "/", kTestMediaFile}); + const std::string metadata_file = + base::StrCat({kTestScreencastPath, "/", kTestMetadataFile}); + { + // Create a valid uploaded screencast. + CreateFile(media_file); + CreateFile(metadata_file); + } + + drivefs::mojom::SyncingStatus syncing_status; + AddTransferItemEvent(syncing_status, /*completed*/ true, /*path*/ media_file); + + EXPECT_CALL(*this, PendingScreencastChangeCallback(testing::_)).Times(0); + pending_screencast_manager()->OnSyncingStatusUpdate(syncing_status); + + content::RunAllTasksUntilIdle(); + + EXPECT_TRUE(pending_screencast_manager()->GetPendingScreencasts().empty()); +} + +IN_PROC_BROWSER_TEST_F(PendingScreencastMangerBrowserTest, + MultipleValidAndInvalidScreencasts) { + drivefs::mojom::SyncingStatus syncing_status; + int num_of_screencasts = 10; + { + // Create multiple valid pending screencasts. + for (int i = 0; i < num_of_screencasts; ++i) { + const std::string test_screencast_path = + base::StrCat({kTestScreencastPath, base::NumberToString(i)}); + const std::string media = + base::StrCat({test_screencast_path, "/", kTestMediaFile}); + const std::string metadata = + base::StrCat({test_screencast_path, "/", kTestMetadataFile}); + CreateFile(media); + CreateFile(metadata); + + AddTransferItemEvent(syncing_status, /*completed*/ false, /*path*/ media); + AddTransferItemEvent(syncing_status, /*completed*/ false, + /*path*/ metadata); + } + + // Tests with a invalid screencast does not have metadata file. + const std::string no_metadata_screencast = "/root/no_metadata/example.webm"; + CreateFile(no_metadata_screencast); + AddTransferItemEvent(syncing_status, /*completed*/ false, + /*path*/ no_metadata_screencast); + + // Tests with a invalid screencast does not have media file. + const std::string no_media_screencast = "/root/no_media/example.projector"; + CreateFile(no_media_screencast); + AddTransferItemEvent(syncing_status, /*completed*/ false, + /*path*/ no_media_screencast); + + // Tests with a non-screencast file. + const std::string non_screencast = "/root/non_screencast/example.txt"; + CreateFile(non_screencast); + AddTransferItemEvent(syncing_status, /*completed*/ false, + /*path*/ non_screencast); + } + + EXPECT_CALL(*this, PendingScreencastChangeCallback(testing::_)).Times(1); + pending_screencast_manager()->OnSyncingStatusUpdate(syncing_status); + + content::RunAllTasksUntilIdle(); + const std::set<ash::PendingScreencast> pending_screencasts = + pending_screencast_manager()->GetPendingScreencasts(); + + // Only valid screencasts could be processed. + EXPECT_EQ(pending_screencasts.size(), num_of_screencasts); + for (int i = 0; i < num_of_screencasts; ++i) { + const std::string container_dir = + base::StrCat({kTestScreencastPath, base::NumberToString(i)}); + const std::string name = + base::StrCat({kTestScreencastName, base::NumberToString(i)}); + ash::PendingScreencast ps{base::FilePath(container_dir), name}; + EXPECT_TRUE(pending_screencasts.find(ps) != pending_screencasts.end()); + } +} + +} // namespace ash
diff --git a/chrome/browser/ui/ash/projector/projector_app_client_impl.cc b/chrome/browser/ui/ash/projector/projector_app_client_impl.cc index 7126836..b686a83 100644 --- a/chrome/browser/ui/ash/projector/projector_app_client_impl.cc +++ b/chrome/browser/ui/ash/projector/projector_app_client_impl.cc
@@ -46,7 +46,10 @@ user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); } -ProjectorAppClientImpl::ProjectorAppClientImpl() { +ProjectorAppClientImpl::ProjectorAppClientImpl() + : pending_screencast_manager_(base::BindRepeating( + &ProjectorAppClientImpl::NotifyScreencastsPendingStatusChanged, + base::Unretained(this))) { if (!base::FeatureList::IsEnabled( ash::features::kOnDeviceSpeechRecognition)) { return; @@ -88,11 +91,9 @@ observer.OnNewScreencastPreconditionChanged(can_start); } -// TODO(b/201468756): Implement a PendingScreencastManager to provide the set -// of PendingScreencast. const std::set<ash::PendingScreencast>& ProjectorAppClientImpl::GetPendingScreencasts() const { - return pending_screencasts_; + return pending_screencast_manager_.GetPendingScreencasts(); } void ProjectorAppClientImpl::NotifyScreencastsPendingStatusChanged(
diff --git a/chrome/browser/ui/ash/projector/projector_app_client_impl.h b/chrome/browser/ui/ash/projector/projector_app_client_impl.h index 53b0ef9f..794db21 100644 --- a/chrome/browser/ui/ash/projector/projector_app_client_impl.h +++ b/chrome/browser/ui/ash/projector/projector_app_client_impl.h
@@ -11,6 +11,7 @@ #include "ash/webui/projector_app/projector_app_client.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" +#include "chrome/browser/ui/ash/projector/pending_screencast_manager.h" #include "chrome/browser/ui/ash/projector/projector_soda_installation_controller.h" namespace network { @@ -54,11 +55,9 @@ base::ObserverList<Observer> observers_; - // TODO(b/201468756): Create a PendingScreencastManager to own this set. - std::set<ash::PendingScreencast> pending_screencasts_; - std::unique_ptr<ProjectorSodaInstallationController> soda_installation_controller_; + PendingSreencastManager pending_screencast_manager_; }; #endif // CHROME_BROWSER_UI_ASH_PROJECTOR_PROJECTOR_APP_CLIENT_IMPL_H_
diff --git a/chrome/browser/ui/views/web_apps/file_handler_launch_dialog_view.cc b/chrome/browser/ui/views/web_apps/file_handler_launch_dialog_view.cc index 0818b14..0b5ce990 100644 --- a/chrome/browser/ui/views/web_apps/file_handler_launch_dialog_view.cc +++ b/chrome/browser/ui/views/web_apps/file_handler_launch_dialog_view.cc
@@ -57,12 +57,11 @@ // Description of permission that's being requested. auto description_view = std::make_unique<views::View>(); - auto* box_layout = - description_view->SetLayoutManager(std::make_unique<views::BoxLayout>( - views::BoxLayout::Orientation::kVertical, - /*inside_border_insets=*/gfx::Insets(), - layout_provider->GetDistanceMetric( - views::DISTANCE_UNRELATED_CONTROL_VERTICAL))); + description_view->SetLayoutManager(std::make_unique<views::BoxLayout>( + views::BoxLayout::Orientation::kVertical, + /*inside_border_insets=*/gfx::Insets(), + layout_provider->GetDistanceMetric( + views::DISTANCE_UNRELATED_CONTROL_VERTICAL))); // Question label. auto* question_label = description_view->AddChildView( @@ -102,8 +101,7 @@ // Additionally, elide very long file names (the max width is the width // available for the label). - const int available_width = fixed_width() - - box_layout->inside_border_insets().width() - + const int available_width = fixed_width() - margins().width() - icon->GetPreferredSize().width() - icon_margin; std::transform(file_paths_.begin(), file_paths_.begin() + displayed_file_name_count,
diff --git a/chrome/browser/ui/web_applications/web_app_metrics.cc b/chrome/browser/ui/web_applications/web_app_metrics.cc index 2a596a9fc..9d83b4f 100644 --- a/chrome/browser/ui/web_applications/web_app_metrics.cc +++ b/chrome/browser/ui/web_applications/web_app_metrics.cc
@@ -174,7 +174,20 @@ const TabStripSelectionChange& selection) { // Process deselection, removal, then selection in-order so we have a // consistent view of selected and last-interacted tabs. - UpdateUkmData(selection.old_contents, TabSwitching::kFrom); + TabSwitching initial_mode = TabSwitching::kFrom; + // Foreground usage duration should be counted when the web app is being + // closed, despite IsInAppWindow returning false at this point. + if (change.type() == TabStripModelChange::kRemoved && + tab_strip_model->empty()) { + auto iter = base::ranges::find_if( + *BrowserList::GetInstance(), [&tab_strip_model](Browser* item) { + return item->tab_strip_model() == tab_strip_model; + }); + if (iter != BrowserList::GetInstance()->end() && + (*iter)->type() == Browser::TYPE_APP) + initial_mode = TabSwitching::kForegroundClosing; + } + UpdateUkmData(selection.old_contents, initial_mode); foreground_web_contents_ = selection.new_contents; // Newly-selected foreground contents should not be going away. @@ -332,13 +345,15 @@ /*ignore_existing_installations=*/true); // Record usage duration and session counts only for installed web apps that // are currently open in a window. - if (provider->ui_manager().IsInAppWindow(web_contents)) { + if (provider->ui_manager().IsInAppWindow(web_contents) || + mode == TabSwitching::kForegroundClosing) { base::Time now = base::Time::Now(); if (app_last_interacted_time_.contains(app_id)) { base::TimeDelta delta = now - app_last_interacted_time_[app_id]; if (delta < max_valid_session_delta_) { switch (mode) { case TabSwitching::kFrom: + case TabSwitching::kForegroundClosing: features.foreground_duration = delta; break; case TabSwitching::kTo:
diff --git a/chrome/browser/ui/web_applications/web_app_metrics.h b/chrome/browser/ui/web_applications/web_app_metrics.h index c20db8ff..a509201 100644 --- a/chrome/browser/ui/web_applications/web_app_metrics.h +++ b/chrome/browser/ui/web_applications/web_app_metrics.h
@@ -78,7 +78,12 @@ private: void CountUserInstalledApps(); - enum class TabSwitching { kFrom, kTo, kBackgroundClosing }; + enum class TabSwitching { + kFrom, + kTo, + kBackgroundClosing, + kForegroundClosing + }; void UpdateUkmData(content::WebContents* web_contents, TabSwitching mode); // Calculate number of user installed apps once on start to avoid cpu costs
diff --git a/chrome/browser/ui/web_applications/web_app_metrics_browsertest.cc b/chrome/browser/ui/web_applications/web_app_metrics_browsertest.cc index 981fac8..07862d5e 100644 --- a/chrome/browser/ui/web_applications/web_app_metrics_browsertest.cc +++ b/chrome/browser/ui/web_applications/web_app_metrics_browsertest.cc
@@ -276,6 +276,48 @@ EXPECT_THAT(metrics, Contains(Pair(UkmEntry::kNumSessionsNameHash, 2))); } +IN_PROC_BROWSER_TEST_F(WebAppMetricsBrowserTest, + InstalledWebApp_RecordsTimeAndSessionWhenClosed) { + ukm::TestAutoSetUkmRecorder ukm_recorder; + AppId app_id = InstallWebApp(); + Browser* app_browser; + + // Open the app. + { + base::subtle::ScopedTimeClockOverrides override( + []() { + return base::subtle::TimeNowIgnoringOverride().LocalMidnight() + + base::Hours(1); + }, + nullptr, nullptr); + app_browser = web_app::LaunchWebAppBrowserAndWait(profile(), app_id); + DCHECK(app_browser); + // Manually activate the web app window (observer is disabled for testing). + WebAppMetrics::Get(profile())->OnBrowserSetLastActive(app_browser); + } + + // Close the app. + { + base::subtle::ScopedTimeClockOverrides override( + []() { + return base::subtle::TimeNowIgnoringOverride().LocalMidnight() + + base::Hours(3); + }, + nullptr, nullptr); + CloseBrowserSynchronously(app_browser); + } + + ForceEmitMetricsNow(); + + auto entries = ukm_recorder.GetEntriesByName(UkmEntry::kEntryName); + ASSERT_EQ(entries.size(), 1U); + auto metrics = entries[0]->metrics; + // 2 hours = 7200 seconds. Nearest 1/50 day bucket is 6912. + EXPECT_THAT(metrics, + Contains(Pair(UkmEntry::kForegroundDurationNameHash, 6912))); + EXPECT_THAT(metrics, Contains(Pair(UkmEntry::kNumSessionsNameHash, 1))); +} + // Verify that the behavior with multiple web app instances is as expected, even // though that behavior isn't completely accurate in recording time // (crbug.com/1081187).
diff --git a/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.h b/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.h index 527fa2d..e00e4943 100644 --- a/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.h +++ b/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.h
@@ -10,11 +10,11 @@ #include <utility> #include <vector> +#include "ash/components/arc/power/arc_power_bridge.h" #include "base/memory/weak_ptr.h" #include "base/timer/timer.h" #include "chrome/browser/ash/throttle_service.h" #include "components/arc/mojom/power.mojom.h" -#include "components/arc/power/arc_power_bridge.h" #include "content/public/browser/web_ui_message_handler.h" #include "ui/aura/window_observer.h" #include "ui/events/event_handler.h"
diff --git a/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc b/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc index 1ed34687..beefa2c3 100644 --- a/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc +++ b/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc
@@ -655,6 +655,8 @@ FireWebUIListener("touchpad-exists-changed", base::Value(exists)); } +void DeviceEmulatorMessageHandler::HapticTouchpadExists(bool exists) {} + void DeviceEmulatorMessageHandler::MouseExists(bool exists) { if (!IsJavascriptAllowed()) return;
diff --git a/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h b/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h index e704e097..029a5f8 100644 --- a/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h +++ b/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h
@@ -127,6 +127,7 @@ // system::PointerDeviceObserver::Observer: void TouchpadExists(bool exists) override; + void HapticTouchpadExists(bool exists) override; void MouseExists(bool exists) override; void PointingStickExists(bool exists) override;
diff --git a/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.cc index 1b8d5bf9..6487b3a9 100644 --- a/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.cc
@@ -30,6 +30,10 @@ IDS_LACROS_DATA_MIGRATION_SCREEN_TITLE); builder->Add("lacrosDataMigrationSubtitle", IDS_LACROS_DATA_MIGRATION_SCREEN_SUBTITLE); + builder->Add("lacrosDataMigrationSkipButton", + IDS_LACROS_DATA_MIGRATION_SCREEN_SKIP_BUTTON); + builder->Add("lacrosDataMigrationSkipSuggestion", + IDS_LACROS_DATA_MIGRATION_SCREEN_SKIP_SUGGESTION); } void LacrosDataMigrationScreenHandler::Bind(LacrosDataMigrationScreen* screen) { @@ -54,6 +58,10 @@ CallJS("login.LacrosDataMigrationScreen.setProgressValue", progress); } +void LacrosDataMigrationScreenHandler::ShowSkipButton() { + CallJS("login.LacrosDataMigrationScreen.showSkipButton"); +} + void LacrosDataMigrationScreenHandler::Initialize() { if (show_on_init_) { Show();
diff --git a/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.h index 3f356154..e2f03e3e 100644 --- a/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.h +++ b/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.h
@@ -32,6 +32,9 @@ // Updates the progress bar. virtual void SetProgressValue(int progress) = 0; + + // Displays the skip button. + virtual void ShowSkipButton() = 0; }; class LacrosDataMigrationScreenHandler : public BaseScreenHandler, @@ -56,6 +59,7 @@ void Unbind() override; void Show() override; void SetProgressValue(int progress) override; + void ShowSkipButton() override; private: // BaseScreenHandler:
diff --git a/chrome/browser/ui/webui/connectors_internals/connectors_internals_ui.cc b/chrome/browser/ui/webui/connectors_internals/connectors_internals_ui.cc index 2486c5d2..64210a45 100644 --- a/chrome/browser/ui/webui/connectors_internals/connectors_internals_ui.cc +++ b/chrome/browser/ui/webui/connectors_internals/connectors_internals_ui.cc
@@ -5,7 +5,6 @@ #include "chrome/browser/ui/webui/connectors_internals/connectors_internals_ui.h" #include "base/bind.h" -#include "base/feature_list.h" #include "build/build_config.h" #include "chrome/browser/enterprise/connectors/device_trust/device_trust_features.h" #include "chrome/browser/profiles/profile.h" @@ -29,9 +28,8 @@ Profile* profile = Profile::FromWebUI(web_ui); source->AddBoolean("isOtr", profile->IsOffTheRecord()); - source->AddBoolean( - "zeroTrustConnectorEnabled", - base::FeatureList::IsEnabled(kDeviceTrustConnectorEnabled)); + source->AddBoolean("zeroTrustConnectorEnabled", + IsDeviceTrustConnectorFeatureEnabled()); webui::SetupWebUIDataSource( source,
diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc index 24e843f5..9207e3466 100644 --- a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc +++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc
@@ -6,6 +6,10 @@ #include "base/memory/ref_counted_memory.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/mock_callback.h" +#include "chrome/browser/new_tab_page/promos/promo_data.h" +#include "chrome/browser/new_tab_page/promos/promo_service.h" +#include "chrome/browser/new_tab_page/promos/promo_service_factory.h" +#include "chrome/browser/new_tab_page/promos/promo_service_observer.h" #include "chrome/browser/search/background/ntp_background_data.h" #include "chrome/browser/search/background/ntp_custom_background_service.h" #include "chrome/browser/search/background/ntp_custom_background_service_observer.h" @@ -17,6 +21,8 @@ #include "chrome/common/webui_url_constants.h" #include "chrome/grit/theme_resources.h" #include "chrome/test/base/testing_profile.h" +#include "components/keyed_service/content/browser_context_keyed_service_factory.h" +#include "components/keyed_service/core/keyed_service.h" #include "components/search_provider_logos/logo_common.h" #include "components/search_provider_logos/logo_service.h" #include "content/public/test/browser_task_environment.h" @@ -24,6 +30,7 @@ #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/receiver.h" +#include "services/network/public/cpp/shared_url_loader_factory.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -92,13 +99,38 @@ ThemeHelper theme_helper_; }; +class MockPromoService : public PromoService { + public: + MockPromoService() : PromoService(nullptr, nullptr) {} + MOCK_METHOD(const absl::optional<PromoData>&, + promo_data, + (), + (const, override)); + MOCK_METHOD(void, AddObserver, (PromoServiceObserver*), (override)); + MOCK_METHOD(void, Refresh, (), (override)); +}; + +std::unique_ptr<TestingProfile> MakeTestingProfile() { + TestingProfile::Builder profile_builder; + profile_builder.AddTestingFactory( + PromoServiceFactory::GetInstance(), + base::BindRepeating([](content::BrowserContext* context) + -> std::unique_ptr<KeyedService> { + return std::make_unique<testing::NiceMock<MockPromoService>>(); + })); + return profile_builder.Build(); +} + } // namespace class NewTabPageHandlerTest : public testing::Test { public: NewTabPageHandlerTest() - : mock_ntp_custom_background_service_(&profile_), - web_contents_(factory_.CreateWebContents(&profile_)) {} + : profile_(MakeTestingProfile()), + mock_ntp_custom_background_service_(profile_.get()), + mock_promo_service_(*static_cast<MockPromoService*>( + PromoServiceFactory::GetForProfile(profile_.get()))), + web_contents_(factory_.CreateWebContents(profile_.get())) {} ~NewTabPageHandlerTest() override = default; @@ -110,12 +142,15 @@ .Times(1) .WillOnce( testing::SaveArg<0>(&ntp_custom_background_service_observer_)); + EXPECT_CALL(mock_promo_service_, AddObserver) + .Times(1) + .WillOnce(testing::SaveArg<0>(&promo_service_observer_)); EXPECT_CALL(mock_page_, SetTheme).Times(1); EXPECT_CALL(mock_ntp_custom_background_service_, RefreshBackgroundIfNeeded) .Times(1); handler_ = std::make_unique<NewTabPageHandler>( mojo::PendingReceiver<new_tab_page::mojom::PageHandler>(), - mock_page_.BindAndGetRemote(), &profile_, + mock_page_.BindAndGetRemote(), profile_.get(), &mock_ntp_custom_background_service_, &mock_theme_service_, &mock_logo_service_, &mock_theme_provider_, web_contents_, base::Time::Now()); @@ -160,18 +195,20 @@ testing::NiceMock<MockPage> mock_page_; // NOTE: The initialization order of these members matters. content::BrowserTaskEnvironment task_environment_; - TestingProfile profile_; + std::unique_ptr<TestingProfile> profile_; testing::NiceMock<MockNtpCustomBackgroundService> mock_ntp_custom_background_service_; testing::NiceMock<MockThemeService> mock_theme_service_; MockLogoService mock_logo_service_; testing::NiceMock<MockThemeProvider> mock_theme_provider_; + MockPromoService& mock_promo_service_; content::TestWebContentsFactory factory_; content::WebContents* web_contents_; // Weak. Owned by factory_. base::HistogramTester histogram_tester_; std::unique_ptr<NewTabPageHandler> handler_; ThemeServiceObserver* theme_service_observer_; NtpCustomBackgroundServiceObserver* ntp_custom_background_service_observer_; + PromoServiceObserver* promo_service_observer_; }; TEST_F(NewTabPageHandlerTest, SetTheme) { @@ -447,3 +484,60 @@ EXPECT_EQ(2u, doodle->interactive->height); EXPECT_EQ("alt text", doodle->description); } + +TEST_F(NewTabPageHandlerTest, GetPromo) { + PromoData promo_data; + promo_data.promo_html = "<html/>"; + promo_data.middle_slot_json = R"({ + "part": [{ + "image": { + "image_url": "https://image.com/image", + "target": "https://image.com/target" + } + }, { + "link": { + "url": "https://link.com", + "text": "bar", + "color": "red" + } + }, { + "text": { + "text": "blub", + "color": "green" + } + }] + })"; + promo_data.promo_log_url = GURL("https://foo.com"); + promo_data.promo_id = "foo"; + auto promo_data_optional = absl::make_optional(promo_data); + ON_CALL(mock_promo_service_, promo_data()) + .WillByDefault(testing::ReturnRef(promo_data_optional)); + EXPECT_CALL(mock_promo_service_, Refresh).Times(1); + + new_tab_page::mojom::PromoPtr promo; + base::MockCallback<NewTabPageHandler::GetPromoCallback> callback; + EXPECT_CALL(callback, Run(testing::_)) + .Times(1) + .WillOnce(testing::Invoke([&promo](new_tab_page::mojom::PromoPtr arg) { + promo = std::move(arg); + })); + handler_->GetPromo(callback.Get()); + + ASSERT_TRUE(promo); + EXPECT_EQ("foo", promo->id); + EXPECT_EQ("https://foo.com/", promo->log_url); + ASSERT_EQ(3lu, promo->middle_slot_parts.size()); + ASSERT_TRUE(promo->middle_slot_parts[0]->is_image()); + const auto& image = promo->middle_slot_parts[0]->get_image(); + EXPECT_EQ("https://image.com/image", image->image_url); + EXPECT_EQ("https://image.com/target", image->target); + ASSERT_TRUE(promo->middle_slot_parts[1]->is_link()); + const auto& link = promo->middle_slot_parts[1]->get_link(); + EXPECT_EQ("red", link->color); + EXPECT_EQ("bar", link->text); + EXPECT_EQ("https://link.com/", link->url); + ASSERT_TRUE(promo->middle_slot_parts[2]->is_text()); + const auto& text = promo->middle_slot_parts[2]->get_text(); + EXPECT_EQ("green", text->color); + EXPECT_EQ("blub", text->text); +}
diff --git a/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.cc b/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.cc index 42a785b..95954612 100644 --- a/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.cc +++ b/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.cc
@@ -6,6 +6,7 @@ #include <numeric> +#include "ash/components/arc/storage_manager/arc_storage_manager.h" #include "base/callback_helpers.h" #include "base/memory/scoped_refptr.h" #include "base/system/sys_info.h" @@ -22,7 +23,6 @@ #include "chromeos/dbus/userdataauth/userdataauth_client.h" #include "components/arc/session/arc_bridge_service.h" #include "components/arc/session/arc_service_manager.h" -#include "components/arc/storage_manager/arc_storage_manager.h" #include "components/browsing_data/content/cache_storage_helper.h" #include "components/browsing_data/content/conditional_cache_counting_helper.h" #include "components/browsing_data/content/cookie_helper.h"
diff --git a/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.h b/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.h index c3452b6..1dec48e1 100644 --- a/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.h +++ b/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.h
@@ -10,6 +10,7 @@ #include <memory> #include <vector> +#include "ash/components/arc/storage_manager/arc_storage_manager.h" #include "base/files/file_util.h" #include "base/memory/weak_ptr.h" #include "base/observer_list_types.h" @@ -19,7 +20,6 @@ #include "chromeos/dbus/cryptohome/rpc.pb.h" #include "components/arc/mojom/storage_manager.mojom.h" #include "components/arc/session/connection_observer.h" -#include "components/arc/storage_manager/arc_storage_manager.h" #include "components/user_manager/user.h" class Profile;
diff --git a/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc b/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc index cbc2f39..a333ebf 100644 --- a/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc +++ b/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
@@ -164,6 +164,10 @@ base::BindRepeating(&CrostiniHandler::HandleRequestContainerInfo, handler_weak_ptr_factory_.GetWeakPtr())); web_ui()->RegisterMessageCallback( + "setContainerBadgeColor", + base::BindRepeating(&CrostiniHandler::HandleSetContainerBadgeColor, + handler_weak_ptr_factory_.GetWeakPtr())); + web_ui()->RegisterMessageCallback( "stopContainer", base::BindRepeating(&CrostiniHandler::HandleStopContainer, handler_weak_ptr_factory_.GetWeakPtr())); @@ -771,11 +775,30 @@ if (info) { container_info_value.SetStringKey(kIpv4Key, info->ipv4_address); } + + SkColor badge_color = + crostini::GetContainerBadgeColor(profile_, container_id); + std::string badge_color_str = + base::StringPrintf("#%02x%02x%02x", SkColorGetR(badge_color), + SkColorGetG(badge_color), SkColorGetB(badge_color)); + container_info_value.SetStringKey("badge_color", badge_color_str); + container_info_list.Append(std::move(container_info_value)); } + FireWebUIListener("crostini-container-info", container_info_list); } +void CrostiniHandler::HandleSetContainerBadgeColor( + base::Value::ConstListView args) { + CHECK_EQ(2U, args.size()); + + crostini::ContainerId container_id(args[0]); + SkColor badge_color(args[1].FindDoubleKey("value").value()); + + crostini::SetContainerBadgeColor(profile_, container_id, badge_color); +} + void CrostiniHandler::HandleStopContainer(base::Value::ConstListView args) { CHECK_EQ(1U, args.size());
diff --git a/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h b/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h index aa9f9e4..09034d4 100644 --- a/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h +++ b/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h
@@ -138,6 +138,8 @@ void HandleDeleteContainer(base::Value::ConstListView args); // Handle a request for the running info of all known containers void HandleRequestContainerInfo(base::Value::ConstListView args); + // Handle a request to set the badge color for a container + void HandleSetContainerBadgeColor(base::Value::ConstListView args); // Handle a request to stop a running lxd container void HandleStopContainer(base::Value::ConstListView args);
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.cc b/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.cc index 70f3f84..f36dcf2 100644 --- a/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.cc +++ b/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.cc
@@ -40,6 +40,10 @@ FireWebUIListener("has-touchpad-changed", base::Value(exists)); } +void PointerHandler::HapticTouchpadExists(bool exists) { + FireWebUIListener("has-haptic-touchpad-changed", base::Value(exists)); +} + void PointerHandler::MouseExists(bool exists) { FireWebUIListener("has-mouse-changed", base::Value(exists)); }
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h b/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h index df516f5d0..2bc0da3 100644 --- a/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h +++ b/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h
@@ -37,6 +37,7 @@ private: // PointerDeviceObserver implementation. void TouchpadExists(bool exists) override; + void HapticTouchpadExists(bool exists) override; void MouseExists(bool exists) override; void PointingStickExists(bool exists) override;
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_section.cc b/chrome/browser/ui/webui/settings/chromeos/device_section.cc index b55ac0f41..afd97ab 100644 --- a/chrome/browser/ui/webui/settings/chromeos/device_section.cc +++ b/chrome/browser/ui/webui/settings/chromeos/device_section.cc
@@ -1031,23 +1031,30 @@ SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate(); updater.RemoveSearchTags(GetTouchpadSearchConcepts()); updater.RemoveSearchTags(GetTouchpadScrollAccelerationSearchConcepts()); - updater.RemoveSearchTags(GetTouchpadHapticFeedback()); - updater.RemoveSearchTags(GetTouchpadHapticClickSensitivity()); if (exists) { updater.AddSearchTags(GetTouchpadSearchConcepts()); if (base::FeatureList::IsEnabled(chromeos::features::kAllowScrollSettings)) updater.AddSearchTags(GetTouchpadScrollAccelerationSearchConcepts()); - // TODO (gavinwill): Move the haptic touchpad search concepts into - // HapticTouchpadExists() once available. - if (base::FeatureList::IsEnabled( - ::features::kAllowDisableTouchpadHapticFeedback)) { - updater.AddSearchTags(GetTouchpadHapticFeedback()); - } - if (base::FeatureList::IsEnabled( - ::features::kAllowTouchpadHapticClickSettings)) { - updater.AddSearchTags(GetTouchpadHapticClickSensitivity()); - } + } +} + +void DeviceSection::HapticTouchpadExists(bool exists) { + SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate(); + updater.RemoveSearchTags(GetTouchpadHapticFeedback()); + updater.RemoveSearchTags(GetTouchpadHapticClickSensitivity()); + + if (!exists) { + return; + } + + if (base::FeatureList::IsEnabled( + ::features::kAllowDisableTouchpadHapticFeedback)) { + updater.AddSearchTags(GetTouchpadHapticFeedback()); + } + if (base::FeatureList::IsEnabled( + ::features::kAllowTouchpadHapticClickSettings)) { + updater.AddSearchTags(GetTouchpadHapticClickSensitivity()); } }
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_section.h b/chrome/browser/ui/webui/settings/chromeos/device_section.h index 95f5cab..e93e3cc 100644 --- a/chrome/browser/ui/webui/settings/chromeos/device_section.h +++ b/chrome/browser/ui/webui/settings/chromeos/device_section.h
@@ -56,6 +56,7 @@ // system::PointerDeviceObserver::Observer: void TouchpadExists(bool exists) override; + void HapticTouchpadExists(bool exists) override; void MouseExists(bool exists) override; void PointingStickExists(bool exists) override;
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc b/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc index e8f2587a..616e4e25 100644 --- a/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc +++ b/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc
@@ -32,7 +32,7 @@ constexpr char kAndroidEnabled[] = "androidEnabled"; // Dummy UUID for testing. The UUID is taken from -// components/arc/volume_mounter/arc_volume_mounter_bridge.cc. +// ash/components/arc/volume_mounter/arc_volume_mounter_bridge.cc. constexpr char kDummyUuid[] = "00000000000000000000000000000000DEADBEEF"; const char* CalculationTypeToEventName(
diff --git a/chrome/browser/user_agent/user_agent_browsertest.cc b/chrome/browser/user_agent/user_agent_browsertest.cc deleted file mode 100644 index 918ed7ae..0000000 --- a/chrome/browser/user_agent/user_agent_browsertest.cc +++ /dev/null
@@ -1,88 +0,0 @@ -// Copyright 2021 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 "base/bind.h" -#include "base/test/scoped_feature_list.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/chrome_content_browser_client.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/common/pref_names.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "chrome/test/base/scoped_testing_local_state.h" -#include "chrome/test/base/testing_browser_process.h" -#include "chrome/test/base/ui_test_utils.h" -#include "components/embedder_support/user_agent_utils.h" -#include "components/prefs/pref_service.h" -#include "content/public/test/browser_test.h" -#include "net/http/http_request_headers.h" -#include "third_party/blink/public/common/features.h" - -namespace policy { - -using EnterprisePolicyState = - ChromeContentBrowserClient::UserAgentReductionEnterprisePolicyState; - -class UserAgentBrowserTest : public InProcessBrowserTest, - public testing::WithParamInterface<bool> { - public: - UserAgentBrowserTest() { - embedded_test_server()->RegisterRequestMonitor(base::BindRepeating( - &UserAgentBrowserTest::MonitorUserAgent, base::Unretained(this))); - if (GetParam()) { - scoped_feature_list_.InitAndEnableFeature( - blink::features::kReduceUserAgent); - } - } - - void ExpectUserAgent(std::string expected_user_agent) { - EXPECT_EQ(expected_user_agent, observered_user_agent_); - } - - void set_user_agent_reduction_policy(int policy) { - browser()->profile()->GetPrefs()->SetInteger(prefs::kUserAgentReduction, - policy); - } - - int user_agent_reduction_policy() { - return browser()->profile()->GetPrefs()->GetInteger( - prefs::kUserAgentReduction); - } - - private: - void MonitorUserAgent(const net::test_server::HttpRequest& request) { - observered_user_agent_ = - request.headers.find(net::HttpRequestHeaders::kUserAgent)->second; - } - - std::string observered_user_agent_; - base::test::ScopedFeatureList scoped_feature_list_; -}; - -IN_PROC_BROWSER_TEST_P(UserAgentBrowserTest, EnterprisePolicyState) { - ASSERT_TRUE(embedded_test_server()->Start()); - GURL url = embedded_test_server()->GetURL("/empty.html"); - - // Check that default is set correctly - EXPECT_EQ(EnterprisePolicyState::kDefault, user_agent_reduction_policy()); - - set_user_agent_reduction_policy(EnterprisePolicyState::kForceDisabled); - ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url)); - ExpectUserAgent(embedder_support::GetFullUserAgent()); - - set_user_agent_reduction_policy(EnterprisePolicyState::kForceEnabled); - ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url)); - ExpectUserAgent(embedder_support::GetReducedUserAgent()); - - set_user_agent_reduction_policy(EnterprisePolicyState::kDefault); - ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url)); - ExpectUserAgent(embedder_support::GetUserAgent()); -} - -INSTANTIATE_TEST_SUITE_P(ReduceUserAgentFeature, - UserAgentBrowserTest, - ::testing::Bool()); - -} // namespace policy
diff --git a/chrome/build/linux.pgo.txt b/chrome/build/linux.pgo.txt index 33c7710..e759ccb 100644 --- a/chrome/build/linux.pgo.txt +++ b/chrome/build/linux.pgo.txt
@@ -1 +1 @@ -chrome-linux-main-1637171708-555a54e81cb15ab58d705bc3a46722a3241eaca0.profdata +chrome-linux-main-1637193204-e5ba9fe8d9b1fbcf3ae90b98f1e62d3e080b3ec9.profdata
diff --git a/chrome/build/mac.pgo.txt b/chrome/build/mac.pgo.txt index 520181aa..19cf1d7 100644 --- a/chrome/build/mac.pgo.txt +++ b/chrome/build/mac.pgo.txt
@@ -1 +1 @@ -chrome-mac-main-1637171708-f185520a910fbb88bb9d719820d80ff84a921076.profdata +chrome-mac-main-1637193204-c44e60b3a110e5e789228a478afd2d9380a13d10.profdata
diff --git a/chrome/build/win32.pgo.txt b/chrome/build/win32.pgo.txt index 290806a..8792be2 100644 --- a/chrome/build/win32.pgo.txt +++ b/chrome/build/win32.pgo.txt
@@ -1 +1 @@ -chrome-win32-main-1637171708-17003bcd4a05091296b27b58a7ceb85a6be4fefa.profdata +chrome-win32-main-1637193204-05f8a04b3a0697b9b788db1fd49e1c4abaa13560.profdata
diff --git a/chrome/build/win64.pgo.txt b/chrome/build/win64.pgo.txt index 5741148..fb3ff24 100644 --- a/chrome/build/win64.pgo.txt +++ b/chrome/build/win64.pgo.txt
@@ -1 +1 @@ -chrome-win64-main-1637171708-f202ade7a961975de9a8741bdd840dd770f9cdd2.profdata +chrome-win64-main-1637193204-57a455ee87b529d85233e774f3d3faeb8bc7446b.profdata
diff --git a/chrome/common/chrome_features.cc b/chrome/common/chrome_features.cc index 2ecf2cf..191e2b3 100644 --- a/chrome/common/chrome_features.cc +++ b/chrome/common/chrome_features.cc
@@ -75,7 +75,7 @@ const base::Feature kAppServiceExternalProtocol{ "AppServiceExternalProtocol", base::FEATURE_DISABLED_BY_DEFAULT}; const base::Feature kAppServiceLoadIconWithoutMojom{ - "AppServiceLoadIconWithoutMojom", base::FEATURE_DISABLED_BY_DEFAULT}; + "AppServiceLoadIconWithoutMojom", base::FEATURE_ENABLED_BY_DEFAULT}; #endif // !defined(OS_ANDROID) #if defined(OS_MAC)
diff --git a/chrome/common/extensions/api/file_manager_private.idl b/chrome/common/extensions/api/file_manager_private.idl index 427be04..473fcb6 100644 --- a/chrome/common/extensions/api/file_manager_private.idl +++ b/chrome/common/extensions/api/file_manager_private.idl
@@ -722,12 +722,14 @@ DOMString timezone; boolean arcEnabled; boolean arcRemovableMediaAccessEnabled; + DOMString[] folderShortcuts; }; dictionary PreferencesChange { boolean? cellularDisabled; boolean? arcEnabled; boolean? arcRemovableMediaAccessEnabled; + DOMString[]? folderShortcuts; }; dictionary SearchParams {
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index c861034..6469784 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc
@@ -1648,10 +1648,6 @@ const char kSuppressDifferentOriginSubframeJSDialogs[] = "suppress_different_origin_subframe_js_dialogs"; -// Enum indicating if the user agent reduction feature should be forced enabled -// or disabled. Defaults to blink::features::kReduceUserAgent field trial. -const char kUserAgentReduction[] = "user_agent_reduction"; - // *************** LOCAL STATE *************** // These are attached to the machine/installation
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 9f9df29..f4344370 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h
@@ -1185,8 +1185,6 @@ extern const char kSuppressDifferentOriginSubframeJSDialogs[]; -extern const char kUserAgentReduction[]; - #if BUILDFLAG(IS_CHROMEOS_ASH) extern const char kPdfAnnotationsEnabled[]; #endif
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index c97d31b..7d4a6d6 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -1647,6 +1647,7 @@ "../browser/net/chrome_network_service_browsertest.cc", "../browser/net/chrome_network_service_restart_browsertest.cc", "../browser/net/cookie_policy_browsertest.cc", + "../browser/net/cookie_store_sameparty_browsertest.cc", "../browser/net/cookie_store_samesite_browsertest.cc", "../browser/net/dns_over_https_browsertest.cc", "../browser/net/dns_probe_browsertest.cc", @@ -2058,7 +2059,6 @@ "../browser/ukm_worker_browsertest.cc", "../browser/unload_browsertest.cc", "../browser/usb/usb_browsertest.cc", - "../browser/user_agent/user_agent_browsertest.cc", "../browser/wake_lock/wake_lock_browsertest.cc", "../browser/webauthn/chrome_webauthn_browsertest.cc", "../browser/window_placement/window_placement_browsertest.cc", @@ -2706,6 +2706,7 @@ deps += [ "//chrome/browser/enterprise/connectors/device_trust:features", + "//chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands:test_support", "//chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence:test_support", ] } @@ -3162,6 +3163,7 @@ "../browser/ash/login/screens/fingerprint_setup_browsertest.cc", "../browser/ash/login/screens/gesture_navigation_screen_browsertest.cc", "../browser/ash/login/screens/hid_detection_screen_browsertest.cc", + "../browser/ash/login/screens/lacros_data_migration_screen_browsertest.cc", "../browser/ash/login/screens/management_transition_screen_browsertest.cc", "../browser/ash/login/screens/marketing_opt_in_screen_browsertest.cc", "../browser/ash/login/screens/mock_arc_terms_of_service_screen.cc", @@ -3424,6 +3426,7 @@ "../browser/ui/ash/keyboard/keyboard_end_to_end_browsertest.cc", "../browser/ui/ash/multi_user/test_multi_user_window_manager.cc", "../browser/ui/ash/multi_user/test_multi_user_window_manager.h", + "../browser/ui/ash/projector/pending_screencast_manager_browsertest.cc", "../browser/ui/ash/projector/projector_client_impl_browsertest.cc", "../browser/ui/ash/projector/projector_navigation_throttle_browsertest.cc", "../browser/ui/ash/screen_orientation_delegate_chromeos_browsertest.cc",
diff --git a/chrome/test/data/policy/policy_test_cases.json b/chrome/test/data/policy/policy_test_cases.json index 4314d93..2c650cec 100644 --- a/chrome/test/data/policy/policy_test_cases.json +++ b/chrome/test/data/policy/policy_test_cases.json
@@ -17350,53 +17350,5 @@ } } ] - }, - "UserAgentReduction": { - "os": [ - "android", - "chromeos_ash", - "chromeos_lacros", - "linux", - "mac", - "win" - ], - "policy_pref_mapping_tests": [ - { - "policies": {}, - "prefs": { - "user_agent_reduction": { - "location": "user_profile", - "default_value": 0 - } - } - }, - { - "policies": {"UserAgentReduction": 0}, - "prefs": { - "user_agent_reduction": { - "location": "user_profile", - "value": 0 - } - } - }, - { - "policies": {"UserAgentReduction": 1}, - "prefs": { - "user_agent_reduction": { - "location": "user_profile", - "value": 1 - } - } - }, - { - "policies": {"UserAgentReduction": 2}, - "prefs": { - "user_agent_reduction": { - "location": "user_profile", - "value": 2 - } - } - } - ] } }
diff --git a/chrome/test/data/webui/chromeos/firmware_update/peripheral_updates_list_test.js b/chrome/test/data/webui/chromeos/firmware_update/peripheral_updates_list_test.js index 79617b38..d5b562a278 100644 --- a/chrome/test/data/webui/chromeos/firmware_update/peripheral_updates_list_test.js +++ b/chrome/test/data/webui/chromeos/firmware_update/peripheral_updates_list_test.js
@@ -10,7 +10,7 @@ import {UpdateCardElement} from 'chrome://accessory-update/update_card.js'; import {assertEquals, assertFalse, assertTrue} from '../../chai_assert.js'; -import {flushTasks} from '../../test_util.js'; +import {flushTasks, isVisible} from '../../test_util.js'; export function peripheralUpdatesListTest() { /** @type {?PeripheralUpdateListElement} */ @@ -19,7 +19,7 @@ /** @type {?FakeUpdateProvider} */ let provider = null; - suiteSetup(() => { + setup(() => { provider = new FakeUpdateProvider(); setUpdateProviderForTesting(provider); }); @@ -52,6 +52,15 @@ /** * @suppress {visibility} + * @return {!Promise} + */ + function clearFirmwareUpdates() { + peripheralUpdateListElement.firmwareUpdates_ = []; + return flushTasks(); + } + + /** + * @suppress {visibility} * @return {!Array<!FirmwareUpdate>} */ function getFirmwareUpdates() { @@ -74,4 +83,14 @@ }); }); }); + + test('EmptyState', () => { + return initializeUpdateList() + .then(() => clearFirmwareUpdates()) + .then(() => { + assertTrue(isVisible(/** @type {!HTMLDivElement} */ ( + peripheralUpdateListElement.shadowRoot.querySelector( + '#upToDateText')))); + }); + }); }
diff --git a/chrome/test/data/webui/settings/chromeos/device_page_tests.js b/chrome/test/data/webui/settings/chromeos/device_page_tests.js index e48bc6af..1e43609 100644 --- a/chrome/test/data/webui/settings/chromeos/device_page_tests.js +++ b/chrome/test/data/webui/settings/chromeos/device_page_tests.js
@@ -58,6 +58,7 @@ cr.webUIListenerCallback('has-mouse-changed', true); cr.webUIListenerCallback('has-pointing-stick-changed', true); cr.webUIListenerCallback('has-touchpad-changed', true); + cr.webUIListenerCallback('has-haptic-touchpad-changed', true); }, /** override */ @@ -339,6 +340,16 @@ type: chrome.settingsPrivate.PrefType.NUMBER, value: 3, }, + haptic_feedback: { + key: 'settings.touchpad.haptic_feedback', + type: chrome.settingsPrivate.PrefType.BOOLEAN, + value: true, + }, + haptic_click_sensitivity: { + key: 'settings.touchpad.haptic_click_sensitivity', + type: chrome.settingsPrivate.PrefType.NUMBER, + value: 3, + }, }, mouse: { primary_right: { @@ -773,6 +784,24 @@ expectEquals(2, slider.pref.value); }); + test('haptic touchpad', function() { + expectTrue(pointersPage.$$('#touchpadHapticFeedbackToggle').checked); + + const slider = + assert(pointersPage.$$('#touchpadHapticClickSensitivity')); + expectEquals(3, slider.pref.value); + MockInteractions.pressAndReleaseKeyOn( + slider.shadowRoot.querySelector('cr-slider'), 39 /* right */, [], + 'ArrowRight'); + expectEquals( + 5, + devicePage.prefs.settings.touchpad.haptic_click_sensitivity.value); + + pointersPage.set( + 'prefs.settings.touchpad.haptic_click_sensitivity.value', 1); + expectEquals(1, slider.pref.value); + }); + test('link doesn\'t activate control', function() { expectReverseScrollValue(pointersPage, false);
diff --git a/chrome/test/data/webui/settings/chromeos/os_settings_v3_browsertest.js b/chrome/test/data/webui/settings/chromeos/os_settings_v3_browsertest.js index 1eb27f85..45a0a9e 100644 --- a/chrome/test/data/webui/settings/chromeos/os_settings_v3_browsertest.js +++ b/chrome/test/data/webui/settings/chromeos/os_settings_v3_browsertest.js
@@ -40,6 +40,16 @@ get browsePreload() { return 'chrome://os-settings/test_loader.html?module=settings/chromeos/device_page_tests.m.js'; } + + /** @override */ + get featureList() { + return { + enabled: [ + 'features::kAllowDisableTouchpadHapticFeedback', + 'features::kAllowTouchpadHapticClickSettings', + ], + }; + } }; TEST_F(
diff --git a/chrome/test/data/webui/settings/chromeos/test_crostini_browser_proxy.js b/chrome/test/data/webui/settings/chromeos/test_crostini_browser_proxy.js index e54cbe7..7694476 100644 --- a/chrome/test/data/webui/settings/chromeos/test_crostini_browser_proxy.js +++ b/chrome/test/data/webui/settings/chromeos/test_crostini_browser_proxy.js
@@ -36,6 +36,7 @@ 'createContainer', 'deleteContainer', 'requestContainerInfo', + 'setContainerBadgeColor', 'stopContainer', ]); this.crostiniMicSharingEnabled = false; @@ -228,6 +229,11 @@ } /** @override */ + setContainerBadgeColor(containerId, badge_color) { + this.methodCalled('setContainerBadgeColor'); + } + + /** @override */ stopContainer(containerId) { this.methodCalled('stopContainer'); }
diff --git a/chromeos/chromeos_strings.grd b/chromeos/chromeos_strings.grd index 2eae79d..40982ea 100644 --- a/chromeos/chromeos_strings.grd +++ b/chromeos/chromeos_strings.grd
@@ -2287,6 +2287,30 @@ <message name="IDS_SHIMLESS_RMA_REPAIR_COMPLETED_BATTERY_CUTOFF_INSTRUCTIONS" translateable="false" desc="Instructions for battery cutoff. These instructions will display when a power cable is attached and the button is disabled."> Remove power cable to enable this option. </message> + <message name="IDS_SHIMLESS_RMA_LOGS_TITLE" translateable="false" desc="Title for the logs dialog displayed on repair complete page"> + RMA Logs + </message> + <message name="IDS_SHIMLESS_RMA_LOGS_CANCEL_BUTTON" translateable="false" desc="Label for the logs dialog cancel button"> + Cancel + </message> + <message name="IDS_SHIMLESS_RMA_LOGS_SAVE_BUTTON" translateable="false" desc="Label for the logs dialog save to USB button. This triggers saving to the root of a USB drive with no option to select location or title of the logs. It is automatic as the file browser is not available to the shimless RMA app."> + Save to USB + </message> + <message name="IDS_SHIMLESS_BATTERY_CUTOFF_TITLE" translateable="false" desc="Title for the battery cutoff dialog for confirming or cancelling the cutoff action"> + Battery Cutoff + </message> + <message name="IDS_SHIMLESS_BATTERY_SHUTOFF_UNPLUG_MESSAGE" translateable="false" desc="Message informing user they need to disconnect the power cable to perform battery shutoff"> + Unplug your cord to cut off battery + </message> + <message name="IDS_SHIMLESS_BATTERY_SHUTOFF_SHUTDOWN_MESSAGE" translateable="false" desc="Message informing user the device is ready to be shut down and perform battery shutoff"> + Shut down your device to complete battery cut off + </message> + <message name="IDS_SHIMLESS_BATTERY_SHUTOFF_CANCEL_BUTTON" translateable="false" desc="Label for the battery shutoff dialog cancel button"> + Cancel + </message> + <message name="IDS_SHIMLESS_BATTERY_SHUTOFF_SHUTDOWN_BUTTON" translateable="false" desc="Label for the battery shutoff dialog shut down button."> + Shut down + </message> <!-- Run calibration page --> <message name="IDS_SHIMLESS_RMA_RUN_CALIBRATION_PAGE_TITLE" translateable="false" desc="Title for the page shown when running component calibration steps."> Calibrating device components
diff --git a/chromeos/crosapi/mojom/app_service_types.mojom b/chromeos/crosapi/mojom/app_service_types.mojom index 3df41675..1d0770bd 100644 --- a/chromeos/crosapi/mojom/app_service_types.mojom +++ b/chromeos/crosapi/mojom/app_service_types.mojom
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Next MinVersion: 12 +// Next MinVersion: 13 module crosapi.mojom; @@ -84,6 +84,11 @@ [MinVersion=11] // Whether the app publisher allows the app to be uninstalled. OptionalBool allow_uninstall@25; + + [MinVersion=12] + // kTrue if the app is able to handle intents and should be shown in intent + // surfaces. + OptionalBool handles_intents@26; }; // The types of apps available in the registry.
diff --git a/chromeos/crosapi/mojom/app_service_types_mojom_traits.cc b/chromeos/crosapi/mojom/app_service_types_mojom_traits.cc index c62df02d..b899c91 100644 --- a/chromeos/crosapi/mojom/app_service_types_mojom_traits.cc +++ b/chromeos/crosapi/mojom/app_service_types_mojom_traits.cc
@@ -118,6 +118,10 @@ if (!data.ReadAllowUninstall(&allow_uninstall)) return false; + apps::mojom::OptionalBool handles_intents; + if (!data.ReadHandlesIntents(&handles_intents)) + return false; + auto app = apps::mojom::App::New(); app->app_type = std::move(app_type); app->app_id = app_id; @@ -145,6 +149,7 @@ app->window_mode = window_mode; app->permissions = std::move(permissions); app->allow_uninstall = allow_uninstall; + app->handles_intents = handles_intents; *out = std::move(app); return true; }
diff --git a/chromeos/crosapi/mojom/app_service_types_mojom_traits.h b/chromeos/crosapi/mojom/app_service_types_mojom_traits.h index 6251e13..0b1508c 100644 --- a/chromeos/crosapi/mojom/app_service_types_mojom_traits.h +++ b/chromeos/crosapi/mojom/app_service_types_mojom_traits.h
@@ -144,6 +144,11 @@ return r->allow_uninstall; } + static const apps::mojom::OptionalBool& handles_intents( + const apps::mojom::AppPtr& r) { + return r->handles_intents; + } + static bool Read(crosapi::mojom::AppDataView data, apps::mojom::AppPtr* out); };
diff --git a/chromeos/crosapi/mojom/app_service_types_traits_unittest.cc b/chromeos/crosapi/mojom/app_service_types_traits_unittest.cc index 90647db8..4a293ea6 100644 --- a/chromeos/crosapi/mojom/app_service_types_traits_unittest.cc +++ b/chromeos/crosapi/mojom/app_service_types_traits_unittest.cc
@@ -65,6 +65,7 @@ input->permissions.push_back(std::move(permission)); input->allow_uninstall = apps::mojom::OptionalBool::kTrue; + input->handles_intents = apps::mojom::OptionalBool::kTrue; apps::mojom::AppPtr output; ASSERT_TRUE( @@ -121,6 +122,7 @@ EXPECT_TRUE(out_permission->is_managed); EXPECT_EQ(output->allow_uninstall, apps::mojom::OptionalBool::kTrue); + EXPECT_EQ(output->handles_intents, apps::mojom::OptionalBool::kTrue); } // Test that serialization and deserialization works with optional fields that @@ -150,6 +152,7 @@ input->intent_filters.push_back(std::move(intent_filter)); input->window_mode = apps::mojom::WindowMode::kBrowser; input->allow_uninstall = apps::mojom::OptionalBool::kTrue; + input->handles_intents = apps::mojom::OptionalBool::kTrue; apps::mojom::AppPtr output; ASSERT_TRUE( @@ -184,6 +187,7 @@ EXPECT_EQ(output->window_mode, apps::mojom::WindowMode::kBrowser); EXPECT_EQ(output->allow_uninstall, apps::mojom::OptionalBool::kTrue); + EXPECT_EQ(output->handles_intents, apps::mojom::OptionalBool::kTrue); } // Test that serialization and deserialization works with updating app type.
diff --git a/chromeos/dbus/fwupd/fwupd_client.cc b/chromeos/dbus/fwupd/fwupd_client.cc index 72701ed..7deefce 100644 --- a/chromeos/dbus/fwupd/fwupd_client.cc +++ b/chromeos/dbus/fwupd/fwupd_client.cc
@@ -39,9 +39,6 @@ void Init(dbus::Bus* bus) override { DCHECK(bus); - if (!features::IsFirmwareUpdaterAppEnabled()) - return; - proxy_ = bus->GetObjectProxy(kFwupdServiceName, dbus::ObjectPath(kFwupdServicePath)); DCHECK(proxy_); @@ -54,7 +51,7 @@ } void RequestUpdates(const std::string& device_id) override { - DCHECK(IsInitialized()); + CHECK(features::IsFirmwareUpdaterAppEnabled()); dbus::MethodCall method_call(kFwupdServiceInterface, kFwupdGetUpgradesMethodName); dbus::MessageWriter writer(&method_call); @@ -68,7 +65,7 @@ } void RequestDevices() override { - DCHECK(IsInitialized()); + CHECK(features::IsFirmwareUpdaterAppEnabled()); dbus::MethodCall method_call(kFwupdServiceInterface, kFwupdGetDevicesMethodName); proxy_->CallMethodWithErrorResponse( @@ -78,9 +75,6 @@ } private: - // Return true if the client has been initialized. - bool IsInitialized() { return proxy_; } - // Pops a string-to-variant-string dictionary from the reader. std::unique_ptr<base::DictionaryValue> PopStringToStringDictionary( dbus::MessageReader* reader) { @@ -226,6 +220,10 @@ // TODO(swifton): This is a stub implementation. void OnDeviceAddedReceived(dbus::Signal* signal) { + // Do nothing if the feature is not enabled. + if (!features::IsFirmwareUpdaterAppEnabled()) + return; + if (client_is_in_testing_mode_) { ++device_signal_call_count_for_testing_; }
diff --git a/chromeos/dbus/shill/fake_shill_manager_client.cc b/chromeos/dbus/shill/fake_shill_manager_client.cc index 2288201..08fa06f 100644 --- a/chromeos/dbus/shill/fake_shill_manager_client.cc +++ b/chromeos/dbus/shill/fake_shill_manager_client.cc
@@ -483,7 +483,7 @@ void FakeShillManagerClient::AddPasspointCredentials( const dbus::ObjectPath& profile_path, const base::Value& properties, - ObjectPathCallback callback, + base::OnceClosure callback, ErrorCallback error_callback) { return; }
diff --git a/chromeos/dbus/shill/fake_shill_manager_client.h b/chromeos/dbus/shill/fake_shill_manager_client.h index ac091f8..7861731 100644 --- a/chromeos/dbus/shill/fake_shill_manager_client.h +++ b/chromeos/dbus/shill/fake_shill_manager_client.h
@@ -68,7 +68,7 @@ ErrorCallback error_callback) override; void AddPasspointCredentials(const dbus::ObjectPath& profile_path, const base::Value& properties, - ObjectPathCallback callback, + base::OnceClosure callback, ErrorCallback error_callback) override; ShillManagerClient::TestInterface* GetTestInterface() override;
diff --git a/chromeos/dbus/shill/shill_manager_client.cc b/chromeos/dbus/shill/shill_manager_client.cc index 72cdd90..07a85a7 100644 --- a/chromeos/dbus/shill/shill_manager_client.cc +++ b/chromeos/dbus/shill/shill_manager_client.cc
@@ -177,15 +177,15 @@ void AddPasspointCredentials(const dbus::ObjectPath& profile_path, const base::Value& properties, - ObjectPathCallback callback, + base::OnceClosure callback, ErrorCallback error_callback) override { dbus::MethodCall method_call(shill::kFlimflamManagerInterface, shill::kAddPasspointCredentialsFunction); dbus::MessageWriter writer(&method_call); writer.AppendObjectPath(profile_path); ShillClientHelper::AppendServiceProperties(&writer, properties); - helper_->CallObjectPathMethodWithErrorCallback( - &method_call, std::move(callback), std::move(error_callback)); + helper_->CallVoidMethodWithErrorCallback(&method_call, std::move(callback), + std::move(error_callback)); } TestInterface* GetTestInterface() override { return nullptr; }
diff --git a/chromeos/dbus/shill/shill_manager_client.h b/chromeos/dbus/shill/shill_manager_client.h index c916cc91..9675334 100644 --- a/chromeos/dbus/shill/shill_manager_client.h +++ b/chromeos/dbus/shill/shill_manager_client.h
@@ -216,7 +216,7 @@ // referenced by |profile_path|. virtual void AddPasspointCredentials(const dbus::ObjectPath& profile_path, const base::Value& properties, - ObjectPathCallback callback, + base::OnceClosure callback, ErrorCallback error_callback) = 0; // Returns an interface for testing (stub only), or returns null.
diff --git a/chromeos/tast_control.gni b/chromeos/tast_control.gni index 786ea13..514b47fb 100644 --- a/chromeos/tast_control.gni +++ b/chromeos/tast_control.gni
@@ -45,9 +45,6 @@ # crbug.com/1263234 "quicksettings.ManagedDeviceInfo", - # crbug.com/1268959 - "quicksettings.OpenSettings", - # b/201197372 "crostini.AppEmacs",
diff --git a/components/arc/BUILD.gn b/components/arc/BUILD.gn index 3dab5eb..9649e99b 100644 --- a/components/arc/BUILD.gn +++ b/components/arc/BUILD.gn
@@ -50,39 +50,9 @@ "intent_helper/link_handler_model.cc", "intent_helper/link_handler_model.h", "intent_helper/open_url_delegate.h", - "net/always_on_vpn_manager.cc", - "net/always_on_vpn_manager.h", - "net/arc_net_host_impl.cc", - "net/arc_net_host_impl.h", - "obb_mounter/arc_obb_mounter_bridge.cc", - "obb_mounter/arc_obb_mounter_bridge.h", - "pay/arc_digital_goods_bridge.cc", - "pay/arc_digital_goods_bridge.h", - "pay/arc_payment_app_bridge.cc", - "pay/arc_payment_app_bridge.h", - "power/arc_power_bridge.cc", - "power/arc_power_bridge.h", - "property/arc_property_bridge.cc", - "property/arc_property_bridge.h", - "rotation_lock/arc_rotation_lock_bridge.cc", - "rotation_lock/arc_rotation_lock_bridge.h", - "sensor/arc_iio_sensor_bridge.cc", - "sensor/arc_iio_sensor_bridge.h", - "sensor/arc_sensor_bridge.cc", - "sensor/arc_sensor_bridge.h", - "storage_manager/arc_storage_manager.cc", - "storage_manager/arc_storage_manager.h", - "timer/arc_timer_bridge.cc", - "timer/arc_timer_bridge.h", - "usb/usb_host_bridge.cc", - "usb/usb_host_bridge.h", - "usb/usb_host_ui_delegate.h", - "volume_mounter/arc_volume_mounter_bridge.cc", - "volume_mounter/arc_volume_mounter_bridge.h", - "wake_lock/arc_wake_lock_bridge.cc", - "wake_lock/arc_wake_lock_bridge.h", ] + # TODO(b/129295708): Remove these public_deps. public_deps = [ "//ash/components/arc:arc", "//ash/components/arc:arc_base", @@ -90,6 +60,7 @@ "//ash/components/arc:prefs", ] + # TODO(b/129295708): Clean up unused deps. Update users of this target. deps = [ "//ash:ash", "//ash/components/audio",
diff --git a/components/arc/mojom/BUILD.gn b/components/arc/mojom/BUILD.gn index d131a67..969ea61 100644 --- a/components/arc/mojom/BUILD.gn +++ b/components/arc/mojom/BUILD.gn
@@ -227,8 +227,10 @@ cpp = "::clockid_t" }, ] - traits_headers = [ "//components/arc/timer/arc_timer_mojom_traits.h" ] - traits_sources = [ "//components/arc/timer/arc_timer_mojom_traits.cc" ] + traits_headers = + [ "//ash/components/arc/timer/arc_timer_mojom_traits.h" ] + traits_sources = + [ "//ash/components/arc/timer/arc_timer_mojom_traits.cc" ] }, { types = [ @@ -241,10 +243,12 @@ cpp = "::chromeos::disks::DiskMountManager::MountEvent" }, ] - traits_headers = - [ "//components/arc/volume_mounter/volume_mounter_mojom_traits.h" ] - traits_sources = - [ "//components/arc/volume_mounter/volume_mounter_mojom_traits.cc" ] + traits_headers = [ + "//ash/components/arc/volume_mounter/volume_mounter_mojom_traits.h", + ] + traits_sources = [ + "//ash/components/arc/volume_mounter/volume_mounter_mojom_traits.cc", + ] }, ] }
diff --git a/components/embedder_support/user_agent_utils.cc b/components/embedder_support/user_agent_utils.cc index 447a607..678a975 100644 --- a/components/embedder_support/user_agent_utils.cc +++ b/components/embedder_support/user_agent_utils.cc
@@ -242,16 +242,6 @@ return version_info::GetProductNameAndVersionForUserAgent(); } -std::string GetFullUserAgent() { - std::string product = GetProduct(); -#if defined(OS_ANDROID) - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kUseMobileUserAgent)) - product += " Mobile"; -#endif - return content::BuildUserAgentFromProduct(product); -} - std::string GetUserAgent() { base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(kUserAgent)) { @@ -264,7 +254,12 @@ if (base::FeatureList::IsEnabled(blink::features::kReduceUserAgent)) return GetReducedUserAgent(); - return GetFullUserAgent(); + std::string product = GetProduct(); +#if defined(OS_ANDROID) + if (command_line->HasSwitch(switches::kUseMobileUserAgent)) + product += " Mobile"; +#endif + return content::BuildUserAgentFromProduct(product); } std::string GetReducedUserAgent() {
diff --git a/components/embedder_support/user_agent_utils.h b/components/embedder_support/user_agent_utils.h index cf8eb83..6fcbffb 100644 --- a/components/embedder_support/user_agent_utils.h +++ b/components/embedder_support/user_agent_utils.h
@@ -25,16 +25,13 @@ // Returns the product used in building the user-agent. std::string GetProduct(); -// Returns the user agent string for Chrome. -std::string GetFullUserAgent(); +// Returns the user agent string for Chrome. If the ReduceUserAgent +// feature is enabled, this will return |GetReducedUserAgent| +std::string GetUserAgent(); // Returns the reduced user agent string for Chrome. std::string GetReducedUserAgent(); -// Returns the full or "reduced" user agent string, depending on the -// UserAgentReduction enterprise policy and blink::features::kReduceUserAgent -std::string GetUserAgent(); - // Returns UserAgentMetadata per the default policy. // This override is currently used in fuchsia, where the enterprise policy // is not relevant.
diff --git a/components/exo/extended_drag_source.cc b/components/exo/extended_drag_source.cc index 3853661..1701b40 100644 --- a/components/exo/extended_drag_source.cc +++ b/components/exo/extended_drag_source.cc
@@ -305,13 +305,16 @@ auto end_closure = base::BindOnce( [](aura::Window* toplevel, + base::WeakPtr<ExtendedDragSource> extended_drag_source, ash::ToplevelWindowEventHandler::DragResult result) { if (toplevel) { toplevel->ClearProperty(ash::kIsDraggingTabsKey); toplevel->ClearProperty(ash::kTabDraggingSourceWindowKey); } + if (extended_drag_source) + extended_drag_source->dragged_window_holder_.reset(); }, - base::Unretained(toplevel)); + base::Unretained(toplevel), weak_factory_.GetWeakPtr()); // TODO(crbug.com/1167581): Experiment setting |update_gesture_target| back // to true when capture is removed from drag and drop. @@ -367,7 +370,6 @@ aura::client::kAnimationsDisabledKey); } event_blocker_.reset(); - dragged_window_holder_.reset(); drag_source_window_ = nullptr; drag_drop_tracker_.reset(); UnlockCursor();
diff --git a/components/exo/wayland/BUILD.gn b/components/exo/wayland/BUILD.gn index e849fc3..dce5cdb 100644 --- a/components/exo/wayland/BUILD.gn +++ b/components/exo/wayland/BUILD.gn
@@ -100,6 +100,7 @@ "//third_party/wayland-protocols:stylus_tools_protocol", "//third_party/wayland-protocols:text_input_extension_protocol", "//third_party/wayland-protocols:text_input_protocol", + "//third_party/wayland-protocols:touchpad_haptics_protocol", "//third_party/wayland-protocols:viewporter_protocol", "//third_party/wayland-protocols:vsync_feedback_protocol", "//third_party/wayland-protocols:xdg_decoration_protocol", @@ -182,6 +183,8 @@ "zcr_remote_shell_v2.h", "zcr_stylus_tools.cc", "zcr_stylus_tools.h", + "zcr_touchpad_haptics.cc", + "zcr_touchpad_haptics.h", "zwp_idle_inhibit_manager.cc", "zwp_idle_inhibit_manager.h", "zwp_input_timestamps_manager.cc",
diff --git a/components/exo/wayland/zcr_touchpad_haptics.cc b/components/exo/wayland/zcr_touchpad_haptics.cc new file mode 100644 index 0000000..d829bf6 --- /dev/null +++ b/components/exo/wayland/zcr_touchpad_haptics.cc
@@ -0,0 +1,46 @@ +// Copyright 2021 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 "components/exo/wayland/zcr_touchpad_haptics.h" + +#include <touchpad-haptics-unstable-v1-server-protocol.h> +#include <wayland-server-core.h> +#include <wayland-server-protocol-core.h> + +namespace exo { +namespace wayland { +namespace { + +void touchpad_haptics_destroy(wl_client* client, wl_resource* resource) { + wl_resource_destroy(resource); +} + +void touchpad_haptics_play(wl_client* client, + wl_resource* resource, + uint32_t effect, + int32_t strength) { + // TODO(b/205702807): Call InputController::PlayHapticTouchpadEffect. +} + +const struct zcr_touchpad_haptics_v1_interface touchpad_haptics_implementation = + { + touchpad_haptics_destroy, + touchpad_haptics_play, +}; + +} // namespace + +void bind_touchpad_haptics(wl_client* client, + void* data, + uint32_t version, + uint32_t id) { + wl_resource* resource = wl_resource_create( + client, &zcr_touchpad_haptics_v1_interface, version, id); + + wl_resource_set_implementation(resource, &touchpad_haptics_implementation, + nullptr, nullptr); +} + +} // namespace wayland +} // namespace exo
diff --git a/components/exo/wayland/zcr_touchpad_haptics.h b/components/exo/wayland/zcr_touchpad_haptics.h new file mode 100644 index 0000000..9840b39 --- /dev/null +++ b/components/exo/wayland/zcr_touchpad_haptics.h
@@ -0,0 +1,23 @@ +// Copyright 2021 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 COMPONENTS_EXO_WAYLAND_ZCR_TOUCHPAD_HAPTICS_H_ +#define COMPONENTS_EXO_WAYLAND_ZCR_TOUCHPAD_HAPTICS_H_ + +#include <cinttypes> + +struct wl_client; + +namespace exo { +namespace wayland { + +void bind_touchpad_haptics(wl_client* client, + void* data, + uint32_t version, + uint32_t id); + +} // namespace wayland +} // namespace exo + +#endif // COMPONENTS_EXO_WAYLAND_ZCR_TOUCHPAD_HAPTICS_H_
diff --git a/components/history_clusters/core/on_device_clustering_backend.cc b/components/history_clusters/core/on_device_clustering_backend.cc index fd7877f..c3cca61 100644 --- a/components/history_clusters/core/on_device_clustering_backend.cc +++ b/components/history_clusters/core/on_device_clustering_backend.cc
@@ -39,15 +39,16 @@ if (!template_url_service) return visit.url_row.url(); - const TemplateURL* default_search_provider = - template_url_service->GetDefaultSearchProvider(); + const TemplateURL* template_url = + template_url_service->GetTemplateURLForHost(visit.url_row.url().host()); + const SearchTermsData& search_terms_data = template_url_service->search_terms_data(); std::u16string search_terms; bool is_valid_search_url = - default_search_provider && - default_search_provider->ExtractSearchTermsFromURL( + template_url && + template_url->ExtractSearchTermsFromURL( visit.url_row.url(), search_terms_data, &search_terms) && !search_terms.empty(); if (!is_valid_search_url) @@ -56,7 +57,7 @@ const std::u16string& normalized_search_query = base::i18n::ToLower(base::CollapseWhitespace(search_terms, false)); TemplateURLRef::SearchTermsArgs search_terms_args(normalized_search_query); - const TemplateURLRef& search_url_ref = default_search_provider->url_ref(); + const TemplateURLRef& search_url_ref = template_url->url_ref(); if (!search_url_ref.SupportsReplacement(search_terms_data)) return visit.url_row.url();
diff --git a/components/history_clusters/core/on_device_clustering_backend_unittest.cc b/components/history_clusters/core/on_device_clustering_backend_unittest.cc index 6f7cf7d..4bb4118 100644 --- a/components/history_clusters/core/on_device_clustering_backend_unittest.cc +++ b/components/history_clusters/core/on_device_clustering_backend_unittest.cc
@@ -514,11 +514,21 @@ visit2.content_annotations.model_annotations.visibility_score = 0.5; visits.push_back(visit2); + history::AnnotatedVisit visit3 = testing::CreateDefaultAnnotatedVisit( + 3, GURL("http://non-default-engine.com/?q=nometadata#whatever")); + visit2.content_annotations.model_annotations.entities = { + history::VisitContentModelAnnotations::Category("nometadata", 30), + }; + visit3.content_annotations.model_annotations.page_topics_model_version = 127; + visit3.content_annotations.model_annotations.visibility_score = 0.5; + visits.push_back(visit3); + std::vector<history::Cluster> result_clusters = ClusterVisits(visits); - ASSERT_EQ(result_clusters.size(), 1u); + ASSERT_EQ(result_clusters.size(), 2u); EXPECT_THAT(testing::ToVisitResults(result_clusters), ElementsAre(ElementsAre(testing::VisitResult(1, 0.0), - testing::VisitResult(2, 1.0, {1})))); + testing::VisitResult(2, 1.0, {1})), + ElementsAre(testing::VisitResult(3, 1.0)))); // Make sure visits are normalized. history::Cluster cluster = result_clusters.at(0); ASSERT_EQ(cluster.visits.size(), 2u); @@ -548,12 +558,24 @@ .model_annotations.visibility_score, FloatEq(0.5)); + history::Cluster cluster2 = result_clusters.at(1); + ASSERT_EQ(cluster2.visits.size(), 1u); + // The third visit should have its original URL as the normalized URL and + // also have its entities rewritten. + history::ClusterVisit third_result_visit = cluster2.visits.at(0); + EXPECT_EQ(third_result_visit.normalized_url, + GURL("http://non-default-engine.com/?q=nometadata")); + EXPECT_TRUE(third_result_visit.annotated_visit.content_annotations + .model_annotations.entities.empty()); + EXPECT_TRUE(third_result_visit.annotated_visit.content_annotations + .model_annotations.categories.empty()); + histogram_tester.ExpectUniqueSample( - "History.Clusters.Backend.ClusterSize.Min", 2, 1); + "History.Clusters.Backend.ClusterSize.Min", 1, 1); histogram_tester.ExpectUniqueSample( "History.Clusters.Backend.ClusterSize.Max", 2, 1); histogram_tester.ExpectUniqueSample( - "History.Clusters.Backend.NumKeywordsPerCluster.Min", 2, 1); + "History.Clusters.Backend.NumKeywordsPerCluster.Min", 0, 1); histogram_tester.ExpectUniqueSample( "History.Clusters.Backend.NumKeywordsPerCluster.Max", 2, 1); histogram_tester.ExpectTotalCount(
diff --git a/components/location/OWNERS b/components/location/OWNERS index 5140571..d3930d9 100644 --- a/components/location/OWNERS +++ b/components/location/OWNERS
@@ -1,2 +1 @@ -jyasskin@chromium.org tedchoc@chromium.org
diff --git a/components/messages/android/java/src/org/chromium/components/messages/MessageWrapper.java b/components/messages/android/java/src/org/chromium/components/messages/MessageWrapper.java index e2e761d..8ddbd63a 100644 --- a/components/messages/android/java/src/org/chromium/components/messages/MessageWrapper.java +++ b/components/messages/android/java/src/org/chromium/components/messages/MessageWrapper.java
@@ -6,6 +6,7 @@ import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; import androidx.annotation.DrawableRes; @@ -159,6 +160,13 @@ mNativeMessageWrapper = 0; } + @CalledByNative + Bitmap getIconBitmap() { + Drawable drawable = mMessageProperties.get(MessageBannerProperties.ICON); + assert drawable instanceof BitmapDrawable; + return ((BitmapDrawable) drawable).getBitmap(); + } + private void handleActionClick() { if (mNativeMessageWrapper == 0) return; MessageWrapperJni.get().handleActionClick(mNativeMessageWrapper);
diff --git a/components/messages/android/message_wrapper.cc b/components/messages/android/message_wrapper.cc index 09df1f7..6ee6255 100644 --- a/components/messages/android/message_wrapper.cc +++ b/components/messages/android/message_wrapper.cc
@@ -214,4 +214,12 @@ java_window_android_ = java_window_android; } +const SkBitmap MessageWrapper::GetIconBitmap() { + JNIEnv* env = base::android::AttachCurrentThread(); + base::android::ScopedJavaLocalRef<jobject> bitmap = + Java_MessageWrapper_getIconBitmap(env, java_message_wrapper_); + gfx::JavaBitmap java_bitmap_lock(bitmap); + return gfx::CreateSkBitmapFromJavaBitmap(java_bitmap_lock); +} + } // namespace messages
diff --git a/components/messages/android/message_wrapper.h b/components/messages/android/message_wrapper.h index c40293a..6278a2ba 100644 --- a/components/messages/android/message_wrapper.h +++ b/components/messages/android/message_wrapper.h
@@ -94,6 +94,8 @@ return java_window_android_; } + const SkBitmap GetIconBitmap(); + private: base::android::ScopedJavaGlobalRef<jobject> java_message_wrapper_; base::OnceClosure action_callback_;
diff --git a/components/page_load_metrics/browser/observers/back_forward_cache_page_load_metrics_observer.cc b/components/page_load_metrics/browser/observers/back_forward_cache_page_load_metrics_observer.cc index f090c86..4fa99d6 100644 --- a/components/page_load_metrics/browser/observers/back_forward_cache_page_load_metrics_observer.cc +++ b/components/page_load_metrics/browser/observers/back_forward_cache_page_load_metrics_observer.cc
@@ -186,6 +186,20 @@ builder.Record(ukm::UkmRecorder::Get()); } +page_load_metrics::PageLoadMetricsObserver::ObservePolicy +BackForwardCachePageLoadMetricsObserver::ShouldObserveMimeType( + const std::string& mime_type) const { + PageLoadMetricsObserver::ObservePolicy policy = + PageLoadMetricsObserver::ShouldObserveMimeType(mime_type); + if (policy == STOP_OBSERVING && has_ever_entered_back_forward_cache_) { + ukm::builders::UserPerceivedPageVisit( + GetLastUkmSourceIdForBackForwardCacheRestore()) + .SetNotCountedForCoreWebVitals(true) + .Record(ukm::UkmRecorder::Get()); + } + return policy; +} + void BackForwardCachePageLoadMetricsObserver:: OnFirstPaintAfterBackForwardCacheRestoreInPage( const page_load_metrics::mojom::BackForwardCacheTiming& timing,
diff --git a/components/page_load_metrics/browser/observers/back_forward_cache_page_load_metrics_observer.h b/components/page_load_metrics/browser/observers/back_forward_cache_page_load_metrics_observer.h index a0ad0ce2..9cee345 100644 --- a/components/page_load_metrics/browser/observers/back_forward_cache_page_load_metrics_observer.h +++ b/components/page_load_metrics/browser/observers/back_forward_cache_page_load_metrics_observer.h
@@ -93,6 +93,8 @@ void OnRestoreFromBackForwardCache( const page_load_metrics::mojom::PageLoadTiming& timing, content::NavigationHandle* navigation_handle) override; + page_load_metrics::PageLoadMetricsObserver::ObservePolicy + ShouldObserveMimeType(const std::string& mime_type) const override; void OnFirstPaintAfterBackForwardCacheRestoreInPage( const page_load_metrics::mojom::BackForwardCacheTiming& timing, size_t index) override;
diff --git a/components/page_load_metrics/browser/observers/back_forward_cache_page_load_metrics_observer_unittest.cc b/components/page_load_metrics/browser/observers/back_forward_cache_page_load_metrics_observer_unittest.cc index 2e3fbb5..3f6a154 100644 --- a/components/page_load_metrics/browser/observers/back_forward_cache_page_load_metrics_observer_unittest.cc +++ b/components/page_load_metrics/browser/observers/back_forward_cache_page_load_metrics_observer_unittest.cc
@@ -20,6 +20,7 @@ using page_load_metrics::FakePageLoadMetricsObserverDelegate; using page_load_metrics::PageLoadMetricsObserverDelegate; using ukm::builders::HistoryNavigation; +using ukm::builders::UserPerceivedPageVisit; class BackForwardCachePageLoadMetricsObserverTest : public page_load_metrics::PageLoadMetricsObserverContentTestHarness { @@ -498,3 +499,37 @@ EXPECT_EQ(page_load_metrics::PageEndReason::END_NEW_NAVIGATION, result_metrics[1].begin()->second); } + +TEST_F(BackForwardCachePageLoadMetricsObserverTest, TestLogsNonCWVPageVisit) { + auto fake_bfcache_restore = + PageLoadMetricsObserverDelegate::BackForwardCacheRestore( + /*was_in_foreground=*/true, base::TimeTicks()); + fake_delegate_->AddBackForwardCacheRestore(fake_bfcache_restore); + observer_with_fake_delegate_->ShouldObserveMimeType("fake-mime-type"); + auto& test_ukm_recorder = tester()->test_ukm_recorder(); + auto result_metrics = test_ukm_recorder.FilteredHumanReadableMetricForEntry( + UserPerceivedPageVisit::kEntryName, + UserPerceivedPageVisit::kNotCountedForCoreWebVitalsName); + EXPECT_EQ(1U, result_metrics.size()); + EXPECT_EQ(UserPerceivedPageVisit::kNotCountedForCoreWebVitalsName, + result_metrics[0].begin()->first); + EXPECT_TRUE(result_metrics[0].begin()->second); + + observer_with_fake_delegate_->ShouldObserveMimeType("text/html"); + result_metrics = test_ukm_recorder.FilteredHumanReadableMetricForEntry( + UserPerceivedPageVisit::kEntryName, + UserPerceivedPageVisit::kNotCountedForCoreWebVitalsName); + // The metric being tested here indicates whether or not logs should be + // ignored when counting logs towards Core Web Vitals. Either the metric being + // present and false, or the metric being absent completely, means the logs + // shouldn't be counted. + // We've just indicated that these logs *should* be counted. + // So if the result metrics size is still 1, this test has passed, and if the + // result metrics are of size 2, the new value should be false. + if (result_metrics.size() > 1) { + EXPECT_EQ(2U, result_metrics.size()); + EXPECT_EQ(UserPerceivedPageVisit::kNotCountedForCoreWebVitalsName, + result_metrics[1].begin()->first); + EXPECT_FALSE(result_metrics[1].begin()->second); + } +}
diff --git a/components/payments/content/android_app_communication_chrome_os.cc b/components/payments/content/android_app_communication_chrome_os.cc index 06337068..d57ca6e 100644 --- a/components/payments/content/android_app_communication_chrome_os.cc +++ b/components/payments/content/android_app_communication_chrome_os.cc
@@ -6,10 +6,10 @@ #include <utility> +#include "ash/components/arc/pay/arc_payment_app_bridge.h" #include "ash/public/cpp/external_arc/overlay/arc_overlay_manager.h" #include "base/callback_helpers.h" #include "components/arc/mojom/payment_app.mojom.h" -#include "components/arc/pay/arc_payment_app_bridge.h" #include "components/payments/core/android_app_description.h" #include "components/payments/core/chrome_os_error_strings.h" #include "components/payments/core/method_strings.h"
diff --git a/components/payments/content/android_app_communication_test_support_chrome_os.cc b/components/payments/content/android_app_communication_test_support_chrome_os.cc index 6b75f37..74b6c9b3 100644 --- a/components/payments/content/android_app_communication_test_support_chrome_os.cc +++ b/components/payments/content/android_app_communication_test_support_chrome_os.cc
@@ -6,10 +6,10 @@ #include <utility> +#include "ash/components/arc/pay/arc_payment_app_bridge.h" #include "ash/components/arc/test/arc_payment_app_bridge_test_support.h" #include "ash/public/cpp/external_arc/overlay/test/test_arc_overlay_manager.h" #include "components/arc/mojom/payment_app.mojom.h" -#include "components/arc/pay/arc_payment_app_bridge.h" #include "components/payments/core/method_strings.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json index 76cde26..5e90fed8 100644 --- a/components/policy/resources/policy_templates.json +++ b/components/policy/resources/policy_templates.json
@@ -28834,49 +28834,7 @@ The <ph name="ENTERPRISE_CONNECTOR_MINIMUM_DATA_SIZE">minimum_data_size</ph> indicates the minimum amount of data in bytes that triggers the pattern check. This means that a clipboard write from a blocked URL would be allowed if the size of the copied data is smaller than the value specified in this field. The default value is 100 bytes if the field is unset. ''' - }, - { - 'name': 'UserAgentReduction', - 'owners': ['abeyad@chromium.org', 'aarontag@chromium.org', 'miketaylr@chromium.org'], - 'type': 'int-enum', - 'schema': { - 'type': 'integer', - 'enum': [0,1,2], - }, - 'items': [ - { - 'name': 'Default', - 'value': 0, - 'caption': '''User Agent reduction will be controllable via Field-Trials and Origin-Trials.''', - }, - { - 'name': 'ForceDisabled', - 'value': 1, - 'caption': '''User Agent reduction diabled, and not enabled by Field-Trials or Origin-Trials.''', - }, - { - 'name': 'ForceEnabled', - 'value': 2, - 'caption': '''User Agent reduction will be enabled for all origins.''', - }, - ], - 'supported_on': ['chrome_os:98-', 'chrome.*:98-', 'android:98-'], - 'default': 0, - 'example_value': 0, - 'features': { - 'per_profile': True, - 'dynamic_refresh': True, - }, - 'id': 929, - 'tags': ['website-sharing'], - 'caption': '''Enable or disable the <ph name="USER_AGENT_REDUCTION_FEATURE_NAME">User-Agent Reduction</ph>.''', - 'desc': '''The <ph name="USER_AGENT_HEADER_NAME">User-Agent</ph> HTTP request header is scheduled to be reduced. In order to facilitate testing and compatibility, this policy can enable the reduction feature for all websites, or disable the ability for origin trials or field trials to enable the feature. - - To learn more about the <ph name="USER_AGENT_REDUCTION_FEATURE_NAME">User-Agent Reduction</ph> and its timeline, read here: - - https://blog.chromium.org/2021/09/user-agent-reduction-origin-trial-and-dates.html - ''' - }, + } ], 'messages': { # Messages that are not associated to any policies. @@ -29849,6 +29807,6 @@ 'placeholders': [], 'deleted_policy_ids': [114, 115, 204, 205, 206, 412, 476, 544, 546, 562, 569, 578, 583, 585, 586, 587, 588, 589, 590, 591, 600, 668, 669, 872], 'deleted_atomic_policy_group_ids': [19], - 'highest_id_currently_used': 929, + 'highest_id_currently_used': 928, 'highest_atomic_group_id_currently_used': 41 }
diff --git a/components/reporting/proto/synced/metric_data.proto b/components/reporting/proto/synced/metric_data.proto index 5a7d51e..38d3057 100644 --- a/components/reporting/proto/synced/metric_data.proto +++ b/components/reporting/proto/synced/metric_data.proto
@@ -99,6 +99,22 @@ optional CpuInfo cpu_info = 1; } +// Audio telemetry data recorded intermittently +message AudioTelemetry { + // Is active output device mute or not. + optional bool output_mute = 1; + // Is active input device mute or not. + optional bool input_mute = 2; + // Active output device's volume in [0, 100]. + optional int32 output_volume = 3; + // Active output device's name. + optional string output_device_name = 4; + // Active input device's gain in [0, 100]. + optional int32 input_gain = 5; + // Active input device's name. + optional string input_device_name = 6; +} + // Data that can change over time, collected and reported every specific period // of time or when an event occur. message TelemetryData { @@ -106,11 +122,14 @@ // Networks telemetry data. optional NetworksTelemetry networks_telemetry = 1; + // Audio telemetry data. + optional AudioTelemetry audio_telemetry = 2; } enum MetricEventType { EVENT_TYPE_UNSPECIFIED = 0; NETWORK_HTTPS_LATENCY_CHANGE = 1; + AUDIO_SEVERE_UNDERRUN = 2; } // Indicates one of the following conditions occurred on the device, data
diff --git a/components/webapps/browser/android/app_banner_manager_android.cc b/components/webapps/browser/android/app_banner_manager_android.cc index ec82a93..37a69f6 100644 --- a/components/webapps/browser/android/app_banner_manager_android.cc +++ b/components/webapps/browser/android/app_banner_manager_android.cc
@@ -557,8 +557,9 @@ if (base::FeatureList::IsEnabled(features::kInstallableAmbientBadgeMessage) && base::FeatureList::IsEnabled( messages::kMessagesForAndroidInfrastructure)) { - message_controller_.EnqueueMessage(web_contents(), GetAppName(), - primary_icon_, manifest().start_url); + message_controller_.EnqueueMessage( + web_contents(), GetAppName(), primary_icon_, has_maskable_primary_icon_, + manifest().start_url); } else { InstallableAmbientBadgeInfoBarDelegate::Create( web_contents(), weak_factory_.GetWeakPtr(), GetAppName(), primary_icon_,
diff --git a/components/webapps/browser/android/installable/installable_ambient_badge_message_controller.cc b/components/webapps/browser/android/installable/installable_ambient_badge_message_controller.cc index 8a4a8d85..21e8751 100644 --- a/components/webapps/browser/android/installable/installable_ambient_badge_message_controller.cc +++ b/components/webapps/browser/android/installable/installable_ambient_badge_message_controller.cc
@@ -32,6 +32,7 @@ content::WebContents* web_contents, const std::u16string& app_name, const SkBitmap& icon, + const bool is_primary_icon_maskable, const GURL& start_url) { DCHECK(!message_); @@ -48,9 +49,13 @@ IDS_AMBIENT_BADGE_INSTALL_ALTERNATIVE, app_name)); message_->SetDescription(url_formatter::FormatUrlForSecurityDisplay( start_url, url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); - // TODO(crbug.com/1247374): Add support for maskable primary icon. message_->DisableIconTint(); - message_->SetIcon(icon); + if (is_primary_icon_maskable && + WebappsIconUtils::DoesAndroidSupportMaskableIcons()) { + message_->SetIcon(WebappsIconUtils::GenerateAdaptiveIconBitmap(icon)); + } else { + message_->SetIcon(icon); + } message_->EnableLargeIcon(true); message_->SetIconRoundedCornerRadius( WebappsIconUtils::GetIdealIconCornerRadiusPxForPromptUI());
diff --git a/components/webapps/browser/android/installable/installable_ambient_badge_message_controller.h b/components/webapps/browser/android/installable/installable_ambient_badge_message_controller.h index 73184ea6..2efe0e0 100644 --- a/components/webapps/browser/android/installable/installable_ambient_badge_message_controller.h +++ b/components/webapps/browser/android/installable/installable_ambient_badge_message_controller.h
@@ -40,6 +40,7 @@ void EnqueueMessage(content::WebContents* web_contents, const std::u16string& app_name, const SkBitmap& icon, + const bool is_primary_icon_maskable, const GURL& start_url); // Dismisses displayed message. This method is safe to call when there is no
diff --git a/components/webapps/browser/android/installable/installable_ambient_badge_message_controller_unittest.cc b/components/webapps/browser/android/installable/installable_ambient_badge_message_controller_unittest.cc index a01e1a70a..24cd89ff 100644 --- a/components/webapps/browser/android/installable/installable_ambient_badge_message_controller_unittest.cc +++ b/components/webapps/browser/android/installable/installable_ambient_badge_message_controller_unittest.cc
@@ -6,6 +6,7 @@ #include "components/messages/android/mock_message_dispatcher_bridge.h" #include "components/webapps/browser/android/installable/installable_ambient_badge_client.h" +#include "components/webapps/browser/android/webapps_icon_utils.h" #include "content/public/test/test_renderer_host.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -36,6 +37,7 @@ void TearDown() override; void EnqueueMessage(); + void EnqueueMessage(bool maskable); void DismissMessage(bool expected); void TriggerActionClick(); @@ -45,6 +47,16 @@ return &message_controller_; } + void ExpectedIconChanged() { + SkBitmap bitmap = message_wrapper_->GetIconBitmap(); + EXPECT_NE(bitmap.bounds(), test_icon.bounds()); + } + + void ExpectedIconUnchanged() { + SkBitmap bitmap = message_wrapper_->GetIconBitmap(); + EXPECT_EQ(bitmap.bounds(), test_icon.bounds()); + } + messages::MessageWrapper* message_wrapper() { return message_wrapper_; } MockInstallableAmbientBadgeClient& client_mock() { return client_mock_; } @@ -53,6 +65,7 @@ MockInstallableAmbientBadgeClient client_mock_; InstallableAmbientBadgeMessageController message_controller_; messages::MessageWrapper* message_wrapper_ = nullptr; + SkBitmap test_icon; }; InstallableAmbientBadgeMessageControllerTest:: @@ -71,14 +84,18 @@ } void InstallableAmbientBadgeMessageControllerTest::EnqueueMessage() { + EnqueueMessage(false); +} + +void InstallableAmbientBadgeMessageControllerTest::EnqueueMessage( + bool maskable) { EXPECT_CALL(message_dispatcher_bridge_, EnqueueMessage) .WillOnce(testing::DoAll(testing::SaveArg<0>(&message_wrapper_), testing::Return(true))); - SkBitmap test_icon; - test_icon.allocPixels( - SkImageInfo::Make(1, 1, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType)); + test_icon.allocPixels(SkImageInfo::Make(100, 100, kRGBA_8888_SkColorType, + kUnpremul_SkAlphaType)); message_controller_.EnqueueMessage(web_contents(), kAppName, test_icon, - GURL("https://example.com/")); + maskable, GURL("https://example.com/")); } void InstallableAmbientBadgeMessageControllerTest::DismissMessage( @@ -140,6 +157,20 @@ EnqueueMessage(); EXPECT_CALL(client_mock(), AddToHomescreenFromBadge); EXPECT_CALL(client_mock(), BadgeDismissed).Times(0); + ExpectedIconUnchanged(); + TriggerActionClick(); +} + +// Tests that message is using an adaptive icon when icon is maskable. +TEST_F(InstallableAmbientBadgeMessageControllerTest, MaskableIcon) { + EnqueueMessage(true); + EXPECT_CALL(client_mock(), AddToHomescreenFromBadge); + EXPECT_CALL(client_mock(), BadgeDismissed).Times(0); + if (WebappsIconUtils::DoesAndroidSupportMaskableIcons()) { + ExpectedIconChanged(); + } else { + ExpectedIconUnchanged(); + } TriggerActionClick(); }
diff --git a/components/webapps/browser/android/java/src/org/chromium/components/webapps/WebappsIconUtils.java b/components/webapps/browser/android/java/src/org/chromium/components/webapps/WebappsIconUtils.java index 691658f..abb7aad 100644 --- a/components/webapps/browser/android/java/src/org/chromium/components/webapps/WebappsIconUtils.java +++ b/components/webapps/browser/android/java/src/org/chromium/components/webapps/WebappsIconUtils.java
@@ -69,6 +69,7 @@ private static final float SHORTCUT_ICON_IDEAL_SIZE_DP = 48; @TargetApi(Build.VERSION_CODES.O) + @CalledByNative public static Bitmap generateAdaptiveIconBitmap(Bitmap bitmap) { Bitmap padded = createHomeScreenIconFromWebIcon(bitmap, true); Icon adaptiveIcon = Icon.createWithAdaptiveBitmap(padded);
diff --git a/components/webapps/browser/android/webapps_icon_utils.cc b/components/webapps/browser/android/webapps_icon_utils.cc index 8fe7b1a7..97e897b 100644 --- a/components/webapps/browser/android/webapps_icon_utils.cc +++ b/components/webapps/browser/android/webapps_icon_utils.cc
@@ -139,6 +139,20 @@ : SkBitmap(); } +SkBitmap WebappsIconUtils::GenerateAdaptiveIconBitmap(const SkBitmap& bitmap) { + JNIEnv* env = base::android::AttachCurrentThread(); + ScopedJavaLocalRef<jobject> result; + + if (!bitmap.isNull()) { + ScopedJavaLocalRef<jobject> java_bitmap = gfx::ConvertToJavaBitmap(bitmap); + result = Java_WebappsIconUtils_generateAdaptiveIconBitmap(env, java_bitmap); + } + + return result.obj() + ? gfx::CreateSkBitmapFromJavaBitmap(gfx::JavaBitmap(result)) + : SkBitmap(); +} + int WebappsIconUtils::GetIdealIconCornerRadiusPxForPromptUI() { return Java_WebappsIconUtils_getIdealIconCornerRadiusPxForPromptUI( base::android::AttachCurrentThread());
diff --git a/components/webapps/browser/android/webapps_icon_utils.h b/components/webapps/browser/android/webapps_icon_utils.h index b39c37d..953ca0d 100644 --- a/components/webapps/browser/android/webapps_icon_utils.h +++ b/components/webapps/browser/android/webapps_icon_utils.h
@@ -53,6 +53,9 @@ const GURL& url, bool* is_generated); + // Generate an adaptive icon for given maskable icon bitmap. + static SkBitmap GenerateAdaptiveIconBitmap(const SkBitmap& icon); + static int GetIdealIconCornerRadiusPxForPromptUI(); static void SetIdealShortcutSizeForTesting(int size);
diff --git a/content/browser/accessibility/accessibility_win_browsertest.cc b/content/browser/accessibility/accessibility_win_browsertest.cc index b678046..4fdbe79 100644 --- a/content/browser/accessibility/accessibility_win_browsertest.cc +++ b/content/browser/accessibility/accessibility_win_browsertest.cc
@@ -5263,7 +5263,8 @@ EXPECT_EQ(nullptr, text_element.Get()); // Web content accessibility support should now be enabled. - expected_mode |= ui::AXMode::kWebContents; + expected_mode |= ui::AXMode::kNativeAPIs | ui::AXMode::kWebContents | + ui::AXMode::kScreenReader | ui::AXMode::kHTML; EXPECT_EQ(expected_mode, content::BrowserAccessibilityStateImpl::GetInstance() ->GetAccessibilityMode()); waiter.WaitForNotification();
diff --git a/content/browser/accessibility/browser_accessibility_state_impl_win.cc b/content/browser/accessibility/browser_accessibility_state_impl_win.cc index 4b5199c..242c728 100644 --- a/content/browser/accessibility/browser_accessibility_state_impl_win.cc +++ b/content/browser/accessibility/browser_accessibility_state_impl_win.cc
@@ -93,7 +93,8 @@ void OnProbableUIAutomationScreenReaderDetected() override { // Same as kAXModeComplete but without kHTML as it is not needed for UIA. - AddAXModeForUIA(ui::kAXModeCompleteNoHTML); + AddAXModeForUIA(ui::AXMode::kNativeAPIs | ui::AXMode::kWebContents | + ui::AXMode::kScreenReader); } void OnTextPatternRequested() override {
diff --git a/content/browser/aggregation_service/DEPS b/content/browser/aggregation_service/DEPS index 5dce390..434bfb8d 100644 --- a/content/browser/aggregation_service/DEPS +++ b/content/browser/aggregation_service/DEPS
@@ -1,3 +1,3 @@ include_rules = [ - "+third_party/distributed_point_functions/src", + "+third_party/distributed_point_functions", ]
diff --git a/content/browser/aggregation_service/aggregatable_report.cc b/content/browser/aggregation_service/aggregatable_report.cc index 35c60a8..30cfaf9 100644 --- a/content/browser/aggregation_service/aggregatable_report.cc +++ b/content/browser/aggregation_service/aggregatable_report.cc
@@ -27,7 +27,7 @@ #include "services/network/public/cpp/is_potentially_trustworthy.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/boringssl/src/include/openssl/hpke.h" -#include "third_party/distributed_point_functions/src/dpf/distributed_point_function.h" +#include "third_party/distributed_point_functions/code/dpf/distributed_point_function.h" #include "url/origin.h" namespace content {
diff --git a/content/browser/loader/navigation_url_loader_impl.cc b/content/browser/loader/navigation_url_loader_impl.cc index f76bb92..cfc9f79 100644 --- a/content/browser/loader/navigation_url_loader_impl.cc +++ b/content/browser/loader/navigation_url_loader_impl.cc
@@ -417,8 +417,7 @@ prefetched_signed_exchange_interceptor = prefetched_signed_exchange_cache->MaybeCreateInterceptor( url_, frame_tree_node_id_, - resource_request_->trusted_params->isolation_info - .network_isolation_key()); + resource_request_->trusted_params->isolation_info); if (prefetched_signed_exchange_interceptor) { interceptors_.push_back( std::move(prefetched_signed_exchange_interceptor)); @@ -608,10 +607,10 @@ // fallback, so restart it with the non-interceptor factory. url_loader_->RestartWithFactory(std::move(factory), options); } else { - // In SXG cases we don't have `url_loader_` because it was reset when the - // SXG interceptor intercepted the response in - // MaybeCreateLoaderForResponse. - DCHECK(response_loader_receiver_.is_bound()); + // In SXG cases we don't have `url_loader_` because it was reset when + // - SignedExchangeRequestHandler intercepted the response in + // MaybeCreateLoaderForResponse, or + // - PrefetchedNavigationLoaderInterceptor made an internal redirect. response_loader_receiver_.reset(); url_loader_ = blink::ThrottlingURLLoader::CreateLoaderAndStart( std::move(factory), CreateURLLoaderThrottles(),
diff --git a/content/browser/renderer_host/navigation_request.cc b/content/browser/renderer_host/navigation_request.cc index a7694895..3684132c 100644 --- a/content/browser/renderer_host/navigation_request.cc +++ b/content/browser/renderer_host/navigation_request.cc
@@ -309,8 +309,7 @@ // values of relevant headers like Sec-CH-UA-Reduced. If `user_agent_override` // is non-empty, `user_agent_override` is returned as the header value. std::string ComputeUserAgentValue(const net::HttpRequestHeaders& headers, - const std::string& user_agent_override, - content::BrowserContext* context) { + const std::string& user_agent_override) { if (!user_agent_override.empty()) { base::UmaHistogramEnumeration("Navigation.UserAgentStringType", UserAgentStringType::kOverriden); @@ -328,8 +327,7 @@ reduced ? UserAgentStringType::kReducedVersion : UserAgentStringType::kFullVersion); return reduced ? GetContentClient()->browser()->GetReducedUserAgent() - : GetContentClient()->browser()->GetUserAgentBasedOnPolicy( - context); + : GetContentClient()->browser()->GetUserAgent(); } // TODO(clamy): This should match what's happening in @@ -364,7 +362,7 @@ headers->SetHeaderIfMissing( net::HttpRequestHeaders::kUserAgent, - ComputeUserAgentValue(*headers, user_agent_override, browser_context)); + ComputeUserAgentValue(*headers, user_agent_override)); if (!render_prefs.enable_referrers) { *referrer = @@ -3961,8 +3959,7 @@ if (!devtools_user_agent_override_) { modified_headers.SetHeader( net::HttpRequestHeaders::kUserAgent, - ComputeUserAgentValue(modified_headers, GetUserAgentOverride(), - browser_context)); + ComputeUserAgentValue(modified_headers, GetUserAgentOverride())); } } @@ -6479,9 +6476,8 @@ common_params_->url, client_hints_delegate, is_overriding_user_agent(), frame_tree_node_, &headers); } - headers.SetHeader( - net::HttpRequestHeaders::kUserAgent, - ComputeUserAgentValue(headers, GetUserAgentOverride(), browser_context)); + headers.SetHeader(net::HttpRequestHeaders::kUserAgent, + ComputeUserAgentValue(headers, GetUserAgentOverride())); begin_params_->headers = headers.ToString(); // |request_headers_| comes from |begin_params_|. Clear |request_headers_| now // so that if |request_headers_| are needed, they will be updated.
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 2d4ac75..094b586f 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -5031,8 +5031,7 @@ // Pass bits of global renderer state to the renderer. GetRendererInterface()->SetUserAgent( - GetContentClient()->browser()->GetUserAgentBasedOnPolicy( - browser_context_)); + GetContentClient()->browser()->GetUserAgent()); GetRendererInterface()->SetReducedUserAgent( GetContentClient()->browser()->GetReducedUserAgent()); GetRendererInterface()->SetUserAgentMetadata(
diff --git a/content/browser/service_worker/embedded_worker_test_helper.h b/content/browser/service_worker/embedded_worker_test_helper.h index cf926ee1..ae16f5a 100644 --- a/content/browser/service_worker/embedded_worker_test_helper.h +++ b/content/browser/service_worker/embedded_worker_test_helper.h
@@ -109,6 +109,8 @@ // Only used for tests that force creating a new render process. int new_render_process_id() const { return new_mock_render_process_id_; } + storage::MockQuotaManager* quota_manager() { return quota_manager_.get(); } + storage::MockQuotaManagerProxy* quota_manager_proxy() { return quota_manager_proxy_.get(); }
diff --git a/content/browser/service_worker/service_worker_registry.cc b/content/browser/service_worker/service_worker_registry.cc index 6c4144a7..46838a1b 100644 --- a/content/browser/service_worker/service_worker_registry.cc +++ b/content/browser/service_worker/service_worker_registry.cc
@@ -195,7 +195,11 @@ const blink::StorageKey& key, NewRegistrationCallback callback, storage::QuotaErrorOr<storage::BucketInfo> result) { - DCHECK(result.ok()); + // Return nullptr if GetOrCreateBucket fails. + if (!result.ok()) { + std::move(callback).Run(nullptr); + return; + } CreateInvokerAndStartRemoteCall( &storage::mojom::ServiceWorkerStorageControl::GetNewRegistrationId, base::BindOnce(&ServiceWorkerRegistry::DidGetNewRegistrationId,
diff --git a/content/browser/service_worker/service_worker_registry_unittest.cc b/content/browser/service_worker/service_worker_registry_unittest.cc index e59b2e1..f6b9981 100644 --- a/content/browser/service_worker/service_worker_registry_unittest.cc +++ b/content/browser/service_worker/service_worker_registry_unittest.cc
@@ -645,6 +645,30 @@ EXPECT_GT(result->id.value(), 0); } +TEST_F(ServiceWorkerRegistryTest, GetOrCreateBucketError) { + const GURL kScope("http://www.test.not/scope/"); + const blink::StorageKey kKey(url::Origin::Create(kScope)); + + scoped_refptr<ServiceWorkerRegistration> registration; + + blink::mojom::ServiceWorkerRegistrationOptions options; + options.scope = kScope; + + helper()->quota_manager()->SetDisableDatabase(true); + storage::QuotaManagerProxySync quota_manager_proxy_sync( + quota_manager_proxy()); + + base::RunLoop loop; + registry()->CreateNewRegistration( + std::move(options), kKey, + base::BindLambdaForTesting( + [&](scoped_refptr<ServiceWorkerRegistration> new_registration) { + EXPECT_EQ(new_registration, nullptr); + loop.Quit(); + })); + loop.Run(); +} + TEST_F(ServiceWorkerRegistryTest, StoreFindUpdateDeleteRegistration) { const GURL kScope("http://www.test.not/scope/"); const blink::StorageKey kKey(url::Origin::Create(kScope));
diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc index ac495278..75926a2b 100644 --- a/content/browser/service_worker/service_worker_version.cc +++ b/content/browser/service_worker/service_worker_version.cc
@@ -1914,8 +1914,7 @@ params->user_agent = (origin_trial_tokens_ && origin_trial_tokens_->contains("UserAgentReduction")) ? browser_client->GetReducedUserAgent() - : browser_client->GetUserAgentBasedOnPolicy( - context_->wrapper()->browser_context()); + : browser_client->GetUserAgent(); params->ua_metadata = browser_client->GetUserAgentMetadata(); params->is_installed = IsInstalled(status_); params->script_url_to_skip_throttling = updated_script_url_;
diff --git a/content/browser/web_package/prefetched_signed_exchange_cache.cc b/content/browser/web_package/prefetched_signed_exchange_cache.cc index a288eb9..a49460a 100644 --- a/content/browser/web_package/prefetched_signed_exchange_cache.cc +++ b/content/browser/web_package/prefetched_signed_exchange_cache.cc
@@ -14,6 +14,9 @@ #include "content/browser/loader/navigation_loader_interceptor.h" #include "content/browser/loader/single_request_url_loader_factory.h" #include "content/browser/navigation_subresource_loader_params.h" +#include "content/browser/renderer_host/frame_tree_node.h" +#include "content/browser/renderer_host/render_frame_host_impl.h" +#include "content/browser/storage_partition_impl.h" #include "content/browser/web_package/signed_exchange_reporter.h" #include "content/browser/web_package/signed_exchange_utils.h" #include "content/public/browser/browser_task_traits.h" @@ -37,6 +40,7 @@ #include "services/network/public/cpp/url_loader_completion_status.h" #include "services/network/public/cpp/wrapper_shared_url_loader_factory.h" #include "services/network/public/mojom/fetch_api.mojom-shared.h" +#include "services/network/public/mojom/restricted_cookie_manager.mojom.h" #include "services/network/public/mojom/url_loader.mojom.h" #include "services/network/public/mojom/url_response_head.mojom.h" #include "storage/browser/blob/blob_data_handle.h" @@ -471,8 +475,11 @@ public: PrefetchedNavigationLoaderInterceptor( std::unique_ptr<const PrefetchedSignedExchangeCacheEntry> exchange, - std::vector<blink::mojom::PrefetchedSignedExchangeInfoPtr> info_list) - : exchange_(std::move(exchange)), info_list_(std::move(info_list)) {} + std::vector<blink::mojom::PrefetchedSignedExchangeInfoPtr> info_list, + mojo::Remote<network::mojom::RestrictedCookieManager> cookie_manager) + : exchange_(std::move(exchange)), + info_list_(std::move(info_list)), + cookie_manager_(std::move(cookie_manager)) {} PrefetchedNavigationLoaderInterceptor( const PrefetchedNavigationLoaderInterceptor&) = delete; @@ -497,12 +504,21 @@ } if (tentative_resource_request.url == exchange_->inner_url()) { DCHECK_EQ(State::kOuterRequestRequested, state_); - state_ = State::kInnerResponseRequested; - std::move(callback).Run( - base::MakeRefCounted<SingleRequestURLLoaderFactory>(base::BindOnce( - &PrefetchedNavigationLoaderInterceptor::StartInnerResponse, - weak_factory_.GetWeakPtr()))); - return; + if (signed_exchange_utils::IsCookielessOnlyExchange( + *exchange_->inner_response()->headers)) { + DCHECK(cookie_manager_); + state_ = State::kCheckingCookies; + CheckAbsenceOfCookies(tentative_resource_request, std::move(callback), + std::move(fallback_callback)); + return; + } else { + state_ = State::kInnerResponseRequested; + std::move(callback).Run( + base::MakeRefCounted<SingleRequestURLLoaderFactory>(base::BindOnce( + &PrefetchedNavigationLoaderInterceptor::StartInnerResponse, + weak_factory_.GetWeakPtr()))); + return; + } } NOTREACHED(); } @@ -521,9 +537,43 @@ enum class State { kInitial, kOuterRequestRequested, + kCheckingCookies, kInnerResponseRequested }; + void CheckAbsenceOfCookies(const network::ResourceRequest& request, + LoaderCallback callback, + FallbackCallback fallback_callback) { + auto match_options = network::mojom::CookieManagerGetOptions::New(); + match_options->name = ""; + match_options->match_type = network::mojom::CookieMatchType::STARTS_WITH; + cookie_manager_->GetAllForUrl( + request.url, request.trusted_params->isolation_info.site_for_cookies(), + *request.trusted_params->isolation_info.top_frame_origin(), + std::move(match_options), + base::BindOnce(&PrefetchedNavigationLoaderInterceptor::OnGetCookies, + weak_factory_.GetWeakPtr(), std::move(callback), + std::move(fallback_callback))); + } + + void OnGetCookies(LoaderCallback callback, + FallbackCallback fallback_callback, + const std::vector<net::CookieWithAccessResult>& results) { + DCHECK_EQ(State::kCheckingCookies, state_); + if (!results.empty()) { + signed_exchange_utils::RecordLoadResultHistogram( + SignedExchangeLoadResult::kHadCookieForCookielessOnlySXG); + std::move(fallback_callback) + .Run(true /* reset_subresource_loader_params */); + return; + } + state_ = State::kInnerResponseRequested; + std::move(callback).Run( + base::MakeRefCounted<SingleRequestURLLoaderFactory>(base::BindOnce( + &PrefetchedNavigationLoaderInterceptor::StartInnerResponse, + weak_factory_.GetWeakPtr()))); + } + void StartRedirectResponse( const network::ResourceRequest& resource_request, mojo::PendingReceiver<network::mojom::URLLoader> receiver, @@ -567,6 +617,7 @@ State state_ = State::kInitial; const std::unique_ptr<const PrefetchedSignedExchangeCacheEntry> exchange_; std::vector<blink::mojom::PrefetchedSignedExchangeInfoPtr> info_list_; + mojo::Remote<network::mojom::RestrictedCookieManager> cookie_manager_; base::WeakPtrFactory<PrefetchedNavigationLoaderInterceptor> weak_factory_{ this}; @@ -704,7 +755,7 @@ PrefetchedSignedExchangeCache::MaybeCreateInterceptor( const GURL& outer_url, int frame_tree_node_id, - const net::NetworkIsolationKey& network_isolation_key) { + const net::IsolationInfo& isolation_info) { DCHECK_CURRENTLY_ON(BrowserThread::UI); const auto it = exchanges_.find(outer_url); if (it == exchanges_.end()) @@ -717,11 +768,35 @@ exchanges_.erase(it); return nullptr; } - auto info_list = GetInfoListForNavigation( - *exchange, verification_time, frame_tree_node_id, network_isolation_key); + auto info_list = + GetInfoListForNavigation(*exchange, verification_time, frame_tree_node_id, + isolation_info.network_isolation_key()); + + mojo::Remote<network::mojom::RestrictedCookieManager> cookie_manager; + auto* frame = FrameTreeNode::GloballyFindByID(frame_tree_node_id); + if (frame) { + StoragePartition* storage_partition = + frame->current_frame_host()->GetProcess()->GetStoragePartition(); + url::Origin inner_url_origin = url::Origin::Create(exchange->inner_url()); + net::IsolationInfo inner_url_isolation_info = + isolation_info.CreateForRedirect(inner_url_origin); + + RenderFrameHostImpl* render_frame_host = frame->current_frame_host(); + static_cast<StoragePartitionImpl*>(storage_partition) + ->CreateRestrictedCookieManager( + network::mojom::RestrictedCookieManagerRole::NETWORK, + inner_url_origin, inner_url_isolation_info, + /* is_service_worker = */ false, + render_frame_host ? render_frame_host->GetProcess()->GetID() : -1, + render_frame_host ? render_frame_host->GetRoutingID() + : MSG_ROUTING_NONE, + cookie_manager.BindNewPipeAndPassReceiver(), + render_frame_host ? render_frame_host->CreateCookieAccessObserver() + : mojo::NullRemote()); + } return std::make_unique<PrefetchedNavigationLoaderInterceptor>( - exchange->Clone(), std::move(info_list)); + exchange->Clone(), std::move(info_list), std::move(cookie_manager)); } const PrefetchedSignedExchangeCache::EntryMap&
diff --git a/content/browser/web_package/prefetched_signed_exchange_cache.h b/content/browser/web_package/prefetched_signed_exchange_cache.h index 0484b4a..99d8dbc 100644 --- a/content/browser/web_package/prefetched_signed_exchange_cache.h +++ b/content/browser/web_package/prefetched_signed_exchange_cache.h
@@ -16,7 +16,7 @@ #include "url/gurl.h" namespace net { -class NetworkIsolationKey; +class IsolationInfo; } namespace content { @@ -60,7 +60,7 @@ std::unique_ptr<NavigationLoaderInterceptor> MaybeCreateInterceptor( const GURL& outer_url, int frame_tree_node_id, - const net::NetworkIsolationKey& network_isolation_key); + const net::IsolationInfo& isolation_info); const EntryMap& GetExchanges();
diff --git a/content/browser/web_package/signed_exchange_devtools_proxy.cc b/content/browser/web_package/signed_exchange_devtools_proxy.cc index b9a69af..b73ac44 100644 --- a/content/browser/web_package/signed_exchange_devtools_proxy.cc +++ b/content/browser/web_package/signed_exchange_devtools_proxy.cc
@@ -103,13 +103,10 @@ void SignedExchangeDevToolsProxy::OnSignedExchangeReceived( const absl::optional<SignedExchangeEnvelope>& envelope, const scoped_refptr<net::X509Certificate>& certificate, - const net::SSLInfo* ssl_info) { + const absl::optional<net::SSLInfo>& ssl_info) { DCHECK_CURRENTLY_ON(BrowserThread::UI); if (!devtools_enabled_) return; - absl::optional<net::SSLInfo> ssl_info_opt; - if (ssl_info) - ssl_info_opt = *ssl_info; FrameTreeNode* frame_tree_node = FrameTreeNode::GloballyFindByID(frame_tree_node_id_); @@ -118,8 +115,7 @@ devtools_instrumentation::OnSignedExchangeReceived( frame_tree_node, devtools_navigation_token_, outer_request_url_, - *outer_response_, envelope, certificate, ssl_info_opt, - std::move(errors_)); + *outer_response_, envelope, certificate, ssl_info, std::move(errors_)); } } // namespace content
diff --git a/content/browser/web_package/signed_exchange_devtools_proxy.h b/content/browser/web_package/signed_exchange_devtools_proxy.h index b0e5de9e..4c30fbee 100644 --- a/content/browser/web_package/signed_exchange_devtools_proxy.h +++ b/content/browser/web_package/signed_exchange_devtools_proxy.h
@@ -73,7 +73,7 @@ void OnSignedExchangeReceived( const absl::optional<SignedExchangeEnvelope>& envelope, const scoped_refptr<net::X509Certificate>& certificate, - const net::SSLInfo* ssl_info); + const absl::optional<net::SSLInfo>& ssl_info); private: const GURL outer_request_url_;
diff --git a/content/browser/web_package/signed_exchange_error.h b/content/browser/web_package/signed_exchange_error.h index 51e7814..db24e4d 100644 --- a/content/browser/web_package/signed_exchange_error.h +++ b/content/browser/web_package/signed_exchange_error.h
@@ -51,7 +51,9 @@ kVariantMismatch, // Certificate's validity period is too long. kCertValidityPeriodTooLong, - kMaxValue = kCertValidityPeriodTooLong + // SXG had "Vary: Cookie" inner header but we had a cookie for the URL. + kHadCookieForCookielessOnlySXG, + kMaxValue = kHadCookieForCookielessOnlySXG }; struct SignedExchangeError {
diff --git a/content/browser/web_package/signed_exchange_handler.cc b/content/browser/web_package/signed_exchange_handler.cc index b2cc1de..76a29e17 100644 --- a/content/browser/web_package/signed_exchange_handler.cc +++ b/content/browser/web_package/signed_exchange_handler.cc
@@ -17,6 +17,7 @@ #include "content/browser/renderer_host/frame_tree_node.h" #include "content/browser/renderer_host/render_frame_host_impl.h" #include "content/browser/renderer_host/render_process_host_impl.h" +#include "content/browser/storage_partition_impl.h" #include "content/browser/web_package/prefetched_signed_exchange_cache_entry.h" #include "content/browser/web_package/signed_exchange_cert_fetcher_factory.h" #include "content/browser/web_package/signed_exchange_certificate_chain.h" @@ -172,6 +173,7 @@ ExchangeHeadersCallback headers_callback, std::unique_ptr<SignedExchangeCertFetcherFactory> cert_fetcher_factory, const net::NetworkIsolationKey& network_isolation_key, + const absl::optional<net::IsolationInfo> outer_request_isolation_info, int load_flags, const net::IPEndPoint& remote_endpoint, std::unique_ptr<blink::WebPackageRequestMatcher> request_matcher, @@ -184,6 +186,7 @@ source_(std::move(body)), cert_fetcher_factory_(std::move(cert_fetcher_factory)), network_isolation_key_(network_isolation_key), + outer_request_isolation_info_(std::move(outer_request_isolation_info)), load_flags_(load_flags), remote_endpoint_(remote_endpoint), request_matcher_(std::move(request_matcher)), @@ -455,7 +458,7 @@ envelope_, unverified_cert_chain_ ? unverified_cert_chain_->cert() : scoped_refptr<net::X509Certificate>(), - nullptr); + absl::nullopt); } std::move(headers_callback_) .Run(result, error, GetFallbackUrl(), nullptr, nullptr); @@ -655,6 +658,18 @@ response_head->headers->GetMimeTypeAndCharset(&response_head->mime_type, &response_head->charset); + net::SSLInfo ssl_info; + ssl_info.cert = cv_result.verified_cert; + ssl_info.unverified_cert = unverified_cert_chain_->cert(); + ssl_info.cert_status = cv_result.cert_status; + ssl_info.is_issued_by_known_root = cv_result.is_issued_by_known_root; + ssl_info.public_key_hashes = cv_result.public_key_hashes; + ssl_info.ocsp_result = cv_result.ocsp_result; + ssl_info.is_fatal_cert_error = net::IsCertStatusError(ssl_info.cert_status); + ssl_info.signed_certificate_timestamps = cv_result.scts; + ssl_info.ct_policy_compliance = cv_result.policy_compliance; + response_head->ssl_info = std::move(ssl_info); + if (!request_matcher_->MatchRequest(envelope_->response_headers())) { signed_exchange_utils::ReportErrorAndTraceEvent( devtools_proxy_.get(), @@ -664,6 +679,70 @@ return; } + // For prefetch, cookies will be checked by PrefetchedSignedExchangeCache. + if (!(load_flags_ & net::LOAD_PREFETCH) && + signed_exchange_utils::IsCookielessOnlyExchange( + *response_head->headers)) { + CheckAbsenceOfCookies(base::BindOnce(&SignedExchangeHandler::CreateResponse, + weak_factory_.GetWeakPtr(), + std::move(response_head))); + return; + } + CreateResponse(std::move(response_head)); +} + +void SignedExchangeHandler::CheckAbsenceOfCookies(base::OnceClosure callback) { + auto* frame = FrameTreeNode::GloballyFindByID(frame_tree_node_id_); + if (!frame) { + std::move(callback).Run(); + return; + } + DCHECK(outer_request_isolation_info_.has_value()); + + StoragePartition* storage_partition = + frame->current_frame_host()->GetProcess()->GetStoragePartition(); + url::Origin inner_url_origin = + url::Origin::Create(envelope_->request_url().url); + net::IsolationInfo isolation_info = + outer_request_isolation_info_->CreateForRedirect(inner_url_origin); + + RenderFrameHostImpl* render_frame_host = frame->current_frame_host(); + static_cast<StoragePartitionImpl*>(storage_partition) + ->CreateRestrictedCookieManager( + network::mojom::RestrictedCookieManagerRole::NETWORK, + inner_url_origin, isolation_info, + /* is_service_worker = */ false, + render_frame_host ? render_frame_host->GetProcess()->GetID() : -1, + render_frame_host ? render_frame_host->GetRoutingID() + : MSG_ROUTING_NONE, + cookie_manager_.BindNewPipeAndPassReceiver(), + render_frame_host ? render_frame_host->CreateCookieAccessObserver() + : mojo::NullRemote()); + + DCHECK(isolation_info.top_frame_origin().has_value()); + auto match_options = network::mojom::CookieManagerGetOptions::New(); + match_options->name = ""; + match_options->match_type = network::mojom::CookieMatchType::STARTS_WITH; + cookie_manager_->GetAllForUrl( + envelope_->request_url().url, isolation_info.site_for_cookies(), + *isolation_info.top_frame_origin(), std::move(match_options), + base::BindOnce(&SignedExchangeHandler::OnGetCookies, + weak_factory_.GetWeakPtr(), std::move(callback))); +} + +void SignedExchangeHandler::OnGetCookies( + base::OnceClosure callback, + const std::vector<net::CookieWithAccessResult>& results) { + if (!results.empty()) { + RunErrorCallback(SignedExchangeLoadResult::kHadCookieForCookielessOnlySXG, + net::ERR_INVALID_SIGNED_EXCHANGE); + return; + } + std::move(callback).Run(); +} + +void SignedExchangeHandler::CreateResponse( + network::mojom::URLResponseHeadPtr response_head) { // TODO(https://crbug.com/803774): Resource timing for signed exchange // loading is not speced yet. https://github.com/WICG/webpackage/issues/156 response_head->load_timing.request_start_time = base::Time::Now(); @@ -682,23 +761,11 @@ return; } - net::SSLInfo ssl_info; - ssl_info.cert = cv_result.verified_cert; - ssl_info.unverified_cert = unverified_cert_chain_->cert(); - ssl_info.cert_status = cv_result.cert_status; - ssl_info.is_issued_by_known_root = cv_result.is_issued_by_known_root; - ssl_info.public_key_hashes = cv_result.public_key_hashes; - ssl_info.ocsp_result = cv_result.ocsp_result; - ssl_info.is_fatal_cert_error = net::IsCertStatusError(ssl_info.cert_status); - ssl_info.signed_certificate_timestamps = cv_result.scts; - ssl_info.ct_policy_compliance = cv_result.policy_compliance; - if (devtools_proxy_) { devtools_proxy_->OnSignedExchangeReceived( - envelope_, unverified_cert_chain_->cert(), &ssl_info); + envelope_, unverified_cert_chain_->cert(), response_head->ssl_info); } - response_head->ssl_info = std::move(ssl_info); std::move(headers_callback_) .Run(SignedExchangeLoadResult::kSuccess, net::OK, envelope_->request_url().url, std::move(response_head),
diff --git a/content/browser/web_package/signed_exchange_handler.h b/content/browser/web_package/signed_exchange_handler.h index 63282eb..ea270549 100644 --- a/content/browser/web_package/signed_exchange_handler.h +++ b/content/browser/web_package/signed_exchange_handler.h
@@ -14,14 +14,17 @@ #include "content/browser/web_package/signed_exchange_error.h" #include "content/browser/web_package/signed_exchange_prologue.h" #include "content/common/content_export.h" +#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/system/data_pipe.h" #include "net/base/io_buffer.h" #include "net/base/ip_endpoint.h" +#include "net/base/isolation_info.h" #include "net/base/network_isolation_key.h" #include "net/cert/cert_verifier.h" #include "net/cert/cert_verify_result.h" #include "net/log/net_log_with_source.h" #include "services/network/public/cpp/shared_url_loader_factory.h" +#include "services/network/public/mojom/restricted_cookie_manager.mojom.h" #include "services/network/public/mojom/url_response_head.mojom.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" @@ -97,6 +100,7 @@ ExchangeHeadersCallback headers_callback, std::unique_ptr<SignedExchangeCertFetcherFactory> cert_fetcher_factory, const net::NetworkIsolationKey& network_isolation_key, + const absl::optional<net::IsolationInfo> outer_request_isolation_info, int load_flags, const net::IPEndPoint& remote_endpoint, std::unique_ptr<blink::WebPackageRequestMatcher> request_matcher, @@ -152,6 +156,10 @@ bool CheckOCSPStatus(const net::OCSPVerifyResult& ocsp_result); void OnVerifyCert(int32_t error_code, const net::CertVerifyResult& cv_result); + void CheckAbsenceOfCookies(base::OnceClosure callback); + void OnGetCookies(base::OnceClosure callback, + const std::vector<net::CookieWithAccessResult>& results); + void CreateResponse(network::mojom::URLResponseHeadPtr response_head); std::unique_ptr<net::SourceStream> CreateResponseBodyStream(); const bool is_secure_transport_; @@ -175,12 +183,14 @@ std::unique_ptr<SignedExchangeCertFetcherFactory> cert_fetcher_factory_; std::unique_ptr<SignedExchangeCertFetcher> cert_fetcher_; const net::NetworkIsolationKey network_isolation_key_; + absl::optional<net::IsolationInfo> outer_request_isolation_info_; const int load_flags_ = 0; const net::IPEndPoint remote_endpoint_; std::unique_ptr<SignedExchangeCertificateChain> unverified_cert_chain_; std::unique_ptr<blink::WebPackageRequestMatcher> request_matcher_; + mojo::Remote<network::mojom::RestrictedCookieManager> cookie_manager_; std::unique_ptr<SignedExchangeDevToolsProxy> devtools_proxy_;
diff --git a/content/browser/web_package/signed_exchange_handler_unittest.cc b/content/browser/web_package/signed_exchange_handler_unittest.cc index 393ef1a..8f895ec 100644 --- a/content/browser/web_package/signed_exchange_handler_unittest.cc +++ b/content/browser/web_package/signed_exchange_handler_unittest.cc
@@ -366,7 +366,8 @@ base::BindOnce(&SignedExchangeHandlerTest::OnHeaderFound, base::Unretained(this)), std::move(cert_fetcher_factory_), network_isolation_key_, - net::LOAD_NORMAL, net::IPEndPoint(), + absl::nullopt /* outer_request_isolation_info */, net::LOAD_NORMAL, + net::IPEndPoint(), std::make_unique<blink::WebPackageRequestMatcher>( net::HttpRequestHeaders(), std::string() /* accept_langs */), nullptr /* devtools_proxy */, nullptr /* reporter */,
diff --git a/content/browser/web_package/signed_exchange_loader.cc b/content/browser/web_package/signed_exchange_loader.cc index 9009047f..c834b511 100644 --- a/content/browser/web_package/signed_exchange_loader.cc +++ b/content/browser/web_package/signed_exchange_loader.cc
@@ -42,7 +42,6 @@ namespace { -constexpr char kLoadResultHistogram[] = "SignedExchange.LoadResult2"; constexpr char kPrefetchLoadResultHistogram[] = "SignedExchange.Prefetch.LoadResult2"; @@ -186,6 +185,9 @@ base::BindOnce(&SignedExchangeLoader::OnHTTPExchangeFound, weak_factory_.GetWeakPtr()), std::move(cert_fetcher_factory), network_isolation_key_, + outer_request_.trusted_params + ? absl::make_optional(outer_request_.trusted_params->isolation_info) + : absl::nullopt, outer_request_.load_flags, outer_response_head_->remote_endpoint, std::make_unique<blink::WebPackageRequestMatcher>(outer_request_.headers, accept_langs_), @@ -401,7 +403,7 @@ } void SignedExchangeLoader::ReportLoadResult(SignedExchangeLoadResult result) { - UMA_HISTOGRAM_ENUMERATION(kLoadResultHistogram, result); + signed_exchange_utils::RecordLoadResultHistogram(result); // |metric_recorder_| could be null in some tests. if ((outer_request_.load_flags & net::LOAD_PREFETCH) && metric_recorder_) { UMA_HISTOGRAM_ENUMERATION(kPrefetchLoadResultHistogram, result);
diff --git a/content/browser/web_package/signed_exchange_reporter.cc b/content/browser/web_package/signed_exchange_reporter.cc index 75f4ee23..7149dc1 100644 --- a/content/browser/web_package/signed_exchange_reporter.cc +++ b/content/browser/web_package/signed_exchange_reporter.cc
@@ -41,6 +41,7 @@ constexpr char kSXGResultCertParseError[] = "sxg.cert_parse_error"; constexpr char kSXGResultVariantMismatch[] = "sxg.variant_mismatch"; constexpr char kSXGHeaderIntegrityMismatch[] = "sxg.header_integrity_mismatch"; +constexpr char kSXGResultHadCookie[] = "sxg.had_cookie"; const char* GetResultTypeString(SignedExchangeLoadResult result) { switch (result) { @@ -80,6 +81,10 @@ // TODO(crbug/910516): Need to update the spec to send the report in this // case. return kSXGResultVariantMismatch; + case SignedExchangeLoadResult::kHadCookieForCookielessOnlySXG: + // TODO(crbug/910516): Need to update the spec to send the report in this + // case. + return kSXGResultHadCookie; } NOTREACHED(); return kSXGResultFailed;
diff --git a/content/browser/web_package/signed_exchange_request_handler_browsertest.cc b/content/browser/web_package/signed_exchange_request_handler_browsertest.cc index b562d91..4d74397 100644 --- a/content/browser/web_package/signed_exchange_request_handler_browsertest.cc +++ b/content/browser/web_package/signed_exchange_request_handler_browsertest.cc
@@ -676,6 +676,93 @@ "SignedExchange.Time.CertificateFetch.Failure", UsePrefetch() ? 2 : 1); } +IN_PROC_BROWSER_TEST_P(SignedExchangeRequestHandlerBrowserTest, + VaryCookieSxgUsed) { + InstallUrlInterceptor( + GURL("https://cert.example.org/cert.msg"), + "content/test/data/sxg/test.example.org.public.pem.cbor"); + InstallMockCert(); + + embedded_test_server()->ServeFilesFromSourceDirectory("content/test/data"); + ASSERT_TRUE(embedded_test_server()->Start()); + + GURL url = + embedded_test_server()->GetURL("/sxg/test.example.org_vary_cookie.sxg"); + MaybeTriggerPrefetchSXG(url, true); + + if (!UsePrefetch()) { + // Need to be in a page to execute JavaScript to trigger renderer initiated + // navigation. + EXPECT_TRUE( + NavigateToURL(shell(), embedded_test_server()->GetURL("/empty.html"))); + } + + std::u16string title = u"https://test.example.org/test/"; + TitleWatcher title_watcher(shell()->web_contents(), title); + // PrefetchedSignedExchangeCache is used only for renderer initiated + // navigation. So use JavaScript to trigger renderer initiated navigation. + EXPECT_TRUE( + ExecJs(shell()->web_contents(), + base::StringPrintf("location.href = '%s';", url.spec().c_str()))); + EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); + + histogram_tester_.ExpectUniqueSample( + kLoadResultHistogram, SignedExchangeLoadResult::kSuccess, + (UsePrefetch() && !SXGPrefetchCacheIsEnabled()) ? 2 : 1); +} + +IN_PROC_BROWSER_TEST_P(SignedExchangeRequestHandlerBrowserTest, + VaryCookieSxgNotUsed) { + InstallUrlInterceptor( + GURL("https://cert.example.org/cert.msg"), + "content/test/data/sxg/test.example.org.public.pem.cbor"); + InstallUrlInterceptor(GURL("https://test.example.org/test/"), + "content/test/data/sxg/fallback.html"); + InstallMockCert(); + + embedded_test_server()->ServeFilesFromSourceDirectory("content/test/data"); + ASSERT_TRUE(embedded_test_server()->Start()); + + SetCookie(shell()->web_contents()->GetBrowserContext(), + GURL("https://test.example.org/test/"), "milk=1"); + + GURL url = + embedded_test_server()->GetURL("/sxg/test.example.org_vary_cookie.sxg"); + MaybeTriggerPrefetchSXG(url, true); + + if (!UsePrefetch()) { + // Need to be in a page to execute JavaScript to trigger renderer initiated + // navigation. + EXPECT_TRUE( + NavigateToURL(shell(), embedded_test_server()->GetURL("/empty.html"))); + } + + std::u16string title = u"Fallback URL response"; + TitleWatcher title_watcher(shell()->web_contents(), title); + // PrefetchedSignedExchangeCache is used only for renderer initiated + // navigation. So use JavaScript to trigger renderer initiated navigation. + EXPECT_TRUE( + ExecJs(shell()->web_contents(), + base::StringPrintf("location.href = '%s';", url.spec().c_str()))); + EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); + + if (UsePrefetch()) { + // kSuccess is recorded for successful prefetch, and + // kHadCookieForCookielessOnlySXG is recorded by not being used for actual + // navigation. + histogram_tester_.ExpectBucketCount(kLoadResultHistogram, + SignedExchangeLoadResult::kSuccess, 1); + histogram_tester_.ExpectBucketCount( + kLoadResultHistogram, + SignedExchangeLoadResult::kHadCookieForCookielessOnlySXG, 1); + histogram_tester_.ExpectTotalCount(kLoadResultHistogram, 2); + } else { + histogram_tester_.ExpectUniqueSample( + kLoadResultHistogram, + SignedExchangeLoadResult::kHadCookieForCookielessOnlySXG, 1); + } +} + INSTANTIATE_TEST_SUITE_P(All, SignedExchangeRequestHandlerBrowserTest, ::testing::Combine(::testing::Bool(),
diff --git a/content/browser/web_package/signed_exchange_utils.cc b/content/browser/web_package/signed_exchange_utils.cc index 50e3780..0019e58 100644 --- a/content/browser/web_package/signed_exchange_utils.cc +++ b/content/browser/web_package/signed_exchange_utils.cc
@@ -6,6 +6,7 @@ #include "base/command_line.h" #include "base/feature_list.h" +#include "base/metrics/histogram_functions.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -29,9 +30,14 @@ namespace signed_exchange_utils { namespace { +constexpr char kLoadResultHistogram[] = "SignedExchange.LoadResult2"; absl::optional<base::Time> g_verification_time_for_testing; } // namespace +void RecordLoadResultHistogram(SignedExchangeLoadResult result) { + base::UmaHistogramEnumeration(kLoadResultHistogram, result); +} + void ReportErrorAndTraceEvent( SignedExchangeDevToolsProxy* devtools_proxy, const std::string& error_message, @@ -270,5 +276,15 @@ g_verification_time_for_testing = verification_time_for_testing; } +bool IsCookielessOnlyExchange(const net::HttpResponseHeaders& inner_headers) { + std::string value; + size_t iter = 0; + while (inner_headers.EnumerateHeader(&iter, "Vary", &value)) { + if (base::EqualsCaseInsensitiveASCII(value, "cookie")) + return true; + } + return false; +} + } // namespace signed_exchange_utils } // namespace content
diff --git a/content/browser/web_package/signed_exchange_utils.h b/content/browser/web_package/signed_exchange_utils.h index de6ed72..61d52173 100644 --- a/content/browser/web_package/signed_exchange_utils.h +++ b/content/browser/web_package/signed_exchange_utils.h
@@ -37,6 +37,9 @@ : url(url_string), raw_string(url_string) {} }; +// Records SignedExchange.LoadResult2 UMA histogram. +void RecordLoadResultHistogram(SignedExchangeLoadResult result); + // Utility method to call SignedExchangeDevToolsProxy::ReportError() and // TRACE_EVENT_INSTANT1 to report the error to both DevTools and about:tracing. // If |devtools_proxy| is nullptr, it just calls TRACE_EVENT_INSTANT1(). @@ -101,6 +104,8 @@ CONTENT_EXPORT void SetVerificationTimeForTesting( absl::optional<base::Time> verification_time_for_testing); +bool IsCookielessOnlyExchange(const net::HttpResponseHeaders& inner_headers); + } // namespace signed_exchange_utils } // namespace content
diff --git a/content/browser/worker_host/shared_worker_host.cc b/content/browser/worker_host/shared_worker_host.cc index 74cd75d2..9bef3a98 100644 --- a/content/browser/worker_host/shared_worker_host.cc +++ b/content/browser/worker_host/shared_worker_host.cc
@@ -302,8 +302,7 @@ factory_.Bind(std::move(factory)); factory_->CreateSharedWorker( std::move(info), token_, instance_.storage_key().origin(), - GetContentClient()->browser()->GetUserAgentBasedOnPolicy( - GetProcessHost()->GetBrowserContext()), + GetContentClient()->browser()->GetUserAgent(), GetContentClient()->browser()->GetReducedUserAgent(), GetContentClient()->browser()->GetUserAgentMetadata(), devtools_handle_->pause_on_start(), devtools_handle_->dev_tools_token(),
diff --git a/content/child/runtime_features.cc b/content/child/runtime_features.cc index 363e374..bfe74a31 100644 --- a/content/child/runtime_features.cc +++ b/content/child/runtime_features.cc
@@ -405,7 +405,6 @@ blink::features::kAutoExpandDetailsElement}, {"UserAgentClientHintFullVersionList", blink::features::kUserAgentClientHintFullVersionList}, - {"UserAgentReduction", blink::features::kReduceUserAgent}, }; for (const auto& mapping : runtimeFeatureNameToChromiumFeatureMapping) { SetRuntimeFeatureFromChromiumFeature(
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc index fb35c99..217b7e7 100644 --- a/content/public/browser/content_browser_client.cc +++ b/content/public/browser/content_browser_client.cc
@@ -878,7 +878,7 @@ network::mojom::NetworkContextParams* network_context_params, cert_verifier::mojom::CertVerifierCreationParams* cert_verifier_creation_params) { - network_context_params->user_agent = GetUserAgentBasedOnPolicy(context); + network_context_params->user_agent = GetUserAgent(); network_context_params->accept_language = "en-us,en"; } @@ -1070,11 +1070,6 @@ return std::string(); } -std::string ContentBrowserClient::GetUserAgentBasedOnPolicy( - content::BrowserContext* content) { - return GetUserAgent(); -} - std::string ContentBrowserClient::GetReducedUserAgent() { return GetUserAgent(); }
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h index 9c780cf..18327d5 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h
@@ -1886,16 +1886,10 @@ // Used as part of the user agent string. virtual std::string GetProduct(); - // Returns the user agent. This can also return the reduced user agent, based - // on blink::features::kUserAgentReduction. Content may cache this value. + // Returns the user agent.Content may cache this value. virtual std::string GetUserAgent(); - // Returns the user agent, allowing for preferences (i.e. enterprise policy). - // Default to the non-context |GetUserAgent| above. - virtual std::string GetUserAgentBasedOnPolicy( - content::BrowserContext* context); - - // Returns the reduced user agent string. Defaults to |GetUserAgent|. Content + // Returns the reduced user agent string. Defaults to |GetUserAgent| Content // may cache this value. virtual std::string GetReducedUserAgent();
diff --git a/content/test/data/sxg/generate-test-sxgs.sh b/content/test/data/sxg/generate-test-sxgs.sh index a802c46..bf499a6 100755 --- a/content/test/data/sxg/generate-test-sxgs.sh +++ b/content/test/data/sxg/generate-test-sxgs.sh
@@ -277,6 +277,22 @@ -o test.example.org_csp.sxg \ -miRecordSize 100 +# A signed exchange with "Vary: Cookie" response header. +gen-signedexchange \ + -version 1b3 \ + -uri https://test.example.org/test/ \ + -status 200 \ + -content test.html \ + -certificate prime256v1-sha256.public.pem \ + -certUrl https://cert.example.org/cert.msg \ + -validityUrl https://test.example.org/resource.validity.msg \ + -privateKey prime256v1.key \ + -date $signature_date \ + -expire 168h \ + -responseHeader "Vary: Cookie" \ + -o test.example.org_vary_cookie.sxg \ + -miRecordSize 100 + echo "Update the test signatures in " echo "signed_exchange_signature_verifier_unittest.cc with the followings:" echo "===="
diff --git a/content/test/data/sxg/test.example.org_vary_cookie.sxg b/content/test/data/sxg/test.example.org_vary_cookie.sxg new file mode 100644 index 0000000..ea2e0c15a --- /dev/null +++ b/content/test/data/sxg/test.example.org_vary_cookie.sxg Binary files differ
diff --git a/content/test/data/sxg/test.example.org_vary_cookie.sxg.mock-http-headers b/content/test/data/sxg/test.example.org_vary_cookie.sxg.mock-http-headers new file mode 100644 index 0000000..5833ecf6 --- /dev/null +++ b/content/test/data/sxg/test.example.org_vary_cookie.sxg.mock-http-headers
@@ -0,0 +1,3 @@ +HTTP/1.1 200 OK +Content-Type: application/signed-exchange;v=b3 +X-Content-Type-Options: nosniff
diff --git a/content/test/gpu/gpu_tests/test_expectations/pixel_expectations.txt b/content/test/gpu/gpu_tests/test_expectations/pixel_expectations.txt index 15ca74b7..608c3ba 100644 --- a/content/test/gpu/gpu_tests/test_expectations/pixel_expectations.txt +++ b/content/test/gpu/gpu_tests/test_expectations/pixel_expectations.txt
@@ -453,6 +453,7 @@ # Flakily crashes on Lacros-like Linux configuration. crbug.com/1209344 [ linux display-server-wayland intel skia-renderer-gl ] Pixel_Video_Context_Loss_VP9 [ RetryOnFailure ] crbug.com/1209344 [ linux display-server-wayland intel skia-renderer-gl ] Pixel_Video_MP4 [ RetryOnFailure ] +crbug.com/1271184 [ linux display-server-wayland intel skia-renderer-gl ] Pixel_Video_Context_Loss_MP4 [ RetryOnFailure ] # WebGPU pixel tests fail on Win10+SkiaRenderer+Dawn. crbug.com/1213920 [ win10 skia-renderer-dawn ] Pixel_WebGPU* [ Failure ]
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 bb7b81d9..d204178 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
@@ -802,6 +802,7 @@ # Failing on chromeos-amd64-generic-rel. crbug.com/1232446 [ chromeos chromeos-board-amd64-generic ] conformance/rendering/gl-scissor-test.html [ Failure ] +crbug.com/1271227 [ chromeos chromeos-board-amd64-generic ] conformance/attribs/gl-bindAttribLocation-aliasing.html [ RetryOnFailure ] ###########################
diff --git a/gpu/ipc/common/gpu_watchdog_timeout.h b/gpu/ipc/common/gpu_watchdog_timeout.h index 01a80fa0..bd29561 100644 --- a/gpu/ipc/common/gpu_watchdog_timeout.h +++ b/gpu/ipc/common/gpu_watchdog_timeout.h
@@ -17,7 +17,13 @@ #if defined(CYGPROFILE_INSTRUMENTATION) constexpr base::TimeDelta kGpuWatchdogTimeout = base::Seconds(30); #elif defined(OS_MAC) +#if defined(ADDRESS_SANITIZER) +// Use a longer timeout because of slower execution time leading to +// intermittent flakes. http://crbug.com/1270755 +constexpr base::TimeDelta kGpuWatchdogTimeout = base::Seconds(50); +#else constexpr base::TimeDelta kGpuWatchdogTimeout = base::Seconds(25); +#endif #elif defined(OS_WIN) constexpr base::TimeDelta kGpuWatchdogTimeout = base::Seconds(30); #else
diff --git a/infra/config/generated/luci/cr-buildbucket.cfg b/infra/config/generated/luci/cr-buildbucket.cfg index e6e736a2..3bb4188 100644 --- a/infra/config/generated/luci/cr-buildbucket.cfg +++ b/infra/config/generated/luci/cr-buildbucket.cfg
@@ -76345,7 +76345,7 @@ execution_timeout_secs: 14400 expiration_secs: 7200 grace_period { - seconds: 120 + seconds: 180 } caches { name: "win_toolchain" @@ -78127,6 +78127,10 @@ value: 100 } experiments { + key: "luci.recipes.use_python3" + value: 100 + } + experiments { key: "luci.use_realms" value: 100 }
diff --git a/infra/config/generated/luci/luci-milo.cfg b/infra/config/generated/luci/luci-milo.cfg index cfdd067..f05e4b09 100644 --- a/infra/config/generated/luci/luci-milo.cfg +++ b/infra/config/generated/luci/luci-milo.cfg
@@ -1196,11 +1196,6 @@ short_name: "P" } builders { - name: "buildbucket/luci.chromium.ci/android-marshmallow-x86-rel" - category: "chromium.android|builder_tester|x86" - short_name: "M" - } - builders { name: "buildbucket/luci.chromium.ci/android-marshmallow-arm64-rel" category: "chromium.android|on_cq" short_name: "M" @@ -1216,6 +1211,11 @@ short_name: "cst" } builders { + name: "buildbucket/luci.chromium.ci/android-marshmallow-x86-rel" + category: "chromium.android|on_cq|x86" + short_name: "M" + } + builders { name: "buildbucket/luci.chromium.ci/Linux TSan Builder" category: "chromium.memory|linux|TSan v2" short_name: "bld" @@ -3255,11 +3255,6 @@ short_name: "11" } builders { - name: "buildbucket/luci.chromium.ci/android-marshmallow-x86-rel" - category: "builder_tester|x86" - short_name: "M" - } - builders { name: "buildbucket/luci.chromium.ci/android-marshmallow-x86-rel-non-cq" category: "builder_tester|x86" short_name: "M_non-cq" @@ -3284,6 +3279,11 @@ category: "on_cq" short_name: "cst" } + builders { + name: "buildbucket/luci.chromium.ci/android-marshmallow-x86-rel" + category: "on_cq|x86" + short_name: "M" + } header { oncalls { name: "Chromium"
diff --git a/infra/config/generated/luci/luci-notify.cfg b/infra/config/generated/luci/luci-notify.cfg index 85e162e..aa245cce 100644 --- a/infra/config/generated/luci/luci-notify.cfg +++ b/infra/config/generated/luci/luci-notify.cfg
@@ -2173,6 +2173,25 @@ } notifiers { notifications { + on_occurrence: FAILURE + failed_step_regexp: "\\b(bot_update|compile|gclient runhooks|runhooks|update|\\w*nocompile_test)\\b" + email { + rotation_urls: "https://chrome-ops-rotation-proxy.appspot.com/current/oncallator:chrome-build-sheriff" + } + template: "tree_closure_email_template" + } + builders { + bucket: "ci" + name: "android-11-x86-rel" + repository: "https://chromium.googlesource.com/chromium/src" + } + tree_closers { + tree_status_host: "chromium-status.appspot.com" + failed_step_regexp: "\\b(bot_update|compile|gclient runhooks|runhooks|update|\\w*nocompile_test)\\b" + } +} +notifiers { + notifications { on_new_status: FAILURE email { recipients: "clank-build-core+androidxfailures@google.com" @@ -2495,6 +2514,25 @@ } builders { bucket: "ci" + name: "android-marshmallow-x86-rel" + repository: "https://chromium.googlesource.com/chromium/src" + } + tree_closers { + tree_status_host: "chromium-status.appspot.com" + failed_step_regexp: "\\b(bot_update|compile|gclient runhooks|runhooks|update|\\w*nocompile_test)\\b" + } +} +notifiers { + notifications { + on_occurrence: FAILURE + failed_step_regexp: "\\b(bot_update|compile|gclient runhooks|runhooks|update|\\w*nocompile_test)\\b" + email { + rotation_urls: "https://chrome-ops-rotation-proxy.appspot.com/current/oncallator:chrome-build-sheriff" + } + template: "tree_closure_email_template" + } + builders { + bucket: "ci" name: "android-pie-arm64-rel" repository: "https://chromium.googlesource.com/chromium/src" } @@ -3520,7 +3558,7 @@ on_occurrence: FAILURE on_occurrence: INFRA_FAILURE email { - recipients: "guterman@google.com" + recipients: "chrome-browser-infra-team@google.com" } } builders {
diff --git a/infra/config/generated/luci/luci-scheduler.cfg b/infra/config/generated/luci/luci-scheduler.cfg index bcdec48..55d76d5 100644 --- a/infra/config/generated/luci/luci-scheduler.cfg +++ b/infra/config/generated/luci/luci-scheduler.cfg
@@ -6383,7 +6383,7 @@ job { id: "rts-model-packager" realm: "ci" - schedule: "0 7 * * *" + schedule: "0 9 * * *" acl_sets: "ci" buildbucket { server: "cr-buildbucket.appspot.com"
diff --git a/infra/config/lib/try.star b/infra/config/lib/try.star index b1c89e9..f83a765 100644 --- a/infra/config/lib/try.star +++ b/infra/config/lib/try.star
@@ -569,6 +569,7 @@ compilator_name, compilator_os, compilator_goma_jobs = None, + compilator_grace_period = defaults.get_value("grace_period", None), compilator_builderless = not settings.is_main, orchestrator_builderless = not settings.is_main, **common_kwargs): @@ -625,6 +626,7 @@ }, os = compilator_os, description_html = compilator_description, + grace_period = compilator_grace_period, **common_kwargs ) return orchestrator_builder, compilator_builder
diff --git a/infra/config/recipes.star b/infra/config/recipes.star index ff9b82ee..2434033f 100644 --- a/infra/config/recipes.star +++ b/infra/config/recipes.star
@@ -242,6 +242,7 @@ build_recipe( name = "recipe:tricium_oilpan", + use_python3 = True, ) build_recipe(
diff --git a/infra/config/subprojects/chromium/ci.star b/infra/config/subprojects/chromium/ci.star index d0be9c2..caef3cd 100644 --- a/infra/config/subprojects/chromium/ci.star +++ b/infra/config/subprojects/chromium/ci.star
@@ -921,11 +921,12 @@ name = "android-marshmallow-x86-rel", branch_selector = branches.STANDARD_MILESTONE, console_view_entry = consoles.console_view_entry( - category = "builder_tester|x86", + category = "on_cq|x86", short_name = "M", ), cq_mirrors_console_view = "mirrors", main_console_view = main_console_if_on_branch(), + tree_closing = True, os = os.LINUX_BIONIC_REMOVE, ) @@ -979,6 +980,7 @@ category = "builder_tester|x86", short_name = "11", ), + tree_closing = True, os = os.LINUX_BIONIC_REMOVE, ) @@ -6666,7 +6668,7 @@ name = "rts-model-packager", builderless = False, executable = "recipe:chromium_rts/create_model", - schedule = "0 7 * * *", # at 12AM or 1AM PT (depending on DST), once a day. + schedule = "0 9 * * *", # at 1AM or 2AM PT (depending on DST), once a day. triggered_by = [], execution_timeout = 8 * time.hour, cores = None, @@ -6678,7 +6680,7 @@ luci.notifier( name = "rts-model-packager-notifier", on_occurrence = ["FAILURE", "INFRA_FAILURE"], - notify_emails = ["guterman@google.com"], + notify_emails = ["chrome-browser-infra-team@google.com"], ), ], )
diff --git a/infra/config/subprojects/chromium/try.star b/infra/config/subprojects/chromium/try.star index 9a890cf3..ce15d7e1 100644 --- a/infra/config/subprojects/chromium/try.star +++ b/infra/config/subprojects/chromium/try.star
@@ -1658,6 +1658,8 @@ compilator_goma_jobs = goma.jobs.J150, compilator_os = os.MAC_11, compilator_name = "mac11-arm64-rel-compilator", + # TODO (crbug/1271287): Revert when root issue is fixed + compilator_grace_period = 3 * time.minute, ) # NOTE: the following trybots aren't sensitive to Mac version on which
diff --git a/ios/chrome/browser/ui/content_suggestions/ntp_home_egtest.mm b/ios/chrome/browser/ui/content_suggestions/ntp_home_egtest.mm index 4e0f73a..a2051507 100644 --- a/ios/chrome/browser/ui/content_suggestions/ntp_home_egtest.mm +++ b/ios/chrome/browser/ui/content_suggestions/ntp_home_egtest.mm
@@ -486,7 +486,9 @@ // Tests that when navigating back to the NTP while having the omnibox focused // and moved up, the scroll position restored is the position before the omnibox // is selected. -- (void)testPositionRestoredWithOmniboxFocused { +// Disable the test due to waterfall failure. +// TODO(crbug.com/1243222): enable the test with fix. +- (void)DISABLED_testPositionRestoredWithOmniboxFocused { [self addMostVisitedTile]; // Add suggestions to be able to scroll on iPad.
diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/BUILD.gn b/ios/chrome/browser/ui/popup_menu/overflow_menu/BUILD.gn index 3fab0ad..68eb92a 100644 --- a/ios/chrome/browser/ui/popup_menu/overflow_menu/BUILD.gn +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/BUILD.gn
@@ -11,6 +11,7 @@ "overflow_menu_mediator.mm", ] deps = [ + ":feature_flags", ":overflow_menu_swift", "resources:overflow_menu_action_bookmark", "resources:overflow_menu_action_edit_bookmark", @@ -31,6 +32,7 @@ "resources:overflow_menu_destination_downloads", "resources:overflow_menu_destination_history", "resources:overflow_menu_destination_passwords", + "resources:overflow_menu_destination_passwords_rebrand", "resources:overflow_menu_destination_reading_list", "resources:overflow_menu_destination_recent_tabs", "resources:overflow_menu_destination_settings", @@ -99,5 +101,8 @@ "feature_flags.h", "feature_flags.mm", ] - deps = [ "//base" ] + deps = [ + "//base", + "//ios/chrome/browser/ui:feature_flags", + ] }
diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/feature_flags.h b/ios/chrome/browser/ui/popup_menu/overflow_menu/feature_flags.h index 432c321..82207559 100644 --- a/ios/chrome/browser/ui/popup_menu/overflow_menu/feature_flags.h +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/feature_flags.h
@@ -13,4 +13,7 @@ // Whether the NewOverflowMenu feature is enabled. bool IsNewOverflowMenuEnabled(); +// Whether the new Google Password Manager branding is enabled. +bool IsPasswordManagerBrandingUpdateEnabled(); + #endif // IOS_CHROME_BROWSER_UI_POPUP_MENU_OVERFLOW_MENU_FEATURE_FLAGS_H_
diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/feature_flags.mm b/ios/chrome/browser/ui/popup_menu/overflow_menu/feature_flags.mm index fef526d6..343bb2bb 100644 --- a/ios/chrome/browser/ui/popup_menu/overflow_menu/feature_flags.mm +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/feature_flags.mm
@@ -3,6 +3,7 @@ // found in the LICENSE file. #import "ios/chrome/browser/ui/popup_menu/overflow_menu/feature_flags.h" +#import "ios/chrome/browser/ui/ui_feature_flags.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -19,3 +20,12 @@ // |UISheetPresentationController|, which was introduced in iOS 15. return false; } + +bool IsPasswordManagerBrandingUpdateEnabled() { + if (IsNewOverflowMenuEnabled()) { + return base::FeatureList::IsEnabled( + kIOSEnablePasswordManagerBrandingUpdate); + } + + return false; +}
diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_mediator.mm b/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_mediator.mm index d8ae056..449e2e97 100644 --- a/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_mediator.mm +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_mediator.mm
@@ -37,6 +37,7 @@ #import "ios/chrome/browser/ui/commands/reading_list_add_command.h" #import "ios/chrome/browser/ui/commands/text_zoom_commands.h" #import "ios/chrome/browser/ui/default_promo/default_browser_utils.h" +#import "ios/chrome/browser/ui/popup_menu/overflow_menu/feature_flags.h" #import "ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_swift.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/web/font_size/font_size_tab_helper.h" @@ -314,7 +315,11 @@ [weakSelf openHistory]; }); self.passwordsDestination = CreateOverflowMenuDestination( - IDS_IOS_TOOLS_MENU_PASSWORDS, @"overflow_menu_destination_passwords", ^{ + IDS_IOS_TOOLS_MENU_PASSWORDS, + (IsPasswordManagerBrandingUpdateEnabled() + ? @"overflow_menu_destination_passwords_rebrand" + : @"overflow_menu_destination_passwords"), + ^{ [weakSelf openPasswords]; }); self.readingListDestination = CreateOverflowMenuDestination(
diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/BUILD.gn b/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/BUILD.gn index e91b6aa9..80dadaad 100644 --- a/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/BUILD.gn +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/BUILD.gn
@@ -164,6 +164,16 @@ ] } +imageset("overflow_menu_destination_passwords_rebrand") { + sources = [ + "overflow_menu_destination_passwords_rebrand.imageset/Contents.json", + "overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords@2x.png", + "overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords@3x.png", + "overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords_dark@2x.png", + "overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords_dark@3x.png", + ] +} + imageset("overflow_menu_destination_reading_list") { sources = [ "overflow_menu_destination_reading_list.imageset/Contents.json",
diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/Contents.json b/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/Contents.json new file mode 100644 index 0000000..0ae0f09 --- /dev/null +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/Contents.json
@@ -0,0 +1,40 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "overflow_menu_destination_passwords@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "overflow_menu_destination_passwords@3x.png", + "scale" : "3x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "filename" : "overflow_menu_destination_passwords_dark@2x.png", + "scale" : "2x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "filename" : "overflow_menu_destination_passwords_dark@3x.png", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +}
diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords@2x.png b/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords@2x.png new file mode 100644 index 0000000..dd50bfb9 --- /dev/null +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords@2x.png Binary files differ
diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords@3x.png b/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords@3x.png new file mode 100644 index 0000000..a83749d7af --- /dev/null +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords@3x.png Binary files differ
diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords_dark@2x.png b/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords_dark@2x.png new file mode 100644 index 0000000..6e9f521 --- /dev/null +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords_dark@2x.png Binary files differ
diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords_dark@3x.png b/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords_dark@3x.png new file mode 100644 index 0000000..8923b51 --- /dev/null +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/resources/overflow_menu_destination_passwords_rebrand.imageset/overflow_menu_destination_passwords_dark@3x.png Binary files differ
diff --git a/ios/web_view/shell/BUILD.gn b/ios/web_view/shell/BUILD.gn index 90e8d10..582ada03 100644 --- a/ios/web_view/shell/BUILD.gn +++ b/ios/web_view/shell/BUILD.gn
@@ -33,11 +33,6 @@ # Path to an entitlements file used in ios_web_view_shell. Can be overridden # to provide an alternative. ios_web_view_shell_entitlements_path = "//build/config/ios/entitlements.plist" - - # Controls whether WebView shell links with MaterialComponents.framework or - # gets the implementation from its downstream provider. Ignored if - # MaterialComponents is not build as a framework. - ios_web_view_shell_links_with_material_components_framework = true } ios_app_bundle("ios_web_view_shell") { @@ -51,17 +46,10 @@ entitlements_path = ios_web_view_shell_entitlements_path bundle_identifier = ios_web_view_shell_bundle_identifier - if (ios_web_view_shell_links_with_material_components_framework) { - deps += [ - "//ios/third_party/material_components_ios:material_components_ios+bundle", - "//ios/third_party/material_components_ios:material_components_ios+link", - ] - } else { - assert_no_deps = [ - "//ios/third_party/material_components_ios:material_components_ios+bundle", - "//ios/third_party/material_components_ios:material_components_ios+link", - ] - } + assert_no_deps = [ + "//ios/third_party/material_components_ios:material_components_ios+bundle", + "//ios/third_party/material_components_ios:material_components_ios+link", + ] configs += [ "//build/config/compiler:enable_arc" ] }
diff --git a/net/cookies/cookie_partition_key.cc b/net/cookies/cookie_partition_key.cc index 2675051..3ef2e39 100644 --- a/net/cookies/cookie_partition_key.cc +++ b/net/cookies/cookie_partition_key.cc
@@ -53,19 +53,11 @@ out = kEmptyCookiePartitionKey; return true; } - if (!base::FeatureList::IsEnabled(features::kPartitionedCookies)) + if (!in->IsSerializeable()) return false; - - // We should not try to serialize a partition key created by a renderer. - DCHECK(!in->from_script_); - - if (in->site_.GetURL().SchemeIsFile()) { - out = in->site_.SerializeFileSiteWithHost(); - return true; - } - if (in->site_.opaque()) - return false; - out = in->site_.Serialize(); + out = in->site_.GetURL().SchemeIsFile() + ? in->site_.SerializeFileSiteWithHost() + : in->site_.Serialize(); return true; } @@ -99,4 +91,12 @@ return absl::make_optional(net::CookiePartitionKey(top_frame_site.value())); } +bool CookiePartitionKey::IsSerializeable() const { + if (!base::FeatureList::IsEnabled(features::kPartitionedCookies)) + return false; + // We should not try to serialize a partition key created by a renderer. + DCHECK(!from_script_); + return !site_.opaque(); +} + } // namespace net
diff --git a/net/cookies/cookie_partition_key.h b/net/cookies/cookie_partition_key.h index 5beecbb..6b82bdf 100644 --- a/net/cookies/cookie_partition_key.h +++ b/net/cookies/cookie_partition_key.h
@@ -90,6 +90,10 @@ bool from_script() const { return from_script_; } + // Returns true if the current partition key can be serialized to a string. + // Cookie partition keys whose internal site is opaque cannot be serialized. + bool IsSerializeable() const; + private: explicit CookiePartitionKey(const SchemefulSite& site); explicit CookiePartitionKey(const GURL& url);
diff --git a/net/cookies/cookie_partition_key_unittest.cc b/net/cookies/cookie_partition_key_unittest.cc index cd0a88d..b3215de 100644 --- a/net/cookies/cookie_partition_key_unittest.cc +++ b/net/cookies/cookie_partition_key_unittest.cc
@@ -141,6 +141,13 @@ EXPECT_TRUE(key->site().opaque()); } +TEST_P(CookiePartitionKeyTest, IsSerializeable) { + EXPECT_FALSE(CookiePartitionKey::FromURLForTesting(GURL()).IsSerializeable()); + EXPECT_EQ(PartitionedCookiesEnabled(), CookiePartitionKey::FromURLForTesting( + GURL("https://www.example.com")) + .IsSerializeable()); +} + } // namespace net #endif // NET_COOKIES_COOKIE_PARTITION_KEY_UNITTEST_H_
diff --git a/pdf/pdfium/pdfium_engine_unittest.cc b/pdf/pdfium/pdfium_engine_unittest.cc index ef5cdc3..78f2699 100644 --- a/pdf/pdfium/pdfium_engine_unittest.cc +++ b/pdf/pdfium/pdfium_engine_unittest.cc
@@ -16,6 +16,7 @@ #include "base/test/mock_callback.h" #include "base/test/scoped_feature_list.h" #include "base/time/time.h" +#include "build/build_config.h" #include "pdf/document_attachment_info.h" #include "pdf/document_layout.h" #include "pdf/document_metadata.h" @@ -652,6 +653,45 @@ EXPECT_TRUE(engine->HandleInputEvent(raw_key_down_event)); } +TEST_F(PDFiumEngineTest, SelectText) { + NiceMock<MockTestClient> client; + std::unique_ptr<PDFiumEngine> engine = + InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf")); + ASSERT_TRUE(engine); + + EXPECT_THAT(engine->GetSelectedText(), IsEmpty()); + + engine->SelectAll(); +#if defined(OS_WIN) + // TODO(crbug.com/1269974): Make line endings more consistent. + constexpr char kExpectedText[] = + "Hello, world!\r\nGoodbye, world!\nHello, world!\r\nGoodbye, world!"; +#else + constexpr char kExpectedText[] = + "Hello, world!\nGoodbye, world!\nHello, world!\nGoodbye, world!"; +#endif + EXPECT_EQ(kExpectedText, engine->GetSelectedText()); +} + +TEST_F(PDFiumEngineTest, SelectCroppedText) { + NiceMock<MockTestClient> client; + std::unique_ptr<PDFiumEngine> engine = + InitializeEngine(&client, FILE_PATH_LITERAL("hello_world_cropped.pdf")); + ASSERT_TRUE(engine); + + EXPECT_THAT(engine->GetSelectedText(), IsEmpty()); + + engine->SelectAll(); + // TODO(crbug.com/791426): This is incorrect, as parts of the text is outside + // the crop box. +#if defined(OS_WIN) + constexpr char kExpectedText[] = "Hello, world!\r\nGoodbye, world!"; +#else + constexpr char kExpectedText[] = "Hello, world!\nGoodbye, world!"; +#endif + EXPECT_EQ(kExpectedText, engine->GetSelectedText()); +} + using PDFiumEngineDeathTest = PDFiumEngineTest; TEST_F(PDFiumEngineDeathTest, RequestThumbnailRedundant) {
diff --git a/pdf/test/data/hello_world_cropped.in b/pdf/test/data/hello_world_cropped.in new file mode 100644 index 0000000..cc0f0e8 --- /dev/null +++ b/pdf/test/data/hello_world_cropped.in
@@ -0,0 +1,56 @@ +{{header}} +{{object 1 0}} << + /Type /Catalog + /Pages 2 0 R +>> +endobj +{{object 2 0}} << + /Type /Pages + /CropBox [55 0 200 97] + /MediaBox [0 0 200 200] + /Count 1 + /Kids [3 0 R] +>> +endobj +{{object 3 0}} << + /Type /Page + /Parent 2 0 R + /Resources << + /Font << + /F1 4 0 R + /F2 5 0 R + >> + >> + /Contents 6 0 R +>> +endobj +{{object 4 0}} << + /Type /Font + /Subtype /Type1 + /BaseFont /Times-Roman +>> +endobj +{{object 5 0}} << + /Type /Font + /Subtype /Type1 + /BaseFont /Helvetica +>> +endobj +{{object 6 0}} << + {{streamlen}} +>> +stream +BT +20 50 Td +/F1 12 Tf +(Hello, world!) Tj +0 50 Td +/F2 16 Tf +(Goodbye, world!) Tj +ET +endstream +endobj +{{xref}} +{{trailer}} +{{startxref}} +%%EOF
diff --git a/pdf/test/data/hello_world_cropped.pdf b/pdf/test/data/hello_world_cropped.pdf new file mode 100644 index 0000000..5be1eac --- /dev/null +++ b/pdf/test/data/hello_world_cropped.pdf
@@ -0,0 +1,69 @@ +%PDF-1.7 +% ò¤ô +1 0 obj << + /Type /Catalog + /Pages 2 0 R +>> +endobj +2 0 obj << + /Type /Pages + /CropBox [55 0 200 97] + /MediaBox [0 0 200 200] + /Count 1 + /Kids [3 0 R] +>> +endobj +3 0 obj << + /Type /Page + /Parent 2 0 R + /Resources << + /Font << + /F1 4 0 R + /F2 5 0 R + >> + >> + /Contents 6 0 R +>> +endobj +4 0 obj << + /Type /Font + /Subtype /Type1 + /BaseFont /Times-Roman +>> +endobj +5 0 obj << + /Type /Font + /Subtype /Type1 + /BaseFont /Helvetica +>> +endobj +6 0 obj << + /Length 83 +>> +stream +BT +20 50 Td +/F1 12 Tf +(Hello, world!) Tj +0 50 Td +/F2 16 Tf +(Goodbye, world!) Tj +ET +endstream +endobj +xref +0 7 +0000000000 65535 f +0000000015 00000 n +0000000068 00000 n +0000000182 00000 n +0000000324 00000 n +0000000402 00000 n +0000000478 00000 n +trailer << + /Root 1 0 R + /Size 7 +>> +startxref +612 +%%EOF
diff --git a/services/metrics/public/cpp/metrics_utils.cc b/services/metrics/public/cpp/metrics_utils.cc index b231133..675dbe3a 100644 --- a/services/metrics/public/cpp/metrics_utils.cc +++ b/services/metrics/public/cpp/metrics_utils.cc
@@ -61,6 +61,8 @@ } int64_t METRICS_EXPORT GetSemanticBucketMinForDurationTiming(int64_t sample) { + if (sample == 0) + return 0; DCHECK(sample > 0); const int64_t kMillisecondsPerMinute = 60 * 1000; const int64_t kMillisecondsPerTenMinutes = 10 * kMillisecondsPerMinute;
diff --git a/testing/buildbot/chromium.android.fyi.json b/testing/buildbot/chromium.android.fyi.json index 4c46614..a7fa19f4 100644 --- a/testing/buildbot/chromium.android.fyi.json +++ b/testing/buildbot/chromium.android.fyi.json
@@ -1637,7 +1637,8 @@ "args": [ "--gs-results-bucket=chromium-result-details", "--recover-devices", - "--avd-config=../../tools/android/avd/proto/generic_android31.textpb" + "--avd-config=../../tools/android/avd/proto/generic_android31.textpb", + "--gtest_filter=-FieldFormatterTest.DifferentLocales" ], "merge": { "args": [ @@ -3674,7 +3675,8 @@ "args": [ "--gs-results-bucket=chromium-result-details", "--recover-devices", - "--avd-config=../../tools/android/avd/proto/generic_android31.textpb" + "--avd-config=../../tools/android/avd/proto/generic_android31.textpb", + "--gtest_filter=-MimeUtilTest.ExtensionTest" ], "merge": { "args": [ @@ -3885,7 +3887,8 @@ "args": [ "--gs-results-bucket=chromium-result-details", "--recover-devices", - "--avd-config=../../tools/android/avd/proto/generic_android31.textpb" + "--avd-config=../../tools/android/avd/proto/generic_android31.textpb", + "--gtest_filter=-PacLibraryTest.ActualPacMyIpAddress*" ], "merge": { "args": [ @@ -4726,7 +4729,8 @@ "args": [ "--gs-results-bucket=chromium-result-details", "--recover-devices", - "--avd-config=../../tools/android/avd/proto/generic_android31.textpb" + "--avd-config=../../tools/android/avd/proto/generic_android31.textpb", + "--gtest_filter=-DownloadBrowserTest.OverrideDownloadDirectory" ], "merge": { "args": [ @@ -5787,7 +5791,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M96", - "revision": "version:96.0.4664.54" + "revision": "version:96.0.4664.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -6051,7 +6055,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M96", - "revision": "version:96.0.4664.54" + "revision": "version:96.0.4664.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}",
diff --git a/testing/buildbot/chromium.android.json b/testing/buildbot/chromium.android.json index 5721a43c..17f5657 100644 --- a/testing/buildbot/chromium.android.json +++ b/testing/buildbot/chromium.android.json
@@ -43662,7 +43662,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M96", - "revision": "version:96.0.4664.54" + "revision": "version:96.0.4664.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -43926,7 +43926,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M96", - "revision": "version:96.0.4664.54" + "revision": "version:96.0.4664.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -44265,7 +44265,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M96", - "revision": "version:96.0.4664.54" + "revision": "version:96.0.4664.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -44529,7 +44529,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M96", - "revision": "version:96.0.4664.54" + "revision": "version:96.0.4664.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -44868,7 +44868,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M96", - "revision": "version:96.0.4664.54" + "revision": "version:96.0.4664.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -45132,7 +45132,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M96", - "revision": "version:96.0.4664.54" + "revision": "version:96.0.4664.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}",
diff --git a/testing/buildbot/chromium.dawn.json b/testing/buildbot/chromium.dawn.json index e7e42407..b1c29ef4 100644 --- a/testing/buildbot/chromium.dawn.json +++ b/testing/buildbot/chromium.dawn.json
@@ -1586,183 +1586,23 @@ ] }, "Dawn Mac x64 Experimental Release (Intel)": { - "gtest_tests": [ - { - "args": [ - "--use-gpu-in-tests", - "--test-launcher-retry-limit=0", - "--exclusive-device-type-preference=discrete,integrated" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "cpu": "x86-64", - "display_attached": "1", - "gpu": "8086:3e9b", - "os": "Mac-11.5.2" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "dawn_end2end_tests", - "test_id_prefix": "ninja://third_party/dawn/src/tests:dawn_end2end_tests/" - }, - { - "args": [ - "--enable-toggles=skip_validation", - "--use-gpu-in-tests", - "--test-launcher-retry-limit=0", - "--exclusive-device-type-preference=discrete,integrated" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "dawn_end2end_skip_validation_tests", - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "cpu": "x86-64", - "display_attached": "1", - "gpu": "8086:3e9b", - "os": "Mac-11.5.2" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "dawn_end2end_tests", - "test_id_prefix": "ninja://third_party/dawn/src/tests:dawn_end2end_tests/" - }, - { - "args": [ - "--enable-backend-validation", - "--use-gpu-in-tests", - "--test-launcher-retry-limit=0", - "--exclusive-device-type-preference=discrete,integrated" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "dawn_end2end_validation_layers_tests", - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "cpu": "x86-64", - "display_attached": "1", - "gpu": "8086:3e9b", - "os": "Mac-11.5.2" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "dawn_end2end_tests", - "test_id_prefix": "ninja://third_party/dawn/src/tests:dawn_end2end_tests/" - }, - { - "args": [ - "--use-wire", - "--use-gpu-in-tests", - "--test-launcher-retry-limit=0", - "--exclusive-device-type-preference=discrete,integrated" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "dawn_end2end_wire_tests", - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "cpu": "x86-64", - "display_attached": "1", - "gpu": "8086:3e9b", - "os": "Mac-11.5.2" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "dawn_end2end_tests", - "test_id_prefix": "ninja://third_party/dawn/src/tests:dawn_end2end_tests/" - }, - { - "args": [ - "--use-cmd-decoder=validating", - "--use-gpu-in-tests" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "gl_tests_validating", - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "cpu": "x86-64", - "display_attached": "1", - "gpu": "8086:3e9b", - "os": "Mac-11.5.2" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "gl_tests", - "test_id_prefix": "ninja://gpu:gl_tests/" - }, - { - "args": [ - "--use-gpu-in-tests" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "cpu": "x86-64", - "display_attached": "1", - "gpu": "8086:3e9b", - "os": "Mac-11.5.2" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "gl_unittests", - "test_id_prefix": "ninja://ui/gl:gl_unittests/" - } - ], "isolated_scripts": [ { "args": [ - "--override-steps=1", - "--gtest-benchmark-name=dawn_perf_tests", - "-v" + "noop_sleep", + "--show-stdout", + "--browser=release", + "--passthrough", + "-v", + "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc" ], - "isolate_name": "dawn_perf_tests", + "isolate_name": "telemetry_gpu_integration_test", "merge": { - "args": [ - "--smoke-test-mode" - ], - "script": "//tools/perf/process_perf_results.py" + "args": [], + "script": "//testing/merge_scripts/standard_isolated_script_merge.py" }, - "name": "dawn_perf_tests", + "name": "noop_sleep_tests", + "should_retry_with_patch": false, "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -1774,76 +1614,10 @@ } ], "expiration": 21600, + "idempotent": false, "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" }, - "test_id_prefix": "ninja://third_party/dawn/src/tests:dawn_perf_tests/" - }, - { - "args": [ - "--initialize-webgpu-adapter-at-startup-timeout-ms=60000", - "--flag-specific=webgpu", - "--platform=mac-mac11" - ], - "isolate_name": "webgpu_blink_web_tests", - "merge": { - "args": [ - "--verbose" - ], - "script": "//third_party/blink/tools/merge_web_test_results.py" - }, - "name": "webgpu_blink_web_tests", - "resultdb": { - "enable": true - }, - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "cpu": "x86-64", - "display_attached": "1", - "gpu": "8086:3e9b", - "os": "Mac-11.5.2" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 4 - }, - "test_id_prefix": "ninja://:webgpu_blink_web_tests/" - }, - { - "args": [ - "--initialize-webgpu-adapter-at-startup-timeout-ms=60000", - "--flag-specific=webgpu-with-backend-validation", - "--time-out-ms=30000", - "--platform=mac-mac11" - ], - "isolate_name": "webgpu_blink_web_tests", - "merge": { - "args": [ - "--verbose" - ], - "script": "//third_party/blink/tools/merge_web_test_results.py" - }, - "name": "webgpu_blink_web_tests_with_backend_validation", - "resultdb": { - "enable": true - }, - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "cpu": "x86-64", - "display_attached": "1", - "gpu": "8086:3e9b", - "os": "Mac-11.5.2" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 4 - }, - "test_id_prefix": "ninja://:webgpu_blink_web_tests/" + "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" } ] },
diff --git a/testing/buildbot/chromium.gpu.fyi.json b/testing/buildbot/chromium.gpu.fyi.json index 4e54839..6ba5698 100644 --- a/testing/buildbot/chromium.gpu.fyi.json +++ b/testing/buildbot/chromium.gpu.fyi.json
@@ -28094,377 +28094,10 @@ ] }, "Win10 FYI x64 Exp Release (Intel HD 630)": { - "gtest_tests": [ - { - "args": [ - "angle_end2end_tests", - "--gtest_filter=-*Vulkan_SwiftShader*", - "--bot-mode", - "--max-processes=1" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test": "angle_end2end_tests", - "test_id_prefix": "ninja://third_party/angle/src/tests:angle_end2end_tests/", - "use_isolated_scripts_api": true - }, - { - "args": [ - "angle_unittests" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "angle_unittests", - "test_id_prefix": "ninja://third_party/angle/src/tests:angle_unittests/", - "use_isolated_scripts_api": true - }, - { - "args": [ - "angle_white_box_tests", - "--bot-mode", - "--max-processes=1" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "angle_white_box_tests", - "test_id_prefix": "ninja://third_party/angle/src/tests:angle_white_box_tests/", - "use_isolated_scripts_api": true - }, - { - "args": [ - "--enable-gpu", - "--test-launcher-bot-mode", - "--test-launcher-jobs=1", - "--gtest_filter=TabCaptureApiPixelTest.EndToEnd*" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "tab_capture_end2end_tests", - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "browser_tests", - "test_id_prefix": "ninja://chrome/test:browser_tests/" - }, - { - "args": [ - "--use-cmd-decoder=passthrough", - "--use-gl=angle", - "--use-gpu-in-tests" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "gl_tests_passthrough", - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test": "gl_tests", - "test_id_prefix": "ninja://gpu:gl_tests/" - }, - { - "args": [ - "--use-gpu-in-tests" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "gl_unittests", - "test_id_prefix": "ninja://ui/gl:gl_unittests/" - }, - { - "args": [ - "--use-gpu-in-tests" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "gles2_conform_test", - "test_id_prefix": "ninja://gpu/gles2_conform_support:gles2_conform_test/" - }, - { - "args": [ - "--use-gpu-in-tests", - "--use-angle=d3d9" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "gles2_conform_d3d9_test", - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "gles2_conform_test", - "test_id_prefix": "ninja://gpu/gles2_conform_support:gles2_conform_test/" - }, - { - "args": [ - "--use-gpu-in-tests", - "--use-angle=gl", - "--disable-gpu-sandbox" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "gles2_conform_gl_test", - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "gles2_conform_test", - "test_id_prefix": "ninja://gpu/gles2_conform_support:gles2_conform_test/" - }, - { - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "gpu_unittests", - "test_id_prefix": "ninja://gpu:gpu_unittests/" - }, - { - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "swiftshader_unittests", - "test_id_prefix": "ninja://third_party/swiftshader/tests/GLESUnitTests:swiftshader_unittests/" - }, - { - "args": [ - "--use-gpu-in-tests" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "vulkan_tests", - "test_id_prefix": "ninja://gpu/vulkan:vulkan_tests/" - }, - { - "args": [ - "--ignore-runtime-requirements=*" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "xr_browser_tests", - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "xr_browser_tests", - "test_id_prefix": "ninja://chrome/test:xr_browser_tests/" - } - ], "isolated_scripts": [ { "args": [ - "context_lost", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=passthrough --use-gl=angle" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "context_lost_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "depth_capture", + "noop_sleep", "--show-stdout", "--browser=release_x64", "--passthrough", @@ -28476,20 +28109,16 @@ "args": [], "script": "//testing/merge_scripts/standard_isolated_script_merge.py" }, - "name": "depth_capture_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, + "name": "noop_sleep_tests", "should_retry_with_patch": false, "swarming": { "can_use_on_swarming_builders": true, "containment_type": "AUTO", "dimension_sets": [ { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", + "gpu": "8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" + "pool": "chromium.tests.gpu" } ], "expiration": 21600, @@ -28497,977 +28126,14 @@ "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" }, "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "gpu_process", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "gpu_process_launch_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "hardware_accelerated_feature", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "hardware_accelerated_feature_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "info_collection", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu", - "--expected-vendor-id", - "8086", - "--expected-device-id", - "3e92", - "--expected-device-id", - "5912" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "info_collection_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "maps", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=passthrough --use-gl=angle", - "--dont-restore-color-profile-after-test", - "--test-machine-name", - "${buildername}", - "--git-revision=${got_revision}" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "maps_pixel_passthrough_test", - "precommit_args": [ - "--gerrit-issue=${patch_issue}", - "--gerrit-patchset=${patch_set}", - "--buildbucket-id=${buildbucket_build_id}" - ], - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chrome-gpu-gold@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "mediapipe", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_higher_performance_gpu --use-cmd-decoder=passthrough --use-gl=angle" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "mediapipe_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "pixel", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=passthrough --use-gl=angle", - "--dont-restore-color-profile-after-test", - "--test-machine-name", - "${buildername}", - "--git-revision=${got_revision}" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "pixel_skia_gold_passthrough_test", - "precommit_args": [ - "--gerrit-issue=${patch_issue}", - "--gerrit-patchset=${patch_set}", - "--buildbucket-id=${buildbucket_build_id}" - ], - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chrome-gpu-gold@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "power", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "power_measurement_test", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "../../tools/perf/run_benchmark", - "--benchmarks=rendering.desktop", - "--browser=release_x64" - ], - "isolate_name": "rendering_representative_perf_tests", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "rendering_representative_perf_tests", - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:rendering_representative_perf_tests/" - }, - { - "args": [ - "screenshot_sync", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=passthrough --use-gl=angle", - "--dont-restore-color-profile-after-test" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "screenshot_sync_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "trace_test", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "trace_test", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "webcodecs", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webcodecs_tests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=d3d11 --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--webgl-conformance-version=2.0.1", - "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl2_conformance_tests_output.json" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl2_conformance_d3d11_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 20 - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=d3d11 --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_d3d11_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=d3d9 --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_d3d9_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=gl --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_gl_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-angle=vulkan --use-cmd-decoder=passthrough --force_high_performance_gpu" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_vulkan_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141", - "os": "Windows-10", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" } ] }, "Win10 FYI x64 Exp Release (NVIDIA)": { - "gtest_tests": [ - { - "args": [ - "angle_end2end_tests", - "--gtest_filter=-*Vulkan_SwiftShader*", - "--bot-mode" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test": "angle_end2end_tests", - "test_id_prefix": "ninja://third_party/angle/src/tests:angle_end2end_tests/", - "use_isolated_scripts_api": true - }, - { - "args": [ - "angle_unittests" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "angle_unittests", - "test_id_prefix": "ninja://third_party/angle/src/tests:angle_unittests/", - "use_isolated_scripts_api": true - }, - { - "args": [ - "angle_white_box_tests", - "--bot-mode" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "angle_white_box_tests", - "test_id_prefix": "ninja://third_party/angle/src/tests:angle_white_box_tests/", - "use_isolated_scripts_api": true - }, - { - "args": [ - "--enable-gpu", - "--test-launcher-bot-mode", - "--test-launcher-jobs=1", - "--gtest_filter=TabCaptureApiPixelTest.EndToEnd*" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "tab_capture_end2end_tests", - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "browser_tests", - "test_id_prefix": "ninja://chrome/test:browser_tests/" - }, - { - "args": [ - "--use-cmd-decoder=passthrough", - "--use-gl=angle", - "--use-gpu-in-tests" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "gl_tests_passthrough", - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test": "gl_tests", - "test_id_prefix": "ninja://gpu:gl_tests/" - }, - { - "args": [ - "--use-gpu-in-tests" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "gl_unittests", - "test_id_prefix": "ninja://ui/gl:gl_unittests/" - }, - { - "args": [ - "--use-gpu-in-tests" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "gles2_conform_test", - "test_id_prefix": "ninja://gpu/gles2_conform_support:gles2_conform_test/" - }, - { - "args": [ - "--use-gpu-in-tests", - "--use-angle=d3d9" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "gles2_conform_d3d9_test", - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "gles2_conform_test", - "test_id_prefix": "ninja://gpu/gles2_conform_support:gles2_conform_test/" - }, - { - "args": [ - "--use-gpu-in-tests", - "--use-angle=gl", - "--disable-gpu-sandbox" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "gles2_conform_gl_test", - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "gles2_conform_test", - "test_id_prefix": "ninja://gpu/gles2_conform_support:gles2_conform_test/" - }, - { - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "gpu_unittests", - "test_id_prefix": "ninja://gpu:gpu_unittests/" - }, - { - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "swiftshader_unittests", - "test_id_prefix": "ninja://third_party/swiftshader/tests/GLESUnitTests:swiftshader_unittests/" - }, - { - "args": [ - "--use-gpu-in-tests" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "vulkan_tests", - "test_id_prefix": "ninja://gpu/vulkan:vulkan_tests/" - }, - { - "args": [ - "--ignore-runtime-requirements=*" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "xr_browser_tests", - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "xr_browser_tests", - "test_id_prefix": "ninja://chrome/test:xr_browser_tests/" - } - ], "isolated_scripts": [ { "args": [ - "context_lost", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=passthrough --use-gl=angle" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "context_lost_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "depth_capture", + "noop_sleep", "--show-stdout", "--browser=release_x64", "--passthrough", @@ -29479,11 +28145,7 @@ "args": [], "script": "//testing/merge_scripts/standard_isolated_script_merge.py" }, - "name": "depth_capture_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, + "name": "noop_sleep_tests", "should_retry_with_patch": false, "swarming": { "can_use_on_swarming_builders": true, @@ -29492,7 +28154,7 @@ { "gpu": "10de:1cb3-27.21.14.5148", "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" + "pool": "chromium.tests.gpu" } ], "expiration": 21600, @@ -29500,567 +28162,6 @@ "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" }, "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "gpu_process", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "gpu_process_launch_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "hardware_accelerated_feature", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "hardware_accelerated_feature_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "info_collection", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --force_high_performance_gpu", - "--expected-vendor-id", - "10de", - "--expected-device-id", - "1cb3" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "info_collection_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "maps", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=passthrough --use-gl=angle", - "--dont-restore-color-profile-after-test", - "--test-machine-name", - "${buildername}", - "--git-revision=${got_revision}" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "maps_pixel_passthrough_test", - "precommit_args": [ - "--gerrit-issue=${patch_issue}", - "--gerrit-patchset=${patch_set}", - "--buildbucket-id=${buildbucket_build_id}" - ], - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chrome-gpu-gold@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "--gtest-benchmark-name=passthrough_command_buffer_perftests", - "-v", - "--use-cmd-decoder=passthrough", - "--use-angle=gl-null", - "--fast-run" - ], - "isolate_name": "command_buffer_perftests", - "merge": { - "args": [ - "--smoke-test-mode" - ], - "script": "//tools/perf/process_perf_results.py" - }, - "name": "passthrough_command_buffer_perftests", - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://gpu:command_buffer_perftests/" - }, - { - "args": [ - "pixel", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=passthrough --use-gl=angle", - "--dont-restore-color-profile-after-test", - "--test-machine-name", - "${buildername}", - "--git-revision=${got_revision}" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "pixel_skia_gold_passthrough_test", - "precommit_args": [ - "--gerrit-issue=${patch_issue}", - "--gerrit-patchset=${patch_set}", - "--buildbucket-id=${buildbucket_build_id}" - ], - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chrome-gpu-gold@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "../../tools/perf/run_benchmark", - "--benchmarks=rendering.desktop", - "--browser=release_x64" - ], - "isolate_name": "rendering_representative_perf_tests", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "rendering_representative_perf_tests", - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:rendering_representative_perf_tests/" - }, - { - "args": [ - "screenshot_sync", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-cmd-decoder=passthrough --use-gl=angle", - "--dont-restore-color-profile-after-test" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "screenshot_sync_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "trace_test", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "trace_test", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=d3d11 --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--webgl-conformance-version=2.0.1", - "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl2_conformance_tests_output.json" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl2_conformance_d3d11_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 20 - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=d3d11 --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_d3d11_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=d3d9 --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_d3d9_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --enable-unsafe-fast-js-calls --enable-fake-no-alloc-direct-call-for-testing --use-gl=angle --use-cmd-decoder=passthrough --force_high_performance_gpu" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_fast_call_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-gl=angle --use-angle=gl --use-cmd-decoder=passthrough --force_high_performance_gpu", - "--read-abbreviated-json-results-from=../../content/test/data/gpu/webgl_conformance_tests_output.json" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_gl_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" - }, - { - "args": [ - "webgl_conformance", - "--show-stdout", - "--browser=release_x64", - "--passthrough", - "-v", - "--extra-browser-args=--enable-logging=stderr --js-flags=--expose-gc --use-angle=vulkan --use-cmd-decoder=passthrough --force_high_performance_gpu" - ], - "isolate_name": "telemetry_gpu_integration_test", - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "webgl_conformance_vulkan_passthrough_tests", - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "should_retry_with_patch": false, - "swarming": { - "can_use_on_swarming_builders": true, - "containment_type": "AUTO", - "dimension_sets": [ - { - "gpu": "10de:1cb3-27.21.14.5148", - "os": "Windows-10-18363", - "pool": "chromium.tests.gpu.experimental" - } - ], - "expiration": 21600, - "idempotent": false, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/" } ] },
diff --git a/testing/buildbot/filters/fuchsia.content_browsertests.filter b/testing/buildbot/filters/fuchsia.content_browsertests.filter index 0cf7c2c..c5c71fb2 100644 --- a/testing/buildbot/filters/fuchsia.content_browsertests.filter +++ b/testing/buildbot/filters/fuchsia.content_browsertests.filter
@@ -17,7 +17,6 @@ -AudioContextManagerTest.AudioContextPlaybackTimeUkm -AutoPictureInPictureContentBrowserTest.AutoPictureInPictureTriggeredWhenFullscreen -BackForwardCacheBrowserTest.DoesNotCacheIfSpeechRecognitionIsStarted --BackForwardCacheBrowserTest.DoesNotCacheIfWebDatabase -BackForwardCacheBrowserTest.VideoSuspendAndResume -BackForwardCacheBrowserTest.WebSocketCachedIfClosed -BackForwardCacheBrowserTest.WebSocketNotCached @@ -27,19 +26,6 @@ -DataDecoderBrowserTest.DecodeImage -DataDecoderBrowserTest.DecodeImageIsolated -DataDecoderBrowserTest.LaunchIsolated --DatabaseTest.DatabaseOperations --DatabaseTest.DatabasePersistsAfterRelaunch --DatabaseTest.DeleteNonexistentRow --DatabaseTest.DeleteRecord --DatabaseTest.InsertRecord --DatabaseTest.ModificationPersistInSecondTab --DatabaseTest.ModificationsPersistAfterRendererCrash --DatabaseTest.OffTheRecordCannotReadRegularDatabase --DatabaseTest.OffTheRecordDBPersistentAcrossWindows --DatabaseTest.OffTheRecordDatabaseNotPersistent --DatabaseTest.RegularCannotReadOffTheRecordDatabase --DatabaseTest.ReloadPage --DatabaseTest.UpdateRecord -DirectSocketsTcpBrowserTest.OpenTcp_MDNS -DnsHttpsProtocolUpgradeBrowserTest.HttpsProtocolUpgrade -File/MediaTest.* @@ -111,3 +97,19 @@ -*/InterestGroupFencedFrameBrowserTest.* -InterestGroupPrivateNetworkBrowserTest.* -InterestGroupRestrictedPermissionsPolicyBrowserTest.* + +# crbug.com/1212491: WebSQL is being deprecated, these are low priority +-BackForwardCacheBrowserTest.DoesNotCacheIfWebDatabase +-DatabaseTest.DatabaseOperations +-DatabaseTest.DatabasePersistsAfterRelaunch +-DatabaseTest.DeleteNonexistentRow +-DatabaseTest.DeleteRecord +-DatabaseTest.InsertRecord +-DatabaseTest.ModificationPersistInSecondTab +-DatabaseTest.ModificationsPersistAfterRendererCrash +-DatabaseTest.OffTheRecordCannotReadRegularDatabase +-DatabaseTest.OffTheRecordDBPersistentAcrossWindows +-DatabaseTest.OffTheRecordDatabaseNotPersistent +-DatabaseTest.RegularCannotReadOffTheRecordDatabase +-DatabaseTest.ReloadPage +-DatabaseTest.UpdateRecord
diff --git a/testing/buildbot/mixins.pyl b/testing/buildbot/mixins.pyl index 51abf88e1..04a7bf70 100644 --- a/testing/buildbot/mixins.pyl +++ b/testing/buildbot/mixins.pyl
@@ -1052,9 +1052,9 @@ 'win10_intel_hd_630_experimental': { 'swarming': { 'dimensions': { - 'gpu': '8086:5912-26.20.100.7870|8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141', + 'gpu': '8086:5912-26.20.100.8141|8086:3e92-26.20.100.8141', 'os': 'Windows-10', - 'pool': 'chromium.tests.gpu.experimental', + 'pool': 'chromium.tests.gpu', }, }, }, @@ -1095,7 +1095,7 @@ 'dimensions': { 'gpu': '10de:1cb3-27.21.14.5148', 'os': 'Windows-10-18363', - 'pool': 'chromium.tests.gpu.experimental', + 'pool': 'chromium.tests.gpu', }, }, },
diff --git a/testing/buildbot/test_suite_exceptions.pyl b/testing/buildbot/test_suite_exceptions.pyl index 9699606b..28bc1fdc 100644 --- a/testing/buildbot/test_suite_exceptions.pyl +++ b/testing/buildbot/test_suite_exceptions.pyl
@@ -1116,6 +1116,12 @@ '--test-launcher-filter-file=../../testing/buildbot/filters/android.emulator_11.components_unittests.filter', ], }, + 'android-12-x64-fyi-rel': { + 'args': [ + # TODO(crbug.com/1192348): Fix the test failure + '--gtest_filter=-FieldFormatterTest.DifferentLocales', + ], + }, 'linux-blink-heap-concurrent-marking-tsan-rel': { 'swarming': { 'shards': 2, @@ -2223,6 +2229,12 @@ '--test-launcher-filter-file=../../testing/buildbot/filters/android.emulator_11.net_unittests.filter', ], }, + 'android-12-x64-fyi-rel': { + 'args': [ + # TODO(crbug.com/1191793): Fix the test failure + '--gtest_filter=-MimeUtilTest.ExtensionTest', + ], + }, 'android-cronet-x86-dbg-10-tests': { 'args': [ '--test-launcher-filter-file=../../testing/buildbot/filters/android.emulator_10.net_unittests.filter', @@ -2609,7 +2621,13 @@ 'modifications': { 'android-11-x86-rel': { 'args': [ - # TODO(crbug.com/1234824): Fix the failed tests + # TODO(crbug.com/1264654): Fix the failed tests + '--gtest_filter=-PacLibraryTest.ActualPacMyIpAddress*' + ], + }, + 'android-12-x64-fyi-rel': { + 'args': [ + # TODO(crbug.com/1264654): Fix the failed tests '--gtest_filter=-PacLibraryTest.ActualPacMyIpAddress*' ], }, @@ -3303,7 +3321,13 @@ 'modifications': { 'android-11-x86-rel': { 'args': [ - # TODO(crbug.com/1191784): Enable this test once the issue is fixed. + # TODO(crbug.com/1191784): Fix the test failure + '--gtest_filter=-DownloadBrowserTest.OverrideDownloadDirectory', + ], + }, + 'android-12-x64-fyi-rel': { + 'args': [ + # TODO(crbug.com/1191784): Fix the test failure '--gtest_filter=-DownloadBrowserTest.OverrideDownloadDirectory', ], },
diff --git a/testing/buildbot/variants.pyl b/testing/buildbot/variants.pyl index c955e1dc..fe822d6d 100644 --- a/testing/buildbot/variants.pyl +++ b/testing/buildbot/variants.pyl
@@ -387,7 +387,7 @@ { 'cipd_package': 'chromium/testing/weblayer-x86', 'location': 'weblayer_instrumentation_test_M96', - 'revision': 'version:96.0.4664.54', + 'revision': 'version:96.0.4664.56', } ], }, @@ -459,7 +459,7 @@ { 'cipd_package': 'chromium/testing/weblayer-x86', 'location': 'weblayer_instrumentation_test_M96', - 'revision': 'version:96.0.4664.54', + 'revision': 'version:96.0.4664.56', } ], }, @@ -531,7 +531,7 @@ { 'cipd_package': 'chromium/testing/weblayer-x86', 'location': 'weblayer_instrumentation_test_M96', - 'revision': 'version:96.0.4664.54', + 'revision': 'version:96.0.4664.56', } ], },
diff --git a/testing/buildbot/waterfalls.pyl b/testing/buildbot/waterfalls.pyl index 8b7c0bc..6747676 100644 --- a/testing/buildbot/waterfalls.pyl +++ b/testing/buildbot/waterfalls.pyl
@@ -2189,11 +2189,13 @@ 'browser_config': 'release', 'mixins': [ 'limited_capacity_bot', - 'mac_mini_intel_gpu_stable', + 'mac_mini_intel_gpu_experimental', ], + # Currently the experimental driver is identical to the stable + # driver. If it's upgraded, change these test_suites to be the same as + # 'Dawn Mac x64 Release (Intel)'. 'test_suites': { - 'gtest_tests': 'gpu_dawn_integration_gtests_validating', - 'isolated_scripts': 'gpu_dawn_isolated_scripts', + 'gpu_telemetry_tests': 'gpu_noop_sleep_telemetry_test', }, }, 'Dawn Mac x64 Release (AMD)': { @@ -4587,10 +4589,12 @@ 'limited_capacity_bot', 'win10_intel_hd_630_experimental', ], + # When the experimental driver is identical to the stable driver, this + # should be running the gpu_noop_sleep_telemetry_test. Otherwise, it + # should be running the same test_suites as + # 'Win10 FYI x64 Release (Intel HD 630)' 'test_suites': { - 'gtest_tests': 'gpu_fyi_win_gtests', - 'isolated_scripts': 'gpu_desktop_representative_perf_fyi_isolated_scripts', - 'gpu_telemetry_tests': 'gpu_fyi_win_intel_release_telemetry_tests', + 'gpu_telemetry_tests': 'gpu_noop_sleep_telemetry_test', }, }, 'Win10 FYI x64 Exp Release (NVIDIA)': { @@ -4605,9 +4609,7 @@ # should be running the same test_suites as # 'Win10 FYI x64 Release (NVIDIA)' 'test_suites': { - 'gtest_tests': 'gpu_fyi_win_gtests', - 'gpu_telemetry_tests': 'gpu_fyi_win_release_telemetry_tests', - 'isolated_scripts': 'gpu_fyi_win_optional_and_representative_perf_isolated_scripts', + 'gpu_telemetry_tests': 'gpu_noop_sleep_telemetry_test', }, }, 'Win10 FYI x64 Release (AMD RX 5500 XT)': {
diff --git a/testing/scripts/run_performance_tests.py b/testing/scripts/run_performance_tests.py index b687be8..00a51f9 100755 --- a/testing/scripts/run_performance_tests.py +++ b/testing/scripts/run_performance_tests.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env vpython3 +#!/usr/bin/env python # Copyright 2017 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.
diff --git a/testing/scripts/run_variations_smoke_tests.py b/testing/scripts/run_variations_smoke_tests.py index 27f2d74..3d967e7 100755 --- a/testing/scripts/run_variations_smoke_tests.py +++ b/testing/scripts/run_variations_smoke_tests.py
@@ -238,7 +238,7 @@ parser = argparse.ArgumentParser() parser.add_argument('--isolated-script-test-output', type=str) args, rest = parser.parse_known_args() - rc = _run_tests(rest) + rc = _run_tests(*rest) if args.isolated_script_test_output: with open(args.isolated_script_test_output, 'w') as f: common.record_local_script_results('run_variations_smoke_tests', f, [],
diff --git a/testing/test_env.py b/testing/test_env.py index 8a641838..95f5741 100755 --- a/testing/test_env.py +++ b/testing/test_env.py
@@ -12,7 +12,7 @@ import subprocess import sys import time -import six + # This is hardcoded to be src/ relative to this script. ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -204,12 +204,12 @@ stderr=subprocess.STDOUT) forward_signals([process]) while process.poll() is None: - sys.stdout.write(six.ensure_str(reader.read())) + sys.stdout.write(reader.read()) # This sleep is needed for signal propagation. See the # wait_with_signals() docstring. time.sleep(0.1) # Read the remaining. - sys.stdout.write(six.ensure_str(reader.read())) + sys.stdout.write(reader.read()) print('Command %r returned exit code %d' % (argv, process.returncode)) return process.returncode
diff --git a/testing/unexpected_passes_common/expectations.py b/testing/unexpected_passes_common/expectations.py index 3e40a0c..16ed224 100644 --- a/testing/unexpected_passes_common/expectations.py +++ b/testing/unexpected_passes_common/expectations.py
@@ -22,6 +22,9 @@ FINDER_DISABLE_COMMENT = 'finder:disable' FINDER_ENABLE_COMMENT = 'finder:enable' +GIT_BLAME_REGEX = re.compile( + r'^[\w\s]+\(.+(?P<date>\d\d\d\d-\d\d-\d\d)[^\)]+\)(?P<content>.*)$', + re.DOTALL) EXPECTATION_LINE_REGEX = re.compile(r'^.*\[ .* \] .* \[ \w* \].*$', re.DOTALL) @@ -100,26 +103,24 @@ num_days = datetime.timedelta(days=num_days) content = '' # `git blame` output is normally in the format: - # revision (author date time timezone lineno) line_content + # revision optional_filename (author date time timezone lineno) line_content # The --porcelain option is meant to be more machine readable, but is much - # more difficult to parse for what we need to do here. In order to be able - # to split by whitespace easily, use -e to display author email instead of - # author name, which is guaranteed to not have spaces. - cmd = ['git', 'blame', '-e', expectation_file_path] + # more difficult to parse for what we need to do here. In order to + # guarantee that the filename won't be included in the output (by default, + # it will be shown if there is content from a renamed file), pass -c to + # use the same format as `git annotate`, which is: + # revision (author date time timezone lineno)line_content + # (Note the lack of space between the ) and the content). + cmd = ['git', 'blame', '-c', expectation_file_path] with open(os.devnull, 'w') as devnull: blame_output = subprocess.check_output(cmd, stderr=devnull).decode('utf-8') for line in blame_output.splitlines(True): - if six.PY2: - split_line = line.split(None, 6) - else: - split_line = line.split(maxsplit=6) - # Handle blank lines. - if len(split_line) < 7: - content += '\n' - continue - _, _, date, _, _, _, line_content = split_line - if re.match(EXPECTATION_LINE_REGEX, line): + match = GIT_BLAME_REGEX.match(line) + assert match + date = match.groupdict()['date'] + line_content = match.groupdict()['content'] + if EXPECTATION_LINE_REGEX.match(line): if six.PY2: date_parts = date.split('-') date = datetime.date(year=int(date_parts[0]),
diff --git a/testing/unexpected_passes_common/expectations_unittest.py b/testing/unexpected_passes_common/expectations_unittest.py index 48f0cfe..8181fe79 100755 --- a/testing/unexpected_passes_common/expectations_unittest.py +++ b/testing/unexpected_passes_common/expectations_unittest.py
@@ -157,13 +157,13 @@ older_str = older_date.isoformat() # pylint: disable=line-too-long blame_output = """\ -5f03bc04975c04 (<author@mail.com> {today_date} 00:00:00 +0000 1) # tags: [ tag1 ] -98637cd80f8c15 (<author@mail.com> {yesterday_date} 00:00:00 +0000 2) # tags: [ tag2 ] -3fcadac9d861d0 (<author@mail.com> {older_date} 00:00:00 +0000 3) # results: [ Failure ] -5f03bc04975c04 (<author@mail.com> {today_date} 00:00:00 +0000 4) -5f03bc04975c04 (<author@mail.com> {today_date} 00:00:00 +0000 5) crbug.com/1234 [ tag1 ] testname [ Failure ] -98637cd80f8c15 (<author@mail.com> {yesterday_date} 00:00:00 +0000 6) [ tag2 ] testname [ Failure ] # Comment -3fcadac9d861d0 (<author@mail.com> {older_date} 00:00:00 +0000 7) [ tag1 ] othertest [ Failure ]""" +5f03bc04975c04 (Some R. Author {today_date} 00:00:00 +0000 1)# tags: [ tag1 ] +98637cd80f8c15 (Some R. Author {yesterday_date} 00:00:00 +0000 2)# tags: [ tag2 ] +3fcadac9d861d0 (Some R. Author {older_date} 00:00:00 +0000 3)# results: [ Failure ] +5f03bc04975c04 (Some R. Author {today_date} 00:00:00 +0000 4) +5f03bc04975c04 (Some R. Author {today_date} 00:00:00 +0000 5)crbug.com/1234 [ tag1 ] testname [ Failure ] +98637cd80f8c15 (Some R. Author {yesterday_date} 00:00:00 +0000 6)[ tag2 ] testname [ Failure ] # Comment +3fcadac9d861d0 (Some R. Author {older_date} 00:00:00 +0000 7)[ tag1 ] othertest [ Failure ]""" # pylint: enable=line-too-long blame_output = blame_output.format(today_date=today_str, yesterday_date=yesterday_str, @@ -189,13 +189,13 @@ older_str = older_date.isoformat() # pylint: disable=line-too-long blame_output = """\ -5f03bc04975c04 (<author@mail.com> {today_date} 00:00:00 +0000 1) # tags: [ tag1 ] -98637cd80f8c15 (<author@mail.com> {yesterday_date} 00:00:00 +0000 2) # tags: [ tag2 ] -3fcadac9d861d0 (<author@mail.com> {older_date} 00:00:00 +0000 3) # results: [ Failure ] -5f03bc04975c04 (<author@mail.com> {today_date} 00:00:00 +0000 4) -5f03bc04975c04 (<author@mail.com> {today_date} 00:00:00 +0000 5) crbug.com/1234 [ tag1 ] testname [ Failure ] -98637cd80f8c15 (<author@mail.com> {yesterday_date} 00:00:00 +0000 6) [ tag2 ] testname [ Failure ] # Comment -3fcadac9d861d0 (<author@mail.com> {older_date} 00:00:00 +0000 7) [ tag1 ] othertest [ Failure ]""" +5f03bc04975c04 (Some R. Author {today_date} 00:00:00 +0000 1)# tags: [ tag1 ] +98637cd80f8c15 (Some R. Author {yesterday_date} 00:00:00 +0000 2)# tags: [ tag2 ] +3fcadac9d861d0 (Some R. Author {older_date} 00:00:00 +0000 3)# results: [ Failure ] +5f03bc04975c04 (Some R. Author {today_date} 00:00:00 +0000 4) +5f03bc04975c04 (Some R. Author {today_date} 00:00:00 +0000 5)crbug.com/1234 [ tag1 ] testname [ Failure ] +98637cd80f8c15 (Some R. Author {yesterday_date} 00:00:00 +0000 6)[ tag2 ] testname [ Failure ] # Comment +3fcadac9d861d0 (Some R. Author {older_date} 00:00:00 +0000 7)[ tag1 ] othertest [ Failure ]""" # pylint: enable=line-too-long blame_output = blame_output.format(today_date=today_str, yesterday_date=yesterday_str,
diff --git a/third_party/.gitignore b/third_party/.gitignore index 8ff80541..dd76f75 100644 --- a/third_party/.gitignore +++ b/third_party/.gitignore
@@ -77,7 +77,6 @@ /devtools-frontend/src /devtools-frontend-internal /directxsdk -/distributed_point_functions/src /dom_distiller_js/dist /eigen3/src /elfutils/src
diff --git a/third_party/blink/renderer/core/animation/interpolable_shadow.cc b/third_party/blink/renderer/core/animation/interpolable_shadow.cc index 93cd12404..11e9628 100644 --- a/third_party/blink/renderer/core/animation/interpolable_shadow.cc +++ b/third_party/blink/renderer/core/animation/interpolable_shadow.cc
@@ -10,7 +10,7 @@ #include "third_party/blink/renderer/core/css/css_identifier_value.h" #include "third_party/blink/renderer/core/css/css_shadow_value.h" #include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { namespace { @@ -142,7 +142,7 @@ DCHECK(shadow_x.IsFixed() && shadow_y.IsFixed() && shadow_blur.IsFixed() && shadow_spread.IsFixed()); return ShadowData( - FloatPoint(shadow_x.Value(), shadow_y.Value()), shadow_blur.Value(), + gfx::PointF(shadow_x.Value(), shadow_y.Value()), shadow_blur.Value(), shadow_spread.Value(), shadow_style_, StyleColor( CSSColorInterpolationType::ResolveInterpolableColor(*color_, state)));
diff --git a/third_party/blink/renderer/core/animation/svg_transform_list_interpolation_type.cc b/third_party/blink/renderer/core/animation/svg_transform_list_interpolation_type.cc index dff7b53..622ac26 100644 --- a/third_party/blink/renderer/core/animation/svg_transform_list_interpolation_type.cc +++ b/third_party/blink/renderer/core/animation/svg_transform_list_interpolation_type.cc
@@ -14,6 +14,7 @@ #include "third_party/blink/renderer/core/animation/svg_interpolation_environment.h" #include "third_party/blink/renderer/core/svg/svg_transform.h" #include "third_party/blink/renderer/core/svg/svg_transform_list.h" +#include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/heap/heap.h" namespace blink { @@ -57,7 +58,7 @@ std::unique_ptr<InterpolableValue> TranslateToInterpolableValue( SVGTransform* transform) { - FloatPoint translate = transform->Translate(); + gfx::PointF translate = transform->Translate(); auto result = std::make_unique<InterpolableList>(2); result->Set(0, std::make_unique<InterpolableNumber>(translate.x())); result->Set(1, std::make_unique<InterpolableNumber>(translate.y())); @@ -95,7 +96,7 @@ std::unique_ptr<InterpolableValue> RotateToInterpolableValue( SVGTransform* transform) { - FloatPoint rotation_center = transform->RotationCenter(); + gfx::PointF rotation_center = transform->RotationCenter(); auto result = std::make_unique<InterpolableList>(3); result->Set(0, std::make_unique<InterpolableNumber>(transform->Angle())); result->Set(1, std::make_unique<InterpolableNumber>(rotation_center.x()));
diff --git a/third_party/blink/renderer/core/clipboard/data_transfer.cc b/third_party/blink/renderer/core/clipboard/data_transfer.cc index 9199b95..bacfdfd 100644 --- a/third_party/blink/renderer/core/clipboard/data_transfer.cc +++ b/third_party/blink/renderer/core/clipboard/data_transfer.cc
@@ -145,7 +145,7 @@ dragged_layout_object->GetDocument().Lifecycle().AdvanceTo( DocumentLifecycle::kPaintClean); - FloatPoint paint_offset = bounding_box.origin(); + gfx::Vector2dF paint_offset = bounding_box.OffsetFromOrigin(); PropertyTreeState border_box_properties = layer->GetLayoutObject() .FirstFragment() .LocalBorderBoxProperties() @@ -153,7 +153,7 @@ // We paint in the containing transform node's space. Add the offset from // the layer to this transform space. paint_offset += - FloatPoint(layer->GetLayoutObject().FirstFragment().PaintOffset()); + gfx::Vector2dF(layer->GetLayoutObject().FirstFragment().PaintOffset()); return DataTransfer::CreateDragImageForFrame( *local_frame_, 1.0f, bounding_box.size(), paint_offset, *builder, @@ -403,7 +403,7 @@ LocalFrame& frame, float opacity, const FloatSize& css_size, - const FloatPoint& paint_offset, + const gfx::Vector2dF& paint_offset, PaintRecordBuilder& builder, const PropertyTreeState& property_tree_state) { float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated();
diff --git a/third_party/blink/renderer/core/clipboard/data_transfer.h b/third_party/blink/renderer/core/clipboard/data_transfer.h index 81f64e7..59b2a1c 100644 --- a/third_party/blink/renderer/core/clipboard/data_transfer.h +++ b/third_party/blink/renderer/core/clipboard/data_transfer.h
@@ -148,7 +148,7 @@ LocalFrame&, float, const FloatSize& css_size, - const FloatPoint& paint_offset, + const gfx::Vector2dF& paint_offset, PaintRecordBuilder&, const PropertyTreeState&); static std::unique_ptr<DragImage> NodeImage(LocalFrame&, Node&);
diff --git a/third_party/blink/renderer/core/css/css_gradient_value.cc b/third_party/blink/renderer/core/css/css_gradient_value.cc index 73c33c95..0444775 100644 --- a/third_party/blink/renderer/core/css/css_gradient_value.cc +++ b/third_party/blink/renderer/core/css/css_gradient_value.cc
@@ -184,19 +184,19 @@ STACK_ALLOCATED(); public: - GradientDesc(const FloatPoint& p0, - const FloatPoint& p1, + GradientDesc(const gfx::PointF& p0, + const gfx::PointF& p1, GradientSpreadMethod spread_method) : p0(p0), p1(p1), spread_method(spread_method) {} - GradientDesc(const FloatPoint& p0, - const FloatPoint& p1, + GradientDesc(const gfx::PointF& p0, + const gfx::PointF& p1, float r0, float r1, GradientSpreadMethod spread_method) : p0(p0), p1(p1), r0(r0), r1(r1), spread_method(spread_method) {} Vector<Gradient::ColorStop> stops; - FloatPoint p0, p1; + gfx::PointF p0, p1; float r0 = 0, r1 = 0; float start_angle = 0, end_angle = 360; GradientSpreadMethod spread_method; @@ -456,6 +456,12 @@ } } +// Used in AdjustedGradientDomainForOffsetRange when the type of v1 - v0 is +// gfx::Vector2dF. +gfx::Vector2dF operator*(const gfx::Vector2dF& v, float scale) { + return gfx::ScaleVector2d(v, scale); +} + template <typename T> std::tuple<T, T> AdjustedGradientDomainForOffsetRange(const T& v0, const T& v1, @@ -524,7 +530,7 @@ float gradient_length; switch (GetClassType()) { case kLinearGradientClass: - gradient_length = FloatSize(desc.p1 - desc.p0).DiagonalLength(); + gradient_length = (desc.p1 - desc.p0).Length(); break; case kRadialGradientClass: gradient_length = desc.r1; @@ -740,12 +746,12 @@ } // Resolve points/radii to front end values. -static FloatPoint ComputeEndPoint( +static gfx::PointF ComputeEndPoint( const CSSValue* horizontal, const CSSValue* vertical, const CSSToLengthConversionData& conversion_data, const FloatSize& size) { - FloatPoint result; + gfx::PointF result; if (horizontal) result.set_x(PositionFromValue(horizontal, conversion_data, size, true)); @@ -875,8 +881,8 @@ // the given size. static void EndPointsFromAngle(float angle_deg, const FloatSize& size, - FloatPoint& first_point, - FloatPoint& second_point, + gfx::PointF& first_point, + gfx::PointF& second_point, CSSGradientType type) { // Prefixed gradients use "polar coordinate" angles, rather than "bearing" // angles. @@ -922,7 +928,7 @@ // Compute start corner relative to center, in Cartesian space (+y = up). float half_height = size.height() / 2; float half_width = size.width() / 2; - FloatPoint end_corner; + gfx::PointF end_corner; if (angle_deg < 90) end_corner.SetPoint(half_width, half_height); else if (angle_deg < 180) @@ -951,8 +957,8 @@ const ComputedStyle& style) const { DCHECK(!size.IsEmpty()); - FloatPoint first_point; - FloatPoint second_point; + gfx::PointF first_point; + gfx::PointF second_point; if (angle_) { float angle = angle_->ComputeDegrees(); EndPointsFromAngle(angle, size, first_point, second_point, gradient_type_); @@ -1245,7 +1251,7 @@ // Compute the radius to the closest/farthest side (depending on the compare // functor). -FloatSize RadiusToSide(const FloatPoint& point, +FloatSize RadiusToSide(const gfx::PointF& point, const FloatSize& size, EndShapeType shape, bool (*compare)(float, float)) { @@ -1264,9 +1270,10 @@ return FloatSize(dx, dy); } -// Compute the radius of an ellipse with center at 0,0 which passes through p, -// and has width/height given by aspectRatio. -inline FloatSize EllipseRadius(const FloatPoint& p, float aspect_ratio) { +// Compute the radius of an ellipse which passes through a point at +// |offset_from_center|, and has width/height given by aspectRatio. +inline FloatSize EllipseRadius(const gfx::Vector2dF& offset_from_center, + float aspect_ratio) { // If the aspectRatio is 0 or infinite, the ellipse is completely flat. // TODO(sashab): Implement Degenerate Radial Gradients, see crbug.com/635727. if (aspect_ratio == 0 || std::isinf(aspect_ratio)) @@ -1274,25 +1281,27 @@ // x^2/a^2 + y^2/b^2 = 1 // a/b = aspectRatio, b = a/aspectRatio - // a = sqrt(x^2 + y^2/(1/r^2)) - float a = sqrtf(p.x() * p.x() + p.y() * p.y() * aspect_ratio * aspect_ratio); + // a = sqrt(x^2 + y^2/(1/aspect_ratio^2)) + float a = sqrtf(offset_from_center.x() * offset_from_center.x() + + offset_from_center.y() * offset_from_center.y() * + aspect_ratio * aspect_ratio); return FloatSize(ClampTo<float>(a), ClampTo<float>(a / aspect_ratio)); } // Compute the radius to the closest/farthest corner (depending on the compare // functor). -FloatSize RadiusToCorner(const FloatPoint& point, +FloatSize RadiusToCorner(const gfx::PointF& point, const FloatSize& size, EndShapeType shape, bool (*compare)(float, float)) { - const FloatRect rect(FloatPoint(), size); - const FloatPoint corners[] = {rect.origin(), rect.top_right(), - rect.bottom_right(), rect.bottom_left()}; + const FloatRect rect(gfx::PointF(), size); + const gfx::PointF corners[] = {rect.origin(), rect.top_right(), + rect.bottom_right(), rect.bottom_left()}; unsigned corner_index = 0; - float distance = (point - corners[corner_index]).DiagonalLength(); + float distance = (point - corners[corner_index]).Length(); for (unsigned i = 1; i < base::size(corners); ++i) { - float new_distance = (point - corners[i]).DiagonalLength(); + float new_distance = (point - corners[i]).Length(); if (compare(new_distance, distance)) { corner_index = i; distance = new_distance; @@ -1311,7 +1320,7 @@ const FloatSize side_radius = RadiusToSide(point, size, kEllipseEndShape, compare); - return EllipseRadius(FloatPoint(corners[corner_index] - point), + return EllipseRadius(corners[corner_index] - point, side_radius.AspectRatio()); } @@ -1324,14 +1333,14 @@ const ComputedStyle& style) const { DCHECK(!size.IsEmpty()); - FloatPoint first_point = + gfx::PointF first_point = ComputeEndPoint(first_x_.Get(), first_y_.Get(), conversion_data, size); if (!first_x_) first_point.set_x(size.width() / 2); if (!first_y_) first_point.set_y(size.height() / 2); - FloatPoint second_point = + gfx::PointF second_point = ComputeEndPoint(second_x_.Get(), second_y_.Get(), conversion_data, size); if (!second_x_) second_point.set_x(size.width() / 2); @@ -1516,7 +1525,7 @@ const float angle = from_angle_ ? from_angle_->ComputeDegrees() : 0; - const FloatPoint position( + const gfx::PointF position( x_ ? PositionFromValue(x_, conversion_data, size, true) : size.width() / 2, y_ ? PositionFromValue(y_, conversion_data, size, false)
diff --git a/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc b/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc index e9501d7a..3672574fb 100644 --- a/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc +++ b/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc
@@ -1513,7 +1513,7 @@ } } - return ShadowData(FloatPoint(x, y), blur, spread, shadow_style, color); + return ShadowData(gfx::PointF(x, y), blur, spread, shadow_style, color); } scoped_refptr<ShadowList> StyleBuilderConverter::ConvertShadowList(
diff --git a/third_party/blink/renderer/core/css/threaded/filter_operation_resolver_threaded_test.cc b/third_party/blink/renderer/core/css/threaded/filter_operation_resolver_threaded_test.cc index 33f8459..4363d252 100644 --- a/third_party/blink/renderer/core/css/threaded/filter_operation_resolver_threaded_test.cc +++ b/third_party/blink/renderer/core/css/threaded/filter_operation_resolver_threaded_test.cc
@@ -81,7 +81,7 @@ ASSERT_EQ(fo.size(), 1ul); EXPECT_EQ(*fo.at(0), *MakeGarbageCollected<DropShadowFilterOperation>( - ShadowData(FloatPoint(10, 5), 1, 0, ShadowStyle::kNormal, + ShadowData(gfx::PointF(10, 5), 1, 0, ShadowStyle::kNormal, StyleColor(Color::kBlack)))); }); }
diff --git a/third_party/blink/renderer/core/css/threaded/text_renderer_threaded_test.cc b/third_party/blink/renderer/core/css/threaded/text_renderer_threaded_test.cc index ba345f0..f58ee73 100644 --- a/third_party/blink/renderer/core/css/threaded/text_renderer_threaded_test.cc +++ b/third_party/blink/renderer/core/css/threaded/text_renderer_threaded_test.cc
@@ -48,7 +48,7 @@ TextDirection::kLtr, false); text_run.SetNormalizeSpace(true); FloatRect text_bounds = font.SelectionRectForText( - text_run, FloatPoint(), font.GetFontDescription().ComputedSize(), 0, + text_run, gfx::PointF(), font.GetFontDescription().ComputedSize(), 0, -1); // X direction. @@ -78,7 +78,7 @@ Font font = Font(font_description); - FloatPoint location(0, 0); + gfx::PointF location(0, 0); TextRun text_run(text, 0, 0, TextRun::kAllowTrailingExpansion, TextDirection::kLtr, false); text_run.SetNormalizeSpace(true);
diff --git a/third_party/blink/renderer/core/dom/element.cc b/third_party/blink/renderer/core/dom/element.cc index 2c78b89..be13f27 100644 --- a/third_party/blink/renderer/core/dom/element.cc +++ b/third_party/blink/renderer/core/dom/element.cc
@@ -1624,9 +1624,8 @@ scrollable_area->GetScrollOffset().height()); std::unique_ptr<cc::SnapSelectionStrategy> strategy = cc::SnapSelectionStrategy::CreateForEndPosition( - ToGfxPointF(scrollable_area->ScrollOffsetToPosition(end_offset)), - true, false); - absl::optional<FloatPoint> snap_point = + scrollable_area->ScrollOffsetToPosition(end_offset), true, false); + absl::optional<gfx::PointF> snap_point = scrollable_area->GetSnapPositionAndSetTarget(*strategy); if (snap_point.has_value()) { end_offset = scrollable_area->ScrollPositionToOffset(snap_point.value()); @@ -1676,9 +1675,8 @@ new_top * box->Style()->EffectiveZoom()); std::unique_ptr<cc::SnapSelectionStrategy> strategy = cc::SnapSelectionStrategy::CreateForEndPosition( - ToGfxPointF(scrollable_area->ScrollOffsetToPosition(end_offset)), - false, true); - absl::optional<FloatPoint> snap_point = + scrollable_area->ScrollOffsetToPosition(end_offset), false, true); + absl::optional<gfx::PointF> snap_point = scrollable_area->GetSnapPositionAndSetTarget(*strategy); if (snap_point.has_value()) { end_offset = scrollable_area->ScrollPositionToOffset(snap_point.value()); @@ -1805,8 +1803,7 @@ gfx::PointF current_position(scrollable_area->ScrollPosition().x(), scrollable_area->ScrollPosition().y()); displacement.Scale(box->Style()->EffectiveZoom()); - gfx::PointF new_offset = current_position + displacement; - FloatPoint new_position(new_offset.x(), new_offset.y()); + gfx::PointF new_position = current_position + displacement; std::unique_ptr<cc::SnapSelectionStrategy> strategy = cc::SnapSelectionStrategy::CreateForEndAndDirection( @@ -1868,9 +1865,9 @@ std::unique_ptr<cc::SnapSelectionStrategy> strategy = cc::SnapSelectionStrategy::CreateForEndPosition( - ToGfxPointF(scrollable_area->ScrollOffsetToPosition(new_offset)), + scrollable_area->ScrollOffsetToPosition(new_offset), scroll_to_options->hasLeft(), scroll_to_options->hasTop()); - absl::optional<FloatPoint> snap_point = + absl::optional<gfx::PointF> snap_point = scrollable_area->GetSnapPositionAndSetTarget(*strategy); if (snap_point.has_value()) { new_offset = scrollable_area->ScrollPositionToOffset(snap_point.value()); @@ -1905,10 +1902,8 @@ return; displacement.Scale(frame->PageZoomFactor()); - FloatPoint new_position = viewport->ScrollPosition() + - FloatPoint(displacement.x(), displacement.y()); - - gfx::PointF current_position = ToGfxPointF(viewport->ScrollPosition()); + gfx::PointF new_position = viewport->ScrollPosition() + displacement; + gfx::PointF current_position = viewport->ScrollPosition(); std::unique_ptr<cc::SnapSelectionStrategy> strategy = cc::SnapSelectionStrategy::CreateForEndAndDirection( current_position, displacement, @@ -1945,10 +1940,10 @@ frame->PageZoomFactor()); } - FloatPoint new_position = viewport->ScrollOffsetToPosition(new_offset); + gfx::PointF new_position = viewport->ScrollOffsetToPosition(new_offset); std::unique_ptr<cc::SnapSelectionStrategy> strategy = cc::SnapSelectionStrategy::CreateForEndPosition( - ToGfxPointF(new_position), scroll_to_options->hasLeft(), + new_position, scroll_to_options->hasLeft(), scroll_to_options->hasTop()); new_position = viewport->GetSnapPositionAndSetTarget(*strategy).value_or(new_position); @@ -2925,6 +2920,12 @@ if (HasCustomStyleCallbacks()) DidRecalcStyle(child_change); + + // This needs to be cleared to satisty the DCHECKed invariants in + // Element::RebuildLayoutTree(). ChildNeedsStyleRecalc() is flipped back on + // before resuming the style recalc when the container is laid out. The stored + // child_change contains the correct flags to resume recalc of child nodes. + ClearChildNeedsStyleRecalc(); return true; }
diff --git a/third_party/blink/renderer/core/editing/finder/find_in_page_coordinates.cc b/third_party/blink/renderer/core/editing/finder/find_in_page_coordinates.cc index e0ad5574..f48e822 100644 --- a/third_party/blink/renderer/core/editing/finder/find_in_page_coordinates.cc +++ b/third_party/blink/renderer/core/editing/finder/find_in_page_coordinates.cc
@@ -41,9 +41,9 @@ #include "third_party/blink/renderer/core/layout/layout_embedded_content.h" #include "third_party/blink/renderer/core/layout/layout_object.h" #include "third_party/blink/renderer/core/layout/layout_view.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_quad.h" #include "ui/gfx/geometry/point.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -88,7 +88,7 @@ // Since we work with rects enclosing quad unions this is still // transform-friendly. FloatRect normalized_rect = absolute_rect; - normalized_rect.MoveBy(-container_rect.origin()); + normalized_rect.Offset(-container_rect.OffsetFromOrigin()); normalized_rect.Scale(1 / container_rect.width(), 1 / container_rect.height());
diff --git a/third_party/blink/renderer/core/editing/finder/text_finder.cc b/third_party/blink/renderer/core/editing/finder/text_finder.cc index 95943f6..e346e1a 100644 --- a/third_party/blink/renderer/core/editing/finder/text_finder.cc +++ b/third_party/blink/renderer/core/editing/finder/text_finder.cc
@@ -739,14 +739,14 @@ int TextFinder::SelectNearestFindMatch(const gfx::PointF& point, gfx::Rect* selection_rect) { - int index = NearestFindMatch(FloatPoint(point), nullptr); + int index = NearestFindMatch(point, nullptr); if (index != -1) return SelectFindMatch(static_cast<unsigned>(index), selection_rect); return -1; } -int TextFinder::NearestFindMatch(const FloatPoint& point, +int TextFinder::NearestFindMatch(const gfx::PointF& point, float* distance_squared) { UpdateFindMatchRects(); @@ -754,10 +754,8 @@ float nearest_distance_squared = FLT_MAX; for (wtf_size_t i = 0; i < find_matches_cache_.size(); ++i) { DCHECK(!find_matches_cache_[i].rect_.IsEmpty()); - FloatSize offset = point - find_matches_cache_[i].rect_.CenterPoint(); - float width = offset.width(); - float height = offset.height(); - float current_distance_squared = width * width + height * height; + gfx::Vector2dF offset = point - find_matches_cache_[i].rect_.CenterPoint(); + float current_distance_squared = offset.LengthSquared(); if (current_distance_squared < nearest_distance_squared) { nearest = i; nearest_distance_squared = current_distance_squared;
diff --git a/third_party/blink/renderer/core/editing/finder/text_finder.h b/third_party/blink/renderer/core/editing/finder/text_finder.h index ca26d049..b55165a6 100644 --- a/third_party/blink/renderer/core/editing/finder/text_finder.h +++ b/third_party/blink/renderer/core/editing/finder/text_finder.h
@@ -82,7 +82,7 @@ // provided point in find-in-page coordinates, or -1 in case of error. // The squared distance to the closest match is returned in the // |distanceSquared| parameter. - int NearestFindMatch(const FloatPoint&, float* distance_squared); + int NearestFindMatch(const gfx::PointF&, float* distance_squared); // Returns whether this frame has the active match. bool ActiveMatchFrame() const { return current_active_match_frame_; }
diff --git a/third_party/blink/renderer/core/editing/selection_controller.cc b/third_party/blink/renderer/core/editing/selection_controller.cc index d8c221e9..7d0f27a 100644 --- a/third_party/blink/renderer/core/editing/selection_controller.cc +++ b/third_party/blink/renderer/core/editing/selection_controller.cc
@@ -355,7 +355,7 @@ // existing selection so we can allow for text dragging. if (LocalFrameView* view = frame_->View()) { const PhysicalOffset v_point(view->ConvertFromRootFrame( - FlooredIntPoint(event.Event().PositionInRootFrame()))); + gfx::ToFlooredPoint(event.Event().PositionInRootFrame()))); if (!extend_selection && Selection().Contains(v_point)) { mouse_down_was_single_click_in_selection_ = true; if (!event.Event().FromTouch()) @@ -1078,7 +1078,7 @@ // editing, place the caret. if (mouse_down_was_single_click_in_selection_ && selection_state_ != SelectionState::kExtendedSelection && - drag_start_pos == PhysicalOffset(FlooredIntPoint( + drag_start_pos == PhysicalOffset(gfx::ToFlooredPoint( event.Event().PositionInRootFrame())) && Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange() && event.Event().button != WebPointerProperties::Button::kRight) { @@ -1257,7 +1257,7 @@ // really strange (having the whole frame be greyed out), so we deselect the // selection. PhysicalOffset p(frame_->View()->ConvertFromRootFrame( - FlooredIntPoint(mev.Event().PositionInRootFrame()))); + gfx::ToFlooredPoint(mev.Event().PositionInRootFrame()))); if (!Selection().Contains(p)) return;
diff --git a/third_party/blink/renderer/core/events/mouse_event.cc b/third_party/blink/renderer/core/events/mouse_event.cc index 5a6b29b..909c08f 100644 --- a/third_party/blink/renderer/core/events/mouse_event.cc +++ b/third_party/blink/renderer/core/events/mouse_event.cc
@@ -175,12 +175,12 @@ const WebPointerProperties& web_pointer_properties, const LocalDOMWindow* dom_window, MouseEventInit* initializer) { - FloatPoint client_point; - FloatPoint screen_point(web_pointer_properties.PositionInScreen()); + gfx::PointF client_point; + gfx::PointF screen_point = web_pointer_properties.PositionInScreen(); float scale_factor = 1.0f; if (dom_window && dom_window->GetFrame() && dom_window->GetFrame()->View()) { LocalFrame* frame = dom_window->GetFrame(); - FloatPoint root_frame_point(web_pointer_properties.PositionInWidget()); + gfx::PointF root_frame_point = web_pointer_properties.PositionInWidget(); if (Page* p = frame->GetPage()) { if (p->GetPointerLockController().GetElement() && !p->GetPointerLockController().LockPending()) { @@ -188,10 +188,10 @@ &screen_point); } } - FloatPoint frame_point = + gfx::PointF frame_point = frame->View()->ConvertFromRootFrame(root_frame_point); scale_factor = 1.0f / frame->PageZoomFactor(); - client_point = frame_point.ScaledBy(scale_factor); + client_point = gfx::ScalePoint(frame_point, scale_factor); } initializer->setScreenX(screen_point.x()); @@ -439,8 +439,8 @@ // Adjust offsetLocation to be relative to the target's padding box. if (const LayoutObject* layout_object = FindTargetLayoutObject(target_node)) { - FloatPoint local_pos = layout_object->AbsoluteToLocalFloatPoint( - FloatPoint(AbsoluteLocation())); + gfx::PointF local_pos = + layout_object->AbsoluteToLocalPoint(gfx::PointF(AbsoluteLocation())); if (layout_object->IsInline()) { UseCounter::Count(
diff --git a/third_party/blink/renderer/core/events/pointer_event_factory.cc b/third_party/blink/renderer/core/events/pointer_event_factory.cc index fb982801..b387ae3a 100644 --- a/third_party/blink/renderer/core/events/pointer_event_factory.cc +++ b/third_party/blink/renderer/core/events/pointer_event_factory.cc
@@ -70,7 +70,7 @@ } void UpdateCommonPointerEventInit(const WebPointerEvent& web_pointer_event, - const FloatPoint& last_global_position, + const gfx::PointF& last_global_position, LocalDOMWindow* dom_window, PointerEventInit* pointer_event_init) { // This function should not update attributes like pointerId, isPrimary, @@ -170,7 +170,7 @@ if (!event_list.IsEmpty()) { // Make a copy of LastPointerPosition so we can modify it after creating // each coalesced event. - FloatPoint last_global_position = + gfx::PointF last_global_position = GetLastPointerPosition(pointer_event_init->pointerId(), event_list.front(), web_pointer_event.GetType()); @@ -201,7 +201,7 @@ new_event_init, static_cast<WebInputEvent::Modifiers>(event.GetModifiers())); - last_global_position = FloatPoint(event.PositionInScreen()); + last_global_position = event.PositionInScreen(); PointerEvent* pointer_event = PointerEvent::Create(type, new_event_init, event.TimeStamp()); @@ -357,13 +357,13 @@ pointer_event_init->setPredictedEvents(predicted_pointer_events); SetLastPosition(pointer_event_init->pointerId(), - FloatPoint(web_pointer_event.PositionInScreen()), event_type); + web_pointer_event.PositionInScreen(), event_type); return PointerEvent::Create(type, pointer_event_init, web_pointer_event.TimeStamp()); } void PointerEventFactory::SetLastPosition(int pointer_id, - const FloatPoint& position_in_screen, + const gfx::PointF& position_in_screen, WebInputEvent::Type event_type) { if (event_type == WebInputEvent::Type::kPointerRawUpdate) pointerrawupdate_last_position_mapping_.Set(pointer_id, position_in_screen); @@ -376,7 +376,7 @@ pointerrawupdate_last_position_mapping_.erase(pointer_id); } -FloatPoint PointerEventFactory::GetLastPointerPosition( +gfx::PointF PointerEventFactory::GetLastPointerPosition( int pointer_id, const WebPointerProperties& event, WebInputEvent::Type event_type) const { @@ -389,7 +389,7 @@ } // If pointer_id is not in the map, returns the current position so the // movement will be zero. - return FloatPoint(event.PositionInScreen()); + return event.PositionInScreen(); } PointerEvent* PointerEventFactory::CreatePointerCancelEvent(
diff --git a/third_party/blink/renderer/core/events/pointer_event_factory.h b/third_party/blink/renderer/core/events/pointer_event_factory.h index 202ea15..1f57462 100644 --- a/third_party/blink/renderer/core/events/pointer_event_factory.h +++ b/third_party/blink/renderer/core/events/pointer_event_factory.h
@@ -93,12 +93,12 @@ // Returns last_position of for the given pointerId if such id is active. // Otherwise it returns the PositionInScreen of the given events, so we will // get movement = 0 when there is no last position. - FloatPoint GetLastPointerPosition(PointerId pointer_id, - const WebPointerProperties& event, - WebInputEvent::Type event_type) const; + gfx::PointF GetLastPointerPosition(PointerId pointer_id, + const WebPointerProperties& event, + WebInputEvent::Type event_type) const; void SetLastPosition(PointerId pointer_id, - const FloatPoint& position_in_screen, + const gfx::PointF& position_in_screen, WebInputEvent::Type event_type); private: @@ -174,8 +174,8 @@ int id_count_[static_cast<int>(WebPointerProperties::PointerType::kMaxValue) + 1]; - PointerIdKeyMap<FloatPoint> pointer_id_last_position_mapping_; - PointerIdKeyMap<FloatPoint> pointerrawupdate_last_position_mapping_; + PointerIdKeyMap<gfx::PointF> pointer_id_last_position_mapping_; + PointerIdKeyMap<gfx::PointF> pointerrawupdate_last_position_mapping_; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/events/pointer_event_factory_test.cc b/third_party/blink/renderer/core/events/pointer_event_factory_test.cc index fc2825f2..80673fc 100644 --- a/third_party/blink/renderer/core/events/pointer_event_factory_test.cc +++ b/third_party/blink/renderer/core/events/pointer_event_factory_test.cc
@@ -106,7 +106,7 @@ WebPointerProperties::Button::kNoButton, gfx::PointF(50, 50), gfx::PointF(20, 20)), type), - FloatPoint(100, 100)); + gfx::PointF(100, 100)); return pointer_event; } void CreateAndCheckPointerTransitionEvent(PointerEvent*, const AtomicString&); @@ -575,7 +575,7 @@ WebPointerProperties::Button::kNoButton, gfx::PointF(50, 50), gfx::PointF(20, 20)), WebInputEvent::Type::kPointerMove), - FloatPoint(20, 20)); + gfx::PointF(20, 20)); } TEST_F(PointerEventFactoryTest, CoalescedEvents) {
diff --git a/third_party/blink/renderer/core/events/web_input_event_conversion.cc b/third_party/blink/renderer/core/events/web_input_event_conversion.cc index f890ce5..a2c4afa2 100644 --- a/third_party/blink/renderer/core/events/web_input_event_conversion.cc +++ b/third_party/blink/renderer/core/events/web_input_event_conversion.cc
@@ -65,7 +65,7 @@ if (frame_view) { LocalFrameView* root_view = frame_view->GetFrame().LocalFrameRoot().View(); if (root_view) { - visual_viewport = FlooredIntPoint( + visual_viewport = gfx::ToFlooredPoint( root_view->GetPage()->GetVisualViewport().VisibleRect().origin()); overscroll_offset = root_view->GetPage()->GetChromeClient().ElasticOverscroll(); @@ -82,9 +82,9 @@ web_event.SetModifiers(event.GetModifiers()); web_event.SetPositionInScreen(event.screenX(), event.screenY()); - FloatPoint local_point = layout_object->AbsoluteToLocalFloatPoint( - FloatPoint(event.AbsoluteLocation())); - web_event.SetPositionInWidget(ToGfxPointF(local_point)); + gfx::PointF local_point = layout_object->AbsoluteToLocalPoint( + gfx::PointF(event.AbsoluteLocation())); + web_event.SetPositionInWidget(local_point); } unsigned ToWebInputEventModifierFrom(WebMouseEvent::Button button) { @@ -257,7 +257,7 @@ // The mouse event co-ordinates should be generated from the co-ordinates of // the touch point. - FloatPoint screen_point = touch->ScreenLocation(); + gfx::PointF screen_point = touch->ScreenLocation(); SetPositionInScreen(screen_point.x(), screen_point.y()); button = WebMouseEvent::Button::kLeft; @@ -265,9 +265,9 @@ click_count = (type_ == WebInputEvent::Type::kMouseDown || type_ == WebInputEvent::Type::kMouseUp); - FloatPoint local_point = layout_object->AbsoluteToLocalFloatPoint( - FloatPoint(touch->AbsoluteLocation())); - SetPositionInWidget(ToGfxPointF(local_point)); + gfx::PointF local_point = layout_object->AbsoluteToLocalPoint( + gfx::PointF(touch->AbsoluteLocation())); + SetPositionInWidget(local_point); pointer_type = WebPointerProperties::PointerType::kTouch; }
diff --git a/third_party/blink/renderer/core/events/web_input_event_conversion_test.cc b/third_party/blink/renderer/core/events/web_input_event_conversion_test.cc index e1ff89c..0701022 100644 --- a/third_party/blink/renderer/core/events/web_input_event_conversion_test.cc +++ b/third_party/blink/renderer/core/events/web_input_event_conversion_test.cc
@@ -51,6 +51,7 @@ #include "third_party/blink/renderer/platform/geometry/int_size.h" #include "third_party/blink/renderer/platform/testing/unit_test_helpers.h" #include "third_party/blink/renderer/platform/testing/url_test_helpers.h" +#include "ui/gfx/geometry/point_conversions.h" namespace blink { @@ -145,7 +146,7 @@ WebMouseEvent transformed_event = TransformWebMouseEvent(view, web_mouse_event); gfx::Point position = - FlooredIntPoint(transformed_event.PositionInRootFrame()); + gfx::ToFlooredPoint(transformed_event.PositionInRootFrame()); EXPECT_EQ(5, position.x()); EXPECT_EQ(5, position.y()); EXPECT_EQ(15, transformed_event.PositionInScreen().x()); @@ -172,7 +173,7 @@ WebGestureEvent scaled_gesture_event = TransformWebGestureEvent(view, web_gesture_event); gfx::Point position = - FlooredIntPoint(scaled_gesture_event.PositionInRootFrame()); + gfx::ToFlooredPoint(scaled_gesture_event.PositionInRootFrame()); EXPECT_EQ(5, position.x()); EXPECT_EQ(6, position.y()); EXPECT_EQ(20, scaled_gesture_event.PositionInScreen().x()); @@ -198,7 +199,7 @@ WebGestureEvent scaled_gesture_event = TransformWebGestureEvent(view, web_gesture_event); gfx::Point position = - FlooredIntPoint(scaled_gesture_event.PositionInRootFrame()); + gfx::ToFlooredPoint(scaled_gesture_event.PositionInRootFrame()); EXPECT_EQ(5, position.x()); EXPECT_EQ(6, position.y()); EXPECT_EQ(20, scaled_gesture_event.PositionInScreen().x()); @@ -630,7 +631,7 @@ WebGestureEvent scaled_gesture_event = TransformWebGestureEvent(view, web_gesture_event); gfx::Point position = - FlooredIntPoint(scaled_gesture_event.PositionInRootFrame()); + gfx::ToFlooredPoint(scaled_gesture_event.PositionInRootFrame()); EXPECT_EQ(10.f, position.x()); EXPECT_EQ(10.f, position.y()); EXPECT_EQ(10.f, scaled_gesture_event.PositionInScreen().x()); @@ -655,7 +656,7 @@ web_view->SetPageScaleFactor(2); - FloatPoint visual_offset(35, 60); + gfx::PointF visual_offset(35, 60); web_view->GetPage()->GetVisualViewport().SetLocation(visual_offset); LocalFrameView* view = @@ -671,7 +672,7 @@ WebMouseEvent transformed_mouse_event = TransformWebMouseEvent(view, web_mouse_event); gfx::Point position = - FlooredIntPoint(transformed_mouse_event.PositionInRootFrame()); + gfx::ToFlooredPoint(transformed_mouse_event.PositionInRootFrame()); EXPECT_EQ(5 + visual_offset.x(), position.x()); EXPECT_EQ(5 + visual_offset.y(), position.y()); EXPECT_EQ(10, transformed_mouse_event.PositionInScreen().x()); @@ -688,7 +689,7 @@ WebMouseWheelEvent scaled_mouse_wheel_event = TransformWebMouseWheelEvent(view, web_mouse_wheel_event); gfx::Point position = - FlooredIntPoint(scaled_mouse_wheel_event.PositionInRootFrame()); + gfx::ToFlooredPoint(scaled_mouse_wheel_event.PositionInRootFrame()); EXPECT_EQ(5 + visual_offset.x(), position.x()); EXPECT_EQ(5 + visual_offset.y(), position.y()); EXPECT_EQ(10, scaled_mouse_wheel_event.PositionInScreen().x()); @@ -706,7 +707,7 @@ WebGestureEvent scaled_gesture_event = TransformWebGestureEvent(view, web_gesture_event); gfx::Point position = - FlooredIntPoint(scaled_gesture_event.PositionInRootFrame()); + gfx::ToFlooredPoint(scaled_gesture_event.PositionInRootFrame()); EXPECT_EQ(5 + visual_offset.x(), position.x()); EXPECT_EQ(5 + visual_offset.y(), position.y()); EXPECT_EQ(10, scaled_gesture_event.PositionInScreen().x()); @@ -771,7 +772,7 @@ WebMouseEvent transformed_mouse_event = TransformWebMouseEvent(view, web_mouse_event); gfx::Point position = - FlooredIntPoint(transformed_mouse_event.PositionInRootFrame()); + gfx::ToFlooredPoint(transformed_mouse_event.PositionInRootFrame()); EXPECT_EQ(web_mouse_event.PositionInWidget().x() + elastic_overscroll.x(), position.x()); @@ -788,7 +789,7 @@ // pinch-zoom). float page_scale = 2; web_view->SetPageScaleFactor(page_scale); - FloatPoint visual_offset(35, 60); + gfx::PointF visual_offset(35, 60); web_view->GetPage()->GetVisualViewport().SetLocation(visual_offset); { WebMouseEvent web_mouse_event(WebInputEvent::Type::kMouseMove, @@ -800,7 +801,7 @@ WebMouseEvent transformed_mouse_event = TransformWebMouseEvent(view, web_mouse_event); gfx::Point position = - FlooredIntPoint(transformed_mouse_event.PositionInRootFrame()); + gfx::ToFlooredPoint(transformed_mouse_event.PositionInRootFrame()); EXPECT_EQ(web_mouse_event.PositionInWidget().x() / page_scale + visual_offset.x() + elastic_overscroll.x(), @@ -849,7 +850,7 @@ WebMouseEvent transformed_mouse_event = TransformWebMouseEvent(view, web_mouse_event); gfx::Point position = - FlooredIntPoint(transformed_mouse_event.PositionInRootFrame()); + gfx::ToFlooredPoint(transformed_mouse_event.PositionInRootFrame()); EXPECT_EQ(web_mouse_event.PositionInWidget().x() + elastic_overscroll.x(), position.x());
diff --git a/third_party/blink/renderer/core/events/wheel_event.h b/third_party/blink/renderer/core/events/wheel_event.h index dac2bde..3d7cecb 100644 --- a/third_party/blink/renderer/core/events/wheel_event.h +++ b/third_party/blink/renderer/core/events/wheel_event.h
@@ -29,8 +29,8 @@ #include "third_party/blink/public/common/input/web_mouse_wheel_event.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/events/mouse_event.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/wtf/casting.h" +#include "ui/gfx/geometry/point_f.h" namespace blink {
diff --git a/third_party/blink/renderer/core/execution_context/navigator_base.cc b/third_party/blink/renderer/core/execution_context/navigator_base.cc index f6e9b96a..c5cc655 100644 --- a/third_party/blink/renderer/core/execution_context/navigator_base.cc +++ b/third_party/blink/renderer/core/execution_context/navigator_base.cc
@@ -39,7 +39,8 @@ // If the User-Agent string is frozen, platform should be a value // matching the frozen string per https://github.com/WICG/ua-client-hints. // See content::frozen_user_agent_strings. - if (RuntimeEnabledFeatures::UserAgentReductionEnabled(execution_context)) { + if (base::FeatureList::IsEnabled(features::kReduceUserAgent) || + RuntimeEnabledFeatures::UserAgentReductionEnabled(execution_context)) { #if defined(OS_ANDROID) return "Linux armv81"; #elif defined(OS_MAC)
diff --git a/third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.cc b/third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.cc index d14f406..88e8c83 100644 --- a/third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.cc +++ b/third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.cc
@@ -388,7 +388,7 @@ WebInputEvent::kNoModifiers, base::TimeTicks::Now()); dummy_event.SetPositionInWidget(point); - gfx::Point transformed_point = FlooredIntPoint( + gfx::Point transformed_point = gfx::ToFlooredPoint( TransformWebMouseEvent(web_local_frame_impl_->GetFrameView(), dummy_event) .PositionInRootFrame()); HitTestLocation location(
diff --git a/third_party/blink/renderer/core/exported/web_page_popup_impl.cc b/third_party/blink/renderer/core/exported/web_page_popup_impl.cc index 5fa62d9..76e1162 100644 --- a/third_party/blink/renderer/core/exported/web_page_popup_impl.cc +++ b/third_party/blink/renderer/core/exported/web_page_popup_impl.cc
@@ -751,7 +751,7 @@ } if (RuntimeEnabledFeatures::ScrollUnificationEnabled()) { if (event.GetType() == WebInputEvent::Type::kGestureScrollBegin) { - HitTestLocation locationScroll(FloatPoint(event.PositionInWidget())); + HitTestLocation locationScroll(event.PositionInWidget()); HitTestResult resultScroll = MainFrame().GetEventHandler().HitTestResultAtLocation(locationScroll); scrollable_node_ = FindFirstScroller(resultScroll.InnerNode());
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 cea6ca1..3edf3d5 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
@@ -210,8 +210,8 @@ // The plugin is positioned in the root frame's coordinates, so it needs to // be painted in them too. - FloatPoint origin(ParentFrameView()->ConvertToRootFrame(gfx::Point())); - origin.Offset(-paint_offset); + gfx::PointF origin(ParentFrameView()->ConvertToRootFrame(gfx::Point())); + origin -= gfx::Vector2dF(ToGfxVector2d(paint_offset)); context.Translate(-origin.x(), -origin.y()); cc::PaintCanvas* canvas = context.Canvas(); @@ -875,15 +875,14 @@ } void WebPluginContainerImpl::HandleWheelEvent(WheelEvent& event) { - FloatPoint absolute_location = - FloatPoint(event.NativeEvent().PositionInRootFrame()); + gfx::PointF absolute_location = event.NativeEvent().PositionInRootFrame(); // Translate the root frame position to content coordinates. absolute_location = ParentFrameView()->ConvertFromRootFrame(absolute_location); - FloatPoint local_point = - element_->GetLayoutObject()->AbsoluteToLocalFloatPoint(absolute_location); + gfx::PointF local_point = + element_->GetLayoutObject()->AbsoluteToLocalPoint(absolute_location); WebMouseWheelEvent translated_event = event.NativeEvent().FlattenTransform(); translated_event.SetPositionInWidget(local_point.x(), local_point.y()); @@ -965,16 +964,15 @@ LocalFrameView* parent = ParentFrameView(); for (unsigned i = 0; i < transformed_event.touches_length; ++i) { - FloatPoint absolute_location = - FloatPoint(transformed_event.touches[i].PositionInWidget()); + gfx::PointF absolute_location = + transformed_event.touches[i].PositionInWidget(); // Translate the root frame position to content coordinates. absolute_location = parent->ConvertFromRootFrame(absolute_location); - FloatPoint local_point = - element_->GetLayoutObject()->AbsoluteToLocalFloatPoint( - absolute_location); - transformed_event.touches[i].SetPositionInWidget(ToGfxPointF(local_point)); + gfx::PointF local_point = + element_->GetLayoutObject()->AbsoluteToLocalPoint(absolute_location); + transformed_event.touches[i].SetPositionInWidget(local_point); } return transformed_event; } @@ -1034,11 +1032,10 @@ WebGestureEvent translated_event = event.NativeEvent(); gfx::PointF absolute_root_frame_location = event.NativeEvent().PositionInRootFrame(); - FloatPoint local_point = - element_->GetLayoutObject()->AbsoluteToLocalFloatPoint( - FloatPoint(absolute_root_frame_location)); + gfx::PointF local_point = element_->GetLayoutObject()->AbsoluteToLocalPoint( + absolute_root_frame_location); translated_event.FlattenTransform(); - translated_event.SetPositionInWidget(ToGfxPointF(local_point)); + translated_event.SetPositionInWidget(local_point); ui::Cursor dummy_cursor; if (web_plugin_->HandleInputEvent(
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 d87580a..aadecad 100644 --- a/third_party/blink/renderer/core/exported/web_view_impl.cc +++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
@@ -1305,8 +1305,9 @@ !fullscreen_controller_->IsFullscreenOrTransitioning(); size_ = main_frame_widget_size; - FloatSize viewport_anchor_coords(viewportAnchorCoordX, viewportAnchorCoordY); if (is_rotation) { + gfx::PointF viewport_anchor_coords(viewportAnchorCoordX, + viewportAnchorCoordY); RotationViewportAnchor anchor(*view, visual_viewport, viewport_anchor_coords, GetPageScaleConstraintsSet()); @@ -2264,12 +2265,12 @@ void WebViewImpl::SetVisualViewportOffset(const gfx::PointF& offset) { DCHECK(GetPage()); - GetPage()->GetVisualViewport().SetLocation(FloatPoint(offset)); + GetPage()->GetVisualViewport().SetLocation(offset); } gfx::PointF WebViewImpl::VisualViewportOffset() const { DCHECK(GetPage()); - return ToGfxPointF(GetPage()->GetVisualViewport().VisibleRect().origin()); + return GetPage()->GetVisualViewport().VisibleRect().origin(); } gfx::SizeF WebViewImpl::VisualViewportSize() const { @@ -2279,7 +2280,7 @@ void WebViewImpl::SetPageScaleFactorAndLocation(float scale_factor, bool is_pinch_gesture_active, - const FloatPoint& location) { + const gfx::PointF& location) { DCHECK(GetPage()); GetPage()->GetVisualViewport().SetScaleAndLocation( @@ -3600,7 +3601,7 @@ // controls ratio since doing so will change the bounds and move the // viewports to keep the offsets valid. The compositor may have already // done that so we don't want to double apply the deltas here. - FloatPoint visual_viewport_offset = visual_viewport.VisibleRect().origin(); + gfx::PointF visual_viewport_offset = visual_viewport.VisibleRect().origin(); visual_viewport_offset.Offset(args.inner_delta.x(), args.inner_delta.y()); GetBrowserControls().SetShownRatio(
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.h b/third_party/blink/renderer/core/exported/web_view_impl.h index 46bd70a..2f5d1c84 100644 --- a/third_party/blink/renderer/core/exported/web_view_impl.h +++ b/third_party/blink/renderer/core/exported/web_view_impl.h
@@ -622,7 +622,7 @@ void SetPageScaleFactorAndLocation(float scale, bool is_pinch_gesture_active, - const FloatPoint&); + const gfx::PointF&); void PropagateZoomFactorToLocalFrameRoots(Frame*, float); void SetPageLifecycleStateInternal(
diff --git a/third_party/blink/renderer/core/fragment_directive/fragment_directive.cc b/third_party/blink/renderer/core/fragment_directive/fragment_directive.cc index 664831d..532793d 100644 --- a/third_party/blink/renderer/core/fragment_directive/fragment_directive.cc +++ b/third_party/blink/renderer/core/fragment_directive/fragment_directive.cc
@@ -144,8 +144,8 @@ WTF::Bind( [](ScriptPromiseResolver* resolver, TextFragmentSelectorGenerator* generator, - const RangeInFlatTree* range, - const TextFragmentSelector& selector) { + const RangeInFlatTree* range, const TextFragmentSelector& selector, + absl::optional<shared_highlighting::LinkGenerationError> error) { if (selector.Type() == TextFragmentSelector::SelectorType::kInvalid) { RejectWithCode(resolver, DOMExceptionCode::kOperationError,
diff --git a/third_party/blink/renderer/core/fragment_directive/text_fragment_generation_navigation_test.cc b/third_party/blink/renderer/core/fragment_directive/text_fragment_generation_navigation_test.cc index c5c45c7..c612d47d 100644 --- a/third_party/blink/renderer/core/fragment_directive/text_fragment_generation_navigation_test.cc +++ b/third_party/blink/renderer/core/fragment_directive/text_fragment_generation_navigation_test.cc
@@ -101,10 +101,11 @@ String TextFragmentGenerationNavigationTest::GenerateSelector( const RangeInFlatTree& selection_range) { String selector; - auto lambda = [](String& selector, - const TextFragmentSelector& generated_selector) { - selector = generated_selector.ToString(); - }; + auto lambda = + [](String& selector, const TextFragmentSelector& generated_selector, + absl::optional<shared_highlighting::LinkGenerationError> error) { + selector = generated_selector.ToString(); + }; auto callback = WTF::Bind(lambda, std::ref(selector)); GetDocument() .GetFrame()
diff --git a/third_party/blink/renderer/core/fragment_directive/text_fragment_handler.cc b/third_party/blink/renderer/core/fragment_directive/text_fragment_handler.cc index e8ba2673..bc2ad21 100644 --- a/third_party/blink/renderer/core/fragment_directive/text_fragment_handler.cc +++ b/third_party/blink/renderer/core/fragment_directive/text_fragment_handler.cc
@@ -57,7 +57,7 @@ // respond with the result. Otherwise, the response callback is stored so // that we reply on completion. if (!selector_requested_before_ready_.value()) - InvokeReplyCallback(preemptive_generation_result_.value()); + InvokeReplyCallback(preemptive_generation_result_.value(), error_); } void TextFragmentHandler::GetExistingSelectors( @@ -173,16 +173,18 @@ } void TextFragmentHandler::DidFinishSelectorGeneration( - const TextFragmentSelector& selector) { + const TextFragmentSelector& selector, + absl::optional<shared_highlighting::LinkGenerationError> error) { DCHECK(!preemptive_generation_result_.has_value()); if (response_callback_) { - InvokeReplyCallback(selector); + InvokeReplyCallback(selector, error); } else { // If we don't have a callback yet, it's because we started generating // preemptively. We'll store the result so that when the selector actually // is requested we can simply use the stored result. preemptive_generation_result_.emplace(selector); + error_ = error; } } @@ -203,7 +205,8 @@ } void TextFragmentHandler::RecordPreemptiveGenerationMetrics( - const TextFragmentSelector& selector) { + const TextFragmentSelector& selector, + absl::optional<shared_highlighting::LinkGenerationError> optional_error) { DCHECK(selector_requested_before_ready_.has_value()); bool success = @@ -218,8 +221,6 @@ base::UmaHistogramBoolean(uma_prefix, success); if (!success) { - absl::optional<shared_highlighting::LinkGenerationError> optional_error = - GetTextFragmentSelectorGenerator()->GetError(); shared_highlighting::LinkGenerationError error = optional_error.has_value() ? optional_error.value() @@ -230,11 +231,21 @@ } void TextFragmentHandler::StartPreemptiveGenerationIfNeeded() { - if (shared_highlighting::ShouldOfferLinkToText( + preemptive_generation_result_.reset(); + error_.reset(); + selector_requested_before_ready_.reset(); + + // It is possible we have unsurved callback, but if we are starting a new + // generation, then we have a new selection, in which case it is safe to + // assume that the client is not waiting for the callback return. + response_callback_.Reset(); + + if (!shared_highlighting::ShouldOfferLinkToText( GetFrame()->GetDocument()->Url())) { - preemptive_generation_result_.reset(); - StartGeneratingForCurrentSelection(); + return; } + + StartGeneratingForCurrentSelection(); } void TextFragmentHandler::Trace(Visitor* visitor) const { @@ -249,8 +260,9 @@ } void TextFragmentHandler::InvokeReplyCallback( - const TextFragmentSelector& selector) { - RecordPreemptiveGenerationMetrics(selector); + const TextFragmentSelector& selector, + absl::optional<shared_highlighting::LinkGenerationError> error) { + RecordPreemptiveGenerationMetrics(selector, error); DCHECK(response_callback_); std::move(response_callback_).Run(selector.ToString());
diff --git a/third_party/blink/renderer/core/fragment_directive/text_fragment_handler.h b/third_party/blink/renderer/core/fragment_directive/text_fragment_handler.h index 22fdbd1..65a88f1 100644 --- a/third_party/blink/renderer/core/fragment_directive/text_fragment_handler.h +++ b/third_party/blink/renderer/core/fragment_directive/text_fragment_handler.h
@@ -60,18 +60,27 @@ void DidDetachDocumentOrFrame(); private: + FRIEND_TEST_ALL_PREFIXES(TextFragmentHandlerTest, + IfGeneratorResetShouldRecordCorrectError); + // The callback passed to TextFragmentSelectorGenerator that will receive the // result. - void DidFinishSelectorGeneration(const TextFragmentSelector& selector); + void DidFinishSelectorGeneration( + const TextFragmentSelector& selector, + absl::optional<shared_highlighting::LinkGenerationError> error); // This starts running the generator over the current selection. // The result will be returned by invoking DidFinishSelectorGeneration(). void StartGeneratingForCurrentSelection(); - void RecordPreemptiveGenerationMetrics(const TextFragmentSelector& selector); + void RecordPreemptiveGenerationMetrics( + const TextFragmentSelector& selector, + absl::optional<shared_highlighting::LinkGenerationError> error); // Called to reply to the client's RequestSelector call with the result. - void InvokeReplyCallback(const TextFragmentSelector& selector); + void InvokeReplyCallback( + const TextFragmentSelector& selector, + absl::optional<shared_highlighting::LinkGenerationError> error); TextFragmentAnchor* GetTextFragmentAnchor(); @@ -88,6 +97,10 @@ // mode. absl::optional<TextFragmentSelector> preemptive_generation_result_; + // If generation failed, contains the reason that generation failed, otherwise + // contains an empty optional. + absl::optional<shared_highlighting::LinkGenerationError> error_; + // Reports whether |RequestSelector| was called before or after selector was // ready. Used only in preemptive link generation mode. absl::optional<bool> selector_requested_before_ready_;
diff --git a/third_party/blink/renderer/core/fragment_directive/text_fragment_handler_test.cc b/third_party/blink/renderer/core/fragment_directive/text_fragment_handler_test.cc index d402b2e..a01e0252 100644 --- a/third_party/blink/renderer/core/fragment_directive/text_fragment_handler_test.cc +++ b/third_party/blink/renderer/core/fragment_directive/text_fragment_handler_test.cc
@@ -29,8 +29,6 @@ namespace blink { -namespace { - using test::RunPendingTasks; class TextFragmentHandlerTest : public SimTest { @@ -70,9 +68,11 @@ String SelectThenRequestSelector(const Position& start, const Position& end) { SetSelection(start, end); - GetTextFragmentHandler().StartPreemptiveGenerationIfNeeded(); + return RequestSelector(); + } + String RequestSelector() { bool callback_called = false; String selector; auto lambda = [](bool& callback_called, String& selector, @@ -140,6 +140,47 @@ ->addForBinding(script_state, ahem, exception_state); } + void VerifyPreemptiveGenerationMetricsDetailed( + bool success, + bool requested_after_ready, + absl::optional<shared_highlighting::LinkGenerationError> error, + bool has_async_tasks) { + base::StringPiece recorded_histograme; + base::StringPiece not_recorded_histogram; + if (requested_after_ready) { + recorded_histograme = + "SharedHighlights.LinkGenerated.RequestedAfterReady"; + not_recorded_histogram = + "SharedHighlights.LinkGenerated.RequestedBeforeReady"; + } else { + recorded_histograme = + "SharedHighlights.LinkGenerated.RequestedBeforeReady"; + not_recorded_histogram = + "SharedHighlights.LinkGenerated.RequestedAfterReady"; + } + + histogram_tester_.ExpectTotalCount(recorded_histograme, 1); + histogram_tester_.ExpectTotalCount(not_recorded_histogram, 0); + histogram_tester_.ExpectBucketCount(recorded_histograme, success, 1); + + histogram_tester_.ExpectTotalCount( + "SharedHighlights.LinkGenerated.Error.Requested", !success); + if (!success && error.has_value()) { + histogram_tester_.ExpectBucketCount( + "SharedHighlights.LinkGenerated.Error.Requested", error.value(), 1); + } + + if (has_async_tasks) { + EXPECT_LT(0u, histogram_tester_ + .GetAllSamples("SharedHighlights.AsyncTask.Iterations") + .size()); + EXPECT_LT(0u, + histogram_tester_ + .GetAllSamples("SharedHighlights.AsyncTask.SearchDuration") + .size()); + } + } + void VerifyPreemptiveGenerationMetrics(bool success) { EXPECT_EQ(1u, histogram_tester_ @@ -151,13 +192,8 @@ "SharedHighlights.LinkGenerated.RequestedBeforeReady") .size()); - if (!success) { - histogram_tester_.ExpectTotalCount( - "SharedHighlights.LinkGenerated.Error.Requested", 1); - } else { - histogram_tester_.ExpectTotalCount( - "SharedHighlights.LinkGenerated.Error.Requested", 0); - } + histogram_tester_.ExpectTotalCount( + "SharedHighlights.LinkGenerated.Error.Requested", !success); // Check async task metrics. EXPECT_LT(0u, histogram_tester_ @@ -680,7 +716,9 @@ ASSERT_EQ("First paragraph", PlainText(EphemeralRange(start, end))); SetSelection(start, end); - auto callback = WTF::Bind([](const TextFragmentSelector& selector) {}); + auto callback = WTF::Bind( + [](const TextFragmentSelector& selector, + absl::optional<shared_highlighting::LinkGenerationError> error) {}); GetDocument() .GetFrame() ->GetTextFragmentHandler() @@ -1136,6 +1174,36 @@ ->Url()); } -} // namespace +// crbug.com/1266937 Even if |TextFragmentSelectorGenerator| gets reset between +// generation completion and selector request we should record the correct error +// code. +TEST_F(TextFragmentHandlerTest, IfGeneratorResetShouldRecordCorrectError) { + SimRequest request("https://example.com/test.html", "text/html"); + LoadURL("https://example.com/test.html"); + request.Complete(R"HTML( + <!DOCTYPE html> + <div>Test page</div> + <p id='first'>First paragraph text that is longer than 20 chars</p> + <p id='second'>Second paragraph text</p> + )HTML"); + + Node* first_paragraph = GetDocument().getElementById("first")->firstChild(); + const auto& selected_start = Position(first_paragraph, 5); + const auto& selected_end = Position(first_paragraph, 6); + ASSERT_EQ(" ", PlainText(EphemeralRange(selected_start, selected_end))); + + SetSelection(selected_start, selected_end); + GetTextFragmentHandler().StartPreemptiveGenerationIfNeeded(); + + // Reset |TextFragmentSelectorGenerator|. + GetTextFragmentHandler().DidDetachDocumentOrFrame(); + + EXPECT_EQ(RequestSelector(), ""); + + absl::optional<shared_highlighting::LinkGenerationError> expected_error = + shared_highlighting::LinkGenerationError::kEmptySelection; + EXPECT_EQ(expected_error, GetTextFragmentHandler().error_); + VerifyPreemptiveGenerationMetricsDetailed(false, true, expected_error, false); +} } // namespace blink
diff --git a/third_party/blink/renderer/core/fragment_directive/text_fragment_selector_generator.cc b/third_party/blink/renderer/core/fragment_directive/text_fragment_selector_generator.cc index a6a2d2b..5e73e510 100644 --- a/third_party/blink/renderer/core/fragment_directive/text_fragment_selector_generator.cc +++ b/third_party/blink/renderer/core/fragment_directive/text_fragment_selector_generator.cc
@@ -716,7 +716,7 @@ void TextFragmentSelectorGenerator::NotifyClientSelectorReady( const TextFragmentSelector& selector) { DCHECK(pending_generate_selector_callback_); - std::move(pending_generate_selector_callback_).Run(selector); + std::move(pending_generate_selector_callback_).Run(selector, error_); } } // namespace blink
diff --git a/third_party/blink/renderer/core/fragment_directive/text_fragment_selector_generator.h b/third_party/blink/renderer/core/fragment_directive/text_fragment_selector_generator.h index db4c921a..a90fb5f 100644 --- a/third_party/blink/renderer/core/fragment_directive/text_fragment_selector_generator.h +++ b/third_party/blink/renderer/core/fragment_directive/text_fragment_selector_generator.h
@@ -32,8 +32,9 @@ class CORE_EXPORT TextFragmentSelectorGenerator final : public GarbageCollected<TextFragmentSelectorGenerator>, public TextFragmentFinder::Client { - using GenerateCallback = - base::OnceCallback<void(const TextFragmentSelector&)>; + using GenerateCallback = base::OnceCallback<void( + const TextFragmentSelector&, + absl::optional<shared_highlighting::LinkGenerationError>)>; public: explicit TextFragmentSelectorGenerator(LocalFrame* main_frame); @@ -69,12 +70,6 @@ LocalFrame* GetFrame() { return frame_; } - // If generation fails, returns the reason that generation failed. If - // generation hasn't finished, or was successful, returns an empty optional. - absl::optional<shared_highlighting::LinkGenerationError> GetError() { - return error_; - } - private: // Used for determining the next step of selector generation. enum GenerationStep { kExact, kRange, kContext };
diff --git a/third_party/blink/renderer/core/fragment_directive/text_fragment_selector_generator_test.cc b/third_party/blink/renderer/core/fragment_directive/text_fragment_selector_generator_test.cc index a12f4b8..ed3595b6 100644 --- a/third_party/blink/renderer/core/fragment_directive/text_fragment_selector_generator_test.cc +++ b/third_party/blink/renderer/core/fragment_directive/text_fragment_selector_generator_test.cc
@@ -90,11 +90,13 @@ bool callback_called = false; String selector; - auto lambda = [](bool& callback_called, String& selector, - const TextFragmentSelector& generated_selector) { - selector = generated_selector.ToString(); - callback_called = true; - }; + auto lambda = + [](bool& callback_called, String& selector, + const TextFragmentSelector& generated_selector, + absl::optional<shared_highlighting::LinkGenerationError> error) { + selector = generated_selector.ToString(); + callback_called = true; + }; auto callback = WTF::Bind(lambda, std::ref(callback_called), std::ref(selector)); GetTextFragmentSelectorGenerator()->Generate(
diff --git a/third_party/blink/renderer/core/frame/browser_controls_test.cc b/third_party/blink/renderer/core/frame/browser_controls_test.cc index 9c06867..bcc5279 100644 --- a/third_party/blink/renderer/core/frame/browser_controls_test.cc +++ b/third_party/blink/renderer/core/frame/browser_controls_test.cc
@@ -727,7 +727,7 @@ // Fully scroll frameview but visualviewport remains scrollable web_view->MainFrameImpl()->SetScrollOffset(gfx::PointF(0, 10000)); - GetVisualViewport().SetLocation(FloatPoint(0, 0)); + GetVisualViewport().SetLocation(gfx::PointF(0, 0)); GetWebView()->MainFrameViewWidget()->HandleInputEvent( GenerateEvent(WebInputEvent::Type::kGestureScrollBegin, 0, -10.f)); GetWebView()->MainFrameViewWidget()->HandleInputEvent( @@ -741,7 +741,7 @@ web_view->GetBrowserControls().SetShownRatio(1, 1); // Fully scroll visual veiwport but frameview remains scrollable web_view->MainFrameImpl()->SetScrollOffset(gfx::PointF(0, 0)); - GetVisualViewport().SetLocation(FloatPoint(0, 10000)); + GetVisualViewport().SetLocation(gfx::PointF(0, 10000)); GetWebView()->MainFrameViewWidget()->HandleInputEvent( GenerateEvent(WebInputEvent::Type::kGestureScrollBegin, 0, -20.f)); GetWebView()->MainFrameViewWidget()->HandleInputEvent( @@ -755,7 +755,7 @@ web_view->GetBrowserControls().SetShownRatio(1, 1); // Fully scroll both frameview and visual viewport web_view->MainFrameImpl()->SetScrollOffset(gfx::PointF(0, 10000)); - GetVisualViewport().SetLocation(FloatPoint(0, 10000)); + GetVisualViewport().SetLocation(gfx::PointF(0, 10000)); VerticalScroll(-30.f); // Browser controls should not move because neither frameview nor visual // viewport
diff --git a/third_party/blink/renderer/core/frame/find_in_page.cc b/third_party/blink/renderer/core/frame/find_in_page.cc index efce143..36b4a1cb 100644 --- a/third_party/blink/renderer/core/frame/find_in_page.cc +++ b/third_party/blink/renderer/core/frame/find_in_page.cc
@@ -256,7 +256,7 @@ void FindInPage::GetNearestFindResult(const gfx::PointF& point, GetNearestFindResultCallback callback) { float distance; - EnsureTextFinder().NearestFindMatch(FloatPoint(point), &distance); + EnsureTextFinder().NearestFindMatch(point, &distance); std::move(callback).Run(distance); }
diff --git a/third_party/blink/renderer/core/frame/fullscreen_controller.h b/third_party/blink/renderer/core/frame/fullscreen_controller.h index 95957d8a..713a398 100644 --- a/third_party/blink/renderer/core/frame/fullscreen_controller.h +++ b/third_party/blink/renderer/core/frame/fullscreen_controller.h
@@ -32,12 +32,12 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_FULLSCREEN_CONTROLLER_H_ #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/int_size.h" #include "third_party/blink/renderer/platform/graphics/color.h" #include "third_party/blink/renderer/platform/heap/heap_allocator.h" #include "third_party/blink/renderer/platform/heap/persistent.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" +#include "ui/gfx/geometry/point_f.h" namespace blink {
diff --git a/third_party/blink/renderer/core/frame/local_dom_window.cc b/third_party/blink/renderer/core/frame/local_dom_window.cc index 48d440e2..1de9e9bc 100644 --- a/third_party/blink/renderer/core/frame/local_dom_window.cc +++ b/third_party/blink/renderer/core/frame/local_dom_window.cc
@@ -1606,10 +1606,10 @@ } PaintLayerScrollableArea* viewport = view->LayoutViewport(); - gfx::PointF current_position = ToGfxPointF(viewport->ScrollPosition()); + gfx::PointF current_position = viewport->ScrollPosition(); gfx::Vector2dF scaled_delta(x * GetFrame()->PageZoomFactor(), y * GetFrame()->PageZoomFactor()); - FloatPoint new_scaled_position(current_position + scaled_delta); + gfx::PointF new_scaled_position = current_position + scaled_delta; std::unique_ptr<cc::SnapSelectionStrategy> strategy = cc::SnapSelectionStrategy::CreateForEndAndDirection( @@ -1674,12 +1674,12 @@ GetFrame()->PageZoomFactor(); } - FloatPoint new_scaled_position = + gfx::PointF new_scaled_position = viewport->ScrollOffsetToPosition(ScrollOffset(scaled_x, scaled_y)); std::unique_ptr<cc::SnapSelectionStrategy> strategy = cc::SnapSelectionStrategy::CreateForEndPosition( - ToGfxPointF(new_scaled_position), scroll_to_options->hasLeft(), + new_scaled_position, scroll_to_options->hasLeft(), scroll_to_options->hasTop()); new_scaled_position = viewport->GetSnapPositionAndSetTarget(*strategy).value_or(
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 d788ba4d..aae32b8 100644 --- a/third_party/blink/renderer/core/frame/local_frame_view.cc +++ b/third_party/blink/renderer/core/frame/local_frame_view.cc
@@ -177,6 +177,7 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/cursor/cursor.h" #include "ui/base/cursor/mojom/cursor_type.mojom-blink.h" +#include "ui/gfx/geometry/point_conversions.h" // Used to check for dirty layouts violating document lifecycle rules. // If arg evaluates to true, the program will continue. If arg evaluates to @@ -3521,17 +3522,18 @@ gfx::Point LocalFrameView::RootFrameToDocument( const gfx::Point& point_in_root_frame) { - return FlooredIntPoint(RootFrameToDocument(FloatPoint(point_in_root_frame))); + return gfx::ToFlooredPoint( + RootFrameToDocument(gfx::PointF(point_in_root_frame))); } -FloatPoint LocalFrameView::RootFrameToDocument( - const FloatPoint& point_in_root_frame) { +gfx::PointF LocalFrameView::RootFrameToDocument( + const gfx::PointF& point_in_root_frame) { ScrollableArea* layout_viewport = LayoutViewport(); if (!layout_viewport) return point_in_root_frame; - FloatPoint local_frame = ConvertFromRootFrame(point_in_root_frame); - return local_frame + layout_viewport->GetScrollOffset(); + gfx::PointF local_frame = ConvertFromRootFrame(point_in_root_frame); + return local_frame + ToGfxVector2dF(layout_viewport->GetScrollOffset()); } IntRect LocalFrameView::DocumentToFrame(const IntRect& rect_in_document) const { @@ -3554,9 +3556,9 @@ return ToFlooredPoint(DocumentToFrame(DoublePoint(point_in_document))); } -FloatPoint LocalFrameView::DocumentToFrame( - const FloatPoint& point_in_document) const { - return FloatPoint(DocumentToFrame(DoublePoint(point_in_document))); +gfx::PointF LocalFrameView::DocumentToFrame( + const gfx::PointF& point_in_document) const { + return gfx::PointF(DocumentToFrame(DoublePoint(point_in_document))); } PhysicalOffset LocalFrameView::DocumentToFrame( @@ -3648,19 +3650,19 @@ return local_offset; } -FloatPoint LocalFrameView::ConvertToContainingEmbeddedContentView( - const FloatPoint& local_point) const { +gfx::PointF LocalFrameView::ConvertToContainingEmbeddedContentView( + const gfx::PointF& local_point) const { if (ParentFrameView()) { auto* layout_object = GetLayoutEmbeddedContent(); if (!layout_object) return local_point; - PhysicalOffset point = PhysicalOffset::FromFloatPointRound(local_point); + PhysicalOffset point = PhysicalOffset::FromPointFRound(local_point); // Add borders and padding point.left += layout_object->BorderLeft() + layout_object->PaddingLeft(); point.top += layout_object->BorderTop() + layout_object->PaddingTop(); - return FloatPoint(layout_object->LocalToAbsolutePoint(point)); + return gfx::PointF(layout_object->LocalToAbsolutePoint(point)); } return local_point; @@ -3668,13 +3670,13 @@ PhysicalOffset LocalFrameView::ConvertFromContainingEmbeddedContentView( const PhysicalOffset& parent_offset) const { - return PhysicalOffset::FromFloatPointRound( - ConvertFromContainingEmbeddedContentView(FloatPoint(parent_offset))); + return PhysicalOffset::FromPointFRound( + ConvertFromContainingEmbeddedContentView(gfx::PointF(parent_offset))); } -FloatPoint LocalFrameView::ConvertFromContainingEmbeddedContentView( - const FloatPoint& parent_point) const { - return FloatPoint( +gfx::PointF LocalFrameView::ConvertFromContainingEmbeddedContentView( + const gfx::PointF& parent_point) const { + return gfx::PointF( ConvertFromContainingEmbeddedContentView(DoublePoint(parent_point))); } @@ -3687,7 +3689,7 @@ return parent_point; DoublePoint point( - layout_object->AbsoluteToLocalFloatPoint(FloatPoint(parent_point))); + layout_object->AbsoluteToLocalPoint(gfx::PointF(parent_point))); // Subtract borders and padding point.Move( (-layout_object->BorderLeft() - layout_object->PaddingLeft()) @@ -3986,15 +3988,15 @@ PhysicalOffset LocalFrameView::ViewportToFrame( const PhysicalOffset& point_in_viewport) const { - PhysicalOffset point_in_root_frame = PhysicalOffset::FromFloatPointRound( + PhysicalOffset point_in_root_frame = PhysicalOffset::FromPointFRound( frame_->GetPage()->GetVisualViewport().ViewportToRootFrame( - FloatPoint(point_in_viewport))); + gfx::PointF(point_in_viewport))); return ConvertFromRootFrame(point_in_root_frame); } -FloatPoint LocalFrameView::ViewportToFrame( - const FloatPoint& point_in_viewport) const { - FloatPoint point_in_root_frame( +gfx::PointF LocalFrameView::ViewportToFrame( + const gfx::PointF& point_in_viewport) const { + gfx::PointF point_in_root_frame( frame_->GetPage()->GetVisualViewport().ViewportToRootFrame( point_in_viewport)); return ConvertFromRootFrame(point_in_root_frame); @@ -4033,9 +4035,9 @@ gfx::Point LocalFrameView::SoonToBeRemovedUnscaledViewportToContents( const gfx::Point& point_in_viewport) const { - gfx::Point point_in_root_frame = FlooredIntPoint( + gfx::Point point_in_root_frame = gfx::ToFlooredPoint( frame_->GetPage()->GetVisualViewport().ViewportCSSPixelsToRootFrame( - FloatPoint(point_in_viewport))); + gfx::PointF(point_in_viewport))); return ConvertFromRootFrame(point_in_root_frame); } @@ -4249,10 +4251,10 @@ return local_offset; } -FloatPoint LocalFrameView::ConvertToRootFrame( - const FloatPoint& local_point) const { +gfx::PointF LocalFrameView::ConvertToRootFrame( + const gfx::PointF& local_point) const { if (LocalFrameView* parent = ParentFrameView()) { - FloatPoint parent_point = + gfx::PointF parent_point = ConvertToContainingEmbeddedContentView(local_point); return parent->ConvertToRootFrame(parent_point); } @@ -4295,10 +4297,11 @@ return offset_in_root_frame; } -FloatPoint LocalFrameView::ConvertFromRootFrame( - const FloatPoint& point_in_root_frame) const { +gfx::PointF LocalFrameView::ConvertFromRootFrame( + const gfx::PointF& point_in_root_frame) const { if (LocalFrameView* parent = ParentFrameView()) { - FloatPoint parent_point = parent->ConvertFromRootFrame(point_in_root_frame); + gfx::PointF parent_point = + parent->ConvertFromRootFrame(point_in_root_frame); return ConvertFromContainingEmbeddedContentView(parent_point); } return point_in_root_frame;
diff --git a/third_party/blink/renderer/core/frame/local_frame_view.h b/third_party/blink/renderer/core/frame/local_frame_view.h index 0d802446..feecd14f 100644 --- a/third_party/blink/renderer/core/frame/local_frame_view.h +++ b/third_party/blink/renderer/core/frame/local_frame_view.h
@@ -506,7 +506,7 @@ IntRect FrameToViewport(const IntRect&) const; gfx::Point FrameToViewport(const gfx::Point&) const; gfx::Point ViewportToFrame(const gfx::Point&) const; - FloatPoint ViewportToFrame(const FloatPoint&) const; + gfx::PointF ViewportToFrame(const gfx::PointF&) const; PhysicalOffset ViewportToFrame(const PhysicalOffset&) const; // FIXME: Some external callers expect to get back a rect that's positioned @@ -522,18 +522,18 @@ IntRect ConvertToRootFrame(const IntRect&) const; gfx::Point ConvertToRootFrame(const gfx::Point&) const; PhysicalOffset ConvertToRootFrame(const PhysicalOffset&) const; - FloatPoint ConvertToRootFrame(const FloatPoint&) const; + gfx::PointF ConvertToRootFrame(const gfx::PointF&) const; PhysicalRect ConvertToRootFrame(const PhysicalRect&) const; IntRect ConvertFromRootFrame(const IntRect&) const; gfx::Point ConvertFromRootFrame(const gfx::Point&) const; - FloatPoint ConvertFromRootFrame(const FloatPoint&) const; + gfx::PointF ConvertFromRootFrame(const gfx::PointF&) const; PhysicalOffset ConvertFromRootFrame(const PhysicalOffset&) const; IntRect RootFrameToDocument(const IntRect&); gfx::Point RootFrameToDocument(const gfx::Point&); - FloatPoint RootFrameToDocument(const FloatPoint&); + gfx::PointF RootFrameToDocument(const gfx::PointF&); gfx::Point DocumentToFrame(const gfx::Point&) const; - FloatPoint DocumentToFrame(const FloatPoint&) const; + gfx::PointF DocumentToFrame(const gfx::PointF&) const; DoublePoint DocumentToFrame(const DoublePoint&) const; PhysicalOffset DocumentToFrame(const PhysicalOffset&) const; IntRect DocumentToFrame(const IntRect&) const; @@ -906,12 +906,13 @@ gfx::Point ConvertToContainingEmbeddedContentView(const gfx::Point&) const; PhysicalOffset ConvertToContainingEmbeddedContentView( const PhysicalOffset&) const; - FloatPoint ConvertToContainingEmbeddedContentView(const FloatPoint&) const; + gfx::PointF ConvertToContainingEmbeddedContentView(const gfx::PointF&) const; IntRect ConvertFromContainingEmbeddedContentView(const IntRect&) const; gfx::Point ConvertFromContainingEmbeddedContentView(const gfx::Point&) const; PhysicalOffset ConvertFromContainingEmbeddedContentView( const PhysicalOffset&) const; - FloatPoint ConvertFromContainingEmbeddedContentView(const FloatPoint&) const; + gfx::PointF ConvertFromContainingEmbeddedContentView( + const gfx::PointF&) const; DoublePoint ConvertFromContainingEmbeddedContentView( const DoublePoint&) const;
diff --git a/third_party/blink/renderer/core/frame/remote_frame.cc b/third_party/blink/renderer/core/frame/remote_frame.cc index 731c3fa..bb758c5 100644 --- a/third_party/blink/renderer/core/frame/remote_frame.cc +++ b/third_party/blink/renderer/core/frame/remote_frame.cc
@@ -83,7 +83,7 @@ FloatRect DeNormalizeRect(const gfx::RectF& normalized, const IntRect& base) { FloatRect result(normalized); result.Scale(base.width(), base.height()); - result.MoveBy(FloatPoint(base.origin())); + result.MoveBy(gfx::PointF(base.origin())); return result; }
diff --git a/third_party/blink/renderer/core/frame/root_frame_viewport.cc b/third_party/blink/renderer/core/frame/root_frame_viewport.cc index dcabceb..d5c4d344 100644 --- a/third_party/blink/renderer/core/frame/root_frame_viewport.cc +++ b/third_party/blink/renderer/core/frame/root_frame_viewport.cc
@@ -270,11 +270,12 @@ visual_viewport->SetScaleAndLocation( pending_view_state_->page_scale_factor_, visual_viewport->IsPinchGestureActive(), - FloatPoint(visual_viewport_offset)); + gfx::PointAtOffsetFromOrigin(ToGfxVector2dF(visual_viewport_offset))); } else if (should_restore_scale) { visual_viewport->SetScale(pending_view_state_->page_scale_factor_); } else if (should_restore_scroll_) { - visual_viewport->SetLocation(FloatPoint(visual_viewport_offset)); + visual_viewport->SetLocation( + gfx::PointAtOffsetFromOrigin(ToGfxVector2dF(visual_viewport_offset))); } should_restore_scroll_ = false; @@ -345,10 +346,9 @@ if (params->type == mojom::blink::ScrollType::kUser) new_scroll_offset = ClampToUserScrollableOffset(new_scroll_offset); - FloatPoint end_point = ScrollOffsetToPosition(new_scroll_offset); + gfx::PointF end_point = ScrollOffsetToPosition(new_scroll_offset); std::unique_ptr<cc::SnapSelectionStrategy> strategy = - cc::SnapSelectionStrategy::CreateForEndPosition(ToGfxPointF(end_point), - true, true); + cc::SnapSelectionStrategy::CreateForEndPosition(end_point, true, true); if (GetLayoutBox()) { end_point = GetSnapPositionAndSetTarget(*strategy).value_or(end_point); new_scroll_offset = ScrollPositionToOffset(end_point); @@ -679,7 +679,7 @@ LayoutViewport().SetNeedsResnap(needs_resnap); } -absl::optional<FloatPoint> RootFrameViewport::GetSnapPositionAndSetTarget( +absl::optional<gfx::PointF> RootFrameViewport::GetSnapPositionAndSetTarget( const cc::SnapSelectionStrategy& strategy) { return LayoutViewport().GetSnapPositionAndSetTarget(strategy); }
diff --git a/third_party/blink/renderer/core/frame/root_frame_viewport.h b/third_party/blink/renderer/core/frame/root_frame_viewport.h index 30c4c33..ae0ded8 100644 --- a/third_party/blink/renderer/core/frame/root_frame_viewport.h +++ b/third_party/blink/renderer/core/frame/root_frame_viewport.h
@@ -132,7 +132,7 @@ void SetSnapContainerDataNeedsUpdate(bool) override; bool NeedsResnap() const override; void SetNeedsResnap(bool) override; - absl::optional<FloatPoint> GetSnapPositionAndSetTarget( + absl::optional<gfx::PointF> GetSnapPositionAndSetTarget( const cc::SnapSelectionStrategy& strategy) override; void SetPendingHistoryRestoreScrollOffset(
diff --git a/third_party/blink/renderer/core/frame/rotation_viewport_anchor.cc b/third_party/blink/renderer/core/frame/rotation_viewport_anchor.cc index 6c60559..0c959e2 100644 --- a/third_party/blink/renderer/core/frame/rotation_viewport_anchor.cc +++ b/third_party/blink/renderer/core/frame/rotation_viewport_anchor.cc
@@ -15,6 +15,7 @@ #include "third_party/blink/renderer/core/layout/hit_test_result.h" #include "third_party/blink/renderer/core/layout/layout_object.h" #include "third_party/blink/renderer/platform/geometry/double_rect.h" +#include "ui/gfx/geometry/point_conversions.h" namespace blink { @@ -23,10 +24,10 @@ static const float kViewportAnchorRelativeEpsilon = 0.1f; static const int kViewportToNodeMaxRelativeArea = 2; -Node* FindNonEmptyAnchorNode(const FloatPoint& absolute_point, +Node* FindNonEmptyAnchorNode(const gfx::PointF& absolute_point, const IntRect& view_rect, EventHandler& event_handler) { - gfx::Point point = FlooredIntPoint(absolute_point); + gfx::Point point = gfx::ToFlooredPoint(absolute_point); HitTestLocation location(point); Node* node = event_handler @@ -67,9 +68,9 @@ } void MoveToEncloseRect(IntRect& outer, const FloatRect& inner) { - gfx::Point minimum_position = - CeiledIntPoint(inner.origin() + inner.size() - FloatSize(outer.size())); - gfx::Point maximum_position = FlooredIntPoint(inner.origin()); + gfx::Point minimum_position = gfx::ToCeiledPoint( + inner.bottom_right() - gfx::Vector2dF(outer.width(), outer.height())); + gfx::Point maximum_position = gfx::ToFlooredPoint(inner.origin()); gfx::Point outer_origin = outer.origin(); outer_origin.SetToMax(minimum_position); @@ -79,18 +80,19 @@ } void MoveIntoRect(FloatRect& inner, const IntRect& outer) { - FloatPoint minimum_position = FloatPoint(outer.origin()); - FloatPoint maximum_position = minimum_position + outer.size() - inner.size(); + gfx::PointF minimum_position = gfx::PointF(outer.origin()); + gfx::PointF maximum_position = gfx::PointF(outer.bottom_right()) - + gfx::Vector2dF(inner.width(), inner.height()); // Adjust maximumPosition to the nearest lower integer because // VisualViewport::maximumScrollPosition() does the same. // The value of minumumPosition is already adjusted since it is // constructed from an integer point. - maximum_position = FloatPoint(FlooredIntPoint(maximum_position)); + maximum_position = gfx::PointF(gfx::ToFlooredPoint(maximum_position)); - FloatPoint inner_origin = inner.origin(); - inner_origin = inner_origin.ExpandedTo(minimum_position); - inner_origin = inner_origin.ShrunkTo(maximum_position); + gfx::PointF inner_origin = inner.origin(); + inner_origin.SetToMax(minimum_position); + inner_origin.SetToMin(maximum_position); inner.set_origin(inner_origin); } @@ -100,7 +102,7 @@ RotationViewportAnchor::RotationViewportAnchor( LocalFrameView& root_frame_view, VisualViewport& visual_viewport, - const FloatSize& anchor_in_inner_view_coords, + const gfx::PointF& anchor_in_inner_view_coords, PageScaleConstraintsSet& page_scale_constraints_set) : root_frame_view_(&root_frame_view), visual_viewport_(&visual_viewport), @@ -126,12 +128,12 @@ // Save the absolute location in case we won't find the anchor node, we'll // fall back to that. visual_viewport_in_document_ = - FloatPoint(root_frame_viewport->VisibleContentRect().origin()); + gfx::PointF(root_frame_viewport->VisibleContentRect().origin()); anchor_node_ = nullptr; anchor_node_bounds_ = PhysicalRect(); - anchor_in_node_coords_ = FloatSize(); - normalized_visual_viewport_offset_ = FloatSize(); + anchor_in_node_coords_ = gfx::PointF(); + normalized_visual_viewport_offset_ = gfx::Vector2dF(); IntRect inner_view_rect = root_frame_viewport->VisibleContentRect(); @@ -144,20 +146,21 @@ // Normalize by the size of the outer rect DCHECK(!outer_view_rect.IsEmpty()); - normalized_visual_viewport_offset_ = visual_viewport_->GetScrollOffset(); - normalized_visual_viewport_offset_.Scale(1.0 / outer_view_rect.width(), - 1.0 / outer_view_rect.height()); + normalized_visual_viewport_offset_ = gfx::ScaleVector2d( + ToGfxVector2dF(visual_viewport_->GetScrollOffset()), + 1.0 / outer_view_rect.width(), 1.0 / outer_view_rect.height()); // Note, we specifically use the unscaled visual viewport size here as the // conversion into content-space below will apply the scale. - FloatPoint anchor_offset(visual_viewport_->Size()); - anchor_offset.Scale(anchor_in_inner_view_coords_.width(), - anchor_in_inner_view_coords_.height()); + gfx::PointF anchor_offset(visual_viewport_->Size().width(), + visual_viewport_->Size().height()); + anchor_offset.Scale(anchor_in_inner_view_coords_.x(), + anchor_in_inner_view_coords_.y()); // Note, we specifically convert to the rootFrameView contents here, rather // than the layout viewport. That's because hit testing works from the // LocalFrameView's absolute coordinates even if it's not the layout viewport. - const FloatPoint anchor_point_in_document = + const gfx::PointF anchor_point_in_document = root_frame_view_->RootFrameToDocument( visual_viewport_->ViewportToRootFrame(anchor_offset)); @@ -171,7 +174,7 @@ anchor_node_bounds_ = root_frame_view_->FrameToDocument( PhysicalRect(node->GetLayoutObject()->AbsoluteBoundingBoxRect())); anchor_in_node_coords_ = - anchor_point_in_document - FloatPoint(anchor_node_bounds_.offset); + anchor_point_in_document - gfx::Vector2dF(anchor_node_bounds_.offset); anchor_in_node_coords_.Scale(1.f / anchor_node_bounds_.Width(), 1.f / anchor_node_bounds_.Height()); } @@ -188,13 +191,13 @@ visual_viewport_size.Scale(1 / new_page_scale_factor); gfx::Point main_frame_origin; - FloatPoint visual_viewport_origin; + gfx::PointF visual_viewport_origin; ComputeOrigins(visual_viewport_size, main_frame_origin, visual_viewport_origin); LayoutViewport().SetScrollOffset( - ToScrollOffset(FloatPoint(main_frame_origin)), + ToScrollOffset(gfx::PointF(main_frame_origin)), mojom::blink::ScrollType::kProgrammatic); // Set scale before location, since location can be clamped on setting scale. @@ -211,18 +214,19 @@ void RotationViewportAnchor::ComputeOrigins( const FloatSize& inner_size, - gfx::Point& main_frame_offset, - FloatPoint& visual_viewport_offset) const { + gfx::Point& main_frame_origin, + gfx::PointF& visual_viewport_origin) const { IntSize outer_size = LayoutViewport().VisibleContentRect().size(); // Compute the viewport origins in CSS pixels relative to the document. - FloatSize abs_visual_viewport_offset = normalized_visual_viewport_offset_; - abs_visual_viewport_offset.Scale(outer_size.width(), outer_size.height()); + gfx::Vector2dF abs_visual_viewport_offset = + gfx::ScaleVector2d(normalized_visual_viewport_offset_, outer_size.width(), + outer_size.height()); - FloatPoint inner_origin = GetInnerOrigin(inner_size); - FloatPoint outer_origin = inner_origin - abs_visual_viewport_offset; + gfx::PointF inner_origin = GetInnerOrigin(inner_size); + gfx::PointF outer_origin = inner_origin - abs_visual_viewport_offset; - IntRect outer_rect = IntRect(FlooredIntPoint(outer_origin), outer_size); + IntRect outer_rect = IntRect(gfx::ToFlooredPoint(outer_origin), outer_size); FloatRect inner_rect = FloatRect(inner_origin, inner_size); MoveToEncloseRect(outer_rect, inner_rect); @@ -232,12 +236,11 @@ MoveIntoRect(inner_rect, outer_rect); - main_frame_offset = outer_rect.origin(); - visual_viewport_offset = - FloatPoint(inner_rect.origin() - outer_rect.origin()); + main_frame_origin = outer_rect.origin(); + visual_viewport_origin = inner_rect.origin() - outer_rect.OffsetFromOrigin(); } -FloatPoint RotationViewportAnchor::GetInnerOrigin( +gfx::PointF RotationViewportAnchor::GetInnerOrigin( const FloatSize& inner_size) const { if (!anchor_node_ || !anchor_node_->isConnected() || !anchor_node_->GetLayoutObject()) @@ -255,18 +258,19 @@ *root_frame_view_, current_node_bounds); // Compute the new anchor point relative to the node position - FloatSize anchor_offset_from_node( - current_node_bounds_in_layout_viewport.size); - anchor_offset_from_node.Scale(anchor_in_node_coords_.width(), - anchor_in_node_coords_.height()); - FloatPoint anchor_point = - FloatPoint(current_node_bounds_in_layout_viewport.offset) + + gfx::Vector2dF anchor_offset_from_node( + current_node_bounds_in_layout_viewport.size.width, + current_node_bounds_in_layout_viewport.size.height); + anchor_offset_from_node.Scale(anchor_in_node_coords_.x(), + anchor_in_node_coords_.y()); + gfx::PointF anchor_point = + gfx::PointF(current_node_bounds_in_layout_viewport.offset) + anchor_offset_from_node; // Compute the new origin point relative to the new anchor point - FloatSize anchor_offset_from_origin = inner_size; - anchor_offset_from_origin.Scale(anchor_in_inner_view_coords_.width(), - anchor_in_inner_view_coords_.height()); + gfx::Vector2dF anchor_offset_from_origin = gfx::ScaleVector2d( + gfx::Vector2dF(inner_size.width(), inner_size.height()), + anchor_in_inner_view_coords_.x(), anchor_in_inner_view_coords_.y()); return anchor_point - anchor_offset_from_origin; }
diff --git a/third_party/blink/renderer/core/frame/rotation_viewport_anchor.h b/third_party/blink/renderer/core/frame/rotation_viewport_anchor.h index d08018c..36d0f3c 100644 --- a/third_party/blink/renderer/core/frame/rotation_viewport_anchor.h +++ b/third_party/blink/renderer/core/frame/rotation_viewport_anchor.h
@@ -10,6 +10,8 @@ #include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/heap/handle.h" #include "ui/gfx/geometry/point.h" +#include "ui/gfx/geometry/point_f.h" +#include "ui/gfx/geometry/vector2d_f.h" namespace blink { @@ -33,7 +35,7 @@ public: RotationViewportAnchor(LocalFrameView& root_frame_view, VisualViewport&, - const FloatSize& anchor_in_inner_view_coords, + const gfx::PointF& anchor_in_inner_view_coords, PageScaleConstraintsSet&); ~RotationViewportAnchor(); @@ -41,11 +43,11 @@ void SetAnchor(); void RestoreToAnchor(); - FloatPoint GetInnerOrigin(const FloatSize& inner_size) const; + gfx::PointF GetInnerOrigin(const FloatSize& inner_size) const; void ComputeOrigins(const FloatSize& inner_size, - gfx::Point& main_frame_offset, - FloatPoint& visual_viewport_offset) const; + gfx::Point& main_frame_origin, + gfx::PointF& visual_viewport_origin) const; ScrollableArea& LayoutViewport() const; LocalFrameView* root_frame_view_; @@ -55,19 +57,19 @@ float old_minimum_page_scale_factor_; // Inner viewport origin in the reference frame of the document in CSS pixels - FloatPoint visual_viewport_in_document_; + gfx::PointF visual_viewport_in_document_; // Inner viewport origin in the reference frame of the outer viewport // normalized to the outer viewport size. - FloatSize normalized_visual_viewport_offset_; + gfx::Vector2dF normalized_visual_viewport_offset_; Node* anchor_node_; // In Document coordinates. PhysicalRect anchor_node_bounds_; - FloatSize anchor_in_inner_view_coords_; - FloatSize anchor_in_node_coords_; + gfx::PointF anchor_in_inner_view_coords_; + gfx::PointF anchor_in_node_coords_; PageScaleConstraintsSet* page_scale_constraints_set_; };
diff --git a/third_party/blink/renderer/core/frame/visual_viewport.cc b/third_party/blink/renderer/core/frame/visual_viewport.cc index f6aa3e2..d2c79b39 100644 --- a/third_party/blink/renderer/core/frame/visual_viewport.cc +++ b/third_party/blink/renderer/core/frame/visual_viewport.cc
@@ -73,6 +73,7 @@ #include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h" #include "third_party/blink/renderer/platform/instrumentation/tracing/traced_value.h" #include "ui/base/ui_base_features.h" +#include "ui/gfx/geometry/point_conversions.h" namespace blink { @@ -424,7 +425,7 @@ } void VisualViewport::Reset() { - SetScaleAndLocation(1, is_pinch_gesture_active_, FloatPoint()); + SetScaleAndLocation(1, is_pinch_gesture_active_, gfx::PointF()); } void VisualViewport::MainFrameDidChangeSize() { @@ -448,27 +449,30 @@ visible_size.Enlarge(0, browser_controls_adjustment_); visible_size.Scale(1 / scale_); - return FloatRect(FloatPoint(GetScrollOffset()), visible_size); + return FloatRect( + gfx::PointAtOffsetFromOrigin(ToGfxVector2dF(GetScrollOffset())), + visible_size); } -FloatPoint VisualViewport::ViewportCSSPixelsToRootFrame( - const FloatPoint& point) const { +gfx::PointF VisualViewport::ViewportCSSPixelsToRootFrame( + const gfx::PointF& point) const { // Note, this is in CSS Pixels so we don't apply scale. - FloatPoint point_in_root_frame = point; - point_in_root_frame.Offset(GetScrollOffset()); + gfx::PointF point_in_root_frame = point; + point_in_root_frame += ToGfxVector2dF(GetScrollOffset()); return point_in_root_frame; } -void VisualViewport::SetLocation(const FloatPoint& new_location) { +void VisualViewport::SetLocation(const gfx::PointF& new_location) { SetScaleAndLocation(scale_, is_pinch_gesture_active_, new_location); } void VisualViewport::Move(const ScrollOffset& delta) { - SetLocation(FloatPoint(offset_ + delta)); + SetLocation(gfx::PointAtOffsetFromOrigin(ToGfxVector2dF(offset_ + delta))); } void VisualViewport::SetScale(float scale) { - SetScaleAndLocation(scale, is_pinch_gesture_active_, FloatPoint(offset_)); + SetScaleAndLocation(scale, is_pinch_gesture_active_, + gfx::PointAtOffsetFromOrigin(ToGfxVector2dF(offset_))); } double VisualViewport::OffsetLeft() const { @@ -505,7 +509,7 @@ void VisualViewport::SetScaleAndLocation(float scale, bool is_pinch_gesture_active, - const FloatPoint& location) { + const gfx::PointF& location) { if (DidSetScaleOrLocation(scale, is_pinch_gesture_active, location)) { NotifyRootFrameViewport(); Document* document = LocalMainFrame()->GetDocument(); @@ -535,7 +539,7 @@ bool VisualViewport::DidSetScaleOrLocation(float scale, bool is_pinch_gesture_active, - const FloatPoint& location) { + const gfx::PointF& location) { if (!LocalMainFrame()) { is_pinch_gesture_active_ = is_pinch_gesture_active; // The VisualViewport for a remote mainframe must always be 1.0 or else @@ -898,8 +902,9 @@ void VisualViewport::UpdateScrollOffset(const ScrollOffset& position, mojom::blink::ScrollType scroll_type) { - if (!DidSetScaleOrLocation(scale_, is_pinch_gesture_active_, - FloatPoint(position))) { + if (!DidSetScaleOrLocation( + scale_, is_pinch_gesture_active_, + gfx::PointAtOffsetFromOrigin(ToGfxVector2dF(position)))) { return; } if (IsExplicitScrollType(scroll_type)) @@ -946,7 +951,7 @@ } void VisualViewport::ClampToBoundaries() { - SetLocation(FloatPoint(offset_)); + SetLocation(gfx::PointAtOffsetFromOrigin(ToGfxVector2dF(offset_))); } FloatRect VisualViewport::ViewportToRootFrame( @@ -977,34 +982,34 @@ return EnclosingIntRect(RootFrameToViewport(FloatRect(rect_in_root_frame))); } -FloatPoint VisualViewport::ViewportToRootFrame( - const FloatPoint& point_in_viewport) const { - FloatPoint point_in_root_frame = point_in_viewport; - point_in_root_frame.Scale(1 / Scale(), 1 / Scale()); - point_in_root_frame.Offset(GetScrollOffset()); +gfx::PointF VisualViewport::ViewportToRootFrame( + const gfx::PointF& point_in_viewport) const { + gfx::PointF point_in_root_frame = point_in_viewport; + point_in_root_frame.Scale(1 / Scale()); + point_in_root_frame += ToGfxVector2dF(GetScrollOffset()); return point_in_root_frame; } -FloatPoint VisualViewport::RootFrameToViewport( - const FloatPoint& point_in_root_frame) const { - FloatPoint point_in_viewport = point_in_root_frame; - point_in_viewport.Offset(-GetScrollOffset()); - point_in_viewport.Scale(Scale(), Scale()); +gfx::PointF VisualViewport::RootFrameToViewport( + const gfx::PointF& point_in_root_frame) const { + gfx::PointF point_in_viewport = point_in_root_frame; + point_in_viewport -= ToGfxVector2dF(GetScrollOffset()); + point_in_viewport.Scale(Scale()); return point_in_viewport; } gfx::Point VisualViewport::ViewportToRootFrame( const gfx::Point& point_in_viewport) const { // FIXME: How to snap to pixels? - return FlooredIntPoint( - FloatPoint(ViewportToRootFrame(FloatPoint(point_in_viewport)))); + return gfx::ToFlooredPoint( + ViewportToRootFrame(gfx::PointF(point_in_viewport))); } gfx::Point VisualViewport::RootFrameToViewport( const gfx::Point& point_in_root_frame) const { // FIXME: How to snap to pixels? - return FlooredIntPoint( - FloatPoint(RootFrameToViewport(FloatPoint(point_in_root_frame)))); + return gfx::ToFlooredPoint( + RootFrameToViewport(gfx::PointF(point_in_root_frame))); } void VisualViewport::StartTrackingPinchStats() {
diff --git a/third_party/blink/renderer/core/frame/visual_viewport.h b/third_party/blink/renderer/core/frame/visual_viewport.h index 80023cf..103b98f 100644 --- a/third_party/blink/renderer/core/frame/visual_viewport.h +++ b/third_party/blink/renderer/core/frame/visual_viewport.h
@@ -106,7 +106,7 @@ // Sets the location of the visual viewport relative to the outer viewport. // The coordinates are in partial CSS pixels. - void SetLocation(const FloatPoint&); + void SetLocation(const gfx::PointF&); // FIXME: This should be called moveBy void Move(const ScrollOffset&); @@ -131,7 +131,7 @@ // Sets scale and location in one operation, preventing intermediate clamping. void SetScaleAndLocation(float scale, bool is_pinch_gesture_active, - const FloatPoint& location); + const gfx::PointF& location); void SetScale(float); float Scale() const { return scale_; } @@ -140,7 +140,7 @@ // Convert the given rect in the main LocalFrameView's coordinates into a rect // in the viewport. The given and returned rects are in CSS pixels, meaning // scale isn't applied. - FloatPoint ViewportCSSPixelsToRootFrame(const FloatPoint&) const; + gfx::PointF ViewportCSSPixelsToRootFrame(const gfx::PointF&) const; // Clamp the given point, in document coordinates, to the maximum/minimum // scroll extents of the viewport within the document. @@ -169,8 +169,8 @@ FloatRect RootFrameToViewport(const FloatRect&) const; IntRect RootFrameToViewport(const IntRect&) const; - FloatPoint ViewportToRootFrame(const FloatPoint&) const; - FloatPoint RootFrameToViewport(const FloatPoint&) const; + gfx::PointF ViewportToRootFrame(const gfx::PointF&) const; + gfx::PointF RootFrameToViewport(const gfx::PointF&) const; gfx::Point ViewportToRootFrame(const gfx::Point&) const; gfx::Point RootFrameToViewport(const gfx::Point&) const; @@ -231,7 +231,7 @@ // WebViewImpl explicitly rather than via // ScrollingCoordinator::DidCompositorScroll() since it needs to be set in // tandem with the page scale delta. - void DidCompositorScroll(const FloatPoint&) final { NOTREACHED(); } + void DidCompositorScroll(const gfx::PointF&) final { NOTREACHED(); } // Visual Viewport API implementation. double OffsetLeft() const; @@ -281,7 +281,7 @@ private: bool DidSetScaleOrLocation(float scale, bool is_pinch_gesture_active, - const FloatPoint& location); + const gfx::PointF& location); void CreateLayers(); void UpdateStyleAndLayout(DocumentUpdateReason) const;
diff --git a/third_party/blink/renderer/core/frame/visual_viewport_test.cc b/third_party/blink/renderer/core/frame/visual_viewport_test.cc index 4819443..c146c6ee 100644 --- a/third_party/blink/renderer/core/frame/visual_viewport_test.cc +++ b/third_party/blink/renderer/core/frame/visual_viewport_test.cc
@@ -305,7 +305,7 @@ // Scroll visual viewport and verify visibleContentRect. size.Scale(0.5); scrollbar_size.Scale(0.5); - visual_viewport.SetLocation(FloatPoint(10, 10)); + visual_viewport.SetLocation(gfx::PointF(10, 10)); EXPECT_EQ(IntRect(gfx::Point(10, 10), size - scrollbar_size), visual_viewport.VisibleContentRect(kExcludeScrollbars)); EXPECT_EQ(IntRect(gfx::Point(10, 10), size), @@ -408,7 +408,7 @@ // Scroll visual viewport to the bottom of the main frame VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); - visual_viewport.SetLocation(FloatPoint(0, 300)); + visual_viewport.SetLocation(gfx::PointF(0, 300)); EXPECT_FLOAT_SIZE_EQ(FloatSize(0, 300), visual_viewport.GetScrollOffset()); // Verify the initial size of the visual viewport in the CSS pixels @@ -496,7 +496,7 @@ // Scroll visual viewport to the right edge of the frame VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); - visual_viewport.SetLocation(FloatPoint(150, 0)); + visual_viewport.SetLocation(gfx::PointF(150, 0)); EXPECT_FLOAT_SIZE_EQ(FloatSize(150, 0), visual_viewport.GetScrollOffset()); // Verify the initial size of the visual viewport in the CSS pixels @@ -563,7 +563,7 @@ visual_viewport.SetSize(size); // Scale the viewport to 2X; size should not change. - FloatRect expected_rect(FloatPoint(0, 0), FloatSize(size)); + FloatRect expected_rect(gfx::PointF(0, 0), FloatSize(size)); expected_rect.Scale(0.5); visual_viewport.SetScale(2); EXPECT_EQ(2, visual_viewport.Scale()); @@ -571,23 +571,23 @@ EXPECT_FLOAT_RECT_EQ(expected_rect, visual_viewport.VisibleRect()); // Move the viewport. - expected_rect.set_origin(FloatPoint(5, 7)); + expected_rect.set_origin(gfx::PointF(5, 7)); visual_viewport.SetLocation(expected_rect.origin()); EXPECT_FLOAT_RECT_EQ(expected_rect, visual_viewport.VisibleRect()); - expected_rect.set_origin(FloatPoint(200, 100)); + expected_rect.set_origin(gfx::PointF(200, 100)); visual_viewport.SetLocation(expected_rect.origin()); EXPECT_FLOAT_RECT_EQ(expected_rect, visual_viewport.VisibleRect()); // Scale the viewport to 3X to introduce some non-int values. - FloatPoint oldLocation = expected_rect.origin(); - expected_rect = FloatRect(FloatPoint(), FloatSize(size)); + gfx::PointF oldLocation = expected_rect.origin(); + expected_rect = FloatRect(gfx::PointF(), FloatSize(size)); expected_rect.Scale(1 / 3.0f); expected_rect.set_origin(oldLocation); visual_viewport.SetScale(3); EXPECT_FLOAT_RECT_EQ(expected_rect, visual_viewport.VisibleRect()); - expected_rect.set_origin(FloatPoint(0.25f, 0.333f)); + expected_rect.set_origin(gfx::PointF(0.25f, 0.333f)); visual_viewport.SetLocation(expected_rect.origin()); EXPECT_FLOAT_RECT_EQ(expected_rect, visual_viewport.VisibleRect()); } @@ -627,45 +627,45 @@ // possible. At minimum scale, the viewport is 1280x960. VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); ASSERT_EQ(0.25, visual_viewport.Scale()); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 0), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(-1, -2)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), + visual_viewport.SetLocation(gfx::PointF(-1, -2)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 0), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(100, 200)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), + visual_viewport.SetLocation(gfx::PointF(100, 200)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 0), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(-5, 10)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), + visual_viewport.SetLocation(gfx::PointF(-5, 10)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 0), visual_viewport.VisibleRect().origin()); // Scale to 2x. The viewport's visible rect should now have a size of 160x120. visual_viewport.SetScale(2); - FloatPoint location(10, 50); + gfx::PointF location(10, 50); visual_viewport.SetLocation(location); EXPECT_FLOAT_POINT_EQ(location, visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(10000, 10000)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(1120, 840), + visual_viewport.SetLocation(gfx::PointF(10000, 10000)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(1120, 840), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(-2000, -2000)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), + visual_viewport.SetLocation(gfx::PointF(-2000, -2000)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 0), visual_viewport.VisibleRect().origin()); // Make sure offset gets clamped on scale out. Scale to 1.25 so the viewport // is 256x192. - visual_viewport.SetLocation(FloatPoint(1120, 840)); + visual_viewport.SetLocation(gfx::PointF(1120, 840)); visual_viewport.SetScale(1.25); - EXPECT_FLOAT_POINT_EQ(FloatPoint(1024, 768), + EXPECT_FLOAT_POINT_EQ(gfx::PointF(1024, 768), visual_viewport.VisibleRect().origin()); // Scale out smaller than 1. visual_viewport.SetScale(0.25); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 0), visual_viewport.VisibleRect().origin()); } @@ -682,59 +682,59 @@ // Visual viewport should be initialized to same size as frame so no scrolling // possible. VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 0), visual_viewport.VisibleRect().origin()); // Shrink the viewport vertically. The resize shouldn't affect the location, // but it should allow vertical scrolling. visual_viewport.SetSize(IntSize(320, 200)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 0), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(10, 20)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 20), + visual_viewport.SetLocation(gfx::PointF(10, 20)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 20), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(0, 100)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 40), + visual_viewport.SetLocation(gfx::PointF(0, 100)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 40), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(0, 10)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 10), + visual_viewport.SetLocation(gfx::PointF(0, 10)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 10), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(0, -100)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), + visual_viewport.SetLocation(gfx::PointF(0, -100)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 0), visual_viewport.VisibleRect().origin()); // Repeat the above but for horizontal dimension. visual_viewport.SetSize(IntSize(280, 240)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 0), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(10, 20)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(10, 0), + visual_viewport.SetLocation(gfx::PointF(10, 20)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(10, 0), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(100, 0)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(40, 0), + visual_viewport.SetLocation(gfx::PointF(100, 0)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(40, 0), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(10, 0)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(10, 0), + visual_viewport.SetLocation(gfx::PointF(10, 0)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(10, 0), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(-100, 0)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), + visual_viewport.SetLocation(gfx::PointF(-100, 0)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 0), visual_viewport.VisibleRect().origin()); // Now with both dimensions. visual_viewport.SetSize(IntSize(280, 200)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 0), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(10, 20)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(10, 20), + visual_viewport.SetLocation(gfx::PointF(10, 20)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(10, 20), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(100, 100)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(40, 40), + visual_viewport.SetLocation(gfx::PointF(100, 100)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(40, 40), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(10, 3)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(10, 3), + visual_viewport.SetLocation(gfx::PointF(10, 3)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(10, 3), visual_viewport.VisibleRect().origin()); - visual_viewport.SetLocation(FloatPoint(-10, -4)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), + visual_viewport.SetLocation(gfx::PointF(-10, -4)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 0), visual_viewport.VisibleRect().origin()); } @@ -750,20 +750,20 @@ // Visual viewport should be initialized to same size as WebView so no // scrolling possible. VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), + EXPECT_FLOAT_POINT_EQ(gfx::PointF(0, 0), visual_viewport.VisibleRect().origin()); // Zoom in to 2X so we can scroll the viewport to 160x120. visual_viewport.SetScale(2); - visual_viewport.SetLocation(FloatPoint(200, 200)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(160, 120), + visual_viewport.SetLocation(gfx::PointF(200, 200)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(160, 120), visual_viewport.VisibleRect().origin()); // Now resize the viewport to make it 10px smaller. Since we're zoomed in by // 2X it should allow us to scroll by 5px more. visual_viewport.SetSize(IntSize(310, 230)); - visual_viewport.SetLocation(FloatPoint(200, 200)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(165, 125), + visual_viewport.SetLocation(gfx::PointF(200, 200)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(165, 125), visual_viewport.VisibleRect().origin()); // The viewport can be larger than the main frame (currently 320, 240) though @@ -779,15 +779,15 @@ visual_viewport.Size()); EXPECT_EQ(IntSize(WebView()->MainFrameViewWidget()->Size()), GetFrame()->View()->FrameRect().size()); - visual_viewport.SetLocation(FloatPoint(1000, 1000)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(320, 240), + visual_viewport.SetLocation(gfx::PointF(1000, 1000)); + EXPECT_FLOAT_POINT_EQ(gfx::PointF(320, 240), visual_viewport.VisibleRect().origin()); // Make sure resizing the viewport doesn't change its offset if the resize // doesn't make the viewport go out of bounds. - visual_viewport.SetLocation(FloatPoint(200, 200)); + visual_viewport.SetLocation(gfx::PointF(200, 200)); visual_viewport.SetSize(IntSize(880, 560)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(200, 200), + EXPECT_FLOAT_POINT_EQ(gfx::PointF(200, 200), visual_viewport.VisibleRect().origin()); } @@ -914,15 +914,15 @@ original_focus); WebView()->SetPageScaleFactor(2); - visual_viewport.SetLocation(FloatPoint(100, 400)); + visual_viewport.SetLocation(gfx::PointF(100, 400)); gfx::Rect anchor; gfx::Rect focus; WebView()->MainFrameViewWidget()->CalculateSelectionBounds(anchor, focus); gfx::Point expected = original_anchor.origin(); - expected -= gfx::ToFlooredVector2d( - ToGfxVector2dF(visual_viewport.VisibleRect().origin())); + expected -= + gfx::ToFlooredVector2d(visual_viewport.VisibleRect().OffsetFromOrigin()); expected = gfx::ScaleToRoundedPoint(expected, visual_viewport.Scale()); EXPECT_EQ(expected, IntRect(anchor).origin()); @@ -959,7 +959,7 @@ ->GetViewState() ->page_scale_factor_); - visual_viewport.SetLocation(FloatPoint(10, 20)); + visual_viewport.SetLocation(gfx::PointF(10, 20)); EXPECT_EQ(ScrollOffset(10, 20), To<LocalFrame>(WebView()->GetPage()->MainFrame()) @@ -991,7 +991,7 @@ VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); EXPECT_EQ(2, visual_viewport.Scale()); - EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 120), + EXPECT_FLOAT_POINT_EQ(gfx::PointF(100, 120), visual_viewport.VisibleRect().origin()); } @@ -1022,7 +1022,7 @@ EXPECT_EQ(2, visual_viewport.Scale()); EXPECT_EQ(ScrollOffset(100, 150), GetFrame()->View()->LayoutViewport()->GetScrollOffset()); - EXPECT_FLOAT_POINT_EQ(FloatPoint(20, 30), + EXPECT_FLOAT_POINT_EQ(gfx::PointF(20, 30), visual_viewport.VisibleRect().origin()); } @@ -1045,7 +1045,7 @@ VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); visual_viewport.SetScale(2); - visual_viewport.SetLocation(FloatPoint(350, 350)); + visual_viewport.SetLocation(gfx::PointF(350, 350)); Persistent<HistoryItem> firstItem = WebView() ->MainFrameImpl() @@ -1189,7 +1189,7 @@ VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); WebView()->SetPageScaleFactor(2); EXPECT_CALL(mock_web_frame_client, DidChangeScrollOffset()); - visual_viewport.SetLocation(FloatPoint(60, 80)); + visual_viewport.SetLocation(gfx::PointF(60, 80)); EXPECT_CALL( mock_web_frame_client, UpdateContextMenuDataForTesting( @@ -1223,17 +1223,17 @@ VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); EXPECT_CALL(mock_web_frame_client, DidChangeScrollOffset()); - visual_viewport.SetLocation(FloatPoint(60, 80)); + visual_viewport.SetLocation(gfx::PointF(60, 80)); Mock::VerifyAndClearExpectations(&mock_web_frame_client); // Scroll vertically. EXPECT_CALL(mock_web_frame_client, DidChangeScrollOffset()); - visual_viewport.SetLocation(FloatPoint(60, 90)); + visual_viewport.SetLocation(gfx::PointF(60, 90)); Mock::VerifyAndClearExpectations(&mock_web_frame_client); // Scroll horizontally. EXPECT_CALL(mock_web_frame_client, DidChangeScrollOffset()); - visual_viewport.SetLocation(FloatPoint(70, 90)); + visual_viewport.SetLocation(gfx::PointF(70, 90)); // Reset the old client so destruction can occur naturally. WebView()->MainFrameImpl()->SetClient(old_client); @@ -1760,19 +1760,19 @@ IntRect bounds = input_element->GetLayoutObject()->AbsoluteBoundingBoxRect(); VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); - FloatPoint scrollDelta(250, 400); + gfx::PointF scrollDelta(250, 400); visual_viewport.SetScale(2); visual_viewport.SetLocation(scrollDelta); const IntRect bounds_in_viewport = input_element->BoundsInViewport(); IntRect expectedBounds = bounds; expectedBounds.Scale(2.f); - FloatPoint expectedScrollDelta = scrollDelta; + gfx::PointF expectedScrollDelta = scrollDelta; expectedScrollDelta.Scale(2.f, 2.f); - EXPECT_EQ(RoundedIntPoint(FloatPoint(FloatPoint(expectedBounds.origin()) - - expectedScrollDelta)), - bounds_in_viewport.origin()); + EXPECT_EQ(gfx::ToRoundedVector2d(gfx::PointF(expectedBounds.origin()) - + expectedScrollDelta), + bounds_in_viewport.OffsetFromOrigin()); EXPECT_EQ(expectedBounds.size(), bounds_in_viewport.size()); } @@ -2000,44 +2000,47 @@ // At scale = 1 the transform should be a no-op. visual_viewport.SetScale(1); EXPECT_FLOAT_POINT_EQ( - FloatPoint(314, 273), - visual_viewport.ViewportToRootFrame(FloatPoint(314, 273))); + gfx::PointF(314, 273), + visual_viewport.ViewportToRootFrame(gfx::PointF(314, 273))); EXPECT_FLOAT_POINT_EQ( - FloatPoint(314, 273), - visual_viewport.RootFrameToViewport(FloatPoint(314, 273))); + gfx::PointF(314, 273), + visual_viewport.RootFrameToViewport(gfx::PointF(314, 273))); // At scale = 2. visual_viewport.SetScale(2); - EXPECT_FLOAT_POINT_EQ(FloatPoint(55, 75), visual_viewport.ViewportToRootFrame( - FloatPoint(110, 150))); EXPECT_FLOAT_POINT_EQ( - FloatPoint(110, 150), - visual_viewport.RootFrameToViewport(FloatPoint(55, 75))); + gfx::PointF(55, 75), + visual_viewport.ViewportToRootFrame(gfx::PointF(110, 150))); + EXPECT_FLOAT_POINT_EQ( + gfx::PointF(110, 150), + visual_viewport.RootFrameToViewport(gfx::PointF(55, 75))); // At scale = 2 and with the visual viewport offset. - visual_viewport.SetLocation(FloatPoint(10, 12)); - EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 62), visual_viewport.ViewportToRootFrame( - FloatPoint(80, 100))); + visual_viewport.SetLocation(gfx::PointF(10, 12)); EXPECT_FLOAT_POINT_EQ( - FloatPoint(80, 100), - visual_viewport.RootFrameToViewport(FloatPoint(50, 62))); + gfx::PointF(50, 62), + visual_viewport.ViewportToRootFrame(gfx::PointF(80, 100))); + EXPECT_FLOAT_POINT_EQ( + gfx::PointF(80, 100), + visual_viewport.RootFrameToViewport(gfx::PointF(50, 62))); // Test points that will cause non-integer values. EXPECT_FLOAT_POINT_EQ( - FloatPoint(50.5, 62.4), - visual_viewport.ViewportToRootFrame(FloatPoint(81, 100.8))); + gfx::PointF(50.5, 62.4), + visual_viewport.ViewportToRootFrame(gfx::PointF(81, 100.8))); EXPECT_FLOAT_POINT_EQ( - FloatPoint(81, 100.8), - visual_viewport.RootFrameToViewport(FloatPoint(50.5, 62.4))); + gfx::PointF(81, 100.8), + visual_viewport.RootFrameToViewport(gfx::PointF(50.5, 62.4))); // Scrolling the main frame should have no effect. frame_view.LayoutViewport()->SetScrollOffset( ScrollOffset(100, 120), mojom::blink::ScrollType::kProgrammatic); - EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 62), visual_viewport.ViewportToRootFrame( - FloatPoint(80, 100))); EXPECT_FLOAT_POINT_EQ( - FloatPoint(80, 100), - visual_viewport.RootFrameToViewport(FloatPoint(50, 62))); + gfx::PointF(50, 62), + visual_viewport.ViewportToRootFrame(gfx::PointF(80, 100))); + EXPECT_FLOAT_POINT_EQ( + gfx::PointF(80, 100), + visual_viewport.RootFrameToViewport(gfx::PointF(50, 62))); } // Tests that the window dimensions are available before a full layout occurs. @@ -2756,7 +2759,7 @@ // Scroll visual viewport to the right edge of the frame VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); - visual_viewport.SetScaleAndLocation(2.f, true, FloatPoint(150, 10)); + visual_viewport.SetScaleAndLocation(2.f, true, gfx::PointF(150, 10)); EXPECT_FLOAT_SIZE_EQ(FloatSize(150, 10), visual_viewport.GetScrollOffset()); EXPECT_EQ(2.f, visual_viewport.Scale()); @@ -2765,7 +2768,7 @@ // Update the scale and location and ensure that a PaintArtifactCompositor // update is not required. - visual_viewport.SetScaleAndLocation(3.f, true, FloatPoint(120, 10)); + visual_viewport.SetScaleAndLocation(3.f, true, gfx::PointF(120, 10)); UpdateAllLifecyclePhasesExceptPaint(); EXPECT_FALSE(paint_artifact_compositor()->NeedsUpdate()); @@ -2841,11 +2844,11 @@ VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); visual_viewport.DisposeImpl(); ASSERT_FALSE(visual_viewport.LayerForScrolling()); - visual_viewport.SetScaleAndLocation(1.75, false, FloatPoint(12, 34)); - EXPECT_EQ(FloatPoint(12, 34), visual_viewport.ScrollPosition()); + visual_viewport.SetScaleAndLocation(1.75, false, gfx::PointF(12, 34)); + EXPECT_EQ(gfx::PointF(12, 34), visual_viewport.ScrollPosition()); UpdateAllLifecyclePhases(); - EXPECT_EQ(FloatPoint(12, 34), visual_viewport.ScrollPosition()); + EXPECT_EQ(gfx::PointF(12, 34), visual_viewport.ScrollPosition()); // When we create the scrolling layer, we should update its scroll offset. ASSERT_TRUE(visual_viewport.LayerForScrolling());
diff --git a/third_party/blink/renderer/core/frame/web_frame_test.cc b/third_party/blink/renderer/core/frame/web_frame_test.cc index 4f68628..a9d9906 100644 --- a/third_party/blink/renderer/core/frame/web_frame_test.cc +++ b/third_party/blink/renderer/core/frame/web_frame_test.cc
@@ -2407,7 +2407,7 @@ web_view_helper.GetWebView()->GetSettings()->SetForceZeroLayoutHeight(true); web_view_helper.Resize(gfx::Size(viewport_width, viewport_height)); - FloatPoint hit_point = FloatPoint(30, 30); // button size is 100x100 + gfx::PointF hit_point = gfx::PointF(30, 30); // button size is 100x100 WebLocalFrameImpl* frame = web_view_helper.LocalMainFrame(); Document* document = frame->GetFrame()->GetDocument(); @@ -2421,8 +2421,8 @@ WebInputEvent::GetStaticTimeStampForTests(), WebGestureDevice::kTouchscreen); gesture_event.SetFrameScale(1); - gesture_event.SetPositionInWidget(ToGfxPointF(hit_point)); - gesture_event.SetPositionInScreen(ToGfxPointF(hit_point)); + gesture_event.SetPositionInWidget(hit_point); + gesture_event.SetPositionInScreen(hit_point); web_view_helper.GetWebView() ->MainFrameImpl() ->GetFrame() @@ -3244,14 +3244,6 @@ class WebFrameResizeTest : public WebFrameTest { protected: - static FloatSize ComputeRelativeOffset(const gfx::Point& absolute_offset, - const LayoutRect& rect) { - FloatSize relative_offset = - FloatPoint(absolute_offset) - FloatPoint(rect.Location()); - relative_offset.Scale(1.f / rect.Width(), 1.f / rect.Height()); - return relative_offset; - } - void TestResizeYieldsCorrectScrollAndScale( const char* url, const float initial_page_scale_factor, @@ -5163,7 +5155,7 @@ // Select the match by the center of its rect. EXPECT_EQ(main_frame->EnsureTextFinder().SelectNearestFindMatch( - ToGfxPointF(result_rect.CenterPoint()), nullptr), + result_rect.CenterPoint(), nullptr), result_index + 1); // Check that the find result ordering matches with our expectations. @@ -6491,26 +6483,26 @@ .As<v8::Int32>() ->Value(); - FloatPoint hit_point; + gfx::PointF hit_point; if (expected_result.Length() >= 17) { - hit_point = FloatPoint(expected_result.Get(context, 15) - .ToLocalChecked() - .As<v8::Int32>() - ->Value(), - expected_result.Get(context, 16) - .ToLocalChecked() - .As<v8::Int32>() - ->Value()); + hit_point = gfx::PointF(expected_result.Get(context, 15) + .ToLocalChecked() + .As<v8::Int32>() + ->Value(), + expected_result.Get(context, 16) + .ToLocalChecked() + .As<v8::Int32>() + ->Value()); } else { hit_point = - FloatPoint((start_edge_start_in_layer_x + start_edge_end_in_layer_x + - end_edge_start_in_layer_x + end_edge_end_in_layer_x) / - 4, - (start_edge_start_in_layer_y + start_edge_end_in_layer_y + - end_edge_start_in_layer_y + end_edge_end_in_layer_y) / - 4 + - 3); + gfx::PointF((start_edge_start_in_layer_x + start_edge_end_in_layer_x + + end_edge_start_in_layer_x + end_edge_end_in_layer_x) / + 4, + (start_edge_start_in_layer_y + start_edge_end_in_layer_y + + end_edge_start_in_layer_y + end_edge_end_in_layer_y) / + 4 + + 3); } WebGestureEvent gesture_event(WebInputEvent::Type::kGestureTap, @@ -6518,8 +6510,8 @@ WebInputEvent::GetStaticTimeStampForTests(), WebGestureDevice::kTouchscreen); gesture_event.SetFrameScale(1); - gesture_event.SetPositionInWidget(ToGfxPointF(hit_point)); - gesture_event.SetPositionInScreen(ToGfxPointF(hit_point)); + gesture_event.SetPositionInWidget(hit_point); + gesture_event.SetPositionInScreen(hit_point); web_view_helper_.GetWebView() ->MainFrameImpl() @@ -7363,7 +7355,7 @@ auto* scrollable_area = frame_impl->GetFrameView()->LayoutViewport(); // Do a compositor scroll, verify that this is counted as a user scroll. - scrollable_area->DidCompositorScroll(FloatPoint(0, 1)); + scrollable_area->DidCompositorScroll(gfx::PointF(0, 1)); web_view_helper.GetWebView() ->MainFrameWidget() ->ApplyViewportChangesForTesting({gfx::Vector2dF(), gfx::Vector2dF(), @@ -7376,7 +7368,7 @@ initial_scroll_state.was_scrolled_by_user = false; // The page scale 1.0f and scroll. - scrollable_area->DidCompositorScroll(FloatPoint(0, 2)); + scrollable_area->DidCompositorScroll(gfx::PointF(0, 2)); web_view_helper.GetWebView() ->MainFrameWidget() ->ApplyViewportChangesForTesting({gfx::Vector2dF(), gfx::Vector2dF(), @@ -7388,7 +7380,7 @@ initial_scroll_state.was_scrolled_by_user = false; // No scroll event if there is no scroll delta. - scrollable_area->DidCompositorScroll(FloatPoint(0, 2)); + scrollable_area->DidCompositorScroll(gfx::PointF(0, 2)); web_view_helper.GetWebView() ->MainFrameWidget() ->ApplyViewportChangesForTesting({gfx::Vector2dF(), gfx::Vector2dF(), @@ -7399,7 +7391,7 @@ client.Reset(); // Non zero page scale and scroll. - scrollable_area->DidCompositorScroll(FloatPoint(9, 15)); + scrollable_area->DidCompositorScroll(gfx::PointF(9, 15)); web_view_helper.GetWebView() ->MainFrameWidget() ->ApplyViewportChangesForTesting({gfx::Vector2dF(), gfx::Vector2dF(), @@ -12256,14 +12248,14 @@ ASSERT_EQ(2ul, web_match_rects.size()); FloatRect result_rect = static_cast<FloatRect>(web_match_rects[0]); - frame->EnsureTextFinder().SelectNearestFindMatch( - ToGfxPointF(result_rect.CenterPoint()), nullptr); + frame->EnsureTextFinder().SelectNearestFindMatch(result_rect.CenterPoint(), + nullptr); EXPECT_TRUE(frame_view->GetScrollableArea()->VisibleContentRect().Contains( box1_rect)); result_rect = static_cast<FloatRect>(web_match_rects[1]); - frame->EnsureTextFinder().SelectNearestFindMatch( - ToGfxPointF(result_rect.CenterPoint()), nullptr); + frame->EnsureTextFinder().SelectNearestFindMatch(result_rect.CenterPoint(), + nullptr); EXPECT_TRUE( frame_view->GetScrollableArea()->VisibleContentRect().Contains(box2_rect)) @@ -12408,7 +12400,7 @@ frame_view->GetScrollableArea()->SetScrollOffset( ScrollOffset(0, 0), mojom::blink::ScrollType::kProgrammatic); - ASSERT_EQ(FloatPoint(), + ASSERT_EQ(gfx::Point(), frame_view->GetScrollableArea()->VisibleContentRect().origin()); WebView() @@ -12419,8 +12411,9 @@ EXPECT_EQ(1, WebView().FakePageScaleAnimationPageScaleForTesting()); frame_view->LayoutViewport()->SetScrollOffset( - ToFloatSize(FloatPoint( - WebView().FakePageScaleAnimationTargetPositionForTesting())), + FloatSize(gfx::PointF( + WebView().FakePageScaleAnimationTargetPositionForTesting()) + .OffsetFromOrigin()), mojom::blink::ScrollType::kProgrammatic); EXPECT_TRUE(frame_view->GetScrollableArea()->VisibleContentRect().Contains( @@ -12450,8 +12443,9 @@ ->FrameWidget() ->ScrollFocusedEditableElementIntoView(); frame_view->GetScrollableArea()->SetScrollOffset( - ToFloatSize(FloatPoint( - WebView().FakePageScaleAnimationTargetPositionForTesting())), + FloatSize(gfx::PointF( + WebView().FakePageScaleAnimationTargetPositionForTesting()) + .OffsetFromOrigin()), mojom::blink::ScrollType::kProgrammatic); EXPECT_TRUE(frame_view->GetScrollableArea()->VisibleContentRect().Contains( @@ -12524,7 +12518,7 @@ LocalFrameView* frame_view = frame->View(); IntRect inputRect(200, 700, 100, 20); ASSERT_EQ(1, visual_viewport.Scale()); - ASSERT_EQ(FloatPoint(0, 300), + ASSERT_EQ(gfx::Point(0, 300), frame_view->GetScrollableArea()->VisibleContentRect().origin()); ASSERT_FALSE(frame_view->GetScrollableArea()->VisibleContentRect().Contains( inputRect)); @@ -12536,8 +12530,9 @@ EXPECT_EQ(1, WebView().FakePageScaleAnimationPageScaleForTesting()); - ScrollOffset target_offset = ToFloatSize( - FloatPoint(WebView().FakePageScaleAnimationTargetPositionForTesting())); + ScrollOffset target_offset = FloatSize( + gfx::PointF(WebView().FakePageScaleAnimationTargetPositionForTesting()) + .OffsetFromOrigin()); rs_controller.RootScrollerArea()->SetScrollOffset( target_offset, mojom::blink::ScrollType::kProgrammatic); @@ -12606,7 +12601,7 @@ LocalFrameView* frame_view = frame->View(); VisualViewport& visual_viewport = frame->GetPage()->GetVisualViewport(); - ASSERT_EQ(FloatPoint(), + ASSERT_EQ(gfx::Point(), frame_view->GetScrollableArea()->VisibleContentRect().origin()); // Simulate the keyboard being shown and resizing the widget. Cause a scroll @@ -12755,8 +12750,8 @@ gfx::Rect block_bounds = ComputeBlockBoundHelper(&WebView(), point, false); WebView().AnimateDoubleTapZoom(point, block_bounds); EXPECT_TRUE(WebView().FakeDoubleTapAnimationPendingForTesting()); - ScrollOffset new_offset = ToScrollOffset( - FloatPoint(WebView().FakePageScaleAnimationTargetPositionForTesting())); + ScrollOffset new_offset = ToScrollOffset(gfx::PointF( + WebView().FakePageScaleAnimationTargetPositionForTesting())); float new_scale = WebView().FakePageScaleAnimationPageScaleForTesting(); visual_viewport.SetScale(new_scale); frame_view->GetScrollableArea()->SetScrollOffset(
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 389c7f70..123ad36 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
@@ -161,7 +161,7 @@ FloatRect NormalizeRect(const IntRect& to_normalize, const IntRect& base_rect) { FloatRect result(to_normalize); result.set_origin( - FloatPoint(to_normalize.origin() - base_rect.OffsetFromOrigin())); + gfx::PointF(to_normalize.origin() - base_rect.OffsetFromOrigin())); result.Scale(1.0 / base_rect.width(), 1.0 / base_rect.height()); return result; } @@ -232,7 +232,7 @@ if (!object->IsBox()) return viz::FrameSinkId(); - gfx::Point local_point = ToRoundedPoint(result.LocalPoint()); + LayoutPoint local_point(ToRoundedPoint(result.LocalPoint())); if (!To<LayoutBox>(object)->ComputedCSSContentBoxRect().Contains(local_point)) return viz::FrameSinkId(); @@ -410,8 +410,8 @@ } gfx::PointF point_in_root_frame(ViewportToRootFrame(point_in_viewport)); - DragData drag_data(current_drag_data_.Get(), FloatPoint(point_in_root_frame), - FloatPoint(screen_point), operations_allowed_); + DragData drag_data(current_drag_data_.Get(), point_in_root_frame, + screen_point, operations_allowed_); GetPage()->GetDragController().DragExited(&drag_data, *local_root_->GetFrame()); @@ -448,9 +448,8 @@ if (!IgnoreInputEvents()) { current_drag_data_->SetModifiers(key_modifiers); - DragData drag_data(current_drag_data_.Get(), - FloatPoint(point_in_root_frame), - FloatPoint(screen_point), operations_allowed_); + DragData drag_data(current_drag_data_.Get(), point_in_root_frame, + screen_point, operations_allowed_); GetPage()->GetDragController().PerformDrag(&drag_data, *local_root_->GetFrame()); @@ -474,9 +473,8 @@ CancelDrag(); return; } - gfx::PointF point_in_root_frame( - ToGfxPointF(GetPage()->GetVisualViewport().ViewportToRootFrame( - FloatPoint(point_in_viewport)))); + gfx::PointF point_in_root_frame = + GetPage()->GetVisualViewport().ViewportToRootFrame(point_in_viewport); WebMouseEvent fake_mouse_move( WebInputEvent::Type::kMouseMove, point_in_root_frame, screen_point, @@ -583,13 +581,12 @@ viz::FrameSinkId remote_frame_sink_id = GetRemoteFrameSinkId(result); if (remote_frame_sink_id.is_valid()) { - FloatPoint local_point = FloatPoint(result.LocalPoint()); + gfx::PointF local_point(result.LocalPoint()); LayoutObject* object = result_node->GetLayoutObject(); if (auto* box = DynamicTo<LayoutBox>(object)) - local_point.MoveBy(-FloatPoint(box->PhysicalContentBoxOffset())); + local_point -= gfx::Vector2dF(box->PhysicalContentBoxOffset()); - *local_point_in_dips = - widget_base_->BlinkSpaceToDIPs(ToGfxPointF(local_point)); + *local_point_in_dips = widget_base_->BlinkSpaceToDIPs(local_point); return remote_frame_sink_id; } @@ -798,8 +795,8 @@ transformed_event.id = PointerEventFactory::kMouseId; // Find the right target frame. See issue 1186900. - HitTestResult result = HitTestResultForRootFramePos( - FloatPoint(transformed_event.PositionInRootFrame())); + HitTestResult result = + HitTestResultForRootFramePos(transformed_event.PositionInRootFrame()); Frame* target_frame; if (result.InnerNodeOrImageMapImage()) target_frame = result.InnerNodeOrImageMapImage()->GetDocument().GetFrame(); @@ -862,7 +859,7 @@ web_view->MinimumPageScaleFactor() != web_view->MaximumPageScaleFactor()) { gfx::Point pos_in_local_frame_root = - FlooredIntPoint(scaled_event.PositionInRootFrame()); + gfx::ToFlooredPoint(scaled_event.PositionInRootFrame()); auto block_bounds = ComputeBlockBound(pos_in_local_frame_root, false); if (ForMainFrame()) { @@ -1097,11 +1094,11 @@ return DragOperation::kNone; } - FloatPoint point_in_root_frame(ViewportToRootFrame(point_in_viewport)); + gfx::PointF point_in_root_frame = ViewportToRootFrame(point_in_viewport); current_drag_data_->SetModifiers(key_modifiers); - DragData drag_data(current_drag_data_.Get(), FloatPoint(point_in_root_frame), - FloatPoint(screen_point), operations_allowed_); + DragData drag_data(current_drag_data_.Get(), point_in_root_frame, + screen_point, operations_allowed_); DragOperation drag_operation = GetPage()->GetDragController().DragEnteredOrUpdated( @@ -1179,8 +1176,7 @@ gfx::PointF WebFrameWidgetImpl::ViewportToRootFrame( const gfx::PointF& point_in_viewport) const { - return ToGfxPointF(GetPage()->GetVisualViewport().ViewportToRootFrame( - FloatPoint(point_in_viewport))); + return GetPage()->GetVisualViewport().ViewportToRootFrame(point_in_viewport); } WebViewImpl* WebFrameWidgetImpl::View() const { @@ -2818,8 +2814,7 @@ HitTestResult WebFrameWidgetImpl::CoreHitTestResultAt( const gfx::PointF& point_in_viewport) { LocalFrameView* view = LocalRootImpl()->GetFrameView(); - FloatPoint point_in_root_frame( - view->ViewportToFrame(FloatPoint(point_in_viewport))); + gfx::PointF point_in_root_frame(view->ViewportToFrame(point_in_viewport)); return HitTestResultForRootFramePos(point_in_root_frame); } @@ -4026,8 +4021,8 @@ } HitTestResult WebFrameWidgetImpl::HitTestResultForRootFramePos( - const FloatPoint& pos_in_root_frame) { - FloatPoint doc_point = + const gfx::PointF& pos_in_root_frame) { + gfx::PointF doc_point = LocalRootImpl()->GetFrame()->View()->ConvertFromRootFrame( pos_in_root_frame); HitTestLocation location(doc_point);
diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_impl.h b/third_party/blink/renderer/core/frame/web_frame_widget_impl.h index 98a79154..5d4b2597a 100644 --- a/third_party/blink/renderer/core/frame/web_frame_widget_impl.h +++ b/third_party/blink/renderer/core/frame/web_frame_widget_impl.h
@@ -81,7 +81,6 @@ namespace blink { class AnimationWorkletMutatorDispatcherImpl; -class FloatPoint; class HitTestResult; class HTMLPlugInElement; class Page; @@ -877,7 +876,7 @@ // Perform a hit test for a point relative to the root frame of the page. HitTestResult HitTestResultForRootFramePos( - const FloatPoint& pos_in_root_frame); + const gfx::PointF& pos_in_root_frame); // Called during |UpdateVisualProperties| to apply the new size to the widget. void ApplyVisualPropertiesSizing(const VisualProperties& visual_properties);
diff --git a/third_party/blink/renderer/core/frame/web_local_frame_impl.cc b/third_party/blink/renderer/core/frame/web_local_frame_impl.cc index 3eab50a..d6db7ad 100644 --- a/third_party/blink/renderer/core/frame/web_local_frame_impl.cc +++ b/third_party/blink/renderer/core/frame/web_local_frame_impl.cc
@@ -774,14 +774,14 @@ gfx::PointF WebLocalFrameImpl::GetScrollOffset() const { if (ScrollableArea* scrollable_area = LayoutViewport()) - return ToGfxPointF(scrollable_area->ScrollPosition()); + return scrollable_area->ScrollPosition(); return gfx::PointF(); } void WebLocalFrameImpl::SetScrollOffset(const gfx::PointF& offset) { if (ScrollableArea* scrollable_area = LayoutViewport()) { scrollable_area->SetScrollOffset( - scrollable_area->ScrollPositionToOffset(FloatPoint(offset)), + scrollable_area->ScrollPositionToOffset(offset), mojom::blink::ScrollType::kProgrammatic); } }
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 590ea1a..8aa0fe30 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
@@ -595,7 +595,7 @@ if (context_->IsComposited()) { // Composited 2D canvases need the dirty rect to be expressed relative // to the content box, as opposed to the layout box. - mapped_dirty_rect.MoveBy(-content_rect.origin()); + mapped_dirty_rect.Offset(-content_rect.OffsetFromOrigin()); } invalidation_rect = mapped_dirty_rect; } else { @@ -812,8 +812,8 @@ // Place the icon near the upper left, like the missing image icon // for image elements. Offset it a bit from the upper corner. FloatSize icon_size(broken_canvas->Size()); - FloatPoint upper_left = - FloatPoint(r.PixelSnappedOffset()) + icon_size.ScaledBy(0.5f); + gfx::PointF upper_left = gfx::PointF(r.PixelSnappedOffset()) + + ToGfxVector2dF(icon_size.ScaledBy(0.5f)); context.DrawImage( broken_canvas, Image::kSyncDecode, PaintAutoDarkMode(ComputedStyleRef(), @@ -885,7 +885,7 @@ !context_ || context_->CreationAttributes().alpha ? SkBlendMode::kSrcOver : SkBlendMode::kSrc; - FloatRect src_rect = FloatRect(FloatPoint(), FloatSize(Size())); + FloatRect src_rect = FloatRect(gfx::PointF(), FloatSize(Size())); scoped_refptr<StaticBitmapImage> snapshot = canvas2d_bridge_ ? canvas2d_bridge_->NewImageSnapshot()
diff --git a/third_party/blink/renderer/core/html/forms/file_input_type_test.cc b/third_party/blink/renderer/core/html/forms/file_input_type_test.cc index f43f30b..ef9ce6fa 100644 --- a/third_party/blink/renderer/core/html/forms/file_input_type_test.cc +++ b/third_party/blink/renderer/core/html/forms/file_input_type_test.cc
@@ -73,8 +73,8 @@ InputType* file_input = MakeGarbageCollected<FileInputType>(*input); DataObject* native_file_raw_drag_data = DataObject::Create(); - const DragData native_file_drag_data(native_file_raw_drag_data, FloatPoint(), - FloatPoint(), kDragOperationCopy); + const DragData native_file_drag_data(native_file_raw_drag_data, gfx::PointF(), + gfx::PointF(), kDragOperationCopy); native_file_drag_data.PlatformData()->Add( MakeGarbageCollected<File>("/native/path")); native_file_drag_data.PlatformData()->SetFilesystemId("fileSystemId"); @@ -85,7 +85,7 @@ DataObject* non_native_file_raw_drag_data = DataObject::Create(); const DragData non_native_file_drag_data(non_native_file_raw_drag_data, - FloatPoint(), FloatPoint(), + gfx::PointF(), gfx::PointF(), kDragOperationCopy); FileMetadata metadata; metadata.length = 1234; @@ -145,7 +145,7 @@ base::RunLoop run_loop; MockFileChooser chooser(doc.GetFrame()->GetBrowserInterfaceBroker(), run_loop.QuitClosure()); - DragData drag_data(DataObject::Create(), FloatPoint(), FloatPoint(), + DragData drag_data(DataObject::Create(), gfx::PointF(), gfx::PointF(), kDragOperationCopy); drag_data.PlatformData()->Add(MakeGarbageCollected<File>("/foo/bar")); input.ReceiveDroppedFiles(&drag_data);
diff --git a/third_party/blink/renderer/core/html/forms/spin_button_element.cc b/third_party/blink/renderer/core/html/forms/spin_button_element.cc index 689388395..b2f1ede 100644 --- a/third_party/blink/renderer/core/html/forms/spin_button_element.cc +++ b/third_party/blink/renderer/core/html/forms/spin_button_element.cc
@@ -38,6 +38,7 @@ #include "third_party/blink/renderer/core/page/chrome_client.h" #include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/core/scroll/scrollbar_theme.h" +#include "ui/gfx/geometry/point_conversions.h" namespace blink { @@ -81,8 +82,8 @@ return; } - gfx::Point local = RoundedIntPoint(box->AbsoluteToLocalFloatPoint( - FloatPoint(mouse_event->AbsoluteLocation()))); + gfx::Point local = gfx::ToRoundedPoint( + box->AbsoluteToLocalPoint(gfx::PointF(mouse_event->AbsoluteLocation()))); if (mouse_event->type() == event_type_names::kMousedown && mouse_event->button() == static_cast<int16_t>(WebPointerProperties::Button::kLeft)) {
diff --git a/third_party/blink/renderer/core/html/html_anchor_element.cc b/third_party/blink/renderer/core/html/html_anchor_element.cc index 35aa152..58e0b67a 100644 --- a/third_party/blink/renderer/core/html/html_anchor_element.cc +++ b/third_party/blink/renderer/core/html/html_anchor_element.cc
@@ -173,13 +173,13 @@ // The coordinates sent in the query string are relative to the height and // width of the image element, ignoring CSS transform/zoom. - FloatPoint map_point = layout_object->AbsoluteToLocalFloatPoint( - FloatPoint(mouse_event->AbsoluteLocation())); + gfx::PointF map_point = layout_object->AbsoluteToLocalPoint( + gfx::PointF(mouse_event->AbsoluteLocation())); // The origin (0,0) is at the upper left of the content area, inside the // padding and border. map_point -= - FloatSize(To<LayoutBox>(layout_object)->PhysicalContentBoxOffset()); + gfx::Vector2dF(To<LayoutBox>(layout_object)->PhysicalContentBoxOffset()); // CSS zoom is not reflected in the map coordinates. float scale_factor = 1 / layout_object->Style()->EffectiveZoom(); @@ -187,7 +187,7 @@ // Negative coordinates are clamped to 0 such that clicks in the left and // top padding/border areas receive an X or Y coordinate of 0. - gfx::Point clamped_point = RoundedIntPoint(map_point); + gfx::Point clamped_point = gfx::ToRoundedPoint(map_point); clamped_point.SetToMax(gfx::Point()); url.Append('?');
diff --git a/third_party/blink/renderer/core/html/track/vtt/vtt_cue.cc b/third_party/blink/renderer/core/html/track/vtt/vtt_cue.cc index 16dd831..531560d 100644 --- a/third_party/blink/renderer/core/html/track/vtt/vtt_cue.cc +++ b/third_party/blink/renderer/core/html/track/vtt/vtt_cue.cc
@@ -171,7 +171,7 @@ SetInlineStyleProperty(CSSPropertyID::kWebkitWritingMode, display_parameters.writing_mode); - const FloatPoint& position = display_parameters.position; + const gfx::PointF& position = display_parameters.position; // the 'top' property must be set to top, SetInlineStyleProperty(CSSPropertyID::kTop, position.y(),
diff --git a/third_party/blink/renderer/core/html/track/vtt/vtt_cue.h b/third_party/blink/renderer/core/html/track/vtt/vtt_cue.h index 04cab19c..fb1aa9e 100644 --- a/third_party/blink/renderer/core/html/track/vtt/vtt_cue.h +++ b/third_party/blink/renderer/core/html/track/vtt/vtt_cue.h
@@ -31,9 +31,9 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_HTML_TRACK_VTT_VTT_CUE_H_ #include "third_party/blink/renderer/core/html/track/text_track_cue.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -52,7 +52,7 @@ public: VTTDisplayParameters(); - FloatPoint position; + gfx::PointF position; double size; CSSValueID direction; CSSValueID text_align;
diff --git a/third_party/blink/renderer/core/input/event_handler.cc b/third_party/blink/renderer/core/input/event_handler.cc index 5d03d8c..ee30b6d4 100644 --- a/third_party/blink/renderer/core/input/event_handler.cc +++ b/third_party/blink/renderer/core/input/event_handler.cc
@@ -101,7 +101,6 @@ #include "third_party/blink/renderer/core/svg/graphics/svg_image_for_container.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/cursors.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/graphics/image.h" #include "third_party/blink/renderer/platform/graphics/image_orientation.h" @@ -117,6 +116,7 @@ #include "ui/base/cursor/mojom/cursor_type.mojom-blink.h" #include "ui/base/dragdrop/mojom/drag_drop_types.mojom-blink.h" #include "ui/gfx/geometry/point.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -410,12 +410,12 @@ mouse_event_manager_->MousePressNode()); } -FloatPoint EventHandler::LastKnownMousePositionInRootFrame() const { +gfx::PointF EventHandler::LastKnownMousePositionInRootFrame() const { return frame_->GetPage()->GetVisualViewport().ViewportToRootFrame( mouse_event_manager_->LastKnownMousePositionInViewport()); } -FloatPoint EventHandler::LastKnownMouseScreenPosition() const { +gfx::PointF EventHandler::LastKnownMouseScreenPosition() const { return mouse_event_manager_->LastKnownMouseScreenPosition(); } @@ -789,7 +789,7 @@ // Save the document point we generate in case the window coordinate is // invalidated by what happens when we dispatch the event. PhysicalOffset document_point = frame_->View()->ConvertFromRootFrame( - PhysicalOffset(FlooredIntPoint(mouse_event.PositionInRootFrame()))); + PhysicalOffset(gfx::ToFlooredPoint(mouse_event.PositionInRootFrame()))); MouseEventWithHitTestResults mev = GetMouseEventTarget(request, mouse_event); if (!mev.InnerNode()) { // An anonymous box can be scrollable. @@ -869,7 +869,7 @@ ? mev.InnerNode()->GetLayoutObject()->EnclosingLayer() : nullptr; gfx::Point p = view->ConvertFromRootFrame( - FlooredIntPoint(mouse_event.PositionInRootFrame())); + gfx::ToFlooredPoint(mouse_event.PositionInRootFrame())); if (layer && layer->GetScrollableArea() && layer->GetScrollableArea()->IsPointInResizeControl( p, kResizerForPointer)) { @@ -1265,8 +1265,8 @@ if (AutoscrollController* controller = scroll_manager_->GetAutoscrollController()) { - controller->UpdateDragAndDrop( - new_target, FloatPoint(event.PositionInRootFrame()), event.TimeStamp()); + controller->UpdateDragAndDrop(new_target, event.PositionInRootFrame(), + event.TimeStamp()); } if (drag_target_ != new_target) { @@ -1641,7 +1641,7 @@ } void EventHandler::CacheTouchAdjustmentResult(uint32_t id, - FloatPoint adjusted_point) { + gfx::PointF adjusted_point) { touch_adjustment_result_.unique_event_id = id; touch_adjustment_result_.adjusted_point = adjusted_point; } @@ -1661,9 +1661,11 @@ // Check if the adjusted point is in the gesture event tap rect. // If not, should not use this touch point in following events. if (should_use_touch_event_adjusted_point_) { - FloatRect tap_rect(FloatPoint(event.PositionInRootFrame()) - - FloatSize(event.TapAreaInRootFrame()) * 0.5, - FloatSize(event.TapAreaInRootFrame())); + FloatSize size(event.TapAreaInRootFrame()); + FloatRect tap_rect( + event.PositionInRootFrame() - + gfx::Vector2dF(size.width() * 0.5, size.height() * 0.5), + size); should_use_touch_event_adjusted_point_ = tap_rect.InclusiveContains(touch_adjustment_result_.adjusted_point); } @@ -1947,7 +1949,7 @@ // point-base hit test. Otherwise add padding and do rect-based hit test. if (GestureCorrespondsToAdjustedTouch(gesture_event)) { adjusted_event.ApplyTouchAdjustment( - ToGfxPointF(touch_adjustment_result_.adjusted_point)); + touch_adjustment_result_.adjusted_point); } else { hit_rect_size = GetHitTestRectForAdjustment( *frame_, LayoutSize(adjusted_event.TapAreaInRootFrame())); @@ -1960,13 +1962,12 @@ LocalFrame& root_frame = frame_->LocalFrameRoot(); HitTestResult hit_test_result; if (hit_rect_size.IsEmpty()) { - location = - HitTestLocation(FloatPoint(adjusted_event.PositionInRootFrame())); + location = HitTestLocation(adjusted_event.PositionInRootFrame()); hit_test_result = root_frame.GetEventHandler().HitTestResultAtLocation( location, hit_type); } else { - PhysicalOffset top_left = PhysicalOffset::FromFloatPointRound( - FloatPoint(adjusted_event.PositionInRootFrame())); + PhysicalOffset top_left = + PhysicalOffset::FromPointFRound(adjusted_event.PositionInRootFrame()); top_left -= PhysicalOffset(hit_rect_size * 0.5f); location = HitTestLocation(PhysicalRect(top_left, hit_rect_size)); hit_test_result = root_frame.GetEventHandler().HitTestResultAtLocation( @@ -1986,8 +1987,7 @@ LocalFrame* hit_frame = hit_test_result.InnerNodeFrame(); if (!hit_frame) hit_frame = frame_; - location = - HitTestLocation(FloatPoint(adjusted_event.PositionInRootFrame())); + location = HitTestLocation(adjusted_event.PositionInRootFrame()); hit_test_result = root_frame.GetEventHandler().HitTestResultAtLocation( location, (hit_type | HitTestRequest::kReadOnly) & ~HitTestRequest::kListBased); @@ -2006,7 +2006,7 @@ HitTestResult* hit_test_result) { Node* adjusted_node = nullptr; gfx::Point adjusted_point = - FlooredIntPoint(gesture_event->PositionInRootFrame()); + gfx::ToFlooredPoint(gesture_event->PositionInRootFrame()); bool adjusted = false; switch (gesture_event->GetType()) { case WebInputEvent::Type::kGestureTap: @@ -2032,7 +2032,7 @@ // crbug.com/398914 if (adjusted) { PhysicalOffset point(frame_->View()->ConvertFromRootFrame(adjusted_point)); - DCHECK(location.ContainsPoint(FloatPoint(point))); + DCHECK(location.ContainsPoint(gfx::PointF(point))); DCHECK(location.IsRectBasedTest()); location = hit_test_result->ResolveRectBasedTest(adjusted_node, point); gesture_event->ApplyTouchAdjustment( @@ -2053,8 +2053,8 @@ if (last_scrollbar_under_mouse_) last_scrollbar_under_mouse_->MouseUp(event); - PhysicalOffset position_in_contents( - v->ConvertFromRootFrame(FlooredIntPoint(event.PositionInRootFrame()))); + PhysicalOffset position_in_contents(v->ConvertFromRootFrame( + gfx::ToFlooredPoint(event.PositionInRootFrame()))); HitTestRequest request(HitTestRequest::kActive); MouseEventWithHitTestResults mev = frame_->GetDocument()->PerformMouseEventHitTest( @@ -2471,7 +2471,7 @@ const WebMouseEvent& event) { PhysicalOffset document_point = event_handling_util::ContentPointFromRootFrame( - frame_, FloatPoint(event.PositionInRootFrame())); + frame_, event.PositionInRootFrame()); // TODO(eirage): This does not handle chorded buttons yet. if (event.GetType() != WebInputEvent::Type::kMouseDown) {
diff --git a/third_party/blink/renderer/core/input/event_handler.h b/third_party/blink/renderer/core/input/event_handler.h index 52daf5a..51fb9fb 100644 --- a/third_party/blink/renderer/core/input/event_handler.h +++ b/third_party/blink/renderer/core/input/event_handler.h
@@ -129,8 +129,8 @@ void ResizeScrollableAreaDestroyed(); - FloatPoint LastKnownMousePositionInRootFrame() const; - FloatPoint LastKnownMouseScreenPosition() const; + gfx::PointF LastKnownMousePositionInRootFrame() const; + gfx::PointF LastKnownMouseScreenPosition() const; gfx::Point DragDataTransferLocationForTesting(); @@ -204,7 +204,7 @@ const HitTestResult&, gfx::Point& target_point, Node*& target_node); - void CacheTouchAdjustmentResult(uint32_t, FloatPoint); + void CacheTouchAdjustmentResult(uint32_t, gfx::PointF); // Dispatch a context menu event. If |override_target_element| is provided, // the context menu event will use that, so that the browser-generated context
diff --git a/third_party/blink/renderer/core/input/event_handler_test.cc b/third_party/blink/renderer/core/input/event_handler_test.cc index c3cc6b2..a78311b 100644 --- a/third_party/blink/renderer/core/input/event_handler_test.cc +++ b/third_party/blink/renderer/core/input/event_handler_test.cc
@@ -116,13 +116,13 @@ class TapEventBuilder : public WebGestureEvent { public: - TapEventBuilder(FloatPoint position, int tap_count) + TapEventBuilder(gfx::PointF position, int tap_count) : WebGestureEvent(WebInputEvent::Type::kGestureTap, WebInputEvent::kNoModifiers, base::TimeTicks::Now(), WebGestureDevice::kTouchscreen) { - SetPositionInWidget(ToGfxPointF(position)); - SetPositionInScreen(ToGfxPointF(position)); + SetPositionInWidget(position); + SetPositionInScreen(position); data.tap.tap_count = tap_count; data.tap.width = 5; data.tap.height = 5; @@ -132,13 +132,13 @@ class TapDownEventBuilder : public WebGestureEvent { public: - TapDownEventBuilder(FloatPoint position) + explicit TapDownEventBuilder(gfx::PointF position) : WebGestureEvent(WebInputEvent::Type::kGestureTapDown, WebInputEvent::kNoModifiers, base::TimeTicks::Now(), WebGestureDevice::kTouchscreen) { - SetPositionInWidget(ToGfxPointF(position)); - SetPositionInScreen(ToGfxPointF(position)); + SetPositionInWidget(position); + SetPositionInScreen(position); data.tap_down.width = 5; data.tap_down.height = 5; frame_scale_ = 1; @@ -147,13 +147,13 @@ class ShowPressEventBuilder : public WebGestureEvent { public: - ShowPressEventBuilder(FloatPoint position) + explicit ShowPressEventBuilder(gfx::PointF position) : WebGestureEvent(WebInputEvent::Type::kGestureShowPress, WebInputEvent::kNoModifiers, base::TimeTicks::Now(), WebGestureDevice::kTouchscreen) { - SetPositionInWidget(ToGfxPointF(position)); - SetPositionInScreen(ToGfxPointF(position)); + SetPositionInWidget(position); + SetPositionInScreen(position); data.show_press.width = 5; data.show_press.height = 5; frame_scale_ = 1; @@ -162,13 +162,13 @@ class LongPressEventBuilder : public WebGestureEvent { public: - LongPressEventBuilder(FloatPoint position) + explicit LongPressEventBuilder(gfx::PointF position) : WebGestureEvent(WebInputEvent::Type::kGestureLongPress, WebInputEvent::kNoModifiers, base::TimeTicks::Now(), WebGestureDevice::kTouchscreen) { - SetPositionInWidget(ToGfxPointF(position)); - SetPositionInScreen(ToGfxPointF(position)); + SetPositionInWidget(position); + SetPositionInScreen(position); data.long_press.width = 5; data.long_press.height = 5; frame_scale_ = 1; @@ -285,7 +285,7 @@ Node* line = GetDocument().getElementById("line")->firstChild(); - TapEventBuilder single_tap_event(FloatPoint(0, 0), 1); + TapEventBuilder single_tap_event(gfx::PointF(0, 0), 1); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( single_tap_event); ASSERT_TRUE(Selection().GetSelectionInDOMTree().IsCaret()); @@ -293,7 +293,7 @@ // Multi-tap events on editable elements should trigger selection, just // like multi-click events. - TapEventBuilder double_tap_event(FloatPoint(0, 0), 2); + TapEventBuilder double_tap_event(gfx::PointF(0, 0), 2); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( double_tap_event); ASSERT_TRUE(Selection().GetSelectionInDOMTree().IsRange()); @@ -309,7 +309,7 @@ EXPECT_EQ("One", Selection().SelectedText().Utf8()); } - TapEventBuilder triple_tap_event(FloatPoint(0, 0), 3); + TapEventBuilder triple_tap_event(gfx::PointF(0, 0), 3); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( triple_tap_event); ASSERT_TRUE(Selection().GetSelectionInDOMTree().IsRange()); @@ -326,20 +326,20 @@ Node* line = GetDocument().getElementById("line")->firstChild(); - TapEventBuilder single_tap_event(FloatPoint(0, 0), 1); + TapEventBuilder single_tap_event(gfx::PointF(0, 0), 1); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( single_tap_event); ASSERT_TRUE(Selection().GetSelectionInDOMTree().IsCaret()); EXPECT_EQ(Position(line, 0), Selection().GetSelectionInDOMTree().Base()); // As the text is readonly, multi-tap events should not trigger selection. - TapEventBuilder double_tap_event(FloatPoint(0, 0), 2); + TapEventBuilder double_tap_event(gfx::PointF(0, 0), 2); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( double_tap_event); ASSERT_TRUE(Selection().GetSelectionInDOMTree().IsCaret()); EXPECT_EQ(Position(line, 0), Selection().GetSelectionInDOMTree().Base()); - TapEventBuilder triple_tap_event(FloatPoint(0, 0), 3); + TapEventBuilder triple_tap_event(gfx::PointF(0, 0), 3); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( triple_tap_event); ASSERT_TRUE(Selection().GetSelectionInDOMTree().IsCaret()); @@ -836,7 +836,7 @@ TEST_F(EventHandlerTest, EmptyTextfieldInsertionOnTap) { SetHtmlInnerHTML("<textarea cols=50 rows=50></textarea>"); - TapEventBuilder single_tap_event(FloatPoint(200, 200), 1); + TapEventBuilder single_tap_event(gfx::PointF(200, 200), 1); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( single_tap_event); @@ -847,7 +847,7 @@ TEST_F(EventHandlerTest, NonEmptyTextfieldInsertionOnTap) { SetHtmlInnerHTML("<textarea cols=50 rows=50>Enter text</textarea>"); - TapEventBuilder single_tap_event(FloatPoint(200, 200), 1); + TapEventBuilder single_tap_event(gfx::PointF(200, 200), 1); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( single_tap_event); @@ -858,7 +858,7 @@ TEST_F(EventHandlerTest, NewlineDivInsertionOnTap) { SetHtmlInnerHTML("<div contenteditable><br/></div>"); - TapEventBuilder single_tap_event(FloatPoint(10, 10), 1); + TapEventBuilder single_tap_event(gfx::PointF(10, 10), 1); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( single_tap_event); @@ -869,7 +869,7 @@ TEST_F(EventHandlerTest, EmptyTextfieldInsertionOnLongPress) { SetHtmlInnerHTML("<textarea cols=50 rows=50></textarea>"); - LongPressEventBuilder long_press_event(FloatPoint(200, 200)); + LongPressEventBuilder long_press_event(gfx::PointF(200, 200)); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( long_press_event); @@ -877,7 +877,7 @@ ASSERT_TRUE(Selection().IsHandleVisible()); // Single Tap on an empty edit field should clear insertion handle - TapEventBuilder single_tap_event(FloatPoint(200, 200), 1); + TapEventBuilder single_tap_event(gfx::PointF(200, 200), 1); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( single_tap_event); @@ -888,7 +888,7 @@ TEST_F(EventHandlerTest, NonEmptyTextfieldInsertionOnLongPress) { SetHtmlInnerHTML("<textarea cols=50 rows=50>Enter text</textarea>"); - LongPressEventBuilder long_press_event(FloatPoint(200, 200)); + LongPressEventBuilder long_press_event(gfx::PointF(200, 200)); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( long_press_event); @@ -900,7 +900,7 @@ SetHtmlInnerHTML("<textarea cols=50 rows=10>Enter text</textarea>"); // Show handle - LongPressEventBuilder long_press_event(FloatPoint(200, 10)); + LongPressEventBuilder long_press_event(gfx::PointF(200, 10)); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( long_press_event); @@ -908,7 +908,7 @@ ASSERT_TRUE(Selection().IsHandleVisible()); // Tap away from text area should clear handle - TapEventBuilder single_tap_event(FloatPoint(200, 350), 1); + TapEventBuilder single_tap_event(gfx::PointF(200, 350), 1); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( single_tap_event); @@ -961,7 +961,7 @@ SetHtmlInnerHTML("<textarea cols=50 rows=50>Mispellinggg</textarea>"); - TapEventBuilder single_tap_event(FloatPoint(10, 10), 1); + TapEventBuilder single_tap_event(gfx::PointF(10, 10), 1); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( single_tap_event); @@ -983,11 +983,11 @@ TEST_F(EventHandlerTest, TouchAdjustmentOnEditableDisplayContents) { SetHtmlInnerHTML( "<div style='display:contents' contenteditable='true'>TEXT</div>"); - TapEventBuilder single_tap_event(FloatPoint(1, 1), 1); + TapEventBuilder single_tap_event(gfx::PointF(1, 1), 1); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( single_tap_event); - LongPressEventBuilder long_press_event(FloatPoint(1, 1)); + LongPressEventBuilder long_press_event(gfx::PointF(1, 1)); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent( long_press_event); @@ -1251,7 +1251,7 @@ Element* element = GetDocument().getElementById("b"); gfx::PointF mouse_press_point = - ToGfxPointF(FloatPoint(element->BoundsInViewport().CenterPoint())); + gfx::PointF(element->BoundsInViewport().CenterPoint()); WebMouseEvent mouse_press_event( WebInputEvent::Type::kMouseDown, mouse_press_point, mouse_press_point, WebPointerProperties::Button::kLeft, 1, @@ -1741,7 +1741,7 @@ // kGestureTapDown sets the pressed parts which is a pre-requisite for // kGestureTap performing a scroll. - const FloatPoint scrollbar_forward_track(495, 450); + const gfx::PointF scrollbar_forward_track(495, 450); TapDownEventBuilder tap_down(scrollbar_forward_track); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent(tap_down); @@ -1968,17 +1968,17 @@ To<HTMLIFrameElement>(GetDocument().getElementById("iframe")); Document* iframe_doc = iframe_element->contentDocument(); - TapDownEventBuilder tap_down(FloatPoint(10, 10)); + TapDownEventBuilder tap_down(gfx::PointF(10, 10)); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent(tap_down); - ShowPressEventBuilder show_press(FloatPoint(10, 10)); + ShowPressEventBuilder show_press(gfx::PointF(10, 10)); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent(show_press); // TapDown and ShowPress active the iframe. EXPECT_TRUE(GetDocument().GetActiveElement()); EXPECT_TRUE(iframe_doc->GetActiveElement()); - TapEventBuilder tap(FloatPoint(10, 10), 1); + TapEventBuilder tap(gfx::PointF(10, 10), 1); GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent(tap); // Should still active. @@ -2042,7 +2042,7 @@ // Do a compositor scroll and set |hover_needs_update_at_scroll_end| to be // true in WebViewImpl. LocalFrameView* frame_view = GetDocument().View(); - frame_view->LayoutViewport()->DidCompositorScroll(FloatPoint(0, 500)); + frame_view->LayoutViewport()->DidCompositorScroll(gfx::PointF(0, 500)); WebView().MainFrameWidget()->ApplyViewportChangesForTesting( {gfx::Vector2dF(), gfx::Vector2dF(), 1.0f, false, 0, 0, cc::BrowserControlsState::kBoth, true}); @@ -3182,7 +3182,7 @@ EXPECT_EQ(iframe_doc->GetFrame() ->GetEventHandler() .LastKnownMousePositionInRootFrame(), - FloatPoint(100, 100)); + gfx::PointF(100, 100)); EXPECT_EQ(iframe_doc->HoverElement(), target); EXPECT_FALSE(target->hasPointerCapture(PointerEventFactory::kMouseId)); @@ -3281,7 +3281,7 @@ EXPECT_EQ(iframe_doc->GetFrame() ->GetEventHandler() .LastKnownMousePositionInRootFrame(), - FloatPoint(100, 300)); + gfx::PointF(100, 300)); EXPECT_EQ(iframe_doc->HoverElement(), target); // Release capture and move event will be send to outer frame.
diff --git a/third_party/blink/renderer/core/input/event_handling_util.cc b/third_party/blink/renderer/core/input/event_handling_util.cc index 3cca8dc..711b89d 100644 --- a/third_party/blink/renderer/core/input/event_handling_util.cc +++ b/third_party/blink/renderer/core/input/event_handling_util.cc
@@ -118,11 +118,11 @@ PhysicalOffset ContentPointFromRootFrame( LocalFrame* frame, - const FloatPoint& point_in_root_frame) { + const gfx::PointF& point_in_root_frame) { LocalFrameView* view = frame->View(); // FIXME: Is it really OK to use the wrong coordinates here when view is 0? // Historically the code would just crash; this is clearly no worse than that. - return PhysicalOffset::FromFloatPointRound( + return PhysicalOffset::FromPointFRound( view ? view->ConvertFromRootFrame(point_in_root_frame) : point_in_root_frame); } @@ -135,8 +135,7 @@ DCHECK(frame->GetDocument()); return frame->GetDocument()->PerformMouseEventHitTest( - request, - ContentPointFromRootFrame(frame, FloatPoint(mev.PositionInRootFrame())), + request, ContentPointFromRootFrame(frame, mev.PositionInRootFrame()), mev); }
diff --git a/third_party/blink/renderer/core/input/event_handling_util.h b/third_party/blink/renderer/core/input/event_handling_util.h index f8d4cbb..eb852c7 100644 --- a/third_party/blink/renderer/core/input/event_handling_util.h +++ b/third_party/blink/renderer/core/input/event_handling_util.h
@@ -42,7 +42,7 @@ ContainerNode* ParentForClickEventInteractiveElementSensitive(const Node&); CORE_EXPORT PhysicalOffset -ContentPointFromRootFrame(LocalFrame*, const FloatPoint& point_in_root_frame); +ContentPointFromRootFrame(LocalFrame*, const gfx::PointF& point_in_root_frame); MouseEventWithHitTestResults PerformMouseEventHitTest(LocalFrame*, const HitTestRequest&,
diff --git a/third_party/blink/renderer/core/input/gesture_manager.cc b/third_party/blink/renderer/core/input/gesture_manager.cc index 6e5d0ac..3ee08d5 100644 --- a/third_party/blink/renderer/core/input/gesture_manager.cc +++ b/third_party/blink/renderer/core/input/gesture_manager.cc
@@ -30,6 +30,7 @@ #include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h" #include "third_party/blink/renderer/core/scroll/scroll_animator_base.h" #include "third_party/blink/renderer/platform/wtf/deque.h" +#include "ui/gfx/geometry/point_conversions.h" #if BUILDFLAG(ENABLE_UNHANDLED_TAP) #include "third_party/blink/public/common/browser_interface_broker_proxy.h" @@ -197,7 +198,7 @@ // We use the adjusted position so the application isn't surprised to see a // event with co-ordinates outside the target's bounds. gfx::Point adjusted_point = frame_view->ConvertFromRootFrame( - FlooredIntPoint(gesture_event.PositionInRootFrame())); + gfx::ToFlooredPoint(gesture_event.PositionInRootFrame())); const unsigned modifiers = gesture_event.GetModifiers(); @@ -229,14 +230,14 @@ DocumentUpdateReason::kHitTest)) return WebInputEventResult::kNotHandled; adjusted_point = frame_view->ConvertFromRootFrame( - FlooredIntPoint(gesture_event.PositionInRootFrame())); + gfx::ToFlooredPoint(gesture_event.PositionInRootFrame())); current_hit_test = event_handling_util::HitTestResultInFrame( frame_, HitTestLocation(adjusted_point), hit_type); } // Capture data for showUnhandledTapUIIfNeeded. gfx::Point tapped_position = - FlooredIntPoint(gesture_event.PositionInRootFrame()); + gfx::ToFlooredPoint(gesture_event.PositionInRootFrame()); Node* tapped_node = current_hit_test.InnerNode(); Element* tapped_element = current_hit_test.InnerElement(); LocalFrame::NotifyUserActivation( @@ -375,7 +376,7 @@ long_press_position_in_root_frame_ = gesture_event.PositionInRootFrame(); HitTestLocation location(frame_->View()->ConvertFromRootFrame( - FlooredIntPoint(long_press_position_in_root_frame_))); + gfx::ToFlooredPoint(long_press_position_in_root_frame_))); HitTestResult hit_test_result = frame_->GetEventHandler().HitTestResultAtLocation(location); @@ -482,7 +483,7 @@ if (!suppress_mouse_events_from_gestures_ && frame_->View()) { HitTestRequest request(HitTestRequest::kActive); PhysicalOffset document_point(frame_->View()->ConvertFromRootFrame( - FlooredIntPoint(targeted_event.Event().PositionInRootFrame()))); + gfx::ToFlooredPoint(targeted_event.Event().PositionInRootFrame()))); MouseEventWithHitTestResults mev = frame_->GetDocument()->PerformMouseEventHitTest(request, document_point, mouse_event);
diff --git a/third_party/blink/renderer/core/input/mouse_event_manager.cc b/third_party/blink/renderer/core/input/mouse_event_manager.cc index 473c52c..d8b6f3d 100644 --- a/third_party/blink/renderer/core/input/mouse_event_manager.cc +++ b/third_party/blink/renderer/core/input/mouse_event_manager.cc
@@ -52,13 +52,14 @@ #include "third_party/blink/renderer/platform/geometry/float_quad.h" #include "ui/base/dragdrop/mojom/drag_drop_types.mojom-blink.h" #include "ui/display/screen_info.h" +#include "ui/gfx/geometry/point_conversions.h" namespace blink { namespace { void UpdateMouseMovementXY(const WebMouseEvent& mouse_event, - const FloatPoint* last_position, + const gfx::PointF* last_position, LocalDOMWindow* dom_window, MouseEventInit* initializer) { if (RuntimeEnabledFeatures::ConsolidatedMovementXYEnabled() && @@ -95,7 +96,7 @@ Node* target_node, const AtomicString& mouse_event_type, const WebMouseEvent& mouse_event, - const FloatPoint* last_position, + const gfx::PointF* last_position, EventTarget* related_target, int click_count) { bool is_mouse_enter_or_leave = @@ -157,8 +158,8 @@ captures_dragging_ = false; is_mouse_position_unknown_ = true; last_known_mouse_position_in_root_frame_ = PhysicalOffset(); - last_known_mouse_position_ = FloatPoint(); - last_known_mouse_screen_position_ = FloatPoint(); + last_known_mouse_position_ = gfx::PointF(); + last_known_mouse_screen_position_ = gfx::PointF(); mouse_pressed_ = false; click_count_ = 0; click_element_ = nullptr; @@ -254,7 +255,7 @@ EventTarget* target, const AtomicString& mouse_event_type, const WebMouseEvent& mouse_event, - const FloatPoint* last_position, + const gfx::PointF* last_position, EventTarget* related_target, bool check_for_listener, const PointerId& pointer_id, @@ -439,10 +440,10 @@ button = WebPointerProperties::Button::kLeft; modifiers |= WebInputEvent::kLeftButtonDown; } - WebMouseEvent fake_mouse_move_event( - WebInputEvent::Type::kMouseMove, ToGfxPointF(last_known_mouse_position_), - ToGfxPointF(last_known_mouse_screen_position_), button, 0, modifiers, - base::TimeTicks::Now()); + WebMouseEvent fake_mouse_move_event(WebInputEvent::Type::kMouseMove, + last_known_mouse_position_, + last_known_mouse_screen_position_, button, + 0, modifiers, base::TimeTicks::Now()); Vector<WebMouseEvent> coalesced_events, predicted_events; frame_->GetEventHandler().HandleMouseMoveEvent( TransformWebMouseEvent(view, fake_mouse_move_event), coalesced_events, @@ -627,7 +628,7 @@ if (LocalFrameView* view = frame_->View()) { mouse_down_pos_ = view->ConvertFromRootFrame( - FlooredIntPoint(mouse_event.PositionInRootFrame())); + gfx::ToFlooredPoint(mouse_event.PositionInRootFrame())); } else { InvalidateClick(); } @@ -640,11 +641,11 @@ return is_mouse_position_unknown_; } -FloatPoint MouseEventManager::LastKnownMousePositionInViewport() { +gfx::PointF MouseEventManager::LastKnownMousePositionInViewport() { return last_known_mouse_position_; } -FloatPoint MouseEventManager::LastKnownMouseScreenPosition() { +gfx::PointF MouseEventManager::LastKnownMouseScreenPosition() { return last_known_mouse_screen_position_; } @@ -652,9 +653,9 @@ is_mouse_position_unknown_ = event.GetType() == WebInputEvent::Type::kMouseLeave; last_known_mouse_position_in_root_frame_ = - PhysicalOffset(FlooredIntPoint(event.PositionInRootFrame())); - last_known_mouse_position_ = FloatPoint(event.PositionInWidget()); - last_known_mouse_screen_position_ = FloatPoint(event.PositionInScreen()); + PhysicalOffset(gfx::ToFlooredPoint(event.PositionInRootFrame())); + last_known_mouse_position_ = event.PositionInWidget(); + last_known_mouse_screen_position_ = event.PositionInScreen(); } void MouseEventManager::SetLastMousePositionAsUnknown() { @@ -685,8 +686,8 @@ single_click) { svg_pan_ = true; frame_->GetDocument()->AccessSVGExtensions().StartPan( - frame_->View()->ConvertFromRootFrame(FloatPoint( - FlooredIntPoint(event.Event().PositionInRootFrame())))); + frame_->View()->ConvertFromRootFrame(gfx::PointF( + gfx::ToFlooredPoint(event.Event().PositionInRootFrame())))); return WebInputEventResult::kHandledSystem; } } @@ -707,7 +708,7 @@ mouse_press_node_ = inner_node; frame_->GetDocument()->SetSequentialFocusNavigationStartingPoint(inner_node); drag_start_pos_in_root_frame_ = - PhysicalOffset(FlooredIntPoint(event.Event().PositionInRootFrame())); + PhysicalOffset(gfx::ToFlooredPoint(event.Event().PositionInRootFrame())); mouse_pressed_ = true; @@ -785,7 +786,7 @@ mouse_down_may_start_drag_ = true; ResetDragSource(); mouse_down_pos_ = frame_->View()->ConvertFromRootFrame( - FlooredIntPoint(mouse_drag_event.PositionInRootFrame())); + gfx::ToFlooredPoint(mouse_drag_event.PositionInRootFrame())); return HandleDrag(mev, DragInitiator::kTouch); } @@ -926,7 +927,7 @@ if (initiator == DragInitiator::kMouse && !DragThresholdExceeded( - FlooredIntPoint(event.Event().PositionInRootFrame()))) { + gfx::ToFlooredPoint(event.Event().PositionInRootFrame()))) { ResetDragSource(); return true; }
diff --git a/third_party/blink/renderer/core/input/mouse_event_manager.h b/third_party/blink/renderer/core/input/mouse_event_manager.h index b0e40a5..61897820 100644 --- a/third_party/blink/renderer/core/input/mouse_event_manager.h +++ b/third_party/blink/renderer/core/input/mouse_event_manager.h
@@ -46,7 +46,7 @@ EventTarget*, const AtomicString&, const WebMouseEvent&, - const FloatPoint* last_position, + const gfx::PointF* last_position, EventTarget* related_target, bool check_for_listener = false, const PointerId& pointer_id = PointerEventFactory::kInvalidId, @@ -122,8 +122,8 @@ // refactoring to be able to remove the dependency from EventHandler. Element* GetElementUnderMouse(); bool IsMousePositionUnknown(); - FloatPoint LastKnownMousePositionInViewport(); - FloatPoint LastKnownMouseScreenPosition(); + gfx::PointF LastKnownMousePositionInViewport(); + gfx::PointF LastKnownMouseScreenPosition(); bool MousePressed(); void ReleaseMousePress(); @@ -213,8 +213,8 @@ // The last mouse movement position this frame has seen in viewport // coordinates. PhysicalOffset last_known_mouse_position_in_root_frame_; - FloatPoint last_known_mouse_position_; - FloatPoint last_known_mouse_screen_position_; + gfx::PointF last_known_mouse_position_; + gfx::PointF last_known_mouse_screen_position_; unsigned is_mouse_position_unknown_ : 1; // Current button-press state for mouse/mouse-like-stylus.
diff --git a/third_party/blink/renderer/core/input/mouse_wheel_event_manager.cc b/third_party/blink/renderer/core/input/mouse_wheel_event_manager.cc index 9726bc7..b1a79ed0 100644 --- a/third_party/blink/renderer/core/input/mouse_wheel_event_manager.cc +++ b/third_party/blink/renderer/core/input/mouse_wheel_event_manager.cc
@@ -21,6 +21,7 @@ #include "third_party/blink/renderer/core/page/scrolling/scroll_state.h" #include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h" #include "third_party/blink/renderer/platform/wtf/deque.h" +#include "ui/gfx/geometry/point_conversions.h" namespace blink { @@ -154,8 +155,8 @@ const Document* doc, const LocalFrameView* view) { DCHECK(doc && doc->GetLayoutView() && view); - PhysicalOffset v_point( - view->ConvertFromRootFrame(FlooredIntPoint(event.PositionInRootFrame()))); + PhysicalOffset v_point(view->ConvertFromRootFrame( + gfx::ToFlooredPoint(event.PositionInRootFrame()))); HitTestRequest request(HitTestRequest::kReadOnly); HitTestLocation location(v_point);
diff --git a/third_party/blink/renderer/core/input/pointer_event_manager.cc b/third_party/blink/renderer/core/input/pointer_event_manager.cc index 51f74ab..c749cb3 100644 --- a/third_party/blink/renderer/core/input/pointer_event_manager.cc +++ b/third_party/blink/renderer/core/input/pointer_event_manager.cc
@@ -367,8 +367,8 @@ HitTestRequest::kActive | HitTestRequest::kListBased; LocalFrame& root_frame = frame_->LocalFrameRoot(); // TODO(szager): Shouldn't this be PositionInScreen() ? - PhysicalOffset hit_test_point = PhysicalOffset::FromFloatPointRound( - FloatPoint(pointer_event.PositionInWidget())); + PhysicalOffset hit_test_point = + PhysicalOffset::FromPointFRound(pointer_event.PositionInWidget()); hit_test_point -= PhysicalOffset(hit_rect_size * 0.5f); HitTestLocation location(PhysicalRect(hit_test_point, hit_rect_size)); HitTestResult hit_test_result = @@ -382,8 +382,7 @@ pointer_event.SetPositionInWidget(adjusted_point.x(), adjusted_point.y()); frame_->GetEventHandler().CacheTouchAdjustmentResult( - pointer_event.unique_touch_event_id, - FloatPoint(pointer_event.PositionInWidget())); + pointer_event.unique_touch_event_id, pointer_event.PositionInWidget()); } bool PointerEventManager::ShouldFilterEvent(PointerEvent* pointer_event) { @@ -425,8 +424,7 @@ HitTestRequest::kReadOnly | HitTestRequest::kActive; HitTestLocation location(frame_->View()->ConvertFromRootFrame( - PhysicalOffset::FromFloatPointRound( - FloatPoint(web_pointer_event.PositionInWidget())))); + PhysicalOffset::FromPointFRound(web_pointer_event.PositionInWidget()))); HitTestResult hit_test_tesult = frame_->GetEventHandler().HitTestResultAtLocation(location, hit_type); Element* target = hit_test_tesult.InnerElement(); @@ -711,7 +709,7 @@ WebInputEvent::Modifiers::kRelativeMotionEvent)) { // Fetch the last_mouse_position for creating MouseEvent before // pointer_event_factory updates it. - FloatPoint last_mouse_position = + gfx::PointF last_mouse_position = pointer_event_factory_.GetLastPointerPosition( PointerEventFactory::kMouseId, event, event.GetType()); @@ -725,8 +723,8 @@ return result; } pointer_event_factory_.SetLastPosition( - pointer_event_factory_.GetPointerEventId(event), - FloatPoint(event.PositionInScreen()), event.GetType()); + pointer_event_factory_.GetPointerEventId(event), event.PositionInScreen(), + event.GetType()); return WebInputEventResult::kHandledSuppressed; } @@ -752,7 +750,7 @@ // Fetch the last_mouse_position for creating MouseEvent before // pointer_event_factory updates it. - FloatPoint last_mouse_position = + gfx::PointF last_mouse_position = pointer_event_factory_.GetLastPointerPosition( pointer_event_factory_.GetPointerEventId(mouse_event), mouse_event, event_type); @@ -1111,9 +1109,9 @@ pointer_event_factory_.RemoveLastPosition(pointer_id); } else if (!last_target || new_target->GetDocument().GetFrame() != last_target->GetDocument().GetFrame()) { - pointer_event_factory_.SetLastPosition( - pointer_id, FloatPoint(web_pointer_event.PositionInScreen()), - web_pointer_event.GetType()); + pointer_event_factory_.SetLastPosition(pointer_id, + web_pointer_event.PositionInScreen(), + web_pointer_event.GetType()); } }
diff --git a/third_party/blink/renderer/core/input/scroll_manager.cc b/third_party/blink/renderer/core/input/scroll_manager.cc index b366c166..ca4ee0b4 100644 --- a/third_party/blink/renderer/core/input/scroll_manager.cc +++ b/third_party/blink/renderer/core/input/scroll_manager.cc
@@ -35,6 +35,7 @@ #include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h" #include "third_party/blink/renderer/platform/widget/input/input_metrics.h" +#include "ui/gfx/geometry/point_conversions.h" namespace blink { namespace { @@ -380,7 +381,8 @@ break; } case ScrollGranularity::kScrollByDocument: { - FloatPoint end_position = scrollable_area->ScrollPosition() + delta; + gfx::PointF end_position = + scrollable_area->ScrollPosition() + ToGfxVector2dF(delta); bool scrolled_x = physical_direction == kScrollLeft || physical_direction == kScrollRight; bool scrolled_y = physical_direction == kScrollUp || @@ -530,7 +532,8 @@ current_scroll_chain_.clear(); std::unique_ptr<ScrollStateData> scroll_state_data = std::make_unique<ScrollStateData>(); - gfx::Point position = FlooredIntPoint(gesture_event.PositionInRootFrame()); + gfx::Point position = + gfx::ToFlooredPoint(gesture_event.PositionInRootFrame()); scroll_state_data->position_x = position.x(); scroll_state_data->position_y = position.y(); scroll_state_data->delta_x_hint = -gesture_event.DeltaXInRootFrame(); @@ -625,7 +628,7 @@ FloatSize delta(-gesture_event.DeltaXInRootFrame(), -gesture_event.DeltaYInRootFrame()); FloatSize velocity(-gesture_event.VelocityX(), -gesture_event.VelocityY()); - FloatPoint position(gesture_event.PositionInRootFrame()); + gfx::PointF position = gesture_event.PositionInRootFrame(); if (delta.IsZero()) return WebInputEventResult::kNotHandled; @@ -739,15 +742,15 @@ if (!scrollable_area) return; - FloatPoint current_position = scrollable_area->ScrollPosition(); + gfx::PointF current_position = scrollable_area->ScrollPosition(); std::unique_ptr<cc::SnapSelectionStrategy> strategy = cc::SnapSelectionStrategy::CreateForDirection( - ToGfxPointF(current_position), + current_position, gfx::Vector2dF(scroll_state_data->delta_x, scroll_state_data->delta_y), RuntimeEnabledFeatures::FractionalScrollOffsetsEnabled()); - absl::optional<FloatPoint> snap_point = + absl::optional<gfx::PointF> snap_point = scrollable_area->GetSnapPositionAndSetTarget(*strategy); if (!snap_point) return; @@ -903,17 +906,17 @@ if (!scrollable_area) return false; - FloatPoint current_position = scrollable_area->ScrollPosition(); - *out_initial_position = ToGfxPointF(current_position); + gfx::PointF current_position = scrollable_area->ScrollPosition(); + *out_initial_position = current_position; std::unique_ptr<cc::SnapSelectionStrategy> strategy = cc::SnapSelectionStrategy::CreateForEndAndDirection( *out_initial_position, natural_displacement, RuntimeEnabledFeatures::FractionalScrollOffsetsEnabled()); - absl::optional<FloatPoint> snap_end = + absl::optional<gfx::PointF> snap_end = scrollable_area->GetSnapPositionAndSetTarget(*strategy); if (!snap_end.has_value()) return false; - *out_target_position = ToGfxPointF(snap_end.value()); + *out_target_position = snap_end.value(); return true; } @@ -940,8 +943,8 @@ scroll_state->SetCurrentNativeScrollingNode(previous_gesture_scrolled_node_); CustomizedScroll(*scroll_state); - FloatPoint end_position = scrollable_area->ScrollPosition(); - return ToGfxPointF(end_position); + // Return the end scroll position. + return scrollable_area->ScrollPosition(); } void ScrollManager::ScrollEndForSnapFling(bool did_finish) { @@ -1050,7 +1053,7 @@ LocalFrameView* view = frame_->View(); PhysicalOffset view_point(view->ConvertFromRootFrame( - FlooredIntPoint(gesture_event.PositionInRootFrame()))); + gfx::ToFlooredPoint(gesture_event.PositionInRootFrame()))); HitTestRequest request(HitTestRequest::kReadOnly); HitTestLocation location(view_point); HitTestResult result(request, location); @@ -1203,7 +1206,7 @@ ? event_target->GetLayoutObject()->EnclosingLayer() : nullptr; gfx::Point p = frame_->View()->ConvertFromRootFrame( - FlooredIntPoint(gesture_event.PositionInRootFrame())); + gfx::ToFlooredPoint(gesture_event.PositionInRootFrame())); if (layer && layer->GetScrollableArea() && layer->GetScrollableArea()->IsPointInResizeControl(p, kResizerForTouch)) { @@ -1216,8 +1219,7 @@ } else if (gesture_event.GetType() == WebInputEvent::Type::kGestureScrollUpdate) { if (resize_scrollable_area_ && resize_scrollable_area_->InResizeMode()) { - gfx::Point pos = - RoundedIntPoint(FloatPoint(gesture_event.PositionInRootFrame())); + gfx::Point pos = gfx::ToRoundedPoint(gesture_event.PositionInRootFrame()); pos.Offset(gesture_event.DeltaXInRootFrame(), gesture_event.DeltaYInRootFrame()); resize_scrollable_area_->Resize(pos, offset_from_resize_corner_); @@ -1243,8 +1245,9 @@ if (evt.GetType() == WebInputEvent::Type::kMouseMove) { if (!frame_->GetEventHandler().MousePressed()) return; - resize_scrollable_area_->Resize(FlooredIntPoint(evt.PositionInRootFrame()), - offset_from_resize_corner_); + resize_scrollable_area_->Resize( + gfx::ToFlooredPoint(evt.PositionInRootFrame()), + offset_from_resize_corner_); } }
diff --git a/third_party/blink/renderer/core/input/scroll_snap_test.cc b/third_party/blink/renderer/core/input/scroll_snap_test.cc index 1ac1311c..921dd01 100644 --- a/third_party/blink/renderer/core/input/scroll_snap_test.cc +++ b/third_party/blink/renderer/core/input/scroll_snap_test.cc
@@ -140,7 +140,7 @@ Element* scroller = GetDocument().getElementById("scroller"); scroller->GetLayoutBoxForScrolling() ->GetScrollableArea() - ->ScrollToAbsolutePosition(FloatPoint(x, y), + ->ScrollToAbsolutePosition(gfx::PointF(x, y), mojom::blink::ScrollBehavior::kAuto); ASSERT_EQ(scroller->scrollLeft(), x); ASSERT_EQ(scroller->scrollTop(), y);
diff --git a/third_party/blink/renderer/core/input/touch.cc b/third_party/blink/renderer/core/input/touch.cc index 69519ff..a67aa35 100644 --- a/third_party/blink/renderer/core/input/touch.cc +++ b/third_party/blink/renderer/core/input/touch.cc
@@ -29,26 +29,26 @@ #include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame_view.h" #include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { namespace { -FloatPoint ContentsOffset(LocalFrame* frame) { +gfx::Vector2dF ContentsOffset(LocalFrame* frame) { if (!frame) - return FloatPoint(); + return gfx::Vector2dF(); LocalFrameView* frame_view = frame->View(); if (!frame_view) - return FloatPoint(); + return gfx::Vector2dF(); float scale = 1.0f / frame->PageZoomFactor(); - return FloatPoint(frame_view->LayoutViewport()->GetScrollOffset()) - .ScaledBy(scale); + return gfx::ScalePoint(frame_view->LayoutViewport()->ScrollPosition(), scale) + .OffsetFromOrigin(); } -LayoutPoint PageToAbsolute(LocalFrame* frame, const FloatPoint& page_pos) { +LayoutPoint PageToAbsolute(LocalFrame* frame, const gfx::PointF& page_pos) { float scale_factor = frame ? frame->PageZoomFactor() : 1.0f; - FloatPoint converted_point = page_pos.ScaledBy(scale_factor); + gfx::PointF converted_point = gfx::ScalePoint(page_pos, scale_factor); if (frame && frame->View()) converted_point = frame->View()->DocumentToFrame(converted_point); @@ -61,8 +61,8 @@ Touch::Touch(LocalFrame* frame, EventTarget* target, int identifier, - const FloatPoint& screen_pos, - const FloatPoint& page_pos, + const gfx::PointF& screen_pos, + const gfx::PointF& page_pos, const FloatSize& radius, float rotation_angle, float force) @@ -78,9 +78,9 @@ Touch::Touch(EventTarget* target, int identifier, - const FloatPoint& client_pos, - const FloatPoint& screen_pos, - const FloatPoint& page_pos, + const gfx::PointF& client_pos, + const gfx::PointF& screen_pos, + const gfx::PointF& page_pos, const FloatSize& radius, float rotation_angle, float force, @@ -98,10 +98,10 @@ Touch::Touch(LocalFrame* frame, const TouchInit* initializer) : target_(initializer->target()), identifier_(initializer->identifier()), - client_pos_(FloatPoint(initializer->clientX(), initializer->clientY())), - screen_pos_(FloatPoint(initializer->screenX(), initializer->screenY())), - page_pos_(FloatPoint(initializer->pageX(), initializer->pageY())), - radius_(FloatSize(initializer->radiusX(), initializer->radiusY())), + client_pos_(initializer->clientX(), initializer->clientY()), + screen_pos_(initializer->screenX(), initializer->screenY()), + page_pos_(initializer->pageX(), initializer->pageY()), + radius_(initializer->radiusX(), initializer->radiusY()), rotation_angle_(initializer->rotationAngle()), force_(initializer->force()), absolute_location_(PageToAbsolute(frame, page_pos_)) {}
diff --git a/third_party/blink/renderer/core/input/touch.h b/third_party/blink/renderer/core/input/touch.h index cef94820..29eec92 100644 --- a/third_party/blink/renderer/core/input/touch.h +++ b/third_party/blink/renderer/core/input/touch.h
@@ -30,10 +30,10 @@ #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/events/event_target.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/geometry/layout_point.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -47,8 +47,8 @@ static Touch* Create(LocalFrame* frame, EventTarget* target, int identifier, - const FloatPoint& screen_pos, - const FloatPoint& page_pos, + const gfx::PointF& screen_pos, + const gfx::PointF& page_pos, const FloatSize& radius, float rotation_angle, float force) { @@ -63,17 +63,17 @@ Touch(LocalFrame*, EventTarget*, int identifier, - const FloatPoint& screen_pos, - const FloatPoint& page_pos, + const gfx::PointF& screen_pos, + const gfx::PointF& page_pos, const FloatSize& radius, float rotation_angle, float force); Touch(EventTarget*, int identifier, - const FloatPoint& client_pos, - const FloatPoint& screen_pos, - const FloatPoint& page_pos, + const gfx::PointF& client_pos, + const gfx::PointF& screen_pos, + const gfx::PointF& page_pos, const FloatSize& radius, float rotation_angle, float force, @@ -97,7 +97,7 @@ // Blink-internal methods const LayoutPoint& AbsoluteLocation() const { return absolute_location_; } - const FloatPoint& ScreenLocation() const { return screen_pos_; } + const gfx::PointF& ScreenLocation() const { return screen_pos_; } Touch* CloneWithNewTarget(EventTarget*) const; void Trace(Visitor*) const override; @@ -106,11 +106,11 @@ Member<EventTarget> target_; int identifier_; // Position relative to the viewport in CSS px. - FloatPoint client_pos_; + gfx::PointF client_pos_; // Position relative to the screen in DIPs. - FloatPoint screen_pos_; + gfx::PointF screen_pos_; // Position relative to the page in CSS px. - FloatPoint page_pos_; + gfx::PointF page_pos_; // Radius in CSS px. FloatSize radius_; float rotation_angle_;
diff --git a/third_party/blink/renderer/core/input/touch_event_manager.cc b/third_party/blink/renderer/core/input/touch_event_manager.cc index c89165c4..4e71361 100644 --- a/third_party/blink/renderer/core/input/touch_event_manager.cc +++ b/third_party/blink/renderer/core/input/touch_event_manager.cc
@@ -208,19 +208,18 @@ point_attr->event_.WebPointerEventInRootFrame(); float scale_factor = 1.0f / target_frame->PageZoomFactor(); - FloatPoint document_point = target_frame->View() - ->RootFrameToDocument(FloatPoint( - transformed_event.PositionInWidget())) - .ScaledBy(scale_factor); + gfx::PointF document_point = + gfx::ScalePoint(target_frame->View()->RootFrameToDocument( + transformed_event.PositionInWidget()), + scale_factor); FloatSize adjusted_radius = FloatSize(transformed_event.width / 2.f, transformed_event.height / 2.f) .ScaledBy(scale_factor); return MakeGarbageCollected<Touch>( target_frame, touch_node, point_attr->event_.id, - FloatPoint(transformed_event.PositionInScreen()), document_point, - adjusted_radius, transformed_event.rotation_angle, - transformed_event.force); + transformed_event.PositionInScreen(), document_point, adjusted_radius, + transformed_event.rotation_angle, transformed_event.force); } WebCoalescedInputEvent TouchEventManager::GenerateWebCoalescedInputEvent() { @@ -534,9 +533,9 @@ if (touch_sequence_document_ && (!touch_node || &touch_node->GetDocument() != touch_sequence_document_)) { if (touch_sequence_document_->GetFrame()) { - HitTestLocation location(PhysicalOffset::FromFloatPointRound( + HitTestLocation location(PhysicalOffset::FromPointFRound( touch_sequence_document_->GetFrame()->View()->ConvertFromRootFrame( - FloatPoint(event.PositionInWidget())))); + event.PositionInWidget()))); result = event_handling_util::HitTestResultInFrame( touch_sequence_document_->GetFrame(), location, hit_type); Node* node = result.InnerNode();
diff --git a/third_party/blink/renderer/core/inspector/dev_tools_emulator.cc b/third_party/blink/renderer/core/inspector/dev_tools_emulator.cc index 5ea7a83..adeeb299 100644 --- a/third_party/blink/renderer/core/inspector/dev_tools_emulator.cc +++ b/third_party/blink/renderer/core/inspector/dev_tools_emulator.cc
@@ -416,7 +416,7 @@ if (!viewport_override_) viewport_override_ = ViewportOverride(); - viewport_override_->position = FloatPoint(position); + viewport_override_->position = position; viewport_override_->scale = scale; // Move the correct (scaled) content area to show in the top left of the
diff --git a/third_party/blink/renderer/core/inspector/dev_tools_emulator.h b/third_party/blink/renderer/core/inspector/dev_tools_emulator.h index 34adb92..7119d8d 100644 --- a/third_party/blink/renderer/core/inspector/dev_tools_emulator.h +++ b/third_party/blink/renderer/core/inspector/dev_tools_emulator.h
@@ -113,7 +113,7 @@ DeviceEmulationParams emulation_params_; struct ViewportOverride { - FloatPoint position; + gfx::PointF position; double scale; }; absl::optional<ViewportOverride> viewport_override_;
diff --git a/third_party/blink/renderer/core/inspector/inspect_tools.cc b/third_party/blink/renderer/core/inspector/inspect_tools.cc index 4d36ff5d..a473198bf 100644 --- a/third_party/blink/renderer/core/inspector/inspect_tools.cc +++ b/third_party/blink/renderer/core/inspector/inspect_tools.cc
@@ -32,6 +32,7 @@ #include "third_party/blink/renderer/platform/cursors.h" #include "third_party/blink/renderer/platform/keyboard_codes.h" #include "third_party/inspector_protocol/crdtp/json.h" +#include "ui/gfx/geometry/point_conversions.h" namespace blink { @@ -82,17 +83,17 @@ Node* HoveredNodeForEvent(LocalFrame* frame, const WebGestureEvent& event, bool ignore_pointer_events_none) { - return HoveredNodeForPoint( - frame, RoundedIntPoint(FloatPoint(event.PositionInRootFrame())), - ignore_pointer_events_none); + return HoveredNodeForPoint(frame, + gfx::ToRoundedPoint(event.PositionInRootFrame()), + ignore_pointer_events_none); } Node* HoveredNodeForEvent(LocalFrame* frame, const WebMouseEvent& event, bool ignore_pointer_events_none) { - return HoveredNodeForPoint( - frame, RoundedIntPoint(FloatPoint(event.PositionInRootFrame())), - ignore_pointer_events_none); + return HoveredNodeForPoint(frame, + gfx::ToRoundedPoint(event.PositionInRootFrame()), + ignore_pointer_events_none); } Node* HoveredNodeForEvent(LocalFrame* frame, @@ -100,7 +101,7 @@ bool ignore_pointer_events_none) { WebPointerEvent transformed_point = event.WebPointerEventInRootFrame(); return HoveredNodeForPoint( - frame, RoundedIntPoint(FloatPoint(transformed_point.PositionInWidget())), + frame, gfx::ToRoundedPoint(transformed_point.PositionInWidget()), ignore_pointer_events_none); }
diff --git a/third_party/blink/renderer/core/inspector/inspector_highlight.cc b/third_party/blink/renderer/core/inspector/inspector_highlight.cc index 0325c05d..ff3a3af9 100644 --- a/third_party/blink/renderer/core/inspector/inspector_highlight.cc +++ b/third_party/blink/renderer/core/inspector/inspector_highlight.cc
@@ -40,12 +40,12 @@ #include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/core/style/computed_style_constants.h" #include "third_party/blink/renderer/core/style/grid_positions_resolver.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/geometry/layout_unit.h" #include "third_party/blink/renderer/platform/graphics/path.h" #include "third_party/blink/renderer/platform/text/writing_mode.h" #include "third_party/blink/renderer/platform/web_test_support.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -143,8 +143,8 @@ protected: gfx::PointF TranslatePoint(const gfx::PointF& point) override { - PhysicalOffset layout_object_point = PhysicalOffset::FromFloatPointRound( - shape_outside_info_.ShapeToLayoutObjectPoint(FloatPoint(point))); + PhysicalOffset layout_object_point = PhysicalOffset::FromPointFRound( + shape_outside_info_.ShapeToLayoutObjectPoint(point)); // TODO(pfeldman): Is this kIgnoreTransforms correct? return gfx::PointF(view_->FrameToViewport( ToRoundedPoint(layout_object_->LocalToAbsolutePoint( @@ -208,9 +208,9 @@ return ColumnQuadToPath(ToGfxQuadF(quad), draw_end_line); } -FloatPoint FramePointToViewport(const LocalFrameView* view, - FloatPoint point_in_frame) { - FloatPoint point_in_root_frame = view->ConvertToRootFrame(point_in_frame); +gfx::PointF FramePointToViewport(const LocalFrameView* view, + gfx::PointF point_in_frame) { + gfx::PointF point_in_root_frame = view->ConvertToRootFrame(point_in_frame); return view->GetPage()->GetVisualViewport().RootFrameToViewport( point_in_root_frame); } @@ -620,10 +620,10 @@ float scale) { LayoutObject* layout_object = node->GetLayoutObject(); PhysicalOffset abs_point = layout_object->LocalToAbsolutePoint(local); - FloatPoint abs_point_in_viewport = FramePointToViewport( - node->GetDocument().View(), FloatPoint(abs_point.left, abs_point.top)); + gfx::PointF abs_point_in_viewport = FramePointToViewport( + node->GetDocument().View(), gfx::PointF(abs_point.left, abs_point.top)); PhysicalOffset scaled_abs_point = - PhysicalOffset::FromFloatPointRound(abs_point_in_viewport); + PhysicalOffset::FromPointFRound(abs_point_in_viewport); scaled_abs_point.Scale(scale); return scaled_abs_point; } @@ -971,10 +971,10 @@ int GetRotationAngle(LayoutObject* layout_object) { // Local vector has 135deg bearing to the Y axis. int local_vector_bearing = 135; - FloatPoint local_a(0, 0); - FloatPoint local_b(1, 1); - FloatPoint abs_a = layout_object->LocalToAbsoluteFloatPoint(local_a); - FloatPoint abs_b = layout_object->LocalToAbsoluteFloatPoint(local_b); + gfx::PointF local_a(0, 0); + gfx::PointF local_b(1, 1); + gfx::PointF abs_a = layout_object->LocalToAbsolutePoint(local_a); + gfx::PointF abs_b = layout_object->LocalToAbsolutePoint(local_b); // Compute bearing of the absolute vector against the Y axis. double theta = atan2(abs_b.x() - abs_a.x(), abs_a.y() - abs_b.y()); if (theta < 0.0)
diff --git a/third_party/blink/renderer/core/inspector/inspector_overlay_agent.cc b/third_party/blink/renderer/core/inspector/inspector_overlay_agent.cc index 425c3f2..7eee548 100644 --- a/third_party/blink/renderer/core/inspector/inspector_overlay_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_overlay_agent.cc
@@ -102,10 +102,10 @@ const size_t kCoordinatesInQuad = 8; if (!quad_array || quad_array->size() != kCoordinatesInQuad) return false; - quad->set_p1(FloatPoint((*quad_array)[0], (*quad_array)[1])); - quad->set_p2(FloatPoint((*quad_array)[2], (*quad_array)[3])); - quad->set_p3(FloatPoint((*quad_array)[4], (*quad_array)[5])); - quad->set_p4(FloatPoint((*quad_array)[6], (*quad_array)[7])); + quad->set_p1(gfx::PointF((*quad_array)[0], (*quad_array)[1])); + quad->set_p2(gfx::PointF((*quad_array)[2], (*quad_array)[3])); + quad->set_p3(gfx::PointF((*quad_array)[4], (*quad_array)[5])); + quad->set_p4(gfx::PointF((*quad_array)[6], (*quad_array)[7])); return true; }
diff --git a/third_party/blink/renderer/core/layout/README.md b/third_party/blink/renderer/core/layout/README.md index 40b7730..b526fd0 100644 --- a/third_party/blink/renderer/core/layout/README.md +++ b/third_party/blink/renderer/core/layout/README.md
@@ -101,7 +101,7 @@ In all cases, the term 'scrollOffset' (or just 'offset') is used to represent the distance of the scrolling viewport from its location when scrolled to the beginning of content, and it uses type ScrollOffset. The term 'scrollPosition' (or just 'position') represents a -point in the coordinate space defined by the overflow rect, and it uses type FloatPoint. +point in the coordinate space defined by the overflow rect, and it uses type gfx::PointF. For illustrations of these concepts, see these files:
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 5acab107..46d52136 100644 --- a/third_party/blink/renderer/core/layout/geometry/physical_offset.h +++ b/third_party/blink/renderer/core/layout/geometry/physical_offset.h
@@ -101,14 +101,6 @@ explicit PhysicalOffset(const gfx::Vector2d& vector) : left(vector.x()), top(vector.y()) {} - static PhysicalOffset FromFloatPointFloor(const FloatPoint& point) { - return {LayoutUnit::FromFloatFloor(point.x()), - LayoutUnit::FromFloatFloor(point.y())}; - } - static PhysicalOffset FromFloatPointRound(const FloatPoint& point) { - return {LayoutUnit::FromFloatRound(point.x()), - LayoutUnit::FromFloatRound(point.y())}; - } static PhysicalOffset FromFloatSizeFloor(const FloatSize& size) { return {LayoutUnit::FromFloatFloor(size.width()), LayoutUnit::FromFloatFloor(size.height())}; @@ -140,9 +132,8 @@ top *= s; } - constexpr explicit operator FloatPoint() const { return {left, top}; } - constexpr explicit operator FloatSize() const { return {left, top}; } constexpr explicit operator gfx::PointF() const { return {left, top}; } + constexpr explicit operator FloatSize() const { return {left, top}; } constexpr explicit operator gfx::Vector2dF() const { return {left, top}; } String ToString() const;
diff --git a/third_party/blink/renderer/core/layout/geometry/transform_state.cc b/third_party/blink/renderer/core/layout/geometry/transform_state.cc index a907d70..4593eadc3 100644 --- a/third_party/blink/renderer/core/layout/geometry/transform_state.cc +++ b/third_party/blink/renderer/core/layout/geometry/transform_state.cc
@@ -62,7 +62,7 @@ FloatSize adjusted_offset((direction_ == kApplyTransformDirection) ? offset : -offset); if (map_point_) - last_planar_point_.Offset(adjusted_offset); + last_planar_point_ += ToGfxVector2dF(adjusted_offset); if (map_quad_) last_planar_quad_.Move(adjusted_offset); } @@ -159,16 +159,16 @@ } PhysicalOffset TransformState::MappedPoint() const { - FloatPoint point = last_planar_point_; - point.Offset(FloatSize(direction_ == kApplyTransformDirection - ? accumulated_offset_ - : -accumulated_offset_)); + gfx::PointF point = last_planar_point_; + point += gfx::Vector2dF(direction_ == kApplyTransformDirection + ? accumulated_offset_ + : -accumulated_offset_); if (accumulated_transform_) { point = direction_ == kApplyTransformDirection ? accumulated_transform_->MapPoint(point) : accumulated_transform_->Inverse().ProjectPoint(point); } - return PhysicalOffset::FromFloatPointRound(point); + return PhysicalOffset::FromPointFRound(point); } FloatQuad TransformState::MappedQuad() const {
diff --git a/third_party/blink/renderer/core/layout/geometry/transform_state.h b/third_party/blink/renderer/core/layout/geometry/transform_state.h index 03824c7..66f90f6 100644 --- a/third_party/blink/renderer/core/layout/geometry/transform_state.h +++ b/third_party/blink/renderer/core/layout/geometry/transform_state.h
@@ -29,7 +29,6 @@ #include <memory> #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_point.h" #include "third_party/blink/renderer/platform/geometry/float_quad.h" #include "third_party/blink/renderer/platform/geometry/int_size.h" #include "third_party/blink/renderer/platform/geometry/layout_point.h" @@ -37,6 +36,7 @@ #include "third_party/blink/renderer/platform/transforms/affine_transform.h" #include "third_party/blink/renderer/platform/transforms/transformation_matrix.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -57,7 +57,7 @@ enum TransformAccumulation { kFlattenTransform, kAccumulateTransform }; TransformState(TransformDirection mapping_direction, - const FloatPoint& p, + const gfx::PointF& p, const FloatQuad& quad) : last_planar_point_(p), last_planar_quad_(quad), @@ -66,7 +66,7 @@ map_quad_(true), direction_(mapping_direction) {} - TransformState(TransformDirection mapping_direction, const FloatPoint& p) + TransformState(TransformDirection mapping_direction, const gfx::PointF& p) : last_planar_point_(p), force_accumulating_transform_(false), map_point_(true), @@ -113,7 +113,7 @@ void Flatten(); // Return the coords of the point or quad in the last flattened layer - FloatPoint LastPlanarPoint() const { return last_planar_point_; } + gfx::PointF LastPlanarPoint() const { return last_planar_point_; } FloatQuad LastPlanarQuad() const { return last_planar_quad_; } // Return the point or quad mapped through the current transform @@ -129,7 +129,7 @@ void FlattenWithTransform(const TransformationMatrix&); void ApplyAccumulatedOffset(); - FloatPoint last_planar_point_; + gfx::PointF last_planar_point_; FloatQuad last_planar_quad_; // We only allocate the transform if we need to
diff --git a/third_party/blink/renderer/core/layout/hit_test_location.cc b/third_party/blink/renderer/core/layout/hit_test_location.cc index 38ab9392..48d0806f 100644 --- a/third_party/blink/renderer/core/layout/hit_test_location.cc +++ b/third_party/blink/renderer/core/layout/hit_test_location.cc
@@ -39,17 +39,17 @@ is_rect_based_(false), is_rectilinear_(true) {} -HitTestLocation::HitTestLocation(const FloatPoint& point) - : point_(PhysicalOffset::FromFloatPointFloor(point)), +HitTestLocation::HitTestLocation(const gfx::PointF& point) + : point_(PhysicalOffset::FromPointFFloor(point)), bounding_box_(RectForPoint(point_)), transformed_point_(point), transformed_rect_(FloatRect(bounding_box_)), is_rect_based_(false), is_rectilinear_(true) {} -HitTestLocation::HitTestLocation(const FloatPoint& point, +HitTestLocation::HitTestLocation(const gfx::PointF& point, const PhysicalRect& bounding_box) - : point_(PhysicalOffset::FromFloatPointFloor(point)), + : point_(PhysicalOffset::FromPointFFloor(point)), bounding_box_(bounding_box), transformed_point_(point), transformed_rect_(FloatRect(bounding_box)), @@ -57,11 +57,12 @@ is_rectilinear_(true) {} HitTestLocation::HitTestLocation(const DoublePoint& point) - : HitTestLocation(FloatPoint(point)) {} + : HitTestLocation(gfx::PointF(point)) {} -HitTestLocation::HitTestLocation(const FloatPoint& point, const FloatQuad& quad) +HitTestLocation::HitTestLocation(const gfx::PointF& point, + const FloatQuad& quad) : transformed_point_(point), transformed_rect_(quad), is_rect_based_(true) { - point_ = PhysicalOffset::FromFloatPointFloor(point); + point_ = PhysicalOffset::FromPointFFloor(point); bounding_box_ = PhysicalRect::EnclosingRect(quad.BoundingBox()); is_rectilinear_ = quad.IsRectilinear(); } @@ -104,7 +105,7 @@ void HitTestLocation::Move(const PhysicalOffset& offset) { point_ += offset; bounding_box_.Move(offset); - transformed_point_.Offset(FloatSize(offset)); + transformed_point_ += gfx::Vector2dF(offset); transformed_rect_.Move(FloatSize(offset)); } @@ -146,10 +147,10 @@ // has false positives. if (is_rect_based_) return Intersects(quad.BoundingBox()); - return quad.ContainsPoint(FloatPoint(point_)); + return quad.ContainsPoint(gfx::PointF(point_)); } -bool HitTestLocation::ContainsPoint(const FloatPoint& point) const { +bool HitTestLocation::ContainsPoint(const gfx::PointF& point) const { return transformed_rect_.ContainsPoint(point); }
diff --git a/third_party/blink/renderer/core/layout/hit_test_location.h b/third_party/blink/renderer/core/layout/hit_test_location.h index 9c36678..1a886ee 100644 --- a/third_party/blink/renderer/core/layout/hit_test_location.h +++ b/third_party/blink/renderer/core/layout/hit_test_location.h
@@ -48,16 +48,16 @@ HitTestLocation(); explicit HitTestLocation(const PhysicalOffset&); explicit HitTestLocation(const gfx::Point&); - explicit HitTestLocation(const FloatPoint&); + explicit HitTestLocation(const gfx::PointF&); explicit HitTestLocation(const DoublePoint&); - explicit HitTestLocation(const FloatPoint&, const FloatQuad&); + explicit HitTestLocation(const gfx::PointF&, const FloatQuad&); explicit HitTestLocation(const PhysicalRect&); // The bounding box isn't always a 1x1 rect even when the hit test is not // rect-based. When we hit test a transformed box and transform the hit test // location into the box's local coordinate space, the bounding box should // also be transformed accordingly. - explicit HitTestLocation(const FloatPoint& point, + explicit HitTestLocation(const gfx::PointF& point, const PhysicalRect& bounding_box); HitTestLocation(const HitTestLocation&, const PhysicalOffset& offset); @@ -93,12 +93,9 @@ } bool Intersects(const FloatRoundedRect&) const; bool Intersects(const FloatQuad&) const; - bool ContainsPoint(const FloatPoint&) const; - bool ContainsPoint(const gfx::PointF& p) const { - return ContainsPoint(FloatPoint(p)); - } + bool ContainsPoint(const gfx::PointF&) const; - const FloatPoint& TransformedPoint() const { return transformed_point_; } + const gfx::PointF& TransformedPoint() const { return transformed_point_; } const FloatQuad& TransformedRect() const { return transformed_rect_; } private: @@ -109,7 +106,7 @@ PhysicalOffset point_; PhysicalRect bounding_box_; - FloatPoint transformed_point_; + gfx::PointF transformed_point_; FloatQuad transformed_rect_; // Index of fragment (FragmentData) to hit-test. If it's -1, all fragments
diff --git a/third_party/blink/renderer/core/layout/layout_box.cc b/third_party/blink/renderer/core/layout/layout_box.cc index e1e4265b..97c95fc 100644 --- a/third_party/blink/renderer/core/layout/layout_box.cc +++ b/third_party/blink/renderer/core/layout/layout_box.cc
@@ -1785,7 +1785,7 @@ // inset by the autoscroll activation threshold), returned offset denotes // direction of scrolling. PhysicalOffset LayoutBox::CalculateAutoscrollDirection( - const FloatPoint& point_in_root_frame) const { + const gfx::PointF& point_in_root_frame) const { NOT_DESTROYED(); if (!GetFrame()) return PhysicalOffset(); @@ -1804,7 +1804,7 @@ PhysicalRect belt_box = View()->GetFrameView()->ConvertToRootFrame(absolute_scrolling_box); belt_box.Inflate(LayoutUnit(-kAutoscrollBeltSize)); - FloatPoint point = point_in_root_frame; + gfx::PointF point = point_in_root_frame; if (point.x() < belt_box.X()) point.Offset(-kAutoscrollBeltSize, 0); @@ -1816,7 +1816,7 @@ else if (point.y() > belt_box.Bottom()) point.Offset(0, kAutoscrollBeltSize); - return PhysicalOffset::FromFloatSizeRound(point - point_in_root_frame); + return PhysicalOffset::FromVector2dFRound(point - point_in_root_frame); } LayoutBox* LayoutBox::FindAutoscrollable(LayoutObject* layout_object, @@ -1966,9 +1966,9 @@ } } -FloatPoint LayoutBox::PerspectiveOrigin(const PhysicalSize* size) const { +gfx::PointF LayoutBox::PerspectiveOrigin(const PhysicalSize* size) const { if (!HasTransformRelatedProperty()) - return FloatPoint(); + return gfx::PointF(); // Use the |size| parameter instead of |Size()| if present. FloatSize float_size = size ? FloatSize(*size) : FloatSize(Size()); @@ -2063,7 +2063,7 @@ if (has_perspective) { // Perspective on the container affects us, so we have to factor it in here. DCHECK(container_object->HasLayer()); - FloatPoint perspective_origin; + gfx::PointF perspective_origin; if (const auto* container_box = DynamicTo<LayoutBox>(container_object)) perspective_origin = container_box->PerspectiveOrigin();
diff --git a/third_party/blink/renderer/core/layout/layout_box.h b/third_party/blink/renderer/core/layout/layout_box.h index 8203463..799f0a24 100644 --- a/third_party/blink/renderer/core/layout/layout_box.h +++ b/third_party/blink/renderer/core/layout/layout_box.h
@@ -1505,7 +1505,7 @@ virtual void Autoscroll(const PhysicalOffset&); bool CanAutoscroll() const; PhysicalOffset CalculateAutoscrollDirection( - const FloatPoint& point_in_root_frame) const; + const gfx::PointF& point_in_root_frame) const; static LayoutBox* FindAutoscrollable(LayoutObject*, bool is_middle_click_autoscroll); static bool HasHorizontallyScrollableAncestor(LayoutObject*); @@ -1844,7 +1844,7 @@ // The optional |size| parameter is used if the size of the object isn't // correct yet. - FloatPoint PerspectiveOrigin(const PhysicalSize* size = nullptr) const; + gfx::PointF PerspectiveOrigin(const PhysicalSize* size = nullptr) const; // Maps the visual rect state |transform_state| from this box into its // container, applying adjustments for the given container offset,
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 4fe0d44..4e6edeef 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
@@ -1089,7 +1089,7 @@ // The sticky offset is physical, so we can just return the delta computed in // absolute coords (though it may be wrong with transforms). PhysicalRect constraining_rect = ComputeStickyConstrainingRect(); - FloatPoint scroll_position = + gfx::PointF scroll_position = ancestor_scroll_container_layer->GetScrollableArea()->ScrollPosition(); constraining_rect.Move(PhysicalOffset(LayoutUnit(scroll_position.x()), LayoutUnit(scroll_position.y())));
diff --git a/third_party/blink/renderer/core/layout/layout_box_model_object_test.cc b/third_party/blink/renderer/core/layout/layout_box_model_object_test.cc index f9b1218..730734bd 100644 --- a/third_party/blink/renderer/core/layout/layout_box_model_object_test.cc +++ b/third_party/blink/renderer/core/layout/layout_box_model_object_test.cc
@@ -43,7 +43,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollOffsetInt().width(), 50)); + gfx::PointF(scrollable_area->ScrollOffsetInt().width(), 50)); ASSERT_EQ(50.0, scrollable_area->ScrollPosition().y()); auto* sticky = GetLayoutBoxModelObjectByElementId("sticky"); sticky->UpdateStickyPositionConstraints(); @@ -84,7 +84,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollOffsetInt().width(), 50)); + gfx::PointF(scrollable_area->ScrollOffsetInt().width(), 50)); ASSERT_EQ(50.0, scrollable_area->ScrollPosition().y()); auto* sticky = GetLayoutBoxModelObjectByElementId("sticky"); sticky->UpdateStickyPositionConstraints(); @@ -132,7 +132,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollOffsetInt().width(), 50)); + gfx::PointF(scrollable_area->ScrollOffsetInt().width(), 50)); EXPECT_EQ(50.f, scrollable_area->ScrollPosition().y()); auto* sticky = GetLayoutBoxModelObjectByElementId("sticky"); @@ -189,7 +189,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 50)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 50)); EXPECT_EQ(50.f, scrollable_area->ScrollPosition().y()); auto* sticky = GetLayoutBoxModelObjectByElementId("sticky"); @@ -231,7 +231,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollOffsetInt().width(), 50)); + gfx::PointF(scrollable_area->ScrollOffsetInt().width(), 50)); ASSERT_EQ(50.0, scrollable_area->ScrollPosition().y()); auto* sticky = GetLayoutBoxModelObjectByElementId("sticky"); sticky->UpdateStickyPositionConstraints(); @@ -267,7 +267,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 50)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 50)); ASSERT_EQ(50.0, scrollable_area->ScrollPosition().y()); auto* sticky = GetLayoutBoxModelObjectByElementId("sticky"); sticky->UpdateStickyPositionConstraints(); @@ -300,7 +300,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 50)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 50)); ASSERT_EQ(50.0, scrollable_area->ScrollPosition().y()); auto* sticky = GetLayoutBoxModelObjectByElementId("sticky"); sticky->UpdateStickyPositionConstraints(); @@ -334,7 +334,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 50)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 50)); ASSERT_EQ(50.0, scrollable_area->ScrollPosition().y()); auto* sticky = GetLayoutBoxModelObjectByElementId("sticky"); sticky->UpdateStickyPositionConstraints(); @@ -621,7 +621,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 100)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 100)); ASSERT_EQ(100.0, scrollable_area->ScrollPosition().y()); // Both the parent and child sticky divs are attempting to place themselves at @@ -661,7 +661,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 100)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 100)); ASSERT_EQ(100.0, scrollable_area->ScrollPosition().y()); // The parent is attempting to place itself at the top of the scrollable area, @@ -701,7 +701,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 100)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 100)); ASSERT_EQ(100.0, scrollable_area->ScrollPosition().y()); // The parent is attempting to place itself 25 pixels from the top of the @@ -741,7 +741,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 100)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 100)); ASSERT_EQ(100.0, scrollable_area->ScrollPosition().y()); // The parent is attempting to place itself at the top of the scrollable area, @@ -786,7 +786,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 100)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 100)); ASSERT_EQ(100.0, scrollable_area->ScrollPosition().y()); // The grandparent and parent divs are attempting to place themselves at the @@ -840,7 +840,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 150)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 150)); ASSERT_EQ(150.0, scrollable_area->ScrollPosition().y()); // All sticky elements are attempting to stick to the top of the scrollable @@ -854,7 +854,7 @@ // area until they run out of <table> space to move in. scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 275)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 275)); ASSERT_EQ(275.0, scrollable_area->ScrollPosition().y()); EXPECT_EQ(PhysicalOffset(0, 200), sticky_div->StickyPositionOffset()); @@ -864,7 +864,7 @@ // sticky header should travel as far as it can (i.e. the table height) then // move off the top with it. scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 350)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 350)); ASSERT_EQ(350.0, scrollable_area->ScrollPosition().y()); EXPECT_EQ(PhysicalOffset(0, 200), sticky_div->StickyPositionOffset()); @@ -910,7 +910,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 150)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 150)); ASSERT_EQ(150.0, scrollable_area->ScrollPosition().y()); EXPECT_EQ(PhysicalOffset(0, 100), outer_sticky_th->StickyPositionOffset()); @@ -957,7 +957,7 @@ auto* scroller = GetLayoutBoxModelObjectByElementId("scroller"); PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 50)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 50)); ASSERT_EQ(50.0, scrollable_area->ScrollPosition().y()); EXPECT_EQ(PhysicalOffset(0, 0), outer_inline->StickyPositionOffset()); @@ -998,7 +998,7 @@ // Scroll the page down. scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 100)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 100)); ASSERT_EQ(100.0, scrollable_area->ScrollPosition().y()); // TODO(smcgruer): Until http://crbug.com/686164 is fixed, the sticky position
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 26d6ffe..442ff796 100644 --- a/third_party/blink/renderer/core/layout/layout_box_test.cc +++ b/third_party/blink/renderer/core/layout/layout_box_test.cc
@@ -1438,7 +1438,7 @@ const auto* scrollable_area = box->GetScrollableArea(); \ EXPECT_EQ(IntSize(), scrollable_area->ScrollOffsetInt()); \ EXPECT_EQ(gfx::Point(), scrollable_area->ScrollOrigin()); \ - EXPECT_EQ(FloatPoint(), scrollable_area->ScrollPosition()); \ + EXPECT_EQ(gfx::PointF(), scrollable_area->ScrollPosition()); \ EXPECT_EQ(IntSize(), scrollable_area->MaximumScrollOffsetInt()); \ EXPECT_EQ(IntSize(), scrollable_area->MinimumScrollOffsetInt()); \ } while (false) @@ -1557,7 +1557,7 @@ } EXPECT_EQ(IntSize(), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(), scrollable_area->ScrollPosition()); // These are the same as in the NonScrollable test. EXPECT_EQ(LayoutRect(0, 0, 540, 400), normal->BorderBoxRect()); EXPECT_EQ(LayoutRect(50, 20, 445, 324), normal->NoOverflowRect()); @@ -1583,7 +1583,7 @@ } EXPECT_EQ(IntSize(), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(), scrollable_area->ScrollPosition()); // These are the same as in the NonScrollable test. EXPECT_EQ(LayoutRect(0, 0, 540, 400), vlr->BorderBoxRect()); EXPECT_EQ(LayoutRect(50, 20, 445, 324), vlr->NoOverflowRect()); @@ -1605,7 +1605,7 @@ } EXPECT_EQ(IntSize(-1615, 0), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(1615, 0), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(1615, 0), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(1615, 0), scrollable_area->ScrollPosition()); // These are the same as in the NonScrollable test. EXPECT_EQ(LayoutRect(0, 0, 540, 400), vrl->BorderBoxRect()); EXPECT_EQ(LayoutRect(45, 20, 445, 324), vrl->NoOverflowRect()); @@ -1622,7 +1622,7 @@ EXPECT_EQ(IntSize(0, 716), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(-1615, 0), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(1615, 0), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(1615, 0), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(1615, 0), scrollable_area->ScrollPosition()); } else { // The contents overflow to the left. // 2020 = child_width + padding_right (without padding_left which is in @@ -1632,7 +1632,7 @@ EXPECT_EQ(IntSize(0, 716), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(-1575, 0), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(1575, 0), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(1575, 0), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(1575, 0), scrollable_area->ScrollPosition()); } // These are the same as in the NonScrollable test. EXPECT_EQ(LayoutRect(0, 0, 540, 400), rtl->BorderBoxRect()); @@ -1650,7 +1650,7 @@ EXPECT_EQ(IntSize(1615, 0), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(0, -716), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(0, 716), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(0, 716), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(0, 716), scrollable_area->ScrollPosition()); } else { // 2060 = child_width + padding_left + padding_right // 1030 = child_height + padding_bottom (without padding_top which is in @@ -1659,7 +1659,7 @@ EXPECT_EQ(IntSize(1615, 0), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(0, -706), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(0, 706), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(0, 706), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(0, 706), scrollable_area->ScrollPosition()); } // These are the same as in the NonScrollable test. EXPECT_EQ(LayoutRect(0, 0, 540, 400), rtl_vlr->BorderBoxRect()); @@ -1678,13 +1678,13 @@ EXPECT_EQ(IntSize(), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(-1615, -716), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(1615, 716), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(1615, 716), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(1615, 716), scrollable_area->ScrollPosition()); } else { EXPECT_EQ(LayoutRect(45, -686, 2060, 1030), rtl_vrl->LayoutOverflowRect()); EXPECT_EQ(IntSize(), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(-1615, -706), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(1615, 706), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(1615, 706), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(1615, 706), scrollable_area->ScrollPosition()); } EXPECT_EQ(IntSize(), rtl_vrl->OriginAdjustmentForScrollbars()); // These are the same as in the NonScrollable test.
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 b43c489..90db51c4 100644 --- a/third_party/blink/renderer/core/layout/layout_embedded_content.cc +++ b/third_party/blink/renderer/core/layout/layout_embedded_content.cc
@@ -39,6 +39,7 @@ #include "third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.h" #include "third_party/blink/renderer/core/paint/embedded_content_painter.h" #include "third_party/blink/renderer/core/paint/paint_layer.h" +#include "ui/gfx/geometry/point_conversions.h" namespace blink { @@ -358,12 +359,12 @@ // accumulation. PhysicalRect replaced_rect = ReplacedContentRect(); TransformState transform_state(TransformState::kApplyTransformDirection, - FloatPoint(), + gfx::PointF(), FloatQuad(FloatRect(replaced_rect))); MapLocalToAncestor(nullptr, transform_state, 0); transform_state.Flatten(); PhysicalOffset absolute_location = - PhysicalOffset::FromFloatPointRound(transform_state.LastPlanarPoint()); + PhysicalOffset::FromPointFRound(transform_state.LastPlanarPoint()); PhysicalRect absolute_replaced_rect = replaced_rect; absolute_replaced_rect.Move(absolute_location); FloatRect absolute_bounding_box = @@ -379,7 +380,7 @@ // RemoteFrameView::frameRectsChanged(). // WebPluginContainerImpl::reportGeometry() // TODO(trchen): Remove this hack once we fixed all callers. - frame_rect.set_origin(RoundedIntPoint(absolute_bounding_box.origin())); + frame_rect.set_origin(gfx::ToRoundedPoint(absolute_bounding_box.origin())); // As an optimization, we don't include the root layer's scroll offset in the // frame rect. As a result, we don't need to recalculate the frame rect every
diff --git a/third_party/blink/renderer/core/layout/layout_flexible_box_test.cc b/third_party/blink/renderer/core/layout/layout_flexible_box_test.cc index a11e0f1..20c4744 100644 --- a/third_party/blink/renderer/core/layout/layout_flexible_box_test.cc +++ b/third_party/blink/renderer/core/layout/layout_flexible_box_test.cc
@@ -102,7 +102,7 @@ } EXPECT_EQ(IntSize(), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(), scrollable_area->ScrollPosition()); const auto* child = GetLayoutBoxByElementId("child"); EXPECT_EQ(LayoutPoint(90, 30), child->Location()); @@ -137,7 +137,7 @@ } EXPECT_EQ(IntSize(), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(), scrollable_area->ScrollPosition()); const auto* child = GetLayoutBoxByElementId("child"); EXPECT_EQ(LayoutPoint(90, 30), child->Location()); @@ -171,7 +171,7 @@ } EXPECT_EQ(IntSize(-1615, 0), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(1615, 0), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(1615, 0), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(1615, 0), scrollable_area->ScrollPosition()); const auto* child = GetLayoutBoxByElementId("child"); // 65 = border_right (30) + padding_right (20) + vertical_scrollbar_width (15) @@ -207,7 +207,7 @@ EXPECT_EQ(IntSize(0, 716), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(-1615, 0), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(1615, 0), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(1615, 0), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(1615, 0), scrollable_area->ScrollPosition()); } else { // -1525 = full_flex_box_width (540) - border-right (30) // - padding_right (20) - vertical_scrollbar_width (15) @@ -223,7 +223,7 @@ // -1575 = -(layout_overflow_width (2020) - client_width (445)) EXPECT_EQ(IntSize(-1575, 0), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(1575, 0), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(1575, 0), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(1575, 0), scrollable_area->ScrollPosition()); } const auto* child = GetLayoutBoxByElementId("child"); @@ -242,7 +242,7 @@ EXPECT_EQ(IntSize(1615, 0), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(0, -716), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(0, 716), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(0, 716), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(0, 716), scrollable_area->ScrollPosition()); } else { // 50 = border_left // -686 = full_flex_box_height (400) - border-bottom (40) - @@ -257,7 +257,7 @@ // -706 = -(layout_overflow_height (1030) - client_height (324)) EXPECT_EQ(IntSize(0, -706), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(0, 706), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(0, 706), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(0, 706), scrollable_area->ScrollPosition()); } const auto* child = GetLayoutBoxByElementId("child"); @@ -285,7 +285,7 @@ EXPECT_EQ(IntSize(), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(-1615, -716), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(1615, 716), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(1615, 716), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(1615, 716), scrollable_area->ScrollPosition()); } else { // 45 = border_right (30) + vertical_scrollbar_width (15) // -686 is the same as RowReverseVLR. @@ -295,7 +295,7 @@ EXPECT_EQ(IntSize(), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(-1615, -706), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(1615, 706), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(1615, 706), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(1615, 706), scrollable_area->ScrollPosition()); } const auto* child = GetLayoutBoxByElementId("child"); @@ -362,13 +362,13 @@ EXPECT_EQ(IntSize(1615, 0), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(0, -716), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(0, 716), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(0, 716), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(0, 716), scrollable_area->ScrollPosition()); } else { EXPECT_EQ(LayoutRect(50, -686, 2040, 1030), flex_box->LayoutOverflowRect()); EXPECT_EQ(IntSize(1595, 0), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(0, -706), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(0, 706), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(0, 706), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(0, 706), scrollable_area->ScrollPosition()); } const auto* child = GetLayoutBoxByElementId("child"); @@ -394,14 +394,14 @@ EXPECT_EQ(IntSize(0, 716), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(-1615, 0), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(1615, 0), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(1615, 0), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(1615, 0), scrollable_area->ScrollPosition()); } else { EXPECT_EQ(LayoutRect(-1525, 20, 2020, 1010), flex_box->LayoutOverflowRect()); EXPECT_EQ(IntSize(0, 686), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(-1575, 0), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(1575, 0), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(1575, 0), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(1575, 0), scrollable_area->ScrollPosition()); } const auto* child = GetLayoutBoxByElementId("child"); @@ -432,7 +432,7 @@ } EXPECT_EQ(IntSize(), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(), scrollable_area->ScrollPosition()); const auto* child = GetLayoutBoxByElementId("child"); EXPECT_EQ(LayoutPoint(-1550, 30), child->Location()); @@ -452,14 +452,14 @@ EXPECT_EQ(IntSize(0, 716), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(-1615, 0), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(1615, 0), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(1615, 0), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(1615, 0), scrollable_area->ScrollPosition()); } else { EXPECT_EQ(LayoutRect(-1510, 20, 2020, 1040), flex_box->LayoutOverflowRect()); EXPECT_EQ(IntSize(0, 716), scrollable_area->MaximumScrollOffsetInt()); EXPECT_EQ(IntSize(-1575, 0), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(1575, 0), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(1575, 0), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(1575, 0), scrollable_area->ScrollPosition()); } const auto* child = GetLayoutBoxByElementId("child"); @@ -516,7 +516,7 @@ } EXPECT_EQ(IntSize(0, 0), scrollable_area->MinimumScrollOffsetInt()); EXPECT_EQ(gfx::Point(0, 0), scrollable_area->ScrollOrigin()); - EXPECT_EQ(FloatPoint(0, 0), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(0, 0), scrollable_area->ScrollPosition()); const auto* child = GetLayoutBoxByElementId("child"); EXPECT_EQ(LayoutPoint(105, 30), child->Location());
diff --git a/third_party/blink/renderer/core/layout/layout_frame_set.cc b/third_party/blink/renderer/core/layout/layout_frame_set.cc index c835e11..939dd92 100644 --- a/third_party/blink/renderer/core/layout/layout_frame_set.cc +++ b/third_party/blink/renderer/core/layout/layout_frame_set.cc
@@ -496,8 +496,8 @@ if (evt.type() == event_type_names::kMousedown && evt.button() == static_cast<int16_t>(WebPointerProperties::Button::kLeft)) { - FloatPoint local_pos = - AbsoluteToLocalFloatPoint(FloatPoint(evt.AbsoluteLocation())); + gfx::PointF local_pos = + AbsoluteToLocalPoint(gfx::PointF(evt.AbsoluteLocation())); StartResizing(cols_, local_pos.x()); StartResizing(rows_, local_pos.y()); if (cols_.split_being_resized_ != kNoSplit || @@ -511,8 +511,8 @@ (evt.type() == event_type_names::kMouseup && evt.button() == static_cast<int16_t>(WebPointerProperties::Button::kLeft))) { - FloatPoint local_pos = - AbsoluteToLocalFloatPoint(FloatPoint(evt.AbsoluteLocation())); + gfx::PointF local_pos = + AbsoluteToLocalPoint(gfx::PointF(evt.AbsoluteLocation())); ContinueResizing(cols_, local_pos.x()); ContinueResizing(rows_, local_pos.y()); if (evt.type() == event_type_names::kMouseup &&
diff --git a/third_party/blink/renderer/core/layout/layout_media.cc b/third_party/blink/renderer/core/layout/layout_media.cc index d523718c..b6fcdc1 100644 --- a/third_party/blink/renderer/core/layout/layout_media.cc +++ b/third_party/blink/renderer/core/layout/layout_media.cc
@@ -187,13 +187,13 @@ // On desktop, this will include scrollbars when they stay visible. const LayoutUnit visible_width(page->GetVisualViewport().VisibleWidth()); // The bottom left corner of the video. - const FloatPoint bottom_left_point( - LocalToAbsoluteFloatPoint(FloatPoint(media_rect.X(), media_rect.MaxY()), - kTraverseDocumentBoundaries)); + const gfx::PointF bottom_left_point( + LocalToAbsolutePoint(gfx::PointF(media_rect.X(), media_rect.MaxY()), + kTraverseDocumentBoundaries)); // The bottom right corner of the video. - const FloatPoint bottom_right_point(LocalToAbsoluteFloatPoint( - FloatPoint(media_rect.MaxX(), media_rect.MaxY()), - kTraverseDocumentBoundaries)); + const gfx::PointF bottom_right_point( + LocalToAbsolutePoint(gfx::PointF(media_rect.MaxX(), media_rect.MaxY()), + kTraverseDocumentBoundaries)); const bool bottom_left_corner_visible = bottom_left_point.x() < visible_width; const bool bottom_right_corner_visible = @@ -227,13 +227,10 @@ const float edge_intersection_y = bottom_left_point.y() + ((visible_width - bottom_left_point.x()) * slope); - const FloatPoint edge_intersection_point(visible_width, edge_intersection_y); + const gfx::PointF edge_intersection_point(visible_width, edge_intersection_y); // Calculate difference. - FloatPoint difference_vector = edge_intersection_point; - difference_vector.Offset(-bottom_left_point.x(), -bottom_left_point.y()); - - return LayoutUnit(difference_vector.length()); + return LayoutUnit((edge_intersection_point - bottom_left_point).Length()); } } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/layout_object.cc b/third_party/blink/renderer/core/layout/layout_object.cc index b32a8f1..a3a79bf 100644 --- a/third_party/blink/renderer/core/layout/layout_object.cc +++ b/third_party/blink/renderer/core/layout/layout_object.cc
@@ -3230,9 +3230,9 @@ return View()->ViewRect(); } -FloatPoint LayoutObject::AncestorToLocalFloatPoint( +gfx::PointF LayoutObject::AncestorToLocalPoint( const LayoutBoxModelObject* ancestor, - const FloatPoint& container_point, + const gfx::PointF& container_point, MapCoordinatesFlags mode) const { NOT_DESTROYED(); TransformState transform_state( @@ -3446,7 +3446,7 @@ if (has_perspective) { // Perspective on the container affects us, so we have to factor it in here. DCHECK(container_object->HasLayer()); - FloatPoint perspective_origin; + gfx::PointF perspective_origin; if (const auto* container_box = DynamicTo<LayoutBox>(container_object)) perspective_origin = container_box->PerspectiveOrigin(size); @@ -3460,8 +3460,8 @@ } } -FloatPoint LayoutObject::LocalToAncestorFloatPoint( - const FloatPoint& local_point, +gfx::PointF LayoutObject::LocalToAncestorPoint( + const gfx::PointF& local_point, const LayoutBoxModelObject* ancestor, MapCoordinatesFlags mode) const { NOT_DESTROYED();
diff --git a/third_party/blink/renderer/core/layout/layout_object.h b/third_party/blink/renderer/core/layout/layout_object.h index 013ff553b..c02b5c7e 100644 --- a/third_party/blink/renderer/core/layout/layout_object.h +++ b/third_party/blink/renderer/core/layout/layout_object.h
@@ -2378,12 +2378,12 @@ const PhysicalOffset& p, MapCoordinatesFlags mode = 0) const { NOT_DESTROYED(); - return PhysicalOffset::FromFloatPointRound( - AncestorToLocalFloatPoint(ancestor, FloatPoint(p), mode)); + return PhysicalOffset::FromPointFRound( + AncestorToLocalPoint(ancestor, gfx::PointF(p), mode)); } - FloatPoint AncestorToLocalFloatPoint(const LayoutBoxModelObject* ancestor, - const FloatPoint& p, - MapCoordinatesFlags = 0) const; + gfx::PointF AncestorToLocalPoint(const LayoutBoxModelObject* ancestor, + const gfx::PointF& p, + MapCoordinatesFlags = 0) const; // Convert a rect/quad/point in local physical coordinates into ancestor // coordinates, taking transforms into account unless kIgnoreTransforms is @@ -2413,12 +2413,12 @@ const LayoutBoxModelObject* ancestor, MapCoordinatesFlags mode = 0) const { NOT_DESTROYED(); - return PhysicalOffset::FromFloatPointRound( - LocalToAncestorFloatPoint(FloatPoint(p), ancestor, mode)); + return PhysicalOffset::FromPointFRound( + LocalToAncestorPoint(gfx::PointF(p), ancestor, mode)); } - FloatPoint LocalToAncestorFloatPoint(const FloatPoint&, - const LayoutBoxModelObject* ancestor, - MapCoordinatesFlags = 0) const; + gfx::PointF LocalToAncestorPoint(const gfx::PointF&, + const LayoutBoxModelObject* ancestor, + MapCoordinatesFlags = 0) const; void LocalToAncestorRects(Vector<PhysicalRect>&, const LayoutBoxModelObject* ancestor, const PhysicalOffset& pre_offset, @@ -2461,10 +2461,10 @@ NOT_DESTROYED(); return LocalToAncestorPoint(p, nullptr, mode); } - FloatPoint LocalToAbsoluteFloatPoint(const FloatPoint& p, - MapCoordinatesFlags mode = 0) const { + gfx::PointF LocalToAbsolutePoint(const gfx::PointF& p, + MapCoordinatesFlags mode = 0) const { NOT_DESTROYED(); - return LocalToAncestorFloatPoint(p, nullptr, mode); + return LocalToAncestorPoint(p, nullptr, mode); } PhysicalRect AbsoluteToLocalRect(const PhysicalRect& rect, MapCoordinatesFlags mode = 0) const { @@ -2481,10 +2481,10 @@ NOT_DESTROYED(); return AncestorToLocalPoint(nullptr, p, mode); } - FloatPoint AbsoluteToLocalFloatPoint(const FloatPoint& p, - MapCoordinatesFlags mode = 0) const { + gfx::PointF AbsoluteToLocalPoint(const gfx::PointF& p, + MapCoordinatesFlags mode = 0) const { NOT_DESTROYED(); - return AncestorToLocalFloatPoint(nullptr, p, mode); + return AncestorToLocalPoint(nullptr, p, mode); } // Return the offset from the container() layoutObject (excluding transforms
diff --git a/third_party/blink/renderer/core/layout/layout_shift_tracker_test.cc b/third_party/blink/renderer/core/layout/layout_shift_tracker_test.cc index 451cafb..cc1aaf0 100644 --- a/third_party/blink/renderer/core/layout/layout_shift_tracker_test.cc +++ b/third_party/blink/renderer/core/layout/layout_shift_tracker_test.cc
@@ -1116,7 +1116,7 @@ )HTML"); GetDocument().GetPage()->GetVisualViewport().SetSize(IntSize(200, 500)); - GetDocument().GetPage()->GetVisualViewport().SetLocation(FloatPoint(0, 100)); + GetDocument().GetPage()->GetVisualViewport().SetLocation(gfx::PointF(0, 100)); UpdateAllLifecyclePhasesForTest(); // The visual viewport. EXPECT_EQ(IntRect(0, 100, 200, 500),
diff --git a/third_party/blink/renderer/core/layout/layout_text.cc b/third_party/blink/renderer/core/layout/layout_text.cc index cebd857..7a2dc74c0 100644 --- a/third_party/blink/renderer/core/layout/layout_text.cc +++ b/third_party/blink/renderer/core/layout/layout_text.cc
@@ -2477,7 +2477,7 @@ if (svg_inline_text) { FloatRect float_rect(item_rect); const NGFragmentItem& item = *cursor.CurrentItem(); - float_rect.MoveBy(FloatPoint(item.SvgFragmentData()->rect.origin())); + float_rect.MoveBy(item.SvgFragmentData()->rect.origin()); if (item.HasSvgTransformForBoundingBox()) { float_rect = item.BuildSvgTransformForBoundingBox().MapRect(float_rect);
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 dd6dea8b..7cc58c28 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
@@ -111,6 +111,10 @@ return ts << c.NameForLayoutTreeAsText(); } +WTF::TextStream& operator<<(WTF::TextStream& ts, const LayoutPoint& point) { + return ts << gfx::PointF(point); +} + WTF::TextStream& operator<<(WTF::TextStream& ts, const gfx::Point& p) { return ts << "(" << p.x() << "," << p.y() << ")"; } @@ -637,14 +641,11 @@ ts << " transparent"; if (layer.GetLayoutObject().IsScrollContainer()) { - PaintLayerScrollableArea* scrollable_area = layer.GetScrollableArea(); - ScrollOffset adjusted_scroll_offset = - scrollable_area->GetScrollOffset() + - ToFloatSize(FloatPoint(scrollable_area->ScrollOrigin())); - if (adjusted_scroll_offset.width()) - ts << " scrollX " << adjusted_scroll_offset.width(); - if (adjusted_scroll_offset.height()) - ts << " scrollY " << adjusted_scroll_offset.height(); + gfx::PointF scroll_position = layer.GetScrollableArea()->ScrollPosition(); + if (scroll_position.x()) + ts << " scrollX " << scroll_position.x(); + if (scroll_position.y()) + ts << " scrollY " << scroll_position.y(); if (layer.GetLayoutBox() && layer.GetLayoutBox()->PixelSnappedClientWidth() != layer.GetLayoutBox()->PixelSnappedScrollWidth())
diff --git a/third_party/blink/renderer/core/layout/layout_tree_as_text.h b/third_party/blink/renderer/core/layout/layout_tree_as_text.h index 1bec7b23..ea5cc00e 100644 --- a/third_party/blink/renderer/core/layout/layout_tree_as_text.h +++ b/third_party/blink/renderer/core/layout/layout_tree_as_text.h
@@ -48,6 +48,7 @@ class LocalFrame; class LayoutBlockFlow; class LayoutObject; +class LayoutPoint; enum LayoutAsTextBehaviorFlags { kLayoutAsTextBehaviorNormal = 0, @@ -113,6 +114,7 @@ // Helper function shared with SVGLayoutTreeAsText (so they are not exported). String QuoteAndEscapeNonPrintables(const String&); WTF::TextStream& operator<<(WTF::TextStream&, const Color&); +WTF::TextStream& operator<<(WTF::TextStream& ts, const LayoutPoint&); WTF::TextStream& operator<<(WTF::TextStream&, const gfx::Point&); WTF::TextStream& operator<<(WTF::TextStream&, const gfx::Size&); WTF::TextStream& operator<<(WTF::TextStream&, const gfx::Rect&);
diff --git a/third_party/blink/renderer/core/layout/line/breaking_context_inline_headers.h b/third_party/blink/renderer/core/layout/line/breaking_context_inline_headers.h index 1641aef..440630ba 100644 --- a/third_party/blink/renderer/core/layout/line/breaking_context_inline_headers.h +++ b/third_party/blink/renderer/core/layout/line/breaking_context_inline_headers.h
@@ -917,7 +917,7 @@ word_measurement); } - FloatRect rect = font.SelectionRectForText(run, FloatPoint(), 0, 0, len); + FloatRect rect = font.SelectionRectForText(run, gfx::PointF(), 0, 0, len); return RewindToMidWordBreak(word_measurement, end, rect.width()); }
diff --git a/third_party/blink/renderer/core/layout/line/ellipsis_box.cc b/third_party/blink/renderer/core/layout/line/ellipsis_box.cc index 2cbfe30..1a82c176 100644 --- a/third_party/blink/renderer/core/layout/line/ellipsis_box.cc +++ b/third_party/blink/renderer/core/layout/line/ellipsis_box.cc
@@ -43,8 +43,8 @@ const Font& font = style.GetFont(); return EnclosingIntRect(font.SelectionRectForText( ConstructTextRun(font, str_, style, TextRun::kAllowTrailingExpansion), - FloatPoint(LogicalLeft().ToInt(), - (LogicalTop() + Root().SelectionTop()).ToInt()), + gfx::PointF(LogicalLeft().ToInt(), + (LogicalTop() + Root().SelectionTop()).ToInt()), Root().SelectionHeight().ToInt())); }
diff --git a/third_party/blink/renderer/core/layout/line/inline_text_box.cc b/third_party/blink/renderer/core/layout/line/inline_text_box.cc index 3dab21a4..b8a8f838 100644 --- a/third_party/blink/renderer/core/layout/line/inline_text_box.cc +++ b/third_party/blink/renderer/core/layout/line/inline_text_box.cc
@@ -274,7 +274,7 @@ LayoutRect r; if (s_pos || e_pos != static_cast<int>(len_)) { r = LayoutRect(EnclosingIntRect( - font.SelectionRectForText(text_run, FloatPoint(starting_point), + font.SelectionRectForText(text_run, gfx::PointF(starting_point), sel_height.ToInt(), s_pos, e_pos))); } else { // Avoid computing the font width when the entire line box is selected as an @@ -598,7 +598,7 @@ // FIXME: Do we need to add rightBearing here? return LayoutUnit(font.SelectionRectForText( ConstructTextRun(style_to_use), - FloatPoint(LogicalLeft().ToInt(), 0), 0, from, to) + gfx::PointF(LogicalLeft().ToInt(), 0), 0, from, to) .right()); }
diff --git a/third_party/blink/renderer/core/layout/map_coordinates_test.cc b/third_party/blink/renderer/core/layout/map_coordinates_test.cc index c09f6f24..acea539 100644 --- a/third_party/blink/renderer/core/layout/map_coordinates_test.cc +++ b/third_party/blink/renderer/core/layout/map_coordinates_test.cc
@@ -158,7 +158,7 @@ To<Element>(overflow->GetNode()) ->GetLayoutBoxForScrolling() ->GetScrollableArea() - ->ScrollToAbsolutePosition(FloatPoint(32, 54)); + ->ScrollToAbsolutePosition(gfx::PointF(32, 54)); PhysicalOffset mapped_point = MapLocalToAncestor(target, To<LayoutBoxModelObject>(target->Parent()), @@ -1434,11 +1434,11 @@ auto* target = GetLayoutBoxByElementId("target"); auto* container = GetLayoutBoxByElementId("container"); - FloatQuad initial_quad(FloatPoint(0, 0), FloatPoint(200, 0), - FloatPoint(200, 200), FloatPoint(0, 200)); + FloatQuad initial_quad(gfx::PointF(0, 0), gfx::PointF(200, 0), + gfx::PointF(200, 200), gfx::PointF(0, 200)); FloatQuad mapped_quad = MapLocalToAncestor(target, container, initial_quad); - EXPECT_FLOAT_QUAD_EQ(FloatQuad(FloatPoint(200, 0), FloatPoint(200, 200), - FloatPoint(0, 200), FloatPoint(0, 0)), + EXPECT_FLOAT_QUAD_EQ(FloatQuad(gfx::PointF(200, 0), gfx::PointF(200, 200), + gfx::PointF(0, 200), gfx::PointF(0, 0)), mapped_quad); mapped_quad = MapAncestorToLocal(target, container, mapped_quad); EXPECT_FLOAT_QUAD_EQ(initial_quad, mapped_quad); @@ -1448,31 +1448,31 @@ auto* outer_transform = GetLayoutBoxByElementId("outerTransform"); mapped_quad = MapLocalToAncestor(target, inner_transform, initial_quad); - EXPECT_FLOAT_QUAD_EQ(FloatQuad(FloatPoint(0, 0), FloatPoint(200, 0), - FloatPoint(200, 200), FloatPoint(0, 200)), + EXPECT_FLOAT_QUAD_EQ(FloatQuad(gfx::PointF(0, 0), gfx::PointF(200, 0), + gfx::PointF(200, 200), gfx::PointF(0, 200)), mapped_quad); mapped_quad = MapAncestorToLocal(target, inner_transform, mapped_quad); EXPECT_FLOAT_QUAD_EQ(initial_quad, mapped_quad); - initial_quad = FloatQuad(FloatPoint(0, 0), FloatPoint(200, 0), - FloatPoint(200, 200), FloatPoint(0, 200)); + initial_quad = FloatQuad(gfx::PointF(0, 0), gfx::PointF(200, 0), + gfx::PointF(200, 200), gfx::PointF(0, 200)); mapped_quad = MapLocalToAncestor(inner_transform, outer_transform, initial_quad); // Clockwise rotation by 45 degrees. EXPECT_FLOAT_QUAD_EQ( - FloatQuad(FloatPoint(100, -41.42), FloatPoint(241.42, 100), - FloatPoint(100, 241.42), FloatPoint(-41.42, 100)), + FloatQuad(gfx::PointF(100, -41.42), gfx::PointF(241.42, 100), + gfx::PointF(100, 241.42), gfx::PointF(-41.42, 100)), mapped_quad); mapped_quad = MapAncestorToLocal(inner_transform, outer_transform, mapped_quad); EXPECT_FLOAT_QUAD_EQ(initial_quad, mapped_quad); - initial_quad = FloatQuad(FloatPoint(100, -41.42), FloatPoint(241.42, 100), - FloatPoint(100, 241.42), FloatPoint(-41.42, 100)); + initial_quad = FloatQuad(gfx::PointF(100, -41.42), gfx::PointF(241.42, 100), + gfx::PointF(100, 241.42), gfx::PointF(-41.42, 100)); mapped_quad = MapLocalToAncestor(outer_transform, container, initial_quad); // Another clockwise rotation by 45 degrees. So now 90 degrees in total. - EXPECT_FLOAT_QUAD_EQ(FloatQuad(FloatPoint(200, 0), FloatPoint(200, 200), - FloatPoint(0, 200), FloatPoint(0, 0)), + EXPECT_FLOAT_QUAD_EQ(FloatQuad(gfx::PointF(200, 0), gfx::PointF(200, 200), + gfx::PointF(0, 200), gfx::PointF(0, 0)), mapped_quad); mapped_quad = MapAncestorToLocal(outer_transform, container, mapped_quad); EXPECT_FLOAT_QUAD_EQ(initial_quad, mapped_quad); @@ -1650,9 +1650,9 @@ TransformationMatrix child_matrix = child->LocalToAbsoluteTransform(); EXPECT_FALSE(child_matrix.IsIdentityOrTranslation()); EXPECT_TRUE(child_matrix.IsAffine()); - EXPECT_EQ(FloatPoint(), child_matrix.ProjectPoint(FloatPoint())); - EXPECT_EQ(FloatPoint(20.0f, 40.0f), - child_matrix.ProjectPoint(FloatPoint(10.0f, 20.0f))); + EXPECT_EQ(gfx::PointF(), child_matrix.ProjectPoint(gfx::PointF())); + EXPECT_EQ(gfx::PointF(20.0f, 40.0f), + child_matrix.ProjectPoint(gfx::PointF(10.0f, 20.0f))); } TEST_F(MapCoordinatesTest, LocalToAncestorTransform) { @@ -1683,9 +1683,9 @@ matrix = child->LocalToAncestorTransform(rotate1); EXPECT_FALSE(matrix.IsIdentity()); EXPECT_TRUE(matrix.IsAffine()); - EXPECT_NEAR(0.0, matrix.ProjectPoint(FloatPoint(100.0, 0.0)).x(), + EXPECT_NEAR(0.0, matrix.ProjectPoint(gfx::PointF(100.0, 0.0)).x(), LayoutUnit::Epsilon()); - EXPECT_NEAR(100.0, matrix.ProjectPoint(FloatPoint(100.0, 0.0)).y(), + EXPECT_NEAR(100.0, matrix.ProjectPoint(gfx::PointF(100.0, 0.0)).y(), LayoutUnit::Epsilon()); // Rotate (100, 0) 135 degrees to (-70.7, 70.7) @@ -1693,10 +1693,10 @@ EXPECT_FALSE(matrix.IsIdentity()); EXPECT_TRUE(matrix.IsAffine()); EXPECT_NEAR(-100.0 * sqrt(2.0) / 2.0, - matrix.ProjectPoint(FloatPoint(100.0, 0.0)).x(), + matrix.ProjectPoint(gfx::PointF(100.0, 0.0)).x(), LayoutUnit::Epsilon()); EXPECT_NEAR(100.0 * sqrt(2.0) / 2.0, - matrix.ProjectPoint(FloatPoint(100.0, 0.0)).y(), + matrix.ProjectPoint(gfx::PointF(100.0, 0.0)).y(), LayoutUnit::Epsilon()); } @@ -1723,25 +1723,25 @@ // With child1, the rotations cancel and points should map basically back to // themselves. - EXPECT_NEAR(100.0, matrix.MapPoint(FloatPoint(100.0, 50.0)).x(), + EXPECT_NEAR(100.0, matrix.MapPoint(gfx::PointF(100.0, 50.0)).x(), LayoutUnit::Epsilon()); - EXPECT_NEAR(50.0, matrix.MapPoint(FloatPoint(100.0, 50.0)).y(), + EXPECT_NEAR(50.0, matrix.MapPoint(gfx::PointF(100.0, 50.0)).y(), LayoutUnit::Epsilon()); - EXPECT_NEAR(50.0, matrix.MapPoint(FloatPoint(50.0, 100.0)).x(), + EXPECT_NEAR(50.0, matrix.MapPoint(gfx::PointF(50.0, 100.0)).x(), LayoutUnit::Epsilon()); - EXPECT_NEAR(100.0, matrix.MapPoint(FloatPoint(50.0, 100.0)).y(), + EXPECT_NEAR(100.0, matrix.MapPoint(gfx::PointF(50.0, 100.0)).y(), LayoutUnit::Epsilon()); // With child2, each rotation gets flattened and the end result is // approximately a scale(1.0, 0.5). matrix = child2->LocalToAbsoluteTransform(); - EXPECT_NEAR(50.0, matrix.MapPoint(FloatPoint(100.0, 50.0)).x(), + EXPECT_NEAR(50.0, matrix.MapPoint(gfx::PointF(100.0, 50.0)).x(), LayoutUnit::Epsilon()); - EXPECT_NEAR(50.0, matrix.MapPoint(FloatPoint(100.0, 50.0)).y(), + EXPECT_NEAR(50.0, matrix.MapPoint(gfx::PointF(100.0, 50.0)).y(), LayoutUnit::Epsilon()); - EXPECT_NEAR(25.0, matrix.MapPoint(FloatPoint(50.0, 100.0)).x(), + EXPECT_NEAR(25.0, matrix.MapPoint(gfx::PointF(50.0, 100.0)).x(), LayoutUnit::Epsilon()); - EXPECT_NEAR(100.0, matrix.MapPoint(FloatPoint(50.0, 100.0)).y(), + EXPECT_NEAR(100.0, matrix.MapPoint(gfx::PointF(50.0, 100.0)).y(), LayoutUnit::Epsilon()); } @@ -1818,7 +1818,7 @@ To<Element>(scroller->GetNode()) ->GetLayoutBoxForScrolling() ->GetScrollableArea() - ->ScrollToAbsolutePosition(FloatPoint(0, 50)); + ->ScrollToAbsolutePosition(gfx::PointF(0, 50)); EXPECT_EQ(PhysicalOffset(0, -40), MapLocalToAncestor(box, scroller, PhysicalOffset())); @@ -1857,7 +1857,7 @@ To<Element>(scroller->GetNode()) ->GetLayoutBoxForScrolling() ->GetScrollableArea() - ->ScrollToAbsolutePosition(FloatPoint(0, 50)); + ->ScrollToAbsolutePosition(gfx::PointF(0, 50)); EXPECT_EQ(PhysicalOffset(0, 10), MapLocalToAncestor(box, scroller, PhysicalOffset())); @@ -1894,7 +1894,7 @@ scroll_element->GetLayoutBoxForScrolling() ->GetScrollableArea() - ->ScrollToAbsolutePosition(FloatPoint(0, 50)); + ->ScrollToAbsolutePosition(gfx::PointF(0, 50)); EXPECT_EQ(PhysicalOffset(1990, -40), MapLocalToAncestor(box, scroller, PhysicalOffset())); @@ -1904,7 +1904,7 @@ scroll_element->GetLayoutBoxForScrolling() ->GetScrollableArea() - ->ScrollToAbsolutePosition(FloatPoint(1900, 50)); + ->ScrollToAbsolutePosition(gfx::PointF(1900, 50)); EXPECT_EQ(PhysicalOffset(90, -40), MapLocalToAncestor(box, scroller, PhysicalOffset())); @@ -1947,7 +1947,7 @@ To<Element>(scroller->GetNode()) ->GetLayoutBoxForScrolling() ->GetScrollableArea() - ->ScrollToAbsolutePosition(FloatPoint(0, 0)); + ->ScrollToAbsolutePosition(gfx::PointF(0, 0)); // The box is now on the right of the scrollbar therefore there is nothing // between the box and the right border of the content.
diff --git a/third_party/blink/renderer/core/layout/ng/inline/ng_fragment_item.cc b/third_party/blink/renderer/core/layout/ng/inline/ng_fragment_item.cc index 718dcf3..46e72ad 100644 --- a/third_party/blink/renderer/core/layout/ng/inline/ng_fragment_item.cc +++ b/third_party/blink/renderer/core/layout/ng/inline/ng_fragment_item.cc
@@ -394,11 +394,10 @@ if (Type() != kSvgText || !HasSvgTransformForBoundingBox()) return point; const float scaling_factor = SvgScalingFactor(); - return PhysicalOffset::FromFloatPointRound( - BuildSvgTransformForBoundingBox() - .Inverse() - .MapPoint(FloatPoint(point).ScaledBy(scaling_factor)) - .ScaledBy(1 / scaling_factor)); + return PhysicalOffset::FromPointFRound( + gfx::ScalePoint(BuildSvgTransformForBoundingBox().Inverse().MapPoint( + gfx::ScalePoint(gfx::PointF(point), scaling_factor)), + scaling_factor)); } float NGFragmentItem::ScaleInlineOffset(LayoutUnit inline_offset) const {
diff --git a/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.cc b/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.cc index 3c88527..20ed0861 100644 --- a/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.cc +++ b/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.cc
@@ -264,7 +264,7 @@ PositionWithAffinity LayoutNGSVGText::PositionForPoint( const PhysicalOffset& point_in_contents) const { NOT_DESTROYED(); - FloatPoint point(point_in_contents.left, point_in_contents.top); + gfx::PointF point(point_in_contents.left, point_in_contents.top); float min_distance = std::numeric_limits<float>::max(); const LayoutSVGInlineText* closest_inline_text = nullptr; for (const LayoutObject* descendant = FirstChild(); descendant;
diff --git a/third_party/blink/renderer/core/layout/ng/svg/ng_svg_text_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/svg/ng_svg_text_layout_algorithm.cc index a975722..2cdcc72 100644 --- a/third_party/blink/renderer/core/layout/ng/svg/ng_svg_text_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/svg/ng_svg_text_layout_algorithm.cc
@@ -142,8 +142,8 @@ ascent = font_data->GetFontMetrics().FixedAscent( item.Style().GetFontBaseline()); } - FloatPoint offset(logical_offset.inline_offset, - logical_offset.block_offset + ascent); + gfx::PointF offset(logical_offset.inline_offset, + logical_offset.block_offset + ascent); if (!horizontal_) offset.SetPoint(-offset.y(), offset.x()); css_positions_.push_back(offset); @@ -174,7 +174,7 @@ // attributes, initialized to (0,0). // TODO(crbug.com/1179585): Report a specification bug on "'x' and 'y' // attributes". - FloatPoint shift; + gfx::PointF shift; // 2. For each array element with index i in result: ResolvedTextLayoutAttributesIterator iterator( inline_node_.SvgCharacterDataList()); @@ -392,7 +392,7 @@ // 1. Let shift be the current adjustment due to the ‘x’ and ‘y’ attributes, // initialized to (0,0). - FloatPoint shift; + gfx::PointF shift; // 2. Set index = 1. // 3. While index < count: // 3.5. Set index to index + 1.
diff --git a/third_party/blink/renderer/core/layout/ng/svg/ng_svg_text_layout_algorithm.h b/third_party/blink/renderer/core/layout/ng/svg/ng_svg_text_layout_algorithm.h index 98af100f9..8a9c16c 100644 --- a/third_party/blink/renderer/core/layout/ng/svg/ng_svg_text_layout_algorithm.h +++ b/third_party/blink/renderer/core/layout/ng/svg/ng_svg_text_layout_algorithm.h
@@ -80,7 +80,7 @@ // This data member represents "CSS_positions" defined in the specification, // but it contains only addressable characters. - Vector<FloatPoint> css_positions_; + Vector<gfx::PointF> css_positions_; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/scroll_anchor.cc b/third_party/blink/renderer/core/layout/scroll_anchor.cc index 2aca96e..54c2e8d0 100644 --- a/third_party/blink/renderer/core/layout/scroll_anchor.cc +++ b/third_party/blink/renderer/core/layout/scroll_anchor.cc
@@ -731,11 +731,11 @@ // roughly the same. ScrollOffset current_offset = scroller_->GetScrollOffset(); FloatRect bounding_box = anchor_object->AbsoluteBoundingBoxFloatRect(); - FloatPoint location_point = + gfx::PointF location_point = anchor_object->Style()->IsFlippedBlocksWritingMode() ? bounding_box.top_right() : bounding_box.origin(); - FloatPoint desired_point = location_point + current_offset; + gfx::PointF desired_point = location_point + ToGfxVector2dF(current_offset); ScrollOffset desired_offset = ScrollOffset(desired_point.x(), desired_point.y());
diff --git a/third_party/blink/renderer/core/layout/scroll_anchor_test.cc b/third_party/blink/renderer/core/layout/scroll_anchor_test.cc index fa94042c..4938b4b 100644 --- a/third_party/blink/renderer/core/layout/scroll_anchor_test.cc +++ b/third_party/blink/renderer/core/layout/scroll_anchor_test.cc
@@ -213,7 +213,7 @@ // Scroll the visual viewport to bring #text to the top. int top = GetDocument().getElementById("text")->getBoundingClientRect()->top(); - v_viewport.SetLocation(FloatPoint(0, top)); + v_viewport.SetLocation(gfx::PointF(0, top)); SetHeight(GetDocument().getElementById("div"), 10); EXPECT_EQ(GetDocument().getElementById("text")->GetLayoutObject(), @@ -226,7 +226,7 @@ EXPECT_EQ(top, v_viewport.ScrollOffsetInt().height()); // Scrolling the visual viewport should clear the anchor. - v_viewport.SetLocation(FloatPoint(0, 0)); + v_viewport.SetLocation(gfx::PointF(0, 0)); EXPECT_EQ(nullptr, GetScrollAnchor(l_viewport).AnchorObject()); }
diff --git a/third_party/blink/renderer/core/layout/shapes/shape.cc b/third_party/blink/renderer/core/layout/shapes/shape.cc index 7fea6df2..c309da8 100644 --- a/third_party/blink/renderer/core/layout/shapes/shape.cc +++ b/third_party/blink/renderer/core/layout/shapes/shape.cc
@@ -252,7 +252,7 @@ // for layout, which is not allowed. See https://crbug.com/429346 ImageObserverDisabler disabler(image); PaintFlags flags; - FloatRect image_source_rect(FloatPoint(), FloatSize(image->Size())); + FloatRect image_source_rect(gfx::PointF(), FloatSize(image->Size())); IntRect image_dest_rect(gfx::Point(), image_size); SkiaPaintCanvas canvas(surface->getCanvas()); canvas.clear(SK_ColorTRANSPARENT);
diff --git a/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc b/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc index 73285a7..7875cc5 100644 --- a/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc +++ b/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc
@@ -478,13 +478,14 @@ return PhysicalRect(physical_bounding_box); } -FloatPoint ShapeOutsideInfo::ShapeToLayoutObjectPoint(FloatPoint point) const { - FloatPoint result = FloatPoint(point.x() + LogicalLeftOffset(), - point.y() + LogicalTopOffset()); +gfx::PointF ShapeOutsideInfo::ShapeToLayoutObjectPoint( + gfx::PointF point) const { + gfx::PointF result = gfx::PointF(point.x() + LogicalLeftOffset(), + point.y() + LogicalTopOffset()); if (layout_box_->StyleRef().IsFlippedBlocksWritingMode()) result.set_y(layout_box_->LogicalHeight() - result.y()); if (!layout_box_->StyleRef().IsHorizontalWritingMode()) - result = result.TransposedPoint(); + result.Transpose(); return result; }
diff --git a/third_party/blink/renderer/core/layout/shapes/shape_outside_info.h b/third_party/blink/renderer/core/layout/shapes/shape_outside_info.h index fbd8961f..dd976387 100644 --- a/third_party/blink/renderer/core/layout/shapes/shape_outside_info.h +++ b/third_party/blink/renderer/core/layout/shapes/shape_outside_info.h
@@ -132,7 +132,7 @@ bool IsComputingShape() const { return is_computing_shape_; } PhysicalRect ComputedShapePhysicalBoundingBox() const; - FloatPoint ShapeToLayoutObjectPoint(FloatPoint) const; + gfx::PointF ShapeToLayoutObjectPoint(gfx::PointF) const; const Shape& ComputedShape() const; void Trace(Visitor* visitor) const;
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_container.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_container.cc index d4ba15a..19ee6ae5 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_container.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_container.cc
@@ -219,7 +219,7 @@ // containers. if (IsObjectBoundingBoxValid() && local_location->Intersects(ObjectBoundingBox())) { - UpdateHitTestResult(result, PhysicalOffset::FromFloatPointRound( + UpdateHitTestResult(result, PhysicalOffset::FromPointFRound( local_location->TransformedPoint())); if (result.AddNodeToListBasedTestResult(GetElement(), *local_location) == kStopHitTesting)
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_ellipse.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_ellipse.cc index 531e48c6..7e5e29d 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_ellipse.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_ellipse.cc
@@ -115,11 +115,10 @@ if (use_path_fallback_ || radius_x_ != radius_y_) return LayoutSVGShape::ShapeDependentStrokeContains(location); - const FloatPoint& point = location.TransformedPoint(); - const FloatPoint center = - FloatPoint(center_.x() - point.x(), center_.y() - point.y()); + const gfx::PointF& point = location.TransformedPoint(); + const gfx::Vector2dF center_offset = center_ - point; const float half_stroke_width = StrokeWidth() / 2; - return std::abs(center.length() - radius_x_) <= half_stroke_width; + return std::abs(center_offset.Length() - radius_x_) <= half_stroke_width; } bool LayoutSVGEllipse::ShapeDependentFillContains( @@ -131,9 +130,9 @@ if (!radius_x_ || !radius_y_) return false; - const FloatPoint& point = location.TransformedPoint(); - const FloatPoint center = - FloatPoint(center_.x() - point.x(), center_.y() - point.y()); + const gfx::PointF& point = location.TransformedPoint(); + const gfx::PointF center = + gfx::PointF(center_.x() - point.x(), center_.y() - point.y()); // This works by checking if the point satisfies the ellipse equation. // (x/rX)^2 + (y/rY)^2 <= 1
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_image.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_image.cc index b5b48de..21f8a36 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_image.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_image.cc
@@ -232,7 +232,7 @@ if (hit_rules.can_hit_fill || hit_rules.can_hit_bounding_box) { if (local_location->Intersects(object_bounding_box_)) { - UpdateHitTestResult(result, PhysicalOffset::FromFloatPointRound( + UpdateHitTestResult(result, PhysicalOffset::FromPointFRound( local_location->TransformedPoint())); if (result.AddNodeToListBasedTestResult(GetElement(), *local_location) == kStopHitTesting)
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_rect.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_rect.cc index 2ce52a13..ee7fba4f 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_rect.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_rect.cc
@@ -88,14 +88,14 @@ if (use_path_fallback_) return LayoutSVGShape::ShapeDependentStrokeContains(location); - const FloatPoint& point = location.TransformedPoint(); + const gfx::PointF& point = location.TransformedPoint(); const float half_stroke_width = StrokeWidth() / 2; const float half_width = fill_bounding_box_.width() / 2; const float half_height = fill_bounding_box_.height() / 2; - const FloatPoint fill_bounding_box_center = - FloatPoint(fill_bounding_box_.x() + half_width, - fill_bounding_box_.y() + half_height); + const gfx::PointF fill_bounding_box_center = + gfx::PointF(fill_bounding_box_.x() + half_width, + fill_bounding_box_.y() + half_height); const float abs_delta_x = std::abs(point.x() - fill_bounding_box_center.x()); const float abs_delta_y = std::abs(point.y() - fill_bounding_box_center.y()); @@ -112,8 +112,7 @@ NOT_DESTROYED(); if (use_path_fallback_) return LayoutSVGShape::ShapeDependentFillContains(location, fill_rule); - return fill_bounding_box_.InclusiveContains( - ToGfxPointF(location.TransformedPoint())); + return fill_bounding_box_.InclusiveContains(location.TransformedPoint()); } // Returns true if the stroke is continuous and definitely uses miter joins.
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_linear_gradient.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_linear_gradient.cc index 72010e0..ab7c1eba 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_linear_gradient.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_linear_gradient.cc
@@ -46,7 +46,7 @@ ->CollectGradientAttributes(MutableAttributes()); } -FloatPoint LayoutSVGResourceLinearGradient::StartPoint( +gfx::PointF LayoutSVGResourceLinearGradient::StartPoint( const LinearGradientAttributes& attributes) const { NOT_DESTROYED(); return SVGLengthContext::ResolvePoint(GetElement(), @@ -54,7 +54,7 @@ *attributes.X1(), *attributes.Y1()); } -FloatPoint LayoutSVGResourceLinearGradient::EndPoint( +gfx::PointF LayoutSVGResourceLinearGradient::EndPoint( const LinearGradientAttributes& attributes) const { NOT_DESTROYED(); return SVGLengthContext::ResolvePoint(GetElement(),
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_linear_gradient.h b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_linear_gradient.h index afb461f..4de72e4 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_linear_gradient.h +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_linear_gradient.h
@@ -57,8 +57,8 @@ void CollectGradientAttributes() override; scoped_refptr<Gradient> BuildGradient() const override; - FloatPoint StartPoint(const LinearGradientAttributes&) const; - FloatPoint EndPoint(const LinearGradientAttributes&) const; + gfx::PointF StartPoint(const LinearGradientAttributes&) const; + gfx::PointF EndPoint(const LinearGradientAttributes&) const; private: Member<LinearGradientAttributesWrapper> attributes_wrapper_;
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_marker.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_marker.cc index ce96ae6..ae9993e 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_marker.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_marker.cc
@@ -76,14 +76,14 @@ return marker_transformation.MapRect(coordinates); } -FloatPoint LayoutSVGResourceMarker::ReferencePoint() const { +gfx::PointF LayoutSVGResourceMarker::ReferencePoint() const { NOT_DESTROYED(); auto* marker = To<SVGMarkerElement>(GetElement()); DCHECK(marker); SVGLengthContext length_context(marker); - return FloatPoint(marker->refX()->CurrentValue()->Value(length_context), - marker->refY()->CurrentValue()->Value(length_context)); + return gfx::PointF(marker->refX()->CurrentValue()->Value(length_context), + marker->refY()->CurrentValue()->Value(length_context)); } float LayoutSVGResourceMarker::Angle() const { @@ -128,7 +128,7 @@ // The reference point (refX, refY) is in the coordinate space of the marker's // contents so we include the value in each marker's transform. - FloatPoint mapped_reference_point = + gfx::PointF mapped_reference_point = LocalToSVGParentTransform().MapPoint(ReferencePoint()); transform.Translate(-mapped_reference_point.x(), -mapped_reference_point.y()); return transform;
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_marker.h b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_marker.h index 9d656dd..d708858 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_marker.h +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_marker.h
@@ -63,7 +63,7 @@ bool ShouldPaint() const; - FloatPoint ReferencePoint() const; + gfx::PointF ReferencePoint() const; float Angle() const; SVGMarkerUnitsType MarkerUnits() const; SVGMarkerOrientType OrientType() const;
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_pattern.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_pattern.cc index 20b2a22..1c2f148 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_pattern.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_pattern.cc
@@ -165,7 +165,7 @@ pattern_data->pattern = Pattern::CreatePaintRecordPattern( AsPaintRecord(tile_bounds.size(), tile_transform), - FloatRect(FloatPoint(), tile_bounds.size())); + FloatRect(gfx::PointF(), tile_bounds.size())); // Compute pattern space transformation. pattern_data->transform.Translate(tile_bounds.x(), tile_bounds.y()); @@ -211,7 +211,7 @@ SVGUnitTypes::kSvgUnitTypeObjectboundingbox) content_transform = tile_transform; - FloatRect bounds(FloatPoint(), size); + FloatRect bounds(gfx::PointF(), size); PaintRecorder paint_recorder; cc::PaintCanvas* canvas = paint_recorder.beginRecording(bounds);
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_radial_gradient.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_radial_gradient.cc index 44cd0a10..a93a6f9 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_radial_gradient.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_radial_gradient.cc
@@ -47,7 +47,7 @@ ->CollectGradientAttributes(MutableAttributes()); } -FloatPoint LayoutSVGResourceRadialGradient::CenterPoint( +gfx::PointF LayoutSVGResourceRadialGradient::CenterPoint( const RadialGradientAttributes& attributes) const { NOT_DESTROYED(); return SVGLengthContext::ResolvePoint(GetElement(), @@ -55,7 +55,7 @@ *attributes.Cx(), *attributes.Cy()); } -FloatPoint LayoutSVGResourceRadialGradient::FocalPoint( +gfx::PointF LayoutSVGResourceRadialGradient::FocalPoint( const RadialGradientAttributes& attributes) const { NOT_DESTROYED(); return SVGLengthContext::ResolvePoint(GetElement(),
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_radial_gradient.h b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_radial_gradient.h index 529ec70..bf7e7eee 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_radial_gradient.h +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_radial_gradient.h
@@ -57,8 +57,8 @@ void CollectGradientAttributes() override; scoped_refptr<Gradient> BuildGradient() const override; - FloatPoint CenterPoint(const RadialGradientAttributes&) const; - FloatPoint FocalPoint(const RadialGradientAttributes&) const; + gfx::PointF CenterPoint(const RadialGradientAttributes&) const; + gfx::PointF FocalPoint(const RadialGradientAttributes&) const; float Radius(const RadialGradientAttributes&) const; float FocalRadius(const RadialGradientAttributes&) const;
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_shape.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_shape.cc index 4e1033d..1164162e 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_shape.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_shape.cc
@@ -38,9 +38,9 @@ #include "third_party/blink/renderer/core/paint/svg_shape_painter.h" #include "third_party/blink/renderer/core/svg/svg_geometry_element.h" #include "third_party/blink/renderer/core/svg/svg_length_context.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/graphics/stroke_data.h" #include "third_party/blink/renderer/platform/wtf/math_extras.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -224,7 +224,7 @@ } DCHECK(stroke_path_cache_); - auto point = ToGfxPointF(location.TransformedPoint()); + auto point = location.TransformedPoint(); if (HasNonScalingStroke()) point = NonScalingStrokeTransform().MapPoint(point); return stroke_path_cache_->Contains(point); @@ -234,8 +234,7 @@ const HitTestLocation& location, const WindRule fill_rule) const { NOT_DESTROYED(); - return GetPath().Contains(ToGfxPointF(location.TransformedPoint()), - fill_rule); + return GetPath().Contains(location.TransformedPoint(), fill_rule); } static bool HasPaintServer(const LayoutObject& object, const SVGPaint& paint) { @@ -254,8 +253,7 @@ bool requires_fill, const WindRule fill_rule) { NOT_DESTROYED(); - if (!fill_bounding_box_.InclusiveContains( - ToGfxPointF(location.TransformedPoint()))) + if (!fill_bounding_box_.InclusiveContains(location.TransformedPoint())) return false; if (requires_fill && !HasPaintServer(*this, StyleRef().FillPaint())) @@ -272,14 +270,13 @@ return false; if (requires_stroke) { - if (!StrokeBoundingBox().InclusiveContains( - ToGfxPointF(location.TransformedPoint()))) + if (!StrokeBoundingBox().InclusiveContains(location.TransformedPoint())) return false; if (!HasPaintServer(*this, StyleRef().StrokePaint())) return false; } else if (!HitTestStrokeBoundingBox().InclusiveContains( - ToGfxPointF(location.TransformedPoint()))) { + location.TransformedPoint())) { return false; } @@ -415,7 +412,7 @@ return false; if (HitTestShape(result.GetHitTestRequest(), *local_location, hit_rules)) { - UpdateHitTestResult(result, PhysicalOffset::FromFloatPointRound( + UpdateHitTestResult(result, PhysicalOffset::FromPointFRound( local_location->TransformedPoint())); if (result.AddNodeToListBasedTestResult(GetElement(), *local_location) == kStopHitTesting)
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 a523ed58..1a17e858 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
@@ -358,7 +358,7 @@ if (StyleRef().UsedPointerEvents() == EPointerEvents::kBoundingBox) { if (IsObjectBoundingBoxValid() && local_location->Intersects(ObjectBoundingBox())) { - UpdateHitTestResult(result, PhysicalOffset::FromFloatPointRound( + UpdateHitTestResult(result, PhysicalOffset::FromPointFRound( local_location->TransformedPoint())); if (result.AddNodeToListBasedTestResult(GetElement(), *local_location) == kStopHitTesting)
diff --git a/third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.cc b/third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.cc index 672facda..046d9d9 100644 --- a/third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.cc +++ b/third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.cc
@@ -118,7 +118,7 @@ return FloatRect(); const FontMetrics& scaled_font_metrics = font_data->GetFontMetrics(); - FloatPoint text_origin(fragment.x, fragment.y); + gfx::PointF text_origin(fragment.x, fragment.y); if (scaling_factor != 1) text_origin.Scale(scaling_factor, scaling_factor);
diff --git a/third_party/blink/renderer/core/layout/svg/svg_hit_test_perftest.cc b/third_party/blink/renderer/core/layout/svg/svg_hit_test_perftest.cc index a734d609..bbca89c 100644 --- a/third_party/blink/renderer/core/layout/svg/svg_hit_test_perftest.cc +++ b/third_party/blink/renderer/core/layout/svg/svg_hit_test_perftest.cc
@@ -109,7 +109,7 @@ PhysicalOffset document_point = event_handling_util::ContentPointFromRootFrame(GetDocument().GetFrame(), - FloatPoint(1, 1)); + gfx::PointF(1, 1)); TransformedHitTestLocation local_location( HitTestLocation(document_point), container->LocalToSVGParentTransform());
diff --git a/third_party/blink/renderer/core/layout/svg/svg_layout_support.cc b/third_party/blink/renderer/core/layout/svg/svg_layout_support.cc index 1d3fe9687..052c8e5 100644 --- a/third_party/blink/renderer/core/layout/svg/svg_layout_support.cc +++ b/third_party/blink/renderer/core/layout/svg/svg_layout_support.cc
@@ -295,7 +295,7 @@ ShapeClipPathOperation& clip_path = To<ShapeClipPathOperation>(*clip_path_operation); return clip_path.GetPath(FloatRect(reference_box), 1) - .Contains(ToGfxPointF(location.TransformedPoint())); + .Contains(location.TransformedPoint()); } DCHECK_EQ(clip_path_operation->GetType(), ClipPathOperation::kReference); SVGResourceClient* client = SVGResources::GetClient(object);
diff --git a/third_party/blink/renderer/core/layout/svg/svg_layout_tree_as_text.cc b/third_party/blink/renderer/core/layout/svg/svg_layout_tree_as_text.cc index 166b127..80f33c6f 100644 --- a/third_party/blink/renderer/core/layout/svg/svg_layout_tree_as_text.cc +++ b/third_party/blink/renderer/core/layout/svg/svg_layout_tree_as_text.cc
@@ -626,8 +626,8 @@ ->CollectGradientAttributes(attributes); WriteCommonGradientProperties(ts, attributes); - FloatPoint focal_point = gradient->FocalPoint(attributes); - FloatPoint center_point = gradient->CenterPoint(attributes); + gfx::PointF focal_point = gradient->FocalPoint(attributes); + gfx::PointF center_point = gradient->CenterPoint(attributes); float radius = gradient->Radius(attributes); float focal_radius = gradient->FocalRadius(attributes);
diff --git a/third_party/blink/renderer/core/layout/svg/transform_helper.cc b/third_party/blink/renderer/core/layout/svg/transform_helper.cc index 5b4be2ff..01be67d 100644 --- a/third_party/blink/renderer/core/layout/svg/transform_helper.cc +++ b/third_party/blink/renderer/core/layout/svg/transform_helper.cc
@@ -92,17 +92,17 @@ return transform.ToAffineTransform(); } -FloatPoint TransformHelper::ComputeTransformOrigin( +gfx::PointF TransformHelper::ComputeTransformOrigin( const LayoutObject& layout_object) { const auto& style = layout_object.StyleRef(); FloatRect reference_box = ComputeReferenceBox(layout_object); - FloatPoint origin( + gfx::PointF origin( FloatValueForLength(style.TransformOriginX(), reference_box.width()) + reference_box.x(), FloatValueForLength(style.TransformOriginY(), reference_box.height()) + reference_box.y()); // See the comment in ComputeTransform() for the reason of scaling by 1/zoom. - return origin.ScaledBy(1 / style.EffectiveZoom()); + return gfx::ScalePoint(origin, style.EffectiveZoom()); } } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/transform_helper.h b/third_party/blink/renderer/core/layout/svg/transform_helper.h index 63c667a..8c1d1c8c 100644 --- a/third_party/blink/renderer/core/layout/svg/transform_helper.h +++ b/third_party/blink/renderer/core/layout/svg/transform_helper.h
@@ -31,7 +31,7 @@ static AffineTransform ComputeTransform(const LayoutObject&, ComputedStyle::ApplyTransformOrigin); - static FloatPoint ComputeTransformOrigin(const LayoutObject&); + static gfx::PointF ComputeTransformOrigin(const LayoutObject&); }; // The following enumeration is used to optimize cases where the scale is known
diff --git a/third_party/blink/renderer/core/layout/svg/transformed_hit_test_location.cc b/third_party/blink/renderer/core/layout/svg/transformed_hit_test_location.cc index afa761a..294b48e 100644 --- a/third_party/blink/renderer/core/layout/svg/transformed_hit_test_location.cc +++ b/third_party/blink/renderer/core/layout/svg/transformed_hit_test_location.cc
@@ -19,7 +19,7 @@ if (!transform.IsInvertible()) return nullptr; const AffineTransform inverse = transform.Inverse(); - FloatPoint transformed_point = inverse.MapPoint(location.TransformedPoint()); + gfx::PointF transformed_point = inverse.MapPoint(location.TransformedPoint()); if (UNLIKELY(location.IsRectBasedTest())) { storage.emplace(transformed_point, inverse.MapQuad(location.TransformedRect()));
diff --git a/third_party/blink/renderer/core/layout/visual_rect_mapping_test.cc b/third_party/blink/renderer/core/layout/visual_rect_mapping_test.cc index 95fbdc0c..9514746 100644 --- a/third_party/blink/renderer/core/layout/visual_rect_mapping_test.cc +++ b/third_party/blink/renderer/core/layout/visual_rect_mapping_test.cc
@@ -130,7 +130,7 @@ auto* scrollable_area = GetScrollableArea(container); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 50)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 50)); UpdateAllLifecyclePhasesForTest(); PhysicalRect original_rect(0, 60, 20, 80); @@ -169,7 +169,7 @@ auto* scrollable_area = GetScrollableArea(container); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 50)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 50)); UpdateAllLifecyclePhasesForTest(); // All results are the same as VisualRectMappingTest.LayoutText because all @@ -206,7 +206,7 @@ auto* scrollable_area = GetScrollableArea(container); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 50)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 50)); UpdateAllLifecyclePhasesForTest(); PhysicalRect original_rect(0, 60, 20, 80); @@ -245,7 +245,7 @@ auto* scrollable_area = GetScrollableArea(container); scrollable_area->ScrollToAbsolutePosition( - FloatPoint(scrollable_area->ScrollPosition().x(), 50)); + gfx::PointF(scrollable_area->ScrollPosition().x(), 50)); UpdateAllLifecyclePhasesForTest(); // All results are the same as VisualRectMappingTest.LayoutInline because all @@ -462,7 +462,7 @@ auto* scrollable_area = GetScrollableArea(container); EXPECT_EQ(0, scrollable_area->ScrollPosition().y()); EXPECT_EQ(0, scrollable_area->ScrollPosition().x()); - scrollable_area->ScrollToAbsolutePosition(FloatPoint(8, 7)); + scrollable_area->ScrollToAbsolutePosition(gfx::PointF(8, 7)); UpdateAllLifecyclePhasesForTest(); auto* target = To<LayoutBlock>(GetLayoutObjectByElementId("target")); @@ -524,7 +524,7 @@ // 150 = total_layout_overflow(100 + 100) - width(50) EXPECT_EQ(150, scrollable_area->ScrollPosition().x()); // Scroll to the right by 8 pixels. - scrollable_area->ScrollToAbsolutePosition(FloatPoint(142, 7)); + scrollable_area->ScrollToAbsolutePosition(gfx::PointF(142, 7)); UpdateAllLifecyclePhasesForTest(); auto* target = To<LayoutBlock>(GetLayoutObjectByElementId("target")); @@ -592,7 +592,7 @@ auto* scrollable_area = GetScrollableArea(container); EXPECT_EQ(0, scrollable_area->ScrollPosition().y()); EXPECT_EQ(0, scrollable_area->ScrollPosition().x()); - scrollable_area->ScrollToAbsolutePosition(FloatPoint(28, 27)); + scrollable_area->ScrollToAbsolutePosition(gfx::PointF(28, 27)); UpdateAllLifecyclePhasesForTest(); auto* target = To<LayoutBlock>(GetLayoutObjectByElementId("target")); @@ -628,7 +628,7 @@ // writing mode. // 150 = total_layout_overflow(100 + 100) - width(50) EXPECT_EQ(150, scrollable_area->ScrollPosition().x()); - scrollable_area->ScrollToAbsolutePosition(FloatPoint(82, 7)); + scrollable_area->ScrollToAbsolutePosition(gfx::PointF(82, 7)); UpdateAllLifecyclePhasesForTest(); auto* target = To<LayoutBlock>(GetLayoutObjectByElementId("target")); @@ -668,7 +668,7 @@ // 150 = total_layout_overflow(100 + 100) - width(50) EXPECT_EQ(150, scrollable_area->ScrollPosition().x()); // Scroll to the right by 8 pixels. - scrollable_area->ScrollToAbsolutePosition(FloatPoint(142, 7)); + scrollable_area->ScrollToAbsolutePosition(gfx::PointF(142, 7)); UpdateAllLifecyclePhasesForTest(); auto* target = To<LayoutBlock>(GetLayoutObjectByElementId("target")); @@ -719,7 +719,7 @@ )HTML"); auto* scroller = To<LayoutBlock>(GetLayoutObjectByElementId("scroller")); - GetScrollableArea(scroller)->ScrollToAbsolutePosition(FloatPoint(88, 77)); + GetScrollableArea(scroller)->ScrollToAbsolutePosition(gfx::PointF(88, 77)); UpdateAllLifecyclePhasesForTest(); auto* normal_flow =
diff --git a/third_party/blink/renderer/core/loader/empty_clients.h b/third_party/blink/renderer/core/loader/empty_clients.h index 9ec5c2d4..dd75112 100644 --- a/third_party/blink/renderer/core/loader/empty_clients.h +++ b/third_party/blink/renderer/core/loader/empty_clients.h
@@ -50,7 +50,6 @@ #include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/platform/cursors.h" #include "third_party/blink/renderer/platform/exported/wrapped_resource_request.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/graphics/touch_action.h" @@ -60,6 +59,7 @@ #include "ui/base/cursor/cursor.h" #include "ui/display/screen_info.h" #include "ui/display/screen_infos.h" +#include "ui/gfx/geometry/point_f.h" #include "v8/include/v8.h" /*
diff --git a/third_party/blink/renderer/core/page/autoscroll_controller.cc b/third_party/blink/renderer/core/page/autoscroll_controller.cc index cc0d2a2..6eba5b3 100644 --- a/third_party/blink/renderer/core/page/autoscroll_controller.cc +++ b/third_party/blink/renderer/core/page/autoscroll_controller.cc
@@ -183,7 +183,7 @@ } void AutoscrollController::UpdateDragAndDrop(Node* drop_target_node, - const FloatPoint& event_position, + const gfx::PointF& event_position, base::TimeTicks event_time) { if (!drop_target_node || !drop_target_node->GetLayoutObject()) { StopAutoscroll(); @@ -222,7 +222,7 @@ } drag_and_drop_autoscroll_reference_position_ = - PhysicalOffset::FromFloatPointRound(event_position) + offset; + PhysicalOffset::FromPointFRound(event_position) + offset; if (autoscroll_type_ == kNoAutoscroll) { autoscroll_type_ = kAutoscrollForDragAndDrop; @@ -263,7 +263,7 @@ void AutoscrollController::HandleMouseMoveForMiddleClickAutoscroll( LocalFrame* frame, - const FloatPoint& position_global, + const gfx::PointF& position_global, bool is_middle_button) { if (!MiddleClickAutoscrollInProgress()) return; @@ -286,22 +286,22 @@ if (!view) return; - FloatSize distance = - (position_global - middle_click_autoscroll_start_pos_global_) - .ScaledBy(1 / frame->DevicePixelRatio()); + gfx::Vector2dF distance = gfx::ScaleVector2d( + position_global - middle_click_autoscroll_start_pos_global_, + 1 / frame->DevicePixelRatio()); - if (fabs(distance.width()) <= kNoMiddleClickAutoscrollRadius) - distance.set_width(0); - if (fabs(distance.height()) <= kNoMiddleClickAutoscrollRadius) - distance.set_height(0); + if (fabs(distance.x()) <= kNoMiddleClickAutoscrollRadius) + distance.set_x(0); + if (fabs(distance.y()) <= kNoMiddleClickAutoscrollRadius) + distance.set_y(0); const float kExponent = 2.2f; const float kMultiplier = -0.000008f; - const int x_signum = (distance.width() < 0) ? -1 : (distance.width() > 0); - const int y_signum = (distance.height() < 0) ? -1 : (distance.height() > 0); + const int x_signum = (distance.x() < 0) ? -1 : (distance.x() > 0); + const int y_signum = (distance.y() < 0) ? -1 : (distance.y() > 0); gfx::Vector2dF velocity( - pow(fabs(distance.width()), kExponent) * kMultiplier * x_signum, - pow(fabs(distance.height()), kExponent) * kMultiplier * y_signum); + pow(fabs(distance.x()), kExponent) * kMultiplier * x_signum, + pow(fabs(distance.y()), kExponent) * kMultiplier * y_signum); bool can_scroll_vertically = vertical_autoscroll_possible @@ -363,8 +363,8 @@ void AutoscrollController::StartMiddleClickAutoscroll( LocalFrame* frame, LayoutBox* scrollable, - const FloatPoint& position, - const FloatPoint& position_global) { + const gfx::PointF& position, + const gfx::PointF& position_global) { DCHECK(RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled()); DCHECK(scrollable); // We don't want to trigger the autoscroll or the middleClickAutoscroll if @@ -443,7 +443,7 @@ } page_->GetChromeClient().SetCursorOverridden(true); page_->GetChromeClient().AutoscrollStart( - ToGfxPointF(position.ScaledBy(1 / frame->DevicePixelRatio())), frame); + gfx::ScalePoint(position, 1 / frame->DevicePixelRatio()), frame); } void AutoscrollController::Animate() { @@ -462,7 +462,7 @@ autoscroll_layout_object_->CalculateAutoscrollDirection( event_handler.LastKnownMousePositionInRootFrame()); PhysicalOffset selection_point = - PhysicalOffset::FromFloatPointRound( + PhysicalOffset::FromPointFRound( event_handler.LastKnownMousePositionInRootFrame()) + offset; switch (autoscroll_type_) {
diff --git a/third_party/blink/renderer/core/page/autoscroll_controller.h b/third_party/blink/renderer/core/page/autoscroll_controller.h index 33d4ded..d1caca24 100644 --- a/third_party/blink/renderer/core/page/autoscroll_controller.h +++ b/third_party/blink/renderer/core/page/autoscroll_controller.h
@@ -29,9 +29,9 @@ #include "base/gtest_prod_util.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_point.h" #include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -79,17 +79,17 @@ void StopAutoscrollIfNeeded(LayoutObject*); void UpdateAutoscrollLayoutObject(); void UpdateDragAndDrop(Node* target_node, - const FloatPoint& event_position, + const gfx::PointF& event_position, base::TimeTicks event_time); // Middle-click autoscroll. void StartMiddleClickAutoscroll(LocalFrame*, LayoutBox* scrollable, - const FloatPoint& position, - const FloatPoint& position_global); + const gfx::PointF& position, + const gfx::PointF& position_global); void HandleMouseMoveForMiddleClickAutoscroll( LocalFrame*, - const FloatPoint& position_global, + const gfx::PointF& position_global, bool is_middle_button); void HandleMouseReleaseForMiddleClickAutoscroll(LocalFrame*, bool is_middle_button); @@ -114,7 +114,7 @@ // Middle-click autoscroll. Member<LayoutBox> horizontal_autoscroll_layout_box_ = nullptr; Member<LayoutBox> vertical_autoscroll_layout_box_ = nullptr; - FloatPoint middle_click_autoscroll_start_pos_global_; + gfx::PointF middle_click_autoscroll_start_pos_global_; gfx::Vector2dF last_velocity_; MiddleClickMode middle_click_mode_ = kMiddleClickInitial;
diff --git a/third_party/blink/renderer/core/page/autoscroll_controller_test.cc b/third_party/blink/renderer/core/page/autoscroll_controller_test.cc index b1a7b0b9bd..d30b5513 100644 --- a/third_party/blink/renderer/core/page/autoscroll_controller_test.cc +++ b/third_party/blink/renderer/core/page/autoscroll_controller_test.cc
@@ -106,8 +106,8 @@ LocalFrame* frame = GetDocument().GetFrame(); Node* document_node = GetDocument().documentElement(); controller.StartMiddleClickAutoscroll( - frame, document_node->parentNode()->GetLayoutBox(), FloatPoint(), - FloatPoint()); + frame, document_node->parentNode()->GetLayoutBox(), gfx::PointF(), + gfx::PointF()); EXPECT_TRUE(controller.IsAutoscrolling()); @@ -145,7 +145,7 @@ LocalFrame* frame = GetDocument().GetFrame(); controller.StartMiddleClickAutoscroll(frame, GetDocument().GetLayoutView(), - FloatPoint(), FloatPoint()); + gfx::PointF(), gfx::PointF()); EXPECT_TRUE(controller.IsAutoscrolling()); @@ -177,7 +177,7 @@ // And finally confirm that autoscrolling can start again. controller.StartMiddleClickAutoscroll(frame, GetDocument().GetLayoutView(), - FloatPoint(), FloatPoint()); + gfx::PointF(), gfx::PointF()); EXPECT_TRUE(controller.IsAutoscrolling()); } @@ -224,7 +224,7 @@ GetDocument().getElementById("scrollable")->GetLayoutBox(); controller.StartMiddleClickAutoscroll( - frame, scrollable, FloatPoint(15.0, 15.0), FloatPoint(15.0, 15.0)); + frame, scrollable, gfx::PointF(15.0, 15.0), gfx::PointF(15.0, 15.0)); EXPECT_TRUE(controller.IsAutoscrolling()); EXPECT_TRUE(controller.horizontal_autoscroll_layout_box_); @@ -273,7 +273,7 @@ GetDocument().getElementById("scrollable")->GetLayoutBox(); controller.StartMiddleClickAutoscroll( - frame, scrollable, FloatPoint(15.0, 15.0), FloatPoint(15.0, 15.0)); + frame, scrollable, gfx::PointF(15.0, 15.0), gfx::PointF(15.0, 15.0)); EXPECT_TRUE(controller.IsAutoscrolling()); EXPECT_TRUE(controller.vertical_autoscroll_layout_box_);
diff --git a/third_party/blink/renderer/core/page/context_menu_controller.cc b/third_party/blink/renderer/core/page/context_menu_controller.cc index 7193fa9..b612b8c 100644 --- a/third_party/blink/renderer/core/page/context_menu_controller.cc +++ b/third_party/blink/renderer/core/page/context_menu_controller.cc
@@ -168,8 +168,8 @@ void ContextMenuController::HandleContextMenuEvent(MouseEvent* mouse_event) { DCHECK(mouse_event->type() == event_type_names::kContextmenu); LocalFrame* frame = mouse_event->target()->ToNode()->GetDocument().GetFrame(); - PhysicalOffset location = PhysicalOffset::FromFloatPointRound( - FloatPoint(mouse_event->AbsoluteLocation())); + PhysicalOffset location = PhysicalOffset::FromPointFRound( + gfx::PointF(mouse_event->AbsoluteLocation())); if (ShowContextMenu(frame, location, mouse_event->GetMenuSourceType(), mouse_event))
diff --git a/third_party/blink/renderer/core/page/drag_controller.cc b/third_party/blink/renderer/core/page/drag_controller.cc index 366ee68..18e06318 100644 --- a/third_party/blink/renderer/core/page/drag_controller.cc +++ b/third_party/blink/renderer/core/page/drag_controller.cc
@@ -92,6 +92,8 @@ #include "third_party/blink/renderer/platform/wtf/shared_buffer.h" #include "ui/base/dragdrop/mojom/drag_drop_types.mojom-blink.h" #include "ui/display/screen_info.h" +#include "ui/gfx/geometry/point_conversions.h" +#include "ui/gfx/geometry/vector2d_conversions.h" #if defined(OS_WIN) #include <windows.h> @@ -124,9 +126,8 @@ static WebMouseEvent CreateMouseEvent(DragData* drag_data) { WebMouseEvent result( - WebInputEvent::Type::kMouseMove, ToGfxPointF(drag_data->ClientPosition()), - ToGfxPointF(drag_data->GlobalPosition()), - WebPointerProperties::Button::kLeft, 0, + WebInputEvent::Type::kMouseMove, drag_data->ClientPosition(), + drag_data->GlobalPosition(), WebPointerProperties::Button::kLeft, 0, static_cast<WebInputEvent::Modifiers>(drag_data->GetModifiers()), base::TimeTicks::Now()); // TODO(dtapuska): Really we should chnage DragData to store the viewport @@ -241,7 +242,7 @@ void DragController::PerformDrag(DragData* drag_data, LocalFrame& local_root) { DCHECK(drag_data); document_under_mouse_ = local_root.DocumentAtPoint( - PhysicalOffset::FromFloatPointRound(drag_data->ClientPosition())); + PhysicalOffset::FromPointFRound(drag_data->ClientPosition())); LocalFrame::NotifyUserActivation( document_under_mouse_ ? document_under_mouse_->GetFrame() : nullptr, mojom::blink::UserActivationNotificationType::kInteraction); @@ -262,7 +263,7 @@ // When drop target is plugin element and it can process drag, we // should prevent default behavior. const HitTestLocation location(local_root.View()->ConvertFromRootFrame( - PhysicalOffset::FromFloatPointRound(drag_data->ClientPosition()))); + PhysicalOffset::FromPointFRound(drag_data->ClientPosition()))); const HitTestResult result = event_handler.HitTestResultAtLocation(location); auto* html_plugin_element = @@ -340,7 +341,7 @@ DCHECK(drag_data); MouseMovedIntoDocument(local_root.DocumentAtPoint( - PhysicalOffset::FromFloatPointRound(drag_data->ClientPosition()))); + PhysicalOffset::FromPointFRound(drag_data->ClientPosition()))); // TODO(esprehn): Replace acceptsLoadDrops with a Setting used in core. drag_destination_action_ = @@ -438,7 +439,7 @@ if ((action_mask & kDragDestinationActionEdit) && CanProcessDrag(drag_data, local_root)) { PhysicalOffset point = frame_view->ConvertFromRootFrame( - PhysicalOffset::FromFloatPointRound(drag_data->ClientPosition())); + PhysicalOffset::FromPointFRound(drag_data->ClientPosition())); Element* element = ElementUnderMouse(document_under_mouse_.Get(), point); if (!element) return false; @@ -488,7 +489,7 @@ LocalFrame& local_root) { DCHECK(drag_data); Document* doc = local_root.DocumentAtPoint( - PhysicalOffset::FromFloatPointRound(drag_data->ClientPosition())); + PhysicalOffset::FromPointFRound(drag_data->ClientPosition())); if (doc && (did_initiate_drag_ || IsA<PluginDocument>(doc) || HasEditableStyle(*doc))) @@ -563,7 +564,7 @@ return false; PhysicalOffset point = document_under_mouse_->View()->ConvertFromRootFrame( - PhysicalOffset::FromFloatPointRound(drag_data->ClientPosition())); + PhysicalOffset::FromPointFRound(drag_data->ClientPosition())); Element* element = ElementUnderMouse(document_under_mouse_.Get(), point); if (!element) return false; @@ -731,7 +732,7 @@ const PhysicalOffset point_in_local_root = local_root.View()->ConvertFromRootFrame( - PhysicalOffset::FromFloatPointRound(drag_data->ClientPosition())); + PhysicalOffset::FromPointFRound(drag_data->ClientPosition())); const HitTestResult result = local_root.GetEventHandler().HitTestResultAtLocation( @@ -758,8 +759,8 @@ ->GetDocument() .GetFrame() ->View() - ->ConvertFromRootFrame(PhysicalOffset::FromFloatPointRound( - drag_data->ClientPosition())); + ->ConvertFromRootFrame( + PhysicalOffset::FromPointFRound(drag_data->ClientPosition())); return !result.IsSelected(HitTestLocation(point_in_frame)); } @@ -1124,9 +1125,9 @@ // Properly orient the drag image and orient it differently if it's smaller // than the original float scale = new_size.width() / static_cast<float>(original_size.width()); - FloatPoint offset(image_element_location - drag_origin); + gfx::Vector2dF offset = image_element_location - drag_origin; return drag_origin + - RoundedIntPoint(offset.ScaledBy(scale)).OffsetFromOrigin(); + gfx::ToRoundedVector2d(gfx::ScaleVector2d(offset, scale)); } static std::unique_ptr<DragImage> DragImageForLink(const KURL& link_url, @@ -1148,16 +1149,16 @@ return origin; // Offset the image so that the cursor is horizontally centered. - FloatPoint image_offset(-link_image->Size().width() / 2.f, - -kLinkDragBorderInset); + gfx::PointF image_offset(-link_image->Size().width() / 2.f, + -kLinkDragBorderInset); // |origin| is in the coordinate space of the frame's contents whereas the // size of |link_image| is in physical pixels. Adjust the image offset to be // scaled in the frame's contents. // TODO(pdr): Unify this calculation with the DragImageForImage scaling code. float scale = 1.f / (device_scale_factor * page_scale_factor); - image_offset.Scale(scale, scale); - image_offset.MoveBy(origin); - return RoundedIntPoint(image_offset); + image_offset.Scale(scale); + image_offset += origin.OffsetFromOrigin(); + return gfx::ToRoundedPoint(image_offset); } // static @@ -1186,8 +1187,8 @@ .LocalBorderBoxProperties() .Unalias(); return DataTransfer::CreateDragImageForFrame( - frame, opacity, painting_rect.size(), painting_rect.origin(), *builder, - property_tree_state); + frame, opacity, painting_rect.size(), painting_rect.OffsetFromOrigin(), + *builder, property_tree_state); } bool DragController::StartDrag(LocalFrame* src, @@ -1219,7 +1220,7 @@ // TODO(pdr): This code shouldn't be necessary because drag_origin is already // in the coordinate space of the view's contents. gfx::Point mouse_dragged_point = src->View()->ConvertFromRootFrame( - FlooredIntPoint(drag_event.PositionInRootFrame())); + gfx::ToFlooredPoint(drag_event.PositionInRootFrame())); gfx::Point drag_location; gfx::Point drag_offset;
diff --git a/third_party/blink/renderer/core/page/drag_controller_test.cc b/third_party/blink/renderer/core/page/drag_controller_test.cc index 5dcc696..e11b7f9 100644 --- a/third_party/blink/renderer/core/page/drag_controller_test.cc +++ b/third_party/blink/renderer/core/page/drag_controller_test.cc
@@ -100,7 +100,7 @@ DataObject* object = DataObject::Create(); object->SetURLAndTitle("https://www.example.com/index.html", "index"); DragData data( - object, FloatPoint(10, 10), FloatPoint(10, 10), + object, gfx::PointF(10, 10), gfx::PointF(10, 10), static_cast<DragOperationsMask>(kDragOperationCopy | kDragOperationLink | kDragOperationMove)); @@ -140,7 +140,7 @@ DataObject* object = DataObject::Create(); object->SetURLAndTitle("https://www.example.com/index.html", "index"); DragData data( - object, FloatPoint(10, 10), FloatPoint(10, 10), + object, gfx::PointF(10, 10), gfx::PointF(10, 10), static_cast<DragOperationsMask>(kDragOperationCopy | kDragOperationLink | kDragOperationMove));
diff --git a/third_party/blink/renderer/core/page/drag_data.cc b/third_party/blink/renderer/core/page/drag_data.cc index d5ace3a8..2ce56b1f 100644 --- a/third_party/blink/renderer/core/page/drag_data.cc +++ b/third_party/blink/renderer/core/page/drag_data.cc
@@ -39,8 +39,8 @@ namespace blink { DragData::DragData(DataObject* data, - const FloatPoint& client_position, - const FloatPoint& global_position, + const gfx::PointF& client_position, + const gfx::PointF& global_position, DragOperationsMask source_operation_mask) : client_position_(client_position), global_position_(global_position),
diff --git a/third_party/blink/renderer/core/page/drag_data.h b/third_party/blink/renderer/core/page/drag_data.h index 0cc02df..5afff8c 100644 --- a/third_party/blink/renderer/core/page/drag_data.h +++ b/third_party/blink/renderer/core/page/drag_data.h
@@ -29,11 +29,11 @@ #include "third_party/blink/public/common/page/drag_operation.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/page/drag_actions.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/hash_map.h" #include "third_party/blink/renderer/platform/wtf/vector.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -50,11 +50,11 @@ // clientPosition is taken to be the position of the drag event within the // target window, with (0,0) at the top left. DragData(DataObject*, - const FloatPoint& client_position, - const FloatPoint& global_position, + const gfx::PointF& client_position, + const gfx::PointF& global_position, DragOperationsMask); - const FloatPoint& ClientPosition() const { return client_position_; } - const FloatPoint& GlobalPosition() const { return global_position_; } + const gfx::PointF& ClientPosition() const { return client_position_; } + const gfx::PointF& GlobalPosition() const { return global_position_; } DataObject* PlatformData() const { return platform_drag_data_; } DragOperationsMask DraggingSourceOperationMask() const { return dragging_source_operation_mask_; @@ -76,8 +76,8 @@ String DroppedFileSystemId() const; private: - const FloatPoint client_position_; - const FloatPoint global_position_; + const gfx::PointF client_position_; + const gfx::PointF global_position_; DataObject* const platform_drag_data_; const DragOperationsMask dragging_source_operation_mask_;
diff --git a/third_party/blink/renderer/core/page/drag_image.cc b/third_party/blink/renderer/core/page/drag_image.cc index 61b91fa..417dbc2 100644 --- a/third_party/blink/renderer/core/page/drag_image.cc +++ b/third_party/blink/renderer/core/page/drag_image.cc
@@ -38,7 +38,6 @@ #include "third_party/blink/renderer/platform/fonts/font_metrics.h" #include "third_party/blink/renderer/platform/fonts/string_truncator.h" #include "third_party/blink/renderer/platform/fonts/text_run_paint_info.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/graphics/bitmap_image.h" #include "third_party/blink/renderer/platform/graphics/canvas_resource_provider.h" @@ -52,6 +51,7 @@ #include "third_party/blink/renderer/platform/weborigin/kurl.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "ui/gfx/geometry/point.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -230,7 +230,7 @@ url_string = StringTruncator::CenterTruncate( url_string, image_size.width() - (kDragLabelBorderX * 2.0f), url_font); - FloatPoint text_pos( + gfx::PointF text_pos( kDragLabelBorderX, image_size.height() - (kLabelBorderYOffset + url_font_data->GetFontMetrics().Descent())); @@ -257,7 +257,7 @@ text_pos.set_x(available_width - ceilf(text_width)); } label_font.DrawBidiText(resource_provider->Canvas(), - TextRunPaintInfo(text_run), FloatPoint(text_pos), + TextRunPaintInfo(text_run), gfx::PointF(text_pos), Font::kDoNotPaintIfFontNotReady, device_scale_factor, text_paint);
diff --git a/third_party/blink/renderer/core/page/page_widget_delegate.cc b/third_party/blink/renderer/core/page/page_widget_delegate.cc index 02d9fcf..ebeba55c 100644 --- a/third_party/blink/renderer/core/page/page_widget_delegate.cc +++ b/third_party/blink/renderer/core/page/page_widget_delegate.cc
@@ -41,6 +41,7 @@ #include "third_party/blink/renderer/core/page/autoscroll_controller.h" #include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/core/page/validation_message_client.h" +#include "ui/gfx/geometry/point_conversions.h" namespace blink { @@ -97,7 +98,7 @@ root->View(), static_cast<const WebMouseEvent&>(event)); HitTestLocation location(root->View()->ConvertFromRootFrame( - FlooredIntPoint(mouse_event.PositionInRootFrame()))); + gfx::ToFlooredPoint(mouse_event.PositionInRootFrame()))); HitTestResult result = root->GetEventHandler().HitTestResultAtLocation( location, HitTestRequest::kReadOnly | HitTestRequest::kActive); result.SetToShadowHostIfInRestrictedShadowRoot();
diff --git a/third_party/blink/renderer/core/page/pointer_lock_controller.cc b/third_party/blink/renderer/core/page/pointer_lock_controller.cc index b6a5978..cfdf1f5 100644 --- a/third_party/blink/renderer/core/page/pointer_lock_controller.cc +++ b/third_party/blink/renderer/core/page/pointer_lock_controller.cc
@@ -369,8 +369,8 @@ } void PointerLockController::GetPointerLockPosition( - FloatPoint* lock_position, - FloatPoint* lock_screen_position) { + gfx::PointF* lock_position, + gfx::PointF* lock_screen_position) { if (element_ && !lock_pending_) { DCHECK(lock_position); DCHECK(lock_screen_position);
diff --git a/third_party/blink/renderer/core/page/pointer_lock_controller.h b/third_party/blink/renderer/core/page/pointer_lock_controller.h index f2caf84d..67c9d9201 100644 --- a/third_party/blink/renderer/core/page/pointer_lock_controller.h +++ b/third_party/blink/renderer/core/page/pointer_lock_controller.h
@@ -33,10 +33,10 @@ #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/platform/bindings/script_state.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/mojo/heap_mojo_remote.h" #include "third_party/blink/renderer/platform/wtf/text/atomic_string.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -80,8 +80,8 @@ // Fetch the locked mouse position when pointer is locked. The values are not // changed if pointer is not locked. - void GetPointerLockPosition(FloatPoint* lock_position, - FloatPoint* lock_screen_position); + void GetPointerLockPosition(gfx::PointF* lock_position, + gfx::PointF* lock_screen_position); void Trace(Visitor*) const; static Element* GetPointerLockedElement(LocalFrame* frame); @@ -121,8 +121,8 @@ // Store the locked position so that the event position keeps unchanged when // in locked states. These values only get set when entering lock states. - FloatPoint pointer_lock_position_; - FloatPoint pointer_lock_screen_position_; + gfx::PointF pointer_lock_position_; + gfx::PointF pointer_lock_screen_position_; bool current_unadjusted_movement_setting_ = false; };
diff --git a/third_party/blink/renderer/core/page/print_context.cc b/third_party/blink/renderer/core/page/print_context.cc index e0d5412b..33f3de3 100644 --- a/third_party/blink/renderer/core/page/print_context.cc +++ b/third_party/blink/renderer/core/page/print_context.cc
@@ -183,7 +183,7 @@ element->GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kPrinting); LocalFrame* frame = element->GetDocument().GetFrame(); - FloatRect page_rect(FloatPoint(0, 0), page_size_in_pixels); + FloatRect page_rect(gfx::PointF(0, 0), page_size_in_pixels); ScopedPrintContext print_context(frame); print_context->BeginPrintMode(page_rect.width(), page_rect.height()); @@ -317,7 +317,7 @@ const FloatSize& page_size_in_pixels) { frame->GetDocument()->UpdateStyleAndLayout(DocumentUpdateReason::kPrinting); - FloatRect page_rect(FloatPoint(0, 0), page_size_in_pixels); + FloatRect page_rect(gfx::PointF(0, 0), page_size_in_pixels); ScopedPrintContext print_context(frame); print_context->BeginPrintMode(page_rect.width(), page_rect.height()); // Account for shrink-to-fit.
diff --git a/third_party/blink/renderer/core/page/scrolling/overscroll_controller.cc b/third_party/blink/renderer/core/page/scrolling/overscroll_controller.cc index ac5acde..2433997 100644 --- a/third_party/blink/renderer/core/page/scrolling/overscroll_controller.cc +++ b/third_party/blink/renderer/core/page/scrolling/overscroll_controller.cc
@@ -8,9 +8,9 @@ #include "third_party/blink/renderer/core/page/chrome_client.h" #include "third_party/blink/renderer/core/scroll/scroll_types.h" #include "third_party/blink/renderer/core/style/computed_style_base_constants.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/graphics/paint/scroll_paint_property_node.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -49,7 +49,7 @@ void OverscrollController::HandleOverscroll( const ScrollResult& scroll_result, - const FloatPoint& position_in_root_frame, + const gfx::PointF& position_in_root_frame, const FloatSize& velocity_in_root_frame) { DCHECK(visual_viewport_); DCHECK(chrome_client_); @@ -62,8 +62,8 @@ gfx::ScaleVector2d(unused_delta, visual_viewport_->Scale()); gfx::Vector2dF velocity_in_viewport = gfx::ScaleVector2d( ToGfxVector2dF(velocity_in_root_frame), visual_viewport_->Scale()); - gfx::PointF position_in_viewport = ToGfxPointF( - visual_viewport_->RootFrameToViewport(position_in_root_frame)); + gfx::PointF position_in_viewport = + visual_viewport_->RootFrameToViewport(position_in_root_frame); ResetAccumulated(scroll_result.did_scroll_x, scroll_result.did_scroll_y);
diff --git a/third_party/blink/renderer/core/page/scrolling/overscroll_controller.h b/third_party/blink/renderer/core/page/scrolling/overscroll_controller.h index 1840c41..eb07f4b4 100644 --- a/third_party/blink/renderer/core/page/scrolling/overscroll_controller.h +++ b/third_party/blink/renderer/core/page/scrolling/overscroll_controller.h
@@ -9,10 +9,13 @@ #include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/heap/handle.h" +namespace gfx { +class PointF; +} + namespace blink { class ChromeClient; -class FloatPoint; struct ScrollResult; class VisualViewport; @@ -33,7 +36,7 @@ // in the case of a fling gesture where we want the overscroll to feel like // it has momentum. void HandleOverscroll(const ScrollResult&, - const FloatPoint& position_in_root_frame, + const gfx::PointF& position_in_root_frame, const FloatSize& velocity_in_root_frame); void Trace(Visitor*) const;
diff --git a/third_party/blink/renderer/core/page/scrolling/root_scroller_test.cc b/third_party/blink/renderer/core/page/scrolling/root_scroller_test.cc index c03f1dd0..c65daaf8 100644 --- a/third_party/blink/renderer/core/page/scrolling/root_scroller_test.cc +++ b/third_party/blink/renderer/core/page/scrolling/root_scroller_test.cc
@@ -1097,7 +1097,7 @@ GetDocument().GetPage()->GetVisualViewport().SetScale(2); GetDocument().GetPage()->GetVisualViewport().SetLocation( - FloatPoint(100, 120)); + gfx::PointF(100, 120)); auto* frame = To<LocalFrame>(GetDocument().GetPage()->MainFrame()); EXPECT_EQ(100, frame->DomWindow()->visualViewport()->pageLeft()); @@ -2846,7 +2846,7 @@ .GlobalRootScroller(); ScrollableArea* scrollable_area = To<LayoutBox>(scroller->GetLayoutObject())->GetScrollableArea(); - scrollable_area->DidCompositorScroll(FloatPoint(0, 100000)); + scrollable_area->DidCompositorScroll(gfx::PointF(0, 100000)); WebView().ResizeWithBrowserControls(gfx::Size(400, 450), 50, 50, false);
diff --git a/third_party/blink/renderer/core/page/scrolling/scroll_metrics_test.cc b/third_party/blink/renderer/core/page/scrolling/scroll_metrics_test.cc index 38ef5014..7f02f7f 100644 --- a/third_party/blink/renderer/core/page/scrolling/scroll_metrics_test.cc +++ b/third_party/blink/renderer/core/page/scrolling/scroll_metrics_test.cc
@@ -54,15 +54,15 @@ class ScrollBeginEventBuilder : public WebGestureEvent { public: - ScrollBeginEventBuilder(FloatPoint position, - FloatPoint delta, + ScrollBeginEventBuilder(gfx::PointF position, + gfx::PointF delta, WebGestureDevice device) : WebGestureEvent(WebInputEvent::Type::kGestureScrollBegin, WebInputEvent::kNoModifiers, base::TimeTicks::Now(), device) { - SetPositionInWidget(ToGfxPointF(position)); - SetPositionInScreen(ToGfxPointF(position)); + SetPositionInWidget(position); + SetPositionInScreen(position); data.scroll_begin.delta_y_hint = delta.y(); frame_scale_ = 1; } @@ -103,9 +103,9 @@ DCHECK(element->getBoundingClientRect()); DOMRect* rect = element->getBoundingClientRect(); ScrollBeginEventBuilder scroll_begin( - FloatPoint(rect->left() + rect->width() / 2, - rect->top() + rect->height() / 2), - FloatPoint(0.f, 1.f), device); + gfx::PointF(rect->left() + rect->width() / 2, + rect->top() + rect->height() / 2), + gfx::PointF(0.f, 1.f), device); ScrollUpdateEventBuilder scroll_update; ScrollEndEventBuilder scroll_end; GetDocument().GetFrame()->GetEventHandler().HandleGestureEvent(scroll_begin);
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 a108cbc..b1e06e3c 100644 --- a/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.cc +++ b/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.cc
@@ -104,7 +104,7 @@ auto* scrollable = ScrollableAreaWithElementIdInAllLocalFrames(element_id); if (!scrollable) return; - scrollable->DidCompositorScroll(FloatPoint(offset.x(), offset.y())); + scrollable->DidCompositorScroll(gfx::PointF(offset.x(), offset.y())); if (snap_target_ids) scrollable->SetTargetSnapAreaElementIds(snap_target_ids.value()); }
diff --git a/third_party/blink/renderer/core/page/scrolling/scrolling_test.cc b/third_party/blink/renderer/core/page/scrolling/scrolling_test.cc index 6339629c..055800db 100644 --- a/third_party/blink/renderer/core/page/scrolling/scrolling_test.cc +++ b/third_party/blink/renderer/core/page/scrolling/scrolling_test.cc
@@ -1841,8 +1841,7 @@ // The compositor offset is reflected in blink and cc scroll tree. gfx::PointF expected_scroll_position = gfx::PointAtOffsetFromOrigin(compositor_delta); - EXPECT_EQ(expected_scroll_position, - ToGfxPointF(scrollable_area->ScrollPosition())); + EXPECT_EQ(expected_scroll_position, scrollable_area->ScrollPosition()); EXPECT_EQ(expected_scroll_position, CurrentScrollOffset(scroll_node)); // Before updating the lifecycle, set the scroll offset back to what it was @@ -1880,7 +1879,7 @@ ForceFullCompositingUpdate(); EXPECT_EQ(gfx::PointF(0, 0), CurrentScrollOffset(inner_viewport_scroll_node)); - page->GetVisualViewport().SetLocation(FloatPoint(10, 20)); + page->GetVisualViewport().SetLocation(gfx::PointF(10, 20)); ForceFullCompositingUpdate(); EXPECT_EQ(gfx::PointF(10, 20), CurrentScrollOffset(inner_viewport_scroll_node)); @@ -2036,7 +2035,7 @@ // Simulate a direct scroll update out of document lifecycle update. scroller->scrollTo(0, 200); - EXPECT_EQ(FloatPoint(0, 200), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(0, 200), scrollable_area->ScrollPosition()); EXPECT_EQ(gfx::PointF(0, 200), CurrentScrollOffset(element_id)); // Simulate the scroll update with scroll delta from impl-side at the @@ -2045,7 +2044,7 @@ commit_data.scrolls.push_back(cc::CompositorCommitData::ScrollUpdateInfo( element_id, gfx::Vector2dF(0, 10), absl::nullopt)); RootCcLayer()->layer_tree_host()->ApplyCompositorChanges(&commit_data); - EXPECT_EQ(FloatPoint(0, 210), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(0, 210), scrollable_area->ScrollPosition()); EXPECT_EQ(gfx::PointF(0, 210), CurrentScrollOffset(element_id)); }
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 4ffe2efd..39eabdf 100644 --- a/third_party/blink/renderer/core/page/scrolling/snap_coordinator.cc +++ b/third_party/blink/renderer/core/page/scrolling/snap_coordinator.cc
@@ -263,9 +263,9 @@ // to keep the area data up to date. So just update the type and skip updating // areas as an optimization. if (!snap_container_data.scroll_snap_type().is_none) { - FloatPoint max_position = scrollable_area->ScrollOffsetToPosition( + gfx::PointF max_position = scrollable_area->ScrollOffsetToPosition( scrollable_area->MaximumScrollOffset()); - snap_container_data.set_max_position(ToGfxPointF(max_position)); + snap_container_data.set_max_position(max_position); // Scroll-padding represents inward offsets from the corresponding edge of // the scrollport.
diff --git a/third_party/blink/renderer/core/page/scrolling/snap_coordinator_test.cc b/third_party/blink/renderer/core/page/scrolling/snap_coordinator_test.cc index 23e7b31..a601111 100644 --- a/third_party/blink/renderer/core/page/scrolling/snap_coordinator_test.cc +++ b/third_party/blink/renderer/core/page/scrolling/snap_coordinator_test.cc
@@ -397,7 +397,7 @@ GetSnapContainerData(*scroller_element->GetLayoutBox()); EXPECT_TRUE(data); cc::SnapContainerData actual_container = *data; - FloatPoint max_position = scrollable_area->ScrollOffsetToPosition( + gfx::PointF max_position = scrollable_area->ScrollOffsetToPosition( scrollable_area->MaximumScrollOffset()); double width = scroller_element->clientWidth(); @@ -405,7 +405,7 @@ cc::SnapContainerData expected_container( cc::ScrollSnapType(false, cc::SnapAxis::kBoth, cc::SnapStrictness::kMandatory), - gfx::RectF(10, 10, width - 20, height - 20), ToGfxPointF(max_position)); + gfx::RectF(10, 10, width - 20, height - 20), max_position); cc::SnapAreaData expected_area(cc::ScrollSnapAlign(cc::SnapAlignment::kStart), gfx::RectF(192, 192, 116, 116), false, cc::ElementId(10)); @@ -421,7 +421,7 @@ ScrollableArea* scrollable_area = scroller_element->GetLayoutBox()->GetScrollableArea(); scroller_element->scrollBy(20, 20); - EXPECT_EQ(FloatPoint(20, 20), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(20, 20), scrollable_area->ScrollPosition()); Element* area_element = GetDocument().getElementById("area"); area_element->setAttribute(kStyleAttr, "scroll-snap-align: start;"); UpdateAllLifecyclePhasesForTest(); @@ -430,7 +430,7 @@ GetSnapContainerData(*scroller_element->GetLayoutBox()); EXPECT_TRUE(data); cc::SnapContainerData actual_container = *data; - FloatPoint max_position = scrollable_area->ScrollOffsetToPosition( + gfx::PointF max_position = scrollable_area->ScrollOffsetToPosition( scrollable_area->MaximumScrollOffset()); double width = scroller_element->clientWidth(); @@ -438,7 +438,7 @@ cc::SnapContainerData expected_container( cc::ScrollSnapType(false, cc::SnapAxis::kBoth, cc::SnapStrictness::kMandatory), - gfx::RectF(10, 10, width - 20, height - 20), ToGfxPointF(max_position)); + gfx::RectF(10, 10, width - 20, height - 20), max_position); cc::SnapAreaData expected_area(cc::ScrollSnapAlign(cc::SnapAlignment::kStart), gfx::RectF(192, 192, 116, 116), false, cc::ElementId(10)); @@ -480,7 +480,7 @@ EXPECT_EQ(body, GetDocument().ViewportDefiningElement()); ScrollableArea* scrollable_area = GetDocument().View()->LayoutViewport(); body->scrollBy(20, 20); - EXPECT_EQ(FloatPoint(20, 20), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(20, 20), scrollable_area->ScrollPosition()); Element* area_element = GetDocument().getElementById("area"); area_element->setAttribute(kStyleAttr, "scroll-snap-align: start;"); UpdateAllLifecyclePhasesForTest(); @@ -489,7 +489,7 @@ EXPECT_TRUE(data); cc::SnapContainerData actual_container = *data; - FloatPoint max_position = scrollable_area->ScrollOffsetToPosition( + gfx::PointF max_position = scrollable_area->ScrollOffsetToPosition( scrollable_area->MaximumScrollOffset()); double width = body->clientWidth(); @@ -497,7 +497,7 @@ cc::SnapContainerData expected_container( cc::ScrollSnapType(false, cc::SnapAxis::kBoth, cc::SnapStrictness::kMandatory), - gfx::RectF(0, 0, width, height), ToGfxPointF(max_position)); + gfx::RectF(0, 0, width, height), max_position); cc::SnapAreaData expected_area(cc::ScrollSnapAlign(cc::SnapAlignment::kStart), gfx::RectF(200, 200, 100, 100), false, @@ -525,7 +525,7 @@ ScrollableArea* scrollable_area = scroller_element->GetLayoutBox()->GetScrollableArea(); - FloatPoint max_position = scrollable_area->ScrollOffsetToPosition( + gfx::PointF max_position = scrollable_area->ScrollOffsetToPosition( scrollable_area->MaximumScrollOffset()); double width = scroller_element->clientWidth(); @@ -535,7 +535,7 @@ cc::SnapContainerData expected_container( cc::ScrollSnapType(false, cc::SnapAxis::kBoth, cc::SnapStrictness::kMandatory), - gfx::RectF(20, 20, width - 20, height - 20), ToGfxPointF(max_position)); + gfx::RectF(20, 20, width - 20, height - 20), max_position); // rect.x = scroller.border + scroller.padding + area.left + area.margin // - area.scroll-margin // rect.y = scroller.border + scroller.padding + area.top + area.margin @@ -567,7 +567,7 @@ ScrollableArea* scrollable_area = scroller_element->GetLayoutBox()->GetScrollableArea(); - FloatPoint max_position = scrollable_area->ScrollOffsetToPosition( + gfx::PointF max_position = scrollable_area->ScrollOffsetToPosition( scrollable_area->MaximumScrollOffset()); double width = scroller_element->clientWidth(); @@ -576,7 +576,7 @@ cc::SnapContainerData expected_container( cc::ScrollSnapType(false, cc::SnapAxis::kBoth, cc::SnapStrictness::kMandatory), - gfx::RectF(10, 10, width - 20, height - 20), ToGfxPointF(max_position)); + gfx::RectF(10, 10, width - 20, height - 20), max_position); cc::SnapAreaData expected_area(cc::ScrollSnapAlign(cc::SnapAlignment::kStart), gfx::RectF(208, 208, 84, 84), false, cc::ElementId(10)); @@ -613,7 +613,7 @@ ScrollableArea* scrollable_area = scroller_element->GetLayoutBox()->GetScrollableArea(); - FloatPoint max_position = scrollable_area->ScrollOffsetToPosition( + gfx::PointF max_position = scrollable_area->ScrollOffsetToPosition( scrollable_area->MaximumScrollOffset()); double width = scroller_element->clientWidth(); @@ -622,7 +622,7 @@ cc::SnapContainerData expected_container( cc::ScrollSnapType(false, cc::SnapAxis::kBoth, cc::SnapStrictness::kMandatory), - gfx::RectF(16, 10, width - 28, height - 24), ToGfxPointF(max_position)); + gfx::RectF(16, 10, width - 28, height - 24), max_position); cc::SnapAreaData expected_area( cc::ScrollSnapAlign(cc::SnapAlignment::kCenter), gfx::RectF(192, 198, 112, 108), false, cc::ElementId(10)); @@ -646,7 +646,7 @@ ScrollableArea* scrollable_area = scroller_element->GetLayoutBox()->GetScrollableArea(); - FloatPoint max_position = scrollable_area->ScrollOffsetToPosition( + gfx::PointF max_position = scrollable_area->ScrollOffsetToPosition( scrollable_area->MaximumScrollOffset()); double width = scroller_element->clientWidth(); @@ -654,7 +654,7 @@ cc::SnapContainerData expected_container( cc::ScrollSnapType(false, cc::SnapAxis::kBoth, cc::SnapStrictness::kMandatory), - gfx::RectF(10, 10, width - 20, height - 20), ToGfxPointF(max_position)); + gfx::RectF(10, 10, width - 20, height - 20), max_position); // The area is scaled from center, so it pushes the area's top-left corner to // (50, 50). @@ -682,7 +682,7 @@ ScrollableArea* scrollable_area = scroller_element->GetLayoutBox()->GetScrollableArea(); - FloatPoint max_position = scrollable_area->ScrollOffsetToPosition( + gfx::PointF max_position = scrollable_area->ScrollOffsetToPosition( scrollable_area->MaximumScrollOffset()); double width = scroller_element->clientWidth(); @@ -691,7 +691,7 @@ cc::SnapContainerData expected_container( cc::ScrollSnapType(false, cc::SnapAxis::kBoth, cc::SnapStrictness::kMandatory), - gfx::RectF(10, 10, width - 20, height - 20), ToGfxPointF(max_position)); + gfx::RectF(10, 10, width - 20, height - 20), max_position); // Under vertical-rl writing mode, 'start' should align to the right // and 'end' should align to the left. cc::SnapAreaData expected_area(
diff --git a/third_party/blink/renderer/core/page/scrolling/viewport_scroll_callback.cc b/third_party/blink/renderer/core/page/scrolling/viewport_scroll_callback.cc index c5d2416..49838a2 100644 --- a/third_party/blink/renderer/core/page/scrolling/viewport_scroll_callback.cc +++ b/third_party/blink/renderer/core/page/scrolling/viewport_scroll_callback.cc
@@ -85,7 +85,7 @@ // Handle Overscroll. if (overscroll_controller_) { - FloatPoint position(state->positionX(), state->positionY()); + gfx::PointF position(state->positionX(), state->positionY()); FloatSize velocity(state->velocityX(), state->velocityY()); overscroll_controller_->HandleOverscroll(result, position, velocity); }
diff --git a/third_party/blink/renderer/core/page/spatial_navigation.cc b/third_party/blink/renderer/core/page/spatial_navigation.cc index a97d467..4a07e438 100644 --- a/third_party/blink/renderer/core/page/spatial_navigation.cc +++ b/third_party/blink/renderer/core/page/spatial_navigation.cc
@@ -184,7 +184,7 @@ // RootFrameToViewport doesn't clip so manually apply the viewport clip here. FloatRect viewport_rect = - FloatRect(FloatPoint(), FloatSize(visual_viewport.Size())); + FloatRect(gfx::PointF(), FloatSize(visual_viewport.Size())); rect_in_viewport.Intersect(viewport_rect); return rect_in_viewport;
diff --git a/third_party/blink/renderer/core/page/spatial_navigation_controller.cc b/third_party/blink/renderer/core/page/spatial_navigation_controller.cc index 8491b612..bb7d8a2 100644 --- a/third_party/blink/renderer/core/page/spatial_navigation_controller.cc +++ b/third_party/blink/renderer/core/page/spatial_navigation_controller.cc
@@ -510,7 +510,7 @@ void SpatialNavigationController::DispatchMouseMoveAt(Element* element) { gfx::PointF event_position(-1, -1); if (element) { - event_position = ToGfxPointF(RectInViewport(*element).origin()); + event_position = RectInViewport(*element).origin(); event_position.Offset(1, 1); }
diff --git a/third_party/blink/renderer/core/page/spatial_navigation_test.cc b/third_party/blink/renderer/core/page/spatial_navigation_test.cc index 52663c0f..a17b42b 100644 --- a/third_party/blink/renderer/core/page/spatial_navigation_test.cc +++ b/third_party/blink/renderer/core/page/spatial_navigation_test.cc
@@ -124,7 +124,7 @@ // Test RootViewport with a pinched viewport. VisualViewport& visual_viewport = GetFrame().GetPage()->GetVisualViewport(); visual_viewport.SetScale(2); - visual_viewport.SetLocation(FloatPoint(200, 200)); + visual_viewport.SetLocation(gfx::PointF(200, 200)); LocalFrameView* root_frame_view = GetFrame().LocalFrameRoot().View(); const PhysicalRect roots_visible_doc_rect( @@ -654,7 +654,7 @@ // Now, test SearchOrigin with a pinched viewport. VisualViewport& visual_viewport = GetFrame().GetPage()->GetVisualViewport(); visual_viewport.SetScale(2); - visual_viewport.SetLocation(FloatPoint(200, 200)); + visual_viewport.SetLocation(gfx::PointF(200, 200)); origin = SearchOrigin(RootViewport(&GetFrame()), nullptr, SpatialNavigationDirection::kUp); EXPECT_EQ(origin.Height(), 0); @@ -1112,7 +1112,7 @@ // Now, test SearchOrigin with a pinched viewport. VisualViewport& visual_viewport = GetFrame().GetPage()->GetVisualViewport(); visual_viewport.SetScale(2); - visual_viewport.SetLocation(FloatPoint(200, 200)); + visual_viewport.SetLocation(gfx::PointF(200, 200)); origin = SearchOrigin(RootViewport(&GetFrame()), nullptr, SpatialNavigationDirection::kDown); EXPECT_EQ(origin.Height(), 0);
diff --git a/third_party/blink/renderer/core/page/touch_adjustment.cc b/third_party/blink/renderer/core/page/touch_adjustment.cc index 988dbeb..bde4024 100644 --- a/third_party/blink/renderer/core/page/touch_adjustment.cc +++ b/third_party/blink/renderer/core/page/touch_adjustment.cc
@@ -36,11 +36,12 @@ #include "third_party/blink/renderer/core/page/chrome_client.h" #include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/core/style/computed_style.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_quad.h" #include "third_party/blink/renderer/platform/geometry/int_size.h" #include "third_party/blink/renderer/platform/text/text_break_iterator.h" #include "ui/display/screen_info.h" +#include "ui/gfx/geometry/point_conversions.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -375,16 +376,16 @@ return hybrid_score; } -FloatPoint ConvertToRootFrame(LocalFrameView* view, FloatPoint pt) { +gfx::PointF ConvertToRootFrame(LocalFrameView* view, gfx::PointF pt) { int x = static_cast<int>(pt.x() + 0.5f); int y = static_cast<int>(pt.y() + 0.5f); gfx::Point adjusted = view->ConvertToRootFrame(gfx::Point(x, y)); - return FloatPoint(adjusted.x(), adjusted.y()); + return gfx::PointF(adjusted.x(), adjusted.y()); } // Adjusts 'point' to the nearest point inside rect, and leaves it unchanged if // already inside. -void AdjustPointToRect(FloatPoint& point, const IntRect& rect) { +void AdjustPointToRect(gfx::PointF& point, const IntRect& rect) { if (point.x() < rect.x()) point.set_x(rect.x()); else if (point.x() > rect.right()) @@ -424,24 +425,24 @@ // the quad. Corner-cases exist where the quad will intersect but this will // fail to adjust the point to somewhere in the intersection. - FloatPoint p1 = ConvertToRootFrame(view, quad.p1()); - FloatPoint p2 = ConvertToRootFrame(view, quad.p2()); - FloatPoint p3 = ConvertToRootFrame(view, quad.p3()); - FloatPoint p4 = ConvertToRootFrame(view, quad.p4()); + gfx::PointF p1 = ConvertToRootFrame(view, quad.p1()); + gfx::PointF p2 = ConvertToRootFrame(view, quad.p2()); + gfx::PointF p3 = ConvertToRootFrame(view, quad.p3()); + gfx::PointF p4 = ConvertToRootFrame(view, quad.p4()); quad = FloatQuad(p1, p2, p3, p4); - if (quad.ContainsPoint(FloatPoint(touch_point))) { + if (quad.ContainsPoint(gfx::PointF(touch_point))) { adjusted_point = touch_point; return true; } // Pull point towards the center of the element. - FloatPoint center = quad.Center(); + gfx::PointF center = quad.Center(); AdjustPointToRect(center, touch_area); - adjusted_point = RoundedIntPoint(center); + adjusted_point = gfx::ToRoundedPoint(center); - return quad.ContainsPoint(FloatPoint(adjusted_point)); + return quad.ContainsPoint(gfx::PointF(adjusted_point)); } // A generic function for finding the target node with the lowest distance
diff --git a/third_party/blink/renderer/core/page/touch_adjustment.h b/third_party/blink/renderer/core/page/touch_adjustment.h index 575f2fc..5802b474 100644 --- a/third_party/blink/renderer/core/page/touch_adjustment.h +++ b/third_party/blink/renderer/core/page/touch_adjustment.h
@@ -22,12 +22,12 @@ #include "base/memory/scoped_refptr.h" #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/geometry/layout_size.h" #include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/wtf/vector.h" #include "ui/gfx/geometry/point.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -53,7 +53,7 @@ struct TouchAdjustmentResult { uint32_t unique_event_id; - FloatPoint adjusted_point; + gfx::PointF adjusted_point; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/applied_decoration_painter.cc b/third_party/blink/renderer/core/paint/applied_decoration_painter.cc index 6120d57..47a2e7ec 100644 --- a/third_party/blink/renderer/core/paint/applied_decoration_painter.cc +++ b/third_party/blink/renderer/core/paint/applied_decoration_painter.cc
@@ -31,7 +31,7 @@ if (decoration_info_.DecorationStyle() == ETextDecorationStyle::kDouble) { context_.DrawLineForText( decoration_info_.StartPoint(line_) + - FloatPoint(0, decoration_info_.DoubleOffset(line_)), + gfx::Vector2dF(0, decoration_info_.DoubleOffset(line_)), decoration_info_.Width(), auto_dark_mode, flags); } }
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 bbf443f..5a87444 100644 --- a/third_party/blink/renderer/core/paint/box_border_painter.cc +++ b/third_party/blink/renderer/core/paint/box_border_painter.cc
@@ -357,13 +357,13 @@ }; void ClipQuad(GraphicsContext& context, - const FloatPoint quad[], + const gfx::PointF quad[], bool antialiased) { SkPathBuilder path; - path.moveTo(FloatPointToSkPoint(quad[0])); - path.lineTo(FloatPointToSkPoint(quad[1])); - path.lineTo(FloatPointToSkPoint(quad[2])); - path.lineTo(FloatPointToSkPoint(quad[3])); + path.moveTo(gfx::PointFToSkPoint(quad[0])); + path.lineTo(gfx::PointFToSkPoint(quad[1])); + path.lineTo(gfx::PointFToSkPoint(quad[2])); + path.lineTo(gfx::PointFToSkPoint(quad[3])); context.ClipPath(path.detach(), antialiased ? kAntiAliased : kNotAntiAliased); } @@ -596,15 +596,15 @@ } void FillQuad(GraphicsContext& context, - const FloatPoint quad[], + const gfx::PointF quad[], const Color& color, bool antialias, const AutoDarkMode& auto_dark_mode) { SkPathBuilder path; - path.moveTo(FloatPointToSkPoint(quad[0])); - path.lineTo(FloatPointToSkPoint(quad[1])); - path.lineTo(FloatPointToSkPoint(quad[2])); - path.lineTo(FloatPointToSkPoint(quad[3])); + path.moveTo(gfx::PointFToSkPoint(quad[0])); + path.lineTo(gfx::PointFToSkPoint(quad[1])); + path.lineTo(gfx::PointFToSkPoint(quad[2])); + path.lineTo(gfx::PointFToSkPoint(quad[3])); PaintFlags flags(context.FillFlags()); flags.setAntiAlias(antialias); flags.setColor(color.Rgb()); @@ -638,37 +638,59 @@ return; } - FloatPoint quad[4]; + gfx::PointF quad[4]; switch (side) { case BoxSide::kTop: - quad[0] = FloatPoint(x1 + std::max(-adjacent_width1, 0), y1); - quad[1] = FloatPoint(x1 + std::max(adjacent_width1, 0), y2); - quad[2] = FloatPoint(x2 - std::max(adjacent_width2, 0), y2); - quad[3] = FloatPoint(x2 - std::max(-adjacent_width2, 0), y1); + quad[0] = gfx::PointF(x1 + std::max(-adjacent_width1, 0), y1); + quad[1] = gfx::PointF(x1 + std::max(adjacent_width1, 0), y2); + quad[2] = gfx::PointF(x2 - std::max(adjacent_width2, 0), y2); + quad[3] = gfx::PointF(x2 - std::max(-adjacent_width2, 0), y1); break; case BoxSide::kBottom: - quad[0] = FloatPoint(x1 + std::max(adjacent_width1, 0), y1); - quad[1] = FloatPoint(x1 + std::max(-adjacent_width1, 0), y2); - quad[2] = FloatPoint(x2 - std::max(-adjacent_width2, 0), y2); - quad[3] = FloatPoint(x2 - std::max(adjacent_width2, 0), y1); + quad[0] = gfx::PointF(x1 + std::max(adjacent_width1, 0), y1); + quad[1] = gfx::PointF(x1 + std::max(-adjacent_width1, 0), y2); + quad[2] = gfx::PointF(x2 - std::max(-adjacent_width2, 0), y2); + quad[3] = gfx::PointF(x2 - std::max(adjacent_width2, 0), y1); break; case BoxSide::kLeft: - quad[0] = FloatPoint(x1, y1 + std::max(-adjacent_width1, 0)); - quad[1] = FloatPoint(x1, y2 - std::max(-adjacent_width2, 0)); - quad[2] = FloatPoint(x2, y2 - std::max(adjacent_width2, 0)); - quad[3] = FloatPoint(x2, y1 + std::max(adjacent_width1, 0)); + quad[0] = gfx::PointF(x1, y1 + std::max(-adjacent_width1, 0)); + quad[1] = gfx::PointF(x1, y2 - std::max(-adjacent_width2, 0)); + quad[2] = gfx::PointF(x2, y2 - std::max(adjacent_width2, 0)); + quad[3] = gfx::PointF(x2, y1 + std::max(adjacent_width1, 0)); break; case BoxSide::kRight: - quad[0] = FloatPoint(x1, y1 + std::max(adjacent_width1, 0)); - quad[1] = FloatPoint(x1, y2 - std::max(adjacent_width2, 0)); - quad[2] = FloatPoint(x2, y2 - std::max(-adjacent_width2, 0)); - quad[3] = FloatPoint(x2, y1 + std::max(-adjacent_width1, 0)); + quad[0] = gfx::PointF(x1, y1 + std::max(adjacent_width1, 0)); + quad[1] = gfx::PointF(x1, y2 - std::max(adjacent_width2, 0)); + quad[2] = gfx::PointF(x2, y2 - std::max(-adjacent_width2, 0)); + quad[3] = gfx::PointF(x2, y1 + std::max(-adjacent_width1, 0)); break; } FillQuad(context, quad, color, antialias, auto_dark_mode); } +void FindIntersection(const gfx::PointF& p1, + const gfx::PointF& p2, + const gfx::PointF& d1, + const gfx::PointF& d2, + gfx::PointF& intersection) { + float px_length = p2.x() - p1.x(); + float py_length = p2.y() - p1.y(); + + float dx_length = d2.x() - d1.x(); + float dy_length = d2.y() - d1.y(); + + float denom = px_length * dy_length - py_length * dx_length; + if (!denom) + return; + + float param = + ((d1.x() - p1.x()) * dy_length - (d1.y() - p1.y()) * dx_length) / denom; + + intersection.set_x(p1.x() + param * px_length); + intersection.set_y(p1.y() + param * py_length); +} + } // anonymous namespace // Holds edges grouped by opacity and sorted in paint order. @@ -1477,10 +1499,10 @@ MiterType second_miter) const { DCHECK(first_miter != kNoMiter || second_miter != kNoMiter); - FloatPoint edge_quad[4]; // The boundary of the edge for fill - FloatPoint + gfx::PointF edge_quad[4]; // The boundary of the edge for fill + gfx::PointF bound_quad1; // Point 1 of the rectilinear bounding box of EdgeQuad - FloatPoint + gfx::PointF bound_quad2; // Point 2 of the rectilinear bounding box of EdgeQuad const PhysicalRect outer_rect = PhysicalRect::EnclosingRect(outer_.Rect()); @@ -1502,30 +1524,31 @@ // Offset size and direction to expand clipping quad const static float kExtensionLength = 1e-1f; - FloatSize extension_offset; + gfx::Vector2dF extension_offset; switch (side) { case BoxSide::kTop: - edge_quad[0] = FloatPoint(outer_rect.MinXMinYCorner()); - edge_quad[1] = FloatPoint(inner_rect.MinXMinYCorner()); - edge_quad[2] = FloatPoint(inner_rect.MaxXMinYCorner()); - edge_quad[3] = FloatPoint(outer_rect.MaxXMinYCorner()); + edge_quad[0] = gfx::PointF(outer_rect.MinXMinYCorner()); + edge_quad[1] = gfx::PointF(inner_rect.MinXMinYCorner()); + edge_quad[2] = gfx::PointF(inner_rect.MaxXMinYCorner()); + edge_quad[3] = gfx::PointF(outer_rect.MaxXMinYCorner()); DCHECK(edge_quad[0].y() == edge_quad[3].y()); DCHECK(edge_quad[1].y() == edge_quad[2].y()); - bound_quad1 = FloatPoint(edge_quad[0].x(), edge_quad[1].y()); - bound_quad2 = FloatPoint(edge_quad[3].x(), edge_quad[2].y()); + bound_quad1 = gfx::PointF(edge_quad[0].x(), edge_quad[1].y()); + bound_quad2 = gfx::PointF(edge_quad[3].x(), edge_quad[2].y()); - extension_offset.set_width(-kExtensionLength); - extension_offset.set_height(0); + extension_offset.set_x(-kExtensionLength); + extension_offset.set_y(0); if (!inner_.GetRadii().TopLeft().IsZero()) { FindIntersection( edge_quad[0], edge_quad[1], - FloatPoint(edge_quad[1].x() + inner_.GetRadii().TopLeft().width(), - edge_quad[1].y()), - FloatPoint(edge_quad[1].x(), - edge_quad[1].y() + inner_.GetRadii().TopLeft().height()), + gfx::PointF(edge_quad[1].x() + inner_.GetRadii().TopLeft().width(), + edge_quad[1].y()), + gfx::PointF( + edge_quad[1].x(), + edge_quad[1].y() + inner_.GetRadii().TopLeft().height()), edge_quad[1]); DCHECK(bound_quad1.y() <= edge_quad[1].y()); bound_quad1.set_y(edge_quad[1].y()); @@ -1535,9 +1558,9 @@ if (!inner_.GetRadii().TopRight().IsZero()) { FindIntersection( edge_quad[3], edge_quad[2], - FloatPoint(edge_quad[2].x() - inner_.GetRadii().TopRight().width(), - edge_quad[2].y()), - FloatPoint( + gfx::PointF(edge_quad[2].x() - inner_.GetRadii().TopRight().width(), + edge_quad[2].y()), + gfx::PointF( edge_quad[2].x(), edge_quad[2].y() + inner_.GetRadii().TopRight().height()), edge_quad[2]); @@ -1551,27 +1574,28 @@ case BoxSide::kLeft: // Swap the order of adjacent edges to allow common code std::swap(first_miter, second_miter); - edge_quad[0] = FloatPoint(outer_rect.MinXMaxYCorner()); - edge_quad[1] = FloatPoint(inner_rect.MinXMaxYCorner()); - edge_quad[2] = FloatPoint(inner_rect.MinXMinYCorner()); - edge_quad[3] = FloatPoint(outer_rect.MinXMinYCorner()); + edge_quad[0] = gfx::PointF(outer_rect.MinXMaxYCorner()); + edge_quad[1] = gfx::PointF(inner_rect.MinXMaxYCorner()); + edge_quad[2] = gfx::PointF(inner_rect.MinXMinYCorner()); + edge_quad[3] = gfx::PointF(outer_rect.MinXMinYCorner()); DCHECK(edge_quad[0].x() == edge_quad[3].x()); DCHECK(edge_quad[1].x() == edge_quad[2].x()); - bound_quad1 = FloatPoint(edge_quad[1].x(), edge_quad[0].y()); - bound_quad2 = FloatPoint(edge_quad[2].x(), edge_quad[3].y()); + bound_quad1 = gfx::PointF(edge_quad[1].x(), edge_quad[0].y()); + bound_quad2 = gfx::PointF(edge_quad[2].x(), edge_quad[3].y()); - extension_offset.set_width(0); - extension_offset.set_height(kExtensionLength); + extension_offset.set_x(0); + extension_offset.set_y(kExtensionLength); if (!inner_.GetRadii().TopLeft().IsZero()) { FindIntersection( edge_quad[3], edge_quad[2], - FloatPoint(edge_quad[2].x() + inner_.GetRadii().TopLeft().width(), - edge_quad[2].y()), - FloatPoint(edge_quad[2].x(), - edge_quad[2].y() + inner_.GetRadii().TopLeft().height()), + gfx::PointF(edge_quad[2].x() + inner_.GetRadii().TopLeft().width(), + edge_quad[2].y()), + gfx::PointF( + edge_quad[2].x(), + edge_quad[2].y() + inner_.GetRadii().TopLeft().height()), edge_quad[2]); DCHECK(bound_quad2.x() <= edge_quad[2].x()); bound_quad1.set_x(edge_quad[2].x()); @@ -1581,10 +1605,10 @@ if (!inner_.GetRadii().BottomLeft().IsZero()) { FindIntersection( edge_quad[0], edge_quad[1], - FloatPoint( + gfx::PointF( edge_quad[1].x() + inner_.GetRadii().BottomLeft().width(), edge_quad[1].y()), - FloatPoint( + gfx::PointF( edge_quad[1].x(), edge_quad[1].y() - inner_.GetRadii().BottomLeft().height()), edge_quad[1]); @@ -1598,27 +1622,27 @@ case BoxSide::kBottom: // Swap the order of adjacent edges to allow common code std::swap(first_miter, second_miter); - edge_quad[0] = FloatPoint(outer_rect.MaxXMaxYCorner()); - edge_quad[1] = FloatPoint(inner_rect.MaxXMaxYCorner()); - edge_quad[2] = FloatPoint(inner_rect.MinXMaxYCorner()); - edge_quad[3] = FloatPoint(outer_rect.MinXMaxYCorner()); + edge_quad[0] = gfx::PointF(outer_rect.MaxXMaxYCorner()); + edge_quad[1] = gfx::PointF(inner_rect.MaxXMaxYCorner()); + edge_quad[2] = gfx::PointF(inner_rect.MinXMaxYCorner()); + edge_quad[3] = gfx::PointF(outer_rect.MinXMaxYCorner()); DCHECK(edge_quad[0].y() == edge_quad[3].y()); DCHECK(edge_quad[1].y() == edge_quad[2].y()); - bound_quad1 = FloatPoint(edge_quad[0].x(), edge_quad[1].y()); - bound_quad2 = FloatPoint(edge_quad[3].x(), edge_quad[2].y()); + bound_quad1 = gfx::PointF(edge_quad[0].x(), edge_quad[1].y()); + bound_quad2 = gfx::PointF(edge_quad[3].x(), edge_quad[2].y()); - extension_offset.set_width(kExtensionLength); - extension_offset.set_height(0); + extension_offset.set_x(kExtensionLength); + extension_offset.set_y(0); if (!inner_.GetRadii().BottomLeft().IsZero()) { FindIntersection( edge_quad[3], edge_quad[2], - FloatPoint( + gfx::PointF( edge_quad[2].x() + inner_.GetRadii().BottomLeft().width(), edge_quad[2].y()), - FloatPoint( + gfx::PointF( edge_quad[2].x(), edge_quad[2].y() - inner_.GetRadii().BottomLeft().height()), edge_quad[2]); @@ -1630,10 +1654,10 @@ if (!inner_.GetRadii().BottomRight().IsZero()) { FindIntersection( edge_quad[0], edge_quad[1], - FloatPoint( + gfx::PointF( edge_quad[1].x() - inner_.GetRadii().BottomRight().width(), edge_quad[1].y()), - FloatPoint( + gfx::PointF( edge_quad[1].x(), edge_quad[1].y() - inner_.GetRadii().BottomRight().height()), edge_quad[1]); @@ -1645,26 +1669,26 @@ break; case BoxSide::kRight: - edge_quad[0] = FloatPoint(outer_rect.MaxXMinYCorner()); - edge_quad[1] = FloatPoint(inner_rect.MaxXMinYCorner()); - edge_quad[2] = FloatPoint(inner_rect.MaxXMaxYCorner()); - edge_quad[3] = FloatPoint(outer_rect.MaxXMaxYCorner()); + edge_quad[0] = gfx::PointF(outer_rect.MaxXMinYCorner()); + edge_quad[1] = gfx::PointF(inner_rect.MaxXMinYCorner()); + edge_quad[2] = gfx::PointF(inner_rect.MaxXMaxYCorner()); + edge_quad[3] = gfx::PointF(outer_rect.MaxXMaxYCorner()); DCHECK(edge_quad[0].x() == edge_quad[3].x()); DCHECK(edge_quad[1].x() == edge_quad[2].x()); - bound_quad1 = FloatPoint(edge_quad[1].x(), edge_quad[0].y()); - bound_quad2 = FloatPoint(edge_quad[2].x(), edge_quad[3].y()); + bound_quad1 = gfx::PointF(edge_quad[1].x(), edge_quad[0].y()); + bound_quad2 = gfx::PointF(edge_quad[2].x(), edge_quad[3].y()); - extension_offset.set_width(0); - extension_offset.set_height(-kExtensionLength); + extension_offset.set_x(0); + extension_offset.set_y(-kExtensionLength); if (!inner_.GetRadii().TopRight().IsZero()) { FindIntersection( edge_quad[0], edge_quad[1], - FloatPoint(edge_quad[1].x() - inner_.GetRadii().TopRight().width(), - edge_quad[1].y()), - FloatPoint( + gfx::PointF(edge_quad[1].x() - inner_.GetRadii().TopRight().width(), + edge_quad[1].y()), + gfx::PointF( edge_quad[1].x(), edge_quad[1].y() + inner_.GetRadii().TopRight().height()), edge_quad[1]); @@ -1676,10 +1700,10 @@ if (!inner_.GetRadii().BottomRight().IsZero()) { FindIntersection( edge_quad[3], edge_quad[2], - FloatPoint( + gfx::PointF( edge_quad[2].x() - inner_.GetRadii().BottomRight().width(), edge_quad[2].y()), - FloatPoint( + gfx::PointF( edge_quad[2].x(), edge_quad[2].y() - inner_.GetRadii().BottomRight().height()), edge_quad[2]); @@ -1703,7 +1727,7 @@ // the miter edge. We extend the clip in the miter direction to ensure overlap // as each edge is drawn. if (first_miter != kNoMiter) { - FloatPoint clipping_quad[4]; + gfx::PointF clipping_quad[4]; clipping_quad[0] = edge_quad[0] + extension_offset; FindIntersection(edge_quad[0], edge_quad[1], bound_quad1, bound_quad2, @@ -1716,7 +1740,7 @@ } if (second_miter != kNoMiter) { - FloatPoint clipping_quad[4]; + gfx::PointF clipping_quad[4]; clipping_quad[0] = edge_quad[0]; clipping_quad[1] = bound_quad1;
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 d79f767..a2bc06a 100644 --- a/third_party/blink/renderer/core/paint/box_painter_base.cc +++ b/third_party/blink/renderer/core/paint/box_painter_base.cc
@@ -102,7 +102,7 @@ if (shadow.Style() != ShadowStyle::kNormal) continue; - FloatSize shadow_offset(shadow.X(), shadow.Y()); + gfx::Vector2dF shadow_offset = shadow.Location().OffsetFromOrigin(); float shadow_blur = shadow.Blur(); float shadow_spread = shadow.Spread(); @@ -210,7 +210,7 @@ bounds.Outset(-shadow.Spread()); FloatRect offset_bounds = bounds; - offset_bounds.MoveBy(-shadow.Location()); + offset_bounds.Offset(-shadow.Location().OffsetFromOrigin()); return UnionRects(bounds, offset_bounds); } @@ -278,8 +278,8 @@ } DrawLooperBuilder draw_looper_builder; - draw_looper_builder.AddShadow(ToFloatSize(shadow.Location()), shadow.Blur(), - shadow_color, + draw_looper_builder.AddShadow(shadow.Location().OffsetFromOrigin(), + shadow.Blur(), shadow_color, DrawLooperBuilder::kShadowRespectsTransforms, DrawLooperBuilder::kShadowIgnoresAlpha); context.SetDrawLooper(draw_looper_builder.DetachDrawLooper()); @@ -541,7 +541,7 @@ // Note that this tile rect uses the image's pre-scaled size. ImageTilingInfo tiling_info; tiling_info.image_rect.set_size(intrinsic_tile_size); - tiling_info.phase = FloatPoint(geometry.ComputeDestPhase()); + tiling_info.phase = gfx::PointF(geometry.ComputeDestPhase()); tiling_info.spacing = FloatSize(geometry.SpaceSize()); // Farther down the pipeline we will use the scaled tile size to determine @@ -604,7 +604,7 @@ GetBGColorPaintWorkletImage(document, node, dest_rect.Rect().size()); if (!paint_worklet_image) return false; - FloatRect src_rect(FloatPoint(), dest_rect.Rect().size()); + FloatRect src_rect(gfx::PointF(), dest_rect.Rect().size()); context.DrawImageRRect( paint_worklet_image.get(), Image::kSyncDecode, PaintAutoDarkMode(style, DarkModeFilter::ElementRole::kBackground),
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 b515eb7..90ef420 100644 --- a/third_party/blink/renderer/core/paint/clip_rect_test.cc +++ b/third_party/blink/renderer/core/paint/clip_rect_test.cc
@@ -71,7 +71,7 @@ TEST_F(ClipRectTest, IntersectsInfinite) { ClipRect rect; - EXPECT_TRUE(rect.Intersects(HitTestLocation(FloatPoint(100000, -3333333)))); + EXPECT_TRUE(rect.Intersects(HitTestLocation(gfx::PointF(100000, -3333333)))); } TEST_F(ClipRectTest, ToString) {
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 db907e2503..61a357b4 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
@@ -115,10 +115,10 @@ // layer for use in CompositedLayerMapping. // // If the layer is not using composited sticky position, this will return -// FloatPoint(). -static FloatPoint StickyPositionOffsetForLayer(PaintLayer& layer) { +// gfx::PointF(). +static gfx::PointF StickyPositionOffsetForLayer(PaintLayer& layer) { if (!UsesCompositedStickyPosition(layer)) - return FloatPoint(); + return gfx::PointF(); const StickyConstraintsMap& constraints_map = layer.AncestorScrollContainerLayer() @@ -127,7 +127,7 @@ const StickyPositionScrollingConstraints* constraints = constraints_map.at(&layer); - return FloatPoint(constraints->GetOffsetForStickyPosition(constraints_map)); + return gfx::PointF(constraints->GetOffsetForStickyPosition(constraints_map)); } static bool NeedsDecorationOutlineLayer(const PaintLayer& paint_layer, @@ -408,7 +408,7 @@ const PaintLayer* layer, const PaintLayer* composited_ancestor, const PhysicalOffset& local_representative_point_for_fragmentation, - const FloatPoint& offset_for_sticky_position) { + const gfx::PointF& 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 // input to be in the space of the PaintLayer. We also need to add in this @@ -432,7 +432,7 @@ if (composited_ancestor) offset += composited_ancestor->SubpixelAccumulation(); offset -= local_representative_point_for_fragmentation; - offset -= PhysicalOffset::FromFloatPointRound(offset_for_sticky_position); + offset -= PhysicalOffset::FromPointFRound(offset_for_sticky_position); return offset; } @@ -483,7 +483,7 @@ // positioned elements. If the compositor is handling sticky offsets for // this layer, we need to remove the Blink-side offset to avoid // double-counting. - FloatPoint offset_for_sticky_position = + gfx::PointF offset_for_sticky_position = StickyPositionOffsetForLayer(*owning_layer_); PhysicalOffset offset_from_composited_ancestor = ComputeOffsetFromCompositedAncestor( @@ -1636,8 +1636,7 @@ GeometryMapper::SourceToDestinationRect(root_view_state.Transform(), source_state.Transform(), local_interest_rect); - local_interest_rect.MoveBy( - -FloatPoint(graphics_layer->GetOffsetFromTransformNode())); + local_interest_rect.Offset(-graphics_layer->GetOffsetFromTransformNode()); // TODO(chrishtr): the code below is a heuristic. Instead we should detect // and return whether the mapping failed. In some cases,
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 8fcfcb0c..727475b 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
@@ -32,12 +32,12 @@ #include "third_party/blink/renderer/core/paint/compositing/graphics_layer_updater.h" #include "third_party/blink/renderer/core/paint/paint_layer.h" #include "third_party/blink/renderer/core/paint/paint_layer_painting_info.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_point_3d.h" #include "third_party/blink/renderer/platform/graphics/graphics_layer.h" #include "third_party/blink/renderer/platform/graphics/graphics_layer_client.h" #include "third_party/blink/renderer/platform/graphics/graphics_types.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" +#include "ui/gfx/geometry/point_f.h" namespace blink {
diff --git a/third_party/blink/renderer/core/paint/compositing/compositing_test.cc b/third_party/blink/renderer/core/paint/compositing/compositing_test.cc index a5c9ff8..f914f20d 100644 --- a/third_party/blink/renderer/core/paint/compositing/compositing_test.cc +++ b/third_party/blink/renderer/core/paint/compositing/compositing_test.cc
@@ -1779,7 +1779,7 @@ commit_data.scrolls.emplace_back(cc::CompositorCommitData::ScrollUpdateInfo( element_id, gfx::Vector2dF(0, 10), absl::nullopt)); Compositor().LayerTreeHost()->ApplyCompositorChanges(&commit_data); - EXPECT_EQ(FloatPoint(0, 10), scrollable_area->ScrollPosition()); + EXPECT_EQ(gfx::PointF(0, 10), scrollable_area->ScrollPosition()); EXPECT_EQ(gfx::PointF(0, 10), GetPropertyTrees()->scroll_tree.current_scroll_offset(element_id));
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 b2c5f61..1aafe1d4 100644 --- a/third_party/blink/renderer/core/paint/document_marker_painter.cc +++ b/third_party/blink/renderer/core/paint/document_marker_painter.cc
@@ -89,7 +89,7 @@ #endif // defined(OS_MAC) void DrawDocumentMarker(GraphicsContext& context, - const FloatPoint& pt, + const gfx::PointF& pt, float width, float zoom, PaintRecord* const marker) { @@ -197,9 +197,9 @@ break; } context.DrawLineForText( - FloatPoint(box_origin.left + start, - (box_origin.top + logical_height.ToInt() - line_thickness) - .ToFloat()), + gfx::PointF(box_origin.left + start, + (box_origin.top + logical_height.ToInt() - line_thickness) + .ToFloat()), width, PaintAutoDarkMode(style, DarkModeFilter::ElementRole::kText)); } else { // For wavy underline format we use this logic that is very similar to @@ -209,9 +209,9 @@ sk_sp<PaintRecord> composition_marker = (RecordMarker(marker_color)); DrawDocumentMarker( context, - FloatPoint((box_origin.left + start).ToFloat(), - (box_origin.top + logical_height.ToInt() - line_thickness) - .ToFloat()), + gfx::PointF((box_origin.left + start).ToFloat(), + (box_origin.top + logical_height.ToInt() - line_thickness) + .ToFloat()), width, line_thickness, composition_marker.get()); } } @@ -273,8 +273,8 @@ : grammar_marker; DrawDocumentMarker(paint_info.context, - FloatPoint((box_origin.left + local_rect.X()).ToFloat(), - (box_origin.top + underline_offset).ToFloat()), + gfx::PointF((box_origin.left + local_rect.X()).ToFloat(), + (box_origin.top + underline_offset).ToFloat()), local_rect.Width().ToFloat(), zoom, marker); }
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 0cc1e1be..601dbe1 100644 --- a/third_party/blink/renderer/core/paint/embedded_object_painter.cc +++ b/third_party/blink/renderer/core/paint/embedded_object_painter.cc
@@ -82,13 +82,15 @@ DarkModeFilter::ElementRole::kBackground)); context.FillRoundedRect(rounded_background_rect, color, auto_dark_mode); - FloatRect text_rect(FloatPoint(), text_geometry); - text_rect.Offset(FloatPoint(content_rect.Center()) - text_rect.CenterPoint()); + FloatRect text_rect(gfx::PointF(), text_geometry); + text_rect.Offset(gfx::PointF(content_rect.Center()) - + text_rect.CenterPoint()); TextRunPaintInfo run_info(text_run); context.SetFillColor(ScaleAlpha(Color::kBlack, kReplacementTextTextOpacity)); context.DrawBidiText( font, run_info, - text_rect.origin() + FloatSize(0, font_data->GetFontMetrics().Ascent()), + text_rect.origin() + + gfx::Vector2dF(0, font_data->GetFontMetrics().Ascent()), auto_dark_mode); }
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 39d03e51..e7a8675 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
@@ -79,7 +79,7 @@ layout_file_upload_control_.ResolveColor(GetCSSPropertyColor())); paint_info.context.DrawBidiText( font, text_run_paint_info, - FloatPoint(RoundToInt(text_x), RoundToInt(text_y)), + gfx::PointF(RoundToInt(text_x), RoundToInt(text_y)), PaintAutoDarkMode(layout_file_upload_control_.StyleRef(), DarkModeFilter::ElementRole::kText)); if (!font.ShouldSkipDrawing()) {
diff --git a/third_party/blink/renderer/core/paint/filter_effect_builder.cc b/third_party/blink/renderer/core/paint/filter_effect_builder.cc index 8a8c11b..40182b6 100644 --- a/third_party/blink/renderer/core/paint/filter_effect_builder.cc +++ b/third_party/blink/renderer/core/paint/filter_effect_builder.cc
@@ -48,6 +48,7 @@ #include "third_party/blink/renderer/platform/graphics/interpolation_space.h" #include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/wtf/math_extras.h" +#include "ui/gfx/geometry/point_conversions.h" namespace blink { @@ -285,7 +286,8 @@ case FilterOperation::kDropShadow: { const ShadowData& shadow = To<DropShadowFilterOperation>(*filter_operation).Shadow(); - FloatPoint offset = shadow.Location().ScaledBy(shorthand_scale_); + gfx::PointF offset = + gfx::ScalePoint(shadow.Location(), shorthand_scale_); float radius = shadow.Blur() * shorthand_scale_; effect = MakeGarbageCollected<FEDropShadow>( parent_filter, radius, radius, offset.x(), offset.y(), @@ -437,8 +439,8 @@ } case FilterOperation::kDropShadow: { const ShadowData& shadow = To<DropShadowFilterOperation>(*op).Shadow(); - gfx::Point floored_offset = - FlooredIntPoint(shadow.Location().ScaledBy(shorthand_scale_)); + gfx::Point floored_offset = gfx::ToFlooredPoint( + gfx::ScalePoint(shadow.Location(), shorthand_scale_)); float radius = shadow.Blur() * shorthand_scale_; filters.AppendDropShadowFilter(floored_offset, radius, shadow.GetColor().GetColor());
diff --git a/third_party/blink/renderer/core/paint/hit_testing_transform_state.cc b/third_party/blink/renderer/core/paint/hit_testing_transform_state.cc index bdfa58e..3dd78d05 100644 --- a/third_party/blink/renderer/core/paint/hit_testing_transform_state.cc +++ b/third_party/blink/renderer/core/paint/hit_testing_transform_state.cc
@@ -52,7 +52,7 @@ accumulated_transform_.MakeIdentity(); } -FloatPoint HitTestingTransformState::MappedPoint() const { +gfx::PointF HitTestingTransformState::MappedPoint() const { return accumulated_transform_.Inverse().ProjectPoint(last_planar_point_); }
diff --git a/third_party/blink/renderer/core/paint/hit_testing_transform_state.h b/third_party/blink/renderer/core/paint/hit_testing_transform_state.h index 92a5c07..e975630f 100644 --- a/third_party/blink/renderer/core/paint/hit_testing_transform_state.h +++ b/third_party/blink/renderer/core/paint/hit_testing_transform_state.h
@@ -27,11 +27,11 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_HIT_TESTING_TRANSFORM_STATE_H_ #include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_quad.h" #include "third_party/blink/renderer/platform/transforms/affine_transform.h" #include "third_party/blink/renderer/platform/transforms/transformation_matrix.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -41,7 +41,7 @@ STACK_ALLOCATED(); public: - HitTestingTransformState(const FloatPoint& p, + HitTestingTransformState(const gfx::PointF& p, const FloatQuad& quad, const FloatQuad& area) : last_planar_point_(p), @@ -55,7 +55,7 @@ void Translate(const gfx::Vector2dF&); void ApplyTransform(const TransformPaintPropertyNode&); - FloatPoint MappedPoint() const; + gfx::PointF MappedPoint() const; FloatQuad MappedQuad() const; PhysicalRect BoundsOfMappedQuad() const; PhysicalRect BoundsOfMappedArea() const; @@ -65,7 +65,7 @@ } private: - FloatPoint last_planar_point_; + gfx::PointF last_planar_point_; FloatQuad last_planar_quad_; FloatQuad last_planar_area_; TransformationMatrix accumulated_transform_;
diff --git a/third_party/blink/renderer/core/paint/image_painter.cc b/third_party/blink/renderer/core/paint/image_painter.cc index d438ed99..bb9c0901c 100644 --- a/third_party/blink/renderer/core/paint/image_painter.cc +++ b/third_party/blink/renderer/core/paint/image_painter.cc
@@ -212,7 +212,7 @@ auto respect_orientation = image->HasDefaultOrientation() ? kDoNotRespectImageOrientation : image_resource.ImageOrientation(); - FloatRect src_rect(FloatPoint(), image->SizeAsFloat(respect_orientation)); + FloatRect src_rect(gfx::PointF(), image->SizeAsFloat(respect_orientation)); // If the content rect requires clipping, adjust |srcRect| and // |pixelSnappedDestRect| over using a clip.
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 7a80046e..631f31a 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
@@ -582,8 +582,8 @@ inline_text_box_.Root().SelectionTop()) .ToInt(); int sel_height = inline_text_box_.Root().SelectionHeight().ToInt(); - FloatPoint local_origin(box_origin.left.ToFloat(), - box_origin.top.ToFloat() - delta_y); + gfx::PointF local_origin(box_origin.left.ToFloat(), + box_origin.top.ToFloat() - delta_y); context.DrawHighlightForText( font, inline_text_box_.ConstructTextRun(style), local_origin, sel_height, background_color, @@ -730,7 +730,7 @@ // FIXME: Convert the document markers to float rects. IntRect marker_rect = EnclosingIntRect( - font.SelectionRectForText(run, FloatPoint(start_point), sel_height, + font.SelectionRectForText(run, gfx::PointF(start_point), sel_height, marker_offsets.start, marker_offsets.end)); start = marker_rect.x() - start_point.left; width = LayoutUnit(marker_rect.width()); @@ -806,8 +806,8 @@ : inline_text_box_.LogicalTop() - selection_top); int sel_height = std::max(0, RoundToInt(selection_bottom - selection_top)); - FloatPoint local_origin(box_rect.X().ToFloat(), - (box_rect.Y() - delta_y).ToFloat()); + gfx::PointF local_origin(box_rect.X().ToFloat(), + (box_rect.Y() - delta_y).ToFloat()); PhysicalRect selection_rect = PhysicalRect::EnclosingRect(font.SelectionRectForText( text_run, local_origin, sel_height, start_pos, end_pos)); @@ -893,7 +893,7 @@ const TextRun& run = inline_text_box_.ConstructTextRun(style); // Pass 0 for height since we only care about the width const FloatRect& marker_rect = font.SelectionRectForText( - run, FloatPoint(), 0, marker_offsets.start, marker_offsets.end); + run, gfx::PointF(), 0, marker_offsets.start, marker_offsets.end); DocumentMarkerPainter::PaintStyleableMarkerUnderline( context, box_origin, marker, style, inline_text_box_.GetLineLayoutItem().GetDocument(), marker_rect, @@ -978,9 +978,8 @@ inline_text_box_.LogicalHeight())); context.Clip(FloatRect(box_rect)); context.DrawHighlightForText( - font, run, FloatPoint(box_origin), box_rect.Height().ToInt(), color, - PaintAutoDarkMode(style, - DarkModeFilter::ElementRole::kText), + font, run, gfx::PointF(box_origin), box_rect.Height().ToInt(), color, + PaintAutoDarkMode(style, DarkModeFilter::ElementRole::kText), paint_offsets.first, paint_offsets.second); }
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 8fe12fa..d325794 100644 --- a/third_party/blink/renderer/core/paint/list_marker_painter.cc +++ b/third_party/blink/renderer/core/paint/list_marker_painter.cc
@@ -207,10 +207,10 @@ TextRunPaintInfo text_run_paint_info(text_run); const SimpleFontData* font_data = layout_list_marker_.StyleRef().GetFont().PrimaryFont(); - FloatPoint text_origin = - FloatPoint(marker.X().Round(), - marker.Y().Round() + - (font_data ? font_data->GetFontMetrics().Ascent() : 0)); + gfx::PointF text_origin = + gfx::PointF(marker.X().Round(), + marker.Y().Round() + + (font_data ? font_data->GetFontMetrics().Ascent() : 0)); // Text is not arbitrary. We can judge whether it's RTL from the first // character, and we only need to handle the direction RightToLeft for now. @@ -252,20 +252,20 @@ if (layout_list_marker_.StyleRef().IsLeftToRightDirection()) { context.DrawText(font, prefix_run_info, text_origin, kInvalidDOMNodeId, auto_dark_mode); - text_origin += FloatSize(IntSize(font.Width(prefix_run), 0)); + text_origin += gfx::Vector2dF(font.Width(prefix_run), 0); context.DrawText(font, text_run_paint_info, text_origin, kInvalidDOMNodeId, auto_dark_mode); - text_origin += FloatSize(IntSize(font.Width(text_run), 0)); + text_origin += gfx::Vector2dF(font.Width(text_run), 0); context.DrawText(font, suffix_run_info, text_origin, kInvalidDOMNodeId, auto_dark_mode); } else { // Is the truncation to IntSize below meaningful or a bug? context.DrawText(font, suffix_run_info, text_origin, kInvalidDOMNodeId, auto_dark_mode); - text_origin += FloatSize(IntSize(font.Width(suffix_run), 0)); + text_origin += gfx::Vector2dF(font.Width(suffix_run), 0); context.DrawText(font, text_run_paint_info, text_origin, kInvalidDOMNodeId, auto_dark_mode); - text_origin += FloatSize(IntSize(font.Width(text_run), 0)); + text_origin += gfx::Vector2dF(font.Width(text_run), 0); context.DrawText(font, prefix_run_info, text_origin, kInvalidDOMNodeId, auto_dark_mode); }
diff --git a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter_test.cc b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter_test.cc index 175b8f9..94028f1 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter_test.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter_test.cc
@@ -238,7 +238,7 @@ auto* root = GetDocument().getElementById("svg")->GetLayoutBox(); HitTestResult result; - root->NodeAtPoint(result, HitTestLocation(FloatPoint(256, 192)), + root->NodeAtPoint(result, HitTestLocation(gfx::PointF(256, 192)), PhysicalOffset(0, 0), kHitTestForeground); EXPECT_EQ(GetDocument().getElementById("pass"), result.InnerElement()); }
diff --git a/third_party/blink/renderer/core/paint/ng/ng_mathml_painter.cc b/third_party/blink/renderer/core/paint/ng/ng_mathml_painter.cc index 84195716..0d0f0165 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_mathml_painter.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_mathml_painter.cc
@@ -46,7 +46,7 @@ AutoDarkMode auto_dark_mode( PaintAutoDarkMode(style, DarkModeFilter::ElementRole::kText)); info.context.DrawText(style.GetFont(), text_fragment_paint_info, - FloatPoint(paint_offset), kInvalidDOMNodeId, + gfx::PointF(paint_offset), kInvalidDOMNodeId, auto_dark_mode); }
diff --git a/third_party/blink/renderer/core/paint/ng/ng_text_painter.cc b/third_party/blink/renderer/core/paint/ng/ng_text_painter.cc index 6188699..2b8b02b 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_text_painter.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_text_painter.cc
@@ -326,7 +326,7 @@ if (step == kPaintEmphasisMark) { graphics_context_.DrawEmphasisMarks( font_, fragment_paint_info_, emphasis_mark_, - FloatPoint(text_origin_) + IntSize(0, emphasis_mark_offset_), + gfx::PointF(text_origin_) + gfx::Vector2dF(0, emphasis_mark_offset_), auto_dark_mode); } else { DCHECK(step == kPaintText); @@ -334,7 +334,7 @@ PaintSvgTextFragment(node_id, auto_dark_mode); } else { graphics_context_.DrawText(font_, fragment_paint_info_, - FloatPoint(text_origin_), node_id, + gfx::PointF(text_origin_), node_id, auto_dark_mode); } // TODO(npm): Check that there are non-whitespace characters. See @@ -405,11 +405,11 @@ stroke_flags.setColor(state.TextMatchColor().Rgb()); } graphics_context_.DrawText(font_, fragment_paint_info_, - FloatPoint(text_origin_), fill_flags, node_id, + gfx::PointF(text_origin_), fill_flags, node_id, auto_dark_mode); if (should_paint_stroke) { graphics_context_.DrawText(font_, fragment_paint_info_, - FloatPoint(text_origin_), stroke_flags, + gfx::PointF(text_origin_), stroke_flags, node_id, auto_dark_mode); } return; @@ -447,7 +447,7 @@ if (SetupPaintForSvgText(state, graphics_context_, style_to_paint, SvgPaintMode::kText, *resource_mode, flags)) { graphics_context_.DrawText(font_, fragment_paint_info_, - FloatPoint(text_origin_), flags, node_id, + gfx::PointF(text_origin_), flags, node_id, auto_dark_mode); } }
diff --git a/third_party/blink/renderer/core/paint/nine_piece_image_grid.cc b/third_party/blink/renderer/core/paint/nine_piece_image_grid.cc index 1061b5c..18d2322 100644 --- a/third_party/blink/renderer/core/paint/nine_piece_image_grid.cc +++ b/third_party/blink/renderer/core/paint/nine_piece_image_grid.cc
@@ -160,7 +160,7 @@ float offset_y, float width, float height) { - return Subrect(FloatRect(FloatPoint(), size), offset_x, offset_y, width, + return Subrect(FloatRect(gfx::PointF(), size), offset_x, offset_y, width, height); }
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 39e5115..25f6f48 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
@@ -152,12 +152,12 @@ // The phase defines the origin of the whole image - not the image // rect (see ImageTilingInfo) - so we need to adjust it to account // for that. - FloatPoint tile_origin_in_dest_space = draw_info.source.origin(); + gfx::PointF tile_origin_in_dest_space = draw_info.source.origin(); tile_origin_in_dest_space.Scale(tiling_info.scale.width(), tiling_info.scale.height()); tiling_info.phase = draw_info.destination.origin() + - (FloatPoint(h_tile->phase, v_tile->phase) - tile_origin_in_dest_space); + (gfx::PointF(h_tile->phase, v_tile->phase) - tile_origin_in_dest_space); tiling_info.spacing = FloatSize(h_tile->spacing, v_tile->spacing); context.DrawImageTiled(image, draw_info.destination, tiling_info,
diff --git a/third_party/blink/renderer/core/paint/object_paint_properties.h b/third_party/blink/renderer/core/paint/object_paint_properties.h index a41e889..b74b20a 100644 --- a/third_party/blink/renderer/core/paint/object_paint_properties.h +++ b/third_party/blink/renderer/core/paint/object_paint_properties.h
@@ -114,10 +114,8 @@ // The space created by overflow clip. The translation equals the // offset between the scrolling contents and the scrollable area of // the container, both originated from the top-left corner, so it is - // the sum of scroll origin and scroll offset of the ScrollableArea. - // To use any content offset based on ScrollOrigin() (e.g. LayoutBox - // or InlineBox's PhysicalLocation()) in this space, we should add - // ScrollOrigin() to the offset. + // the sum of scroll position (instead of scroll offset) of the + // ScrollableArea. // // ... +-[ TransformIsolationNode ] // This serves as a parent to subtree transforms on an element with
diff --git a/third_party/blink/renderer/core/paint/outline_painter.cc b/third_party/blink/renderer/core/paint/outline_painter.cc index b17dd4c..29e140e 100644 --- a/third_party/blink/renderer/core/paint/outline_painter.cc +++ b/third_party/blink/renderer/core/paint/outline_painter.cc
@@ -20,6 +20,8 @@ #include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h" #include "third_party/blink/renderer/platform/graphics/path.h" #include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h" +#include "ui/gfx/geometry/point_conversions.h" +#include "ui/gfx/geometry/skia_conversions.h" #include "ui/native_theme/native_theme.h" namespace blink { @@ -713,9 +715,10 @@ int joint_offset = (width_ + 1) / 2; ExtendLineAtEndpoint(adjusted_line.start, adjusted_line.end, joint_offset); ExtendLineAtEndpoint(adjusted_line.end, adjusted_line.start, joint_offset); - context_.DrawLine(RoundedIntPoint(FloatPoint(adjusted_line.start)), - RoundedIntPoint(FloatPoint(adjusted_line.end)), - auto_dark_mode); + context_.DrawLine( + gfx::ToRoundedPoint(gfx::SkPointToPointF(adjusted_line.start)), + gfx::ToRoundedPoint(gfx::SkPointToPointF(adjusted_line.end)), + auto_dark_mode); } GraphicsContext& context_;
diff --git a/third_party/blink/renderer/core/paint/paint_layer.cc b/third_party/blink/renderer/core/paint/paint_layer.cc index 0654194..54e86145 100644 --- a/third_party/blink/renderer/core/paint/paint_layer.cc +++ b/third_party/blink/renderer/core/paint/paint_layer.cc
@@ -663,10 +663,10 @@ // transform space, then move into squashing layer state. point += paint_invalidation_container.PrimaryStitchingFragment().PaintOffset(); - point = PhysicalOffset::FromFloatPointRound( + point = PhysicalOffset::FromPointFRound( GeometryMapper::SourceToDestinationProjection(source_state.Transform(), dest_state.Transform()) - .MapPoint(FloatPoint(point))); + .MapPoint(gfx::PointF(point))); point -= PhysicalOffset(squashing_layer->GetOffsetFromTransformNode()); } @@ -1993,7 +1993,7 @@ return 0; // Flatten the point into the target plane - FloatPoint target_point = transform_state.MappedPoint(); + gfx::PointF target_point = transform_state.MappedPoint(); // Now map the point back through the transform, which computes Z. FloatPoint3D backmapped_point = @@ -2522,7 +2522,7 @@ // // We can't just map HitTestLocation and HitTestRect because they may have // been flattened (losing z) by our container. - FloatPoint local_point = new_transform_state.MappedPoint(); + gfx::PointF local_point = new_transform_state.MappedPoint(); PhysicalRect bounds_of_mapped_area = new_transform_state.BoundsOfMappedArea(); absl::optional<HitTestLocation> new_location; if (recursion_data.location.IsRectBasedTest()) @@ -2734,7 +2734,7 @@ else ConvertToLayerCoords(&root_layer, origin); - FloatPoint point(hit_test_location.Point() - origin.offset); + gfx::PointF point(hit_test_location.Point() - origin.offset); gfx::RectF reference_box = ClipPathClipper::LocalReferenceBox(GetLayoutObject()); @@ -2747,7 +2747,7 @@ return !clip_path ->GetPath(FloatRect(reference_box), GetLayoutObject().StyleRef().EffectiveZoom()) - .Contains(ToGfxPointF(point)); + .Contains(point); } DCHECK_EQ(clip_path_operation->GetType(), ClipPathOperation::kReference); LayoutSVGResourceClipper* clipper = @@ -2758,7 +2758,7 @@ // the coordinate system is the top-left of the reference box, so adjust // the point accordingly. if (clipper->ClipPathUnits() == SVGUnitTypes::kSvgUnitTypeUserspaceonuse) - point.MoveBy(-FloatPoint(reference_box.origin())); + point -= reference_box.OffsetFromOrigin(); // Unzoom the point and the reference box, since the <clipPath> geometry is // not zoomed. float inverse_zoom = 1 / GetLayoutObject().StyleRef().EffectiveZoom();
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 90dbb179..1c5f945 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_clipper.cc +++ b/third_party/blink/renderer/core/paint/paint_layer_clipper.cc
@@ -156,8 +156,8 @@ GeometryMapper::SourceToDestinationRect( clip_root_layer_transform, layer_transform, clipped_rect_in_local_space); // TODO(chrishtr): not correct for fragmentation. - clipped_rect_in_local_space.MoveBy( - -FloatPoint(layer_->GetLayoutObject().FirstFragment().PaintOffset())); + clipped_rect_in_local_space.Offset( + -gfx::Vector2dF(layer_->GetLayoutObject().FirstFragment().PaintOffset())); return PhysicalRect::FastAndLossyFromFloatRect(clipped_rect_in_local_space); }
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 7af54dc7..7f62a1a 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
@@ -188,7 +188,8 @@ return box ? box->GetScrollableArea() : nullptr; } -void PaintLayerScrollableArea::DidCompositorScroll(const FloatPoint& position) { +void PaintLayerScrollableArea::DidCompositorScroll( + const gfx::PointF& position) { ScrollableArea::DidCompositorScroll(position); // This should be alive if it receives composited scroll callbacks. CHECK(!HasBeenDisposed()); @@ -770,8 +771,7 @@ layer_size.Width() - border_width - scrollbars.HorizontalSum(), layer_size.Height() - border_height - scrollbars.VerticalSum()); size.ClampNegativeToZero(); - return PhysicalRect(PhysicalOffset::FromFloatPointRound(ScrollPosition()), - size); + return PhysicalRect(PhysicalOffset::FromPointFRound(ScrollPosition()), size); } IntRect PaintLayerScrollableArea::VisibleContentRect( @@ -825,10 +825,10 @@ gfx::Point PaintLayerScrollableArea::LastKnownMousePosition() const { return GetLayoutBox()->GetFrame() - ? FlooredIntPoint(GetLayoutBox() - ->GetFrame() - ->GetEventHandler() - .LastKnownMousePositionInRootFrame()) + ? gfx::ToFlooredPoint(GetLayoutBox() + ->GetFrame() + ->GetEventHandler() + .LastKnownMousePositionInRootFrame()) : gfx::Point(); } @@ -1904,7 +1904,7 @@ EnsureRareData().needs_resnap_ = needs_resnap; } -absl::optional<FloatPoint> +absl::optional<gfx::PointF> PaintLayerScrollableArea::GetSnapPositionAndSetTarget( const cc::SnapSelectionStrategy& strategy) { if (!RareData() || !RareData()->snap_container_data_) @@ -1928,10 +1928,10 @@ cc::TargetSnapAreaElementIds snap_targets; gfx::PointF snap_position; - absl::optional<FloatPoint> snap_point; + absl::optional<gfx::PointF> snap_point; if (data.FindSnapPosition(strategy, &snap_position, &snap_targets, active_element_id)) { - snap_point = FloatPoint(snap_position.x(), snap_position.y()); + snap_point = gfx::PointF(snap_position.x(), snap_position.y()); } if (data.SetTargetSnapAreaElementIds(snap_targets)) @@ -2073,7 +2073,7 @@ (HasHorizontalScrollbar() ? HorizontalScrollbar()->ScrollbarThickness() : resize_control_size)); - if (v_bar_rect.Contains(local_point)) { + if (v_bar_rect.Contains(LayoutPoint(local_point))) { result.SetScrollbar(VerticalScrollbar()); return true; } @@ -2092,7 +2092,7 @@ ? VerticalScrollbar()->ScrollbarThickness() : resize_control_size), h_scrollbar_thickness); - if (h_bar_rect.Contains(local_point)) { + if (h_bar_rect.Contains(LayoutPoint(local_point))) { result.SetScrollbar(HorizontalScrollbar()); return true; } @@ -2371,10 +2371,9 @@ new_scroll_offset.set_height(old_scroll_offset.height()); } - FloatPoint end_point = ScrollOffsetToPosition(new_scroll_offset); + gfx::PointF end_point = ScrollOffsetToPosition(new_scroll_offset); std::unique_ptr<cc::SnapSelectionStrategy> strategy = - cc::SnapSelectionStrategy::CreateForEndPosition(ToGfxPointF(end_point), - true, true); + cc::SnapSelectionStrategy::CreateForEndPosition(end_point, true, true); end_point = GetSnapPositionAndSetTarget(*strategy).value_or(end_point); new_scroll_offset = ScrollPositionToOffset(end_point);
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 71bf985..0fe910a 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
@@ -302,7 +302,7 @@ // only a helper. cc::Layer* LayerForScrolling() const override; - void DidCompositorScroll(const FloatPoint&) override; + void DidCompositorScroll(const gfx::PointF&) override; // GraphicsLayers for the scrolling components. // Any function can return nullptr if they are not accelerated. @@ -334,15 +334,16 @@ gfx::Point ConvertFromRootFrameToVisualViewport( const gfx::Point&) const override; int ScrollSize(ScrollbarOrientation) const override; - FloatPoint ScrollPosition() const override { - return FloatPoint(ScrollOrigin()) + GetScrollOffset(); + gfx::PointF ScrollPosition() const override { + return gfx::PointF(ScrollOrigin()) + ToGfxVector2dF(GetScrollOffset()); } - FloatPoint ScrollOffsetToPosition(const ScrollOffset& offset) const override { - return FloatPoint(ScrollOrigin()) + offset; + gfx::PointF ScrollOffsetToPosition( + const ScrollOffset& offset) const override { + return gfx::PointF(ScrollOrigin()) + ToGfxVector2dF(offset); } ScrollOffset ScrollPositionToOffset( - const FloatPoint& position) const override { - return position - ScrollOrigin(); + const gfx::PointF& position) const override { + return ScrollOffset(position - gfx::PointF(ScrollOrigin())); } IntSize ScrollOffsetInt() const override; ScrollOffset GetScrollOffset() const override; @@ -386,12 +387,13 @@ gfx::Point ScrollOrigin() const { return scroll_origin_; } bool ScrollOriginChanged() const { return scroll_origin_changed_; } - void ScrollToAbsolutePosition(const FloatPoint& position, + void ScrollToAbsolutePosition(const gfx::PointF& position, mojom::blink::ScrollBehavior scroll_behavior = mojom::blink::ScrollBehavior::kInstant, mojom::blink::ScrollType scroll_type = mojom::blink::ScrollType::kProgrammatic) { - SetScrollOffset(position - ScrollOrigin(), scroll_type, scroll_behavior); + SetScrollOffset(ScrollOffset(position - gfx::PointF(ScrollOrigin())), + scroll_type, scroll_behavior); } // This will set the scroll position without clamping, and it will do all @@ -610,7 +612,7 @@ bool NeedsResnap() const override; void SetNeedsResnap(bool) override; - absl::optional<FloatPoint> GetSnapPositionAndSetTarget( + absl::optional<gfx::PointF> GetSnapPositionAndSetTarget( const cc::SnapSelectionStrategy& strategy) override; void DisposeImpl() 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 35e94c64..2835eb6 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_test.cc +++ b/third_party/blink/renderer/core/paint/paint_layer_test.cc
@@ -2942,7 +2942,7 @@ // the same. PaintLayerScrollableArea* scrollable_area = GetPaintLayerByElementId("scroller")->GetScrollableArea(); - scrollable_area->ScrollToAbsolutePosition(FloatPoint(10, 10)); + scrollable_area->ScrollToAbsolutePosition(gfx::PointF(10, 10)); UpdateAllLifecyclePhasesForTest(); EXPECT_EQ(fixed->ExpandedBoundingBoxForCompositingOverlapTest(false),
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 16c45aca3..2670b808 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
@@ -2007,7 +2007,7 @@ context_.current.clip = overflow_clip; } -static FloatPoint PerspectiveOrigin(const LayoutBox& box) { +static gfx::PointF PerspectiveOrigin(const LayoutBox& box) { const ComputedStyle& style = box.StyleRef(); // Perspective origin has no effect without perspective. DCHECK(style.HasPerspective()); @@ -2032,7 +2032,7 @@ TransformPaintPropertyNode::TransformAndOrigin( TransformationMatrix().ApplyPerspective(style.UsedPerspective()), PerspectiveOrigin(To<LayoutBox>(object_)) + - FloatSize(context_.current.paint_offset))}; + gfx::Vector2dF(context_.current.paint_offset))}; state.flags.flattens_inherited_transform = context_.should_flatten_inherited_transform; state.rendering_context_id = context_.rendering_context_id; @@ -2233,11 +2233,9 @@ const auto& box = To<LayoutBox>(object_); DCHECK(box.GetScrollableArea()); - // Bake ScrollOrigin into ScrollTranslation. See comments for - // ScrollTranslation in object_paint_properties.h for details. - FloatPoint scroll_position = FloatPoint(box.ScrollOrigin()) + - box.GetScrollableArea()->GetScrollOffset(); - TransformPaintPropertyNode::State state{-ToGfxVector2dF(scroll_position)}; + gfx::PointF scroll_position = box.GetScrollableArea()->ScrollPosition(); + TransformPaintPropertyNode::State state{ + -scroll_position.OffsetFromOrigin()}; if (!box.GetScrollableArea()->PendingScrollAnchorAdjustment().IsZero()) { context_.current.pending_scroll_anchor_adjustment += ToGfxVector2dF( box.GetScrollableArea()->PendingScrollAnchorAdjustment());
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 30e54009..9bb371f 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
@@ -1760,14 +1760,14 @@ const auto* properties = PaintPropertiesForElement("span"); ASSERT_TRUE(properties); ASSERT_TRUE(properties->Filter()); - EXPECT_EQ(FloatPoint(0, 20), + EXPECT_EQ(gfx::PointF(0, 20), properties->Filter()->Filter().ReferenceBox().origin()); GetDocument().getElementById("spacer")->setAttribute( html_names::kStyleAttr, "display: inline-block; height: 100px"); UpdateAllLifecyclePhasesForTest(); ASSERT_EQ(properties, PaintPropertiesForElement("span")); - EXPECT_EQ(FloatPoint(0, 100), + EXPECT_EQ(gfx::PointF(0, 100), properties->Filter()->Filter().ReferenceBox().origin()); }
diff --git a/third_party/blink/renderer/core/paint/svg_image_painter.cc b/third_party/blink/renderer/core/paint/svg_image_painter.cc index 4240f54..460ade8 100644 --- a/third_party/blink/renderer/core/paint/svg_image_painter.cc +++ b/third_party/blink/renderer/core/paint/svg_image_painter.cc
@@ -70,7 +70,7 @@ RespectImageOrientationEnum respect_orientation = image_resource.ImageOrientation(); - FloatRect src_rect(FloatPoint(), image->SizeAsFloat(respect_orientation)); + FloatRect src_rect(gfx::PointF(), image->SizeAsFloat(respect_orientation)); if (respect_orientation && !image->HasDefaultOrientation()) { // We need the oriented source rect for adjusting the aspect ratio FloatSize unadjusted_size(src_rect.size());
diff --git a/third_party/blink/renderer/core/paint/svg_inline_text_box_painter.cc b/third_party/blink/renderer/core/paint/svg_inline_text_box_painter.cc index d9e5754..75b09ea 100644 --- a/third_party/blink/renderer/core/paint/svg_inline_text_box_painter.cc +++ b/third_party/blink/renderer/core/paint/svg_inline_text_box_painter.cc
@@ -370,8 +370,8 @@ float decoration_offset = BaselineOffsetForDecoration( decoration, font_data->GetFontMetrics(), thickness); - FloatPoint decoration_origin(fragment.x, - fragment.y - decoration_offset / scaling_factor); + gfx::PointF decoration_origin( + fragment.x, fragment.y - decoration_offset / scaling_factor); Path path; path.AddRect( @@ -503,7 +503,7 @@ float scaling_factor = text_layout_object.ScalingFactor(); DCHECK(scaling_factor); - FloatPoint text_origin(fragment.x, fragment.y); + gfx::PointF text_origin(fragment.x, fragment.y); GraphicsContext& context = paint_info.context; GraphicsContextStateSaver state_saver(context, false);
diff --git a/third_party/blink/renderer/core/paint/text_decoration_info.cc b/third_party/blink/renderer/core/paint/text_decoration_info.cc index c055f190..9e2700f0 100644 --- a/third_party/blink/renderer/core/paint/text_decoration_info.cc +++ b/third_party/blink/renderer/core/paint/text_decoration_info.cc
@@ -145,7 +145,7 @@ computed_font_size_(scaled_font.GetFontDescription().ComputedSize()), scaling_factor_(scaling_factor), underline_position_(ResolveUnderlinePosition(style_, baseline_type_)), - local_origin_(FloatPoint(local_origin)), + local_origin_(gfx::PointF(local_origin)), antialias_(ShouldSetDecorationAntialias(style)), decoration_index_(kUndefinedDecorationIndex) { DCHECK(font_data_); @@ -217,9 +217,9 @@ return style_.AppliedTextDecorations()[decoration_index_].GetColor(); } -FloatPoint TextDecorationInfo::StartPoint(TextDecorationLine line) const { +gfx::PointF TextDecorationInfo::StartPoint(TextDecorationLine line) const { return local_origin_ + - FloatPoint( + gfx::Vector2dF( 0, line_data_[TextDecorationToLineDataIndex(line)].line_offset); } float TextDecorationInfo::DoubleOffset(TextDecorationLine line) const { @@ -259,7 +259,7 @@ } FloatRect TextDecorationInfo::BoundsForLine(TextDecorationLine line) const { - FloatPoint start_point = StartPoint(line); + gfx::PointF start_point = StartPoint(line); switch (DecorationStyle()) { case ETextDecorationStyle::kDotted: case ETextDecorationStyle::kDashed: @@ -289,7 +289,7 @@ if (!line_data_[line_data_index].stroke_path) { // These coordinate transforms need to match what's happening in // GraphicsContext's drawLineForText and drawLine. - FloatPoint start_point = StartPoint(line); + gfx::PointF start_point = StartPoint(line); line_data_[TextDecorationToLineDataIndex(line)].stroke_path = GraphicsContext::GetPathForTextLine( start_point, width_, ResolvedThickness(), @@ -368,7 +368,7 @@ if (line_data_[line_data_index].stroke_path) return line_data_[line_data_index].stroke_path; - FloatPoint start_point = StartPoint(line); + gfx::PointF start_point = StartPoint(line); float wave_offset = DoubleOffset(line) * line_data_[TextDecorationToLineDataIndex(line)].wavy_offset_factor; @@ -381,15 +381,15 @@ // AppliedDecorationPainter::StrokeWavyTextDecoration(). // Offset the start point, so the beizer curve starts before the current line, // that way we can clip it exactly the same way in both ends. - FloatPoint p1(start_point + FloatPoint(-2 * step, wave_offset)); + gfx::PointF p1(start_point + gfx::Vector2dF(-2 * step, wave_offset)); // Increase the width including the previous offset, plus an extra wave to be // painted after the line. - FloatPoint p2(start_point + FloatPoint(width_ + 4 * step, wave_offset)); + gfx::PointF p2(start_point + gfx::Vector2dF(width_ + 4 * step, wave_offset)); GraphicsContext::AdjustLineToPixelBoundaries(p1, p2, ResolvedThickness()); Path& path = line_data_[line_data_index].stroke_path.emplace(); - path.MoveTo(ToGfxPointF(p1)); + path.MoveTo(p1); bool is_vertical_line = (p1.x() == p2.x());
diff --git a/third_party/blink/renderer/core/paint/text_decoration_info.h b/third_party/blink/renderer/core/paint/text_decoration_info.h index bc424ee..f18695f 100644 --- a/third_party/blink/renderer/core/paint/text_decoration_info.h +++ b/third_party/blink/renderer/core/paint/text_decoration_info.h
@@ -12,12 +12,12 @@ #include "third_party/blink/renderer/core/style/applied_text_decoration.h" #include "third_party/blink/renderer/core/style/computed_style_constants.h" #include "third_party/blink/renderer/platform/fonts/font_baseline.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/geometry/layout_unit.h" #include "third_party/blink/renderer/platform/graphics/path.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/vector.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { class ComputedStyle; @@ -90,7 +90,7 @@ // SetPerLineData must be called with the line argument before using // the remaining methods. - FloatPoint StartPoint(TextDecorationLine line) const; + gfx::PointF StartPoint(TextDecorationLine line) const; float DoubleOffset(TextDecorationLine line) const; // Compute bounds for the given line and the current decoration. @@ -120,7 +120,7 @@ const float computed_font_size_; const float scaling_factor_; ResolvedUnderlinePosition underline_position_; - FloatPoint local_origin_; + gfx::PointF local_origin_; bool antialias_; Vector<float> applied_decorations_thickness_;
diff --git a/third_party/blink/renderer/core/paint/text_painter.cc b/third_party/blink/renderer/core/paint/text_painter.cc index d9b9de9..b449206 100644 --- a/third_party/blink/renderer/core/paint/text_painter.cc +++ b/third_party/blink/renderer/core/paint/text_painter.cc
@@ -205,12 +205,12 @@ if (step == kPaintEmphasisMark) { graphics_context_.DrawEmphasisMarks( font_, text_run_paint_info, emphasis_mark_, - FloatPoint(text_origin_) + IntSize(0, emphasis_mark_offset_), + gfx::PointF(text_origin_) + gfx::Vector2dF(0, emphasis_mark_offset_), auto_dark_mode); } else { DCHECK(step == kPaintText); graphics_context_.DrawText(font_, text_run_paint_info, - FloatPoint(text_origin_), node_id, + gfx::PointF(text_origin_), node_id, auto_dark_mode); } }
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 61ad750..a847e896 100644 --- a/third_party/blink/renderer/core/paint/text_painter_base.cc +++ b/third_party/blink/renderer/core/paint/text_painter_base.cc
@@ -127,7 +127,7 @@ for (wtf_size_t i = shadow_list->Shadows().size(); i--;) { const ShadowData& shadow = shadow_list->Shadows()[i]; draw_looper_builder.AddShadow( - FloatSize(shadow.X(), shadow.Y()), shadow.Blur(), + shadow.Location().OffsetFromOrigin(), shadow.Blur(), shadow.GetColor().Resolve(current_color, color_scheme), DrawLooperBuilder::kShadowRespectsTransforms, alpha_mode); } @@ -203,9 +203,9 @@ float dilation, const Vector<Font::TextIntercept>& text_intercepts) { for (auto intercept : text_intercepts) { - FloatPoint clip_origin(text_origin_); + gfx::PointF clip_origin(text_origin_); FloatRect clip_rect( - clip_origin + FloatPoint(intercept.begin_, upper), + clip_origin + gfx::Vector2dF(intercept.begin_, upper), FloatSize(intercept.end_ - intercept.begin_, stripe_width)); clip_rect.OutsetX(dilation); // We need to ensure the clip rectangle is covering the full underline @@ -377,7 +377,7 @@ const auto font_ascent = font_data->GetFontMetrics().Ascent(); const TextRun placeholder_text_run(&kIdeographicFullStopCharacter, 1); - const FloatPoint emphasis_mark_text_origin( + const gfx::PointF emphasis_mark_text_origin( text_frame_rect_.X().ToFloat(), text_frame_rect_.Y().ToFloat() + font_ascent + emphasis_mark_offset_); const TextRunPaintInfo text_run_paint_info(placeholder_text_run);
diff --git a/third_party/blink/renderer/core/resize_observer/resize_observer_entry.cc b/third_party/blink/renderer/core/resize_observer/resize_observer_entry.cc index f6f4dc78..3919900 100644 --- a/third_party/blink/renderer/core/resize_observer/resize_observer_entry.cc +++ b/third_party/blink/renderer/core/resize_observer/resize_observer_entry.cc
@@ -28,7 +28,7 @@ LayoutSize bounding_box_size = LayoutSize(svg_graphics_element->GetBBox().size()); content_rect_ = DOMRectReadOnly::FromFloatRect( - FloatRect(FloatPoint(), FloatSize(bounding_box_size))); + FloatRect(gfx::PointF(), FloatSize(bounding_box_size))); ResizeObserverSize* size = ResizeObserverSize::Create( bounding_box_size.Width(), bounding_box_size.Height()); content_box_size_.push_back(size); @@ -72,15 +72,13 @@ } } if (!content_rect_) - content_rect_ = DOMRectReadOnly::FromFloatRect( - FloatRect(FloatPoint(LayoutPoint()), FloatSize(LayoutSize()))); + content_rect_ = DOMRectReadOnly::FromFloatRect(FloatRect()); if (content_box_size_.size() == 0) content_box_size_.push_back(ResizeObserverSize::Create(0, 0)); if (border_box_size_.size() == 0) border_box_size_.push_back(ResizeObserverSize::Create(0, 0)); - if (device_pixel_content_box_size_.size() == 0) { + if (device_pixel_content_box_size_.size() == 0) device_pixel_content_box_size_.push_back(ResizeObserverSize::Create(0, 0)); - } } void ResizeObserverEntry::Trace(Visitor* visitor) const {
diff --git a/third_party/blink/renderer/core/resize_observer/resize_observer_utilities.cc b/third_party/blink/renderer/core/resize_observer/resize_observer_utilities.cc index f940bb2..7a2321b6 100644 --- a/third_party/blink/renderer/core/resize_observer/resize_observer_utilities.cc +++ b/third_party/blink/renderer/core/resize_observer/resize_observer_utilities.cc
@@ -92,7 +92,7 @@ AdjustForAbsoluteZoom::AdjustLayoutUnit(content_rect.Height(), style)); return DOMRectReadOnly::FromFloatRect(FloatRect( - FloatPoint(content_rect.Location()), FloatSize(content_rect.Size()))); + gfx::PointF(content_rect.Location()), FloatSize(content_rect.Size()))); } } // namespace blink
diff --git a/third_party/blink/renderer/core/scroll/mac_scrollbar_animator_impl.h b/third_party/blink/renderer/core/scroll/mac_scrollbar_animator_impl.h index 2664d17..84971bb 100644 --- a/third_party/blink/renderer/core/scroll/mac_scrollbar_animator_impl.h +++ b/third_party/blink/renderer/core/scroll/mac_scrollbar_animator_impl.h
@@ -9,12 +9,12 @@ #include "base/task/single_thread_task_runner.h" #include "third_party/blink/renderer/core/scroll/mac_scrollbar_animator.h" #include "third_party/blink/renderer/core/scroll/scroll_animator_base.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/scheduler/public/post_cancellable_task.h" #include "third_party/blink/renderer/platform/timer.h" +#include "ui/gfx/geometry/point_f.h" @class BlinkScrollbarObserver; @class BlinkScrollbarPainterControllerDelegate;
diff --git a/third_party/blink/renderer/core/scroll/scroll_animator_compositor_coordinator.cc b/third_party/blink/renderer/core/scroll/scroll_animator_compositor_coordinator.cc index adce6bb0..ac81bd3 100644 --- a/third_party/blink/renderer/core/scroll/scroll_animator_compositor_coordinator.cc +++ b/third_party/blink/renderer/core/scroll/scroll_animator_compositor_coordinator.cc
@@ -235,14 +235,15 @@ return compositor_animation_.get(); } -FloatPoint ScrollAnimatorCompositorCoordinator::CompositorOffsetFromBlinkOffset( +gfx::PointF +ScrollAnimatorCompositorCoordinator::CompositorOffsetFromBlinkOffset( ScrollOffset offset) { return GetScrollableArea()->ScrollOffsetToPosition(offset); } ScrollOffset ScrollAnimatorCompositorCoordinator::BlinkOffsetFromCompositorOffset( - FloatPoint position) { + gfx::PointF position) { return GetScrollableArea()->ScrollPositionToOffset(position); }
diff --git a/third_party/blink/renderer/core/scroll/scroll_animator_compositor_coordinator.h b/third_party/blink/renderer/core/scroll/scroll_animator_compositor_coordinator.h index eae1afc..6afe19b 100644 --- a/third_party/blink/renderer/core/scroll/scroll_animator_compositor_coordinator.h +++ b/third_party/blink/renderer/core/scroll/scroll_animator_compositor_coordinator.h
@@ -138,8 +138,8 @@ // writing-mode:vertical-rl, // and flex-direction:row-reverse), they aren't. See core/layout/README.md // for more info. - FloatPoint CompositorOffsetFromBlinkOffset(ScrollOffset); - ScrollOffset BlinkOffsetFromCompositorOffset(FloatPoint); + gfx::PointF CompositorOffsetFromBlinkOffset(ScrollOffset); + ScrollOffset BlinkOffsetFromCompositorOffset(gfx::PointF); void CompositorAnimationFinished(int group_id); // Returns true if the compositor animation was attached to a new layer.
diff --git a/third_party/blink/renderer/core/scroll/scroll_animator_test.cc b/third_party/blink/renderer/core/scroll/scroll_animator_test.cc index 246efe4..712d7396 100644 --- a/third_party/blink/renderer/core/scroll/scroll_animator_test.cc +++ b/third_party/blink/renderer/core/scroll/scroll_animator_test.cc
@@ -36,10 +36,10 @@ #include "third_party/blink/renderer/core/scroll/scroll_animator_base.h" #include "third_party/blink/renderer/core/scroll/scrollable_area.h" #include "third_party/blink/renderer/core/scroll/scrollbar_theme.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/scheduler/public/thread.h" #include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h" +#include "ui/gfx/geometry/point_f.h" namespace blink {
diff --git a/third_party/blink/renderer/core/scroll/scroll_types.h b/third_party/blink/renderer/core/scroll/scroll_types.h index 785c550e..320afbd5 100644 --- a/third_party/blink/renderer/core/scroll/scroll_types.h +++ b/third_party/blink/renderer/core/scroll/scroll_types.h
@@ -30,8 +30,8 @@ #include "third_party/blink/public/mojom/input/scroll_direction.mojom-blink.h" #include "third_party/blink/public/mojom/scroll/scroll_enums.mojom-blink.h" #include "third_party/blink/public/mojom/scroll/scroll_into_view_params.mojom-blink.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_size.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -42,10 +42,6 @@ // information. typedef FloatSize ScrollOffset; -inline ScrollOffset ToScrollOffset(const FloatPoint& p) { - return ScrollOffset(p.x(), p.y()); -} - inline ScrollOffset ToScrollOffset(const gfx::PointF& p) { return ScrollOffset(p.x(), p.y()); }
diff --git a/third_party/blink/renderer/core/scroll/scrollable_area.cc b/third_party/blink/renderer/core/scroll/scrollable_area.cc index 0fb9a7a..ab48ff9 100644 --- a/third_party/blink/renderer/core/scroll/scrollable_area.cc +++ b/third_party/blink/renderer/core/scroll/scrollable_area.cc
@@ -922,7 +922,7 @@ std::max(0, size.height() - HorizontalScrollbarHeight())); } -void ScrollableArea::DidCompositorScroll(const FloatPoint& position) { +void ScrollableArea::DidCompositorScroll(const gfx::PointF& position) { ScrollOffset new_offset(ScrollPositionToOffset(position)); SetScrollOffset(new_offset, mojom::blink::ScrollType::kCompositor); } @@ -964,19 +964,19 @@ bool scrolled_y, base::ScopedClosureRunner on_finish) { DCHECK(IsRootFrameViewport() || !GetLayoutBox()->IsGlobalRootScroller()); - FloatPoint current_position = ScrollPosition(); + gfx::PointF current_position = ScrollPosition(); return SnapForEndPosition(current_position, scrolled_x, scrolled_y, std::move(on_finish)); } -bool ScrollableArea::SnapForEndPosition(const FloatPoint& end_position, +bool ScrollableArea::SnapForEndPosition(const gfx::PointF& end_position, bool scrolled_x, bool scrolled_y, base::ScopedClosureRunner on_finish) { DCHECK(IsRootFrameViewport() || !GetLayoutBox()->IsGlobalRootScroller()); std::unique_ptr<cc::SnapSelectionStrategy> strategy = - cc::SnapSelectionStrategy::CreateForEndPosition(ToGfxPointF(end_position), - scrolled_x, scrolled_y); + cc::SnapSelectionStrategy::CreateForEndPosition(end_position, scrolled_x, + scrolled_y); return PerformSnapping(*strategy, mojom::blink::ScrollBehavior::kSmooth, std::move(on_finish)); } @@ -984,10 +984,10 @@ bool ScrollableArea::SnapForDirection(const ScrollOffset& delta, base::ScopedClosureRunner on_finish) { DCHECK(IsRootFrameViewport() || !GetLayoutBox()->IsGlobalRootScroller()); - FloatPoint current_position = ScrollPosition(); + gfx::PointF current_position = ScrollPosition(); std::unique_ptr<cc::SnapSelectionStrategy> strategy = cc::SnapSelectionStrategy::CreateForDirection( - ToGfxPointF(current_position), ToGfxVector2dF(delta), + current_position, ToGfxVector2dF(delta), RuntimeEnabledFeatures::FractionalScrollOffsetsEnabled()); return PerformSnapping(*strategy, mojom::blink::ScrollBehavior::kSmooth, std::move(on_finish)); @@ -995,10 +995,10 @@ bool ScrollableArea::SnapForEndAndDirection(const ScrollOffset& delta) { DCHECK(IsRootFrameViewport() || !GetLayoutBox()->IsGlobalRootScroller()); - FloatPoint current_position = ScrollPosition(); + gfx::PointF current_position = ScrollPosition(); std::unique_ptr<cc::SnapSelectionStrategy> strategy = cc::SnapSelectionStrategy::CreateForEndAndDirection( - ToGfxPointF(current_position), ToGfxVector2dF(delta), + current_position, ToGfxVector2dF(delta), RuntimeEnabledFeatures::FractionalScrollOffsetsEnabled()); return PerformSnapping(*strategy); } @@ -1008,11 +1008,9 @@ if (!container_data || !container_data->size()) return; - FloatPoint current_position = ScrollPosition(); + gfx::PointF current_position = ScrollPosition(); std::unique_ptr<cc::SnapSelectionStrategy> strategy = - cc::SnapSelectionStrategy::CreateForTargetElement( - ToGfxPointF(current_position)); - + cc::SnapSelectionStrategy::CreateForTargetElement(current_position); PerformSnapping(*strategy, mojom::blink::ScrollBehavior::kInstant); } @@ -1020,7 +1018,8 @@ const cc::SnapSelectionStrategy& strategy, mojom::blink::ScrollBehavior scroll_behavior, base::ScopedClosureRunner on_finish) { - absl::optional<FloatPoint> snap_point = GetSnapPositionAndSetTarget(strategy); + absl::optional<gfx::PointF> snap_point = + GetSnapPositionAndSetTarget(strategy); if (!snap_point) return false; CancelScrollAnimation();
diff --git a/third_party/blink/renderer/core/scroll/scrollable_area.h b/third_party/blink/renderer/core/scroll/scrollable_area.h index 8f6b86bf7..c43332c 100644 --- a/third_party/blink/renderer/core/scroll/scrollable_area.h +++ b/third_party/blink/renderer/core/scroll/scrollable_area.h
@@ -187,7 +187,7 @@ bool scrolled_y, base::ScopedClosureRunner on_finish = base::ScopedClosureRunner()); bool SnapForEndPosition( - const FloatPoint& end_position, + const gfx::PointF& end_position, bool scrolled_x, bool scrolled_y, base::ScopedClosureRunner on_finish = base::ScopedClosureRunner()); @@ -203,7 +203,7 @@ // // NOTE: If a target position is found, then it is expected that this position // will be scrolled to. - virtual absl::optional<FloatPoint> GetSnapPositionAndSetTarget( + virtual absl::optional<gfx::PointF> GetSnapPositionAndSetTarget( const cc::SnapSelectionStrategy& strategy) { return absl::nullopt; } @@ -339,14 +339,14 @@ // of blink renderer, we should pass "scroll origin". Similarly, when "scroll // offset" is set from outside of blink renderer, we should set "scroll // position" here. - virtual FloatPoint ScrollPosition() const { - return FloatPoint(GetScrollOffset()); + virtual gfx::PointF ScrollPosition() const { + return ScrollOffsetToPosition(GetScrollOffset()); } - virtual FloatPoint ScrollOffsetToPosition(const ScrollOffset& offset) const { - return FloatPoint(offset); + virtual gfx::PointF ScrollOffsetToPosition(const ScrollOffset& offset) const { + return gfx::PointF(offset.width(), offset.height()); } virtual ScrollOffset ScrollPositionToOffset( - const FloatPoint& position) const { + const gfx::PointF& position) const { return ToScrollOffset(position); } virtual IntSize ScrollOffsetInt() const = 0; @@ -534,7 +534,7 @@ const = 0; // Callback for compositor-side scrolling. - virtual void DidCompositorScroll(const FloatPoint& position); + virtual void DidCompositorScroll(const gfx::PointF& position); virtual void ScrollbarFrameRectChanged() {}
diff --git a/third_party/blink/renderer/core/scroll/scrollable_area_test.cc b/third_party/blink/renderer/core/scroll/scrollable_area_test.cc index 4a9f987..66647e87 100644 --- a/third_party/blink/renderer/core/scroll/scrollable_area_test.cc +++ b/third_party/blink/renderer/core/scroll/scrollable_area_test.cc
@@ -301,7 +301,7 @@ MockScrollableArea* scrollable_area = MockScrollableArea::Create(ScrollOffset(100, 100)); - scrollable_area->DidCompositorScroll(FloatPoint(40, 51)); + scrollable_area->DidCompositorScroll(gfx::PointF(40, 51)); EXPECT_EQ(40, scrollable_area->ScrollOffsetInt().width()); EXPECT_EQ(51, scrollable_area->ScrollOffsetInt().height());
diff --git a/third_party/blink/renderer/core/scroll/scrollbar.cc b/third_party/blink/renderer/core/scroll/scrollbar.cc index 7d99c42..13e0448 100644 --- a/third_party/blink/renderer/core/scroll/scrollbar.cc +++ b/third_party/blink/renderer/core/scroll/scrollbar.cc
@@ -40,6 +40,7 @@ #include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/text/text_direction.h" #include "ui/base/ui_base_features.h" +#include "ui/gfx/geometry/point_conversions.h" namespace blink { @@ -346,7 +347,7 @@ DCHECK(should_update_capture); switch (evt.GetType()) { case WebInputEvent::Type::kGestureTapDown: { - gfx::Point position = FlooredIntPoint(evt.PositionInRootFrame()); + gfx::Point position = gfx::ToFlooredPoint(evt.PositionInRootFrame()); SetPressedPart(GetTheme().HitTestRootFramePosition(*this, position), evt.GetType()); pressed_pos_ = Orientation() == kHorizontalScrollbar @@ -448,7 +449,7 @@ } void Scrollbar::MouseMoved(const WebMouseEvent& evt) { - gfx::Point position = FlooredIntPoint(evt.PositionInRootFrame()); + gfx::Point position = gfx::ToFlooredPoint(evt.PositionInRootFrame()); ScrollbarPart part = GetTheme().HitTestRootFramePosition(*this, position); // If the WebMouseEvent was already handled on the compositor thread, simply @@ -527,7 +528,7 @@ scrollable_area_->MouseReleasedScrollbar(); ScrollbarPart part = GetTheme().HitTestRootFramePosition( - *this, FlooredIntPoint(mouse_event.PositionInRootFrame())); + *this, gfx::ToFlooredPoint(mouse_event.PositionInRootFrame())); if (part == kNoPart) { SetHoveredPart(kNoPart); scrollable_area_->MouseExitedScrollbar(*this); @@ -542,7 +543,7 @@ if (evt.button == WebPointerProperties::Button::kRight) return; - gfx::Point position = FlooredIntPoint(evt.PositionInRootFrame()); + gfx::Point position = gfx::ToFlooredPoint(evt.PositionInRootFrame()); SetPressedPart(GetTheme().HitTestRootFramePosition(*this, position), evt.GetType());
diff --git a/third_party/blink/renderer/core/scroll/scrollbar_theme_aura.cc b/third_party/blink/renderer/core/scroll/scrollbar_theme_aura.cc index 400d6280..4a44489 100644 --- a/third_party/blink/renderer/core/scroll/scrollbar_theme_aura.cc +++ b/third_party/blink/renderer/core/scroll/scrollbar_theme_aura.cc
@@ -44,6 +44,7 @@ #include "third_party/blink/renderer/platform/graphics/graphics_context.h" #include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h" #include "third_party/blink/renderer/platform/web_test_support.h" +#include "ui/gfx/geometry/point_conversions.h" namespace blink { @@ -362,7 +363,7 @@ int snap_outside_of_max = expansion_amount + thickness; gfx::Point mouse_position = scrollbar.ConvertFromRootFrame( - FlooredIntPoint(event.PositionInRootFrame())); + gfx::ToFlooredPoint(event.PositionInRootFrame())); int mouse_offset_in_scrollbar = is_horizontal ? mouse_position.y() : mouse_position.x();
diff --git a/third_party/blink/renderer/core/style/computed_style.cc b/third_party/blink/renderer/core/style/computed_style.cc index 056d83f..5ba6b08 100644 --- a/third_party/blink/renderer/core/style/computed_style.cc +++ b/third_party/blink/renderer/core/style/computed_style.cc
@@ -1280,7 +1280,7 @@ ApplyMotionPath apply_motion_path, ApplyIndependentTransformProperties apply_independent_transform_properties) const { - ApplyTransform(result, FloatRect(FloatPoint(), FloatSize(border_box_size)), + ApplyTransform(result, FloatRect(gfx::PointF(), FloatSize(border_box_size)), apply_origin, apply_motion_path, apply_independent_transform_properties); } @@ -1395,10 +1395,10 @@ float origin_shift_y = 0; // If the offset-position and offset-anchor properties are not yet enabled, // they will have the default value, auto. - FloatPoint anchor_point(origin_x, origin_y); + gfx::PointF anchor_point(origin_x, origin_y); if (!position.X().IsAuto() || !anchor.X().IsAuto()) { anchor_point = FloatPointForLengthPoint(anchor, bounding_box.size()); - anchor_point += bounding_box.origin(); + anchor_point += bounding_box.OffsetFromOrigin(); // Shift the origin from transform-origin to offset-anchor. origin_shift_x = anchor_point.x() - origin_x;
diff --git a/third_party/blink/renderer/core/style/filter_operations_test.cc b/third_party/blink/renderer/core/style/filter_operations_test.cc index 813f3e51..a71e3e8 100644 --- a/third_party/blink/renderer/core/style/filter_operations_test.cc +++ b/third_party/blink/renderer/core/style/filter_operations_test.cc
@@ -48,7 +48,7 @@ TEST(FilterOperationsTest, mapRectDropShadow) { FilterOperations ops; ops.Operations().push_back(MakeGarbageCollected<DropShadowFilterOperation>( - ShadowData(FloatPoint(3, 8), 20, 0, ShadowStyle::kNormal, + ShadowData(gfx::PointF(3, 8), 20, 0, ShadowStyle::kNormal, StyleColor(Color(1, 2, 3))))); EXPECT_TRUE(ops.HasFilterThatMovesPixels()); EXPECT_EQ(IntRect(-54, -49, 124, 124), @@ -70,7 +70,7 @@ // important that the bounds be filtered in the correct order. FilterOperations ops; ops.Operations().push_back(MakeGarbageCollected<DropShadowFilterOperation>( - ShadowData(FloatPoint(100, 200), 0, 0, ShadowStyle::kNormal, + ShadowData(gfx::PointF(100, 200), 0, 0, ShadowStyle::kNormal, StyleColor(Color::kBlack)))); ops.Operations().push_back(MakeGarbageCollected<BoxReflectFilterOperation>( BoxReflection(BoxReflection::kVerticalReflection, 50)));
diff --git a/third_party/blink/renderer/core/style/shadow_data.cc b/third_party/blink/renderer/core/style/shadow_data.cc index a97e281..a848356 100644 --- a/third_party/blink/renderer/core/style/shadow_data.cc +++ b/third_party/blink/renderer/core/style/shadow_data.cc
@@ -33,7 +33,7 @@ } ShadowData ShadowData::NeutralValue() { - return ShadowData(FloatPoint(0, 0), 0, 0, ShadowStyle::kNormal, + return ShadowData(gfx::PointF(0, 0), 0, 0, ShadowStyle::kNormal, StyleColor(Color::kTransparent)); }
diff --git a/third_party/blink/renderer/core/style/shadow_data.h b/third_party/blink/renderer/core/style/shadow_data.h index 80ffe3f..e04ebee7 100644 --- a/third_party/blink/renderer/core/style/shadow_data.h +++ b/third_party/blink/renderer/core/style/shadow_data.h
@@ -28,8 +28,8 @@ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/css/style_color.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_rect_outsets.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -41,7 +41,7 @@ USING_FAST_MALLOC(ShadowData); public: - ShadowData(const FloatPoint& location, + ShadowData(const gfx::PointF& location, float blur, float spread, ShadowStyle style, @@ -59,7 +59,7 @@ float X() const { return location_.x(); } float Y() const { return location_.y(); } - FloatPoint Location() const { return location_; } + gfx::PointF Location() const { return location_; } float Blur() const { return blur_; } float Spread() const { return spread_; } ShadowStyle Style() const { return style_; } @@ -72,7 +72,7 @@ FloatRectOutsets RectOutsets() const; private: - FloatPoint location_; + gfx::PointF location_; float blur_; float spread_; StyleColor color_;
diff --git a/third_party/blink/renderer/core/svg/graphics/filters/svg_fe_image.cc b/third_party/blink/renderer/core/svg/graphics/filters/svg_fe_image.cc index ec770e4..5b8fb4d 100644 --- a/third_party/blink/renderer/core/svg/graphics/filters/svg_fe_image.cc +++ b/third_party/blink/renderer/core/svg/graphics/filters/svg_fe_image.cc
@@ -89,7 +89,7 @@ gfx::SizeF viewport_size; if (!length_context.DetermineViewport(viewport_size)) return absl::nullopt; - return MakeMapBetweenRects(FloatRect(FloatPoint(), FloatSize(viewport_size)), + return MakeMapBetweenRects(FloatRect(gfx::PointF(), FloatSize(viewport_size)), target_rect); } @@ -111,7 +111,7 @@ return dest_rect; } if (image_) { - FloatRect src_rect = FloatRect(FloatPoint(), FloatSize(image_->Size())); + FloatRect src_rect = FloatRect(gfx::PointF(), FloatSize(image_->Size())); preserve_aspect_ratio_->TransformRect(dest_rect, src_rect); return dest_rect; } @@ -199,7 +199,7 @@ if (PaintImage image = image_ ? image_->PaintImageForCurrentFrame() : PaintImage()) { - FloatRect src_rect = FloatRect(FloatPoint(), FloatSize(image_->Size())); + FloatRect src_rect = FloatRect(gfx::PointF(), FloatSize(image_->Size())); FloatRect dst_rect = GetFilter()->MapLocalRectToAbsoluteRect(FilterPrimitiveSubregion()); preserve_aspect_ratio_->TransformRect(dst_rect, src_rect);
diff --git a/third_party/blink/renderer/core/svg/graphics/svg_image.cc b/third_party/blink/renderer/core/svg/graphics/svg_image.cc index d5f2c34..61edc2e 100644 --- a/third_party/blink/renderer/core/svg/graphics/svg_image.cc +++ b/third_party/blink/renderer/core/svg/graphics/svg_image.cc
@@ -463,7 +463,7 @@ const IntRect dest_rect(gfx::Point(), RoundedIntSize(size)); cc::PaintCanvas* canvas = recorder.beginRecording(dest_rect); DrawForContainer(draw_info, canvas, PaintFlags(), FloatRect(dest_rect), - FloatRect(FloatPoint(), size)); + FloatRect(gfx::PointF(), size)); builder.set_paint_record(recorder.finishRecordingAsPicture(), ToGfxRect(dest_rect), PaintImage::GetNextContentId()); @@ -483,7 +483,7 @@ if (!record) return false; - const FloatRect bounds(FloatPoint(), draw_info.ContainerSize()); + const FloatRect bounds(gfx::PointF(), draw_info.ContainerSize()); flags.setShader(PaintShader::MakePaintRecord( std::move(record), bounds, SkTileMode::kClamp, SkTileMode::kClamp, &local_matrix));
diff --git a/third_party/blink/renderer/core/svg/graphics/svg_image.h b/third_party/blink/renderer/core/svg/graphics/svg_image.h index dc67907..267d91b 100644 --- a/third_party/blink/renderer/core/svg/graphics/svg_image.h +++ b/third_party/blink/renderer/core/svg/graphics/svg_image.h
@@ -90,8 +90,8 @@ void AdvanceAnimationForTesting() override; SVGImageChromeClient& ChromeClientForTesting(); - static FloatPoint OffsetForCurrentFrame(const FloatRect& dst_rect, - const FloatRect& src_rect); + static gfx::PointF OffsetForCurrentFrame(const FloatRect& dst_rect, + const FloatRect& src_rect); // Service CSS and SMIL animations. void ServiceAnimations(base::TimeTicks monotonic_animation_start_time);
diff --git a/third_party/blink/renderer/core/svg/svg_animate_motion_element.cc b/third_party/blink/renderer/core/svg/svg_animate_motion_element.cc index e272ddad..090b86f 100644 --- a/third_party/blink/renderer/core/svg/svg_animate_motion_element.cc +++ b/third_party/blink/renderer/core/svg/svg_animate_motion_element.cc
@@ -127,7 +127,7 @@ template <typename CharType> static bool ParsePointInternal(const CharType* ptr, const CharType* end, - FloatPoint& point) { + gfx::PointF& point) { if (!SkipOptionalSVGSpaces(ptr, end)) return false; @@ -139,13 +139,13 @@ if (!ParseNumber(ptr, end, y)) return false; - point = FloatPoint(x, y); + point = gfx::PointF(x, y); // disallow anything except spaces at the end return !SkipOptionalSVGSpaces(ptr, end); } -static bool ParsePoint(const String& string, FloatPoint& point) { +static bool ParsePoint(const String& string, gfx::PointF& point) { if (string.IsEmpty()) return false; return WTF::VisitCharacters(string, [&](const auto* chars, unsigned length) { @@ -189,7 +189,7 @@ // Apply 'from' to 'to' to get 'by' semantics. If the animation mode // is 'by', |from_string| will be the empty string and yield a point // of (0,0). - to_point_ += from_point_; + to_point_ += from_point_.OffsetFromOrigin(); to_point_at_end_of_duration_ = to_point_; return true; } @@ -249,13 +249,13 @@ float SVGAnimateMotionElement::CalculateDistance(const String& from_string, const String& to_string) { - FloatPoint from; - FloatPoint to; + gfx::PointF from; + gfx::PointF to; if (!ParsePoint(from_string, from)) return -1; if (!ParsePoint(to_string, to)) return -1; - return (to - from).DiagonalLength(); + return (to - from).Length(); } void SVGAnimateMotionElement::UpdateAnimationMode() {
diff --git a/third_party/blink/renderer/core/svg/svg_animate_motion_element.h b/third_party/blink/renderer/core/svg/svg_animate_motion_element.h index f2aa2082..df9e760 100644 --- a/third_party/blink/renderer/core/svg/svg_animate_motion_element.h +++ b/third_party/blink/renderer/core/svg/svg_animate_motion_element.h
@@ -64,9 +64,9 @@ // Note: we do not support percentage values for to/from coords as the spec // implies we should (opera doesn't either) - FloatPoint from_point_; - FloatPoint to_point_; - FloatPoint to_point_at_end_of_duration_; + gfx::PointF from_point_; + gfx::PointF to_point_; + gfx::PointF to_point_at_end_of_duration_; Path path_; Path animation_path_;
diff --git a/third_party/blink/renderer/core/svg/svg_document_extensions.cc b/third_party/blink/renderer/core/svg/svg_document_extensions.cc index b3da61a..f583f91 100644 --- a/third_party/blink/renderer/core/svg/svg_document_extensions.cc +++ b/third_party/blink/renderer/core/svg/svg_document_extensions.cc
@@ -154,14 +154,14 @@ return !svg || svg->ZoomAndPanEnabled(); } -void SVGDocumentExtensions::StartPan(const FloatPoint& start) { +void SVGDocumentExtensions::StartPan(const gfx::PointF& start) { if (SVGSVGElement* svg = rootElement(*document_)) { translate_ = gfx::Vector2dF(start.x() - svg->CurrentTranslate().x(), start.y() - svg->CurrentTranslate().y()); } } -void SVGDocumentExtensions::UpdatePan(const FloatPoint& pos) const { +void SVGDocumentExtensions::UpdatePan(const gfx::PointF& pos) const { if (SVGSVGElement* svg = rootElement(*document_)) { svg->SetCurrentTranslate( gfx::Vector2dF(pos.x() - translate_.x(), pos.y() - translate_.y()));
diff --git a/third_party/blink/renderer/core/svg/svg_document_extensions.h b/third_party/blink/renderer/core/svg/svg_document_extensions.h index 6a298d0..3e632cc 100644 --- a/third_party/blink/renderer/core/svg/svg_document_extensions.h +++ b/third_party/blink/renderer/core/svg/svg_document_extensions.h
@@ -23,10 +23,10 @@ #include "base/dcheck_is_on.h" #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/hash_set.h" +#include "ui/gfx/geometry/point_f.h" #include "ui/gfx/geometry/vector2d_f.h" namespace blink { @@ -69,8 +69,8 @@ bool ZoomAndPanEnabled() const; - void StartPan(const FloatPoint& start); - void UpdatePan(const FloatPoint& pos) const; + void StartPan(const gfx::PointF& start); + void UpdatePan(const gfx::PointF& pos) const; static SVGSVGElement* rootElement(const Document&);
diff --git a/third_party/blink/renderer/core/svg/svg_length_context.cc b/third_party/blink/renderer/core/svg/svg_length_context.cc index 30de98b..c19ebc0 100644 --- a/third_party/blink/renderer/core/svg/svg_length_context.cc +++ b/third_party/blink/renderer/core/svg/svg_length_context.cc
@@ -190,20 +190,20 @@ width.Value(length_context), height.Value(length_context)); } -FloatPoint SVGLengthContext::ResolvePoint(const SVGElement* context, - SVGUnitTypes::SVGUnitType type, - const SVGLength& x, - const SVGLength& y) { +gfx::PointF SVGLengthContext::ResolvePoint(const SVGElement* context, + SVGUnitTypes::SVGUnitType type, + const SVGLength& x, + const SVGLength& y) { DCHECK_NE(SVGUnitTypes::kSvgUnitTypeUnknown, type); if (type == SVGUnitTypes::kSvgUnitTypeUserspaceonuse) { SVGLengthContext length_context(context); - return FloatPoint(x.Value(length_context), y.Value(length_context)); + return gfx::PointF(x.Value(length_context), y.Value(length_context)); } // FIXME: valueAsPercentage() won't be correct for eg. cm units. They need to // be resolved in user space and then be considered in objectBoundingBox // space. - return FloatPoint(x.ValueAsPercentage(), y.ValueAsPercentage()); + return gfx::PointF(x.ValueAsPercentage(), y.ValueAsPercentage()); } gfx::Vector2dF SVGLengthContext::ResolveLengthPair(
diff --git a/third_party/blink/renderer/core/svg/svg_length_context.h b/third_party/blink/renderer/core/svg/svg_length_context.h index 8fc152f20..8b8faa5 100644 --- a/third_party/blink/renderer/core/svg/svg_length_context.h +++ b/third_party/blink/renderer/core/svg/svg_length_context.h
@@ -63,10 +63,10 @@ const SVGLength& y, const SVGLength& width, const SVGLength& height); - static FloatPoint ResolvePoint(const SVGElement*, - SVGUnitTypes::SVGUnitType, - const SVGLength& x, - const SVGLength& y); + static gfx::PointF ResolvePoint(const SVGElement*, + SVGUnitTypes::SVGUnitType, + const SVGLength& x, + const SVGLength& y); static float ResolveLength(const SVGElement*, SVGUnitTypes::SVGUnitType, const SVGLength&);
diff --git a/third_party/blink/renderer/core/svg/svg_path_parser.h b/third_party/blink/renderer/core/svg/svg_path_parser.h index 9c32f3e..590d78a6 100644 --- a/third_party/blink/renderer/core/svg/svg_path_parser.h +++ b/third_party/blink/renderer/core/svg/svg_path_parser.h
@@ -26,8 +26,8 @@ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/svg/svg_path_data.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "ui/gfx/geometry/point_f.h" namespace blink {
diff --git a/third_party/blink/renderer/core/svg/svg_path_string_source.cc b/third_party/blink/renderer/core/svg/svg_path_string_source.cc index b147b83..d36fafb 100644 --- a/third_party/blink/renderer/core/svg/svg_path_string_source.cc +++ b/third_party/blink/renderer/core/svg/svg_path_string_source.cc
@@ -20,8 +20,9 @@ #include "third_party/blink/renderer/core/svg/svg_path_string_source.h" +#include "base/notreached.h" #include "third_party/blink/renderer/core/svg/svg_parser_utilities.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" +#include "ui/gfx/geometry/point_f.h" namespace blink {
diff --git a/third_party/blink/renderer/core/svg/svg_point_list.cc b/third_party/blink/renderer/core/svg/svg_point_list.cc index 85a1536..b0917cb 100644 --- a/third_party/blink/renderer/core/svg/svg_point_list.cc +++ b/third_party/blink/renderer/core/svg/svg_point_list.cc
@@ -22,10 +22,10 @@ #include "third_party/blink/renderer/core/svg/animation/smil_animation_effect_parameters.h" #include "third_party/blink/renderer/core/svg/svg_parser_utilities.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/wtf/text/character_visitor.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" +#include "ui/gfx/geometry/point_f.h" namespace blink {
diff --git a/third_party/blink/renderer/core/svg/svg_transform.cc b/third_party/blink/renderer/core/svg/svg_transform.cc index bb0b8cb..f632b85 100644 --- a/third_party/blink/renderer/core/svg/svg_transform.cc +++ b/third_party/blink/renderer/core/svg/svg_transform.cc
@@ -42,7 +42,7 @@ SVGTransform::SVGTransform(SVGTransformType transform_type, float angle, - const FloatPoint& center, + const gfx::PointF& center, const AffineTransform& matrix) : transform_type_(transform_type), angle_(angle), @@ -80,14 +80,14 @@ matrix_.Translate(tx, ty); } -FloatPoint SVGTransform::Translate() const { - return FloatPoint::NarrowPrecision(matrix_.E(), matrix_.F()); +gfx::PointF SVGTransform::Translate() const { + return gfx::PointF(ClampTo<float>(matrix_.E()), ClampTo<float>(matrix_.F())); } void SVGTransform::SetScale(float sx, float sy) { transform_type_ = SVGTransformType::kScale; angle_ = 0; - center_ = FloatPoint(); + center_ = gfx::PointF(); matrix_.MakeIdentity(); matrix_.ScaleNonUniform(sx, sy); @@ -100,7 +100,7 @@ void SVGTransform::SetRotate(float angle, float cx, float cy) { transform_type_ = SVGTransformType::kRotate; angle_ = angle; - center_ = FloatPoint(cx, cy); + center_ = gfx::PointF(cx, cy); // TODO: toString() implementation, which can show cx, cy (need to be stored?) matrix_.MakeIdentity();
diff --git a/third_party/blink/renderer/core/svg/svg_transform.h b/third_party/blink/renderer/core/svg/svg_transform.h index 2e2c9fd..a46ee7d 100644 --- a/third_party/blink/renderer/core/svg/svg_transform.h +++ b/third_party/blink/renderer/core/svg/svg_transform.h
@@ -22,10 +22,10 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_TRANSFORM_H_ #include "third_party/blink/renderer/core/svg/properties/svg_listable_property.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/transforms/affine_transform.h" #include "third_party/blink/renderer/platform/wtf/casting.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -57,7 +57,7 @@ explicit SVGTransform(const AffineTransform&); SVGTransform(SVGTransformType, float, - const FloatPoint&, + const gfx::PointF&, const AffineTransform&); ~SVGTransform() override; @@ -73,7 +73,7 @@ void OnMatrixChange(); float Angle() const { return angle_; } - FloatPoint RotationCenter() const { return center_; } + gfx::PointF RotationCenter() const { return center_; } void SetMatrix(const AffineTransform&); void SetTranslate(float tx, float ty); @@ -83,7 +83,7 @@ void SetSkewY(float angle); // Internal use only (animation system) - FloatPoint Translate() const; + gfx::PointF Translate() const; FloatSize Scale() const; String ValueAsString() const override; @@ -106,7 +106,7 @@ private: SVGTransformType transform_type_; float angle_; - FloatPoint center_; + gfx::PointF center_; AffineTransform matrix_; };
diff --git a/third_party/blink/renderer/core/svg/svg_transform_distance.cc b/third_party/blink/renderer/core/svg/svg_transform_distance.cc index 29686ca..d9c24ed 100644 --- a/third_party/blink/renderer/core/svg/svg_transform_distance.cc +++ b/third_party/blink/renderer/core/svg/svg_transform_distance.cc
@@ -21,9 +21,9 @@ #include <math.h> -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/heap/heap.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -55,18 +55,17 @@ case SVGTransformType::kUnknown: break; case SVGTransformType::kRotate: { - FloatSize center_distance = to_svg_transform->RotationCenter() - - from_svg_transform->RotationCenter(); + gfx::Vector2dF center_distance = to_svg_transform->RotationCenter() - + from_svg_transform->RotationCenter(); angle_ = to_svg_transform->Angle() - from_svg_transform->Angle(); - cx_ = center_distance.width(); - cy_ = center_distance.height(); + cx_ = center_distance.x(); + cy_ = center_distance.y(); break; } case SVGTransformType::kTranslate: { - FloatSize translation_distance = + gfx::Vector2dF translation_distance = to_svg_transform->Translate() - from_svg_transform->Translate(); - transform_.Translate(translation_distance.width(), - translation_distance.height()); + transform_.Translate(translation_distance.x(), translation_distance.y()); break; } case SVGTransformType::kScale: { @@ -178,8 +177,9 @@ case SVGTransformType::kUnknown: return MakeGarbageCollected<SVGTransform>(); case SVGTransformType::kTranslate: { - FloatPoint translation = transform->Translate(); - translation += FloatSize::NarrowPrecision(transform_.E(), transform_.F()); + gfx::PointF translation = transform->Translate(); + translation += gfx::Vector2dF(ClampTo<float>(transform_.E()), + ClampTo<float>(transform_.F())); new_transform->SetTranslate(translation.x(), translation.y()); return new_transform; } @@ -190,7 +190,7 @@ return new_transform; } case SVGTransformType::kRotate: { - FloatPoint center = transform->RotationCenter(); + gfx::PointF center = transform->RotationCenter(); new_transform->SetRotate(transform->Angle() + angle_, center.x() + cx_, center.y() + cy_); return new_transform;
diff --git a/third_party/blink/renderer/core/svg/svg_transform_list.cc b/third_party/blink/renderer/core/svg/svg_transform_list.cc index 6989abb..aa47d726 100644 --- a/third_party/blink/renderer/core/svg/svg_transform_list.cc +++ b/third_party/blink/renderer/core/svg/svg_transform_list.cc
@@ -213,8 +213,8 @@ case CSSValueID::kRotate: { transform_value->Append(*CSSNumericLiteralValue::Create( transform.Angle(), CSSPrimitiveValue::UnitType::kDegrees)); - FloatPoint rotation_origin = transform.RotationCenter(); - if (!ToFloatSize(rotation_origin).IsZero()) { + gfx::PointF rotation_origin = transform.RotationCenter(); + if (!rotation_origin.IsOrigin()) { transform_value->Append(*CSSNumericLiteralValue::Create( rotation_origin.x(), CSSPrimitiveValue::UnitType::kUserUnits)); transform_value->Append(*CSSNumericLiteralValue::Create(
diff --git a/third_party/blink/renderer/core/testing/internals.cc b/third_party/blink/renderer/core/testing/internals.cc index 940e911..ee21f344 100644 --- a/third_party/blink/renderer/core/testing/internals.cc +++ b/third_party/blink/renderer/core/testing/internals.cc
@@ -2234,8 +2234,9 @@ layer->touch_action_region(); if (!touch_action_region.GetAllRegions().IsEmpty()) { const auto& offset = layer->offset_to_transform_parent(); - IntRect layer_rect(RoundedIntPoint(FloatPoint(offset.x(), offset.y())), - IntSize(layer->bounds())); + IntRect layer_rect( + gfx::ToRoundedPoint(gfx::PointAtOffsetFromOrigin(offset)), + IntSize(layer->bounds())); Vector<IntRect> layer_hit_test_rects; for (auto hit_test_rect : touch_action_region.GetAllRegions()) @@ -3553,14 +3554,13 @@ void Internals::setVisualViewportOffset(int x, int y) { if (!GetFrame()) return; - FloatPoint offset(x, y); + gfx::PointF offset(x, y); // `setVisualViewportOffset()` inputs are in physical pixels, but // `SetLocation()` gets positions in DIPs when --use-zoom-for-dsf disabled. - GetFrame()->GetPage()->GetVisualViewport().SetLocation( - Platform::Current()->IsUseZoomForDSFEnabled() - ? offset - : offset.ScaledBy(1 / GetFrame()->DevicePixelRatio())); + if (!Platform::Current()->IsUseZoomForDSFEnabled()) + offset.Scale(1 / GetFrame()->DevicePixelRatio()); + GetFrame()->GetPage()->GetVisualViewport().SetLocation(offset); } bool Internals::isUseCounted(Document* document, uint32_t feature) {
diff --git a/third_party/blink/renderer/modules/accessibility/ax_inline_text_box.cc b/third_party/blink/renderer/modules/accessibility/ax_inline_text_box.cc index e936a8a..4fa25cf 100644 --- a/third_party/blink/renderer/modules/accessibility/ax_inline_text_box.cc +++ b/third_party/blink/renderer/modules/accessibility/ax_inline_text_box.cc
@@ -76,7 +76,7 @@ // both in the same coordinate system. FloatRect parent_bounding_box = ParentObject()->LocalBoundingBoxRectForAccessibility(); - out_bounds_in_container.MoveBy(-parent_bounding_box.origin()); + out_bounds_in_container.Offset(-parent_bounding_box.OffsetFromOrigin()); } bool AXInlineTextBox::ComputeAccessibilityIsIgnored(
diff --git a/third_party/blink/renderer/modules/accessibility/ax_layout_object.cc b/third_party/blink/renderer/modules/accessibility/ax_layout_object.cc index 3fb299c..6d8ddea0 100644 --- a/third_party/blink/renderer/modules/accessibility/ax_layout_object.cc +++ b/third_party/blink/renderer/modules/accessibility/ax_layout_object.cc
@@ -1753,7 +1753,7 @@ return nullptr; for (const auto& child : parent->ChildrenIncludingIgnored()) { - if (child->GetBoundsInFrameCoordinates().Contains(point)) + if (child->GetBoundsInFrameCoordinates().Contains(LayoutPoint(point))) return child.Get(); }
diff --git a/third_party/blink/renderer/modules/accessibility/ax_object.cc b/third_party/blink/renderer/modules/accessibility/ax_object.cc index 92a1396..0b53b187b 100644 --- a/third_party/blink/renderer/modules/accessibility/ax_object.cc +++ b/third_party/blink/renderer/modules/accessibility/ax_object.cc
@@ -4297,7 +4297,7 @@ // Check if there are any mock elements that need to be handled. for (const auto& child : ChildrenIncludingIgnored()) { if (child->IsMockObject() && - child->GetBoundsInFrameCoordinates().Contains(point)) + child->GetBoundsInFrameCoordinates().Contains(LayoutPoint(point))) return child->ElementAccessibilityHitTest(point); } @@ -5288,8 +5288,8 @@ view->GetPage()->GetChromeClient().WindowToViewportScalar( layout_object->GetFrame(), 1.0f); out_bounds_in_container.set_origin( - FloatPoint(scale_factor * (frame_rect.x() - root_frame_rect.x()), - scale_factor * (frame_rect.y() - root_frame_rect.y()))); + gfx::PointF(scale_factor * (frame_rect.x() - root_frame_rect.x()), + scale_factor * (frame_rect.y() - root_frame_rect.y()))); } } return;
diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc b/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc index 2b854ce5..f0e0e0a 100644 --- a/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc +++ b/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc
@@ -601,13 +601,13 @@ } double BaseRenderingContext2D::shadowOffsetX() const { - return GetState().ShadowOffset().width(); + return GetState().ShadowOffset().x(); } void BaseRenderingContext2D::setShadowOffsetX(double x) { if (!std::isfinite(x)) return; - if (GetState().ShadowOffset().width() == x) + if (GetState().ShadowOffset().x() == x) return; if (identifiability_study_helper_.ShouldUpdateBuilder()) { identifiability_study_helper_.UpdateBuilder(CanvasOps::kSetShadowOffsetX, @@ -617,13 +617,13 @@ } double BaseRenderingContext2D::shadowOffsetY() const { - return GetState().ShadowOffset().height(); + return GetState().ShadowOffset().y(); } void BaseRenderingContext2D::setShadowOffsetY(double y) { if (!std::isfinite(y)) return; - if (GetState().ShadowOffset().height() == y) + if (GetState().ShadowOffset().y() == y) return; if (identifiability_study_helper_.ShouldUpdateBuilder()) { identifiability_study_helper_.UpdateBuilder(CanvasOps::kSetShadowOffsetY, @@ -1361,9 +1361,9 @@ // Compute the src to dst transform FloatSize scale(dst_rect->size().width() / src_rect->size().width(), dst_rect->size().height() / src_rect->size().height()); - FloatPoint scaled_src_location = src_rect->origin(); + gfx::PointF scaled_src_location = src_rect->origin(); scaled_src_location.Scale(scale.width(), scale.height()); - FloatSize offset = dst_rect->origin() - scaled_src_location; + gfx::Vector2dF offset = dst_rect->origin() - scaled_src_location; src_rect->Intersect(image_rect); @@ -1670,7 +1670,7 @@ FloatSize image_size = image_source->ElementSize( default_object_size, RespectImageOrientationInternal(image_source)); - ClipRectsToImageRect(FloatRect(FloatPoint(), image_size), &src_rect, + ClipRectsToImageRect(FloatRect(gfx::PointF(), image_size), &src_rect, &dst_rect); if (src_rect.IsEmpty()) @@ -1739,8 +1739,8 @@ float fx1 = ClampTo<float>(x1); float fy1 = ClampTo<float>(y1); - auto* gradient = MakeGarbageCollected<CanvasGradient>(FloatPoint(fx0, fy0), - FloatPoint(fx1, fy1)); + auto* gradient = MakeGarbageCollected<CanvasGradient>(gfx::PointF(fx0, fy0), + gfx::PointF(fx1, fy1)); gradient->SetExecutionContext( identifiability_study_helper_.execution_context()); return gradient; @@ -1775,7 +1775,7 @@ float fr1 = ClampTo<float>(r1); auto* gradient = MakeGarbageCollected<CanvasGradient>( - FloatPoint(fx0, fy0), fr0, FloatPoint(fx1, fy1), fr1); + gfx::PointF(fx0, fy0), fr0, gfx::PointF(fx1, fy1), fr1); gradient->SetExecutionContext( identifiability_study_helper_.execution_context()); return gradient; @@ -1801,7 +1801,7 @@ // |startAngle| at 0 starts from x-axis. a = Rad2deg(a) + 90; - auto* gradient = MakeGarbageCollected<CanvasGradient>(a, FloatPoint(x, y)); + auto* gradient = MakeGarbageCollected<CanvasGradient>(a, gfx::PointF(x, y)); gradient->SetExecutionContext( identifiability_study_helper_.execution_context()); return gradient;
diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_gradient.cc b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_gradient.cc index 93f7e41..20c838da 100644 --- a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_gradient.cc +++ b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_gradient.cc
@@ -32,7 +32,7 @@ namespace blink { -CanvasGradient::CanvasGradient(const FloatPoint& p0, const FloatPoint& p1) +CanvasGradient::CanvasGradient(const gfx::PointF& p0, const gfx::PointF& p1) : gradient_( Gradient::CreateLinear(p0, p1, @@ -45,9 +45,9 @@ } } -CanvasGradient::CanvasGradient(const FloatPoint& p0, +CanvasGradient::CanvasGradient(const gfx::PointF& p0, float r0, - const FloatPoint& p1, + const gfx::PointF& p1, float r1) : gradient_( Gradient::CreateRadial(p0, @@ -67,7 +67,7 @@ // CanvasRenderingContext2D.createConicGradient only takes one angle argument // it makes sense to make that rotation here and always make the angles 0 -> 2pi -CanvasGradient::CanvasGradient(float startAngle, const FloatPoint& center) +CanvasGradient::CanvasGradient(float startAngle, const gfx::PointF& center) : gradient_( Gradient::CreateConic(center, startAngle,
diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_gradient.h b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_gradient.h index 7d8c53b..25f07d1 100644 --- a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_gradient.h +++ b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_gradient.h
@@ -43,14 +43,14 @@ public: // Linear Gradient - CanvasGradient(const FloatPoint& p0, const FloatPoint& p1); + CanvasGradient(const gfx::PointF& p0, const gfx::PointF& p1); // Radial Gradient - CanvasGradient(const FloatPoint& p0, + CanvasGradient(const gfx::PointF& p0, float r0, - const FloatPoint& p1, + const gfx::PointF& p1, float r1); // Conic Gradient - CanvasGradient(float startAngle, const FloatPoint& center); + CanvasGradient(float startAngle, const gfx::PointF& center); Gradient* GetGradient() const { return gradient_.get(); }
diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_path.cc b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_path.cc index b003cc5..510bdcef 100644 --- a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_path.cc +++ b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_path.cc
@@ -48,7 +48,7 @@ namespace blink { // TODO(crbug.com/940846): Consider using double-type without casting and -// DoublePoint & DoubleRect instead of FloatPoint & FloatRect. +// DoublePoint & DoubleRect instead of gfx::PointF & FloatRect. void CanvasPath::closePath() { if (UNLIKELY(path_.IsEmpty())) @@ -253,14 +253,14 @@ return new_end_angle; } -inline void LineToFloatPoint(CanvasPath* path, const FloatPoint& p) { +inline void LineTo(CanvasPath* path, const gfx::PointF& p) { path->lineTo(p.x(), p.y()); } -inline FloatPoint GetPointOnEllipse(float radius_x, - float radius_y, - float theta) { - return FloatPoint(radius_x * cosf(theta), radius_y * sinf(theta)); +inline gfx::PointF GetPointOnEllipse(float radius_x, + float radius_y, + float theta) { + return gfx::PointF(radius_x * cosf(theta), radius_y * sinf(theta)); } void CanonicalizeAngle(float* start_angle, float* end_angle) { @@ -331,14 +331,16 @@ DCHECK((anticlockwise && (start_angle - end_angle) >= 0) || (!anticlockwise && (end_angle - start_angle) >= 0)); - FloatPoint center(x, y); + gfx::PointF center(x, y); AffineTransform rotation_matrix; rotation_matrix.RotateRadians(rotation); // First, if the object's path has any subpaths, then the method must add a // straight line from the last point in the subpath to the start point of the // arc. - LineToFloatPoint(path, center + rotation_matrix.MapPoint(GetPointOnEllipse( - radius_x, radius_y, start_angle))); + LineTo(path, center + rotation_matrix + .MapPoint(GetPointOnEllipse(radius_x, radius_y, + start_angle)) + .OffsetFromOrigin()); if (UNLIKELY((!radius_x && !radius_y) || start_angle == end_angle)) return; @@ -349,21 +351,25 @@ for (float angle = start_angle - fmodf(start_angle, kPiOverTwoFloat) + kPiOverTwoFloat; angle < end_angle; angle += kPiOverTwoFloat) { - LineToFloatPoint( - path, center + rotation_matrix.MapPoint( - GetPointOnEllipse(radius_x, radius_y, angle))); + LineTo(path, center + rotation_matrix + .MapPoint(GetPointOnEllipse(radius_x, radius_y, + angle)) + .OffsetFromOrigin()); } } else { for (float angle = start_angle - fmodf(start_angle, kPiOverTwoFloat); angle > end_angle; angle -= kPiOverTwoFloat) { - LineToFloatPoint( - path, center + rotation_matrix.MapPoint( - GetPointOnEllipse(radius_x, radius_y, angle))); + LineTo(path, center + rotation_matrix + .MapPoint(GetPointOnEllipse(radius_x, radius_y, + angle)) + .OffsetFromOrigin()); } } - LineToFloatPoint(path, center + rotation_matrix.MapPoint(GetPointOnEllipse( - radius_x, radius_y, end_angle))); + LineTo(path, center + rotation_matrix + .MapPoint(GetPointOnEllipse(radius_x, radius_y, + end_angle)) + .OffsetFromOrigin()); } } // namespace
diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.cc b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.cc index 9fb81ee..264fe27 100644 --- a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.cc +++ b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.cc
@@ -1009,8 +1009,8 @@ bidi_override); text_run.SetNormalizeSpace(true); // Draw the item text at the correct point. - FloatPoint location(ClampTo<float>(x), - ClampTo<float>(y + GetFontBaseline(*font_data))); + gfx::PointF location(ClampTo<float>(x), + ClampTo<float>(y + GetFontBaseline(*font_data))); double font_width = font.Width(text_run); bool use_max_width = (max_width && *max_width < font_width);
diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_state.cc b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_state.cc index 27588ba..57ab079 100644 --- a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_state.cc +++ b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_state.cc
@@ -383,7 +383,7 @@ stroke_flags_for_filter.setColor(stroke_style_->PaintColor()); FilterEffectBuilder filter_effect_builder( - FloatRect((FloatPoint()), FloatSize(canvas_size)), + FloatRect((gfx::PointF()), FloatSize(canvas_size)), 1.0f, // Deliberately ignore zoom on the canvas element. &fill_flags_for_filter, &stroke_flags_for_filter); @@ -455,7 +455,7 @@ stroke_flags_for_filter.setColor(stroke_style_->PaintColor()); FilterEffectBuilder filter_effect_builder( - FloatRect((FloatPoint()), FloatSize(canvas_size)), + FloatRect((gfx::PointF()), FloatSize(canvas_size)), 1.0f, // Deliberately ignore zoom on the canvas element. &fill_flags_for_filter, &stroke_flags_for_filter); @@ -525,8 +525,8 @@ if (!shadow_only_image_filter_) { const auto sigma = BlurRadiusToStdDev(shadow_blur_); shadow_only_image_filter_ = sk_make_sp<DropShadowPaintFilter>( - shadow_offset_.width(), shadow_offset_.height(), sigma, sigma, - shadow_color_, ShadowMode::kDrawShadowOnly, nullptr); + shadow_offset_.x(), shadow_offset_.y(), sigma, sigma, shadow_color_, + ShadowMode::kDrawShadowOnly, nullptr); } return shadow_only_image_filter_; } @@ -537,8 +537,8 @@ if (!shadow_and_foreground_image_filter_) { const auto sigma = BlurRadiusToStdDev(shadow_blur_); shadow_and_foreground_image_filter_ = sk_make_sp<DropShadowPaintFilter>( - shadow_offset_.width(), shadow_offset_.height(), sigma, sigma, - shadow_color_, ShadowMode::kDrawShadowAndForeground, nullptr); + shadow_offset_.x(), shadow_offset_.y(), sigma, sigma, shadow_color_, + ShadowMode::kDrawShadowAndForeground, nullptr); } return shadow_and_foreground_image_filter_; } @@ -551,12 +551,12 @@ } void CanvasRenderingContext2DState::SetShadowOffsetX(double x) { - shadow_offset_.set_width(ClampTo<float>(x)); + shadow_offset_.set_x(ClampTo<float>(x)); ShadowParameterChanged(); } void CanvasRenderingContext2DState::SetShadowOffsetY(double y) { - shadow_offset_.set_height(ClampTo<float>(y)); + shadow_offset_.set_y(ClampTo<float>(y)); ShadowParameterChanged(); }
diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_state.h b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_state.h index e182cd3..12ffa936 100644 --- a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_state.h +++ b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_state.h
@@ -206,7 +206,7 @@ void SetShadowOffsetX(double); void SetShadowOffsetY(double); - const FloatSize& ShadowOffset() const { return shadow_offset_; } + const gfx::Vector2dF& ShadowOffset() const { return shadow_offset_; } void SetShadowBlur(double); double ShadowBlur() const { return shadow_blur_; } @@ -266,7 +266,7 @@ mutable PaintFlags fill_flags_; mutable PaintFlags image_flags_; - FloatSize shadow_offset_; + gfx::Vector2dF shadow_offset_; double shadow_blur_; SkColor shadow_color_; mutable sk_sp<SkDrawLooper> empty_draw_looper_;
diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_test.cc b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_test.cc index 9c368d3..a46d3e1 100644 --- a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_test.cc +++ b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_test.cc
@@ -260,8 +260,8 @@ partial_image_data_ = ImageData::Create(2, 2, settings, ASSERT_NO_EXCEPTION); NonThrowableExceptionState exception_state; - auto* opaque_gradient = - MakeGarbageCollected<CanvasGradient>(FloatPoint(0, 0), FloatPoint(10, 0)); + auto* opaque_gradient = MakeGarbageCollected<CanvasGradient>( + gfx::PointF(0, 0), gfx::PointF(10, 0)); opaque_gradient->addColorStop(0, String("green"), exception_state); EXPECT_FALSE(exception_state.HadException()); opaque_gradient->addColorStop(1, String("blue"), exception_state); @@ -270,8 +270,8 @@ V8UnionCSSColorValueOrCanvasGradientOrCanvasPatternOrString>( opaque_gradient); - auto* alpha_gradient = - MakeGarbageCollected<CanvasGradient>(FloatPoint(0, 0), FloatPoint(10, 0)); + auto* alpha_gradient = MakeGarbageCollected<CanvasGradient>( + gfx::PointF(0, 0), gfx::PointF(10, 0)); alpha_gradient->addColorStop(0, String("green"), exception_state); EXPECT_FALSE(exception_state.HadException()); alpha_gradient->addColorStop(1, String("rgba(0, 0, 255, 0.5)"),
diff --git a/third_party/blink/renderer/modules/canvas/imagebitmap/image_bitmap_rendering_context_base.cc b/third_party/blink/renderer/modules/canvas/imagebitmap/image_bitmap_rendering_context_base.cc index e67e5e8..a9677aa 100644 --- a/third_party/blink/renderer/modules/canvas/imagebitmap/image_bitmap_rendering_context_base.cc +++ b/third_party/blink/renderer/modules/canvas/imagebitmap/image_bitmap_rendering_context_base.cc
@@ -84,8 +84,8 @@ return copy_image; } -void ImageBitmapRenderingContextBase::SetUV(const FloatPoint& left_top, - const FloatPoint& right_bottom) { +void ImageBitmapRenderingContextBase::SetUV(const gfx::PointF& left_top, + const gfx::PointF& right_bottom) { image_layer_bridge_->SetUV(left_top, right_bottom); }
diff --git a/third_party/blink/renderer/modules/canvas/imagebitmap/image_bitmap_rendering_context_base.h b/third_party/blink/renderer/modules/canvas/imagebitmap/image_bitmap_rendering_context_base.h index 514ddfa..efbb8b58 100644 --- a/third_party/blink/renderer/modules/canvas/imagebitmap/image_bitmap_rendering_context_base.h +++ b/third_party/blink/renderer/modules/canvas/imagebitmap/image_bitmap_rendering_context_base.h
@@ -9,7 +9,7 @@ #include "third_party/blink/renderer/core/html/canvas/canvas_rendering_context.h" #include "third_party/blink/renderer/core/html/canvas/canvas_rendering_context_factory.h" #include "third_party/blink/renderer/modules/modules_export.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" +#include "ui/gfx/geometry/point_f.h" namespace cc { class Layer; @@ -48,7 +48,7 @@ void SetImage(ImageBitmap*); scoped_refptr<StaticBitmapImage> GetImage() final; - void SetUV(const FloatPoint& left_top, const FloatPoint& right_bottom); + void SetUV(const gfx::PointF& left_top, const gfx::PointF& right_bottom); bool IsComposited() const final { return true; } bool IsAccelerated() const final; bool PushFrame() override;
diff --git a/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.cc b/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.cc index 0f134ef..902fe54 100644 --- a/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.cc +++ b/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.cc
@@ -681,7 +681,7 @@ false); text_run.SetNormalizeSpace(true); // Draw the item text at the correct point. - FloatPoint location(x, y + GetFontBaseline(*font_data)); + gfx::PointF location(x, y + GetFontBaseline(*font_data)); double font_width = font.Width(text_run); bool use_max_width = (max_width && *max_width < font_width); @@ -718,7 +718,7 @@ // We draw when fontWidth is 0 so compositing operations (eg, a "copy" op) // still work. paint_canvas->scale((font_width > 0 ? (width / font_width) : 0), 1); - location = FloatPoint(); + location = gfx::PointF(); } Draw<OverdrawOp::kNone>(
diff --git a/third_party/blink/renderer/modules/csspaint/nativepaint/clip_path_paint_definition.cc b/third_party/blink/renderer/modules/csspaint/nativepaint/clip_path_paint_definition.cc index 0730770..cd8f9f9 100644 --- a/third_party/blink/renderer/modules/csspaint/nativepaint/clip_path_paint_definition.cc +++ b/third_party/blink/renderer/modules/csspaint/nativepaint/clip_path_paint_definition.cc
@@ -270,7 +270,7 @@ ShapeClipPathOperation::Create(result_shape); Path path = current_shape->GetPath( - FloatRect(FloatPoint(0.0, 0.0), container_size), input->Zoom()); + FloatRect(gfx::PointF(0.0, 0.0), container_size), input->Zoom()); PaintRenderingContext2DSettings* context_settings = PaintRenderingContext2DSettings::Create(); auto* rendering_context = MakeGarbageCollected<PaintRenderingContext2D>(
diff --git a/third_party/blink/renderer/modules/delegated_ink/delegated_ink_trail_presenter.cc b/third_party/blink/renderer/modules/delegated_ink/delegated_ink_trail_presenter.cc index a9c6b8e..ae6bcda 100644 --- a/third_party/blink/renderer/modules/delegated_ink/delegated_ink_trail_presenter.cc +++ b/third_party/blink/renderer/modules/delegated_ink/delegated_ink_trail_presenter.cc
@@ -84,7 +84,7 @@ physical_point.Scale(effective_zoom); physical_point = layout_view->LocalToAbsolutePoint( physical_point, kTraverseDocumentBoundaries); - gfx::PointF point = ToGfxPointF(FloatPoint(physical_point)); + gfx::PointF point = gfx::PointF(physical_point); // Intersect with the visible viewport so that the presentation area can't // extend beyond the edges of the window or over the scrollbars. The frame
diff --git a/third_party/blink/renderer/modules/exported/web_ax_object.cc b/third_party/blink/renderer/modules/exported/web_ax_object.cc index 0e9fc8fb..61f18f82 100644 --- a/third_party/blink/renderer/modules/exported/web_ax_object.cc +++ b/third_party/blink/renderer/modules/exported/web_ax_object.cc
@@ -532,7 +532,8 @@ if (hit) return WebAXObject(hit); - if (private_->GetBoundsInFrameCoordinates().Contains(contents_point)) + if (private_->GetBoundsInFrameCoordinates().Contains( + LayoutPoint(contents_point))) return *this; return WebAXObject();
diff --git a/third_party/blink/renderer/modules/media_controls/media_controls_display_cutout_delegate_test.cc b/third_party/blink/renderer/modules/media_controls/media_controls_display_cutout_delegate_test.cc index 4940609..5eb6578 100644 --- a/third_party/blink/renderer/modules/media_controls/media_controls_display_cutout_delegate_test.cc +++ b/third_party/blink/renderer/modules/media_controls/media_controls_display_cutout_delegate_test.cc
@@ -154,8 +154,8 @@ Touch* CreateTouchAtPoint(int x, int y) { return Touch::Create(GetDocument().GetFrame(), &GetVideoElement(), - 1 /* identifier */, FloatPoint(x, y), FloatPoint(x, y), - FloatSize(1, 1), 90, 0); + 1 /* identifier */, gfx::PointF(x, y), + gfx::PointF(x, y), FloatSize(1, 1), 90, 0); } mojom::ViewportFit CurrentViewportFit() const {
diff --git a/third_party/blink/renderer/modules/remoteplayback/remote_playback.cc b/third_party/blink/renderer/modules/remoteplayback/remote_playback.cc index d2efc0a..296fff0 100644 --- a/third_party/blink/renderer/modules/remoteplayback/remote_playback.cc +++ b/third_party/blink/renderer/modules/remoteplayback/remote_playback.cc
@@ -206,6 +206,13 @@ return promise; } + if (!media_element_->DomWindow()) { + resolver->Reject(MakeGarbageCollected<DOMException>( + DOMExceptionCode::kInvalidAccessError, + "RemotePlayback::prompt() does not work in a detached window.")); + return promise; + } + if (!LocalFrame::HasTransientUserActivation( media_element_->DomWindow()->GetFrame())) { resolver->Reject(MakeGarbageCollected<DOMException>(
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_queue.cc b/third_party/blink/renderer/modules/webgpu/gpu_queue.cc index 3c321ae0..b43d69e 100644 --- a/third_party/blink/renderer/modules/webgpu/gpu_queue.cc +++ b/third_party/blink/renderer/modules/webgpu/gpu_queue.cc
@@ -144,10 +144,17 @@ // TODO(crbug.com/dawn/856): Cover more source formats if needed. if ((src_color_type == SkColorType::kRGBA_8888_SkColorType || src_color_type == SkColorType::kBGRA_8888_SkColorType) && - (dst_texture_format == WGPUTextureFormat_RG8Unorm || + (dst_texture_format == WGPUTextureFormat_R8Unorm || + dst_texture_format == WGPUTextureFormat_R16Float || + dst_texture_format == WGPUTextureFormat_R32Float || + dst_texture_format == WGPUTextureFormat_RG8Unorm || + dst_texture_format == WGPUTextureFormat_RG16Float || + dst_texture_format == WGPUTextureFormat_RG32Float || dst_texture_format == WGPUTextureFormat_RGBA8Unorm || dst_texture_format == WGPUTextureFormat_BGRA8Unorm || - dst_texture_format == WGPUTextureFormat_RGB10A2Unorm)) { + dst_texture_format == WGPUTextureFormat_RGB10A2Unorm || + dst_texture_format == WGPUTextureFormat_RGBA16Float || + dst_texture_format == WGPUTextureFormat_RGBA32Float)) { return true; }
diff --git a/third_party/blink/renderer/modules/xr/xr_input_source.cc b/third_party/blink/renderer/modules/xr/xr_input_source.cc index 80e24f4..32356d3 100644 --- a/third_party/blink/renderer/modules/xr/xr_input_source.cc +++ b/third_party/blink/renderer/modules/xr/xr_input_source.cc
@@ -496,9 +496,9 @@ // Do a hit test at the overlay pointer position to see if the pointer // intersects a cross origin iframe. If yes, set the visibility to false which // causes targetRaySpace and gripSpace to return null poses. - FloatPoint point(new_state->overlay_pointer_position->x(), - new_state->overlay_pointer_position->y()); - DVLOG(3) << __func__ << ": hit test point=" << point; + gfx::PointF point(new_state->overlay_pointer_position->x(), + new_state->overlay_pointer_position->y()); + DVLOG(3) << __func__ << ": hit test point=" << point.ToString(); HitTestRequest::HitTestRequestType hit_type = HitTestRequest::kTouchEvent | HitTestRequest::kReadOnly |
diff --git a/third_party/blink/renderer/modules/xr/xr_webgl_layer.cc b/third_party/blink/renderer/modules/xr/xr_webgl_layer.cc index 43d44f83..b9e33cd 100644 --- a/third_party/blink/renderer/modules/xr/xr_webgl_layer.cc +++ b/third_party/blink/renderer/modules/xr/xr_webgl_layer.cc
@@ -20,8 +20,8 @@ #include "third_party/blink/renderer/modules/xr/xr_viewport.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/geometry/double_size.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/int_size.h" +#include "ui/gfx/geometry/point_f.h" #include <algorithm>
diff --git a/third_party/blink/renderer/platform/BUILD.gn b/third_party/blink/renderer/platform/BUILD.gn index 82c0b99..e940ca5 100644 --- a/third_party/blink/renderer/platform/BUILD.gn +++ b/third_party/blink/renderer/platform/BUILD.gn
@@ -737,7 +737,6 @@ "geometry/calculation_expression_node.h", "geometry/calculation_value.cc", "geometry/calculation_value.h", - "geometry/cg/float_point_cg.cc", "geometry/cg/float_rect_cg.cc", "geometry/cg/float_size_cg.cc", "geometry/cg/int_rect_cg.cc", @@ -752,8 +751,6 @@ "geometry/double_size.h", "geometry/float_box.cc", "geometry/float_box.h", - "geometry/float_point.cc", - "geometry/float_point.h", "geometry/float_point_3d.cc", "geometry/float_point_3d.h", "geometry/float_polygon.cc", @@ -1762,7 +1759,6 @@ ] } else { sources -= [ - "geometry/cg/float_point_cg.cc", "geometry/cg/float_rect_cg.cc", "geometry/cg/float_size_cg.cc", "geometry/cg/int_rect_cg.cc", @@ -2067,7 +2063,6 @@ "geometry/float_box_test.cc", "geometry/float_box_test_helpers.cc", "geometry/float_box_test_helpers.h", - "geometry/float_point_test.cc", "geometry/float_polygon_test.cc", "geometry/float_quad_test.cc", "geometry/float_rect_test.cc",
diff --git a/third_party/blink/renderer/platform/animation/compositor_scroll_offset_animation_curve.cc b/third_party/blink/renderer/platform/animation/compositor_scroll_offset_animation_curve.cc index 055ba560..a819978 100644 --- a/third_party/blink/renderer/platform/animation/compositor_scroll_offset_animation_curve.cc +++ b/third_party/blink/renderer/platform/animation/compositor_scroll_offset_animation_curve.cc
@@ -3,10 +3,11 @@ // found in the LICENSE file. #include "third_party/blink/renderer/platform/animation/compositor_scroll_offset_animation_curve.h" -#include "third_party/blink/renderer/platform/animation/timing_function.h" #include "cc/animation/scroll_offset_animation_curve.h" #include "cc/animation/scroll_offset_animation_curve_factory.h" +#include "third_party/blink/renderer/platform/animation/timing_function.h" +#include "third_party/blink/renderer/platform/geometry/int_size.h" #include "ui/gfx/animation/keyframe/timing_function.h" using blink::CompositorScrollOffsetAnimationCurve; @@ -14,10 +15,10 @@ namespace blink { CompositorScrollOffsetAnimationCurve::CompositorScrollOffsetAnimationCurve( - FloatPoint target_value, + gfx::PointF target_value, ScrollType scroll_type) : curve_(cc::ScrollOffsetAnimationCurveFactory::CreateAnimation( - ToGfxPointF(target_value), + target_value, scroll_type)) {} CompositorScrollOffsetAnimationCurve::CompositorScrollOffsetAnimationCurve( @@ -28,12 +29,12 @@ default; void CompositorScrollOffsetAnimationCurve::SetInitialValue( - FloatPoint initial_value) { - curve_->SetInitialValue(ToGfxPointF(initial_value)); + gfx::PointF initial_value) { + curve_->SetInitialValue(initial_value); } -FloatPoint CompositorScrollOffsetAnimationCurve::GetValue(double time) const { - return FloatPoint(curve_->GetValue(base::Seconds(time))); +gfx::PointF CompositorScrollOffsetAnimationCurve::GetValue(double time) const { + return curve_->GetValue(base::Seconds(time)); } void CompositorScrollOffsetAnimationCurve::ApplyAdjustment(IntSize adjustment) { @@ -45,13 +46,14 @@ return curve_->Duration(); } -FloatPoint CompositorScrollOffsetAnimationCurve::TargetValue() const { - return FloatPoint(curve_->target_value()); +gfx::PointF CompositorScrollOffsetAnimationCurve::TargetValue() const { + return curve_->target_value(); } -void CompositorScrollOffsetAnimationCurve::UpdateTarget(base::TimeDelta time, - FloatPoint new_target) { - curve_->UpdateTarget(time, ToGfxPointF(new_target)); +void CompositorScrollOffsetAnimationCurve::UpdateTarget( + base::TimeDelta time, + gfx::PointF new_target) { + curve_->UpdateTarget(time, new_target); } std::unique_ptr<gfx::AnimationCurve>
diff --git a/third_party/blink/renderer/platform/animation/compositor_scroll_offset_animation_curve.h b/third_party/blink/renderer/platform/animation/compositor_scroll_offset_animation_curve.h index 39bc3d2..f932ee5 100644 --- a/third_party/blink/renderer/platform/animation/compositor_scroll_offset_animation_curve.h +++ b/third_party/blink/renderer/platform/animation/compositor_scroll_offset_animation_curve.h
@@ -10,8 +10,8 @@ #include "base/memory/ptr_util.h" #include "cc/animation/scroll_offset_animation_curve_factory.h" #include "third_party/blink/renderer/platform/animation/compositor_animation_curve.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/platform_export.h" +#include "ui/gfx/geometry/point_f.h" namespace cc { class ScrollOffsetAnimationCurve; @@ -19,12 +19,14 @@ namespace blink { +class IntSize; + class PLATFORM_EXPORT CompositorScrollOffsetAnimationCurve : public CompositorAnimationCurve { public: using ScrollType = cc::ScrollOffsetAnimationCurveFactory::ScrollType; - CompositorScrollOffsetAnimationCurve(FloatPoint, ScrollType); + CompositorScrollOffsetAnimationCurve(gfx::PointF, ScrollType); explicit CompositorScrollOffsetAnimationCurve( cc::ScrollOffsetAnimationCurve*); CompositorScrollOffsetAnimationCurve( @@ -34,12 +36,12 @@ ~CompositorScrollOffsetAnimationCurve() override; - void SetInitialValue(FloatPoint); - FloatPoint GetValue(double time) const; + void SetInitialValue(gfx::PointF); + gfx::PointF GetValue(double time) const; base::TimeDelta Duration() const; - FloatPoint TargetValue() const; + gfx::PointF TargetValue() const; void ApplyAdjustment(IntSize); - void UpdateTarget(base::TimeDelta time, FloatPoint new_target); + void UpdateTarget(base::TimeDelta time, gfx::PointF new_target); // CompositorAnimationCurve implementation. std::unique_ptr<gfx::AnimationCurve> CloneToAnimationCurve() const override;
diff --git a/third_party/blink/renderer/platform/exported/web_font.cc b/third_party/blink/renderer/platform/exported/web_font.cc index b940966..8565d13 100644 --- a/third_party/blink/renderer/platform/exported/web_font.cc +++ b/third_party/blink/renderer/platform/exported/web_font.cc
@@ -91,7 +91,7 @@ DrawingRecorder recorder(context, *builder, DisplayItem::kWebFont); context.Save(); context.SetFillColor(color); - context.DrawText(private_->GetFont(), run_info, FloatPoint(left_baseline), + context.DrawText(private_->GetFont(), run_info, left_baseline, kInvalidDOMNodeId, AutoDarkMode::Disabled()); context.Restore(); } @@ -113,8 +113,8 @@ int height, int from, int to) const { - return ToGfxRectF(private_->GetFont().SelectionRectForText( - run, FloatPoint(left_baseline), height, from, to)); + return ToGfxRectF(private_->GetFont().SelectionRectForText(run, left_baseline, + height, from, to)); } } // namespace blink
diff --git a/third_party/blink/renderer/platform/fonts/cursor_position_test.cc b/third_party/blink/renderer/platform/fonts/cursor_position_test.cc index 5badced0..61a017d4 100644 --- a/third_party/blink/renderer/platform/fonts/cursor_position_test.cc +++ b/third_party/blink/renderer/platform/fonts/cursor_position_test.cc
@@ -46,7 +46,7 @@ DCHECK_GE(end, -1); DCHECK_LE(end, static_cast<int>(text_run.length())); FloatRect rect = - font.SelectionRectForText(text_run, FloatPoint(), 12, start, end); + font.SelectionRectForText(text_run, gfx::PointF(), 12, start, end); return rect.width(); }
diff --git a/third_party/blink/renderer/platform/fonts/font.cc b/third_party/blink/renderer/platform/fonts/font.cc index 386ed35..480ddc4 100644 --- a/third_party/blink/renderer/platform/fonts/font.cc +++ b/third_party/blink/renderer/platform/fonts/font.cc
@@ -149,7 +149,7 @@ void DrawBlobs(cc::PaintCanvas* canvas, const cc::PaintFlags& flags, const ShapeResultBloberizer::BlobBuffer& blobs, - const FloatPoint& point, + const gfx::PointF& point, cc::NodeId node_id = cc::kInvalidNodeId) { for (const auto& blob_info : blobs) { DCHECK(blob_info.blob); @@ -207,7 +207,7 @@ void Font::DrawText(cc::PaintCanvas* canvas, const TextRunPaintInfo& run_info, - const FloatPoint& point, + const gfx::PointF& point, float device_scale_factor, const cc::PaintFlags& flags, DrawType draw_type) const { @@ -217,7 +217,7 @@ void Font::DrawText(cc::PaintCanvas* canvas, const TextRunPaintInfo& run_info, - const FloatPoint& point, + const gfx::PointF& point, float device_scale_factor, cc::NodeId node_id, const cc::PaintFlags& flags, @@ -240,7 +240,7 @@ void Font::DrawText(cc::PaintCanvas* canvas, const NGTextFragmentPaintInfo& text_info, - const FloatPoint& point, + const gfx::PointF& point, float device_scale_factor, cc::NodeId node_id, const cc::PaintFlags& flags, @@ -261,7 +261,7 @@ bool Font::DrawBidiText(cc::PaintCanvas* canvas, const TextRunPaintInfo& run_info, - const FloatPoint& point, + const gfx::PointF& point, CustomFontNotReadyAction custom_font_not_ready_action, float device_scale_factor, const cc::PaintFlags& flags, @@ -289,7 +289,7 @@ if (!bidi_runs.RunCount()) return true; - FloatPoint curr_point = point; + gfx::PointF curr_point = point; BidiCharacterRun* bidi_run = bidi_runs.FirstRun(); CachingWordShaper word_shaper(*this); while (bidi_run) { @@ -324,7 +324,7 @@ void Font::DrawEmphasisMarks(cc::PaintCanvas* canvas, const TextRunPaintInfo& run_info, const AtomicString& mark, - const FloatPoint& point, + const gfx::PointF& point, float device_scale_factor, const cc::PaintFlags& flags) const { if (ShouldSkipDrawing()) @@ -348,7 +348,7 @@ void Font::DrawEmphasisMarks(cc::PaintCanvas* canvas, const NGTextFragmentPaintInfo& text_info, const AtomicString& mark, - const FloatPoint& point, + const gfx::PointF& point, float device_scale_factor, const cc::PaintFlags& flags) const { if (ShouldSkipDrawing()) @@ -479,7 +479,7 @@ } FloatRect Font::SelectionRectForText(const TextRun& run, - const FloatPoint& point, + const gfx::PointF& point, float height, int from, int to) const {
diff --git a/third_party/blink/renderer/platform/fonts/font.h b/third_party/blink/renderer/platform/fonts/font.h index b6000b08..6a005c2 100644 --- a/third_party/blink/renderer/platform/fonts/font.h +++ b/third_party/blink/renderer/platform/fonts/font.h
@@ -44,6 +44,10 @@ // To avoid conflicts with the DrawText macro from the Windows SDK... #undef DrawText +namespace gfx { +class PointF; +} + namespace cc { class PaintCanvas; class PaintFlags; @@ -52,7 +56,6 @@ namespace blink { struct CharacterRange; -class FloatPoint; class FloatRect; class FontSelector; class ShapeCache; @@ -91,27 +94,27 @@ // https://crbug.com/716231 void DrawText(cc::PaintCanvas*, const TextRunPaintInfo&, - const FloatPoint&, + const gfx::PointF&, float device_scale_factor, const cc::PaintFlags&, DrawType = DrawType::kGlyphsOnly) const; void DrawText(cc::PaintCanvas*, const TextRunPaintInfo&, - const FloatPoint&, + const gfx::PointF&, float device_scale_factor, cc::NodeId node_id, const cc::PaintFlags&, DrawType = DrawType::kGlyphsOnly) const; void DrawText(cc::PaintCanvas*, const NGTextFragmentPaintInfo&, - const FloatPoint&, + const gfx::PointF&, float device_scale_factor, cc::NodeId node_id, const cc::PaintFlags&, DrawType = DrawType::kGlyphsOnly) const; bool DrawBidiText(cc::PaintCanvas*, const TextRunPaintInfo&, - const FloatPoint&, + const gfx::PointF&, CustomFontNotReadyAction, float device_scale_factor, const cc::PaintFlags&, @@ -119,13 +122,13 @@ void DrawEmphasisMarks(cc::PaintCanvas*, const TextRunPaintInfo&, const AtomicString& mark, - const FloatPoint&, + const gfx::PointF&, float device_scale_factor, const cc::PaintFlags&) const; void DrawEmphasisMarks(cc::PaintCanvas*, const NGTextFragmentPaintInfo&, const AtomicString& mark, - const FloatPoint&, + const gfx::PointF&, float device_scale_factor, const cc::PaintFlags&) const; @@ -164,7 +167,7 @@ IncludePartialGlyphsOption, BreakGlyphsOption) const; FloatRect SelectionRectForText(const TextRun&, - const FloatPoint&, + const gfx::PointF&, float height, int from = 0, int to = -1) const;
diff --git a/third_party/blink/renderer/platform/fonts/shaping/shape_result_bloberizer.cc b/third_party/blink/renderer/platform/fonts/shaping/shape_result_bloberizer.cc index 6eea8e4..8268a90 100644 --- a/third_party/blink/renderer/platform/fonts/shaping/shape_result_bloberizer.cc +++ b/third_party/blink/renderer/platform/fonts/shaping/shape_result_bloberizer.cc
@@ -240,7 +240,7 @@ inline void ShapeResultBloberizer::AddEmphasisMark( const GlyphData& emphasis_data, CanvasRotationInVertical canvas_rotation, - FloatPoint glyph_center, + gfx::PointF glyph_center, float mid_glyph_offset) { const SimpleFontData* emphasis_font_data = emphasis_data.font_data; DCHECK(emphasis_font_data); @@ -255,7 +255,8 @@ 0); } else { Add(emphasis_data.glyph, emphasis_font_data, emphasis_data.canvas_rotation, - FloatPoint(-glyph_center.x(), mid_glyph_offset - glyph_center.y()), 0); + gfx::Vector2dF(-glyph_center.x(), mid_glyph_offset - glyph_center.y()), + 0); } } @@ -288,10 +289,10 @@ if (bloberizer->IsSkipInkException(text, character_index)) return; - FloatPoint start_offset = - is_horizontal ? FloatPoint(advance, 0) : FloatPoint(0, advance); - bloberizer->Add(glyph, font_data, rotation, start_offset + glyph_offset, - character_index); + gfx::Vector2dF start_offset = + is_horizontal ? gfx::Vector2dF(advance, 0) : gfx::Vector2dF(0, advance); + bloberizer->Add(glyph, font_data, rotation, + start_offset + ToGfxVector2dF(glyph_offset), character_index); } /*static*/ void ShapeResultBloberizer::AddFastHorizontalGlyphToBloberizer( @@ -334,7 +335,7 @@ ShapeResultBloberizer* bloberizer; const StringView& text; const GlyphData& emphasis_data; - FloatPoint glyph_center; + gfx::PointF glyph_center; }; } // namespace @@ -350,7 +351,7 @@ ShapeResultBloberizer* bloberizer = parsed_context->bloberizer; const StringView& text = parsed_context->text; const GlyphData& emphasis_data = parsed_context->emphasis_data; - FloatPoint glyph_center = parsed_context->glyph_center; + gfx::PointF glyph_center = parsed_context->glyph_center; if (text.Is8Bit()) { if (Character::CanReceiveTextEmphasis(text[character_index])) { @@ -544,7 +545,7 @@ : ShapeResultBloberizer(font_description, device_scale_factor, Type::kNormal) { - FloatPoint glyph_center = + gfx::PointF glyph_center = emphasis.font_data->BoundsForGlyph(emphasis.glyph).CenterPoint(); float advance = 0; @@ -589,7 +590,7 @@ : ShapeResultBloberizer(font_description, device_scale_factor, Type::kNormal) { - FloatPoint glyph_center = + gfx::PointF glyph_center = emphasis.font_data->BoundsForGlyph(emphasis.glyph).CenterPoint(); ClusterCallbackContext context = {this, text, emphasis, glyph_center}; float initial_advance = 0;
diff --git a/third_party/blink/renderer/platform/fonts/shaping/shape_result_bloberizer.h b/third_party/blink/renderer/platform/fonts/shaping/shape_result_bloberizer.h index bc2a7f74..893554a 100644 --- a/third_party/blink/renderer/platform/fonts/shaping/shape_result_bloberizer.h +++ b/third_party/blink/renderer/platform/fonts/shaping/shape_result_bloberizer.h
@@ -9,11 +9,11 @@ #include "third_party/blink/renderer/platform/fonts/glyph.h" #include "third_party/blink/renderer/platform/fonts/shaping/shape_result_buffer.h" #include "third_party/blink/renderer/platform/fonts/simple_font_data.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/vector.h" #include "third_party/skia/include/core/SkTextBlob.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -81,7 +81,7 @@ void Add(Glyph glyph, const SimpleFontData* font_data, CanvasRotationInVertical canvas_rotation, - const FloatPoint& offset, + const gfx::Vector2dF& offset, unsigned character_index) { // cannot mix x-only/xy offsets DCHECK(pending_glyphs_.IsEmpty() || HasPendingVerticalOffsets()); @@ -145,7 +145,7 @@ void AddEmphasisMark(const GlyphData& emphasis_data, CanvasRotationInVertical canvas_rotation, - FloatPoint glyph_center, + gfx::PointF glyph_center, float mid_glyph_offset); static void AddEmphasisMarkToBloberizer( void* context,
diff --git a/third_party/blink/renderer/platform/fonts/shaping/shape_result_bloberizer_test.cc b/third_party/blink/renderer/platform/fonts/shaping/shape_result_bloberizer_test.cc index 29da8ed0..1b1d20fb 100644 --- a/third_party/blink/renderer/platform/fonts/shaping/shape_result_bloberizer_test.cc +++ b/third_party/blink/renderer/platform/fonts/shaping/shape_result_bloberizer_test.cc
@@ -218,10 +218,10 @@ // 2 pending glyphs ShapeResultBloberizerTestInfo::Add(bloberizer, 42, font1.get(), CanvasRotationInVertical::kRegular, - FloatPoint(10, 0), 0); + gfx::Vector2dF(10, 0), 0); ShapeResultBloberizerTestInfo::Add(bloberizer, 43, font1.get(), CanvasRotationInVertical::kRegular, - FloatPoint(15, 0), 1); + gfx::Vector2dF(15, 0), 1); EXPECT_EQ(ShapeResultBloberizerTestInfo::PendingRunFontData(bloberizer), font1.get()); @@ -250,7 +250,7 @@ // one more glyph, different font => pending run flush ShapeResultBloberizerTestInfo::Add(bloberizer, 44, font2.get(), CanvasRotationInVertical::kRegular, - FloatPoint(12, 2), 2); + gfx::Vector2dF(12, 2), 2); EXPECT_EQ(ShapeResultBloberizerTestInfo::PendingRunFontData(bloberizer), font2.get()); @@ -312,7 +312,7 @@ for (const auto& op : append_ops) { ShapeResultBloberizerTestInfo::Add(bloberizer, 42, test_font.get(), - op.canvas_rotation, FloatPoint(), 0); + op.canvas_rotation, gfx::Vector2dF(), 0); EXPECT_EQ( op.expected_pending_glyphs, ShapeResultBloberizerTestInfo::PendingRunGlyphs(bloberizer).size());
diff --git a/third_party/blink/renderer/platform/fonts/shaping/shape_result_buffer.cc b/third_party/blink/renderer/platform/fonts/shaping/shape_result_buffer.cc index 1538d6de..1ac585a8 100644 --- a/third_party/blink/renderer/platform/fonts/shaping/shape_result_buffer.cc +++ b/third_party/blink/renderer/platform/fonts/shaping/shape_result_buffer.cc
@@ -8,8 +8,8 @@ #include "third_party/blink/renderer/platform/fonts/shaping/shape_result.h" #include "third_party/blink/renderer/platform/fonts/shaping/shape_result_inline_headers.h" #include "third_party/blink/renderer/platform/fonts/simple_font_data.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/text/text_direction.h" +#include "ui/gfx/geometry/point_f.h" namespace blink {
diff --git a/third_party/blink/renderer/platform/fonts/shaping/shape_result_test_info.h b/third_party/blink/renderer/platform/fonts/shaping/shape_result_test_info.h index 6e7d72bb..5bbc9003 100644 --- a/third_party/blink/renderer/platform/fonts/shaping/shape_result_test_info.h +++ b/third_party/blink/renderer/platform/fonts/shaping/shape_result_test_info.h
@@ -50,7 +50,7 @@ Glyph glyph, const SimpleFontData* font_data, CanvasRotationInVertical canvas_rotation, - const FloatPoint& offset, + const gfx::Vector2dF& offset, unsigned character_index) { bloberizer.Add(glyph, font_data, canvas_rotation, offset, character_index); }
diff --git a/third_party/blink/renderer/platform/geometry/cg/float_point_cg.cc b/third_party/blink/renderer/platform/geometry/cg/float_point_cg.cc deleted file mode 100644 index ddc4b9b..0000000 --- a/third_party/blink/renderer/platform/geometry/cg/float_point_cg.cc +++ /dev/null
@@ -1,39 +0,0 @@ -/* - * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. - * Copyright (C) 2005 Nokia. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "third_party/blink/renderer/platform/geometry/float_point.h" - -#include <ApplicationServices/ApplicationServices.h> - -namespace blink { - -FloatPoint::FloatPoint(const CGPoint& p) : x_(p.x), y_(p.y) {} - -FloatPoint::operator CGPoint() const { - return CGPointMake(x_, y_); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/platform/geometry/cg/float_rect_cg.cc b/third_party/blink/renderer/platform/geometry/cg/float_rect_cg.cc index 17de3474c..5ba4b1e 100644 --- a/third_party/blink/renderer/platform/geometry/cg/float_rect_cg.cc +++ b/third_party/blink/renderer/platform/geometry/cg/float_rect_cg.cc
@@ -27,10 +27,12 @@ #include "third_party/blink/renderer/platform/geometry/float_rect.h" #include <ApplicationServices/ApplicationServices.h> +#include "third_party/blink/renderer/platform/geometry/cg_conversions.h" namespace blink { -FloatRect::FloatRect(const CGRect& r) : location_(r.origin), size_(r.size) {} +FloatRect::FloatRect(const CGRect& r) + : location_(CGPointToPointF(r.origin)), size_(r.size) {} FloatRect::operator CGRect() const { return CGRectMake(x(), y(), width(), height());
diff --git a/third_party/blink/renderer/platform/geometry/cg_conversions.cc b/third_party/blink/renderer/platform/geometry/cg_conversions.cc index b157641d..c32cbb2 100644 --- a/third_party/blink/renderer/platform/geometry/cg_conversions.cc +++ b/third_party/blink/renderer/platform/geometry/cg_conversions.cc
@@ -7,6 +7,7 @@ #include <ApplicationServices/ApplicationServices.h> #include "ui/gfx/geometry/point.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -18,4 +19,12 @@ return CGPointMake(p.x(), p.y()); } +gfx::PointF CGPointToPointF(const CGPoint& p) { + return gfx::PointF(static_cast<int>(p.x), static_cast<int>(p.y)); +} + +CGPoint PointFToCGPoint(const gfx::PointF& p) { + return CGPointMake(p.x(), p.y()); +} + } // namespace blink
diff --git a/third_party/blink/renderer/platform/geometry/cg_conversions.h b/third_party/blink/renderer/platform/geometry/cg_conversions.h index fd21739d..71af6b0 100644 --- a/third_party/blink/renderer/platform/geometry/cg_conversions.h +++ b/third_party/blink/renderer/platform/geometry/cg_conversions.h
@@ -12,6 +12,7 @@ namespace gfx { class Point; +class PointF; } typedef struct CGPoint CGPoint; @@ -25,6 +26,9 @@ PLATFORM_EXPORT gfx::Point CGPointToPoint(const CGPoint&); PLATFORM_EXPORT CGPoint PointToCGPoint(const gfx::Point&); +PLATFORM_EXPORT gfx::PointF CGPointToPointF(const CGPoint&); +PLATFORM_EXPORT CGPoint PointFToCGPoint(const gfx::PointF&); + } // namespace blink #endif // defined(OS_MAC)
diff --git a/third_party/blink/renderer/platform/geometry/double_point.cc b/third_party/blink/renderer/platform/geometry/double_point.cc index 17f786a..2db5779 100644 --- a/third_party/blink/renderer/platform/geometry/double_point.cc +++ b/third_party/blink/renderer/platform/geometry/double_point.cc
@@ -10,8 +10,8 @@ namespace blink { -DoublePoint::operator FloatPoint() const { - return FloatPoint(ClampTo<float>(x_), ClampTo<float>(y_)); +DoublePoint::operator gfx::PointF() const { + return gfx::PointF(ClampTo<float>(x_), ClampTo<float>(y_)); } DoublePoint DoublePoint::ExpandedTo(const DoublePoint& other) const {
diff --git a/third_party/blink/renderer/platform/geometry/double_point.h b/third_party/blink/renderer/platform/geometry/double_point.h index 64567804..57e8404 100644 --- a/third_party/blink/renderer/platform/geometry/double_point.h +++ b/third_party/blink/renderer/platform/geometry/double_point.h
@@ -7,10 +7,10 @@ #include <iosfwd> #include "third_party/blink/renderer/platform/geometry/double_size.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/forward.h" #include "ui/gfx/geometry/point.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -21,7 +21,7 @@ constexpr DoublePoint() : x_(0), y_(0) {} constexpr DoublePoint(double x, double y) : x_(x), y_(y) {} constexpr DoublePoint(const gfx::Point& p) : x_(p.x()), y_(p.y()) {} - constexpr DoublePoint(const FloatPoint& p) : x_(p.x()), y_(p.y()) {} + constexpr DoublePoint(const gfx::PointF& p) : x_(p.x()), y_(p.y()) {} // We also have conversion operator to DoublePoint defined in LayoutPoint. constexpr explicit DoublePoint(const IntSize& s) @@ -31,7 +31,7 @@ constexpr explicit DoublePoint(const DoubleSize& size) : x_(size.Width()), y_(size.Height()) {} - explicit operator FloatPoint() const; + explicit operator gfx::PointF() const; static constexpr DoublePoint Zero() { return DoublePoint(); }
diff --git a/third_party/blink/renderer/platform/geometry/float_point.cc b/third_party/blink/renderer/platform/geometry/float_point.cc deleted file mode 100644 index 72a195e..0000000 --- a/third_party/blink/renderer/platform/geometry/float_point.cc +++ /dev/null
@@ -1,109 +0,0 @@ -/* - * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2005 Nokia. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "third_party/blink/renderer/platform/geometry/float_point.h" - -#include <math.h> - -#include <algorithm> -#include <limits> - -#include "build/build_config.h" -#include "third_party/blink/renderer/platform/geometry/layout_point.h" -#include "third_party/blink/renderer/platform/geometry/layout_size.h" -#include "third_party/blink/renderer/platform/wtf/math_extras.h" -#include "third_party/blink/renderer/platform/wtf/text/text_stream.h" -#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" -#include "third_party/skia/include/core/SkPoint.h" - -namespace blink { - -float FloatPoint::SlopeAngleRadians() const { -#if defined(OS_MAC) - // atan2f(...) returns less accurate results on Mac. - // 3.1415925 vs. 3.14159274 for atan2f(0, -50) as an example. - return static_cast<float>( - atan2(static_cast<double>(y_), static_cast<double>(x_))); -#else - return atan2f(y_, x_); -#endif -} - -float FloatPoint::length() const { - return hypotf(x_, y_); -} - -FloatPoint FloatPoint::ExpandedTo(const FloatPoint& other) const { - return FloatPoint(std::max(x_, other.x_), std::max(y_, other.y_)); -} - -FloatPoint FloatPoint::ShrunkTo(const FloatPoint& other) const { - return FloatPoint(std::min(x_, other.x_), std::min(y_, other.y_)); -} - -FloatPoint FloatPoint::NarrowPrecision(double x, double y) { - return FloatPoint(ClampTo<float>(x), ClampTo<float>(y)); -} - -bool FindIntersection(const FloatPoint& p1, - const FloatPoint& p2, - const FloatPoint& d1, - const FloatPoint& d2, - FloatPoint& intersection) { - float px_length = p2.x() - p1.x(); - float py_length = p2.y() - p1.y(); - - float dx_length = d2.x() - d1.x(); - float dy_length = d2.y() - d1.y(); - - float denom = px_length * dy_length - py_length * dx_length; - if (!denom) - return false; - - float param = - ((d1.x() - p1.x()) * dy_length - (d1.y() - p1.y()) * dx_length) / denom; - - intersection.set_x(p1.x() + param * px_length); - intersection.set_y(p1.y() + param * py_length); - return true; -} - -std::ostream& operator<<(std::ostream& ostream, const FloatPoint& point) { - return ostream << point.ToString(); -} - -String FloatPoint::ToString() const { - return String::Format("%lg,%lg", x(), y()); -} - -WTF::TextStream& operator<<(WTF::TextStream& ts, const FloatPoint& p) { - ts << "(" << WTF::TextStream::FormatNumberRespectingIntegers(p.x()); - ts << "," << WTF::TextStream::FormatNumberRespectingIntegers(p.y()); - ts << ")"; - return ts; -} - -} // namespace blink
diff --git a/third_party/blink/renderer/platform/geometry/float_point.h b/third_party/blink/renderer/platform/geometry/float_point.h deleted file mode 100644 index f8425f8..0000000 --- a/third_party/blink/renderer/platform/geometry/float_point.h +++ /dev/null
@@ -1,307 +0,0 @@ -/* - * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2005 Nokia. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GEOMETRY_FLOAT_POINT_H_ -#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GEOMETRY_FLOAT_POINT_H_ - -#include <iosfwd> -#include "build/build_config.h" -#include "third_party/blink/renderer/platform/geometry/float_size.h" -#include "third_party/blink/renderer/platform/geometry/int_size.h" -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" -#include "third_party/blink/renderer/platform/wtf/forward.h" -#include "third_party/blink/renderer/platform/wtf/hash_traits.h" -#include "third_party/skia/include/core/SkPoint.h" -#include "ui/gfx/geometry/point.h" -#include "ui/gfx/geometry/point3_f.h" -#include "ui/gfx/geometry/point_f.h" -#include "ui/gfx/geometry/vector2d_f.h" - -#if defined(OS_MAC) -typedef struct CGPoint CGPoint; - -#ifdef __OBJC__ -#import <Foundation/Foundation.h> -#endif -#endif - -namespace blink { - -class PLATFORM_EXPORT FloatPoint { - DISALLOW_NEW(); - - public: - constexpr FloatPoint() : x_(0), y_(0) {} - constexpr FloatPoint(float x, float y) : x_(x), y_(y) {} - constexpr explicit FloatPoint(const gfx::Point& p) : x_(p.x()), y_(p.y()) {} - explicit FloatPoint(const SkPoint& p) : x_(p.x()), y_(p.y()) {} - constexpr explicit FloatPoint(const FloatSize& s) - : x_(s.width()), y_(s.height()) {} - constexpr explicit FloatPoint(const IntSize& s) - : x_(s.width()), y_(s.height()) {} - constexpr explicit FloatPoint(const gfx::PointF& p) : x_(p.x()), y_(p.y()) {} - constexpr explicit FloatPoint(const gfx::Vector2dF& v) - : x_(v.x()), y_(v.y()) {} - // We also have conversion operators to FloatPoint defined LayoutPoint, - // LayoutSize and DoublePoint. - - static constexpr FloatPoint Zero() { return FloatPoint(); } - - static FloatPoint NarrowPrecision(double x, double y); - - bool IsValid() const { - return x_ != -std::numeric_limits<float>::infinity() && - y_ != -std::numeric_limits<float>::infinity(); - } - - constexpr float x() const { return x_; } - constexpr float y() const { return y_; } - - void set_x(float x) { x_ = x; } - void set_y(float y) { y_ = y; } - void SetPoint(float x, float y) { - x_ = x; - y_ = y; - } - void Offset(float dx, float dy) { - x_ += dx; - y_ += dy; - } - void Offset(const IntSize& a) { - x_ += a.width(); - y_ += a.height(); - } - void Offset(const FloatSize& a) { - x_ += a.width(); - y_ += a.height(); - } - void MoveBy(const gfx::Point& a) { - x_ += a.x(); - y_ += a.y(); - } - void MoveBy(const FloatPoint& a) { - x_ += a.x(); - y_ += a.y(); - } - void Scale(float sx, float sy) { - x_ *= sx; - y_ *= sy; - } - - float Dot(const FloatPoint& a) const { return x_ * a.x() + y_ * a.y(); } - - float SlopeAngleRadians() const; - float length() const; - float LengthSquared() const { return x_ * x_ + y_ * y_; } - - FloatPoint ExpandedTo(const FloatPoint& other) const; - FloatPoint ShrunkTo(const FloatPoint& other) const; - - FloatPoint TransposedPoint() const { return FloatPoint(y_, x_); } - - FloatPoint ScaledBy(float scale) const { - return FloatPoint(x_ * scale, y_ * scale); - } - -#if defined(OS_MAC) - FloatPoint(const CGPoint&); - operator CGPoint() const; -#endif - - explicit operator SkPoint() const { return SkPoint::Make(x_, y_); } - - // These are deleted during blink geometry type to gfx migration. - // Use ToGfxPointF(), ToGfxPoint3F() and ToGfxVector2dF() instead. - operator gfx::PointF() const = delete; - operator gfx::Point3F() const = delete; - operator gfx::Vector2dF() const = delete; - - String ToString() const; - - private: - float x_, y_; - - friend struct ::WTF::DefaultHash<blink::FloatSize>; - friend struct ::WTF::HashTraits<blink::FloatSize>; -}; - -inline FloatPoint& operator+=(FloatPoint& a, const FloatSize& b) { - a.Offset(b.width(), b.height()); - return a; -} - -inline FloatPoint& operator+=(FloatPoint& a, const FloatPoint& b) { - a.Offset(b.x(), b.y()); - return a; -} - -inline FloatPoint& operator-=(FloatPoint& a, const FloatSize& b) { - a.Offset(-b.width(), -b.height()); - return a; -} - -constexpr FloatPoint operator+(const FloatPoint& a, const FloatSize& b) { - return FloatPoint(a.x() + b.width(), a.y() + b.height()); -} - -constexpr FloatPoint operator+(const FloatPoint& a, const IntSize& b) { - return FloatPoint(a.x() + b.width(), a.y() + b.height()); -} - -constexpr FloatPoint operator+(const gfx::Point& a, const FloatSize& b) { - return FloatPoint(a.x() + b.width(), a.y() + b.height()); -} - -constexpr FloatPoint operator+(const FloatPoint& a, const FloatPoint& b) { - return FloatPoint(a.x() + b.x(), a.y() + b.y()); -} - -constexpr FloatPoint operator+(const FloatPoint& a, const gfx::Point& b) { - return FloatPoint(a.x() + b.x(), a.y() + b.y()); -} - -constexpr FloatSize operator-(const FloatPoint& a, const FloatPoint& b) { - return FloatSize(a.x() - b.x(), a.y() - b.y()); -} - -constexpr FloatSize operator-(const FloatPoint& a, const gfx::Point& b) { - return FloatSize(a.x() - b.x(), a.y() - b.y()); -} - -constexpr FloatPoint operator-(const FloatPoint& a, const FloatSize& b) { - return FloatPoint(a.x() - b.width(), a.y() - b.height()); -} - -constexpr FloatPoint operator-(const FloatPoint& a) { - return FloatPoint(-a.x(), -a.y()); -} - -constexpr bool operator==(const FloatPoint& a, const FloatPoint& b) { - return a.x() == b.x() && a.y() == b.y(); -} - -constexpr bool operator!=(const FloatPoint& a, const FloatPoint& b) { - return !(a == b); -} - -inline float operator*(const FloatPoint& a, const FloatPoint& b) { - // dot product - return a.Dot(b); -} - -inline gfx::Point RoundedIntPoint(const FloatPoint& p) { - return gfx::Point(ClampTo<int>(roundf(p.x())), ClampTo<int>(roundf(p.y()))); -} - -inline IntSize RoundedIntSize(const FloatPoint& p) { - return IntSize(ClampTo<int>(roundf(p.x())), ClampTo<int>(roundf(p.y()))); -} - -inline gfx::Point FlooredIntPoint(const FloatPoint& p) { - return gfx::Point(ClampTo<int>(floorf(p.x())), ClampTo<int>(floorf(p.y()))); -} - -inline gfx::Point FlooredIntPoint(const gfx::PointF& p) { - return gfx::Point(ClampTo<int>(floorf(p.x())), ClampTo<int>(floorf(p.y()))); -} - -inline gfx::Point CeiledIntPoint(const FloatPoint& p) { - return gfx::Point(ClampTo<int>(ceilf(p.x())), ClampTo<int>(ceilf(p.y()))); -} - -inline IntSize FlooredIntSize(const FloatPoint& p) { - return IntSize(ClampTo<int>(floorf(p.x())), ClampTo<int>(floorf(p.y()))); -} - -inline FloatSize ToFloatSize(const FloatPoint& a) { - return FloatSize(a.x(), a.y()); -} - -// Find point where lines through the two pairs of points intersect. -// Returns false if the lines don't intersect. -PLATFORM_EXPORT bool FindIntersection(const FloatPoint& p1, - const FloatPoint& p2, - const FloatPoint& d1, - const FloatPoint& d2, - FloatPoint& intersection); - -constexpr gfx::PointF ToGfxPointF(const FloatPoint& p) { - return gfx::PointF(p.x(), p.y()); -} - -constexpr gfx::Point3F ToGfxPoint3F(const FloatPoint& p) { - return gfx::Point3F(p.x(), p.y(), 0.f); -} - -constexpr gfx::Vector2dF ToGfxVector2dF(const FloatPoint& p) { - return gfx::Vector2dF(p.x(), p.y()); -} - -PLATFORM_EXPORT std::ostream& operator<<(std::ostream&, const FloatPoint&); -PLATFORM_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, - const FloatPoint&); - -} // namespace blink - -namespace WTF { - -template <> -struct DefaultHash<blink::FloatPoint> { - STATIC_ONLY(DefaultHash); - struct Hash { - STATIC_ONLY(Hash); - typedef typename IntTypes<sizeof(float)>::UnsignedType Bits; - static unsigned GetHash(const blink::FloatPoint& key) { - return HashInts(bit_cast<Bits>(key.x()), bit_cast<Bits>(key.y())); - } - static bool Equal(const blink::FloatPoint& a, const blink::FloatPoint& b) { - return bit_cast<Bits>(a.x()) == bit_cast<Bits>(b.x()) && - bit_cast<Bits>(a.y()) == bit_cast<Bits>(b.y()); - } - static const bool safe_to_compare_to_empty_or_deleted = true; - }; -}; - -template <> -struct HashTraits<blink::FloatPoint> : GenericHashTraits<blink::FloatPoint> { - STATIC_ONLY(HashTraits); - static const bool kEmptyValueIsZero = false; - static blink::FloatPoint EmptyValue() { - return blink::FloatPoint(std::numeric_limits<float>::infinity(), - std::numeric_limits<float>::infinity()); - } - static void ConstructDeletedValue(blink::FloatPoint& slot, bool) { - slot = blink::FloatPoint(-std::numeric_limits<float>::infinity(), - -std::numeric_limits<float>::infinity()); - } - static bool IsDeletedValue(const blink::FloatPoint& value) { - return !value.IsValid(); - } -}; - -} // namespace WTF - -#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GEOMETRY_FLOAT_POINT_H_
diff --git a/third_party/blink/renderer/platform/geometry/float_point_3d.h b/third_party/blink/renderer/platform/geometry/float_point_3d.h index aa28950..cfe5940 100644 --- a/third_party/blink/renderer/platform/geometry/float_point_3d.h +++ b/third_party/blink/renderer/platform/geometry/float_point_3d.h
@@ -23,11 +23,12 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GEOMETRY_FLOAT_POINT_3D_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GEOMETRY_FLOAT_POINT_3D_H_ -#include "third_party/blink/renderer/platform/geometry/float_point.h" +#include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/skia/include/core/SkPoint3.h" #include "ui/gfx/geometry/point3_f.h" +#include "ui/gfx/geometry/point_f.h" #include "ui/gfx/geometry/vector3d_f.h" namespace blink { @@ -40,7 +41,7 @@ constexpr FloatPoint3D(float x, float y, float z) : x_(x), y_(y), z_(z) {} - constexpr FloatPoint3D(const FloatPoint& p) : x_(p.x()), y_(p.y()), z_(0) {} + constexpr FloatPoint3D(const gfx::PointF& p) : x_(p.x()), y_(p.y()), z_(0) {} constexpr FloatPoint3D(const FloatPoint3D&) = default;
diff --git a/third_party/blink/renderer/platform/geometry/float_point_test.cc b/third_party/blink/renderer/platform/geometry/float_point_test.cc deleted file mode 100644 index c7d15480..0000000 --- a/third_party/blink/renderer/platform/geometry/float_point_test.cc +++ /dev/null
@@ -1,31 +0,0 @@ -// Copyright 2015 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/platform/geometry/float_point.h" - -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/blink/renderer/platform/geometry/geometry_test_helpers.h" - -namespace blink { - -TEST(FloatPointTest, LengthTest) { - // Sanity check the Pythagorean triples 3-4-5 and 5-12-13 - FloatPoint p1 = FloatPoint(3.f, 4.f); - EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, p1.length(), 5.f); - FloatPoint p2 = FloatPoint(5.f, 12.f); - EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, p2.length(), 13.f); - - // Test very small numbers. This fails under the old implementation of - // FloatPoint::length(): `return sqrtf(lengthSquared());' - FloatPoint p3 = FloatPoint(.5e-20f, .5e-20f); - EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, p3.length(), - .707106781186548e-20f); - - // Test very large numbers. - FloatPoint p4 = FloatPoint(.5e20f, .5e20f); - EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, p4.length(), - .707106781186548e20f); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/platform/geometry/float_polygon.cc b/third_party/blink/renderer/platform/geometry/float_polygon.cc index 992ead2..e85180d 100644 --- a/third_party/blink/renderer/platform/geometry/float_polygon.cc +++ b/third_party/blink/renderer/platform/geometry/float_polygon.cc
@@ -28,7 +28,6 @@ */ #include "third_party/blink/renderer/platform/geometry/float_polygon.h" -#include "third_party/blink/renderer/platform/geometry/float_shape_helpers.h" #include <memory> #include "third_party/blink/renderer/platform/wtf/math_extras.h"
diff --git a/third_party/blink/renderer/platform/geometry/float_quad.cc b/third_party/blink/renderer/platform/geometry/float_quad.cc index 919fdb2b..16ca1540 100644 --- a/third_party/blink/renderer/platform/geometry/float_quad.cc +++ b/third_party/blink/renderer/platform/geometry/float_quad.cc
@@ -33,9 +33,9 @@ #include <algorithm> #include <cmath> #include <limits> -#include "third_party/blink/renderer/platform/geometry/float_shape_helpers.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/skia/include/core/SkPoint.h" +#include "ui/gfx/geometry/skia_conversions.h" namespace blink { @@ -47,30 +47,26 @@ return std::max(std::max(a, b), std::max(c, d)); } -inline float Dot(const FloatSize& a, const FloatSize& b) { - return a.width() * b.width() + a.height() * b.height(); -} - -inline bool IsPointInTriangle(const FloatPoint& p, - const FloatPoint& t1, - const FloatPoint& t2, - const FloatPoint& t3) { +inline bool IsPointInTriangle(const gfx::PointF& p, + const gfx::PointF& t1, + const gfx::PointF& t2, + const gfx::PointF& t3) { // Compute vectors - FloatSize v0 = t3 - t1; - FloatSize v1 = t2 - t1; - FloatSize v2 = p - t1; + gfx::Vector2dF v0 = t3 - t1; + gfx::Vector2dF v1 = t2 - t1; + gfx::Vector2dF v2 = p - t1; // Compute dot products - float dot00 = Dot(v0, v0); - float dot01 = Dot(v0, v1); - float dot02 = Dot(v0, v2); - float dot11 = Dot(v1, v1); - float dot12 = Dot(v1, v2); + double dot00 = gfx::DotProduct(v0, v0); + double dot01 = gfx::DotProduct(v0, v1); + double dot02 = gfx::DotProduct(v0, v2); + double dot11 = gfx::DotProduct(v1, v1); + double dot12 = gfx::DotProduct(v1, v2); // Compute barycentric coordinates - float inv_denom = 1.0f / (dot00 * dot11 - dot01 * dot01); - float u = (dot11 * dot02 - dot01 * dot12) * inv_denom; - float v = (dot00 * dot12 - dot01 * dot02) * inv_denom; + double inv_denom = 1.0f / (dot00 * dot11 - dot01 * dot01); + double u = (dot11 * dot02 - dot01 * dot12) * inv_denom; + double v = (dot00 * dot12 - dot01 * dot02) * inv_denom; // Check if point is in triangle return (u >= 0) && (v >= 0) && (u + v <= 1); @@ -100,10 +96,10 @@ } FloatQuad::FloatQuad(const SkPoint (&quad)[4]) - : FloatQuad(FloatPoint(quad[0]), - FloatPoint(quad[1]), - FloatPoint(quad[2]), - FloatPoint(quad[3])) {} + : FloatQuad(gfx::SkPointToPointF(quad[0]), + gfx::SkPointToPointF(quad[1]), + gfx::SkPointToPointF(quad[2]), + gfx::SkPointToPointF(quad[3])) {} bool FloatQuad::IsRectilinear() const { return (WithinEpsilon(p1_.x(), p2_.x()) && WithinEpsilon(p2_.y(), p3_.y()) && @@ -112,7 +108,7 @@ WithinEpsilon(p3_.y(), p4_.y()) && WithinEpsilon(p4_.x(), p1_.x())); } -bool FloatQuad::ContainsPoint(const FloatPoint& p) const { +bool FloatQuad::ContainsPoint(const gfx::PointF& p) const { return IsPointInTriangle(p, p1_, p2_, p3_) || IsPointInTriangle(p, p1_, p3_, p4_); } @@ -123,8 +119,9 @@ ContainsPoint(other.p3()) && ContainsPoint(other.p4()); } -static inline FloatPoint RightMostCornerToVector(const FloatRect& rect, - const FloatSize& vector) { +static inline gfx::PointF RightMostCornerToVector( + const FloatRect& rect, + const gfx::Vector2dF& vector) { // Return the corner of the rectangle that if it is to the left of the vector // would mean all of the rectangle is to the left of the vector. // The vector here represents the side between two points in a clockwise @@ -135,12 +132,12 @@ // QQQ from the top corner of Q to the right corner of Q, then all of X // Q is left of the vector, and intersection impossible. // - FloatPoint point; - if (vector.width() >= 0) + gfx::PointF point; + if (vector.x() >= 0) point.set_y(rect.bottom()); else point.set_y(rect.y()); - if (vector.height() >= 0) + if (vector.y() >= 0) point.set_x(rect.x()); else point.set_x(rect.right()); @@ -154,7 +151,7 @@ // For each side of the quad clockwise we check if the rectangle is to the // left of it since only content on the right can onlap with the quad. This // only works if the quad is convex. - FloatSize v1, v2, v3, v4; + gfx::Vector2dF v1, v2, v3, v4; // Ensure we use clockwise vectors. if (!IsCounterclockwise()) { @@ -169,20 +166,20 @@ v4 = p3_ - p4_; } - FloatPoint p = RightMostCornerToVector(rect, v1); - if (Determinant(v1, p - p1_) < 0) + gfx::PointF p = RightMostCornerToVector(rect, v1); + if (gfx::CrossProduct(v1, p - p1_) < 0) return false; p = RightMostCornerToVector(rect, v2); - if (Determinant(v2, p - p2_) < 0) + if (gfx::CrossProduct(v2, p - p2_) < 0) return false; p = RightMostCornerToVector(rect, v3); - if (Determinant(v3, p - p3_) < 0) + if (gfx::CrossProduct(v3, p - p3_) < 0) return false; p = RightMostCornerToVector(rect, v4); - if (Determinant(v4, p - p4_) < 0) + if (gfx::CrossProduct(v4, p - p4_) < 0) return false; // If not all of the rectangle is outside one of the quad's four sides, then @@ -191,10 +188,10 @@ } // Tests whether the line is contained by or intersected with the circle. -static inline bool LineIntersectsCircle(const FloatPoint& center, +static inline bool LineIntersectsCircle(const gfx::PointF& center, float radius, - const FloatPoint& p0, - const FloatPoint& p1) { + const gfx::PointF& p0, + const gfx::PointF& p1) { float x0 = p0.x() - center.x(), y0 = p0.y() - center.y(); float x1 = p1.x() - center.x(), y1 = p1.y() - center.y(); float radius2 = radius * radius; @@ -220,7 +217,8 @@ ((y0 <= y && y <= y1) || (y1 <= y && y <= y0))); } -bool FloatQuad::IntersectsCircle(const FloatPoint& center, float radius) const { +bool FloatQuad::IntersectsCircle(const gfx::PointF& center, + float radius) const { return ContainsPoint( center) // The circle may be totally contained by the quad. || LineIntersectsCircle(center, radius, p1_, p2_) || @@ -229,7 +227,7 @@ LineIntersectsCircle(center, radius, p4_, p1_); } -bool FloatQuad::IntersectsEllipse(const FloatPoint& center, +bool FloatQuad::IntersectsEllipse(const gfx::PointF& center, const FloatSize& radii) const { // Transform the ellipse to an origin-centered circle whose radius is the // product of major radius and minor radius. Here we apply the same @@ -238,7 +236,7 @@ transformed_quad.Move(-center.x(), -center.y()); transformed_quad.Scale(radii.height(), radii.width()); - FloatPoint origin_point; + gfx::PointF origin_point; return transformed_quad.IntersectsCircle(origin_point, radii.height() * radii.width()); } @@ -246,7 +244,7 @@ bool FloatQuad::IsCounterclockwise() const { // Return if the two first vectors are turning clockwise. If the quad is // convex then all following vectors will turn the same way. - return Determinant(p2_ - p1_, p3_ - p2_) < 0; + return gfx::CrossProduct(p2_ - p1_, p3_ - p2_) < 0; } std::ostream& operator<<(std::ostream& ostream, const FloatQuad& quad) { @@ -254,10 +252,9 @@ } String FloatQuad::ToString() const { - return String::Format("%s; %s; %s; %s", p1_.ToString().Ascii().c_str(), - p2_.ToString().Ascii().c_str(), - p3_.ToString().Ascii().c_str(), - p4_.ToString().Ascii().c_str()); + return String::Format("%s; %s; %s; %s", p1_.ToString().c_str(), + p2_.ToString().c_str(), p3_.ToString().c_str(), + p4_.ToString().c_str()); } } // namespace blink
diff --git a/third_party/blink/renderer/platform/geometry/float_quad.h b/third_party/blink/renderer/platform/geometry/float_quad.h index 10e486b3..a0972c85 100644 --- a/third_party/blink/renderer/platform/geometry/float_quad.h +++ b/third_party/blink/renderer/platform/geometry/float_quad.h
@@ -30,11 +30,11 @@ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GEOMETRY_FLOAT_QUAD_H_ #include <iosfwd> -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/geometry/layout_size.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" +#include "ui/gfx/geometry/point_f.h" #include "ui/gfx/geometry/quad_f.h" struct SkPoint; @@ -50,10 +50,10 @@ public: constexpr FloatQuad() = default; - constexpr FloatQuad(const FloatPoint& p1, - const FloatPoint& p2, - const FloatPoint& p3, - const FloatPoint& p4) + constexpr FloatQuad(const gfx::PointF& p1, + const gfx::PointF& p2, + const gfx::PointF& p3, + const gfx::PointF& p4) : p1_(p1), p2_(p2), p3_(p3), p4_(p4) {} constexpr FloatQuad(const FloatRect& in_rect) @@ -78,15 +78,15 @@ // Use ToGfxQuadF() instead. operator gfx::QuadF() const = delete; - constexpr FloatPoint p1() const { return p1_; } - constexpr FloatPoint p2() const { return p2_; } - constexpr FloatPoint p3() const { return p3_; } - constexpr FloatPoint p4() const { return p4_; } + constexpr gfx::PointF p1() const { return p1_; } + constexpr gfx::PointF p2() const { return p2_; } + constexpr gfx::PointF p3() const { return p3_; } + constexpr gfx::PointF p4() const { return p4_; } - void set_p1(const FloatPoint& p) { p1_ = p; } - void set_p2(const FloatPoint& p) { p2_ = p; } - void set_p3(const FloatPoint& p) { p3_ = p; } - void set_p4(const FloatPoint& p) { p4_ = p; } + void set_p1(const gfx::PointF& p) { p1_ = p; } + void set_p2(const gfx::PointF& p) { p2_ = p; } + void set_p3(const gfx::PointF& p) { p3_ = p; } + void set_p4(const gfx::PointF& p) { p4_ = p; } // isEmpty tests that the bounding box is empty. This will not identify // "slanted" empty quads. @@ -100,7 +100,7 @@ // Tests whether the given point is inside, or on an edge or corner of this // quad. - bool ContainsPoint(const FloatPoint&) const; + bool ContainsPoint(const gfx::PointF&) const; // Tests whether the four corners of other are inside, or coincident with the // sides of this quad. Note that this only works for convex quads, but that @@ -118,15 +118,15 @@ // Note that these two functions only work for convex quads. // These intersections are edge-inclusive and will return true even if the // intersecting area is empty (i.e., the intersection is a line or a point). - bool IntersectsCircle(const FloatPoint& center, float radius) const; - bool IntersectsEllipse(const FloatPoint& center, + bool IntersectsCircle(const gfx::PointF& center, float radius) const; + bool IntersectsEllipse(const gfx::PointF& center, const FloatSize& radii) const; // The center of the quad. If the quad is the result of a affine-transformed // rectangle this is the same as the original center transformed. - FloatPoint Center() const { - return FloatPoint((p1_.x() + p2_.x() + p3_.x() + p4_.x()) / 4.0, - (p1_.y() + p2_.y() + p3_.y() + p4_.y()) / 4.0); + gfx::PointF Center() const { + return gfx::PointF((p1_.x() + p2_.x() + p3_.x() + p4_.x()) / 4.0, + (p1_.y() + p2_.y() + p3_.y() + p4_.y()) / 4.0); } FloatRect BoundingBox() const; @@ -134,7 +134,8 @@ return EnclosingIntRect(BoundingBox()); } - void Move(const FloatSize& offset) { + void Move(const FloatSize& offset) { Move(ToGfxVector2dF(offset)); } + void Move(const gfx::Vector2dF& offset) { p1_ += offset; p2_ += offset; p3_ += offset; @@ -166,10 +167,10 @@ String ToString() const; private: - FloatPoint p1_; - FloatPoint p2_; - FloatPoint p3_; - FloatPoint p4_; + gfx::PointF p1_; + gfx::PointF p2_; + gfx::PointF p3_; + gfx::PointF p4_; }; inline FloatQuad& operator+=(FloatQuad& a, const FloatSize& b) { @@ -192,8 +193,7 @@ } constexpr gfx::QuadF ToGfxQuadF(const FloatQuad& q) { - return gfx::QuadF(ToGfxPointF(q.p1()), ToGfxPointF(q.p2()), - ToGfxPointF(q.p3()), ToGfxPointF(q.p4())); + return gfx::QuadF(q.p1(), q.p2(), q.p3(), q.p4()); } PLATFORM_EXPORT std::ostream& operator<<(std::ostream&, const FloatQuad&);
diff --git a/third_party/blink/renderer/platform/geometry/float_quad_test.cc b/third_party/blink/renderer/platform/geometry/float_quad_test.cc index fff5038..bfff751 100644 --- a/third_party/blink/renderer/platform/geometry/float_quad_test.cc +++ b/third_party/blink/renderer/platform/geometry/float_quad_test.cc
@@ -11,14 +11,14 @@ namespace blink { TEST(FloatQuadTest, ToString) { - FloatQuad quad(FloatPoint(2, 3), FloatPoint(5, 7), FloatPoint(11, 13), - FloatPoint(17, 19)); + FloatQuad quad(gfx::PointF(2, 3), gfx::PointF(5, 7), gfx::PointF(11, 13), + gfx::PointF(17, 19)); EXPECT_EQ("2,3; 5,7; 11,13; 17,19", quad.ToString()); } TEST(FloatQuadTest, BoundingBox) { - FloatQuad quad(FloatPoint(2, 3), FloatPoint(5, 7), FloatPoint(11, 13), - FloatPoint(17, 19)); + FloatQuad quad(gfx::PointF(2, 3), gfx::PointF(5, 7), gfx::PointF(11, 13), + gfx::PointF(17, 19)); FloatRect rect = quad.BoundingBox(); EXPECT_EQ(rect.x(), 2); EXPECT_EQ(rect.y(), 3); @@ -28,8 +28,8 @@ TEST(FloatQuadTest, BoundingBoxSaturateInf) { constexpr double inf = std::numeric_limits<double>::infinity(); - FloatQuad quad(FloatPoint(-inf, 3), FloatPoint(5, inf), FloatPoint(11, 13), - FloatPoint(17, 19)); + FloatQuad quad(gfx::PointF(-inf, 3), gfx::PointF(5, inf), gfx::PointF(11, 13), + gfx::PointF(17, 19)); FloatRect rect = quad.BoundingBox(); EXPECT_EQ(rect.x(), std::numeric_limits<int>::min()); EXPECT_EQ(rect.y(), 3.0f); @@ -40,8 +40,8 @@ TEST(FloatQuadTest, BoundingBoxSaturateLarge) { constexpr double large = std::numeric_limits<float>::max() * 4; - FloatQuad quad(FloatPoint(-large, 3), FloatPoint(5, large), - FloatPoint(11, 13), FloatPoint(17, 19)); + FloatQuad quad(gfx::PointF(-large, 3), gfx::PointF(5, large), + gfx::PointF(11, 13), gfx::PointF(17, 19)); FloatRect rect = quad.BoundingBox(); EXPECT_EQ(rect.x(), std::numeric_limits<int>::min()); EXPECT_EQ(rect.y(), 3.0f); @@ -87,40 +87,40 @@ FloatQuad quad(FloatRect(10, 10, 10, 10)); // A circle fully contained in the top-left of the quad should intersect. - EXPECT_TRUE(quad.IntersectsCircle(FloatPoint(12, 12), 1)); + EXPECT_TRUE(quad.IntersectsCircle(gfx::PointF(12, 12), 1)); // A point fully contained in the top-left of the quad should intersect. - EXPECT_TRUE(quad.IntersectsCircle(FloatPoint(12, 12), 0)); + EXPECT_TRUE(quad.IntersectsCircle(gfx::PointF(12, 12), 0)); // A circle that touches the left edge should intersect. - EXPECT_TRUE(quad.IntersectsCircle(FloatPoint(9, 11), 1)); + EXPECT_TRUE(quad.IntersectsCircle(gfx::PointF(9, 11), 1)); // A circle that touches the top edge should intersect. - EXPECT_TRUE(quad.IntersectsCircle(FloatPoint(11, 9), 1)); + EXPECT_TRUE(quad.IntersectsCircle(gfx::PointF(11, 9), 1)); // A circle that touches the right edge should intersect. - EXPECT_TRUE(quad.IntersectsCircle(FloatPoint(21, 11), 1)); + EXPECT_TRUE(quad.IntersectsCircle(gfx::PointF(21, 11), 1)); // A circle that touches the bottom edge should intersect. - EXPECT_TRUE(quad.IntersectsCircle(FloatPoint(11, 21), 1)); + EXPECT_TRUE(quad.IntersectsCircle(gfx::PointF(11, 21), 1)); // A point that touches the left edge should intersect. - EXPECT_TRUE(quad.IntersectsCircle(FloatPoint(10, 11), 0)); + EXPECT_TRUE(quad.IntersectsCircle(gfx::PointF(10, 11), 0)); // A point that touches the top edge should intersect. - EXPECT_TRUE(quad.IntersectsCircle(FloatPoint(11, 10), 0)); + EXPECT_TRUE(quad.IntersectsCircle(gfx::PointF(11, 10), 0)); // A point that touches the right edge should intersect. - EXPECT_TRUE(quad.IntersectsCircle(FloatPoint(20, 11), 0)); + EXPECT_TRUE(quad.IntersectsCircle(gfx::PointF(20, 11), 0)); // A point that touches the bottom edge should intersect. - EXPECT_TRUE(quad.IntersectsCircle(FloatPoint(11, 20), 0)); + EXPECT_TRUE(quad.IntersectsCircle(gfx::PointF(11, 20), 0)); // A circle that is fully outside the quad should not intersect. - EXPECT_FALSE(quad.IntersectsCircle(FloatPoint(9, 9), 1)); + EXPECT_FALSE(quad.IntersectsCircle(gfx::PointF(9, 9), 1)); // A point that is fully outside the quad should not intersect. - EXPECT_FALSE(quad.IntersectsCircle(FloatPoint(9, 9), 0)); + EXPECT_FALSE(quad.IntersectsCircle(gfx::PointF(9, 9), 0)); } } // namespace blink
diff --git a/third_party/blink/renderer/platform/geometry/float_rect.cc b/third_party/blink/renderer/platform/geometry/float_rect.cc index 95eae39..55f45cb 100644 --- a/third_party/blink/renderer/platform/geometry/float_rect.cc +++ b/third_party/blink/renderer/platform/geometry/float_rect.cc
@@ -31,6 +31,7 @@ #include "third_party/blink/renderer/platform/wtf/math_extras.h" #include "third_party/blink/renderer/platform/wtf/text/text_stream.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" +#include "ui/gfx/geometry/point_conversions.h" namespace blink { @@ -184,7 +185,7 @@ UnionEvenIfEmpty(other); } -void FloatRect::Extend(const FloatPoint& p) { +void FloatRect::Extend(const gfx::PointF& p) { float min_x = std::min(x(), p.x()); float min_y = std::min(y(), p.y()); float max_x = std::max(this->right(), p.x()); @@ -200,11 +201,11 @@ size_.set_height(height() * sy); } -float FloatRect::SquaredDistanceTo(const FloatPoint& point) const { - FloatPoint closest_point; +float FloatRect::SquaredDistanceTo(const gfx::PointF& point) const { + gfx::PointF closest_point; closest_point.set_x(ClampTo<float>(point.x(), x(), right())); closest_point.set_y(ClampTo<float>(point.y(), y(), bottom())); - return (point - closest_point).DiagonalLengthSquared(); + return (point - closest_point).LengthSquared(); } FloatRect UnionRects(const Vector<FloatRect>& rects) { @@ -217,8 +218,8 @@ } IntRect EnclosedIntRect(const FloatRect& rect) { - gfx::Point location = CeiledIntPoint(rect.origin()); - gfx::Point max_point = FlooredIntPoint(rect.bottom_right()); + gfx::Point location = gfx::ToCeiledPoint(rect.origin()); + gfx::Point max_point = gfx::ToFlooredPoint(rect.bottom_right()); IntSize size(base::ClampSub(max_point.x(), location.x()), base::ClampSub(max_point.y(), location.y())); size.ClampNegativeToZero(); @@ -226,7 +227,8 @@ } IntRect RoundedIntRect(const FloatRect& rect) { - return IntRect(RoundedIntPoint(rect.origin()), RoundedIntSize(rect.size())); + return IntRect(gfx::ToRoundedPoint(rect.origin()), + RoundedIntSize(rect.size())); } FloatRect MapRect(const FloatRect& r, @@ -247,7 +249,7 @@ } String FloatRect::ToString() const { - return String::Format("%s %s", origin().ToString().Ascii().c_str(), + return String::Format("%s %s", origin().ToString().c_str(), size().ToString().Ascii().c_str()); }
diff --git a/third_party/blink/renderer/platform/geometry/float_rect.h b/third_party/blink/renderer/platform/geometry/float_rect.h index 94f6840..4ee2b8a5 100644 --- a/third_party/blink/renderer/platform/geometry/float_rect.h +++ b/third_party/blink/renderer/platform/geometry/float_rect.h
@@ -33,12 +33,14 @@ #include "base/dcheck_is_on.h" #include "base/numerics/clamped_math.h" #include "build/build_config.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_rect_outsets.h" +#include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/skia/include/core/SkRect.h" +#include "ui/gfx/geometry/point_conversions.h" +#include "ui/gfx/geometry/point_f.h" #include "ui/gfx/geometry/rect_f.h" #if defined(OS_MAC) @@ -56,10 +58,10 @@ public: constexpr FloatRect() = default; - constexpr FloatRect(const FloatPoint& location, const FloatSize& size) + constexpr FloatRect(const gfx::PointF& location, const FloatSize& size) : location_(location), size_(size) {} constexpr FloatRect(float x, float y, float width, float height) - : location_(FloatPoint(x, y)), size_(FloatSize(width, height)) {} + : location_(gfx::PointF(x, y)), size_(FloatSize(width, height)) {} constexpr explicit FloatRect(const IntRect& r) : FloatRect(r.x(), r.y(), r.width(), r.height()) {} constexpr explicit FloatRect(const gfx::RectF& r) @@ -72,10 +74,14 @@ double width, double height); - constexpr FloatPoint origin() const { return location_; } + constexpr gfx::PointF origin() const { return location_; } constexpr FloatSize size() const { return size_; } - void set_origin(const FloatPoint& location) { location_ = location; } + constexpr gfx::Vector2dF OffsetFromOrigin() const { + return location_.OffsetFromOrigin(); + } + + void set_origin(const gfx::PointF& location) { location_ = location; } void set_size(const FloatSize& size) { size_ = size; } constexpr float x() const { return location_.x(); } @@ -96,13 +102,14 @@ bool IsFinite() const; bool IsExpressibleAsIntRect() const; - FloatPoint CenterPoint() const { - return FloatPoint(x() + width() / 2, y() + height() / 2); + gfx::PointF CenterPoint() const { + return gfx::PointF(x() + width() / 2, y() + height() / 2); } - void Offset(const FloatSize& delta) { location_ += delta; } - void MoveBy(const FloatPoint& delta) { - location_.Offset(delta.x(), delta.y()); + void Offset(const FloatSize& delta) { location_ += ToGfxVector2dF(delta); } + void Offset(const gfx::Vector2dF& delta) { location_ += delta; } + void MoveBy(const gfx::PointF& delta) { + location_ += delta.OffsetFromOrigin(); } void Offset(float dx, float dy) { location_.Offset(dx, dy); } @@ -122,15 +129,15 @@ void ShiftYEdgeTo(float); void ShiftMaxYEdgeTo(float); - FloatPoint top_right() const { - return FloatPoint(location_.x() + size_.width(), location_.y()); + gfx::PointF top_right() const { + return gfx::PointF(location_.x() + size_.width(), location_.y()); } // typically topRight - FloatPoint bottom_left() const { - return FloatPoint(location_.x(), location_.y() + size_.height()); + gfx::PointF bottom_left() const { + return gfx::PointF(location_.x(), location_.y() + size_.height()); } // typically bottomLeft - FloatPoint bottom_right() const { - return FloatPoint(location_.x() + size_.width(), - location_.y() + size_.height()); + gfx::PointF bottom_right() const { + return gfx::PointF(location_.x() + size_.width(), + location_.y() + size_.height()); } // typically bottomRight WARN_UNUSED_RESULT bool Intersects(const IntRect&) const; @@ -144,10 +151,10 @@ void Union(const FloatRect&); void UnionEvenIfEmpty(const FloatRect&); void UnionIfNonZero(const FloatRect&); - void Extend(const FloatPoint&); + void Extend(const gfx::PointF&); // Returns true if |p| is in the rect or is on any of the edges of the rect. - bool InclusiveContains(const FloatPoint& p) const { + bool InclusiveContains(const gfx::PointF& p) const { return p.x() >= x() && p.x() <= right() && p.y() >= y() && p.y() <= bottom(); } @@ -168,10 +175,10 @@ void Scale(float sx, float sy); FloatRect TransposedRect() const { - return FloatRect(location_.TransposedPoint(), size_.TransposedSize()); + return FloatRect(gfx::TransposePoint(location_), size_.TransposedSize()); } - float SquaredDistanceTo(const FloatPoint&) const; + float SquaredDistanceTo(const gfx::PointF&) const; #if defined(OS_MAC) FloatRect(const CGRect&); @@ -194,7 +201,7 @@ String ToString() const; private: - FloatPoint location_; + gfx::PointF location_; FloatSize size_; void SetLocationAndSizeFromEdges(float left, @@ -229,7 +236,7 @@ } constexpr FloatRect operator+(const FloatRect& a, const FloatRect& b) { - return FloatRect(a.origin() + b.origin(), a.size() + b.size()); + return FloatRect(a.origin() + b.OffsetFromOrigin(), a.size() + b.size()); } constexpr bool operator==(const FloatRect& a, const FloatRect& b) { @@ -242,8 +249,8 @@ // Returns a IntRect containing the given FloatRect. inline IntRect EnclosingIntRect(const FloatRect& rect) { - gfx::Point location = FlooredIntPoint(rect.origin()); - gfx::Point max_point = CeiledIntPoint(rect.bottom_right()); + gfx::Point location = gfx::ToFlooredPoint(rect.origin()); + gfx::Point max_point = gfx::ToCeiledPoint(rect.bottom_right()); return IntRect(location, IntSize(base::ClampSub(max_point.x(), location.x()), base::ClampSub(max_point.y(), location.y())));
diff --git a/third_party/blink/renderer/platform/geometry/float_rect_test.cc b/third_party/blink/renderer/platform/geometry/float_rect_test.cc index d551077..8497f52 100644 --- a/third_party/blink/renderer/platform/geometry/float_rect_test.cc +++ b/third_party/blink/renderer/platform/geometry/float_rect_test.cc
@@ -6,9 +6,9 @@ #include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/geometry_test_helpers.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -30,107 +30,107 @@ FloatRect r1(100, 100, 250, 150); // `1` case - FloatPoint p1(80, 80); + gfx::PointF p1(80, 80); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p1), 800.f); - FloatPoint p2(-10, -10); + gfx::PointF p2(-10, -10); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p2), 24200.f); - FloatPoint p3(80, -10); + gfx::PointF p3(80, -10); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p3), 12500.f); // `2` case - FloatPoint p4(110, 80); + gfx::PointF p4(110, 80); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p4), 400.f); - FloatPoint p5(150, 0); + gfx::PointF p5(150, 0); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p5), 10000.f); - FloatPoint p6(180, -10); + gfx::PointF p6(180, -10); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p6), 12100.f); // `3` case - FloatPoint p7(400, 80); + gfx::PointF p7(400, 80); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p7), 2900.f); - FloatPoint p8(360, -10); + gfx::PointF p8(360, -10); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p8), 12200.f); // `4` case - FloatPoint p9(80, 110); + gfx::PointF p9(80, 110); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p9), 400.f); - FloatPoint p10(-10, 180); + gfx::PointF p10(-10, 180); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p10), 12100.f); // `5`(& In) case - FloatPoint p11(100, 100); + gfx::PointF p11(100, 100); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p11), 0.f); - FloatPoint p12(150, 100); + gfx::PointF p12(150, 100); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p12), 0.f); - FloatPoint p13(350, 100); + gfx::PointF p13(350, 100); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p13), 0.f); - FloatPoint p14(350, 150); + gfx::PointF p14(350, 150); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p14), 0.f); - FloatPoint p15(350, 250); + gfx::PointF p15(350, 250); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p15), 0.f); - FloatPoint p16(150, 250); + gfx::PointF p16(150, 250); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p16), 0.f); - FloatPoint p17(100, 250); + gfx::PointF p17(100, 250); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p17), 0.f); - FloatPoint p18(100, 150); + gfx::PointF p18(100, 150); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p18), 0.f); - FloatPoint p19(150, 150); + gfx::PointF p19(150, 150); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p19), 0.f); // `6` case - FloatPoint p20(380, 150); + gfx::PointF p20(380, 150); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p20), 900.f); // `7` case - FloatPoint p21(80, 280); + gfx::PointF p21(80, 280); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p21), 1300.f); - FloatPoint p22(-10, 300); + gfx::PointF p22(-10, 300); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p22), 14600.f); // `8` case - FloatPoint p23(180, 300); + gfx::PointF p23(180, 300); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p23), 2500.f); // `9` case - FloatPoint p24(450, 450); + gfx::PointF p24(450, 450); EXPECT_PRED_FORMAT2(geometry_test::AssertAlmostEqual, r1.SquaredDistanceTo(p24), 50000.f); }
diff --git a/third_party/blink/renderer/platform/geometry/float_rounded_rect.cc b/third_party/blink/renderer/platform/geometry/float_rounded_rect.cc index 5925c14..11b629264 100644 --- a/third_party/blink/renderer/platform/geometry/float_rounded_rect.cc +++ b/third_party/blink/renderer/platform/geometry/float_rounded_rect.cc
@@ -230,8 +230,8 @@ if (!top_left.IsEmpty()) { FloatRect rect(rect_.x(), rect_.y(), top_left.width(), top_left.height()); if (quad.IntersectsRect(rect)) { - FloatPoint center(rect_.x() + top_left.width(), - rect_.y() + top_left.height()); + gfx::PointF center(rect_.x() + top_left.width(), + rect_.y() + top_left.height()); FloatSize size(top_left.width(), top_left.height()); if (!quad.IntersectsEllipse(center, size)) return false; @@ -243,8 +243,8 @@ FloatRect rect(rect_.right() - top_right.width(), rect_.y(), top_right.width(), top_right.height()); if (quad.IntersectsRect(rect)) { - FloatPoint center(rect_.right() - top_right.width(), - rect_.y() + top_right.height()); + gfx::PointF center(rect_.right() - top_right.width(), + rect_.y() + top_right.height()); FloatSize size(top_right.width(), top_right.height()); if (!quad.IntersectsEllipse(center, size)) return false; @@ -256,8 +256,8 @@ FloatRect rect(rect_.x(), rect_.bottom() - bottom_left.height(), bottom_left.width(), bottom_left.height()); if (quad.IntersectsRect(rect)) { - FloatPoint center(rect_.x() + bottom_left.width(), - rect_.bottom() - bottom_left.height()); + gfx::PointF center(rect_.x() + bottom_left.width(), + rect_.bottom() - bottom_left.height()); FloatSize size(bottom_left.width(), bottom_left.height()); if (!quad.IntersectsEllipse(center, size)) return false; @@ -270,8 +270,8 @@ rect_.bottom() - bottom_right.height(), bottom_right.width(), bottom_right.height()); if (quad.IntersectsRect(rect)) { - FloatPoint center(rect_.right() - bottom_right.width(), - rect_.bottom() - bottom_right.height()); + gfx::PointF center(rect_.right() - bottom_right.width(), + rect_.bottom() - bottom_right.height()); FloatSize size(bottom_right.width(), bottom_right.height()); if (!quad.IntersectsEllipse(center, size)) return false;
diff --git a/third_party/blink/renderer/platform/geometry/float_shape_helpers.h b/third_party/blink/renderer/platform/geometry/float_shape_helpers.h deleted file mode 100644 index a2c3513e..0000000 --- a/third_party/blink/renderer/platform/geometry/float_shape_helpers.h +++ /dev/null
@@ -1,18 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GEOMETRY_FLOAT_SHAPE_HELPERS_H_ -#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GEOMETRY_FLOAT_SHAPE_HELPERS_H_ - -// Code that is useful for both FloatPolygon and FloatQuad. - -#include "third_party/blink/renderer/platform/geometry/float_size.h" - -namespace blink { -inline float Determinant(const FloatSize& a, const FloatSize& b) { - return a.width() * b.height() - a.height() * b.width(); -} -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GEOMETRY_FLOAT_SHAPE_HELPERS_H_
diff --git a/third_party/blink/renderer/platform/geometry/layout_point.cc b/third_party/blink/renderer/platform/geometry/layout_point.cc index e80bce8df..a464770c 100644 --- a/third_party/blink/renderer/platform/geometry/layout_point.cc +++ b/third_party/blink/renderer/platform/geometry/layout_point.cc
@@ -5,7 +5,6 @@ #include "third_party/blink/renderer/platform/geometry/layout_point.h" #include <algorithm> -#include "third_party/blink/renderer/platform/wtf/text/text_stream.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" namespace blink { @@ -27,8 +26,4 @@ Y().ToString().Ascii().c_str()); } -WTF::TextStream& operator<<(WTF::TextStream& ts, const LayoutPoint& point) { - return ts << FloatPoint(point); -} - } // namespace blink
diff --git a/third_party/blink/renderer/platform/geometry/layout_point.h b/third_party/blink/renderer/platform/geometry/layout_point.h index aecc49d8..57e09f4 100644 --- a/third_party/blink/renderer/platform/geometry/layout_point.h +++ b/third_party/blink/renderer/platform/geometry/layout_point.h
@@ -33,7 +33,6 @@ #include <iosfwd> #include "third_party/blink/renderer/platform/geometry/double_point.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/layout_size.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/forward.h" @@ -48,9 +47,7 @@ constexpr LayoutPoint() = default; constexpr LayoutPoint(LayoutUnit x, LayoutUnit y) : x_(x), y_(y) {} constexpr LayoutPoint(int x, int y) : x_(LayoutUnit(x)), y_(LayoutUnit(y)) {} - constexpr LayoutPoint(const gfx::Point& point) - : x_(point.x()), y_(point.y()) {} - constexpr explicit LayoutPoint(const FloatPoint& point) + constexpr explicit LayoutPoint(const gfx::Point& point) : x_(point.x()), y_(point.y()) {} constexpr explicit LayoutPoint(const gfx::PointF& point) : x_(point.x()), y_(point.y()) {} @@ -59,9 +56,6 @@ constexpr explicit LayoutPoint(const LayoutSize& size) : x_(size.Width()), y_(size.Height()) {} - constexpr explicit operator FloatPoint() const { - return FloatPoint(x_.ToFloat(), y_.ToFloat()); - } constexpr explicit operator gfx::PointF() const { return gfx::PointF(x_.ToFloat(), y_.ToFloat()); } @@ -195,12 +189,12 @@ return gfx::Point(point.X().Ceil(), point.Y().Ceil()); } -inline LayoutPoint FlooredLayoutPoint(const FloatPoint& p) { +inline LayoutPoint FlooredLayoutPoint(const gfx::PointF& p) { return LayoutPoint(LayoutUnit::FromFloatFloor(p.x()), LayoutUnit::FromFloatFloor(p.y())); } -inline LayoutPoint CeiledLayoutPoint(const FloatPoint& p) { +inline LayoutPoint CeiledLayoutPoint(const gfx::PointF& p) { return LayoutPoint(LayoutUnit::FromFloatCeil(p.x()), LayoutUnit::FromFloatCeil(p.y())); } @@ -219,12 +213,10 @@ } inline LayoutPoint FlooredLayoutPoint(const FloatSize& s) { - return FlooredLayoutPoint(FloatPoint(s)); + return FlooredLayoutPoint(gfx::PointF(s.width(), s.height())); } PLATFORM_EXPORT std::ostream& operator<<(std::ostream&, const LayoutPoint&); -PLATFORM_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, - const LayoutPoint&); } // namespace blink
diff --git a/third_party/blink/renderer/platform/geometry/layout_rect.h b/third_party/blink/renderer/platform/geometry/layout_rect.h index b1aa21c4..89aeb2c 100644 --- a/third_party/blink/renderer/platform/geometry/layout_rect.h +++ b/third_party/blink/renderer/platform/geometry/layout_rect.h
@@ -61,7 +61,7 @@ : location_(LayoutPoint(x, y)), size_(LayoutSize(width, height)) {} constexpr LayoutRect(int x, int y, int width, int height) : location_(LayoutPoint(x, y)), size_(LayoutSize(width, height)) {} - constexpr LayoutRect(const FloatPoint& location, const FloatSize& size) + constexpr LayoutRect(const gfx::PointF& location, const FloatSize& size) : location_(location), size_(size) {} constexpr LayoutRect(const DoublePoint& location, const DoubleSize& size) : location_(location), size_(size) {}
diff --git a/third_party/blink/renderer/platform/geometry/layout_size.h b/third_party/blink/renderer/platform/geometry/layout_size.h index 43747c90..2ae3a08 100644 --- a/third_party/blink/renderer/platform/geometry/layout_size.h +++ b/third_party/blink/renderer/platform/geometry/layout_size.h
@@ -33,12 +33,12 @@ #include <iosfwd> #include "third_party/blink/renderer/platform/geometry/double_size.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/geometry/int_size.h" #include "third_party/blink/renderer/platform/geometry/layout_unit.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/forward.h" +#include "ui/gfx/geometry/point_f.h" #include "ui/gfx/geometry/size_f.h" #include "ui/gfx/geometry/vector2d_f.h" @@ -68,8 +68,8 @@ constexpr explicit operator FloatSize() const { return FloatSize(width_.ToFloat(), height_.ToFloat()); } - constexpr explicit operator FloatPoint() const { - return FloatPoint(width_.ToFloat(), height_.ToFloat()); + constexpr explicit operator gfx::PointF() const { + return gfx::PointF(width_.ToFloat(), height_.ToFloat()); } constexpr explicit operator gfx::SizeF() const { return gfx::SizeF(width_.ToFloat(), height_.ToFloat()); @@ -208,8 +208,8 @@ return a.Width() != b.width() || a.Height() != b.height(); } -constexpr FloatPoint operator+(const FloatPoint& a, const LayoutSize& b) { - return FloatPoint(a.x() + b.Width(), a.y() + b.Height()); +constexpr gfx::PointF operator+(const gfx::PointF& a, const LayoutSize& b) { + return gfx::PointF(a.x() + b.Width(), a.y() + b.Height()); } inline IntSize FlooredIntSize(const LayoutSize& s) {
diff --git a/third_party/blink/renderer/platform/geometry/length_functions.cc b/third_party/blink/renderer/platform/geometry/length_functions.cc index 589d2e9e..f8aa3e02 100644 --- a/third_party/blink/renderer/platform/geometry/length_functions.cc +++ b/third_party/blink/renderer/platform/geometry/length_functions.cc
@@ -23,11 +23,11 @@ #include "third_party/blink/renderer/platform/geometry/length_functions.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/geometry/layout_unit.h" #include "third_party/blink/renderer/platform/geometry/length_point.h" #include "third_party/blink/renderer/platform/geometry/length_size.h" +#include "ui/gfx/geometry/point_f.h" namespace blink { @@ -124,10 +124,10 @@ FloatValueForLength(length_size.Height(), box_size.height())); } -FloatPoint FloatPointForLengthPoint(const LengthPoint& length_point, - const FloatSize& box_size) { - return FloatPoint(FloatValueForLength(length_point.X(), box_size.width()), - FloatValueForLength(length_point.Y(), box_size.height())); +gfx::PointF FloatPointForLengthPoint(const LengthPoint& length_point, + const FloatSize& box_size) { + return gfx::PointF(FloatValueForLength(length_point.X(), box_size.width()), + FloatValueForLength(length_point.Y(), box_size.height())); } } // namespace blink
diff --git a/third_party/blink/renderer/platform/geometry/length_functions.h b/third_party/blink/renderer/platform/geometry/length_functions.h index 1612b98..7c9f8ce4 100644 --- a/third_party/blink/renderer/platform/geometry/length_functions.h +++ b/third_party/blink/renderer/platform/geometry/length_functions.h
@@ -28,9 +28,12 @@ #include "third_party/blink/renderer/platform/geometry/length.h" #include "third_party/blink/renderer/platform/platform_export.h" +namespace gfx { +class PointF; +} + namespace blink { -class FloatPoint; class FloatSize; class LayoutUnit; class Length; @@ -55,8 +58,8 @@ LayoutUnit maximum_value); PLATFORM_EXPORT FloatSize FloatSizeForLengthSize(const LengthSize&, const FloatSize& box_size); -PLATFORM_EXPORT FloatPoint FloatPointForLengthPoint(const LengthPoint&, - const FloatSize& box_size); +PLATFORM_EXPORT gfx::PointF FloatPointForLengthPoint(const LengthPoint&, + const FloatSize& box_size); } // namespace blink
diff --git a/third_party/blink/renderer/platform/graphics/bitmap_image.cc b/third_party/blink/renderer/platform/graphics/bitmap_image.cc index eac8a15f..8643365b 100644 --- a/third_party/blink/renderer/platform/graphics/bitmap_image.cc +++ b/third_party/blink/renderer/platform/graphics/bitmap_image.cc
@@ -294,7 +294,7 @@ // ImageOrientation expects the origin to be at (0, 0) canvas->translate(adjusted_dst_rect.x(), adjusted_dst_rect.y()); - adjusted_dst_rect.set_origin(FloatPoint()); + adjusted_dst_rect.set_origin(gfx::PointF()); canvas->concat(AffineTransformToSkMatrix( orientation.TransformFromDefault(adjusted_dst_rect.size())));
diff --git a/third_party/blink/renderer/platform/graphics/compositing/layers_as_json.cc b/third_party/blink/renderer/platform/graphics/compositing/layers_as_json.cc index f780e04..ea684c61 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/layers_as_json.cc +++ b/third_party/blink/renderer/platform/graphics/compositing/layers_as_json.cc
@@ -5,12 +5,12 @@ #include "third_party/blink/renderer/platform/graphics/compositing/layers_as_json.h" #include "cc/layers/layer.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/geometry_as_json.h" #include "third_party/blink/renderer/platform/graphics/color.h" #include "third_party/blink/renderer/platform/graphics/graphics_types.h" #include "third_party/blink/renderer/platform/graphics/paint/transform_paint_property_node.h" #include "third_party/blink/renderer/platform/wtf/text/text_stream.h" +#include "ui/gfx/geometry/point_f.h" namespace blink {
diff --git a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc index e8817e4..d0be373 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc +++ b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc
@@ -1233,14 +1233,14 @@ bool PaintArtifactCompositor::DirectlySetScrollOffset( CompositorElementId element_id, - const FloatPoint& scroll_offset) { + const gfx::PointF& scroll_offset) { if (!root_layer_ || !root_layer_->layer_tree_host()) return false; auto* property_trees = root_layer_->layer_tree_host()->property_trees(); if (!property_trees->element_id_to_scroll_node_index.contains(element_id)) return false; - PropertyTreeManager::DirectlySetScrollOffset( - *root_layer_->layer_tree_host(), element_id, ToGfxPointF(scroll_offset)); + PropertyTreeManager::DirectlySetScrollOffset(*root_layer_->layer_tree_host(), + element_id, scroll_offset); return true; }
diff --git a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h index 5801379..fdf3d1c 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h +++ b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h
@@ -179,7 +179,7 @@ // cc::TransformNode::scroll_offset (which will be synched with blink // transform node in DirectlyUpdateScrollOffsetTransform() or Update()). bool DirectlySetScrollOffset(CompositorElementId, - const FloatPoint& scroll_offset); + const gfx::PointF& scroll_offset); // The root layer of the tree managed by this object. cc::Layer* RootLayer() const { return root_layer_.get(); }
diff --git a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc index 922500189..7f5280e 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc +++ b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc
@@ -4531,7 +4531,7 @@ ASSERT_FALSE(transform_tree.needs_update()); ASSERT_TRUE(GetPaintArtifactCompositor().DirectlySetScrollOffset( - scroll_element_id, FloatPoint(-10, -20))); + scroll_element_id, gfx::PointF(-10, -20))); EXPECT_TRUE( host.pending_commit_state()->layers_that_should_push_properties.contains( scroll_layer));
diff --git a/third_party/blink/renderer/platform/graphics/compositing/paint_chunks_to_cc_layer.cc b/third_party/blink/renderer/platform/graphics/compositing/paint_chunks_to_cc_layer.cc index c70eabd..07031fff3 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/paint_chunks_to_cc_layer.cc +++ b/third_party/blink/renderer/platform/graphics/compositing/paint_chunks_to_cc_layer.cc
@@ -578,8 +578,7 @@ // with empty bounds, with a filter applied that produces output even when // there's no input this will expand the bounds to match. gfx::RectF filtered_bounds = current_effect_->MapRect( - gfx::RectF(ToGfxPointF(effect.Filter().ReferenceBox().CenterPoint()), - gfx::SizeF())); + gfx::RectF(effect.Filter().ReferenceBox().CenterPoint(), gfx::SizeF())); effect_bounds_stack_.back().bounds = filtered_bounds; // Emit an empty paint operation to add the filtered bounds (mapped to layer // space) to the visual rect of the filter's SaveLayerOp.
diff --git a/third_party/blink/renderer/platform/graphics/crossfade_generated_image.cc b/third_party/blink/renderer/platform/graphics/crossfade_generated_image.cc index f2f646dd..921e40c 100644 --- a/third_party/blink/renderer/platform/graphics/crossfade_generated_image.cc +++ b/third_party/blink/renderer/platform/graphics/crossfade_generated_image.cc
@@ -46,9 +46,9 @@ cc::PaintCanvas* canvas, const PaintFlags& flags, const ImageDrawOptions& draw_options) { - FloatRect from_image_rect(FloatPoint(), FloatSize(from_image_->Size())); - FloatRect to_image_rect(FloatPoint(), FloatSize(to_image_->Size())); - FloatRect dest_rect((FloatPoint()), size_); + FloatRect from_image_rect(gfx::PointF(), FloatSize(from_image_->Size())); + FloatRect to_image_rect(gfx::PointF(), FloatSize(to_image_->Size())); + FloatRect dest_rect((gfx::PointF()), size_); // TODO(junov): The various effects encoded into paint should probably be // applied here instead of inside the layer. This probably faulty behavior @@ -98,7 +98,7 @@ return; PaintFlags flags = context.FillFlags(); flags.setBlendMode(SkBlendMode::kSrcOver); - FloatRect dest_rect((FloatPoint()), size_); + FloatRect dest_rect((gfx::PointF()), size_); ImageDrawOptions draw_options(options); draw_options.sampling_options = context.ComputeSamplingOptions(this, dest_rect, src_rect);
diff --git a/third_party/blink/renderer/platform/graphics/draw_looper_builder.cc b/third_party/blink/renderer/platform/graphics/draw_looper_builder.cc index 9b2d5e9..68c2a6d 100644 --- a/third_party/blink/renderer/platform/graphics/draw_looper_builder.cc +++ b/third_party/blink/renderer/platform/graphics/draw_looper_builder.cc
@@ -56,7 +56,7 @@ sk_draw_looper_builder_.addLayerOnTop(info); } -void DrawLooperBuilder::AddShadow(const FloatSize& offset, +void DrawLooperBuilder::AddShadow(const gfx::Vector2dF& offset, float blur, const Color& color, ShadowTransformMode shadow_transform_mode, @@ -85,7 +85,7 @@ if (blur) info.fPaintBits |= SkLayerDrawLooper::kMaskFilter_Bit; // our blur info.fPaintBits |= SkLayerDrawLooper::kColorFilter_Bit; - info.fOffset.set(offset.width(), offset.height()); + info.fOffset.set(offset.x(), offset.y()); info.fPostTranslate = (shadow_transform_mode == kShadowIgnoresTransforms); SkPaint* paint = sk_draw_looper_builder_.addLayerOnTop(info);
diff --git a/third_party/blink/renderer/platform/graphics/draw_looper_builder.h b/third_party/blink/renderer/platform/graphics/draw_looper_builder.h index 84a3275..a13a592 100644 --- a/third_party/blink/renderer/platform/graphics/draw_looper_builder.h +++ b/third_party/blink/renderer/platform/graphics/draw_looper_builder.h
@@ -38,10 +38,13 @@ class SkDrawLooper; +namespace gfx { +class Vector2dF; +} + namespace blink { class Color; -class FloatSize; class PLATFORM_EXPORT DrawLooperBuilder final { STACK_ALLOCATED(); @@ -66,7 +69,7 @@ sk_sp<SkDrawLooper> DetachDrawLooper(); void AddUnmodifiedContent(); - void AddShadow(const FloatSize& offset, + void AddShadow(const gfx::Vector2dF& offset, float blur, const Color&, ShadowTransformMode = kShadowRespectsTransforms,
diff --git a/third_party/blink/renderer/platform/graphics/filters/fe_drop_shadow.cc b/third_party/blink/renderer/platform/graphics/filters/fe_drop_shadow.cc index 3d86184..3688090 100644 --- a/third_party/blink/renderer/platform/graphics/filters/fe_drop_shadow.cc +++ b/third_party/blink/renderer/platform/graphics/filters/fe_drop_shadow.cc
@@ -44,10 +44,10 @@ shadow_opacity_(shadow_opacity) {} FloatRect FEDropShadow::MapEffect(const FloatSize& std_deviation, - const FloatPoint& offset, + const gfx::PointF& offset, const FloatRect& rect) { FloatRect offset_rect = rect; - offset_rect.MoveBy(offset); + offset_rect.Offset(offset.OffsetFromOrigin()); FloatRect blurred_rect = FEGaussianBlur::MapEffect(std_deviation, offset_rect); return UnionRects(blurred_rect, rect); @@ -56,8 +56,8 @@ FloatRect FEDropShadow::MapEffect(const FloatRect& rect) const { const Filter* filter = GetFilter(); DCHECK(filter); - FloatPoint offset(filter->ApplyHorizontalScale(dx_), - filter->ApplyVerticalScale(dy_)); + gfx::PointF offset(filter->ApplyHorizontalScale(dx_), + filter->ApplyVerticalScale(dy_)); FloatSize std_error(filter->ApplyHorizontalScale(std_x_), filter->ApplyVerticalScale(std_y_)); return MapEffect(std_error, offset, rect);
diff --git a/third_party/blink/renderer/platform/graphics/filters/fe_drop_shadow.h b/third_party/blink/renderer/platform/graphics/filters/fe_drop_shadow.h index 16ef4d2..bfda001 100644 --- a/third_party/blink/renderer/platform/graphics/filters/fe_drop_shadow.h +++ b/third_party/blink/renderer/platform/graphics/filters/fe_drop_shadow.h
@@ -33,7 +33,7 @@ // Compute which destination area will be affected when applying a drop // shadow effect with |stdDeviation| and |offset| to an area |rect|. static FloatRect MapEffect(const FloatSize& std_deviation, - const FloatPoint& offset, + const gfx::PointF& offset, const FloatRect&); void SetShadowColor(const Color& color) { shadow_color_ = color; }
diff --git a/third_party/blink/renderer/platform/graphics/gpu/image_layer_bridge.cc b/third_party/blink/renderer/platform/graphics/gpu/image_layer_bridge.cc index 2205f60..dfdfed70 100644 --- a/third_party/blink/renderer/platform/graphics/gpu/image_layer_bridge.cc +++ b/third_party/blink/renderer/platform/graphics/gpu/image_layer_bridge.cc
@@ -107,12 +107,12 @@ has_presented_since_last_set_image_ = false; } -void ImageLayerBridge::SetUV(const FloatPoint& left_top, - const FloatPoint& right_bottom) { +void ImageLayerBridge::SetUV(const gfx::PointF& left_top, + const gfx::PointF& right_bottom) { if (disposed_) return; - layer_->SetUV(ToGfxPointF(left_top), ToGfxPointF(right_bottom)); + layer_->SetUV(left_top, right_bottom); } void ImageLayerBridge::Dispose() {
diff --git a/third_party/blink/renderer/platform/graphics/gpu/image_layer_bridge.h b/third_party/blink/renderer/platform/graphics/gpu/image_layer_bridge.h index 3707806..d245132 100644 --- a/third_party/blink/renderer/platform/graphics/gpu/image_layer_bridge.h +++ b/third_party/blink/renderer/platform/graphics/gpu/image_layer_bridge.h
@@ -8,11 +8,11 @@ #include "cc/layers/texture_layer_client.h" #include "cc/resources/shared_bitmap_id_registrar.h" #include "components/viz/common/resources/resource_format.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/graphics/graphics_types.h" #include "third_party/blink/renderer/platform/graphics/static_bitmap_image.h" #include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/platform_export.h" +#include "ui/gfx/geometry/point_f.h" namespace cc { class CrossThreadSharedBitmap; @@ -51,7 +51,7 @@ void SetFilterQuality(cc::PaintFlags::FilterQuality filter_quality) { filter_quality_ = filter_quality; } - void SetUV(const FloatPoint& left_top, const FloatPoint& right_bottom); + void SetUV(const gfx::PointF& left_top, const gfx::PointF& right_bottom); bool IsAccelerated() { return image_ && image_->IsTextureBacked(); }
diff --git a/third_party/blink/renderer/platform/graphics/gradient.cc b/third_party/blink/renderer/platform/graphics/gradient.cc index 4c1b779..79db7ad9 100644 --- a/third_party/blink/renderer/platform/graphics/gradient.cc +++ b/third_party/blink/renderer/platform/graphics/gradient.cc
@@ -203,8 +203,8 @@ class LinearGradient final : public Gradient { public: - LinearGradient(const FloatPoint& p0, - const FloatPoint& p1, + LinearGradient(const gfx::PointF& p0, + const gfx::PointF& p1, GradientSpreadMethod spread_method, ColorInterpolation interpolation, DegenerateHandling degenerate_handling) @@ -234,15 +234,15 @@ } private: - const FloatPoint p0_; - const FloatPoint p1_; + const gfx::PointF p0_; + const gfx::PointF p1_; }; class RadialGradient final : public Gradient { public: - RadialGradient(const FloatPoint& p0, + RadialGradient(const gfx::PointF& p0, float r0, - const FloatPoint& p1, + const gfx::PointF& p1, float r1, float aspect_ratio, GradientSpreadMethod spread_method, @@ -293,8 +293,8 @@ } private: - const FloatPoint p0_; - const FloatPoint p1_; + const gfx::PointF p0_; + const gfx::PointF p1_; const float r0_; const float r1_; const float aspect_ratio_; // For elliptical gradient, width / height. @@ -302,7 +302,7 @@ class ConicGradient final : public Gradient { public: - ConicGradient(const FloatPoint& position, + ConicGradient(const gfx::PointF& position, float rotation, float start_angle, float end_angle, @@ -348,7 +348,7 @@ } private: - const FloatPoint position_; // center point + const gfx::PointF position_; // center point const float rotation_; // global rotation (deg) const float start_angle_; // angle (deg) corresponding to color position 0 const float end_angle_; // angle (deg) corresponding to color position 1 @@ -357,8 +357,8 @@ } // namespace scoped_refptr<Gradient> Gradient::CreateLinear( - const FloatPoint& p0, - const FloatPoint& p1, + const gfx::PointF& p0, + const gfx::PointF& p1, GradientSpreadMethod spread_method, ColorInterpolation interpolation, DegenerateHandling degenerate_handling) { @@ -367,9 +367,9 @@ } scoped_refptr<Gradient> Gradient::CreateRadial( - const FloatPoint& p0, + const gfx::PointF& p0, float r0, - const FloatPoint& p1, + const gfx::PointF& p1, float r1, float aspect_ratio, GradientSpreadMethod spread_method, @@ -381,7 +381,7 @@ } scoped_refptr<Gradient> Gradient::CreateConic( - const FloatPoint& position, + const gfx::PointF& position, float rotation, float start_angle, float end_angle,
diff --git a/third_party/blink/renderer/platform/graphics/gradient.h b/third_party/blink/renderer/platform/graphics/gradient.h index c9e77c2..f040a1cc2 100644 --- a/third_party/blink/renderer/platform/graphics/gradient.h +++ b/third_party/blink/renderer/platform/graphics/gradient.h
@@ -43,9 +43,12 @@ class SkMatrix; +namespace gfx { +class PointF; +} + namespace blink { -class FloatPoint; struct ImageDrawOptions; class PLATFORM_EXPORT Gradient : public RefCounted<Gradient> { @@ -65,16 +68,16 @@ }; static scoped_refptr<Gradient> CreateLinear( - const FloatPoint& p0, - const FloatPoint& p1, + const gfx::PointF& p0, + const gfx::PointF& p1, GradientSpreadMethod = kSpreadMethodPad, ColorInterpolation = ColorInterpolation::kUnpremultiplied, DegenerateHandling = DegenerateHandling::kAllow); static scoped_refptr<Gradient> CreateRadial( - const FloatPoint& p0, + const gfx::PointF& p0, float r0, - const FloatPoint& p1, + const gfx::PointF& p1, float r1, float aspect_ratio = 1, GradientSpreadMethod = kSpreadMethodPad, @@ -82,7 +85,7 @@ DegenerateHandling = DegenerateHandling::kAllow); static scoped_refptr<Gradient> CreateConic( - const FloatPoint& position, + const gfx::PointF& position, float rotation, float start_angle, float end_angle,
diff --git a/third_party/blink/renderer/platform/graphics/graphics_context.cc b/third_party/blink/renderer/platform/graphics/graphics_context.cc index ad33a1e..323d6e9 100644 --- a/third_party/blink/renderer/platform/graphics/graphics_context.cc +++ b/third_party/blink/renderer/platform/graphics/graphics_context.cc
@@ -68,7 +68,7 @@ namespace { -SkRect GetRectForTextLine(FloatPoint pt, float width, float stroke_thickness) { +SkRect GetRectForTextLine(gfx::PointF pt, float width, float stroke_thickness) { int thickness = std::max(static_cast<int>(stroke_thickness), 1); SkRect r; r.fLeft = WebCoreFloatToSkScalar(pt.x()); @@ -80,7 +80,7 @@ return r; } -std::pair<gfx::Point, gfx::Point> GetPointsForTextLine(FloatPoint pt, +std::pair<gfx::Point, gfx::Point> GetPointsForTextLine(gfx::PointF pt, float width, float stroke_thickness) { int y = floorf(pt.y() + std::max<float>(stroke_thickness / 2.0f, 0.5f)); @@ -359,8 +359,8 @@ } static void EnforceDotsAtEndpoints(GraphicsContext& context, - FloatPoint& p1, - FloatPoint& p2, + gfx::PointF& p1, + gfx::PointF& p2, const int path_length, const int width, const PaintFlags& flags, @@ -468,16 +468,16 @@ if (pen_style == kNoStroke) return; - FloatPoint p1 = FloatPoint(point1); - FloatPoint p2 = FloatPoint(point2); + gfx::PointF p1 = gfx::PointF(point1); + gfx::PointF p2 = gfx::PointF(point2); bool is_vertical_line = (p1.x() == p2.x()); int width = roundf(StrokeThickness()); // We know these are vertical or horizontal lines, so the length will just // be the sum of the displacement component vectors give or take 1 - // probably worth the speed up of no square root, which also won't be exact. - FloatSize disp = p2 - p1; - int length = SkScalarRoundToInt(disp.width() + disp.height()); + gfx::Vector2dF disp = p2 - p1; + int length = SkScalarRoundToInt(disp.x() + disp.y()); const DarkModeFlags flags(this, auto_dark_mode, paint_flags ? *paint_flags @@ -513,7 +513,7 @@ canvas_->drawLine(p1.x(), p1.y(), p2.x(), p2.y(), flags); } -void GraphicsContext::DrawLineForText(const FloatPoint& pt, +void GraphicsContext::DrawLineForText(const gfx::PointF& pt, float width, const AutoDarkMode& auto_dark_mode, const PaintFlags* paint_flags) { @@ -566,7 +566,7 @@ void GraphicsContext::DrawText(const Font& font, const TextRunPaintInfo& text_info, - const FloatPoint& point, + const gfx::PointF& point, const PaintFlags& flags, DOMNodeId node_id, const AutoDarkMode& auto_dark_mode) { @@ -578,7 +578,7 @@ void GraphicsContext::DrawText(const Font& font, const NGTextFragmentPaintInfo& text_info, - const FloatPoint& point, + const gfx::PointF& point, const PaintFlags& flags, DOMNodeId node_id, const AutoDarkMode& auto_dark_mode) { @@ -619,7 +619,7 @@ template <typename TextPaintInfo> void GraphicsContext::DrawTextInternal(const Font& font, const TextPaintInfo& text_info, - const FloatPoint& point, + const gfx::PointF& point, DOMNodeId node_id, const AutoDarkMode& auto_dark_mode) { DrawTextPasses(auto_dark_mode, [&](const PaintFlags& flags) { @@ -650,7 +650,7 @@ void GraphicsContext::DrawText(const Font& font, const TextRunPaintInfo& text_info, - const FloatPoint& point, + const gfx::PointF& point, DOMNodeId node_id, const AutoDarkMode& auto_dark_mode) { DrawTextInternal(font, text_info, point, node_id, auto_dark_mode); @@ -658,7 +658,7 @@ void GraphicsContext::DrawText(const Font& font, const NGTextFragmentPaintInfo& text_info, - const FloatPoint& point, + const gfx::PointF& point, DOMNodeId node_id, const AutoDarkMode& auto_dark_mode) { DrawTextInternal(font, text_info, point, node_id, auto_dark_mode); @@ -669,7 +669,7 @@ const Font& font, const TextPaintInfo& text_info, const AtomicString& mark, - const FloatPoint& point, + const gfx::PointF& point, const AutoDarkMode& auto_dark_mode) { DrawTextPasses(auto_dark_mode, [&font, &text_info, &mark, &point, this](const PaintFlags& flags) { @@ -681,7 +681,7 @@ void GraphicsContext::DrawEmphasisMarks(const Font& font, const TextRunPaintInfo& text_info, const AtomicString& mark, - const FloatPoint& point, + const gfx::PointF& point, const AutoDarkMode& auto_dark_mode) { DrawEmphasisMarksInternal(font, text_info, mark, point, auto_dark_mode); } @@ -690,7 +690,7 @@ const Font& font, const NGTextFragmentPaintInfo& text_info, const AtomicString& mark, - const FloatPoint& point, + const gfx::PointF& point, const AutoDarkMode& auto_dark_mode) { DrawEmphasisMarksInternal(font, text_info, mark, point, auto_dark_mode); } @@ -698,7 +698,7 @@ void GraphicsContext::DrawBidiText( const Font& font, const TextRunPaintInfo& run_info, - const FloatPoint& point, + const gfx::PointF& point, const AutoDarkMode& auto_dark_mode, Font::CustomFontNotReadyAction custom_font_not_ready_action) { DrawTextPasses( @@ -716,7 +716,7 @@ void GraphicsContext::DrawHighlightForText(const Font& font, const TextRun& run, - const FloatPoint& point, + const gfx::PointF& point, int h, const Color& background_color, const AutoDarkMode& auto_dark_mode, @@ -954,11 +954,12 @@ const FloatRoundedRect& inner) { // A DRRect is "simple" (i.e. can be drawn as a rrect stroke) if // 1) all sides have the same width - const FloatSize stroke_size = inner.Rect().origin() - outer.Rect().origin(); + const gfx::Vector2dF stroke_size = + inner.Rect().origin() - outer.Rect().origin(); if (!WebCoreFloatNearlyEqual(stroke_size.AspectRatio(), 1) || - !WebCoreFloatNearlyEqual(stroke_size.width(), + !WebCoreFloatNearlyEqual(stroke_size.x(), outer.Rect().right() - inner.Rect().right()) || - !WebCoreFloatNearlyEqual(stroke_size.height(), + !WebCoreFloatNearlyEqual(stroke_size.y(), outer.Rect().bottom() - inner.Rect().bottom())) { return false; } @@ -976,7 +977,7 @@ return WebCoreFloatNearlyEqual(outer.width(), outer.height()) && WebCoreFloatNearlyEqual(inner.width(), inner.height()) && WebCoreFloatNearlyEqual(outer.width(), - inner.width() + stroke_size.width()); + inner.width() + stroke_size.x()); }; const auto& o_radii = outer.GetRadii(); @@ -1185,8 +1186,8 @@ Concat(AffineTransformToSkMatrix(affine)); } -void GraphicsContext::AdjustLineToPixelBoundaries(FloatPoint& p1, - FloatPoint& p2, +void GraphicsContext::AdjustLineToPixelBoundaries(gfx::PointF& p1, + gfx::PointF& p2, float stroke_width) { // For odd widths, we add in 0.5 to the appropriate x/y so that the float // arithmetic works out. For example, with a border width of 3, painting will @@ -1206,7 +1207,7 @@ } } -Path GraphicsContext::GetPathForTextLine(const FloatPoint& pt, +Path GraphicsContext::GetPathForTextLine(const gfx::PointF& pt, float width, float stroke_thickness, StrokeStyle stroke_style) { @@ -1216,8 +1217,8 @@ gfx::Point start; gfx::Point end; std::tie(start, end) = GetPointsForTextLine(pt, width, stroke_thickness); - path.MoveTo(ToGfxPointF(FloatPoint(start))); - path.AddLineTo(ToGfxPointF(FloatPoint(end))); + path.MoveTo(gfx::PointF(start)); + path.AddLineTo(gfx::PointF(end)); } else { path.AddRect(GetRectForTextLine(pt, width, stroke_thickness)); }
diff --git a/third_party/blink/renderer/platform/graphics/graphics_context.h b/third_party/blink/renderer/platform/graphics/graphics_context.h index 0119d2d..ad294420d 100644 --- a/third_party/blink/renderer/platform/graphics/graphics_context.h +++ b/third_party/blink/renderer/platform/graphics/graphics_context.h
@@ -78,7 +78,7 @@ FloatSize scale{1.0f, 1.0f}; // Origin of the full image in destination space. - FloatPoint phase; + gfx::PointF phase; // Additional spacing between tiles in destination space. FloatSize spacing; @@ -352,12 +352,12 @@ void DrawText(const Font&, const TextRunPaintInfo&, - const FloatPoint&, + const gfx::PointF&, DOMNodeId, const AutoDarkMode& auto_dark_mode); void DrawText(const Font&, const NGTextFragmentPaintInfo&, - const FloatPoint&, + const gfx::PointF&, DOMNodeId, const AutoDarkMode& auto_dark_mode); @@ -365,7 +365,7 @@ // if we can change that to use the four parameter version above. void DrawText(const Font&, const TextRunPaintInfo&, - const FloatPoint&, + const gfx::PointF&, const PaintFlags&, DOMNodeId, const AutoDarkMode& auto_dark_mode); @@ -374,7 +374,7 @@ // four parameter overload can be removed or if it can wrap this method. void DrawText(const Font&, const NGTextFragmentPaintInfo&, - const FloatPoint&, + const gfx::PointF&, const PaintFlags&, DOMNodeId, const AutoDarkMode& auto_dark_mode); @@ -382,30 +382,30 @@ void DrawEmphasisMarks(const Font&, const TextRunPaintInfo&, const AtomicString& mark, - const FloatPoint&, + const gfx::PointF&, const AutoDarkMode& auto_dark_mode); void DrawEmphasisMarks(const Font&, const NGTextFragmentPaintInfo&, const AtomicString& mark, - const FloatPoint&, + const gfx::PointF&, const AutoDarkMode& auto_dark_mode); void DrawBidiText( const Font&, const TextRunPaintInfo&, - const FloatPoint&, + const gfx::PointF&, const AutoDarkMode& auto_dark_mode, Font::CustomFontNotReadyAction = Font::kDoNotPaintIfFontNotReady); void DrawHighlightForText(const Font&, const TextRun&, - const FloatPoint&, + const gfx::PointF&, int h, const Color& background_color, const AutoDarkMode& auto_dark_mode, int from = 0, int to = -1); - void DrawLineForText(const FloatPoint&, + void DrawLineForText(const gfx::PointF&, float width, const AutoDarkMode& auto_dark_mode, const PaintFlags* flags = nullptr); @@ -483,11 +483,11 @@ // Sets location of a URL destination (a.k.a. anchor) in the page. void SetURLDestinationLocation(const String& name, const gfx::Point&); - static void AdjustLineToPixelBoundaries(FloatPoint& p1, - FloatPoint& p2, + static void AdjustLineToPixelBoundaries(gfx::PointF& p1, + gfx::PointF& p2, float stroke_width); - static Path GetPathForTextLine(const FloatPoint&, + static Path GetPathForTextLine(const gfx::PointF&, float width, float stroke_thickness, StrokeStyle); @@ -516,7 +516,7 @@ template <typename TextPaintInfo> void DrawTextInternal(const Font&, const TextPaintInfo&, - const FloatPoint&, + const gfx::PointF&, DOMNodeId, const AutoDarkMode& auto_dark_mode); @@ -524,7 +524,7 @@ void DrawEmphasisMarksInternal(const Font&, const TextPaintInfo&, const AtomicString& mark, - const FloatPoint&, + const gfx::PointF&, const AutoDarkMode& auto_dark_mode); template <typename DrawTextFunc>
diff --git a/third_party/blink/renderer/platform/graphics/graphics_layer.h b/third_party/blink/renderer/platform/graphics/graphics_layer.h index 290c6c6..a970a2e6 100644 --- a/third_party/blink/renderer/platform/graphics/graphics_layer.h +++ b/third_party/blink/renderer/platform/graphics/graphics_layer.h
@@ -33,7 +33,6 @@ #include "cc/input/scroll_snap_data.h" #include "cc/layers/content_layer_client.h" #include "cc/layers/layer.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_point_3d.h" #include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/geometry/int_rect.h" @@ -55,6 +54,7 @@ #include "third_party/blink/renderer/platform/transforms/transformation_matrix.h" #include "third_party/blink/renderer/platform/wtf/vector.h" #include "third_party/skia/include/core/SkRefCnt.h" +#include "ui/gfx/geometry/point_f.h" namespace cc { class DisplayItemList;
diff --git a/third_party/blink/renderer/platform/graphics/image.cc b/third_party/blink/renderer/platform/graphics/image.cc index 77e0352b..4fd5aa8 100644 --- a/third_party/blink/renderer/platform/graphics/image.cc +++ b/third_party/blink/renderer/platform/graphics/image.cc
@@ -36,7 +36,6 @@ #include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/web_data.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/geometry/length.h" @@ -59,6 +58,7 @@ #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkSurface.h" +#include "ui/gfx/geometry/point_f.h" namespace blink {
diff --git a/third_party/blink/renderer/platform/graphics/image.h b/third_party/blink/renderer/platform/graphics/image.h index d875a59..12dae0b 100644 --- a/third_party/blink/renderer/platform/graphics/image.h +++ b/third_party/blink/renderer/platform/graphics/image.h
@@ -30,7 +30,6 @@ #include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" #include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink-forward.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/graphics/graphics_types.h" @@ -44,6 +43,7 @@ #include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h" #include "third_party/skia/include/core/SkRefCnt.h" #include "ui/base/resource/resource_scale_factor.h" +#include "ui/gfx/geometry/point_f.h" class SkMatrix;
diff --git a/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator_test.cc b/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator_test.cc index 26dad1a..c7c422da 100644 --- a/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator_test.cc +++ b/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator_test.cc
@@ -6,12 +6,12 @@ #include "base/callback_helpers.h" #include "testing/gmock/include/gmock/gmock.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_artifact.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_controller_test.h" #include "third_party/blink/renderer/platform/testing/paint_property_test_helpers.h" #include "third_party/blink/renderer/platform/testing/paint_test_configurations.h" #include "third_party/blink/renderer/platform/testing/test_paint_artifact.h" +#include "ui/gfx/geometry/point_f.h" namespace blink {
diff --git a/third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h b/third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h index 3600eaed..8909d86 100644 --- a/third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h +++ b/third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h
@@ -110,11 +110,6 @@ rect.Map(Matrix()); } - FloatPoint MapPoint(const FloatPoint& point) const { - if (LIKELY(IsIdentityOr2DTranslation())) - return point + FloatSize(Translation2D()); - return Matrix().MapPoint(point); - } gfx::PointF MapPoint(const gfx::PointF& point) const { if (LIKELY(IsIdentityOr2DTranslation())) return point + Translation2D();
diff --git a/third_party/blink/renderer/platform/graphics/path.cc b/third_party/blink/renderer/platform/graphics/path.cc index 3b21f9d..d0da3b5d 100644 --- a/third_party/blink/renderer/platform/graphics/path.cc +++ b/third_party/blink/renderer/platform/graphics/path.cc
@@ -30,7 +30,6 @@ #include "third_party/blink/renderer/platform/graphics/path.h" #include <math.h> -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/graphics/graphics_context.h" #include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h"
diff --git a/third_party/blink/renderer/platform/graphics/picture_snapshot.h b/third_party/blink/renderer/platform/graphics/picture_snapshot.h index 9ea4fa07..c0433fa 100644 --- a/third_party/blink/renderer/platform/graphics/picture_snapshot.h +++ b/third_party/blink/renderer/platform/graphics/picture_snapshot.h
@@ -52,7 +52,7 @@ public: struct TilePictureStream : RefCounted<TilePictureStream> { - FloatPoint layer_offset; + gfx::PointF layer_offset; sk_sp<SkPicture> picture; };
diff --git a/third_party/blink/renderer/platform/graphics/placeholder_image.cc b/third_party/blink/renderer/platform/graphics/placeholder_image.cc index c650180f..0535942e 100644 --- a/third_party/blink/renderer/platform/graphics/placeholder_image.cc +++ b/third_party/blink/renderer/platform/graphics/placeholder_image.cc
@@ -14,7 +14,6 @@ #include "third_party/blink/renderer/platform/fonts/font_family.h" #include "third_party/blink/renderer/platform/fonts/font_selection_types.h" #include "third_party/blink/renderer/platform/fonts/text_run_paint_info.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/graphics/bitmap_image.h" @@ -32,6 +31,7 @@ #include "third_party/skia/include/core/SkRect.h" #include "third_party/skia/include/core/SkSize.h" #include "ui/gfx/geometry/point.h" +#include "ui/gfx/geometry/point_f.h" #include "ui/gfx/geometry/skia_conversions.h" namespace blink { @@ -349,8 +349,8 @@ flags.setColor(SkColorSetARGB(0xAB, 0, 0, 0)); shared_font_->font().DrawBidiText( canvas, TextRunPaintInfo(TextRun(text_)), - FloatPoint(text_x, feature_y + icon_and_text_scale_factor_ * - (kTextPaddingY + kFontSize)), + gfx::PointF(text_x, feature_y + icon_and_text_scale_factor_ * + (kTextPaddingY + kFontSize)), Font::kUseFallbackIfFontNotReady, 1.0f, flags); }
diff --git a/third_party/blink/renderer/platform/graphics/skia/skia_utils.h b/third_party/blink/renderer/platform/graphics/skia/skia_utils.h index b53bb9b..19ca998 100644 --- a/third_party/blink/renderer/platform/graphics/skia/skia_utils.h +++ b/third_party/blink/renderer/platform/graphics/skia/skia_utils.h
@@ -113,7 +113,7 @@ return RULE_NONZERO; } -inline SkPoint FloatPointToSkPoint(const FloatPoint& point) { +inline SkPoint FloatPointToSkPoint(const gfx::PointF& point) { return SkPoint::Make(WebCoreFloatToSkScalar(point.x()), WebCoreFloatToSkScalar(point.y())); }
diff --git a/third_party/blink/renderer/platform/graphics/static_bitmap_image.cc b/third_party/blink/renderer/platform/graphics/static_bitmap_image.cc index 1e64df9d..7bb7f49 100644 --- a/third_party/blink/renderer/platform/graphics/static_bitmap_image.cc +++ b/third_party/blink/renderer/platform/graphics/static_bitmap_image.cc
@@ -62,7 +62,7 @@ // ImageOrientation expects the origin to be at (0, 0) canvas->translate(adjusted_dst_rect.x(), adjusted_dst_rect.y()); - adjusted_dst_rect.set_origin(FloatPoint()); + adjusted_dst_rect.set_origin(gfx::PointF()); canvas->concat(AffineTransformToSkMatrix( orientation_.TransformFromDefault(adjusted_dst_rect.size())));
diff --git a/third_party/blink/renderer/platform/testing/shape_result_perf_test.cc b/third_party/blink/renderer/platform/testing/shape_result_perf_test.cc index 5931c94c..aee282ab 100644 --- a/third_party/blink/renderer/platform/testing/shape_result_perf_test.cc +++ b/third_party/blink/renderer/platform/testing/shape_result_perf_test.cc
@@ -112,7 +112,7 @@ int endpos = GetParam(); param_string = base::NumberToString(endpos); do { - font.SelectionRectForText(run, FloatPoint(), 100, 0, endpos); + font.SelectionRectForText(run, gfx::PointF(), 100, 0, endpos); timer.NextLap(); } while (!timer.HasTimeLimitExpired()); }
diff --git a/third_party/blink/renderer/platform/transforms/affine_transform.cc b/third_party/blink/renderer/platform/transforms/affine_transform.cc index a6caa395..87259c0 100644 --- a/third_party/blink/renderer/platform/transforms/affine_transform.cc +++ b/third_party/blink/renderer/platform/transforms/affine_transform.cc
@@ -269,13 +269,6 @@ return gfx::Point(static_cast<int>(lround(x2)), static_cast<int>(lround(y2))); } -FloatPoint AffineTransform::MapPoint(const FloatPoint& point) const { - double x2, y2; - Map(point.x(), point.y(), x2, y2); - - return FloatPoint(ClampTo<float>(x2), ClampTo<float>(y2)); -} - gfx::PointF AffineTransform::MapPoint(const gfx::PointF& point) const { double x2, y2; Map(point.x(), point.y(), x2, y2);
diff --git a/third_party/blink/renderer/platform/transforms/affine_transform.h b/third_party/blink/renderer/platform/transforms/affine_transform.h index 390c2b8..89ceee97 100644 --- a/third_party/blink/renderer/platform/transforms/affine_transform.h +++ b/third_party/blink/renderer/platform/transforms/affine_transform.h
@@ -42,7 +42,6 @@ namespace blink { -class FloatPoint; class FloatQuad; class FloatRect; class FloatSize; @@ -73,9 +72,7 @@ // Rounds the mapped point to the nearest integer value. gfx::Point MapPoint(const gfx::Point&) const; - gfx::PointF MapPoint(const gfx::PointF&) const; - FloatPoint MapPoint(const FloatPoint&) const; IntSize MapSize(const IntSize&) const; FloatSize MapSize(const FloatSize&) const;
diff --git a/third_party/blink/renderer/platform/transforms/rotation_test.cc b/third_party/blink/renderer/platform/transforms/rotation_test.cc index c046838..8967168 100644 --- a/third_party/blink/renderer/platform/transforms/rotation_test.cc +++ b/third_party/blink/renderer/platform/transforms/rotation_test.cc
@@ -5,6 +5,7 @@ #include "third_party/blink/renderer/platform/transforms/rotation.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/renderer/platform/wtf/math_extras.h" namespace blink {
diff --git a/third_party/blink/renderer/platform/transforms/transformation_matrix.cc b/third_party/blink/renderer/platform/transforms/transformation_matrix.cc index cabb5581..33e4930 100644 --- a/third_party/blink/renderer/platform/transforms/transformation_matrix.cc +++ b/third_party/blink/renderer/platform/transforms/transformation_matrix.cc
@@ -819,8 +819,8 @@ return ScaleNonUniform(s, s); } -FloatPoint TransformationMatrix::ProjectPoint(const FloatPoint& p, - bool* clamped) const { +gfx::PointF TransformationMatrix::ProjectPoint(const gfx::PointF& p, + bool* clamped) const { // This is basically raytracing. We have a point in the destination // plane with z=0, and we cast a ray parallel to the z-axis from that // point to find the z-position at which it intersects the z=0 plane @@ -839,7 +839,7 @@ if (M33() == 0) { // In this case, the projection plane is parallel to the ray we are trying // to trace, and there is no well-defined value for the projection. - return FloatPoint(); + return gfx::PointF(); } double x = p.x(); @@ -864,7 +864,7 @@ out_y /= w; } - return FloatPoint(static_cast<float>(out_x), static_cast<float>(out_y)); + return gfx::PointF(static_cast<float>(out_x), static_cast<float>(out_y)); } FloatQuad TransformationMatrix::ProjectQuad(const FloatQuad& q) const { @@ -943,10 +943,10 @@ box = bounds; } -FloatPoint TransformationMatrix::MapPoint(const FloatPoint& p) const { +gfx::PointF TransformationMatrix::MapPoint(const gfx::PointF& p) const { if (IsIdentityOrTranslation()) { - return FloatPoint(p.x() + static_cast<float>(matrix_[3][0]), - p.y() + static_cast<float>(matrix_[3][1])); + return gfx::PointF(p.x() + static_cast<float>(matrix_[3][0]), + p.y() + static_cast<float>(matrix_[3][1])); } return InternalMapPoint(p); } @@ -980,10 +980,10 @@ float max_x = r.right(); float max_y = r.bottom(); - result.set_p1(InternalMapPoint(FloatPoint(r.x(), r.y()))); - result.set_p2(InternalMapPoint(FloatPoint(max_x, r.y()))); - result.set_p3(InternalMapPoint(FloatPoint(max_x, max_y))); - result.set_p4(InternalMapPoint(FloatPoint(r.x(), max_y))); + result.set_p1(InternalMapPoint(gfx::PointF(r.x(), r.y()))); + result.set_p2(InternalMapPoint(gfx::PointF(max_x, r.y()))); + result.set_p3(InternalMapPoint(gfx::PointF(max_x, max_y))); + result.set_p4(InternalMapPoint(gfx::PointF(r.x(), max_y))); return result.BoundingBox(); } @@ -1638,8 +1638,8 @@ return *this; } -FloatPoint TransformationMatrix::InternalMapPoint( - const FloatPoint& source_point) const { +gfx::PointF TransformationMatrix::InternalMapPoint( + const gfx::PointF& source_point) const { double x = source_point.x(); double y = source_point.y(); double result_x = matrix_[3][0] + x * matrix_[0][0] + y * matrix_[1][0]; @@ -1649,7 +1649,7 @@ result_x /= w; result_y /= w; } - return FloatPoint(ClampToFloat(result_x), ClampToFloat(result_y)); + return gfx::PointF(ClampToFloat(result_x), ClampToFloat(result_y)); } FloatPoint3D TransformationMatrix::InternalMapPoint(
diff --git a/third_party/blink/renderer/platform/transforms/transformation_matrix.h b/third_party/blink/renderer/platform/transforms/transformation_matrix.h index d1ee4220..722c5ef8 100644 --- a/third_party/blink/renderer/platform/transforms/transformation_matrix.h +++ b/third_party/blink/renderer/platform/transforms/transformation_matrix.h
@@ -34,12 +34,12 @@ #include "build/build_config.h" #include "skia/ext/skia_matrix_44.h" -#include "third_party/blink/renderer/platform/geometry/float_point.h" #include "third_party/blink/renderer/platform/geometry/float_point_3d.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/skia/include/core/SkM44.h" +#include "ui/gfx/geometry/point_f.h" namespace gfx { class PointF; @@ -204,10 +204,7 @@ // Map a 2D point through the transform, returning a 2D point. // Note that this ignores the z component, effectively projecting the point // into the z=0 plane. - FloatPoint MapPoint(const FloatPoint&) const; - gfx::PointF MapPoint(const gfx::PointF& p) const { - return ToGfxPointF(MapPoint(FloatPoint(p))); - } + gfx::PointF MapPoint(const gfx::PointF&) const; // If the matrix has 3D components, the z component of the result is // dropped, effectively projecting the rect into the z=0 plane @@ -232,7 +229,7 @@ // transform applied, by extending a ray perpendicular to the source plane and // computing the local x,y position of the point where that ray intersects // with the destination plane. - FloatPoint ProjectPoint(const FloatPoint&, bool* clamped = nullptr) const; + gfx::PointF ProjectPoint(const gfx::PointF&, bool* clamped = nullptr) const; // Projects the four corners of the quad. FloatQuad ProjectQuad(const FloatQuad&) const; // Projects the four corners of the quad and takes a bounding box, @@ -319,7 +316,7 @@ // Append translation after existing operations. i.e. // TransformationMatrix t2 = t1; // t2.PostTranslate(x, y); - // t2.MapPoint(p) == t1.MapPoint(p) + FloatPoint(x, y) + // t2.MapPoint(p) == t1.MapPoint(p) + gfx::PointF(x, y) TransformationMatrix& PostTranslate(double tx, double ty); TransformationMatrix& PostTranslate3d(double tx, double ty, double tz); @@ -494,7 +491,7 @@ String ToString(bool as_matrix = false) const; private: - FloatPoint InternalMapPoint(const FloatPoint& source_point) const; + gfx::PointF InternalMapPoint(const gfx::PointF& source_point) const; FloatPoint3D InternalMapPoint(const FloatPoint3D& source_point) const; void SetMatrix(const Matrix4& m) { memcpy(&matrix_, &m, sizeof(Matrix4)); }
diff --git a/third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py b/third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py index 469de79..59574aa2 100755 --- a/third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py +++ b/third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py
@@ -323,6 +323,8 @@ 'gfx::Determinant', 'gfx::IntersectRects', 'gfx::PointAtOffsetFromOrigin', + 'gfx::PointFToSkPoint', + 'gfx::PointToSkIPoint', 'gfx::MaximumCoveredRect', 'gfx::RectFToSkRect', 'gfx::RectToSkIRect', @@ -335,8 +337,10 @@ 'gfx::ScalePoint', 'gfx::ScaleToRoundedPoint', 'gfx::ScaleVector2d', + 'gfx::SkIPointToPoint', 'gfx::SkIRectToRect', 'gfx::SkRectToRectF', + 'gfx::SkPointToPointF', 'gfx::SubtractRects', 'gfx::ToCeiledPoint', 'gfx::ToCeiledSize',
diff --git a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json index b416aed..5d84259 100644 --- a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json +++ b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json
@@ -268071,7 +268071,7 @@ [] ], "delete.js": [ - "88ed59d9918ee79f27b065af202865f58d091f07", + "3c3d1ef703b08bf79c44e3726b75d6a50ebb703c", [] ], "fontname.js": [ @@ -268091,7 +268091,7 @@ [] ], "forwarddelete.js": [ - "a61b28303d4afa9e3452655f56cc3419ba94be6f", + "52152327f2154f69763ce434c52ba18f95aceefc", [] ], "hilitecolor.js": [ @@ -268373,7 +268373,7 @@ [] ], "delete_7001-last-expected.txt": [ - "a7e6d30ae6724c8b8d9456c45a14ccd3837216af", + "a05da9c7ef446ee33011f53df9df721804308fbd", [] ], "fontname-expected.txt": [ @@ -292348,7 +292348,7 @@ [] ], "underover-parameters-4.tentative-expected.txt": [ - "7ca753da6662a38a0d6ca324d78ee129c892ac42", + "023452f778d73d6b81de241037b9e0d2f2eb596e", [] ], "underover-stretchy-001-ref.html": [ @@ -306512,6 +306512,12 @@ ] }, "the-audio-api": { + "the-audiobuffer-interface": { + "acquire-the-content-expected.txt": [ + "74faed557c78367661d2024d85dc5ec4b5c36c85", + [] + ] + }, "the-audiobuffersourcenode-interface": { "resources": { "audiobuffersource-multi-channels-expected.wav": [ @@ -447136,7 +447142,7 @@ }, "user-activation": { "activation-trigger-keyboard-enter.html": [ - "fd51229c5dba4179e6c5c64336761f443f67f865", + "4c1b31c50bd0d37ac40ef7a6d15468d65c398629", [ null, { @@ -447145,7 +447151,7 @@ ] ], "activation-trigger-keyboard-escape.html": [ - "76bdefbb19ac3888917178c6e271fcc49496d0b2", + "01cb27d7b5f096ec7b2009a453f0d0dea2362fef", [ null, { @@ -447154,7 +447160,7 @@ ] ], "activation-trigger-mouse-left.html": [ - "8bde4dd2edc17978e2d273e3b1e10872977ab7f4", + "51ad49a44ebdf94b0cb0a9156b0d9c750b526c80", [ null, { @@ -447163,7 +447169,7 @@ ] ], "activation-trigger-mouse-right.html": [ - "a4734d06a12bc9a6b7972928f6ab510005885523", + "1e9f839df31508118e56d34e7249d58b92b344eb", [ null, { @@ -447171,6 +447177,27 @@ } ] ], + "activation-trigger-pointerevent.html": [ + "49870936084f5be768a25821eb0414715caa2e20", + [ + "html/user-activation/activation-trigger-pointerevent.html?mouse", + { + "testdriver": true + } + ], + [ + "html/user-activation/activation-trigger-pointerevent.html?pen", + { + "testdriver": true + } + ], + [ + "html/user-activation/activation-trigger-pointerevent.html?touch", + { + "testdriver": true + } + ] + ], "chained-setTimeout.tentative.html": [ "b815adab605a33405004556e479dbe53d32cf091", [ @@ -506641,6 +506668,13 @@ ] }, "the-audiobuffer-interface": { + "acquire-the-content.html": [ + "659a69c866429acad5e0239ae021b92d690ff59a", + [ + null, + {} + ] + ], "audiobuffer-copy-channel.html": [ "c0cd49d32520fdf3c55248b1130da64d5845097d", [
diff --git a/third_party/blink/web_tests/external/wpt/editing/data/delete.js b/third_party/blink/web_tests/external/wpt/editing/data/delete.js index 88ed59d..3c3d1ef 100644 --- a/third_party/blink/web_tests/external/wpt/editing/data/delete.js +++ b/third_party/blink/web_tests/external/wpt/editing/data/delete.js
@@ -2735,6 +2735,12 @@ "<p contenteditable=\"false\"><span contenteditable=\"\"></span></p>", [true], {"delete":[false,false,"",false,false,""]}], +["<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>", + [["delete",""]], + ["<p contenteditable=\"false\"><span contenteditable=\"\">af</span></p>", + "<p contenteditable=\"false\"><span contenteditable=\"\">af<br></span></p>"], + [true], + {"delete":[false,false,"",false,false,""]}], ["<p contenteditable=\"false\"><unknown-element contenteditable>[abc]</unknown-element></p>", [["delete",""]], "<p contenteditable=\"false\"><unknown-element contenteditable=\"\"></unknown-element></p>",
diff --git a/third_party/blink/web_tests/external/wpt/editing/data/forwarddelete.js b/third_party/blink/web_tests/external/wpt/editing/data/forwarddelete.js index a61b283..5215232 100644 --- a/third_party/blink/web_tests/external/wpt/editing/data/forwarddelete.js +++ b/third_party/blink/web_tests/external/wpt/editing/data/forwarddelete.js
@@ -2616,6 +2616,12 @@ "<p contenteditable=\"false\"><span contenteditable=\"\"></span></p>", [true], {"forwarddelete":[false,false,"",false,false,""]}], +["<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>", + [["forwarddelete",""]], + ["<p contenteditable=\"false\"><span contenteditable=\"\">af</span></p>", + "<p contenteditable=\"false\"><span contenteditable=\"\">a<br>f</span></p>"], + [true], + {"forwarddelete":[false,false,"",false,false,""]}], ["<p contenteditable=\"false\"><unknown-element contenteditable>[abc]</unknown-element></p>", [["forwarddelete",""]], "<p contenteditable=\"false\"><unknown-element contenteditable=\"\"></unknown-element></p>",
diff --git a/third_party/blink/web_tests/external/wpt/editing/run/delete_7001-last-expected.txt b/third_party/blink/web_tests/external/wpt/editing/run/delete_7001-last-expected.txt index a7e6d30..a05da9c 100644 --- a/third_party/blink/web_tests/external/wpt/editing/run/delete_7001-last-expected.txt +++ b/third_party/blink/web_tests/external/wpt/editing/run/delete_7001-last-expected.txt
@@ -1,5 +1,5 @@ This is a testharness.js-based test. -Found 210 tests; 207 PASS, 3 FAIL, 0 TIMEOUT, 0 NOTRUN. +Found 219 tests; 216 PASS, 3 FAIL, 0 TIMEOUT, 0 NOTRUN. PASS [["delete",""]] "<p contenteditable=false><span contenteditable=true>[abc]</span></p>" queryCommandIndeterm("delete") after PASS [["delete",""]] "<p contenteditable=false><span contenteditable=true>[abc]</span></p>" queryCommandState("delete") after PASS [["delete",""]] "<p contenteditable=false><span contenteditable=true>[abc]</span></p>" queryCommandValue("delete") after @@ -201,6 +201,15 @@ PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>[abc]</span></p>" queryCommandIndeterm("delete") after PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>[abc]</span></p>" queryCommandState("delete") after PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>[abc]</span></p>" queryCommandValue("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" checks for modifications to non-editable content +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" compare innerHTML +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" queryCommandState("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" queryCommandValue("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" queryCommandState("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" queryCommandValue("delete") after PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>[abc]</unknown-element></p>": execCommand("delete", false, "") return value PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>[abc]</unknown-element></p>" checks for modifications to non-editable content PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>[abc]</unknown-element></p>" compare innerHTML
diff --git a/third_party/blink/web_tests/external/wpt/remote-playback/prompt-in-detached-iframe.html b/third_party/blink/web_tests/external/wpt/remote-playback/prompt-in-detached-iframe.html new file mode 100644 index 0000000..5014717 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/remote-playback/prompt-in-detached-iframe.html
@@ -0,0 +1,17 @@ +<!DOCTYPE html> +<body> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +promise_test(t => { + let i = document.createElement("iframe"); + document.body.appendChild(i); + let audio = document.createElement("audio"); + i.contentDocument.body.appendChild(audio); + let remote = audio.remote; + i.remove(); + return promise_rejects_dom(t, "InvalidAccessError", remote.prompt()); +}, 'Calling remote.prompt() in a detached context should throw InvalidAccessError'); +</script> +</body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/webaudio/the-audio-api/the-audiobuffer-interface/acquire-the-content-expected.txt b/third_party/blink/web_tests/external/wpt/webaudio/the-audio-api/the-audiobuffer-interface/acquire-the-content-expected.txt new file mode 100644 index 0000000..74faed557 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/webaudio/the-audio-api/the-audiobuffer-interface/acquire-the-content-expected.txt
@@ -0,0 +1,6 @@ +This is a testharness.js-based test. +FAIL AudioBufferSourceNode setter set with non-null buffer assert_true: Invalid value at index 0, expecte close to 1.0, found 0.5 when reading back expected true got false +FAIL AudioBufferSourceNode buffer setter set with null assert_true: Invalid value at index 0, expecte close to 1.0, found 0.5 when reading back expected true got false +PASS ConvolverNode +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/external/wpt/webaudio/the-audio-api/the-audiobuffer-interface/acquire-the-content.html b/third_party/blink/web_tests/external/wpt/webaudio/the-audio-api/the-audiobuffer-interface/acquire-the-content.html new file mode 100644 index 0000000..659a69c --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/webaudio/the-audio-api/the-audiobuffer-interface/acquire-the-content.html
@@ -0,0 +1,85 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Test for AudioBuffer's "acquire the content" operation</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +const SAMPLERATE = 8000; +const LENGTH = 128; + +var tests = { + "AudioBufferSourceNode setter set with non-null buffer": function(oac) { + var buf = oac.createBuffer(1, LENGTH, SAMPLERATE) + var bs = new AudioBufferSourceNode(oac); + var channelData = buf.getChannelData(0); + for (var i = 0; i < channelData.length; i++) { + channelData[i] = 1.0; + } + bs.buffer = buf; + bs.start(); // This acquires the content since buf is not null + for (var i = 0; i < channelData.length; i++) { + channelData[i] = 0.5; + } + allSamplesAtOne(buf, "reading back"); + bs.connect(oac.destination); + return oac.startRendering(); + }, + "AudioBufferSourceNode buffer setter set with null" : (oac) => { + var buf = oac.createBuffer(1, LENGTH, SAMPLERATE) + var bs = new AudioBufferSourceNode(oac); + var channelData = buf.getChannelData(0); + for (var i = 0; i < channelData.length; i++) { + channelData[i] = 1.0; + } + bs.buffer = null; + bs.start(); // This does not acquire the content + bs.buffer = buf; // This does + for (var i = 0; i < channelData.length; i++) { + channelData[i] = 0.5; + } + allSamplesAtOne(buf, "reading back"); + bs.connect(oac.destination); + return oac.startRendering(); + }, + "ConvolverNode": (oac) => { + var buf = oac.createBuffer(1, LENGTH, SAMPLERATE) + var impulse = oac.createBuffer(1, 1, SAMPLERATE) + var bs = new AudioBufferSourceNode(oac); + var convolver = new ConvolverNode(oac, {disableNormalization: true}); + + impulse.getChannelData(0)[0] = 1.0; // unit impulse function + convolver.buffer = impulse; // This does acquire the content + impulse.getChannelData(0)[0] = 0.5; + + var channelData = buf.getChannelData(0); + for (var i = 0; i < channelData.length; i++) { + channelData[i] = 1.0; + } + bs.buffer = buf; + bs.start(); + + bs.connect(convolver).connect(oac.destination); + return oac.startRendering(); + } +}; + +function allSamplesAtOne(audiobuffer, location) { + var buf = audiobuffer.getChannelData(0); + for (var i = 0; i < buf.length; i++) { + // The convolver can introduce a slight numerical error. + if (Math.abs(buf[i] - 1.0) > 0.0001) { + assert_true(false, `Invalid value at index ${i}, expecte close to 1.0, found ${buf[i]} when ${location}`) + return Promise.reject(); + } + } + assert_true(true, `Buffer unmodified when ${location}.`); + return Promise.resolve(); +} + +for (const test of Object.keys(tests)) { + promise_test(async function(t) { + var buf = await tests[test](new OfflineAudioContext(1, LENGTH, SAMPLERATE)); + return allSamplesAtOne(buf, "rendering"); + }, test); +}; +</script>
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/external/wpt/editing/run/delete_7001-last-expected.txt b/third_party/blink/web_tests/flag-specific/highdpi/external/wpt/editing/run/delete_7001-last-expected.txt new file mode 100644 index 0000000..a05da9c --- /dev/null +++ b/third_party/blink/web_tests/flag-specific/highdpi/external/wpt/editing/run/delete_7001-last-expected.txt
@@ -0,0 +1,223 @@ +This is a testharness.js-based test. +Found 219 tests; 216 PASS, 3 FAIL, 0 TIMEOUT, 0 NOTRUN. +PASS [["delete",""]] "<p contenteditable=false><span contenteditable=true>[abc]</span></p>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<p contenteditable=false><span contenteditable=true>[abc]</span></p>" queryCommandState("delete") after +PASS [["delete",""]] "<p contenteditable=false><span contenteditable=true>[abc]</span></p>" queryCommandValue("delete") after +PASS [["delete",""]] "<div><div>{}<br></div></div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div><div>{}<br></div></div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div><div>{}<br></div></div>" compare innerHTML +PASS [["delete",""]] "<div><div>{}<br></div></div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div><div>{}<br></div></div>" queryCommandState("delete") before +PASS [["delete",""]] "<div><div>{}<br></div></div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div><div>{}<br></div></div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div><div>{}<br></div></div>" queryCommandState("delete") after +PASS [["delete",""]] "<div><div>{}<br></div></div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div><div contenteditable=false><div contenteditable><div>{}<br></div></div></div></div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div><div contenteditable=false><div contenteditable><div>{}<br></div></div></div></div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div><div contenteditable=false><div contenteditable><div>{}<br></div></div></div></div>" compare innerHTML +PASS [["delete",""]] "<div><div contenteditable=false><div contenteditable><div>{}<br></div></div></div></div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div><div contenteditable=false><div contenteditable><div>{}<br></div></div></div></div>" queryCommandState("delete") before +PASS [["delete",""]] "<div><div contenteditable=false><div contenteditable><div>{}<br></div></div></div></div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div><div contenteditable=false><div contenteditable><div>{}<br></div></div></div></div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div><div contenteditable=false><div contenteditable><div>{}<br></div></div></div></div>" queryCommandState("delete") after +PASS [["delete",""]] "<div><div contenteditable=false><div contenteditable><div>{}<br></div></div></div></div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div><div contenteditable=false><span contenteditable>{}<br></span></div></div></div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div><div contenteditable=false><span contenteditable>{}<br></span></div></div></div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div><div contenteditable=false><span contenteditable>{}<br></span></div></div></div>" compare innerHTML +PASS [["delete",""]] "<div><div contenteditable=false><span contenteditable>{}<br></span></div></div></div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div><div contenteditable=false><span contenteditable>{}<br></span></div></div></div>" queryCommandState("delete") before +PASS [["delete",""]] "<div><div contenteditable=false><span contenteditable>{}<br></span></div></div></div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div><div contenteditable=false><span contenteditable>{}<br></span></div></div></div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div><div contenteditable=false><span contenteditable>{}<br></span></div></div></div>" queryCommandState("delete") after +PASS [["delete",""]] "<div><div contenteditable=false><span contenteditable>{}<br></span></div></div></div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:pre>foo \n[]bar</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:pre>foo \n[]bar</div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div style=white-space:pre>foo \n[]bar</div>" compare innerHTML +PASS [["delete",""]] "<div style=white-space:pre>foo \n[]bar</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:pre>foo \n[]bar</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:pre>foo \n[]bar</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:pre>foo \n[]bar</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:pre>foo \n[]bar</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:pre>foo \n[]bar</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:pre>foo\n []bar</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:pre>foo\n []bar</div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div style=white-space:pre>foo\n []bar</div>" compare innerHTML +PASS [["delete",""]] "<div style=white-space:pre>foo\n []bar</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:pre>foo\n []bar</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:pre>foo\n []bar</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:pre>foo\n []bar</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:pre>foo\n []bar</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:pre>foo\n []bar</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:pre>foo\n\n[]bar</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:pre>foo\n\n[]bar</div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div style=white-space:pre>foo\n\n[]bar</div>" compare innerHTML +PASS [["delete",""]] "<div style=white-space:pre>foo\n\n[]bar</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:pre>foo\n\n[]bar</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:pre>foo\n\n[]bar</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:pre>foo\n\n[]bar</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:pre>foo\n\n[]bar</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:pre>foo\n\n[]bar</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:pre>foo\nb[]</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:pre>foo\nb[]</div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div style=white-space:pre>foo\nb[]</div>" compare innerHTML +PASS [["delete",""]] "<div style=white-space:pre>foo\nb[]</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:pre>foo\nb[]</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:pre>foo\nb[]</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:pre>foo\nb[]</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:pre>foo\nb[]</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:pre>foo\nb[]</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo \n[]bar</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo \n[]bar</div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo \n[]bar</div>" compare innerHTML +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo \n[]bar</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo \n[]bar</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo \n[]bar</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo \n[]bar</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo \n[]bar</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo \n[]bar</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n []bar</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n []bar</div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n []bar</div>" compare innerHTML +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n []bar</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n []bar</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n []bar</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n []bar</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n []bar</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n []bar</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n\n[]bar</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n\n[]bar</div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n\n[]bar</div>" compare innerHTML +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n\n[]bar</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n\n[]bar</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n\n[]bar</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n\n[]bar</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n\n[]bar</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\n\n[]bar</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\nb[]</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\nb[]</div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\nb[]</div>" compare innerHTML +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\nb[]</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\nb[]</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\nb[]</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\nb[]</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\nb[]</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:pre-wrap>foo\nb[]</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:pre-line>foo \n[]bar</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:pre-line>foo \n[]bar</div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div style=white-space:pre-line>foo \n[]bar</div>" compare innerHTML +PASS [["delete",""]] "<div style=white-space:pre-line>foo \n[]bar</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:pre-line>foo \n[]bar</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:pre-line>foo \n[]bar</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:pre-line>foo \n[]bar</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:pre-line>foo \n[]bar</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:pre-line>foo \n[]bar</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n []bar</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n []bar</div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n []bar</div>" compare innerHTML +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n []bar</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n []bar</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n []bar</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n []bar</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n []bar</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n []bar</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n\n[]bar</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n\n[]bar</div>" checks for modifications to non-editable content +FAIL [["delete",""]] "<div style=white-space:pre-line>foo\n\n[]bar</div>" compare innerHTML assert_equals: Unexpected innerHTML (after normalizing inline style) expected "<div style=\"white-space:pre-line\">foo\nbar</div>" but got "<div style=\"white-space:pre-line\">foo bar</div>" +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n\n[]bar</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n\n[]bar</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n\n[]bar</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n\n[]bar</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n\n[]bar</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:pre-line>foo\n\n[]bar</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:pre-line>foo\nb[]</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:pre-line>foo\nb[]</div>" checks for modifications to non-editable content +FAIL [["delete",""]] "<div style=white-space:pre-line>foo\nb[]</div>" compare innerHTML assert_in_array: Unexpected innerHTML (after normalizing inline style) value "<div style=\"white-space:pre-line\">foo <br></div>" not in array ["<div style=\"white-space:pre-line\">foo\n\n</div>", "<div style=\"white-space:pre-line\">foo\n<br></div>"] +PASS [["delete",""]] "<div style=white-space:pre-line>foo\nb[]</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:pre-line>foo\nb[]</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:pre-line>foo\nb[]</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:pre-line>foo\nb[]</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:pre-line>foo\nb[]</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:pre-line>foo\nb[]</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:nowrap>foo \n[]bar</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:nowrap>foo \n[]bar</div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div style=white-space:nowrap>foo \n[]bar</div>" compare innerHTML +PASS [["delete",""]] "<div style=white-space:nowrap>foo \n[]bar</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:nowrap>foo \n[]bar</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:nowrap>foo \n[]bar</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:nowrap>foo \n[]bar</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:nowrap>foo \n[]bar</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:nowrap>foo \n[]bar</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n []bar</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n []bar</div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n []bar</div>" compare innerHTML +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n []bar</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n []bar</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n []bar</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n []bar</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n []bar</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n []bar</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n\n[]bar</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n\n[]bar</div>" checks for modifications to non-editable content +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n\n[]bar</div>" compare innerHTML +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n\n[]bar</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n\n[]bar</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n\n[]bar</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n\n[]bar</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n\n[]bar</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:nowrap>foo\n\n[]bar</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<div style=white-space:nowrap>foo\nb[]</div>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<div style=white-space:nowrap>foo\nb[]</div>" checks for modifications to non-editable content +FAIL [["delete",""]] "<div style=white-space:nowrap>foo\nb[]</div>" compare innerHTML assert_in_array: Unexpected innerHTML (after normalizing inline style) value "<div style=\"white-space:nowrap\">foo </div>" not in array ["<div style=\"white-space:nowrap\">foo\n</div>", "<div style=\"white-space:nowrap\">foo<br></div>"] +PASS [["delete",""]] "<div style=white-space:nowrap>foo\nb[]</div>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<div style=white-space:nowrap>foo\nb[]</div>" queryCommandState("delete") before +PASS [["delete",""]] "<div style=white-space:nowrap>foo\nb[]</div>" queryCommandValue("delete") before +PASS [["delete",""]] "<div style=white-space:nowrap>foo\nb[]</div>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<div style=white-space:nowrap>foo\nb[]</div>" queryCommandState("delete") after +PASS [["delete",""]] "<div style=white-space:nowrap>foo\nb[]</div>" queryCommandValue("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[b]c</span></p>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[b]c</span></p>" checks for modifications to non-editable content +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[b]c</span></p>" compare innerHTML +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[b]c</span></p>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[b]c</span></p>" queryCommandState("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[b]c</span></p>" queryCommandValue("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[b]c</span></p>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[b]c</span></p>" queryCommandState("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[b]c</span></p>" queryCommandValue("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>a[b]c</unknown-element></p>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>a[b]c</unknown-element></p>" checks for modifications to non-editable content +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>a[b]c</unknown-element></p>" compare innerHTML +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>a[b]c</unknown-element></p>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>a[b]c</unknown-element></p>" queryCommandState("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>a[b]c</unknown-element></p>" queryCommandValue("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>a[b]c</unknown-element></p>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>a[b]c</unknown-element></p>" queryCommandState("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>a[b]c</unknown-element></p>" queryCommandValue("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>[abc]</span></p>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>[abc]</span></p>" checks for modifications to non-editable content +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>[abc]</span></p>" compare innerHTML +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>[abc]</span></p>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>[abc]</span></p>" queryCommandState("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>[abc]</span></p>" queryCommandValue("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>[abc]</span></p>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>[abc]</span></p>" queryCommandState("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>[abc]</span></p>" queryCommandValue("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" checks for modifications to non-editable content +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" compare innerHTML +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" queryCommandState("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" queryCommandValue("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" queryCommandState("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><span contenteditable>a[bc<br>de]f</span></p>" queryCommandValue("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>[abc]</unknown-element></p>": execCommand("delete", false, "") return value +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>[abc]</unknown-element></p>" checks for modifications to non-editable content +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>[abc]</unknown-element></p>" compare innerHTML +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>[abc]</unknown-element></p>" queryCommandIndeterm("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>[abc]</unknown-element></p>" queryCommandState("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>[abc]</unknown-element></p>" queryCommandValue("delete") before +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>[abc]</unknown-element></p>" queryCommandIndeterm("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>[abc]</unknown-element></p>" queryCommandState("delete") after +PASS [["delete",""]] "<p contenteditable=\"false\"><unknown-element contenteditable>[abc]</unknown-element></p>" queryCommandValue("delete") after +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt b/third_party/blink/web_tests/flag-specific/highdpi/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt new file mode 100644 index 0000000..636b5cbd --- /dev/null +++ b/third_party/blink/web_tests/flag-specific/highdpi/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt
@@ -0,0 +1,6 @@ +This is a testharness.js-based test. +FAIL href assert_equals: expected "http://web-platform.test:8001/common/blank.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.href%20%3D%20%22%2Fcommon%2Fblank.html%3Fthereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL search assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.search%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL hash assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20#thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt b/third_party/blink/web_tests/flag-specific/highdpi/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt new file mode 100644 index 0000000..4eecf2b --- /dev/null +++ b/third_party/blink/web_tests/flag-specific/highdpi/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt
@@ -0,0 +1,6 @@ +This is a testharness.js-based test. +FAIL href assert_equals: expected "http://web-platform.test:8001/common/blank.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.href%20%3D%20%22%2Fcommon%2Fblank.html%3Fthereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL search assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.search%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL hash assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20#thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/external/wpt/webaudio/the-audio-api/the-audiobuffer-interface/acquire-the-content-expected.txt b/third_party/blink/web_tests/flag-specific/highdpi/external/wpt/webaudio/the-audio-api/the-audiobuffer-interface/acquire-the-content-expected.txt new file mode 100644 index 0000000..74faed557 --- /dev/null +++ b/third_party/blink/web_tests/flag-specific/highdpi/external/wpt/webaudio/the-audio-api/the-audiobuffer-interface/acquire-the-content-expected.txt
@@ -0,0 +1,6 @@ +This is a testharness.js-based test. +FAIL AudioBufferSourceNode setter set with non-null buffer assert_true: Invalid value at index 0, expecte close to 1.0, found 0.5 when reading back expected true got false +FAIL AudioBufferSourceNode buffer setter set with null assert_true: Invalid value at index 0, expecte close to 1.0, found 0.5 when reading back expected true got false +PASS ConvolverNode +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/virtual/shared_array_buffer_on_desktop/external/wpt/webaudio/the-audio-api/the-audiobuffer-interface/acquire-the-content-expected.txt b/third_party/blink/web_tests/flag-specific/highdpi/virtual/shared_array_buffer_on_desktop/external/wpt/webaudio/the-audio-api/the-audiobuffer-interface/acquire-the-content-expected.txt new file mode 100644 index 0000000..74faed557 --- /dev/null +++ b/third_party/blink/web_tests/flag-specific/highdpi/virtual/shared_array_buffer_on_desktop/external/wpt/webaudio/the-audio-api/the-audiobuffer-interface/acquire-the-content-expected.txt
@@ -0,0 +1,6 @@ +This is a testharness.js-based test. +FAIL AudioBufferSourceNode setter set with non-null buffer assert_true: Invalid value at index 0, expecte close to 1.0, found 0.5 when reading back expected true got false +FAIL AudioBufferSourceNode buffer setter set with null assert_true: Invalid value at index 0, expecte close to 1.0, found 0.5 when reading back expected true got false +PASS ConvolverNode +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/external/wpt/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.12/external/wpt/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt new file mode 100644 index 0000000..6240f63 --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-mac10.12/external/wpt/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt
@@ -0,0 +1,8 @@ +This is a testharness.js-based test. +PASS PeerConnection passthrough MediaRecorder receives VP8 after onstart with a video stream. +PASS PeerConnection passthrough MediaRecorder receives VP8 after onstart with a audio/video stream. +PASS PeerConnection passthrough MediaRecorder receives VP9 after onstart with a video stream. +PASS PeerConnection passthrough MediaRecorder receives VP9 after onstart with a audio/video stream. +FAIL PeerConnection passthrough MediaRecorder should be prepared to handle the codec switching from VP8 to VP9 assert_unreached: MediaRecorder should be prepared to handle codec switches Reached unreachable code +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/mac-mac10.13/external/wpt/mathml/presentation-markup/scripts/underover-parameters-4.tentative-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.13/external/wpt/mathml/presentation-markup/scripts/underover-parameters-4.tentative-expected.txt deleted file mode 100644 index 023452f..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.13/external/wpt/mathml/presentation-markup/scripts/underover-parameters-4.tentative-expected.txt +++ /dev/null
@@ -1,9 +0,0 @@ -This is a testharness.js-based test. -PASS Baseline alignment -PASS Heights of bases -PASS AccentBaseHeight, UnderbarExtraDescender -FAIL AccentBaseHeight, UnderbarVerticalGap assert_approx_equals: munderover: accent over short base expected 40 +/- 2 but got 30 -FAIL AccentBaseHeight, OverbarExtraAscender assert_approx_equals: mover: accent over short base expected 40 +/- 2 but got 30 -FAIL AccentBaseHeight, OverbarVerticalGap assert_approx_equals: mover: accent over short base expected 40 +/- 2 but got 140 -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/platform/mac-mac10.14/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.14/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt new file mode 100644 index 0000000..e08d8be7 --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-mac10.14/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt
@@ -0,0 +1,9 @@ +Content-Type: text/plain +This is a testharness.js-based test. +FAIL href assert_equals: expected "http://web-platform.test:8001/common/blank.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.href%20%3D%20%22%2Fcommon%2Fblank.html%3Fthereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL search assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.search%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL hash assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20#thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +Harness: the test ran to completion. + +#EOF +#EOF
diff --git a/third_party/blink/web_tests/platform/mac-mac10.14/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.14/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt new file mode 100644 index 0000000..60f94000 --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-mac10.14/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt
@@ -0,0 +1,9 @@ +Content-Type: text/plain +This is a testharness.js-based test. +FAIL href assert_equals: expected "http://web-platform.test:8001/common/blank.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.href%20%3D%20%22%2Fcommon%2Fblank.html%3Fthereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL search assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.search%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL hash assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20#thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +Harness: the test ran to completion. + +#EOF +#EOF
diff --git a/third_party/blink/web_tests/platform/mac-mac10.14/external/wpt/mathml/presentation-markup/scripts/underover-parameters-4.tentative-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.14/external/wpt/mathml/presentation-markup/scripts/underover-parameters-4.tentative-expected.txt deleted file mode 100644 index 023452f..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.14/external/wpt/mathml/presentation-markup/scripts/underover-parameters-4.tentative-expected.txt +++ /dev/null
@@ -1,9 +0,0 @@ -This is a testharness.js-based test. -PASS Baseline alignment -PASS Heights of bases -PASS AccentBaseHeight, UnderbarExtraDescender -FAIL AccentBaseHeight, UnderbarVerticalGap assert_approx_equals: munderover: accent over short base expected 40 +/- 2 but got 30 -FAIL AccentBaseHeight, OverbarExtraAscender assert_approx_equals: mover: accent over short base expected 40 +/- 2 but got 30 -FAIL AccentBaseHeight, OverbarVerticalGap assert_approx_equals: mover: accent over short base expected 40 +/- 2 but got 140 -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/platform/mac-mac10.14/external/wpt/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.14/external/wpt/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt new file mode 100644 index 0000000..1e93b7a --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-mac10.14/external/wpt/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt
@@ -0,0 +1,8 @@ +This is a testharness.js-based test. +PASS PeerConnection passthrough MediaRecorder receives VP8 after onstart with a video stream. +PASS PeerConnection passthrough MediaRecorder receives VP8 after onstart with a audio/video stream. +PASS PeerConnection passthrough MediaRecorder receives VP9 after onstart with a video stream. +PASS PeerConnection passthrough MediaRecorder receives VP9 after onstart with a audio/video stream. +PASS PeerConnection passthrough MediaRecorder should be prepared to handle the codec switching from VP8 to VP9 +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/mac-mac10.15/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.15/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt new file mode 100644 index 0000000..636b5cbd --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-mac10.15/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt
@@ -0,0 +1,6 @@ +This is a testharness.js-based test. +FAIL href assert_equals: expected "http://web-platform.test:8001/common/blank.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.href%20%3D%20%22%2Fcommon%2Fblank.html%3Fthereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL search assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.search%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL hash assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20#thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/mac-mac10.15/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.15/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt new file mode 100644 index 0000000..4eecf2b --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-mac10.15/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt
@@ -0,0 +1,6 @@ +This is a testharness.js-based test. +FAIL href assert_equals: expected "http://web-platform.test:8001/common/blank.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.href%20%3D%20%22%2Fcommon%2Fblank.html%3Fthereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL search assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.search%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL hash assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20#thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/mac/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt b/third_party/blink/web_tests/platform/mac/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt new file mode 100644 index 0000000..e08d8be7 --- /dev/null +++ b/third_party/blink/web_tests/platform/mac/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt
@@ -0,0 +1,9 @@ +Content-Type: text/plain +This is a testharness.js-based test. +FAIL href assert_equals: expected "http://web-platform.test:8001/common/blank.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.href%20%3D%20%22%2Fcommon%2Fblank.html%3Fthereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL search assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.search%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL hash assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20#thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +Harness: the test ran to completion. + +#EOF +#EOF
diff --git a/third_party/blink/web_tests/platform/mac/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt b/third_party/blink/web_tests/platform/mac/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt new file mode 100644 index 0000000..60f94000 --- /dev/null +++ b/third_party/blink/web_tests/platform/mac/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt
@@ -0,0 +1,9 @@ +Content-Type: text/plain +This is a testharness.js-based test. +FAIL href assert_equals: expected "http://web-platform.test:8001/common/blank.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.href%20%3D%20%22%2Fcommon%2Fblank.html%3Fthereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL search assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.search%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL hash assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20#thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +Harness: the test ran to completion. + +#EOF +#EOF
diff --git a/third_party/blink/web_tests/platform/win/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt b/third_party/blink/web_tests/platform/win/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt new file mode 100644 index 0000000..636b5cbd --- /dev/null +++ b/third_party/blink/web_tests/platform/win/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt
@@ -0,0 +1,6 @@ +This is a testharness.js-based test. +FAIL href assert_equals: expected "http://web-platform.test:8001/common/blank.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.href%20%3D%20%22%2Fcommon%2Fblank.html%3Fthereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL search assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.search%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL hash assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20#thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onclick%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/win/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt b/third_party/blink/web_tests/platform/win/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt new file mode 100644 index 0000000..4eecf2b --- /dev/null +++ b/third_party/blink/web_tests/platform/win/external/wpt/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt
@@ -0,0 +1,6 @@ +This is a testharness.js-based test. +FAIL href assert_equals: expected "http://web-platform.test:8001/common/blank.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.href%20%3D%20%22%2Fcommon%2Fblank.html%3Fthereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL search assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.search%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +FAIL hash assert_equals: expected "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20#thereplacement" but got "http://web-platform.test:8001/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/slow-code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.id%20%3D%20%22the-button%22%3B%0A%20%20%20%20button.textContent%20%3D%20%22needs%20to%20have%20content%20to%20be%20clickable%22%3B%0A%20%20%20%20button.onmouseup%20%3D%20()%20%3D%3E%20%7B%20location.hash%20%3D%20%22thereplacement%22%3B%20%7D%3B%0A%20%20%20%20document.currentScript.before(button)%3B%0A%20%20%20%20parent.test_driver.click(button)%3B%0A%20%20" +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/wpt_internal/css/css-conditional/container-queries/reattach-container-with-dirty-child.html b/third_party/blink/web_tests/wpt_internal/css/css-conditional/container-queries/reattach-container-with-dirty-child.html new file mode 100644 index 0000000..2513f88 --- /dev/null +++ b/third_party/blink/web_tests/wpt_internal/css/css-conditional/container-queries/reattach-container-with-dirty-child.html
@@ -0,0 +1,33 @@ +<!doctype html> +<title>@container changing display type while descendant styles change</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> + #container { + container-type: inline-size; + } + @container (min-width: 200px) { + div { color: red } + } + @container (max-width: 150px) { + div { color: lime } + } +</style> +<div id="container"> + <div id="child"><span id="inner">XXX</span></div> +</div> +<script> + test(() => { + container.offsetTop; + assert_equals(getComputedStyle(child).color, "rgb(255, 0, 0)"); + }, "Initially wider than 200px"); + + test(() => { + container.style.width = "100px"; + container.style.display = "inline-block"; + inner.style.color = "green"; + container.offsetTop; + assert_equals(getComputedStyle(child).color, "rgb(0, 255, 0)"); + assert_equals(getComputedStyle(inner).color, "rgb(0, 128, 0)"); + }, "Container query changed and inner.style applied"); +</script>
diff --git a/third_party/closure_compiler/externs/file_manager_private.js b/third_party/closure_compiler/externs/file_manager_private.js index 97ff3351..f4f9423 100644 --- a/third_party/closure_compiler/externs/file_manager_private.js +++ b/third_party/closure_compiler/externs/file_manager_private.js
@@ -494,7 +494,8 @@ * use24hourClock: boolean, * timezone: string, * arcEnabled: boolean, - * arcRemovableMediaAccessEnabled: boolean + * arcRemovableMediaAccessEnabled: boolean, + * folderShortcuts: !Array<string> * }} */ chrome.fileManagerPrivate.Preferences; @@ -503,7 +504,8 @@ * @typedef {{ * cellularDisabled: (boolean|undefined), * arcEnabled: (boolean|undefined), - * arcRemovableMediaAccessEnabled: (boolean|undefined) + * arcRemovableMediaAccessEnabled: (boolean|undefined), + * folderShortcuts: (!Array<string>|undefined) * }} */ chrome.fileManagerPrivate.PreferencesChange;
diff --git a/third_party/dav1d/BUILD.gn b/third_party/dav1d/BUILD.gn index 7b9fd8e4..cf37414 100644 --- a/third_party/dav1d/BUILD.gn +++ b/third_party/dav1d/BUILD.gn
@@ -115,7 +115,7 @@ if (needs_stack_alignment) { dav1d_copts += [ stackalign_flag ] } - if (is_mac) { + if (is_mac || is_ios) { dav1d_copts += [ "-D_DARWIN_C_SOURCE" ] } if (is_linux || is_chromeos || is_android || current_os == "aix") {
diff --git a/third_party/distributed_point_functions/BUILD.gn b/third_party/distributed_point_functions/BUILD.gn index d12236d..1c69971 100644 --- a/third_party/distributed_point_functions/BUILD.gn +++ b/third_party/distributed_point_functions/BUILD.gn
@@ -6,7 +6,7 @@ import("//third_party/protobuf/proto_library.gni") proto_library("proto") { - sources = [ "src/dpf/distributed_point_function.proto" ] + sources = [ "code/dpf/distributed_point_function.proto" ] proto_out_dir = "third_party/distributed_point_functions/dpf" cc_generator_options = "lite" } @@ -18,7 +18,7 @@ config("distributed_point_functions_includes") { include_dirs = [ ".", - "src", + "code", "$target_gen_dir", ] } @@ -34,19 +34,21 @@ source_set("distributed_point_functions") { sources = [ + "code/dpf/distributed_point_function.cc", + "code/dpf/distributed_point_function.h", + "code/dpf/internal/array_conversions.h", + "code/dpf/internal/pseudorandom_generator.cc", + "code/dpf/internal/pseudorandom_generator.h", + "code/dpf/status_macros.h", "glog/logging.h", - "src/dpf/distributed_point_function.cc", - "src/dpf/distributed_point_function.h", - "src/dpf/internal/array_conversions.h", - "src/dpf/internal/pseudorandom_generator.cc", - "src/dpf/internal/pseudorandom_generator.h", - "src/dpf/status_macros.h", ] public_deps = [ ":proto", "$dpf_abseil_cpp_dir:absl", + "//base", "//third_party/boringssl", + "//third_party/protobuf:protobuf_lite", ] # Do not apply Chromium code rules to this third-party code.
diff --git a/third_party/distributed_point_functions/DEPS b/third_party/distributed_point_functions/DEPS new file mode 100644 index 0000000..fa1f248 --- /dev/null +++ b/third_party/distributed_point_functions/DEPS
@@ -0,0 +1,12 @@ +include_rules = [ + "+absl", + "+benchmark", + "+dpf", + "+google/protobuf", +] + +specific_include_rules = { + "logging\.h": [ + "+base/check.h" + ] +}
diff --git a/third_party/distributed_point_functions/README.chromium b/third_party/distributed_point_functions/README.chromium index 4032e5b3..fb2adfc 100644 --- a/third_party/distributed_point_functions/README.chromium +++ b/third_party/distributed_point_functions/README.chromium
@@ -14,10 +14,11 @@ functions, based on the paper by Boneh et al. Local Modifications: -The directory src/ is an unchanged copy, and parts of -src/dpf/distributed_point_function_test.cc are adapted for fuzzing in +The directory code/ is an unchanged copy of the source code other than the +addition of a .clang-format file to disable automatic code formatting. Parts of +code/dpf/distributed_point_function_test.cc are also adapted for fuzzing in fuzz/dpf_fuzzer.cc. The source code pulled in depends on "glog/logging.h" which is not accessible -from chromium. As a workaround, we create a simple glog/logging.h that defines +from chromium. As a workaround, we create a simple glog/logging.h that includes the macros needed.
diff --git a/third_party/distributed_point_functions/code/.bazelci/presubmit.yml b/third_party/distributed_point_functions/code/.bazelci/presubmit.yml new file mode 100644 index 0000000..0d0a47ea --- /dev/null +++ b/third_party/distributed_point_functions/code/.bazelci/presubmit.yml
@@ -0,0 +1,8 @@ +tasks: + ubuntu2004: + build_targets: + - "//..." + test_flags: + - "--test_tag_filters=-benchmark" + test_targets: + - "//..."
diff --git a/third_party/distributed_point_functions/code/.clang-format b/third_party/distributed_point_functions/code/.clang-format new file mode 100644 index 0000000..e384528 --- /dev/null +++ b/third_party/distributed_point_functions/code/.clang-format
@@ -0,0 +1 @@ +DisableFormat: true
diff --git a/third_party/distributed_point_functions/code/.gitignore b/third_party/distributed_point_functions/code/.gitignore new file mode 100644 index 0000000..b803df0 --- /dev/null +++ b/third_party/distributed_point_functions/code/.gitignore
@@ -0,0 +1,2 @@ +# Bazel generated symlinks +bazel-*
diff --git a/third_party/distributed_point_functions/code/BUILD b/third_party/distributed_point_functions/code/BUILD new file mode 100644 index 0000000..bf2e8337 --- /dev/null +++ b/third_party/distributed_point_functions/code/BUILD
@@ -0,0 +1,5 @@ +load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") + +licenses(["notice"]) + +exports_files(["LICENSE"])
diff --git a/third_party/distributed_point_functions/code/CODE_OF_CONDUCT.md b/third_party/distributed_point_functions/code/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..dc079b4d --- /dev/null +++ b/third_party/distributed_point_functions/code/CODE_OF_CONDUCT.md
@@ -0,0 +1,93 @@ +# Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +This Code of Conduct also applies outside the project spaces when the Project +Steward has a reasonable belief that an individual's behavior may have a +negative impact on the project or its community. + +## Conflict Resolution + +We do not believe that all conflict is bad; healthy debate and disagreement +often yield positive results. However, it is never okay to be disrespectful or +to engage in behavior that violates the project’s code of conduct. + +If you see someone violating the code of conduct, you are encouraged to address +the behavior directly with those involved. Many issues can be resolved quickly +and easily, and this gives people more control over the outcome of their +dispute. If you are unable to resolve the matter for any reason, or if the +behavior is threatening or harassing, report it. We are dedicated to providing +an environment where participants feel welcome and safe. + +Reports should be directed to *[PROJECT STEWARD NAME(s) AND EMAIL(s)]*, the +Project Steward(s) for *[PROJECT NAME]*. It is the Project Steward’s duty to +receive and address reported violations of the code of conduct. They will then +work with a committee consisting of representatives from the Open Source +Programs Office and the Google Open Source Strategy team. If for any reason you +are uncomfortable reaching out to the Project Steward, please email +opensource@google.com. + +We will investigate every complaint, but you may not receive a direct response. +We will use our discretion in determining when and how to follow up on reported +incidents, which may range from not taking action to permanent expulsion from +the project and project-sponsored spaces. We will notify the accused of the +report and provide them an opportunity to discuss it before any action is taken. +The identity of the reporter will be omitted from the details of the report +supplied to the accused. In potentially harmful situations, such as ongoing +harassment or threats to anyone's safety, we may take action without notice. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
diff --git a/third_party/distributed_point_functions/code/CONTRIBUTING.md b/third_party/distributed_point_functions/code/CONTRIBUTING.md new file mode 100644 index 0000000..22b241c --- /dev/null +++ b/third_party/distributed_point_functions/code/CONTRIBUTING.md
@@ -0,0 +1,29 @@ +# How to Contribute + +We'd love to accept your patches and contributions to this project. There are +just a few small guidelines you need to follow. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement (CLA). You (or your employer) retain the copyright to your +contribution; this simply gives us permission to use and redistribute your +contributions as part of the project. Head over to +<https://cla.developers.google.com/> to see your current agreements on file or +to sign a new one. + +You generally only need to submit a CLA once, so if you've already submitted one +(even if it was for a different project), you probably don't need to do it +again. + +## Code reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. + +## Community Guidelines + +This project follows +[Google's Open Source Community Guidelines](https://opensource.google/conduct/).
diff --git a/third_party/distributed_point_functions/code/LICENSE b/third_party/distributed_point_functions/code/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/third_party/distributed_point_functions/code/LICENSE
@@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License.
diff --git a/third_party/distributed_point_functions/code/README.md b/third_party/distributed_point_functions/code/README.md new file mode 100644 index 0000000..9c7757c8 --- /dev/null +++ b/third_party/distributed_point_functions/code/README.md
@@ -0,0 +1,45 @@ +# An Implementation of Incremental Distributed Point Functions in C++ [](https://buildkite.com/bazel/google-distributed-point-functions) + +This library contains an implementation of incremental distributed point +functions, based on the following paper: +> Boneh, D., Boyle, E., Corrigan-Gibbs, H., Gilboa, N., & Ishai, Y. (2020). +Lightweight Techniques for Private Heavy Hitters. arXiv preprint +> arXiv:2012.14884. https://arxiv.org/abs/2012.14884 + +## About Incremental Distributed Point Functions + +A distributed point function (DPF) is parameterized by an index `alpha` and a +value `beta`. It consists of two algorithms: key generation and evaluation. +The key generation procedure produces two keys `k_a` and `k_b`, given `alpha` +and `beta`. Evaluating each key on any point `x` in the DPF domain results in an +additive secret share of `beta`, if `x == alpha`, and a share of 0 otherwise. + +Incremental DPFs additionally can be evaluated on prefixes of the index domain. +More precisely, an incremental DPF is parameterized by a hierarchy of index +domains, each a power of two larger than the previous. Key generation now takes +a vector `beta`, one value `beta[i]` for each hierarchy level. +When evaluated on a `b`-bit prefix of `alpha`, where b is the log domain size of +the `i`-th hierarchy level, the incremental DPF returns a secret share of +`beta[i]`, otherwise a share of 0. + +For more details, see the above paper, as well as the +[`DistributedPointFunction` class documentation](dpf/distributed_point_function.h). + + +## Building/Running Tests + +This repository requires Bazel. You can install Bazel by +following the instructions for your platform on the +[Bazel website](https://docs.bazel.build/versions/master/install.html). + +Once you have installed Bazel you can clone this repository and run all tests +that are included by navigating into the root folder and running: + +```bash +bazel test //... +``` + +## Disclaimer + +This is not an officially supported Google product. The code is provided as-is, +with no guarantees of correctness or security.
diff --git a/third_party/distributed_point_functions/code/WORKSPACE.bazel b/third_party/distributed_point_functions/code/WORKSPACE.bazel new file mode 100644 index 0000000..edf54cf --- /dev/null +++ b/third_party/distributed_point_functions/code/WORKSPACE.bazel
@@ -0,0 +1,117 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +# rules_proto defines abstract rules for building Protocol Buffers. +# https://github.com/bazelbuild/rules_proto +http_archive( + name = "rules_proto", + sha256 = "a4382f78723af788f0bc19fd4c8411f44ffe0a72723670a34692ffad56ada3ac", + strip_prefix = "rules_proto-f7a30f6f80006b591fa7c437fe5a951eb10bcbcf", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/f7a30f6f80006b591fa7c437fe5a951eb10bcbcf.zip", + "https://github.com/bazelbuild/rules_proto/archive/f7a30f6f80006b591fa7c437fe5a951eb10bcbcf.zip", + ], +) + +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") + +rules_proto_dependencies() + +rules_proto_toolchains() + +# rules_cc defines rules for generating C++ code from Protocol Buffers. +http_archive( + name = "rules_cc", + sha256 = "e0e0e15cd88a8cdc153268dddf698c921550c7a1819bba987b57d41b643d8e0a", + strip_prefix = "rules_cc-0a198b994a5d61412ea1622ce681d17dbdbdd027", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_cc/archive/0a198b994a5d61412ea1622ce681d17dbdbdd027.zip", + "https://github.com/bazelbuild/rules_cc/archive/0a198b994a5d61412ea1622ce681d17dbdbdd027.zip", + ], +) + +load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies") + +rules_cc_dependencies() + +# io_bazel_rules_go defines rules for generating C++ code from Protocol Buffers. +http_archive( + name = "io_bazel_rules_go", + sha256 = "c1a2f7457c060aaeab0ed9b711b14a75c758297062a7b20fefbecd3504427677", + strip_prefix = "rules_go-707c634bf8f7ca5b57c2a923bec16fa62ced1fc7", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/archive/707c634bf8f7ca5b57c2a923bec16fa62ced1fc7.zip", + "https://github.com/bazelbuild/rules_go/archive/707c634bf8f7ca5b57c2a923bec16fa62ced1fc7.zip", + ], +) + +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") + +go_rules_dependencies() + +go_register_toolchains(version = "1.15.5") + +# Install gtest. +http_archive( + name = "com_github_google_googletest", + sha256 = "1315261a037d90405714830edf4243fccd89950556353aa3d21095b6a1430ead", + strip_prefix = "googletest-6a5eb807493214be733d4cbb9f07f22fde25284f", + urls = [ + "https://mirror.bazel.build/github.com/google/googletest/archive/6a5eb807493214be733d4cbb9f07f22fde25284f.zip", + "https://github.com/google/googletest/archive/6a5eb807493214be733d4cbb9f07f22fde25284f.zip", + ], +) + +# abseil-cpp +http_archive( + name = "com_google_absl", + sha256 = "64c43686598cf554d9e91fa9a6dafd87a84d7ce9f667dccdd3971b5b249960dc", + strip_prefix = "abseil-cpp-3b4a16abad2c2ddc494371cc39a2946e36d35d11", + urls = [ + "https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/3b4a16abad2c2ddc494371cc39a2946e36d35d11.zip", + "https://github.com/abseil/abseil-cpp/archive/3b4a16abad2c2ddc494371cc39a2946e36d35d11.zip", + ], +) + +# BoringSSL +http_archive( + name = "boringssl", + sha256 = "fdaeff38523caba6c9d54ff99f811e8f055b88ce970a38da842f0ee322fbb405", + strip_prefix = "boringssl-7cc621db9c1011895bd070782cefe6cd7b5674b4", + urls = [ + "https://mirror.bazel.build/github.com/boringssl/boringssl/archive/7cc621db9c1011895bd070782cefe6cd7b5674b4.zip", + "https://github.com/boringssl/boringssl/archive/7cc621db9c1011895bd070782cefe6cd7b5674b4.zip", + ], +) + +# Benchmarks +http_archive( + name = "com_github_google_benchmark", + sha256 = "d37d3fb186bbcc30018962185606869c032e866bc9ad376a6112fbb64fe6935f", + strip_prefix = "benchmark-5e387e7d33a55b8d6b7c5025379b97cc9418fabf", + urls = [ + "https://mirror.bazel.build/github.com/google/benchmark/archive/5e387e7d33a55b8d6b7c5025379b97cc9418fabf.zip", + "https://github.com/google/benchmark/archive/5e387e7d33a55b8d6b7c5025379b97cc9418fabf.zip", + ], +) + +# gflags needed for glog. +http_archive( + name = "com_github_gflags_gflags", + sha256 = "cfdba0f2f17e8b1ff75c98113d5080d8ec016148426abcc19130864e2952d7bd", + strip_prefix = "gflags-827c769e5fc98e0f2a34c47cef953cc6328abced", + urls = [ + "https://mirror.bazel.build/github.com/gflags/gflags/archive/827c769e5fc98e0f2a34c47cef953cc6328abced.zip", + "https://github.com/gflags/gflags/archive/827c769e5fc98e0f2a34c47cef953cc6328abced.zip", + ], +) + +# glog for logging +http_archive( + name = "com_github_google_glog", + sha256 = "8476f6b3be29b3ebecc7de058183d510acec6e6dcef35d416cc3ac407a3a5645", + strip_prefix = "glog-a79416bab739907a31a1e139540921ff0492f010", + urls = [ + "https://mirror.bazel.build/github.com/google/glog/archive/a79416bab739907a31a1e139540921ff0492f010.zip", + "https://github.com/google/glog/archive/a79416bab739907a31a1e139540921ff0492f010.zip", + ], +)
diff --git a/third_party/distributed_point_functions/code/dpf/BUILD b/third_party/distributed_point_functions/code/dpf/BUILD new file mode 100644 index 0000000..e1cbce5a --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/BUILD
@@ -0,0 +1,73 @@ +load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") +load("@rules_cc//cc:defs.bzl", "cc_library") +load("@rules_proto//proto:defs.bzl", "proto_library") + +package( + default_visibility = ["//visibility:public"], +) + +licenses(["notice"]) + +cc_library( + name = "distributed_point_function", + srcs = ["distributed_point_function.cc"], + hdrs = ["distributed_point_function.h"], + deps = [ + ":distributed_point_function_cc_proto", + ":status_macros", + "//dpf/internal:array_conversions", + "//dpf/internal:pseudorandom_generator", + "@boringssl//:crypto", + "@com_github_google_glog//:glog", + "@com_google_absl//absl/container:btree", + "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings:str_format", + ], +) + +cc_test( + name = "distributed_point_function_test", + size = "medium", + srcs = ["distributed_point_function_test.cc"], + deps = [ + ":distributed_point_function", + "//dpf/internal:status_matchers", + "@com_github_google_googletest//:gtest_main", + "@com_google_absl//absl/random", + ], +) + +proto_library( + name = "distributed_point_function_proto", + srcs = ["distributed_point_function.proto"], +) + +cc_proto_library( + name = "distributed_point_function_cc_proto", + deps = [":distributed_point_function_proto"], +) + +go_proto_library( + name = "distributed_point_function_go_proto", + importpath = "github.com/google/distributed_point_functions/dpf/distributed_point_function_go_proto", + protos = [":distributed_point_function_proto"], +) + +cc_test( + name = "distributed_point_function_benchmark", + srcs = [ + "distributed_point_function_benchmark.cc", + ], + tags = ["benchmark"], + deps = [ + ":distributed_point_function", + "@com_github_google_benchmark//:benchmark_main", + "@com_google_absl//absl/random", + ], +) + +cc_library( + name = "status_macros", + hdrs = ["status_macros.h"], +)
diff --git a/third_party/distributed_point_functions/code/dpf/distributed_point_function.cc b/third_party/distributed_point_functions/code/dpf/distributed_point_function.cc new file mode 100644 index 0000000..cae3378 --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/distributed_point_function.cc
@@ -0,0 +1,998 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "dpf/distributed_point_function.h" + +#include <glog/logging.h> +#include <openssl/rand.h> + +#include <limits> + +#include "absl/container/btree_map.h" +#include "absl/container/flat_hash_map.h" +#include "absl/strings/str_format.h" +#include "dpf/internal/array_conversions.h" +#include "dpf/status_macros.h" + +namespace distributed_point_functions { + +namespace { + +// PRG keys used to expand seeds using AES. The first two are used to compute +// correction words of seeds, while the last is used to compute correction +// words of the incremental DPF values. Values were computed by taking the +// first half of the SHA256 sum of the constant name, e.g., `echo +// "DistributedPointFunction::kPrgKeyLeft" | sha256sum` +constexpr absl::uint128 kPrgKeyLeft = + absl::MakeUint128(0x5be037ccf6a03de5ULL, 0x935f08d0a5b6a2fdULL); +constexpr absl::uint128 kPrgKeyRight = + absl::MakeUint128(0xef94b6aedebb026cULL, 0xe2ea1fe0f66f4d0bULL); +constexpr absl::uint128 kPrgKeyValue = + absl::MakeUint128(0x05a5d1588c5423e3ULL, 0x46a31101b21d1c98ULL); + +// Extracts the lowest bit of `x` and sets it to 0 in `x`. +bool ExtractAndClearLowestBit(absl::uint128& x) { + bool bit = ((x & absl::uint128{1}) != 0); + x &= ~absl::uint128{1}; + return bit; +} + +// Computes the value correction word given two seeds `seed_a`, `seed_b` for +// parties a and b, such that the element at `block_index` is equal to `beta`. +// If `invert` is true, the result is multiplied element-wise by -1. Templated +// to use the correct integer type without needing modular reduction. +template <typename T> +absl::uint128 ComputeValueCorrectionFor(absl::Span<const absl::uint128> seeds, + int block_index, T beta, bool invert) { + constexpr int elements_per_block = dpf_internal::ElementsPerBlock<T>(); + + // Split up seeds into individual integers. + std::array<T, elements_per_block> ints_a = dpf_internal::Uint128ToArray<T>( + seeds[0]), + ints_b = dpf_internal::Uint128ToArray<T>( + seeds[1]); + + // Add beta to the right position. + ints_b[block_index] += beta; + + // Add up shares, invert if needed. + for (int i = 0; i < elements_per_block; i++) { + ints_b[i] = ints_b[i] - ints_a[i]; + if (invert) { + ints_b[i] = -ints_b[i]; + } + } + + // Re-assemble block. + return dpf_internal::ArrayToUint128(ints_b); +} + +} // namespace + +DistributedPointFunction::DistributedPointFunction( + std::vector<DpfParameters> parameters, int tree_levels_needed, + absl::flat_hash_map<int, int> tree_to_hierarchy, + std::vector<int> hierarchy_to_tree, + dpf_internal::PseudorandomGenerator prg_left, + dpf_internal::PseudorandomGenerator prg_right, + dpf_internal::PseudorandomGenerator prg_value) + : parameters_(std::move(parameters)), + tree_levels_needed_(tree_levels_needed), + tree_to_hierarchy_(std::move(tree_to_hierarchy)), + hierarchy_to_tree_(std::move(hierarchy_to_tree)), + prg_left_(std::move(prg_left)), + prg_right_(std::move(prg_right)), + prg_value_(std::move(prg_value)) {} + +absl::StatusOr<absl::uint128> DistributedPointFunction::ComputeValueCorrection( + int hierarchy_level, absl::Span<const absl::uint128> seeds, + absl::uint128 alpha, absl::uint128 beta, bool invert) const { + // Compute third PRG output component of current seed. + std::array<absl::uint128, 2> value_correction_shares; + DPF_RETURN_IF_ERROR( + prg_value_.Evaluate(seeds, absl::MakeSpan(value_correction_shares))); + + // Compute index in block for alpha at the current hierarchy level. + int index_in_block = DomainToBlockIndex(alpha, hierarchy_level); + + // Choose implementation depending on element_bitsize. + int element_bitsize = parameters_[hierarchy_level].element_bitsize(); + absl::uint128 value_correction; + switch (element_bitsize) { + case 8: + value_correction = + ComputeValueCorrectionFor(value_correction_shares, index_in_block, + static_cast<uint8_t>(beta), invert); + break; + case 16: + value_correction = + ComputeValueCorrectionFor(value_correction_shares, index_in_block, + static_cast<uint16_t>(beta), invert); + break; + case 32: + value_correction = + ComputeValueCorrectionFor(value_correction_shares, index_in_block, + static_cast<uint32_t>(beta), invert); + break; + case 64: + value_correction = + ComputeValueCorrectionFor(value_correction_shares, index_in_block, + static_cast<uint64_t>(beta), invert); + break; + case 128: + value_correction = + ComputeValueCorrectionFor(value_correction_shares, index_in_block, + static_cast<absl::uint128>(beta), invert); + break; + default: + return absl::UnimplementedError(absl::StrCat( + "`element_bitsize = ", element_bitsize, "` unimplemented")); + } + return value_correction; +} + +// Expands the PRG seeds at the next `tree_level`, updates `seeds` and +// `control_bits`, and writes the next correction word to `keys`. +absl::Status DistributedPointFunction::GenerateNext( + int tree_level, absl::uint128 alpha, absl::Span<const absl::uint128> beta, + absl::Span<absl::uint128> seeds, absl::Span<bool> control_bits, + absl::Span<DpfKey> keys) const { + // As in `GenerateKeysIncremental`, we annotate code with the corresponding + // lines from https://arxiv.org/pdf/2012.14884.pdf#figure.caption.12. + // + // Lines 13 & 14: Compute value correction word if there is a value on the + // current level. This is done here already, since we use the "PRG evaluation + // optimization" described in Appendix C.2 of the paper. Since we are using + // fixed-key AES as PRG, which can have arbitrary stretch, this optimization + // works even for large output groups. + CorrectionWord* correction_word = keys[0].add_correction_words(); + if (tree_to_hierarchy_.contains(tree_level - 1)) { + int hierarchy_level = tree_to_hierarchy_.at(tree_level - 1); + absl::uint128 alpha_prefix = 0; + int shift_amount = parameters_.back().log_domain_size() - + parameters_[hierarchy_level].log_domain_size(); + if (shift_amount < 128) { + alpha_prefix = alpha >> shift_amount; + } + DPF_ASSIGN_OR_RETURN( + absl::uint128 value_correction, + ComputeValueCorrection(hierarchy_level, seeds, alpha_prefix, + beta[hierarchy_level], control_bits[1])); + correction_word->mutable_output()->set_high( + absl::Uint128High64(value_correction)); + correction_word->mutable_output()->set_low( + absl::Uint128Low64(value_correction)); + } + + // Line 5: Expand seeds from previous level. + std::array<std::array<absl::uint128, 2>, 2> expanded_seeds; + DPF_RETURN_IF_ERROR( + prg_left_.Evaluate(seeds, absl::MakeSpan(expanded_seeds[0]))); + DPF_RETURN_IF_ERROR( + prg_right_.Evaluate(seeds, absl::MakeSpan(expanded_seeds[1]))); + std::array<std::array<bool, 2>, 2> expanded_control_bits; + expanded_control_bits[0][0] = ExtractAndClearLowestBit(expanded_seeds[0][0]); + expanded_control_bits[0][1] = ExtractAndClearLowestBit(expanded_seeds[0][1]); + expanded_control_bits[1][0] = ExtractAndClearLowestBit(expanded_seeds[1][0]); + expanded_control_bits[1][1] = ExtractAndClearLowestBit(expanded_seeds[1][1]); + + // Lines 6-8: Assign keep/lose branch depending on current bit of `alpha`. + bool current_bit = 0; + if (parameters_.back().log_domain_size() - tree_level < 128) { + current_bit = + (alpha & (absl::uint128{1} + << (parameters_.back().log_domain_size() - tree_level))) != 0; + } + bool keep = current_bit, lose = !current_bit; + + // Line 9: Compute seed correction word. + absl::uint128 seed_correction = + expanded_seeds[lose][0] ^ expanded_seeds[lose][1]; + + // Line 10: Compute control bit correction words. + std::array<bool, 2> control_bit_correction; + control_bit_correction[0] = expanded_control_bits[0][0] ^ + expanded_control_bits[0][1] ^ current_bit ^ 1; + control_bit_correction[1] = + expanded_control_bits[1][0] ^ expanded_control_bits[1][1] ^ current_bit; + + // We swap lines 11 and 12, since we first need to use the previous level's + // control bits before updating them. + + // Line 12: Update seeds. Note that there is a typo in the paper: The + // multiplication / AND needs to be done with the control bit of iteration + // l-1, not l. Note that unlike the original algorithm, we are using the + // corrected seed directly for the next iteration. This is secure as we're + // using AES with a different key (kPrgKeyValue) to compute the value + // correction word below. + seeds[0] = expanded_seeds[keep][0]; + seeds[1] = expanded_seeds[keep][1]; + if (control_bits[0]) { + seeds[0] ^= seed_correction; + } + if (control_bits[1]) { + seeds[1] ^= seed_correction; + } + + // Line 11: Update control bits. Again, same typo as in Line 12. + control_bits[0] = expanded_control_bits[keep][0] ^ + (control_bits[0] & control_bit_correction[keep]); + control_bits[1] = expanded_control_bits[keep][1] ^ + (control_bits[1] & control_bit_correction[keep]); + + // Line 15: Assemble correction word and add it to keys[0]. + correction_word->mutable_seed()->set_high( + absl::Uint128High64(seed_correction)); + correction_word->mutable_seed()->set_low(absl::Uint128Low64(seed_correction)); + correction_word->set_control_left(control_bit_correction[0]); + correction_word->set_control_right(control_bit_correction[1]); + + // Copy correction word to second key. + *(keys[1].add_correction_words()) = *correction_word; + + return absl::OkStatus(); +} + +absl::Status DistributedPointFunction::CheckContextParameters( + const EvaluationContext& ctx) const { + if (ctx.parameters_size() != static_cast<int>(parameters_.size())) { + return absl::InvalidArgumentError( + "Number of parameters in `ctx` doesn't match"); + } + if (ctx.previous_hierarchy_level() >= ctx.parameters_size() - 1) { + return absl::InvalidArgumentError( + "This context has already been fully evaluated"); + } + if (!ctx.partial_evaluations().empty() && + ctx.partial_evaluations_level() >= ctx.previous_hierarchy_level()) { + return absl::InvalidArgumentError( + "ctx.previous_hierarchy_level must be less than ctx.hierarchy_level"); + } + for (int i = 0; i < ctx.parameters_size(); ++i) { + if (ctx.parameters(i).log_domain_size() != + parameters_[i].log_domain_size() || + ctx.parameters(i).element_bitsize() != + parameters_[i].element_bitsize()) { + return absl::InvalidArgumentError( + absl::StrCat("Parameter ", i, " in `ctx` doesn't match")); + } + } + return absl::OkStatus(); +} + +absl::uint128 DistributedPointFunction::DomainToTreeIndex( + absl::uint128 domain_index, int hierarchy_level) const { + int block_index_bits = parameters_[hierarchy_level].log_domain_size() - + hierarchy_to_tree_[hierarchy_level]; + DCHECK(block_index_bits < 128); + return domain_index >> block_index_bits; +} + +int DistributedPointFunction::DomainToBlockIndex(absl::uint128 domain_index, + int hierarchy_level) const { + int block_index_bits = parameters_[hierarchy_level].log_domain_size() - + hierarchy_to_tree_[hierarchy_level]; + DCHECK(block_index_bits < 128); + return static_cast<int>(domain_index & + ((absl::uint128{1} << block_index_bits) - 1)); +} + +absl::StatusOr<DistributedPointFunction::DpfExpansion> +DistributedPointFunction::EvaluateSeeds( + DpfExpansion partial_evaluations, absl::Span<const absl::uint128> paths, + absl::Span<const CorrectionWord* const> correction_words) const { + if (partial_evaluations.seeds.size() != + partial_evaluations.control_bits.size() || + partial_evaluations.seeds.size() != paths.size()) { + return absl::InvalidArgumentError( + "partial_evaluations.seeds.size(), " + "partial_evaluations.control_bits.size() and paths.size() must " + "all be equal"); + } + auto num_seeds = static_cast<int64_t>(partial_evaluations.seeds.size()); + auto num_levels = static_cast<int>(correction_words.size()); + int64_t max_batch_size = dpf_internal::PseudorandomGenerator::kBatchSize; + + // Allocate output and temporary buffers. + DpfExpansion result = std::move(partial_evaluations); + std::vector<absl::uint128> buffer_left, buffer_right; + buffer_left.reserve(max_batch_size); + buffer_right.reserve(max_batch_size); + BitVector current_bits(max_batch_size); + + // Parse correction words for faster access (we access them once for each + // batch). + std::vector<absl::uint128> correction_seeds(num_levels); + BitVector correction_controls_left(num_levels); + BitVector correction_controls_right(num_levels); + for (int level = 0; level < num_levels; ++level) { + const CorrectionWord& correction = *(correction_words[level]); + correction_seeds[level] = + absl::MakeUint128(correction.seed().high(), correction.seed().low()); + correction_controls_left[level] = correction.control_left(); + correction_controls_right[level] = correction.control_right(); + } + + // Perform DPF evaluation in blocks. + for (int64_t start_block = 0; start_block < num_seeds; + start_block += max_batch_size) { + int64_t current_batch_size = + std::min<int64_t>(num_seeds - start_block, max_batch_size); + for (int level = 0; level < num_levels; ++level) { + // Sort seeds into left and right depending on the current bit of the + // corresponding prefix. + int bit_index = num_levels - level - 1; + for (int i = 0; i < current_batch_size; ++i) { + current_bits[i] = 0; + if (bit_index < 128) { + current_bits[i] = + (paths[start_block + i] & (absl::uint128{1} << bit_index)) != 0; + } + if (current_bits[i] == 0) { + buffer_left.push_back(result.seeds[start_block + i]); + } else { + buffer_right.push_back(result.seeds[start_block + i]); + } + } + + // Compute PRG. + DPF_RETURN_IF_ERROR( + prg_left_.Evaluate(buffer_left, absl::MakeSpan(buffer_left))); + DPF_RETURN_IF_ERROR( + prg_right_.Evaluate(buffer_right, absl::MakeSpan(buffer_right))); + + // Merge back into result and compute correction. + int64_t left_index = 0, right_index = 0; + for (int i = 0; i < current_batch_size; ++i) { + absl::uint128 current_seed; + if (current_bits[i] == 0) { + current_seed = buffer_left[left_index]; + ++left_index; + } else { + current_seed = buffer_right[right_index]; + ++right_index; + } + if (result.control_bits[start_block + i]) { + current_seed ^= correction_seeds[level]; + } + bool current_control_bit = ExtractAndClearLowestBit(current_seed); + if (result.control_bits[start_block + i]) { + if (current_bits[i] == 0) { + current_control_bit ^= correction_controls_left[level]; + } else { + current_control_bit ^= correction_controls_right[level]; + } + } + result.seeds[start_block + i] = current_seed; + result.control_bits[start_block + i] = current_control_bit; + } + buffer_left.resize(0); + buffer_right.resize(0); + } + } + return result; +} + +absl::StatusOr<DistributedPointFunction::DpfExpansion> +DistributedPointFunction::ExpandSeeds( + const DpfExpansion& partial_evaluations, + absl::Span<const CorrectionWord* const> correction_words) const { + int num_expansions = static_cast<int>(correction_words.size()); + DCHECK(num_expansions < 63); + + // Allocate buffers with the correct size to avoid reallocations. + auto current_level_size = + static_cast<int64_t>(partial_evaluations.seeds.size()); + int64_t max_batch_size = dpf_internal::PseudorandomGenerator::kBatchSize; + int64_t output_size = current_level_size << num_expansions; + std::vector<absl::uint128> prg_buffer_left(max_batch_size), + prg_buffer_right(max_batch_size); + + // Copy seeds and control bits. We will swap these after every expansion. + DpfExpansion expansion = partial_evaluations; + expansion.seeds.reserve(output_size); + expansion.control_bits.reserve(output_size); + DpfExpansion next_level_expansion; + next_level_expansion.seeds.reserve(output_size); + next_level_expansion.control_bits.reserve(output_size); + + // We use an iterative expansion here to pipeline AES as much as possible. + for (int i = 0; i < num_expansions; ++i) { + next_level_expansion.seeds.resize(2 * current_level_size); + next_level_expansion.control_bits.resize(2 * current_level_size); + absl::uint128 correction_seed = absl::MakeUint128( + correction_words[i]->seed().high(), correction_words[i]->seed().low()); + bool correction_control_left = correction_words[i]->control_left(); + bool correction_control_right = correction_words[i]->control_right(); + // Expand PRG. + for (int64_t start_block = 0; start_block < current_level_size; + start_block += max_batch_size) { + int64_t batch_size = + std::min<int64_t>(current_level_size - start_block, max_batch_size); + DPF_RETURN_IF_ERROR(prg_left_.Evaluate( + absl::MakeConstSpan(expansion.seeds).subspan(start_block, batch_size), + absl::MakeSpan(prg_buffer_left).subspan(0, batch_size))); + DPF_RETURN_IF_ERROR(prg_right_.Evaluate( + absl::MakeConstSpan(expansion.seeds).subspan(start_block, batch_size), + absl::MakeSpan(prg_buffer_right).subspan(0, batch_size))); + + // Merge results into next level of seeds and perform correction. + for (int64_t j = 0; j < batch_size; ++j) { + int64_t index_expanded = 2 * (start_block + j); + if (expansion.control_bits[start_block + j]) { + prg_buffer_left[j] ^= correction_seed; + prg_buffer_right[j] ^= correction_seed; + } + next_level_expansion.seeds[index_expanded] = prg_buffer_left[j]; + next_level_expansion.seeds[index_expanded + 1] = prg_buffer_right[j]; + next_level_expansion.control_bits[index_expanded] = + ExtractAndClearLowestBit( + next_level_expansion.seeds[index_expanded]); + next_level_expansion.control_bits[index_expanded + 1] = + ExtractAndClearLowestBit( + next_level_expansion.seeds[index_expanded + 1]); + if (expansion.control_bits[start_block + j]) { + next_level_expansion.control_bits[index_expanded] ^= + correction_control_left; + next_level_expansion.control_bits[index_expanded + 1] ^= + correction_control_right; + } + } + } + std::swap(expansion, next_level_expansion); + current_level_size *= 2; + } + return expansion; +} + +absl::StatusOr<DistributedPointFunction::DpfExpansion> +DistributedPointFunction::ComputePartialEvaluations( + absl::Span<const absl::uint128> prefixes, bool update_ctx, + EvaluationContext& ctx) const { + int64_t num_prefixes = static_cast<int64_t>(prefixes.size()); + + DpfExpansion partial_evaluations; + int start_level = hierarchy_to_tree_[ctx.partial_evaluations_level()]; + int stop_level = hierarchy_to_tree_[ctx.previous_hierarchy_level()]; + if (ctx.partial_evaluations_size() > 0 && start_level <= stop_level) { + // We have partial evaluations from a tree level before the current one. + // Parse `ctx.partial_evaluations` into a btree_map for quick lookups up by + // prefix. We use a btree_map because `ctx.partial_evaluations()` will + // usually be sorted. + absl::btree_map<absl::uint128, std::pair<absl::uint128, bool>> + previous_partial_evaluations; + for (const PartialEvaluation& element : ctx.partial_evaluations()) { + absl::uint128 prefix = + absl::MakeUint128(element.prefix().high(), element.prefix().low()); + // Try inserting `(seed, control_bit)` at `prefix` into + // partial_evaluations. Return an error if `prefix` is already present. + int64_t previous_size = previous_partial_evaluations.size(); + previous_partial_evaluations.try_emplace( + previous_partial_evaluations.end(), prefix, + std::make_pair( + absl::MakeUint128(element.seed().high(), element.seed().low()), + element.control_bit())); + if (previous_partial_evaluations.size() <= previous_size) { + return absl::InvalidArgumentError( + "Duplicate prefix in `ctx.partial_evaluations()`"); + } + } + // Now select all partial evaluations from the map that correspond to + // `prefixes`. + partial_evaluations.seeds.reserve(prefixes.size()); + partial_evaluations.control_bits.reserve(prefixes.size()); + for (int64_t i = 0; i < num_prefixes; ++i) { + absl::uint128 previous_prefix = 0; + if (stop_level - start_level < 128) { + previous_prefix = prefixes[i] >> (stop_level - start_level); + } + auto it = previous_partial_evaluations.find(previous_prefix); + if (it == previous_partial_evaluations.end()) { + return absl::InvalidArgumentError(absl::StrCat( + "Prefix not present in ctx.partial_evaluations at hierarchy level ", + ctx.previous_hierarchy_level())); + } + std::pair<absl::uint128, bool> partial_evaluation = it->second; + partial_evaluations.seeds.push_back(partial_evaluation.first); + partial_evaluations.control_bits.push_back(partial_evaluation.second); + } + } else { + // No partial evaluations in `ctx` -> Start from the beginning. + partial_evaluations.seeds.resize( + num_prefixes, + absl::MakeUint128(ctx.key().seed().high(), ctx.key().seed().low())); + partial_evaluations.control_bits.resize( + num_prefixes, static_cast<bool>(ctx.key().party())); + start_level = 0; + } + + // Evaluate the DPF up to current_tree_level. + DPF_ASSIGN_OR_RETURN( + partial_evaluations, + EvaluateSeeds(std::move(partial_evaluations), prefixes, + absl::MakeConstSpan(ctx.key().correction_words()) + .subspan(start_level, stop_level - start_level))); + + // Update `partial_evaluations` in `ctx` if there are more evaluations to + // come. + ctx.clear_partial_evaluations(); + ctx.mutable_partial_evaluations()->Reserve(num_prefixes); + if (update_ctx) { + for (int64_t i = 0; i < num_prefixes; ++i) { + PartialEvaluation* current_element = ctx.add_partial_evaluations(); + current_element->mutable_prefix()->set_high( + absl::Uint128High64(prefixes[i])); + current_element->mutable_prefix()->set_low( + absl::Uint128Low64(prefixes[i])); + current_element->mutable_seed()->set_high( + absl::Uint128High64(partial_evaluations.seeds[i])); + current_element->mutable_seed()->set_low( + absl::Uint128Low64(partial_evaluations.seeds[i])); + current_element->set_control_bit(partial_evaluations.control_bits[i]); + } + } + ctx.set_partial_evaluations_level(ctx.previous_hierarchy_level()); + return partial_evaluations; +} + +absl::StatusOr<DistributedPointFunction::DpfExpansion> +DistributedPointFunction::ExpandAndUpdateContext( + int hierarchy_level, absl::Span<const absl::uint128> prefixes, + EvaluationContext& ctx) const { + // Expand seeds by expanding either the DPF key seed, or + // `ctx.partial_evaluations` for the given `prefixes`. + DpfExpansion selected_partial_evaluations; + int start_level = 0; + if (prefixes.empty()) { + // First expansion -> Expand seed of the DPF key. + selected_partial_evaluations.seeds = { + absl::MakeUint128(ctx.key().seed().high(), ctx.key().seed().low())}; + selected_partial_evaluations.control_bits = { + static_cast<bool>(ctx.key().party())}; + } else { + // Second or later expansion -> Extract all seeds for `prefixes` from + // `ctx.partial_evaluations`. Update `ctx` if this is not the last + // evaluation. + bool update_ctx = + (hierarchy_level < static_cast<int>(parameters_.size()) - 1); + DPF_ASSIGN_OR_RETURN(selected_partial_evaluations, + ComputePartialEvaluations(prefixes, update_ctx, ctx)); + DCHECK(ctx.previous_hierarchy_level() >= 0); + start_level = hierarchy_to_tree_[ctx.previous_hierarchy_level()]; + } + + // Expand up to the next hierarchy level. + int stop_level = hierarchy_to_tree_[hierarchy_level]; + DPF_ASSIGN_OR_RETURN( + DpfExpansion expansion, + ExpandSeeds(selected_partial_evaluations, + absl::MakeConstSpan(ctx.key().correction_words()) + .subspan(start_level, stop_level - start_level))); + + // Update hierarchy level in ctx. + ctx.set_previous_hierarchy_level(hierarchy_level); + return expansion; +} + +absl::StatusOr<std::unique_ptr<DistributedPointFunction>> +DistributedPointFunction::Create(const DpfParameters& parameters) { + return CreateIncremental(absl::MakeConstSpan(¶meters, 1)); +} + +absl::StatusOr<std::unique_ptr<DistributedPointFunction>> +DistributedPointFunction::CreateIncremental( + absl::Span<const DpfParameters> parameters) { + // Check that parameters are valid. + if (parameters.empty()) { + return absl::InvalidArgumentError("`parameters` must not be empty"); + } + // Sentinel values for checking that domain sizes are increasing and not too + // far apart, and element sizes are non-decreasing. + int previous_log_domain_size = 0; + int previous_element_bitsize = 1; + for (int i = 0; i < static_cast<int>(parameters.size()); ++i) { + // Check log_domain_size. + int32_t log_domain_size = parameters[i].log_domain_size(); + if (log_domain_size < 0) { + return absl::InvalidArgumentError( + "`log_domain_size` must be non-negative"); + } + if (i > 0 && log_domain_size <= previous_log_domain_size) { + return absl::InvalidArgumentError( + "`log_domain_size` fields must be in ascending order in " + "`parameters`"); + } + // For full evaluation of a particular hierarchy level, want to be able to + // represent 1 << (log_domain_size - previous_log_domain_size) in an + // int64_t, so hierarchy levels may be at most 62 apart. Note that such + // large gaps between levels are rare in practice, and in any case this + // error can circumvented by adding additional intermediate hierarchy + // levels. + if (log_domain_size > previous_log_domain_size + 62) { + return absl::InvalidArgumentError( + "Hierarchies may be at most 62 levels apart"); + } + previous_log_domain_size = log_domain_size; + + // Check element_bitsize. + int32_t element_bitsize = parameters[i].element_bitsize(); + if (element_bitsize < 1) { + return absl::InvalidArgumentError("`element_bitsize` must be positive"); + } + if (element_bitsize > 128) { + return absl::InvalidArgumentError( + "`element_bitsize` must be less than or equal to 128"); + } + if ((element_bitsize & (element_bitsize - 1)) != 0) { + return absl::InvalidArgumentError( + "`element_bitsize` must be a power of 2"); + } + if (element_bitsize < previous_element_bitsize) { + return absl::InvalidArgumentError( + "`element_bitsize` fields must be non-decreasing in " + "`parameters`"); + } + previous_element_bitsize = element_bitsize; + } + + // Map hierarchy levels to levels in the evaluation tree for value correction, + // and vice versa. + absl::flat_hash_map<int, int> tree_to_hierarchy; + std::vector<int> hierarchy_to_tree(parameters.size()); + // Also keep track of the height needed for the evaluation tree so far. + int tree_levels_needed = 0; + for (int i = 0; i < static_cast<int>(parameters.size()); ++i) { + int log_element_size = + static_cast<int>(std::log2(parameters[i].element_bitsize())); + // The tree level depends on the domain size and the element size. A single + // AES block can fit 128 = 2^7 bits, so usually tree_level == + // log_domain_size iff log_element_size == 7. For smaller element sizes, we + // can reduce the tree_level (and thus the height of the tree) by the + // difference between log_element_size and 7. However, since the minimum + // tree level is 0, we have to ensure that no two hierarchy levels map to + // the same tree_level, hence the std::max. + int tree_level = + std::max(tree_levels_needed, + parameters[i].log_domain_size() - 7 + log_element_size); + tree_to_hierarchy[tree_level] = i; + hierarchy_to_tree[i] = tree_level; + tree_levels_needed = std::max(tree_levels_needed, tree_level + 1); + } + + // Set up PRGs. + DPF_ASSIGN_OR_RETURN( + dpf_internal::PseudorandomGenerator prg_left, + dpf_internal::PseudorandomGenerator::Create(kPrgKeyLeft)); + DPF_ASSIGN_OR_RETURN( + dpf_internal::PseudorandomGenerator prg_right, + dpf_internal::PseudorandomGenerator::Create(kPrgKeyRight)); + DPF_ASSIGN_OR_RETURN( + dpf_internal::PseudorandomGenerator prg_value, + dpf_internal::PseudorandomGenerator::Create(kPrgKeyValue)); + + // Copy parameters and return new DPF. + return absl::WrapUnique(new DistributedPointFunction( + std::vector<DpfParameters>(parameters.begin(), parameters.end()), + tree_levels_needed, std::move(tree_to_hierarchy), + std::move(hierarchy_to_tree), std::move(prg_left), std::move(prg_right), + std::move(prg_value))); +} + +absl::StatusOr<std::pair<DpfKey, DpfKey>> +DistributedPointFunction::GenerateKeys(absl::uint128 alpha, + absl::uint128 beta) const { + return GenerateKeysIncremental(alpha, absl::MakeConstSpan(&beta, 1)); +} + +absl::StatusOr<std::pair<DpfKey, DpfKey>> +DistributedPointFunction::GenerateKeysIncremental( + absl::uint128 alpha, absl::Span<const absl::uint128> beta) const { + // Check validity of beta. + if (beta.size() != parameters_.size()) { + return absl::InvalidArgumentError( + "`beta` has to have the same size as `parameters` passed at " + "construction"); + } + for (int i = 0; i < static_cast<int>(parameters_.size()); ++i) { + if (parameters_[i].element_bitsize() < 128 && + beta[i] >= (absl::uint128{1} << (parameters_[i].element_bitsize()))) { + return absl::InvalidArgumentError( + absl::StrCat("`beta[", i, "]` larger than `parameters[", i, + "].element_bitsize()` allows")); + } + } + + // Check validity of alpha. + int last_level_log_domain_size = parameters_.back().log_domain_size(); + if (last_level_log_domain_size < 128 && + alpha >= (absl::uint128{1} << last_level_log_domain_size)) { + return absl::InvalidArgumentError( + "`alpha` must be smaller than the output domain size"); + } + + std::array<DpfKey, 2> keys; + keys[0].set_party(0); + keys[1].set_party(1); + + // We will annotate the following code with the corresponding lines from the + // pseudocode in the Incremental DPF paper + // (https://arxiv.org/pdf/2012.14884.pdf, Figure 11). + // + // There are two possible dimensions for each variable at each level: Parties + // (0 or 1) and branches (left or right). For two-dimensional arrays, we use + // the outer dimension for the branch, and the inner dimension for the party. + // + // Line 2: Sample random seeds for each party. + std::array<absl::uint128, 2> seeds; + RAND_bytes(reinterpret_cast<uint8_t*>(&seeds[0]), sizeof(absl::uint128)); + RAND_bytes(reinterpret_cast<uint8_t*>(&seeds[1]), sizeof(absl::uint128)); + keys[0].mutable_seed()->set_high(absl::Uint128High64(seeds[0])); + keys[0].mutable_seed()->set_low(absl::Uint128Low64(seeds[0])); + keys[1].mutable_seed()->set_high(absl::Uint128High64(seeds[1])); + keys[1].mutable_seed()->set_low(absl::Uint128Low64(seeds[1])); + + // Line 3: Initialize control bits. + std::array<bool, 2> control_bits{0, 1}; + + // Line 4: Compute correction words for each level after the first one. + keys[0].mutable_correction_words()->Reserve(tree_levels_needed_ - 1); + for (int i = 1; i < tree_levels_needed_; i++) { + DPF_RETURN_IF_ERROR(GenerateNext(i, alpha, beta, absl::MakeSpan(seeds), + absl::MakeSpan(control_bits), + absl::MakeSpan(keys))); + } + + // Compute output correction word for last layer. + DPF_ASSIGN_OR_RETURN( + absl::uint128 last_level_output_correction, + ComputeValueCorrection(parameters_.size() - 1, seeds, alpha, beta.back(), + control_bits[1])); + keys[0].mutable_last_level_output_correction()->set_high( + absl::Uint128High64(last_level_output_correction)); + keys[0].mutable_last_level_output_correction()->set_low( + absl::Uint128Low64(last_level_output_correction)); + keys[1].mutable_last_level_output_correction()->set_high( + absl::Uint128High64(last_level_output_correction)); + keys[1].mutable_last_level_output_correction()->set_low( + absl::Uint128Low64(last_level_output_correction)); + + return std::make_pair(std::move(keys[0]), std::move(keys[1])); +} + +absl::StatusOr<EvaluationContext> +DistributedPointFunction::CreateEvaluationContext(DpfKey key) { + // Check that `key` is valid for this DPF. + if (key.correction_words_size() != tree_levels_needed_ - 1) { + return absl::InvalidArgumentError(absl::StrCat( + "Malformed DpfKey: expected ", tree_levels_needed_ - 1, + " correction words, but got ", key.correction_words_size())); + } + for (int i = 0; i < static_cast<int>(hierarchy_to_tree_.size()); ++i) { + if (hierarchy_to_tree_[i] == tree_levels_needed_ - 1) { + // The output correction of the last tree level is always stored in + // last_level_output_correction. + continue; + } + if (!key.correction_words(hierarchy_to_tree_[i]).has_output()) { + return absl::InvalidArgumentError(absl::StrCat( + "Malformed DpfKey: expected correction_words[", hierarchy_to_tree_[i], + "] to contain the output correction of hierarchy level ", i)); + } + } + // Create new EvaluationContext with `parameters_` and `key`. + EvaluationContext result; + for (int i = 0; i < static_cast<int>(parameters_.size()); ++i) { + *(result.add_parameters()) = parameters_[i]; + } + *(result.mutable_key()) = std::move(key); + // previous_hierarchy_level = -1 means that this context has not been + // evaluated at all. + result.set_previous_hierarchy_level(-1); + return result; +} + +template <typename T> +absl::StatusOr<std::vector<T>> DistributedPointFunction::EvaluateUntil( + int hierarchy_level, absl::Span<const absl::uint128> prefixes, + EvaluationContext& ctx) const { + DPF_RETURN_IF_ERROR(CheckContextParameters(ctx)); + if (hierarchy_level < 0 || + hierarchy_level >= static_cast<int>(parameters_.size())) { + return absl::InvalidArgumentError( + "`hierarchy_level` must be non-negative and less than " + "parameters_.size()"); + } + if (sizeof(T) * 8 != parameters_[hierarchy_level].element_bitsize()) { + return absl::InvalidArgumentError( + "Size of template parameter T doesn't match the element size of " + "`hierarchy_level`"); + } + if (hierarchy_level <= ctx.previous_hierarchy_level()) { + return absl::InvalidArgumentError( + "`hierarchy_level` must be greater than " + "`ctx.previous_hierarchy_level`"); + } + if ((ctx.previous_hierarchy_level() < 0) != (prefixes.empty())) { + return absl::InvalidArgumentError( + "`prefixes` must be empty if and only if this is the first call with " + "`ctx`."); + } + + int previous_log_domain_size = 0; + int previous_hierarchy_level = ctx.previous_hierarchy_level(); + if (!prefixes.empty()) { + DCHECK(ctx.previous_hierarchy_level() >= 0); + previous_log_domain_size = + parameters_[previous_hierarchy_level].log_domain_size(); + for (absl::uint128 prefix : prefixes) { + if (previous_log_domain_size < 128 && + prefix > (absl::uint128{1} << previous_log_domain_size)) { + return absl::InvalidArgumentError( + absl::StrFormat("Index %d out of range for hierarchy level %d", + prefix, previous_hierarchy_level)); + } + } + } + int64_t prefixes_size = static_cast<int64_t>(prefixes.size()); + + // The `prefixes` passed in by the caller refer to the domain of the previous + // hierarchy level. However, because we batch multiple elements of type T in a + // single uint128 block, multiple prefixes can actually refer to the same + // block in the FSS evaluation tree. On a high level, our approach is as + // follows: + // + // 1. Split up each element of `prefixes` into a tree index, pointing to a + // block in the FSS tree, and a block index, pointing to an element of type + // T in that block. + // + // 2. Compute a list of unique `tree_indices`, and for each original prefix, + // remember the position of the corresponding tree index in `tree_indices`. + // + // 3. After expanding the unique `tree_indices`, use the positions saved in + // Step (2) together with the corresponding block index to retrieve the + // expanded values for each prefix, and return them in the same order as + // `prefixes`. + // + // `tree_indices` holds the unique tree indices from `prefixes`, to be passed + // to `ExpandAndUpdateContext`. + std::vector<absl::uint128> tree_indices; + tree_indices.reserve(prefixes_size); + // `tree_indices_inverse` is the inverse of `tree_indices`, used for + // deduplicating and constructing `prefix_map`. Use a btree_map because we + // expect `prefixes` (and thus `tree_indices`) to be sorted. + absl::btree_map<absl::uint128, int64_t> tree_indices_inverse; + // `prefix_map` maps each i < prefixes.size() to an element of `tree_indices` + // and a block index. Used to select which elements to return after the + // expansion, to ensure the result is ordered the same way as `prefixes`. + std::vector<std::pair<int64_t, int>> prefix_map; + prefix_map.reserve(prefixes_size); + for (int64_t i = 0; i < prefixes_size; ++i) { + absl::uint128 tree_index = + DomainToTreeIndex(prefixes[i], previous_hierarchy_level); + int block_index = DomainToBlockIndex(prefixes[i], previous_hierarchy_level); + + // Check if `tree_index` already exists in `tree_indices`. + int64_t previous_size = tree_indices_inverse.size(); + auto it = tree_indices_inverse.try_emplace(tree_indices_inverse.end(), + tree_index, tree_indices.size()); + if (tree_indices_inverse.size() > previous_size) { + tree_indices.push_back(tree_index); + } + prefix_map.push_back(std::make_pair(it->second, block_index)); + } + + // Perform expansion of unique `tree_indices`. + DPF_ASSIGN_OR_RETURN( + DpfExpansion expansion, + ExpandAndUpdateContext(hierarchy_level, tree_indices, ctx)); + + // Get output correction word from `ctx`. + constexpr int elements_per_block = dpf_internal::ElementsPerBlock<T>(); + const Block* output_correction = nullptr; + if (hierarchy_level < static_cast<int>(parameters_.size()) - 1) { + output_correction = + &(ctx.key() + .correction_words(hierarchy_to_tree_[hierarchy_level]) + .output()); + } else { + // Last level output correction is stored in an extra proto field, since we + // have one less correction word than tree levels. + output_correction = &(ctx.key().last_level_output_correction()); + } + + // Split output correction into elements of type T. + std::array<T, elements_per_block> correction_ints = + dpf_internal::Uint128ToArray<T>(absl::MakeUint128( + output_correction->high(), output_correction->low())); + + // Compute output PRG value of expanded seeds using prg_ctx_value_. + std::vector<absl::uint128> hashed_expansion(expansion.seeds.size()); + DPF_RETURN_IF_ERROR( + prg_value_.Evaluate(expansion.seeds, absl::MakeSpan(hashed_expansion))); + + // Compute value corrections for each block in `expanded_seeds`. We have to + // account for the fact that blocks might not be full (i.e., have less than + // elements_per_block elements). + const int corrected_elements_per_block = + 1 << (parameters_[hierarchy_level].log_domain_size() - + hierarchy_to_tree_[hierarchy_level]); + std::vector<T> corrected_expansion(hashed_expansion.size() * + corrected_elements_per_block); + for (int64_t i = 0; i < static_cast<int64_t>(hashed_expansion.size()); ++i) { + std::array<T, elements_per_block> current_elements = + dpf_internal::Uint128ToArray<T>(hashed_expansion[i]); + for (int j = 0; j < corrected_elements_per_block; ++j) { + if (expansion.control_bits[i]) { + current_elements[j] += correction_ints[j]; + } + if (ctx.key().party() == 1) { + current_elements[j] = -current_elements[j]; + } + corrected_expansion[i * corrected_elements_per_block + j] = + current_elements[j]; + } + } + + // Compute the number of outputs we will have. For each prefix, we will have a + // full expansion from the previous heirarchy level to the current heirarchy + // level. + int log_domain_size = parameters_[hierarchy_level].log_domain_size(); + DCHECK(log_domain_size - previous_log_domain_size < 63); + int64_t outputs_per_prefix = int64_t{1} + << (log_domain_size - previous_log_domain_size); + + if (prefixes.empty()) { + // If prefixes is empty (i.e., this is the first evaluation of `ctx`), just + // return the expansion. + DCHECK(static_cast<int>(corrected_expansion.size()) == outputs_per_prefix); + return corrected_expansion; + } else { + // Otherwise, only return elements under `prefixes`. + int blocks_per_tree_prefix = expansion.seeds.size() / tree_indices.size(); + std::vector<T> result(prefixes_size * outputs_per_prefix); + for (int64_t i = 0; i < prefixes_size; ++i) { + int64_t prefix_expansion_start = + prefix_map[i].first * blocks_per_tree_prefix * + corrected_elements_per_block + + prefix_map[i].second * outputs_per_prefix; + std::copy_n(&corrected_expansion[prefix_expansion_start], + outputs_per_prefix, &result[i * outputs_per_prefix]); + } + return result; + } +} + +// Template instantiations for all types we support. +template absl::StatusOr<std::vector<uint8_t>> +DistributedPointFunction::EvaluateUntil( + int hierarchy_level, absl::Span<const absl::uint128> prefixes, + EvaluationContext& ctx) const; +template absl::StatusOr<std::vector<uint16_t>> +DistributedPointFunction::EvaluateUntil( + int hierarchy_level, absl::Span<const absl::uint128> prefixes, + EvaluationContext& ctx) const; +template absl::StatusOr<std::vector<uint32_t>> +DistributedPointFunction::EvaluateUntil( + int hierarchy_level, absl::Span<const absl::uint128> prefixes, + EvaluationContext& ctx) const; +template absl::StatusOr<std::vector<uint64_t>> +DistributedPointFunction::EvaluateUntil( + int hierarchy_level, absl::Span<const absl::uint128> prefixes, + EvaluationContext& ctx) const; +template absl::StatusOr<std::vector<absl::uint128>> +DistributedPointFunction::EvaluateUntil( + int hierarchy_level, absl::Span<const absl::uint128> prefixes, + EvaluationContext& ctx) const; + +} // namespace distributed_point_functions
diff --git a/third_party/distributed_point_functions/code/dpf/distributed_point_function.h b/third_party/distributed_point_functions/code/dpf/distributed_point_function.h new file mode 100644 index 0000000..bc2f8fb4 --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/distributed_point_function.h
@@ -0,0 +1,274 @@ +/* + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DISTRIBUTED_POINT_FUNCTIONS_DPF_DISTRIBUTED_POINT_FUNCTION_H_ +#define DISTRIBUTED_POINT_FUNCTIONS_DPF_DISTRIBUTED_POINT_FUNCTION_H_ + +#include <openssl/cipher.h> + +#include <memory> + +#include "absl/container/flat_hash_map.h" +#include "absl/status/statusor.h" +#include "dpf/distributed_point_function.pb.h" +#include "dpf/internal/pseudorandom_generator.h" + +namespace distributed_point_functions { + +// Implements key generation and evaluation of distributed point functions. +// A distributed point function (DPF) is parameterized by an index `alpha` and a +// value `beta`. The key generation procedure produces two keys `k_a`, `k_b`. +// Evaluating each key on any point `x` in the DPF domain results in an additive +// secret share of `beta`, if `x == alpha`, and a share of 0 otherwise. This +// class also supports *incremental* DPFs that can additionally be evaluated on +// prefixes of points, resulting in different values `beta_i`for each prefix of +// `alpha`. +class DistributedPointFunction { + public: + // Creates a new instance of a distributed point function that can be + // evaluated only at the output layer. + // + // Returns INVALID_ARGUMENT if the parameters are invalid. + static absl::StatusOr<std::unique_ptr<DistributedPointFunction>> Create( + const DpfParameters& parameters); + + // Creates a new instance of an *incremental* DPF that can be evaluated at + // multiple layers. Each parameter set in `parameters` should specify the + // domain size and element size at one of the layers to be evaluated, in + // increasing domain size order. Element sizes must be non-decreasing. + // + // Returns INVALID_ARGUMENT if the parameters are invalid. + static absl::StatusOr<std::unique_ptr<DistributedPointFunction>> + CreateIncremental(absl::Span<const DpfParameters> parameters); + + // DistributedPointFunction is neither copyable nor movable. + DistributedPointFunction(const DistributedPointFunction&) = delete; + DistributedPointFunction& operator=(const DistributedPointFunction&) = delete; + + // Generates a pair of keys for a DPF that evaluates to `beta` when evaluated + // `alpha`. Returns INVALID_ARGUMENT if used on an incremental DPF with more + // than one set of parameters, or if `alpha` or `beta` are outside of the + // domains specified at construction. + absl::StatusOr<std::pair<DpfKey, DpfKey>> GenerateKeys( + absl::uint128 alpha, absl::uint128 beta) const; + + // Generates a pair of keys for an incremental DPF. For each parameter i + // passed at construction, the DPF evaluates to `beta[i]` at the first + // `parameters_[i].log_domain_size()` bits of `alpha`. + // Returns INVALID_ARGUMENT if `beta.size() != parameters_.size()` or if + // `alpha` or any element of `beta` are outside of the domains specified at + // construction. + absl::StatusOr<std::pair<DpfKey, DpfKey>> GenerateKeysIncremental( + absl::uint128 alpha, absl::Span<const absl::uint128> beta) const; + + // Returns an `EvaluationContext` for incrementally evaluating the given + // DpfKey. + // + // Returns INVALID_ARGUMENT if `key` doesn't match the parameters given at + // construction. + absl::StatusOr<EvaluationContext> CreateEvaluationContext(DpfKey key); + + // Evaluates the given `hierarchy_level` of the DPF under all `prefixes` + // passed to this function. If `prefixes` is empty, evaluation starts from the + // seed of `ctx.key`. Otherwise, each element of `prefixes` must fit in the + // domain size of `ctx.previous_hierarchy_level`. Further, `prefixes` may only + // contain extensions of the prefixes passed in the previous call. For + // example, in the following sequence of calls, for each element p2 of + // `prefixes2`, there must be an element p1 of `prefixes1` such that p1 is a + // prefix of p2: + // + // DPF_ASSIGN_OR_RETURN(std::unique_ptr<EvaluationContext> ctx, + // dpf->CreateEvaluationContext(key)); + // using T0 = ...; + // DPF_ASSIGN_OR_RETURN(std::vector<T0> evaluations0, + // dpf->EvaluateUntil(0, {}, *ctx)); + // + // std::vector<absl::uint128> prefixes1 = ...; + // using T1 = ...; + // DPF_ASSIGN_OR_RETURN(std::vector<T1> evaluations1, + // dpf->EvaluateUntil(1, prefixes1, *ctx)); + // ... + // std::vector<absl::uint128> prefixes2 = ...; + // using T2 = ...; + // DPF_ASSIGN_OR_RETURN(std::vector<T2> evaluations2, + // dpf->EvaluateUntil(3, prefixes2, *ctx)); + // + // The prefixes are read from the lowest-order bits of the corresponding + // absl::uint128. The number of bits used for each prefix depends on the + // output domain size of the previously evaluated hierarchy level. For + // example, if `ctx` was last evaluated on a hierarchy level with output + // domain size 2**20, then the 20 lowest-order bits of each element in + // `prefixes` are used. + // + // Returns `INVALID_ARGUMENT` if + // - any element of `prefixes` is larger than the next hierarchy level's + // log_domain_size, + // - `prefixes` contains elements that are not extensions of previous + // prefixes, or + // - the bit-size of T doesn't match the next hierarchy level's + // element_bitsize. + template <typename T> + absl::StatusOr<std::vector<T>> EvaluateUntil( + int hierarchy_level, absl::Span<const absl::uint128> prefixes, + EvaluationContext& ctx) const; + + template <typename T> + absl::StatusOr<std::vector<T>> EvaluateNext( + absl::Span<const absl::uint128> prefixes, EvaluationContext& ctx) const { + if (prefixes.empty()) { + return EvaluateUntil<T>(0, prefixes, ctx); + } else { + return EvaluateUntil<T>(ctx.previous_hierarchy_level() + 1, prefixes, + ctx); + } + } + + private: + // Private constructor, called by `CreateIncremental`. + DistributedPointFunction(std::vector<DpfParameters> parameters, + int tree_levels_needed, + absl::flat_hash_map<int, int> tree_to_hierarchy, + std::vector<int> hierarchy_to_tree, + dpf_internal::PseudorandomGenerator prg_left, + dpf_internal::PseudorandomGenerator prg_right, + dpf_internal::PseudorandomGenerator prg_value); + + // Computes the value correction for the given `hierarchy_level`, `seeds`, + // index `alpha` and value `beta`. If `invert` is true, the individual values + // in the returned block are multiplied element-wise by -1. Expands `seeds` + // using `prg_ctx_value_`, then calls ComputeValueCorrectionFor<T> for the + // right type depending on `parameters_[hierarchy_level].element_bitsize()`. + // + // Returns INTERNAL in case the PRG expansion fails, and UNIMPLEMENTED if + // `element_bitsize` is not supported. + absl::StatusOr<absl::uint128> ComputeValueCorrection( + int hierarchy_level, absl::Span<const absl::uint128> seeds, + absl::uint128 alpha, absl::uint128 beta, bool invert) const; + + // Expands the PRG seeds at the next `tree_level` for an incremental DPF with + // index `alpha` and values `beta`, updates `seeds` and `control_bits`, and + // writes the next correction word to `keys`. Called from + // `GenerateKeysIncremental`. + absl::Status GenerateNext(int tree_level, absl::uint128 alpha, + absl::Span<const absl::uint128> beta, + absl::Span<absl::uint128> seeds, + absl::Span<bool> control_bits, + absl::Span<DpfKey> keys) const; + + // Checks if the parameters of `ctx` are compatible with this DPF. Returns OK + // if that's the case, and INVALID_ARGUMENT otherwise. + absl::Status CheckContextParameters(const EvaluationContext& ctx) const; + + // Computes the tree index (representing a path in the FSS tree) from the + // given `domain_index` and `hierarchy_level`. Does NOT check whether the + // given domain index fits in the domain at `hierarchy_level`. + absl::uint128 DomainToTreeIndex(absl::uint128 domain_index, + int hierarchy_level) const; + + // Computes the block index (pointing to an element in a batched 128-bit + // block) from the given `domain_index` and `hierarchy_level`. Does NOT check + // whether the given domain index fits in the domain at `hierarchy_level`. + int DomainToBlockIndex(absl::uint128 domain_index, int hierarchy_level) const; + + // BitVector is a vector of bools. Allows for faster access times than + // std::vector<bool>, as well as inlining if the size is small. + using BitVector = absl::InlinedVector<bool, 8 / sizeof(bool)>; + + // Seeds and control bits resulting from a DPF expansion. This type is + // returned by `ExpandSeeds` and `ExpandAndUpdateContext`. + struct DpfExpansion { + std::vector<absl::uint128> seeds; + BitVector control_bits; + }; + + // Performs DPF evaluation of the given `partial_evaluations` using + // prg_ctx_left_ or prg_ctx_right_, and the given `correction_words`. At each + // level `l < correction_words.size()`, the evaluation for the i-th seed in + // `partial_evaluations` continues along the left or right path depending on + // the l-th most significant bit among the lowest `correction_words.size()` + // bits of `paths[i]`. + // + // Returns INTERNAL in case of OpenSSL errors. + absl::StatusOr<DpfExpansion> EvaluateSeeds( + DpfExpansion partial_evaluations, absl::Span<const absl::uint128> paths, + absl::Span<const CorrectionWord* const> correction_words) const; + + // Performs DPF expansion of the given `partial_evaluations` using + // prg_ctx_left_ and prg_ctx_right_, and the given `correction_words`. In more + // detail, each of the partial evaluations is subjected to a full subtree + // expansion of `correction_words.size()` levels, and the concatenated result + // is provided in the response. The result contains + // `(partial_evaluations.size() * (2^correction_words.size())` evaluations in + // a single `DpfExpansion`. + // + // Returns INTERNAL in case of OpenSSL errors. + absl::StatusOr<DpfExpansion> ExpandSeeds( + const DpfExpansion& partial_evaluations, + absl::Span<const CorrectionWord* const> correction_words) const; + + // Computes partial evaluations of the paths to `prefixes` to be used as the + // starting point of the expansion of `ctx`. If `update_ctx == true`, saves + // the partial evaluations of `ctx.previous_hierarchy_level` to `ctx` and sets + // `ctx.partial_evaluations_level` to `ctx.previous_hierarchy_level`. + // Called by `ExpandAndUpdateContext`. + // + // Returns INVALID_ARGUMENT if any element of `prefixes` is not found in + // `ctx.partial_evaluations()`, or `ctx.partial_evaluations()` contains + // duplicate seeds. + absl::StatusOr<DpfExpansion> ComputePartialEvaluations( + absl::Span<const absl::uint128> prefixes, bool update_ctx, + EvaluationContext& ctx) const; + + // Extracts the seeds for the given `prefixes` from `ctx` and expands them as + // far as needed for the next hierarchy level. Returns the result as a + // `DpfExpansion`. Called by `EvaluateUntil`, where the expanded seeds are + // corrected to obtain output values. + // After expansion, `ctx.hierarchy_level()` is increased. If this isn't the + // last expansion, the expanded seeds are also saved in `ctx` for the next + // expansion. + // + // Returns INVALID_ARGUMENT if any element of `prefixes` is not found in + // `ctx.partial_evaluations()`, or `ctx.partial_evaluations()` contains + // duplicate seeds. Returns INTERNAL in case of OpenSSL errors. + absl::StatusOr<DpfExpansion> ExpandAndUpdateContext( + int hierarchy_level, absl::Span<const absl::uint128> prefixes, + EvaluationContext& ctx) const; + + // DP parameters passed to the factory function. Contains the domain size and + // element size for hierarchy level of the incremental DPF. + const std::vector<DpfParameters> parameters_; + + // Number of levels in the evaluation tree. This is always less than or equal + // to the largest log_domain_size in parameters_. + const int tree_levels_needed_; + + // Maps levels of the FSS evaluation tree to hierarchy levels (i.e., elements + // of parameters_). + const absl::flat_hash_map<int, int> tree_to_hierarchy_; + + // The inverse of tree_to_hierarchy_. + const std::vector<int> hierarchy_to_tree_; + + // Pseudorandom generators for seed expansion (left and right), and value + // correction. + const dpf_internal::PseudorandomGenerator prg_left_; + const dpf_internal::PseudorandomGenerator prg_right_; + const dpf_internal::PseudorandomGenerator prg_value_; +}; + +} // namespace distributed_point_functions + +#endif // DISTRIBUTED_POINT_FUNCTIONS_DPF_DISTRIBUTED_POINT_FUNCTION_H_
diff --git a/third_party/distributed_point_functions/code/dpf/distributed_point_function.proto b/third_party/distributed_point_functions/code/dpf/distributed_point_function.proto new file mode 100644 index 0000000..eafc860 --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/distributed_point_function.proto
@@ -0,0 +1,91 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package distributed_point_functions; + +// For compatibility with protobuf lite. +option optimize_for = LITE_RUNTIME; + +// For faster allocations of submessages. +option cc_enable_arenas = true; + +// Parameters of a distributed point function (DPF). +message DpfParameters { + int32 log_domain_size = 1; + int32 element_bitsize = 2; +} + +// A single 128-bit AES block. +message Block { + uint64 high = 1; + uint64 low = 2; +} + +// A correction word used to evaluate a single layer in the DPF evaluation tree. +message CorrectionWord { + // Block used to correct the new seeds after PRG evaluation. + Block seed = 1; + // Correction bits for the left and right control bits. + bool control_left = 2; + bool control_right = 3; + // Block used to correct the output value at the previous tree layer. Only + // included if the previous tree layer is an output layer. + Block output = 4; +} + +// A key of a distributed point function (DPF). +message DpfKey { + // Initial seed at the first level. + Block seed = 1; + // Correction words for each level after expansion. + repeated CorrectionWord correction_words = 2; + // Party this DpfKey belongs to (0 or 1). + int32 party = 3; + // Output correction for the last layer. + Block last_level_output_correction = 4; +} + +// Maps a single prefix of a DPF index to a PRG seed. Used to store partial +// evaluation state between hierarchy levels in `EvaluationContext` +message PartialEvaluation { + // Prefix in the FSS evaluation tree. Does not necessarily coincide with the + // corresponding prefix of the output domain at this hierarchy level. + Block prefix = 1; + // Seed for the next evaluation. + Block seed = 2; + // Control bit for the correction in the next evaluation. + bool control_bit = 3; +} + +// An EvaluationContext holds the state of a partially evaluated incremental +// DPF. +message EvaluationContext { + // The parameters of the DPF being evaluated. One set of parameters for each + // hierarchy level of the incremental DPF. + repeated DpfParameters parameters = 1; + // The DPF key being evaluated. + DpfKey key = 2; + // The hierarchy level that this EvaluationContext was last evaluated on. + int32 previous_hierarchy_level = 3; + // Maps prefixes from an earlier hierarchy level to PRG seeds, which are used + // to continue the evaluation under each prefix. Uses a repeated message field + // since Protobuf doesn't allow messages (such as `Block`) as map keys. + repeated PartialEvaluation partial_evaluations = 4; + // The hierarchy level `partial_evaluations` corresponds to. If levels are + // expanded sequentially, this is equal to `previous_hierarchy_level - 1`, + // otherwise it can be smaller. Ignored when `partial_evaluations` is empty. + int32 partial_evaluations_level = 5; +}
diff --git a/third_party/distributed_point_functions/code/dpf/distributed_point_function_benchmark.cc b/third_party/distributed_point_functions/code/dpf/distributed_point_function_benchmark.cc new file mode 100644 index 0000000..f8e677f --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/distributed_point_function_benchmark.cc
@@ -0,0 +1,188 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "absl/random/random.h" +#include "benchmark/benchmark.h" +#include "dpf/distributed_point_function.h" + +namespace distributed_point_functions { +namespace { + +// Benchmarks a regular DPF evaluation. Expects the first range argument to +// specify the output log domain size. +template <typename T> +void BM_EvaluateRegularDpf(benchmark::State& state) { + DpfParameters parameters; + parameters.set_log_domain_size(state.range(0)); + parameters.set_element_bitsize(sizeof(T) * 8); + std::unique_ptr<DistributedPointFunction> dpf = + DistributedPointFunction::Create(parameters).value(); + absl::uint128 alpha = 0, beta = 1; + std::pair<DpfKey, DpfKey> keys = dpf->GenerateKeys(alpha, beta).value(); + EvaluationContext ctx_0 = dpf->CreateEvaluationContext(keys.first).value(); + for (auto s : state) { + google::protobuf::Arena arena; + EvaluationContext* ctx = + google::protobuf::Arena::CreateMessage<EvaluationContext>(&arena); + *ctx = ctx_0; + std::vector<T> result = dpf->EvaluateNext<T>({}, *ctx).value(); + benchmark::DoNotOptimize(result); + } +} +BENCHMARK_TEMPLATE(BM_EvaluateRegularDpf, uint8_t)->DenseRange(12, 24, 2); +BENCHMARK_TEMPLATE(BM_EvaluateRegularDpf, uint16_t)->DenseRange(12, 24, 2); +BENCHMARK_TEMPLATE(BM_EvaluateRegularDpf, uint32_t)->DenseRange(12, 24, 2); +BENCHMARK_TEMPLATE(BM_EvaluateRegularDpf, uint64_t)->DenseRange(12, 24, 2); +BENCHMARK_TEMPLATE(BM_EvaluateRegularDpf, absl::uint128)->DenseRange(12, 24, 2); + +// Benchmarks full evaluation of all hierarchy levels. Expects the first range +// argument to specify the number of iterations. The output domain size is fixed +// to 2**20. +template <typename T> +void BM_EvaluateHierarchicalFull(benchmark::State& state) { + // Set up DPF with the given parameters. + const int kMaxLogDomainSize = 20; + int num_hierarchy_levels = state.range(0); + std::vector<DpfParameters> parameters(num_hierarchy_levels); + for (int i = 0; i < num_hierarchy_levels; ++i) { + parameters[i].set_log_domain_size(static_cast<int>( + static_cast<double>(i + 1) / num_hierarchy_levels * kMaxLogDomainSize)); + parameters[i].set_element_bitsize(sizeof(T) * 8); + } + std::unique_ptr<DistributedPointFunction> dpf = + DistributedPointFunction::CreateIncremental(parameters).value(); + + // Generate keys. + absl::uint128 alpha = 12345; + std::vector<absl::uint128> beta(num_hierarchy_levels); + for (int i = 0; i < num_hierarchy_levels; ++i) { + beta[i] = i; + } + std::pair<DpfKey, DpfKey> keys = + dpf->GenerateKeysIncremental(alpha, beta).value(); + + // Set up evaluation context and evaluation prefixes for each level. + EvaluationContext ctx_0 = dpf->CreateEvaluationContext(keys.first).value(); + std::vector<std::vector<absl::uint128>> prefixes(num_hierarchy_levels); + for (int i = 1; i < num_hierarchy_levels; ++i) { + prefixes[i].resize(1 << parameters[i - 1].log_domain_size()); + std::iota(prefixes[i].begin(), prefixes[i].end(), absl::uint128{0}); + } + + // Run hierarchical evaluation. + for (auto s : state) { + google::protobuf::Arena arena; + EvaluationContext* ctx = + google::protobuf::Arena::CreateMessage<EvaluationContext>(&arena); + *ctx = ctx_0; + for (int i = 0; i < num_hierarchy_levels; ++i) { + std::vector<T> result = dpf->EvaluateNext<T>(prefixes[i], *ctx).value(); + benchmark::DoNotOptimize(result); + } + benchmark::DoNotOptimize(*ctx); + } +} +BENCHMARK_TEMPLATE(BM_EvaluateHierarchicalFull, uint8_t)->DenseRange(1, 16, 2); +BENCHMARK_TEMPLATE(BM_EvaluateHierarchicalFull, uint16_t)->DenseRange(1, 16, 2); +BENCHMARK_TEMPLATE(BM_EvaluateHierarchicalFull, uint32_t)->DenseRange(1, 16, 2); +BENCHMARK_TEMPLATE(BM_EvaluateHierarchicalFull, uint64_t)->DenseRange(1, 16, 2); +BENCHMARK_TEMPLATE(BM_EvaluateHierarchicalFull, absl::uint128) + ->DenseRange(1, 16, 2); + +// Generates `num_nonzeros` random prefixes for the given set of `parameters`. +std::vector<std::vector<absl::uint128>> GenerateRandomPrefixes( + absl::Span<const DpfParameters> parameters, + absl::Span<const int> num_nonzeros) { + auto num_hierarchy_levels = static_cast<int>(parameters.size()); + std::vector<std::vector<absl::uint128>> prefixes(parameters.size()); + + absl::BitGen rng; + absl::uniform_int_distribution<uint32_t> dist_index, dist_value; + for (int i = 0; i < num_hierarchy_levels; ++i) { + if (i > 0) { // prefixes must be empty for the first level. + prefixes[i] = std::vector<absl::uint128>(num_nonzeros[i - 1]); + absl::uint128 prefix = 0; + // Difference between the previous domain size and the one before that. + // This is the amount of bits we have to shift prefixes from the previous + // level to append the current level. + int previous_domain_size_difference = parameters[i - 1].log_domain_size(); + if (i > 1) { + previous_domain_size_difference -= parameters[i - 2].log_domain_size(); + } + dist_value = absl::uniform_int_distribution<uint32_t>( + 0, (1 << previous_domain_size_difference) - 1); + if (i > 1) { + dist_index = absl::uniform_int_distribution<uint32_t>( + 0, prefixes[i - 1].size() - 1); + } + for (int j = 0; i > 0 && j < num_nonzeros[i - 1]; ++j) { + if (i > 1) { + // Choose a random prefix from the previous level to extend. + prefix = prefixes[i - 1][dist_index(rng)] + << previous_domain_size_difference; + } + prefixes[i][j] = prefix | dist_value(rng); + } + } + std::sort(prefixes[i].begin(), prefixes[i].end()); + } + return prefixes; +} + +// Benchmark the example used here: +// https://github.com/abetterinternet/prio-documents/issues/18#issuecomment-801248636 +void BM_IsrgExampleHierarchy(benchmark::State& state) { + const int kNumHierarchyLevels = 2; + std::vector<DpfParameters> parameters(kNumHierarchyLevels); + std::vector<int> num_nonzeros(kNumHierarchyLevels - 1); + + parameters[0].set_log_domain_size(12); + parameters[0].set_element_bitsize(32); + num_nonzeros[0] = 32; + + parameters[1].set_log_domain_size(25); + parameters[1].set_element_bitsize(32); + + std::unique_ptr<DistributedPointFunction> dpf = + DistributedPointFunction::CreateIncremental(parameters).value(); + + // Create DPF keys. + absl::uint128 alpha = 1234567; + std::vector<absl::uint128> beta(kNumHierarchyLevels, 1); + std::pair<DpfKey, DpfKey> keys = + dpf->GenerateKeysIncremental(alpha, beta).value(); + + // Generate prefixes for evaluation with the appropriate number of nonzeros. + std::vector<std::vector<absl::uint128>> prefixes = + GenerateRandomPrefixes(parameters, num_nonzeros); + + // Run hierarchical evaluation. + EvaluationContext ctx_0 = dpf->CreateEvaluationContext(keys.first).value(); + for (auto s : state) { + google::protobuf::Arena arena; + EvaluationContext* ctx = + google::protobuf::Arena::CreateMessage<EvaluationContext>(&arena); + *ctx = ctx_0; + for (int i = 0; i < kNumHierarchyLevels; ++i) { + std::vector<uint32_t> result = + dpf->EvaluateNext<uint32_t>(prefixes[i], *ctx).value(); + benchmark::DoNotOptimize(result); + } + benchmark::DoNotOptimize(*ctx); + } +} +BENCHMARK(BM_IsrgExampleHierarchy); + +} // namespace +} // namespace distributed_point_functions \ No newline at end of file
diff --git a/third_party/distributed_point_functions/code/dpf/distributed_point_function_test.cc b/third_party/distributed_point_functions/code/dpf/distributed_point_function_test.cc new file mode 100644 index 0000000..2a97985 --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/distributed_point_function_test.cc
@@ -0,0 +1,723 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "dpf/distributed_point_function.h" + +#include <gmock/gmock.h> +#include <gtest/gtest.h> + +#include "absl/random/random.h" +#include "dpf/internal/status_matchers.h" + +namespace distributed_point_functions { +namespace { + +using dpf_internal::IsOkAndHolds; +using dpf_internal::StatusIs; +using ::testing::Ne; +using ::testing::StartsWith; + +TEST(DistributedPointFunction, TestCreate) { + for (int log_domain_size = 0; log_domain_size <= 62; ++log_domain_size) { + for (int element_bitsize = 1; element_bitsize <= 128; + element_bitsize *= 2) { + DpfParameters parameters; + + parameters.set_log_domain_size(log_domain_size); + parameters.set_element_bitsize(element_bitsize); + + EXPECT_THAT(DistributedPointFunction::Create(parameters), + IsOkAndHolds(Ne(nullptr))) + << "log_domain_size=" << log_domain_size + << " element_bitsize=" << element_bitsize; + } + } +} + +TEST(DistributedPointFunction, TestCreateCreateIncrementalLargeDomain) { + std::vector<DpfParameters> parameters(2); + parameters[0].set_element_bitsize(128); + parameters[1].set_element_bitsize(128); + + // Test that creating an incremental DPF with a large total domain size works. + parameters[0].set_log_domain_size(50); + parameters[1].set_log_domain_size(100); + + EXPECT_THAT(DistributedPointFunction::CreateIncremental(parameters), + IsOkAndHolds(Ne(nullptr))); +} + +TEST(DistributedPointFunction, FailsWithoutParameters) { + EXPECT_THAT(DistributedPointFunction::CreateIncremental({}), + StatusIs(absl::StatusCode::kInvalidArgument, + "`parameters` must not be empty")); +} + +TEST(DistributedPointFunction, FailsWhenParametersNotSorted) { + std::vector<DpfParameters> parameters(2); + + parameters[0].set_log_domain_size(12); + parameters[1].set_log_domain_size(10); + parameters[0].set_element_bitsize(32); + parameters[1].set_element_bitsize(32); + + EXPECT_THAT(DistributedPointFunction::CreateIncremental(parameters), + StatusIs(absl::StatusCode::kInvalidArgument, + "`log_domain_size` fields must be in ascending order in " + "`parameters`")); +} + +TEST(DistributedPointFunction, FailsWhenDomainSizeNegative) { + DpfParameters parameters; + + parameters.set_log_domain_size(-1); + parameters.set_element_bitsize(32); + + EXPECT_THAT(DistributedPointFunction::Create(parameters), + StatusIs(absl::StatusCode::kInvalidArgument, + "`log_domain_size` must be non-negative")); +} + +TEST(DistributedPointFunction, FailsWhenElementBitsizeZeroOrNegative) { + for (int element_bitsize : {0, -1}) { + DpfParameters parameters; + + parameters.set_log_domain_size(10); + parameters.set_element_bitsize(element_bitsize); + + EXPECT_THAT(DistributedPointFunction::Create(parameters), + StatusIs(absl::StatusCode::kInvalidArgument, + "`element_bitsize` must be positive")); + } +} + +TEST(DistributedPointFunction, FailsWhenElementBitsizeTooLarge) { + DpfParameters parameters; + + parameters.set_log_domain_size(10); + parameters.set_element_bitsize(256); + + EXPECT_THAT(DistributedPointFunction::Create(parameters), + StatusIs(absl::StatusCode::kInvalidArgument, + "`element_bitsize` must be less than or equal to 128")); +} + +TEST(DistributedPointFunction, FailsWhenElementBitsizeNotAPowerOfTwo) { + DpfParameters parameters; + + parameters.set_log_domain_size(10); + parameters.set_element_bitsize(23); + + EXPECT_THAT(DistributedPointFunction::Create(parameters), + StatusIs(absl::StatusCode::kInvalidArgument, + "`element_bitsize` must be a power of 2")); +} + +TEST(DistributedPointFunction, FailsWhenElementBitsizesDecrease) { + std::vector<DpfParameters> parameters(2); + parameters[0].set_log_domain_size(10); + parameters[1].set_log_domain_size(12); + + parameters[0].set_element_bitsize(128); + parameters[1].set_element_bitsize(32); + + EXPECT_THAT(DistributedPointFunction::CreateIncremental(parameters), + StatusIs(absl::StatusCode::kInvalidArgument, + "`element_bitsize` fields must be non-decreasing in " + "`parameters`")); +} + +TEST(DistributedPointFunction, FailsWhenHierarchiesAreTooFarApart) { + std::vector<DpfParameters> parameters(2); + parameters[0].set_element_bitsize(128); + parameters[1].set_element_bitsize(128); + + parameters[0].set_log_domain_size(10); + parameters[1].set_log_domain_size(73); + + EXPECT_THAT(DistributedPointFunction::CreateIncremental(parameters), + StatusIs(absl::StatusCode::kInvalidArgument, + "Hierarchies may be at most 62 levels apart")); +} + +class DpfKeyGenerationTest + : public testing::TestWithParam<std::tuple<int, int>> { + public: + void SetUp() { + std::tie(log_domain_size_, element_bitsize_) = GetParam(); + DpfParameters parameters; + parameters.set_log_domain_size(log_domain_size_); + parameters.set_element_bitsize(element_bitsize_); + DPF_ASSERT_OK_AND_ASSIGN(dpf_, + DistributedPointFunction::Create(parameters)); + } + + protected: + int log_domain_size_; + int element_bitsize_; + std::unique_ptr<DistributedPointFunction> dpf_; +}; + +TEST_P(DpfKeyGenerationTest, KeyHasCorrectFormat) { + DpfKey key_a, key_b; + DPF_ASSERT_OK_AND_ASSIGN(std::tie(key_a, key_b), dpf_->GenerateKeys(0, 0)); + + // Check that party is set correctly. + EXPECT_EQ(key_a.party(), 0); + EXPECT_EQ(key_b.party(), 1); + // Check that keys are accepted by `CreateEvaluationContext`. + DPF_EXPECT_OK(dpf_->CreateEvaluationContext(key_a)); + DPF_EXPECT_OK(dpf_->CreateEvaluationContext(key_b)); +} + +TEST_P(DpfKeyGenerationTest, FailsIfBetaHasTheWrongSize) { + EXPECT_THAT( + dpf_->GenerateKeysIncremental(0, {1, 2}), + StatusIs(absl::StatusCode::kInvalidArgument, + "`beta` has to have the same size as `parameters` passed at " + "construction")); +} + +TEST_P(DpfKeyGenerationTest, FailsIfAlphaIsTooLarge) { + if (log_domain_size_ >= 128) { + // Alpha is an absl::uint128, so never too large in this case. + return; + } + + EXPECT_THAT(dpf_->GenerateKeys((absl::uint128{1} << log_domain_size_), 1), + StatusIs(absl::StatusCode::kInvalidArgument, + "`alpha` must be smaller than the output domain size")); +} + +TEST_P(DpfKeyGenerationTest, FailsIfBetaIsTooLarge) { + if (element_bitsize_ >= 128) { + // Beta is an absl::uint128, so never too large in this case. + return; + } + + EXPECT_THAT( + dpf_->GenerateKeys(0, (absl::uint128{1} << element_bitsize_)), + StatusIs( + absl::StatusCode::kInvalidArgument, + "`beta[0]` larger than `parameters[0].element_bitsize()` allows")); +} + +TEST_P(DpfKeyGenerationTest, FailsIfNumberOfCorrectionWordsDoesntMatch) { + DpfKey key_a, key_b; + + DPF_ASSERT_OK_AND_ASSIGN(std::tie(key_a, key_b), dpf_->GenerateKeys(0, 0)); + key_a.add_correction_words(); + + EXPECT_THAT(dpf_->CreateEvaluationContext(key_a), + StatusIs(absl::StatusCode::kInvalidArgument, + absl::StrCat("Malformed DpfKey: expected ", + key_b.correction_words_size(), + " correction words, but got ", + key_a.correction_words_size()))); +} + +INSTANTIATE_TEST_SUITE_P(VaryDomainAndElementSizes, DpfKeyGenerationTest, + testing::Combine(testing::Values(0, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 32, 62), + testing::Values(8, 16, 32, 64, 128))); + +struct DpfTestParameters { + int log_domain_size; + int element_bitsize; + + friend std::ostream& operator<<(std::ostream& os, + const DpfTestParameters& parameters) { + return os << "{ log_domain_size: " << parameters.log_domain_size + << ", element_bitsize: " << parameters.element_bitsize << " }"; + } +}; + +class DpfEvaluationTest : public testing::TestWithParam< + std::tuple</*parameters*/ + std::vector<DpfTestParameters>, + /*alpha*/ absl::uint128, + /*beta*/ std::vector<absl::uint128>, + /*level_step*/ int>> { + protected: + void SetUp() { + const std::vector<DpfTestParameters>& parameters = std::get<0>(GetParam()); + parameters_.resize(parameters.size()); + for (int i = 0; i < static_cast<int>(parameters.size()); ++i) { + parameters_[i].set_log_domain_size(parameters[i].log_domain_size); + parameters_[i].set_element_bitsize(parameters[i].element_bitsize); + } + DPF_ASSERT_OK_AND_ASSIGN( + dpf_, DistributedPointFunction::CreateIncremental(parameters_)); + alpha_ = std::get<1>(GetParam()); + beta_ = std::get<2>(GetParam()); + DPF_ASSERT_OK_AND_ASSIGN(keys_, + dpf_->GenerateKeysIncremental(alpha_, beta_)); + level_step_ = std::get<3>( + GetParam()); // Number of hierarchy level to evaluate at once. + } + + // Returns the prefix of `index` for the domain of `hierarchy_level`. + absl::uint128 GetPrefixForLevel(int hierarchy_level, absl::uint128 index) { + absl::uint128 result = 0; + int shift_amount = parameters_.back().log_domain_size() - + parameters_[hierarchy_level].log_domain_size(); + if (shift_amount < 128) { + result = index >> shift_amount; + } + return result; + } + + // Evaluates both contexts `ctx0` and `ctx1` at `hierarchy level`, using the + // appropriate prefixes of `evaluation_points`. Checks that the expansion of + // both keys form correct DPF shares, i.e., they add up to + // `beta_[ctx.hierarchy_level()]` under prefixes of `alpha_`, and to 0 + // otherwise. + template <typename T> + void EvaluateAndCheckLevel(int hierarchy_level, + absl::Span<const absl::uint128> evaluation_points, + EvaluationContext& ctx0, EvaluationContext& ctx1) { + int previous_hierarchy_level = ctx0.previous_hierarchy_level(); + int current_log_domain_size = + parameters_[hierarchy_level].log_domain_size(); + int previous_log_domain_size = 0; + int num_expansions = 1; + bool is_first_evaluation = previous_hierarchy_level < 0; + // Generate prefixes if we're not on the first level. + std::vector<absl::uint128> prefixes; + if (!is_first_evaluation) { + num_expansions = static_cast<int>(evaluation_points.size()); + prefixes.resize(evaluation_points.size()); + previous_log_domain_size = + parameters_[previous_hierarchy_level].log_domain_size(); + for (int i = 0; i < static_cast<int>(evaluation_points.size()); ++i) { + prefixes[i] = + GetPrefixForLevel(previous_hierarchy_level, evaluation_points[i]); + } + } + + absl::StatusOr<std::vector<T>> result_0 = + dpf_->EvaluateUntil<T>(hierarchy_level, prefixes, ctx0); + absl::StatusOr<std::vector<T>> result_1 = + dpf_->EvaluateUntil<T>(hierarchy_level, prefixes, ctx1); + + // Check results are ok. + DPF_EXPECT_OK(result_0); + DPF_EXPECT_OK(result_1); + if (result_0.ok() && result_1.ok()) { + // Check output sizes match. + ASSERT_EQ(result_0->size(), result_1->size()); + int64_t outputs_per_prefix = + int64_t{1} << (current_log_domain_size - previous_log_domain_size); + int64_t expected_output_size = num_expansions * outputs_per_prefix; + ASSERT_EQ(result_0->size(), expected_output_size); + + // Iterate over the outputs and check that they sum up to 0 or to + // beta_[current_hierarchy_level]. + absl::uint128 previous_alpha_prefix = 0; + if (!is_first_evaluation) { + previous_alpha_prefix = + GetPrefixForLevel(previous_hierarchy_level, alpha_); + } + absl::uint128 current_alpha_prefix = + GetPrefixForLevel(hierarchy_level, alpha_); + for (int64_t i = 0; i < expected_output_size; ++i) { + int prefix_index = i / outputs_per_prefix; + int prefix_expansion_index = i % outputs_per_prefix; + // The output is on the path to alpha, if we're at the first level or + // under a prefix of alpha, and the current block in the expansion of + // the prefix is also on the path to alpha. + if ((is_first_evaluation || + prefixes[prefix_index] == previous_alpha_prefix) && + prefix_expansion_index == + (current_alpha_prefix % outputs_per_prefix)) { + // We need to static_cast here since otherwise operator+ returns an + // unsigned int without doing a modular reduction, which causes the + // test to fail on types with sizeof(T) < sizeof(unsigned). + EXPECT_EQ(static_cast<T>((*result_0)[i] + (*result_1)[i]), + beta_[hierarchy_level]) + << "i=" << i << ", hierarchy_level=" << hierarchy_level + << "\nparameters={\n" + << parameters_[hierarchy_level].DebugString() << "}\n" + << "previous_alpha_prefix=" << previous_alpha_prefix << "\n" + << "current_alpha_prefix=" << current_alpha_prefix << "\n"; + } else { + EXPECT_EQ(static_cast<T>((*result_0)[i] + (*result_1)[i]), 0) + << "i=" << i << ", hierarchy_level=" << hierarchy_level + << "\nparameters={\n" + << parameters_[hierarchy_level].DebugString() << "}\n"; + } + } + } + } + + std::vector<DpfParameters> parameters_; + std::unique_ptr<DistributedPointFunction> dpf_; + absl::uint128 alpha_; + std::vector<absl::uint128> beta_; + std::pair<DpfKey, DpfKey> keys_; + int level_step_; +}; + +TEST_P(DpfEvaluationTest, FailsIfOutputCorrectionIsMissing) { + if (parameters_.size() == 1) { + // Only one hierarchy level -> No output correction in correction words. + return; + } + int tree_level; + + for (tree_level = 0; tree_level < keys_.first.correction_words_size(); + ++tree_level) { + CorrectionWord* word = keys_.first.mutable_correction_words(tree_level); + // Remove first output correction word. + if (word->has_output()) { + word->clear_output(); + break; + } + } + + EXPECT_THAT(dpf_->CreateEvaluationContext(keys_.first), + StatusIs(absl::StatusCode::kInvalidArgument, + StartsWith(absl::StrCat( + "Malformed DpfKey: expected correction_words[", + tree_level, "] to contain the output correction")))); +} + +TEST_P(DpfEvaluationTest, FailsIfParameterSizeDoesntMatch) { + DPF_ASSERT_OK_AND_ASSIGN(EvaluationContext ctx, + dpf_->CreateEvaluationContext(keys_.first)); + + ctx.mutable_parameters()->erase(ctx.parameters().end() - 1); + + EXPECT_THAT(dpf_->EvaluateNext<absl::uint128>({}, ctx), + StatusIs(absl::StatusCode::kInvalidArgument, + "Number of parameters in `ctx` doesn't match")); +} + +TEST_P(DpfEvaluationTest, FailsIfParameterDoesntMatch) { + DPF_ASSERT_OK_AND_ASSIGN(EvaluationContext ctx, + dpf_->CreateEvaluationContext(keys_.first)); + + ctx.mutable_parameters(0)->set_log_domain_size( + ctx.parameters(0).log_domain_size() + 1); + + EXPECT_THAT(dpf_->EvaluateNext<absl::uint128>({}, ctx), + StatusIs(absl::StatusCode::kInvalidArgument, + "Parameter 0 in `ctx` doesn't match")); +} + +TEST_P(DpfEvaluationTest, FailsIfContextFullyEvaluated) { + DPF_ASSERT_OK_AND_ASSIGN(EvaluationContext ctx, + dpf_->CreateEvaluationContext(keys_.first)); + + ctx.set_previous_hierarchy_level(parameters_.size() - 1); + + EXPECT_THAT(dpf_->EvaluateNext<absl::uint128>({}, ctx), + StatusIs(absl::StatusCode::kInvalidArgument, + "This context has already been fully evaluated")); +} + +TEST_P(DpfEvaluationTest, FailsIfPrefixNotPresentInCtx) { + if (parameters_.size() < 3 || parameters_[0].element_bitsize() != 128 || + parameters_[1].element_bitsize() != 128 || + parameters_[2].element_bitsize() != 128) { + return; + } + DPF_ASSERT_OK_AND_ASSIGN(EvaluationContext ctx, + dpf_->CreateEvaluationContext(keys_.first)); + + // Evaluate on prefixes 0 and 1, then delete partial evaluations for prefix 0. + DPF_ASSERT_OK(dpf_->EvaluateNext<absl::uint128>({}, ctx)); + DPF_ASSERT_OK(dpf_->EvaluateNext<absl::uint128>({0, 1}, ctx)); + ctx.mutable_partial_evaluations()->erase(ctx.partial_evaluations().begin()); + + // The missing prefix corresponds to hierarchy level 1, even though we + // evaluate at level 2. + EXPECT_THAT(dpf_->EvaluateNext<absl::uint128>({0}, ctx), + StatusIs(absl::StatusCode::kInvalidArgument, + "Prefix not present in ctx.partial_evaluations at " + "hierarchy level 1")); +} + +TEST_P(DpfEvaluationTest, TestCorrectness) { + DPF_ASSERT_OK_AND_ASSIGN(EvaluationContext ctx0, + dpf_->CreateEvaluationContext(keys_.first)); + DPF_ASSERT_OK_AND_ASSIGN(EvaluationContext ctx1, + dpf_->CreateEvaluationContext(keys_.second)); + + // Generate a random set of evaluation points. The library should be able to + // handle duplicates, so fixing the size to 1000 works even for smaller + // domains. + absl::BitGen rng; + absl::uniform_int_distribution<uint64_t> dist; + const int kNumEvaluationPoints = 1000; + std::vector<absl::uint128> evaluation_points(kNumEvaluationPoints); + for (int i = 0; i < kNumEvaluationPoints - 1; ++i) { + evaluation_points[i] = absl::MakeUint128(dist(rng), dist(rng)); + if (parameters_.back().log_domain_size() < 128) { + evaluation_points[i] %= absl::uint128{1} + << parameters_.back().log_domain_size(); + } + } + evaluation_points.back() = alpha_; // Always evaluate on alpha_. + + int num_levels = static_cast<int>(parameters_.size()); + for (int i = level_step_ - 1; i < num_levels; i += level_step_) { + switch (parameters_[i].element_bitsize()) { + case 8: + EvaluateAndCheckLevel<uint8_t>(i, evaluation_points, ctx0, ctx1); + break; + case 16: + EvaluateAndCheckLevel<uint16_t>(i, evaluation_points, ctx0, ctx1); + break; + case 32: + EvaluateAndCheckLevel<uint32_t>(i, evaluation_points, ctx0, ctx1); + break; + case 64: + EvaluateAndCheckLevel<uint64_t>(i, evaluation_points, ctx0, ctx1); + break; + case 128: + EvaluateAndCheckLevel<absl::uint128>(i, evaluation_points, ctx0, ctx1); + break; + default: + ASSERT_TRUE(0) << "Unsupported element_bitsize"; + } + } +} + +INSTANTIATE_TEST_SUITE_P( + OneHierarchyLevelVaryElementSizes, DpfEvaluationTest, + testing::Combine( + // DPF parameters. + testing::Values( + // Vary element sizes, small domain size. + std::vector<DpfTestParameters>{ + {.log_domain_size = 4, .element_bitsize = 8}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 4, .element_bitsize = 16}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 4, .element_bitsize = 32}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 4, .element_bitsize = 64}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 4, .element_bitsize = 128}}, + // Vary element sizes, medium domain size. + std::vector<DpfTestParameters>{ + {.log_domain_size = 10, .element_bitsize = 8}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 10, .element_bitsize = 16}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 10, .element_bitsize = 32}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 10, .element_bitsize = 64}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 10, .element_bitsize = 128}}), + testing::Values(0, 1, 15), // alpha + testing::Values(std::vector<absl::uint128>(1, 1), + std::vector<absl::uint128>(1, 100), + std::vector<absl::uint128>(1, 255)), // beta + testing::Values(1))); // level_step + +INSTANTIATE_TEST_SUITE_P( + OneHierarchyLevelVaryDomainSizes, DpfEvaluationTest, + testing::Combine( + // DPF parameters. + testing::Values( + // Vary domain sizes, small element size. + std::vector<DpfTestParameters>{ + {.log_domain_size = 0, .element_bitsize = 8}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 1, .element_bitsize = 8}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 2, .element_bitsize = 8}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 3, .element_bitsize = 8}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 4, .element_bitsize = 8}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 5, .element_bitsize = 8}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 6, .element_bitsize = 8}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 7, .element_bitsize = 8}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 8, .element_bitsize = 8}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 9, .element_bitsize = 8}}, + // Vary domain sizes, medium element size. + std::vector<DpfTestParameters>{ + {.log_domain_size = 0, .element_bitsize = 64}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 1, .element_bitsize = 64}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 2, .element_bitsize = 64}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 3, .element_bitsize = 64}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 4, .element_bitsize = 64}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 5, .element_bitsize = 64}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 6, .element_bitsize = 64}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 7, .element_bitsize = 64}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 8, .element_bitsize = 64}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 9, .element_bitsize = 64}}, + // Vary domain sizes, large element size. + std::vector<DpfTestParameters>{ + {.log_domain_size = 0, .element_bitsize = 128}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 1, .element_bitsize = 128}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 2, .element_bitsize = 128}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 3, .element_bitsize = 128}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 4, .element_bitsize = 128}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 5, .element_bitsize = 128}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 6, .element_bitsize = 128}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 7, .element_bitsize = 128}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 8, .element_bitsize = 128}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 9, .element_bitsize = 128}}), + testing::Values(0), // alpha + testing::Values(std::vector<absl::uint128>(1, 1), + std::vector<absl::uint128>(1, 100), + std::vector<absl::uint128>(1, 255)), // beta + testing::Values(1))); // level_step + +INSTANTIATE_TEST_SUITE_P( + TwoHierarchyLevels, DpfEvaluationTest, + testing::Combine( + // DPF parameters. + testing::Values( + // Equal element sizes. + std::vector<DpfTestParameters>{ + {.log_domain_size = 5, .element_bitsize = 8}, + {.log_domain_size = 10, .element_bitsize = 8}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 5, .element_bitsize = 16}, + {.log_domain_size = 10, .element_bitsize = 16}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 5, .element_bitsize = 32}, + {.log_domain_size = 10, .element_bitsize = 32}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 5, .element_bitsize = 64}, + {.log_domain_size = 10, .element_bitsize = 64}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 5, .element_bitsize = 128}, + {.log_domain_size = 10, .element_bitsize = 128}}, + // First correction is in seed word. + std::vector<DpfTestParameters>{ + {.log_domain_size = 0, .element_bitsize = 8}, + {.log_domain_size = 10, .element_bitsize = 128}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 0, .element_bitsize = 16}, + {.log_domain_size = 10, .element_bitsize = 128}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 0, .element_bitsize = 32}, + {.log_domain_size = 10, .element_bitsize = 128}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 0, .element_bitsize = 64}, + {.log_domain_size = 10, .element_bitsize = 128}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 0, .element_bitsize = 128}, + {.log_domain_size = 10, .element_bitsize = 128}}), + testing::Values(0, 1, 2, 100, 1023), // alpha + testing::Values(std::vector<absl::uint128>({1, 2}), + std::vector<absl::uint128>({80, 90}), + std::vector<absl::uint128>({255, 255})), // beta + testing::Values(1, 2))); // level_step + +INSTANTIATE_TEST_SUITE_P( + ThreeHierarchyLevels, DpfEvaluationTest, + testing::Combine( + // DPF parameters. + testing::Values<std::vector<DpfTestParameters>>( + // Equal element sizes. + std::vector<DpfTestParameters>{ + {.log_domain_size = 5, .element_bitsize = 8}, + {.log_domain_size = 10, .element_bitsize = 8}, + {.log_domain_size = 15, .element_bitsize = 8}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 5, .element_bitsize = 16}, + {.log_domain_size = 10, .element_bitsize = 16}, + {.log_domain_size = 15, .element_bitsize = 16}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 5, .element_bitsize = 32}, + {.log_domain_size = 10, .element_bitsize = 32}, + {.log_domain_size = 15, .element_bitsize = 32}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 5, .element_bitsize = 64}, + {.log_domain_size = 10, .element_bitsize = 64}, + {.log_domain_size = 15, .element_bitsize = 64}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 5, .element_bitsize = 128}, + {.log_domain_size = 10, .element_bitsize = 128}, + {.log_domain_size = 15, .element_bitsize = 128}}, + // Varying element sizes + std::vector<DpfTestParameters>{ + {.log_domain_size = 5, .element_bitsize = 8}, + {.log_domain_size = 10, .element_bitsize = 16}, + {.log_domain_size = 15, .element_bitsize = 32}}, + // Small level distances. + std::vector<DpfTestParameters>{ + {.log_domain_size = 4, .element_bitsize = 8}, + {.log_domain_size = 5, .element_bitsize = 8}, + {.log_domain_size = 6, .element_bitsize = 8}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 3, .element_bitsize = 16}, + {.log_domain_size = 4, .element_bitsize = 16}, + {.log_domain_size = 5, .element_bitsize = 16}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 2, .element_bitsize = 32}, + {.log_domain_size = 3, .element_bitsize = 32}, + {.log_domain_size = 4, .element_bitsize = 32}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 1, .element_bitsize = 64}, + {.log_domain_size = 2, .element_bitsize = 64}, + {.log_domain_size = 3, .element_bitsize = 64}}, + std::vector<DpfTestParameters>{ + {.log_domain_size = 0, .element_bitsize = 128}, + {.log_domain_size = 1, .element_bitsize = 128}, + {.log_domain_size = 2, .element_bitsize = 128}}), + testing::Values(0, 1), // alpha + testing::Values(std::vector<absl::uint128>({1, 2, 3})), // beta + testing::Values(1, 2))); // level_step + +INSTANTIATE_TEST_SUITE_P( + MaximumOutputDomainSize, DpfEvaluationTest, + testing::Combine( + // DPF parameters. We want to be able to evaluate at every bit, so this + // lambda returns a vector with 129 parameters with log domain sizes + // 0...128. + testing::Values([]() -> std::vector<DpfTestParameters> { + std::vector<DpfTestParameters> parameters(129); + for (int i = 0; i < static_cast<int>(parameters.size()); ++i) { + parameters[i].log_domain_size = i; + parameters[i].element_bitsize = 64; + } + return parameters; + }()), + testing::Values(absl::MakeUint128(23, 42)), // alpha + testing::Values(std::vector<absl::uint128>(129, 1234567)), // beta + testing::Values(1, 2, 3, 5, 7))); // level_step + +} // namespace +} // namespace distributed_point_functions
diff --git a/third_party/distributed_point_functions/code/dpf/internal/BUILD b/third_party/distributed_point_functions/code/dpf/internal/BUILD new file mode 100644 index 0000000..0fce316 --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/internal/BUILD
@@ -0,0 +1,63 @@ +load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") + +package( + default_visibility = ["//dpf:__subpackages__"], +) + +licenses(["notice"]) + +cc_library( + name = "array_conversions", + hdrs = ["array_conversions.h"], + deps = [ + "@com_google_absl//absl/base", + "@com_google_absl//absl/numeric:int128", + ], +) + +cc_test( + name = "array_conversions_test", + srcs = ["array_conversions_test.cc"], + deps = [ + ":array_conversions", + "@com_github_google_googletest//:gtest_main", + ], +) + +cc_library( + name = "status_matchers", + testonly = 1, + srcs = [ + "status_matchers.cc", + ], + hdrs = ["status_matchers.h"], + deps = [ + "//dpf:status_macros", + "@com_github_google_googletest//:gtest", + "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings", + ], +) + +cc_library( + name = "pseudorandom_generator", + srcs = ["pseudorandom_generator.cc"], + hdrs = ["pseudorandom_generator.h"], + deps = [ + "@boringssl//:crypto", + "@com_google_absl//absl/numeric:int128", + "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", + ], +) + +cc_test( + name = "pseudorandom_generator_test", + srcs = ["pseudorandom_generator_test.cc"], + deps = [ + ":pseudorandom_generator", + ":status_matchers", + "@com_github_google_googletest//:gtest_main", + ], +)
diff --git a/third_party/distributed_point_functions/code/dpf/internal/array_conversions.h b/third_party/distributed_point_functions/code/dpf/internal/array_conversions.h new file mode 100644 index 0000000..2df61aa --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/internal/array_conversions.h
@@ -0,0 +1,82 @@ +/* + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DISTRIBUTED_POINT_FUNCTIONS_DPF_INTERNAL_ARRAY_CONVERSIONS_H_ +#define DISTRIBUTED_POINT_FUNCTIONS_DPF_INTERNAL_ARRAY_CONVERSIONS_H_ + +#include <array> +#include <type_traits> + +#include "absl/base/casts.h" +#include "absl/numeric/int128.h" + +namespace distributed_point_functions { +namespace dpf_internal { + +// Computes the number of unsigned integers of type T that fit into an +// absl::uint128. Results in compile-time errors if T is not an unsigned +// integer, or if it doesn't have a positive size that divides +// sizeof(absl::uint128). +template <typename T> +constexpr size_t ElementsPerBlock() { + static_assert( + std::is_same<T, absl::uint128>::value | std::is_unsigned<T>::value, + "Uint128ToArray<T> may only be used with unsigned types T"); + static_assert(sizeof(T) <= sizeof(absl::uint128), + "sizeof(T) may not be larger than sizeof(absl::uint128)"); + static_assert(sizeof(T) != 0, "sizeof(T) must be positive"); + static_assert(sizeof(absl::uint128) % sizeof(T) == 0, + "sizeof(T) must divide sizeof(absl::uint128)"); + return sizeof(absl::uint128) / sizeof(T); +} + +// Converts a given 128 bit block to a std::array of unsigned integers in +// little-endian order, i.e., the first item in the returned array corresponds +// to the lowest-order bits in `in`. +template <typename T> +std::array<T, ElementsPerBlock<T>()> Uint128ToArray(absl::uint128 in) { +#ifdef ABSL_IS_LITTLE_ENDIAN + return absl::bit_cast<std::array<T, ElementsPerBlock<T>()>>(in); +#else + std::array<T, ElementsPerBlock<T>()> result; + for (int i = 0; i < ElementsPerBlock<T>(); ++i) { + // static_cast takes the result modulo 2^element_bitsize, so this is safe. + result[i] = static_cast<T>(in >> (i * sizeof(T) * 8)); + } + return result; +#endif +} + +// Assembles a std::array of unsigned integers into a single absl::uint128 +// block. The first item in `in` will be placed in the lowest-order bits of the +// uint128. +template <typename T> +absl::uint128 ArrayToUint128(const std::array<T, ElementsPerBlock<T>()> &in) { +#ifdef ABSL_IS_LITTLE_ENDIAN + return absl::bit_cast<absl::uint128>(in); +#else + absl::uint128 result = 0; + for (int i = 0; i < ElementsPerBlock<T>(); i++) { + result |= absl::uint128{in[i]} << (i * sizeof(T) * 8); + } + return result; +#endif +} + +} // namespace dpf_internal +} // namespace distributed_point_functions + +#endif // DISTRIBUTED_POINT_FUNCTIONS_DPF_INTERNAL_ARRAY_CONVERSIONS_H_
diff --git a/third_party/distributed_point_functions/code/dpf/internal/array_conversions_test.cc b/third_party/distributed_point_functions/code/dpf/internal/array_conversions_test.cc new file mode 100644 index 0000000..3b69321d --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/internal/array_conversions_test.cc
@@ -0,0 +1,63 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "dpf/internal/array_conversions.h" + +#include <gmock/gmock.h> +#include <gtest/gtest.h> + +namespace distributed_point_functions { +namespace dpf_internal { +namespace { + +using ::testing::ElementsAre; + +TEST(ArrayConversionTest, TestUint128ToArray) { + absl::uint128 block = + absl::MakeUint128(0x0f0e0d0c0b0a0908, 0x0706050403020100); + EXPECT_THAT(Uint128ToArray<uint8_t>(block), + ElementsAre(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F)); + EXPECT_THAT(Uint128ToArray<uint16_t>(block), + ElementsAre(0x0100, 0x0302, 0x0504, 0x0706, 0x0908, 0x0b0a, + 0x0d0c, 0x0f0e)); + EXPECT_THAT(Uint128ToArray<uint32_t>(block), + ElementsAre(0x03020100, 0x07060504, 0x0b0a0908, 0x0f0e0d0c)); + EXPECT_THAT(Uint128ToArray<uint64_t>(block), + ElementsAre(0x0706050403020100, 0x0f0e0d0c0b0a0908)); + EXPECT_THAT(Uint128ToArray<absl::uint128>(block), ElementsAre(block)); +} + +TEST(ArrayConversionTest, TestArrayToUint128) { + absl::uint128 expected = + absl::MakeUint128(0x0f0e0d0c0b0a0908, 0x0706050403020100); + EXPECT_EQ( + ArrayToUint128<uint8_t>({0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}), + expected); + EXPECT_EQ(ArrayToUint128<uint16_t>({0x0100, 0x0302, 0x0504, 0x0706, 0x0908, + 0x0b0a, 0x0d0c, 0x0f0e}), + expected); + EXPECT_EQ(ArrayToUint128<uint32_t>( + {0x03020100, 0x07060504, 0x0b0a0908, 0x0f0e0d0c}), + expected); + EXPECT_EQ(ArrayToUint128<uint64_t>({0x0706050403020100, 0x0f0e0d0c0b0a0908}), + expected); + EXPECT_EQ(ArrayToUint128<absl::uint128>({expected}), expected); +} + +} // namespace + +} // namespace dpf_internal +} // namespace distributed_point_functions
diff --git a/third_party/distributed_point_functions/code/dpf/internal/pseudorandom_generator.cc b/third_party/distributed_point_functions/code/dpf/internal/pseudorandom_generator.cc new file mode 100644 index 0000000..4456881 --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/internal/pseudorandom_generator.cc
@@ -0,0 +1,89 @@ +/* + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dpf/internal/pseudorandom_generator.h" + +#include <vector> + +namespace distributed_point_functions { +namespace dpf_internal { + +PseudorandomGenerator::PseudorandomGenerator( + bssl::UniquePtr<EVP_CIPHER_CTX> prg_ctx) + : prg_ctx_(std::move(prg_ctx)) {} + +absl::StatusOr<PseudorandomGenerator> PseudorandomGenerator::Create( + absl::uint128 key) { + bssl::UniquePtr<EVP_CIPHER_CTX> prg_ctx(EVP_CIPHER_CTX_new()); + if (!prg_ctx) { + return absl::InternalError("Failed to allocate AES context"); + } + // Set up the OpenSSL encryption context. We want to evaluate the PRG in + // parallel on many seeds (see class comment in pseudorandom_generator.h), so + // we're using ECB mode here to achieve that. This batched evaluation is not + // to be confused with encryption of an array, for which ECB would be + // insecure. + int openssl_status = + EVP_EncryptInit_ex(prg_ctx.get(), EVP_aes_128_ecb(), nullptr, + reinterpret_cast<const uint8_t*>(&key), nullptr); + if (openssl_status != 1) { + return absl::InternalError("Failed to set up AES context"); + } + return PseudorandomGenerator(std::move(prg_ctx)); +} + +absl::Status PseudorandomGenerator::Evaluate( + absl::Span<const absl::uint128> in, absl::Span<absl::uint128> out) const { + if (in.size() != out.size()) { + return absl::InvalidArgumentError("Input and output sizes don't match"); + } + if (in.empty()) { + // Nothing to do. + return absl::OkStatus(); + } + // Compute orthomorphism sigma for each element in `in`, `kBatchSize` elements + // at a time. + auto in_size = static_cast<int64_t>(in.size()); + std::vector<absl::uint128> sigma_in(kBatchSize); + for (int64_t start_block = 0; start_block < in_size; + start_block += kBatchSize) { + int64_t batch_size = std::min<int64_t>(in_size - start_block, kBatchSize); + for (int i = 0; i < batch_size; ++i) { + sigma_in[i] = + absl::MakeUint128(absl::Uint128High64(in[start_block + i]) ^ + absl::Uint128Low64(in[start_block + i]), + absl::Uint128High64(in[start_block + i])); + } + int out_len; + int openssl_status = EVP_EncryptUpdate( + prg_ctx_.get(), reinterpret_cast<uint8_t*>(out.data() + start_block), + &out_len, reinterpret_cast<const uint8_t*>(sigma_in.data()), + static_cast<int>(batch_size * sizeof(absl::uint128))); + if (openssl_status != 1) { + return absl::InternalError("AES encryption failed"); + } + if (out_len != static_cast<int>(sizeof(absl::uint128)) * batch_size) { + return absl::InternalError("OpenSSL output size does not match"); + } + for (int64_t i = 0; i < batch_size; ++i) { + out[start_block + i] ^= sigma_in[i]; + } + } + return absl::OkStatus(); +} + +} // namespace dpf_internal +} // namespace distributed_point_functions
diff --git a/third_party/distributed_point_functions/code/dpf/internal/pseudorandom_generator.h b/third_party/distributed_point_functions/code/dpf/internal/pseudorandom_generator.h new file mode 100644 index 0000000..a4f87b7e --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/internal/pseudorandom_generator.h
@@ -0,0 +1,75 @@ +/* + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DISTRIBUTED_POINT_FUNCTIONS_DPF_INTERNAL_PSEUDORANDOM_GENERATOR_H_ +#define DISTRIBUTED_POINT_FUNCTIONS_DPF_INTERNAL_PSEUDORANDOM_GENERATOR_H_ + +#include <openssl/cipher.h> + +#include "absl/numeric/int128.h" +#include "absl/status/statusor.h" + +namespace distributed_point_functions { +namespace dpf_internal { + +// PseudorandomGenerator (PRG) based on AES. For key `key`, input `in` and +// output `out`, the PRG is defined as +// +// out[i] = AES.Encrypt(key, sigma(in[i])) ^ sigma(in[i]), +// +// where sigma(x) = (x.high64 ^ x.low64, x.high64). This is the +// correlation-robust MMO construction from https://eprint.iacr.org/2019/074.pdf +// (pp. 18-19). +class PseudorandomGenerator { + public: + // Creates a new PseudorandomGenerator with the given `key`. + // + // Returns INTERNAL in case of allocation failures or OpenSSL errors. + static absl::StatusOr<PseudorandomGenerator> Create(absl::uint128 key); + + // Computes pseudorandom values from `in` and writing the output to `out`. + // It is safe to call this method if `in` and `out` overlap. + // + // Returns INVALID_ARGUMENT if sizes of `in` and `out` don't match or their + // sizes in bytes exceed an `int`, or INTERNAL in case of OpenSSL errors. + absl::Status Evaluate(absl::Span<const absl::uint128> in, + absl::Span<absl::uint128> out) const; + + // PseudorandomGenerator is not copyable. + PseudorandomGenerator(const PseudorandomGenerator&) = delete; + PseudorandomGenerator& operator=(const PseudorandomGenerator&) = delete; + + // PseudorandomGenerator is movable (it just wraps a bssl::UniquePtr). + PseudorandomGenerator(PseudorandomGenerator&&) = default; + PseudorandomGenerator& operator=(PseudorandomGenerator&&) = default; + + // The maximum number of AES blocks encrypted at once. Chosen to pipeline AES + // as much as possible, while still allowing both source and destination to + // comfortably fit in the L2 CPU cache. + static constexpr int kBatchSize = 4096; + + private: + // Called by `Create`. + PseudorandomGenerator(bssl::UniquePtr<EVP_CIPHER_CTX> prg_ctx); + + // The OpenSSL encryption context used by `Evaluate`. + bssl::UniquePtr<EVP_CIPHER_CTX> prg_ctx_; +}; + +} // namespace dpf_internal +} // namespace distributed_point_functions + +#endif // DISTRIBUTED_POINT_FUNCTIONS_DPF_INTERNAL_PSEUDORANDOM_GENERATOR_H_
diff --git a/third_party/distributed_point_functions/code/dpf/internal/pseudorandom_generator_test.cc b/third_party/distributed_point_functions/code/dpf/internal/pseudorandom_generator_test.cc new file mode 100644 index 0000000..8eefcdc --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/internal/pseudorandom_generator_test.cc
@@ -0,0 +1,150 @@ +/* + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dpf/internal/pseudorandom_generator.h" + +#include <gmock/gmock.h> +#include <gtest/gtest.h> + +#include "dpf/internal/status_matchers.h" + +namespace distributed_point_functions { +namespace dpf_internal { +namespace { + +// Test blocks for keys, inputs, and outputs. +constexpr absl::uint128 kKey0 = + absl::MakeUint128(0x0000000000000000, 0x0000000000000000); +constexpr absl::uint128 kKey1 = + absl::MakeUint128(0x1111111111111111, 0x1111111111111111); +constexpr absl::uint128 kSeed0 = + absl::MakeUint128(0x0123012301230123, 0x0123012301230123); +constexpr absl::uint128 kSeed1 = + absl::MakeUint128(0x4567456745674567, 0x4567456745674567); +constexpr absl::uint128 kSeed2 = + absl::MakeUint128(0x89ab89ab89ab89ab, 0x89ab89ab89ab89ab); +constexpr absl::uint128 kSeed3 = + absl::MakeUint128(0xcdefcdefcdefcdef, 0xcdefcdefcdefcdef); + +TEST(PseudorandomGeneratorTest, CreateSucceeds) { + DPF_EXPECT_OK(PseudorandomGenerator::Create(kKey0)); +} + +TEST(PseudorandomGeneratorTest, SameKeysAndSeedsGenerateSameOutput) { + std::vector<absl::uint128> in; + + DPF_ASSERT_OK_AND_ASSIGN(PseudorandomGenerator prg_0, + PseudorandomGenerator::Create(kKey0)); + DPF_ASSERT_OK_AND_ASSIGN(PseudorandomGenerator prg_1, + PseudorandomGenerator::Create(kKey0)); + in = {kSeed0}; + // Initialize output arrays with different values, to make sure they are the + // same afterwards. + std::vector<absl::uint128> out_0(in.size(), kSeed2), out_1(in.size(), kSeed3); + + DPF_EXPECT_OK(prg_0.Evaluate(in, absl::MakeSpan(out_0))); + DPF_EXPECT_OK(prg_1.Evaluate(in, absl::MakeSpan(out_1))); + EXPECT_THAT(out_0, testing::ElementsAreArray(out_1)); +} + +TEST(PseudorandomGeneratorTest, DifferentKeysGenerateDifferentOutput) { + std::vector<absl::uint128> in{kSeed0}; + + DPF_ASSERT_OK_AND_ASSIGN(PseudorandomGenerator prg_0, + PseudorandomGenerator::Create(kKey0)); + DPF_ASSERT_OK_AND_ASSIGN(PseudorandomGenerator prg_1, + PseudorandomGenerator::Create(kKey1)); + // Initialize output arrays with the same values, to make sure they are + // different afterwards. + std::vector<absl::uint128> out_0(in.size(), kSeed2), out_1(in.size(), kSeed2); + + DPF_EXPECT_OK(prg_0.Evaluate(in, absl::MakeSpan(out_0))); + DPF_EXPECT_OK(prg_1.Evaluate(in, absl::MakeSpan(out_1))); + EXPECT_THAT(out_0, testing::Not(testing::ElementsAreArray(out_1))); +} + +TEST(PseudorandomGeneratorTest, DifferentSeedsGenerateDifferentOutput) { + DPF_ASSERT_OK_AND_ASSIGN(PseudorandomGenerator prg, + PseudorandomGenerator::Create(kKey0)); + std::vector<absl::uint128> in_0, in_1; + + in_0 = {kSeed0}; + in_1 = {kSeed1}; + // Initialize output arrays with the same values, to make sure they are + // different afterwards. + std::vector<absl::uint128> out_0(in_0.size(), kSeed2), + out_1(in_1.size(), kSeed2); + + DPF_EXPECT_OK(prg.Evaluate(in_0, absl::MakeSpan(out_0))); + DPF_EXPECT_OK(prg.Evaluate(in_1, absl::MakeSpan(out_1))); + EXPECT_THAT(out_0, testing::Not(testing::ElementsAreArray(out_1))); +} + +TEST(PseudorandomGeneratorTest, BatchedEvaluationEqualsBlockWiseEvaluation) { + DPF_ASSERT_OK_AND_ASSIGN(PseudorandomGenerator prg, + PseudorandomGenerator::Create(kKey0)); + std::vector<absl::uint128> in_0, in_1, in_2; + + in_0 = {kSeed0}; + in_1 = {kSeed1}; + in_2 = {kSeed0, kSeed1}; + std::vector<absl::uint128> out_0(in_0.size()), out_1(in_1.size()), + out_2(in_2.size()); + + DPF_EXPECT_OK(prg.Evaluate(in_0, absl::MakeSpan(out_0))); + DPF_EXPECT_OK(prg.Evaluate(in_1, absl::MakeSpan(out_1))); + DPF_EXPECT_OK(prg.Evaluate(in_2, absl::MakeSpan(out_2))); + EXPECT_THAT(out_2, testing::ElementsAre(out_0[0], out_1[0])); +} + +TEST(PseudorandomGeneratorTest, TestSpecificOutputValues) { + std::vector<absl::uint128> in, out_0, out_1; + + DPF_ASSERT_OK_AND_ASSIGN(PseudorandomGenerator prg_0, + PseudorandomGenerator::Create(kKey0)); + DPF_ASSERT_OK_AND_ASSIGN(PseudorandomGenerator prg_1, + PseudorandomGenerator::Create(kKey1)); + in = {kSeed0, kSeed1}; + out_0.resize(in.size()); + out_1.resize(in.size()); + + DPF_EXPECT_OK(prg_0.Evaluate(in, absl::MakeSpan(out_0))); + DPF_EXPECT_OK(prg_1.Evaluate(in, absl::MakeSpan(out_1))); + EXPECT_THAT(out_0, + testing::ElementsAre( + absl::MakeUint128(0x73c2dc14812be4ef, 0xeac64d09c8adf8ed), + absl::MakeUint128(0xb8f33653a53a8436, 0xaedf39b62de91d95))); + EXPECT_THAT(out_1, + testing::ElementsAre( + absl::MakeUint128(0x934704aff58fa233, 0xd3c20d1b9cc18d8f), + absl::MakeUint128(0x530098817046d284, 0x43e61d3273a04f7c))); +} + +TEST(PseudorandomGeneratorTest, EvaluateFailsWhenSizesDontMatch) { + std::vector<absl::uint128> in{kSeed0}; + DPF_ASSERT_OK_AND_ASSIGN(PseudorandomGenerator prg, + PseudorandomGenerator::Create(kKey0)); + + std::vector<absl::uint128> out(in.size() + 1); + + EXPECT_THAT(prg.Evaluate(in, absl::MakeSpan(out)), + StatusIs(absl::StatusCode::kInvalidArgument, + "Input and output sizes don't match")); +} + +} // namespace +} // namespace dpf_internal +} // namespace distributed_point_functions
diff --git a/third_party/distributed_point_functions/code/dpf/internal/status_matchers.cc b/third_party/distributed_point_functions/code/dpf/internal/status_matchers.cc new file mode 100644 index 0000000..b9fa6fe --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/internal/status_matchers.cc
@@ -0,0 +1,58 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "dpf/internal/status_matchers.h" + +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" + +namespace distributed_point_functions { +namespace dpf_internal { + +void StatusIsMatcherCommonImpl::DescribeTo(std::ostream* os) const { + *os << "has a status code that "; + code_matcher_.DescribeTo(os); + *os << ", and has an error message that "; + message_matcher_.DescribeTo(os); +} + +void StatusIsMatcherCommonImpl::DescribeNegationTo(std::ostream* os) const { + *os << "has a status code that "; + code_matcher_.DescribeNegationTo(os); + *os << ", or has an error message that "; + message_matcher_.DescribeNegationTo(os); +} + +bool StatusIsMatcherCommonImpl::MatchAndExplain( + const ::absl::Status& status, + ::testing::MatchResultListener* result_listener) const { + ::testing::StringMatchResultListener inner_listener; + if (!code_matcher_.MatchAndExplain(status.code(), &inner_listener)) { + *result_listener << (inner_listener.str().empty() + ? "whose status code is wrong" + : "which has a status code " + + inner_listener.str()); + return false; + } + + if (!message_matcher_.Matches(std::string(status.message()))) { + *result_listener << "whose error message is wrong: " << status.message(); + return false; + } + + return true; +} + +} // namespace dpf_internal +} // namespace distributed_point_functions
diff --git a/third_party/distributed_point_functions/code/dpf/internal/status_matchers.h b/third_party/distributed_point_functions/code/dpf/internal/status_matchers.h new file mode 100644 index 0000000..008f6b9 --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/internal/status_matchers.h
@@ -0,0 +1,387 @@ +/* + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Testing utilities for working with absl::Status and absl::StatusOr. +// +// Defines the following utilities: +// +// ================= +// DPF_EXPECT_OK(s) +// +// DPF_ASSERT_OK(s) +// ================= +// Convenience macros for `EXPECT_THAT(s, IsOk())`, where `s` is either +// a `Status` or a `StatusOr<T>`. +// +// There are no EXPECT_NOT_OK/ASSERT_NOT_OK macros since they would not +// provide much value (when they fail, they would just print the OK status +// which conveys no more information than `EXPECT_FALSE(s.ok())`. You can +// of course use `EXPECT_THAT(s, Not(IsOk()))` if you prefer _THAT style. +// +// If you want to check for particular errors, better alternatives are: +// EXPECT_THAT(s, StatusIs(expected_error)); +// EXPECT_THAT(s, StatusIs(_, HasSubstr("expected error"))); +// +// =============== +// IsOkAndHolds(m) +// =============== +// +// This gMock matcher matches a StatusOr<T> value whose status is OK +// and whose inner value matches matcher m. Example: +// +// using ::testing::MatchesRegex; +// using distributed_point_functions::IsOkAndHolds; +// ... +// absl::StatusOr<string> maybe_name = ...; +// EXPECT_THAT(maybe_name, IsOkAndHolds(MatchesRegex("John .*"))); +// +// =============================== +// StatusIs(status_code_matcher, +// error_message_matcher) +// =============================== +// +// This gMock matcher matches a Status or StatusOr<T> value if all of the +// following are true: +// +// - the status' error_code() matches status_code_matcher, and +// - the status' error_message() matches error_message_matcher. +// +// Example: +// +// enum FooErrorCode { +// ... +// kServerError +// }; +// +// using ::testing::HasSubstr; +// using ::testing::MatchesRegex; +// using ::testing::Ne; +// using ::testing::_; +// using distributed_point_functions::StatusIs; +// absl::StatusOr<string> GetName(int id); +// ... +// +// // The status code must be kServerError; the error message can be +// // anything. +// EXPECT_THAT(GetName(42), +// StatusIs(kServerError, _)); +// // The status code can be anything; the error message must match the +// // regex. +// EXPECT_THAT(GetName(43), +// StatusIs(_, MatchesRegex("server.*time-out"))); +// +// // The status code should not be kServerError; the error message can be +// // anything with "client" in it. +// EXPECT_CALL(mock_env, HandleStatus( +// StatusIs(Ne(kServerError), HasSubstr("client")))); +// +// =============================== +// StatusIs(status_code_matcher) +// =============================== +// +// This is a shorthand for +// StatusIs(status_code_matcher, +// testing::_) +// In other words, it's like the two-argument StatusIs(), except that it +// ignores error message. +// +// =============== +// IsOk() +// =============== +// +// Matches an absl::Status or absl::StatusOr<T> value whose status value is +// absl::StatusCode::kOk. Equivalent to 'StatusIs(absl::StatusCode::kOk)'. +// Example: +// using distributed_point_functions::IsOk; +// ... +// absl::StatusOr<string> maybe_name = ...; +// EXPECT_THAT(maybe_name, IsOk()); +// Status s = ...; +// EXPECT_THAT(s, IsOk()); +// + +#ifndef DISTRIBUTED_POINT_FUNCTIONS_DPF_UTIL_STATUS_MATCHERS_H_ +#define DISTRIBUTED_POINT_FUNCTIONS_DPF_UTIL_STATUS_MATCHERS_H_ + +#include <gmock/gmock.h> + +#include <string> + +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "dpf/status_macros.h" + +namespace distributed_point_functions { +namespace dpf_internal { + +inline const absl::Status& GetStatus(const absl::Status& status) { + return status; +} + +template <typename T> +inline const absl::Status& GetStatus(const absl::StatusOr<T>& status) { + return status.status(); +} + +//////////////////////////////////////////////////////////// +// Implementation of IsOkAndHolds(). + +// Monomorphic implementation of matcher IsOkAndHolds(m). StatusOrType is a +// reference to StatusOr<T>. +template <typename StatusOrType> +class IsOkAndHoldsMatcherImpl + : public ::testing::MatcherInterface<StatusOrType> { + public: + typedef + typename std::remove_reference<StatusOrType>::type::value_type value_type; + + template <typename InnerMatcher> + explicit IsOkAndHoldsMatcherImpl(InnerMatcher&& inner_matcher) + : inner_matcher_(::testing::SafeMatcherCast<const value_type&>( + std::forward<InnerMatcher>(inner_matcher))) {} + + void DescribeTo(std::ostream* os) const override { + *os << "is OK and has a value that "; + inner_matcher_.DescribeTo(os); + } + + void DescribeNegationTo(std::ostream* os) const override { + *os << "isn't OK or has a value that "; + inner_matcher_.DescribeNegationTo(os); + } + + bool MatchAndExplain( + StatusOrType actual_value, + ::testing::MatchResultListener* result_listener) const override { + if (!actual_value.ok()) { + *result_listener << "which has status " << actual_value.status(); + return false; + } + + ::testing::StringMatchResultListener inner_listener; + const bool matches = + inner_matcher_.MatchAndExplain(*actual_value, &inner_listener); + const std::string inner_explanation = inner_listener.str(); + if (!inner_explanation.empty()) { + *result_listener << "which contains value " + << ::testing::PrintToString(*actual_value) << ", " + << inner_explanation; + } + return matches; + } + + private: + const ::testing::Matcher<const value_type&> inner_matcher_; +}; + +// Implements IsOkAndHolds(m) as a polymorphic matcher. +template <typename InnerMatcher> +class IsOkAndHoldsMatcher { + public: + explicit IsOkAndHoldsMatcher(InnerMatcher inner_matcher) + : inner_matcher_(std::move(inner_matcher)) {} + + // Converts this polymorphic matcher to a monomorphic matcher of the + // given type. StatusOrType can be either StatusOr<T> or a + // reference to StatusOr<T>. + template <typename StatusOrType> + operator ::testing::Matcher<StatusOrType>() const { // NOLINT + return ::testing::Matcher<StatusOrType>( + new IsOkAndHoldsMatcherImpl<const StatusOrType&>(inner_matcher_)); + } + + private: + const InnerMatcher inner_matcher_; +}; + +//////////////////////////////////////////////////////////// +// Implementation of StatusIs(). + +// StatusIs() is a polymorphic matcher. This class is the common +// implementation of it shared by all types T where StatusIs() can be +// used as a Matcher<T>. +class StatusIsMatcherCommonImpl { + public: + StatusIsMatcherCommonImpl( + ::testing::Matcher<absl::StatusCode> code_matcher, + ::testing::Matcher<const std::string&> message_matcher) + : code_matcher_(std::move(code_matcher)), + message_matcher_(std::move(message_matcher)) {} + + void DescribeTo(std::ostream* os) const; + + void DescribeNegationTo(std::ostream* os) const; + + bool MatchAndExplain(const absl::Status& status, + ::testing::MatchResultListener* result_listener) const; + + private: + const ::testing::Matcher<absl::StatusCode> code_matcher_; + const ::testing::Matcher<const std::string&> message_matcher_; +}; + +// Monomorphic implementation of matcher StatusIs() for a given type +// T. T can be Status, StatusOr<>, or a reference to either of them. +template <typename T> +class MonoStatusIsMatcherImpl : public ::testing::MatcherInterface<T> { + public: + explicit MonoStatusIsMatcherImpl(StatusIsMatcherCommonImpl common_impl) + : common_impl_(std::move(common_impl)) {} + + void DescribeTo(std::ostream* os) const override { + common_impl_.DescribeTo(os); + } + + void DescribeNegationTo(std::ostream* os) const override { + common_impl_.DescribeNegationTo(os); + } + + bool MatchAndExplain( + T actual_value, + ::testing::MatchResultListener* result_listener) const override { + return common_impl_.MatchAndExplain(GetStatus(actual_value), + result_listener); + } + + private: + StatusIsMatcherCommonImpl common_impl_; +}; + +// Implements StatusIs() as a polymorphic matcher. +class StatusIsMatcher { + public: + template <typename StatusCodeMatcher, typename StatusMessageMatcher> + StatusIsMatcher(StatusCodeMatcher&& code_matcher, + StatusMessageMatcher&& message_matcher) + : common_impl_(::testing::MatcherCast<absl::StatusCode>( + std::forward<StatusCodeMatcher>(code_matcher)), + ::testing::MatcherCast<const std::string&>( + std::forward<StatusMessageMatcher>(message_matcher))) { + } + + // Converts this polymorphic matcher to a monomorphic matcher of the + // given type. T can be StatusOr<>, Status, or a reference to + // either of them. + template <typename T> + operator ::testing::Matcher<T>() const { // NOLINT + return ::testing::Matcher<T>( + new MonoStatusIsMatcherImpl<const T&>(common_impl_)); + } + + private: + const StatusIsMatcherCommonImpl common_impl_; +}; + +// Monomorphic implementation of matcher IsOk() for a given type T. +// T can be Status, StatusOr<>, or a reference to either of them. +template <typename T> +class MonoIsOkMatcherImpl : public ::testing::MatcherInterface<T> { + public: + void DescribeTo(std::ostream* os) const override { *os << "is OK"; } + void DescribeNegationTo(std::ostream* os) const override { + *os << "is not OK"; + } + bool MatchAndExplain( + T actual_value, + ::testing::MatchResultListener* result_listener) const override { + if (!GetStatus(actual_value).ok()) { + *result_listener << "whose status is " + << GetStatus(actual_value).message(); + return false; + } + return true; + } +}; + +// Implements IsOk() as a polymorphic matcher. +class IsOkMatcher { + public: + template <typename T> + operator ::testing::Matcher<T>() const { // NOLINT + return ::testing::Matcher<T>(new MonoIsOkMatcherImpl<const T&>()); + } +}; + +// Macros for testing the results of functions that return absl::Status or +// absl::StatusOr<T> (for any type T). +#define DPF_EXPECT_OK(expression) \ + EXPECT_THAT(expression, distributed_point_functions::dpf_internal::IsOk()) +#define DPF_ASSERT_OK(expression) \ + ASSERT_THAT(expression, distributed_point_functions::dpf_internal::IsOk()) + +// Executes an expression that returns an absl::StatusOr, and assigns the +// contained variable to lhs if the error code is OK. +// If the Status is non-OK, generates a test failure and returns from the +// current function, which must have a void return type. +// +// Example: Declaring and initializing a new value +// DPF_ASSERT_OK_AND_ASSIGN(const ValueType& value, MaybeGetValue(arg)); +// +// Example: Assigning to an existing value +// ValueType value; +// DPF_ASSERT_OK_AND_ASSIGN(value, MaybeGetValue(arg)); +// +// The value assignment example would expand into something like: +// auto status_or_value = MaybeGetValue(arg); +// DPF_ASSERT_OK(status_or_value.status()); +// value = std::move(status_or_value).ValueOrDie(); +// +// WARNING: Like ASSIGN_OR_RETURN, DPF_ASSERT_OK_AND_ASSIGN expands into +// multiple statements; it cannot be used in a single statement (e.g. as the +// body of an if statement without {})! +#define DPF_ASSERT_OK_AND_ASSIGN(lhs, rexpr) \ + DPF_ASSERT_OK_AND_ASSIGN_IMPL_( \ + DPF_STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __LINE__), lhs, rexpr) + +#define DPF_ASSERT_OK_AND_ASSIGN_IMPL_(statusor, lhs, rexpr) \ + auto statusor = (rexpr); \ + DPF_ASSERT_OK(statusor); \ + lhs = std::move(statusor).value(); + +// Returns a gMock matcher that matches a StatusOr<> whose status is +// OK and whose value matches the inner matcher. +template <typename InnerMatcher> +dpf_internal::IsOkAndHoldsMatcher<typename std::decay<InnerMatcher>::type> +IsOkAndHolds(InnerMatcher&& inner_matcher) { + return dpf_internal::IsOkAndHoldsMatcher< + typename std::decay<InnerMatcher>::type>( + std::forward<InnerMatcher>(inner_matcher)); +} + +// Returns a gMock matcher that matches a Status or StatusOr<> whose status code +// matches code_matcher, and whose error message matches message_matcher. +template <typename StatusCodeMatcher, typename StatusMessageMatcher> +dpf_internal::StatusIsMatcher StatusIs(StatusCodeMatcher&& code_matcher, + StatusMessageMatcher&& message_matcher) { + return dpf_internal::StatusIsMatcher( + std::forward<StatusCodeMatcher>(code_matcher), + std::forward<StatusMessageMatcher>(message_matcher)); +} + +// Returns a gMock matcher that matches a Status or StatusOr<> whose status code +// matches code_matcher. +template <typename StatusCodeMatcher> +dpf_internal::StatusIsMatcher StatusIs(StatusCodeMatcher&& code_matcher) { + return StatusIs(std::forward<StatusCodeMatcher>(code_matcher), ::testing::_); +} + +// Returns a gMock matcher that matches a Status or StatusOr<> which is OK. +inline dpf_internal::IsOkMatcher IsOk() { return dpf_internal::IsOkMatcher(); } + +} // namespace dpf_internal +} // namespace distributed_point_functions + +#endif // DISTRIBUTED_POINT_FUNCTIONS_DPF_UTIL_STATUS_MATCHERS_H_
diff --git a/third_party/distributed_point_functions/code/dpf/status_macros.h b/third_party/distributed_point_functions/code/dpf/status_macros.h new file mode 100644 index 0000000..9949ec4 --- /dev/null +++ b/third_party/distributed_point_functions/code/dpf/status_macros.h
@@ -0,0 +1,51 @@ +/* + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DISTRIBUTED_POINT_FUNCTIONS_DPF_UTIL_STATUS_MACROS_H_ +#define DISTRIBUTED_POINT_FUNCTIONS_DPF_UTIL_STATUS_MACROS_H_ + +// Helper macro that checks if the right hand side (rexpression) evaluates to a +// StatusOr with Status OK, and if so assigns the value to the value on the left +// hand side (lhs), otherwise returns the error status. Example: +// DPF_ASSIGN_OR_RETURN(lhs, rexpression); +#define DPF_ASSIGN_OR_RETURN(lhs, rexpr) \ + DPF_ASSIGN_OR_RETURN_IMPL_( \ + DPF_STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __LINE__), lhs, rexpr) + +// Internal helper. +#define DPF_ASSIGN_OR_RETURN_IMPL_(statusor, lhs, rexpr) \ + auto statusor = (rexpr); \ + if (ABSL_PREDICT_FALSE(!statusor.ok())) { \ + return std::move(statusor).status(); \ + } \ + lhs = std::move(statusor).value() + +// Internal helper for concatenating macro values. +#define DPF_STATUS_MACROS_IMPL_CONCAT_INNER_(x, y) x##y +#define DPF_STATUS_MACROS_IMPL_CONCAT_(x, y) \ + DPF_STATUS_MACROS_IMPL_CONCAT_INNER_(x, y) + +#define DPF_RETURN_IF_ERROR(expr) \ + DPF_RETURN_IF_ERROR_IMPL_(DPF_STATUS_MACROS_IMPL_CONCAT_(_status, __LINE__), \ + expr) + +#define DPF_RETURN_IF_ERROR_IMPL_(status, expr) \ + auto status = (expr); \ + if (ABSL_PREDICT_FALSE(!status.ok())) { \ + return status; \ + } + +#endif // DISTRIBUTED_POINT_FUNCTIONS_DPF_UTIL_STATUS_MACROS_H_
diff --git a/third_party/distributed_point_functions/fuzz/dpf_fuzzer.cc b/third_party/distributed_point_functions/fuzz/dpf_fuzzer.cc index 3fc6586..62402fa 100644 --- a/third_party/distributed_point_functions/fuzz/dpf_fuzzer.cc +++ b/third_party/distributed_point_functions/fuzz/dpf_fuzzer.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 "third_party/distributed_point_functions/src/dpf/distributed_point_function.h" +#include "third_party/distributed_point_functions/code/dpf/distributed_point_function.h" #include <stddef.h> #include <stdint.h>
diff --git a/third_party/distributed_point_functions/glog/logging.h b/third_party/distributed_point_functions/glog/logging.h index 3f0fe1b2..7fff05a 100644 --- a/third_party/distributed_point_functions/glog/logging.h +++ b/third_party/distributed_point_functions/glog/logging.h
@@ -5,27 +5,6 @@ #ifndef THIRD_PARTY_DISTRIBUTED_POINT_FUNCTIONS_GLOG_LOGGING_H_ #define THIRD_PARTY_DISTRIBUTED_POINT_FUNCTIONS_GLOG_LOGGING_H_ -#include <stdlib.h> - -#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) -#define DCHECK_IS_ON() false -#else -#define DCHECK_IS_ON() true -#endif - -#if DCHECK_IS_ON() - -#define DCHECK(condition) \ - if (!(condition)) { \ - printf("Check failed: function %s, file %s, line %d.\n", \ - __PRETTY_FUNCTION__, __FILE__, __LINE__); \ - abort(); \ - } - -#else - -#define DCHECK(condition) (void)(condition) - -#endif +#include "base/check.h" #endif // THIRD_PARTY_DISTRIBUTED_POINT_FUNCTIONS_GLOG_LOGGING_H_
diff --git a/third_party/unrar/README.chromium b/third_party/unrar/README.chromium index 2f1efb0..36d1e01 100644 --- a/third_party/unrar/README.chromium +++ b/third_party/unrar/README.chromium
@@ -1,8 +1,8 @@ Name: UnRAR source for decompressing .RAR and other files. Short Name: unrar URL: https://github.com/aawc/unrar.git -Revision: 5bf3568f8865dc4d335def904f80c875dc45c4d1 -Version: 5.7.3 +Revision: d84d61312db5dd83ed1da9fe3e45cb233a56630c +Version: 6.0.3 License: Non-standard License File: src/license.txt Security Critical: yes
diff --git a/third_party/wayland-protocols/BUILD.gn b/third_party/wayland-protocols/BUILD.gn index ffdf9074..b268d0d1fb 100644 --- a/third_party/wayland-protocols/BUILD.gn +++ b/third_party/wayland-protocols/BUILD.gn
@@ -154,3 +154,7 @@ wayland_protocol("org_kde_kwin_idle") { sources = [ "kde/src/protocols/idle.xml" ] } + +wayland_protocol("touchpad_haptics_protocol") { + sources = [ "unstable/touchpad-haptics/touchpad-haptics-unstable-v1.xml" ] +}
diff --git a/third_party/wayland-protocols/unstable/touchpad-haptics/README.md b/third_party/wayland-protocols/unstable/touchpad-haptics/README.md new file mode 100644 index 0000000..efaf2359 --- /dev/null +++ b/third_party/wayland-protocols/unstable/touchpad-haptics/README.md
@@ -0,0 +1,5 @@ +Extensions of pointer protocol with details for haptic feedbacks. + +Maintainers: +Sean O'Brien <seobrien@chromium.org> +Yuichiro Hanada <yhanada@chromium.org>
diff --git a/third_party/wayland-protocols/unstable/touchpad-haptics/touchpad-haptics-unstable-v1.xml b/third_party/wayland-protocols/unstable/touchpad-haptics/touchpad-haptics-unstable-v1.xml new file mode 100644 index 0000000..5290bed --- /dev/null +++ b/third_party/wayland-protocols/unstable/touchpad-haptics/touchpad-haptics-unstable-v1.xml
@@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="touchpad_haptics_unstable_v1"> + + <copyright> + Copyright 2021 The Chromium Authors. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <interface name="zcr_touchpad_haptics_v1" version="1"> + <description summary="Allows to play haptic feedback effects on touchpad"> + Allows to play haptic feedback effects on touchpad. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding uinterface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and uinterface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + </description> + + <request name="destroy" type="destructor"> + <description summary="release the memory for the touchpad haptics object"> + Destroy touchpad_haptics object. + </description> + </request> + + <event name="activated" since="1"> + <description summary="touchpad haptics activated"> + Inform the client that a haptic touchpad is present and ready to perform + effects. + </description> + </event> + + <event name="deactivated" since="1"> + <description summary="touchpad haptics deactivated"> + Inform the client that no haptic touchpad is available, likely because the + user disabled haptic effects. + </description> + </event> + + <!-- This enum is from ui/events/devices/haptic_touchpad_effects.h --> + <enum name="effect"> + <entry name="snap" value="0" summary="UI feedback for snapping into place" /> + <entry name="snap_reverse" value="1" summary="UI feedback for snapping out of place" /> + <entry name="knock" value="2" summary="UI feedback for reaching a limit or boundary" /> + <entry name="tick" value="3" summary="UI feedback for discrete state changes" /> + <entry name="toggle_on" value="4" summary="UI feedback for activating a feature" /> + <entry name="toggle_off" value="5" summary="UI feedback for deactivating a feature" /> + <entry name="press" value="6" summary="Standard touchpad button down effect" /> + <entry name="release" value="7" summary="Standard touchpad button up effect" /> + <entry name="deep_press" value="8" summary="Deeper (more force) touchpad button down effect" /> + <entry name="deep_release" value="9" summary="Deeper (more force) touchpad button up effect" /> + </enum> + + <request name="play" since="1"> + <description summary="Play haptic feedback"> + Play the given haptic feedback with the given strength. + The strength should be in [1, 5]. + </description> + <arg name="effect" type="uint" enum="effect"/> + <arg name="strength" type="int"/> + </request> + + </interface> + +</protocol>
diff --git a/tools/mb/mb_config.pyl b/tools/mb/mb_config.pyl index 825d2629..069481e 100644 --- a/tools/mb/mb_config.pyl +++ b/tools/mb/mb_config.pyl
@@ -459,7 +459,6 @@ 'chromium.gpu.fyi': { # These all use the 'trybot' mixins to ensure that dcheck is on. 'ANGLE GPU Android Release (Nexus 5X)': 'gpu_tests_android_release_trybot_arm64', - 'Android FYI dEQP Release (Nexus 5X)': 'angle_deqp_android_release_trybot_arm64', 'Android FYI Release (Nexus 5)': 'gpu_tests_android_release_trybot_reclient', 'Android FYI Release (Nexus 5X)': 'gpu_tests_android_release_trybot_arm64_reclient', 'Android FYI Release (Nexus 9)': 'gpu_tests_android_release_trybot_arm64_reclient', @@ -473,7 +472,6 @@ 'GPU FYI Lacros x64 Builder': 'gpu_tests_ozone_linux_non_x11_release_trybot', 'GPU FYI Linux Builder': 'gpu_fyi_tests_release_trybot', 'GPU FYI Linux Builder (dbg)': 'gpu_fyi_tests_debug_trybot', - 'GPU FYI Linux dEQP Builder': 'angle_deqp_release_trybot', 'GPU FYI Mac Builder': 'gpu_fyi_tests_release_trybot', 'GPU FYI Mac Builder (asan)': 'gpu_fyi_tests_release_trybot_asan', 'GPU FYI Mac Builder (dbg)': 'gpu_fyi_tests_debug_trybot', @@ -848,7 +846,6 @@ 'cast_shell_android': 'android_cast_debug_static_bot_compile_only', 'gpu-fyi-try-android-l-nexus-5-32': 'gpu_tests_android_release_trybot', 'gpu-fyi-try-android-m-nexus-5x-64': 'gpu_tests_android_release_trybot_arm64', - 'gpu-fyi-try-android-m-nexus-5x-deqp-64': 'angle_deqp_android_release_trybot_arm64', 'gpu-fyi-try-android-m-nexus-5x-skgl-64': 'gpu_tests_android_release_trybot_arm64', 'gpu-fyi-try-android-m-nexus-9-64': 'gpu_tests_android_release_trybot_arm64', 'gpu-fyi-try-android-n-nvidia-shield-tv-64': 'gpu_tests_android_release_trybot_arm64', @@ -867,13 +864,11 @@ 'android-angle-chromium-try': 'gpu_tests_android_release_trybot_arm64_fastbuild', 'android-angle-try': 'angle_specific_no_trace_android_release_trybot_arm64', 'android_angle_rel_ng': 'gpu_tests_android_release_trybot_arm64', - 'android_angle_deqp_rel_ng': 'angle_deqp_android_release_trybot_arm64', 'fuchsia-angle-rel': 'gpu_fyi_tests_release_trybot_fuchsia', 'fuchsia-angle-try': 'angle_specific_release_trybot_fuchsia', 'ios-angle-try-intel': 'angle_specific_release_trybot_ios', 'linux-angle-rel': 'gpu_fyi_tests_release_trybot', 'linux-angle-chromium-try': 'gpu_tests_release_trybot', - 'linux_angle_deqp_rel_ng': 'angle_deqp_release_trybot', 'linux-angle-try': 'angle_specific_release_trybot', 'mac-angle-chromium-try': 'gpu_tests_release_trybot', 'win-angle-chromium-x64-try': 'gpu_tests_release_trybot', @@ -994,13 +989,11 @@ 'gpu-fyi-try-lacros-amd-rel': 'gpu_tests_ozone_linux_non_x11_release_trybot', 'gpu-fyi-try-lacros-intel-rel': 'gpu_tests_ozone_linux_non_x11_release_trybot', 'gpu-fyi-try-linux-amd-rel': 'gpu_fyi_tests_release_trybot', - 'gpu-fyi-try-linux-intel-dqp': 'angle_deqp_release_trybot', 'gpu-fyi-try-linux-intel-exp': 'gpu_fyi_tests_release_trybot', 'gpu-fyi-try-linux-intel-rel': 'gpu_fyi_tests_release_trybot', 'gpu-fyi-try-linux-intel-sk-dawn-rel': 'gpu_tests_sk_dawn_release_trybot', 'gpu-fyi-try-linux-intel-skv': 'gpu_fyi_tests_release_trybot', 'gpu-fyi-try-linux-nvidia-dbg': 'gpu_fyi_tests_debug_trybot', - 'gpu-fyi-try-linux-nvidia-dqp': 'angle_deqp_release_trybot', 'gpu-fyi-try-linux-nvidia-exp': 'gpu_fyi_tests_release_trybot', 'gpu-fyi-try-linux-nvidia-rel': 'gpu_fyi_tests_release_trybot', 'gpu-fyi-try-linux-nvidia-skv': 'gpu_fyi_tests_release_trybot', @@ -1608,10 +1601,6 @@ 'android_without_codecs', 'release_trybot', 'strip_debug_info', ], - 'angle_deqp_android_release_trybot_arm64': [ - 'angle_deqp_tests', 'android', 'shared_release_bot_dcheck_always_on', 'arm64', - ], - 'angle_deqp_release_trybot': [ 'angle_deqp_tests', 'shared_release_bot_dcheck_always_on', ],
diff --git a/tools/mb/mb_config_expectations/chromium.gpu.fyi.json b/tools/mb/mb_config_expectations/chromium.gpu.fyi.json index 94246c0..3747de1 100644 --- a/tools/mb/mb_config_expectations/chromium.gpu.fyi.json +++ b/tools/mb/mb_config_expectations/chromium.gpu.fyi.json
@@ -138,20 +138,6 @@ "use_static_angle": true } }, - "Android FYI dEQP Release (Nexus 5X)": { - "gn_args": { - "build_angle_deqp_tests": true, - "dcheck_always_on": true, - "ffmpeg_branding": "Chrome", - "is_component_build": true, - "is_debug": false, - "proprietary_codecs": true, - "symbol_level": 1, - "target_cpu": "arm64", - "target_os": "android", - "use_goma": true - } - }, "ChromeOS FYI Release (amd64-generic)": { "args_file": "//build/args/chromeos/amd64-generic-vm.gni", "gn_args": { @@ -228,16 +214,6 @@ "use_goma": true } }, - "GPU FYI Linux dEQP Builder": { - "gn_args": { - "build_angle_deqp_tests": true, - "dcheck_always_on": true, - "is_component_build": true, - "is_debug": false, - "symbol_level": 1, - "use_goma": true - } - }, "GPU FYI Mac Builder": { "gn_args": { "blink_enable_generated_code_formatting": false,
diff --git a/tools/mb/mb_config_expectations/tryserver.chromium.android.json b/tools/mb/mb_config_expectations/tryserver.chromium.android.json index 9b1c9a2..6bd500a8 100644 --- a/tools/mb/mb_config_expectations/tryserver.chromium.android.json +++ b/tools/mb/mb_config_expectations/tryserver.chromium.android.json
@@ -945,20 +945,6 @@ "use_static_angle": true } }, - "gpu-fyi-try-android-m-nexus-5x-deqp-64": { - "gn_args": { - "build_angle_deqp_tests": true, - "dcheck_always_on": true, - "ffmpeg_branding": "Chrome", - "is_component_build": true, - "is_debug": false, - "proprietary_codecs": true, - "symbol_level": 1, - "target_cpu": "arm64", - "target_os": "android", - "use_goma": true - } - }, "gpu-fyi-try-android-m-nexus-5x-skgl-64": { "gn_args": { "blink_enable_generated_code_formatting": false,
diff --git a/tools/mb/mb_config_expectations/tryserver.chromium.angle.json b/tools/mb/mb_config_expectations/tryserver.chromium.angle.json index 822ce2f..cbc155a 100644 --- a/tools/mb/mb_config_expectations/tryserver.chromium.angle.json +++ b/tools/mb/mb_config_expectations/tryserver.chromium.angle.json
@@ -28,20 +28,6 @@ "use_goma": true } }, - "android_angle_deqp_rel_ng": { - "gn_args": { - "build_angle_deqp_tests": true, - "dcheck_always_on": true, - "ffmpeg_branding": "Chrome", - "is_component_build": true, - "is_debug": false, - "proprietary_codecs": true, - "symbol_level": 1, - "target_cpu": "arm64", - "target_os": "android", - "use_goma": true - } - }, "android_angle_rel_ng": { "gn_args": { "blink_enable_generated_code_formatting": false, @@ -145,16 +131,6 @@ "use_goma": true } }, - "linux_angle_deqp_rel_ng": { - "gn_args": { - "build_angle_deqp_tests": true, - "dcheck_always_on": true, - "is_component_build": true, - "is_debug": false, - "symbol_level": 1, - "use_goma": true - } - }, "mac-angle-chromium-try": { "gn_args": { "blink_enable_generated_code_formatting": false,
diff --git a/tools/mb/mb_config_expectations/tryserver.chromium.linux.json b/tools/mb/mb_config_expectations/tryserver.chromium.linux.json index 916f9cb..5b2f64e 100644 --- a/tools/mb/mb_config_expectations/tryserver.chromium.linux.json +++ b/tools/mb/mb_config_expectations/tryserver.chromium.linux.json
@@ -245,16 +245,6 @@ "use_goma": true } }, - "gpu-fyi-try-linux-intel-dqp": { - "gn_args": { - "build_angle_deqp_tests": true, - "dcheck_always_on": true, - "is_component_build": true, - "is_debug": false, - "symbol_level": 1, - "use_goma": true - } - }, "gpu-fyi-try-linux-intel-exp": { "gn_args": { "blink_enable_generated_code_formatting": false, @@ -331,16 +321,6 @@ "use_goma": true } }, - "gpu-fyi-try-linux-nvidia-dqp": { - "gn_args": { - "build_angle_deqp_tests": true, - "dcheck_always_on": true, - "is_component_build": true, - "is_debug": false, - "symbol_level": 1, - "use_goma": true - } - }, "gpu-fyi-try-linux-nvidia-exp": { "gn_args": { "blink_enable_generated_code_formatting": false,
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 09ebcae..d85dfc56 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -6,18 +6,7 @@ <!-- - You - - 888 d8b 888 - 888 88P 888 - 888 8P 888 - .d88888 .d88b. 88888b. " 888888 - d88" 888 d88""88b 888 "88b 888 - 888 888 888 888 888 888 888 - Y88b 888 Y88..88P 888 888 Y88b. - "Y88888 "Y88P" 888 888 "Y888 - - need an OWNER review to submit changes to this file. + You DON'T need an OWNER review to submit changes to this file. This file describes the enumerations used in metrics data. It is used along with histograms.xml to describe the histogram data collected by Chrome. @@ -27127,7 +27116,6 @@ <int value="926" label="HistoryClustersVisible"/> <int value="927" label="ChromadToCloudMigrationEnabled"/> <int value="928" label="CopyPreventionSettings"/> - <int value="929" label="UserAgentReduction"/> </enum> <enum name="EnterprisePolicyDeviceIdValidity"> @@ -78376,6 +78364,7 @@ <int value="15" label="Invalid integrity header"/> <int value="16" label="Variant mismatch"/> <int value="17" label="Certificate's validity period is too long"/> + <int value="18" label="Had a cookie for cookieless only SXG"/> </enum> <enum name="SignedExchangeSignatureVerificationResult"> @@ -91275,7 +91264,6 @@ <int value="2052019697" label="chrome://userimage/"/> <int value="2114840772" label="chrome://drive-internals/"/> <int value="2120829362" label="chrome://account-manager-welcome/"/> - <int value="3251925547" label="chrome://offline-internals/"/> </enum> <enum name="WebURLRequestPriority">
diff --git a/tools/metrics/ukm/ukm.xml b/tools/metrics/ukm/ukm.xml index 0a00f38..f15a311 100644 --- a/tools/metrics/ukm/ukm.xml +++ b/tools/metrics/ukm/ukm.xml
@@ -12251,6 +12251,10 @@ </summary> </metric> <metric name="Experimental.TotalForegroundDuration"> + <obsolete> + Deprecated on November 2021, replaced by + PageTiming.TotalForegroundDuration. + </obsolete> <summary> The total amount of time the page spent in the foreground, in milliseconds. Note that this metric adds all foreground durations @@ -13283,6 +13287,20 @@ loads that failed in the foreground. </summary> </metric> + <metric name="PageTiming.TotalForegroundDuration"> + <summary> + The total amount of time the page spent in the foreground, in + milliseconds. Note that this metric adds all foreground durations + occurring for the page. For example: if the page starts foregrounded + during 1 second, then goes to the background for a while, then is + foregrounded again for 2 seconds, and then is unloaded, this metric + reports 3 seconds. To see metrics about consecutive foreground sessions, + see the PageForegroundSession event instead. This metric is recorded at + the end of each page load. As usual with PageLoad metrics, we consider app + backgrounding on Android to be the end of page load as well as the app + could be evicted by Android anytime after that happens. + </summary> + </metric> <metric name="PageTiming.UserTimingMarkFullyLoaded"> <summary> When the page UserTiming mark API is called with the standard @@ -18266,6 +18284,15 @@ Cache Restore (more metrics in the HistoryNavigation event), and AMP documents (more metrics in the AmpPageLoad event) </summary> + <metric name="NotCountedForCoreWebVitals" enum="Boolean"> + <summary> + Determines if this page visit event should be counted towards calculations + involving Core Web Vitals. If true, this page visit event should not be + counted. If false or NULL, the page visit event should be considered. + Currently this is determined by checking the mime-type of the page visit + event. + </summary> + </metric> <metric name="PageVisitFinalStatus" enum="PageVisitFinalStatus"> <summary> Determines the final status for this page visit. That is, records whether
diff --git a/tools/perf/core/perfetto_binary_roller/binary_deps.json b/tools/perf/core/perfetto_binary_roller/binary_deps.json index 8e41502..fd3e249 100644 --- a/tools/perf/core/perfetto_binary_roller/binary_deps.json +++ b/tools/perf/core/perfetto_binary_roller/binary_deps.json
@@ -6,11 +6,11 @@ }, "win": { "hash": "2abe2291e0e9b51e8750059797f1284422cb27d8", - "remote_path": "perfetto_binaries/trace_processor_shell/win/406e7c3674a735f3fc4b751a90d21fd3d74f9511/trace_processor_shell.exe" + "remote_path": "perfetto_binaries/trace_processor_shell/win/f32b6ac45880108dee6eaa9e585aa8c6217607cb/trace_processor_shell.exe" }, "mac": { "hash": "0dda5c90a9ea600e8c3dd1276671b55a07260c4d", - "remote_path": "perfetto_binaries/trace_processor_shell/mac/406e7c3674a735f3fc4b751a90d21fd3d74f9511/trace_processor_shell" + "remote_path": "perfetto_binaries/trace_processor_shell/mac/f32b6ac45880108dee6eaa9e585aa8c6217607cb/trace_processor_shell" }, "linux_arm64": { "hash": "5074025a2898ec41a872e70a5719e417acb0a380", @@ -18,7 +18,7 @@ }, "linux": { "hash": "4cdd2006b2e87bbf78fe37b58a3e09d6392977e1", - "remote_path": "perfetto_binaries/trace_processor_shell/linux/406e7c3674a735f3fc4b751a90d21fd3d74f9511/trace_processor_shell" + "remote_path": "perfetto_binaries/trace_processor_shell/linux/f32b6ac45880108dee6eaa9e585aa8c6217607cb/trace_processor_shell" } }, "power_profile.sql": {
diff --git a/tools/traffic_annotation/summary/annotations.xml b/tools/traffic_annotation/summary/annotations.xml index b086b9f..00c0490 100644 --- a/tools/traffic_annotation/summary/annotations.xml +++ b/tools/traffic_annotation/summary/annotations.xml
@@ -226,7 +226,7 @@ <item id="open_search" added_in_milestone="62" hash_code="107267424" type="0" content_hash_code="83025542" os_list="linux,windows,chromeos" file_path="components/search_engines/template_url_fetcher.cc"/> <item id="openscreen_message" added_in_milestone="83" hash_code="23036184" type="0" content_hash_code="124395439" os_list="linux,windows,chromeos" file_path="components/openscreen_platform/udp_socket.cc"/> <item id="openscreen_tls_message" added_in_milestone="83" hash_code="40127335" type="0" content_hash_code="15991338" os_list="linux,windows,chromeos" file_path="components/openscreen_platform/tls_connection_factory.cc"/> - <item id="optimization_guide_model" added_in_milestone="79" hash_code="106373593" type="0" content_hash_code="32403047" os_list="linux,windows" file_path="components/optimization_guide/core/prediction_model_fetcher_impl.cc"/> + <item id="optimization_guide_model" added_in_milestone="79" hash_code="106373593" type="0" content_hash_code="32403047" os_list="linux,windows,chromeos" file_path="components/optimization_guide/core/prediction_model_fetcher_impl.cc"/> <item id="optimization_guide_model_download" added_in_milestone="88" hash_code="100143055" type="0" content_hash_code="97983899" os_list="linux,windows,chromeos" file_path="chrome/browser/optimization_guide/prediction/prediction_model_download_manager.cc"/> <item id="origin_policy_loader" added_in_milestone="69" hash_code="6483617" type="0" content_hash_code="134028975" os_list="linux,windows,chromeos" file_path="services/network/origin_policy/origin_policy_fetcher.cc"/> <item id="parallel_download_job" added_in_milestone="62" hash_code="135118587" type="0" content_hash_code="105330419" os_list="linux,windows,chromeos" file_path="components/download/internal/common/parallel_download_job.cc"/>
diff --git a/ui/accessibility/platform/ax_platform_node_win.cc b/ui/accessibility/platform/ax_platform_node_win.cc index bc6efc5..943321b1 100644 --- a/ui/accessibility/platform/ax_platform_node_win.cc +++ b/ui/accessibility/platform/ax_platform_node_win.cc
@@ -8417,24 +8417,54 @@ case UIA_ProviderDescriptionPropertyId: case UIA_RuntimeIdPropertyId: break; - // These properties are indicative of a screenreader, we should enable full - // accessibility support. - case UIA_AriaRolePropertyId: + // These properties require the screenreader mode to get correct results case UIA_LabeledByPropertyId: case UIA_LiveSettingPropertyId: case UIA_LevelPropertyId: case UIA_DescribedByPropertyId: - probable_screen_reader_detected = true; - probable_advanced_client_detected = true; - break; + // This property currently requires the html mode to get correct results. + // see crbug.com/703277 case UIA_AutomationIdPropertyId: + // These properties are indicative of a screenreader. + case UIA_AriaRolePropertyId: + case UIA_ControlTypePropertyId: + case UIA_LocalizedControlTypePropertyId: + case UIA_NamePropertyId: + case UIA_AcceleratorKeyPropertyId: + case UIA_AccessKeyPropertyId: + case UIA_IsKeyboardFocusablePropertyId: + case UIA_ClassNamePropertyId: + case UIA_HelpTextPropertyId: + case UIA_ClickablePointPropertyId: + case UIA_CulturePropertyId: + case UIA_IsControlElementPropertyId: + case UIA_IsContentElementPropertyId: + case UIA_IsPasswordPropertyId: + case UIA_IsOffscreenPropertyId: + case UIA_OrientationPropertyId: + case UIA_IsRequiredForFormPropertyId: + case UIA_ItemStatusPropertyId: + case UIA_ExpandCollapseExpandCollapseStatePropertyId: + case UIA_SelectionItemIsSelectedPropertyId: + case UIA_ToggleToggleStatePropertyId: + case UIA_AriaPropertiesPropertyId: + case UIA_IsDataValidForFormPropertyId: + case UIA_ControllerForPropertyId: + case UIA_FlowsToPropertyId: + case UIA_OptimizeForVisualContentPropertyId: + case UIA_FlowsFromPropertyId: + case UIA_IsPeripheralPropertyId: + case UIA_PositionInSetPropertyId: + case UIA_SizeOfSetPropertyId: + case UIA_AnnotationObjectsPropertyId: + case UIA_LandmarkTypePropertyId: + case UIA_LocalizedLandmarkTypePropertyId: + case UIA_FullDescriptionPropertyId: + case UIA_IsDialogPropertyId: uiautomation_id_requested = true; probable_screen_reader_detected = true; probable_advanced_client_detected = true; break; - default: - // All other properties should cause us to enable. - probable_advanced_client_detected = true; } for (WinAccessibilityAPIUsageObserver& observer :
diff --git a/ui/base/ime/linux/fake_input_method_context.cc b/ui/base/ime/linux/fake_input_method_context.cc index a864a6e..2f8e3ea1 100644 --- a/ui/base/ime/linux/fake_input_method_context.cc +++ b/ui/base/ime/linux/fake_input_method_context.cc
@@ -35,4 +35,7 @@ const std::u16string& text, const gfx::Range& selection_range) {} +void FakeInputMethodContext::SetContentType(TextInputType input_type, + int input_flags) {} + } // namespace ui
diff --git a/ui/base/ime/linux/fake_input_method_context.h b/ui/base/ime/linux/fake_input_method_context.h index dc9f324..5b9ad9f 100644 --- a/ui/base/ime/linux/fake_input_method_context.h +++ b/ui/base/ime/linux/fake_input_method_context.h
@@ -28,6 +28,7 @@ void SetCursorLocation(const gfx::Rect& rect) override; void SetSurroundingText(const std::u16string& text, const gfx::Range& selection_range) override; + void SetContentType(TextInputType input_type, int input_flags) override; }; } // namespace ui
diff --git a/ui/base/ime/linux/input_method_auralinux.cc b/ui/base/ime/linux/input_method_auralinux.cc index 81769b2a4..bd09a8f5 100644 --- a/ui/base/ime/linux/input_method_auralinux.cc +++ b/ui/base/ime/linux/input_method_auralinux.cc
@@ -11,6 +11,7 @@ #include "ui/base/ime/constants.h" #include "ui/base/ime/linux/linux_input_method_context_factory.h" #include "ui/base/ime/text_input_client.h" +#include "ui/base/ime/text_input_flags.h" #include "ui/events/event.h" namespace { @@ -367,6 +368,14 @@ const TextInputClient* client) { UpdateContextFocusState(); InputMethodBase::OnTextInputTypeChanged(client); + + LinuxInputMethodContext* context = + text_input_type_ != TEXT_INPUT_TYPE_NONE && + text_input_type_ != TEXT_INPUT_TYPE_PASSWORD + ? context_.get() + : context_simple_.get(); + int flags = client ? client->GetTextInputFlags() : TEXT_INPUT_FLAG_NONE; + context->SetContentType(text_input_type_, flags); // TODO(yoichio): Support inputmode HTML attribute. }
diff --git a/ui/base/ime/linux/input_method_auralinux_unittest.cc b/ui/base/ime/linux/input_method_auralinux_unittest.cc index 8dd8c84..bf4770ce 100644 --- a/ui/base/ime/linux/input_method_auralinux_unittest.cc +++ b/ui/base/ime/linux/input_method_auralinux_unittest.cc
@@ -152,6 +152,8 @@ TestResult::GetInstance()->RecordAction(base::ASCIIToUTF16(re.str())); } + void SetContentType(TextInputType input_type, int input_flags) override {} + private: LinuxInputMethodContextDelegate* delegate_; std::vector<std::u16string> actions_;
diff --git a/ui/base/ime/linux/linux_input_method_context.h b/ui/base/ime/linux/linux_input_method_context.h index 3c11d7b..c179180 100644 --- a/ui/base/ime/linux/linux_input_method_context.h +++ b/ui/base/ime/linux/linux_input_method_context.h
@@ -44,6 +44,9 @@ virtual void SetSurroundingText(const std::u16string& text, const gfx::Range& selection_range) = 0; + // Tells the system IME the content type of the text input client is changed. + virtual void SetContentType(TextInputType input_type, int input_flags) = 0; + // Resets the context. A client needs to call OnTextInputTypeChanged() again // before calling DispatchKeyEvent(). virtual void Reset() = 0;
diff --git a/ui/chromeos/styles/cros_colors.json5 b/ui/chromeos/styles/cros_colors.json5 index 1b8909a..928911d 100644 --- a/ui/chromeos/styles/cros_colors.json5 +++ b/ui/chromeos/styles/cros_colors.json5
@@ -174,6 +174,7 @@ * Other foundational colors. */ focus_ring_color: "$color_prominent", + focus_ring_color_inactive: "$icon_color_secondary", focus_aura_color: "rgba($color_prominent_rgb, 0.24)", separator_color: { light: "rgba($black_rgb, 0.14)",
diff --git a/ui/display/manager/display_manager.cc b/ui/display/manager/display_manager.cc index 7ca5557..d1ad9497 100644 --- a/ui/display/manager/display_manager.cc +++ b/ui/display/manager/display_manager.cc
@@ -534,7 +534,7 @@ void DisplayManager::SetDisplayRotation(int64_t display_id, Display::Rotation rotation, Display::RotationSource source) { - if (IsInUnifiedMode()) + if (IsInUnifiedMode() && display_id == kUnifiedDisplayId) return; DisplayInfoList display_info_list; @@ -1816,6 +1816,19 @@ if (display_info_list->size() == 1) return; + for (auto& display_info : *display_info_list) { + auto it = display_info_.find(display_info.id()); + if (it != display_info_.end()) { + display_info.SetRotation( + it->second.GetRotation(Display::RotationSource::USER), + Display::RotationSource::USER); + display_info.SetRotation( + it->second.GetRotation(Display::RotationSource::ACTIVE), + Display::RotationSource::ACTIVE); + display_info.UpdateDisplaySize(); + } + } + if (!ValidateMatrix(current_unified_desktop_matrix_) || !ValidateMatrixForDisplayInfoList(*display_info_list, current_unified_desktop_matrix_)) { @@ -1842,7 +1855,6 @@ for (const auto& id : row) { const ManagedDisplayInfo* info = FindInfoById(*display_info_list, id); DCHECK(info); - max_height = std::max(max_height, info->size_in_pixel().height()); } rows_max_heights.emplace_back(max_height); @@ -2104,6 +2116,8 @@ display_info.size_in_pixel(), scale))); new_display.set_touch_support(display_info.touch_support()); new_display.set_maximum_cursor_size(display_info.maximum_cursor_size()); + new_display.set_rotation(display_info.GetActiveRotation()); + new_display.set_panel_rotation(display_info.GetLogicalActiveRotation()); return new_display; }
diff --git a/ui/display/manager/managed_display_info.cc b/ui/display/manager/managed_display_info.cc index c55054fb..cb655798 100644 --- a/ui/display/manager/managed_display_info.cc +++ b/ui/display/manager/managed_display_info.cc
@@ -255,6 +255,7 @@ id, base::StringPrintf("Display-%d", static_cast<int>(id)), has_overscan); display_info.set_device_scale_factor(device_scale_factor); display_info.SetRotation(rotation, Display::RotationSource::ACTIVE); + display_info.SetRotation(rotation, Display::RotationSource::USER); display_info.set_zoom_factor(zoom_factor); display_info.SetBounds(bounds_in_native);
diff --git a/ui/display/test/display_manager_test_api.cc b/ui/display/test/display_manager_test_api.cc index 5549bcd..f428a520 100644 --- a/ui/display/test/display_manager_test_api.cc +++ b/ui/display/test/display_manager_test_api.cc
@@ -121,6 +121,15 @@ bounds.set_y(next_y); next_y += bounds.height(); iter->SetBounds(bounds); + + // Overcan and native resolution are excluded for now as they require + // special handing (has_overscan flag. resolution change makes sense + // only on external). + display_manager_->RegisterDisplayProperty( + iter->id(), iter->GetRotation(Display::RotationSource::USER), + /*overscan_insets=*/nullptr, + /*native_resolution=*/gfx::Size(), iter->device_scale_factor(), + iter->zoom_factor(), iter->refresh_rate(), iter->is_interlaced()); } }
diff --git a/ui/file_manager/file_manager/common/js/api.js b/ui/file_manager/file_manager/common/js/api.js index 976da9c..80e2313 100644 --- a/ui/file_manager/file_manager/common/js/api.js +++ b/ui/file_manager/file_manager/common/js/api.js
@@ -50,3 +50,10 @@ return promisify( chrome.fileManagerPrivate.resolveIsolatedEntries, isolatedEntries); } + +/** + * @return {!Promise<!chrome.fileManagerPrivate.Preferences|undefined>} + */ +export async function getPreferences() { + return promisify(chrome.fileManagerPrivate.getPreferences); +}
diff --git a/ui/file_manager/file_manager/foreground/css/file_manager.css b/ui/file_manager/file_manager/foreground/css/file_manager.css index cbca9dbb..31545b3 100644 --- a/ui/file_manager/file_manager/foreground/css/file_manager.css +++ b/ui/file_manager/file_manager/foreground/css/file_manager.css
@@ -1831,8 +1831,8 @@ .thumbnail-item[lead]:not([selected]) { /* 2px border: 1px via box-shadow + 1px via border, to accommodate the difference between regular border 1px and selected border 2px.*/ - border-color: var(--cros-icon-color-secondary); - box-shadow: 0 0 0 1px var(--cros-icon-color-secondary); + border-color: var(--cros-focus-ring-color-inactive); + box-shadow: 0 0 0 1px var(--cros-focus-ring-color-inactive); } .thumbnail-grid > .spacer.folder-spacer { @@ -1927,7 +1927,7 @@ body.files-ng #list-container list > li[selected], body.files-ng #list-container list > li:active, body.files-ng #list-container list > li.accepts, -body.files-ng #list-container list:focus > li[lead] { +body.files-ng #list-container list > li[lead] { background-color: var(--cros-highlight-color-hover); border-radius: 2px; } @@ -1977,10 +1977,19 @@ border: 1px solid transparent; } -html.focus-outline-visible body.files-ng #list-container list:focus > li[lead] { +/* + * selector "li[lead]" is for the row just being operated on, + * e.g. with mouse: click/select/unselect + * with keyboard: Ctrl + ArrowUp/ArrowDown to move + */ +body.files-ng.check-select #list-container list:focus > li[lead] { border: 1px solid var(--cros-focus-ring-color); } +body.files-ng.check-select #list-container list > li[lead] { + border: 1px solid var(--cros-focus-ring-color-inactive); +} + #list-container.nohover grid > .accepts { background-color: transparent; } @@ -2618,7 +2627,7 @@ } body.files-ng #list-container li .detail-checkmark { - color: var(--cros-icon-color-primary); + color: var(--cros-icon-color-secondary); } body.files-ng #list-container li .detail-thumbnail {
diff --git a/ui/file_manager/file_manager/foreground/js/folder_shortcuts_data_model.js b/ui/file_manager/file_manager/foreground/js/folder_shortcuts_data_model.js index 226e5ef..908c12c 100644 --- a/ui/file_manager/file_manager/foreground/js/folder_shortcuts_data_model.js +++ b/ui/file_manager/file_manager/foreground/js/folder_shortcuts_data_model.js
@@ -4,6 +4,7 @@ import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js'; +import {getPreferences} from '../../common/js/api.js'; import {AsyncUtil} from '../../common/js/async_util.js'; import {FilteredVolumeManager} from '../../common/js/filtered_volume_manager.js'; import {metrics} from '../../common/js/metrics.js'; @@ -12,7 +13,7 @@ import {xfm} from '../../common/js/xfm.js'; /** - * The drive mount path used in the xfm.storage. It must be '/drive'. + * The drive mount path used in the persisted storage. It must be '/drive'. * @type {string} */ const STORED_DRIVE_MOUNT_PATH = '/drive'; @@ -20,7 +21,10 @@ /** * Model for the folder shortcuts. This object is ArrayDataModel-like * object with additional methods for the folder shortcut feature. - * This uses xfm.storage as backend. Items are always sorted by URL. + * This used to use xfm.storage as backend. Now it's migrated to Chrome + * preferences. + * + * Items are always sorted by URL. */ export class FolderShortcutsDataModel extends EventTarget { /** @@ -43,13 +47,9 @@ // Load the shortcuts. Runs within the queue. this.load_(); - // Listening for changes in the xfm.storage. - xfm.storage.onChanged.addListener((changes, namespace) => { - if (!(FolderShortcutsDataModel.NAME in changes) || namespace !== 'sync') { - return; - } - this.reload_(); // Runs within the queue. - }); + // The list of folder shortcuts is persisted in the preferences. + chrome.fileManagerPrivate.onPreferencesChanged.addListener( + this.reload_.bind(this)); // If the volume info list is changed, then shortcuts have to be reloaded. this.volumeManager_.volumeInfoList.addEventListener( @@ -141,8 +141,8 @@ } } // Not adding to the model nor to the |unresolvablePaths_| means - // that it will be removed from the xfm.storage permanently after the - // next call to save_(). + // that it will be removed from the persistent storage permanently after + // the next call to save_(). }; // Resolve the items all at once, in parallel. @@ -198,19 +198,12 @@ async load_() { this.queue_.run(async (callback) => { try { - const value = - await xfm.storage.sync.getAsync(FolderShortcutsDataModel.NAME); - if (value) { - const shortcutPaths = /** @type {!Array} */ ( - value[FolderShortcutsDataModel.NAME] || []); + const shortcutPaths = await this.getPersistedShortcutPaths_(); + // Record metrics. + metrics.recordSmallCount('FolderShortcut.Count', shortcutPaths.length); - // Record metrics. - metrics.recordSmallCount( - 'FolderShortcut.Count', shortcutPaths.length); - - // Resolve and add the entries to the model. - this.processEntries_(shortcutPaths); // Runs within a queue. - } + // Resolve and add the entries to the model. + this.processEntries_(shortcutPaths); // Runs within a queue. } finally { callback(); } @@ -218,17 +211,67 @@ } /** + * Fetches the shortcut paths from the legacy chrome.storage.sync. + * + * This can be removed after M108, when we expect all users to have migrated + * to the SWA/prefs version. + * + * @return {!Promise<!Array<string>>} + * @private + */ + async getPersistedShortcutPathsLegacy_() { + const value = + await xfm.storage.sync.getAsync(FolderShortcutsDataModel.NAME); + if (value) { + const shortcutPaths = + /** @type {!Array} */ (value[FolderShortcutsDataModel.NAME] || []); + return shortcutPaths; + } + + return []; + } + + /** + * Fetches the shortcut paths from the persistent storage (preferences) it + * migrates from the legacy storage.chrome.sync if needed. + * + * @return {!Promise<!Array<string>>} + * @private + */ + async getPersistedShortcutPaths_() { + if (!window.isSWA) { + // Migration code works for non SWA. + const legacyPaths = await this.getPersistedShortcutPathsLegacy_(); + if (legacyPaths.length) { + // Migrate to prefs. The onPreferencesChanged listener will make the + // value to be reloaded from prefs. + chrome.fileManagerPrivate.setPreferences( + {folderShortcuts: legacyPaths}); + + // Remove from legacy storage: xfm.storage.sync. + const prefs = {}; + prefs[FolderShortcutsDataModel.NAME] = []; + xfm.storage.sync.setAsync(prefs); + return legacyPaths; + } + } + + const prefs = await getPreferences(); + if (prefs.folderShortcuts && prefs.folderShortcuts.length) { + return prefs.folderShortcuts; + } + + return []; + } + + /** * Reloads the model and loads the shortcuts. * @private */ reload_() { - let shortcutPaths; this.queue_.run(async (callback) => { try { - const value = - await xfm.storage.sync.getAsync(FolderShortcutsDataModel.NAME); - const shortcutPaths = - /** @type {!Array} */ (value[FolderShortcutsDataModel.NAME] || []); + const shortcutPaths = await this.getPersistedShortcutPaths_(); this.processEntries_(shortcutPaths); // Runs within a queue. } finally { callback(); @@ -405,7 +448,7 @@ } /** - * Saves the current array to xfm.storage. + * Saves the current array to the persistent storage (Chrome prefs). * @private */ save_() { @@ -423,9 +466,8 @@ .concat(Object.keys(this.pendingPaths_)) .concat(Object.keys(this.unresolvablePaths_)); - const prefs = {}; - prefs[FolderShortcutsDataModel.NAME] = paths; - xfm.storage.sync.setAsync(prefs); + const prefs = {folderShortcuts: paths}; + chrome.fileManagerPrivate.setPreferences(prefs); } /**
diff --git a/ui/gtk/input_method_context_impl_gtk.cc b/ui/gtk/input_method_context_impl_gtk.cc index b935925..42ddcfb9 100644 --- a/ui/gtk/input_method_context_impl_gtk.cc +++ b/ui/gtk/input_method_context_impl_gtk.cc
@@ -251,4 +251,9 @@ gdk_last_set_client_window_ = window; } +void InputMethodContextImplGtk::SetContentType(ui::TextInputType input_type, + int input_flags) { + // Do nothing. +} + } // namespace gtk
diff --git a/ui/gtk/input_method_context_impl_gtk.h b/ui/gtk/input_method_context_impl_gtk.h index b220a6f7..9258f4d3 100644 --- a/ui/gtk/input_method_context_impl_gtk.h +++ b/ui/gtk/input_method_context_impl_gtk.h
@@ -39,6 +39,7 @@ void Blur() override; void SetSurroundingText(const std::u16string& text, const gfx::Range& selection_range) override; + void SetContentType(ui::TextInputType input_type, int input_flags) override; private: // GtkIMContext event handlers. They are shared among |gtk_context_simple_|
diff --git a/ui/message_center/views/notification_view_base.cc b/ui/message_center/views/notification_view_base.cc index 494dfaa5..e0489cf 100644 --- a/ui/message_center/views/notification_view_base.cc +++ b/ui/message_center/views/notification_view_base.cc
@@ -56,7 +56,6 @@ #include "ui/views/focus/focus_manager.h" #include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout_view.h" -#include "ui/views/layout/fill_layout.h" #include "ui/views/native_cursor.h" #include "ui/views/style/typography.h" #include "ui/views/widget/widget.h" @@ -497,11 +496,12 @@ .SetBorder(views::CreateEmptyBorder(kLargeImageContainerPadding)); } -std::unique_ptr<views::View> NotificationViewBase::CreateActionsRow() { +std::unique_ptr<views::View> NotificationViewBase::CreateActionsRow( + std::unique_ptr<views::LayoutManager> layout_manager) { DCHECK(!actions_row_); auto actions_row = std::make_unique<views::View>(); actions_row->SetVisible(false); - actions_row->SetLayoutManager(std::make_unique<views::FillLayout>()); + actions_row->SetLayoutManager(std::move(layout_manager)); // |action_buttons_row_| contains inline action buttons. DCHECK(!action_buttons_row_);
diff --git a/ui/message_center/views/notification_view_base.h b/ui/message_center/views/notification_view_base.h index 4bb0aa9..0115330 100644 --- a/ui/message_center/views/notification_view_base.h +++ b/ui/message_center/views/notification_view_base.h
@@ -20,11 +20,13 @@ #include "ui/views/animation/ink_drop_observer.h" #include "ui/views/controls/button/button.h" #include "ui/views/layout/box_layout_view.h" +#include "ui/views/layout/fill_layout.h" namespace views { class BoxLayoutView; class Label; class LabelButton; +class LayoutManager; class ProgressBar; } // namespace views @@ -165,8 +167,11 @@ // Inline settings view contains inline settings. views::Builder<views::BoxLayoutView> CreateInlineSettingsBuilder(); - // Actions row contains inline action buttons and inline textfield. - std::unique_ptr<views::View> CreateActionsRow(); + // Actions row contains inline action buttons and inline textfield. Use the + // given layout manager for the actions row. + std::unique_ptr<views::View> CreateActionsRow( + std::unique_ptr<views::LayoutManager> layout_manager = + std::make_unique<views::FillLayout>()); // Generate a view to show notification title and other supporting views. static std::unique_ptr<views::Label> GenerateTitleView(
diff --git a/ui/ozone/platform/wayland/host/wayland_input_method_context.cc b/ui/ozone/platform/wayland/host/wayland_input_method_context.cc index efe811af..006cb7e 100644 --- a/ui/ozone/platform/wayland/host/wayland_input_method_context.cc +++ b/ui/ozone/platform/wayland/host/wayland_input_method_context.cc
@@ -18,6 +18,8 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/ime/composition_text.h" #include "ui/base/ime/ime_text_span.h" +#include "ui/base/ime/text_input_flags.h" +#include "ui/base/ime/text_input_type.h" #include "ui/events/base_event_utils.h" #include "ui/events/event.h" #include "ui/events/event_utils.h" @@ -119,6 +121,71 @@ return absl::nullopt; } +// Converts Chrome's TextInputType into wayland's content_purpose. +// Some of TextInputType values do not have clearly corresponding wayland value, +// and they fallback to closer type. +uint32_t InputTypeToContentPurpose(TextInputType input_type) { + switch (input_type) { + case TEXT_INPUT_TYPE_NONE: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_NORMAL; + case TEXT_INPUT_TYPE_TEXT: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_NORMAL; + case TEXT_INPUT_TYPE_PASSWORD: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_PASSWORD; + case TEXT_INPUT_TYPE_SEARCH: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_NORMAL; + case TEXT_INPUT_TYPE_EMAIL: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_EMAIL; + case TEXT_INPUT_TYPE_NUMBER: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_NUMBER; + case TEXT_INPUT_TYPE_TELEPHONE: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_PHONE; + case TEXT_INPUT_TYPE_URL: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_URL; + case TEXT_INPUT_TYPE_DATE: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_DATE; + case TEXT_INPUT_TYPE_DATE_TIME: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_DATETIME; + case TEXT_INPUT_TYPE_DATE_TIME_LOCAL: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_DATETIME; + case TEXT_INPUT_TYPE_MONTH: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_DATE; + case TEXT_INPUT_TYPE_TIME: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_TIME; + case TEXT_INPUT_TYPE_WEEK: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_DATE; + case TEXT_INPUT_TYPE_TEXT_AREA: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_NORMAL; + case TEXT_INPUT_TYPE_CONTENT_EDITABLE: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_NORMAL; + case TEXT_INPUT_TYPE_DATE_TIME_FIELD: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_DATETIME; + case TEXT_INPUT_TYPE_NULL: + return ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_NORMAL; + } +} + +// Converts Chrome's TextInputType into wayland's content_hint. +uint32_t InputFlagsToContentHint(int input_flags) { + uint32_t hint = 0; + if (input_flags & TEXT_INPUT_FLAG_AUTOCOMPLETE_ON) + hint |= ZWP_TEXT_INPUT_V1_CONTENT_HINT_AUTO_COMPLETION; + if (input_flags & TEXT_INPUT_FLAG_AUTOCORRECT_ON) + hint |= ZWP_TEXT_INPUT_V1_CONTENT_HINT_AUTO_CORRECTION; + // No good match. Fallback to AUTO_CORRECTION. + if (input_flags & TEXT_INPUT_FLAG_SPELLCHECK_ON) + hint |= ZWP_TEXT_INPUT_V1_CONTENT_HINT_AUTO_CORRECTION; + if (input_flags & TEXT_INPUT_FLAG_AUTOCAPITALIZE_CHARACTERS) + hint |= ZWP_TEXT_INPUT_V1_CONTENT_HINT_UPPERCASE; + if (input_flags & TEXT_INPUT_FLAG_AUTOCAPITALIZE_WORDS) + hint |= ZWP_TEXT_INPUT_V1_CONTENT_HINT_TITLECASE; + if (input_flags & TEXT_INPUT_FLAG_AUTOCAPITALIZE_SENTENCES) + hint |= ZWP_TEXT_INPUT_V1_CONTENT_HINT_AUTO_CAPITALIZATION; + if (input_flags & TEXT_INPUT_FLAG_HAS_BEEN_PASSWORD) + hint |= ZWP_TEXT_INPUT_V1_CONTENT_HINT_PASSWORD; + return hint; +} + } // namespace WaylandInputMethodContext::WaylandInputMethodContext( @@ -319,6 +386,16 @@ text_input_->SetSurroundingText(truncated_text, relocated_selection_range); } +void WaylandInputMethodContext::SetContentType(TextInputType input_type, + int input_flags) { + if (!text_input_) + return; + + uint32_t content_purpose = InputTypeToContentPurpose(input_type); + uint32_t content_hint = InputFlagsToContentHint(input_flags); + text_input_->SetContentType(content_hint, content_purpose); +} + void WaylandInputMethodContext::OnPreeditString( base::StringPiece text, const std::vector<SpanStyle>& spans,
diff --git a/ui/ozone/platform/wayland/host/wayland_input_method_context.h b/ui/ozone/platform/wayland/host/wayland_input_method_context.h index 640376b..a08c721 100644 --- a/ui/ozone/platform/wayland/host/wayland_input_method_context.h +++ b/ui/ozone/platform/wayland/host/wayland_input_method_context.h
@@ -46,6 +46,7 @@ void SetCursorLocation(const gfx::Rect& rect) override; void SetSurroundingText(const std::u16string& text, const gfx::Range& selection_range) override; + void SetContentType(TextInputType input_type, int input_flags) override; void Reset() override; void Focus() override; void Blur() override;
diff --git a/ui/ozone/platform/wayland/host/wayland_input_method_context_unittest.cc b/ui/ozone/platform/wayland/host/wayland_input_method_context_unittest.cc index 246c5025..b4ea885 100644 --- a/ui/ozone/platform/wayland/host/wayland_input_method_context_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_input_method_context_unittest.cc
@@ -12,6 +12,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/ime/linux/linux_input_method_context.h" +#include "ui/base/ime/text_input_flags.h" +#include "ui/base/ime/text_input_type.h" #include "ui/events/event.h" #include "ui/gfx/range/range.h" #include "ui/ozone/platform/wayland/host/wayland_input_method_context.h" @@ -369,6 +371,17 @@ (std::pair<size_t, size_t>(1, 1))); } +TEST_P(WaylandInputMethodContextTest, SetContentType) { + EXPECT_CALL(*zwp_text_input_, + SetContentType(ZWP_TEXT_INPUT_V1_CONTENT_HINT_AUTO_COMPLETION, + ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_URL)) + .Times(1); + input_method_context_->SetContentType(TEXT_INPUT_TYPE_URL, + TEXT_INPUT_FLAG_AUTOCOMPLETE_ON); + connection_->ScheduleFlush(); + Sync(); +} + TEST_P(WaylandInputMethodContextTest, OnPreeditChanged) { zwp_text_input_v1_send_preedit_string(zwp_text_input_->resource(), 0, "PreeditString", "");
diff --git a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper.h b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper.h index 24a5f6a..2b7c438 100644 --- a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper.h +++ b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper.h
@@ -86,6 +86,8 @@ virtual void SetCursorRect(const gfx::Rect& rect) = 0; virtual void SetSurroundingText(const std::string& text, const gfx::Range& selection_range) = 0; + virtual void SetContentType(uint32_t content_hint, + uint32_t content_purpose) = 0; }; } // namespace ui
diff --git a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.cc b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.cc index a745a73..e45a77bd 100644 --- a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.cc +++ b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.cc
@@ -94,6 +94,11 @@ obj_.get(), text.c_str(), selection_range.start(), selection_range.end()); } +void ZWPTextInputWrapperV1::SetContentType(uint32_t content_hint, + uint32_t content_purpose) { + zwp_text_input_v1_set_content_type(obj_.get(), content_hint, content_purpose); +} + void ZWPTextInputWrapperV1::ResetInputEventState() { spans_.clear(); preedit_cursor_ = -1;
diff --git a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.h b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.h index 588854e..c1440d4 100644 --- a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.h +++ b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.h
@@ -46,6 +46,7 @@ void SetCursorRect(const gfx::Rect& rect) override; void SetSurroundingText(const std::string& text, const gfx::Range& selection_range) override; + void SetContentType(uint32_t content_hint, uint32_t content_purpose) override; private: void ResetInputEventState();
diff --git a/ui/ozone/platform/wayland/test/mock_zwp_text_input.cc b/ui/ozone/platform/wayland/test/mock_zwp_text_input.cc index 9a74d362..3dd020fa 100644 --- a/ui/ozone/platform/wayland/test/mock_zwp_text_input.cc +++ b/ui/ozone/platform/wayland/test/mock_zwp_text_input.cc
@@ -42,6 +42,14 @@ text, gfx::Range(cursor, anchor)); } +void TextInputV1SetContentType(wl_client* client, + wl_resource* resource, + uint32_t content_hint, + uint32_t content_purpose) { + GetUserDataAs<MockZwpTextInput>(resource)->SetContentType(content_hint, + content_purpose); +} + void TextInputV1SetCursorRectangle(wl_client* client, wl_resource* resource, int32_t x, @@ -60,7 +68,7 @@ &TextInputV1HideInputPanel, // hide_input_panel &TextInputV1Reset, // reset &TextInputV1SetSurroundingText, // set_surrounding_text - nullptr, // set_content_type + &TextInputV1SetContentType, // set_content_type &TextInputV1SetCursorRectangle, // set_cursor_rectangle nullptr, // set_preferred_language nullptr, // commit_state
diff --git a/ui/ozone/platform/wayland/test/mock_zwp_text_input.h b/ui/ozone/platform/wayland/test/mock_zwp_text_input.h index 1ad34bd..4ee5c5c 100644 --- a/ui/ozone/platform/wayland/test/mock_zwp_text_input.h +++ b/ui/ozone/platform/wayland/test/mock_zwp_text_input.h
@@ -36,6 +36,8 @@ void(int32_t x, int32_t y, int32_t width, int32_t height)); MOCK_METHOD2(SetSurroundingText, void(std::string text, gfx::Range selection_range)); + MOCK_METHOD2(SetContentType, + void(uint32_t content_hint, uint32_t content_purpose)); }; } // namespace wl