diff --git a/DEPS b/DEPS index 80b86f85..1d480671 100644 --- a/DEPS +++ b/DEPS
@@ -304,15 +304,15 @@ # 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': 'f7064a1861e13b87cdfaafb11410c7e68c1f440d', + 'skia_revision': 'cf02fc1a0184d993a22a99c147dcb9fa5287a475', # 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': '27bc33ed3812654d8efaa1e640955adf6afd6632', + 'v8_revision': '2b2cdf9c9f88fd97b92a1775c6093b27a0d90440', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. - 'angle_revision': '1ee27fcdbfe6ad6138907783cd43b83d6720f390', + 'angle_revision': 'fc7cb00e99475c0093cde8d39efe9b811d1f5889', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling SwiftShader # and whatever else without interference from each other. @@ -320,7 +320,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling PDFium # and whatever else without interference from each other. - 'pdfium_revision': 'aae3f4452ac46d64c705a1a117503d59000ebf5e', + 'pdfium_revision': '1233727e1f81bca977ee92d4c6284e2828f76a1e', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling BoringSSL # and whatever else without interference from each other. @@ -331,7 +331,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Fuchsia sdk # and whatever else without interference from each other. - 'fuchsia_version': 'version:12.20230327.2.1', + 'fuchsia_version': 'version:12.20230328.1.1', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling google-toolbox-for-mac # and whatever else without interference from each other. @@ -391,7 +391,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling devtools-frontend # and whatever else without interference from each other. - 'devtools_frontend_revision': '9ba6ed7f9e83373c5395aa30c66dd6c81f0efec0', + 'devtools_frontend_revision': 'e4be04fa264a0bd5d4e6e23fe220cfc0cf49d5b4', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libprotobuf-mutator # and whatever else without interference from each other. @@ -431,11 +431,11 @@ # 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': 'df714941d3a24b7d7a6e7e2a5475c8e8a76a81f8', + 'dawn_revision': '8e414572be8c970db605f8fb04bae214c819d52e', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'quiche_revision': 'e7c0769c8904bf60a5295c218c12f2af6a5cb55d', + 'quiche_revision': 'b3fe8cfa820d3ea5404e166d7b00bd90f18c7c77', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ios_webkit # and whatever else without interference from each other. @@ -467,7 +467,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. - 'cros_components_revision': 'e8f7d0cc3350e2554e86edd7bebc6313f018e25c', + 'cros_components_revision': 'c1cc4ae57ac3688608297f44c97d8b0afdf7f791', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -794,7 +794,7 @@ 'src/clank': { 'url': Var('chrome_git') + '/clank/internal/apps.git' + '@' + - 'cf8ffc879eb73497b886ddfe4e901c274b96c435', + '34c4b57a88080ed902fef4f6759d049a12a2589b', 'condition': 'checkout_android and checkout_src_internal', }, @@ -983,7 +983,7 @@ 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'zd34H0ZKUoP4415kneK7fwSS-MzZu0_hYScGJWzsVgkC', + 'version': 'IwQ7KNjxWpqRI6oAx44UGTHRiAfJbRilFmFy26FOm0AC', }, ], 'condition': 'checkout_android', @@ -1109,7 +1109,7 @@ }, { 'package': 'chromium/third_party/android_sdk/public/cmdline-tools', - 'version': '3Yn5Sn7BMObm8gsoZCF0loJMKg9_PpgU07G9DObCLdQC', + 'version': 'EWnL2r7oV5GtE9Ef7GyohyFam42wtMtEKYU4dCb3U1YC', }, ], 'condition': 'checkout_android_native_support', @@ -1240,7 +1240,7 @@ Var('chromium_git') + '/devtools/devtools-frontend' + '@' + Var('devtools_frontend_revision'), 'src/third_party/devtools-frontend-internal': { - 'url': Var('chrome_git') + '/devtools/devtools-internal.git' + '@' + '261f701a7f57b23ea170314c1925d3743858b496', + 'url': Var('chrome_git') + '/devtools/devtools-internal.git' + '@' + '1ecdbc9a9aeac20ea258fe077dc81318b8a1e6d7', 'condition': 'checkout_src_internal', }, @@ -1706,7 +1706,7 @@ }, 'src/third_party/perfetto': - Var('android_git') + '/platform/external/perfetto.git' + '@' + 'e904de5554bd8af597344c98aefd940a6a7d00fb', + Var('android_git') + '/platform/external/perfetto.git' + '@' + '02d6c7406b5174d707a8021fe88e6591adc143fe', 'src/third_party/perl': { 'url': Var('chromium_git') + '/chromium/deps/perl.git' + '@' + '6f3e5028eb65d0b4c5fdd792106ac4c84eee1eb3', @@ -1851,7 +1851,7 @@ 'dep_type': 'cipd', }, - 'src/third_party/vulkan-deps': '{chromium_git}/vulkan-deps@2f3f68dfda8b45bb661cf28637c09509917c7a4d', + 'src/third_party/vulkan-deps': '{chromium_git}/vulkan-deps@dd38395da61015e0d6b4e29c1c333a74781adcc4', 'src/third_party/vulkan_memory_allocator': Var('chromium_git') + '/external/github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git' + '@' + 'ebe84bec02c041d28f902da0214bf442743fc907', @@ -1888,10 +1888,10 @@ Var('chromium_git') + '/external/khronosgroup/webgl.git' + '@' + 'd1b65aa5a88f6efd900604dfcda840154e9f16e2', 'src/third_party/webgpu-cts/src': - Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + '7e014d4d99cdacd0c08a711d379fcb7886ed66d2', + Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + 'fd777c3d00dce755d04cbe5da9a407a2f06ff008', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + 'ef5cd7d336ffa0b388a5b2140ef7a6ec31b69b75', + Var('webrtc_git') + '/src.git' + '@' + 'd32e5b3078ebc105ba7a3644298f567ae339e187', # Wuffs' canonical repository is at github.com/google/wuffs, but we use # Skia's mirror of Wuffs, the same as in upstream Skia's DEPS file. @@ -1925,7 +1925,7 @@ 'packages': [ { 'package': 'skia/tools/goldctl/linux-amd64', - 'version': 'HkmOI1AX5KQdM4e3VR1v5kN_kJWirqdbUeY0lEj93FcC', + 'version': 'CHIKK9YvBNPOM_lAlqkfs4dTTbM6I-AKggA94sfc5PoC', }, ], 'dep_type': 'cipd', @@ -1935,7 +1935,7 @@ 'packages': [ { 'package': 'skia/tools/goldctl/windows-amd64', - 'version': 'pUOVquC14y84RkNMzEAPw_7tztey-kvH7KBwGsFViuIC', + 'version': 'aW-NZ8C8eVMaPmBAILqVE-mOxYdoUXfiDHShsTeZMwkC', }, ], 'dep_type': 'cipd', @@ -1946,7 +1946,7 @@ 'packages': [ { 'package': 'skia/tools/goldctl/mac-amd64', - 'version': 'enC5EfEkxcrBLcpjtbBzQmOsnYRzN43BtNoPNzoyjekC', + 'version': 'Gwb7laBBhkBhwP1nIoAb1EwklQ5sEon7g7r76v7jAasC', }, ], 'dep_type': 'cipd', @@ -1957,7 +1957,7 @@ 'packages': [ { 'package': 'skia/tools/goldctl/mac-arm64', - 'version': 'Jh19SHnigVXYxpk7Fp4ZDMF_ZvLpQUie2NMaK5aEISMC', + 'version': '432GgeQWQIAz1NADw1ssxRVYDIKzNs1i3tKIITtxDdcC', }, ], 'dep_type': 'cipd', @@ -1968,7 +1968,7 @@ Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': Var('chrome_git') + '/chrome/src-internal.git@8f94ab55bf24a2399e85050aaaa74f172632d0cf', + 'url': Var('chrome_git') + '/chrome/src-internal.git@508d8c48a509774fd7081a465c35434b901c2ad0', 'condition': 'checkout_src_internal', }, @@ -2031,7 +2031,7 @@ 'packages': [ { 'package': 'chromeos_internal/apps/projector_app/app', - 'version': 'iur9WcgDC2QZq2awVp1NybKu9W449sGwfG332Bz2ER8C', + 'version': 'Yq_L5c9of72GZrYljasRcp4Fo7EyYYkKLnbktHFNRkMC', }, ], 'condition': 'checkout_chromeos and checkout_src_internal',
diff --git a/ash/app_list/test_app_list_client.cc b/ash/app_list/test_app_list_client.cc index 043887f..f59150e 100644 --- a/ash/app_list/test_app_list_client.cc +++ b/ash/app_list/test_app_list_client.cc
@@ -9,6 +9,7 @@ #include "ash/app_list/app_list_model_provider.h" #include "ash/app_list/model/app_list_item.h" #include "ash/public/cpp/app_list/app_list_controller.h" +#include "ash/public/cpp/app_list/app_list_types.h" #include "base/functional/bind.h" #include "base/task/sequenced_task_runner.h" #include "base/time/time.h" @@ -87,7 +88,7 @@ std::unique_ptr<ScopedIphSession> TestAppListClient::CreateLauncherSearchIphSession() { - return nullptr; + return std::make_unique<ScopedIphSession>(); } std::vector<TestAppListClient::SearchResultActionId>
diff --git a/ash/app_list/views/app_list_view_pixeltest.cc b/ash/app_list/views/app_list_view_pixeltest.cc index bc3474b..dda73129 100644 --- a/ash/app_list/views/app_list_view_pixeltest.cc +++ b/ash/app_list/views/app_list_view_pixeltest.cc
@@ -17,6 +17,8 @@ #include "ash/test/pixel/ash_pixel_differ.h" #include "ash/test/pixel/ash_pixel_test_init_params.h" #include "ash/wm/tablet_mode/tablet_mode_controller.h" +#include "base/run_loop.h" +#include "testing/gtest/include/gtest/gtest.h" #include "ui/events/types/event_type.h" #include "ui/views/controls/scroll_view.h" #include "ui/views/controls/textfield/textfield_test_api.h" @@ -184,6 +186,41 @@ GetPrimaryShelf()->navigation_widget())); } +class AppListViewLauncherSearchIphTest + : public AshTestBase, + public testing::WithParamInterface</*rtl=*/bool> { + public: + absl::optional<pixel_test::InitParams> CreatePixelTestInitParams() + const override { + pixel_test::InitParams init_params; + init_params.under_rtl = GetParam(); + return init_params; + } + + void SetUp() override { + AshTestBase::SetUp(); + + AppListTestHelper* test_helper = GetAppListTestHelper(); + test_helper->ShowAppList(); + GetAppListTestHelper()->search_model()->SetWouldTriggerLauncherSearchIph( + true); + GetAppListTestHelper()->GetSearchBoxView()->SetIsIphAllowed(true); + } +}; + +INSTANTIATE_TEST_SUITE_P(RTL, + AppListViewLauncherSearchIphTest, + testing::Bool()); + +TEST_P(AppListViewLauncherSearchIphTest, Basic) { + // Wait re-layout for adding IPH view. + base::RunLoop().RunUntilIdle(); + + EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen( + "launcher_search_iph", /*revision_number=*/0, + GetAppListTestHelper()->GetSearchBoxView())); +} + class AppListViewTabletPixelTest : public AshTestBase, public testing::WithParamInterface</*tablet_mode=*/bool> {
diff --git a/ash/app_list/views/launcher_search_iph_view.cc b/ash/app_list/views/launcher_search_iph_view.cc index 2dafe00..173ad97 100644 --- a/ash/app_list/views/launcher_search_iph_view.cc +++ b/ash/app_list/views/launcher_search_iph_view.cc
@@ -5,13 +5,18 @@ #include "ash/app_list/views/launcher_search_iph_view.h" #include <memory> +#include <string> #include <utility> #include "ash/public/cpp/app_list/app_list_client.h" +#include "ash/style/pill_button.h" +#include "base/functional/bind.h" #include "ui/gfx/font_list.h" #include "ui/gfx/text_constants.h" +#include "ui/views/controls/button/button.h" #include "ui/views/controls/label.h" #include "ui/views/layout/box_layout.h" +#include "ui/views/layout/box_layout_view.h" namespace ash { namespace { @@ -21,35 +26,97 @@ constexpr int kTitleTextFontSize = 20; constexpr int kDescriptionTextFontSize = 16; +constexpr int kMainLayoutBetweenChildSpacing = 16; +constexpr int kActionContainerBetweenChildSpacing = 8; + constexpr char16_t kTitleTextPlaceholder[] = u"Title text"; constexpr char16_t kDescriptionTextPlaceholder[] = u"Description text"; + +constexpr char16_t kChipOneQueryPlaceholder[] = u"Weather"; +constexpr char16_t kChipTwoQueryPlaceholder[] = u"1+1"; +constexpr char16_t kChipThreeQueryPlaceholder[] = u"5 cm in inches"; + +constexpr char16_t kAssistantButtonPlaceholder[] = u"Assistant"; } // namespace LauncherSearchIphView::LauncherSearchIphView( - std::unique_ptr<ScopedIphSession> scoped_iph_session) - : scoped_iph_session_(std::move(scoped_iph_session)) { - SetID(kViewId); + std::unique_ptr<ScopedIphSession> scoped_iph_session, + raw_ptr<Delegate> delegate) + : scoped_iph_session_(std::move(scoped_iph_session)), delegate_(delegate) { + SetID(ViewId::kSelf); - SetLayoutManager(std::make_unique<views::BoxLayout>( - views::BoxLayout::Orientation::kVertical, - gfx::Insets::VH(kVerticalInset, kHorizontalInset))); + raw_ptr<views::BoxLayout> box_layout = + SetLayoutManager(std::make_unique<views::BoxLayout>( + views::BoxLayout::Orientation::kVertical, + gfx::Insets::VH(kVerticalInset, kHorizontalInset))); + box_layout->set_between_child_spacing(kMainLayoutBetweenChildSpacing); + // Use `kStretch` for `actions_container` to get stretched. + box_layout->set_cross_axis_alignment( + views::BoxLayout::CrossAxisAlignment::kStretch); - raw_ptr<views::Label> title_label = - AddChildView(std::make_unique<views::Label>(kTitleTextPlaceholder)); + // Add texts into a container to avoid stretching `views::Label`s. + raw_ptr<views::BoxLayoutView> text_container = + AddChildView(std::make_unique<views::BoxLayoutView>()); + text_container->SetOrientation(views::BoxLayout::Orientation::kVertical); + text_container->SetCrossAxisAlignment( + views::BoxLayout::CrossAxisAlignment::kStart); + text_container->SetBetweenChildSpacing(kMainLayoutBetweenChildSpacing); + + raw_ptr<views::Label> title_label = text_container->AddChildView( + std::make_unique<views::Label>(kTitleTextPlaceholder)); title_label->SetFontList(gfx::FontList().DeriveWithSizeDelta( kTitleTextFontSize - gfx::FontList().GetFontSize())); title_label->SetLineHeight(kTitleTextFontSize); title_label->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_TO_HEAD); - raw_ptr<views::Label> description_label = - AddChildView(std::make_unique<views::Label>(kDescriptionTextPlaceholder)); + raw_ptr<views::Label> description_label = text_container->AddChildView( + std::make_unique<views::Label>(kDescriptionTextPlaceholder)); description_label->SetFontList(gfx::FontList().DeriveWithSizeDelta( kDescriptionTextFontSize - gfx::FontList().GetFontSize())); description_label->SetLineHeight(kDescriptionTextFontSize); description_label->SetHorizontalAlignment( gfx::HorizontalAlignment::ALIGN_TO_HEAD); + + raw_ptr<views::BoxLayoutView> actions_container = + AddChildView(std::make_unique<views::BoxLayoutView>()); + actions_container->SetOrientation(views::BoxLayout::Orientation::kHorizontal); + actions_container->SetBetweenChildSpacing( + kActionContainerBetweenChildSpacing); + + int query_chip_view_id = ViewId::kChipStart; + for (const std::u16string& query : + {kChipOneQueryPlaceholder, kChipTwoQueryPlaceholder, + kChipThreeQueryPlaceholder}) { + raw_ptr<ash::PillButton> chip = + actions_container->AddChildView(std::make_unique<ash::PillButton>( + base::BindRepeating(&LauncherSearchIphView::RunLauncherSearchQuery, + weak_ptr_factory_.GetWeakPtr(), query), + query)); + chip->SetID(query_chip_view_id); + query_chip_view_id++; + } + + raw_ptr<views::View> spacer = + actions_container->AddChildView(std::make_unique<views::View>()); + actions_container->SetFlexForView(spacer, 1); + + raw_ptr<ash::PillButton> assistant_button = + actions_container->AddChildView(std::make_unique<ash::PillButton>( + base::BindRepeating(&LauncherSearchIphView::OpenAssistantPage, + weak_ptr_factory_.GetWeakPtr()), + kAssistantButtonPlaceholder)); + assistant_button->SetID(ViewId::kAssistant); } LauncherSearchIphView::~LauncherSearchIphView() = default; +void LauncherSearchIphView::RunLauncherSearchQuery( + const std::u16string& query) { + delegate_->RunLauncherSearchQuery(query); +} + +void LauncherSearchIphView::OpenAssistantPage() { + delegate_->OpenAssistantPage(); +} + } // namespace ash
diff --git a/ash/app_list/views/launcher_search_iph_view.h b/ash/app_list/views/launcher_search_iph_view.h index 155c863..ad549c6b 100644 --- a/ash/app_list/views/launcher_search_iph_view.h +++ b/ash/app_list/views/launcher_search_iph_view.h
@@ -6,6 +6,7 @@ #define ASH_APP_LIST_VIEWS_LAUNCHER_SEARCH_IPH_VIEW_H_ #include <memory> +#include <string> #include "ash/public/cpp/app_list/app_list_client.h" #include "ui/views/view.h" @@ -14,14 +15,36 @@ class LauncherSearchIphView : public views::View { public: - static constexpr int kViewId = 1; + // Delegate for handling actions of `LauncherSearchIphView`. + class Delegate { + public: + virtual ~Delegate() = default; + // Run `query` as a launcher search. `query` is localized. + virtual void RunLauncherSearchQuery(const std::u16string& query) = 0; + // Opens Assistant page in the launcher. + virtual void OpenAssistantPage() = 0; + }; - explicit LauncherSearchIphView( - std::unique_ptr<ScopedIphSession> scoped_iph_session); + enum ViewId { + kSelf = 1, + kAssistant, + // Do not put a new id after `kChipStart`. Numbers after `kChipStart` + // will be used for chips. + kChipStart + }; + + LauncherSearchIphView(std::unique_ptr<ScopedIphSession> scoped_iph_session, + raw_ptr<Delegate> delegate); ~LauncherSearchIphView() override; private: + // TODO(b/272370530): Use string id for internationalization. + void RunLauncherSearchQuery(const std::u16string& query); + + void OpenAssistantPage(); + std::unique_ptr<ScopedIphSession> scoped_iph_session_; + raw_ptr<Delegate> delegate_; base::WeakPtrFactory<LauncherSearchIphView> weak_ptr_factory_{this}; };
diff --git a/ash/app_list/views/search_box_view.cc b/ash/app_list/views/search_box_view.cc index bf09fab..d930db5 100644 --- a/ash/app_list/views/search_box_view.cc +++ b/ash/app_list/views/search_box_view.cc
@@ -494,6 +494,14 @@ } } +void SearchBoxView::RunLauncherSearchQuery(const std::u16string& query) { + UpdateQuery(query); +} + +void SearchBoxView::OpenAssistantPage() { + delegate_->AssistantButtonPressed(); +} + // static int SearchBoxView::GetFocusRingSpacing() { return kSearchBoxFocusRingWidth + kSearchBoxFocusRingPadding; @@ -1236,8 +1244,8 @@ return; } - SetIphView( - std::make_unique<LauncherSearchIphView>(std::move(scoped_iph_session))); + SetIphView(std::make_unique<LauncherSearchIphView>( + std::move(scoped_iph_session), /*delegate=*/this)); } else { DeleteIphView(); }
diff --git a/ash/app_list/views/search_box_view.h b/ash/app_list/views/search_box_view.h index d56a9192..c5aba7a 100644 --- a/ash/app_list/views/search_box_view.h +++ b/ash/app_list/views/search_box_view.h
@@ -14,6 +14,7 @@ #include "ash/app_list/app_list_view_delegate.h" #include "ash/app_list/model/search/search_box_model.h" #include "ash/app_list/model/search/search_box_model_observer.h" +#include "ash/app_list/views/launcher_search_iph_view.h" #include "ash/ash_export.h" #include "ash/public/cpp/app_list/app_list_types.h" #include "ash/search_box/search_box_view_base.h" @@ -39,7 +40,8 @@ // contents and selection model of the Textfield. class ASH_EXPORT SearchBoxView : public SearchBoxViewBase, public AppListModelProvider::Observer, - public SearchBoxModelObserver { + public SearchBoxModelObserver, + public LauncherSearchIphView::Delegate { public: enum class PlaceholderTextType { kShortcuts = 0, @@ -102,6 +104,10 @@ void OnBoundsChanged(const gfx::Rect& previous_bounds) override; void AddedToWidget() override; + // LauncherSearchIphView::Delegate: + void RunLauncherSearchQuery(const std::u16string& query) override; + void OpenAssistantPage() override; + // Updates the search box's background corner radius and color based on the // state of AppListModel. void UpdateBackground(AppListState target_state);
diff --git a/ash/shortcut_viewer/views/keyboard_shortcut_item_list_view.cc b/ash/shortcut_viewer/views/keyboard_shortcut_item_list_view.cc index 75f28a3..fae8f3e 100644 --- a/ash/shortcut_viewer/views/keyboard_shortcut_item_list_view.cc +++ b/ash/shortcut_viewer/views/keyboard_shortcut_item_list_view.cc
@@ -79,7 +79,7 @@ SetLayoutManager(std::move(layout)); SetBorder(views::CreateEmptyBorder( gfx::Insets::TLBR(0, kLeftPadding, 0, kRightPadding))); - GetViewAccessibility().OverrideRole(ax::mojom::Role::kList); + SetAccessibilityProperties(ax::mojom::Role::kList); } void KeyboardShortcutItemListView::AddCategoryLabel(
diff --git a/ash/shortcut_viewer/views/keyboard_shortcut_item_view.cc b/ash/shortcut_viewer/views/keyboard_shortcut_item_view.cc index 4939ec43..d1065ca 100644 --- a/ash/shortcut_viewer/views/keyboard_shortcut_item_view.cc +++ b/ash/shortcut_viewer/views/keyboard_shortcut_item_view.cc
@@ -21,9 +21,10 @@ #include "base/notreached.h" #include "base/strings/utf_string_conversions.h" #include "base/trace_event/trace_event.h" -#include "ui/accessibility/ax_node_data.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/strings/grit/ui_strings.h" #include "ui/views/accessibility/view_accessibility.h" #include "ui/views/border.h" #include "ui/views/controls/image_view.h" @@ -234,19 +235,15 @@ SetBorder(views::CreateEmptyBorder( gfx::Insets::TLBR(kVerticalPadding, 0, kVerticalPadding, 0))); - // Use leaf list item role so that name is spoken by screen reader, but - // redundant child label text is not also spoken. (The role is set in - // GetAccessibleNodeData.) - GetViewAccessibility().OverrideIsLeaf(true); - accessible_name_ = - description_label_view_->GetText() + u", " + accessible_string; -} + SetAccessibilityProperties( + ax::mojom::Role::kListItem, + l10n_util::GetStringFUTF16(IDS_CONCAT_TWO_STRINGS_WITH_COMMA, + description_label_view_->GetText(), + accessible_string)); -void KeyboardShortcutItemView::GetAccessibleNodeData( - ui::AXNodeData* node_data) { - // A valid role must be set prior to setting the name. - node_data->role = ax::mojom::Role::kListItem; - node_data->SetName(accessible_name_); + // Use leaf list item role so that name is spoken by screen reader, but + // redundant child label text is not also spoken. + GetViewAccessibility().OverrideIsLeaf(true); } int KeyboardShortcutItemView::GetHeightForWidth(int w) const { @@ -343,4 +340,7 @@ calculated_size_ = gfx::Size(width, content_height + insets.height()); } +BEGIN_METADATA(KeyboardShortcutItemView, views::View) +END_METADATA + } // namespace keyboard_shortcut_viewer
diff --git a/ash/shortcut_viewer/views/keyboard_shortcut_item_view.h b/ash/shortcut_viewer/views/keyboard_shortcut_item_view.h index 5b6c0e4..1afb795 100644 --- a/ash/shortcut_viewer/views/keyboard_shortcut_item_view.h +++ b/ash/shortcut_viewer/views/keyboard_shortcut_item_view.h
@@ -6,6 +6,8 @@ #define ASH_SHORTCUT_VIEWER_VIEWS_KEYBOARD_SHORTCUT_ITEM_VIEW_H_ #include "ash/public/cpp/keyboard_shortcut_item.h" +#include "ui/base/metadata/metadata_header_macros.h" + #include "ui/views/view.h" namespace views { @@ -17,6 +19,7 @@ // A view that displays a shortcut metadata. class KeyboardShortcutItemView : public views::View { public: + METADATA_HEADER(KeyboardShortcutItemView); KeyboardShortcutItemView(const ash::KeyboardShortcutItem& item, ash::ShortcutCategory category); @@ -26,7 +29,6 @@ ~KeyboardShortcutItemView() override = default; // views::View: - void GetAccessibleNodeData(ui::AXNodeData* node_data) override; int GetHeightForWidth(int w) const override; void Layout() override; @@ -74,9 +76,6 @@ mutable gfx::Rect description_bounds_; mutable gfx::Rect shortcut_bounds_; mutable gfx::Size calculated_size_; - - // Accessibility data. - std::u16string accessible_name_; }; } // namespace keyboard_shortcut_viewer
diff --git a/ash/shortcut_viewer/views/keyboard_shortcut_view.cc b/ash/shortcut_viewer/views/keyboard_shortcut_view.cc index 6ba75103..df40a28 100644 --- a/ash/shortcut_viewer/views/keyboard_shortcut_view.cc +++ b/ash/shortcut_viewer/views/keyboard_shortcut_view.cc
@@ -42,6 +42,7 @@ #include "ui/base/accelerators/accelerator.h" #include "ui/base/default_style.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" #include "ui/base/resource/resource_bundle.h" #include "ui/chromeos/events/keyboard_layout_util.h" #include "ui/chromeos/styles/cros_tokens_color_mappings.h" @@ -155,8 +156,8 @@ class ShortcutsListScrollView : public views::ScrollView { public: ShortcutsListScrollView() { - GetViewAccessibility().OverrideRole(ax::mojom::Role::kScrollView); - GetViewAccessibility().OverrideName( + SetAccessibilityProperties( + ax::mojom::Role::kScrollView, l10n_util::GetStringUTF16(IDS_KSV_SCROLL_VIEW_ACCESSIBILITY_NAME)); } @@ -289,10 +290,6 @@ return g_ksv_view->GetWidget(); } -const char* KeyboardShortcutView::GetClassName() const { - return "KeyboardShortcutView"; -} - std::u16string KeyboardShortcutView::GetAccessibleWindowTitle() const { return l10n_util::GetStringUTF16(IDS_KSV_TITLE); } @@ -681,6 +678,9 @@ window->SetProperty(chromeos::kFrameInactiveColorKey, background_color); } +BEGIN_METADATA(KeyboardShortcutView, views::WidgetDelegateView) +END_METADATA + } // namespace keyboard_shortcut_viewer namespace ash {
diff --git a/ash/shortcut_viewer/views/keyboard_shortcut_view.h b/ash/shortcut_viewer/views/keyboard_shortcut_view.h index b360d6a5..a56e5ee 100644 --- a/ash/shortcut_viewer/views/keyboard_shortcut_view.h +++ b/ash/shortcut_viewer/views/keyboard_shortcut_view.h
@@ -11,6 +11,7 @@ #include "base/timer/timer.h" #include "third_party/abseil-cpp/absl/types/optional.h" +#include "ui/base/metadata/metadata_header_macros.h" #include "ui/views/widget/widget_delegate.h" namespace aura { @@ -34,6 +35,7 @@ // The UI container for Ash and Chrome keyboard shortcuts. class KeyboardShortcutView : public views::WidgetDelegateView { public: + METADATA_HEADER(KeyboardShortcutView); KeyboardShortcutView(const KeyboardShortcutView&) = delete; KeyboardShortcutView& operator=(const KeyboardShortcutView&) = delete; @@ -47,7 +49,6 @@ static views::Widget* Toggle(aura::Window* context); // views::View: - const char* GetClassName() const override; std::u16string GetAccessibleWindowTitle() const override; bool AcceleratorPressed(const ui::Accelerator& accelerator) override; void Layout() override;
diff --git a/ash/shortcut_viewer/views/keyboard_shortcut_view_unittest.cc b/ash/shortcut_viewer/views/keyboard_shortcut_view_unittest.cc index 5d0034e6..f438e175 100644 --- a/ash/shortcut_viewer/views/keyboard_shortcut_view_unittest.cc +++ b/ash/shortcut_viewer/views/keyboard_shortcut_view_unittest.cc
@@ -25,6 +25,7 @@ #include "ui/events/devices/device_data_manager_test_api.h" #include "ui/events/test/event_generator.h" #include "ui/gfx/color_palette.h" +#include "ui/views/accessibility/view_accessibility.h" #include "ui/views/controls/textfield/textfield.h" #include "ui/views/test/button_test_api.h" #include "ui/views/widget/widget.h" @@ -321,4 +322,72 @@ EXPECT_EQ(kTitleAndFrameColorDark, GetView()->GetBackground()->get_color()); } +TEST_F(KeyboardShortcutViewTest, AccessibilityProperties) { + // Show the widget. + Toggle(); + + EXPECT_TRUE(GetFoundShortcutItems().empty()); + // Type a letter and show the search results. + KeyPress(ui::VKEY_A, /*should_insert=*/true); + auto time_out = base::Milliseconds(300); + task_environment()->FastForwardBy(time_out); + base::RunLoop().RunUntilIdle(); + + const std::vector<KeyboardShortcutItemView*>& items = GetFoundShortcutItems(); + EXPECT_FALSE(items.empty()); + + auto* first_item = items.front(); + ui::AXNodeData first_item_data; + first_item->GetViewAccessibility().GetAccessibleNodeData(&first_item_data); + EXPECT_EQ(first_item_data.role, ax::mojom::Role::kListItem); + EXPECT_EQ(first_item->GetAccessibleRole(), first_item_data.role); + EXPECT_FALSE(first_item->GetAccessibleName().empty()); + EXPECT_EQ( + first_item_data.GetString16Attribute(ax::mojom::StringAttribute::kName), + first_item->GetAccessibleName()); + EXPECT_EQ(first_item_data.GetIntAttribute(ax::mojom::IntAttribute::kPosInSet), + 1); + EXPECT_EQ(first_item_data.GetIntAttribute(ax::mojom::IntAttribute::kSetSize), + static_cast<int>(items.size())); + + auto* last_item = items.back(); + ui::AXNodeData last_item_data; + last_item->GetViewAccessibility().GetAccessibleNodeData(&last_item_data); + EXPECT_EQ(last_item_data.role, ax::mojom::Role::kListItem); + EXPECT_EQ(last_item->GetAccessibleRole(), last_item_data.role); + EXPECT_EQ( + last_item_data.GetString16Attribute(ax::mojom::StringAttribute::kName), + last_item->GetAccessibleName()); + EXPECT_FALSE(last_item->GetAccessibleName().empty()); + EXPECT_EQ(last_item_data.GetIntAttribute(ax::mojom::IntAttribute::kPosInSet), + static_cast<int>(items.size())); + EXPECT_EQ(last_item_data.GetIntAttribute(ax::mojom::IntAttribute::kSetSize), + static_cast<int>(items.size())); + + auto* list = last_item->parent(); + while (list && list->GetAccessibleRole() != ax::mojom::Role::kList) { + list = list->parent(); + } + + EXPECT_TRUE(list); + ui::AXNodeData list_data; + list->GetViewAccessibility().GetAccessibleNodeData(&list_data); + EXPECT_EQ(list_data.role, ax::mojom::Role::kList); + + auto* scroll_view = list->parent(); + while (scroll_view && + scroll_view->GetAccessibleRole() != ax::mojom::Role::kScrollView) { + scroll_view = scroll_view->parent(); + } + + EXPECT_TRUE(scroll_view); + ui::AXNodeData scroll_view_data; + scroll_view->GetViewAccessibility().GetAccessibleNodeData(&scroll_view_data); + EXPECT_EQ(scroll_view_data.role, ax::mojom::Role::kScrollView); + EXPECT_FALSE(scroll_view->GetAccessibleName().empty()); + EXPECT_EQ( + scroll_view_data.GetString16Attribute(ax::mojom::StringAttribute::kName), + scroll_view->GetAccessibleName()); +} + } // namespace keyboard_shortcut_viewer
diff --git a/ash/system/input_device_settings/input_device_settings_controller_impl.cc b/ash/system/input_device_settings/input_device_settings_controller_impl.cc index 91f16df..ffde876 100644 --- a/ash/system/input_device_settings/input_device_settings_controller_impl.cc +++ b/ash/system/input_device_settings/input_device_settings_controller_impl.cc
@@ -104,10 +104,16 @@ // suppress_meta_fkey_rewrites must never be non-default for internal // keyboards, otherwise the keyboard settings are not valid. +// Modifier remappings must only contain valid modifiers within the +// modifier_keys array. bool keyboardSettingsAreValid(const mojom::Keyboard& keyboard, const mojom::KeyboardSettings& settings) { - // TODO(wangdanny): Validate modifier keys to make sure they can apply - // to the given device. + for (const auto& remapping : settings.modifier_remappings) { + auto it = base::ranges::find(keyboard.modifier_keys, remapping.first); + if (it == keyboard.modifier_keys.end()) { + return false; + } + } return keyboard.is_external || (settings.suppress_meta_fkey_rewrites == kDefaultSuppressMetaFKeyRewrites); }
diff --git a/ash/system/input_device_settings/input_device_settings_controller_unittest.cc b/ash/system/input_device_settings/input_device_settings_controller_unittest.cc index e317468..7253175 100644 --- a/ash/system/input_device_settings/input_device_settings_controller_unittest.cc +++ b/ash/system/input_device_settings/input_device_settings_controller_unittest.cc
@@ -280,6 +280,16 @@ EXPECT_EQ(observer_->num_keyboards_settings_updated(), 0u); EXPECT_EQ(keyboard_pref_handler_->num_keyboard_settings_updated(), 0u); + + // The keyboard is internal and it doesn't have capslock remapping. + settings->suppress_meta_fkey_rewrites = kDefaultSuppressMetaFKeyRewrites; + settings->modifier_remappings[ui::mojom::ModifierKey::kCapsLock] = + ui::mojom::ModifierKey::kAlt; + controller_->SetKeyboardSettings((DeviceId)kSampleKeyboardInternal.id, + settings.Clone()); + + EXPECT_EQ(observer_->num_keyboards_settings_updated(), 0u); + EXPECT_EQ(keyboard_pref_handler_->num_keyboard_settings_updated(), 0u); } // Tests that given an invalid id, keyboard settings are not updated and
diff --git a/ash/webui/projector_app/BUILD.gn b/ash/webui/projector_app/BUILD.gn index 52df83d..7b2aa84 100644 --- a/ash/webui/projector_app/BUILD.gn +++ b/ash/webui/projector_app/BUILD.gn
@@ -10,6 +10,8 @@ static_library("projector_app") { sources = [ + "annotator_page_handler_impl.cc", + "annotator_page_handler_impl.h", "projector_app_client.cc", "projector_app_client.h", "projector_message_handler.cc", @@ -20,10 +22,10 @@ "projector_screencast.h", "projector_xhr_sender.cc", "projector_xhr_sender.h", + "trusted_projector_annotator_ui.cc", + "trusted_projector_annotator_ui.h", "trusted_projector_ui.cc", "trusted_projector_ui.h", - "untrusted_annotator_page_handler_impl.cc", - "untrusted_annotator_page_handler_impl.h", "untrusted_projector_annotator_ui.cc", "untrusted_projector_annotator_ui.h", "untrusted_projector_ui.cc", @@ -37,6 +39,7 @@ "//ash/webui/projector_app/mojom:annotator_mojo_bindings", "//ash/webui/projector_app/public/mojom:annotator_mojo_bindings", "//ash/webui/resources:media_app_bundle_resources", + "//ash/webui/resources:projector_annotator_trusted_resources", "//ash/webui/resources:projector_annotator_untrusted_resources", "//ash/webui/resources:projector_app_bundle_resources", "//ash/webui/resources:projector_app_trusted_resources", @@ -79,10 +82,10 @@ source_set("unit_tests") { testonly = true sources = [ + "test/annotator_page_handler_impl_unittest.cc", "test/projector_message_handler_unittest.cc", "test/projector_oauth_token_fetcher_unittest.cc", "test/projector_xhr_sender_unittest.cc", - "test/untrusted_annotator_page_handler_impl_unittest.cc", ] deps = [
diff --git a/ash/webui/projector_app/untrusted_annotator_page_handler_impl.cc b/ash/webui/projector_app/annotator_page_handler_impl.cc similarity index 67% rename from ash/webui/projector_app/untrusted_annotator_page_handler_impl.cc rename to ash/webui/projector_app/annotator_page_handler_impl.cc index 3328a30b1..4beb9ec3 100644 --- a/ash/webui/projector_app/untrusted_annotator_page_handler_impl.cc +++ b/ash/webui/projector_app/annotator_page_handler_impl.cc
@@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/webui/projector_app/untrusted_annotator_page_handler_impl.h" +#include "ash/webui/projector_app/annotator_page_handler_impl.h" #include <memory> #include "ash/public/cpp/projector/annotator_tool.h" #include "ash/public/cpp/projector/projector_controller.h" -#include "ash/webui/projector_app/mojom/untrusted_annotator.mojom.h" +#include "ash/webui/projector_app/mojom/annotator.mojom.h" #include "ash/webui/projector_app/projector_app_client.h" #include "ash/webui/projector_app/public/mojom/annotator_structs.mojom.h" #include "base/check.h" @@ -18,10 +18,10 @@ namespace ash { -UntrustedAnnotatorPageHandlerImpl::UntrustedAnnotatorPageHandlerImpl( - mojo::PendingReceiver<annotator::mojom::UntrustedAnnotatorPageHandler> +AnnotatorPageHandlerImpl::AnnotatorPageHandlerImpl( + mojo::PendingReceiver<annotator::mojom::AnnotatorPageHandler> annotator_handler, - mojo::PendingRemote<annotator::mojom::UntrustedAnnotatorPage> annotator, + mojo::PendingRemote<annotator::mojom::AnnotatorPage> annotator, content::WebUI* web_ui) : annotator_remote_(std::move(annotator)), annotator_handler_receiver_(this, std::move(annotator_handler)), @@ -29,11 +29,11 @@ ProjectorAppClient::Get()->SetAnnotatorPageHandler(this); } -UntrustedAnnotatorPageHandlerImpl::~UntrustedAnnotatorPageHandlerImpl() { +AnnotatorPageHandlerImpl::~AnnotatorPageHandlerImpl() { ProjectorAppClient::Get()->ResetAnnotatorPageHandler(this); } -void UntrustedAnnotatorPageHandlerImpl::SetTool(const AnnotatorTool& tool) { +void AnnotatorPageHandlerImpl::SetTool(const AnnotatorTool& tool) { auto mojo_tool = annotator::mojom::AnnotatorTool::New(); mojo_tool->color = tool.GetColorHexString(); mojo_tool->tool = tool.GetToolString(); @@ -41,19 +41,19 @@ annotator_remote_->SetTool(std::move(mojo_tool)); } -void UntrustedAnnotatorPageHandlerImpl::Undo() { +void AnnotatorPageHandlerImpl::Undo() { annotator_remote_->Undo(); } -void UntrustedAnnotatorPageHandlerImpl::Redo() { +void AnnotatorPageHandlerImpl::Redo() { annotator_remote_->Redo(); } -void UntrustedAnnotatorPageHandlerImpl::Clear() { +void AnnotatorPageHandlerImpl::Clear() { annotator_remote_->Clear(); } -void UntrustedAnnotatorPageHandlerImpl::OnUndoRedoAvailabilityChanged( +void AnnotatorPageHandlerImpl::OnUndoRedoAvailabilityChanged( bool undo_available, bool redo_available) { // ProjectorController is created when ash::Shell::Init is called and is @@ -63,11 +63,20 @@ redo_available); } -void UntrustedAnnotatorPageHandlerImpl::OnCanvasInitialized(bool success) { +void AnnotatorPageHandlerImpl::OnCanvasInitialized(bool success) { // ProjectorController is created when ash::Shell::Init is called and is // destroyed when ash::Shell is destroyed. Therefore, ProjectorController // is available when this WebUI is showing. ProjectorController::Get()->OnCanvasInitialized(success); } +void AnnotatorPageHandlerImpl::OnError( + const std::vector<std::string>& messages) { + for (const auto& message : messages) { + LOG(ERROR) << message; + } + + // TODO(b/239979179): Consider reloading the webcontent. +} + } // namespace ash
diff --git a/ash/webui/projector_app/annotator_page_handler_impl.h b/ash/webui/projector_app/annotator_page_handler_impl.h new file mode 100644 index 0000000..8808cef0 --- /dev/null +++ b/ash/webui/projector_app/annotator_page_handler_impl.h
@@ -0,0 +1,64 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_WEBUI_PROJECTOR_APP_ANNOTATOR_PAGE_HANDLER_IMPL_H_ +#define ASH_WEBUI_PROJECTOR_APP_ANNOTATOR_PAGE_HANDLER_IMPL_H_ + +#include "ash/public/cpp/projector/projector_annotator_controller.h" +#include "ash/webui/projector_app/mojom/annotator.mojom.h" +#include "base/functional/callback.h" +#include "base/values.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" +#include "mojo/public/cpp/bindings/pending_remote.h" +#include "mojo/public/cpp/bindings/receiver.h" +#include "mojo/public/cpp/bindings/remote.h" + +namespace content { +class WebUI; +} // namespace content + +namespace ash { + +struct AnnotatorTool; + +// Handles communication with the Annotator WebUI (i.e. +// chrome://projector/annotator/annotator_embedder.html). +class AnnotatorPageHandlerImpl : public annotator::mojom::AnnotatorPageHandler { + public: + AnnotatorPageHandlerImpl( + mojo::PendingReceiver<annotator::mojom::AnnotatorPageHandler> + annotator_handler, + mojo::PendingRemote<annotator::mojom::AnnotatorPage> annotator, + content::WebUI* web_ui); + AnnotatorPageHandlerImpl(const AnnotatorPageHandlerImpl&) = delete; + AnnotatorPageHandlerImpl& operator=(const AnnotatorPageHandlerImpl&) = delete; + ~AnnotatorPageHandlerImpl() override; + + // Called by ProjectorAppClient. + void SetTool(const AnnotatorTool& tool); + void Undo(); + void Redo(); + void Clear(); + + // annotator::mojom::AnnotatorHandler: + void OnUndoRedoAvailabilityChanged(bool undo_available, + bool redo_available) override; + void OnCanvasInitialized(bool success) override; + void OnError(const std::vector<std::string>& messages) override; + + content::WebUI* get_web_ui_for_test() { return web_ui_; } + + private: + mojo::Remote<annotator::mojom::AnnotatorPage> annotator_remote_; + mojo::Receiver<annotator::mojom::AnnotatorPageHandler> + annotator_handler_receiver_; + + // The WebUI that owns the TrustedProjectorAnnotatorUI that owns this + // instance. + content::WebUI* const web_ui_; +}; + +} // namespace ash + +#endif // ASH_WEBUI_PROJECTOR_APP_ANNOTATOR_PAGE_HANDLER_IMPL_H_
diff --git a/ash/webui/projector_app/mojom/BUILD.gn b/ash/webui/projector_app/mojom/BUILD.gn index 2ee3298..95890cd 100644 --- a/ash/webui/projector_app/mojom/BUILD.gn +++ b/ash/webui/projector_app/mojom/BUILD.gn
@@ -10,7 +10,7 @@ cur_dir = rebase_path(".", "//") mojom("annotator_mojo_bindings") { - sources = [ "untrusted_annotator.mojom" ] + sources = [ "annotator.mojom" ] deps = [ "//ash/webui/projector_app/public/mojom:annotator_mojo_bindings" ] webui_module_path = "/$cur_dir" }
diff --git a/ash/webui/projector_app/mojom/untrusted_annotator.mojom b/ash/webui/projector_app/mojom/annotator.mojom similarity index 78% rename from ash/webui/projector_app/mojom/untrusted_annotator.mojom rename to ash/webui/projector_app/mojom/annotator.mojom index 2059657c..fca08dc 100644 --- a/ash/webui/projector_app/mojom/untrusted_annotator.mojom +++ b/ash/webui/projector_app/mojom/annotator.mojom
@@ -8,7 +8,7 @@ // AnnotatorPage interface implemented in the Javascript. Used by the browser // process to send events to Javascript. -interface UntrustedAnnotatorPage { +interface AnnotatorPage { // Clears the annotations on the annotator canvas. Clear(); // Undo the last stroke on the annotator canvas. @@ -21,7 +21,7 @@ // AnnotatoPagerHandler interface implemented in C++ in the browser process. // Used by Javascript to communicate with the browser process. -interface UntrustedAnnotatorPageHandler { +interface AnnotatorPageHandler { // Notifies the browser that that undo/redo availability // changed for annotator. OnUndoRedoAvailabilityChanged(bool undo_available, @@ -30,13 +30,17 @@ // Notifies the browser process that the annotation canvas // has been initialized. OnCanvasInitialized(bool success); + + // Notifies the browser process that an error has occurred + // in the renderer and sends the error messages to it. + OnError(array<string> errors); }; // Interface used to setup the communication between Javascript and C++ // in the browser process. -interface UntrustedAnnotatorPageHandlerFactory { +interface AnnotatorPageHandlerFactory { // Creates the AnnotatorPageHandler in the browser process and binds it // to receive calls from Javascript. - Create(pending_receiver<UntrustedAnnotatorPageHandler> handler, - pending_remote<UntrustedAnnotatorPage> annotator); + Create(pending_receiver<AnnotatorPageHandler> handler, + pending_remote<AnnotatorPage> annotator); };
diff --git a/ash/webui/projector_app/projector_app_client.h b/ash/webui/projector_app/projector_app_client.h index 96a51d0b..f59e2dc 100644 --- a/ash/webui/projector_app/projector_app_client.h +++ b/ash/webui/projector_app/projector_app_client.h
@@ -25,7 +25,7 @@ namespace ash { -class UntrustedAnnotatorPageHandlerImpl; +class AnnotatorPageHandlerImpl; struct AnnotatorTool; struct ProjectorScreencastVideo; struct NewScreencastPrecondition; @@ -160,13 +160,11 @@ // Registers the AnnotatorPageHandlerImpl that is owned by the WebUI that // contains the Projector annotator. - virtual void SetAnnotatorPageHandler( - UntrustedAnnotatorPageHandlerImpl* handler) = 0; + virtual void SetAnnotatorPageHandler(AnnotatorPageHandlerImpl* handler) = 0; // Resets the stored AnnotatorPageHandlerImpl if it matches the one that is // passed in. - virtual void ResetAnnotatorPageHandler( - UntrustedAnnotatorPageHandlerImpl* handler) = 0; + virtual void ResetAnnotatorPageHandler(AnnotatorPageHandlerImpl* handler) = 0; // Sets the tool inside the annotator WebUI. virtual void SetTool(const AnnotatorTool& tool) = 0;
diff --git a/ash/webui/projector_app/public/cpp/projector_app_constants.cc b/ash/webui/projector_app/public/cpp/projector_app_constants.cc index eaaa2443..8fa9675 100644 --- a/ash/webui/projector_app/public/cpp/projector_app_constants.cc +++ b/ash/webui/projector_app/public/cpp/projector_app_constants.cc
@@ -15,6 +15,7 @@ "https://screencast.apps.chrome"; const char kChromeUITrustedProjectorUrl[] = "chrome://projector/"; +const char kChromeUITrustedAnnotatorUrl[] = "chrome://projector-annotator/"; const char kChromeUIUntrustedAnnotatorUrl[] = "chrome-untrusted://projector-annotator/";
diff --git a/ash/webui/projector_app/public/cpp/projector_app_constants.h b/ash/webui/projector_app/public/cpp/projector_app_constants.h index 8108b594..ee43ff1 100644 --- a/ash/webui/projector_app/public/cpp/projector_app_constants.h +++ b/ash/webui/projector_app/public/cpp/projector_app_constants.h
@@ -16,6 +16,7 @@ extern const char kChromeUIUntrustedProjectorPwaUrl[]; extern const char kChromeUITrustedProjectorUrl[]; +extern const char kChromeUITrustedAnnotatorUrl[]; extern const char kChromeUIUntrustedAnnotatorUrl[]; extern const char kChromeUITrustedProjectorSwaAppId[];
diff --git a/ash/webui/projector_app/resources/BUILD.gn b/ash/webui/projector_app/resources/BUILD.gn index 989adb1d..0cae46dc 100644 --- a/ash/webui/projector_app/resources/BUILD.gn +++ b/ash/webui/projector_app/resources/BUILD.gn
@@ -11,6 +11,7 @@ js_type_check("closure_compile") { is_polymer3 = true deps = [ + "//ash/webui/projector_app/resources/annotator/trusted:trusted_annotator_library", "//ash/webui/projector_app/resources/annotator/untrusted:untrusted_annotator_library", "//ash/webui/projector_app/resources/app/trusted:trusted_app", "//ash/webui/projector_app/resources/app/untrusted:untrusted_app",
diff --git a/ash/webui/projector_app/resources/annotator/trusted/BUILD.gn b/ash/webui/projector_app/resources/annotator/trusted/BUILD.gn new file mode 100644 index 0000000..88d8fbd --- /dev/null +++ b/ash/webui/projector_app/resources/annotator/trusted/BUILD.gn
@@ -0,0 +1,49 @@ +# Copyright 2022 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//chrome/common/features.gni") +import("//third_party/closure_compiler/compile_js.gni") +import("//ui/webui/resources/tools/generate_grd.gni") + +assert(is_chromeos_ash, "Projector Annotator is ChromeOS only") + +js_library("trusted_annotator_library") { + sources = [ + "annotator_browser_proxy.js", + "annotator_embedder_impl.js", + "trusted_annotator_comm_factory.js", + ] + deps = [ + "//ash/webui/common/resources:cr_deprecated", + "//ash/webui/common/resources/post_message_api:post_message_api_client", + "//ash/webui/common/resources/post_message_api:post_message_api_request_handler", + "//ash/webui/projector_app/mojom:annotator_mojo_bindings_webui_js", + "//ash/webui/projector_app/public/mojom:annotator_mojo_bindings_webui_js", + "//ash/webui/projector_app/resources/common:message_types", + ] + externs_list = [ "../../common/projector_app.externs.js" ] +} + +generate_grd("build_trusted_grd") { + input_files = [ + "annotator_embedder.html", + "annotator_embedder.css", + "annotator_browser_proxy.js", + "trusted_annotator_comm_factory.js", + "annotator_embedder_impl.js", + ] + + manifest_files = [] + input_files_base_dir = rebase_path(".", "//") + grd_prefix = "ash_projector_annotator_trusted" + out_grd = "$target_gen_dir/${grd_prefix}_resources.grd" + deps = [ + "//ash/webui/projector_app/mojom:annotator_mojo_bindings_webui_grdp", + "//ash/webui/projector_app/public/mojom:annotator_mojo_bindings_webui_grdp", + ] + grdp_files = [ + "$target_gen_dir/../../../mojom/annotator_mojo_bindings_webui_resources.grdp", + "$target_gen_dir/../../../public/mojom/annotator_mojo_bindings_webui_resources.grdp", + ] +}
diff --git a/ash/webui/projector_app/resources/annotator/untrusted/annotator_browser_proxy.js b/ash/webui/projector_app/resources/annotator/trusted/annotator_browser_proxy.js similarity index 62% rename from ash/webui/projector_app/resources/annotator/untrusted/annotator_browser_proxy.js rename to ash/webui/projector_app/resources/annotator/trusted/annotator_browser_proxy.js index 11310906..322941c5 100644 --- a/ash/webui/projector_app/resources/annotator/untrusted/annotator_browser_proxy.js +++ b/ash/webui/projector_app/resources/annotator/trusted/annotator_browser_proxy.js
@@ -1,8 +1,9 @@ // Copyright 2022 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {addSingletonGetter} from 'chrome://resources/ash/common/cr_deprecated.js'; -import {UntrustedAnnotatorPageCallbackRouter, UntrustedAnnotatorPageHandlerFactory, UntrustedAnnotatorPageHandlerRemote, UntrustedAnnotatorPageRemote} from './ash/webui/projector_app/mojom/untrusted_annotator.mojom-webui.js'; +import {AnnotatorPageCallbackRouter, AnnotatorPageHandlerFactory, AnnotatorPageHandlerRemote, AnnotatorPageRemote} from './ash/webui/projector_app/mojom/annotator.mojom-webui.js'; /** * To use the annotator proxy, please import this module and call @@ -27,6 +28,14 @@ * @param {boolean} success */ onCanvasInitialized(success) {} + + /** + * Sends 'error' message to handler. + * The Handler will log the message. If the error is not a recoverable error, + * the handler closes the corresponding WebUI. + * @param {!Array<string>} msg Error messages. + */ + onError(msg) {} } /** @@ -34,9 +43,9 @@ */ export class AnnotatorBrowserProxyImpl { constructor() { - this.pageHandlerFactory = UntrustedAnnotatorPageHandlerFactory.getRemote(); - this.pageHandlerRemote = new UntrustedAnnotatorPageHandlerRemote(); - this.annotatorCallbackRouter = new UntrustedAnnotatorPageCallbackRouter(); + this.pageHandlerFactory = AnnotatorPageHandlerFactory.getRemote(); + this.pageHandlerRemote = new AnnotatorPageHandlerRemote(); + this.annotatorCallbackRouter = new AnnotatorPageCallbackRouter(); this.pageHandlerFactory.create( this.pageHandlerRemote.$.bindNewPipeAndPassReceiver(), @@ -57,9 +66,11 @@ onCanvasInitialized(success) { this.pageHandlerRemote.onCanvasInitialized(success); } + + /** @override */ + onError(msgs) { + this.pageHandlerRemote.onError(msgs); + } } -/** - * @type {AnnotatorBrowserProxyImpl} - */ -export const browserProxy = new AnnotatorBrowserProxyImpl(); +addSingletonGetter(AnnotatorBrowserProxyImpl); \ No newline at end of file
diff --git a/ash/webui/projector_app/resources/annotator/trusted/annotator_embedder.css b/ash/webui/projector_app/resources/annotator/trusted/annotator_embedder.css new file mode 100644 index 0000000..0cd16f1 --- /dev/null +++ b/ash/webui/projector_app/resources/annotator/trusted/annotator_embedder.css
@@ -0,0 +1,19 @@ +/* Copyright 2021 The Chromium Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ + +body { + background-color: transparent; + height: 100vh; + margin: 0; + overflow: hidden; + width: 100vw; +} + +.marker-iframe { + border: none; + height: 100vh; + margin: 0; + overflow: hidden; + width: 100vw; +}
diff --git a/ash/webui/projector_app/resources/annotator/trusted/annotator_embedder.html b/ash/webui/projector_app/resources/annotator/trusted/annotator_embedder.html new file mode 100644 index 0000000..105c6d3 --- /dev/null +++ b/ash/webui/projector_app/resources/annotator/trusted/annotator_embedder.html
@@ -0,0 +1,20 @@ +<!-- +Copyright 2021 The Chromium Authors +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> + +<!DOCTYPE html> +<html> +<head> + <link rel="stylesheet" href="annotator_embedder.css"> + <script type="module" src="annotator_embedder_impl.js"></script> + </head> + <body> + <iframe + class="marker-iframe" + src="chrome-untrusted://projector-annotator" + allow="cross-origin-isolated"> + </iframe> + </body> +</html>
diff --git a/ash/webui/projector_app/resources/annotator/trusted/annotator_embedder_impl.js b/ash/webui/projector_app/resources/annotator/trusted/annotator_embedder_impl.js new file mode 100644 index 0000000..97652a40 --- /dev/null +++ b/ash/webui/projector_app/resources/annotator/trusted/annotator_embedder_impl.js
@@ -0,0 +1,64 @@ +// Copyright 2021 The Chromium Authors. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import {AnnotatorBrowserProxyImpl} from './annotator_browser_proxy.js'; +import {AnnotatorPageCallbackRouter} from './ash/webui/projector_app/mojom/annotator.mojom-webui.js'; +import {AnnotatorTrustedCommFactory} from './trusted_annotator_comm_factory.js'; + +/** + * Enum for passing annotator error message to the browser process. + * @enum {string} + */ +const AnnotatorToolErrorType = { + UNDO_ERROR: 'UNDO_ERROR', + REDO_ERROR: 'REDO_ERROR', + CLEAR_ERROR: 'CLEAR_ERROR', + SET_TOOL_ERROR: 'SET_TOOL_ERROR', +}; + + +/* @type {UntrustedAnnotatorClient} */ +const client = AnnotatorTrustedCommFactory.getPostMessageAPIClient(); + +/* @type {AnnotatorPageCallbackRouter} */ +const annotatorPageRouter = + AnnotatorBrowserProxyImpl.getInstance().getAnnotatorCallbackRouter(); + +annotatorPageRouter.undo.addListener(() => { + try { + client.undo(); + } catch (error) { + AnnotatorBrowserProxyImpl.getInstance().onError( + [AnnotatorToolErrorType.UNDO_ERROR]); + } +}); + +annotatorPageRouter.redo.addListener(() => { + try { + client.redo(); + } catch (error) { + AnnotatorBrowserProxyImpl.getInstance().onError( + [AnnotatorToolErrorType.REDO_ERROR]); + } +}); + + +annotatorPageRouter.clear.addListener(() => { + try { + client.clear(); + } catch (error) { + AnnotatorBrowserProxyImpl.getInstance().onError( + [AnnotatorToolErrorType.CLEAR_ERROR]); + } +}); + + +annotatorPageRouter.setTool.addListener((tool) => { + try { + client.setTool(tool); + } catch (error) { + AnnotatorBrowserProxyImpl.getInstance().onError( + [AnnotatorToolErrorType.SET_TOOL_ERROR]); + } +}); \ No newline at end of file
diff --git a/ash/webui/projector_app/resources/annotator/trusted/trusted_annotator_comm_factory.js b/ash/webui/projector_app/resources/annotator/trusted/trusted_annotator_comm_factory.js new file mode 100644 index 0000000..bb2bcb4 --- /dev/null +++ b/ash/webui/projector_app/resources/annotator/trusted/trusted_annotator_comm_factory.js
@@ -0,0 +1,134 @@ +// Copyright 2021 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import {PostMessageAPIClient} from 'chrome://resources/ash/common/post_message_api/post_message_api_client.js'; +import {RequestHandler} from 'chrome://resources/ash/common/post_message_api/post_message_api_request_handler.js'; + +import {AnnotatorBrowserProxy, AnnotatorBrowserProxyImpl} from './annotator_browser_proxy.js'; + +const TARGET_URL = 'chrome-untrusted://projector-annotator/'; + +// A PostMessageAPIClient that sends messages to chrome-untrusted://projector. +export class UntrustedAnnotatorClient extends PostMessageAPIClient { + /** + * @param {!Window} targetWindow + */ + constructor(targetWindow) { + super(TARGET_URL, targetWindow); + } + + /** + * Notifies the Annotator tool to update the tool. + * @param {!projectorApp.AnnotatorToolParams} tool + * @return {Promise<boolean>} + */ + setTool(tool) { + return this.callApiFn('setTool', [tool]); + } + + /** + * Notifies the Annotator to undo the last stroke. + * @return {Promise<boolean>} + */ + undo() { + return this.callApiFn('undo', []); + } + + /** + * Notifies the Annotator to redo the last stroke. + * @return {Promise<boolean>} + */ + redo() { + return this.callApiFn('redo', []); + } + + /** + * Notifies the Annotator to clear the screen. + * @return {Promise<boolean>} + */ + clear() { + return this.callApiFn('clear', []); + } +} + +/** + * Class that implements the RequestHandler inside the Projector trusted scheme + * for Annotator. + */ +class TrustedAnnotatorRequestHandler extends RequestHandler { + /* + * @param {!Element} iframeElement The <iframe> element to listen to as a + * client. + * @param {AnnotatorBrowserProxy} browserProxy The browser proxy that will + * be used to handle the messages. + */ + constructor(iframeElement, browserProxy) { + super(iframeElement, TARGET_URL, TARGET_URL); + this.browserProxy_ = browserProxy; + + this.registerMethod('onUndoRedoAvailabilityChanged', (values) => { + if (!values || values.length != 2) { + return; + } + return this.browserProxy_.onUndoRedoAvailabilityChanged( + values[0], values[1]); + }); + + this.registerMethod('onCanvasInitialized', (values) => { + if (!values || values.length != 1) { + return; + } + return this.browserProxy_.onCanvasInitialized(values[0]); + }); + } +} + +/** + * This is a class that is used to setup the duplex communication + * channels between this origin, chrome://projector/* and the iframe embedded + * inside the document. + */ +export class AnnotatorTrustedCommFactory { + /** + * Creates the instances of PostMessageAPIClient and RequestHandler if they + * have not been created already. + */ + static maybeCreateInstances() { + if (AnnotatorTrustedCommFactory.client_ || + AnnotatorTrustedCommFactory.requestHandler_) { + return; + } + + const iframeElement = document.getElementsByTagName('iframe')[0]; + + AnnotatorTrustedCommFactory.client_ = + new UntrustedAnnotatorClient(iframeElement.contentWindow); + + AnnotatorTrustedCommFactory.requestHandler_ = + new TrustedAnnotatorRequestHandler( + iframeElement, AnnotatorBrowserProxyImpl.getInstance()); + } + + /** + * In order to use this class, please do the following + * (e.g. to set the tool do the following): + * const success = await + * AnnotatorTrustedCommFactory.getPostMessageAPIClient().setTool(tool); + * + * @return {!UntrustedAnnotatorClient} + */ + static getPostMessageAPIClient() { + // AnnotatorTrustedCommFactory.client_ should be available. However to be on + // the cautious side create an instance here if getPostMessageAPIClient is + // triggered before the page finishes loading. + AnnotatorTrustedCommFactory.maybeCreateInstances(); + return AnnotatorTrustedCommFactory.client_; + } +} + +document.addEventListener('DOMContentLoaded', () => { + // Create instances of the singletons(PostMessageAPIClient and + // RequestHandler) when the document has finished loading. + AnnotatorTrustedCommFactory.maybeCreateInstances(); +});
diff --git a/ash/webui/projector_app/resources/annotator/untrusted/BUILD.gn b/ash/webui/projector_app/resources/annotator/untrusted/BUILD.gn index 53efe48f..088d9cd0e 100644 --- a/ash/webui/projector_app/resources/annotator/untrusted/BUILD.gn +++ b/ash/webui/projector_app/resources/annotator/untrusted/BUILD.gn
@@ -9,13 +9,10 @@ assert(is_chromeos_ash, "Projector Annotator is ChromeOS only") js_library("untrusted_annotator_library") { - sources = [ - "annotator_browser_proxy.js", - "untrusted_annotator_comm_factory.js", - ] + sources = [ "untrusted_annotator_comm_factory.js" ] deps = [ - "//ash/webui/projector_app/mojom:annotator_mojo_bindings_webui_js", - "//ash/webui/projector_app/public/mojom:annotator_mojo_bindings_webui_js", + "//ash/webui/common/resources/post_message_api:post_message_api_client", + "//ash/webui/common/resources/post_message_api:post_message_api_request_handler", "//ash/webui/projector_app/resources/common:message_types", ] externs_list = [ "../../common/projector_app.externs.js" ] @@ -23,7 +20,6 @@ generate_grd("build_untrusted_grd") { input_files = [ - "annotator_browser_proxy.js", "annotator.html", "untrusted_annotator_comm_factory.js", ] @@ -31,13 +27,4 @@ input_files_base_dir = rebase_path(".", "//") grd_prefix = "ash_projector_annotator_untrusted" out_grd = "$target_gen_dir/${grd_prefix}_resources.grd" - - deps = [ - "//ash/webui/projector_app/mojom:annotator_mojo_bindings_webui_grdp", - "//ash/webui/projector_app/public/mojom:annotator_mojo_bindings_webui_grdp", - ] - grdp_files = [ - "$target_gen_dir/../../../mojom/annotator_mojo_bindings_webui_resources.grdp", - "$target_gen_dir/../../../public/mojom/annotator_mojo_bindings_webui_resources.grdp", - ] }
diff --git a/ash/webui/projector_app/resources/annotator/untrusted/untrusted_annotator_comm_factory.js b/ash/webui/projector_app/resources/annotator/untrusted/untrusted_annotator_comm_factory.js index f780a39..8775c9d 100644 --- a/ash/webui/projector_app/resources/annotator/untrusted/untrusted_annotator_comm_factory.js +++ b/ash/webui/projector_app/resources/annotator/untrusted/untrusted_annotator_comm_factory.js
@@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import {AnnotatorBrowserProxyImpl, browserProxy} from './annotator_browser_proxy.js'; -import {UntrustedAnnotatorPageCallbackRouter} from './ash/webui/projector_app/mojom/untrusted_annotator.mojom-webui.js'; +import {PostMessageAPIClient} from '//resources/ash/common/post_message_api/post_message_api_client.js'; +import {RequestHandler} from '//resources/ash/common/post_message_api/post_message_api_request_handler.js'; + +const TARGET_URL = 'chrome://projector-annotator/'; /** * Returns the projector app element inside this current DOM. @@ -14,57 +16,130 @@ document.querySelector('projector-ink-canvas-wrapper')); } -/* @type {AnnotatorPageCallbackRouter} */ -let annotatorPageRouter = null; -const observer = new MutationObserver(() => { - if (getAnnotatorElement()) { - if (annotatorPageRouter) { - // We have already registered. Therefore, return early. +// A client that sends messages to the chrome://projector embedder. +export class TrustedAnnotatorClient extends PostMessageAPIClient { + /** + * @param {!Window} parentWindow The embedder window from which requests + * come. + */ + constructor(parentWindow) { + super(TARGET_URL, parentWindow); + } + + /** + * Notifies the native ui that undo/redo has become available. + * @param {boolean} undoAvailable + * @param {boolean} redoAvailable + * @return {Promise} + */ + onUndoRedoAvailabilityChanged(undoAvailable, redoAvailable) { + return this.callApiFn( + 'onUndoRedoAvailabilityChanged', [undoAvailable, redoAvailable]); + } + + /** + * Notifies the native UI that the canvas has initialized. + * @param {boolean} success + * @return {Promise} + */ + onCanvasInitialized(success) { + return this.callApiFn('onCanvasInitialized', [success]); + } +} + +/** + * Class that implements the RequestHandler inside the Projector untrusted + * scheme for Annotator. + */ +export class UntrustedAnnotatorRequestHandler extends RequestHandler { + /** + * @param {!Window} parentWindow The embedder window from which requests + * come. + */ + constructor(parentWindow) { + super(null, TARGET_URL, TARGET_URL); + this.targetWindow_ = parentWindow; + + this.registerMethod('setTool', (args) => { + getAnnotatorElement().setTool(args[0]); + return true; + }); + + this.registerMethod('undo', () => { + getAnnotatorElement().undo(); + return true; + }); + + this.registerMethod('redo', () => { + getAnnotatorElement().redo(); + return true; + }); + + this.registerMethod('clear', () => { + getAnnotatorElement().clear(); + return true; + }); + } + + /** @override */ + targetWindow() { + return this.targetWindow_; + } +} + +/** + * This is a class that is used to setup the duplex communication channels + * between this origin, chrome-untrusted://projector/* and the embedder content. + */ +export class AnnotatorUntrustedCommFactory { + /** + * Creates the instances of PostMessageAPIClient and Requesthandler. + */ + static maybeCreateInstances() { + if (AnnotatorUntrustedCommFactory.client_ || + AnnotatorUntrustedCommFactory.requestHandler_) { return; } - annotatorPageRouter = browserProxy.getAnnotatorCallbackRouter(); + AnnotatorUntrustedCommFactory.client_ = + new TrustedAnnotatorClient(window.parent); - // Register for callbacks from the browser process. - annotatorPageRouter.undo.addListener(() => { - try { - getAnnotatorElement().undo(); - } catch (error) { - console.error('AnnotatorToolErrorType.UNDO_ERROR', error); - } - }); - annotatorPageRouter.redo.addListener(() => { - try { - getAnnotatorElement().redo(); - } catch (error) { - console.error('AnnotatorToolErrorType.REDO_ERROR', error); - } - }); - annotatorPageRouter.clear.addListener(() => { - try { - getAnnotatorElement().clear(); - } catch (error) { - console.error('AnnotatorToolErrorType.CLEAR_ERROR', error); - } - }); - annotatorPageRouter.setTool.addListener((tool) => { - try { - getAnnotatorElement().setTool(tool); - } catch (error) { - console.error('AnnotatorToolErrorType.SET_TOOL_ERROR', error); - } - }); - - // Pass calls to the browser process. + AnnotatorUntrustedCommFactory.requestHandler_ = + new UntrustedAnnotatorRequestHandler(window.parent); const elem = getAnnotatorElement(); elem.addUndoRedoListener((undoAvailable, redoAvailable) => { - browserProxy.onUndoRedoAvailabilityChanged(undoAvailable, redoAvailable); + AnnotatorUntrustedCommFactory.client_.onUndoRedoAvailabilityChanged( + undoAvailable, redoAvailable); }); elem.addCanvasInitializationCallback((success) => { - browserProxy.onCanvasInitialized(success); + AnnotatorUntrustedCommFactory.client_.onCanvasInitialized(success); }); } + + /** + * In order to use this class, please do the following (e.g. To notify when + * undo-redo becomes available): + * AnnotatorUntrustedCommFactory. + * getPostMessageAPIClient(). + * onUndoRedoAvailabilityChanged(true, true); + * @return {!TrustedAnnotatorClient} + */ + static getPostMessageAPIClient() { + // AnnotatorUntrustedCommFactory.client_ should be available. However to be + // on the cautious side create an instance here if getPostMessageAPIClient + // is triggered before the page finishes loading. + AnnotatorUntrustedCommFactory.maybeCreateInstances(); + return AnnotatorUntrustedCommFactory.client_; + } +} + +const observer = new MutationObserver(() => { + if (getAnnotatorElement()) { + // Create instances of the singletons(PostMessageAPIClient and + // RequestHandler) when the annotator element has been added to DOM tree. + AnnotatorUntrustedCommFactory.maybeCreateInstances(); + } }); observer.observe(document, {childList: true, subtree: true});
diff --git a/ash/webui/projector_app/resources/app/trusted/projector_browser_proxy.js b/ash/webui/projector_app/resources/app/trusted/projector_browser_proxy.js index 05d6833..600c9f3 100644 --- a/ash/webui/projector_app/resources/app/trusted/projector_browser_proxy.js +++ b/ash/webui/projector_app/resources/app/trusted/projector_browser_proxy.js
@@ -3,6 +3,7 @@ // found in the LICENSE file. import {sendWithPromise} from 'chrome://resources/ash/common/cr.m.js'; +import {addSingletonGetter} from 'chrome://resources/ash/common/cr_deprecated.js'; /** * To use the browser proxy, please import this module and call @@ -124,24 +125,9 @@ } /** - * @type {ProjectorBrowserProxyImpl} - */ -let browserProxy; - -/** * @implements {ProjectorBrowserProxy} */ export class ProjectorBrowserProxyImpl { - /** - * @returns {ProjectorBrowserProxyImpl} - */ - static getInstance() { - if (!browserProxy) { - browserProxy = new ProjectorBrowserProxyImpl(); - } - return browserProxy; - } - /** @override */ getAccounts() { return sendWithPromise('getAccounts'); @@ -216,3 +202,5 @@ return sendWithPromise('getVideo', [videoFileId, resourceKey]); } } + +addSingletonGetter(ProjectorBrowserProxyImpl);
diff --git a/ash/webui/projector_app/test/untrusted_annotator_page_handler_impl_unittest.cc b/ash/webui/projector_app/test/annotator_page_handler_impl_unittest.cc similarity index 65% rename from ash/webui/projector_app/test/untrusted_annotator_page_handler_impl_unittest.cc rename to ash/webui/projector_app/test/annotator_page_handler_impl_unittest.cc index b9aaf28..c0ecb750 100644 --- a/ash/webui/projector_app/test/untrusted_annotator_page_handler_impl_unittest.cc +++ b/ash/webui/projector_app/test/annotator_page_handler_impl_unittest.cc
@@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/webui/projector_app/untrusted_annotator_page_handler_impl.h" +#include "ash/webui/projector_app/annotator_page_handler_impl.h" #include "ash/public/cpp/projector/annotator_tool.h" #include "ash/public/cpp/test/mock_projector_controller.h" -#include "ash/webui/projector_app/mojom/untrusted_annotator.mojom.h" +#include "ash/webui/projector_app/mojom/annotator.mojom.h" #include "ash/webui/projector_app/public/mojom/annotator_structs.mojom.h" #include "ash/webui/projector_app/test/mock_app_client.h" #include "base/test/task_environment.h" @@ -23,14 +23,12 @@ namespace { // MOCK the annotator instance in the WebUI renderer. -class MockUntrustedAnnotatorPage - : public annotator::mojom::UntrustedAnnotatorPage { +class MockAnnotatorPage : public annotator::mojom::AnnotatorPage { public: - MockUntrustedAnnotatorPage() = default; - MockUntrustedAnnotatorPage(const MockUntrustedAnnotatorPage&) = delete; - MockUntrustedAnnotatorPage& operator=(const MockUntrustedAnnotatorPage&) = - delete; - ~MockUntrustedAnnotatorPage() override = default; + MockAnnotatorPage() = default; + MockAnnotatorPage(const MockAnnotatorPage&) = delete; + MockAnnotatorPage& operator=(const MockAnnotatorPage&) = delete; + ~MockAnnotatorPage() override = default; MOCK_METHOD0(Clear, void()); MOCK_METHOD0(Undo, void()); @@ -49,33 +47,32 @@ remote_->OnCanvasInitialized(success); } - mojo::Receiver<annotator::mojom::UntrustedAnnotatorPage>& receiver() { + mojo::Receiver<annotator::mojom::AnnotatorPage>& receiver() { return receiver_; } - mojo::Remote<annotator::mojom::UntrustedAnnotatorPageHandler>& remote() { + mojo::Remote<annotator::mojom::AnnotatorPageHandler>& remote() { return remote_; } private: - mojo::Receiver<annotator::mojom::UntrustedAnnotatorPage> receiver_{this}; - mojo::Remote<annotator::mojom::UntrustedAnnotatorPageHandler> remote_; + mojo::Receiver<annotator::mojom::AnnotatorPage> receiver_{this}; + mojo::Remote<annotator::mojom::AnnotatorPageHandler> remote_; }; } // namespace -class UntrustedAnnotatorPageHandlerImplTest : public testing::Test { +class AnnotatorPageHandlerImplTest : public testing::Test { public: - UntrustedAnnotatorPageHandlerImplTest() = default; - UntrustedAnnotatorPageHandlerImplTest( - const UntrustedAnnotatorPageHandlerImplTest&) = delete; - UntrustedAnnotatorPageHandlerImplTest& operator=( - const UntrustedAnnotatorPageHandlerImplTest&) = delete; - ~UntrustedAnnotatorPageHandlerImplTest() override = default; + AnnotatorPageHandlerImplTest() = default; + AnnotatorPageHandlerImplTest(const AnnotatorPageHandlerImplTest&) = delete; + AnnotatorPageHandlerImplTest& operator=(const AnnotatorPageHandlerImplTest&) = + delete; + ~AnnotatorPageHandlerImplTest() override = default; // testing::Test: void SetUp() override { - annotator_ = std::make_unique<MockUntrustedAnnotatorPage>(); - handler_ = std::make_unique<UntrustedAnnotatorPageHandlerImpl>( + annotator_ = std::make_unique<MockAnnotatorPage>(); + handler_ = std::make_unique<AnnotatorPageHandlerImpl>( annotator().remote().BindNewPipeAndPassReceiver(), annotator().receiver().BindNewPipeAndPassRemote(), /*web_ui=*/nullptr); @@ -86,9 +83,9 @@ handler_.reset(); } - UntrustedAnnotatorPageHandlerImpl& handler() { return *handler_; } + AnnotatorPageHandlerImpl& handler() { return *handler_; } MockProjectorController& controller() { return controller_; } - MockUntrustedAnnotatorPage& annotator() { return *annotator_; } + MockAnnotatorPage& annotator() { return *annotator_; } base::test::SingleThreadTaskEnvironment& task_environment() { return task_environment_; } @@ -96,13 +93,13 @@ private: base::test::SingleThreadTaskEnvironment task_environment_; - std::unique_ptr<MockUntrustedAnnotatorPage> annotator_; - std::unique_ptr<UntrustedAnnotatorPageHandlerImpl> handler_; + std::unique_ptr<MockAnnotatorPage> annotator_; + std::unique_ptr<AnnotatorPageHandlerImpl> handler_; MockProjectorController controller_; MockAppClient client_; }; -TEST_F(UntrustedAnnotatorPageHandlerImplTest, SetTool) { +TEST_F(AnnotatorPageHandlerImplTest, SetTool) { AnnotatorTool expected_tool; expected_tool.color = SkColorSetARGB(0xA1, 0xB2, 0xC3, 0xD4); expected_tool.size = 5; @@ -118,25 +115,25 @@ annotator().FlushReceiverForTesting(); } -TEST_F(UntrustedAnnotatorPageHandlerImplTest, Undo) { +TEST_F(AnnotatorPageHandlerImplTest, Undo) { EXPECT_CALL(annotator(), Undo()); handler().Undo(); annotator().FlushReceiverForTesting(); } -TEST_F(UntrustedAnnotatorPageHandlerImplTest, Redo) { +TEST_F(AnnotatorPageHandlerImplTest, Redo) { EXPECT_CALL(annotator(), Redo()); handler().Redo(); annotator().FlushReceiverForTesting(); } -TEST_F(UntrustedAnnotatorPageHandlerImplTest, Clear) { +TEST_F(AnnotatorPageHandlerImplTest, Clear) { EXPECT_CALL(annotator(), Clear()); handler().Clear(); annotator().FlushReceiverForTesting(); } -TEST_F(UntrustedAnnotatorPageHandlerImplTest, UndoRedoAvailabilityChanged) { +TEST_F(AnnotatorPageHandlerImplTest, UndoRedoAvailabilityChanged) { EXPECT_CALL(controller(), OnUndoRedoAvailabilityChanged(false, false)); annotator().SendUndoRedoAvailableChanged(false, false); @@ -148,7 +145,7 @@ annotator().FlushRemoteForTesting(); } -TEST_F(UntrustedAnnotatorPageHandlerImplTest, CanvasInitialized) { +TEST_F(AnnotatorPageHandlerImplTest, CanvasInitialized) { EXPECT_CALL(controller(), OnCanvasInitialized(true)); annotator().SendCanvasInitialized(true);
diff --git a/ash/webui/projector_app/test/mock_app_client.h b/ash/webui/projector_app/test/mock_app_client.h index f1ca1498..1a6b57fb 100644 --- a/ash/webui/projector_app/test/mock_app_client.h +++ b/ash/webui/projector_app/test/mock_app_client.h
@@ -55,10 +55,8 @@ void(const std::string&, const std::string&, ProjectorAppClient::OnGetVideoCallback)); - MOCK_METHOD1(SetAnnotatorPageHandler, - void(UntrustedAnnotatorPageHandlerImpl*)); - MOCK_METHOD1(ResetAnnotatorPageHandler, - void(UntrustedAnnotatorPageHandlerImpl*)); + MOCK_METHOD1(SetAnnotatorPageHandler, void(AnnotatorPageHandlerImpl*)); + MOCK_METHOD1(ResetAnnotatorPageHandler, void(AnnotatorPageHandlerImpl*)); MOCK_METHOD1(SetTool, void(const AnnotatorTool&)); MOCK_METHOD0(Clear, void()); MOCK_METHOD1(NotifyAppUIActive, void(bool active));
diff --git a/ash/webui/projector_app/trusted_projector_annotator_ui.cc b/ash/webui/projector_app/trusted_projector_annotator_ui.cc new file mode 100644 index 0000000..d8c2b3e9 --- /dev/null +++ b/ash/webui/projector_app/trusted_projector_annotator_ui.cc
@@ -0,0 +1,96 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/webui/projector_app/trusted_projector_annotator_ui.h" + +#include "ash/public/cpp/projector/projector_annotator_controller.h" +#include "ash/webui/grit/ash_projector_annotator_trusted_resources.h" +#include "ash/webui/grit/ash_projector_annotator_trusted_resources_map.h" +#include "ash/webui/grit/ash_projector_common_resources.h" +#include "ash/webui/grit/ash_projector_common_resources_map.h" +#include "ash/webui/projector_app/annotator_page_handler_impl.h" +#include "ash/webui/projector_app/public/cpp/projector_app_constants.h" +#include "components/prefs/pref_service.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_ui.h" +#include "content/public/browser/web_ui_data_source.h" +#include "content/public/common/url_constants.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" +#include "services/network/public/mojom/content_security_policy.mojom.h" +#include "url/gurl.h" + +namespace ash { + +namespace { + +void CreateAndAddProjectorAnnotatorHTMLSource(content::WebUI* web_ui) { + content::WebUIDataSource* source = content::WebUIDataSource::CreateAndAdd( + web_ui->GetWebContents()->GetBrowserContext(), + kChromeUIProjectorAnnotatorHost); + + // TODO(b/216523790): Split trusted annotator resources into a separate + // bundle. + source->AddResourcePaths( + base::make_span(kAshProjectorAnnotatorTrustedResources, + kAshProjectorAnnotatorTrustedResourcesSize)); + source->AddResourcePaths(base::make_span(kAshProjectorCommonResources, + kAshProjectorCommonResourcesSize)); + source->AddResourcePath( + "", IDR_ASH_PROJECTOR_ANNOTATOR_TRUSTED_ANNOTATOR_EMBEDDER_HTML); + + std::string csp = + std::string("frame-src ") + kChromeUIUntrustedAnnotatorUrl + ";"; + // Allow use of SharedArrayBuffer (required by wasm code in the iframe guest). + source->OverrideCrossOriginOpenerPolicy("same-origin"); + source->OverrideCrossOriginEmbedderPolicy("require-corp"); + + source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::FrameSrc, csp); + + source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::TrustedTypes, + "trusted-types polymer-html-literal " + "polymer-template-event-attribute-policy;"); +} + +} // namespace + +TrustedProjectorAnnotatorUI::TrustedProjectorAnnotatorUI( + content::WebUI* web_ui, + const GURL& url, + PrefService* pref_service) + : MojoBubbleWebUIController(web_ui, /*enable_chrome_send=*/false) { + CreateAndAddProjectorAnnotatorHTMLSource(web_ui); + + // The Annotator and Projector SWA embed contents in a sandboxed + // chrome-untrusted:// iframe. + web_ui->AddRequestableScheme(content::kChromeUIUntrustedScheme); +} + +TrustedProjectorAnnotatorUI::~TrustedProjectorAnnotatorUI() = default; + +void TrustedProjectorAnnotatorUI::BindInterface( + mojo::PendingReceiver<annotator::mojom::AnnotatorPageHandlerFactory> + receiver) { + if (receiver_.is_bound()) { + receiver_.reset(); + } + receiver_.Bind(std::move(receiver)); +} + +void TrustedProjectorAnnotatorUI::Create( + mojo::PendingReceiver<annotator::mojom::AnnotatorPageHandler> + annotator_handler, + mojo::PendingRemote<annotator::mojom::AnnotatorPage> annotator) { + // Multiple WebUIs (and therefore TrustedProjectorAnnotatorUIs) are created + // for a single Projector recording session, so a new AnnotatorMessageHandler + // needs to be created each time and attached to the new WebUI. The new + // handler is then referenced in ProjectorClientImpl. + handler_ = std::make_unique<AnnotatorPageHandlerImpl>( + std::move(annotator_handler), std::move(annotator), web_ui()); +} + +WEB_UI_CONTROLLER_TYPE_IMPL(TrustedProjectorAnnotatorUI) + +} // namespace ash
diff --git a/ash/webui/projector_app/trusted_projector_annotator_ui.h b/ash/webui/projector_app/trusted_projector_annotator_ui.h new file mode 100644 index 0000000..ea79b58 --- /dev/null +++ b/ash/webui/projector_app/trusted_projector_annotator_ui.h
@@ -0,0 +1,57 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_WEBUI_PROJECTOR_APP_TRUSTED_PROJECTOR_ANNOTATOR_UI_H_ +#define ASH_WEBUI_PROJECTOR_APP_TRUSTED_PROJECTOR_ANNOTATOR_UI_H_ + +#include "ash/webui/projector_app/mojom/annotator.mojom.h" +#include "content/public/browser/web_ui_controller.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" +#include "mojo/public/cpp/bindings/pending_remote.h" +#include "mojo/public/cpp/bindings/receiver.h" +#include "ui/webui/mojo_bubble_web_ui_controller.h" + +class GURL; +class PrefService; + +namespace ash { + +class AnnotatorPageHandlerImpl; + +// The implementation for the Projector annotator for screen recording +// annotations. +class TrustedProjectorAnnotatorUI + : public ui::MojoBubbleWebUIController, + annotator::mojom::AnnotatorPageHandlerFactory { + public: + TrustedProjectorAnnotatorUI(content::WebUI* web_ui, + const GURL& url, + PrefService* pref_service); + ~TrustedProjectorAnnotatorUI() override; + TrustedProjectorAnnotatorUI(const TrustedProjectorAnnotatorUI&) = delete; + TrustedProjectorAnnotatorUI& operator=(const TrustedProjectorAnnotatorUI&) = + delete; + + void BindInterface( + mojo::PendingReceiver<annotator::mojom::AnnotatorPageHandlerFactory> + factory); + + private: + WEB_UI_CONTROLLER_TYPE_DECL(); + + // annotator::mojom::AnnotatorPageHandlerFactory: + void Create( + mojo::PendingReceiver<annotator::mojom::AnnotatorPageHandler> + annotator_handler, + mojo::PendingRemote<annotator::mojom::AnnotatorPage> annotator) override; + + mojo::Receiver<annotator::mojom::AnnotatorPageHandlerFactory> receiver_{this}; + + // Handler for requests coming from the web_ui. + std::unique_ptr<AnnotatorPageHandlerImpl> handler_; +}; + +} // namespace ash + +#endif // ASH_WEBUI_PROJECTOR_APP_TRUSTED_PROJECTOR_ANNOTATOR_UI_H_
diff --git a/ash/webui/projector_app/untrusted_annotator_page_handler_impl.h b/ash/webui/projector_app/untrusted_annotator_page_handler_impl.h deleted file mode 100644 index 9f194f0..0000000 --- a/ash/webui/projector_app/untrusted_annotator_page_handler_impl.h +++ /dev/null
@@ -1,66 +0,0 @@ -// Copyright 2023 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_WEBUI_PROJECTOR_APP_UNTRUSTED_ANNOTATOR_PAGE_HANDLER_IMPL_H_ -#define ASH_WEBUI_PROJECTOR_APP_UNTRUSTED_ANNOTATOR_PAGE_HANDLER_IMPL_H_ - -#include "ash/public/cpp/projector/projector_annotator_controller.h" -#include "ash/webui/projector_app/mojom/untrusted_annotator.mojom.h" -#include "base/functional/callback.h" -#include "base/values.h" -#include "mojo/public/cpp/bindings/pending_receiver.h" -#include "mojo/public/cpp/bindings/pending_remote.h" -#include "mojo/public/cpp/bindings/receiver.h" -#include "mojo/public/cpp/bindings/remote.h" - -namespace content { -class WebUI; -} // namespace content - -namespace ash { - -struct AnnotatorTool; - -// Handles communication with the Annotator WebUI (i.e. -// chrome-untrusted://projector/annotator/annotator_embedder.html) -class UntrustedAnnotatorPageHandlerImpl - : public annotator::mojom::UntrustedAnnotatorPageHandler { - public: - UntrustedAnnotatorPageHandlerImpl( - mojo::PendingReceiver<annotator::mojom::UntrustedAnnotatorPageHandler> - annotator_handler, - mojo::PendingRemote<annotator::mojom::UntrustedAnnotatorPage> annotator, - content::WebUI* web_ui); - UntrustedAnnotatorPageHandlerImpl(const UntrustedAnnotatorPageHandlerImpl&) = - delete; - UntrustedAnnotatorPageHandlerImpl& operator=( - const UntrustedAnnotatorPageHandlerImpl&) = delete; - ~UntrustedAnnotatorPageHandlerImpl() override; - - // Called by ProjectorAppClient. - void SetTool(const AnnotatorTool& tool); - void Undo(); - void Redo(); - void Clear(); - - // annotator::mojom::AnnotatorHandler: - void OnUndoRedoAvailabilityChanged(bool undo_available, - bool redo_available) override; - void OnCanvasInitialized(bool success) override; - - content::WebUI* get_web_ui_for_test() { return web_ui_; } - - private: - mojo::Remote<annotator::mojom::UntrustedAnnotatorPage> annotator_remote_; - mojo::Receiver<annotator::mojom::UntrustedAnnotatorPageHandler> - annotator_handler_receiver_; - - // The WebUI that owns the TrustedProjectorAnnotatorUI that owns this - // instance. - content::WebUI* const web_ui_; -}; - -} // namespace ash - -#endif // ASH_WEBUI_PROJECTOR_APP_UNTRUSTED_ANNOTATOR_PAGE_HANDLER_IMPL_H_
diff --git a/ash/webui/projector_app/untrusted_projector_annotator_ui.cc b/ash/webui/projector_app/untrusted_projector_annotator_ui.cc index 3cb065d..10bab51 100644 --- a/ash/webui/projector_app/untrusted_projector_annotator_ui.cc +++ b/ash/webui/projector_app/untrusted_projector_annotator_ui.cc
@@ -10,7 +10,6 @@ #include "ash/webui/grit/ash_projector_common_resources_map.h" #include "ash/webui/media_app_ui/buildflags.h" #include "ash/webui/projector_app/public/cpp/projector_app_constants.h" -#include "ash/webui/projector_app/untrusted_annotator_page_handler_impl.h" #include "chromeos/grit/chromeos_projector_app_bundle_resources.h" #include "chromeos/grit/chromeos_projector_app_bundle_resources_map.h" #include "content/public/browser/web_contents.h" @@ -88,6 +87,9 @@ // Loading WASM in chrome-untrusted://projector-annotator/annotator/ink.js is // not compatible with trusted types. source->DisableTrustedTypesCSP(); + + source->AddFrameAncestor(GURL(kChromeUITrustedAnnotatorUrl)); + delegate->PopulateLoadTimeData(source); source->UseStringsJs(); } @@ -103,23 +105,4 @@ UntrustedProjectorAnnotatorUI::~UntrustedProjectorAnnotatorUI() = default; -void UntrustedProjectorAnnotatorUI::BindInterface( - mojo::PendingReceiver< - annotator::mojom::UntrustedAnnotatorPageHandlerFactory> factory) { - if (receiver_.is_bound()) { - receiver_.reset(); - } - receiver_.Bind(std::move(factory)); -} - -void UntrustedProjectorAnnotatorUI::Create( - mojo::PendingReceiver<annotator::mojom::UntrustedAnnotatorPageHandler> - annotator_handler, - mojo::PendingRemote<annotator::mojom::UntrustedAnnotatorPage> annotator) { - handler_ = std::make_unique<UntrustedAnnotatorPageHandlerImpl>( - std::move(annotator_handler), std::move(annotator), web_ui()); -} - -WEB_UI_CONTROLLER_TYPE_IMPL(UntrustedProjectorAnnotatorUI) - } // namespace ash
diff --git a/ash/webui/projector_app/untrusted_projector_annotator_ui.h b/ash/webui/projector_app/untrusted_projector_annotator_ui.h index 3616ac5..ead7586e 100644 --- a/ash/webui/projector_app/untrusted_projector_annotator_ui.h +++ b/ash/webui/projector_app/untrusted_projector_annotator_ui.h
@@ -5,10 +5,6 @@ #ifndef ASH_WEBUI_PROJECTOR_APP_UNTRUSTED_PROJECTOR_ANNOTATOR_UI_H_ #define ASH_WEBUI_PROJECTOR_APP_UNTRUSTED_PROJECTOR_ANNOTATOR_UI_H_ -#include "ash/webui/projector_app/mojom/untrusted_annotator.mojom.h" -#include "mojo/public/cpp/bindings/pending_receiver.h" -#include "mojo/public/cpp/bindings/pending_remote.h" -#include "mojo/public/cpp/bindings/receiver.h" #include "ui/webui/untrusted_web_ui_controller.h" namespace content { @@ -17,8 +13,6 @@ namespace ash { -class UntrustedAnnotatorPageHandlerImpl; - // A delegate used during data source creation to expose some //chrome // functionality to the data source class UntrustedProjectorAnnotatorUIDelegate { @@ -29,9 +23,7 @@ }; // The webui for chrome-untrusted://projector-annotator. -class UntrustedProjectorAnnotatorUI - : public ui::UntrustedWebUIController, - public annotator::mojom::UntrustedAnnotatorPageHandlerFactory { +class UntrustedProjectorAnnotatorUI : public ui::UntrustedWebUIController { public: // UntrustedProjectorAnnotatorUI does not store the passed in // `UntrustedProjectorAnnotatorUIDelegate`. @@ -42,26 +34,6 @@ UntrustedProjectorAnnotatorUI& operator=( const UntrustedProjectorAnnotatorUI&) = delete; ~UntrustedProjectorAnnotatorUI() override; - - void BindInterface( - mojo::PendingReceiver< - annotator::mojom::UntrustedAnnotatorPageHandlerFactory> factory); - - private: - // annotator::mojom::UntrustedAnnotatorPageHandlerFactory: - void Create( - mojo::PendingReceiver<annotator::mojom::UntrustedAnnotatorPageHandler> - annotator_handler, - mojo::PendingRemote<annotator::mojom::UntrustedAnnotatorPage> annotator) - override; - - mojo::Receiver<annotator::mojom::UntrustedAnnotatorPageHandlerFactory> - receiver_{this}; - - // Handler for requests coming from the web_ui. - std::unique_ptr<UntrustedAnnotatorPageHandlerImpl> handler_; - - WEB_UI_CONTROLLER_TYPE_DECL(); }; } // namespace ash
diff --git a/ash/webui/resources/BUILD.gn b/ash/webui/resources/BUILD.gn index f162d1f..04dd34df 100644 --- a/ash/webui/resources/BUILD.gn +++ b/ash/webui/resources/BUILD.gn
@@ -330,6 +330,14 @@ deps = [ "//ash/webui/projector_app/resources/annotator/untrusted:build_untrusted_grd" ] } +# Resources used by chrome://projector-annotator SWA. +ash_generated_grit("projector_annotator_trusted_resources") { + source = "$root_gen_dir/ash/webui/projector_app/resources/annotator/trusted/ash_projector_annotator_trusted_resources.grd" + deps = [ + "//ash/webui/projector_app/resources/annotator/trusted:build_trusted_grd", + ] +} + # Resources used by chrome://projector and chrome://projector-annotator SWA. ash_generated_grit("projector_common_resources") { source = "$root_gen_dir/ash/webui/projector_app/resources/common/ash_projector_common_resources.grd"
diff --git a/ash/webui/sample_system_web_app_ui/resources/trusted/component_playground.html b/ash/webui/sample_system_web_app_ui/resources/trusted/component_playground.html index 7d657a40..b5998865 100644 --- a/ash/webui/sample_system_web_app_ui/resources/trusted/component_playground.html +++ b/ash/webui/sample_system_web_app_ui/resources/trusted/component_playground.html
@@ -4,7 +4,6 @@ <meta charset="utf8"> <title>Component Playground</title> <link rel="stylesheet" href="chrome://theme/colors.css?sets=legacy,sys"> - $i18nRaw{ash_import_map_script} <style> html { background-color: var(--cros-bg-color);
diff --git a/ash/webui/sample_system_web_app_ui/sample_system_web_app_ui.cc b/ash/webui/sample_system_web_app_ui/sample_system_web_app_ui.cc index 8dd3dbb..61d2dc7 100644 --- a/ash/webui/sample_system_web_app_ui/sample_system_web_app_ui.cc +++ b/ash/webui/sample_system_web_app_ui/sample_system_web_app_ui.cc
@@ -24,43 +24,6 @@ namespace ash { -namespace { -// TODO(clamclamyan): Refactor into a better way e.g. generating the import map. -static constexpr const char kAshImportMapScript[] = R"( -<script type="importmap" nonce="%s"> -{ - "imports": { - "lit": "chrome://resources/mwc/lit/index.js", - "@material/": "chrome://resources/mwc/@material/", - "chrome://resources/mwc/lit/index.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directive.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/decorators.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/async-append.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/async-replace.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/cache.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/choose.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/class-map.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/guard.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/if-defined.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/join.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/keyed.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/live.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/map.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/range.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/ref.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/repeat.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/style-map.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/template-content.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/unsafe-html.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/unsafe-svg.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/until.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/when.js": "chrome://resources/mwc/lit/index.js" - } -} -</script> -)"; -} // namespace - SampleSystemWebAppUI::SampleSystemWebAppUI(content::WebUI* web_ui) : ui::MojoWebUIController(web_ui) { auto* browser_context = web_ui->GetWebContents()->GetBrowserContext(); @@ -92,24 +55,6 @@ network::mojom::CSPDirectiveName::TrustedTypes, "trusted-types lit-html worker-js-static;"); - // We use a 128-bit nonce. - std::vector<uint8_t> bytes(16); - crypto::RandBytes(bytes); - std::string nonce = base::Base64Encode(bytes); - - // Use the internationalization API to inject an import map <script> into - // the page. TODO(clamclamyan): Refactor into a better way. - trusted_source->AddString( - "ash_import_map_script", - base::StringPrintf(kAshImportMapScript, nonce.c_str())); - - static constexpr char script_src_csp[] = - "script-src chrome://resources 'self' 'nonce-%s';"; - - trusted_source->OverrideContentSecurityPolicy( - network::mojom::CSPDirectiveName::ScriptSrc, - base::StringPrintf(script_src_csp, nonce.c_str())); - // Add ability to request chrome-untrusted: URLs web_ui->AddRequestableScheme(content::kChromeUIUntrustedScheme);
diff --git a/ash/wm/float/float_controller_unittest.cc b/ash/wm/float/float_controller_unittest.cc index 234ce02..88b97ae4 100644 --- a/ash/wm/float/float_controller_unittest.cc +++ b/ash/wm/float/float_controller_unittest.cc
@@ -661,6 +661,24 @@ docked_magnifier_controller->GetMagnifierHeightForTesting()); } +// Tests that if we unminimize a window that was floated and another window has +// since been floated, unminimizing the window would not float it. +TEST_F(WindowFloatTest, UnminimzeWithFloatedWindow) { + // Create two windows and float the second one and then minimize it. + auto window1 = CreateAppWindow(); + auto window2 = CreateFloatedWindow(); + WindowState::Get(window2.get())->Minimize(); + + ASSERT_EQ(window1.get(), window_util::GetActiveWindow()); + PressAndReleaseKey(ui::VKEY_F, ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN); + ASSERT_TRUE(WindowState::Get(window1.get())->IsFloated()); + + // On unminimizing `window2`, we do not float it even if its pre-minimized + // state is floated, as doing so would unfloat `window1`. + WindowState::Get(window2.get())->Unminimize(); + EXPECT_TRUE(WindowState::Get(window1.get())->IsFloated()); +} + // Test that floated window are not blocking keyboard events when it's on an // inactive desk. TEST_F(WindowFloatTest, FloatWindowShouldNotBlockKeyboardEvents) {
diff --git a/ash/wm/overview/overview_item.cc b/ash/wm/overview/overview_item.cc index 6d84449..4d94019 100644 --- a/ash/wm/overview/overview_item.cc +++ b/ash/wm/overview/overview_item.cc
@@ -806,13 +806,13 @@ ->GetAnimator() ->is_animating(); if (should_show_shadow) { - // The shadow should match the size of the transformed window or preview - // window if unclipped. If clipped, the shadow should match the size of the - // item minus the border and header. - const gfx::RectF shadow_bounds = unclipped_size_ - ? GetWindowTargetBoundsWithInsets() - : GetUnclippedShadowBounds(); - SetShadowBounds(absl::make_optional(shadow_bounds)); + // The shadow should always match the size of the item minus the border and + // header instead of the transformed window or preview view, since for the + // window which has `kPillarBoxed` or `kLetterBoxed` dimension types, it + // doesn't occupy the whole remaining area of the overview item widget minus + // the header view in which case, the shadow looks weird if it matches the + // size of the transformed window or preview view. + SetShadowBounds(absl::make_optional(GetWindowTargetBoundsWithInsets())); } else { SetShadowBounds(absl::nullopt); }
diff --git a/ash/wm/overview/overview_session_unittest.cc b/ash/wm/overview/overview_session_unittest.cc index 6e402fcf..b30c1ba 100644 --- a/ash/wm/overview/overview_session_unittest.cc +++ b/ash/wm/overview/overview_session_unittest.cc
@@ -2580,6 +2580,13 @@ return boundsf.width() / boundsf.height(); }; + // Helper function which returns the ratio of the item width and height minus + // the header and window margin. + auto item_ratio = [](OverviewItem* item) { + gfx::RectF boundsf = item->GetWindowTargetBoundsWithInsets(); + return boundsf.width() / boundsf.height(); + }; + // Add three windows which in overview mode will be considered wide, tall and // normal. Set top view insets to 0 so it is easy to check the ratios of the // shadows match the ratios of the untransformed windows. @@ -2614,9 +2621,11 @@ EXPECT_TRUE(contains(tall_widget, tall_item)); EXPECT_TRUE(contains(normal_widget, normal_item)); - // Verify the shadows preserve the ratios of the original windows. - EXPECT_NEAR(shadow_ratio(wide_item), 4.f, 0.01f); - EXPECT_NEAR(shadow_ratio(tall_item), 0.25f, 0.01f); + // Verify the shadow of window with normal type preserves the ratio of the + // original window. Otherwise, it preserves the ratio of the item bounds minus + // the header of window margin. + EXPECT_NEAR(shadow_ratio(wide_item), item_ratio(wide_item), 0.01f); + EXPECT_NEAR(shadow_ratio(tall_item), item_ratio(tall_item), 0.01f); EXPECT_NEAR(shadow_ratio(normal_item), 1.f, 0.01f); // Verify all the shadows are within the bounds of their respective item @@ -2628,8 +2637,8 @@ EXPECT_TRUE(contains(tall_widget, tall_item)); EXPECT_TRUE(contains(normal_widget, normal_item)); - EXPECT_NEAR(shadow_ratio(wide_item), 4.f, 0.01f); - EXPECT_NEAR(shadow_ratio(tall_item), 0.25f, 0.01f); + EXPECT_NEAR(shadow_ratio(wide_item), item_ratio(wide_item), 0.01f); + EXPECT_NEAR(shadow_ratio(tall_item), item_ratio(tall_item), 0.01f); EXPECT_NEAR(shadow_ratio(normal_item), 1.f, 0.01f); // Test that leaving overview mode cleans up properly.
diff --git a/ash/wm/window_state.cc b/ash/wm/window_state.cc index 34b3df19..c89760c0 100644 --- a/ash/wm/window_state.cc +++ b/ash/wm/window_state.cc
@@ -814,6 +814,17 @@ : state->window_state_type; } + // Floated state has a limitation of one floated window per desk. So if we try + // to restore a window to floated state, and there is a existing floated + // window on the desk, we do not float the window as doing so would unfloat + // the existing floated window. + if (IsMinimized() && restore_state == WindowStateType::kFloated) { + if (window_util::GetFloatedWindowForActiveDesk()) { + return IsTabletModeEnabled() ? GetMaximizedOrCenteredWindowType() + : WindowStateType::kNormal; + } + } + // Different with the restore behaviors in clamshell mode, a window can not be // restored to kNormal window state if it's a maximize-able window. // We should still be able to restore a fullscreen/minimized/snapped window to
diff --git a/base/allocator/partition_alloc_support.cc b/base/allocator/partition_alloc_support.cc index 007bf25..6f09521 100644 --- a/base/allocator/partition_alloc_support.cc +++ b/base/allocator/partition_alloc_support.cc
@@ -827,11 +827,6 @@ // experiments. } -PartitionAllocSupport* PartitionAllocSupport::Get() { - static auto* singleton = new PartitionAllocSupport(); - return singleton; -} - PartitionAllocSupport::PartitionAllocSupport() = default; void PartitionAllocSupport::ReconfigureForTests() {
diff --git a/base/allocator/partition_alloc_support.h b/base/allocator/partition_alloc_support.h index fb9f67a..83dc0ed 100644 --- a/base/allocator/partition_alloc_support.h +++ b/base/allocator/partition_alloc_support.h
@@ -91,7 +91,10 @@ std::string stacktrace); #endif - static PartitionAllocSupport* Get(); + static PartitionAllocSupport* Get() { + static auto* singleton = new PartitionAllocSupport(); + return singleton; + } static BrpConfiguration GetBrpConfiguration(const std::string& process_type);
diff --git a/base/allocator/partition_allocator/partition_root.h b/base/allocator/partition_allocator/partition_root.h index d4124a2..62bc4d6 100644 --- a/base/allocator/partition_allocator/partition_root.h +++ b/base/allocator/partition_allocator/partition_root.h
@@ -1052,7 +1052,6 @@ // // This isn't a general purpose function. The caller is responsible for ensuring // that the ref-count is in place for this allocation. -PA_COMPONENT_EXPORT(PARTITION_ALLOC) PtrPosWithinAlloc IsPtrWithinSameAlloc(uintptr_t orig_address, uintptr_t test_address, size_t type_size);
diff --git a/base/json/json_writer.cc b/base/json/json_writer.cc index b08808a..9195e64 100644 --- a/base/json/json_writer.cc +++ b/base/json/json_writer.cc
@@ -11,10 +11,8 @@ #include "base/json/string_escape.h" #include "base/logging.h" -#include "base/notreached.h" #include "base/numerics/safe_conversions.h" #include "base/strings/string_number_conversions.h" -#include "base/strings/utf_string_conversions.h" #include "base/values.h" #include "build/build_config.h" @@ -38,16 +36,18 @@ size_t max_depth) { json->clear(); // Is there a better way to estimate the size of the output? - if (json->capacity() < 1024) + if (json->capacity() < 1024) { json->reserve(1024); + } JSONWriter writer(options, json, max_depth); bool result = node.Visit([&writer](const auto& member) { return writer.BuildJSONString(member, 0); }); - if (options & OPTIONS_PRETTY_PRINT) + if (options & OPTIONS_PRETTY_PRINT) { json->append(kPrettyPrintLineEnding); + } return result; } @@ -90,8 +90,9 @@ // Ensure that the number has a .0 if there's no decimal or 'e'. This // makes sure that when we read the JSON back, it's interpreted as a // real rather than an int. - if (real.find_first_of(".eE") == std::string::npos) + if (real.find_first_of(".eE") == std::string::npos) { real.append(".0"); + } // The JSON spec requires that non-integer values in the range (-1,1) // have a zero before the decimal point - ".52" is not valid, "0.52" is. @@ -119,32 +120,38 @@ bool JSONWriter::BuildJSONString(const Value::Dict& node, size_t depth) { internal::StackMarker depth_check(max_depth_, &stack_depth_); - if (depth_check.IsTooDeep()) + if (depth_check.IsTooDeep()) { return false; + } json_string_->push_back('{'); - if (pretty_print_) + if (pretty_print_) { json_string_->append(kPrettyPrintLineEnding); + } bool first_value_has_been_output = false; bool result = true; for (const auto [key, value] : node) { - if (omit_binary_values_ && value.type() == Value::Type::BINARY) + if (omit_binary_values_ && value.type() == Value::Type::BINARY) { continue; + } if (first_value_has_been_output) { json_string_->push_back(','); - if (pretty_print_) + if (pretty_print_) { json_string_->append(kPrettyPrintLineEnding); + } } - if (pretty_print_) + if (pretty_print_) { IndentLine(depth + 1U); + } EscapeJSONString(key, true, json_string_); json_string_->push_back(':'); - if (pretty_print_) + if (pretty_print_) { json_string_->push_back(' '); + } result &= value.Visit([this, depth = depth + 1](const auto& member) { return BuildJSONString(member, depth); @@ -154,8 +161,9 @@ } if (pretty_print_) { - if (first_value_has_been_output) + if (first_value_has_been_output) { json_string_->append(kPrettyPrintLineEnding); + } IndentLine(depth); } @@ -166,23 +174,27 @@ bool JSONWriter::BuildJSONString(const Value::List& node, size_t depth) { internal::StackMarker depth_check(max_depth_, &stack_depth_); - if (depth_check.IsTooDeep()) + if (depth_check.IsTooDeep()) { return false; + } json_string_->push_back('['); - if (pretty_print_) + if (pretty_print_) { json_string_->push_back(' '); + } bool first_value_has_been_output = false; bool result = true; for (const auto& value : node) { - if (omit_binary_values_ && value.type() == Value::Type::BINARY) + if (omit_binary_values_ && value.type() == Value::Type::BINARY) { continue; + } if (first_value_has_been_output) { json_string_->push_back(','); - if (pretty_print_) + if (pretty_print_) { json_string_->push_back(' '); + } } result &= value.Visit([this, depth](const auto& member) { @@ -192,8 +204,9 @@ first_value_has_been_output = true; } - if (pretty_print_) + if (pretty_print_) { json_string_->push_back(' '); + } json_string_->push_back(']'); return result; } @@ -202,4 +215,23 @@ json_string_->append(depth * 3U, ' '); } +absl::optional<std::string> WriteJson(ValueView node, size_t max_depth) { + std::string result; + if (!JSONWriter::Write(node, &result, max_depth)) { + return absl::nullopt; + } + return result; +} + +absl::optional<std::string> WriteJsonWithOptions(ValueView node, + uint32_t options, + size_t max_depth) { + std::string result; + if (!JSONWriter::WriteWithOptions(node, static_cast<int>(options), &result, + max_depth)) { + return absl::nullopt; + } + return result; +} + } // namespace base
diff --git a/base/json/json_writer.h b/base/json/json_writer.h index 6341a42..ddb943d9 100644 --- a/base/json/json_writer.h +++ b/base/json/json_writer.h
@@ -6,7 +6,7 @@ #define BASE_JSON_JSON_WRITER_H_ #include <stddef.h> - +#include <cstdint> #include <string> #include "base/base_export.h" @@ -14,28 +14,61 @@ #include "base/memory/raw_ptr.h" #include "base/strings/string_piece.h" #include "base/values.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { +enum JsonOptions { + // This option instructs the writer that if a Binary value is encountered, + // the value (and key if within a dictionary) will be omitted from the + // output, and success will be returned. Otherwise, if a binary value is + // encountered, failure will be returned. + OPTIONS_OMIT_BINARY_VALUES = 1 << 0, + + // This option instructs the writer to write doubles that have no fractional + // part as a normal integer (i.e., without using exponential notation + // or appending a '.0') as long as the value is within the range of a + // 64-bit int. + OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION = 1 << 1, + + // Return a slightly nicer formatted json string (pads with whitespace to + // help with readability). + OPTIONS_PRETTY_PRINT = 1 << 2, +}; + +// Given a root node, generates and returns a JSON string. +// +// Returns `absl::nullopt` if +// * the nesting depth exceeds `max_depth`, or +// * the JSON contains binary values. +BASE_EXPORT absl::optional<std::string> WriteJson( + ValueView node, + size_t max_depth = internal::kAbsoluteMaxDepth); + +// Given a root node, generates and returns a JSON string. +// The string is formatted according to `options` which is a bitmask of +// `JsonOptions`. +// +// Returns `absl::nullopt` if +// * the nesting depth exceeds `max_depth,` or +// * the JSON contains binary values +// (unless `JsonOptions::OPTIONS_OMIT_BINARY_VALUES` is passed). +BASE_EXPORT absl::optional<std::string> WriteJsonWithOptions( + ValueView node, + uint32_t options, + size_t max_depth = internal::kAbsoluteMaxDepth); + class BASE_EXPORT JSONWriter { public: - enum Options { - // This option instructs the writer that if a Binary value is encountered, - // the value (and key if within a dictionary) will be omitted from the - // output, and success will be returned. Otherwise, if a binary value is - // encountered, failure will be returned. - OPTIONS_OMIT_BINARY_VALUES = 1 << 0, - - // This option instructs the writer to write doubles that have no fractional - // part as a normal integer (i.e., without using exponential notation - // or appending a '.0') as long as the value is within the range of a - // 64-bit int. - OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION = 1 << 1, - - // Return a slightly nicer formatted json string (pads with whitespace to - // help with readability). - OPTIONS_PRETTY_PRINT = 1 << 2, - }; + using Options = JsonOptions; + // TODO: Once we support c++20 we replace these with + // `using enum ::JsonOptions`. + static constexpr auto OPTIONS_OMIT_BINARY_VALUES = + JsonOptions::OPTIONS_OMIT_BINARY_VALUES; + static constexpr auto OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION = + JsonOptions::OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION; + static constexpr auto OPTIONS_PRETTY_PRINT = + JsonOptions::OPTIONS_PRETTY_PRINT; JSONWriter(const JSONWriter&) = delete; JSONWriter& operator=(const JSONWriter&) = delete; @@ -46,12 +79,16 @@ // TODO(tc): Should we generate json if it would be invalid json (e.g., // |node| is not a dictionary/list Value or if there are inf/-inf float // values)? Return true on success and false on failure. + // + // Deprecated: use the standalone method `WriteJson()` instead. static bool Write(ValueView node, std::string* json, size_t max_depth = internal::kAbsoluteMaxDepth); // Same as above but with |options| which is a bunch of JSONWriter::Options // bitwise ORed together. Return true on success and false on failure. + // + // Deprecated: use the standalone method `WriteJsonWithOptions()` instead. static bool WriteWithOptions(ValueView node, int options, std::string* json,
diff --git a/base/json/json_writer_unittest.cc b/base/json/json_writer_unittest.cc index 8fc13292..0fc6da9 100644 --- a/base/json/json_writer_unittest.cc +++ b/base/json/json_writer_unittest.cc
@@ -6,160 +6,143 @@ #include "base/json/json_reader.h" #include "base/containers/span.h" -#include "base/memory/ptr_util.h" #include "base/strings/stringprintf.h" #include "base/values.h" #include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" + +#if BUILDFLAG(IS_WIN) +#include "base/strings/string_util.h" +#endif namespace base { -TEST(JSONWriterTest, BasicTypes) { - std::string output_js; +namespace { - // Test null. - EXPECT_TRUE(JSONWriter::Write(Value(), &output_js)); - EXPECT_EQ("null", output_js); - - // Test empty dict. - EXPECT_TRUE(JSONWriter::Write(Value(Value::Type::DICT), &output_js)); - EXPECT_EQ("{}", output_js); - - // Test empty list. - EXPECT_TRUE(JSONWriter::Write(Value(Value::Type::LIST), &output_js)); - EXPECT_EQ("[]", output_js); - - // Test integer values. - EXPECT_TRUE(JSONWriter::Write(Value(42), &output_js)); - EXPECT_EQ("42", output_js); - - // Test boolean values. - EXPECT_TRUE(JSONWriter::Write(Value(true), &output_js)); - EXPECT_EQ("true", output_js); - - // Test Real values should always have a decimal or an 'e'. - EXPECT_TRUE(JSONWriter::Write(Value(1.0), &output_js)); - EXPECT_EQ("1.0", output_js); - - // Test Real values in the range (-1, 1) must have leading zeros - EXPECT_TRUE(JSONWriter::Write(Value(0.2), &output_js)); - EXPECT_EQ("0.2", output_js); - - // Test Real values in the range (-1, 1) must have leading zeros - EXPECT_TRUE(JSONWriter::Write(Value(-0.8), &output_js)); - EXPECT_EQ("-0.8", output_js); - - // Test String values. - EXPECT_TRUE(JSONWriter::Write(Value("foo"), &output_js)); - EXPECT_EQ("\"foo\"", output_js); -} - -TEST(JSONWriterTest, NestedTypes) { - std::string output_js; - - // Writer unittests like empty list/dict nesting, - // list list nesting, etc. - Value::Dict root_dict; - Value::List list; - Value::Dict inner_dict; - inner_dict.Set("inner int", 10); - list.Append(std::move(inner_dict)); - Value::Dict empty_dict; - list.Append(std::move(empty_dict)); - list.Append(Value::List()); - list.Append(true); - root_dict.Set("list", Value(std::move(list))); - +std::string FixNewlines(const std::string& json) { // The pretty-printer uses a different newline style on Windows than on // other platforms. #if BUILDFLAG(IS_WIN) -#define JSON_NEWLINE "\r\n" + std::string result; + ReplaceChars(json, "\n", "\r\n", &result); + return result; #else -#define JSON_NEWLINE "\n" + return json; #endif +} + +} // namespace + +TEST(JsonWriterTest, BasicTypes) { + // Test null. + EXPECT_EQ(WriteJson(Value()), "null"); + + // Test empty dict. + EXPECT_EQ(WriteJson(Value(Value::Type::DICT)), "{}"); + + // Test empty list. + EXPECT_EQ(WriteJson(Value(Value::Type::LIST)), "[]"); + + // Test integer values. + EXPECT_EQ(WriteJson(Value(42)), "42"); + + // Test boolean values. + EXPECT_EQ(WriteJson(Value(true)), "true"); + + // Test Real values should always have a decimal or an 'e'. + EXPECT_EQ(WriteJson(Value(1.0)), "1.0"); + + // Test Real values in the range (-1, 1) must have leading zeros + EXPECT_EQ(WriteJson(Value(0.2)), "0.2"); + + // Test Real values in the range (-1, 1) must have leading zeros + EXPECT_EQ(WriteJson(Value(-0.8)), "-0.8"); + + // Test String values. + EXPECT_EQ(WriteJson(Value("foo")), "\"foo\""); +} + +TEST(JsonWriterTest, NestedTypes) { + // Writer unittests like empty list/dict nesting, + // list list nesting, etc. + auto dict = + Value::Dict().Set("list", Value::List() + .Append(Value::Dict().Set("inner int", 10)) + .Append(Value::Dict()) + .Append(Value::List()) + .Append(true)); + + EXPECT_EQ(WriteJson(dict), "{\"list\":[{\"inner int\":10},{},[],true]}"); // Test the pretty-printer. - EXPECT_TRUE(JSONWriter::Write(root_dict, &output_js)); - EXPECT_EQ("{\"list\":[{\"inner int\":10},{},[],true]}", output_js); - EXPECT_TRUE(JSONWriter::WriteWithOptions( - root_dict, JSONWriter::OPTIONS_PRETTY_PRINT, &output_js)); - EXPECT_EQ("{" JSON_NEWLINE " \"list\": [ {" JSON_NEWLINE - " \"inner int\": 10" JSON_NEWLINE " }, {" JSON_NEWLINE - " }, [ ], true ]" JSON_NEWLINE "}" JSON_NEWLINE, - output_js); - -#undef JSON_NEWLINE + EXPECT_EQ(WriteJsonWithOptions(dict, JSONWriter::OPTIONS_PRETTY_PRINT), + FixNewlines(R"({ + "list": [ { + "inner int": 10 + }, { + }, [ ], true ] +} +)")); } -TEST(JSONWriterTest, KeysWithPeriods) { - std::string output_js; +TEST(JsonWriterTest, KeysWithPeriods) { + EXPECT_EQ(WriteJson(Value::Dict() // + .Set("a.b", 3) + .Set("c", 2) + .Set("d.e.f", Value::Dict().Set("g.h.i.j", 1))), + R"({"a.b":3,"c":2,"d.e.f":{"g.h.i.j":1}})"); - Value::Dict period_dict; - period_dict.Set("a.b", 3); - period_dict.Set("c", 2); - Value::Dict period_dict2; - period_dict2.Set("g.h.i.j", 1); - period_dict.Set("d.e.f", std::move(period_dict2)); - EXPECT_TRUE(JSONWriter::Write(period_dict, &output_js)); - EXPECT_EQ("{\"a.b\":3,\"c\":2,\"d.e.f\":{\"g.h.i.j\":1}}", output_js); - - Value::Dict period_dict3; - period_dict3.SetByDottedPath("a.b", 2); - period_dict3.Set("a.b", 1); - EXPECT_TRUE(JSONWriter::Write(period_dict3, &output_js)); - EXPECT_EQ("{\"a\":{\"b\":2},\"a.b\":1}", output_js); + EXPECT_EQ(WriteJson(Value::Dict() // + .Set("a", Value::Dict().Set("b", 2)) + .Set("a.b", 1)), + R"({"a":{"b":2},"a.b":1})"); } -TEST(JSONWriterTest, BinaryValues) { - std::string output_js; +TEST(JsonWriterTest, BinaryValues) { + const auto kBinaryData = + base::make_span(reinterpret_cast<const uint8_t*>("asdf"), 4u); // Binary values should return errors unless suppressed via the - // OPTIONS_OMIT_BINARY_VALUES flag. - const auto kBufferSpan = - base::make_span(reinterpret_cast<const uint8_t*>("asdf"), 4u); - Value root(kBufferSpan); - EXPECT_FALSE(JSONWriter::Write(root, &output_js)); - EXPECT_TRUE(JSONWriter::WriteWithOptions( - root, JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js)); - EXPECT_TRUE(output_js.empty()); + // `OPTIONS_OMIT_BINARY_VALUES` flag. + EXPECT_EQ(WriteJson(Value(kBinaryData)), absl::nullopt); + EXPECT_EQ(WriteJsonWithOptions(Value(kBinaryData), + JsonOptions::OPTIONS_OMIT_BINARY_VALUES), + ""); - Value::List binary_list; - binary_list.Append(Value(kBufferSpan)); - binary_list.Append(5); - binary_list.Append(Value(kBufferSpan)); - binary_list.Append(2); - binary_list.Append(Value(kBufferSpan)); - EXPECT_FALSE(JSONWriter::Write(binary_list, &output_js)); - EXPECT_TRUE(JSONWriter::WriteWithOptions( - binary_list, JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js)); - EXPECT_EQ("[5,2]", output_js); + auto binary_list = Value::List() + .Append(Value(kBinaryData)) + .Append(5) + .Append(Value(kBinaryData)) + .Append(2) + .Append(Value(kBinaryData)); + EXPECT_EQ(WriteJson(binary_list), absl::nullopt); + EXPECT_EQ( + WriteJsonWithOptions(binary_list, JSONWriter::OPTIONS_OMIT_BINARY_VALUES), + "[5,2]"); - Value::Dict binary_dict; - binary_dict.Set("a", Value(kBufferSpan)); - binary_dict.Set("b", 5); - binary_dict.Set("c", Value(kBufferSpan)); - binary_dict.Set("d", 2); - binary_dict.Set("e", Value(kBufferSpan)); - EXPECT_FALSE(JSONWriter::Write(binary_dict, &output_js)); - EXPECT_TRUE(JSONWriter::WriteWithOptions( - binary_dict, JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js)); - EXPECT_EQ("{\"b\":5,\"d\":2}", output_js); + auto binary_dict = Value::Dict() + .Set("a", Value(kBinaryData)) + .Set("b", 5) + .Set("c", Value(kBinaryData)) + .Set("d", 2) + .Set("e", Value(kBinaryData)); + EXPECT_EQ(WriteJson(binary_dict), absl::nullopt); + EXPECT_EQ( + WriteJsonWithOptions(binary_dict, JSONWriter::OPTIONS_OMIT_BINARY_VALUES), + R"({"b":5,"d":2})"); } -TEST(JSONWriterTest, DoublesAsInts) { - std::string output_js; - +TEST(JsonWriterTest, DoublesAsInts) { // Test allowing a double with no fractional part to be written as an integer. Value double_value(1e10); - EXPECT_TRUE(JSONWriter::WriteWithOptions( - double_value, JSONWriter::OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION, - &output_js)); - EXPECT_EQ("10000000000", output_js); + EXPECT_EQ( + WriteJsonWithOptions(double_value, + JSONWriter::OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION), + "10000000000"); } -TEST(JSONWriterTest, StackOverflow) { - std::string output_js; - +TEST(JsonWriterTest, StackOverflow) { Value::List deep_list; const size_t max_depth = 100000; @@ -170,11 +153,12 @@ } Value deep_list_value(std::move(deep_list)); - EXPECT_FALSE(JSONWriter::Write(deep_list_value, &output_js)); - EXPECT_FALSE(JSONWriter::WriteWithOptions( - deep_list_value, JSONWriter::OPTIONS_PRETTY_PRINT, &output_js)); + EXPECT_EQ(WriteJson(deep_list_value), absl::nullopt); + EXPECT_EQ( + WriteJsonWithOptions(deep_list_value, JSONWriter::OPTIONS_PRETTY_PRINT), + absl::nullopt); - // We cannot just let deep_list tear down since it + // We cannot just let `deep_list` tear down since it // would cause a stack overflow. Therefore, we tear // down the deep list manually. deep_list = std::move(deep_list_value).TakeList(); @@ -185,7 +169,7 @@ } } -TEST(JSONWriterTest, TestMaxDepthWithValidNodes) { +TEST(JsonWriterTest, TestMaxDepthWithValidNodes) { // Create JSON to the max depth - 1. Nodes at that depth are still valid // for writing which matches the JSONParser logic. std::string nested_json; @@ -203,8 +187,49 @@ nested_json, JSON_ALLOW_TRAILING_COMMAS); EXPECT_TRUE(json_val.has_value()); const Value& value = *json_val; - std::string serialized; - EXPECT_TRUE(JSONWriter::Write(value, &serialized)); + EXPECT_NE(WriteJson(value), absl::nullopt); +} + +// Test that the JSONWriter::Write method still works. +TEST(JsonWriterTest, JSONWriterWriteSuccess) { + std::string output_js; + + EXPECT_TRUE( + JSONWriter::Write(base::Value::Dict().Set("key", "value"), &output_js)); + EXPECT_EQ(output_js, R"({"key":"value"})"); +} + +// Test that the JSONWriter::Write method still works. +TEST(JsonWriterTest, JSONWriterWriteFailure) { + std::string output_js; + + EXPECT_FALSE(JSONWriter::Write( + base::Value::Dict() // + .Set("key", + base::Value::Dict().Set("nested-key", base::Value::Dict())), + &output_js, /*max_depth=*/1)); +} + +// Test that the JSONWriter::WriteWithOptions method still works. +TEST(JsonWriterTest, JSONWriterWriteWithOptionsSuccess) { + std::string output_js; + EXPECT_TRUE(JSONWriter::WriteWithOptions( + base::Value::Dict().Set("key", "value"), JSONWriter::OPTIONS_PRETTY_PRINT, + &output_js)); + EXPECT_EQ(output_js, FixNewlines(R"({ + "key": "value" +} +)")); +} + +// Test that the JSONWriter::WriteWithOptions method still works. +TEST(JsonWriterTest, JSONWriterWriteWithOptionsFailure) { + std::string output_js; + + EXPECT_FALSE(JSONWriter::WriteWithOptions( + base::Value::Dict().Set( + "key", base::Value::Dict().Set("nested-key", base::Value::Dict())), + JSONWriter::OPTIONS_PRETTY_PRINT, &output_js, /*max_depth=*/1)); } } // namespace base
diff --git a/build/fuchsia/linux_internal.sdk.sha1 b/build/fuchsia/linux_internal.sdk.sha1 index 97488c0..45e3a1c 100644 --- a/build/fuchsia/linux_internal.sdk.sha1 +++ b/build/fuchsia/linux_internal.sdk.sha1
@@ -1 +1 @@ -12.20230327.2.1 +12.20230328.1.1
diff --git a/build_overrides/partition_alloc.gni b/build_overrides/partition_alloc.gni index 63e64ae..c2f7bd29 100644 --- a/build_overrides/partition_alloc.gni +++ b/build_overrides/partition_alloc.gni
@@ -38,8 +38,7 @@ # issues on some (e.g. Windows with shims, Android with non-universal symbol # wrapping), and has not been validated on others. # - Windows: debug CRT is not compatible, see below. -_disable_partition_alloc_everywhere = - (!is_linux && is_component_build) || (is_win && is_debug) +_disable_partition_alloc_everywhere = is_component_build || (is_win && is_debug) # - NaCl: No plans to support it. # - iOS: Depends on ios_partition_alloc_enabled.
diff --git a/cc/layers/texture_layer_impl_unittest.cc b/cc/layers/texture_layer_impl_unittest.cc index f9f3cbb..5c45c9d7 100644 --- a/cc/layers/texture_layer_impl_unittest.cc +++ b/cc/layers/texture_layer_impl_unittest.cc
@@ -58,7 +58,8 @@ gpu::Mailbox::GenerateForSharedImage(), GL_LINEAR, GL_TEXTURE_2D, gpu::SyncToken(gpu::CommandBufferNamespace::GPU_IO, gpu::CommandBufferId::FromUnsafeValue(0x234), 0x456), - layer_size, viz::RGBA_8888, false /* is_overlay_candidate */); + layer_size, viz::SinglePlaneFormat::kRGBA_8888, + false /* is_overlay_candidate */); TextureLayerImpl* texture_layer_impl = impl.AddLayer<TextureLayerImpl>(); texture_layer_impl->SetBounds(layer_size);
diff --git a/cc/test/fake_ui_resource_layer_tree_host_impl.cc b/cc/test/fake_ui_resource_layer_tree_host_impl.cc index 29cf576..abe5f5e 100644 --- a/cc/test/fake_ui_resource_layer_tree_host_impl.cc +++ b/cc/test/fake_ui_resource_layer_tree_host_impl.cc
@@ -30,8 +30,8 @@ data.resource_id_for_export = resource_provider()->ImportResource( viz::TransferableResource::MakeGpu( gpu::Mailbox::GenerateForSharedImage(), GL_LINEAR, GL_TEXTURE_2D, - gpu::SyncToken(), bitmap.GetSize(), viz::RGBA_8888, - false /* is_overlay_candidate */), + gpu::SyncToken(), bitmap.GetSize(), + viz::SinglePlaneFormat::kRGBA_8888, false /* is_overlay_candidate */), base::DoNothing()); data.opaque = bitmap.GetOpaque();
diff --git a/cc/test/pixel_test.cc b/cc/test/pixel_test.cc index 76480de..79d1dc7 100644 --- a/cc/test/pixel_test.cc +++ b/cc/test/pixel_test.cc
@@ -245,8 +245,8 @@ source.readPixels(info, mapping.memory(), info.minRowBytes(), 0, 0); return child_resource_provider_->ImportResource( - viz::TransferableResource::MakeSoftware(shared_bitmap_id, size, - viz::RGBA_8888), + viz::TransferableResource::MakeSoftware( + shared_bitmap_id, size, viz::SinglePlaneFormat::kRGBA_8888), base::DoNothing()); }
diff --git a/cc/test/render_pass_test_utils.cc b/cc/test/render_pass_test_utils.cc index 125c822..3ee5d75b5 100644 --- a/cc/test/render_pass_test_utils.cc +++ b/cc/test/render_pass_test_utils.cc
@@ -42,7 +42,8 @@ constexpr gfx::Size size(64, 64); auto transfer_resource = viz::TransferableResource::MakeGpu( gpu::Mailbox::GenerateForSharedImage(), GL_LINEAR, GL_TEXTURE_2D, - sync_token, size, viz::RGBA_8888, false /* is_overlay_candidate */); + sync_token, size, viz::SinglePlaneFormat::kRGBA_8888, + false /* is_overlay_candidate */); transfer_resource.color_space = std::move(color_space); return resource_provider->ImportResource(transfer_resource, base::DoNothing());
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 78d403d..cc26eda15 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -10689,7 +10689,8 @@ quad_visible_rect_(5, 5, 5, 5) { resource_id_ = resource_provider_->ImportResource( viz::TransferableResource::MakeSoftware( - viz::SharedBitmap::GenerateId(), gfx::Size(1, 1), viz::RGBA_8888), + viz::SharedBitmap::GenerateId(), gfx::Size(1, 1), + viz::SinglePlaneFormat::kRGBA_8888), base::DoNothing()); SetBounds(gfx::Size(10, 10)); SetDrawsContent(true);
diff --git a/cc/trees/layer_tree_host_perftest.cc b/cc/trees/layer_tree_host_perftest.cc index e1c54a74..a869cf6 100644 --- a/cc/trees/layer_tree_host_perftest.cc +++ b/cc/trees/layer_tree_host_perftest.cc
@@ -334,7 +334,7 @@ constexpr gfx::Size size(64, 64); viz::TransferableResource resource = viz::TransferableResource::MakeGpu( gpu_mailbox, GL_LINEAR, GL_TEXTURE_2D, next_sync_token, size, - viz::RGBA_8888, false /* is_overlay_candidate */); + viz::SinglePlaneFormat::kRGBA_8888, false /* is_overlay_candidate */); next_fence_sync_++; tab_contents_->SetTransferableResource(resource, std::move(callback));
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc index 357aa57..0cf91c8 100644 --- a/cc/trees/layer_tree_host_unittest_context.cc +++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -850,8 +850,8 @@ texture->SetIsDrawable(true); constexpr gfx::Size size(64, 64); auto resource = viz::TransferableResource::MakeGpu( - mailbox, GL_LINEAR, GL_TEXTURE_2D, sync_token, size, viz::RGBA_8888, - false /* is_overlay_candidate */); + mailbox, GL_LINEAR, GL_TEXTURE_2D, sync_token, size, + viz::SinglePlaneFormat::kRGBA_8888, false /* is_overlay_candidate */); texture->SetTransferableResource( resource, base::BindOnce(&LayerTreeHostContextTestDontUseLostResources:: EmptyReleaseCallback));
diff --git a/cc/trees/swap_promise.h b/cc/trees/swap_promise.h index 3fb3c2b..6711a7da 100644 --- a/cc/trees/swap_promise.h +++ b/cc/trees/swap_promise.h
@@ -30,7 +30,7 @@ // fails to send its new state to the output, SwapPromise::DidNotSwap() will // be called. Note that it is possible to activate, and subsequently not swap. // -// Promises complete afer either DidSwap() or DidNotSwap() is called, thus +// Promises complete after either DidSwap() or DidNotSwap() is called, thus // there are three possible call sequences: // DidNotSwap() // DidActivate() ; WillSwap(); DidSwap()
diff --git a/chrome/VERSION b/chrome/VERSION index b2291c7..adc9136d 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ MAJOR=114 MINOR=0 -BUILD=5680 +BUILD=5681 PATCH=0
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClient.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClient.java index a3cafb9..887efb9 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClient.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClient.java
@@ -160,7 +160,7 @@ public void onConnected(Origin origin, Connection service) throws RemoteException { Bundle commandArgs = new Bundle(); commandArgs.putString(ARG_NOTIFICATION_CHANNEL_NAME, channelName); - Bundle commandResult = service.sendExtraCommand( + Bundle commandResult = safeSendExtraCommand(service, COMMAND_CHECK_NOTIFICATION_PERMISSION, commandArgs, /*callback=*/null); boolean commandSuccess = commandResult == null ? false @@ -211,7 +211,7 @@ public void onConnected(Origin origin, Connection service) throws RemoteException { Bundle commandArgs = new Bundle(); commandArgs.putString(ARG_NOTIFICATION_CHANNEL_NAME, channelName); - Bundle commandResult = service.sendExtraCommand( + Bundle commandResult = safeSendExtraCommand(service, COMMAND_GET_NOTIFICATION_PERMISSION_REQUEST_PENDING_INTENT, commandArgs, /*callback=*/null); boolean commandSuccess = commandResult == null @@ -291,8 +291,7 @@ }); } }; - - Bundle executionResult = service.sendExtraCommand( + Bundle executionResult = safeSendExtraCommand(service, CHECK_LOCATION_PERMISSION_COMMAND_NAME, Bundle.EMPTY, resultCallback); // Set permission to false if the service does not know how to handle the // extraCommand or did not handle the command. @@ -321,9 +320,8 @@ public void onConnected(Origin origin, Connection service) throws RemoteException { Bundle args = new Bundle(); args.putBoolean(LOCATION_ARG_ENABLE_HIGH_ACCURACY, highAccuracy); - Bundle executionResult = service.sendExtraCommand( - START_LOCATION_COMMAND_NAME, args, locationCallback); - + Bundle executionResult = safeSendExtraCommand( + service, START_LOCATION_COMMAND_NAME, args, locationCallback); // Notify an error if the service does not know how to handle the extraCommand. if (executionResult == null || !executionResult.getBoolean(EXTRA_COMMAND_SUCCESS)) { notifyLocationUpdateError( @@ -341,8 +339,8 @@ public void stopLocationUpdates(String url) { connectAndExecute(Uri.parse(url), new ExecutionCallback() { @Override - public void onConnected(Origin origin, Connection service) throws RemoteException { - service.sendExtraCommand(STOP_LOCATION_COMMAND_NAME, Bundle.EMPTY, null); + public void onConnected(Origin origin, Connection service) { + safeSendExtraCommand(service, STOP_LOCATION_COMMAND_NAME, Bundle.EMPTY, null); } }); } @@ -503,4 +501,18 @@ error.putString("message", message); callback.onExtraCallback(EXTRA_NEW_LOCATION_ERROR_CALLBACK, error); } + + @Nullable + private Bundle safeSendExtraCommand(Connection service, String commandName, Bundle args, + TrustedWebActivityCallback callback) { + try { + return service.sendExtraCommand(commandName, args, callback); + } catch (Exception e) { + // Catching all exceptions is really bad, but we need it here, + // because Android exposes us to client bugs by throwing a variety + // of exceptions. See crbug.com/1426591. + Log.e(TAG, "There was an error with the client implementation", e); + return null; + } + } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentUiService.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentUiService.java index f72571d2..ba79181 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentUiService.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentUiService.java
@@ -51,7 +51,6 @@ import org.chromium.components.payments.JourneyLogger; import org.chromium.components.payments.PaymentApp; import org.chromium.components.payments.PaymentAppType; -import org.chromium.components.payments.PaymentFeatureList; import org.chromium.components.payments.PaymentOptionsUtils; import org.chromium.components.payments.PaymentRequestParams; import org.chromium.components.payments.PaymentUiServiceTestInterface; @@ -574,7 +573,6 @@ /** Sets the modifier for the order summary based on the given app, if any. */ private void updateOrderSummary(@Nullable PaymentApp app) { - if (!PaymentFeatureList.isEnabled(PaymentFeatureList.WEB_PAYMENTS_MODIFIERS)) return; if (mParams.hasClosed()) return; PaymentDetailsModifier modifier = getModifier(app); PaymentItem total = modifier == null ? null : modifier.total; @@ -614,7 +612,6 @@ /** Updates the modifiers for payment apps and order summary. */ private void updateAppModifiedTotals() { - if (!PaymentFeatureList.isEnabled(PaymentFeatureList.WEB_PAYMENTS_MODIFIERS)) return; if (mParams.hasClosed() || mParams.getMethodData().isEmpty()) return; if (mPaymentMethodsSection == null) return;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestRule.java b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestRule.java index caab79a..662a58e 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestRule.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestRule.java
@@ -45,7 +45,6 @@ import org.chromium.components.payments.PaymentAppFactoryDelegate; import org.chromium.components.payments.PaymentAppFactoryInterface; import org.chromium.components.payments.PaymentAppService; -import org.chromium.components.payments.PaymentFeatureList; import org.chromium.components.payments.PaymentRequestService; import org.chromium.components.payments.PaymentRequestService.PaymentRequestServiceObserverForTest; import org.chromium.content_public.browser.WebContents; @@ -119,10 +118,6 @@ */ /* package */ static final int FIRST_BILLING_ADDRESS = 1; - /** Command line flag to enable payment details modifiers in tests. */ - /* package */ static final String ENABLE_WEB_PAYMENTS_MODIFIERS = - "enable-features=" + PaymentFeatureList.WEB_PAYMENTS_MODIFIERS; - /** Command line flag to enable experimental web platform features in tests. */ /* package */ static final String ENABLE_EXPERIMENTAL_WEB_PLATFORM_FEATURES = "enable-experimental-web-platform-features";
diff --git a/chrome/app/os_settings_strings.grdp b/chrome/app/os_settings_strings.grdp index d374e00..cb366a9b 100644 --- a/chrome/app/os_settings_strings.grdp +++ b/chrome/app/os_settings_strings.grdp
@@ -279,12 +279,12 @@ </message> <if expr="reven"> <message name="IDS_OS_SETTINGS_SYNC_FEATURE_LABEL" desc="Label describing the OS sync feature."> - Your apps and settings will sync across all ChromeOS Flex devices where you are signed in with your Google account. For browser sync options, go to <ph name="LINK_BEGIN"><a></ph>Chrome settings<ph name="LINK_END"></a></ph>. + Your apps and settings will sync across all ChromeOS Flex devices where you are signed in with your Google account. For browser sync options, go to <ph name="LINK_BEGIN"><a href='#'></ph>Chrome settings<ph name="LINK_END"></a></ph>. </message> </if> <if expr="not reven"> <message name="IDS_OS_SETTINGS_SYNC_FEATURE_LABEL" desc="Label describing the OS sync feature."> - Your apps and settings will sync across all ChromeOS devices where you are signed in with your Google account. For browser sync options, go to <ph name="LINK_BEGIN"><a></ph>Chrome settings<ph name="LINK_END"></a></ph>. + Your apps and settings will sync across all ChromeOS devices where you are signed in with your Google account. For browser sync options, go to <ph name="LINK_BEGIN"><a href='#'></ph>Chrome settings<ph name="LINK_END"></a></ph>. </message> </if> <message name="IDS_OS_SETTINGS_SYNC_APPS_CHECKBOX_LABEL" desc="Label for the checkbox which enables syncing of apps across devices.">
diff --git a/chrome/app/theme/chrome_unscaled_resources.grd b/chrome/app/theme/chrome_unscaled_resources.grd index c80929b..21c18a95 100644 --- a/chrome/app/theme/chrome_unscaled_resources.grd +++ b/chrome/app/theme/chrome_unscaled_resources.grd
@@ -41,6 +41,10 @@ <include name="IDR_PRODUCT_LOGO_24PX_2X" file="google_chrome/chrome_24px_2x.svg" type="BINDATA" /> <!-- Used by lacros. --> <include name="IDR_PRODUCT_LOGO_256_CANARY" file="google_chrome/product_logo_256_canary.png" type="BINDATA" /> + <!-- Used by ChromeOS OOBE --> + <include name="IDR_CROS_OOBE_FIRST_ANIMATION" file="google_chrome/chromeos/oobe/project_simon/first_animation.json" type="BINDATA" /> + <include name="IDR_CROS_OOBE_PRODUCT_NAME" file="google_chrome/chromeos/oobe/project_simon/product_name.txt" type="BINDATA" /> + <include name="IDR_CROS_OOBE_WELCOME_BACKDROP" file="google_chrome/chromeos/oobe/project_simon/welcome_backdrop.svg" type="BINDATA" /> </if> <if expr="is_win"> <!-- External company logo, displayed in the Chrome Cleanup WebUI if
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 9552700b..af20f72 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -2174,6 +2174,7 @@ "//components/paint_preview/buildflags", "//components/paint_preview/features", "//components/password_manager/content/browser", + "//components/password_manager/content/common", "//components/password_manager/core/browser", "//components/password_manager/core/common", "//components/payments/content:utils",
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index 8463c92..3234109 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm
@@ -1674,7 +1674,7 @@ return dockMenu; if (IncognitoModePrefs::GetAvailability(profile->GetPrefs()) != - IncognitoModePrefs::Availability::kDisabled) { + policy::IncognitoModeAvailability::kDisabled) { titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_INCOGNITO_WINDOW_MAC); item.reset( [[NSMenuItem alloc] initWithTitle:titleStr
diff --git a/chrome/browser/app_controller_mac_browsertest.mm b/chrome/browser/app_controller_mac_browsertest.mm index aa82566..b94d0fd 100644 --- a/chrome/browser/app_controller_mac_browsertest.mm +++ b/chrome/browser/app_controller_mac_browsertest.mm
@@ -76,6 +76,7 @@ #include "components/account_id/account_id.h" #include "components/bookmarks/browser/bookmark_model.h" #include "components/bookmarks/test/bookmark_test_helpers.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/prefs/pref_service.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/web_contents.h" @@ -1033,7 +1034,7 @@ EXPECT_TRUE(BrowserList::GetInstance()->empty()); // Force incognito mode. IncognitoModePrefs::SetAvailability( - profile->GetPrefs(), IncognitoModePrefs::Availability::kForced); + profile->GetPrefs(), policy::IncognitoModeAvailability::kForced); // Simulate click on "New window". ui_test_utils::BrowserChangeObserver browser_added_observer( nullptr, ui_test_utils::BrowserChangeObserver::ChangeType::kAdded);
diff --git a/chrome/browser/apps/almanac_api_client/BUILD.gn b/chrome/browser/apps/almanac_api_client/BUILD.gn index c68a041..94b831c3 100644 --- a/chrome/browser/apps/almanac_api_client/BUILD.gn +++ b/chrome/browser/apps/almanac_api_client/BUILD.gn
@@ -19,6 +19,7 @@ "//base", "//chrome/browser:browser_process", "//chrome/browser/apps:user_type_filter", + "//chrome/browser/apps/almanac_api_client/proto", "//chrome/browser/profiles:profile", "//chrome/common:channel_info", "//chromeos/ash/components/system", @@ -37,6 +38,7 @@ deps = [ ":almanac_api_client", "//base", + "//chrome/browser/apps/almanac_api_client/proto", "//chrome/common:channel_info", "//chrome/test:test_support", "//components/language/core/browser",
diff --git a/chrome/browser/apps/almanac_api_client/device_info_manager.cc b/chrome/browser/apps/almanac_api_client/device_info_manager.cc index 0717d16..f95f755a 100644 --- a/chrome/browser/apps/almanac_api_client/device_info_manager.cc +++ b/chrome/browser/apps/almanac_api_client/device_info_manager.cc
@@ -9,6 +9,7 @@ #include "base/strings/string_util.h" #include "base/task/task_traits.h" #include "base/task/thread_pool.h" +#include "chrome/browser/apps/almanac_api_client/proto/client_context.pb.h" #include "chrome/browser/apps/user_type_filter.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile.h" @@ -20,6 +21,43 @@ #include "components/version_info/version_info.h" #include "third_party/abseil-cpp/absl/types/optional.h" +namespace { + +apps::proto::ClientDeviceContext::Channel ConvertChannelTypeToProto( + const version_info::Channel channel) { + switch (channel) { + case version_info::Channel::CANARY: + return apps::proto::ClientDeviceContext::CHANNEL_CANARY; + case version_info::Channel::DEV: + return apps::proto::ClientDeviceContext::CHANNEL_DEV; + case version_info::Channel::BETA: + return apps::proto::ClientDeviceContext::CHANNEL_BETA; + case version_info::Channel::STABLE: + return apps::proto::ClientDeviceContext::CHANNEL_STABLE; + case version_info::Channel::UNKNOWN: + // The "unknown" channel is used for builds without a channel (e.g. + // local builds). The API refers to this as "internal" to avoid confusion + // with the "unknown" default enum value. + return apps::proto::ClientDeviceContext::CHANNEL_INTERNAL; + } +} + +apps::proto::ClientUserContext::UserType ConvertStringUserTypeToProto( + const std::string& user_type) { + if (user_type == apps::kUserTypeUnmanaged) { + return apps::proto::ClientUserContext::USERTYPE_UNMANAGED; + } else if (user_type == apps::kUserTypeManaged) { + return apps::proto::ClientUserContext::USERTYPE_MANAGED; + } else if (user_type == apps::kUserTypeChild) { + return apps::proto::ClientUserContext::USERTYPE_CHILD; + } else if (user_type == apps::kUserTypeGuest) { + return apps::proto::ClientUserContext::USERTYPE_GUEST; + } + return apps::proto::ClientUserContext::USERTYPE_UNKNOWN; +} + +} // namespace + namespace apps { DeviceInfo::DeviceInfo() = default; @@ -30,6 +68,29 @@ DeviceInfo::~DeviceInfo() = default; +proto::ClientDeviceContext DeviceInfo::ToDeviceContext() const { + proto::ClientDeviceContext device_context; + + device_context.set_board(board); + device_context.set_model(model); + device_context.set_channel(ConvertChannelTypeToProto(version_info.channel)); + device_context.mutable_versions()->set_chrome_ash(version_info.ash_chrome); + device_context.mutable_versions()->set_chrome_os_platform( + version_info.platform); + device_context.set_hardware_id(hardware_id); + + return device_context; +} + +proto::ClientUserContext DeviceInfo::ToUserContext() const { + proto::ClientUserContext user_context; + + user_context.set_language(locale); + user_context.set_user_type(ConvertStringUserTypeToProto(user_type)); + + return user_context; +} + DeviceInfoManager::DeviceInfoManager(Profile* profile) : profile_(profile) {} DeviceInfoManager::~DeviceInfoManager() = default;
diff --git a/chrome/browser/apps/almanac_api_client/device_info_manager.h b/chrome/browser/apps/almanac_api_client/device_info_manager.h index a10194f..f2f3bc6 100644 --- a/chrome/browser/apps/almanac_api_client/device_info_manager.h +++ b/chrome/browser/apps/almanac_api_client/device_info_manager.h
@@ -12,6 +12,7 @@ #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "base/system/sys_info.h" +#include "chrome/browser/apps/almanac_api_client/proto/client_context.pb.h" #include "components/version_info/channel.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -35,6 +36,14 @@ DeviceInfo& operator=(const DeviceInfo& other); ~DeviceInfo(); + // Returns a ClientDeviceContext proto containing the device-specific fields + // from this DeviceInfo. + proto::ClientDeviceContext ToDeviceContext() const; + + // Returns a ClientUserContext proto containing the user-specific fields from + // this DeviceInfo. + proto::ClientUserContext ToUserContext() const; + // The board family of the device. e.g. "brya" std::string board;
diff --git a/chrome/browser/apps/almanac_api_client/device_info_manager_unittest.cc b/chrome/browser/apps/almanac_api_client/device_info_manager_unittest.cc index 4e1ece8..6b9c6c0 100644 --- a/chrome/browser/apps/almanac_api_client/device_info_manager_unittest.cc +++ b/chrome/browser/apps/almanac_api_client/device_info_manager_unittest.cc
@@ -8,6 +8,7 @@ #include "base/test/scoped_chromeos_version_info.h" #include "base/test/test_future.h" +#include "chrome/browser/apps/almanac_api_client/proto/client_context.pb.h" #include "chrome/browser/browser_process.h" #include "chrome/common/channel_info.h" #include "chrome/test/base/testing_profile.h" @@ -15,6 +16,7 @@ #include "chromeos/ash/components/system/statistics_provider.h" #include "components/language/core/browser/pref_names.h" #include "components/prefs/pref_service.h" +#include "components/version_info/channel.h" #include "content/public/test/browser_task_environment.h" #include "testing/gtest/include/gtest/gtest.h" @@ -61,7 +63,6 @@ DeviceInfo device_info = info_future.Take(); - // Values set above: ASSERT_EQ(device_info.board, "puff"); ASSERT_FALSE(device_info.model.empty()); ASSERT_EQ(device_info.user_type, "unmanaged"); @@ -83,4 +84,98 @@ ASSERT_EQ(device_info.locale, g_browser_process->GetApplicationLocale()); } +TEST_F(DeviceInfoManagerTest, DeviceInfoToProto) { + DeviceInfo device_info; + device_info.board = "brya"; + device_info.model = "taniks"; + device_info.hardware_id = "FOOBAR D0G-F4N-C1UB"; + device_info.user_type = "unmanaged"; + device_info.version_info.ash_chrome = "10.10.10"; + device_info.version_info.platform = "12345.0.0"; + device_info.version_info.channel = version_info::Channel::STABLE; + device_info.locale = "en-US"; + + proto::ClientDeviceContext device_context = device_info.ToDeviceContext(); + + EXPECT_EQ(device_context.board(), "brya"); + EXPECT_EQ(device_context.model(), "taniks"); + EXPECT_EQ(device_context.channel(), + apps::proto::ClientDeviceContext::CHANNEL_STABLE); + EXPECT_EQ(device_context.versions().chrome_ash(), "10.10.10"); + EXPECT_EQ(device_context.versions().chrome_os_platform(), "12345.0.0"); + EXPECT_EQ(device_context.hardware_id(), "FOOBAR D0G-F4N-C1UB"); + + proto::ClientUserContext user_context = device_info.ToUserContext(); + + EXPECT_EQ(user_context.language(), "en-US"); + EXPECT_EQ(user_context.user_type(), + apps::proto::ClientUserContext::USERTYPE_UNMANAGED); +} + +TEST_F(DeviceInfoManagerTest, UserTypeToProto) { + { + DeviceInfo info; + info.user_type = "unmanaged"; + EXPECT_EQ(info.ToUserContext().user_type(), + proto::ClientUserContext::USERTYPE_UNMANAGED); + } + { + DeviceInfo info; + info.user_type = "managed"; + EXPECT_EQ(info.ToUserContext().user_type(), + proto::ClientUserContext::USERTYPE_MANAGED); + } + { + DeviceInfo info; + info.user_type = "child"; + EXPECT_EQ(info.ToUserContext().user_type(), + proto::ClientUserContext::USERTYPE_CHILD); + } + { + DeviceInfo info; + info.user_type = "guest"; + EXPECT_EQ(info.ToUserContext().user_type(), + proto::ClientUserContext::USERTYPE_GUEST); + } + { + DeviceInfo info; + info.user_type = "dog"; + EXPECT_EQ(info.ToUserContext().user_type(), + proto::ClientUserContext::USERTYPE_UNKNOWN); + } +} + +TEST_F(DeviceInfoManagerTest, ChannelTypeToProto) { + { + DeviceInfo info; + info.version_info.channel = version_info::Channel::CANARY; + EXPECT_EQ(info.ToDeviceContext().channel(), + proto::ClientDeviceContext::CHANNEL_CANARY); + } + { + DeviceInfo info; + info.version_info.channel = version_info::Channel::DEV; + EXPECT_EQ(info.ToDeviceContext().channel(), + proto::ClientDeviceContext::CHANNEL_DEV); + } + { + DeviceInfo info; + info.version_info.channel = version_info::Channel::BETA; + EXPECT_EQ(info.ToDeviceContext().channel(), + proto::ClientDeviceContext::CHANNEL_BETA); + } + { + DeviceInfo info; + info.version_info.channel = version_info::Channel::STABLE; + EXPECT_EQ(info.ToDeviceContext().channel(), + proto::ClientDeviceContext::CHANNEL_STABLE); + } + { + DeviceInfo info; + info.version_info.channel = version_info::Channel::UNKNOWN; + EXPECT_EQ(info.ToDeviceContext().channel(), + proto::ClientDeviceContext::CHANNEL_INTERNAL); + } +} + } // namespace apps
diff --git a/chrome/browser/apps/app_preload_service/app_preload_server_connector.cc b/chrome/browser/apps/app_preload_service/app_preload_server_connector.cc index 2435e68..abe21da 100644 --- a/chrome/browser/apps/app_preload_service/app_preload_server_connector.cc +++ b/chrome/browser/apps/app_preload_service/app_preload_server_connector.cc
@@ -14,7 +14,6 @@ #include "chrome/browser/apps/almanac_api_client/proto/client_context.pb.h" #include "chrome/browser/apps/app_preload_service/preload_app_definition.h" #include "chrome/browser/apps/app_preload_service/proto/app_preload.pb.h" -#include "chrome/browser/apps/user_type_filter.h" #include "components/version_info/channel.h" #include "google_apis/google_api_keys.h" #include "net/base/net_errors.h" @@ -59,57 +58,10 @@ } )"); -apps::proto::ClientUserContext::UserType ConvertStringUserTypeToProto( - const std::string& user_type) { - if (user_type == apps::kUserTypeUnmanaged) { - return apps::proto::ClientUserContext::USERTYPE_UNMANAGED; - } else if (user_type == apps::kUserTypeManaged) { - return apps::proto::ClientUserContext::USERTYPE_MANAGED; - } else if (user_type == apps::kUserTypeChild) { - return apps::proto::ClientUserContext::USERTYPE_CHILD; - } else if (user_type == apps::kUserTypeGuest) { - return apps::proto::ClientUserContext::USERTYPE_GUEST; - } - return apps::proto::ClientUserContext::USERTYPE_UNKNOWN; -} - -apps::proto::ClientDeviceContext::Channel ConvertChannelTypeToProto( - const version_info::Channel channel) { - switch (channel) { - case version_info::Channel::CANARY: - return apps::proto::ClientDeviceContext::CHANNEL_CANARY; - case version_info::Channel::DEV: - return apps::proto::ClientDeviceContext::CHANNEL_DEV; - case version_info::Channel::BETA: - return apps::proto::ClientDeviceContext::CHANNEL_BETA; - case version_info::Channel::STABLE: - return apps::proto::ClientDeviceContext::CHANNEL_STABLE; - case version_info::Channel::UNKNOWN: - return apps::proto::ClientDeviceContext::CHANNEL_INTERNAL; - } -} - std::string BuildGetAppsForFirstLoginRequestBody(const apps::DeviceInfo& info) { apps::proto::AppPreloadListRequest request_proto; - - apps::proto::ClientDeviceContext* device_context = - request_proto.mutable_device_context(); - - device_context->set_board(info.board); - device_context->set_model(info.model); - device_context->set_channel( - ConvertChannelTypeToProto(info.version_info.channel)); - device_context->mutable_versions()->set_chrome_ash( - info.version_info.ash_chrome); - device_context->mutable_versions()->set_chrome_os_platform( - info.version_info.platform); - device_context->set_hardware_id(info.hardware_id); - - apps::proto::ClientUserContext* user_context = - request_proto.mutable_user_context(); - - user_context->set_language(info.locale); - user_context->set_user_type(ConvertStringUserTypeToProto(info.user_type)); + *request_proto.mutable_device_context() = info.ToDeviceContext(); + *request_proto.mutable_user_context() = info.ToUserContext(); return request_proto.SerializeAsString(); }
diff --git a/chrome/browser/apps/app_preload_service/app_preload_server_connector_unittest.cc b/chrome/browser/apps/app_preload_service/app_preload_server_connector_unittest.cc index 955128b..d109aff 100644 --- a/chrome/browser/apps/app_preload_service/app_preload_server_connector_unittest.cc +++ b/chrome/browser/apps/app_preload_service/app_preload_server_connector_unittest.cc
@@ -54,15 +54,11 @@ }; TEST_F(AppPreloadServerConnectorTest, GetAppsForFirstLoginRequest) { + // We only set enough fields to verify that context protos are attached to the + // request. DeviceInfo device_info; device_info.board = "brya"; - device_info.model = "taniks"; - device_info.hardware_id = "FOOBAR D0G-F4N-C1UB"; device_info.user_type = "unmanaged"; - device_info.version_info.ash_chrome = "10.10.10"; - device_info.version_info.platform = "12345.0.0"; - device_info.version_info.channel = version_info::Channel::STABLE; - device_info.locale = "en-US"; std::string method; std::string method_override_header; @@ -90,16 +86,8 @@ ASSERT_TRUE(request.ParseFromString(body)); EXPECT_EQ(request.device_context().board(), "brya"); - EXPECT_EQ(request.device_context().model(), "taniks"); - EXPECT_EQ(request.device_context().channel(), - apps::proto::ClientDeviceContext::CHANNEL_STABLE); - EXPECT_EQ(request.user_context().language(), "en-US"); EXPECT_EQ(request.user_context().user_type(), apps::proto::ClientUserContext::USERTYPE_UNMANAGED); - EXPECT_EQ(request.device_context().versions().chrome_ash(), "10.10.10"); - EXPECT_EQ(request.device_context().versions().chrome_os_platform(), - "12345.0.0"); - EXPECT_EQ(request.device_context().hardware_id(), "FOOBAR D0G-F4N-C1UB"); } TEST_F(AppPreloadServerConnectorTest, GetAppsForFirstLoginSuccessfulResponse) {
diff --git a/chrome/browser/apps/app_service/menu_util.cc b/chrome/browser/apps/app_service/menu_util.cc index 4eccb2a..c5d0ed6 100644 --- a/chrome/browser/apps/app_service/menu_util.cc +++ b/chrome/browser/apps/app_service/menu_util.cc
@@ -19,6 +19,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_features.h" #include "chrome/grit/generated_resources.h" +#include "components/policy/core/common/policy_pref_names.h" #include "content/public/common/content_features.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/image_model.h" @@ -206,7 +207,7 @@ // "Normal" windows are not allowed when incognito is enforced. if (IncognitoModePrefs::GetAvailability(profile->GetPrefs()) != - IncognitoModePrefs::Availability::kForced) { + policy::IncognitoModeAvailability::kForced) { AddCommandItem(ash::APP_CONTEXT_MENU_NEW_WINDOW, IDS_APP_LIST_NEW_WINDOW, menu_items); } @@ -214,7 +215,7 @@ // Incognito windows are not allowed when incognito is disabled. if (!profile->IsOffTheRecord() && IncognitoModePrefs::GetAvailability(profile->GetPrefs()) != - IncognitoModePrefs::Availability::kDisabled) { + policy::IncognitoModeAvailability::kDisabled) { AddCommandItem(ash::APP_CONTEXT_MENU_NEW_INCOGNITO_WINDOW, IDS_APP_LIST_NEW_INCOGNITO_WINDOW, menu_items); }
diff --git a/chrome/browser/ash/BUILD.gn b/chrome/browser/ash/BUILD.gn index a268f58..3254f8c 100644 --- a/chrome/browser/ash/BUILD.gn +++ b/chrome/browser/ash/BUILD.gn
@@ -3829,6 +3829,7 @@ "//chromeos/ash/components/dbus/oobe_config", "//chromeos/ash/components/dbus/patchpanel", "//chromeos/ash/components/dbus/pciguard", + "//chromeos/ash/components/dbus/printscanmgr", "//chromeos/ash/components/dbus/private_computing", "//chromeos/ash/components/dbus/rgbkbd", "//chromeos/ash/components/dbus/rmad",
diff --git a/chrome/browser/ash/app_list/launcher_search_iph_browsertest.cc b/chrome/browser/ash/app_list/launcher_search_iph_browsertest.cc index 6373c4f..7fabcdd 100644 --- a/chrome/browser/ash/app_list/launcher_search_iph_browsertest.cc +++ b/chrome/browser/ash/app_list/launcher_search_iph_browsertest.cc
@@ -3,6 +3,7 @@ // found in the LICENSE file. #include "ash/app_list/app_list_public_test_util.h" +#include "ash/app_list/views/app_list_bubble_view.h" #include "ash/app_list/views/assistant/assistant_test_api_impl.h" #include "ash/app_list/views/launcher_search_iph_view.h" #include "ash/app_list/views/search_box_view.h" @@ -14,6 +15,7 @@ #include "base/run_loop.h" #include "base/scoped_observation.h" #include "chrome/browser/ash/app_list/app_list_client_impl.h" +#include "chrome/browser/ash/app_list/search/search_controller.h" #include "chrome/browser/ui/ash/assistant/assistant_test_mixin.h" #include "chrome/test/base/mixin_based_in_process_browser_test.h" #include "components/feature_engagement/public/feature_constants.h" @@ -62,13 +64,23 @@ } raw_ptr<views::View> launcher_search_iph_view = - search_box_view->GetViewByID(ash::LauncherSearchIphView::kViewId); + search_box_view->GetViewByID(ash::LauncherSearchIphView::ViewId::kSelf); if (!launcher_search_iph_view) { return false; } return launcher_search_iph_view->GetVisible(); } + +void Click(raw_ptr<views::View> view) { + ASSERT_TRUE(view); + + ui::test::EventGenerator event_generator( + view->GetWidget()->GetNativeWindow()->GetRootWindow()); + event_generator.MoveMouseToInHost(view->GetBoundsInScreen().CenterPoint()); + event_generator.ClickLeftButton(); +} + } // namespace class AppListIphBrowserTest : public MixinBasedInProcessBrowserTest { @@ -88,7 +100,7 @@ ash::AssistantTestApiImpl test_api_impl_; }; -class AppListIphBrowerTestWithDemoMode : public AppListIphBrowserTest { +class AppListIphBrowserTestWithDemoMode : public AppListIphBrowserTest { public: void SetUpCommandLine(base::CommandLine* command_line) override { scoped_iph_feature_list_ = @@ -99,9 +111,39 @@ MixinBasedInProcessBrowserTest::SetUpCommandLine(command_line); } + protected: + void OpenAppListWithIph() { + ASSERT_TRUE(!app_list_client_impl_); + ASSERT_TRUE(!search_box_view_); + + app_list_client_impl_ = AppListClientImpl::GetInstance(); + app_list_client_impl_->UpdateProfile(); + + app_list_client_impl_->ShowAppList(ash::AppListShowSource::kSearchKey); + // We dispatch mouse events to interact with UI. Wait animation completion + // to reliably dispatch those events. + ash::AppListTestApi().WaitForBubbleWindow( + /*wait_for_opening_animation=*/true); + search_box_view_ = ash::GetSearchBoxView(); + ASSERT_TRUE(search_box_view_); + // There is an async call for checking IPH trigger condition. + ViewWaiter(search_box_view_, ash::LauncherSearchIphView::ViewId::kSelf) + .Run(); + ASSERT_TRUE(IsLauncherSearchIphViewVisible()); + } + + raw_ptr<AppListClientImpl> app_list_client_impl() { + return app_list_client_impl_; + } + + raw_ptr<ash::SearchBoxView> search_box_view() { return search_box_view_; } + private: std::unique_ptr<feature_engagement::test::ScopedIphFeatureList> scoped_iph_feature_list_; + + raw_ptr<AppListClientImpl> app_list_client_impl_ = nullptr; + raw_ptr<ash::SearchBoxView> search_box_view_ = nullptr; }; IN_PROC_BROWSER_TEST_F(AppListIphBrowserTest, @@ -115,43 +157,25 @@ EXPECT_FALSE(IsLauncherSearchIphViewVisible()); } -IN_PROC_BROWSER_TEST_F(AppListIphBrowerTestWithDemoMode, LauncherSearchIph) { - raw_ptr<AppListClientImpl> client_impl = AppListClientImpl::GetInstance(); - client_impl->UpdateProfile(); - - client_impl->ShowAppList(ash::AppListShowSource::kSearchKey); - ash::AppListTestApi().WaitForBubbleWindow( - /*wait_for_opening_animation=*/false); - raw_ptr<ash::SearchBoxView> search_box_view = ash::GetSearchBoxView(); - ASSERT_TRUE(search_box_view); - // There is an async call for checking IPH trigger condition. - ViewWaiter(search_box_view, ash::LauncherSearchIphView::kViewId).Run(); +IN_PROC_BROWSER_TEST_F(AppListIphBrowserTestWithDemoMode, LauncherSearchIph) { + OpenAppListWithIph(); EXPECT_TRUE(IsLauncherSearchIphViewVisible()); // Dismiss the app list and show it again. IPH won't be shown this time. Note // that this is IPH demo mode behavior. - client_impl->DismissView(); - ASSERT_FALSE(client_impl->GetAppListWindow()); + app_list_client_impl()->DismissView(); + ASSERT_FALSE(app_list_client_impl()->GetAppListWindow()); - client_impl->ShowAppList(ash::AppListShowSource::kSearchKey); + app_list_client_impl()->ShowAppList(ash::AppListShowSource::kSearchKey); ash::AppListTestApi().WaitForBubbleWindow( /*wait_for_opening_animation=*/false); EXPECT_FALSE(IsLauncherSearchIphViewVisible()); } -IN_PROC_BROWSER_TEST_F(AppListIphBrowerTestWithDemoMode, +IN_PROC_BROWSER_TEST_F(AppListIphBrowserTestWithDemoMode, LauncherSearchIphSearch) { - raw_ptr<AppListClientImpl> client_impl = AppListClientImpl::GetInstance(); - client_impl->UpdateProfile(); - - client_impl->ShowAppList(ash::AppListShowSource::kSearchKey); - ash::AppListTestApi().WaitForBubbleWindow( - /*wait_for_opening_animation=*/false); - raw_ptr<ash::SearchBoxView> search_box_view = ash::GetSearchBoxView(); - ASSERT_TRUE(search_box_view); - // There is an async call for checking IPH trigger condition. - ViewWaiter(search_box_view, ash::LauncherSearchIphView::kViewId).Run(); + OpenAppListWithIph(); EXPECT_TRUE(IsLauncherSearchIphViewVisible()); // Do search and confirm that the IPH gets dismissed. @@ -159,30 +183,44 @@ EXPECT_FALSE(IsLauncherSearchIphViewVisible()); } -IN_PROC_BROWSER_TEST_F(AppListIphBrowerTestWithDemoMode, +IN_PROC_BROWSER_TEST_F(AppListIphBrowserTestWithDemoMode, LauncherSearchIphAssistant) { - raw_ptr<AppListClientImpl> client_impl = AppListClientImpl::GetInstance(); - client_impl->UpdateProfile(); - - client_impl->ShowAppList(ash::AppListShowSource::kSearchKey); - ash::AppListTestApi().WaitForBubbleWindow( - /*wait_for_opening_animation=*/false); - raw_ptr<ash::SearchBoxView> search_box_view = ash::GetSearchBoxView(); - ASSERT_TRUE(search_box_view); - // There is an async call for checking IPH trigger condition. - ViewWaiter(search_box_view, ash::LauncherSearchIphView::kViewId).Run(); - EXPECT_TRUE(IsLauncherSearchIphViewVisible()); + OpenAppListWithIph(); // Clicks Assistant button to open Assistant UI and confirm that IPH gets // dismissed. raw_ptr<views::ImageButton> assistant_button = - search_box_view->assistant_button(); + search_box_view()->assistant_button(); ASSERT_TRUE(assistant_button); - ui::test::EventGenerator event_generator( - assistant_button->GetWidget()->GetNativeWindow()->GetRootWindow()); - event_generator.MoveMouseToInHost( - assistant_button->GetBoundsInScreen().CenterPoint()); - event_generator.ClickLeftButton(); + Click(assistant_button); EXPECT_FALSE(IsLauncherSearchIphViewVisible()); } + +IN_PROC_BROWSER_TEST_F(AppListIphBrowserTestWithDemoMode, ClickChip) { + OpenAppListWithIph(); + + raw_ptr<views::View> chip = search_box_view()->GetViewByID( + ash::LauncherSearchIphView::ViewId::kChipStart); + ASSERT_TRUE(chip); + Click(chip); + + EXPECT_EQ(u"Weather", + app_list_client_impl()->search_controller()->get_query()); + EXPECT_EQ(ash::AppListBubblePage::kSearch, + ash::GetAppListBubbleView()->current_page_for_test()); + EXPECT_FALSE(IsLauncherSearchIphViewVisible()); +} + +IN_PROC_BROWSER_TEST_F(AppListIphBrowserTestWithDemoMode, ClickAssistant) { + OpenAppListWithIph(); + + raw_ptr<views::View> assistant_button = search_box_view()->GetViewByID( + ash::LauncherSearchIphView::ViewId::kAssistant); + ASSERT_TRUE(assistant_button); + Click(assistant_button); + + EXPECT_EQ(ash::AppListBubblePage::kAssistant, + ash::GetAppListBubbleView()->current_page_for_test()); + EXPECT_FALSE(IsLauncherSearchIphViewVisible()); +}
diff --git a/chrome/browser/ash/app_list/search/system_info/cpu_answer_result.cc b/chrome/browser/ash/app_list/search/system_info/cpu_answer_result.cc new file mode 100644 index 0000000..e91e839 --- /dev/null +++ b/chrome/browser/ash/app_list/search/system_info/cpu_answer_result.cc
@@ -0,0 +1,69 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ash/app_list/search/system_info/cpu_answer_result.h" + +#include "ash/public/cpp/app_list/app_list_types.h" +#include "ash/public/cpp/power_utils.h" +#include "base/functional/callback.h" +#include "chrome/browser/ash/app_list/search/system_info/cpu_data.h" +#include "chrome/browser/ash/app_list/search/system_info/system_info_answer_result.h" +#include "chrome/browser/ash/app_list/search/system_info/system_info_util.h" + +namespace app_list { +namespace { + +constexpr int kCpuUsageRefreshIntervalInSeconds = 1; +using AnswerCardInfo = ::ash::SystemInfoAnswerCardData; + +} // namespace + +CpuAnswerResult::CpuAnswerResult( + Profile* profile, + const std::u16string& query, + const std::string& url_path, + const gfx::ImageSkia& icon, + double relevance_score, + const std::u16string& title, + const std::u16string& description, + SystemInfoCategory system_info_category, + const AnswerCardInfo& answer_card_info, + SystemInfoCardProvider::UpdateCpuResultCallback callback, + std::unique_ptr<base::RepeatingTimer> timer, + SystemInfoCardProvider* provider) + : SystemInfoAnswerResult(profile, + query, + url_path, + icon, + relevance_score, + title, + description, + system_info_category, + answer_card_info), + callback_(std::move(callback)), + timer_(std::move(timer)), + provider_(provider) { + provider_->AddCpuDataObserver(this); + timer_->Start(FROM_HERE, base::Seconds(kCpuUsageRefreshIntervalInSeconds), + base::BindRepeating(&CpuAnswerResult::UpdateResult, + weak_factory_.GetWeakPtr())); +} + +CpuAnswerResult::~CpuAnswerResult() { + timer_->Stop(); + if (provider_ && this->IsInObserverList()) { + provider_->RemoveCpuDataObserver(this); + } +} + +void CpuAnswerResult::OnCpuDataUpdated(const std::u16string& title, + const std::u16string& description) { + UpdateTitleAndDetails(title, description); +} + +void CpuAnswerResult::UpdateResult() { + callback_.Run(/*create_result=*/false); +} + +} // namespace app_list
diff --git a/chrome/browser/ash/app_list/search/system_info/cpu_answer_result.h b/chrome/browser/ash/app_list/search/system_info/cpu_answer_result.h new file mode 100644 index 0000000..7171e15 --- /dev/null +++ b/chrome/browser/ash/app_list/search/system_info/cpu_answer_result.h
@@ -0,0 +1,51 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_ASH_APP_LIST_SEARCH_SYSTEM_INFO_CPU_ANSWER_RESULT_H_ +#define CHROME_BROWSER_ASH_APP_LIST_SEARCH_SYSTEM_INFO_CPU_ANSWER_RESULT_H_ + +#include "ash/public/cpp/app_list/app_list_types.h" +#include "base/functional/callback.h" +#include "base/timer/timer.h" +#include "chrome/browser/ash/app_list/search/system_info/cpu_data.h" +#include "chrome/browser/ash/app_list/search/system_info/system_info_answer_result.h" +#include "chrome/browser/ash/app_list/search/system_info/system_info_card_provider.h" + +namespace app_list { + +class CpuAnswerResult : public SystemInfoAnswerResult, + public SystemInfoCardProvider::CpuDataObserver { + public: + CpuAnswerResult(Profile* profile, + const std::u16string& query, + const std::string& url_path, + const gfx::ImageSkia& icon, + double relevance_score, + const std::u16string& title, + const std::u16string& description, + SystemInfoCategory system_info_category, + const ash::SystemInfoAnswerCardData& answer_card_info, + SystemInfoCardProvider::UpdateCpuResultCallback callback, + std::unique_ptr<base::RepeatingTimer> timer, + SystemInfoCardProvider* provider); + + ~CpuAnswerResult() override; + + CpuAnswerResult(const CpuAnswerResult& other) = delete; + CpuAnswerResult& operator=(const CpuAnswerResult& other) = delete; + + void OnCpuDataUpdated(const std::u16string& title, + const std::u16string& description) override; + void UpdateResult(); + + private: + SystemInfoCardProvider::UpdateCpuResultCallback callback_; + std::unique_ptr<base::RepeatingTimer> timer_; + SystemInfoCardProvider* provider_; + base::WeakPtrFactory<CpuAnswerResult> weak_factory_{this}; +}; + +} // namespace app_list + +#endif // CHROME_BROWSER_ASH_APP_LIST_SEARCH_SYSTEM_INFO_CPU_ANSWER_RESULT_H_
diff --git a/chrome/browser/ash/app_list/search/system_info/system_info_card_provider.cc b/chrome/browser/ash/app_list/search/system_info/system_info_card_provider.cc index 8cca2543..b813037 100644 --- a/chrome/browser/ash/app_list/search/system_info/system_info_card_provider.cc +++ b/chrome/browser/ash/app_list/search/system_info/system_info_card_provider.cc
@@ -17,6 +17,7 @@ #include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/ash/app_list/search/common/icon_constants.h" #include "chrome/browser/ash/app_list/search/system_info/battery_answer_result.h" +#include "chrome/browser/ash/app_list/search/system_info/cpu_answer_result.h" #include "chrome/browser/ash/app_list/search/system_info/cpu_data.h" #include "chrome/browser/ash/app_list/search/system_info/cpu_usage_data.h" #include "chrome/browser/ash/app_list/search/system_info/system_info_answer_result.h" @@ -79,6 +80,7 @@ base::BindOnce(&SystemInfoCardProvider::OnProbeServiceDisconnect, weak_factory_.GetWeakPtr())); StartObservingCalculators(); + cpu_usage_timer_ = std::make_unique<base::RepeatingTimer>(); // TODO(b/261867385): We manually load the icon from the local codebase as // the icon load from proxy is flaky. When the flakiness if solved, we can @@ -111,7 +113,7 @@ UpdateMemoryUsage(); break; case SystemInfoInputType::kCPU: - UpdateCpuUsage(); + UpdateCpuUsage(/*create_result=*/true); break; case SystemInfoInputType::kVersion: UpdateChromeOsVersion(); @@ -220,7 +222,8 @@ weak_factory_.GetWeakPtr())); } -void SystemInfoCardProvider::OnCpuUsageUpdated(TelemetryInfoPtr info_ptr) { +void SystemInfoCardProvider::OnCpuUsageUpdated(bool create_result, + TelemetryInfoPtr info_ptr) { if (info_ptr.is_null()) { LOG(ERROR) << "Null response from croshealthd::ProbeTelemetryInfo."; return; @@ -260,36 +263,47 @@ PopulateAverageScaledClockSpeed(*cpu_info, *new_cpu_usage.get()); previous_cpu_usage_data_ = new_cpu_usage_data; - cpu_usage_ = std::move(new_cpu_usage); - std::u16string title = l10n_util::GetStringFUTF16( - IDS_ASH_CPU_IN_LAUNCHER_TITLE, cpu_usage_->GetPercentUsageTotalString()); + std::u16string title = + l10n_util::GetStringFUTF16(IDS_ASH_CPU_IN_LAUNCHER_TITLE, + new_cpu_usage->GetPercentUsageTotalString()); std::u16string description = l10n_util::GetStringFUTF16( IDS_ASH_CPU_IN_LAUNCHER_DESCRIPTION, - base::NumberToString16(cpu_usage_->GetAverageCpuTempCelsius()), + base::NumberToString16(new_cpu_usage->GetAverageCpuTempCelsius()), // Provide the frequency in GHz and round the value to 2 decimal places. base::NumberToString16( static_cast<double>( - cpu_usage_->GetScalingAverageCurrentFrequencyKhz() / 10000) / + new_cpu_usage->GetScalingAverageCurrentFrequencyKhz() / 10000) / 100)); - AnswerCardInfo answer_card_info( - ash::SystemInfoAnswerCardDisplayType::kTextCard); - SearchProvider::Results new_results; - new_results.emplace_back(std::make_unique<SystemInfoAnswerResult>( - profile_, last_query_, /*url_path=*/"", diagnostics_icon_, relevance_, - title, description, - SystemInfoAnswerResult::SystemInfoCategory::kDiagnostics, - answer_card_info)); - SwapResults(&new_results); + if (create_result) { + AnswerCardInfo answer_card_info( + ash::SystemInfoAnswerCardDisplayType::kTextCard); + SearchProvider::Results new_results; + DCHECK(cpu_usage_timer_); + new_results.emplace_back(std::make_unique<CpuAnswerResult>( + profile_, last_query_, /*url_path=*/"", diagnostics_icon_, relevance_, + title, description, + SystemInfoAnswerResult::SystemInfoCategory::kDiagnostics, + answer_card_info, + base::BindRepeating(&SystemInfoCardProvider::UpdateCpuUsage, + weak_factory_.GetWeakPtr()), + std::move(cpu_usage_timer_), this)); + SwapResults(&new_results); + cpu_usage_timer_ = std::make_unique<base::RepeatingTimer>(); + } else { + for (auto& observer : cpu_observers_) { + observer.OnCpuDataUpdated(title, description); + } + } } -void SystemInfoCardProvider::UpdateCpuUsage() { +void SystemInfoCardProvider::UpdateCpuUsage(bool create_result) { BindCrosHealthdProbeServiceIfNecessary(); probe_service_->ProbeTelemetryInfo( {ProbeCategories::kCpu}, base::BindOnce(&SystemInfoCardProvider::OnCpuUsageUpdated, - weak_factory_.GetWeakPtr())); + weak_factory_.GetWeakPtr(), create_result)); } void SystemInfoCardProvider::UpdateBatteryInfo() { @@ -517,4 +531,17 @@ SwapResults(&new_results); } +void SystemInfoCardProvider::AddCpuDataObserver(CpuDataObserver* observer) { + cpu_observers_.AddObserver(observer); +} + +void SystemInfoCardProvider::RemoveCpuDataObserver(CpuDataObserver* observer) { + cpu_observers_.RemoveObserver(observer); +} + +void SystemInfoCardProvider::SetCpuUsageTimerForTesting( + std::unique_ptr<base::RepeatingTimer> timer) { + cpu_usage_timer_ = std::move(timer); +} + } // namespace app_list
diff --git a/chrome/browser/ash/app_list/search/system_info/system_info_card_provider.h b/chrome/browser/ash/app_list/search/system_info/system_info_card_provider.h index f0bfcbd..70771be 100644 --- a/chrome/browser/ash/app_list/search/system_info/system_info_card_provider.h +++ b/chrome/browser/ash/app_list/search/system_info/system_info_card_provider.h
@@ -10,6 +10,7 @@ #include <vector> #include "base/memory/weak_ptr.h" +#include "base/timer/timer.h" #include "chrome/browser/ash/app_list/search/search_provider.h" #include "chrome/browser/ash/app_list/search/system_info/battery_health.h" #include "chrome/browser/ash/app_list/search/system_info/cpu_data.h" @@ -34,6 +35,15 @@ class SystemInfoCardProvider : public SearchProvider, public ash::settings::SizeCalculator::Observer { public: + using UpdateCpuResultCallback = base::RepeatingCallback<void(bool)>; + // Implemented by clients that wish to be updated periodically about the + // cpu usage of the device. + class CpuDataObserver : public base::CheckedObserver { + public: + virtual void OnCpuDataUpdated(const std::u16string& title, + const std::u16string& description) = 0; + }; + explicit SystemInfoCardProvider(Profile* profile); ~SystemInfoCardProvider() override; @@ -50,6 +60,12 @@ const ash::settings::SizeCalculator::CalculationType& calculation_type, int64_t total_bytes) override; + // Adds and removes the Cpu Data observer. + virtual void AddCpuDataObserver(CpuDataObserver* observer); + virtual void RemoveCpuDataObserver(CpuDataObserver* observer); + + void SetCpuUsageTimerForTesting(std::unique_ptr<base::RepeatingTimer> timer); + private: void BindCrosHealthdProbeServiceIfNecessary(); void OnProbeServiceDisconnect(); @@ -60,8 +76,9 @@ void OnMemoryUsageUpdated( ash::cros_healthd::mojom::TelemetryInfoPtr info_ptr); - void UpdateCpuUsage(); - void OnCpuUsageUpdated(ash::cros_healthd::mojom::TelemetryInfoPtr info_ptr); + void UpdateCpuUsage(bool create_result); + void OnCpuUsageUpdated(bool create_result, + ash::cros_healthd::mojom::TelemetryInfoPtr info_ptr); void UpdateBatteryInfo(); void OnBatteryInfoUpdated( @@ -104,11 +121,13 @@ std::string chromeOS_version_{""}; CpuUsageData previous_cpu_usage_data_{CpuUsageData()}; ash::cros_healthd::mojom::MemoryInfo* memory_info_{nullptr}; - std::unique_ptr<CpuData> cpu_usage_{nullptr}; std::unique_ptr<BatteryHealth> battery_health_{nullptr}; gfx::ImageSkia os_settings_icon_; gfx::ImageSkia diagnostics_icon_; std::vector<SystemInfoKeywordInput> keywords_; + std::unique_ptr<base::RepeatingTimer> cpu_usage_timer_; + + base::ObserverList<SystemInfoCardProvider::CpuDataObserver> cpu_observers_; base::WeakPtrFactory<SystemInfoCardProvider> weak_factory_{this}; };
diff --git a/chrome/browser/ash/app_list/search/system_info/system_info_card_provider_unittest.cc b/chrome/browser/ash/app_list/search/system_info/system_info_card_provider_unittest.cc index 9cc67b7..bc74bac 100644 --- a/chrome/browser/ash/app_list/search/system_info/system_info_card_provider_unittest.cc +++ b/chrome/browser/ash/app_list/search/system_info/system_info_card_provider_unittest.cc
@@ -18,6 +18,7 @@ #include "base/system/sys_info.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/scoped_running_on_chromeos.h" +#include "base/timer/mock_timer.h" #include "chrome/browser/ash/app_list/search/system_info/system_info_util.h" #include "chrome/browser/ash/app_list/search/test/test_search_controller.h" #include "chrome/browser/ash/file_manager/fake_disk_mount_manager.h" @@ -113,29 +114,6 @@ /*memory_info=*/nullptr); } -// Sets the CpuUsage response on cros_healthd. `usage_data` should contain one -// entry for each logical cpu. -void SetCrosHealthdCpuUsageResponse( - const std::vector<CpuUsageData>& usage_data) { - // Use fake temp and scaled clock speed data since none was supplied. - const std::vector<uint32_t> scaled_clock_speeds(usage_data.size(), 10000); - SetCrosHealthdCpuResponse(usage_data, {50}, scaled_clock_speeds); -} - -void SetCrosHealthdCpuTemperatureResponse( - const std::vector<int32_t>& cpu_temps) { - // Use fake usage_data and scaled clock speed data since none was supplied. - SetCrosHealthdCpuResponse({CpuUsageData(1000, 1000, 1000)}, cpu_temps, - {10000}); -} - -void SetCrosHealthdCpuScalingResponse(const std::vector<uint32_t>& cpu_speeds) { - // Use fake temp and usage_data data since none was supplied. - const std::vector<CpuUsageData> usage_data(cpu_speeds.size(), - CpuUsageData(1000, 1000, 1000)); - SetCrosHealthdCpuResponse(usage_data, {50}, cpu_speeds); -} - void SetCrosHealthdMemoryUsageResponse(uint32_t total_memory_kib, uint32_t free_memory_kib, uint32_t available_memory_kib) { @@ -418,17 +396,21 @@ } TEST_F(SystemInfoCardProviderTest, Cpu) { + // Setup Timer + auto timer = std::make_unique<base::MockRepeatingTimer>(); + auto* timer_ptr = timer.get(); + provider_->SetCpuUsageTimerForTesting(std::move(timer)); + int temp_1 = 40; int temp_2 = 50; int temp_3 = 15; - uint32_t core_1_speed = 4000; - uint32_t core_2_speed = 5000; + uint32_t core_1_speed = 4000000; + uint32_t core_2_speed = 2000000; CpuUsageData core_1(1000, 1000, 1000); CpuUsageData core_2(2000, 2000, 2000); - SetCrosHealthdCpuUsageResponse({core_1, core_2}); - SetCrosHealthdCpuScalingResponse({core_1_speed, core_2_speed}); - SetCrosHealthdCpuTemperatureResponse({temp_1, temp_2, temp_3}); + SetCrosHealthdCpuResponse({core_1, core_2}, {temp_1, temp_2, temp_3}, + {core_1_speed, core_2_speed}); StartSearch(u"cpu"); Wait(); @@ -452,8 +434,42 @@ ASSERT_EQ(results()[0]->details_text_vector().size(), 1u); const auto& details = results()[0]->details_text_vector()[0]; ASSERT_EQ(details.GetType(), ash::SearchResultTextItemType::kString); - EXPECT_EQ(details.GetText(), u"Temperature: 35°C - Current speed: 0.01GHz"); + EXPECT_EQ(details.GetText(), u"Temperature: 35°C - Current speed: 3GHz"); EXPECT_TRUE(details.GetTextTags().empty()); + + int new_temp_1 = 20; + int new_temp_2 = 30; + int new_temp_3 = 10; + core_1_speed = 5000000; + core_2_speed = 6000000; + + CpuUsageData core_1_delta(3000, 2500, 4500); + CpuUsageData core_2_delta(1000, 5500, 3500); + + SetCrosHealthdCpuResponse({core_1 + core_1_delta, core_2 + core_2_delta}, + {new_temp_1, new_temp_2, new_temp_3}, + {core_1_speed, core_2_speed}); + + timer_ptr->Fire(); + Wait(); + + EXPECT_EQ(title.GetText(), u"CPU current usage: 60%"); + EXPECT_EQ(details.GetText(), u"Temperature: 20°C - Current speed: 5.5GHz"); + + SetCrosHealthdCpuResponse({core_1 + core_1_delta + core_1_delta, + core_2 + core_2_delta + core_2_delta}, + {new_temp_1, new_temp_2, new_temp_3}, + {core_1_speed, core_2_speed}); + + StartSearch(u"cpu usage"); + Wait(); + + ASSERT_FALSE(results().empty()); + EXPECT_EQ(results().size(), 1u); + const auto& title2 = results()[0]->title_text_vector()[0]; + EXPECT_EQ(title2.GetText(), u"CPU current usage: 60%"); + const auto& details2 = results()[0]->details_text_vector()[0]; + EXPECT_EQ(details2.GetText(), u"Temperature: 20°C - Current speed: 5.5GHz"); } TEST_F(SystemInfoCardProviderTest, CpuProbeError) {
diff --git a/chrome/browser/ash/app_list/search/system_info/system_info_util.h b/chrome/browser/ash/app_list/search/system_info/system_info_util.h index eba57e5..d145a04 100644 --- a/chrome/browser/ash/app_list/search/system_info/system_info_util.h +++ b/chrome/browser/ash/app_list/search/system_info/system_info_util.h
@@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_ASH_APP_LIST_SEARCH_SYSTEM_INFO_SYSTEM_INFO_UTIL_H_ #define CHROME_BROWSER_ASH_APP_LIST_SEARCH_SYSTEM_INFO_SYSTEM_INFO_UTIL_H_ +#include <string> #include <vector> #include "base/time/time.h"
diff --git a/chrome/browser/ash/app_mode/fake_cws.cc b/chrome/browser/ash/app_mode/fake_cws.cc index e6cdfb4..ada4a71 100644 --- a/chrome/browser/ash/app_mode/fake_cws.cc +++ b/chrome/browser/ash/app_mode/fake_cws.cc
@@ -20,7 +20,6 @@ #include "chrome/test/base/in_process_browser_test.h" #include "crypto/sha2.h" #include "extensions/common/extensions_client.h" -#include "extensions/common/value_builder.h" #include "net/base/url_util.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/http_request.h" @@ -366,12 +365,12 @@ auto it = id_to_details_map_.find(*details_id); if (it != id_to_details_map_.end()) { std::string details = - extensions::DictionaryBuilder() - .Set("id", *details_id) - .Set("icon_url", it->second.icon_url) - .Set("localized_name", it->second.localized_name) - .Set("manifest", it->second.manifest_json) - .ToJSON(); + base::WriteJson(base::Value::Dict() + .Set("id", *details_id) + .Set("icon_url", it->second.icon_url) + .Set("localized_name", it->second.localized_name) + .Set("manifest", it->second.manifest_json)) + .value(); std::unique_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); http_response->set_code(net::HTTP_OK); http_response->set_content_type("application/json");
diff --git a/chrome/browser/ash/arc/vmm/arc_system_state_observation.cc b/chrome/browser/ash/arc/vmm/arc_system_state_observation.cc index 09f9cc2..7aa9959 100644 --- a/chrome/browser/ash/arc/vmm/arc_system_state_observation.cc +++ b/chrome/browser/ash/arc/vmm/arc_system_state_observation.cc
@@ -33,10 +33,15 @@ } absl::optional<base::TimeDelta> ArcSystemStateObservation::GetPeaceDuration() { - if (last_peace_timestamp_->is_null()) { + if (!last_peace_timestamp_.has_value()) { return absl::nullopt; } return base::Time::Now() - *last_peace_timestamp_; } +base::WeakPtr<ArcSystemStateObservation> +ArcSystemStateObservation::GetWeakPtr() { + return weak_ptr_factory_.GetWeakPtr(); +} + } // namespace arc
diff --git a/chrome/browser/ash/arc/vmm/arc_system_state_observation.h b/chrome/browser/ash/arc/vmm/arc_system_state_observation.h index 25272c91..0dba598 100644 --- a/chrome/browser/ash/arc/vmm/arc_system_state_observation.h +++ b/chrome/browser/ash/arc/vmm/arc_system_state_observation.h
@@ -26,11 +26,15 @@ absl::optional<base::TimeDelta> GetPeaceDuration(); + base::WeakPtr<ArcSystemStateObservation> GetWeakPtr(); + // ash::ThrottleService override: void ThrottleInstance(bool should_throttle) override; private: absl::optional<base::Time> last_peace_timestamp_; + + base::WeakPtrFactory<ArcSystemStateObservation> weak_ptr_factory_{this}; }; } // namespace arc
diff --git a/chrome/browser/ash/arc/vmm/arc_vmm_manager.cc b/chrome/browser/ash/arc/vmm/arc_vmm_manager.cc index 836ce4fa..e250ee2 100644 --- a/chrome/browser/ash/arc/vmm/arc_vmm_manager.cc +++ b/chrome/browser/ash/arc/vmm/arc_vmm_manager.cc
@@ -62,14 +62,20 @@ accelerator_ = std::make_unique<AcceleratorTarget>(this); } if (base::FeatureList::IsEnabled(kVmmSwapPolicy)) { + arc_system_state_observation_ = + std::make_unique<ArcSystemStateObservation>(context); swap_out_delay_ = base::Seconds(kVmmSwapOutDelaySecond.Get()); scheduler_ = std::make_unique<ArcVmmSwapScheduler>( base::Seconds(kVmmSwapOutTimeIntervalSecond.Get()), base::Seconds(kVmmSwapArcSilenceIntervalSecond.Get()), - base::BindRepeating([]() { - // TODO(sstan): Placeholder for ARC side implementation. - return false; - }), + base::BindRepeating( + [](base::WeakPtr<ArcSystemStateObservation> observation) { + return observation && + observation->GetPeaceDuration() > + base::Seconds(kVmmSwapArcSilenceIntervalSecond.Get() / + 2); + }, + arc_system_state_observation_->GetWeakPtr()), base::BindRepeating(&ArcVmmManager::SetSwapState, weak_ptr_factory_.GetWeakPtr())); scheduler_->Start();
diff --git a/chrome/browser/ash/arc/vmm/arc_vmm_manager.h b/chrome/browser/ash/arc/vmm/arc_vmm_manager.h index b423f0bb..51b2cd0 100644 --- a/chrome/browser/ash/arc/vmm/arc_vmm_manager.h +++ b/chrome/browser/ash/arc/vmm/arc_vmm_manager.h
@@ -8,6 +8,7 @@ #include <string> #include "base/functional/callback_forward.h" +#include "chrome/browser/ash/arc/vmm/arc_system_state_observation.h" #include "chrome/browser/ash/arc/vmm/arc_vmm_swap_scheduler.h" #include "chromeos/ash/components/dbus/vm_concierge/concierge_service.pb.h" #include "components/keyed_service/core/keyed_service.h" @@ -44,6 +45,10 @@ static void EnsureFactoryBuilt(); + ArcSystemStateObservation* system_state_observation_for_testing() { + return arc_system_state_observation_.get(); + } + private: // Accelerator target for experimental usage. Ctrl + Alt + Shift + O / P for // enable or disable vmm swap. @@ -65,6 +70,8 @@ // flag and parameters. std::unique_ptr<ArcVmmSwapScheduler> scheduler_; + std::unique_ptr<ArcSystemStateObservation> arc_system_state_observation_; + std::string user_id_hash_; base::WeakPtrFactory<ArcVmmManager> weak_ptr_factory_{this};
diff --git a/chrome/browser/ash/arc/vmm/arc_vmm_manager_unittest.cc b/chrome/browser/ash/arc/vmm/arc_vmm_manager_unittest.cc index 95e83b6..1d37968 100644 --- a/chrome/browser/ash/arc/vmm/arc_vmm_manager_unittest.cc +++ b/chrome/browser/ash/arc/vmm/arc_vmm_manager_unittest.cc
@@ -4,11 +4,15 @@ #include "chrome/browser/ash/arc/vmm/arc_vmm_manager.h" +#include "ash/components/arc/arc_features.h" #include "ash/components/arc/session/arc_service_manager.h" #include "base/test/bind.h" +#include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" +#include "chrome/test/base/testing_profile_manager.h" #include "chromeos/ash/components/dbus/cicerone/fake_cicerone_client.h" #include "chromeos/ash/components/dbus/concierge/fake_concierge_client.h" +#include "components/prefs/testing_pref_service.h" #include "content/public/test/browser_task_environment.h" #include "testing/gtest/include/gtest/gtest.h" @@ -76,15 +80,20 @@ // This is needed for setting up ArcBridge. arc_service_manager_ = std::make_unique<ArcServiceManager>(); - testing_profile_ = std::make_unique<TestingProfile>(); - manager_ = - ArcVmmManager::GetForBrowserContextForTesting(testing_profile_.get()); - manager_->set_user_id_hash("test_user_hash_id"); + profile_manager_ = std::make_unique<TestingProfileManager>( + TestingBrowserProcess::GetGlobal()); + ASSERT_TRUE(profile_manager_->SetUp()); + testing_profile_ = profile_manager_->CreateTestingProfile("test_name"); concierge_client_ = std::make_unique<TestConciergeClient>(ash::FakeCiceroneClient::Get()); } + void InitVmmManager() { + manager_ = ArcVmmManager::GetForBrowserContextForTesting(testing_profile_); + manager_->set_user_id_hash("test_user_hash_id"); + } + ArcVmmManager* manager() { return manager_; } TestConciergeClient* client() { return concierge_client_.get(); } @@ -93,7 +102,11 @@ base::test::TaskEnvironment::TimeSource::MOCK_TIME}; private: - std::unique_ptr<TestingProfile> testing_profile_; + base::test::ScopedFeatureList scoped_features_; + TestingPrefServiceSimple local_state_; + + std::unique_ptr<TestingProfileManager> profile_manager_; + TestingProfile* testing_profile_ = nullptr; std::unique_ptr<TestConciergeClient> concierge_client_; ArcVmmManager* manager_ = nullptr; @@ -101,6 +114,7 @@ }; TEST_F(ArcVmmManagerTest, SwapSuccess) { + InitVmmManager(); manager()->SetSwapState(true); base::RunLoop().RunUntilIdle(); // Send "ENABLE" first. @@ -114,4 +128,32 @@ EXPECT_EQ(1, client()->swap_out_count()); EXPECT_EQ(0, client()->disable_count()); } + +TEST_F(ArcVmmManagerTest, ObservationAndScheduler) { + base::test::ScopedFeatureList features_; + // The feature companion with some paremeter. Although the test will use + // the default value, keep the empty parameter here for better readability. + features_.InitAndEnableFeatureWithParameters(kVmmSwapPolicy, {{}}); + InitVmmManager(); + + // Should enabled observation. + EXPECT_NE(manager()->system_state_observation_for_testing(), nullptr); + + base::RunLoop().RunUntilIdle(); + // Mark ARC is inactive. + manager()->system_state_observation_for_testing()->ThrottleInstance(true); + + // Haven't start swap out. + task_environment_.FastForwardBy(base::Minutes(1)); + EXPECT_EQ(0, client()->enable_count()); + EXPECT_EQ(0, client()->swap_out_count()); + EXPECT_EQ(0, client()->disable_count()); + + // Should trigger the swap out state after 1 hour. + task_environment_.FastForwardBy(base::Hours(1)); + EXPECT_EQ(1, client()->enable_count()); + EXPECT_EQ(1, client()->swap_out_count()); + EXPECT_EQ(0, client()->disable_count()); +} + } // namespace arc
diff --git a/chrome/browser/ash/dbus/ash_dbus_helper.cc b/chrome/browser/ash/dbus/ash_dbus_helper.cc index 5b263bc..850f7fe 100644 --- a/chrome/browser/ash/dbus/ash_dbus_helper.cc +++ b/chrome/browser/ash/dbus/ash_dbus_helper.cc
@@ -54,6 +54,7 @@ #include "chromeos/ash/components/dbus/os_install/os_install_client.h" #include "chromeos/ash/components/dbus/patchpanel/patchpanel_client.h" #include "chromeos/ash/components/dbus/pciguard/pciguard_client.h" +#include "chromeos/ash/components/dbus/printscanmgr/printscanmgr_client.h" #include "chromeos/ash/components/dbus/private_computing/private_computing_client.h" #include "chromeos/ash/components/dbus/resourced/resourced_client.h" #include "chromeos/ash/components/dbus/rgbkbd/rgbkbd_client.h" @@ -183,6 +184,7 @@ InitializeDBusClient<OsInstallClient>(bus); InitializeDBusClient<PatchPanelClient>(bus); InitializeDBusClient<PciguardClient>(bus); + InitializeDBusClient<PrintscanmgrClient>(bus); InitializeDBusClient<PrivateComputingClient>(bus); InitializeDBusClient<chromeos::PermissionBrokerClient>(bus); InitializeDBusClient<chromeos::PowerManagerClient>(bus); @@ -295,6 +297,7 @@ } chromeos::PowerManagerClient::Shutdown(); chromeos::PermissionBrokerClient::Shutdown(); + PrintscanmgrClient::Shutdown(); PciguardClient::Shutdown(); PatchPanelClient::Shutdown(); PrivateComputingClient::Shutdown();
diff --git a/chrome/browser/ash/drive/fileapi/drivefs_async_file_util.cc b/chrome/browser/ash/drive/fileapi/drivefs_async_file_util.cc index 49cf4e7..b57d3d3c6 100644 --- a/chrome/browser/ash/drive/fileapi/drivefs_async_file_util.cc +++ b/chrome/browser/ash/drive/fileapi/drivefs_async_file_util.cc
@@ -198,28 +198,9 @@ if (error != drive::FILE_ERROR_OK) { LOG(ERROR) << "Cannot get metadata of '" << drive_path_ << "': " << error; - blocking_task_runner_->PostTask( - FROM_HERE, base::BindOnce(&DeleteOperation::Delete, this)); - return; - } - - DCHECK(metadata); - id_ = Id(metadata->stable_id); - // TODO(b/271203956) Remove this code once DriveFS automatically unpins - // deleted files and folders. - VLOG(1) << "Unpinning " << id_ << " '" << drive_path_ << "'..."; - DCHECK(drive_); - drive_->GetDriveFsInterface()->SetPinnedByStableId( - metadata->stable_id, false, - base::BindOnce(&DeleteOperation::OnUnpinFile, this)); - } - - void OnUnpinFile(const drive::FileError error) { - if (error == drive::FILE_ERROR_OK) { - VLOG(1) << "Unpinned " << id_ << " '" << drive_path_ << "'"; } else { - LOG(ERROR) << "Cannot unpin " << id_ << " '" << drive_path_ - << "': " << error; + DCHECK(metadata); + id_ = Id(metadata->stable_id); } blocking_task_runner_->PostTask( @@ -247,8 +228,8 @@ void OnDeleted() { DCHECK(drive_); if (PinManager* const pin_manager = drive_->GetPinManager()) { - // Local delete events are currently not sent via DriveFS, so for now - // we notify the `PinManager` for local deletes. + // TODO(b/267225898) Local delete events are currently not sent via + // DriveFS, so for now we notify the `PinManager` for local deletes. pin_manager->NotifyDelete(id_, drive_path_); } }
diff --git a/chrome/browser/ash/file_manager/file_manager_browsertest.cc b/chrome/browser/ash/file_manager/file_manager_browsertest.cc index 1361e4f52d..e33e3e4 100644 --- a/chrome/browser/ash/file_manager/file_manager_browsertest.cc +++ b/chrome/browser/ash/file_manager/file_manager_browsertest.cc
@@ -1549,9 +1549,7 @@ TestCase("driveOfflineInfoBanner"), TestCase("driveDeleteDialogDoesntMentionPermanentDelete"), TestCase("driveInlineSyncStatusSingleFile").EnableInlineStatusSync(), - TestCase("driveInlineSyncStatusParentFolder").EnableInlineStatusSync(), - TestCase("driveLocalDeleteUnpinsItem").EnableBulkPinning(), - TestCase("driveCloudDeleteUnpinsItem").EnableBulkPinning() + TestCase("driveInlineSyncStatusParentFolder").EnableInlineStatusSync() // TODO(b/189173190): Enable // TestCase("driveEnableDocsOfflineDialog"), // TODO(b/189173190): Enable @@ -2011,6 +2009,7 @@ .FeatureIds({"screenplay-09c32d6b-36d3-494b-bb83-e19655880471"}), TestCase("hideCurrentDirectoryByTogglingHiddenAndroidFolders"), TestCase("newFolderInDownloads"), + TestCase("showFilesSettingsButton"), TestCase("showSendFeedbackAction") .FeatureIds({"screenplay-3bd7bbba-a25a-4386-93cf-933266df22a7"}), TestCase("showSendFeedbackAction")
diff --git a/chrome/browser/ash/file_manager/file_manager_string_util.cc b/chrome/browser/ash/file_manager/file_manager_string_util.cc index 65eec7a..687a290 100644 --- a/chrome/browser/ash/file_manager/file_manager_string_util.cc +++ b/chrome/browser/ash/file_manager/file_manager_string_util.cc
@@ -502,6 +502,7 @@ SET_STRING("FILE_ITEMS_EXTRACTED", IDS_FILE_BROWSER_FILE_ITEMS_EXTRACTED); SET_STRING("FILE_ITEMS_MOVED", IDS_FILE_BROWSER_FILE_ITEMS_MOVED); SET_STRING("FILE_MOVED", IDS_FILE_BROWSER_FILE_MOVED); + SET_STRING("FILES_SETTINGS_LABEL", IDS_FILE_BROWSER_FILES_SETTINGS_LABEL); SET_STRING("FOLDER_SHARED_WITH_CROSTINI", IDS_FILE_BROWSER_FOLDER_SHARED_WITH_CROSTINI); SET_STRING("FOLDER_SHARED_WITH_CROSTINI_PLURAL",
diff --git a/chrome/browser/ash/login/screens/error_screen.cc b/chrome/browser/ash/login/screens/error_screen.cc index a674a89..f6bce7a 100644 --- a/chrome/browser/ash/login/screens/error_screen.cc +++ b/chrome/browser/ash/login/screens/error_screen.cc
@@ -39,7 +39,6 @@ #include "chromeos/ash/components/network/network_handler.h" #include "chromeos/ash/components/network/network_state_handler.h" #include "chromeos/dbus/power/power_manager_client.h" -#include "components/session_manager/core/session_manager.h" #include "components/web_modal/web_contents_modal_dialog_manager.h" #include "third_party/cros_system_api/dbus/service_constants.h" #include "ui/gfx/native_widget_types.h" @@ -265,7 +264,6 @@ view_->Show(); LOG(WARNING) << "Network error screen message is shown"; - session_manager::SessionManager::Get()->NotifyNetworkErrorScreenShown(); NetworkHandler::Get()->network_state_handler()->RequestPortalDetection(); }
diff --git a/chrome/browser/ash/login/ui/login_display_host_webui.cc b/chrome/browser/ash/login/ui/login_display_host_webui.cc index 20dc6823..96320018 100644 --- a/chrome/browser/ash/login/ui/login_display_host_webui.cc +++ b/chrome/browser/ash/login/ui/login_display_host_webui.cc
@@ -1010,11 +1010,6 @@ observers_.RemoveObserver(observer); } -void LoginDisplayHostWebUI::OnNetworkErrorScreenShown() { - VLOG(1) << "Login WebUI >> WEBUI_VISIBLE(ERROR_SCREEN)"; - ShowWebUI(); -} - void LoginDisplayHostWebUI::OnLoginOrLockScreenVisible() { VLOG(1) << "Login WebUI >> WEBUI_VISIBLE"; ShowWebUI();
diff --git a/chrome/browser/ash/login/ui/login_display_host_webui.h b/chrome/browser/ash/login/ui/login_display_host_webui.h index f24b89e..c417bb1 100644 --- a/chrome/browser/ash/login/ui/login_display_host_webui.h +++ b/chrome/browser/ash/login/ui/login_display_host_webui.h
@@ -112,7 +112,6 @@ bool HandleAccelerator(LoginAcceleratorAction action) final; // session_manager::SessionManagerObserver: - void OnNetworkErrorScreenShown() override; void OnLoginOrLockScreenVisible() override; // Trace id for ShowLoginWebUI event (since there exists at most one login
diff --git a/chrome/browser/ash/login/ui/webui_login_view.cc b/chrome/browser/ash/login/ui/webui_login_view.cc index 796e0e8..f6d3873 100644 --- a/chrome/browser/ash/login/ui/webui_login_view.cc +++ b/chrome/browser/ash/login/ui/webui_login_view.cc
@@ -300,11 +300,6 @@ } } -void WebUILoginView::OnNetworkErrorScreenShown() { - OnLoginPromptVisible(); - session_observation_.Reset(); -} - void WebUILoginView::OnLoginOrLockScreenVisible() { OnLoginPromptVisible(); session_observation_.Reset();
diff --git a/chrome/browser/ash/login/ui/webui_login_view.h b/chrome/browser/ash/login/ui/webui_login_view.h index 6ab813b..2fc8ef4 100644 --- a/chrome/browser/ash/login/ui/webui_login_view.h +++ b/chrome/browser/ash/login/ui/webui_login_view.h
@@ -128,7 +128,6 @@ void GetAccessibleNodeData(ui::AXNodeData* node_data) override; // session_manager::SessionManagerObserver: - void OnNetworkErrorScreenShown() override; void OnLoginOrLockScreenVisible() override; private:
diff --git a/chrome/browser/ash/policy/remote_commands/device_command_fetch_crd_availability_info_job.cc b/chrome/browser/ash/policy/remote_commands/device_command_fetch_crd_availability_info_job.cc index 0e7dd00..c40c36b6 100644 --- a/chrome/browser/ash/policy/remote_commands/device_command_fetch_crd_availability_info_job.cc +++ b/chrome/browser/ash/policy/remote_commands/device_command_fetch_crd_availability_info_job.cc
@@ -7,11 +7,11 @@ #include <algorithm> #include "base/functional/bind.h" +#include "base/json/json_writer.h" #include "base/time/time.h" #include "chrome/browser/ash/policy/remote_commands/crd_logging.h" #include "chrome/browser/ash/policy/remote_commands/crd_remote_command_utils.h" #include "components/policy/core/common/remote_commands/remote_command_job.h" -#include "extensions/common/value_builder.h" namespace policy { @@ -19,7 +19,6 @@ using enterprise_management::CrdSessionAvailability; using enterprise_management::RemoteCommand; -using extensions::DictionaryBuilder; constexpr char kIdleTime[] = "deviceIdleTimeInSeconds"; constexpr char kUserSessionType[] = "userSessionType"; @@ -86,18 +85,19 @@ CallbackWithResult callback, bool is_in_managed_environment) { std::string payload = - extensions::DictionaryBuilder() - .Set(kIdleTime, static_cast<int>(GetDeviceIdleTime().InSeconds())) - .Set(kUserSessionType, GetCurrentUserSessionType()) - .Set(kIsInManagedEnvironment, is_in_managed_environment) - .Set(kSupportedCrdSessionTypes, - GetSupportedSessionTypes(is_in_managed_environment)) - .Set(kRemoteSupportAvailability, - GetRemoteSupportAvailability(GetCurrentUserSessionType())) - .Set(kRemoteAccessAvailability, - GetRemoteAccessAvailability(is_in_managed_environment, - GetCurrentUserSessionType())) - .ToJSON(); + base::WriteJson( + base::Value::Dict() + .Set(kIdleTime, static_cast<int>(GetDeviceIdleTime().InSeconds())) + .Set(kUserSessionType, GetCurrentUserSessionType()) + .Set(kIsInManagedEnvironment, is_in_managed_environment) + .Set(kSupportedCrdSessionTypes, + GetSupportedSessionTypes(is_in_managed_environment)) + .Set(kRemoteSupportAvailability, + GetRemoteSupportAvailability(GetCurrentUserSessionType())) + .Set(kRemoteAccessAvailability, + GetRemoteAccessAvailability(is_in_managed_environment, + GetCurrentUserSessionType()))) + .value(); CRD_DVLOG(1) << "Finished FETCH_CRD_AVAILABILITY_INFO remote command: " << payload;
diff --git a/chrome/browser/ash/policy/remote_commands/device_command_fetch_crd_availability_info_job_unittest.cc b/chrome/browser/ash/policy/remote_commands/device_command_fetch_crd_availability_info_job_unittest.cc index c03c5155..94e69e9 100644 --- a/chrome/browser/ash/policy/remote_commands/device_command_fetch_crd_availability_info_job_unittest.cc +++ b/chrome/browser/ash/policy/remote_commands/device_command_fetch_crd_availability_info_job_unittest.cc
@@ -21,8 +21,6 @@ #include "chrome/browser/ash/policy/remote_commands/user_session_type_test_util.h" #include "chrome/browser/ash/settings/device_settings_test_helper.h" #include "components/policy/proto/device_management_backend.pb.h" -#include "extensions/common/value_builder.h" -#include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/user_activity/user_activity_detector.h" @@ -37,19 +35,18 @@ using chromeos::network_config::mojom::OncSource; using enterprise_management::CrdSessionAvailability; using enterprise_management::RemoteCommand; -using extensions::DictionaryBuilder; using test::SessionTypeToString; using test::TestSessionType; using testing::Not; constexpr int64_t kUniqueID = 111222333444; -RemoteCommand GenerateCommandProto(const std::string& payload) { +RemoteCommand GenerateCommandProto() { RemoteCommand command_proto; command_proto.set_type(RemoteCommand::FETCH_CRD_AVAILABILITY_INFO); command_proto.set_command_id(kUniqueID); command_proto.set_age_of_command(0); - command_proto.set_payload(payload); + command_proto.set_payload(""); return command_proto; } @@ -119,13 +116,11 @@ DeviceSettingsTestBase::TearDown(); } - Result CreateAndRunJob( - const DictionaryBuilder& payload = DictionaryBuilder()) { + Result CreateAndRunJob() { DeviceCommandFetchCrdAvailabilityInfoJob job; - bool initialized = - job.Init(base::TimeTicks::Now(), GenerateCommandProto(payload.ToJSON()), - enterprise_management::SignedData()); + bool initialized = job.Init(base::TimeTicks::Now(), GenerateCommandProto(), + enterprise_management::SignedData()); if (!initialized) { ADD_FAILURE() << "Failed to initialize job"; return Result{};
diff --git a/chrome/browser/ash/policy/remote_commands/device_command_start_crd_session_job.cc b/chrome/browser/ash/policy/remote_commands/device_command_start_crd_session_job.cc index e9ebd9e..03dd76d 100644 --- a/chrome/browser/ash/policy/remote_commands/device_command_start_crd_session_job.cc +++ b/chrome/browser/ash/policy/remote_commands/device_command_start_crd_session_job.cc
@@ -13,6 +13,7 @@ #include "base/functional/bind.h" #include "base/functional/callback.h" #include "base/json/json_reader.h" +#include "base/json/json_writer.h" #include "base/memory/weak_ptr.h" #include "base/metrics/histogram_functions.h" #include "base/notreached.h" @@ -26,7 +27,6 @@ #include "chrome/browser/device_identity/device_oauth2_token_service.h" #include "chrome/browser/device_identity/device_oauth2_token_service_factory.h" #include "components/policy/proto/device_management_backend.pb.h" -#include "extensions/common/value_builder.h" #include "google_apis/gaia/gaia_constants.h" #include "google_apis/gaia/oauth2_access_token_manager.h" #include "remoting/host/chromeos/features.h" @@ -36,8 +36,6 @@ namespace { -using extensions::DictionaryBuilder; - // OAuth2 Token scopes constexpr char kCloudDevicesOAuth2Scope[] = "https://www.googleapis.com/auth/clouddevices"; @@ -92,18 +90,21 @@ } std::string CreateSuccessPayload(const std::string& access_code) { - return DictionaryBuilder() - .Set(kResultCodeFieldName, static_cast<int>(ResultCode::SUCCESS)) - .Set(kResultAccessCodeFieldName, access_code) - .ToJSON(); + return base::WriteJson(base::Value::Dict() + .Set(kResultCodeFieldName, + static_cast<int>(ResultCode::SUCCESS)) + .Set(kResultAccessCodeFieldName, access_code)) + .value(); } std::string CreateNonIdlePayload(const base::TimeDelta& time_delta) { - return DictionaryBuilder() - .Set(kResultCodeFieldName, static_cast<int>(ResultCode::FAILURE_NOT_IDLE)) - .Set(kResultLastActivityFieldName, - static_cast<int>(time_delta.InSeconds())) - .ToJSON(); + return base::WriteJson( + base::Value::Dict() + .Set(kResultCodeFieldName, + static_cast<int>(ResultCode::FAILURE_NOT_IDLE)) + .Set(kResultLastActivityFieldName, + static_cast<int>(time_delta.InSeconds()))) + .value(); } std::string CreateErrorPayload(ResultCode result_code, @@ -111,12 +112,12 @@ DCHECK(result_code != ResultCode::SUCCESS); DCHECK(result_code != ResultCode::FAILURE_NOT_IDLE); - DictionaryBuilder builder; - builder.Set(kResultCodeFieldName, static_cast<int>(result_code)); + auto payload = base::Value::Dict() // + .Set(kResultCodeFieldName, static_cast<int>(result_code)); if (!error_message.empty()) { - builder.Set(kResultMessageFieldName, error_message); + payload.Set(kResultMessageFieldName, error_message); } - return builder.ToJSON(); + return base::WriteJson(payload).value(); } DeviceOAuth2TokenService& GetOAuthService() {
diff --git a/chrome/browser/ash/policy/remote_commands/device_command_start_crd_session_unittest.cc b/chrome/browser/ash/policy/remote_commands/device_command_start_crd_session_unittest.cc index 7aacc3e..8603ef1 100644 --- a/chrome/browser/ash/policy/remote_commands/device_command_start_crd_session_unittest.cc +++ b/chrome/browser/ash/policy/remote_commands/device_command_start_crd_session_unittest.cc
@@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/time/time.h" #include "chrome/browser/ash/policy/remote_commands/device_command_start_crd_session_job.h" #include <map> @@ -10,12 +9,14 @@ #include <utility> #include <vector> +#include "base/json/json_writer.h" #include "base/strings/stringprintf.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/repeating_test_future.h" #include "base/test/scoped_feature_list.h" #include "base/test/test_future.h" #include "base/test/values_test_util.h" +#include "base/time/time.h" #include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h" #include "chrome/browser/ash/app_mode/kiosk_app_manager.h" #include "chrome/browser/ash/app_mode/web_app/web_kiosk_app_manager.h" @@ -30,7 +31,6 @@ #include "chromeos/ash/services/network_config/in_process_instance.h" #include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h" #include "components/policy/proto/device_management_backend.pb.h" -#include "extensions/common/value_builder.h" #include "remoting/host/chromeos/features.h" #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/test/test_url_loader_factory.h" @@ -41,15 +41,17 @@ namespace { +using base::test::IsJson; using base::test::RepeatingTestFuture; using base::test::TestFuture; -using extensions::DictionaryBuilder; using test::TestSessionType; using UmaSessionType = DeviceCommandStartCrdSessionJob::UmaSessionType; using chromeos::network_config::mojom::NetworkType; using chromeos::network_config::mojom::OncSource; using remoting::features::kEnableCrdAdminRemoteAccess; +using Payload = base::Value::Dict; + namespace em = ::enterprise_management; constexpr char kResultCodeFieldName[] = "resultCode"; @@ -96,12 +98,12 @@ // Macro expecting success. We are using a macro because a function would // report any error against the line in the function, and not against the // place where EXPECT_SUCCESS is called. -#define EXPECT_SUCCESS(statement_) \ - ({ \ - auto result_ = statement_; \ - EXPECT_EQ(result_.status, RemoteCommandJob::Status::SUCCEEDED); \ - EXPECT_THAT(result_.payload, \ - base::test::IsJson(CreateSuccessPayload(kTestAccessCode))); \ +#define EXPECT_SUCCESS(statement_) \ + ({ \ + auto result_ = statement_; \ + EXPECT_EQ(result_.status, RemoteCommandJob::Status::SUCCEEDED); \ + EXPECT_THAT(result_.payload, \ + IsJson(CreateSuccessPayload(kTestAccessCode))); \ }) // Macro expecting error. We are using a macro because a function would @@ -111,13 +113,13 @@ ({ \ auto result_ = statement_; \ EXPECT_EQ(result_.status, RemoteCommandJob::Status::FAILED); \ - EXPECT_THAT(result_.payload, base::test::IsJson(CreateErrorPayload( \ - error_code, ##__VA_ARGS__))); \ + EXPECT_THAT(result_.payload, \ + IsJson(CreateErrorPayload(error_code, ##__VA_ARGS__))); \ }) em::RemoteCommand GenerateCommandProto(RemoteCommandJob::UniqueIDType unique_id, base::TimeDelta age_of_command, - std::string payload) { + const std::string& payload) { em::RemoteCommand command_proto; command_proto.set_type(em::RemoteCommand_Type_DEVICE_START_CRD_SESSION); command_proto.set_command_id(unique_id); @@ -293,13 +295,10 @@ DeviceSettingsTestBase::TearDown(); } - // Create an empty payload builder. - DictionaryBuilder Payload() const { return DictionaryBuilder(); } - - std::string CreateSuccessPayload(const std::string& access_code); - std::string CreateErrorPayload(ResultCode result_code, - const std::string& error_message); - std::string CreateNotIdlePayload(int idle_time_in_sec); + Payload CreateSuccessPayload(const std::string& access_code); + Payload CreateErrorPayload(ResultCode result_code, + const std::string& error_message); + Payload CreateNotIdlePayload(int idle_time_in_sec); void LogInAsKioskUser() { test::StartSessionOfType(TestSessionType::kAutoLaunchedWebKioskSession, @@ -328,8 +327,7 @@ StubCrdHostDelegate& crd_host_delegate() { return crd_host_delegate_; } - Result RunJobAndWaitForResult( - const DictionaryBuilder& payload = DictionaryBuilder()) { + Result RunJobAndWaitForResult(const Payload& payload = Payload()) { DeviceCommandStartCrdSessionJob job{&crd_host_delegate_}; bool initialized = InitializeJob(job, payload); @@ -348,11 +346,12 @@ } bool InitializeJob(DeviceCommandStartCrdSessionJob& job, - const DictionaryBuilder& payload = DictionaryBuilder()) { - bool success = job.Init( - base::TimeTicks::Now(), - GenerateCommandProto(kUniqueID, base::TimeDelta(), payload.ToJSON()), - em::SignedData()); + const Payload& payload = Payload()) { + bool success = + job.Init(base::TimeTicks::Now(), + GenerateCommandProto(kUniqueID, base::TimeDelta(), + base::WriteJson(payload).value()), + em::SignedData()); if (oauth_token_) { job.SetOAuthTokenForTest(oauth_token_.value()); @@ -403,31 +402,29 @@ : public DeviceCommandStartCrdSessionJobTest, public ::testing::WithParamInterface<test::TestSessionType> {}; -std::string DeviceCommandStartCrdSessionJobTest::CreateSuccessPayload( +Payload DeviceCommandStartCrdSessionJobTest::CreateSuccessPayload( const std::string& access_code) { - return DictionaryBuilder() + return Payload() .Set(kResultCodeFieldName, static_cast<int>(ResultCode::SUCCESS)) - .Set(kResultAccessCodeFieldName, access_code) - .ToJSON(); + .Set(kResultAccessCodeFieldName, access_code); } -std::string DeviceCommandStartCrdSessionJobTest::CreateErrorPayload( +Payload DeviceCommandStartCrdSessionJobTest::CreateErrorPayload( ResultCode result_code, const std::string& error_message = "") { - DictionaryBuilder builder; - builder.Set(kResultCodeFieldName, static_cast<int>(result_code)); + auto payload = Payload() // + .Set(kResultCodeFieldName, static_cast<int>(result_code)); if (!error_message.empty()) { - builder.Set(kResultMessageFieldName, error_message); + payload.Set(kResultMessageFieldName, error_message); } - return builder.ToJSON(); + return payload; } -std::string DeviceCommandStartCrdSessionJobTest::CreateNotIdlePayload( +Payload DeviceCommandStartCrdSessionJobTest::CreateNotIdlePayload( int idle_time_in_sec) { - return DictionaryBuilder() + return Payload() .Set(kResultCodeFieldName, static_cast<int>(ResultCode::FAILURE_NOT_IDLE)) - .Set(kResultLastActivityFieldName, idle_time_in_sec) - .ToJSON(); + .Set(kResultLastActivityFieldName, idle_time_in_sec); } TEST_F(DeviceCommandStartCrdSessionJobTest, @@ -496,7 +493,8 @@ Result result = RunJobAndWaitForResult( Payload().Set("idlenessCutoffSec", idleness_cutoff_in_sec)); EXPECT_EQ(result.status, RemoteCommandJob::Status::FAILED); - EXPECT_EQ(result.payload, CreateNotIdlePayload(device_idle_time_in_sec)); + EXPECT_THAT(result.payload, + IsJson(CreateNotIdlePayload(device_idle_time_in_sec))); } TEST_F(DeviceCommandStartCrdSessionJobTest, @@ -837,11 +835,9 @@ } // Return a `RemoteCommand` payload that would start a remote access session. - DictionaryBuilder RemoteAccessPayload() { - return DictionaryBuilder( - Payload() - .Set("crdSessionType", CrdSessionType::REMOTE_ACCESS_SESSION) - .Build()); + Payload RemoteAccessPayload() { + return Payload().Set("crdSessionType", + CrdSessionType::REMOTE_ACCESS_SESSION); } void AddActiveManagedNetwork() { @@ -869,7 +865,8 @@ auto payload_without_crd_session_type = Payload(); - Result result = RunJobAndWaitForResult(payload_without_crd_session_type); + Result result = + RunJobAndWaitForResult(std::move(payload_without_crd_session_type)); if (SupportsRemoteSupport(user_session_type)) { EXPECT_SUCCESS(result);
diff --git a/chrome/browser/ash/printing/printer_configurer.cc b/chrome/browser/ash/printing/printer_configurer.cc index 6a8a0b39..fefd822d 100644 --- a/chrome/browser/ash/printing/printer_configurer.cc +++ b/chrome/browser/ash/printing/printer_configurer.cc
@@ -25,6 +25,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/common/webui_url_constants.h" #include "chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.h" +#include "chromeos/dbus/common/dbus_library_error.h" #include "chromeos/printing/ppd_provider.h" #include "chromeos/printing/printer_configuration.h" #include "components/device_event_log/device_event_log.h" @@ -88,14 +89,14 @@ // in PrinterSetupResult. PrinterSetupResult PrinterSetupResultFromDbusErrorCode( const Printer& printer, - DbusLibraryError dbus_error) { + chromeos::DBusLibraryError dbus_error) { DCHECK_LT(dbus_error, 0); const std::string prefix = printer.make_and_model() + " setup result: "; switch (dbus_error) { - case DbusLibraryError::kNoReply: + case chromeos::DBusLibraryError::kNoReply: PRINTER_LOG(ERROR) << prefix << "D-Bus error - no reply"; return PrinterSetupResult::kDbusNoReply; - case DbusLibraryError::kTimeout: + case chromeos::DBusLibraryError::kTimeout: PRINTER_LOG(ERROR) << prefix << "D-Bus error - timeout"; return PrinterSetupResult::kDbusTimeout; default: @@ -154,7 +155,7 @@ PrinterSetupResult setup_result = result_code < 0 ? PrinterSetupResultFromDbusErrorCode( - printer, static_cast<DbusLibraryError>(result_code)) + printer, static_cast<chromeos::DBusLibraryError>(result_code)) : PrinterSetupResultFromDbusResultCode(printer, result_code); std::move(cb).Run(setup_result); }
diff --git a/chrome/browser/ash/printing/printer_configurer.h b/chrome/browser/ash/printing/printer_configurer.h index 4efa9fa2..a199e68c 100644 --- a/chrome/browser/ash/printing/printer_configurer.h +++ b/chrome/browser/ash/printing/printer_configurer.h
@@ -46,7 +46,7 @@ kManualSetupRequired = 17, // Printer requires manual setup // Space left for additional errors - // Specific DBus errors. This must stay in sync with the DbusLibraryError + // Specific DBus errors. This must stay in sync with the DBusLibraryError // enum and PrinterSetupResultFromDbusErrorCode(). kDbusNoReply = 64, // Expected remote response but got nothing kDbusTimeout = 65, // Generic timeout error (c.f. dbus-protocol.h)
diff --git a/chrome/browser/ash/system_web_apps/system_web_app_manager_browsertest.cc b/chrome/browser/ash/system_web_apps/system_web_app_manager_browsertest.cc index ee6a7c456..820adeb 100644 --- a/chrome/browser/ash/system_web_apps/system_web_app_manager_browsertest.cc +++ b/chrome/browser/ash/system_web_apps/system_web_app_manager_browsertest.cc
@@ -278,9 +278,6 @@ explicit SystemWebAppManagerFileHandlingBrowserTestBase( IncludeLaunchDirectory include_launch_directory) { - scoped_feature_blink_api_.InitWithFeatures( - {blink::features::kFileHandlingAPI}, {}); - maybe_installation_ = TestSystemWebAppInstallation::SetUpAppThatReceivesLaunchFiles( include_launch_directory); @@ -350,7 +347,6 @@ private: base::test::ScopedFeatureList scoped_feature_web_app_provider_type_; - base::test::ScopedFeatureList scoped_feature_blink_api_; }; class SystemWebAppManagerLaunchFilesBrowserTest @@ -834,71 +830,6 @@ // crashed, the following call will fail. EXPECT_TRUE(content::ExecuteScript(web_contents, "(function() {})();")); } - -class SystemWebAppManagerFileHandlingOriginTrialsBrowserTest - : public SystemWebAppManagerBrowserTest { - public: - SystemWebAppManagerFileHandlingOriginTrialsBrowserTest() - : SystemWebAppManagerBrowserTest(/*install_mock=*/false) { - maybe_installation_ = - TestSystemWebAppInstallation::SetUpAppWithEnabledOriginTrials( - OriginTrialsMap({{GetOrigin(GURL("chrome://test-system-app/")), - {"FileHandling"}}})); - } - - ~SystemWebAppManagerFileHandlingOriginTrialsBrowserTest() override = default; - - content::WebContents* LaunchWithTestFiles() { - // Create temporary directory and files. - base::ScopedAllowBlockingForTesting allow_blocking; - base::ScopedTempDir temp_directory; - CHECK(temp_directory.CreateUniqueTempDir()); - base::FilePath temp_file_path; - CHECK(base::CreateTemporaryFileInDir(temp_directory.GetPath(), - &temp_file_path)); - - // Launch the App. - apps::AppLaunchParams params = LaunchParamsForApp(GetMockAppType()); - params.launch_source = apps::LaunchSource::kFromChromeInternal; - params.launch_files = {temp_file_path}; - params.override_url = GetStartUrl(); - - return SystemWebAppBrowserTestBase::LaunchApp(std::move(params)); - } - - bool WaitForLaunchParam(content::WebContents* web_contents) { - bool promise_resolved = false; - EXPECT_TRUE(content::ExecuteScriptAndExtractBool( - web_contents, - "launchQueue.setConsumer(launchParams => {" - " domAutomationController.send(true);" - "});", - &promise_resolved)); - return promise_resolved; - } - - private: - url::Origin GetOrigin(const GURL& url) { return url::Origin::Create(url); } -}; - -// Test that file handling works when the App is first installed. -IN_PROC_BROWSER_TEST_P(SystemWebAppManagerFileHandlingOriginTrialsBrowserTest, - PRE_FileHandlingWorks) { - WaitForTestSystemAppInstall(); - - content::WebContents* web_contents = LaunchWithTestFiles(); - EXPECT_TRUE(WaitForLaunchParam(web_contents)); -} - -// Test that file handling works when after a version upgrade. -IN_PROC_BROWSER_TEST_P(SystemWebAppManagerFileHandlingOriginTrialsBrowserTest, - FileHandlingWorks) { - WaitForTestSystemAppInstall(); - - content::WebContents* web_contents = LaunchWithTestFiles(); - EXPECT_TRUE(WaitForLaunchParam(web_contents)); -} - class SystemWebAppManagerNotShownInLauncherTest : public SystemWebAppManagerBrowserTest { public: @@ -1072,10 +1003,8 @@ // Use an app with FileHandling enabled since it will perform extra setup // steps. maybe_installation_ = - TestSystemWebAppInstallation::SetUpAppWithEnabledOriginTrials( - OriginTrialsMap( - {{url::Origin::Create(GURL("chrome://test-system-app/")), - {"FileHandling"}}})); + TestSystemWebAppInstallation::SetUpAppThatReceivesLaunchFiles( + TestSystemWebAppInstallation::IncludeLaunchDirectory::kNo); } else { maybe_installation_ = TestSystemWebAppInstallation::SetUpWithoutApps(); } @@ -2022,9 +1951,6 @@ SystemWebAppManagerOriginTrialsBrowserTest); INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_REGULAR_PROFILE_P( - SystemWebAppManagerFileHandlingOriginTrialsBrowserTest); - -INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_REGULAR_PROFILE_P( SystemWebAppManagerUninstallBrowserTest); INSTANTIATE_SYSTEM_WEB_APP_MANAGER_TEST_SUITE_REGULAR_PROFILE_P(
diff --git a/chrome/browser/ash/wallpaper_handlers/mock_wallpaper_handlers.cc b/chrome/browser/ash/wallpaper_handlers/mock_wallpaper_handlers.cc index 6f5ed2cc..37bf075 100644 --- a/chrome/browser/ash/wallpaper_handlers/mock_wallpaper_handlers.cc +++ b/chrome/browser/ash/wallpaper_handlers/mock_wallpaper_handlers.cc
@@ -10,6 +10,7 @@ #include "ash/webui/personalization_app/proto/backdrop_wallpaper.pb.h" #include "base/functional/bind.h" #include "base/functional/callback.h" +#include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "base/task/sequenced_task_runner.h" #include "chrome/browser/ash/wallpaper_handlers/wallpaper_handlers.h" @@ -63,6 +64,46 @@ return image; } +ash::personalization_app::mojom::FetchGooglePhotosPhotosResponsePtr +CreateFakeGooglePhotosPhotosResponse() { + auto response = + ash::personalization_app::mojom::FetchGooglePhotosPhotosResponse::New(); + std::vector<ash::personalization_app::mojom::GooglePhotosPhotoPtr> photos; + for (auto i = 0; i < 3; i++) { + auto photo = ash::personalization_app::mojom::GooglePhotosPhoto::New(); + std::string id = base::StringPrintf("fake_google_photos_photo_id_%i", i); + photo->id = id; + photo->name = id; + photo->dedup_key = id; + photo->url = GURL(kDataUrlPrefix + base::NumberToString(i)); + photos.push_back(std::move(photo)); + } + response->photos = std::move(photos); + response->resume_token = absl::nullopt; + return response; +} + +ash::personalization_app::mojom::FetchGooglePhotosAlbumsResponsePtr +CreateFakeGooglePhotosSharedAlbumsResponse() { + std::vector<ash::personalization_app::mojom::GooglePhotosAlbumPtr> result; + for (int i = 0; i < 3; i++) { + auto album = ash::personalization_app::mojom::GooglePhotosAlbum::New(); + std::string id = + base::StringPrintf("fake_google_photos_shared_album_id_%i", i); + album->id = id; + album->is_shared = true; + // Shared albums always have `photo_count == 0` due to technical debt on + // server side. + album->photo_count = 0; + album->preview = GURL(kDataUrlPrefix + base::NumberToString(i)); + album->timestamp = base::Time::Now(); + album->title = id; + result.push_back(std::move(album)); + } + return ash::personalization_app::mojom::FetchGooglePhotosAlbumsResponse::New( + std::move(result), absl::nullopt); +} + } // namespace MockBackdropCollectionInfoFetcher::MockBackdropCollectionInfoFetcher() { @@ -138,12 +179,13 @@ ON_CALL(*this, AddRequestAndStartIfNecessary) .WillByDefault( [](const absl::optional<std::string>& resume_token, - base::OnceCallback<void(GooglePhotosAlbumsCbkArgs)> callback) { - auto response = FetchGooglePhotosAlbumsResponse::New( - std::vector<GooglePhotosAlbumPtr>(), absl::nullopt); + base::OnceCallback<void(ash::personalization_app::mojom:: + FetchGooglePhotosAlbumsResponsePtr)> + callback) { base::SequencedTaskRunner::GetCurrentDefault()->PostTask( FROM_HERE, - base::BindOnce(std::move(callback), std::move(response))); + base::BindOnce(std::move(callback), + CreateFakeGooglePhotosSharedAlbumsResponse())); }); ON_CALL(*this, ParseResponse) @@ -194,12 +236,13 @@ [](const absl::optional<std::string>& item_id, const absl::optional<std::string>& album_id, const absl::optional<std::string>& resume_token, bool shuffle, - base::OnceCallback<void(GooglePhotosPhotosCbkArgs)> callback) { - auto response = FetchGooglePhotosPhotosResponse::New( - std::vector<GooglePhotosPhotoPtr>(), absl::nullopt); + base::OnceCallback<void(ash::personalization_app::mojom:: + FetchGooglePhotosPhotosResponsePtr)> + callback) { base::SequencedTaskRunner::GetCurrentDefault()->PostTask( FROM_HERE, - base::BindOnce(std::move(callback), std::move(response))); + base::BindOnce(std::move(callback), + CreateFakeGooglePhotosPhotosResponse())); }); ON_CALL(*this, ParseResponse)
diff --git a/chrome/browser/ash/web_applications/camera_app/camera_system_web_app_info.cc b/chrome/browser/ash/web_applications/camera_app/camera_system_web_app_info.cc index 1f38a508..699327b 100644 --- a/chrome/browser/ash/web_applications/camera_app/camera_system_web_app_info.cc +++ b/chrome/browser/ash/web_applications/camera_app/camera_system_web_app_info.cc
@@ -59,13 +59,10 @@ } CameraSystemAppDelegate::CameraSystemAppDelegate(Profile* profile) - : ash::SystemWebAppDelegate( - ash::SystemWebAppType::CAMERA, - "Camera", - GURL("chrome://camera-app/views/main.html"), - profile, - ash::OriginTrialsMap( - {{ash::GetOrigin("chrome://camera-app"), {"FileHandling"}}})) {} + : ash::SystemWebAppDelegate(ash::SystemWebAppType::CAMERA, + "Camera", + GURL("chrome://camera-app/views/main.html"), + profile) {} std::unique_ptr<WebAppInstallInfo> CameraSystemAppDelegate::GetWebAppInfo() const {
diff --git a/chrome/browser/ash/web_applications/camera_app/chrome_camera_app_ui_delegate.cc b/chrome/browser/ash/web_applications/camera_app/chrome_camera_app_ui_delegate.cc index f7df4a90..fc0d4a7 100644 --- a/chrome/browser/ash/web_applications/camera_app/chrome_camera_app_ui_delegate.cc +++ b/chrome/browser/ash/web_applications/camera_app/chrome_camera_app_ui_delegate.cc
@@ -37,6 +37,7 @@ #include "chrome/browser/web_applications/web_app_launch_queue.h" #include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_tab_helper.h" +#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/devicetype.h" #include "chromeos/ui/base/window_properties.h" #include "components/services/app_service/public/cpp/app_launch_util.h" @@ -310,6 +311,8 @@ DeviceTypeToString(chromeos::GetDeviceType())); source->AddBoolean("timeLapse", base::FeatureList::IsEnabled( ash::features::kCameraAppTimeLapse)); + source->AddBoolean("jelly", + base::FeatureList::IsEnabled(chromeos::features::kJelly)); } bool ChromeCameraAppUIDelegate::IsMetricsAndCrashReportingEnabled() {
diff --git a/chrome/browser/ash/web_applications/file_manager_web_app_info.cc b/chrome/browser/ash/web_applications/file_manager_web_app_info.cc index fd4598d..89120e2 100644 --- a/chrome/browser/ash/web_applications/file_manager_web_app_info.cc +++ b/chrome/browser/ash/web_applications/file_manager_web_app_info.cc
@@ -149,13 +149,10 @@ } FileManagerSystemAppDelegate::FileManagerSystemAppDelegate(Profile* profile) - : ash::SystemWebAppDelegate( - ash::SystemWebAppType::FILE_MANAGER, - "File Manager", - GURL(kChromeUIFileManagerURL), - profile, - ash::OriginTrialsMap( - {{ash::GetOrigin(kChromeUIFileManagerURL), {"FileHandling"}}})) {} + : ash::SystemWebAppDelegate(ash::SystemWebAppType::FILE_MANAGER, + "File Manager", + GURL(kChromeUIFileManagerURL), + profile) {} std::unique_ptr<WebAppInstallInfo> FileManagerSystemAppDelegate::GetWebAppInfo() const {
diff --git a/chrome/browser/ash/web_applications/help_app/help_app_integration_browsertest.cc b/chrome/browser/ash/web_applications/help_app/help_app_integration_browsertest.cc index a97d3b4..4bdc43f 100644 --- a/chrome/browser/ash/web_applications/help_app/help_app_integration_browsertest.cc +++ b/chrome/browser/ash/web_applications/help_app/help_app_integration_browsertest.cc
@@ -783,9 +783,18 @@ base::HistogramTester histogram_tester; // The /? key is OEM_2 on a US standard keyboard. + GURL expected_url; +#if BUILDFLAG(ENABLE_CROS_HELP_APP) + expected_url = GURL("chrome://help-app"); +#else + expected_url = GURL(chrome::kChromeHelpViaKeyboardURL); +#endif + content::TestNavigationObserver navigation_observer(expected_url); + navigation_observer.StartWatchingNewWebContents(); ASSERT_TRUE(ui_test_utils::SendKeyPressSync( browser(), ui::VKEY_OEM_2, /*control=*/true, /*shift=*/false, /*alt=*/false, /*command=*/false)); + navigation_observer.Wait(); #if BUILDFLAG(ENABLE_CROS_HELP_APP) // Default browser tab and Help app are open.
diff --git a/chrome/browser/ash/web_applications/media_app/media_web_app_info.cc b/chrome/browser/ash/web_applications/media_app/media_web_app_info.cc index 5d9e5f9..0ee36528 100644 --- a/chrome/browser/ash/web_applications/media_app/media_web_app_info.cc +++ b/chrome/browser/ash/web_applications/media_app/media_web_app_info.cc
@@ -226,13 +226,10 @@ } // namespace MediaSystemAppDelegate::MediaSystemAppDelegate(Profile* profile) - : ash::SystemWebAppDelegate( - ash::SystemWebAppType::MEDIA, - "Media", - GURL("chrome://media-app/pwa.html"), - profile, - ash::OriginTrialsMap( - {{ash::GetOrigin("chrome://media-app"), {"FileHandling"}}})) { + : ash::SystemWebAppDelegate(ash::SystemWebAppType::MEDIA, + "Media", + GURL("chrome://media-app/pwa.html"), + profile) { // Tie survey registration to SWA registration. That is, the delegate map // owned by SystemWebAppManager, which is created at startup. PhotosExperienceSurveyTrigger::Register(profile);
diff --git a/chrome/browser/ash/web_applications/personalization_app/personalization_app_wallpaper_provider_impl.cc b/chrome/browser/ash/web_applications/personalization_app/personalization_app_wallpaper_provider_impl.cc index 354f107..794fb9a 100644 --- a/chrome/browser/ash/web_applications/personalization_app/personalization_app_wallpaper_provider_impl.cc +++ b/chrome/browser/ash/web_applications/personalization_app/personalization_app_wallpaper_provider_impl.cc
@@ -255,11 +255,7 @@ return; } - if (!google_photos_albums_fetcher_) { - google_photos_albums_fetcher_ = - wallpaper_fetcher_delegate_->CreateGooglePhotosAlbumsFetcher(profile_); - } - google_photos_albums_fetcher_->AddRequestAndStartIfNecessary( + GetOrCreateGooglePhotosAlbumsFetcher()->AddRequestAndStartIfNecessary( resume_token, std::move(callback)); } @@ -273,12 +269,7 @@ return; } - if (!google_photos_shared_albums_fetcher_) { - google_photos_shared_albums_fetcher_ = - wallpaper_fetcher_delegate_->CreateGooglePhotosSharedAlbumsFetcher( - profile_); - } - google_photos_shared_albums_fetcher_->AddRequestAndStartIfNecessary( + GetOrCreateGooglePhotosSharedAlbumsFetcher()->AddRequestAndStartIfNecessary( resume_token, std::move(callback)); } @@ -293,15 +284,12 @@ return; } - if (!google_photos_enabled_fetcher_) { - google_photos_enabled_fetcher_ = - wallpaper_fetcher_delegate_->CreateGooglePhotosEnabledFetcher(profile_); - } // base::Unretained is safe to use because |this| outlives // |google_photos_enabled_fetcher_|. - google_photos_enabled_fetcher_->AddRequestAndStartIfNecessary(base::BindOnce( - &PersonalizationAppWallpaperProviderImpl::OnFetchGooglePhotosEnabled, - base::Unretained(this), std::move(callback))); + GetOrCreateGooglePhotosEnabledFetcher()->AddRequestAndStartIfNecessary( + base::BindOnce( + &PersonalizationAppWallpaperProviderImpl::OnFetchGooglePhotosEnabled, + base::Unretained(this), std::move(callback))); } void PersonalizationAppWallpaperProviderImpl::FetchGooglePhotosPhotos( @@ -319,11 +307,7 @@ return; } - if (!google_photos_photos_fetcher_) { - google_photos_photos_fetcher_ = - wallpaper_fetcher_delegate_->CreateGooglePhotosPhotosFetcher(profile_); - } - google_photos_photos_fetcher_->AddRequestAndStartIfNecessary( + GetOrCreateGooglePhotosPhotosFetcher()->AddRequestAndStartIfNecessary( item_id, album_id, resume_token, /*shuffle=*/false, base::BindOnce( &PersonalizationAppWallpaperProviderImpl::OnFetchGooglePhotosPhotos, @@ -803,32 +787,43 @@ } wallpaper_handlers::GooglePhotosAlbumsFetcher* -PersonalizationAppWallpaperProviderImpl::SetGooglePhotosAlbumsFetcherForTest( - std::unique_ptr<wallpaper_handlers::GooglePhotosAlbumsFetcher> fetcher) { - google_photos_albums_fetcher_ = std::move(fetcher); +PersonalizationAppWallpaperProviderImpl:: + GetOrCreateGooglePhotosAlbumsFetcher() { + if (!google_photos_albums_fetcher_) { + google_photos_albums_fetcher_ = + wallpaper_fetcher_delegate_->CreateGooglePhotosAlbumsFetcher(profile_); + } return google_photos_albums_fetcher_.get(); } wallpaper_handlers::GooglePhotosSharedAlbumsFetcher* PersonalizationAppWallpaperProviderImpl:: - SetGooglePhotosSharedAlbumsFetcherForTest( - std::unique_ptr<wallpaper_handlers::GooglePhotosSharedAlbumsFetcher> - fetcher) { - google_photos_shared_albums_fetcher_ = std::move(fetcher); + GetOrCreateGooglePhotosSharedAlbumsFetcher() { + if (!google_photos_shared_albums_fetcher_) { + google_photos_shared_albums_fetcher_ = + wallpaper_fetcher_delegate_->CreateGooglePhotosSharedAlbumsFetcher( + profile_); + } return google_photos_shared_albums_fetcher_.get(); } wallpaper_handlers::GooglePhotosEnabledFetcher* -PersonalizationAppWallpaperProviderImpl::SetGooglePhotosEnabledFetcherForTest( - std::unique_ptr<wallpaper_handlers::GooglePhotosEnabledFetcher> fetcher) { - google_photos_enabled_fetcher_ = std::move(fetcher); +PersonalizationAppWallpaperProviderImpl:: + GetOrCreateGooglePhotosEnabledFetcher() { + if (!google_photos_enabled_fetcher_) { + google_photos_enabled_fetcher_ = + wallpaper_fetcher_delegate_->CreateGooglePhotosEnabledFetcher(profile_); + } return google_photos_enabled_fetcher_.get(); } wallpaper_handlers::GooglePhotosPhotosFetcher* -PersonalizationAppWallpaperProviderImpl::SetGooglePhotosPhotosFetcherForTest( - std::unique_ptr<wallpaper_handlers::GooglePhotosPhotosFetcher> fetcher) { - google_photos_photos_fetcher_ = std::move(fetcher); +PersonalizationAppWallpaperProviderImpl:: + GetOrCreateGooglePhotosPhotosFetcher() { + if (!google_photos_photos_fetcher_) { + google_photos_photos_fetcher_ = + wallpaper_fetcher_delegate_->CreateGooglePhotosPhotosFetcher(profile_); + } return google_photos_photos_fetcher_.get(); }
diff --git a/chrome/browser/ash/web_applications/personalization_app/personalization_app_wallpaper_provider_impl.h b/chrome/browser/ash/web_applications/personalization_app/personalization_app_wallpaper_provider_impl.h index 4c985f5..36ed74f 100644 --- a/chrome/browser/ash/web_applications/personalization_app/personalization_app_wallpaper_provider_impl.h +++ b/chrome/browser/ash/web_applications/personalization_app/personalization_app_wallpaper_provider_impl.h
@@ -188,21 +188,16 @@ void CancelPreviewWallpaper() override; wallpaper_handlers::GooglePhotosAlbumsFetcher* - SetGooglePhotosAlbumsFetcherForTest( - std::unique_ptr<wallpaper_handlers::GooglePhotosAlbumsFetcher> fetcher); + GetOrCreateGooglePhotosAlbumsFetcher(); wallpaper_handlers::GooglePhotosSharedAlbumsFetcher* - SetGooglePhotosSharedAlbumsFetcherForTest( - std::unique_ptr<wallpaper_handlers::GooglePhotosSharedAlbumsFetcher> - fetcher); + GetOrCreateGooglePhotosSharedAlbumsFetcher(); wallpaper_handlers::GooglePhotosEnabledFetcher* - SetGooglePhotosEnabledFetcherForTest( - std::unique_ptr<wallpaper_handlers::GooglePhotosEnabledFetcher> fetcher); + GetOrCreateGooglePhotosEnabledFetcher(); wallpaper_handlers::GooglePhotosPhotosFetcher* - SetGooglePhotosPhotosFetcherForTest( - std::unique_ptr<wallpaper_handlers::GooglePhotosPhotosFetcher> fetcher); + GetOrCreateGooglePhotosPhotosFetcher(); private: friend class PersonalizationAppWallpaperProviderImplTest;
diff --git a/chrome/browser/ash/web_applications/personalization_app/personalization_app_wallpaper_provider_impl_unittest.cc b/chrome/browser/ash/web_applications/personalization_app/personalization_app_wallpaper_provider_impl_unittest.cc index 5cdfde2..66468d6 100644 --- a/chrome/browser/ash/web_applications/personalization_app/personalization_app_wallpaper_provider_impl_unittest.cc +++ b/chrome/browser/ash/web_applications/personalization_app/personalization_app_wallpaper_provider_impl_unittest.cc
@@ -458,10 +458,7 @@ // Mock a fetcher for the enablement state query. auto* const google_photos_enabled_fetcher = static_cast<::testing::NiceMock< wallpaper_handlers::MockGooglePhotosEnabledFetcher>*>( - delegate()->SetGooglePhotosEnabledFetcherForTest( - std::make_unique<::testing::NiceMock< - wallpaper_handlers::MockGooglePhotosEnabledFetcher>>( - profile()))); + delegate()->GetOrCreateGooglePhotosEnabledFetcher()); EXPECT_CALL(*google_photos_enabled_fetcher, AddRequestAndStartIfNecessary) .Times(num_fetches); @@ -492,17 +489,12 @@ // Mock a fetcher for the albums query. auto* const google_photos_albums_fetcher = static_cast< ::testing::NiceMock<wallpaper_handlers::MockGooglePhotosAlbumsFetcher>*>( - delegate()->SetGooglePhotosAlbumsFetcherForTest( - std::make_unique<::testing::NiceMock< - wallpaper_handlers::MockGooglePhotosAlbumsFetcher>>(profile()))); + delegate()->GetOrCreateGooglePhotosAlbumsFetcher()); auto* const google_photos_shared_albums_fetcher = static_cast<::testing::NiceMock< wallpaper_handlers::MockGooglePhotosSharedAlbumsFetcher>*>( - delegate()->SetGooglePhotosSharedAlbumsFetcherForTest( - std::make_unique<::testing::NiceMock< - wallpaper_handlers::MockGooglePhotosSharedAlbumsFetcher>>( - profile()))); + delegate()->GetOrCreateGooglePhotosSharedAlbumsFetcher()); // Simulate the client making multiple requests for the same information to // test that all callbacks for that query are called. @@ -542,9 +534,7 @@ // Mock a fetcher for the albums query. auto* const google_photos_albums_fetcher = static_cast< ::testing::NiceMock<wallpaper_handlers::MockGooglePhotosAlbumsFetcher>*>( - delegate()->SetGooglePhotosAlbumsFetcherForTest( - std::make_unique<::testing::NiceMock< - wallpaper_handlers::MockGooglePhotosAlbumsFetcher>>(profile()))); + delegate()->GetOrCreateGooglePhotosAlbumsFetcher()); // The albums fetcher should never be called. EXPECT_CALL(*google_photos_albums_fetcher, AddRequestAndStartIfNecessary) @@ -570,9 +560,7 @@ // Mock a fetcher for the photos query. auto* const google_photos_photos_fetcher = static_cast< ::testing::NiceMock<wallpaper_handlers::MockGooglePhotosPhotosFetcher>*>( - delegate()->SetGooglePhotosPhotosFetcherForTest( - std::make_unique<::testing::NiceMock< - wallpaper_handlers::MockGooglePhotosPhotosFetcher>>(profile()))); + delegate()->GetOrCreateGooglePhotosPhotosFetcher()); // Simulate the client making multiple requests for the same information to // test that all callbacks for that query are called. @@ -604,9 +592,7 @@ FetchPhotosBeforeEnabled) { auto* const google_photos_photos_fetcher = static_cast< ::testing::NiceMock<wallpaper_handlers::MockGooglePhotosPhotosFetcher>*>( - delegate()->SetGooglePhotosPhotosFetcherForTest( - std::make_unique<::testing::NiceMock< - wallpaper_handlers::MockGooglePhotosPhotosFetcher>>(profile()))); + delegate()->GetOrCreateGooglePhotosPhotosFetcher()); const std::string item_id = "itemId"; const std::string album_id = "albumId";
diff --git a/chrome/browser/ash/web_applications/projector_app/projector_app_integration_browsertest.cc b/chrome/browser/ash/web_applications/projector_app/projector_app_integration_browsertest.cc index adade574..91007c3 100644 --- a/chrome/browser/ash/web_applications/projector_app/projector_app_integration_browsertest.cc +++ b/chrome/browser/ash/web_applications/projector_app/projector_app_integration_browsertest.cc
@@ -15,29 +15,19 @@ #include "chrome/browser/ui/ash/projector/projector_app_client_impl.h" #include "chrome/browser/ui/ash/system_web_apps/system_web_app_ui_utils.h" #include "content/public/test/browser_test.h" -#include "content/public/test/browser_test_utils.h" namespace { #if BUILDFLAG(ENABLE_CROS_MEDIA_APP) && BUILDFLAG(ENABLE_CROS_PROJECTOR_APP) - -static content::EvalJsResult EvalJsInMainFrame(content::WebContents* web_ui, - const std::string& script) { - // Clients of this helper all run in the same isolated world. - constexpr int kWorldId = 1; - return EvalJs(web_ui->GetPrimaryMainFrame(), script, - content::EXECUTE_SCRIPT_DEFAULT_OPTIONS, kWorldId); -} - // File containing the test utility library constexpr base::FilePath::CharType kTestLibraryPath[] = FILE_PATH_LITERAL("ash/webui/system_apps/public/js/dom_testing_helpers.js"); -void PrepareAnnotatorForTest(content::WebContents* web_contents) { +void PrepareAppForTest(content::WebContents* web_contents) { EXPECT_TRUE(WaitForLoadStop(web_contents)); EXPECT_EQ(nullptr, - EvalJsInMainFrame(web_contents, - SandboxedWebUiAppTestBase::LoadJsTestLibrary( + SandboxedWebUiAppTestBase::EvalJsInAppFrame( + web_contents, SandboxedWebUiAppTestBase::LoadJsTestLibrary( base::FilePath(kTestLibraryPath)))); } #endif // BUILDFLAG(ENABLE_CROS_MEDIA_APP) && @@ -85,7 +75,7 @@ projector_app_client->get_annotator_handler_for_test() ->get_web_ui_for_test() ->GetWebContents(); - PrepareAnnotatorForTest(annotator_embedder); + PrepareAppForTest(annotator_embedder); // Checks ink is loaded by ensuring the ink engine canvas has a non zero width // and height attributes (checking <canvas.width/height is insufficient since @@ -102,9 +92,9 @@ inkCanvas.getAttribute('width') !== '0'; })(); )"; - EXPECT_EQ( - true, - EvalJsInMainFrame(annotator_embedder, kCheckInkLoaded).ExtractBool()); + EXPECT_EQ(true, SandboxedWebUiAppTestBase::EvalJsInAppFrame( + annotator_embedder, kCheckInkLoaded) + .ExtractBool()); } #endif // BUILDFLAG(ENABLE_CROS_MEDIA_APP) && // BUILDFLAG(ENABLE_CROS_PROJECTOR_APP)
diff --git a/chrome/browser/chrome_browser_interface_binders.cc b/chrome/browser/chrome_browser_interface_binders.cc index a5fe73d..cc05624 100644 --- a/chrome/browser/chrome_browser_interface_binders.cc +++ b/chrome/browser/chrome_browser_interface_binders.cc
@@ -248,8 +248,8 @@ #include "ash/webui/personalization_app/personalization_app_ui.h" #include "ash/webui/personalization_app/search/search.mojom.h" #include "ash/webui/print_management/print_management_ui.h" -#include "ash/webui/projector_app/mojom/untrusted_annotator.mojom.h" -#include "ash/webui/projector_app/untrusted_projector_annotator_ui.h" +#include "ash/webui/projector_app/mojom/annotator.mojom.h" +#include "ash/webui/projector_app/trusted_projector_annotator_ui.h" #include "ash/webui/scanning/mojom/scanning.mojom.h" #include "ash/webui/scanning/scanning_ui.h" #include "ash/webui/shimless_rma/shimless_rma.h" @@ -1206,6 +1206,10 @@ ash::camera_app::mojom::CameraAppHelper, ash::CameraAppUI>(map); RegisterWebUIControllerInterfaceBinder< + ash::annotator::mojom::AnnotatorPageHandlerFactory, + ash::TrustedProjectorAnnotatorUI>(map); + + RegisterWebUIControllerInterfaceBinder< ash::help_app::mojom::PageHandlerFactory, ash::HelpAppUI>(map); RegisterWebUIControllerInterfaceBinder< @@ -1463,9 +1467,6 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) registry.ForWebUI<ash::DemoModeAppUntrustedUI>() .Add<ash::mojom::demo_mode::UntrustedPageHandlerFactory>(); - - registry.ForWebUI<ash::UntrustedProjectorAnnotatorUI>() - .Add<ash::annotator::mojom::UntrustedAnnotatorPageHandlerFactory>(); #endif // BUILDFLAG(IS_CHROMEOS_ASH) #if BUILDFLAG(IS_CHROMEOS_ASH) && !defined(OFFICIAL_BUILD)
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index bdef817..301fa6c 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc
@@ -488,6 +488,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_finder.h" +#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/search/new_tab_page_navigation_throttle.h" #include "chrome/browser/ui/web_applications/tabbed_web_app_navigation_throttle.h" #include "chrome/browser/ui/web_applications/webui_web_app_navigation_throttle.h" @@ -500,6 +501,8 @@ #include "chrome/browser/webauthn/chrome_authenticator_request_delegate.h" #include "chrome/grit/chrome_unscaled_resources.h" // nogncheck crbug.com/1125897 #include "components/commerce/core/commerce_feature_list.h" +#include "components/password_manager/content/common/web_ui_constants.h" +#include "components/password_manager/core/common/password_manager_features.h" #include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom.h" #endif // !BUILDFLAG(IS_ANDROID) @@ -6582,6 +6585,21 @@ } #endif +#if !BUILDFLAG(IS_ANDROID) + // TODO(crbug.com/1420597): Remove this after feature is launched. + // Redirect from old Password Manager UI in settings to new UI. + if (base::FeatureList::IsEnabled( + password_manager::features::kPasswordManagerRedesign)) { + if (url->SchemeIs(content::kChromeUIScheme) && + url->DomainIs(chrome::kChromeUISettingsHost) && + base::StartsWith( + url->path(), + chrome::GetSettingsUrl(chrome::kPasswordManagerSubPage).path())) { + *url = GURL(chrome::kChromeUIPasswordManagerURL); + } + } +#endif + return true; } @@ -6623,6 +6641,17 @@ } #endif // BUILDFLAG(IS_WIN) +#if !BUILDFLAG(IS_ANDROID) + // TODO(crbug.com/1420597): Remove this after feature is launched. + // No need to actually reverse-rewrite the URL, but return true to update the + // displayed URL when rewriting chrome://settings/passwords to + // chrome://password-manager. + if (url->SchemeIs(content::kChromeUIScheme) && + url->DomainIs(password_manager::kChromeUIPasswordManagerHost)) { + return true; + } +#endif + // No need to actually reverse-rewrite the URL, but return true to update the // displayed URL when rewriting chrome://help to chrome://settings/help. return url->SchemeIs(content::kChromeUIScheme) &&
diff --git a/chrome/browser/chrome_content_browser_client_unittest.cc b/chrome/browser/chrome_content_browser_client_unittest.cc index bfe5321..3db84f2 100644 --- a/chrome/browser/chrome_content_browser_client_unittest.cc +++ b/chrome/browser/chrome_content_browser_client_unittest.cc
@@ -66,10 +66,12 @@ #if !BUILDFLAG(IS_ANDROID) #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/browser_with_test_window_test.h" #include "chrome/test/base/search_test_utils.h" +#include "components/password_manager/core/common/password_manager_features.h" #include "ui/base/page_transition_types.h" #else #include "base/system/sys_info.h" @@ -549,6 +551,11 @@ GURL chrome_settings(chrome::kChromeUISettingsURL); EXPECT_TRUE(test_content_browser_client.HandleWebUIReverse(&chrome_settings, &profile_)); +#if !BUILDFLAG(IS_ANDROID) + GURL chrome_passwords_in_settings(chrome::kChromeUIPasswordManagerURL); + EXPECT_TRUE(test_content_browser_client.HandleWebUIReverse( + &chrome_passwords_in_settings, &profile_)); +#endif } #if !BUILDFLAG(IS_ANDROID) @@ -579,6 +586,22 @@ histogram_tester.ExpectBucketCount(histogram_name, false, 1); histogram_tester.ExpectTotalCount(histogram_name, 2); } + +TEST_F(ChromeContentBrowserClientTest, RedirectToPasswordManager) { + base::test::ScopedFeatureList feature_list( + password_manager::features::kPasswordManagerRedesign); + + TestChromeContentBrowserClient test_content_browser_client; + + GURL settings_url = chrome::GetSettingsUrl(chrome::kPasswordManagerSubPage); + settings_url = net::AppendQueryParameter(settings_url, "foo", "bar"); + + GURL new_passwords_url = GURL(chrome::kChromeUIPasswordManagerURL); + + test_content_browser_client.HandleWebUI(&settings_url, &profile_); + EXPECT_EQ(settings_url, new_passwords_url); +} + #endif #if BUILDFLAG(IS_CHROMEOS)
diff --git a/chrome/browser/chromeos/extensions/telemetry/chromeos_permission_messages_unittest.cc b/chrome/browser/chromeos/extensions/telemetry/chromeos_permission_messages_unittest.cc index f4a7444..766cbe1 100644 --- a/chrome/browser/chromeos/extensions/telemetry/chromeos_permission_messages_unittest.cc +++ b/chrome/browser/chromeos/extensions/telemetry/chromeos_permission_messages_unittest.cc
@@ -8,6 +8,7 @@ #include <vector> #include "base/memory/scoped_refptr.h" +#include "base/test/scoped_feature_list.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/permissions_test_util.h" #include "chrome/browser/extensions/test_extension_environment.h" @@ -15,6 +16,7 @@ #include "chrome/test/base/testing_profile.h" #include "extensions/common/extension.h" #include "extensions/common/extension_builder.h" +#include "extensions/common/extension_features.h" #include "extensions/common/manifest.h" #include "extensions/common/manifest_handlers/permissions_parser.h" #include "extensions/common/permissions/permission_set.h" @@ -201,7 +203,32 @@ active_permissions()[0]); } -TEST_F(ChromeOSPermissionMessageUnittest, OsTelemetryEventsMessage) { +TEST_F(ChromeOSPermissionMessageUnittest, OsTelemetryEvents_ErrorFeatureFlag) { + CreateAndInstallExtensionWithPermissions( + base::Value::List(), + extensions::ListBuilder().Append("os.events").Build()); + + EXPECT_EQ(0U, optional_permissions().size()); + EXPECT_EQ(0U, GetInactiveOptionalPermissionMessages().size()); + + EXPECT_EQ(0U, required_permissions().size()); + EXPECT_EQ(0U, active_permissions().size()); +} + +class ChromeOSPermissionMessageUnittestWithPendingApprovalPermission + : public ChromeOSPermissionMessageUnittest { + public: + ChromeOSPermissionMessageUnittestWithPendingApprovalPermission() { + feature_list_.InitAndEnableFeature( + extensions_features::kTelemetryExtensionPendingApprovalApi); + } + + private: + base::test::ScopedFeatureList feature_list_; +}; + +TEST_F(ChromeOSPermissionMessageUnittestWithPendingApprovalPermission, + OsTelemetryEventsMessage) { CreateAndInstallExtensionWithPermissions( base::Value::List(), extensions::ListBuilder().Append("os.events").Build());
diff --git a/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api_unittest.cc b/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api_unittest.cc index 965d3d2..cb7b24f 100644 --- a/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api_unittest.cc +++ b/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api_unittest.cc
@@ -15,6 +15,7 @@ #include "chrome/test/base/testing_profile.h" #include "components/bookmarks/browser/bookmark_model.h" #include "components/bookmarks/test/bookmark_test_helpers.h" +#include "components/policy/core/common/policy_pref_names.h" #include "extensions/browser/api_test_utils.h" namespace extensions { @@ -141,7 +142,7 @@ RunOpenInNewWindowFunctionIncognitoDisabled) { // Incognito disabled. IncognitoModePrefs::SetAvailability( - profile()->GetPrefs(), IncognitoModePrefs::Availability::kDisabled); + profile()->GetPrefs(), policy::IncognitoModeAvailability::kDisabled); auto new_window_function = base::MakeRefCounted<BookmarkManagerPrivateOpenInNewWindowFunction>(); @@ -155,7 +156,7 @@ RunOpenInNewWindowFunctionIncognitoForced) { // Incognito forced. IncognitoModePrefs::SetAvailability( - profile()->GetPrefs(), IncognitoModePrefs::Availability::kForced); + profile()->GetPrefs(), policy::IncognitoModeAvailability::kForced); auto new_window_function = base::MakeRefCounted<BookmarkManagerPrivateOpenInNewWindowFunction>();
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc index e657c5a..3c8e587 100644 --- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc +++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
@@ -61,6 +61,7 @@ #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "chrome/grit/generated_resources.h" +#include "components/policy/core/common/policy_pref_names.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_details.h" @@ -505,7 +506,7 @@ const PrefService::Preference* pref = prefs->FindPreference(prefs::kExtensionsUIDeveloperMode); info->is_incognito_available = IncognitoModePrefs::GetAvailability(prefs) != - IncognitoModePrefs::Availability::kDisabled; + policy::IncognitoModeAvailability::kDisabled; info->is_developer_mode_controlled_by_policy = pref->IsManaged(); info->in_developer_mode = !info->is_child_account &&
diff --git a/chrome/browser/extensions/api/tabs/tabs_apitest.cc b/chrome/browser/extensions/api/tabs/tabs_apitest.cc index a93e4cd0..5dc93ec 100644 --- a/chrome/browser/extensions/api/tabs/tabs_apitest.cc +++ b/chrome/browser/extensions/api/tabs/tabs_apitest.cc
@@ -18,6 +18,7 @@ #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/ui_test_utils.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/prefs/pref_service.h" #include "content/public/common/content_features.h" #include "content/public/test/back_forward_cache_util.h" @@ -352,7 +353,7 @@ IncognitoDisabledByPref) { IncognitoModePrefs::SetAvailability( browser()->profile()->GetPrefs(), - IncognitoModePrefs::Availability::kDisabled); + policy::IncognitoModeAvailability::kDisabled); // This makes sure that creating an incognito window fails due to pref // (policy) being set.
diff --git a/chrome/browser/extensions/api/tabs/tabs_test.cc b/chrome/browser/extensions/api/tabs/tabs_test.cc index f3c5fef..8df399c 100644 --- a/chrome/browser/extensions/api/tabs/tabs_test.cc +++ b/chrome/browser/extensions/api/tabs/tabs_test.cc
@@ -44,6 +44,7 @@ #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" #include "chrome/common/webui_url_constants.h" #include "chrome/test/base/ui_test_utils.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/prefs/pref_service.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/notification_service.h" @@ -456,7 +457,7 @@ // Force Incognito mode. IncognitoModePrefs::SetAvailability( browser()->profile()->GetPrefs(), - IncognitoModePrefs::Availability::kForced); + policy::IncognitoModeAvailability::kForced); // Run without an explicit "incognito" param. scoped_refptr<WindowsCreateFunction> function(new WindowsCreateFunction()); function->SetRenderFrameHost(browser() @@ -500,7 +501,7 @@ // Force Incognito mode. IncognitoModePrefs::SetAvailability( browser()->profile()->GetPrefs(), - IncognitoModePrefs::Availability::kForced); + policy::IncognitoModeAvailability::kForced); // Run without an explicit "incognito" param. scoped_refptr<WindowsCreateFunction> function = new WindowsCreateFunction(); scoped_refptr<const Extension> extension(ExtensionBuilder("Test").Build()); @@ -537,7 +538,7 @@ // Force Incognito mode. IncognitoModePrefs::SetAvailability( browser()->profile()->GetPrefs(), - IncognitoModePrefs::Availability::kForced); + policy::IncognitoModeAvailability::kForced); // Run with an explicit "incognito" param. scoped_refptr<WindowsCreateFunction> function = new WindowsCreateFunction(); @@ -568,7 +569,7 @@ // Disable Incognito mode. IncognitoModePrefs::SetAvailability( browser()->profile()->GetPrefs(), - IncognitoModePrefs::Availability::kDisabled); + policy::IncognitoModeAvailability::kDisabled); // Run in normal window. scoped_refptr<WindowsCreateFunction> function = new WindowsCreateFunction(); scoped_refptr<const Extension> extension(ExtensionBuilder("Test").Build());
diff --git a/chrome/browser/extensions/api/tabs/windows_util.cc b/chrome/browser/extensions/api/tabs/windows_util.cc index b40f7d7..b0b66087 100644 --- a/chrome/browser/extensions/api/tabs/windows_util.cc +++ b/chrome/browser/extensions/api/tabs/windows_util.cc
@@ -16,6 +16,7 @@ #include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser_navigator.h" +#include "components/policy/core/common/policy_pref_names.h" #include "extensions/browser/extension_function.h" #include "extensions/browser/extension_function_dispatcher.h" #include "extensions/common/constants.h" @@ -100,23 +101,23 @@ absl::optional<bool> incognito, std::vector<GURL>* urls, std::string* error) { - const IncognitoModePrefs::Availability incognito_availability = + const policy::IncognitoModeAvailability incognito_availability = IncognitoModePrefs::GetAvailability(profile->GetPrefs()); bool incognito_result = false; if (incognito.has_value()) { incognito_result = incognito.value(); - if (incognito_result && - incognito_availability == IncognitoModePrefs::Availability::kDisabled) { + if (incognito_result && incognito_availability == + policy::IncognitoModeAvailability::kDisabled) { *error = extensions::tabs_constants::kIncognitoModeIsDisabled; return IncognitoResult::kError; } if (!incognito_result && - incognito_availability == IncognitoModePrefs::Availability::kForced) { + incognito_availability == policy::IncognitoModeAvailability::kForced) { *error = extensions::tabs_constants::kIncognitoModeIsForced; return IncognitoResult::kError; } } else if (incognito_availability == - IncognitoModePrefs::Availability::kForced) { + policy::IncognitoModeAvailability::kForced) { // If incognito argument is not specified explicitly, we default to // incognito when forced so by policy. incognito_result = true;
diff --git a/chrome/browser/extensions/api/tabs/windows_util_unittest.cc b/chrome/browser/extensions/api/tabs/windows_util_unittest.cc index 5c21dd79..11a3244 100644 --- a/chrome/browser/extensions/api/tabs/windows_util_unittest.cc +++ b/chrome/browser/extensions/api/tabs/windows_util_unittest.cc
@@ -14,6 +14,7 @@ #include "chrome/test/base/testing_profile.h" #include "components/bookmarks/browser/bookmark_model.h" #include "components/bookmarks/test/bookmark_test_helpers.h" +#include "components/policy/core/common/policy_pref_names.h" #include "extensions/browser/api_test_utils.h" namespace windows_util { @@ -29,7 +30,7 @@ TEST_F(WindowsUtilUnitTest, ShouldOpenIncognitoWindowIncognitoDisabled) { // Incognito disabled. IncognitoModePrefs::SetAvailability( - profile()->GetPrefs(), IncognitoModePrefs::Availability::kDisabled); + profile()->GetPrefs(), policy::IncognitoModeAvailability::kDisabled); std::string error; std::vector<GURL> urls; @@ -43,7 +44,7 @@ TEST_F(WindowsUtilUnitTest, ShouldOpenIncognitoWindowIncognitoForced) { // Incognito forced. IncognitoModePrefs::SetAvailability( - profile()->GetPrefs(), IncognitoModePrefs::Availability::kForced); + profile()->GetPrefs(), policy::IncognitoModeAvailability::kForced); std::string error; std::vector<GURL> urls;
diff --git a/chrome/browser/extensions/content_script_apitest.cc b/chrome/browser/extensions/content_script_apitest.cc index 6f62be03..f5c44d4 100644 --- a/chrome/browser/extensions/content_script_apitest.cc +++ b/chrome/browser/extensions/content_script_apitest.cc
@@ -62,7 +62,6 @@ #include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_response.h" -#include "services/network/public/cpp/features.h" #include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/privacy_budget/identifiable_surface.h" #include "ui/base/l10n/l10n_util.h" @@ -2246,19 +2245,8 @@ } class ContentScriptApiPrerenderingTest : public ContentScriptApiTest { - public: - ContentScriptApiPrerenderingTest() { - feature_list_.InitWithFeatures( - { - network::features::kPrerender2ContentSecurityPolicyExtensions, - extensions_features::kMinimumMV3CSPWithInlineSpeculationRules, - }, - {}); - } - private: content::test::ScopedPrerenderFeatureList prerender_feature_list_; - base::test::ScopedFeatureList feature_list_; }; IN_PROC_BROWSER_TEST_F(ContentScriptApiPrerenderingTest, Prerendering) {
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json index bcc31002..9d18a806 100644 --- a/chrome/browser/flag-metadata.json +++ b/chrome/browser/flag-metadata.json
@@ -4957,7 +4957,7 @@ { "name": "more-video-capture-buffers", "owners": [ "chromeos-camera-eng@google.com" ], - "expiry_milestone": 110 + "expiry_milestone": 120 }, { "name": "most-visited-tiles",
diff --git a/chrome/browser/incognito/android/incognito_utils_android.cc b/chrome/browser/incognito/android/incognito_utils_android.cc index 117856e..6c17979 100644 --- a/chrome/browser/incognito/android/incognito_utils_android.cc +++ b/chrome/browser/incognito/android/incognito_utils_android.cc
@@ -13,13 +13,13 @@ static jboolean JNI_IncognitoUtils_GetIncognitoModeEnabled(JNIEnv* env) { PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetOriginalProfile()->GetPrefs(); - IncognitoModePrefs::Availability incognito_pref = + policy::IncognitoModeAvailability incognito_pref = IncognitoModePrefs::GetAvailability(prefs); - DCHECK(incognito_pref == IncognitoModePrefs::Availability::kEnabled || - incognito_pref == IncognitoModePrefs::Availability::kDisabled) + DCHECK(incognito_pref == policy::IncognitoModeAvailability::kEnabled || + incognito_pref == policy::IncognitoModeAvailability::kDisabled) << "Unsupported incognito mode preference: " << static_cast<int>(incognito_pref); - return incognito_pref != IncognitoModePrefs::Availability::kDisabled; + return incognito_pref != policy::IncognitoModeAvailability::kDisabled; } static jboolean JNI_IncognitoUtils_GetIncognitoModeManaged(JNIEnv* env) {
diff --git a/chrome/browser/lacros/browser_service_lacros.cc b/chrome/browser/lacros/browser_service_lacros.cc index 6b8d4f2..6fb18ee 100644 --- a/chrome/browser/lacros/browser_service_lacros.cc +++ b/chrome/browser/lacros/browser_service_lacros.cc
@@ -59,6 +59,7 @@ #include "components/feedback/system_logs/system_logs_fetcher.h" #include "components/keep_alive_registry/keep_alive_types.h" #include "components/keep_alive_registry/scoped_keep_alive.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/sessions/content/session_tab_helper.h" #include "content/public/browser/browser_thread.h" #include "google_apis/gaia/gaia_auth_util.h" @@ -551,16 +552,16 @@ } switch (IncognitoModePrefs::GetAvailability(profile->GetPrefs())) { - case IncognitoModePrefs::Availability::kEnabled: + case policy::IncognitoModeAvailability::kEnabled: // Default behavior: both incognito and regular mode are allowed. break; - case IncognitoModePrefs::Availability::kDisabled: + case policy::IncognitoModeAvailability::kDisabled: incognito = false; break; - case IncognitoModePrefs::Availability::kForced: + case policy::IncognitoModeAvailability::kForced: incognito = true; break; - case IncognitoModePrefs::Availability::kNumTypes: + case policy::IncognitoModeAvailability::kNumTypes: NOTREACHED(); break; }
diff --git a/chrome/browser/lacros/browser_service_lacros_browsertest.cc b/chrome/browser/lacros/browser_service_lacros_browsertest.cc index a612cb78..401c24c 100644 --- a/chrome/browser/lacros/browser_service_lacros_browsertest.cc +++ b/chrome/browser/lacros/browser_service_lacros_browsertest.cc
@@ -38,6 +38,7 @@ #include "chromeos/startup/browser_params_proxy.h" #include "components/keep_alive_registry/keep_alive_types.h" #include "components/keep_alive_registry/scoped_keep_alive.h" +#include "components/policy/core/common/policy_pref_names.h" #include "content/public/test/browser_test.h" #include "content/public/test/browser_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" @@ -436,7 +437,7 @@ ProfileManager::GetPrimaryUserProfilePath()); // Disallow incognito. IncognitoModePrefs::SetAvailability( - main_profile->GetPrefs(), IncognitoModePrefs::Availability::kDisabled); + main_profile->GetPrefs(), policy::IncognitoModeAvailability::kDisabled); // Request a new incognito window. NewWindowSync(/*incognito=*/true, /*should_trigger_session_restore=*/false); // A regular window opens instead.
diff --git a/chrome/browser/mac/auth_session_request.mm b/chrome/browser/mac/auth_session_request.mm index ae45961..c1d8c450 100644 --- a/chrome/browser/mac/auth_session_request.mm +++ b/chrome/browser/mac/auth_session_request.mm
@@ -17,6 +17,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" +#include "components/policy/core/common/policy_pref_names.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_handle.h" @@ -225,7 +226,7 @@ bool ephemeral_sessions_allowed_by_policy = IncognitoModePrefs::GetAvailability(profile->GetPrefs()) != - IncognitoModePrefs::Availability::kDisabled; + policy::IncognitoModeAvailability::kDisabled; // As per the documentation for `shouldUseEphemeralSession`: "Whether the // request is honored depends on the user’s default web browser." If policy
diff --git a/chrome/browser/page_load_metrics/observers/ad_metrics/overlay_popup_ad_intervention_browsertest.cc b/chrome/browser/page_load_metrics/observers/ad_metrics/overlay_popup_ad_intervention_browsertest.cc index 429849cd..6e120d3 100644 --- a/chrome/browser/page_load_metrics/observers/ad_metrics/overlay_popup_ad_intervention_browsertest.cc +++ b/chrome/browser/page_load_metrics/observers/ad_metrics/overlay_popup_ad_intervention_browsertest.cc
@@ -155,10 +155,12 @@ base::test::ScopedFeatureList feature_list_; }; -// TODO(https://crbug.com/1394447): Fails on Linux MSan or ChromeOS Asan LSsan. -#if (BUILDFLAG(IS_LINUX) && defined(MEMORY_SANITIZER)) || \ - (BUILDFLAG(IS_CHROMEOS) && defined(ADDRESS_SANITIZER) && \ - defined(LEAK_SANITIZER)) +// TODO(https://crbug.com/1394447): Fails on Linux MSan, and ChromeOS Debug as +// well as Asan LSsan. +#if (BUILDFLAG(IS_LINUX) && defined(MEMORY_SANITIZER)) || \ + (BUILDFLAG(IS_CHROMEOS) && \ + (!defined(NDEBUG) || defined(ADDRESS_SANITIZER) || \ + defined(LEAK_SANITIZER))) #define MAYBE_OverlayPopupAd_NoAdInterventionTriggered \ DISABLED_OverlayPopupAd_NoAdInterventionTriggered #else
diff --git a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.cc b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.cc index c20ca87..3bcfb0f 100644 --- a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.cc +++ b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.cc
@@ -138,7 +138,7 @@ } bool PasswordManagerSettingsServiceAndroidImpl::IsSettingEnabled( - PasswordManagerSetting setting) { + PasswordManagerSetting setting) const { if (setting == PasswordManagerSetting::kOfferToSavePasswords && ShouldSuspendPasswordSavingDueToError(pref_service_)) { return false;
diff --git a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.h b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.h index 5e48982..e9a687ee 100644 --- a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.h +++ b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.h
@@ -53,7 +53,7 @@ // PasswordManagerSettingsService implementation bool IsSettingEnabled( - password_manager::PasswordManagerSetting setting) override; + password_manager::PasswordManagerSetting setting) const override; void RequestSettingsFromBackend() override; void TurnOffAutoSignIn() override;
diff --git a/chrome/browser/password_manager/android/save_update_password_message_delegate.cc b/chrome/browser/password_manager/android/save_update_password_message_delegate.cc index 60bfd2c..033bec0 100644 --- a/chrome/browser/password_manager/android/save_update_password_message_delegate.cc +++ b/chrome/browser/password_manager/android/save_update_password_message_delegate.cc
@@ -80,6 +80,18 @@ "UpdateWithUsernameConfirmation", reason); } + +bool UPMExploratoryStringsEnabledWithSupportedParam() { + if (!base::FeatureList::IsEnabled( + password_manager::features::kExploratorySaveUpdatePasswordStrings)) { + return false; + } + + int string_version = + password_manager::features::kSaveUpdatePromptSyncingStringVersion.Get(); + return string_version == 2 || string_version == 3; +} + } // namespace SaveUpdatePasswordMessageDelegate::SaveUpdatePasswordMessageDelegate() @@ -293,8 +305,7 @@ const password_manager::PasswordForm& pending_credentials, bool update_password, bool unified_password_manager) { - if (base::FeatureList::IsEnabled( - password_manager::features::kExploratorySaveUpdatePasswordStrings)) { + if (UPMExploratoryStringsEnabledWithSupportedParam()) { return GetExploratoryStringsMessageDescription(update_password); }
diff --git a/chrome/browser/password_manager/android/save_update_password_message_delegate_unittest.cc b/chrome/browser/password_manager/android/save_update_password_message_delegate_unittest.cc index aa720e2..1e1354b 100644 --- a/chrome/browser/password_manager/android/save_update_password_message_delegate_unittest.cc +++ b/chrome/browser/password_manager/android/save_update_password_message_delegate_unittest.cc
@@ -97,8 +97,7 @@ }; class SaveUpdatePasswordMessageDelegateTest - : public testing::WithParamInterface<FeatureConfigTestParam>, - public ChromeRenderViewHostTestHarness { + : public ChromeRenderViewHostTestHarness { public: SaveUpdatePasswordMessageDelegateTest(); @@ -106,8 +105,6 @@ void SetUp() override; void TearDown() override; - void InitFeatureList(); - std::unique_ptr<MockPasswordFormManagerForUI> CreateFormManager( const GURL& password_form_url, const std::vector<const PasswordForm*>* best_matches); @@ -150,22 +147,16 @@ void TriggerLegacyDialogAcceptedCallback(int selected_username_index); void TriggerDialogDismissedCallback(bool dialog_accepted); + // TODO(crbug.com/1428562): Remove this helper as it makes tests hard to read. + std::u16string GetExpectedUPMMessageDescription( + bool is_update, + bool is_signed_in, + const std::u16string& account_email); void CommitPasswordFormMetrics(); void VerifyUkmMetrics(const ukm::TestUkmRecorder& ukm_recorder, PasswordFormMetricsRecorder::BubbleDismissalReason expected_dismissal_reason); - std::u16string GetUnifiedPasswordManagerMessageDescription( - bool is_update, - bool is_signed_in, - const std::u16string& account_email); - - std::u16string GetExploratoryStringsMessageDescription( - bool is_update, - bool is_signed_in, - const std::u16string& account_email, - int new_string_version); - messages::MockMessageDispatcherBridge* message_dispatcher_bridge() { return &message_dispatcher_bridge_; } @@ -185,7 +176,6 @@ const std::vector<const PasswordForm*> kTwoFormsBestMatches = { &kPasswordForm1, &kPasswordForm2}; - base::test::ScopedFeatureList scoped_feature_list_; PasswordForm pending_credentials_; std::unique_ptr<SaveUpdatePasswordMessageDelegate> delegate_; GURL password_form_url_; @@ -199,6 +189,24 @@ PasswordEditDialog::DialogDismissedCallback dialog_dismissed_callback_; }; +class SaveUpdatePasswordMessageDelegateWithFeaturesTest + : public testing::WithParamInterface<FeatureConfigTestParam>, + public SaveUpdatePasswordMessageDelegateTest { + protected: + void SetUp() override; + void InitFeatureList(); + + // TODO(crbug.com/1428562): Remove this helper as it makes tests hard to read. + std::u16string GetExploratoryStringsMessageDescription( + bool is_update, + bool is_signed_in, + const std::u16string& account_email, + int new_string_version); + + private: + base::test::ScopedFeatureList scoped_feature_list_; +}; + SaveUpdatePasswordMessageDelegateTest::SaveUpdatePasswordMessageDelegateTest() : delegate_(base::WrapUnique( new SaveUpdatePasswordMessageDelegate(base::BindRepeating( @@ -206,8 +214,6 @@ base::Unretained(this))))) {} void SaveUpdatePasswordMessageDelegateTest::SetUp() { - InitFeatureList(); - ChromeRenderViewHostTestHarness::SetUp(); ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( web_contents(), nullptr); @@ -225,41 +231,10 @@ ChromeRenderViewHostTestHarness::TearDown(); } -void SaveUpdatePasswordMessageDelegateTest::InitFeatureList() { - std::vector<FeatureRefAndParams> enabled_features; - std::vector<FeatureRef> disabled_features; - - FeatureConfigTestParam feature_config = GetParam(); - if (feature_config.with_unified_password_manager_android) { - enabled_features.push_back( - {password_manager::features::kUnifiedPasswordManagerAndroid, {}}); - } else { - disabled_features.push_back( - password_manager::features::kUnifiedPasswordManagerAndroid); - disabled_features.push_back( - password_manager::features::kUnifiedPasswordManagerAndroidBranding); - } - - if (feature_config.with_exploratory_save_update_password_strings) { - enabled_features.push_back( - {password_manager::features::kExploratorySaveUpdatePasswordStrings, - {{password_manager::features::kSaveUpdatePromptSyncingStringVersion - .name, - base::NumberToString( - feature_config.save_update_prompt_syncing_string_version)}}}); - } else { - disabled_features.push_back( - password_manager::features::kExploratorySaveUpdatePasswordStrings); - } - - // This feature only concerns AccountInfo with configured AccountCapabilities. - enabled_features.push_back( - {chrome::android::kHideNonDisplayableAccountEmail, {}}); - - scoped_feature_list_.InitWithFeaturesAndParameters(enabled_features, - disabled_features); +void SaveUpdatePasswordMessageDelegateWithFeaturesTest::SetUp() { + SaveUpdatePasswordMessageDelegateTest::SetUp(); + InitFeatureList(); } - std::unique_ptr<MockPasswordFormManagerForUI> SaveUpdatePasswordMessageDelegateTest::CreateFormManager( const GURL& password_form_url, @@ -404,6 +379,24 @@ std::move(dialog_dismissed_callback_).Run(dialog_accepted); } +std::u16string +SaveUpdatePasswordMessageDelegateTest::GetExpectedUPMMessageDescription( + bool is_update, + bool is_signed_in, + const std::u16string& account_email) { + if (is_signed_in) { + return l10n_util::GetStringFUTF16( + is_update + ? IDS_PASSWORD_MANAGER_UPDATE_PASSWORD_SIGNED_IN_MESSAGE_DESCRIPTION + : IDS_PASSWORD_MANAGER_SAVE_PASSWORD_SIGNED_IN_MESSAGE_DESCRIPTION, + account_email); + } + return l10n_util::GetStringUTF16( + is_update + ? IDS_PASSWORD_MANAGER_UPDATE_PASSWORD_SIGNED_OUT_MESSAGE_DESCRIPTION + : IDS_PASSWORD_MANAGER_SAVE_PASSWORD_SIGNED_OUT_MESSAGE_DESCRIPTION); +} + void SaveUpdatePasswordMessageDelegateTest::CommitPasswordFormMetrics() { // PasswordFormMetricsRecorder::dtor commits accumulated metrics. metrics_recorder_.reset(); @@ -430,30 +423,46 @@ } } -std::u16string SaveUpdatePasswordMessageDelegateTest:: - GetUnifiedPasswordManagerMessageDescription( - bool is_update, - bool is_signed_in, - const std::u16string& account_email) { - if (is_signed_in) { - return l10n_util::GetStringFUTF16( - is_update - ? IDS_PASSWORD_MANAGER_UPDATE_PASSWORD_SIGNED_IN_MESSAGE_DESCRIPTION - : IDS_PASSWORD_MANAGER_SAVE_PASSWORD_SIGNED_IN_MESSAGE_DESCRIPTION, - account_email); +void SaveUpdatePasswordMessageDelegateWithFeaturesTest::InitFeatureList() { + std::vector<FeatureRefAndParams> enabled_features; + std::vector<FeatureRef> disabled_features; + + FeatureConfigTestParam feature_config = GetParam(); + if (feature_config.with_unified_password_manager_android) { + enabled_features.push_back( + {password_manager::features::kUnifiedPasswordManagerAndroid, {}}); + } else { + disabled_features.push_back( + password_manager::features::kUnifiedPasswordManagerAndroid); + disabled_features.push_back( + password_manager::features::kUnifiedPasswordManagerAndroidBranding); } - return l10n_util::GetStringUTF16( - is_update - ? IDS_PASSWORD_MANAGER_UPDATE_PASSWORD_SIGNED_OUT_MESSAGE_DESCRIPTION - : IDS_PASSWORD_MANAGER_SAVE_PASSWORD_SIGNED_OUT_MESSAGE_DESCRIPTION); + + if (feature_config.with_exploratory_save_update_password_strings) { + enabled_features.push_back( + {password_manager::features::kExploratorySaveUpdatePasswordStrings, + {{password_manager::features::kSaveUpdatePromptSyncingStringVersion + .name, + base::NumberToString( + feature_config.save_update_prompt_syncing_string_version)}}}); + } else { + disabled_features.push_back( + password_manager::features::kExploratorySaveUpdatePasswordStrings); + } + + // This feature only concerns AccountInfo with configured AccountCapabilities. + enabled_features.push_back( + {chrome::android::kHideNonDisplayableAccountEmail, {}}); + + scoped_feature_list_.InitWithFeaturesAndParameters(enabled_features, + disabled_features); } -std::u16string -SaveUpdatePasswordMessageDelegateTest::GetExploratoryStringsMessageDescription( - bool is_update, - bool is_signed_in, - const std::u16string& account_email, - int new_string_version) { +std::u16string SaveUpdatePasswordMessageDelegateWithFeaturesTest:: + GetExploratoryStringsMessageDescription(bool is_update, + bool is_signed_in, + const std::u16string& account_email, + int new_string_version) { if (!is_signed_in) { return l10n_util::GetStringUTF16( IDS_PASSWORD_MANAGER_SAVE_UPDATE_PASSWORD_SIGNED_OUT_MESSAGE_DESCRIPTION_V1); @@ -478,129 +487,8 @@ } } -// Tests that message properties (title, description, icon, button text) are -// set correctly for save password message. -TEST_P(SaveUpdatePasswordMessageDelegateTest, - MessagePropertyValues_SavePassword) { - SetPendingCredentials(kUsername, kPassword); - auto form_manager = - CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); - const bool is_signed_in = false; - const bool is_update = false; - EnqueueMessage(std::move(form_manager), /*user_signed_in=*/is_signed_in, - /*update_password=*/is_update); - - EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON), - GetMessageWrapper()->GetPrimaryButtonText()); - - // Validate message description that depends on - // kExploratorySaveUpdatePasswordStrings feature - if (GetParam().with_exploratory_save_update_password_strings) { - // password_manager::features::kExploratorySaveUpdatePasswordStrings is - // enabled - EXPECT_EQ(GetExploratoryStringsMessageDescription( - is_update, is_signed_in, kAccountEmail16, - GetParam().save_update_prompt_syncing_string_version), - GetMessageWrapper()->GetDescription()); - } else if (GetParam().with_unified_password_manager_android) { - // password_manager::features::kUnifiedPasswordManagerAndroid is enabled - EXPECT_EQ(GetUnifiedPasswordManagerMessageDescription( - is_update, is_signed_in, kAccountEmail16), - GetMessageWrapper()->GetDescription()); - } else { - EXPECT_NE(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kUsername)); - EXPECT_EQ(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kPassword)); - EXPECT_EQ(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kAccountEmail16)); - } - - // Validate remaining message fields - if (GetParam().with_unified_password_manager_android) { - // password_manager::features::kUnifiedPasswordManagerAndroid is enabled - EXPECT_EQ(ResourceMapper::MapToJavaDrawableId( - IDR_ANDROID_PASSWORD_MANAGER_LOGO_24DP), - GetMessageWrapper()->GetIconResourceId()); - } else { - EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD), - GetMessageWrapper()->GetTitle()); - EXPECT_EQ( - ResourceMapper::MapToJavaDrawableId(IDR_ANDROID_INFOBAR_SAVE_PASSWORD), - GetMessageWrapper()->GetIconResourceId()); - } - - EXPECT_EQ(ResourceMapper::MapToJavaDrawableId(IDR_ANDROID_MESSAGE_SETTINGS), - GetMessageWrapper()->GetSecondaryIconResourceId()); - - DismissMessage(messages::DismissReason::UNKNOWN); -} - -// Tests that secondary button title is right. -// kPasswordEditDialogWithDetails feature off. -TEST_P(SaveUpdatePasswordMessageDelegateTest, - MessageSecondaryButtonProperty_SavePassword) { - base::test::ScopedFeatureList scoped_feature_state; - scoped_feature_state.InitAndDisableFeature( - password_manager::features::kPasswordEditDialogWithDetails); - - SetPendingCredentials(kUsername, kPassword); - auto form_manager = - CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); - EnqueueMessage(std::move(form_manager), /*user_signed_in=*/false, - /*update_password=*/false); - - if (GetParam().with_unified_password_manager_android) { - // password_manager::features::kUnifiedPasswordManagerAndroid is enabled - EXPECT_EQ( - l10n_util::GetStringUTF16(IDS_PASSWORD_MESSAGE_NEVER_SAVE_MENU_ITEM), - GetMessageWrapper()->GetSecondaryButtonMenuText()); - } else { - EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BLOCKLIST_BUTTON), - GetMessageWrapper()->GetSecondaryButtonMenuText()); - } - DismissMessage(messages::DismissReason::UNKNOWN); -} - -// Tests that message properties (title, description, icon, button text) are -// set correctly for update password message. -TEST_P(SaveUpdatePasswordMessageDelegateTest, - MessagePropertyValues_UpdatePassword) { - SetPendingCredentials(kUsername, kPassword); - auto form_manager = - CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); - const bool is_signed_in = false; - const bool is_update = true; - EnqueueMessage(std::move(form_manager), /*user_signed_in=*/is_signed_in, - /*update_password=*/is_update); - - EXPECT_EQ(l10n_util::GetStringUTF16(IDS_UPDATE_PASSWORD), - GetMessageWrapper()->GetTitle()); - - if (GetParam().with_exploratory_save_update_password_strings) { - // password_manager::features::kExploratorySaveUpdatePasswordStrings is - // enabled - EXPECT_EQ(GetExploratoryStringsMessageDescription( - is_update, is_signed_in, kAccountEmail16, - GetParam().save_update_prompt_syncing_string_version), - GetMessageWrapper()->GetDescription()); - } else if (GetParam().with_unified_password_manager_android) { - // password_manager::features::kUnifiedPasswordManagerAndroid is enabled - EXPECT_EQ(GetUnifiedPasswordManagerMessageDescription( - is_update, is_signed_in, kAccountEmail16), - GetMessageWrapper()->GetDescription()); - } - - EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UPDATE_BUTTON), - GetMessageWrapper()->GetPrimaryButtonText()); - EXPECT_EQ(std::u16string(), - GetMessageWrapper()->GetSecondaryButtonMenuText()); - - DismissMessage(messages::DismissReason::UNKNOWN); -} - // Tests that secondary menu icon is set for the save password message -TEST_P(SaveUpdatePasswordMessageDelegateTest, +TEST_F(SaveUpdatePasswordMessageDelegateTest, CogButton_SavePassword_PasswordEditDialogWithDetails) { base::test::ScopedFeatureList scoped_feature_state; scoped_feature_state.InitWithFeatures( @@ -621,7 +509,7 @@ // Tests that secondary menu icon is set for the update password message // in case when user has only single credential stored for the web site -TEST_P(SaveUpdatePasswordMessageDelegateTest, +TEST_F(SaveUpdatePasswordMessageDelegateTest, CogButton_SingleCredUpdatePassword_PasswordEditDialogWithDetails) { base::test::ScopedFeatureList scoped_feature_state; scoped_feature_state.InitWithFeatures( @@ -642,7 +530,7 @@ // Tests that secondary menu icon is not set for the update password message // in case when user has multiple credentials stored for the web site -TEST_P(SaveUpdatePasswordMessageDelegateTest, +TEST_F(SaveUpdatePasswordMessageDelegateTest, NoCogButton_MultipleCredUpdatePassword_PasswordEditDialogWithDetails) { base::test::ScopedFeatureList scoped_feature_state; scoped_feature_state.InitWithFeatures( @@ -660,166 +548,8 @@ DismissMessage(messages::DismissReason::UNKNOWN); } -// Tests that the description is set correctly when signed-in user saves a -// password. -TEST_P(SaveUpdatePasswordMessageDelegateTest, - SignedInDescription_SavePassword) { - SetPendingCredentials(kUsername, kPassword); - auto form_manager = - CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); - const bool is_signed_in = true; - const bool is_update = false; - EnqueueMessage(std::move(form_manager), /*user_signed_in=*/is_signed_in, - /*update_password=*/is_update); - - if (GetParam().with_exploratory_save_update_password_strings) { - // password_manager::features::kExploratorySaveUpdatePasswordStrings is - // enabled - EXPECT_EQ(GetExploratoryStringsMessageDescription( - is_update, is_signed_in, kAccountEmail16, - GetParam().save_update_prompt_syncing_string_version), - GetMessageWrapper()->GetDescription()); - } else if (GetParam().with_unified_password_manager_android) { - // password_manager::features::kUnifiedPasswordManagerAndroid is enabled - EXPECT_EQ(GetUnifiedPasswordManagerMessageDescription( - is_update, is_signed_in, kAccountEmail16), - GetMessageWrapper()->GetDescription()); - } else { - EXPECT_EQ(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kUsername)); - EXPECT_EQ(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kPassword)); - EXPECT_NE(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kAccountEmail16)); - } - DismissMessage(messages::DismissReason::UNKNOWN); -} - -// Tests that the description is set correctly when the signed-in user with a -// non-displayable email saves a password. -TEST_P(SaveUpdatePasswordMessageDelegateTest, - SignedInDescription_SavePasswordNonDisplayableEmail) { - SetPendingCredentials(kUsername, kPassword); - auto form_manager = - CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); - const bool is_signed_in = true; - const bool is_update = false; - - absl::optional<AccountInfo> account_info; - account_info = AccountInfo(); - account_info.value().email = kAccountEmail; - account_info.value().full_name = kAccountFullName; - AccountCapabilitiesTestMutator mutator(&account_info.value().capabilities); - mutator.set_can_have_email_address_displayed(false); - - EnqueueMessage(std::move(form_manager), /*user_signed_in=*/is_signed_in, - /*update_password=*/is_update, account_info); - if (GetParam().with_exploratory_save_update_password_strings) { - // password_manager::features::kExploratorySaveUpdatePasswordStrings is - // enabled - EXPECT_EQ(GetExploratoryStringsMessageDescription( - is_update, is_signed_in, kAccountFullName16, - GetParam().save_update_prompt_syncing_string_version), - GetMessageWrapper()->GetDescription()); - } else if (GetParam().with_unified_password_manager_android) { - // password_manager::features::kUnifiedPasswordManagerAndroid is enabled - EXPECT_EQ(GetUnifiedPasswordManagerMessageDescription( - is_update, is_signed_in, kAccountFullName16), - GetMessageWrapper()->GetDescription()); - } else { - EXPECT_EQ(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kUsername)); - EXPECT_EQ(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kPassword)); - EXPECT_EQ(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kAccountEmail16)); - EXPECT_NE(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kAccountFullName16)); - } - DismissMessage(messages::DismissReason::UNKNOWN); -} - -// Tests that the description is set correctly when signed-in user updates a -// password. -TEST_P(SaveUpdatePasswordMessageDelegateTest, - SignedInDescription_UpdatePassword) { - SetPendingCredentials(kUsername, kPassword); - auto form_manager = - CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); - const bool is_signed_in = true; - const bool is_update = true; - EnqueueMessage(std::move(form_manager), /*user_signed_in=*/is_signed_in, - /*update_password=*/is_update); - - if (GetParam().with_exploratory_save_update_password_strings) { - // password_manager::features::kExploratorySaveUpdatePasswordStrings is - // enabled - EXPECT_EQ(GetExploratoryStringsMessageDescription( - is_update, is_signed_in, kAccountEmail16, - GetParam().save_update_prompt_syncing_string_version), - GetMessageWrapper()->GetDescription()); - } else if (GetParam().with_unified_password_manager_android) { - // password_manager::features::kUnifiedPasswordManagerAndroid is enabled - EXPECT_EQ(GetUnifiedPasswordManagerMessageDescription( - is_update, is_signed_in, kAccountEmail16), - GetMessageWrapper()->GetDescription()); - } else { - EXPECT_EQ(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kUsername)); - EXPECT_EQ(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kPassword)); - EXPECT_NE(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kAccountEmail16)); - } - DismissMessage(messages::DismissReason::UNKNOWN); -} - -// Tests that the description is set correctly when the signed-in user with a -// non-displayable email updates a password. -TEST_P(SaveUpdatePasswordMessageDelegateTest, - SignedInDescription_UpdatePasswordNonDisplayableEmail) { - SetPendingCredentials(kUsername, kPassword); - auto form_manager = - CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); - const bool is_signed_in = true; - const bool is_update = true; - - absl::optional<AccountInfo> account_info; - account_info = AccountInfo(); - account_info.value().email = kAccountEmail; - account_info.value().full_name = kAccountFullName; - AccountCapabilitiesTestMutator mutator(&account_info.value().capabilities); - mutator.set_can_have_email_address_displayed(false); - - EnqueueMessage(std::move(form_manager), /*user_signed_in=*/is_signed_in, - /*update_password=*/is_update, account_info); - if (GetParam().with_exploratory_save_update_password_strings) { - // password_manager::features::kExploratorySaveUpdatePasswordStrings is - // enabled - EXPECT_EQ(GetExploratoryStringsMessageDescription( - is_update, is_signed_in, kAccountFullName16, - GetParam().save_update_prompt_syncing_string_version), - GetMessageWrapper()->GetDescription()); - } else if (GetParam().with_unified_password_manager_android) { - // password_manager::features::kUnifiedPasswordManagerAndroid is enabled - EXPECT_EQ(GetUnifiedPasswordManagerMessageDescription( - is_update, is_signed_in, kAccountFullName16), - GetMessageWrapper()->GetDescription()); - } else { - EXPECT_EQ(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kUsername)); - EXPECT_EQ(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kPassword)); - EXPECT_EQ(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kAccountEmail16)); - EXPECT_NE(std::u16string::npos, - GetMessageWrapper()->GetDescription().find(kAccountFullName16)); - } - DismissMessage(messages::DismissReason::UNKNOWN); -} - // Tests that the previous prompt gets dismissed when the new one is enqueued. -TEST_P(SaveUpdatePasswordMessageDelegateTest, OnlyOnePromptAtATime) { +TEST_F(SaveUpdatePasswordMessageDelegateTest, OnlyOnePromptAtATime) { SetPendingCredentials(kUsername, kPassword); auto form_manager = CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); @@ -836,7 +566,7 @@ // Tests that password form is saved and metrics recorded correctly when the // user clicks "Save" button. -TEST_P(SaveUpdatePasswordMessageDelegateTest, SaveOnActionClick) { +TEST_F(SaveUpdatePasswordMessageDelegateTest, SaveOnActionClick) { base::HistogramTester histogram_tester; ukm::TestAutoSetUkmRecorder test_ukm_recorder; @@ -860,7 +590,7 @@ // Tests that password form is not saved and metrics recorded correctly when the // user dismisses the message. -TEST_P(SaveUpdatePasswordMessageDelegateTest, DontSaveOnDismiss) { +TEST_F(SaveUpdatePasswordMessageDelegateTest, DontSaveOnDismiss) { base::HistogramTester histogram_tester; ukm::TestAutoSetUkmRecorder test_ukm_recorder; @@ -884,7 +614,7 @@ // Tests that password form is not saved and metrics recorded correctly when the // message is autodismissed. -TEST_P(SaveUpdatePasswordMessageDelegateTest, MetricOnAutodismissTimer) { +TEST_F(SaveUpdatePasswordMessageDelegateTest, MetricOnAutodismissTimer) { base::HistogramTester histogram_tester; ukm::TestAutoSetUkmRecorder test_ukm_recorder; @@ -908,7 +638,7 @@ // Tests that update password message with a single PasswordForm immediately // saves the form on Update button tap and doesn't display confirmation dialog. -TEST_P(SaveUpdatePasswordMessageDelegateTest, UpdatePasswordWithSingleForm) { +TEST_F(SaveUpdatePasswordMessageDelegateTest, UpdatePasswordWithSingleForm) { base::HistogramTester histogram_tester; ukm::TestAutoSetUkmRecorder test_ukm_recorder; @@ -935,7 +665,7 @@ // Tests that the update dialog is shown after the message in case if multiple // password match the form. -TEST_P(SaveUpdatePasswordMessageDelegateTest, +TEST_F(SaveUpdatePasswordMessageDelegateTest, TriggeredEditDialogLegacy_TwoFormsMatching_UpdatePassword) { base::test::ScopedFeatureList scoped_feature_state; scoped_feature_state.InitAndDisableFeature( @@ -958,7 +688,7 @@ // Tests triggering password edit dialog and saving credentials after the // user accepts the dialog. -TEST_P(SaveUpdatePasswordMessageDelegateTest, TriggerEditDialogLegacy_Accept) { +TEST_F(SaveUpdatePasswordMessageDelegateTest, TriggerEditDialogLegacy_Accept) { base::test::ScopedFeatureList scoped_feature_state; scoped_feature_state.InitAndDisableFeature( password_manager::features::kPasswordEditDialogWithDetails); @@ -990,7 +720,7 @@ // Tests triggering password edit dialog and saving credentials with // empty username after the user accepts the dialog. -TEST_P(SaveUpdatePasswordMessageDelegateTest, +TEST_F(SaveUpdatePasswordMessageDelegateTest, TriggerEditDialogLegacy_WithEmptyUsername_Accept) { base::test::ScopedFeatureList scoped_feature_state; scoped_feature_state.InitAndDisableFeature( @@ -1022,7 +752,7 @@ // Tests that credentials are not saved if the user cancels password edit // dialog. -TEST_P(SaveUpdatePasswordMessageDelegateTest, TriggerEditDialogLegacy_Cancel) { +TEST_F(SaveUpdatePasswordMessageDelegateTest, TriggerEditDialogLegacy_Cancel) { base::test::ScopedFeatureList scoped_feature_state; scoped_feature_state.InitAndDisableFeature( password_manager::features::kPasswordEditDialogWithDetails); @@ -1056,7 +786,7 @@ // in the message. // 2. Saving the password form is executed after clicking on Update button of // the dialog. -TEST_P(SaveUpdatePasswordMessageDelegateTest, +TEST_F(SaveUpdatePasswordMessageDelegateTest, TriggerConfirmUsernameDialog_Accept) { base::test::ScopedFeatureList scoped_feature_state; scoped_feature_state.InitAndEnableFeature( @@ -1099,13 +829,12 @@ kAcceptInUsernameConfirmDialog, 1); } - // Verifies that: // 1. Save password dialog is shown after clicking on cog menu item // "Edit password"in the message. // 2. Saving the password form is executed after clicking on Save button of the // dialog. -TEST_P(SaveUpdatePasswordMessageDelegateTest, +TEST_F(SaveUpdatePasswordMessageDelegateTest, TriggerSaveMessage_CogButton_Accept) { base::test::ScopedFeatureList scoped_feature_state; scoped_feature_state.InitAndEnableFeature( @@ -1155,7 +884,7 @@ // Verifies that the site is blocklisted after clicking on // "Never for this site" menu option in Save message -TEST_P(SaveUpdatePasswordMessageDelegateTest, +TEST_F(SaveUpdatePasswordMessageDelegateTest, TriggerSaveMessage_CogButton_NeverSave) { base::test::ScopedFeatureList scoped_feature_state; scoped_feature_state.InitAndEnableFeature( @@ -1198,7 +927,7 @@ // action) in the message. // 2. Updating the password form is executed after clicking on Update button of // the dialog. -TEST_P(SaveUpdatePasswordMessageDelegateTest, +TEST_F(SaveUpdatePasswordMessageDelegateTest, TriggerUpdateMessage_CogButton_Accept) { base::test::ScopedFeatureList scoped_feature_state; scoped_feature_state.InitAndEnableFeature( @@ -1252,7 +981,7 @@ // "Edit password"in the message. // 2. The dialog is dismissed with negative result after clicking on Cancel // button. -TEST_P(SaveUpdatePasswordMessageDelegateTest, +TEST_F(SaveUpdatePasswordMessageDelegateTest, TriggerSaveMessage_CogButton_Cancel) { base::test::ScopedFeatureList scoped_feature_state; scoped_feature_state.InitAndEnableFeature( @@ -1293,9 +1022,312 @@ 1); } +// Tests that if the exploratory strings feature is given an unsupported +// string version as a param, the regular strings are used instead. +TEST_F(SaveUpdatePasswordMessageDelegateTest, + ExploratoryStringsWithWrongParamFallsBackToRegular) { + base::test::ScopedFeatureList scoped_feature_state; + scoped_feature_state.InitAndEnableFeatureWithParameters( + password_manager::features::kExploratorySaveUpdatePasswordStrings, + {{password_manager::features::kSaveUpdatePromptSyncingStringVersion.name, + "1"}}); + SetPendingCredentials(kUsername, kPassword); + auto form_manager = + CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); + const bool kUserNotSignedIn = false; + const bool kNotUpdate = false; + EnqueueMessage(std::move(form_manager), kUserNotSignedIn, kNotUpdate); + EXPECT_EQ(GetExpectedUPMMessageDescription(kNotUpdate, kUserNotSignedIn, + kAccountEmail16), + GetMessageWrapper()->GetDescription()); + + DismissMessage(messages::DismissReason::UNKNOWN); +} + +// Tests parameterized with different feature states + +// Tests that message properties (title, description, icon, button text) are +// set correctly for save password message. +TEST_P(SaveUpdatePasswordMessageDelegateWithFeaturesTest, + MessagePropertyValues_SavePassword) { + SetPendingCredentials(kUsername, kPassword); + auto form_manager = + CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); + const bool is_signed_in = false; + const bool is_update = false; + EnqueueMessage(std::move(form_manager), /*user_signed_in=*/is_signed_in, + /*update_password=*/is_update); + + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON), + GetMessageWrapper()->GetPrimaryButtonText()); + + // Validate message description that depends on + // kExploratorySaveUpdatePasswordStrings feature + if (GetParam().with_exploratory_save_update_password_strings) { + // password_manager::features::kExploratorySaveUpdatePasswordStrings is + // enabled + EXPECT_EQ(GetExploratoryStringsMessageDescription( + is_update, is_signed_in, kAccountEmail16, + GetParam().save_update_prompt_syncing_string_version), + GetMessageWrapper()->GetDescription()); + } else if (GetParam().with_unified_password_manager_android) { + // password_manager::features::kUnifiedPasswordManagerAndroid is enabled + EXPECT_EQ(GetExpectedUPMMessageDescription(is_update, is_signed_in, + kAccountEmail16), + GetMessageWrapper()->GetDescription()); + } else { + EXPECT_NE(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kUsername)); + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kPassword)); + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kAccountEmail16)); + } + + // Validate remaining message fields + if (GetParam().with_unified_password_manager_android) { + // password_manager::features::kUnifiedPasswordManagerAndroid is enabled + EXPECT_EQ(ResourceMapper::MapToJavaDrawableId( + IDR_ANDROID_PASSWORD_MANAGER_LOGO_24DP), + GetMessageWrapper()->GetIconResourceId()); + } else { + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD), + GetMessageWrapper()->GetTitle()); + EXPECT_EQ( + ResourceMapper::MapToJavaDrawableId(IDR_ANDROID_INFOBAR_SAVE_PASSWORD), + GetMessageWrapper()->GetIconResourceId()); + } + + EXPECT_EQ(ResourceMapper::MapToJavaDrawableId(IDR_ANDROID_MESSAGE_SETTINGS), + GetMessageWrapper()->GetSecondaryIconResourceId()); + + DismissMessage(messages::DismissReason::UNKNOWN); +} + +// Tests that secondary button title is right. +// kPasswordEditDialogWithDetails feature off. +TEST_P(SaveUpdatePasswordMessageDelegateWithFeaturesTest, + MessageSecondaryButtonProperty_SavePassword) { + base::test::ScopedFeatureList scoped_feature_state; + scoped_feature_state.InitAndDisableFeature( + password_manager::features::kPasswordEditDialogWithDetails); + + SetPendingCredentials(kUsername, kPassword); + auto form_manager = + CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); + EnqueueMessage(std::move(form_manager), /*user_signed_in=*/false, + /*update_password=*/false); + + if (GetParam().with_unified_password_manager_android) { + // password_manager::features::kUnifiedPasswordManagerAndroid is enabled + EXPECT_EQ( + l10n_util::GetStringUTF16(IDS_PASSWORD_MESSAGE_NEVER_SAVE_MENU_ITEM), + GetMessageWrapper()->GetSecondaryButtonMenuText()); + } else { + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BLOCKLIST_BUTTON), + GetMessageWrapper()->GetSecondaryButtonMenuText()); + } + DismissMessage(messages::DismissReason::UNKNOWN); +} + +// Tests that message properties (title, description, icon, button text) are +// set correctly for update password message. +TEST_P(SaveUpdatePasswordMessageDelegateWithFeaturesTest, + MessagePropertyValues_UpdatePassword) { + SetPendingCredentials(kUsername, kPassword); + auto form_manager = + CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); + const bool is_signed_in = false; + const bool is_update = true; + EnqueueMessage(std::move(form_manager), /*user_signed_in=*/is_signed_in, + /*update_password=*/is_update); + + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_UPDATE_PASSWORD), + GetMessageWrapper()->GetTitle()); + + if (GetParam().with_exploratory_save_update_password_strings) { + // password_manager::features::kExploratorySaveUpdatePasswordStrings is + // enabled + EXPECT_EQ(GetExploratoryStringsMessageDescription( + is_update, is_signed_in, kAccountEmail16, + GetParam().save_update_prompt_syncing_string_version), + GetMessageWrapper()->GetDescription()); + } else if (GetParam().with_unified_password_manager_android) { + // password_manager::features::kUnifiedPasswordManagerAndroid is enabled + EXPECT_EQ(GetExpectedUPMMessageDescription(is_update, is_signed_in, + kAccountEmail16), + GetMessageWrapper()->GetDescription()); + } + + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UPDATE_BUTTON), + GetMessageWrapper()->GetPrimaryButtonText()); + EXPECT_EQ(std::u16string(), + GetMessageWrapper()->GetSecondaryButtonMenuText()); + + DismissMessage(messages::DismissReason::UNKNOWN); +} + +// Tests that the description is set correctly when signed-in user saves a +// password. +TEST_P(SaveUpdatePasswordMessageDelegateWithFeaturesTest, + SignedInDescription_SavePassword) { + SetPendingCredentials(kUsername, kPassword); + auto form_manager = + CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); + const bool is_signed_in = true; + const bool is_update = false; + EnqueueMessage(std::move(form_manager), /*user_signed_in=*/is_signed_in, + /*update_password=*/is_update); + + if (GetParam().with_exploratory_save_update_password_strings) { + // password_manager::features::kExploratorySaveUpdatePasswordStrings is + // enabled + EXPECT_EQ(GetExploratoryStringsMessageDescription( + is_update, is_signed_in, kAccountEmail16, + GetParam().save_update_prompt_syncing_string_version), + GetMessageWrapper()->GetDescription()); + } else if (GetParam().with_unified_password_manager_android) { + // password_manager::features::kUnifiedPasswordManagerAndroid is enabled + EXPECT_EQ(GetExpectedUPMMessageDescription(is_update, is_signed_in, + kAccountEmail16), + GetMessageWrapper()->GetDescription()); + } else { + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kUsername)); + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kPassword)); + EXPECT_NE(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kAccountEmail16)); + } + DismissMessage(messages::DismissReason::UNKNOWN); +} + +// Tests that the description is set correctly when the signed-in user with a +// non-displayable email saves a password. +TEST_P(SaveUpdatePasswordMessageDelegateWithFeaturesTest, + SignedInDescription_SavePasswordNonDisplayableEmail) { + SetPendingCredentials(kUsername, kPassword); + auto form_manager = + CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); + const bool is_signed_in = true; + const bool is_update = false; + + absl::optional<AccountInfo> account_info; + account_info = AccountInfo(); + account_info.value().email = kAccountEmail; + account_info.value().full_name = kAccountFullName; + AccountCapabilitiesTestMutator mutator(&account_info.value().capabilities); + mutator.set_can_have_email_address_displayed(false); + + EnqueueMessage(std::move(form_manager), /*user_signed_in=*/is_signed_in, + /*update_password=*/is_update, account_info); + if (GetParam().with_exploratory_save_update_password_strings) { + // password_manager::features::kExploratorySaveUpdatePasswordStrings is + // enabled + EXPECT_EQ(GetExploratoryStringsMessageDescription( + is_update, is_signed_in, kAccountFullName16, + GetParam().save_update_prompt_syncing_string_version), + GetMessageWrapper()->GetDescription()); + } else if (GetParam().with_unified_password_manager_android) { + // password_manager::features::kUnifiedPasswordManagerAndroid is enabled + EXPECT_EQ(GetExpectedUPMMessageDescription(is_update, is_signed_in, + kAccountFullName16), + GetMessageWrapper()->GetDescription()); + } else { + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kUsername)); + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kPassword)); + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kAccountEmail16)); + EXPECT_NE(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kAccountFullName16)); + } + DismissMessage(messages::DismissReason::UNKNOWN); +} + +// Tests that the description is set correctly when signed-in user updates a +// password. +TEST_P(SaveUpdatePasswordMessageDelegateWithFeaturesTest, + SignedInDescription_UpdatePassword) { + SetPendingCredentials(kUsername, kPassword); + auto form_manager = + CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); + const bool is_signed_in = true; + const bool is_update = true; + EnqueueMessage(std::move(form_manager), /*user_signed_in=*/is_signed_in, + /*update_password=*/is_update); + + if (GetParam().with_exploratory_save_update_password_strings) { + // password_manager::features::kExploratorySaveUpdatePasswordStrings is + // enabled + EXPECT_EQ(GetExploratoryStringsMessageDescription( + is_update, is_signed_in, kAccountEmail16, + GetParam().save_update_prompt_syncing_string_version), + GetMessageWrapper()->GetDescription()); + } else if (GetParam().with_unified_password_manager_android) { + // password_manager::features::kUnifiedPasswordManagerAndroid is enabled + EXPECT_EQ(GetExpectedUPMMessageDescription(is_update, is_signed_in, + kAccountEmail16), + GetMessageWrapper()->GetDescription()); + } else { + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kUsername)); + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kPassword)); + EXPECT_NE(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kAccountEmail16)); + } + DismissMessage(messages::DismissReason::UNKNOWN); +} + +// Tests that the description is set correctly when the signed-in user with a +// non-displayable email updates a password. +TEST_P(SaveUpdatePasswordMessageDelegateWithFeaturesTest, + SignedInDescription_UpdatePasswordNonDisplayableEmail) { + SetPendingCredentials(kUsername, kPassword); + auto form_manager = + CreateFormManager(GURL(kDefaultUrl), empty_best_matches()); + const bool is_signed_in = true; + const bool is_update = true; + + absl::optional<AccountInfo> account_info; + account_info = AccountInfo(); + account_info.value().email = kAccountEmail; + account_info.value().full_name = kAccountFullName; + AccountCapabilitiesTestMutator mutator(&account_info.value().capabilities); + mutator.set_can_have_email_address_displayed(false); + + EnqueueMessage(std::move(form_manager), /*user_signed_in=*/is_signed_in, + /*update_password=*/is_update, account_info); + if (GetParam().with_exploratory_save_update_password_strings) { + // password_manager::features::kExploratorySaveUpdatePasswordStrings is + // enabled + EXPECT_EQ(GetExploratoryStringsMessageDescription( + is_update, is_signed_in, kAccountFullName16, + GetParam().save_update_prompt_syncing_string_version), + GetMessageWrapper()->GetDescription()); + } else if (GetParam().with_unified_password_manager_android) { + // password_manager::features::kUnifiedPasswordManagerAndroid is enabled + EXPECT_EQ(GetExpectedUPMMessageDescription(is_update, is_signed_in, + kAccountFullName16), + GetMessageWrapper()->GetDescription()); + } else { + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kUsername)); + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kPassword)); + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kAccountEmail16)); + EXPECT_NE(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kAccountFullName16)); + } + DismissMessage(messages::DismissReason::UNKNOWN); +} + INSTANTIATE_TEST_SUITE_P( All, - SaveUpdatePasswordMessageDelegateTest, + SaveUpdatePasswordMessageDelegateWithFeaturesTest, testing::Values( // Exploratory strings are disabled, no version specified FeatureConfigTestParam{
diff --git a/chrome/browser/password_manager/password_manager_settings_service_impl.cc b/chrome/browser/password_manager/password_manager_settings_service_impl.cc index 8be81030..5a5aaa50 100644 --- a/chrome/browser/password_manager/password_manager_settings_service_impl.cc +++ b/chrome/browser/password_manager/password_manager_settings_service_impl.cc
@@ -14,7 +14,7 @@ : pref_service_(pref_service) {} bool PasswordManagerSettingsServiceImpl::IsSettingEnabled( - PasswordManagerSetting setting) { + PasswordManagerSetting setting) const { switch (setting) { case PasswordManagerSetting::kOfferToSavePasswords: return pref_service_->GetBoolean(
diff --git a/chrome/browser/password_manager/password_manager_settings_service_impl.h b/chrome/browser/password_manager/password_manager_settings_service_impl.h index a95313b..f62fa11 100644 --- a/chrome/browser/password_manager/password_manager_settings_service_impl.h +++ b/chrome/browser/password_manager/password_manager_settings_service_impl.h
@@ -27,7 +27,7 @@ ~PasswordManagerSettingsServiceImpl() override = default; bool IsSettingEnabled( - password_manager::PasswordManagerSetting setting) override; + password_manager::PasswordManagerSetting setting) const override; void TurnOffAutoSignIn() override; void RequestSettingsFromBackend() override;
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc index bc342655..661e7625 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc
@@ -278,6 +278,7 @@ #include "chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h" #include "chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.h" #include "chrome/browser/ui/webui/settings/settings_ui.h" +#include "chrome/browser/ui/webui/side_panel/companion/promo_handler.h" #include "chrome/browser/ui/webui/side_panel/read_anything/read_anything_prefs.h" #include "chrome/browser/ui/webui/tab_search/tab_search_prefs.h" #include "chrome/browser/ui/webui/whats_new/whats_new_ui.h" @@ -1531,6 +1532,7 @@ BrowserFeaturePromoSnoozeService::RegisterProfilePrefs(registry); captions::LiveTranslateController::RegisterProfilePrefs(registry); ChromeAuthenticatorRequestDelegate::RegisterProfilePrefs(registry); + companion::PromoHandler::RegisterProfilePrefs(registry); DeviceServiceImpl::RegisterProfilePrefs(registry); DevToolsWindow::RegisterProfilePrefs(registry); DriveService::RegisterProfilePrefs(registry);
diff --git a/chrome/browser/prefs/incognito_mode_prefs.cc b/chrome/browser/prefs/incognito_mode_prefs.cc index dc0fc7f..32906fa1 100644 --- a/chrome/browser/prefs/incognito_mode_prefs.cc +++ b/chrome/browser/prefs/incognito_mode_prefs.cc
@@ -30,31 +30,35 @@ #include "chromeos/startup/browser_params_proxy.h" #endif // BUILDFLAG(IS_CHROMEOS_LACROS) -// static -// Sadly, this is required until c++17. -constexpr IncognitoModePrefs::Availability - IncognitoModePrefs::kDefaultAvailability; +using policy::IncognitoModeAvailability; // static -bool IncognitoModePrefs::IntToAvailability(int in_value, - Availability* out_value) { - if (in_value < 0 || in_value >= static_cast<int>(Availability::kNumTypes)) { +const IncognitoModeAvailability IncognitoModePrefs::kDefaultAvailability = + policy::IncognitoModeAvailability::kEnabled; + +// static +bool IncognitoModePrefs::IntToAvailability( + int in_value, + IncognitoModeAvailability* out_value) { + if (in_value < 0 || + in_value >= static_cast<int>(IncognitoModeAvailability::kNumTypes)) { *out_value = kDefaultAvailability; return false; } - *out_value = static_cast<Availability>(in_value); + *out_value = static_cast<IncognitoModeAvailability>(in_value); return true; } // static -IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailability( +IncognitoModeAvailability IncognitoModePrefs::GetAvailability( const PrefService* pref_service) { return GetAvailabilityInternal(pref_service, CHECK_PARENTAL_CONTROLS); } // static -void IncognitoModePrefs::SetAvailability(PrefService* prefs, - const Availability availability) { +void IncognitoModePrefs::SetAvailability( + PrefService* prefs, + const IncognitoModeAvailability availability) { prefs->SetInteger(policy::policy_prefs::kIncognitoModeAvailability, static_cast<int>(availability)); } @@ -88,13 +92,13 @@ // static bool IncognitoModePrefs::CanOpenBrowser(Profile* profile) { switch (GetAvailability(profile->GetPrefs())) { - case IncognitoModePrefs::Availability::kEnabled: + case IncognitoModeAvailability::kEnabled: return true; - case IncognitoModePrefs::Availability::kDisabled: + case IncognitoModeAvailability::kDisabled: return !profile->IsIncognitoProfile(); - case IncognitoModePrefs::Availability::kForced: + case IncognitoModeAvailability::kForced: return profile->IsIncognitoProfile(); default: @@ -107,7 +111,7 @@ bool IncognitoModePrefs::IsIncognitoAllowed(Profile* profile) { return !profile->IsGuestSession() && IncognitoModePrefs::GetAvailability(profile->GetPrefs()) != - IncognitoModePrefs::Availability::kDisabled; + IncognitoModeAvailability::kDisabled; } // static @@ -122,20 +126,21 @@ } // static -IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailabilityInternal( +IncognitoModeAvailability IncognitoModePrefs::GetAvailabilityInternal( const PrefService* pref_service, GetAvailabilityMode mode) { DCHECK(pref_service); int pref_value = pref_service->GetInteger( policy::policy_prefs::kIncognitoModeAvailability); - Availability result = kDefaultAvailability; + IncognitoModeAvailability result = kDefaultAvailability; bool valid = IntToAvailability(pref_value, &result); DCHECK(valid); - if (result != IncognitoModePrefs::Availability::kDisabled && + if (result != IncognitoModeAvailability::kDisabled && mode == CHECK_PARENTAL_CONTROLS && ArePlatformParentalControlsEnabled()) { - if (result == IncognitoModePrefs::Availability::kForced) + if (result == IncognitoModeAvailability::kForced) { LOG(ERROR) << "Ignoring FORCED incognito. Parental control logging on"; - return IncognitoModePrefs::Availability::kDisabled; + } + return IncognitoModeAvailability::kDisabled; } return result; } @@ -159,7 +164,7 @@ bool should_use_incognito = forced_by_switch || GetAvailabilityInternal(prefs, DONT_CHECK_PARENTAL_CONTROLS) == - IncognitoModePrefs::Availability::kForced; + IncognitoModeAvailability::kForced; #if BUILDFLAG(IS_CHROMEOS_LACROS) auto* init_params = chromeos::BrowserParamsProxy::Get(); should_use_incognito |= @@ -168,5 +173,5 @@ #endif return should_use_incognito && GetAvailabilityInternal(prefs, CHECK_PARENTAL_CONTROLS) != - IncognitoModePrefs::Availability::kDisabled; + IncognitoModeAvailability::kDisabled; }
diff --git a/chrome/browser/prefs/incognito_mode_prefs.h b/chrome/browser/prefs/incognito_mode_prefs.h index eb8a611..b0fc8ae 100644 --- a/chrome/browser/prefs/incognito_mode_prefs.h +++ b/chrome/browser/prefs/incognito_mode_prefs.h
@@ -12,6 +12,10 @@ class CommandLine; } +namespace policy { +enum class IncognitoModeAvailability; +} + namespace user_prefs { class PrefRegistrySyncable; } @@ -19,23 +23,7 @@ // Specifies Incognito mode availability preferences. class IncognitoModePrefs { public: - // Possible values for Incognito mode availability. Please, do not change - // the order of entries since numeric values are exposed to users. - enum class Availability { - // Incognito mode enabled. Users may open pages in both Incognito mode and - // normal mode (usually the default behaviour). - kEnabled = 0, - // Incognito mode disabled. Users may not open pages in Incognito mode. - // Only normal mode is available for browsing. - kDisabled, - // Incognito mode forced. Users may open pages *ONLY* in Incognito mode. - // Normal mode is not available for browsing. - kForced, - - kNumTypes - }; - - static constexpr Availability kDefaultAvailability = Availability::kEnabled; + static const policy::IncognitoModeAvailability kDefaultAvailability; IncognitoModePrefs() = delete; IncognitoModePrefs(const IncognitoModePrefs&) = delete; @@ -46,17 +34,20 @@ // Returns kIncognitoModeAvailability preference value stored // in the given pref service. - static Availability GetAvailability(const PrefService* prefs); + static policy::IncognitoModeAvailability GetAvailability( + const PrefService* prefs); // Sets kIncognitoModeAvailability preference to the specified availability // value. - static void SetAvailability(PrefService* prefs, - const Availability availability); + static void SetAvailability( + PrefService* prefs, + const policy::IncognitoModeAvailability availability); // Converts in_value into the corresponding Availability value. Returns true // if conversion is successful (in_value is valid). Otherwise, returns false // and *out_value is set to ENABLED. - static bool IntToAvailability(int in_value, Availability* out_value); + static bool IntToAvailability(int in_value, + policy::IncognitoModeAvailability* out_value); // Returns true if the initial browser should start in incognito mode. static bool ShouldLaunchIncognito(const base::CommandLine& command_line, @@ -91,8 +82,9 @@ // Internal version of GetAvailability() that specifies whether parental // controls should be checked (which is expensive and not always necessary // to do - such as when checking for FORCED state). - static Availability GetAvailabilityInternal(const PrefService* pref_service, - GetAvailabilityMode mode); + static policy::IncognitoModeAvailability GetAvailabilityInternal( + const PrefService* pref_service, + GetAvailabilityMode mode); // Internal version of ShouldLaunchIncognito() and // ShouldOpenSubsequentBrowsersInIncognito() that specifies whether it is for
diff --git a/chrome/browser/prefs/incognito_mode_prefs_unittest.cc b/chrome/browser/prefs/incognito_mode_prefs_unittest.cc index de550b47..52a05d3 100644 --- a/chrome/browser/prefs/incognito_mode_prefs_unittest.cc +++ b/chrome/browser/prefs/incognito_mode_prefs_unittest.cc
@@ -19,17 +19,17 @@ }; TEST_F(IncognitoModePrefsTest, IntToAvailability) { - ASSERT_EQ(0, static_cast<int>(IncognitoModePrefs::Availability::kEnabled)); - ASSERT_EQ(1, static_cast<int>(IncognitoModePrefs::Availability::kDisabled)); - ASSERT_EQ(2, static_cast<int>(IncognitoModePrefs::Availability::kForced)); + ASSERT_EQ(0, static_cast<int>(policy::IncognitoModeAvailability::kEnabled)); + ASSERT_EQ(1, static_cast<int>(policy::IncognitoModeAvailability::kDisabled)); + ASSERT_EQ(2, static_cast<int>(policy::IncognitoModeAvailability::kForced)); - IncognitoModePrefs::Availability incognito; + policy::IncognitoModeAvailability incognito; EXPECT_TRUE(IncognitoModePrefs::IntToAvailability(0, &incognito)); - EXPECT_EQ(IncognitoModePrefs::Availability::kEnabled, incognito); + EXPECT_EQ(policy::IncognitoModeAvailability::kEnabled, incognito); EXPECT_TRUE(IncognitoModePrefs::IntToAvailability(1, &incognito)); - EXPECT_EQ(IncognitoModePrefs::Availability::kDisabled, incognito); + EXPECT_EQ(policy::IncognitoModeAvailability::kDisabled, incognito); EXPECT_TRUE(IncognitoModePrefs::IntToAvailability(2, &incognito)); - EXPECT_EQ(IncognitoModePrefs::Availability::kForced, incognito); + EXPECT_EQ(policy::IncognitoModeAvailability::kForced, incognito); EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(10, &incognito)); EXPECT_EQ(IncognitoModePrefs::kDefaultAvailability, incognito); @@ -40,20 +40,20 @@ TEST_F(IncognitoModePrefsTest, GetAvailability) { prefs_.SetUserPref(policy::policy_prefs::kIncognitoModeAvailability, std::make_unique<base::Value>(static_cast<int>( - IncognitoModePrefs::Availability::kEnabled))); - EXPECT_EQ(IncognitoModePrefs::Availability::kEnabled, + policy::IncognitoModeAvailability::kEnabled))); + EXPECT_EQ(policy::IncognitoModeAvailability::kEnabled, IncognitoModePrefs::GetAvailability(&prefs_)); prefs_.SetUserPref(policy::policy_prefs::kIncognitoModeAvailability, std::make_unique<base::Value>(static_cast<int>( - IncognitoModePrefs::Availability::kDisabled))); - EXPECT_EQ(IncognitoModePrefs::Availability::kDisabled, + policy::IncognitoModeAvailability::kDisabled))); + EXPECT_EQ(policy::IncognitoModeAvailability::kDisabled, IncognitoModePrefs::GetAvailability(&prefs_)); prefs_.SetUserPref(policy::policy_prefs::kIncognitoModeAvailability, std::make_unique<base::Value>(static_cast<int>( - IncognitoModePrefs::Availability::kForced))); - EXPECT_EQ(IncognitoModePrefs::Availability::kForced, + policy::IncognitoModeAvailability::kForced))); + EXPECT_EQ(policy::IncognitoModeAvailability::kForced, IncognitoModePrefs::GetAvailability(&prefs_)); } @@ -63,8 +63,8 @@ prefs_.SetUserPref(policy::policy_prefs::kIncognitoModeAvailability, std::make_unique<base::Value>(-1)); EXPECT_DCHECK_DEATH({ - IncognitoModePrefs::Availability availability = + policy::IncognitoModeAvailability availability = IncognitoModePrefs::GetAvailability(&prefs_); - EXPECT_EQ(IncognitoModePrefs::Availability::kEnabled, availability); + EXPECT_EQ(policy::IncognitoModeAvailability::kEnabled, availability); }); }
diff --git a/chrome/browser/preloading/prefetch/search_prefetch/search_preload_unified_browsertest.cc b/chrome/browser/preloading/prefetch/search_prefetch/search_preload_unified_browsertest.cc index 03b92c5a..ad9ad66 100644 --- a/chrome/browser/preloading/prefetch/search_prefetch/search_preload_unified_browsertest.cc +++ b/chrome/browser/preloading/prefetch/search_prefetch/search_preload_unified_browsertest.cc
@@ -20,6 +20,7 @@ #include "chrome/browser/preloading/prefetch/search_prefetch/search_prefetch_service.h" #include "chrome/browser/preloading/prefetch/search_prefetch/search_prefetch_service_factory.h" #include "chrome/browser/preloading/prefetch/search_prefetch/search_preload_test_response_utils.h" +#include "chrome/browser/preloading/prefetch/search_prefetch/streaming_search_prefetch_url_loader.h" #include "chrome/browser/preloading/prerender/prerender_manager.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url_service_factory.h" @@ -1859,6 +1860,65 @@ /*SearchPrefetchStatus::kPrefetchServedForRealNavigation*/ 16, 1); } +// Tests that if prerender is canceled by itself before the loader receives +// response body from the internet, the correct result can be recorded. +IN_PROC_BROWSER_TEST_F(SearchPreloadUnifiedFallbackBrowserTest, + PrerenderDiscardedBeforeServingData) { + base::HistogramTester histogram_tester; + set_service_deferral_type(SearchPreloadTestResponseDeferralType::kDeferBody); + + const GURL kInitialUrl = embedded_test_server()->GetURL("/empty.html"); + ASSERT_TRUE(GetActiveWebContents()); + ASSERT_TRUE(content::NavigateToURL(GetActiveWebContents(), kInitialUrl)); + SetUpContext(); + + std::string search_query_1 = "pre"; + std::string prerender_query = "prerender"; + GURL expected_prefetch_url = + GetSearchUrl(prerender_query, UrlType::kPrefetch); + GURL expected_prerender_url = + GetSearchUrl(prerender_query, UrlType::kPrerender); + content::test::PrerenderHostRegistryObserver registry_observer( + *GetActiveWebContents()); + + ChangeAutocompleteResult(search_query_1, prerender_query, + PrerenderHint::kDisabled, PrefetchHint::kEnabled); + + // Wait until prefetch request succeeds. + absl::optional<SearchPrefetchStatus> prefetch_status = + search_prefetch_service()->GetSearchPrefetchStatusForTesting( + GetCanonicalSearchURL(expected_prefetch_url)); + EXPECT_TRUE(prefetch_status.has_value()); + WaitUntilStatusChangesTo(GetCanonicalSearchURL(expected_prefetch_url), + {SearchPrefetchStatus::kCanBeServed}); + std::string search_query_2 = "prer"; + ChangeAutocompleteResult(search_query_2, prerender_query, + PrerenderHint::kEnabled, PrefetchHint::kEnabled); + // The suggestion service should hint `expected_prefetch_url`, and + // prerendering for this url should start. + registry_observer.WaitForTrigger(expected_prerender_url); + int host_id = prerender_helper().GetHostForUrl(expected_prerender_url); + content::test::PrerenderHostObserver prerender_observer( + *GetActiveWebContents(), host_id); + prerender_helper().CancelPrerenderedPage(host_id); + prerender_observer.WaitForDestroyed(); + + prefetch_status = + search_prefetch_service()->GetSearchPrefetchStatusForTesting( + GetCanonicalSearchURL(expected_prerender_url)); + EXPECT_TRUE(prefetch_status.has_value()); + DispatchDelayedResponseTask(); + WaitUntilStatusChangesTo(GetCanonicalSearchURL(expected_prefetch_url), + {SearchPrefetchStatus::kComplete}); + + ASSERT_TRUE( + content::NavigateToURL(GetActiveWebContents(), expected_prerender_url)); + + histogram_tester.ExpectUniqueSample( + "Omnibox.SearchPrefetch.PrefetchFinalStatus.SuggestionPrefetch", + SearchPrefetchStatus::kPrefetchServedForRealNavigation, 1); +} + // Edge case: when the prerendering navigation is still reading from the cache, // the loader would not be deleted until finishing reading. IN_PROC_BROWSER_TEST_F(SearchPreloadUnifiedFallbackBrowserTest,
diff --git a/chrome/browser/preloading/prefetch/search_prefetch/streaming_search_prefetch_url_loader.cc b/chrome/browser/preloading/prefetch/search_prefetch/streaming_search_prefetch_url_loader.cc index 0a4aed6..c5ac5cad 100644 --- a/chrome/browser/preloading/prefetch/search_prefetch/streaming_search_prefetch_url_loader.cc +++ b/chrome/browser/preloading/prefetch/search_prefetch/streaming_search_prefetch_url_loader.cc
@@ -69,17 +69,23 @@ StreamingSearchPrefetchURLLoader::ResponseReader::ResponseReader( mojo::PendingReceiver<network::mojom::URLLoader> forward_receiver, mojo::PendingRemote<network::mojom::URLLoaderClient> forwarding_client, - base::OnceClosure forwarding_disconnection_callback, + base::OnceCallback<void(ResponseReader*)> forwarding_disconnection_callback, absl::optional<network::URLLoaderCompletionStatus> status, - int complete_size_bytes_to_transfer) - : complete_size_bytes_to_transfer_(complete_size_bytes_to_transfer), + StreamingSearchPrefetchURLLoader* loader) + : disconnection_callback_(std::move(forwarding_disconnection_callback)), + loader_(loader), url_loader_completion_status_(status) { forwarding_receiver_.Bind(std::move(forward_receiver)); forwarding_client_.Bind(std::move(forwarding_client)); + // Safe to use Unretained, because `this` owns the receiver. forwarding_receiver_.set_disconnect_handler( - std::move(forwarding_disconnection_callback)); + base::BindOnce(&StreamingSearchPrefetchURLLoader::ResponseReader:: + OnForwardingDisconnection, + base::Unretained(this))); } +StreamingSearchPrefetchURLLoader::ResponseReader::~ResponseReader() = default; + void StreamingSearchPrefetchURLLoader::ResponseReader::OnStatusCodeReady( const network::URLLoaderCompletionStatus& status) { DCHECK(!url_loader_completion_status_); @@ -94,33 +100,47 @@ MojoResult rv = CreateDataPipeForServingData(producer_handle_, consumer_handle); if (rv != MOJO_RESULT_OK) { - // TODO(https://crbug.com/1400881): Discard prerender. + OnForwardingDisconnection(); return; } + handle_watcher_ = std::make_unique<mojo::SimpleWatcher>( + FROM_HERE, mojo::SimpleWatcher::ArmingPolicy::MANUAL, + base::SequencedTaskRunner::GetCurrentDefault()); + + // It is safe to use `base::Unretained(this)` as `this` owns the watcher. + handle_watcher_->Watch( + producer_handle_.get(), MOJO_HANDLE_SIGNAL_WRITABLE, + MOJO_WATCH_CONDITION_SATISFIED, + base::BindRepeating( + &StreamingSearchPrefetchURLLoader::ResponseReader::OnDataHandleReady, + base::Unretained(this))); forwarding_client_->OnReceiveResponse(resource_response->Clone(), std::move(consumer_handle), /*cached_metadata=*/absl::nullopt); } -void StreamingSearchPrefetchURLLoader::ResponseReader::PushData( - int bytes_of_raw_data_to_transfer, - const std::string& response_body) { - DCHECK_LE(bytes_of_raw_data_to_transfer, int(response_body.size())); +void StreamingSearchPrefetchURLLoader::ResponseReader::PushData() { + while (true) { + base::StringPiece response_data = + loader_->GetMoreDataFromCache(write_position_); + if (response_data.empty()) { + if (!response_data.data()) { + complete_writing_ = true; + MaybeSendCompletionSignal(); + } + break; + } + uint32_t write_size = response_data.size(); + MojoResult result = producer_handle_->WriteData( + response_data.data(), &write_size, MOJO_WRITE_DATA_FLAG_NONE); - while (bytes_of_raw_data_to_transfer > write_position_) { - uint32_t write_size = - static_cast<uint32_t>(bytes_of_raw_data_to_transfer - write_position_); - - MojoResult result = - producer_handle_->WriteData(response_body.data() + write_position_, - &write_size, MOJO_WRITE_DATA_FLAG_NONE); if (result == MOJO_RESULT_SHOULD_WAIT) { handle_watcher_->ArmOrNotify(); return; } if (result != MOJO_RESULT_OK) { - // Failed it; + OnForwardingDisconnection(); return; } @@ -128,23 +148,26 @@ // successfully been written to. write_position_ += write_size; } - MaybeSendCompletionSignal(); } -void StreamingSearchPrefetchURLLoader::ResponseReader::OnResponseDataComplete( - int bytes_of_raw_data_to_transfer, - const std::string& response_body) { - DCHECK_EQ(complete_size_bytes_to_transfer_, -1); - complete_size_bytes_to_transfer_ = bytes_of_raw_data_to_transfer; - PushData(complete_size_bytes_to_transfer_, response_body); - MaybeSendCompletionSignal(); +void StreamingSearchPrefetchURLLoader::ResponseReader::OnDataHandleReady( + MojoResult result, + const mojo::HandleSignalsState& state) { + if (complete_writing_) { + // This method might be called after this finishes serving with an error + // result, in which case we do not want to do anything. + return; + } + if (result != MOJO_RESULT_OK) { + OnForwardingDisconnection(); + return; + } + PushData(); } void StreamingSearchPrefetchURLLoader::ResponseReader:: MaybeSendCompletionSignal() { - if (complete_size_bytes_to_transfer_ < 0 || !url_loader_completion_status_ || - write_position_ < complete_size_bytes_to_transfer_) { - // Not completed yet. + if (!complete_writing_ || !url_loader_completion_status_) { return; } if (producer_handle_) { @@ -153,7 +176,13 @@ producer_handle_.reset(); } -StreamingSearchPrefetchURLLoader::ResponseReader::~ResponseReader() = default; +void StreamingSearchPrefetchURLLoader::ResponseReader:: + OnForwardingDisconnection() { + if (disconnection_callback_) { + std::move(disconnection_callback_).Run(this); + } +} + void StreamingSearchPrefetchURLLoader::ResponseReader::FollowRedirect( const std::vector<std::string>& removed_headers, const net::HttpRequestHeaders& modified_headers, @@ -339,17 +368,20 @@ base::BindOnce( &StreamingSearchPrefetchURLLoader::OnPrerenderForwardingDisconnect, weak_factory_.GetWeakPtr()), - status_, drain_complete_ ? bytes_of_raw_data_to_transfer_ : -1); - + status_, this); response_reader_for_prerender_->StartReadingResponseFromData( resource_response_); - response_reader_for_prerender_->PushData(bytes_of_raw_data_to_transfer_, - body_content_); + response_reader_for_prerender_->PushData(); } -void StreamingSearchPrefetchURLLoader::OnPrerenderForwardingDisconnect() { +void StreamingSearchPrefetchURLLoader::OnPrerenderForwardingDisconnect( + ResponseReader* reader) { DCHECK(prerender_utils::SearchPreloadShareableCacheIsEnabled()); - response_reader_for_prerender_.reset(); + if (reader != response_reader_for_prerender_.get()) { + return; + } + base::SequencedTaskRunner::GetCurrentDefault()->DeleteSoon( + FROM_HERE, std::move(response_reader_for_prerender_)); if (self_pointer_) { MaybeDeleteItself(); } @@ -499,8 +531,7 @@ } if (response_reader_for_prerender_) { - response_reader_for_prerender_->PushData(bytes_of_raw_data_to_transfer_, - body_content_); + response_reader_for_prerender_->PushData(); } } @@ -513,8 +544,7 @@ Finish(); } if (response_reader_for_prerender_) { - response_reader_for_prerender_->OnResponseDataComplete( - bytes_of_raw_data_to_transfer_, body_content_); + response_reader_for_prerender_->PushData(); } } @@ -557,6 +587,16 @@ PushData(); } +base::StringPiece StreamingSearchPrefetchURLLoader::GetMoreDataFromCache( + int writing_position) const { + DCHECK_GE(bytes_of_raw_data_to_transfer_, writing_position); + if (drain_complete_ && writing_position == bytes_of_raw_data_to_transfer_) { + return base::StringPiece(); + } + return base::StringPiece(body_content_.data() + writing_position, + bytes_of_raw_data_to_transfer_ - writing_position); +} + void StreamingSearchPrefetchURLLoader::PushData() { // TODO(https://crbug.com/1400881): This method should be migrated into // `ResponseReader::PushData`. Now `ResponseReader` is sort of a copy of this, @@ -565,18 +605,21 @@ DCHECK(!streaming_prefetch_request_); while (true) { DCHECK_GE(bytes_of_raw_data_to_transfer_, write_position_); - uint32_t write_size = - static_cast<uint32_t>(bytes_of_raw_data_to_transfer_ - write_position_); - if (write_size == 0) { - if (drain_complete_) { + base::StringPiece response_data = GetMoreDataFromCache(write_position_); + + if (response_data.empty()) { + // If no data is provided, the cache has served every byte to loader. + // In this case we can stop. + if (!response_data.data()) { Finish(); } + // No data can be fed into the producer. return; } + uint32_t write_size = response_data.size(); + MojoResult result = producer_handle_->WriteData( + response_data.data(), &write_size, MOJO_WRITE_DATA_FLAG_NONE); - MojoResult result = - producer_handle_->WriteData(body_content_.data() + write_position_, - &write_size, MOJO_WRITE_DATA_FLAG_NONE); if (result == MOJO_RESULT_SHOULD_WAIT) { handle_watcher_->ArmOrNotify(); return;
diff --git a/chrome/browser/preloading/prefetch/search_prefetch/streaming_search_prefetch_url_loader.h b/chrome/browser/preloading/prefetch/search_prefetch/streaming_search_prefetch_url_loader.h index 2bbf3f54..ed5fe2d9 100644 --- a/chrome/browser/preloading/prefetch/search_prefetch/streaming_search_prefetch_url_loader.h +++ b/chrome/browser/preloading/prefetch/search_prefetch/streaming_search_prefetch_url_loader.h
@@ -42,9 +42,10 @@ ResponseReader( mojo::PendingReceiver<network::mojom::URLLoader> forward_receiver, mojo::PendingRemote<network::mojom::URLLoaderClient> forwarding_client, - base::OnceClosure forwarding_disconnection_callback, + base::OnceCallback<void(ResponseReader*)> + forwarding_disconnection_callback, absl::optional<network::URLLoaderCompletionStatus>, - int complete_size_bytes_to_transfer); + StreamingSearchPrefetchURLLoader* loader); ~ResponseReader() override; // Not copyable nor movable. @@ -64,13 +65,21 @@ void PauseReadingBodyFromNet() override; void ResumeReadingBodyFromNet() override; + // Sets date pipe up between this instance and its client. void StartReadingResponseFromData( network::mojom::URLResponseHeadPtr& resource_response); - void PushData(int bytes_of_raw_data_to_transfer, - const std::string& response_body); - void OnResponseDataComplete(int bytes_of_raw_data_to_transfer, - const std::string& response_body); + // TODO(https://crbug.com/1400881): These methods will replace the + // `StreamingSearchPrefetchURLLoader`'s. + // Pushes the received data into the producer end of the data pipe. + void PushData(); + // `PushData` may find itself having to wait until the data pipe to + // be ready. At that time, this method would be invoked. + void OnDataHandleReady(MojoResult result, + const mojo::HandleSignalsState& state); + + // Called by `StreamingSearchPrefetchURLLoader` to inform it of the + // received response. void OnStatusCodeReady(const network::URLLoaderCompletionStatus& status); private: @@ -78,6 +87,11 @@ // loader has completed fetching. If so, inform the forwarding client. void MaybeSendCompletionSignal(); + void OnForwardingDisconnection(); + + // Set to true once it writes all bytes into the data pipe. + bool complete_writing_ = false; + // Records the position where to read the next body from. // content----------------------------- // ^ ^ @@ -85,10 +99,6 @@ // write_position_ end of response body. int write_position_ = 0; - // Sets upon the corresponding URLLoader has read all data from network. - // Set to -1 when the URLLoader has not drained all data. - int complete_size_bytes_to_transfer_ = -1; - // Data pipe for pushing the received response to the client. mojo::ScopedDataPipeProducerHandle producer_handle_; std::unique_ptr<mojo::SimpleWatcher> handle_watcher_; @@ -97,6 +107,16 @@ mojo::Receiver<network::mojom::URLLoader> forwarding_receiver_{this}; mojo::Remote<network::mojom::URLLoaderClient> forwarding_client_; + // Invoked when `this` does not need more data from the loader and asks the + // loader to delete itself. + base::OnceCallback<void(ResponseReader*)> disconnection_callback_; + + // 'loader_' owns this, and guarantees that `loader_` won't be deleted + // before deleting `this`, so it is safe to keep a ref. + // TODO(crbug.com/1400881): This breaks the hierarchy. Will be replaced soon + // after refactoring. + raw_ptr<StreamingSearchPrefetchURLLoader> loader_; + // Records the completion status for the corresponding network loader. absl::optional<network::URLLoaderCompletionStatus> url_loader_completion_status_; @@ -185,10 +205,9 @@ // closed. void OnURLLoaderClientMojoDisconnect(); - // When a disconnection occurs in the the Mojo pipe connecting to prerendering - // navigation. If the prerendering navigation is the only one that needs this - // loader, delete the loader. - void OnPrerenderForwardingDisconnect(); + // When the given `reader` asks `this` to delete itself. If the prerendering + // navigation is the only one that needs this loader, delete the loader. + void OnPrerenderForwardingDisconnect(ResponseReader* reader); // Start serving the response from |producer_handle_|, which serves // |body_content_|. @@ -197,6 +216,14 @@ // Called when more data can be sent into |producer_handle_|. void OnHandleReady(MojoResult result, const mojo::HandleSignalsState& state); + // Returns the view of `body_content_`, starting from the `writing_position` + // and ending at the end of the string. + // Returns an invalid StringPiece (note, not an empty StringPiece) if there is + // no more valid data. Returns an empty StringPiece if writing_position + // reaches the end of the current response body but `this` is waiting for the + // network to produce more data. + base::StringPiece GetMoreDataFromCache(int writing_position) const; + // Push data into |producer_handle_|. void PushData();
diff --git a/chrome/browser/preloading/prerender/prerender_manager.cc b/chrome/browser/preloading/prerender/prerender_manager.cc index b4862725..7abdd9e9 100644 --- a/chrome/browser/preloading/prerender/prerender_manager.cc +++ b/chrome/browser/preloading/prerender/prerender_manager.cc
@@ -132,7 +132,7 @@ // AutocompleteControllerAndroid::OnSuggestionSelected() or // ChromeOmniboxClient::OnURLOpenedFromOmnibox() if there is no started // prerender. - DCHECK_NE(prediction_status_, PrerenderPredictionStatus::kNotStarted); + CHECK_NE(prediction_status_, PrerenderPredictionStatus::kNotStarted); SetFailureReason(prediction_status_); base::UmaHistogramEnumeration( internal::kHistogramPrerenderPredictionStatusDefaultSearchEngine, @@ -258,7 +258,7 @@ // finalized. if (prediction_status_ != PrerenderPredictionStatus::kUnused) return; - DCHECK_NE(prediction_status, PrerenderPredictionStatus::kUnused); + CHECK_NE(prediction_status, PrerenderPredictionStatus::kUnused); prediction_status_ = prediction_status; } @@ -376,7 +376,7 @@ void PrerenderManager::StartPrerenderSearchSuggestion( const AutocompleteMatch& match, const GURL& canonical_search_url) { - DCHECK(AutocompleteMatch::IsSearchType(match.type)); + CHECK(AutocompleteMatch::IsSearchType(match.type)); TemplateURLRef::SearchTermsArgs& search_terms_args = *(match.search_terms_args); @@ -436,12 +436,12 @@ base::AutoReset<bool> resetter(&search_terms_args.is_prefetch, true); const TemplateURL* default_provider = template_url_service->GetDefaultSearchProvider(); - DCHECK(default_provider); + CHECK(default_provider); prerender_url = GURL(default_provider->url_ref().ReplaceSearchTerms( search_terms_args, template_url_service->search_terms_data(), /*post_content=*/nullptr)); } - DCHECK(!search_terms_args.is_prefetch); + CHECK(!search_terms_args.is_prefetch); } StartPrerenderSearchResultInternal(canonical_search_url, prerender_url, @@ -452,7 +452,7 @@ const GURL& canonical_search_url, const GURL& prerendering_url, base::WeakPtr<content::PreloadingAttempt> preloading_attempt) { - DCHECK(prerender_utils::SearchPrefetchUpgradeToPrerenderIsEnabled()); + CHECK(prerender_utils::SearchPrefetchUpgradeToPrerenderIsEnabled()); // If the caller does not want to prerender a new result, this does not need // to do anything. @@ -495,9 +495,9 @@ void PrerenderManager::ResetPrerenderHandlesOnPrimaryPageChanged( content::NavigationHandle* navigation_handle) { - DCHECK(navigation_handle->HasCommitted() && - navigation_handle->IsInPrimaryMainFrame() && - !navigation_handle->IsSameDocument()); + CHECK(navigation_handle->HasCommitted() && + navigation_handle->IsInPrimaryMainFrame() && + !navigation_handle->IsSameDocument()); const GURL& opened_url = navigation_handle->GetURL(); if (direct_url_input_prerender_handle_) { // Record whether or not the prediction is correct when prerendering for @@ -591,7 +591,7 @@ /*preloading_attempt=*/attempt.get(), std::move(url_match_predicate)); if (prerender_handle) { - DCHECK(!search_prerender_task_) + CHECK(!search_prerender_task_) << "SearchPrerenderTask should be reset before setting a new one."; search_prerender_task_ = std::make_unique<SearchPrerenderTask>( canonical_search_url, std::move(prerender_handle));
diff --git a/chrome/browser/preloading/prerender/prerender_omnibox_ui_browsertest.cc b/chrome/browser/preloading/prerender/prerender_omnibox_ui_browsertest.cc index 75716d6..18fd2a9 100644 --- a/chrome/browser/preloading/prerender/prerender_omnibox_ui_browsertest.cc +++ b/chrome/browser/preloading/prerender/prerender_omnibox_ui_browsertest.cc
@@ -90,7 +90,7 @@ } void OnInitialized() override { - DCHECK(waiting_); + CHECK(waiting_); std::move(waiting_).Run(); }
diff --git a/chrome/browser/preloading/prerender/prerender_utils.cc b/chrome/browser/preloading/prerender/prerender_utils.cc index 7ec4e434..20e84ac 100644 --- a/chrome/browser/preloading/prerender/prerender_utils.cc +++ b/chrome/browser/preloading/prerender/prerender_utils.cc
@@ -31,7 +31,7 @@ } bool SearchPrefetchUpgradeToPrerenderIsEnabled() { - DCHECK(IsSearchSuggestionPrerenderEnabled()); + CHECK(IsSearchSuggestionPrerenderEnabled()); switch (features::kSearchSuggestionPrerenderImplementationTypeParam.Get()) { case features::SearchSuggestionPrerenderImplementationType::kUsePrefetch: return true;
diff --git a/chrome/browser/privacy_budget/privacy_budget_browsertest.cc b/chrome/browser/privacy_budget/privacy_budget_browsertest.cc index d638b59..71f94c70 100644 --- a/chrome/browser/privacy_budget/privacy_budget_browsertest.cc +++ b/chrome/browser/privacy_budget/privacy_budget_browsertest.cc
@@ -458,25 +458,34 @@ Contains(Key(navigation_source_id_hash))))))); } -// TODO(crbug.com/1412257): Test is flaky on Android. -#if BUILDFLAG(IS_ANDROID) -#define MAYBE_CallsCanvasToBlob DISABLED_CallsCanvasToBlob -#else -#define MAYBE_CallsCanvasToBlob CallsCanvasToBlob -#endif IN_PROC_BROWSER_TEST_F(PrivacyBudgetBrowserTestWithTestRecorder, - MAYBE_CallsCanvasToBlob) { + CallsCanvasToBlob) { ASSERT_TRUE(embedded_test_server()->Start()); content::DOMMessageQueue messages(web_contents()); base::RunLoop run_loop; - // We expect 3 entries here generated by the two navigations - // from the test. The first navigation adds a document created entry and a web - // feature entry, while the second one generates only a document created - // entry. - recorder().SetOnAddEntryCallback(ukm::builders::Identifiability::kEntryName, - BarrierClosure(3u, run_loop.QuitClosure())); + // Add a callback checking when the canvas metric is reported. + recorder().SetOnAddEntryCallback( + ukm::builders::Identifiability::kEntryName, + base::BindLambdaForTesting([this, &run_loop]() { + // toBlob() is called on a context-less canvas, hence -1, which is the + // value of blink::CanvasRenderingContext::CanvasRenderingAPI::kUnknown. + constexpr uint64_t input_digest = -1; + const uint64_t canvas_key = + blink::IdentifiableSurface::FromTypeAndToken( + blink::IdentifiableSurface::Type::kCanvasReadback, input_digest) + .ToUkmMetricHash(); + + for (const ukm::mojom::UkmEntry* entry : recorder().GetEntriesByName( + ukm::builders::Identifiability::kEntryName)) { + for (const auto& [key, value] : entry->metrics) { + if (key == canvas_key) { + run_loop.Quit(); + } + } + } + })); ASSERT_TRUE(content::NavigateToURL( web_contents(), embedded_test_server()->GetURL( @@ -496,56 +505,38 @@ // Wait for the metrics to come down the pipe. run_loop.Run(); - - auto merged_entries = recorder().GetMergedEntriesByName( - ukm::builders::Identifiability::kEntryName); - - // We expect two merged entries, corresponding to the two navigations. - ASSERT_EQ(merged_entries.size(), 2u); - - // toBlob() is called on a context-less canvas, hence -1, which is the value - // of blink::CanvasRenderingContext::CanvasRenderingAPI::kUnknown. - constexpr uint64_t input_digest = -1; - - // We collect all metrics together and check that there is one that contains - // the canvas readback metrics. - auto metrics = merged_entries.begin()->second->metrics; - - for (auto& it : merged_entries) { - metrics.insert(it.second->metrics.begin(), it.second->metrics.end()); - } - - // The exact values depend on the test host, so we only check that the metric - // was collected. - EXPECT_THAT(metrics, - IsSupersetOf({ - Key(blink::IdentifiableSurface::FromTypeAndToken( - blink::IdentifiableSurface::Type::kCanvasReadback, - input_digest) - .ToUkmMetricHash()), - })); } -// TODO(crbug.com/1238940, crbug.com/1238859): Test is flaky on Win and Android. -#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_ANDROID) -#define MAYBE_CanvasToBlobDifferentDocument \ - DISABLED_CanvasToBlobDifferentDocument -#else -#define MAYBE_CanvasToBlobDifferentDocument CanvasToBlobDifferentDocument -#endif IN_PROC_BROWSER_TEST_F(PrivacyBudgetBrowserTestWithTestRecorder, - MAYBE_CanvasToBlobDifferentDocument) { + CanvasToBlobDifferentDocument) { ASSERT_TRUE(embedded_test_server()->Start()); content::DOMMessageQueue messages(web_contents()); base::RunLoop run_loop; - // We expect 3 entries here generated by the two navigations - // from the test. The first navigation adds a document created entry and a web - // feature entry, while the second one generates only a document created - // entry. - recorder().SetOnAddEntryCallback(ukm::builders::Identifiability::kEntryName, - BarrierClosure(3u, run_loop.QuitClosure())); + // Add a callback checking when the canvas metric is reported. + recorder().SetOnAddEntryCallback( + ukm::builders::Identifiability::kEntryName, + base::BindLambdaForTesting([this, &run_loop]() { + // (kCanvasReadback | input_digest << kTypeBits) = one of the + // merged_entries. If the value of the relevant merged entry changes, + // input_digest needs to change. The new input_digest can be calculated + // by: new_input_digest = new_ukm_entry >> kTypeBits; + constexpr uint64_t input_digest = UINT64_C(33457614533296512); + const uint64_t canvas_key = + blink::IdentifiableSurface::FromTypeAndToken( + blink::IdentifiableSurface::Type::kCanvasReadback, input_digest) + .ToUkmMetricHash(); + + for (const ukm::mojom::UkmEntry* entry : recorder().GetEntriesByName( + ukm::builders::Identifiability::kEntryName)) { + for (const auto& [key, value] : entry->metrics) { + if (key == canvas_key) { + run_loop.Quit(); + } + } + } + })); ASSERT_TRUE(content::NavigateToURL( web_contents(), embedded_test_server()->GetURL( @@ -565,42 +556,6 @@ // Wait for the metrics to come down the pipe. run_loop.Run(); - - auto merged_entries = recorder().GetMergedEntriesByName( - ukm::builders::Identifiability::kEntryName); - - // We expect two merged entries, corresponding to the two navigations. - ASSERT_EQ(merged_entries.size(), 2u); - - // (kCanvasReadback | input_digest << kTypeBits) = one of the merged_entries - // If the value of the relevant merged entry changes, input_digest needs to - // change. The new input_digest can be calculated by: - // new_input_digest = new_ukm_entry >> kTypeBits; - constexpr uint64_t input_digest = UINT64_C(33457614533296512); - // We collect all metrics together and check that there is one that contains - // the canvas readback metrics. - auto metrics = merged_entries.begin()->second->metrics; - - for (auto& it : merged_entries) { - metrics.insert(it.second->metrics.begin(), it.second->metrics.end()); - } - - // The exact values depend on the test host, so we only check that the metric - // was collected. - EXPECT_THAT(metrics, - IsSupersetOf({ - Key(blink::IdentifiableSurface::FromTypeAndToken( - blink::IdentifiableSurface::Type::kCanvasReadback, - input_digest) - .ToUkmMetricHash()), - })); - - for (auto& metric : metrics) { - auto surface(blink::IdentifiableSurface::FromMetricHash(metric.first)); - LOG(INFO) << "surface type " << static_cast<uint64_t>(surface.GetType()) - << " surface input hash " << surface.GetInputHash() << " value " - << metric.second; - } } namespace {
diff --git a/chrome/browser/profiles/delete_profile_helper.cc b/chrome/browser/profiles/delete_profile_helper.cc index ce481ef..ae4096aa 100644 --- a/chrome/browser/profiles/delete_profile_helper.cc +++ b/chrome/browser/profiles/delete_profile_helper.cc
@@ -4,6 +4,8 @@ #include "chrome/browser/profiles/delete_profile_helper.h" +#include <memory> + #include "base/check.h" #include "base/feature_list.h" #include "base/files/file_path.h" @@ -18,6 +20,7 @@ #include "chrome/browser/download/download_core_service.h" #include "chrome/browser/download/download_core_service_factory.h" #include "chrome/browser/password_manager/password_store_factory.h" +#include "chrome/browser/profiles/keep_alive/profile_keep_alive_types.h" #include "chrome/browser/profiles/nuke_profile_directory_utils.h" #include "chrome/browser/profiles/profile_attributes_entry.h" #include "chrome/browser/profiles/profile_attributes_storage.h" @@ -126,7 +129,8 @@ } void DeleteProfileHelper::ScheduleEphemeralProfileForDeletion( - const base::FilePath& profile_dir) { + const base::FilePath& profile_dir, + std::unique_ptr<ScopedProfileKeepAlive> keep_alive) { DCHECK(IsRegisteredAsEphemeral( &profile_manager_->GetProfileAttributesStorage(), profile_dir)); DCHECK_EQ(0u, chrome::GetBrowserCount( @@ -143,7 +147,8 @@ DCHECK(!new_active_profile_dir->empty()); RemoveFromLastActiveProfilesPrefList(profile_dir); - FinishDeletingProfile(profile_dir, new_active_profile_dir.value()); + FinishDeletingProfile(profile_dir, new_active_profile_dir.value(), + std::move(keep_alive)); } void DeleteProfileHelper::CleanUpEphemeralProfiles() { @@ -240,7 +245,12 @@ profile_manager_->GetProfileByPath(last_used_profile_path); if (last_used_profile_path != profile_dir && last_used_profile_path != guest_profile_path && last_used_profile) { - FinishDeletingProfile(profile_dir, last_used_profile_path); + Profile* profile = profile_manager_->GetProfileByPath(profile_dir); + FinishDeletingProfile( + profile_dir, last_used_profile_path, + profile ? std::make_unique<ScopedProfileKeepAlive>( + profile, ProfileKeepAliveOrigin::kProfileDeletionProcess) + : nullptr); return; } @@ -292,7 +302,8 @@ void DeleteProfileHelper::FinishDeletingProfile( const base::FilePath& profile_dir, - const base::FilePath& new_active_profile_dir) { + const base::FilePath& new_active_profile_dir, + std::unique_ptr<ScopedProfileKeepAlive> keep_alive) { // Update the last used profile pref before closing browser windows. This // way the correct last used profile is set for any notification observers. profiles::SetLastUsedProfile(new_active_profile_dir.BaseName()); @@ -302,7 +313,8 @@ profile_manager_->LoadProfileByPath( profile_dir, false, base::BindOnce(&DeleteProfileHelper::OnLoadProfileForProfileDeletion, - base::Unretained(this), profile_dir)); + base::Unretained(this), profile_dir, + std::move(keep_alive))); if (!IsProfileDirectoryMarkedForDeletion(profile_dir)) { // Prevents CreateProfileAsync from re-creating the profile. MarkProfileDirectoryForDeletion(profile_dir); @@ -311,6 +323,7 @@ void DeleteProfileHelper::OnLoadProfileForProfileDeletion( const base::FilePath& profile_dir, + std::unique_ptr<ScopedProfileKeepAlive> keep_alive, Profile* profile) { ProfileAttributesStorage& storage = profile_manager_->GetProfileAttributesStorage(); @@ -392,6 +405,13 @@ return; } - FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); + Profile* profile_to_delete = + profile_manager_->GetProfileByPath(profile_to_delete_path); + FinishDeletingProfile( + profile_to_delete_path, new_active_profile_path, + profile_to_delete ? std::make_unique<ScopedProfileKeepAlive>( + profile_to_delete, + ProfileKeepAliveOrigin::kProfileDeletionProcess) + : nullptr); std::move(callback).Run(loaded_profile); }
diff --git a/chrome/browser/profiles/delete_profile_helper.h b/chrome/browser/profiles/delete_profile_helper.h index d2b5da4..e529c24f 100644 --- a/chrome/browser/profiles/delete_profile_helper.h +++ b/chrome/browser/profiles/delete_profile_helper.h
@@ -7,6 +7,7 @@ #include "base/functional/callback_forward.h" #include "base/memory/raw_ref.h" +#include "chrome/browser/profiles/keep_alive/scoped_profile_keep_alive.h" #include "chrome/browser/profiles/profile_metrics.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -51,7 +52,9 @@ // Schedules the ephemeral profile at the given path to be deleted. New // profiles will not be created. If the profile is not loaded, this may // trigger a reload of the profile so that user data is cleaned up. - void ScheduleEphemeralProfileForDeletion(const base::FilePath& profile_dir); + void ScheduleEphemeralProfileForDeletion( + const base::FilePath& profile_dir, + std::unique_ptr<ScopedProfileKeepAlive> keep_alive); // Checks if any profiles are left behind (e.g. because of a browser // crash) and schedule them for deletion. Unlike the "Schedule" methods above, @@ -73,10 +76,14 @@ // Schedules the profile at the given path to be deleted on shutdown, // and marks the new profile as active. - void FinishDeletingProfile(const base::FilePath& profile_dir, - const base::FilePath& new_active_profile_dir); - void OnLoadProfileForProfileDeletion(const base::FilePath& profile_dir, - Profile* profile); + void FinishDeletingProfile( + const base::FilePath& profile_dir, + const base::FilePath& new_active_profile_dir, + std::unique_ptr<ScopedProfileKeepAlive> keep_alive); + void OnLoadProfileForProfileDeletion( + const base::FilePath& profile_dir, + std::unique_ptr<ScopedProfileKeepAlive> keep_alive, + Profile* profile); // If the `loaded_profile` has been loaded successfully and isn't already // scheduled for deletion, then finishes adding `profile_to_delete_dir` to the
diff --git a/chrome/browser/profiles/incognito_mode_policy_handler.cc b/chrome/browser/profiles/incognito_mode_policy_handler.cc index 844cdd3..af87e21 100644 --- a/chrome/browser/profiles/incognito_mode_policy_handler.cc +++ b/chrome/browser/profiles/incognito_mode_policy_handler.cc
@@ -36,7 +36,7 @@ base::Value::GetTypeName(base::Value::Type::INTEGER)); return false; } - IncognitoModePrefs::Availability availability_enum_value; + policy::IncognitoModeAvailability availability_enum_value; if (!IncognitoModePrefs::IntToAvailability(availability->GetInt(), &availability_enum_value)) { errors->AddError(key::kIncognitoModeAvailability, @@ -77,7 +77,7 @@ const base::Value* deprecated_enabled = policies.GetValue(key::kIncognitoEnabled, base::Value::Type::BOOLEAN); if (availability) { - IncognitoModePrefs::Availability availability_enum_value; + policy::IncognitoModeAvailability availability_enum_value; if (IncognitoModePrefs::IntToAvailability(availability->GetInt(), &availability_enum_value)) { prefs->SetInteger(policy::policy_prefs::kIncognitoModeAvailability, @@ -89,8 +89,8 @@ prefs->SetInteger( policy::policy_prefs::kIncognitoModeAvailability, static_cast<int>(deprecated_enabled->GetBool() - ? IncognitoModePrefs::Availability::kEnabled - : IncognitoModePrefs::Availability::kDisabled)); + ? policy::IncognitoModeAvailability::kEnabled + : policy::IncognitoModeAvailability::kDisabled)); } }
diff --git a/chrome/browser/profiles/incognito_mode_policy_handler_unittest.cc b/chrome/browser/profiles/incognito_mode_policy_handler_unittest.cc index 6ceeaf7..2228d9d 100644 --- a/chrome/browser/profiles/incognito_mode_policy_handler_unittest.cc +++ b/chrome/browser/profiles/incognito_mode_policy_handler_unittest.cc
@@ -48,7 +48,7 @@ UpdateProviderPolicy(policy); } - void VerifyValues(IncognitoModePrefs::Availability availability) { + void VerifyValues(policy::IncognitoModeAvailability availability) { const base::Value* value = nullptr; EXPECT_TRUE(store_->GetValue( policy::policy_prefs::kIncognitoModeAvailability, &value)); @@ -62,22 +62,22 @@ TEST_F(IncognitoModePolicyHandlerTest, NoObsoletePolicyAndIncognitoEnabled) { SetPolicies(INCOGNITO_ENABLED_UNKNOWN, - static_cast<int>(IncognitoModePrefs::Availability::kEnabled)); - VerifyValues(IncognitoModePrefs::Availability::kEnabled); + static_cast<int>(policy::IncognitoModeAvailability::kEnabled)); + VerifyValues(policy::IncognitoModeAvailability::kEnabled); } TEST_F(IncognitoModePolicyHandlerTest, NoObsoletePolicyAndIncognitoDisabled) { SetPolicies(INCOGNITO_ENABLED_UNKNOWN, - static_cast<int>(IncognitoModePrefs::Availability::kDisabled)); - VerifyValues(IncognitoModePrefs::Availability::kDisabled); + static_cast<int>(policy::IncognitoModeAvailability::kDisabled)); + VerifyValues(policy::IncognitoModeAvailability::kDisabled); } TEST_F(IncognitoModePolicyHandlerTest, NoObsoletePolicyAndIncognitoForced) { SetPolicies(INCOGNITO_ENABLED_UNKNOWN, - static_cast<int>(IncognitoModePrefs::Availability::kForced)); - VerifyValues(IncognitoModePrefs::Availability::kForced); + static_cast<int>(policy::IncognitoModeAvailability::kForced)); + VerifyValues(policy::IncognitoModeAvailability::kForced); } TEST_F(IncognitoModePolicyHandlerTest, @@ -94,27 +94,27 @@ TEST_F(IncognitoModePolicyHandlerTest, ObsoletePolicyDoesNotAffectAvailabilityEnabled) { SetPolicies(INCOGNITO_ENABLED_FALSE, - static_cast<int>(IncognitoModePrefs::Availability::kEnabled)); - VerifyValues(IncognitoModePrefs::Availability::kEnabled); + static_cast<int>(policy::IncognitoModeAvailability::kEnabled)); + VerifyValues(policy::IncognitoModeAvailability::kEnabled); } TEST_F(IncognitoModePolicyHandlerTest, ObsoletePolicyDoesNotAffectAvailabilityForced) { SetPolicies(INCOGNITO_ENABLED_TRUE, - static_cast<int>(IncognitoModePrefs::Availability::kForced)); - VerifyValues(IncognitoModePrefs::Availability::kForced); + static_cast<int>(policy::IncognitoModeAvailability::kForced)); + VerifyValues(policy::IncognitoModeAvailability::kForced); } TEST_F(IncognitoModePolicyHandlerTest, ObsoletePolicySetsPreferenceToEnabled) { SetPolicies(INCOGNITO_ENABLED_TRUE, kIncognitoModeAvailabilityNotSet); - VerifyValues(IncognitoModePrefs::Availability::kEnabled); + VerifyValues(policy::IncognitoModeAvailability::kEnabled); } TEST_F(IncognitoModePolicyHandlerTest, ObsoletePolicySetsPreferenceToDisabled) { SetPolicies(INCOGNITO_ENABLED_FALSE, kIncognitoModeAvailabilityNotSet); - VerifyValues(IncognitoModePrefs::Availability::kDisabled); + VerifyValues(policy::IncognitoModeAvailability::kDisabled); } } // namespace policy
diff --git a/chrome/browser/profiles/keep_alive/profile_keep_alive_types.cc b/chrome/browser/profiles/keep_alive/profile_keep_alive_types.cc index 79634dd..ff5d412a 100644 --- a/chrome/browser/profiles/keep_alive/profile_keep_alive_types.cc +++ b/chrome/browser/profiles/keep_alive/profile_keep_alive_types.cc
@@ -69,6 +69,8 @@ return out << "kProfileCreationSamlFlow"; case ProfileKeepAliveOrigin::kDriveFsNativeMessageHostLacros: return out << "kDriveFsNativeMessageHostLacros"; + case ProfileKeepAliveOrigin::kProfileDeletionProcess: + return out << "kProfileDeletionProcess"; } NOTREACHED(); return out << static_cast<int>(origin);
diff --git a/chrome/browser/profiles/keep_alive/profile_keep_alive_types.h b/chrome/browser/profiles/keep_alive/profile_keep_alive_types.h index 378d062f..b9de360 100644 --- a/chrome/browser/profiles/keep_alive/profile_keep_alive_types.h +++ b/chrome/browser/profiles/keep_alive/profile_keep_alive_types.h
@@ -86,6 +86,9 @@ kExtensionUpdater = 18, // This profile is being created (and is used to render GAIA sign-in flow). + // The profile creation flow either opens a browser window before + // kProfileCreationFlow keep alive is released or gets aborted without opening + // a browser window and in that case the profile should be removed. kProfileCreationFlow = 19, // The user just closed a notification. This might cause writing to the @@ -135,7 +138,13 @@ // This keeps the profile alive while the connection is active. kDriveFsNativeMessageHostLacros = 31, - kMaxValue = kDriveFsNativeMessageHostLacros, + // Used during the deletion process for the respective profile. Avoids the + // profile from being randomly unloaded. Useful to keep an ephemeral profile + // alive until their deletion is completed, after releasing its last keep + // alive. + kProfileDeletionProcess = 32, + + kMaxValue = kProfileDeletionProcess, }; std::ostream& operator<<(std::ostream& out,
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc index 43431d7a..0e4d187d 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.cc +++ b/chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -71,6 +71,7 @@ #include "components/keyed_service/core/simple_key_map.h" #include "components/keyed_service/core/simple_keyed_service_factory.h" #include "components/permissions/permission_manager.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/prefs/json_pref_store.h" #include "components/profile_metrics/browser_profile_type.h" #include "components/security_interstitials/content/stateful_ssl_host_state_delegate.h" @@ -199,7 +200,7 @@ // Always crash when incognito is not available. CHECK(!IsIncognitoProfile() || IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) != - IncognitoModePrefs::Availability::kDisabled); + policy::IncognitoModeAvailability::kDisabled); TrackZoomLevelsFromParent();
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc index eab4bc3..13171da 100644 --- a/chrome/browser/profiles/profile_manager.cc +++ b/chrome/browser/profiles/profile_manager.cc
@@ -76,6 +76,7 @@ #include "components/bookmarks/common/bookmark_pref_names.h" #include "components/browsing_data/core/pref_names.h" #include "components/content_settings/core/browser/host_content_settings_map.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" #include "components/search_engines/default_search_manager.h" @@ -514,7 +515,7 @@ return nullptr; if (profile->IsGuestSession() || profile->IsSystemProfile() || IncognitoModePrefs::GetAvailability(profile->GetPrefs()) == - IncognitoModePrefs::Availability::kForced) { + policy::IncognitoModeAvailability::kForced) { return profile->GetPrimaryOTRProfile(/*create_if_needed=*/true); } return profile; @@ -1287,6 +1288,7 @@ << "). keep_alives=" << info->keep_alives; if (origin == ProfileKeepAliveOrigin::kBrowserWindow || + origin == ProfileKeepAliveOrigin::kProfileCreationFlow || (origin == ProfileKeepAliveOrigin::kProfilePickerView && base::FeatureList::IsEnabled(features::kDestroySystemProfiles))) { ClearFirstBrowserWindowKeepAlive(profile); @@ -1300,7 +1302,8 @@ CHECK(profile); CHECK(!profile->IsOffTheRecord()); - ProfileInfo* info = GetProfileInfoByPath(profile->GetPath()); + const base::FilePath profile_path = profile->GetPath(); + ProfileInfo* info = GetProfileInfoByPath(profile_path); if (!info) { // Can be null in unit tests, when the Profile was not created via // ProfileManager. @@ -1313,6 +1316,22 @@ } DCHECK(base::Contains(info->keep_alives, origin)); + +#if !BUILDFLAG(IS_ANDROID) + // When removing the last keep alive of an ephemeral profile, schedule the + // profile for deletion if it is not yet marked. + bool ephemeral = + IsRegisteredAsEphemeral(&GetProfileAttributesStorage(), profile_path); + bool marked_for_deletion = IsProfileDirectoryMarkedForDeletion(profile_path); + if (ephemeral && !marked_for_deletion && + GetTotalRefCount(info->keep_alives) == 1) { + delete_profile_helper_->ScheduleEphemeralProfileForDeletion( + profile_path, + std::make_unique<ScopedProfileKeepAlive>( + profile, ProfileKeepAliveOrigin::kProfileDeletionProcess)); + } +#endif + info->keep_alives[origin]--; DCHECK_LE(0, info->keep_alives[origin]); @@ -2070,16 +2089,8 @@ } base::FilePath path = profile->GetPath(); - ProfileInfo* info = GetProfileInfoByPath(path); if (IsProfileDirectoryMarkedForDeletion(path)) { // Do nothing if the profile is already being deleted. - } else if (IsRegisteredAsEphemeral(&GetProfileAttributesStorage(), path) && - info->keep_alives[ProfileKeepAliveOrigin::kProfileCreationFlow] == - 0) { - // Delete if the profile is an ephemeral profile and it is not in the - // profile creation flow. - // TODO(crbug.com/1369535): Delete the profile when there is no keep alive. - delete_profile_helper_->ScheduleEphemeralProfileForDeletion(path); } else if (!profile->IsOffTheRecord()) { auto* browsing_data_lifetime_manager = ChromeBrowsingDataLifetimeManagerFactory::GetForProfile(
diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc index 73bd9bc..5613bf10 100644 --- a/chrome/browser/profiles/profile_manager_unittest.cc +++ b/chrome/browser/profiles/profile_manager_unittest.cc
@@ -49,6 +49,7 @@ #include "chrome/test/base/testing_profile.h" #include "components/account_id/account_id.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/supervised_user/core/common/buildflags.h" #include "content/public/browser/notification_service.h" #include "content/public/common/content_switches.h" @@ -1231,14 +1232,14 @@ ASSERT_TRUE(profile->GetPrimaryOTRProfile(/*create_if_needed=*/true)); IncognitoModePrefs::SetAvailability( - prefs, IncognitoModePrefs::Availability::kDisabled); + prefs, policy::IncognitoModeAvailability::kDisabled); EXPECT_FALSE( profile_manager->GetLastUsedProfileAllowedByPolicy()->IsOffTheRecord()); // GetLastUsedProfileAllowedByPolicy() returns the off-the-record Profile when // incognito mode is forced. IncognitoModePrefs::SetAvailability( - prefs, IncognitoModePrefs::Availability::kForced); + prefs, policy::IncognitoModeAvailability::kForced); EXPECT_TRUE( profile_manager->GetLastUsedProfileAllowedByPolicy()->IsOffTheRecord()); }
diff --git a/chrome/browser/profiles/profile_selections.cc b/chrome/browser/profiles/profile_selections.cc index 72f10df..b0515bd 100644 --- a/chrome/browser/profiles/profile_selections.cc +++ b/chrome/browser/profiles/profile_selections.cc
@@ -15,7 +15,7 @@ BASE_FEATURE(kSystemProfileSelectionDefaultNone, "SystemProfileSelectionDefaultNone", - base::FeatureState::FEATURE_DISABLED_BY_DEFAULT); + base::FeatureState::FEATURE_ENABLED_BY_DEFAULT); bool AreKeyedServicesDisabledForProfileByDefault(const Profile* profile) { if (profile && profile->IsSystemProfile()) {
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu.cc b/chrome/browser/renderer_context_menu/render_view_context_menu.cc index 766d0ed..5041b20 100644 --- a/chrome/browser/renderer_context_menu/render_view_context_menu.cc +++ b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
@@ -133,6 +133,7 @@ #include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/password_manager/core/browser/password_manager_util.h" #include "components/policy/content/policy_blocklist_service.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/prefs/pref_member.h" #include "components/prefs/pref_service.h" #include "components/search_engines/search_engines_pref_names.h" @@ -3550,9 +3551,9 @@ if (!IsURLAllowedInIncognito(params_.link_url, browser_context_)) return false; - IncognitoModePrefs::Availability incognito_avail = + policy::IncognitoModeAvailability incognito_avail = IncognitoModePrefs::GetAvailability(GetPrefs(browser_context_)); - return incognito_avail != IncognitoModePrefs::Availability::kDisabled; + return incognito_avail != policy::IncognitoModeAvailability::kDisabled; } void RenderViewContextMenu::ExecOpenWebApp() {
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu_unittest.cc b/chrome/browser/renderer_context_menu/render_view_context_menu_unittest.cc index 6815ae6..2cd29c6 100644 --- a/chrome/browser/renderer_context_menu/render_view_context_menu_unittest.cc +++ b/chrome/browser/renderer_context_menu/render_view_context_menu_unittest.cc
@@ -575,7 +575,7 @@ // Disable Incognito mode. IncognitoModePrefs::SetAvailability( - profile()->GetPrefs(), IncognitoModePrefs::Availability::kDisabled); + profile()->GetPrefs(), policy::IncognitoModeAvailability::kDisabled); menu = CreateContextMenu(); ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD)); EXPECT_FALSE(
diff --git a/chrome/browser/resources/chromeos/cloud_upload/BUILD.gn b/chrome/browser/resources/chromeos/cloud_upload/BUILD.gn index ac12b391..f6c02bc 100644 --- a/chrome/browser/resources/chromeos/cloud_upload/BUILD.gn +++ b/chrome/browser/resources/chromeos/cloud_upload/BUILD.gn
@@ -28,7 +28,6 @@ ] web_component_files = [ "base_setup_page.ts", - "drive_upload_page.ts", "file_handler_card.ts", "file_handler_page.ts", "move_confirmation_page.ts",
diff --git a/chrome/browser/resources/chromeos/cloud_upload/drive_upload_page.html b/chrome/browser/resources/chromeos/cloud_upload/drive_upload_page.html deleted file mode 100644 index 940744e..0000000 --- a/chrome/browser/resources/chromeos/cloud_upload/drive_upload_page.html +++ /dev/null
@@ -1,56 +0,0 @@ -<style> - :host { - box-sizing: border-box; - display: flex; - flex-direction: column; - padding: 32px; - width: 512px; - } - - .title { - color: var(--cros-text-color-primary); - font: var(--cros-display-7-font); - } - - #content:focus-visible { - outline: none; - } - - .normal-text { - color: var(--cros-text-color-secondary); - font: var(--cros-body-2-font); - margin-block-end: 32px; - margin-block-start: 16px; - } - - #button-container { - display: flex; - justify-content: flex-end; - } - - cr-button { - border-radius: 16px; - } - - cr-button:focus-visible { - /* disable cr-button default keyboard focus style */ - box-shadow: none; - outline: 2px solid var(--cros-focus-ring-color); - outline-offset: 2px; - } -</style> - -<!-- TODO(b/258071752): Use localized strings --> -<div id="content" autofocus tabindex="-1"> - <div class="title"> - Files will move to Google Drive when opening in Docs, Sheets, or Slides - </div> - <div class="normal-text"> - <!-- TODO(b/258071752): Deep link to settings --> - You can change this at any time in Settings > Files > Office file handling - </div> -</div> -<div id="button-container"> - <cr-button class="cancel-button">$i18n{cancel}</cr-button> - <cr-button class="action-button">Continue</cr-button> -</div>
diff --git a/chrome/browser/resources/chromeos/cloud_upload/drive_upload_page.ts b/chrome/browser/resources/chromeos/cloud_upload/drive_upload_page.ts deleted file mode 100644 index 6df30c2..0000000 --- a/chrome/browser/resources/chromeos/cloud_upload/drive_upload_page.ts +++ /dev/null
@@ -1,47 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'chrome://resources/cr_elements/cr_button/cr_button.js'; - -import {assert} from 'chrome://resources/js/assert_ts.js'; - -import {UserAction} from './cloud_upload.mojom-webui.js'; -import {CloudUploadBrowserProxy} from './cloud_upload_browser_proxy.js'; -import {getTemplate} from './drive_upload_page.html.js'; - -/** - * The DriveUploadPageElement represents the setup page the user sees after - * choosing Docs/Sheets/Slides. - */ -export class DriveUploadPageElement extends HTMLElement { - private proxy: CloudUploadBrowserProxy = - CloudUploadBrowserProxy.getInstance(); - - constructor() { - super(); - const shadowRoot = this.attachShadow({mode: 'open'}); - - shadowRoot.innerHTML = getTemplate(); - const uploadButton = - shadowRoot.querySelector<HTMLElement>('.action-button'); - const cancelButton = - shadowRoot.querySelector<HTMLElement>('.cancel-button'); - assert(uploadButton); - assert(cancelButton); - - uploadButton.addEventListener('click', () => this.onContinueButtonClick()); - cancelButton.addEventListener('click', () => this.onCancelButtonClick()); - } - - private onContinueButtonClick(): void { - this.proxy.handler.respondWithUserActionAndClose( - UserAction.kConfirmOrUploadToGoogleDrive); - } - - private onCancelButtonClick(): void { - this.proxy.handler.respondWithUserActionAndClose(UserAction.kCancel); - } -} - -customElements.define('drive-upload-page', DriveUploadPageElement); \ No newline at end of file
diff --git a/chrome/browser/resources/chromeos/cloud_upload/file_handler_page.ts b/chrome/browser/resources/chromeos/cloud_upload/file_handler_page.ts index e128e0f..b832f85 100644 --- a/chrome/browser/resources/chromeos/cloud_upload/file_handler_page.ts +++ b/chrome/browser/resources/chromeos/cloud_upload/file_handler_page.ts
@@ -272,7 +272,6 @@ continue; } if (providerCard.type === CloudProviderType.DRIVE) { - // TODO(petermarshall): Remove kSetUpGoogleDrive step or use it here. this.proxy.handler.respondWithUserActionAndClose( UserAction.kConfirmOrUploadToGoogleDrive); return;
diff --git a/chrome/browser/resources/chromeos/cloud_upload/main.ts b/chrome/browser/resources/chromeos/cloud_upload/main.ts index 6ef419f..53ab56a 100644 --- a/chrome/browser/resources/chromeos/cloud_upload/main.ts +++ b/chrome/browser/resources/chromeos/cloud_upload/main.ts
@@ -3,7 +3,6 @@ // found in the LICENSE file. import './cloud_upload_dialog.js'; -import './drive_upload_page.js'; import './file_handler_page.js'; import {assert} from 'chrome://resources/js/assert_ts.js'; @@ -25,10 +24,6 @@ document.body.append(document.createElement('cloud-upload')); break; } - case DialogPage.kGoogleDriveSetup: { - document.body.append(document.createElement('drive-upload-page')); - break; - } case DialogPage.kMoveConfirmationOneDrive: { const movePage = new MoveConfirmationPageElement(); movePage.setNumFiles(dialogArgs.args.fileNames.length);
diff --git a/chrome/browser/resources/chromeos/emoji_picker/emoji_picker.ts b/chrome/browser/resources/chromeos/emoji_picker/emoji_picker.ts index 48380449..99f0de5 100644 --- a/chrome/browser/resources/chromeos/emoji_picker/emoji_picker.ts +++ b/chrome/browser/resources/chromeos/emoji_picker/emoji_picker.ts
@@ -1004,15 +1004,17 @@ visualContent: emoji.base.visualContent, keywords: [], }, - alternates: emoji.alternates.map( - (alternate: Emoji): - Emoji => { - return { - string: alternate.string, - name: alternate.name, - keywords: [...(alternate.keywords ?? [])], - }; - }), + alternates: emoji.alternates?.map( + (alternate: Emoji): + Emoji => { + return { + string: alternate.string, + name: alternate.name, + keywords: + [...(alternate.keywords ?? [])], + }; + }) ?? + [], })) ?? []; }
diff --git a/chrome/browser/resources/chromeos/login/oobe.css b/chrome/browser/resources/chromeos/login/oobe.css index 791aa15c..5b411f0 100644 --- a/chrome/browser/resources/chromeos/login/oobe.css +++ b/chrome/browser/resources/chromeos/login/oobe.css
@@ -98,6 +98,13 @@ } } +#welcome-backdrop { + visibility: hidden; +} + +html.simon-enabled #welcome-backdrop { + visibility: visible; +} button { font-family: inherit; outline: none;
diff --git a/chrome/browser/resources/chromeos/login/oobe.html b/chrome/browser/resources/chromeos/login/oobe.html index dc11fd88..8a9b153f 100644 --- a/chrome/browser/resources/chromeos/login/oobe.html +++ b/chrome/browser/resources/chromeos/login/oobe.html
@@ -24,6 +24,9 @@ <!-- OOBE Start Script --> <script type="module" src="./oobe.js"></script> </head> +<if expr="_google_chrome"> + <img id="welcome-backdrop" src="internal_assets/welcome_backdrop.svg" aria-hidden="true"> +</if> <custom-style> <style include="oobe-flex-layout-styles"></style>
diff --git a/chrome/browser/resources/chromeos/login/screens/oobe/welcome_dialog.js b/chrome/browser/resources/chromeos/login/screens/oobe/welcome_dialog.js index fcf60dd..4b906ce 100644 --- a/chrome/browser/resources/chromeos/login/screens/oobe/welcome_dialog.js +++ b/chrome/browser/resources/chromeos/login/screens/oobe/welcome_dialog.js
@@ -215,6 +215,12 @@ this.setVideoPlay_(visible); } + getProjectSimonProductName() { + return loadTimeData.valueExists('kProjectSimonProductName') ? + loadTimeData.getString('kProjectSimonProductName') : + ''; + } + /** * Play or pause welcome video. * @param {boolean} play - whether play or pause welcome video.
diff --git a/chrome/browser/resources/settings/chromeos/os_people_page/os_sync_controls_subpage.html b/chrome/browser/resources/settings/chromeos/os_people_page/os_sync_controls_subpage.html index 7dc1172..dcb158b6 100644 --- a/chrome/browser/resources/settings/chromeos/os_people_page/os_sync_controls_subpage.html +++ b/chrome/browser/resources/settings/chromeos/os_people_page/os_sync_controls_subpage.html
@@ -18,7 +18,7 @@ <div id="featureLabel" class="settings-box"> <localized-link class="secondary" localized-string="$i18n{osSyncFeatureLabel}" - link-url="$i18n{browserSettingsSyncSetupUrl}"> + on-link-clicked="onBrowserSyncSettingsClicked_"> </localized-link> </div> <div id="syncDataRadio" class="cr-row first">
diff --git a/chrome/browser/resources/settings/chromeos/os_people_page/os_sync_controls_subpage.ts b/chrome/browser/resources/settings/chromeos/os_people_page/os_sync_controls_subpage.ts index cba01f1..b5b0781 100644 --- a/chrome/browser/resources/settings/chromeos/os_people_page/os_sync_controls_subpage.ts +++ b/chrome/browser/resources/settings/chromeos/os_people_page/os_sync_controls_subpage.ts
@@ -191,6 +191,17 @@ } /** + * Called when the link to the browser's sync settings is clicked. + */ + private onBrowserSyncSettingsClicked_(event: CustomEvent<{event: Event}>) { + // Prevent the default link click behavior. + event.detail.event.preventDefault(); + + // Programmatically open browser's sync settings. + chrome.send('OpenBrowserSyncSettings'); + } + + /** * Handler for when any sync data type checkbox is changed. */ private onSingleSyncDataTypeChanged_(): void {
diff --git a/chrome/browser/resources/settings/chromeos/os_settings.ts b/chrome/browser/resources/settings/chromeos/os_settings.ts index eb4a21f..cc7b278 100644 --- a/chrome/browser/resources/settings/chromeos/os_settings.ts +++ b/chrome/browser/resources/settings/chromeos/os_settings.ts
@@ -110,7 +110,7 @@ export {CrSettingsPrefs} from '../prefs/prefs_types.js'; export {PrivacyPageBrowserProxyImpl, SecureDnsMode, SecureDnsUiManagementMode} from '../privacy_page/privacy_page_browser_proxy.js'; export {setCrosAudioConfigForTesting} from './device_page/cros_audio_config.js'; -export {DevicePageBrowserProxy, DevicePageBrowserProxyImpl, IdleBehavior, LidClosedBehavior, NoteAppLockScreenSupport, setDisplayApiForTesting, StorageSpaceState} from './device_page/device_page_browser_proxy.js'; +export {DevicePageBrowserProxy, DevicePageBrowserProxyImpl, IdleBehavior, LidClosedBehavior, NoteAppInfo, NoteAppLockScreenSupport, setDisplayApiForTesting, StorageSpaceState} from './device_page/device_page_browser_proxy.js'; export * as fakeCrosAudioConfig from './device_page/fake_cros_audio_config.js'; export {fakeKeyboards, fakeKeyboards2, fakeMice, fakeMice2, fakePointingSticks, fakePointingSticks2, fakeTouchpads, fakeTouchpads2} from './device_page/fake_input_device_data.js'; export {FakeInputDeviceSettingsProvider} from './device_page/fake_input_device_settings_provider.js';
diff --git a/chrome/browser/resources/signin/profile_picker/profile_creation_flow/account_selection_lacros.html b/chrome/browser/resources/signin/profile_picker/profile_creation_flow/account_selection_lacros.html index 6eb0d51..12f9f16 100644 --- a/chrome/browser/resources/signin/profile_picker/profile_creation_flow/account_selection_lacros.html +++ b/chrome/browser/resources/signin/profile_picker/profile_creation_flow/account_selection_lacros.html
@@ -170,7 +170,8 @@ --theme-text-color:[[profileThemeInfo.themeFrameTextColor]];"> <template is="dom-if" if="[[hasPreviousRoute_]]"> <cr-icon-button id="backButton" iron-icon="cr:arrow-back" - on-click="onBackClick_" aria-label$="[[getBackButtonAriaLabel_()]]"> + on-click="onBackClick_" aria-label$="[[getBackButtonAriaLabel_()]]" + title$="[[getBackButtonAriaLabel_()]]"> </cr-icon-button> </template> </div>
diff --git a/chrome/browser/resources/signin/profile_picker/profile_creation_flow/local_profile_customization.html b/chrome/browser/resources/signin/profile_picker/profile_creation_flow/local_profile_customization.html index ff6bb37..c87dc51 100644 --- a/chrome/browser/resources/signin/profile_picker/profile_creation_flow/local_profile_customization.html +++ b/chrome/browser/resources/signin/profile_picker/profile_creation_flow/local_profile_customization.html
@@ -200,7 +200,8 @@ --theme-shape-color:[[profileThemeInfo.themeShapeColor]]"> <iron-icon class="banner" icon="profiles:customize-banner"></iron-icon> <cr-icon-button id="backButton" iron-icon="cr:arrow-back" - on-click="onBackClick_" aria-label$="[[getBackButtonAriaLabel_()]]"> + on-click="onBackClick_" aria-label$="[[getBackButtonAriaLabel_()]]" + title$="[[getBackButtonAriaLabel_()]]"> </cr-icon-button> <h1 class="title" id="title">$i18n{localProfileCreationTitle}</h1> <div id="avatarContainer"> @@ -208,7 +209,8 @@ <div id="customizeAvatarEllipse"></div> <cr-icon-button id="customizeAvatarIcon" iron-icon="cr:create" on-click="onCustomizeAvatarClick_" - aria-label="$i18n{localProfileCreationCustomizeAvatarLabel}"> + aria-label="$i18n{localProfileCreationCustomizeAvatarLabel}" + title="$i18n{localProfileCreationCustomizeAvatarLabel}"> </cr-icon-button> </div> </div>
diff --git a/chrome/browser/resources/signin/profile_picker/profile_creation_flow/profile_type_choice.html b/chrome/browser/resources/signin/profile_picker/profile_creation_flow/profile_type_choice.html index a4d182b..95d3814 100644 --- a/chrome/browser/resources/signin/profile_picker/profile_creation_flow/profile_type_choice.html +++ b/chrome/browser/resources/signin/profile_picker/profile_creation_flow/profile_type_choice.html
@@ -114,6 +114,7 @@ --theme-text-color:[[profileThemeInfo.themeFrameTextColor]];"> <cr-icon-button id="backButton" iron-icon="cr:arrow-back" on-click="onBackClick_" aria-label$="[[getBackButtonAriaLabel_()]]" + title$="[[getBackButtonAriaLabel_()]]" disabled="[[profileCreationInProgress]]"> </cr-icon-button> <div id="avatarContainer">
diff --git a/chrome/browser/signin/chrome_signin_helper.cc b/chrome/browser/signin/chrome_signin_helper.cc index 83b5c8d..9707396 100644 --- a/chrome/browser/signin/chrome_signin_helper.cc +++ b/chrome/browser/signin/chrome_signin_helper.cc
@@ -25,6 +25,7 @@ #include "chrome/browser/signin/signin_ui_util.h" #include "chrome/browser/ui/webui/signin/signin_url_utils.h" #include "components/account_manager_core/account_manager_facade.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/signin/core/browser/account_reconcilor.h" #include "components/signin/public/base/account_consistency_method.h" #include "components/signin/public/base/consent_level.h" @@ -610,7 +611,7 @@ // Google Drive. int profile_mode_mask = PROFILE_MODE_DEFAULT; if (incognito_availibility == - static_cast<int>(IncognitoModePrefs::Availability::kDisabled) || + static_cast<int>(policy::IncognitoModeAvailability::kDisabled) || IncognitoModePrefs::ArePlatformParentalControlsEnabled()) { profile_mode_mask |= PROFILE_MODE_INCOGNITO_DISABLED; }
diff --git a/chrome/browser/signin/chromeos_mirror_account_consistency_browsertest.cc b/chrome/browser/signin/chromeos_mirror_account_consistency_browsertest.cc index 1431e09d..2f96ce9 100644 --- a/chrome/browser/signin/chromeos_mirror_account_consistency_browsertest.cc +++ b/chrome/browser/signin/chromeos_mirror_account_consistency_browsertest.cc
@@ -140,7 +140,7 @@ PrefService* prefs = profile->GetPrefs(); prefs->SetInteger( policy::policy_prefs::kIncognitoModeAvailability, - static_cast<int>(IncognitoModePrefs::Availability::kDisabled)); + static_cast<int>(policy::IncognitoModeAvailability::kDisabled)); ASSERT_EQ(1, signin::PROFILE_MODE_INCOGNITO_DISABLED); // TODO(http://crbug.com/1134144): This test seems to test supervised profiles
diff --git a/chrome/browser/signin/header_modification_delegate_impl.cc b/chrome/browser/signin/header_modification_delegate_impl.cc index e68d4a4e..637c702 100644 --- a/chrome/browser/signin/header_modification_delegate_impl.cc +++ b/chrome/browser/signin/header_modification_delegate_impl.cc
@@ -100,7 +100,7 @@ incognito_mode_availability = incognito_enabled_ ? incognito_mode_availability - : static_cast<int>(IncognitoModePrefs::Availability::kDisabled); + : static_cast<int>(policy::IncognitoModeAvailability::kDisabled); #endif FixAccountConsistencyRequestHeader(
diff --git a/chrome/browser/supervised_user/android/web_content_handler_impl.cc b/chrome/browser/supervised_user/android/web_content_handler_impl.cc index dad501ec..a0bc607 100644 --- a/chrome/browser/supervised_user/android/web_content_handler_impl.cc +++ b/chrome/browser/supervised_user/android/web_content_handler_impl.cc
@@ -34,7 +34,7 @@ WebContentHandlerImpl::WebContentHandlerImpl(content::WebContents* web_contents) : supervised_user::WebContentHandler(), web_contents_(web_contents) { - // TODO(b/4370063): Add Check on web_contents + CHECK(web_contents_); } WebContentHandlerImpl::~WebContentHandlerImpl() = default;
diff --git a/chrome/browser/supervised_user/android/web_content_handler_impl_unittest.cc b/chrome/browser/supervised_user/android/web_content_handler_impl_unittest.cc index ebe5ad4..4bbbd5cb 100644 --- a/chrome/browser/supervised_user/android/web_content_handler_impl_unittest.cc +++ b/chrome/browser/supervised_user/android/web_content_handler_impl_unittest.cc
@@ -9,8 +9,11 @@ #include "base/test/metrics/histogram_tester.h" #include "base/time/time.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/supervised_user/android/website_parent_approval.h" +#include "chrome/test/base/testing_profile.h" #include "components/supervised_user/core/browser/supervised_user_settings_service.h" +#include "content/public/browser/web_contents_user_data.h" #include "content/public/test/browser_task_environment.h" #include "content/public/test/test_utils.h" #include "testing/gmock/include/gmock/gmock.h" @@ -41,10 +44,12 @@ content::BrowserTaskEnvironment& task_environment() { return task_environment_; } + TestingProfile* GetProfilePtr() { return &profile_; } private: content::BrowserTaskEnvironment task_environment_{ base::test::TaskEnvironment::TimeSource::MOCK_TIME}; + TestingProfile profile_; }; TEST_F(WebContentHandlerImplTest, @@ -60,7 +65,12 @@ // Check that duration metric is recorded. base::TimeDelta elapsed_time = base::Minutes(1); task_environment().FastForwardBy(elapsed_time); - WebContentHandlerImpl web_content_handler(/*web_contents=*/nullptr); + + std::unique_ptr<content::WebContents> web_contents = + content::WebContents::Create( + content::WebContents::CreateParams(GetProfilePtr())); + WebContentHandlerImpl web_content_handler = + WebContentHandlerImpl(web_contents.get()); web_content_handler.OnLocalApprovalRequestCompleted( supervisedUserSettingsServiceMock, url, start_time, @@ -90,7 +100,11 @@ base::TimeDelta elapsed_time = base::Minutes(5); task_environment().FastForwardBy(elapsed_time); - WebContentHandlerImpl web_content_handler(/*web_contents=*/nullptr); + std::unique_ptr<content::WebContents> web_contents = + content::WebContents::Create( + content::WebContents::CreateParams(GetProfilePtr())); + WebContentHandlerImpl web_content_handler = + WebContentHandlerImpl(web_contents.get()); // Receive a request canceled by the parent. // Check that no duration metric is recorded for incomplete requests. @@ -118,7 +132,11 @@ base::TimeDelta elapsed_time = base::Minutes(5); task_environment().FastForwardBy(elapsed_time); - WebContentHandlerImpl web_content_handler(/*web_contents=*/nullptr); + std::unique_ptr<content::WebContents> web_contents = + content::WebContents::Create( + content::WebContents::CreateParams(GetProfilePtr())); + WebContentHandlerImpl web_content_handler = + WebContentHandlerImpl(web_contents.get()); // Receive a request accepted by the parent with a total duration of 5 // minutes. Check that duration metric is recorded.
diff --git a/chrome/browser/supervised_user/chromeos/web_content_handler_impl.cc b/chrome/browser/supervised_user/chromeos/web_content_handler_impl.cc index 7501728e..3501cc14 100644 --- a/chrome/browser/supervised_user/chromeos/web_content_handler_impl.cc +++ b/chrome/browser/supervised_user/chromeos/web_content_handler_impl.cc
@@ -70,7 +70,7 @@ favicon_handler_(std::make_unique<SupervisedUserFaviconRequestHandler>( url.GetWithEmptyPath(), &large_icon_service)) { - // TODO(b/4370063): Add Check on web_contents + CHECK(web_contents_); if (supervised_user::IsLocalWebApprovalsEnabled()) { // Prefetch the favicon which will be rendered as part of the web approvals // ParentAccessDialog. Pass in DoNothing() for the favicon fetched callback
diff --git a/chrome/browser/supervised_user/chromeos/web_content_handler_impl_unittest.cc b/chrome/browser/supervised_user/chromeos/web_content_handler_impl_unittest.cc index 1d8e1015..b345188 100644 --- a/chrome/browser/supervised_user/chromeos/web_content_handler_impl_unittest.cc +++ b/chrome/browser/supervised_user/chromeos/web_content_handler_impl_unittest.cc
@@ -9,10 +9,13 @@ #include "base/test/metrics/histogram_tester.h" #include "base/time/time.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/supervised_user/chromeos/mock_large_icon_service.h" #include "chrome/browser/supervised_user/chromeos/supervised_user_favicon_request_handler.h" +#include "chrome/test/base/testing_profile.h" #include "chromeos/crosapi/mojom/parent_access.mojom.h" #include "components/supervised_user/core/browser/supervised_user_settings_service.h" +#include "content/public/browser/web_contents_user_data.h" #include "content/public/test/browser_task_environment.h" #include "content/public/test/test_utils.h" #include "testing/gmock/include/gmock/gmock.h" @@ -45,11 +48,12 @@ } MockLargeIconService& large_icon_service() { return large_icon_service_; } + TestingProfile* GetProfilePtr() { return &profile_; } private: content::BrowserTaskEnvironment task_environment_{ base::test::TaskEnvironment::TimeSource::MOCK_TIME}; - + TestingProfile profile_; MockLargeIconService large_icon_service_; }; @@ -72,7 +76,10 @@ const base::TimeDelta approval_duration = base::Seconds(35); task_environment().FastForwardBy(approval_duration); - WebContentHandlerImpl web_content_handler(/*web_contents=*/nullptr, url, + std::unique_ptr<content::WebContents> web_contents = + content::WebContents::Create( + content::WebContents::CreateParams(GetProfilePtr())); + WebContentHandlerImpl web_content_handler(web_contents.get(), url, large_icon_service()); web_content_handler.OnLocalApprovalRequestCompleted( @@ -110,7 +117,10 @@ const base::TimeDelta approval_duration = base::Seconds(35); task_environment().FastForwardBy(approval_duration); - WebContentHandlerImpl web_content_handler(/*web_contents=*/nullptr, url, + std::unique_ptr<content::WebContents> web_contents = + content::WebContents::Create( + content::WebContents::CreateParams(GetProfilePtr())); + WebContentHandlerImpl web_content_handler(web_contents.get(), url, large_icon_service()); web_content_handler.OnLocalApprovalRequestCompleted( @@ -148,7 +158,10 @@ const base::TimeDelta approval_duration = base::Seconds(35); task_environment().FastForwardBy(approval_duration); - WebContentHandlerImpl web_content_handler(/*web_contents=*/nullptr, url, + std::unique_ptr<content::WebContents> web_contents = + content::WebContents::Create( + content::WebContents::CreateParams(GetProfilePtr())); + WebContentHandlerImpl web_content_handler(web_contents.get(), url, large_icon_service()); web_content_handler.OnLocalApprovalRequestCompleted( @@ -184,7 +197,10 @@ const base::TimeDelta approval_duration = base::Seconds(35); task_environment().FastForwardBy(approval_duration); - WebContentHandlerImpl web_content_handler(/*web_contents=*/nullptr, url, + std::unique_ptr<content::WebContents> web_contents = + content::WebContents::Create( + content::WebContents::CreateParams(GetProfilePtr())); + WebContentHandlerImpl web_content_handler(web_contents.get(), url, large_icon_service()); web_content_handler.OnLocalApprovalRequestCompleted(
diff --git a/chrome/browser/supervised_user/supervised_user_pref_store.cc b/chrome/browser/supervised_user/supervised_user_pref_store.cc index ba1a56a..ed6c464 100644 --- a/chrome/browser/supervised_user/supervised_user_pref_store.cc +++ b/chrome/browser/supervised_user/supervised_user_pref_store.cc
@@ -152,7 +152,7 @@ // restrictions are applied for Unicorn accounts. prefs_->SetInteger( policy::policy_prefs::kIncognitoModeAvailability, - static_cast<int>(IncognitoModePrefs::Availability::kDisabled)); + static_cast<int>(policy::IncognitoModeAvailability::kDisabled)); } {
diff --git a/chrome/browser/supervised_user/supervised_user_pref_store_unittest.cc b/chrome/browser/supervised_user/supervised_user_pref_store_unittest.cc index a1937b0c..e2a31e6 100644 --- a/chrome/browser/supervised_user/supervised_user_pref_store_unittest.cc +++ b/chrome/browser/supervised_user/supervised_user_pref_store_unittest.cc
@@ -147,7 +147,7 @@ EXPECT_THAT( fixture.changed_prefs()->FindIntByDottedPath( policy::policy_prefs::kIncognitoModeAvailability), - Optional(static_cast<int>(IncognitoModePrefs::Availability::kDisabled))); + Optional(static_cast<int>(policy::IncognitoModeAvailability::kDisabled))); // kSupervisedModeManualHosts does not have a hardcoded value. EXPECT_FALSE(fixture.changed_prefs()->FindDictByDottedPath(
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index b35a81f..d985a34 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -1697,6 +1697,7 @@ "webui/side_panel/companion/companion_url_builder.cc", "webui/side_panel/companion/companion_url_builder.h", "webui/side_panel/companion/constants.h", + "webui/side_panel/companion/msbb_delegate.h", "webui/side_panel/companion/promo_handler.cc", "webui/side_panel/companion/promo_handler.h", "webui/side_panel/customize_chrome/customize_chrome_colors.cc", @@ -2223,6 +2224,8 @@ "../ash/app_list/search/system_info/battery_answer_result.cc", "../ash/app_list/search/system_info/battery_answer_result.h", "../ash/app_list/search/system_info/battery_health.h", + "../ash/app_list/search/system_info/cpu_answer_result.cc", + "../ash/app_list/search/system_info/cpu_answer_result.h", "../ash/app_list/search/system_info/cpu_data.h", "../ash/app_list/search/system_info/cpu_usage_data.cc", "../ash/app_list/search/system_info/cpu_usage_data.h",
diff --git a/chrome/browser/ui/ash/chrome_new_window_client_browsertest.cc b/chrome/browser/ui/ash/chrome_new_window_client_browsertest.cc index 94ef5be92..3e15aad3 100644 --- a/chrome/browser/ui/ash/chrome_new_window_client_browsertest.cc +++ b/chrome/browser/ui/ash/chrome_new_window_client_browsertest.cc
@@ -19,6 +19,7 @@ #include "chrome/common/webui_url_constants.h" #include "chrome/test/base/in_process_browser_test.h" #include "components/account_id/account_id.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/session_manager/core/session_manager.h" #include "components/user_manager/fake_user_manager.h" #include "components/user_manager/known_user.h" @@ -122,14 +123,14 @@ // Disabling incognito mode disables creation of new incognito windows. IncognitoModePrefs::SetAvailability( - profile->GetPrefs(), IncognitoModePrefs::Availability::kDisabled); + profile->GetPrefs(), policy::IncognitoModeAvailability::kDisabled); ChromeNewWindowClient::Get()->NewWindow( /*incognito=*/true, /*should_trigger_session_restore=*/true); EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); // Enabling incognito mode enables creation of new incognito windows. IncognitoModePrefs::SetAvailability( - profile->GetPrefs(), IncognitoModePrefs::Availability::kEnabled); + profile->GetPrefs(), policy::IncognitoModeAvailability::kEnabled); ChromeNewWindowClient::Get()->NewWindow( /*incognito=*/true, /*should_trigger_session_restore=*/true); EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
diff --git a/chrome/browser/ui/ash/network/network_portal_signin_controller.cc b/chrome/browser/ui/ash/network/network_portal_signin_controller.cc index 4040c47b..3163d57 100644 --- a/chrome/browser/ui/ash/network/network_portal_signin_controller.cc +++ b/chrome/browser/ui/ash/network/network_portal_signin_controller.cc
@@ -144,19 +144,19 @@ return SigninMode::kNormalTab; } - IncognitoModePrefs::Availability availability; + policy::IncognitoModeAvailability availability; IncognitoModePrefs::IntToAvailability( profile->GetPrefs()->GetInteger( policy::policy_prefs::kIncognitoModeAvailability), &availability); - if (availability == IncognitoModePrefs::Availability::kDisabled) { + if (availability == policy::IncognitoModeAvailability::kDisabled) { // Use a dialog to prevent navigation and use an OTR profile due to // Incognito browsing disabled by policy preference. return SigninMode::kIncognitoDialogDisabled; } if (IncognitoModePrefs::GetAvailability(profile->GetPrefs()) == - IncognitoModePrefs::Availability::kDisabled) { + policy::IncognitoModeAvailability::kDisabled) { // Use a dialog to prevent navigation and use an OTR profile due to // Incognito browsing disabled by parental controls. return SigninMode::kIncognitoDialogParental;
diff --git a/chrome/browser/ui/ash/network/network_portal_signin_controller_unittest.cc b/chrome/browser/ui/ash/network/network_portal_signin_controller_unittest.cc index e11cc04..9246510 100644 --- a/chrome/browser/ui/ash/network/network_portal_signin_controller_unittest.cc +++ b/chrome/browser/ui/ash/network/network_portal_signin_controller_unittest.cc
@@ -22,6 +22,7 @@ #include "chromeos/ash/components/network/network_state_handler.h" #include "chromeos/ash/components/network/proxy/proxy_config_handler.h" #include "components/captive_portal/core/captive_portal_detector.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/prefs/pref_service.h" #include "components/proxy_config/proxy_config_dictionary.h" #include "components/proxy_config/proxy_config_pref_names.h" @@ -264,7 +265,7 @@ std::string expected_url = SetProbeUrl(kTestPortalUrl); SetNetworkProxy(); IncognitoModePrefs::SetAvailability( - GetPrefs(), IncognitoModePrefs::Availability::kDisabled); + GetPrefs(), policy::IncognitoModeAvailability::kDisabled); ShowSignin(); EXPECT_EQ(controller_->dialog_url(), expected_url); }
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 ec8185c..3c5b06b 100644 --- a/chrome/browser/ui/ash/projector/projector_app_client_impl.cc +++ b/chrome/browser/ui/ash/projector/projector_app_client_impl.cc
@@ -9,8 +9,8 @@ #include "ash/constants/ash_features.h" #include "ash/constants/ash_pref_names.h" #include "ash/public/cpp/projector/annotator_tool.h" +#include "ash/webui/projector_app/annotator_page_handler_impl.h" #include "ash/webui/projector_app/public/cpp/projector_app_constants.h" -#include "ash/webui/projector_app/untrusted_annotator_page_handler_impl.h" #include "base/functional/bind.h" #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/browser_process.h" @@ -156,12 +156,12 @@ } void ProjectorAppClientImpl::SetAnnotatorPageHandler( - ash::UntrustedAnnotatorPageHandlerImpl* handler) { + ash::AnnotatorPageHandlerImpl* handler) { annotator_handler_ = handler; } void ProjectorAppClientImpl::ResetAnnotatorPageHandler( - ash::UntrustedAnnotatorPageHandlerImpl* handler) { + ash::AnnotatorPageHandlerImpl* handler) { if (annotator_handler_ == handler) { annotator_handler_ = nullptr; }
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 cfba1d4a..a25a270 100644 --- a/chrome/browser/ui/ash/projector/projector_app_client_impl.h +++ b/chrome/browser/ui/ash/projector/projector_app_client_impl.h
@@ -8,8 +8,8 @@ #include <memory> #include "ash/public/cpp/projector/projector_annotator_controller.h" +#include "ash/webui/projector_app/annotator_page_handler_impl.h" #include "ash/webui/projector_app/projector_app_client.h" -#include "ash/webui/projector_app/untrusted_annotator_page_handler_impl.h" #include "base/observer_list.h" #include "chrome/browser/ui/ash/projector/pending_screencast_manager.h" #include "chrome/browser/ui/ash/projector/screencast_manager.h" @@ -52,10 +52,9 @@ const std::string& video_file_id, const std::string& resource_key, ash::ProjectorAppClient::OnGetVideoCallback callback) const override; - void SetAnnotatorPageHandler( - ash::UntrustedAnnotatorPageHandlerImpl* handler) override; + void SetAnnotatorPageHandler(ash::AnnotatorPageHandlerImpl* handler) override; void ResetAnnotatorPageHandler( - ash::UntrustedAnnotatorPageHandlerImpl* handler) override; + ash::AnnotatorPageHandlerImpl* handler) override; void SetTool(const ash::AnnotatorTool& tool) override; void Clear() override; void NotifyAppUIActive(bool active) override; @@ -63,7 +62,7 @@ const std::vector<base::FilePath>& screencast_paths, bool suppress) override; - ash::UntrustedAnnotatorPageHandlerImpl* get_annotator_handler_for_test() { + ash::AnnotatorPageHandlerImpl* get_annotator_handler_for_test() { return annotator_handler_; } PendingScreencastManager* get_pending_screencast_manager_for_test() { @@ -81,7 +80,7 @@ ash::ScreencastManager screencast_manager_; - ash::UntrustedAnnotatorPageHandlerImpl* annotator_handler_ = nullptr; + ash::AnnotatorPageHandlerImpl* annotator_handler_ = nullptr; }; #endif // CHROME_BROWSER_UI_ASH_PROJECTOR_PROJECTOR_APP_CLIENT_IMPL_H_
diff --git a/chrome/browser/ui/ash/projector/projector_client_impl.cc b/chrome/browser/ui/ash/projector/projector_client_impl.cc index 57c6184..7bd0e908 100644 --- a/chrome/browser/ui/ash/projector/projector_client_impl.cc +++ b/chrome/browser/ui/ash/projector/projector_client_impl.cc
@@ -103,7 +103,7 @@ // static void ProjectorClientImpl::InitForProjectorAnnotator(views::WebView* web_view) { - web_view->LoadInitialURL(GURL(ash::kChromeUIUntrustedAnnotatorUrl)); + web_view->LoadInitialURL(GURL(ash::kChromeUITrustedAnnotatorUrl)); } // Using base::Unretained for callback is safe since the ProjectorClientImpl
diff --git a/chrome/browser/ui/ash/projector/projector_client_impl_browsertest.cc b/chrome/browser/ui/ash/projector/projector_client_impl_browsertest.cc index 9d90f10..dcfe2e4 100644 --- a/chrome/browser/ui/ash/projector/projector_client_impl_browsertest.cc +++ b/chrome/browser/ui/ash/projector/projector_client_impl_browsertest.cc
@@ -181,6 +181,7 @@ IN_PROC_BROWSER_TEST_F(ProjectorClientTest, AppUrlsValid) { VerifyUrlValid(kChromeUITrustedProjectorUrl); VerifyUrlValid(kChromeUIUntrustedProjectorUrl); + VerifyUrlValid(kChromeUITrustedAnnotatorUrl); VerifyUrlValid(kChromeUIUntrustedAnnotatorUrl); }
diff --git a/chrome/browser/ui/ash/projector/projector_navigation_throttle_browsertest.cc b/chrome/browser/ui/ash/projector/projector_navigation_throttle_browsertest.cc index bb82bc3..9d2e396c 100644 --- a/chrome/browser/ui/ash/projector/projector_navigation_throttle_browsertest.cc +++ b/chrome/browser/ui/ash/projector/projector_navigation_throttle_browsertest.cc
@@ -390,6 +390,21 @@ EXPECT_EQ(tab->GetVisibleURL(), untrusted_annotator_url); } +// Verifies that chrome://projector-annotator is not accessible when the app is +// disabled. +IN_PROC_BROWSER_TEST_F(ProjectorNavigationThrottleDisabledTest, + TrustedAnnotatorNavigationInvalidUrl) { + GURL trusted_annotator_url(kChromeUITrustedAnnotatorUrl); + + ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), trusted_annotator_url)); + content::WebContents* tab = + browser()->tab_strip_model()->GetActiveWebContents(); + ASSERT_TRUE(tab); + EXPECT_EQ(tab->GetController().GetVisibleEntry()->GetPageType(), + content::PAGE_TYPE_ERROR); + EXPECT_EQ(tab->GetVisibleURL(), trusted_annotator_url); +} + class ProjectorNavigationThrottleLocaleTest : public ProjectorNavigationThrottleTest, public testing::WithParamInterface<std::string> {
diff --git a/chrome/browser/ui/ash/shelf/extension_shelf_context_menu.cc b/chrome/browser/ui/ash/shelf/extension_shelf_context_menu.cc index 3f0ce5dc..68e55a0e 100644 --- a/chrome/browser/ui/ash/shelf/extension_shelf_context_menu.cc +++ b/chrome/browser/ui/ash/shelf/extension_shelf_context_menu.cc
@@ -21,6 +21,7 @@ #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" #include "components/app_constants/constants.h" +#include "components/policy/core/common/policy_pref_names.h" #include "content/public/browser/context_menu_params.h" #include "extensions/browser/extension_prefs.h" #include "ui/base/l10n/l10n_util.h" @@ -153,12 +154,12 @@ // "Normal" windows are not allowed when incognito is enforced. return IncognitoModePrefs::GetAvailability( controller()->profile()->GetPrefs()) != - IncognitoModePrefs::Availability::kForced; + policy::IncognitoModeAvailability::kForced; case ash::APP_CONTEXT_MENU_NEW_INCOGNITO_WINDOW: // Incognito windows are not allowed when incognito is disabled. return IncognitoModePrefs::GetAvailability( controller()->profile()->GetPrefs()) != - IncognitoModePrefs::Availability::kDisabled; + policy::IncognitoModeAvailability::kDisabled; default: if (command_id < ash::COMMAND_ID_COUNT) return ShelfContextMenu::IsCommandIdEnabled(command_id);
diff --git a/chrome/browser/ui/ash/shelf/shelf_context_menu_unittest.cc b/chrome/browser/ui/ash/shelf/shelf_context_menu_unittest.cc index e501791..61a1b0a 100644 --- a/chrome/browser/ui/ash/shelf/shelf_context_menu_unittest.cc +++ b/chrome/browser/ui/ash/shelf/shelf_context_menu_unittest.cc
@@ -55,6 +55,7 @@ #include "chromeos/ash/components/dbus/concierge/concierge_client.h" #include "chromeos/ash/components/dbus/seneschal/seneschal_client.h" #include "components/exo/shell_surface_util.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/prefs/pref_service.h" #include "components/viz/test/test_gpu_service_holder.h" #include "ui/aura/window_event_dispatcher.h" @@ -271,7 +272,7 @@ // Disable Incognito mode. IncognitoModePrefs::SetAvailability( - profile()->GetPrefs(), IncognitoModePrefs::Availability::kDisabled); + profile()->GetPrefs(), policy::IncognitoModeAvailability::kDisabled); shelf_context_menu = CreateShelfContextMenu(ash::TYPE_BROWSER_SHORTCUT, display_id); menu = GetMenuModel(shelf_context_menu.get()); @@ -297,7 +298,7 @@ // Disable Incognito mode. IncognitoModePrefs::SetAvailability( - profile()->GetPrefs(), IncognitoModePrefs::Availability::kForced); + profile()->GetPrefs(), policy::IncognitoModeAvailability::kForced); shelf_context_menu = CreateShelfContextMenu(ash::TYPE_BROWSER_SHORTCUT, display_id); menu = GetMenuModel(shelf_context_menu.get());
diff --git a/chrome/browser/ui/ash/system_web_apps/system_web_app_ui_utils.h b/chrome/browser/ui/ash/system_web_apps/system_web_app_ui_utils.h index d2bbb6d..d34fb8e 100644 --- a/chrome/browser/ui/ash/system_web_apps/system_web_app_ui_utils.h +++ b/chrome/browser/ui/ash/system_web_apps/system_web_app_ui_utils.h
@@ -41,16 +41,18 @@ ~SystemAppLaunchParams(); // If provided launches System Apps into |url|, instead of its start_url (as - // specified its WebAppInstallInfo). Mutually exclusive with non-empty - // |launch_paths|. + // specified its WebAppInstallInfo). + // + // This is mutually exclusive with non-empty |launch_paths|. absl::optional<GURL> url; // Where the app is launched from. apps::LaunchSource launch_source = apps::LaunchSource::kFromChromeInternal; - // If non-empty, specifies files passed to Web File Handling. Apps need to - // have "FileHandling" origin trial in its SystemAppInfo, and file handlers - // in its WebAppInstallInfo. Mutually exclusive with |url|. + // If non-empty, specifies files passed to Web File Handling. The app needs to + // specify file handlers in its WebAppInstallInfo. + // + // This is mutually exclusive with |url|. std::vector<base::FilePath> launch_paths; };
diff --git a/chrome/browser/ui/bookmarks/bookmark_context_menu_controller.cc b/chrome/browser/ui/bookmarks/bookmark_context_menu_controller.cc index 28ca87e9..f670932 100644 --- a/chrome/browser/ui/bookmarks/bookmark_context_menu_controller.cc +++ b/chrome/browser/ui/bookmarks/bookmark_context_menu_controller.cc
@@ -36,6 +36,7 @@ #include "components/bookmarks/common/bookmark_metrics.h" #include "components/bookmarks/common/bookmark_pref_names.h" #include "components/bookmarks/managed/managed_bookmark_service.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/prefs/pref_service.h" #include "components/strings/grit/components_strings.h" #include "components/tab_groups/tab_group_visual_data.h" @@ -464,25 +465,25 @@ selection_[0]->parent() == model_->root_node(); bool can_edit = prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled) && bookmarks::CanAllBeEditedByUser(model_->client(), selection_); - IncognitoModePrefs::Availability incognito_avail = + policy::IncognitoModeAvailability incognito_avail = IncognitoModePrefs::GetAvailability(prefs); switch (command_id) { case IDC_BOOKMARK_BAR_OPEN_INCOGNITO: return !profile_->IsOffTheRecord() && - incognito_avail != IncognitoModePrefs::Availability::kDisabled; + incognito_avail != policy::IncognitoModeAvailability::kDisabled; case IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO: return chrome::HasBookmarkURLsAllowedInIncognitoMode(selection_, profile_) && !profile_->IsOffTheRecord() && - incognito_avail != IncognitoModePrefs::Availability::kDisabled; + incognito_avail != policy::IncognitoModeAvailability::kDisabled; case IDC_BOOKMARK_BAR_OPEN_ALL: case IDC_BOOKMARK_BAR_OPEN_ALL_NEW_TAB_GROUP: return chrome::HasBookmarkURLs(selection_); case IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW: return chrome::HasBookmarkURLs(selection_) && - incognito_avail != IncognitoModePrefs::Availability::kForced; + incognito_avail != policy::IncognitoModeAvailability::kForced; case IDC_BOOKMARK_BAR_RENAME_FOLDER: case IDC_BOOKMARK_BAR_EDIT:
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc index 6790142a..c63da86 100644 --- a/chrome/browser/ui/browser_browsertest.cc +++ b/chrome/browser/ui/browser_browsertest.cc
@@ -92,6 +92,7 @@ #include "components/javascript_dialogs/app_modal_dialog_view.h" #include "components/javascript_dialogs/tab_modal_dialog_manager.h" #include "components/omnibox/common/omnibox_focus_state.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/prefs/pref_service.h" #include "components/services/app_service/public/cpp/app_launch_util.h" #include "components/sessions/core/command_storage_manager_test_helper.h" @@ -1579,7 +1580,7 @@ // Set Incognito to FORCED. IncognitoModePrefs::SetAvailability( browser()->profile()->GetPrefs(), - IncognitoModePrefs::Availability::kForced); + policy::IncognitoModeAvailability::kForced); // Bookmarks & Settings commands should get disabled. EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_NEW_WINDOW)); EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER)); @@ -1635,7 +1636,7 @@ // Set Incognito to DISABLED. IncognitoModePrefs::SetAvailability( browser()->profile()->GetPrefs(), - IncognitoModePrefs::Availability::kDisabled); + policy::IncognitoModeAvailability::kDisabled); // Make sure New Incognito Window command is disabled. All remaining commands // should be enabled. EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_NEW_INCOGNITO_WINDOW)); @@ -1684,7 +1685,7 @@ // Set Incognito to DISABLED. IncognitoModePrefs::SetAvailability( browser()->profile()->GetPrefs(), - IncognitoModePrefs::Availability::kDisabled); + policy::IncognitoModeAvailability::kDisabled); // Make sure Manage Extensions command is disabled. EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_MANAGE_EXTENSIONS)); EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_NEW_WINDOW)); @@ -1719,14 +1720,14 @@ // Set Incognito to FORCED. IncognitoModePrefs::SetAvailability( popup_browser->profile()->GetPrefs(), - IncognitoModePrefs::Availability::kForced); + policy::IncognitoModeAvailability::kForced); // OPTIONS and IMPORT_SETTINGS are disabled when Incognito is forced. EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); // Set Incognito to AVAILABLE. IncognitoModePrefs::SetAvailability( popup_browser->profile()->GetPrefs(), - IncognitoModePrefs::Availability::kEnabled); + policy::IncognitoModeAvailability::kEnabled); // OPTIONS and IMPORT_SETTINGS are still disabled since it is a non-normal UI. EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS));
diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc index dc085f1..86189a9 100644 --- a/chrome/browser/ui/browser_command_controller.cc +++ b/chrome/browser/ui/browser_command_controller.cc
@@ -1272,18 +1272,18 @@ void BrowserCommandController::UpdateSharedCommandsForIncognitoAvailability( CommandUpdater* command_updater, Profile* profile) { - IncognitoModePrefs::Availability incognito_availability = + policy::IncognitoModeAvailability incognito_availability = IncognitoModePrefs::GetAvailability(profile->GetPrefs()); command_updater->UpdateCommandEnabled( IDC_NEW_WINDOW, - incognito_availability != IncognitoModePrefs::Availability::kForced); + incognito_availability != policy::IncognitoModeAvailability::kForced); command_updater->UpdateCommandEnabled( IDC_NEW_INCOGNITO_WINDOW, - incognito_availability != IncognitoModePrefs::Availability::kDisabled && + incognito_availability != policy::IncognitoModeAvailability::kDisabled && !profile->IsGuestSession()); const bool forced_incognito = - incognito_availability == IncognitoModePrefs::Availability::kForced; + incognito_availability == policy::IncognitoModeAvailability::kForced; const bool is_guest = profile->IsGuestSession(); command_updater->UpdateCommandEnabled(
diff --git a/chrome/browser/ui/browser_command_controller_unittest.cc b/chrome/browser/ui/browser_command_controller_unittest.cc index 73c178c..46aafa14 100644 --- a/chrome/browser/ui/browser_command_controller_unittest.cc +++ b/chrome/browser/ui/browser_command_controller_unittest.cc
@@ -29,6 +29,7 @@ #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile_manager.h" #include "components/performance_manager/public/features.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/signin/public/base/signin_pref_names.h" #include "content/public/browser/native_web_keyboard_event.h" #include "ui/events/keycodes/dom/dom_code.h" @@ -187,7 +188,7 @@ testprofile->SetGuestSession(false); IncognitoModePrefs::SetAvailability( browser()->profile()->GetPrefs(), - IncognitoModePrefs::Availability::kForced); + policy::IncognitoModeAvailability::kForced); chrome::BrowserCommandController :: UpdateSharedCommandsForIncognitoAvailability( browser()->command_controller(), testprofile); @@ -483,7 +484,7 @@ // Setup forced incognito mode. IncognitoModePrefs::SetAvailability( browser()->profile()->GetPrefs(), - IncognitoModePrefs::Availability::kForced); + policy::IncognitoModeAvailability::kForced); EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); // Enter fullscreen. browser()->command_controller()->FullscreenStateChanged(); @@ -495,10 +496,10 @@ // UpdateSharedCommandsForIncognitoAvailability() again. IncognitoModePrefs::SetAvailability( browser()->profile()->GetPrefs(), - IncognitoModePrefs::Availability::kDisabled); + policy::IncognitoModeAvailability::kDisabled); IncognitoModePrefs::SetAvailability( browser()->profile()->GetPrefs(), - IncognitoModePrefs::Availability::kForced); + policy::IncognitoModeAvailability::kForced); EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); }
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc index c81630f..e76fe5f 100644 --- a/chrome/browser/ui/browser_commands.cc +++ b/chrome/browser/ui/browser_commands.cc
@@ -119,6 +119,7 @@ #include "components/media_router/browser/media_router_dialog_controller.h" // nogncheck #include "components/media_router/browser/media_router_metrics.h" #include "components/omnibox/browser/omnibox_prefs.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/prefs/pref_service.h" #include "components/reading_list/core/reading_list_entry.h" #include "components/reading_list/core/reading_list_model.h" @@ -492,7 +493,7 @@ PrefService* prefs = profile->GetPrefs(); if (off_the_record) { if (IncognitoModePrefs::GetAvailability(prefs) == - IncognitoModePrefs::Availability::kDisabled) { + policy::IncognitoModeAvailability::kDisabled) { off_the_record = false; } } else if (profile->IsGuestSession() ||
diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc index c4a4bb8..9ee8a99f 100644 --- a/chrome/browser/ui/browser_navigator.cc +++ b/chrome/browser/ui/browser_navigator.cc
@@ -45,6 +45,7 @@ #include "components/captive_portal/core/buildflags.h" #include "components/no_state_prefetch/browser/no_state_prefetch_manager.h" #include "components/password_manager/content/common/web_ui_constants.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/prefs/pref_service.h" #include "content/public/browser/browser_url_handler.h" #include "content/public/browser/navigation_entry.h" @@ -153,7 +154,7 @@ // If incognito is forced, we punt. PrefService* prefs = profile->GetPrefs(); if (prefs && IncognitoModePrefs::GetAvailability(prefs) == - IncognitoModePrefs::Availability::kForced) { + policy::IncognitoModeAvailability::kForced) { return false; }
diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc index f7754bf8..7ff296a 100644 --- a/chrome/browser/ui/browser_navigator_browsertest.cc +++ b/chrome/browser/ui/browser_navigator_browsertest.cc
@@ -206,11 +206,11 @@ PrefService* prefs1 = browser->profile()->GetPrefs(); prefs1->SetInteger( policy::policy_prefs::kIncognitoModeAvailability, - static_cast<int>(IncognitoModePrefs::Availability::kForced)); + static_cast<int>(policy::IncognitoModeAvailability::kForced)); PrefService* prefs2 = browser->profile()->GetOriginalProfile()->GetPrefs(); prefs2->SetInteger( policy::policy_prefs::kIncognitoModeAvailability, - static_cast<int>(IncognitoModePrefs::Availability::kForced)); + static_cast<int>(policy::IncognitoModeAvailability::kForced)); // Navigate to the page. NavigateParams params(MakeNavigateParams(browser));
diff --git a/chrome/browser/ui/browser_unittest.cc b/chrome/browser/ui/browser_unittest.cc index de96f4d..41fcf3c 100644 --- a/chrome/browser/ui/browser_unittest.cc +++ b/chrome/browser/ui/browser_unittest.cc
@@ -15,6 +15,7 @@ #include "chrome/test/base/browser_with_test_window_test.h" #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/zoom/zoom_controller.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/site_instance.h" @@ -205,7 +206,7 @@ // Tests BrowserCreate() when Incognito mode is disabled. TEST_F(BrowserUnitTest, CreateBrowserWithIncognitoModeDisabled) { IncognitoModePrefs::SetAvailability( - profile()->GetPrefs(), IncognitoModePrefs::Availability::kDisabled); + profile()->GetPrefs(), policy::IncognitoModeAvailability::kDisabled); // Creating a browser window in OTR profile should fail if incognito is // disabled. @@ -224,7 +225,7 @@ // Tests BrowserCreate() when Incognito mode is forced. TEST_F(BrowserUnitTest, CreateBrowserWithIncognitoModeForced) { IncognitoModePrefs::SetAvailability( - profile()->GetPrefs(), IncognitoModePrefs::Availability::kForced); + profile()->GetPrefs(), policy::IncognitoModeAvailability::kForced); // Creating a browser window in the original profile should fail if incognito // is forced. @@ -243,7 +244,7 @@ // Tests BrowserCreate() with not restrictions on incognito mode. TEST_F(BrowserUnitTest, CreateBrowserWithIncognitoModeEnabled) { - ASSERT_EQ(IncognitoModePrefs::Availability::kEnabled, + ASSERT_EQ(policy::IncognitoModeAvailability::kEnabled, IncognitoModePrefs::GetAvailability(profile()->GetPrefs())); // Creating a browser in the original test profile should succeed.
diff --git a/chrome/browser/ui/hats/hats_service.cc b/chrome/browser/ui/hats/hats_service.cc index 5478a1ae..38be2f2 100644 --- a/chrome/browser/ui/hats/hats_service.cc +++ b/chrome/browser/ui/hats/hats_service.cc
@@ -31,6 +31,7 @@ #include "components/performance_manager/public/features.h" #include "components/permissions/constants.h" #include "components/permissions/features.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/pref_registry/pref_registry_syncable.h" #include "components/prefs/scoped_user_pref_update.h" #include "components/version_info/version_info.h" @@ -750,7 +751,7 @@ return; } if (IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) == - IncognitoModePrefs::Availability::kDisabled) { + policy::IncognitoModeAvailability::kDisabled) { // Incognito mode needs to be enabled to create an off-the-record profile // for HaTS dialog. UMA_HISTOGRAM_ENUMERATION(kHatsShouldShowSurveyReasonHistogram,
diff --git a/chrome/browser/ui/hats/hats_service_browsertest.cc b/chrome/browser/ui/hats/hats_service_browsertest.cc index d4407bb..43e4404 100644 --- a/chrome/browser/ui/hats/hats_service_browsertest.cc +++ b/chrome/browser/ui/hats/hats_service_browsertest.cc
@@ -261,8 +261,8 @@ PrefService* pref_service = browser()->profile()->GetPrefs(); pref_service->SetInteger( policy::policy_prefs::kIncognitoModeAvailability, - static_cast<int>(IncognitoModePrefs::Availability::kDisabled)); - EXPECT_EQ(IncognitoModePrefs::Availability::kDisabled, + static_cast<int>(policy::IncognitoModeAvailability::kDisabled)); + EXPECT_EQ(policy::IncognitoModeAvailability::kDisabled, IncognitoModePrefs::GetAvailability(pref_service)); GetHatsService()->LaunchSurvey(kHatsSurveyTriggerSettings);
diff --git a/chrome/browser/ui/views/autofill/payments/local_card_migration_icon_view.cc b/chrome/browser/ui/views/autofill/payments/local_card_migration_icon_view.cc index d5d2167..bf2d0b0 100644 --- a/chrome/browser/ui/views/autofill/payments/local_card_migration_icon_view.cc +++ b/chrome/browser/ui/views/autofill/payments/local_card_migration_icon_view.cc
@@ -17,6 +17,7 @@ #include "components/strings/grit/components_strings.h" #include "components/vector_icons/vector_icons.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/views/animation/ink_drop.h" @@ -33,6 +34,9 @@ "LocalCardMigration") { SetID(VIEW_ID_MIGRATE_LOCAL_CREDIT_CARD_BUTTON); SetUpForInOutAnimation(); + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringUTF16(IDS_TOOLTIP_MIGRATE_LOCAL_CARD)); } LocalCardMigrationIconView::~LocalCardMigrationIconView() {} @@ -128,15 +132,6 @@ return gfx::kNoneIcon; } -const char* LocalCardMigrationIconView::GetClassName() const { - return "LocalCardMigrationIconView"; -} - -std::u16string LocalCardMigrationIconView::GetTextForTooltipAndAccessibleName() - const { - return l10n_util::GetStringUTF16(IDS_TOOLTIP_MIGRATE_LOCAL_CARD); -} - ManageMigrationUiController* LocalCardMigrationIconView::GetController() const { content::WebContents* web_contents = GetWebContents(); if (!web_contents) @@ -167,4 +162,7 @@ UpdateIconImage(); } +BEGIN_METADATA(LocalCardMigrationIconView, PageActionIconView) +END_METADATA + } // namespace autofill
diff --git a/chrome/browser/ui/views/autofill/payments/local_card_migration_icon_view.h b/chrome/browser/ui/views/autofill/payments/local_card_migration_icon_view.h index c3693d54..7b5f647 100644 --- a/chrome/browser/ui/views/autofill/payments/local_card_migration_icon_view.h +++ b/chrome/browser/ui/views/autofill/payments/local_card_migration_icon_view.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_PAYMENTS_LOCAL_CARD_MIGRATION_ICON_VIEW_H_ #include "chrome/browser/ui/views/page_action/page_action_icon_view.h" +#include "ui/base/metadata/metadata_header_macros.h" class CommandUpdater; @@ -17,6 +18,7 @@ // bubble. class LocalCardMigrationIconView : public PageActionIconView { public: + METADATA_HEADER(LocalCardMigrationIconView); LocalCardMigrationIconView( CommandUpdater* command_updater, IconLabelBubbleView::Delegate* icon_label_bubble_delegate, @@ -31,14 +33,12 @@ // PageActionIconView: views::BubbleDialogDelegate* GetBubble() const override; void UpdateImpl() override; - std::u16string GetTextForTooltipAndAccessibleName() const override; protected: // PageActionIconView: void OnExecuting(PageActionIconView::ExecuteSource execute_source) override; const gfx::VectorIcon& GetVectorIcon() const override; const gfx::VectorIcon& GetVectorIconBadge() const override; - const char* GetClassName() const override; private: ManageMigrationUiController* GetController() const;
diff --git a/chrome/browser/ui/views/autofill/payments/local_card_migration_uitest.cc b/chrome/browser/ui/views/autofill/payments/local_card_migration_uitest.cc index 70189ee..35de7b0 100644 --- a/chrome/browser/ui/views/autofill/payments/local_card_migration_uitest.cc +++ b/chrome/browser/ui/views/autofill/payments/local_card_migration_uitest.cc
@@ -46,6 +46,7 @@ #include "chrome/browser/ui/views/page_action/page_action_icon_view.h" #include "chrome/browser/ui/views/toolbar/toolbar_view.h" #include "chrome/browser/web_data_service_factory.h" +#include "chrome/grit/generated_resources.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "components/autofill/content/browser/content_autofill_client.h" @@ -85,6 +86,7 @@ #include "services/network/test/test_url_loader_factory.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/base/l10n/l10n_util.h" #include "ui/events/base_event_utils.h" #include "ui/views/bubble/bubble_frame_view.h" #include "ui/views/controls/button/button.h" @@ -1098,6 +1100,14 @@ first_card.NicknameAndLastFourDigitsForTesting()); } +IN_PROC_BROWSER_TEST_F(LocalCardMigrationBrowserTest, IconViewAccessibleName) { + EXPECT_EQ(GetLocalCardMigrationIconView()->GetAccessibleName(), + l10n_util::GetStringUTF16(IDS_TOOLTIP_MIGRATE_LOCAL_CARD)); + EXPECT_EQ( + GetLocalCardMigrationIconView()->GetTextForTooltipAndAccessibleName(), + l10n_util::GetStringUTF16(IDS_TOOLTIP_MIGRATE_LOCAL_CARD)); +} + IN_PROC_BROWSER_TEST_F(LocalCardMigrationBrowserUiTest, InvokeUi_default) { ShowAndVerifyUi(); }
diff --git a/chrome/browser/ui/views/autofill/payments/offer_notification_bubble_views_interactive_uitest.cc b/chrome/browser/ui/views/autofill/payments/offer_notification_bubble_views_interactive_uitest.cc index 33f171e..eded56a 100644 --- a/chrome/browser/ui/views/autofill/payments/offer_notification_bubble_views_interactive_uitest.cc +++ b/chrome/browser/ui/views/autofill/payments/offer_notification_bubble_views_interactive_uitest.cc
@@ -14,6 +14,7 @@ #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/views/autofill/payments/promo_code_label_button.h" #include "chrome/common/webui_url_constants.h" +#include "chrome/grit/generated_resources.h" #include "chrome/test/base/interactive_test_utils.h" #include "chrome/test/base/ui_test_utils.h" #include "components/autofill/core/browser/data_model/autofill_offer_data.h" @@ -626,4 +627,15 @@ "Autofill.PageLoadsWithOfferIconShowing.FreeListingCouponOffer", true, 2); } +IN_PROC_BROWSER_TEST_P(OfferNotificationBubbleViewsInteractiveUiTest, + IconViewAccessibleName) { + EXPECT_EQ(GetOfferNotificationIconView()->GetAccessibleName(), + l10n_util::GetStringUTF16( + IDS_AUTOFILL_OFFERS_REMINDER_ICON_TOOLTIP_TEXT)); + EXPECT_EQ( + GetOfferNotificationIconView()->GetTextForTooltipAndAccessibleName(), + l10n_util::GetStringUTF16( + IDS_AUTOFILL_OFFERS_REMINDER_ICON_TOOLTIP_TEXT)); +} + } // namespace autofill
diff --git a/chrome/browser/ui/views/autofill/payments/offer_notification_icon_view.cc b/chrome/browser/ui/views/autofill/payments/offer_notification_icon_view.cc index facdc6f..cc643ca 100644 --- a/chrome/browser/ui/views/autofill/payments/offer_notification_icon_view.cc +++ b/chrome/browser/ui/views/autofill/payments/offer_notification_icon_view.cc
@@ -15,6 +15,7 @@ #include "components/strings/grit/components_strings.h" #include "components/vector_icons/vector_icons.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" #include "ui/gfx/paint_vector_icon.h" namespace autofill { @@ -27,7 +28,12 @@ IDC_OFFERS_AND_REWARDS_FOR_PAGE, icon_label_bubble_delegate, page_action_icon_delegate, - "PaymentsOfferNotification") {} + "PaymentsOfferNotification") { + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringUTF16( + IDS_AUTOFILL_OFFERS_REMINDER_ICON_TOOLTIP_TEXT)); +} OfferNotificationIconView::~OfferNotificationIconView() = default; @@ -52,12 +58,6 @@ SetVisible(command_enabled); } -std::u16string OfferNotificationIconView::GetTextForTooltipAndAccessibleName() - const { - return l10n_util::GetStringUTF16( - IDS_AUTOFILL_OFFERS_REMINDER_ICON_TOOLTIP_TEXT); -} - void OfferNotificationIconView::OnExecuting( PageActionIconView::ExecuteSource execute_source) {} @@ -65,13 +65,12 @@ return kLocalOfferFlippedIcon; } -const char* OfferNotificationIconView::GetClassName() const { - return "OfferNotificationIconView"; -} - OfferNotificationBubbleController* OfferNotificationIconView::GetController() const { return OfferNotificationBubbleController::Get(GetWebContents()); } +BEGIN_METADATA(OfferNotificationIconView, PageActionIconView) +END_METADATA + } // namespace autofill
diff --git a/chrome/browser/ui/views/autofill/payments/offer_notification_icon_view.h b/chrome/browser/ui/views/autofill/payments/offer_notification_icon_view.h index 20086e23..407c4ed 100644 --- a/chrome/browser/ui/views/autofill/payments/offer_notification_icon_view.h +++ b/chrome/browser/ui/views/autofill/payments/offer_notification_icon_view.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_PAYMENTS_OFFER_NOTIFICATION_ICON_VIEW_H_ #include "chrome/browser/ui/views/page_action/page_action_icon_view.h" +#include "ui/base/metadata/metadata_header_macros.h" class CommandUpdater; @@ -17,6 +18,7 @@ // related offers that are eligible on the current page domain. class OfferNotificationIconView : public PageActionIconView { public: + METADATA_HEADER(OfferNotificationIconView); OfferNotificationIconView( CommandUpdater* command_updater, IconLabelBubbleView::Delegate* icon_label_bubble_delegate, @@ -29,13 +31,11 @@ // PageActionIconView: views::BubbleDialogDelegate* GetBubble() const override; void UpdateImpl() override; - std::u16string GetTextForTooltipAndAccessibleName() const override; protected: // PageActionIconView: void OnExecuting(PageActionIconView::ExecuteSource execute_source) override; const gfx::VectorIcon& GetVectorIcon() const override; - const char* GetClassName() const override; private: OfferNotificationBubbleController* GetController() const;
diff --git a/chrome/browser/ui/views/autofill/payments/save_card_bubble_views_browsertest.cc b/chrome/browser/ui/views/autofill/payments/save_card_bubble_views_browsertest.cc index 8e673eb..2d51a1bf 100644 --- a/chrome/browser/ui/views/autofill/payments/save_card_bubble_views_browsertest.cc +++ b/chrome/browser/ui/views/autofill/payments/save_card_bubble_views_browsertest.cc
@@ -39,6 +39,7 @@ #include "chrome/browser/ui/views/page_action/page_action_icon_controller.h" #include "chrome/browser/ui/views/page_action/page_action_icon_loading_indicator_view.h" #include "chrome/browser/ui/views/toolbar/toolbar_view.h" +#include "chrome/grit/generated_resources.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "components/autofill/content/browser/content_autofill_driver.h" @@ -78,6 +79,7 @@ #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/test/test_url_loader_factory.h" #include "testing/gmock/include/gmock/gmock.h" +#include "ui/base/l10n/l10n_util.h" #include "ui/events/base_event_utils.h" #include "ui/views/bubble/bubble_frame_view.h" #include "ui/views/controls/button/button.h" @@ -2095,6 +2097,14 @@ Bucket(ManageCardsPromptMetric::kManageCardsDone, 1))); } +IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, + IconViewAccessibleName) { + EXPECT_EQ(GetSaveCardIconView()->GetAccessibleName(), + l10n_util::GetStringUTF16(IDS_TOOLTIP_SAVE_CREDIT_CARD)); + EXPECT_EQ(GetSaveCardIconView()->GetTextForTooltipAndAccessibleName(), + l10n_util::GetStringUTF16(IDS_TOOLTIP_SAVE_CREDIT_CARD)); +} + // TODO(crbug.com/1346433): Add new browser tests for save card bubble view // where it check for user label information based on experiment conditions. // These aren't being added at the current time because of issues with the Sync
diff --git a/chrome/browser/ui/views/autofill/payments/save_payment_icon_view.cc b/chrome/browser/ui/views/autofill/payments/save_payment_icon_view.cc index f8b3699..9956be2 100644 --- a/chrome/browser/ui/views/autofill/payments/save_payment_icon_view.cc +++ b/chrome/browser/ui/views/autofill/payments/save_payment_icon_view.cc
@@ -18,6 +18,7 @@ #include "components/strings/grit/components_strings.h" #include "components/vector_icons/vector_icons.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" #include "ui/gfx/paint_vector_icon.h" namespace autofill { @@ -42,6 +43,8 @@ } command_id_ = command_id; SetUpForInOutAnimation(); + SetAccessibilityProperties(/*role*/ absl::nullopt, + GetTextForTooltipAndAccessibleName()); } SavePaymentIconView::~SavePaymentIconView() = default; @@ -77,6 +80,8 @@ SetCommandEnabled(controller && controller->IsIconVisible()); SetVisible(command_enabled); + SetAccessibleName(GetTextForTooltipAndAccessibleName()); + if (command_enabled && controller->ShouldShowSavingPaymentAnimation()) { SetEnabled(false); SetIsLoading(/*is_loading=*/true); @@ -110,10 +115,6 @@ return gfx::kNoneIcon; } -const char* SavePaymentIconView::GetClassName() const { - return "SavePaymentIconView"; -} - std::u16string SavePaymentIconView::GetTextForTooltipAndAccessibleName() const { std::u16string text; @@ -142,4 +143,7 @@ controller->OnAnimationEnded(); } +BEGIN_METADATA(SavePaymentIconView, PageActionIconView) +END_METADATA + } // namespace autofill
diff --git a/chrome/browser/ui/views/autofill/payments/save_payment_icon_view.h b/chrome/browser/ui/views/autofill/payments/save_payment_icon_view.h index f7a6ebbf..92644f7 100644 --- a/chrome/browser/ui/views/autofill/payments/save_payment_icon_view.h +++ b/chrome/browser/ui/views/autofill/payments/save_payment_icon_view.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_PAYMENTS_SAVE_PAYMENT_ICON_VIEW_H_ #include "chrome/browser/ui/views/page_action/page_action_icon_view.h" +#include "ui/base/metadata/metadata_header_macros.h" class CommandUpdater; @@ -18,6 +19,7 @@ // it. class SavePaymentIconView : public PageActionIconView { public: + METADATA_HEADER(SavePaymentIconView); SavePaymentIconView(CommandUpdater* command_updater, IconLabelBubbleView::Delegate* icon_label_bubble_delegate, PageActionIconView::Delegate* page_action_icon_delegate, @@ -38,7 +40,6 @@ void OnExecuting(PageActionIconView::ExecuteSource execute_source) override; const gfx::VectorIcon& GetVectorIcon() const override; const gfx::VectorIcon& GetVectorIconBadge() const override; - const char* GetClassName() const override; private: SavePaymentIconController* GetController() const;
diff --git a/chrome/browser/ui/views/autofill/payments/virtual_card_enroll_bubble_views_interactive_uitest.cc b/chrome/browser/ui/views/autofill/payments/virtual_card_enroll_bubble_views_interactive_uitest.cc index 98327dee..8165f4c 100644 --- a/chrome/browser/ui/views/autofill/payments/virtual_card_enroll_bubble_views_interactive_uitest.cc +++ b/chrome/browser/ui/views/autofill/payments/virtual_card_enroll_bubble_views_interactive_uitest.cc
@@ -20,7 +20,9 @@ #include "components/autofill/core/browser/payments/payments_service_url.h" #include "components/autofill/core/browser/payments/test_legal_message_line.h" #include "components/autofill/core/browser/payments/virtual_card_enrollment_manager.h" +#include "components/strings/grit/components_strings.h" #include "content/public/test/browser_test.h" +#include "ui/base/l10n/l10n_util.h" #include "ui/gfx/image/image_unittest_util.h" #include "ui/views/test/widget_test.h" #include "ui/views/view_observer.h" @@ -570,4 +572,15 @@ BucketsAre(base::Bucket(false, 1), base::Bucket(true, 0))); } +IN_PROC_BROWSER_TEST_P( + VirtualCardEnrollBubbleViewsInteractiveUiTestParameterized, + IconViewAccessibleName) { + EXPECT_EQ(GetIconView()->GetAccessibleName(), + l10n_util::GetStringUTF16( + IDS_AUTOFILL_VIRTUAL_CARD_ENROLLMENT_FALLBACK_ICON_TOOLTIP)); + EXPECT_EQ(GetIconView()->GetTextForTooltipAndAccessibleName(), + l10n_util::GetStringUTF16( + IDS_AUTOFILL_VIRTUAL_CARD_ENROLLMENT_FALLBACK_ICON_TOOLTIP)); +} + } // namespace autofill
diff --git a/chrome/browser/ui/views/autofill/payments/virtual_card_enroll_icon_view.cc b/chrome/browser/ui/views/autofill/payments/virtual_card_enroll_icon_view.cc index 022aa533..0a1e3dd 100644 --- a/chrome/browser/ui/views/autofill/payments/virtual_card_enroll_icon_view.cc +++ b/chrome/browser/ui/views/autofill/payments/virtual_card_enroll_icon_view.cc
@@ -16,6 +16,7 @@ #include "components/strings/grit/components_strings.h" #include "components/vector_icons/vector_icons.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" #include "ui/gfx/paint_vector_icon.h" namespace autofill { @@ -28,7 +29,12 @@ IDC_VIRTUAL_CARD_ENROLL, icon_label_bubble_delegate, delegate, - "VirtualCardEnroll") {} + "VirtualCardEnroll") { + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringUTF16( + IDS_AUTOFILL_VIRTUAL_CARD_ENROLLMENT_FALLBACK_ICON_TOOLTIP)); +} VirtualCardEnrollIconView::~VirtualCardEnrollIconView() = default; @@ -58,16 +64,6 @@ return kCreditCardIcon; } -const char* VirtualCardEnrollIconView::GetClassName() const { - return "VirtualCardEnrollIconView"; -} - -std::u16string VirtualCardEnrollIconView::GetTextForTooltipAndAccessibleName() - const { - return l10n_util::GetStringUTF16( - IDS_AUTOFILL_VIRTUAL_CARD_ENROLLMENT_FALLBACK_ICON_TOOLTIP); -} - VirtualCardEnrollBubbleController* VirtualCardEnrollIconView::GetController() const { content::WebContents* web_contents = GetWebContents(); @@ -77,4 +73,7 @@ return VirtualCardEnrollBubbleControllerImpl::FromWebContents(web_contents); } +BEGIN_METADATA(VirtualCardEnrollIconView, PageActionIconView) +END_METADATA + } // namespace autofill
diff --git a/chrome/browser/ui/views/autofill/payments/virtual_card_enroll_icon_view.h b/chrome/browser/ui/views/autofill/payments/virtual_card_enroll_icon_view.h index 0740e9d..c945971a 100644 --- a/chrome/browser/ui/views/autofill/payments/virtual_card_enroll_icon_view.h +++ b/chrome/browser/ui/views/autofill/payments/virtual_card_enroll_icon_view.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_PAYMENTS_VIRTUAL_CARD_ENROLL_ICON_VIEW_H_ #include "chrome/browser/ui/views/page_action/page_action_icon_view.h" +#include "ui/base/metadata/metadata_header_macros.h" class CommandUpdater; @@ -17,6 +18,7 @@ // can choose to enroll in a virtual card. class VirtualCardEnrollIconView : public PageActionIconView { public: + METADATA_HEADER(VirtualCardEnrollIconView); VirtualCardEnrollIconView( CommandUpdater* command_updater, IconLabelBubbleView::Delegate* icon_label_bubble_delegate, @@ -31,13 +33,11 @@ // PageActionIconView: views::BubbleDialogDelegate* GetBubble() const override; void UpdateImpl() override; - std::u16string GetTextForTooltipAndAccessibleName() const override; protected: // PageActionIconView: void OnExecuting(PageActionIconView::ExecuteSource execute_source) override; const gfx::VectorIcon& GetVectorIcon() const override; - const char* GetClassName() const override; private: VirtualCardEnrollBubbleController* GetController() const;
diff --git a/chrome/browser/ui/views/autofill/payments/virtual_card_manual_fallback_bubble_views_interactive_uitest.cc b/chrome/browser/ui/views/autofill/payments/virtual_card_manual_fallback_bubble_views_interactive_uitest.cc index 7234dd0..11c264b 100644 --- a/chrome/browser/ui/views/autofill/payments/virtual_card_manual_fallback_bubble_views_interactive_uitest.cc +++ b/chrome/browser/ui/views/autofill/payments/virtual_card_manual_fallback_bubble_views_interactive_uitest.cc
@@ -18,6 +18,7 @@ #include "chrome/browser/ui/views/autofill/payments/virtual_card_manual_fallback_icon_view.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/toolbar_button_provider.h" +#include "chrome/grit/generated_resources.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/interactive_test_utils.h" #include "chrome/test/base/ui_test_utils.h" @@ -406,6 +407,16 @@ cardholder_name_button->GetAccessibleName()); } +IN_PROC_BROWSER_TEST_F(VirtualCardManualFallbackBubbleViewsInteractiveUiTest, + IconViewAccessibleName) { + EXPECT_EQ(GetIconView()->GetAccessibleName(), + l10n_util::GetStringUTF16( + IDS_AUTOFILL_VIRTUAL_CARD_MANUAL_FALLBACK_ICON_TOOLTIP)); + EXPECT_EQ(GetIconView()->GetTextForTooltipAndAccessibleName(), + l10n_util::GetStringUTF16( + IDS_AUTOFILL_VIRTUAL_CARD_MANUAL_FALLBACK_ICON_TOOLTIP)); +} + class VirtualCardManualFallbackBubbleViewsPrerenderTest : public VirtualCardManualFallbackBubbleViewsInteractiveUiTest { public:
diff --git a/chrome/browser/ui/views/autofill/payments/virtual_card_manual_fallback_icon_view.cc b/chrome/browser/ui/views/autofill/payments/virtual_card_manual_fallback_icon_view.cc index 9435c3a..c96de50 100644 --- a/chrome/browser/ui/views/autofill/payments/virtual_card_manual_fallback_icon_view.cc +++ b/chrome/browser/ui/views/autofill/payments/virtual_card_manual_fallback_icon_view.cc
@@ -13,6 +13,7 @@ #include "chrome/grit/generated_resources.h" #include "components/strings/grit/components_strings.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" #include "ui/gfx/paint_vector_icon.h" namespace autofill { @@ -25,7 +26,12 @@ IDC_VIRTUAL_CARD_MANUAL_FALLBACK, icon_label_bubble_delegate, delegate, - "VirtualCardManualFallback") {} + "VirtualCardManualFallback") { + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringUTF16( + IDS_AUTOFILL_VIRTUAL_CARD_MANUAL_FALLBACK_ICON_TOOLTIP)); +} VirtualCardManualFallbackIconView::~VirtualCardManualFallbackIconView() = default; @@ -50,12 +56,6 @@ SetVisible(SetCommandEnabled(command_enabled)); } -std::u16string -VirtualCardManualFallbackIconView::GetTextForTooltipAndAccessibleName() const { - return l10n_util::GetStringUTF16( - IDS_AUTOFILL_VIRTUAL_CARD_MANUAL_FALLBACK_ICON_TOOLTIP); -} - void VirtualCardManualFallbackIconView::OnExecuting( PageActionIconView::ExecuteSource execute_source) {} @@ -64,10 +64,6 @@ return kCreditCardIcon; } -const char* VirtualCardManualFallbackIconView::GetClassName() const { - return "VirtualCardManualFallbackIconView"; -} - VirtualCardManualFallbackBubbleController* VirtualCardManualFallbackIconView::GetController() const { content::WebContents* web_contents = GetWebContents(); @@ -77,4 +73,7 @@ return VirtualCardManualFallbackBubbleController::Get(web_contents); } +BEGIN_METADATA(VirtualCardManualFallbackIconView, PageActionIconView) +END_METADATA + } // namespace autofill
diff --git a/chrome/browser/ui/views/autofill/payments/virtual_card_manual_fallback_icon_view.h b/chrome/browser/ui/views/autofill/payments/virtual_card_manual_fallback_icon_view.h index 91667403..f34a818 100644 --- a/chrome/browser/ui/views/autofill/payments/virtual_card_manual_fallback_icon_view.h +++ b/chrome/browser/ui/views/autofill/payments/virtual_card_manual_fallback_icon_view.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_PAYMENTS_VIRTUAL_CARD_MANUAL_FALLBACK_ICON_VIEW_H_ #include "chrome/browser/ui/views/page_action/page_action_icon_view.h" +#include "ui/base/metadata/metadata_header_macros.h" class CommandUpdater; @@ -17,6 +18,7 @@ // selected the virtual card to use and the information has been sent to Chrome. class VirtualCardManualFallbackIconView : public PageActionIconView { public: + METADATA_HEADER(VirtualCardManualFallbackIconView); VirtualCardManualFallbackIconView( CommandUpdater* command_updater, IconLabelBubbleView::Delegate* icon_label_bubble_delegate, @@ -30,13 +32,11 @@ // PageActionIconView: views::BubbleDialogDelegate* GetBubble() const override; void UpdateImpl() override; - std::u16string GetTextForTooltipAndAccessibleName() const override; protected: // PageActionIconView: void OnExecuting(PageActionIconView::ExecuteSource execute_source) override; const gfx::VectorIcon& GetVectorIcon() const override; - const char* GetClassName() const override; private: VirtualCardManualFallbackBubbleController* GetController() const;
diff --git a/chrome/browser/ui/views/autofill/save_update_address_profile_icon_view.cc b/chrome/browser/ui/views/autofill/save_update_address_profile_icon_view.cc index 17cd3023..a3869a71 100644 --- a/chrome/browser/ui/views/autofill/save_update_address_profile_icon_view.cc +++ b/chrome/browser/ui/views/autofill/save_update_address_profile_icon_view.cc
@@ -12,6 +12,7 @@ #include "components/strings/grit/components_strings.h" #include "components/vector_icons/vector_icons.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" namespace autofill { @@ -23,7 +24,10 @@ IDC_SAVE_AUTOFILL_ADDRESS, icon_label_bubble_delegate, page_action_icon_delegate, - "SaveAutofillAddress") {} + "SaveAutofillAddress") { + SetAccessibilityProperties(/*role*/ absl::nullopt, + GetTextForTooltipAndAccessibleName()); +} SaveUpdateAddressProfileIconView::~SaveUpdateAddressProfileIconView() = default; @@ -46,6 +50,7 @@ bool command_enabled = SetCommandEnabled(controller && controller->IsBubbleActive()); SetVisible(command_enabled); + SetAccessibleName(GetTextForTooltipAndAccessibleName()); } std::u16string @@ -73,4 +78,7 @@ return SaveUpdateAddressProfileIconController::Get(GetWebContents()); } +BEGIN_METADATA(SaveUpdateAddressProfileIconView, PageActionIconView) +END_METADATA + } // namespace autofill
diff --git a/chrome/browser/ui/views/autofill/save_update_address_profile_icon_view.h b/chrome/browser/ui/views/autofill/save_update_address_profile_icon_view.h index 06ec3e51..38c4022d 100644 --- a/chrome/browser/ui/views/autofill/save_update_address_profile_icon_view.h +++ b/chrome/browser/ui/views/autofill/save_update_address_profile_icon_view.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_SAVE_UPDATE_ADDRESS_PROFILE_ICON_VIEW_H_ #include "chrome/browser/ui/views/page_action/page_action_icon_view.h" +#include "ui/base/metadata/metadata_header_macros.h" class CommandUpdater; @@ -16,6 +17,7 @@ // The location bar icon to show the Save Address Profile bubble. class SaveUpdateAddressProfileIconView : public PageActionIconView { public: + METADATA_HEADER(SaveUpdateAddressProfileIconView); SaveUpdateAddressProfileIconView( CommandUpdater* command_updater, IconLabelBubbleView::Delegate* icon_label_bubble_delegate,
diff --git a/chrome/browser/ui/views/commerce/price_tracking_icon_view.cc b/chrome/browser/ui/views/commerce/price_tracking_icon_view.cc index 1d483d1..c432d2ed 100644 --- a/chrome/browser/ui/views/commerce/price_tracking_icon_view.cc +++ b/chrome/browser/ui/views/commerce/price_tracking_icon_view.cc
@@ -34,6 +34,7 @@ #include "components/strings/grit/components_strings.h" #include "content/public/browser/web_contents.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/metadata/metadata_impl_macros.h" #include "ui/base/models/image_model.h" #include "ui/gfx/vector_icon_types.h" #include "ui/views/view_class_properties.h" @@ -72,6 +73,9 @@ icon_(&omnibox::kPriceTrackingDisabledIcon) { SetUpForInOutAnimation(); SetProperty(views::kElementIdentifierKey, kPriceTrackingChipElementId); + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringUTF16(IDS_OMNIBOX_TRACK_PRICE)); } PriceTrackingIconView::~PriceTrackingIconView() = default; @@ -80,11 +84,6 @@ return bubble_coordinator_.GetBubble(); } -std::u16string PriceTrackingIconView::GetTextForTooltipAndAccessibleName() - const { - return tooltip_text_and_accessibleName_; -} - void PriceTrackingIconView::OnExecuting( PageActionIconView::ExecuteSource execute_source) { if (AnimateOutTimer().IsRunning()) { @@ -253,8 +252,8 @@ : &omnibox::kPriceTrackingDisabledIcon; // TODO(meiliang@): Confirm with UXW on the tooltip string. If this expected, // we can return label()->GetText() instead. - tooltip_text_and_accessibleName_ = l10n_util::GetStringUTF16( - enable ? IDS_OMNIBOX_TRACKING_PRICE : IDS_OMNIBOX_TRACK_PRICE); + SetAccessibleName(l10n_util::GetStringUTF16( + enable ? IDS_OMNIBOX_TRACKING_PRICE : IDS_OMNIBOX_TRACK_PRICE)); SetLabel(l10n_util::GetStringUTF16(enable ? IDS_OMNIBOX_TRACKING_PRICE : IDS_OMNIBOX_TRACK_PRICE)); @@ -315,3 +314,6 @@ return animate_out_timer_for_testing_ ? *animate_out_timer_for_testing_ : animate_out_timer_; } + +BEGIN_METADATA(PriceTrackingIconView, PageActionIconView) +END_METADATA
diff --git a/chrome/browser/ui/views/commerce/price_tracking_icon_view.h b/chrome/browser/ui/views/commerce/price_tracking_icon_view.h index 67c2c93..c092168c 100644 --- a/chrome/browser/ui/views/commerce/price_tracking_icon_view.h +++ b/chrome/browser/ui/views/commerce/price_tracking_icon_view.h
@@ -9,6 +9,7 @@ #include "base/timer/timer.h" #include "chrome/browser/ui/views/commerce/price_tracking_bubble_dialog_view.h" #include "chrome/browser/ui/views/page_action/page_action_icon_view.h" +#include "ui/base/metadata/metadata_header_macros.h" #include "ui/gfx/vector_icon_types.h" class Browser; @@ -19,6 +20,7 @@ // track or untrack the current page. class PriceTrackingIconView : public PageActionIconView { public: + METADATA_HEADER(PriceTrackingIconView); PriceTrackingIconView(IconLabelBubbleView::Delegate* parent_delegate, Delegate* delegate, Browser* browser); @@ -26,7 +28,6 @@ // PageActionIconView: views::BubbleDialogDelegate* GetBubble() const override; - std::u16string GetTextForTooltipAndAccessibleName() const override; void OnExecuting(PageActionIconView::ExecuteSource execute_source) override; const gfx::VectorIcon& GetVectorIcon() const override; @@ -57,7 +58,6 @@ PriceTrackingBubbleCoordinator bubble_coordinator_; raw_ptr<const gfx::VectorIcon> icon_; - std::u16string tooltip_text_and_accessibleName_; // Animates out the price tracking icon label after a fixed period of time. // This keeps the label visible for long enough to give users an opportunity
diff --git a/chrome/browser/ui/views/commerce/price_tracking_icon_view_interactive_uitest.cc b/chrome/browser/ui/views/commerce/price_tracking_icon_view_interactive_uitest.cc index af820eb..0ec24487 100644 --- a/chrome/browser/ui/views/commerce/price_tracking_icon_view_interactive_uitest.cc +++ b/chrome/browser/ui/views/commerce/price_tracking_icon_view_interactive_uitest.cc
@@ -21,6 +21,7 @@ #include "chrome/browser/ui/views/side_panel/side_panel_registry.h" #include "chrome/browser/ui/views/toolbar/toolbar_view.h" #include "chrome/common/pref_names.h" +#include "chrome/grit/generated_resources.h" #include "chrome/test/base/browser_with_test_window_test.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/interactive_test_utils.h" @@ -364,6 +365,14 @@ EXPECT_FALSE(GetBookmarkStar()->GetActive()); } +IN_PROC_BROWSER_TEST_F(PriceTrackingIconViewInteractiveTest, + IconViewAccessibleName) { + EXPECT_EQ(GetChip()->GetAccessibleName(), + l10n_util::GetStringUTF16(IDS_OMNIBOX_TRACK_PRICE)); + EXPECT_EQ(GetChip()->GetTextForTooltipAndAccessibleName(), + l10n_util::GetStringUTF16(IDS_OMNIBOX_TRACK_PRICE)); +} + class PriceTrackingIconViewErrorHandelingTest : public PriceTrackingIconViewInteractiveTest { public:
diff --git a/chrome/browser/ui/views/file_system_access/file_system_access_icon_view.cc b/chrome/browser/ui/views/file_system_access/file_system_access_icon_view.cc index 149500d..695865c 100644 --- a/chrome/browser/ui/views/file_system_access/file_system_access_icon_view.cc +++ b/chrome/browser/ui/views/file_system_access/file_system_access_icon_view.cc
@@ -27,6 +27,10 @@ page_action_icon_delegate, "FileSystemAccess") { SetVisible(false); + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringUTF16( + IDS_FILE_SYSTEM_ACCESS_DIRECTORY_USAGE_TOOLTIP)); } views::BubbleDialogDelegate* FileSystemAccessIconView::GetBubble() const { @@ -54,21 +58,18 @@ if (has_write_access_ != had_write_access) UpdateIconImage(); + SetAccessibleName(has_write_access_ + ? l10n_util::GetStringUTF16( + IDS_FILE_SYSTEM_ACCESS_WRITE_USAGE_TOOLTIP) + : l10n_util::GetStringUTF16( + IDS_FILE_SYSTEM_ACCESS_DIRECTORY_USAGE_TOOLTIP)); + // If icon isn't visible, a bubble shouldn't be shown either. Close it if // it was still open. if (!GetVisible()) FileSystemAccessUsageBubbleView::CloseCurrentBubble(); } -std::u16string FileSystemAccessIconView::GetTextForTooltipAndAccessibleName() - const { - return has_write_access_ - ? l10n_util::GetStringUTF16( - IDS_FILE_SYSTEM_ACCESS_WRITE_USAGE_TOOLTIP) - : l10n_util::GetStringUTF16( - IDS_FILE_SYSTEM_ACCESS_DIRECTORY_USAGE_TOOLTIP); -} - void FileSystemAccessIconView::OnExecuting(ExecuteSource execute_source) { auto* web_contents = GetWebContents(); url::Origin origin =
diff --git a/chrome/browser/ui/views/file_system_access/file_system_access_icon_view.h b/chrome/browser/ui/views/file_system_access/file_system_access_icon_view.h index dd1b016..ac7a238 100644 --- a/chrome/browser/ui/views/file_system_access/file_system_access_icon_view.h +++ b/chrome/browser/ui/views/file_system_access/file_system_access_icon_view.h
@@ -23,7 +23,6 @@ // PageActionIconView: views::BubbleDialogDelegate* GetBubble() const override; void UpdateImpl() override; - std::u16string GetTextForTooltipAndAccessibleName() const override; void OnExecuting(ExecuteSource execute_source) override; const gfx::VectorIcon& GetVectorIcon() const override;
diff --git a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_lacros.cc b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_lacros.cc index 2bd6210..08c98c6c 100644 --- a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_lacros.cc +++ b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_lacros.cc
@@ -67,8 +67,8 @@ const bool showing_frame = browser_view_->frame()->UseCustomFrame() && !view->IsFrameCondensed(); const float scale = device_scale_factor(); - const gfx::Size widget_size = - view->GetWidget()->GetWindowBoundsInScreen().size(); + const gfx::Size widget_size_px = + platform_window()->GetBoundsInPixels().size(); std::vector<gfx::Rect> opaque_region; if (showing_frame && @@ -124,8 +124,10 @@ } else { GetContentWindow()->layer()->SetRoundedCornerRadius({}); GetContentWindow()->layer()->SetIsFastRoundedCorner(false); - opaque_region.push_back({{}, widget_size}); + opaque_region.push_back({{}, widget_size_px}); } + // TODO(crbug.com/1306688): Instead of setting OpaqueRegion, set the rounded + // corners in dp. platform_window()->SetOpaqueRegion(&opaque_region); }
diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc index 9cff115..c742980 100644 --- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc +++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
@@ -89,6 +89,30 @@ GetViewID(content_setting_image_model_->image_type()); if (view_id) SetID(*view_id); + + // Because this view is focusable, it should always have an accessible name, + // even if an announcement is not to be made. + // TODO(crbug.com/1411342): `IconLabelBubbleView::GetAccessibleNodeData` + // would set the name to explicitly empty when the name was missing. + // That function no longer exists. As a result we need to handle that here. + // There appear to be cases in which `Update` is never called and we lack + // an announcement string ID during construction. As a result, this view + // will lack an accessible name and the paint checks will fail. Shouldn't + // this view always have an accessible name? If not, should it be pruned + // from the accessibility tree when it lacks one? + const std::u16string& accessible_name = + content_setting_image_model_->AccessibilityAnnouncementStringId() + ? l10n_util::GetStringUTF16(content_setting_image_model_ + ->AccessibilityAnnouncementStringId()) + : std::u16string(); + const std::u16string& accessible_description = + l10n_util::GetStringUTF16(IDS_A11Y_OMNIBOX_CHIP_HINT); + + SetAccessibilityProperties( + /*role*/ absl::nullopt, accessible_name, accessible_description, + /*role_description*/ absl::nullopt, + accessible_name.empty() ? ax::mojom::NameFrom::kAttributeExplicitlyEmpty + : ax::mojom::NameFrom::kAttribute); } ContentSettingImageView::~ContentSettingImageView() = default; @@ -114,14 +138,12 @@ if (content_setting_image_model_->ShouldNotifyAccessibility(web_contents)) { auto name = l10n_util::GetStringUTF16( content_setting_image_model_->AccessibilityAnnouncementStringId()); - auto desc = l10n_util::GetStringUTF16(IDS_A11Y_OMNIBOX_CHIP_HINT); - GetViewAccessibility().OverrideName(name); - GetViewAccessibility().OverrideDescription(desc); + SetAccessibleName(name); #if BUILDFLAG(IS_MAC) NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); #else GetViewAccessibility().AnnounceText(l10n_util::GetStringFUTF16( - IDS_CONCAT_TWO_STRINGS_WITH_COMMA, name, desc)); + IDS_CONCAT_TWO_STRINGS_WITH_COMMA, name, GetAccessibleDescription())); #endif NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); content_setting_image_model_->AccessibilityWasNotified(web_contents);
diff --git a/chrome/browser/ui/views/location_bar/cookie_controls_bubble_view_browsertest.cc b/chrome/browser/ui/views/location_bar/cookie_controls_bubble_view_browsertest.cc index d35afb8..f2950bb76 100644 --- a/chrome/browser/ui/views/location_bar/cookie_controls_bubble_view_browsertest.cc +++ b/chrome/browser/ui/views/location_bar/cookie_controls_bubble_view_browsertest.cc
@@ -15,6 +15,7 @@ #include "chrome/browser/ui/views/location_bar/cookie_controls_bubble_view.h" #include "chrome/browser/ui/views/page_action/page_action_icon_view.h" #include "chrome/common/chrome_features.h" +#include "chrome/grit/generated_resources.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "components/content_settings/core/browser/cookie_settings.h" @@ -22,6 +23,7 @@ #include "content/public/test/browser_test.h" #include "content/public/test/browser_test_utils.h" #include "net/dns/mock_host_resolver.h" +#include "ui/base/l10n/l10n_util.h" #include "ui/views/controls/link.h" #include "ui/views/view.h" #include "url/gurl.h" @@ -182,3 +184,11 @@ // Show bubble. ShowAndVerifyUi(); } + +IN_PROC_BROWSER_TEST_F(CookieControlsBubbleViewTest, IconViewAccessibleName) { + EXPECT_FALSE(cookie_controls_icon()->GetVisible()); + EXPECT_EQ(cookie_controls_icon()->GetAccessibleName(), + l10n_util::GetStringUTF16(IDS_COOKIE_CONTROLS_TOOLTIP)); + EXPECT_EQ(cookie_controls_icon()->GetTextForTooltipAndAccessibleName(), + l10n_util::GetStringUTF16(IDS_COOKIE_CONTROLS_TOOLTIP)); +}
diff --git a/chrome/browser/ui/views/location_bar/cookie_controls_icon_view.cc b/chrome/browser/ui/views/location_bar/cookie_controls_icon_view.cc index 2be40e1..d53343e8 100644 --- a/chrome/browser/ui/views/location_bar/cookie_controls_icon_view.cc +++ b/chrome/browser/ui/views/location_bar/cookie_controls_icon_view.cc
@@ -30,6 +30,9 @@ page_action_icon_delegate, "CookieControls") { SetVisible(false); + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringUTF16(IDS_COOKIE_CONTROLS_TOOLTIP)); } CookieControlsIconView::~CookieControlsIconView() = default; @@ -121,11 +124,6 @@ : views::kEyeCrossedIcon; } -std::u16string CookieControlsIconView::GetTextForTooltipAndAccessibleName() - const { - return l10n_util::GetStringUTF16(IDS_COOKIE_CONTROLS_TOOLTIP); -} - BEGIN_METADATA(CookieControlsIconView, PageActionIconView) ADD_READONLY_PROPERTY_METADATA(bool, AssociatedBubble) END_METADATA
diff --git a/chrome/browser/ui/views/location_bar/cookie_controls_icon_view.h b/chrome/browser/ui/views/location_bar/cookie_controls_icon_view.h index b3ca0ee0..5079f1b8 100644 --- a/chrome/browser/ui/views/location_bar/cookie_controls_icon_view.h +++ b/chrome/browser/ui/views/location_bar/cookie_controls_icon_view.h
@@ -36,7 +36,6 @@ // PageActionIconView: views::BubbleDialogDelegate* GetBubble() const override; void UpdateImpl() override; - std::u16string GetTextForTooltipAndAccessibleName() const override; protected: void OnExecuting(PageActionIconView::ExecuteSource source) override;
diff --git a/chrome/browser/ui/views/location_bar/find_bar_icon.cc b/chrome/browser/ui/views/location_bar/find_bar_icon.cc index baf771f1..57fa941 100644 --- a/chrome/browser/ui/views/location_bar/find_bar_icon.cc +++ b/chrome/browser/ui/views/location_bar/find_bar_icon.cc
@@ -24,6 +24,8 @@ "Find"), browser_(browser) { DCHECK(browser_); + SetAccessibilityProperties(/*role*/ absl::nullopt, + l10n_util::GetStringUTF16(IDS_TOOLTIP_FIND)); } FindBarIcon::~FindBarIcon() {} @@ -46,10 +48,6 @@ } } -std::u16string FindBarIcon::GetTextForTooltipAndAccessibleName() const { - return l10n_util::GetStringUTF16(IDS_TOOLTIP_FIND); -} - void FindBarIcon::OnExecuting(ExecuteSource execute_source) {} views::BubbleDialogDelegate* FindBarIcon::GetBubble() const {
diff --git a/chrome/browser/ui/views/location_bar/find_bar_icon.h b/chrome/browser/ui/views/location_bar/find_bar_icon.h index 99e45a9c..22a5caa 100644 --- a/chrome/browser/ui/views/location_bar/find_bar_icon.h +++ b/chrome/browser/ui/views/location_bar/find_bar_icon.h
@@ -30,7 +30,6 @@ void OnExecuting(ExecuteSource execute_source) override; views::BubbleDialogDelegate* GetBubble() const override; const gfx::VectorIcon& GetVectorIcon() const override; - std::u16string GetTextForTooltipAndAccessibleName() const override; private: raw_ptr<Browser> browser_ = nullptr;
diff --git a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc index bc4462b..3c242ae 100644 --- a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc +++ b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc
@@ -12,7 +12,6 @@ #include "chrome/browser/ui/color/chrome_color_id.h" #include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/omnibox/omnibox_theme.h" -#include "ui/accessibility/ax_node_data.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/metadata/metadata_impl_macros.h" #include "ui/compositor/layer_animator.h" @@ -209,7 +208,12 @@ } void IconLabelBubbleView::SetLabel(const std::u16string& label_text) { - SetAccessibleName(label_text); + // TODO(crbug.com/1411342): Under what conditions, if any, will the text be + // empty? Read the description of the bug and update accordingly. + SetAccessibleName(label_text, + label_text.empty() + ? ax::mojom::NameFrom::kAttributeExplicitlyEmpty + : ax::mojom::NameFrom::kAttribute); label()->SetText(label_text); separator_view_->SetVisible(ShouldShowSeparator()); separator_view_->UpdateOpacity(); @@ -421,12 +425,6 @@ AnimationEnded(animation); } -void IconLabelBubbleView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - LabelButton::GetAccessibleNodeData(node_data); - if (GetAccessibleName().empty()) - node_data->SetNameExplicitlyEmpty(); -} - void IconLabelBubbleView::SetImageModel(const ui::ImageModel& image_model) { DCHECK(!image_model.IsEmpty()); LabelButton::SetImageModel(STATE_NORMAL, image_model);
diff --git a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h index 0917e381..0d770b6 100644 --- a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h +++ b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h
@@ -28,10 +28,6 @@ class FontList; } // namespace gfx -namespace ui { -struct AXNodeData; -} - namespace views { class AXVirtualView; class ImageView; @@ -169,7 +165,6 @@ void AnimationEnded(const gfx::Animation* animation) override; void AnimationProgressed(const gfx::Animation* animation) override; void AnimationCanceled(const gfx::Animation* animation) override; - void GetAccessibleNodeData(ui::AXNodeData* node_data) override; const gfx::FontList& font_list() const { return label()->font_list(); }
diff --git a/chrome/browser/ui/views/location_bar/intent_picker_view.cc b/chrome/browser/ui/views/location_bar/intent_picker_view.cc index 8aef34d..e81e3c7 100644 --- a/chrome/browser/ui/views/location_bar/intent_picker_view.cc +++ b/chrome/browser/ui/views/location_bar/intent_picker_view.cc
@@ -30,7 +30,11 @@ icon_label_bubble_delegate, page_action_icon_delegate, "IntentPicker"), - browser_(browser) {} + browser_(browser) { + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringUTF16(IDS_TOOLTIP_INTENT_PICKER_ICON)); +} IntentPickerView::~IntentPickerView() = default; @@ -72,10 +76,6 @@ return vector_icons::kOpenInNewIcon; } -std::u16string IntentPickerView::GetTextForTooltipAndAccessibleName() const { - return l10n_util::GetStringUTF16(IDS_TOOLTIP_INTENT_PICKER_ICON); -} - BEGIN_METADATA(IntentPickerView, PageActionIconView) ADD_READONLY_PROPERTY_METADATA(bool, ShowIcon) END_METADATA
diff --git a/chrome/browser/ui/views/location_bar/intent_picker_view.h b/chrome/browser/ui/views/location_bar/intent_picker_view.h index 5eec7ac..bb41b4a 100644 --- a/chrome/browser/ui/views/location_bar/intent_picker_view.h +++ b/chrome/browser/ui/views/location_bar/intent_picker_view.h
@@ -30,7 +30,6 @@ void OnExecuting(PageActionIconView::ExecuteSource execute_source) override; views::BubbleDialogDelegate* GetBubble() const override; const gfx::VectorIcon& GetVectorIcon() const override; - std::u16string GetTextForTooltipAndAccessibleName() const override; private: bool GetShowIcon() const;
diff --git a/chrome/browser/ui/views/location_bar/location_icon_view.cc b/chrome/browser/ui/views/location_bar/location_icon_view.cc index 807ec69..183619c 100644 --- a/chrome/browser/ui/views/location_bar/location_icon_view.cc +++ b/chrome/browser/ui/views/location_bar/location_icon_view.cc
@@ -23,7 +23,6 @@ #include "content/public/common/url_constants.h" #include "extensions/common/constants.h" #include "ui/accessibility/ax_enums.mojom.h" -#include "ui/accessibility/ax_node_data.h" #include "ui/base/clipboard/clipboard.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/metadata/metadata_impl_macros.h" @@ -48,6 +47,8 @@ // Readability is guaranteed by the omnibox theme. label()->SetAutoColorReadabilityEnabled(false); + + SetAccessibleProperties(/*is_initialization*/ true); } LocationIconView::~LocationIconView() {} @@ -89,25 +90,6 @@ return true; } -void LocationIconView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - if (delegate_->IsEditingOrEmpty()) { - node_data->role = ax::mojom::Role::kImage; - node_data->SetNameChecked(l10n_util::GetStringUTF8(IDS_ACC_SEARCH_ICON)); - return; - } - - // If no display text exists, ensure that the accessibility label is added. - auto accessibility_label = base::UTF16ToUTF8( - delegate_->GetLocationBarModel()->GetSecureAccessibilityText()); - if (label()->GetText().empty() && !accessibility_label.empty()) { - node_data->AddStringAttribute(ax::mojom::StringAttribute::kDescription, - accessibility_label); - } - - IconLabelBubbleView::GetAccessibleNodeData(node_data); - node_data->role = ax::mojom::Role::kPopUpButton; -} - void LocationIconView::AddedToWidget() { Update(true); } @@ -211,6 +193,32 @@ AnimateOut(); } +void LocationIconView::SetAccessibleProperties(bool is_initialization) { + ax::mojom::Role role = delegate_->IsEditingOrEmpty() + ? ax::mojom::Role::kImage + : ax::mojom::Role::kPopUpButton; + + const std::u16string name = + delegate_->IsEditingOrEmpty() + ? l10n_util::GetStringUTF16(IDS_ACC_SEARCH_ICON) + : GetAccessibleName(); + + // If no display text exists, ensure that the accessibility label is added. + const std::u16string description = + delegate_->IsEditingOrEmpty() ? GetAccessibleDescription() + : label()->GetText().empty() + ? delegate_->GetLocationBarModel()->GetSecureAccessibilityText() + : std::u16string(); + + if (is_initialization) { + SetAccessibilityProperties(role, name, description); + } else { + SetAccessibleRole(role); + SetAccessibleName(name); + SetAccessibleDescription(description); + } +} + void LocationIconView::UpdateIcon() { // Cancel any previous outstanding icon requests, as they are now outdated. icon_fetch_weak_ptr_factory_.InvalidateWeakPtrs(); @@ -230,6 +238,7 @@ void LocationIconView::Update(bool suppress_animations) { UpdateTextVisibility(suppress_animations); UpdateIcon(); + SetAccessibleProperties(/*is_initialization*/ false); // The label text color may have changed in response to changes in security // level.
diff --git a/chrome/browser/ui/views/location_bar/location_icon_view.h b/chrome/browser/ui/views/location_bar/location_icon_view.h index eb9ae3f..d8f2fbc 100644 --- a/chrome/browser/ui/views/location_bar/location_icon_view.h +++ b/chrome/browser/ui/views/location_bar/location_icon_view.h
@@ -75,7 +75,6 @@ bool ShowBubble(const ui::Event& event) override; bool IsBubbleShowing() const override; bool OnMousePressed(const ui::MouseEvent& event) override; - void GetAccessibleNodeData(ui::AXNodeData* node_data) override; void AddedToWidget() override; void OnThemeChanged() override; @@ -120,6 +119,9 @@ // If |suppress_animations| is true, the text change will not be animated. void UpdateTextVisibility(bool suppress_animations); + // Updates the accessible properties based on if we are editing or empty. + void SetAccessibleProperties(bool is_initialization); + // Updates Icon based on the current state and theme. void UpdateIcon();
diff --git a/chrome/browser/ui/views/location_bar/location_icon_view_unittest.cc b/chrome/browser/ui/views/location_bar/location_icon_view_unittest.cc index fd2092b..36f9e03 100644 --- a/chrome/browser/ui/views/location_bar/location_icon_view_unittest.cc +++ b/chrome/browser/ui/views/location_bar/location_icon_view_unittest.cc
@@ -9,9 +9,12 @@ #include "base/memory/raw_ptr.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" +#include "chrome/grit/generated_resources.h" #include "chrome/test/views/chrome_views_test_base.h" #include "components/omnibox/browser/location_bar_model.h" #include "components/omnibox/browser/test_location_bar_model.h" +#include "components/strings/grit/components_strings.h" +#include "ui/base/l10n/l10n_util.h" #include "ui/views/widget/widget.h" namespace { @@ -150,3 +153,36 @@ view()->Update(/*suppress_animations=*/false); EXPECT_FALSE(view()->is_animating_label()); } + +TEST_F(LocationIconViewTest, IconViewAccessibleNameAndRole) { + ui::AXNodeData data; + view()->GetAccessibleNodeData(&data); + EXPECT_EQ(view()->GetAccessibleName(), + l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON)); + EXPECT_EQ(data.GetString16Attribute(ax::mojom::StringAttribute::kName), + l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON)); + EXPECT_EQ(view()->GetAccessibleRole(), ax::mojom::Role::kPopUpButton); + EXPECT_EQ(data.role, ax::mojom::Role::kPopUpButton); + + delegate()->set_is_editing_or_empty(true); + view()->Update(/*suppress_animations=*/true); + data = ui::AXNodeData(); + view()->GetAccessibleNodeData(&data); + EXPECT_EQ(view()->GetAccessibleName(), + l10n_util::GetStringUTF16(IDS_ACC_SEARCH_ICON)); + EXPECT_EQ(data.GetString16Attribute(ax::mojom::StringAttribute::kName), + l10n_util::GetStringUTF16(IDS_ACC_SEARCH_ICON)); + EXPECT_EQ(view()->GetAccessibleRole(), ax::mojom::Role::kImage); + EXPECT_EQ(data.role, ax::mojom::Role::kImage); + + delegate()->set_is_editing_or_empty(false); + SetSecurityLevel(security_state::SecurityLevel::WARNING); + view()->Update(/*suppress_animations=*/true); + data = ui::AXNodeData(); + view()->GetAccessibleNodeData(&data); + EXPECT_EQ(view()->GetAccessibleName(), u"Insecure"); + EXPECT_EQ(data.GetString16Attribute(ax::mojom::StringAttribute::kName), + u"Insecure"); + EXPECT_EQ(view()->GetAccessibleRole(), ax::mojom::Role::kPopUpButton); + EXPECT_EQ(data.role, ax::mojom::Role::kPopUpButton); +}
diff --git a/chrome/browser/ui/views/location_bar/selected_keyword_view.cc b/chrome/browser/ui/views/location_bar/selected_keyword_view.cc index b3705ee7..913e4f1b 100644 --- a/chrome/browser/ui/views/location_bar/selected_keyword_view.cc +++ b/chrome/browser/ui/views/location_bar/selected_keyword_view.cc
@@ -46,6 +46,22 @@ partial_label_.SetFontList(font_list); partial_label_.SetVisible(false); label()->SetElideBehavior(gfx::FADE_TAIL); + + // TODO(crbug.com/1411342): `IconLabelBubbleView::GetAccessibleNodeData` + // would set the name to explicitly empty when the name was missing. + // That function no longer exists. As a result we need to handle that here. + // Regarding this view's namelessness: Until this view has a keyword and + // labels with text, there will be no accessible name. But this view claims to + // be focusable, so paint checks will fail due to a lack of name. It might + // make more sense to only set `FocusBehavior` when this view will be shown. + // For now, Eliminate the paint check failure. + if (GetAccessibleName().empty()) { + SetAccessibilityProperties(/*role*/ absl::nullopt, + /*name*/ std::u16string(), + /*description*/ absl::nullopt, + /*role_description*/ absl::nullopt, + ax::mojom::NameFrom::kAttributeExplicitlyEmpty); + } } SelectedKeywordView::~SelectedKeywordView() {}
diff --git a/chrome/browser/ui/views/location_bar/star_view.cc b/chrome/browser/ui/views/location_bar/star_view.cc index 270f14c4..de5773f 100644 --- a/chrome/browser/ui/views/location_bar/star_view.cc +++ b/chrome/browser/ui/views/location_bar/star_view.cc
@@ -63,6 +63,8 @@ SetID(VIEW_ID_STAR_BUTTON); SetProperty(views::kElementIdentifierKey, kBookmarkStarViewElementId); SetActive(false); + SetAccessibilityProperties(/*role*/ absl::nullopt, + l10n_util::GetStringUTF16(IDS_TOOLTIP_STAR)); } StarView::~StarView() = default; @@ -84,6 +86,8 @@ void StarView::UpdateImpl() { SetVisible(browser_defaults::bookmarks_enabled && edit_bookmarks_enabled_.GetValue()); + SetAccessibleName(l10n_util::GetStringUTF16(GetActive() ? IDS_TOOLTIP_STARRED + : IDS_TOOLTIP_STAR)); } void StarView::OnExecuting(PageActionIconView::ExecuteSource execute_source) { @@ -120,11 +124,6 @@ return GetActive() ? omnibox::kStarActiveIcon : omnibox::kStarIcon; } -std::u16string StarView::GetTextForTooltipAndAccessibleName() const { - return l10n_util::GetStringUTF16(GetActive() ? IDS_TOOLTIP_STARRED - : IDS_TOOLTIP_STAR); -} - void StarView::EditBookmarksPrefUpdated() { Update(); }
diff --git a/chrome/browser/ui/views/location_bar/star_view.h b/chrome/browser/ui/views/location_bar/star_view.h index 0a58fd4..d885378 100644 --- a/chrome/browser/ui/views/location_bar/star_view.h +++ b/chrome/browser/ui/views/location_bar/star_view.h
@@ -5,8 +5,6 @@ #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_STAR_VIEW_H_ #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_STAR_VIEW_H_ -#include <memory> - #include "base/memory/raw_ptr.h" #include "chrome/browser/ui/views/page_action/page_action_icon_view.h" #include "components/prefs/pref_member.h" @@ -38,7 +36,6 @@ void ExecuteCommand(ExecuteSource source) override; views::BubbleDialogDelegate* GetBubble() const override; const gfx::VectorIcon& GetVectorIcon() const override; - std::u16string GetTextForTooltipAndAccessibleName() const override; private: void EditBookmarksPrefUpdated();
diff --git a/chrome/browser/ui/views/page_action/page_action_icon_view.cc b/chrome/browser/ui/views/page_action/page_action_icon_view.cc index 11a3c5f3..7fd28cbcf 100644 --- a/chrome/browser/ui/views/page_action/page_action_icon_view.cc +++ b/chrome/browser/ui/views/page_action/page_action_icon_view.cc
@@ -12,7 +12,6 @@ #include "chrome/browser/ui/views/page_action/page_action_icon_loading_indicator_view.h" #include "chrome/browser/ui/views/page_action/page_action_icon_view_observer.h" #include "ui/accessibility/ax_enums.mojom.h" -#include "ui/accessibility/ax_node_data.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/metadata/metadata_impl_macros.h" #include "ui/base/models/image_model.h" @@ -116,10 +115,8 @@ InstallLoadingIndicator(); } -void PageActionIconView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ax::mojom::Role::kButton; - const std::u16string name_text = GetTextForTooltipAndAccessibleName(); - node_data->SetName(name_text); +std::u16string PageActionIconView::GetTextForTooltipAndAccessibleName() const { + return GetAccessibleName(); } std::u16string PageActionIconView::GetTooltipText(const gfx::Point& p) const {
diff --git a/chrome/browser/ui/views/page_action/page_action_icon_view.h b/chrome/browser/ui/views/page_action/page_action_icon_view.h index 91ef5a4..d78bad6 100644 --- a/chrome/browser/ui/views/page_action/page_action_icon_view.h +++ b/chrome/browser/ui/views/page_action/page_action_icon_view.h
@@ -98,7 +98,9 @@ virtual views::BubbleDialogDelegate* GetBubble() const = 0; // Retrieve the text to be used for a tooltip or accessible name. - virtual std::u16string GetTextForTooltipAndAccessibleName() const = 0; + // If this string never changes, subclasses should use `SetAccessibleName` + // in the constructor instead of overriding this function. + virtual std::u16string GetTextForTooltipAndAccessibleName() const; SkColor GetLabelColorForTesting() const; @@ -159,7 +161,6 @@ virtual void OnPressed(bool activated) {} // views::IconLabelBubbleView: - void GetAccessibleNodeData(ui::AXNodeData* node_data) override; std::u16string GetTooltipText(const gfx::Point& p) const override; void ViewHierarchyChanged( const views::ViewHierarchyChangedDetails& details) override;
diff --git a/chrome/browser/ui/views/page_action/page_action_icon_view_unittest.cc b/chrome/browser/ui/views/page_action/page_action_icon_view_unittest.cc index fe35db4..b0a2e850 100644 --- a/chrome/browser/ui/views/page_action/page_action_icon_view_unittest.cc +++ b/chrome/browser/ui/views/page_action/page_action_icon_view_unittest.cc
@@ -72,12 +72,10 @@ true, font_list) { SetUpForInOutAnimation(); + SetAccessibilityProperties(/*role*/ absl::nullopt, u"TestTooltip"); } views::BubbleDialogDelegate* GetBubble() const override { return nullptr; } - std::u16string GetTextForTooltipAndAccessibleName() const override { - return u"TestTooltip"; - } bool IsLabelVisible() const { return label()->GetVisible(); } @@ -194,3 +192,8 @@ EXPECT_FALSE(image_previous.BackedBySameObjectAs( icon_view->GetImage(views::Button::STATE_NORMAL))); } + +TEST_F(PageActionIconViewTest, IconViewAccessibleName) { + EXPECT_EQ(view()->GetAccessibleName(), + view()->GetTextForTooltipAndAccessibleName()); +}
diff --git a/chrome/browser/ui/views/page_action/pwa_install_view.cc b/chrome/browser/ui/views/page_action/pwa_install_view.cc index aa57535..124e06e 100644 --- a/chrome/browser/ui/views/page_action/pwa_install_view.cc +++ b/chrome/browser/ui/views/page_action/pwa_install_view.cc
@@ -91,6 +91,10 @@ return; } + SetAccessibleName(l10n_util::GetStringFUTF16( + IDS_OMNIBOX_PWA_INSTALL_ICON_TOOLTIP, + webapps::AppBannerManager::GetInstallableWebAppName(web_contents))); + auto* manager = webapps::AppBannerManager::FromWebContents(web_contents); // May not be present e.g. in incognito mode. if (!manager) @@ -177,15 +181,6 @@ return omnibox::kInstallDesktopIcon; } -std::u16string PwaInstallView::GetTextForTooltipAndAccessibleName() const { - content::WebContents* web_contents = GetWebContents(); - if (!web_contents) - return std::u16string(); - return l10n_util::GetStringFUTF16( - IDS_OMNIBOX_PWA_INSTALL_ICON_TOOLTIP, - webapps::AppBannerManager::GetInstallableWebAppName(web_contents)); -} - bool PwaInstallView::ShouldShowIph(content::WebContents* web_contents, webapps::AppBannerManager* manager) { web_app::AppId app_id =
diff --git a/chrome/browser/ui/views/page_action/pwa_install_view.h b/chrome/browser/ui/views/page_action/pwa_install_view.h index d2fe8798..e3b10d9 100644 --- a/chrome/browser/ui/views/page_action/pwa_install_view.h +++ b/chrome/browser/ui/views/page_action/pwa_install_view.h
@@ -42,7 +42,6 @@ void OnExecuting(PageActionIconView::ExecuteSource source) override; views::BubbleDialogDelegate* GetBubble() const override; const gfx::VectorIcon& GetVectorIcon() const override; - std::u16string GetTextForTooltipAndAccessibleName() const override; private: raw_ptr<Browser> browser_ = nullptr;
diff --git a/chrome/browser/ui/views/page_action/pwa_install_view_browsertest.cc b/chrome/browser/ui/views/page_action/pwa_install_view_browsertest.cc index 8d8460a..f7549bce 100644 --- a/chrome/browser/ui/views/page_action/pwa_install_view_browsertest.cc +++ b/chrome/browser/ui/views/page_action/pwa_install_view_browsertest.cc
@@ -33,6 +33,7 @@ #include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_sync_bridge.h" #include "chrome/common/chrome_switches.h" +#include "chrome/grit/generated_resources.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "components/feature_engagement/public/feature_constants.h" @@ -49,6 +50,7 @@ #include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_response.h" #include "services/network/public/cpp/network_switches.h" +#include "ui/base/l10n/l10n_util.h" #include "ui/gfx/color_utils.h" #include "ui/views/view_observer.h" #include "ui/views/widget/any_widget_observer.h" @@ -792,6 +794,17 @@ feature_engagement::kIPHDesktopPwaInstallFeature)); } +IN_PROC_BROWSER_TEST_F(PwaInstallViewBrowserTest, IconViewAccessibleName) { + const std::u16string& web_app_name = + webapps::AppBannerManager::GetInstallableWebAppName(web_contents_); + EXPECT_EQ(pwa_install_view_->GetAccessibleName(), + l10n_util::GetStringFUTF16(IDS_OMNIBOX_PWA_INSTALL_ICON_TOOLTIP, + web_app_name)); + EXPECT_EQ(pwa_install_view_->GetTextForTooltipAndAccessibleName(), + l10n_util::GetStringFUTF16(IDS_OMNIBOX_PWA_INSTALL_ICON_TOOLTIP, + web_app_name)); +} + #if BUILDFLAG(IS_CHROMEOS_ASH) // Omnibox install promotion should not show if prefer_related_applications is // true and an ARC app listed as related.
diff --git a/chrome/browser/ui/views/page_action/zoom_view.cc b/chrome/browser/ui/views/page_action/zoom_view.cc index 8624401..65a8d75 100644 --- a/chrome/browser/ui/views/page_action/zoom_view.cc +++ b/chrome/browser/ui/views/page_action/zoom_view.cc
@@ -27,6 +27,10 @@ "Zoom"), icon_(&kZoomMinusIcon) { SetVisible(false); + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringFUTF16(IDS_TOOLTIP_ZOOM, + base::FormatPercent(current_zoom_percent_))); } ZoomView::~ZoomView() {} @@ -73,6 +77,9 @@ zoom::ZoomController::FromWebContents(web_contents); current_zoom_percent_ = zoom_controller->GetZoomPercent(); + SetAccessibleName(l10n_util::GetStringFUTF16( + IDS_TOOLTIP_ZOOM, base::FormatPercent(current_zoom_percent_))); + // The icon is hidden when the zoom level is default. if (features::IsChromeRefresh2023()) { @@ -120,10 +127,5 @@ return *icon_; } -std::u16string ZoomView::GetTextForTooltipAndAccessibleName() const { - return l10n_util::GetStringFUTF16(IDS_TOOLTIP_ZOOM, - base::FormatPercent(current_zoom_percent_)); -} - BEGIN_METADATA(ZoomView, PageActionIconView) END_METADATA
diff --git a/chrome/browser/ui/views/page_action/zoom_view.h b/chrome/browser/ui/views/page_action/zoom_view.h index 6f2b94a..17b6c2d 100644 --- a/chrome/browser/ui/views/page_action/zoom_view.h +++ b/chrome/browser/ui/views/page_action/zoom_view.h
@@ -33,7 +33,6 @@ void OnExecuting(PageActionIconView::ExecuteSource source) override; views::BubbleDialogDelegate* GetBubble() const override; const gfx::VectorIcon& GetVectorIcon() const override; - std::u16string GetTextForTooltipAndAccessibleName() const override; private: bool ShouldBeVisible(bool can_show_bubble) const;
diff --git a/chrome/browser/ui/views/passwords/manage_passwords_icon_views.cc b/chrome/browser/ui/views/passwords/manage_passwords_icon_views.cc index d64c84c..639480b 100644 --- a/chrome/browser/ui/views/passwords/manage_passwords_icon_views.cc +++ b/chrome/browser/ui/views/passwords/manage_passwords_icon_views.cc
@@ -29,6 +29,8 @@ // Password icon should not be mirrored in RTL. image()->SetFlipCanvasOnPaintForRTLUI(false); SetProperty(views::kElementIdentifierKey, kPasswordsOmniboxKeyIconElementId); + SetAccessibilityProperties(/*role*/ absl::nullopt, + GetTextForTooltipAndAccessibleName()); } ManagePasswordsIconViews::~ManagePasswordsIconViews() = default; @@ -40,6 +42,7 @@ PasswordBubbleViewBase::CloseCurrentBubble(); state_ = state; UpdateUiForState(); + SetAccessibleName(GetTextForTooltipAndAccessibleName()); } void ManagePasswordsIconViews::UpdateUiForState() {
diff --git a/chrome/browser/ui/views/performance_controls/high_efficiency_bubble_view.cc b/chrome/browser/ui/views/performance_controls/high_efficiency_bubble_view.cc index cb17f59..8bbb3f8 100644 --- a/chrome/browser/ui/views/performance_controls/high_efficiency_bubble_view.cc +++ b/chrome/browser/ui/views/performance_controls/high_efficiency_bubble_view.cc
@@ -18,6 +18,7 @@ #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" #include "chrome/grit/google_chrome_strings.h" +#include "components/policy/core/common/policy_pref_names.h" #include "components/signin/public/base/signin_buildflags.h" #include "components/strings/grit/components_strings.h" #include "ui/base/interaction/element_identifier.h" @@ -86,7 +87,7 @@ const bool is_guest = profile->IsGuestSession(); const bool is_forced_incognito = IncognitoModePrefs::GetAvailability(profile->GetPrefs()) == - IncognitoModePrefs::Availability::kForced; + policy::IncognitoModeAvailability::kForced; // Show bubble without Performance Settings Page Link since guest users or // forced incognito users are not allowed to navigate to the performance
diff --git a/chrome/browser/ui/views/performance_controls/high_efficiency_chip_view.cc b/chrome/browser/ui/views/performance_controls/high_efficiency_chip_view.cc index 908c796..a990e66 100644 --- a/chrome/browser/ui/views/performance_controls/high_efficiency_chip_view.cc +++ b/chrome/browser/ui/views/performance_controls/high_efficiency_chip_view.cc
@@ -55,6 +55,9 @@ "HighEfficiency"), browser_(browser) { DCHECK(browser_); + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringUTF16(IDS_HIGH_EFFICIENCY_CHIP_ACCNAME)); auto* manager = performance_manager::user_tuning:: UserPerformanceTuningManager::GetInstance(); @@ -168,11 +171,6 @@ return bubble_; } -std::u16string HighEfficiencyChipView::GetTextForTooltipAndAccessibleName() - const { - return l10n_util::GetStringUTF16(IDS_HIGH_EFFICIENCY_CHIP_ACCNAME); -} - void HighEfficiencyChipView::MaybeShowIPH() { if (browser_->window() != nullptr) { bool const promo_shown = browser_->window()->MaybeShowFeaturePromo(
diff --git a/chrome/browser/ui/views/performance_controls/high_efficiency_chip_view.h b/chrome/browser/ui/views/performance_controls/high_efficiency_chip_view.h index 7b4bded..d849d92c 100644 --- a/chrome/browser/ui/views/performance_controls/high_efficiency_chip_view.h +++ b/chrome/browser/ui/views/performance_controls/high_efficiency_chip_view.h
@@ -52,7 +52,6 @@ void OnExecuting(PageActionIconView::ExecuteSource execute_source) override; views::BubbleDialogDelegate* GetBubble() const override; const gfx::VectorIcon& GetVectorIcon() const override; - std::u16string GetTextForTooltipAndAccessibleName() const override; private: void MaybeShowIPH();
diff --git a/chrome/browser/ui/views/profiles/profile_management_step_controller.cc b/chrome/browser/ui/views/profiles/profile_management_step_controller.cc index ff0e8f2..4204cc35 100644 --- a/chrome/browser/ui/views/profiles/profile_management_step_controller.cc +++ b/chrome/browser/ui/views/profiles/profile_management_step_controller.cc
@@ -151,11 +151,6 @@ ~FinishSamlSignInStepController() override { if (finish_flow_callback_.value()) { finish_flow_callback_->Reset(); - - // The profile setup did not continue. Schedule it for deletion. - g_browser_process->profile_manager() - ->GetDeleteProfileHelper() - .ScheduleEphemeralProfileForDeletion(profile_->GetPath()); } }
diff --git a/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider.cc b/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider.cc index 7e36d3c..715725b9 100644 --- a/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider.cc +++ b/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider.cc
@@ -66,15 +66,6 @@ if (callback_) { if (IsInitialized()) { contents()->SetDelegate(nullptr); - - // Schedule the ephemeral profile for deletion if it wasn't deleted yet, - // since it's not needed any more. - if (!profile_path_.has_value() && - !IsProfileDirectoryMarkedForDeletion(profile_->GetPath())) { - g_browser_process->profile_manager() - ->GetDeleteProfileHelper() - .ScheduleEphemeralProfileForDeletion(profile_->GetPath()); - } } ProfileMetrics::LogProfileAddSignInFlowOutcome(
diff --git a/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider_browsertest.cc b/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider_browsertest.cc index a1215acc..da6c4d8 100644 --- a/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider_browsertest.cc +++ b/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider_browsertest.cc
@@ -7,12 +7,17 @@ #include "base/functional/callback_helpers.h" #include "base/test/mock_callback.h" #include "base/test/scoped_feature_list.h" +#include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/nuke_profile_directory_utils.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_attributes_entry.h" +#include "chrome/browser/profiles/profile_attributes_storage.h" +#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/signin/signin_features.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/profiles/profile_picker_web_contents_host.h" #include "chrome/test/base/in_process_browser_test.h" +#include "chrome/test/base/profile_deletion_observer.h" #include "components/signin/public/base/signin_metrics.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_delegate.h" @@ -79,6 +84,7 @@ IN_PROC_BROWSER_TEST_P(ProfilePickerDiceSignInProviderBrowserTest, SwitchToSignInThenExit) { + ProfileDeletionObserver observer; base::FilePath provider_profile_path; base::RunLoop switch_finished_loop; base::MockCallback<ProfilePickerDiceSignInProvider::SignedInCallback> @@ -115,8 +121,14 @@ switch_finished_loop.Run(); } - // On exit, the provider should schedule the profile it created for deletion. - EXPECT_TRUE(IsProfileDirectoryMarkedForDeletion(provider_profile_path)); + // On exit, the profile it created should be scheduled for deletion since it + // has no more keep alives. + observer.Wait(); + ProfileAttributesEntry* entry = + g_browser_process->profile_manager() + ->GetProfileAttributesStorage() + .GetProfileAttributesWithPath(provider_profile_path); + EXPECT_EQ(entry, nullptr); } IN_PROC_BROWSER_TEST_P(ProfilePickerDiceSignInProviderBrowserTest,
diff --git a/chrome/browser/ui/views/profiles/profile_picker_flow_controller.cc b/chrome/browser/ui/views/profiles/profile_picker_flow_controller.cc index 4d92b119..1012c818 100644 --- a/chrome/browser/ui/views/profiles/profile_picker_flow_controller.cc +++ b/chrome/browser/ui/views/profiles/profile_picker_flow_controller.cc
@@ -143,11 +143,6 @@ ~ProfileCreationSignedInFlowController() override { // Record unfinished signed-in profile creation. if (!is_finishing_) { - // Schedule the profile for deletion, it's not needed any more. - g_browser_process->profile_manager() - ->GetDeleteProfileHelper() - .ScheduleEphemeralProfileForDeletion(profile()->GetPath()); - // TODO(crbug.com/1300109): Consider moving this recording into // ProfilePickerTurnSyncOnDelegate and unify this code with Cancel(). ProfileMetrics::LogProfileAddSignInFlowOutcome( @@ -177,11 +172,6 @@ return; is_finishing_ = true; - - // Schedule the profile for deletion, it's not needed any more. - g_browser_process->profile_manager() - ->GetDeleteProfileHelper() - .ScheduleEphemeralProfileForDeletion(profile()->GetPath()); } void FinishAndOpenBrowser(PostHostClearedCallback callback) override {
diff --git a/chrome/browser/ui/views/profiles/profile_picker_view_browsertest.cc b/chrome/browser/ui/views/profiles/profile_picker_view_browsertest.cc index 84cb43e9..c1c8b1cc 100644 --- a/chrome/browser/ui/views/profiles/profile_picker_view_browsertest.cc +++ b/chrome/browser/ui/views/profiles/profile_picker_view_browsertest.cc
@@ -32,6 +32,7 @@ #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" #include "chrome/browser/policy/profile_policy_connector.h" #include "chrome/browser/policy/profile_policy_connector_builder.h" +#include "chrome/browser/profiles/keep_alive/profile_keep_alive_types.h" #include "chrome/browser/profiles/nuke_profile_directory_utils.h" #include "chrome/browser/profiles/profile_attributes_entry.h" #include "chrome/browser/profiles/profile_attributes_storage.h" @@ -50,6 +51,7 @@ #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/profile_ui_test_utils.h" #include "chrome/browser/ui/startup/first_run_service.h" @@ -756,9 +758,11 @@ GetSyncConfirmationURL(), "joe.consumer@gmail.com", "Joe"); // Close the flow with the [X] button. + ProfileDeletionObserver observer; base::FilePath canceled_path = profile_to_cancel->GetPath(); widget()->CloseWithReason(views::Widget::ClosedReason::kCloseButtonClicked); WaitForPickerClosed(); + observer.Wait(); ProfileAttributesStorage& storage = g_browser_process->profile_manager()->GetProfileAttributesStorage(); @@ -804,8 +808,10 @@ base::FilePath profile_to_cancel_path = profile_to_cancel->GetPath(); // Close the flow with the [X] button. + ProfileDeletionObserver observer; widget()->CloseWithReason(views::Widget::ClosedReason::kCloseButtonClicked); WaitForPickerClosed(); + observer.Wait(); // The profile entry is deleted. ProfileAttributesEntry* entry = @@ -839,7 +845,7 @@ } IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest, - CancelWhileSigningInWithNoOtherWindow) { + PRE_CancelWhileSigningInWithNoOtherWindow) { ASSERT_EQ(1u, BrowserList::GetInstance()->size()); Profile* profile_to_cancel = StartDiceSignIn(); base::FilePath profile_to_cancel_path = profile_to_cancel->GetPath(); @@ -853,17 +859,30 @@ widget()->CloseWithReason(views::Widget::ClosedReason::kCloseButtonClicked); WaitForPickerClosed(); - // The profile entry is deleted. + // The profile entry is not yet deleted when Chrome is shutting down, but it + // will be deleted at next startup since it is an ephemeral profile. ProfileAttributesEntry* entry = g_browser_process->profile_manager() ->GetProfileAttributesStorage() .GetProfileAttributesWithPath(profile_to_cancel_path); - EXPECT_EQ(entry, nullptr); + EXPECT_NE(entry, nullptr); + EXPECT_TRUE(entry->IsEphemeral()); + ASSERT_EQ(2u, g_browser_process->profile_manager() + ->GetProfileAttributesStorage() + .GetNumberOfProfiles()); // Still no browser window is open. EXPECT_EQ(0u, BrowserList::GetInstance()->size()); } +IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest, + CancelWhileSigningInWithNoOtherWindow) { + // There is only one profile left. + ASSERT_EQ(1u, g_browser_process->profile_manager() + ->GetProfileAttributesStorage() + .GetNumberOfProfiles()); +} + // Tests dice-specific logic for keeping track of the new profile color. IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest, CreateSignedInProfileDiceReenter) { @@ -1806,12 +1825,14 @@ EXPECT_EQ(ProfilePicker::GetSwitchProfilePath(), other_path); // Simulate clicking on the cancel button. + ProfileDeletionObserver observer; ProfilePickerHandler* handler = profile_picker_handler(); base::Value::List args; handler->HandleCancelProfileSwitch(args); // Check expectations when the profile creation flow is done. WaitForPickerClosed(); + observer.Wait(); // Only one browser should be displayed. EXPECT_EQ(BrowserList::GetInstance()->size(), 1u); @@ -2131,14 +2152,8 @@ EXPECT_FALSE(new_browser->signin_view_controller()->ShowsModalDialog()); } -// TODO(crbug.com/1367031): Test is flaky on Linux and macOS -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) -#define MAYBE_CancelLocalProfileCreation DISABLED_CancelLocalProfileCreation -#else -#define MAYBE_CancelLocalProfileCreation CancelLocalProfileCreation -#endif IN_PROC_BROWSER_TEST_F(ProfilePickerLocalProfileCreationDialogBrowserTest, - MAYBE_CancelLocalProfileCreation) { + CancelLocalProfileCreation) { ASSERT_EQ(1u, BrowserList::GetInstance()->size()); ASSERT_EQ(1u, g_browser_process->profile_manager() ->GetProfileAttributesStorage() @@ -2179,8 +2194,9 @@ // Simulate clicking the "Delete profile" button on the profile customization // dialog. + ProfileDeletionObserver observer; DeleteLocalProfile(dialog_web_contents); - ui_test_utils::WaitForBrowserToClose(new_browser); + observer.Wait(); ASSERT_EQ(1u, g_browser_process->profile_manager() ->GetProfileAttributesStorage()
diff --git a/chrome/browser/ui/views/qrcode_generator/qrcode_generator_icon_view.cc b/chrome/browser/ui/views/qrcode_generator/qrcode_generator_icon_view.cc index fed1231..c661263 100644 --- a/chrome/browser/ui/views/qrcode_generator/qrcode_generator_icon_view.cc +++ b/chrome/browser/ui/views/qrcode_generator/qrcode_generator_icon_view.cc
@@ -31,6 +31,9 @@ bubble_requested_(false) { SetVisible(false); SetLabel(l10n_util::GetStringUTF16(IDS_OMNIBOX_QRCODE_GENERATOR_ICON_LABEL)); + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringUTF16(IDS_OMNIBOX_QRCODE_GENERATOR_ICON_TOOLTIP)); } QRCodeGeneratorIconView::~QRCodeGeneratorIconView() = default; @@ -98,11 +101,6 @@ return kQrcodeGeneratorIcon; } -std::u16string QRCodeGeneratorIconView::GetTextForTooltipAndAccessibleName() - const { - return l10n_util::GetStringUTF16(IDS_OMNIBOX_QRCODE_GENERATOR_ICON_TOOLTIP); -} - bool QRCodeGeneratorIconView::ShouldShowLabel() const { return false; }
diff --git a/chrome/browser/ui/views/qrcode_generator/qrcode_generator_icon_view.h b/chrome/browser/ui/views/qrcode_generator/qrcode_generator_icon_view.h index 355ca91..78f0542 100644 --- a/chrome/browser/ui/views/qrcode_generator/qrcode_generator_icon_view.h +++ b/chrome/browser/ui/views/qrcode_generator/qrcode_generator_icon_view.h
@@ -28,7 +28,6 @@ // PageActionIconView: views::BubbleDialogDelegate* GetBubble() const override; void UpdateImpl() override; - std::u16string GetTextForTooltipAndAccessibleName() const override; bool ShouldShowLabel() const override; protected:
diff --git a/chrome/browser/ui/views/reader_mode/reader_mode_icon_view.cc b/chrome/browser/ui/views/reader_mode/reader_mode_icon_view.cc index 835e14c..4659d67 100644 --- a/chrome/browser/ui/views/reader_mode/reader_mode_icon_view.cc +++ b/chrome/browser/ui/views/reader_mode/reader_mode_icon_view.cc
@@ -51,7 +51,12 @@ icon_label_bubble_delegate, page_action_icon_delegate, "ReaderMode"), - pref_service_(pref_service) {} + pref_service_(pref_service) { + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringUTF16(GetActive() ? IDS_EXIT_DISTILLED_PAGE + : IDS_DISTILL_PAGE)); +} ReaderModeIconView::~ReaderModeIconView() { content::WebContents* contents = web_contents(); @@ -123,6 +128,9 @@ SetActive(false); } + SetAccessibleName(l10n_util::GetStringUTF16( + GetActive() ? IDS_EXIT_DISTILLED_PAGE : IDS_DISTILL_PAGE)); + // Notify the icon when navigation to and from a distilled page occurs so that // it can hide the inkdrop. Observe(contents); @@ -132,11 +140,6 @@ return GetActive() ? kReaderModeIcon : kReaderModeDisabledIcon; } -std::u16string ReaderModeIconView::GetTextForTooltipAndAccessibleName() const { - return l10n_util::GetStringUTF16(GetActive() ? IDS_EXIT_DISTILLED_PAGE - : IDS_DISTILL_PAGE); -} - // TODO(gilmanmh): Consider displaying a bubble the first time a user // activates the icon to explain what Reader Mode is. views::BubbleDialogDelegate* ReaderModeIconView::GetBubble() const {
diff --git a/chrome/browser/ui/views/reader_mode/reader_mode_icon_view.h b/chrome/browser/ui/views/reader_mode/reader_mode_icon_view.h index e807caf..8f20096 100644 --- a/chrome/browser/ui/views/reader_mode/reader_mode_icon_view.h +++ b/chrome/browser/ui/views/reader_mode/reader_mode_icon_view.h
@@ -5,8 +5,6 @@ #ifndef CHROME_BROWSER_UI_VIEWS_READER_MODE_READER_MODE_ICON_VIEW_H_ #define CHROME_BROWSER_UI_VIEWS_READER_MODE_READER_MODE_ICON_VIEW_H_ -#include <string> - #include "base/memory/raw_ptr.h" #include "chrome/browser/ui/views/page_action/page_action_icon_view.h" #include "components/dom_distiller/content/browser/distillable_page_utils.h" @@ -42,7 +40,6 @@ // PageActionIconView overrides: void UpdateImpl() override; const gfx::VectorIcon& GetVectorIcon() const override; - std::u16string GetTextForTooltipAndAccessibleName() const override; void OnExecuting(PageActionIconView::ExecuteSource execute_source) override; // GetBubble() is required by PageActionIconView; however, the icon
diff --git a/chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_icon_view.cc b/chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_icon_view.cc index 3d1ac62..eb1ab65 100644 --- a/chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_icon_view.cc +++ b/chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_icon_view.cc
@@ -34,6 +34,9 @@ SetVisible(false); SetLabel(l10n_util::GetStringUTF16(IDS_OMNIBOX_ICON_SEND_TAB_TO_SELF)); SetUpForInOutAnimation(); + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringUTF16(IDS_OMNIBOX_TOOLTIP_SEND_TAB_TO_SELF)); } SendTabToSelfIconView::~SendTabToSelfIconView() {} @@ -110,11 +113,6 @@ return kLaptopAndSmartphoneIcon; } -std::u16string SendTabToSelfIconView::GetTextForTooltipAndAccessibleName() - const { - return l10n_util::GetStringUTF16(IDS_OMNIBOX_TOOLTIP_SEND_TAB_TO_SELF); -} - SendTabToSelfBubbleController* SendTabToSelfIconView::GetController() const { content::WebContents* web_contents = GetWebContents(); if (!web_contents) {
diff --git a/chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_icon_view.h b/chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_icon_view.h index b05a622..4387e95 100644 --- a/chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_icon_view.h +++ b/chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_icon_view.h
@@ -30,7 +30,6 @@ // PageActionIconView: views::BubbleDialogDelegate* GetBubble() const override; void UpdateImpl() override; - std::u16string GetTextForTooltipAndAccessibleName() const override; // gfx::AnimationDelegate: void AnimationProgressed(const gfx::Animation* animation) override;
diff --git a/chrome/browser/ui/views/sharing/sharing_icon_view.cc b/chrome/browser/ui/views/sharing/sharing_icon_view.cc index 4c0c9180..591f6f18 100644 --- a/chrome/browser/ui/views/sharing/sharing_icon_view.cc +++ b/chrome/browser/ui/views/sharing/sharing_icon_view.cc
@@ -69,6 +69,8 @@ if (!controller) return; + SetAccessibleName(controller->GetTextForTooltipAndAccessibleName()); + // To ensure that we reset error icon badge. if (!GetVisible()) { should_show_error_ = controller->HasSendFailed(); @@ -165,12 +167,6 @@ return controller ? controller->GetVectorIcon() : gfx::kNoneIcon; } -std::u16string SharingIconView::GetTextForTooltipAndAccessibleName() const { - auto* controller = GetController(); - return controller ? controller->GetTextForTooltipAndAccessibleName() - : std::u16string(); -} - void SharingIconView::GetAccessibleNodeData(ui::AXNodeData* node_data) { auto* controller = GetController(); if (controller && !controller->HasAccessibleUi()) {
diff --git a/chrome/browser/ui/views/sharing/sharing_icon_view.h b/chrome/browser/ui/views/sharing/sharing_icon_view.h index 3f0f6d9..f3d2b1b 100644 --- a/chrome/browser/ui/views/sharing/sharing_icon_view.h +++ b/chrome/browser/ui/views/sharing/sharing_icon_view.h
@@ -46,7 +46,6 @@ views::BubbleDialogDelegate* GetBubble() const override; void UpdateImpl() override; const gfx::VectorIcon& GetVectorIcon() const override; - std::u16string GetTextForTooltipAndAccessibleName() const override; void GetAccessibleNodeData(ui::AXNodeData* node_data) override; // gfx::AnimationDelegate:
diff --git a/chrome/browser/ui/views/sharing_hub/sharing_hub_icon_view.cc b/chrome/browser/ui/views/sharing_hub/sharing_hub_icon_view.cc index 4dc922ce..b69c305 100644 --- a/chrome/browser/ui/views/sharing_hub/sharing_hub_icon_view.cc +++ b/chrome/browser/ui/views/sharing_hub/sharing_hub_icon_view.cc
@@ -60,6 +60,9 @@ SetLabel( l10n_util::GetStringUTF16(IDS_BROWSER_SHARING_OMNIBOX_SENDING_LABEL)); SetUpForInOutAnimation(); + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringUTF16(IDS_SHARING_HUB_TOOLTIP)); } SharingHubIconView::~SharingHubIconView() = default; @@ -104,10 +107,6 @@ return GetSharingHubVectorIcon(); } -std::u16string SharingHubIconView::GetTextForTooltipAndAccessibleName() const { - return l10n_util::GetStringUTF16(IDS_SHARING_HUB_TOOLTIP); -} - SharingHubBubbleController* SharingHubIconView::GetController() const { content::WebContents* web_contents = GetWebContents(); if (!web_contents) {
diff --git a/chrome/browser/ui/views/sharing_hub/sharing_hub_icon_view.h b/chrome/browser/ui/views/sharing_hub/sharing_hub_icon_view.h index d06606a..e13ceda 100644 --- a/chrome/browser/ui/views/sharing_hub/sharing_hub_icon_view.h +++ b/chrome/browser/ui/views/sharing_hub/sharing_hub_icon_view.h
@@ -30,7 +30,6 @@ // PageActionIconView: views::BubbleDialogDelegate* GetBubble() const override; void UpdateImpl() override; - std::u16string GetTextForTooltipAndAccessibleName() const override; protected: // PageActionIconView:
diff --git a/chrome/browser/ui/views/side_search/side_search_icon_view.cc b/chrome/browser/ui/views/side_search/side_search_icon_view.cc index 605dca17..0fd3360 100644 --- a/chrome/browser/ui/views/side_search/side_search_icon_view.cc +++ b/chrome/browser/ui/views/side_search/side_search_icon_view.cc
@@ -51,6 +51,10 @@ SetUpForInOutAnimation(); SetPaintLabelOverSolidBackground(true); browser_->tab_strip_model()->AddObserver(this); + SetAccessibilityProperties( + /*role*/ absl::nullopt, + l10n_util::GetStringUTF16( + IDS_TOOLTIP_SIDE_SEARCH_TOOLBAR_BUTTON_NOT_ACTIVATED)); } SideSearchIconView::~SideSearchIconView() { @@ -159,11 +163,6 @@ ->GetSizedIconImage(size); } -std::u16string SideSearchIconView::GetTextForTooltipAndAccessibleName() const { - return l10n_util::GetStringUTF16( - IDS_TOOLTIP_SIDE_SEARCH_TOOLBAR_BUTTON_NOT_ACTIVATED); -} - void SideSearchIconView::AnimationProgressed(const gfx::Animation* animation) { PageActionIconView::AnimationProgressed(animation); // When the label is fully revealed pause the animation for
diff --git a/chrome/browser/ui/views/side_search/side_search_icon_view.h b/chrome/browser/ui/views/side_search/side_search_icon_view.h index 49ee2bc..ccc0f1d 100644 --- a/chrome/browser/ui/views/side_search/side_search_icon_view.h +++ b/chrome/browser/ui/views/side_search/side_search_icon_view.h
@@ -46,7 +46,6 @@ views::BubbleDialogDelegate* GetBubble() const override; const gfx::VectorIcon& GetVectorIcon() const override; ui::ImageModel GetSizedIconImage(int size) const override; - std::u16string GetTextForTooltipAndAccessibleName() const override; void AnimationProgressed(const gfx::Animation* animation) override; private:
diff --git a/chrome/browser/ui/views/site_data/page_specific_site_data_dialog_interactive_uitest.cc b/chrome/browser/ui/views/site_data/page_specific_site_data_dialog_interactive_uitest.cc index a1610e4..0c8404d 100644 --- a/chrome/browser/ui/views/site_data/page_specific_site_data_dialog_interactive_uitest.cc +++ b/chrome/browser/ui/views/site_data/page_specific_site_data_dialog_interactive_uitest.cc
@@ -37,7 +37,6 @@ #include "content/public/browser/render_frame_host.h" #include "content/public/common/content_features.h" #include "content/public/test/browser_test.h" -#include "content/public/test/browser_test_utils.h" #include "net/dns/mock_host_resolver.h" #include "third_party/blink/public/common/features.h" #include "ui/base/interaction/element_identifier.h" @@ -57,11 +56,45 @@ namespace { DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE(kWebContentsElementId); +DEFINE_LOCAL_CUSTOM_ELEMENT_EVENT_TYPE(kCookieAccessedEvent); const char kFirstPartyAllowedRow[] = "FirstPartyAllowedRow"; const char kThirdPartyBlockedRow[] = "ThirdPartyBlockedRow"; const char kOnlyPartitionedRow[] = "OnlyPartitionedRow"; const char kMixedPartitionedRow[] = "MixedPartitionedRow"; const char kCookiesDialogHistogramName[] = "Privacy.CookiesInUseDialog.Action"; + +class CookieChangeObserver : public content::WebContentsObserver { + public: + CookieChangeObserver(content::WebContents* web_contents, + int num_expected_calls) + : content::WebContentsObserver(web_contents), + num_expected_calls_(num_expected_calls) {} + ~CookieChangeObserver() override = default; + + private: + void OnCookiesAccessed(content::RenderFrameHost* render_frame_host, + const content::CookieAccessDetails& details) override { + OnCookieAccessed(); + } + void OnCookiesAccessed(content::NavigationHandle* navigation, + const content::CookieAccessDetails& details) override { + OnCookieAccessed(); + } + + void OnCookieAccessed() { + if (++num_seen_ == num_expected_calls_) { + auto* const el = + ui::ElementTracker::GetElementTracker()->GetElementInAnyContext( + kBrowserViewElementId); + ui::ElementTracker::GetFrameworkDelegate()->NotifyCustomEvent( + el, kCookieAccessedEvent); + } + } + + int num_seen_ = 0; + const int num_expected_calls_; +}; + } // namespace class PageSpecificSiteDataDialogInteractiveUiTest @@ -117,21 +150,15 @@ // Returns a common sequence of setup steps for all tests. MultiStep NavigateAndOpenDialog( ui::ElementIdentifier section_id, - content::CookieChangeObserver* cookie_observer = nullptr) { + CookieChangeObserver* cookie_observer = nullptr) { const GURL third_party_cookie_page_url = https_server()->GetURL("a.test", GetTestPageRelativeURL()); return Steps( InstrumentTab(kWebContentsElementId), NavigateWebContents(kWebContentsElementId, third_party_cookie_page_url), - Do(base::BindOnce( - [](content::CookieChangeObserver* cookie_observer) { - /* TODO(jam): enable this after fixing. - if (cookie_observer) { - cookie_observer->Wait(); - } - */ - }, - cookie_observer)), + cookie_observer + ? Steps(WaitForEvent(kBrowserViewElementId, kCookieAccessedEvent)) + : MultiStep(), PressButton(kLocationIconElementId), PressButton(PageInfoMainView::kCookieButtonElementId), PressButton(PageInfoCookiesContentView::kCookieDialogButton), @@ -201,7 +228,7 @@ IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogInteractiveUiTest, FirstPartyAllowed) { - content::CookieChangeObserver observer( + CookieChangeObserver observer( browser()->tab_strip_model()->GetActiveWebContents(), 6); RunTestSequenceInContext( context(), @@ -240,7 +267,7 @@ IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogInteractiveUiTest, ThirdPartyBlocked) { - content::CookieChangeObserver observer( + CookieChangeObserver observer( browser()->tab_strip_model()->GetActiveWebContents(), 6); RunTestSequenceInContext( context(), @@ -278,7 +305,7 @@ IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogInteractiveUiTest, OnlyPartitionedBlockedThirdPartyCookies) { - content::CookieChangeObserver observer( + CookieChangeObserver observer( browser()->tab_strip_model()->GetActiveWebContents(), 6); RunTestSequenceInContext( context(), @@ -311,7 +338,7 @@ IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogInteractiveUiTest, MixedPartitionedBlockedThirdPartyCookies) { - content::CookieChangeObserver observer( + CookieChangeObserver observer( browser()->tab_strip_model()->GetActiveWebContents(), 6); RunTestSequenceInContext( context(),
diff --git a/chrome/browser/ui/views/translate/translate_icon_view.cc b/chrome/browser/ui/views/translate/translate_icon_view.cc index dd78dc54..7478c00 100644 --- a/chrome/browser/ui/views/translate/translate_icon_view.cc +++ b/chrome/browser/ui/views/translate/translate_icon_view.cc
@@ -32,6 +32,8 @@ page_action_icon_delegate, "Translate") { SetID(VIEW_ID_TRANSLATE_BUTTON); + SetAccessibilityProperties(/*role*/ absl::nullopt, + l10n_util::GetStringUTF16(IDS_TOOLTIP_TRANSLATE)); } TranslateIconView::~TranslateIconView() = default; @@ -98,9 +100,5 @@ return kTranslateIcon; } -std::u16string TranslateIconView::GetTextForTooltipAndAccessibleName() const { - return l10n_util::GetStringUTF16(IDS_TOOLTIP_TRANSLATE); -} - BEGIN_METADATA(TranslateIconView, PageActionIconView) END_METADATA
diff --git a/chrome/browser/ui/views/translate/translate_icon_view.h b/chrome/browser/ui/views/translate/translate_icon_view.h index aa74cd9..bb870c9 100644 --- a/chrome/browser/ui/views/translate/translate_icon_view.h +++ b/chrome/browser/ui/views/translate/translate_icon_view.h
@@ -31,7 +31,6 @@ // PageActionIconView: void OnExecuting(PageActionIconView::ExecuteSource execute_source) override; const gfx::VectorIcon& GetVectorIcon() const override; - std::u16string GetTextForTooltipAndAccessibleName() const override; private: // Returns the Partial Translate bubble instance for the Translate icon.
diff --git a/chrome/browser/ui/views/translate/translate_icon_view_interactive_uitest.cc b/chrome/browser/ui/views/translate/translate_icon_view_interactive_uitest.cc index d721813b5..37809ef7 100644 --- a/chrome/browser/ui/views/translate/translate_icon_view_interactive_uitest.cc +++ b/chrome/browser/ui/views/translate/translate_icon_view_interactive_uitest.cc
@@ -10,10 +10,12 @@ #include "chrome/browser/ui/views/page_action/page_action_icon_view.h" #include "chrome/browser/ui/views/translate/partial_translate_bubble_view.h" #include "chrome/browser/ui/views/translate/translate_bubble_controller.h" +#include "chrome/grit/generated_resources.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/interactive_test_utils.h" #include "components/translate/core/browser/translate_manager.h" #include "content/public/test/browser_test.h" +#include "ui/base/l10n/l10n_util.h" #include "ui/base/test/ui_controls.h" namespace translate { @@ -85,4 +87,11 @@ EXPECT_THAT(translate_icon->GetBubble(), ::testing::IsNull()); } +IN_PROC_BROWSER_TEST_F(TranslateIconViewTest, IconViewAccessibleName) { + EXPECT_EQ(GetTranslateIcon()->GetAccessibleName(), + l10n_util::GetStringUTF16(IDS_TOOLTIP_TRANSLATE)); + EXPECT_EQ(GetTranslateIcon()->GetTextForTooltipAndAccessibleName(), + l10n_util::GetStringUTF16(IDS_TOOLTIP_TRANSLATE)); +} + } // namespace translate
diff --git a/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload.mojom b/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload.mojom index 14c3fa1..12478b7 100644 --- a/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload.mojom +++ b/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload.mojom
@@ -7,7 +7,6 @@ // The selected action when the user closes the dialog. enum UserAction { kCancel, - kSetUpGoogleDrive, kSetUpOneDrive, kUploadToGoogleDrive, kUploadToOneDrive, @@ -21,8 +20,6 @@ kFileHandlerDialog, // Set up OneDrive (multi-page). kOneDriveSetup, - // Set up Google Drive (one-page confirmation screen). - kGoogleDriveSetup, // Confirm that the user wants to move the file to OneDrive. kMoveConfirmationOneDrive, // Confirm that the user wants to move the file to Google Drive.
diff --git a/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload_dialog.cc b/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload_dialog.cc index 42cc9e6..0888d83a 100644 --- a/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload_dialog.cc +++ b/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload_dialog.cc
@@ -710,9 +710,6 @@ StartUpload(); } else if (user_response == kUserActionUploadToOneDrive) { StartUpload(); - } else if (user_response == kUserActionSetUpGoogleDrive) { - cloud_provider_ = CloudProvider::kGoogleDrive; - InitAndShowDialog(mojom::DialogPage::kGoogleDriveSetup); } else if (user_response == kUserActionSetUpOneDrive) { cloud_provider_ = CloudProvider::kOneDrive; InitAndShowDialog(mojom::DialogPage::kOneDriveSetup); @@ -895,9 +892,6 @@ const int kDialogHeightForFileHandlerDialog = 475; const int kDialogHeightForFileHandlerDialogNoLocalApp = 311; -const int kDialogWidthForDriveSetup = 512; -const int kDialogHeightForDriveSetup = 220; - const int kDialogWidthForMoveConfirmation = 512; const int kDialogHeightForMoveConfirmationWithCheckbox = 500; @@ -918,11 +912,6 @@ size->set_height(kDialogHeightForOneDriveSetup); return; } - case mojom::DialogPage::kGoogleDriveSetup: { - size->set_width(kDialogWidthForDriveSetup); - size->set_height(kDialogHeightForDriveSetup); - return; - } case mojom::DialogPage::kMoveConfirmationGoogleDrive: case mojom::DialogPage::kMoveConfirmationOneDrive: { size->set_width(kDialogWidthForMoveConfirmation);
diff --git a/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload_dialog.h b/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload_dialog.h index 0eed892a..0868d00 100644 --- a/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload_dialog.h +++ b/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload_dialog.h
@@ -44,7 +44,6 @@ // The string conversions of ash::cloud_upload::mojom::UserAction. const char kUserActionCancel[] = "cancel"; -const char kUserActionSetUpGoogleDrive[] = "setup-drive"; const char kUserActionSetUpOneDrive[] = "setup-onedrive"; const char kUserActionUploadToGoogleDrive[] = "upload-drive"; const char kUserActionUploadToOneDrive[] = "upload-onedrive";
diff --git a/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload_ui.cc b/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload_ui.cc index 44ffb890..bd995d39 100644 --- a/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload_ui.cc +++ b/chrome/browser/ui/webui/ash/cloud_upload/cloud_upload_ui.cc
@@ -75,9 +75,6 @@ case mojom::UserAction::kCancel: args.Append(kUserActionCancel); break; - case mojom::UserAction::kSetUpGoogleDrive: - args.Append(kUserActionSetUpGoogleDrive); - break; case mojom::UserAction::kSetUpOneDrive: args.Append(kUserActionSetUpOneDrive); break;
diff --git a/chrome/browser/ui/webui/ash/cros_components_browsertest.cc b/chrome/browser/ui/webui/ash/cros_components_browsertest.cc index 6dbc470..13d92301 100644 --- a/chrome/browser/ui/webui/ash/cros_components_browsertest.cc +++ b/chrome/browser/ui/webui/ash/cros_components_browsertest.cc
@@ -22,41 +22,6 @@ static constexpr const char kTestHost[] = "test-host"; static constexpr const char kTestUrl[] = "chrome://test-host"; -// TODO(clamclamyan): Replace import map once @material imports are rewritten. -static constexpr const char kCrosComponentsHtml[] = R"( -<script type="importmap"> -{ - "imports": { - "lit": "chrome://resources/mwc/lit/index.js", - "@material/": "chrome://resources/mwc/@material/", - "chrome://resources/mwc/lit/index.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/decorators.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directive.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/async-append.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/async-replace.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/cache.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/choose.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/class-map.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/guard.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/if-defined.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/join.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/keyed.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/live.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/map.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/range.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/ref.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/repeat.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/style-map.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/template-content.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/unsafe-html.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/unsafe-svg.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/until.js": "chrome://resources/mwc/lit/index.js", - "chrome://resources/mwc/lit/directives/when.js": "chrome://resources/mwc/lit/index.js" - } -} -</script> -)"; - // WebUIController that registers a URLDataSource which serves an html page with // our import map and a Trusted Types CSP that allows us to inject script tags. class CrosComponentsUI : public content::WebUIController { @@ -70,9 +35,7 @@ base::BindRepeating( [](const std::string& path, content::WebUIDataSource::GotDataCallback callback) { - base::RefCountedString* ref_contents = - new base::RefCountedString(kCrosComponentsHtml); - std::move(callback).Run(ref_contents); + std::move(callback).Run(new base::RefCountedString("")); })); source->OverrideContentSecurityPolicy(
diff --git a/chrome/browser/ui/webui/ash/login/oobe_ui.cc b/chrome/browser/ui/webui/ash/login/oobe_ui.cc index 6c7eb85..5a070ebb 100644 --- a/chrome/browser/ui/webui/ash/login/oobe_ui.cc +++ b/chrome/browser/ui/webui/ash/login/oobe_ui.cc
@@ -181,6 +181,9 @@ constexpr char kLogo24PX2XSvgPath[] = "logo_24px-2x.svg"; constexpr char kSyncConsentIcons[] = "sync-consent-icons.html"; constexpr char kSyncConsentIconsJs[] = "sync-consent-icons.m.js"; +// Project Simon TODO(b/269117729) - Rename with final names. +constexpr char kFirstAnimation[] = "internal_assets/first_animation.json"; +constexpr char kWelcomeBackdrop[] = "internal_assets/welcome_backdrop.svg"; #endif // Adds various product logo resources. @@ -194,6 +197,17 @@ source->AddResourcePath(kProductLogoPath, IDR_PRODUCT_LOGO_64); } +void AddProjectSimonResources(content::WebUIDataSource* source) { +#if BUILDFLAG(GOOGLE_CHROME_BRANDING) + source->AddResourcePath(kFirstAnimation, IDR_CROS_OOBE_FIRST_ANIMATION); + source->AddResourcePath(kWelcomeBackdrop, IDR_CROS_OOBE_WELCOME_BACKDROP); + auto product_name = + ui::ResourceBundle::GetSharedInstance().GetRawDataResource( + IDR_CROS_OOBE_PRODUCT_NAME); + source->AddString("kProjectSimonProductName", std::string{product_name}); +#endif +} + void AddSyncConsentResources(content::WebUIDataSource* source) { #if BUILDFLAG(GOOGLE_CHROME_BRANDING) source->AddResourcePath(kSyncConsentIcons, @@ -286,6 +300,7 @@ // Configure shared resources AddProductLogoResources(source); + AddProjectSimonResources(source); quick_unlock::AddFingerprintResources(source); AddSyncConsentResources(source);
diff --git a/chrome/browser/ui/webui/ash/sync/os_sync_handler.cc b/chrome/browser/ui/webui/ash/sync/os_sync_handler.cc index c1a052c..761cc2a 100644 --- a/chrome/browser/ui/webui/ash/sync/os_sync_handler.cc +++ b/chrome/browser/ui/webui/ash/sync/os_sync_handler.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/ui/webui/ash/sync/os_sync_handler.h" +#include "ash/public/cpp/new_window_delegate.h" #include "base/auto_reset.h" #include "base/check_op.h" #include "base/functional/bind.h" @@ -11,12 +12,14 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/sync_service_factory.h" #include "chrome/browser/ui/webui/settings/ash/pref_names.h" +#include "chrome/common/webui_url_constants.h" #include "components/prefs/pref_service.h" #include "components/sync/base/pref_names.h" #include "components/sync/base/user_selectable_type.h" #include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_user_settings.h" #include "content/public/browser/web_ui.h" +#include "url/gurl.h" using syncer::SyncService; using syncer::SyncUserSettings; @@ -54,6 +57,10 @@ "SetOsSyncDatatypes", base::BindRepeating(&OSSyncHandler::HandleSetOsSyncDatatypes, base::Unretained(this))); + web_ui()->RegisterMessageCallback( + "OpenBrowserSyncSettings", + base::BindRepeating(&OSSyncHandler::HandleOpenBrowserSyncSettings, + base::Unretained(this))); } void OSSyncHandler::OnJavascriptAllowed() { @@ -84,6 +91,14 @@ // TODO(https://crbug.com/1278325): Remove this. } +void OSSyncHandler::HandleOpenBrowserSyncSettings( + const base::Value::List& args) { + ash::NewWindowDelegate::GetPrimary()->OpenUrl( + GURL(chrome::kChromeUISettingsURL).Resolve(chrome::kSyncSetupSubPage), + ash::NewWindowDelegate::OpenUrlFrom::kUserInteraction, + ash::NewWindowDelegate::Disposition::kSwitchToTab); +} + void OSSyncHandler::HandleSetOsSyncDatatypes(const base::Value::List& args) { CHECK_EQ(1u, args.size()); const base::Value& result_value = args[0]; @@ -125,10 +140,6 @@ // TODO(jamescook): Add metrics for selected types. } -void OSSyncHandler::SetWebUIForTest(content::WebUI* web_ui) { - set_web_ui(web_ui); -} - void OSSyncHandler::PushSyncPrefs() { syncer::SyncService* service = GetSyncService(); // The sync service may be nullptr if it has been just disabled by policy.
diff --git a/chrome/browser/ui/webui/ash/sync/os_sync_handler.h b/chrome/browser/ui/webui/ash/sync/os_sync_handler.h index 73481e6..e224211 100644 --- a/chrome/browser/ui/webui/ash/sync/os_sync_handler.h +++ b/chrome/browser/ui/webui/ash/sync/os_sync_handler.h
@@ -42,8 +42,7 @@ void HandleDidNavigateAwayFromOsSyncPage(const base::Value::List& args); void HandleOsSyncPrefsDispatch(const base::Value::List& args); void HandleSetOsSyncDatatypes(const base::Value::List& args); - - void SetWebUIForTest(content::WebUI* web_ui); + void HandleOpenBrowserSyncSettings(const base::Value::List& args); private: // Pushes the updated sync prefs to JavaScript.
diff --git a/chrome/browser/ui/webui/ash/sync/os_sync_handler_unittest.cc b/chrome/browser/ui/webui/ash/sync/os_sync_handler_unittest.cc index c0f0e9bf..db2a560 100644 --- a/chrome/browser/ui/webui/ash/sync/os_sync_handler_unittest.cc +++ b/chrome/browser/ui/webui/ash/sync/os_sync_handler_unittest.cc
@@ -7,11 +7,13 @@ #include <memory> #include <string> +#include "ash/public/cpp/test/test_new_window_delegate.h" #include "base/functional/bind.h" #include "base/values.h" #include "chrome/browser/signin/identity_test_environment_profile_adaptor.h" #include "chrome/browser/sync/sync_service_factory.h" #include "chrome/browser/ui/webui/settings/ash/pref_names.h" +#include "chrome/common/webui_url_constants.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/test_chrome_web_ui_controller_factory.h" #include "components/keyed_service/core/keyed_service.h" @@ -22,6 +24,7 @@ #include "content/public/browser/web_ui_controller.h" #include "content/public/test/test_web_ui.h" #include "testing/gmock/include/gmock/gmock-matchers.h" +#include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" using content::TestWebUI; @@ -100,6 +103,15 @@ } }; +class MockNewWindowDelegate : public testing::NiceMock<TestNewWindowDelegate> { + public: + // TestNewWindowDelegate: + MOCK_METHOD(void, + OpenUrl, + (const GURL& url, OpenUrlFrom from, Disposition disposition), + (override)); +}; + class OsSyncHandlerTest : public ChromeRenderViewHostTestHarness { protected: OsSyncHandlerTest() = default; @@ -119,13 +131,23 @@ profile(), base::BindRepeating(&BuildTestSyncService))); user_settings_ = sync_service_->GetUserSettings(); - handler_ = std::make_unique<OSSyncHandler>(profile()); - handler_->SetWebUIForTest(&web_ui_); - web_ui_.set_web_contents(web_contents()); + auto handler = std::make_unique<OSSyncHandler>(profile()); + handler_ = handler.get(); + web_ui_ = std::make_unique<content::TestWebUI>(); + web_ui_->AddMessageHandler(std::move(handler)); + web_ui_->set_web_contents(web_contents()); + + // Initialize NewWindowDelegate things. + auto instance = std::make_unique<MockNewWindowDelegate>(); + auto primary = std::make_unique<MockNewWindowDelegate>(); + new_window_delegate_primary_ = primary.get(); + new_window_provider_ = std::make_unique<TestNewWindowDelegateProvider>( + std::move(instance), std::move(primary)); } void TearDown() override { - handler_.reset(); + new_window_provider_.reset(); + web_ui_.reset(); identity_test_env_adaptor_.reset(); ChromeRenderViewHostTestHarness::TearDown(); } @@ -138,7 +160,7 @@ // Expects that an "os-sync-prefs-changed" event was sent to the WebUI and // returns the data passed to that event. base::Value::Dict ExpectOsSyncPrefsSent() { - const TestWebUI::CallData& call_data = *web_ui_.call_data().back(); + const TestWebUI::CallData& call_data = *web_ui_->call_data().back(); EXPECT_EQ("cr.webUIListenerCallback", call_data.function_name()); EXPECT_TRUE(call_data.arg1()); @@ -167,17 +189,19 @@ syncer::SyncUserSettings* user_settings_ = nullptr; std::unique_ptr<IdentityTestEnvironmentProfileAdaptor> identity_test_env_adaptor_; - TestWebUI web_ui_; + std::unique_ptr<TestWebUI> web_ui_; TestWebUIProvider test_web_ui_provider_; std::unique_ptr<TestChromeWebUIControllerFactory> test_web_ui_factory_; - std::unique_ptr<OSSyncHandler> handler_; + OSSyncHandler* handler_; + MockNewWindowDelegate* new_window_delegate_primary_; + std::unique_ptr<TestNewWindowDelegateProvider> new_window_provider_; }; TEST_F(OsSyncHandlerTest, OsSyncPrefsSentOnNavigateToPage) { handler_->HandleDidNavigateToOsSyncPage(base::Value::List()); - ASSERT_EQ(1U, web_ui_.call_data().size()); - const TestWebUI::CallData& call_data = *web_ui_.call_data().back(); + ASSERT_EQ(1U, web_ui_->call_data().size()); + const TestWebUI::CallData& call_data = *web_ui_->call_data().back(); std::string event_name = call_data.arg1()->GetString(); EXPECT_EQ(event_name, "os-sync-prefs-changed"); @@ -191,15 +215,15 @@ handler_->HandleDidNavigateToOsSyncPage(base::Value::List()); // No data is sent yet, because the engine is not initialized. - EXPECT_EQ(0U, web_ui_.call_data().size()); + EXPECT_EQ(0U, web_ui_->call_data().size()); // Now, act as if the SyncService has started up. sync_service_->SetTransportState(SyncService::TransportState::ACTIVE); NotifySyncStateChanged(); // Update for sync prefs is sent. - ASSERT_EQ(1U, web_ui_.call_data().size()); - const TestWebUI::CallData& call_data = *web_ui_.call_data().back(); + ASSERT_EQ(1U, web_ui_->call_data().size()); + const TestWebUI::CallData& call_data = *web_ui_->call_data().back(); std::string event_name = call_data.arg1()->GetString(); EXPECT_EQ(event_name, "os-sync-prefs-changed"); @@ -306,6 +330,17 @@ /*wallpaper_enabled=*/true); } +TEST_F(OsSyncHandlerTest, OpenBrowserSyncSettings) { + EXPECT_CALL( + *new_window_delegate_primary_, + OpenUrl( + GURL(chrome::kChromeUISettingsURL).Resolve(chrome::kSyncSetupSubPage), + ash::NewWindowDelegate::OpenUrlFrom::kUserInteraction, + ash::NewWindowDelegate::Disposition::kSwitchToTab)); + base::Value::List empty_args; + web_ui_->HandleReceivedMessage("OpenBrowserSyncSettings", empty_args); +} + } // namespace } // namespace ash
diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index 54a2c46..cc09e0be 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -216,6 +216,7 @@ #include "ash/webui/print_management/print_management_ui.h" #include "ash/webui/print_management/url_constants.h" #include "ash/webui/projector_app/public/cpp/projector_app_constants.h" // nogncheck +#include "ash/webui/projector_app/trusted_projector_annotator_ui.h" #include "ash/webui/projector_app/trusted_projector_ui.h" #include "ash/webui/scanning/scanning_ui.h" #include "ash/webui/scanning/url_constants.h" @@ -500,6 +501,13 @@ Profile::FromWebUI(web_ui)->GetPrefs()); } +template <> +WebUIController* NewWebUI<ash::TrustedProjectorAnnotatorUI>(WebUI* web_ui, + const GURL& url) { + return new ash::TrustedProjectorAnnotatorUI( + web_ui, url, Profile::FromWebUI(web_ui)->GetPrefs()); +} + void BindPrintManagement( Profile* profile, mojo::PendingReceiver< @@ -1029,6 +1037,10 @@ IsProjectorAppEnabled(profile)) { return &NewWebUI<ash::TrustedProjectorUI>; } + if (url.host_piece() == ash::kChromeUIProjectorAnnotatorHost && + IsProjectorAppEnabled(profile)) { + return &NewWebUI<ash::TrustedProjectorAnnotatorUI>; + } if (url.host_piece() == ash::eche_app::kChromeUIEcheAppHost && base::FeatureList::IsEnabled(ash::features::kEcheSWA)) { return &NewWebUI<ash::eche_app::EcheAppUI>;
diff --git a/chrome/browser/ui/webui/policy/policy_ui_browsertest.cc b/chrome/browser/ui/webui/policy/policy_ui_browsertest.cc index bb55d29..f3a187f 100644 --- a/chrome/browser/ui/webui/policy/policy_ui_browsertest.cc +++ b/chrome/browser/ui/webui/policy/policy_ui_browsertest.cc
@@ -181,7 +181,17 @@ #endif } +void InitPolicyCategory(base::Value::Dict& expected_dict, + const std::string& key, + const std::string& name) { + base::Value::Dict* dict = + expected_dict.EnsureDict("policyValues")->EnsureDict(key); + dict->Set("name", name); + dict->Set("policies", base::Value::Dict()); +} + void SetExpectedPolicy(base::Value::Dict& expected, + const std::string& category, const std::string& name, const std::string& level, const std::string& scope, @@ -190,8 +200,10 @@ const std::string& warning, bool ignored, const base::Value& value) { - base::Value::Dict* dict = - expected.EnsureDict("chromePolicies")->EnsureDict(name.c_str()); + base::Value::Dict* dict = expected.EnsureDict("policyValues") + ->EnsureDict(category) + ->EnsureDict("policies") + ->EnsureDict(name.c_str()); dict->Set("level", level); dict->Set("scope", scope); dict->Set("source", source); @@ -443,8 +455,10 @@ // Set policy values and generate expected dictionary. policy::PolicyMap values; base::Value::Dict expected_values; - + InitPolicyCategory(expected_values, "chrome", "Chrome Policies"); SetChromeMetaData(expected_values); + expected_values.FindDict("policyValues") + ->Set("extensions", base::Value::Dict()); base::Value::List popups_blocked_for_urls; popups_blocked_for_urls.Append("aaa"); @@ -453,17 +467,18 @@ values.Set(policy::key::kPopupsBlockedForUrls, policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_MACHINE, policy::POLICY_SOURCE_PLATFORM, base::Value(popups_blocked_for_urls.Clone()), nullptr); - SetExpectedPolicy(expected_values, policy::key::kPopupsBlockedForUrls, - "mandatory", "machine", "platform", std::string(), - std::string(), false, + SetExpectedPolicy(expected_values, "chrome", + policy::key::kPopupsBlockedForUrls, "mandatory", "machine", + "platform", std::string(), std::string(), false, base::Value(popups_blocked_for_urls.Clone())); values.Set(policy::key::kDefaultImagesSetting, policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_MACHINE, policy::POLICY_SOURCE_CLOUD, base::Value(2), nullptr); - SetExpectedPolicy(expected_values, policy::key::kDefaultImagesSetting, - "mandatory", "machine", "cloud", std::string(), - std::string(), false, base::Value(2)); + SetExpectedPolicy(expected_values, "chrome", + policy::key::kDefaultImagesSetting, "mandatory", "machine", + "cloud", std::string(), std::string(), false, + base::Value(2)); // This also checks that we save complex policies correctly. base::Value::Dict unknown_policy; @@ -475,19 +490,29 @@ values.Set(kUnknownPolicy, policy::POLICY_LEVEL_RECOMMENDED, policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, base::Value(unknown_policy.Clone()), nullptr); - SetExpectedPolicy(expected_values, kUnknownPolicy, "recommended", "user", - "cloud", l10n_util::GetStringUTF8(IDS_POLICY_UNKNOWN), - std::string(), false, - base::Value(std::move(unknown_policy))); + SetExpectedPolicy(expected_values, "chrome", kUnknownPolicy, "recommended", + "user", "cloud", + l10n_util::GetStringUTF8(IDS_POLICY_UNKNOWN), std::string(), + false, base::Value(std::move(unknown_policy))); - // Set the extension policies to an empty dictionary as we haven't added any - // such policies. - expected_values.Set("extensionPolicies", base::Value::Dict()); expected_values.Set("status", base::Value::Dict()); -#if BUILDFLAG(IS_CHROMEOS_ASH) - expected_values.Set("loginScreenExtensionPolicies", base::Value::Dict()); - expected_values.Set("deviceLocalAccountPolicies", base::Value::Dict()); -#endif // BUILDFLAG(IS_CHROMEOS_ASH) + +#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) + InitPolicyCategory(expected_values, "updater", "Google Update Policies"); +#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) + +#if !BUILDFLAG(IS_CHROMEOS) + InitPolicyCategory(expected_values, "precedence", "Policy Precedence"); + // Set the default precedence order. + base::Value::List precedence_order; + precedence_order.Append("Platform machine"); + precedence_order.Append("Cloud machine"); + precedence_order.Append("Platform user"); + precedence_order.Append("Cloud user"); + expected_values.FindDict("policyValues") + ->FindDict("precedence") + ->Set("precedenceOrder", std::move(precedence_order)); +#endif // !BUILDFLAG(IS_CHROMEOS) provider_.UpdateChromePolicy(values); @@ -497,18 +522,43 @@ // Change policy values. values.Erase(policy::key::kDefaultImagesSetting); expected_values.RemoveByDottedPath( - std::string("chromePolicies.") + + std::string("policyValues.chrome.policies.") + std::string(policy::key::kDefaultImagesSetting)); popups_blocked_for_urls.Append("ddd"); values.Set(policy::key::kPopupsBlockedForUrls, policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_MACHINE, policy::POLICY_SOURCE_PLATFORM, base::Value(popups_blocked_for_urls.Clone()), nullptr); - SetExpectedPolicy(expected_values, policy::key::kPopupsBlockedForUrls, - "mandatory", "machine", "platform", std::string(), - std::string(), false, + SetExpectedPolicy(expected_values, "chrome", + policy::key::kPopupsBlockedForUrls, "mandatory", "machine", + "platform", std::string(), std::string(), false, base::Value(popups_blocked_for_urls.Clone())); +#if !BUILDFLAG(IS_CHROMEOS) + values.Set(policy::key::kCloudPolicyOverridesPlatformPolicy, + policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_MACHINE, + policy::POLICY_SOURCE_PLATFORM, base::Value(true), nullptr); + SetExpectedPolicy(expected_values, "chrome", + policy::key::kCloudPolicyOverridesPlatformPolicy, + "mandatory", "machine", "platform", std::string(), + std::string(), false, base::Value(true)); + SetExpectedPolicy(expected_values, "precedence", + policy::key::kCloudPolicyOverridesPlatformPolicy, + "mandatory", "machine", "platform", std::string(), + std::string(), false, base::Value(true)); + + // Update the precedence order since cloud machine policies now override + // platform machine policies due to policy CloudPolicyOverridesPlatformPolicy. + base::Value::List precedence_order_updated; + precedence_order_updated.Append("Cloud machine"); + precedence_order_updated.Append("Platform machine"); + precedence_order_updated.Append("Platform user"); + precedence_order_updated.Append("Cloud user"); + expected_values.FindDict("policyValues") + ->FindDict("precedence") + ->Set("precedenceOrder", std::move(precedence_order_updated)); +#endif // !BUILDFLAG(IS_CHROMEOS) + provider_.UpdateChromePolicy(values); // Check writing changed policies to the same file (should overwrite the
diff --git a/chrome/browser/ui/webui/policy/policy_ui_handler.cc b/chrome/browser/ui/webui/policy/policy_ui_handler.cc index c0a8c87..1f70662 100644 --- a/chrome/browser/ui/webui/policy/policy_ui_handler.cc +++ b/chrome/browser/ui/webui/policy/policy_ui_handler.cc
@@ -32,7 +32,6 @@ #include "chrome/browser/download/download_prefs.h" #include "chrome/browser/enterprise/util/affiliation.h" #include "chrome/browser/policy/chrome_browser_policy_connector.h" -#include "chrome/browser/policy/chrome_policy_conversions_client.h" #include "chrome/browser/policy/policy_ui_utils.h" #include "chrome/browser/policy/policy_value_and_status_aggregator.h" #include "chrome/browser/policy/profile_policy_connector.h" @@ -44,12 +43,14 @@ #include "chrome/browser/ui/chrome_select_file_policy.h" #include "chrome/browser/ui/webui/webui_util.h" #include "chrome/grit/chromium_strings.h" +#include "components/crx_file/id_util.h" #include "components/enterprise/browser/controller/browser_dm_token_storage.h" #include "components/enterprise/browser/controller/chrome_browser_cloud_management_controller.h" #include "components/enterprise/browser/reporting/common_pref_names.h" #include "components/policy/core/browser/configuration_policy_handler_list.h" #include "components/policy/core/browser/policy_conversions.h" #include "components/policy/core/browser/webui/json_generation.h" +#include "components/policy/core/browser/webui/policy_webui_constants.h" #include "components/policy/core/common/cloud/cloud_policy_manager.h" #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" #include "components/policy/core/common/cloud/cloud_policy_util.h" @@ -90,6 +91,13 @@ #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" #endif +namespace { + +// Key under which extension policies are grouped in JSON policy exports. +const char kExtensionsKey[] = "extensions"; + +} // namespace + PolicyUIHandler::PolicyUIHandler() = default; PolicyUIHandler::~PolicyUIHandler() { @@ -347,16 +355,34 @@ #endif // !BUILDFLAG(IS_CHROMEOS) std::string PolicyUIHandler::GetPoliciesAsJson() { - auto client = std::make_unique<policy::ChromePolicyConversionsClient>( - web_ui()->GetWebContents()->GetBrowserContext()); + base::Value::Dict policy_values = + policy_value_and_status_aggregator_->GetAggregatedPolicyValues(); + policy_values.Remove(policy::kPolicyIdsKey); + base::Value::Dict* extensions_dict = + policy_values.FindDict(policy::kPolicyValuesKey) + ->EnsureDict(kExtensionsKey); - policy::JsonGenerationParams params = policy::GetChromeMetadataParams( - /*application_name=*/l10n_util::GetStringUTF8(IDS_PRODUCT_NAME)); + // Iterate through all policy headings to identify extension policies. + for (auto entry : *policy_values.FindDict(policy::kPolicyValuesKey)) { + if (crx_file::id_util::IdIsValid(entry.first)) { + extensions_dict->Set(entry.first, base::Value::Dict()); + } + } + + // Extract identified extension policies into their own category. + for (auto entry : *extensions_dict) { + extensions_dict->Set(entry.first, + policy_values.FindDict(policy::kPolicyValuesKey) + ->Extract(entry.first) + .value_or(base::Value())); + } return policy::GenerateJson( - /*policy_values=*/policy::DictionaryPolicyConversions(std::move(client)) - .ToValueDict(), - policy_value_and_status_aggregator_->GetAggregatedPolicyStatus(), params); + std::move(policy_values), + policy_value_and_status_aggregator_->GetAggregatedPolicyStatus(), + /*params=*/ + policy::GetChromeMetadataParams( + /*application_name=*/l10n_util::GetStringUTF8(IDS_PRODUCT_NAME))); } void PolicyUIHandler::WritePoliciesToJSONFile(const base::FilePath& path) {
diff --git a/chrome/browser/ui/webui/settings/ash/people_section.cc b/chrome/browser/ui/webui/settings/ash/people_section.cc index a6a2b76..fafc2618 100644 --- a/chrome/browser/ui/webui/settings/ash/people_section.cc +++ b/chrome/browser/ui/webui/settings/ash/people_section.cc
@@ -413,9 +413,6 @@ "appsToggleSharingEnabled", base::FeatureList::IsEnabled(syncer::kSyncChromeOSAppsToggleSharing) && crosapi::browser_util::IsLacrosEnabled()); - html_source->AddString( - "browserSettingsSyncSetupUrl", - base::StrCat({chrome::kChromeUISettingsURL, chrome::kSyncSetupSubPage})); // This handler is for chrome://os-settings. html_source->AddBoolean("isOSSettings", true);
diff --git a/chrome/browser/ui/webui/side_panel/companion/companion_page_handler.cc b/chrome/browser/ui/webui/side_panel/companion/companion_page_handler.cc index 60fc3dad..4e98c6c 100644 --- a/chrome/browser/ui/webui/side_panel/companion/companion_page_handler.cc +++ b/chrome/browser/ui/webui/side_panel/companion/companion_page_handler.cc
@@ -9,10 +9,14 @@ #include "chrome/browser/ui/ui_features.h" #include "chrome/browser/ui/webui/side_panel/companion/companion_side_panel_untrusted_ui.h" #include "chrome/browser/ui/webui/side_panel/companion/companion_url_builder.h" +#include "chrome/browser/ui/webui/side_panel/companion/msbb_delegate.h" #include "chrome/browser/ui/webui/side_panel/companion/promo_handler.h" +#include "chrome/browser/unified_consent/unified_consent_service_factory.h" #include "chrome/common/webui_url_constants.h" #include "components/prefs/pref_service.h" #include "components/unified_consent/pref_names.h" +#include "components/unified_consent/unified_consent_service.h" +#include "components/unified_consent/url_keyed_data_collection_consent_helper.h" #include "content/public/browser/web_contents.h" #include "net/base/url_util.h" #include "url/gurl.h" @@ -29,18 +33,19 @@ receiver_(this, std::move(receiver)), page_(std::move(page)), companion_untrusted_ui_(companion_untrusted_ui), - url_builder_(std::make_unique<CompanionUrlBuilder>( - browser->profile()->GetPrefs())), - promo_handler_( - std::make_unique<PromoHandler>(browser->profile()->GetPrefs())) { + url_builder_( + std::make_unique<CompanionUrlBuilder>(browser->profile()->GetPrefs(), + this)) { DCHECK(browser); + promo_handler_ = + std::make_unique<PromoHandler>(browser->profile()->GetPrefs(), this); NotifyURLChanged(); } CompanionPageHandler::~CompanionPageHandler() = default; void CompanionPageHandler::PrimaryPageChanged(content::Page& page) { - if (!url_builder_->IsMsbbEnabled()) { + if (!IsMsbbEnabled()) { return; } NotifyURLChanged(); @@ -68,4 +73,20 @@ // TODO(b/274618487): Start lens region search. } +void CompanionPageHandler::EnableMsbb(bool enable_msbb) { + auto* profile = + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); + auto* consent_service = UnifiedConsentServiceFactory::GetForProfile(profile); + consent_service->SetUrlKeyedAnonymizedDataCollectionEnabled(enable_msbb); +} + +bool CompanionPageHandler::IsMsbbEnabled() { + auto* profile = + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); + std::unique_ptr<unified_consent::UrlKeyedDataCollectionConsentHelper> helper = + unified_consent::UrlKeyedDataCollectionConsentHelper:: + NewAnonymizedDataCollectionConsentHelper(profile->GetPrefs()); + return helper->IsEnabled(); +} + } // namespace companion
diff --git a/chrome/browser/ui/webui/side_panel/companion/companion_page_handler.h b/chrome/browser/ui/webui/side_panel/companion/companion_page_handler.h index 10396da7..e90bdd5 100644 --- a/chrome/browser/ui/webui/side_panel/companion/companion_page_handler.h +++ b/chrome/browser/ui/webui/side_panel/companion/companion_page_handler.h
@@ -6,7 +6,9 @@ #define CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_COMPANION_COMPANION_PAGE_HANDLER_H_ #include "base/memory/raw_ptr.h" +#include "base/memory/weak_ptr.h" #include "chrome/browser/ui/webui/side_panel/companion/companion.mojom.h" +#include "chrome/browser/ui/webui/side_panel/companion/msbb_delegate.h" #include "content/public/browser/web_contents_observer.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" @@ -21,7 +23,8 @@ class PromoHandler; class CompanionPageHandler : public side_panel::mojom::CompanionPageHandler, - public content::WebContentsObserver { + public content::WebContentsObserver, + public MsbbDelegate { public: explicit CompanionPageHandler( mojo::PendingReceiver<side_panel::mojom::CompanionPageHandler> receiver, @@ -42,6 +45,10 @@ void PrimaryPageChanged(content::Page& page) override; private: + // MsbbDelegate overrides. + void EnableMsbb(bool enable_msbb) override; + bool IsMsbbEnabled() override; + // Notifies the companion page of the visible URL when the active tab has // changed or when the primary page has changed on the active tab. void NotifyURLChanged(); @@ -51,6 +58,8 @@ raw_ptr<CompanionSidePanelUntrustedUI> companion_untrusted_ui_ = nullptr; std::unique_ptr<CompanionUrlBuilder> url_builder_; std::unique_ptr<PromoHandler> promo_handler_; + + base::WeakPtrFactory<CompanionPageHandler> weak_ptr_factory_{this}; }; } // namespace companion
diff --git a/chrome/browser/ui/webui/side_panel/companion/companion_url_builder.cc b/chrome/browser/ui/webui/side_panel/companion/companion_url_builder.cc index 4b78734..10420eb 100644 --- a/chrome/browser/ui/webui/side_panel/companion/companion_url_builder.cc +++ b/chrome/browser/ui/webui/side_panel/companion/companion_url_builder.cc
@@ -7,10 +7,9 @@ #include "base/base64.h" #include "chrome/browser/ui/ui_features.h" #include "chrome/browser/ui/webui/side_panel/companion/constants.h" +#include "chrome/browser/ui/webui/side_panel/companion/msbb_delegate.h" #include "chrome/browser/ui/webui/side_panel/companion/proto/companion_url_params.pb.h" #include "components/prefs/pref_service.h" -#include "components/unified_consent/pref_names.h" -#include "components/unified_consent/url_keyed_data_collection_consent_helper.h" #include "net/base/url_util.h" #include "url/gurl.h" @@ -31,36 +30,28 @@ "chrome-untrusted://companion-side-panel.top-chrome"; } // namespace -CompanionUrlBuilder::CompanionUrlBuilder(PrefService* pref_service) - : pref_service_(pref_service) {} +CompanionUrlBuilder::CompanionUrlBuilder(PrefService* pref_service, + MsbbDelegate* msbb_delegate) + : pref_service_(pref_service), msbb_delegate_(msbb_delegate) {} CompanionUrlBuilder::~CompanionUrlBuilder() = default; -bool CompanionUrlBuilder::IsMsbbEnabled() { - std::unique_ptr<unified_consent::UrlKeyedDataCollectionConsentHelper> - consent_helper = unified_consent::UrlKeyedDataCollectionConsentHelper:: - NewAnonymizedDataCollectionConsentHelper(pref_service_); - return consent_helper->IsEnabled(); -} - GURL CompanionUrlBuilder::BuildCompanionURL(GURL page_url) { // Fill the protobuf with the required query params. companion::proto::QueryParams url_params; - bool is_msbb_enabled = IsMsbbEnabled(); + bool is_msbb_enabled = msbb_delegate_->IsMsbbEnabled(); if (is_msbb_enabled) { url_params.set_page_url(page_url.spec()); } url_params.set_has_msbb_enabled(is_msbb_enabled); - // TODO(b/273652233): Uncomment. - // companion::proto::PromoState* promo_state = - // url_params.mutable_promo_state(); - // promo_state->set_signin_promo_denial_count( - // pref_service_->GetInteger(kSigninPromoDeclinedPref)); - // promo_state->set_msbb_promo_denial_count( - // pref_service_->GetInteger(kMsbbPromoDeclinedPref)); - // promo_state->set_labs_promo_denial_count( - // pref_service_->GetInteger(kLabsPromoDeclinedPref)); + companion::proto::PromoState* promo_state = url_params.mutable_promo_state(); + promo_state->set_signin_promo_denial_count( + pref_service_->GetInteger(kSigninPromoDeclinedCountPref)); + promo_state->set_msbb_promo_denial_count( + pref_service_->GetInteger(kMsbbPromoDeclinedCountPref)); + promo_state->set_labs_promo_denial_count( + pref_service_->GetInteger(kLabsPromoDeclinedCountPref)); GURL url_with_query_params = GetHomepageURLForCompanion(); std::string base64_encoded_proto;
diff --git a/chrome/browser/ui/webui/side_panel/companion/companion_url_builder.h b/chrome/browser/ui/webui/side_panel/companion/companion_url_builder.h index 2838a6a..b670651 100644 --- a/chrome/browser/ui/webui/side_panel/companion/companion_url_builder.h +++ b/chrome/browser/ui/webui/side_panel/companion/companion_url_builder.h
@@ -10,6 +10,7 @@ class PrefService; namespace companion { +class MsbbDelegate; // Utility to build URL for the search companion request. The URL contains // various query parameters needed at the server side such as main page URL, @@ -17,7 +18,7 @@ // schema consistency. class CompanionUrlBuilder { public: - explicit CompanionUrlBuilder(PrefService* pref_service); + CompanionUrlBuilder(PrefService* pref_service, MsbbDelegate* msbb_delegate); CompanionUrlBuilder(const CompanionUrlBuilder&) = delete; CompanionUrlBuilder& operator=(const CompanionUrlBuilder&) = delete; ~CompanionUrlBuilder(); @@ -27,15 +28,12 @@ // associated state. GURL BuildCompanionURL(GURL page_url); - // Util method to check whether make searches and browsing better option is - // enabled in the settings. - bool IsMsbbEnabled(); - private: // The base URL for companion. GURL GetHomepageURLForCompanion(); raw_ptr<PrefService> pref_service_; + raw_ptr<MsbbDelegate> msbb_delegate_; }; } // namespace companion
diff --git a/chrome/browser/ui/webui/side_panel/companion/companion_url_builder_unittest.cc b/chrome/browser/ui/webui/side_panel/companion/companion_url_builder_unittest.cc index a6ee9b4..e005d36 100644 --- a/chrome/browser/ui/webui/side_panel/companion/companion_url_builder_unittest.cc +++ b/chrome/browser/ui/webui/side_panel/companion/companion_url_builder_unittest.cc
@@ -7,10 +7,11 @@ #include "base/base64.h" #include "base/logging.h" #include "chrome/browser/ui/webui/side_panel/companion/constants.h" +#include "chrome/browser/ui/webui/side_panel/companion/msbb_delegate.h" +#include "chrome/browser/ui/webui/side_panel/companion/promo_handler.h" #include "chrome/browser/ui/webui/side_panel/companion/proto/companion_url_params.pb.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/testing_pref_service.h" -#include "components/unified_consent/pref_names.h" #include "net/base/url_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -22,6 +23,13 @@ namespace { constexpr char kUrl[] = "https://foo.com/"; constexpr char kOrigin[] = "chrome-untrusted://companion-side-panel.top-chrome"; + +class MockMsbbDelegate : public MsbbDelegate { + public: + MOCK_METHOD1(EnableMsbb, void(bool)); + MOCK_METHOD0(IsMsbbEnabled, bool()); +}; + } // namespace class CompanionUrlBuilderTest : public testing::Test { @@ -30,32 +38,25 @@ ~CompanionUrlBuilderTest() override = default; void SetUp() override { - pref_service_.registry()->RegisterBooleanPref( - unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled, - false); + PromoHandler::RegisterProfilePrefs(pref_service_.registry()); + EXPECT_CALL(msbb_delegate_, IsMsbbEnabled()) + .WillRepeatedly(testing::Return(true)); - pref_service_.registry()->RegisterIntegerPref(kSigninPromoDeclinedPref, 0); - pref_service_.registry()->RegisterIntegerPref(kMsbbPromoDeclinedPref, 0); - pref_service_.registry()->RegisterIntegerPref(kLabsPromoDeclinedPref, 0); - - pref_service_.SetUserPref( - unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled, - base::Value(true)); - pref_service_.SetUserPref(kSigninPromoDeclinedPref, base::Value(1)); - url_builder_ = std::make_unique<CompanionUrlBuilder>(&pref_service_); + pref_service_.SetUserPref(kSigninPromoDeclinedCountPref, base::Value(1)); + url_builder_ = + std::make_unique<CompanionUrlBuilder>(&pref_service_, &msbb_delegate_); } protected: TestingPrefServiceSimple pref_service_; + MockMsbbDelegate msbb_delegate_; std::unique_ptr<CompanionUrlBuilder> url_builder_; }; TEST_F(CompanionUrlBuilderTest, MsbbOff) { - pref_service_.SetUserPref( - unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled, - base::Value(false)); - pref_service_.SetUserPref(kSigninPromoDeclinedPref, base::Value(1)); - EXPECT_FALSE(url_builder_->IsMsbbEnabled()); + EXPECT_CALL(msbb_delegate_, IsMsbbEnabled()) + .WillRepeatedly(testing::Return(false)); + pref_service_.SetUserPref(kSigninPromoDeclinedCountPref, base::Value(1)); GURL page_url(kUrl); GURL companion_url = url_builder_->BuildCompanionURL(page_url); @@ -82,8 +83,9 @@ TEST_F(CompanionUrlBuilderTest, MsbbOn) { GURL page_url(kUrl); + EXPECT_CALL(msbb_delegate_, IsMsbbEnabled()) + .WillRepeatedly(testing::Return(true)); GURL companion_url = url_builder_->BuildCompanionURL(page_url); - EXPECT_TRUE(url_builder_->IsMsbbEnabled()); std::string value; EXPECT_TRUE(net::GetValueForKeyInQuery(companion_url, "url", &value)); @@ -105,12 +107,11 @@ EXPECT_EQ(proto.page_url(), page_url.spec()); EXPECT_TRUE(proto.has_msbb_enabled()); - // TODO(b/273652233): Uncomment. // Verify promo state. - // EXPECT_TRUE(proto.has_promo_state()); - // EXPECT_EQ(1, proto.promo_state().signin_promo_denial_count()); - // EXPECT_EQ(0, proto.promo_state().msbb_promo_denial_count()); - // EXPECT_EQ(0, proto.promo_state().labs_promo_denial_count()); + EXPECT_TRUE(proto.has_promo_state()); + EXPECT_EQ(1, proto.promo_state().signin_promo_denial_count()); + EXPECT_EQ(0, proto.promo_state().msbb_promo_denial_count()); + EXPECT_EQ(0, proto.promo_state().labs_promo_denial_count()); } TEST_F(CompanionUrlBuilderTest, NonProtobufParams) {
diff --git a/chrome/browser/ui/webui/side_panel/companion/constants.h b/chrome/browser/ui/webui/side_panel/companion/constants.h index d1889e6..f81cb1b 100644 --- a/chrome/browser/ui/webui/side_panel/companion/constants.h +++ b/chrome/browser/ui/webui/side_panel/companion/constants.h
@@ -8,12 +8,12 @@ namespace companion { // Pref names for storing various promo states. -const char kMsbbPromoDeclinedPref[] = - "Search.Companion.Promo.MSBB.Declined.Count"; -const char kSigninPromoDeclinedPref[] = - "Search.Companion.Promo.Signin.Declined.Count"; -const char kLabsPromoDeclinedPref[] = - "Search.Companion.Promo.Labs.Declined.Count"; +const char kMsbbPromoDeclinedCountPref[] = + "Companion.Promo.MSBB.Declined.Count"; +const char kSigninPromoDeclinedCountPref[] = + "Companion.Promo.Signin.Declined.Count"; +const char kLabsPromoDeclinedCountPref[] = + "Companion.Promo.Labs.Declined.Count"; } // namespace companion
diff --git a/chrome/browser/ui/webui/side_panel/companion/msbb_delegate.h b/chrome/browser/ui/webui/side_panel/companion/msbb_delegate.h new file mode 100644 index 0000000..45b55fd --- /dev/null +++ b/chrome/browser/ui/webui/side_panel/companion/msbb_delegate.h
@@ -0,0 +1,25 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_COMPANION_MSBB_DELEGATE_H_ +#define CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_COMPANION_MSBB_DELEGATE_H_ + +namespace companion { + +// Helper class to read and write the setting for make searches and browsing +// better. +class MsbbDelegate { + public: + virtual ~MsbbDelegate() = default; + + // Enable the setting for make searches and browsing better. + virtual void EnableMsbb(bool enable_msbb) = 0; + + // Whether the setting is enabled for make searches and browsing better. + virtual bool IsMsbbEnabled() = 0; +}; + +} // namespace companion + +#endif // CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_COMPANION_MSBB_DELEGATE_H_
diff --git a/chrome/browser/ui/webui/side_panel/companion/promo_handler.cc b/chrome/browser/ui/webui/side_panel/companion/promo_handler.cc index 38598c7..5498fed 100644 --- a/chrome/browser/ui/webui/side_panel/companion/promo_handler.cc +++ b/chrome/browser/ui/webui/side_panel/companion/promo_handler.cc
@@ -4,19 +4,66 @@ #include "chrome/browser/ui/webui/side_panel/companion/promo_handler.h" +#include "chrome/browser/ui/webui/side_panel/companion/companion.mojom.h" +#include "chrome/browser/ui/webui/side_panel/companion/constants.h" +#include "chrome/browser/ui/webui/side_panel/companion/msbb_delegate.h" +#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" namespace companion { -PromoHandler::PromoHandler(PrefService* pref_service) - : pref_service_(pref_service) {} +PromoHandler::PromoHandler(PrefService* pref_service, + MsbbDelegate* msbb_delegate) + : pref_service_(pref_service), msbb_delegate_(msbb_delegate) {} PromoHandler::~PromoHandler() = default; +// static +void PromoHandler::RegisterProfilePrefs(PrefRegistrySimple* registry) { + registry->RegisterIntegerPref(kMsbbPromoDeclinedCountPref, 0); + registry->RegisterIntegerPref(kSigninPromoDeclinedCountPref, 0); + registry->RegisterIntegerPref(kLabsPromoDeclinedCountPref, 0); +} + void PromoHandler::OnPromoAction(PromoType promo_type, PromoAction promo_action) { - // TODO(b/273652233): Implement logic to persist promo count, and optionally - // open sign-in flow. + if (promo_type == PromoType::kSignin) { + OnSigninPromo(promo_action); + } else if (promo_type == PromoType::kMsbb) { + OnMsbbPromo(promo_action); + } else if (promo_type == PromoType::kLabs) { + OnLabsPromo(promo_action); + } +} + +void PromoHandler::OnSigninPromo(PromoAction promo_action) { + if (promo_action == PromoAction::kRejected) { + IncrementPref(kSigninPromoDeclinedCountPref); + } else if (promo_action == PromoAction::kAccepted) { + // TODO(b/273792326): Start sign-in flow. + } +} + +void PromoHandler::OnMsbbPromo(PromoAction promo_action) { + if (promo_action == PromoAction::kRejected) { + IncrementPref(kMsbbPromoDeclinedCountPref); + } else if (promo_action == PromoAction::kAccepted) { + // Turn on MSBB. + msbb_delegate_->EnableMsbb(true); + } +} + +void PromoHandler::OnLabsPromo(PromoAction promo_action) { + if (promo_action == PromoAction::kRejected) { + IncrementPref(kLabsPromoDeclinedCountPref); + } else if (promo_action == PromoAction::kAccepted) { + // TODO(b/272954072): Nothing to do. Just collect metrics. + } +} + +void PromoHandler::IncrementPref(const std::string& pref_name) { + int current_val = pref_service_->GetInteger(pref_name); + pref_service_->SetInteger(pref_name, current_val + 1); } } // namespace companion
diff --git a/chrome/browser/ui/webui/side_panel/companion/promo_handler.h b/chrome/browser/ui/webui/side_panel/companion/promo_handler.h index 8318c6b..0ffa7bb2 100644 --- a/chrome/browser/ui/webui/side_panel/companion/promo_handler.h +++ b/chrome/browser/ui/webui/side_panel/companion/promo_handler.h
@@ -5,32 +5,50 @@ #ifndef CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_COMPANION_PROMO_HANDLER_H_ #define CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_COMPANION_PROMO_HANDLER_H_ +#include <string> + +#include "base/functional/callback.h" #include "base/memory/raw_ptr.h" #include "chrome/browser/ui/webui/side_panel/companion/companion.mojom.h" +class PrefRegistrySimple; class PrefService; namespace companion { using side_panel::mojom::PromoAction; using side_panel::mojom::PromoType; +class MsbbDelegate; + // Central class to handle user actions on various promos displayed in the // search companion. class PromoHandler { public: - explicit PromoHandler(PrefService* pref_service); + PromoHandler(PrefService* pref_service, MsbbDelegate* msbb_setter); + ~PromoHandler(); + + // Disallow copy/assign. PromoHandler(const PromoHandler&) = delete; PromoHandler& operator=(const PromoHandler&) = delete; - ~PromoHandler(); + + // Registers preferences used by this class in the provided |registry|. This + // should be called for the Profile registry. + static void RegisterProfilePrefs(PrefRegistrySimple* registry); // Called in response to the mojo call from renderer. Takes necessary action // to handle the user action on the promo. void OnPromoAction(PromoType promo_type, PromoAction promo_action); private: + void OnSigninPromo(PromoAction promo_action); + void OnMsbbPromo(PromoAction promo_action); + void OnLabsPromo(PromoAction promo_action); + void IncrementPref(const std::string& pref_name); + // Lifetime of the PrefService is bound to profile which outlives the lifetime // of the companion page. raw_ptr<PrefService> pref_service_; + raw_ptr<MsbbDelegate> msbb_delegate_; }; } // namespace companion
diff --git a/chrome/browser/ui/webui/side_panel/companion/promo_handler_unittest.cc b/chrome/browser/ui/webui/side_panel/companion/promo_handler_unittest.cc index 389951d0..310ea06 100644 --- a/chrome/browser/ui/webui/side_panel/companion/promo_handler_unittest.cc +++ b/chrome/browser/ui/webui/side_panel/companion/promo_handler_unittest.cc
@@ -5,11 +5,23 @@ #include "chrome/browser/ui/webui/side_panel/companion/promo_handler.h" #include "chrome/browser/ui/webui/side_panel/companion/companion.mojom.h" +#include "chrome/browser/ui/webui/side_panel/companion/constants.h" +#include "chrome/browser/ui/webui/side_panel/companion/msbb_delegate.h" +#include "components/prefs/pref_registry_simple.h" #include "components/prefs/testing_pref_service.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" namespace companion { +namespace { + +class MockMsbbDelegate : public MsbbDelegate { + public: + MOCK_METHOD1(EnableMsbb, void(bool)); + MOCK_METHOD0(IsMsbbEnabled, bool()); +}; + +} // namespace class PromoHandlerTest : public testing::Test { public: @@ -17,17 +29,39 @@ ~PromoHandlerTest() override = default; void SetUp() override { - promo_handler_ = std::make_unique<PromoHandler>(&pref_service_); + PromoHandler::RegisterProfilePrefs(pref_service_.registry()); + promo_handler_ = + std::make_unique<PromoHandler>(&pref_service_, &msbb_delegate_); } protected: TestingPrefServiceSimple pref_service_; + MockMsbbDelegate msbb_delegate_; std::unique_ptr<PromoHandler> promo_handler_; }; -TEST_F(PromoHandlerTest, OnPromoActionTest) { +TEST_F(PromoHandlerTest, MsbbPromo) { + promo_handler_->OnPromoAction(PromoType::kMsbb, PromoAction::kRejected); + EXPECT_EQ(1, pref_service_.GetInteger(kMsbbPromoDeclinedCountPref)); + + EXPECT_CALL(msbb_delegate_, EnableMsbb(true)).Times(1); promo_handler_->OnPromoAction(PromoType::kMsbb, PromoAction::kAccepted); - // TODO(shaktisahu): Verify result. +} + +TEST_F(PromoHandlerTest, SigninPromo) { + promo_handler_->OnPromoAction(PromoType::kSignin, PromoAction::kRejected); + EXPECT_EQ(1, pref_service_.GetInteger(kSigninPromoDeclinedCountPref)); + + promo_handler_->OnPromoAction(PromoType::kSignin, PromoAction::kAccepted); + // TODO(b/273792326): Add test. +} + +TEST_F(PromoHandlerTest, LabsPromo) { + promo_handler_->OnPromoAction(PromoType::kLabs, PromoAction::kRejected); + EXPECT_EQ(1, pref_service_.GetInteger(kLabsPromoDeclinedCountPref)); + + promo_handler_->OnPromoAction(PromoType::kLabs, PromoAction::kAccepted); + // TODO(b/272954072): Add test. } } // namespace companion
diff --git a/chrome/browser/ui/webui/signin/inline_login_ui.cc b/chrome/browser/ui/webui/signin/inline_login_ui.cc index 4942bba..dd19d0d 100644 --- a/chrome/browser/ui/webui/signin/inline_login_ui.cc +++ b/chrome/browser/ui/webui/signin/inline_login_ui.cc
@@ -28,6 +28,7 @@ #include "chrome/grit/generated_resources.h" #include "chrome/grit/inline_login_resources.h" #include "chrome/grit/inline_login_resources_map.h" +#include "components/policy/core/common/policy_pref_names.h" #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_data_source.h" #include "content/public/common/content_switches.h" @@ -292,7 +293,7 @@ } else { bool is_incognito_enabled = (IncognitoModePrefs::GetAvailability(profile->GetPrefs()) != - IncognitoModePrefs::Availability::kDisabled); + policy::IncognitoModeAvailability::kDisabled); int message_id = is_incognito_enabled ? IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_BODY
diff --git a/chrome/browser/win/jumplist.cc b/chrome/browser/win/jumplist.cc index 399f4c3..e132cca 100644 --- a/chrome/browser/win/jumplist.cc +++ b/chrome/browser/win/jumplist.cc
@@ -159,9 +159,10 @@ } // Updates the "Tasks" category of the JumpList. -bool UpdateTaskCategory(JumpListUpdater* jumplist_updater, - IncognitoModePrefs::Availability incognito_availability, - const base::FilePath& cmd_line_profile_dir) { +bool UpdateTaskCategory( + JumpListUpdater* jumplist_updater, + policy::IncognitoModeAvailability incognito_availability, + const base::FilePath& cmd_line_profile_dir) { base::FilePath chrome_path; if (!base::PathService::Get(base::FILE_EXE, &chrome_path)) return false; @@ -174,7 +175,7 @@ // collection. We use our application icon as the icon for this item. // We remove '&' characters from this string so we can share it with our // system menu. - if (incognito_availability != IncognitoModePrefs::Availability::kForced) { + if (incognito_availability != policy::IncognitoModeAvailability::kForced) { scoped_refptr<ShellLinkItem> chrome = CreateShellLink(cmd_line_profile_dir); std::u16string chrome_title = l10n_util::GetStringUTF16(IDS_NEW_WINDOW); base::ReplaceSubstringsAfterOffset(&chrome_title, 0, u"&", @@ -186,7 +187,7 @@ // Create an IShellLink object which launches Chrome in incognito mode, and // add it to the collection. - if (incognito_availability != IncognitoModePrefs::Availability::kDisabled) { + if (incognito_availability != policy::IncognitoModeAvailability::kDisabled) { scoped_refptr<ShellLinkItem> incognito = CreateShellLink(cmd_line_profile_dir); incognito->GetCommandLine()->AppendSwitch(switches::kIncognito); @@ -586,7 +587,7 @@ base::FilePath profile_dir = profile_->GetPath(); // Check if incognito windows (or normal windows) are disabled by policy. - IncognitoModePrefs::Availability incognito_availability = + policy::IncognitoModeAvailability incognito_availability = IncognitoModePrefs::GetAvailability(profile_->GetPrefs()); auto update_transaction = std::make_unique<UpdateTransaction>(); @@ -705,7 +706,7 @@ const base::FilePath& cmd_line_profile_dir, bool most_visited_should_update, bool recently_closed_should_update, - IncognitoModePrefs::Availability incognito_availability, + policy::IncognitoModeAvailability incognito_availability, UpdateTransaction* update_transaction) { DCHECK(update_transaction); @@ -741,7 +742,7 @@ const base::FilePath& cmd_line_profile_dir, bool most_visited_should_update, bool recently_closed_should_update, - IncognitoModePrefs::Availability incognito_availability, + policy::IncognitoModeAvailability incognito_availability, UpdateTransaction* update_transaction) { DCHECK(update_transaction);
diff --git a/chrome/browser/win/jumplist.h b/chrome/browser/win/jumplist.h index 6a9847b..8e900394 100644 --- a/chrome/browser/win/jumplist.h +++ b/chrome/browser/win/jumplist.h
@@ -237,7 +237,7 @@ const base::FilePath& cmd_line_profile_dir, bool most_visited_should_update, bool recently_closed_should_update, - IncognitoModePrefs::Availability incognito_availability, + policy::IncognitoModeAvailability incognito_availability, UpdateTransaction* update_transaction); // Creates a new JumpList along with any icons that are not in the cache, @@ -251,7 +251,7 @@ const base::FilePath& cmd_line_profile_dir, bool most_visited_should_update, bool recently_closed_should_update, - IncognitoModePrefs::Availability incognito_availability, + policy::IncognitoModeAvailability incognito_availability, UpdateTransaction* update_transaction); // Updates icon files for |item_list| in |icon_dir|, which consists of
diff --git a/chrome/build/mac-arm.pgo.txt b/chrome/build/mac-arm.pgo.txt index f5d7d14..d24c0da 100644 --- a/chrome/build/mac-arm.pgo.txt +++ b/chrome/build/mac-arm.pgo.txt
@@ -1 +1 @@ -chrome-mac-arm-main-1679954386-05b1b656ba2d69b02ce785f9a11a387b8c09d45c.profdata +chrome-mac-arm-main-1679997565-a00234ad816202489d2a3725f9370d3952a5e106.profdata
diff --git a/chrome/build/mac.pgo.txt b/chrome/build/mac.pgo.txt index 7f485c23..ac88cb66 100644 --- a/chrome/build/mac.pgo.txt +++ b/chrome/build/mac.pgo.txt
@@ -1 +1 @@ -chrome-mac-main-1679939715-f2197e078da171c9a5b41d8a4444f02b40d1bd6a.profdata +chrome-mac-main-1679983124-773c9d67bd8c27da136d9a0602b500e2bcf24bcc.profdata
diff --git a/chrome/build/win32.pgo.txt b/chrome/build/win32.pgo.txt index 7ddc8955..5e3766d 100644 --- a/chrome/build/win32.pgo.txt +++ b/chrome/build/win32.pgo.txt
@@ -1 +1 @@ -chrome-win32-main-1679950782-683238c0416bcc31133aa08de790f1a9ba83313b.profdata +chrome-win32-main-1679993275-ef13b8a4268eaa656fbe95df262cd60f5bdf5b17.profdata
diff --git a/chrome/build/win64.pgo.txt b/chrome/build/win64.pgo.txt index 68c1c55..c4af929 100644 --- a/chrome/build/win64.pgo.txt +++ b/chrome/build/win64.pgo.txt
@@ -1 +1 @@ -chrome-win64-main-1679939715-ef406d1f8b818e5b00d81bb8d0eae130ed5c3687.profdata +chrome-win64-main-1679993275-528ce5f807aa931259aaa6745a8125009392d9b5.profdata
diff --git a/chrome/chrome_paks.gni b/chrome/chrome_paks.gni index 69782d1..84da6451 100644 --- a/chrome/chrome_paks.gni +++ b/chrome/chrome_paks.gni
@@ -269,6 +269,7 @@ "$root_gen_dir/ash/webui/ash_os_feedback_untrusted_resources.pak", "$root_gen_dir/ash/webui/ash_personalization_app_resources.pak", "$root_gen_dir/ash/webui/ash_print_management_resources.pak", + "$root_gen_dir/ash/webui/ash_projector_annotator_trusted_resources.pak", "$root_gen_dir/ash/webui/ash_projector_annotator_untrusted_resources.pak", "$root_gen_dir/ash/webui/ash_projector_app_trusted_resources.pak", "$root_gen_dir/ash/webui/ash_projector_app_untrusted_resources.pak", @@ -351,6 +352,7 @@ "//ash/webui/resources:multidevice_debug_resources", "//ash/webui/resources:os_feedback_resources", "//ash/webui/resources:os_feedback_untrusted_resources", + "//ash/webui/resources:projector_annotator_trusted_resources", "//ash/webui/resources:projector_annotator_untrusted_resources", "//ash/webui/resources:projector_app_bundle_resources", "//ash/webui/resources:projector_app_trusted_resources",
diff --git a/chrome/common/chromeos/extensions/api/_permission_features.json b/chrome/common/chromeos/extensions/api/_permission_features.json index aab6113..89172a7e 100644 --- a/chrome/common/chromeos/extensions/api/_permission_features.json +++ b/chrome/common/chromeos/extensions/api/_permission_features.json
@@ -20,6 +20,7 @@ "extension_types": [ "chromeos_system_extension" ], + "feature_flag": "TelemetryExtensionPendingApprovalApi", "dependencies": [ "manifest:chromeos_system_extension" ] }, "os.telemetry": {
diff --git a/chrome/common/chromeos/extensions/manifest_tests/extension_manifests_chromeos_system_extension_unittest.cc b/chrome/common/chromeos/extensions/manifest_tests/extension_manifests_chromeos_system_extension_unittest.cc index 856511f..79cb649 100644 --- a/chrome/common/chromeos/extensions/manifest_tests/extension_manifests_chromeos_system_extension_unittest.cc +++ b/chrome/common/chromeos/extensions/manifest_tests/extension_manifests_chromeos_system_extension_unittest.cc
@@ -3,8 +3,10 @@ // found in the LICENSE file. #include "base/memory/scoped_refptr.h" +#include "base/test/scoped_feature_list.h" #include "chrome/common/chromeos/extensions/chromeos_system_extensions_manifest_constants.h" #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" +#include "extensions/common/extension_features.h" #include "testing/gtest/include/gtest/gtest.h" namespace chromeos { @@ -12,13 +14,33 @@ using ExtensionManifestChromeOSSystemExtensionTest = ChromeManifestTest; TEST_F(ExtensionManifestChromeOSSystemExtensionTest, + ValidChromeOSSystemExtension_Invalid_Permission_Allowlisted_Google) { + LoadAndExpectWarning( + "chromeos_system_extension_google.json", + "'os.events' requires the 'TelemetryExtensionPendingApprovalApi' feature " + "flag to be enabled."); +} + +class ExtensionManifestChromeOSSystemExtensionTestPendingApproval + : public ExtensionManifestChromeOSSystemExtensionTest { + public: + ExtensionManifestChromeOSSystemExtensionTestPendingApproval() { + feature_list_.InitAndEnableFeature( + extensions_features::kTelemetryExtensionPendingApprovalApi); + } + + private: + base::test::ScopedFeatureList feature_list_; +}; + +TEST_F(ExtensionManifestChromeOSSystemExtensionTestPendingApproval, InvalidChromeOSSystemExtension) { LoadAndExpectWarning( "chromeos_system_extension_invalid.json", "'chromeos_system_extension' is not allowed for specified extension ID."); } -TEST_F(ExtensionManifestChromeOSSystemExtensionTest, +TEST_F(ExtensionManifestChromeOSSystemExtensionTestPendingApproval, ValidChromeOSSystemExtension_Allowlisted_Google) { scoped_refptr<extensions::Extension> extension( LoadAndExpectSuccess("chromeos_system_extension_google.json")); @@ -26,7 +48,7 @@ EXPECT_TRUE(extension->install_warnings().empty()); } -TEST_F(ExtensionManifestChromeOSSystemExtensionTest, +TEST_F(ExtensionManifestChromeOSSystemExtensionTestPendingApproval, ValidChromeOSSystemExtension_Allowlisted_HP) { scoped_refptr<extensions::Extension> extension( LoadAndExpectSuccess("chromeos_system_extension_hp.json")); @@ -34,7 +56,7 @@ EXPECT_TRUE(extension->install_warnings().empty()); } -TEST_F(ExtensionManifestChromeOSSystemExtensionTest, +TEST_F(ExtensionManifestChromeOSSystemExtensionTestPendingApproval, ValidChromeOSSystemExtension_Allowlisted_ASUS) { scoped_refptr<extensions::Extension> extension( LoadAndExpectSuccess("chromeos_system_extension_asus.json")); @@ -42,42 +64,42 @@ EXPECT_TRUE(extension->install_warnings().empty()); } -TEST_F(ExtensionManifestChromeOSSystemExtensionTest, +TEST_F(ExtensionManifestChromeOSSystemExtensionTestPendingApproval, ValidNonChromeOSSystemExtension) { scoped_refptr<extensions::Extension> extension( LoadAndExpectSuccess("background_page.json")); EXPECT_FALSE(extension->is_chromeos_system_extension()); } -TEST_F(ExtensionManifestChromeOSSystemExtensionTest, +TEST_F(ExtensionManifestChromeOSSystemExtensionTestPendingApproval, InvalidExternallyConnectableEmpty) { LoadAndExpectError( "chromeos_system_extension_invalid_externally_connectable_empty.json", chromeos::kInvalidExternallyConnectableDeclaration); } -TEST_F(ExtensionManifestChromeOSSystemExtensionTest, +TEST_F(ExtensionManifestChromeOSSystemExtensionTestPendingApproval, InvalidExternallyConnectableIds) { LoadAndExpectError( "chromeos_system_extension_invalid_externally_connectable_ids.json", chromeos::kInvalidExternallyConnectableDeclaration); } -TEST_F(ExtensionManifestChromeOSSystemExtensionTest, +TEST_F(ExtensionManifestChromeOSSystemExtensionTestPendingApproval, InvalidExternallyConnectableTls) { LoadAndExpectError( "chromeos_system_extension_invalid_externally_connectable_tls.json", chromeos::kInvalidExternallyConnectableDeclaration); } -TEST_F(ExtensionManifestChromeOSSystemExtensionTest, +TEST_F(ExtensionManifestChromeOSSystemExtensionTestPendingApproval, InvalidExternallyConnectableMatchesMoreThanOne) { LoadAndExpectError( "chromeos_system_extension_invalid_externally_connectable_2_origins.json", chromeos::kInvalidExternallyConnectableDeclaration); } -TEST_F(ExtensionManifestChromeOSSystemExtensionTest, +TEST_F(ExtensionManifestChromeOSSystemExtensionTestPendingApproval, InvalidExternallyConnectableMatchesEmpty) { LoadAndExpectError( "chromeos_system_extension_invalid_externally_connectable_matches_empty." @@ -85,14 +107,14 @@ chromeos::kInvalidExternallyConnectableDeclaration); } -TEST_F(ExtensionManifestChromeOSSystemExtensionTest, +TEST_F(ExtensionManifestChromeOSSystemExtensionTestPendingApproval, InvalidExternallyConnectableMatchesDisallowedOrigin) { LoadAndExpectError( "chromeos_system_extension_invalid_externally_connectable_1_origin.json", chromeos::kInvalidExternallyConnectableDeclaration); } -TEST_F(ExtensionManifestChromeOSSystemExtensionTest, +TEST_F(ExtensionManifestChromeOSSystemExtensionTestPendingApproval, InvalidExternallyConnectableNotExist) { LoadAndExpectError( "chromeos_system_extension_invalid_externally_connectable_not_exist.json",
diff --git a/chrome/services/sharing/nearby/platform/BUILD.gn b/chrome/services/sharing/nearby/platform/BUILD.gn index b5f0108..d94ee3cc 100644 --- a/chrome/services/sharing/nearby/platform/BUILD.gn +++ b/chrome/services/sharing/nearby/platform/BUILD.gn
@@ -97,6 +97,7 @@ "bidirectional_stream_unittest.cc", "ble_medium_unittest.cc", "ble_v2_medium_unittest.cc", + "ble_v2_peripheral_unittest.cc", "bluetooth_adapter_unittest.cc", "bluetooth_classic_medium_unittest.cc", "bluetooth_server_socket_unittest.cc",
diff --git a/chrome/services/sharing/nearby/platform/ble_v2_medium.cc b/chrome/services/sharing/nearby/platform/ble_v2_medium.cc index 9b07e2a..a6d54c2 100644 --- a/chrome/services/sharing/nearby/platform/ble_v2_medium.cc +++ b/chrome/services/sharing/nearby/platform/ble_v2_medium.cc
@@ -1,25 +1,39 @@ // Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - #include "chrome/services/sharing/nearby/platform/ble_v2_medium.h" #include "base/logging.h" #include "base/notreached.h" -#include "base/task/thread_pool.h" -#include "base/threading/platform_thread.h" -#include "base/time/time.h" +#include "base/rand_util.h" #include "chrome/services/sharing/nearby/platform/ble_v2_peripheral.h" +#include "third_party/nearby/src/internal/platform/byte_array.h" #include "third_party/nearby/src/internal/platform/implementation/ble_v2.h" namespace nearby::chrome { +namespace { +// Max times trying to generate unique scan session id. +static constexpr int kGenerateSessionIdRetryLimit = 3; +// Indicating failed to generate unique scan session id. +static constexpr uint64_t kFailedGenerateSessionId = 0; + +// Client name for logging in BLE scanning. +static constexpr char kScanClientName[] = "NearbyBleV2"; +} // namespace + BleV2Medium::BleV2Medium() { LOG(WARNING) << "BleV2Medium default constructor not implemented yet."; } +BleV2Medium::BleV2Medium( + const mojo::SharedRemote<bluetooth::mojom::Adapter>& adapter) + : adapter_(adapter) { + DCHECK(adapter_.is_bound()); +} + BleV2Medium::~BleV2Medium() { - NOTIMPLEMENTED(); + LOG(WARNING) << "BleV2Medium destructor not implemented yet."; } bool BleV2Medium::StartAdvertising( @@ -59,16 +73,104 @@ const Uuid& service_uuid, api::ble_v2::TxPowerLevel tx_power_level, BleV2Medium::ScanningCallback callback) { - LOG(WARNING) << "Ble StartScanning"; + if (!IsScanning()) { + discovered_ble_peripherals_map_.clear(); + service_uuid_to_session_ids_map_.clear(); + session_id_to_scanning_callback_map_.clear(); - base::ThreadPool::CreateSequencedTaskRunner({})->PostTask( - FROM_HERE, - base::BindOnce(&BleV2Medium::SimulateAdvertisementFound, - weak_ptr_factory_.GetWeakPtr(), std::move(callback))); + bool success = + adapter_->AddObserver(adapter_observer_.BindNewPipeAndPassRemote()); + if (!success) { + adapter_observer_.reset(); + return nullptr; + } + mojo::PendingRemote<bluetooth::mojom::DiscoverySession> discovery_session; + success = + adapter_->StartDiscoverySession(kScanClientName, &discovery_session); + + if (!success || !discovery_session.is_valid()) { + adapter_observer_.reset(); + return nullptr; + } + + discovery_session_.Bind(std::move(discovery_session)); + discovery_session_.set_disconnect_handler( + base::BindOnce(&BleV2Medium::DiscoveringChanged, base::Unretained(this), + /*discovering=*/false)); + } + if (callback.start_scanning_result) { + callback.start_scanning_result(absl::OkStatus()); + } + + // A "service" refers to high-level libraries like Connections, Presence, + // Fast Pair, etc. Each service has a unique `service_uuid`, and each client + // application that consumes that service will be making requests to + // `StartScanning()` with the same `service_uuid`. In order to disambiguate + // multiple clients using the same `service_uuid`, we create a `session_id` + // here for each scan request. + uint64_t session_id = GenerateUniqueSessionId(); + + device::BluetoothUUID bluetooth_service_uuid{std::string(service_uuid)}; + + // Save session id, service id and callback for this scan session. + session_id_to_scanning_callback_map_.insert( + {session_id, std::move(callback)}); + auto iter = service_uuid_to_session_ids_map_.find(bluetooth_service_uuid); + if (iter == service_uuid_to_session_ids_map_.end()) { + service_uuid_to_session_ids_map_.insert( + {bluetooth_service_uuid, {session_id}}); + } else { + iter->second.insert(session_id); + } + + // Generate and return ScanningSession. return std::make_unique<BleV2Medium::ScanningSession>( BleV2Medium::ScanningSession{ - .stop_scanning = []() { return absl::OkStatus(); }, + .stop_scanning = + [this, session_id, bluetooth_service_uuid]() { + size_t num_erased_from_callback_map = + session_id_to_scanning_callback_map_.erase(session_id); + + size_t num_erased_from_service_and_session_map = 0u; + auto iter = service_uuid_to_session_ids_map_.find( + bluetooth_service_uuid); + if (iter != service_uuid_to_session_ids_map_.end()) { + num_erased_from_service_and_session_map = + iter->second.erase(session_id); + } + if (num_erased_from_callback_map != 1u || + num_erased_from_service_and_session_map != 1u) { + return absl::NotFoundError( + "Can't find the provided internal session"); + } + + session_id_to_scanning_callback_map_.erase(session_id); + service_uuid_to_session_ids_map_[bluetooth_service_uuid].erase( + session_id); + if (service_uuid_to_session_ids_map_[bluetooth_service_uuid] + .empty()) { + service_uuid_to_session_ids_map_.erase( + bluetooth_service_uuid); + } + // Stop discovery if there's no more on-going scan sessions. + if (session_id_to_scanning_callback_map_.empty()) { + bool stop_discovery_success = true; + if (discovery_session_) { + bool message_success = + discovery_session_->Stop(&stop_discovery_success); + stop_discovery_success = + stop_discovery_success && message_success; + } + adapter_observer_.reset(); + discovery_session_.reset(); + if (!stop_discovery_success) { + return absl::InternalError( + "Discovery is not fully stopped"); + } + } + return absl::OkStatus(); + }, }); } @@ -106,16 +208,143 @@ return false; } -// Simulating start scan then return a peripheral. -void BleV2Medium::SimulateAdvertisementFound( - BleV2Medium::ScanningCallback callback) { - LOG(WARNING) << "Simulating Scanning"; - callback.start_scanning_result(absl::OkStatus()); - - discovered_ble_peripherals_map_.emplace("invalid_address", BleV2Peripheral{}); - callback.advertisement_found_cb( - discovered_ble_peripherals_map_.begin()->second, - api::ble_v2::BleAdvertisementData{}); +void BleV2Medium::PresentChanged(bool present) { + NOTIMPLEMENTED(); } +void BleV2Medium::PoweredChanged(bool powered) { + NOTIMPLEMENTED(); +} + +void BleV2Medium::DiscoverableChanged(bool discoverable) { + NOTIMPLEMENTED(); +} + +void BleV2Medium::DiscoveringChanged(bool discovering) { + NOTIMPLEMENTED(); +} + +void BleV2Medium::DeviceAdded(bluetooth::mojom::DeviceInfoPtr device) { + if (!IsScanning()) { + return; + } + + // Best-effort attempt to filter out BT Classic devices. Dual-mode (BT + // Classic and BLE) devices which the system has paired and/or connected to + // may also expose service data, but all BLE advertisements that we are + // interested in are captured in an element of |service_data_map|. See + // BluetoothClassicMedium for separate discovery of BT Classic devices. + if (device.is_null() || device->service_data_map.empty()) { + return; + } + + if (device.is_null()) { + LOG(WARNING) << "Device is empty."; + return; + } + + // Extract Advertisement Data. + auto advertisement_data = api::ble_v2::BleAdvertisementData{ + .is_extended_advertisement = false, + .service_data = {}, + }; + for (const auto& service_data_pair : device->service_data_map) { + advertisement_data.service_data.insert( + {BluetoothServiceUuidToNearbyUuid(service_data_pair.first), + ByteArray{std::string(service_data_pair.second.begin(), + service_data_pair.second.end())}}); + } + + // Extract bluetooth service ids from the advertising device. + // TODO(b/274997457): make sure cros bt platform will provide service_uuids + // in addition to service_data_map. + std::vector<device::BluetoothUUID> bluetooth_service_set{ + device->service_uuids}; + // Add a new or update the existing discovered peripheral. Note: Because + // BleV2Peripherals are passed by reference to NearbyConnections, if a + // BleV2Peripheral already exists with the given address, the reference should + // not be invalidated, the update functions should be called instead. + const std::string& address = device->address; + auto* existing_ble_peripheral = GetDiscoveredBlePeripheral(address); + if (existing_ble_peripheral) { + existing_ble_peripheral->UpdateDeviceInfo(std::move(device)); + } else { + discovered_ble_peripherals_map_.emplace( + address, chrome::BleV2Peripheral(std::move(device))); + } + + for (const auto& service_uuid : bluetooth_service_set) { + auto iter = service_uuid_to_session_ids_map_.find(service_uuid); + if (iter == service_uuid_to_session_ids_map_.end()) { + continue; + } + + for (auto session_id : iter->second) { + const auto scanning_callback_iter = + session_id_to_scanning_callback_map_.find(session_id); + if (scanning_callback_iter == + session_id_to_scanning_callback_map_.end()) { + continue; + } + // Fetch the BleV2Peripheral with the same `address` again because + // previously fetched pointers may have been invalidated while iterating + // through the IDs. + auto* ble_peripheral = GetDiscoveredBlePeripheral(address); + if (!ble_peripheral) { + LOG(WARNING) << "Can't find previously discovered ble peripheral."; + continue; + } + + if (scanning_callback_iter->second.advertisement_found_cb) { + scanning_callback_iter->second.advertisement_found_cb( + *ble_peripheral, advertisement_data); + } + } + } +} + +void BleV2Medium::DeviceChanged(bluetooth::mojom::DeviceInfoPtr device) { + DeviceAdded(std::move(device)); +} + +void BleV2Medium::DeviceRemoved(bluetooth::mojom::DeviceInfoPtr device) { + // TODO we also need this when productionize the ble medium code. + NOTIMPLEMENTED(); +} + +bool BleV2Medium::IsScanning() { + return adapter_observer_.is_bound() && + !service_uuid_to_session_ids_map_.empty() && + !session_id_to_scanning_callback_map_.empty(); +} + +chrome::BleV2Peripheral* BleV2Medium::GetDiscoveredBlePeripheral( + const std::string& address) { + auto it = discovered_ble_peripherals_map_.find(address); + return it == discovered_ble_peripherals_map_.end() ? nullptr : &it->second; +} + +uint64_t BleV2Medium::GenerateUniqueSessionId() { + for (int i = 0; i < kGenerateSessionIdRetryLimit; i++) { + uint64_t session_id = base::RandUint64(); + if (session_id != kFailedGenerateSessionId && + session_id_to_scanning_callback_map_.find(session_id) == + session_id_to_scanning_callback_map_.end()) { + return session_id; + } + } + return kFailedGenerateSessionId; +} + +Uuid BleV2Medium::BluetoothServiceUuidToNearbyUuid( + const device::BluetoothUUID& bluetooth_service_uuid) { + auto uint_bytes = bluetooth_service_uuid.GetBytes(); + uint64_t most_sig_bits = 0; + uint64_t least_sig_bits = 0; + for (int i = 0; i < 8; i++) { + most_sig_bits |= static_cast<uint64_t>(uint_bytes[i]) << ((7 - i) * 8); + least_sig_bits |= static_cast<uint64_t>(uint_bytes[i + 8]) << ((7 - i) * 8); + } + return Uuid{most_sig_bits, least_sig_bits}; +} } // namespace nearby::chrome
diff --git a/chrome/services/sharing/nearby/platform/ble_v2_medium.h b/chrome/services/sharing/nearby/platform/ble_v2_medium.h index f87dbd0..587fa258 100644 --- a/chrome/services/sharing/nearby/platform/ble_v2_medium.h +++ b/chrome/services/sharing/nearby/platform/ble_v2_medium.h
@@ -9,6 +9,9 @@ #include "base/memory/weak_ptr.h" #include "chrome/services/sharing/nearby/platform/ble_v2_peripheral.h" +#include "device/bluetooth/public/mojom/adapter.mojom.h" +#include "mojo/public/cpp/bindings/receiver.h" +#include "mojo/public/cpp/bindings/shared_remote.h" #include "third_party/nearby/src/internal/platform/implementation/ble_v2.h" namespace nearby::chrome { @@ -16,11 +19,19 @@ // Concrete ble_v2::BleMedium implementation. // Productionized impl will also consumes bluetooth::mojom::Adapter methods. // Current skeleton has not added it yet. -class BleV2Medium : public ::nearby::api::ble_v2::BleMedium { +class BleV2Medium : public ::nearby::api::ble_v2::BleMedium, + public bluetooth::mojom::AdapterObserver { public: BleV2Medium(); + + explicit BleV2Medium( + const mojo::SharedRemote<bluetooth::mojom::Adapter>& adapter); + ~BleV2Medium() override; + BleV2Medium(const BleV2Medium&) = delete; + BleV2Medium& operator=(const BleV2Medium&) = delete; + // This would deprecate soon. Will delete this after nearby codes delete it // first. // TODO(b/271305977): Delete this method. @@ -75,8 +86,34 @@ bool IsExtendedAdvertisementsAvailable() override; private: - // This will eventually be removed once the class is productionized. - void SimulateAdvertisementFound(BleV2Medium::ScanningCallback callback); + // bluetooth::mojom::AdapterObserver: + void PresentChanged(bool present) override; + void PoweredChanged(bool powered) override; + void DiscoverableChanged(bool discoverable) override; + void DiscoveringChanged(bool discovering) override; + void DeviceAdded(bluetooth::mojom::DeviceInfoPtr device) override; + void DeviceChanged(bluetooth::mojom::DeviceInfoPtr device) override; + void DeviceRemoved(bluetooth::mojom::DeviceInfoPtr device) override; + + void ProcessFoundDevice(bluetooth::mojom::DeviceInfoPtr device); + bool IsScanning(); + uint64_t GenerateUniqueSessionId(); + chrome::BleV2Peripheral* GetDiscoveredBlePeripheral( + const std::string& address); + Uuid BluetoothServiceUuidToNearbyUuid( + const device::BluetoothUUID& bluetooth_service_uuid); + + mojo::SharedRemote<bluetooth::mojom::Adapter> adapter_; + + // Only set while discovery is active. + mojo::Remote<bluetooth::mojom::DiscoverySession> discovery_session_; + + // Group scanning session ids with the same bluetooth service id in sets. + std::map<device::BluetoothUUID, std::set<uint64_t>> + service_uuid_to_session_ids_map_; + + // Saving scanning callbacks, keyed by session ids. + std::map<uint64_t, ScanningCallback> session_id_to_scanning_callback_map_; // Keyed by address of advertising remote device. Note: References to these // BlePeripherals are passed to Nearby Connections. This is safe because, for @@ -85,6 +122,10 @@ std::map<std::string, chrome::BleV2Peripheral> discovered_ble_peripherals_map_; + // |adapter_observer_| is only set and bound during active discovery so that + // events we don't care about outside of discovery don't pile up. + mojo::Receiver<bluetooth::mojom::AdapterObserver> adapter_observer_{this}; + base::WeakPtrFactory<BleV2Medium> weak_ptr_factory_{this}; }; } // namespace nearby::chrome
diff --git a/chrome/services/sharing/nearby/platform/ble_v2_medium_unittest.cc b/chrome/services/sharing/nearby/platform/ble_v2_medium_unittest.cc index 7353184d..4aaf851 100644 --- a/chrome/services/sharing/nearby/platform/ble_v2_medium_unittest.cc +++ b/chrome/services/sharing/nearby/platform/ble_v2_medium_unittest.cc
@@ -7,10 +7,33 @@ #include "base/test/task_environment.h" #include "chrome/services/sharing/nearby/platform/ble_v2_medium.h" #include "chrome/services/sharing/nearby/platform/count_down_latch.h" +#include "chrome/services/sharing/nearby/test_support/fake_adapter.h" +#include "mojo/public/cpp/bindings/pending_remote.h" +#include "mojo/public/cpp/bindings/self_owned_receiver.h" #include "testing/gtest/include/gtest/gtest.h" namespace nearby::chrome { +namespace { + +const char kDeviceAddress[] = "DeviceAddress"; +const char kDeviceServiceData1Str[] = "Device_Advertisement1"; +const Uuid kFastAdvertisementServiceUuid1{0x0000FEF300001000, + 0x800000805F9B34FB}; +const ByteArray kDeviceServiceData1ByteArray{ + std::string{kDeviceServiceData1Str}}; +const device::BluetoothUUID kService1BluetoothUuid{ + base::span<const uint8_t>(reinterpret_cast<const uint8_t*>( + kFastAdvertisementServiceUuid1.data().data()), + kFastAdvertisementServiceUuid1.data().size())}; +const device::BluetoothUUID kService2BluetoothUuid("1000"); + +std::vector<uint8_t> GetByteVector(const std::string& str) { + return std::vector<uint8_t>(str.begin(), str.end()); +} + +} // namespace + class BleV2MediumTest : public testing::Test { public: BleV2MediumTest() = default; @@ -18,12 +41,61 @@ BleV2MediumTest(const BleV2MediumTest&) = delete; BleV2MediumTest& operator=(const BleV2MediumTest&) = delete; + void SetUp() override { + auto fake_adapter = std::make_unique<bluetooth::FakeAdapter>(); + fake_adapter_ = fake_adapter.get(); + + mojo::PendingRemote<bluetooth::mojom::Adapter> pending_adapter; + + mojo::MakeSelfOwnedReceiver( + std::move(fake_adapter), + pending_adapter.InitWithNewPipeAndPassReceiver()); + + remote_adapter_.Bind(std::move(pending_adapter), + /*bind_task_runner=*/nullptr); + + ble_v2_medium_ = std::make_unique<BleV2Medium>(remote_adapter_); + } + + void OnPeripheralDiscovered() { + if (on_expected_peripherals_discovered_callback_) { + std::move(on_expected_peripherals_discovered_callback_).Run(); + } + } + + void SetOnExpectedPeripheralsDiscoveredCallback(base::OnceClosure callback) { + on_expected_peripherals_discovered_callback_ = std::move(callback); + } + + bluetooth::mojom::DeviceInfoPtr CreateDeviceInfo( + const std::string& address, + const base::flat_map<device::BluetoothUUID, std::vector<uint8_t>>& + service_data_map) { + // Do not set |name|. This reflects Chrome's usual representation of a BLE + // advertisement. + auto device_info = bluetooth::mojom::DeviceInfo::New(); + device_info->address = address; + device_info->name_for_display = address; + device_info->service_data_map = service_data_map; + for (auto pair : service_data_map) { + device_info->service_uuids.push_back(pair.first); + } + + return device_info; + } + + bluetooth::FakeAdapter* fake_adapter_; + mojo::SharedRemote<bluetooth::mojom::Adapter> remote_adapter_; + std::unique_ptr<BleV2Medium> ble_v2_medium_; + private: + std::unique_ptr<BleV2Medium::ScanningSession> scanning_session_; + base::OnceClosure on_expected_peripherals_discovered_callback_; + base::OnceClosure on_discovery_session_destroyed_callback_; base::test::TaskEnvironment task_environment_; }; -TEST_F(BleV2MediumTest, TestScanning) { - auto ble_v2_medium = std::make_unique<BleV2Medium>(); +TEST_F(BleV2MediumTest, TestScanning_OneService) { CountDownLatch scanning_started_latch(1); CountDownLatch found_advertisement_latch(1); api::ble_v2::BleMedium::ScanningCallback scanning_callback = { @@ -32,19 +104,138 @@ scanning_started_latch.CountDown(); }, .advertisement_found_cb = - [&found_advertisement_latch]( + [this, &found_advertisement_latch]( api::ble_v2::BlePeripheral& peripheral, const api::ble_v2::BleAdvertisementData& advertisement_data) { + EXPECT_EQ(peripheral.GetAddress(), kDeviceAddress); + EXPECT_EQ(advertisement_data.service_data + .find(kFastAdvertisementServiceUuid1) + ->second, + kDeviceServiceData1ByteArray); found_advertisement_latch.CountDown(); + OnPeripheralDiscovered(); }}; - auto scanning_session = ble_v2_medium->StartScanning( - /*service_uuid=*/{}, /*tx_power_level=*/{}, std::move(scanning_callback)); + auto scanning_session = ble_v2_medium_->StartScanning( + kFastAdvertisementServiceUuid1, {}, std::move(scanning_callback)); + EXPECT_NE(scanning_session, nullptr); + + base::flat_map<device::BluetoothUUID, std::vector<uint8_t>> service_data_map; + service_data_map.insert_or_assign(kService1BluetoothUuid, + GetByteVector(kDeviceServiceData1Str)); EXPECT_TRUE(scanning_started_latch.Await().Ok()); + + base::RunLoop run_loop; + SetOnExpectedPeripheralsDiscoveredCallback(run_loop.QuitClosure()); + fake_adapter_->NotifyDeviceAdded( + CreateDeviceInfo(kDeviceAddress, service_data_map)); + run_loop.Run(); + EXPECT_TRUE(found_advertisement_latch.Await().Ok()); - auto status = scanning_session->stop_scanning(); - EXPECT_TRUE(status.ok()); + EXPECT_TRUE(scanning_session->stop_scanning().ok()); +} + +TEST_F(BleV2MediumTest, TestScanning_MultipleSessions) { + // Expects session 1 found one advertisement. + CountDownLatch session_1_found_advertisement_latch(1); + // Expects session 2 found two advertisement. + CountDownLatch session_2_found_advertisement_latch(2); + // Expects both sessions succeeded to start scanning. + CountDownLatch scanning_started_latch(2); + + api::ble_v2::BleMedium::ScanningCallback scanning_callback_1 = { + .start_scanning_result = + [&scanning_started_latch](absl::Status status) { + scanning_started_latch.CountDown(); + }, + .advertisement_found_cb = + [this, &session_1_found_advertisement_latch]( + api::ble_v2::BlePeripheral& peripheral, + const api::ble_v2::BleAdvertisementData& advertisement_data) { + session_1_found_advertisement_latch.CountDown(); + OnPeripheralDiscovered(); + }}; + api::ble_v2::BleMedium::ScanningCallback scanning_callback_2 = { + .start_scanning_result = + [&scanning_started_latch](absl::Status status) { + scanning_started_latch.CountDown(); + }, + .advertisement_found_cb = + [this, &session_2_found_advertisement_latch]( + api::ble_v2::BlePeripheral& peripheral, + const api::ble_v2::BleAdvertisementData& advertisement_data) { + session_2_found_advertisement_latch.CountDown(); + OnPeripheralDiscovered(); + }}; + + auto scanning_session_1 = ble_v2_medium_->StartScanning( + kFastAdvertisementServiceUuid1, {}, std::move(scanning_callback_1)); + auto scanning_session_2 = ble_v2_medium_->StartScanning( + kFastAdvertisementServiceUuid1, {}, std::move(scanning_callback_2)); + // Verify both sessions start successfully. + EXPECT_NE(scanning_session_1, nullptr); + EXPECT_NE(scanning_session_2, nullptr); + EXPECT_TRUE(scanning_started_latch.Await().Ok()); + + base::flat_map<device::BluetoothUUID, std::vector<uint8_t>> service_data_map; + service_data_map.insert_or_assign(kService1BluetoothUuid, + GetByteVector(kDeviceServiceData1Str)); + base::RunLoop run_loop; + SetOnExpectedPeripheralsDiscoveredCallback(run_loop.QuitClosure()); + // Both session should see the advertisement. + fake_adapter_->NotifyDeviceAdded( + CreateDeviceInfo(kDeviceAddress, service_data_map)); + run_loop.Run(); + + // Verify session 1 did see one advertisement and stop successfully. + EXPECT_TRUE(session_1_found_advertisement_latch.Await().Ok()); + EXPECT_TRUE(scanning_session_1->stop_scanning().ok()); + + base::RunLoop run_loop_2; + SetOnExpectedPeripheralsDiscoveredCallback(run_loop_2.QuitClosure()); + // Only session 2 should see the advertisement. + fake_adapter_->NotifyDeviceAdded( + CreateDeviceInfo(kDeviceAddress, service_data_map)); + run_loop_2.Run(); + + // Verify session 2 did see two advertisements and stop successfully. + EXPECT_TRUE(session_2_found_advertisement_latch.Await().Ok()); + EXPECT_TRUE(scanning_session_2->stop_scanning().ok()); +} + +TEST_F(BleV2MediumTest, TestScanning_IgnoreIrrelevantAdvertisement) { + CountDownLatch scanning_started_latch(1); + api::ble_v2::BleMedium::ScanningCallback scanning_callback = { + .start_scanning_result = + [&scanning_started_latch](absl::Status status) { + scanning_started_latch.CountDown(); + }, + .advertisement_found_cb = + [](api::ble_v2::BlePeripheral& peripheral, + const api::ble_v2::BleAdvertisementData& advertisement_data) { + // should not reached here for irrelavant advertisement. + EXPECT_TRUE(false); + }}; + + auto scanning_session = ble_v2_medium_->StartScanning( + kFastAdvertisementServiceUuid1, {}, std::move(scanning_callback)); + EXPECT_NE(scanning_session, nullptr); + + base::flat_map<device::BluetoothUUID, std::vector<uint8_t>> service_data_map; + // Scan for kService1BluetoothUuid but notify with kService2BluetoothUuid. + service_data_map.insert_or_assign(kService2BluetoothUuid, + GetByteVector(kDeviceServiceData1Str)); + + EXPECT_TRUE(scanning_started_latch.Await().Ok()); + + base::RunLoop run_loop; + fake_adapter_->NotifyDeviceAdded( + CreateDeviceInfo(kDeviceAddress, service_data_map)); + fake_adapter_->SetDiscoverySessionDestroyedCallback(run_loop.QuitClosure()); + + EXPECT_TRUE(scanning_session->stop_scanning().ok()); + run_loop.Run(); } } // namespace nearby::chrome
diff --git a/chrome/services/sharing/nearby/platform/ble_v2_peripheral.cc b/chrome/services/sharing/nearby/platform/ble_v2_peripheral.cc index a69e217..f96ecf3 100644 --- a/chrome/services/sharing/nearby/platform/ble_v2_peripheral.cc +++ b/chrome/services/sharing/nearby/platform/ble_v2_peripheral.cc
@@ -6,7 +6,8 @@ namespace nearby::chrome { -BleV2Peripheral::BleV2Peripheral() = default; +BleV2Peripheral::BleV2Peripheral(bluetooth::mojom::DeviceInfoPtr device_info) + : device_info_(std::move(device_info)) {} BleV2Peripheral::BleV2Peripheral(BleV2Peripheral&&) = default; @@ -15,7 +16,13 @@ BleV2Peripheral::~BleV2Peripheral() = default; std::string BleV2Peripheral::GetAddress() const { - return "NOT_IMPLEMENTED"; + return device_info_->address; +} + +void BleV2Peripheral::UpdateDeviceInfo( + bluetooth::mojom::DeviceInfoPtr device_info) { + DCHECK_EQ(device_info_->address, device_info->address); + device_info_ = std::move(device_info); } } // namespace nearby::chrome
diff --git a/chrome/services/sharing/nearby/platform/ble_v2_peripheral.h b/chrome/services/sharing/nearby/platform/ble_v2_peripheral.h index f3fc453b..9688ba6 100644 --- a/chrome/services/sharing/nearby/platform/ble_v2_peripheral.h +++ b/chrome/services/sharing/nearby/platform/ble_v2_peripheral.h
@@ -7,6 +7,7 @@ #include <string> +#include "device/bluetooth/public/mojom/adapter.mojom.h" #include "third_party/nearby/src/internal/platform/implementation/ble_v2.h" namespace nearby::chrome { @@ -14,9 +15,7 @@ // Concrete BleV2Peripheral implementation. class BleV2Peripheral : public api::ble_v2::BlePeripheral { public: - // The default constructor will eventually be replaced by constructing with - // needed metadata like device info and etc, when the class is productionized. - BleV2Peripheral(); + explicit BleV2Peripheral(bluetooth::mojom::DeviceInfoPtr device_info); BleV2Peripheral(const BleV2Peripheral&) = delete; BleV2Peripheral& operator=(const BleV2Peripheral&) = delete; BleV2Peripheral(BleV2Peripheral&&); @@ -25,6 +24,10 @@ ~BleV2Peripheral() override; std::string GetAddress() const override; + void UpdateDeviceInfo(bluetooth::mojom::DeviceInfoPtr device_info); + + private: + bluetooth::mojom::DeviceInfoPtr device_info_; }; } // namespace nearby::chrome
diff --git a/chrome/services/sharing/nearby/platform/ble_v2_peripheral_unittest.cc b/chrome/services/sharing/nearby/platform/ble_v2_peripheral_unittest.cc new file mode 100644 index 0000000..444389c --- /dev/null +++ b/chrome/services/sharing/nearby/platform/ble_v2_peripheral_unittest.cc
@@ -0,0 +1,50 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/services/sharing/nearby/platform/ble_v2_peripheral.h" + +#include "base/test/gtest_util.h" +#include "base/test/task_environment.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace nearby::chrome { + +namespace { +const char kAddress[] = "address"; +} // namespace + +class BleV2PeripheralTest : public testing::Test { + protected: + base::test::TaskEnvironment task_environment_; +}; + +TEST_F(BleV2PeripheralTest, GetAddress) { + auto device_info = bluetooth::mojom::DeviceInfo::New(); + device_info->address = kAddress; + BleV2Peripheral peripheral{std::move(device_info)}; + EXPECT_EQ(peripheral.GetAddress(), kAddress); +} + +TEST_F(BleV2PeripheralTest, CanUpdateWithSameAddress) { + auto device_info = bluetooth::mojom::DeviceInfo::New(); + device_info->address = kAddress; + BleV2Peripheral peripheral{std::move(device_info)}; + EXPECT_EQ(peripheral.GetAddress(), kAddress); + auto device_info2 = bluetooth::mojom::DeviceInfo::New(); + device_info2->address = kAddress; + peripheral.UpdateDeviceInfo(std::move(device_info2)); + EXPECT_EQ(peripheral.GetAddress(), kAddress); +} + +TEST_F(BleV2PeripheralTest, CanNotUpdateWithDifferentAddress) { + auto device_info = bluetooth::mojom::DeviceInfo::New(); + device_info->address = kAddress; + BleV2Peripheral peripheral{std::move(device_info)}; + EXPECT_EQ(peripheral.GetAddress(), kAddress); + auto device_info2 = bluetooth::mojom::DeviceInfo::New(); + device_info2->address = "different address"; + EXPECT_DCHECK_DEATH(peripheral.UpdateDeviceInfo(std::move(device_info2))); +} + +} // namespace nearby::chrome
diff --git a/chrome/test/data/webui/settings/chromeos/BUILD.gn b/chrome/test/data/webui/settings/chromeos/BUILD.gn index 05475e3..49281ba 100644 --- a/chrome/test/data/webui/settings/chromeos/BUILD.gn +++ b/chrome/test/data/webui/settings/chromeos/BUILD.gn
@@ -33,7 +33,6 @@ "cups_printer_test_utils.js", "cursor_and_touchpad_page_tests.js", "date_time_page_tests.js", - "device_page_tests.js", "display_and_magnification_page_tests.js", "esim_install_error_dialog_test.js", "esim_remove_profile_dialog_test.js", @@ -122,7 +121,6 @@ "people_page_account_manager_subpage_test.js", "per_device_keyboard_subsection_test.js", "per_device_keyboard_remap_keys_test.js", - "per_device_keyboard_test.js", "per_device_pointing_stick_subsection_test.js", "personalization_page_with_personalization_hub_test.js", "privacy_hub_subpage_tests.js", @@ -144,7 +142,6 @@ "test_crostini_browser_proxy.js", "test_cups_printers_browser_proxy.js", "test_device_name_browser_proxy.js", - "test_device_page_browser_proxy.js", "test_guest_os_browser_proxy.js", "test_internet_page_browser_proxy.js", "test_kerberos_accounts_browser_proxy.js", @@ -202,11 +199,14 @@ "date_time_page/timezone_selector_test.ts", "date_time_page/timezone_subpage_test.ts", + "device_page/device_page_tests.js", + "device_page/per_device_keyboard_test.js", "device_page/per_device_mouse_subsection_test.ts", "device_page/per_device_mouse_test.ts", "device_page/per_device_pointing_stick_test.ts", "device_page/per_device_touchpad_subsection_test.ts", "device_page/per_device_touchpad_test.ts", + "device_page/test_device_page_browser_proxy.ts", "internet_page/tether_connection_dialog_test.ts",
diff --git a/chrome/test/data/webui/settings/chromeos/cursor_and_touchpad_page_tests.js b/chrome/test/data/webui/settings/chromeos/cursor_and_touchpad_page_tests.js index 009dd11..35b7b04 100644 --- a/chrome/test/data/webui/settings/chromeos/cursor_and_touchpad_page_tests.js +++ b/chrome/test/data/webui/settings/chromeos/cursor_and_touchpad_page_tests.js
@@ -10,7 +10,7 @@ import {waitAfterNextRender, waitBeforeNextRender} from 'chrome://webui-test/polymer_test_util.js'; import {eventToPromise, isVisible} from 'chrome://webui-test/test_util.js'; -import {TestDevicePageBrowserProxy} from './test_device_page_browser_proxy.js'; +import {TestDevicePageBrowserProxy} from './device_page/test_device_page_browser_proxy.js'; const DEFAULT_BLACK_CURSOR_COLOR = 0; const RED_CURSOR_COLOR = 0xd93025;
diff --git a/chrome/test/data/webui/settings/chromeos/device_page_tests.js b/chrome/test/data/webui/settings/chromeos/device_page/device_page_tests.js similarity index 98% rename from chrome/test/data/webui/settings/chromeos/device_page_tests.js rename to chrome/test/data/webui/settings/chromeos/device_page/device_page_tests.js index 9a87a21..7b37130 100644 --- a/chrome/test/data/webui/settings/chromeos/device_page_tests.js +++ b/chrome/test/data/webui/settings/chromeos/device_page/device_page_tests.js
@@ -16,7 +16,8 @@ import {flushTasks, waitAfterNextRender} from 'chrome://webui-test/polymer_test_util.js'; import {isVisible} from 'chrome://webui-test/test_util.js'; -import {FakeSystemDisplay} from './fake_system_display.js'; +import {FakeSystemDisplay} from '../fake_system_display.js'; + import {TestDevicePageBrowserProxy} from './test_device_page_browser_proxy.js'; /** @enum {string} */ @@ -2019,8 +2020,8 @@ keyboardPage.shadowRoot.querySelector('#keyboardShortcutViewer').click(); assertEquals( 1, - DevicePageBrowserProxyImpl.getInstance() - .keyboardShortcutViewerShown_); + DevicePageBrowserProxyImpl.getInstance().getCallCount( + 'showKeyboardShortcutViewer')); }); test('Deep link to keyboard shortcuts', async () => { @@ -2055,8 +2056,7 @@ assertFalse( displayPage.showUnifiedDesktop_(false, false, displayPage.displays)); assertEquals( - displayPage.invalidDisplayId_, - browserProxy.lastHighlightedDisplayId_); + displayPage.invalidDisplayId_, browserProxy.lastHighlightedDisplayId); // Add a display. addDisplay(1); @@ -2270,7 +2270,7 @@ // invalid. assertEquals( displayPage.invalidDisplayId_, - browserProxy.lastHighlightedDisplayId_); + browserProxy.lastHighlightedDisplayId); // Navigate back to the display page. return showAndGetDeviceSubpage('display', routes.DISPLAY); @@ -2446,8 +2446,8 @@ assert(powerPage.shadowRoot.querySelector('#powerSource')); assertEquals( 1, - DevicePageBrowserProxyImpl.getInstance() - .updatePowerStatusCalled_); + DevicePageBrowserProxyImpl.getInstance().getCallCount( + 'updatePowerStatus')); lidClosedToggle = assert( powerPage.shadowRoot.querySelector('#lidClosedToggle')); @@ -2457,8 +2457,8 @@ assertEquals( 1, - DevicePageBrowserProxyImpl.getInstance() - .requestPowerManagementSettingsCalled_); + DevicePageBrowserProxyImpl.getInstance().getCallCount( + 'requestPowerManagementSettings')); sendPowerManagementSettings( [ IdleBehavior.DISPLAY_OFF_SLEEP, @@ -2510,7 +2510,7 @@ selectValue(acIdleSelect, IdleBehavior.DISPLAY_ON); assertEquals( IdleBehavior.DISPLAY_ON, - DevicePageBrowserProxyImpl.getInstance().acIdleBehavior_); + DevicePageBrowserProxyImpl.getInstance().acIdleBehavior); }); test('power sources', function() { @@ -2582,7 +2582,7 @@ selectValue(powerSourceSelect, powerSourceSelect.children[1].value); assertEquals( powerSource.id, - DevicePageBrowserProxyImpl.getInstance().powerSourceId_); + DevicePageBrowserProxyImpl.getInstance().powerSourceId); }); test('set AC idle behavior', function() { @@ -2603,7 +2603,7 @@ selectValue(acIdleSelect, IdleBehavior.DISPLAY_ON); assertEquals( IdleBehavior.DISPLAY_ON, - DevicePageBrowserProxyImpl.getInstance().acIdleBehavior_); + DevicePageBrowserProxyImpl.getInstance().acIdleBehavior); }); test('set battery idle behavior', function() { @@ -2628,8 +2628,7 @@ selectValue(batteryIdleSelect, IdleBehavior.DISPLAY_ON); assertEquals( IdleBehavior.DISPLAY_ON, - DevicePageBrowserProxyImpl.getInstance() - .batteryIdleBehavior_); + DevicePageBrowserProxyImpl.getInstance().batteryIdleBehavior); }); }); @@ -2659,14 +2658,14 @@ lidClosedToggle.shadowRoot.querySelector('#control').click(); assertEquals( LidClosedBehavior.DO_NOTHING, - DevicePageBrowserProxyImpl.getInstance().lidClosedBehavior_); + DevicePageBrowserProxyImpl.getInstance().lidClosedBehavior); sendLid(LidClosedBehavior.DO_NOTHING); assertFalse(lidClosedToggle.checked); lidClosedToggle.shadowRoot.querySelector('#control').click(); assertEquals( LidClosedBehavior.SUSPEND, - DevicePageBrowserProxyImpl.getInstance().lidClosedBehavior_); + DevicePageBrowserProxyImpl.getInstance().lidClosedBehavior); sendLid(LidClosedBehavior.SUSPEND); assertTrue(lidClosedToggle.checked); }); @@ -3098,7 +3097,7 @@ waitingDiv = assert(page.shadowRoot.querySelector('#waiting')); LockScreenSupport = NoteAppLockScreenSupport; - assertEquals(1, browserProxy.requestNoteTakingApps_); + assertEquals(1, browserProxy.getCallCount('requestNoteTakingApps')); assert(browserProxy.onNoteTakingAppsUpdated_); }); }); @@ -3201,13 +3200,13 @@ entry('n2', 'v2', true, LockScreenSupport.NOT_SUPPORTED), ]); flush(); - assertEquals(0, browserProxy.setPreferredAppCount_); + assertEquals(0, browserProxy.getCallCount('setPreferredNoteTakingApp')); assertEquals('v2', browserProxy.getPreferredNoteTakingAppId()); // Update select element to new value, verify browser proxy is called. appSelector.value = 'v1'; stylusPage.onSelectedAppChanged_(); - assertEquals(1, browserProxy.setPreferredAppCount_); + assertEquals(1, browserProxy.getCallCount('setPreferredNoteTakingApp')); assertEquals('v1', browserProxy.getPreferredNoteTakingAppId()); }); @@ -3232,7 +3231,7 @@ entry('n2', 'v2', true, LockScreenSupport.NOT_SUPPORTED), ]); flush(); - assertEquals(0, browserProxy.setPreferredAppCount_); + assertEquals(0, browserProxy.getCallCount('setPreferredNoteTakingApp')); assertEquals('v2', browserProxy.getPreferredNoteTakingAppId()); }); @@ -3326,7 +3325,8 @@ // Select the app with lock screen app support. appSelector.value = 'v2'; stylusPage.onSelectedAppChanged_(); - assertEquals(1, browserProxy.setPreferredAppCount_); + assertEquals( + 1, browserProxy.getCallCount('setPreferredNoteTakingApp')); assertEquals('v2', browserProxy.getPreferredNoteTakingAppId()); return new Promise(function(resolve) { @@ -3359,7 +3359,8 @@ // Select the app that does not support lock screen again. appSelector.value = 'v1'; stylusPage.onSelectedAppChanged_(); - assertEquals(2, browserProxy.setPreferredAppCount_); + assertEquals( + 2, browserProxy.getCallCount('setPreferredNoteTakingApp')); assertEquals('v1', browserProxy.getPreferredNoteTakingAppId()); return new Promise(function(resolve) { @@ -3441,7 +3442,10 @@ assertFalse(isVisible(enableAppOnLockScreenPolicyIndicator())); enableAppOnLockScreenToggle().click(); - assertEquals(1, browserProxy.setAppOnLockScreenCount_); + assertEquals( + 1, + browserProxy.getCallCount( + 'setPreferredNoteTakingAppEnabledOnLockScreen')); return new Promise(function(resolve) { microTask.run(resolve); @@ -3457,7 +3461,10 @@ browserProxy.getPreferredAppLockScreenState()); enableAppOnLockScreenToggle().click(); - assertEquals(2, browserProxy.setAppOnLockScreenCount_); + assertEquals( + 2, + browserProxy.getCallCount( + 'setPreferredNoteTakingAppEnabledOnLockScreen')); return new Promise(function(resolve) { microTask.run(resolve); @@ -3486,7 +3493,10 @@ assertFalse(enableAppOnLockScreenToggle().checked); enableAppOnLockScreenToggleLabel().click(); - assertEquals(1, browserProxy.setAppOnLockScreenCount_); + assertEquals( + 1, + browserProxy.getCallCount( + 'setPreferredNoteTakingAppEnabledOnLockScreen')); return new Promise(function(resolve) { microTask.run(resolve); @@ -3502,7 +3512,10 @@ browserProxy.getPreferredAppLockScreenState()); enableAppOnLockScreenToggleLabel().click(); - assertEquals(2, browserProxy.setAppOnLockScreenCount_); + assertEquals( + 2, + browserProxy.getCallCount( + 'setPreferredNoteTakingAppEnabledOnLockScreen')); return new Promise(function(resolve) { microTask.run(resolve); @@ -3537,7 +3550,10 @@ // The toggle should be disabled, so enabling app on lock screen // should not be attempted. enableAppOnLockScreenToggle().click(); - assertEquals(0, browserProxy.setAppOnLockScreenCount_); + assertEquals( + 0, + browserProxy.getCallCount( + 'setPreferredNoteTakingAppEnabledOnLockScreen')); return new Promise(function(resolve) { microTask.run(resolve); @@ -3548,7 +3564,10 @@ // Tap on label should not work either. enableAppOnLockScreenToggleLabel().click(); - assertEquals(0, browserProxy.setAppOnLockScreenCount_); + assertEquals( + 0, + browserProxy.getCallCount( + 'setPreferredNoteTakingAppEnabledOnLockScreen')); return new Promise(function(resolve) { microTask.run(resolve);
diff --git a/chrome/test/data/webui/settings/chromeos/per_device_keyboard_test.js b/chrome/test/data/webui/settings/chromeos/device_page/per_device_keyboard_test.js similarity index 98% rename from chrome/test/data/webui/settings/chromeos/per_device_keyboard_test.js rename to chrome/test/data/webui/settings/chromeos/device_page/per_device_keyboard_test.js index 2e826cb..9caa308 100644 --- a/chrome/test/data/webui/settings/chromeos/per_device_keyboard_test.js +++ b/chrome/test/data/webui/settings/chromeos/device_page/per_device_keyboard_test.js
@@ -172,7 +172,8 @@ .click(); assertEquals( 1, - DevicePageBrowserProxyImpl.getInstance().keyboardShortcutViewerShown_); + DevicePageBrowserProxyImpl.getInstance().getCallCount( + 'showKeyboardShortcutViewer')); }); test('Navigate to input tab', async () => {
diff --git a/chrome/test/data/webui/settings/chromeos/device_page/test_device_page_browser_proxy.ts b/chrome/test/data/webui/settings/chromeos/device_page/test_device_page_browser_proxy.ts new file mode 100644 index 0000000..2cff4ff5f --- /dev/null +++ b/chrome/test/data/webui/settings/chromeos/device_page/test_device_page_browser_proxy.ts
@@ -0,0 +1,248 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import {DevicePageBrowserProxy, IdleBehavior, LidClosedBehavior, NoteAppInfo, NoteAppLockScreenSupport} from 'chrome://os-settings/chromeos/os_settings.js'; +import {assert} from 'chrome://resources/js/assert_ts.js'; +import {webUIListenerCallback} from 'chrome://resources/js/cr.js'; +import {assertEquals} from 'chrome://webui-test/chai_assert.js'; +import {TestBrowserProxy} from 'chrome://webui-test/test_browser_proxy.js'; + +export class TestDevicePageBrowserProxy extends TestBrowserProxy implements + DevicePageBrowserProxy { + acIdleBehavior: IdleBehavior|undefined; + batteryIdleBehavior: IdleBehavior|undefined; + lastHighlightedDisplayId = '-1'; + lidClosedBehavior: LidClosedBehavior|undefined; + powerSourceId = '-1'; + + private androidAppsReceived_ = false; + private noteTakingApps_: NoteAppInfo[] = []; + private hasHapticTouchpad_ = true; + private hasKeyboard_ = true; + private hasMouse_ = true; + private hasPointingStick_ = true; + private hasTouchpad_ = true; + private onNoteTakingAppsUpdated_!: + (apps: NoteAppInfo[], waitingForAndroid: boolean) => void; + + constructor() { + super([ + 'requestNoteTakingApps', + 'requestPowerManagementSettings', + 'setPreferredNoteTakingApp', + 'setPreferredNoteTakingAppEnabledOnLockScreen', + 'showKeyboardShortcutViewer', + 'showPlayStore', + 'updatePowerStatus', + ]); + } + + set hasMouse(hasMouse: boolean) { + this.hasMouse_ = hasMouse; + webUIListenerCallback('has-mouse-changed', this.hasMouse_); + } + + set hasTouchpad(hasTouchpad: boolean) { + this.hasTouchpad_ = hasTouchpad; + webUIListenerCallback('has-touchpad-changed', this.hasTouchpad_); + } + + set hasPointingStick(hasPointingStick: boolean) { + this.hasPointingStick_ = hasPointingStick; + webUIListenerCallback('has-pointing-stick-changed', this.hasPointingStick_); + } + + set hasHapticTouchpad(hasHapticTouchpad: boolean) { + this.hasHapticTouchpad_ = hasHapticTouchpad; + webUIListenerCallback( + 'has-haptic-touchpad-changed', this.hasHapticTouchpad_); + } + + initializePointers(): void { + webUIListenerCallback('has-mouse-changed', this.hasMouse_); + webUIListenerCallback('has-touchpad-changed', this.hasTouchpad_); + webUIListenerCallback('has-pointing-stick-changed', this.hasPointingStick_); + webUIListenerCallback( + 'has-haptic-touchpad-changed', this.hasHapticTouchpad_); + } + + initializeStylus(): void { + // Enable stylus. + webUIListenerCallback('has-stylus-changed', true); + } + + initializeKeyboard(): void {} + + initializeKeyboardWatcher(): void { + webUIListenerCallback('has-hardware-keyboard', this.hasKeyboard_); + } + + showKeyboardShortcutViewer(): void { + this.methodCalled('showKeyboardShortcutViewer'); + } + + updateAndroidEnabled(): void {} + + updatePowerStatus(): void { + this.methodCalled('updatePowerStatus'); + } + + setPowerSource(powerSourceId: string): void { + this.powerSourceId = powerSourceId; + } + + requestPowerManagementSettings(): void { + this.methodCalled('requestPowerManagementSettings'); + } + + setIdleBehavior(behavior: IdleBehavior, whenOnAc: boolean): void { + if (whenOnAc) { + this.acIdleBehavior = behavior; + } else { + this.batteryIdleBehavior = behavior; + } + } + + setLidClosedBehavior(behavior: LidClosedBehavior): void { + this.lidClosedBehavior = behavior; + } + + setNoteTakingAppsUpdatedCallback( + callback: (apps: NoteAppInfo[], waitingForAndroid: boolean) => void): + void { + this.onNoteTakingAppsUpdated_ = callback; + } + + requestNoteTakingApps(): void { + this.methodCalled('requestNoteTakingApps'); + } + + setPreferredNoteTakingApp(appId: string): void { + this.methodCalled('setPreferredNoteTakingApp'); + + let changed = false; + this.noteTakingApps_.forEach((app) => { + changed = changed || app.preferred !== (app.value === appId); + app.preferred = app.value === appId; + }); + + if (changed) { + this.scheduleLockScreenAppsUpdated_(); + } + } + + setPreferredNoteTakingAppEnabledOnLockScreen(enabled: boolean): void { + this.methodCalled('setPreferredNoteTakingAppEnabledOnLockScreen'); + + this.noteTakingApps_.forEach((app) => { + if (enabled) { + if (app.preferred) { + assertEquals( + NoteAppLockScreenSupport.SUPPORTED, app.lockScreenSupport); + } + if (app.lockScreenSupport === NoteAppLockScreenSupport.SUPPORTED) { + app.lockScreenSupport = NoteAppLockScreenSupport.ENABLED; + } + } else { + if (app.preferred) { + assertEquals(NoteAppLockScreenSupport.ENABLED, app.lockScreenSupport); + } + if (app.lockScreenSupport === NoteAppLockScreenSupport.ENABLED) { + app.lockScreenSupport = NoteAppLockScreenSupport.SUPPORTED; + } + } + }); + + this.scheduleLockScreenAppsUpdated_(); + } + + highlightDisplay(id: string): void { + this.lastHighlightedDisplayId = id; + } + + dragDisplayDelta() {} + + openMyFiles() {} + + openBrowsingDataSettings() {} + + setAdaptiveCharging() {} + + setExternalStoragesUpdatedCallback() {} + + updateExternalStorages() {} + + updateStorageInfo() {} + + // Test interface: + /** + * Sets whether the app list contains Android apps. + * @param received Whether the list of Android note-taking apps was received. + */ + setAndroidAppsReceived(received: boolean): void { + this.androidAppsReceived_ = received; + + this.scheduleLockScreenAppsUpdated_(); + } + + /** + * @return App id of the app currently selected as preferred. + */ + getPreferredNoteTakingAppId(): string { + const app = this.noteTakingApps_.find((existing) => { + return existing.preferred; + }); + + return app ? app.value : ''; + } + + /** + * @return The lock screen support state of the app currently selected as + * preferred. + */ + getPreferredAppLockScreenState(): NoteAppLockScreenSupport|undefined { + const app = this.noteTakingApps_.find((existing) => { + return existing.preferred; + }); + + return app?.lockScreenSupport; + } + + /** + * Sets the current list of known note taking apps. + * @param apps The list of apps to set. + */ + setNoteTakingApps(apps: NoteAppInfo[]): void { + this.noteTakingApps_ = apps; + this.scheduleLockScreenAppsUpdated_(); + } + + /** + * Adds an app to the list of known note-taking apps. + */ + addNoteTakingApp(app: NoteAppInfo): void { + const appAlreadyExists = this.noteTakingApps_.find((existing) => { + return existing.value === app.value; + }); + assert(!appAlreadyExists); + + this.noteTakingApps_.push(app); + this.scheduleLockScreenAppsUpdated_(); + } + + /** + * Invokes the registered note taking apps update callback. + */ + private scheduleLockScreenAppsUpdated_(): void { + this.onNoteTakingAppsUpdated_( + this.noteTakingApps_.map((app) => { + return Object.assign({}, app); + }), + !this.androidAppsReceived_); + } + + showPlayStore(url: string): void { + this.methodCalled(this.showPlayStore.name, url); + } +}
diff --git a/chrome/test/data/webui/settings/chromeos/manage_accessibility_page_tests.js b/chrome/test/data/webui/settings/chromeos/manage_accessibility_page_tests.js index 5897ea6..84ac7b6 100644 --- a/chrome/test/data/webui/settings/chromeos/manage_accessibility_page_tests.js +++ b/chrome/test/data/webui/settings/chromeos/manage_accessibility_page_tests.js
@@ -12,7 +12,7 @@ import {waitAfterNextRender, waitBeforeNextRender} from 'chrome://webui-test/polymer_test_util.js'; import {eventToPromise, isVisible} from 'chrome://webui-test/test_util.js'; -import {TestDevicePageBrowserProxy} from './test_device_page_browser_proxy.js'; +import {TestDevicePageBrowserProxy} from './device_page/test_device_page_browser_proxy.js'; suite('ManageAccessibilityPageTests', function() { let page = null;
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 ba427dc..42d6b7bc 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
@@ -39,7 +39,7 @@ var OSSettingsDevicePageV3Test = class extends OSSettingsV3BrowserTest { /** @override */ get browsePreload() { - return 'chrome://os-settings/test_loader.html?module=settings/chromeos/device_page_tests.js'; + return 'chrome://os-settings/test_loader.html?module=settings/chromeos/device_page/device_page_tests.js'; } /** @override */ @@ -204,7 +204,7 @@ 'AccessibilityPage', 'os_a11y_page_tests.js', {enabled: ['features::kPdfOcr']}, - ], +], ['AboutPage', 'os_about_page_tests.js'], ['ApnDetailDialog', 'apn_detail_dialog_tests.js'], [ @@ -266,6 +266,10 @@ ['DateTimePageTimezoneSelector', 'date_time_page/timezone_selector_test.js'], ['DateTimePageTimezoneSubpage', 'date_time_page/timezone_subpage_test.js'], [ + 'DevicePagePerDeviceKeyboard', 'device_page/per_device_keyboard_test.js', + {enabled: ['ash::features::kInputDeviceSettingsSplit']} + ], + [ 'DevicePagePerDeviceMouse', 'device_page/per_device_mouse_test.js', {enabled: ['ash::features::kInputDeviceSettingsSplit']} ], @@ -476,10 +480,6 @@ ], ['PeoplePageQuickUnlock', 'quick_unlock_authenticate_browsertest_chromeos.js'], [ - 'PerDeviceKeyboard', 'per_device_keyboard_test.js', - {enabled: ['ash::features::kInputDeviceSettingsSplit']} - ], - [ 'PerDeviceKeyboardRemapKeys', 'per_device_keyboard_remap_keys_test.js', {enabled: ['ash::features::kInputDeviceSettingsSplit']} ],
diff --git a/chrome/test/data/webui/settings/chromeos/test_device_page_browser_proxy.js b/chrome/test/data/webui/settings/chromeos/test_device_page_browser_proxy.js deleted file mode 100644 index 84532588..0000000 --- a/chrome/test/data/webui/settings/chromeos/test_device_page_browser_proxy.js +++ /dev/null
@@ -1,235 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import {NoteAppLockScreenSupport} from 'chrome://os-settings/chromeos/os_settings.js'; -import {assert} from 'chrome://resources/ash/common/assert.js'; -import {webUIListenerCallback} from 'chrome://resources/ash/common/cr.m.js'; -import {assertEquals} from 'chrome://webui-test/chai_assert.js'; -import {TestBrowserProxy} from 'chrome://webui-test/test_browser_proxy.js'; - -export class TestDevicePageBrowserProxy extends TestBrowserProxy { - constructor() { - super([ - 'showPlayStore', - ]); - - this.keyboardShortcutViewerShown_ = 0; - this.updatePowerStatusCalled_ = 0; - this.requestPowerManagementSettingsCalled_ = 0; - this.requestNoteTakingApps_ = 0; - this.onNoteTakingAppsUpdated_ = null; - - this.androidAppsReceived_ = false; - this.noteTakingApps_ = []; - this.setPreferredAppCount_ = 0; - this.setAppOnLockScreenCount_ = 0; - - this.lastHighlightedDisplayId_ = '-1'; - - this.hasMouse_ = true; - this.hasTouchpad_ = true; - this.hasPointingStick_ = true; - this.hasHapticTouchpad_ = true; - } - - /** @param {boolean} hasMouse */ - set hasMouse(hasMouse) { - this.hasMouse_ = hasMouse; - webUIListenerCallback('has-mouse-changed', this.hasMouse_); - } - - /** @param {boolean} hasTouchpad */ - set hasTouchpad(hasTouchpad) { - this.hasTouchpad_ = hasTouchpad; - webUIListenerCallback('has-touchpad-changed', this.hasTouchpad_); - } - - /** @param {boolean} hasPointingStick */ - set hasPointingStick(hasPointingStick) { - this.hasPointingStick_ = hasPointingStick; - webUIListenerCallback('has-pointing-stick-changed', this.hasPointingStick_); - } - - /** @param {boolean} hasHapticTouchpad */ - set hasHapticTouchpad(hasHapticTouchpad) { - this.hasHapticTouchpad_ = hasHapticTouchpad; - webUIListenerCallback( - 'has-haptic-touchpad-changed', this.hasHapticTouchpad_); - } - - initializePointers() { - webUIListenerCallback('has-mouse-changed', this.hasMouse_); - webUIListenerCallback('has-touchpad-changed', this.hasTouchpad_); - webUIListenerCallback('has-pointing-stick-changed', this.hasPointingStick_); - webUIListenerCallback( - 'has-haptic-touchpad-changed', this.hasHapticTouchpad_); - } - - initializeStylus() { - // Enable stylus. - webUIListenerCallback('has-stylus-changed', true); - } - - initializeKeyboard() {} - - initializeKeyboardWatcher() { - webUIListenerCallback('has-hardware-keyboard', this.hasKeyboard_); - } - - showKeyboardShortcutViewer() { - this.keyboardShortcutViewerShown_++; - } - - updateAndroidEnabled() {} - - updatePowerStatus() { - this.updatePowerStatusCalled_++; - } - - setPowerSource(powerSourceId) { - this.powerSourceId_ = powerSourceId; - } - - requestPowerManagementSettings() { - this.requestPowerManagementSettingsCalled_++; - } - - setIdleBehavior(behavior, whenOnAc) { - if (whenOnAc) { - this.acIdleBehavior_ = behavior; - } else { - this.batteryIdleBehavior_ = behavior; - } - } - - setLidClosedBehavior(behavior) { - this.lidClosedBehavior_ = behavior; - } - - setNoteTakingAppsUpdatedCallback(callback) { - this.onNoteTakingAppsUpdated_ = callback; - } - - requestNoteTakingApps() { - this.requestNoteTakingApps_++; - } - - setPreferredNoteTakingApp(appId) { - ++this.setPreferredAppCount_; - - let changed = false; - this.noteTakingApps_.forEach((app) => { - changed = changed || app.preferred !== (app.value === appId); - app.preferred = app.value === appId; - }); - - if (changed) { - this.scheduleLockScreenAppsUpdated_(); - } - } - - setPreferredNoteTakingAppEnabledOnLockScreen(enabled) { - ++this.setAppOnLockScreenCount_; - - this.noteTakingApps_.forEach((app) => { - if (enabled) { - if (app.preferred) { - assertEquals( - NoteAppLockScreenSupport.SUPPORTED, app.lockScreenSupport); - } - if (app.lockScreenSupport === NoteAppLockScreenSupport.SUPPORTED) { - app.lockScreenSupport = NoteAppLockScreenSupport.ENABLED; - } - } else { - if (app.preferred) { - assertEquals(NoteAppLockScreenSupport.ENABLED, app.lockScreenSupport); - } - if (app.lockScreenSupport === NoteAppLockScreenSupport.ENABLED) { - app.lockScreenSupport = NoteAppLockScreenSupport.SUPPORTED; - } - } - }); - - this.scheduleLockScreenAppsUpdated_(); - } - - highlightDisplay(id) { - this.lastHighlightedDisplayId_ = id; - } - - updateStorageInfo() {} - - // Test interface: - /** - * Sets whether the app list contains Android apps. - * @param {boolean} Whether the list of Android note-taking apps was - * received. - */ - setAndroidAppsReceived(received) { - this.androidAppsReceived_ = received; - - this.scheduleLockScreenAppsUpdated_(); - } - - /** - * @return {string} App id of the app currently selected as preferred. - */ - getPreferredNoteTakingAppId() { - const app = this.noteTakingApps_.find(function(existing) { - return existing.preferred; - }); - - return app ? app.value : ''; - } - - /** - * @return {NoteAppLockScreenSupport | undefined} The lock screen - * support state of the app currently selected as preferred. - */ - getPreferredAppLockScreenState() { - const app = this.noteTakingApps_.find(function(existing) { - return existing.preferred; - }); - - return app ? app.lockScreenSupport : undefined; - } - - /** - * Sets the current list of known note taking apps. - * @param {Array<!NoteAppInfo>} The list of apps to set. - */ - setNoteTakingApps(apps) { - this.noteTakingApps_ = apps; - this.scheduleLockScreenAppsUpdated_(); - } - - /** - * Adds an app to the list of known note-taking apps. - * @param {!NoteAppInfo} - */ - addNoteTakingApp(app) { - assert(!this.noteTakingApps_.find((existing) => { - return existing.value === app.value; - })); - - this.noteTakingApps_.push(app); - this.scheduleLockScreenAppsUpdated_(); - } - - /** - * Invokes the registered note taking apps update callback. - * @private - */ - scheduleLockScreenAppsUpdated_() { - this.onNoteTakingAppsUpdated_( - this.noteTakingApps_.map((app) => { - return Object.assign({}, app); - }), - !this.androidAppsReceived_); - } - - showPlayStore(url) { - this.methodCalled(this.showPlayStore.name, url); - } -}
diff --git a/chrome/updater/test/integration_tests.cc b/chrome/updater/test/integration_tests.cc index 92b612b8..036c396 100644 --- a/chrome/updater/test/integration_tests.cc +++ b/chrome/updater/test/integration_tests.cc
@@ -91,6 +91,9 @@ protected: void SetUp() override { +#if BUILDFLAG(IS_WIN) && defined(ARCH_CPU_ARM64) + GTEST_SKIP() << "Integration tests disabled on Arm64 Win"; +#else ASSERT_NO_FATAL_FAILURE(CleanProcesses()); ASSERT_TRUE(WaitForUpdaterExit()); ASSERT_NO_FATAL_FAILURE(Clean()); @@ -98,7 +101,7 @@ // TODO(crbug.com/1233612) - reenable the code when system tests pass. // SetUpTestService(); ASSERT_NO_FATAL_FAILURE(EnterTestMode(GURL("http://localhost:1234"))); - +#endif #if BUILDFLAG(IS_LINUX) // On LUCI the XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS environment // variables may not be set. These are required for systemctl to connect to
diff --git a/chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.cc b/chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.cc index 3ab02ce..c0f5e027 100644 --- a/chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.cc +++ b/chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.cc
@@ -4,7 +4,6 @@ #include "chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.h" -#include <dbus/dbus-protocol.h> #include <fcntl.h> #include <stddef.h> #include <stdint.h> @@ -22,7 +21,6 @@ #include "base/json/json_string_value_serializer.h" #include "base/location.h" #include "base/logging.h" -#include "base/no_destructor.h" #include "base/observer_list.h" #include "base/posix/eintr_wrapper.h" #include "base/strings/string_split.h" @@ -33,6 +31,7 @@ #include "chromeos/ash/components/dbus/cryptohome/rpc.pb.h" #include "chromeos/ash/components/dbus/debug_daemon/fake_debug_daemon_client.h" #include "chromeos/ash/components/dbus/debug_daemon/metrics.h" +#include "chromeos/dbus/common/dbus_library_error.h" #include "chromeos/dbus/common/pipe_reader.h" #include "dbus/bus.h" #include "dbus/message.h" @@ -126,21 +125,6 @@ DebugDaemonClient::GetLogsCallback callback_; }; -// Convert the string representation of a D-Bus error into a -// DbusLibraryError value. -DbusLibraryError DbusLibraryErrorFromString( - const std::string& dbus_error_string) { - static const base::NoDestructor<std::map<std::string, DbusLibraryError>> - error_string_map({ - {DBUS_ERROR_NO_REPLY, DbusLibraryError::kNoReply}, - {DBUS_ERROR_TIMEOUT, DbusLibraryError::kTimeout}, - }); - - auto it = error_string_map->find(dbus_error_string); - return it != error_string_map->end() ? it->second - : DbusLibraryError::kGenericError; -} - // The DebugDaemonClient implementation used in production. class DebugDaemonClientImpl : public DebugDaemonClient { public: @@ -1028,7 +1012,8 @@ dbus::MessageReader err_reader(err_response); err_str = err_response->GetErrorName(); } - DbusLibraryError dbus_error = DbusLibraryErrorFromString(err_str); + chromeos::DBusLibraryError dbus_error = + chromeos::DBusLibraryErrorFromString(err_str); std::move(callback).Run(dbus_error); }
diff --git a/chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.h b/chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.h index 49ca91d7e..19d1925 100644 --- a/chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.h +++ b/chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.h
@@ -31,13 +31,6 @@ namespace ash { -// A DbusLibraryError represents an error response received from D-Bus. -enum DbusLibraryError { - kGenericError = -1, // Catch-all generic error - kNoReply = -2, // debugd did not respond before timeout - kTimeout = -3 // Unspecified D-Bus timeout (e.g. socket error) -}; - // DebugDaemonClient is used to communicate with the debug daemon. class COMPONENT_EXPORT(DEBUG_DAEMON) DebugDaemonClient : public chromeos::DBusClient,
diff --git a/chromeos/ash/components/dbus/printscanmgr/BUILD.gn b/chromeos/ash/components/dbus/printscanmgr/BUILD.gn new file mode 100644 index 0000000..9ca84e53 --- /dev/null +++ b/chromeos/ash/components/dbus/printscanmgr/BUILD.gn
@@ -0,0 +1,24 @@ +# Copyright 2023 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/ui.gni") + +assert(is_chromeos_ash, "Non-ChromeOS builds cannot depend on //chromeos/ash") + +component("printscanmgr") { + defines = [ "IS_PRINTSCANMGR_IMPL" ] + + deps = [ + "//base", + "//chromeos/dbus/common", + "//dbus", + ] + + sources = [ + "fake_printscanmgr_client.cc", + "fake_printscanmgr_client.h", + "printscanmgr_client.cc", + "printscanmgr_client.h", + ] +}
diff --git a/chromeos/ash/components/dbus/printscanmgr/OWNERS b/chromeos/ash/components/dbus/printscanmgr/OWNERS new file mode 100644 index 0000000..b67d268 --- /dev/null +++ b/chromeos/ash/components/dbus/printscanmgr/OWNERS
@@ -0,0 +1 @@ +file://chromeos/printing/OWNERS
diff --git a/chromeos/ash/components/dbus/printscanmgr/fake_printscanmgr_client.cc b/chromeos/ash/components/dbus/printscanmgr/fake_printscanmgr_client.cc new file mode 100644 index 0000000..576dc7e --- /dev/null +++ b/chromeos/ash/components/dbus/printscanmgr/fake_printscanmgr_client.cc
@@ -0,0 +1,63 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromeos/ash/components/dbus/printscanmgr/fake_printscanmgr_client.h" + +#include "base/containers/contains.h" +#include "base/functional/bind.h" +#include "base/task/single_thread_task_runner.h" + +namespace ash { + +FakePrintscanmgrClient::FakePrintscanmgrClient() = default; +FakePrintscanmgrClient::~FakePrintscanmgrClient() = default; + +void FakePrintscanmgrClient::Init(dbus::Bus* bus) {} + +void FakePrintscanmgrClient::CupsAddManuallyConfiguredPrinter( + const std::string& name, + const std::string& uri, + const std::string& ppd_contents, + CupsAddPrinterCallback callback) { + printers_.insert(name); + base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), 0)); +} + +void FakePrintscanmgrClient::CupsAddAutoConfiguredPrinter( + const std::string& name, + const std::string& uri, + CupsAddPrinterCallback callback) { + printers_.insert(name); + base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), 0)); +} + +void FakePrintscanmgrClient::CupsRemovePrinter( + const std::string& name, + CupsRemovePrinterCallback callback, + base::OnceClosure error_callback) { + const bool has_printer = base::Contains(printers_, name); + if (has_printer) { + printers_.erase(name); + } + + base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), has_printer)); +} + +void FakePrintscanmgrClient::CupsRetrievePrinterPpd( + const std::string& name, + CupsRetrievePrinterPpdCallback callback, + base::OnceClosure error_callback) { + base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), ppd_data_)); +} + +void FakePrintscanmgrClient::SetPpdDataForTesting( + const std::vector<uint8_t>& data) { + ppd_data_ = data; +} + +} // namespace ash
diff --git a/chromeos/ash/components/dbus/printscanmgr/fake_printscanmgr_client.h b/chromeos/ash/components/dbus/printscanmgr/fake_printscanmgr_client.h new file mode 100644 index 0000000..daf5d44 --- /dev/null +++ b/chromeos/ash/components/dbus/printscanmgr/fake_printscanmgr_client.h
@@ -0,0 +1,56 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROMEOS_ASH_COMPONENTS_DBUS_PRINTSCANMGR_FAKE_PRINTSCANMGR_CLIENT_H_ +#define CHROMEOS_ASH_COMPONENTS_DBUS_PRINTSCANMGR_FAKE_PRINTSCANMGR_CLIENT_H_ + +#include <stdint.h> + +#include <set> +#include <string> +#include <vector> + +#include "chromeos/ash/components/dbus/printscanmgr/printscanmgr_client.h" + +namespace ash { + +// Implementation of PrintscanmgrClient used for testing. +class COMPONENT_EXPORT(PRINTSCANMGR) FakePrintscanmgrClient + : public PrintscanmgrClient { + public: + FakePrintscanmgrClient(); + FakePrintscanmgrClient(const FakePrintscanmgrClient&) = delete; + FakePrintscanmgrClient& operator=(const FakePrintscanmgrClient&) = delete; + ~FakePrintscanmgrClient() override; + + // DBusClient overrides: + void Init(dbus::Bus* bus) override; + + // PrintscanmgrClient overrides: + void CupsAddManuallyConfiguredPrinter( + const std::string& name, + const std::string& uri, + const std::string& ppd_contents, + CupsAddPrinterCallback callback) override; + void CupsAddAutoConfiguredPrinter(const std::string& name, + const std::string& uri, + CupsAddPrinterCallback callback) override; + void CupsRemovePrinter(const std::string& name, + CupsRemovePrinterCallback callback, + base::OnceClosure error_callback) override; + void CupsRetrievePrinterPpd(const std::string& name, + CupsRetrievePrinterPpdCallback callback, + base::OnceClosure error_callback) override; + + // Sets PPD data that will be returned by CupsRetrievePrinterPpd for testing. + void SetPpdDataForTesting(const std::vector<uint8_t>& data); + + private: + std::set<std::string> printers_; + std::vector<uint8_t> ppd_data_; +}; + +} // namespace ash + +#endif // CHROMEOS_ASH_COMPONENTS_DBUS_PRINTSCANMGR_FAKE_PRINTSCANMGR_CLIENT_H_
diff --git a/chromeos/ash/components/dbus/printscanmgr/printscanmgr_client.cc b/chromeos/ash/components/dbus/printscanmgr/printscanmgr_client.cc new file mode 100644 index 0000000..5f13e00 --- /dev/null +++ b/chromeos/ash/components/dbus/printscanmgr/printscanmgr_client.cc
@@ -0,0 +1,217 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromeos/ash/components/dbus/printscanmgr/printscanmgr_client.h" + +#include <stdint.h> + +#include <string> +#include <utility> +#include <vector> + +#include "base/check.h" +#include "base/check_op.h" +#include "base/logging.h" +#include "base/memory/weak_ptr.h" +#include "chromeos/ash/components/dbus/printscanmgr/fake_printscanmgr_client.h" +#include "chromeos/dbus/common/dbus_library_error.h" +#include "dbus/message.h" +#include "dbus/object_path.h" +#include "dbus/object_proxy.h" +#include "third_party/cros_system_api/dbus/service_constants.h" + +namespace ash { + +namespace { + +PrintscanmgrClient* g_instance = nullptr; + +// The PrintscanmgrClient implementation used in production. +class PrintscanmgrClientImpl : public PrintscanmgrClient { + public: + PrintscanmgrClientImpl() = default; + PrintscanmgrClientImpl(const PrintscanmgrClientImpl&) = delete; + PrintscanmgrClientImpl& operator=(const PrintscanmgrClientImpl&) = delete; + ~PrintscanmgrClientImpl() override = default; + + // DBusClient overrides: + void Init(dbus::Bus* bus) override { + printscanmgr_proxy_ = bus->GetObjectProxy( + printscanmgr::kPrintscanmgrServiceName, + dbus::ObjectPath(printscanmgr::kPrintscanmgrServicePath)); + } + + // PrintscanmgrClient overrides: + void CupsAddManuallyConfiguredPrinter( + const std::string& name, + const std::string& uri, + const std::string& ppd_contents, + PrintscanmgrClient::CupsAddPrinterCallback callback) override { + dbus::MethodCall method_call( + printscanmgr::kPrintscanmgrInterface, + printscanmgr::kCupsAddManuallyConfiguredPrinter); + dbus::MessageWriter writer(&method_call); + writer.AppendString(name); + writer.AppendString(uri); + writer.AppendArrayOfBytes( + reinterpret_cast<const uint8_t*>(ppd_contents.data()), + ppd_contents.size()); + + printscanmgr_proxy_->CallMethodWithErrorResponse( + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, + base::BindOnce(&PrintscanmgrClientImpl::OnPrinterAdded, + weak_ptr_factory_.GetWeakPtr(), std::move(callback))); + } + + void CupsAddAutoConfiguredPrinter( + const std::string& name, + const std::string& uri, + PrintscanmgrClient::CupsAddPrinterCallback callback) override { + dbus::MethodCall method_call(printscanmgr::kPrintscanmgrInterface, + printscanmgr::kCupsAddAutoConfiguredPrinter); + dbus::MessageWriter writer(&method_call); + writer.AppendString(name); + writer.AppendString(uri); + + printscanmgr_proxy_->CallMethodWithErrorResponse( + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, + base::BindOnce(&PrintscanmgrClientImpl::OnPrinterAdded, + weak_ptr_factory_.GetWeakPtr(), std::move(callback))); + } + + void CupsRemovePrinter(const std::string& name, + PrintscanmgrClient::CupsRemovePrinterCallback callback, + base::OnceClosure error_callback) override { + dbus::MethodCall method_call(printscanmgr::kPrintscanmgrInterface, + printscanmgr::kCupsRemovePrinter); + dbus::MessageWriter writer(&method_call); + writer.AppendString(name); + + printscanmgr_proxy_->CallMethod( + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, + base::BindOnce(&PrintscanmgrClientImpl::OnPrinterRemoved, + weak_ptr_factory_.GetWeakPtr(), std::move(callback), + std::move(error_callback))); + } + + void CupsRetrievePrinterPpd( + const std::string& name, + PrintscanmgrClient::CupsRetrievePrinterPpdCallback callback, + base::OnceClosure error_callback) override { + dbus::MethodCall method_call(printscanmgr::kPrintscanmgrInterface, + printscanmgr::kCupsRetrievePpd); + dbus::MessageWriter writer(&method_call); + writer.AppendString(name); + + printscanmgr_proxy_->CallMethod( + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, + base::BindOnce(&PrintscanmgrClientImpl::OnRetrievedPrinterPpd, + weak_ptr_factory_.GetWeakPtr(), std::move(callback), + std::move(error_callback))); + } + + private: + void OnPrinterAdded(CupsAddPrinterCallback callback, + dbus::Response* response, + dbus::ErrorResponse* err_response) { + if (!response) { + SendErrorResponse(std::move(callback), err_response); + return; + } + + int32_t result; + if (!dbus::MessageReader(response).PopInt32(&result)) { + SendErrorResponse(std::move(callback), err_response); + return; + } + + DCHECK_GE(result, 0); + std::move(callback).Run(result); + } + + void OnPrinterRemoved(CupsRemovePrinterCallback callback, + base::OnceClosure error_callback, + dbus::Response* response) { + if (!response) { + std::move(error_callback).Run(); + return; + } + + bool result; + if (!dbus::MessageReader(response).PopBool(&result)) { + std::move(error_callback).Run(); + return; + } + + std::move(callback).Run(result); + } + + void OnRetrievedPrinterPpd(CupsRetrievePrinterPpdCallback callback, + base::OnceClosure error_callback, + dbus::Response* response) { + size_t length = 0; + const uint8_t* bytes = nullptr; + + if (!(response && + dbus::MessageReader(response).PopArrayOfBytes(&bytes, &length)) || + length == 0 || bytes == nullptr) { + LOG(ERROR) << "Failed to retrieve printer PPD"; + std::move(error_callback).Run(); + return; + } + + std::vector<uint8_t> data(bytes, bytes + length); + std::move(callback).Run(data); + } + + void SendErrorResponse(CupsAddPrinterCallback callback, + dbus::ErrorResponse* err_response) { + chromeos::DBusLibraryError dbus_error = + chromeos::DBusLibraryError::kGenericError; + if (err_response) { + dbus::MessageReader err_reader(err_response); + std::string err_str = err_response->GetErrorName(); + dbus_error = chromeos::DBusLibraryErrorFromString(err_str); + } + + std::move(callback).Run(dbus_error); + } + + dbus::ObjectProxy* printscanmgr_proxy_ = nullptr; + base::WeakPtrFactory<PrintscanmgrClientImpl> weak_ptr_factory_{this}; +}; + +} // namespace + +// static +PrintscanmgrClient* PrintscanmgrClient::Get() { + return g_instance; +} + +// static +void PrintscanmgrClient::Initialize(dbus::Bus* bus) { + CHECK(bus); + CHECK(!g_instance); + g_instance = new PrintscanmgrClientImpl(); + g_instance->Init(bus); +} + +// static +void PrintscanmgrClient::InitializeFake() { + CHECK(!g_instance); + g_instance = new FakePrintscanmgrClient(); + g_instance->Init(nullptr); +} + +// static +void PrintscanmgrClient::Shutdown() { + CHECK(g_instance); + delete g_instance; + g_instance = nullptr; +} + +PrintscanmgrClient::PrintscanmgrClient() = default; +PrintscanmgrClient::~PrintscanmgrClient() = default; + +} // namespace ash
diff --git a/chromeos/ash/components/dbus/printscanmgr/printscanmgr_client.h b/chromeos/ash/components/dbus/printscanmgr/printscanmgr_client.h new file mode 100644 index 0000000..0305b74 --- /dev/null +++ b/chromeos/ash/components/dbus/printscanmgr/printscanmgr_client.h
@@ -0,0 +1,94 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROMEOS_ASH_COMPONENTS_DBUS_PRINTSCANMGR_PRINTSCANMGR_CLIENT_H_ +#define CHROMEOS_ASH_COMPONENTS_DBUS_PRINTSCANMGR_PRINTSCANMGR_CLIENT_H_ + +#include <stdint.h> + +#include <string> +#include <vector> + +#include "base/component_export.h" +#include "base/functional/callback.h" +#include "chromeos/dbus/common/dbus_client.h" +#include "dbus/bus.h" + +namespace ash { + +// PrintscanmgrClient is used to communicate with the printscanmgr daemon. +class COMPONENT_EXPORT(PRINTSCANMGR) PrintscanmgrClient + : public chromeos::DBusClient { + public: + // Returns the global instance if initialized. May return null. + static PrintscanmgrClient* Get(); + + // Creates and initializes the global instance. `bus` must not be null. + static void Initialize(dbus::Bus* bus); + + // Creates and initializes a fake global instance. + static void InitializeFake(); + + // Destroys the global instance if it has been initialized. + static void Shutdown(); + + PrintscanmgrClient(const PrintscanmgrClient&) = delete; + PrintscanmgrClient& operator=(const PrintscanmgrClient&) = delete; + + ~PrintscanmgrClient() override; + + // A callback to handle the result of CupsAdd[Auto|Manually]ConfiguredPrinter. + // A negative value denotes a D-Bus library error while non-negative values + // denote a response from printscanmgr. + using CupsAddPrinterCallback = base::OnceCallback<void(int32_t)>; + + // Calls CupsAddManuallyConfiguredPrinter. `name` is the printer name. `uri` + // is the device. `ppd_contents` is the contents of the PPD file used to drive + // the device. Refer to the comment for `CupsAddPrinterCallback` for details + // on the format of `callback`. + virtual void CupsAddManuallyConfiguredPrinter( + const std::string& name, + const std::string& uri, + const std::string& ppd_contents, + CupsAddPrinterCallback callback) = 0; + + // Calls CupsAddAutoConfiguredPrinter. `name` is the printer name. `uri` is + // the device. Refer to the comment for `CupsAddPrinterCallback` for details + // on the format of `callback`. + virtual void CupsAddAutoConfiguredPrinter( + const std::string& name, + const std::string& uri, + CupsAddPrinterCallback callback) = 0; + + // A callback to handle the result of CupsRemovePrinter. + using CupsRemovePrinterCallback = base::OnceCallback<void(bool success)>; + + // Calls CupsRemovePrinter. `name` is the printer name as registered in CUPS. + // `callback` is called with true if removing the printer from CUPS was + // successful and false if there was an error. `error_callback` will be called + // if there was an error communicating with printscanmgr. + virtual void CupsRemovePrinter(const std::string& name, + CupsRemovePrinterCallback callback, + base::OnceClosure error_callback) = 0; + + // A callback to handle the result of CupsRetrievePrinterPpd. + using CupsRetrievePrinterPpdCallback = + base::OnceCallback<void(const std::vector<uint8_t>& ppd)>; + + // Calls the printscanmgr method to retrieve a PPD. `name` is the printer name + // as registered in CUPS. `callback` is called with a string containing the + // PPD data. `error_callback` will be called if there was an error retrieving + // the PPD. + virtual void CupsRetrievePrinterPpd(const std::string& name, + CupsRetrievePrinterPpdCallback callback, + base::OnceClosure error_callback) = 0; + + protected: + // Initialize() should be used instead. + PrintscanmgrClient(); +}; + +} // namespace ash + +#endif // CHROMEOS_ASH_COMPONENTS_DBUS_PRINTSCANMGR_PRINTSCANMGR_CLIENT_H_
diff --git a/chromeos/ash/components/drivefs/drivefs_pin_manager.cc b/chromeos/ash/components/drivefs/drivefs_pin_manager.cc index ee1d3dfd..a2e4076 100644 --- a/chromeos/ash/components/drivefs/drivefs_pin_manager.cc +++ b/chromeos/ash/components/drivefs/drivefs_pin_manager.cc
@@ -1046,25 +1046,7 @@ DCHECK_EQ(event.type, mojom::FileChange::Type::kDelete); VLOG(1) << "Got " << Quote(event); - const Path& path = event.path; - const Id id = static_cast<Id>(event.stable_id); - - // TODO(b/271203956) Remove this code once DriveFS automatically unpins - // deleted files and folders. - drivefs_->SetPinnedByStableId( - event.stable_id, /*pinned=*/false, - base::BindOnce( - [](const Id id, const Path& path, const drive::FileError status) { - if (status != drive::FILE_ERROR_OK) { - LOG(ERROR) << "Cannot unpin " << id << " " << Quote(path) << ": " - << status; - } else { - VLOG(1) << "Unpinned " << id << " " << Quote(path); - } - }, - id, path)); - - NotifyDelete(id, path); + NotifyDelete(Id(event.stable_id), event.path); } void PinManager::OnFileModified(const mojom::FileChange& event) {
diff --git a/chromeos/ash/components/drivefs/drivefs_pin_manager_unittest.cc b/chromeos/ash/components/drivefs/drivefs_pin_manager_unittest.cc index 4277ee0..ff81d622 100644 --- a/chromeos/ash/components/drivefs/drivefs_pin_manager_unittest.cc +++ b/chromeos/ash/components/drivefs/drivefs_pin_manager_unittest.cc
@@ -906,7 +906,7 @@ PinManager manager(temp_dir_.GetPath(), &drivefs_); DCHECK_CALLED_ON_VALID_SEQUENCE(manager.sequence_checker_); - EXPECT_EQ(manager.progress_.stage, Stage::kStopped); + manager.progress_.stage = Stage::kSyncing; const DriveItem item{.size = 2487}; const Path path("/root/Path 1"); @@ -916,15 +916,28 @@ event.stable_id = item.stable_id; event.path = path; - EXPECT_CALL(drivefs_, SetPinnedByStableId(item.stable_id, false, _)) - .WillOnce(RunOnceCallback<2>(kFileOk)); + // Add a tracked file. + ASSERT_TRUE(manager.Add(*MakeMetadata(item), path)); + EXPECT_THAT(manager.files_to_pin_, SizeIs(1)); + EXPECT_THAT(manager.files_to_track_, SizeIs(1)); + EXPECT_EQ(manager.progress_.failed_files, 0); + // Notify that the file has been deleted. manager.OnFileDeleted(std::as_const(event)); - EXPECT_CALL(drivefs_, SetPinnedByStableId(item.stable_id, false, _)) - .WillOnce(RunOnceCallback<2>(FileError::FILE_ERROR_ACCESS_DENIED)); + // The file should have been removed from the tracked files. + EXPECT_THAT(manager.files_to_pin_, IsEmpty()); + EXPECT_THAT(manager.files_to_track_, IsEmpty()); + EXPECT_EQ(manager.progress_.failed_files, 1); + // Receiving a delete notification for an untracked file shouldn't do + // anything. manager.OnFileDeleted(std::as_const(event)); + EXPECT_THAT(manager.files_to_pin_, IsEmpty()); + EXPECT_THAT(manager.files_to_track_, IsEmpty()); + EXPECT_EQ(manager.progress_.failed_files, 1); + + manager.Stop(); } // Tests PinManager::OnFilesChanged(). @@ -964,7 +977,6 @@ } EXPECT_CALL(drivefs_, GetMetadataByStableId(id, _)); - EXPECT_CALL(drivefs_, SetPinnedByStableId(id, false, _)); manager.OnFilesChanged(std::as_const(events)); manager.Stop();
diff --git a/chromeos/dbus/BUILD.gn b/chromeos/dbus/BUILD.gn index cdc2ed1..82478bc 100644 --- a/chromeos/dbus/BUILD.gn +++ b/chromeos/dbus/BUILD.gn
@@ -28,6 +28,7 @@ ] sources = [ "common/blocking_method_caller_unittest.cc", + "common/dbus_library_error_unittest.cc", "common/pipe_reader_unittest.cc", "tpm_manager/tpm_manager_client_unittest.cc", ]
diff --git a/chromeos/dbus/common/BUILD.gn b/chromeos/dbus/common/BUILD.gn index e42a17054..6258c33 100644 --- a/chromeos/dbus/common/BUILD.gn +++ b/chromeos/dbus/common/BUILD.gn
@@ -20,6 +20,8 @@ "blocking_method_caller.cc", "blocking_method_caller.h", "dbus_client.h", + "dbus_library_error.cc", + "dbus_library_error.h", "dbus_method_call_status.h", "pipe_reader.cc", "pipe_reader.h",
diff --git a/chromeos/dbus/common/dbus_library_error.cc b/chromeos/dbus/common/dbus_library_error.cc new file mode 100644 index 0000000..385272c --- /dev/null +++ b/chromeos/dbus/common/dbus_library_error.cc
@@ -0,0 +1,29 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromeos/dbus/common/dbus_library_error.h" + +#include <dbus/dbus-protocol.h> + +#include <map> +#include <string> + +#include "base/no_destructor.h" + +namespace chromeos { + +DBusLibraryError DBusLibraryErrorFromString( + const std::string& dbus_error_string) { + static const base::NoDestructor<std::map<std::string, DBusLibraryError>> + error_string_map({ + {DBUS_ERROR_NO_REPLY, DBusLibraryError::kNoReply}, + {DBUS_ERROR_TIMEOUT, DBusLibraryError::kTimeout}, + }); + + auto it = error_string_map->find(dbus_error_string); + return it != error_string_map->end() ? it->second + : DBusLibraryError::kGenericError; +} + +} // namespace chromeos
diff --git a/chromeos/dbus/common/dbus_library_error.h b/chromeos/dbus/common/dbus_library_error.h new file mode 100644 index 0000000..b258059 --- /dev/null +++ b/chromeos/dbus/common/dbus_library_error.h
@@ -0,0 +1,29 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROMEOS_DBUS_COMMON_DBUS_LIBRARY_ERROR_H_ +#define CHROMEOS_DBUS_COMMON_DBUS_LIBRARY_ERROR_H_ + +#include <string> + +#include "base/component_export.h" + +namespace chromeos { + +// A DBusLibraryError represents an error response received from D-Bus. +enum DBusLibraryError { + kGenericError = -1, // Catch-all generic error + kNoReply = -2, // debugd did not respond before timeout + kTimeout = -3 // Unspecified D-Bus timeout (e.g. socket error) +}; + +// Convert the string representation of a D-Bus error into a +// DBusLibraryError value. +COMPONENT_EXPORT(CHROMEOS_DBUS_COMMON) +DBusLibraryError DBusLibraryErrorFromString( + const std::string& dbus_error_string); + +} // namespace chromeos + +#endif // CHROMEOS_DBUS_COMMON_DBUS_LIBRARY_ERROR_H_
diff --git a/chromeos/dbus/common/dbus_library_error_unittest.cc b/chromeos/dbus/common/dbus_library_error_unittest.cc new file mode 100644 index 0000000..bd02708 --- /dev/null +++ b/chromeos/dbus/common/dbus_library_error_unittest.cc
@@ -0,0 +1,54 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromeos/dbus/common/dbus_library_error.h" + +#include <dbus/dbus-protocol.h> + +#include <string> + +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace chromeos { + +// POD struct for DBusLibraryErrorTest. +struct DBusLibraryErrorTestParams { + std::string dbus_error_in; + DBusLibraryError expected_error_out; +}; + +class DBusLibraryErrorTest + : public testing::Test, + public testing::WithParamInterface<DBusLibraryErrorTestParams> { + public: + DBusLibraryErrorTest() = default; + DBusLibraryErrorTest(const DBusLibraryErrorTest&) = delete; + DBusLibraryErrorTest& operator=(const DBusLibraryErrorTest&) = delete; + + DBusLibraryErrorTestParams params() const { return GetParam(); } +}; + +TEST_P(DBusLibraryErrorTest, DBusLibraryErrorFromString) { + DBusLibraryError actual_error_out = + DBusLibraryErrorFromString(params().dbus_error_in); + + EXPECT_EQ(params().expected_error_out, actual_error_out); +} + +INSTANTIATE_TEST_SUITE_P( + , + DBusLibraryErrorTest, + testing::Values( + DBusLibraryErrorTestParams{ + /*dbus_error_in=*/DBUS_ERROR_NO_REPLY, + /*expected_error_out=*/DBusLibraryError::kNoReply}, + DBusLibraryErrorTestParams{ + /*dbus_error_in=*/DBUS_ERROR_TIMEOUT, + /*expected_error_out=*/DBusLibraryError::kTimeout}, + DBusLibraryErrorTestParams{ + /*dbus_error_in=*/"Nonstandard error message", + /*expected_error_out=*/DBusLibraryError::kGenericError})); + +} // namespace chromeos
diff --git a/components/autofill/core/browser/autofill_feedback_data.cc b/components/autofill/core/browser/autofill_feedback_data.cc index fdaa5e7..4c0917d 100644 --- a/components/autofill/core/browser/autofill_feedback_data.cc +++ b/components/autofill/core/browser/autofill_feedback_data.cc
@@ -51,6 +51,14 @@ field->server_type_prediction_is_override()); field_data.Set("htmlType", FieldTypeToStringPiece(field->html_type())); field_data.Set("section", field->section.ToString()); + field_data.Set("rank", base::NumberToString(field->rank())); + field_data.Set("rankInSignatureGroup", + base::NumberToString(field->rank_in_signature_group())); + field_data.Set("rankInHostForm", + base::NumberToString(field->rank_in_host_form())); + field_data.Set( + "rankInHostFormSignatureGroup", + base::NumberToString(field->rank_in_host_form_signature_group())); field_data.Set("isEmpty", field->IsEmpty()); field_data.Set("isFocusable", field->IsFocusable());
diff --git a/components/autofill/core/browser/autofill_feedback_data_unittest.cc b/components/autofill/core/browser/autofill_feedback_data_unittest.cc index 2334b9f..72dd4e7 100644 --- a/components/autofill/core/browser/autofill_feedback_data_unittest.cc +++ b/components/autofill/core/browser/autofill_feedback_data_unittest.cc
@@ -43,6 +43,10 @@ "labelAttribute": "First Name on Card", "parseableNameAttribute": "", "placeholderAttribute": "", + "rank": "0", + "rankInHostForm": "0", + "rankInHostFormSignatureGroup": "0", + "rankInSignatureGroup": "0", "section": "firstnameoncard_0_11", "serverType": "NO_SERVER_DATA", "serverTypeIsOverride": false @@ -60,6 +64,10 @@ "labelAttribute": "Last Name on Card", "parseableNameAttribute": "", "placeholderAttribute": "", + "rank": "1", + "rankInHostForm": "1", + "rankInHostFormSignatureGroup": "0", + "rankInSignatureGroup": "0", "section": "firstnameoncard_0_11", "serverType": "NO_SERVER_DATA", "serverTypeIsOverride": false @@ -77,6 +85,10 @@ "labelAttribute": "Email", "parseableNameAttribute": "", "placeholderAttribute": "", + "rank": "2", + "rankInHostForm": "2", + "rankInHostFormSignatureGroup": "0", + "rankInSignatureGroup": "0", "section": "firstnameoncard_0_11", "serverType": "NO_SERVER_DATA", "serverTypeIsOverride": false
diff --git a/components/autofill/core/browser/autofill_save_update_address_profile_delegate_ios_unittest.cc b/components/autofill/core/browser/autofill_save_update_address_profile_delegate_ios_unittest.cc index 126650b..0dec105 100644 --- a/components/autofill/core/browser/autofill_save_update_address_profile_delegate_ios_unittest.cc +++ b/components/autofill/core/browser/autofill_save_update_address_profile_delegate_ios_unittest.cc
@@ -15,18 +15,28 @@ namespace autofill { +namespace { + +constexpr char16_t kTestEmail[] = u"test@email.com"; + +} // namespace + class AutofillSaveUpdateAddressProfileDelegateIOSTest : public testing::Test { protected: AutofillSaveUpdateAddressProfileDelegateIOSTest() = default; ~AutofillSaveUpdateAddressProfileDelegateIOSTest() override {} - void SetUp() override { profile_ = test::GetFullProfile(); } - std::unique_ptr<AutofillSaveUpdateAddressProfileDelegateIOS> CreateAutofillSaveUpdateAddressProfileDelegate( AutofillProfile* original_profile = nullptr, absl::optional<std::u16string> email = absl::nullopt, - bool is_migration_to_account = false) { + bool is_migration_to_account = false, + bool is_account_profile = false) { + profile_ = test::GetFullProfile(); + if (is_account_profile) { + profile_.set_source_for_testing( + autofill::AutofillProfile::Source::kAccount); + } return std::make_unique<AutofillSaveUpdateAddressProfileDelegateIOS>( profile_, original_profile, email, /*locale=*/"en-US", @@ -52,56 +62,6 @@ delegate->Accept(); } -// Tests that the delegate returns Save Address profile strings when the -// original_profile is supplied as nullptr to the delegate. -TEST_F(AutofillSaveUpdateAddressProfileDelegateIOSTest, - TestSaveAddressStrings) { - std::unique_ptr<AutofillSaveUpdateAddressProfileDelegateIOS> delegate = - CreateAutofillSaveUpdateAddressProfileDelegate(); - EXPECT_EQ(delegate->GetMessageActionText(), - l10n_util::GetStringUTF16( - IDS_IOS_AUTOFILL_SAVE_ADDRESS_MESSAGE_PRIMARY_ACTION)); - EXPECT_EQ( - delegate->GetMessageText(), - l10n_util::GetStringUTF16(IDS_IOS_AUTOFILL_SAVE_ADDRESS_MESSAGE_TITLE)); - EXPECT_EQ(delegate->GetDescription(), - std::u16string(u"John H. Doe, 666 Erebus St.")); -} - -// Tests the message UI strings when the profile is saved in the Google Account. -TEST_F(AutofillSaveUpdateAddressProfileDelegateIOSTest, - TestSaveAddressInAccountStrings) { - std::unique_ptr<AutofillSaveUpdateAddressProfileDelegateIOS> delegate = - CreateAutofillSaveUpdateAddressProfileDelegate(nullptr, u"test@gmail.com", - true); - EXPECT_EQ(delegate->GetDescription(), - l10n_util::GetStringFUTF16( - IDS_IOS_AUTOFILL_SAVE_ADDRESS_IN_ACCOUNT_MESSAGE_SUBTITLE, - u"test@gmail.com")); - EXPECT_EQ(delegate->GetMessageText(), - l10n_util::GetStringUTF16( - IDS_IOS_AUTOFILL_SAVE_ADDRESS_IN_ACCOUNT_MESSAGE_TITLE)); -} - -// Tests that the delegate returns Update Address profile strings when the -// original_profile is supplied to the delegate. -TEST_F(AutofillSaveUpdateAddressProfileDelegateIOSTest, - TestUpdateAddressStrings) { - AutofillProfile original_profile = test::GetFullProfile(); - original_profile.SetInfo(NAME_FULL, u"John Doe", "en-US"); - std::unique_ptr<AutofillSaveUpdateAddressProfileDelegateIOS> delegate = - CreateAutofillSaveUpdateAddressProfileDelegate(&original_profile); - - EXPECT_EQ(delegate->GetMessageActionText(), - l10n_util::GetStringUTF16( - IDS_IOS_AUTOFILL_UPDATE_ADDRESS_MESSAGE_PRIMARY_ACTION)); - EXPECT_EQ( - delegate->GetMessageText(), - l10n_util::GetStringUTF16(IDS_IOS_AUTOFILL_UPDATE_ADDRESS_MESSAGE_TITLE)); - EXPECT_EQ(delegate->GetDescription(), - std::u16string(u"John Doe, 666 Erebus St.")); -} - // Tests that the callback is run with kDeclined on destruction. TEST_F(AutofillSaveUpdateAddressProfileDelegateIOSTest, TestCallbackOnDestruction) { @@ -140,4 +100,84 @@ delegate->EditAccepted(); } +struct DelegateStringsTestCase { + bool is_migration; + bool is_update; + bool is_account_profile; + int expected_message_action_text_id; + int expected_message_text_id; + absl::variant<int, std::u16string> expected_description_or_id; +}; + +class DelegateStringsTest + : public AutofillSaveUpdateAddressProfileDelegateIOSTest, + public ::testing::WithParamInterface<DelegateStringsTestCase> { + protected: + bool is_migration() const { return GetParam().is_migration; } + bool is_update() const { return GetParam().is_update; } + bool is_account_profile() const { return GetParam().is_account_profile; } +}; + +// Tests the message title, subtitle and action text strings. +TEST_P(DelegateStringsTest, TestStrings) { + AutofillProfile original_profile = test::GetFullProfile(); + original_profile.SetInfo(NAME_FULL, u"John Doe", "en-US"); + + std::unique_ptr<AutofillSaveUpdateAddressProfileDelegateIOS> delegate = + CreateAutofillSaveUpdateAddressProfileDelegate( + is_update() ? &original_profile : nullptr, kTestEmail, is_migration(), + is_account_profile()); + + const DelegateStringsTestCase& test_case = GetParam(); + EXPECT_EQ( + delegate->GetMessageActionText(), + l10n_util::GetStringUTF16(test_case.expected_message_action_text_id)); + EXPECT_EQ(delegate->GetMessageText(), + l10n_util::GetStringUTF16(test_case.expected_message_text_id)); + if (absl::holds_alternative<int>(test_case.expected_description_or_id)) { + EXPECT_EQ( + delegate->GetDescription(), + l10n_util::GetStringFUTF16( + absl::get<int>(test_case.expected_description_or_id), kTestEmail)); + } else { + EXPECT_EQ(delegate->GetDescription(), + absl::get<std::u16string>(test_case.expected_description_or_id)); + } +} + +INSTANTIATE_TEST_SUITE_P( + AutofillSaveUpdateAddressProfileDelegateIOSTest, + DelegateStringsTest, + testing::Values( + // Tests strings for the save profile views. + DelegateStringsTestCase{ + false, false, false, + IDS_IOS_AUTOFILL_SAVE_ADDRESS_MESSAGE_PRIMARY_ACTION, + IDS_IOS_AUTOFILL_SAVE_ADDRESS_MESSAGE_TITLE, + u"John H. Doe, 666 Erebus St."}, + // Tests strings for the save profile in Google Account views. + DelegateStringsTestCase{ + false, false, true, + IDS_IOS_AUTOFILL_SAVE_ADDRESS_MESSAGE_PRIMARY_ACTION, + IDS_IOS_AUTOFILL_SAVE_ADDRESS_MESSAGE_TITLE, + IDS_IOS_AUTOFILL_SAVE_ADDRESS_IN_ACCOUNT_MESSAGE_SUBTITLE}, + // Test strings for the migration view. + DelegateStringsTestCase{ + true, false, false, + IDS_IOS_AUTOFILL_SAVE_ADDRESS_MESSAGE_PRIMARY_ACTION, + IDS_IOS_AUTOFILL_SAVE_ADDRESS_IN_ACCOUNT_MESSAGE_TITLE, + IDS_IOS_AUTOFILL_SAVE_ADDRESS_IN_ACCOUNT_MESSAGE_SUBTITLE}, + // Test strings for the update views. + DelegateStringsTestCase{ + false, true, false, + IDS_IOS_AUTOFILL_UPDATE_ADDRESS_MESSAGE_PRIMARY_ACTION, + IDS_IOS_AUTOFILL_UPDATE_ADDRESS_MESSAGE_TITLE, + u"John Doe, 666 Erebus St."}, + // Test strings for the update in Google Account views. + DelegateStringsTestCase{ + false, true, true, + IDS_IOS_AUTOFILL_UPDATE_ADDRESS_MESSAGE_PRIMARY_ACTION, + IDS_IOS_AUTOFILL_UPDATE_ADDRESS_MESSAGE_TITLE, + u"John Doe, 666 Erebus St."})); + } // namespace autofill
diff --git a/components/autofill_strings_grdp/IDS_IOS_AUTOFILL_SAVE_ADDRESS_IN_ACCOUNT_MESSAGE_SUBTITLE.png.sha1 b/components/autofill_strings_grdp/IDS_IOS_AUTOFILL_SAVE_ADDRESS_IN_ACCOUNT_MESSAGE_SUBTITLE.png.sha1 index 3dcd351..5385b707 100644 --- a/components/autofill_strings_grdp/IDS_IOS_AUTOFILL_SAVE_ADDRESS_IN_ACCOUNT_MESSAGE_SUBTITLE.png.sha1 +++ b/components/autofill_strings_grdp/IDS_IOS_AUTOFILL_SAVE_ADDRESS_IN_ACCOUNT_MESSAGE_SUBTITLE.png.sha1
@@ -1 +1 @@ -b4214a2043e947761426d150be7989ddd7910283 \ No newline at end of file +b4214a2043e947761426d150be7989ddd7910283
diff --git a/components/bookmarks/browser/bookmark_model.cc b/components/bookmarks/browser/bookmark_model.cc index 00653c7..1b582551a 100644 --- a/components/bookmarks/browser/bookmark_model.cc +++ b/components/bookmarks/browser/bookmark_model.cc
@@ -120,8 +120,6 @@ case StorageType::kLocalOrSyncable: return profile_path.Append(kLocalOrSyncableBookmarksFileName); case StorageType::kAccount: - // TODO(1404250): Remove NOTREACHED when account bookmarks are supported. - NOTREACHED(); return profile_path.Append(kAccountBookmarksFileName); } }
diff --git a/components/browser_ui/contacts_picker/android/BUILD.gn b/components/browser_ui/contacts_picker/android/BUILD.gn index 0c18af0..4645fbe 100644 --- a/components/browser_ui/contacts_picker/android/BUILD.gn +++ b/components/browser_ui/contacts_picker/android/BUILD.gn
@@ -100,12 +100,12 @@ "//components/payments/mojom:mojom_java", "//content/public/android:content_java", "//content/public/test/android:content_java_test_support", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_appcompat_appcompat_java", "//third_party/androidx:androidx_appcompat_appcompat_resources_java", "//third_party/androidx:androidx_core_core_java", "//third_party/androidx:androidx_recyclerview_recyclerview_java", + "//third_party/androidx:androidx_test_monitor_java", + "//third_party/androidx:androidx_test_rules_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/blink/public/mojom:android_mojo_bindings_java", "//third_party/junit",
diff --git a/components/browser_ui/contacts_picker/android/java/src/org/chromium/components/browser_ui/contacts_picker/ContactDetailsTest.java b/components/browser_ui/contacts_picker/android/java/src/org/chromium/components/browser_ui/contacts_picker/ContactDetailsTest.java index 0016f77..035a4fc 100644 --- a/components/browser_ui/contacts_picker/android/java/src/org/chromium/components/browser_ui/contacts_picker/ContactDetailsTest.java +++ b/components/browser_ui/contacts_picker/android/java/src/org/chromium/components/browser_ui/contacts_picker/ContactDetailsTest.java
@@ -10,8 +10,8 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; -import android.support.test.InstrumentationRegistry; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import org.junit.Assert;
diff --git a/components/browser_ui/contacts_picker/android/java/src/org/chromium/components/browser_ui/contacts_picker/ContactsPickerDialogTest.java b/components/browser_ui/contacts_picker/android/java/src/org/chromium/components/browser_ui/contacts_picker/ContactsPickerDialogTest.java index 7d5de5f..d55ad6a 100644 --- a/components/browser_ui/contacts_picker/android/java/src/org/chromium/components/browser_ui/contacts_picker/ContactsPickerDialogTest.java +++ b/components/browser_ui/contacts_picker/android/java/src/org/chromium/components/browser_ui/contacts_picker/ContactsPickerDialogTest.java
@@ -11,12 +11,12 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; -import android.support.test.InstrumentationRegistry; import android.view.View; import android.widget.Button; import android.widget.TextView; import androidx.recyclerview.widget.RecyclerView; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.LargeTest; import org.junit.After;
diff --git a/components/browser_ui/modaldialog/android/BUILD.gn b/components/browser_ui/modaldialog/android/BUILD.gn index da8d9ece..c42c884 100644 --- a/components/browser_ui/modaldialog/android/BUILD.gn +++ b/components/browser_ui/modaldialog/android/BUILD.gn
@@ -100,10 +100,10 @@ "//base:base_java_test_support", "//content/public/test/android:content_java_test_support", "//third_party/android_deps:espresso_java", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_activity_activity_java", "//third_party/androidx:androidx_annotation_annotation_java", + "//third_party/androidx:androidx_test_monitor_java", + "//third_party/androidx:androidx_test_rules_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/hamcrest:hamcrest_java", "//third_party/junit:junit",
diff --git a/components/browser_ui/photo_picker/android/BUILD.gn b/components/browser_ui/photo_picker/android/BUILD.gn index 8fbb47c..43e20b3 100644 --- a/components/browser_ui/photo_picker/android/BUILD.gn +++ b/components/browser_ui/photo_picker/android/BUILD.gn
@@ -159,13 +159,13 @@ "//components/browser_ui/widget/android:java", "//components/browser_ui/widget/android:test_support_java", "//content/public/test/android:content_java_test_support", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_activity_activity_java", "//third_party/androidx:androidx_appcompat_appcompat_java", "//third_party/androidx:androidx_appcompat_appcompat_resources_java", "//third_party/androidx:androidx_core_core_java", "//third_party/androidx:androidx_recyclerview_recyclerview_java", + "//third_party/androidx:androidx_test_monitor_java", + "//third_party/androidx:androidx_test_rules_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/hamcrest:hamcrest_java", "//third_party/junit",
diff --git a/components/browser_ui/photo_picker/android/java/src/org/chromium/components/browser_ui/photo_picker/DecoderServiceHostTest.java b/components/browser_ui/photo_picker/android/java/src/org/chromium/components/browser_ui/photo_picker/DecoderServiceHostTest.java index 552e9376..f4ab60198 100644 --- a/components/browser_ui/photo_picker/android/java/src/org/chromium/components/browser_ui/photo_picker/DecoderServiceHostTest.java +++ b/components/browser_ui/photo_picker/android/java/src/org/chromium/components/browser_ui/photo_picker/DecoderServiceHostTest.java
@@ -9,8 +9,8 @@ import android.graphics.Bitmap; import android.net.Uri; import android.os.Build; -import android.support.test.InstrumentationRegistry; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.LargeTest; import androidx.test.filters.SmallTest;
diff --git a/components/browser_ui/photo_picker/android/java/src/org/chromium/components/browser_ui/photo_picker/ImageDecoderTest.java b/components/browser_ui/photo_picker/android/java/src/org/chromium/components/browser_ui/photo_picker/ImageDecoderTest.java index d6abd62..6efa1f1 100644 --- a/components/browser_ui/photo_picker/android/java/src/org/chromium/components/browser_ui/photo_picker/ImageDecoderTest.java +++ b/components/browser_ui/photo_picker/android/java/src/org/chromium/components/browser_ui/photo_picker/ImageDecoderTest.java
@@ -12,8 +12,8 @@ import android.os.Bundle; import android.os.IBinder; import android.os.ParcelFileDescriptor; -import android.support.test.InstrumentationRegistry; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.LargeTest; import org.junit.Assert;
diff --git a/components/browser_ui/widget/android/BUILD.gn b/components/browser_ui/widget/android/BUILD.gn index 519b460..372665e 100644 --- a/components/browser_ui/widget/android/BUILD.gn +++ b/components/browser_ui/widget/android/BUILD.gn
@@ -331,12 +331,12 @@ "//components/browser_ui/test/android:test_support_java", "//components/browser_ui/theme/android:java_resources", "//content/public/test/android:content_java_test_support", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_annotation_annotation_java", "//third_party/androidx:androidx_appcompat_appcompat_resources_java", "//third_party/androidx:androidx_core_core_java", "//third_party/androidx:androidx_recyclerview_recyclerview_java", + "//third_party/androidx:androidx_test_monitor_java", + "//third_party/androidx:androidx_test_rules_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/hamcrest:hamcrest_java", "//third_party/junit",
diff --git a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/CheckBoxWithDescriptionTest.java b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/CheckBoxWithDescriptionTest.java index 3040e8ab..69472ca 100644 --- a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/CheckBoxWithDescriptionTest.java +++ b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/CheckBoxWithDescriptionTest.java
@@ -7,11 +7,11 @@ import static org.mockito.Mockito.mock; import android.content.Context; -import android.support.test.InstrumentationRegistry; import android.view.ContextThemeWrapper; import android.view.View; import androidx.annotation.Nullable; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import org.junit.Assert;
diff --git a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/DualControlLayoutTest.java b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/DualControlLayoutTest.java index ed13f07..0424b37a 100644 --- a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/DualControlLayoutTest.java +++ b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/DualControlLayoutTest.java
@@ -5,7 +5,6 @@ package org.chromium.components.browser_ui.widget; import android.content.Context; -import android.support.test.InstrumentationRegistry; import android.view.LayoutInflater; import android.view.View; import android.view.View.MeasureSpec; @@ -14,6 +13,7 @@ import android.widget.FrameLayout; import android.widget.Space; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import org.junit.Assert;
diff --git a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/PromoDialogTest.java b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/PromoDialogTest.java index 8bb2594..d7683d6 100644 --- a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/PromoDialogTest.java +++ b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/PromoDialogTest.java
@@ -6,7 +6,6 @@ import android.app.Activity; import android.content.DialogInterface; -import android.support.test.InstrumentationRegistry; import android.text.method.LinkMovementMethod; import android.view.View; import android.view.View.MeasureSpec; @@ -15,6 +14,7 @@ import android.widget.TextView; import androidx.core.view.ViewCompat; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import org.junit.Assert;
diff --git a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RadioButtonLayoutTest.java b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RadioButtonLayoutTest.java index 3a893ce..02b8183 100644 --- a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RadioButtonLayoutTest.java +++ b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RadioButtonLayoutTest.java
@@ -5,11 +5,11 @@ package org.chromium.components.browser_ui.widget; import android.content.Context; -import android.support.test.InstrumentationRegistry; import android.view.View; import android.view.ViewGroup.MarginLayoutParams; import android.widget.RadioButton; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import org.junit.Assert;
diff --git a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RadioButtonWithDescriptionLayoutTest.java b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RadioButtonWithDescriptionLayoutTest.java index 99b8e3d..77b2e44 100644 --- a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RadioButtonWithDescriptionLayoutTest.java +++ b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RadioButtonWithDescriptionLayoutTest.java
@@ -8,7 +8,6 @@ import static org.mockito.Mockito.verify; import android.content.Context; -import android.support.test.InstrumentationRegistry; import android.text.TextUtils; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; @@ -18,6 +17,7 @@ import android.widget.RadioGroup; import android.widget.TextView; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import org.junit.Assert;
diff --git a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RadioButtonWithEditTextTest.java b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RadioButtonWithEditTextTest.java index 785eef4..a5edbf8d 100644 --- a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RadioButtonWithEditTextTest.java +++ b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RadioButtonWithEditTextTest.java
@@ -8,7 +8,6 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import android.app.Activity; -import android.support.test.InstrumentationRegistry; import android.text.InputType; import android.text.TextUtils; import android.view.KeyEvent; @@ -20,6 +19,7 @@ import android.widget.RadioButton; import android.widget.TextView; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import org.hamcrest.Matchers;
diff --git a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RoundedIconGeneratorTest.java b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RoundedIconGeneratorTest.java index 911dc6b2c..965730c 100644 --- a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RoundedIconGeneratorTest.java +++ b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/RoundedIconGeneratorTest.java
@@ -6,8 +6,8 @@ import android.content.Context; import android.graphics.Color; -import android.support.test.InstrumentationRegistry; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import org.junit.Assert;
diff --git a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/WrappingLayoutTest.java b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/WrappingLayoutTest.java index d870d63..7d82102 100644 --- a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/WrappingLayoutTest.java +++ b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/WrappingLayoutTest.java
@@ -5,10 +5,10 @@ package org.chromium.components.browser_ui.widget; import android.content.Context; -import android.support.test.InstrumentationRegistry; import android.view.View; import android.view.View.MeasureSpec; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import org.junit.Assert;
diff --git a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/highlight/ViewHighlighterTest.java b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/highlight/ViewHighlighterTest.java index a138b8a..cdb9e64 100644 --- a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/highlight/ViewHighlighterTest.java +++ b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/highlight/ViewHighlighterTest.java
@@ -10,11 +10,11 @@ import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.ColorDrawable; -import android.support.test.InstrumentationRegistry; import android.view.ContextThemeWrapper; import android.view.View; import android.widget.ImageView; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; import org.junit.Assert;
diff --git a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/listmenu/ListMenuButtonTest.java b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/listmenu/ListMenuButtonTest.java index 893c576..bb818fd 100644 --- a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/listmenu/ListMenuButtonTest.java +++ b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/listmenu/ListMenuButtonTest.java
@@ -5,9 +5,9 @@ package org.chromium.components.browser_ui.widget.listmenu; import android.content.Context; -import android.support.test.InstrumentationRegistry; import android.view.View; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import org.junit.Assert;
diff --git a/components/cronet/android/BUILD.gn b/components/cronet/android/BUILD.gn index 3695335..b1e6ca5 100644 --- a/components/cronet/android/BUILD.gn +++ b/components/cronet/android/BUILD.gn
@@ -847,8 +847,8 @@ ":cronet_sample_apk_java", ":package_impl_common_java", "//third_party/android_deps:espresso_java", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", + "//third_party/androidx:androidx_test_monitor_java", + "//third_party/androidx:androidx_test_rules_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/junit", ]
diff --git a/components/cronet/android/sample/javatests/src/org/chromium/cronet_sample_apk/CronetSampleTest.java b/components/cronet/android/sample/javatests/src/org/chromium/cronet_sample_apk/CronetSampleTest.java index 0357ae1..1684fa431 100644 --- a/components/cronet/android/sample/javatests/src/org/chromium/cronet_sample_apk/CronetSampleTest.java +++ b/components/cronet/android/sample/javatests/src/org/chromium/cronet_sample_apk/CronetSampleTest.java
@@ -15,15 +15,15 @@ import android.content.Intent; import android.net.Uri; import android.os.ConditionVariable; -import android.support.test.InstrumentationRegistry; -import android.support.test.rule.ActivityTestRule; -import android.support.test.runner.AndroidJUnit4; import android.text.Editable; import android.text.TextWatcher; import android.widget.TextView; +import androidx.test.InstrumentationRegistry; import androidx.test.espresso.NoMatchingViewException; import androidx.test.filters.SmallTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; import org.junit.Assert; import org.junit.Rule;
diff --git a/components/dom_distiller/ios/distiller_page_ios.mm b/components/dom_distiller/ios/distiller_page_ios.mm index e630782..c5e7a71 100644 --- a/components/dom_distiller/ios/distiller_page_ios.mm +++ b/components/dom_distiller/ios/distiller_page_ios.mm
@@ -73,17 +73,17 @@ result = base::Value(value->GetBool()); DCHECK_EQ(result.type(), base::Value::Type::BOOLEAN); } else if (value->is_dict()) { - base::Value dictionary(base::Value::Type::DICT); - for (const auto kv : value->DictItems()) { + base::Value::Dict dictionary; + for (const auto kv : value->GetDict()) { base::Value item_value = ConvertedResultFromScriptResult(&kv.second, max_depth - 1); if (item_value.type() == base::Value::Type::NONE) { return result; } - dictionary.SetPath(kv.first, std::move(item_value)); + dictionary.SetByDottedPath(kv.first, std::move(item_value)); } - result = std::move(dictionary); + result = base::Value(std::move(dictionary)); DCHECK_EQ(result.type(), base::Value::Type::DICT); } else if (value->is_list()) {
diff --git a/components/embedder_support/android/BUILD.gn b/components/embedder_support/android/BUILD.gn index 8ced98c..2a91d45 100644 --- a/components/embedder_support/android/BUILD.gn +++ b/components/embedder_support/android/BUILD.gn
@@ -324,10 +324,10 @@ "//base:base_java", "//base:base_java_test_support", "//content/public/test/android:content_java_test_support", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_appcompat_appcompat_java", "//third_party/androidx:androidx_core_core_java", + "//third_party/androidx:androidx_test_monitor_java", + "//third_party/androidx:androidx_test_rules_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/junit", "//ui/android:ui_java",
diff --git a/components/external_intents/android/BUILD.gn b/components/external_intents/android/BUILD.gn index 9959650..69b1810 100644 --- a/components/external_intents/android/BUILD.gn +++ b/components/external_intents/android/BUILD.gn
@@ -83,10 +83,10 @@ "//content/public/android:content_java", "//content/public/test/android:content_java_test_support", "//third_party/android_sdk:android_test_mock_java", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_appcompat_appcompat_java", "//third_party/androidx:androidx_browser_browser_java", "//third_party/androidx:androidx_core_core_java", + "//third_party/androidx:androidx_test_monitor_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/junit", "//third_party/mockito:mockito_java",
diff --git a/components/external_intents/android/javatests/src/org/chromium/components/external_intents/ExternalNavigationHandlerTest.java b/components/external_intents/android/javatests/src/org/chromium/components/external_intents/ExternalNavigationHandlerTest.java index 4983bf77..0d23c8b5 100644 --- a/components/external_intents/android/javatests/src/org/chromium/components/external_intents/ExternalNavigationHandlerTest.java +++ b/components/external_intents/android/javatests/src/org/chromium/components/external_intents/ExternalNavigationHandlerTest.java
@@ -21,10 +21,10 @@ import android.os.Bundle; import android.os.SystemClock; import android.provider.Browser; -import android.support.test.InstrumentationRegistry; import android.test.mock.MockPackageManager; import androidx.appcompat.app.AlertDialog; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; import androidx.test.filters.SmallTest;
diff --git a/components/favicon/core/favicon_database.cc b/components/favicon/core/favicon_database.cc index 27f995e..e495e86 100644 --- a/components/favicon/core/favicon_database.cc +++ b/components/favicon/core/favicon_database.cc
@@ -265,7 +265,7 @@ sql::InitStatus FaviconDatabase::Init(const base::FilePath& db_name) { // TODO(shess): Consider separating database open from schema setup. // With that change, this code could Raze() from outside the - // transaction, rather than needing RazeAndClose() in InitImpl(). + // transaction, rather than needing RazeAndPoison() in InitImpl(). // Retry failed setup in case the recovery system fixed things. const size_t kAttempts = 2; @@ -1144,14 +1144,14 @@ if (!db_.DoesColumnExist("favicons", "icon_type")) { LOG(ERROR) << "Raze because of missing favicon.icon_type"; - db_.RazeAndClose(); + db_.RazeAndPoison(); return sql::INIT_FAILURE; } if (cur_version < 7 && !db_.DoesColumnExist("favicons", "sizes")) { LOG(ERROR) << "Raze because of missing favicon.sizes"; - db_.RazeAndClose(); + db_.RazeAndPoison(); return sql::INIT_FAILURE; } @@ -1183,7 +1183,7 @@ if (IsFaviconDBStructureIncorrect()) { LOG(ERROR) << "Raze because of invalid favicon db structure."; - db_.RazeAndClose(); + db_.RazeAndPoison(); return sql::INIT_FAILURE; }
diff --git a/components/gwp_asan/client/guarded_page_allocator.cc b/components/gwp_asan/client/guarded_page_allocator.cc index d0c35bd1b..d19e61f4 100644 --- a/components/gwp_asan/client/guarded_page_allocator.cc +++ b/components/gwp_asan/client/guarded_page_allocator.cc
@@ -185,7 +185,8 @@ CHECK_LE(num_metadata, AllocatorState::kMaxMetadata); CHECK_LE(num_metadata, total_pages); CHECK_LE(total_pages, AllocatorState::kMaxRequestedSlots); - CHECK_LE(num_lightweight_detector_metadata, AllocatorState::kMaxMetadata); + CHECK_LE(num_lightweight_detector_metadata, + AllocatorState::kMaxLightweightMetadata); max_alloced_pages_ = max_alloced_pages; state_.num_metadata = num_metadata; state_.total_requested_pages = total_pages;
diff --git a/components/gwp_asan/client/gwp_asan.cc b/components/gwp_asan/client/gwp_asan.cc index 1f108c2..170a4b6 100644 --- a/components/gwp_asan/client/gwp_asan.cc +++ b/components/gwp_asan/client/gwp_asan.cc
@@ -155,6 +155,12 @@ "kMaxMetadata out of range"); constexpr int kMaxMetadata = static_cast<int>(AllocatorState::kMaxMetadata); + static_assert(AllocatorState::kMaxLightweightMetadata <= + std::numeric_limits<int>::max(), + "kMaxMetadata out of range"); + constexpr int kMaxLightweightMetadata = + static_cast<int>(AllocatorState::kMaxLightweightMetadata); + int total_pages = GetFieldTrialParamByFeatureAsInt(feature, "TotalPages", kDefaultTotalPages); if (total_pages < 1 || total_pages > kMaxRequestedSlots) { @@ -198,7 +204,7 @@ max_lightweight_metadata = GetFieldTrialParamByFeatureAsInt( feature, "MaxLightweightMetadata", kDefaultMaxLightweightMetadata); if (max_lightweight_metadata < 1 || - max_lightweight_metadata > kMaxMetadata) { + max_lightweight_metadata > kMaxLightweightMetadata) { DLOG(ERROR) << "GWP-ASan MaxLightweightMetadata is out-of-range: " << max_lightweight_metadata; return absl::nullopt;
diff --git a/components/gwp_asan/common/allocator_state.cc b/components/gwp_asan/common/allocator_state.cc index 850bb7b..209a74b0 100644 --- a/components/gwp_asan/common/allocator_state.cc +++ b/components/gwp_asan/common/allocator_state.cc
@@ -85,7 +85,7 @@ if (!metadata_addr || !slot_to_metadata_addr) return false; - if (num_lightweight_detector_metadata > kMaxMetadata) { + if (num_lightweight_detector_metadata > kMaxLightweightMetadata) { return false; }
diff --git a/components/gwp_asan/common/allocator_state.h b/components/gwp_asan/common/allocator_state.h index 2833b79a..52f9d7d 100644 --- a/components/gwp_asan/common/allocator_state.h +++ b/components/gwp_asan/common/allocator_state.h
@@ -56,6 +56,8 @@ static constexpr size_t kMaxMetadata = 2048; // Invalid metadata index. static constexpr MetadataIdx kInvalidMetadataIdx = kMaxMetadata; + // Maximum number of metadata slots used by the Lightweight UAF Detector. + static constexpr size_t kMaxLightweightMetadata = 32768; // Maximum number of stack trace frames to collect for an allocation or // deallocation.
diff --git a/components/gwp_asan/common/allocator_state_unittest.cc b/components/gwp_asan/common/allocator_state_unittest.cc index 1598c7e..3b3c8c8a 100644 --- a/components/gwp_asan/common/allocator_state_unittest.cc +++ b/components/gwp_asan/common/allocator_state_unittest.cc
@@ -18,6 +18,8 @@ static constexpr size_t kMaxMetadata = AllocatorState::kMaxMetadata; static constexpr size_t kMaxRequestedSlots = AllocatorState::kMaxRequestedSlots; static constexpr size_t kMaxReservedSlots = AllocatorState::kMaxReservedSlots; +static constexpr size_t kMaxLightweightMetadata = + AllocatorState::kMaxLightweightMetadata; class AllocatorStateTest : public testing::Test { protected: @@ -230,10 +232,12 @@ InitializeState(base::GetPageSize(), 1, 1, 1, 0, 0, 0, 1); EXPECT_TRUE(state_.IsValid()); - InitializeState(base::GetPageSize(), 1, 1, 1, 0, 0, 0, kMaxMetadata); + InitializeState(base::GetPageSize(), 1, 1, 1, 0, 0, 0, + kMaxLightweightMetadata); EXPECT_TRUE(state_.IsValid()); - InitializeState(base::GetPageSize(), 1, 1, 1, 0, 0, 0, kMaxMetadata + 1); + InitializeState(base::GetPageSize(), 1, 1, 1, 0, 0, 0, + kMaxLightweightMetadata + 1); EXPECT_FALSE(state_.IsValid()); }
diff --git a/components/image_fetcher/BUILD.gn b/components/image_fetcher/BUILD.gn index ae9a8ee..4eb743a 100644 --- a/components/image_fetcher/BUILD.gn +++ b/components/image_fetcher/BUILD.gn
@@ -66,7 +66,7 @@ "//base:jni_java", "//components/browser_ui/util/android:java", "//components/embedder_support/android:simple_factory_key_java", - "//third_party/android_support_test_runner:runner_java", + "//third_party/androidx:androidx_test_monitor_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/gif_player:gif_player_java", "//third_party/junit",
diff --git a/components/infobars/android/BUILD.gn b/components/infobars/android/BUILD.gn index 64bc14d..b9c71f4 100644 --- a/components/infobars/android/BUILD.gn +++ b/components/infobars/android/BUILD.gn
@@ -112,9 +112,9 @@ "//base:base_java_test_support", "//components/browser_ui/theme/android:java_resources", "//components/browser_ui/widget/android:java", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_appcompat_appcompat_java", + "//third_party/androidx:androidx_test_monitor_java", + "//third_party/androidx:androidx_test_rules_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/junit:junit", ]
diff --git a/components/infobars/android/java/src/org/chromium/components/infobars/InfoBarControlLayoutTest.java b/components/infobars/android/java/src/org/chromium/components/infobars/InfoBarControlLayoutTest.java index c3310e7a..cee89ae 100644 --- a/components/infobars/android/java/src/org/chromium/components/infobars/InfoBarControlLayoutTest.java +++ b/components/infobars/android/java/src/org/chromium/components/infobars/InfoBarControlLayoutTest.java
@@ -5,11 +5,11 @@ package org.chromium.components.infobars; import android.content.Context; -import android.support.test.InstrumentationRegistry; import android.view.View; import android.view.View.MeasureSpec; import android.view.ViewGroup.LayoutParams; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import org.junit.Assert;
diff --git a/components/keyed_service/README b/components/keyed_service/README deleted file mode 100644 index d12f06af..0000000 --- a/components/keyed_service/README +++ /dev/null
@@ -1,9 +0,0 @@ -KeyedService is a layered component -(https://sites.google.com/a/chromium.org/dev/developers/design-documents/layered-components-design) -to enable it to be shared cleanly on iOS. - -This component has the following structure: - -- core/: shared code that does not depend on src/content/ or src/ios/ -- content/: Code based on the content layer. -- ios/: Code based on src/ios.
diff --git a/components/keyed_service/README.md b/components/keyed_service/README.md new file mode 100644 index 0000000..76d70c1 --- /dev/null +++ b/components/keyed_service/README.md
@@ -0,0 +1,14 @@ +KeyedService and KeyedServiceFactory together support building a dependency tree +of services that are all keyed off the same object (typically, +content::BrowserContext or web::BrowserState), and whose teardown order is +managed according to the expressed dependency order. + +KeyedService is a layered component +(https://sites.google.com/a/chromium.org/dev/developers/design-documents/layered-components-design) +to enable it to be shared cleanly on iOS. + +This component has the following structure: + +- core/: shared code that does not depend on src/content/ or src/ios/ +- content/: Code based on the content layer. +- ios/: Code based on src/ios.
diff --git a/components/language/android/BUILD.gn b/components/language/android/BUILD.gn index 12974fd..5bd96cf 100644 --- a/components/language/android/BUILD.gn +++ b/components/language/android/BUILD.gn
@@ -96,7 +96,7 @@ "//chrome/browser/flags:java", "//chrome/test/android:chrome_java_integration_test_support", "//content/public/test/android:content_java_test_support", - "//third_party/android_support_test_runner:rules_java", + "//third_party/androidx:androidx_test_rules_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/junit", ]
diff --git a/components/minidump_uploader/BUILD.gn b/components/minidump_uploader/BUILD.gn index 837a017c..f3d1383 100644 --- a/components/minidump_uploader/BUILD.gn +++ b/components/minidump_uploader/BUILD.gn
@@ -83,7 +83,7 @@ "//base:base_java", "//base:base_java_test_support", "//base:base_junit_test_support", - "//third_party/android_support_test_runner:runner_java", + "//third_party/androidx:androidx_test_monitor_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/junit", ]
diff --git a/components/paint_preview/player/android/BUILD.gn b/components/paint_preview/player/android/BUILD.gn index 3f7ab49a..52521e25 100644 --- a/components/paint_preview/player/android/BUILD.gn +++ b/components/paint_preview/player/android/BUILD.gn
@@ -126,8 +126,9 @@ "//components/signin/public/android:signin_java_test_support", "//content/public/android:content_java", "//content/public/test/android:content_java_test_support", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", + "//third_party/androidx:androidx_test_monitor_java", + "//third_party/androidx:androidx_test_rules_java", + "//third_party/androidx:androidx_test_runner_java", "//third_party/junit", "//url:gurl_java", ] @@ -144,8 +145,8 @@ "//base:base_java_test_support", "//content/public/android:content_java", "//content/public/test/android:content_java_test_support", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", + "//third_party/androidx:androidx_test_monitor_java", + "//third_party/androidx:androidx_test_rules_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/androidx:androidx_test_uiautomator_uiautomator_java", "//third_party/hamcrest:hamcrest_java",
diff --git a/components/paint_preview/player/android/javatests/src/org/chromium/components/paintpreview/player/PaintPreviewPlayerTest.java b/components/paint_preview/player/android/javatests/src/org/chromium/components/paintpreview/player/PaintPreviewPlayerTest.java index 5472805..d27e228 100644 --- a/components/paint_preview/player/android/javatests/src/org/chromium/components/paintpreview/player/PaintPreviewPlayerTest.java +++ b/components/paint_preview/player/android/javatests/src/org/chromium/components/paintpreview/player/PaintPreviewPlayerTest.java
@@ -7,12 +7,12 @@ import android.graphics.Rect; import android.os.Build; import android.os.Build.VERSION_CODES; -import android.support.test.InstrumentationRegistry; import android.util.Size; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiDevice;
diff --git a/components/password_manager/core/browser/mock_password_manager_settings_service.h b/components/password_manager/core/browser/mock_password_manager_settings_service.h index d6a9b4b..15909fd 100644 --- a/components/password_manager/core/browser/mock_password_manager_settings_service.h +++ b/components/password_manager/core/browser/mock_password_manager_settings_service.h
@@ -18,7 +18,7 @@ MOCK_METHOD(bool, IsSettingEnabled, (password_manager::PasswordManagerSetting), - (override)); + (const override)); MOCK_METHOD(void, RequestSettingsFromBackend, (), (override)); MOCK_METHOD(void, TurnOffAutoSignIn, (), (override));
diff --git a/components/password_manager/core/browser/password_manager_settings_service.h b/components/password_manager/core/browser/password_manager_settings_service.h index 0a83c266..a9995cc4 100644 --- a/components/password_manager/core/browser/password_manager_settings_service.h +++ b/components/password_manager/core/browser/password_manager_settings_service.h
@@ -13,7 +13,7 @@ // Checks if `setting` is enabled. It ensures that the correct pref is checked // on Android, which depends on the unified password manager status. virtual bool IsSettingEnabled( - password_manager::PasswordManagerSetting setting) = 0; + password_manager::PasswordManagerSetting setting) const = 0; // Asynchronously fetch password settings from backend. virtual void RequestSettingsFromBackend() = 0;
diff --git a/components/payments/content/android/BUILD.gn b/components/payments/content/android/BUILD.gn index fdeb5e0..2f01096 100644 --- a/components/payments/content/android/BUILD.gn +++ b/components/payments/content/android/BUILD.gn
@@ -390,7 +390,7 @@ "//components/payments/mojom:mojom_java", "//content/public/test/android:content_java_test_support", "//third_party/android_sdk:android_test_base_java", - "//third_party/android_support_test_runner:runner_java", + "//third_party/androidx:androidx_test_monitor_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/blink/public/mojom:android_mojo_bindings_java", "//third_party/junit",
diff --git a/components/payments/content/android/java/src/org/chromium/components/payments/PaymentFeatureList.java b/components/payments/content/android/java/src/org/chromium/components/payments/PaymentFeatureList.java index 0e1e71b8..e1028c2 100644 --- a/components/payments/content/android/java/src/org/chromium/components/payments/PaymentFeatureList.java +++ b/components/payments/content/android/java/src/org/chromium/components/payments/PaymentFeatureList.java
@@ -33,7 +33,6 @@ public static final String WEB_PAYMENTS_APP_STORE_BILLING_DEBUG = "AppStoreBillingDebug"; public static final String WEB_PAYMENTS_EXPERIMENTAL_FEATURES = "WebPaymentsExperimentalFeatures"; - public static final String WEB_PAYMENTS_MODIFIERS = "WebPaymentsModifiers"; public static final String WEB_PAYMENTS_SINGLE_APP_UI_SKIP = "WebPaymentsSingleAppUiSkip"; // Do not instantiate this class.
diff --git a/components/payments/content/android/payment_feature_list.cc b/components/payments/content/android/payment_feature_list.cc index 6f6f80665..baa58f9fd 100644 --- a/components/payments/content/android/payment_feature_list.cc +++ b/components/payments/content/android/payment_feature_list.cc
@@ -34,7 +34,6 @@ &features::kEnforceFullDelegation, &features::kGPayAppDynamicUpdate, &features::kWebPaymentsExperimentalFeatures, - &features::kWebPaymentsModifiers, &features::kWebPaymentsSingleAppUiSkip, &kAndroidAppPaymentUpdateEvents, &kOmitParametersInReadyToPay,
diff --git a/components/payments/content/payment_request_spec.cc b/components/payments/content/payment_request_spec.cc index 974b14e..c9a593da 100644 --- a/components/payments/content/payment_request_spec.cc +++ b/components/payments/content/payment_request_spec.cc
@@ -352,9 +352,9 @@ const mojom::PaymentDetailsModifierPtr* PaymentRequestSpec::GetApplicableModifier(PaymentApp* selected_app) const { - if (!selected_app || - !base::FeatureList::IsEnabled(features::kWebPaymentsModifiers)) + if (!selected_app) { return nullptr; + } DCHECK(details_->modifiers); for (const auto& modifier : *details_->modifiers) {
diff --git a/components/payments/core/features.cc b/components/payments/core/features.cc index bde93cda..ebc1b74 100644 --- a/components/payments/core/features.cc +++ b/components/payments/core/features.cc
@@ -15,11 +15,6 @@ base::FEATURE_DISABLED_BY_DEFAULT); // TODO(rouslan): Remove this. -BASE_FEATURE(kWebPaymentsModifiers, - "WebPaymentsModifiers", - base::FEATURE_ENABLED_BY_DEFAULT); - -// TODO(rouslan): Remove this. BASE_FEATURE(kWebPaymentsSingleAppUiSkip, "WebPaymentsSingleAppUiSkip", base::FEATURE_ENABLED_BY_DEFAULT);
diff --git a/components/payments/core/features.h b/components/payments/core/features.h index 0a8b652..860db56 100644 --- a/components/payments/core/features.h +++ b/components/payments/core/features.h
@@ -14,9 +14,6 @@ // release. BASE_DECLARE_FEATURE(kWebPaymentsExperimentalFeatures); -// Used to control the support for Payment Details modifiers. -BASE_DECLARE_FEATURE(kWebPaymentsModifiers); - // Used to control whether the Payment Sheet can be skipped for Payment Requests // with a single URL based payment app and no other info requested. BASE_DECLARE_FEATURE(kWebPaymentsSingleAppUiSkip);
diff --git a/components/policy/core/common/policy_pref_names.h b/components/policy/core/common/policy_pref_names.h index 47c3ed2..3482934 100644 --- a/components/policy/core/common/policy_pref_names.h +++ b/components/policy/core/common/policy_pref_names.h
@@ -9,6 +9,23 @@ #include "components/policy/policy_export.h" namespace policy { + +// Possible values for Incognito mode availability. Please, do not change +// the order of entries since numeric values are exposed to users. +enum class IncognitoModeAvailability { + // Incognito mode enabled. Users may open pages in both Incognito mode and + // normal mode (usually the default behaviour). + kEnabled = 0, + // Incognito mode disabled. Users may not open pages in Incognito mode. + // Only normal mode is available for browsing. + kDisabled, + // Incognito mode forced. Users may open pages *ONLY* in Incognito mode. + // Normal mode is not available for browsing. + kForced, + + kNumTypes +}; + namespace policy_prefs { #if BUILDFLAG(IS_WIN)
diff --git a/components/services/app_service/public/cpp/app_launch_util.h b/components/services/app_service/public/cpp/app_launch_util.h index e37d4f1..71c42fd 100644 --- a/components/services/app_service/public/cpp/app_launch_util.h +++ b/components/services/app_service/public/cpp/app_launch_util.h
@@ -12,12 +12,17 @@ namespace apps { -// Enumeration of possible app launch sources. -// This should be kept in sync with metadata/apps/histograms.xml, -// LaunchSource in enums.xml, as well as ApplicationLaunchSource in -// //components/services/app_service/public/protos/app_types.proto. Note the -// enumeration is used in UMA histogram so entries should not be re-ordered or -// removed. New entries should be added at the bottom. +// Enumeration of possible app launch sources. When adding a new entry to this +// enum: +// - Update DefaultAppLaunchSource in metadata/apps/histograms.xml +// - Update LaunchSource in enums.xml +// - Update ApplicationLaunchSource in +// //components/services/app_service/public/protos/app_types.proto. +// - Email chromeos-data-team@google.com to request a corresponding change to +// backend enums. +// +// These values are persisted to logs. Entries should not be renumbered and +// numeric values should never be reused. enum class LaunchSource { kUnknown = 0, kFromAppListGrid = 1, // Grid of apps, not the search box.
diff --git a/components/session_manager/core/session_manager.cc b/components/session_manager/core/session_manager.cc index b1bcc54..333ea62d 100644 --- a/components/session_manager/core/session_manager.cc +++ b/components/session_manager/core/session_manager.cc
@@ -103,11 +103,6 @@ observer.OnUserProfileLoaded(account_id); } -void SessionManager::NotifyNetworkErrorScreenShown() { - for (auto& observer : observers_) - observer.OnNetworkErrorScreenShown(); -} - void SessionManager::NotifyLoginOrLockScreenVisible() { login_or_lock_screen_shown_for_test_ = true; for (auto& observer : observers_)
diff --git a/components/session_manager/core/session_manager_observer.h b/components/session_manager/core/session_manager_observer.h index f6c60d4..aa22051 100644 --- a/components/session_manager/core/session_manager_observer.h +++ b/components/session_manager/core/session_manager_observer.h
@@ -28,21 +28,15 @@ // after the user has logged in. virtual void OnUserSessionStarted(bool is_primary_user) {} - // Invoked when a network error message is displayed on the WebUI login - // screen. - virtual void OnNetworkErrorScreenShown() {} - // Invoked when the specific part of login/lock WebUI is considered to be - // visible. That moment is tracked as the first paint event after - // `OnNetworkErrorScreenShown()`. + // visible. // // Possible series of notifications: // 1. Boot into fresh OOBE. `OnLoginOrLockScreenVisible()`. // 2. Boot into user pods list (normal boot). Same for lock screen. // `OnLoginOrLockScreenVisible()`. // 3. Boot into GAIA sign in UI (user pods display disabled or no users): - // if no network is connected or flaky network - // (`OnLoginOrLockScreenVisible()` + `OnNetworkErrorScreenShown()`). + // `OnLoginOrLockScreenVisible()`. // 4. Boot into retail mode. `OnLoginOrLockScreenVisible()`. virtual void OnLoginOrLockScreenVisible() {}
diff --git a/components/signin/public/android/BUILD.gn b/components/signin/public/android/BUILD.gn index 8ee9fef..3441cf0d 100644 --- a/components/signin/public/android/BUILD.gn +++ b/components/signin/public/android/BUILD.gn
@@ -149,8 +149,8 @@ "//base:base_java", "//base:base_java_test_support", "//content/public/test/android:content_java_test_support", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", + "//third_party/androidx:androidx_test_monitor_java", + "//third_party/androidx:androidx_test_rules_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/junit", "//third_party/mockito:mockito_java",
diff --git a/components/signin/public/android/java/src/org/chromium/components/signin/AccountManagerFacadeTest.java b/components/signin/public/android/java/src/org/chromium/components/signin/AccountManagerFacadeTest.java index d806e3a..ab6d6fe 100644 --- a/components/signin/public/android/java/src/org/chromium/components/signin/AccountManagerFacadeTest.java +++ b/components/signin/public/android/java/src/org/chromium/components/signin/AccountManagerFacadeTest.java
@@ -9,8 +9,8 @@ import static org.junit.Assert.assertTrue; import android.accounts.Account; -import android.support.test.InstrumentationRegistry; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import org.junit.After;
diff --git a/components/site_isolation/features.cc b/components/site_isolation/features.cc index c40b09df..b45a6e9 100644 --- a/components/site_isolation/features.cc +++ b/components/site_isolation/features.cc
@@ -9,10 +9,6 @@ namespace site_isolation { namespace features { -BASE_FEATURE(kCacheSiteIsolationMemoryThreshold, - "CacheSiteIsolationMemoryThreshold", - base::FEATURE_ENABLED_BY_DEFAULT); - // Controls a mode for dynamically process-isolating sites where the user has // entered a password. This is intended to be used primarily when full site // isolation is turned off. To check whether this mode is enabled, use
diff --git a/components/site_isolation/features.h b/components/site_isolation/features.h index 07a3a64..b406c936 100644 --- a/components/site_isolation/features.h +++ b/components/site_isolation/features.h
@@ -10,7 +10,6 @@ namespace site_isolation { namespace features { -BASE_DECLARE_FEATURE(kCacheSiteIsolationMemoryThreshold); BASE_DECLARE_FEATURE(kSiteIsolationForPasswordSites); BASE_DECLARE_FEATURE(kSiteIsolationForOAuthSites); BASE_DECLARE_FEATURE(kSiteIsolationMemoryThresholds);
diff --git a/components/site_isolation/site_isolation_policy.cc b/components/site_isolation/site_isolation_policy.cc index b65e325..8c4b5be 100644 --- a/components/site_isolation/site_isolation_policy.cc +++ b/components/site_isolation/site_isolation_policy.cc
@@ -29,12 +29,7 @@ using IsolatedOriginSource = content::ChildProcessSecurityPolicy::IsolatedOriginSource; -bool g_disallow_memory_threshold_caching = false; - -bool ShouldCacheMemoryThresholdDecision() { - return base::FeatureList::IsEnabled( - features::kCacheSiteIsolationMemoryThreshold); -} +bool g_disallow_memory_threshold_caching_for_testing = false; struct IsolationDisableDecisions { bool should_disable_strict; @@ -184,9 +179,7 @@ // static bool SiteIsolationPolicy::ShouldDisableSiteIsolationDueToMemoryThreshold( content::SiteIsolationMode site_isolation_mode) { - static const bool cache_memory_threshold_decision = - ShouldCacheMemoryThresholdDecision(); - if (!g_disallow_memory_threshold_caching && cache_memory_threshold_decision) { + if (!g_disallow_memory_threshold_caching_for_testing) { return CachedDisableSiteIsolation(site_isolation_mode); } return ShouldDisableSiteIsolationDueToMemorySlow(site_isolation_mode); @@ -398,7 +391,7 @@ // static void SiteIsolationPolicy::SetDisallowMemoryThresholdCachingForTesting( bool disallow_caching) { - g_disallow_memory_threshold_caching = disallow_caching; + g_disallow_memory_threshold_caching_for_testing = disallow_caching; } } // namespace site_isolation
diff --git a/components/site_isolation/site_isolation_policy.h b/components/site_isolation/site_isolation_policy.h index f0bcc9d..45f56e9 100644 --- a/components/site_isolation/site_isolation_policy.h +++ b/components/site_isolation/site_isolation_policy.h
@@ -90,8 +90,8 @@ static bool ShouldPdfCompositorBeEnabledForOopifs(); // When set to true bypasses the caching of the results of - // ShouldDisableSiteIsolationDueToMemoryThreshold(). Setting to false reverts - // to the default behavior (caching is controlled by a base::Feature). + // ShouldDisableSiteIsolationDueToMemoryThreshold(). Setting to false allows + // caching. static void SetDisallowMemoryThresholdCachingForTesting( bool disallow_caching);
diff --git a/components/strictmode/android/BUILD.gn b/components/strictmode/android/BUILD.gn index be1aa707..04e60f2 100644 --- a/components/strictmode/android/BUILD.gn +++ b/components/strictmode/android/BUILD.gn
@@ -25,9 +25,9 @@ ":java", "//base:base_java_test_support", "//content/public/test/android:content_java_test_support", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_appcompat_appcompat_java", "//third_party/androidx:androidx_core_core_java", + "//third_party/androidx:androidx_test_monitor_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/junit", ]
diff --git a/components/strictmode/android/javatests/src/org/chromium/components/strictmode/ThreadStrictModeInterceptorTest.java b/components/strictmode/android/javatests/src/org/chromium/components/strictmode/ThreadStrictModeInterceptorTest.java index 4ef2d18..eff0492 100644 --- a/components/strictmode/android/javatests/src/org/chromium/components/strictmode/ThreadStrictModeInterceptorTest.java +++ b/components/strictmode/android/javatests/src/org/chromium/components/strictmode/ThreadStrictModeInterceptorTest.java
@@ -9,9 +9,9 @@ import android.os.StrictMode; import android.os.StrictMode.ThreadPolicy; -import android.support.test.InstrumentationRegistry; import androidx.core.content.ContextCompat; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import org.junit.Test;
diff --git a/components/supervised_user/core/browser/supervised_user_settings_service.cc b/components/supervised_user/core/browser/supervised_user_settings_service.cc index 0da369b53..a255fa5 100644 --- a/components/supervised_user/core/browser/supervised_user_settings_service.cc +++ b/components/supervised_user/core/browser/supervised_user_settings_service.cc
@@ -138,7 +138,7 @@ // Write the sync setting. std::string setting_key = MakeSplitSettingKey( supervised_user::kContentPackManualBehaviorHosts, host); - SaveItem(setting_key, std::make_unique<base::Value>(true)); + SaveItem(setting_key, base::Value(true)); // Now notify subscribers of the updates. website_approval_callback_list_.Notify(setting_key); @@ -198,7 +198,7 @@ void SupervisedUserSettingsService::SaveItem( const std::string& key, - std::unique_ptr<base::Value> value) { + base::Value value) { // Update the value in our local dict, and push the changes to sync. std::string key_suffix = key; base::Value::Dict* dict = nullptr; @@ -207,7 +207,7 @@ dict = GetDictionaryAndSplitKey(&key_suffix); DCHECK(GetQueuedItems()->empty()); SyncChangeList change_list; - SyncData data = CreateSyncDataForSetting(key, *value); + SyncData data = CreateSyncDataForSetting(key, value); SyncChange::SyncChangeType change_type = dict->Find(key_suffix) ? SyncChange::ACTION_UPDATE : SyncChange::ACTION_ADD; @@ -221,7 +221,7 @@ base::RecordAction(UserMetricsAction("ManagedUsers_UploadItem_Queued")); dict = GetQueuedItems(); } - dict->Set(key_suffix, base::Value::FromUniquePtrValue(std::move(value))); + dict->Set(key_suffix,std::move(value)); // Now notify subscribers of the updates. // For simplicity and consistency with ProcessSyncChanges() we notify both
diff --git a/components/supervised_user/core/browser/supervised_user_settings_service.h b/components/supervised_user/core/browser/supervised_user_settings_service.h index 3f4b2ca..2e67b3a 100644 --- a/components/supervised_user/core/browser/supervised_user_settings_service.h +++ b/components/supervised_user/core/browser/supervised_user_settings_service.h
@@ -145,7 +145,7 @@ // This may be called regardless of whether the sync server has completed // initialization; in either case the local changes will be handled // immediately. - void SaveItem(const std::string& key, std::unique_ptr<base::Value> value); + void SaveItem(const std::string& key, base::Value value); // Sets the setting with the given `key` to `value`. void SetLocalSetting(base::StringPiece key, base::Value value);
diff --git a/components/supervised_user/core/browser/supervised_user_settings_service_unittest.cc b/components/supervised_user/core/browser/supervised_user_settings_service_unittest.cc index a427e85..0e408cd 100644 --- a/components/supervised_user/core/browser/supervised_user_settings_service_unittest.cc +++ b/components/supervised_user/core/browser/supervised_user_settings_service_unittest.cc
@@ -53,13 +53,13 @@ split_items_.Set(key, value); settings_service_.SaveItem( SupervisedUserSettingsService::MakeSplitSettingKey(kSplitItemName, key), - std::make_unique<base::Value>(value)); + base::Value(value)); } void UploadAtomicItem(const std::string& value) { - atomic_setting_value_ = std::make_unique<base::Value>(value); + atomic_setting_value_ = base::Value(value); settings_service_.SaveItem(kAtomicItemName, - std::make_unique<base::Value>(value)); + base::Value(value)); } void VerifySyncDataItem(syncer::SyncData sync_data) { @@ -67,7 +67,7 @@ sync_data.GetSpecifics().managed_user_setting(); base::Value* expected_value = nullptr; if (supervised_user_setting.name() == kAtomicItemName) { - expected_value = atomic_setting_value_.get(); + expected_value = &atomic_setting_value_.value(); } else { EXPECT_TRUE(base::StartsWith(supervised_user_setting.name(), std::string(kSplitItemName) + ':', @@ -77,7 +77,7 @@ expected_value = split_items_.Find(key); EXPECT_TRUE(expected_value); } - + ASSERT_TRUE(expected_value); EXPECT_EQ(*expected_value, base::JSONReader::Read(supervised_user_setting.value())); } @@ -141,7 +141,7 @@ base::test::TaskEnvironment task_environment_; base::Value::Dict split_items_; - std::unique_ptr<base::Value> atomic_setting_value_; + absl::optional<base::Value> atomic_setting_value_; SupervisedUserSettingsService settings_service_; absl::optional<base::Value::Dict> settings_; base::CallbackListSubscription user_settings_subscription_;
diff --git a/components/sync/base/features.cc b/components/sync/base/features.cc index 481ac91..aabcd26 100644 --- a/components/sync/base/features.cc +++ b/components/sync/base/features.cc
@@ -22,7 +22,12 @@ BASE_FEATURE(kPasswordNotesWithBackup, "PasswordNotesWithBackup", - base::FEATURE_DISABLED_BY_DEFAULT); +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) + base::FEATURE_DISABLED_BY_DEFAULT +#else + base::FEATURE_ENABLED_BY_DEFAULT +#endif +); #if BUILDFLAG(IS_ANDROID) BASE_FEATURE(kSyncAndroidLimitNTPPromoImpressions,
diff --git a/components/translate/content/android/BUILD.gn b/components/translate/content/android/BUILD.gn index 423d8ef..81306638 100644 --- a/components/translate/content/android/BUILD.gn +++ b/components/translate/content/android/BUILD.gn
@@ -108,9 +108,9 @@ "//components/browser_ui/widget/android:java", "//components/messages/android:java", "//content/public/android:content_java", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_appcompat_appcompat_java", + "//third_party/androidx:androidx_test_monitor_java", + "//third_party/androidx:androidx_test_rules_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/junit:junit", "//third_party/mockito:mockito_java",
diff --git a/components/url_formatter/android/BUILD.gn b/components/url_formatter/android/BUILD.gn index f1174a7f..ce299dd 100644 --- a/components/url_formatter/android/BUILD.gn +++ b/components/url_formatter/android/BUILD.gn
@@ -34,8 +34,8 @@ "//base:base_java", "//base:base_java_test_support", "//content/public/test/android:content_java_test_support", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_core_core_java", + "//third_party/androidx:androidx_test_monitor_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/junit", "//url:android_test_helper_java",
diff --git a/components/viz/client/client_resource_provider_unittest.cc b/components/viz/client/client_resource_provider_unittest.cc index 79c75a1..64f2015 100644 --- a/components/viz/client/client_resource_provider_unittest.cc +++ b/components/viz/client/client_resource_provider_unittest.cc
@@ -516,9 +516,9 @@ gpu::SyncToken sync_token = sii->GenUnverifiedSyncToken(); constexpr gfx::Size size(64, 64); - auto tran = TransferableResource::MakeGpu(mailbox, GL_LINEAR, GL_TEXTURE_2D, - sync_token, size, RGBA_8888, - false /* is_overlay_candidate */); + auto tran = TransferableResource::MakeGpu( + mailbox, GL_LINEAR, GL_TEXTURE_2D, sync_token, size, + SinglePlaneFormat::kRGBA_8888, false /* is_overlay_candidate */); ResourceId resource = provider().ImportResource( tran, base::BindOnce(&MockReleaseCallback::Released, base::Unretained(&release)));
diff --git a/components/viz/common/resources/transferable_resource.h b/components/viz/common/resources/transferable_resource.h index de70043..2bbd0d9 100644 --- a/components/viz/common/resources/transferable_resource.h +++ b/components/viz/common/resources/transferable_resource.h
@@ -55,11 +55,6 @@ const std::vector<TransferableResource>& input); bool is_null() const { return mailbox_holder.mailbox.IsZero(); } - static TransferableResource MakeSoftware(const SharedBitmapId& id, - const gfx::Size& size, - ResourceFormat format) { - return MakeSoftware(id, size, SharedImageFormat::SinglePlane(format)); - } static TransferableResource MakeGpu(const gpu::Mailbox& mailbox, uint32_t filter, uint32_t texture_target,
diff --git a/components/viz/service/compositor_frame_fuzzer/compositor_frame_fuzzer_util.cc b/components/viz/service/compositor_frame_fuzzer/compositor_frame_fuzzer_util.cc index aa706eb17..042b6c4 100644 --- a/components/viz/service/compositor_frame_fuzzer/compositor_frame_fuzzer_util.cc +++ b/components/viz/service/compositor_frame_fuzzer/compositor_frame_fuzzer_util.cc
@@ -272,7 +272,7 @@ tile_size, GetColorFromProtobuf(quad_spec.tile_quad().texture_color())); TransferableResource transferable_resource = TransferableResource::MakeSoftware(fuzzed_bitmap->id, fuzzed_bitmap->size, - RGBA_8888); + SinglePlaneFormat::kRGBA_8888); auto* shared_quad_state = pass->CreateAndAppendSharedQuadState(); ConfigureSharedQuadState(shared_quad_state, quad_spec);
diff --git a/components/viz/service/display/display_resource_provider_skia_unittest.cc b/components/viz/service/display/display_resource_provider_skia_unittest.cc index 62dd5f43e..31b9e8e 100644 --- a/components/viz/service/display/display_resource_provider_skia_unittest.cc +++ b/components/viz/service/display/display_resource_provider_skia_unittest.cc
@@ -101,15 +101,15 @@ return base::BindRepeating(&CollectResources, array); } - TransferableResource CreateResource(ResourceFormat format) { + TransferableResource CreateResource() { constexpr gfx::Size size(64, 64); gpu::Mailbox gpu_mailbox = gpu::Mailbox::GenerateForSharedImage(); gpu::SyncToken sync_token = GenSyncToken(); EXPECT_TRUE(sync_token.HasData()); TransferableResource gl_resource = TransferableResource::MakeGpu( - gpu_mailbox, GL_LINEAR, GL_TEXTURE_2D, sync_token, size, format, - false /* is_overlay_candidate */); + gpu_mailbox, GL_LINEAR, GL_TEXTURE_2D, sync_token, size, + SinglePlaneFormat::kRGBA_8888, false /* is_overlay_candidate */); return gl_resource; } @@ -362,13 +362,13 @@ for (auto sync_type : kSynchronizationTypes) { MockReleaseCallback release; - TransferableResource tran1 = CreateResource(RGBA_8888); + TransferableResource tran1 = CreateResource(); tran1.synchronization_type = sync_type; ResourceId id1 = child_resource_provider_->ImportResource( tran1, base::BindOnce(&MockReleaseCallback::Released, base::Unretained(&release))); - TransferableResource tran2 = CreateResource(RGBA_8888); + TransferableResource tran2 = CreateResource(); ASSERT_EQ(tran2.synchronization_type, TransferableResource::SynchronizationType::kSyncToken); ResourceId id2 = child_resource_provider_->ImportResource( @@ -468,13 +468,13 @@ for (auto sync_type : kSynchronizationTypes) { MockReleaseCallback release; - TransferableResource tran1 = CreateResource(RGBA_8888); + TransferableResource tran1 = CreateResource(); tran1.synchronization_type = sync_type; ResourceId id1 = child_resource_provider_->ImportResource( tran1, base::BindOnce(&MockReleaseCallback::Released, base::Unretained(&release))); - TransferableResource tran2 = CreateResource(RGBA_8888); + TransferableResource tran2 = CreateResource(); ASSERT_EQ(tran2.synchronization_type, TransferableResource::SynchronizationType::kSyncToken); ResourceId id2 = child_resource_provider_->ImportResource( @@ -564,14 +564,14 @@ TEST_F(DisplayResourceProviderSkiaTest, ResourceFenceOutlivesResourceProvider) { MockReleaseCallback release; - TransferableResource tran1 = CreateResource(RGBA_8888); + TransferableResource tran1 = CreateResource(); tran1.synchronization_type = TransferableResource::SynchronizationType::kGpuCommandsCompleted; ResourceId id1 = child_resource_provider_->ImportResource( tran1, base::BindOnce(&MockReleaseCallback::Released, base::Unretained(&release))); - TransferableResource tran2 = CreateResource(RGBA_8888); + TransferableResource tran2 = CreateResource(); tran2.synchronization_type = TransferableResource::SynchronizationType::kReleaseFence; ResourceId id2 = child_resource_provider_->ImportResource( @@ -660,7 +660,7 @@ constexpr size_t kUsedResources = 4; ResourceId ids[kTotalResources]; for (auto& id : ids) { - TransferableResource tran = CreateResource(RGBA_8888); + TransferableResource tran = CreateResource(); id = child_resource_provider_->ImportResource( tran, base::BindOnce(&MockReleaseCallback::Released, base::Unretained(&release)));
diff --git a/components/viz/service/display/display_resource_provider_software_unittest.cc b/components/viz/service/display/display_resource_provider_software_unittest.cc index 5a83f61..cfcbef86 100644 --- a/components/viz/service/display/display_resource_provider_software_unittest.cc +++ b/components/viz/service/display/display_resource_provider_software_unittest.cc
@@ -54,12 +54,12 @@ static SharedBitmapId CreateAndFillSharedBitmap(SharedBitmapManager* manager, const gfx::Size& size, - ResourceFormat format, + SharedImageFormat format, uint32_t value) { SharedBitmapId shared_bitmap_id = SharedBitmap::GenerateId(); - base::MappedReadOnlyRegion shm = bitmap_allocation::AllocateSharedBitmap( - size, SinglePlaneFormat::kRGBA_8888); + base::MappedReadOnlyRegion shm = + bitmap_allocation::AllocateSharedBitmap(size, format); manager->ChildAllocatedSharedBitmap(shm.region.Map(), shared_bitmap_id); base::span<uint32_t> span = shm.mapping.GetMemoryAsSpan<uint32_t>(size.GetArea()); @@ -79,14 +79,6 @@ child_resource_provider_->ShutdownAndReleaseAllResources(); } - TransferableResource CreateResource(ResourceFormat format) { - constexpr gfx::Size size(64, 64); - SharedBitmapId shared_bitmap_id = CreateAndFillSharedBitmap( - shared_bitmap_manager_.get(), size, format, 0); - - return TransferableResource::MakeSoftware(shared_bitmap_id, size, format); - } - protected: const std::unique_ptr<TestSharedBitmapManager> shared_bitmap_manager_; const std::unique_ptr<DisplayResourceProviderSoftware> resource_provider_; @@ -95,7 +87,7 @@ TEST_F(DisplayResourceProviderSoftwareTest, ReadSoftwareResources) { gfx::Size size(64, 64); - ResourceFormat format = RGBA_8888; + SharedImageFormat format = SinglePlaneFormat::kRGBA_8888; const uint32_t kBadBeef = 0xbadbeef; SharedBitmapId shared_bitmap_id = CreateAndFillSharedBitmap( shared_bitmap_manager_.get(), size, format, kBadBeef);
diff --git a/components/viz/service/display/overlay_ca_unittest.cc b/components/viz/service/display/overlay_ca_unittest.cc index b856ac2..3eeda25 100644 --- a/components/viz/service/display/overlay_ca_unittest.cc +++ b/components/viz/service/display/overlay_ca_unittest.cc
@@ -77,7 +77,8 @@ bool is_overlay_candidate) { auto resource = TransferableResource::MakeGpu( gpu::Mailbox::GenerateForSharedImage(), GL_LINEAR, GL_TEXTURE_2D, - gpu::SyncToken(), size, RGBA_8888, is_overlay_candidate); + gpu::SyncToken(), size, SinglePlaneFormat::kRGBA_8888, + is_overlay_candidate); ResourceId resource_id = child_resource_provider->ImportResource(resource, base::DoNothing());
diff --git a/components/viz/service/display/overlay_candidate_factory_unittest.cc b/components/viz/service/display/overlay_candidate_factory_unittest.cc index 690c18b..4c3e989e 100644 --- a/components/viz/service/display/overlay_candidate_factory_unittest.cc +++ b/components/viz/service/display/overlay_candidate_factory_unittest.cc
@@ -40,7 +40,7 @@ auto resource = TransferableResource::MakeGpu( gpu::Mailbox::GenerateForSharedImage(), GL_LINEAR, GL_TEXTURE_2D, - gpu::SyncToken(), gfx::Size(1, 1), ResourceFormat::RGBA_8888, true); + gpu::SyncToken(), gfx::Size(1, 1), SinglePlaneFormat::kRGBA_8888, true); ResourceId resource_id = child_resource_provider_.ImportResource(resource, base::DoNothing());
diff --git a/components/viz/service/display/overlay_dc_unittest.cc b/components/viz/service/display/overlay_dc_unittest.cc index 70cad658..a2f8160 100644 --- a/components/viz/service/display/overlay_dc_unittest.cc +++ b/components/viz/service/display/overlay_dc_unittest.cc
@@ -97,7 +97,8 @@ bool is_overlay_candidate) { auto resource = TransferableResource::MakeGpu( gpu::Mailbox::GenerateForSharedImage(), GL_LINEAR, GL_TEXTURE_2D, - gpu::SyncToken(), size, RGBA_8888, is_overlay_candidate); + gpu::SyncToken(), size, SinglePlaneFormat::kRGBA_8888, + is_overlay_candidate); ResourceId resource_id = child_resource_provider->ImportResource(resource, base::DoNothing());
diff --git a/components/viz/service/display/overlay_unittest.cc b/components/viz/service/display/overlay_unittest.cc index 65fd060..c8346e1 100644 --- a/components/viz/service/display/overlay_unittest.cc +++ b/components/viz/service/display/overlay_unittest.cc
@@ -409,10 +409,10 @@ ClientResourceProvider* child_resource_provider, const gfx::Size& size, bool is_overlay_candidate, - ResourceFormat resource_format) { + SharedImageFormat format) { auto resource = TransferableResource::MakeGpu( gpu::Mailbox::GenerateForSharedImage(), GL_LINEAR, GL_TEXTURE_2D, - gpu::SyncToken(), size, resource_format, is_overlay_candidate); + gpu::SyncToken(), size, format, is_overlay_candidate); ResourceId resource_id = child_resource_provider->ImportResource(resource, base::DoNothing()); @@ -425,10 +425,10 @@ ContextProvider* child_context_provider, const gfx::Size& size, bool is_overlay_candidate, - ResourceFormat resource_format, + SharedImageFormat format, SurfaceId test_surface_id = SurfaceId()) { ResourceId resource_id = CreateResourceInLayerTree( - child_resource_provider, size, is_overlay_candidate, resource_format); + child_resource_provider, size, is_overlay_candidate, format); int child_id = parent_resource_provider->CreateChild(base::DoNothing(), test_surface_id); @@ -458,7 +458,7 @@ bool is_overlay_candidate) { return CreateResource(parent_resource_provider, child_resource_provider, child_context_provider, size, is_overlay_candidate, - RGBA_8888); + SinglePlaneFormat::kRGBA_8888); } SolidColorDrawQuad* CreateSolidColorQuadAt( @@ -480,7 +480,7 @@ AggregatedRenderPass* render_pass, const gfx::Rect& rect, gfx::ProtectedVideoType protected_video_type, - ResourceFormat resource_format, + SharedImageFormat format, const gfx::Size& resource_size_in_pixels, SurfaceId test_surface_id = SurfaceId()) { bool needs_blending = false; @@ -489,10 +489,9 @@ bool nearest_neighbor = false; float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; bool is_overlay_candidate = true; - ResourceId resource_id = - CreateResource(parent_resource_provider, child_resource_provider, - child_context_provider, resource_size_in_pixels, - is_overlay_candidate, resource_format, test_surface_id); + ResourceId resource_id = CreateResource( + parent_resource_provider, child_resource_provider, child_context_provider, + resource_size_in_pixels, is_overlay_candidate, format, test_surface_id); auto* overlay_quad = render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); overlay_quad->SetNew(shared_quad_state, rect, rect, needs_blending, @@ -513,12 +512,12 @@ AggregatedRenderPass* render_pass, const gfx::Rect& rect, gfx::ProtectedVideoType protected_video_type, - ResourceFormat resource_format, + SharedImageFormat format, SurfaceId test_surface_id = SurfaceId()) { return CreateCandidateQuadAt( parent_resource_provider, child_resource_provider, child_context_provider, - shared_quad_state, render_pass, rect, protected_video_type, - resource_format, rect.size(), test_surface_id); + shared_quad_state, render_pass, rect, protected_video_type, format, + rect.size(), test_surface_id); } TextureDrawQuad* CreateCandidateQuadAt( @@ -532,7 +531,7 @@ return CreateCandidateQuadAt( parent_resource_provider, child_resource_provider, child_context_provider, shared_quad_state, render_pass, rect, gfx::ProtectedVideoType::kClear, - RGBA_8888, test_surface_id); + SinglePlaneFormat::kRGBA_8888, test_surface_id); } #if BUILDFLAG(ENABLE_CAST_OVERLAY_STRATEGY) @@ -2188,7 +2187,7 @@ resource_provider_.get(), child_resource_provider_.get(), child_provider_.get(), pass->shared_quad_state_list.back(), pass.get(), pass->output_rect, gfx::ProtectedVideoType::kHardwareProtected, - YUV_420_BIPLANAR) + MultiPlaneFormat::kYUV_420_BIPLANAR) ->needs_blending = false; pass->shared_quad_state_list.front()->opacity = 1.0; @@ -4232,7 +4231,7 @@ resource_provider_.get(), child_resource_provider_.get(), child_provider_.get(), pass->shared_quad_state_list.back(), pass.get(), kSmallCandidateRect, gfx::ProtectedVideoType::kHardwareProtected, - YUV_420_BIPLANAR); + MultiPlaneFormat::kYUV_420_BIPLANAR); SurfaceDamageRectList surface_damage_rect_list; OverlayCandidate candidate; auto color_mat = GetIdentityColorMatrix(); @@ -4255,7 +4254,7 @@ resource_provider_.get(), child_resource_provider_.get(), child_provider_.get(), pass->shared_quad_state_list.back(), pass.get(), kVideoCandidateRect, gfx::ProtectedVideoType::kHardwareProtected, - YUV_420_BIPLANAR); + MultiPlaneFormat::kYUV_420_BIPLANAR); pass->shared_quad_state_list.back()->clip_rect = kOverlayClipRect; SurfaceDamageRectList surface_damage_rect_list; OverlayCandidate candidate; @@ -4289,7 +4288,7 @@ resource_provider_.get(), child_resource_provider_.get(), child_provider_.get(), pass->shared_quad_state_list.back(), pass.get(), kVideoCandidateRect, gfx::ProtectedVideoType::kHardwareProtected, - YUV_420_BIPLANAR); + MultiPlaneFormat::kYUV_420_BIPLANAR); pass->shared_quad_state_list.back()->clip_rect = kOverlayClipRect; SurfaceDamageRectList surface_damage_rect_list; gfx::RectF primary_rect(0, 0, 100, 120); @@ -4476,7 +4475,8 @@ resource_provider_.get(), child_resource_provider_.get(), child_provider_.get(), pass->shared_quad_state_list.back(), pass.get(), pass->output_rect, gfx::ProtectedVideoType::kHardwareProtected, - YUV_420_BIPLANAR, gfx::ScaleToRoundedSize(kDisplaySize, res_scale)) + MultiPlaneFormat::kYUV_420_BIPLANAR, + gfx::ScaleToRoundedSize(kDisplaySize, res_scale)) ->needs_blending = false; pass->shared_quad_state_list.front()->opacity = 1.0; @@ -4505,17 +4505,16 @@ ContextProvider* child_context_provider, const SharedQuadState* shared_quad_state, AggregatedRenderPass* render_pass, - const gfx::Rect& rect, - ResourceFormat resource_format = RGBA_8888, - SurfaceId test_surface_id = SurfaceId()) { + const gfx::Rect& rect) { bool needs_blending = false; bool premultiplied_alpha = false; bool force_anti_aliasing_off = false; bool nearest_neighbor = false; bool is_overlay_candidate = true; - ResourceId resource_id = CreateResource( - parent_resource_provider, child_resource_provider, child_context_provider, - rect.size(), is_overlay_candidate, resource_format, test_surface_id); + ResourceId resource_id = + CreateResource(parent_resource_provider, child_resource_provider, + child_context_provider, rect.size(), is_overlay_candidate, + SinglePlaneFormat::kRGBA_8888, SurfaceId()); auto* overlay_quad = render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); overlay_quad->SetNew(shared_quad_state, rect, rect, needs_blending, @@ -4865,7 +4864,7 @@ child_resource_provider_.get(), child_provider_.get(), pass->shared_quad_state_list.back(), pass.get(), kSmallCandidateRect, gfx::ProtectedVideoType::kClear, - RGBA_8888, kResourceSize); + SinglePlaneFormat::kRGBA_8888, kResourceSize); // Here resource size and rect size on screen will match 1:1. CreateCandidateQuadAt(resource_provider_.get(), @@ -5546,10 +5545,11 @@ auto* sqs = pass->CreateAndAppendSharedQuadState(); sqs->overlay_damage_index = surface_damage_rect_list.size(); surface_damage_rect_list.emplace_back(kBottomLeft); - CreateCandidateQuadAt( - resource_provider_.get(), child_resource_provider_.get(), - child_provider_.get(), sqs, pass.get(), kBottomLeft, - gfx::ProtectedVideoType::kHardwareProtected, YUV_420_BIPLANAR); + CreateCandidateQuadAt(resource_provider_.get(), + child_resource_provider_.get(), child_provider_.get(), + sqs, pass.get(), kBottomLeft, + gfx::ProtectedVideoType::kHardwareProtected, + MultiPlaneFormat::kYUV_420_BIPLANAR); overlay_processor_->AddExpectedRect(kBottomLeft, true); } {
diff --git a/components/viz/service/display/renderer_perftest.cc b/components/viz/service/display/renderer_perftest.cc index fbe73aa4..4924f32 100644 --- a/components/viz/service/display/renderer_perftest.cc +++ b/components/viz/service/display/renderer_perftest.cc
@@ -179,8 +179,8 @@ gpu::SyncToken sync_token = sii->GenVerifiedSyncToken(); TransferableResource gl_resource = TransferableResource::MakeGpu( - mailbox, GL_LINEAR, GL_TEXTURE_2D, sync_token, size, RGBA_8888, - false /* is_overlay_candidate */); + mailbox, GL_LINEAR, GL_TEXTURE_2D, sync_token, size, + SinglePlaneFormat::kRGBA_8888, false /* is_overlay_candidate */); gl_resource.color_space = gfx::ColorSpace(); auto release_callback = base::BindOnce( &DeleteSharedImage, std::move(child_context_provider), mailbox);
diff --git a/components/viz/service/display/renderer_pixeltest.cc b/components/viz/service/display/renderer_pixeltest.cc index c8ce716..b438a68 100644 --- a/components/viz/service/display/renderer_pixeltest.cc +++ b/components/viz/service/display/renderer_pixeltest.cc
@@ -128,8 +128,8 @@ gpu::SyncToken sync_token = sii->GenUnverifiedSyncToken(); TransferableResource gl_resource = TransferableResource::MakeGpu( - mailbox, GL_LINEAR, GL_TEXTURE_2D, sync_token, size, - format.resource_format(), false /* is_overlay_candidate */); + mailbox, GL_LINEAR, GL_TEXTURE_2D, sync_token, size, format, + false /* is_overlay_candidate */); gl_resource.color_space = std::move(color_space); auto release_callback = base::BindOnce(&DeleteSharedImage, std::move(context_provider), mailbox); @@ -283,7 +283,7 @@ shared_bitmap_manager); resource = child_resource_provider->ImportResource( TransferableResource::MakeSoftware(shared_bitmap_id, rect.size(), - RGBA_8888), + SinglePlaneFormat::kRGBA_8888), base::DoNothing()); auto span = mapping.GetMemoryAsSpan<uint32_t>(pixels.size()); @@ -346,7 +346,7 @@ shared_bitmap_manager); resource = child_resource_provider->ImportResource( TransferableResource::MakeSoftware(shared_bitmap_id, rect.size(), - RGBA_8888), + SinglePlaneFormat::kRGBA_8888), base::DoNothing()); auto span = mapping.GetMemoryAsSpan<uint32_t>(pixels.size());
diff --git a/components/viz/service/display/software_renderer_unittest.cc b/components/viz/service/display/software_renderer_unittest.cc index 52e5e293..2d9db960 100644 --- a/components/viz/service/display/software_renderer_unittest.cc +++ b/components/viz/service/display/software_renderer_unittest.cc
@@ -93,7 +93,8 @@ // Makes a resource id that refers to the registered SharedBitmapId. return child_resource_provider_->ImportResource( - TransferableResource::MakeSoftware(shared_bitmap_id, size, RGBA_8888), + TransferableResource::MakeSoftware(shared_bitmap_id, size, + SinglePlaneFormat::kRGBA_8888), base::DoNothing()); }
diff --git a/components/viz/service/display/surface_aggregator_perftest.cc b/components/viz/service/display/surface_aggregator_perftest.cc index e90c7199..369aa525 100644 --- a/components/viz/service/display/surface_aggregator_perftest.cc +++ b/components/viz/service/display/surface_aggregator_perftest.cc
@@ -113,7 +113,7 @@ for (int j = 0; j < num_textures; j++) { const gfx::Size size(1, 2); TransferableResource resource = TransferableResource::MakeSoftware( - SharedBitmap::GenerateId(), size, ResourceFormat::RGBA_8888); + SharedBitmap::GenerateId(), size, SinglePlaneFormat::kRGBA_8888); resource.id = ResourceId(j); frame_builder.AddTransferableResource(resource); @@ -231,7 +231,8 @@ // Create the resource if we haven't yet. if (created_resources.find(resource_id) == created_resources.end()) { created_resources[resource_id] = TransferableResource::MakeSoftware( - SharedBitmap::GenerateId(), quad->rect.size(), RGBA_8888); + SharedBitmap::GenerateId(), quad->rect.size(), + SinglePlaneFormat::kRGBA_8888); created_resources[resource_id].id = resource_id; } resource_data_map_[frame_sink_id]
diff --git a/components/viz/service/display/surface_aggregator_unittest.cc b/components/viz/service/display/surface_aggregator_unittest.cc index 19f488b99..ac35644 100644 --- a/components/viz/service/display/surface_aggregator_unittest.cc +++ b/components/viz/service/display/surface_aggregator_unittest.cc
@@ -5841,7 +5841,8 @@ for (ResourceId resource_id : resource_ids) { auto resource = TransferableResource::MakeSoftware( - SharedBitmap::GenerateId(), gfx::Size(1, 1), RGBA_8888); + SharedBitmap::GenerateId(), gfx::Size(1, 1), + SinglePlaneFormat::kRGBA_8888); resource.id = resource_id; if (!valid) { // ResourceProvider is software, so only software resources are valid. Do
diff --git a/components/viz/service/transitions/transferable_resource_tracker.cc b/components/viz/service/transitions/transferable_resource_tracker.cc index a60e0b5..1826965 100644 --- a/components/viz/service/transitions/transferable_resource_tracker.cc +++ b/components/viz/service/transitions/transferable_resource_tracker.cc
@@ -82,7 +82,7 @@ shared_bitmap_manager_->LocalAllocatedSharedBitmap( std::move(output_copy.bitmap), id); resource = TransferableResource::MakeSoftware( - id, output_copy.draw_data.size, RGBA_8888); + id, output_copy.draw_data.size, SinglePlaneFormat::kRGBA_8888); // Remove the bitmap from shared bitmap manager when no longer in use. release_callback = base::BindOnce( @@ -96,7 +96,7 @@ resource = TransferableResource::MakeGpu( output_copy.mailbox, GL_LINEAR, GL_TEXTURE_2D, output_copy.sync_token, - output_copy.draw_data.size, RGBA_8888, + output_copy.draw_data.size, SinglePlaneFormat::kRGBA_8888, /*is_overlay_candidate=*/false); resource.color_space = output_copy.color_space;
diff --git a/components/viz/test/compositor_frame_helpers.cc b/components/viz/test/compositor_frame_helpers.cc index 1d2e6b2..cd4a965 100644 --- a/components/viz/test/compositor_frame_helpers.cc +++ b/components/viz/test/compositor_frame_helpers.cc
@@ -518,7 +518,8 @@ // Adds a TransferableResource the first time seeing a ResourceId. if (resources_added.insert(resource_id).second) { frame.resource_list.push_back(TransferableResource::MakeSoftware( - SharedBitmap::GenerateId(), quad->rect.size(), RGBA_8888)); + SharedBitmap::GenerateId(), quad->rect.size(), + SinglePlaneFormat::kRGBA_8888)); frame.resource_list.back().id = resource_id; } }
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn index b5644ad..0f251da 100644 --- a/content/browser/BUILD.gn +++ b/content/browser/BUILD.gn
@@ -1468,6 +1468,8 @@ "preloading/prefetch/prefetch_streaming_url_loader_status.h", "preloading/prefetch/prefetch_type.cc", "preloading/prefetch/prefetch_type.h", + "preloading/prefetch/prefetch_url_loader_helper.cc", + "preloading/prefetch/prefetch_url_loader_helper.h", "preloading/prefetch/prefetch_url_loader_interceptor.cc", "preloading/prefetch/prefetch_url_loader_interceptor.h", "preloading/prefetch/proxy_lookup_client_impl.cc",
diff --git a/content/browser/attribution_reporting/attribution_data_host_manager_impl.cc b/content/browser/attribution_reporting/attribution_data_host_manager_impl.cc index db77edfe1..dce5112 100644 --- a/content/browser/attribution_reporting/attribution_data_host_manager_impl.cc +++ b/content/browser/attribution_reporting/attribution_data_host_manager_impl.cc
@@ -37,7 +37,6 @@ #include "components/attribution_reporting/trigger_registration.h" #include "content/browser/attribution_reporting/attribution_beacon_id.h" #include "content/browser/attribution_reporting/attribution_constants.h" -#include "content/browser/attribution_reporting/attribution_features.h" #include "content/browser/attribution_reporting/attribution_input_event.h" #include "content/browser/attribution_reporting/attribution_manager.h" #include "content/browser/attribution_reporting/attribution_trigger.h" @@ -829,11 +828,9 @@ const net::HttpResponseHeaders* headers, bool is_final_response) { auto it = registrations_.find(beacon_id); - - if (base::FeatureList::IsEnabled(kAttributionFencedFrameReportingBeacon)) { - DCHECK(it != registrations_.end()); - } - + // This may happen if validation failed in + // `AttributionHost::NotifyFencedFrameReportingBeaconStarted()` and therefore + // not being tracked. if (it == registrations_.end()) { return; }
diff --git a/content/browser/browser_context_impl.cc b/content/browser/browser_context_impl.cc index bc2d685..92f04550 100644 --- a/content/browser/browser_context_impl.cc +++ b/content/browser/browser_context_impl.cc
@@ -299,6 +299,11 @@ return prefetch_service_.get(); } +void BrowserContextImpl::SetPrefetchServiceForTesting( + std::unique_ptr<PrefetchService> prefetch_service) { + prefetch_service_ = std::move(prefetch_service); +} + void BrowserContextImpl::WriteIntoTrace( perfetto::TracedProto<TraceProto> proto) const { proto->set_id(UniqueId());
diff --git a/content/browser/browser_context_impl.h b/content/browser/browser_context_impl.h index b13cc4f..da4086e7 100644 --- a/content/browser/browser_context_impl.h +++ b/content/browser/browser_context_impl.h
@@ -96,6 +96,8 @@ } PrefetchService* GetPrefetchService(); + void SetPrefetchServiceForTesting( + std::unique_ptr<PrefetchService> prefetch_service); using TraceProto = perfetto::protos::pbzero::ChromeBrowserContext; // Write a representation of this object into a trace.
diff --git a/content/browser/loader/keep_alive_url_browsertest.cc b/content/browser/loader/keep_alive_url_browsertest.cc new file mode 100644 index 0000000..1a077af --- /dev/null +++ b/content/browser/loader/keep_alive_url_browsertest.cc
@@ -0,0 +1,403 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/browser/loader/keep_alive_url_loader_service.h" + +#include <memory> +#include <vector> + +#include "base/feature_list.h" +#include "base/location.h" +#include "base/run_loop.h" +#include "base/synchronization/lock.h" +#include "base/test/bind.h" +#include "base/test/mock_callback.h" +#include "base/test/scoped_feature_list.h" +#include "base/thread_annotations.h" +#include "content/browser/loader/keep_alive_url_loader.h" +#include "content/browser/renderer_host/render_frame_host_impl.h" +#include "content/browser/storage_partition_impl.h" +#include "content/browser/web_contents/web_contents_impl.h" +#include "content/public/browser/browser_context.h" +#include "content/public/browser/render_frame_host.h" +#include "content/public/browser/storage_partition.h" +#include "content/public/test/back_forward_cache_util.h" +#include "content/public/test/browser_test.h" +#include "content/public/test/browser_test_utils.h" +#include "content/public/test/content_browser_test.h" +#include "content/public/test/content_browser_test_utils.h" +#include "content/public/test/test_utils.h" +#include "content/shell/browser/shell.h" +#include "content/test/content_browser_test_utils_internal.h" +#include "net/dns/mock_host_resolver.h" +#include "net/http/http_request_headers.h" +#include "net/test/embedded_test_server/controllable_http_response.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "third_party/blink/public/common/features.h" + +namespace content { + +namespace { + +constexpr char16_t kPromiseResolvedPageTitle[] = u"Resolved"; +constexpr char kPrimaryHost[] = "a.com"; +constexpr char kSecondaryHost[] = "b.com"; +constexpr char kKeepAliveEndpoint[] = "/beacon"; +constexpr char kKeepAliveResponse[] = + "HTTP/1.1 200 OK\r\n" + "Content-Type: text/html; charset=utf-8\r\n" + "\r\n"; + +// A helper to manage responding to multiple fetch keepalive requests in batch. +class KeepAliveRequestsHandler { + public: + KeepAliveRequestsHandler(net::EmbeddedTestServer* server, + size_t num_requests) { + for (size_t i = 0; i < num_requests; ++i) { + controllers_.emplace_back( + std::make_unique<net::test_server::ControllableHttpResponse>( + server, kKeepAliveEndpoint)); + } + } + // Not Copyable. + KeepAliveRequestsHandler(const KeepAliveRequestsHandler&) = delete; + KeepAliveRequestsHandler& operator=(const KeepAliveRequestsHandler&) = delete; + + void WaitForAllRequests() { + for (auto& controller : controllers_) { + controller->WaitForRequest(); + } + } + + void Send(const std::string& bytes) { + for (auto& controller : controllers_) { + controller->Send(bytes); + } + } + + void Done() { + for (auto& controller : controllers_) { + controller->Done(); + } + } + + private: + std::vector<std::unique_ptr<net::test_server::ControllableHttpResponse>> + controllers_; +}; + +// Help to count the total triggering of one of methods observed by +// `KeepAliveURLLoadersTestObserver`. +// Use `WaitUntil()` to wait until this counter reaching specific value. +class AtomicCounter { + public: + AtomicCounter() = default; + // Not Copyable. + AtomicCounter(const AtomicCounter&) = delete; + AtomicCounter& operator=(const AtomicCounter&) = delete; + + // Increments the internal counter, and stops `waiting_run_loop_` if exists. + void Increment() { + base::AutoLock auto_lock(lock_); + count_++; + if (waiting_run_loop_) { + waiting_run_loop_->Quit(); + } + } + + // If `count_` does not yet reach `value`, a RunLoop will be created and runs + // until it is stopped by `Increment()`. + void WaitUntil(size_t value) { + { + base::AutoLock auto_lock(lock_); + if (count_ >= value) { + return; + } + } + + { + base::AutoLock auto_lock(lock_); + waiting_run_loop_ = std::make_unique<base::RunLoop>( + base::RunLoop::Type::kNestableTasksAllowed); + } + waiting_run_loop_->Run(); + + { + base::AutoLock auto_lock(lock_); + waiting_run_loop_.reset(); + } + } + + private: + base::Lock lock_; + size_t count_ GUARDED_BY(lock_) = 0; + std::unique_ptr<base::RunLoop> waiting_run_loop_ = nullptr; +}; + +// Observes all created KeepAliveURLLoader instances' behaviors. +// KeepAliveURLLoader itself is running in browser UI thread. But there can be +// multiple instances. +class KeepAliveURLLoadersTestObserver + : public KeepAliveURLLoader::TestObserver { + public: + KeepAliveURLLoadersTestObserver() = default; + // Not Copyable. + KeepAliveURLLoadersTestObserver(const KeepAliveURLLoadersTestObserver&) = + delete; + KeepAliveURLLoadersTestObserver& operator=( + const KeepAliveURLLoadersTestObserver&) = delete; + + // Waits for `OnReceiveResponseForwarded` to be called `total` times. + void WaitForTotalOnReceiveResponseForwarded(size_t total) { + on_receive_response_forwarded_count_.WaitUntil(total); + } + // Waits for `OnReceiveResponseProcessed` to be called `total` times. + void WaitForTotalOnReceiveResponseProcessed(size_t total) { + on_receive_response_processed_count_.WaitUntil(total); + } + // Waits for `OnCompleteForwarded` to be called `total` times. + void WaitForTotalOnCompleteForwarded(size_t total) { + on_complete_forwarded_count_.WaitUntil(total); + } + // Waits for `OnCompleteProcessed` to be called `total` times. + void WaitForTotalOnCompleteProcessed(size_t total) { + on_complete_processed_count_.WaitUntil(total); + } + + protected: + ~KeepAliveURLLoadersTestObserver() override = default; + + private: + // KeepAliveURLLoader::TestObserver overrides: + void OnReceiveResponseForwarded(KeepAliveURLLoader* loader) override { + on_receive_response_forwarded_count_.Increment(); + } + void OnReceiveResponseProcessed(KeepAliveURLLoader* loader) override { + on_receive_response_processed_count_.Increment(); + } + void OnCompleteForwarded(KeepAliveURLLoader* loader) override { + on_complete_forwarded_count_.Increment(); + } + void OnCompleteProcessed(KeepAliveURLLoader* loader) override { + on_complete_processed_count_.Increment(); + } + + AtomicCounter on_receive_response_forwarded_count_; + AtomicCounter on_receive_response_processed_count_; + AtomicCounter on_complete_forwarded_count_; + AtomicCounter on_complete_processed_count_; +}; + +} // namespace + +// Contains the integration tests for loading fetch(url, {keepalive: true}) +// requests via browser process that are difficult to reliably reproduce in web +// tests. +// +// Note that due to using different approach, tests to cover implementation +// before `kKeepAliveInBrowserMigration`, i.e. loading via delaying renderer +// shutdown, cannot be verified with inspecting KeepAliveURLLoaderService here +// and still live in a different file +// content/browser/renderer_host/render_process_host_browsertest.cc +class KeepAliveURLBrowserTest + : public ContentBrowserTest, + public ::testing::WithParamInterface<std::string> { + public: + KeepAliveURLBrowserTest() { + feature_list_.InitWithFeaturesAndParameters( + GetDefaultEnabledBackForwardCacheFeaturesForTesting( + {{blink::features::kKeepAliveInBrowserMigration, {}}}), + GetDefaultDisabledBackForwardCacheFeaturesForTesting()); + } + ~KeepAliveURLBrowserTest() override = default; + // Not Copyable. + KeepAliveURLBrowserTest(const KeepAliveURLBrowserTest&) = delete; + KeepAliveURLBrowserTest& operator=(const KeepAliveURLBrowserTest&) = delete; + + void SetUpOnMainThread() override { + loaders_observer_ = base::MakeRefCounted<KeepAliveURLLoadersTestObserver>(); + // Support multiple sites on the test server. + host_resolver()->AddRule("*", "127.0.0.1"); + loader_service()->SetLoaderObserverForTesting(loaders_observer_); + } + + void RegisterRequestsHandler(size_t num_requests) { + requests_handler_ = std::make_unique<KeepAliveRequestsHandler>( + embedded_test_server(), num_requests); + ASSERT_TRUE(embedded_test_server()->Start()); + } + + protected: + WebContentsImpl* web_contents() const { + return static_cast<WebContentsImpl*>(shell()->web_contents()); + } + RenderFrameHostImpl* current_frame_host() { + return web_contents()->GetPrimaryFrameTree().root()->current_frame_host(); + } + KeepAliveURLLoaderService* loader_service() { + return static_cast<StoragePartitionImpl*>( + web_contents() + ->GetBrowserContext() + ->GetDefaultStoragePartition()) + ->GetKeepAliveURLLoaderService(); + } + void DisableBackForwardCache(WebContents* web_contents) { + DisableBackForwardCacheForTesting( + web_contents, BackForwardCache::TEST_REQUIRES_NO_CACHING); + } + KeepAliveRequestsHandler& requests_handler() { return *requests_handler_; } + KeepAliveURLLoadersTestObserver& loaders_observer() { + return *loaders_observer_; + } + GURL GetKeepalivePageURL(const std::string& method, + size_t num_requests = 1) const { + return embedded_test_server()->GetURL( + kPrimaryHost, + base::StringPrintf("/fetch-keepalive.html?method=%s&requests=%zu", + method.c_str(), num_requests)); + } + GURL GetCrossOriginPageURL() { + return embedded_test_server()->GetURL(kSecondaryHost, "/title2.html"); + } + + void ExpectReceiveResponseCalled() const {} + + private: + base::test::ScopedFeatureList feature_list_; + std::unique_ptr<KeepAliveRequestsHandler> requests_handler_; + scoped_refptr<KeepAliveURLLoadersTestObserver> loaders_observer_; +}; + +INSTANTIATE_TEST_SUITE_P( + All, + KeepAliveURLBrowserTest, + ::testing::Values(net::HttpRequestHeaders::kGetMethod/*, + net::HttpRequestHeaders::kPostMethod*/), + [](const testing::TestParamInfo<KeepAliveURLBrowserTest::ParamType>& info) { + return info.param; + }); + +IN_PROC_BROWSER_TEST_P(KeepAliveURLBrowserTest, OneRequest) { + const std::string method = GetParam(); + RegisterRequestsHandler(1); + ASSERT_TRUE(NavigateToURL(web_contents(), GetKeepalivePageURL(method))); + // Ensure the keepalive request is sent, but delay response. + requests_handler().WaitForAllRequests(); + ASSERT_EQ(loader_service()->NumLoadersForTesting(), 1u); + + // End the keepalive request by sending back response. + requests_handler().Send(kKeepAliveResponse); + requests_handler().Done(); + + TitleWatcher watcher(web_contents(), kPromiseResolvedPageTitle); + EXPECT_EQ(watcher.WaitAndGetTitle(), kPromiseResolvedPageTitle); + loaders_observer().WaitForTotalOnReceiveResponseForwarded(1); + loaders_observer().WaitForTotalOnCompleteForwarded(1); + EXPECT_EQ(loader_service()->NumLoadersForTesting(), 0u); +} + +// Verify keepalive request loading works given 2 concurrent requests to the +// same host. +// +// Note: Chromium allows at most 6 concurrent connections to the same host under +// HTTP 1.1 protocol, which `embedded_test_server()` uses by default. +// Exceeding this limit will hang the browser. +// TODO(crbug.com/1428502): Flaky on Fuchsia and Android. +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) +#define MAYBE_TwoConcurrentRequestsPerHost DISABLED_TwoConcurrentRequestsPerHost +#else +#define MAYBE_TwoConcurrentRequestsPerHost TwoConcurrentRequestsPerHost +#endif +IN_PROC_BROWSER_TEST_P(KeepAliveURLBrowserTest, + MAYBE_TwoConcurrentRequestsPerHost) { + const std::string method = GetParam(); + const size_t num_requests = 2; + RegisterRequestsHandler(num_requests); + ASSERT_TRUE( + NavigateToURL(web_contents(), GetKeepalivePageURL(method, num_requests))); + // Ensure all keepalive requests are sent, but delay responses. + requests_handler().WaitForAllRequests(); + ASSERT_EQ(loader_service()->NumLoadersForTesting(), num_requests); + + // End the keepalive request by sending back responses. + requests_handler().Send(kKeepAliveResponse); + requests_handler().Done(); + + TitleWatcher watcher(web_contents(), kPromiseResolvedPageTitle); + EXPECT_EQ(watcher.WaitAndGetTitle(), kPromiseResolvedPageTitle); + loaders_observer().WaitForTotalOnReceiveResponseForwarded(2); + loaders_observer().WaitForTotalOnCompleteForwarded(2); + EXPECT_EQ(loader_service()->NumLoadersForTesting(), 0u); +} + +// Delays response to a keepalive ping until after the page making the keepalive +// ping has been unloaded. The browser must ensure the response is received and +// processed by the browser. +IN_PROC_BROWSER_TEST_P(KeepAliveURLBrowserTest, + ReceiveResponseAfterPageUnload) { + const std::string method = GetParam(); + RegisterRequestsHandler(1); + ASSERT_TRUE(NavigateToURL(web_contents(), GetKeepalivePageURL(method))); + RenderFrameHostImplWrapper rfh_1(current_frame_host()); + // Ensure the current page can be unloaded instead of being cached. + DisableBackForwardCache(web_contents()); + // Ensure the keepalive request is sent before leaving the current page. + requests_handler().WaitForAllRequests(); + ASSERT_EQ(loader_service()->NumLoadersForTesting(), 1u); + + // Navigate to cross-origin page. + ASSERT_TRUE(NavigateToURL(web_contents(), GetCrossOriginPageURL())); + // Ensure the previous page has been unloaded. + ASSERT_TRUE(rfh_1.WaitUntilRenderFrameDeleted()); + // The disconnected loader is still pending to receive response. + ASSERT_EQ(loader_service()->NumLoadersForTesting(), 1u); + ASSERT_EQ(loader_service()->NumDisconnectedLoadersForTesting(), 1u); + + // End the keepalive request by sending back response. + requests_handler().Send(kKeepAliveResponse); + requests_handler().Done(); + + // The response should be processed in browser. + loaders_observer().WaitForTotalOnReceiveResponseProcessed(1); + // `KeepAliveURLLoader::OnComplete` may not be called, as renderer is dead. + EXPECT_EQ(loader_service()->NumDisconnectedLoadersForTesting(), 0u); +} + +// Delays response to a keepalive ping until after the page making the keepalive +// ping is put into BackForwardCache. The response should be processed by the +// renderer after the page is restored from BackForwardcache. +IN_PROC_BROWSER_TEST_P(KeepAliveURLBrowserTest, + ReceiveResponseInBackForwardCache) { + const std::string method = GetParam(); + RegisterRequestsHandler(1); + ASSERT_TRUE(NavigateToURL(web_contents(), GetKeepalivePageURL(method))); + RenderFrameHostImplWrapper rfh_1(current_frame_host()); + // Ensure the keepalive request is sent before leaving the current page. + requests_handler().WaitForAllRequests(); + ASSERT_EQ(loader_service()->NumLoadersForTesting(), 1u); + + // Navigate to cross-origin page. + ASSERT_TRUE(NavigateToURL(web_contents(), GetCrossOriginPageURL())); + // Ensure the previous page has been put into BackForwardCache. + ASSERT_EQ(rfh_1->GetLifecycleState(), + RenderFrameHost::LifecycleState::kInBackForwardCache); + // The loader is still pending to receive response. + ASSERT_EQ(loader_service()->NumLoadersForTesting(), 1u); + ASSERT_EQ(loader_service()->NumDisconnectedLoadersForTesting(), 0u); + // Send back response. + requests_handler().Send(kKeepAliveResponse); + // The response is immediately forwarded to the in-BackForwardCache renderer. + loaders_observer().WaitForTotalOnReceiveResponseForwarded(1); + // Go back to `rfh_1`. + ASSERT_TRUE(HistoryGoBack(web_contents())); + + // The response should be processed in renderer. Hence resolving Promise. + TitleWatcher watcher(web_contents(), kPromiseResolvedPageTitle); + EXPECT_EQ(watcher.WaitAndGetTitle(), kPromiseResolvedPageTitle); + requests_handler().Done(); + loaders_observer().WaitForTotalOnCompleteForwarded(1); + EXPECT_EQ(loader_service()->NumLoadersForTesting(), 0u); +} + +} // namespace content
diff --git a/content/browser/loader/keep_alive_url_loader.cc b/content/browser/loader/keep_alive_url_loader.cc index fc3c6f7..1553b88 100644 --- a/content/browser/loader/keep_alive_url_loader.cc +++ b/content/browser/loader/keep_alive_url_loader.cc
@@ -133,6 +133,10 @@ // invalidate `forwarding_client_`. if (forwarding_client_) { // The renderer is alive, forwards the action. + if (observer_for_testing_) { + observer_for_testing_->OnReceiveResponseForwarded(this); + } + // The receiver may fail to finish reading `response`, so response caching // is not guaranteed. forwarding_client_->OnReceiveResponse(std::move(response), std::move(body), @@ -142,6 +146,10 @@ return; } + if (observer_for_testing_) { + observer_for_testing_->OnReceiveResponseProcessed(this); + } + // No need to wait for `OnComplete()`. // This loader should be deleted immediately to avoid hanged requests taking // up resources. @@ -215,7 +223,19 @@ if (forwarding_client_) { // The renderer is alive, forwards the action. + if (observer_for_testing_) { + observer_for_testing_->OnCompleteForwarded(this); + } + forwarding_client_->OnComplete(completion_status); + DeleteSelf(); + // DO NOT touch any members after this line. `this` is already deleted. + return; + } + + // TODO(crbug.com/1356128): Handle in the browser process. + if (observer_for_testing_) { + observer_for_testing_->OnCompleteProcessed(this); } DeleteSelf(); @@ -255,4 +275,9 @@ std::move(on_delete_callback_).Run(); } +void KeepAliveURLLoader::SetObserverForTesting( + scoped_refptr<TestObserver> observer) { + observer_for_testing_ = observer; +} + } // namespace content
diff --git a/content/browser/loader/keep_alive_url_loader.h b/content/browser/loader/keep_alive_url_loader.h index 6a91cb24..c562060 100644 --- a/content/browser/loader/keep_alive_url_loader.h +++ b/content/browser/loader/keep_alive_url_loader.h
@@ -87,6 +87,21 @@ // Must be called immediately after creating a KeepAliveLoader. void set_on_delete_callback(OnDeleteCallback on_delete_callback); + // For testing only: + // TODO(crbug.com/1427366): Figure out alt to not rely on this in test. + class TestObserver : public base::RefCountedThreadSafe<TestObserver> { + public: + virtual void OnReceiveResponseForwarded(KeepAliveURLLoader* loader) = 0; + virtual void OnReceiveResponseProcessed(KeepAliveURLLoader* loader) = 0; + virtual void OnCompleteForwarded(KeepAliveURLLoader* loader) = 0; + virtual void OnCompleteProcessed(KeepAliveURLLoader* loader) = 0; + + protected: + virtual ~TestObserver() = default; + friend class base::RefCountedThreadSafe<TestObserver>; + }; + void SetObserverForTesting(scoped_refptr<TestObserver> observer); + private: // Receives actions from renderer. // `network::mojom::URLLoader` overrides: @@ -144,6 +159,10 @@ // Whether `OnReceiveResponse()` has been called. bool has_received_response_ = false; + + // For testing only: + // Not owned. + scoped_refptr<TestObserver> observer_for_testing_ = nullptr; }; } // namespace content
diff --git a/content/browser/loader/keep_alive_url_loader_service.cc b/content/browser/loader/keep_alive_url_loader_service.cc index 3df42469..7a0abcc 100644 --- a/content/browser/loader/keep_alive_url_loader_service.cc +++ b/content/browser/loader/keep_alive_url_loader_service.cc
@@ -8,7 +8,6 @@ #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "base/trace_event/trace_event.h" -#include "content/browser/loader/keep_alive_url_loader.h" #include "content/browser/url_loader_factory_getter.h" #include "content/public/browser/browser_thread.h" #include "mojo/public/cpp/bindings/message.h" @@ -156,6 +155,10 @@ raw_loader->set_on_delete_callback( base::BindOnce(&KeepAliveURLLoaderService::RemoveLoader, base::Unretained(service_), receiver_id)); + if (service_->loader_test_observer_) { + raw_loader->SetObserverForTesting( // IN-TEST + service_->loader_test_observer_); // IN-TEST + } } void KeepAliveURLLoaderService::KeepAliveURLLoaderFactory::Clone( @@ -221,4 +224,9 @@ return disconnected_loaders_.size(); } +void KeepAliveURLLoaderService::SetLoaderObserverForTesting( + scoped_refptr<KeepAliveURLLoader::TestObserver> observer) { + loader_test_observer_ = observer; +} + } // namespace content
diff --git a/content/browser/loader/keep_alive_url_loader_service.h b/content/browser/loader/keep_alive_url_loader_service.h index eea87c4d..c3f4253 100644 --- a/content/browser/loader/keep_alive_url_loader_service.h +++ b/content/browser/loader/keep_alive_url_loader_service.h
@@ -8,6 +8,8 @@ #include <map> #include <memory> +#include "base/memory/scoped_refptr.h" +#include "content/browser/loader/keep_alive_url_loader.h" #include "content/common/content_export.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" @@ -52,6 +54,8 @@ // For testing only: size_t NumLoadersForTesting() const; size_t NumDisconnectedLoadersForTesting() const; + void SetLoaderObserverForTesting( + scoped_refptr<KeepAliveURLLoader::TestObserver> observer); private: class KeepAliveURLLoaderFactory; @@ -79,6 +83,11 @@ // The key is the mojo::ReceiverId assigned by `loader_receivers_`. std::map<mojo::ReceiverId, std::unique_ptr<network::mojom::URLLoader>> disconnected_loaders_; + + // For testing only: + // Not owned. + scoped_refptr<KeepAliveURLLoader::TestObserver> loader_test_observer_ = + nullptr; }; } // namespace content
diff --git a/content/browser/network_service_instance_impl.cc b/content/browser/network_service_instance_impl.cc index 4ff57c8..4d580959 100644 --- a/content/browser/network_service_instance_impl.cc +++ b/content/browser/network_service_instance_impl.cc
@@ -151,12 +151,8 @@ void CreateInProcessNetworkServiceOnThread( mojo::PendingReceiver<network::mojom::NetworkService> receiver) { - // The test interface doesn't need to be implemented in the in-process case. - auto registry = std::make_unique<service_manager::BinderRegistry>(); - registry->AddInterface(base::BindRepeating( - [](mojo::PendingReceiver<network::mojom::NetworkServiceTest>) {})); g_in_process_instance = new network::NetworkService( - std::move(registry), std::move(receiver), + nullptr /* registry */, std::move(receiver), true /* delay_initialization_until_set_client */); } @@ -408,8 +404,7 @@ if (GetContentClient() ->browser() ->ShouldRunOutOfProcessSystemDnsResolution() && - IsOutOfProcessNetworkService() && - !g_force_create_network_service_directly) { + IsOutOfProcessNetworkService()) { mojo::PendingRemote<network::mojom::SystemDnsResolver> dns_remote; mojo::MakeSelfOwnedReceiver( std::make_unique<content::SystemDnsResolverMojoImpl>(), @@ -545,6 +540,9 @@ .Pass()); } } else { + DCHECK(IsInProcessNetworkService()) + << "If the network service is created directly, the test must not " + "request an out of process network service."; // This should only be reached in unit tests. if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { CreateNetworkServiceOnIOForTesting( @@ -565,8 +563,6 @@ delete g_client; // In case we're recreating the network service. g_client = new NetworkServiceClient(); - // Call SetClient before creating NetworkServiceClient, as the latter - // might make requests to NetworkService that depend on initialization. (*g_network_service_remote)->SetParams(CreateNetworkServiceParams()); g_client->OnNetworkServiceInitialized(g_network_service_remote->get()); @@ -715,6 +711,7 @@ } void ForceCreateNetworkServiceDirectlyForTesting() { + ForceInProcessNetworkService(true); g_force_create_network_service_directly = true; }
diff --git a/content/browser/network_service_instance_impl.h b/content/browser/network_service_instance_impl.h index f58a074..c8e2d260 100644 --- a/content/browser/network_service_instance_impl.h +++ b/content/browser/network_service_instance_impl.h
@@ -17,6 +17,7 @@ // Creates the network::NetworkService object on the IO thread directly instead // of trying to go through the ServiceManager. +// This also calls ForceInProcessNetworkService(). CONTENT_EXPORT void ForceCreateNetworkServiceDirectlyForTesting(); // Resets the interface ptr to the network service.
diff --git a/content/browser/preloading/prefetch/prefetch_service.cc b/content/browser/preloading/prefetch/prefetch_service.cc index 2171fb7..f036e5b 100644 --- a/content/browser/preloading/prefetch/prefetch_service.cc +++ b/content/browser/preloading/prefetch/prefetch_service.cc
@@ -15,6 +15,7 @@ #include "base/metrics/histogram_macros.h" #include "base/ranges/algorithm.h" #include "base/timer/timer.h" +#include "content/browser/browser_context_impl.h" #include "content/browser/preloading/prefetch/prefetch_document_manager.h" #include "content/browser/preloading/prefetch/prefetch_features.h" #include "content/browser/preloading/prefetch/prefetch_network_context.h" @@ -222,6 +223,15 @@ return false; } +BrowserContext* BrowserContextFromFrameTreeNodeId(int frame_tree_node_id) { + WebContents* web_content = + WebContents::FromFrameTreeNodeId(frame_tree_node_id); + if (!web_content) { + return nullptr; + } + return web_content->GetBrowserContext(); +} + } // namespace // static @@ -233,6 +243,27 @@ return std::make_unique<PrefetchService>(browser_context); } +// static +PrefetchService* PrefetchService::GetFromFrameTreeNodeId( + int frame_tree_node_id) { + BrowserContext* browser_context = + BrowserContextFromFrameTreeNodeId(frame_tree_node_id); + if (!browser_context) { + return nullptr; + } + return BrowserContextImpl::From(browser_context)->GetPrefetchService(); +} + +void PrefetchService::SetFromFrameTreeNodeIdForTesting( + int frame_tree_node_id, + std::unique_ptr<PrefetchService> prefetch_service) { + BrowserContext* browser_context = + BrowserContextFromFrameTreeNodeId(frame_tree_node_id); + CHECK(browser_context); + return BrowserContextImpl::From(browser_context) + ->SetPrefetchServiceForTesting(std::move(prefetch_service)); // IN-TEST +} + PrefetchService::PrefetchService(BrowserContext* browser_context) : browser_context_(browser_context), delegate_(GetContentClient()->browser()->CreatePrefetchServiceDelegate( @@ -253,6 +284,10 @@ PrefetchService::~PrefetchService() = default; +PrefetchOriginProber* PrefetchService::GetPrefetchOriginProber() const { + return origin_prober_.get(); +} + void PrefetchService::PrefetchUrl( base::WeakPtr<PrefetchContainer> prefetch_container) { DCHECK(prefetch_container);
diff --git a/content/browser/preloading/prefetch/prefetch_service.h b/content/browser/preloading/prefetch/prefetch_service.h index 07ddd19e9..667350b 100644 --- a/content/browser/preloading/prefetch/prefetch_service.h +++ b/content/browser/preloading/prefetch/prefetch_service.h
@@ -49,6 +49,11 @@ static std::unique_ptr<PrefetchService> CreateIfPossible( BrowserContext* browser_context); + static PrefetchService* GetFromFrameTreeNodeId(int frame_tree_node_id); + static void SetFromFrameTreeNodeIdForTesting( + int frame_tree_node_id, + std::unique_ptr<PrefetchService> prefetch_service); + explicit PrefetchService(BrowserContext* browser_context); virtual ~PrefetchService(); @@ -65,10 +70,7 @@ return prefetch_proxy_configurator_.get(); } - PrefetchOriginProber* GetPrefetchOriginProber() const { - return origin_prober_.get(); - } - + virtual PrefetchOriginProber* GetPrefetchOriginProber() const; virtual void PrefetchUrl(base::WeakPtr<PrefetchContainer> prefetch_container); // Called when a navigation to `url` that will be served by @@ -88,7 +90,8 @@ // Copies any cookies in the isolated network context associated with // |prefetch_container| to the default network context. - void CopyIsolatedCookies(base::WeakPtr<PrefetchContainer> prefetch_container); + virtual void CopyIsolatedCookies( + base::WeakPtr<PrefetchContainer> prefetch_container); // Removes the prefetch with the given |prefetch_container_key| from // |all_prefetches_|.
diff --git a/content/browser/preloading/prefetch/prefetch_url_loader_helper.cc b/content/browser/preloading/prefetch/prefetch_url_loader_helper.cc new file mode 100644 index 0000000..57225dbf --- /dev/null +++ b/content/browser/preloading/prefetch/prefetch_url_loader_helper.cc
@@ -0,0 +1,235 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/browser/preloading/prefetch/prefetch_url_loader_helper.h" + +#include "base/memory/weak_ptr.h" +#include "base/metrics/histogram_macros.h" +#include "base/time/time.h" +#include "content/browser/preloading/prefetch/prefetch_container.h" +#include "content/browser/preloading/prefetch/prefetch_origin_prober.h" +#include "content/browser/preloading/prefetch/prefetch_params.h" +#include "content/browser/preloading/prefetch/prefetch_probe_result.h" +#include "content/browser/preloading/prefetch/prefetch_service.h" +#include "content/browser/preloading/prefetch/prefetch_serving_page_metrics_container.h" +#include "content/browser/renderer_host/frame_tree_node.h" +#include "content/browser/renderer_host/navigation_request.h" +#include "content/public/browser/prefetch_metrics.h" +#include "content/public/browser/web_contents.h" +#include "services/network/public/cpp/resource_request.h" +#include "url/gurl.h" +#include "url/scheme_host_port.h" + +namespace content { +namespace { + +using GetPrefetchCallback = + base::OnceCallback<void(base::WeakPtr<PrefetchContainer>)>; + +PrefetchServingPageMetricsContainer* +PrefetchServingPageMetricsContainerFromFrameTreeNodeId(int frame_tree_node_id) { + FrameTreeNode* frame_tree_node = + FrameTreeNode::GloballyFindByID(frame_tree_node_id); + if (!frame_tree_node || !frame_tree_node->navigation_request()) { + return nullptr; + } + + return PrefetchServingPageMetricsContainer::GetForNavigationHandle( + *frame_tree_node->navigation_request()); +} + +void RecordCookieWaitTime(base::TimeDelta wait_time) { + UMA_HISTOGRAM_CUSTOM_TIMES( + "PrefetchProxy.AfterClick.Mainframe.CookieWaitTime", wait_time, + base::TimeDelta(), base::Seconds(5), 50); +} + +// Gets the relevant |GetPrefetchOriginProber| from |PrefetchService|. +PrefetchOriginProber* GetPrefetchOriginProber(int frame_tree_node_id) { + PrefetchService* prefetch_service = + PrefetchService::GetFromFrameTreeNodeId(frame_tree_node_id); + if (!prefetch_service) { + return nullptr; + } + + return prefetch_service->GetPrefetchOriginProber(); +} + +// Called when all checks below are complete. +void OnComplete(int frame_tree_node_id, + GetPrefetchCallback get_prefetch_callback, + base::WeakPtr<PrefetchContainer> prefetch_container, + PrefetchProbeResult probe_result) { + if (!prefetch_container || + !prefetch_container->IsPrefetchServable(PrefetchCacheableDuration())) { + std::move(get_prefetch_callback).Run(nullptr); + return; + } + + // Delay updating the prefetch with the probe result in case it becomes not + // servable. + if (prefetch_container) { + prefetch_container->OnPrefetchProbeResult(probe_result); + + PrefetchServingPageMetricsContainer* serving_page_metrics_container = + PrefetchServingPageMetricsContainerFromFrameTreeNodeId( + frame_tree_node_id); + if (serving_page_metrics_container) { + serving_page_metrics_container->SetPrefetchStatus( + prefetch_container->GetPrefetchStatus()); + } + } + + std::move(get_prefetch_callback).Run(std::move(prefetch_container)); +} + +// Called when cookie copy is completed (if asynchronously waited). +// `cookie_copy_start_time` is the time when we started waiting for cookies to +// be copied, delaying the navigation. Used to calculate total cookie wait +// time. +void OnCookieCopyComplete(int frame_tree_node_id, + GetPrefetchCallback get_prefetch_callback, + base::WeakPtr<PrefetchContainer> prefetch_container, + PrefetchProbeResult probe_result, + base::TimeTicks cookie_copy_start_time) { + base::TimeDelta wait_time = base::TimeTicks::Now() - cookie_copy_start_time; + DCHECK_GT(wait_time, base::TimeDelta()); + RecordCookieWaitTime(wait_time); + OnComplete(frame_tree_node_id, std::move(get_prefetch_callback), + std::move(prefetch_container), probe_result); +} + +// Starts the cookie copy for next redirect hop of |prefetch_container|. +void StartCookieCopy(int frame_tree_node_id, + base::WeakPtr<PrefetchContainer> prefetch_container) { + PrefetchService* prefetch_service = + PrefetchService::GetFromFrameTreeNodeId(frame_tree_node_id); + if (!prefetch_service) { + return; + } + + prefetch_service->CopyIsolatedCookies(prefetch_container); +} + +// Ensures that the cookies for prefetch are copied from its isolated +// network context to the default network context. +void EnsureCookiesCopiedAndInterceptPrefetchedNavigation( + int frame_tree_node_id, + const network::ResourceRequest& tentative_resource_request, + GetPrefetchCallback get_prefetch_callback, + base::WeakPtr<PrefetchContainer> prefetch_container, + PrefetchProbeResult probe_result) { + if (prefetch_container && + !prefetch_container->HasIsolatedCookieCopyStarted()) { + StartCookieCopy(frame_tree_node_id, prefetch_container); + } + + if (prefetch_container) { + prefetch_container->OnInterceptorCheckCookieCopy(); + } + + if (prefetch_container && + prefetch_container->IsIsolatedCookieCopyInProgress()) { + prefetch_container->SetOnCookieCopyCompleteCallback(base::BindOnce( + &OnCookieCopyComplete, frame_tree_node_id, + std::move(get_prefetch_callback), prefetch_container, probe_result, + /* cookie_copy_start_time */ base::TimeTicks::Now())); + return; + } + + RecordCookieWaitTime(base::TimeDelta()); + + OnComplete(frame_tree_node_id, std::move(get_prefetch_callback), + std::move(prefetch_container), probe_result); +} + +// Called when the `PrefetchOriginProber` check is done (if performed). +// `probe_start_time` is used to calculate probe latency which is +// reported to the tab helper. +void OnProbeComplete(int frame_tree_node_id, + const network::ResourceRequest& tentative_resource_request, + GetPrefetchCallback get_prefetch_callback, + base::WeakPtr<PrefetchContainer> prefetch_container, + base::TimeTicks probe_start_time, + PrefetchProbeResult probe_result) { + PrefetchServingPageMetricsContainer* serving_page_metrics_container = + PrefetchServingPageMetricsContainerFromFrameTreeNodeId( + frame_tree_node_id); + if (serving_page_metrics_container) { + serving_page_metrics_container->SetProbeLatency(base::TimeTicks::Now() - + probe_start_time); + } + + if (PrefetchProbeResultIsSuccess(probe_result)) { + EnsureCookiesCopiedAndInterceptPrefetchedNavigation( + frame_tree_node_id, tentative_resource_request, + std::move(get_prefetch_callback), std::move(prefetch_container), + probe_result); + return; + } + + if (prefetch_container) { + prefetch_container->OnPrefetchProbeResult(probe_result); + + if (serving_page_metrics_container) { + serving_page_metrics_container->SetPrefetchStatus( + prefetch_container->GetPrefetchStatus()); + } + } + + std::move(get_prefetch_callback).Run(nullptr); +} + +} // namespace + +void OnGotPrefetchToServe( + int frame_tree_node_id, + const network::ResourceRequest& tentative_resource_request, + GetPrefetchCallback get_prefetch_callback, + base::WeakPtr<PrefetchContainer> prefetch_container) { + // The |tentative_resource_request.url| might be different from + // |prefetch_container->GetURL()| because of No-Vary-Search non-exact url + // match. +#if DCHECK_IS_ON() + if (prefetch_container) { + GURL::Replacements replacements; + replacements.ClearRef(); + replacements.ClearQuery(); + DCHECK_EQ(tentative_resource_request.url.ReplaceComponents(replacements), + prefetch_container->GetCurrentURLToServe().ReplaceComponents( + replacements)); + } +#endif + + if (!prefetch_container || + !prefetch_container->IsPrefetchServable(PrefetchCacheableDuration()) || + prefetch_container->HaveDefaultContextCookiesChanged( + tentative_resource_request.url)) { + std::move(get_prefetch_callback).Run(nullptr); + return; + } + + PrefetchOriginProber* origin_prober = + GetPrefetchOriginProber(frame_tree_node_id); + if (!origin_prober) { + std::move(get_prefetch_callback).Run(nullptr); + return; + } + if (origin_prober->ShouldProbeOrigins()) { + origin_prober->Probe( + url::SchemeHostPort(tentative_resource_request.url).GetURL(), + base::BindOnce( + &OnProbeComplete, frame_tree_node_id, tentative_resource_request, + std::move(get_prefetch_callback), std::move(prefetch_container), + /* probe_start_time */ base::TimeTicks::Now())); + return; + } + + EnsureCookiesCopiedAndInterceptPrefetchedNavigation( + frame_tree_node_id, tentative_resource_request, + std::move(get_prefetch_callback), std::move(prefetch_container), + PrefetchProbeResult::kNoProbing); +} + +} // namespace content
diff --git a/content/browser/preloading/prefetch/prefetch_url_loader_helper.h b/content/browser/preloading/prefetch/prefetch_url_loader_helper.h new file mode 100644 index 0000000..a24bc53 --- /dev/null +++ b/content/browser/preloading/prefetch/prefetch_url_loader_helper.h
@@ -0,0 +1,27 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_PRELOADING_PREFETCH_PREFETCH_URL_LOADER_HELPER_H_ +#define CONTENT_BROWSER_PRELOADING_PREFETCH_PREFETCH_URL_LOADER_HELPER_H_ + +#include "base/memory/weak_ptr.h" +#include "content/common/content_export.h" +#include "services/network/public/cpp/resource_request.h" + +namespace content { + +class PrefetchContainer; + +// Checks if `prefetch_container` can be used for `tentative_resource_request`, +// and starts checking `PrefetchOriginProber` if needed. +void CONTENT_EXPORT +OnGotPrefetchToServe(int frame_tree_node_id, + const network::ResourceRequest& tentative_resource_request, + base::OnceCallback<void(base::WeakPtr<PrefetchContainer>)> + get_prefetch_callback, + base::WeakPtr<PrefetchContainer> prefetch_container); + +} // namespace content + +#endif // CONTENT_BROWSER_PRELOADING_PREFETCH_PREFETCH_URL_LOADER_HELPER_H_
diff --git a/content/browser/preloading/prefetch/prefetch_url_loader_interceptor.cc b/content/browser/preloading/prefetch/prefetch_url_loader_interceptor.cc index 21ca5a9..bb5bcbb 100644 --- a/content/browser/preloading/prefetch/prefetch_url_loader_interceptor.cc +++ b/content/browser/preloading/prefetch/prefetch_url_loader_interceptor.cc
@@ -7,27 +7,19 @@ #include <memory> #include "base/memory/weak_ptr.h" -#include "base/metrics/histogram_macros.h" -#include "base/time/time.h" #include "content/browser/browser_context_impl.h" #include "content/browser/loader/navigation_loader_interceptor.h" #include "content/browser/preloading/prefetch/prefetch_container.h" #include "content/browser/preloading/prefetch/prefetch_features.h" -#include "content/browser/preloading/prefetch/prefetch_origin_prober.h" -#include "content/browser/preloading/prefetch/prefetch_params.h" -#include "content/browser/preloading/prefetch/prefetch_probe_result.h" #include "content/browser/preloading/prefetch/prefetch_service.h" -#include "content/browser/preloading/prefetch/prefetch_serving_page_metrics_container.h" #include "content/browser/preloading/prefetch/prefetch_streaming_url_loader.h" +#include "content/browser/preloading/prefetch/prefetch_url_loader_helper.h" #include "content/browser/renderer_host/frame_tree_node.h" #include "content/browser/renderer_host/navigation_request.h" -#include "content/public/browser/prefetch_metrics.h" #include "content/public/browser/web_contents.h" #include "services/network/public/cpp/resource_request.h" #include "services/network/public/cpp/single_request_url_loader_factory.h" #include "services/network/public/cpp/wrapper_shared_url_loader_factory.h" -#include "url/gurl.h" -#include "url/scheme_host_port.h" namespace content { namespace { @@ -40,31 +32,6 @@ return web_content->GetBrowserContext(); } -PrefetchService* PrefetchServiceFromFrameTreeNodeId(int frame_tree_node_id) { - BrowserContext* browser_context = - BrowserContextFromFrameTreeNodeId(frame_tree_node_id); - if (!browser_context) - return nullptr; - return BrowserContextImpl::From(browser_context)->GetPrefetchService(); -} - -PrefetchServingPageMetricsContainer* -PrefetchServingPageMetricsContainerFromFrameTreeNodeId(int frame_tree_node_id) { - FrameTreeNode* frame_tree_node = - FrameTreeNode::GloballyFindByID(frame_tree_node_id); - if (!frame_tree_node || !frame_tree_node->navigation_request()) - return nullptr; - - return PrefetchServingPageMetricsContainer::GetForNavigationHandle( - *frame_tree_node->navigation_request()); -} - -void RecordCookieWaitTime(base::TimeDelta wait_time) { - UMA_HISTOGRAM_CUSTOM_TIMES( - "PrefetchProxy.AfterClick.Mainframe.CookieWaitTime", wait_time, - base::TimeDelta(), base::Seconds(5), 50); -} - } // namespace // static @@ -83,7 +50,7 @@ PrefetchURLLoaderInterceptor::~PrefetchURLLoaderInterceptor() = default; void PrefetchURLLoaderInterceptor::MaybeCreateLoader( - const network::ResourceRequest& tenative_resource_request, + const network::ResourceRequest& tentative_resource_request, BrowserContext* browser_context, NavigationLoaderInterceptor::LoaderCallback callback, NavigationLoaderInterceptor::FallbackCallback fallback_callback) { @@ -91,193 +58,51 @@ DCHECK(!loader_callback_); loader_callback_ = std::move(callback); - url_ = tenative_resource_request.url; if (redirect_prefetch_container_ && - redirect_prefetch_container_->DoesCurrentURLToServeMatch(url_)) { - OnGotPrefetchToServe(tenative_resource_request, - redirect_prefetch_container_); + redirect_prefetch_container_->DoesCurrentURLToServeMatch( + tentative_resource_request.url)) { + OnGotPrefetchToServe( + frame_tree_node_id_, tentative_resource_request, + base::BindOnce(&PrefetchURLLoaderInterceptor::OnGetPrefetchComplete, + weak_factory_.GetWeakPtr()), + redirect_prefetch_container_); return; } - GetPrefetch(url_, base::BindOnce( - &PrefetchURLLoaderInterceptor::OnGotPrefetchToServe, - weak_factory_.GetWeakPtr(), tenative_resource_request)); -} - -void PrefetchURLLoaderInterceptor::OnGotPrefetchToServe( - const network::ResourceRequest& tenative_resource_request, - base::WeakPtr<PrefetchContainer> prefetch_container) { - // The |url_| might be different from |prefetch_container->GetURL()| because - // of No-Vary-Search non-exact url match. -#if DCHECK_IS_ON() - if (prefetch_container) { - GURL::Replacements replacements; - replacements.ClearRef(); - replacements.ClearQuery(); - DCHECK_EQ(url_.ReplaceComponents(replacements), - prefetch_container->GetCurrentURLToServe().ReplaceComponents( - replacements)); - } -#endif - - if (!prefetch_container || - !prefetch_container->IsPrefetchServable(PrefetchCacheableDuration()) || - prefetch_container->HaveDefaultContextCookiesChanged(url_)) { - DoNotInterceptNavigation(); - return; - } - - PrefetchOriginProber* origin_prober = GetPrefetchOriginProber(); - if (!origin_prober) { - DoNotInterceptNavigation(); - return; - } - if (origin_prober->ShouldProbeOrigins()) { - probe_start_time_ = base::TimeTicks::Now(); - base::OnceClosure on_success_callback = - base::BindOnce(&PrefetchURLLoaderInterceptor:: - EnsureCookiesCopiedAndInterceptPrefetchedNavigation, - weak_factory_.GetWeakPtr(), tenative_resource_request, - prefetch_container); - - origin_prober->Probe( - url::SchemeHostPort(url_).GetURL(), - base::BindOnce(&PrefetchURLLoaderInterceptor::OnProbeComplete, - weak_factory_.GetWeakPtr(), prefetch_container, - std::move(on_success_callback))); - return; - } - - probe_result_ = PrefetchProbeResult::kNoProbing; - EnsureCookiesCopiedAndInterceptPrefetchedNavigation(tenative_resource_request, - prefetch_container); + GetPrefetch( + tentative_resource_request, + base::BindOnce(&PrefetchURLLoaderInterceptor::OnGetPrefetchComplete, + weak_factory_.GetWeakPtr())); } void PrefetchURLLoaderInterceptor::GetPrefetch( - const GURL& url, + const network::ResourceRequest& tentative_resource_request, base::OnceCallback<void(base::WeakPtr<PrefetchContainer>)> get_prefetch_callback) const { PrefetchService* prefetch_service = - PrefetchServiceFromFrameTreeNodeId(frame_tree_node_id_); + PrefetchService::GetFromFrameTreeNodeId(frame_tree_node_id_); if (!prefetch_service) { std::move(get_prefetch_callback).Run(nullptr); return; } - prefetch_service->GetPrefetchToServe(url, std::move(get_prefetch_callback)); + prefetch_service->GetPrefetchToServe( + tentative_resource_request.url, + base::BindOnce(&OnGotPrefetchToServe, frame_tree_node_id_, + tentative_resource_request, + std::move(get_prefetch_callback))); } -PrefetchOriginProber* PrefetchURLLoaderInterceptor::GetPrefetchOriginProber() - const { - PrefetchService* prefetch_service = - PrefetchServiceFromFrameTreeNodeId(frame_tree_node_id_); - if (!prefetch_service) - return nullptr; - - return prefetch_service->GetPrefetchOriginProber(); -} - -void PrefetchURLLoaderInterceptor::OnProbeComplete( - base::WeakPtr<PrefetchContainer> prefetch_container, - base::OnceClosure on_success_callback, - PrefetchProbeResult result) { - DCHECK(probe_start_time_); - - PrefetchServingPageMetricsContainer* serving_page_metrics_container = - PrefetchServingPageMetricsContainerFromFrameTreeNodeId( - frame_tree_node_id_); - if (serving_page_metrics_container) - serving_page_metrics_container->SetProbeLatency(base::TimeTicks::Now() - - probe_start_time_.value()); - - probe_result_ = result; - - if (PrefetchProbeResultIsSuccess(result)) { - std::move(on_success_callback).Run(); - return; - } - - if (prefetch_container) { - prefetch_container->OnPrefetchProbeResult(probe_result_); - - if (serving_page_metrics_container) { - serving_page_metrics_container->SetPrefetchStatus( - prefetch_container->GetPrefetchStatus()); - } - } - - DoNotInterceptNavigation(); -} - -void PrefetchURLLoaderInterceptor:: - EnsureCookiesCopiedAndInterceptPrefetchedNavigation( - const network::ResourceRequest& tenative_resource_request, - base::WeakPtr<PrefetchContainer> prefetch_container) { - if (!prefetch_container->HasIsolatedCookieCopyStarted()) { - StartCookieCopy(prefetch_container); - } - - if (prefetch_container) { - prefetch_container->OnInterceptorCheckCookieCopy(); - } - - if (prefetch_container && - prefetch_container->IsIsolatedCookieCopyInProgress()) { - cookie_copy_start_time_ = base::TimeTicks::Now(); - prefetch_container->SetOnCookieCopyCompleteCallback(base::BindOnce( - &PrefetchURLLoaderInterceptor::InterceptPrefetchedNavigation, - weak_factory_.GetWeakPtr(), tenative_resource_request, - prefetch_container)); - return; - } - - RecordCookieWaitTime(base::TimeDelta()); - - InterceptPrefetchedNavigation(tenative_resource_request, prefetch_container); -} - -void PrefetchURLLoaderInterceptor::StartCookieCopy( +void PrefetchURLLoaderInterceptor::OnGetPrefetchComplete( base::WeakPtr<PrefetchContainer> prefetch_container) { - PrefetchService* prefetch_service = - PrefetchServiceFromFrameTreeNodeId(frame_tree_node_id_); - if (!prefetch_service) { + if (!prefetch_container) { + // Do not intercept the request. + redirect_prefetch_container_ = nullptr; + std::move(loader_callback_).Run({}); return; } - prefetch_service->CopyIsolatedCookies(prefetch_container); -} - -void PrefetchURLLoaderInterceptor::InterceptPrefetchedNavigation( - const network::ResourceRequest& tenative_resource_request, - base::WeakPtr<PrefetchContainer> prefetch_container) { - if (cookie_copy_start_time_) { - base::TimeDelta wait_time = - base::TimeTicks::Now() - cookie_copy_start_time_.value(); - DCHECK_GT(wait_time, base::TimeDelta()); - RecordCookieWaitTime(wait_time); - } - - if (!prefetch_container || - !prefetch_container->IsPrefetchServable(PrefetchCacheableDuration())) { - DoNotInterceptNavigation(); - return; - } - - // Delay updating the prefetch with the probe result in case it becomes not - // servable. - if (prefetch_container) { - prefetch_container->OnPrefetchProbeResult(probe_result_); - - PrefetchServingPageMetricsContainer* serving_page_metrics_container = - PrefetchServingPageMetricsContainerFromFrameTreeNodeId( - frame_tree_node_id_); - if (serving_page_metrics_container) { - serving_page_metrics_container->SetPrefetchStatus( - prefetch_container->GetPrefetchStatus()); - } - } - // Set up a URL loader factory to "create" the streaming URL loader from the // prefetch. After this point, the streaming URL loader will manager its own // lifetime, and will delete itself once the prefetch response is completed @@ -339,9 +164,4 @@ std::move(pending_remote)))); } -void PrefetchURLLoaderInterceptor::DoNotInterceptNavigation() { - redirect_prefetch_container_ = nullptr; - std::move(loader_callback_).Run({}); -} - } // namespace content
diff --git a/content/browser/preloading/prefetch/prefetch_url_loader_interceptor.h b/content/browser/preloading/prefetch/prefetch_url_loader_interceptor.h index 8f11921..bac8a66 100644 --- a/content/browser/preloading/prefetch/prefetch_url_loader_interceptor.h +++ b/content/browser/preloading/prefetch/prefetch_url_loader_interceptor.h
@@ -9,19 +9,14 @@ #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" -#include "base/time/time.h" #include "content/browser/loader/navigation_loader_interceptor.h" -#include "content/browser/preloading/prefetch/prefetch_probe_result.h" #include "content/common/content_export.h" -#include "content/public/browser/global_routing_id.h" #include "services/network/public/cpp/resource_request.h" -#include "url/gurl.h" namespace content { class BrowserContext; class PrefetchContainer; -class PrefetchOriginProber; // Intercepts navigations that can use prefetched resources. class CONTENT_EXPORT PrefetchURLLoaderInterceptor @@ -39,70 +34,37 @@ // NavigationLoaderInterceptor void MaybeCreateLoader( - const network::ResourceRequest& tenative_resource_request, + const network::ResourceRequest& tentative_resource_request, BrowserContext* browser_context, NavigationLoaderInterceptor::LoaderCallback callback, NavigationLoaderInterceptor::FallbackCallback fallback_callback) override; + protected: + int GetFrameTreeNodeId() const { return frame_tree_node_id_; } + private: - // Gets the prefetch associated with |url| from |PrefetchService|. The - // |get_prefetch_callback| is called with this associated prefetch. + // Gets the `PrefetchContainer` (if any) to be used for + // `tentative_resource_request`. The `PrefetchContainer` is first obtained + // from `PrefetchService` and then goes through other checks in + // `PrefetchUrlLoaderHelper`. + // The |get_prefetch_callback| is called with this associated prefetch. + // Declared virtual only for testing. virtual void GetPrefetch( - const GURL& url, + const network::ResourceRequest& tentative_resource_request, base::OnceCallback<void(base::WeakPtr<PrefetchContainer>)> get_prefetch_callback) const; - // Gets the relevant |GetPrefetchOriginProber| from |PrefetchService|. - virtual PrefetchOriginProber* GetPrefetchOriginProber() const; - - // Checks the prefetch retrieved via |GetPrefetch| to see if it can be used - // for |tenative_resource_request|. - void OnGotPrefetchToServe( - const network::ResourceRequest& tenative_resource_request, + void OnGetPrefetchComplete( base::WeakPtr<PrefetchContainer> prefetch_container); - void OnProbeComplete(base::WeakPtr<PrefetchContainer> prefetch_container, - base::OnceClosure on_success_callback, - PrefetchProbeResult result); - - // Ensures that the cookies for prefetch are copied from its isolated network - // context to the default network context before calling - // |InterceptPrefetchedNavigation|. - void EnsureCookiesCopiedAndInterceptPrefetchedNavigation( - const network::ResourceRequest& tenative_resource_request, - base::WeakPtr<PrefetchContainer> prefetch_container); - - // Starts the cookie copy for next redirect hop of |prefetch_container|. - virtual void StartCookieCopy( - base::WeakPtr<PrefetchContainer> prefetch_container); - - void InterceptPrefetchedNavigation( - const network::ResourceRequest& tenative_resource_request, - base::WeakPtr<PrefetchContainer> prefetch_container); - void DoNotInterceptNavigation(); - // The frame tree node |this| is associated with, used to retrieve // |PrefetchService|. const int frame_tree_node_id_; - // The URL being navigated to. - GURL url_; - // Called once |this| has decided whether to intercept or not intercept the // navigation. NavigationLoaderInterceptor::LoaderCallback loader_callback_; - // The time when probing was started. Used to calculate probe latency which is - // reported to the tab helper. - absl::optional<base::TimeTicks> probe_start_time_; - - // Result of the most recent probe. - PrefetchProbeResult probe_result_{PrefetchProbeResult::kNoProbing}; - - // The time when we started waiting for cookies to be copied, delaying the - // navigation. Used to calculate total cookie wait time. - absl::optional<base::TimeTicks> cookie_copy_start_time_; - // The prefetch container that has already been used to serve a redirect. If // another request can be intercepted, this will be checked first to see if // its next redirect hop matches the request URL.
diff --git a/content/browser/preloading/prefetch/prefetch_url_loader_interceptor_unittest.cc b/content/browser/preloading/prefetch/prefetch_url_loader_interceptor_unittest.cc index 5a51b84..5c35830 100644 --- a/content/browser/preloading/prefetch/prefetch_url_loader_interceptor_unittest.cc +++ b/content/browser/preloading/prefetch/prefetch_url_loader_interceptor_unittest.cc
@@ -18,9 +18,11 @@ #include "content/browser/preloading/prefetch/prefetch_origin_prober.h" #include "content/browser/preloading/prefetch/prefetch_params.h" #include "content/browser/preloading/prefetch/prefetch_probe_result.h" +#include "content/browser/preloading/prefetch/prefetch_service.h" #include "content/browser/preloading/prefetch/prefetch_streaming_url_loader.h" #include "content/browser/preloading/prefetch/prefetch_test_utils.h" #include "content/browser/preloading/prefetch/prefetch_type.h" +#include "content/browser/preloading/prefetch/prefetch_url_loader_helper.h" #include "content/browser/preloading/preloading.h" #include "content/browser/preloading/preloading_data_impl.h" #include "content/browser/renderer_host/frame_tree_node.h" @@ -134,19 +136,14 @@ raw_ptr<ContentBrowserClient> old_browser_client_; }; -class TestPrefetchURLLoaderInterceptor : public PrefetchURLLoaderInterceptor { +class TestPrefetchService : public PrefetchService { public: - explicit TestPrefetchURLLoaderInterceptor(int frame_tree_node_id) - : PrefetchURLLoaderInterceptor(frame_tree_node_id) {} - ~TestPrefetchURLLoaderInterceptor() override = default; - - void AddPrefetch(base::WeakPtr<PrefetchContainer> prefetch_container) { - prefetches_[prefetch_container->GetURL()] = prefetch_container; - } + explicit TestPrefetchService(BrowserContext* browser_context) + : PrefetchService(browser_context) {} void TakePrefetchOriginProber( - std::unique_ptr<TestPrefetchOriginProber> origin_prober) { - origin_prober_ = std::move(origin_prober); + std::unique_ptr<TestPrefetchOriginProber> test_origin_prober) { + test_origin_prober_ = std::move(test_origin_prober); } void AddOnStartCookieCopyClosure(const GURL& prefetch_url, @@ -159,26 +156,14 @@ on_start_cookie_copy_closure_[key] = std::move(closure); } - int num_probes() const { return origin_prober_->num_probes(); } + int num_probes() const { return test_origin_prober_->num_probes(); } private: - void GetPrefetch(const GURL& url, - base::OnceCallback<void(base::WeakPtr<PrefetchContainer>)> - get_prefetch_callback) const override { - const auto& iter = prefetches_.find(url); - if (iter == prefetches_.end()) { - std::move(get_prefetch_callback).Run(nullptr); - return; - } - std::move(get_prefetch_callback).Run(iter->second); - } - PrefetchOriginProber* GetPrefetchOriginProber() const override { - EXPECT_TRUE(origin_prober_); - return origin_prober_.get(); + return test_origin_prober_.get(); } - void StartCookieCopy( + void CopyIsolatedCookies( base::WeakPtr<PrefetchContainer> prefetch_container) override { if (!prefetch_container->GetPrefetchType() .IsIsolatedNetworkContextRequired()) { @@ -195,13 +180,39 @@ std::move(itr->second).Run(); } - std::map<GURL, base::WeakPtr<PrefetchContainer>> prefetches_; - std::unique_ptr<TestPrefetchOriginProber> origin_prober_; + std::unique_ptr<TestPrefetchOriginProber> test_origin_prober_; std::map<std::pair<GURL, GURL>, base::OnceClosure> on_start_cookie_copy_closure_; }; +class TestPrefetchURLLoaderInterceptor : public PrefetchURLLoaderInterceptor { + public: + explicit TestPrefetchURLLoaderInterceptor(int frame_tree_node_id) + : PrefetchURLLoaderInterceptor(frame_tree_node_id) {} + ~TestPrefetchURLLoaderInterceptor() override = default; + + void AddPrefetch(base::WeakPtr<PrefetchContainer> prefetch_container) { + prefetches_[prefetch_container->GetURL()] = prefetch_container; + } + + private: + void GetPrefetch(const network::ResourceRequest& tentative_resource_request, + base::OnceCallback<void(base::WeakPtr<PrefetchContainer>)> + get_prefetch_callback) const override { + const auto& iter = prefetches_.find(tentative_resource_request.url); + if (iter == prefetches_.end()) { + std::move(get_prefetch_callback).Run(nullptr); + return; + } + + OnGotPrefetchToServe(GetFrameTreeNodeId(), tentative_resource_request, + std::move(get_prefetch_callback), iter->second); + } + + std::map<GURL, base::WeakPtr<PrefetchContainer>> prefetches_; +}; + class PrefetchURLLoaderInterceptorTest : public RenderViewHostTestHarness { public: PrefetchURLLoaderInterceptorTest() @@ -214,6 +225,13 @@ test_content_browser_client_ = std::make_unique<ScopedMockContentBrowserClient>(); + std::unique_ptr<TestPrefetchService> prefetch_service = + std::make_unique<TestPrefetchService>(browser_context()); + + PrefetchService::SetFromFrameTreeNodeIdForTesting( + web_contents()->GetPrimaryMainFrame()->GetFrameTreeNodeId(), + std::move(prefetch_service)); + browser_context() ->GetDefaultStoragePartition() ->GetNetworkContext() @@ -241,6 +259,12 @@ RenderViewHostTestHarness::TearDown(); } + TestPrefetchService* GetPrefetchService() { + return static_cast<TestPrefetchService*>( + PrefetchService::GetFromFrameTreeNodeId( + web_contents()->GetPrimaryMainFrame()->GetFrameTreeNodeId())); + } + TestPrefetchURLLoaderInterceptor* interceptor() { return interceptor_.get(); } void WaitForCallback(const GURL& url) { @@ -426,7 +450,7 @@ interceptor()->AddPrefetch(prefetch_container->GetWeakPtr()); - interceptor()->TakePrefetchOriginProber( + GetPrefetchService()->TakePrefetchOriginProber( std::make_unique<TestPrefetchOriginProber>( browser_context(), /*should_probe_origins_response=*/false, kTestUrl, PrefetchProbeResult::kNoProbing)); @@ -451,7 +475,7 @@ "PrefetchProxy.AfterClick.Mainframe.CookieWaitTime", base::TimeDelta(), 1); - EXPECT_EQ(interceptor()->num_probes(), 0); + EXPECT_EQ(GetPrefetchService()->num_probes(), 0); EXPECT_EQ(prefetch_container->GetPrefetchStatus(), PrefetchStatus::kPrefetchResponseUsed); ExpectCorrectUkmLogs(kTestUrl, /*is_accurate_trigger=*/true, @@ -499,7 +523,7 @@ interceptor()->AddPrefetch(prefetch_container->GetWeakPtr()); - interceptor()->TakePrefetchOriginProber( + GetPrefetchService()->TakePrefetchOriginProber( std::make_unique<TestPrefetchOriginProber>( browser_context(), /*should_probe_origins_response=*/false, kTestUrl, PrefetchProbeResult::kNoProbing)); @@ -532,7 +556,7 @@ "PrefetchProxy.AfterClick.Mainframe.CookieWaitTime", base::Milliseconds(20), 1); - EXPECT_EQ(interceptor()->num_probes(), 0); + EXPECT_EQ(GetPrefetchService()->num_probes(), 0); ExpectCorrectUkmLogs(kTestUrl, /*is_accurate_trigger=*/true, PreloadingTriggeringOutcome::kSuccess); } @@ -575,7 +599,7 @@ interceptor()->AddPrefetch(prefetch_container->GetWeakPtr()); - interceptor()->TakePrefetchOriginProber( + GetPrefetchService()->TakePrefetchOriginProber( std::make_unique<TestPrefetchOriginProber>( browser_context(), /*should_probe_origins_response=*/false, kTestUrl, PrefetchProbeResult::kNoProbing)); @@ -600,7 +624,7 @@ "PrefetchProxy.AfterClick.Mainframe.CookieWaitTime", base::TimeDelta(), 1); - EXPECT_EQ(interceptor()->num_probes(), 0); + EXPECT_EQ(GetPrefetchService()->num_probes(), 0); ExpectCorrectUkmLogs(kTestUrl, /*is_accurate_trigger=*/true, PreloadingTriggeringOutcome::kSuccess); } @@ -612,7 +636,7 @@ EXPECT_CALL(*test_content_browser_client(), WillCreateURLLoaderFactory) .Times(0); - interceptor()->TakePrefetchOriginProber( + GetPrefetchService()->TakePrefetchOriginProber( std::make_unique<TestPrefetchOriginProber>( browser_context(), /*should_probe_origins_response=*/false, kTestUrl, PrefetchProbeResult::kNoProbing)); @@ -638,7 +662,7 @@ histogram_tester().ExpectTotalCount( "PrefetchProxy.AfterClick.Mainframe.CookieWaitTime", 0); - EXPECT_EQ(interceptor()->num_probes(), 0); + EXPECT_EQ(GetPrefetchService()->num_probes(), 0); auto actual = test_ukm_recorder()->GetEntries( ukm::builders::Preloading_Attempt::kEntryName, @@ -665,7 +689,7 @@ interceptor()->AddPrefetch(prefetch_container->GetWeakPtr()); - interceptor()->TakePrefetchOriginProber( + GetPrefetchService()->TakePrefetchOriginProber( std::make_unique<TestPrefetchOriginProber>( browser_context(), /*should_probe_origins_response=*/false, kTestUrl, PrefetchProbeResult::kNoProbing)); @@ -691,7 +715,7 @@ histogram_tester().ExpectTotalCount( "PrefetchProxy.AfterClick.Mainframe.CookieWaitTime", 0); - EXPECT_EQ(interceptor()->num_probes(), 0); + EXPECT_EQ(GetPrefetchService()->num_probes(), 0); ExpectCorrectUkmLogs(GURL("http://Not.Accurate.Trigger/"), /*is_accurate_trigger=*/false, PreloadingTriggeringOutcome::kReady); @@ -722,7 +746,7 @@ interceptor()->AddPrefetch(prefetch_container->GetWeakPtr()); - interceptor()->TakePrefetchOriginProber( + GetPrefetchService()->TakePrefetchOriginProber( std::make_unique<TestPrefetchOriginProber>( browser_context(), /*should_probe_origins_response=*/false, kTestUrl, PrefetchProbeResult::kNoProbing)); @@ -746,7 +770,7 @@ histogram_tester().ExpectTotalCount( "PrefetchProxy.AfterClick.Mainframe.CookieWaitTime", 0); - EXPECT_EQ(interceptor()->num_probes(), 0); + EXPECT_EQ(GetPrefetchService()->num_probes(), 0); ExpectCorrectUkmLogs(GURL("http://Not.Accurate.Trigger/"), /*is_accurate_trigger=*/false, PreloadingTriggeringOutcome::kReady); @@ -779,7 +803,7 @@ interceptor()->AddPrefetch(prefetch_container->GetWeakPtr()); - interceptor()->TakePrefetchOriginProber( + GetPrefetchService()->TakePrefetchOriginProber( std::make_unique<TestPrefetchOriginProber>( browser_context(), /*should_probe_origins_response=*/false, kTestUrl, PrefetchProbeResult::kNoProbing)); @@ -803,7 +827,7 @@ histogram_tester().ExpectTotalCount( "PrefetchProxy.AfterClick.Mainframe.CookieWaitTime", 0); - EXPECT_EQ(interceptor()->num_probes(), 0); + EXPECT_EQ(GetPrefetchService()->num_probes(), 0); ExpectCorrectUkmLogs(GURL("http://Not.Accurate.Trigger/"), /*is_accurate_trigger=*/false, PreloadingTriggeringOutcome::kReady); @@ -849,7 +873,7 @@ // Set up |TestPrefetchOriginProber| to require a probe and simulate a // successful probe. - interceptor()->TakePrefetchOriginProber( + GetPrefetchService()->TakePrefetchOriginProber( std::make_unique<TestPrefetchOriginProber>( browser_context(), /*should_probe_origins_response=*/true, kTestUrl, PrefetchProbeResult::kDNSProbeSuccess)); @@ -870,7 +894,7 @@ EXPECT_TRUE(was_intercepted(kTestUrl).has_value()); EXPECT_TRUE(was_intercepted(kTestUrl).value()); - EXPECT_EQ(interceptor()->num_probes(), 1); + EXPECT_EQ(GetPrefetchService()->num_probes(), 1); ExpectCorrectUkmLogs(kTestUrl, /*is_accurate_trigger=*/true, PreloadingTriggeringOutcome::kSuccess); } @@ -901,7 +925,7 @@ // Set up |TestPrefetchOriginProber| to require a probe and simulate a // unsuccessful probe. - interceptor()->TakePrefetchOriginProber( + GetPrefetchService()->TakePrefetchOriginProber( std::make_unique<TestPrefetchOriginProber>( browser_context(), /*should_probe_origins_response=*/true, kTestUrl, PrefetchProbeResult::kDNSProbeFailure)); @@ -922,7 +946,7 @@ EXPECT_TRUE(was_intercepted(kTestUrl).has_value()); EXPECT_FALSE(was_intercepted(kTestUrl).value()); - EXPECT_EQ(interceptor()->num_probes(), 1); + EXPECT_EQ(GetPrefetchService()->num_probes(), 1); ExpectCorrectUkmLogs(GURL("http://Not.Accurate.Trigger/"), /*is_accurate_trigger=*/false, PreloadingTriggeringOutcome::kReady); @@ -957,7 +981,7 @@ interceptor()->AddPrefetch(prefetch_container->GetWeakPtr()); - interceptor()->TakePrefetchOriginProber( + GetPrefetchService()->TakePrefetchOriginProber( std::make_unique<TestPrefetchOriginProber>( browser_context(), /*should_probe_origins_response=*/false, kTestUrl, PrefetchProbeResult::kNoProbing)); @@ -994,7 +1018,7 @@ "PrefetchProxy.AfterClick.Mainframe.CookieWaitTime", base::Milliseconds(20), 1); - EXPECT_EQ(interceptor()->num_probes(), 0); + EXPECT_EQ(GetPrefetchService()->num_probes(), 0); ExpectCorrectUkmLogs(kTestUrl, /*is_accurate_trigger=*/true, PreloadingTriggeringOutcome::kReady); } @@ -1043,7 +1067,7 @@ interceptor()->AddPrefetch(prefetch_container->GetWeakPtr()); - interceptor()->TakePrefetchOriginProber( + GetPrefetchService()->TakePrefetchOriginProber( std::make_unique<TestPrefetchOriginProber>( browser_context(), /*should_probe_origins_response=*/false, kTestUrl, PrefetchProbeResult::kNoProbing)); @@ -1066,7 +1090,7 @@ EXPECT_FALSE(was_intercepted(kRedirectUrl).has_value()); base::RunLoop on_start_cookie_copy_run_loop; - interceptor()->AddOnStartCookieCopyClosure( + GetPrefetchService()->AddOnStartCookieCopyClosure( kTestUrl, kRedirectUrl, on_start_cookie_copy_run_loop.QuitClosure()); network::ResourceRequest request2; @@ -1100,7 +1124,7 @@ "PrefetchProxy.AfterClick.Mainframe.CookieWaitTime", base::Milliseconds(20), 1); - EXPECT_EQ(interceptor()->num_probes(), 0); + EXPECT_EQ(GetPrefetchService()->num_probes(), 0); EXPECT_EQ(prefetch_container->GetPrefetchStatus(), PrefetchStatus::kPrefetchResponseUsed); ExpectCorrectUkmLogs(kTestUrl, /*is_accurate_trigger=*/true,
diff --git a/content/browser/preloading/prerender/prerender_browsertest.cc b/content/browser/preloading/prerender/prerender_browsertest.cc index 81f82083..788969a 100644 --- a/content/browser/preloading/prerender/prerender_browsertest.cc +++ b/content/browser/preloading/prerender/prerender_browsertest.cc
@@ -2133,7 +2133,7 @@ RenderFrameHost* same_origin_render_frame_host = FindRenderFrameHost( prerender_frame_host->GetPage(), kSameOriginSubframeUrl); - DCHECK(same_origin_render_frame_host); + CHECK(same_origin_render_frame_host); EXPECT_EQ(true, EvalJs(same_origin_render_frame_host, kInitialDocumentPrerenderingScript)); EXPECT_EQ(false, EvalJs(same_origin_render_frame_host, @@ -2144,7 +2144,7 @@ RenderFrameHost* cross_origin_render_frame_host = FindRenderFrameHost( prerender_frame_host->GetPage(), kCrossOriginSubframeUrl); - DCHECK(cross_origin_render_frame_host); + CHECK(cross_origin_render_frame_host); EXPECT_EQ(false, EvalJs(cross_origin_render_frame_host, kInitialDocumentPrerenderingScript)); EXPECT_EQ(false, EvalJs(cross_origin_render_frame_host, @@ -2213,7 +2213,7 @@ RenderFrameHost* cross_origin_render_frame_host = FindRenderFrameHost( prerender_frame_host->GetPage(), kCrossOriginSubframeUrl); - DCHECK(cross_origin_render_frame_host); + CHECK(cross_origin_render_frame_host); EXPECT_EQ(false, EvalJs(cross_origin_render_frame_host, kInitialDocumentPrerenderingScript)); EXPECT_EQ(false, EvalJs(cross_origin_render_frame_host, @@ -2914,7 +2914,7 @@ auto throttle_ptr = std::make_unique<TestNavigationThrottle>(handle); - DCHECK(!throttle); + CHECK(!throttle); throttle = throttle_ptr.get(); throttle_ptr->SetResponse( TestNavigationThrottle::WILL_START_REQUEST, @@ -8658,7 +8658,7 @@ // Make a prerendered page. int host_id = AddPrerender(kPrerenderingUrl); auto* prerendered_rfh = GetPrerenderedMainFrameHost(host_id); - DCHECK(prerendered_rfh); + CHECK(prerendered_rfh); EXPECT_TRUE(AddTestUtilJS(prerendered_rfh)); test::PrerenderHostObserver host_observer(*web_contents(), host_id); @@ -9086,7 +9086,7 @@ // Start prerendering. int host_id = AddPrerender(kPrerenderingUrl); RenderFrameHost* prerender_rfh = GetPrerenderedMainFrameHost(host_id); - DCHECK(prerender_rfh); + CHECK(prerender_rfh); AddTestUtilJS(prerender_rfh); // Add subframe in prerendering page. @@ -9126,8 +9126,8 @@ web_contents(), base::BindLambdaForTesting([](NavigationHandle* navigation_handle) { EXPECT_TRUE(navigation_handle->IsInPrimaryMainFrame()); - DCHECK_EQ(navigation_handle->GetNavigatingFrameType(), - FrameType::kPrimaryMainFrame); + CHECK_EQ(navigation_handle->GetNavigatingFrameType(), + FrameType::kPrimaryMainFrame); })); // Navigate to an initial page. ASSERT_TRUE(NavigateToURL(shell(), kInitialUrl)); @@ -9139,8 +9139,8 @@ web_contents(), base::BindLambdaForTesting([](NavigationHandle* navigation_handle) { EXPECT_TRUE(navigation_handle->IsInPrerenderedMainFrame()); - DCHECK_EQ(navigation_handle->GetNavigatingFrameType(), - FrameType::kPrerenderMainFrame); + CHECK_EQ(navigation_handle->GetNavigatingFrameType(), + FrameType::kPrerenderMainFrame); })); // Start prerendering. AddPrerender(kPrerenderingUrl); @@ -9152,8 +9152,8 @@ base::BindLambdaForTesting([](NavigationHandle* navigation_handle) { EXPECT_TRUE(navigation_handle->IsInPrimaryMainFrame()); EXPECT_TRUE(navigation_handle->IsPrerenderedPageActivation()); - DCHECK_EQ(navigation_handle->GetNavigatingFrameType(), - FrameType::kPrimaryMainFrame); + CHECK_EQ(navigation_handle->GetNavigatingFrameType(), + FrameType::kPrimaryMainFrame); })); NavigatePrimaryPage(kPrerenderingUrl); }
diff --git a/content/browser/preloading/prerender/prerender_commit_deferring_condition.cc b/content/browser/preloading/prerender/prerender_commit_deferring_condition.cc index 0c068282..2982f063 100644 --- a/content/browser/preloading/prerender/prerender_commit_deferring_condition.cc +++ b/content/browser/preloading/prerender/prerender_commit_deferring_condition.cc
@@ -51,8 +51,8 @@ WebContentsObserver(navigation_request.GetWebContents()), candidate_prerender_frame_tree_node_id_( candidate_prerender_frame_tree_node_id) { - DCHECK_NE(candidate_prerender_frame_tree_node_id_, - RenderFrameHost::kNoFrameTreeNodeId); + CHECK_NE(candidate_prerender_frame_tree_node_id_, + RenderFrameHost::kNoFrameTreeNodeId); } CommitDeferringCondition::Result
diff --git a/content/browser/preloading/prerender/prerender_handle_impl.cc b/content/browser/preloading/prerender/prerender_handle_impl.cc index 24f9454..695abba 100644 --- a/content/browser/preloading/prerender/prerender_handle_impl.cc +++ b/content/browser/preloading/prerender/prerender_handle_impl.cc
@@ -18,13 +18,13 @@ : prerender_host_registry_(std::move(prerender_host_registry)), frame_tree_node_id_(frame_tree_node_id), prerendering_url_(prerendering_url) { - DCHECK(!prerendering_url_.is_empty()); + CHECK(!prerendering_url_.is_empty()); // PrerenderHandleImpl is now designed only for embedder triggers. If you use // this handle for other triggers, please make sure to update the logging etc. auto* prerender_host = prerender_host_registry_->FindNonReservedHostById(frame_tree_node_id); - DCHECK(prerender_host); - DCHECK_EQ(prerender_host->trigger_type(), PrerenderTriggerType::kEmbedder); + CHECK(prerender_host); + CHECK_EQ(prerender_host->trigger_type(), PrerenderTriggerType::kEmbedder); } PrerenderHandleImpl::~PrerenderHandleImpl() {
diff --git a/content/browser/preloading/prerender/prerender_host.cc b/content/browser/preloading/prerender/prerender_host.cc index 844f08b4..67ea03d 100644 --- a/content/browser/preloading/prerender/prerender_host.cc +++ b/content/browser/preloading/prerender/prerender_host.cc
@@ -109,7 +109,7 @@ WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(WebContentsImpl::FromRenderFrameHost( frame_tree_node.current_frame_host())); - DCHECK(web_contents); + CHECK(web_contents); PrerenderHostRegistry* prerender_registry = web_contents->GetPrerenderHostRegistry(); int prerender_host_id = @@ -148,21 +148,21 @@ // the other hand, renderer-initiated prerendering should have valid initiator // information. if (attributes.IsBrowserInitiated()) { - DCHECK(!attributes.initiator_origin.has_value()); - DCHECK(!attributes.initiator_frame_token.has_value()); - DCHECK_EQ(attributes.initiator_process_id, - ChildProcessHost::kInvalidUniqueID); - DCHECK_EQ(attributes.initiator_ukm_id, ukm::kInvalidSourceId); - DCHECK_EQ(attributes.initiator_frame_tree_node_id, - RenderFrameHost::kNoFrameTreeNodeId); + CHECK(!attributes.initiator_origin.has_value()); + CHECK(!attributes.initiator_frame_token.has_value()); + CHECK_EQ(attributes.initiator_process_id, + ChildProcessHost::kInvalidUniqueID); + CHECK_EQ(attributes.initiator_ukm_id, ukm::kInvalidSourceId); + CHECK_EQ(attributes.initiator_frame_tree_node_id, + RenderFrameHost::kNoFrameTreeNodeId); } else { - DCHECK(attributes.initiator_origin.has_value()); - DCHECK(attributes.initiator_frame_token.has_value()); - DCHECK_NE(attributes.initiator_process_id, - ChildProcessHost::kInvalidUniqueID); - DCHECK_NE(attributes.initiator_ukm_id, ukm::kInvalidSourceId); - DCHECK_NE(attributes.initiator_frame_tree_node_id, - RenderFrameHost::kNoFrameTreeNodeId); + CHECK(attributes.initiator_origin.has_value()); + CHECK(attributes.initiator_frame_token.has_value()); + CHECK_NE(attributes.initiator_process_id, + ChildProcessHost::kInvalidUniqueID); + CHECK_NE(attributes.initiator_ukm_id, ukm::kInvalidSourceId); + CHECK_NE(attributes.initiator_frame_tree_node_id, + RenderFrameHost::kNoFrameTreeNodeId); } // When `kPrerender2SequentialPrerendering` feature is enabled, the prerender @@ -243,7 +243,7 @@ SiteInstanceGroup* source) { // `node` can only become focused when `node`'s current RenderFrameHost is // active. - NOTREACHED(); + NOTREACHED_NORETURN(); } int PrerenderHost::GetOuterDelegateFrameTreeNodeId() { @@ -323,10 +323,10 @@ if (initial_navigation_id_.has_value()) { // In usual code path, `initial_navigation_id_` should be set by // PrerenderNavigationThrottle during `LoadURLWithParams` above. - DCHECK_EQ(*initial_navigation_id_, - created_navigation_handle->GetNavigationId()); - DCHECK(begin_params_); - DCHECK(common_params_); + CHECK_EQ(*initial_navigation_id_, + created_navigation_handle->GetNavigationId()); + CHECK(begin_params_); + CHECK(common_params_); } else { // In some exceptional code path, such as the navigation failed due to CSP // violations, PrerenderNavigationThrottle didn't run at this point. So, @@ -342,17 +342,17 @@ // The initial navigation in the prerender frame tree should not wait for // `beforeunload` in the old page, so BeginNavigation stage should be reached // synchronously. - DCHECK_GE(navigation_request->state(), - NavigationRequest::WAITING_FOR_RENDERER_RESPONSE); + CHECK_GE(navigation_request->state(), + NavigationRequest::WAITING_FOR_RENDERER_RESPONSE); return true; } void PrerenderHost::DidStartNavigation(NavigationHandle* navigation_handle) { - DCHECK(base::FeatureList::IsEnabled( + CHECK(base::FeatureList::IsEnabled( blink::features::kPrerender2MainFrameNavigation)); auto* navigation_request = NavigationRequest::From(navigation_handle); - DCHECK(navigation_request->IsInPrerenderedMainFrame()); + CHECK(navigation_request->IsInPrerenderedMainFrame()); // Do nothing for the initial navigation. if (GetInitialNavigationId() == navigation_request->GetNavigationId()) { @@ -360,7 +360,7 @@ } // Reset `is_ready_for_activation_` since it can be set to true more than once - // and DCHECK will fail when the main frame navigation happens in a + // and CHECK will fail when the main frame navigation happens in a // prerendered page and PrerenderHost::DidFinishNavigation is called multiple // times. is_ready_for_activation_ = false; @@ -370,8 +370,8 @@ auto* navigation_request = NavigationRequest::From(navigation_handle); // Observe navigation only in the prerendering frame tree. - DCHECK_EQ(&(navigation_request->frame_tree_node()->frame_tree()), - frame_tree_.get()); + CHECK_EQ(&(navigation_request->frame_tree_node()->frame_tree()), + frame_tree_.get()); const bool is_prerender_main_frame = navigation_request->GetFrameTreeNodeId() == frame_tree_node_id_; @@ -402,7 +402,7 @@ // main frame navigation reaches DidFinishNavigation and the prerender host // has not been canceled yet. if (is_prerender_main_frame && !final_status_) { - DCHECK(!is_ready_for_activation_); + CHECK(!is_ready_for_activation_); is_ready_for_activation_ = true; // Prerender is ready to activate. Set the status to kReady. @@ -592,16 +592,16 @@ // As the initial prerender navigation is a) limited to HTTP(s) URLs and b) // initiated by the PrerenderHost, we do not expect some navigation parameters - // connected to certain navigation types to be set and the DCHECKS below + // connected to certain navigation types to be set and the CHECKS below // enforce that. // The parameters of the potential activation, however, are coming from the // renderer and we mostly don't have any guarantees what they are, so we - // should not DCHECK them. Instead, by default we compare them with initial + // should not CHECK them. Instead, by default we compare them with initial // prerender activation parameters and fail to activate when they differ. // Note: some of those parameters should be never set (or should be ignored) // for main-frame / HTTP(s) navigations, but we still compare them here as a // defence-in-depth measure. - DCHECK(navigation_request.IsInPrimaryMainFrame()); + CHECK(navigation_request.IsInPrimaryMainFrame()); // Compare BeginNavigationParams. ActivationNavigationParamsMatch result = @@ -668,7 +668,7 @@ } // Initial prerender navigation cannot be a form submission. - DCHECK(!begin_params_->is_form_submission); + CHECK(!begin_params_->is_form_submission); if (potential_activation.is_form_submission != begin_params_->is_form_submission) { return ActivationNavigationParamsMatch::kIsFormSubmission; @@ -686,7 +686,7 @@ // Trust token params can be set only on subframe navigations, so both values // should be null here. - DCHECK(!begin_params_->trust_token_params); + CHECK(!begin_params_->trust_token_params); if (potential_activation.trust_token_params != begin_params_->trust_token_params) { return ActivationNavigationParamsMatch::kTrustTokenParams; @@ -694,7 +694,7 @@ // Web bundle token cannot be set due because it is only set for child // frame navigations. - DCHECK(!begin_params_->web_bundle_token); + CHECK(!begin_params_->web_bundle_token); if (potential_activation.web_bundle_token) { return ActivationNavigationParamsMatch::kWebBundleToken; } @@ -702,8 +702,8 @@ // Don't require equality for request_context_type because link clicks // (HYPERLINK) should be allowed for activation, whereas prerender always has // type LOCATION. - DCHECK_EQ(begin_params_->request_context_type, - blink::mojom::RequestContextType::LOCATION); + CHECK_EQ(begin_params_->request_context_type, + blink::mojom::RequestContextType::LOCATION); switch (potential_activation.request_context_type) { case blink::mojom::RequestContextType::HYPERLINK: case blink::mojom::RequestContextType::LOCATION: @@ -713,7 +713,7 @@ } // Since impression should not be set, no need to compare contents. - DCHECK(!begin_params_->impression); + CHECK(!begin_params_->impression); if (potential_activation.impression.has_value()) { return ActivationNavigationParamsMatch::kImpressionHasValue; } @@ -752,8 +752,8 @@ return ActivationNavigationParamsMatch::kTransition; } - DCHECK_EQ(common_params_->navigation_type, - blink::mojom::NavigationType::DIFFERENT_DOCUMENT); + CHECK_EQ(common_params_->navigation_type, + blink::mojom::NavigationType::DIFFERENT_DOCUMENT); if (potential_activation.navigation_type != common_params_->navigation_type) { return ActivationNavigationParamsMatch::kNavigationType; } @@ -766,18 +766,18 @@ // prerendering navigation isn't a download and as prerendering activation // won't reach out to the network, it won't turn into a navigation as well. - DCHECK(common_params_->base_url_for_data_url.is_empty()); + CHECK(common_params_->base_url_for_data_url.is_empty()); if (potential_activation.base_url_for_data_url != common_params_->base_url_for_data_url) { return ActivationNavigationParamsMatch::kBaseUrlForDataUrl; } - // The method parameter is compared only by DCHECK_EQ because that change is + // The method parameter is compared only by CHECK_EQ because that change is // detected earlier by checking the HTTP request headers changes. - DCHECK_EQ(potential_activation.method, common_params_->method); + CHECK_EQ(potential_activation.method, common_params_->method); // Initial prerender navigation can't be a form submission. - DCHECK(!common_params_->post_data); + CHECK(!common_params_->post_data); if (potential_activation.post_data != common_params_->post_data) { return ActivationNavigationParamsMatch::kPostData; } @@ -786,7 +786,7 @@ // debugging purposes and does not impact the properties of the document // created by this navigation. - DCHECK(!common_params_->started_from_context_menu); + CHECK(!common_params_->started_from_context_menu); if (potential_activation.started_from_context_menu != common_params_->started_from_context_menu) { return ActivationNavigationParamsMatch::kStartedFromContextMenu; @@ -818,7 +818,7 @@ } // Initial prerender navigation can't be a history navigation. - DCHECK(!common_params_->is_history_navigation_in_new_child_frame); + CHECK(!common_params_->is_history_navigation_in_new_child_frame); if (potential_activation.is_history_navigation_in_new_child_frame != common_params_->is_history_navigation_in_new_child_frame) { return ActivationNavigationParamsMatch::kIsHistoryNavigationInNewChildFrame; @@ -836,13 +836,13 @@ } RenderFrameHostImpl* PrerenderHost::GetPrerenderedMainFrameHost() { - DCHECK(frame_tree_); - DCHECK(frame_tree_->root()->current_frame_host()); + CHECK(frame_tree_); + CHECK(frame_tree_->root()->current_frame_host()); return frame_tree_->root()->current_frame_host(); } FrameTree& PrerenderHost::GetPrerenderFrameTree() { - DCHECK(frame_tree_); + CHECK(frame_tree_); return *frame_tree_; } @@ -854,8 +854,8 @@ void PrerenderHost::RecordFailedFinalStatusImpl( const PrerenderCancellationReason& reason) { - DCHECK(!final_status_); - DCHECK_NE(reason.final_status(), PrerenderFinalStatus::kActivated); + CHECK(!final_status_); + CHECK_NE(reason.final_status(), PrerenderFinalStatus::kActivated); final_status_ = reason.final_status(); RecordFailedPrerenderFinalStatus(reason, attributes_); @@ -865,7 +865,7 @@ } void PrerenderHost::RecordActivation(NavigationRequest& navigation_request) { - DCHECK(!final_status_); + CHECK(!final_status_); final_status_ = PrerenderFinalStatus::kActivated; // TODO(crbug.com/1299330): Replace @@ -911,15 +911,15 @@ } void PrerenderHost::SetInitialNavigation(NavigationRequest* navigation) { - DCHECK(!initial_navigation_id_.has_value()); + CHECK(!initial_navigation_id_.has_value()); initial_navigation_id_ = navigation->GetNavigationId(); begin_params_ = navigation->begin_params().Clone(); common_params_ = navigation->common_params().Clone(); // The prerendered page should be checked by the main world CSP. See also // relevant comments in AreCommonNavigationParamsCompatibleWithNavigation(). - DCHECK_EQ(common_params_->should_check_main_world_csp, - network::mojom::CSPDisposition::CHECK); + CHECK_EQ(common_params_->should_check_main_world_csp, + network::mojom::CSPDisposition::CHECK); } void PrerenderHost::SetTriggeringOutcome(PreloadingTriggeringOutcome outcome) { @@ -1033,7 +1033,7 @@ case PrerenderFinalStatus::kActivated: // The activation path does not call this method, so it should never reach // this case. - NOTREACHED(); + NOTREACHED_NORETURN(); } } @@ -1072,10 +1072,10 @@ return; RenderFrameHostImpl* host = PrerenderHost::GetPrerenderedMainFrameHost(); - DCHECK(host); + CHECK(host); PrerenderHostRegistry* registry = host->delegate()->GetPrerenderHostRegistry(); - DCHECK(registry); + CHECK(registry); registry->CancelHost(frame_tree_node_id_, status); }
diff --git a/content/browser/preloading/prerender/prerender_host_registry.cc b/content/browser/preloading/prerender/prerender_host_registry.cc index 3e0b45d..ca306d7 100644 --- a/content/browser/preloading/prerender/prerender_host_registry.cc +++ b/content/browser/preloading/prerender/prerender_host_registry.cc
@@ -86,7 +86,7 @@ PrerenderHostRegistry::~PrerenderHostRegistry() { // This function is called by WebContentsImpl's dtor, so web_contents() should // not be a null ptr at this moment. - DCHECK(web_contents()); + CHECK(web_contents()); PrerenderFinalStatus final_status = web_contents()->GetClosedByUserGesture() @@ -122,12 +122,12 @@ // The initiator WebContents can be different from the WebContents that will // host a prerendered page only when the prerender-in-new-tab runs. - DCHECK(attributes.initiator_web_contents); + CHECK(attributes.initiator_web_contents); auto& initiator_web_contents = static_cast<WebContentsImpl&>(*attributes.initiator_web_contents); auto& prerender_web_contents = static_cast<WebContentsImpl&>(*web_contents()); - DCHECK(&initiator_web_contents == &prerender_web_contents || - base::FeatureList::IsEnabled(blink::features::kPrerender2InNewTab)); + CHECK(&initiator_web_contents == &prerender_web_contents || + base::FeatureList::IsEnabled(blink::features::kPrerender2InNewTab)); int frame_tree_node_id = RenderFrameHost::kNoFrameTreeNodeId; @@ -169,7 +169,7 @@ attributes); break; default: - NOTREACHED(); + NOTREACHED_NORETURN(); } if (attempt) attempt->SetEligibility(reason); @@ -312,12 +312,12 @@ // No running prerender means that no other prerender is waiting in // the pending queue, because the prerender sequence only stops when // all the pending prerenders are started. - DCHECK_EQ(pending_prerenders_.size(), 1u); + CHECK_EQ(pending_prerenders_.size(), 1u); int started_frame_tree_node_id = StartPrerendering(RenderFrameHost::kNoFrameTreeNodeId); - DCHECK(started_frame_tree_node_id == frame_tree_node_id || - started_frame_tree_node_id == - RenderFrameHost::kNoFrameTreeNodeId); + CHECK(started_frame_tree_node_id == frame_tree_node_id || + started_frame_tree_node_id == + RenderFrameHost::kNoFrameTreeNodeId); frame_tree_node_id = started_frame_tree_node_id; } break; @@ -341,8 +341,8 @@ int PrerenderHostRegistry::CreateAndStartHostForNewTab( const PrerenderAttributes& attributes) { - DCHECK(base::FeatureList::IsEnabled(blink::features::kPrerender2InNewTab)); - DCHECK_EQ(attributes.trigger_type, PrerenderTriggerType::kSpeculationRule); + CHECK(base::FeatureList::IsEnabled(blink::features::kPrerender2InNewTab)); + CHECK_EQ(attributes.trigger_type, PrerenderTriggerType::kSpeculationRule); std::string recorded_url = attributes.initiator_origin.has_value() ? attributes.initiator_origin.value().GetURL().spec() @@ -363,9 +363,9 @@ int PrerenderHostRegistry::StartPrerendering(int frame_tree_node_id) { if (frame_tree_node_id == RenderFrameHost::kNoFrameTreeNodeId) { - DCHECK(base::FeatureList::IsEnabled( + CHECK(base::FeatureList::IsEnabled( blink::features::kPrerender2SequentialPrerendering)); - DCHECK_EQ(running_prerender_host_id_, RenderFrameHost::kNoFrameTreeNodeId); + CHECK_EQ(running_prerender_host_id_, RenderFrameHost::kNoFrameTreeNodeId); for (auto iter = pending_prerenders_.begin(); iter != pending_prerenders_.end();) { @@ -382,7 +382,7 @@ // The initiator WebContents should be alive as it cancels all the // prerendering requests during destruction. - DCHECK(prerender_host->initiator_web_contents()); + CHECK(prerender_host->initiator_web_contents()); // Don't start the pending prerender triggered by the background tab. if (IsBackground( @@ -403,7 +403,7 @@ auto prerender_host_it = prerender_host_by_frame_tree_node_id_.find(frame_tree_node_id); - DCHECK(prerender_host_it != prerender_host_by_frame_tree_node_id_.end()); + CHECK(prerender_host_it != prerender_host_by_frame_tree_node_id_.end()); PrerenderHost& prerender_host = *prerender_host_it->second; devtools_instrumentation::WillInitiatePrerender( prerender_host.GetPrerenderFrameTree()); @@ -484,7 +484,7 @@ iter != prerender_new_tab_handle_by_frame_tree_node_id_.end()) { // The host should be driven by PrerenderHostRegistry associated with // the new tab. - DCHECK_NE(running_prerender_host_id_, host_id); + CHECK_NE(running_prerender_host_id_, host_id); std::unique_ptr<PrerenderNewTabHandle> handle = std::move(iter->second); prerender_new_tab_handle_by_frame_tree_node_id_.erase(iter); @@ -492,7 +492,7 @@ cancelled_ids.insert(host_id); } } else { - DCHECK(prerender_new_tab_handle_by_frame_tree_node_id_.empty()); + CHECK(prerender_new_tab_handle_by_frame_tree_node_id_.empty()); } } @@ -548,7 +548,7 @@ break; } } else { - DCHECK(prerender_new_tab_handle_by_frame_tree_node_id_.empty()); + CHECK(prerender_new_tab_handle_by_frame_tree_node_id_.empty()); } CancelHosts(ids_to_be_deleted, reason); @@ -572,7 +572,7 @@ for (auto& iter : prerender_new_tab_handle_map) iter.second->CancelPrerendering(reason); } else { - DCHECK(prerender_new_tab_handle_by_frame_tree_node_id_.empty()); + CHECK(prerender_new_tab_handle_by_frame_tree_node_id_.empty()); } pending_prerenders_.clear(); @@ -629,10 +629,10 @@ std::unique_ptr<PrerenderHost> host = std::move(prerender_host_by_frame_tree_node_id_[host_id]); prerender_host_by_frame_tree_node_id_.erase(host_id); - DCHECK_EQ(host_id, host->frame_tree_node_id()); + CHECK_EQ(host_id, host->frame_tree_node_id()); // Reserve the host for activation. - DCHECK(!reserved_prerender_host_); + CHECK(!reserved_prerender_host_); reserved_prerender_host_ = std::move(host); return host_id; @@ -643,7 +643,7 @@ if (!reserved_prerender_host_) return nullptr; - DCHECK_EQ(frame_tree_node_id, reserved_prerender_host_->frame_tree_node_id()); + CHECK_EQ(frame_tree_node_id, reserved_prerender_host_->frame_tree_node_id()); return reserved_prerender_host_->GetPrerenderedMainFrameHost(); } @@ -661,8 +661,8 @@ void PrerenderHostRegistry::OnActivationFinished(int frame_tree_node_id) { // OnActivationFinished() should not be called for non-reserved hosts. - DCHECK(!base::Contains(prerender_host_by_frame_tree_node_id_, - frame_tree_node_id)); + CHECK(!base::Contains(prerender_host_by_frame_tree_node_id_, + frame_tree_node_id)); if (!reserved_prerender_host_) { // The activation finished successfully and has already activated the @@ -672,7 +672,7 @@ // The activation navigation is cancelled before activating the prerendered // page, which means the activation failed. - DCHECK_EQ(frame_tree_node_id, reserved_prerender_host_->frame_tree_node_id()); + CHECK_EQ(frame_tree_node_id, reserved_prerender_host_->frame_tree_node_id()); // TODO(https://crbug.com/1378151): Monitor the final status metric and see // whether it could be possible. @@ -705,7 +705,7 @@ PrerenderHostRegistry::TakePreCreatedWebContentsForNewTabIfExists( const mojom::CreateNewWindowParams& create_new_window_params, const WebContents::CreateParams& web_contents_create_params) { - DCHECK(base::FeatureList::IsEnabled(blink::features::kPrerender2InNewTab)); + CHECK(base::FeatureList::IsEnabled(blink::features::kPrerender2InNewTab)); // Don't serve a prerendered page if the window needs the opener or is created // for non-regular navigations. @@ -753,7 +753,7 @@ } void PrerenderHostRegistry::CancelAllHostsForTesting() { - DCHECK(!reserved_prerender_host_) + CHECK(!reserved_prerender_host_) << "It is not possible to cancel a reserved host, so they must not exist " "when trying to cancel all hosts"; @@ -793,7 +793,7 @@ // ready to commit, so `prerender_host` should always be non-null here. auto* prerender_host = PrerenderHost::GetPrerenderHostFromFrameTreeNode( *navigation_request->frame_tree_node()); - DCHECK(prerender_host); + CHECK(prerender_host); prerender_host->DidStartNavigation(navigation_handle); } @@ -870,7 +870,7 @@ RenderFrameHost* render_frame_host, const GlobalRequestID& request_id, const blink::mojom::ResourceLoadInfo& resource_load_info) { - DCHECK(render_frame_host); + CHECK(render_frame_host); if (render_frame_host->GetLifecycleState() != RenderFrameHost::LifecycleState::kPrerendering) { @@ -955,7 +955,7 @@ } if (!host->GetInitialNavigationId().has_value()) { - DCHECK(base::FeatureList::IsEnabled( + CHECK(base::FeatureList::IsEnabled( blink::features::kPrerender2SequentialPrerendering)); CancelHost(host->frame_tree_node_id(), PrerenderFinalStatus::kActivatedBeforeStarted); @@ -996,7 +996,7 @@ cancelled_prerenders.push_back(host_id); } } else { - DCHECK(prerender_new_tab_handle_by_frame_tree_node_id_.empty()); + CHECK(prerender_new_tab_handle_by_frame_tree_node_id_.empty()); } CancelHosts( cancelled_prerenders, @@ -1030,7 +1030,7 @@ PrerenderTriggerType PrerenderHostRegistry::GetPrerenderTriggerType( int frame_tree_node_id) { PrerenderHost* prerender_host = FindReservedHostById(frame_tree_node_id); - DCHECK(prerender_host); + CHECK(prerender_host); return prerender_host->trigger_type(); } @@ -1038,7 +1038,7 @@ const std::string& PrerenderHostRegistry::GetPrerenderEmbedderHistogramSuffix( int frame_tree_node_id) { PrerenderHost* prerender_host = FindReservedHostById(frame_tree_node_id); - DCHECK(prerender_host); + CHECK(prerender_host); return prerender_host->embedder_histogram_suffix(); } @@ -1085,7 +1085,7 @@ int frame_tree_node_id, bool success, std::unique_ptr<memory_instrumentation::GlobalMemoryDump> dump) { - DCHECK( + CHECK( base::FeatureList::IsEnabled(blink::features::kPrerender2MemoryControls)); // Stop a prerendering when we can't get the current memory usage. if (!success) {
diff --git a/content/browser/preloading/prerender/prerender_host_unittest.cc b/content/browser/preloading/prerender/prerender_host_unittest.cc index 18d2350..ed38085c 100644 --- a/content/browser/preloading/prerender/prerender_host_unittest.cc +++ b/content/browser/preloading/prerender/prerender_host_unittest.cc
@@ -259,7 +259,7 @@ // Perform a navigation in the primary frame tree which activates the // prerendered page. The main expectation is that this navigation commits - // successfully and doesn't hit any DCHECKs. + // successfully and doesn't hit any CHECKs. contents()->ActivatePrerenderedPage(kPrerenderingUrl); ExpectFinalStatus(PrerenderFinalStatus::kActivated);
diff --git a/content/browser/preloading/prerender/prerender_metrics.cc b/content/browser/preloading/prerender/prerender_metrics.cc index 3ed14d4..9c7f153 100644 --- a/content/browser/preloading/prerender/prerender_metrics.cc +++ b/content/browser/preloading/prerender/prerender_metrics.cc
@@ -59,13 +59,13 @@ const std::string& embedder_suffix) { switch (trigger_type) { case PrerenderTriggerType::kSpeculationRule: - DCHECK(embedder_suffix.empty()); + CHECK(embedder_suffix.empty()); return std::string(histogram_base_name) + ".SpeculationRule"; case PrerenderTriggerType::kEmbedder: - DCHECK(!embedder_suffix.empty()); + CHECK(!embedder_suffix.empty()); return std::string(histogram_base_name) + ".Embedder_" + embedder_suffix; } - NOTREACHED(); + NOTREACHED_NORETURN(); } void ReportHeaderMismatch(const std::string& key, @@ -151,7 +151,7 @@ const std::string& embedder_histogram_suffix) const { switch (final_status_) { case PrerenderFinalStatus::kInactivePageRestriction: - DCHECK(absl::holds_alternative<uint64_t>(explanation_)); + CHECK(absl::holds_alternative<uint64_t>(explanation_)); base::UmaHistogramSparse( GenerateHistogramName("Prerender.CanceledForInactivePageRestriction." "DisallowActivationReason", @@ -160,13 +160,13 @@ absl::get<uint64_t>(explanation_)); break; case PrerenderFinalStatus::kMojoBinderPolicy: - DCHECK(absl::holds_alternative<std::string>(explanation_)); + CHECK(absl::holds_alternative<std::string>(explanation_)); RecordPrerenderCancelledInterface(absl::get<std::string>(explanation_), trigger_type, embedder_histogram_suffix); break; default: - DCHECK(absl::holds_alternative<absl::monostate>(explanation_)); + CHECK(absl::holds_alternative<absl::monostate>(explanation_)); // Other types need not to report. break; } @@ -175,16 +175,16 @@ std::string PrerenderCancellationReason::ToDevtoolReasonString() const { switch (final_status_) { case PrerenderFinalStatus::kInactivePageRestriction: - DCHECK(absl::holds_alternative<uint64_t>(explanation_)); + CHECK(absl::holds_alternative<uint64_t>(explanation_)); // TODO(https://crbug.com/1328365): It seems we have to return an integer. // And devtool has to handle it based on the enum.xml, as the content // layer cannot know about the enums added by the embedder layer. return ""; case PrerenderFinalStatus::kMojoBinderPolicy: - DCHECK(absl::holds_alternative<std::string>(explanation_)); + CHECK(absl::holds_alternative<std::string>(explanation_)); return absl::get<std::string>(explanation_); default: - DCHECK(absl::holds_alternative<absl::monostate>(explanation_)); + CHECK(absl::holds_alternative<absl::monostate>(explanation_)); return ""; } } @@ -207,15 +207,15 @@ void RecordFailedPrerenderFinalStatus( const PrerenderCancellationReason& cancellation_reason, const PrerenderAttributes& attributes) { - DCHECK_NE(cancellation_reason.final_status(), - PrerenderFinalStatus::kActivated); + CHECK_NE(cancellation_reason.final_status(), + PrerenderFinalStatus::kActivated); RecordPrerenderFinalStatusUma(cancellation_reason.final_status(), attributes.trigger_type, attributes.embedder_histogram_suffix); if (attributes.initiator_ukm_id != ukm::kInvalidSourceId) { // `initiator_ukm_id` must be valid for the speculation rules. - DCHECK_EQ(attributes.trigger_type, PrerenderTriggerType::kSpeculationRule); + CHECK_EQ(attributes.trigger_type, PrerenderTriggerType::kSpeculationRule); ukm::builders::PrerenderPageLoad(attributes.initiator_ukm_id) .SetFinalStatus(static_cast<int>(cancellation_reason.final_status())) .Record(ukm::UkmRecorder::Get()); @@ -227,7 +227,7 @@ if (!attributes.IsBrowserInitiated()) { auto* ftn = FrameTreeNode::GloballyFindByID( attributes.initiator_frame_tree_node_id); - DCHECK(ftn); + CHECK(ftn); // TODO(https://crbug.com/1332377): Discuss with devtools to finalize the // message protocol. if (attributes.initiator_devtools_navigation_token.has_value()) { @@ -247,7 +247,7 @@ attributes.embedder_histogram_suffix); if (attributes.initiator_ukm_id != ukm::kInvalidSourceId) { // `initiator_ukm_id` must be valid only for the speculation rules. - DCHECK_EQ(attributes.trigger_type, PrerenderTriggerType::kSpeculationRule); + CHECK_EQ(attributes.trigger_type, PrerenderTriggerType::kSpeculationRule); ukm::builders::PrerenderPageLoad(attributes.initiator_ukm_id) .SetFinalStatus(static_cast<int>(PrerenderFinalStatus::kActivated)) .Record(ukm::UkmRecorder::Get()); @@ -275,7 +275,7 @@ PrerenderCrossOriginRedirectionMismatch mismatch_type, PrerenderTriggerType trigger_type, const std::string& embedder_histogram_suffix) { - DCHECK_EQ(trigger_type, PrerenderTriggerType::kEmbedder); + CHECK_EQ(trigger_type, PrerenderTriggerType::kEmbedder); base::UmaHistogramEnumeration( GenerateHistogramName( "Prerender.Experimental.PrerenderCrossOriginRedirectionMismatch", @@ -287,7 +287,7 @@ PrerenderCrossOriginRedirectionProtocolChange change_type, PrerenderTriggerType trigger_type, const std::string& embedder_histogram_suffix) { - DCHECK_EQ(trigger_type, PrerenderTriggerType::kEmbedder); + CHECK_EQ(trigger_type, PrerenderTriggerType::kEmbedder); base::UmaHistogramEnumeration( GenerateHistogramName( "Prerender.Experimental.CrossOriginRedirectionProtocolChange",
diff --git a/content/browser/preloading/prerender/prerender_navigation_throttle.cc b/content/browser/preloading/prerender/prerender_navigation_throttle.cc index a6583e37..cc36602 100644 --- a/content/browser/preloading/prerender/prerender_navigation_throttle.cc +++ b/content/browser/preloading/prerender/prerender_navigation_throttle.cc
@@ -33,16 +33,16 @@ const url::Origin& initial_origin, PrerenderTriggerType trigger_type, const std::string& embedder_histogram_suffix) { - DCHECK_NE(initial_origin, current_origin); - DCHECK_EQ(trigger_type, PrerenderTriggerType::kEmbedder); - DCHECK(current_origin.GetURL().SchemeIsHTTPOrHTTPS()); - DCHECK(initial_origin.GetURL().SchemeIsHTTPOrHTTPS()); + CHECK_NE(initial_origin, current_origin); + CHECK_EQ(trigger_type, PrerenderTriggerType::kEmbedder); + CHECK(current_origin.GetURL().SchemeIsHTTPOrHTTPS()); + CHECK(initial_origin.GetURL().SchemeIsHTTPOrHTTPS()); std::bitset<3> bits; bits[2] = current_origin.scheme() != initial_origin.scheme(); bits[1] = current_origin.host() != initial_origin.host(); bits[0] = current_origin.port() != initial_origin.port(); - DCHECK(bits.any()); + CHECK(bits.any()); auto mismatch_type = static_cast<PrerenderCrossOriginRedirectionMismatch>(bits.to_ulong()); @@ -225,7 +225,7 @@ // Skip the same-site check for non-redirected cases as the initiator // origin is nullopt for browser-initiated prerendering. - DCHECK(!prerender_host_->initiator_origin().has_value()); + CHECK(!prerender_host_->initiator_origin().has_value()); } else if (prerender_navigation_utils::IsCrossSite( navigation_url, prerender_host_->initiator_origin().value())) {
diff --git a/content/browser/preloading/prerender/prerender_new_tab_handle.cc b/content/browser/preloading/prerender/prerender_new_tab_handle.cc index f948140..e96fadd 100644 --- a/content/browser/preloading/prerender/prerender_new_tab_handle.cc +++ b/content/browser/preloading/prerender/prerender_new_tab_handle.cc
@@ -25,8 +25,7 @@ PreloadingEligibility IsPrerender2Supported( WebContents& web_contents) override { // This should be checked in the initiator's WebContents. - NOTREACHED(); - return PreloadingEligibility::kPreloadingDisabled; + NOTREACHED_NORETURN(); } // TODO(crbug.com/1350676): Investigate if we have to override other @@ -37,8 +36,8 @@ const PrerenderAttributes& attributes, BrowserContext& browser_context) : attributes_(attributes), web_contents_create_params_(&browser_context) { - DCHECK(base::FeatureList::IsEnabled(blink::features::kPrerender2InNewTab)); - DCHECK(!attributes.IsBrowserInitiated()); + CHECK(base::FeatureList::IsEnabled(blink::features::kPrerender2InNewTab)); + CHECK(!attributes.IsBrowserInitiated()); auto* initiator_render_frame_host = RenderFrameHostImpl::FromFrameToken( attributes_.initiator_process_id, @@ -66,7 +65,7 @@ web_contents_delegate_ = std::make_unique<WebContentsDelegateImpl>(); web_contents_->SetDelegate(web_contents_delegate_.get()); - DCHECK_EQ(web_contents_->GetVisibility(), Visibility::HIDDEN); + CHECK_EQ(web_contents_->GetVisibility(), Visibility::HIDDEN); } PrerenderNewTabHandle::~PrerenderNewTabHandle() { @@ -116,7 +115,7 @@ // TODO(crbug.com/1350676): Consider supporting activation for non-empty // `main_frame_name`. - DCHECK(web_contents_create_params_.main_frame_name.empty()); + CHECK(web_contents_create_params_.main_frame_name.empty()); if (web_contents_create_params_.main_frame_name != web_contents_create_params.main_frame_name) { return nullptr; @@ -127,7 +126,7 @@ // that parameters newly added to WebContents::CreateParams are accordingly // handled here with an approach similar to SameSizeAsDocumentLoader. - DCHECK(web_contents_); + CHECK(web_contents_); web_contents_->SetDelegate(nullptr); return std::move(web_contents_); } @@ -141,7 +140,7 @@ } PrerenderHostRegistry& PrerenderNewTabHandle::GetPrerenderHostRegistry() { - DCHECK(web_contents_); + CHECK(web_contents_); return *web_contents_->GetPrerenderHostRegistry(); }
diff --git a/content/browser/preloading/prerender/prerender_subframe_navigation_throttle.cc b/content/browser/preloading/prerender/prerender_subframe_navigation_throttle.cc index bb89de6..c05d1ffe 100644 --- a/content/browser/preloading/prerender/prerender_subframe_navigation_throttle.cc +++ b/content/browser/preloading/prerender/prerender_subframe_navigation_throttle.cc
@@ -105,10 +105,10 @@ } void PrerenderSubframeNavigationThrottle::OnActivated() { - DCHECK(!NavigationRequest::From(navigation_handle()) - ->frame_tree_node() - ->frame_tree() - .is_prerendering()); + CHECK(!NavigationRequest::From(navigation_handle()) + ->frame_tree_node() + ->frame_tree() + .is_prerendering()); // OnActivated() is called right before activation navigation commit which is // a little early. We want to resume the subframe navigation after the // PageBroadcast ActivatePrerenderedPage IPC is sent, to @@ -154,8 +154,8 @@ NavigationThrottle::ThrottleCheckResult PrerenderSubframeNavigationThrottle::DeferOrCancelCrossOriginSubframeNavigation( const FrameTreeNode& frame_tree_node) { - DCHECK(frame_tree_node.frame_tree().is_prerendering()); - DCHECK(!frame_tree_node.IsMainFrame()); + CHECK(frame_tree_node.frame_tree().is_prerendering()); + CHECK(!frame_tree_node.IsMainFrame()); // Look up the PrerenderHost. PrerenderHostRegistry* registry = frame_tree_node.current_frame_host() @@ -171,9 +171,9 @@ // Defer cross-origin subframe navigations during prerendering. // Will resume the navigation upon activation. - DCHECK(!observation_.IsObserving()); + CHECK(!observation_.IsObserving()); observation_.Observe(prerender_host); - DCHECK(observation_.IsObservingSource(prerender_host)); + CHECK(observation_.IsObservingSource(prerender_host)); is_deferred_ = true; return NavigationThrottle::DEFER; } @@ -187,7 +187,7 @@ PrerenderSubframeNavigationThrottle::WillStartOrRedirectRequest() { auto* navigation_request = NavigationRequest::From(navigation_handle()); FrameTreeNode* frame_tree_node = navigation_request->frame_tree_node(); - DCHECK(!frame_tree_node->IsMainFrame()); + CHECK(!frame_tree_node->IsMainFrame()); // Proceed if the page isn't in the prerendering state. if (!frame_tree_node->frame_tree().is_prerendering())
diff --git a/content/browser/renderer_host/back_forward_cache_impl.cc b/content/browser/renderer_host/back_forward_cache_impl.cc index 7b050b22..574adb6 100644 --- a/content/browser/renderer_host/back_forward_cache_impl.cc +++ b/content/browser/renderer_host/back_forward_cache_impl.cc
@@ -275,9 +275,9 @@ // Parses the “allowed_websites” and "blocked_websites" field trial parameters // and creates a map to represent hosts and corresponding path prefixes. -std::map<std::string, std::vector<std::string>> ParseCommaSeparatedURLs( +base::flat_map<std::string, std::vector<std::string>> ParseCommaSeparatedURLs( base::StringPiece comma_separated_urls) { - std::map<std::string, std::vector<std::string>> urls; + base::flat_map<std::string, std::vector<std::string>> urls; for (auto& it : base::SplitString(comma_separated_urls, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { @@ -288,14 +288,10 @@ } // Parses the "cgi_params" field trial parameter into a set by splitting on "|". -std::unordered_set<std::string> ParseBlockedCgiParams( +base::flat_set<std::string> ParseBlockedCgiParams( base::StringPiece cgi_params_string) { - std::vector<std::string> split = - base::SplitString(cgi_params_string, "|", base::TRIM_WHITESPACE, - base::SplitResult::SPLIT_WANT_NONEMPTY); - std::unordered_set<std::string> cgi_params; - cgi_params.insert(split.begin(), split.end()); - return cgi_params; + return base::SplitString(cgi_params_string, "|", base::TRIM_WHITESPACE, + base::SplitResult::SPLIT_WANT_NONEMPTY); } BackForwardCacheTestDelegate* g_bfcache_disabled_test_observer = nullptr;
diff --git a/content/browser/renderer_host/back_forward_cache_impl.h b/content/browser/renderer_host/back_forward_cache_impl.h index bf98de5..b3ad355 100644 --- a/content/browser/renderer_host/back_forward_cache_impl.h +++ b/content/browser/renderer_host/back_forward_cache_impl.h
@@ -489,24 +489,24 @@ // the field trial parameter "allowed_websites". This is represented here by a // set of host and path prefix. When |allowed_urls_| is empty, it means there // are no restrictions on URLs. - const std::map<std::string, // URL's host, - std::vector<std::string> // URL's path prefix - > + const base::flat_map<std::string, // URL's host, + std::vector<std::string> // URL's path prefix + > allowed_urls_; // This is an emergency kill switch per url to stop BFCache. The data will be // provided via the field trial parameter "blocked_websites". // "blocked_websites" have priority over "allowed_websites". This is // represented here by a set of host and path prefix. - const std::map<std::string, // URL's host, - std::vector<std::string> // URL's path prefix - > + const base::flat_map<std::string, // URL's host, + std::vector<std::string> // URL's path prefix + > blocked_urls_; // Data provided from the "blocked_cgi_params" feature param. If any of these // occur in the query of the URL then the page is not eligible for caching. // See |IsQueryAllowed|. - const std::unordered_set<std::string> blocked_cgi_params_; + const base::flat_set<std::string> blocked_cgi_params_; // Helper class to iterate through the frame tree in the page and populate the // NotRestoredReasons.
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc index 146799a..60b52a9 100644 --- a/content/browser/renderer_host/render_frame_host_impl.cc +++ b/content/browser/renderer_host/render_frame_host_impl.cc
@@ -76,6 +76,7 @@ #include "content/browser/installedapp/installed_app_provider_impl.h" #include "content/browser/interest_group/ad_auction_document_data.h" #include "content/browser/loader/file_url_loader_factory.h" +#include "content/browser/loader/keep_alive_url_loader_service.h" #include "content/browser/loader/navigation_early_hints_manager.h" #include "content/browser/loader/prefetch_url_loader_service.h" #include "content/browser/log_console_message.h" @@ -4465,18 +4466,13 @@ void RenderFrameHostImpl::DidChangeBackForwardCacheDisablingFeatures( BackForwardCacheBlockingDetails details) { - renderer_reported_bfcache_disabling_features_.Clear(); - for (auto& feature_details : details) { - renderer_reported_bfcache_disabling_features_.Put( - static_cast<blink::scheduler::WebSchedulerTrackedFeature>( - feature_details->feature)); - } + renderer_reported_bfcache_blocking_details_ = std::move(details); MaybeEvictFromBackForwardCache(); if (back_forward_cache_disabling_features_callback_for_testing_) { back_forward_cache_disabling_features_callback_for_testing_.Run( - renderer_reported_bfcache_disabling_features_); + GetBackForwardCacheDisablingFeatures()); } } @@ -4525,19 +4521,33 @@ RenderFrameHostImpl::BackForwardCacheDisablingFeatures RenderFrameHostImpl::GetBackForwardCacheDisablingFeatures() const { - BackForwardCacheDisablingFeatures features = - renderer_reported_bfcache_disabling_features_; + BackForwardCacheDisablingFeatures features; + for (const auto& details : GetBackForwardCacheBlockingDetails()) { + features.Put(static_cast<blink::scheduler::WebSchedulerTrackedFeature>( + details->feature)); + } + return features; +} - features.PutAll( +RenderFrameHostImpl::BackForwardCacheBlockingDetails +RenderFrameHostImpl::GetBackForwardCacheBlockingDetails() const { + BackForwardCacheBlockingDetails combined_details_list = DedicatedWorkerHostsForDocument::GetOrCreateForCurrentDocument( const_cast<RenderFrameHostImpl*>(this)) - ->GetBackForwardCacheDisablingFeatures()); + ->GetBackForwardCacheBlockingDetails(); - for (const auto& it : browser_reported_bfcache_disabling_features_counts_) { - features.Put(it.first); + for (const auto& details : renderer_reported_bfcache_blocking_details_) { + combined_details_list.push_back(details.Clone()); } - return features; + for (const auto& it : browser_reported_bfcache_disabling_features_counts_) { + // Browser reported features do not have JS location details. Create a + // blocking details struct with only the feature filled. + auto details_ptr = blink::mojom::BlockingDetails::New(); + details_ptr->feature = static_cast<uint32_t>(it.first); + combined_details_list.push_back(std::move(details_ptr)); + } + return combined_details_list; } RenderFrameHostImpl::BackForwardCacheDisablingFeatureHandle @@ -9683,6 +9693,7 @@ } } + // Set up prefetch loader factory. std::unique_ptr<blink::PendingURLLoaderFactoryBundle> factory_bundle_for_prefetch; mojo::PendingRemote<network::mojom::URLLoaderFactory> @@ -9751,6 +9762,37 @@ } } + // Set up keepalive loader factory. It is used to proxy the keepalive + // requests, i.e. fetch(..., {keepalive: true}), via the browser process. + // See + // https://docs.google.com/document/d/1ZzxMMBvpqn8VZBZKnb7Go8TWjnrGcXuLS_USwVVRUvY/edit + // Note that this loader does not depend on `prefetch_loader_factory` nor + // `topics_loader_factory`. + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory; + if (base::FeatureList::IsEnabled( + blink::features::kKeepAliveInBrowserMigration)) { + std::unique_ptr<blink::PendingURLLoaderFactoryBundle> + factory_bundle_for_keep_alive; + + if (subresource_loader_factories) { + // Clone the factory bundle for keepalive. + auto bundle = base::MakeRefCounted<blink::URLLoaderFactoryBundle>( + std::move(subresource_loader_factories)); + subresource_loader_factories = CloneFactoryBundle(bundle); + factory_bundle_for_keep_alive = CloneFactoryBundle(bundle); + } + + if (factory_bundle_for_keep_alive) { + // Also setting up URLLoaderFactory for keepalive using the same loader + // factories. + auto* storage_partition = GetStoragePartition(); + storage_partition->GetKeepAliveURLLoaderService()->BindFactory( + keep_alive_loader_factory.InitWithNewPipeAndPassReceiver(), + std::move(factory_bundle_for_keep_alive)); + } + } + mojom::NavigationClient* navigation_client = navigation_request->GetCommitNavigationClient(); @@ -9813,8 +9855,8 @@ std::move(subresource_loader_factories), std::move(subresource_overrides), std::move(controller), std::move(container_info), std::move(prefetch_loader_factory), - std::move(topics_loader_factory), manifest_policy, - std::move(policy_container), *document_token, + std::move(topics_loader_factory), std::move(keep_alive_loader_factory), + manifest_policy, std::move(policy_container), *document_token, devtools_navigation_token); navigation_request->frame_tree_node() ->navigator() @@ -12533,7 +12575,7 @@ DCHECK(params.embedding_token.has_value()); SetEmbeddingToken(params.embedding_token.value()); - renderer_reported_bfcache_disabling_features_.Clear(); + renderer_reported_bfcache_blocking_details_.clear(); browser_reported_bfcache_disabling_features_counts_.clear(); TakeNewDocumentPropertiesFromNavigation(navigation_request); @@ -12815,6 +12857,8 @@ mojo::PendingRemote<network::mojom::URLLoaderFactory> prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory, const absl::optional<blink::ParsedPermissionsPolicy>& permissions_policy, blink::mojom::PolicyContainerPtr policy_container, const blink::DocumentToken& document_token, @@ -12909,7 +12953,8 @@ std::move(subresource_loader_factories), std::move(subresource_overrides), std::move(controller), std::move(container_info), std::move(prefetch_loader_factory), std::move(topics_loader_factory), - document_token, devtools_navigation_token, permissions_policy, + std::move(keep_alive_loader_factory), document_token, + devtools_navigation_token, permissions_policy, std::move(policy_container), std::move(code_cache_host), std::move(cookie_manager_info), std::move(storage_info), BuildCommitNavigationCallback(navigation_request));
diff --git a/content/browser/renderer_host/render_frame_host_impl.h b/content/browser/renderer_host/render_frame_host_impl.h index 1f798b5..442baca 100644 --- a/content/browser/renderer_host/render_frame_host_impl.h +++ b/content/browser/renderer_host/render_frame_host_impl.h
@@ -1832,13 +1832,19 @@ using BackForwardCacheDisablingFeature = blink::scheduler::WebSchedulerTrackedFeature; - // BackForwardCache disabling feature for |this|, used in determing |this| - // frame's BackForwardCache eligibility. - // See comments at |renderer_reported_bfcache_disabling_features_| and + // BackForwardCache disabling feature for |this|, used in determining |this| + // frame's BackForwardCache eligibility. The return value includes all the + // blocking features from browser, renderer and dedicated workers. + // See comments at |renderer_reported_bfcache_blocking_details_| and // |browser_reported_bfcache_disabling_features_|. BackForwardCacheDisablingFeatures GetBackForwardCacheDisablingFeatures() const; - + using BackForwardCacheBlockingDetails = + std::vector<blink::mojom::BlockingDetailsPtr>; + // Returns a vector of blocking details for |this|. This returns more + // information than `GetBackForwardCacheDisablingFeatures()`, which returns + // only a list of features used. + BackForwardCacheBlockingDetails GetBackForwardCacheBlockingDetails() const; using BackForwardCacheDisablingFeaturesCallback = base::RepeatingCallback<void(BackForwardCacheDisablingFeatures)>; void SetBackForwardCacheDisablingFeaturesCallbackForTesting( @@ -2412,8 +2418,7 @@ // blink::mojom::BackForwardCacheControllerHost: void EvictFromBackForwardCache(blink::mojom::RendererEvictionReason) override; - using BackForwardCacheBlockingDetails = - std::vector<blink::mojom::BlockingDetailsPtr>; + void DidChangeBackForwardCacheDisablingFeatures( BackForwardCacheBlockingDetails details) override; @@ -2948,6 +2953,8 @@ prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory, const absl::optional<blink::ParsedPermissionsPolicy>& permissions_policy, blink::mojom::PolicyContainerPtr policy_container, const blink::DocumentToken& document_token, @@ -4549,16 +4556,16 @@ // These values should be cleared on document commit. // // Some features are tracked in these places: - // * `renderer_reported_bfcache_disabling_features_` for features in the - // document in the renderer. + // * `renderer_reported_bfcache_blocking_details_` for features in the + // document in the renderer and the JavaScript locations that used the + // features. // * `browser_reported_bfcache_disabling_features_counts_` for the browser // features. // * `DedicatedWorkerHost` for features used in dedicated workers. // They are tracked separately, because when the renderer updates the set of // features, the browser ones should persist. Also, dedicated workers might be // destroyed while their renderers persist. - BackForwardCacheDisablingFeatures - renderer_reported_bfcache_disabling_features_; + BackForwardCacheBlockingDetails renderer_reported_bfcache_blocking_details_; // Count the usage of BackForwardCacheDisablingFeature. base::flat_map<BackForwardCacheDisablingFeature, int>
diff --git a/content/browser/renderer_host/render_process_host_browsertest.cc b/content/browser/renderer_host/render_process_host_browsertest.cc index 11126a63..fba23b5 100644 --- a/content/browser/renderer_host/render_process_host_browsertest.cc +++ b/content/browser/renderer_host/render_process_host_browsertest.cc
@@ -183,10 +183,10 @@ } // namespace -class RenderProcessHostTest : public ContentBrowserTest, - public RenderProcessHostObserver { +class RenderProcessHostTestBase : public ContentBrowserTest, + public RenderProcessHostObserver { public: - RenderProcessHostTest() = default; + RenderProcessHostTestBase() = default; void SetUpCommandLine(base::CommandLine* command_line) override { command_line->AppendSwitchASCII( @@ -283,7 +283,57 @@ } }; -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, GuestsAreNotSuitableHosts) { +// A ContentBrowserClient that can wait for calls to +// `blink::mojom::KeepAliveHandle`. +class KeepAliveHandleContentBrowserClient + : public ContentBrowserTestContentBrowserClient { + public: + explicit KeepAliveHandleContentBrowserClient(base::OnceClosure callback) { + started_callback_ = std::move(callback); + } + void OnKeepaliveRequestStarted(BrowserContext* browser_context) override { + ContentBrowserTestContentBrowserClient::OnKeepaliveRequestStarted( + browser_context); + CHECK(started_callback_); + GetUIThreadTaskRunner({})->PostTask(FROM_HERE, + std::move(started_callback_)); + } + + private: + base::OnceClosure started_callback_; +}; + +class RenderProcessHostTest : public RenderProcessHostTestBase, + public ::testing::WithParamInterface<bool> { + public: + RenderProcessHostTest() = default; + + void SetUp() override { + if (IsKeepAliveInBrowserMigrationEnabled()) { + feature_list_.InitAndEnableFeature( + blink::features::kKeepAliveInBrowserMigration); + } else { + feature_list_.InitAndDisableFeature( + blink::features::kKeepAliveInBrowserMigration); + } + RenderProcessHostTestBase::SetUp(); + } + + protected: + bool IsKeepAliveInBrowserMigrationEnabled() { return GetParam(); } + + base::test::ScopedFeatureList feature_list_; +}; + +INSTANTIATE_TEST_SUITE_P( + All, + RenderProcessHostTest, + testing::Values(false, true), + [](const testing::TestParamInfo<RenderProcessHostTest::ParamType>& info) { + return info.param ? "KeepAliveInBrowserMigration" : "Default"; + }); + +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, GuestsAreNotSuitableHosts) { // Set max renderers to 1 to force running out of processes. RenderProcessHost::SetMaxRendererProcessCount(1); @@ -308,7 +358,7 @@ EXPECT_EQ(2, RenderProcessHost::GetCurrentRenderProcessCountForTesting()); } -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, SpareRenderProcessHostTaken) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, SpareRenderProcessHostTaken) { ASSERT_TRUE(embedded_test_server()->Start()); RenderProcessHost::WarmupSpareRenderProcessHost( @@ -338,7 +388,7 @@ } } -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, SpareRenderProcessHostNotTaken) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, SpareRenderProcessHostNotTaken) { ASSERT_TRUE(embedded_test_server()->Start()); RenderProcessHost::WarmupSpareRenderProcessHost( @@ -365,7 +415,7 @@ } } -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, SpareRenderProcessHostKilled) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, SpareRenderProcessHostKilled) { RenderProcessHost::WarmupSpareRenderProcessHost( ShellContentBrowserClient::Get()->browser_context()); @@ -392,7 +442,7 @@ // Test that the spare renderer works correctly when the limit on the maximum // number of processes is small. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, SpareRendererSurpressedMaxProcesses) { ASSERT_TRUE(embedded_test_server()->Start()); @@ -435,7 +485,7 @@ } // Check that the spare renderer is dropped if an existing process is reused. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, SpareRendererOnProcessReuse) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, SpareRendererOnProcessReuse) { ASSERT_TRUE(embedded_test_server()->Start()); NonSpareRendererContentBrowserClient browser_client; @@ -475,7 +525,7 @@ // Verifies that the spare renderer maintained by SpareRenderProcessHostManager // is correctly destroyed during browser shutdown. This test is an analogue // to the //chrome-layer FastShutdown.SpareRenderProcessHost test. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, SpareRenderProcessHostDuringShutdown) { content::RenderProcessHost::WarmupSpareRenderProcessHost( shell()->web_contents()->GetBrowserContext()); @@ -486,7 +536,7 @@ // Verifies that the spare renderer maintained by SpareRenderProcessHostManager // is correctly destroyed when closing the last content shell. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, SpareRendererDuringClosing) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, SpareRendererDuringClosing) { content::RenderProcessHost::WarmupSpareRenderProcessHost( shell()->web_contents()->GetBrowserContext()); shell()->web_contents()->Close(); @@ -497,7 +547,7 @@ // This test verifies that SpareRenderProcessHostManager correctly accounts // for StoragePartition differences when handing out the spare process. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, SpareProcessVsCustomStoragePartition) { ASSERT_TRUE(embedded_test_server()->Start()); @@ -591,7 +641,7 @@ // Note: DisableRefCounts() used to be called DisableKeepAliveRefCount(); // the name if this test is left unchanged to avoid disrupt any tracking // tools (e.g. flakiness) that might reference the old name. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, SpareVsDisableKeepAliveRefCount) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, SpareVsDisableKeepAliveRefCount) { RenderProcessHost::WarmupSpareRenderProcessHost( ShellContentBrowserClient::Get()->browser_context()); base::RunLoop().RunUntilIdle(); @@ -620,7 +670,7 @@ } // Check that the spare renderer is properly destroyed via DisableRefCounts(). -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, SpareVsFastShutdown) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, SpareVsFastShutdown) { RenderProcessHost::WarmupSpareRenderProcessHost( ShellContentBrowserClient::Get()->browser_context()); base::RunLoop().RunUntilIdle(); @@ -700,7 +750,7 @@ #define MAYBE_AllProcessExitedCallsBeforeAnyHostDestroyedCalls \ AllProcessExitedCallsBeforeAnyHostDestroyedCalls #endif -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, MAYBE_AllProcessExitedCallsBeforeAnyHostDestroyedCalls) { ASSERT_TRUE(embedded_test_server()->Start()); @@ -739,7 +789,7 @@ logging_string); } -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, KillProcessOnBadMojoMessage) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, KillProcessOnBadMojoMessage) { ASSERT_TRUE(embedded_test_server()->Start()); GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); @@ -822,7 +872,7 @@ #if BUILDFLAG(ENABLE_MOJO_RENDERER) || BUILDFLAG(IS_ANDROID) #define KillProcessZerosAudioStreams DISABLED_KillProcessZerosAudioStreams #endif -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, KillProcessZerosAudioStreams) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, KillProcessZerosAudioStreams) { // TODO(maxmorin): This test only uses an output stream. There should be a // similar test for input streams. embedded_test_server()->ServeFilesFromSourceDirectory( @@ -884,20 +934,20 @@ } // Test class instance to run specific setup steps for capture streams. -class CaptureStreamRenderProcessHostTest : public RenderProcessHostTest { +class CaptureStreamRenderProcessHostTest : public RenderProcessHostTestBase { public: void SetUp() override { // Pixel output is needed when digging pixel values out of video tags for // verification in VideoCaptureStream tests. EnablePixelOutput(); - RenderProcessHostTest::SetUp(); + RenderProcessHostTestBase::SetUp(); } void SetUpCommandLine(base::CommandLine* command_line) override { // These flags are necessary to emulate camera input for getUserMedia() // tests. command_line->AppendSwitch(switches::kUseFakeUIForMediaStream); - RenderProcessHostTest::SetUpCommandLine(command_line); + RenderProcessHostTestBase::SetUpCommandLine(command_line); } }; @@ -1042,7 +1092,7 @@ EXPECT_EQ(0, host_destructions_); } -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, KeepAliveRendererProcess) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, KeepAliveRendererProcess) { embedded_test_server()->RegisterRequestHandler( base::BindRepeating(HandleBeacon)); ASSERT_TRUE(embedded_test_server()->Start()); @@ -1072,6 +1122,13 @@ Observe(rph); rfh->SetKeepAliveTimeoutForTesting(base::Seconds(30)); + if (IsKeepAliveInBrowserMigrationEnabled()) { + // When fetch keepalive in browser migration is enabled, the process will be + // able to exit immediately. Instead of verifying the time it takes until it + // exits, verify that the `keep_alive_ref_count()` is as expected. + EXPECT_EQ(rph->keep_alive_ref_count(), 0); + } + // Navigate to a site that will be in a different process. base::TimeTicks start = base::TimeTicks::Now(); EXPECT_TRUE(NavigateToURL( @@ -1082,7 +1139,7 @@ EXPECT_LT(base::TimeTicks::Now() - start, base::Seconds(30)); } -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, KeepAliveRendererProcessWithServiceWorker) { base::RunLoop run_loop; embedded_test_server()->RegisterRequestHandler( @@ -1109,7 +1166,13 @@ // We are still using the same process. ASSERT_EQ(shell()->web_contents()->GetPrimaryMainFrame()->GetProcess(), rph); // 1 for the service worker, 1 for the keepalive fetch. - EXPECT_EQ(rph->keep_alive_ref_count(), 1); + if (!IsKeepAliveInBrowserMigrationEnabled()) { + EXPECT_EQ(rph->keep_alive_ref_count(), 1); + } else { + // When fetch keepalive in browser migration is enabled, the process will be + // able to exit immediately. + EXPECT_EQ(rph->keep_alive_ref_count(), 0); + } EXPECT_EQ(rph->worker_ref_count(), 1); } @@ -1120,7 +1183,7 @@ #else #define MAYBE_KeepAliveRendererProcess_Hung KeepAliveRendererProcess_Hung #endif -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, MAYBE_KeepAliveRendererProcess_Hung) { // Disable HangWatcher so it doesn't interfere with this test when hangs take // place. @@ -1160,12 +1223,21 @@ Observe(rph); rfh->SetKeepAliveTimeoutForTesting(base::Seconds(1)); + if (IsKeepAliveInBrowserMigrationEnabled()) { + // When fetch keepalive in browser migration is enabled, the process will be + // able to exit immediately. Instead of verifying the time it takes until it + // exits, verify that the `keep_alive_ref_count()` is as expected. + EXPECT_EQ(rph->keep_alive_ref_count(), 0); + } + base::TimeTicks start = base::TimeTicks::Now(); EXPECT_TRUE(NavigateToURL(shell(), GURL("data:text/html,<p>hello</p>"))); WaitUntilProcessExits(1); - EXPECT_GE(base::TimeTicks::Now() - start, base::Seconds(1)); + if (!IsKeepAliveInBrowserMigrationEnabled()) { + EXPECT_GE(base::TimeTicks::Now() - start, base::Seconds(1)); + } } // Test is flaky on Android builders: https://crbug.com/875179 @@ -1176,7 +1248,7 @@ #define MAYBE_FetchKeepAliveRendererProcess_Hung \ FetchKeepAliveRendererProcess_Hung #endif -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, MAYBE_FetchKeepAliveRendererProcess_Hung) { // Disable HangWatcher so it doesn't interfere with this test when hangs take // place. @@ -1218,15 +1290,28 @@ Observe(rph); rfh->SetKeepAliveTimeoutForTesting(base::Seconds(1)); + if (IsKeepAliveInBrowserMigrationEnabled()) { + // Wait for the page to make the keepalive request. + const std::u16string waiting = u"Waiting"; + TitleWatcher watcher(shell()->web_contents(), waiting); + ASSERT_EQ(waiting, watcher.WaitAndGetTitle()); + // When fetch keepalive in browser migration is enabled, the process will be + // able to exit immediately. Instead of verifying the time it takes until it + // exits, verify that the `keep_alive_ref_count()` is as expected. + EXPECT_EQ(rph->keep_alive_ref_count(), 0); + } + base::TimeTicks start = base::TimeTicks::Now(); EXPECT_TRUE(NavigateToURL(shell(), GURL("data:text/html,<p>hello</p>"))); WaitUntilProcessExits(1); - EXPECT_GE(base::TimeTicks::Now() - start, base::Seconds(1)); + if (!IsKeepAliveInBrowserMigrationEnabled()) { + EXPECT_GE(base::TimeTicks::Now() - start, base::Seconds(1)); + } } -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ManyKeepaliveRequests) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, ManyKeepaliveRequests) { auto resolver = base::MakeRefCounted<DelayedHttpResponseWithResolver::Resolver>(); embedded_test_server()->RegisterRequestHandler( @@ -1253,7 +1338,7 @@ } } -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, TooManyKeepaliveRequests) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, TooManyKeepaliveRequests) { embedded_test_server()->RegisterRequestHandler( base::BindRepeating(HandleHungBeacon, base::RepeatingClosure())); ASSERT_TRUE(embedded_test_server()->Start()); @@ -1296,7 +1381,7 @@ host_observation_{this}; }; -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, PriorityOverride) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, PriorityOverride) { // Start up a real renderer process. ASSERT_TRUE(embedded_test_server()->Start()); GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); @@ -1346,7 +1431,7 @@ // This test verifies properties of RenderProcessHostImpl *before* Init method // is called. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ConstructedButNotInitializedYet) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, ConstructedButNotInitializedYet) { RenderProcessHost* process = RenderProcessHostImpl::CreateRenderProcessHost( ShellContentBrowserClient::Get()->browser_context(), nullptr); @@ -1376,7 +1461,7 @@ } // This test verifies that a fast shutdown is possible for a starting process. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, FastShutdownForStartingProcess) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, FastShutdownForStartingProcess) { RenderProcessHost* process = RenderProcessHostImpl::CreateRenderProcessHost( ShellContentBrowserClient::Get()->browser_context(), nullptr); process->Init(); @@ -1384,10 +1469,42 @@ process->Cleanup(); } +// Verifies that a fast shutdown is possible with pending keepalive request. +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, + FastShutdownWithKeepAliveRequest) { + base::RunLoop request_sent_loop, request_handled_loop; + KeepAliveHandleContentBrowserClient browser_client( + request_handled_loop.QuitClosure()); + embedded_test_server()->RegisterRequestHandler( + base::BindRepeating(HandleHungBeacon, request_sent_loop.QuitClosure())); + ASSERT_TRUE(embedded_test_server()->Start()); + + const auto kTestUrl = embedded_test_server()->GetURL("/send-beacon.html"); + ASSERT_TRUE(NavigateToURL(shell(), kTestUrl)); + RenderFrameHostImpl* rfh = static_cast<RenderFrameHostImpl*>( + shell()->web_contents()->GetPrimaryMainFrame()); + RenderProcessHostImpl* rph = + static_cast<RenderProcessHostImpl*>(rfh->GetProcess()); + // Ensure keepalive request is sent. + request_sent_loop.Run(); + + if (IsKeepAliveInBrowserMigrationEnabled()) { + // When fetch keepalive in browser migration is enabled, the process will be + // able to exit immediately. Verify that the `keep_alive_ref_count()` is as + // expected. + EXPECT_EQ(rph->keep_alive_ref_count(), 0); + EXPECT_TRUE(rph->FastShutdownIfPossible()); + } else { + request_handled_loop.Run(); + EXPECT_EQ(rph->keep_alive_ref_count(), 1); + EXPECT_FALSE(rph->FastShutdownIfPossible()); + } +} + // Tests that all RenderFrameHosts that lives in the process are accessible via // RenderProcessHost::ForEachRenderFrameHost(), except those RenderFrameHosts // whose lifecycle states are kSpeculative. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ForEachRenderFrameHost) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, ForEachRenderFrameHost) { ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a = embedded_test_server()->GetURL( "a.com", "/cross_site_iframe_factory.html?a(a(a,a))"); @@ -1538,7 +1655,7 @@ // Ensure that we don't leak a renderer process if there are only non-live // RenderFrameHosts assigned to its RenderProcessHost (e.g., when the last live // frame goes away). See https://crbug.com/1226834. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, AllowUnusedProcessToExit) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, AllowUnusedProcessToExit) { ASSERT_TRUE(embedded_test_server()->Start()); // Ensure all sites get dedicated processes during the test. @@ -1663,7 +1780,7 @@ // Similar to AllowUnusedProcessToExit, for the case that a sad frame from a // previous renderer crash is the only remaining RenderFrameHost in a process. // See https://crbug.com/1226834. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, AllowUnusedProcessToExitAfterCrash) { ASSERT_TRUE(embedded_test_server()->Start()); @@ -1781,7 +1898,7 @@ // among the IPC listeners but is no longer discoverable via FromID, while // handling the deletion of a subframe. One way this can occur is during bfcache // eviction. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, HandleNestedFrameDeletion) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, HandleNestedFrameDeletion) { ASSERT_TRUE(embedded_test_server()->Start()); // Ensure all sites get dedicated processes during the test. @@ -1862,7 +1979,7 @@ // deletions of RenderFrameHost objects, when we might encounter a parent RFH // that is no longer discoverable via FromID, while handling the deletion of a // subframe. One way this can occur is during bfcache eviction. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ForEachFrameNestedFrameDeletion) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, ForEachFrameNestedFrameDeletion) { // This test specifically wants to test with BackForwardCache eviction, so // skip it if BackForwardCache is disabled. if (!IsBackForwardCacheEnabled()) @@ -1911,7 +2028,7 @@ } #if BUILDFLAG(IS_WIN) -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ZeroExecutionTimes) { +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, ZeroExecutionTimes) { // This test only works if the renderer process is sandboxed. if (base::CommandLine::ForCurrentProcess()->HasSwitch( sandbox::policy::switches::kNoSandbox)) { @@ -1935,7 +2052,7 @@ } class RenderProcessHostWriteableFileTest - : public RenderProcessHostTest, + : public RenderProcessHostTestBase, public ::testing::WithParamInterface< std::tuple</*enforcement_enabled=*/bool, /*add_no_execute_flags=*/bool>> { @@ -1944,7 +2061,7 @@ enforcement_feature_.InitWithFeatureState( base::features::kEnforceNoExecutableFileHandles, IsEnforcementEnabled()); - RenderProcessHostTest::SetUp(); + RenderProcessHostTestBase::SetUp(); } protected: @@ -2025,7 +2142,7 @@ // This test verifies that the Pseudonymization salt that is generated in the // browser process is correctly synchronized with a child process, in this case, // two separate renderer processes. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, +IN_PROC_BROWSER_TEST_P(RenderProcessHostTest, SetPseudonymizationSaltSynchronized) { ASSERT_TRUE(embedded_test_server()->Start());
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 1e18f774..e229769 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -2228,8 +2228,11 @@ if (delayed_cleanup_needed_) ret += " dcn"; - if (keep_alive_ref_count_ != 0) + if (keep_alive_ref_count_ != 0) { + CHECK(!base::FeatureList::IsEnabled( + blink::features::kKeepAliveInBrowserMigration)); ret += " karc=" + base::NumberToString(keep_alive_ref_count_); + } if (shutdown_delay_ref_count_ != 0) ret += " sdrc=" + base::NumberToString(shutdown_delay_ref_count_); @@ -2664,12 +2667,18 @@ if (base::FeatureList::IsEnabled(kCheckNoNewRefCountsWhenRphDeletingSoon)) { CHECK(!deleting_soon_); } + CHECK(!base::FeatureList::IsEnabled( + blink::features::kKeepAliveInBrowserMigration)); ++keep_alive_ref_count_; DCHECK(!keep_alive_start_times_.contains(handle_id)); keep_alive_start_times_[handle_id] = base::Time::Now(); } bool RenderProcessHostImpl::AreAllRefCountsZero() { + if (base::FeatureList::IsEnabled( + blink::features::kKeepAliveInBrowserMigration)) { + CHECK_EQ(keep_alive_ref_count_, 0); + } return keep_alive_ref_count_ == 0 && worker_ref_count_ == 0 && shutdown_delay_ref_count_ == 0 && pending_reuse_ref_count_ == 0; } @@ -2677,6 +2686,8 @@ void RenderProcessHostImpl::DecrementKeepAliveRefCount(uint64_t handle_id) { DCHECK_CURRENTLY_ON(BrowserThread::UI); CHECK(!are_ref_counts_disabled_); + CHECK(!base::FeatureList::IsEnabled( + blink::features::kKeepAliveInBrowserMigration)); CHECK_GT(keep_alive_ref_count_, 0); --keep_alive_ref_count_; DCHECK(keep_alive_start_times_.contains(handle_id)); @@ -3647,8 +3658,12 @@ if (!skip_unload_handlers && !SuddenTerminationAllowed()) return false; - if (keep_alive_ref_count_ != 0) + // TODO(crbug.com/1356128): Remove this block once the migration is launched. + if (keep_alive_ref_count_ != 0) { + CHECK(!base::FeatureList::IsEnabled( + blink::features::kKeepAliveInBrowserMigration)); return false; + } if (worker_ref_count_ != 0) return false; @@ -3926,6 +3941,8 @@ }); return; } else if (keep_alive_ref_count_ != 0) { + CHECK(!base::FeatureList::IsEnabled( + blink::features::kKeepAliveInBrowserMigration)); TRACE_EVENT( "shutdown", "RenderProcessHostImpl::Cleanup : Have keep_alive_ref.", ChromeTrackEvent::kRenderProcessHost, *this,
diff --git a/content/browser/renderer_host/render_process_host_impl.h b/content/browser/renderer_host/render_process_host_impl.h index 0430bf5..e3d9292 100644 --- a/content/browser/renderer_host/render_process_host_impl.h +++ b/content/browser/renderer_host/render_process_host_impl.h
@@ -147,7 +147,7 @@ class RenderProcessHostCreationObserver; class RenderProcessHostFactory; class RenderProcessHostPriorityClients; -class RenderProcessHostTest; +class RenderProcessHostTestBase; class RenderWidgetHelper; class SiteInfo; class SiteInstance; @@ -787,7 +787,7 @@ friend class RenderFrameHostImplSubframeReuseBrowserTest_MultipleDelays_Test; friend class VisitRelayingRenderProcessHost; friend class StoragePartitonInterceptor; - friend class RenderProcessHostTest; + friend class RenderProcessHostTestBase; // TODO(crbug.com/1111231): This class is a friend so that it can call our // private mojo implementation methods, acting as a pass-through. This is only // necessary during the associated interface migration, after which,
diff --git a/content/browser/service_worker/service_worker_test_utils.cc b/content/browser/service_worker/service_worker_test_utils.cc index a370a53..15e3ff9 100644 --- a/content/browser/service_worker/service_worker_test_utils.cc +++ b/content/browser/service_worker/service_worker_test_utils.cc
@@ -95,6 +95,8 @@ prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory, const blink::DocumentToken& document_token, const base::UnguessableToken& devtools_navigation_token, const absl::optional<blink::ParsedPermissionsPolicy>& permissions_policy, @@ -261,8 +263,11 @@ blink::CreateCommitNavigationParams(), network::mojom::URLResponseHead::New(), mojo::ScopedDataPipeConsumerHandle(), nullptr, nullptr, absl::nullopt, - nullptr, std::move(info), mojo::NullRemote(), mojo::NullRemote(), - blink::DocumentToken(), base::UnguessableToken::Create(), + nullptr, std::move(info), + /*prefetch_loader_factory=*/mojo::NullRemote(), + /*topics_loader_factory=*/mojo::NullRemote(), + /*keep_alive_loader_factory=*/mojo::NullRemote(), blink::DocumentToken(), + base::UnguessableToken::Create(), std::vector<blink::ParsedPermissionsPolicyDeclaration>(), CreateStubPolicyContainer(), mojo::NullRemote(), nullptr, nullptr, base::BindOnce(
diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc index 34c850bb0..f3bc508 100644 --- a/content/browser/storage_partition_impl.cc +++ b/content/browser/storage_partition_impl.cc
@@ -75,6 +75,7 @@ #include "content/browser/host_zoom_level_context.h" #include "content/browser/indexed_db/indexed_db_control_wrapper.h" #include "content/browser/interest_group/interest_group_manager_impl.h" +#include "content/browser/loader/keep_alive_url_loader_service.h" #include "content/browser/loader/prefetch_url_loader_service.h" #include "content/browser/locks/lock_manager.h" #include "content/browser/navigation_or_document_handle.h" @@ -1413,6 +1414,12 @@ std::make_unique<BrowsingTopicsURLLoaderService>(); } + if (base::FeatureList::IsEnabled( + blink::features::kKeepAliveInBrowserMigration)) { + keep_alive_url_loader_service_ = + std::make_unique<KeepAliveURLLoaderService>(); + } + cookie_store_manager_ = std::make_unique<CookieStoreManager>(service_worker_context_); // Unit tests use the LoadAllSubscriptions() callback to crash early if @@ -1742,6 +1749,12 @@ return browsing_topics_url_loader_service_.get(); } +KeepAliveURLLoaderService* +StoragePartitionImpl::GetKeepAliveURLLoaderService() { + DCHECK(initialized_); + return keep_alive_url_loader_service_.get(); +} + CookieStoreManager* StoragePartitionImpl::GetCookieStoreManager() { DCHECK(initialized_); return cookie_store_manager_.get();
diff --git a/content/browser/storage_partition_impl.h b/content/browser/storage_partition_impl.h index 677bdc8..5b3dd24a 100644 --- a/content/browser/storage_partition_impl.h +++ b/content/browser/storage_partition_impl.h
@@ -72,6 +72,7 @@ class BroadcastChannelService; class BrowsingDataFilterBuilder; class BrowsingTopicsURLLoaderService; +class KeepAliveURLLoaderService; class BucketManager; class CacheStorageControlWrapper; class CookieStoreManager; @@ -254,6 +255,7 @@ storage::BlobUrlRegistry* GetBlobUrlRegistry(); PrefetchURLLoaderService* GetPrefetchURLLoaderService(); BrowsingTopicsURLLoaderService* GetBrowsingTopicsURLLoaderService(); + KeepAliveURLLoaderService* GetKeepAliveURLLoaderService(); CookieStoreManager* GetCookieStoreManager(); FileSystemAccessManagerImpl* GetFileSystemAccessManager(); BucketManager* GetBucketManager(); @@ -648,6 +650,7 @@ std::unique_ptr<PrefetchURLLoaderService> prefetch_url_loader_service_; std::unique_ptr<BrowsingTopicsURLLoaderService> browsing_topics_url_loader_service_; + std::unique_ptr<KeepAliveURLLoaderService> keep_alive_url_loader_service_; std::unique_ptr<CookieStoreManager> cookie_store_manager_; std::unique_ptr<BucketManager> bucket_manager_; scoped_refptr<GeneratedCodeCacheContext> generated_code_cache_context_;
diff --git a/content/browser/web_contents/web_contents_impl_browsertest.cc b/content/browser/web_contents/web_contents_impl_browsertest.cc index cf02d4d5..7c4cb53 100644 --- a/content/browser/web_contents/web_contents_impl_browsertest.cc +++ b/content/browser/web_contents/web_contents_impl_browsertest.cc
@@ -7,7 +7,6 @@ #include <utility> #include <vector> -#include "base/allocator/partition_alloc_features.h" #include "base/allocator/partition_allocator/partition_alloc_buildflags.h" #include "base/command_line.h" #include "base/containers/contains.h" @@ -5927,24 +5926,7 @@ // Initialize PCScanFeature before WebContentsImplBrowserTest to make sure that // the feature is enabled within the entire lifetime of the test. class WebContentsImplStarScanBrowserTest : private PCScanFeature, - public WebContentsImplBrowserTest { - public: - void SetUp() override { - // Since ReconfigureAfterFeatureListInit() has been already invoked at - // FeatureListScopedToEachTest::OnTestStart(), we cannot enable PCScan - // and cannot re-reconfigure partition roots here. This causes DCHECK() - // failure at PerfromcScan(). - if (!base::FeatureList::IsEnabled(base::features::kPartitionAllocPCScan) && - !base::FeatureList::IsEnabled( - base::features::kPartitionAllocPCScanBrowserOnly) && - !base::FeatureList::IsEnabled( - base::features::kPartitionAllocPCScanRendererOnly)) { - GTEST_SKIP() << "PCScanFeature is not enabled. Need --enable-features" - << "=PartitionAllocPCScan"; - } - WebContentsImplBrowserTest::SetUp(); - } -}; + public WebContentsImplBrowserTest {}; } // namespace
diff --git a/content/browser/webrtc/resources/candidate_grid.js b/content/browser/webrtc/resources/candidate_grid.js index f0fce46..d7a8890 100644 --- a/content/browser/webrtc/resources/candidate_grid.js +++ b/content/browser/webrtc/resources/candidate_grid.js
@@ -134,8 +134,16 @@ localRow.children[index].innerText += '\n' + localCandidate.url; } } else if (stat === 'priority') { - localRow.children[index].innerText = '0x' + - parseInt(localCandidate[stat], 10).toString(16); + const priority = parseInt(localCandidate[stat], 10) & 0xFFFFFFFF; + localRow.children[index].innerText = '0x' + priority.toString(16) + + // RFC 5245 - 4.1.2.1. + // priority = (2^24)*(type preference) + + // (2^8)*(local preference) + + // (2^0)*(256 - component ID) + '\n' + (priority >> 24) + + ' | ' + ((priority >> 8) & 0xFFFF) + + ' | ' + (priority & 0xFF); + } else { localRow.children[index].innerText = localCandidate[stat]; }
diff --git a/content/browser/webrtc/webrtc_audio_debug_recordings_browsertest.cc b/content/browser/webrtc/webrtc_audio_debug_recordings_browsertest.cc index fb17dc8..a7c9d2d4 100644 --- a/content/browser/webrtc/webrtc_audio_debug_recordings_browsertest.cc +++ b/content/browser/webrtc/webrtc_audio_debug_recordings_browsertest.cc
@@ -143,7 +143,7 @@ // Make a call. GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); EXPECT_TRUE(NavigateToURL(shell(), url)); - ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});"); + EXPECT_EQ("OK", EvalJsInShell("call({video: true, audio: true});")); EXPECT_EQ("OK", EvalJsInShell("hangup();")); WebRTCInternals::GetInstance()->DisableAudioDebugRecordings(); @@ -233,7 +233,7 @@ // Make a call. GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); EXPECT_TRUE(NavigateToURL(shell(), url)); - ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});"); + EXPECT_EQ("OK", EvalJsInShell("call({video: true, audio: true});")); EXPECT_EQ("OK", EvalJsInShell("hangup();")); // Verify that no files exist and remove temp dir. @@ -284,9 +284,8 @@ GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); EXPECT_TRUE(NavigateToURL(shell(), url)); EXPECT_TRUE(NavigateToURL(shell2, url)); - ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});"); - EXPECT_EQ("OK", EvalJs(shell2, "call({video: true, audio: true});", - EXECUTE_SCRIPT_USE_MANUAL_REPLY)); + EXPECT_EQ("OK", EvalJsInShell("call({video: true, audio: true});")); + EXPECT_EQ("OK", EvalJs(shell2, "call({video: true, audio: true});")); EXPECT_EQ("OK", EvalJsInShell("hangup();")); EXPECT_EQ("OK", EvalJs(shell2, "hangup();"));
diff --git a/content/browser/webrtc/webrtc_browsertest.cc b/content/browser/webrtc/webrtc_browsertest.cc index 9e591e5..327f6b67 100644 --- a/content/browser/webrtc/webrtc_browsertest.cc +++ b/content/browser/webrtc/webrtc_browsertest.cc
@@ -49,8 +49,10 @@ protected: // Convenience function since most peerconnection-call.html tests just load // the page, kick off some javascript and wait for the title to change to OK. - void MakeTypicalPeerConnectionCall(const std::string& javascript) { - MakeTypicalCall(javascript, "/media/peerconnection-call.html"); + void MakeTypicalPeerConnectionCall(const std::string& javascript, + bool use_manual_reply = true) { + MakeTypicalCall(javascript, "/media/peerconnection-call.html", + use_manual_reply); } void SetConfigurationTest(const std::string& javascript) { @@ -61,7 +63,8 @@ }; IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserTest, CanSetupAudioAndVideoCall) { - MakeTypicalPeerConnectionCall("call({video: true, audio: true});"); + MakeTypicalPeerConnectionCall("call({video: true, audio: true});", + /*use_manual_reply=*/false); } // Flaky on Android and Linux ASAN https://crbug.com/1099365. @@ -75,9 +78,11 @@ MAYBE_NetworkProcessCrashRecovery) { if (!IsOutOfProcessNetworkService()) return; - MakeTypicalPeerConnectionCall("call({video: true, audio: true});"); + MakeTypicalPeerConnectionCall("call({video: true, audio: true});", + /*use_manual_reply=*/false); SimulateNetworkServiceCrash(); - MakeTypicalPeerConnectionCall("call({video: true, audio: true});"); + MakeTypicalPeerConnectionCall("call({video: true, audio: true});", + /*use_manual_reply=*/false); } IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserTest, @@ -192,20 +197,23 @@ #endif IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserTest, MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle) { - MakeTypicalPeerConnectionCall("callWithoutMsidAndBundle();"); + MakeTypicalPeerConnectionCall("callWithoutMsidAndBundle();", + /*use_manual_reply=*/false); } // This test will modify the SDP offer to an unsupported codec, which should // cause SetLocalDescription to fail. IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserTest, NegotiateUnsupportedVideoCodec) { - MakeTypicalPeerConnectionCall("negotiateUnsupportedVideoCodec();"); + MakeTypicalPeerConnectionCall("negotiateUnsupportedVideoCodec();", + /*use_manual_reply=*/false); } // This test will modify the SDP offer to use no encryption, which should // cause SetLocalDescription to fail. IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserTest, NegotiateNonCryptoCall) { - MakeTypicalPeerConnectionCall("negotiateNonCryptoCall();"); + MakeTypicalPeerConnectionCall("negotiateNonCryptoCall();", + /*use_manual_reply=*/false); } // This test can negotiate an SDP offer that includes a b=AS:xx to control @@ -235,7 +243,8 @@ } IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserTest, CallInsideIframe) { - MakeTypicalPeerConnectionCall("callInsideIframe({video: true, audio:true});"); + MakeTypicalPeerConnectionCall("callInsideIframe({video: true, audio:true});", + /*use_manual_reply=*/false); } // Tests that SetConfiguration succeeds and triggers an ICE restart on the next
diff --git a/content/browser/webrtc/webrtc_content_browsertest_base.cc b/content/browser/webrtc/webrtc_content_browsertest_base.cc index 83af1b7..6c75fcc 100644 --- a/content/browser/webrtc/webrtc_content_browsertest_base.cc +++ b/content/browser/webrtc/webrtc_content_browsertest_base.cc
@@ -72,21 +72,20 @@ void WebRtcContentBrowserTestBase::MakeTypicalCall( const std::string& javascript, - const std::string& html_file) { + const std::string& html_file, + bool use_manual_reply) { if (!embedded_test_server()->Started()) ASSERT_TRUE(embedded_test_server()->Start()); GURL url(embedded_test_server()->GetURL(html_file)); EXPECT_TRUE(NavigateToURL(shell(), url)); - ExecuteJavascriptAndWaitForOk(javascript); -} + int options = EXECUTE_SCRIPT_DEFAULT_OPTIONS; + if (use_manual_reply) { + options |= EXECUTE_SCRIPT_USE_MANUAL_REPLY; + } -void WebRtcContentBrowserTestBase::ExecuteJavascriptAndWaitForOk( - const std::string& javascript) { - std::string result = - EvalJs(shell(), javascript, EXECUTE_SCRIPT_USE_MANUAL_REPLY) - .ExtractString(); + std::string result = EvalJs(shell(), javascript, options).ExtractString(); if (result != "OK") { if (result.empty()) result = "(nothing)"; @@ -94,7 +93,7 @@ javascript.c_str()); FAIL(); } - } +} std::string WebRtcContentBrowserTestBase::GenerateGetUserMediaCall( const char* function_name,
diff --git a/content/browser/webrtc/webrtc_content_browsertest_base.h b/content/browser/webrtc/webrtc_content_browsertest_base.h index 97e86127..247bffa 100644 --- a/content/browser/webrtc/webrtc_content_browsertest_base.h +++ b/content/browser/webrtc/webrtc_content_browsertest_base.h
@@ -28,13 +28,10 @@ // last-evaluated statement, which must be a string. std::string EvalJsInShell(const std::string& javascript); - // Waits for the javascript to return OK via the automation controller. - // If the javascript returns != OK or times out, we fail the test. - void ExecuteJavascriptAndWaitForOk(const std::string& javascript); - // Execute a typical javascript call after having started the webserver. void MakeTypicalCall(const std::string& javascript, - const std::string& html_file); + const std::string& html_file, + bool use_manual_reply = true); // Generates javascript code for a getUserMedia call. std::string GenerateGetUserMediaCall(const char* function_name,
diff --git a/content/browser/webrtc/webrtc_internals_browsertest.cc b/content/browser/webrtc/webrtc_internals_browsertest.cc index c9ec163..62955d4 100644 --- a/content/browser/webrtc/webrtc_internals_browsertest.cc +++ b/content/browser/webrtc/webrtc_internals_browsertest.cc
@@ -686,7 +686,7 @@ ASSERT_TRUE(embedded_test_server()->Start()); GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); EXPECT_TRUE(NavigateToURL(shell(), url)); - ASSERT_TRUE(ExecuteJavascript("call({video:true});")); + ASSERT_EQ(true, EvalJs(shell(), "call({video:true});")); ExpectTitle("OK"); // Open webrtc-internals in the second window.
diff --git a/content/browser/worker_host/dedicated_worker_host.cc b/content/browser/worker_host/dedicated_worker_host.cc index 0f14f38..787f8ad 100644 --- a/content/browser/worker_host/dedicated_worker_host.cc +++ b/content/browser/worker_host/dedicated_worker_host.cc
@@ -959,12 +959,7 @@ // The frame may have already been closed. return; } - bfcache_disabling_features_.Clear(); - for (auto& feature_details : details) { - bfcache_disabling_features_.Put( - static_cast<blink::scheduler::WebSchedulerTrackedFeature>( - feature_details->feature)); - } + bfcache_blocking_details_ = std::move(details); ancestor_render_frame_host->MaybeEvictFromBackForwardCache(); } @@ -1016,7 +1011,17 @@ blink::scheduler::WebSchedulerTrackedFeatures DedicatedWorkerHost::GetBackForwardCacheDisablingFeatures() const { - return bfcache_disabling_features_; + blink::scheduler::WebSchedulerTrackedFeatures features; + for (auto& details : bfcache_blocking_details_) { + features.Put(static_cast<blink::scheduler::WebSchedulerTrackedFeature>( + details->feature)); + } + return features; +} + +const DedicatedWorkerHost::BackForwardCacheBlockingDetails& +DedicatedWorkerHost::GetBackForwardCacheBlockingDetails() const { + return bfcache_blocking_details_; } base::WeakPtr<ServiceWorkerContainerHost>
diff --git a/content/browser/worker_host/dedicated_worker_host.h b/content/browser/worker_host/dedicated_worker_host.h index 1b50807..e719b16 100644 --- a/content/browser/worker_host/dedicated_worker_host.h +++ b/content/browser/worker_host/dedicated_worker_host.h
@@ -228,6 +228,9 @@ blink::scheduler::WebSchedulerTrackedFeatures GetBackForwardCacheDisablingFeatures() const; + const BackForwardCacheBlockingDetails& GetBackForwardCacheBlockingDetails() + const; + base::WeakPtr<ServiceWorkerContainerHost> GetServiceWorkerContainerHost(); mojo::PendingRemote<blink::mojom::BackForwardCacheControllerHost> @@ -413,7 +416,7 @@ // JavaScript / WebAssembly resources. CodeCacheHostImpl::ReceiverSet code_cache_host_receivers_; - blink::scheduler::WebSchedulerTrackedFeatures bfcache_disabling_features_; + BackForwardCacheBlockingDetails bfcache_blocking_details_; base::WeakPtrFactory<DedicatedWorkerHost> weak_factory_{this}; };
diff --git a/content/browser/worker_host/dedicated_worker_hosts_for_document.cc b/content/browser/worker_host/dedicated_worker_hosts_for_document.cc index 04da591..8f56dca 100644 --- a/content/browser/worker_host/dedicated_worker_hosts_for_document.cc +++ b/content/browser/worker_host/dedicated_worker_hosts_for_document.cc
@@ -4,6 +4,7 @@ #include "content/browser/worker_host/dedicated_worker_hosts_for_document.h" +#include "content/browser/renderer_host/render_frame_host_impl.h" #include "content/browser/service_worker/service_worker_container_host.h" #include "content/browser/worker_host/dedicated_worker_host.h" @@ -31,13 +32,26 @@ blink::scheduler::WebSchedulerTrackedFeatures DedicatedWorkerHostsForDocument::GetBackForwardCacheDisablingFeatures() const { - blink::scheduler::WebSchedulerTrackedFeatures features; - for (auto worker : dedicated_workers_) { - features.PutAll(worker->GetBackForwardCacheDisablingFeatures()); + RenderFrameHostImpl::BackForwardCacheDisablingFeatures features; + for (auto& feature_detail : GetBackForwardCacheBlockingDetails()) { + features.Put(static_cast<blink::scheduler::WebSchedulerTrackedFeature>( + feature_detail->feature)); } return features; } +DedicatedWorkerHost::BackForwardCacheBlockingDetails +DedicatedWorkerHostsForDocument::GetBackForwardCacheBlockingDetails() const { + DedicatedWorkerHost::BackForwardCacheBlockingDetails combined_details; + for (auto worker : dedicated_workers_) { + auto& details_for_worker = worker->GetBackForwardCacheBlockingDetails(); + for (auto& details : details_for_worker) { + combined_details.push_back(details.Clone()); + } + } + return combined_details; +} + void DedicatedWorkerHostsForDocument::OnEnterBackForwardCache() { DCHECK(BackForwardCache::IsBackForwardCacheFeatureEnabled()); DCHECK_EQ(render_frame_host().GetLifecycleState(),
diff --git a/content/browser/worker_host/dedicated_worker_hosts_for_document.h b/content/browser/worker_host/dedicated_worker_hosts_for_document.h index b2621dc7..d5de317 100644 --- a/content/browser/worker_host/dedicated_worker_hosts_for_document.h +++ b/content/browser/worker_host/dedicated_worker_hosts_for_document.h
@@ -7,14 +7,13 @@ #include "base/containers/flat_set.h" #include "base/memory/safe_ref.h" +#include "content/browser/worker_host/dedicated_worker_host.h" #include "content/common/content_export.h" #include "content/public/browser/document_user_data.h" #include "third_party/blink/public/common/scheduler/web_scheduler_tracked_feature.h" namespace content { -class DedicatedWorkerHost; - // Manages the set of dedicated workers whose ancestor is this document. This // class is exported for testing. class CONTENT_EXPORT DedicatedWorkerHostsForDocument @@ -34,6 +33,9 @@ blink::scheduler::WebSchedulerTrackedFeatures GetBackForwardCacheDisablingFeatures() const; + DedicatedWorkerHost::BackForwardCacheBlockingDetails + GetBackForwardCacheBlockingDetails() const; + // Called when the page is put into back/forward cache. void OnEnterBackForwardCache();
diff --git a/content/common/navigation_client.mojom b/content/common/navigation_client.mojom index 03b1251..c06018c 100644 --- a/content/common/navigation_client.mojom +++ b/content/common/navigation_client.mojom
@@ -254,6 +254,10 @@ // (https://github.com/patcg-individual-drafts/topics) via the browser // process. // + // |keep_alive_loader_factory| is used to handle fetch keepalive requests via + // the browser process. + // See https://docs.google.com/document/d/1ZzxMMBvpqn8VZBZKnb7Go8TWjnrGcXuLS_USwVVRUvY + // // For automation driver-initiated navigations over the devtools protocol, // |devtools_navigation_token_| is used to tag the navigation. This navigation // token is then sent into the renderer and lands on the DocumentLoader. That @@ -282,6 +286,7 @@ blink.mojom.ServiceWorkerContainerInfoForClient? container_info, pending_remote<network.mojom.URLLoaderFactory>? prefetch_loader_factory, pending_remote<network.mojom.URLLoaderFactory>? topics_loader_factory, + pending_remote<network.mojom.URLLoaderFactory>? keep_alive_loader_factory, blink.mojom.DocumentToken document_token, mojo_base.mojom.UnguessableToken devtools_navigation_token, array<blink.mojom.ParsedPermissionsPolicyDeclaration>? permissions_policy,
diff --git a/content/public/browser/desktop_capture.cc b/content/public/browser/desktop_capture.cc index 1a7301d..26c02f4 100644 --- a/content/public/browser/desktop_capture.cc +++ b/content/public/browser/desktop_capture.cc
@@ -30,13 +30,13 @@ // Leave desktop effects enabled during WebRTC captures. options.set_disable_effects(false); #if BUILDFLAG(IS_WIN) + // TODO(crbug.com/webrtc/15045): Possibly remove this flag. Keeping for now + // to force fallback to GDI. static BASE_FEATURE(kDirectXCapturer, "DirectXCapturer", base::FEATURE_ENABLED_BY_DEFAULT); if (base::FeatureList::IsEnabled(kDirectXCapturer)) { + // Results in DirectX as main capture API and GDI as fallback solution. options.set_allow_directx_capturer(true); - options.set_allow_use_magnification_api(false); - } else { - options.set_allow_use_magnification_api(true); } options.set_enumerate_current_process_windows( ShouldEnumerateCurrentProcessWindows());
diff --git a/content/renderer/navigation_client.cc b/content/renderer/navigation_client.cc index 808d7bf..bd825c5b 100644 --- a/content/renderer/navigation_client.cc +++ b/content/renderer/navigation_client.cc
@@ -38,6 +38,8 @@ mojo::PendingRemote<network::mojom::URLLoaderFactory> prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory, const blink::DocumentToken& document_token, const base::UnguessableToken& devtools_navigation_token, const absl::optional<blink::ParsedPermissionsPolicy>& permissions_policy, @@ -60,7 +62,8 @@ std::move(subresource_overrides), std::move(controller_service_worker_info), std::move(container_info), std::move(prefetch_loader_factory), std::move(topics_loader_factory), - document_token, devtools_navigation_token, permissions_policy, + std::move(keep_alive_loader_factory), document_token, + devtools_navigation_token, permissions_policy, std::move(policy_container), std::move(code_cache_host), std::move(cookie_manager_info), std::move(storage_info), std::move(callback));
diff --git a/content/renderer/navigation_client.h b/content/renderer/navigation_client.h index 4428b6d..d26c061 100644 --- a/content/renderer/navigation_client.h +++ b/content/renderer/navigation_client.h
@@ -38,6 +38,8 @@ prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory, const blink::DocumentToken& document_token, const base::UnguessableToken& devtools_navigation_token, const absl::optional<blink::ParsedPermissionsPolicy>& permissions_policy,
diff --git a/content/renderer/pepper/pepper_graphics_2d_host.cc b/content/renderer/pepper/pepper_graphics_2d_host.cc index 2c6a701d1..a62621e 100644 --- a/content/renderer/pepper/pepper_graphics_2d_host.cc +++ b/content/renderer/pepper/pepper_graphics_2d_host.cc
@@ -759,7 +759,8 @@ image_data_->Unmap(); *transferable_resource = viz::TransferableResource::MakeSoftware( - shared_bitmap->id(), pixel_image_size, viz::RGBA_8888); + shared_bitmap->id(), pixel_image_size, + viz::SinglePlaneFormat::kRGBA_8888); *release_callback = base::BindOnce( &PepperGraphics2DHost::ReleaseSoftwareCallback, this->AsWeakPtr(), std::move(shared_bitmap), std::move(registration));
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 91f25d7..c54f4bed 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc
@@ -1499,7 +1499,8 @@ std::move(params->subresource_loader_factories), /*subresource_overrides=*/absl::nullopt, /*prefetch_loader_factory=*/mojo::NullRemote(), - /*topics_loader_factory=*/mojo::NullRemote()); + /*topics_loader_factory=*/mojo::NullRemote(), + /*keep_alive_loader_factory=*/mojo::NullRemote()); } return render_frame; @@ -2529,6 +2530,8 @@ mojo::PendingRemote<network::mojom::URLLoaderFactory> prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory, const blink::DocumentToken& document_token, const base::UnguessableToken& devtools_navigation_token, const absl::optional<blink::ParsedPermissionsPolicy>& permissions_policy, @@ -2590,8 +2593,9 @@ std::move(subresource_loader_factories), std::move(subresource_overrides), std::move(controller_service_worker_info), std::move(container_info), std::move(prefetch_loader_factory), std::move(topics_loader_factory), - std::move(code_cache_host), std::move(cookie_manager_info), - std::move(storage_info), std::move(document_state)); + std::move(keep_alive_loader_factory), std::move(code_cache_host), + std::move(cookie_manager_info), std::move(storage_info), + std::move(document_state)); // Handle a navigation that has a non-empty `data_url_as_string`, or perform // a "loadDataWithBaseURL" navigation, which is different from a normal data: @@ -2709,6 +2713,8 @@ mojo::PendingRemote<network::mojom::URLLoaderFactory> prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory, mojo::PendingRemote<blink::mojom::CodeCacheHost> code_cache_host, mojom::CookieManagerInfoPtr cookie_manager_info, mojom::StorageInfoPtr storage_info, @@ -2724,7 +2730,8 @@ CreateLoaderFactoryBundle(std::move(subresource_loader_factories), std::move(subresource_overrides), std::move(prefetch_loader_factory), - std::move(topics_loader_factory)); + std::move(topics_loader_factory), + std::move(keep_alive_loader_factory)); DCHECK(new_loader_factories); DCHECK(new_loader_factories->HasBoundDefaultFactory()); @@ -2861,7 +2868,8 @@ std::move(subresource_loader_factories), absl::nullopt /* subresource_overrides */, mojo::NullRemote() /* prefetch_loader_factory */, - mojo::NullRemote() /* topics_loader_factory */); + mojo::NullRemote() /* topics_loader_factory */, + mojo::NullRemote() /* keep_alive_loader_factory */); DCHECK(new_loader_factories->HasBoundDefaultFactory()); // Send the provisional load failure. @@ -5516,8 +5524,9 @@ subresource_overrides, mojo::PendingRemote<network::mojom::URLLoaderFactory> prefetch_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> topics_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> - topics_loader_factory) { + keep_alive_loader_factory) { DCHECK(info); // We don't check `DCHECK(info->pending_default_factory())`, because it will // be missing for speculative frames (and in other cases where no subresource @@ -5542,6 +5551,10 @@ if (topics_loader_factory) { loader_factories->SetTopicsLoaderFactory(std::move(topics_loader_factory)); } + if (keep_alive_loader_factory) { + loader_factories->SetKeepAliveLoaderFactory( + std::move(keep_alive_loader_factory)); + } return loader_factories; } @@ -6010,7 +6023,8 @@ network::NotImplementedURLLoaderFactory::Create()), /*subresource_overrides=*/absl::nullopt, /*prefetch_loader_factory=*/{}, - /*topics_loader_factory=*/{}); + /*topics_loader_factory=*/{}, + /*keep_alive_loader_factory=*/{}); auto navigation_params = std::make_unique<WebNavigationParams>(); navigation_params->url = base_url;
diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index 07e9bb1..a441c84 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h
@@ -451,6 +451,8 @@ prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory, const blink::DocumentToken& document_token, const base::UnguessableToken& devtools_navigation_token, const absl::optional<blink::ParsedPermissionsPolicy>& permissions_policy, @@ -907,7 +909,9 @@ mojo::PendingRemote<network::mojom::URLLoaderFactory> prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> - topics_loader_factory); + topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory); // Update current main frame's encoding and send it to browser window. // Since we want to let users see the right encoding info from menu @@ -973,6 +977,8 @@ prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory, mojo::PendingRemote<blink::mojom::CodeCacheHost> code_cache_host, mojom::CookieManagerInfoPtr cookie_manager_info, mojom::StorageInfoPtr storage_info,
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index 07e327ec..7e3bbee 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn
@@ -1347,6 +1347,7 @@ "../browser/loader/cross_site_document_blocking_browsertest.cc", "../browser/loader/derived_origin_in_fetch_browsertest.cc", "../browser/loader/file_url_loader_factory_browsertest.cc", + "../browser/loader/keep_alive_url_browsertest.cc", "../browser/loader/loader_browsertest.cc", "../browser/loader/navigation_early_hints_browsertest.cc", "../browser/loader/prefetch_browsertest.cc",
diff --git a/content/test/content_unittests_bundle_data.filelist b/content/test/content_unittests_bundle_data.filelist index 332c2f9..f458bff 100644 --- a/content/test/content_unittests_bundle_data.filelist +++ b/content/test/content_unittests_bundle_data.filelist
@@ -780,6 +780,7 @@ data/gpu/vc/teddy3_vp9_320x180_30fps.webm data/gpu/vc/video_utils.js data/gpu/vc/videos_mxn.html +data/gpu/vc/webgl2_videos_mxn.html data/gpu/vc/webgl_video.js data/gpu/vc/webgl_videos_mxn.html data/gpu/vc/webgpu_video.js
diff --git a/content/test/data/fetch-keepalive.html b/content/test/data/fetch-keepalive.html index 59e27da..215f567 100644 --- a/content/test/data/fetch-keepalive.html +++ b/content/test/data/fetch-keepalive.html
@@ -1,16 +1,25 @@ <!doctype html> +<!-- + This page loads the given number of fetch keepalive requests, and then waits for their responses. +--> <title>Fetching</title> <script> -const params = new URL(location.href).searchParams; -const numRequests = params.has('requests') ? Number(params.get('requests')) : 1; +const PARAMS = new URL(location.href).searchParams; +const NUM_REQUESTS= PARAMS.has('requests') ? Number(PARAMS.get('requests')) : 1; +const METHOD = PARAMS.get('method') || 'GET'; + const promises = []; -for (let i = 0; i < numRequests; i += 1) { - promises.push(fetch('/beacon', {keepalive: true, cache: 'no-store'})); +for (let i = 0; i < NUM_REQUESTS; i += 1) { + promises.push(fetch('/beacon', { + keepalive: true, + cache: 'no-store', + method: METHOD + })); } document.title = 'Waiting'; Promise.all(promises).then(() => { - document.title = 'Resolved'; + document.title = 'Resolved'; }, () => { - document.title = 'Rejected'; + document.title = 'Rejected'; }); </script>
diff --git a/content/test/data/gpu/vc/README.md b/content/test/data/gpu/vc/README.md index f005a7d..25314a5 100644 --- a/content/test/data/gpu/vc/README.md +++ b/content/test/data/gpu/vc/README.md
@@ -26,6 +26,7 @@ with CSS icons. ### webgl_videos_mxn.html +### webgl2_videos_mxn.html PLEASE RUN http-server TO SERVE THIS DEMO, OTHERWISE THIS DEMO WILL NOT START. The image of each video frame is uploaded and rendered by WebGL. The UI is also rendered by WebGL. The demo uses texImage2D API to copy the video textures into GPU. @@ -56,7 +57,7 @@ webgpu_videos_mxn.html?codec=vp8 ``` -For webgl_videos_mxn.html and webgpu_videos_mxn.html: +For webgl_videos_mxn.html, webgl2_videos_mxn.html and webgpu_videos_mxn.html: To remove the UI icons. Use `ui=none`. ``` webgpu_videos_mxn.html?ui=none @@ -74,10 +75,20 @@ To disable the 30fps cap in the sample. Use `cap_ui_fps=0` ``` - webgpu_videos_mxn.html?cap_ui_fps=0 ``` +To show a local webcam stream. Use `use_local_camera=1` +``` +webgpu_videos_mxn.html?use_local_camera=1 +``` + +For webgl2_videos_mxn.html only: +To use fixed texture size via texStorage2D, use `fixed_texture_size=1`. +``` +webgl2_videos_mxn.html?fixed_texture_size=1 +``` + For webgpu_videos_mxn.html only: To disable Import Texture API and force the video texture copy through createImageBitmap() and then copyExternalImageToTexture(), @@ -89,7 +100,6 @@ To disable using onSubmittedWorkDone to workaround webgpu backpressure issue(may hurt performance). Use `back_pressure_workaround=0` ``` - webgpu_videos_mxn.html?back_pressure_workaround=0 ```
diff --git a/content/test/data/gpu/vc/video_utils.js b/content/test/data/gpu/vc/video_utils.js index 5c7e505..b95ef04b 100644 --- a/content/test/data/gpu/vc/video_utils.js +++ b/content/test/data/gpu/vc/video_utils.js
@@ -20,12 +20,13 @@ if (videoCount <= 4 || useLargeSizeVideo) { return './teddy1_vp8_640x360_30fps.webm'; } else { - if (index < 4) + if (index < 4) { return './teddy3_vp8_320x180_30fps.webm'; - else if (index < 16) + } else if (index < 16) { return './teddy2_vp8_320x180_15fps.webm'; - else + } else { return './teddy1_vp8_320x180_7fps.webm'; + } } break; @@ -34,19 +35,20 @@ if (videoCount <= 4 || useLargeSizeVideo) { return './teddy1_vp9_640x360_30fps.webm'; } else { - if (index < 4) + if (index < 4) { return './teddy3_vp9_320x180_30fps.webm'; - else if (index < 16) + } else if (index < 16) { return './teddy2_vp9_320x180_15fps.webm'; - else + } else { return './teddy1_vp9_320x180_7fps.webm'; + } } break; } } function getArrayForVideoVertexBuffer(videos, videoRows, videoColumns) { - // Each video takes 6 vertices (2 triangles). Each vertice has 4 floats. + // Each video takes 6 vertices (2 triangles). Each vertex has 4 floats. // Therefore, each video needs 24 floats. // The small video at the corner is included in the vertex buffer. const rectVerts = new Float32Array(videos.length * 24); @@ -93,7 +95,7 @@ } function getArrayForIconVertexBuffer(videos, videoRows, videoColumns) { - // Each icon takes 6 vertices (2 triangles). Each vertice has 2 floats. + // Each icon takes 6 vertices (2 triangles). Each vertex has 2 floats. // Therefore, each video needs 12 floats. const rectVerts = new Float32Array(videos.length * 12); @@ -159,7 +161,7 @@ // (1) Generate 10 different lengths of voice bar. Each bar takes 2 triangles, // which are 6 vertices. // (2) Generate borders, consisting of 4 lines. Each line takes 2 vertices. - // Each vertice has 2 floats. + // Each vertex has 2 floats. // Total are 10*6*2 + 4*2*2 = 120 + 16 = 136 floats. const rectVerts = new Float32Array(136); @@ -211,7 +213,7 @@ } function getArrayForFPSVertexBuffer(fpsCount) { - // Each FPS takes 6 vertices (2 triangles). Each vertice has 4 floats. + // Each FPS takes 6 vertices (2 triangles). Each vertex has 4 floats. // Therefore, each FPS needs 24 floats. const rectVerts = new Float32Array(fpsCount * 24);
diff --git a/content/test/data/gpu/vc/videos_mxn.html b/content/test/data/gpu/vc/videos_mxn.html index 8882645..7eeed011 100644 --- a/content/test/data/gpu/vc/videos_mxn.html +++ b/content/test/data/gpu/vc/videos_mxn.html
@@ -4,23 +4,25 @@ found in the LICENSE file. --> <html> + <head> <title>MxN Video playbacks</title> <script> - const _default_rows = 7; - const _default_columns = 7; - const _total_video_width = 1600; - const _total_video_height = 900; - var codec = 'vp9'; + const _defaultRows = 7; + const _defaultColumns = 7; + const _totalVideoWidth = 1600; + const _totalVideoHeight = 900; + let codec = 'vp9'; const parsedString = (function (names) { const pairs = {}; for (let i = 0; i < names.length; ++i) { - var keyValue = names[i].split('=', 2); - if (keyValue.length == 1) + const keyValue = names[i].split('=', 2); + if (keyValue.length === 1) { pairs[keyValue[0]] = ''; - else + } else { pairs[keyValue[0]] = decodeURIComponent(keyValue[1].replace(/\+/g, ' ')); + } } return pairs; })(window.location.search.substr(1).split('&')); @@ -31,12 +33,13 @@ if (videoCount <= 4) { return './teddy1_vp8_640x360_30fps.webm'; } else { - if (index < 4) + if (index < 4) { return './teddy3_vp8_320x180_30fps.webm'; - else if (index < 16) + } else if (index < 16) { return './teddy2_vp8_320x180_15fps.webm'; - else + } else { return './teddy1_vp8_320x180_7fps.webm'; + } } break; @@ -45,12 +48,13 @@ if (videoCount <= 4) { return './teddy1_vp9_640x360_30fps.webm'; } else { - if (index < 4) + if (index < 4) { return './teddy3_vp9_320x180_30fps.webm'; - else if (index < 16) + } else if (index < 16) { return './teddy2_vp9_320x180_15fps.webm'; - else + } else { return './teddy1_vp9_320x180_7fps.webm'; + } } break; } @@ -61,70 +65,75 @@ // Get the video row count and the column count from the string. // Example: videos_mxn.html?rows=9&columns=9 - var video_rows = parsedString['rows']; - var video_columns = parsedString['columns']; - if (video_rows == undefined) - video_rows = _default_rows; - if (video_columns == undefined) - video_columns = _default_columns; + let videoRows = parsedString['rows']; + let videoColumns = parsedString['columns']; + if (videoRows === undefined) { + videoRows = _defaultRows; + } + if (videoColumns === undefined) { + videoColumns = _defaultColumns; + } // Get the video source option from the string. - codecString = parsedString['codec'] - if (codecString == 'vp8') + codecString = parsedString['codec']; + if (codecString === 'vp8') { codec = 'vp8'; - else if (codecString != 'vp9' && codecString != undefined) + } else if (codecString !== 'vp9' && codecString !== undefined) { console.warn('Unsupported video codec format! Switch to default VP9.'); + } // Limite the number of videos to 20x20. // These videos will not load when the number is too big. - const max_col_row = Math.max(video_rows, video_columns); - if (max_col_row > 20) { + const maxColRow = Math.max(videoRows, videoColumns); + if (maxColRow > 20) { const p = container.appendChild(document.createElement('p')); p.style.position = "absolute"; p.style.top = 0; p.style.left = 0; - p.style.width = _total_video_width; - p.style.height = _total_video_height; + p.style.width = _totalVideoWidth; + p.style.height = _totalVideoHeight; p.innerHTML = "Cannot support videos more than 20 x 20!" + "<br />" + "Please change the number of rows/columns."; return; } // Calculate the video onscreen size - const video_width = _total_video_width / max_col_row; - const video_height = _total_video_height / max_col_row; - const icon_height = video_height / 8; + const videoWidth = _totalVideoWidth / maxColRow; + const videoHeight = _totalVideoHeight / maxColRow; + const iconHeight = videoHeight / 8; // Create MxN videos. - const video_count = video_rows * video_columns; - for (let row = 0; row < video_rows; row++) { - for (let column = 0; column < video_columns; column++) { + let animatedBar; + let iconBottom; + const videoCount = videoRows * videoColumns; + for (let row = 0; row < videoRows; row++) { + for (let column = 0; column < videoColumns; column++) { // Onscreen position. - const video_top = row * video_height; - const video_left = column * video_width; + const videoTop = row * videoHeight; + const videoLeft = column * videoWidth; // Video source. - const i = row * video_columns + column; - const video_src = GetVideoSource(video_count, i, codec); + const i = row * videoColumns + column; + const videoSrc = GetVideoSource(videoCount, i, codec); - createOneVideo(video_top, video_left, video_width, video_height, - video_src, /*has_border=*/i == 0); + createOneVideo(videoTop, videoLeft, videoWidth, videoHeight, + videoSrc, /*hasBorder=*/ i === 0); // Create an icon on top of each video. - createOneIcon(video_top, video_left, video_width, video_height, icon_height); + createOneIcon(videoTop, videoLeft, videoWidth, videoHeight, iconHeight); // For the voice animation on the last video. - if (i == 0) { - var animatedBar = document.createElement('icon'); - var icon_bottom = video_top + icon_height * 2; - createVoiceAnimationBar(animatedBar, video_top, video_left, - video_width, video_height, icon_height); + if (i === 0) { + animatedBar = document.createElement('icon'); + iconBottom = videoTop + iconHeight * 2; + createVoiceAnimationBar(animatedBar, videoTop, videoLeft, + videoWidth, videoHeight, iconHeight); } } } // Create one small video at the upper right corner to similate the one // from the local camera (640x360). - createLocalVideoAndIcon(video_width, video_height, codec); + createLocalVideoAndIcon(videoWidth, videoHeight, codec); // Start the voice icon animation. const frameTime30Fps = 32; // ms @@ -140,12 +149,12 @@ } lastTimestamp = timestamp; - const maxBarHeight = icon_height - 4; + const maxBarHeight = iconHeight - 4; barHeight = barHeight + (maxBarHeight / 10); if (barHeight > maxBarHeight) barHeight = maxBarHeight / 10; - animatedBar.style.top = icon_bottom - barHeight; + animatedBar.style.top = iconBottom - barHeight; animatedBar.style.height = barHeight; window.requestAnimationFrame(voiceBarAnimation); @@ -154,18 +163,18 @@ window.requestAnimationFrame(voiceBarAnimation); } - function createOneVideo(top, left, width, height, video_src, has_border) { + function createOneVideo(top, left, width, height, videoSrc, hasBorder) { const video = document.createElement('video'); video.loop = true; video.autoplay = true; video.muted = true; - video.src = video_src; + video.src = videoSrc; video.width = width; video.height = height; video.style.position = "absolute"; video.style.top = top; video.style.left = left; - if (has_border) { + if (hasBorder) { const borderWidth = 3; video.style.borderWidth = borderWidth; video.width = width - borderWidth * 2; @@ -178,42 +187,42 @@ container.appendChild(video); } - function createOneIcon(video_top, video_left, video_width, video_height, icon_height) { - const icon = document.createElement('icon'); + function createOneIcon(videoTop, videoLeft, videoWidth, videoHeight, iconHeight) { + const icon = document.createElement('icon'); icon.style.backgroundColor = "rgba(29, 110, 216, 255)"; icon.style.position = "absolute"; - icon.style.width = icon_height; - icon.style.height = icon_height; - icon.style.top = video_top + icon_height; - icon.style.left = video_left + video_width - icon_height * 2; + icon.style.width = iconHeight; + icon.style.height = iconHeight; + icon.style.top = videoTop + iconHeight; + icon.style.left = videoLeft + videoWidth - iconHeight * 2; container.appendChild(icon); } - function createLocalVideoAndIcon(video_width, video_height, codec) { - const small_video_width = video_width / 3; - const small_video_height = video_height / 3; - const icon_height = small_video_height / 8; - const video_src = GetVideoSource(1, 1, codec); + function createLocalVideoAndIcon(videoWidth, videoHeight, codec) { + const smallVideoWidth = videoWidth / 3; + const smallVideoHeight = videoHeight / 3; + const iconHeight = smallVideoHeight / 8; + const videoSrc = GetVideoSource(1, 1, codec); - createOneVideo(video_height - small_video_height, - _total_video_width - small_video_width, small_video_width, - small_video_height, video_src, false); + createOneVideo(videoHeight - smallVideoHeight, + _totalVideoWidth - smallVideoWidth, smallVideoWidth, + smallVideoHeight, videoSrc, false); - createOneIcon(video_height - small_video_height, _total_video_width - - small_video_width, small_video_width, small_video_height, icon_height); + createOneIcon(videoHeight - smallVideoHeight, _totalVideoWidth - + smallVideoWidth, smallVideoWidth, smallVideoHeight, iconHeight); } - function createVoiceAnimationBar(bar, video_top, video_left, video_width, - video_height, icon_height) { + function createVoiceAnimationBar(bar, videoTop, videoLeft, videoWidth, + videoHeight, iconHeight) { bar.style.backgroundColor = "white"; bar.style.position = "absolute"; bar.style.width = 5; - bar.style.height = icon_height - 4; - bar.style.top = video_top + icon_height + 4; - bar.style.left = video_left + video_width - icon_height * 1.5 - 2; + bar.style.height = iconHeight - 4; + bar.style.top = videoTop + iconHeight + 4; + bar.style.left = videoLeft + videoWidth - iconHeight * 1.5 - 2; container.appendChild(bar); } @@ -221,8 +230,11 @@ </script> </head> -<body onload="startMxNVideos()"> + +<body> <div id="container" style="position:absolute; top:0px; left:0px"> </div> + <script>startMxNVideos();</script> </body> -</html> + +</html> \ No newline at end of file
diff --git a/content/test/data/gpu/vc/webgl2_videos_mxn.html b/content/test/data/gpu/vc/webgl2_videos_mxn.html new file mode 100644 index 0000000..a67b483 --- /dev/null +++ b/content/test/data/gpu/vc/webgl2_videos_mxn.html
@@ -0,0 +1,176 @@ +<!-- +Copyright 2022 The Chromium Authors +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> +<html> + +<head> + <title>WebGL2 MxN Video playbacks</title> + <style> + #message { + position: absolute; + width: 1600px; + height: 900px; + top: 200px; + left: 400px; + } + </style> + <script src="../third_party/stats-js/stats.js"></script> + <script src="video_utils.js"></script> + <script src="webgl_video.js"></script> + <script> + const _defaultRows = 7; + const _defaultColumns = 7; + const _totalVideoWidth = 1600; + const _totalVideoHeight = 900; + let hasUIOnTop = true; + let hasFPSOnTop = true; + let capUIFPS = true; + let useLargeSizeVideo = false; + let codec = 'vp9'; + let useLocalCamera = false; + let fixedTextureSize = false; + + async function startMxNVideos() { + const container = document.getElementById('container'); + const p = document.getElementById('message'); + + // Initialize WebGL + + const gl = await webglInit(_totalVideoWidth, _totalVideoHeight, 'webgl2'); + if (!gl) { + p.innerHTML = "WebGL2 not supported!"; + return; + } + + const fixedTextureSizeOption = parsedString['fixed_texture_size']; + if (fixedTextureSizeOption === '0') { + fixedTextureSize = false; + } else if (fixedTextureSizeOption === '1') { + fixedTextureSize = true; + } + + // Get the UI rendering options from the string. + const uiOption = parsedString['ui']; + if (uiOption === 'none') { + hasUIOnTop = false; + } + + const fpsOption = parsedString['fps']; + if (fpsOption === 'none') { + hasFPSOnTop = false; + } + + codecString = parsedString['codec']; + if (codecString === 'vp8') { + codec = 'vp8'; + } else if (codecString !== 'vp9' && codecString !== undefined) { + console.warn('Unsupported video codec format! Switch to default VP9.'); + } + + const capFPSOption = parsedString['cap_ui_fps']; + if (capFPSOption === '0') { + capUIFPS = false; + } else if (capFPSOption === '1') { + capUIFPS = true; + } + + const useLargeSizeVideoOption = parsedString['use_large_size_video']; + if (useLargeSizeVideoOption === '0') { + useLargeSizeVideo = false; + } else if (useLargeSizeVideoOption === '1') { + useLargeSizeVideo = true; + } + + const useLocalCameraOption = parsedString['use_local_camera']; + if (useLocalCameraOption === '0') { + useLocalCamera = false; + } else if (useLocalCameraOption === '1') { + useLocalCamera = true; + } + + // Get the number of video rows and columns from the string. + let videoRows = parsedString['rows']; + let videoColumns = parsedString['columns']; + if (videoRows === undefined) { + videoRows = _defaultRows; + } if (videoColumns === undefined) { + videoColumns = _defaultColumns; + } + + // Limit the number of videos to 20x20. + // The video will not load when the number is too big. + const maxColRow = Math.max(videoRows, videoColumns); + if (maxColRow > 20) { + p.innerHTML = "Cannot support videos more than 20 x 20 !" + "<br />" + + "Please change the number of rows/columns."; + return; + } + + // Calculate the video onscreen size + const videoWidth = _totalVideoWidth / maxColRow; + const videoHeight = _totalVideoHeight / maxColRow; + + // Create MxN videos and a small video (size = 89x50) at the upper right + // corner to similate the one from the local camera. + p.innerHTML = "Uploading videos..."; + const videos = []; + const videoCount = videoRows * videoColumns; + for (let i = 0; i < videoCount + 1; i++) { + const video = document.createElement('video'); + video.id = i; + video.loop = true; + video.autoplay = true; + video.muted = true; + video.display = "none"; + video.src = GetVideoSource(videoCount, i, codec, useLargeSizeVideo); + video.width = videoWidth; + video.height = videoHeight; + video.crossorigin = "anonymous"; + videos.push(video); + } + // For the small video at the upper right corner. + videos[videoRows * videoColumns].width = videoWidth / 3; + videos[videoRows * videoColumns].height = videoHeight / 3; + if (useLocalCamera) { + const video = videos[videoRows * videoColumns]; + video.src = ""; + const constraints = { + audio: false, + video: { width: 640, height: 360 } + }; + await navigator.mediaDevices.getUserMedia(constraints) + .then((mediaStream) => { + video.srcObject = mediaStream; + video.onloadedmetadata = () => { + video.play(); + }; + }) + .catch((err) => { + console.error(`${err.name}: ${err.message}`); + }); + } else { + // Use the 640x360 source to simulate the local camera. + videos[videoRows * videoColumns].src = GetVideoSource(1, 1, codec); + } + + await Promise.all(videos.map(video => video.play())); + p.remove(); + + // Simulate video playback by WebGL rendering. + webglDrawVideoFrames(gl, videos, videoRows, videoColumns, + hasUIOnTop, hasFPSOnTop, capUIFPS, fixedTextureSize); + } + + </script> +</head> + +<body> + <div id="container" style="position:absolute; top:0px; left:0px"> + <p id="message"></p> + </div> + <script>startMxNVideos();</script> +</body> + +</html> \ No newline at end of file
diff --git a/content/test/data/gpu/vc/webgl_video.js b/content/test/data/gpu/vc/webgl_video.js index 93c626e..250107c6 100644 --- a/content/test/data/gpu/vc/webgl_video.js +++ b/content/test/data/gpu/vc/webgl_video.js
@@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function webglInit(canvasWidth, canvasHeight) { +function webglInit(canvasWidth, canvasHeight, mode = 'webgl') { const container = document.getElementById('container'); const canvas = container.appendChild(document.createElement('canvas')); canvas.width = canvasWidth; canvas.height = canvasHeight; - const gl = canvas.getContext('webgl'); + const gl = canvas.getContext(mode); if (!gl) { console.warn('WebGL not supported. canvas.getContext("webgl") fails!'); return null; @@ -37,25 +37,25 @@ } `, - vertex_icons: ` + vertexIcons: ` attribute vec2 aVertPos; void main(void) { gl_Position = vec4(aVertPos, 0.0, 1.0); } `, - fragment_output_blue: ` + fragmentOutputBlue: ` void main(void) { gl_FragColor = vec4(0.11328125, 0.4296875, 0.84375, 1.0); } `, - fragment_output_light_blue: ` + fragmentOutputLightBlue: ` void main(void) { gl_FragColor = vec4(0.3515625, 0.50390625, 0.75390625, 1.0); } `, - fragment_output_white: ` + fragmentOutputWhite: ` void main(void) { gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); } @@ -102,18 +102,18 @@ video: null, icon: null, animation: null, - border: null + border: null, }; function initializePrograms(gl) { webglPrograms.video = setupProgramForVideo(gl, webglShaders.vertex, webglShaders.fragment); - webglPrograms.icon = setupProgram(gl, webglShaders.vertex_icons, - webglShaders.fragment_output_blue); - webglPrograms.animation = setupProgram(gl, webglShaders.vertex_icons, - webglShaders.fragment_output_white); - webglPrograms.border = setupProgram(gl, webglShaders.vertex_icons, - webglShaders.fragment_output_light_blue); + webglPrograms.icon = setupProgram(gl, webglShaders.vertexIcons, + webglShaders.fragmentOutputBlue); + webglPrograms.animation = setupProgram(gl, webglShaders.vertexIcons, + webglShaders.fragmentOutputWhite); + webglPrograms.border = setupProgram(gl, webglShaders.vertexIcons, + webglShaders.fragmentOutputLightBlue); } function createVertexBufferForVideos(gl, videos, videoRows, videoColumns) { @@ -210,45 +210,78 @@ } } +function initTexture(gl) { + const texture = gl.createTexture(); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + return texture; +} + const webglVideoTextures = []; function initializeVideoTextures(gl, count) { for (let i = 0; i < count; ++i) { - const texture = gl.createTexture(); - gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - webglVideoTextures.push(texture); + const texture = initTexture(gl); + webglVideoTextures.push({texture}); } } -function updateTexture(gl, texture, source) { +function updateTextureViaTexStorage2D( + gl, textureInfo, source, texWidth, texHeight) { + if (textureInfo.texWidth !== texWidth || + textureInfo.texHeight !== texHeight) { + gl.deleteTexture(textureInfo.texture); + textureInfo.texture = initTexture(gl); + textureInfo.texWidth = texWidth; + textureInfo.texHeight = texHeight; + gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, texWidth, texHeight); + console.log(`Reinitializing texture (${texWidth}x${texHeight})`); + } else { + gl.activeTexture(gl.TEXTURE0); + } + + texture = textureInfo.texture; + gl.bindTexture(gl.TEXTURE_2D, texture); + + gl.texSubImage2D( + gl.TEXTURE_2D, 0, 0, 0, texWidth, texHeight, gl.RGBA, gl.UNSIGNED_BYTE, + source); +} + +function updateTextureViaTexImage2D(gl, textureInfo, source) { + if (textureInfo.texWidth || textureInfo.texHeight) { + gl.deleteTexture(textureInfo.texture); + textureInfo.texture = initTexture(gl); + textureInfo.texWidth = 0; + textureInfo.texHeight = 0; + console.log('Reinitializing texture'); + } else { + gl.activeTexture(gl.TEXTURE0); + } + + texture = textureInfo.texture; + gl.bindTexture(gl.TEXTURE_2D, texture); const level = 0; const internalFormat = gl.RGBA; const srcFormat = gl.RGBA; const srcType = gl.UNSIGNED_BYTE; - gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.texImage2D(gl.TEXTURE_2D, level, internalFormat, srcFormat, srcType, - source); + gl.texImage2D( + gl.TEXTURE_2D, level, internalFormat, srcFormat, srcType, source); } const webglFPSTextures = []; function initializeFPSTextures(gl, count) { for (let i = 0; i < count; ++i) { - const texture = gl.createTexture(); - gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - webglFPSTextures.push(texture); + const texture = initTexture(gl); + webglFPSTextures.push({texture}); } } function webglDrawVideoFrames( - gl, videos, videoRows, videoColumns, addUI, addFPS, capUIFPS) { + gl, videos, videoRows, videoColumns, addUI, addFPS, capUIFPS, + fixedTextureSize) { initializePrograms(gl); initializeVideoTextures(gl, videos.length); if (addFPS) { @@ -264,16 +297,16 @@ // are ready. var videoIsReady = new Array(videos.length); - function UpdateIsVideoReady(video) { + function updateIsVideoReady(video) { videoIsReady[video.id] = true; video.requestVideoFrameCallback(function () { - UpdateIsVideoReady(video); + updateIsVideoReady(video); }); } for (const video of videos) { video.requestVideoFrameCallback(function () { - UpdateIsVideoReady(video); + updateIsVideoReady(video); }); } @@ -301,12 +334,21 @@ bindVertexBufferForVideos(gl); for (let i = 0; i < videos.length; ++i) { if (videoIsReady[videos[i].id]) { - updateTexture(gl, webglVideoTextures[i], videos[i]); - videoIsReady[i] = false; + if (fixedTextureSize) { + updateTextureViaTexStorage2D( + gl, webglVideoTextures[i], videos[i], videos[i].videoWidth, + videos[i].videoHeight); + } else { + updateTextureViaTexImage2D(gl, webglVideoTextures[i], videos[i]); + } + videoIsReady[videos[i].id] = false; totalVideoFrames++; } + } + + for (let i = 0; i < videos.length; ++i) { gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, webglVideoTextures[i]); + gl.bindTexture(gl.TEXTURE_2D, webglVideoTextures[i].texture); gl.drawArrays(gl.TRIANGLES, 6 * i, 6); } // Add UI on Top of all videos. @@ -317,8 +359,9 @@ // Animated voice bar on the last video. index_voice_bar++; - if (index_voice_bar >= 10) + if (index_voice_bar >= 10) { index_voice_bar = 0; + } gl.useProgram(webglPrograms.animation); bindVertexBufferForAnimation(gl); gl.drawArrays(gl.TRIANGLES, index_voice_bar * 6, 6); @@ -335,7 +378,7 @@ bindVertexBufferForFPS(gl); for (let i = 0; i < fpsPanels.length; ++i) { - updateTexture(gl, webglFPSTextures[i], fpsPanels[i].dom); + updateTextureViaTexImage2D(gl, webglFPSTextures[i], fpsPanels[i].dom); gl.drawArrays(gl.TRIANGLES, 6 * i, 6); } }
diff --git a/content/test/data/gpu/vc/webgl_videos_mxn.html b/content/test/data/gpu/vc/webgl_videos_mxn.html index 6abe56a..55d43471 100644 --- a/content/test/data/gpu/vc/webgl_videos_mxn.html +++ b/content/test/data/gpu/vc/webgl_videos_mxn.html
@@ -16,19 +16,20 @@ left: 400px; } </style> - <script type="text/javascript" src="../third_party/stats-js/stats.js"></script> - <script type="text/javascript" src="video_utils.js"></script> - <script type="text/javascript" src="webgl_video.js"></script> + <script src="../third_party/stats-js/stats.js"></script> + <script src="video_utils.js"></script> + <script src="webgl_video.js"></script> <script> const _defaultRows = 7; const _defaultColumns = 7; const _totalVideoWidth = 1600; const _totalVideoHeight = 900; - var hasUIOnTop = true; - var hasFPSOnTop = true; - var capUIFPS = true; - var useLargeSizeVideo = false; - var codec = 'vp9'; + let hasUIOnTop = true; + let hasFPSOnTop = true; + let capUIFPS = true; + let useLargeSizeVideo = false; + let codec = 'vp9'; + let useLocalCamera = false; async function startMxNVideos() { const container = document.getElementById('container'); @@ -44,40 +45,54 @@ // Get the UI rendering options from the string. const uiOption = parsedString['ui']; - if (uiOption == 'none') + if (uiOption === 'none') { hasUIOnTop = false; + } const fpsOption = parsedString['fps']; - if (fpsOption == 'none') + if (fpsOption === 'none') { hasFPSOnTop = false; + } - codecString = parsedString['codec'] - if (codecString == 'vp8') + codecString = parsedString['codec']; + if (codecString === 'vp8') { codec = 'vp8'; - else if (codecString != 'vp9' && codecString != undefined) + } else if (codecString !== 'vp9' && codecString !== undefined) { console.warn('Unsupported video codec format! Switch to default VP9.'); + } - const capFPSOption = parsedString['cap_ui_fps'] - if (capFPSOption == '0') + const capFPSOption = parsedString['cap_ui_fps']; + if (capFPSOption === '0') { capUIFPS = false; - else if (capFPSOption == '1') + } else if (capFPSOption === '1') { capUIFPS = true; + } - const useLargeSizeVideoOption = parsedString['use_large_size_video'] - if (useLargeSizeVideoOption == '0') + const useLargeSizeVideoOption = parsedString['use_large_size_video']; + if (useLargeSizeVideoOption === '0') { useLargeSizeVideo = false; - else if (useLargeSizeVideoOption == '1') + } else if (useLargeSizeVideoOption === '1') { useLargeSizeVideo = true; + } + + const useLocalCameraOption = parsedString['use_local_camera']; + if (useLocalCameraOption === '0') { + useLocalCamera = false; + } else if (useLocalCameraOption === '1') { + useLocalCamera = true; + } // Get the number of video rows and columns from the string. - var videoRows = parsedString['rows']; - var videoColumns = parsedString['columns']; - if (videoRows == undefined) + let videoRows = parsedString['rows']; + let videoColumns = parsedString['columns']; + if (videoRows === undefined) { videoRows = _defaultRows; - if (videoColumns == undefined) + } + if (videoColumns === undefined) { videoColumns = _defaultColumns; + } - // Limite the number of videos to 20x20. + // Limit the number of videos to 20x20. // The video will not load when the number is too big. const maxColRow = Math.max(videoRows, videoColumns); if (maxColRow > 20) { @@ -93,7 +108,7 @@ // Create MxN videos and a small video (size = 89x50) at the upper right // corner to similate the one from the local camera. p.innerHTML = "Uploading videos..."; - var videos = []; + const videos = []; const videoCount = videoRows * videoColumns; for (let i = 0; i < videoCount + 1; i++) { const video = document.createElement('video'); @@ -111,8 +126,28 @@ // For the small video at the upper right corner. videos[videoRows * videoColumns].width = videoWidth / 3; videos[videoRows * videoColumns].height = videoHeight / 3; - // Use the 640x360 source to simulate the local camera. - videos[videoRows * videoColumns].src = GetVideoSource(1, 1, codec); + + if (useLocalCamera) { + const video = videos[videoRows * videoColumns]; + video.src = ""; + const constraints = { + audio: false, + video: { width: 640, height: 360 } + }; + await navigator.mediaDevices.getUserMedia(constraints) + .then((mediaStream) => { + video.srcObject = mediaStream; + video.onloadedmetadata = () => { + video.play(); + }; + }) + .catch((err) => { + console.error(`${err.name}: ${err.message}`); + }); + } else { + // Use the 640x360 source to simulate the local camera. + videos[videoRows * videoColumns].src = GetVideoSource(1, 1, codec); + } await Promise.all(videos.map(video => video.play())); p.remove(); @@ -125,10 +160,11 @@ </script> </head> -<body onload="startMxNVideos()"> +<body> <div id="container" style="position:absolute; top:0px; left:0px"> <p id="message"></p> </div> + <script>startMxNVideos();</script> </body> </html> \ No newline at end of file
diff --git a/content/test/data/media/peerconnection-call.html b/content/test/data/media/peerconnection-call.html index c4e99fc..01f1d39 100644 --- a/content/test/data/media/peerconnection-call.html +++ b/content/test/data/media/peerconnection-call.html
@@ -24,14 +24,14 @@ // video in this call since we expect video to be playing). function call(constraints) { createConnections(); - navigator.mediaDevices.getUserMedia(constraints) - .then(addStreamToBothConnectionsAndNegotiate) - .catch(failTest); - - Promise.all([ + return Promise.all([ + navigator.mediaDevices.getUserMedia(constraints) + .then(addStreamToBothConnectionsAndNegotiate), detectVideoPlaying('remote-view-1'), detectVideoPlaying('remote-view-2') - ]).then(reportTestSuccess); + ]) + .then(logSuccess) + .catch(toStackTrace); } function oldStyleCall() { @@ -199,14 +199,14 @@ createConnections(); setOfferSdpTransform(removeBundle); setRemoteSdpTransform(removeMsid); - navigator.mediaDevices.getUserMedia({audio: true, video: true}) - .then(addStreamToBothConnectionsAndNegotiate) - .catch(failTest); - - Promise.all([ + return Promise.all([ + navigator.mediaDevices.getUserMedia({audio: true, video: true}) + .then(addStreamToBothConnectionsAndNegotiate), detectVideoPlaying('remote-view-1'), detectVideoPlaying('remote-view-1') - ]).then(reportTestSuccess); + ]) + .then(logSuccess) + .catch(toStackTrace); } // Test that we can't setup a call with an unsupported video codec @@ -214,31 +214,35 @@ createConnections(); setOfferSdpTransform(removeVideoCodec); - setOnLocalDescriptionError(function(error) { - var expectedMsg = "Failed to set local offer sdp: Failed to set local " + - "video description recv parameters for m-section with mid='1'."; - assertEquals(expectedMsg, error.message); - reportTestSuccess(); - }); - navigator.mediaDevices.getUserMedia({audio: true, video: true}) + return navigator.mediaDevices.getUserMedia({audio: true, video: true}) .then(addStreamToBothConnectionsAndNegotiate) - .catch(failTest); + .then( + () => toStackTrace('Expected to fail, but succeeded'), + (error) => { + var expectedMsg = "Failed to set local offer sdp: Failed to set local " + + "video description recv parameters for m-section with mid='1'."; + assertEqualsSync(expectedMsg, error.message); + return logSuccess(); + }) + .catch(toStackTrace); } // Test that we can't setup a call if one peer does not support encryption function negotiateNonCryptoCall() { createConnections(); setOfferSdpTransform(removeCrypto); - setOnLocalDescriptionError(function(error) { - // Note: Per spec, error should be 'IllegalModificationError' - // https://crbug.com/823036 - var expectedError = 'OperationError'; - assertEquals(expectedError, error.name); - reportTestSuccess(); - }); - navigator.mediaDevices.getUserMedia({audio: true, video: true}) + return navigator.mediaDevices.getUserMedia({audio: true, video: true}) .then(addStreamToBothConnectionsAndNegotiate) - .catch(failTest); + .then(() => { + return toStackTrace('Expected to fail, but succeeded'); + }, (error) => { + // Note: Per spec, error should be 'IllegalModificationError' + // https://crbug.com/823036 + var expectedError = 'OperationError'; + assertEqualsSync(expectedError, error.name); + return logSuccess(); + }) + .catch(toStackTrace); } // Test that we can negotiate a call with an SDP offer that includes a @@ -347,23 +351,24 @@ // Loads this page inside itself using an iframe, and ensures we can make a // successful getUserMedia + peerconnection call inside the iframe. function callInsideIframe(constraints) { - runInsideIframe(function(iframe) { + return createIframe().then(function(iframe) { // Run a regular webrtc call inside the iframe. - iframe.contentWindow.call(constraints); + return iframe.contentWindow.call(constraints); }); } - // Func should accept an iframe as its first argument. - function runInsideIframe(func) { + function createIframe() { var iframe = document.createElement('iframe'); document.body.appendChild(iframe); - iframe.onload = onIframeLoaded; - iframe.src = window.location; + return new Promise(resolve => { + iframe.onload = onIframeLoaded; + iframe.src = window.location; - function onIframeLoaded() { - var iframe = window.document.querySelector('iframe'); - func(iframe); - } + function onIframeLoaded() { + var iframe = window.document.querySelector('iframe'); + resolve(iframe); + } + }); } // Test call with a stream that has been created by getUserMedia, clone @@ -447,7 +452,7 @@ displayAndRemember(localStream); gFirstConnection.addStream(localStream); gSecondConnection.addStream(localStream); - negotiate(); + return negotiate(); } // Called if getUserMedia succeeds when we want to send from one connection. @@ -469,7 +474,7 @@ } function negotiate() { - negotiateBetween(gFirstConnection, gSecondConnection); + return negotiateBetween(gFirstConnection, gSecondConnection); } function iceCandidateIsLoopback(candidate) {
diff --git a/content/test/data/media/webrtc_test_common.js b/content/test/data/media/webrtc_test_common.js index 30222ae9..030867b 100644 --- a/content/test/data/media/webrtc_test_common.js +++ b/content/test/data/media/webrtc_test_common.js
@@ -5,7 +5,6 @@ // Default transform functions, overridden by some test cases. var transformSdp = function(sdp) { return sdp; }; var transformRemoteSdp = function(sdp) { return sdp; }; -var onLocalDescriptionError = function(error) { failTest(error); }; // Provide functions to set the transform functions. function setOfferSdpTransform(newTransform) { @@ -14,9 +13,6 @@ function setRemoteSdpTransform(newTransform) { transformRemoteSdp = newTransform; } -function setOnLocalDescriptionError(newHandler) { - onLocalDescriptionError = newHandler; -} /** * Negotiate a call between two peer connections. @@ -31,7 +27,7 @@ * Args: * caller, callee: RTCPeerConnection instances. */ -function negotiateBetween(caller, callee) { +async function negotiateBetween(caller, callee) { console.log("Negotiating call..."); // Not stable = negotiation is ongoing. The behavior of re-negotiating while // a negotiation is ongoing is more or less undefined, so avoid this. @@ -40,77 +36,69 @@ connectOnIceCandidate_(caller, callee); - caller.createOffer( - function (offer) { - onOfferCreated_(offer, caller, callee); - }, - function(error) {} - ); + const offer = await new Promise((resolve, reject) => { + caller.createOffer(resolve, reject); + }) + return onOfferCreated_(offer, caller, callee); } /** * @private */ -function onOfferCreated_(offer, caller, callee) { +async function onOfferCreated_(offer, caller, callee) { offer.sdp = transformSdp(offer.sdp); console.log('Offer:\n' + offer.sdp); - caller.setLocalDescription(offer, function() { - assertEquals('have-local-offer', caller.signalingState); - receiveOffer_(offer.sdp, caller, callee); - }, onLocalDescriptionError); + await new Promise((resolve, reject) => { + caller.setLocalDescription(offer, resolve, reject); + }); + assertEqualsSync('have-local-offer', caller.signalingState); + return receiveOffer_(offer.sdp, caller, callee); } /** * @private */ -function receiveOffer_(offerSdp, caller, callee) { +async function receiveOffer_(offerSdp, caller, callee) { console.log("Receiving offer..."); offerSdp = transformRemoteSdp(offerSdp); var parsedOffer = new RTCSessionDescription({ type: 'offer', sdp: offerSdp }); - callee.setRemoteDescription(parsedOffer, - function() { - assertEquals('have-remote-offer', - callee.signalingState); - callee.createAnswer( - function (answer) { - onAnswerCreated_(answer, caller, callee); - }, - function(error) { - } - ); - }, - failTest); + await new Promise((resolve, reject) => { + callee.setRemoteDescription(parsedOffer, resolve, reject); + }); + assertEqualsSync('have-remote-offer', callee.signalingState); + const answer = await new Promise((resolve, reject) => { + callee.createAnswer(resolve, reject); + }); + return onAnswerCreated_(answer, caller, callee); } /** * @private */ -function onAnswerCreated_(answer, caller, callee) { +async function onAnswerCreated_(answer, caller, callee) { answer.sdp = transformSdp(answer.sdp); console.log('Answer:\n' + answer.sdp); - callee.setLocalDescription(answer, - function () { - assertEquals('stable', callee.signalingState); - }, - onLocalDescriptionError); - receiveAnswer_(answer.sdp, caller); + await new Promise((resolve, reject) => { + callee.setLocalDescription(answer, resolve, reject); + }); + assertEqualsSync('stable', callee.signalingState); + return receiveAnswer_(answer.sdp, caller); } /** * @private */ -function receiveAnswer_(answerSdp, caller) { +async function receiveAnswer_(answerSdp, caller) { console.log("Receiving answer..."); answerSdp = transformRemoteSdp(answerSdp); var parsedAnswer = new RTCSessionDescription({ type: 'answer', sdp: answerSdp }); - caller.setRemoteDescription(parsedAnswer, - function() { - assertEquals('stable', caller.signalingState); - }, - failTest); + await new Promise((resolve, reject) => { + caller.setRemoteDescription(parsedAnswer, resolve, reject); + }); + assertEqualsSync('stable', caller.signalingState); } /** @@ -128,13 +116,13 @@ /** * @private */ -function onIceCandidate_(event, originator, target) { +async function onIceCandidate_(event, originator, target) { if (event.candidate) { var candidate = new RTCIceCandidate(event.candidate); target.addIceCandidate(candidate); } else { // The spec guarantees that the special "null" candidate will be fired // *after* changing the gathering state to "complete". - assertEquals('complete', originator.iceGatheringState); + assertEqualsSync('complete', originator.iceGatheringState); } }
diff --git a/content/test/data/media/webrtc_test_utilities.js b/content/test/data/media/webrtc_test_utilities.js index 5d903e8..b85021f 100644 --- a/content/test/data/media/webrtc_test_utilities.js +++ b/content/test/data/media/webrtc_test_utilities.js
@@ -270,6 +270,12 @@ } } +function assertEqualsSync(expected, actual) { + if (actual != expected) { + throw new Error('expected \'' + expected + '\', got \'' + actual + '\'.'); + } +} + function assertNotEquals(expected, actual) { if (actual === expected) { failTest('expected \'' + expected + '\', got \'' + actual + '\'.');
diff --git a/content/test/test_render_frame.cc b/content/test/test_render_frame.cc index 9bf4a27..0ac4120 100644 --- a/content/test/test_render_frame.cc +++ b/content/test/test_render_frame.cc
@@ -270,8 +270,10 @@ blink::mojom::ControllerServiceWorkerInfoPtr(), blink::mojom::ServiceWorkerContainerInfoForClientPtr(), mojo::NullRemote() /* prefetch_loader_factory */, - mojo::NullRemote() /* topics_loader_factory */, blink::DocumentToken(), - base::UnguessableToken::Create(), blink::ParsedPermissionsPolicy(), + mojo::NullRemote() /* topics_loader_factory */, + mojo::NullRemote() /* keep_alive_loader_factory */, + blink::DocumentToken(), base::UnguessableToken::Create(), + blink::ParsedPermissionsPolicy(), blink::mojom::PolicyContainer::New( blink::mojom::PolicyContainerPolicies::New(), mock_policy_container_host.BindNewEndpointAndPassDedicatedRemote()),
diff --git a/content/test/test_render_frame_host.cc b/content/test/test_render_frame_host.cc index 86ab9b4..9c3c920 100644 --- a/content/test/test_render_frame_host.cc +++ b/content/test/test_render_frame_host.cc
@@ -619,6 +619,8 @@ mojo::PendingRemote<network::mojom::URLLoaderFactory> prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory, const absl::optional<blink::ParsedPermissionsPolicy>& permissions_policy, blink::mojom::PolicyContainerPtr policy_container, const blink::DocumentToken& document_token,
diff --git a/content/test/test_render_frame_host.h b/content/test/test_render_frame_host.h index 61d3f4a..424c423 100644 --- a/content/test/test_render_frame_host.h +++ b/content/test/test_render_frame_host.h
@@ -275,6 +275,8 @@ prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory, const absl::optional<blink::ParsedPermissionsPolicy>& permissions_policy, blink::mojom::PolicyContainerPtr policy_container, const blink::DocumentToken& document_token,
diff --git a/content/web_test/renderer/test_plugin.cc b/content/web_test/renderer/test_plugin.cc index 027526d..2c37c02f 100644 --- a/content/web_test/renderer/test_plugin.cc +++ b/content/web_test/renderer/test_plugin.cc
@@ -338,7 +338,8 @@ shared_bitmap_); *resource = viz::TransferableResource::MakeSoftware( - shared_bitmap_->id(), shared_bitmap_->size(), viz::RGBA_8888); + shared_bitmap_->id(), shared_bitmap_->size(), + viz::SinglePlaneFormat::kRGBA_8888); *release_callback = base::BindOnce(&ReleaseSharedMemory, std::move(shared_bitmap_), std::move(registration));
diff --git a/extensions/common/extension_features.cc b/extensions/common/extension_features.cc index d87af4c7..ddb9ce0 100644 --- a/extensions/common/extension_features.cc +++ b/extensions/common/extension_features.cc
@@ -109,13 +109,6 @@ "ForceWebRequestProxyForTest", base::FEATURE_DISABLED_BY_DEFAULT); -// If enabled, the minimum MV3 Content-Security-Policy will include -// 'inline-speculation-rules' source in the script-src. -// See https://crbug.com/1382361 to track the launch status. -BASE_FEATURE(kMinimumMV3CSPWithInlineSpeculationRules, - "MinimumMV3CSPWithInlineSpeculationRules", - base::FEATURE_ENABLED_BY_DEFAULT); - // Controls whether extensions can use the new favicon fetching in Manifest V3. BASE_FEATURE(kNewExtensionFaviconHandling, "ExtensionsNewFaviconHandling",
diff --git a/extensions/common/extension_features.h b/extensions/common/extension_features.h index 376e089a..2b70320 100644 --- a/extensions/common/extension_features.h +++ b/extensions/common/extension_features.h
@@ -70,8 +70,6 @@ BASE_DECLARE_FEATURE(kForceWebRequestProxyForTest); -BASE_DECLARE_FEATURE(kMinimumMV3CSPWithInlineSpeculationRules); - BASE_DECLARE_FEATURE(kNewExtensionFaviconHandling); BASE_DECLARE_FEATURE(kNewWebstoreDomain);
diff --git a/extensions/common/manifest_handlers/csp_info.cc b/extensions/common/manifest_handlers/csp_info.cc index e4df35c..1fcbea13 100644 --- a/extensions/common/manifest_handlers/csp_info.cc +++ b/extensions/common/manifest_handlers/csp_info.cc
@@ -43,18 +43,11 @@ // The minimum CSP to be used in order to prevent remote scripts. static const char kMinimumMV3CSP[] = - "script-src 'self' 'wasm-unsafe-eval'; object-src 'self';"; + "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules'; " + "object-src 'self';"; // For unpacked extensions, we additionally allow the use of localhost files to // aid in rapid local development. static const char kMinimumUnpackedMV3CSP[] = - "script-src 'self' 'wasm-unsafe-eval' http://localhost:* " - "http://127.0.0.1:*; object-src 'self';"; - -// Variants to support inline-specluation-rules. See https://crbug.com/1382361. -static const char kMinimumMV3CSPWithInlineSpeculationRules[] = - "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules'; " - "object-src 'self';"; -static const char kMinimumUnpackedMV3CSPWithInlineSpeculationRules[] = "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules' " "http://localhost:* http://127.0.0.1:*; object-src 'self';"; @@ -129,16 +122,9 @@ const std::string* GetMinimumMV3CSPForExtension(const Extension& extension) { DCHECK_GE(extension.manifest_version(), 3); - static const base::NoDestructor<std::string> default_csp( - base::FeatureList::IsEnabled( - extensions_features::kMinimumMV3CSPWithInlineSpeculationRules) - ? kMinimumMV3CSPWithInlineSpeculationRules - : kMinimumMV3CSP); + static const base::NoDestructor<std::string> default_csp(kMinimumMV3CSP); static const base::NoDestructor<std::string> default_unpacked_csp( - base::FeatureList::IsEnabled( - extensions_features::kMinimumMV3CSPWithInlineSpeculationRules) - ? kMinimumUnpackedMV3CSPWithInlineSpeculationRules - : kMinimumUnpackedMV3CSP); + kMinimumUnpackedMV3CSP); return Manifest::IsUnpackedLocation(extension.location()) ? default_unpacked_csp.get() @@ -228,18 +214,12 @@ // static const char* CSPHandler::GetMinimumMV3CSPForTesting() { - return base::FeatureList::IsEnabled( - extensions_features::kMinimumMV3CSPWithInlineSpeculationRules) - ? kMinimumMV3CSPWithInlineSpeculationRules - : kMinimumMV3CSP; + return kMinimumMV3CSP; } // static const char* CSPHandler::GetMinimumUnpackedMV3CSPForTesting() { - return base::FeatureList::IsEnabled( - extensions_features::kMinimumMV3CSPWithInlineSpeculationRules) - ? kMinimumUnpackedMV3CSPWithInlineSpeculationRules - : kMinimumUnpackedMV3CSP; + return kMinimumUnpackedMV3CSP; } bool CSPHandler::Parse(Extension* extension, std::u16string* error) {
diff --git a/extensions/common/value_builder.h b/extensions/common/value_builder.h index bc488ec..67d906ec 100644 --- a/extensions/common/value_builder.h +++ b/extensions/common/value_builder.h
@@ -32,6 +32,23 @@ namespace extensions { +// DEPRECATED: Building a dictionary can now directly be performed on +// `base::Value::Dict`, and `ToJSON()` can be replaced by calling `WriteJson()`: +// +// std::string result = +// base::WriteJson( +// base::Value::Dict() +// .Set("key-1", "first value") +// .Set("key-2", 2) +// .Set("key-3", true) +// .Set("nested-dictionary", base::Value::Dict() +// .Set("nested-key-1", "value") +// .Set("nested-key-2", true)) +// .Set("nested-list", base::Value::List() +// .Append("nested-list-value") +// .Append(5) +// .Append(true))).value(); +// class DictionaryBuilder { public: DictionaryBuilder(); @@ -62,6 +79,16 @@ base::Value::Dict dict_; }; +// DEPRECATED: Building a list can now directly be performed on +// `base::Value::List`, and `ToJSON()` can be replaced by calling `WriteJson()`: +// +// std::string result = +// base::WriteJson( +// base::Value::List() +// .Append("nested-list-value") +// .Append(5) +// .Append(true)).value(); +// class ListBuilder { public: ListBuilder(); @@ -87,8 +114,9 @@ // But if it's good enough for the STL, it's good enough for this class. template <typename InputIt> ListBuilder& Append(InputIt first, InputIt last) { - for (; first != last; ++first) + for (; first != last; ++first) { list_.Append(*first); + } return *this; }
diff --git a/fuchsia_web/runners/BUILD.gn b/fuchsia_web/runners/BUILD.gn index 4ecfc093..ea8c1f33 100644 --- a/fuchsia_web/runners/BUILD.gn +++ b/fuchsia_web/runners/BUILD.gn
@@ -23,13 +23,11 @@ ] deps = [ "//base", - "//fuchsia_web/runners/common/modular", "//third_party/fuchsia-sdk/sdk/pkg/scenic_cpp", "//ui/gfx/geometry", "//url", ] public_deps = [ - "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.modular:fuchsia.modular_hlcpp", "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.sys:fuchsia.sys_hlcpp", "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.ui.app:fuchsia.ui.app_hlcpp", "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.web:fuchsia.web_hlcpp", @@ -51,8 +49,6 @@ "cast/cast_runner.h", "cast/cast_runner_switches.cc", "cast/cast_runner_switches.h", - "cast/cast_runner_v1.cc", - "cast/cast_runner_v1.h", "cast/cast_streaming.cc", "cast/cast_streaming.h", "cast/named_message_port_connector_fuchsia.cc", @@ -70,13 +66,11 @@ "//components/fuchsia_component_support", "//components/fuchsia_component_support:dynamic_component_host", "//fuchsia_web/cast_streaming", - "//fuchsia_web/runners/common/modular", "//fuchsia_web/webinstance_host", "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_hlcpp", "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.diagnostics:fuchsia.diagnostics_hlcpp", "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.legacymetrics:fuchsia.legacymetrics_hlcpp", "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.mem:fuchsia.mem_hlcpp", - "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.modular:fuchsia.modular_hlcpp", "//third_party/fuchsia-sdk/sdk/pkg/scenic_cpp", "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp", "//url", @@ -98,6 +92,7 @@ "//content/public/common", "//media", "//third_party/blink/common", + "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.modular:*", ] sources = [ "cast/main.cc" ] @@ -142,11 +137,6 @@ } } -fuchsia_component("cast_runner_component_v1") { - manifest = "cast/cast_runner.cmx" - data_deps = [ ":cast_runner_exe" ] -} - fuchsia_component("cast_runner_component") { manifest = "cast/cast_runner.cml" data_deps = [ ":cast_runner_exe" ] @@ -154,10 +144,7 @@ fuchsia_package("cast_runner_pkg") { package_name = "cast_runner" - deps = [ - ":cast_runner_component", - ":cast_runner_component_v1", - ] + deps = [ ":cast_runner_component" ] excluded_files = _web_instance_host_deps_files_to_exclude } @@ -194,7 +181,6 @@ deps = [ ":cast_runner_core", ":cast_runner_test_core", - "common/modular:unit_tests", "//base", "//base/test:run_all_unittests", "//base/test:test_support", @@ -209,12 +195,9 @@ test("cast_runner_integration_tests") { sources = [ - "cast/cast_runner_cfv1_shim_integration_test.cc", "cast/cast_runner_integration_test.cc", "cast/cast_runner_integration_test_base.cc", "cast/cast_runner_integration_test_base.h", - "common/modular/fake_component_context.cc", - "common/modular/fake_component_context.h", ] data = [ "cast/testdata" ] deps = [ @@ -223,16 +206,15 @@ "//base/test:test_support", "//build:chromecast_buildflags", "//components/cast/message_port", + "//components/fuchsia_component_support:dynamic_component_host", "//fuchsia_web/common", "//fuchsia_web/common/test:run_all_integration_tests", "//fuchsia_web/common/test:test_support", "//fuchsia_web/runners/cast/test:integration", - "//fuchsia_web/runners/common/modular", "//net:test_support", "//testing/gtest", "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.camera3:fuchsia.camera3_hlcpp", "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.legacymetrics:fuchsia.legacymetrics_hlcpp", - "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.modular:fuchsia.modular_hlcpp", "//third_party/fuchsia-sdk/sdk/pkg/scenic_cpp", "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp", ]
diff --git a/fuchsia_web/runners/cast/cast_resolver.cc b/fuchsia_web/runners/cast/cast_resolver.cc index c51bc99..29bfc1a 100644 --- a/fuchsia_web/runners/cast/cast_resolver.cc +++ b/fuchsia_web/runners/cast/cast_resolver.cc
@@ -82,7 +82,6 @@ // Declare and expose capabilities implemented by the component. DeclareAndExposeProtocol(decl, "fuchsia.ui.app.ViewProvider"); - DeclareAndExposeProtocol(decl, "fuchsia.modular.Lifecycle"); // Expose the Binder, from the framework, to allow CastRunnerV1 to start the // component.
diff --git a/fuchsia_web/runners/cast/cast_runner.cml b/fuchsia_web/runners/cast/cast_runner.cml index 93eb36b..907fb5a2 100644 --- a/fuchsia_web/runners/cast/cast_runner.cml +++ b/fuchsia_web/runners/cast/cast_runner.cml
@@ -11,7 +11,6 @@ program: { runner: "elf", binary: "cast_runner_exe", - args: [ "--enable-cfv2" ], // TODO(crbug.com/1280703): Remove once web_instance is a CFv2 component. lifecycle: { stop_event: "notify" }, },
diff --git a/fuchsia_web/runners/cast/cast_runner.cmx b/fuchsia_web/runners/cast/cast_runner.cmx deleted file mode 100644 index 99ec60b..0000000 --- a/fuchsia_web/runners/cast/cast_runner.cmx +++ /dev/null
@@ -1,12 +0,0 @@ -{ - "program": { - "binary": "cast_runner_exe" - }, - "sandbox": { - "services": [ - "fuchsia.feedback.ComponentDataRegister", - "fuchsia.feedback.CrashReportingProductRegister", - "fuchsia.sys.Runner-cast" - ] - } -}
diff --git a/fuchsia_web/runners/cast/cast_runner_cfv1_shim_integration_test.cc b/fuchsia_web/runners/cast/cast_runner_cfv1_shim_integration_test.cc deleted file mode 100644 index 3ce9bd7..0000000 --- a/fuchsia_web/runners/cast/cast_runner_cfv1_shim_integration_test.cc +++ /dev/null
@@ -1,190 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <fuchsia/sys/cpp/fidl.h> -#include <lib/fdio/fd.h> -#include <lib/fidl/cpp/interface_request.h> -#include <lib/sys/cpp/component_context.h> -#include <lib/sys/cpp/outgoing_directory.h> -#include <lib/sys/cpp/service_directory.h> -#include <unistd.h> -#include <zircon/processargs.h> - -#include <utility> -#include <vector> - -#include "base/auto_reset.h" -#include "base/command_line.h" -#include "base/fuchsia/fuchsia_logging.h" -#include "base/fuchsia/process_context.h" -#include "base/fuchsia/scoped_service_publisher.h" -#include "base/fuchsia/test_component_controller.h" -#include "base/functional/callback.h" -#include "base/location.h" -#include "base/run_loop.h" -#include "base/test/bind.h" -#include "base/test/scoped_run_loop_timeout.h" -#include "base/test/task_environment.h" -#include "base/test/test_timeouts.h" -#include "fuchsia_web/runners/cast/cast_runner_switches.h" -#include "net/test/embedded_test_server/default_handlers.h" -#include "net/test/embedded_test_server/embedded_test_server.h" -#include "testing/gtest/include/gtest/gtest.h" - -class CastRunnerCfv1ShimIntegrationTest : public ::testing::Test { - protected: - CastRunnerCfv1ShimIntegrationTest() - : fake_runner_publisher_( - &services_for_runner_, - [this](fidl::InterfaceRequest<fuchsia::sys::Runner> request) { - received_requests_.push_back(std::move(request)); - if (on_request_received_) - on_request_received_.Run(); - }, - "fuchsia.sys.Runner-cast") {} - - void SetUp() override { - cast_runner_services_ = StartCfv1Shim(); - - // Connect to the CastRunner's fuchsia.sys.Runner interface. - cast_runner_shim_ = cast_runner_services_->Connect<fuchsia::sys::Runner>(); - cast_runner_shim_.set_error_handler([](zx_status_t status) { - ZX_LOG(ERROR, status) << "CastRunner closed channel."; - ADD_FAILURE(); - }); - - static constexpr base::StringPiece kTestServerRoot( - "fuchsia_web/runners/cast/testdata"); - test_server_.ServeFilesFromSourceDirectory(kTestServerRoot); - net::test_server::RegisterDefaultHandlers(&test_server_); - ASSERT_TRUE(test_server_.Start()); - } - - void TearDown() override { - // Unbind the Runner channel, to prevent it from triggering an error when - // the CastRunner and WebEngine are torn down. - cast_runner_shim_.Unbind(); - } - - void RunUntilRequestsReceived(size_t expected_count) { - base::RunLoop run_loop; - base::AutoReset reset(&on_request_received_, - base::BindLambdaForTesting([&]() { - if (received_requests_.size() == expected_count) - run_loop.Quit(); - })); - run_loop.Run(); - } - - ::fuchsia::sys::ComponentControllerPtr& controller_ptr() { - return controller_.ptr(); - } - ::fuchsia::sys::RunnerPtr& cast_runner_shim_ptr() { - return cast_runner_shim_; - } - - std::vector<fidl::InterfaceRequest<fuchsia::sys::Runner>> received_requests_; - - private: - std::unique_ptr<sys::ServiceDirectory> StartCfv1Shim() { - fuchsia::sys::LaunchInfo launch_info; - launch_info.url = - "fuchsia-pkg://fuchsia.com/cast_runner#meta/cast_runner.cmx"; - - // Clone stderr from the current process to CastRunner and ask it to - // redirect all logs to stderr. - launch_info.err = fuchsia::sys::FileDescriptor::New(); - launch_info.err->type0 = PA_FD; - zx_status_t status = fdio_fd_clone( - STDERR_FILENO, launch_info.err->handle0.reset_and_get_address()); - ZX_CHECK(status == ZX_OK, status); - - base::CommandLine command_line(base::CommandLine::NO_PROGRAM); - command_line.AppendSwitch(kDisableVulkanForTestsSwitch); - command_line.AppendSwitchASCII("enable-logging", "stderr"); - - // Add all switches and arguments, skipping the program. - launch_info.arguments.emplace(std::vector<std::string>( - command_line.argv().begin() + 1, command_line.argv().end())); - - auto additional_services = std::make_unique<fuchsia::sys::ServiceList>(); - auto* svc_dir = services_for_runner_.GetOrCreateDirectory("svc"); - additional_services->names.push_back("fuchsia.sys.Runner-cast"); - - fuchsia::io::DirectoryHandle svc_dir_handle; - svc_dir->Serve(fuchsia::io::OpenFlags::RIGHT_READABLE | - fuchsia::io::OpenFlags::RIGHT_WRITABLE, - svc_dir_handle.NewRequest().TakeChannel()); - additional_services->host_directory = std::move(svc_dir_handle); - - launch_info.additional_services = std::move(additional_services); - - fuchsia::io::DirectoryHandle cast_runner_services_dir; - launch_info.directory_request = cast_runner_services_dir.NewRequest(); - - fuchsia::sys::LauncherPtr launcher; - base::ComponentContextForProcess()->svc()->Connect(launcher.NewRequest()); - launcher->CreateComponent(std::move(launch_info), - controller_.ptr().NewRequest()); - return std::make_unique<sys::ServiceDirectory>( - std::move(cast_runner_services_dir)); - } - - base::test::SingleThreadTaskEnvironment task_environment_{ - base::test::SingleThreadTaskEnvironment::MainThreadType::IO}; - net::EmbeddedTestServer test_server_; - - // TODO(https://crbug.com/1168538): Override the RunLoop timeout set by - // |task_environment_| to allow for the very high variability in web.Context - // launch times. - const base::test::ScopedRunLoopTimeout scoped_timeout_{ - FROM_HERE, TestTimeouts::action_max_timeout()}; - - std::unique_ptr<sys::ServiceDirectory> cast_runner_services_; - fuchsia::sys::RunnerPtr cast_runner_shim_; - base::TestComponentController controller_; - - // Directory used to publish test ContextProvider to CastRunner. - sys::OutgoingDirectory services_for_runner_; - base::ScopedServicePublisher<fuchsia::sys::Runner> fake_runner_publisher_; - base::RepeatingClosure on_request_received_; -}; - -// Ensure that when running in CFv1 "shim" mode, all connection attempts are -// trivially redirected to a fuchsia.sys.Runner-cast service capability in -// the shim Runner's environment. -TEST_F(CastRunnerCfv1ShimIntegrationTest, ProxiesConnect) { - ASSERT_EQ(received_requests_.size(), 0u); - - // The test constructor launched the CastRunner, configured as CFv1 shim, - // and immediately connected to it. That should result in two requests via the - // additional-services, which will be handled by |fake_runner_publisher_| - // as soon as the message loop is allowed to pump events. - // The first request is from the Runner shim itself, to allow it to monitor - // whether the service capability is still valid. - // The second is the test's connection to the shim Runner. - RunUntilRequestsReceived(2u); -} - -// Ensure that CFv1 "shim" mode tears down the Runner component if the -// underlying service capability disconnects it. This is required in order to -// have the shim correctly reflect instability in the real Runner, to the CFv1 -// framework. -TEST_F(CastRunnerCfv1ShimIntegrationTest, ExitOnFailure) { - // |cast_runner_shim_| is expected to disconnect, so remove the error handler. - cast_runner_shim_ptr().set_error_handler([](zx_status_t) {}); - - // Wait for the two incoming Runner connections. - RunUntilRequestsReceived(2u); - - // Close the two connections, and expect the Runner to self-terminate. - received_requests_.clear(); - base::RunLoop loop; - controller_ptr().set_error_handler( - [quit_loop = loop.QuitClosure()](zx_status_t status) { - EXPECT_EQ(status, ZX_ERR_PEER_CLOSED); - quit_loop.Run(); - }); - loop.Run(); -}
diff --git a/fuchsia_web/runners/cast/cast_runner_integration_test.cc b/fuchsia_web/runners/cast/cast_runner_integration_test.cc index 3e37628..d9e533f 100644 --- a/fuchsia_web/runners/cast/cast_runner_integration_test.cc +++ b/fuchsia_web/runners/cast/cast_runner_integration_test.cc
@@ -5,30 +5,25 @@ #include <fuchsia/camera3/cpp/fidl.h> #include <fuchsia/legacymetrics/cpp/fidl.h> #include <fuchsia/media/cpp/fidl.h> -#include <fuchsia/modular/cpp/fidl.h> #include <fuchsia/web/cpp/fidl.h> #include <lib/fdio/directory.h> #include <lib/fidl/cpp/binding.h> #include <lib/sys/cpp/component_context.h> #include <lib/ui/scenic/cpp/view_ref_pair.h> #include <lib/ui/scenic/cpp/view_token_pair.h> -#include <lib/zx/channel.h> -#include <zircon/processargs.h> #include <utility> #include <vector> #include "base/auto_reset.h" -#include "base/barrier_closure.h" #include "base/base_paths.h" #include "base/files/file_util.h" #include "base/fuchsia/file_utils.h" -#include "base/fuchsia/filtered_service_directory.h" #include "base/fuchsia/fuchsia_logging.h" #include "base/fuchsia/mem_buffer_util.h" #include "base/fuchsia/scoped_service_binding.h" -#include "base/fuchsia/test_component_controller.h" #include "base/functional/callback_helpers.h" +#include "base/guid.h" #include "base/path_service.h" #include "base/run_loop.h" #include "base/strings/strcat.h" @@ -39,6 +34,7 @@ #include "base/test/test_timeouts.h" #include "build/build_config.h" #include "build/chromecast_buildflags.h" +#include "components/fuchsia_component_support/dynamic_component_host.h" #include "fuchsia_web/common/string_util.h" #include "fuchsia_web/common/test/fit_adapter.h" #include "fuchsia_web/common/test/frame_test_util.h" @@ -50,8 +46,6 @@ #include "fuchsia_web/runners/cast/fake_api_bindings.h" #include "fuchsia_web/runners/cast/fake_application_config_manager.h" #include "fuchsia_web/runners/cast/fidl/fidl/hlcpp/chromium/cast/cpp/fidl.h" -#include "fuchsia_web/runners/common/modular/agent_impl.h" -#include "fuchsia_web/runners/common/modular/fake_component_context.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -62,9 +56,6 @@ constexpr char kBlankAppUrl[] = "/defaultresponse"; constexpr char kEchoHeaderPath[] = "/echoheader?Test"; -constexpr char kDummyAgentUrl[] = - "fuchsia-pkg://fuchsia.com/dummy_agent#meta/dummy_agent.cmx"; - chromium::cast::ApplicationConfig CreateAppConfigWithTestData( base::StringPiece app_id, GURL url) { @@ -124,14 +115,27 @@ FakeApplicationContext(const FakeApplicationContext&) = delete; FakeApplicationContext& operator=(const FakeApplicationContext&) = delete; - chromium::cast::ApplicationController* controller() { - if (!controller_) + chromium::cast::ApplicationController* application_controller() { + if (!application_controller_) { return nullptr; + } - return controller_.get(); + return application_controller_.get(); + } + + void WaitForSetApplicationController() { + if (application_controller_) { + return; + } + base::RunLoop loop; + on_set_application_controller_ = loop.QuitClosure(); + loop.Run(); } absl::optional<int64_t> WaitForApplicationTerminated() { + if (application_exit_code_.has_value()) { + return application_exit_code_; + } base::RunLoop loop; on_application_terminated_ = loop.QuitClosure(); loop.Run(); @@ -144,162 +148,96 @@ callback(1); } void SetApplicationController( - fidl::InterfaceHandle<chromium::cast::ApplicationController> controller) - override { - controller_ = controller.Bind(); + fidl::InterfaceHandle<chromium::cast::ApplicationController> + application_controller) override { + application_controller_ = application_controller.Bind(); + if (on_set_application_controller_) { + std::move(on_set_application_controller_).Run(); + } } void OnApplicationExit(int64_t exit_code) override { application_exit_code_ = exit_code; - if (on_application_terminated_) + if (on_application_terminated_) { std::move(on_application_terminated_).Run(); + } } - chromium::cast::ApplicationControllerPtr controller_; + chromium::cast::ApplicationControllerPtr application_controller_; + base::OnceClosure on_set_application_controller_; absl::optional<int64_t> application_exit_code_; base::OnceClosure on_application_terminated_; }; -class FakeComponentState : public cr_fuchsia::AgentImpl::ComponentStateBase { - public: - FakeComponentState(base::StringPiece component_url, - chromium::cast::ApiBindings* bindings_manager, - chromium::cast::UrlRequestRewriteRulesProvider* - url_request_rules_provider, - base::OnceClosure on_delete) - : ComponentStateBase(component_url), - bindings_manager_binding_(outgoing_directory(), bindings_manager), - context_binding_(outgoing_directory(), &application_context_), - on_delete_(std::move(on_delete)) { - if (url_request_rules_provider) { - url_request_rules_provider_binding_.emplace(outgoing_directory(), - url_request_rules_provider); - } - } - - ~FakeComponentState() override { - if (on_delete_) - std::move(on_delete_).Run(); - } - FakeComponentState(const FakeComponentState&) = delete; - FakeComponentState& operator=(const FakeComponentState&) = delete; - - // Make outgoing_directory() public. - using ComponentStateBase::outgoing_directory; - - FakeApplicationContext* application_context() { - return &application_context_; - } - - void Disconnect() { DisconnectClientsAndTeardown(); } - - bool api_bindings_has_clients() { - return bindings_manager_binding_.has_clients(); - } - - bool url_request_rules_provider_has_clients() { - if (url_request_rules_provider_binding_) { - return url_request_rules_provider_binding_->has_clients(); - } - return false; - } - - protected: - const base::ScopedServiceBinding<chromium::cast::ApiBindings> - bindings_manager_binding_; - absl::optional<base::ScopedServiceBinding< - chromium::cast::UrlRequestRewriteRulesProvider>> - url_request_rules_provider_binding_; - - FakeApplicationContext application_context_; - const base::ScopedServiceBinding<chromium::cast::ApplicationContext> - context_binding_; - base::OnceClosure on_delete_; -}; - class TestCastComponent { public: - explicit TestCastComponent(fuchsia::sys::RunnerPtr& cast_runner) - : cast_runner_(cast_runner.get()) { - EXPECT_TRUE(cast_runner_); + // `test_realm_services` is used to connect to the test `Realm` exposed by + // the CastRunnerLauncher, that contains a collection capable of resolving + // and running Cast components. + explicit TestCastComponent(const sys::ServiceDirectory& test_realm_services) + : test_realm_services_(test_realm_services) { + // Instantiate the per-instance service directory and fakes by default, + // for tests to configure & add expectations to. + services_.emplace(); } ~TestCastComponent() { ShutdownComponent(); } TestCastComponent(const TestCastComponent&) = delete; - TestCastComponent& operator=(const FakeComponentState&) = delete; + TestCastComponent& operator=(const TestCastComponent&) = delete; - void CreateComponentContextAndStartComponent( - base::StringPiece app_id = kTestAppId) { - ASSERT_FALSE(component_context_) - << "ComponentContext may only be created once"; + void disable_offer_services() { offer_services_ = false; } + void offer_closed_services() { offer_closed_services_ = true; } + + // Attempts to start the Cast activity identified by `app_id`, and to inject + // script bindings to support querying JavaScript/DOM state via the + // the `ExecuteJavaScript()` API (see below). + // Note that this function will not return until the activity has actually + // launched. + void StartCastComponentWithQueryApi(base::StringPiece app_id = kTestAppId) { auto component_url = base::StrCat({"cast:", app_id}); InjectQueryApi(); - CreateComponentContext(component_url); StartCastComponent(component_url); - WaitComponentStateCreated(); WaitQueryApiConnected(); } - void CreateComponentContext(const base::StringPiece& component_url, - bool with_fake_agent = true) { - ASSERT_FALSE(component_context_) - << "ComponentContext may only be created once"; - url_request_rewrite_rules_provider_ = - std::make_unique<FakeUrlRequestRewriteRulesProvider>(); - component_context_ = std::make_unique<cr_fuchsia::FakeComponentContext>( - &component_services_, component_url); - if (with_fake_agent) { - component_context_->RegisterCreateComponentStateCallback( - FakeApplicationConfigManager::kFakeAgentUrl, - base::BindRepeating(&TestCastComponent::OnComponentConnect, - base::Unretained(this))); - } - } - + // Attempts to start the Cast activity identified by `app_id`. + // Note that activity launch is asynchronous, tests that need to wait until + // the activity has actually started (e.g. to interact with its + // `ApplicationController`, etc), should normally use the + // `StartCastComponentWithQueryApi()` call instead. void StartCastComponent(base::StringPiece component_url) { - ASSERT_FALSE(component_services_client_) - << "Component may only be started once"; + ASSERT_FALSE(component_) << "Component may only be started once"; - // Configure the Runner, including a service directory channel to publish - // services to. - fuchsia::sys::StartupInfo startup_info; - startup_info.launch_info.url = std::string(component_url); + fidl::InterfaceHandle<fuchsia::io::Directory> services; + if (offer_services_) { + if (offer_closed_services_) { + // Create the `services` channel, and immediately close the "request" + // end, to simulate a missing service directory. + std::ignore = services.NewRequest(); + } else { + // Create a `fuchsia.io.Directory` connected to the directory of fake + // services. + zx_status_t status = services_->services.Serve( + fuchsia::io::OpenFlags::RIGHT_READABLE | + fuchsia::io::OpenFlags::RIGHT_WRITABLE | + fuchsia::io::OpenFlags::DIRECTORY, + services.NewRequest().TakeChannel()); + ZX_CHECK(status == ZX_OK, status) << "Serve()"; + } + } - fidl::InterfaceHandle<fuchsia::io::Directory> outgoing_directory; - startup_info.launch_info.directory_request = - outgoing_directory.NewRequest(); - - fidl::InterfaceHandle<fuchsia::io::Directory> svc_directory; - EXPECT_EQ(fdio_service_connect_at( - outgoing_directory.channel().get(), "svc", - svc_directory.NewRequest().TakeChannel().release()), - ZX_OK); - - component_services_client_ = - std::make_unique<sys::ServiceDirectory>(std::move(svc_directory)); - - // Populate |component_services_| with services for the component to use. - fidl::InterfaceHandle<fuchsia::io::Directory> directory; - component_services_.GetOrCreateDirectory("svc")->Serve( - fuchsia::io::OpenFlags::RIGHT_READABLE | - fuchsia::io::OpenFlags::RIGHT_WRITABLE, - directory.NewRequest().TakeChannel()); - - // Provide the directory of services in the |flat_namespace|. - startup_info.flat_namespace.paths.emplace_back(base::kServiceDirectoryPath); - startup_info.flat_namespace.directories.emplace_back( - directory.TakeChannel()); - - fuchsia::sys::Package package; - package.resolved_url = std::string(component_url); - - cast_runner_->StartComponent(std::move(package), std::move(startup_info), - component_controller_.ptr().NewRequest()); - component_controller_.ptr().set_error_handler([](zx_status_t status) { - ZX_LOG(ERROR, status) << "Component launch failed"; - ADD_FAILURE(); - }); + // Create the new dynamic component in the test component collection for + // the `cast_runner`. The component is created with an Id chosen + // at random to uniquely identify it, and supplied with `services` as + // configured above. + component_.emplace( + test_realm_services_.Connect<fuchsia::component::Realm>(), + test::CastRunnerLauncher::kTestCollectionName, + base::GUID::GenerateRandomV4().AsLowercaseString(), component_url, + base::BindOnce(&TestCastComponent::OnComponentTeardown, + base::Unretained(this)), + std::move(services)); } // Executes |code| in the context of the test application and then returns @@ -307,6 +245,8 @@ // execution is blocked until the promise is complete and the result of the // promise is returned. std::string ExecuteJavaScript(const std::string& code) { + CHECK(test_port_); + fuchsia::web::WebMessage message; message.set_data(base::MemBufferFromString(code, "test-msg")); test_port_->PostMessage( @@ -326,61 +266,79 @@ return response_string.value_or(std::string()); } - void CheckAppUrl(const GURL& app_url) { - EXPECT_EQ(ExecuteJavaScript("window.location.href"), app_url.spec()); + std::string QueryAppUrl() { + return ExecuteJavaScript("window.location.href"); } - // Closes the ComponentController and runs until the ComponentState is - // observed to have been deleted. + // Closes active connections to all services offered to the component, + // to simulate the controlling agent tearing-down unexpectedly. + void DisconnectServices() { services_.reset(); } + + // Destroys the component and runs until it is observed to have torn-down. void ShutdownComponent() { - if (component_state_) { - component_controller_.ptr().Unbind(); + if (component_) { + component_->Destroy(); WaitForComponentDestroyed(); } } - void ExpectControllerDisconnectWithStatus(zx_status_t expected_status) { - EXPECT_TRUE(component_controller_); - - base::RunLoop loop; - component_controller_.ptr().set_error_handler( - [&loop, expected_status](zx_status_t status) { - loop.Quit(); - EXPECT_EQ(expected_status, status); - }); - - loop.Run(); - } - - // Run until the ComponentState and ComponentController are both closed. + // Runs until `component_` is observed to have torn-down. + // Note that this may return before connections to services used by + // the component have been observed to have closed. // This should be used after triggering component teardown, e.g. via an // explicit ComponentController.Kill() call, to wait for it to take effect. void WaitForComponentDestroyed() { - ASSERT_TRUE(component_state_); + ASSERT_TRUE(component_); base::RunLoop state_loop; - base::AutoReset reset_callback(&on_component_state_destroyed_, + base::AutoReset reset_callback(&on_component_destroyed_, state_loop.QuitClosure()); - - if (component_controller_) - ExpectControllerDisconnectWithStatus(ZX_ERR_PEER_CLOSED); - state_loop.Run(); } - FakeApiBindingsImpl* api_bindings() { return &api_bindings_; } - cr_fuchsia::FakeComponentContext* component_context() { - return component_context_.get(); + // Disables treatment of `component_` teardown as a test failure. This is + // useful for test of teardown-time API behaviours. + void SetIgnoreComponentDestroyed() { + on_component_destroyed_ = base::DoNothing(); } - base::TestComponentController* component_controller() { - return &component_controller_; + + FakeApiBindingsImpl& api_bindings() { return services_->api_bindings; } + FakeApplicationContext& application_context() { + return services_->application_context; } - sys::OutgoingDirectory* component_services() { return &component_services_; } - sys::ServiceDirectory* component_services_client() { - return component_services_client_.get(); + + sys::ServiceDirectory& exposed_by_component() { + return component_->exposed(); } - FakeComponentState* component_state() { return component_state_; } private: + // Used to manage fake services offered to each Cast component individually. + // Most of the FIDL services used by Cast activities are ambient, provided by + // the CastRunner itself. The services provided here are only those offered + // directly to Cast activities by their owning agent. + struct FakeComponentServices { + FakeComponentServices() + : api_bindings_binding(&services, &api_bindings), + url_request_rewrite_rules_provider_binding( + &services, + &url_request_rewrite_rules_provider), + context_binding(&services, &application_context) {} + + // Directory of services to offer to the Cast component. + vfs::PseudoDir services; + + FakeApiBindingsImpl api_bindings; + base::ScopedServiceBinding<chromium::cast::ApiBindings> + api_bindings_binding; + + FakeUrlRequestRewriteRulesProvider url_request_rewrite_rules_provider; + base::ScopedServiceBinding<chromium::cast::UrlRequestRewriteRulesProvider> + url_request_rewrite_rules_provider_binding; + + FakeApplicationContext application_context; + base::ScopedServiceBinding<chromium::cast::ApplicationContext> + context_binding; + }; + void InjectQueryApi() { // Inject an API which can be used to evaluate arbitrary Javascript and // return the results over a MessagePort. @@ -406,61 +364,43 @@ "});", "test")); binding_list.emplace_back(std::move(eval_js_binding)); - api_bindings_.set_bindings(std::move(binding_list)); + services_->api_bindings.set_bindings(std::move(binding_list)); } void WaitQueryApiConnected() { EXPECT_FALSE(test_port_); - test_port_ = api_bindings_.RunAndReturnConnectedPort("testport").Bind(); + test_port_ = + services_->api_bindings.RunAndReturnConnectedPort("testport").Bind(); } - void WaitComponentStateCreated() { - base::RunLoop run_loop; - base::AutoReset reset_callback(&on_component_state_created_, - run_loop.QuitClosure()); - run_loop.Run(); - } + void OnComponentTeardown() { + component_.reset(); - std::unique_ptr<cr_fuchsia::AgentImpl::ComponentStateBase> OnComponentConnect( - base::StringPiece component_url) { - auto component_state = std::make_unique<FakeComponentState>( - component_url, &api_bindings_, - url_request_rewrite_rules_provider_.get(), - base::BindOnce(&TestCastComponent::OnComponentStateDestroyed, - base::Unretained(this))); - component_state_ = component_state.get(); - - if (on_component_state_created_) { - std::move(on_component_state_created_).Run(); - } - - return component_state; - } - - void OnComponentStateDestroyed() { - component_state_ = nullptr; - - if (on_component_state_destroyed_) { - std::move(on_component_state_destroyed_).Run(); + if (on_component_destroyed_) { + std::move(on_component_destroyed_).Run(); + } else { + ADD_FAILURE() << "Unexpected TestCastComponent teardown."; } } - fuchsia::sys::Runner* const cast_runner_; + const sys::ServiceDirectory& test_realm_services_; - FakeApiBindingsImpl api_bindings_; - std::unique_ptr<FakeUrlRequestRewriteRulesProvider> - url_request_rewrite_rules_provider_; + // True if the Cast component should be offered a service directory channel + // that has already been closed, to simulate the providing agent having + // torn-down the directory before the component Connect()s through it. + bool offer_closed_services_ = false; - // Incoming service directory, ComponentContext and per-component state. - sys::OutgoingDirectory component_services_; - std::unique_ptr<cr_fuchsia::FakeComponentContext> component_context_; - base::TestComponentController component_controller_; - std::unique_ptr<sys::ServiceDirectory> component_services_client_; - FakeComponentState* component_state_ = nullptr; + // False if the Cast component should not be offered any service directory. + bool offer_services_ = true; + + // Holds the service directory and fake services offered to `component_`. + absl::optional<FakeComponentServices> services_; + + absl::optional<fuchsia_component_support::DynamicComponentHost> component_; + fuchsia::web::MessagePortPtr test_port_; - base::OnceClosure on_component_state_created_; - base::OnceClosure on_component_state_destroyed_; + base::OnceClosure on_component_destroyed_; }; } // namespace @@ -468,36 +408,64 @@ // A basic integration test ensuring a basic cast request launches the right // URL in the Chromium service. TEST_F(CastRunnerIntegrationTest, BasicRequest) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); GURL app_url = test_server().GetURL(kBlankAppUrl); app_config_manager().AddApp(kTestAppId, app_url); - component.CreateComponentContextAndStartComponent(); + component.StartCastComponentWithQueryApi(); - component.CheckAppUrl(app_url); + // Verify that the app has navigated to the expected URL. + EXPECT_EQ(component.QueryAppUrl(), app_url.spec()); } // Verify that the Runner can continue to be used even after its Context has // crashed. Regression test for https://crbug.com/1066826. // TODO(crbug.com/1066833): Replace this with a WebRunner test, ideally a // unit-test, which can simulate Context disconnection more simply. -// TODO(crbug.com/1010222): Once CastRunner migrates to creating the WebEngine -// component directly, it should be possible to rehabilitate and re-enable -// this test. At present it is not straightforward to terminate the -// WebEngine component instance, only the ContextProvider, which will not -// result in the WebEngine instance being torn-down. -TEST_F(CastRunnerIntegrationTest, DISABLED_CanRecreateContext) { - TestCastComponent component(cast_runner()); +TEST_F(CastRunnerIntegrationTest, CanRecreateContext) { + TestCastComponent component(test_realm_services()); const GURL app_url = test_server().GetURL(kBlankAppUrl); app_config_manager().AddApp(kTestAppId, app_url); // Create a Cast component and verify that it has loaded. - component.CreateComponentContextAndStartComponent(kTestAppId); - component.CheckAppUrl(app_url); + component.StartCastComponentWithQueryApi(kTestAppId); - // Terminate the component that provides the ContextProvider service and - // wait for the Cast component to terminate, without allowing the message- - // loop to spin in-between. + // Connect to the CastRunner's Realm, and request to enumerate the contents + // of the "web_instances" collection. + fidl::SynchronousInterfacePtr<fuchsia::component::Realm> runner_realm; + test_realm_services().Connect( + runner_realm.NewRequest(), + test::CastRunnerLauncher::kCastRunnerRealmProtocol); + fidl::SynchronousInterfacePtr<fuchsia::component::ChildIterator> + instance_iterator; + fuchsia::component::Realm_ListChildren_Result list_children_result; + zx_status_t status = runner_realm->ListChildren( + fuchsia::component::decl::CollectionRef{.name = "web_instances"}, + instance_iterator.NewRequest(), &list_children_result); + ASSERT_EQ(status, ZX_OK); + ASSERT_FALSE(list_children_result.is_err()); + + // The CastRunner's "web_instances" collection should contain exactly one + // child component. + std::vector<fuchsia::component::decl::ChildRef> web_instance_refs; + status = instance_iterator->Next(&web_instance_refs); + ASSERT_EQ(status, ZX_OK); + ASSERT_EQ(web_instance_refs.size(), 1u); + + // Verify that no further children remain in "web_instances". + std::vector<fuchsia::component::decl::ChildRef> empty_web_instance_refs; + status = instance_iterator->Next(&empty_web_instance_refs); + ASSERT_EQ(status, ZX_OK); + ASSERT_TRUE(empty_web_instance_refs.empty()); + + // Destroy the one child of the "web_instances" collection. + fuchsia::component::Realm_DestroyChild_Result destroy_child_result; + status = runner_realm->DestroyChild(std::move(web_instance_refs[0]), + &destroy_child_result); + ASSERT_EQ(status, ZX_OK); + ASSERT_FALSE(destroy_child_result.is_err()); + + // Expect that the Cast component goes away, since its container is gone. component.WaitForComponentDestroyed(); // Create a second Cast component and verify that it has loaded. @@ -505,71 +473,63 @@ // disconnecting yet, so attempts to launch Cast components could fail. // WebContentRunner::CreateFrameWithParams() will synchronously verify that // the web.Context is not-yet-closed, to work-around that. - TestCastComponent second_component(cast_runner()); - app_config_manager().AddApp(kTestAppId, app_url); - second_component.CreateComponentContextAndStartComponent(kTestAppId); - second_component.CheckAppUrl(app_url); + TestCastComponent second_component(test_realm_services()); + second_component.StartCastComponentWithQueryApi(kTestAppId); } TEST_F(CastRunnerIntegrationTest, ApiBindings) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); app_config_manager().AddApp(kTestAppId, test_server().GetURL(kBlankAppUrl)); - component.CreateComponentContextAndStartComponent(); + component.StartCastComponentWithQueryApi(); - // Verify that we can communicate with the binding added in - // CastRunnerIntegrationTest(). + // Verify that we can communicate with the query-API binding added by + // `StartCastComponentWithQueryApi()`. EXPECT_EQ(component.ExecuteJavaScript("1+2+\"\""), "3"); } -TEST_F(CastRunnerIntegrationTest, IncorrectCastAppId) { - TestCastComponent component(cast_runner()); - const char kIncorrectComponentUrl[] = "cast:99999999"; +TEST_F(CastRunnerIntegrationTest, UnknownCastAppId_Fails) { + TestCastComponent component(test_realm_services()); + const char kUnknownComponentUrl[] = "cast:99999999"; - component.CreateComponentContext(kIncorrectComponentUrl); - component.StartCastComponent(kIncorrectComponentUrl); + component.StartCastComponent(kUnknownComponentUrl); // Run the loop until the ComponentController is dropped. - component.ExpectControllerDisconnectWithStatus(ZX_ERR_PEER_CLOSED); - - EXPECT_TRUE(!component.component_state()); + component.WaitForComponentDestroyed(); } TEST_F(CastRunnerIntegrationTest, UrlRequestRewriteRulesProvider) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); GURL echo_app_url = test_server().GetURL(kEchoHeaderPath); app_config_manager().AddApp(kTestAppId, echo_app_url); - component.CreateComponentContextAndStartComponent(); - - component.CheckAppUrl(echo_app_url); + component.StartCastComponentWithQueryApi(); EXPECT_EQ(component.ExecuteJavaScript("document.body.innerText"), "TestHeaderValue"); } TEST_F(CastRunnerIntegrationTest, ApplicationControllerBound) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); app_config_manager().AddApp(kTestAppId, test_server().GetURL(kBlankAppUrl)); - component.CreateComponentContextAndStartComponent(); + component.StartCastComponentWithQueryApi(); - // Spin the message loop to handle creation of the component state. - base::RunLoop().RunUntilIdle(); - ASSERT_TRUE(component.component_state()); - EXPECT_TRUE(component.component_state()->application_context()->controller()); + // Run until the application calls SetApplicationController(). + component.application_context().WaitForSetApplicationController(); + EXPECT_TRUE(component.application_context().application_controller()); } // Verify an App launched with remote debugging enabled is properly reachable. TEST_F(CastRunnerIntegrationTest, RemoteDebugging) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); GURL app_url = test_server().GetURL(kBlankAppUrl); auto app_config = FakeApplicationConfigManager::CreateConfig(kTestAppId, app_url); app_config.set_enable_remote_debugging(true); app_config_manager().AddAppConfig(std::move(app_config)); - component.CreateComponentContextAndStartComponent(); + component.StartCastComponentWithQueryApi(); // Connect to the debug service and ensure we get the proper response. base::Value::List devtools_list = @@ -582,158 +542,59 @@ } TEST_F(CastRunnerIntegrationTest, IsolatedContext) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); const GURL kContentDirectoryUrl("fuchsia-dir://testdata/empty.html"); app_config_manager().AddAppConfig( CreateAppConfigWithTestData(kTestAppId, kContentDirectoryUrl)); - component.CreateComponentContextAndStartComponent(); - component.CheckAppUrl(kContentDirectoryUrl); + component.StartCastComponentWithQueryApi(); + + // Verify that the app was navigated to the isolated content URL. + EXPECT_EQ(component.QueryAppUrl(), kContentDirectoryUrl.spec()); } -// Test the lack of CastAgent service does not cause a CastRunner crash. -TEST_F(CastRunnerIntegrationTest, NoCastAgent) { - TestCastComponent component(cast_runner()); +// Verify that the component fails to start if no service directory is offered. +TEST_F(CastRunnerIntegrationTest, ServiceDirectoryMissing_FailToStart) { + TestCastComponent component(test_realm_services()); + component.disable_offer_services(); app_config_manager().AddApp(kTestAppId, test_server().GetURL(kEchoHeaderPath)); component.StartCastComponent(base::StrCat({"cast:", kTestAppId})); - component.ExpectControllerDisconnectWithStatus(ZX_ERR_PEER_CLOSED); + // Expect that the component stops. + component.WaitForComponentDestroyed(); } -// Test the CastAgent disconnecting does not cause a CastRunner crash. -TEST_F(CastRunnerIntegrationTest, DisconnectedCastAgent) { - TestCastComponent component(cast_runner()); +// Verify that the component fails to start if the offered service directory +// channel has already been closed, such that Connect() calls will result in +// service request channels being dropped. +TEST_F(CastRunnerIntegrationTest, ServiceDirectoryEmpty_FailToStart) { + TestCastComponent component(test_realm_services()); + component.offer_closed_services(); app_config_manager().AddApp(kTestAppId, test_server().GetURL(kEchoHeaderPath)); - component.CreateComponentContextAndStartComponent(); + component.StartCastComponent(base::StrCat({"cast:", kTestAppId})); - // Tear down the ComponentState, this should close the Agent connection and - // shut down the CastComponent. - component.component_state()->Disconnect(); - - component.ExpectControllerDisconnectWithStatus(ZX_ERR_PEER_CLOSED); + // Expect that the component stops. + component.WaitForComponentDestroyed(); } -// Test that the ApiBindings and RewriteRules are received from the secondary -// DummyAgent. This validates that the |agent_url| retrieved from -// AppConfigManager is the one used to retrieve the bindings and the rewrite -// rules. -TEST_F(CastRunnerIntegrationTest, ApplicationConfigAgentUrl) { - TestCastComponent component(cast_runner()); +// Simulate an Agent crash by tearing down `services_`, resulting in the +// service-directory and bindings passed to the Cast activity itself being +// closed. This should cause the component to terminate. +TEST_F(CastRunnerIntegrationTest, ServicesClose_TerminatesComponent) { + TestCastComponent component(test_realm_services()); + app_config_manager().AddApp(kTestAppId, + test_server().GetURL(kEchoHeaderPath)); - // These are part of the secondary agent, and CastRunner will contact - // the secondary agent for both of them. - FakeUrlRequestRewriteRulesProvider dummy_url_request_rewrite_rules_provider; - FakeApiBindingsImpl dummy_agent_api_bindings; + component.StartCastComponentWithQueryApi(); - // Indicate that this app is to get bindings from a secondary agent. - auto app_config = FakeApplicationConfigManager::CreateConfig( - kTestAppId, test_server().GetURL(kBlankAppUrl)); - app_config.set_agent_url(kDummyAgentUrl); - app_config_manager().AddAppConfig(std::move(app_config)); + // Disconnect all service bindings. + component.DisconnectServices(); - // Instantiate the bindings that are returned in the multi-agent scenario. The - // bindings returned for the single-agent scenario are not initialized. - std::vector<chromium::cast::ApiBinding> binding_list; - chromium::cast::ApiBinding echo_binding; - echo_binding.set_before_load_script(base::MemBufferFromString( - "window.echo = cast.__platform__.PortConnector.bind('dummyService');", - "test")); - binding_list.emplace_back(std::move(echo_binding)); - // Assign the bindings to the multi-agent binding. - dummy_agent_api_bindings.set_bindings(std::move(binding_list)); - - auto component_url = base::StrCat({"cast:", kTestAppId}); - component.CreateComponentContext(component_url, /*with_fake_agent=*/false); - EXPECT_TRUE(component.component_context()); - - base::RunLoop shutdown_run_loop; - base::RunLoop run_loop; - FakeComponentState* dummy_component_state = nullptr; - component.component_context()->RegisterCreateComponentStateCallback( - kDummyAgentUrl, - base::BindLambdaForTesting( - [&](base::StringPiece component_url) - -> std::unique_ptr<cr_fuchsia::AgentImpl::ComponentStateBase> { - run_loop.Quit(); - auto result = std::make_unique<FakeComponentState>( - component_url, &dummy_agent_api_bindings, - &dummy_url_request_rewrite_rules_provider, - shutdown_run_loop.QuitClosure()); - dummy_component_state = result.get(); - return result; - })); - - component.StartCastComponent(component_url); - - // Wait for the component state to be created. - run_loop.Run(); - - // Validate that the component state in the default agent wasn't crated. - EXPECT_FALSE(component.component_state()); - - // Shutdown component before destroying dummy_agent_api_bindings. - component.component_controller()->ptr().Unbind(); - shutdown_run_loop.Run(); -} - -// Test that when RewriteRules are not provided, a WebComponent is still -// created. Further validate that the primary agent does not provide ApiBindings -// or RewriteRules. -TEST_F(CastRunnerIntegrationTest, ApplicationConfigAgentUrlRewriteOptional) { - TestCastComponent component(cast_runner()); - FakeApiBindingsImpl dummy_agent_api_bindings; - - // Indicate that this app is to get bindings from a secondary agent. - auto app_config = FakeApplicationConfigManager::CreateConfig( - kTestAppId, test_server().GetURL(kBlankAppUrl)); - app_config.set_agent_url(kDummyAgentUrl); - app_config_manager().AddAppConfig(std::move(app_config)); - - // Instantiate the bindings that are returned in the multi-agent scenario. The - // bindings returned for the single-agent scenario are not initialized. - std::vector<chromium::cast::ApiBinding> binding_list; - chromium::cast::ApiBinding echo_binding; - echo_binding.set_before_load_script(base::MemBufferFromString( - "window.echo = cast.__platform__.PortConnector.bind('dummyService');", - "test")); - binding_list.emplace_back(std::move(echo_binding)); - // Assign the bindings to the multi-agent binding. - dummy_agent_api_bindings.set_bindings(std::move(binding_list)); - - auto component_url = base::StrCat({"cast:", kTestAppId}); - component.CreateComponentContext(component_url, /*with_fake_agent=*/false); - - base::RunLoop shutdown_run_loop; - base::RunLoop run_loop; - FakeComponentState* dummy_component_state = nullptr; - component.component_context()->RegisterCreateComponentStateCallback( - kDummyAgentUrl, - base::BindLambdaForTesting( - [&](base::StringPiece component_url) - -> std::unique_ptr<cr_fuchsia::AgentImpl::ComponentStateBase> { - run_loop.Quit(); - auto result = std::make_unique<FakeComponentState>( - component_url, &dummy_agent_api_bindings, nullptr, - shutdown_run_loop.QuitClosure()); - dummy_component_state = result.get(); - return result; - })); - - component.StartCastComponent(component_url); - - // Wait for the component state to be created. - run_loop.Run(); - - // Validate that the component state in the default agent wasn't crated. - EXPECT_FALSE(component.component_state()); - - // Shutdown component before destroying dummy_agent_api_bindings. - component.component_controller()->ptr().Unbind(); - shutdown_run_loop.Run(); + component.WaitForComponentDestroyed(); } class AudioCastRunnerIntegrationTest : public CastRunnerIntegrationTest { @@ -744,7 +605,7 @@ }; TEST_F(AudioCastRunnerIntegrationTest, Microphone) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); GURL app_url = test_server().GetURL("/microphone.html"); auto app_config = FakeApplicationConfigManager::CreateConfig(kTestAppId, app_url); @@ -759,7 +620,7 @@ cast_runner_launcher().fake_cast_agent().RegisterOnConnectClosure( fuchsia::media::Audio::Name_, run_loop.QuitClosure()); - component.CreateComponentContextAndStartComponent(); + component.StartCastComponentWithQueryApi(); component.ExecuteJavaScript("connectMicrophone();"); // Will quit once AudioCapturer is connected. @@ -767,7 +628,7 @@ } TEST_F(CastRunnerIntegrationTest, Camera) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); GURL app_url = test_server().GetURL("/camera.html"); auto app_config = FakeApplicationConfigManager::CreateConfig(kTestAppId, app_url); @@ -782,13 +643,13 @@ fuchsia::camera3::DeviceWatcher::Name_, base::MakeExpectedRunAtLeastOnceClosure(FROM_HERE)); - component.CreateComponentContextAndStartComponent(); + component.StartCastComponentWithQueryApi(); component.ExecuteJavaScript("connectCamera();"); } TEST_F(CastRunnerIntegrationTest, CameraAccessAfterComponentShutdown) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); GURL app_url = test_server().GetURL("/camera.html"); // First app with camera permission. @@ -801,25 +662,25 @@ // Second app without camera permission (but it will still try to access // fuchsia.camera3.DeviceWatcher service to enumerate devices). - TestCastComponent second_component(cast_runner()); + TestCastComponent second_component(test_realm_services()); auto app_config_2 = FakeApplicationConfigManager::CreateConfig(kSecondTestAppId, app_url); app_config_manager().AddAppConfig(std::move(app_config_2)); // Start and then shutdown the first app. - component.CreateComponentContextAndStartComponent(kTestAppId); + component.StartCastComponentWithQueryApi(kTestAppId); component.ShutdownComponent(); // Start the second app and try to connect the camera. It's expected to fail // to initialize the camera without crashing CastRunner. - second_component.CreateComponentContextAndStartComponent(kSecondTestAppId); + second_component.StartCastComponentWithQueryApi(kSecondTestAppId); EXPECT_EQ(second_component.ExecuteJavaScript("connectCamera();"), "getUserMediaFailed"); } TEST_F(CastRunnerIntegrationTest, MultipleComponentsUsingCamera) { - TestCastComponent first_component(cast_runner()); - TestCastComponent second_component(cast_runner()); + TestCastComponent first_component(test_realm_services()); + TestCastComponent second_component(test_realm_services()); GURL app_url = test_server().GetURL("/camera.html"); @@ -835,7 +696,7 @@ camera_permission1.set_type(fuchsia::web::PermissionType::CAMERA); app_config1.mutable_permissions()->push_back(std::move(camera_permission1)); app_config_manager().AddAppConfig(std::move(app_config1)); - first_component.CreateComponentContextAndStartComponent(kTestAppId); + first_component.StartCastComponentWithQueryApi(kTestAppId); auto app_config2 = FakeApplicationConfigManager::CreateConfig(kSecondTestAppId, app_url); @@ -843,7 +704,7 @@ camera_permission2.set_type(fuchsia::web::PermissionType::CAMERA); app_config2.mutable_permissions()->push_back(std::move(camera_permission2)); app_config_manager().AddAppConfig(std::move(app_config2)); - second_component.CreateComponentContextAndStartComponent(kSecondTestAppId); + second_component.StartCastComponentWithQueryApi(kSecondTestAppId); // Shut down the first component. first_component.ShutdownComponent(); @@ -860,45 +721,47 @@ // A basic integration test ensuring a basic cast request launches the right // URL in the Chromium service. TEST_F(HeadlessCastRunnerIntegrationTest, Headless) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); const char kAnimationPath[] = "/css_animation.html"; const GURL animation_url = test_server().GetURL(kAnimationPath); app_config_manager().AddApp(kTestAppId, animation_url); - component.CreateComponentContextAndStartComponent(); + component.StartCastComponentWithQueryApi(); auto tokens = scenic::ViewTokenPair::New(); auto view_ref_pair = scenic::ViewRefPair::New(); // Create a view. - auto view_provider = component.component_services_client() - ->Connect<fuchsia::ui::app::ViewProvider>(); + auto view_provider = component.exposed_by_component() + .Connect<fuchsia::ui::app::ViewProvider>(); view_provider->CreateViewWithViewRef( std::move(tokens.view_holder_token.value), std::move(view_ref_pair.control_ref), std::move(view_ref_pair.view_ref)); - component.api_bindings()->RunAndReturnConnectedPort("animation_finished"); + component.api_bindings().RunAndReturnConnectedPort("animation_finished"); // Verify that dropped "view" EventPair is handled properly. tokens.view_token.value.reset(); - component.api_bindings()->RunAndReturnConnectedPort("view_hidden"); + component.api_bindings().RunAndReturnConnectedPort("view_hidden"); } // Isolated *and* headless? Doesn't sound like much fun! TEST_F(HeadlessCastRunnerIntegrationTest, IsolatedAndHeadless) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); const GURL kContentDirectoryUrl("fuchsia-dir://testdata/empty.html"); app_config_manager().AddAppConfig( CreateAppConfigWithTestData(kTestAppId, kContentDirectoryUrl)); - component.CreateComponentContextAndStartComponent(); - component.CheckAppUrl(kContentDirectoryUrl); + component.StartCastComponentWithQueryApi(); + + // Verify that the app was able to navigate to the isolated content URL. + EXPECT_EQ(component.QueryAppUrl(), kContentDirectoryUrl.spec()); } // Verifies that the Context can establish a connection to the Agent's // MetricsRecorder service. TEST_F(CastRunnerIntegrationTest, LegacyMetricsRedirect) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); GURL app_url = test_server().GetURL(kBlankAppUrl); app_config_manager().AddApp(kTestAppId, app_url); @@ -912,7 +775,7 @@ // If the Component is going to connect to the MetricsRecorder service, it // will have done so by the time the Component is responding. - component.CreateComponentContextAndStartComponent(); + component.StartCastComponentWithQueryApi(); ASSERT_EQ(connected_to_metrics_recorder_service, #if BUILDFLAG(ENABLE_CAST_RECEIVER) true @@ -925,97 +788,50 @@ // Verifies that the ApplicationContext::OnApplicationTerminated() is notified // with the component exit code if the web content closes itself. TEST_F(CastRunnerIntegrationTest, OnApplicationTerminated_WindowClose) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); const GURL url = test_server().GetURL(kBlankAppUrl); app_config_manager().AddApp(kTestAppId, url); - component.CreateComponentContextAndStartComponent(); + component.StartCastComponentWithQueryApi(); - // It is possible to observe the ComponentController close before + // It is possible to observe the component teardown before // OnApplicationTerminated() is received, so ignore that. - component.component_controller()->ptr().set_error_handler([](zx_status_t) {}); + component.SetIgnoreComponentDestroyed(); // Have the web content close itself, and wait for OnApplicationTerminated(). EXPECT_EQ(component.ExecuteJavaScript("window.close()"), "undefined"); - absl::optional<zx_status_t> exit_code = component.component_state() - ->application_context() - ->WaitForApplicationTerminated(); + absl::optional<zx_status_t> exit_code = + component.application_context().WaitForApplicationTerminated(); ASSERT_TRUE(exit_code); EXPECT_EQ(exit_code.value(), ZX_OK); } -// Verifies that the ComponentController reports TerminationReason::EXITED and -// exit code ZX_OK if the web content terminates itself. -// TODO(https://crbug.com/1066833): Make this a WebRunner test. -TEST_F(CastRunnerIntegrationTest, OnTerminated_WindowClose) { - TestCastComponent component(cast_runner()); +// Verifies that the ApplicationContext::OnApplicationTerminated() is notified +// with the component exit code if the component is requested to stop. +TEST_F(CastRunnerIntegrationTest, OnApplicationTerminated_ComponentStop) { + TestCastComponent component(test_realm_services()); const GURL url = test_server().GetURL(kBlankAppUrl); app_config_manager().AddApp(kTestAppId, url); - component.CreateComponentContextAndStartComponent(); + component.StartCastComponentWithQueryApi(); - // Register an handler on the ComponentController channel, for the - // OnTerminated event. - base::RunLoop exit_code_loop; - component.component_controller()->ptr().set_error_handler( - [quit_loop = exit_code_loop.QuitClosure()](zx_status_t) { - quit_loop.Run(); - ADD_FAILURE(); - }); - component.component_controller()->ptr().events().OnTerminated = - [quit_loop = exit_code_loop.QuitClosure()]( - int64_t exit_code, fuchsia::sys::TerminationReason reason) { - quit_loop.Run(); - EXPECT_EQ(reason, fuchsia::sys::TerminationReason::EXITED); - EXPECT_EQ(exit_code, ZX_OK); - }; + // It is possible to observe the component teardown before + // OnApplicationTerminated() is received, so ignore that. + component.SetIgnoreComponentDestroyed(); - // Have the web content close itself, and wait for OnTerminated(). - EXPECT_EQ(component.ExecuteJavaScript("window.close()"), "undefined"); - exit_code_loop.Run(); - - // TestComponent's destructor will spin the loop until the ComponentState is - // torn down. -} - -// Verifies that the ComponentController reports TerminationReason::EXITED and -// exit code ZX_OK if Kill() is used. -// TODO(https://crbug.com/1066833): Make this a WebRunner test. -TEST_F(CastRunnerIntegrationTest, OnTerminated_ComponentKill) { - TestCastComponent component(cast_runner()); - const GURL url = test_server().GetURL(kBlankAppUrl); - app_config_manager().AddApp(kTestAppId, url); - - component.CreateComponentContextAndStartComponent(); - - // Register an handler on the ComponentController channel, for the - // OnTerminated event. - base::RunLoop exit_code_loop; - component.component_controller()->ptr().set_error_handler( - [quit_loop = exit_code_loop.QuitClosure()](zx_status_t) { - quit_loop.Run(); - ADD_FAILURE(); - }); - component.component_controller()->ptr().events().OnTerminated = - [quit_loop = exit_code_loop.QuitClosure()]( - int64_t exit_code, fuchsia::sys::TerminationReason reason) { - quit_loop.Run(); - EXPECT_EQ(reason, fuchsia::sys::TerminationReason::EXITED); - EXPECT_EQ(exit_code, ZX_OK); - }; - - // Kill() the component and wait for OnTerminated(). - component.component_controller()->ptr()->Kill(); - exit_code_loop.Run(); - - // TestComponent's destructor will spin the loop until the ComponentState is - // torn down. + // Request that the component be destroyed, and wait for + // OnApplicationTerminated(). + component.ShutdownComponent(); + absl::optional<zx_status_t> exit_code = + component.application_context().WaitForApplicationTerminated(); + ASSERT_TRUE(exit_code); + EXPECT_EQ(exit_code.value(), ZX_OK); } // Ensures that CastRunner handles the value not being specified. // TODO(https://crrev.com/c/2516246): Check for no logging. TEST_F(CastRunnerIntegrationTest, InitialMinConsoleLogSeverity_NotSet) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); GURL app_url = test_server().GetURL(kBlankAppUrl); auto app_config = FakeApplicationConfigManager::CreateConfig(kTestAppId, app_url); @@ -1023,14 +839,12 @@ EXPECT_FALSE(app_config.has_initial_min_console_log_severity()); app_config_manager().AddAppConfig(std::move(app_config)); - component.CreateComponentContextAndStartComponent(); - - component.CheckAppUrl(app_url); + component.StartCastComponentWithQueryApi(); } // TODO(https://crrev.com/c/2516246): Check for logging. TEST_F(CastRunnerIntegrationTest, InitialMinConsoleLogSeverity_DEBUG) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); GURL app_url = test_server().GetURL(kBlankAppUrl); auto app_config = FakeApplicationConfigManager::CreateConfig(kTestAppId, app_url); @@ -1039,31 +853,28 @@ fuchsia::diagnostics::Severity::DEBUG; app_config_manager().AddAppConfig(std::move(app_config)); - component.CreateComponentContextAndStartComponent(); - - component.CheckAppUrl(app_url); + component.StartCastComponentWithQueryApi(); } TEST_F(CastRunnerIntegrationTest, WebGLContextAbsentWithoutVulkanFeature) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); const char kTestPath[] = "/webgl_presence.html"; const GURL test_url = test_server().GetURL(kTestPath); app_config_manager().AddApp(kTestAppId, test_url); - component.CreateComponentContextAndStartComponent(); + component.StartCastComponentWithQueryApi(); EXPECT_EQ(component.ExecuteJavaScript("document.title"), "absent"); } TEST_F(CastRunnerIntegrationTest, WebGLContextAbsentWithoutVulkanFeature_IsolatedRunner) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); const GURL kContentDirectoryUrl("fuchsia-dir://testdata/webgl_presence.html"); app_config_manager().AddAppConfig( CreateAppConfigWithTestData(kTestAppId, kContentDirectoryUrl)); - component.CreateComponentContextAndStartComponent(); - component.CheckAppUrl(kContentDirectoryUrl); + component.StartCastComponentWithQueryApi(); EXPECT_EQ(component.ExecuteJavaScript("document.title"), "absent"); } @@ -1071,16 +882,19 @@ // Verifies that starting a component fails if CORS exempt headers cannot be // fetched. TEST_F(CastRunnerIntegrationTest, MissingCorsExemptHeaderProvider) { - TestCastComponent component(cast_runner()); + // Prevent the FakeCastAgent from publishing the + // chromium.cast.CorsExemptHeaderProvider service. + cast_runner_launcher().fake_cast_agent().RegisterOnConnectClosure( + chromium::cast::CorsExemptHeaderProvider::Name_, base::DoNothing()); + + // Start the Cast component, and wait for it to be destroyed. + TestCastComponent component(test_realm_services()); GURL app_url = test_server().GetURL(kBlankAppUrl); app_config_manager().AddApp(kTestAppId, app_url); - - // Start the Cast component, and wait for the controller to disconnect. component.StartCastComponent(base::StrCat({"cast:", kTestAppId})); - component.ExpectControllerDisconnectWithStatus(ZX_ERR_PEER_CLOSED); - - EXPECT_FALSE(component.component_state()); + // Expect it to be more or less immediately torn-down. + component.WaitForComponentDestroyed(); } // Verifies that CastRunner offers a chromium.cast.DataReset service. @@ -1091,7 +905,7 @@ // data). TEST_F(CastRunnerIntegrationTest, DataReset_Service) { base::RunLoop loop; - auto data_reset = cast_runner_services().Connect<chromium::cast::DataReset>(); + auto data_reset = test_realm_services().Connect<chromium::cast::DataReset>(); data_reset.set_error_handler([quit_loop = loop.QuitClosure()](zx_status_t) { quit_loop.Run(); ADD_FAILURE(); @@ -1106,18 +920,18 @@ EXPECT_TRUE(succeeded); // Verify that it is no longer possible to launch a component. - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); GURL app_url = test_server().GetURL(kBlankAppUrl); app_config_manager().AddApp(kTestAppId, app_url); component.StartCastComponent(base::StrCat({"cast:", kTestAppId})); - component.ExpectControllerDisconnectWithStatus(ZX_ERR_PEER_CLOSED); + component.WaitForComponentDestroyed(); } // Verifies that the CastRunner exposes a fuchsia.web.FrameHost protocol // capability, without requiring any special configuration. TEST_F(CastRunnerIntegrationTest, FrameHost_Service) { // Connect to the fuchsia.web.FrameHost service and create a Frame. - auto frame_host = cast_runner_services().Connect<fuchsia::web::FrameHost>(); + auto frame_host = test_realm_services().Connect<fuchsia::web::FrameHost>(); fuchsia::web::FramePtr frame; frame_host->CreateFrameWithParams(fuchsia::web::CreateFrameParams(), frame.NewRequest()); @@ -1146,25 +960,24 @@ TEST_F(MAYBE_VulkanCastRunnerIntegrationTest, WebGLContextPresentWithVulkanFeature) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); const char kTestPath[] = "/webgl_presence.html"; const GURL test_url = test_server().GetURL(kTestPath); app_config_manager().AddApp(kTestAppId, test_url); - component.CreateComponentContextAndStartComponent(); + component.StartCastComponentWithQueryApi(); EXPECT_EQ(component.ExecuteJavaScript("document.title"), "present"); } TEST_F(MAYBE_VulkanCastRunnerIntegrationTest, WebGLContextPresentWithVulkanFeature_IsolatedRunner) { - TestCastComponent component(cast_runner()); + TestCastComponent component(test_realm_services()); const GURL kContentDirectoryUrl("fuchsia-dir://testdata/webgl_presence.html"); app_config_manager().AddAppConfig( CreateAppConfigWithTestData(kTestAppId, kContentDirectoryUrl)); - component.CreateComponentContextAndStartComponent(); - component.CheckAppUrl(kContentDirectoryUrl); + component.StartCastComponentWithQueryApi(); EXPECT_EQ(component.ExecuteJavaScript("document.title"), "present"); }
diff --git a/fuchsia_web/runners/cast/cast_runner_integration_test_base.cc b/fuchsia_web/runners/cast/cast_runner_integration_test_base.cc index 1f8e531..a652434 100644 --- a/fuchsia_web/runners/cast/cast_runner_integration_test_base.cc +++ b/fuchsia_web/runners/cast/cast_runner_integration_test_base.cc
@@ -5,7 +5,6 @@ #include "fuchsia_web/runners/cast/cast_runner_integration_test_base.h" #include <fuchsia/io/cpp/fidl.h> -#include <fuchsia/sys/cpp/fidl.h> #include <lib/fdio/fd.h> #include <lib/sys/cpp/component_context.h> #include <unistd.h> @@ -33,14 +32,7 @@ CastRunnerIntegrationTest::~CastRunnerIntegrationTest() = default; void CastRunnerIntegrationTest::SetUp() { - cast_runner_services_ = cast_runner_launcher_.StartCastRunner(); - - // Connect to the CastRunner's fuchsia.sys.Runner interface. - cast_runner_ = cast_runner_services().Connect<fuchsia::sys::Runner>(); - cast_runner_.set_error_handler([](zx_status_t status) { - ZX_LOG(ERROR, status) << "CastRunner closed channel."; - ADD_FAILURE(); - }); + test_realm_services_ = cast_runner_launcher_.Create(); static constexpr base::StringPiece kTestServerRoot( "fuchsia_web/runners/cast/testdata"); @@ -48,9 +40,3 @@ net::test_server::RegisterDefaultHandlers(&test_server_); ASSERT_TRUE(test_server_.Start()); } - -void CastRunnerIntegrationTest::TearDown() { - // Unbind the Runner channel, to prevent it from triggering an error when - // the CastRunner and WebEngine are torn down. - cast_runner_.Unbind(); -}
diff --git a/fuchsia_web/runners/cast/cast_runner_integration_test_base.h b/fuchsia_web/runners/cast/cast_runner_integration_test_base.h index fe85ae96..1705c5ba 100644 --- a/fuchsia_web/runners/cast/cast_runner_integration_test_base.h +++ b/fuchsia_web/runners/cast/cast_runner_integration_test_base.h
@@ -5,7 +5,6 @@ #ifndef FUCHSIA_WEB_RUNNERS_CAST_CAST_RUNNER_INTEGRATION_TEST_BASE_H_ #define FUCHSIA_WEB_RUNNERS_CAST_CAST_RUNNER_INTEGRATION_TEST_BASE_H_ -#include <fuchsia/sys/cpp/fidl.h> #include <lib/fidl/cpp/interface_request.h> #include <lib/sys/cpp/outgoing_directory.h> #include <lib/sys/cpp/service_directory.h> @@ -41,15 +40,14 @@ // testing::Test: void SetUp() override; - void TearDown() override; test::CastRunnerLauncher& cast_runner_launcher() { return cast_runner_launcher_; } net::EmbeddedTestServer& test_server() { return test_server_; } - fuchsia::sys::RunnerPtr& cast_runner() { return cast_runner_; } - const sys::ServiceDirectory& cast_runner_services() const { - return *cast_runner_services_; + + const sys::ServiceDirectory& test_realm_services() const { + return *test_realm_services_; } FakeApplicationConfigManager& app_config_manager() { @@ -69,9 +67,7 @@ test::CastRunnerLauncher cast_runner_launcher_; - fuchsia::sys::RunnerPtr cast_runner_; - - std::unique_ptr<sys::ServiceDirectory> cast_runner_services_; + std::unique_ptr<sys::ServiceDirectory> test_realm_services_; }; #endif // FUCHSIA_WEB_RUNNERS_CAST_CAST_RUNNER_INTEGRATION_TEST_BASE_H_
diff --git a/fuchsia_web/runners/cast/cast_runner_switches.cc b/fuchsia_web/runners/cast/cast_runner_switches.cc index 7b50520..8e676adf 100644 --- a/fuchsia_web/runners/cast/cast_runner_switches.cc +++ b/fuchsia_web/runners/cast/cast_runner_switches.cc
@@ -6,6 +6,4 @@ const char kDisableVulkanForTestsSwitch[] = "disable-vulkan-for-tests"; -const char kEnableCfv2[] = "enable-cfv2"; - const char kForceHeadlessForTestsSwitch[] = "force-headless-for-tests";
diff --git a/fuchsia_web/runners/cast/cast_runner_switches.h b/fuchsia_web/runners/cast/cast_runner_switches.h index 5b17bf12..4f20bfd1 100644 --- a/fuchsia_web/runners/cast/cast_runner_switches.h +++ b/fuchsia_web/runners/cast/cast_runner_switches.h
@@ -8,10 +8,6 @@ // Disable Vulkan flag for the cast runner. Used for tests. extern const char kDisableVulkanForTestsSwitch[]; -// Run as a CFv2 component, processing StartComponent requests from the CFv1 -// shim. -extern const char kEnableCfv2[]; - // Force headless mode. extern const char kForceHeadlessForTestsSwitch[];
diff --git a/fuchsia_web/runners/cast/cast_runner_v1.cc b/fuchsia_web/runners/cast/cast_runner_v1.cc deleted file mode 100644 index f66c8c0..0000000 --- a/fuchsia_web/runners/cast/cast_runner_v1.cc +++ /dev/null
@@ -1,255 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "fuchsia_web/runners/cast/cast_runner_v1.h" - -#include <fuchsia/component/cpp/fidl.h> -#include <fuchsia/component/decl/cpp/fidl.h> -#include <fuchsia/logger/cpp/fidl.h> -#include <fuchsia/sys/cpp/fidl.h> -#include <fuchsia/ui/app/cpp/fidl.h> -#include <lib/fdio/directory.h> -#include <lib/fidl/cpp/binding.h> -#include <lib/fidl/cpp/interface_request.h> -#include <lib/sys/cpp/outgoing_directory.h> -#include <lib/sys/cpp/service_directory.h> -#include <lib/vfs/cpp/pseudo_dir.h> - -#include <memory> -#include <string> -#include <utility> - -#include "base/fuchsia/fuchsia_logging.h" -#include "base/fuchsia/process_context.h" -#include "base/fuchsia/startup_context.h" -#include "base/guid.h" -#include "base/logging.h" -#include "components/fuchsia_component_support/dynamic_component_host.h" -#include "fuchsia_web/runners/cast/fidl/fidl/hlcpp/chromium/cast/cpp/fidl.h" -#include "fuchsia_web/runners/common/modular/agent_manager.h" -#include "third_party/abseil-cpp/absl/types/optional.h" -#include "url/gurl.h" - -namespace { - -constexpr char kCollection[] = "v1-activities"; - -// Retains the state necessary to managed a Cast CFv2 activity, running content -// on behalf of a Cast activity launched via CFv1. -// This class self-deletes when its work is complete, or when requested. -class CastComponentV1 : public fuchsia::sys::ComponentController { - public: - CastComponentV1(GURL component_url, - std::unique_ptr<base::StartupContext> startup_context, - fidl::InterfaceRequest<fuchsia::sys::ComponentController> - controller_request, - std::string agent_url) - : component_url_(std::move(component_url)), - startup_context_(std::move(startup_context)), - agent_url_(std::move(agent_url)), - child_id_(base::GUID::GenerateRandomV4().AsLowercaseString()), - agent_manager_(startup_context_->svc()) { - // Bind the ComponentController request, if provided, to trigger teardown. - if (controller_request.is_valid()) { - controller_binding_.Bind(std::move(controller_request)); - controller_binding_.set_error_handler([this](zx_status_t status) { - ZX_LOG_IF(ERROR, status != ZX_ERR_PEER_CLOSED, status) - << "ComponentController disconnected for " << component_url_; - delete this; - }); - } - - // Offer the Cast component its own LogSink. - OfferFromStartupContext<fuchsia::logger::LogSink>(); - - // Offer services from the associated Agent to the CFv2 component. - OfferFromAgent<chromium::cast::ApiBindings>(); - OfferFromAgent<chromium::cast::ApplicationContext>(); - OfferFromAgent<chromium::cast::UrlRequestRewriteRulesProvider>(); - - // Expose services from the CFv2 component, via the CFv1 component's - // outgoing directory. - ExposeFromCfv2Component<fuchsia::ui::app::ViewProvider>(); - ExposeFromCfv2Component<fuchsia::modular::Lifecycle>(); - - // Create the CFv2 dynamic child component to host the application. - fidl::InterfaceHandle<fuchsia::io::Directory> services; - zx_status_t status = - services_.Serve(fuchsia::io::OpenFlags::RIGHT_READABLE | - fuchsia::io::OpenFlags::RIGHT_WRITABLE | - fuchsia::io::OpenFlags::DIRECTORY, - services.NewRequest().TakeChannel()); - ZX_CHECK(status == ZX_OK, status) << "Serve()"; - - component_.emplace( - kCollection, child_id_, component_url_.spec(), - base::BindOnce(&CastComponentV1::OnTeardown, - // Safe because `component_` is owned by `this`. - base::Unretained(this)), - std::move(services)); - - // Start serving requests to the CFv1 outgoing directory. - startup_context_->ServeOutgoingDirectory(); - } - - private: - ~CastComponentV1() override { - // Report termination, if possible. - if (controller_binding_.is_bound()) { - controller_binding_.events().OnTerminated( - ZX_OK, fuchsia::sys::TerminationReason::EXITED); - } - } - - // fuchsia::sys::ComponentController implementation. - void Kill() override { - // Teardown of the CFv2 component will be observed via `OnTeardown`. - component_->Destroy(); - } - void Detach() override { controller_binding_.Close(ZX_OK); } - - template <typename Interface> - void OfferFromStartupContext() { - zx_status_t status = services_.AddEntry( - Interface::Name_, - std::make_unique<vfs::Service>(fidl::InterfaceRequestHandler<Interface>( - [this](fidl::InterfaceRequest<Interface> request) { - startup_context_->svc()->Connect(std::move(request)); - }))); - ZX_CHECK(status == ZX_OK, status); - } - - template <typename Interface> - void OfferFromAgent() { - zx_status_t status = services_.AddEntry( - Interface::Name_, - std::make_unique<vfs::Service>(fidl::InterfaceRequestHandler<Interface>( - [this](fidl::InterfaceRequest<Interface> request) { - agent_manager_.ConnectToAgentService(agent_url_, - std::move(request)); - }))); - ZX_CHECK(status == ZX_OK, status); - } - - template <typename Interface> - void ExposeFromCfv2Component() { - zx_status_t status = startup_context_->outgoing()->AddPublicService( - fidl::InterfaceRequestHandler<Interface>( - [this](fidl::InterfaceRequest<Interface> request) { - component_->exposed().Connect(std::move(request)); - })); - ZX_CHECK(status == ZX_OK, status); - } - - void OnTeardown() { - // Although the ComponentController will have reported a status to the - // framework when closing, this is not reflected in the `Binder` status. - // Deleting `this` will delete `component_`, causing the stopped child to - // actually be removed from the collection. - delete this; - } - - const GURL component_url_; - const std::unique_ptr<base::StartupContext> startup_context_; - const std::string agent_url_; - const std::string child_id_; - - // Binds the ComponentController request to this implementation. - fidl::Binding<fuchsia::sys::ComponentController> controller_binding_{this}; - - // Used to connect to services provided by the Agent that owns the activity. - cr_fuchsia::AgentManager agent_manager_; - - // Holds the service-directory offered to `component_`. - vfs::PseudoDir services_; - - // Manages the CFv2 dynamic child component for this CFv1 component. - absl::optional<fuchsia_component_support::DynamicComponentHost> component_; -}; - -// Maintains the state associated with a new Cast activity while the owning -// Agent URL is being resolved. -// This class self-deletes when its work is complete. -class PendingCastComponentV1 { - public: - PendingCastComponentV1( - GURL component_url, - std::unique_ptr<base::StartupContext> startup_context, - fidl::InterfaceRequest<fuchsia::sys::ComponentController> - controller_request) - : component_url_(std::move(component_url)), - startup_context_(std::move(startup_context)), - controller_request_(std::move(controller_request)) { - // Request the application's configuration, including the identity of the - // Agent that should provide component-specific resources, e.g. API - // bindings. - base::ComponentContextForProcess()->svc()->Connect( - application_config_manager_.NewRequest()); - application_config_manager_.set_error_handler([this](zx_status_t status) { - ZX_LOG(ERROR, status) << "ApplicationConfigManager disconnected."; - delete this; - }); - application_config_manager_->GetConfig( - component_url_.GetContent(), - fit::bind_member(this, - &PendingCastComponentV1::OnApplicationConfigReceived)); - } - - private: - void OnApplicationConfigReceived( - chromium::cast::ApplicationConfig application_config) { - if (application_config.has_agent_url()) { - new CastComponentV1(std::move(component_url_), - std::move(startup_context_), - std::move(controller_request_), - std::move(*application_config.mutable_agent_url())); - } else { - LOG(ERROR) << "No Agent is associated with this application."; - } - delete this; - } - - GURL component_url_; - std::unique_ptr<base::StartupContext> startup_context_; - fidl::InterfaceRequest<fuchsia::sys::ComponentController> controller_request_; - - // Used to obtain the component URL of the owning Agent. - chromium::cast::ApplicationConfigManagerPtr application_config_manager_; -}; - -} // namespace - -CastRunnerV1::CastRunnerV1() = default; - -CastRunnerV1::~CastRunnerV1() = default; - -void CastRunnerV1::StartComponent( - fuchsia::sys::Package package, - fuchsia::sys::StartupInfo startup_info, - fidl::InterfaceRequest<fuchsia::sys::ComponentController> - controller_request) { - // Verify that |package| specifies a Cast URI, before servicing the request. - constexpr char kCastPresentationUrlScheme[] = "cast"; - constexpr char kCastSecurePresentationUrlScheme[] = "casts"; - - GURL cast_url(package.resolved_url); - if (!cast_url.is_valid() || - (!cast_url.SchemeIs(kCastPresentationUrlScheme) && - !cast_url.SchemeIs(kCastSecurePresentationUrlScheme)) || - cast_url.GetContent().empty()) { - LOG(ERROR) << "Rejected invalid URL: " << cast_url; - return; - } - - auto startup_context = - std::make_unique<base::StartupContext>(std::move(startup_info)); - - if (!startup_context->has_outgoing_directory_request()) { - LOG(ERROR) << "Missing outgoing directory request"; - return; - } - - new PendingCastComponentV1(std::move(cast_url), std::move(startup_context), - std::move(controller_request)); -}
diff --git a/fuchsia_web/runners/cast/cast_runner_v1.h b/fuchsia_web/runners/cast/cast_runner_v1.h deleted file mode 100644 index e48991f..0000000 --- a/fuchsia_web/runners/cast/cast_runner_v1.h +++ /dev/null
@@ -1,27 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FUCHSIA_WEB_RUNNERS_CAST_CAST_RUNNER_V1_H_ -#define FUCHSIA_WEB_RUNNERS_CAST_CAST_RUNNER_V1_H_ - -#include <fuchsia/sys/cpp/fidl.h> - -// fuchsia.sys.Runner implementation which delegates hosting of cast/casts -// activities to the actual CFv2-based runner. -class CastRunnerV1 final : public fuchsia::sys::Runner { - public: - CastRunnerV1(); - ~CastRunnerV1() override; - - CastRunnerV1(const CastRunnerV1&) = delete; - CastRunnerV1& operator=(const CastRunnerV1&) = delete; - - // fuchsia::sys::Runner implementation. - void StartComponent(fuchsia::sys::Package package, - fuchsia::sys::StartupInfo startup_info, - fidl::InterfaceRequest<fuchsia::sys::ComponentController> - controller_request) override; -}; - -#endif // FUCHSIA_WEB_RUNNERS_CAST_CAST_RUNNER_V1_H_
diff --git a/fuchsia_web/runners/cast/main.cc b/fuchsia_web/runners/cast/main.cc index d0e83c0..3bd49e0 100644 --- a/fuchsia_web/runners/cast/main.cc +++ b/fuchsia_web/runners/cast/main.cc
@@ -30,7 +30,6 @@ #include "fuchsia_web/runners/cast/cast_resolver.h" #include "fuchsia_web/runners/cast/cast_runner.h" #include "fuchsia_web/runners/cast/cast_runner_switches.h" -#include "fuchsia_web/runners/cast/cast_runner_v1.h" #include "fuchsia_web/webinstance_host/web_instance_host.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -51,61 +50,20 @@ return false; } -// Name of the service capability implemented by the CFv2-based Runner. -constexpr char kCfv2RunnerService[] = "fuchsia.sys.Runner-cast"; - -// Publish a fuchsia.sys.Runner protocol that simply delegates to a specially- -// named protocol available in the incoming service directory. -int Cfv1ToCfv2RunnerProxyMain() { - sys::OutgoingDirectory* const outgoing_directory = - base::ComponentContextForProcess()->outgoing().get(); - - const base::ScopedServicePublisher proxy_sys_runner( - outgoing_directory, - fidl::InterfaceRequestHandler<fuchsia::sys::Runner>( - [](fidl::InterfaceRequest<fuchsia::sys::Runner> request) { - zx_status_t status = - base::ComponentContextForProcess()->svc()->Connect( - std::move(request), kCfv2RunnerService); - ZX_CHECK(status == ZX_OK, status) << "Connect(Runner-cast)"; - })); - - // If the CFv2-based Runner implementation fails then terminate the proxy - // so that the framework will observe this Runner-component failing. - auto cfv2_runner = - base::ComponentContextForProcess()->svc()->Connect<fuchsia::sys::Runner>( - kCfv2RunnerService); - CHECK(cfv2_runner) << "Connect(Runner-cast)"; - cfv2_runner.set_error_handler( - base::LogFidlErrorAndExitProcess(FROM_HERE, kCfv2RunnerService)); - - // Start serving the outgoing service directory to clients. - outgoing_directory->ServeFromStartupInfo(); - - // ELF runner will kill the component when the framework requests it to. - base::RunLoop().Run(); - - NOTREACHED(); - return 0; -} - } // namespace int main(int argc, char** argv) { base::SingleThreadTaskExecutor io_task_executor(base::MessagePumpType::IO); base::CommandLine::Init(argc, argv); - base::CommandLine* const command_line = - base::CommandLine::ForCurrentProcess(); - const bool enable_cfv2 = command_line->HasSwitch(kEnableCfv2); static constexpr base::StringPiece kComponentUrl( "fuchsia-pkg://fuchsia.com/cast_runner#meta/cast_runner.cm"); - static constexpr base::StringPiece kComponentUrlCfv1( - "fuchsia-pkg://fuchsia.com/cast_runner#meta/cast_runner.cmx"); fuchsia_component_support::RegisterProductDataForCrashReporting( - enable_cfv2 ? kComponentUrl : kComponentUrlCfv1, "FuchsiaCastRunner"); + kComponentUrl, "FuchsiaCastRunner"); + base::CommandLine* const command_line = + base::CommandLine::ForCurrentProcess(); CHECK(InitLoggingFromCommandLine(*command_line)) << "Failed to initialize logging."; @@ -120,10 +78,6 @@ "and does not support all necessary functionality."; #endif - if (!enable_cfv2) { - return Cfv1ToCfv2RunnerProxyMain(); - } - RegisterFuchsiaDirScheme(); sys::OutgoingDirectory* const outgoing_directory = @@ -144,11 +98,6 @@ const base::ScopedServiceBinding<fuchsia::component::runner::ComponentRunner> runner_binding(outgoing_directory, &runner); - // Publish the legacy fuchsia.sys.Runner implementation for Cast applications. - CastRunnerV1 runner_v1; - const base::ScopedServiceBinding<fuchsia::sys::Runner> runner_v1_binding( - outgoing_directory, &runner_v1); - // Publish the associated DataReset service for the instance. const base::ScopedServiceBinding<chromium::cast::DataReset> data_reset_binding(outgoing_directory, &runner);
diff --git a/fuchsia_web/runners/cast/test/cast_runner_launcher.cc b/fuchsia_web/runners/cast/test/cast_runner_launcher.cc index d012e28..b625d423 100644 --- a/fuchsia_web/runners/cast/test/cast_runner_launcher.cc +++ b/fuchsia_web/runners/cast/test/cast_runner_launcher.cc
@@ -99,7 +99,7 @@ } } -std::unique_ptr<sys::ServiceDirectory> CastRunnerLauncher::StartCastRunner() { +std::unique_ptr<sys::ServiceDirectory> CastRunnerLauncher::Create() { auto realm_builder = RealmBuilder::Create(); static constexpr char kCastRunnerComponentName[] = "cast_runner"; @@ -269,6 +269,21 @@ std::move(test_proxy_decl)); } + // Expose the CastRunner's Realm to the test Realm root, for it to expose + // for use by integration tests (see below). + { + auto runner_decl = realm_builder.GetComponentDecl(kCastRunnerComponentName); + runner_decl.mutable_exposes()->emplace_back( + fuchsia::component::decl::Expose::WithProtocol(std::move( + fuchsia::component::decl::ExposeProtocol() + .set_source(fuchsia::component::decl::Ref::WithFramework({})) + .set_source_name(fuchsia::component::Realm::Name_) + .set_target(fuchsia::component::decl::Ref::WithParent({})) + .set_target_name(fuchsia::component::Realm::Name_)))); + realm_builder.ReplaceComponentDecl(kCastRunnerComponentName, + std::move(runner_decl)); + } + // Offer the test-proxy the Cast Resolver and Runner capabilities, and // expose its framework-provided Realm protocol out to the test. { @@ -304,6 +319,19 @@ fuchsia::component::decl::ChildRef{.name = kTestProxyName})) .set_target_name(kCastRunnerName)))); + // Expose the CastRunner's Realm via the root component, as + // "fuchsia.component.Realm:runner", to allow tests to e.g. + // manipulate the child components in the `web_instances` collection. + realm_decl.mutable_exposes()->emplace_back( + fuchsia::component::decl::Expose::WithProtocol(std::move( + fuchsia::component::decl::ExposeProtocol() + .set_source(fuchsia::component::decl::Ref::WithChild( + fuchsia::component::decl::ChildRef{ + .name = kCastRunnerComponentName})) + .set_source_name(fuchsia::component::Realm::Name_) + .set_target(fuchsia::component::decl::Ref::WithParent({})) + .set_target_name(kCastRunnerRealmProtocol)))); + realm_builder.ReplaceRealmDecl(std::move(realm_decl)); }
diff --git a/fuchsia_web/runners/cast/test/cast_runner_launcher.h b/fuchsia_web/runners/cast/test/cast_runner_launcher.h index 360440c1..260c8e0 100644 --- a/fuchsia_web/runners/cast/test/cast_runner_launcher.h +++ b/fuchsia_web/runners/cast/test/cast_runner_launcher.h
@@ -27,14 +27,26 @@ // managed by this launcher. static constexpr char kTestCollectionName[] = "cast-test-collection"; + // Name of the CastRunner's Realm protocol, as exposed via the returned + // service directory. + static constexpr char kCastRunnerRealmProtocol[] = + "fuchsia.component.Realm-runner"; + explicit CastRunnerLauncher(CastRunnerFeatures runner_features); CastRunnerLauncher(const CastRunnerLauncher&) = delete; CastRunnerLauncher& operator=(const CastRunnerLauncher&) = delete; ~CastRunnerLauncher(); - std::unique_ptr<sys::ServiceDirectory> StartCastRunner(); + // Creates a test Realm configured to use the `cast_runner.cm` component, + // and returns a service-directory containing: + // - Services published by the `cast_runner.cm`. + // - A Realm containing `kTestCollectionName` into which Cast activities + // may be launched. + // - A Realm named `kCastRunnerRealmProtocol` to allow tests to manipulate + // the `cast_runner.cm` child components. + std::unique_ptr<sys::ServiceDirectory> Create(); - // May only be called after StartCastRunner(). + // May only be called after Create(). FakeCastAgent& fake_cast_agent() { return *fake_cast_agent_; } private:
diff --git a/fuchsia_web/runners/cast/test/fake_cast_agent.cc b/fuchsia_web/runners/cast/test/fake_cast_agent.cc index 8f184cbb..1ab2eca9 100644 --- a/fuchsia_web/runners/cast/test/fake_cast_agent.cc +++ b/fuchsia_web/runners/cast/test/fake_cast_agent.cc
@@ -30,12 +30,10 @@ } void FakeCastAgent::OnStart() { - ASSERT_EQ(outgoing()->AddPublicService( - cors_exempt_header_provider_bindings_.GetHandler(this)), - ZX_OK); - ASSERT_EQ(outgoing()->AddPublicService( - app_config_manager_bindings_.GetHandler(&app_config_manager_)), - ZX_OK); + MaybeAddDefaultService( + cors_exempt_header_provider_bindings_.GetHandler(this)); + MaybeAddDefaultService( + app_config_manager_bindings_.GetHandler(&app_config_manager_)); for (const auto& [name, on_connect_closure] : on_connect_) { ASSERT_EQ(outgoing()->AddPublicService( @@ -54,4 +52,12 @@ callback({StringToBytes("Test")}); } +template <class T> +void FakeCastAgent::MaybeAddDefaultService( + fidl::InterfaceRequestHandler<T> request_handler) { + if (on_connect_.find(T::Name_) == on_connect_.end()) { + ASSERT_EQ(outgoing()->AddPublicService(std::move(request_handler)), ZX_OK); + } +} + } // namespace test
diff --git a/fuchsia_web/runners/cast/test/fake_cast_agent.h b/fuchsia_web/runners/cast/test/fake_cast_agent.h index 81ba22c..e8cde02 100644 --- a/fuchsia_web/runners/cast/test/fake_cast_agent.h +++ b/fuchsia_web/runners/cast/test/fake_cast_agent.h
@@ -31,8 +31,11 @@ FakeCastAgent& operator=(const FakeCastAgent&) = delete; // Registers a callback to be invoked every time the specified service is - // requested. This can be combined with Expect[Not]RunClosure() to express - // simple expectations on whether services are connected-to. + // requested. This can be combined with e.g: + // - Expect[Not]RunClosure() to express simple expectations on whether + // services are connected-to. + // - DoNothing() to prevent default services (e.g. CorsExemptHeaderProvider) + // being handled by the fake. void RegisterOnConnectClosure(base::StringPiece service, base::RepeatingClosure callback); @@ -50,6 +53,12 @@ void GetCorsExemptHeaderNames( GetCorsExemptHeaderNamesCallback callback) override; + // Adds the service provided by the supplied `request_handler` to the + // fake component's outgoing service directory, unless the caller has + // registered an on-connect closure for that service already. + template <class T> + void MaybeAddDefaultService(fidl::InterfaceRequestHandler<T> request_handler); + bool is_started_ = false; // Used to publish a stub CorsExemptHeaderProvider to the Cast runtime.
diff --git a/fuchsia_web/runners/common/modular/BUILD.gn b/fuchsia_web/runners/common/modular/BUILD.gn deleted file mode 100644 index e9cd180..0000000 --- a/fuchsia_web/runners/common/modular/BUILD.gn +++ /dev/null
@@ -1,52 +0,0 @@ -# Copyright 2019 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -assert(is_fuchsia) - -import("//testing/test.gni") - -# Only allow use by targets in this directory unless explicitly specified. -visibility = [ ":*" ] - -# Integration helpers for fuchsia.modular. -# TODO(crbug.com/1280705): Delete this directory once fully migrated to CFv2. -source_set("modular") { - # Only for use by Fuchsia Components. - visibility += [ - ":unit_tests", - "//chromecast/internal/*", - "//fuchsia_web/runners/*", - "//fuchsia_web/webengine/*", - ] - sources = [ - "agent_impl.cc", - "agent_impl.h", - "agent_manager.cc", - "agent_manager.h", - "lifecycle_impl.cc", - "lifecycle_impl.h", - ] - deps = [ "//base" ] - public_deps = [ - "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.modular:fuchsia.modular_hlcpp", - "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp", - ] -} - -source_set("unit_tests") { - testonly = true - visibility += [ "//fuchsia_web/runners/*" ] - sources = [ "agent_impl_unittest.cc" ] - deps = [ - ":modular", - "//base", - "//base:testfidl", - "//base/test:run_all_unittests", - "//base/test:test_support", - "//fuchsia_web/common/test:test_support", - "//testing/gmock", - "//testing/gtest", - "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp", - ] -}
diff --git a/fuchsia_web/runners/common/modular/agent_impl.cc b/fuchsia_web/runners/common/modular/agent_impl.cc deleted file mode 100644 index 6e6f2bb8..0000000 --- a/fuchsia_web/runners/common/modular/agent_impl.cc +++ /dev/null
@@ -1,124 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "fuchsia_web/runners/common/modular/agent_impl.h" - -#include <lib/fdio/directory.h> -#include <lib/sys/cpp/component_context.h> - -#include <utility> - -#include "base/fuchsia/fuchsia_logging.h" -#include "base/fuchsia/process_context.h" -#include "base/functional/bind.h" - -namespace cr_fuchsia { - -AgentImpl::ComponentStateBase::~ComponentStateBase() = default; - -AgentImpl::ComponentStateBase::ComponentStateBase( - base::StringPiece component_id) - : component_id_(component_id) { - service_provider_ = base::ServiceProviderImpl::CreateForOutgoingDirectory( - &outgoing_directory_); - - // Tear down this instance when the client disconnects from the directory. - service_provider_->SetOnLastClientDisconnectedClosure(base::BindOnce( - &ComponentStateBase::TeardownIfUnused, base::Unretained(this))); -} - -void AgentImpl::ComponentStateBase::DisconnectClientsAndTeardown() { - agent_impl_->DeleteComponentState(component_id_); - // Do not touch |this|, since it is already gone. -} - -void AgentImpl::ComponentStateBase::TeardownIfUnused() { - DCHECK(agent_impl_); - - // Don't teardown if the ServiceProvider has client(s). - if (service_provider_->has_clients()) - return; - - // Don't teardown if caller-specified bindings still have clients. - for (auto& keepalive_callback : keepalive_callbacks_) { - if (keepalive_callback.Run()) - return; - } - - DisconnectClientsAndTeardown(); - // Do not touch |this|, since it is already gone. -} - -AgentImpl::AgentImpl( - sys::OutgoingDirectory* outgoing_directory, - CreateComponentStateCallback create_component_state_callback) - : AgentImpl(outgoing_directory, - std::move(create_component_state_callback), - {}) {} - -AgentImpl::AgentImpl( - sys::OutgoingDirectory* outgoing_directory, - CreateComponentStateCallback create_component_state_callback, - std::vector<std::string> public_service_names) - : create_component_state_callback_( - std::move(create_component_state_callback)), - public_service_names_(std::move(public_service_names)), - agent_binding_(outgoing_directory, this) { - if (!public_service_names_.empty()) { - fuchsia::io::DirectoryHandle root_directory; - zx_status_t status = outgoing_directory->Serve(root_directory.NewRequest()); - ZX_CHECK(status == ZX_OK, status) << "Serve(root)"; - fuchsia::io::DirectoryHandle svc_directory; - status = fdio_service_connect_at( - root_directory.channel().get(), "svc", - svc_directory.NewRequest().TakeChannel().release()); - ZX_CHECK(status == ZX_OK, status) << "open(svc)"; - public_services_ = - std::make_unique<sys::ServiceDirectory>(std::move(svc_directory)); - } -} - -AgentImpl::~AgentImpl() { - DCHECK(active_components_.empty()); -} - -void AgentImpl::Connect( - std::string requester_url, - fidl::InterfaceRequest<::fuchsia::sys::ServiceProvider> services) { - auto it = active_components_.find(requester_url); - if (it == active_components_.end()) { - std::unique_ptr<ComponentStateBase> component_state = - create_component_state_callback_.Run(requester_url); - if (!component_state) - return; - - // Add public services to the |component_state|. - const auto* outgoing = component_state->outgoing_directory(); - for (const auto& service_name : public_service_names_) { - zx_status_t status = outgoing->AddPublicService( - std::make_unique<vfs::Service>( - [public_services = public_services_.get(), service_name]( - zx::channel request, async_dispatcher_t* dispatcher) { - public_services->Connect(service_name, std::move(request)); - }), - service_name); - CHECK_EQ(status, ZX_OK); - } - - // Register the new component's state. - auto result = - active_components_.emplace(requester_url, std::move(component_state)); - it = result.first; - CHECK(result.second); - it->second->agent_impl_ = this; - } - it->second->service_provider_->AddBinding(std::move(services)); -} - -void AgentImpl::DeleteComponentState(base::StringPiece component_id) { - size_t removed_components = active_components_.erase(component_id); - DCHECK_EQ(removed_components, 1u); -} - -} // namespace cr_fuchsia
diff --git a/fuchsia_web/runners/common/modular/agent_impl.h b/fuchsia_web/runners/common/modular/agent_impl.h deleted file mode 100644 index 4313b0f..0000000 --- a/fuchsia_web/runners/common/modular/agent_impl.h +++ /dev/null
@@ -1,163 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FUCHSIA_WEB_RUNNERS_COMMON_MODULAR_AGENT_IMPL_H_ -#define FUCHSIA_WEB_RUNNERS_COMMON_MODULAR_AGENT_IMPL_H_ - -#include <fuchsia/modular/cpp/fidl.h> -#include <lib/fidl/cpp/binding_set.h> -#include <lib/sys/cpp/component_context.h> -#include <lib/zx/channel.h> - -#include <memory> -#include <string> -#include <utility> -#include <vector> - -#include "base/containers/flat_map.h" -#include "base/fuchsia/scoped_service_binding.h" -#include "base/fuchsia/service_provider_impl.h" -#include "base/functional/bind.h" -#include "base/strings/string_piece.h" - -namespace sys { -class ServiceDirectory; -} - -namespace cr_fuchsia { - -// AgentImpl allows the set of services published to each component to be -// configured via a caller-supplied factory function for per-component state. -// Specializations of the ComponentStateBase returned by the factory function -// can extend it to publish specific services, and to manage per-component -// service state as desired. -class AgentImpl final : public ::fuchsia::modular::Agent { - public: - // Common base for per-component services and state. The base provides an - // outgoing directory into which specializations publish their services, to - // have them made available to the client. Different specializations of the - // ComponentStateBase can be created to suit different components. - // - // For example, to publish separate instances of Service1 to each component, - // while having all components share a single instance of Service2: - // - // MyComponentState : public ComponentStateBase { - // public: - // MyComponentState(..) : ComponentStateBase(..) - // : binding1_(outgoing_directory(), &service1_), - // binding2_(outgoing_directory(), shared_service2_) {} - // private: - // Service1 service1_; - // ScopedServiceBinding<Service1> binding1_; - // Service2* shared_service2_; // e.g. Owned by the AgentImpl's embedder. - // ScopedServiceBinding<Service2> binding2_; - // }; - class ComponentStateBase { - public: - ComponentStateBase(const ComponentStateBase&) = delete; - ComponentStateBase& operator=(const ComponentStateBase&) = delete; - - virtual ~ComponentStateBase(); - - protected: - explicit ComponentStateBase(base::StringPiece component_id); - - // Returns the identity of the component served by this instance. - const base::StringPiece component_id() const { return component_id_; } - - // Returns the directory into which the ComponentState implementation should - // publish the services that the component may use. - sys::OutgoingDirectory* outgoing_directory() { - return &outgoing_directory_; - } - - // Registers |service_binding| to prevent teardown of this - // ComponentStateBase while it has one or more clients. |service_binding| - // will typically be the ScopedServiceBinding<> of a critical service used - // by the component. - template <typename T> - void AddKeepAliveBinding(T* service_binding) { - keepalive_callbacks_.push_back(base::BindRepeating( - &T::has_clients, base::Unretained(service_binding))); - service_binding->SetOnLastClientCallback(base::BindRepeating( - &ComponentStateBase::TeardownIfUnused, base::Unretained(this))); - } - - // Requests that this instance be torn-down, regardless of whether one or - // more keep-alive bindings (see above) have clients. - void DisconnectClientsAndTeardown(); - - private: - friend class AgentImpl; - - // Tears down this instance if there are no ServiceProvider clients, and - // no |keepalive_callbacks_| indicate that there are no clients of - // bindings that were configured to keep us alive. - void TeardownIfUnused(); - - const std::string component_id_; - AgentImpl* agent_impl_ = nullptr; - sys::OutgoingDirectory outgoing_directory_; - std::unique_ptr<base::ServiceProviderImpl> service_provider_; - std::vector<base::RepeatingCallback<bool()>> keepalive_callbacks_; - }; - - // Creates a component state instance providing the services to which the - // specified |component_id| should have access. Return nullptr to reject the - // connection request. - using CreateComponentStateCallback = - base::RepeatingCallback<std::unique_ptr<ComponentStateBase>( - base::StringPiece component_id)>; - - // Binds the Agent service in the supplied |outgoing_directory|, and invokes - // |create_component_state_callback| on each Connect() call, for the caller to - // create per-component data structures and services. - AgentImpl(sys::OutgoingDirectory* outgoing_directory, - CreateComponentStateCallback create_component_state_callback); - - // As above, with the addition that |public_services| will be offered to all - // components, in addition to any services offered by the ComponentState - // implementations themselves. The agent process should publish the services - // to its outgoing-directory, and additionally list them here, to have them - // also available via calls by Mods to ConnectToAgentService(). - AgentImpl(sys::OutgoingDirectory* outgoing_directory, - CreateComponentStateCallback create_component_state_callback, - std::vector<std::string> public_service_names); - - AgentImpl(const AgentImpl&) = delete; - AgentImpl& operator=(const AgentImpl&) = delete; - - ~AgentImpl() override; - - // fuchsia::modular::Agent implementation. - void Connect(std::string requester_url, - fidl::InterfaceRequest<::fuchsia::sys::ServiceProvider> services) - override; - - private: - friend class ComponentStateBase; - - void DeleteComponentState(base::StringPiece component_id); - void MaybeRunOnLastClientCallback(); - - // Returns a ComponentStateBase instance for a given component-Id. - const CreateComponentStateCallback create_component_state_callback_; - - // Set of service names to publish to all components. - const std::vector<std::string> public_service_names_; - - // Used to route requests for public services via the outgoing directory. - std::unique_ptr<sys::ServiceDirectory> public_services_; - - // Binds this Agent implementation into the |outgoing_directory|. - base::ScopedServiceBinding<::fuchsia::modular::Agent> agent_binding_; - - // Owns the ComponentState instances for each connected component. - base::flat_map<std::string, std::unique_ptr<ComponentStateBase>> - active_components_; -}; - -} // namespace cr_fuchsia - -#endif // FUCHSIA_WEB_RUNNERS_COMMON_MODULAR_AGENT_IMPL_H_
diff --git a/fuchsia_web/runners/common/modular/agent_impl_unittest.cc b/fuchsia_web/runners/common/modular/agent_impl_unittest.cc deleted file mode 100644 index 618af73a..0000000 --- a/fuchsia_web/runners/common/modular/agent_impl_unittest.cc +++ /dev/null
@@ -1,468 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "fuchsia_web/runners/common/modular/agent_impl.h" - -#include <lib/sys/cpp/component_context.h> - -#include "base/fuchsia/fuchsia_logging.h" -#include "base/fuchsia/process_context.h" -#include "base/fuchsia/test_component_context_for_process.h" -#include "base/logging.h" -#include "base/test/task_environment.h" -#include "base/test/test_future.h" -#include "base/testfidl/cpp/fidl.h" -#include "fuchsia_web/common/test/fit_adapter.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace cr_fuchsia { - -namespace { - -const char kNoServicesComponentId[] = "no-services"; -const char kAccumulatorComponentId1[] = "accumulator1"; -const char kAccumulatorComponentId2[] = "accumulator2"; -const char kKeepAliveComponentId[] = "keep-alive"; - -class EmptyComponentState : public AgentImpl::ComponentStateBase { - public: - explicit EmptyComponentState(base::StringPiece component) - : ComponentStateBase(component) {} -}; - -class AccumulatingTestInterfaceImpl : public base::testfidl::TestInterface { - public: - AccumulatingTestInterfaceImpl() = default; - - AccumulatingTestInterfaceImpl(const AccumulatingTestInterfaceImpl&) = delete; - AccumulatingTestInterfaceImpl& operator=( - const AccumulatingTestInterfaceImpl&) = delete; - - // TestInterface implementation: - void Add(int32_t a, int32_t b, AddCallback callback) override { - accumulated_ += a + b; - callback(accumulated_); - } - - private: - int32_t accumulated_ = 0; -}; - -class AccumulatorComponentState : public AgentImpl::ComponentStateBase { - public: - explicit AccumulatorComponentState(base::StringPiece component) - : ComponentStateBase(component), - service_binding_(outgoing_directory(), &service_) {} - - protected: - AccumulatingTestInterfaceImpl service_; - base::ScopedServiceBinding<base::testfidl::TestInterface> service_binding_; -}; - -class KeepAliveComponentState : public AccumulatorComponentState { - public: - explicit KeepAliveComponentState(base::StringPiece component) - : AccumulatorComponentState(component) { - AddKeepAliveBinding(&service_binding_); - } - - void DisconnectClientsAndTeardown() { - AgentImpl::ComponentStateBase::DisconnectClientsAndTeardown(); - } -}; - -class AgentImplTest : public ::testing::Test { - protected: - AgentImplTest() = default; - - AgentImplTest(const AgentImplTest&) = delete; - AgentImplTest& operator=(const AgentImplTest&) = delete; - - fuchsia::modular::AgentPtr CreateAgentAndConnect() { - EXPECT_FALSE(agent_impl_); - if (public_services_.empty()) { - agent_impl_ = std::make_unique<AgentImpl>( - base::ComponentContextForProcess()->outgoing().get(), - base::BindRepeating(&AgentImplTest::OnComponentConnect, - base::Unretained(this))); - } else { - agent_impl_ = std::make_unique<AgentImpl>( - base::ComponentContextForProcess()->outgoing().get(), - base::BindRepeating(&AgentImplTest::OnComponentConnect, - base::Unretained(this)), - public_services_); - } - fuchsia::modular::AgentPtr agent; - test_context_.published_services()->Connect(agent.NewRequest()); - return agent; - } - - void TeardownKeepAliveComponentState() { - std::move(disconnect_clients_and_teardown_).Run(); - } - - void set_public_services(std::vector<std::string> services) { - public_services_ = std::move(services); - } - - std::unique_ptr<AgentImpl::ComponentStateBase> OnComponentConnect( - base::StringPiece component_id) { - if (component_id == kNoServicesComponentId) { - return std::make_unique<EmptyComponentState>(component_id); - } else if (component_id == kAccumulatorComponentId1 || - component_id == kAccumulatorComponentId2) { - return std::make_unique<AccumulatorComponentState>(component_id); - } else if (component_id == kKeepAliveComponentId) { - auto component_state = - std::make_unique<KeepAliveComponentState>(component_id); - disconnect_clients_and_teardown_ = - base::BindOnce(&KeepAliveComponentState::DisconnectClientsAndTeardown, - base::Unretained(component_state.get())); - return component_state; - } - return nullptr; - } - - base::test::SingleThreadTaskEnvironment task_environment_{ - base::test::SingleThreadTaskEnvironment::MainThreadType::IO}; - const base::TestComponentContextForProcess test_context_; - - std::unique_ptr<AgentImpl> agent_impl_; - - // Set only if a keep-alive component was connected, to allow the test to - // forcibly teardown the ComponentState for it. - base::OnceClosure disconnect_clients_and_teardown_; - - // Service names passed to the AgentImpl constructor to publish from - // the process' outgoing directory. - std::vector<std::string> public_services_; -}; - -} // namespace - -// Verify that the Agent can publish and unpublish itself. -TEST_F(AgentImplTest, PublishAndUnpublish) { - base::test::TestFuture<zx_status_t> client_disconnect_status1; - fuchsia::modular::AgentPtr agent = CreateAgentAndConnect(); - agent.set_error_handler( - CallbackToFitFunction(client_disconnect_status1.GetCallback())); - - base::RunLoop().RunUntilIdle(); - EXPECT_FALSE(client_disconnect_status1.IsReady()); - - // Teardown the Agent. - agent_impl_.reset(); - - // Verify that the client got disconnected on teardown. - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(client_disconnect_status1.Get(), ZX_ERR_PEER_CLOSED); - - // Verify that the Agent service is no longer available. - base::test::TestFuture<zx_status_t> client_disconnect_status2; - test_context_.published_services()->Connect(agent.NewRequest()); - agent.set_error_handler( - CallbackToFitFunction(client_disconnect_status2.GetCallback())); - - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(client_disconnect_status2.Get(), ZX_ERR_PEER_CLOSED); -} - -// Verify that multiple connection attempts with the different component Ids -// to the same service get different instances. -TEST_F(AgentImplTest, DifferentComponentIdSameService) { - fuchsia::modular::AgentPtr agent = CreateAgentAndConnect(); - - // Connect to the Agent twice using the same component Id. - fuchsia::sys::ServiceProviderPtr component_services1; - agent->Connect(kAccumulatorComponentId1, component_services1.NewRequest()); - fuchsia::sys::ServiceProviderPtr component_services2; - agent->Connect(kAccumulatorComponentId2, component_services2.NewRequest()); - - // Request the TestInterface from each of the service directories. - base::testfidl::TestInterfacePtr test_interface1; - component_services1->ConnectToService( - base::testfidl::TestInterface::Name_, - test_interface1.NewRequest().TakeChannel()); - base::testfidl::TestInterfacePtr test_interface2; - component_services2->ConnectToService( - base::testfidl::TestInterface::Name_, - test_interface2.NewRequest().TakeChannel()); - - // Both TestInterface pointers should remain valid until we are done. - test_interface1.set_error_handler([](zx_status_t status) { - ZX_LOG(ERROR, status); - ADD_FAILURE(); - }); - test_interface2.set_error_handler([](zx_status_t status) { - ZX_LOG(ERROR, status); - ADD_FAILURE(); - }); - - // Call Add() via one TestInterface and verify accumulator had been at zero. - { - base::RunLoop loop; - test_interface1->Add(1, 2, - [quit_loop = loop.QuitClosure()](int32_t result) { - EXPECT_EQ(result, 3); - quit_loop.Run(); - }); - loop.RunUntilIdle(); - } - - // Call Add() via the second TestInterface, and verify that first Add() call's - // effects aren't visible. - { - base::RunLoop loop; - test_interface2->Add(3, 4, - [quit_loop = loop.QuitClosure()](int32_t result) { - EXPECT_EQ(result, 7); - quit_loop.Run(); - }); - loop.RunUntilIdle(); - } - - // Cleanly unbind the test interfaces now that we're done with them. - test_interface1 = nullptr; - test_interface2 = nullptr; - - // Tear down connections to the agent and let the error handlers unwind. - { - base::RunLoop loop; - component_services1.Unbind(); - component_services2.Unbind(); - loop.RunUntilIdle(); - } -} - -// Verify that multiple connection attempts with the same component Id connect -// it to the same service instances. -TEST_F(AgentImplTest, SameComponentIdSameService) { - fuchsia::modular::AgentPtr agent = CreateAgentAndConnect(); - - // Connect to the Agent twice using the same component Id. - fuchsia::sys::ServiceProviderPtr component_services1; - agent->Connect(kAccumulatorComponentId1, component_services1.NewRequest()); - fuchsia::sys::ServiceProviderPtr component_services2; - agent->Connect(kAccumulatorComponentId1, component_services2.NewRequest()); - - // Request the TestInterface from each of the service directories. - base::testfidl::TestInterfacePtr test_interface1; - component_services1->ConnectToService( - base::testfidl::TestInterface::Name_, - test_interface1.NewRequest().TakeChannel()); - base::testfidl::TestInterfacePtr test_interface2; - component_services2->ConnectToService( - base::testfidl::TestInterface::Name_, - test_interface2.NewRequest().TakeChannel()); - - // Both TestInterface pointers should remain valid until we are done. - test_interface1.set_error_handler([](zx_status_t status) { - ZX_LOG(ERROR, status); - ADD_FAILURE(); - }); - test_interface2.set_error_handler([](zx_status_t status) { - ZX_LOG(ERROR, status); - ADD_FAILURE(); - }); - - // Call Add() via one TestInterface and verify accumulator had been at zero. - { - base::RunLoop loop; - test_interface1->Add(1, 2, - [quit_loop = loop.QuitClosure()](int32_t result) { - EXPECT_EQ(result, 3); - quit_loop.Run(); - }); - loop.RunUntilIdle(); - } - - // Call Add() via the other TestInterface, and verify that the result of the - // previous Add() was already in the accumulator. - { - base::RunLoop loop; - test_interface2->Add(3, 4, - [quit_loop = loop.QuitClosure()](int32_t result) { - EXPECT_EQ(result, 10); - quit_loop.Run(); - }); - loop.RunUntilIdle(); - } - - // Cleanly unbind the test interfaces now that we're done with them. - test_interface1 = nullptr; - test_interface2 = nullptr; - - // Tear down connections to the agent and let the error handlers unwind. - { - base::RunLoop loop; - component_services1.Unbind(); - component_services2.Unbind(); - loop.RunUntilIdle(); - } -} - -// Verify that connections to a service registered to keep-alive the -// ComponentStateBase keeps it alive after the ServiceProvider is dropped. -TEST_F(AgentImplTest, KeepAliveBinding) { - fuchsia::modular::AgentPtr agent = CreateAgentAndConnect(); - - { - // Connect to the Agent and request the TestInterface. - fuchsia::sys::ServiceProviderPtr component_services; - agent->Connect(kAccumulatorComponentId1, component_services.NewRequest()); - base::testfidl::TestInterfacePtr test_interface; - component_services->ConnectToService( - base::testfidl::TestInterface::Name_, - test_interface.NewRequest().TakeChannel()); - - // The TestInterface pointer should be closed as soon as we Unbind() the - // ServiceProvider. - test_interface.set_error_handler( - [](zx_status_t status) { EXPECT_EQ(status, ZX_ERR_PEER_CLOSED); }); - - // After disconnecting ServiceProvider, TestInterface should remain valid. - component_services.Unbind(); - base::RunLoop().RunUntilIdle(); - EXPECT_FALSE(test_interface); - } - - { - // Connect to the Agent and request the TestInterface. - fuchsia::sys::ServiceProviderPtr component_services; - agent->Connect(kKeepAliveComponentId, component_services.NewRequest()); - base::testfidl::TestInterfacePtr test_interface; - component_services->ConnectToService( - base::testfidl::TestInterface::Name_, - test_interface.NewRequest().TakeChannel()); - - // The TestInterface pointer should remain valid until we are done. - test_interface.set_error_handler([](zx_status_t status) { - ZX_LOG(ERROR, status); - ADD_FAILURE(); - }); - - // After disconnecting ServiceProvider, TestInterface should remain valid. - component_services.Unbind(); - base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(test_interface); - } - - // Spin the MessageLoop to let the AgentImpl see that TestInterface is gone. - base::RunLoop().RunUntilIdle(); -} - -// Verify that connections to a service registered to keep-alive the -// ComponentStateBase is disconnected by DisconnectClientsAndTeardown. -TEST_F(AgentImplTest, DisconnectClientsAndTeardown) { - fuchsia::modular::AgentPtr agent = CreateAgentAndConnect(); - - { - // Connect to the Agent and request the TestInterface. - fuchsia::sys::ServiceProviderPtr component_services; - agent->Connect(kKeepAliveComponentId, component_services.NewRequest()); - base::testfidl::TestInterfacePtr test_interface; - component_services->ConnectToService( - base::testfidl::TestInterface::Name_, - test_interface.NewRequest().TakeChannel()); - - // The TestInterface pointer should remain valid until we call - // DisconnectClientsAndTeardown(). - test_interface.set_error_handler( - [](zx_status_t status) { ZX_LOG_IF(ERROR, status != ZX_OK, status); }); - - // After disconnecting ServiceProvider, TestInterface should remain valid. - component_services.Unbind(); - base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(test_interface); - - // After invoking DisconnectClientsAndTeardown(), TestInterface should - // be disconnected. - TeardownKeepAliveComponentState(); - base::RunLoop().RunUntilIdle(); - EXPECT_FALSE(test_interface); - } -} - -class AgentImplTestWithPublicService : public AgentImplTest { - protected: - static constexpr char kServiceName[] = "base.testfidl.TestInterface-public"; - - AgentImplTestWithPublicService() : AgentImplTest() { - // Publish kServiceName to the outgoing services directory for the current - // process (scoped to this test by the TestComponentContextForProcess). - // AgentImpl should route requests for this "public" service via the - // outgoing services directory. - base::ComponentContextForProcess() - ->outgoing() - ->AddPublicService<base::testfidl::TestInterface>( - [](fidl::InterfaceRequest<base::testfidl::TestInterface> request) { - request.Close(ZX_OK); - }, - kServiceName); - } -}; - -// Verify that the DefaultComponentState publishes the process' outgoing -// service directory. -TEST_F(AgentImplTestWithPublicService, PublicService) { - // Configure the AgentImpl to provide the "public" service. - set_public_services({kServiceName}); - fuchsia::modular::AgentPtr agent = CreateAgentAndConnect(); - - // Connect to the ServiceProvider for the a dummy component. - fuchsia::sys::ServiceProviderPtr component_services; - agent->Connect(kAccumulatorComponentId1, component_services.NewRequest()); - - // Connect to the public service. - base::testfidl::TestInterfacePtr test_interface; - component_services->ConnectToService( - kServiceName, test_interface.NewRequest().TakeChannel()); - - // If we successfully connect then the service connection will be closed - // with ZX_OK, by the connection-handler implementation in the test base. - base::test::TestFuture<zx_status_t> service_disconnect_status; - test_interface.set_error_handler( - CallbackToFitFunction(service_disconnect_status.GetCallback())); - base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(service_disconnect_status.IsReady()); - EXPECT_EQ(service_disconnect_status.Get(), ZX_OK); - - // Close the ServiceProvider channel and spin the MessageLoop to let the - // AgentImpl clean up the component state. - component_services = nullptr; - base::RunLoop().RunUntilIdle(); -} - -// Verify that services published via the outgoing directory, but not as -// public services, are not available. -TEST_F(AgentImplTestWithPublicService, PublicServiceNotProvided) { - // Configure the AgentImpl to provide the "public" service. - set_public_services({}); - fuchsia::modular::AgentPtr agent = CreateAgentAndConnect(); - - // Connect to the ServiceProvider for the a dummy component. - fuchsia::sys::ServiceProviderPtr component_services; - agent->Connect(kAccumulatorComponentId1, component_services.NewRequest()); - - // Connect to the public service. - base::testfidl::TestInterfacePtr test_interface; - component_services->ConnectToService( - kServiceName, test_interface.NewRequest().TakeChannel()); - - // If the service is not routed as "public" by the AgentImpl then the - // request should simply be dropped. - base::test::TestFuture<zx_status_t> service_disconnect_status; - test_interface.set_error_handler( - CallbackToFitFunction(service_disconnect_status.GetCallback())); - base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(service_disconnect_status.IsReady()); - EXPECT_EQ(service_disconnect_status.Get(), ZX_ERR_PEER_CLOSED); - - // Close the ServiceProvider channel and spin the MessageLoop to let the - // AgentImpl clean up the component state. - component_services = nullptr; - base::RunLoop().RunUntilIdle(); -} - -} // namespace cr_fuchsia
diff --git a/fuchsia_web/runners/common/modular/agent_manager.cc b/fuchsia_web/runners/common/modular/agent_manager.cc deleted file mode 100644 index 2e76baf0..0000000 --- a/fuchsia_web/runners/common/modular/agent_manager.cc +++ /dev/null
@@ -1,50 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "fuchsia_web/runners/common/modular/agent_manager.h" - -#include <utility> - -#include "base/fuchsia/fuchsia_logging.h" -#include "base/logging.h" -#include "base/strings/string_piece.h" - -namespace cr_fuchsia { - -AgentManager::AgentManager(const sys::ServiceDirectory* incoming) - : component_context_( - incoming->Connect<fuchsia::modular::ComponentContext>()) {} - -AgentManager::~AgentManager() = default; - -void AgentManager::ConnectToAgentServiceUnsafe(base::StringPiece agent, - base::StringPiece interface, - zx::channel request) { - auto it = agents_.find(agent); - if (it == agents_.end()) { - it = agents_.emplace(agent, AgentConnection()).first; - component_context_->DeprecatedConnectToAgent( - std::string(agent), it->second.services.NewRequest(), - it->second.controller.NewRequest()); - it->second.services.set_error_handler( - [this, agent = std::string(agent)](zx_status_t status) { - ZX_LOG(WARNING, status) << "Agent disconnected: " << agent; - agents_.erase(agent); - }); - } - it->second.services->ConnectToService(std::string(interface), - std::move(request)); -} - -AgentManager::AgentConnection::AgentConnection() = default; - -AgentManager::AgentConnection::AgentConnection(AgentConnection&& other) = - default; - -AgentManager::AgentConnection& AgentManager::AgentConnection::operator=( - AgentConnection&& other) = default; - -AgentManager::AgentConnection::~AgentConnection() = default; - -} // namespace cr_fuchsia
diff --git a/fuchsia_web/runners/common/modular/agent_manager.h b/fuchsia_web/runners/common/modular/agent_manager.h deleted file mode 100644 index 615632c7..0000000 --- a/fuchsia_web/runners/common/modular/agent_manager.h +++ /dev/null
@@ -1,69 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FUCHSIA_WEB_RUNNERS_COMMON_MODULAR_AGENT_MANAGER_H_ -#define FUCHSIA_WEB_RUNNERS_COMMON_MODULAR_AGENT_MANAGER_H_ - -#include <fuchsia/modular/cpp/fidl.h> -#include <fuchsia/sys/cpp/fidl.h> -#include <lib/sys/cpp/component_context.h> - -#include "base/containers/flat_map.h" -#include "base/strings/string_piece.h" - -namespace cr_fuchsia { - -// Connects to the ComponentContext service from the supplied ServiceDirectory, -// and uses it to connect-to and manage one or more Agents used by the caller. -class AgentManager { - public: - explicit AgentManager(const sys::ServiceDirectory* incoming); - - AgentManager(const AgentManager&) = delete; - AgentManager& operator=(const AgentManager&) = delete; - - ~AgentManager(); - - // Connects to |agent| so satisfying the specified |request|. - // |agent| will be kept alive until this AgentManager is destroyed. - template <typename Interface> - void ConnectToAgentService(base::StringPiece agent, - fidl::InterfaceRequest<Interface> request) { - ConnectToAgentServiceUnsafe(agent, Interface::Name_, request.TakeChannel()); - } - - template <typename Interface> - fidl::InterfacePtr<Interface> ConnectToAgentService(base::StringPiece agent) { - fidl::InterfacePtr<Interface> ptr; - ConnectToAgentService(agent, ptr.NewRequest()); - return ptr; - } - - private: - // Holds a pointer to Agent-provided services, and keeps the Agent alive. - struct AgentConnection { - AgentConnection(); - AgentConnection(AgentConnection&& other); - ~AgentConnection(); - - AgentConnection& operator=(AgentConnection&& other); - - fuchsia::sys::ServiceProviderPtr services; - fuchsia::modular::AgentControllerPtr controller; - }; - - void ConnectToAgentServiceUnsafe(base::StringPiece agent, - base::StringPiece interface, - zx::channel request); - - const fuchsia::modular::ComponentContextPtr component_context_; - - // Cache of resources for Agents which we're actively using. All |agents_| - // are kept alive until the AgentManager is torn down, for now. - base::flat_map<std::string, AgentConnection> agents_; -}; - -} // namespace cr_fuchsia - -#endif // FUCHSIA_WEB_RUNNERS_COMMON_MODULAR_AGENT_MANAGER_H_
diff --git a/fuchsia_web/runners/common/modular/fake_component_context.cc b/fuchsia_web/runners/common/modular/fake_component_context.cc deleted file mode 100644 index 62ded23..0000000 --- a/fuchsia_web/runners/common/modular/fake_component_context.cc +++ /dev/null
@@ -1,55 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "fuchsia_web/runners/common/modular/fake_component_context.h" - -#include <memory> -#include <string> -#include <utility> - -#include "base/check.h" -#include "base/notreached.h" -#include "base/run_loop.h" -#include "base/strings/string_piece.h" -#include "fuchsia_web/runners/common/modular/agent_impl.h" - -namespace cr_fuchsia { - -FakeComponentContext::FakeComponentContext( - sys::OutgoingDirectory* outgoing_directory, - base::StringPiece component_url) - : binding_(outgoing_directory, this), - component_url_(component_url), - outgoing_directory_(outgoing_directory) {} - -void FakeComponentContext::RegisterCreateComponentStateCallback( - base::StringPiece agent_url, - AgentImpl::CreateComponentStateCallback create_component_state_callback) { - agent_impl_map_.insert(std::make_pair( - agent_url, - std::make_unique<AgentImpl>(outgoing_directory_, - std::move(create_component_state_callback)))); -} - -void FakeComponentContext::DeprecatedConnectToAgent( - std::string agent_url, - fidl::InterfaceRequest<::fuchsia::sys::ServiceProvider> services, - fidl::InterfaceRequest<fuchsia::modular::AgentController> controller) { - auto it = agent_impl_map_.find(agent_url); - CHECK(it != agent_impl_map_.end()) - << "Received request for an unknown agent URL: " << agent_url; - - it->second->Connect(component_url_, std::move(services)); -} - -void FakeComponentContext::NotImplemented_(const std::string& name) { - NOTIMPLEMENTED() << " API: " << name; -} - -FakeComponentContext::~FakeComponentContext() { - agent_services_.Unbind(); - base::RunLoop().RunUntilIdle(); -} - -} // namespace cr_fuchsia
diff --git a/fuchsia_web/runners/common/modular/fake_component_context.h b/fuchsia_web/runners/common/modular/fake_component_context.h deleted file mode 100644 index 86606a89..0000000 --- a/fuchsia_web/runners/common/modular/fake_component_context.h +++ /dev/null
@@ -1,60 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FUCHSIA_WEB_RUNNERS_COMMON_MODULAR_FAKE_COMPONENT_CONTEXT_H_ -#define FUCHSIA_WEB_RUNNERS_COMMON_MODULAR_FAKE_COMPONENT_CONTEXT_H_ - -#include <fuchsia/modular/cpp/fidl_test_base.h> - -#include <map> -#include <memory> -#include <string> -#include <utility> - -#include "base/strings/string_piece.h" -#include "fuchsia_web/runners/common/modular/agent_impl.h" - -namespace cr_fuchsia { - -// Used to test interactions with an Agent in unit-tests for a component. -// |create_component_state_callback| can be used with a test-specific -// ComponentStateBase to serve fake services to the component. -// |outgoing_directory| specifies the directory into which the ComponentContext -// should be published, alongside any other services the test wishes to provide -// to the component's default service namespace. |component_url| specifies the -// component identity that should be reported to the Agent -class FakeComponentContext - : public fuchsia::modular::testing::ComponentContext_TestBase { - public: - FakeComponentContext(sys::OutgoingDirectory* outgoing_directory, - base::StringPiece component_url); - - FakeComponentContext(const FakeComponentContext&) = delete; - FakeComponentContext& operator=(const FakeComponentContext&) = delete; - - ~FakeComponentContext() override; - - void RegisterCreateComponentStateCallback( - base::StringPiece agent_url, - AgentImpl::CreateComponentStateCallback callback); - - // fuchsia::modular::ComponentContext_TestBase implementation. - void DeprecatedConnectToAgent( - std::string agent_url, - fidl::InterfaceRequest<::fuchsia::sys::ServiceProvider> services, - fidl::InterfaceRequest<fuchsia::modular::AgentController> controller) - override; - void NotImplemented_(const std::string& name) override; - - private: - base::ScopedServiceBinding<fuchsia::modular::ComponentContext> binding_; - const std::string component_url_; - sys::OutgoingDirectory* const outgoing_directory_; - fuchsia::sys::ServiceProviderPtr agent_services_; - - std::map<base::StringPiece, std::unique_ptr<AgentImpl>> agent_impl_map_; -}; - -} // namespace cr_fuchsia -#endif // FUCHSIA_WEB_RUNNERS_COMMON_MODULAR_FAKE_COMPONENT_CONTEXT_H_
diff --git a/fuchsia_web/runners/common/modular/lifecycle_impl.cc b/fuchsia_web/runners/common/modular/lifecycle_impl.cc deleted file mode 100644 index 941b95a..0000000 --- a/fuchsia_web/runners/common/modular/lifecycle_impl.cc +++ /dev/null
@@ -1,21 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "fuchsia_web/runners/common/modular/lifecycle_impl.h" - -namespace cr_fuchsia { - -LifecycleImpl::LifecycleImpl(sys::OutgoingDirectory* outgoing_directory, - base::OnceClosure on_terminate) - : binding_(outgoing_directory, this), - on_terminate_(std::move(on_terminate)) {} - -LifecycleImpl::~LifecycleImpl() = default; - -void LifecycleImpl::Terminate() { - if (on_terminate_) - std::move(on_terminate_).Run(); -} - -} // namespace cr_fuchsia
diff --git a/fuchsia_web/runners/common/modular/lifecycle_impl.h b/fuchsia_web/runners/common/modular/lifecycle_impl.h deleted file mode 100644 index b30cc2c..0000000 --- a/fuchsia_web/runners/common/modular/lifecycle_impl.h +++ /dev/null
@@ -1,41 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FUCHSIA_WEB_RUNNERS_COMMON_MODULAR_LIFECYCLE_IMPL_H_ -#define FUCHSIA_WEB_RUNNERS_COMMON_MODULAR_LIFECYCLE_IMPL_H_ - -#include <fuchsia/modular/cpp/fidl.h> - -#include "base/fuchsia/scoped_service_binding.h" - -namespace sys { -class OutgoingDirectory; -} // namespace sys - -namespace cr_fuchsia { - -// Implements the fuchsia.modular.Lifecycle protocol, by invoking the supplied -// graceful teardown Callback when Terminate() is called, or when the Lifecycle -// client drops the channel. -class LifecycleImpl final : public ::fuchsia::modular::Lifecycle { - public: - LifecycleImpl(sys::OutgoingDirectory* outgoing_directory, - base::OnceClosure on_terminate); - ~LifecycleImpl() override; - - LifecycleImpl(const LifecycleImpl&) = delete; - LifecycleImpl& operator=(const LifecycleImpl&) = delete; - - // fuchsia::modular::Lifecycle implementation. - void Terminate() override; - - private: - const base::ScopedServiceBinding<::fuchsia::modular::Lifecycle> binding_; - - base::OnceClosure on_terminate_; -}; - -} // namespace cr_fuchsia - -#endif // FUCHSIA_WEB_RUNNERS_COMMON_MODULAR_LIFECYCLE_IMPL_H_
diff --git a/fuchsia_web/runners/common/web_component.cc b/fuchsia_web/runners/common/web_component.cc index 2212af7..10b3da89 100644 --- a/fuchsia_web/runners/common/web_component.cc +++ b/fuchsia_web/runners/common/web_component.cc
@@ -26,8 +26,6 @@ runner_(runner), startup_context_(std::move(context)), controller_binding_(this), - module_context_( - startup_context()->svc()->Connect<fuchsia::modular::ModuleContext>()), navigation_listener_binding_(this) { DCHECK(!debug_name_.empty()); DCHECK(runner); @@ -49,10 +47,6 @@ } WebComponent::~WebComponent() { - // If Modular is available, request to be removed from the Story. - if (module_context_) - module_context_->RemoveSelfFromStory(); - if (controller_binding_.is_bound()) { // Send process termination details to the client. controller_binding_.events().OnTerminated(termination_exit_code_, @@ -106,9 +100,6 @@ view_provider_binding_ = std::make_unique< base::ScopedServiceBinding<fuchsia::ui::app::ViewProvider>>( startup_context()->component_context()->outgoing().get(), this); - lifecycle_ = std::make_unique<cr_fuchsia::LifecycleImpl>( - startup_context()->component_context()->outgoing().get(), - base::BindOnce(&WebComponent::Kill, base::Unretained(this))); startup_context()->ServeOutgoingDirectory(); }
diff --git a/fuchsia_web/runners/common/web_component.h b/fuchsia_web/runners/common/web_component.h index f651f7a..4297479 100644 --- a/fuchsia_web/runners/common/web_component.h +++ b/fuchsia_web/runners/common/web_component.h
@@ -5,7 +5,6 @@ #ifndef FUCHSIA_WEB_RUNNERS_COMMON_WEB_COMPONENT_H_ #define FUCHSIA_WEB_RUNNERS_COMMON_WEB_COMPONENT_H_ -#include <fuchsia/modular/cpp/fidl.h> #include <fuchsia/sys/cpp/fidl.h> #include <fuchsia/ui/app/cpp/fidl.h> #include <fuchsia/web/cpp/fidl.h> @@ -18,7 +17,6 @@ #include "base/fuchsia/scoped_service_binding.h" #include "base/fuchsia/startup_context.h" #include "base/time/time.h" -#include "fuchsia_web/runners/common/modular/lifecycle_impl.h" #include "url/gurl.h" class WebContentRunner; @@ -38,7 +36,7 @@ // |runner| must out-live |this|. // [context| will be retained to provide component-specific services. // If |context| includes an outgoing-directory request then the component - // will publish ViewProvider and Lifecycle services. + // will publish a ViewProvider implementation. // |controller_request| may optionally be supplied and used to control the // lifetime of this component instance. WebComponent(base::StringPiece debug_name, @@ -120,10 +118,6 @@ // Bindings used to manage the lifetime of this component instance. fidl::Binding<fuchsia::sys::ComponentController> controller_binding_; - std::unique_ptr<cr_fuchsia::LifecycleImpl> lifecycle_; - - // If running as a Mod then these are used to e.g. RemoveSelfFromStory(). - fuchsia::modular::ModuleContextPtr module_context_; // Objects used for binding and exporting the ViewProvider service. std::unique_ptr<base::ScopedServiceBinding<fuchsia::ui::app::ViewProvider>>
diff --git a/fuchsia_web/webengine/test_debug_listener.cc b/fuchsia_web/webengine/test_debug_listener.cc index 4adf2b5..f089be1 100644 --- a/fuchsia_web/webengine/test_debug_listener.cc +++ b/fuchsia_web/webengine/test_debug_listener.cc
@@ -19,26 +19,30 @@ void TestDebugListener::AddPort(uint16_t port) { EXPECT_EQ(debug_ports_.find(port), debug_ports_.end()); debug_ports_.insert(port); - if (on_debug_ports_changed_) + if (on_debug_ports_changed_) { on_debug_ports_changed_.Run(); + } } void TestDebugListener::RemovePort(uint16_t port) { EXPECT_EQ(debug_ports_.erase(port), 1u); - if (on_debug_ports_changed_) + if (on_debug_ports_changed_) { on_debug_ports_changed_.Run(); + } } void TestDebugListener::RunUntilNumberOfPortsIs(size_t size) { - if (debug_ports_.size() == size) + if (debug_ports_.size() == size) { return; + } base::RunLoop run_loop; base::AutoReset<base::RepeatingClosure> set_on_debug_ports_changed( &on_debug_ports_changed_, base::BindLambdaForTesting([this, &run_loop, size]() { - if (debug_ports_.size() == size) + if (debug_ports_.size() == size) { run_loop.Quit(); + } })); run_loop.Run(); ASSERT_EQ(debug_ports_.size(), size); @@ -50,8 +54,9 @@ : test_debug_listener_(test_debug_listener), binding_(this, std::move(listener)) { binding_.set_error_handler([this](zx_status_t) { - if (port_ != 0) + if (port_ != 0) { test_debug_listener_->RemovePort(port_); + } test_debug_listener_->DestroyListener(this); }); } @@ -59,8 +64,19 @@ TestDebugListener::TestPerContextListener::~TestPerContextListener() = default; void TestDebugListener::TestPerContextListener::OnHttpPortOpen(uint16_t port) { + // If `port` is non-zero then the PerContextListener has created, or replaced, + // its DevTools port. If `port` is zero then the PerContextListener is + // reporting that it is not listening on DevTools. + // Remove the previously-reported `port_`, if any, from the TestDebugListener, + // before adding the new `port`, if set, to maintain the list of available + // DevTools ports. + if (port_ != 0) { + test_debug_listener_->RemovePort(port_); + } port_ = port; - test_debug_listener_->AddPort(port); + if (port != 0) { + test_debug_listener_->AddPort(port); + } } void TestDebugListener::OnContextDevToolsAvailable(
diff --git "a/infra/config/generated/builders/ci/Lacros FYI Release \050octopus\051/properties.json" "b/infra/config/generated/builders/ci/Lacros FYI Release \050octopus\051/properties.json" new file mode 100644 index 0000000..a5cc6548 --- /dev/null +++ "b/infra/config/generated/builders/ci/Lacros FYI Release \050octopus\051/properties.json"
@@ -0,0 +1,67 @@ +{ + "$build/chromium_tests_builder_config": { + "builder_config": { + "builder_db": { + "entries": [ + { + "builder_id": { + "bucket": "ci", + "builder": "Lacros FYI Release (octopus)", + "project": "chromium" + }, + "builder_spec": { + "builder_group": "chromium.gpu.fyi", + "execution_mode": "COMPILE_AND_TEST", + "legacy_chromium_config": { + "apply_configs": [ + "mb" + ], + "build_config": "Release", + "config": "chromium", + "target_arch": "intel", + "target_bits": 64, + "target_cros_boards": [ + "octopus" + ], + "target_platform": "chromeos" + }, + "legacy_gclient_config": { + "apply_configs": [ + "chromeos", + "checkout_lacros_sdk" + ], + "config": "chromium" + }, + "run_tests_serially": true + } + } + ] + }, + "builder_ids": [ + { + "bucket": "ci", + "builder": "Lacros FYI Release (octopus)", + "project": "chromium" + } + ] + } + }, + "$build/reclient": { + "instance": "rbe-chromium-trusted", + "jobs": 500, + "metrics_project": "chromium-reclient-metrics" + }, + "$recipe_engine/resultdb/test_presentation": { + "column_keys": [], + "grouping_keys": [ + "status", + "v.test_suite" + ] + }, + "builder_group": "chromium.gpu.fyi", + "perf_dashboard_machine_group": "ChromiumGPUFYI", + "recipe": "chromium", + "sheriff_rotations": [ + "chromium.gpu" + ] +} \ No newline at end of file
diff --git a/infra/config/generated/luci/cr-buildbucket.cfg b/infra/config/generated/luci/cr-buildbucket.cfg index de9f8527..2e3d67b 100644 --- a/infra/config/generated/luci/cr-buildbucket.cfg +++ b/infra/config/generated/luci/cr-buildbucket.cfg
@@ -9935,6 +9935,93 @@ } } builders { + name: "Lacros FYI Release (octopus)" + swarming_host: "chromium-swarm.appspot.com" + dimensions: "builderless:1" + dimensions: "cores:8" + dimensions: "cpu:x86-64" + dimensions: "free_space:standard" + dimensions: "os:Ubuntu-18.04" + dimensions: "pool:luci.chromium.gpu.ci" + dimensions: "ssd:0" + exe { + cipd_package: "infra/chromium/bootstrapper/${platform}" + cipd_version: "latest" + cmd: "bootstrapper" + } + properties: + '{' + ' "$bootstrap/exe": {' + ' "exe": {' + ' "cipd_package": "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",' + ' "cipd_version": "refs/heads/main",' + ' "cmd": [' + ' "luciexe"' + ' ]' + ' }' + ' },' + ' "$bootstrap/properties": {' + ' "properties_file": "infra/config/generated/builders/ci/Lacros FYI Release (octopus)/properties.json",' + ' "top_level_project": {' + ' "ref": "refs/heads/main",' + ' "repo": {' + ' "host": "chromium.googlesource.com",' + ' "project": "chromium/src"' + ' }' + ' }' + ' },' + ' "builder_group": "chromium.gpu.fyi",' + ' "led_builder_is_bootstrapped": true,' + ' "recipe": "chromium",' + ' "sheriff_rotations": [' + ' "chromium.gpu"' + ' ]' + '}' + execution_timeout_secs: 21600 + build_numbers: YES + service_account: "chromium-ci-gpu-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "chromium_swarming.expose_merge_script_failures" + value: 100 + } + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "chrome-luci-data" + dataset: "chromium" + table: "ci_test_results" + test_results {} + } + bq_exports { + project: "chrome-luci-data" + dataset: "chromium" + table: "gpu_ci_test_results" + test_results { + predicate { + test_id_regexp: "ninja://chrome/test:telemetry_gpu_integration_test[^/]*/.+" + } + } + } + bq_exports { + project: "chrome-luci-data" + dataset: "chromium" + table: "blink_web_tests_ci_test_results" + test_results { + predicate { + test_id_regexp: "(ninja://[^/]*blink_web_tests/.+)|(ninja://[^/]*blink_wpt_tests/.+)" + } + } + } + history_options { + use_invocation_timestamp: true + } + } + } + builders { name: "Lacros FYI x64 Release (AMD)" swarming_host: "chromium-swarm.appspot.com" dimensions: "builderless:1" @@ -33158,7 +33245,7 @@ name: "ios15-sdk-simulator" swarming_host: "chromium-swarm.appspot.com" dimensions: "builder:ios15-sdk-simulator" - dimensions: "cpu:x86-64" + dimensions: "cpu:arm64" dimensions: "os:Mac-13" dimensions: "pool:luci.chromium.ci" exe {
diff --git a/infra/config/generated/luci/luci-milo.cfg b/infra/config/generated/luci/luci-milo.cfg index 68f08b8a3..16b9f622 100644 --- a/infra/config/generated/luci/luci-milo.cfg +++ b/infra/config/generated/luci/luci-milo.cfg
@@ -11373,6 +11373,11 @@ category: "Lacros|Intel" short_name: "int" } + builders { + name: "buildbucket/luci.chromium.ci/Lacros FYI Release (octopus)" + category: "Lacros|Intel" + short_name: "oct" + } header { oncalls { name: "Chromium"
diff --git a/infra/config/generated/luci/luci-scheduler.cfg b/infra/config/generated/luci/luci-scheduler.cfg index 8ad4ca8..2059f0e9 100644 --- a/infra/config/generated/luci/luci-scheduler.cfg +++ b/infra/config/generated/luci/luci-scheduler.cfg
@@ -1307,6 +1307,15 @@ } } job { + id: "Lacros FYI Release (octopus)" + realm: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Lacros FYI Release (octopus)" + } +} +job { id: "Lacros FYI x64 Release (AMD)" realm: "ci" buildbucket { @@ -6309,6 +6318,7 @@ triggers: "GPU Mac Builder (dbg)" triggers: "GPU Win x64 Builder" triggers: "GPU Win x64 Builder (dbg)" + triggers: "Lacros FYI Release (octopus)" triggers: "Leak Detection Linux" triggers: "Libfuzzer Upload Chrome OS ASan" triggers: "Libfuzzer Upload Linux ASan"
diff --git a/infra/config/generated/sheriff-rotations/chromium.gpu.txt b/infra/config/generated/sheriff-rotations/chromium.gpu.txt index 93aed63..531a03e1 100644 --- a/infra/config/generated/sheriff-rotations/chromium.gpu.txt +++ b/infra/config/generated/sheriff-rotations/chromium.gpu.txt
@@ -28,6 +28,7 @@ ci/GPU Linux Builder ci/GPU Mac Builder ci/GPU Win x64 Builder +ci/Lacros FYI Release (octopus) ci/Lacros FYI x64 Release (AMD) ci/Lacros FYI x64 Release (Intel) ci/Linux FYI Debug (NVIDIA)
diff --git a/infra/config/subprojects/chromium/ci/chromium.fyi.star b/infra/config/subprojects/chromium/ci/chromium.fyi.star index 1c6e550..37e62d5 100644 --- a/infra/config/subprojects/chromium/ci/chromium.fyi.star +++ b/infra/config/subprojects/chromium/ci/chromium.fyi.star
@@ -2288,6 +2288,7 @@ build_gs_bucket = "chromium-fyi-archive", ), os = os.MAC_13, + cpu = cpu.ARM64, console_view_entry = [ consoles.console_view_entry( category = "iOS|iOS15",
diff --git a/infra/config/subprojects/chromium/ci/chromium.gpu.fyi.star b/infra/config/subprojects/chromium/ci/chromium.gpu.fyi.star index 5cb477e..e159e6d 100644 --- a/infra/config/subprojects/chromium/ci/chromium.gpu.fyi.star +++ b/infra/config/subprojects/chromium/ci/chromium.gpu.fyi.star
@@ -355,6 +355,38 @@ ) ci.gpu.linux_builder( + name = "Lacros FYI Release (octopus)", + builder_spec = builder_config.builder_spec( + gclient_config = builder_config.gclient_config( + config = "chromium", + apply_configs = [ + "chromeos", + "checkout_lacros_sdk", + ], + ), + chromium_config = builder_config.chromium_config( + config = "chromium", + apply_configs = [ + "mb", + ], + build_config = builder_config.build_config.RELEASE, + target_arch = builder_config.target_arch.INTEL, + target_bits = 64, + target_platform = builder_config.target_platform.CHROMEOS, + target_cros_boards = [ + "octopus", + ], + ), + run_tests_serially = True, + ), + console_view_entry = consoles.console_view_entry( + category = "Lacros|Intel", + short_name = "oct", + ), + reclient_jobs = reclient.jobs.HIGH_JOBS_FOR_CI, +) + +ci.gpu.linux_builder( name = "GPU Flake Finder", executable = "recipe:chromium_expectation_files/expectation_file_scripts", # This will eventually be set up to run on a schedule, but only support
diff --git a/ios/chrome/app/spotlight/actions_spotlight_manager.h b/ios/chrome/app/spotlight/actions_spotlight_manager.h index fe7354c..7d7b80b 100644 --- a/ios/chrome/app/spotlight/actions_spotlight_manager.h +++ b/ios/chrome/app/spotlight/actions_spotlight_manager.h
@@ -8,6 +8,7 @@ #import "ios/chrome/app/spotlight/base_spotlight_manager.h" @class AppStartupParameters; +@class SpotlightInterface; namespace spotlight {
diff --git a/ios/chrome/app/spotlight/actions_spotlight_manager.mm b/ios/chrome/app/spotlight/actions_spotlight_manager.mm index ad83331..82ff353 100644 --- a/ios/chrome/app/spotlight/actions_spotlight_manager.mm +++ b/ios/chrome/app/spotlight/actions_spotlight_manager.mm
@@ -10,6 +10,7 @@ #import "base/metrics/histogram_macros.h" #import "base/strings/sys_string_conversions.h" #import "ios/chrome/app/app_startup_parameters.h" +#import "ios/chrome/app/spotlight/spotlight_interface.h" #import "ios/chrome/app/spotlight/spotlight_logger.h" #import "ios/chrome/common/app_group/app_group_constants.h" #import "ios/chrome/grit/ios_strings.h" @@ -115,7 +116,6 @@ } // namespace spotlight @interface ActionsSpotlightManager () - // Creates a new Spotlight entry with title `title` for the given `action`. - (CSSearchableItem*)itemForAction:(NSString*)action title:(NSString*)title; @@ -129,7 +129,8 @@ + (ActionsSpotlightManager*)actionsSpotlightManager { return [[ActionsSpotlightManager alloc] initWithLargeIconService:nil - domain:spotlight::DOMAIN_ACTIONS]; + domain:spotlight::DOMAIN_ACTIONS + spotlightInterface:[SpotlightInterface defaultInterface]]; } #pragma mark public methods @@ -193,10 +194,8 @@ title:defaultBrowserTitle], ]; - [[CSSearchableIndex defaultSearchableIndex] - indexSearchableItems:spotlightItems - completionHandler:nil]; - [[SpotlightLogger sharedLogger] logIndexedItems:spotlightItems]; + [self.spotlightInterface indexSearchableItems:spotlightItems + completionHandler:nil]; }); }]; }
diff --git a/ios/chrome/app/spotlight/base_spotlight_manager.h b/ios/chrome/app/spotlight/base_spotlight_manager.h index db5f9ee..2c5ea0c52 100644 --- a/ios/chrome/app/spotlight/base_spotlight_manager.h +++ b/ios/chrome/app/spotlight/base_spotlight_manager.h
@@ -11,6 +11,7 @@ #include "ios/chrome/app/spotlight/spotlight_util.h" class GURL; +@class SpotlightInterface; namespace favicon { class LargeIconService; @@ -21,10 +22,14 @@ - (instancetype)initWithLargeIconService: (favicon::LargeIconService*)largeIconService domain:(spotlight::Domain)domain + spotlightInterface:(SpotlightInterface*)spotlightInterface NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_UNAVAILABLE; +/// Facade interface for the spotlight API. +@property(nonatomic, readonly) SpotlightInterface* spotlightInterface; + // Refreshes all items that point to `URLToRefresh`, using title `title`, by // calling spotlightItemsWithURL on given URL. The values of `title` and `URL` // will be passed to spotlightItemsWithURL.
diff --git a/ios/chrome/app/spotlight/base_spotlight_manager.mm b/ios/chrome/app/spotlight/base_spotlight_manager.mm index 47cb8272d..07f59b67 100644 --- a/ios/chrome/app/spotlight/base_spotlight_manager.mm +++ b/ios/chrome/app/spotlight/base_spotlight_manager.mm
@@ -20,6 +20,7 @@ #import "components/favicon/core/large_icon_service.h" #import "components/favicon_base/fallback_icon_style.h" #import "components/favicon_base/favicon_types.h" +#import "ios/chrome/app/spotlight/spotlight_interface.h" #import "ios/chrome/app/spotlight/spotlight_logger.h" #import "ios/chrome/grit/ios_strings.h" #import "net/base/mac/url_conversions.h" @@ -106,13 +107,15 @@ @implementation BaseSpotlightManager -- (instancetype)initWithLargeIconService: - (favicon::LargeIconService*)largeIconService - domain:(spotlight::Domain)domain { +- (instancetype) + initWithLargeIconService:(favicon::LargeIconService*)largeIconService + domain:(spotlight::Domain)domain + spotlightInterface:(SpotlightInterface*)spotlightInterface { self = [super init]; if (self) { _spotlightDomain = domain; _largeIconService = largeIconService; + _spotlightInterface = spotlightInterface; _largeIconTaskTracker = std::make_unique<base::CancelableTaskTracker>(); } return self; @@ -150,7 +153,10 @@ - (void)clearAllSpotlightItems:(BlockWithError)callback { [self cancelAllLargeIconPendingTasks]; - spotlight::DeleteSearchableDomainItems(_spotlightDomain, callback); + [self.spotlightInterface deleteSearchableItemsWithDomainIdentifiers:@[ + spotlight::StringFromSpotlightDomain(_spotlightDomain) + ] + completionHandler:callback]; } - (CSSearchableItem*)spotlightItemWithItemID:(NSString*)itemID @@ -279,10 +285,8 @@ defaultTitle:title]; if ([spotlightItems count]) { - [[CSSearchableIndex defaultSearchableIndex] - indexSearchableItems:spotlightItems - completionHandler:nil]; - [[SpotlightLogger sharedLogger] logIndexedItems:spotlightItems]; + [self.spotlightInterface indexSearchableItems:spotlightItems + completionHandler:nil]; } }
diff --git a/ios/chrome/app/spotlight/bookmarks_spotlight_manager.mm b/ios/chrome/app/spotlight/bookmarks_spotlight_manager.mm index d333d6f..d7aa20b7 100644 --- a/ios/chrome/app/spotlight/bookmarks_spotlight_manager.mm +++ b/ios/chrome/app/spotlight/bookmarks_spotlight_manager.mm
@@ -54,9 +54,6 @@ BOOL _initialIndexDone; } -/// Facade interface for the spotlight API. -@property(nonatomic, readonly) SpotlightInterface* spotlightInterface; - // Detaches the `SpotlightBookmarkModelBridge` from the bookmark model. The // manager must not be used after calling this method. - (void)detachBookmarkModel; @@ -168,12 +165,12 @@ bookmarkModel:(bookmarks::BookmarkModel*)bookmarkModel spotlightInterface:(SpotlightInterface*)spotlightInterface { self = [super initWithLargeIconService:largeIconService - domain:spotlight::DOMAIN_BOOKMARKS]; + domain:spotlight::DOMAIN_BOOKMARKS + spotlightInterface:spotlightInterface]; if (self) { _bookmarkModelBridge.reset(new SpotlightBookmarkModelBridge(self)); _bookmarkModel = bookmarkModel; bookmarkModel->AddObserver(_bookmarkModelBridge.get()); - _spotlightInterface = spotlightInterface; } return self; }
diff --git a/ios/chrome/app/spotlight/reading_list_spotlight_manager.h b/ios/chrome/app/spotlight/reading_list_spotlight_manager.h index 6895df2..038602d 100644 --- a/ios/chrome/app/spotlight/reading_list_spotlight_manager.h +++ b/ios/chrome/app/spotlight/reading_list_spotlight_manager.h
@@ -33,6 +33,7 @@ - (instancetype)initWithLargeIconService: (favicon::LargeIconService*)largeIconService domain:(spotlight::Domain)domain + spotlightInterface:(SpotlightInterface*)spotlightInterface NS_UNAVAILABLE; /// Immediately clears and reindexes the reading list items in Spotlight. Calls
diff --git a/ios/chrome/app/spotlight/reading_list_spotlight_manager.mm b/ios/chrome/app/spotlight/reading_list_spotlight_manager.mm index 3b2d4c22..ff3edc9 100644 --- a/ios/chrome/app/spotlight/reading_list_spotlight_manager.mm +++ b/ios/chrome/app/spotlight/reading_list_spotlight_manager.mm
@@ -34,9 +34,6 @@ std::map<GURL, bool> _batch_update_log; } -/// Facade interface for the spotlight API. -@property(nonatomic, readonly) SpotlightInterface* spotlightInterface; - /// Tracks reentrant batch updates of the model. A value of 0 indicates that the /// model is not in batch updates mode and vice versa. @property(nonatomic, assign) NSInteger modelUpdateDepth; @@ -60,11 +57,11 @@ readingListModel:(ReadingListModel*)model spotlightInterface:(SpotlightInterface*)spotlightInterface { self = [super initWithLargeIconService:largeIconService - domain:spotlight::DOMAIN_READING_LIST]; + domain:spotlight::DOMAIN_READING_LIST + spotlightInterface:spotlightInterface]; if (self) { _model = model; _modelBridge.reset(new ReadingListModelBridge(self, model)); - _spotlightInterface = spotlightInterface; } return self; }
diff --git a/ios/chrome/app/spotlight/reading_list_spotlight_manager_unittest.mm b/ios/chrome/app/spotlight/reading_list_spotlight_manager_unittest.mm index fb674e5..8d25c55d 100644 --- a/ios/chrome/app/spotlight/reading_list_spotlight_manager_unittest.mm +++ b/ios/chrome/app/spotlight/reading_list_spotlight_manager_unittest.mm
@@ -80,10 +80,7 @@ browser_state_.get()); CreateMockLargeIconService(); - readingListSpotlightManager_ = [[ReadingListSpotlightManager alloc] - initWithLargeIconService:large_icon_service_.get() - readingListModel:model_ - spotlightInterface:[SpotlightInterface defaultInterface]]; + spotlightInterface_ = [SpotlightInterface defaultInterface]; } protected: @@ -106,24 +103,17 @@ }); } - ~ReadingListSpotlightManagerTest() override { - [readingListSpotlightManager_ shutdown]; - } - base::test::TaskEnvironment task_environment_; std::unique_ptr<TestChromeBrowserState> browser_state_; testing::StrictMock<favicon::MockFaviconService> mock_favicon_service_; std::unique_ptr<favicon::LargeIconServiceImpl> large_icon_service_; base::CancelableTaskTracker cancelable_task_tracker_; ReadingListModel* model_; - ReadingListSpotlightManager* readingListSpotlightManager_; + SpotlightInterface* spotlightInterface_; }; /// Tests that init propagates the `model` and -shutdown removes it. TEST_F(ReadingListSpotlightManagerTest, testInitAndShutdown) { - // For this test, don't use readingListSpotlightManager_, and init a new copy - // instead. - ReadingListSpotlightManager* manager = [[ReadingListSpotlightManager alloc] initWithLargeIconService:large_icon_service_.get() readingListModel:model_ @@ -135,32 +125,38 @@ } /// Tests that clearAndReindexReadingList actually clears all items (by calling -/// super) and adds the items (again, by calling super -/// -refreshItemsWithURL:title:) +/// spotlight api) and adds the items ( by calling base class method +/// refreshItemsWithURL) TEST_F(ReadingListSpotlightManagerTest, testClearsAndIndexesItems) { - id partialMgrMock = - [OCMockObject partialMockForObject:readingListSpotlightManager_]; - [[[partialMgrMock expect] andForwardToRealObject] - clearAllSpotlightItems:[OCMArg any]]; + void (^proxyBlock)(NSInvocation*) = ^(NSInvocation* invocation) { + void (^passedBlock)(NSError* error); + [invocation getArgument:&passedBlock atIndex:3]; + passedBlock(nil); + }; GURL ignoredURL = GURL("http://chromium.org"); - __block BOOL invocationFired = false; - [[[[partialMgrMock expect] ignoringNonObjectArgs] andDo:^(NSInvocation* inv) { - GURL* url; - [inv getArgument:&url atIndex:2]; - EXPECT_EQ(kTestURL, url->spec()); - __unsafe_unretained NSString* title; - [inv getArgument:&title atIndex:3]; - EXPECT_NSEQ(title, base::SysUTF8ToNSString(kTestTitle)); - invocationFired = true; - }] refreshItemsWithURL:ignoredURL title:[OCMArg any]]; - EXPECT_TRUE( - base::test::ios::WaitUntilConditionOrTimeout(base::Seconds(3), ^bool { - return invocationFired; - })); + id mockSpotlightInterface = + [OCMockObject partialMockForObject:spotlightInterface_]; - [partialMgrMock clearAndReindexReadingListWithCompletionBlock:nil]; + ReadingListSpotlightManager* manager = [[ReadingListSpotlightManager alloc] + initWithLargeIconService:large_icon_service_.get() + readingListModel:model_ + spotlightInterface:mockSpotlightInterface]; - EXPECT_OCMOCK_VERIFY(partialMgrMock); + id mockManager = [OCMockObject partialMockForObject:manager]; + + [[[mockSpotlightInterface expect] andDo:proxyBlock] + deleteSearchableItemsWithDomainIdentifiers:[OCMArg any] + completionHandler:[OCMArg any]]; + [[[mockManager expect] ignoringNonObjectArgs] + refreshItemsWithURL:ignoredURL + title:[OCMArg any]]; + + [mockManager clearAndReindexReadingListWithCompletionBlock:nil]; + + EXPECT_OCMOCK_VERIFY(mockSpotlightInterface); + EXPECT_OCMOCK_VERIFY(mockManager); + + [manager shutdown]; }
diff --git a/ios/chrome/app/spotlight/spotlight_util.h b/ios/chrome/app/spotlight/spotlight_util.h index d52294b..b18fa23 100644 --- a/ios/chrome/app/spotlight/spotlight_util.h +++ b/ios/chrome/app/spotlight/spotlight_util.h
@@ -46,12 +46,6 @@ // Maximum retry attempts to delete/index a set of items. const NSUInteger kMaxAttempts = 5; -// Utility methods deleting nodes in Spotlight index. Will be retried in case of -// failure as required by Apple documentation. -void DeleteSearchableDomainItems(Domain domain, BlockWithError callback); -void DeleteItemsWithIdentifiers(NSArray* items, BlockWithError callback); -void ClearAllSpotlightEntries(BlockWithError callback); - // Converts the spotlight::Domain enum to Spotlight domain string NSString* StringFromSpotlightDomain(Domain domain); @@ -62,13 +56,6 @@ // calling other methods of this class. bool IsSpotlightAvailable(); -// Clears the current Spotlight index of the device. Method is static to allow -// clearing the index without instantiating SpotlightManager. -// This method must not be called if `isSpotlightAvailable` returns NO. -// This method is asynchronous and can fail. Completion is called with a -// parameter indicating if the deletion was a success. -void ClearSpotlightIndexWithCompletion(BlockWithError completion); - // Finds the Spoglight itemID and calls `completion` with the corresponding URL. // Calls `completion` with nil if none was found. // `completion` is called on the Spotlight Thread.
diff --git a/ios/chrome/app/spotlight/spotlight_util.mm b/ios/chrome/app/spotlight/spotlight_util.mm index 69bfe10..a5f6059 100644 --- a/ios/chrome/app/spotlight/spotlight_util.mm +++ b/ios/chrome/app/spotlight/spotlight_util.mm
@@ -38,36 +38,6 @@ SPOTLIGHT_AVAILABILITY_COUNT }; -// Documentation says that failed deletion should be retried. Set a maximum -// value to avoid infinite loop. -const int kMaxDeletionAttempts = 5; - -// Execute blockName block with up to retryCount retries on error. Execute -// callback when done. -void DoWithRetry(BlockWithError callback, - NSUInteger retryCount, - void (^blockName)(BlockWithError error)) { - BlockWithError retryCallback = ^(NSError* error) { - if (error && retryCount > 0) { - DoWithRetry(callback, retryCount - 1, blockName); - } else { - if (callback) { - dispatch_async(dispatch_get_main_queue(), ^{ - callback(error); - }); - } - } - }; - blockName(retryCallback); -} - -// Execute blockName block with up to kMaxDeletionAttempts retries on error. -// Execute callback when done. -void DoWithRetry(BlockWithError completion, - void (^blockName)(BlockWithError error)) { - DoWithRetry(completion, kMaxDeletionAttempts, blockName); -} - // Strings corresponding to the domain/prefix for respectively bookmarks, // top sites and actions items for spotlight. #if BUILDFLAG(GOOGLE_CHROME_BRANDING) @@ -149,47 +119,6 @@ } } -void DeleteItemsWithIdentifiers(NSArray* items, BlockWithError callback) { - void (^deleteItems)(BlockWithError) = ^(BlockWithError errorBlock) { - [[CSSearchableIndex defaultSearchableIndex] - deleteSearchableItemsWithIdentifiers:items - completionHandler:errorBlock]; - [[SpotlightLogger sharedLogger] logDeletionOfItemsWithIdentifiers:items]; - }; - - DoWithRetry(callback, deleteItems); -} - -void DeleteSearchableDomainItems(Domain domain, BlockWithError callback) { - void (^deleteItems)(BlockWithError) = ^(BlockWithError errorBlock) { - NSString* domainString = StringFromSpotlightDomain(domain); - [[CSSearchableIndex defaultSearchableIndex] - deleteSearchableItemsWithDomainIdentifiers:@[ domainString ] - completionHandler:errorBlock]; - [[SpotlightLogger sharedLogger] logDeletionOfItemsInDomain:domainString]; - }; - - DoWithRetry(callback, deleteItems); -} - -void ClearAllSpotlightEntries(BlockWithError callback) { - BlockWithError augmentedCallback = ^(NSError* error) { - [[NSUserDefaults standardUserDefaults] - removeObjectForKey:@(kSpotlightLastIndexingDateKey)]; - if (callback) { - callback(error); - } - }; - - void (^deleteItems)(BlockWithError) = ^(BlockWithError errorBlock) { - [[CSSearchableIndex defaultSearchableIndex] - deleteAllSearchableItemsWithCompletionHandler:errorBlock]; - [[SpotlightLogger sharedLogger] logDeletionOfAllItems]; - }; - - DoWithRetry(augmentedCallback, deleteItems); -} - bool IsSpotlightAvailable() { bool loaded = !![CSSearchableIndex class]; bool available = loaded && [CSSearchableIndex isIndexingAvailable]; @@ -208,11 +137,6 @@ return loaded && available; } -void ClearSpotlightIndexWithCompletion(BlockWithError completion) { - DCHECK(IsSpotlightAvailable()); - ClearAllSpotlightEntries(completion); -} - NSString* GetSpotlightCustomAttributeItemID() { #if BUILDFLAG(GOOGLE_CHROME_BRANDING) return @"ComGoogleChromeItemID";
diff --git a/ios/chrome/app/spotlight/topsites_spotlight_manager.mm b/ios/chrome/app/spotlight/topsites_spotlight_manager.mm index be9b25dd..279e26fa 100644 --- a/ios/chrome/app/spotlight/topsites_spotlight_manager.mm +++ b/ios/chrome/app/spotlight/topsites_spotlight_manager.mm
@@ -14,6 +14,7 @@ #import "components/history/core/browser/top_sites.h" #import "components/history/core/browser/top_sites_observer.h" #import "components/sync/driver/sync_service.h" +#import "ios/chrome/app/spotlight/spotlight_interface.h" #import "ios/chrome/browser/bookmarks/local_or_syncable_bookmark_model_factory.h" #import "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h" #import "ios/chrome/browser/history/top_sites_factory.h" @@ -49,7 +50,8 @@ - (instancetype) initWithLargeIconService:(favicon::LargeIconService*)largeIconService topSites:(scoped_refptr<history::TopSites>)topSites - bookmarkModel:(bookmarks::BookmarkModel*)bookmarkModel; + bookmarkModel:(bookmarks::BookmarkModel*)bookmarkModel + spotlightInterface:(SpotlightInterface*)spotlightInterface; // Updates all indexed top sites from appropriate source, within limit of number // of sites shown on NTP. @@ -119,15 +121,18 @@ topSites:ios::TopSitesFactory::GetForBrowserState( browserState) bookmarkModel:ios::LocalOrSyncableBookmarkModelFactory:: - GetForBrowserState(browserState)]; + GetForBrowserState(browserState) + spotlightInterface:[SpotlightInterface defaultInterface]]; } - (instancetype) initWithLargeIconService:(favicon::LargeIconService*)largeIconService topSites:(scoped_refptr<history::TopSites>)topSites - bookmarkModel:(bookmarks::BookmarkModel*)bookmarkModel { + bookmarkModel:(bookmarks::BookmarkModel*)bookmarkModel + spotlightInterface:(SpotlightInterface*)spotlightInterface { self = [super initWithLargeIconService:largeIconService - domain:spotlight::DOMAIN_TOPSITES]; + domain:spotlight::DOMAIN_TOPSITES + spotlightInterface:spotlightInterface]; if (self) { DCHECK(topSites); DCHECK(bookmarkModel);
diff --git a/ios/chrome/browser/browser_state/chrome_browser_state_impl.mm b/ios/chrome/browser/browser_state/chrome_browser_state_impl.mm index e084418..d5013cb 100644 --- a/ios/chrome/browser/browser_state/chrome_browser_state_impl.mm +++ b/ios/chrome/browser/browser_state/chrome_browser_state_impl.mm
@@ -26,6 +26,7 @@ #import "components/sync_preferences/pref_service_syncable.h" #import "components/user_prefs/user_prefs.h" #import "ios/chrome/browser/application_context/application_context.h" +#import "ios/chrome/browser/bookmarks/account_bookmark_model_factory.h" #import "ios/chrome/browser/bookmarks/local_or_syncable_bookmark_model_factory.h" #import "ios/chrome/browser/browser_state/bookmark_model_loaded_observer.h" #import "ios/chrome/browser/browser_state/constants.h" @@ -149,9 +150,15 @@ io_data_->Init(cookie_path, cache_path, cache_max_size, state_path_); // Listen for bookmark model load, to bootstrap the sync service. - bookmarks::BookmarkModel* model = + // TODO(crbug.com/1427452): See if BookmarkModelLoadedObserver can be removed. + bookmarks::BookmarkModel* local_or_syncable_model = ios::LocalOrSyncableBookmarkModelFactory::GetForBrowserState(this); - model->AddObserver(new BookmarkModelLoadedObserver(this)); + local_or_syncable_model->AddObserver(new BookmarkModelLoadedObserver(this)); + bookmarks::BookmarkModel* account_model = + ios::AccountBookmarkModelFactory::GetForBrowserState(this); + if (account_model) { + account_model->AddObserver(new BookmarkModelLoadedObserver(this)); + } } ChromeBrowserStateImpl::~ChromeBrowserStateImpl() {
diff --git a/ios/chrome/browser/reading_list/offline_page_tab_helper.mm b/ios/chrome/browser/reading_list/offline_page_tab_helper.mm index 0949e81..e522cd35 100644 --- a/ios/chrome/browser/reading_list/offline_page_tab_helper.mm +++ b/ios/chrome/browser/reading_list/offline_page_tab_helper.mm
@@ -190,9 +190,9 @@ context->GetPageTransition(), ui::PAGE_TRANSITION_RELOAD); is_offline_navigation_ = reading_list::IsOfflineEntryURL(initial_navigation_url_); + navigation_transition_type_ = context->GetPageTransition(); is_new_navigation_ = ui::PageTransitionIsNewNavigation(navigation_transition_type_); - navigation_transition_type_ = context->GetPageTransition(); navigation_is_renderer_initiated_ = context->IsRendererInitiated(); }
diff --git a/ios/chrome/browser/ui/authentication/authentication_flow.mm b/ios/chrome/browser/ui/authentication/authentication_flow.mm index 760d4552..cafe9fb 100644 --- a/ios/chrome/browser/ui/authentication/authentication_flow.mm +++ b/ios/chrome/browser/ui/authentication/authentication_flow.mm
@@ -222,9 +222,16 @@ return CHECK_MERGE_CASE; case CHECK_MERGE_CASE: // If the user enabled Sync, expect the data clearing strategy to be set. - DCHECK(self.postSignInAction == PostSignInAction::kNone || - (self.postSignInAction == PostSignInAction::kCommitSync && - self.localDataClearingStrategy != SHOULD_CLEAR_DATA_USER_CHOICE)); + switch (self.postSignInAction) { + case PostSignInAction::kNone: + case PostSignInAction::kEnableBookmarkReadingListAccountStorage: + // `localDataClearingStrategy` is not required. + break; + case PostSignInAction::kCommitSync: + DCHECK_NE(SHOULD_CLEAR_DATA_USER_CHOICE, + self.localDataClearingStrategy); + break; + } if (_shouldShowManagedConfirmation) return SHOW_MANAGED_CONFIRMATION; else if (_shouldSignOut)
diff --git a/ios/chrome/browser/ui/autofill/BUILD.gn b/ios/chrome/browser/ui/autofill/BUILD.gn index 9e23ab5..47fe708 100644 --- a/ios/chrome/browser/ui/autofill/BUILD.gn +++ b/ios/chrome/browser/ui/autofill/BUILD.gn
@@ -102,6 +102,41 @@ frameworks = [ "UIKit.framework" ] } +source_set("autofill_shared_ui") { + configs += [ "//build/config/compiler:enable_arc" ] + sources = [ + "autofill_country_selection_table_view_controller.h", + "autofill_country_selection_table_view_controller.mm", + "autofill_profile_edit_consumer.h", + "autofill_profile_edit_handler.h", + "autofill_profile_edit_mediator.h", + "autofill_profile_edit_mediator.mm", + "autofill_profile_edit_mediator_delegate.h", + "autofill_profile_edit_table_view_controller.h", + "autofill_profile_edit_table_view_controller.mm", + "autofill_profile_edit_table_view_controller_delegate.h", + ] + deps = [ + ":autofill_ui_type", + "//base:base", + "//components/autofill/core/browser", + "//components/autofill/core/common:features", + "//ios/chrome/app/strings", + "//ios/chrome/browser/application_context", + "//ios/chrome/browser/shared/public/features", + "//ios/chrome/browser/shared/ui/list_model", + "//ios/chrome/browser/shared/ui/table_view", + "//ios/chrome/browser/shared/ui/table_view:constants", + "//ios/chrome/browser/shared/ui/table_view:utils", + "//ios/chrome/browser/shared/ui/util", + "//ios/chrome/browser/ui/autofill/cells", + "//ios/chrome/browser/ui/settings/autofill:constants", + "//ios/chrome/common/ui/colors", + "//ios/chrome/common/ui/util", + "//ui/base", + ] +} + source_set("autofill_ui_type") { configs += [ "//build/config/compiler:enable_arc" ] sources = [ @@ -225,17 +260,29 @@ source_set("unit_tests") { testonly = true - sources = [ "card_unmask_prompt_view_controller_unittest.mm" ] + sources = [ + "autofill_profile_edit_mediator_unittest.mm", + "card_unmask_prompt_view_controller_unittest.mm", + ] deps = [ + ":autofill_shared_ui", ":bridges", "//base/test:test_support", "//components/autofill/core/browser", + "//components/autofill/core/browser:test_support", "//components/prefs:test_support", + "//ios/chrome/browser/autofill", + "//ios/chrome/browser/browser_state:test_support", + "//ios/chrome/browser/shared/ui/list_model", "//ios/chrome/browser/shared/ui/table_view:test_support", "//ios/chrome/browser/ui/autofill/cells", + "//ios/chrome/browser/ui/settings:test_support", + "//ios/chrome/browser/webdata_services", "//ios/chrome/test:test_support", + "//ios/web/public/test", "//testing/gmock", "//testing/gtest", + "//third_party/ocmock", ] configs += [ "//build/config/compiler:enable_arc" ] }
diff --git a/ios/chrome/browser/ui/settings/autofill/autofill_country_selection_table_view_controller.h b/ios/chrome/browser/ui/autofill/autofill_country_selection_table_view_controller.h similarity index 68% rename from ios/chrome/browser/ui/settings/autofill/autofill_country_selection_table_view_controller.h rename to ios/chrome/browser/ui/autofill/autofill_country_selection_table_view_controller.h index 6a744e4..1064e224 100644 --- a/ios/chrome/browser/ui/settings/autofill/autofill_country_selection_table_view_controller.h +++ b/ios/chrome/browser/ui/autofill/autofill_country_selection_table_view_controller.h
@@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_COUNTRY_SELECTION_TABLE_VIEW_CONTROLLER_H_ -#define IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_COUNTRY_SELECTION_TABLE_VIEW_CONTROLLER_H_ +#ifndef IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_COUNTRY_SELECTION_TABLE_VIEW_CONTROLLER_H_ +#define IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_COUNTRY_SELECTION_TABLE_VIEW_CONTROLLER_H_ -#import "ios/chrome/browser/ui/settings/settings_controller_protocol.h" -#import "ios/chrome/browser/ui/settings/settings_root_table_view_controller.h" +#import "ios/chrome/browser/shared/ui/table_view/chrome_table_view_controller.h" @class AutofillCountrySelectionTableViewController; @class CountryItem; @@ -23,7 +22,7 @@ // Controller for the UI that allows the user to select a country. @interface AutofillCountrySelectionTableViewController - : SettingsRootTableViewController <SettingsControllerProtocol> + : ChromeTableViewController // The designated initializer. `delegate` must not be nil and // will not be retained. @@ -38,4 +37,4 @@ @end -#endif // IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_COUNTRY_SELECTION_TABLE_VIEW_CONTROLLER_H_ +#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_COUNTRY_SELECTION_TABLE_VIEW_CONTROLLER_H_
diff --git a/ios/chrome/browser/ui/settings/autofill/autofill_country_selection_table_view_controller.mm b/ios/chrome/browser/ui/autofill/autofill_country_selection_table_view_controller.mm similarity index 97% rename from ios/chrome/browser/ui/settings/autofill/autofill_country_selection_table_view_controller.mm rename to ios/chrome/browser/ui/autofill/autofill_country_selection_table_view_controller.mm index 2e512c3c5..5824439 100644 --- a/ios/chrome/browser/ui/settings/autofill/autofill_country_selection_table_view_controller.mm +++ b/ios/chrome/browser/ui/autofill/autofill_country_selection_table_view_controller.mm
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "ios/chrome/browser/ui/settings/autofill/autofill_country_selection_table_view_controller.h" +#import "ios/chrome/browser/ui/autofill/autofill_country_selection_table_view_controller.h" #import "base/mac/foundation_util.h" #import "base/strings/sys_string_conversions.h" @@ -10,8 +10,8 @@ #import "ios/chrome/browser/shared/ui/table_view/table_view_navigation_controller_constants.h" #import "ios/chrome/browser/shared/ui/table_view/table_view_utils.h" #import "ios/chrome/browser/shared/ui/util/uikit_ui_util.h" +#import "ios/chrome/browser/ui/autofill/cells/country_item.h" #import "ios/chrome/browser/ui/settings/autofill/autofill_constants.h" -#import "ios/chrome/browser/ui/settings/autofill/cells/country_item.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h" #import "ios/chrome/common/ui/util/constraints_ui_util.h" #import "ios/chrome/grit/ios_strings.h" @@ -80,7 +80,6 @@ [super viewDidLoad]; self.title = l10n_util::GetNSString(IDS_IOS_AUTOFILL_EDIT_ADDRESS); - self.shouldHideDoneButton = YES; // Search controller. self.searchController =
diff --git a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_consumer.h b/ios/chrome/browser/ui/autofill/autofill_profile_edit_consumer.h similarity index 87% rename from ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_consumer.h rename to ios/chrome/browser/ui/autofill/autofill_profile_edit_consumer.h index 5796bde..e13a81ae 100644 --- a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_consumer.h +++ b/ios/chrome/browser/ui/autofill/autofill_profile_edit_consumer.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 IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_CONSUMER_H_ -#define IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_CONSUMER_H_ +#ifndef IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_CONSUMER_H_ +#define IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_CONSUMER_H_ #import <Foundation/Foundation.h> @@ -48,4 +48,4 @@ @end -#endif // IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_CONSUMER_H_ +#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_CONSUMER_H_
diff --git a/ios/chrome/browser/ui/autofill/autofill_profile_edit_handler.h b/ios/chrome/browser/ui/autofill/autofill_profile_edit_handler.h new file mode 100644 index 0000000..964f283 --- /dev/null +++ b/ios/chrome/browser/ui/autofill/autofill_profile_edit_handler.h
@@ -0,0 +1,48 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_HANDLER_H_ +#define IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_HANDLER_H_ + +#import <Foundation/Foundation.h> +#import <UIKit/UIKit.h> + +// Protocol for updating the autofill profile edit view controller. +@protocol AutofillProfileEditHandler <NSObject> + +// Called when the view controller's view has disappeared. +- (void)viewDidDisappear; + +// Called for loading the model to the view controller. +- (void)loadModel; + +// Called when a row is selected in the view controller. +- (void)didSelectRowAtIndexPath:(NSIndexPath*)indexPath; + +// Called for setting `cell` properties at `indexPath`. +- (UITableViewCell*)cell:(UITableViewCell*)cell + forRowAtIndexPath:(NSIndexPath*)indexPath; + +// Returns header sections view controller whose height should be 0. +- (BOOL)heightForHeaderShouldBeZeroInSection:(NSInteger)section; + +// Returns footer sections in the view controller whose height should be 0. +- (BOOL)heightForFooterShouldBeZeroInSection:(NSInteger)section; + +// Returns YES if the row is editable for `indexPath` in the view controller. +- (BOOL)canEditRowAtIndexPath:(NSIndexPath*)indexPath; + +// Decides the editing style for the `indexPath` in the view controller. +- (UITableViewCellEditingStyle)editingStyleForRowAtIndexPath: + (NSIndexPath*)indexPath; + +// Decides to indent row when editing at `indexPath`. +- (BOOL)shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath*)indexPath; + +// Called when the edit button is pressed. +- (void)editButtonPressed; + +@end + +#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_HANDLER_H_
diff --git a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator.h b/ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator.h similarity index 77% rename from ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator.h rename to ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator.h index e678ead..069ef3b5 100644 --- a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator.h +++ b/ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator.h
@@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_MEDIATOR_H_ -#define IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_MEDIATOR_H_ +#ifndef IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_MEDIATOR_H_ +#define IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_MEDIATOR_H_ #import <Foundation/Foundation.h> -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller_delegate.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller_delegate.h" namespace autofill { class AutofillProfile; @@ -41,4 +41,4 @@ @end -#endif // IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_MEDIATOR_H_ +#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_MEDIATOR_H_
diff --git a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator.mm b/ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator.mm similarity index 96% rename from ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator.mm rename to ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator.mm index b7ecd18f..b0b6a19 100644 --- a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator.mm +++ b/ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator.mm
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator.h" #import "base/strings/sys_string_conversions.h" #import "components/autofill/core/browser/geo/autofill_country.h" @@ -10,11 +10,11 @@ #import "components/autofill/core/browser/ui/country_combobox_model.h" #import "ios/chrome/browser/application_context/application_context.h" #import "ios/chrome/browser/shared/ui/list_model/list_model.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_consumer.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator_delegate.h" #import "ios/chrome/browser/ui/autofill/autofill_ui_type.h" #import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h" -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_consumer.h" -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator_delegate.h" -#import "ios/chrome/browser/ui/settings/autofill/cells/country_item.h" +#import "ios/chrome/browser/ui/autofill/cells/country_item.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support."
diff --git a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator_delegate.h b/ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator_delegate.h similarity index 74% rename from ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator_delegate.h rename to ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator_delegate.h index d62dbd78..6e9c988 100644 --- a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator_delegate.h +++ b/ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator_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 IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_MEDIATOR_DELEGATE_H_ -#define IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_MEDIATOR_DELEGATE_H_ +#ifndef IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_MEDIATOR_DELEGATE_H_ +#define IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_MEDIATOR_DELEGATE_H_ @class AutofillProfileEditMediator; @class CountryItem; @@ -24,4 +24,4 @@ @end -#endif // IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_MEDIATOR_DELEGATE_H_ +#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_MEDIATOR_DELEGATE_H_
diff --git a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator_unittest.mm b/ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator_unittest.mm similarity index 94% rename from ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator_unittest.mm rename to ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator_unittest.mm index 32efe62..56a0779 100644 --- a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator_unittest.mm +++ b/ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator_unittest.mm
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator.h" #import "base/strings/sys_string_conversions.h" #import "base/test/scoped_feature_list.h" @@ -12,9 +12,9 @@ #import "ios/chrome/browser/autofill/personal_data_manager_factory.h" #import "ios/chrome/browser/browser_state/test_chrome_browser_state.h" #import "ios/chrome/browser/shared/ui/list_model/list_model.h" -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_consumer.h" -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator_delegate.h" -#import "ios/chrome/browser/ui/settings/autofill/cells/country_item.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_consumer.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator_delegate.h" +#import "ios/chrome/browser/ui/autofill/cells/country_item.h" #import "ios/chrome/browser/ui/settings/personal_data_manager_finished_profile_tasks_waiter.h" #import "ios/chrome/browser/webdata_services/web_data_service_factory.h" #import "ios/chrome/test/ios_chrome_scoped_testing_local_state.h"
diff --git a/ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller.h b/ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller.h new file mode 100644 index 0000000..5361265 --- /dev/null +++ b/ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller.h
@@ -0,0 +1,33 @@ +// Copyright 2015 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_H_ +#define IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_H_ + +#import "ios/chrome/browser/shared/ui/table_view/chrome_table_view_controller.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_consumer.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_handler.h" + +@protocol AutofillProfileEditTableViewControllerDelegate; + +// The table view shared between the settings and messages UI for the edit +// functionality. +@interface AutofillProfileEditTableViewController + : NSObject <AutofillProfileEditConsumer, + AutofillProfileEditHandler, + UITextFieldDelegate> + +// Initializes a AutofillProfileEditTableViewController with passed `delegate` +// and `userEmail`. +- (instancetype)initWithDelegate: + (id<AutofillProfileEditTableViewControllerDelegate>)delegate + userEmail:(NSString*)userEmail + controller:(ChromeTableViewController*)controller + NS_DESIGNATED_INITIALIZER; + +- (instancetype)init NS_UNAVAILABLE; + +@end + +#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_H_
diff --git a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller.mm b/ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller.mm similarity index 84% rename from ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller.mm rename to ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller.mm index 54041da02c..b0eacdec 100644 --- a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller.mm +++ b/ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller.mm
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller.h" #import "base/mac/foundation_util.h" #import "base/strings/sys_string_conversions.h" @@ -11,17 +11,18 @@ #import "components/autofill/core/common/autofill_features.h" #import "ios/chrome/browser/shared/public/features/features.h" #import "ios/chrome/browser/shared/ui/table_view/cells/table_view_attributed_string_header_footer_item.h" +#import "ios/chrome/browser/shared/ui/table_view/cells/table_view_link_header_footer_item.h" #import "ios/chrome/browser/shared/ui/table_view/cells/table_view_multi_detail_text_item.h" #import "ios/chrome/browser/shared/ui/table_view/cells/table_view_text_edit_item_delegate.h" #import "ios/chrome/browser/shared/ui/table_view/cells/table_view_text_item.h" #import "ios/chrome/browser/shared/ui/table_view/table_view_model.h" #import "ios/chrome/browser/shared/ui/table_view/table_view_utils.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller_delegate.h" #import "ios/chrome/browser/ui/autofill/autofill_ui_type.h" #import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h" #import "ios/chrome/browser/ui/autofill/cells/autofill_edit_item.h" +#import "ios/chrome/browser/ui/autofill/cells/country_item.h" #import "ios/chrome/browser/ui/settings/autofill/autofill_constants.h" -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller_delegate.h" -#import "ios/chrome/browser/ui/settings/autofill/cells/country_item.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h" #import "ios/chrome/grit/ios_strings.h" #import "ui/base/l10n/l10n_util.h" @@ -30,7 +31,6 @@ #error "This file requires ARC support." #endif - namespace { using ::AutofillTypeFromAutofillUIType; using ::AutofillUITypeFromAutofillType; @@ -102,6 +102,9 @@ // `autofill::features::kAutofillAccountProfilesUnionView` is enabled. @property(nonatomic, assign) BOOL autofillAccountProfilesUnionViewEnabled; +// The shown view controller. +@property(nonatomic, weak) ChromeTableViewController* controller; + @end @implementation AutofillProfileEditTableViewController { @@ -112,8 +115,9 @@ - (instancetype)initWithDelegate: (id<AutofillProfileEditTableViewControllerDelegate>)delegate - userEmail:(NSString*)userEmail { - self = [super initWithStyle:ChromeTableViewStyle()]; + userEmail:(NSString*)userEmail + controller:(ChromeTableViewController*)controller { + self = [super init]; if (self) { _delegate = delegate; _userEmail = userEmail; @@ -122,34 +126,21 @@ _autofillAccountProfilesUnionViewEnabled = base::FeatureList::IsEnabled( autofill::features::kAutofillAccountProfilesUnionView); _requiredFieldsWithEmptyValue = [[NSMutableSet<NSString*> alloc] init]; - - [self setTitle:l10n_util::GetNSString(IDS_IOS_AUTOFILL_EDIT_ADDRESS)]; + _controller = controller; } return self; } -- (void)viewDidLoad { - [super viewDidLoad]; +#pragma mark - AutofillProfileEditHandler - self.tableView.allowsSelectionDuringEditing = YES; - self.tableView.accessibilityIdentifier = kAutofillProfileEditTableViewId; - - [self loadModel]; -} - -- (void)viewDidDisappear:(BOOL)animated { +- (void)viewDidDisappear { [self.delegate viewDidDisappear]; - [super viewDidDisappear:animated]; } -#pragma mark - SettingsRootTableViewController - - (void)editButtonPressed { - [super editButtonPressed]; - - if (!self.tableView.editing) { - TableViewModel* model = self.tableViewModel; + if (!self.controller.tableView.editing) { + TableViewModel* model = self.controller.tableViewModel; NSInteger itemCount = [model numberOfItemsInSection: [model sectionForSectionIdentifier:SectionIdentifierFields]]; @@ -161,7 +152,8 @@ for (NSInteger itemIndex = 0; itemIndex < itemCount; ++itemIndex) { NSIndexPath* path = [NSIndexPath indexPathForItem:itemIndex inSection:section]; - NSInteger itemType = [self.tableViewModel itemTypeForIndexPath:path]; + NSInteger itemType = + [self.controller.tableViewModel itemTypeForIndexPath:path]; if (itemType == ItemTypeCountry && self.autofillAccountProfilesUnionViewEnabled) { @@ -182,16 +174,15 @@ } // Reload the model. - [self loadModel]; + [self.controller loadModel]; // Update the cells. - [self reconfigureCellsForItems: - [self.tableViewModel - itemsInSectionWithIdentifier:SectionIdentifierFields]]; + [self.controller reconfigureCellsForItems:[self.controller.tableViewModel + itemsInSectionWithIdentifier: + SectionIdentifierFields]]; } - (void)loadModel { - [super loadModel]; - TableViewModel* model = self.tableViewModel; + TableViewModel* model = self.controller.tableViewModel; [model addSectionWithIdentifier:SectionIdentifierFields]; for (size_t i = 0; i < std::size(kProfileFieldsToDisplay); ++i) { @@ -222,14 +213,11 @@ } } -#pragma mark - UITableViewDataSource - -- (UITableViewCell*)tableView:(UITableView*)tableView - cellForRowAtIndexPath:(NSIndexPath*)indexPath { - UITableViewCell* cell = [super tableView:tableView - cellForRowAtIndexPath:indexPath]; +- (UITableViewCell*)cell:(UITableViewCell*)cell + forRowAtIndexPath:(NSIndexPath*)indexPath { cell.selectionStyle = UITableViewCellSelectionStyleNone; - NSInteger itemType = [self.tableViewModel itemTypeForIndexPath:indexPath]; + NSInteger itemType = + [self.controller.tableViewModel itemTypeForIndexPath:indexPath]; if (itemType == ItemTypeFooter || itemType == ItemTypeError) { return cell; } @@ -250,16 +238,17 @@ return textFieldCell; } -- (void)tableView:(UITableView*)tableView - didSelectRowAtIndexPath:(NSIndexPath*)indexPath { - NSInteger itemType = [self.tableViewModel itemTypeForIndexPath:indexPath]; - if (self.tableView.editing) { +- (void)didSelectRowAtIndexPath:(NSIndexPath*)indexPath { + NSInteger itemType = + [self.controller.tableViewModel itemTypeForIndexPath:indexPath]; + if (self.controller.tableView.editing) { if (self.autofillAccountProfilesUnionViewEnabled && itemType == ItemTypeCountry) { [self.delegate willSelectCountryWithCurrentlySelectedCountry: self.homeAddressCountry]; } else if (itemType != ItemTypeFooter && itemType != ItemTypeError) { - UITableViewCell* cell = [self.tableView cellForRowAtIndexPath:indexPath]; + UITableViewCell* cell = + [self.controller.tableView cellForRowAtIndexPath:indexPath]; TableViewTextEditCell* textFieldCell = base::mac::ObjCCastStrict<TableViewTextEditCell>(cell); [textFieldCell.textField becomeFirstResponder]; @@ -267,32 +256,40 @@ } } -- (CGFloat)tableView:(UITableView*)tableView - heightForHeaderInSection:(NSInteger)section { +- (BOOL)heightForHeaderShouldBeZeroInSection:(NSInteger)section { NSInteger sectionIdentifier = - [self.tableViewModel sectionIdentifierForSectionIndex:section]; + [self.controller.tableViewModel sectionIdentifierForSectionIndex:section]; - if (sectionIdentifier == SectionIdentifierFooter || - sectionIdentifier == SectionIdentifierErrorFooter) { - return 0; - } - return [super tableView:tableView heightForHeaderInSection:section]; + return sectionIdentifier == SectionIdentifierFooter || + sectionIdentifier == SectionIdentifierErrorFooter; } -- (CGFloat)tableView:(UITableView*)tableView - heightForFooterInSection:(NSInteger)section { +- (BOOL)heightForFooterShouldBeZeroInSection:(NSInteger)section { NSInteger sectionIdentifier = - [self.tableViewModel sectionIdentifierForSectionIndex:section]; - if (sectionIdentifier == SectionIdentifierFields) { - return 0; - } - return [super tableView:tableView heightForFooterInSection:section]; + [self.controller.tableViewModel sectionIdentifierForSectionIndex:section]; + + return sectionIdentifier == SectionIdentifierFields; +} + +- (BOOL)canEditRowAtIndexPath:(NSIndexPath*)indexPath { + // If we don't allow the edit of the cell, the selection of the cell isn't + // forwarded. + return YES; +} + +- (UITableViewCellEditingStyle)editingStyleForRowAtIndexPath: + (NSIndexPath*)indexPath { + return UITableViewCellEditingStyleNone; +} + +- (BOOL)shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath*)indexPath { + return NO; } #pragma mark - TableViewTextEditItemDelegate - (void)tableViewItemDidBeginEditing:(TableViewTextEditItem*)tableViewItem { - [self reconfigureCellsForItems:@[ tableViewItem ]]; + [self.controller reconfigureCellsForItems:@[ tableViewItem ]]; } - (void)tableViewItemDidChange:(TableViewTextEditItem*)tableViewItem { @@ -300,30 +297,11 @@ [self computeErrorIfRequiredTextField:tableViewItem]; [self updateDoneButtonStatus]; } - [self reconfigureCellsForItems:@[ tableViewItem ]]; + [self.controller reconfigureCellsForItems:@[ tableViewItem ]]; } - (void)tableViewItemDidEndEditing:(TableViewTextEditItem*)tableViewItem { - [self reconfigureCellsForItems:@[ tableViewItem ]]; -} - -#pragma mark - UITableViewDelegate - -- (BOOL)tableView:(UITableView*)tableView - canEditRowAtIndexPath:(NSIndexPath*)indexPath { - // If we don't allow the edit of the cell, the selection of the cell isn't - // forwarded. - return YES; -} - -- (UITableViewCellEditingStyle)tableView:(UITableView*)tableView - editingStyleForRowAtIndexPath:(NSIndexPath*)indexPath { - return UITableViewCellEditingStyleNone; -} - -- (BOOL)tableView:(UITableView*)tableview - shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath*)indexPath { - return NO; + [self.controller reconfigureCellsForItems:@[ tableViewItem ]]; } #pragma mark - AutofillProfileEditConsumer @@ -333,7 +311,7 @@ self.homeAddressCountry = country; [self.requiredFieldsWithEmptyValue removeAllObjects]; - for (TableViewItem* item in [self.tableViewModel + for (TableViewItem* item in [self.controller.tableViewModel itemsInSectionWithIdentifier:SectionIdentifierFields]) { if (item.type == ItemTypeCountry) { TableViewMultiDetailTextItem* multiDetailTextItem = @@ -344,7 +322,7 @@ base::mac::ObjCCastStrict<TableViewTextEditItem>(item); [self computeErrorIfRequiredTextField:tableViewTextEditItem]; } - [self reconfigureCellsForItems:@[ item ]]; + [self.controller reconfigureCellsForItems:@[ item ]]; } [self updateDoneButtonStatus]; @@ -541,20 +519,21 @@ // Removes the given section if it exists. - (void)removeSectionWithIdentifier:(NSInteger)sectionIdentifier withRowAnimation:(UITableViewRowAnimation)animation { - TableViewModel* model = self.tableViewModel; + TableViewModel* model = self.controller.tableViewModel; if ([model hasSectionForSectionIdentifier:sectionIdentifier]) { NSInteger section = [model sectionForSectionIdentifier:sectionIdentifier]; [model removeSectionWithIdentifier:sectionIdentifier]; - [[self tableView] deleteSections:[NSIndexSet indexSetWithIndex:section] - withRowAnimation:animation]; + [[self.controller tableView] + deleteSections:[NSIndexSet indexSetWithIndex:section] + withRowAnimation:animation]; } } // If the error status has changed, displays the footer accordingly. - (void)changeFooterStatusToRemoveSection:(SectionIdentifier)removeSection addSection:(SectionIdentifier)addSection { - TableViewModel* model = self.tableViewModel; - [self + TableViewModel* model = self.controller.tableViewModel; + [self.controller performBatchTableViewUpdates:^{ [self removeSectionWithIdentifier:removeSection withRowAnimation:UITableViewRowAnimationTop]; @@ -562,15 +541,16 @@ [model sectionForSectionIdentifier:SectionIdentifierFields]; [model insertSectionWithIdentifier:addSection atIndex:fieldsSectionIndex + 1]; - [self.tableView + [self.controller.tableView insertSections:[NSIndexSet indexSetWithIndex:fieldsSectionIndex + 1] withRowAnimation:UITableViewRowAnimationTop]; - [self.tableViewModel setFooter:(([self.requiredFieldsWithEmptyValue - count] > 0) - ? [self errorMessageItem] - : [self footerItem]) - forSectionWithIdentifier:addSection]; + [self.controller.tableViewModel + setFooter:(([self.requiredFieldsWithEmptyValue + count] > 0) + ? [self errorMessageItem] + : [self footerItem]) + forSectionWithIdentifier:addSection]; } completion:nil]; } @@ -579,7 +559,7 @@ // and shows/removes the error footer if required. - (void)updateDoneButtonStatus { BOOL shouldShowError = ([self.requiredFieldsWithEmptyValue count] > 0); - self.navigationItem.rightBarButtonItem.enabled = !shouldShowError; + self.controller.navigationItem.rightBarButtonItem.enabled = !shouldShowError; if (shouldShowError != self.errorSectionPresented) { SectionIdentifier addSection = shouldShowError ? SectionIdentifierErrorFooter @@ -599,7 +579,7 @@ // Returns YES, if the error message needs to be changed. This happens when // there are multiple required fields that become empty. - (BOOL)shouldChangeErrorMessage { - TableViewHeaderFooterItem* currentFooter = [self.tableViewModel + TableViewHeaderFooterItem* currentFooter = [self.controller.tableViewModel footerForSectionWithIdentifier:SectionIdentifierErrorFooter]; TableViewAttributedStringHeaderFooterItem* attributedFooterItem = base::mac::ObjCCastStrict<TableViewAttributedStringHeaderFooterItem>( @@ -674,8 +654,8 @@ item.fieldNameLabelText = l10n_util::GetNSString(field.displayStringID); item.textFieldValue = [self valueForAutofillUIType:autofillUIType]; item.autofillUIType = autofillUIType; - item.textFieldEnabled = self.tableView.editing; - item.hideIcon = !self.tableView.editing; + item.textFieldEnabled = self.controller.tableView.editing; + item.hideIcon = !self.controller.tableView.editing; item.autoCapitalizationType = field.autoCapitalizationType; item.returnKeyType = field.returnKeyType; item.keyboardType = field.keyboardType; @@ -690,7 +670,7 @@ item.text = l10n_util::GetNSString(IDS_IOS_AUTOFILL_COUNTRY); item.trailingDetailText = self.homeAddressCountry; item.trailingDetailTextColor = [UIColor colorNamed:kTextPrimaryColor]; - if (self.tableView.editing) { + if (self.controller.tableView.editing) { item.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator; } return item;
diff --git a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller_delegate.h b/ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller_delegate.h similarity index 79% rename from ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller_delegate.h rename to ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller_delegate.h index c61334b..bbe44fa 100644 --- a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller_delegate.h +++ b/ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller_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 IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_DELEGATE_H_ -#define IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_DELEGATE_H_ +#ifndef IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_DELEGATE_H_ +#define IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_DELEGATE_H_ #import "components/autofill/core/browser/field_types.h" #import "ios/chrome/browser/ui/autofill/autofill_ui_type.h" @@ -35,4 +35,4 @@ @end -#endif // IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_DELEGATE_H_ +#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_DELEGATE_H_
diff --git a/ios/chrome/browser/ui/autofill/cells/BUILD.gn b/ios/chrome/browser/ui/autofill/cells/BUILD.gn index b990513..e45d4055 100644 --- a/ios/chrome/browser/ui/autofill/cells/BUILD.gn +++ b/ios/chrome/browser/ui/autofill/cells/BUILD.gn
@@ -6,6 +6,8 @@ sources = [ "autofill_edit_item.h", "autofill_edit_item.mm", + "country_item.h", + "country_item.mm", "cvc_header_item.h", "cvc_header_item.mm", "expiration_date_edit_item+private.h",
diff --git a/ios/chrome/browser/ui/settings/autofill/cells/country_item.h b/ios/chrome/browser/ui/autofill/cells/country_item.h similarity index 65% rename from ios/chrome/browser/ui/settings/autofill/cells/country_item.h rename to ios/chrome/browser/ui/autofill/cells/country_item.h index 14da597..3ef25ea 100644 --- a/ios/chrome/browser/ui/settings/autofill/cells/country_item.h +++ b/ios/chrome/browser/ui/autofill/cells/country_item.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 IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_CELLS_COUNTRY_ITEM_H_ -#define IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_CELLS_COUNTRY_ITEM_H_ +#ifndef IOS_CHROME_BROWSER_UI_AUTOFILL_CELLS_COUNTRY_ITEM_H_ +#define IOS_CHROME_BROWSER_UI_AUTOFILL_CELLS_COUNTRY_ITEM_H_ #import "ios/chrome/browser/shared/ui/table_view/cells/table_view_detail_text_item.h" @@ -15,4 +15,4 @@ @end -#endif // IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_CELLS_COUNTRY_ITEM_H_ +#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_CELLS_COUNTRY_ITEM_H_
diff --git a/ios/chrome/browser/ui/settings/autofill/cells/country_item.mm b/ios/chrome/browser/ui/autofill/cells/country_item.mm similarity index 79% rename from ios/chrome/browser/ui/settings/autofill/cells/country_item.mm rename to ios/chrome/browser/ui/autofill/cells/country_item.mm index c0c5bf70..d31fab9 100644 --- a/ios/chrome/browser/ui/settings/autofill/cells/country_item.mm +++ b/ios/chrome/browser/ui/autofill/cells/country_item.mm
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "ios/chrome/browser/ui/settings/autofill/cells/country_item.h" +#import "ios/chrome/browser/ui/autofill/cells/country_item.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support."
diff --git a/ios/chrome/browser/ui/bookmarks/BUILD.gn b/ios/chrome/browser/ui/bookmarks/BUILD.gn index c5cf0a58..7d0ddec8 100644 --- a/ios/chrome/browser/ui/bookmarks/BUILD.gn +++ b/ios/chrome/browser/ui/bookmarks/BUILD.gn
@@ -174,6 +174,7 @@ testonly = true sources = [ "bookmarks_accessibility_egtest.mm", + "bookmarks_account_storage_promo_egtest.mm", "bookmarks_egtest.mm", "bookmarks_entries_egtest.mm", "bookmarks_promo_egtest.mm", @@ -184,7 +185,9 @@ ":constants", ":eg_test_support+eg2", "//base/test:test_support", + "//components/bookmarks/common", "//components/policy:generated", + "//components/signin/public/base", "//components/strings", "//components/url_formatter", "//ios/chrome/app/strings",
diff --git a/ios/chrome/browser/ui/bookmarks/bookmarks_account_storage_promo_egtest.mm b/ios/chrome/browser/ui/bookmarks/bookmarks_account_storage_promo_egtest.mm new file mode 100644 index 0000000..054944c --- /dev/null +++ b/ios/chrome/browser/ui/bookmarks/bookmarks_account_storage_promo_egtest.mm
@@ -0,0 +1,87 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import <UIKit/UIKit.h> +#import <XCTest/XCTest.h> + +#import "base/ios/ios_util.h" +#import "components/bookmarks/common/bookmark_features.h" +#import "components/signin/public/base/consent_level.h" +#import "ios/chrome/browser/signin/fake_system_identity.h" +#import "ios/chrome/browser/ui/authentication/signin/signin_constants.h" +#import "ios/chrome/browser/ui/authentication/signin_earl_grey.h" +#import "ios/chrome/browser/ui/authentication/signin_earl_grey_ui_test_util.h" +#import "ios/chrome/browser/ui/authentication/signin_matchers.h" +#import "ios/chrome/browser/ui/bookmarks/bookmark_earl_grey.h" +#import "ios/chrome/browser/ui/bookmarks/bookmark_earl_grey_ui.h" +#import "ios/chrome/browser/ui/bookmarks/bookmark_ui_constants.h" +#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" +#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" +#import "ios/chrome/test/earl_grey/chrome_matchers.h" +#import "ios/chrome/test/earl_grey/web_http_server_chrome_test_case.h" +#import "ios/testing/earl_grey/earl_grey_test.h" + +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + +using chrome_test_util::BookmarksHomeDoneButton; +using chrome_test_util::BookmarksNavigationBarBackButton; +using chrome_test_util::IdentityCellMatcherForEmail; +using chrome_test_util::PrimarySignInButton; +using chrome_test_util::SecondarySignInButton; + +// Bookmark promo integration tests for Chrome with +// kEnableBookmarksAccountStorage enabled. +@interface BookmarksAccountStoragePromoTestCase : WebHttpServerChromeTestCase +@end + +@implementation BookmarksAccountStoragePromoTestCase + +- (AppLaunchConfiguration)appConfigurationForTestCase { + AppLaunchConfiguration config; + config.features_enabled.push_back(bookmarks::kEnableBookmarksAccountStorage); + return config; +} + +- (void)setUp { + [super setUp]; + [ChromeEarlGrey waitForBookmarksToFinishLoading]; + [ChromeEarlGrey clearBookmarks]; +} + +// Tear down called once per test. +- (void)tearDown { + [super tearDown]; + [ChromeEarlGrey clearBookmarks]; + [BookmarkEarlGrey clearBookmarksPositionCache]; +} + +#pragma mark - BookmarksAccountStoragePromoTestCase Tests + +// Tests to sign-in with one identity, sign-out, and use the sign-in promo +// from bookmark to sign-in with a different identity. +// See http://crbug.com/1428495. +- (void)testSignInPromoAfterSignOut { + FakeSystemIdentity* fakeIdentity1 = [FakeSystemIdentity fakeIdentity1]; + // Sign-in+sync with identity1. + [SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity1 enableSync:YES]; + [SigninEarlGrey signOut]; + [SigninEarlGrey forgetFakeIdentity:fakeIdentity1]; + // Sign-in with bookmark account storage with identity2. + FakeSystemIdentity* fakeIdentity2 = [FakeSystemIdentity fakeIdentity2]; + [SigninEarlGrey addFakeIdentity:fakeIdentity2]; + [BookmarkEarlGreyUI openBookmarks]; + [SigninEarlGreyUI + verifySigninPromoVisibleWithMode:SigninPromoViewModeSigninWithAccount]; + [[EarlGrey + selectElementWithMatcher:grey_allOf(PrimarySignInButton(), + grey_sufficientlyVisible(), nil)] + performAction:grey_tap()]; + // Result: the sign-in is successful without any issue. + [SigninEarlGrey verifyPrimaryAccountWithEmail:fakeIdentity2.userEmail + consent:signin::ConsentLevel::kSignin]; +} + +@end
diff --git a/ios/chrome/browser/ui/browser_container/BUILD.gn b/ios/chrome/browser/ui/browser_container/BUILD.gn index 5551230..a1b54dd 100644 --- a/ios/chrome/browser/ui/browser_container/BUILD.gn +++ b/ios/chrome/browser/ui/browser_container/BUILD.gn
@@ -29,6 +29,7 @@ "//ios/chrome/browser/shared/public/commands", "//ios/chrome/browser/shared/public/features", "//ios/chrome/browser/ui/alert_coordinator", + "//ios/chrome/browser/ui/fullscreen", "//ios/chrome/browser/ui/link_to_text", "//ios/chrome/browser/ui/overlays", "//ios/chrome/browser/ui/partial_translate",
diff --git a/ios/chrome/browser/ui/browser_container/browser_container_coordinator.mm b/ios/chrome/browser/ui/browser_container/browser_container_coordinator.mm index 4a67160..4d6bfa3 100644 --- a/ios/chrome/browser/ui/browser_container/browser_container_coordinator.mm +++ b/ios/chrome/browser/ui/browser_container/browser_container_coordinator.mm
@@ -21,6 +21,7 @@ #import "ios/chrome/browser/ui/browser_container/browser_container_view_controller.h" #import "ios/chrome/browser/ui/browser_container/browser_edit_menu_handler.h" #import "ios/chrome/browser/ui/browser_container/edit_menu_alert_delegate.h" +#import "ios/chrome/browser/ui/fullscreen/fullscreen_controller.h" #import "ios/chrome/browser/ui/link_to_text/link_to_text_mediator.h" #import "ios/chrome/browser/ui/overlays/overlay_container_coordinator.h" #import "ios/chrome/browser/ui/partial_translate/partial_translate_mediator.h" @@ -94,11 +95,14 @@ if (base::FeatureList::IsEnabled(kIOSEditMenuPartialTranslate)) { PrefService* prefService = browserState->GetOriginalChromeBrowserState()->GetPrefs(); + FullscreenController* fullscreenController = + FullscreenController::FromBrowser(self.browser); self.partialTranslateMediator = [[PartialTranslateMediator alloc] initWithWebStateList:webStateList->AsWeakPtr() withBaseViewController:self.viewController prefService:prefService + fullscreenController:fullscreenController incognito:incognito]; self.partialTranslateMediator.alertDelegate = self; CommandDispatcher* dispatcher = browser->GetCommandDispatcher();
diff --git a/ios/chrome/browser/ui/follow/first_follow_view_controller.mm b/ios/chrome/browser/ui/follow/first_follow_view_controller.mm index ab02f562..aea4a93 100644 --- a/ios/chrome/browser/ui/follow/first_follow_view_controller.mm +++ b/ios/chrome/browser/ui/follow/first_follow_view_controller.mm
@@ -35,7 +35,7 @@ - (instancetype)initWithTitle:(NSString*)title active:(BOOL)active faviconSource:(FirstFollowFaviconSource)faviconSource { - if ((self = [super initWithNibName:nil bundle:nil])) { + if ((self = [super init])) { _webSiteTitle = base::SysNSStringToUTF16(title); _webSiteHasActiveContent = active; _faviconSource = faviconSource;
diff --git a/ios/chrome/browser/ui/partial_translate/BUILD.gn b/ios/chrome/browser/ui/partial_translate/BUILD.gn index 8cb9e3c6..5505ae5 100644 --- a/ios/chrome/browser/ui/partial_translate/BUILD.gn +++ b/ios/chrome/browser/ui/partial_translate/BUILD.gn
@@ -16,6 +16,7 @@ "//ios/chrome/browser/shared/public/commands", "//ios/chrome/browser/shared/public/features", "//ios/chrome/browser/ui/browser_container:edit_menu_alert_delegate", + "//ios/chrome/browser/ui/fullscreen", "//ios/chrome/browser/web_selection", "//ios/chrome/browser/web_state_list", "//ios/public/provider/chrome/browser/partial_translate:partial_translate_api", @@ -79,6 +80,7 @@ "//ios/chrome/app/strings", "//ios/chrome/browser/browser_state", "//ios/chrome/browser/main:public", + "//ios/chrome/browser/ui/fullscreen", "//ios/chrome/browser/web_state_list", "//ios/chrome/test/app:test_support", "//ios/testing/earl_grey:eg_app_support+eg2",
diff --git a/ios/chrome/browser/ui/partial_translate/partial_translate_app_interface.mm b/ios/chrome/browser/ui/partial_translate/partial_translate_app_interface.mm index c9a1b9fa..db84d84e 100644 --- a/ios/chrome/browser/ui/partial_translate/partial_translate_app_interface.mm +++ b/ios/chrome/browser/ui/partial_translate/partial_translate_app_interface.mm
@@ -6,6 +6,7 @@ #import "ios/chrome/browser/browser_state/chrome_browser_state.h" #import "ios/chrome/browser/main/browser.h" +#import "ios/chrome/browser/ui/fullscreen/fullscreen_controller.h" #import "ios/chrome/browser/ui/partial_translate/partial_translate_mediator.h" #import "ios/chrome/browser/web_state_list/web_state_list.h" #import "ios/chrome/test/app/chrome_test_util.h" @@ -30,12 +31,15 @@ chrome_test_util::GetActiveViewController(); Browser* browser = chrome_test_util::GetMainBrowser(); WebStateList* webStateList = browser ? browser->GetWebStateList() : nullptr; + FullscreenController* fullscreenController = + FullscreenController::FromBrowser(browser); PartialTranslateMediator* partialTranslateMediator = [[PartialTranslateMediator alloc] initWithWebStateList:webStateList->AsWeakPtr() withBaseViewController:viewController prefService:prefService + fullscreenController:fullscreenController incognito:incognito]; BOOL shouldInstallPartialTranslate = [partialTranslateMediator shouldInstallPartialTranslate];
diff --git a/ios/chrome/browser/ui/partial_translate/partial_translate_mediator.h b/ios/chrome/browser/ui/partial_translate/partial_translate_mediator.h index 937e298..e3a2673 100644 --- a/ios/chrome/browser/ui/partial_translate/partial_translate_mediator.h +++ b/ios/chrome/browser/ui/partial_translate/partial_translate_mediator.h
@@ -12,6 +12,7 @@ @protocol BrowserCoordinatorCommands; @protocol EditMenuAlertDelegate; +class FullscreenController; class PrefService; class WebStateList; @@ -25,6 +26,7 @@ - (instancetype)initWithWebStateList:(base::WeakPtr<WebStateList>)webStateList withBaseViewController:(UIViewController*)baseViewController prefService:(PrefService*)prefs + fullscreenController:(FullscreenController*)fullscreenController incognito:(BOOL)incognito NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_UNAVAILABLE;
diff --git a/ios/chrome/browser/ui/partial_translate/partial_translate_mediator.mm b/ios/chrome/browser/ui/partial_translate/partial_translate_mediator.mm index a5ed6a1..da8d694 100644 --- a/ios/chrome/browser/ui/partial_translate/partial_translate_mediator.mm +++ b/ios/chrome/browser/ui/partial_translate/partial_translate_mediator.mm
@@ -11,6 +11,7 @@ #import "ios/chrome/browser/shared/public/commands/browser_coordinator_commands.h" #import "ios/chrome/browser/shared/public/features/features.h" #import "ios/chrome/browser/ui/browser_container/edit_menu_alert_delegate.h" +#import "ios/chrome/browser/ui/fullscreen/fullscreen_controller.h" #import "ios/chrome/browser/web_selection/web_selection_response.h" #import "ios/chrome/browser/web_selection/web_selection_tab_helper.h" #import "ios/chrome/browser/web_state_list/web_state_list.h" @@ -97,17 +98,23 @@ // The Browser's WebStateList. base::WeakPtr<WebStateList> _webStateList; + + // The fullscreen controller to offset sourceRect depending on fullscreen + // status. + FullscreenController* _fullscreenController; } - (instancetype)initWithWebStateList:(base::WeakPtr<WebStateList>)webStateList withBaseViewController:(UIViewController*)baseViewController prefService:(PrefService*)prefs + fullscreenController:(FullscreenController*)fullscreenController incognito:(BOOL)incognito { if (self = [super init]) { DCHECK(webStateList); DCHECK(baseViewController); _webStateList = webStateList; _baseViewController = baseViewController; + _fullscreenController = fullscreenController; _incognito = incognito; _translateEnabled.Init(translate::prefs::kOfferTranslateEnabled, prefs); } @@ -116,6 +123,7 @@ - (void)shutdown { _translateEnabled.Destroy(); + _fullscreenController = nullptr; } - (void)handlePartialTranslateSelection { @@ -219,16 +227,26 @@ return [self switchToFullTranslateWithError:PartialTranslateError:: kSelectionTooLong]; } - if ([[response.selectedText + if (!response.valid || + [[response.selectedText stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] == 0u) { return [self switchToFullTranslateWithError:PartialTranslateError::kSelectionEmpty]; } - __weak __typeof(self) weakSelf = self; + + CGRect sourceRect = response.sourceRect; + if (_fullscreenController && !CGRectEqualToRect(sourceRect, CGRectZero)) { + UIEdgeInsets fullscreenInset = + _fullscreenController->GetCurrentViewportInsets(); + sourceRect.origin.y += fullscreenInset.top; + sourceRect.origin.x += fullscreenInset.left; + } + self.controller = ios::provider::NewPartialTranslateController( - response.selectedText, response.sourceRect, self.incognito); + response.selectedText, sourceRect, self.incognito); + __weak __typeof(self) weakSelf = self; [self.controller presentOnViewController:self.baseViewController flowCompletionHandler:^(BOOL success) {
diff --git a/ios/chrome/browser/ui/partial_translate/partial_translate_mediator_unittest.mm b/ios/chrome/browser/ui/partial_translate/partial_translate_mediator_unittest.mm index 4e8f7afe..414c6b1 100644 --- a/ios/chrome/browser/ui/partial_translate/partial_translate_mediator_unittest.mm +++ b/ios/chrome/browser/ui/partial_translate/partial_translate_mediator_unittest.mm
@@ -167,6 +167,7 @@ initWithWebStateList:web_state_list_.AsWeakPtr() withBaseViewController:base_view_controller_ prefService:browser_state_->GetSyncablePrefs() + fullscreenController:nullptr incognito:NO]; mediator_.alertDelegate = fake_alert_controller_; mediator_.browserHandler = mock_browser_coordinator_commands_handler_; @@ -247,6 +248,7 @@ initWithWebStateList:web_state_list_.AsWeakPtr() withBaseViewController:base_view_controller_ prefService:browser_state_->GetSyncablePrefs() + fullscreenController:nullptr incognito:YES]; base::HistogramTester histogram_tester; LoadPageAndSelectSize(10); @@ -273,6 +275,7 @@ initWithWebStateList:web_state_list_.AsWeakPtr() withBaseViewController:base_view_controller_ prefService:browser_state_->GetSyncablePrefs() + fullscreenController:nullptr incognito:YES]; EXPECT_FALSE([mediator shouldInstallPartialTranslate]); }
diff --git a/ios/chrome/browser/ui/passwords/account_storage_notice/passwords_account_storage_notice_view_controller.h b/ios/chrome/browser/ui/passwords/account_storage_notice/passwords_account_storage_notice_view_controller.h index 53d4ebb..b3a694e 100644 --- a/ios/chrome/browser/ui/passwords/account_storage_notice/passwords_account_storage_notice_view_controller.h +++ b/ios/chrome/browser/ui/passwords/account_storage_notice/passwords_account_storage_notice_view_controller.h
@@ -34,6 +34,7 @@ (id<PasswordsAccountStorageNoticeActionHandler>)actionHandler NS_DESIGNATED_INITIALIZER; +- (instancetype)init NS_UNAVAILABLE; - (instancetype)initWithNibName:(NSString*)name bundle:(NSBundle*)bundle NS_UNAVAILABLE; - (instancetype)initWithCoder:(NSCoder*)coder NS_UNAVAILABLE;
diff --git a/ios/chrome/browser/ui/passwords/account_storage_notice/passwords_account_storage_notice_view_controller.mm b/ios/chrome/browser/ui/passwords/account_storage_notice/passwords_account_storage_notice_view_controller.mm index 546e118..5cb0a1e 100644 --- a/ios/chrome/browser/ui/passwords/account_storage_notice/passwords_account_storage_notice_view_controller.mm +++ b/ios/chrome/browser/ui/passwords/account_storage_notice/passwords_account_storage_notice_view_controller.mm
@@ -27,7 +27,7 @@ - (instancetype)initWithActionHandler: (id<PasswordsAccountStorageNoticeActionHandler>)actionHandler { - self = [super initWithNibName:nil bundle:nil]; + self = [super init]; if (!self) { return nil; }
diff --git a/ios/chrome/browser/ui/passwords/password_suggestion_view_controller.mm b/ios/chrome/browser/ui/passwords/password_suggestion_view_controller.mm index 1fe29cf..9c12144 100644 --- a/ios/chrome/browser/ui/passwords/password_suggestion_view_controller.mm +++ b/ios/chrome/browser/ui/passwords/password_suggestion_view_controller.mm
@@ -38,7 +38,7 @@ - (instancetype)initWithPasswordSuggestion:(NSString*)passwordSuggestion userEmail:(NSString*)userEmail { - if (self = [super initWithNibName:nil bundle:nil]) { + if (self = [super init]) { _userEmail = userEmail; _passwordSuggestion = passwordSuggestion; }
diff --git a/ios/chrome/browser/ui/policy/user_policy/user_policy_prompt_view_controller.mm b/ios/chrome/browser/ui/policy/user_policy/user_policy_prompt_view_controller.mm index 6865c0b..0b08b823 100644 --- a/ios/chrome/browser/ui/policy/user_policy/user_policy_prompt_view_controller.mm +++ b/ios/chrome/browser/ui/policy/user_policy/user_policy_prompt_view_controller.mm
@@ -25,7 +25,7 @@ @implementation UserPolicyPromptViewController - (instancetype)initWithManagedDomain:(NSString*)managedDomain { - if (self = [super initWithNibName:nil bundle:nil]) { + if (self = [super init]) { self.titleString = l10n_util::GetNSString(IDS_IOS_USER_POLICY_NOTIFICATION_TITLE); self.subtitleString =
diff --git a/ios/chrome/browser/ui/settings/autofill/BUILD.gn b/ios/chrome/browser/ui/settings/autofill/BUILD.gn index 29fb424..dfa6f853 100644 --- a/ios/chrome/browser/ui/settings/autofill/BUILD.gn +++ b/ios/chrome/browser/ui/settings/autofill/BUILD.gn
@@ -13,8 +13,6 @@ "autofill_add_credit_card_view_controller.h", "autofill_add_credit_card_view_controller.mm", "autofill_add_credit_card_view_controller_delegate.h", - "autofill_country_selection_table_view_controller.h", - "autofill_country_selection_table_view_controller.mm", "autofill_credit_card_edit_table_view_controller.h", "autofill_credit_card_edit_table_view_controller.mm", "autofill_credit_card_table_view_controller.h", @@ -24,17 +22,12 @@ "autofill_edit_table_view_controller+protected.h", "autofill_edit_table_view_controller.h", "autofill_edit_table_view_controller.mm", - "autofill_profile_edit_consumer.h", "autofill_profile_edit_coordinator.h", "autofill_profile_edit_coordinator.mm", - "autofill_profile_edit_mediator.h", - "autofill_profile_edit_mediator.mm", - "autofill_profile_edit_mediator_delegate.h", - "autofill_profile_edit_table_view_controller.h", - "autofill_profile_edit_table_view_controller.mm", - "autofill_profile_edit_table_view_controller_delegate.h", "autofill_profile_table_view_controller.h", "autofill_profile_table_view_controller.mm", + "autofill_settings_profile_edit_table_view_controller.h", + "autofill_settings_profile_edit_table_view_controller.mm", ] deps = [ ":constants", @@ -53,7 +46,6 @@ "//ios/chrome/browser/shared/coordinator/chrome_coordinator", "//ios/chrome/browser/shared/public/commands", "//ios/chrome/browser/shared/public/features", - "//ios/chrome/browser/shared/ui/list_model", "//ios/chrome/browser/shared/ui/table_view", "//ios/chrome/browser/shared/ui/table_view:utils", "//ios/chrome/browser/shared/ui/table_view/cells", @@ -61,12 +53,10 @@ "//ios/chrome/browser/signin", "//ios/chrome/browser/sync", "//ios/chrome/browser/ui/alert_coordinator", - "//ios/chrome/browser/ui/autofill", + "//ios/chrome/browser/ui/autofill:autofill_shared_ui", "//ios/chrome/browser/ui/autofill:autofill_ui_type", "//ios/chrome/browser/ui/autofill/cells", "//ios/chrome/browser/ui/autofill/form_input_accessory:form_input_accessory", - "//ios/chrome/browser/ui/qr_scanner", - "//ios/chrome/browser/ui/scanner", "//ios/chrome/browser/ui/settings:settings_root", "//ios/chrome/browser/ui/settings:settings_root_categories", "//ios/chrome/browser/ui/settings/autofill/cells", @@ -76,7 +66,6 @@ "//ios/chrome/common/ui/elements:form_input_accessory", "//ios/chrome/common/ui/table_view:cells_constants", "//ios/chrome/common/ui/util", - "//ui/base", ] } @@ -95,9 +84,8 @@ "autofill_add_credit_card_mediator_unittest.mm", "autofill_credit_card_table_view_controller_unittest.mm", "autofill_credit_card_util_unittest.mm", - "autofill_profile_edit_mediator_unittest.mm", - "autofill_profile_edit_table_view_controller_unittest.mm", "autofill_profile_table_view_controller_unittest.mm", + "autofill_settings_profile_edit_table_view_controller_unittest.mm", ] deps = [ ":autofill", @@ -111,11 +99,12 @@ "//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state:test_support", "//ios/chrome/browser/main:test_support", - "//ios/chrome/browser/shared/ui/list_model", "//ios/chrome/browser/shared/ui/table_view", "//ios/chrome/browser/shared/ui/table_view:test_support", + "//ios/chrome/browser/shared/ui/table_view:utils", "//ios/chrome/browser/signin", "//ios/chrome/browser/signin:test_support", + "//ios/chrome/browser/ui/autofill:autofill_shared_ui", "//ios/chrome/browser/ui/settings:settings_root", "//ios/chrome/browser/ui/settings:test_support", "//ios/chrome/browser/ui/settings/autofill/cells",
diff --git a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_coordinator.mm b/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_coordinator.mm index 82672fe..ad53d14 100644 --- a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_coordinator.mm +++ b/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_coordinator.mm
@@ -13,15 +13,17 @@ #import "ios/chrome/browser/autofill/personal_data_manager_factory.h" #import "ios/chrome/browser/browser_state/chrome_browser_state.h" #import "ios/chrome/browser/main/browser.h" +#import "ios/chrome/browser/shared/ui/table_view/table_view_utils.h" #import "ios/chrome/browser/signin/authentication_service.h" #import "ios/chrome/browser/signin/authentication_service_factory.h" #import "ios/chrome/browser/sync/sync_setup_service.h" #import "ios/chrome/browser/sync/sync_setup_service_factory.h" -#import "ios/chrome/browser/ui/settings/autofill/autofill_country_selection_table_view_controller.h" -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator.h" -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_mediator_delegate.h" -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller.h" -#import "ios/chrome/browser/ui/settings/autofill/cells/country_item.h" +#import "ios/chrome/browser/ui/autofill/autofill_country_selection_table_view_controller.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_mediator_delegate.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller.h" +#import "ios/chrome/browser/ui/autofill/cells/country_item.h" +#import "ios/chrome/browser/ui/settings/autofill/autofill_settings_profile_edit_table_view_controller.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -34,7 +36,10 @@ // The view controller attached to this coordinator. @property(nonatomic, strong) - AutofillProfileEditTableViewController* viewController; + AutofillSettingsProfileEditTableViewController* viewController; + +@property(nonatomic, strong) + AutofillProfileEditTableViewController* sharedViewController; // The mediator for the view controller attatched to this coordinator. @property(nonatomic, strong) AutofillProfileEditMediator* mediator; @@ -83,10 +88,14 @@ autofillProfile:&_autofillProfile countryCode:base::SysUTF8ToNSString(countryCode)]; - self.viewController = [[AutofillProfileEditTableViewController alloc] + self.viewController = [[AutofillSettingsProfileEditTableViewController alloc] + initWithStyle:ChromeTableViewStyle()]; + self.sharedViewController = [[AutofillProfileEditTableViewController alloc] initWithDelegate:self.mediator - userEmail:[self syncingUserEmail]]; - self.mediator.consumer = self.viewController; + userEmail:[self syncingUserEmail] + controller:self.viewController]; + self.mediator.consumer = self.sharedViewController; + self.viewController.handler = self.sharedViewController; DCHECK(self.baseNavigationController); [self.baseNavigationController pushViewController:self.viewController @@ -107,6 +116,8 @@ // mediator and view controller should still live. return; } + + self.sharedViewController = nil; self.viewController = nil; self.mediator = nil; [self.delegate
diff --git a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller.h b/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller.h deleted file mode 100644 index 90a0da66..0000000 --- a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller.h +++ /dev/null
@@ -1,27 +0,0 @@ -// Copyright 2015 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_H_ -#define IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_H_ - -#import "ios/chrome/browser/ui/settings/autofill/autofill_edit_table_view_controller.h" -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_consumer.h" - -@protocol AutofillProfileEditTableViewControllerDelegate; - -// The table view for the Autofill profile edit settings. -@interface AutofillProfileEditTableViewController - : AutofillEditTableViewController <AutofillProfileEditConsumer> - -// Initializes a AutofillProfileEditTableViewController with passed delegate, -// `profile` and `userEmail`. -- (instancetype)initWithDelegate: - (id<AutofillProfileEditTableViewControllerDelegate>)delegate - userEmail:(NSString*)userEmail NS_DESIGNATED_INITIALIZER; - -- (instancetype)initWithStyle:(UITableViewStyle)style NS_UNAVAILABLE; - -@end - -#endif // IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_H_
diff --git a/ios/chrome/browser/ui/settings/autofill/autofill_settings_profile_edit_table_view_controller.h b/ios/chrome/browser/ui/settings/autofill/autofill_settings_profile_edit_table_view_controller.h new file mode 100644 index 0000000..a02f567e --- /dev/null +++ b/ios/chrome/browser/ui/settings/autofill/autofill_settings_profile_edit_table_view_controller.h
@@ -0,0 +1,21 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_SETTINGS_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_H_ +#define IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_SETTINGS_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_H_ + +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_handler.h" +#import "ios/chrome/browser/ui/settings/autofill/autofill_edit_table_view_controller.h" + +@protocol AutofillProfileEditTableViewController; + +// The table view for the Autofill profile edit settings. +@interface AutofillSettingsProfileEditTableViewController + : AutofillEditTableViewController + +@property(nonatomic, weak) id<AutofillProfileEditHandler> handler; + +@end + +#endif // IOS_CHROME_BROWSER_UI_SETTINGS_AUTOFILL_AUTOFILL_SETTINGS_PROFILE_EDIT_TABLE_VIEW_CONTROLLER_H_
diff --git a/ios/chrome/browser/ui/settings/autofill/autofill_settings_profile_edit_table_view_controller.mm b/ios/chrome/browser/ui/settings/autofill/autofill_settings_profile_edit_table_view_controller.mm new file mode 100644 index 0000000..205975a --- /dev/null +++ b/ios/chrome/browser/ui/settings/autofill/autofill_settings_profile_edit_table_view_controller.mm
@@ -0,0 +1,94 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "ios/chrome/browser/ui/settings/autofill/autofill_settings_profile_edit_table_view_controller.h" + +#import "ios/chrome/browser/ui/settings/autofill/autofill_constants.h" +#import "ios/chrome/grit/ios_strings.h" +#import "ui/base/l10n/l10n_util.h" + +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + +@implementation AutofillSettingsProfileEditTableViewController + +#pragma mark - Initialization + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setTitle:l10n_util::GetNSString(IDS_IOS_AUTOFILL_EDIT_ADDRESS)]; + self.tableView.allowsSelectionDuringEditing = YES; + self.tableView.accessibilityIdentifier = kAutofillProfileEditTableViewId; + + [self loadModel]; +} + +- (void)viewDidDisappear:(BOOL)animated { + [self.handler viewDidDisappear]; + [super viewDidDisappear:animated]; +} + +- (void)loadModel { + [super loadModel]; + [self.handler loadModel]; +} + +#pragma mark - SettingsRootTableViewController + +- (void)editButtonPressed { + [super editButtonPressed]; + + [self.handler editButtonPressed]; +} + +#pragma mark - UITableViewDataSource + +- (UITableViewCell*)tableView:(UITableView*)tableView + cellForRowAtIndexPath:(NSIndexPath*)indexPath { + UITableViewCell* cell = [super tableView:tableView + cellForRowAtIndexPath:indexPath]; + return [self.handler cell:cell forRowAtIndexPath:indexPath]; +} + +- (void)tableView:(UITableView*)tableView + didSelectRowAtIndexPath:(NSIndexPath*)indexPath { + [self.handler didSelectRowAtIndexPath:indexPath]; +} + +- (CGFloat)tableView:(UITableView*)tableView + heightForHeaderInSection:(NSInteger)section { + if ([self.handler heightForHeaderShouldBeZeroInSection:section]) { + return 0; + } + return [super tableView:tableView heightForHeaderInSection:section]; +} + +- (CGFloat)tableView:(UITableView*)tableView + heightForFooterInSection:(NSInteger)section { + if ([self.handler heightForFooterShouldBeZeroInSection:section]) { + return 0; + } + return [super tableView:tableView heightForFooterInSection:section]; +} + +#pragma mark - UITableViewDelegate + +- (BOOL)tableView:(UITableView*)tableView + canEditRowAtIndexPath:(NSIndexPath*)indexPath { + return [self.handler canEditRowAtIndexPath:indexPath]; +} + +- (UITableViewCellEditingStyle)tableView:(UITableView*)tableView + editingStyleForRowAtIndexPath:(NSIndexPath*)indexPath { + return [self.handler editingStyleForRowAtIndexPath:indexPath]; +} + +- (BOOL)tableView:(UITableView*)tableView + shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath*)indexPath { + return [self.handler shouldIndentWhileEditingRowAtIndexPath:indexPath]; +} + +@end
diff --git a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller_unittest.mm b/ios/chrome/browser/ui/settings/autofill/autofill_settings_profile_edit_table_view_controller_unittest.mm similarity index 69% rename from ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller_unittest.mm rename to ios/chrome/browser/ui/settings/autofill/autofill_settings_profile_edit_table_view_controller_unittest.mm index f928816e..cc6164b 100644 --- a/ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller_unittest.mm +++ b/ios/chrome/browser/ui/settings/autofill/autofill_settings_profile_edit_table_view_controller_unittest.mm
@@ -1,22 +1,26 @@ -// Copyright 2015 The Chromium Authors +// Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller.h" +#import "ios/chrome/browser/ui/settings/autofill/autofill_settings_profile_edit_table_view_controller.h" #import <memory> - #import "base/feature_list.h" #import "base/mac/foundation_util.h" #import "base/strings/sys_string_conversions.h" #import "base/strings/utf_string_conversions.h" #import "base/test/scoped_feature_list.h" #import "components/autofill/core/common/autofill_features.h" +#import "ios/chrome/browser/shared/ui/table_view/cells/table_view_header_footer_item.h" +#import "ios/chrome/browser/shared/ui/table_view/cells/table_view_link_header_footer_item.h" #import "ios/chrome/browser/shared/ui/table_view/cells/table_view_text_edit_item.h" #import "ios/chrome/browser/shared/ui/table_view/chrome_table_view_controller_test.h" #import "ios/chrome/browser/shared/ui/table_view/table_view_model.h" -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_consumer.h" -#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_edit_table_view_controller_delegate.h" +#import "ios/chrome/browser/shared/ui/table_view/table_view_utils.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_consumer.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_handler.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller.h" +#import "ios/chrome/browser/ui/autofill/autofill_profile_edit_table_view_controller_delegate.h" #import "ios/chrome/grit/ios_strings.h" #import "testing/gtest_mac.h" #import "testing/platform_test.h" @@ -90,7 +94,7 @@ namespace { -class AutofillProfileEditTableViewControllerTest +class AutofillSettingsProfileEditTableViewControllerTest : public ChromeTableViewControllerTest { protected: void SetUp() override { @@ -100,26 +104,33 @@ fake_consumer_ = [[AutofillProfileEditFakeConsumer alloc] init]; CreateController(); CheckController(); - fake_consumer_.consumer = - base::mac::ObjCCastStrict<AutofillProfileEditTableViewController>( - controller()); + fake_consumer_.consumer = autofill_profile_edit_table_view_controller_; // Reload the model so that the consumer changes are propogated. [controller() loadModel]; } ChromeTableViewController* InstantiateController() override { - return [[AutofillProfileEditTableViewController alloc] - initWithDelegate:delegate_mock_ - userEmail:nil]; + AutofillSettingsProfileEditTableViewController* viewController = + [[AutofillSettingsProfileEditTableViewController alloc] + initWithStyle:ChromeTableViewStyle()]; + autofill_profile_edit_table_view_controller_ = + [[AutofillProfileEditTableViewController alloc] + initWithDelegate:delegate_mock_ + userEmail:nil + controller:viewController]; + viewController.handler = autofill_profile_edit_table_view_controller_; + return viewController; } AutofillProfileEditFakeConsumer* fake_consumer_; + AutofillProfileEditTableViewController* + autofill_profile_edit_table_view_controller_; id delegate_mock_; }; // Default test case of no addresses or credit cards. -TEST_F(AutofillProfileEditTableViewControllerTest, TestInitialization) { +TEST_F(AutofillSettingsProfileEditTableViewControllerTest, TestInitialization) { TableViewModel* model = [controller() tableViewModel]; int rowCnt = base::FeatureList::IsEnabled( @@ -132,7 +143,7 @@ } // Adding a single address results in an address section. -TEST_F(AutofillProfileEditTableViewControllerTest, TestOneProfile) { +TEST_F(AutofillSettingsProfileEditTableViewControllerTest, TestOneProfile) { TableViewModel* model = [controller() tableViewModel]; // UITableView* tableView = [autofill_profile_edit_controller_ tableView]; @@ -156,27 +167,34 @@ } } -class AutofillProfileEditTableViewControllerTestWithUnionViewEnabled - : public AutofillProfileEditTableViewControllerTest { +class AutofillSettingsProfileEditTableViewControllerTestWithUnionViewEnabled + : public AutofillSettingsProfileEditTableViewControllerTest { protected: - AutofillProfileEditTableViewControllerTestWithUnionViewEnabled() { + AutofillSettingsProfileEditTableViewControllerTestWithUnionViewEnabled() { scoped_feature_list_.InitAndEnableFeature( autofill::features::kAutofillAccountProfilesUnionView); } ChromeTableViewController* InstantiateController() override { - return [[AutofillProfileEditTableViewController alloc] - initWithDelegate:delegate_mock_ - userEmail:base::SysUTF16ToNSString(kTestEmail)]; + AutofillSettingsProfileEditTableViewController* viewController = + [[AutofillSettingsProfileEditTableViewController alloc] + initWithStyle:ChromeTableViewStyle()]; + autofill_profile_edit_table_view_controller_ = + [[AutofillProfileEditTableViewController alloc] + initWithDelegate:delegate_mock_ + userEmail:base::SysUTF16ToNSString(kTestEmail) + controller:viewController]; + viewController.handler = autofill_profile_edit_table_view_controller_; + return viewController; } base::test::ScopedFeatureList scoped_feature_list_; }; // Tests the footer text of the view controller for the address profiles with -// source kAccount when `autofill::features::kAutofillAccountProfilesUnionView` -// is enabled. -TEST_F(AutofillProfileEditTableViewControllerTestWithUnionViewEnabled, +// source kAccount when +//`autofill::features::kAutofillAccountProfilesUnionView` / is enabled. +TEST_F(AutofillSettingsProfileEditTableViewControllerTestWithUnionViewEnabled, TestFooterTextWithEmail) { [fake_consumer_ createAccountProfile];
diff --git a/ios/chrome/browser/ui/settings/autofill/cells/BUILD.gn b/ios/chrome/browser/ui/settings/autofill/cells/BUILD.gn index 80d3abb..161cc9df 100644 --- a/ios/chrome/browser/ui/settings/autofill/cells/BUILD.gn +++ b/ios/chrome/browser/ui/settings/autofill/cells/BUILD.gn
@@ -9,8 +9,6 @@ "autofill_card_item.mm", "autofill_profile_item.h", "autofill_profile_item.mm", - "country_item.h", - "country_item.mm", ] deps = [
diff --git a/ios/chrome/browser/ui/spotlight_debugger/spotlight_debugger_view_controller.mm b/ios/chrome/browser/ui/spotlight_debugger/spotlight_debugger_view_controller.mm index c2a322c91..dd6a4e1 100644 --- a/ios/chrome/browser/ui/spotlight_debugger/spotlight_debugger_view_controller.mm +++ b/ios/chrome/browser/ui/spotlight_debugger/spotlight_debugger_view_controller.mm
@@ -9,6 +9,7 @@ #import "base/time/time.h" #import "ios/chrome/app/spotlight/bookmarks_spotlight_manager.h" #import "ios/chrome/app/spotlight/reading_list_spotlight_manager.h" +#import "ios/chrome/app/spotlight/spotlight_interface.h" #import "ios/chrome/app/spotlight/spotlight_logger.h" #import "ios/chrome/app/spotlight/spotlight_util.h" #import "ios/chrome/browser/shared/ui/table_view/table_view_navigation_controller.h" @@ -47,6 +48,8 @@ @property(nonatomic, strong) UIActivityIndicatorView* spinner; +@property(nonatomic, readonly) SpotlightInterface* spotlightInterface; + @end @implementation SpotlightDebuggerViewController @@ -57,6 +60,7 @@ _spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge]; _spinner.translatesAutoresizingMaskIntoConstraints = NO; + _spotlightInterface = [SpotlightInterface defaultInterface]; } return self; } @@ -210,7 +214,8 @@ - (void)clearAllSpotlightEntries { [self showSpinner]; - spotlight::ClearSpotlightIndexWithCompletion(^(NSError* error) { + [self.spotlightInterface deleteAllSearchableItemsWithCompletionHandler:^( + NSError* error) { dispatch_async(dispatch_get_main_queue(), ^{ UIAlertController* controller = [UIAlertController alertControllerWithTitle:@"Clear Entries" @@ -226,7 +231,7 @@ [self removeSpinner]; [self.tableView reloadData]; }); - }); + }]; } - (void)clearAndReindexBookmarks {
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/pinned_tabs/pinned_tabs_layout.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/pinned_tabs/pinned_tabs_layout.mm index fa832c5..fe6b433 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/pinned_tabs/pinned_tabs_layout.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/pinned_tabs/pinned_tabs_layout.mm
@@ -10,6 +10,13 @@ #error "This file requires ARC support." #endif +namespace { + +// Initial scale for items being inserted in the collection view. +const CGFloat kInsertedItemInitialScale = 0.01f; + +} // namespace + @implementation PinnedTabsLayout - (instancetype)init { @@ -56,4 +63,27 @@ return YES; } +- (UICollectionViewLayoutAttributes*) + initialLayoutAttributesForAppearingItemAtIndexPath: + (NSIndexPath*)itemIndexPath { + // Note that this method is called for any item whose index path is becoming + // `itemIndexPath`, which includes any items that were in the layout but whose + // index path is changing. For an item whose index path is changing, this + // method is called after + // -finalLayoutAttributesForDisappearingItemAtIndexPath: + UICollectionViewLayoutAttributes* attributes = [[super + initialLayoutAttributesForAppearingItemAtIndexPath:itemIndexPath] copy]; + // Appearing items that aren't being inserted just use the default + // attributes. + if (![self.indexPathsOfInsertingItems containsObject:itemIndexPath]) { + return attributes; + } + + attributes.alpha = 0.0; + attributes.transform = + CGAffineTransformScale(attributes.transform, kInsertedItemInitialScale, + kInsertedItemInitialScale); + return attributes; +} + @end
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_context_menu/tab_context_menu_helper.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_context_menu/tab_context_menu_helper.mm index 94184be..daff9f2 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_context_menu/tab_context_menu_helper.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_context_menu/tab_context_menu_helper.mm
@@ -27,6 +27,8 @@ #error "This file requires ARC support." #endif +using PinnedState = WebStateSearchCriteria::PinnedState; + @interface TabContextMenuHelper () @property(nonatomic, weak) id<TabContextMenuDelegate> contextMenuDelegate; @@ -82,7 +84,10 @@ ActionFactory* actionFactory = [[ActionFactory alloc] initWithScenario:scenario]; - const BOOL pinned = scenario == MenuScenarioHistogram::kPinnedTabsEntry; + const BOOL pinned = IsPinnedTabsEnabled() && + [self isTabPinnedForIdentifier:cell.itemIdentifier]; + const BOOL tabSearchScenario = + scenario == MenuScenarioHistogram::kTabGridSearchResult; const BOOL inactive = scenario == MenuScenarioHistogram::kInactiveTabsEntry; TabItem* item = [self tabItemForIdentifier:cell.itemIdentifier]; @@ -93,7 +98,9 @@ NSMutableArray<UIMenuElement*>* menuElements = [[NSMutableArray alloc] init]; - if (IsPinnedTabsEnabled() && !self.incognito && !inactive) { + const BOOL isPinActionEnabled = IsPinnedTabsEnabled() && !self.incognito && + !inactive && !tabSearchScenario; + if (isPinActionEnabled) { if (pinned) { [menuElements addObject:[actionFactory actionToUnpinTabWithBlock:^{ [self.contextMenuDelegate @@ -182,6 +189,25 @@ bookmarkModel->GetMostRecentlyAddedUserNodeForURL(item.URL); } +// Returns `YES` if the tab for the given `identifier` is pinned. +- (BOOL)isTabPinnedForIdentifier:(NSString*)identifier { + BrowserList* browserList = + BrowserListFactory::GetForBrowserState(_browserState); + + for (Browser* browser : browserList->AllRegularBrowsers()) { + WebStateList* webStateList = browser->GetWebStateList(); + web::WebState* webState = + GetWebState(webStateList, WebStateSearchCriteria{ + .identifier = identifier, + .pinned_state = PinnedState::kPinned, + }); + if (webState) { + return YES; + } + } + return NO; +} + // Returns the TabItem object representing the tab with `identifier. - (TabItem*)tabItemForIdentifier:(NSString*)identifier { BrowserList* browserList =
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_mediator.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_mediator.mm index 66e06ad..8b49fa30 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_mediator.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_mediator.mm
@@ -376,11 +376,6 @@ return; } - if (IsPinnedTabsEnabled() && webStateList->IsWebStatePinnedAt(atIndex)) { - [self.consumer selectItemWithID:nil]; - return; - } - [self.consumer selectItemWithID:newWebState->GetStableIdentifier()]; } @@ -493,11 +488,9 @@ } - (void)selectItemWithID:(NSString*)itemID { - int index = GetTabIndex(self.webStateList, - WebStateSearchCriteria{ - .identifier = itemID, - .pinned_state = PinnedState::kNonPinned, - }); + int index = GetTabIndex(self.webStateList, WebStateSearchCriteria{ + .identifier = itemID, + }); WebStateList* itemWebStateList = self.webStateList; if (index == WebStateList::kInvalidIndex) { // If this is a search result, it may contain items from other windows or @@ -580,10 +573,7 @@ - (BOOL)isItemWithIDSelected:(NSString*)itemID { int index = GetTabIndex(self.webStateList, - WebStateSearchCriteria{ - .identifier = itemID, - .pinned_state = PinnedState::kNonPinned, - }); + WebStateSearchCriteria{.identifier = itemID}); if (index == WebStateList::kInvalidIndex) { return NO; } @@ -1039,11 +1029,10 @@ completion(self.appearanceCache[identifier]); return; } - web::WebState* webState = GetWebState( - self.webStateList, WebStateSearchCriteria{ - .identifier = identifier, - .pinned_state = PinnedState::kNonPinned, - }); + web::WebState* webState = + GetWebState(self.webStateList, WebStateSearchCriteria{ + .identifier = identifier, + }); if (webState) { SnapshotTabHelper::FromWebState(webState)->RetrieveColorSnapshot( ^(UIImage* image) { @@ -1054,11 +1043,10 @@ - (void)faviconForIdentifier:(NSString*)identifier completion:(void (^)(UIImage*))completion { - web::WebState* webState = GetWebState( - self.webStateList, WebStateSearchCriteria{ - .identifier = identifier, - .pinned_state = PinnedState::kNonPinned, - }); + web::WebState* webState = + GetWebState(self.webStateList, WebStateSearchCriteria{ + .identifier = identifier, + }); if (!webState) { return; }
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller.mm index 1ae5648..e18e8c72 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller.mm
@@ -1110,8 +1110,8 @@ GridTransitionLayout* pinnedTabsTransitionLayout = [self.pinnedTabsViewController transitionLayout]; - return [self combineTransitionLayout:pinnedTabsTransitionLayout - withTransitionLayout:regularTabsTransitionLayout]; + return [self combineTransitionLayout:regularTabsTransitionLayout + withTransitionLayout:pinnedTabsTransitionLayout]; } return regularTabsTransitionLayout;
diff --git a/ios/chrome/browser/web_selection/web_selection_response.h b/ios/chrome/browser/web_selection/web_selection_response.h index 7d5f8bc..63550825 100644 --- a/ios/chrome/browser/web_selection/web_selection_response.h +++ b/ios/chrome/browser/web_selection/web_selection_response.h
@@ -42,6 +42,8 @@ // Note: if `selectedText` is empty, `sourceRect` can be CGRectZero if there was // no selection or non zero if the selection contained no text (it could contain // an image). +// Note: sourceRect is in page coordinate and does not take into account the +// view inset. @property(nonatomic, readonly, assign) CGRect sourceRect; @end
diff --git a/ios/chrome/browser/web_selection/web_selection_response.mm b/ios/chrome/browser/web_selection/web_selection_response.mm index ab3507a..6d9a952e 100644 --- a/ios/chrome/browser/web_selection/web_selection_response.mm +++ b/ios/chrome/browser/web_selection/web_selection_response.mm
@@ -6,12 +6,32 @@ #import "base/strings/sys_string_conversions.h" #import "components/shared_highlighting/ios/parsing_utils.h" +#import "ios/web/public/ui/crw_web_view_proxy.h" +#import "ios/web/public/ui/crw_web_view_scroll_view_proxy.h" #import "ios/web/public/web_state.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +namespace { + +CGRect ConvertToBrowserRect(CGRect web_view_rect, web::WebState* web_state) { + if (CGRectEqualToRect(web_view_rect, CGRectZero) || !web_state) { + return web_view_rect; + } + + id<CRWWebViewProxy> web_view_proxy = web_state->GetWebViewProxy(); + CGFloat zoom_scale = web_view_proxy.scrollViewProxy.zoomScale; + + return CGRectMake((web_view_rect.origin.x * zoom_scale), + (web_view_rect.origin.y * zoom_scale), + (web_view_rect.size.width * zoom_scale), + web_view_rect.size.height * zoom_scale); +} + +} // namespace + @interface WebSelectionResponse () - (instancetype)initWithSelectedText:(NSString*)selectedText sourceView:(UIView*)sourceView @@ -39,8 +59,7 @@ return [[WebSelectionResponse alloc] initWithSelectedText:base::SysUTF8ToNSString(*selectedText) sourceView:webState->GetView() - sourceRect:shared_highlighting::ConvertToBrowserRect( - sourceRect.value(), webState) + sourceRect:ConvertToBrowserRect(sourceRect.value(), webState) valid:YES]; }
diff --git a/ios/chrome/common/ui/confirmation_alert/confirmation_alert_view_controller.h b/ios/chrome/common/ui/confirmation_alert/confirmation_alert_view_controller.h index e63a4524..97556a0 100644 --- a/ios/chrome/common/ui/confirmation_alert/confirmation_alert_view_controller.h +++ b/ios/chrome/common/ui/confirmation_alert/confirmation_alert_view_controller.h
@@ -25,6 +25,7 @@ // Setting those properties will make those buttons be added to the view // controller. @interface ConfirmationAlertViewController : UIViewController + // The navigation bar title view. Nil if not needed. If needed, must be set // before the view is loaded. @property(nonatomic, strong) UIView* titleView; @@ -100,6 +101,13 @@ // The action handler for interactions in this View Controller. @property(nonatomic, weak) id<ConfirmationAlertActionHandler> actionHandler; +// Designated initializer. +- (instancetype)init NS_DESIGNATED_INITIALIZER; + +- (instancetype)initWithCoder:(NSCoder*)coder NS_UNAVAILABLE; +- (instancetype)initWithNibName:(NSString*)name + bundle:(NSBundle*)bundle NS_UNAVAILABLE; + // Can be overridden by subclasses to customize the secondary title, e.g. set a // different style, or a UITextViewDelegate. The default implementation does // nothing.
diff --git a/ios/chrome/common/ui/confirmation_alert/confirmation_alert_view_controller.mm b/ios/chrome/common/ui/confirmation_alert/confirmation_alert_view_controller.mm index 786011f..ee92f5a 100644 --- a/ios/chrome/common/ui/confirmation_alert/confirmation_alert_view_controller.mm +++ b/ios/chrome/common/ui/confirmation_alert/confirmation_alert_view_controller.mm
@@ -89,7 +89,7 @@ #pragma mark - Public - (instancetype)init { - self = [super init]; + self = [super initWithNibName:nil bundle:nil]; if (self) { _customSpacingAfterImage = kStackViewSpacingAfterIllustration; _showDismissBarButton = YES;
diff --git a/ios/web/annotations/annotations_inttest.mm b/ios/web/annotations/annotations_inttest.mm index 39ba00a8..a99dc106 100644 --- a/ios/web/annotations/annotations_inttest.mm +++ b/ios/web/annotations/annotations_inttest.mm
@@ -286,6 +286,32 @@ "</body></html>"); } +// Tests page decoration on no-decoration tags. +// Covers: DecorateAnnotations, ConvertMatchToAnnotation. +TEST_F(AnnotationTextManagerTest, NoDecorateText) { + LoadHtmlAndExtractText("<html><body>" + "<p>text</p>" + "<a>annotation1</a>" + "<input type=\"radio\">" + "<label>annotation2</label>" + "<p>text</p>" + "</body></html>"); + + std::string text = "\ntext" + "annotation1" + "annotation2" + "\ntext"; + EXPECT_EQ(text, observer()->extracted_text()); + + // Create annotation. + NSString* source = base::SysUTF8ToNSString(text); + CreateAndApplyAnnotations(source, @[ @"annotation1", @"annotation2" ], + observer() -> seq_id()); + + EXPECT_EQ(observer()->successes(), 0); + EXPECT_EQ(observer()->annotations(), 2); +} + // Tests different annotation cases, including tags boundaries. // Covers: RemoveDecorations TEST_F(AnnotationTextManagerTest, DecorateTextCrossingElements) {
diff --git a/ios/web/annotations/resources/annotations.ts b/ios/web/annotations/resources/annotations.ts index 6d47dbd..a87cfee1 100644 --- a/ios/web/annotations/resources/annotations.ts +++ b/ios/web/annotations/resources/annotations.ts
@@ -9,7 +9,7 @@ import {gCrWeb} from '//ios/web/public/js_messaging/resources/gcrweb.js'; import {sendWebKitMessage} from '//ios/web/public/js_messaging/resources/utils.js' -import {NON_TEXT_NODE_NAMES} +import {NON_TEXT_NODE_NAMES, NO_DECORATION_NODE_NAMES} from '//ios/web/annotations/resources/annotations_constants.js'; // Mark: Private properties @@ -201,14 +201,17 @@ break; } - // If the hit on a link, do not stylize. The check doesn't happen before - // the annotation loop above, to keep the running cursor's (annotationIndex) - // integrity. + // If the hit on a link (or other interactive tags), do not stylize. The + // check doesn't happen before the annotation loop above, to keep the + // running cursor's (annotationIndex) integrity. It also doesn't happen + // at text extraction, to allow these tag's text to participate in a bigger + // intent detection. let currentParentNode: Node|null = node.parentNode; while (currentParentNode) { if (currentParentNode instanceof HTMLElement && - currentParentNode.tagName === 'A') { + NO_DECORATION_NODE_NAMES.has(currentParentNode.tagName)) { replacements = []; + failures++; break; } currentParentNode = currentParentNode.parentNode;
diff --git a/ios/web/annotations/resources/annotations_constants.ts b/ios/web/annotations/resources/annotations_constants.ts index c1a9f1d4..0756f09d 100644 --- a/ios/web/annotations/resources/annotations_constants.ts +++ b/ios/web/annotations/resources/annotations_constants.ts
@@ -8,6 +8,11 @@ 'INPUT' ]); +// Tags that should not be decorated. +const NO_DECORATION_NODE_NAMES = new Set([ + 'A', 'LABEL' +]); + export { - NON_TEXT_NODE_NAMES, + NON_TEXT_NODE_NAMES, NO_DECORATION_NODE_NAMES, } \ No newline at end of file
diff --git a/ios/web/common/features.h b/ios/web/common/features.h index ce9ffee..0584962 100644 --- a/ios/web/common/features.h +++ b/ios/web/common/features.h
@@ -103,9 +103,6 @@ // When true, the fullscreen API should be used to enable fullscreen mode. bool IsFullscreenAPIEnabled(); -// Return true when the smooth scrolling feature is enabled. -bool IsFullscreenSmoothScrollingEnabled(); - // When true, the new session serialization code should be used. bool UseNewSessionSerialization();
diff --git a/media/filters/win/media_foundation_audio_decoder.cc b/media/filters/win/media_foundation_audio_decoder.cc index 19441532..08b76584 100644 --- a/media/filters/win/media_foundation_audio_decoder.cc +++ b/media/filters/win/media_foundation_audio_decoder.cc
@@ -282,6 +282,9 @@ } bool MediaFoundationAudioDecoder::ConfigureOutput() { + // Reset sample staging buffer before configure output, in case stream + // configuration changed. + output_sample_.Reset(); // Configure audio output. Microsoft::WRL::ComPtr<IMFMediaType> output_type; for (uint32_t i = 0; @@ -389,7 +392,9 @@ sample_rate_ <= limits::kMaxSampleRate, "Sample rate is not supported", false); - timestamp_helper_ = std::make_unique<AudioTimestampHelper>(sample_rate_); + if (!timestamp_helper_) { + timestamp_helper_ = std::make_unique<AudioTimestampHelper>(sample_rate_); + } decoder_->ProcessMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, 0); return true; }
diff --git a/mojo/core/broker_host.cc b/mojo/core/broker_host.cc index 7a5d4f94..a0371495 100644 --- a/mojo/core/broker_host.cc +++ b/mojo/core/broker_host.cc
@@ -32,8 +32,11 @@ client_process_(std::move(client_process)) #endif { + CHECK(connection_params.endpoint().is_valid() || + connection_params.server_endpoint().is_valid()); + base::CurrentThread::Get()->AddDestructionObserver(this); - CHECK(connection_params.endpoint().is_valid()); + channel_ = Channel::Create(this, std::move(connection_params), #if BUILDFLAG(IS_WIN) client_process_
diff --git a/mojo/core/channel.cc b/mojo/core/channel.cc index 4b7bbc1..71d2ab3 100644 --- a/mojo/core/channel.cc +++ b/mojo/core/channel.cc
@@ -893,13 +893,23 @@ // static scoped_refptr<Channel> Channel::CreateForIpczDriver( Delegate* delegate, - PlatformChannelEndpoint endpoint, + Endpoint endpoint, scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) { #if BUILDFLAG(IS_NACL) return nullptr; #else - return Create(delegate, ConnectionParams{std::move(endpoint)}, - HandlePolicy::kAcceptHandles, std::move(io_task_runner)); + ConnectionParams params = + absl::visit(base::Overloaded{ + [](PlatformChannelEndpoint& endpoint) { + return ConnectionParams(std::move(endpoint)); + }, + [](PlatformChannelServerEndpoint& endpoint) { + return ConnectionParams(std::move(endpoint)); + }, + }, + endpoint); + return Create(delegate, std::move(params), HandlePolicy::kAcceptHandles, + std::move(io_task_runner)); #endif }
diff --git a/mojo/core/channel.h b/mojo/core/channel.h index 40e03ebe..4cc0e92 100644 --- a/mojo/core/channel.h +++ b/mojo/core/channel.h
@@ -22,7 +22,9 @@ #include "mojo/core/connection_params.h" #include "mojo/core/platform_handle_in_transit.h" #include "mojo/public/cpp/platform/platform_channel_endpoint.h" +#include "mojo/public/cpp/platform/platform_channel_server_endpoint.h" #include "mojo/public/cpp/platform/platform_handle.h" +#include "third_party/abseil-cpp/absl/types/variant.h" namespace mojo::core { @@ -316,9 +318,11 @@ // header, and the Channel is no longer responsible for encoding or decoding // any metadata about transmitted PlatformHandles, since the ipcz driver takes // care of that. + using Endpoint = + absl::variant<PlatformChannelEndpoint, PlatformChannelServerEndpoint>; static scoped_refptr<Channel> CreateForIpczDriver( Delegate* delegate, - PlatformChannelEndpoint endpoint, + Endpoint endpoint, scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); Channel(const Channel&) = delete;
diff --git a/mojo/core/channel_mac.cc b/mojo/core/channel_mac.cc index 229ff07..24405df2 100644 --- a/mojo/core/channel_mac.cc +++ b/mojo/core/channel_mac.cc
@@ -55,8 +55,14 @@ self_(this), io_task_runner_(io_task_runner), watch_controller_(FROM_HERE) { - PlatformHandle channel_handle = - connection_params.TakeEndpoint().TakePlatformHandle(); + PlatformHandle channel_handle; + if (connection_params.server_endpoint().is_valid()) { + channel_handle = + connection_params.TakeServerEndpoint().TakePlatformHandle(); + } else { + channel_handle = connection_params.TakeEndpoint().TakePlatformHandle(); + } + if (channel_handle.is_mach_send()) { send_port_ = channel_handle.TakeMachSendRight(); } else if (channel_handle.is_mach_receive()) {
diff --git a/mojo/core/channel_posix.cc b/mojo/core/channel_posix.cc index 42b55c2..f57c9b3 100644 --- a/mojo/core/channel_posix.cc +++ b/mojo/core/channel_posix.cc
@@ -122,8 +122,12 @@ : Channel(delegate, handle_policy), self_(this), io_task_runner_(io_task_runner) { - socket_ = connection_params.TakeEndpoint().TakePlatformHandle().TakeFD(); - CHECK(socket_.is_valid()); + if (connection_params.server_endpoint().is_valid()) + server_ = connection_params.TakeServerEndpoint(); + else + socket_ = connection_params.TakeEndpoint().TakePlatformHandle().TakeFD(); + + CHECK(server_.is_valid() || socket_.is_valid()); } ChannelPosix::~ChannelPosix() { @@ -221,13 +225,19 @@ read_watcher_ = std::make_unique<base::MessagePumpForIO::FdWatchController>(FROM_HERE); base::CurrentThread::Get()->AddDestructionObserver(this); - write_watcher_ = - std::make_unique<base::MessagePumpForIO::FdWatchController>(FROM_HERE); - base::CurrentIOThread::Get()->WatchFileDescriptor( - socket_.get(), true /* persistent */, base::MessagePumpForIO::WATCH_READ, - read_watcher_.get(), this); - base::AutoLock lock(write_lock_); - FlushOutgoingMessagesNoLock(); + if (server_.is_valid()) { + base::CurrentIOThread::Get()->WatchFileDescriptor( + server_.platform_handle().GetFD().get(), false /* persistent */, + base::MessagePumpForIO::WATCH_READ, read_watcher_.get(), this); + } else { + write_watcher_ = + std::make_unique<base::MessagePumpForIO::FdWatchController>(FROM_HERE); + base::CurrentIOThread::Get()->WatchFileDescriptor( + socket_.get(), true /* persistent */, + base::MessagePumpForIO::WATCH_READ, read_watcher_.get(), this); + base::AutoLock lock(write_lock_); + FlushOutgoingMessagesNoLock(); + } } void ChannelPosix::WaitForWriteOnIOThread() { @@ -258,8 +268,10 @@ write_watcher_.reset(); if (leak_handle_) { std::ignore = socket_.release(); + server_.TakePlatformHandle().release(); } else { socket_.reset(); + std::ignore = server_.TakePlatformHandle(); } #if BUILDFLAG(IS_IOS) fds_to_close_.clear(); @@ -276,6 +288,24 @@ } void ChannelPosix::OnFileCanReadWithoutBlocking(int fd) { + if (server_.is_valid()) { + CHECK_EQ(fd, server_.platform_handle().GetFD().get()); +#if !BUILDFLAG(IS_NACL) + read_watcher_.reset(); + base::CurrentThread::Get()->RemoveDestructionObserver(this); + + AcceptSocketConnection(server_.platform_handle().GetFD().get(), &socket_); + std::ignore = server_.TakePlatformHandle(); + if (!socket_.is_valid()) { + OnError(Error::kConnectionFailed); + return; + } + StartOnIOThread(); +#else + NOTREACHED(); +#endif + return; + } CHECK_EQ(fd, socket_.get()); bool validation_error = false; @@ -340,6 +370,10 @@ // cannot be written, it's queued and a wait is initiated to write the message // ASAP on the I/O thread. bool ChannelPosix::WriteNoLock(MessageView message_view) { + if (server_.is_valid()) { + outgoing_messages_.emplace_front(std::move(message_view)); + return true; + } size_t bytes_written = 0; std::vector<PlatformHandleInTransit> handles = message_view.TakeHandles(); size_t num_handles = handles.size();
diff --git a/mojo/core/channel_posix.h b/mojo/core/channel_posix.h index 94b55c9..695be6d 100644 --- a/mojo/core/channel_posix.h +++ b/mojo/core/channel_posix.h
@@ -98,7 +98,12 @@ bool CloseHandles(const int* fds, size_t num_fds); #endif // BUILDFLAG(IS_IOS) - // The socket over which to communicate. + // We may be initialized with a server socket, in which case this will be + // valid until it accepts an incoming connection. + PlatformChannelServerEndpoint server_; + + // The socket over which to communicate. May be passed in at construction time + // or accepted over |server_|. base::ScopedFD socket_; // These watchers must only be accessed on the IO thread.
diff --git a/mojo/core/channel_win.cc b/mojo/core/channel_win.cc index 9f751fa9..f75273f 100644 --- a/mojo/core/channel_win.cc +++ b/mojo/core/channel_win.cc
@@ -67,8 +67,16 @@ is_untrusted_process_(connection_params.is_untrusted_process()), self_(this), io_task_runner_(io_task_runner) { - handle_ = - connection_params.TakeEndpoint().TakePlatformHandle().TakeHandle(); + if (connection_params.server_endpoint().is_valid()) { + handle_ = connection_params.TakeServerEndpoint() + .TakePlatformHandle() + .TakeHandle(); + needs_connection_ = true; + } else { + handle_ = + connection_params.TakeEndpoint().TakePlatformHandle().TakeHandle(); + } + CHECK(handle_.IsValid()); } @@ -178,6 +186,29 @@ base::CurrentThread::Get()->AddDestructionObserver(this); base::CurrentIOThread::Get()->RegisterIOHandler(handle_.Get(), this); + if (needs_connection_) { + BOOL ok = ::ConnectNamedPipe(handle_.Get(), &connect_context_.overlapped); + if (ok) { + PLOG(ERROR) << "Unexpected success while waiting for pipe connection"; + OnError(Error::kConnectionFailed); + return; + } + + const DWORD err = GetLastError(); + switch (err) { + case ERROR_PIPE_CONNECTED: + break; + case ERROR_IO_PENDING: + is_connect_pending_ = true; + AddRef(); + return; + case ERROR_NO_DATA: + default: + OnError(Error::kConnectionFailed); + return; + } + } + // Now that we have registered our IOHandler, we can start writing. { base::AutoLock lock(write_lock_); @@ -230,6 +261,16 @@ } else { OnError(Error::kDisconnected); } + } else if (context == &connect_context_) { + DCHECK(is_connect_pending_); + is_connect_pending_ = false; + ReadMore(0); + + base::AutoLock lock(write_lock_); + if (delay_writes_) { + delay_writes_ = false; + WriteNextNoLock(); + } } else if (context == &read_context_) { OnReadDone(static_cast<size_t>(bytes_transfered)); } else { @@ -340,9 +381,8 @@ // If we can't write because the pipe is disconnected then continue // reading to fetch any in-flight messages, relying on end-of-stream to // signal the actual disconnection. - if (is_read_pending_) { + if (is_read_pending_ || is_connect_pending_) return; - } } OnError(error); @@ -356,9 +396,14 @@ // The pipe handle this Channel uses for communication. base::win::ScopedHandle handle_; + // Indicates whether |handle_| must wait for a connection. + bool needs_connection_ = false; + const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; + base::MessagePumpForIO::IOContext connect_context_; base::MessagePumpForIO::IOContext read_context_; + bool is_connect_pending_ = false; bool is_read_pending_ = false; // Protects all fields potentially accessed on multiple threads via Write().
diff --git a/mojo/core/connection_params.cc b/mojo/core/connection_params.cc index b05b211..dac76f1d 100644 --- a/mojo/core/connection_params.cc +++ b/mojo/core/connection_params.cc
@@ -15,6 +15,10 @@ ConnectionParams::ConnectionParams(PlatformChannelEndpoint endpoint) : endpoint_(std::move(endpoint)) {} +ConnectionParams::ConnectionParams( + PlatformChannelServerEndpoint server_endpoint) + : server_endpoint_(std::move(server_endpoint)) {} + ConnectionParams::ConnectionParams(ConnectionParams&&) = default; ConnectionParams::~ConnectionParams() = default;
diff --git a/mojo/core/connection_params.h b/mojo/core/connection_params.h index bf8dce5..052f38b 100644 --- a/mojo/core/connection_params.h +++ b/mojo/core/connection_params.h
@@ -8,6 +8,7 @@ #include "build/build_config.h" #include "mojo/core/system_impl_export.h" #include "mojo/public/cpp/platform/platform_channel_endpoint.h" +#include "mojo/public/cpp/platform/platform_channel_server_endpoint.h" namespace mojo { namespace core { @@ -17,6 +18,7 @@ public: ConnectionParams(); explicit ConnectionParams(PlatformChannelEndpoint endpoint); + explicit ConnectionParams(PlatformChannelServerEndpoint server_endpoint); ConnectionParams(ConnectionParams&&); ConnectionParams(const ConnectionParams&) = delete; @@ -27,9 +29,16 @@ ConnectionParams& operator=(ConnectionParams&&); const PlatformChannelEndpoint& endpoint() const { return endpoint_; } + const PlatformChannelServerEndpoint& server_endpoint() const { + return server_endpoint_; + } PlatformChannelEndpoint TakeEndpoint() { return std::move(endpoint_); } + PlatformChannelServerEndpoint TakeServerEndpoint() { + return std::move(server_endpoint_); + } + void set_is_async(bool is_async) { is_async_ = is_async; } bool is_async() const { return is_async_; } @@ -46,6 +55,7 @@ bool is_untrusted_process_ = false; bool leak_endpoint_ = false; PlatformChannelEndpoint endpoint_; + PlatformChannelServerEndpoint server_endpoint_; }; } // namespace core
diff --git a/mojo/core/core.cc b/mojo/core/core.cc index 40027e0..415c175 100644 --- a/mojo/core/core.cc +++ b/mojo/core/core.cc
@@ -1301,6 +1301,8 @@ return MOJO_RESULT_INVALID_ARGUMENT; if (transport_endpoint->type != MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL && transport_endpoint->type != + MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL_SERVER && + transport_endpoint->type != MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL_ASYNC) { return MOJO_RESULT_UNIMPLEMENTED; } @@ -1316,8 +1318,18 @@ if (!endpoint.is_valid()) return MOJO_RESULT_INVALID_ARGUMENT; - ConnectionParams connection_params( - PlatformChannelEndpoint(std::move(endpoint))); + ConnectionParams connection_params; +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_POSIX) + if (transport_endpoint->type == + MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL_SERVER) { + connection_params = + ConnectionParams(PlatformChannelServerEndpoint(std::move(endpoint))); + } +#endif + if (!connection_params.server_endpoint().is_valid()) { + connection_params = + ConnectionParams(PlatformChannelEndpoint(std::move(endpoint))); + } // At this point everything else has been validated, so we can take ownership // of the dispatcher. @@ -1330,6 +1342,7 @@ // Release ownership of the endpoint platform handle, per the API // contract. The caller retains ownership on failure. connection_params.TakeEndpoint().TakePlatformHandle().release(); + connection_params.TakeServerEndpoint().TakePlatformHandle().release(); return result; } DCHECK_EQ(removed_dispatcher.get(), invitation_dispatcher); @@ -1387,6 +1400,8 @@ return MOJO_RESULT_INVALID_ARGUMENT; if (transport_endpoint->type != MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL && transport_endpoint->type != + MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL_SERVER && + transport_endpoint->type != MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL_ASYNC) { return MOJO_RESULT_UNIMPLEMENTED; } @@ -1406,8 +1421,18 @@ return MOJO_RESULT_INVALID_ARGUMENT; } - ConnectionParams connection_params( - PlatformChannelEndpoint(std::move(endpoint))); + ConnectionParams connection_params; +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_POSIX) + if (transport_endpoint->type == + MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL_SERVER) { + connection_params = + ConnectionParams(PlatformChannelServerEndpoint(std::move(endpoint))); + } +#endif + if (!connection_params.server_endpoint().is_valid()) { + connection_params = + ConnectionParams(PlatformChannelEndpoint(std::move(endpoint))); + } if (options && options->flags & MOJO_ACCEPT_INVITATION_FLAG_LEAK_TRANSPORT_ENDPOINT) { connection_params.set_leak_endpoint(true);
diff --git a/mojo/core/embedder/BUILD.gn b/mojo/core/embedder/BUILD.gn index df6f3e93..fce6597 100644 --- a/mojo/core/embedder/BUILD.gn +++ b/mojo/core/embedder/BUILD.gn
@@ -21,13 +21,13 @@ public_deps = [ "//base", "//mojo:buildflags", - "//mojo/core:embedder_internal", "//mojo/public/cpp/platform", "//third_party/ipcz/src:ipcz_chromium", ] deps = [ ":features", + "//mojo/core:embedder_internal", "//mojo/public/c/system", ] }
diff --git a/mojo/core/invitation_unittest.cc b/mojo/core/invitation_unittest.cc index f8c11dd..53037f1 100644 --- a/mojo/core/invitation_unittest.cc +++ b/mojo/core/invitation_unittest.cc
@@ -45,22 +45,34 @@ namespace core { namespace { +enum class TransportType { + kChannel, + kChannelServer, +}; + const char kSecondaryChannelHandleSwitch[] = "test-secondary-channel-handle"; -class InvitationTest : public test::MojoTestBase { +// TODO(https://crbug.com/1428561): Flaky on Tsan. +#if defined(THREAD_SANITIZER) +#define MAYBE_InvitationTest DISABLED_InvitationTest +#else +#define MAYBE_InvitationTest InvitationTest +#endif +class MAYBE_InvitationTest : public test::MojoTestBase { public: - InvitationTest() = default; + MAYBE_InvitationTest() = default; - InvitationTest(const InvitationTest&) = delete; - InvitationTest& operator=(const InvitationTest&) = delete; + MAYBE_InvitationTest(const MAYBE_InvitationTest&) = delete; + MAYBE_InvitationTest& operator=(const MAYBE_InvitationTest&) = delete; - ~InvitationTest() override = default; + ~MAYBE_InvitationTest() override = default; protected: static base::Process LaunchChildTestClient( const std::string& test_client_name, MojoHandle* primordial_pipes, size_t num_primordial_pipes, + TransportType transport_type, MojoSendInvitationFlags send_flags, MojoProcessErrorHandler error_handler = nullptr, uintptr_t error_handler_context = 0, @@ -72,6 +84,7 @@ base::ProcessHandle process, MojoHandle* primordial_pipes, size_t num_primordial_pipes, + TransportType transport_type, MojoSendInvitationFlags flags, MojoProcessErrorHandler error_handler, uintptr_t error_handler_context, @@ -99,13 +112,12 @@ #error "Platform not yet supported." #endif - if (switch_name.empty()) { + if (switch_name.empty()) switch_name = PlatformChannel::kHandleSwitch; - } command_line->AppendSwitchASCII(std::string(switch_name), value); } -TEST_F(InvitationTest, Create) { +TEST_F(MAYBE_InvitationTest, Create) { MojoHandle invitation; EXPECT_EQ(MOJO_RESULT_OK, MojoCreateInvitation(nullptr, &invitation)); EXPECT_EQ(MOJO_RESULT_OK, MojoClose(invitation)); @@ -117,7 +129,7 @@ EXPECT_EQ(MOJO_RESULT_OK, MojoClose(invitation)); } -TEST_F(InvitationTest, InvalidArguments) { +TEST_F(MAYBE_InvitationTest, InvalidArguments) { MojoHandle invitation; MojoCreateInvitationOptions invalid_create_options; invalid_create_options.struct_size = 0; @@ -225,7 +237,7 @@ EXPECT_EQ(MOJO_RESULT_OK, MojoClose(invitation)); } -TEST_F(InvitationTest, AttachAndExtractLocally) { +TEST_F(MAYBE_InvitationTest, AttachAndExtractLocally) { MojoHandle invitation; EXPECT_EQ(MOJO_RESULT_OK, MojoCreateInvitation(nullptr, &invitation)); @@ -250,7 +262,7 @@ EXPECT_EQ(MOJO_RESULT_OK, MojoClose(pipe1)); } -TEST_F(InvitationTest, ClosedInvitationClosesAttachments) { +TEST_F(MAYBE_InvitationTest, ClosedInvitationClosesAttachments) { MojoHandle invitation; EXPECT_EQ(MOJO_RESULT_OK, MojoCreateInvitation(nullptr, &invitation)); @@ -267,7 +279,7 @@ EXPECT_EQ(MOJO_RESULT_OK, MojoClose(pipe)); } -TEST_F(InvitationTest, AttachNameInUse) { +TEST_F(MAYBE_InvitationTest, AttachNameInUse) { constexpr uint32_t kName0 = 0; constexpr uint32_t kName1 = 1; MojoHandle invitation; @@ -295,10 +307,11 @@ } // static -base::Process InvitationTest::LaunchChildTestClient( +base::Process MAYBE_InvitationTest::LaunchChildTestClient( const std::string& test_client_name, MojoHandle* primordial_pipes, size_t num_primordial_pipes, + TransportType transport_type, MojoSendInvitationFlags send_flags, MojoProcessErrorHandler error_handler, uintptr_t error_handler_context, @@ -316,10 +329,31 @@ launch_options.start_hidden = true; #endif - PlatformChannel channel; +#if !BUILDFLAG(IS_FUCHSIA) + absl::optional<NamedPlatformChannel> named_channel; +#endif + absl::optional<PlatformChannel> channel; PlatformHandle local_endpoint_handle; - PrepareToPassRemoteEndpoint(&channel, &launch_options, &command_line); - local_endpoint_handle = channel.TakeLocalEndpoint().TakePlatformHandle(); + if (transport_type == TransportType::kChannel) { + channel.emplace(); + PrepareToPassRemoteEndpoint(&channel.value(), &launch_options, + &command_line); + local_endpoint_handle = channel->TakeLocalEndpoint().TakePlatformHandle(); + } else { +#if !BUILDFLAG(IS_FUCHSIA) + NamedPlatformChannel::Options named_channel_options; +#if !BUILDFLAG(IS_WIN) + CHECK(base::PathService::Get(base::DIR_TEMP, + &named_channel_options.socket_dir)); +#endif + named_channel.emplace(named_channel_options); + named_channel->PassServerNameOnCommandLine(&command_line); + local_endpoint_handle = + named_channel->TakeServerEndpoint().TakePlatformHandle(); +#else // !BUILDFLAG(IS_FUCHSIA) + NOTREACHED() << "Named pipe support does not exist for Mojo on Fuchsia."; +#endif // !BUILDFLAG(IS_FUCHSIA) + } std::string enable_features; std::string disable_features; @@ -334,22 +368,24 @@ base::Process child_process = base::SpawnMultiProcessTestChild( test_client_name, command_line, launch_options); - channel.RemoteProcessLaunchAttempted(); + if (channel) + channel->RemoteProcessLaunchAttempted(); SendInvitationToClient(std::move(local_endpoint_handle), child_process.Handle(), primordial_pipes, - num_primordial_pipes, send_flags, error_handler, - error_handler_context, ""); + num_primordial_pipes, transport_type, send_flags, + error_handler, error_handler_context, ""); return child_process; } // static -void InvitationTest::SendInvitationToClient( +void MAYBE_InvitationTest::SendInvitationToClient( PlatformHandle endpoint_handle, base::ProcessHandle process, MojoHandle* primordial_pipes, size_t num_primordial_pipes, + TransportType transport_type, MojoSendInvitationFlags flags, MojoProcessErrorHandler error_handler, uintptr_t error_handler_context, @@ -377,7 +413,10 @@ MojoInvitationTransportEndpoint transport_endpoint; transport_endpoint.struct_size = sizeof(transport_endpoint); - transport_endpoint.type = MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL; + if (transport_type == TransportType::kChannel) + transport_endpoint.type = MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL; + else + transport_endpoint.type = MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL_SERVER; transport_endpoint.num_platform_handles = 1; transport_endpoint.platform_handles = &handle; @@ -394,7 +433,7 @@ error_handler, error_handler_context, &options)); } -class TestClientBase : public InvitationTest { +class TestClientBase : public MAYBE_InvitationTest { public: TestClientBase(const TestClientBase&) = delete; TestClientBase& operator=(const TestClientBase&) = delete; @@ -403,12 +442,17 @@ base::StringPiece switch_name = {}) { const auto& command_line = *base::CommandLine::ForCurrentProcess(); PlatformChannelEndpoint channel_endpoint; - if (switch_name.empty()) { - channel_endpoint = - PlatformChannel::RecoverPassedEndpointFromCommandLine(command_line); - } else { - channel_endpoint = PlatformChannel::RecoverPassedEndpointFromString( - command_line.GetSwitchValueASCII(switch_name)); +#if !BUILDFLAG(IS_FUCHSIA) + channel_endpoint = NamedPlatformChannel::ConnectToServer(command_line); +#endif + if (!channel_endpoint.is_valid()) { + if (switch_name.empty()) { + channel_endpoint = + PlatformChannel::RecoverPassedEndpointFromCommandLine(command_line); + } else { + channel_endpoint = PlatformChannel::RecoverPassedEndpointFromString( + command_line.GetSwitchValueASCII(switch_name)); + } } MojoPlatformHandle endpoint_handle; PlatformHandle::ToMojoPlatformHandle(channel_endpoint.TakePlatformHandle(), @@ -447,11 +491,11 @@ const std::string kTestMessage3 = "i am the shover robot"; const std::string kTestMessage4 = "i shove the messages down the pipe"; -TEST_F(InvitationTest, SendInvitation) { +TEST_F(MAYBE_InvitationTest, SendInvitation) { MojoHandle primordial_pipe; - base::Process child_process = - LaunchChildTestClient("SendInvitationClient", &primordial_pipe, 1, - MOJO_SEND_INVITATION_FLAG_NONE); + base::Process child_process = LaunchChildTestClient( + "SendInvitationClient", &primordial_pipe, 1, TransportType::kChannel, + MOJO_SEND_INVITATION_FLAG_NONE); WriteMessage(primordial_pipe, kTestMessage1); EXPECT_EQ(MOJO_RESULT_OK, @@ -483,11 +527,11 @@ ASSERT_EQ(MOJO_RESULT_OK, MojoClose(primordial_pipe)); } -TEST_F(InvitationTest, SendInvitationMultiplePipes) { +TEST_F(MAYBE_InvitationTest, SendInvitationMultiplePipes) { MojoHandle pipes[2]; - base::Process child_process = - LaunchChildTestClient("SendInvitationMultiplePipesClient", pipes, 2, - MOJO_SEND_INVITATION_FLAG_NONE); + base::Process child_process = LaunchChildTestClient( + "SendInvitationMultiplePipesClient", pipes, 2, TransportType::kChannel, + MOJO_SEND_INVITATION_FLAG_NONE); WriteMessage(pipes[0], kTestMessage1); WriteMessage(pipes[1], kTestMessage2); @@ -532,6 +576,51 @@ EXPECT_EQ(MOJO_RESULT_OK, MojoClose(pipes[1])); } +// Fuchsia has no named pipe support. +#if !BUILDFLAG(IS_FUCHSIA) +// TODO(crbug.com/1426421): Flaky on Linux TSAN. +#if BUILDFLAG(IS_LINUX) && defined(THREAD_SANITIZER) +#define MAYBE_SendInvitationWithServer DISABLED_SendInvitationWithServer +#else +#define MAYBE_SendInvitationWithServer SendInvitationWithServer +#endif +TEST_F(MAYBE_InvitationTest, MAYBE_SendInvitationWithServer) { + MojoHandle primordial_pipe; + base::Process child_process = LaunchChildTestClient( + "SendInvitationWithServerClient", &primordial_pipe, 1, + TransportType::kChannelServer, MOJO_SEND_INVITATION_FLAG_NONE); + + WriteMessage(primordial_pipe, kTestMessage1); + EXPECT_EQ(MOJO_RESULT_OK, + WaitForSignals(primordial_pipe, MOJO_HANDLE_SIGNAL_READABLE)); + EXPECT_EQ(kTestMessage3, ReadMessage(primordial_pipe)); + EXPECT_EQ(MOJO_RESULT_OK, MojoClose(primordial_pipe)); + + int wait_result = -1; + base::WaitForMultiprocessTestChildExit( + child_process, TestTimeouts::action_timeout(), &wait_result); + child_process.Close(); + EXPECT_EQ(0, wait_result); +} + +DEFINE_TEST_CLIENT(SendInvitationWithServerClient) { + MojoHandle primordial_pipe; + MojoHandle invitation = AcceptInvitation(MOJO_ACCEPT_INVITATION_FLAG_NONE); + const uint32_t pipe_name = 0; + ASSERT_EQ(MOJO_RESULT_OK, + MojoExtractMessagePipeFromInvitation(invitation, &pipe_name, 4, + nullptr, &primordial_pipe)); + ASSERT_EQ(MOJO_RESULT_OK, MojoClose(invitation)); + + WaitForSignals(primordial_pipe, MOJO_HANDLE_SIGNAL_READABLE); + ASSERT_EQ(kTestMessage1, ReadMessage(primordial_pipe)); + WriteMessage(primordial_pipe, kTestMessage3); + WaitForSignals(primordial_pipe, MOJO_HANDLE_SIGNAL_PEER_CLOSED); + + ASSERT_EQ(MOJO_RESULT_OK, MojoClose(primordial_pipe)); +} +#endif // !BUILDFLAG(IS_FUCHSIA) + const char kErrorMessage[] = "ur bad :("; const char kDisconnectMessage[] = "go away plz"; @@ -590,12 +679,13 @@ details->flags & MOJO_PROCESS_ERROR_FLAG_DISCONNECTED); } -TEST_F(InvitationTest, ProcessErrors) { +TEST_F(MAYBE_InvitationTest, ProcessErrors) { RemoteProcessState process_state; MojoHandle pipe; base::Process child_process = LaunchChildTestClient( - "ProcessErrorsClient", &pipe, 1, MOJO_SEND_INVITATION_FLAG_NONE, - &TestProcessErrorHandler, reinterpret_cast<uintptr_t>(&process_state)); + "ProcessErrorsClient", &pipe, 1, TransportType::kChannel, + MOJO_SEND_INVITATION_FLAG_NONE, &TestProcessErrorHandler, + reinterpret_cast<uintptr_t>(&process_state)); MojoMessageHandle message; WaitForSignals(pipe, MOJO_HANDLE_SIGNAL_READABLE); @@ -650,7 +740,7 @@ } // Temporary removed support for reinvitation for non-isolated connections. -TEST_F(InvitationTest, DISABLED_Reinvitation) { +TEST_F(MAYBE_InvitationTest, DISABLED_Reinvitation) { // The gist of this test is that a process should be able to accept an // invitation, lose its connection to the process network, and then accept a // new invitation to re-establish communication. @@ -666,8 +756,9 @@ MojoHandle pipe; base::Process child_process = LaunchChildTestClient( - "ReinvitationClient", &pipe, 1, MOJO_SEND_INVITATION_FLAG_NONE, nullptr, - 0, &command_line, &launch_options); + "ReinvitationClient", &pipe, 1, TransportType::kChannel, + MOJO_SEND_INVITATION_FLAG_NONE, nullptr, 0, &command_line, + &launch_options); secondary_channel.RemoteProcessLaunchAttempted(); // Synchronize end-to-end communication first to ensure the process connection @@ -732,11 +823,11 @@ EXPECT_EQ(kDisconnectMessage, ReadMessage(new_pipe.get().value())); } -TEST_F(InvitationTest, SendIsolatedInvitation) { +TEST_F(MAYBE_InvitationTest, SendIsolatedInvitation) { MojoHandle primordial_pipe; - base::Process child_process = - LaunchChildTestClient("SendIsolatedInvitationClient", &primordial_pipe, 1, - MOJO_SEND_INVITATION_FLAG_ISOLATED); + base::Process child_process = LaunchChildTestClient( + "SendIsolatedInvitationClient", &primordial_pipe, 1, + TransportType::kChannel, MOJO_SEND_INVITATION_FLAG_ISOLATED); WriteMessage(primordial_pipe, kTestMessage1); EXPECT_EQ(MOJO_RESULT_OK, @@ -769,7 +860,7 @@ ASSERT_EQ(MOJO_RESULT_OK, MojoClose(primordial_pipe)); } -TEST_F(InvitationTest, SendMultipleIsolatedInvitations) { +TEST_F(MAYBE_InvitationTest, SendMultipleIsolatedInvitations) { if (mojo::core::IsMojoIpczEnabled()) { // This feature is not particularly useful in a world where isolated // connections are only supported between broker nodes. @@ -789,7 +880,8 @@ MojoHandle primordial_pipe; base::Process child_process = LaunchChildTestClient( "SendMultipleIsolatedInvitationsClient", &primordial_pipe, 1, - MOJO_SEND_INVITATION_FLAG_ISOLATED, nullptr, 0, &command_line, &options); + TransportType::kChannel, MOJO_SEND_INVITATION_FLAG_ISOLATED, nullptr, 0, + &command_line, &options); secondary_transport.RemoteProcessLaunchAttempted(); WriteMessage(primordial_pipe, kTestMessage1); @@ -802,8 +894,8 @@ MojoHandle new_pipe; SendInvitationToClient( secondary_transport.TakeLocalEndpoint().TakePlatformHandle(), - child_process.Handle(), &new_pipe, 1, MOJO_SEND_INVITATION_FLAG_ISOLATED, - nullptr, 0, ""); + child_process.Handle(), &new_pipe, 1, TransportType::kChannel, + MOJO_SEND_INVITATION_FLAG_ISOLATED, nullptr, 0, ""); WaitForSignals(primordial_pipe, MOJO_HANDLE_SIGNAL_PEER_CLOSED); EXPECT_EQ(MOJO_RESULT_OK, MojoClose(primordial_pipe)); @@ -854,7 +946,7 @@ ASSERT_EQ(MOJO_RESULT_OK, MojoClose(primordial_pipe)); } -TEST_F(InvitationTest, SendIsolatedInvitationWithDuplicateName) { +TEST_F(MAYBE_InvitationTest, SendIsolatedInvitationWithDuplicateName) { if (mojo::core::IsMojoIpczEnabled()) { // This feature is not particularly useful in a world where isolated // connections are only supported between broker nodes. @@ -866,24 +958,24 @@ PlatformChannel channel2; MojoHandle pipe0, pipe1; const char kConnectionName[] = "there can be only one!"; - SendInvitationToClient(channel1.TakeLocalEndpoint().TakePlatformHandle(), - base::kNullProcessHandle, &pipe0, 1, - MOJO_SEND_INVITATION_FLAG_ISOLATED, nullptr, 0, - kConnectionName); + SendInvitationToClient( + channel1.TakeLocalEndpoint().TakePlatformHandle(), + base::kNullProcessHandle, &pipe0, 1, TransportType::kChannel, + MOJO_SEND_INVITATION_FLAG_ISOLATED, nullptr, 0, kConnectionName); // Send another invitation with the same connection name. |pipe0| should be // disconnected as the first invitation's connection is torn down. - SendInvitationToClient(channel2.TakeLocalEndpoint().TakePlatformHandle(), - base::kNullProcessHandle, &pipe1, 1, - MOJO_SEND_INVITATION_FLAG_ISOLATED, nullptr, 0, - kConnectionName); + SendInvitationToClient( + channel2.TakeLocalEndpoint().TakePlatformHandle(), + base::kNullProcessHandle, &pipe1, 1, TransportType::kChannel, + MOJO_SEND_INVITATION_FLAG_ISOLATED, nullptr, 0, kConnectionName); WaitForSignals(pipe0, MOJO_HANDLE_SIGNAL_PEER_CLOSED); EXPECT_EQ(MOJO_RESULT_OK, MojoClose(pipe0)); EXPECT_EQ(MOJO_RESULT_OK, MojoClose(pipe1)); } -TEST_F(InvitationTest, SendIsolatedInvitationToSelf) { +TEST_F(MAYBE_InvitationTest, SendIsolatedInvitationToSelf) { if (IsMojoIpczEnabled()) { GTEST_SKIP() << "MojoIpcz does not support nodes sending isolated " << "invitations to themselves."; @@ -893,9 +985,11 @@ MojoHandle pipe0, pipe1; SendInvitationToClient(channel.TakeLocalEndpoint().TakePlatformHandle(), base::kNullProcessHandle, &pipe0, 1, + TransportType::kChannel, MOJO_SEND_INVITATION_FLAG_ISOLATED, nullptr, 0, ""); SendInvitationToClient(channel.TakeRemoteEndpoint().TakePlatformHandle(), base::kNullProcessHandle, &pipe1, 1, + TransportType::kChannel, MOJO_SEND_INVITATION_FLAG_ISOLATED, nullptr, 0, ""); WriteMessage(pipe0, kTestMessage1); @@ -904,11 +998,11 @@ EXPECT_EQ(MOJO_RESULT_OK, MojoClose(pipe1)); } -TEST_F(InvitationTest, BrokenInvitationTransportBreaksAttachedPipe) { +TEST_F(MAYBE_InvitationTest, BrokenInvitationTransportBreaksAttachedPipe) { MojoHandle primordial_pipe; - base::Process child_process = - LaunchChildTestClient("BrokenTransportClient", &primordial_pipe, 1, - MOJO_SEND_INVITATION_FLAG_NONE); + base::Process child_process = LaunchChildTestClient( + "BrokenTransportClient", &primordial_pipe, 1, TransportType::kChannel, + MOJO_SEND_INVITATION_FLAG_NONE); EXPECT_EQ(MOJO_RESULT_OK, WaitForSignals(primordial_pipe, MOJO_HANDLE_SIGNAL_PEER_CLOSED)); @@ -921,11 +1015,12 @@ EXPECT_EQ(0, wait_result); } -TEST_F(InvitationTest, BrokenIsolatedInvitationTransportBreaksAttachedPipe) { +TEST_F(MAYBE_InvitationTest, + BrokenIsolatedInvitationTransportBreaksAttachedPipe) { MojoHandle primordial_pipe; - base::Process child_process = - LaunchChildTestClient("BrokenTransportClient", &primordial_pipe, 1, - MOJO_SEND_INVITATION_FLAG_ISOLATED); + base::Process child_process = LaunchChildTestClient( + "BrokenTransportClient", &primordial_pipe, 1, TransportType::kChannel, + MOJO_SEND_INVITATION_FLAG_ISOLATED); EXPECT_EQ(MOJO_RESULT_OK, WaitForSignals(primordial_pipe, MOJO_HANDLE_SIGNAL_PEER_CLOSED));
diff --git a/mojo/core/ipcz_driver/invitation.cc b/mojo/core/ipcz_driver/invitation.cc index 80c4cf0..ef55e9a 100644 --- a/mojo/core/ipcz_driver/invitation.cc +++ b/mojo/core/ipcz_driver/invitation.cc
@@ -89,9 +89,15 @@ return IPCZ_INVALID_DRIVER_HANDLE; } + Channel::Endpoint channel_endpoint; + if (endpoint.type == MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL_SERVER) { + channel_endpoint = PlatformChannelServerEndpoint(std::move(handle)); + } else { + channel_endpoint = PlatformChannelEndpoint(std::move(handle)); + } auto transport = base::MakeRefCounted<Transport>( - endpoint_types, PlatformChannelEndpoint(std::move(handle)), - std::move(remote_process), is_remote_process_untrusted); + endpoint_types, std::move(channel_endpoint), std::move(remote_process), + is_remote_process_untrusted); transport->SetErrorHandler(error_handler, error_handler_context); transport->set_leak_channel_on_shutdown(options.leak_channel_on_shutdown); transport->set_is_peer_trusted(options.is_peer_trusted);
diff --git a/mojo/core/ipcz_driver/transport.cc b/mojo/core/ipcz_driver/transport.cc index e797e92b..fa572f7 100644 --- a/mojo/core/ipcz_driver/transport.cc +++ b/mojo/core/ipcz_driver/transport.cc
@@ -25,6 +25,7 @@ #include "mojo/public/cpp/platform/platform_channel.h" #include "mojo/public/cpp/platform/platform_channel_endpoint.h" #include "mojo/public/cpp/platform/platform_handle.h" +#include "third_party/abseil-cpp/absl/types/variant.h" #include "third_party/ipcz/include/ipcz/ipcz.h" #if BUILDFLAG(IS_WIN) @@ -200,7 +201,7 @@ } // namespace Transport::Transport(EndpointTypes endpoint_types, - PlatformChannelEndpoint endpoint, + Channel::Endpoint endpoint, base::Process remote_process, bool is_remote_process_untrusted) : endpoint_types_(endpoint_types), @@ -213,7 +214,7 @@ // static scoped_refptr<Transport> Transport::Create(EndpointTypes endpoint_types, - PlatformChannelEndpoint endpoint, + Channel::Endpoint endpoint, base::Process remote_process, bool is_remote_process_untrusted) { return base::MakeRefCounted<Transport>(endpoint_types, std::move(endpoint), @@ -278,7 +279,7 @@ std::vector<PendingTransmission> pending_transmissions; { base::AutoLock lock(lock_); - if (channel_ || !inactive_endpoint_.is_valid()) { + if (channel_ || !IsEndpointValid()) { return false; } @@ -350,7 +351,7 @@ scoped_refptr<Channel> channel; { base::AutoLock lock(lock_); - if (inactive_endpoint_.is_valid()) { + if (IsEndpointValid()) { PendingTransmission transmission; transmission.bytes = std::vector<uint8_t>(data.begin(), data.end()); transmission.handles = std::move(platform_handles); @@ -588,8 +589,10 @@ DCHECK_EQ(handles.size(), 1u); #endif - CHECK(inactive_endpoint_.is_valid()); - handles[0] = inactive_endpoint_.TakePlatformHandle(); + DCHECK(IsEndpointValid()); + DCHECK(absl::holds_alternative<PlatformChannelEndpoint>(inactive_endpoint_)); + handles[0] = absl::get<PlatformChannelEndpoint>(inactive_endpoint_) + .TakePlatformHandle(); return true; } @@ -667,6 +670,18 @@ self = std::move(self_reference_for_channel_); } +bool Transport::IsEndpointValid() const { + return absl::visit(base::Overloaded{ + [](const PlatformChannelEndpoint& endpoint) { + return endpoint.is_valid(); + }, + [](const PlatformChannelServerEndpoint& endpoint) { + return endpoint.is_valid(); + }, + }, + inactive_endpoint_); +} + bool Transport::CanTransmitHandles() const { #if BUILDFLAG(IS_WIN) // On Windows, we can transmit handles only if at least one endpoint is a
diff --git a/mojo/core/ipcz_driver/transport.h b/mojo/core/ipcz_driver/transport.h index 9642910..1472037 100644 --- a/mojo/core/ipcz_driver/transport.h +++ b/mojo/core/ipcz_driver/transport.h
@@ -41,7 +41,7 @@ EndpointType destination; }; Transport(EndpointTypes endpoint_types, - PlatformChannelEndpoint endpoint, + Channel::Endpoint endpoint, base::Process remote_process, bool is_remote_process_untrusted = false); @@ -49,7 +49,7 @@ // than MakeRefCounted<T>. static scoped_refptr<Transport> Create( EndpointTypes endpoint_types, - PlatformChannelEndpoint endpoint, + Channel::Endpoint endpoint, base::Process remote_process = base::Process(), bool is_remote_process_untrusted = false); @@ -93,7 +93,7 @@ // invalidating the transport. May only be called on a Transport which has not // yet been activated, and only when the channel endpoint is not a server. PlatformChannelEndpoint TakeEndpoint() { - return std::move(inactive_endpoint_); + return std::move(absl::get<PlatformChannelEndpoint>(inactive_endpoint_)); } // Handles reports of bad activity from ipcz, resulting from parcel rejection @@ -168,6 +168,7 @@ ~Transport() override; + bool IsEndpointValid() const; bool CanTransmitHandles() const; // Indicates whether this transport should serialize its remote process handle @@ -208,7 +209,7 @@ // start its underlying Channel instance once activated. Not guarded by a lock // since it must not accessed beyond activation, where thread safety becomes a // factor. - PlatformChannelEndpoint inactive_endpoint_; + Channel::Endpoint inactive_endpoint_; base::Lock lock_; scoped_refptr<Channel> channel_ GUARDED_BY(lock_);
diff --git a/mojo/core/node_controller.cc b/mojo/core/node_controller.cc index 5bb1939..b4998b0 100644 --- a/mojo/core/node_controller.cc +++ b/mojo/core/node_controller.cc
@@ -162,6 +162,21 @@ target_process.IsValid() ? target_process.Duplicate() : base::Process(), std::move(connection_params), process_error_callback); +#if BUILDFLAG(IS_WIN) + // On Windows, if target_process is invalid it means it's elevated or running + // in another session so a named pipe should be used instead. + if (!target_process.IsValid()) { + handle_policy = Channel::HandlePolicy::kRejectHandles; + NamedPlatformChannel::Options options; + NamedPlatformChannel named_channel(options); + node_connection_params = + ConnectionParams(named_channel.TakeServerEndpoint()); + node_connection_params.set_is_untrusted_process(is_untrusted_process); + broker_host->SendNamedChannel(named_channel.GetServerName()); + return node_connection_params; + } +#endif + // Sync connections usurp the passed endpoint and use it for the sync broker // channel. A new channel is created here for the NodeChannel and sent over // a sync broker message to the client. @@ -416,48 +431,6 @@ // |BIND_SYNC_BROKER| message from the invited client. node_connection_params = std::move(connection_params); } else { -#if defined(IS_WIN) - // On Windows, if `target_process` is invalid we can't duplicate a pipe - // handle to the remote client. In that case we instead open a new named - // pipe and send the client its name via the broker. Once connected, the new - // named pipe will be used for the client Channel. - if (!target_process.IsValid()) { - NamedPlatformChannel::Options options; - NamedPlatformChannel named_channel(options); - - const bool is_untrusted_process = - connection_params.is_untrusted_process(); - BrokerHost* broker_host = - new BrokerHost(base::Process(), std::move(connection_params), - process_error_callback); - broker_host->SendNamedChannel(named_channel.GetServerName()); - - PlatformChannelServer::WaitForConnection( - named_channel.TakeServerEndpoint(), - base::BindOnce( - [](base::Process target_process, - const ports::NodeName& temporary_node_name, - const ProcessErrorCallback& process_error_callback, - bool is_untrusted_process, - scoped_refptr<NodeController> node_controller, - PlatformChannelEndpoint endpoint) { - if (!endpoint.is_valid()) { - return; - } - - ConnectionParams params(std::move(endpoint)); - params.set_is_untrusted_process(is_untrusted_process); - node_controller->FinishSendBrokerClientInvitationOnIOThread( - std::move(target_process), std::move(params), - temporary_node_name, Channel::HandlePolicy::kRejectHandles, - process_error_callback); - }, - std::move(target_process), temporary_node_name, - process_error_callback, is_untrusted_process, this)); - return; - } -#endif - absl::optional<ConnectionParams> params = CreateSyncNodeConnectionParams( target_process, std::move(connection_params), process_error_callback, handle_policy); @@ -471,26 +444,14 @@ node_connection_params = std::move(*params); } - FinishSendBrokerClientInvitationOnIOThread( - std::move(target_process), std::move(node_connection_params), - temporary_node_name, handle_policy, process_error_callback); -#else // !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_FUCHSIA) - FinishSendBrokerClientInvitationOnIOThread( - std::move(target_process), std::move(connection_params), - temporary_node_name, Channel::HandlePolicy::kAcceptHandles, + scoped_refptr<NodeChannel> channel = NodeChannel::Create( + this, std::move(node_connection_params), handle_policy, io_task_runner_, process_error_callback); +#else // !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_FUCHSIA) + scoped_refptr<NodeChannel> channel = NodeChannel::Create( + this, std::move(connection_params), Channel::HandlePolicy::kAcceptHandles, + io_task_runner_, process_error_callback); #endif // !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_FUCHSIA) -} - -void NodeController::FinishSendBrokerClientInvitationOnIOThread( - base::Process target_process, - ConnectionParams connection_params, - ports::NodeName temporary_node_name, - Channel::HandlePolicy handle_policy, - const ProcessErrorCallback& process_error_callback) { - scoped_refptr<NodeChannel> channel = - NodeChannel::Create(this, std::move(connection_params), handle_policy, - io_task_runner_, process_error_callback); // We set up the invitee channel with a temporary name so it can be identified // as a pending invitee if it writes any messages to the channel. We may start
diff --git a/mojo/core/node_controller.h b/mojo/core/node_controller.h index 70a914c..80651533 100644 --- a/mojo/core/node_controller.h +++ b/mojo/core/node_controller.h
@@ -188,15 +188,8 @@ void SendBrokerClientInvitationOnIOThread( base::Process target_process, ConnectionParams connection_params, - ports::NodeName temporary_node_name, + ports::NodeName token, const ProcessErrorCallback& process_error_callback); - void FinishSendBrokerClientInvitationOnIOThread( - base::Process target_process, - ConnectionParams connection_params, - ports::NodeName temporary_node_name, - Channel::HandlePolicy handle_policy, - const ProcessErrorCallback& process_error_callback); - void AcceptBrokerClientInvitationOnIOThread( ConnectionParams connection_params, absl::optional<PlatformHandle> broker_host_handle);
diff --git a/mojo/public/cpp/platform/BUILD.gn b/mojo/public/cpp/platform/BUILD.gn index 95326ae7..5c07c918 100644 --- a/mojo/public/cpp/platform/BUILD.gn +++ b/mojo/public/cpp/platform/BUILD.gn
@@ -28,21 +28,9 @@ sources += [ "socket_utils_posix.cc" ] } - if (is_win || is_mac || (is_posix && !is_nacl)) { - public += [ "platform_channel_server.h" ] - sources += [ "platform_channel_server.cc" ] - } - if (is_win) { public += [ "platform_handle_security_util_win.h" ] - sources += [ - "platform_channel_server_win.cc", - "platform_handle_security_util_win.cc", - ] - } else if (is_mac) { - sources += [ "platform_channel_server_mac.cc" ] - } else if (is_posix && !is_nacl) { - sources += [ "platform_channel_server_posix.cc" ] + sources += [ "platform_handle_security_util_win.cc" ] } public_deps = [
diff --git a/mojo/public/cpp/platform/named_platform_channel.h b/mojo/public/cpp/platform/named_platform_channel.h index 455a9fa..c8e19615 100644 --- a/mojo/public/cpp/platform/named_platform_channel.h +++ b/mojo/public/cpp/platform/named_platform_channel.h
@@ -87,8 +87,8 @@ // named pipe server; on POSIX it's a bound, listening domain socket. In each // case it should accept a single new connection. // - // Use with PlatformChannelServer to wait for a new connection, yielding a - // PlatformChannelEndpoint that is usable with the Mojo invitations API. + // Use the handle to send or receive an invitation, with the endpoint type as + // |MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL_SERVER|. [[nodiscard]] PlatformChannelServerEndpoint TakeServerEndpoint() { return std::move(server_endpoint_); }
diff --git a/mojo/public/cpp/platform/platform_channel_server.cc b/mojo/public/cpp/platform/platform_channel_server.cc deleted file mode 100644 index f9cb895..0000000 --- a/mojo/public/cpp/platform/platform_channel_server.cc +++ /dev/null
@@ -1,52 +0,0 @@ -// Copyright 2023 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "mojo/public/cpp/platform/platform_channel_server.h" - -#include <memory> -#include <utility> - -namespace mojo { - -PlatformChannelServer::PlatformChannelServer() = default; - -PlatformChannelServer::~PlatformChannelServer() = default; - -// static -void PlatformChannelServer::WaitForConnection( - PlatformChannelServerEndpoint server_endpoint, - ConnectionCallback callback) { - auto server = std::make_unique<PlatformChannelServer>(); - auto* server_ptr = server.get(); - auto wrapped_callback = base::BindOnce( - [](std::unique_ptr<PlatformChannelServer> server, - PlatformChannelServer::ConnectionCallback callback, - PlatformChannelEndpoint endpoint) { - std::move(callback).Run(std::move(endpoint)); - }, - std::move(server), std::move(callback)); - if (!server_ptr->TryListen(server_endpoint, wrapped_callback)) { - base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask( - FROM_HERE, - base::BindOnce(std::move(wrapped_callback), PlatformChannelEndpoint())); - } -} - -bool PlatformChannelServer::TryListen( - PlatformChannelServerEndpoint& server_endpoint, - ConnectionCallback& callback) { - auto listener = Listener::Create(); - if (!listener->Start(server_endpoint, callback)) { - return false; - } - - listener_ = std::move(listener); - return true; -} - -void PlatformChannelServer::Stop() { - listener_.reset(); -} - -} // namespace mojo
diff --git a/mojo/public/cpp/platform/platform_channel_server.h b/mojo/public/cpp/platform/platform_channel_server.h deleted file mode 100644 index 3d9db8a4..0000000 --- a/mojo/public/cpp/platform/platform_channel_server.h +++ /dev/null
@@ -1,89 +0,0 @@ -// Copyright 2023 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MOJO_PUBLIC_CPP_PLATFORM_PLATFORM_CHANNEL_SERVER_H_ -#define MOJO_PUBLIC_CPP_PLATFORM_PLATFORM_CHANNEL_SERVER_H_ - -#include <memory> - -#include "base/component_export.h" -#include "base/functional/callback.h" -#include "base/task/single_thread_task_runner.h" -#include "mojo/public/cpp/platform/platform_channel_endpoint.h" -#include "mojo/public/cpp/platform/platform_channel_server_endpoint.h" - -namespace mojo { - -// PlatformChannelServer takes ownership of a PlatformChannelServerEndpoint -// and listens for a single incoming client connection. -// -// This class is not thread-safe and must be used on a thread which runs an I/O -// MessagePump. -class COMPONENT_EXPORT(MOJO_CPP_PLATFORM) PlatformChannelServer { - public: - using ConnectionCallback = base::OnceCallback<void(PlatformChannelEndpoint)>; - - // Implemented for each supported platform. - class COMPONENT_EXPORT(MOJO_CPP_PLATFORM) Listener { - public: - virtual ~Listener() = default; - - // Implemented for each supported platform. - static std::unique_ptr<Listener> Create(); - - // Attempts to start listening on `server_endpoint`. Returns true on success - // or false on failure. Same semantics as Listen() below, which calls this. - virtual bool Start(PlatformChannelServerEndpoint& server_endpoint, - ConnectionCallback& callback) = 0; - }; - - PlatformChannelServer(); - - // Destruction implicitly stops the listener if started, ensuring the - // ConnectionCallback will not be called beyoned the lifetime of this object. - ~PlatformChannelServer(); - - // Spins up a PlatformChannelServer on the current (I/O) task runner to listen - // on `server_endpoint` for an incoming connection. `callback` is always - // called eventually, as long as the calling task runner is still running when - // either the server accepts a connection or is disconnected. If disconnected, - // `callback` receives an invalid endpoint. - static void WaitForConnection(PlatformChannelServerEndpoint server_endpoint, - ConnectionCallback callback); - - // Listens on `server_endpoint` for a single connection, invoking `callback` - // once it arrives. Must not be called on a server that is already listening. - // - // If the server endpoint is disconnected before a connection is received, - // the callback will be invoked with an invalid endpoint. - // - // If the server is stopped before a connection is received, `callback` will - // not be called. - // - // If the server could not listen on the given endpoint, this returns false - // and `callback` is never called. Otherwise it returns true. - // - // This takes ownership of (i.e. moves) `server_endpoint` and `callback` if - // and only if it returns true. - bool TryListen(PlatformChannelServerEndpoint& server_endpoint, - ConnectionCallback& callback); - - // Same as above, but takes a callback by value for convenience when the - // doesn't care about retaining the arguments in the failure case. - bool Listen(PlatformChannelServerEndpoint server_endpoint, - ConnectionCallback callback) { - return TryListen(server_endpoint, callback); - } - - // Stops listening for new connections immediately. The callback given to - // Listen() can no longer be invoked once this is called. - void Stop(); - - private: - std::unique_ptr<Listener> listener_; -}; - -} // namespace mojo - -#endif // MOJO_PUBLIC_CPP_PLATFORM_PLATFORM_CHANNEL_SERVER_H_
diff --git a/mojo/public/cpp/platform/platform_channel_server_endpoint.h b/mojo/public/cpp/platform/platform_channel_server_endpoint.h index 6229a076..c741b87c 100644 --- a/mojo/public/cpp/platform/platform_channel_server_endpoint.h +++ b/mojo/public/cpp/platform/platform_channel_server_endpoint.h
@@ -11,10 +11,9 @@ namespace mojo { // A PlatformHandle with a little extra type information to convey that it's -// a channel server endpoint, i.e. a handle that should be used with -// PlatformChannelServer to wait for a new connection and ultimately provide -// a connected PlatformChannelEndpoint suitable for use with the Mojo -// invitations API. +// a channel server endpoint, i.e. a handle that can be used to send invitations +// as |MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL_SERVER| to a remote +// PlatformChannelEndpoint. class COMPONENT_EXPORT(MOJO_CPP_PLATFORM) PlatformChannelServerEndpoint { public: PlatformChannelServerEndpoint();
diff --git a/mojo/public/cpp/platform/platform_channel_server_mac.cc b/mojo/public/cpp/platform/platform_channel_server_mac.cc deleted file mode 100644 index 3eb32fa..0000000 --- a/mojo/public/cpp/platform/platform_channel_server_mac.cc +++ /dev/null
@@ -1,66 +0,0 @@ -// Copyright 2023 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "mojo/public/cpp/platform/platform_channel_server.h" - -#include <memory> -#include <utility> - -#include "base/check.h" -#include "base/memory/weak_ptr.h" -#include "base/task/sequenced_task_runner.h" -#include "mojo/public/cpp/platform/platform_channel_endpoint.h" -#include "mojo/public/cpp/platform/platform_handle.h" - -namespace mojo { - -namespace { - -// NOTE: On macOS, PlatformChannelServerEndpoint is not special, as they need to -// perform the same connection handshake as any other PlatformChannelEndpoint. -// PlatformChannelServer acts as a simple passthrough implementation for -// compatibility with application logic on other platforms. -class ListenerImpl : public PlatformChannelServer::Listener { - public: - ListenerImpl() = default; - ~ListenerImpl() override = default; - - // PlatformChannelServer::Listener: - bool Start(PlatformChannelServerEndpoint& server_endpoint, - PlatformChannelServer::ConnectionCallback& callback) override { - if (!server_endpoint.is_valid() || - !server_endpoint.platform_handle().is_mach_receive()) { - return false; - } - - // Invoke the callback asynchronously to guard against re-entrancy issues. - // This simply repackages the server endpoint as a PlatformChannelEndpoint, - // since they're functionally equivalent on macOS. Note that we post the - // task as a WeakPtr-bound method to ensure that it doesn't run if the - // Listener is destroyed first. - PlatformChannelEndpoint endpoint{server_endpoint.TakePlatformHandle()}; - base::SequencedTaskRunner::GetCurrentDefault()->PostTask( - FROM_HERE, base::BindOnce(&ListenerImpl::RunCallback, - weak_ptr_factory_.GetWeakPtr(), - std::move(callback), std::move(endpoint))); - return true; - } - - private: - void RunCallback(PlatformChannelServer::ConnectionCallback callback, - PlatformChannelEndpoint endpoint) { - std::move(callback).Run(std::move(endpoint)); - } - - base::WeakPtrFactory<ListenerImpl> weak_ptr_factory_{this}; -}; - -} // namespace - -std::unique_ptr<PlatformChannelServer::Listener> -PlatformChannelServer::Listener::Create() { - return std::make_unique<ListenerImpl>(); -} - -} // namespace mojo
diff --git a/mojo/public/cpp/platform/platform_channel_server_posix.cc b/mojo/public/cpp/platform/platform_channel_server_posix.cc deleted file mode 100644 index 914c93e..0000000 --- a/mojo/public/cpp/platform/platform_channel_server_posix.cc +++ /dev/null
@@ -1,90 +0,0 @@ -// Copyright 2023 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "mojo/public/cpp/platform/platform_channel_server.h" - -#include <memory> -#include <utility> - -#include "base/check.h" -#include "base/files/scoped_file.h" -#include "base/message_loop/message_pump_for_io.h" -#include "base/notreached.h" -#include "base/task/current_thread.h" -#include "mojo/public/cpp/platform/platform_channel_endpoint.h" -#include "mojo/public/cpp/platform/platform_handle.h" -#include "mojo/public/cpp/platform/socket_utils_posix.h" - -namespace mojo { - -namespace { - -class ListenerImpl : public PlatformChannelServer::Listener, - public base::MessagePumpForIO::FdWatcher { - public: - ListenerImpl() : watch_controller_(FROM_HERE) {} - ~ListenerImpl() override = default; - - // PlatformChannelServer::Listener: - bool Start(PlatformChannelServerEndpoint& server_endpoint, - PlatformChannelServer::ConnectionCallback& callback) override { - if (!server_endpoint.is_valid()) { - return false; - } - - base::ScopedFD server = server_endpoint.TakePlatformHandle().TakeFD(); - if (!base::CurrentIOThread::Get()->WatchFileDescriptor( - server.get(), /*persistent=*/true, - base::MessagePumpForIO::WATCH_READ, &watch_controller_, this)) { - return false; - } - - server_ = std::move(server); - callback_ = std::move(callback); - return true; - } - - // base::MessagePumpForIO::FdWatcher: - void OnFileCanReadWithoutBlocking(int fd) override { - base::ScopedFD socket; - CHECK_EQ(fd, server_.get()); - if (!AcceptSocketConnection(fd, &socket)) { - // Unrecoverable error, e.g. socket disconnection. Fail. - Stop(); - std::move(callback_).Run({}); - return; - } - - if (!socket.is_valid()) { - // Transient failure; a second connection attempt might succeed. - return; - } - - Stop(); - std::move(callback_).Run( - PlatformChannelEndpoint{PlatformHandle{std::move(socket)}}); - } - - void OnFileCanWriteWithoutBlocking(int fd) override { NOTREACHED(); } - - private: - void Stop() { - CHECK(server_.is_valid()); - watch_controller_.StopWatchingFileDescriptor(); - server_.reset(); - } - - base::ScopedFD server_; - PlatformChannelServer::ConnectionCallback callback_; - base::MessagePumpForIO::FdWatchController watch_controller_; -}; - -} // namespace - -std::unique_ptr<PlatformChannelServer::Listener> -PlatformChannelServer::Listener::Create() { - return std::make_unique<ListenerImpl>(); -} - -} // namespace mojo
diff --git a/mojo/public/cpp/platform/platform_channel_server_win.cc b/mojo/public/cpp/platform/platform_channel_server_win.cc deleted file mode 100644 index 08b31902f..0000000 --- a/mojo/public/cpp/platform/platform_channel_server_win.cc +++ /dev/null
@@ -1,134 +0,0 @@ -// Copyright 2023 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "mojo/public/cpp/platform/platform_channel_server.h" - -#include <windows.h> - -#include <cstring> -#include <memory> -#include <utility> - -#include "base/check.h" -#include "base/memory/weak_ptr.h" -#include "base/task/current_thread.h" -#include "base/task/sequenced_task_runner.h" -#include "base/win/object_watcher.h" -#include "base/win/scoped_handle.h" -#include "mojo/public/cpp/platform/platform_channel_endpoint.h" -#include "mojo/public/cpp/platform/platform_handle.h" - -namespace mojo { - -namespace { - -class ListenerImpl : public PlatformChannelServer::Listener, - public base::win::ObjectWatcher::Delegate { - public: - ListenerImpl() { - memset(&connect_overlapped_, 0, sizeof(connect_overlapped_)); - } - - ~ListenerImpl() override { - if (server_.is_valid()) { - ::CancelIo(server_.get()); - } - } - - // PlatformChannelServer::Listener: - bool Start(PlatformChannelServerEndpoint& server_endpoint, - PlatformChannelServer::ConnectionCallback& callback) override { - connect_event_.Set(::CreateEvent(NULL, TRUE, FALSE, NULL)); - if (!connect_event_.is_valid()) { - return false; - } - - connect_overlapped_.hEvent = connect_event_.get(); - if (!event_watcher_.StartWatchingOnce(connect_event_.get(), this)) { - return false; - } - - base::win::ScopedHandle server = - server_endpoint.TakePlatformHandle().TakeHandle(); - BOOL ok = ::ConnectNamedPipe(server.get(), &connect_overlapped_); - if (ok) { - // This call should always fail with ERROR_IO_PENDING or - // ERROR_PIPE_CONNECTED. - return false; - } - - const DWORD error = ::GetLastError(); - switch (error) { - case ERROR_PIPE_CONNECTED: - // Already connected. Invoke the callback asynchronously to avoid any - // potential re-entrancy issues in the caller. The task is posted with - // a WeakPtr-bound method to ensure that it doesn't run if the server - // is stopped first. - event_watcher_.StopWatching(); - connect_event_.Close(); - base::SequencedTaskRunner::GetCurrentDefault()->PostTask( - FROM_HERE, base::BindOnce(&ListenerImpl::RunCallback, - weak_ptr_factory_.GetWeakPtr(), - std::move(callback), std::move(server))); - break; - - case ERROR_IO_PENDING: - // Will continue in OnIOCompleted whenever the event is signaled. - break; - - default: - // Fail. - connect_event_.Close(); - return false; - } - - server_ = std::move(server); - callback_ = std::move(callback); - return true; - } - - // base::win::ObjectWatcher: - void OnObjectSignaled(HANDLE object) override { - // Event signaled. Check the status of the pipe. The only success case is - // when ConnectNamedPipe() returns ERROR_PIPE_CONNECTED here. - CHECK_EQ(object, connect_event_.get()); - BOOL ok = ::ConnectNamedPipe(server_.get(), &connect_overlapped_); - if (ok || ::GetLastError() != ERROR_PIPE_CONNECTED) { - std::move(callback_).Run({}); - return; - } - - // Success. Pass ownership of the connected pipe to the user-provided - // callback. - connect_event_.Close(); - std::move(callback_).Run( - PlatformChannelEndpoint{PlatformHandle{std::move(server_)}}); - } - - private: - void RunCallback(PlatformChannelServer::ConnectionCallback callback, - base::win::ScopedHandle server) { - std::move(callback).Run( - PlatformChannelEndpoint{PlatformHandle{std::move(server)}}); - } - - base::win::ScopedHandle server_; - - OVERLAPPED connect_overlapped_; - base::win::ScopedHandle connect_event_; - base::win::ObjectWatcher event_watcher_; - - PlatformChannelServer::ConnectionCallback callback_; - - base::WeakPtrFactory<ListenerImpl> weak_ptr_factory_{this}; -}; - -} // namespace - -std::unique_ptr<PlatformChannelServer::Listener> -PlatformChannelServer::Listener::Create() { - return std::make_unique<ListenerImpl>(); -} - -} // namespace mojo
diff --git a/mojo/public/cpp/platform/tests/BUILD.gn b/mojo/public/cpp/platform/tests/BUILD.gn index 66de64e..8a7e7c9 100644 --- a/mojo/public/cpp/platform/tests/BUILD.gn +++ b/mojo/public/cpp/platform/tests/BUILD.gn
@@ -14,12 +14,4 @@ "//mojo/public/cpp/system", "//testing/gtest", ] - - if (is_win || is_mac || (is_posix && !is_nacl)) { - sources += [ "platform_channel_server_unittest.cc" ] - deps += [ - "//base/test:test_support", - "//mojo/core/embedder", - ] - } }
diff --git a/mojo/public/cpp/platform/tests/DEPS b/mojo/public/cpp/platform/tests/DEPS index d11274b53..ef8ad28 100644 --- a/mojo/public/cpp/platform/tests/DEPS +++ b/mojo/public/cpp/platform/tests/DEPS
@@ -1,4 +1,3 @@ include_rules = [ - "+mojo/core", "+mojo/public", ]
diff --git a/mojo/public/cpp/platform/tests/platform_channel_server_unittest.cc b/mojo/public/cpp/platform/tests/platform_channel_server_unittest.cc deleted file mode 100644 index 48c1bc3..0000000 --- a/mojo/public/cpp/platform/tests/platform_channel_server_unittest.cc +++ /dev/null
@@ -1,252 +0,0 @@ -// Copyright 2023 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "mojo/public/cpp/platform/platform_channel_server.h" - -#include <tuple> -#include <utility> - -#include "base/containers/span.h" -#include "base/files/scoped_temp_dir.h" -#include "base/functional/callback.h" -#include "base/run_loop.h" -#include "base/task/single_thread_task_runner.h" -#include "base/test/bind.h" -#include "base/test/task_environment.h" -#include "build/build_config.h" -#include "mojo/core/channel.h" -#include "mojo/public/cpp/platform/named_platform_channel.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" - -namespace mojo { -namespace { - -class RunOnDestruction { - public: - template <typename Fn> - explicit RunOnDestruction(Fn fn) - : callback_(base::BindLambdaForTesting(fn)) {} - RunOnDestruction(RunOnDestruction&&) = default; - ~RunOnDestruction() { - if (callback_) { - std::move(callback_).Run(); - } - } - - private: - base::OnceClosure callback_; -}; - -class TestChannel : public core::Channel::Delegate { - public: - explicit TestChannel(PlatformChannelEndpoint endpoint) - : io_task_runner_(base::SingleThreadTaskRunner::GetCurrentDefault()), - channel_( - core::Channel::Create(this, - core::ConnectionParams{std::move(endpoint)}, - core::Channel::HandlePolicy::kRejectHandles, - io_task_runner_)) { - channel_->Start(); - } - - ~TestChannel() override { - // We pump the IO task queue after ShutDown() to ensure completion, as - // Channel implementions post a cleanup task there. - base::RunLoop shutdown_flush; - channel_->ShutDown(); - io_task_runner_->PostTask(FROM_HERE, shutdown_flush.QuitClosure()); - shutdown_flush.Run(); - } - - void SendMessage(const std::string& message) { - auto data = base::make_span( - reinterpret_cast<const uint8_t*>(message.data()), message.size()); - channel_->Write(core::Channel::Message::CreateIpczMessage(data, {})); - } - - std::string WaitForSingleMessage() { - wait_for_message_.Run(); - CHECK(received_message_); - return *received_message_; - } - - // core::Channel::Delegate: - bool IsIpczTransport() const override { - // We use Channel in ipcz mode because it's simpler. Doesn't matter if - // MojoIpcz is actually enabled. - return true; - } - - void OnChannelMessage(const void* payload, - size_t payload_size, - std::vector<PlatformHandle> handles) override { - received_message_ = - std::string(static_cast<const char*>(payload), payload_size); - std::move(quit_).Run(); - } - - void OnChannelError(core::Channel::Error error) override {} - - private: - const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; - const scoped_refptr<core::Channel> channel_; - base::RunLoop wait_for_message_; - base::OnceClosure quit_{wait_for_message_.QuitClosure()}; - absl::optional<std::string> received_message_; -}; - -class PlatformChannelServerTest : public testing::Test { - public: - PlatformChannelServerTest() { CHECK(temp_dir_.CreateUniqueTempDir()); } - - ~PlatformChannelServerTest() override = default; - - using NamedChannelDetails = std::tuple<PlatformChannelServerEndpoint, - NamedPlatformChannel::ServerName>; - NamedChannelDetails CreateRandomChannel() { - NamedPlatformChannel::Options options; -#if BUILDFLAG(IS_POSIX) - options.socket_dir = temp_dir_.GetPath(); -#endif - NamedPlatformChannel channel(options); - return {channel.TakeServerEndpoint(), channel.GetServerName()}; - } - - PlatformChannelServer& server() { return server_; } - - void VerifyEndToEndConnection(PlatformChannelEndpoint a, - PlatformChannelEndpoint b) { - TestChannel channel_a(std::move(a)); - TestChannel channel_b(std::move(b)); - - const std::string kMessage1 = "Hello, world?"; - const std::string kMessage2 = "Oh, hi world."; - channel_a.SendMessage(kMessage1); - channel_b.SendMessage(kMessage2); - EXPECT_EQ(kMessage2, channel_a.WaitForSingleMessage()); - EXPECT_EQ(kMessage1, channel_b.WaitForSingleMessage()); - } - - private: - base::ScopedTempDir temp_dir_; - base::test::TaskEnvironment task_environment_{ - base::test::TaskEnvironment::MainThreadType::IO}; - PlatformChannelServer server_; -}; - -TEST_F(PlatformChannelServerTest, ConnectAfterListen) { - // Basic test that a client can connect after Listen() and the server will - // invoke its user-provided callback with a new functioning endpoint. - auto [server_endpoint, name] = CreateRandomChannel(); - - base::RunLoop loop; - PlatformChannelEndpoint endpoint_a; - EXPECT_TRUE(server().Listen( - std::move(server_endpoint), - base::BindLambdaForTesting([&](PlatformChannelEndpoint endpoint) { - endpoint_a = std::move(endpoint); - loop.Quit(); - }))); - auto endpoint_b = NamedPlatformChannel::ConnectToServer(name); - EXPECT_TRUE(endpoint_b.is_valid()); - loop.Run(); - VerifyEndToEndConnection(std::move(endpoint_a), std::move(endpoint_b)); -} - -TEST_F(PlatformChannelServerTest, ConnectBeforeListen) { - // Basic test that a client can connect *before* Listen() and the server will - // still invoke its user-provided callback with a new functioning endpoint. - auto [server_endpoint, name] = CreateRandomChannel(); - - base::RunLoop loop; - auto endpoint_a = NamedPlatformChannel::ConnectToServer(name); - EXPECT_TRUE(endpoint_a.is_valid()); - PlatformChannelEndpoint endpoint_b; - EXPECT_TRUE(server().Listen( - std::move(server_endpoint), - base::BindLambdaForTesting([&](PlatformChannelEndpoint endpoint) { - endpoint_b = std::move(endpoint); - loop.Quit(); - }))); - loop.Run(); - VerifyEndToEndConnection(std::move(endpoint_a), std::move(endpoint_b)); -} - -TEST_F(PlatformChannelServerTest, WaitForConnection) { - // Tests the static WaitForConnection() helper. - auto [server_endpoint, name] = CreateRandomChannel(); - - base::RunLoop loop; - auto endpoint_a = NamedPlatformChannel::ConnectToServer(name); - PlatformChannelEndpoint endpoint_b; - PlatformChannelServer::WaitForConnection( - std::move(server_endpoint), - base::BindLambdaForTesting([&](PlatformChannelEndpoint endpoint) { - endpoint_b = std::move(endpoint); - loop.Quit(); - })); - loop.Run(); - VerifyEndToEndConnection(std::move(endpoint_a), std::move(endpoint_b)); -} - -TEST_F(PlatformChannelServerTest, NoCallbackAfterListenConnectStop) { - // Tests that the ConnectionCallback is never invoked after Stop(), even if - // we Listen() and the client connects immediately before the Stop() call. - auto [server_endpoint, name] = CreateRandomChannel(); - bool callback_invoked = false; - bool callback_destroyed = false; - base::RunLoop loop; - EXPECT_TRUE(server().Listen( - std::move(server_endpoint), - base::BindOnce( - // This callback should never run and should be destroyed when we - // Stop() below. - [](RunOnDestruction, bool* callback_invoked, - PlatformChannelEndpoint endpoint) { *callback_invoked = true; }, - // When the above callback is destroyed, this one will run. - RunOnDestruction([&] { - callback_destroyed = true; - loop.Quit(); - }), - &callback_invoked))); - auto endpoint = NamedPlatformChannel::ConnectToServer(name); - server().Stop(); - loop.Run(); - EXPECT_TRUE(callback_destroyed); - EXPECT_FALSE(callback_invoked); - EXPECT_TRUE(endpoint.is_valid()); -} - -TEST_F(PlatformChannelServerTest, NoCallbackAfterConnectListenStop) { - // Tests that the ConnectionCallback is never invoked after Stop(), even if - // the client connects before a Listen() which immediately precedes the Stop() - // call. - auto [server_endpoint, name] = CreateRandomChannel(); - bool callback_invoked = false; - bool callback_destroyed = false; - base::RunLoop loop; - auto endpoint = NamedPlatformChannel::ConnectToServer(name); - EXPECT_TRUE(endpoint.is_valid()); - EXPECT_TRUE(server().Listen( - std::move(server_endpoint), - base::BindOnce( - // This callback should never run and should be destroyed when we - // Stop() below. - [](RunOnDestruction, bool* callback_invoked, - PlatformChannelEndpoint endpoint) { *callback_invoked = true; }, - // When the above callback is destroyed, this one will run. - RunOnDestruction([&] { - callback_destroyed = true; - loop.Quit(); - }), - &callback_invoked))); - server().Stop(); - loop.Run(); - EXPECT_TRUE(callback_destroyed); - EXPECT_FALSE(callback_invoked); -} - -} // namespace -} // namespace mojo
diff --git a/mojo/public/cpp/system/invitation.cc b/mojo/public/cpp/system/invitation.cc index 42e0b46..7245722 100644 --- a/mojo/public/cpp/system/invitation.cc +++ b/mojo/public/cpp/system/invitation.cc
@@ -4,22 +4,14 @@ #include "mojo/public/cpp/system/invitation.h" -#include <memory> #include <tuple> -#include <utility> #include "base/numerics/safe_conversions.h" #include "build/build_config.h" -#include "mojo/core/embedder/embedder.h" #include "mojo/public/c/system/invitation.h" #include "mojo/public/c/system/platform_handle.h" -#include "mojo/public/cpp/platform/platform_channel_server.h" #include "mojo/public/cpp/system/platform_handle.h" -#if BUILDFLAG(IS_WIN) -#include <windows.h> -#endif - namespace mojo { namespace { @@ -110,38 +102,6 @@ std::ignore = invitation.release(); } -void WaitForServerConnection( - PlatformChannelServerEndpoint server_endpoint, - PlatformChannelServer::ConnectionCallback callback) { - core::GetIOTaskRunner()->PostTask( - FROM_HERE, - base::BindOnce(&PlatformChannelServer::WaitForConnection, - std::move(server_endpoint), std::move(callback))); -} - -base::Process CloneProcessFromHandle(base::ProcessHandle handle) { - if (handle == base::kNullProcessHandle) { - return base::Process{}; - } - -#if BUILDFLAG(IS_WIN) - // We can't use the hack below on Windows, because handle verification will - // explode when a new Process instance tries to own the already-owned - // `handle`. - HANDLE new_handle; - BOOL ok = - ::DuplicateHandle(::GetCurrentProcess(), handle, ::GetCurrentProcess(), - &new_handle, 0, FALSE, DUPLICATE_SAME_ACCESS); - CHECK(ok); - return base::Process(new_handle); -#else - base::Process temporary_owner(handle); - base::Process clone = temporary_owner.Duplicate(); - std::ignore = temporary_owner.Release(); - return clone; -#endif -} - } // namespace OutgoingInvitation::OutgoingInvitation() { @@ -209,20 +169,10 @@ base::ProcessHandle target_process, PlatformChannelServerEndpoint server_endpoint, const ProcessErrorCallback& error_callback) { - WaitForServerConnection( - std::move(server_endpoint), - base::BindOnce( - [](OutgoingInvitation invitation, base::Process target_process, - const ProcessErrorCallback& error_callback, - PlatformChannelEndpoint endpoint) { - SendInvitation(std::move(invitation.handle_), - target_process.Handle(), - endpoint.TakePlatformHandle(), - MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL, - invitation.extra_flags_, error_callback, ""); - }, - std::move(invitation), CloneProcessFromHandle(target_process), - error_callback)); + SendInvitation(std::move(invitation.handle_), target_process, + server_endpoint.TakePlatformHandle(), + MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL_SERVER, + invitation.extra_flags_, error_callback, ""); } // static @@ -241,7 +191,7 @@ PlatformChannelEndpoint channel_endpoint, base::StringPiece connection_name, base::ProcessHandle target_process) { - OutgoingInvitation invitation; + mojo::OutgoingInvitation invitation; ScopedMessagePipeHandle pipe = invitation.AttachMessagePipe(kIsolatedPipeName); SendInvitation(std::move(invitation.handle_), target_process, @@ -257,24 +207,14 @@ PlatformChannelServerEndpoint server_endpoint, base::StringPiece connection_name, base::ProcessHandle target_process) { - OutgoingInvitation invitation; + mojo::OutgoingInvitation invitation; ScopedMessagePipeHandle pipe = invitation.AttachMessagePipe(kIsolatedPipeName); - WaitForServerConnection( - std::move(server_endpoint), - base::BindOnce( - [](OutgoingInvitation invitation, base::Process target_process, - const std::string& connection_name, - PlatformChannelEndpoint endpoint) { - SendInvitation( - std::move(invitation.handle_), target_process.Handle(), - endpoint.TakePlatformHandle(), - MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL, - MOJO_SEND_INVITATION_FLAG_ISOLATED | invitation.extra_flags_, - ProcessErrorCallback(), connection_name); - }, - std::move(invitation), CloneProcessFromHandle(target_process), - std::string(connection_name))); + SendInvitation(std::move(invitation.handle_), target_process, + server_endpoint.TakePlatformHandle(), + MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL_SERVER, + MOJO_SEND_INVITATION_FLAG_ISOLATED | invitation.extra_flags_, + ProcessErrorCallback(), connection_name); return pipe; }
diff --git a/mojo/public/cpp/system/tests/invitation_unittest.cc b/mojo/public/cpp/system/tests/invitation_unittest.cc index 5a92c7d..e289a0eb 100644 --- a/mojo/public/cpp/system/tests/invitation_unittest.cc +++ b/mojo/public/cpp/system/tests/invitation_unittest.cc
@@ -59,15 +59,22 @@ const char kTransportTypeChannelServer[] = "channel-server"; #endif -class InvitationCppTest : public testing::Test, - public testing::WithParamInterface<TransportType> { +// TODO(https://crbug.com/1428561): Flaky on Tsan. +#if defined(THREAD_SANITIZER) +#define MAYBE_InvitationCppTest DISABLED_InvitationCppTest +#else +#define MAYBE_InvitationCppTest InvitationCppTest +#endif +class MAYBE_InvitationCppTest + : public testing::Test, + public testing::WithParamInterface<TransportType> { public: - InvitationCppTest() = default; + MAYBE_InvitationCppTest() = default; - InvitationCppTest(const InvitationCppTest&) = delete; - InvitationCppTest& operator=(const InvitationCppTest&) = delete; + MAYBE_InvitationCppTest(const MAYBE_InvitationCppTest&) = delete; + MAYBE_InvitationCppTest& operator=(const MAYBE_InvitationCppTest&) = delete; - ~InvitationCppTest() override = default; + ~MAYBE_InvitationCppTest() override = default; protected: void LaunchChildTestClient(const std::string& test_client_name, @@ -196,7 +203,7 @@ base::Process child_process_; }; -class TestClientBase : public InvitationCppTest { +class TestClientBase : public MAYBE_InvitationCppTest { public: TestClientBase(const TestClientBase&) = delete; TestClientBase& operator=(const TestClientBase&) = delete; @@ -237,7 +244,7 @@ const char kTestMessage1[] = "hello"; const char kTestMessage2[] = "hello"; -TEST_P(InvitationCppTest, Send) { +TEST_P(MAYBE_InvitationCppTest, Send) { ScopedMessagePipeHandle pipe; LaunchChildTestClient("CppSendClient", &pipe, 1, InvitationType::kNormal, GetParam()); @@ -251,7 +258,7 @@ CHECK_EQ(kTestMessage1, ReadMessage(pipe)); } -TEST_P(InvitationCppTest, SendIsolated) { +TEST_P(MAYBE_InvitationCppTest, SendIsolated) { ScopedMessagePipeHandle pipe; LaunchChildTestClient("CppSendIsolatedClient", &pipe, 1, InvitationType::kIsolated, GetParam()); @@ -264,7 +271,7 @@ CHECK_EQ(kTestMessage1, ReadMessage(pipe)); } -TEST_P(InvitationCppTest, SendWithMultiplePipes) { +TEST_P(MAYBE_InvitationCppTest, SendWithMultiplePipes) { ScopedMessagePipeHandle pipes[2]; LaunchChildTestClient("CppSendWithMultiplePipesClient", pipes, 2, InvitationType::kNormal, GetParam()); @@ -281,7 +288,7 @@ CHECK_EQ(kTestMessage2, ReadMessage(pipe1)); } -TEST(InvitationCppTest_NoParam, SendIsolatedInvitationWithDuplicateName) { +TEST(MAYBE_InvitationCppTest_NoParam, SendIsolatedInvitationWithDuplicateName) { if (mojo::core::IsMojoIpczEnabled()) { // This feature is not particularly useful in a world where isolated // connections are only supported between broker nodes. @@ -311,7 +318,7 @@ #define MAYBE_ProcessErrors ProcessErrors #endif -TEST_P(InvitationCppTest, MAYBE_ProcessErrors) { +TEST_P(MAYBE_InvitationCppTest, MAYBE_ProcessErrors) { ProcessErrorCallback actual_error_callback; ScopedMessagePipeHandle pipe; @@ -356,7 +363,7 @@ } INSTANTIATE_TEST_SUITE_P(All, - InvitationCppTest, + MAYBE_InvitationCppTest, testing::Values(TransportType::kChannel #if !BUILDFLAG(IS_FUCHSIA) ,
diff --git a/net/server/http_connection.cc b/net/server/http_connection.cc index 351ef23..0fee0cc 100644 --- a/net/server/http_connection.cc +++ b/net/server/http_connection.cc
@@ -160,7 +160,7 @@ HttpConnection::~HttpConnection() = default; void HttpConnection::SetWebSocket(std::unique_ptr<WebSocket> web_socket) { - DCHECK(!web_socket_ || !web_socket); + DCHECK(!web_socket_); web_socket_ = std::move(web_socket); }
diff --git a/net/server/http_server.cc b/net/server/http_server.cc index 6629c381..75d6bb41 100644 --- a/net/server/http_server.cc +++ b/net/server/http_server.cc
@@ -144,7 +144,6 @@ std::unique_ptr<HttpConnection> connection = std::move(it->second); id_to_connection_.erase(it); delegate_->OnClose(connection_id); - connection->SetWebSocket(nullptr); // The call stack might have callbacks which still have the pointer of // connection. Instead of referencing connection with ID all the time,
diff --git a/services/network/network_context.cc b/services/network/network_context.cc index 7301ba6..2800a88 100644 --- a/services/network/network_context.cc +++ b/services/network/network_context.cc
@@ -2307,7 +2307,8 @@ builder.SetCookieStore(std::move(cookie_store)); } - if (base::FeatureList::IsEnabled(features::kPrivateStateTokens)) { + if (base::FeatureList::IsEnabled(features::kPrivateStateTokens) || + base::FeatureList::IsEnabled(features::kFledgePst)) { trust_token_store_ = std::make_unique<PendingTrustTokenStore>(); base::FilePath trust_token_path;
diff --git a/services/network/network_service.cc b/services/network/network_service.cc index e51487d..be54504 100644 --- a/services/network/network_service.cc +++ b/services/network/network_service.cc
@@ -493,8 +493,8 @@ // static std::unique_ptr<NetworkService> NetworkService::CreateForTesting() { - auto network_service = std::make_unique<NetworkService>( - std::make_unique<service_manager::BinderRegistry>()); + auto network_service = + std::make_unique<NetworkService>(nullptr /* binder_registry */); network_service->InitMockNetworkChangeNotifierForTesting(); // IN-TEST return network_service; }
diff --git a/services/network/public/cpp/content_security_policy/content_security_policy.cc b/services/network/public/cpp/content_security_policy/content_security_policy.cc index 7261365..24a953fb4 100644 --- a/services/network/public/cpp/content_security_policy/content_security_policy.cc +++ b/services/network/public/cpp/content_security_policy/content_security_policy.cc
@@ -733,14 +733,8 @@ continue; } - // Discussed at https://github.com/WICG/nav-speculation/pull/209, and merged - // to the speculationrules explainer, - // https://github.com/WICG/nav-speculation/blob/main/triggers.md#content-security-policy. - // TODO(https://crbug.com/1382361): Have a patch spec and merge it to the - // upstream CSP spec. - if (base::FeatureList::IsEnabled( - features::kPrerender2ContentSecurityPolicyExtensions) && - base::EqualsCaseInsensitiveASCII(expression, + // https://wicg.github.io/nav-speculation/speculation-rules.html#content-security-policy + if (base::EqualsCaseInsensitiveASCII(expression, "'inline-speculation-rules'")) { if (directive_name == CSPDirectiveName::ScriptSrc || directive_name == CSPDirectiveName::ScriptSrcElem) { @@ -830,7 +824,7 @@ } // Parse the 'required-trusted-types-for' directive. -// https://w3c.github.io/webappsec-trusted-types/dist/spec/#require-trusted-types-for-csp-directive +// https://w3c.github.io/trusted-types/dist/spec/#require-trusted-types-for-csp-directive network::mojom::CSPRequireTrustedTypesFor ParseRequireTrustedTypesFor( base::StringPiece value, std::vector<std::string>& parsing_errors) { @@ -862,7 +856,7 @@ } // This implements tt-policy-name from -// https://w3c.github.io/webappsec-trusted-types/dist/spec/#trusted-types-csp-directive/ +// https://w3c.github.io/trusted-types/dist/spec/#trusted-types-csp-directive bool IsValidTrustedTypesPolicyName(base::StringPiece value) { return base::ranges::all_of(value, [](char c) { return base::IsAsciiAlpha(c) || base::IsAsciiDigit(c) || @@ -871,7 +865,7 @@ } // Parse the 'trusted-types' directive. -// https://w3c.github.io/webappsec-trusted-types/dist/spec/#trusted-types-csp-directive +// https://w3c.github.io/trusted-types/dist/spec/#trusted-types-csp-directive network::mojom::CSPTrustedTypesPtr ParseTrustedTypes( base::StringPiece value, std::vector<std::string>& parsing_errors) {
diff --git a/services/network/public/cpp/content_security_policy/content_security_policy_unittest.cc b/services/network/public/cpp/content_security_policy/content_security_policy_unittest.cc index 6ab63bc..74d027d 100644 --- a/services/network/public/cpp/content_security_policy/content_security_policy_unittest.cc +++ b/services/network/public/cpp/content_security_policy/content_security_policy_unittest.cc
@@ -1586,8 +1586,6 @@ } TEST(ContentSecurityPolicy, ParseInlineSpeculationRules) { - base::test::ScopedFeatureList scoped_feature_list( - features::kPrerender2ContentSecurityPolicyExtensions); std::vector<mojom::ContentSecurityPolicyPtr> script_src_policies = ParseCSP("script-src 'inline-speculation-rules'"); ASSERT_EQ(1u, script_src_policies.size());
diff --git a/services/network/public/cpp/features.cc b/services/network/public/cpp/features.cc index 884669e2..4dd799d7 100644 --- a/services/network/public/cpp/features.cc +++ b/services/network/public/cpp/features.cc
@@ -335,10 +335,6 @@ "PrefetchNoVarySearch", base::FEATURE_ENABLED_BY_DEFAULT); -BASE_FEATURE(kPrerender2ContentSecurityPolicyExtensions, - "Prerender2ContentSecurityPolicyExtensions", - base::FEATURE_ENABLED_BY_DEFAULT); - BASE_FEATURE(kLessChattyNetworkService, "LessChattyNetworkService", base::FEATURE_DISABLED_BY_DEFAULT);
diff --git a/services/network/public/cpp/features.h b/services/network/public/cpp/features.h index 0e3f1f9..bd0ad94 100644 --- a/services/network/public/cpp/features.h +++ b/services/network/public/cpp/features.h
@@ -127,12 +127,6 @@ COMPONENT_EXPORT(NETWORK_CPP) BASE_DECLARE_FEATURE(kPrefetchNoVarySearch); -// Enables the `inline-speculation-rules` source support in the -// Content-Security-Policy for Prerender2. -// https://crbug.com/1382361 -COMPONENT_EXPORT(NETWORK_CPP) -BASE_DECLARE_FEATURE(kPrerender2ContentSecurityPolicyExtensions); - // Enables UMA to track received GetCookiesString IPCs. This feature is enabled // by default, it is just here to allow some tests to disable it. These tests // make use of TaskEnvironment::FastForward with very long delays (days) which
diff --git a/services/network/public/mojom/content_security_policy.mojom b/services/network/public/mojom/content_security_policy.mojom index 527cc26..e0b7339a 100644 --- a/services/network/public/mojom/content_security_policy.mojom +++ b/services/network/public/mojom/content_security_policy.mojom
@@ -131,7 +131,7 @@ }; // The parsed value of the CSP directive 'trusted-types'. -// https://w3c.github.io/webappsec-trusted-types/dist/spec/#trusted-types-csp-directive +// https://w3c.github.io/trusted-types/dist/spec/#trusted-types-csp-directive struct CSPTrustedTypes { // The list of policies allowed by the 'trusted-types' directive. array<string> list; @@ -184,12 +184,12 @@ array<string> report_endpoints; // The parsed value of the directive 'require-trusted-types-for'. - // https://w3c.github.io/webappsec-trusted-types/dist/spec/#require-trusted-types-for-csp-directive + // https://w3c.github.io/trusted-types/dist/spec/#require-trusted-types-for-csp-directive CSPRequireTrustedTypesFor require_trusted_types_for = CSPRequireTrustedTypesFor.None; // The parsed value of the directive 'trusted-types'. - // https://w3c.github.io/webappsec-trusted-types/dist/spec/#trusted-types-csp-directive + // https://w3c.github.io/trusted-types/dist/spec/#trusted-types-csp-directive // Note: If this is null, the directive was not present. On the other side, if // this is a default CSPTrustedTypes struct with empty list, it means that the // directive was present with empty value, so policies may not be created and
diff --git a/testing/buildbot/chromium.chromiumos.json b/testing/buildbot/chromium.chromiumos.json index 22b3cc3..bfc5d84 100644 --- a/testing/buildbot/chromium.chromiumos.json +++ b/testing/buildbot/chromium.chromiumos.json
@@ -5886,9 +5886,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "isolate_profile_data": true, "merge": { "args": [], @@ -5900,8 +5900,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [ @@ -6057,9 +6057,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "isolate_profile_data": true, "merge": { "args": [], @@ -6071,8 +6071,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [ @@ -6209,9 +6209,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "isolate_profile_data": true, "merge": { "args": [], @@ -6223,8 +6223,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [
diff --git a/testing/buildbot/chromium.coverage.json b/testing/buildbot/chromium.coverage.json index 8a5749f..2e25899 100644 --- a/testing/buildbot/chromium.coverage.json +++ b/testing/buildbot/chromium.coverage.json
@@ -25738,9 +25738,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "isolate_profile_data": true, "merge": { "args": [], @@ -25752,8 +25752,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [ @@ -25909,9 +25909,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "isolate_profile_data": true, "merge": { "args": [], @@ -25923,8 +25923,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [ @@ -26061,9 +26061,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "isolate_profile_data": true, "merge": { "args": [], @@ -26075,8 +26075,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [
diff --git a/testing/buildbot/chromium.fyi.json b/testing/buildbot/chromium.fyi.json index 87df94e9..cd15e7c8 100644 --- a/testing/buildbot/chromium.fyi.json +++ b/testing/buildbot/chromium.fyi.json
@@ -46385,9 +46385,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -46398,8 +46398,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [ @@ -46556,9 +46556,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -46569,8 +46569,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [ @@ -46708,9 +46708,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -46721,8 +46721,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [ @@ -48228,9 +48228,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -48241,8 +48241,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [ @@ -48399,9 +48399,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -48412,8 +48412,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [ @@ -48551,9 +48551,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -48564,8 +48564,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [ @@ -49319,9 +49319,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -49332,8 +49332,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [
diff --git a/testing/buildbot/chromium.gpu.fyi.json b/testing/buildbot/chromium.gpu.fyi.json index 6e21bf0..bc6a377 100644 --- a/testing/buildbot/chromium.gpu.fyi.json +++ b/testing/buildbot/chromium.gpu.fyi.json
@@ -5736,6 +5736,380 @@ "GPU FYI Win x64 Builder (dbg)": {}, "GPU FYI Win x64 DX12 Vulkan Builder": {}, "GPU FYI Win x64 DX12 Vulkan Builder (dbg)": {}, + "Lacros FYI Release (octopus)": { + "additional_compile_targets": [ + "chromiumos_preflight" + ], + "isolated_scripts": [ + { + "args": [ + "context_lost", + "--show-stdout", + "--browser=lacros-chrome", + "--passthrough", + "-v", + "--stable-jobs", + "--extra-browser-args=--log-level=0 --js-flags=--expose-gc --use-cmd-decoder=passthrough --use-gl=angle", + "--deploy-lacros", + "--remote=variable_chromeos_device_hostname" + ], + "isolate_name": "telemetry_gpu_integration_test", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_isolated_script_merge.py" + }, + "name": "context_lost_passthrough_tests Ash ToT", + "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": [ + { + "device_type": "octopus", + "os": "ChromeOS", + "pool": "chrome.tests" + } + ], + "expiration": 21600, + "idempotent": false, + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/", + "trigger_script": { + "script": "//testing/trigger_scripts/chromeos_device_trigger.py" + }, + "variant_id": "Ash ToT" + }, + { + "args": [ + "gpu_process", + "--show-stdout", + "--browser=lacros-chrome", + "--passthrough", + "-v", + "--stable-jobs", + "--extra-browser-args=--log-level=0 --js-flags=--expose-gc", + "--deploy-lacros", + "--remote=variable_chromeos_device_hostname" + ], + "isolate_name": "telemetry_gpu_integration_test", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_isolated_script_merge.py" + }, + "name": "gpu_process_launch_tests Ash ToT", + "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": [ + { + "device_type": "octopus", + "os": "ChromeOS", + "pool": "chrome.tests" + } + ], + "expiration": 21600, + "idempotent": false, + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/", + "trigger_script": { + "script": "//testing/trigger_scripts/chromeos_device_trigger.py" + }, + "variant_id": "Ash ToT" + }, + { + "args": [ + "hardware_accelerated_feature", + "--show-stdout", + "--browser=lacros-chrome", + "--passthrough", + "-v", + "--stable-jobs", + "--extra-browser-args=--log-level=0 --js-flags=--expose-gc", + "--deploy-lacros", + "--remote=variable_chromeos_device_hostname" + ], + "isolate_name": "telemetry_gpu_integration_test", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_isolated_script_merge.py" + }, + "name": "hardware_accelerated_feature_tests Ash ToT", + "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": [ + { + "device_type": "octopus", + "os": "ChromeOS", + "pool": "chrome.tests" + } + ], + "expiration": 21600, + "idempotent": false, + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/", + "trigger_script": { + "script": "//testing/trigger_scripts/chromeos_device_trigger.py" + }, + "variant_id": "Ash ToT" + }, + { + "args": [ + "info_collection", + "--show-stdout", + "--browser=lacros-chrome", + "--passthrough", + "-v", + "--stable-jobs", + "--extra-browser-args=--log-level=0 --js-flags=--expose-gc --force_high_performance_gpu", + "--expected-vendor-id", + "0", + "--expected-device-id", + "0", + "--deploy-lacros", + "--remote=variable_chromeos_device_hostname" + ], + "isolate_name": "telemetry_gpu_integration_test", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_isolated_script_merge.py" + }, + "name": "info_collection_tests Ash ToT", + "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": [ + { + "device_type": "octopus", + "os": "ChromeOS", + "pool": "chrome.tests" + } + ], + "expiration": 21600, + "idempotent": false, + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/", + "trigger_script": { + "script": "//testing/trigger_scripts/chromeos_device_trigger.py" + }, + "variant_id": "Ash ToT" + }, + { + "args": [ + "maps", + "--show-stdout", + "--browser=lacros-chrome", + "--passthrough", + "-v", + "--stable-jobs", + "--extra-browser-args=--log-level=0 --js-flags=--expose-gc --use-cmd-decoder=passthrough --use-gl=angle", + "--dont-restore-color-profile-after-test", + "--test-machine-name", + "${buildername}", + "--deploy-lacros", + "--remote=variable_chromeos_device_hostname", + "--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 Ash ToT", + "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": [ + { + "device_type": "octopus", + "os": "ChromeOS", + "pool": "chrome.tests" + } + ], + "expiration": 21600, + "idempotent": false, + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/", + "trigger_script": { + "script": "//testing/trigger_scripts/chromeos_device_trigger.py" + }, + "variant_id": "Ash ToT" + }, + { + "args": [ + "pixel", + "--show-stdout", + "--browser=lacros-chrome", + "--passthrough", + "-v", + "--stable-jobs", + "--extra-browser-args=--log-level=0 --js-flags=--expose-gc --use-cmd-decoder=passthrough --use-gl=angle", + "--dont-restore-color-profile-after-test", + "--test-machine-name", + "${buildername}", + "--deploy-lacros", + "--remote=variable_chromeos_device_hostname", + "--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 Ash ToT", + "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": [ + { + "device_type": "octopus", + "os": "ChromeOS", + "pool": "chrome.tests" + } + ], + "expiration": 21600, + "idempotent": false, + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/", + "trigger_script": { + "script": "//testing/trigger_scripts/chromeos_device_trigger.py" + }, + "variant_id": "Ash ToT" + }, + { + "args": [ + "screenshot_sync", + "--show-stdout", + "--browser=lacros-chrome", + "--passthrough", + "-v", + "--stable-jobs", + "--extra-browser-args=--log-level=0 --js-flags=--expose-gc --use-cmd-decoder=passthrough --use-gl=angle", + "--dont-restore-color-profile-after-test", + "--deploy-lacros", + "--remote=variable_chromeos_device_hostname" + ], + "isolate_name": "telemetry_gpu_integration_test", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_isolated_script_merge.py" + }, + "name": "screenshot_sync_passthrough_tests Ash ToT", + "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": [ + { + "device_type": "octopus", + "os": "ChromeOS", + "pool": "chrome.tests" + } + ], + "expiration": 21600, + "idempotent": false, + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/", + "trigger_script": { + "script": "//testing/trigger_scripts/chromeos_device_trigger.py" + }, + "variant_id": "Ash ToT" + }, + { + "args": [ + "trace_test", + "--show-stdout", + "--browser=lacros-chrome", + "--passthrough", + "-v", + "--stable-jobs", + "--extra-browser-args=--log-level=0 --js-flags=--expose-gc", + "--deploy-lacros", + "--remote=variable_chromeos_device_hostname" + ], + "isolate_name": "telemetry_gpu_integration_test", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_isolated_script_merge.py" + }, + "name": "trace_test Ash ToT", + "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": [ + { + "device_type": "octopus", + "os": "ChromeOS", + "pool": "chrome.tests" + } + ], + "expiration": 21600, + "idempotent": false, + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test_id_prefix": "ninja://chrome/test:telemetry_gpu_integration_test/", + "trigger_script": { + "script": "//testing/trigger_scripts/chromeos_device_trigger.py" + }, + "variant_id": "Ash ToT" + } + ] + }, "Lacros FYI x64 Release (AMD)": { "isolated_scripts": [ {
diff --git a/testing/buildbot/chromium.memory.json b/testing/buildbot/chromium.memory.json index 5264360..90320c30 100644 --- a/testing/buildbot/chromium.memory.json +++ b/testing/buildbot/chromium.memory.json
@@ -18414,12 +18414,12 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome", "--test-launcher-print-test-stdio=always", "--combine-ash-logs-on-bots", "--asan-symbolize-output" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "isolate_profile_data": true, "merge": { "args": [], @@ -18431,8 +18431,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [ @@ -18605,12 +18605,12 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome", "--test-launcher-print-test-stdio=always", "--combine-ash-logs-on-bots", "--asan-symbolize-output" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "isolate_profile_data": true, "merge": { "args": [], @@ -18622,8 +18622,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [ @@ -18772,12 +18772,12 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome", "--test-launcher-print-test-stdio=always", "--combine-ash-logs-on-bots", "--asan-symbolize-output" ], - "description": "Run with ash-chrome version 114.0.5679.0", + "description": "Run with ash-chrome version 114.0.5680.0", "isolate_profile_data": true, "merge": { "args": [], @@ -18789,8 +18789,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v114.0.5679.0", - "revision": "version:114.0.5679.0" + "location": "lacros_version_skew_tests_v114.0.5680.0", + "revision": "version:114.0.5680.0" } ], "dimension_sets": [
diff --git a/testing/buildbot/test_suites.pyl b/testing/buildbot/test_suites.pyl index d135a2a..24494c8 100644 --- a/testing/buildbot/test_suites.pyl +++ b/testing/buildbot/test_suites.pyl
@@ -6949,6 +6949,24 @@ }, }, + 'gpu_fyi_lacros_device_release_telemetry_tests': { + # TODO(crbug.com/1392806): Enable more tests if bots are not busy. + 'gpu_common_and_optional_telemetry_tests': { + 'variants': [ + 'LACROS_ASH_TOT', + ] + }, + # 'gpu_mediapipe_passthrough_telemetry_tests', + 'gpu_passthrough_telemetry_tests': { + 'variants': [ + 'LACROS_ASH_TOT', + ] + }, + # 'gpu_webcodecs_telemetry_test', + # 'gpu_webgl2_conformance_gles_passthrough_telemetry_tests', + # 'gpu_webgl_conformance_gles_passthrough_telemetry_tests', + }, + 'ios16_beta_simulator_tests': { 'ios_common_tests': { 'variants': [
diff --git a/testing/buildbot/variants.pyl b/testing/buildbot/variants.pyl index b638ad3..b0243467 100644 --- a/testing/buildbot/variants.pyl +++ b/testing/buildbot/variants.pyl
@@ -22,16 +22,16 @@ }, 'LACROS_VERSION_SKEW_CANARY': { 'args': [ - '--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5679.0/test_ash_chrome', + '--ash-chrome-path-override=../../lacros_version_skew_tests_v114.0.5680.0/test_ash_chrome', ], - 'description': 'Run with ash-chrome version 114.0.5679.0', + 'description': 'Run with ash-chrome version 114.0.5680.0', 'identifier': 'Lacros version skew testing ash canary', 'swarming': { 'cipd_packages': [ { 'cipd_package': 'chromium/testing/linux-ash-chromium/x86_64/ash.zip', - 'location': 'lacros_version_skew_tests_v114.0.5679.0', - 'revision': 'version:114.0.5679.0', + 'location': 'lacros_version_skew_tests_v114.0.5680.0', + 'revision': 'version:114.0.5680.0', }, ], }, @@ -729,6 +729,12 @@ ], }, }, + 'LACROS_ASH_TOT': { + 'args': [ + '--deploy-lacros', + ], + 'identifier': 'Ash ToT', + }, 'LACROS_BETTY_PI_ARC': { 'args': [ '--board=betty-pi-arc',
diff --git a/testing/buildbot/waterfalls.pyl b/testing/buildbot/waterfalls.pyl index d8d1ff92..e4bdff9 100644 --- a/testing/buildbot/waterfalls.pyl +++ b/testing/buildbot/waterfalls.pyl
@@ -4471,6 +4471,29 @@ 'GPU FYI Win x64 Builder (dbg)' : {}, 'GPU FYI Win x64 DX12 Vulkan Builder': {}, 'GPU FYI Win x64 DX12 Vulkan Builder (dbg)': {}, + 'Lacros FYI Release (octopus)': { + 'additional_compile_targets': [ + 'chromiumos_preflight', + ], + 'os_type': 'chromeos', + 'browser_config': 'lacros-chrome', + 'mixins': [ + 'limited_capacity_bot', + ], + 'swarming': { + 'dimension_sets': [ + { + 'os': 'ChromeOS', + 'device_type': 'octopus', + 'pool': 'chrome.tests', + }, + ], + }, + 'test_suites': { + 'gpu_telemetry_tests': 'gpu_fyi_lacros_device_release_telemetry_tests', + }, + 'skip_merge_script': True, + }, 'Lacros FYI x64 Release (AMD)': { 'os_type': 'lacros', 'browser_config': 'release',
diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json index 0d4e7420..6cf4391 100644 --- a/testing/variations/fieldtrial_testing_config.json +++ b/testing/variations/fieldtrial_testing_config.json
@@ -373,7 +373,6 @@ ], "disable_features": [ "AndroidScrollOptimizations", - "CacheSiteIsolationMemoryThreshold", "UseGetrandomForRandBytes" ] } @@ -1532,6 +1531,26 @@ ] } ], + "BFCachePerformanceManagerPolicy": [ + { + "platforms": [ + "android" + ], + "experiments": [ + { + "name": "EnabledPolicy_CacheSize3_20230328", + "params": { + "cache_size": "3", + "foreground_cache_size": "0" + }, + "enable_features": [ + "BFCachePerformanceManagerPolicy", + "BackForwardCacheSize" + ] + } + ] + } + ], "BackForwardCache": [ { "platforms": [ @@ -9384,25 +9403,6 @@ ] } ], - "PasswordNotesWithBackup": [ - { - "platforms": [ - "chromeos", - "chromeos_lacros", - "linux", - "mac", - "windows" - ], - "experiments": [ - { - "name": "Enabled", - "enable_features": [ - "PasswordNotesWithBackup" - ] - } - ] - } - ], "PasswordsGrouping": [ { "platforms": [
diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc index 73a97f9..e43c664 100644 --- a/third_party/blink/common/features.cc +++ b/third_party/blink/common/features.cc
@@ -1761,5 +1761,9 @@ "RemoteResourceCache", base::FEATURE_DISABLED_BY_DEFAULT); +BASE_FEATURE(kKeepAliveInBrowserMigration, + "KeepAliveInBrowserMigration", + base::FEATURE_DISABLED_BY_DEFAULT); + } // namespace features } // namespace blink
diff --git a/third_party/blink/public/common/features.h b/third_party/blink/public/common/features.h index 8280f637..ca40b80 100644 --- a/third_party/blink/public/common/features.h +++ b/third_party/blink/public/common/features.h
@@ -1083,6 +1083,12 @@ // See https://crbug.com/1414262 BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kRemoteResourceCache); +// Kill-switch for the fetch keepalive request infra migration. +// If enabled, all keepalive requests will be proxied via the browser process. +// Design Doc: https://bit.ly/chromium-keepalive-migration +// Tracker: https://crbug.com/1356128 +BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kKeepAliveInBrowserMigration); + } // namespace features } // namespace blink
diff --git a/third_party/blink/public/platform/child_url_loader_factory_bundle.h b/third_party/blink/public/platform/child_url_loader_factory_bundle.h index 1c456ed..d72f297 100644 --- a/third_party/blink/public/platform/child_url_loader_factory_bundle.h +++ b/third_party/blink/public/platform/child_url_loader_factory_bundle.h
@@ -34,6 +34,14 @@ // |pending_topics_loader_factory| is used only by the frames who may send // fetch requests with {browsingTopics: true} flag. The loader factory allows // topics handling to be proxied via the browser process. +// +// |pending_keep_alive_loader_factory| is used only by the frames who may send +// fetch requests with {keepalive: true} flag. The loader factory allows +// keepalive request handling to be proxied via the browser process. The browser +// may forward the response back if the request initiator frame is still alive. +// It is only set if `blink::features::kKeepAliveInBrowserMigration` is true. +// See also crbug.com/1356128 and +// https://docs.google.com/document/d/1ZzxMMBvpqn8VZBZKnb7Go8TWjnrGcXuLS_USwVVRUvY class BLINK_PLATFORM_EXPORT ChildPendingURLLoaderFactoryBundle : public blink::PendingURLLoaderFactoryBundle { public: @@ -49,6 +57,8 @@ pending_prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + pending_keep_alive_loader_factory, bool bypass_redirect_checks); ChildPendingURLLoaderFactoryBundle( const ChildPendingURLLoaderFactoryBundle&) = delete; @@ -67,6 +77,7 @@ {}, // pending_isolated_world_factories {}, // pending_prefetch_loader_factory {}, // pending_topics_loader_factory + {}, // pending_keep_alive_loader_factory false)); // bypass_redirect_checks return pending_bundle; } @@ -81,6 +92,11 @@ return pending_topics_loader_factory_; } + mojo::PendingRemote<network::mojom::URLLoaderFactory>& + pending_keep_alive_loader_factory() { + return pending_keep_alive_loader_factory_; + } + protected: // PendingURLLoaderFactoryBundle overrides. scoped_refptr<network::SharedURLLoaderFactory> CreateFactory() override; @@ -90,6 +106,9 @@ mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_topics_loader_factory_; + + mojo::PendingRemote<network::mojom::URLLoaderFactory> + pending_keep_alive_loader_factory_; }; // This class extends URLLoaderFactoryBundle to support prefetch loader factory @@ -126,6 +145,9 @@ void SetTopicsLoaderFactory( mojo::PendingRemote<network::mojom::URLLoaderFactory> topics_loader_factory); + void SetKeepAliveLoaderFactory( + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory); virtual bool IsHostChildURLLoaderFactoryBundle() const; @@ -135,6 +157,7 @@ private: mojo::Remote<network::mojom::URLLoaderFactory> prefetch_loader_factory_; mojo::Remote<network::mojom::URLLoaderFactory> topics_loader_factory_; + mojo::Remote<network::mojom::URLLoaderFactory> keep_alive_loader_factory_; std::map<GURL, mojom::TransferrableURLLoaderPtr> subresource_overrides_; };
diff --git a/third_party/blink/public/platform/tracked_child_url_loader_factory_bundle.h b/third_party/blink/public/platform/tracked_child_url_loader_factory_bundle.h index 83cfe3d..b5af3959 100644 --- a/third_party/blink/public/platform/tracked_child_url_loader_factory_bundle.h +++ b/third_party/blink/public/platform/tracked_child_url_loader_factory_bundle.h
@@ -45,6 +45,8 @@ pending_prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + pending_keep_alive_loader_factory, std::unique_ptr<HostPtrAndTaskRunner> main_thread_host_bundle, bool bypass_redirect_checks); TrackedChildPendingURLLoaderFactoryBundle(
diff --git a/third_party/blink/renderer/bindings/IDLExtendedAttributes.md b/third_party/blink/renderer/bindings/IDLExtendedAttributes.md index 8d863c0..38a6846 100644 --- a/third_party/blink/renderer/bindings/IDLExtendedAttributes.md +++ b/third_party/blink/renderer/bindings/IDLExtendedAttributes.md
@@ -554,7 +554,7 @@ ### [StringContext=TrustedHTML|TrustedScript|TrustedScriptURL] _(t)_ -Standard: [TrustedType](https://w3c.github.io/webappsec-trusted-types/dist/spec/#!trustedtypes-extended-attribute) +Standard: [TrustedType](https://w3c.github.io/trusted-types/dist/spec/#!trustedtypes-extended-attribute) Summary: Indicate that a DOMString for HTMLs and scripts or USVString for script URLs is to be supplemented with additional Trusted Types enforcement logic.
diff --git a/third_party/blink/renderer/bindings/generated_in_core.gni b/third_party/blink/renderer/bindings/generated_in_core.gni index 05eee338..2f70c85a 100644 --- a/third_party/blink/renderer/bindings/generated_in_core.gni +++ b/third_party/blink/renderer/bindings/generated_in_core.gni
@@ -337,6 +337,8 @@ "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_stream_byob_read_result.h", "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_stream_get_reader_options.cc", "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_stream_get_reader_options.h", + "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_stream_read_result.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_stream_read_result.h", "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_writable_pair.cc", "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_readable_writable_pair.h", "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_reporting_observer_options.cc",
diff --git a/third_party/blink/renderer/bindings/idl_in_core.gni b/third_party/blink/renderer/bindings/idl_in_core.gni index 14c5e23..590ee434 100644 --- a/third_party/blink/renderer/bindings/idl_in_core.gni +++ b/third_party/blink/renderer/bindings/idl_in_core.gni
@@ -548,6 +548,7 @@ "//third_party/blink/renderer/core/streams/readable_stream_default_reader.idl", "//third_party/blink/renderer/core/streams/readable_stream_generic_reader.idl", "//third_party/blink/renderer/core/streams/readable_stream_get_reader_options.idl", + "//third_party/blink/renderer/core/streams/readable_stream_read_result.idl", "//third_party/blink/renderer/core/streams/readable_writable_pair.idl", "//third_party/blink/renderer/core/streams/stream_pipe_options.idl", "//third_party/blink/renderer/core/streams/transform_stream.idl",
diff --git a/third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py b/third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py index 5f7db98..ec54c5c 100644 --- a/third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py +++ b/third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py
@@ -576,8 +576,8 @@ def _propagate_extattrs_to_overload_group(self): ANY_OF = ('CrossOrigin', 'CrossOriginIsolated', 'Custom', 'IsolatedContext', 'LegacyLenientThis', 'LegacyUnforgeable', - 'NoAllocDirectCall', 'NotEnumerable', 'PerWorldBindings', - 'SecureContext', 'Unscopable') + 'NotEnumerable', 'PerWorldBindings', 'SecureContext', + 'Unscopable') old_irs = self._ir_map.irs_of_kinds(IRMap.IR.Kind.INTERFACE, IRMap.IR.Kind.NAMESPACE) @@ -595,18 +595,34 @@ group.extended_attributes.append( ExtendedAttribute(key=key)) + # [Affects=] must be consistent among overloaded operations. affects_values = set() for overload in group: affects_values.add( overload.extended_attributes.value_of('Affects')) assert len(affects_values) == 1, ( "Overloaded operations have inconsistent extended " - "attributes of [Affects].") + "attributes of [Affects]. {}.{}".format( + new_ir.identifier, group.identifier)) affects_value = affects_values.pop() if affects_value: group.extended_attributes.append( ExtendedAttribute(key='Affects', values=affects_value)) + # [NoAllocDirectCall] must be consistent among overloaded + # operations. + nadc_values = set() + for overload in group: + nadc_values.add( + 'NoAllocDirectCall' in overload.extended_attributes) + assert len(nadc_values) == 1, ( + "Overloaded operations have inconsistent extended " + "attributes of [NoAllocDirectCall]. {}.{}".format( + new_ir.identifier, group.identifier)) + if True in nadc_values: + group.extended_attributes.append( + ExtendedAttribute(key='NoAllocDirectCall')) + def _calculate_group_exposure(self): old_irs = self._ir_map.irs_of_kinds(IRMap.IR.Kind.CALLBACK_INTERFACE, IRMap.IR.Kind.INTERFACE,
diff --git a/third_party/blink/renderer/core/css/parser/css_parser_impl.cc b/third_party/blink/renderer/core/css/parser/css_parser_impl.cc index ec7ccbe..18ef8e3 100644 --- a/third_party/blink/renderer/core/css/parser/css_parser_impl.cc +++ b/third_party/blink/renderer/core/css/parser/css_parser_impl.cc
@@ -2046,21 +2046,6 @@ case kSemicolonToken: stream.UncheckedConsume(); break; - case kIdentToken: { - { - CSSParserTokenStream::Boundary boundary(stream, kSemicolonToken); - ConsumeDeclaration(stream, rule_type); - // Consume the remainder of the declaration (if any) for error - // recovery. - stream.ConsumeUntilPeekedTypeIs<>(); - } - - if (!stream.AtEnd()) { - stream.UncheckedConsume(); // kSemicolonToken - } - - break; - } case kAtKeywordToken: if (RuntimeEnabledFeatures::CSSNestingEnabled()) { CSSParserToken name_token = stream.ConsumeIncludingWhitespace(); @@ -2079,6 +2064,33 @@ // for error recovery, once the syntax has settled. ConsumeErroneousAtRule(stream); break; + case kIdentToken: { + wtf_size_t state = stream.Save(); + bool consumed_declaration = false; + { + CSSParserTokenStream::Boundary boundary(stream, kSemicolonToken); + consumed_declaration = ConsumeDeclaration(stream, rule_type); + } + if (consumed_declaration) { + if (!stream.AtEnd()) { + DCHECK_EQ(stream.UncheckedPeek().GetType(), kSemicolonToken); + stream.UncheckedConsume(); // kSemicolonToken + } + break; + } else if (!RuntimeEnabledFeatures::CSSNestingIdentEnabled() || + use_observer) { + // TODO(crbug.com/1427259): Support restart with inspector attached. + // Error recovery. + stream.ConsumeUntilPeekedTypeIs<kSemicolonToken>(); + if (!stream.AtEnd()) { + stream.UncheckedConsume(); // kSemicolonToken + } + break; + } + // Retry as nested rule. + stream.Restore(state); + [[fallthrough]]; + } default: if (RuntimeEnabledFeatures::CSSNestingEnabled() && parent_rule_for_nesting != nullptr) { // [1] (see function comment) @@ -2144,14 +2156,14 @@ return child; } -void CSSParserImpl::ConsumeDeclaration(CSSParserTokenStream& stream, +bool CSSParserImpl::ConsumeDeclaration(CSSParserTokenStream& stream, StyleRule::RuleType rule_type) { const wtf_size_t decl_offset_start = stream.Offset(); DCHECK_EQ(stream.Peek().GetType(), kIdentToken); const CSSParserToken& lhs = stream.ConsumeIncludingWhitespace(); if (stream.Peek().GetType() != kColonToken) { - return; // Parse error. + return false; // Parse error. } stream.UncheckedConsume(); // kColonToken @@ -2169,7 +2181,7 @@ rule_type == StyleRule::kProperty || rule_type == StyleRule::kCounterStyle) { if (important) { // Invalid - return; + return false; } atrule_id = lhs.ParseAsAtRuleDescriptorID(); AtRuleDescriptorParser::ParseAtRule(rule_type, atrule_id, tokenized_value, @@ -2182,12 +2194,12 @@ // @rules other than FontFace still handled with legacy code. if (important && (rule_type == StyleRule::kKeyframe || rule_type == StyleRule::kTry)) { - return; + return false; } if (unresolved_property == CSSPropertyID::kVariable) { if (rule_type != StyleRule::kStyle && rule_type != StyleRule::kKeyframe) { - return; + return false; } AtomicString variable_name = lhs.Value().ToAtomicString(); bool is_animation_tainted = rule_type == StyleRule::kKeyframe; @@ -2207,6 +2219,8 @@ important, parsed_properties_.size() != properties_count); } + + return parsed_properties_.size() != properties_count; } void CSSParserImpl::ConsumeVariableValue(
diff --git a/third_party/blink/renderer/core/css/parser/css_parser_impl.h b/third_party/blink/renderer/core/css/parser/css_parser_impl.h index f02126b..ea6843c 100644 --- a/third_party/blink/renderer/core/css/parser/css_parser_impl.h +++ b/third_party/blink/renderer/core/css/parser/css_parser_impl.h
@@ -250,7 +250,9 @@ CSSParserTokenStream& stream, CSSNestingType, StyleRule* parent_rule_for_nesting); - void ConsumeDeclaration(CSSParserTokenStream&, StyleRule::RuleType); + // Returns true if a declaration was parsed and added to parsed_properties_, + // and false otherwise. + bool ConsumeDeclaration(CSSParserTokenStream&, StyleRule::RuleType); void ConsumeDeclarationValue(const CSSTokenizedValue&, CSSPropertyID, bool important,
diff --git a/third_party/blink/renderer/core/css/parser/css_parser_token_stream.h b/third_party/blink/renderer/core/css/parser/css_parser_token_stream.h index 1d6602d..05d6cd7 100644 --- a/third_party/blink/renderer/core/css/parser/css_parser_token_stream.h +++ b/third_party/blink/renderer/core/css/parser/css_parser_token_stream.h
@@ -248,6 +248,122 @@ return CSSParserTokenRange(buffer_); } + // Restarts + // ======== + // + // CSSParserTokenStream has limited restart capabilities through the + // Save and Restore functions. + // + // Saving the stream is allowed under the following conditions: + // + // 1. There are no boundaries, except for the regular EOF boundary. + // (See inner class Boundary). This avoids having to store the boundaries + // in the stream snapshot. + // 2. The lookahead token is present. (See HasLookAhead). This avoids having + // to store whether or not we have a lookahead token. + // + // Restoring the stream is allowed under the following conditions: + // + // 1. The lookahead token is present (at the time of Restore). This is + // important for undoing mutations to the tokenizer's block stack (see + // CSSTokenizer::Restore). + // 2. The Save/Restore pair does not cross a BlockGuard. + // + // + // Restoring + // ========= + // + // Suppose that we had a short string to tokenize. + // + // - The '^' indicates the position of the tokenizer (CSSTokenizer). + // - The 'offset' indicates the value of CSSParserTokenStream::offset_. + // + // These values temporarily go out of sync when producing lookahead values, + // because doing so moves the position of the tokenizer only. The stream + // offset does not catch up until the lookahead is Consumed. + // + // The initial state looks like this: + // + // span:hover { X } [offset=0] + // ^ + // Ensuring lookahead moves the tokenizer position (but not the stream + // offset): + // + // span:hover { X } [offset=0, lookahead=span] + // ^ + // Consuming that lookahead token makes the offset catch up: + // + // span:hover { X } [offset=4] + // ^ + // Ensure lookahead again: + // + // span:hover { X } [offset=4, lookahead=:] + // ^ + // Consuming again: + // + // span:hover { X } [offset=5] + // ^ + // Now suppose that we had saved the stream state earlier, + // at [offset=0, lookahead=span] (keeping in mind that having lookahead is + // a prerequisite for saving the stream). We can restore to that position, + // provided that we first ensure lookahead: + // + // span:hover { X } [offset=5, lookahead=hover] + // ^ + // The restore process will then do two things. First, rewind the tokenizer's + // position to that of the saved stream offset (0): + // + // span:hover { X } [offset=5, lookahead=hover] + // ^ + // Then, set the stream offset to that rewound tokenizer position (0), + // and recreate the lookahead from that point: + // + // span:hover { X } [offset=0, lookahead=span] + // ^ + // Now that the restore is finished, we have exactly the same state as when + // it was saved: [offset=0, lookahead=span]. + // + // + // Blocks + // ====== + // + // Suppose instead that we want to restore to offset=0 in this state: + // + // span:hover { X } [offset=11, lookahead={] + // ^ + // Now we have a problem, because producing the lookahead token for '{' + // modified the block stack of the CSSTokenizer. This is why the restore + // process requires a lookahead token: we inspect the block type of that + // lookahead token to *undo* the mutation before the rest of the restore + // process. + // + // - If the lookahead token has BlockType::kBlockStart, + // then we simply pop the recently pushed token type from the stack. + // - If the lookahead token has BlockType::kBlockEnd, + // then we push the matching token type to the stack to restore the + // recently popped token type. + // + // Note that it's not possible to Consume past a block-start or block-end: + // a BlockGuard is required to enter blocks, which also ensures that we always + // consume the entire block. Note also that block-end tokens are treated as + // EOF (see UncheckedAtEnd): it is therefore not possible to escape the + // current block during a BlockGuard. For these reasons, we only ever need to + // undo at most one mutation to the block stack: the block stack mutation + // caused by the "final" lookahead before the restore process. + + wtf_size_t Save() const { + DCHECK_EQ(boundaries_, FlagForTokenType(kEOFToken)); + DCHECK(has_look_ahead_); + return offset_; + } + + void Restore(wtf_size_t offset) { + DCHECK(has_look_ahead_); + offset_ = offset; + boundaries_ = FlagForTokenType(kEOFToken); + next_ = tokenizer_.Restore(next_, offset_); + } + private: template <CSSParserTokenType... EndTypes> ALWAYS_INLINE bool TokenMarksEnd(const CSSParserToken& token) {
diff --git a/third_party/blink/renderer/core/css/parser/css_parser_token_stream_test.cc b/third_party/blink/renderer/core/css/parser/css_parser_token_stream_test.cc index 56db750..87180d4 100644 --- a/third_party/blink/renderer/core/css/parser/css_parser_token_stream_test.cc +++ b/third_party/blink/renderer/core/css/parser/css_parser_token_stream_test.cc
@@ -319,6 +319,276 @@ EXPECT_FALSE(stream.AtEnd()); } +namespace { + +Vector<CSSParserToken, 32> TokenizeAll(String string) { + CSSTokenizer tokenizer(string); + return tokenizer.TokenizeToEOF(); +} + +// See struct RestartData. +std::pair<wtf_size_t, wtf_size_t> ParseRestart(String restart) { + wtf_size_t restart_target = restart.find('^'); + wtf_size_t restart_offset = restart.find('<'); + return std::make_pair(restart_target, restart_offset); +} + +// Consume all tokens in `stream`, and store them in `tokens`, +// restarting (once) at the token with offset `restart_offset` +// to the offset specified by `restart_target`. +void TokenizeInto(CSSParserTokenStream& stream, + wtf_size_t restart_target, + wtf_size_t restart_offset, + Vector<CSSParserToken, 32>& tokens) { + absl::optional<wtf_size_t> saved_offset; + + while (true) { + stream.EnsureLookAhead(); + + if (restart_target == stream.Offset()) { + saved_offset = stream.Save(); + } + + if (saved_offset.has_value() && restart_offset == stream.Offset()) { + stream.Restore(saved_offset.value()); + saved_offset.reset(); + // Do not restart again: + restart_target = std::numeric_limits<wtf_size_t>::max(); + continue; + } + + if (stream.AtEnd()) { + return; + } + + if (stream.UncheckedPeek().GetBlockType() == CSSParserToken::kBlockStart) { + // Push block-start token about to be consumed by BlockGuard. + tokens.push_back(stream.UncheckedPeek()); + CSSParserTokenStream::BlockGuard guard(stream); + TokenizeInto(stream, restart_target, restart_offset, tokens); + // Note that stream.AtEnd() is true for EOF, but also for + // any block-end token. + stream.EnsureLookAhead(); + DCHECK(stream.AtEnd()); + if (stream.UncheckedPeek().GetType() != kEOFToken) { + // Add block-end token. + tokens.push_back(stream.UncheckedPeek()); + } + } else { + tokens.push_back(stream.UncheckedConsume()); + } + } +} + +} // namespace + +struct RestartData { + // The string to tokenize. + const char* input; + // Specifies where to restart from and to as follows: + // + // '^' - Restart to this offset. + // '<' - Instead of consuming the token at this offset, restart to the + // offset indicated '^' instead. + // + // Example: + // + // Input: "foo bar baz" + // Restart: " ^ < " + // + // The above will consume foo, <space>, <bar>, <space>, then restart + // at bar. + // + // Note that the '<' can appear at an offset equal to the length of the + // input string, to represent restarts that happen when the stream is + // at EOF. + const char* restart; + // Represents the expected token sequence, including the restart. + // Continuing the example above, the appropriate 'ref' would be: + // + // "foo bar bar baz" + const char* ref; +}; + +RestartData restart_data[] = { + // clang-format off + { + "x y z", + "^ < ", + "x x y z" + }, + { + "x y z", + " ^ <", + "x y y z" + }, + { + "x y z", + " ^<", + "x y /**/ z" + }, + { + "x y z", + "^< ", + "x/**/x y z" + }, + { + "x y z", + "^ <", + "x y/**/x y z" + }, + + // Restarting on block-start: + { + "x y { a b c } z", + " ^ < ", + "x y y { a b c } z" + }, + { + "x y ( a b c ) z", + " ^ < ", + "x y y ( a b c ) z" + }, + { + "x y { a b c } z", + " ^ < ", + "x y y { a b c } z" + }, + { + "x y foo( a b c ) z", + " ^ < ", + "x y y foo( a b c ) z" + }, + + // Restarting over a block: + { + "x y { a b c } z w", + " ^ < ", + "x y { a b c } y { a b c } z w" + }, + { + "x y { a b c } z w", + " ^ < ", + "x y { a b c }y { a b c } z w" + }, + // Restart to block-start: + { + "x y { a b c } z w", + " ^ < ", + "x y { a b c } { a b c } z w" + }, + + // Restarting over an EOF-terminated block + { + "x y { a b c ", + " ^ <", + "x y { a b c y { a b c " + }, + + // Restart within block: + { + "x y { a b c } z", + " ^ < ", + "x y { a b a b c } z" + }, + { + "x y { a b c } z", + " ^ < ", + "x y { a b c a b c } z" + }, + { + "x y { a b c } z", + " ^ < ", + "x y { a b c /**/ a b c } z" + }, + // Restart within EOF-terminated block. + { + "x y {([ a b c d", + " ^ < ", + "x y {([ a b a b c d" + }, + { + "x y {([ a b c d", + " ^ <", + "x y {([ a b c a b c d" + }, + + // clang-format on +}; + +class RestartTest : public testing::Test, + public testing::WithParamInterface<RestartData> {}; + +INSTANTIATE_TEST_SUITE_P(CSSParserTokenStreamTest, + RestartTest, + testing::ValuesIn(restart_data)); + +TEST_P(RestartTest, All) { + RestartData param = GetParam(); + + String ref(param.ref); + Vector<CSSParserToken, 32> ref_tokens = TokenizeAll(ref); + + String input(param.input); + CSSTokenizer tokenizer(input); + CSSParserTokenStream stream(tokenizer); + + auto [restart_target, restart_offset] = ParseRestart(String(param.restart)); + Vector<CSSParserToken, 32> actual_tokens; + TokenizeInto(stream, restart_target, restart_offset, actual_tokens); + + SCOPED_TRACE(testing::Message() + << "Expected (serialized): " + << CSSParserTokenRange(ref_tokens).Serialize()); + SCOPED_TRACE(testing::Message() + << "Actual (serialized): " + << CSSParserTokenRange(actual_tokens).Serialize()); + + SCOPED_TRACE(param.ref); + SCOPED_TRACE(param.restart); + SCOPED_TRACE(param.input); + + EXPECT_EQ(actual_tokens, ref_tokens); +} + +class NullRestartTest : public testing::Test, + public testing::WithParamInterface<RestartData> {}; + +INSTANTIATE_TEST_SUITE_P(CSSParserTokenStreamTest, + NullRestartTest, + testing::ValuesIn(restart_data)); + +// Ignores RestartData.restart, and instead tests restarting to and from +// the same offset, i.e. "restarting" to the offset we're already on. +TEST_P(NullRestartTest, All) { + RestartData param = GetParam(); + + String input(param.input); + Vector<CSSParserToken, 32> ref_tokens = TokenizeAll(input); + + for (wtf_size_t restart_offset = 0; restart_offset <= input.length(); + ++restart_offset) { + CSSTokenizer tokenizer(input); + CSSParserTokenStream stream(tokenizer); + + Vector<CSSParserToken, 32> actual_tokens; + TokenizeInto(stream, /* restart_target */ restart_offset, restart_offset, + actual_tokens); + + SCOPED_TRACE(testing::Message() + << "Expected (serialized): " + << CSSParserTokenRange(ref_tokens).Serialize()); + SCOPED_TRACE(testing::Message() + << "Actual (serialized): " + << CSSParserTokenRange(actual_tokens).Serialize()); + + SCOPED_TRACE(param.input); + SCOPED_TRACE(testing::Message() << "restart_offset:" << restart_offset); + + EXPECT_EQ(actual_tokens, ref_tokens); + } +} + } // namespace } // namespace blink
diff --git a/third_party/blink/renderer/core/css/parser/css_selector_parser.cc b/third_party/blink/renderer/core/css/parser/css_selector_parser.cc index f2c9e51..20e8ce5 100644 --- a/third_party/blink/renderer/core/css/parser/css_selector_parser.cc +++ b/third_party/blink/renderer/core/css/parser/css_selector_parser.cc
@@ -833,6 +833,7 @@ // (This only covers the first rule in the complex selector list; // see https://github.com/w3c/csswg-drafts/issues/7980.) const bool disallow_tag_start = + !RuntimeEnabledFeatures::CSSNestingIdentEnabled() && in_nested_style_rule && (nesting_type_ == CSSNestingType::kNesting); if (disallow_tag_start && first_in_complex_selector_list && compound_selector[0].Match() == CSSSelector::MatchType::kTag) {
diff --git a/third_party/blink/renderer/core/css/parser/css_tokenizer.h b/third_party/blink/renderer/core/css/parser/css_tokenizer.h index 34ccc2b..c46710b8 100644 --- a/third_party/blink/renderer/core/css/parser/css_tokenizer.h +++ b/third_party/blink/renderer/core/css/parser/css_tokenizer.h
@@ -56,6 +56,23 @@ // all you can do is destroy it. void PersistStrings(CSSTokenizer& destination); + // See documentation near CSSParserTokenStream. + CSSParserToken Restore(const CSSParserToken& next, wtf_size_t offset) { + // Undo block stack mutation. + if (next.GetBlockType() == CSSParserToken::BlockType::kBlockStart) { + block_stack_.pop_back(); + } else if (next.GetBlockType() == CSSParserToken::BlockType::kBlockEnd) { + static_assert(kLeftParenthesisToken == (kRightParenthesisToken - 1)); + static_assert(kLeftBracketToken == (kRightBracketToken - 1)); + static_assert(kLeftBraceToken == (kRightBraceToken - 1)); + block_stack_.push_back( + static_cast<CSSParserTokenType>(next.GetType() - 1)); + } + input_.Restore(offset); + // Produce the post-restore lookahead token. + return TokenizeSingle(); + } + private: template <bool SkipComments, bool StoreOffset> ALWAYS_INLINE CSSParserToken NextToken();
diff --git a/third_party/blink/renderer/core/css/parser/css_tokenizer_input_stream.h b/third_party/blink/renderer/core/css/parser/css_tokenizer_input_stream.h index 7cf199e3..02034629 100644 --- a/third_party/blink/renderer/core/css/parser/css_tokenizer_input_stream.h +++ b/third_party/blink/renderer/core/css/parser/css_tokenizer_input_stream.h
@@ -86,6 +86,8 @@ return StringView(string_, start, length); } + void Restore(wtf_size_t offset) { offset_ = offset; } + private: wtf_size_t offset_ = 0; const wtf_size_t string_length_;
diff --git a/third_party/blink/renderer/core/css/properties/computed_style_utils.cc b/third_party/blink/renderer/core/css/properties/computed_style_utils.cc index ea9f5b1..feaa939 100644 --- a/third_party/blink/renderer/core/css/properties/computed_style_utils.cc +++ b/third_party/blink/renderer/core/css/properties/computed_style_utils.cc
@@ -1987,8 +1987,7 @@ static bool IsSVGObjectWithWidthAndHeight(const LayoutObject& layout_object) { DCHECK(layout_object.IsSVGChild()); - return layout_object.IsSVGImage() || - layout_object.IsSVGForeignObjectIncludingNG() || + return layout_object.IsSVGImage() || layout_object.IsSVGForeignObject() || (layout_object.IsSVGShape() && IsA<SVGRectElement>(layout_object.GetNode())); }
diff --git a/third_party/blink/renderer/core/dom/element.cc b/third_party/blink/renderer/core/dom/element.cc index 5b89f88..370dff8 100644 --- a/third_party/blink/renderer/core/dom/element.cc +++ b/third_party/blink/renderer/core/dom/element.cc
@@ -2018,7 +2018,7 @@ // codepath below. auto* svg_element = DynamicTo<SVGElement>(this); if (svg_element && GetLayoutObject() && - !GetLayoutObject()->IsSVGForeignObjectIncludingNG()) { + !GetLayoutObject()->IsSVGForeignObject()) { // Get the bounding rectangle from the SVG model. // TODO(pdr): This should include stroke. if (IsA<SVGGraphicsElement>(svg_element)) { @@ -2118,7 +2118,7 @@ // codepath below. const auto* svg_element = DynamicTo<SVGElement>(this); if (svg_element && !element_layout_object->IsSVGRoot() && - !element_layout_object->IsSVGForeignObjectIncludingNG()) { + !element_layout_object->IsSVGForeignObject()) { // Get the bounding rectangle from the SVG model. // TODO(pdr): ObjectBoundingBox does not include stroke and the spec is not // clear (see: https://github.com/w3c/svgwg/issues/339, crbug.com/529734).
diff --git a/third_party/blink/renderer/core/dom/text.cc b/third_party/blink/renderer/core/dom/text.cc index cb6a9e1a..d23e74b 100644 --- a/third_party/blink/renderer/core/dom/text.cc +++ b/third_party/blink/renderer/core/dom/text.cc
@@ -256,9 +256,8 @@ const ComputedStyle& style, const Text::AttachContext& context) { const LayoutObject& parent = *context.parent; - // <button> and <fieldset> should allow whitespace even though - // LayoutFlexibleBox doesn't. - if (parent.IsButton() || parent.IsFieldset()) { + // <button> should allow whitespace even though LayoutFlexibleBox doesn't. + if (parent.IsButton()) { return true; }
diff --git a/third_party/blink/renderer/core/editing/commands/replace_selection_command.cc b/third_party/blink/renderer/core/editing/commands/replace_selection_command.cc index cddd972..17685f6b 100644 --- a/third_party/blink/renderer/core/editing/commands/replace_selection_command.cc +++ b/third_party/blink/renderer/core/editing/commands/replace_selection_command.cc
@@ -188,8 +188,7 @@ // register an event handler. && !(shadow_ancestor_element && shadow_ancestor_element->GetLayoutObject() && - shadow_ancestor_element->GetLayoutObject() - ->IsTextControlIncludingNG()) && + shadow_ancestor_element->GetLayoutObject()->IsTextControl()) && IsRichlyEditable(*editable_root)) { RemoveInterchangeNodes(fragment_); return;
diff --git a/third_party/blink/renderer/core/editing/iterators/text_iterator.cc b/third_party/blink/renderer/core/editing/iterators/text_iterator.cc index 7c1a0e1b..327c807 100644 --- a/third_party/blink/renderer/core/editing/iterators/text_iterator.cc +++ b/third_party/blink/renderer/core/editing/iterators/text_iterator.cc
@@ -365,7 +365,7 @@ // Enter user-agent shadow root, if necessary. if (iteration_progress_ < kHandledUserAgentShadowRoot) { if (std::is_same<Strategy, EditingStrategy>::value && - EntersTextControls() && layout_object->IsTextControlIncludingNG()) { + EntersTextControls() && layout_object->IsTextControl()) { ShadowRoot* user_agent_shadow_root = To<Element>(node_)->UserAgentShadowRoot(); DCHECK(user_agent_shadow_root->IsUserAgent()); @@ -567,7 +567,7 @@ DCHECK_EQ(last_text_node_, text_node_handler_.GetNode()); - if (EntersTextControls() && layout_object->IsTextControlIncludingNG()) { + if (EntersTextControls() && layout_object->IsTextControl()) { // The shadow tree should be already visited. return; }
diff --git a/third_party/blink/renderer/core/editing/layout_selection.cc b/third_party/blink/renderer/core/editing/layout_selection.cc index d831bb8..9da38ac 100644 --- a/third_party/blink/renderer/core/editing/layout_selection.cc +++ b/third_party/blink/renderer/core/editing/layout_selection.cc
@@ -239,7 +239,7 @@ parent = parent->Parent()) { if (parent->IsSVGRoot()) return; - if (parent->IsSVGText() || parent->IsNGSVGText()) { + if (parent->IsNGSVGText()) { if (!parent->ShouldInvalidateSelection()) parent->SetShouldInvalidateSelection(); return;
diff --git a/third_party/blink/renderer/core/editing/spellcheck/spell_checker.cc b/third_party/blink/renderer/core/editing/spellcheck/spell_checker.cc index 5ab0e75..c61d1ae 100644 --- a/third_party/blink/renderer/core/editing/spellcheck/spell_checker.cc +++ b/third_party/blink/renderer/core/editing/spellcheck/spell_checker.cc
@@ -534,7 +534,7 @@ return nullptr; if (layout_object->IsText()) return node; - if (layout_object->IsTextControlIncludingNG()) { + if (layout_object->IsTextControl()) { node = To<TextControlElement>(node) ->VisiblePositionForIndex(1) .DeepEquivalent()
diff --git a/third_party/blink/renderer/core/fetch/body_stream_buffer.cc b/third_party/blink/renderer/core/fetch/body_stream_buffer.cc index a3269de..02d1cb4 100644 --- a/third_party/blink/renderer/core/fetch/body_stream_buffer.cc +++ b/third_party/blink/renderer/core/fetch/body_stream_buffer.cc
@@ -509,7 +509,10 @@ } void BodyStreamBuffer::EndLoading() { - DCHECK(loader_); + if (!loader_) { + DCHECK(!keep_alive_); + return; + } virtual_time_pauser_.UnpauseVirtualTime(); keep_alive_.Clear(); loader_ = nullptr;
diff --git a/third_party/blink/renderer/core/fetch/readable_stream_bytes_consumer.cc b/third_party/blink/renderer/core/fetch/readable_stream_bytes_consumer.cc index a46cbcc..75fc6ea 100644 --- a/third_party/blink/renderer/core/fetch/readable_stream_bytes_consumer.cc +++ b/third_party/blink/renderer/core/fetch/readable_stream_bytes_consumer.cc
@@ -8,78 +8,53 @@ #include <algorithm> -#include "third_party/blink/renderer/bindings/core/v8/iterable.h" #include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h" -#include "third_party/blink/renderer/bindings/core/v8/script_function.h" -#include "third_party/blink/renderer/bindings/core/v8/script_value.h" +#include "third_party/blink/renderer/core/execution_context/agent.h" +#include "third_party/blink/renderer/core/execution_context/execution_context.h" +#include "third_party/blink/renderer/core/streams/read_request.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/scoped_persistent.h" #include "third_party/blink/renderer/platform/bindings/script_forbidden_scope.h" #include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/bindings/v8_binding_macros.h" +#include "third_party/blink/renderer/platform/scheduler/public/event_loop.h" +#include "third_party/blink/renderer/platform/wtf/functional.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "v8/include/v8.h" namespace blink { -class ReadableStreamBytesConsumer::Fulfilled final - : public ScriptFunction::Callable { +class ReadableStreamBytesConsumer::BytesConsumerReadRequest final + : public ReadRequest { public: - explicit Fulfilled(ReadableStreamBytesConsumer* consumer) + explicit BytesConsumerReadRequest(ReadableStreamBytesConsumer* consumer) : consumer_(consumer) {} - ScriptValue Call(ScriptState* script_state, ScriptValue v) override { - v8::Local<v8::Value> item = v.V8Value(); - if (!item->IsObject()) { + void ChunkSteps(ScriptState* script_state, + v8::Local<v8::Value> chunk) const override { + if (!chunk->IsUint8Array()) { consumer_->OnRejected(); - return ScriptValue(); - } - v8::Local<v8::Value> value; - bool done; - if (!V8UnpackIterationResult(script_state, item.As<v8::Object>(), &value, - &done)) { - consumer_->OnRejected(); - return ScriptValue(); - } - if (done) { - consumer_->OnReadDone(); - return v; - } - if (!value->IsUint8Array()) { - consumer_->OnRejected(); - return ScriptValue(); + return; } NonThrowableExceptionState exception_state; consumer_->OnRead( NativeValueTraits<MaybeShared<DOMUint8Array>>::NativeValue( - script_state->GetIsolate(), value, exception_state) + script_state->GetIsolate(), chunk, exception_state) .Get()); - return v; } - void Trace(Visitor* visitor) const override { - visitor->Trace(consumer_); - ScriptFunction::Callable::Trace(visitor); + void CloseSteps(ScriptState* script_state) const override { + consumer_->OnReadDone(); } - private: - Member<ReadableStreamBytesConsumer> consumer_; -}; - -class ReadableStreamBytesConsumer::Rejected final - : public ScriptFunction::Callable { - public: - explicit Rejected(ReadableStreamBytesConsumer* consumer) - : consumer_(consumer) {} - - ScriptValue Call(ScriptState*, ScriptValue v) override { + void ErrorSteps(ScriptState* script_state, + v8::Local<v8::Value> e) const override { consumer_->OnRejected(); - return v; } void Trace(Visitor* visitor) const override { visitor->Trace(consumer_); - ScriptFunction::Callable::Trace(visitor); + ReadRequest::Trace(visitor); } private: @@ -121,23 +96,13 @@ } if (!is_reading_) { is_reading_ = true; + is_inside_read_ = true; ScriptState::Scope scope(script_state_); DCHECK(reader_); - ExceptionState exception_state(script_state_->GetIsolate(), - ExceptionState::kUnknownContext, "", ""); - - ScriptPromise script_promise = - reader_->read(script_state_, exception_state); - if (exception_state.HadException()) - script_promise = ScriptPromise::Reject(script_state_, exception_state); - - script_promise - .Then(MakeGarbageCollected<ScriptFunction>( - script_state_, MakeGarbageCollected<Fulfilled>(this)), - MakeGarbageCollected<ScriptFunction>( - script_state_, MakeGarbageCollected<Rejected>(this))) - .MarkAsHandled(); + auto* read_request = MakeGarbageCollected<BytesConsumerReadRequest>(this); + ReadableStreamDefaultReader::Read(script_state_, reader_, read_request); + is_inside_read_ = false; } return Result::kShouldWait; } @@ -211,6 +176,14 @@ DCHECK(buffer); DCHECK(!pending_buffer_); DCHECK(!pending_offset_); + if (is_inside_read_) { + scoped_refptr<scheduler::EventLoop> event_loop = + ExecutionContext::From(script_state_)->GetAgent()->event_loop(); + event_loop->EnqueueMicrotask( + WTF::BindOnce(&ReadableStreamBytesConsumer::OnRead, + WrapPersistent(this), WrapPersistent(buffer))); + return; + } is_reading_ = false; if (state_ == PublicState::kClosed) return; @@ -223,6 +196,13 @@ void ReadableStreamBytesConsumer::OnReadDone() { DCHECK(is_reading_); DCHECK(!pending_buffer_); + if (is_inside_read_) { + scoped_refptr<scheduler::EventLoop> event_loop = + ExecutionContext::From(script_state_)->GetAgent()->event_loop(); + event_loop->EnqueueMicrotask(WTF::BindOnce( + &ReadableStreamBytesConsumer::OnReadDone, WrapPersistent(this))); + return; + } is_reading_ = false; if (state_ == PublicState::kClosed) return; @@ -238,6 +218,13 @@ void ReadableStreamBytesConsumer::OnRejected() { DCHECK(is_reading_); DCHECK(!pending_buffer_); + if (is_inside_read_) { + scoped_refptr<scheduler::EventLoop> event_loop = + ExecutionContext::From(script_state_)->GetAgent()->event_loop(); + event_loop->EnqueueMicrotask(WTF::BindOnce( + &ReadableStreamBytesConsumer::OnRejected, WrapPersistent(this))); + return; + } is_reading_ = false; if (state_ == PublicState::kClosed) return;
diff --git a/third_party/blink/renderer/core/fetch/readable_stream_bytes_consumer.h b/third_party/blink/renderer/core/fetch/readable_stream_bytes_consumer.h index e43f658..07d22033 100644 --- a/third_party/blink/renderer/core/fetch/readable_stream_bytes_consumer.h +++ b/third_party/blink/renderer/core/fetch/readable_stream_bytes_consumer.h
@@ -43,8 +43,7 @@ void Trace(Visitor*) const override; private: - class Fulfilled; - class Rejected; + class BytesConsumerReadRequest; void OnRead(DOMUint8Array*); void OnReadDone(); @@ -59,6 +58,7 @@ size_t pending_offset_ = 0; PublicState state_ = PublicState::kReadableOrWaiting; bool is_reading_ = false; + bool is_inside_read_ = false; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/frame/animation_frame_timing_monitor.cc b/third_party/blink/renderer/core/frame/animation_frame_timing_monitor.cc index d93dbca8..2dfc652 100644 --- a/third_party/blink/renderer/core/frame/animation_frame_timing_monitor.cc +++ b/third_party/blink/renderer/core/frame/animation_frame_timing_monitor.cc
@@ -201,18 +201,48 @@ base::TimeDelta total_compilation_duration; base::TimeDelta total_execution_duration; base::TimeDelta total_forced_style_and_layout_duration; + base::TimeDelta script_type_duration_user_callback; + base::TimeDelta script_type_duration_event_listener; + base::TimeDelta script_type_duration_promise_handler; + base::TimeDelta script_type_duration_script_block; for (const Member<ScriptTimingInfo>& script : info.Scripts()) { total_compilation_duration += (script->ExecutionStartTime() - script->StartTime()); - total_execution_duration += + base::TimeDelta execution_duration = (script->EndTime() - script->ExecutionStartTime()); + total_execution_duration += execution_duration; total_forced_style_and_layout_duration += script->StyleDuration(); total_forced_style_and_layout_duration += script->LayoutDuration(); + switch (script->GetType()) { + case ScriptTimingInfo::Type::kClassicScript: + case ScriptTimingInfo::Type::kModuleScript: + case ScriptTimingInfo::Type::kExecuteScript: + script_type_duration_script_block += execution_duration; + break; + case ScriptTimingInfo::Type::kEventHandler: + script_type_duration_event_listener += execution_duration; + break; + case ScriptTimingInfo::Type::kPromiseResolve: + case ScriptTimingInfo::Type::kPromiseReject: + script_type_duration_promise_handler += execution_duration; + break; + case ScriptTimingInfo::Type::kUserCallback: + script_type_duration_user_callback += execution_duration; + break; + } } builder.SetDuration_LongScript_JSCompilation( total_compilation_duration.InMilliseconds()); builder.SetDuration_LongScript_JSExecution( total_execution_duration.InMilliseconds()); + builder.SetDuration_LongScript_JSExecution_ScriptBlocks( + script_type_duration_script_block.InMilliseconds()); + builder.SetDuration_LongScript_JSExecution_EventListeners( + script_type_duration_event_listener.InMilliseconds()); + builder.SetDuration_LongScript_JSExecution_PromiseHandlers( + script_type_duration_promise_handler.InMilliseconds()); + builder.SetDuration_LongScript_JSExecution_UserCallbacks( + script_type_duration_user_callback.InMilliseconds()); builder.SetDuration_StyleAndLayout_Forced( total_forced_style_and_layout_duration.InMilliseconds()); builder.SetDidPause(info.DidPause());
diff --git a/third_party/blink/renderer/core/frame/csp/trusted_types_directive.cc b/third_party/blink/renderer/core/frame/csp/trusted_types_directive.cc index 7fb3333..7d4920c3 100644 --- a/third_party/blink/renderer/core/frame/csp/trusted_types_directive.cc +++ b/third_party/blink/renderer/core/frame/csp/trusted_types_directive.cc
@@ -12,7 +12,7 @@ bool IsNotPolicyNameChar(UChar c) { // This implements the negation of one char of tt-policy-name from - // https://w3c.github.io/webappsec-trusted-types/dist/spec/#trusted-types-csp-directive/ + // https://w3c.github.io/trusted-types/dist/spec/#trusted-types-csp-directive bool is_name_char = (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '-' || c == '#' || c == '=' || c == '_' || c == '/' || c == '@' || @@ -22,7 +22,7 @@ bool IsPolicyName(const String& name) { // This implements tt-policy-name from - // https://w3c.github.io/webappsec-trusted-types/dist/spec/#trusted-types-csp-directive/ + // https://w3c.github.io/trusted-types/dist/spec/#trusted-types-csp-directive return name.Find(&IsNotPolicyNameChar) == kNotFound; }
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 df00c3f2..cf47a24 100644 --- a/third_party/blink/renderer/core/frame/local_dom_window.cc +++ b/third_party/blink/renderer/core/frame/local_dom_window.cc
@@ -490,7 +490,7 @@ if (ContentSecurityPolicy::ShouldBypassMainWorldDeprecated(world)) return script_source; - // https://w3c.github.io/webappsec-trusted-types/dist/spec/#require-trusted-types-for-pre-navigation-check + // https://w3c.github.io/trusted-types/dist/spec/#require-trusted-types-for-pre-navigation-check // 4.9.1.1. require-trusted-types-for Pre-Navigation check script_source = TrustedTypesCheckForJavascriptURLinNavigation(script_source, this);
diff --git a/third_party/blink/renderer/core/frame/window.idl b/third_party/blink/renderer/core/frame/window.idl index 4da19b8..4e4acc6 100644 --- a/third_party/blink/renderer/core/frame/window.idl +++ b/third_party/blink/renderer/core/frame/window.idl
@@ -199,7 +199,7 @@ // https://w3c.github.io/webappsec-secure-contexts/#monkey-patching-global-object readonly attribute boolean isSecureContext; - // TrustedTypes API: http://github.com/wicg/trusted-types + // TrustedTypes API: http://github.com/w3c/trusted-types [CallWith=ScriptState] readonly attribute TrustedTypePolicyFactory trustedTypes; // Anonymous iframe:
diff --git a/third_party/blink/renderer/core/html/forms/html_field_set_element.cc b/third_party/blink/renderer/core/html/forms/html_field_set_element.cc index 0805152..317aa23 100644 --- a/third_party/blink/renderer/core/html/forms/html_field_set_element.cc +++ b/third_party/blink/renderer/core/html/forms/html_field_set_element.cc
@@ -34,7 +34,6 @@ #include "third_party/blink/renderer/core/html/html_collection.h" #include "third_party/blink/renderer/core/html_names.h" #include "third_party/blink/renderer/core/layout/layout_block.h" -#include "third_party/blink/renderer/core/layout/layout_object_factory.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.h" #include "third_party/blink/renderer/platform/wtf/std_lib_extras.h" @@ -144,7 +143,7 @@ LayoutObject* HTMLFieldSetElement::CreateLayoutObject( const ComputedStyle& style, LegacyLayout legacy) { - return LayoutObjectFactory::CreateFieldset(*this, style, legacy); + return MakeGarbageCollected<LayoutNGFieldset>(this); } LayoutBox* HTMLFieldSetElement::GetLayoutBoxForScrolling() const {
diff --git a/third_party/blink/renderer/core/html/forms/html_text_area_element.cc b/third_party/blink/renderer/core/html/forms/html_text_area_element.cc index e2e8c75..39bb029 100644 --- a/third_party/blink/renderer/core/html/forms/html_text_area_element.cc +++ b/third_party/blink/renderer/core/html/forms/html_text_area_element.cc
@@ -52,7 +52,7 @@ #include "third_party/blink/renderer/core/layout/adjust_for_absolute_zoom.h" #include "third_party/blink/renderer/core/layout/layout_box.h" #include "third_party/blink/renderer/core/layout/layout_object.h" -#include "third_party/blink/renderer/core/layout/layout_object_factory.h" +#include "third_party/blink/renderer/core/layout/ng/layout_ng_text_control_multi_line.h" #include "third_party/blink/renderer/core/page/chrome_client.h" #include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h" @@ -270,7 +270,7 @@ LayoutObject* HTMLTextAreaElement::CreateLayoutObject( const ComputedStyle& style, LegacyLayout legacy) { - return LayoutObjectFactory::CreateTextControlMultiLine(*this, style, legacy); + return MakeGarbageCollected<LayoutNGTextControlMultiLine>(this); } void HTMLTextAreaElement::AppendToFormData(FormData& form_data) {
diff --git a/third_party/blink/renderer/core/html/forms/password_input_type.cc b/third_party/blink/renderer/core/html/forms/password_input_type.cc index a5a3c6dc..21cee6a7 100644 --- a/third_party/blink/renderer/core/html/forms/password_input_type.cc +++ b/third_party/blink/renderer/core/html/forms/password_input_type.cc
@@ -46,7 +46,6 @@ #include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h" #include "third_party/blink/renderer/core/input/keyboard_event_manager.h" #include "third_party/blink/renderer/core/input_type_names.h" -#include "third_party/blink/renderer/core/layout/layout_text_control_single_line.h" namespace blink {
diff --git a/third_party/blink/renderer/core/html/forms/slider_track_element.cc b/third_party/blink/renderer/core/html/forms/slider_track_element.cc index c5e8779..da29ca6 100644 --- a/third_party/blink/renderer/core/html/forms/slider_track_element.cc +++ b/third_party/blink/renderer/core/html/forms/slider_track_element.cc
@@ -4,7 +4,7 @@ #include "third_party/blink/renderer/core/html/forms/slider_track_element.h" -#include "third_party/blink/renderer/core/layout/layout_object_factory.h" +#include "third_party/blink/renderer/core/layout/ng/layout_ng_block_flow.h" namespace blink { @@ -13,7 +13,7 @@ LayoutObject* SliderTrackElement::CreateLayoutObject(const ComputedStyle& style, LegacyLayout legacy) { - return LayoutObjectFactory::CreateSliderTrack(*this, style, legacy); + return MakeGarbageCollected<LayoutNGBlockFlow>(this); } } // namespace blink
diff --git a/third_party/blink/renderer/core/html/forms/text_control_element.cc b/third_party/blink/renderer/core/html/forms/text_control_element.cc index e9e6dcd..8b3f14a 100644 --- a/third_party/blink/renderer/core/html/forms/text_control_element.cc +++ b/third_party/blink/renderer/core/html/forms/text_control_element.cc
@@ -129,7 +129,7 @@ void TextControlElement::DefaultEventHandler(Event& event) { if (event.type() == event_type_names::kWebkitEditableContentChanged && - GetLayoutObject() && GetLayoutObject()->IsTextControlIncludingNG()) { + GetLayoutObject() && GetLayoutObject()->IsTextControl()) { last_change_was_user_edit_ = !GetDocument().IsRunningExecCommand(); user_has_edited_the_field_ |= last_change_was_user_edit_;
diff --git a/third_party/blink/renderer/core/html/forms/text_control_inner_elements.cc b/third_party/blink/renderer/core/html/forms/text_control_inner_elements.cc index a9fa463..52d9726 100644 --- a/third_party/blink/renderer/core/html/forms/text_control_inner_elements.cc +++ b/third_party/blink/renderer/core/html/forms/text_control_inner_elements.cc
@@ -37,7 +37,7 @@ #include "third_party/blink/renderer/core/html/forms/html_input_element.h" #include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h" #include "third_party/blink/renderer/core/html_names.h" -#include "third_party/blink/renderer/core/layout/layout_object_factory.h" +#include "third_party/blink/renderer/core/layout/ng/layout_ng_text_control_inner_editor.h" namespace blink { @@ -124,8 +124,7 @@ LayoutObject* TextControlInnerEditorElement::CreateLayoutObject( const ComputedStyle& style, LegacyLayout legacy) { - return LayoutObjectFactory::CreateTextControlInnerEditor(*this, style, - legacy); + return MakeGarbageCollected<LayoutNGTextControlInnerEditor>(this); } scoped_refptr<const ComputedStyle>
diff --git a/third_party/blink/renderer/core/html/forms/text_field_input_type.cc b/third_party/blink/renderer/core/html/forms/text_field_input_type.cc index 96f2b08..f9c782c 100644 --- a/third_party/blink/renderer/core/html/forms/text_field_input_type.cc +++ b/third_party/blink/renderer/core/html/forms/text_field_input_type.cc
@@ -45,7 +45,7 @@ #include "third_party/blink/renderer/core/html/forms/text_control_inner_elements.h" #include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h" #include "third_party/blink/renderer/core/html_names.h" -#include "third_party/blink/renderer/core/layout/layout_object_factory.h" +#include "third_party/blink/renderer/core/layout/ng/layout_ng_text_control_single_line.h" #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/paint/paint_layer.h" @@ -301,8 +301,7 @@ LayoutObject* TextFieldInputType::CreateLayoutObject( const ComputedStyle& style, LegacyLayout legacy) const { - return LayoutObjectFactory::CreateTextControlSingleLine(GetElement(), style, - legacy); + return MakeGarbageCollected<LayoutNGTextControlSingleLine>(&GetElement()); } ControlPart TextFieldInputType::AutoAppearance() const {
diff --git a/third_party/blink/renderer/core/html/html_iframe_element.idl b/third_party/blink/renderer/core/html/html_iframe_element.idl index 0f9ff86..7fd6e35 100644 --- a/third_party/blink/renderer/core/html/html_iframe_element.idl +++ b/third_party/blink/renderer/core/html/html_iframe_element.idl
@@ -21,7 +21,7 @@ // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#htmliframeelement // The `HTMLString` references below are from Trusted Types: -// https://github.com/WICG/trusted-types/, which is still WIP. +// https://github.com/w3c/trusted-types/, which is still WIP. // https://crbug.com/739170. [ Exposed=Window,
diff --git a/third_party/blink/renderer/core/html/html_script_element.cc b/third_party/blink/renderer/core/html/html_script_element.cc index 8028e58..19855285 100644 --- a/third_party/blink/renderer/core/html/html_script_element.cc +++ b/third_party/blink/renderer/core/html/html_script_element.cc
@@ -299,8 +299,7 @@ const WTF::OrdinalNumber& context_line, const String& script_content) { // Support 'inline-speculation-rules' source. - // https://github.com/WICG/nav-speculation/blob/main/triggers.md#content-security-policy - // TODO(http://crbug.com/1382361): Standardize it officially. + // https://wicg.github.io/nav-speculation/speculation-rules.html#content-security-policy DCHECK(loader_); ContentSecurityPolicy::InlineType inline_type = loader_->GetScriptType() ==
diff --git a/third_party/blink/renderer/core/html/html_script_element.h b/third_party/blink/renderer/core/html/html_script_element.h index d41e5380..45fe50b 100644 --- a/third_party/blink/renderer/core/html/html_script_element.h +++ b/third_party/blink/renderer/core/html/html_script_element.h
@@ -127,7 +127,7 @@ Element& CloneWithoutAttributesAndChildren(Document&) const override; - // https://w3c.github.io/webappsec-trusted-types/dist/spec/#script-scripttext + // https://w3c.github.io/trusted-types/dist/spec/#script-scripttext ParkableString script_text_internal_slot_; bool children_changed_by_api_;
diff --git a/third_party/blink/renderer/core/layout/api/line_layout_item.h b/third_party/blink/renderer/core/layout/api/line_layout_item.h index 96043ee26..4023e1f5 100644 --- a/third_party/blink/renderer/core/layout/api/line_layout_item.h +++ b/third_party/blink/renderer/core/layout/api/line_layout_item.h
@@ -186,8 +186,6 @@ bool IsSVGInlineText() const { return layout_object_->IsSVGInlineText(); } - bool IsSVGText() const { return layout_object_->IsSVGText(); } - bool IsSVGTextPath() const { return layout_object_->IsSVGTextPath(); } bool IsTableCell() const { return layout_object_->IsTableCell(); }
diff --git a/third_party/blink/renderer/core/layout/api/line_layout_svg_inline_text.h b/third_party/blink/renderer/core/layout/api/line_layout_svg_inline_text.h deleted file mode 100644 index 370caf2..0000000 --- a/third_party/blink/renderer/core/layout/api/line_layout_svg_inline_text.h +++ /dev/null
@@ -1,118 +0,0 @@ -// Copyright 2015 The Chromium Authors -// 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_CORE_LAYOUT_API_LINE_LAYOUT_SVG_INLINE_TEXT_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_API_LINE_LAYOUT_SVG_INLINE_TEXT_H_ - -#include "base/check_op.h" -#include "third_party/blink/renderer/core/layout/api/line_layout_text.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h" - -namespace blink { - -class LineLayoutSVGInlineText : public LineLayoutText { - public: - explicit LineLayoutSVGInlineText(LayoutSVGInlineText* layout_svg_inline_text) - : LineLayoutText(layout_svg_inline_text) {} - - explicit LineLayoutSVGInlineText(const LineLayoutItem& item) - : LineLayoutText(item) { - SECURITY_DCHECK(!item || item.IsSVGInlineText()); - } - - explicit LineLayoutSVGInlineText(std::nullptr_t) : LineLayoutText(nullptr) {} - - LineLayoutSVGInlineText() = default; - - const Vector<SVGTextMetrics>& MetricsList() const { - return ToSVGInlineText()->MetricsList(); - } - - SVGCharacterDataMap& CharacterDataMap() { - return ToSVGInlineText()->CharacterDataMap(); - } - - bool CharacterStartsNewTextChunk(int position) const { - return ToSVGInlineText()->CharacterStartsNewTextChunk(position); - } - - float ScalingFactor() const { return ToSVGInlineText()->ScalingFactor(); } - - const Font& ScaledFont() const { return ToSVGInlineText()->ScaledFont(); } - - private: - LayoutSVGInlineText* ToSVGInlineText() { - return To<LayoutSVGInlineText>(GetLayoutObject()); - } - - const LayoutSVGInlineText* ToSVGInlineText() const { - return To<LayoutSVGInlineText>(GetLayoutObject()); - } -}; - -class SVGInlineTextMetricsIterator { - DISALLOW_NEW(); - - public: - SVGInlineTextMetricsIterator() { Reset(LineLayoutSVGInlineText()); } - explicit SVGInlineTextMetricsIterator( - LineLayoutSVGInlineText text_line_layout) { - Reset(text_line_layout); - } - - void AdvanceToTextStart(LineLayoutSVGInlineText text_line_layout, - unsigned start_character_offset) { - DCHECK(text_line_layout); - if (!text_line_layout_ || text_line_layout_ != text_line_layout) { - Reset(text_line_layout); - DCHECK(!MetricsList().empty()); - } - - if (character_offset_ == start_character_offset) - return; - - // TODO(fs): We could walk backwards through the metrics list in these - // cases. - if (character_offset_ > start_character_offset) - Reset(text_line_layout); - - while (character_offset_ < start_character_offset) - Next(); - DCHECK_EQ(character_offset_, start_character_offset); - } - - void Next() { - character_offset_ += Metrics().length(); - DCHECK_LE(character_offset_, text_line_layout_.length()); - DCHECK_LT(metrics_list_offset_, MetricsList().size()); - ++metrics_list_offset_; - } - - const SVGTextMetrics& Metrics() const { - DCHECK(text_line_layout_); - DCHECK_LT(metrics_list_offset_, MetricsList().size()); - return MetricsList()[metrics_list_offset_]; - } - const Vector<SVGTextMetrics>& MetricsList() const { - return text_line_layout_.MetricsList(); - } - unsigned MetricsListOffset() const { return metrics_list_offset_; } - unsigned CharacterOffset() const { return character_offset_; } - bool IsAtEnd() const { return metrics_list_offset_ == MetricsList().size(); } - - private: - void Reset(LineLayoutSVGInlineText text_line_layout) { - text_line_layout_ = text_line_layout; - character_offset_ = 0; - metrics_list_offset_ = 0; - } - - LineLayoutSVGInlineText text_line_layout_; - unsigned metrics_list_offset_; - unsigned character_offset_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_API_LINE_LAYOUT_SVG_INLINE_TEXT_H_
diff --git a/third_party/blink/renderer/core/layout/build.gni b/third_party/blink/renderer/core/layout/build.gni index a480c21..e8f502e1 100644 --- a/third_party/blink/renderer/core/layout/build.gni +++ b/third_party/blink/renderer/core/layout/build.gni
@@ -42,7 +42,6 @@ "api/line_layout_ruby_run.h", "api/line_layout_ruby_text.h", "api/line_layout_svg_inline.h", - "api/line_layout_svg_inline_text.h", "api/line_layout_svg_text_path.h", "api/line_layout_text.cc", "api/line_layout_text.h", @@ -126,8 +125,6 @@ "layout_embedded_content.h", "layout_embedded_object.cc", "layout_embedded_object.h", - "layout_fieldset.cc", - "layout_fieldset.h", "layout_flow_thread.cc", "layout_flow_thread.h", "layout_frame.cc", @@ -189,8 +186,6 @@ "layout_shift_region.h", "layout_shift_tracker.cc", "layout_shift_tracker.h", - "layout_slider_track.cc", - "layout_slider_track.h", "layout_state.cc", "layout_state.h", "layout_table.cc", @@ -213,10 +208,6 @@ "layout_text_combine.h", "layout_text_control.cc", "layout_text_control.h", - "layout_text_control_multi_line.cc", - "layout_text_control_multi_line.h", - "layout_text_control_single_line.cc", - "layout_text_control_single_line.h", "layout_text_fragment.cc", "layout_text_fragment.h", "layout_theme.cc", @@ -680,8 +671,6 @@ "svg/layout_svg_ellipse.h", "svg/layout_svg_filter_primitive.cc", "svg/layout_svg_filter_primitive.h", - "svg/layout_svg_foreign_object.cc", - "svg/layout_svg_foreign_object.h", "svg/layout_svg_hidden_container.cc", "svg/layout_svg_hidden_container.h", "svg/layout_svg_image.cc", @@ -719,8 +708,6 @@ "svg/layout_svg_root.h", "svg/layout_svg_shape.cc", "svg/layout_svg_shape.h", - "svg/layout_svg_text.cc", - "svg/layout_svg_text.h", "svg/layout_svg_text_path.cc", "svg/layout_svg_text_path.h", "svg/layout_svg_transformable_container.cc", @@ -729,12 +716,6 @@ "svg/layout_svg_tspan.h", "svg/layout_svg_viewport_container.cc", "svg/layout_svg_viewport_container.h", - "svg/line/svg_inline_flow_box.cc", - "svg/line/svg_inline_flow_box.h", - "svg/line/svg_inline_text_box.cc", - "svg/line/svg_inline_text_box.h", - "svg/line/svg_root_inline_box.cc", - "svg/line/svg_root_inline_box.h", "svg/svg_character_data.h", "svg/svg_content_container.cc", "svg/svg_content_container.h", @@ -746,21 +727,6 @@ "svg/svg_marker_data.h", "svg/svg_resources.cc", "svg/svg_resources.h", - "svg/svg_text_chunk_builder.cc", - "svg/svg_text_chunk_builder.h", - "svg/svg_text_fragment.h", - "svg/svg_text_layout_attributes_builder.cc", - "svg/svg_text_layout_attributes_builder.h", - "svg/svg_text_layout_engine.cc", - "svg/svg_text_layout_engine.h", - "svg/svg_text_layout_engine_baseline.cc", - "svg/svg_text_layout_engine_baseline.h", - "svg/svg_text_layout_engine_spacing.cc", - "svg/svg_text_layout_engine_spacing.h", - "svg/svg_text_metrics.cc", - "svg/svg_text_metrics.h", - "svg/svg_text_query.cc", - "svg/svg_text_query.h", "svg/transform_helper.cc", "svg/transform_helper.h", "svg/transformed_hit_test_location.cc", @@ -864,7 +830,6 @@ "layout_table_row_test.cc", "layout_table_section_test.cc", "layout_table_test.cc", - "layout_text_control_single_line_test.cc", "layout_text_control_test.cc", "layout_text_fragment_test.cc", "layout_text_test.cc", @@ -901,6 +866,7 @@ "ng/inline/ng_paragraph_line_breaker_test.cc", "ng/inline/ng_physical_line_box_fragment_test.cc", "ng/layout_ng_fieldset_test.cc", + "ng/layout_ng_text_control_single_line_test.cc", "ng/list/layout_ng_list_item_test.cc", "ng/ng_absolute_utils_test.cc", "ng/ng_anchor_query_test.cc", @@ -934,7 +900,6 @@ "shapes/ellipse_shape_test.cc", "style_retain_scope_test.cc", "svg/layout_svg_container_test.cc", - "svg/layout_svg_foreign_object_test.cc", "svg/layout_svg_inline_test.cc", "svg/layout_svg_root_test.cc", "svg/layout_svg_text_test.cc",
diff --git a/third_party/blink/renderer/core/layout/generated_children.h b/third_party/blink/renderer/core/layout/generated_children.h index ebeaf01..eb1b44f 100644 --- a/third_party/blink/renderer/core/layout/generated_children.h +++ b/third_party/blink/renderer/core/layout/generated_children.h
@@ -17,9 +17,10 @@ static bool CanHaveGeneratedChildren(const LayoutObject& layout_object) { // FIXME: LayoutMedia::layout makes assumptions about what children are // allowed so we can't support generated content. - if (layout_object.IsMedia() || layout_object.IsTextControlIncludingNG() || - IsMenuList(&layout_object)) + if (layout_object.IsMedia() || layout_object.IsTextControl() || + IsMenuList(&layout_object)) { return false; + } // Input elements can't have generated children, but button elements can. // We'll write the code assuming any other button types that might emerge in
diff --git a/third_party/blink/renderer/core/layout/layout_block.cc b/third_party/blink/renderer/core/layout/layout_block.cc index 70c2d01..4971ee5 100644 --- a/third_party/blink/renderer/core/layout/layout_block.cc +++ b/third_party/blink/renderer/core/layout/layout_block.cc
@@ -1047,7 +1047,7 @@ bool LayoutBlock::IsAnonymousNGFieldsetContentWrapper() const { NOT_DESTROYED(); - return Parent() && Parent()->IsLayoutNGFieldset() && IsAnonymous(); + return Parent() && Parent()->IsFieldset() && IsAnonymous(); } void LayoutBlock::InvalidatePaint( @@ -1523,8 +1523,9 @@ if (default_inline_size != kIndefiniteSize) { sizes.max_size += default_inline_size; // <textarea>'s intrinsic size should ignore scrollbar existence. - if (IsTextAreaIncludingNG()) + if (IsTextArea()) { sizes -= scrollbar_thickness; + } if (!StyleRef().LogicalWidth().IsPercentOrCalc()) sizes.min_size = sizes.max_size; return sizes;
diff --git a/third_party/blink/renderer/core/layout/layout_block_flow.cc b/third_party/blink/renderer/core/layout/layout_block_flow.cc index 2eb7b288..4bd729b 100644 --- a/third_party/blink/renderer/core/layout/layout_block_flow.cc +++ b/third_party/blink/renderer/core/layout/layout_block_flow.cc
@@ -4308,8 +4308,9 @@ // For LayoutNG, the multi-column display type will be applied to the // anonymous content box. Thus, the flow thread should be added to the // anonymous content box instead of the fieldset itself. - if (IsFieldsetIncludingNG()) + if (IsFieldset()) { return; + } // Form controls are replaced content (also when implemented as a regular // block), and are therefore not supposed to support multicol.
diff --git a/third_party/blink/renderer/core/layout/layout_block_flow_line.cc b/third_party/blink/renderer/core/layout/layout_block_flow_line.cc index fe6d4ac..4681056 100644 --- a/third_party/blink/renderer/core/layout/layout_block_flow_line.cc +++ b/third_party/blink/renderer/core/layout/layout_block_flow_line.cc
@@ -41,7 +41,6 @@ #include "third_party/blink/renderer/core/layout/ng/inline/ng_fragment_item.h" #include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_cursor.h" #include "third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_root_inline_box.h" #include "third_party/blink/renderer/core/layout/vertical_position_cache.h" #include "third_party/blink/renderer/core/paint/outline_painter.h" #include "third_party/blink/renderer/platform/text/bidi_resolver.h" @@ -943,32 +942,19 @@ line_box->SetBidiLevel(bidi_level); line_box->SetEndsWithBreak(line_info.PreviousLineBrokeCleanly()); - bool is_svg_root_inline_box = line_box->IsSVGRootInlineBox(); - GlyphOverflowAndFallbackFontsMap text_box_data_map; // Now we position all of our text runs horizontally. - if (!is_svg_root_inline_box) - ComputeInlineDirectionPositionsForLine( - line_box, line_info, bidi_runs.FirstRun(), trailing_space_run, - end.AtEnd(), text_box_data_map, vertical_position_cache, - word_measurements); + ComputeInlineDirectionPositionsForLine( + line_box, line_info, bidi_runs.FirstRun(), trailing_space_run, + end.AtEnd(), text_box_data_map, vertical_position_cache, + word_measurements); // Now position our text runs vertically. ComputeBlockDirectionPositionsForLine(line_box, bidi_runs.FirstRun(), text_box_data_map, vertical_position_cache); - // SVG text layout code computes vertical & horizontal positions on its own. - // Note that we still need to execute computeVerticalPositionsForLine() as - // it calls InlineTextBox::positionLineBox(), which tracks whether the box - // contains reversed text or not. If we wouldn't do that editing and thus - // text selection in RTL boxes would not work as expected. - if (is_svg_root_inline_box) { - DCHECK(IsSVGText()); - To<SVGRootInlineBox>(line_box)->ComputePerCharacterLayoutInformation(); - } - // Compute our overflow now. line_box->ComputeOverflow(line_box->LineTop(), line_box->LineBottom(), text_box_data_map);
diff --git a/third_party/blink/renderer/core/layout/layout_box.cc b/third_party/blink/renderer/core/layout/layout_box.cc index bc3776d..abba4b1 100644 --- a/third_party/blink/renderer/core/layout/layout_box.cc +++ b/third_party/blink/renderer/core/layout/layout_box.cc
@@ -65,7 +65,6 @@ #include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" #include "third_party/blink/renderer/core/layout/hit_test_result.h" #include "third_party/blink/renderer/core/layout/layout_embedded_content.h" -#include "third_party/blink/renderer/core/layout/layout_fieldset.h" #include "third_party/blink/renderer/core/layout/layout_inline.h" #include "third_party/blink/renderer/core/layout/layout_list_marker.h" #include "third_party/blink/renderer/core/layout/layout_multi_column_flow_thread.h" @@ -156,9 +155,9 @@ // // See |NGBlockLayoutAlgorithm::ComputeMinMaxSizes()| and |LayoutBlock:: // ComputeIntrinsicLogicalWidths()|. - return LayoutUnit(ceilf(LayoutTextControl::GetAvgCharWidth(box.StyleRef()) * + return LayoutUnit(ceilf(layout_text_control::GetAvgCharWidth(box.StyleRef()) * textarea.cols())) + - LayoutTextControl::ScrollbarThickness(box); + layout_text_control::ScrollbarThickness(box); } LayoutUnit TextFieldIntrinsicInlineSize(const HTMLInputElement& input, @@ -168,13 +167,14 @@ if (factor <= 0) factor = 20; - const float char_width = LayoutTextControl::GetAvgCharWidth(box.StyleRef()); + const float char_width = layout_text_control::GetAvgCharWidth(box.StyleRef()); float float_result = char_width * factor; float max_char_width = 0.f; const Font& font = box.StyleRef().GetFont(); - if (LayoutTextControl::HasValidAvgCharWidth(font)) + if (layout_text_control::HasValidAvgCharWidth(font)) { max_char_width = font.PrimaryFont()->MaxCharWidth(); + } // For text inputs, IE adds some extra width. if (max_char_width > char_width) @@ -225,7 +225,7 @@ if (box.StyleRef().OverflowInlineDirection() == EOverflow::kScroll || (box.StyleRef().OverflowInlineDirection() == EOverflow::kAuto && inner_style.OverflowWrap() == EOverflowWrap::kNormal)) - scrollbar_thickness = LayoutTextControl::ScrollbarThickness(box); + scrollbar_thickness = layout_text_control::ScrollbarThickness(box); return inner_box.LineHeight(true, inner_style.IsHorizontalWritingMode() ? kHorizontalLine @@ -1402,9 +1402,10 @@ return ListBoxItemHeight(*select, *this) * select->ListBoxSize() - ComputeLogicalScrollbars().BlockSum(); } - if (IsTextFieldIncludingNG()) + if (IsTextField()) { return TextFieldIntrinsicBlockSize(*To<HTMLInputElement>(GetNode()), *this); - if (IsTextAreaIncludingNG()) { + } + if (IsTextArea()) { return TextAreaIntrinsicBlockSize(*To<HTMLTextAreaElement>(GetNode()), *this); } @@ -2970,7 +2971,7 @@ if (UNLIKELY(input)) { // As for LayoutButton, ControlClip is to for not BUTTONs but INPUT // buttons for IE/Firefox compatibility. - if (IsTextFieldIncludingNG() || IsButton()) { + if (IsTextField() || IsButton()) { DCHECK(HasControlClip()); PhysicalRect control_clip = PhysicalPaddingBoxRect(); control_clip.Move(location); @@ -2990,7 +2991,7 @@ bool LayoutBox::HasControlClip() const { NOT_DESTROYED(); - return UNLIKELY(IsTextFieldIncludingNG() || IsMenuList(this) || + return UNLIKELY(IsTextField() || IsMenuList(this) || (IsButton() && IsA<HTMLInputElement>(GetNode()))); } @@ -4588,12 +4589,14 @@ if (default_height != kIndefiniteSize) { height = default_height + BorderAndPaddingLogicalHeight(); // <textarea>'s intrinsic size should ignore scrollbar existence. - if (!IsTextAreaIncludingNG()) + if (!IsTextArea()) { height += ComputeLogicalScrollbars().BlockSum(); + } // FIXME: The logical height of the inner editor box should have been // added before calling ComputeLogicalHeight to avoid this hack. - if (IsTextControlIncludingNG()) + if (IsTextControl()) { SetIntrinsicContentLogicalHeight(default_height); + } } else if (ShouldApplySizeContainment()) { height = BorderAndPaddingLogicalHeight() + ComputeLogicalScrollbars().BlockSum(); @@ -4868,8 +4871,9 @@ // non-anonymous. if (containing_block->IsAnonymous()) { if (!in_quirks_mode && containing_block->Parent() && - containing_block->Parent()->IsLayoutNGFieldset()) + containing_block->Parent()->IsFieldset()) { return false; + } EDisplay display = containing_block->StyleRef().Display(); return display == EDisplay::kBlock || display == EDisplay::kInlineBlock || display == EDisplay::kFlowRoot;
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 ce1f50f..33d427c4 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
@@ -845,8 +845,9 @@ // Skip anonymous containing blocks except for anonymous fieldset content box. while (sticky_container->IsAnonymous()) { if (sticky_container->Parent() && - sticky_container->Parent()->IsLayoutNGFieldset()) + sticky_container->Parent()->IsFieldset()) { break; + } sticky_container = sticky_container->ContainingBlock(); }
diff --git a/third_party/blink/renderer/core/layout/layout_embedded_object.cc b/third_party/blink/renderer/core/layout/layout_embedded_object.cc index dc00b93..f5684a8 100644 --- a/third_party/blink/renderer/core/layout/layout_embedded_object.cc +++ b/third_party/blink/renderer/core/layout/layout_embedded_object.cc
@@ -95,11 +95,6 @@ NOT_DESTROYED(); DCHECK(NeedsLayout()); - if (!RuntimeEnabledFeatures::LayoutNGReplacedNoBoxSettersEnabled()) { - UpdateLogicalWidth(); - UpdateLogicalHeight(); - } - ClearLayoutOverflow(); if (!GetEmbeddedContentView() && GetFrameView())
diff --git a/third_party/blink/renderer/core/layout/layout_fieldset.cc b/third_party/blink/renderer/core/layout/layout_fieldset.cc deleted file mode 100644 index ff2a48b5..0000000 --- a/third_party/blink/renderer/core/layout/layout_fieldset.cc +++ /dev/null
@@ -1,178 +0,0 @@ -/* - * Copyright (C) 1999 Lars Knoll (knoll@kde.org) - * (C) 1999 Antti Koivisto (koivisto@kde.org) - * (C) 2000 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "third_party/blink/renderer/core/layout/layout_fieldset.h" - -#include "third_party/blink/renderer/core/css/css_property_names.h" -#include "third_party/blink/renderer/core/html/forms/html_legend_element.h" -#include "third_party/blink/renderer/core/paint/fieldset_painter.h" - -namespace blink { - -LayoutFieldset::LayoutFieldset(Element* element) : LayoutBlockFlow(element) {} - -MinMaxSizes LayoutFieldset::PreferredLogicalWidths() const { - NOT_DESTROYED(); - MinMaxSizes sizes = LayoutBlockFlow::PreferredLogicalWidths(); - // Size-contained elements don't consider their contents for preferred sizing. - if (ShouldApplySizeContainment()) - return sizes; - - if (LayoutBox* legend = FindInFlowLegend()) { - int legend_min_width = legend->PreferredLogicalWidths().min_size.ToInt(); - - const Length& legend_margin_left = legend->StyleRef().MarginLeft(); - const Length& legend_margin_right = legend->StyleRef().MarginRight(); - - if (legend_margin_left.IsFixed()) - legend_min_width += legend_margin_left.Value(); - - if (legend_margin_right.IsFixed()) - legend_min_width += legend_margin_right.Value(); - - sizes.min_size = - max(sizes.min_size, legend_min_width + BorderAndPaddingWidth()); - } - - return sizes; -} - -LayoutObject* LayoutFieldset::LayoutSpecialExcludedChild(bool relayout_children, - SubtreeLayoutScope&) { - NOT_DESTROYED(); - LayoutBox* legend = FindInFlowLegend(); - if (legend) { - LayoutRect old_legend_frame_rect = legend->FrameRect(); - - if (relayout_children) { - legend->SetNeedsLayoutAndFullPaintInvalidation( - layout_invalidation_reason::kFieldsetChanged); - } - legend->LayoutIfNeeded(); - - LayoutUnit logical_left; - if (StyleRef().IsLeftToRightDirection()) { - switch (legend->StyleRef().GetTextAlign()) { - case ETextAlign::kCenter: - logical_left = (LogicalWidth() - LogicalWidthForChild(*legend)) / 2; - break; - case ETextAlign::kRight: - logical_left = LogicalWidth() - BorderEnd() - PaddingEnd() - - LogicalWidthForChild(*legend); - break; - default: - logical_left = - BorderStart() + PaddingStart() + MarginStartForChild(*legend); - break; - } - } else { - switch (legend->StyleRef().GetTextAlign()) { - case ETextAlign::kLeft: - logical_left = BorderStart() + PaddingStart(); - break; - case ETextAlign::kCenter: { - // Make sure that the extra pixel goes to the end side in RTL (since - // it went to the end side in LTR). - LayoutUnit centered_width = - LogicalWidth() - LogicalWidthForChild(*legend); - logical_left = centered_width - centered_width / 2; - break; - } - default: - logical_left = LogicalWidth() - BorderStart() - PaddingStart() - - MarginStartForChild(*legend) - - LogicalWidthForChild(*legend); - break; - } - } - - SetLogicalLeftForChild(*legend, logical_left); - - LayoutUnit fieldset_border_before = LayoutUnit(BorderBefore()); - LayoutUnit legend_logical_height = LogicalHeightForChild(*legend); - - LayoutUnit legend_logical_top; - LayoutUnit collapsed_legend_extent; - // FIXME: We need to account for the legend's margin before too. - if (fieldset_border_before > legend_logical_height) { - // The <legend> is smaller than the associated fieldset before border - // so the latter determines positioning of the <legend>. The sizing - // depends - // on the legend's margins as we want to still follow the author's cues. - // Firefox completely ignores the margins in this case which seems wrong. - legend_logical_top = (fieldset_border_before - legend_logical_height) / 2; - collapsed_legend_extent = max<LayoutUnit>( - fieldset_border_before, legend_logical_top + legend_logical_height + - MarginAfterForChild(*legend)); - } else { - collapsed_legend_extent = - legend_logical_height + MarginAfterForChild(*legend); - } - - SetLogicalTopForChild(*legend, legend_logical_top); - SetLogicalHeight(PaddingBefore() + collapsed_legend_extent); - - if (legend->FrameRect() != old_legend_frame_rect) { - // We need to invalidate the fieldset border if the legend's frame - // changed. - SetShouldDoFullPaintInvalidation(); - } - } - return legend; -} - -LayoutBox* LayoutFieldset::FindInFlowLegend(const LayoutBlock& fieldset) { - DCHECK(fieldset.IsFieldset() || fieldset.IsLayoutNGFieldset()); - for (LayoutObject* legend = fieldset.FirstChild(); legend; - legend = legend->NextSibling()) { - if (legend->IsRenderedLegendCandidate()) - return To<LayoutBox>(legend); - } - return nullptr; -} - -void LayoutFieldset::PaintBoxDecorationBackground( - const PaintInfo& paint_info, - const PhysicalOffset& paint_offset) const { - NOT_DESTROYED(); - FieldsetPainter(*this).PaintBoxDecorationBackground(paint_info, paint_offset); -} - -void LayoutFieldset::PaintMask(const PaintInfo& paint_info, - const PhysicalOffset& paint_offset) const { - NOT_DESTROYED(); - FieldsetPainter(*this).PaintMask(paint_info, paint_offset); -} - -bool LayoutFieldset::BackgroundIsKnownToBeOpaqueInRect( - const PhysicalRect& local_rect) const { - NOT_DESTROYED(); - // If the field set has a legend, then it probably does not completely fill - // its background. - if (FindInFlowLegend()) - return false; - - return LayoutBlockFlow::BackgroundIsKnownToBeOpaqueInRect(local_rect); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/layout_fieldset.h b/third_party/blink/renderer/core/layout/layout_fieldset.h deleted file mode 100644 index b257882c..0000000 --- a/third_party/blink/renderer/core/layout/layout_fieldset.h +++ /dev/null
@@ -1,73 +0,0 @@ -/* - * Copyright (C) 1999 Lars Knoll (knoll@kde.org) - * (C) 1999 Antti Koivisto (koivisto@kde.org) - * (C) 2000 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_FIELDSET_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_FIELDSET_H_ - -#include "third_party/blink/renderer/core/layout/layout_block_flow.h" - -namespace blink { - -class LayoutFieldset final : public LayoutBlockFlow { - public: - explicit LayoutFieldset(Element*); - - static LayoutBox* FindInFlowLegend(const LayoutBlock& fieldset); - LayoutBox* FindInFlowLegend() const { - NOT_DESTROYED(); - return FindInFlowLegend(*this); - } - - const char* GetName() const override { - NOT_DESTROYED(); - return "LayoutFieldset"; - } - - bool CreatesNewFormattingContext() const final { - NOT_DESTROYED(); - return true; - } - - bool BackgroundIsKnownToBeOpaqueInRect(const PhysicalRect&) const override; - - private: - bool IsOfType(LayoutObjectType type) const override { - NOT_DESTROYED(); - return type == kLayoutObjectFieldset || LayoutBlockFlow::IsOfType(type); - } - - LayoutObject* LayoutSpecialExcludedChild(bool relayout_children, - SubtreeLayoutScope&) override; - - MinMaxSizes PreferredLogicalWidths() const override; - - void PaintBoxDecorationBackground( - const PaintInfo&, - const PhysicalOffset& paint_offset) const override; - void PaintMask(const PaintInfo&, - const PhysicalOffset& paint_offset) const override; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_FIELDSET_H_
diff --git a/third_party/blink/renderer/core/layout/layout_frame.cc b/third_party/blink/renderer/core/layout/layout_frame.cc index 084d80c38..eb9aa7f 100644 --- a/third_party/blink/renderer/core/layout/layout_frame.cc +++ b/third_party/blink/renderer/core/layout/layout_frame.cc
@@ -53,15 +53,4 @@ } } -void LayoutFrame::UpdateLayout() { - NOT_DESTROYED(); - // Should respect to BoxLayoutExtraInput. - if (Parent()->IsLayoutNGObject() && - !RuntimeEnabledFeatures::LayoutNGReplacedNoBoxSettersEnabled()) { - UpdateLogicalWidth(); - UpdateLogicalHeight(); - } - LayoutEmbeddedContent::UpdateLayout(); -} - } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/layout_frame.h b/third_party/blink/renderer/core/layout/layout_frame.h index 17c5fc66..1787bb95 100644 --- a/third_party/blink/renderer/core/layout/layout_frame.h +++ b/third_party/blink/renderer/core/layout/layout_frame.h
@@ -46,7 +46,6 @@ NOT_DESTROYED(); return type == kLayoutObjectFrame || LayoutEmbeddedContent::IsOfType(type); } - void UpdateLayout() override; }; template <>
diff --git a/third_party/blink/renderer/core/layout/layout_iframe.cc b/third_party/blink/renderer/core/layout/layout_iframe.cc index 2faf9e6..d5886bb 100644 --- a/third_party/blink/renderer/core/layout/layout_iframe.cc +++ b/third_party/blink/renderer/core/layout/layout_iframe.cc
@@ -46,12 +46,6 @@ NOT_DESTROYED(); DCHECK(NeedsLayout()); - if (!RuntimeEnabledFeatures::LayoutNGReplacedNoBoxSettersEnabled()) { - UpdateLogicalWidth(); - // No kids to layout as a replaced element. - UpdateLogicalHeight(); - } - ClearLayoutOverflow(); ClearNeedsLayout(); }
diff --git a/third_party/blink/renderer/core/layout/layout_object.cc b/third_party/blink/renderer/core/layout/layout_object.cc index 5311454..c3cbad6f 100644 --- a/third_party/blink/renderer/core/layout/layout_object.cc +++ b/third_party/blink/renderer/core/layout/layout_object.cc
@@ -75,7 +75,6 @@ #include "third_party/blink/renderer/core/layout/layout_counter.h" #include "third_party/blink/renderer/core/layout/layout_custom_scrollbar_part.h" #include "third_party/blink/renderer/core/layout/layout_embedded_content.h" -#include "third_party/blink/renderer/core/layout/layout_fieldset.h" #include "third_party/blink/renderer/core/layout/layout_flow_thread.h" #include "third_party/blink/renderer/core/layout/layout_image.h" #include "third_party/blink/renderer/core/layout/layout_image_resource_style_image.h" @@ -94,6 +93,7 @@ #include "third_party/blink/renderer/core/layout/ng/flex/layout_ng_flexible_box.h" #include "third_party/blink/renderer/core/layout/ng/inline/layout_ng_text_combine.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_block_flow.h" +#include "third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.h" #include "third_party/blink/renderer/core/layout/ng/list/layout_ng_list_item.h" #include "third_party/blink/renderer/core/layout/ng/ng_block_node.h" #include "third_party/blink/renderer/core/layout/ng/ng_layout_result.h" @@ -180,8 +180,9 @@ return false; // Text controls have some logic in the layout objects that will be missed if // we traverse the fragment tree when hit-testing. - if (obj.IsTextControlIncludingNG()) + if (obj.IsTextControl()) { return false; + } return true; } @@ -800,7 +801,7 @@ const auto* parent_layout_block = DynamicTo<LayoutBlock>(parent); return parent_layout_block && IsA<HTMLFieldSetElement>(parent->GetNode()) && - LayoutFieldset::FindInFlowLegend(*parent_layout_block) == this; + LayoutNGFieldset::FindInFlowLegend(*parent_layout_block) == this; } bool LayoutObject::IsListMarkerForSummary() const { @@ -1352,8 +1353,9 @@ if (!style->Width().IsFixed() || !style->Height().IsFixed()) return false; - if (object->IsTextControlIncludingNG()) + if (object->IsTextControl()) { return true; + } if (!object->ShouldClipOverflowAlongBothAxis()) return false; @@ -1389,8 +1391,9 @@ return; if (UNLIKELY(IsSVGChild() && !IsNGSVGText() && !IsSVGInline() && - !IsSVGInlineText() && !IsNGSVGForeignObject())) + !IsSVGInlineText() && !IsSVGForeignObject())) { return; + } // Don't mark |LayoutFlowThread| because |CollectInlines()| skips them. if (!IsLayoutFlowThread()) @@ -1784,13 +1787,13 @@ // select elements inside that are created by user agent shadow DOM, and we // have (C++) code that assumes that the elements are indeed contained by the // text control. So just make sure this is the case. - if (IsA<LayoutView>(this) || IsSVGForeignObjectIncludingNG() || - IsTextControlIncludingNG()) + if (IsA<LayoutView>(this) || IsSVGForeignObject() || IsTextControl()) { return true; + } // crbug.com/1153042: If <fieldset> is a fixed container, its anonymous // content box should be a fixed container. - if (IsAnonymous() && Parent() && Parent()->IsLayoutNGFieldset() && + if (IsAnonymous() && Parent() && Parent()->IsFieldset() && Parent()->CanContainFixedPositionObjects()) { return true; } @@ -1823,7 +1826,7 @@ ComputeIsFixedContainer(style) || // crbug.com/1153042: If <fieldset> is an absolute container, its // anonymous content box should be an absolute container. - (IsAnonymous() && Parent() && Parent()->IsLayoutNGFieldset() && + (IsAnonymous() && Parent() && Parent()->IsFieldset() && Parent()->StyleRef().CanContainAbsolutePositionObjects()); } @@ -3948,8 +3951,9 @@ break; // The anonymous fieldset contents wrapper should be kept. if (destroy_root_parent->Parent() && - destroy_root_parent->Parent()->IsLayoutNGFieldset()) + destroy_root_parent->Parent()->IsFieldset()) { break; + } // RubyBase should be kept if RubyText exists if (destroy_root_parent->IsRubyBase()) { auto* ruby_run = DynamicTo<LayoutRubyRun>(destroy_root_parent->Parent());
diff --git a/third_party/blink/renderer/core/layout/layout_object.h b/third_party/blink/renderer/core/layout/layout_object.h index 6173eb1..66ef99e 100644 --- a/third_party/blink/renderer/core/layout/layout_object.h +++ b/third_party/blink/renderer/core/layout/layout_object.h
@@ -882,16 +882,8 @@ } bool IsFieldset() const { NOT_DESTROYED(); - return IsOfType(kLayoutObjectFieldset); - } - bool IsLayoutNGFieldset() const { - NOT_DESTROYED(); return IsOfType(kLayoutObjectNGFieldset); } - bool IsFieldsetIncludingNG() const { - NOT_DESTROYED(); - return IsFieldset() || IsLayoutNGFieldset(); - } bool IsFrame() const { NOT_DESTROYED(); return IsOfType(kLayoutObjectFrame); @@ -1076,21 +1068,18 @@ NOT_DESTROYED(); return IsTableSection() && !IsLayoutNGObject(); } - bool IsTextAreaIncludingNG() const { + bool IsTextArea() const { NOT_DESTROYED(); - return IsOfType(kLayoutObjectTextControlMultiLine) || - IsOfType(kLayoutObjectNGTextControlMultiLine); + return IsOfType(kLayoutObjectNGTextControlMultiLine); } - bool IsTextControlIncludingNG() const { + bool IsTextControl() const { NOT_DESTROYED(); - return IsOfType(kLayoutObjectTextControl) || - IsOfType(kLayoutObjectNGTextControlMultiLine) || + return IsOfType(kLayoutObjectNGTextControlMultiLine) || IsOfType(kLayoutObjectNGTextControlSingleLine); } - bool IsTextFieldIncludingNG() const { + bool IsTextField() const { NOT_DESTROYED(); - return IsOfType(kLayoutObjectTextControlSingleLine) || - IsOfType(kLayoutObjectNGTextControlSingleLine); + return IsOfType(kLayoutObjectNGTextControlSingleLine); } bool IsVideo() const { NOT_DESTROYED(); @@ -1338,10 +1327,6 @@ NOT_DESTROYED(); return IsOfType(kLayoutObjectSVGShape); } - bool IsSVGText() const { - NOT_DESTROYED(); - return IsOfType(kLayoutObjectSVGText); - } bool IsSVGTextPath() const { NOT_DESTROYED(); return IsOfType(kLayoutObjectSVGTextPath); @@ -1364,12 +1349,7 @@ } bool IsSVGForeignObject() const { NOT_DESTROYED(); - return IsOfType(kLayoutObjectSVGForeignObject); - } - bool IsSVGForeignObjectIncludingNG() const { - NOT_DESTROYED(); - return IsOfType(kLayoutObjectSVGForeignObject) || - IsOfType(kLayoutObjectNGSVGForeignObject); + return IsOfType(kLayoutObjectNGSVGForeignObject); } bool IsSVGResourceContainer() const { NOT_DESTROYED(); @@ -1383,10 +1363,6 @@ NOT_DESTROYED(); return IsOfType(kLayoutObjectNGSVGText); } - bool IsNGSVGForeignObject() const { - NOT_DESTROYED(); - return IsOfType(kLayoutObjectNGSVGForeignObject); - } // FIXME: Those belong into a SVG specific base-class for all layoutObjects // (see above). Unfortunately we don't have such a class yet, because it's not @@ -1401,9 +1377,8 @@ // https://www.w3.org/TR/compositing-1/#propdef-mix-blend-mode bool IsBlendingAllowed() const { NOT_DESTROYED(); - return !IsSVG() || IsSVGShape() || IsSVGImage() || IsSVGText() || - IsSVGInline() || IsSVGRoot() || IsSVGForeignObjectIncludingNG() || - IsNGSVGText() || + return !IsSVG() || IsSVGShape() || IsSVGImage() || IsSVGInline() || + IsSVGRoot() || IsSVGForeignObject() || IsNGSVGText() || // Blending does not apply to non-renderable elements such as // patterns (see: https://github.com/w3c/fxtf-drafts/issues/309). (IsSVGContainer() && !IsSVGHiddenContainer()); @@ -3727,7 +3702,6 @@ kLayoutObjectCounter, kLayoutObjectCustomScrollbarPart, kLayoutObjectEmbeddedObject, - kLayoutObjectFieldset, kLayoutObjectFrame, kLayoutObjectFrameSet, kLayoutObjectIFrame, @@ -3772,9 +3746,6 @@ kLayoutObjectTableCol, kLayoutObjectTableRow, kLayoutObjectTableSection, - kLayoutObjectTextControl, - kLayoutObjectTextControlMultiLine, - kLayoutObjectTextControlSingleLine, kLayoutObjectVideo, kLayoutObjectView, kLayoutObjectWidget, @@ -3784,7 +3755,6 @@ kLayoutObjectSVG, /* Keep by itself? */ kLayoutObjectSVGContainer, kLayoutObjectSVGFilterPrimitive, - kLayoutObjectSVGForeignObject, kLayoutObjectSVGHiddenContainer, kLayoutObjectSVGImage, kLayoutObjectSVGInline, @@ -3792,7 +3762,6 @@ kLayoutObjectSVGResourceContainer, kLayoutObjectSVGRoot, kLayoutObjectSVGShape, - kLayoutObjectSVGText, kLayoutObjectSVGTextPath, kLayoutObjectSVGTransformableContainer, kLayoutObjectSVGTSpan,
diff --git a/third_party/blink/renderer/core/layout/layout_object_factory.cc b/third_party/blink/renderer/core/layout/layout_object_factory.cc index 439d10fc..a2c13d1 100644 --- a/third_party/blink/renderer/core/layout/layout_object_factory.cc +++ b/third_party/blink/renderer/core/layout/layout_object_factory.cc
@@ -11,13 +11,11 @@ #include "third_party/blink/renderer/core/html/html_frame_set_element.h" #include "third_party/blink/renderer/core/layout/layout_block_flow.h" #include "third_party/blink/renderer/core/layout/layout_counter.h" -#include "third_party/blink/renderer/core/layout/layout_fieldset.h" #include "third_party/blink/renderer/core/layout/layout_frame_set.h" #include "third_party/blink/renderer/core/layout/layout_inside_list_marker.h" #include "third_party/blink/renderer/core/layout/layout_list_item.h" #include "third_party/blink/renderer/core/layout/layout_list_marker.h" #include "third_party/blink/renderer/core/layout/layout_outside_list_marker.h" -#include "third_party/blink/renderer/core/layout/layout_slider_track.h" #include "third_party/blink/renderer/core/layout/layout_table.h" #include "third_party/blink/renderer/core/layout/layout_table_caption.h" #include "third_party/blink/renderer/core/layout/layout_table_cell.h" @@ -26,8 +24,6 @@ #include "third_party/blink/renderer/core/layout/layout_table_section.h" #include "third_party/blink/renderer/core/layout/layout_text.h" #include "third_party/blink/renderer/core/layout/layout_text_combine.h" -#include "third_party/blink/renderer/core/layout/layout_text_control_multi_line.h" -#include "third_party/blink/renderer/core/layout/layout_text_control_single_line.h" #include "third_party/blink/renderer/core/layout/layout_text_fragment.h" #include "third_party/blink/renderer/core/layout/layout_view.h" #include "third_party/blink/renderer/core/layout/ng/custom/layout_ng_custom.h" @@ -39,30 +35,22 @@ #include "third_party/blink/renderer/core/layout/ng/inline/layout_ng_text_fragment.h" #include "third_party/blink/renderer/core/layout/ng/inline/layout_ng_word_break.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_block_flow.h" -#include "third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_frame_set.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_progress.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_ruby_as_block.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_ruby_text.h" -#include "third_party/blink/renderer/core/layout/ng/layout_ng_text_control_inner_editor.h" -#include "third_party/blink/renderer/core/layout/ng/layout_ng_text_control_multi_line.h" -#include "third_party/blink/renderer/core/layout/ng/layout_ng_text_control_single_line.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_view.h" #include "third_party/blink/renderer/core/layout/ng/list/layout_ng_inside_list_marker.h" #include "third_party/blink/renderer/core/layout/ng/list/layout_ng_list_item.h" #include "third_party/blink/renderer/core/layout/ng/list/layout_ng_outside_list_marker.h" #include "third_party/blink/renderer/core/layout/ng/mathml/layout_ng_mathml_block.h" #include "third_party/blink/renderer/core/layout/ng/mathml/layout_ng_mathml_block_flow.h" -#include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_foreign_object.h" -#include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_caption.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_cell.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_column.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_section.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" #include "third_party/blink/renderer/core/mathml/mathml_element.h" #include "third_party/blink/renderer/core/mathml/mathml_token_element.h" #include "third_party/blink/renderer/core/style/computed_style.h" @@ -237,13 +225,6 @@ return new_object; } -LayoutBlock* LayoutObjectFactory::CreateFieldset(Node& node, - const ComputedStyle& style, - LegacyLayout legacy) { - return CreateObject<LayoutBlock, LayoutNGFieldset, LayoutFieldset>(node, - legacy); -} - LayoutBox* LayoutObjectFactory::CreateFrameSet(HTMLFrameSetElement& element, const ComputedStyle& style, LegacyLayout legacy) { @@ -251,37 +232,6 @@ legacy); } -LayoutObject* LayoutObjectFactory::CreateSliderTrack(Node& node, - const ComputedStyle& style, - LegacyLayout legacy) { - return CreateObject<LayoutBlock, LayoutNGBlockFlow, LayoutSliderTrack>( - node, legacy); -} - -LayoutObject* LayoutObjectFactory::CreateTextControlInnerEditor( - Node& node, - const ComputedStyle& style, - LegacyLayout legacy) { - return CreateObject<LayoutBlockFlow, LayoutNGTextControlInnerEditor, - LayoutTextControlInnerEditor>(node, legacy); -} - -LayoutObject* LayoutObjectFactory::CreateTextControlMultiLine( - Node& node, - const ComputedStyle& style, - LegacyLayout legacy) { - return CreateObject<LayoutBlockFlow, LayoutNGTextControlMultiLine, - LayoutTextControlMultiLine>(node, legacy); -} - -LayoutObject* LayoutObjectFactory::CreateTextControlSingleLine( - Node& node, - const ComputedStyle& style, - LegacyLayout legacy) { - return CreateObject<LayoutBlockFlow, LayoutNGTextControlSingleLine, - LayoutTextControlSingleLine>(node, legacy); -} - LayoutText* LayoutObjectFactory::CreateText(Node* node, scoped_refptr<StringImpl> str, LegacyLayout legacy) { @@ -347,22 +297,6 @@ return CreateObject<LayoutRubyText, LayoutNGRubyText>(*node, legacy); } -LayoutObject* LayoutObjectFactory::CreateSVGForeignObject( - Node& node, - const ComputedStyle& style, - LegacyLayout legacy) { - return CreateObject<LayoutBlockFlow, LayoutNGSVGForeignObject, - LayoutSVGForeignObject>(node, legacy, - /*disable_ng_for_type=*/false); -} - -LayoutObject* LayoutObjectFactory::CreateSVGText(Node& node, - const ComputedStyle& style, - LegacyLayout legacy) { - return CreateObject<LayoutBlockFlow, LayoutNGSVGText, LayoutSVGText>(node, - legacy); -} - LayoutObject* LayoutObjectFactory::CreateBR(Node* node, LegacyLayout legacy) { return CreateObject<LayoutObject, LayoutNGBR, LayoutBR>(*node, legacy); }
diff --git a/third_party/blink/renderer/core/layout/layout_object_factory.h b/third_party/blink/renderer/core/layout/layout_object_factory.h index ab40696..d6166ef 100644 --- a/third_party/blink/renderer/core/layout/layout_object_factory.h +++ b/third_party/blink/renderer/core/layout/layout_object_factory.h
@@ -70,22 +70,9 @@ static LayoutObject* CreateCounter(PseudoElement& pseduo, const CounterContentData& counter, LegacyLayout legacy); - static LayoutBlock* CreateFieldset(Node&, const ComputedStyle&, LegacyLayout); static LayoutBox* CreateFrameSet(HTMLFrameSetElement& element, const ComputedStyle& style, LegacyLayout legacy); - static LayoutObject* CreateSliderTrack(Node& node, - const ComputedStyle& style, - LegacyLayout legacy); - static LayoutObject* CreateTextControlInnerEditor(Node& node, - const ComputedStyle& style, - LegacyLayout legacy); - static LayoutObject* CreateTextControlMultiLine(Node& node, - const ComputedStyle& style, - LegacyLayout legacy); - static LayoutObject* CreateTextControlSingleLine(Node& node, - const ComputedStyle& style, - LegacyLayout legacy); static LayoutText* CreateText(Node*, scoped_refptr<StringImpl>, LegacyLayout); static LayoutText* CreateTextCombine(Node*, @@ -106,13 +93,6 @@ const ComputedStyle& style, LegacyLayout legacy); - static LayoutObject* CreateSVGForeignObject(Node& node, - const ComputedStyle& style, - LegacyLayout legacy); - static LayoutObject* CreateSVGText(Node& node, - const ComputedStyle& style, - LegacyLayout legacy); - static LayoutObject* CreateBR(Node*, LegacyLayout); static LayoutObject* CreateWordBreak(HTMLElement*, LegacyLayout);
diff --git a/third_party/blink/renderer/core/layout/layout_replaced.cc b/third_party/blink/renderer/core/layout/layout_replaced.cc index 3ef94a99..e03aea5 100644 --- a/third_party/blink/renderer/core/layout/layout_replaced.cc +++ b/third_party/blink/renderer/core/layout/layout_replaced.cc
@@ -126,11 +126,6 @@ PhysicalRect old_content_rect = ReplacedContentRect(); - if (!RuntimeEnabledFeatures::LayoutNGReplacedNoBoxSettersEnabled()) { - UpdateLogicalWidth(); - UpdateLogicalHeight(); - } - ClearLayoutOverflow(); ClearSelfNeedsLayoutOverflowRecalc(); ClearChildNeedsLayoutOverflowRecalc(); @@ -867,8 +862,7 @@ } LayoutSize LayoutReplaced::SizeFromNG() const { - if (!RuntimeEnabledFeatures::LayoutNGReplacedNoBoxSettersEnabled() || - !GetBoxLayoutExtraInput()) { + if (!GetBoxLayoutExtraInput()) { return Size(); } LayoutSize new_size(OverrideLogicalWidth(), OverrideLogicalHeight()); @@ -878,8 +872,7 @@ } NGPhysicalBoxStrut LayoutReplaced::BorderPaddingFromNG() const { - if (RuntimeEnabledFeatures::LayoutNGReplacedNoBoxSettersEnabled() && - GetBoxLayoutExtraInput()) { + if (GetBoxLayoutExtraInput()) { return GetBoxLayoutExtraInput()->border_padding_for_replaced; } return NGPhysicalBoxStrut(
diff --git a/third_party/blink/renderer/core/layout/layout_slider_track.cc b/third_party/blink/renderer/core/layout/layout_slider_track.cc deleted file mode 100644 index 93b8918..0000000 --- a/third_party/blink/renderer/core/layout/layout_slider_track.cc +++ /dev/null
@@ -1,90 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT - * OWNER 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/core/layout/layout_slider_track.h" - -#include "third_party/blink/renderer/core/dom/shadow_root.h" -#include "third_party/blink/renderer/core/html/forms/html_input_element.h" -#include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h" - -namespace blink { - -LayoutSliderTrack::LayoutSliderTrack(Element* element) - : LayoutBlockFlow(element) {} - -void LayoutSliderTrack::UpdateLayout() { - NOT_DESTROYED(); - auto* input = To<HTMLInputElement>(GetNode()->OwnerShadowHost()); - const bool is_vertical = !StyleRef().IsHorizontalWritingMode(); - - Element* thumb_element = input->UserAgentShadowRoot()->getElementById( - shadow_element_names::kIdSliderThumb); - LayoutBox* thumb = thumb_element ? thumb_element->GetLayoutBox() : nullptr; - - SubtreeLayoutScope layout_scope(*this); - // Force a layout to reset the position of the thumb so the code below doesn't - // move the thumb to the wrong place. - // This is necessary for |web_tests/media/controls/ - // progress-bar-repaint-on-size-change.html|. - if (thumb) - layout_scope.SetChildNeedsLayout(thumb); - - LayoutBlockFlow::UpdateLayout(); - - // These should always exist, unless someone mutates the shadow DOM (e.g., in - // the inspector). - if (!thumb) - return; - - double percentage_offset = input->RatioValue().ToDouble(); - LayoutUnit available_extent = is_vertical ? ContentHeight() : ContentWidth(); - available_extent -= - is_vertical ? thumb->Size().Height() : thumb->Size().Width(); - LayoutUnit offset(percentage_offset * available_extent); - LayoutPoint thumb_location = thumb->Location(); - if (is_vertical) { - thumb_location.SetY(thumb_location.Y() - offset); - } else if (StyleRef().IsLeftToRightDirection()) { - thumb_location.SetX(thumb_location.X() + offset); - } else { - thumb_location.SetX(thumb_location.X() - offset); - } - thumb->SetLocation(thumb_location); - - // We need one-off invalidation code here because painting of the timeline - // element does not go through style. - // Instead it has a custom implementation in C++ code. - // Therefore the style system cannot understand when it needs to be paint - // invalidated. - Parent()->SetShouldDoFullPaintInvalidation(); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/layout_slider_track.h b/third_party/blink/renderer/core/layout/layout_slider_track.h deleted file mode 100644 index 3fa14da1..0000000 --- a/third_party/blink/renderer/core/layout/layout_slider_track.h +++ /dev/null
@@ -1,49 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT - * OWNER 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_CORE_LAYOUT_LAYOUT_SLIDER_TRACK_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_SLIDER_TRACK_H_ - -#include "third_party/blink/renderer/core/layout/layout_block_flow.h" - -namespace blink { - -class LayoutSliderTrack final : public LayoutBlockFlow { - public: - explicit LayoutSliderTrack(Element*); - - private: - void UpdateLayout() override; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_SLIDER_TRACK_H_
diff --git a/third_party/blink/renderer/core/layout/layout_text_control.cc b/third_party/blink/renderer/core/layout/layout_text_control.cc index 655c611..24b568c 100644 --- a/third_party/blink/renderer/core/layout/layout_text_control.cc +++ b/third_party/blink/renderer/core/layout/layout_text_control.cc
@@ -23,44 +23,19 @@ #include "third_party/blink/renderer/core/layout/layout_text_control.h" #include "third_party/blink/renderer/core/css/style_change_reason.h" -#include "third_party/blink/renderer/core/html/forms/html_text_area_element.h" -#include "third_party/blink/renderer/core/html/forms/text_control_element.h" -#include "third_party/blink/renderer/core/layout/hit_test_result.h" -#include "third_party/blink/renderer/core/layout/layout_object_inlines.h" +#include "third_party/blink/renderer/core/html/html_element.h" +#include "third_party/blink/renderer/core/layout/layout_block.h" +#include "third_party/blink/renderer/core/layout/text_run_constructor.h" #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" namespace blink { -LayoutTextControl::LayoutTextControl(TextControlElement* element) - : LayoutBlockFlow(element) { - DCHECK(element); -} +namespace layout_text_control { -LayoutTextControl::~LayoutTextControl() = default; - -TextControlElement* LayoutTextControl::GetTextControlElement() const { - NOT_DESTROYED(); - return ToTextControl(GetNode()); -} - -TextControlInnerEditorElement* LayoutTextControl::InnerEditorElement() const { - NOT_DESTROYED(); - return GetTextControlElement()->InnerEditorElement(); -} - -void LayoutTextControl::StyleDidChange(StyleDifference diff, - const ComputedStyle* old_style) { - NOT_DESTROYED(); - LayoutBlockFlow::StyleDidChange(diff, old_style); - StyleDidChange(InnerEditorElement(), old_style, StyleRef()); -} - -// static -void LayoutTextControl::StyleDidChange(HTMLElement* inner_editor, - const ComputedStyle* old_style, - const ComputedStyle& new_style) { +void StyleDidChange(HTMLElement* inner_editor, + const ComputedStyle* old_style, + const ComputedStyle& new_style) { if (!inner_editor) return; LayoutBlock* inner_editor_layout_object = @@ -89,20 +64,18 @@ } } -// static -int LayoutTextControl::ScrollbarThickness(const LayoutBox& box) { +int ScrollbarThickness(const LayoutBox& box) { const Page& page = *box.GetDocument().GetPage(); return page.GetScrollbarTheme().ScrollbarThickness( page.GetChromeClient().WindowToViewportScalar(box.GetFrame(), 1.0f), box.StyleRef().ScrollbarWidth()); } -void LayoutTextControl::HitInnerEditorElement( - const LayoutBox& box, - HTMLElement& inner_editor, - HitTestResult& result, - const HitTestLocation& hit_test_location, - const PhysicalOffset& accumulated_offset) { +void HitInnerEditorElement(const LayoutBox& box, + HTMLElement& inner_editor, + HitTestResult& result, + const HitTestLocation& hit_test_location, + const PhysicalOffset& accumulated_offset) { if (!inner_editor.GetLayoutObject()) return; @@ -155,7 +128,7 @@ // avgCharWidth from the width of a '0'. This only seems to apply to a fixed // number of Mac fonts, but, in order to get similar rendering across platforms, // we do this check for all platforms. -bool LayoutTextControl::HasValidAvgCharWidth(const Font& font) { +bool HasValidAvgCharWidth(const Font& font) { const SimpleFontData* font_data = font.PrimaryFont(); DCHECK(font_data); if (!font_data) @@ -185,8 +158,7 @@ return !font_families_with_invalid_char_width_map->Contains(family); } -// static -float LayoutTextControl::GetAvgCharWidth(const ComputedStyle& style) { +float GetAvgCharWidth(const ComputedStyle& style) { const Font& font = style.GetFont(); const SimpleFontData* primary_font = font.PrimaryFont(); if (primary_font && HasValidAvgCharWidth(font)) { @@ -206,60 +178,6 @@ return font.Width(text_run); } -void LayoutTextControl::AddOutlineRects(Vector<PhysicalRect>& rects, - OutlineInfo* info, - const PhysicalOffset& additional_offset, - NGOutlineType) const { - NOT_DESTROYED(); - rects.emplace_back(additional_offset, Size()); - if (info) - *info = OutlineInfo::GetFromStyle(StyleRef()); -} - -LayoutObject* LayoutTextControl::LayoutSpecialExcludedChild( - bool relayout_children, - SubtreeLayoutScope& layout_scope) { - NOT_DESTROYED(); - HTMLElement* placeholder = ToTextControl(GetNode())->PlaceholderElement(); - LayoutObject* placeholder_layout_object = - placeholder ? placeholder->GetLayoutObject() : nullptr; - if (!placeholder_layout_object) - return nullptr; - if (relayout_children) - layout_scope.SetChildNeedsLayout(placeholder_layout_object); - return placeholder_layout_object; -} - -LayoutUnit LayoutTextControl::FirstLineBoxBaseline() const { - NOT_DESTROYED(); - if (ShouldApplyLayoutContainment()) - return LayoutUnit(-1); - - LayoutUnit result = LayoutBlock::FirstLineBoxBaseline(); - if (result != -1) - return result; - - // When the text is empty, |LayoutBlock::firstLineBoxBaseline()| cannot - // compute the baseline because lineboxes do not exist. - Element* inner_editor = InnerEditorElement(); - if (!inner_editor || !inner_editor->GetLayoutObject()) - return LayoutUnit(-1); - - LayoutBlock* inner_editor_layout_object = - To<LayoutBlock>(inner_editor->GetLayoutObject()); - const SimpleFontData* font_data = - inner_editor_layout_object->Style(true)->GetFont().PrimaryFont(); - DCHECK(font_data); - if (!font_data) - return LayoutUnit(-1); - - LayoutUnit baseline(font_data->GetFontMetrics().Ascent(kAlphabeticBaseline)); - for (LayoutObject* box = inner_editor_layout_object; box && box != this; - box = box->Parent()) { - if (box->IsBox()) - baseline += To<LayoutBox>(box)->LogicalTop(); - } - return baseline; -} +} // namespace layout_text_control } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/layout_text_control.h b/third_party/blink/renderer/core/layout/layout_text_control.h index e3e3734..b8e6113 100644 --- a/third_party/blink/renderer/core/layout/layout_text_control.h +++ b/third_party/blink/renderer/core/layout/layout_text_control.h
@@ -23,76 +23,32 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_CONTROL_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_CONTROL_H_ -#include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/core/layout/layout_block_flow.h" - namespace blink { -class TextControlElement; -class TextControlInnerEditorElement; +class ComputedStyle; +class Font; +class HTMLElement; +class HitTestLocation; +class HitTestResult; +class LayoutBox; +struct PhysicalOffset; -class CORE_EXPORT LayoutTextControl : public LayoutBlockFlow { - public: - ~LayoutTextControl() override; +namespace layout_text_control { - TextControlElement* GetTextControlElement() const; - const char* GetName() const override { - NOT_DESTROYED(); - return "LayoutTextControl"; - } +void StyleDidChange(HTMLElement* inner_editor, + const ComputedStyle* old_style, + const ComputedStyle& new_style); +int ScrollbarThickness(const LayoutBox& box); +float GetAvgCharWidth(const ComputedStyle& style); +bool HasValidAvgCharWidth(const Font& font); - bool CreatesNewFormattingContext() const final { - NOT_DESTROYED(); - // INPUT and other replaced elements rendered by Blink itself should be - // completely contained. - return true; - } +void HitInnerEditorElement(const LayoutBox& box, + HTMLElement& inner_editor, + HitTestResult&, + const HitTestLocation&, + const PhysicalOffset& accumulated_offset); - static void StyleDidChange(HTMLElement* inner_editor, - const ComputedStyle* old_style, - const ComputedStyle& new_style); - static int ScrollbarThickness(const LayoutBox& box); - static float GetAvgCharWidth(const ComputedStyle& style); - static bool HasValidAvgCharWidth(const Font& font); - - static void HitInnerEditorElement(const LayoutBox& box, - HTMLElement& inner_editor, - HitTestResult&, - const HitTestLocation&, - const PhysicalOffset& accumulated_offset); - - protected: - LayoutTextControl(TextControlElement*); - - // This convenience function should not be made public because - // innerEditorElement may outlive the layout tree. - TextControlInnerEditorElement* InnerEditorElement() const; - - void StyleDidChange(StyleDifference, const ComputedStyle* old_style) override; - - LayoutObject* LayoutSpecialExcludedChild(bool relayout_children, - SubtreeLayoutScope&) override; - - LayoutUnit FirstLineBoxBaseline() const override; - - bool IsOfType(LayoutObjectType type) const override { - NOT_DESTROYED(); - return type == kLayoutObjectTextControl || LayoutBlockFlow::IsOfType(type); - } - - private: - void RemoveLeftoverAnonymousBlock(LayoutBlock*) final { NOT_DESTROYED(); } - - void AddOutlineRects(Vector<PhysicalRect>&, - OutlineInfo*, - const PhysicalOffset& additional_offset, - NGOutlineType) const final; - - bool CanBeProgrammaticallyScrolled() const final { - NOT_DESTROYED(); - return true; - } -}; +} // namespace layout_text_control } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/layout_text_control_multi_line.cc b/third_party/blink/renderer/core/layout/layout_text_control_multi_line.cc deleted file mode 100644 index 32a9344..0000000 --- a/third_party/blink/renderer/core/layout/layout_text_control_multi_line.cc +++ /dev/null
@@ -1,88 +0,0 @@ -/** - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * (C) 2008 Torch Mobile Inc. All rights reserved. - * (http://www.torchmobile.com/) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "third_party/blink/renderer/core/layout/layout_text_control_multi_line.h" - -#include "third_party/blink/renderer/core/html/forms/html_text_area_element.h" -#include "third_party/blink/renderer/core/layout/hit_test_result.h" -#include "third_party/blink/renderer/core/layout/layout_theme.h" - -namespace blink { - -LayoutTextControlMultiLine::LayoutTextControlMultiLine(Element* element) - : LayoutTextControl(To<TextControlElement>(element)) { - DCHECK(IsA<HTMLTextAreaElement>(element)); -} - -LayoutTextControlMultiLine::~LayoutTextControlMultiLine() = default; - -bool LayoutTextControlMultiLine::NodeAtPoint( - HitTestResult& result, - const HitTestLocation& hit_test_location, - const PhysicalOffset& accumulated_offset, - HitTestPhase phase) { - NOT_DESTROYED(); - if (!LayoutTextControl::NodeAtPoint(result, hit_test_location, - accumulated_offset, phase)) - return false; - - const LayoutObject* stop_node = result.GetHitTestRequest().GetStopNode(); - if (stop_node && stop_node->NodeForHitTest() == result.InnerNode()) - return true; - - if (result.InnerNode() == GetNode() || - result.InnerNode() == InnerEditorElement()) { - HitInnerEditorElement(*this, *InnerEditorElement(), result, - hit_test_location, accumulated_offset); - } - return true; -} - -LayoutUnit LayoutTextControlMultiLine::BaselinePosition( - FontBaseline baseline_type, - bool first_line, - LineDirectionMode direction, - LinePositionMode line_position_mode) const { - NOT_DESTROYED(); - return LayoutBox::BaselinePosition(baseline_type, first_line, direction, - line_position_mode); -} - -LayoutObject* LayoutTextControlMultiLine::LayoutSpecialExcludedChild( - bool relayout_children, - SubtreeLayoutScope& layout_scope) { - NOT_DESTROYED(); - LayoutObject* placeholder_layout_object = - LayoutTextControl::LayoutSpecialExcludedChild(relayout_children, - layout_scope); - if (!placeholder_layout_object) - return nullptr; - if (!placeholder_layout_object->IsBox()) - return placeholder_layout_object; - auto* placeholder_box = To<LayoutBox>(placeholder_layout_object); - placeholder_box->LayoutIfNeeded(); - placeholder_box->SetX(BorderLeft() + PaddingLeft()); - placeholder_box->SetY(BorderTop() + PaddingTop()); - return placeholder_layout_object; -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/layout_text_control_multi_line.h b/third_party/blink/renderer/core/layout/layout_text_control_multi_line.h deleted file mode 100644 index 8f47f3a..0000000 --- a/third_party/blink/renderer/core/layout/layout_text_control_multi_line.h +++ /dev/null
@@ -1,65 +0,0 @@ -/* - * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. - * (http://www.torchmobile.com/) - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_CONTROL_MULTI_LINE_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_CONTROL_MULTI_LINE_H_ - -#include "third_party/blink/renderer/core/layout/layout_text_control.h" - -namespace blink { - -class LayoutTextControlMultiLine final : public LayoutTextControl { - public: - explicit LayoutTextControlMultiLine(Element*); - ~LayoutTextControlMultiLine() override; - - private: - bool IsOfType(LayoutObjectType type) const override { - NOT_DESTROYED(); - return type == kLayoutObjectTextControlMultiLine || - LayoutTextControl::IsOfType(type); - } - - bool NodeAtPoint(HitTestResult&, - const HitTestLocation&, - const PhysicalOffset& accumulated_offset, - HitTestPhase) override; - - // We override the two baseline functions because we want our baseline to be - // the bottom of our margin box. - LayoutUnit BaselinePosition( - FontBaseline, - bool first_line, - LineDirectionMode, - LinePositionMode = kPositionOnContainingLine) const override; - LayoutUnit InlineBlockBaseline(LineDirectionMode) const override { - NOT_DESTROYED(); - return LayoutUnit(-1); - } - - LayoutObject* LayoutSpecialExcludedChild(bool relayout_children, - SubtreeLayoutScope&) override; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_CONTROL_MULTI_LINE_H_
diff --git a/third_party/blink/renderer/core/layout/layout_text_control_single_line.cc b/third_party/blink/renderer/core/layout/layout_text_control_single_line.cc deleted file mode 100644 index ab03f78b7..0000000 --- a/third_party/blink/renderer/core/layout/layout_text_control_single_line.cc +++ /dev/null
@@ -1,190 +0,0 @@ -/** - * Copyright (C) 2006, 2007, 2010 Apple Inc. All rights reserved. - * (C) 2008 Torch Mobile Inc. All rights reserved. - * (http://www.torchmobile.com/) - * Copyright (C) 2010 Google Inc. All rights reserved. - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "third_party/blink/renderer/core/layout/layout_text_control_single_line.h" - -#include "third_party/blink/renderer/core/css_value_keywords.h" -#include "third_party/blink/renderer/core/dom/shadow_root.h" -#include "third_party/blink/renderer/core/frame/local_frame_view.h" -#include "third_party/blink/renderer/core/html/forms/html_input_element.h" -#include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h" -#include "third_party/blink/renderer/core/layout/hit_test_result.h" -#include "third_party/blink/renderer/core/paint/text_control_single_line_painter.h" -#include "third_party/blink/renderer/platform/fonts/simple_font_data.h" - -namespace blink { - -LayoutTextControlSingleLine::LayoutTextControlSingleLine(Element* element) - : LayoutTextControl(To<TextControlElement>(element)) { - DCHECK(IsA<HTMLInputElement>(element)); -} - -LayoutTextControlSingleLine::~LayoutTextControlSingleLine() = default; - -inline Element* LayoutTextControlSingleLine::ContainerElement() const { - NOT_DESTROYED(); - return InputElement()->UserAgentShadowRoot()->getElementById( - shadow_element_names::kIdTextFieldContainer); -} - -inline Element* LayoutTextControlSingleLine::EditingViewPortElement() const { - NOT_DESTROYED(); - return InputElement()->UserAgentShadowRoot()->getElementById( - shadow_element_names::kIdEditingViewPort); -} - -inline HTMLElement* LayoutTextControlSingleLine::InnerSpinButtonElement() - const { - NOT_DESTROYED(); - return To<HTMLElement>(InputElement()->UserAgentShadowRoot()->getElementById( - shadow_element_names::kIdSpinButton)); -} - -void LayoutTextControlSingleLine::Paint(const PaintInfo& paint_info) const { - NOT_DESTROYED(); - TextControlSingleLinePainter(*this).Paint(paint_info); -} - -void LayoutTextControlSingleLine::UpdateLayout() { - NOT_DESTROYED(); - - LayoutBlockFlow::UpdateBlockLayout(true); - - LayoutBox* inner_editor_layout_object = InnerEditorElement()->GetLayoutBox(); - Element* container = ContainerElement(); - LayoutBox* container_layout_object = - container ? container->GetLayoutBox() : nullptr; - // Center the child block in the block progression direction (vertical - // centering for horizontal text fields). - if (!container && inner_editor_layout_object && - inner_editor_layout_object->Size().Height() != ContentLogicalHeight()) { - LayoutUnit logical_height_diff = - inner_editor_layout_object->LogicalHeight() - ContentLogicalHeight(); - inner_editor_layout_object->SetLogicalTop( - inner_editor_layout_object->LogicalTop() - - (logical_height_diff / 2 + LayoutMod(logical_height_diff, 2))); - } else if (container && container_layout_object && - container_layout_object->Size().Height() != - ContentLogicalHeight()) { - LayoutUnit logical_height_diff = - container_layout_object->LogicalHeight() - ContentLogicalHeight(); - container_layout_object->SetLogicalTop( - container_layout_object->LogicalTop() - - (logical_height_diff / 2 + LayoutMod(logical_height_diff, 2))); - } - - HTMLElement* placeholder_element = InputElement()->PlaceholderElement(); - if (LayoutBox* placeholder_box = - placeholder_element ? placeholder_element->GetLayoutBox() : nullptr) { - LayoutUnit inner_editor_logical_width; - - if (inner_editor_layout_object) - inner_editor_logical_width = inner_editor_layout_object->LogicalWidth(); - placeholder_box->SetOverrideLogicalWidth(inner_editor_logical_width); - bool needed_layout = placeholder_box->NeedsLayout(); - placeholder_box->LayoutIfNeeded(); - LayoutPoint text_offset; - if (inner_editor_layout_object) - text_offset = inner_editor_layout_object->Location(); - if (EditingViewPortElement() && EditingViewPortElement()->GetLayoutBox()) - text_offset += - ToLayoutSize(EditingViewPortElement()->GetLayoutBox()->Location()); - if (container_layout_object) - text_offset += ToLayoutSize(container_layout_object->Location()); - if (inner_editor_layout_object) { - // We use inlineBlockBaseline() for innerEditor because it has no - // inline boxes when we show the placeholder. - LayoutUnit inner_editor_baseline = - inner_editor_layout_object->InlineBlockBaseline(kHorizontalLine); - // We use firstLineBoxBaseline() for placeholder. - // TODO(tkent): It's inconsistent with innerEditorBaseline. However - // placeholderBox->inlineBlockBase() is unexpectedly larger. - LayoutUnit placeholder_baseline = placeholder_box->FirstLineBoxBaseline(); - text_offset += LayoutSize(LayoutUnit(), - inner_editor_baseline - placeholder_baseline); - } - placeholder_box->SetLocation(text_offset); - - // The placeholder gets layout last, after the parent text control and its - // other children, so in order to get the correct overflow from the - // placeholder we need to recompute it now. - if (needed_layout) { - SetNeedsOverflowRecalc(); - ComputeLayoutOverflow(ClientLogicalBottom()); - } - } -} - -bool LayoutTextControlSingleLine::NodeAtPoint( - HitTestResult& result, - const HitTestLocation& hit_test_location, - const PhysicalOffset& accumulated_offset, - HitTestPhase phase) { - NOT_DESTROYED(); - if (!LayoutTextControl::NodeAtPoint(result, hit_test_location, - accumulated_offset, phase)) - return false; - - const LayoutObject* stop_node = result.GetHitTestRequest().GetStopNode(); - if (stop_node && stop_node->NodeForHitTest() == result.InnerNode()) - return true; - - // Say that we hit the inner text element if - // - we hit a node inside the inner text element, - // - we hit the <input> element (e.g. we're over the border or padding), or - // - we hit regions not in any decoration buttons. - Element* container = ContainerElement(); - if (result.InnerNode()->IsDescendantOf(InnerEditorElement()) || - result.InnerNode() == GetNode() || - (container && container == result.InnerNode())) { - HitInnerEditorElement(*this, *InnerEditorElement(), result, - hit_test_location, accumulated_offset); - } - return true; -} - -HTMLInputElement* LayoutTextControlSingleLine::InputElement() const { - NOT_DESTROYED(); - return To<HTMLInputElement>(GetNode()); -} - -void LayoutTextControlSingleLine::ComputeVisualOverflow(bool recompute_floats) { - NOT_DESTROYED(); - LayoutRect previous_visual_overflow_rect = VisualOverflowRect(); - ClearVisualOverflow(); - AddVisualOverflowFromChildren(); - AddVisualEffectOverflow(); - - if (recompute_floats || CreatesNewFormattingContext() || - HasSelfPaintingLayer()) - AddVisualOverflowFromFloats(); - - if (VisualOverflowRect() != previous_visual_overflow_rect) { - InvalidateIntersectionObserverCachedRects(); - SetShouldCheckForPaintInvalidation(); - GetFrameView()->SetIntersectionObservationState(LocalFrameView::kDesired); - } -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/layout_text_control_single_line.h b/third_party/blink/renderer/core/layout/layout_text_control_single_line.h deleted file mode 100644 index 87b32638..0000000 --- a/third_party/blink/renderer/core/layout/layout_text_control_single_line.h +++ /dev/null
@@ -1,105 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. - * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. - * (http://www.torchmobile.com/) - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_CONTROL_SINGLE_LINE_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_CONTROL_SINGLE_LINE_H_ - -#include "third_party/blink/renderer/core/layout/layout_text_control.h" - -namespace blink { - -// LayoutObject for text-field <input>s. -// -// This class inherits from LayoutTextControl and LayoutBlockFlow. If we'd like -// to change the base class, we need to make sure that -// ShouldIgnoreOverflowPropertyForInlineBlockBaseline flag works with the new -// base class. -class LayoutTextControlSingleLine : public LayoutTextControl { - public: - explicit LayoutTextControlSingleLine(Element*); - ~LayoutTextControlSingleLine() override; - - protected: - Element* ContainerElement() const; - Element* EditingViewPortElement() const; - HTMLInputElement* InputElement() const; - - private: - bool IsOfType(LayoutObjectType type) const override { - NOT_DESTROYED(); - return type == kLayoutObjectTextControlSingleLine || - LayoutTextControl::IsOfType(type); - } - - void Paint(const PaintInfo&) const override; - void UpdateLayout() override; - - bool NodeAtPoint(HitTestResult&, - const HitTestLocation&, - const PhysicalOffset& accumulated_offset, - HitTestPhase) final; - - int TextBlockWidth() const; - - void ComputeVisualOverflow(bool recompute_floats) override; - - // If the INPUT content height is smaller than the font height, the - // inner-editor element overflows the INPUT box intentionally, however it - // shouldn't affect outside of the INPUT box. So we ignore child overflow. - void AddLayoutOverflowFromChildren() final { NOT_DESTROYED(); } - - bool RespectsCSSOverflow() const override { - NOT_DESTROYED(); - return false; - } - - HTMLElement* InnerSpinButtonElement() const; -}; - -// ---------------------------- - -class LayoutTextControlInnerEditor : public LayoutBlockFlow { - public: - LayoutTextControlInnerEditor(Element* element) : LayoutBlockFlow(element) { - NOT_DESTROYED(); - } - - private: - bool IsIntrinsicallyScrollable( - ScrollbarOrientation orientation) const override { - NOT_DESTROYED(); - return orientation == kHorizontalScrollbar; - } - bool ScrollsOverflowX() const override { - NOT_DESTROYED(); - return IsScrollContainer(); - } - bool ScrollsOverflowY() const override { - NOT_DESTROYED(); - return false; - } -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_CONTROL_SINGLE_LINE_H_
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 04398bf..563ba06 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
@@ -56,7 +56,6 @@ #include "third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_root.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_shape.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" #include "third_party/blink/renderer/core/layout/svg/svg_layout_tree_as_text.h" #include "third_party/blink/renderer/core/page/print_context.h" #include "third_party/blink/renderer/core/paint/paint_layer.h" @@ -522,10 +521,6 @@ Write(ts, To<LayoutSVGRoot>(o), indent); return; } - if (o.IsSVGText()) { - WriteSVGText(ts, To<LayoutSVGText>(o), indent); - return; - } if (o.IsSVGInline()) { WriteSVGInline(ts, To<LayoutSVGInline>(o), indent); return;
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 0159506..ad721e9 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
@@ -29,7 +29,6 @@ #include "third_party/blink/renderer/core/layout/api/line_layout_box.h" #include "third_party/blink/renderer/core/layout/api/line_layout_list_marker.h" #include "third_party/blink/renderer/core/layout/api/line_layout_ruby_run.h" -#include "third_party/blink/renderer/core/layout/api/line_layout_svg_inline_text.h" #include "third_party/blink/renderer/core/layout/api/line_layout_text.h" #include "third_party/blink/renderer/core/layout/api/line_layout_text_combine.h" #include "third_party/blink/renderer/core/layout/line/inline_iterator.h" @@ -1389,13 +1388,6 @@ const LineLayoutText& layout_text, bool& prohibit_break_inside, bool previous_is_space_or_other_space_separator) { - if (layout_text.IsSVGInlineText() && current_.Offset()) { - // Force creation of new InlineBoxes for each absolute positioned character - // (those that start new text chunks). - if (LineLayoutSVGInlineText(layout_text) - .CharacterStartsNewTextChunk(current_.Offset())) - line_midpoint_state_.EnsureCharacterGetsLineBox(current_); - } if (prohibit_break_inside) { current_.SetNextBreakablePosition(layout_text.TextLength()); prohibit_break_inside = false;
diff --git a/third_party/blink/renderer/core/layout/ng/grid/ng_grid_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/grid/ng_grid_layout_algorithm.cc index a1c3d6e5..63c41be 100644 --- a/third_party/blink/renderer/core/layout/ng/grid/ng_grid_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/grid/ng_grid_layout_algorithm.cc
@@ -281,6 +281,7 @@ : NGGridLayoutSubtree(grid_sizing_tree.FinalizeTree()); Vector<EBreakBetween> row_break_between; + LayoutUnit previously_consumed_grid_block_size; LayoutUnit consumed_grid_block_size; Vector<GridItemPlacementData> grid_items_placement_data; Vector<LayoutUnit> row_offset_adjustments; @@ -291,7 +292,8 @@ const auto* grid_data = To<NGGridBreakTokenData>(BreakToken()->TokenData()); - consumed_grid_block_size = grid_data->consumed_grid_block_size; + previously_consumed_grid_block_size = consumed_grid_block_size = + grid_data->consumed_grid_block_size; grid_items_placement_data = grid_data->grid_items_placement_data; row_offset_adjustments = grid_data->row_offset_adjustments; row_break_between = grid_data->row_break_between; @@ -340,10 +342,10 @@ if (constraint_space.HasKnownFragmentainerBlockSize()) { // |FinishFragmentation| uses |NGBoxFragmentBuilder::IntrinsicBlockSize| to - // determine the final size of this fragment. We don't have an accurate - // "per-fragment" intrinsic block-size so just set it to the trailing - // border-padding. - container_builder_.SetIntrinsicBlockSize(border_padding.block_end); + // determine the final size of this fragment. + container_builder_.SetIntrinsicBlockSize( + consumed_grid_block_size - previously_consumed_grid_block_size + + border_padding.block_end); } else { container_builder_.SetIntrinsicBlockSize(intrinsic_block_size); } @@ -2932,6 +2934,7 @@ const NGGridLayoutData& layout_data, LogicalRect* containing_grid_area, NGGridLayoutSubtree&& layout_subtree, + LayoutUnit unavailable_block_size, bool min_block_size_should_encompass_intrinsic_size, absl::optional<LayoutUnit> opt_fragment_relative_block_offset) const { DCHECK(containing_grid_area); @@ -2944,8 +2947,14 @@ ComputeGridItemAvailableSize(grid_item, layout_data.Rows(), &containing_grid_area->offset.block_offset); + LogicalSize available_size = containing_grid_area->size; + if (available_size.block_size != kIndefiniteSize) { + available_size.block_size -= unavailable_block_size; + DCHECK_GE(available_size.block_size, LayoutUnit()); + } + return CreateConstraintSpace( - NGCacheSlot::kLayout, grid_item, layout_data, containing_grid_area->size, + NGCacheSlot::kLayout, grid_item, layout_data, available_size, /* opt_fixed_block_size */ absl::nullopt, std::move(layout_subtree), min_block_size_should_encompass_intrinsic_size, opt_fragment_relative_block_offset); @@ -3356,6 +3365,7 @@ HeapVector<GridItemPlacementData*> out_of_fragmentainer_space_item_placement; BaselineAccumulator baseline_accumulator(Style().GetFontBaseline()); LayoutUnit max_row_expansion; + LayoutUnit max_item_block_end; wtf_size_t expansion_row_set_index; wtf_size_t breakpoint_row_set_index; bool has_subsequent_children; @@ -3382,6 +3392,7 @@ out_of_fragmentainer_space_item_placement.clear(); baseline_accumulator = BaselineAccumulator(Style().GetFontBaseline()); max_row_expansion = LayoutUnit(); + max_item_block_end = LayoutUnit(); expansion_row_set_index = kNotFound; breakpoint_row_set_index = kNotFound; has_subsequent_children = false; @@ -3407,9 +3418,27 @@ grid_item, item_placement_data .has_descendant_that_depends_on_percentage_block_size); + + LayoutUnit unavailable_block_size; + if (IsBreakInside(BreakToken()) && IsBreakInside(break_token)) { + // If a sibling grid item has overflowed the fragmentainer (in a + // previous fragment) due to monolithic content, the grid container has + // been stretched to encompass it, but the other grid items (like this + // one) have not (we still want the non-overflowed items to fragment + // properly). The available space left in the row needs to be shrunk, in + // order to compensate for this, or this item might overflow the grid + // row. + const auto* grid_data = + To<NGGridBreakTokenData>(BreakToken()->TokenData()); + unavailable_block_size = grid_data->consumed_grid_block_size - + (item_placement_data.offset.block_offset + + break_token->ConsumedBlockSize()); + } + LogicalRect grid_area; const auto space = CreateConstraintSpaceForLayout( grid_item, *layout_data, &grid_area, NGGridLayoutSubtree(), + unavailable_block_size, min_block_size_should_encompass_intrinsic_size, fragment_relative_block_offset); @@ -3551,6 +3580,11 @@ max_row_expansion = std::max(max_row_expansion, item_expansion); } + // Keep track of the tallest item, in case it overflows the fragmentainer + // with monolithic content. + max_item_block_end = + std::max(max_item_block_end, + fragment_relative_block_offset + fragment.BlockSize()); } }; @@ -3658,8 +3692,12 @@ if (auto last_baseline = baseline_accumulator.LastBaseline()) container_builder_.SetLastBaseline(*last_baseline); - if (fragmentainer_space != kIndefiniteSize) - *consumed_grid_block_size += fragmentainer_space; + if (fragmentainer_space != kIndefiniteSize) { + // If there are items overflowing the fragmentainer (due to monolithic + // content), also include that in the consumed grid block-size. + *consumed_grid_block_size += + std::max(fragmentainer_space, max_item_block_end); + } } void NGGridLayoutAlgorithm::PlaceOutOfFlowItems(
diff --git a/third_party/blink/renderer/core/layout/ng/grid/ng_grid_layout_algorithm.h b/third_party/blink/renderer/core/layout/ng/grid/ng_grid_layout_algorithm.h index 26b0ec4..d2fe753 100644 --- a/third_party/blink/renderer/core/layout/ng/grid/ng_grid_layout_algorithm.h +++ b/third_party/blink/renderer/core/layout/ng/grid/ng_grid_layout_algorithm.h
@@ -213,6 +213,7 @@ const NGGridLayoutData& layout_data, LogicalRect* containing_grid_area, NGGridLayoutSubtree&& layout_subtree = NGGridLayoutSubtree(), + LayoutUnit unavailable_block_size = LayoutUnit(), bool min_block_size_should_encompass_intrinsic_size = false, absl::optional<LayoutUnit> opt_fragment_relative_block_offset = absl::nullopt) const;
diff --git a/third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.cc b/third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.cc index bed69f1..f174542 100644 --- a/third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.cc +++ b/third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.cc
@@ -6,7 +6,6 @@ #include "third_party/blink/renderer/core/css/properties/longhands.h" #include "third_party/blink/renderer/core/dom/layout_tree_builder_traversal.h" -#include "third_party/blink/renderer/core/layout/layout_fieldset.h" #include "third_party/blink/renderer/core/layout/layout_object_factory.h" namespace blink { @@ -54,8 +53,7 @@ // > the '::before' and '::after' pseudo-elements) of the fieldset // > element except for the rendered legend, if there is one. - if (new_child->IsRenderedLegendCandidate() && - !LayoutFieldset::FindInFlowLegend(*this)) { + if (new_child->IsRenderedLegendCandidate() && !FindInFlowLegend()) { LayoutNGBlockFlow::AddChild(new_child, FirstChild()); return; } @@ -180,7 +178,7 @@ void LayoutNGFieldset::InvalidatePaint( const PaintInvalidatorContext& context) const { // Fieldset's box decoration painting depends on the legend geometry. - const LayoutBox* legend_box = LayoutFieldset::FindInFlowLegend(*this); + const LayoutBox* legend_box = FindInFlowLegend(); if (legend_box && legend_box->ShouldCheckLayoutForPaintInvalidation()) { GetMutableForPainting().SetShouldDoFullPaintInvalidation( PaintInvalidationReason::kLayout); @@ -192,8 +190,9 @@ const PhysicalRect& local_rect) const { // If the field set has a legend, then it probably does not completely fill // its background. - if (LayoutFieldset::FindInFlowLegend(*this)) + if (FindInFlowLegend()) { return false; + } return LayoutBlockFlow::BackgroundIsKnownToBeOpaqueInRect(local_rect); } @@ -210,4 +209,16 @@ return LayoutNGBlockFlow::ScrollHeight(); } +// static +LayoutBox* LayoutNGFieldset::FindInFlowLegend(const LayoutBlock& fieldset) { + DCHECK(fieldset.IsFieldset()); + for (LayoutObject* legend = fieldset.FirstChild(); legend; + legend = legend->NextSibling()) { + if (legend->IsRenderedLegendCandidate()) { + return To<LayoutBox>(legend); + } + } + return nullptr; +} + } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.h b/third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.h index cd107d65b..258eae82 100644 --- a/third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.h +++ b/third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.h
@@ -29,6 +29,12 @@ LayoutBlock* FindAnonymousFieldsetContentBox() const; + static LayoutBox* FindInFlowLegend(const LayoutBlock& fieldset); + LayoutBox* FindInFlowLegend() const { + NOT_DESTROYED(); + return FindInFlowLegend(*this); + } + protected: bool IsOfType(LayoutObjectType) const override; void InsertedIntoTree() override; @@ -50,7 +56,7 @@ template <> struct DowncastTraits<LayoutNGFieldset> { static bool AllowFrom(const LayoutObject& object) { - return object.IsLayoutNGFieldset(); + return object.IsFieldset(); } };
diff --git a/third_party/blink/renderer/core/layout/ng/layout_ng_text_control_multi_line.cc b/third_party/blink/renderer/core/layout/ng/layout_ng_text_control_multi_line.cc index 42c6037..ab4ac22 100644 --- a/third_party/blink/renderer/core/layout/ng/layout_ng_text_control_multi_line.cc +++ b/third_party/blink/renderer/core/layout/ng/layout_ng_text_control_multi_line.cc
@@ -25,8 +25,8 @@ StyleDifference style_diff, const ComputedStyle* old_style) { LayoutNGBlockFlow::StyleDidChange(style_diff, old_style); - LayoutTextControl::StyleDidChange(InnerEditorElement(), old_style, - StyleRef()); + layout_text_control::StyleDidChange(InnerEditorElement(), old_style, + StyleRef()); } bool LayoutNGTextControlMultiLine::NodeAtPoint( @@ -43,7 +43,7 @@ HTMLElement* inner_editor = InnerEditorElement(); if (result.InnerNode() == GetNode() || result.InnerNode() == inner_editor) { - LayoutTextControl::HitInnerEditorElement( + layout_text_control::HitInnerEditorElement( *this, *inner_editor, result, hit_test_location, accumulated_offset); } return stop_hit_testing;
diff --git a/third_party/blink/renderer/core/layout/ng/layout_ng_text_control_single_line.cc b/third_party/blink/renderer/core/layout/ng/layout_ng_text_control_single_line.cc index 3671b73..ecb3630 100644 --- a/third_party/blink/renderer/core/layout/ng/layout_ng_text_control_single_line.cc +++ b/third_party/blink/renderer/core/layout/ng/layout_ng_text_control_single_line.cc
@@ -39,8 +39,8 @@ StyleDifference style_diff, const ComputedStyle* old_style) { LayoutNGBlockFlow::StyleDidChange(style_diff, old_style); - LayoutTextControl::StyleDidChange(InnerEditorElement(), old_style, - StyleRef()); + layout_text_control::StyleDidChange(InnerEditorElement(), old_style, + StyleRef()); } bool LayoutNGTextControlSingleLine::NodeAtPoint( @@ -67,7 +67,7 @@ if (result.InnerNode()->IsDescendantOf(inner_editor) || result.InnerNode() == GetNode() || (container && container == result.InnerNode())) { - LayoutTextControl::HitInnerEditorElement( + layout_text_control::HitInnerEditorElement( *this, *inner_editor, result, hit_test_location, accumulated_offset); } return stop_hit_testing;
diff --git a/third_party/blink/renderer/core/layout/layout_text_control_single_line_test.cc b/third_party/blink/renderer/core/layout/ng/layout_ng_text_control_single_line_test.cc similarity index 74% rename from third_party/blink/renderer/core/layout/layout_text_control_single_line_test.cc rename to third_party/blink/renderer/core/layout/ng/layout_ng_text_control_single_line_test.cc index aad5843..9948adb 100644 --- a/third_party/blink/renderer/core/layout/layout_text_control_single_line_test.cc +++ b/third_party/blink/renderer/core/layout/ng/layout_ng_text_control_single_line_test.cc
@@ -2,19 +2,15 @@ // 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/core/layout/layout_text_control_single_line.h" - -#include "build/build_config.h" #include "third_party/blink/renderer/core/testing/core_unit_test_helper.h" -#include "ui/base/ui_base_features.h" namespace blink { namespace { -class LayoutTextControlSingleLineTest : public RenderingTest {}; +class LayoutNGTextControlSingleLineTest : public RenderingTest {}; -TEST_F(LayoutTextControlSingleLineTest, VisualOverflowCleared) { +TEST_F(LayoutNGTextControlSingleLineTest, VisualOverflowCleared) { SetBodyInnerHTML(R"HTML( <style> #input {
diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc index 3deaf07..27507ec 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc
@@ -2390,9 +2390,12 @@ NGPreviousInflowPosition* previous_inflow_position) { if (ConstraintSpace().HasKnownFragmentainerBlockSize()) { // The remaining part of the fragmentainer (the unusable space for child - // content, due to the break) should still be occupied by this container. + // content, due to the break) should still be occupied by this + // container. Also encompass fragmentainer overflow (may be caused by + // monolithic content). previous_inflow_position->logical_block_offset = - FragmentainerSpaceLeft(ConstraintSpace()); + std::max(previous_inflow_position->logical_block_offset, + FragmentainerSpaceLeft(ConstraintSpace())); } }
diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_node.cc b/third_party/blink/renderer/core/layout/ng/ng_block_node.cc index ee078f28..7312f8c2 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_block_node.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_block_node.cc
@@ -15,7 +15,6 @@ #include "third_party/blink/renderer/core/layout/geometry/writing_mode_converter.h" #include "third_party/blink/renderer/core/layout/intrinsic_sizing_info.h" #include "third_party/blink/renderer/core/layout/layout_block_flow.h" -#include "third_party/blink/renderer/core/layout/layout_fieldset.h" #include "third_party/blink/renderer/core/layout/layout_inline.h" #include "third_party/blink/renderer/core/layout/layout_multi_column_flow_thread.h" #include "third_party/blink/renderer/core/layout/layout_multi_column_set.h" @@ -182,7 +181,7 @@ CreateAlgorithmAndRun<NGGridLayoutAlgorithm>(params, callback); } else if (box.IsLayoutReplaced()) { CreateAlgorithmAndRun<NGReplacedLayoutAlgorithm>(params, callback); - } else if (box.IsLayoutNGFieldset()) { + } else if (box.IsFieldset()) { CreateAlgorithmAndRun<NGFieldsetLayoutAlgorithm>(params, callback); } else if (box.IsLayoutNGFrameSet()) { CreateAlgorithmAndRun<NGFrameSetLayoutAlgorithm>(params, callback); @@ -863,29 +862,13 @@ << "Forced block size wasn't the fragment's block size?"; input.override_inline_size = fragment.InlineSize(); input.override_block_size = fragment.BlockSize(); - if (RuntimeEnabledFeatures::LayoutNGReplacedNoBoxSettersEnabled()) { - input.border_padding_for_replaced = - physical_fragment.Borders() + physical_fragment.Padding(); - } + input.border_padding_for_replaced = + physical_fragment.Borders() + physical_fragment.Padding(); box_->ComputeAndSetBlockDirectionMargins(box_->ContainingBlock()); if (box_->NeedsLayout()) box_->LayoutIfNeeded(); else box_->ForceLayout(); - -#if DCHECK_IS_ON() - if (!RuntimeEnabledFeatures::LayoutNGReplacedNoBoxSettersEnabled()) { - // Assert that legacy uses the size NG forces above. But legacy sends - // LayoutUnit to float and back, which can slightly change the result. So - // give a 1px cushion. - PhysicalSize difference = - PhysicalSize(box_->Size()) - physical_fragment.Size(); - DCHECK_LE(difference.width.Abs(), LayoutUnit(1)) - << box_->Size() << " " << physical_fragment.Size(); - DCHECK_LE(difference.height.Abs(), LayoutUnit(1)) - << box_->Size() << " " << physical_fragment.Size(); - } -#endif } // If we miss the cache for one result (fragment), we need to clear the @@ -1229,7 +1212,7 @@ if (!IsFieldsetContainer()) return nullptr; return NGBlockNode( - LayoutFieldset::FindInFlowLegend(*To<LayoutBlock>(box_.Get()))); + LayoutNGFieldset::FindInFlowLegend(*To<LayoutBlock>(box_.Get()))); } NGBlockNode NGBlockNode::GetFieldsetContent() const {
diff --git a/third_party/blink/renderer/core/layout/ng/ng_fieldset_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/ng_fieldset_layout_algorithm.cc index f37f2e9c..0615180 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_fieldset_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_fieldset_layout_algorithm.cc
@@ -4,7 +4,6 @@ #include "third_party/blink/renderer/core/layout/ng/ng_fieldset_layout_algorithm.h" -#include "third_party/blink/renderer/core/layout/layout_fieldset.h" #include "third_party/blink/renderer/core/layout/ng/ng_block_break_token.h" #include "third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h" #include "third_party/blink/renderer/core/layout/ng/ng_constraint_space.h"
diff --git a/third_party/blink/renderer/core/layout/ng/ng_layout_input_node.h b/third_party/blink/renderer/core/layout/ng/ng_layout_input_node.h index 37af68b6..555a18a 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_layout_input_node.h +++ b/third_party/blink/renderer/core/layout/ng/ng_layout_input_node.h
@@ -119,9 +119,7 @@ return To<LayoutNGOutsideListMarker>(box_.Get())->NeedsOccupyWholeLine(); } bool IsButton() const { return IsBlock() && box_->IsButton(); } - bool IsFieldsetContainer() const { - return IsBlock() && box_->IsLayoutNGFieldset(); - } + bool IsFieldsetContainer() const { return IsBlock() && box_->IsFieldset(); } bool IsInitialLetterBox() const { return box_->IsInitialLetterBox(); } bool IsMedia() const { return box_->IsMedia(); } bool IsRubyRun() const { return IsBlock() && box_->IsRubyRun(); } @@ -162,10 +160,10 @@ wtf_size_t TableCellRowspan() const; - bool IsTextArea() const { return box_->IsTextAreaIncludingNG(); } - bool IsTextControl() const { return box_->IsTextControlIncludingNG(); } + bool IsTextArea() const { return box_->IsTextArea(); } + bool IsTextControl() const { return box_->IsTextControl(); } bool IsTextControlPlaceholder() const; - bool IsTextField() const { return box_->IsTextFieldIncludingNG(); } + bool IsTextField() const { return box_->IsTextField(); } bool IsMathRoot() const { return box_->IsMathMLRoot(); } bool IsMathML() const { return box_->IsMathML(); }
diff --git a/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_foreign_object.h b/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_foreign_object.h index b9f7af9..d4d46563 100644 --- a/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_foreign_object.h +++ b/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_foreign_object.h
@@ -15,7 +15,28 @@ extern template class CORE_EXTERN_TEMPLATE_EXPORT LayoutNGBlockFlowMixin<LayoutSVGBlock>; -// The LayoutNG representation of SVG <foreignObject>. +// LayoutNGSVGForeignObject is the LayoutObject associated with <foreignobject>. +// http://www.w3.org/TR/SVG/extend.html#ForeignObjectElement +// +// Foreign object is a way of inserting arbitrary non-SVG content into SVG. +// A good example of this is HTML in SVG. Because of this, CSS content has to +// be aware of SVG: e.g. when determining containing blocks we stop at the +// enclosing foreign object (see LayoutObject::ComputeIsFixedContainer). +// +// Note that SVG is also allowed in HTML with the HTML5 parsing rules so SVG +// content also has to be aware of CSS objects. +// See http://www.w3.org/TR/html5/syntax.html#elements-0 with the rules for +// 'foreign elements'. TODO(jchaffraix): Find a better place for this paragraph. +// +// The coordinate space for the descendants of the foreignObject does not +// include the effective zoom (it is baked into any lengths as usual). The +// transform that defines the userspace of the element is: +// +// [CSS transform] * [inverse effective zoom] (* ['x' and 'y' translation]) +// +// Because of this, the frame rect and visual rect includes effective zoom. The +// object bounding box (ObjectBoundingBox method) is however not zoomed to be +// compatible with the expectations of the getBBox() DOM interface. class LayoutNGSVGForeignObject final : public LayoutNGBlockFlowMixin<LayoutSVGBlock> { public: @@ -65,7 +86,7 @@ template <> struct DowncastTraits<LayoutNGSVGForeignObject> { static bool AllowFrom(const LayoutObject& object) { - return object.IsNGSVGForeignObject(); + return object.IsSVGForeignObject(); } };
diff --git a/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_foreign_object_test.cc b/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_foreign_object_test.cc index 581c211304d..b84f140e 100644 --- a/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_foreign_object_test.cc +++ b/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_foreign_object_test.cc
@@ -3,15 +3,412 @@ // found in the LICENSE file. #include "third_party/blink/renderer/core/testing/core_unit_test_helper.h" -#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h" namespace blink { class LayoutNGSVGForeignObjectTest : public RenderingTest { public: - LayoutNGSVGForeignObjectTest() = default; + LayoutNGSVGForeignObjectTest() + : RenderingTest(MakeGarbageCollected<SingleChildLocalFrameClient>()) {} }; +TEST_F(LayoutNGSVGForeignObjectTest, DivInForeignObject) { + SetBodyInnerHTML(R"HTML( + <style>body { margin: 0 }</style> + <svg id='svg' style='width: 500px; height: 400px'> + <foreignObject id='foreign' x='100' y='100' width='300' height='200'> + <div id='div' style='margin: 50px; width: 200px; height: 100px'> + </div> + </foreignObject> + </svg> + )HTML"); + + const auto& svg = *GetDocument().getElementById("svg"); + const auto& foreign = *GetDocument().getElementById("foreign"); + const auto& foreign_object = *GetLayoutObjectByElementId("foreign"); + const auto& div = *GetLayoutObjectByElementId("div"); + + EXPECT_EQ(gfx::RectF(100, 100, 300, 200), foreign_object.ObjectBoundingBox()); + EXPECT_EQ(AffineTransform(), foreign_object.LocalSVGTransform()); + EXPECT_EQ(AffineTransform(), foreign_object.LocalToSVGParentTransform()); + + // MapToVisualRectInAncestorSpace + PhysicalRect div_rect(0, 0, 100, 50); + EXPECT_TRUE(div.MapToVisualRectInAncestorSpace(&GetLayoutView(), div_rect)); + EXPECT_EQ(PhysicalRect(150, 150, 100, 50), div_rect); + + // LocalToAncestorPoint + EXPECT_EQ(PhysicalOffset(150, 150), + div.LocalToAncestorPoint(PhysicalOffset(), &GetLayoutView(), + kTraverseDocumentBoundaries)); + + // MapAncestorToLocal + EXPECT_EQ(PhysicalOffset(-150, -150), + div.AncestorToLocalPoint(&GetLayoutView(), PhysicalOffset(), + kTraverseDocumentBoundaries)); + + // Hit testing + EXPECT_EQ(svg, HitTest(1, 1)); + EXPECT_EQ(foreign, HitTest(149, 149)); + EXPECT_EQ(div.GetNode(), HitTest(150, 150)); + EXPECT_EQ(div.GetNode(), HitTest(349, 249)); + EXPECT_EQ(foreign, HitTest(350, 250)); + EXPECT_EQ(svg, HitTest(450, 350)); + + // Rect based hit testing + auto results = RectBasedHitTest(PhysicalRect(0, 0, 300, 300)); + int count = 0; + EXPECT_EQ(3u, results.size()); + for (auto result : results) { + Node* node = result.Get(); + if (node == svg || node == div.GetNode() || node == foreign) { + count++; + } + } + EXPECT_EQ(3, count); +} + +TEST_F(LayoutNGSVGForeignObjectTest, IframeInForeignObject) { + SetBodyInnerHTML(R"HTML( + <style>body { margin: 0 }</style> + <svg id='svg' style='width: 500px; height: 450px'> + <foreignObject id='foreign' x='100' y='100' width='300' height='250'> + <iframe id=iframe style='border: none; margin: 30px; + width: 240px; height: 190px'></iframe> + </foreignObject> + </svg> + )HTML"); + SetChildFrameHTML(R"HTML( + <style> + body { margin: 0 } + * { background: white; } + </style> + <div id='div' style='margin: 70px; width: 100px; height: 50px'></div> + )HTML"); + UpdateAllLifecyclePhasesForTest(); + + const auto& svg = *GetDocument().getElementById("svg"); + const auto& foreign = *GetDocument().getElementById("foreign"); + const auto& foreign_object = *GetLayoutObjectByElementId("foreign"); + const auto& iframe = *GetDocument().getElementById("iframe"); + const auto& div = *ChildDocument().getElementById("div")->GetLayoutObject(); + + EXPECT_EQ(gfx::RectF(100, 100, 300, 250), foreign_object.ObjectBoundingBox()); + EXPECT_EQ(AffineTransform(), foreign_object.LocalSVGTransform()); + EXPECT_EQ(AffineTransform(), foreign_object.LocalToSVGParentTransform()); + + // MapToVisualRectInAncestorSpace + PhysicalRect div_rect(0, 0, 100, 50); + EXPECT_TRUE(div.MapToVisualRectInAncestorSpace(&GetLayoutView(), div_rect)); + EXPECT_EQ(PhysicalRect(200, 200, 100, 50), div_rect); + + // LocalToAncestorPoint + EXPECT_EQ(PhysicalOffset(200, 200), + div.LocalToAncestorPoint(PhysicalOffset(), &GetLayoutView(), + kTraverseDocumentBoundaries)); + + // AncestorToLocalPoint + EXPECT_EQ(PhysicalOffset(-200, -200), + div.AncestorToLocalPoint(&GetLayoutView(), PhysicalOffset(), + kTraverseDocumentBoundaries)); + + // Hit testing + EXPECT_EQ(svg, HitTest(90, 90)); + EXPECT_EQ(foreign, HitTest(129, 129)); + EXPECT_EQ(ChildDocument().documentElement(), HitTest(130, 130)); + EXPECT_EQ(ChildDocument().documentElement(), HitTest(199, 199)); + EXPECT_EQ(div.GetNode(), HitTest(200, 200)); + EXPECT_EQ(div.GetNode(), HitTest(299, 249)); + EXPECT_EQ(ChildDocument().documentElement(), HitTest(300, 250)); + EXPECT_EQ(ChildDocument().documentElement(), HitTest(369, 319)); + EXPECT_EQ(foreign, HitTest(370, 320)); + EXPECT_EQ(svg, HitTest(450, 400)); + + // Rect based hit testing + auto results = RectBasedHitTest(PhysicalRect(0, 0, 300, 300)); + int count = 0; + EXPECT_EQ(7u, results.size()); + for (auto result : results) { + Node* node = result.Get(); + if (node == svg || node == div.GetNode() || node == foreign || + node == iframe) { + count++; + } + } + EXPECT_EQ(4, count); +} + +TEST_F(LayoutNGSVGForeignObjectTest, HitTestZoomedForeignObject) { + SetBodyInnerHTML(R"HTML( + <style>* { margin: 0; zoom: 150% }</style> + <svg id='svg' style='width: 200px; height: 200px'> + <foreignObject id='foreign' x='10' y='10' width='100' height='150' + style='overflow: visible'> + <div id='div' style='margin: 50px; width: 50px; height: 50px'></div> + </foreignObject> + </svg> + )HTML"); + + const auto& svg = *GetDocument().getElementById("svg"); + const auto& foreign = *GetDocument().getElementById("foreign"); + const auto& foreign_object = *GetLayoutObjectByElementId("foreign"); + const auto& div = *GetDocument().getElementById("div"); + + EXPECT_EQ(gfx::RectF(10, 10, 100, 150), foreign_object.ObjectBoundingBox()); + EXPECT_EQ(AffineTransform(), foreign_object.LocalSVGTransform()); + AffineTransform zoom; + zoom.Scale(1 / foreign_object.StyleRef().EffectiveZoom()); + EXPECT_EQ(zoom, foreign_object.LocalToSVGParentTransform()); + + // MapToVisualRectInAncestorSpace + PhysicalRect div_rect(0, 0, 100, 50); + EXPECT_TRUE(div.GetLayoutObject()->MapToVisualRectInAncestorSpace( + &GetLayoutView(), div_rect)); + // Origin at x=y=(50 * 1.5 + 10) * 1.5 * 1.5 * 1.5 = 286.875 + // Dimensions will be subjected to scaling with 1/1.5 because the + // accumulated zoom on the <fO> is one more than that of its parent <svg>. + EXPECT_EQ(PhysicalRect(286, 286, 68, 35), div_rect); + + PhysicalOffset div_offset(LayoutUnit(286.875), LayoutUnit(286.875)); + // LocalToAncestorPoint + EXPECT_EQ(div_offset, div.GetLayoutObject()->LocalToAncestorPoint( + PhysicalOffset(), &GetLayoutView(), + kTraverseDocumentBoundaries)); + + // AncestorToLocalPoint + EXPECT_EQ(PhysicalOffset(), + div.GetLayoutObject()->AncestorToLocalPoint( + &GetLayoutView(), div_offset, kTraverseDocumentBoundaries)); + + EXPECT_EQ(svg, HitTest(20, 20)); + EXPECT_EQ(foreign, HitTest(280, 280)); + // Check all corners of the <div>. + EXPECT_EQ(div, HitTest(290, 290)); + EXPECT_EQ(div, HitTest(290, 286 + 250)); + EXPECT_EQ(div, HitTest(286 + 250, 290)); + EXPECT_EQ(div, HitTest(286 + 250, 286 + 250)); + // Check (just) outside the <div>. + EXPECT_EQ(svg, HitTest(286 + 256, 290)); + EXPECT_EQ(svg, HitTest(290, 286 + 256)); + + // Rect based hit testing + auto results = RectBasedHitTest(PhysicalRect(0, 0, 300, 300)); + int count = 0; + EXPECT_EQ(3u, results.size()); + for (auto result : results) { + Node* node = result.Get(); + if (node == svg || node == &div || node == foreign) { + count++; + } + } + EXPECT_EQ(3, count); +} + +TEST_F(LayoutNGSVGForeignObjectTest, HitTestViewBoxForeignObject) { + SetBodyInnerHTML(R"HTML( + <svg id='svg' style='width: 200px; height: 200px' viewBox='0 0 100 100'> + <foreignObject id='foreign' x='10' y='10' width='100' height='150'> + <div id='div' style='margin: 50px; width: 50px; height: 50px'> + </div> + </foreignObject> + </svg> + )HTML"); + + const auto& svg = *GetDocument().getElementById("svg"); + const auto& foreign = *GetDocument().getElementById("foreign"); + const auto& div = *GetDocument().getElementById("div"); + + // LocalToAncestorPoint + EXPECT_EQ( + PhysicalOffset(128, 128), + div.GetLayoutObject()->LocalToAncestorPoint( + PhysicalOffset(), &GetLayoutView(), kTraverseDocumentBoundaries)); + + // AncestorToLocalPoint + EXPECT_EQ(PhysicalOffset(), div.GetLayoutObject()->AncestorToLocalPoint( + &GetLayoutView(), PhysicalOffset(128, 128), + kTraverseDocumentBoundaries)); + + EXPECT_EQ(svg, HitTest(20, 20)); + EXPECT_EQ(foreign, HitTest(120, 110)); + EXPECT_EQ(div, HitTest(160, 160)); +} + +TEST_F(LayoutNGSVGForeignObjectTest, HitTestUnderClipPath) { + SetBodyInnerHTML(R"HTML( + <style> + * { + margin: 0 + } + #target { + width: 500px; + height: 500px; + background-color: blue; + } + #target:hover { + background-color: green; + } + </style> + <svg id="svg" style="width: 500px; height: 500px"> + <clipPath id="c"> + <circle cx="250" cy="250" r="200"/> + </clipPath> + <g clip-path="url(#c)"> + <foreignObject id="foreignObject" width="100%" height="100%"> + </foreignObject> + </g> + </svg> + )HTML"); + + const auto& svg = *GetDocument().getElementById("svg"); + const auto& foreignObject = *GetDocument().getElementById("foreignObject"); + + // The fist and the third return |svg| because the circle clip-path + // clips out the foreignObject. + EXPECT_EQ(svg, GetDocument().ElementFromPoint(20, 20)); + EXPECT_EQ(foreignObject, GetDocument().ElementFromPoint(250, 250)); + EXPECT_EQ(svg, GetDocument().ElementFromPoint(400, 400)); +} + +TEST_F(LayoutNGSVGForeignObjectTest, + HitTestUnderClippedPositionedForeignObjectDescendant) { + SetBodyInnerHTML(R"HTML( + <style> + * { + margin: 0 + } + </style> + <svg id="svg" style="width: 600px; height: 600px"> + <foreignObject id="foreignObject" x="200" y="200" width="100" + height="100"> + <div id="target" style="overflow: hidden; position: relative; + width: 100px; height: 50px; left: 5px"></div> + </foreignObject> + </svg> + )HTML"); + + const auto& svg = *GetDocument().getElementById("svg"); + const auto& target = *GetDocument().getElementById("target"); + const auto& foreignObject = *GetDocument().getElementById("foreignObject"); + + EXPECT_EQ(svg, GetDocument().ElementFromPoint(1, 1)); + EXPECT_EQ(foreignObject, GetDocument().ElementFromPoint(201, 201)); + EXPECT_EQ(target, GetDocument().ElementFromPoint(206, 206)); + EXPECT_EQ(foreignObject, GetDocument().ElementFromPoint(205, 255)); + + HitTestRequest request(HitTestRequest::kReadOnly | HitTestRequest::kActive); + HitTestLocation location((PhysicalOffset(206, 206))); + HitTestResult result(request, location); + GetDocument().GetLayoutView()->HitTest(location, result); + EXPECT_EQ(target, result.InnerNode()); + EXPECT_EQ(PhysicalOffset(206, 206), result.PointInInnerNodeFrame()); +} + +TEST_F(LayoutNGSVGForeignObjectTest, + HitTestUnderTransformedForeignObjectDescendant) { + SetBodyInnerHTML(R"HTML( + <style> + * { + margin: 0 + } + </style> + <svg id="svg" style="width: 600px; height: 600px"> + <foreignObject id="foreignObject" x="200" y="200" width="100" + height="100" transform="translate(30)"> + <div id="target" style="overflow: hidden; position: relative; + width: 100px; height: 50px; left: 5px"></div> + </foreignObject> + </svg> + )HTML"); + + const auto& svg = *GetDocument().getElementById("svg"); + const auto& target = *GetDocument().getElementById("target"); + const auto& foreign_object = *GetDocument().getElementById("foreignObject"); + + EXPECT_EQ(svg, GetDocument().ElementFromPoint(1, 1)); + EXPECT_EQ(foreign_object, GetDocument().ElementFromPoint(231, 201)); + EXPECT_EQ(target, GetDocument().ElementFromPoint(236, 206)); + EXPECT_EQ(foreign_object, GetDocument().ElementFromPoint(235, 255)); + + HitTestRequest request(HitTestRequest::kReadOnly | HitTestRequest::kActive); + HitTestLocation location((PhysicalOffset(236, 206))); + HitTestResult result(request, location); + GetDocument().GetLayoutView()->HitTest(location, result); + EXPECT_EQ(target, result.InnerNode()); + EXPECT_EQ(PhysicalOffset(236, 206), result.PointInInnerNodeFrame()); +} + +TEST_F(LayoutNGSVGForeignObjectTest, HitTestUnderScrollingAncestor) { + SetBodyInnerHTML(R"HTML( + <style> + * { + margin: 0 + } + </style> + <div id=scroller style="width: 500px; height: 500px; overflow: auto"> + <svg width="3000" height="3000"> + <foreignObject width="3000" height="3000"> + <div id="target" style="width: 3000px; height: 3000px; background: red"> + </div> + </foreignObject> + </svg> + </div> + )HTML"); + + auto& scroller = *GetDocument().getElementById("scroller"); + const auto& target = *GetDocument().getElementById("target"); + + EXPECT_EQ(target, GetDocument().ElementFromPoint(450, 450)); + + HitTestRequest request(HitTestRequest::kReadOnly | HitTestRequest::kActive); + HitTestLocation location((PhysicalOffset(450, 450))); + HitTestResult result(request, location); + GetDocument().GetLayoutView()->HitTest(location, result); + EXPECT_EQ(target, result.InnerNode()); + EXPECT_EQ(PhysicalOffset(450, 450), result.PointInInnerNodeFrame()); + + scroller.setScrollTop(3000); + + EXPECT_EQ(target, GetDocument().ElementFromPoint(450, 450)); + + GetDocument().GetLayoutView()->HitTest(location, result); + EXPECT_EQ(target, result.InnerNode()); + EXPECT_EQ(PhysicalOffset(450, 450), result.PointInInnerNodeFrame()); +} + +TEST_F(LayoutNGSVGForeignObjectTest, BBoxPropagationZoomed) { + GetFrame().SetPageZoomFactor(2); + SetBodyInnerHTML(R"HTML( + <svg> + <g> + <foreignObject x="6" y="5" width="100" height="50" id="target"/> + </g> + </svg> + )HTML"); + UpdateAllLifecyclePhasesForTest(); + + const auto& target = *GetLayoutObjectByElementId("target"); + ASSERT_EQ(target.StyleRef().EffectiveZoom(), 2); + + EXPECT_EQ(target.ObjectBoundingBox(), gfx::RectF(6, 5, 100, 50)); + EXPECT_EQ(target.StrokeBoundingBox(), gfx::RectF(12, 10, 200, 100)); + const auto& parent_g = *target.Parent(); + EXPECT_EQ(parent_g.ObjectBoundingBox(), gfx::RectF(6, 5, 100, 50)); + EXPECT_EQ(parent_g.StrokeBoundingBox(), gfx::RectF(6, 5, 100, 50)); +} + +// crbug.com/1335655 +TEST_F(LayoutNGSVGForeignObjectTest, SetNeedsCollectInlines) { + SetBodyInnerHTML(R"HTML( + <svg><foreignObject id="target">abc</foreignObject></svg>)HTML"); + UpdateAllLifecyclePhasesForTest(); + + auto* target = GetElementById("target"); + target->setAttribute("unicode-bidi", "bidi-override"); + GetDocument().body()->innerText(); + // Pass if no crash. +} + // crbug.com/1372886 TEST_F(LayoutNGSVGForeignObjectTest, SubtreeLayoutCrash) { SetBodyInnerHTML(R"HTML(
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 2ec06e5..341fa71 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
@@ -22,6 +22,20 @@ namespace blink { +namespace { + +const LayoutNGSVGText* FindTextRoot(const LayoutObject* start) { + DCHECK(start); + for (; start; start = start->Parent()) { + if (const auto* ng_text = DynamicTo<LayoutNGSVGText>(start)) { + return ng_text; + } + } + return nullptr; +} + +} // namespace + LayoutNGSVGText::LayoutNGSVGText(Element* element) : LayoutNGBlockFlowMixin<LayoutSVGBlock>(element), needs_update_bounding_box_(true), @@ -351,4 +365,23 @@ return needs_text_metrics_update_; } +LayoutNGSVGText* LayoutNGSVGText::LocateLayoutSVGTextAncestor( + LayoutObject* start) { + return const_cast<LayoutNGSVGText*>(FindTextRoot(start)); +} + +const LayoutNGSVGText* LayoutNGSVGText::LocateLayoutSVGTextAncestor( + const LayoutObject* start) { + return FindTextRoot(start); +} + +// static +void LayoutNGSVGText::NotifySubtreeStructureChanged( + LayoutObject* object, + LayoutInvalidationReasonForTracing reason) { + if (auto* ng_text = LocateLayoutSVGTextAncestor(object)) { + ng_text->SubtreeStructureChanged(reason); + } +} + } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.h b/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.h index 27942a0..fdbddf1 100644 --- a/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.h +++ b/third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.h
@@ -29,6 +29,14 @@ bool IsObjectBoundingBoxValid() const; + // These two functions return a LayoutNGSVGText or nullptr. + static LayoutNGSVGText* LocateLayoutSVGTextAncestor(LayoutObject*); + static const LayoutNGSVGText* LocateLayoutSVGTextAncestor( + const LayoutObject*); + + static void NotifySubtreeStructureChanged(LayoutObject*, + LayoutInvalidationReasonForTracing); + private: // LayoutObject override: const char* GetName() const override;
diff --git a/third_party/blink/renderer/core/layout/ng/table/ng_table_row_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/table/ng_table_row_layout_algorithm.cc index 4bb79bd..960f715 100644 --- a/third_party/blink/renderer/core/layout/ng/table/ng_table_row_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/table/ng_table_row_layout_algorithm.cc
@@ -40,13 +40,24 @@ auto CreateCellConstraintSpace = [this, &table_data]( - NGBlockNode cell, const NGTableConstraintSpaceData::Cell& cell_data, + NGBlockNode cell, const NGBlockBreakToken* cell_break_token, + const NGTableConstraintSpaceData::Cell& cell_data, LayoutUnit row_block_size, absl::optional<LayoutUnit> row_baseline, bool min_block_size_should_encompass_intrinsic_size) { - const LayoutUnit cell_block_size = - cell_data.rowspan_block_size != kIndefiniteSize - ? cell_data.rowspan_block_size - : row_block_size; + bool has_rowspan = cell_data.rowspan_block_size != kIndefiniteSize; + LayoutUnit cell_block_size = + has_rowspan ? cell_data.rowspan_block_size : row_block_size; + + if (IsBreakInside(cell_break_token) && IsBreakInside(BreakToken()) && + !has_rowspan) { + // The table row may have consumed more space than the cell, if some + // sibling cell has overflowed the fragmentainer. Subtract this + // difference, so that this cell won't overflow the row - unless the + // cell is rowspanned. In that case it doesn't make sense to + // compensate against just the current row. + cell_block_size -= BreakToken()->ConsumedBlockSize() - + cell_break_token->ConsumedBlockSize(); + } DCHECK_EQ(table_data.table_writing_direction.GetWritingMode(), ConstraintSpace().GetWritingMode()); @@ -139,7 +150,7 @@ MinBlockSizeShouldEncompassIntrinsicSize(cell, cell_data); const auto cell_space = CreateCellConstraintSpace( - cell, cell_data, row_block_size, row_baseline, + cell, cell_break_token, cell_data, row_block_size, row_baseline, min_block_size_should_encompass_intrinsic_size); const NGLayoutResult* cell_result = cell.Layout(cell_space, cell_break_token); @@ -249,6 +260,7 @@ // separately), we have seen all children by now. container_builder_.SetHasSeenAllChildren(); + container_builder_.SetIntrinsicBlockSize(max_cell_block_size); container_builder_.SetFragmentsTotalBlockSize(row_block_size); if (row.is_collapsed) container_builder_.SetIsHiddenForPaint(true);
diff --git a/third_party/blink/renderer/core/layout/ng/table/ng_table_section_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/table/ng_table_section_layout_algorithm.cc index ab10c795..2d284c7 100644 --- a/third_party/blink/renderer/core/layout/ng/table/ng_table_section_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/table/ng_table_section_layout_algorithm.cc
@@ -41,6 +41,7 @@ absl::optional<LayoutUnit> first_baseline; absl::optional<LayoutUnit> last_baseline; LogicalOffset offset; + LayoutUnit intrinsic_block_size; bool is_first_non_collapsed_row = true; Vector<LayoutUnit> row_offsets = {LayoutUnit()}; @@ -126,6 +127,7 @@ actual_start_row_index = row_index; row_offsets.emplace_back(offset.block_offset); } + intrinsic_block_size = offset.block_offset; } if (!child_iterator.NextChild().node) @@ -142,6 +144,7 @@ block_size += BreakToken()->ConsumedBlockSize(); } container_builder_.SetFragmentsTotalBlockSize(block_size); + container_builder_.SetIntrinsicBlockSize(intrinsic_block_size); if (first_baseline) container_builder_.SetFirstBaseline(*first_baseline);
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.cc deleted file mode 100644 index 05b4ed4..0000000 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.cc +++ /dev/null
@@ -1,202 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * Copyright (C) 2009 Google, Inc. - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.h" - -#include "third_party/blink/renderer/core/layout/hit_test_result.h" -#include "third_party/blink/renderer/core/layout/svg/svg_layout_support.h" -#include "third_party/blink/renderer/core/layout/svg/svg_resources.h" -#include "third_party/blink/renderer/core/layout/svg/transformed_hit_test_location.h" -#include "third_party/blink/renderer/core/paint/paint_layer.h" -#include "third_party/blink/renderer/core/paint/svg_foreign_object_painter.h" -#include "third_party/blink/renderer/core/svg/svg_foreign_object_element.h" -#include "third_party/blink/renderer/core/svg/svg_length_context.h" - -namespace blink { - -LayoutSVGForeignObject::LayoutSVGForeignObject(Element* element) - : LayoutSVGBlock(element) { - DCHECK(IsA<SVGForeignObjectElement>(element)); -} - -LayoutSVGForeignObject::~LayoutSVGForeignObject() = default; - -bool LayoutSVGForeignObject::IsChildAllowed(LayoutObject* child, - const ComputedStyle& style) const { - NOT_DESTROYED(); - // Disallow arbitary SVG content. Only allow proper <svg xmlns="svgNS"> - // subdocuments. - return !child->IsSVGChild(); -} - -void LayoutSVGForeignObject::Paint(const PaintInfo& paint_info) const { - NOT_DESTROYED(); - SVGForeignObjectPainter(*this).Paint(paint_info); -} - -void LayoutSVGForeignObject::UpdateLogicalWidth() { - NOT_DESTROYED(); - const ComputedStyle& style = StyleRef(); - float logical_width = - style.IsHorizontalWritingMode() ? viewport_.width() : viewport_.height(); - logical_width *= style.EffectiveZoom(); - SetLogicalWidth(LayoutUnit(logical_width)); -} - -void LayoutSVGForeignObject::ComputeLogicalHeight( - LayoutUnit, - LayoutUnit logical_top, - LogicalExtentComputedValues& computed_values) const { - NOT_DESTROYED(); - const ComputedStyle& style = StyleRef(); - float logical_height = - style.IsHorizontalWritingMode() ? viewport_.height() : viewport_.width(); - logical_height *= style.EffectiveZoom(); - computed_values.extent_ = LayoutUnit(logical_height); - computed_values.position_ = logical_top; -} - -AffineTransform LayoutSVGForeignObject::LocalToSVGParentTransform() const { - NOT_DESTROYED(); - // Include a zoom inverse in the local-to-parent transform since descendants - // of the <foreignObject> will have regular zoom applied, and thus need to - // have that removed when moving into the <fO> ancestors chain (the SVG root - // will then reapply the zoom again if that boundary is crossed). - AffineTransform transform = local_transform_; - transform.Scale(1 / StyleRef().EffectiveZoom()); - return transform; -} - -void LayoutSVGForeignObject::UpdateLayout() { - NOT_DESTROYED(); - DCHECK(NeedsLayout()); - - auto* foreign = To<SVGForeignObjectElement>(GetElement()); - - // Update our transform before layout, in case any of our descendants rely on - // the transform being somewhat accurate. The |needs_transform_update_| flag - // will be cleared after layout has been performed. - // TODO(fs): Remove this. AFAICS in all cases where descendants compute some - // form of CTM, they stop at their nearest ancestor LayoutSVGRoot, and thus - // will not care about (reach) this value. - if (needs_transform_update_) { - local_transform_ = - foreign->CalculateTransform(SVGElement::kIncludeMotionTransform); - } - - LayoutRect old_frame_rect = FrameRect(); - - // Resolve the viewport in the local coordinate space - this does not include - // zoom. - SVGLengthContext length_context(foreign); - const ComputedStyle& style = StyleRef(); - gfx::Vector2dF origin = - length_context.ResolveLengthPair(style.X(), style.Y(), style); - gfx::Vector2dF size = - length_context.ResolveLengthPair(style.Width(), style.Height(), style); - // SetRect() will clamp negative width/height to zero. - viewport_.SetRect(origin.x(), origin.y(), size.x(), size.y()); - - // Use the zoomed version of the viewport as the location, because we will - // interpose a transform that "unzooms" the effective zoom to let the children - // of the foreign object exist with their specified zoom. - gfx::PointF zoomed_location = - gfx::ScalePoint(viewport_.origin(), style.EffectiveZoom()); - - // Set box origin to the foreignObject x/y translation, so positioned objects - // in XHTML content get correct positions. A regular LayoutBoxModelObject - // would pull this information from ComputedStyle - in SVG those properties - // are ignored for non <svg> elements, so we mimic what happens when - // specifying them through CSS. - SetLocation(LayoutPoint(zoomed_location)); - - LayoutBlock::UpdateLayout(); - DCHECK(!NeedsLayout()); - const bool bounds_changed = old_frame_rect != FrameRect(); - - // Invalidate all resources of this client if our reference box changed. - if (EverHadLayout() && bounds_changed) - SVGResourceInvalidator(*this).InvalidateEffects(); - - bool update_parent_boundaries = bounds_changed; - if (UpdateTransformAfterLayout(bounds_changed)) - update_parent_boundaries = true; - - // Notify ancestor about our bounds changing. - if (update_parent_boundaries) - LayoutSVGBlock::SetNeedsBoundariesUpdate(); - - DCHECK(!needs_transform_update_); -} - -bool LayoutSVGForeignObject::NodeAtPointFromSVG( - HitTestResult& result, - const HitTestLocation& hit_test_location, - const PhysicalOffset& accumulated_offset, - HitTestPhase) { - NOT_DESTROYED(); - DCHECK_EQ(accumulated_offset, PhysicalOffset()); - TransformedHitTestLocation local_location(hit_test_location, - LocalToSVGParentTransform()); - if (!local_location) - return false; - - // |local_location| already includes the offset of the <foreignObject> - // element, but PaintLayer::HitTestLayer assumes it has not been. - HitTestLocation local_without_offset(*local_location, -PhysicalLocation()); - HitTestResult layer_result(result.GetHitTestRequest(), local_without_offset); - bool retval = Layer()->HitTest(local_without_offset, layer_result, - PhysicalRect(PhysicalRect::InfiniteIntRect())); - - // Preserve the "point in inner node frame" from the original request, - // since |layer_result| is a hit test rooted at the <foreignObject> element, - // not the frame, due to the constructor above using - // |point_in_foreign_object| as its "point in inner node frame". - // TODO(chrishtr): refactor the PaintLayer and HitTestResults code around - // this, to better support hit tests that don't start at frame boundaries. - PhysicalOffset original_point_in_inner_node_frame = - result.PointInInnerNodeFrame(); - if (result.GetHitTestRequest().ListBased()) - result.Append(layer_result); - else - result = layer_result; - result.SetPointInInnerNodeFrame(original_point_in_inner_node_frame); - return retval; -} - -bool LayoutSVGForeignObject::NodeAtPoint( - HitTestResult& result, - const HitTestLocation& hit_test_location, - const PhysicalOffset& accumulated_offset, - HitTestPhase phase) { - NOT_DESTROYED(); - // Skip LayoutSVGBlock's override. - return LayoutBlockFlow::NodeAtPoint(result, hit_test_location, - accumulated_offset, phase); -} - -PaintLayerType LayoutSVGForeignObject::LayerTypeRequired() const { - NOT_DESTROYED(); - // Skip LayoutSVGBlock's override. - return LayoutBlockFlow::LayerTypeRequired(); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.h b/third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.h deleted file mode 100644 index 1e2bbce..0000000 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.h +++ /dev/null
@@ -1,134 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * Copyright (C) 2009 Google, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_FOREIGN_OBJECT_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_FOREIGN_OBJECT_H_ - -#include "third_party/blink/renderer/core/layout/svg/layout_svg_block.h" -#include "third_party/blink/renderer/platform/wtf/casting.h" - -namespace blink { - -// LayoutSVGForeignObject is the LayoutObject associated with <foreignobject>. -// http://www.w3.org/TR/SVG/extend.html#ForeignObjectElement -// -// Foreign object is a way of inserting arbitrary non-SVG content into SVG. -// A good example of this is HTML in SVG. Because of this, CSS content has to -// be aware of SVG: e.g. when determining containing blocks we stop at the -// enclosing foreign object (see LayoutObject::canContainFixedPositionObjects). -// -// Note that SVG is also allowed in HTML with the HTML5 parsing rules so SVG -// content also has to be aware of CSS objects. -// See http://www.w3.org/TR/html5/syntax.html#elements-0 with the rules for -// 'foreign elements'. TODO(jchaffraix): Find a better place for this paragraph. -// -// The coordinate space for the descendants of the foreignObject does not -// include the effective zoom (it is baked into any lengths as usual). The -// transform that defines the userspace of the element is: -// -// [CSS transform] * [inverse effective zoom] (* ['x' and 'y' translation]) -// -// Because of this, the frame rect and visual rect includes effective zoom. The -// object bounding box (ObjectBoundingBox method) is however not zoomed to be -// compatible with the expectations of the getBBox() DOM interface. -class LayoutSVGForeignObject final : public LayoutSVGBlock { - public: - explicit LayoutSVGForeignObject(Element*); - ~LayoutSVGForeignObject() override; - - const char* GetName() const override { - NOT_DESTROYED(); - return "LayoutSVGForeignObject"; - } - - bool IsChildAllowed(LayoutObject*, const ComputedStyle&) const override; - - void Paint(const PaintInfo&) const override; - - void UpdateLayout() override; - - gfx::RectF ObjectBoundingBox() const override { - NOT_DESTROYED(); - return viewport_; - } - gfx::RectF StrokeBoundingBox() const override { - NOT_DESTROYED(); - return VisualRectInLocalSVGCoordinates(); - } - gfx::RectF VisualRectInLocalSVGCoordinates() const override { - NOT_DESTROYED(); - return gfx::RectF(FrameRect()); - } - bool IsObjectBoundingBoxValid() const { - NOT_DESTROYED(); - return !viewport_.IsEmpty(); - } - - bool NodeAtPoint(HitTestResult&, - const HitTestLocation&, - const PhysicalOffset&, - HitTestPhase) override; - - // A method to call when recursively hit testing from an SVG parent. - // Since LayoutSVGRoot has a PaintLayer always, this will cause a - // trampoline through PaintLayer::HitTest and back to a call to NodeAtPoint - // on this object. This is why there are two methods. - bool NodeAtPointFromSVG(HitTestResult&, - const HitTestLocation&, - const PhysicalOffset&, - HitTestPhase); - - bool IsOfType(LayoutObjectType type) const override { - NOT_DESTROYED(); - return type == kLayoutObjectSVGForeignObject || - LayoutSVGBlock::IsOfType(type); - } - - PaintLayerType LayerTypeRequired() const override; - - bool CreatesNewFormattingContext() const final { - NOT_DESTROYED(); - // This is the root of a foreign object. Don't let anything inside it escape - // to our ancestors. - return true; - } - - private: - void UpdateLogicalWidth() override; - void ComputeLogicalHeight(LayoutUnit logical_height, - LayoutUnit logical_top, - LogicalExtentComputedValues&) const override; - AffineTransform LocalToSVGParentTransform() const override; - - // The resolved viewport in the regular SVG coordinate space (after any - // 'transform' has been applied but without zoom-adjustment). - gfx::RectF viewport_; -}; - -template <> -struct DowncastTraits<LayoutSVGForeignObject> { - static bool AllowFrom(const LayoutObject& object) { - return object.IsSVGForeignObject(); - } -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_FOREIGN_OBJECT_H_
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object_test.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object_test.cc deleted file mode 100644 index e101c646..0000000 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object_test.cc +++ /dev/null
@@ -1,410 +0,0 @@ -// Copyright 2017 The Chromium Authors -// 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/core/paint/paint_layer.h" -#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h" - -namespace blink { - -class LayoutSVGForeignObjectTest : public RenderingTest { - public: - LayoutSVGForeignObjectTest() - : RenderingTest(MakeGarbageCollected<SingleChildLocalFrameClient>()) {} -}; - -TEST_F(LayoutSVGForeignObjectTest, DivInForeignObject) { - SetBodyInnerHTML(R"HTML( - <style>body { margin: 0 }</style> - <svg id='svg' style='width: 500px; height: 400px'> - <foreignObject id='foreign' x='100' y='100' width='300' height='200'> - <div id='div' style='margin: 50px; width: 200px; height: 100px'> - </div> - </foreignObject> - </svg> - )HTML"); - - const auto& svg = *GetDocument().getElementById("svg"); - const auto& foreign = *GetDocument().getElementById("foreign"); - const auto& foreign_object = *GetLayoutObjectByElementId("foreign"); - const auto& div = *GetLayoutObjectByElementId("div"); - - EXPECT_EQ(gfx::RectF(100, 100, 300, 200), foreign_object.ObjectBoundingBox()); - EXPECT_EQ(AffineTransform(), foreign_object.LocalSVGTransform()); - EXPECT_EQ(AffineTransform(), foreign_object.LocalToSVGParentTransform()); - - // MapToVisualRectInAncestorSpace - PhysicalRect div_rect(0, 0, 100, 50); - EXPECT_TRUE(div.MapToVisualRectInAncestorSpace(&GetLayoutView(), div_rect)); - EXPECT_EQ(PhysicalRect(150, 150, 100, 50), div_rect); - - // LocalToAncestorPoint - EXPECT_EQ(PhysicalOffset(150, 150), - div.LocalToAncestorPoint(PhysicalOffset(), &GetLayoutView(), - kTraverseDocumentBoundaries)); - - // MapAncestorToLocal - EXPECT_EQ(PhysicalOffset(-150, -150), - div.AncestorToLocalPoint(&GetLayoutView(), PhysicalOffset(), - kTraverseDocumentBoundaries)); - - // Hit testing - EXPECT_EQ(svg, HitTest(1, 1)); - EXPECT_EQ(foreign, HitTest(149, 149)); - EXPECT_EQ(div.GetNode(), HitTest(150, 150)); - EXPECT_EQ(div.GetNode(), HitTest(349, 249)); - EXPECT_EQ(foreign, HitTest(350, 250)); - EXPECT_EQ(svg, HitTest(450, 350)); - - // Rect based hit testing - auto results = RectBasedHitTest(PhysicalRect(0, 0, 300, 300)); - int count = 0; - EXPECT_EQ(3u, results.size()); - for (auto result : results) { - Node* node = result.Get(); - if (node == svg || node == div.GetNode() || node == foreign) - count++; - } - EXPECT_EQ(3, count); -} - -TEST_F(LayoutSVGForeignObjectTest, IframeInForeignObject) { - SetBodyInnerHTML(R"HTML( - <style>body { margin: 0 }</style> - <svg id='svg' style='width: 500px; height: 450px'> - <foreignObject id='foreign' x='100' y='100' width='300' height='250'> - <iframe id=iframe style='border: none; margin: 30px; - width: 240px; height: 190px'></iframe> - </foreignObject> - </svg> - )HTML"); - SetChildFrameHTML(R"HTML( - <style> - body { margin: 0 } - * { background: white; } - </style> - <div id='div' style='margin: 70px; width: 100px; height: 50px'></div> - )HTML"); - UpdateAllLifecyclePhasesForTest(); - - const auto& svg = *GetDocument().getElementById("svg"); - const auto& foreign = *GetDocument().getElementById("foreign"); - const auto& foreign_object = *GetLayoutObjectByElementId("foreign"); - const auto& iframe = *GetDocument().getElementById("iframe"); - const auto& div = *ChildDocument().getElementById("div")->GetLayoutObject(); - - EXPECT_EQ(gfx::RectF(100, 100, 300, 250), foreign_object.ObjectBoundingBox()); - EXPECT_EQ(AffineTransform(), foreign_object.LocalSVGTransform()); - EXPECT_EQ(AffineTransform(), foreign_object.LocalToSVGParentTransform()); - - // MapToVisualRectInAncestorSpace - PhysicalRect div_rect(0, 0, 100, 50); - EXPECT_TRUE(div.MapToVisualRectInAncestorSpace(&GetLayoutView(), div_rect)); - EXPECT_EQ(PhysicalRect(200, 200, 100, 50), div_rect); - - // LocalToAncestorPoint - EXPECT_EQ(PhysicalOffset(200, 200), - div.LocalToAncestorPoint(PhysicalOffset(), &GetLayoutView(), - kTraverseDocumentBoundaries)); - - // AncestorToLocalPoint - EXPECT_EQ(PhysicalOffset(-200, -200), - div.AncestorToLocalPoint(&GetLayoutView(), PhysicalOffset(), - kTraverseDocumentBoundaries)); - - // Hit testing - EXPECT_EQ(svg, HitTest(90, 90)); - EXPECT_EQ(foreign, HitTest(129, 129)); - EXPECT_EQ(ChildDocument().documentElement(), HitTest(130, 130)); - EXPECT_EQ(ChildDocument().documentElement(), HitTest(199, 199)); - EXPECT_EQ(div.GetNode(), HitTest(200, 200)); - EXPECT_EQ(div.GetNode(), HitTest(299, 249)); - EXPECT_EQ(ChildDocument().documentElement(), HitTest(300, 250)); - EXPECT_EQ(ChildDocument().documentElement(), HitTest(369, 319)); - EXPECT_EQ(foreign, HitTest(370, 320)); - EXPECT_EQ(svg, HitTest(450, 400)); - - // Rect based hit testing - auto results = RectBasedHitTest(PhysicalRect(0, 0, 300, 300)); - int count = 0; - EXPECT_EQ(7u, results.size()); - for (auto result : results) { - Node* node = result.Get(); - if (node == svg || node == div.GetNode() || node == foreign || - node == iframe) - count++; - } - EXPECT_EQ(4, count); -} - -TEST_F(LayoutSVGForeignObjectTest, HitTestZoomedForeignObject) { - SetBodyInnerHTML(R"HTML( - <style>* { margin: 0; zoom: 150% }</style> - <svg id='svg' style='width: 200px; height: 200px'> - <foreignObject id='foreign' x='10' y='10' width='100' height='150' - style='overflow: visible'> - <div id='div' style='margin: 50px; width: 50px; height: 50px'></div> - </foreignObject> - </svg> - )HTML"); - - const auto& svg = *GetDocument().getElementById("svg"); - const auto& foreign = *GetDocument().getElementById("foreign"); - const auto& foreign_object = *GetLayoutObjectByElementId("foreign"); - const auto& div = *GetDocument().getElementById("div"); - - EXPECT_EQ(gfx::RectF(10, 10, 100, 150), foreign_object.ObjectBoundingBox()); - EXPECT_EQ(AffineTransform(), foreign_object.LocalSVGTransform()); - AffineTransform zoom; - zoom.Scale(1 / foreign_object.StyleRef().EffectiveZoom()); - EXPECT_EQ(zoom, foreign_object.LocalToSVGParentTransform()); - - // MapToVisualRectInAncestorSpace - PhysicalRect div_rect(0, 0, 100, 50); - EXPECT_TRUE(div.GetLayoutObject()->MapToVisualRectInAncestorSpace( - &GetLayoutView(), div_rect)); - // Origin at x=y=(50 * 1.5 + 10) * 1.5 * 1.5 * 1.5 = 286.875 - // Dimensions will be subjected to scaling with 1/1.5 because the - // accumulated zoom on the <fO> is one more than that of its parent <svg>. - EXPECT_EQ(PhysicalRect(286, 286, 68, 35), div_rect); - - PhysicalOffset div_offset(LayoutUnit(286.875), LayoutUnit(286.875)); - // LocalToAncestorPoint - EXPECT_EQ(div_offset, div.GetLayoutObject()->LocalToAncestorPoint( - PhysicalOffset(), &GetLayoutView(), - kTraverseDocumentBoundaries)); - - // AncestorToLocalPoint - EXPECT_EQ(PhysicalOffset(), - div.GetLayoutObject()->AncestorToLocalPoint( - &GetLayoutView(), div_offset, kTraverseDocumentBoundaries)); - - EXPECT_EQ(svg, HitTest(20, 20)); - EXPECT_EQ(foreign, HitTest(280, 280)); - // Check all corners of the <div>. - EXPECT_EQ(div, HitTest(290, 290)); - EXPECT_EQ(div, HitTest(290, 286 + 250)); - EXPECT_EQ(div, HitTest(286 + 250, 290)); - EXPECT_EQ(div, HitTest(286 + 250, 286 + 250)); - // Check (just) outside the <div>. - EXPECT_EQ(svg, HitTest(286 + 256, 290)); - EXPECT_EQ(svg, HitTest(290, 286 + 256)); - - // Rect based hit testing - auto results = RectBasedHitTest(PhysicalRect(0, 0, 300, 300)); - int count = 0; - EXPECT_EQ(3u, results.size()); - for (auto result : results) { - Node* node = result.Get(); - if (node == svg || node == &div || node == foreign) - count++; - } - EXPECT_EQ(3, count); -} - -TEST_F(LayoutSVGForeignObjectTest, HitTestViewBoxForeignObject) { - SetBodyInnerHTML(R"HTML( - <svg id='svg' style='width: 200px; height: 200px' viewBox='0 0 100 100'> - <foreignObject id='foreign' x='10' y='10' width='100' height='150'> - <div id='div' style='margin: 50px; width: 50px; height: 50px'> - </div> - </foreignObject> - </svg> - )HTML"); - - const auto& svg = *GetDocument().getElementById("svg"); - const auto& foreign = *GetDocument().getElementById("foreign"); - const auto& div = *GetDocument().getElementById("div"); - - // LocalToAncestorPoint - EXPECT_EQ( - PhysicalOffset(128, 128), - div.GetLayoutObject()->LocalToAncestorPoint( - PhysicalOffset(), &GetLayoutView(), kTraverseDocumentBoundaries)); - - // AncestorToLocalPoint - EXPECT_EQ(PhysicalOffset(), div.GetLayoutObject()->AncestorToLocalPoint( - &GetLayoutView(), PhysicalOffset(128, 128), - kTraverseDocumentBoundaries)); - - EXPECT_EQ(svg, HitTest(20, 20)); - EXPECT_EQ(foreign, HitTest(120, 110)); - EXPECT_EQ(div, HitTest(160, 160)); -} - -TEST_F(LayoutSVGForeignObjectTest, HitTestUnderClipPath) { - SetBodyInnerHTML(R"HTML( - <style> - * { - margin: 0 - } - #target { - width: 500px; - height: 500px; - background-color: blue; - } - #target:hover { - background-color: green; - } - </style> - <svg id="svg" style="width: 500px; height: 500px"> - <clipPath id="c"> - <circle cx="250" cy="250" r="200"/> - </clipPath> - <g clip-path="url(#c)"> - <foreignObject id="foreignObject" width="100%" height="100%"> - </foreignObject> - </g> - </svg> - )HTML"); - - const auto& svg = *GetDocument().getElementById("svg"); - const auto& foreignObject = *GetDocument().getElementById("foreignObject"); - - // The fist and the third return |svg| because the circle clip-path - // clips out the foreignObject. - EXPECT_EQ(svg, GetDocument().ElementFromPoint(20, 20)); - EXPECT_EQ(foreignObject, GetDocument().ElementFromPoint(250, 250)); - EXPECT_EQ(svg, GetDocument().ElementFromPoint(400, 400)); -} - -TEST_F(LayoutSVGForeignObjectTest, - HitTestUnderClippedPositionedForeignObjectDescendant) { - SetBodyInnerHTML(R"HTML( - <style> - * { - margin: 0 - } - </style> - <svg id="svg" style="width: 600px; height: 600px"> - <foreignObject id="foreignObject" x="200" y="200" width="100" - height="100"> - <div id="target" style="overflow: hidden; position: relative; - width: 100px; height: 50px; left: 5px"></div> - </foreignObject> - </svg> - )HTML"); - - const auto& svg = *GetDocument().getElementById("svg"); - const auto& target = *GetDocument().getElementById("target"); - const auto& foreignObject = *GetDocument().getElementById("foreignObject"); - - EXPECT_EQ(svg, GetDocument().ElementFromPoint(1, 1)); - EXPECT_EQ(foreignObject, GetDocument().ElementFromPoint(201, 201)); - EXPECT_EQ(target, GetDocument().ElementFromPoint(206, 206)); - EXPECT_EQ(foreignObject, GetDocument().ElementFromPoint(205, 255)); - - HitTestRequest request(HitTestRequest::kReadOnly | HitTestRequest::kActive); - HitTestLocation location((PhysicalOffset(206, 206))); - HitTestResult result(request, location); - GetDocument().GetLayoutView()->HitTest(location, result); - EXPECT_EQ(target, result.InnerNode()); - EXPECT_EQ(PhysicalOffset(206, 206), result.PointInInnerNodeFrame()); -} - -TEST_F(LayoutSVGForeignObjectTest, - HitTestUnderTransformedForeignObjectDescendant) { - SetBodyInnerHTML(R"HTML( - <style> - * { - margin: 0 - } - </style> - <svg id="svg" style="width: 600px; height: 600px"> - <foreignObject id="foreignObject" x="200" y="200" width="100" - height="100" transform="translate(30)"> - <div id="target" style="overflow: hidden; position: relative; - width: 100px; height: 50px; left: 5px"></div> - </foreignObject> - </svg> - )HTML"); - - const auto& svg = *GetDocument().getElementById("svg"); - const auto& target = *GetDocument().getElementById("target"); - const auto& foreign_object = *GetDocument().getElementById("foreignObject"); - - EXPECT_EQ(svg, GetDocument().ElementFromPoint(1, 1)); - EXPECT_EQ(foreign_object, GetDocument().ElementFromPoint(231, 201)); - EXPECT_EQ(target, GetDocument().ElementFromPoint(236, 206)); - EXPECT_EQ(foreign_object, GetDocument().ElementFromPoint(235, 255)); - - HitTestRequest request(HitTestRequest::kReadOnly | HitTestRequest::kActive); - HitTestLocation location((PhysicalOffset(236, 206))); - HitTestResult result(request, location); - GetDocument().GetLayoutView()->HitTest(location, result); - EXPECT_EQ(target, result.InnerNode()); - EXPECT_EQ(PhysicalOffset(236, 206), result.PointInInnerNodeFrame()); -} - -TEST_F(LayoutSVGForeignObjectTest, HitTestUnderScrollingAncestor) { - SetBodyInnerHTML(R"HTML( - <style> - * { - margin: 0 - } - </style> - <div id=scroller style="width: 500px; height: 500px; overflow: auto"> - <svg width="3000" height="3000"> - <foreignObject width="3000" height="3000"> - <div id="target" style="width: 3000px; height: 3000px; background: red"> - </div> - </foreignObject> - </svg> - </div> - )HTML"); - - auto& scroller = *GetDocument().getElementById("scroller"); - const auto& target = *GetDocument().getElementById("target"); - - EXPECT_EQ(target, GetDocument().ElementFromPoint(450, 450)); - - HitTestRequest request(HitTestRequest::kReadOnly | HitTestRequest::kActive); - HitTestLocation location((PhysicalOffset(450, 450))); - HitTestResult result(request, location); - GetDocument().GetLayoutView()->HitTest(location, result); - EXPECT_EQ(target, result.InnerNode()); - EXPECT_EQ(PhysicalOffset(450, 450), result.PointInInnerNodeFrame()); - - scroller.setScrollTop(3000); - - EXPECT_EQ(target, GetDocument().ElementFromPoint(450, 450)); - - GetDocument().GetLayoutView()->HitTest(location, result); - EXPECT_EQ(target, result.InnerNode()); - EXPECT_EQ(PhysicalOffset(450, 450), result.PointInInnerNodeFrame()); -} - -TEST_F(LayoutSVGForeignObjectTest, BBoxPropagationZoomed) { - GetFrame().SetPageZoomFactor(2); - SetBodyInnerHTML(R"HTML( - <svg> - <g> - <foreignObject x="6" y="5" width="100" height="50" id="target"/> - </g> - </svg> - )HTML"); - UpdateAllLifecyclePhasesForTest(); - - const auto& target = *GetLayoutObjectByElementId("target"); - ASSERT_EQ(target.StyleRef().EffectiveZoom(), 2); - - EXPECT_EQ(target.ObjectBoundingBox(), gfx::RectF(6, 5, 100, 50)); - EXPECT_EQ(target.StrokeBoundingBox(), gfx::RectF(12, 10, 200, 100)); - const auto& parent_g = *target.Parent(); - EXPECT_EQ(parent_g.ObjectBoundingBox(), gfx::RectF(6, 5, 100, 50)); - EXPECT_EQ(parent_g.StrokeBoundingBox(), gfx::RectF(6, 5, 100, 50)); -} - -// crbug.com/1335655 -TEST_F(LayoutSVGForeignObjectTest, SetNeedsCollectInlines) { - SetBodyInnerHTML(R"HTML( - <svg><foreignObject id="target">abc</foreignObject></svg>)HTML"); - UpdateAllLifecyclePhasesForTest(); - - auto* target = GetElementById("target"); - target->setAttribute("unicode-bidi", "bidi-override"); - GetDocument().body()->innerText(); - // Pass if no crash. -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_inline.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_inline.cc index 61d8246..730d970 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_inline.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_inline.cc
@@ -26,8 +26,6 @@ #include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_container.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_flow_box.h" #include "third_party/blink/renderer/core/layout/svg/svg_layout_support.h" #include "third_party/blink/renderer/core/layout/svg/svg_resources.h" #include "third_party/blink/renderer/core/paint/compositing/compositing_reason_finder.h" @@ -64,14 +62,6 @@ SetAlwaysCreateLineBoxes(); } -InlineFlowBox* LayoutSVGInline::CreateInlineFlowBox() { - NOT_DESTROYED(); - InlineFlowBox* box = - MakeGarbageCollected<SVGInlineFlowBox>(LineLayoutItem(this)); - box->SetHasVirtualLogicalHeight(); - return box; -} - bool LayoutSVGInline::IsObjectBoundingBoxValid() const { if (IsInLayoutNGInlineFormattingContext()) { NGInlineCursor cursor; @@ -191,8 +181,7 @@ const ComputedStyle* old_style) { NOT_DESTROYED(); if (diff.HasDifference()) { - if (auto* svg_text = DynamicTo<LayoutNGSVGText>( - LayoutSVGText::LocateLayoutSVGTextAncestor(this))) { + if (auto* svg_text = LayoutNGSVGText::LocateLayoutSVGTextAncestor(this)) { if (svg_text->NeedsTextMetricsUpdate()) diff.SetNeedsFullLayout(); } @@ -215,13 +204,13 @@ LayoutObject* before_child) { NOT_DESTROYED(); LayoutInline::AddChild(child, before_child); - LayoutSVGText::NotifySubtreeStructureChanged( + LayoutNGSVGText::NotifySubtreeStructureChanged( this, layout_invalidation_reason::kChildChanged); } void LayoutSVGInline::RemoveChild(LayoutObject* child) { NOT_DESTROYED(); - LayoutSVGText::NotifySubtreeStructureChanged( + LayoutNGSVGText::NotifySubtreeStructureChanged( this, layout_invalidation_reason::kChildChanged); LayoutInline::RemoveChild(child); }
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_inline.h b/third_party/blink/renderer/core/layout/svg/layout_svg_inline.h index 2486c2f..77e1274 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_inline.h +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_inline.h
@@ -64,8 +64,6 @@ NGOutlineType) const final; private: - InlineFlowBox* CreateInlineFlowBox() final; - void WillBeDestroyed() final; void StyleDidChange(StyleDifference, const ComputedStyle* old_style) final;
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.cc index d53715e0..002c186 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.cc
@@ -34,16 +34,8 @@ #include "third_party/blink/renderer/core/layout/ng/inline/ng_fragment_item.h" #include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_cursor.h" #include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.h" #include "third_party/blink/renderer/core/layout/svg/svg_layout_support.h" -#include "third_party/blink/renderer/platform/fonts/character_range.h" #include "third_party/blink/renderer/platform/instrumentation/use_counter.h" -#include "third_party/blink/renderer/platform/text/bidi_character_run.h" -#include "third_party/blink/renderer/platform/text/bidi_resolver.h" -#include "third_party/blink/renderer/platform/text/text_direction.h" -#include "third_party/blink/renderer/platform/text/text_run.h" -#include "third_party/blink/renderer/platform/text/text_run_iterator.h" namespace blink { @@ -67,7 +59,7 @@ NOT_DESTROYED(); SetTextInternal(NormalizeWhitespace(GetText().Impl())); LayoutText::TextDidChange(); - LayoutSVGText::NotifySubtreeStructureChanged( + LayoutNGSVGText::NotifySubtreeStructureChanged( this, layout_invalidation_reason::kTextChanged); if (StyleRef().UsedUserModify() != EUserModify::kReadOnly) @@ -91,13 +83,9 @@ return; // The text metrics may be influenced by style changes. - if (LayoutSVGBlock* text_or_ng_text = - LayoutSVGText::LocateLayoutSVGTextAncestor(this)) { - if (auto* text_layout_object = DynamicTo<LayoutSVGText>(text_or_ng_text)) - text_layout_object->SetNeedsTextMetricsUpdate(); - else - To<LayoutNGSVGText>(text_or_ng_text)->SetNeedsTextMetricsUpdate(); - text_or_ng_text->SetNeedsLayoutAndFullPaintInvalidation( + if (auto* ng_text = LayoutNGSVGText::LocateLayoutSVGTextAncestor(this)) { + ng_text->SetNeedsTextMetricsUpdate(); + ng_text->SetNeedsLayoutAndFullPaintInvalidation( layout_invalidation_reason::kStyleChange); } } @@ -109,82 +97,20 @@ void LayoutSVGInlineText::InvalidateSubtreeLayoutForFontUpdates() { NOT_DESTROYED(); if (!IsFontFallbackValid()) { - LayoutSVGText::NotifySubtreeStructureChanged( + LayoutNGSVGText::NotifySubtreeStructureChanged( this, layout_invalidation_reason::kFontsChanged); } LayoutText::InvalidateSubtreeLayoutForFontUpdates(); } -InlineTextBox* LayoutSVGInlineText::CreateTextBox(int start, uint16_t length) { - NOT_DESTROYED(); - InlineTextBox* box = MakeGarbageCollected<SVGInlineTextBox>( - LineLayoutItem(this), start, length); - box->SetHasVirtualLogicalHeight(); - return box; -} - -LayoutRect LayoutSVGInlineText::LocalCaretRect(const InlineBox* box, - int caret_offset, - LayoutUnit*) const { - NOT_DESTROYED(); - if (!box || !box->IsInlineTextBox()) - return LayoutRect(); - - const auto* text_box = To<InlineTextBox>(box); - if (static_cast<unsigned>(caret_offset) < text_box->Start() || - static_cast<unsigned>(caret_offset) > text_box->Start() + text_box->Len()) - return LayoutRect(); - - // Use the edge of the selection rect to determine the caret rect. - if (static_cast<unsigned>(caret_offset) < - text_box->Start() + text_box->Len()) { - LayoutRect rect = - text_box->LocalSelectionRect(caret_offset, caret_offset + 1); - LayoutUnit x = box->IsLeftToRightDirection() ? rect.X() : rect.MaxX(); - return LayoutRect(x, rect.Y(), GetFrameView()->CaretWidth(), rect.Height()); - } - - LayoutRect rect = - text_box->LocalSelectionRect(caret_offset - 1, caret_offset); - LayoutUnit x = box->IsLeftToRightDirection() ? rect.MaxX() : rect.X(); - return LayoutRect(x, rect.Y(), GetFrameView()->CaretWidth(), rect.Height()); -} - -gfx::RectF LayoutSVGInlineText::FloatLinesBoundingBox() const { - NOT_DESTROYED(); - gfx::RectF bounding_box; - for (InlineTextBox* box : TextBoxes()) - bounding_box.Union(gfx::RectF(box->FrameRect())); - return bounding_box; -} - PhysicalRect LayoutSVGInlineText::PhysicalLinesBoundingBox() const { NOT_DESTROYED(); - return PhysicalRect::EnclosingRect(FloatLinesBoundingBox()); -} - -bool LayoutSVGInlineText::CharacterStartsNewTextChunk(int position) const { - NOT_DESTROYED(); - DCHECK_GE(position, 0); - DCHECK_LT(position, static_cast<int>(TextLength())); - - // Each <textPath> element starts a new text chunk, regardless of any x/y - // values. - if (!position && Parent()->IsSVGTextPath() && !PreviousSibling()) - return true; - - const SVGCharacterDataMap::const_iterator it = - character_data_map_.find(static_cast<unsigned>(position + 1)); - if (it == character_data_map_.end()) - return false; - - return it->value.HasX() || it->value.HasY(); + return PhysicalRect(); } gfx::RectF LayoutSVGInlineText::ObjectBoundingBox() const { NOT_DESTROYED(); - if (!IsInLayoutNGInlineFormattingContext()) - return FloatLinesBoundingBox(); + DCHECK(IsInLayoutNGInlineFormattingContext()); gfx::RectF bounds; NGInlineCursor cursor; @@ -203,28 +129,29 @@ DCHECK_GE(GetDocument().Lifecycle().GetState(), DocumentLifecycle::kPrePaintClean); - if (IsInLayoutNGInlineFormattingContext()) { - NGInlineCursor cursor; - cursor.MoveTo(*this); - NGInlineCursor last_hit_cursor; - PhysicalOffset last_hit_transformed_point; - LayoutUnit closest_distance = LayoutUnit::Max(); - for (; cursor; cursor.MoveToNextForSameLayoutObject()) { - PhysicalOffset transformed_point = - cursor.CurrentItem()->MapPointInContainer(point); - PhysicalRect item_rect = cursor.Current().RectInContainerFragment(); - LayoutUnit distance; - if (!item_rect.Contains(transformed_point) || - !cursor.PositionForPointInChild(transformed_point)) - distance = item_rect.SquaredDistanceTo(transformed_point); - // Intentionally apply '<=', not '<', because we'd like to choose a later - // item. - if (distance <= closest_distance) { - closest_distance = distance; - last_hit_cursor = cursor; - last_hit_transformed_point = transformed_point; - } + DCHECK(IsInLayoutNGInlineFormattingContext()); + NGInlineCursor cursor; + cursor.MoveTo(*this); + NGInlineCursor last_hit_cursor; + PhysicalOffset last_hit_transformed_point; + LayoutUnit closest_distance = LayoutUnit::Max(); + for (; cursor; cursor.MoveToNextForSameLayoutObject()) { + PhysicalOffset transformed_point = + cursor.CurrentItem()->MapPointInContainer(point); + PhysicalRect item_rect = cursor.Current().RectInContainerFragment(); + LayoutUnit distance; + if (!item_rect.Contains(transformed_point) || + !cursor.PositionForPointInChild(transformed_point)) { + distance = item_rect.SquaredDistanceTo(transformed_point); } + // Intentionally apply '<=', not '<', because we'd like to choose a later + // item. + if (distance <= closest_distance) { + closest_distance = distance; + last_hit_cursor = cursor; + last_hit_transformed_point = transformed_point; + } + } if (last_hit_cursor) { auto position_with_affinity = last_hit_cursor.PositionForPointInChild(last_hit_transformed_point); @@ -233,247 +160,6 @@ return AdjustForEditingBoundary(position_with_affinity); } return CreatePositionWithAffinity(0); - } - - if (!HasInlineFragments() || !TextLength()) - return CreatePositionWithAffinity(0); - - DCHECK(scaling_factor_); - - const SimpleFontData* font_data = scaled_font_.PrimaryFont(); - DCHECK(font_data); - float baseline = - font_data ? font_data->GetFontMetrics().FloatAscent() / scaling_factor_ - : 0; - - LayoutBlock* containing_block = ContainingBlock(); - DCHECK(containing_block); - - // Map local point to absolute point, as the character origins stored in the - // text fragments use absolute coordinates. - gfx::PointF absolute_point(point); - absolute_point += - gfx::PointF(containing_block->Location()).OffsetFromOrigin(); - - double closest_distance = std::numeric_limits<double>::max(); - float position_in_fragment = 0; - const SVGTextFragment* closest_distance_fragment = nullptr; - SVGInlineTextBox* closest_distance_box = nullptr; - - for (InlineTextBox* box : TextBoxes()) { - auto* text_box = DynamicTo<SVGInlineTextBox>(box); - if (!text_box) - continue; - - for (const SVGTextFragment& fragment : text_box->TextFragments()) { - gfx::RectF fragment_rect = fragment.BoundingBox(baseline); - - double distance = - (fragment_rect.ClosestPoint(absolute_point) - absolute_point) - .LengthSquared(); - if (distance <= closest_distance) { - closest_distance = distance; - closest_distance_box = text_box; - closest_distance_fragment = &fragment; - // TODO(fs): This only works (reasonably) well for text with trivial - // transformations. For improved fidelity in the other cases we ought - // to apply the inverse transformation for the fragment and then map - // against the (untransformed) fragment rect. - position_in_fragment = fragment.is_vertical - ? absolute_point.y() - fragment_rect.y() - : absolute_point.x() - fragment_rect.x(); - } - } - } - - if (!closest_distance_fragment) - return CreatePositionWithAffinity(0); - - int offset = closest_distance_box->OffsetForPositionInFragment( - *closest_distance_fragment, position_in_fragment); - return CreatePositionWithAffinity(offset + closest_distance_box->Start(), - offset > 0 - ? TextAffinity::kUpstreamIfPossible - : TextAffinity::kDownstream); -} - -namespace { - -inline bool IsValidSurrogatePair(const TextRun& run, unsigned index) { - if (!U16_IS_LEAD(run[index])) - return false; - if (index + 1 >= run.length()) - return false; - return U16_IS_TRAIL(run[index + 1]); -} - -unsigned CountCodePoints(const TextRun& run, - unsigned index, - unsigned end_index) { - unsigned num_codepoints = 0; - while (index < end_index) { - index += IsValidSurrogatePair(run, index) ? 2 : 1; - num_codepoints++; - } - return num_codepoints; -} - -TextRun ConstructTextRun(LayoutSVGInlineText& text, - unsigned position, - unsigned length, - TextDirection text_direction) { - const ComputedStyle& style = text.StyleRef(); - - TextRun run( - // characters, will be set below if non-zero. - static_cast<const LChar*>(nullptr), - 0, // length, will be set below if non-zero. - 0, // xPos, only relevant with allowTabs=true - 0, // padding, only relevant for justified text, not relevant for SVG - TextRun::kAllowTrailingExpansion, text_direction, - IsOverride(style.GetUnicodeBidi()) /* directionalOverride */); - - if (length) { - if (text.Is8Bit()) - run.SetText(text.Characters8() + position, length); - else - run.SetText(text.Characters16() + position, length); - } - - // We handle letter & word spacing ourselves. - run.DisableSpacing(); - - // Propagate the maximum length of the characters buffer to the TextRun, even - // when we're only processing a substring. - run.SetCharactersLength(text.TextLength() - position); - DCHECK_GE(run.CharactersLength(), run.length()); - return run; -} - -// TODO(pdr): We only have per-glyph data so we need to synthesize per-grapheme -// data. E.g., if 'fi' is shaped into a single glyph, we do not know the 'i' -// position. The code below synthesizes an average glyph width when characters -// share a single position. This will incorrectly split combining diacritics. -// See: https://crbug.com/473476. -void SynthesizeGraphemeWidths(const TextRun& run, - Vector<CharacterRange>& ranges) { - unsigned distribute_count = 0; - for (int range_index = static_cast<int>(ranges.size()) - 1; range_index >= 0; - --range_index) { - CharacterRange& current_range = ranges[range_index]; - if (current_range.Width() == 0) { - distribute_count++; - continue; - } - if (distribute_count == 0) - continue; - distribute_count++; - - // Distribute the width evenly among the code points. - const unsigned distribute_end = range_index + distribute_count; - unsigned num_codepoints = CountCodePoints(run, range_index, distribute_end); - DCHECK_GT(num_codepoints, 0u); - float new_width = current_range.Width() / num_codepoints; - - float last_end_position = current_range.start; - unsigned distribute_index = range_index; - do { - CharacterRange& range = ranges[distribute_index]; - range.start = last_end_position; - range.end = last_end_position + new_width; - last_end_position = range.end; - distribute_index += IsValidSurrogatePair(run, distribute_index) ? 2 : 1; - } while (distribute_index < distribute_end); - - distribute_count = 0; - } -} - -} // namespace - -void LayoutSVGInlineText::AddMetricsFromRun( - const TextRun& run, - bool& last_character_was_white_space) { - NOT_DESTROYED(); - Vector<CharacterRange> char_ranges = - ScaledFont().IndividualCharacterRanges(run); - SynthesizeGraphemeWidths(run, char_ranges); - - const SimpleFontData* font_data = ScaledFont().PrimaryFont(); - DCHECK(font_data); - if (!font_data) - return; - - const float cached_font_height = - font_data->GetFontMetrics().FloatHeight() / scaling_factor_; - const bool preserve_white_space = - StyleRef().WhiteSpace() == EWhiteSpace::kPre; - const unsigned run_length = run.length(); - - // TODO(pdr): Character-based iteration is ambiguous and error-prone. It - // should be unified under a single concept. See: https://crbug.com/593570 - unsigned character_index = 0; - while (character_index < run_length) { - bool current_character_is_white_space = run[character_index] == ' '; - if (!preserve_white_space && last_character_was_white_space && - current_character_is_white_space) { - metrics_.push_back(SVGTextMetrics(SVGTextMetrics::kSkippedSpaceMetrics)); - character_index++; - continue; - } - - unsigned length = IsValidSurrogatePair(run, character_index) ? 2 : 1; - float width = char_ranges[character_index].Width() / scaling_factor_; - - metrics_.push_back(SVGTextMetrics(length, width, cached_font_height)); - - last_character_was_white_space = current_character_is_white_space; - character_index += length; - } -} - -void LayoutSVGInlineText::UpdateMetricsList( - bool& last_character_was_white_space) { - NOT_DESTROYED(); - metrics_.clear(); - - if (!TextLength()) - return; - - TextRun run = - ConstructTextRun(*this, 0, TextLength(), StyleRef().Direction()); - BidiResolver<TextRunIterator, BidiCharacterRun> bidi_resolver; - BidiRunList<BidiCharacterRun>& bidi_runs = bidi_resolver.Runs(); - bool bidi_override = IsOverride(StyleRef().GetUnicodeBidi()); - BidiStatus status(TextDirection::kLtr, bidi_override); - if (run.Is8Bit() || bidi_override) { - WTF::unicode::CharDirection direction = WTF::unicode::kLeftToRight; - // If BiDi override is in effect, use the specified direction. - if (bidi_override && !StyleRef().IsLeftToRightDirection()) - direction = WTF::unicode::kRightToLeft; - bidi_runs.AddRun(new BidiCharacterRun( - status.context->Override(), status.context->Level(), 0, - run.CharactersLength(), direction, status.context->Dir())); - } else { - status.last = status.last_strong = WTF::unicode::kOtherNeutral; - bidi_resolver.SetStatus(status); - bidi_resolver.SetPositionIgnoringNestedIsolates(TextRunIterator(&run, 0)); - const bool kHardLineBreak = false; - const bool kReorderRuns = false; - bidi_resolver.CreateBidiRunsForLine(TextRunIterator(&run, run.length()), - kNoVisualOverride, kHardLineBreak, - kReorderRuns); - } - - for (const BidiCharacterRun* bidi_run = bidi_runs.FirstRun(); bidi_run; - bidi_run = bidi_run->Next()) { - TextRun sub_run = ConstructTextRun(*this, bidi_run->Start(), - bidi_run->Stop() - bidi_run->Start(), - bidi_run->Direction()); - AddMetricsFromRun(sub_run, last_character_was_white_space); - } - - bidi_resolver.Runs().DeleteRuns(); } void LayoutSVGInlineText::UpdateScaledFont() {
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h b/third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h index 9171d8a3..43919af 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h
@@ -23,9 +23,6 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_INLINE_TEXT_H_ #include "third_party/blink/renderer/core/layout/layout_text.h" -#include "third_party/blink/renderer/core/layout/svg/svg_character_data.h" -#include "third_party/blink/renderer/core/layout/svg/svg_text_metrics.h" -#include "third_party/blink/renderer/platform/wtf/vector.h" namespace blink { @@ -33,21 +30,6 @@ public: LayoutSVGInlineText(Node*, scoped_refptr<StringImpl>); - bool CharacterStartsNewTextChunk(int position) const; - SVGCharacterDataMap& CharacterDataMap() { - NOT_DESTROYED(); - return character_data_map_; - } - const SVGCharacterDataMap& CharacterDataMap() const { - NOT_DESTROYED(); - return character_data_map_; - } - - const Vector<SVGTextMetrics>& MetricsList() const { - NOT_DESTROYED(); - return metrics_; - } - float ScalingFactor() const { NOT_DESTROYED(); return scaling_factor_; @@ -57,15 +39,10 @@ return scaled_font_; } void UpdateScaledFont(); - void UpdateMetricsList(bool& last_character_was_white_space); static void ComputeNewScaledFontForStyle(const LayoutObject&, float& scaling_factor, Font& scaled_font); - // Preserves floating point precision for the use in DRT. It knows how to - // round and does a better job than enclosingIntRect. - gfx::RectF FloatLinesBoundingBox() const; - const char* GetName() const override { NOT_DESTROYED(); return "LayoutSVGInlineText"; @@ -78,8 +55,6 @@ bool IsFontFallbackValid() const override; void InvalidateSubtreeLayoutForFontUpdates() override; - void AddMetricsFromRun(const TextRun&, bool& last_character_was_white_space); - gfx::RectF ObjectBoundingBox() const override; bool IsOfType(LayoutObjectType type) const override { @@ -88,20 +63,13 @@ LayoutText::IsOfType(type); } - LayoutRect LocalCaretRect( - const InlineBox*, - int caret_offset, - LayoutUnit* extra_width_to_end_of_line = nullptr) const override; PhysicalRect PhysicalLinesBoundingBox() const override; - InlineTextBox* CreateTextBox(int start, uint16_t length) override; PhysicalRect VisualRectInDocument(VisualRectFlags) const final; gfx::RectF VisualRectInLocalSVGCoordinates() const final; float scaling_factor_; Font scaled_font_; - SVGCharacterDataMap character_data_map_; - Vector<SVGTextMetrics> metrics_; }; template <>
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_clipper.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_clipper.cc index 0f82b378..bd0321f 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_clipper.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_clipper.cc
@@ -65,7 +65,7 @@ // Only shapes, paths and texts are allowed for clipping. if (layout_object->IsSVGShape()) { strategy = ClipStrategy::kPath; - } else if (layout_object->IsSVGText() || layout_object->IsNGSVGText()) { + } else if (layout_object->IsNGSVGText()) { // Text requires masking. strategy = ClipStrategy::kMask; }
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc index 726bbbd..3960531 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc
@@ -33,7 +33,6 @@ #include "third_party/blink/renderer/core/layout/layout_view.h" #include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_masker.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" #include "third_party/blink/renderer/core/layout/svg/svg_layout_support.h" #include "third_party/blink/renderer/core/layout/svg/svg_resources.h" #include "third_party/blink/renderer/core/layout/svg/transform_helper.h" @@ -205,10 +204,6 @@ DCHECK(NeedsLayout()); LayoutSize old_size = Size(); - if (!RuntimeEnabledFeatures::LayoutNGReplacedNoBoxSettersEnabled()) { - UpdateLogicalWidth(); - UpdateLogicalHeight(); - } // Whether we have a self-painting layer depends on whether there are // compositing descendants (see: |HasCompositingDescendants()| which is called
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 deleted file mode 100644 index a9bd44b..0000000 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_text.cc +++ /dev/null
@@ -1,456 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> - * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2008 Rob Buis <buis@kde.org> - * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> - * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. - * Copyright (C) 2012 Google Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" - -#include "third_party/blink/renderer/core/editing/position_with_affinity.h" -#include "third_party/blink/renderer/core/frame/web_feature.h" -#include "third_party/blink/renderer/core/layout/api/line_layout_item.h" -#include "third_party/blink/renderer/core/layout/hit_test_request.h" -#include "third_party/blink/renderer/core/layout/hit_test_result.h" -#include "third_party/blink/renderer/core/layout/layout_state.h" -#include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.h" -#include "third_party/blink/renderer/core/layout/pointer_events_hit_rules.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_inline.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_container.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_root.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_root_inline_box.h" -#include "third_party/blink/renderer/core/layout/svg/svg_layout_support.h" -#include "third_party/blink/renderer/core/layout/svg/svg_resources.h" -#include "third_party/blink/renderer/core/layout/svg/svg_text_layout_attributes_builder.h" -#include "third_party/blink/renderer/core/layout/svg/transformed_hit_test_location.h" -#include "third_party/blink/renderer/core/paint/svg_text_painter.h" -#include "third_party/blink/renderer/core/style/shadow_list.h" -#include "third_party/blink/renderer/core/svg/svg_text_element.h" -#include "third_party/blink/renderer/platform/instrumentation/use_counter.h" -#include "ui/gfx/geometry/quad_f.h" - -namespace blink { - -namespace { - -const LayoutSVGBlock* FindTextRoot(const LayoutObject* start) { - DCHECK(start); - for (; start; start = start->Parent()) { - if (const auto* text = DynamicTo<LayoutSVGText>(start)) - return text; - if (const auto* ng_text = DynamicTo<LayoutNGSVGText>(start)) - return ng_text; - } - return nullptr; -} - -} // namespace - -LayoutSVGText::LayoutSVGText(Element* node) - : LayoutSVGBlock(To<SVGElement>(node)), - needs_reordering_(false), - needs_positioning_values_update_(false), - needs_text_metrics_update_(false) { - DCHECK(IsA<SVGTextElement>(node)); - UseCounter::Count(GetDocument(), WebFeature::kSVGText); -} - -LayoutSVGText::~LayoutSVGText() { - DCHECK(descendant_text_nodes_.empty()); -} - -void LayoutSVGText::Trace(Visitor* visitor) const { - visitor->Trace(descendant_text_nodes_); - LayoutSVGBlock::Trace(visitor); -} - -void LayoutSVGText::StyleDidChange(StyleDifference diff, - const ComputedStyle* old_style) { - NOT_DESTROYED(); - LayoutSVGBlock::StyleDidChange(diff, old_style); - SVGResources::UpdatePaints(*this, old_style, StyleRef()); -} - -void LayoutSVGText::WillBeDestroyed() { - NOT_DESTROYED(); - descendant_text_nodes_.clear(); - SVGResources::ClearPaints(*this, Style()); - LayoutSVGBlock::WillBeDestroyed(); -} - -bool LayoutSVGText::IsChildAllowed(LayoutObject* child, - const ComputedStyle&) const { - NOT_DESTROYED(); - return child->IsSVGInline() || - (child->IsText() && SVGLayoutSupport::IsLayoutableTextNode(child)); -} - -LayoutSVGBlock* LayoutSVGText::LocateLayoutSVGTextAncestor( - LayoutObject* start) { - return const_cast<LayoutSVGBlock*>(FindTextRoot(start)); -} - -const LayoutSVGBlock* LayoutSVGText::LocateLayoutSVGTextAncestor( - const LayoutObject* start) { - return FindTextRoot(start); -} - -static inline void CollectDescendantTextNodes( - LayoutSVGText& text_root, - HeapVector<Member<LayoutSVGInlineText>>& descendant_text_nodes) { - for (LayoutObject* descendant = text_root.FirstChild(); descendant; - descendant = descendant->NextInPreOrder(&text_root)) { - if (descendant->IsSVGInlineText()) - descendant_text_nodes.push_back(To<LayoutSVGInlineText>(descendant)); - } -} - -void LayoutSVGText::SubtreeStructureChanged( - LayoutInvalidationReasonForTracing reason) { - NOT_DESTROYED(); - if (BeingDestroyed() || !EverHadLayout()) { - DCHECK(descendant_text_nodes_.empty()); - return; - } - if (DocumentBeingDestroyed()) - return; - - // The positioning elements cache depends on the size of each text - // LayoutObject in the subtree. If this changes, clear the cache. It will be - // rebuilt on the next layout. - descendant_text_nodes_.clear(); - SetNeedsPositioningValuesUpdate(); - SetNeedsTextMetricsUpdate(); - // TODO(fs): Restore the passing of |reason| here. - LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this); - - if (StyleRef().UsedUserModify() != EUserModify::kReadOnly) - UseCounter::Count(GetDocument(), WebFeature::kSVGTextEdited); -} - -void LayoutSVGText::NotifySubtreeStructureChanged( - LayoutObject* object, - LayoutInvalidationReasonForTracing reason) { - if (LayoutSVGBlock* text_or_ng_text = LocateLayoutSVGTextAncestor(object)) { - if (auto* layout_text = DynamicTo<LayoutSVGText>(text_or_ng_text)) - layout_text->SubtreeStructureChanged(reason); - else - To<LayoutNGSVGText>(text_or_ng_text)->SubtreeStructureChanged(reason); - } -} - -static inline void UpdateFontAndMetrics(LayoutSVGText& text_root) { - bool last_character_was_white_space = true; - for (LayoutObject* descendant = text_root.FirstChild(); descendant; - descendant = descendant->NextInPreOrder(&text_root)) { - if (!descendant->IsSVGInlineText()) - continue; - auto& text = To<LayoutSVGInlineText>(*descendant); - text.UpdateScaledFont(); - text.UpdateMetricsList(last_character_was_white_space); - } -} - -static inline void CheckDescendantTextNodeConsistency( - LayoutSVGText& text, - HeapVector<Member<LayoutSVGInlineText>>& expected_descendant_text_nodes) { -#if DCHECK_IS_ON() - HeapVector<Member<LayoutSVGInlineText>> new_descendant_text_nodes; - CollectDescendantTextNodes(text, new_descendant_text_nodes); - DCHECK(new_descendant_text_nodes == expected_descendant_text_nodes); -#endif -} - -void LayoutSVGText::UpdateTransformAffectsVectorEffect() { - if (StyleRef().VectorEffect() == EVectorEffect::kNonScalingStroke) { - SetTransformAffectsVectorEffect(true); - return; - } - - SetTransformAffectsVectorEffect(false); - for (LayoutObject* descendant = FirstChild(); descendant; - descendant = descendant->NextInPreOrder(this)) { - if (descendant->IsSVGInline() && descendant->StyleRef().VectorEffect() == - EVectorEffect::kNonScalingStroke) { - SetTransformAffectsVectorEffect(true); - break; - } - } -} - -void LayoutSVGText::UpdateLayout() { - NOT_DESTROYED(); - DCHECK(NeedsLayout()); - // This flag is set and reset as needed only within this function. - DCHECK(!needs_reordering_); - - ClearOffsetMappingIfNeeded(); - - // When laying out initially, build the character data map and propagate - // resulting layout attributes to all LayoutSVGInlineText children in the - // subtree. - if (!EverHadLayout()) { - needs_positioning_values_update_ = true; - needs_text_metrics_update_ = true; - } - - bool update_parent_boundaries = false; - - // If the root layout size changed (eg. window size changes), or the screen - // scale factor has changed, then recompute the on-screen font size. Since - // the computation of layout attributes uses the text metrics, we need to - // update them before updating the layout attributes. - if (needs_text_metrics_update_) { - // Recompute the transform before updating font and corresponding - // metrics. At this point our bounding box may be incorrect, so - // any box relative transforms will be incorrect. Since the scaled - // font size only needs the scaling components to be correct, this - // should be fine. We update the transform again after computing - // the bounding box below, and after that we clear the - // |needs_transform_update_| flag. - if (needs_transform_update_) { - local_transform_ = - GetElement()->CalculateTransform(SVGElement::kIncludeMotionTransform); - } - - UpdateFontAndMetrics(*this); - // Font changes may change the size of the "em" unit, so we need to - // update positions that might depend on the font size. This is a big - // hammer but we have no simple way to determine if the positions of - // children depend on the font size. - needs_positioning_values_update_ = true; - needs_text_metrics_update_ = false; - update_parent_boundaries = true; - } - - // When the x/y/dx/dy/rotate lists change, we need to recompute the layout - // attributes. - if (needs_positioning_values_update_) { - descendant_text_nodes_.clear(); - CollectDescendantTextNodes(*this, descendant_text_nodes_); - - SVGTextLayoutAttributesBuilder(*this).BuildLayoutAttributes(); - - needs_positioning_values_update_ = false; - needs_reordering_ = true; - update_parent_boundaries = true; - } - - CheckDescendantTextNodeConsistency(*this, descendant_text_nodes_); - - // Reduced version of LayoutBlock::layoutBlock(), which only takes care of SVG - // text. All if branches that could cause early exit in LayoutBlocks - // layoutBlock() method are turned into assertions. - DCHECK(!IsInline()); - DCHECK(!SimplifiedLayout()); - DCHECK(!ScrollsOverflow()); - DCHECK(!HasControlClip()); - DCHECK(!PositionedObjects()); - DCHECK(!IsAnonymousBlock()); - - if (!FirstChild()) - SetChildrenInline(true); - - // FIXME: We need to find a way to only layout the child boxes, if needed. - gfx::RectF old_boundaries = ObjectBoundingBox(); - DCHECK(ChildrenInline()); - - RebuildFloatsFromIntruding(); - - LayoutUnit before_edge = - BorderBefore() + PaddingBefore() + ComputeLogicalScrollbars().block_start; - LayoutUnit after_edge = - BorderAfter() + PaddingAfter() + ComputeLogicalScrollbars().block_end; - SetLogicalHeight(before_edge); - - LayoutState state(*this); - LayoutInlineChildren(true, after_edge); - - needs_reordering_ = false; - - const bool bounds_changed = old_boundaries != ObjectBoundingBox(); - if (bounds_changed) { - // Invalidate all resources of this client if our reference box changed. - SVGResourceInvalidator resource_invalidator(*this); - resource_invalidator.InvalidateEffects(); - resource_invalidator.InvalidatePaints(); - update_parent_boundaries = true; - } - - if (UpdateTransformAfterLayout(bounds_changed)) - update_parent_boundaries = true; - - ClearLayoutOverflow(); - - // If our bounds changed, notify the parents. - if (update_parent_boundaries) - LayoutSVGBlock::SetNeedsBoundariesUpdate(); - - UpdateTransformAffectsVectorEffect(); - - DCHECK(!needs_reordering_); - DCHECK(!needs_transform_update_); - DCHECK(!needs_text_metrics_update_); - DCHECK(!needs_positioning_values_update_); - ClearSelfNeedsLayoutOverflowRecalc(); - ClearNeedsLayout(); -} - -void LayoutSVGText::RecalcVisualOverflow() { - NOT_DESTROYED(); - ClearVisualOverflow(); - LayoutObject::RecalcVisualOverflow(); - AddSelfVisualOverflow(LayoutRect(ObjectBoundingBox())); - AddVisualEffectOverflow(); -} - -RootInlineBox* LayoutSVGText::CreateRootInlineBox() { - NOT_DESTROYED(); - RootInlineBox* box = - MakeGarbageCollected<SVGRootInlineBox>(LineLayoutItem(this)); - box->SetHasVirtualLogicalHeight(); - return box; -} - -bool LayoutSVGText::NodeAtPoint(HitTestResult& result, - const HitTestLocation& hit_test_location, - const PhysicalOffset& accumulated_offset, - HitTestPhase phase) { - NOT_DESTROYED(); - DCHECK_EQ(accumulated_offset, PhysicalOffset()); - // We only draw in the foreground phase, so we only hit-test then. - if (phase != HitTestPhase::kForeground) - return false; - - TransformedHitTestLocation local_location(hit_test_location, - LocalToSVGParentTransform()); - if (!local_location) - return false; - if (!SVGLayoutSupport::IntersectsClipPath(*this, ObjectBoundingBox(), - *local_location)) - return false; - - if (LayoutBlock::NodeAtPoint(result, *local_location, accumulated_offset, - phase)) - return true; - - // Consider the bounding box if requested. - if (StyleRef().UsedPointerEvents() == EPointerEvents::kBoundingBox) { - if (IsObjectBoundingBoxValid() && - local_location->Intersects(ObjectBoundingBox())) { - UpdateHitTestResult(result, PhysicalOffset::FromPointFRound( - local_location->TransformedPoint())); - if (result.AddNodeToListBasedTestResult(GetElement(), *local_location) == - kStopHitTesting) - return true; - } - } - return false; -} - -PositionWithAffinity LayoutSVGText::PositionForPoint( - const PhysicalOffset& point_in_contents) const { - NOT_DESTROYED(); - RootInlineBox* root_box = FirstRootBox(); - if (!root_box) - return CreatePositionWithAffinity(0); - - PhysicalOffset clipped_point_in_contents(point_in_contents); - clipped_point_in_contents -= root_box->PhysicalLocation(); - clipped_point_in_contents.ClampNegativeToZero(); - clipped_point_in_contents += root_box->PhysicalLocation(); - - DCHECK(!root_box->NextRootBox()); - DCHECK(ChildrenInline()); - - auto* closest_box = - To<SVGRootInlineBox>(root_box)->ClosestLeafChildForPosition( - clipped_point_in_contents); - if (!closest_box) - return CreatePositionWithAffinity(0); - - return closest_box->GetLineLayoutItem().PositionForPoint( - PhysicalOffset(clipped_point_in_contents.left, closest_box->Y())); -} - -void LayoutSVGText::AbsoluteQuads(Vector<gfx::QuadF>& quads, - MapCoordinatesFlags mode) const { - NOT_DESTROYED(); - quads.push_back(LocalToAbsoluteQuad(gfx::QuadF(StrokeBoundingBox()), mode)); -} - -void LayoutSVGText::Paint(const PaintInfo& paint_info) const { - NOT_DESTROYED(); - SVGTextPainter(*this).Paint(paint_info); -} - -gfx::RectF LayoutSVGText::ObjectBoundingBox() const { - NOT_DESTROYED(); - if (const RootInlineBox* box = FirstRootBox()) - return gfx::RectF(box->FrameRect()); - return gfx::RectF(); -} - -gfx::RectF LayoutSVGText::StrokeBoundingBox() const { - NOT_DESTROYED(); - if (!FirstRootBox()) - return gfx::RectF(); - return SVGLayoutSupport::ExtendTextBBoxWithStroke(*this, ObjectBoundingBox()); -} - -gfx::RectF LayoutSVGText::VisualRectInLocalSVGCoordinates() const { - NOT_DESTROYED(); - if (!FirstRootBox()) - return gfx::RectF(); - return SVGLayoutSupport::ComputeVisualRectForText(*this, ObjectBoundingBox()); -} - -void LayoutSVGText::AddOutlineRects(Vector<PhysicalRect>& rects, - OutlineInfo* info, - const PhysicalOffset&, - NGOutlineType) const { - NOT_DESTROYED(); - rects.push_back(PhysicalRect::EnclosingRect(ObjectBoundingBox())); - if (info) - *info = OutlineInfo::GetUnzoomedFromStyle(StyleRef()); -} - -bool LayoutSVGText::IsObjectBoundingBoxValid() const { - NOT_DESTROYED(); - // If we don't have any line boxes, then consider the bbox invalid. - return FirstLineBox(); -} - -void LayoutSVGText::AddChild(LayoutObject* child, LayoutObject* before_child) { - NOT_DESTROYED(); - LayoutSVGBlock::AddChild(child, before_child); - SubtreeStructureChanged(layout_invalidation_reason::kChildChanged); -} - -void LayoutSVGText::RemoveChild(LayoutObject* child) { - NOT_DESTROYED(); - SubtreeStructureChanged(layout_invalidation_reason::kChildChanged); - LayoutSVGBlock::RemoveChild(child); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_text.h b/third_party/blink/renderer/core/layout/svg/layout_svg_text.h deleted file mode 100644 index df42555..0000000 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_text.h +++ /dev/null
@@ -1,130 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_TEXT_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_TEXT_H_ - -#include "third_party/blink/renderer/core/layout/svg/layout_svg_block.h" - -namespace blink { - -class LayoutSVGInlineText; - -class LayoutSVGText final : public LayoutSVGBlock { - public: - explicit LayoutSVGText(Element*); - ~LayoutSVGText() override; - void Trace(Visitor*) const override; - - bool IsChildAllowed(LayoutObject*, const ComputedStyle&) const override; - - void SetNeedsPositioningValuesUpdate() { - NOT_DESTROYED(); - needs_positioning_values_update_ = true; - } - void SetNeedsTextMetricsUpdate() { - NOT_DESTROYED(); - needs_text_metrics_update_ = true; - } - gfx::RectF VisualRectInLocalSVGCoordinates() const override; - gfx::RectF ObjectBoundingBox() const override; - gfx::RectF StrokeBoundingBox() const override; - bool IsObjectBoundingBoxValid() const; - - void AddOutlineRects(Vector<PhysicalRect>&, - OutlineInfo*, - const PhysicalOffset& additional_offset, - NGOutlineType) const override; - - // These two functions return a LayoutSVGText, a LayoutNGSVGText, or nullptr. - static LayoutSVGBlock* LocateLayoutSVGTextAncestor(LayoutObject*); - static const LayoutSVGBlock* LocateLayoutSVGTextAncestor(const LayoutObject*); - - static void NotifySubtreeStructureChanged(LayoutObject*, - LayoutInvalidationReasonForTracing); - - bool NeedsReordering() const { - NOT_DESTROYED(); - return needs_reordering_; - } - const HeapVector<Member<LayoutSVGInlineText>>& DescendantTextNodes() const { - NOT_DESTROYED(); - return descendant_text_nodes_; - } - - void RecalcVisualOverflow() override; - - const char* GetName() const override { - NOT_DESTROYED(); - return "LayoutSVGText"; - } - - private: - bool RespectsCSSOverflow() const override { - NOT_DESTROYED(); - return false; - } - - bool IsOfType(LayoutObjectType type) const override { - NOT_DESTROYED(); - return type == kLayoutObjectSVGText || LayoutSVGBlock::IsOfType(type); - } - - void Paint(const PaintInfo&) const override; - bool NodeAtPoint(HitTestResult&, - const HitTestLocation&, - const PhysicalOffset& accumulated_offset, - HitTestPhase) override; - PositionWithAffinity PositionForPoint(const PhysicalOffset&) const override; - - void UpdateLayout() override; - - void AbsoluteQuads(Vector<gfx::QuadF>&, - MapCoordinatesFlags mode = 0) const override; - - void AddChild(LayoutObject* child, - LayoutObject* before_child = nullptr) override; - void RemoveChild(LayoutObject*) override; - - void StyleDidChange(StyleDifference, const ComputedStyle* old_style) override; - void WillBeDestroyed() override; - - RootInlineBox* CreateRootInlineBox() override; - - void SubtreeStructureChanged(LayoutInvalidationReasonForTracing); - void UpdateTransformAffectsVectorEffect(); - - bool needs_reordering_ : 1; - bool needs_positioning_values_update_ : 1; - bool needs_text_metrics_update_ : 1; - HeapVector<Member<LayoutSVGInlineText>> descendant_text_nodes_; -}; - -template <> -struct DowncastTraits<LayoutSVGText> { - static bool AllowFrom(const LayoutObject& object) { - return object.IsSVGText(); - } -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_TEXT_H_
diff --git a/third_party/blink/renderer/core/layout/svg/line/svg_inline_flow_box.cc b/third_party/blink/renderer/core/layout/svg/line/svg_inline_flow_box.cc deleted file mode 100644 index 8f31a94..0000000 --- a/third_party/blink/renderer/core/layout/svg/line/svg_inline_flow_box.cc +++ /dev/null
@@ -1,37 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> - * Copyright (C) 2006 Apple Computer Inc. - * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_flow_box.h" - -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.h" -#include "third_party/blink/renderer/core/paint/svg_inline_flow_box_painter.h" - -namespace blink { - -void SVGInlineFlowBox::Paint(const PaintInfo& paint_info, - const PhysicalOffset& paint_offset, - LayoutUnit, - LayoutUnit) const { - SVGInlineFlowBoxPainter(*this).Paint(paint_info, paint_offset); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/line/svg_inline_flow_box.h b/third_party/blink/renderer/core/layout/svg/line/svg_inline_flow_box.h deleted file mode 100644 index 9e40bcf..0000000 --- a/third_party/blink/renderer/core/layout/svg/line/svg_inline_flow_box.h +++ /dev/null
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> - * Copyright (C) 2006 Apple Computer Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LINE_SVG_INLINE_FLOW_BOX_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LINE_SVG_INLINE_FLOW_BOX_H_ - -#include "third_party/blink/renderer/core/layout/line/inline_flow_box.h" -#include "third_party/blink/renderer/platform/wtf/casting.h" - -namespace blink { - -class SVGInlineFlowBox final : public InlineFlowBox { - public: - SVGInlineFlowBox(LineLayoutItem item) : InlineFlowBox(item) {} - - bool IsSVGInlineFlowBox() const override { return true; } - LayoutUnit VirtualLogicalHeight() const override { return logical_height_; } - void SetLogicalHeight(LayoutUnit h) { logical_height_ = h; } - - void Paint(const PaintInfo&, - const PhysicalOffset&, - LayoutUnit line_top, - LayoutUnit line_bottom) const override; - - private: - LayoutUnit logical_height_; -}; - -template <> -struct DowncastTraits<SVGInlineFlowBox> { - static bool AllowFrom(const InlineBox& box) { - return box.IsSVGInlineFlowBox(); - } -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LINE_SVG_INLINE_FLOW_BOX_H_
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 deleted file mode 100644 index 0e15735..0000000 --- a/third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.cc +++ /dev/null
@@ -1,337 +0,0 @@ -/* - * Copyright (C) 2007 Rob Buis <buis@kde.org> - * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.h" - -#include "third_party/blink/renderer/core/editing/markers/document_marker.h" -#include "third_party/blink/renderer/core/editing/markers/text_match_marker.h" -#include "third_party/blink/renderer/core/layout/api/line_layout_svg_inline_text.h" -#include "third_party/blink/renderer/core/layout/hit_test_result.h" -#include "third_party/blink/renderer/core/layout/pointer_events_hit_rules.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h" -#include "third_party/blink/renderer/core/paint/svg_inline_text_box_painter.h" -#include "third_party/blink/renderer/platform/wtf/math_extras.h" -#include "third_party/blink/renderer/platform/wtf/size_assertions.h" -#include "ui/gfx/geometry/rect_conversions.h" - -namespace blink { - -struct SameSizeAsSVGInlineTextBox : public InlineTextBox { - LayoutUnit float1; - uint32_t bitfields : 1; - Vector<SVGTextFragment> vector; -}; - -ASSERT_SIZE(SVGInlineTextBox, SameSizeAsSVGInlineTextBox); - -SVGInlineTextBox::SVGInlineTextBox(LineLayoutItem item, - int start, - uint16_t length) - : InlineTextBox(item, start, length), starts_new_text_chunk_(false) {} - -void SVGInlineTextBox::DirtyLineBoxes() { - InlineTextBox::DirtyLineBoxes(); - - // Clear the now stale text fragments. - ClearTextFragments(); - - // And clear any following text fragments as the text on which they depend may - // now no longer exist, or glyph positions may be wrong. - InlineTextBox* next_box = NextForSameLayoutObject(); - if (next_box) - next_box->DirtyLineBoxes(); -} - -int SVGInlineTextBox::OffsetForPosition(LayoutUnit, - IncludePartialGlyphsOption, - BreakGlyphsOption) const { - // SVG doesn't use the standard offset <-> position selection system, as it's - // not suitable for SVGs complex needs. Vertical text selection, inline boxes - // spanning multiple lines (contrary to HTML, etc.) - NOTREACHED(); - return 0; -} - -int SVGInlineTextBox::OffsetForPositionInFragment( - const SVGTextFragment& fragment, - float position) const { - LineLayoutSVGInlineText line_layout_item = - LineLayoutSVGInlineText(GetLineLayoutItem()); - - // Adjust position for the scaled font size. - DCHECK(line_layout_item.ScalingFactor()); - position *= line_layout_item.ScalingFactor(); - - // If this fragment is subjected to 'textLength' glyph adjustments, then - // apply the inverse to the position within the fragment. - if (fragment.AffectedByTextLength()) - position /= fragment.length_adjust_scale; - - TextRun text_run = ConstructTextRun(line_layout_item.StyleRef(), fragment); - return fragment.character_offset - Start() + - line_layout_item.ScaledFont().OffsetForPosition( - text_run, position, kIncludePartialGlyphs, - BreakGlyphsOption(true)); -} - -LayoutUnit SVGInlineTextBox::PositionForOffset(int) const { - // SVG doesn't use the offset <-> position selection system. - NOTREACHED(); - return LayoutUnit(); -} - -gfx::RectF SVGInlineTextBox::SelectionRectForTextFragment( - const SVGTextFragment& fragment, - int start_position, - int end_position, - const ComputedStyle& style) const { - DCHECK_LT(start_position, end_position); - - LineLayoutSVGInlineText line_layout_item = - LineLayoutSVGInlineText(GetLineLayoutItem()); - - float scaling_factor = line_layout_item.ScalingFactor(); - DCHECK(scaling_factor); - - const Font& scaled_font = line_layout_item.ScaledFont(); - const SimpleFontData* font_data = scaled_font.PrimaryFont(); - DCHECK(font_data); - if (!font_data) - return gfx::RectF(); - - const FontMetrics& scaled_font_metrics = font_data->GetFontMetrics(); - gfx::PointF text_origin(fragment.x, fragment.y); - if (scaling_factor != 1) - text_origin.Scale(scaling_factor, scaling_factor); - - text_origin.Offset(0, -scaled_font_metrics.FloatAscent()); - - gfx::RectF selection_rect = scaled_font.SelectionRectForText( - ConstructTextRun(style, fragment), text_origin, - fragment.height * scaling_factor, start_position, end_position); - if (scaling_factor == 1) - return selection_rect; - - selection_rect.Scale(1 / scaling_factor); - return selection_rect; -} - -LayoutRect SVGInlineTextBox::LocalSelectionRect( - int start_position, - int end_position, - bool consider_current_selection) const { - int box_start = Start(); - start_position = std::max(start_position - box_start, 0); - end_position = std::min(end_position - box_start, static_cast<int>(Len())); - if (start_position >= end_position) - return LayoutRect(); - - const ComputedStyle& style = GetLineLayoutItem().StyleRef(); - - gfx::RectF selection_rect; - int fragment_start_position = 0; - int fragment_end_position = 0; - - unsigned text_fragments_size = text_fragments_.size(); - for (unsigned i = 0; i < text_fragments_size; ++i) { - const SVGTextFragment& fragment = text_fragments_.at(i); - - fragment_start_position = start_position; - fragment_end_position = end_position; - if (!MapStartEndPositionsIntoFragmentCoordinates( - fragment, fragment_start_position, fragment_end_position)) - continue; - - gfx::RectF fragment_rect = SelectionRectForTextFragment( - fragment, fragment_start_position, fragment_end_position, style); - if (fragment.IsTransformed()) - fragment_rect = fragment.BuildFragmentTransform().MapRect(fragment_rect); - - selection_rect.Union(fragment_rect); - } - - return LayoutRect(gfx::ToEnclosingRect(selection_rect)); -} - -void SVGInlineTextBox::Paint(const PaintInfo& paint_info, - const PhysicalOffset& paint_offset, - LayoutUnit, - LayoutUnit) const { - SVGInlineTextBoxPainter(*this).Paint(paint_info, paint_offset); -} - -TextRun SVGInlineTextBox::ConstructTextRun( - const ComputedStyle& style, - const SVGTextFragment& fragment) const { - LineLayoutText text = GetLineLayoutItem(); - CHECK(!text.NeedsLayout()); - - TextRun run( - // characters, will be set below if non-zero. - static_cast<const LChar*>(nullptr), - 0, // length, will be set below if non-zero. - 0, // xPos, only relevant with allowTabs=true - 0, // padding, only relevant for justified text, not relevant for SVG - TextRun::kAllowTrailingExpansion, Direction(), - DirOverride() || - style.RtlOrdering() == EOrder::kVisual /* directionalOverride */); - - if (fragment.length) { - if (text.Is8Bit()) - run.SetText(text.Characters8() + fragment.character_offset, - fragment.length); - else - run.SetText(text.Characters16() + fragment.character_offset, - fragment.length); - } - - // We handle letter & word spacing ourselves. - run.DisableSpacing(); - - // Propagate the maximum length of the characters buffer to the TextRun, even - // when we're only processing a substring. - run.SetCharactersLength(text.TextLength() - fragment.character_offset); - DCHECK_GE(run.CharactersLength(), run.length()); - return run; -} - -bool SVGInlineTextBox::MapStartEndPositionsIntoFragmentCoordinates( - const SVGTextFragment& fragment, - int& start_position, - int& end_position) const { - int fragment_offset_in_box = - static_cast<int>(fragment.character_offset) - Start(); - - // Compute positions relative to the fragment. - start_position -= fragment_offset_in_box; - end_position -= fragment_offset_in_box; - - // Intersect with the fragment range. - start_position = std::max(start_position, 0); - end_position = std::min(end_position, static_cast<int>(fragment.length)); - - return start_position < end_position; -} - -void SVGInlineTextBox::PaintDocumentMarker(const PaintInfo&, - const PhysicalOffset&, - const DocumentMarker&, - const ComputedStyle&, - const Font&, - bool) const { - // SVG does not have support for generic document markers (e.g., - // spellchecking, etc). -} - -void SVGInlineTextBox::PaintTextMarkerForeground(const PaintInfo& paint_info, - const PhysicalOffset& point, - const DocumentMarker& marker, - const ComputedStyle& style, - const Font& font) const { - SVGInlineTextBoxPainter(*this).PaintTextMarkerForeground(paint_info, point, - marker, style, font); -} - -void SVGInlineTextBox::PaintTextMarkerBackground(const PaintInfo& paint_info, - const PhysicalOffset& point, - const DocumentMarker& marker, - const ComputedStyle& style, - const Font& font) const { - SVGInlineTextBoxPainter(*this).PaintTextMarkerBackground(paint_info, point, - marker, style, font); -} - -gfx::RectF SVGInlineTextBox::CalculateBoundaries() const { - LineLayoutSVGInlineText line_layout_item = - LineLayoutSVGInlineText(GetLineLayoutItem()); - const SimpleFontData* font_data = line_layout_item.ScaledFont().PrimaryFont(); - DCHECK(font_data); - if (!font_data) - return gfx::RectF(); - - float scaling_factor = line_layout_item.ScalingFactor(); - DCHECK(scaling_factor); - float baseline = font_data->GetFontMetrics().FloatAscent() / scaling_factor; - - gfx::RectF text_bounding_rect; - for (const SVGTextFragment& fragment : text_fragments_) - text_bounding_rect.Union(fragment.OverflowBoundingBox(baseline)); - - return text_bounding_rect; -} - -bool SVGInlineTextBox::HitTestFragments( - const HitTestLocation& hit_test_location) const { - auto line_layout_item = LineLayoutSVGInlineText(GetLineLayoutItem()); - const SimpleFontData* font_data = line_layout_item.ScaledFont().PrimaryFont(); - DCHECK(font_data); - if (!font_data) - return false; - - DCHECK(line_layout_item.ScalingFactor()); - float baseline = font_data->GetFontMetrics().FloatAscent() / - line_layout_item.ScalingFactor(); - for (const SVGTextFragment& fragment : text_fragments_) { - gfx::QuadF fragment_quad = fragment.BoundingQuad(baseline); - if (hit_test_location.Intersects(fragment_quad)) - return true; - } - return false; -} - -bool SVGInlineTextBox::NodeAtPoint(HitTestResult& result, - const HitTestLocation& hit_test_location, - const PhysicalOffset& accumulated_offset, - LayoutUnit, - LayoutUnit) { - // FIXME: integrate with InlineTextBox::nodeAtPoint better. - DCHECK(!IsLineBreak()); - - auto line_layout_item = LineLayoutSVGInlineText(GetLineLayoutItem()); - const ComputedStyle& style = line_layout_item.StyleRef(); - PointerEventsHitRules hit_rules(PointerEventsHitRules::kSvgTextHitTesting, - result.GetHitTestRequest(), - style.UsedPointerEvents()); - if (hit_rules.require_visible && style.Visibility() != EVisibility::kVisible) - return false; - if (hit_rules.can_hit_bounding_box || - (hit_rules.can_hit_stroke && - (style.HasStroke() || !hit_rules.require_stroke)) || - (hit_rules.can_hit_fill && - (style.HasFill() || !hit_rules.require_fill))) { - // Currently SVGInlineTextBox doesn't flip in blocks direction. - PhysicalRect rect{PhysicalOffset(Location()), PhysicalSize(Size())}; - rect.Move(accumulated_offset); - if (hit_test_location.Intersects(rect)) { - if (HitTestFragments(hit_test_location)) { - line_layout_item.UpdateHitTestResult( - result, hit_test_location.Point() - accumulated_offset); - if (result.AddNodeToListBasedTestResult(line_layout_item.GetNode(), - hit_test_location, - rect) == kStopHitTesting) - return true; - } - } - } - return false; -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.h b/third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.h deleted file mode 100644 index 31facba..0000000 --- a/third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.h +++ /dev/null
@@ -1,121 +0,0 @@ -/* - * Copyright (C) 2007 Rob Buis <buis@kde.org> - * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LINE_SVG_INLINE_TEXT_BOX_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LINE_SVG_INLINE_TEXT_BOX_H_ - -#include "third_party/blink/renderer/core/layout/line/inline_text_box.h" -#include "third_party/blink/renderer/core/layout/svg/svg_text_layout_engine.h" - -namespace blink { - -class DocumentMarker; - -class SVGInlineTextBox final : public InlineTextBox { - public: - SVGInlineTextBox(LineLayoutItem, int start, uint16_t length); - - bool IsSVGInlineTextBox() const override { return true; } - - LayoutUnit VirtualLogicalHeight() const override { return logical_height_; } - void SetLogicalHeight(LayoutUnit height) { logical_height_ = height; } - - int OffsetForPosition(LayoutUnit x, - IncludePartialGlyphsOption, - BreakGlyphsOption) const override; - LayoutUnit PositionForOffset(int offset) const override; - - void Paint(const PaintInfo&, - const PhysicalOffset&, - LayoutUnit line_top, - LayoutUnit line_bottom) const override; - LayoutRect LocalSelectionRect( - int start_position, - int end_position, - bool consider_current_selection = true) const override; - - bool MapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment&, - int& start_position, - int& end_position) const; - - // Calculate the bounding rect of all text fragments. - gfx::RectF CalculateBoundaries() const; - - void ClearTextFragments() { text_fragments_.clear(); } - Vector<SVGTextFragment>& TextFragments() { return text_fragments_; } - const Vector<SVGTextFragment>& TextFragments() const { - return text_fragments_; - } - - void DirtyLineBoxes() override; - - bool StartsNewTextChunk() const { return starts_new_text_chunk_; } - void SetStartsNewTextChunk(bool new_text_chunk) { - starts_new_text_chunk_ = new_text_chunk; - } - - int OffsetForPositionInFragment(const SVGTextFragment&, float position) const; - gfx::RectF SelectionRectForTextFragment(const SVGTextFragment&, - int fragment_start_position, - int fragment_end_position, - const ComputedStyle&) const; - TextRun ConstructTextRun(const ComputedStyle&, const SVGTextFragment&) const; - - private: - void PaintDocumentMarker(const PaintInfo&, - const PhysicalOffset&, - const DocumentMarker&, - const ComputedStyle&, - const Font&, - bool) const final; - void PaintTextMarkerForeground(const PaintInfo&, - const PhysicalOffset&, - const DocumentMarker&, - const ComputedStyle&, - const Font&) const final; - void PaintTextMarkerBackground(const PaintInfo&, - const PhysicalOffset&, - const DocumentMarker&, - const ComputedStyle&, - const Font&) const final; - - bool HitTestFragments(const HitTestLocation& hit_test_location) const; - bool NodeAtPoint(HitTestResult&, - const HitTestLocation&, - const PhysicalOffset& accumulated_offset, - LayoutUnit line_top, - LayoutUnit line_bottom) override; - - LayoutUnit logical_height_; - bool starts_new_text_chunk_ : 1; - Vector<SVGTextFragment> text_fragments_; -}; - -template <> -struct DowncastTraits<SVGInlineTextBox> { - static bool AllowFrom(const InlineBox& box) { - return box.IsSVGInlineTextBox(); - } -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LINE_SVG_INLINE_TEXT_BOX_H_
diff --git a/third_party/blink/renderer/core/layout/svg/line/svg_root_inline_box.cc b/third_party/blink/renderer/core/layout/svg/line/svg_root_inline_box.cc deleted file mode 100644 index 352c3293..0000000 --- a/third_party/blink/renderer/core/layout/svg/line/svg_root_inline_box.cc +++ /dev/null
@@ -1,215 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> - * Copyright (C) 2006 Apple Computer Inc. - * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * Copyright (C) 2011 Torch Mobile (Beijing) CO. Ltd. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "third_party/blink/renderer/core/layout/svg/line/svg_root_inline_box.h" - -#include "third_party/blink/renderer/core/layout/api/line_layout_api_shim.h" -#include "third_party/blink/renderer/core/layout/api/line_layout_block_flow.h" -#include "third_party/blink/renderer/core/layout/api/line_layout_svg_inline_text.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_flow_box.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.h" -#include "third_party/blink/renderer/core/layout/svg/svg_text_layout_engine.h" -#include "third_party/blink/renderer/core/paint/svg_root_inline_box_painter.h" - -namespace blink { - -void SVGRootInlineBox::Paint(const PaintInfo& paint_info, - const PhysicalOffset& paint_offset, - LayoutUnit, - LayoutUnit) const { - SVGRootInlineBoxPainter(*this).Paint(paint_info, paint_offset); -} - -void SVGRootInlineBox::MarkDirty() { - for (InlineBox* child = FirstChild(); child; child = child->NextOnLine()) - child->MarkDirty(); - RootInlineBox::MarkDirty(); -} - -void SVGRootInlineBox::ComputePerCharacterLayoutInformation() { - auto& text_root = - To<LayoutSVGText>(*LineLayoutAPIShim::LayoutObjectFrom(Block())); - - const HeapVector<Member<LayoutSVGInlineText>>& descendant_text_nodes = - text_root.DescendantTextNodes(); - if (descendant_text_nodes.empty()) - return; - - if (text_root.NeedsReordering()) - ReorderValueLists(); - - // Perform SVG text layout phase two (see SVGTextLayoutEngine for details). - SVGTextLayoutEngine character_layout(descendant_text_nodes); - character_layout.LayoutCharactersInTextBoxes(this); - - // Perform SVG text layout phase three (see SVGTextChunkBuilder for details). - character_layout.FinishLayout(); - - // Perform SVG text layout phase four - // Position & resize all SVGInlineText/FlowBoxes in the inline box tree, - // resize the root box as well as the LayoutSVGText parent block. - LayoutInlineBoxes(*this); - - // Let the HTML block space originate from the local SVG coordinate space. - LineLayoutBlockFlow parent_block = Block(); - parent_block.SetLocation(LayoutPoint()); - // The width could be any value, but set it so that a line box will mirror - // within the childRect when its coordinates are converted between physical - // block direction and flipped block direction, for ease of understanding of - // flipped coordinates. The height doesn't matter. - parent_block.SetSize(LayoutSize(X() * 2 + Width(), LayoutUnit())); - - SetLineTopBottomPositions(LogicalTop(), LogicalBottom(), LogicalTop(), - LogicalBottom()); -} - -gfx::RectF SVGRootInlineBox::LayoutInlineBoxes(InlineBox& box) { - gfx::RectF rect; - if (auto* svg_inline_text_box = DynamicTo<SVGInlineTextBox>(box)) { - rect = svg_inline_text_box->CalculateBoundaries(); - } else { - for (InlineBox* child = To<InlineFlowBox>(box).FirstChild(); child; - child = child->NextOnLine()) - rect.Union(LayoutInlineBoxes(*child)); - } - - LayoutRect logical_rect(EnclosingLayoutRect(rect)); - if (!box.IsHorizontal()) - logical_rect.SetSize(logical_rect.Size().TransposedSize()); - - box.SetX(logical_rect.X()); - box.SetY(logical_rect.Y()); - box.SetLogicalWidth(logical_rect.Width()); - if (auto* svg_inline_text_box = DynamicTo<SVGInlineTextBox>(box)) - svg_inline_text_box->SetLogicalHeight(logical_rect.Height()); - else if (auto* svg_inline_flow_box = DynamicTo<SVGInlineFlowBox>(box)) - svg_inline_flow_box->SetLogicalHeight(logical_rect.Height()); - else - To<SVGRootInlineBox>(box).SetLogicalHeight(logical_rect.Height()); - - return rect; -} - -InlineBox* SVGRootInlineBox::ClosestLeafChildForPosition( - const PhysicalOffset& point) { - InlineBox* first_leaf = FirstLeafChild(); - InlineBox* last_leaf = LastLeafChild(); - if (first_leaf == last_leaf) - return first_leaf; - - // FIXME: Check for vertical text! - InlineBox* closest_leaf = nullptr; - for (InlineBox* leaf = first_leaf; leaf; leaf = leaf->NextLeafChild()) { - if (!leaf->IsSVGInlineTextBox()) - continue; - if (point.top < leaf->Y()) - continue; - if (point.left > leaf->Y() + leaf->VirtualLogicalHeight()) - continue; - - closest_leaf = leaf; - if (point.left < leaf->X() + leaf->LogicalWidth()) - return leaf; - } - - return closest_leaf ? closest_leaf : last_leaf; -} - -static inline void SwapPositioningValuesInTextBoxes( - SVGInlineTextBox* first_text_box, - SVGInlineTextBox* last_text_box) { - LineLayoutSVGInlineText first_text_node = - LineLayoutSVGInlineText(first_text_box->GetLineLayoutItem()); - SVGCharacterDataMap& first_character_data_map = - first_text_node.CharacterDataMap(); - SVGCharacterDataMap::iterator it_first = - first_character_data_map.find(first_text_box->Start() + 1); - if (it_first == first_character_data_map.end()) - return; - LineLayoutSVGInlineText last_text_node = - LineLayoutSVGInlineText(last_text_box->GetLineLayoutItem()); - SVGCharacterDataMap& last_character_data_map = - last_text_node.CharacterDataMap(); - SVGCharacterDataMap::iterator it_last = - last_character_data_map.find(last_text_box->Start() + 1); - if (it_last == last_character_data_map.end()) - return; - // We only want to perform the swap if both inline boxes are absolutely - // positioned. - std::swap(it_first->value, it_last->value); -} - -static inline void ReverseInlineBoxRangeAndValueListsIfNeeded( - HeapVector<Member<InlineBox>>::iterator first, - HeapVector<Member<InlineBox>>::iterator last) { - // This is a copy of std::reverse(first, last). It additionally assures - // that the metrics map within the layoutObjects belonging to the - // InlineBoxes are reordered as well. - while (true) { - if (first == last || first == --last) - return; - - auto* first_text_box = DynamicTo<SVGInlineTextBox>(first->Get()); - auto* last_text_box = DynamicTo<SVGInlineTextBox>(last->Get()); - if (last_text_box && first_text_box) { - // Reordering is only necessary for BiDi text that is _absolutely_ - // positioned. - if (first_text_box->Len() == 1 && - first_text_box->Len() == last_text_box->Len()) - SwapPositioningValuesInTextBoxes(first_text_box, last_text_box); - } - - InlineBox* temp = *first; - *first = *last; - *last = temp; - ++first; - } -} - -void SVGRootInlineBox::ReorderValueLists() { - HeapVector<Member<InlineBox>> leaf_boxes_in_logical_order; - ClearCollectionScope<HeapVector<Member<InlineBox>>> scope( - &leaf_boxes_in_logical_order); - CollectLeafBoxesInLogicalOrder(leaf_boxes_in_logical_order, - ReverseInlineBoxRangeAndValueListsIfNeeded); -} - -bool SVGRootInlineBox::NodeAtPoint(HitTestResult& result, - const HitTestLocation& hit_test_location, - const PhysicalOffset& accumulated_offset, - LayoutUnit line_top, - LayoutUnit line_bottom) { - // Iterate the text boxes in reverse so that the top-most node will be considered first. - for (InlineBox* leaf = LastLeafChild(); leaf; leaf = leaf->PrevLeafChild()) { - if (!leaf->IsSVGInlineTextBox()) - continue; - if (leaf->NodeAtPoint(result, hit_test_location, accumulated_offset, - line_top, line_bottom)) - return true; - } - - return false; -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/line/svg_root_inline_box.h b/third_party/blink/renderer/core/layout/svg/line/svg_root_inline_box.h deleted file mode 100644 index cdb549b..0000000 --- a/third_party/blink/renderer/core/layout/svg/line/svg_root_inline_box.h +++ /dev/null
@@ -1,73 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> - * Copyright (C) 2006 Apple Computer Inc. - * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LINE_SVG_ROOT_INLINE_BOX_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LINE_SVG_ROOT_INLINE_BOX_H_ - -#include "third_party/blink/renderer/core/layout/line/root_inline_box.h" -#include "third_party/blink/renderer/platform/wtf/casting.h" - -namespace blink { - -class SVGRootInlineBox final : public RootInlineBox { - public: - SVGRootInlineBox(LineLayoutItem block) : RootInlineBox(block) {} - - bool IsSVGRootInlineBox() const override { return true; } - - LayoutUnit VirtualLogicalHeight() const override { return logical_height_; } - void SetLogicalHeight(LayoutUnit height) { logical_height_ = height; } - - void Paint(const PaintInfo&, - const PhysicalOffset&, - LayoutUnit line_top, - LayoutUnit line_bottom) const override; - - void MarkDirty() override; - - void ComputePerCharacterLayoutInformation(); - - InlineBox* ClosestLeafChildForPosition(const PhysicalOffset&); - - bool NodeAtPoint(HitTestResult&, - const HitTestLocation&, - const PhysicalOffset& accumulated_offset, - LayoutUnit line_top, - LayoutUnit line_bottom) final; - - private: - void ReorderValueLists(); - gfx::RectF LayoutInlineBoxes(InlineBox&); - - LayoutUnit logical_height_; -}; - -template <> -struct DowncastTraits<SVGRootInlineBox> { - static bool AllowFrom(const InlineBox& box) { - return box.IsSVGRootInlineBox(); - } -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LINE_SVG_ROOT_INLINE_BOX_H_
diff --git a/third_party/blink/renderer/core/layout/svg/svg_content_container.cc b/third_party/blink/renderer/core/layout/svg/svg_content_container.cc index 40c946b..7a8126b 100644 --- a/third_party/blink/renderer/core/layout/svg/svg_content_container.cc +++ b/third_party/blink/renderer/core/layout/svg/svg_content_container.cc
@@ -7,11 +7,9 @@ #include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_foreign_object.h" #include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_container.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_image.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_marker.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_shape.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" #include "third_party/blink/renderer/core/layout/svg/svg_layout_support.h" #include "third_party/blink/renderer/core/layout/svg/svg_resources.h" @@ -56,10 +54,9 @@ if (layout_info.scale_factor_changed) { // If the screen scaling factor changed we need to update the text // metrics (note: this also happens for layoutSizeChanged=true). - if (auto* text = DynamicTo<LayoutSVGText>(child)) - text->SetNeedsTextMetricsUpdate(); - else if (auto* ng_text = DynamicTo<LayoutNGSVGText>(child)) + if (auto* ng_text = DynamicTo<LayoutNGSVGText>(child)) { ng_text->SetNeedsTextMetricsUpdate(); + } force_child_layout = true; } @@ -73,9 +70,6 @@ // the LayoutSVGShape to update its shape object if (auto* shape = DynamicTo<LayoutSVGShape>(child)) { shape->SetNeedsShapeUpdate(); - } else if (auto* text = DynamicTo<LayoutSVGText>(child)) { - text->SetNeedsTextMetricsUpdate(); - text->SetNeedsPositioningValuesUpdate(); } else if (auto* ng_text = DynamicTo<LayoutNGSVGText>(child)) { ng_text->SetNeedsTextMetricsUpdate(); } @@ -118,15 +112,11 @@ PhysicalOffset accumulated_offset; for (LayoutObject* child = children_.LastChild(); child; child = child->PreviousSibling()) { - if (auto* foreign_object = DynamicTo<LayoutSVGForeignObject>(child)) { + if (auto* foreign_object = DynamicTo<LayoutNGSVGForeignObject>(child)) { if (foreign_object->NodeAtPointFromSVG(result, location, - accumulated_offset, phase)) + accumulated_offset, phase)) { return true; - } else if (auto* ng_foreign_object = - DynamicTo<LayoutNGSVGForeignObject>(child)) { - if (ng_foreign_object->NodeAtPointFromSVG(result, location, - accumulated_offset, phase)) - return true; + } } else { if (child->NodeAtPoint(result, location, accumulated_offset, phase)) return true; @@ -153,8 +143,6 @@ if (object.IsSVGShape()) return !To<LayoutSVGShape>(object).IsShapeEmpty(); - if (object.IsSVGText()) - return To<LayoutSVGText>(object).IsObjectBoundingBoxValid(); if (const auto* ng_text = DynamicTo<LayoutNGSVGText>(object)) return ng_text->IsObjectBoundingBoxValid(); @@ -163,10 +151,9 @@ !svg_container->IsSVGHiddenContainer(); } - if (auto* foreign_object = DynamicTo<LayoutSVGForeignObject>(object)) + if (auto* foreign_object = DynamicTo<LayoutNGSVGForeignObject>(object)) { return foreign_object->IsObjectBoundingBoxValid(); - if (auto* ng_foreign_object = DynamicTo<LayoutNGSVGForeignObject>(object)) - return ng_foreign_object->IsObjectBoundingBoxValid(); + } if (object.IsSVGImage()) return To<LayoutSVGImage>(object).IsObjectBoundingBoxValid(); @@ -179,8 +166,9 @@ // The local-to-parent transform for <foreignObject> contains a zoom inverse, // so we need to apply zoom to the bounding box that we use for propagation to // be in the correct coordinate space. - if (object.IsSVGForeignObjectIncludingNG()) + if (object.IsSVGForeignObject()) { bounds.Scale(object.StyleRef().EffectiveZoom()); + } return bounds; }
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 2f45fba3..5a3fd42 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
@@ -217,8 +217,7 @@ // computing the transform to the SVG root is always what we want to do here. DCHECK_NE(ancestor, &object); DCHECK(object.IsSVGContainer() || object.IsSVGShape() || - object.IsSVGImage() || object.IsSVGText() || - object.IsSVGForeignObjectIncludingNG()); + object.IsSVGImage() || object.IsSVGForeignObject()); AffineTransform local_to_svg_root; const LayoutSVGRoot& svg_root = ComputeTransformToSVGRoot(object, local_to_svg_root, nullptr); @@ -288,8 +287,7 @@ gfx::RectF SVGLayoutSupport::ExtendTextBBoxWithStroke( const LayoutObject& layout_object, const gfx::RectF& text_bounds) { - DCHECK(layout_object.IsSVGText() || layout_object.IsNGSVGText() || - layout_object.IsSVGInline()); + DCHECK(layout_object.IsNGSVGText() || layout_object.IsSVGInline()); gfx::RectF bounds = text_bounds; const ComputedStyle& style = layout_object.StyleRef(); if (style.HasStroke()) { @@ -305,8 +303,7 @@ gfx::RectF SVGLayoutSupport::ComputeVisualRectForText( const LayoutObject& layout_object, const gfx::RectF& text_bounds) { - DCHECK(layout_object.IsSVGText() || layout_object.IsNGSVGText() || - layout_object.IsSVGInline()); + DCHECK(layout_object.IsNGSVGText() || layout_object.IsSVGInline()); gfx::RectF visual_rect = ExtendTextBBoxWithStroke(layout_object, text_bounds); if (const ShadowList* text_shadow = layout_object.StyleRef().TextShadow()) text_shadow->AdjustRectForShadow(visual_rect); @@ -456,7 +453,7 @@ // containers that could contain LayoutSVGTexts that are closer. for (LayoutObject* child = layout_object->SlowLastChild(); child; child = child->PreviousSibling()) { - if (child->IsSVGText() || child->IsNGSVGText()) { + if (child->IsNGSVGText()) { double distance = DistanceToChildLayoutObject(child, point); if (distance >= closest_text.distance) continue;
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 2a32dfe..40e3885 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
@@ -29,11 +29,11 @@ #include "third_party/blink/renderer/core/layout/svg/svg_layout_tree_as_text.h" #include "third_party/blink/renderer/core/css/properties/longhands.h" -#include "third_party/blink/renderer/core/layout/api/line_layout_svg_inline_text.h" #include "third_party/blink/renderer/core/layout/layout_tree_as_text.h" #include "third_party/blink/renderer/core/layout/line/inline_text_box.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_image.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_inline.h" +#include "third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_clipper.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_filter.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_linear_gradient.h" @@ -43,9 +43,6 @@ #include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_radial_gradient.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_root.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_shape.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_root_inline_box.h" #include "third_party/blink/renderer/core/layout/svg/svg_layout_support.h" #include "third_party/blink/renderer/core/layout/svg/svg_resources.h" #include "third_party/blink/renderer/core/paint/paint_layer.h" @@ -404,100 +401,6 @@ return ts; } -static void WriteLayoutSVGTextBox(WTF::TextStream& ts, - const LayoutSVGText& text) { - auto* box = To<SVGRootInlineBox>(text.FirstRootBox()); - if (!box) - return; - - // FIXME: Remove this hack, once the new text layout engine is completly - // landed. We want to preserve the old web test results for now. - ts << " contains 1 chunk(s)"; - - if (text.Parent() && (text.Parent()->ResolveColor(GetCSSPropertyColor()) != - text.ResolveColor(GetCSSPropertyColor()))) { - WriteNameValuePair( - ts, "color", - text.ResolveColor(GetCSSPropertyColor()).NameForLayoutTreeAsText()); - } -} - -static inline void WriteSVGInlineTextBox(WTF::TextStream& ts, - SVGInlineTextBox* text_box, - int indent) { - Vector<SVGTextFragment>& fragments = text_box->TextFragments(); - if (fragments.empty()) - return; - - LineLayoutSVGInlineText text_line_layout = - LineLayoutSVGInlineText(text_box->GetLineLayoutItem()); - - const ComputedStyle& style = text_line_layout.StyleRef(); - String text = text_box->GetLineLayoutItem().GetText(); - - unsigned fragments_size = fragments.size(); - for (unsigned i = 0; i < fragments_size; ++i) { - SVGTextFragment& fragment = fragments.at(i); - WriteIndent(ts, indent + 1); - - unsigned start_offset = fragment.character_offset; - unsigned end_offset = fragment.character_offset + fragment.length; - - // FIXME: Remove this hack, once the new text layout engine is completly - // landed. We want to preserve the old web test results for now. - ts << "chunk 1 "; - ETextAnchor anchor = style.TextAnchor(); - bool is_vertical_text = !style.IsHorizontalWritingMode(); - if (anchor == ETextAnchor::kMiddle) { - ts << "(middle anchor"; - if (is_vertical_text) - ts << ", vertical"; - ts << ") "; - } else if (anchor == ETextAnchor::kEnd) { - ts << "(end anchor"; - if (is_vertical_text) - ts << ", vertical"; - ts << ") "; - } else if (is_vertical_text) { - ts << "(vertical) "; - } - start_offset -= text_box->Start(); - end_offset -= text_box->Start(); - // </hack> - - ts << "text run " << i + 1 << " at (" << fragment.x << "," << fragment.y - << ")"; - ts << " startOffset " << start_offset << " endOffset " << end_offset; - if (is_vertical_text) - ts << " height " << fragment.height; - else - ts << " width " << fragment.width; - - if (!text_box->IsLeftToRightDirection() || text_box->DirOverride()) { - ts << (text_box->IsLeftToRightDirection() ? " LTR" : " RTL"); - if (text_box->DirOverride()) - ts << " override"; - } - - ts << ": " - << QuoteAndEscapeNonPrintables( - text.Substring(fragment.character_offset, fragment.length)) - << "\n"; - } -} - -static inline void WriteSVGInlineTextBoxes(WTF::TextStream& ts, - const LayoutText& text, - int indent) { - for (InlineTextBox* box : text.TextBoxes()) { - auto* svg_inline_text_box = DynamicTo<SVGInlineTextBox>(box); - if (!svg_inline_text_box) - continue; - - WriteSVGInlineTextBox(ts, svg_inline_text_box, indent); - } -} - static void WriteStandardPrefix(WTF::TextStream& ts, const LayoutObject& object, int indent) { @@ -655,15 +558,6 @@ WriteChildren(ts, root, indent); } -void WriteSVGText(WTF::TextStream& ts, const LayoutSVGText& text, int indent) { - WriteStandardPrefix(ts, text, indent); - WritePositionAndStyle(ts, text); - WriteLayoutSVGTextBox(ts, text); - ts << "\n"; - WriteResources(ts, text, indent); - WriteChildren(ts, text, indent); -} - void WriteSVGInline(WTF::TextStream& ts, const LayoutSVGInline& text, int indent) { @@ -680,7 +574,6 @@ WriteStandardPrefix(ts, text, indent); WritePositionAndStyle(ts, text); ts << "\n"; - WriteSVGInlineTextBoxes(ts, text, indent); } void WriteSVGImage(WTF::TextStream& ts,
diff --git a/third_party/blink/renderer/core/layout/svg/svg_layout_tree_as_text.h b/third_party/blink/renderer/core/layout/svg/svg_layout_tree_as_text.h index c322a891..d56bb1de 100644 --- a/third_party/blink/renderer/core/layout/svg/svg_layout_tree_as_text.h +++ b/third_party/blink/renderer/core/layout/svg/svg_layout_tree_as_text.h
@@ -36,7 +36,6 @@ class LayoutSVGInlineText; class LayoutSVGShape; class LayoutSVGRoot; -class LayoutSVGText; // functions used by the main LayoutTreeAsText code void Write(WTF::TextStream&, const LayoutSVGShape&, int indent); @@ -49,7 +48,6 @@ void WriteSVGInlineText(WTF::TextStream&, const LayoutSVGInlineText&, int indent); -void WriteSVGText(WTF::TextStream&, const LayoutSVGText&, int indent); void WriteSVGInline(WTF::TextStream&, const LayoutSVGInline&, int indent); void WriteResources(WTF::TextStream&, const LayoutObject&, int indent);
diff --git a/third_party/blink/renderer/core/layout/svg/svg_resources.cc b/third_party/blink/renderer/core/layout/svg/svg_resources.cc index be6c680..49486a8 100644 --- a/third_party/blink/renderer/core/layout/svg/svg_resources.cc +++ b/third_party/blink/renderer/core/layout/svg/svg_resources.cc
@@ -20,9 +20,9 @@ #include "third_party/blink/renderer/core/layout/svg/svg_resources.h" #include "base/ranges/algorithm.h" +#include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_filter.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_paint_server.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" #include "third_party/blink/renderer/core/paint/filter_effect_builder.h" #include "third_party/blink/renderer/core/style/computed_style.h" #include "third_party/blink/renderer/core/style/reference_clip_path_operation.h" @@ -52,8 +52,9 @@ // position is already baked into the transform, and we don't want to re-apply // the offset when, e.g., using "objectBoundingBox" for clipPathUnits. // Use the frame size since it should have the proper zoom applied. - if (layout_object.IsSVGForeignObjectIncludingNG()) + if (layout_object.IsSVGForeignObject()) { return gfx::RectF(gfx::SizeF(To<LayoutBox>(layout_object).Size())); + } // Text "sub-elements" (<tspan>, <textpath>, <a>) should use the entire // <text>s object bounding box rather then their own. @@ -61,7 +62,7 @@ const LayoutObject* obb_layout_object = &layout_object; if (layout_object.IsSVGInline()) { obb_layout_object = - LayoutSVGText::LocateLayoutSVGTextAncestor(&layout_object); + LayoutNGSVGText::LocateLayoutSVGTextAncestor(&layout_object); } DCHECK(obb_layout_object); return obb_layout_object->ObjectBoundingBox();
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_chunk_builder.cc b/third_party/blink/renderer/core/layout/svg/svg_text_chunk_builder.cc deleted file mode 100644 index 4c86f5b6..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_chunk_builder.cc +++ /dev/null
@@ -1,302 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "third_party/blink/renderer/core/layout/svg/svg_text_chunk_builder.h" - -#include "third_party/blink/renderer/core/layout/api/line_layout_svg_inline_text.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.h" -#include "third_party/blink/renderer/core/svg/svg_animated_length.h" -#include "third_party/blink/renderer/core/svg/svg_length_context.h" -#include "third_party/blink/renderer/core/svg/svg_text_content_element.h" - -namespace blink { - -float CalculateTextAnchorShift(const ComputedStyle& style, float length) { - bool is_ltr = style.IsLeftToRightDirection(); - switch (style.TextAnchor()) { - default: - NOTREACHED(); - [[fallthrough]]; - case ETextAnchor::kStart: - return is_ltr ? 0 : -length; - case ETextAnchor::kMiddle: - return -length / 2; - case ETextAnchor::kEnd: - return is_ltr ? -length : 0; - } -} - -namespace { - -bool NeedsTextAnchorAdjustment(const ComputedStyle& style) { - bool is_ltr = style.IsLeftToRightDirection(); - switch (style.TextAnchor()) { - default: - NOTREACHED(); - [[fallthrough]]; - case ETextAnchor::kStart: - return !is_ltr; - case ETextAnchor::kMiddle: - return true; - case ETextAnchor::kEnd: - return is_ltr; - } -} - -class ChunkLengthAccumulator { - public: - ChunkLengthAccumulator(bool is_vertical) - : num_characters_(0), length_(0), is_vertical_(is_vertical) {} - - typedef HeapVector<Member<SVGInlineTextBox>>::const_iterator - BoxListConstIterator; - - void ProcessRange(BoxListConstIterator box_start, - BoxListConstIterator box_end); - void Reset() { - num_characters_ = 0; - length_ = 0; - } - - float length() const { return length_; } - unsigned NumCharacters() const { return num_characters_; } - - private: - unsigned num_characters_; - float length_; - const bool is_vertical_; -}; - -void ChunkLengthAccumulator::ProcessRange(BoxListConstIterator box_start, - BoxListConstIterator box_end) { - SVGTextFragment* last_fragment = nullptr; - for (auto* box_iter = box_start; box_iter != box_end; ++box_iter) { - for (SVGTextFragment& fragment : (*box_iter)->TextFragments()) { - num_characters_ += fragment.length; - - if (is_vertical_) - length_ += fragment.height; - else - length_ += fragment.width; - - if (!last_fragment) { - last_fragment = &fragment; - continue; - } - - // Respect gap between chunks. - if (is_vertical_) - length_ += fragment.y - (last_fragment->y + last_fragment->height); - else - length_ += fragment.x - (last_fragment->x + last_fragment->width); - - last_fragment = &fragment; - } - } -} - -} // namespace - -SVGTextChunkBuilder::SVGTextChunkBuilder() = default; - -void SVGTextChunkBuilder::ProcessTextChunks( - const HeapVector<Member<SVGInlineTextBox>>& line_layout_boxes) { - if (line_layout_boxes.empty()) - return; - - bool found_start = false; - auto const* box_iter = line_layout_boxes.begin(); - auto const* end_box = line_layout_boxes.end(); - auto const* chunk_start_box = box_iter; - for (; box_iter != end_box; ++box_iter) { - if (!(*box_iter)->StartsNewTextChunk()) - continue; - - if (!found_start) { - found_start = true; - } else { - DCHECK_NE(box_iter, chunk_start_box); - HandleTextChunk(chunk_start_box, box_iter); - } - chunk_start_box = box_iter; - } - - if (!found_start) - return; - - if (box_iter != chunk_start_box) - HandleTextChunk(chunk_start_box, box_iter); -} - -SVGTextPathChunkBuilder::SVGTextPathChunkBuilder() - : SVGTextChunkBuilder(), total_length_(0), total_characters_(0) {} - -void SVGTextPathChunkBuilder::HandleTextChunk(BoxListConstIterator box_start, - BoxListConstIterator box_end) { - const ComputedStyle& style = (*box_start)->GetLineLayoutItem().StyleRef(); - - ChunkLengthAccumulator length_accumulator(!style.IsHorizontalWritingMode()); - length_accumulator.ProcessRange(box_start, box_end); - - total_length_ += length_accumulator.length(); - total_characters_ += length_accumulator.NumCharacters(); -} - -static float ComputeTextLengthBias(const SVGTextFragment& fragment, - float scale) { - float initial_position = fragment.is_vertical ? fragment.y : fragment.x; - return initial_position + scale * -initial_position; -} - -void SVGTextChunkBuilder::HandleTextChunk(BoxListConstIterator box_start, - BoxListConstIterator box_end) { - DCHECK(*box_start); - - const LineLayoutSVGInlineText text_line_layout = - LineLayoutSVGInlineText((*box_start)->GetLineLayoutItem()); - const ComputedStyle& style = text_line_layout.StyleRef(); - - // Handle 'lengthAdjust' property. - float desired_text_length = 0; - SVGLengthAdjustType length_adjust = kSVGLengthAdjustUnknown; - if (SVGTextContentElement* text_content_element = - SVGTextContentElement::ElementFromLineLayoutItem( - text_line_layout.Parent())) { - length_adjust = text_content_element->lengthAdjust()->CurrentEnumValue(); - - SVGLengthContext length_context(text_content_element); - if (text_content_element->TextLengthIsSpecifiedByUser()) - desired_text_length = - text_content_element->textLength()->CurrentValue()->Value( - length_context); - else - desired_text_length = 0; - } - - bool process_text_length = desired_text_length > 0; - bool process_text_anchor = NeedsTextAnchorAdjustment(style); - if (!process_text_anchor && !process_text_length) - return; - - bool is_vertical_text = !style.IsHorizontalWritingMode(); - - // Calculate absolute length of whole text chunk (starting from text box - // 'start', spanning 'length' text boxes). - ChunkLengthAccumulator length_accumulator(is_vertical_text); - length_accumulator.ProcessRange(box_start, box_end); - - if (process_text_length) { - float chunk_length = length_accumulator.length(); - if (length_adjust == kSVGLengthAdjustSpacing) { - float text_length_shift = 0; - if (length_accumulator.NumCharacters() > 1) { - text_length_shift = desired_text_length - chunk_length; - text_length_shift /= length_accumulator.NumCharacters() - 1; - } - unsigned at_character = 0; - for (auto* box_iter = box_start; box_iter != box_end; ++box_iter) { - Vector<SVGTextFragment>& fragments = (*box_iter)->TextFragments(); - if (fragments.empty()) - continue; - ProcessTextLengthSpacingCorrection(is_vertical_text, text_length_shift, - fragments, at_character); - } - - // Fragments have been adjusted, we have to recalculate the chunk - // length, to be able to apply the text-anchor shift. - if (process_text_anchor) { - length_accumulator.Reset(); - length_accumulator.ProcessRange(box_start, box_end); - } - } else { - DCHECK_EQ(length_adjust, kSVGLengthAdjustSpacingAndGlyphs); - float text_length_scale = desired_text_length / chunk_length; - float text_length_bias = 0; - - bool found_first_fragment = false; - for (auto* box_iter = box_start; box_iter != box_end; ++box_iter) { - SVGInlineTextBox* text_box = *box_iter; - Vector<SVGTextFragment>& fragments = text_box->TextFragments(); - if (fragments.empty()) - continue; - - if (!found_first_fragment) { - found_first_fragment = true; - text_length_bias = - ComputeTextLengthBias(fragments.front(), text_length_scale); - } - - ApplyTextLengthScaleAdjustment(text_length_scale, text_length_bias, - fragments); - } - } - } - - if (!process_text_anchor) - return; - - float text_anchor_shift = - CalculateTextAnchorShift(style, length_accumulator.length()); - for (auto* box_iter = box_start; box_iter != box_end; ++box_iter) { - Vector<SVGTextFragment>& fragments = (*box_iter)->TextFragments(); - if (fragments.empty()) - continue; - ProcessTextAnchorCorrection(is_vertical_text, text_anchor_shift, fragments); - } -} - -void SVGTextChunkBuilder::ProcessTextLengthSpacingCorrection( - bool is_vertical_text, - float text_length_shift, - Vector<SVGTextFragment>& fragments, - unsigned& at_character) { - for (SVGTextFragment& fragment : fragments) { - if (is_vertical_text) - fragment.y += text_length_shift * at_character; - else - fragment.x += text_length_shift * at_character; - - at_character += fragment.length; - } -} - -void SVGTextChunkBuilder::ApplyTextLengthScaleAdjustment( - float text_length_scale, - float text_length_bias, - Vector<SVGTextFragment>& fragments) { - for (SVGTextFragment& fragment : fragments) { - DCHECK_EQ(fragment.length_adjust_scale, 1u); - fragment.length_adjust_scale = text_length_scale; - fragment.length_adjust_bias = text_length_bias; - } -} - -void SVGTextChunkBuilder::ProcessTextAnchorCorrection( - bool is_vertical_text, - float text_anchor_shift, - Vector<SVGTextFragment>& fragments) { - for (SVGTextFragment& fragment : fragments) { - if (is_vertical_text) - fragment.y += text_anchor_shift; - else - fragment.x += text_anchor_shift; - } -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_chunk_builder.h b/third_party/blink/renderer/core/layout/svg/svg_text_chunk_builder.h deleted file mode 100644 index 97e040e..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_chunk_builder.h +++ /dev/null
@@ -1,97 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_CHUNK_BUILDER_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_CHUNK_BUILDER_H_ - -#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h" -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" -#include "third_party/blink/renderer/platform/wtf/vector.h" - -namespace blink { - -class ComputedStyle; -class SVGInlineTextBox; -struct SVGTextFragment; - -// SVGTextChunkBuilder performs the third layout phase for SVG text. -// -// Phase one built the layout information from the SVG DOM stored in the -// LayoutSVGInlineText objects (SVGTextLayoutAttributes). -// Phase two performed the actual per-character layout, computing the final -// positions for each character, stored in the SVGInlineTextBox objects -// (SVGTextFragment). -// Phase three performs all modifications that have to be applied to each -// individual text chunk (text-anchor & textLength). - -class SVGTextChunkBuilder { - STACK_ALLOCATED(); - - public: - SVGTextChunkBuilder(); - SVGTextChunkBuilder(const SVGTextChunkBuilder&) = delete; - SVGTextChunkBuilder& operator=(const SVGTextChunkBuilder&) = delete; - - void ProcessTextChunks(const HeapVector<Member<SVGInlineTextBox>>&); - - protected: - typedef HeapVector<Member<SVGInlineTextBox>>::const_iterator - BoxListConstIterator; - - virtual void HandleTextChunk(BoxListConstIterator box_start, - BoxListConstIterator box_end); - - private: - void ProcessTextLengthSpacingCorrection(bool is_vertical_text, - float text_length_shift, - Vector<SVGTextFragment>&, - unsigned& at_character); - void ApplyTextLengthScaleAdjustment(float text_length_scale, - float text_length_bias, - Vector<SVGTextFragment>&); - void ProcessTextAnchorCorrection(bool is_vertical_text, - float text_anchor_shift, - Vector<SVGTextFragment>&); -}; - -class SVGTextPathChunkBuilder final : public SVGTextChunkBuilder { - STACK_ALLOCATED(); - - public: - SVGTextPathChunkBuilder(); - SVGTextPathChunkBuilder(const SVGTextPathChunkBuilder&) = delete; - SVGTextPathChunkBuilder& operator=(const SVGTextPathChunkBuilder&) = delete; - - float TotalLength() const { return total_length_; } - unsigned TotalCharacters() const { return total_characters_; } - - private: - void HandleTextChunk(BoxListConstIterator box_start, - BoxListConstIterator box_end) override; - - float total_length_; - unsigned total_characters_; -}; - -// Compute the "shift" induced by the 'text-anchor' property. -float CalculateTextAnchorShift(const ComputedStyle&, float length); - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_CHUNK_BUILDER_H_
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_fragment.h b/third_party/blink/renderer/core/layout/svg/svg_text_fragment.h deleted file mode 100644 index 5d6e19ac..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_fragment.h +++ /dev/null
@@ -1,173 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_FRAGMENT_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_FRAGMENT_H_ - -#include "third_party/blink/renderer/core/layout/line/glyph_overflow.h" -#include "third_party/blink/renderer/platform/transforms/affine_transform.h" -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" - -namespace blink { - -// A SVGTextFragment describes a text fragment of a LayoutSVGInlineText which -// can be laid out at once. -struct SVGTextFragment { - DISALLOW_NEW(); - SVGTextFragment() - : character_offset(0), - metrics_list_offset(0), - length(0), - is_text_on_path(false), - is_vertical(false), - x(0), - y(0), - width(0), - height(0), - length_adjust_scale(1), - length_adjust_bias(0) {} - - enum TransformType { - kTransformRespectingTextLength, - kTransformIgnoringTextLength - }; - - gfx::RectF BoundingBox(float baseline) const { - gfx::RectF fragment_rect(x, y - baseline, width, height); - if (!IsTransformed()) - return fragment_rect; - return BuildNormalFragmentTransform().MapRect(fragment_rect); - } - - gfx::RectF OverflowBoundingBox(float baseline) const { - gfx::RectF fragment_rect( - x - glyph_overflow.left, y - baseline - glyph_overflow.top, - width + glyph_overflow.left + glyph_overflow.right, - height + glyph_overflow.top + glyph_overflow.bottom); - if (!IsTransformed()) - return fragment_rect; - return BuildNormalFragmentTransform().MapRect(fragment_rect); - } - - gfx::QuadF BoundingQuad(float baseline) const { - gfx::QuadF fragment_quad(gfx::RectF(x, y - baseline, width, height)); - if (!IsTransformed()) - return fragment_quad; - return BuildNormalFragmentTransform().MapQuad(fragment_quad); - } - - AffineTransform BuildFragmentTransform( - TransformType type = kTransformRespectingTextLength) const { - if (type == kTransformIgnoringTextLength) { - AffineTransform result = transform; - TransformAroundOrigin(result); - return result; - } - return BuildNormalFragmentTransform(); - } - - bool AffectedByTextLength() const { return length_adjust_scale != 1; } - - bool IsTransformed() const { - return AffectedByTextLength() || !transform.IsIdentity(); - } - - // The first laid out character starts at LayoutSVGInlineText::characters() + - // characterOffset. - unsigned character_offset; - unsigned metrics_list_offset; - unsigned length : 30; - unsigned is_text_on_path : 1; - unsigned is_vertical : 1; - - float x; - float y; - float width; - float height; - - GlyphOverflow glyph_overflow; - - // Includes rotation/glyph-orientation-(horizontal|vertical) transforms, as - // well as orientation related shifts - // (see SVGTextLayoutEngine, which builds this transformation). - AffineTransform transform; - - // Contains lengthAdjust related transformations, which are not allowed to - // influence the SVGTextQuery code. - float length_adjust_scale; - float length_adjust_bias; - - private: - AffineTransform BuildNormalFragmentTransform() const { - if (is_text_on_path) - return BuildTransformForTextOnPath(); - return BuildTransformForTextOnLine(); - } - - void TransformAroundOrigin(AffineTransform& result) const { - // Returns (translate(x, y) * result) * translate(-x, -y). - result.SetE(result.E() + x); - result.SetF(result.F() + y); - result.Translate(-x, -y); - } - - AffineTransform BuildTransformForTextOnPath() const { - // For text-on-path layout, multiply the transform with the - // lengthAdjustTransform before orienting the resulting transform. - // T(x,y) * M(transform) * M(lengthAdjust) * T(-x,-y) - AffineTransform result = !AffectedByTextLength() - ? transform - : transform * LengthAdjustTransform(); - if (!result.IsIdentity()) - TransformAroundOrigin(result); - return result; - } - - AffineTransform LengthAdjustTransform() const { - AffineTransform result; - if (!AffectedByTextLength()) - return result; - // Load a transform assuming horizontal direction, then swap if vertical. - result.SetMatrix(length_adjust_scale, 0, 0, 1, length_adjust_bias, 0); - if (is_vertical) { - result.SetD(result.A()); - result.SetA(1); - result.SetF(result.E()); - result.SetE(0); - } - return result; - } - - AffineTransform BuildTransformForTextOnLine() const { - // For text-on-line layout, orient the transform first, then multiply - // the lengthAdjustTransform with the oriented transform. - // M(lengthAdjust) * T(x,y) * M(transform) * T(-x,-y) - if (transform.IsIdentity()) - return LengthAdjustTransform(); - - AffineTransform result = transform; - TransformAroundOrigin(result); - result.PostConcat(LengthAdjustTransform()); - return result; - } -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_FRAGMENT_H_
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_layout_attributes_builder.cc b/third_party/blink/renderer/core/layout/svg/svg_text_layout_attributes_builder.cc deleted file mode 100644 index 1e7c61999..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_layout_attributes_builder.cc +++ /dev/null
@@ -1,254 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "third_party/blink/renderer/core/layout/svg/svg_text_layout_attributes_builder.h" - -#include "third_party/blink/renderer/core/layout/api/line_layout_svg_inline_text.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_inline.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" -#include "third_party/blink/renderer/core/svg/svg_animated_length_list.h" -#include "third_party/blink/renderer/core/svg/svg_animated_number_list.h" -#include "third_party/blink/renderer/core/svg/svg_length_context.h" -#include "third_party/blink/renderer/core/svg/svg_length_list.h" -#include "third_party/blink/renderer/core/svg/svg_number_list.h" -#include "third_party/blink/renderer/core/svg/svg_text_positioning_element.h" - -namespace blink { - -namespace { - -void UpdateLayoutAttributes(LayoutSVGInlineText& text, - unsigned& value_list_position, - const SVGCharacterDataMap& all_characters_map) { - SVGCharacterDataMap& character_data_map = text.CharacterDataMap(); - character_data_map.clear(); - - LineLayoutSVGInlineText text_line_layout(&text); - for (SVGInlineTextMetricsIterator iterator(text_line_layout); - !iterator.IsAtEnd(); iterator.Next()) { - if (iterator.Metrics().IsEmpty()) - continue; - - auto it = all_characters_map.find(value_list_position + 1); - if (it != all_characters_map.end()) - character_data_map.Set(iterator.CharacterOffset() + 1, it->value); - - // Increase the position in the value/attribute list with one for each - // "character unit" (that will be displayed.) - value_list_position++; - } -} - -} // namespace - -SVGTextLayoutAttributesBuilder::SVGTextLayoutAttributesBuilder( - LayoutSVGText& text_root) - : text_root_(text_root), character_count_(0) {} - -void SVGTextLayoutAttributesBuilder::BuildLayoutAttributes() { - character_data_map_.clear(); - - if (text_positions_.empty()) { - character_count_ = 0; - CollectTextPositioningElements(text_root_); - } - - if (!character_count_) - return; - - BuildCharacterDataMap(text_root_); - - unsigned value_list_position = 0; - LayoutObject* child = text_root_.FirstChild(); - while (child) { - if (child->IsSVGInlineText()) { - UpdateLayoutAttributes(To<LayoutSVGInlineText>(*child), - value_list_position, character_data_map_); - } else if (child->IsSVGInline()) { - // Visit children of text content elements. - if (LayoutObject* inline_child = - To<LayoutSVGInline>(child)->FirstChild()) { - child = inline_child; - continue; - } - } - child = child->NextInPreOrderAfterChildren(&text_root_); - } -} - -static inline unsigned CountCharactersInTextNode( - const LayoutSVGInlineText& text) { - unsigned num_characters = 0; - for (const SVGTextMetrics& metrics : text.MetricsList()) { - if (metrics.IsEmpty()) - continue; - num_characters++; - } - return num_characters; -} - -static SVGTextPositioningElement* PositioningElementFromLayoutObject( - LayoutObject& layout_object) { - DCHECK(layout_object.IsSVGText() || layout_object.IsSVGInline()); - - Node* node = layout_object.GetNode(); - DCHECK(node); - DCHECK(node->IsSVGElement()); - - return DynamicTo<SVGTextPositioningElement>(node); -} - -void SVGTextLayoutAttributesBuilder::CollectTextPositioningElements( - LayoutBoxModelObject& start) { - DCHECK(!start.IsSVGText() || text_positions_.empty()); - SVGTextPositioningElement* element = - PositioningElementFromLayoutObject(start); - unsigned at_position = text_positions_.size(); - if (element) - text_positions_.push_back(TextPosition(element, character_count_)); - - for (LayoutObject* child = start.SlowFirstChild(); child; - child = child->NextSibling()) { - if (child->IsSVGInlineText()) { - character_count_ += - CountCharactersInTextNode(To<LayoutSVGInlineText>(*child)); - continue; - } - - if (child->IsSVGInline()) { - CollectTextPositioningElements(To<LayoutSVGInline>(*child)); - continue; - } - } - - if (!element) - return; - - // Compute the length of the subtree after all children have been visited. - TextPosition& position = text_positions_[at_position]; - DCHECK(!position.length); - position.length = character_count_ - position.start; -} - -void SVGTextLayoutAttributesBuilder::BuildCharacterDataMap( - LayoutSVGText& text_root) { - // Fill character data map using text positioning elements in top-down order. - for (const TextPosition& position : text_positions_) - FillCharacterDataMap(position); - - // Handle x/y default attributes. - SVGCharacterData& data = - character_data_map_.insert(1, SVGCharacterData()).stored_value->value; - if (!data.HasX()) - data.x = 0; - if (!data.HasY()) - data.y = 0; -} - -namespace { - -class AttributeListsIterator { - STACK_ALLOCATED(); - - public: - AttributeListsIterator(SVGTextPositioningElement*); - - bool HasAttributes() const { - return x_list_remaining_ || y_list_remaining_ || dx_list_remaining_ || - dy_list_remaining_ || rotate_list_remaining_; - } - void UpdateCharacterData(wtf_size_t index, SVGCharacterData&); - - private: - SVGLengthContext length_context_; - const SVGLengthList* x_list_; - unsigned x_list_remaining_; - const SVGLengthList* y_list_; - unsigned y_list_remaining_; - const SVGLengthList* dx_list_; - unsigned dx_list_remaining_; - const SVGLengthList* dy_list_; - unsigned dy_list_remaining_; - const SVGNumberList* rotate_list_; - unsigned rotate_list_remaining_; -}; - -AttributeListsIterator::AttributeListsIterator( - SVGTextPositioningElement* element) - : length_context_(element), - x_list_(element->x()->CurrentValue()), - x_list_remaining_(x_list_->length()), - y_list_(element->y()->CurrentValue()), - y_list_remaining_(y_list_->length()), - dx_list_(element->dx()->CurrentValue()), - dx_list_remaining_(dx_list_->length()), - dy_list_(element->dy()->CurrentValue()), - dy_list_remaining_(dy_list_->length()), - rotate_list_(element->rotate()->CurrentValue()), - rotate_list_remaining_(rotate_list_->length()) {} - -inline void AttributeListsIterator::UpdateCharacterData( - wtf_size_t index, - SVGCharacterData& data) { - if (x_list_remaining_) { - data.x = x_list_->at(index)->Value(length_context_); - --x_list_remaining_; - } - if (y_list_remaining_) { - data.y = y_list_->at(index)->Value(length_context_); - --y_list_remaining_; - } - if (dx_list_remaining_) { - data.dx = dx_list_->at(index)->Value(length_context_); - --dx_list_remaining_; - } - if (dy_list_remaining_) { - data.dy = dy_list_->at(index)->Value(length_context_); - --dy_list_remaining_; - } - if (rotate_list_remaining_) { - data.rotate = - rotate_list_->at(std::min(index, rotate_list_->length() - 1))->Value(); - // The last rotation value spans the whole scope. - if (rotate_list_remaining_ > 1) - --rotate_list_remaining_; - } -} - -} // namespace - -void SVGTextLayoutAttributesBuilder::FillCharacterDataMap( - const TextPosition& position) { - AttributeListsIterator attr_lists(position.element); - for (wtf_size_t i = 0; attr_lists.HasAttributes() && i < position.length; - ++i) { - SVGCharacterData& data = - character_data_map_.insert(position.start + i + 1, SVGCharacterData()) - .stored_value->value; - attr_lists.UpdateCharacterData(i, data); - } -} - -void SVGTextLayoutAttributesBuilder::TextPosition::Trace( - blink::Visitor* visitor) const { - visitor->Trace(element); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_layout_attributes_builder.h b/third_party/blink/renderer/core/layout/svg/svg_text_layout_attributes_builder.h deleted file mode 100644 index d01ef39c..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_layout_attributes_builder.h +++ /dev/null
@@ -1,89 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_LAYOUT_ATTRIBUTES_BUILDER_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_LAYOUT_ATTRIBUTES_BUILDER_H_ - -#include "third_party/blink/renderer/core/layout/svg/svg_character_data.h" -#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h" -#include "third_party/blink/renderer/platform/heap/garbage_collected.h" -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" -#include "third_party/blink/renderer/platform/wtf/vector.h" - -namespace blink { - -class LayoutBoxModelObject; -class LayoutSVGText; -class SVGTextPositioningElement; - -// SVGTextLayoutAttributesBuilder performs the first layout phase for SVG text. -// -// It extracts the x/y/dx/dy/rotate values from the SVGTextPositioningElements -// in the DOM. These values are propagated to the corresponding -// LayoutSVGInlineText layoutObjects. -// The first layout phase only extracts the relevant information needed in -// LayoutBlockFlowLine to create the InlineBox tree based on text chunk -// boundaries & BiDi information. -// The second layout phase is carried out by SVGTextLayoutEngine. -class SVGTextLayoutAttributesBuilder { - STACK_ALLOCATED(); - - public: - explicit SVGTextLayoutAttributesBuilder(LayoutSVGText&); - SVGTextLayoutAttributesBuilder(const SVGTextLayoutAttributesBuilder&) = - delete; - SVGTextLayoutAttributesBuilder& operator=( - const SVGTextLayoutAttributesBuilder&) = delete; - - void BuildLayoutAttributes(); - - struct TextPosition { - DISALLOW_NEW(); - - public: - TextPosition(SVGTextPositioningElement* new_element = nullptr, - unsigned new_start = 0, - unsigned new_length = 0) - : element(new_element), start(new_start), length(new_length) {} - - void Trace(Visitor*) const; - - Member<SVGTextPositioningElement> element; - unsigned start; - unsigned length; - }; - - private: - void BuildCharacterDataMap(LayoutSVGText&); - void BuildLayoutAttributes(LayoutSVGText&) const; - void CollectTextPositioningElements(LayoutBoxModelObject&); - void FillCharacterDataMap(const TextPosition&); - - LayoutSVGText& text_root_; - unsigned character_count_; - HeapVector<TextPosition> text_positions_; - SVGCharacterDataMap character_data_map_; -}; - -} // namespace blink - -WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS( - blink::SVGTextLayoutAttributesBuilder::TextPosition) - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_LAYOUT_ATTRIBUTES_BUILDER_H_
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine.cc b/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine.cc deleted file mode 100644 index d4149845d..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine.cc +++ /dev/null
@@ -1,572 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "third_party/blink/renderer/core/layout/svg/svg_text_layout_engine.h" - -#include "base/auto_reset.h" -#include "third_party/blink/renderer/core/frame/web_feature.h" -#include "third_party/blink/renderer/core/layout/api/line_layout_api_shim.h" -#include "third_party/blink/renderer/core/layout/api/line_layout_svg_text_path.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_flow_box.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.h" -#include "third_party/blink/renderer/core/layout/svg/svg_text_chunk_builder.h" -#include "third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_baseline.h" -#include "third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_spacing.h" -#include "third_party/blink/renderer/core/svg/svg_animated_length.h" -#include "third_party/blink/renderer/core/svg/svg_element.h" -#include "third_party/blink/renderer/core/svg/svg_length_context.h" -#include "third_party/blink/renderer/core/svg/svg_text_content_element.h" -#include "third_party/blink/renderer/platform/instrumentation/use_counter.h" - -namespace blink { - -SVGTextLayoutEngine::SVGTextLayoutEngine( - const HeapVector<Member<LayoutSVGInlineText>>& descendant_text_nodes) - : descendant_text_nodes_(descendant_text_nodes), - current_logical_text_node_index_(0), - logical_character_offset_(0), - logical_metrics_list_offset_(0), - is_vertical_text_(false), - in_path_layout_(false), - text_length_spacing_in_effect_(false), - last_text_box_was_in_text_path_(false), - text_path_(nullptr), - text_path_current_offset_(0), - text_path_displacement_(0), - text_path_spacing_(0), - text_path_scaling_(1) { - DCHECK(!descendant_text_nodes_.empty()); -} - -SVGTextLayoutEngine::~SVGTextLayoutEngine() = default; - -bool SVGTextLayoutEngine::SetCurrentTextPosition(const SVGCharacterData& data) { - bool has_x = data.HasX(); - if (has_x) - text_position_.set_x(data.x); - - bool has_y = data.HasY(); - if (has_y) - text_position_.set_y(data.y); - - // If there's an absolute x/y position available, it marks the beginning of - // a new position along the path. - if (in_path_layout_) { - // TODO(fs): If a new chunk (== absolute position) is defined while in - // path layout mode, alignment should be based on that chunk and not - // the path as a whole. (Re: the addition of m_textPathStartOffset - // below.) - if (is_vertical_text_) { - if (has_y) - text_path_current_offset_ = data.y + text_path_start_offset_; - } else { - if (has_x) - text_path_current_offset_ = data.x + text_path_start_offset_; - } - } else if ((!has_x || !has_y) && last_text_box_was_in_text_path_) { - UseCounter::Count(descendant_text_nodes_[0]->GetDocument(), - WebFeature::kSVGTextHangingFromPath); - last_text_box_was_in_text_path_ = false; - } - return has_x || has_y; -} - -void SVGTextLayoutEngine::AdvanceCurrentTextPosition(float glyph_advance) { - // TODO(fs): m_textPathCurrentOffset should preferably also be updated - // here, but that requires a bit more untangling yet. - if (is_vertical_text_) - text_position_.set_y(text_position_.y() + glyph_advance); - else - text_position_.set_x(text_position_.x() + glyph_advance); -} - -bool SVGTextLayoutEngine::ApplyRelativePositionAdjustmentsIfNeeded( - const SVGCharacterData& data) { - gfx::Vector2dF delta; - bool has_dx = data.HasDx(); - if (has_dx) - delta.set_x(data.dx); - - bool has_dy = data.HasDy(); - if (has_dy) - delta.set_y(data.dy); - - // Apply dx/dy value adjustments to current text position, if needed. - text_position_ += delta; - - if (in_path_layout_) { - if (is_vertical_text_) - delta.Transpose(); - - text_path_current_offset_ += delta.x(); - text_path_displacement_ += delta.y(); - } - return has_dx || has_dy; -} - -void SVGTextLayoutEngine::ComputeCurrentFragmentMetrics( - SVGInlineTextBox* text_box) { - LineLayoutSVGInlineText text_line_layout = - LineLayoutSVGInlineText(text_box->GetLineLayoutItem()); - TextRun run = text_box->ConstructTextRun(text_line_layout.StyleRef(), - current_text_fragment_); - - float scaling_factor = text_line_layout.ScalingFactor(); - DCHECK(scaling_factor); - const Font& scaled_font = text_line_layout.ScaledFont(); - gfx::RectF glyph_overflow_bounds; - - const SimpleFontData* font_data = scaled_font.PrimaryFont(); - DCHECK(font_data); - if (!font_data) - return; - - float width = scaled_font.Width(run, nullptr, &glyph_overflow_bounds); - current_text_fragment_.glyph_overflow.SetFromBounds(glyph_overflow_bounds, - scaled_font, width); - current_text_fragment_.glyph_overflow.top /= scaling_factor; - current_text_fragment_.glyph_overflow.left /= scaling_factor; - current_text_fragment_.glyph_overflow.right /= scaling_factor; - current_text_fragment_.glyph_overflow.bottom /= scaling_factor; - - float height = font_data->GetFontMetrics().FloatHeight(); - current_text_fragment_.height = height / scaling_factor; - current_text_fragment_.width = width / scaling_factor; -} - -void SVGTextLayoutEngine::RecordTextFragment(SVGInlineTextBox* text_box) { - DCHECK(!current_text_fragment_.length); - - // Figure out length of fragment. - current_text_fragment_.length = visual_metrics_iterator_.CharacterOffset() - - current_text_fragment_.character_offset; - - // Figure out fragment metrics. - ComputeCurrentFragmentMetrics(text_box); - - text_box->TextFragments().push_back(current_text_fragment_); - current_text_fragment_ = SVGTextFragment(); -} - -void SVGTextLayoutEngine::BeginTextPathLayout(SVGInlineFlowBox* flow_box) { - // Build text chunks for all <textPath> children, using the line layout - // algorithm. This is needeed as text-anchor is just an additional startOffset - // for text paths. - SVGTextLayoutEngine line_layout(descendant_text_nodes_); - line_layout.text_length_spacing_in_effect_ = text_length_spacing_in_effect_; - line_layout.LayoutCharactersInTextBoxes(flow_box); - - in_path_layout_ = true; - LineLayoutSVGTextPath text_path = - LineLayoutSVGTextPath(flow_box->GetLineLayoutItem()); - - text_path_ = text_path.LayoutPath(); - if (!text_path_) - return; - text_path_start_offset_ = text_path_->StartOffset(); - - SVGTextPathChunkBuilder text_path_chunk_layout_builder; - text_path_chunk_layout_builder.ProcessTextChunks( - line_layout.line_layout_boxes_); - - // Handle 'textLength' adjustments. - SVGLengthAdjustType length_adjust = kSVGLengthAdjustUnknown; - float desired_text_length = 0; - - if (SVGTextContentElement* text_content_element = - SVGTextContentElement::ElementFromLineLayoutItem(text_path)) { - SVGLengthContext length_context(text_content_element); - length_adjust = text_content_element->lengthAdjust()->CurrentEnumValue(); - if (text_content_element->TextLengthIsSpecifiedByUser()) - desired_text_length = - text_content_element->textLength()->CurrentValue()->Value( - length_context); - else - desired_text_length = 0; - } - - float text_path_content_length = text_path_chunk_layout_builder.TotalLength(); - if (desired_text_length) { - if (length_adjust == kSVGLengthAdjustSpacing) { - text_path_spacing_ = 0; - if (text_path_chunk_layout_builder.TotalCharacters() > 1) { - text_path_spacing_ = desired_text_length - text_path_content_length; - text_path_spacing_ /= - text_path_chunk_layout_builder.TotalCharacters() - 1; - } - } else { - text_path_scaling_ = desired_text_length / text_path_content_length; - } - text_path_content_length = desired_text_length; - } - - // Perform text-anchor adjustment. - float text_anchor_shift = - CalculateTextAnchorShift(text_path.StyleRef(), text_path_content_length); - text_path_start_offset_ += text_anchor_shift; - text_path_current_offset_ = text_path_start_offset_; -} - -void SVGTextLayoutEngine::EndTextPathLayout() { - in_path_layout_ = false; - text_path_ = nullptr; - text_path_start_offset_ = 0; - text_path_current_offset_ = 0; - text_path_spacing_ = 0; - text_path_scaling_ = 1; -} - -void SVGTextLayoutEngine::LayoutInlineTextBox(SVGInlineTextBox* text_box) { - DCHECK(text_box); - - LineLayoutSVGInlineText text_line_layout = - LineLayoutSVGInlineText(text_box->GetLineLayoutItem()); - DCHECK(text_line_layout.Parent()); - DCHECK(text_line_layout.Parent().GetNode()); - DCHECK(text_line_layout.Parent().GetNode()->IsSVGElement()); - - const ComputedStyle& style = text_line_layout.StyleRef(); - - text_box->ClearTextFragments(); - is_vertical_text_ = !style.IsHorizontalWritingMode(); - LayoutTextOnLineOrPath(text_box, text_line_layout, style); - - if (in_path_layout_) - return; - - line_layout_boxes_.push_back(text_box); -} - -static bool DefinesTextLengthWithSpacing(const InlineFlowBox* start) { - SVGTextContentElement* text_content_element = - SVGTextContentElement::ElementFromLineLayoutItem( - start->GetLineLayoutItem()); - return text_content_element && - text_content_element->lengthAdjust()->CurrentEnumValue() == - kSVGLengthAdjustSpacing && - text_content_element->TextLengthIsSpecifiedByUser(); -} - -void SVGTextLayoutEngine::LayoutCharactersInTextBoxes(InlineFlowBox* start) { - bool text_length_spacing_in_effect = - text_length_spacing_in_effect_ || DefinesTextLengthWithSpacing(start); - base::AutoReset<bool> text_length_spacing_scope( - &text_length_spacing_in_effect_, text_length_spacing_in_effect); - last_text_box_was_in_text_path_ = false; - - for (InlineBox* child = start->FirstChild(); child; - child = child->NextOnLine()) { - if (auto* svg_inline_text_box = DynamicTo<SVGInlineTextBox>(child)) { - DCHECK(child->GetLineLayoutItem().IsSVGInlineText()); - LayoutInlineTextBox(svg_inline_text_box); - last_text_box_was_in_text_path_ = false; - } else { - // Skip generated content. - Node* node = child->GetLineLayoutItem().GetNode(); - if (!node) - continue; - - auto* flow_box = To<SVGInlineFlowBox>(child); - bool is_text_path = IsA<SVGTextPathElement>(*node); - if (is_text_path) - BeginTextPathLayout(flow_box); - - LayoutCharactersInTextBoxes(flow_box); - - if (is_text_path) - EndTextPathLayout(); - last_text_box_was_in_text_path_ = is_text_path; - } - } -} - -void SVGTextLayoutEngine::FinishLayout() { - visual_metrics_iterator_ = SVGInlineTextMetricsIterator(); - - // After all text fragments are stored in their correpsonding - // SVGInlineTextBoxes, we can layout individual text chunks. - // Chunk layouting is only performed for line layout boxes, not for path - // layout, where it has already been done. - SVGTextChunkBuilder chunk_layout_builder; - chunk_layout_builder.ProcessTextChunks(line_layout_boxes_); - - line_layout_boxes_.clear(); -} - -const LayoutSVGInlineText* SVGTextLayoutEngine::NextLogicalTextNode() { - DCHECK_LT(current_logical_text_node_index_, descendant_text_nodes_.size()); - ++current_logical_text_node_index_; - if (current_logical_text_node_index_ == descendant_text_nodes_.size()) - return nullptr; - - logical_metrics_list_offset_ = 0; - logical_character_offset_ = 0; - return descendant_text_nodes_[current_logical_text_node_index_]; -} - -const LayoutSVGInlineText* SVGTextLayoutEngine::CurrentLogicalCharacterMetrics( - SVGTextMetrics& logical_metrics) { - // If we've consumed all text nodes, there can be no more metrics. - if (current_logical_text_node_index_ == descendant_text_nodes_.size()) - return nullptr; - - const LayoutSVGInlineText* logical_text_node = - descendant_text_nodes_[current_logical_text_node_index_]; - const Vector<SVGTextMetrics>* metrics_list = - &logical_text_node->MetricsList(); - unsigned metrics_list_size = metrics_list->size(); - DCHECK_LE(logical_metrics_list_offset_, metrics_list_size); - - // Find the next non-collapsed text metrics cell. - while (true) { - // If we run out of metrics, move to the next set of non-empty layout - // attributes. - if (logical_metrics_list_offset_ == metrics_list_size) { - logical_text_node = NextLogicalTextNode(); - if (!logical_text_node) - return nullptr; - metrics_list = &logical_text_node->MetricsList(); - metrics_list_size = metrics_list->size(); - // Return to the while so that we check if the new metrics list is - // non-empty before using it. - continue; - } - - DCHECK(metrics_list_size); - logical_metrics = metrics_list->at(logical_metrics_list_offset_); - // Stop if we found the next valid logical text metrics object. - if (!logical_metrics.IsEmpty()) - break; - - AdvanceToNextLogicalCharacter(logical_metrics); - } - - return logical_text_node; -} - -void SVGTextLayoutEngine::AdvanceToNextLogicalCharacter( - const SVGTextMetrics& logical_metrics) { - ++logical_metrics_list_offset_; - logical_character_offset_ += logical_metrics.length(); -} - -void SVGTextLayoutEngine::LayoutTextOnLineOrPath( - SVGInlineTextBox* text_box, - LineLayoutSVGInlineText text_line_layout, - const ComputedStyle& style) { - if (in_path_layout_ && !text_path_) - return; - - // Find the start of the current text box in the metrics list. - visual_metrics_iterator_.AdvanceToTextStart(text_line_layout, - text_box->Start()); - - const Font& font = style.GetFont(); - - SVGTextLayoutEngineSpacing spacing_layout(font, style.EffectiveZoom()); - SVGTextLayoutEngineBaseline baseline_layout(text_line_layout.ScaledFont(), - text_line_layout.ScalingFactor()); - - bool did_start_text_fragment = false; - bool apply_spacing_to_next_character = false; - bool needs_fragment_per_glyph = - is_vertical_text_ || in_path_layout_ || text_length_spacing_in_effect_; - - float last_angle = 0; - float baseline_shift_value = baseline_layout.CalculateBaselineShift(style); - baseline_shift_value -= baseline_layout.CalculateAlignmentBaselineShift( - is_vertical_text_, text_line_layout); - gfx::Vector2dF baseline_shift; - if (is_vertical_text_) - baseline_shift.set_x(baseline_shift_value); - else - baseline_shift.set_y(-baseline_shift_value); - - // Main layout algorithm. - const unsigned box_end_offset = text_box->Start() + text_box->Len(); - while (!visual_metrics_iterator_.IsAtEnd() && - visual_metrics_iterator_.CharacterOffset() < box_end_offset) { - const SVGTextMetrics& visual_metrics = visual_metrics_iterator_.Metrics(); - if (visual_metrics.IsEmpty()) { - visual_metrics_iterator_.Next(); - continue; - } - - SVGTextMetrics logical_metrics(SVGTextMetrics::kSkippedSpaceMetrics); - const LayoutSVGInlineText* logical_text_node = - CurrentLogicalCharacterMetrics(logical_metrics); - if (!logical_text_node) - break; - - auto it = logical_text_node->CharacterDataMap().find( - logical_character_offset_ + 1); - const SVGCharacterData data = - it != logical_text_node->CharacterDataMap().end() ? it->value - : SVGCharacterData(); - - // TODO(fs): Use the return value to eliminate the additional - // hash-lookup below when determining if this text box should be tagged - // as starting a new text chunk. - SetCurrentTextPosition(data); - - // When we've advanced to the box start offset, determine using the original - // x/y values, whether this character starts a new text chunk, before doing - // any further processing. - if (visual_metrics_iterator_.CharacterOffset() == text_box->Start()) - text_box->SetStartsNewTextChunk( - logical_text_node->CharacterStartsNewTextChunk( - logical_character_offset_)); - - bool has_relative_position = ApplyRelativePositionAdjustmentsIfNeeded(data); - - // Determine the orientation of the current glyph. - // Font::width() calculates the resolved FontOrientation for each character, - // but that value is not exposed today to avoid the API complexity. - UChar32 current_character = text_line_layout.CodepointAt( - visual_metrics_iterator_.CharacterOffset()); - FontOrientation font_orientation = font.GetFontDescription().Orientation(); - font_orientation = AdjustOrientationForCharacterInMixedVertical( - font_orientation, current_character); - - // Calculate glyph advance. The shaping engine takes care of x/y orientation - // shifts for different fontOrientation values. - float glyph_advance = visual_metrics.Advance(font_orientation); - - // Calculate CSS 'letter-spacing' and 'word-spacing' for the character, if - // needed. - float spacing = spacing_layout.CalculateCSSSpacing(current_character); - - gfx::Vector2dF text_path_shift; - PointAndTangent position; - if (in_path_layout_) { - float scaled_glyph_advance = glyph_advance * text_path_scaling_; - // Setup translations that move to the glyph midpoint. - text_path_shift = - gfx::Vector2dF(-scaled_glyph_advance / 2, text_path_displacement_); - if (is_vertical_text_) - text_path_shift.Transpose(); - text_path_shift += baseline_shift; - - // Calculate current offset along path. - float text_path_offset = - text_path_current_offset_ + scaled_glyph_advance / 2; - - // Move to next character. - text_path_current_offset_ += scaled_glyph_advance + text_path_spacing_ + - spacing * text_path_scaling_; - - PathPositionMapper::PositionType position_type = - text_path_->PointAndNormalAtLength(text_path_offset, position); - - // Skip character, if we're before the path. - if (position_type == PathPositionMapper::kBeforePath) { - AdvanceToNextLogicalCharacter(logical_metrics); - visual_metrics_iterator_.Next(); - continue; - } - - // Stop processing if the next character lies behind the path. - if (position_type == PathPositionMapper::kAfterPath) - break; - - text_position_ = position.point; - - // For vertical text on path, the actual angle has to be rotated 90 - // degrees anti-clockwise, not the orientation angle! - if (is_vertical_text_) - position.tangent_in_degrees -= 90; - } else { - position.point = text_position_; - position.point += baseline_shift; - } - - if (data.HasRotate()) - position.tangent_in_degrees += data.rotate; - - // Determine whether we have to start a new fragment. - bool should_start_new_fragment = - needs_fragment_per_glyph || has_relative_position || - position.tangent_in_degrees || - position.tangent_in_degrees != last_angle || - apply_spacing_to_next_character; - - // If we already started a fragment, close it now. - if (did_start_text_fragment && should_start_new_fragment) { - apply_spacing_to_next_character = false; - RecordTextFragment(text_box); - } - - // Eventually start a new fragment, if not yet done. - if (!did_start_text_fragment || should_start_new_fragment) { - DCHECK(!current_text_fragment_.character_offset); - DCHECK(!current_text_fragment_.length); - - did_start_text_fragment = true; - current_text_fragment_.character_offset = - visual_metrics_iterator_.CharacterOffset(); - current_text_fragment_.metrics_list_offset = - visual_metrics_iterator_.MetricsListOffset(); - current_text_fragment_.x = position.point.x(); - current_text_fragment_.y = position.point.y(); - - // Build fragment transformation. - if (position.tangent_in_degrees) - current_text_fragment_.transform.Rotate(position.tangent_in_degrees); - - if (text_path_shift.x() || text_path_shift.y()) { - current_text_fragment_.transform.Translate(text_path_shift.x(), - text_path_shift.y()); - } - - // For vertical text, always rotate by 90 degrees regardless of - // fontOrientation. - // The shaping engine takes care of the necessary orientation. - if (is_vertical_text_) - current_text_fragment_.transform.Rotate(90); - - current_text_fragment_.is_vertical = is_vertical_text_; - current_text_fragment_.is_text_on_path = - in_path_layout_ && text_path_scaling_ != 1; - if (current_text_fragment_.is_text_on_path) - current_text_fragment_.length_adjust_scale = text_path_scaling_; - } - - // Advance current text position after processing of the current character - // finished. - AdvanceCurrentTextPosition(glyph_advance + spacing); - - // Apply CSS 'letter-spacing' and 'word-spacing' to the next character, if - // needed. - if (!in_path_layout_ && spacing) - apply_spacing_to_next_character = true; - - AdvanceToNextLogicalCharacter(logical_metrics); - visual_metrics_iterator_.Next(); - last_angle = position.tangent_in_degrees; - } - - if (!did_start_text_fragment) - return; - - // Close last open fragment, if needed. - RecordTextFragment(text_box); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine.h b/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine.h deleted file mode 100644 index bfcae1e..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine.h +++ /dev/null
@@ -1,107 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_LAYOUT_ENGINE_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_LAYOUT_ENGINE_H_ - -#include <memory> -#include "third_party/blink/renderer/core/layout/api/line_layout_svg_inline_text.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h" -#include "third_party/blink/renderer/core/layout/svg/svg_text_fragment.h" -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" -#include "third_party/blink/renderer/platform/wtf/vector.h" - -namespace blink { - -class ComputedStyle; -class InlineFlowBox; -class PathPositionMapper; -class SVGInlineFlowBox; -class SVGInlineTextBox; -class SVGTextMetrics; - -// SVGTextLayoutEngine performs the second layout phase for SVG text. -// -// The InlineBox tree was created, containing the text chunk information, -// necessary to apply certain SVG specific text layout properties (text-length -// adjustments and text-anchor). -// The second layout phase uses the SVGTextLayoutAttributes stored in the -// individual LayoutSVGInlineText layoutObjects to compute the final positions -// for each character which are stored in the SVGInlineTextBox objects. - -class SVGTextLayoutEngine { - STACK_ALLOCATED(); - - public: - explicit SVGTextLayoutEngine(const HeapVector<Member<LayoutSVGInlineText>>&); - SVGTextLayoutEngine(const SVGTextLayoutEngine&) = delete; - SVGTextLayoutEngine& operator=(const SVGTextLayoutEngine&) = delete; - ~SVGTextLayoutEngine(); - - void LayoutCharactersInTextBoxes(InlineFlowBox* start); - void FinishLayout(); - - private: - bool SetCurrentTextPosition(const SVGCharacterData&); - void AdvanceCurrentTextPosition(float glyph_advance); - bool ApplyRelativePositionAdjustmentsIfNeeded(const SVGCharacterData&); - - void ComputeCurrentFragmentMetrics(SVGInlineTextBox*); - void RecordTextFragment(SVGInlineTextBox*); - - void BeginTextPathLayout(SVGInlineFlowBox*); - void EndTextPathLayout(); - - void LayoutInlineTextBox(SVGInlineTextBox*); - void LayoutTextOnLineOrPath(SVGInlineTextBox*, - LineLayoutSVGInlineText, - const ComputedStyle&); - - const LayoutSVGInlineText* NextLogicalTextNode(); - const LayoutSVGInlineText* CurrentLogicalCharacterMetrics(SVGTextMetrics&); - void AdvanceToNextLogicalCharacter(const SVGTextMetrics&); - - // Logical iteration state. - const HeapVector<Member<LayoutSVGInlineText>>& descendant_text_nodes_; - unsigned current_logical_text_node_index_; - unsigned logical_character_offset_; - unsigned logical_metrics_list_offset_; - - HeapVector<Member<SVGInlineTextBox>> line_layout_boxes_; - - SVGTextFragment current_text_fragment_; - SVGInlineTextMetricsIterator visual_metrics_iterator_; - gfx::PointF text_position_; - bool is_vertical_text_; - bool in_path_layout_; - bool text_length_spacing_in_effect_; - bool last_text_box_was_in_text_path_; - - // Text on path layout - std::unique_ptr<PathPositionMapper> text_path_; - float text_path_start_offset_; - float text_path_current_offset_; - float text_path_displacement_; - float text_path_spacing_; - float text_path_scaling_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_LAYOUT_ENGINE_H_
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_baseline.cc b/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_baseline.cc deleted file mode 100644 index 7caee87..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_baseline.cc +++ /dev/null
@@ -1,162 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_baseline.h" - -#include "third_party/blink/renderer/core/svg/svg_length_context.h" -#include "third_party/blink/renderer/platform/fonts/font.h" - -namespace blink { - -SVGTextLayoutEngineBaseline::SVGTextLayoutEngineBaseline(const Font& font, - float effective_zoom) - : font_(font), effective_zoom_(effective_zoom) { - DCHECK(effective_zoom_); -} - -float SVGTextLayoutEngineBaseline::CalculateBaselineShift( - const ComputedStyle& style) const { - const SimpleFontData* font_data = font_.PrimaryFont(); - DCHECK(font_data); - if (!font_data) - return 0; - - DCHECK(effective_zoom_); - switch (style.BaselineShiftType()) { - case EBaselineShiftType::kLength: - return SVGLengthContext::ValueForLength( - style.BaselineShift(), style, - font_.GetFontDescription().ComputedPixelSize() / effective_zoom_); - case EBaselineShiftType::kSub: - return -font_data->GetFontMetrics().FloatHeight() / 2 / effective_zoom_; - case EBaselineShiftType::kSuper: - return font_data->GetFontMetrics().FloatHeight() / 2 / effective_zoom_; - default: - NOTREACHED(); - return 0; - } -} - -EAlignmentBaseline -SVGTextLayoutEngineBaseline::DominantBaselineToAlignmentBaseline( - bool is_vertical_text, - LineLayoutItem text_line_layout) const { - DCHECK(text_line_layout); - DCHECK(text_line_layout.Style()); - - EDominantBaseline baseline = text_line_layout.StyleRef().DominantBaseline(); - if (baseline == EDominantBaseline::kAuto) { - if (is_vertical_text) - baseline = EDominantBaseline::kCentral; - else - baseline = EDominantBaseline::kAlphabetic; - } - - switch (baseline) { - case EDominantBaseline::kUseScript: - // TODO(fs): The dominant-baseline and the baseline-table components - // are set by determining the predominant script of the character data - // content. - return EAlignmentBaseline::kAlphabetic; - case EDominantBaseline::kNoChange: - DCHECK(text_line_layout.Parent()); - return DominantBaselineToAlignmentBaseline(is_vertical_text, - text_line_layout.Parent()); - case EDominantBaseline::kResetSize: - DCHECK(text_line_layout.Parent()); - return DominantBaselineToAlignmentBaseline(is_vertical_text, - text_line_layout.Parent()); - case EDominantBaseline::kIdeographic: - return EAlignmentBaseline::kIdeographic; - case EDominantBaseline::kAlphabetic: - return EAlignmentBaseline::kAlphabetic; - case EDominantBaseline::kHanging: - return EAlignmentBaseline::kHanging; - case EDominantBaseline::kMathematical: - return EAlignmentBaseline::kMathematical; - case EDominantBaseline::kCentral: - return EAlignmentBaseline::kCentral; - case EDominantBaseline::kMiddle: - return EAlignmentBaseline::kMiddle; - case EDominantBaseline::kTextAfterEdge: - return EAlignmentBaseline::kTextAfterEdge; - case EDominantBaseline::kTextBeforeEdge: - return EAlignmentBaseline::kTextBeforeEdge; - default: - NOTREACHED(); - return EAlignmentBaseline::kAuto; - } -} - -float SVGTextLayoutEngineBaseline::CalculateAlignmentBaselineShift( - bool is_vertical_text, - LineLayoutItem text_line_layout) const { - DCHECK(text_line_layout); - DCHECK(text_line_layout.Style()); - DCHECK(text_line_layout.Parent()); - - LineLayoutItem text_line_layout_parent = text_line_layout.Parent(); - DCHECK(text_line_layout_parent); - - EAlignmentBaseline baseline = text_line_layout.StyleRef().AlignmentBaseline(); - if (baseline == EAlignmentBaseline::kAuto || - baseline == EAlignmentBaseline::kBaseline) { - baseline = DominantBaselineToAlignmentBaseline(is_vertical_text, - text_line_layout_parent); - DCHECK_NE(baseline, EAlignmentBaseline::kAuto); - DCHECK_NE(baseline, EAlignmentBaseline::kBaseline); - } - - const SimpleFontData* font_data = font_.PrimaryFont(); - DCHECK(font_data); - if (!font_data) - return 0; - - const FontMetrics& font_metrics = font_data->GetFontMetrics(); - float ascent = font_metrics.FloatAscent() / effective_zoom_; - float descent = font_metrics.FloatDescent() / effective_zoom_; - float xheight = font_metrics.XHeight() / effective_zoom_; - - // Note: http://wiki.apache.org/xmlgraphics-fop/LineLayout/AlignmentHandling - switch (baseline) { - case EAlignmentBaseline::kBeforeEdge: - case EAlignmentBaseline::kTextBeforeEdge: - return ascent; - case EAlignmentBaseline::kMiddle: - return xheight / 2; - case EAlignmentBaseline::kCentral: - return (ascent - descent) / 2; - case EAlignmentBaseline::kAfterEdge: - case EAlignmentBaseline::kTextAfterEdge: - case EAlignmentBaseline::kIdeographic: - return -descent; - case EAlignmentBaseline::kAlphabetic: - return 0; - case EAlignmentBaseline::kHanging: - return ascent * 8 / 10.f; - case EAlignmentBaseline::kMathematical: - return ascent / 2; - case EAlignmentBaseline::kBaseline: - default: - NOTREACHED(); - return 0; - } -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_baseline.h b/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_baseline.h deleted file mode 100644 index 2a75582..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_baseline.h +++ /dev/null
@@ -1,61 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_LAYOUT_ENGINE_BASELINE_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_LAYOUT_ENGINE_BASELINE_H_ - -#include "third_party/blink/renderer/core/layout/api/line_layout_item.h" -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" - -namespace blink { - -class Font; -class ComputedStyle; - -// Helper class used by SVGTextLayoutEngine to handle 'alignment-baseline' / -// 'dominant-baseline' and 'baseline-shift'. -class SVGTextLayoutEngineBaseline { - STACK_ALLOCATED(); - - public: - SVGTextLayoutEngineBaseline(const Font&, float effective_zoom); - SVGTextLayoutEngineBaseline(const SVGTextLayoutEngineBaseline&) = delete; - SVGTextLayoutEngineBaseline& operator=(const SVGTextLayoutEngineBaseline&) = - delete; - - float CalculateBaselineShift(const ComputedStyle&) const; - float CalculateAlignmentBaselineShift(bool is_vertical_text, - LineLayoutItem) const; - - private: - EAlignmentBaseline DominantBaselineToAlignmentBaseline(bool is_vertical_text, - LineLayoutItem) const; - - const Font& font_; - - // Everything we read from the m_font's font descriptor during layout is - // scaled by the effective zoom, as fonts always are in computed style. Since - // layout inside SVG takes place in unzoomed coordinates we have to compensate - // for zoom when reading values from the font descriptor. - float effective_zoom_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_LAYOUT_ENGINE_BASELINE_H_
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_spacing.cc b/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_spacing.cc deleted file mode 100644 index 0b629e804..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_spacing.cc +++ /dev/null
@@ -1,54 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_spacing.h" - -#include "third_party/blink/renderer/platform/fonts/font.h" -#include "third_party/blink/renderer/platform/text/character.h" - -namespace blink { - -SVGTextLayoutEngineSpacing::SVGTextLayoutEngineSpacing(const Font& font, - float effective_zoom) - : font_(font), last_character_(0), effective_zoom_(effective_zoom) { - DCHECK(effective_zoom_); -} - -float SVGTextLayoutEngineSpacing::CalculateCSSSpacing(UChar current_character) { - UChar last_character = last_character_; - last_character_ = current_character; - - if (!font_.GetFontDescription().LetterSpacing() && - !font_.GetFontDescription().WordSpacing()) - return 0; - - float spacing = font_.GetFontDescription().LetterSpacing(); - if (font_.GetFontDescription().WordSpacing()) { - if (Character::TreatAsSpace(current_character) && - !Character::TreatAsSpace(last_character)) - spacing += font_.GetFontDescription().WordSpacing(); - } - - if (effective_zoom_ != 1) - spacing = spacing / effective_zoom_; - - return spacing; -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_spacing.h b/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_spacing.h deleted file mode 100644 index 2efc8ad0..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_spacing.h +++ /dev/null
@@ -1,51 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_LAYOUT_ENGINE_SPACING_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_LAYOUT_ENGINE_SPACING_H_ - -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" -#include "third_party/blink/renderer/platform/wtf/text/wtf_uchar.h" - -namespace blink { - -class Font; - -// Helper class used by SVGTextLayoutEngine to handle 'letter-spacing' and -// 'word-spacing'. -class SVGTextLayoutEngineSpacing { - STACK_ALLOCATED(); - - public: - SVGTextLayoutEngineSpacing(const Font&, float effective_zoom); - SVGTextLayoutEngineSpacing(const SVGTextLayoutEngineSpacing&) = delete; - SVGTextLayoutEngineSpacing& operator=(const SVGTextLayoutEngineSpacing&) = - delete; - - float CalculateCSSSpacing(UChar current_character); - - private: - const Font& font_; - UChar last_character_; - float effective_zoom_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_LAYOUT_ENGINE_SPACING_H_
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_metrics.cc b/third_party/blink/renderer/core/layout/svg/svg_text_metrics.cc deleted file mode 100644 index d517435..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_metrics.cc +++ /dev/null
@@ -1,54 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "third_party/blink/renderer/core/layout/svg/svg_text_metrics.h" - -#include "third_party/blink/renderer/platform/fonts/font_orientation.h" -#include "third_party/blink/renderer/platform/wtf/math_extras.h" -#include "ui/gfx/geometry/size_f.h" - -namespace blink { - -SVGTextMetrics::SVGTextMetrics(unsigned length, float width, float height) - : width_(width), height_(height), length_(length) {} - -SVGTextMetrics::SVGTextMetrics(SVGTextMetrics::MetricsType) - : SVGTextMetrics(1, 0, 0) {} - -gfx::SizeF SVGTextMetrics::Extents() const { - // TODO(fs): Negative glyph extents seems kind of weird to have, but - // presently it can occur in some cases (like Arabic.) - // gfx::SizeF clamps negative values to zeros. - return gfx::SizeF(width_, height_); -} - -float SVGTextMetrics::Advance(FontOrientation orientation) const { - switch (orientation) { - case FontOrientation::kHorizontal: - case FontOrientation::kVerticalRotated: - return width_; - case FontOrientation::kVerticalUpright: - return height_; - default: - NOTREACHED(); - return width_; - } -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_metrics.h b/third_party/blink/renderer/core/layout/svg/svg_text_metrics.h deleted file mode 100644 index 51930a7..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_metrics.h +++ /dev/null
@@ -1,62 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_METRICS_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_METRICS_H_ - -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" - -namespace gfx { -class SizeF; -} - -namespace blink { - -enum class FontOrientation; - -class SVGTextMetrics { - DISALLOW_NEW(); - - public: - enum MetricsType { kSkippedSpaceMetrics }; - - SVGTextMetrics(MetricsType); - SVGTextMetrics(unsigned length, float width, float height); - - bool IsEmpty() const { return !width_ && !height_ && length_ <= 1; } - - gfx::SizeF Extents() const; - - // TODO(kojii): We should store logical width (advance) and height instead - // of storing physical and calculate logical. crbug.com/544767 - float Advance(FontOrientation) const; - float Advance(bool is_vertical) const { - return is_vertical ? height_ : width_; - } - unsigned length() const { return length_; } - - private: - float width_; - float height_; - unsigned length_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_METRICS_H_
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_query.cc b/third_party/blink/renderer/core/layout/svg/svg_text_query.cc deleted file mode 100644 index 2aec8da..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_query.cc +++ /dev/null
@@ -1,634 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "third_party/blink/renderer/core/layout/svg/svg_text_query.h" - -#include <algorithm> -#include "third_party/blink/renderer/core/layout/api/line_layout_svg_inline_text.h" -#include "third_party/blink/renderer/core/layout/layout_block_flow.h" -#include "third_party/blink/renderer/core/layout/layout_inline.h" -#include "third_party/blink/renderer/core/layout/line/inline_flow_box.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.h" -#include "third_party/blink/renderer/core/layout/svg/svg_text_fragment.h" -#include "third_party/blink/renderer/core/layout/svg/svg_text_metrics.h" -#include "third_party/blink/renderer/platform/wtf/vector.h" - -namespace blink { - -// Base structure for callback user data -struct QueryData { - STACK_ALLOCATED(); - - public: - QueryData() - : is_vertical_text(false), - current_offset(0), - text_line_layout(nullptr), - text_box(nullptr) {} - - bool is_vertical_text; - unsigned current_offset; - LineLayoutSVGInlineText text_line_layout; - const SVGInlineTextBox* text_box; -}; - -static inline InlineFlowBox* FlowBoxForLayoutObject( - LayoutObject* layout_object) { - if (!layout_object) - return nullptr; - - if (layout_object->IsLayoutBlock()) { - // If we're given a block element, it has to be a LayoutSVGText. - DCHECK(layout_object->IsSVGText()); - auto* layout_block_flow = To<LayoutBlockFlow>(layout_object); - - // LayoutSVGText only ever contains a single line box. - InlineFlowBox* flow_box = layout_block_flow->FirstLineBox(); - DCHECK_EQ(flow_box, layout_block_flow->LastLineBox()); - return flow_box; - } - - if (layout_object->IsLayoutInline()) { - // We're given a LayoutSVGInline or objects that derive from it - // (LayoutSVGTSpan / LayoutSVGTextPath) - auto* layout_inline = To<LayoutInline>(layout_object); - - // LayoutSVGInline only ever contains a single line box. - InlineFlowBox* flow_box = layout_inline->FirstLineBox(); - DCHECK_EQ(flow_box, layout_inline->LastLineBox()); - return flow_box; - } - - NOTREACHED(); - return nullptr; -} - -static void CollectTextBoxesInFlowBox( - InlineFlowBox* flow_box, - HeapVector<Member<SVGInlineTextBox>>& text_boxes) { - if (!flow_box) - return; - - for (InlineBox* child = flow_box->FirstChild(); child; - child = child->NextOnLine()) { - if (child->IsInlineFlowBox()) { - // Skip generated content. - if (!child->GetLineLayoutItem().GetNode()) - continue; - - CollectTextBoxesInFlowBox(To<InlineFlowBox>(child), text_boxes); - continue; - } - - if (auto* svg_inline_text_box = DynamicTo<SVGInlineTextBox>(child)) - text_boxes.push_back(svg_inline_text_box); - } -} - -typedef bool ProcessTextFragmentCallback(QueryData*, const SVGTextFragment&); - -static bool QueryTextBox(QueryData* query_data, - const SVGInlineTextBox* text_box, - ProcessTextFragmentCallback fragment_callback) { - query_data->text_box = text_box; - query_data->text_line_layout = - LineLayoutSVGInlineText(text_box->GetLineLayoutItem()); - - query_data->is_vertical_text = - !query_data->text_line_layout.StyleRef().IsHorizontalWritingMode(); - - // Loop over all text fragments in this text box, firing a callback for each. - for (const SVGTextFragment& fragment : text_box->TextFragments()) { - if (fragment_callback(query_data, fragment)) - return true; - } - return false; -} - -// Execute a query in "spatial" order starting at |queryRoot|. This means -// walking the lines boxes in the order they would get painted. -static void SpatialQuery(LayoutObject* query_root, - QueryData* query_data, - ProcessTextFragmentCallback fragment_callback) { - HeapVector<Member<SVGInlineTextBox>> text_boxes; - CollectTextBoxesInFlowBox(FlowBoxForLayoutObject(query_root), text_boxes); - - // Loop over all text boxes - for (const SVGInlineTextBox* text_box : text_boxes) { - if (QueryTextBox(query_data, text_box, fragment_callback)) - return; - } -} - -static void CollectTextBoxesInLogicalOrder( - LineLayoutSVGInlineText text_line_layout, - HeapVector<Member<SVGInlineTextBox>>& text_boxes) { - text_boxes.Shrink(0); - for (InlineTextBox* text_box = text_line_layout.FirstTextBox(); text_box; - text_box = text_box->NextForSameLayoutObject()) - text_boxes.push_back(To<SVGInlineTextBox>(text_box)); - std::sort(text_boxes.begin(), text_boxes.end(), - InlineTextBox::CompareByStart); -} - -// Execute a query in "logical" order starting at |queryRoot|. This means -// walking the lines boxes for each layout object in layout tree (pre)order. -static void LogicalQuery(LayoutObject* query_root, - QueryData* query_data, - ProcessTextFragmentCallback fragment_callback) { - if (!query_root) - return; - - // Walk the layout tree in pre-order, starting at the specified root, and - // run the query for each text node. - HeapVector<Member<SVGInlineTextBox>> text_boxes; - for (LayoutObject* layout_object = query_root->SlowFirstChild(); - layout_object; - layout_object = layout_object->NextInPreOrder(query_root)) { - if (!layout_object->IsSVGInlineText()) - continue; - - auto text_line_layout = - LineLayoutSVGInlineText(To<LayoutSVGInlineText>(layout_object)); - DCHECK(text_line_layout.Style()); - - // TODO(fs): Allow filtering the search earlier, since we should be - // able to trivially reject (prune) at least some of the queries. - CollectTextBoxesInLogicalOrder(text_line_layout, text_boxes); - - for (const SVGInlineTextBox* text_box : text_boxes) { - if (QueryTextBox(query_data, text_box, fragment_callback)) - return; - query_data->current_offset += text_box->Len(); - } - } -} - -static bool MapStartEndPositionsIntoFragmentCoordinates( - const QueryData* query_data, - const SVGTextFragment& fragment, - int& start_position, - int& end_position) { - unsigned box_start = query_data->current_offset; - - // Make <startPosition, endPosition> offsets relative to the current text box. - start_position -= box_start; - end_position -= box_start; - - // Reuse the same logic used for text selection & painting, to map our - // query start/length into start/endPositions of the current text fragment. - return query_data->text_box->MapStartEndPositionsIntoFragmentCoordinates( - fragment, start_position, end_position); -} - -// numberOfCharacters() implementation -static bool NumberOfCharactersCallback(QueryData*, const SVGTextFragment&) { - // no-op - return false; -} - -unsigned SVGTextQuery::NumberOfCharacters() const { - QueryData data; - LogicalQuery(query_root_layout_object_, &data, NumberOfCharactersCallback); - return data.current_offset; -} - -// textLength() implementation -struct TextLengthData : QueryData { - TextLengthData() : text_length(0) {} - - float text_length; -}; - -static bool TextLengthCallback(QueryData* query_data, - const SVGTextFragment& fragment) { - TextLengthData* data = static_cast<TextLengthData*>(query_data); - data->text_length += - query_data->is_vertical_text ? fragment.height : fragment.width; - return false; -} - -float SVGTextQuery::TextLength() const { - TextLengthData data; - LogicalQuery(query_root_layout_object_, &data, TextLengthCallback); - return data.text_length; -} - -using MetricsList = Vector<SVGTextMetrics>; - -MetricsList::const_iterator FindMetricsForCharacter( - const MetricsList& metrics_list, - const SVGTextFragment& fragment, - unsigned start_in_fragment) { - // Find the text metrics cell that starts at or contains the character at - // |startInFragment|. - MetricsList::const_iterator metrics = - metrics_list.begin() + fragment.metrics_list_offset; - unsigned fragment_offset = 0; - while (fragment_offset < fragment.length) { - fragment_offset += metrics->length(); - if (start_in_fragment < fragment_offset) - break; - ++metrics; - } - DCHECK_LE(metrics, metrics_list.end()); - return metrics; -} - -static float CalculateGlyphRange(const QueryData* query_data, - const SVGTextFragment& fragment, - unsigned start, - unsigned end) { - const MetricsList& metrics_list = query_data->text_line_layout.MetricsList(); - auto* metrics = FindMetricsForCharacter(metrics_list, fragment, start); - auto* end_metrics = FindMetricsForCharacter(metrics_list, fragment, end); - float glyph_range = 0; - for (; metrics != end_metrics; ++metrics) - glyph_range += metrics->Advance(query_data->is_vertical_text); - return glyph_range; -} - -// subStringLength() implementation -struct SubStringLengthData : QueryData { - SubStringLengthData(unsigned query_start_position, unsigned query_length) - : start_position(query_start_position), - length(query_length), - sub_string_length(0) {} - - unsigned start_position; - unsigned length; - - float sub_string_length; -}; - -static bool SubStringLengthCallback(QueryData* query_data, - const SVGTextFragment& fragment) { - SubStringLengthData* data = static_cast<SubStringLengthData*>(query_data); - - int start_position = data->start_position; - int end_position = start_position + data->length; - if (!MapStartEndPositionsIntoFragmentCoordinates( - query_data, fragment, start_position, end_position)) - return false; - - data->sub_string_length += - CalculateGlyphRange(query_data, fragment, start_position, end_position); - return false; -} - -float SVGTextQuery::SubStringLength(unsigned start_position, - unsigned length) const { - SubStringLengthData data(start_position, length); - LogicalQuery(query_root_layout_object_, &data, SubStringLengthCallback); - return data.sub_string_length; -} - -// startPositionOfCharacter() implementation -struct StartPositionOfCharacterData : QueryData { - StartPositionOfCharacterData(unsigned query_position) - : position(query_position) {} - - unsigned position; - gfx::PointF start_position; -}; - -static gfx::PointF LogicalGlyphPositionToPhysical( - const QueryData* query_data, - const SVGTextFragment& fragment, - float logical_glyph_offset) { - float physical_glyph_offset = logical_glyph_offset; - if (!query_data->text_box->IsLeftToRightDirection()) { - float fragment_extent = - query_data->is_vertical_text ? fragment.height : fragment.width; - physical_glyph_offset = fragment_extent - logical_glyph_offset; - } - - gfx::PointF glyph_position(fragment.x, fragment.y); - if (query_data->is_vertical_text) - glyph_position.Offset(0, physical_glyph_offset); - else - glyph_position.Offset(physical_glyph_offset, 0); - - return glyph_position; -} - -static gfx::PointF CalculateGlyphPosition(const QueryData* query_data, - const SVGTextFragment& fragment, - unsigned offset_in_fragment) { - float glyph_offset_in_direction = - CalculateGlyphRange(query_data, fragment, 0, offset_in_fragment); - gfx::PointF glyph_position = LogicalGlyphPositionToPhysical( - query_data, fragment, glyph_offset_in_direction); - if (fragment.IsTransformed()) { - AffineTransform fragment_transform = fragment.BuildFragmentTransform( - SVGTextFragment::kTransformIgnoringTextLength); - glyph_position = fragment_transform.MapPoint(glyph_position); - } - return glyph_position; -} - -static bool StartPositionOfCharacterCallback(QueryData* query_data, - const SVGTextFragment& fragment) { - StartPositionOfCharacterData* data = - static_cast<StartPositionOfCharacterData*>(query_data); - - int start_position = data->position; - int end_position = start_position + 1; - if (!MapStartEndPositionsIntoFragmentCoordinates( - query_data, fragment, start_position, end_position)) - return false; - - data->start_position = - CalculateGlyphPosition(query_data, fragment, start_position); - return true; -} - -gfx::PointF SVGTextQuery::StartPositionOfCharacter(unsigned position) const { - StartPositionOfCharacterData data(position); - LogicalQuery(query_root_layout_object_, &data, - StartPositionOfCharacterCallback); - return data.start_position; -} - -// endPositionOfCharacter() implementation -struct EndPositionOfCharacterData : QueryData { - EndPositionOfCharacterData(unsigned query_position) - : position(query_position) {} - - unsigned position; - gfx::PointF end_position; -}; - -static bool EndPositionOfCharacterCallback(QueryData* query_data, - const SVGTextFragment& fragment) { - EndPositionOfCharacterData* data = - static_cast<EndPositionOfCharacterData*>(query_data); - - int start_position = data->position; - int end_position = start_position + 1; - if (!MapStartEndPositionsIntoFragmentCoordinates( - query_data, fragment, start_position, end_position)) - return false; - - data->end_position = - CalculateGlyphPosition(query_data, fragment, end_position); - return true; -} - -gfx::PointF SVGTextQuery::EndPositionOfCharacter(unsigned position) const { - EndPositionOfCharacterData data(position); - LogicalQuery(query_root_layout_object_, &data, - EndPositionOfCharacterCallback); - return data.end_position; -} - -// rotationOfCharacter() implementation -struct RotationOfCharacterData : QueryData { - RotationOfCharacterData(unsigned query_position) - : position(query_position), rotation(0) {} - - unsigned position; - float rotation; -}; - -static bool RotationOfCharacterCallback(QueryData* query_data, - const SVGTextFragment& fragment) { - RotationOfCharacterData* data = - static_cast<RotationOfCharacterData*>(query_data); - - int start_position = data->position; - int end_position = start_position + 1; - if (!MapStartEndPositionsIntoFragmentCoordinates( - query_data, fragment, start_position, end_position)) - return false; - - if (!fragment.IsTransformed()) { - data->rotation = 0; - } else { - AffineTransform fragment_transform = fragment.BuildFragmentTransform( - SVGTextFragment::kTransformIgnoringTextLength); - fragment_transform.Scale(1 / fragment_transform.XScale(), - 1 / fragment_transform.YScale()); - data->rotation = ClampTo<float>( - Rad2deg(atan2(fragment_transform.B(), fragment_transform.A()))); - } - return true; -} - -float SVGTextQuery::RotationOfCharacter(unsigned position) const { - RotationOfCharacterData data(position); - LogicalQuery(query_root_layout_object_, &data, RotationOfCharacterCallback); - return data.rotation; -} - -// extentOfCharacter() implementation -struct ExtentOfCharacterData : QueryData { - ExtentOfCharacterData(unsigned query_position) : position(query_position) {} - - unsigned position; - gfx::RectF extent; -}; - -static gfx::RectF PhysicalGlyphExtents(const QueryData* query_data, - const SVGTextMetrics& metrics, - const gfx::PointF& glyph_position) { - gfx::RectF glyph_extents(glyph_position, metrics.Extents()); - - // If RTL, adjust the starting point to align with the LHS of the glyph - // bounding box. - if (!query_data->text_box->IsLeftToRightDirection()) { - if (query_data->is_vertical_text) - glyph_extents.Offset(0, -glyph_extents.height()); - else - glyph_extents.Offset(-glyph_extents.width(), 0); - } - return glyph_extents; -} - -static inline gfx::RectF CalculateGlyphBoundaries( - const QueryData* query_data, - const SVGTextFragment& fragment, - int start_position) { - const float scaling_factor = query_data->text_line_layout.ScalingFactor(); - DCHECK(scaling_factor); - const SimpleFontData* font_data = - query_data->text_line_layout.ScaledFont().PrimaryFont(); - DCHECK(font_data); - if (!font_data) - return gfx::RectF(); - - const float baseline = - font_data->GetFontMetrics().FloatAscent() / scaling_factor; - float glyph_offset_in_direction = - CalculateGlyphRange(query_data, fragment, 0, start_position); - gfx::PointF glyph_position = LogicalGlyphPositionToPhysical( - query_data, fragment, glyph_offset_in_direction); - glyph_position.Offset(0, -baseline); - - // Use the SVGTextMetrics computed by SVGTextMetricsBuilder. - const MetricsList& metrics_list = query_data->text_line_layout.MetricsList(); - auto* metrics = - FindMetricsForCharacter(metrics_list, fragment, start_position); - - gfx::RectF extent = - PhysicalGlyphExtents(query_data, *metrics, glyph_position); - if (fragment.IsTransformed()) { - AffineTransform fragment_transform = fragment.BuildFragmentTransform( - SVGTextFragment::kTransformIgnoringTextLength); - extent = fragment_transform.MapRect(extent); - } - return extent; -} - -static bool ExtentOfCharacterCallback(QueryData* query_data, - const SVGTextFragment& fragment) { - ExtentOfCharacterData* data = static_cast<ExtentOfCharacterData*>(query_data); - - int start_position = data->position; - int end_position = start_position + 1; - if (!MapStartEndPositionsIntoFragmentCoordinates( - query_data, fragment, start_position, end_position)) - return false; - - data->extent = CalculateGlyphBoundaries(query_data, fragment, start_position); - return true; -} - -gfx::RectF SVGTextQuery::ExtentOfCharacter(unsigned position) const { - ExtentOfCharacterData data(position); - LogicalQuery(query_root_layout_object_, &data, ExtentOfCharacterCallback); - return data.extent; -} - -// characterNumberAtPosition() implementation -struct CharacterNumberAtPositionData : QueryData { - explicit CharacterNumberAtPositionData(const gfx::PointF& query_position) - : position(query_position) {} - - int CharacterNumberWithin(const LayoutObject* query_root) const; - - gfx::PointF position; - LineLayoutItem hit_layout_item{nullptr}; - int offset_in_text_node = 0; -}; - -int CharacterNumberAtPositionData::CharacterNumberWithin( - const LayoutObject* query_root) const { - // http://www.w3.org/TR/SVG/single-page.html#text-__svg__SVGTextContentElement__getCharNumAtPosition - // "If no such character exists, a value of -1 is returned." - if (!hit_layout_item) - return -1; - DCHECK(query_root); - int character_number = offset_in_text_node; - - // Accumulate the lengths of all the text nodes preceding the target layout - // object within the queried root, to get the complete character number. - for (LineLayoutItem layout_item = - hit_layout_item.PreviousInPreOrder(query_root); - layout_item; layout_item = layout_item.PreviousInPreOrder(query_root)) { - if (!layout_item.IsSVGInlineText()) - continue; - character_number += - LineLayoutSVGInlineText(layout_item).ResolvedTextLength(); - } - return character_number; -} - -static unsigned LogicalOffsetInTextNode( - LineLayoutSVGInlineText text_line_layout, - const SVGInlineTextBox* start_text_box, - unsigned fragment_offset) { - HeapVector<Member<SVGInlineTextBox>> text_boxes; - CollectTextBoxesInLogicalOrder(text_line_layout, text_boxes); - - DCHECK(start_text_box); - wtf_size_t index = text_boxes.Find(start_text_box); - DCHECK_NE(index, kNotFound); - - unsigned offset = fragment_offset; - while (index) { - --index; - offset += text_boxes[index]->Len(); - } - return offset; -} - -static bool CharacterNumberAtPositionCallback(QueryData* query_data, - const SVGTextFragment& fragment) { - CharacterNumberAtPositionData* data = - static_cast<CharacterNumberAtPositionData*>(query_data); - - const float scaling_factor = data->text_line_layout.ScalingFactor(); - DCHECK(scaling_factor); - - const SimpleFontData* font_data = - data->text_line_layout.ScaledFont().PrimaryFont(); - DCHECK(font_data); - if (!font_data) - return false; - - const float baseline = - font_data->GetFontMetrics().FloatAscent() / scaling_factor; - - // Test the query point against the bounds of the entire fragment first. - if (!fragment.BoundingBox(baseline).InclusiveContains(data->position)) - return false; - - AffineTransform fragment_transform = fragment.BuildFragmentTransform( - SVGTextFragment::kTransformIgnoringTextLength); - - // Iterate through the glyphs in this fragment, and check if their extents - // contain the query point. - MetricsList::const_iterator metrics = - data->text_line_layout.MetricsList().begin() + - fragment.metrics_list_offset; - unsigned fragment_offset = 0; - float glyph_offset = 0; - while (fragment_offset < fragment.length) { - gfx::PointF glyph_position = - LogicalGlyphPositionToPhysical(data, fragment, glyph_offset); - glyph_position.Offset(0, -baseline); - - gfx::RectF extent = fragment_transform.MapRect( - PhysicalGlyphExtents(data, *metrics, glyph_position)); - if (extent.InclusiveContains(data->position)) { - // Compute the character offset of the glyph within the text node. - unsigned offset_in_box = fragment.character_offset - - query_data->text_box->Start() + fragment_offset; - data->offset_in_text_node = LogicalOffsetInTextNode( - query_data->text_line_layout, query_data->text_box, offset_in_box); - data->hit_layout_item = LineLayoutItem(data->text_line_layout); - return true; - } - fragment_offset += metrics->length(); - glyph_offset += metrics->Advance(data->is_vertical_text); - ++metrics; - } - return false; -} - -int SVGTextQuery::CharacterNumberAtPosition(const gfx::PointF& position) const { - CharacterNumberAtPositionData data(position); - SpatialQuery(query_root_layout_object_, &data, - CharacterNumberAtPositionCallback); - return data.CharacterNumberWithin(query_root_layout_object_); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_query.h b/third_party/blink/renderer/core/layout/svg/svg_text_query.h deleted file mode 100644 index 3349c86c..0000000 --- a/third_party/blink/renderer/core/layout/svg/svg_text_query.h +++ /dev/null
@@ -1,56 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_QUERY_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_QUERY_H_ - -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" - -namespace gfx { -class PointF; -class RectF; -} // namespace gfx - -namespace blink { - -class LayoutObject; - -class SVGTextQuery { - STACK_ALLOCATED(); - - public: - SVGTextQuery(LayoutObject* layout_object) - : query_root_layout_object_(layout_object) {} - - unsigned NumberOfCharacters() const; - float TextLength() const; - float SubStringLength(unsigned start_position, unsigned length) const; - gfx::PointF StartPositionOfCharacter(unsigned position) const; - gfx::PointF EndPositionOfCharacter(unsigned position) const; - float RotationOfCharacter(unsigned position) const; - gfx::RectF ExtentOfCharacter(unsigned position) const; - int CharacterNumberAtPosition(const gfx::PointF&) const; - - private: - LayoutObject* query_root_layout_object_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_TEXT_QUERY_H_
diff --git a/third_party/blink/renderer/core/layout/text_autosizer.cc b/third_party/blink/renderer/core/layout/text_autosizer.cc index 4ae1516..643a1c4 100644 --- a/third_party/blink/renderer/core/layout/text_autosizer.cc +++ b/third_party/blink/renderer/core/layout/text_autosizer.cc
@@ -137,7 +137,7 @@ (containing_block && containing_block->IsHorizontalWritingMode() != layout_object->IsHorizontalWritingMode()) || layout_object->StyleRef().IsDisplayReplacedType() || - layout_object->IsTextAreaIncludingNG() || + layout_object->IsTextArea() || layout_object->StyleRef().UsedUserModify() != EUserModify::kReadOnly; } @@ -792,7 +792,7 @@ // TextAreas and user-modifiable areas get a free pass to autosize regardless // of text content. - if (root->IsTextAreaIncludingNG() || + if (root->IsTextArea() || (root->Style() && root->StyleRef().UsedUserModify() != EUserModify::kReadOnly)) { cluster->has_enough_text_to_autosize_ = kHasEnoughText;
diff --git a/third_party/blink/renderer/core/loader/loader_factory_for_frame.cc b/third_party/blink/renderer/core/loader/loader_factory_for_frame.cc index 1e79dc6..f960867 100644 --- a/third_party/blink/renderer/core/loader/loader_factory_for_frame.cc +++ b/third_party/blink/renderer/core/loader/loader_factory_for_frame.cc
@@ -10,6 +10,7 @@ #include "services/network/public/cpp/wrapper_shared_url_loader_factory.h" #include "services/network/public/mojom/url_loader_factory.mojom-blink.h" #include "third_party/blink/public/common/blob/blob_utils.h" +#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h" #include "third_party/blink/public/platform/modules/service_worker/web_service_worker_network_provider.h" #include "third_party/blink/public/platform/platform.h" @@ -183,7 +184,8 @@ mojom::blink::LocalFrameHost& local_frame_host, mojo::PendingReceiver<mojom::blink::KeepAliveHandle> pending_receiver) { DCHECK(pending_receiver); - if (request.GetKeepalive() && keep_alive_handle_factory_.is_bound()) { + if (!base::FeatureList::IsEnabled(features::kKeepAliveInBrowserMigration) && + request.GetKeepalive() && keep_alive_handle_factory_.is_bound()) { keep_alive_handle_factory_->IssueKeepAliveHandle( std::move(pending_receiver)); }
diff --git a/third_party/blink/renderer/core/page/focus_controller.cc b/third_party/blink/renderer/core/page/focus_controller.cc index 452a976..6dfaea7 100644 --- a/third_party/blink/renderer/core/page/focus_controller.cc +++ b/third_party/blink/renderer/core/page/focus_controller.cc
@@ -1316,7 +1316,7 @@ return next_element; } LayoutObject* layout = next_element->GetLayoutObject(); - if (layout && layout->IsTextControlIncludingNG()) { + if (layout && layout->IsTextControl()) { // TODO(crbug.com/1320441): Extend it for radio buttons and checkboxes. return next_element; }
diff --git a/third_party/blink/renderer/core/paint/box_painter.cc b/third_party/blink/renderer/core/paint/box_painter.cc index caaeb264..5d000f9e 100644 --- a/third_party/blink/renderer/core/paint/box_painter.cc +++ b/third_party/blink/renderer/core/paint/box_painter.cc
@@ -11,6 +11,7 @@ #include "third_party/blink/renderer/core/layout/layout_box.h" #include "third_party/blink/renderer/core/layout/layout_object.h" #include "third_party/blink/renderer/core/layout/layout_theme.h" +#include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_foreign_object.h" #include "third_party/blink/renderer/core/paint/background_image_geometry.h" #include "third_party/blink/renderer/core/paint/box_decoration_data.h" #include "third_party/blink/renderer/core/paint/box_model_object_painter.h" @@ -46,9 +47,8 @@ PaintInfo child_info(paint_info); for (LayoutObject* child = layout_box_.SlowFirstChild(); child; child = child->NextSibling()) { - if (child->IsSVGForeignObjectIncludingNG()) { - SVGForeignObjectPainter(To<LayoutBlockFlow>(*child)) - .PaintLayer(paint_info); + if (auto* foreign_object = DynamicTo<LayoutNGSVGForeignObject>(child)) { + SVGForeignObjectPainter(*foreign_object).PaintLayer(paint_info); } else { child->Paint(child_info); }
diff --git a/third_party/blink/renderer/core/paint/build.gni b/third_party/blink/renderer/core/paint/build.gni index 29fd5bc..bd58729 100644 --- a/third_party/blink/renderer/core/paint/build.gni +++ b/third_party/blink/renderer/core/paint/build.gni
@@ -50,8 +50,6 @@ "embedded_content_painter.h", "embedded_object_painter.cc", "embedded_object_painter.h", - "fieldset_painter.cc", - "fieldset_painter.h", "fieldset_paint_info.cc", "fieldset_paint_info.h", "filter_effect_builder.cc", @@ -190,24 +188,16 @@ "svg_foreign_object_painter.h", "svg_image_painter.cc", "svg_image_painter.h", - "svg_inline_flow_box_painter.cc", - "svg_inline_flow_box_painter.h", - "svg_inline_text_box_painter.cc", - "svg_inline_text_box_painter.h", "svg_mask_painter.cc", "svg_mask_painter.h", "svg_model_object_painter.cc", "svg_model_object_painter.h", "svg_object_painter.cc", "svg_object_painter.h", - "svg_root_inline_box_painter.cc", - "svg_root_inline_box_painter.h", "svg_root_painter.cc", "svg_root_painter.h", "svg_shape_painter.cc", "svg_shape_painter.h", - "svg_text_painter.cc", - "svg_text_painter.h", "table_cell_painter.cc", "table_cell_painter.h", "table_cell_paint_invalidator.cc", @@ -220,8 +210,6 @@ "table_row_painter.h", "table_section_painter.cc", "table_section_painter.h", - "text_control_single_line_painter.cc", - "text_control_single_line_painter.h", "text_decoration_info.cc", "text_decoration_info.h", "text_painter_base.cc",
diff --git a/third_party/blink/renderer/core/paint/clip_path_clipper.cc b/third_party/blink/renderer/core/paint/clip_path_clipper.cc index c8f6115..e83689e9c 100644 --- a/third_party/blink/renderer/core/paint/clip_path_clipper.cc +++ b/third_party/blink/renderer/core/paint/clip_path_clipper.cc
@@ -66,8 +66,7 @@ // Is the reference box (as returned by LocalReferenceBox) for |clip_path_owner| // zoomed with EffectiveZoom()? static bool UsesZoomedReferenceBox(const LayoutObject& clip_path_owner) { - return !clip_path_owner.IsSVGChild() || - clip_path_owner.IsSVGForeignObjectIncludingNG(); + return !clip_path_owner.IsSVGChild() || clip_path_owner.IsSVGForeignObject(); } CompositedPaintStatus CompositeClipPathStatus(Node* node) {
diff --git a/third_party/blink/renderer/core/paint/css_mask_painter.cc b/third_party/blink/renderer/core/paint/css_mask_painter.cc index 29cc1a9..2dbe8cb 100644 --- a/third_party/blink/renderer/core/paint/css_mask_painter.cc +++ b/third_party/blink/renderer/core/paint/css_mask_painter.cc
@@ -25,16 +25,16 @@ if (masker) { const gfx::RectF reference_box = SVGResources::ReferenceBoxForEffects(object); - const float reference_box_zoom = object.IsSVGForeignObjectIncludingNG() - ? object.StyleRef().EffectiveZoom() - : 1; + const float reference_box_zoom = + object.IsSVGForeignObject() ? object.StyleRef().EffectiveZoom() : 1; return masker->ResourceBoundingBox(reference_box, reference_box_zoom); } } } - if (object.IsSVGChild() && !object.IsSVGForeignObjectIncludingNG()) + if (object.IsSVGChild() && !object.IsSVGForeignObject()) { return absl::nullopt; + } if (!style.HasMask()) return absl::nullopt;
diff --git a/third_party/blink/renderer/core/paint/fieldset_painter.cc b/third_party/blink/renderer/core/paint/fieldset_painter.cc deleted file mode 100644 index 5dc9676..0000000 --- a/third_party/blink/renderer/core/paint/fieldset_painter.cc +++ /dev/null
@@ -1,128 +0,0 @@ -// Copyright 2014 The Chromium Authors -// 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/core/paint/fieldset_painter.h" - -#include "third_party/blink/renderer/core/layout/layout_fieldset.h" -#include "third_party/blink/renderer/core/paint/background_image_geometry.h" -#include "third_party/blink/renderer/core/paint/box_decoration_data.h" -#include "third_party/blink/renderer/core/paint/box_model_object_painter.h" -#include "third_party/blink/renderer/core/paint/box_painter.h" -#include "third_party/blink/renderer/core/paint/fieldset_paint_info.h" -#include "third_party/blink/renderer/core/paint/paint_info.h" -#include "third_party/blink/renderer/platform/graphics/graphics_context_state_saver.h" -#include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h" - -namespace blink { - -namespace { - -FieldsetPaintInfo CreateFieldsetPaintInfo(const LayoutBox& fieldset, - const LayoutBox& legend) { - LayoutRectOutsets fieldset_borders( - fieldset.BorderTop(), fieldset.BorderRight(), - LayoutUnit(), // bottom border will always be left alone. - fieldset.BorderLeft()); - // Using legend.FrameRect() is incorrect in vertical-rl mode, but we probably - // won't fix this here which is for legacy layout. - return FieldsetPaintInfo(fieldset.StyleRef(), - PhysicalSizeToBeNoop(fieldset.Size()), - fieldset_borders, PhysicalRect(legend.FrameRect())); -} - -} // anonymous namespace - -void FieldsetPainter::PaintBoxDecorationBackground( - const PaintInfo& paint_info, - const PhysicalOffset& paint_offset) { - if (layout_fieldset_.StyleRef().Visibility() != EVisibility::kVisible) - return; - - PhysicalRect paint_rect(paint_offset, layout_fieldset_.Size()); - LayoutBox* legend = layout_fieldset_.FindInFlowLegend(); - if (!legend || paint_info.DescendantPaintingBlocked()) { - return BoxPainter(layout_fieldset_) - .PaintBoxDecorationBackground(paint_info, paint_offset); - } - - BoxDecorationData box_decoration_data(paint_info, layout_fieldset_); - // TODO(crbug.com/786475): Fieldset should not scroll. - DCHECK(!box_decoration_data.IsPaintingBackgroundInContentsSpace()); - if (box_decoration_data.ShouldPaint() && - !DrawingRecorder::UseCachedDrawingIfPossible( - paint_info.context, layout_fieldset_, paint_info.phase)) { - FieldsetPaintInfo fieldset_paint_info = - CreateFieldsetPaintInfo(layout_fieldset_, *legend); - paint_rect.Contract(fieldset_paint_info.border_outsets); - - BoxDrawingRecorder recorder(paint_info.context, layout_fieldset_, - paint_info.phase, paint_offset); - - if (box_decoration_data.ShouldPaintShadow()) { - BoxPainterBase::PaintNormalBoxShadow(paint_info, paint_rect, - layout_fieldset_.StyleRef()); - } - if (box_decoration_data.ShouldPaintBackground()) { - BackgroundImageGeometry geometry(layout_fieldset_); - BoxModelObjectPainter(layout_fieldset_) - .PaintFillLayers(paint_info, box_decoration_data.BackgroundColor(), - layout_fieldset_.StyleRef().BackgroundLayers(), - paint_rect, geometry); - } - if (box_decoration_data.ShouldPaintShadow()) { - BoxPainterBase::PaintInsetBoxShadowWithBorderRect( - paint_info, paint_rect, layout_fieldset_.StyleRef()); - } - - if (box_decoration_data.ShouldPaintBorder()) { - // Create a clipping region around the legend and paint the border as - // normal - GraphicsContext& graphics_context = paint_info.context; - GraphicsContextStateSaver state_saver(graphics_context); - - PhysicalRect legend_cutout_rect = fieldset_paint_info.legend_cutout_rect; - legend_cutout_rect.Move(paint_offset); - graphics_context.ClipOut(ToPixelSnappedRect(legend_cutout_rect)); - - Node* node = nullptr; - const LayoutObject* layout_object = &layout_fieldset_; - for (; layout_object && !node; layout_object = layout_object->Parent()) - node = layout_object->GeneratingNode(); - BoxPainterBase::PaintBorder( - layout_fieldset_, layout_fieldset_.GetDocument(), node, paint_info, - paint_rect, layout_fieldset_.StyleRef()); - } - } - - BoxPainter(layout_fieldset_) - .RecordHitTestData(paint_info, paint_rect, layout_fieldset_); - BoxPainter(layout_fieldset_) - .RecordRegionCaptureData(paint_info, paint_rect, layout_fieldset_); -} - -void FieldsetPainter::PaintMask(const PaintInfo& paint_info, - const PhysicalOffset& paint_offset) { - if (layout_fieldset_.StyleRef().Visibility() != EVisibility::kVisible || - paint_info.phase != PaintPhase::kMask) - return; - - PhysicalRect paint_rect(paint_offset, layout_fieldset_.Size()); - LayoutBox* legend = layout_fieldset_.FindInFlowLegend(); - if (!legend || paint_info.DescendantPaintingBlocked()) - return BoxPainter(layout_fieldset_).PaintMask(paint_info, paint_offset); - - if (DrawingRecorder::UseCachedDrawingIfPossible( - paint_info.context, layout_fieldset_, paint_info.phase)) - return; - - FieldsetPaintInfo fieldset_paint_info = - CreateFieldsetPaintInfo(layout_fieldset_, *legend); - paint_rect.Contract(fieldset_paint_info.border_outsets); - - BoxDrawingRecorder recorder(paint_info.context, layout_fieldset_, - paint_info.phase, paint_offset); - BoxPainter(layout_fieldset_).PaintMaskImages(paint_info, paint_rect); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/paint/fieldset_painter.h b/third_party/blink/renderer/core/paint/fieldset_painter.h deleted file mode 100644 index 1154d9a..0000000 --- a/third_party/blink/renderer/core/paint/fieldset_painter.h +++ /dev/null
@@ -1,33 +0,0 @@ -// Copyright 2014 The Chromium Authors -// 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_CORE_PAINT_FIELDSET_PAINTER_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_FIELDSET_PAINTER_H_ - -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" - -namespace blink { - -class LayoutFieldset; -struct PaintInfo; -struct PhysicalOffset; - -class FieldsetPainter { - STACK_ALLOCATED(); - - public: - FieldsetPainter(const LayoutFieldset& layout_fieldset) - : layout_fieldset_(layout_fieldset) {} - - void PaintBoxDecorationBackground(const PaintInfo&, - const PhysicalOffset& paint_offset); - void PaintMask(const PaintInfo&, const PhysicalOffset& paint_offset); - - private: - const LayoutFieldset& layout_fieldset_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_FIELDSET_PAINTER_H_
diff --git a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc index 43f8551e..b23c11c 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc
@@ -410,7 +410,7 @@ !box_fragment_.HasSelfPaintingLayer() && paint_info.phase != PaintPhase::kOverlayOverflowControls) { PaintAllPhasesAtomically(paint_info); - } else if (layout_object && layout_object->IsNGSVGForeignObject()) { + } else if (layout_object && layout_object->IsSVGForeignObject()) { ScopedSVGPaintState paint_state(*layout_object, paint_info); PaintTiming::From(layout_object->GetDocument()).MarkFirstContentfulPaint(); PaintInternal(paint_info);
diff --git a/third_party/blink/renderer/core/paint/object_paint_invalidator.cc b/third_party/blink/renderer/core/paint/object_paint_invalidator.cc index a85f271..f32b894 100644 --- a/third_party/blink/renderer/core/paint/object_paint_invalidator.cc +++ b/third_party/blink/renderer/core/paint/object_paint_invalidator.cc
@@ -80,8 +80,9 @@ return; // See layout_selection.cc SetShouldInvalidateIfNeeded() for the reason // for the IsSVGText() condition here. - if (!object_.CanBeSelectionLeaf() && !object_.IsSVGText()) + if (!object_.CanBeSelectionLeaf()) { return; + } reason = PaintInvalidationReason::kSelection; if (const auto* selection_client =
diff --git a/third_party/blink/renderer/core/paint/paint_layer.cc b/third_party/blink/renderer/core/paint/paint_layer.cc index 9216c848..b2fb2d5 100644 --- a/third_party/blink/renderer/core/paint/paint_layer.cc +++ b/third_party/blink/renderer/core/paint/paint_layer.cc
@@ -1463,7 +1463,7 @@ // foreignObject; if it weren't for that case we could test z_offset // and then DCHECK(transform_state) inside of it. DCHECK(!z_offset || transform_state || - hit_layer->GetLayoutObject().IsSVGForeignObjectIncludingNG()); + hit_layer->GetLayoutObject().IsSVGForeignObject()); if (z_offset && transform_state) { // This is actually computing our z, but that's OK because the hitLayer is // coplanar with us. @@ -1575,7 +1575,7 @@ // IsReplacedNormalFlowStacking() true for LayoutSVGForeignObject), // where the hit_test_rect has already been transformed to local coordinates. bool use_transform = false; - if (!layout_object.IsSVGForeignObjectIncludingNG() && + if (!layout_object.IsSVGForeignObject() && // Only a layer that can contain all descendants can become a transform // container. This excludes layout objects having transform nodes created // for animating opacity etc. or for backface-visibility:hidden. @@ -2037,7 +2037,7 @@ } bool PaintLayer::IsReplacedNormalFlowStacking() const { - return GetLayoutObject().IsSVGForeignObjectIncludingNG(); + return GetLayoutObject().IsSVGForeignObject(); } PaintLayer* PaintLayer::HitTestChildren( @@ -2165,7 +2165,7 @@ To<ShapeClipPathOperation>(clip_path_operation); float zoom = GetLayoutObject().StyleRef().EffectiveZoom(); DCHECK(!GetLayoutObject().IsSVGChild() || - GetLayoutObject().IsSVGForeignObjectIncludingNG()); + GetLayoutObject().IsSVGForeignObject()); return !clip_path->GetPath(reference_box, zoom).Contains(point); } DCHECK_EQ(clip_path_operation->GetType(), ClipPathOperation::kReference); @@ -2291,8 +2291,9 @@ return false; // SVG root and SVG foreign object paint atomically. - if (box->IsSVGRoot() || box->IsSVGForeignObjectIncludingNG()) + if (box->IsSVGRoot() || box->IsSVGForeignObject()) { return true; + } // Don't create subsequence for the document element because the subsequence // for LayoutView serves the same purpose. This can avoid unnecessary paint
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 497882c..65781d0 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
@@ -1554,8 +1554,7 @@ if (VisualViewportSuppliesScrollbars() || !CanHaveOverflowScrollbars(*GetLayoutBox()) || GetLayoutBox()->GetFrame()->GetSettings()->GetHideScrollbars() || - GetLayoutBox()->IsLayoutNGFieldset() || - GetLayoutBox()->IsLayoutNGFrameSet() || + GetLayoutBox()->IsFieldset() || GetLayoutBox()->IsLayoutNGFrameSet() || GetLayoutBox()->StyleRef().ScrollbarWidth() == EScrollbarWidth::kNone) { needs_horizontal_scrollbar = false; needs_vertical_scrollbar = 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 d487f4c..a94d555 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
@@ -931,7 +931,7 @@ DCHECK(object_.IsSVGChild()); // SVG does not use paint offset internally, except for SVGForeignObject which // has different SVG and HTML coordinate spaces. - DCHECK(object_.IsSVGForeignObjectIncludingNG() || + DCHECK(object_.IsSVGForeignObject() || context_.current.paint_offset.IsZero()); if (NeedsPaintPropertyUpdate()) {
diff --git a/third_party/blink/renderer/core/paint/scoped_svg_paint_state.cc b/third_party/blink/renderer/core/paint/scoped_svg_paint_state.cc index c8c7bec..c32de7e 100644 --- a/third_party/blink/renderer/core/paint/scoped_svg_paint_state.cc +++ b/third_party/blink/renderer/core/paint/scoped_svg_paint_state.cc
@@ -71,7 +71,7 @@ // LayoutSVGRoot and LayoutSVGForeignObject always have a self-painting // PaintLayer (hence comments below about PaintLayerPainter). bool is_svg_root_or_foreign_object = - object_.IsSVGRoot() || object_.IsSVGForeignObjectIncludingNG(); + object_.IsSVGRoot() || object_.IsSVGForeignObject(); if (is_svg_root_or_foreign_object) { // PaintLayerPainter takes care of clip path. DCHECK(object_.HasLayer() || !properties || !properties->ClipPathMask());
diff --git a/third_party/blink/renderer/core/paint/svg_container_painter.cc b/third_party/blink/renderer/core/paint/svg_container_painter.cc index eada7f5..5d8b2a5 100644 --- a/third_party/blink/renderer/core/paint/svg_container_painter.cc +++ b/third_party/blink/renderer/core/paint/svg_container_painter.cc
@@ -6,8 +6,8 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/renderer/core/layout/layout_box_model_object.h" +#include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_foreign_object.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_container.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_viewport_container.h" #include "third_party/blink/renderer/core/layout/svg/svg_layout_support.h" #include "third_party/blink/renderer/core/paint/object_painter.h" @@ -95,8 +95,8 @@ for (LayoutObject* child = layout_svg_container_.FirstChild(); child; child = child->NextSibling()) { - if (child->IsSVGForeignObjectIncludingNG()) { - SVGForeignObjectPainter(To<LayoutBlockFlow>(*child)) + if (auto* foreign_object = DynamicTo<LayoutNGSVGForeignObject>(child)) { + SVGForeignObjectPainter(*foreign_object) .PaintLayer(paint_info_before_filtering); } else { child->Paint(paint_info_before_filtering);
diff --git a/third_party/blink/renderer/core/paint/svg_foreign_object_painter.cc b/third_party/blink/renderer/core/paint/svg_foreign_object_painter.cc index e2ed0f3..0dcd0c7 100644 --- a/third_party/blink/renderer/core/paint/svg_foreign_object_painter.cc +++ b/third_party/blink/renderer/core/paint/svg_foreign_object_painter.cc
@@ -5,23 +5,18 @@ #include "third_party/blink/renderer/core/paint/svg_foreign_object_painter.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_foreign_object.h" +#include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_foreign_object.h" #include "third_party/blink/renderer/core/paint/block_painter.h" #include "third_party/blink/renderer/core/paint/paint_info.h" #include "third_party/blink/renderer/core/paint/paint_layer.h" #include "third_party/blink/renderer/core/paint/paint_layer_painter.h" -#include "third_party/blink/renderer/core/paint/scoped_svg_paint_state.h" -#include "third_party/blink/renderer/core/paint/timing/paint_timing.h" -#include "third_party/blink/renderer/core/svg/svg_element.h" #include "third_party/blink/renderer/platform/graphics/paint/display_item_cache_skipper.h" namespace blink { SVGForeignObjectPainter::SVGForeignObjectPainter( - const LayoutBlockFlow& layout_svg_foreign_object) - : layout_svg_foreign_object_(layout_svg_foreign_object) { - DCHECK(layout_svg_foreign_object.IsSVGForeignObjectIncludingNG()); -} + const LayoutNGSVGForeignObject& layout_svg_foreign_object) + : layout_svg_foreign_object_(layout_svg_foreign_object) {} void SVGForeignObjectPainter::PaintLayer(const PaintInfo& paint_info) { if (paint_info.phase != PaintPhase::kForeground && @@ -47,16 +42,4 @@ .Paint(paint_info.context, paint_info.GetPaintFlags()); } -void SVGForeignObjectPainter::Paint(const PaintInfo& paint_info) { - DCHECK(layout_svg_foreign_object_.IsSVGForeignObject()); - // ScopedSVGPaintState only applies masks (and clips-within-clips) here. - ScopedSVGPaintState paint_state(layout_svg_foreign_object_, paint_info); - - PaintTiming& timing = - PaintTiming::From(layout_svg_foreign_object_.GetDocument()); - timing.MarkFirstContentfulPaint(); - - BlockPainter(layout_svg_foreign_object_).Paint(paint_info); -} - } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/svg_foreign_object_painter.h b/third_party/blink/renderer/core/paint/svg_foreign_object_painter.h index fa8a9f0..9073ff2 100644 --- a/third_party/blink/renderer/core/paint/svg_foreign_object_painter.h +++ b/third_party/blink/renderer/core/paint/svg_foreign_object_painter.h
@@ -10,22 +10,19 @@ namespace blink { struct PaintInfo; -class LayoutBlockFlow; +class LayoutNGSVGForeignObject; class SVGForeignObjectPainter { STACK_ALLOCATED(); public: explicit SVGForeignObjectPainter( - const LayoutBlockFlow& layout_svg_foreign_object); + const LayoutNGSVGForeignObject& layout_svg_foreign_object); - void Paint(const PaintInfo&); void PaintLayer(const PaintInfo& paint_info); private: - // layout_svg_foreign_object_ must be a LayoutSVGForeignObject or a - // LayoutNGSVGForeignObject. - const LayoutBlockFlow& layout_svg_foreign_object_; + const LayoutNGSVGForeignObject& layout_svg_foreign_object_; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/svg_inline_flow_box_painter.cc b/third_party/blink/renderer/core/paint/svg_inline_flow_box_painter.cc deleted file mode 100644 index 542b46e..0000000 --- a/third_party/blink/renderer/core/paint/svg_inline_flow_box_painter.cc +++ /dev/null
@@ -1,46 +0,0 @@ -// Copyright 2014 The Chromium Authors -// 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/core/paint/svg_inline_flow_box_painter.h" - -#include "third_party/blink/renderer/core/layout/api/line_layout_api_shim.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_flow_box.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.h" -#include "third_party/blink/renderer/core/paint/paint_info.h" -#include "third_party/blink/renderer/core/paint/scoped_svg_paint_state.h" -#include "third_party/blink/renderer/core/paint/svg_inline_text_box_painter.h" - -namespace blink { - -void SVGInlineFlowBoxPainter::PaintSelectionBackground( - const PaintInfo& paint_info) { - DCHECK(paint_info.phase == PaintPhase::kForeground || - paint_info.phase == PaintPhase::kSelectionDragImage); - - for (InlineBox* child = svg_inline_flow_box_.FirstChild(); child; - child = child->NextOnLine()) { - if (auto* svg_inline_text_box = DynamicTo<SVGInlineTextBox>(child)) { - SVGInlineTextBoxPainter(*svg_inline_text_box) - .PaintSelectionBackground(paint_info); - } else if (auto* svg_inline_flow_box = DynamicTo<SVGInlineFlowBox>(child)) { - SVGInlineFlowBoxPainter(*svg_inline_flow_box) - .PaintSelectionBackground(paint_info); - } - } -} - -void SVGInlineFlowBoxPainter::Paint(const PaintInfo& paint_info, - const PhysicalOffset& paint_offset) { - DCHECK(paint_info.phase == PaintPhase::kForeground || - paint_info.phase == PaintPhase::kSelectionDragImage); - - ScopedSVGPaintState paint_state(*LineLayoutAPIShim::ConstLayoutObjectFrom( - svg_inline_flow_box_.GetLineLayoutItem()), - paint_info, svg_inline_flow_box_); - for (InlineBox* child = svg_inline_flow_box_.FirstChild(); child; - child = child->NextOnLine()) - child->Paint(paint_info, paint_offset, LayoutUnit(), LayoutUnit()); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/paint/svg_inline_flow_box_painter.h b/third_party/blink/renderer/core/paint/svg_inline_flow_box_painter.h deleted file mode 100644 index 7af4ac0..0000000 --- a/third_party/blink/renderer/core/paint/svg_inline_flow_box_painter.h +++ /dev/null
@@ -1,32 +0,0 @@ -// Copyright 2014 The Chromium Authors -// 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_CORE_PAINT_SVG_INLINE_FLOW_BOX_PAINTER_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_SVG_INLINE_FLOW_BOX_PAINTER_H_ - -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" - -namespace blink { - -class SVGInlineFlowBox; -struct PaintInfo; -struct PhysicalOffset; - -class SVGInlineFlowBoxPainter { - STACK_ALLOCATED(); - - public: - SVGInlineFlowBoxPainter(const SVGInlineFlowBox& svg_inline_flow_box) - : svg_inline_flow_box_(svg_inline_flow_box) {} - - void PaintSelectionBackground(const PaintInfo&); - void Paint(const PaintInfo&, const PhysicalOffset& paint_offset); - - private: - const SVGInlineFlowBox& svg_inline_flow_box_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_SVG_INLINE_FLOW_BOX_PAINTER_H_
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 deleted file mode 100644 index 7bea819..0000000 --- a/third_party/blink/renderer/core/paint/svg_inline_text_box_painter.cc +++ /dev/null
@@ -1,797 +0,0 @@ -// Copyright 2014 The Chromium Authors -// 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/core/paint/svg_inline_text_box_painter.h" - -#include <memory> - -#include "base/types/optional_util.h" -#include "third_party/abseil-cpp/absl/types/optional.h" -#include "third_party/blink/renderer/core/editing/editor.h" -#include "third_party/blink/renderer/core/editing/markers/document_marker_controller.h" -#include "third_party/blink/renderer/core/editing/markers/text_match_marker.h" -#include "third_party/blink/renderer/core/frame/local_frame.h" -#include "third_party/blink/renderer/core/layout/api/line_layout_api_shim.h" -#include "third_party/blink/renderer/core/layout/layout_theme.h" -#include "third_party/blink/renderer/core/layout/line/inline_flow_box.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.h" -#include "third_party/blink/renderer/core/layout/svg/svg_layout_support.h" -#include "third_party/blink/renderer/core/layout/svg/svg_resources.h" -#include "third_party/blink/renderer/core/paint/highlight_painting_utils.h" -#include "third_party/blink/renderer/core/paint/inline_text_box_painter.h" -#include "third_party/blink/renderer/core/paint/paint_auto_dark_mode.h" -#include "third_party/blink/renderer/core/paint/paint_info.h" -#include "third_party/blink/renderer/core/paint/selection_bounds_recorder.h" -#include "third_party/blink/renderer/core/paint/svg_object_painter.h" -#include "third_party/blink/renderer/core/paint/text_painter_base.h" -#include "third_party/blink/renderer/core/paint/timing/paint_timing.h" -#include "third_party/blink/renderer/core/paint/timing/paint_timing_detector.h" -#include "third_party/blink/renderer/core/style/applied_text_decoration.h" -#include "third_party/blink/renderer/core/style/shadow_list.h" -#include "third_party/blink/renderer/core/svg/svg_element.h" -#include "third_party/blink/renderer/platform/fonts/text_run_paint_info.h" -#include "third_party/blink/renderer/platform/graphics/graphics_context_state_saver.h" -#include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h" -#include "ui/gfx/geometry/rect_conversions.h" - -namespace blink { - -static inline bool TextShouldBePainted( - const LayoutSVGInlineText& text_layout_object) { - // Font::pixelSize(), returns FontDescription::computedPixelSize(), which - // returns "int(x + 0.5)". If the absolute font size on screen is below - // x=0.5, don't render anything. - return text_layout_object.ScaledFont() - .GetFontDescription() - .ComputedPixelSize(); -} - -bool SVGInlineTextBoxPainter::ShouldPaintSelection( - const PaintInfo& paint_info) const { - // Don't paint selections when printing. - if (InlineLayoutObject().GetDocument().Printing()) - return false; - // Don't paint selections when rendering a mask, clip-path (as a mask), - // pattern or feImage (element reference.) - if (paint_info.IsRenderingResourceSubtree()) - return false; - return svg_inline_text_box_.IsSelected(); -} - -LayoutObject& SVGInlineTextBoxPainter::InlineLayoutObject() const { - return *LineLayoutAPIShim::LayoutObjectFrom( - svg_inline_text_box_.GetLineLayoutItem()); -} - -LayoutObject& SVGInlineTextBoxPainter::ParentInlineLayoutObject() const { - return *LineLayoutAPIShim::LayoutObjectFrom( - svg_inline_text_box_.Parent()->GetLineLayoutItem()); -} - -LayoutSVGInlineText& SVGInlineTextBoxPainter::InlineText() const { - return To<LayoutSVGInlineText>(InlineLayoutObject()); -} - -void SVGInlineTextBoxPainter::Paint(const PaintInfo& paint_info, - const PhysicalOffset& paint_offset) { - DCHECK(paint_info.phase == PaintPhase::kForeground || - paint_info.phase == PaintPhase::kSelectionDragImage); - DCHECK(svg_inline_text_box_.Truncation() == kCNoTruncation); - - if (svg_inline_text_box_.GetLineLayoutItem().StyleRef().Visibility() != - EVisibility::kVisible || - !svg_inline_text_box_.Len()) - return; - - // We're explicitly not supporting composition & custom underlines and custom - // highlighters -- unlike InlineTextBox. If we ever need that for SVG, it's - // very easy to refactor and reuse the code. - - bool have_selection = ShouldPaintSelection(paint_info); - if (!have_selection && paint_info.phase == PaintPhase::kSelectionDragImage) - return; - - LayoutObject& parent_layout_object = ParentInlineLayoutObject(); - const ComputedStyle& style = parent_layout_object.StyleRef(); - - absl::optional<SelectionBoundsRecorder> start_bounds_recorder; - absl::optional<SelectionBoundsRecorder> end_bounds_recorder; - if (have_selection && paint_info.phase == PaintPhase::kForeground) { - const FrameSelection& frame_selection = - InlineLayoutObject().GetFrame()->Selection(); - SelectionState selection_state = - frame_selection.ComputeLayoutSelectionStateForInlineTextBox( - svg_inline_text_box_); - if (SelectionBoundsRecorder::ShouldRecordSelection(frame_selection, - selection_state)) { - // Even when the selection state is kStartAndEnd for the - // SVGInlineTextBox, we have to record the start and end bounds - // separately since the selection rects are calculated per-fragment, and - // the start and end of the selection don't necessarily occur in the same - // fragment (i.e. don't have the same selection rect). - int start_position, end_position; - svg_inline_text_box_.SelectionStartEnd(start_position, end_position); - if (selection_state == SelectionState::kStart || - selection_state == SelectionState::kStartAndEnd) { - RecordSelectionBoundsForRange( - start_position, start_position + 1, SelectionState::kStart, style, - paint_info.context.GetPaintController(), start_bounds_recorder); - } - - if (selection_state == SelectionState::kStartAndEnd || - selection_state == SelectionState::kEnd) { - RecordSelectionBoundsForRange( - end_position - 1, end_position, SelectionState::kEnd, style, - paint_info.context.GetPaintController(), end_bounds_recorder); - } - } - } - - LayoutSVGInlineText& text_layout_object = InlineText(); - if (!TextShouldBePainted(text_layout_object)) - return; - - if (!DrawingRecorder::UseCachedDrawingIfPossible( - paint_info.context, svg_inline_text_box_, paint_info.phase)) { - DrawingRecorder recorder( - paint_info.context, svg_inline_text_box_, paint_info.phase, - gfx::ToEnclosingRect( - parent_layout_object.VisualRectInLocalSVGCoordinates())); - InlineTextBoxPainter text_painter(svg_inline_text_box_); - const DocumentMarkerVector& markers_to_paint = - text_painter.ComputeMarkersToPaint(); - text_painter.PaintDocumentMarkers( - markers_to_paint, paint_info, paint_offset, style, - text_layout_object.ScaledFont(), DocumentMarkerPaintPhase::kBackground); - - if (!svg_inline_text_box_.TextFragments().empty()) - PaintTextFragments(paint_info, parent_layout_object); - - text_painter.PaintDocumentMarkers( - markers_to_paint, paint_info, paint_offset, style, - text_layout_object.ScaledFont(), DocumentMarkerPaintPhase::kForeground); - } -} - -void SVGInlineTextBoxPainter::PaintTextFragments( - const PaintInfo& paint_info, - LayoutObject& parent_layout_object) { - const ComputedStyle& style = parent_layout_object.StyleRef(); - - bool has_fill = style.HasFill(); - bool has_visible_stroke = style.HasVisibleStroke(); - - const ComputedStyle* selection_style = &style; - bool should_paint_selection = ShouldPaintSelection(paint_info); - if (should_paint_selection) { - selection_style = parent_layout_object.GetSelectionStyle(); - if (selection_style) { - if (!has_fill) - has_fill = selection_style->HasFill(); - if (!has_visible_stroke) - has_visible_stroke = selection_style->HasVisibleStroke(); - } else { - selection_style = &style; - } - } - - if (paint_info.IsRenderingClipPathAsMaskImage()) { - has_fill = true; - has_visible_stroke = false; - } - - for (const SVGTextFragment& fragment : svg_inline_text_box_.TextFragments()) { - GraphicsContextStateSaver state_saver(paint_info.context, false); - absl::optional<AffineTransform> shader_transform; - if (fragment.IsTransformed()) { - state_saver.Save(); - const auto fragment_transform = fragment.BuildFragmentTransform(); - paint_info.context.ConcatCTM(fragment_transform); - DCHECK(fragment_transform.IsInvertible()); - shader_transform = fragment_transform.Inverse(); - } - - // Spec: All text decorations except line-through should be drawn before the - // text is filled and stroked; thus, the text is rendered on top of these - // decorations. - const Vector<AppliedTextDecoration, 1>& decorations = - style.AppliedTextDecorations(); - for (const AppliedTextDecoration& decoration : decorations) { - if (EnumHasFlags(decoration.Lines(), TextDecorationLine::kUnderline)) - PaintDecoration(paint_info, TextDecorationLine::kUnderline, fragment); - if (EnumHasFlags(decoration.Lines(), TextDecorationLine::kOverline)) - PaintDecoration(paint_info, TextDecorationLine::kOverline, fragment); - } - - for (int i = 0; i < 3; i++) { - switch (style.PaintOrderType(i)) { - case PT_FILL: - if (has_fill) { - PaintText(paint_info, style, *selection_style, fragment, - kApplyToFillMode, should_paint_selection, - base::OptionalToPtr(shader_transform)); - } - break; - case PT_STROKE: - if (has_visible_stroke) { - PaintText(paint_info, style, *selection_style, fragment, - kApplyToStrokeMode, should_paint_selection, - base::OptionalToPtr(shader_transform)); - } - break; - case PT_MARKERS: - // Markers don't apply to text - break; - default: - NOTREACHED(); - break; - } - } - - // Spec: Line-through should be drawn after the text is filled and stroked; - // thus, the line-through is rendered on top of the text. - for (const AppliedTextDecoration& decoration : decorations) { - if (EnumHasFlags(decoration.Lines(), TextDecorationLine::kLineThrough)) - PaintDecoration(paint_info, TextDecorationLine::kLineThrough, fragment); - } - } -} - -void SVGInlineTextBoxPainter::PaintSelectionBackground( - const PaintInfo& paint_info) { - auto layout_item = svg_inline_text_box_.GetLineLayoutItem(); - if (layout_item.StyleRef().Visibility() != EVisibility::kVisible) - return; - - DCHECK(!layout_item.GetDocument().Printing()); - - if (paint_info.phase == PaintPhase::kSelectionDragImage || - !ShouldPaintSelection(paint_info)) - return; - - Color background_color = HighlightPaintingUtils::HighlightBackgroundColor( - layout_item.GetDocument(), layout_item.StyleRef(), layout_item.GetNode(), - absl::nullopt, kPseudoIdSelection); - if (!background_color.Alpha()) - return; - - LayoutSVGInlineText& text_layout_object = InlineText(); - if (!TextShouldBePainted(text_layout_object)) - return; - - const ComputedStyle& style = - svg_inline_text_box_.Parent()->GetLineLayoutItem().StyleRef(); - - int start_position, end_position; - svg_inline_text_box_.SelectionStartEnd(start_position, end_position); - - const Vector<SVGTextFragmentWithRange> fragment_info_list = - CollectFragmentsInRange(start_position, end_position); - for (const SVGTextFragmentWithRange& fragment_with_range : - fragment_info_list) { - const SVGTextFragment& fragment = fragment_with_range.fragment; - GraphicsContextStateSaver state_saver(paint_info.context); - if (fragment.IsTransformed()) - paint_info.context.ConcatCTM(fragment.BuildFragmentTransform()); - - paint_info.context.SetFillColor(background_color); - paint_info.context.FillRect( - svg_inline_text_box_.SelectionRectForTextFragment( - fragment, fragment_with_range.start_position, - fragment_with_range.end_position, style), - background_color, - PaintAutoDarkMode(style, DarkModeFilter::ElementRole::kSVG)); - } -} - -static inline LayoutObject* FindLayoutObjectDefininingTextDecoration( - InlineFlowBox* parent_box) { - // Lookup first layout object in parent hierarchy which has text-decoration - // set. - LayoutObject* layout_object = nullptr; - while (parent_box) { - layout_object = - LineLayoutAPIShim::LayoutObjectFrom(parent_box->GetLineLayoutItem()); - - if (layout_object->Style() && - layout_object->StyleRef().GetTextDecorationLine() != - TextDecorationLine::kNone) - break; - - parent_box = parent_box->Parent(); - } - - DCHECK(layout_object); - return layout_object; -} - -// Offset from the baseline for |decoration|. Positive offsets are above the -// baseline. -static inline float BaselineOffsetForDecoration(TextDecorationLine decoration, - const FontMetrics& font_metrics, - float thickness) { - // FIXME: For SVG Fonts we need to use the attributes defined in the - // <font-face> if specified. - // Compatible with Batik/Presto. - if (decoration == TextDecorationLine::kUnderline) - return -thickness * 1.5f; - if (decoration == TextDecorationLine::kOverline) - return font_metrics.FloatAscent() - thickness; - if (decoration == TextDecorationLine::kLineThrough) - return font_metrics.FloatAscent() * 3 / 8.0f; - - NOTREACHED(); - return 0.0f; -} - -static inline float ThicknessForDecoration(TextDecorationLine, - const Font& font) { - // FIXME: For SVG Fonts we need to use the attributes defined in the - // <font-face> if specified. - // Compatible with Batik/Presto - return font.GetFontDescription().ComputedSize() / 20.0f; -} - -void SVGInlineTextBoxPainter::PaintDecoration(const PaintInfo& paint_info, - TextDecorationLine decoration, - const SVGTextFragment& fragment) { - if (!svg_inline_text_box_.GetLineLayoutItem() - .StyleRef() - .HasAppliedTextDecorations()) { - return; - } - - if (fragment.width <= 0) - return; - - // Find out which style defined the text-decoration, as its fill/stroke - // properties have to be used for drawing instead of ours. - LayoutObject* decoration_layout_object = - FindLayoutObjectDefininingTextDecoration(svg_inline_text_box_.Parent()); - const ComputedStyle& decoration_style = decoration_layout_object->StyleRef(); - - if (decoration_style.Visibility() != EVisibility::kVisible) - return; - - float scaling_factor = 1; - Font scaled_font; - LayoutSVGInlineText::ComputeNewScaledFontForStyle( - *decoration_layout_object, scaling_factor, scaled_font); - DCHECK(scaling_factor); - - float thickness = ThicknessForDecoration(decoration, scaled_font); - if (thickness <= 0) - return; - - const SimpleFontData* font_data = scaled_font.PrimaryFont(); - DCHECK(font_data); - if (!font_data) - return; - - float decoration_offset = BaselineOffsetForDecoration( - decoration, font_data->GetFontMetrics(), thickness); - gfx::PointF decoration_origin( - fragment.x, fragment.y - decoration_offset / scaling_factor); - - Path path; - path.AddRect( - gfx::RectF(decoration_origin, - gfx::SizeF(fragment.width, thickness / scaling_factor))); - - AutoDarkMode auto_dark_mode( - PaintAutoDarkMode(decoration_style, DarkModeFilter::ElementRole::kSVG)); - - for (int i = 0; i < 3; i++) { - switch (decoration_style.PaintOrderType(i)) { - case PT_FILL: - if (decoration_style.HasFill()) { - cc::PaintFlags fill_flags; - if (!SVGObjectPainter(*decoration_layout_object) - .PreparePaint(paint_info.IsRenderingClipPathAsMaskImage(), - decoration_style, kApplyToFillMode, - fill_flags)) { - break; - } - fill_flags.setAntiAlias(true); - paint_info.context.DrawPath(path.GetSkPath(), fill_flags, - auto_dark_mode); - } - break; - case PT_STROKE: - if (decoration_style.HasVisibleStroke()) { - cc::PaintFlags stroke_flags; - if (!SVGObjectPainter(*decoration_layout_object) - .PreparePaint(paint_info.IsRenderingClipPathAsMaskImage(), - decoration_style, kApplyToStrokeMode, - stroke_flags)) { - break; - } - stroke_flags.setAntiAlias(true); - float stroke_scale_factor = decoration_style.VectorEffect() == - EVectorEffect::kNonScalingStroke - ? 1 / scaling_factor - : 1; - StrokeData stroke_data; - SVGLayoutSupport::ApplyStrokeStyleToStrokeData( - stroke_data, decoration_style, *decoration_layout_object, - stroke_scale_factor); - if (stroke_scale_factor != 1) - stroke_data.SetThickness(stroke_data.Thickness() * - stroke_scale_factor); - stroke_data.SetupPaint(&stroke_flags); - paint_info.context.DrawPath(path.GetSkPath(), stroke_flags, - auto_dark_mode); - } - break; - case PT_MARKERS: - break; - default: - NOTREACHED(); - } - } -} - -bool SVGInlineTextBoxPainter::SetupTextPaint( - const PaintInfo& paint_info, - const ComputedStyle& style, - LayoutSVGResourceMode resource_mode, - cc::PaintFlags& flags, - const AffineTransform* shader_transform) { - LayoutSVGInlineText& text_layout_object = InlineText(); - - float scaling_factor = text_layout_object.ScalingFactor(); - DCHECK(scaling_factor); - - absl::optional<AffineTransform> paint_server_transform; - - if (scaling_factor != 1 || shader_transform) { - paint_server_transform.emplace(); - - // Adjust the paint-server coordinate space. - paint_server_transform->Scale(scaling_factor); - - if (shader_transform) - paint_server_transform->PreConcat(*shader_transform); - } - - if (!SVGObjectPainter(ParentInlineLayoutObject()) - .PreparePaint(paint_info.IsRenderingClipPathAsMaskImage(), style, - resource_mode, flags, - base::OptionalToPtr(paint_server_transform))) { - return false; - } - - flags.setAntiAlias(true); - - if (style.TextShadow() && - // Text shadows are disabled when printing. http://crbug.com/258321 - !InlineLayoutObject().GetDocument().Printing()) { - flags.setLooper(TextPainterBase::CreateDrawLooper( - style.TextShadow(), DrawLooperBuilder::kShadowRespectsAlpha, - style.VisitedDependentColor(GetCSSPropertyColor()), - style.UsedColorScheme())); - } - - if (resource_mode == kApplyToStrokeMode) { - // The stroke geometry needs be generated based on the scaled font. - float stroke_scale_factor = - style.VectorEffect() != EVectorEffect::kNonScalingStroke - ? scaling_factor - : 1; - StrokeData stroke_data; - SVGLayoutSupport::ApplyStrokeStyleToStrokeData( - stroke_data, style, ParentInlineLayoutObject(), stroke_scale_factor); - if (stroke_scale_factor != 1) - stroke_data.SetThickness(stroke_data.Thickness() * stroke_scale_factor); - stroke_data.SetupPaint(&flags); - } - return true; -} - -void SVGInlineTextBoxPainter::PaintText(const PaintInfo& paint_info, - TextRun& text_run, - const SVGTextFragment& fragment, - int start_position, - int end_position, - const cc::PaintFlags& flags) { - LayoutSVGInlineText& text_layout_object = InlineText(); - const Font& scaled_font = text_layout_object.ScaledFont(); - - float scaling_factor = text_layout_object.ScalingFactor(); - DCHECK(scaling_factor); - - gfx::PointF text_origin(fragment.x, fragment.y); - - GraphicsContext& context = paint_info.context; - GraphicsContextStateSaver state_saver(context, false); - if (scaling_factor != 1) { - text_origin.Scale(scaling_factor, scaling_factor); - state_saver.Save(); - context.Scale(1 / scaling_factor, 1 / scaling_factor); - } - - TextRunPaintInfo text_run_paint_info(text_run); - text_run_paint_info.from = start_position; - text_run_paint_info.to = end_position; - - context.DrawText(scaled_font, text_run_paint_info, text_origin, flags, - text_layout_object.EnsureNodeId(), - PaintAutoDarkMode(text_layout_object.StyleRef(), - DarkModeFilter::ElementRole::kSVG)); - // TODO(npm): Check that there are non-whitespace characters. See - // crbug.com/788444. - context.GetPaintController().SetTextPainted(); - - if (!scaled_font.ShouldSkipDrawing()) { - PaintTiming& timing = PaintTiming::From(text_layout_object.GetDocument()); - timing.MarkFirstContentfulPaint(); - PaintTimingDetector::NotifyTextPaint(gfx::ToEnclosingRect( - InlineLayoutObject().VisualRectInLocalSVGCoordinates())); - } -} - -namespace { - -class SelectionStyleScope { - STACK_ALLOCATED(); - - public: - SelectionStyleScope(LayoutObject&, - const ComputedStyle& style, - const ComputedStyle& selection_style); - SelectionStyleScope(const SelectionStyleScope&) = delete; - SelectionStyleScope& operator=(const SelectionStyleScope) = delete; - ~SelectionStyleScope(); - - private: - LayoutObject& layout_object_; - const ComputedStyle& selection_style_; - const bool styles_are_equal_; -}; - -SelectionStyleScope::SelectionStyleScope(LayoutObject& layout_object, - const ComputedStyle& style, - const ComputedStyle& selection_style) - : layout_object_(layout_object), - selection_style_(selection_style), - styles_are_equal_(style == selection_style) { - if (styles_are_equal_) - return; - DCHECK(IsA<SVGElement>(layout_object.GetNode()) && - !layout_object.IsSVGInlineText()); - SVGResources::UpdatePaints(layout_object_, nullptr, selection_style_); -} - -SelectionStyleScope::~SelectionStyleScope() { - if (styles_are_equal_) - return; - SVGResources::ClearPaints(layout_object_, &selection_style_); -} - -} // namespace - -void SVGInlineTextBoxPainter::PaintText( - const PaintInfo& paint_info, - const ComputedStyle& style, - const ComputedStyle& selection_style, - const SVGTextFragment& fragment, - LayoutSVGResourceMode resource_mode, - bool should_paint_selection, - const AffineTransform* shader_transform) { - int start_position = 0; - int end_position = 0; - if (should_paint_selection) { - svg_inline_text_box_.SelectionStartEnd(start_position, end_position); - should_paint_selection = - svg_inline_text_box_.MapStartEndPositionsIntoFragmentCoordinates( - fragment, start_position, end_position); - } - - // Fast path if there is no selection, just draw the whole chunk part using - // the regular style. - TextRun text_run = svg_inline_text_box_.ConstructTextRun(style, fragment); - if (!should_paint_selection || start_position >= end_position) { - cc::PaintFlags flags; - if (SetupTextPaint(paint_info, style, resource_mode, flags, - shader_transform)) - PaintText(paint_info, text_run, fragment, 0, fragment.length, flags); - return; - } - - // Eventually draw text using regular style until the start position of the - // selection. - bool paint_selected_text_only = - paint_info.phase == PaintPhase::kSelectionDragImage; - if (start_position > 0 && !paint_selected_text_only) { - cc::PaintFlags flags; - if (SetupTextPaint(paint_info, style, resource_mode, flags, - shader_transform)) - PaintText(paint_info, text_run, fragment, 0, start_position, flags); - } - - // Draw text using selection style from the start to the end position of the - // selection. - { - SelectionStyleScope scope(ParentInlineLayoutObject(), style, - selection_style); - cc::PaintFlags flags; - if (SetupTextPaint(paint_info, selection_style, resource_mode, flags, - shader_transform)) { - PaintText(paint_info, text_run, fragment, start_position, end_position, - flags); - } - } - - // Eventually draw text using regular style from the end position of the - // selection to the end of the current chunk part. - if (end_position < static_cast<int>(fragment.length) && - !paint_selected_text_only) { - cc::PaintFlags flags; - if (SetupTextPaint(paint_info, style, resource_mode, flags, - shader_transform)) { - PaintText(paint_info, text_run, fragment, end_position, fragment.length, - flags); - } - } -} - -Vector<SVGTextFragmentWithRange> SVGInlineTextBoxPainter::CollectTextMatches( - const DocumentMarker& marker) const { - const Vector<SVGTextFragmentWithRange> empty_text_match_list; - - // SVG does not support grammar or spellcheck markers, so skip anything but - // TextFragmentMarker and TextMatchMarker types. - if (marker.GetType() != DocumentMarker::kTextMatch && - marker.GetType() != DocumentMarker::kTextFragment) - return empty_text_match_list; - - if (!InlineLayoutObject() - .GetFrame() - ->GetEditor() - .MarkedTextMatchesAreHighlighted()) - return empty_text_match_list; - - int marker_start_position = - std::max<int>(marker.StartOffset() - svg_inline_text_box_.Start(), 0); - int marker_end_position = - std::min<int>(marker.EndOffset() - svg_inline_text_box_.Start(), - svg_inline_text_box_.Len()); - - if (marker_start_position >= marker_end_position) - return empty_text_match_list; - - return CollectFragmentsInRange(marker_start_position, marker_end_position); -} - -Vector<SVGTextFragmentWithRange> -SVGInlineTextBoxPainter::CollectFragmentsInRange(int start_position, - int end_position) const { - Vector<SVGTextFragmentWithRange> fragment_info_list; - for (const SVGTextFragment& fragment : svg_inline_text_box_.TextFragments()) { - // TODO(ramya.v): If these can't be negative we should use unsigned. - int fragment_start_position = start_position; - int fragment_end_position = end_position; - if (!svg_inline_text_box_.MapStartEndPositionsIntoFragmentCoordinates( - fragment, fragment_start_position, fragment_end_position)) - continue; - - fragment_info_list.push_back(SVGTextFragmentWithRange( - fragment, fragment_start_position, fragment_end_position)); - } - return fragment_info_list; -} - -void SVGInlineTextBoxPainter::PaintTextMarkerForeground( - const PaintInfo& paint_info, - const PhysicalOffset& point, - const DocumentMarker& marker, - const ComputedStyle& style, - const Font& font) { - const Vector<SVGTextFragmentWithRange> text_match_info_list = - CollectTextMatches(marker); - if (text_match_info_list.empty()) - return; - - Color text_color = LayoutTheme::GetTheme().PlatformTextSearchColor( - marker.GetType() == DocumentMarker::kTextMatch - ? To<TextMatchMarker>(marker).IsActiveMatch() - : false, - style.UsedColorScheme()); - - cc::PaintFlags fill_flags; - fill_flags.setColor(text_color.Rgb()); - fill_flags.setAntiAlias(true); - - cc::PaintFlags stroke_flags; - bool should_paint_stroke = false; - if (SetupTextPaint(paint_info, style, kApplyToStrokeMode, stroke_flags, - nullptr)) { - should_paint_stroke = true; - stroke_flags.setLooper(nullptr); - stroke_flags.setColor(text_color.Rgb()); - } - - for (const SVGTextFragmentWithRange& text_match_info : text_match_info_list) { - const SVGTextFragment& fragment = text_match_info.fragment; - GraphicsContextStateSaver state_saver(paint_info.context); - if (fragment.IsTransformed()) - paint_info.context.ConcatCTM(fragment.BuildFragmentTransform()); - - TextRun text_run = svg_inline_text_box_.ConstructTextRun(style, fragment); - PaintText(paint_info, text_run, fragment, text_match_info.start_position, - text_match_info.end_position, fill_flags); - if (should_paint_stroke) { - PaintText(paint_info, text_run, fragment, text_match_info.start_position, - text_match_info.end_position, stroke_flags); - } - } -} - -void SVGInlineTextBoxPainter::PaintTextMarkerBackground( - const PaintInfo& paint_info, - const PhysicalOffset& point, - const DocumentMarker& marker, - const ComputedStyle& style, - const Font& font) { - const Vector<SVGTextFragmentWithRange> text_match_info_list = - CollectTextMatches(marker); - if (text_match_info_list.empty()) - return; - - Color color = LayoutTheme::GetTheme().PlatformTextSearchHighlightColor( - marker.GetType() == DocumentMarker::kTextMatch - ? To<TextMatchMarker>(marker).IsActiveMatch() - : false, - style.UsedColorScheme()); - for (const SVGTextFragmentWithRange& text_match_info : text_match_info_list) { - const SVGTextFragment& fragment = text_match_info.fragment; - - GraphicsContextStateSaver state_saver(paint_info.context, false); - if (fragment.IsTransformed()) { - state_saver.Save(); - paint_info.context.ConcatCTM(fragment.BuildFragmentTransform()); - } - gfx::RectF fragment_rect = - svg_inline_text_box_.SelectionRectForTextFragment( - fragment, text_match_info.start_position, - text_match_info.end_position, style); - paint_info.context.SetFillColor(color); - paint_info.context.FillRect( - fragment_rect, - PaintAutoDarkMode(style, DarkModeFilter::ElementRole::kSVG)); - } -} - -void SVGInlineTextBoxPainter::RecordSelectionBoundsForRange( - int start_position, - int end_position, - SelectionState selection_state, - const ComputedStyle& style, - PaintController& paint_controller, - absl::optional<SelectionBoundsRecorder>& bounds_recorder) { - const Vector<SVGTextFragmentWithRange> fragment_info_list = - CollectFragmentsInRange(start_position, end_position); - // We expect at most single fragment for which to record the selection rect. - // There can be no fragments when the identified selection position is at the - // end of an SVGInlineTextBox (selection_state is still kStart, but no - // selection is painted). - DCHECK_LE(fragment_info_list.size(), 1u); - if (fragment_info_list.size()) { - const SVGTextFragmentWithRange& fragment_with_range = fragment_info_list[0]; - const SVGTextFragment& fragment = fragment_with_range.fragment; - PhysicalRect selection_rect = PhysicalRect::EnclosingRect( - svg_inline_text_box_.SelectionRectForTextFragment( - fragment, fragment_with_range.start_position, - fragment_with_range.end_position, style)); - TextDirection direction = svg_inline_text_box_.IsLeftToRightDirection() - ? TextDirection::kLtr - : TextDirection::kRtl; - bounds_recorder.emplace(selection_state, selection_rect, paint_controller, - direction, style.GetWritingMode(), - InlineLayoutObject()); - } -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/paint/svg_inline_text_box_painter.h b/third_party/blink/renderer/core/paint/svg_inline_text_box_painter.h deleted file mode 100644 index 2d32144d..0000000 --- a/third_party/blink/renderer/core/paint/svg_inline_text_box_painter.h +++ /dev/null
@@ -1,107 +0,0 @@ -// Copyright 2014 The Chromium Authors -// 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_CORE_PAINT_SVG_INLINE_TEXT_BOX_PAINTER_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_SVG_INLINE_TEXT_BOX_PAINTER_H_ - -#include "third_party/abseil-cpp/absl/types/optional.h" -#include "third_party/blink/renderer/core/paint/svg_object_painter.h" -#include "third_party/blink/renderer/core/style/computed_style_constants.h" -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" - -namespace blink { - -class AffineTransform; -class ComputedStyle; -class DocumentMarker; -class Font; -class LayoutSVGInlineText; -class SelectionBoundsRecorder; -class SVGInlineTextBox; -class TextRun; -struct PaintInfo; -struct PhysicalOffset; -struct SVGTextFragment; - -struct SVGTextFragmentWithRange { - DISALLOW_NEW(); - - public: - SVGTextFragmentWithRange(const SVGTextFragment& fragment, - int start_position, - int end_position) - : fragment(fragment), - start_position(start_position), - end_position(end_position) {} - const SVGTextFragment& fragment; - int start_position; - int end_position; -}; - -class SVGInlineTextBoxPainter { - STACK_ALLOCATED(); - - public: - SVGInlineTextBoxPainter(const SVGInlineTextBox& svg_inline_text_box) - : svg_inline_text_box_(svg_inline_text_box) {} - void Paint(const PaintInfo&, const PhysicalOffset& paint_offset); - void PaintSelectionBackground(const PaintInfo&); - void PaintTextMarkerForeground(const PaintInfo&, - const PhysicalOffset&, - const DocumentMarker&, - const ComputedStyle&, - const Font&); - void PaintTextMarkerBackground(const PaintInfo&, - const PhysicalOffset&, - const DocumentMarker&, - const ComputedStyle&, - const Font&); - - private: - bool ShouldPaintSelection(const PaintInfo&) const; - void PaintTextFragments(const PaintInfo&, LayoutObject&); - void PaintDecoration(const PaintInfo&, - TextDecorationLine, - const SVGTextFragment&); - bool SetupTextPaint(const PaintInfo&, - const ComputedStyle&, - LayoutSVGResourceMode, - cc::PaintFlags&, - const AffineTransform*); - void PaintText(const PaintInfo&, - TextRun&, - const SVGTextFragment&, - int start_position, - int end_position, - const cc::PaintFlags&); - void PaintText(const PaintInfo&, - const ComputedStyle&, - const ComputedStyle& selection_style, - const SVGTextFragment&, - LayoutSVGResourceMode, - bool should_paint_selection, - const AffineTransform*); - Vector<SVGTextFragmentWithRange> CollectTextMatches( - const DocumentMarker&) const; - Vector<SVGTextFragmentWithRange> CollectFragmentsInRange( - int start_position, - int end_position) const; - LayoutObject& InlineLayoutObject() const; - LayoutObject& ParentInlineLayoutObject() const; - LayoutSVGInlineText& InlineText() const; - - void RecordSelectionBoundsForRange( - int start_position, - int end_position, - SelectionState selection_state, - const ComputedStyle& style, - PaintController& paint_controller, - absl::optional<SelectionBoundsRecorder>& bounds_recorder); - - const SVGInlineTextBox& svg_inline_text_box_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_SVG_INLINE_TEXT_BOX_PAINTER_H_
diff --git a/third_party/blink/renderer/core/paint/svg_mask_painter.cc b/third_party/blink/renderer/core/paint/svg_mask_painter.cc index aedb64ea..442d188 100644 --- a/third_party/blink/renderer/core/paint/svg_mask_painter.cc +++ b/third_party/blink/renderer/core/paint/svg_mask_painter.cc
@@ -62,7 +62,7 @@ content_transformation.Translate(reference_box.x(), reference_box.y()); content_transformation.ScaleNonUniform(reference_box.width(), reference_box.height()); - } else if (layout_object.IsSVGForeignObjectIncludingNG()) { + } else if (layout_object.IsSVGForeignObject()) { content_transformation.Scale(style.EffectiveZoom()); }
diff --git a/third_party/blink/renderer/core/paint/svg_root_inline_box_painter.cc b/third_party/blink/renderer/core/paint/svg_root_inline_box_painter.cc deleted file mode 100644 index 6cdf6f8d..0000000 --- a/third_party/blink/renderer/core/paint/svg_root_inline_box_painter.cc +++ /dev/null
@@ -1,53 +0,0 @@ -// Copyright 2014 The Chromium Authors -// 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/core/paint/svg_root_inline_box_painter.h" - -#include "third_party/blink/renderer/core/layout/api/line_layout_api_shim.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_flow_box.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_inline_text_box.h" -#include "third_party/blink/renderer/core/layout/svg/line/svg_root_inline_box.h" -#include "third_party/blink/renderer/core/paint/paint_info.h" -#include "third_party/blink/renderer/core/paint/scoped_svg_paint_state.h" -#include "third_party/blink/renderer/core/paint/svg_inline_flow_box_painter.h" -#include "third_party/blink/renderer/core/paint/svg_inline_text_box_painter.h" -#include "third_party/blink/renderer/core/paint/svg_model_object_painter.h" -#include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h" - -namespace blink { - -void SVGRootInlineBoxPainter::Paint(const PaintInfo& paint_info, - const PhysicalOffset& paint_offset) { - DCHECK(paint_info.phase == PaintPhase::kForeground || - paint_info.phase == PaintPhase::kSelectionDragImage); - - const auto& layout_object = *LineLayoutAPIShim::ConstLayoutObjectFrom( - svg_root_inline_box_.GetLineLayoutItem()); - bool has_selection = !layout_object.GetDocument().Printing() && - svg_root_inline_box_.IsSelected(); - if (has_selection && - !DrawingRecorder::UseCachedDrawingIfPossible( - paint_info.context, layout_object, paint_info.phase)) { - SVGDrawingRecorder recorder(paint_info.context, layout_object, - paint_info.phase); - for (InlineBox* child = svg_root_inline_box_.FirstChild(); child; - child = child->NextOnLine()) { - if (auto* svg_inline_text_box = DynamicTo<SVGInlineTextBox>(child)) { - SVGInlineTextBoxPainter(*svg_inline_text_box) - .PaintSelectionBackground(paint_info); - } else if (auto* svg_inline_flow_box = - DynamicTo<SVGInlineFlowBox>(child)) { - SVGInlineFlowBoxPainter(*svg_inline_flow_box) - .PaintSelectionBackground(paint_info); - } - } - } - - ScopedSVGPaintState paint_state(layout_object, paint_info); - for (InlineBox* child = svg_root_inline_box_.FirstChild(); child; - child = child->NextOnLine()) - child->Paint(paint_info, paint_offset, LayoutUnit(), LayoutUnit()); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/paint/svg_root_inline_box_painter.h b/third_party/blink/renderer/core/paint/svg_root_inline_box_painter.h deleted file mode 100644 index 4d37a9d3..0000000 --- a/third_party/blink/renderer/core/paint/svg_root_inline_box_painter.h +++ /dev/null
@@ -1,31 +0,0 @@ -// Copyright 2014 The Chromium Authors -// 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_CORE_PAINT_SVG_ROOT_INLINE_BOX_PAINTER_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_SVG_ROOT_INLINE_BOX_PAINTER_H_ - -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" - -namespace blink { - -class SVGRootInlineBox; -struct PaintInfo; -struct PhysicalOffset; - -class SVGRootInlineBoxPainter { - STACK_ALLOCATED(); - - public: - SVGRootInlineBoxPainter(const SVGRootInlineBox& svg_root_inline_box) - : svg_root_inline_box_(svg_root_inline_box) {} - - void Paint(const PaintInfo&, const PhysicalOffset& paint_offset); - - private: - const SVGRootInlineBox& svg_root_inline_box_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_SVG_ROOT_INLINE_BOX_PAINTER_H_
diff --git a/third_party/blink/renderer/core/paint/svg_text_painter.cc b/third_party/blink/renderer/core/paint/svg_text_painter.cc deleted file mode 100644 index 31f1692..0000000 --- a/third_party/blink/renderer/core/paint/svg_text_painter.cc +++ /dev/null
@@ -1,45 +0,0 @@ -// Copyright 2014 The Chromium Authors -// 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/core/paint/svg_text_painter.h" - -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" -#include "third_party/blink/renderer/core/paint/block_painter.h" -#include "third_party/blink/renderer/core/paint/paint_info.h" -#include "third_party/blink/renderer/core/paint/scoped_svg_paint_state.h" -#include "third_party/blink/renderer/core/paint/svg_model_object_painter.h" - -namespace blink { - -void SVGTextPainter::Paint(const PaintInfo& paint_info) { - if (paint_info.phase != PaintPhase::kForeground && - paint_info.phase != PaintPhase::kForcedColorsModeBackplate && - paint_info.phase != PaintPhase::kSelectionDragImage) - return; - - PaintInfo block_info(paint_info); - if (const auto* properties = - layout_svg_text_.FirstFragment().PaintProperties()) { - // TODO(https://crbug.com/1278452): Also consider Translate, Rotate, - // Scale, and Offset, probably via a single transform operation to - // FirstFragment().PreTransform(). - if (const auto* transform = properties->Transform()) - block_info.TransformCullRect(*transform); - } - ScopedSVGTransformState transform_state(block_info, layout_svg_text_); - - if (block_info.phase == PaintPhase::kForeground) - SVGModelObjectPainter::RecordHitTestData(layout_svg_text_, block_info); - SVGModelObjectPainter::RecordRegionCaptureData(layout_svg_text_, block_info); - - BlockPainter(layout_svg_text_).Paint(block_info); - - // Paint the outlines, if any - if (block_info.phase == PaintPhase::kForeground) { - block_info.phase = PaintPhase::kOutline; - BlockPainter(layout_svg_text_).Paint(block_info); - } -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/paint/svg_text_painter.h b/third_party/blink/renderer/core/paint/svg_text_painter.h deleted file mode 100644 index fd36361..0000000 --- a/third_party/blink/renderer/core/paint/svg_text_painter.h +++ /dev/null
@@ -1,29 +0,0 @@ -// Copyright 2014 The Chromium Authors -// 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_CORE_PAINT_SVG_TEXT_PAINTER_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_SVG_TEXT_PAINTER_H_ - -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" - -namespace blink { - -struct PaintInfo; -class LayoutSVGText; - -class SVGTextPainter { - STACK_ALLOCATED(); - - public: - SVGTextPainter(const LayoutSVGText& layout_svg_text) - : layout_svg_text_(layout_svg_text) {} - void Paint(const PaintInfo&); - - private: - const LayoutSVGText& layout_svg_text_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_SVG_TEXT_PAINTER_H_
diff --git a/third_party/blink/renderer/core/paint/text_control_single_line_painter.cc b/third_party/blink/renderer/core/paint/text_control_single_line_painter.cc deleted file mode 100644 index 83eaa6c..0000000 --- a/third_party/blink/renderer/core/paint/text_control_single_line_painter.cc +++ /dev/null
@@ -1,53 +0,0 @@ -// Copyright 2018 The Chromium Authors -// 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/core/paint/text_control_single_line_painter.h" - -#include "third_party/blink/renderer/core/html/forms/html_input_element.h" -#include "third_party/blink/renderer/core/layout/layout_text_control_single_line.h" -#include "third_party/blink/renderer/core/layout/layout_theme.h" -#include "third_party/blink/renderer/core/paint/block_painter.h" -#include "third_party/blink/renderer/core/paint/box_painter.h" -#include "third_party/blink/renderer/core/paint/scoped_paint_state.h" -#include "third_party/blink/renderer/core/paint/theme_painter.h" -#include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h" - -namespace blink { - -void TextControlSingleLinePainter::Paint(const PaintInfo& paint_info) { - BlockPainter(text_control_).Paint(paint_info); - - if (!ShouldPaintSelfBlockBackground(paint_info.phase) || - !To<HTMLInputElement>(text_control_.GetNode()) - ->ShouldDrawCapsLockIndicator()) - return; - - if (DrawingRecorder::UseCachedDrawingIfPossible( - paint_info.context, text_control_, DisplayItem::kCapsLockIndicator)) - return; - - PhysicalRect contents_rect = text_control_.PhysicalContentBoxRect(); - - // Center in the block progression direction. - if (text_control_.IsHorizontalWritingMode()) { - contents_rect.SetY( - (text_control_.Size().Height() - contents_rect.Height()) / 2); - } else { - contents_rect.SetX((text_control_.Size().Width() - contents_rect.Width()) / - 2); - } - - // Convert the rect into the coords used for painting the content. - ScopedPaintState paint_state(text_control_, paint_info); - contents_rect.Move(paint_state.PaintOffset()); - gfx::Rect snapped_rect = ToPixelSnappedRect(contents_rect); - - BoxDrawingRecorder recorder(paint_info.context, text_control_, - DisplayItem::kCapsLockIndicator, - paint_state.PaintOffset()); - LayoutTheme::GetTheme().Painter().PaintCapsLockIndicator( - text_control_, paint_state.GetPaintInfo(), snapped_rect); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/paint/text_control_single_line_painter.h b/third_party/blink/renderer/core/paint/text_control_single_line_painter.h deleted file mode 100644 index 3bbf6cac..0000000 --- a/third_party/blink/renderer/core/paint/text_control_single_line_painter.h +++ /dev/null
@@ -1,29 +0,0 @@ -// Copyright 2018 The Chromium Authors -// 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_CORE_PAINT_TEXT_CONTROL_SINGLE_LINE_PAINTER_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_TEXT_CONTROL_SINGLE_LINE_PAINTER_H_ - -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" - -namespace blink { - -class LayoutTextControlSingleLine; -struct PaintInfo; - -class TextControlSingleLinePainter { - STACK_ALLOCATED(); - - public: - TextControlSingleLinePainter(const LayoutTextControlSingleLine& text_control) - : text_control_(text_control) {} - void Paint(const PaintInfo&); - - private: - const LayoutTextControlSingleLine& text_control_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_TEXT_CONTROL_SINGLE_LINE_PAINTER_H_
diff --git a/third_party/blink/renderer/core/script/script_element_base.h b/third_party/blink/renderer/core/script/script_element_base.h index 31616faa..77487631 100644 --- a/third_party/blink/renderer/core/script/script_element_base.h +++ b/third_party/blink/renderer/core/script/script_element_base.h
@@ -60,7 +60,7 @@ // This implements https://dom.spec.whatwg.org/#concept-child-text-content virtual String ChildTextContent() = 0; // This supports - // https://w3c.github.io/webappsec-trusted-types/dist/spec/#prepare-script-url-and-text + // https://w3c.github.io/trusted-types/dist/spec/#prepare-script-url-and-text virtual String ScriptTextInternalSlot() const = 0; virtual bool HasSourceAttribute() const = 0; virtual bool HasAttributionsrcAttribute() const = 0;
diff --git a/third_party/blink/renderer/core/script/script_loader.cc b/third_party/blink/renderer/core/script/script_loader.cc index f999453..a0e91ae 100644 --- a/third_party/blink/renderer/core/script/script_loader.cc +++ b/third_party/blink/renderer/core/script/script_loader.cc
@@ -531,7 +531,7 @@ // <spec step="5">Let source text be el's child text content.</spec> // // Trusted Types additionally requires: - // https://w3c.github.io/webappsec-trusted-types/dist/spec/#slot-value-verification + // https://w3c.github.io/trusted-types/dist/spec/#slot-value-verification // - Step 4: Execute the Prepare the script URL and text algorithm upon the // script element. If that algorithm threw an error, then return. The // script is not executed. @@ -1424,9 +1424,9 @@ String ScriptLoader::GetScriptText() const { // Step 3 of - // https://w3c.github.io/webappsec-trusted-types/dist/spec/#abstract-opdef-prepare-the-script-url-and-text + // https://w3c.github.io/trusted-types/dist/spec/#abstract-opdef-prepare-the-script-url-and-text // called from § 4.1.3.3, step 4 of - // https://w3c.github.io/webappsec-trusted-types/dist/spec/#slot-value-verification + // https://w3c.github.io/trusted-types/dist/spec/#slot-value-verification // This will return the [[ScriptText]] internal slot value after that step, // or a null string if the the Trusted Type algorithm threw an error. String child_text_content = element_->ChildTextContent();
diff --git a/third_party/blink/renderer/core/scroll/scrollable_area.cc b/third_party/blink/renderer/core/scroll/scrollable_area.cc index 2dcb345..959310d 100644 --- a/third_party/blink/renderer/core/scroll/scrollable_area.cc +++ b/third_party/blink/renderer/core/scroll/scrollable_area.cc
@@ -866,8 +866,9 @@ Node* ScrollableArea::EventTargetNode() const { const LayoutBox* box = GetLayoutBox(); Node* node = box->GetNode(); - if (!node && box->Parent() && box->Parent()->IsLayoutNGFieldset()) + if (!node && box->Parent() && box->Parent()->IsFieldset()) { node = box->Parent()->GetNode(); + } if (node && IsA<Element>(node)) { const LayoutBox* layout_box_for_scrolling = To<Element>(node)->GetLayoutBoxForScrolling();
diff --git a/third_party/blink/renderer/core/streams/build.gni b/third_party/blink/renderer/core/streams/build.gni index 3212fa1..16ae6aa 100644 --- a/third_party/blink/renderer/core/streams/build.gni +++ b/third_party/blink/renderer/core/streams/build.gni
@@ -15,6 +15,8 @@ "queue_with_sizes.h", "queuing_strategy_common.cc", "queuing_strategy_common.h", + "read_into_request.h", + "read_request.h", "readable_byte_stream_controller.cc", "readable_byte_stream_controller.h", "readable_stream.cc",
diff --git a/third_party/blink/renderer/core/streams/promise_handler.cc b/third_party/blink/renderer/core/streams/promise_handler.cc index be186a3..e7bb2e8 100644 --- a/third_party/blink/renderer/core/streams/promise_handler.cc +++ b/third_party/blink/renderer/core/streams/promise_handler.cc
@@ -57,6 +57,7 @@ v8::Local<v8::Promise> promise, ScriptFunction* on_fulfilled, ScriptFunction* on_rejected) { + v8::Context::Scope v8_context_scope(context); v8::MaybeLocal<v8::Promise> result_maybe; if (!on_fulfilled) { DCHECK(on_rejected);
diff --git a/third_party/blink/renderer/core/streams/read_into_request.h b/third_party/blink/renderer/core/streams/read_into_request.h new file mode 100644 index 0000000..d18f9b00 --- /dev/null +++ b/third_party/blink/renderer/core/streams/read_into_request.h
@@ -0,0 +1,37 @@ +// Copyright 2023 The Chromium Authors +// 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_CORE_STREAMS_READ_INTO_REQUEST_H_ +#define THIRD_PARTY_BLINK_RENDERER_CORE_STREAMS_READ_INTO_REQUEST_H_ + +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/visitor.h" +#include "v8/include/v8.h" + +namespace blink { + +class DOMArrayBufferView; +class ScriptState; + +// Implementation of the "read-into request" struct from the standard. +// ReadIntoRequest allows polymorphically overriding the chunk, close, and +// error steps. +// https://streams.spec.whatwg.org/#read-into-request +class ReadIntoRequest : public GarbageCollected<ReadIntoRequest> { + public: + ReadIntoRequest() = default; + ReadIntoRequest(const ReadIntoRequest&) = delete; + ReadIntoRequest& operator=(const ReadIntoRequest&) = delete; + virtual ~ReadIntoRequest() = default; + + virtual void ChunkSteps(ScriptState*, DOMArrayBufferView* chunk) const = 0; + virtual void CloseSteps(ScriptState*, DOMArrayBufferView* chunk) const = 0; + virtual void ErrorSteps(ScriptState*, v8::Local<v8::Value> e) const = 0; + + virtual void Trace(Visitor*) const {} +}; + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_CORE_STREAMS_READ_INTO_REQUEST_H_
diff --git a/third_party/blink/renderer/core/streams/read_request.h b/third_party/blink/renderer/core/streams/read_request.h new file mode 100644 index 0000000..8abcf11 --- /dev/null +++ b/third_party/blink/renderer/core/streams/read_request.h
@@ -0,0 +1,36 @@ +// Copyright 2023 The Chromium Authors +// 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_CORE_STREAMS_READ_REQUEST_H_ +#define THIRD_PARTY_BLINK_RENDERER_CORE_STREAMS_READ_REQUEST_H_ + +#include "third_party/blink/renderer/core/core_export.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/visitor.h" +#include "v8/include/v8.h" + +namespace blink { + +class ScriptState; + +// Implementation of the "read request" struct from the standard. ReadRequest +// allows polymorphically overriding the chunk, close, and error steps. +// https://streams.spec.whatwg.org/#read-request +class CORE_EXPORT ReadRequest : public GarbageCollected<ReadRequest> { + public: + ReadRequest() = default; + ReadRequest(const ReadRequest&) = delete; + ReadRequest& operator=(const ReadRequest&) = delete; + virtual ~ReadRequest() = default; + + virtual void ChunkSteps(ScriptState*, v8::Local<v8::Value> chunk) const = 0; + virtual void CloseSteps(ScriptState*) const = 0; + virtual void ErrorSteps(ScriptState*, v8::Local<v8::Value> e) const = 0; + + virtual void Trace(Visitor*) const {} +}; + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_CORE_STREAMS_READ_REQUEST_H_
diff --git a/third_party/blink/renderer/core/streams/readable_byte_stream_controller.cc b/third_party/blink/renderer/core/streams/readable_byte_stream_controller.cc index 01e3e9b..23faaab8 100644 --- a/third_party/blink/renderer/core/streams/readable_byte_stream_controller.cc +++ b/third_party/blink/renderer/core/streams/readable_byte_stream_controller.cc
@@ -13,10 +13,11 @@ #include "third_party/blink/renderer/bindings/core/v8/v8_underlying_source_start_callback.h" #include "third_party/blink/renderer/core/streams/miscellaneous_operations.h" #include "third_party/blink/renderer/core/streams/promise_handler.h" +#include "third_party/blink/renderer/core/streams/read_into_request.h" +#include "third_party/blink/renderer/core/streams/read_request.h" #include "third_party/blink/renderer/core/streams/readable_stream.h" #include "third_party/blink/renderer/core/streams/readable_stream_byob_request.h" #include "third_party/blink/renderer/core/streams/stream_algorithms.h" -#include "third_party/blink/renderer/core/streams/stream_promise_resolver.h" #include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h" #include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer_view.h" #include "third_party/blink/renderer/core/typed_arrays/dom_data_view.h" @@ -515,7 +516,7 @@ return; } // b. Let readRequest be reader.[[readRequests]][0]. - StreamPromiseResolver* read_request = default_reader->read_requests_[0]; + ReadRequest* read_request = default_reader->read_requests_[0]; // c. Remove readRequest from reader.[[readRequests]]. default_reader->read_requests_.pop_front(); // d. Perform ! @@ -1099,7 +1100,7 @@ void ReadableByteStreamController::FillReadRequestFromQueue( ScriptState* script_state, ReadableByteStreamController* controller, - StreamPromiseResolver* read_request) { + ReadRequest* read_request) { // https://streams.spec.whatwg.org/#abstract-opdef-readablebytestreamcontrollerfillreadrequestfromqueue // 1. Assert: controller.[[queueTotalSize]] > 0. DCHECK_GT(controller->queue_total_size_, 0); @@ -1117,24 +1118,16 @@ DOMUint8Array* view = DOMUint8Array::Create(entry->buffer, entry->byte_offset, entry->byte_length); // 7. Perform readRequest’s chunk steps, given view. - // TODO(nidhijaju): Implement https://github.com/whatwg/streams/pull/1045 to - // remove forAuthorCode and update implementation for readRequest's chunk - // steps. - ReadableStreamGenericReader* reader = - controller->controlled_readable_stream_->reader_; - read_request->Resolve( + read_request->ChunkSteps( script_state, - ReadableStream::CreateReadResult( - script_state, - ToV8Traits<DOMUint8Array>::ToV8(script_state, view).ToLocalChecked(), - false, To<ReadableStreamDefaultReader>(reader)->for_author_code_)); + ToV8Traits<DOMUint8Array>::ToV8(script_state, view).ToLocalChecked()); } void ReadableByteStreamController::PullInto( ScriptState* script_state, ReadableByteStreamController* controller, NotShared<DOMArrayBufferView> view, - ReadableStreamBYOBReader::ReadIntoRequest* read_into_request, + ReadIntoRequest* read_into_request, ExceptionState& exception_state) { // https://streams.spec.whatwg.org/#readable-byte-stream-controller-pull-into // 1. Let stream be controller.[[stream]]. @@ -1622,8 +1615,8 @@ return result; } -StreamPromiseResolver* ReadableByteStreamController::PullSteps( - ScriptState* script_state) { +void ReadableByteStreamController::PullSteps(ScriptState* script_state, + ReadRequest* read_request) { // https://whatpr.org/streams/1029.html#rbs-controller-private-pull // TODO: This function follows an old version of the spec referenced above, so // it needs to be updated to the new version on @@ -1637,31 +1630,11 @@ if (queue_total_size_ > 0) { // a. Assert: ! ReadableStreamGetNumReadRequests(stream) is 0. DCHECK_EQ(ReadableStream::GetNumReadRequests(stream), 0); - // b. Let entry be the first element of this.[[queue]]. - QueueEntry* entry = queue_[0]; - // c. Remove entry from this.[[queue]], shifting all other elements - // downward (so that the second becomes the first, and so on). - queue_.pop_front(); - // d. Set this.[[queueTotalSize]] to this.[[queueTotalSize]] − - // entry.[[byteLength]]. - queue_total_size_ -= entry->byte_length; - // e. Perform ! ReadableByteStreamControllerHandleQueueDrain(this). - HandleQueueDrain(script_state, this); - // f. Let view be ! Construct(%Uint8Array%, « entry.[[buffer]], - // entry.[[byteOffset]], entry.[[byteLength]] »). - DOMUint8Array* view = DOMUint8Array::Create( - entry->buffer, entry->byte_offset, entry->byte_length); - // g. Return a promise resolved with ! - // ReadableStreamCreateReadResult(view, false, - // stream.[[reader]].[[forAuthorCode]]). - ReadableStreamGenericReader* reader = stream->reader_; - return StreamPromiseResolver::CreateResolved( - script_state, - ReadableStream::CreateReadResult( - script_state, - ToV8Traits<DOMUint8Array>::ToV8(script_state, view) - .ToLocalChecked(), - false, To<ReadableStreamDefaultReader>(reader)->for_author_code_)); + // b. Perform ! ReadableByteStreamControllerFillReadRequestFromQueue(this, + // readRequest). + FillReadRequestFromQueue(script_state, this, read_request); + // c. Return. + return; } // 4. Let autoAllocateChunkSize be this.[[autoAllocateChunkSize]]. const size_t auto_allocate_chunk_size = auto_allocate_chunk_size_; @@ -1669,8 +1642,9 @@ if (auto_allocate_chunk_size) { // a. Let buffer be Construct(%ArrayBuffer%, « autoAllocateChunkSize »). auto* buffer = DOMArrayBuffer::Create(auto_allocate_chunk_size, 1); - // b. If buffer is an abrupt completion, return a promise rejected with - // buffer.[[Value]]. + // b. If buffer is an abrupt completion, + // i. Perform readRequest’s error steps, given buffer.[[Value]]. + // ii. Return. // This is not needed as DOMArrayBuffer::Create() is designed to // crash if it cannot allocate the memory. @@ -1687,13 +1661,10 @@ // this.[[pendingPullIntos]]. pending_pull_intos_.push_back(pull_into_descriptor); } - // 6. Let promise be ! ReadableStreamAddReadRequest(stream). - StreamPromiseResolver* promise = - ReadableStream::AddReadRequest(script_state, stream); + // 6. Perform ! ReadableStreamAddReadRequest(stream, readRequest). + ReadableStream::AddReadRequest(script_state, stream, read_request); // 7. Perform ! ReadableByteStreamControllerCallPullIfNeeded(this). CallPullIfNeeded(script_state, this); - // 8. Return promise. - return promise; } void ReadableByteStreamController::ReleaseSteps() {
diff --git a/third_party/blink/renderer/core/streams/readable_byte_stream_controller.h b/third_party/blink/renderer/core/streams/readable_byte_stream_controller.h index 845a789..0c30551 100644 --- a/third_party/blink/renderer/core/streams/readable_byte_stream_controller.h +++ b/third_party/blink/renderer/core/streams/readable_byte_stream_controller.h
@@ -8,7 +8,6 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/renderer/bindings/core/v8/script_value.h" #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/core/streams/readable_stream_byob_reader.h" #include "third_party/blink/renderer/core/streams/readable_stream_controller.h" #include "third_party/blink/renderer/core/typed_arrays/array_buffer_view_helpers.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" @@ -23,10 +22,11 @@ class ExceptionState; class ReadableStream; class ReadableStreamBYOBRequest; +class ReadIntoRequest; +class ReadRequest; class ScriptState; class StreamAlgorithm; class StreamStartAlgorithm; -class StreamPromiseResolver; class UnderlyingSource; class CORE_EXPORT ReadableByteStreamController @@ -215,13 +215,13 @@ // https://streams.spec.whatwg.org/#abstract-opdef-readablebytestreamcontrollerfillreadrequestfromqueue static void FillReadRequestFromQueue(ScriptState*, ReadableByteStreamController*, - StreamPromiseResolver* read_request); + ReadRequest* read_request); // https://streams.spec.whatwg.org/#readable-byte-stream-controller-pull-into static void PullInto(ScriptState*, ReadableByteStreamController*, NotShared<DOMArrayBufferView> view, - ReadableStreamBYOBReader::ReadIntoRequest*, + ReadIntoRequest*, ExceptionState&); // https://streams.spec.whatwg.org/#readable-byte-stream-controller-handle-queue-drain @@ -274,7 +274,7 @@ v8::Local<v8::Value> reason) override; // https://streams.spec.whatwg.org/#rbs-controller-private-pull - StreamPromiseResolver* PullSteps(ScriptState*) override; + void PullSteps(ScriptState*, ReadRequest*) override; // https://streams.spec.whatwg.org/#abstract-opdef-readablebytestreamcontroller-releasesteps void ReleaseSteps() override;
diff --git a/third_party/blink/renderer/core/streams/readable_stream.cc b/third_party/blink/renderer/core/streams/readable_stream.cc index fc48a92..5cd74fe 100644 --- a/third_party/blink/renderer/core/streams/readable_stream.cc +++ b/third_party/blink/renderer/core/streams/readable_stream.cc
@@ -4,7 +4,6 @@ #include "third_party/blink/renderer/core/streams/readable_stream.h" -#include "third_party/blink/renderer/bindings/core/v8/iterable.h" #include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h" #include "third_party/blink/renderer/bindings/core/v8/script_function.h" #include "third_party/blink/renderer/bindings/core/v8/to_v8_traits.h" @@ -18,11 +17,15 @@ #include "third_party/blink/renderer/bindings/core/v8/v8_union_readablestreambyobreader_readablestreamdefaultreader.h" #include "third_party/blink/renderer/bindings/core/v8/v8_writable_stream.h" #include "third_party/blink/renderer/core/dom/abort_signal.h" +#include "third_party/blink/renderer/core/execution_context/agent.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h" #include "third_party/blink/renderer/core/frame/web_feature.h" #include "third_party/blink/renderer/core/streams/miscellaneous_operations.h" #include "third_party/blink/renderer/core/streams/promise_handler.h" +#include "third_party/blink/renderer/core/streams/read_into_request.h" +#include "third_party/blink/renderer/core/streams/read_request.h" #include "third_party/blink/renderer/core/streams/readable_byte_stream_controller.h" +#include "third_party/blink/renderer/core/streams/readable_stream_byob_reader.h" #include "third_party/blink/renderer/core/streams/readable_stream_controller.h" #include "third_party/blink/renderer/core/streams/readable_stream_default_controller.h" #include "third_party/blink/renderer/core/streams/readable_stream_generic_reader.h" @@ -45,7 +48,9 @@ #include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/heap/persistent.h" #include "third_party/blink/renderer/platform/instrumentation/use_counter.h" +#include "third_party/blink/renderer/platform/scheduler/public/event_loop.h" #include "third_party/blink/renderer/platform/wtf/deque.h" +#include "third_party/blink/renderer/platform/wtf/functional.h" namespace blink { @@ -193,52 +198,53 @@ // This is the main entrypoint for ReadableStreamPipeTo(). ScriptPromise Start(ReadableStream* readable, WritableStream* destination) { - // 1. Assert: ! IsReadableStream(source) is true. + // 1. Assert: source implements ReadableStream. DCHECK(readable); - // 2. Assert: ! IsWritableStream(dest) is true. + // 2. Assert: dest implements WritableStream. DCHECK(destination); // Not relevant to C++ implementation: - // 3. Assert: Type(preventClose) is Boolean, Type(preventAbort) is Boolean, - // and Type(preventCancel) is Boolean. + // 3. Assert: preventClose, preventAbort, and preventCancel are all + // booleans. // TODO(ricea): Implement |signal|. - // 4. Assert: signal is undefined or signal is an instance of the - // AbortSignal interface. + // 4. If signal was not given, let signal be undefined. + // 5. Assert: either signal is undefined, or signal implements AbortSignal. - // 5. Assert: ! IsReadableStreamLocked(source) is false. + // 6. Assert: ! IsReadableStreamLocked(source) is false. DCHECK(!ReadableStream::IsLocked(readable)); - // 6. Assert: ! IsWritableStreamLocked(dest) is false. + // 7. Assert: ! IsWritableStreamLocked(dest) is false. DCHECK(!WritableStream::IsLocked(destination)); auto* isolate = script_state_->GetIsolate(); ExceptionState exception_state(isolate, ExceptionState::kUnknownContext, "", ""); - // 7. If ! - // IsReadableByteStreamController(source.[[readableStreamController]]) is - // true, let reader be either ! AcquireReadableStreamBYOBReader(source) - // or ! AcquireReadableStreamDefaultReader(source), at the user agent’s + // 8. If source.[[controller]] implements ReadableByteStreamController, let + // reader be ! AcquireReadableStreamBYOBReader(source) or ! + // AcquireReadableStreamDefaultReader(source), at the user agent's // discretion. - // 8. Otherwise, let reader be ! AcquireReadableStreamDefaultReader(source). + // 9. Otherwise, let reader be ! AcquireReadableStreamDefaultReader(source). reader_ = ReadableStream::AcquireDefaultReader(script_state_, readable, - false, exception_state); + exception_state); DCHECK(!exception_state.HadException()); - // 9. Let writer be ! AcquireWritableStreamDefaultWriter(dest). + // 10. Let writer be ! AcquireWritableStreamDefaultWriter(dest). writer_ = WritableStream::AcquireDefaultWriter(script_state_, destination, exception_state); DCHECK(!exception_state.HadException()); - // 10. Let shuttingDown be false. + // 11. Set source.[[disturbed]] to true. + + // 12. Let shuttingDown be false. DCHECK(!is_shutting_down_); - // 11. Let promise be a new promise. + // 13. Let promise be a new promise. promise_ = MakeGarbageCollected<StreamPromiseResolver>(script_state_); - // 12. If signal is not undefined, + // 14. If signal is not undefined, if (auto* signal = pipe_options_->Signal()) { // b. If signal is aborted, perform abortAlgorithm and // return promise. @@ -252,7 +258,7 @@ MakeGarbageCollected<PipeToAbortAlgorithm>(this, signal)); } - // 13. In parallel ... + // 15. In parallel ... // The rest of the algorithm is described in terms of a series of // constraints rather than as explicit steps. if (CheckInitialState()) { @@ -279,7 +285,7 @@ HandleNextEvent(Undefined()); } - // 14. Return promise. + // 16. Return promise. return promise_->GetScriptPromise(script_state_); } @@ -476,42 +482,62 @@ } is_reading_ = true; - ThenPromise(ReadableStreamDefaultReader::Read(script_state_, reader_) - ->V8Promise(script_state_->GetIsolate()), - &PipeToEngine::ReadFulfilled, &PipeToEngine::ReadRejected); + auto* read_request = MakeGarbageCollected<PipeToReadRequest>(this); + ReadableStreamDefaultReader::Read(script_state_, reader_, read_request); return Undefined(); } - v8::Local<v8::Value> ReadFulfilled(v8::Local<v8::Value> result) { - is_reading_ = false; - DCHECK(result->IsObject()); - auto* isolate = script_state_->GetIsolate(); - v8::Local<v8::Value> value; - bool done = false; - bool unpack_succeeded = V8UnpackIterationResult( - script_state_, result.As<v8::Object>(), &value, &done); - DCHECK(unpack_succeeded); - if (done) { - ReadableClosed(); - return Undefined(); + class PipeToReadRequest final : public ReadRequest { + public: + explicit PipeToReadRequest(PipeToEngine* instance) : instance_(instance) {} + + void ChunkSteps(ScriptState* script_state, + v8::Local<v8::Value> chunk) const override { + scoped_refptr<scheduler::EventLoop> event_loop = + ExecutionContext::From(script_state)->GetAgent()->event_loop(); + v8::Global<v8::Value> value(script_state->GetIsolate(), chunk); + event_loop->EnqueueMicrotask( + WTF::BindOnce(&PipeToEngine::ReadRequestChunkStepsBody, + WrapPersistent(instance_.Get()), + WrapPersistent(script_state), std::move(value))); } - const auto write = - WritableStreamDefaultWriter::Write(script_state_, writer_, value); - last_write_.Reset(isolate, write); + + void CloseSteps(ScriptState* script_state) const override { + instance_->ReadableClosed(); + } + + void ErrorSteps(ScriptState* script_state, + v8::Local<v8::Value> e) const override { + instance_->is_reading_ = false; + if (instance_->is_shutting_down_) { + // This function can be called during shutdown when the lock is + // released. Exit early in that case. + return; + } + instance_->ReadableError( + instance_->Readable()->GetStoredError(script_state->GetIsolate())); + } + + void Trace(Visitor* visitor) const override { + visitor->Trace(instance_); + ReadRequest::Trace(visitor); + } + + private: + Member<PipeToEngine> instance_; + }; + + void ReadRequestChunkStepsBody(ScriptState* script_state, + v8::Global<v8::Value> chunk) { + // This is needed because this method runs as an enqueued microtask, so the + // isolate needs a current context. + ScriptState::Scope scope(script_state); + is_reading_ = false; + const auto write = WritableStreamDefaultWriter::Write( + script_state, writer_, chunk.Get(script_state->GetIsolate())); + last_write_.Reset(script_state->GetIsolate(), write); ThenPromise(write, nullptr, &PipeToEngine::WritableError); HandleNextEvent(Undefined()); - return Undefined(); - } - - v8::Local<v8::Value> ReadRejected(v8::Local<v8::Value>) { - is_reading_ = false; - if (is_shutting_down_) { - // This function can be called during shutdown when the lock is released. - // Exit early in that case. - return Undefined(); - } - ReadableError(Readable()->GetStoredError(script_state_->GetIsolate())); - return Undefined(); } // If read() is in progress, then wait for it to tell us that the stream is @@ -877,7 +903,8 @@ Member<ReadableStream> stream_; Member<ReadableStreamDefaultReader> reader_; Member<StreamPromiseResolver> cancel_promise_; - bool closed_ = false; + bool reading_ = false; + bool read_again_ = false; // The standard contains a number of pairs of variables with one for each // stream. These are implemented as arrays here. While they are 1-indexed in @@ -897,16 +924,23 @@ int, v8::Local<v8::Value>[]) override { // https://streams.spec.whatwg.org/#readable-stream-tee - // 12. Let pullAlgorithm be the following steps: - // a. Return the result of transforming ! ReadableStreamDefaultReaderRead( - // reader) with a fulfillment handler which takes the argument result - // and performs the following steps: - return StreamThenPromise( - script_state->GetContext(), - ReadableStreamDefaultReader::Read(script_state, engine_->reader_) - ->V8Promise(script_state->GetIsolate()), - MakeGarbageCollected<ScriptFunction>( - script_state, MakeGarbageCollected<ResolveFunction>(engine_))); + // 13. Let pullAlgorithm be the following steps: + // a. If reading is true, + if (engine_->reading_) { + // i. Set readAgain to true. + engine_->read_again_ = true; + // ii. Return a promise resolved with undefined. + return PromiseResolveWithUndefined(script_state); + } + // b. Set reading to true. + engine_->reading_ = true; + // c. Let readRequest be a read request with the following items: + auto* read_request = MakeGarbageCollected<TeeReadRequest>(engine_); + // d. Perform ! ReadableStreamDefaultReaderRead(reader, readRequest). + ReadableStreamDefaultReader::Read(script_state, engine_->reader_, + read_request); + // e. Return a promise resolved with undefined. + return PromiseResolveWithUndefined(script_state); } void Trace(Visitor* visitor) const override { @@ -915,90 +949,94 @@ } private: - class ResolveFunction final : public PromiseHandler { + class TeeReadRequest final : public ReadRequest { public: - explicit ResolveFunction(TeeEngine* engine) : engine_(engine) {} + explicit TeeReadRequest(TeeEngine* engine) : engine_(engine) {} - void CallWithLocal(ScriptState* script_state, - v8::Local<v8::Value> result) override { - // i. If closed is true, return. - if (engine_->closed_) { - return; - } + void ChunkSteps(ScriptState* script_state, + v8::Local<v8::Value> chunk) const override { + scoped_refptr<scheduler::EventLoop> event_loop = + ExecutionContext::From(script_state)->GetAgent()->event_loop(); + v8::Global<v8::Value> value(script_state->GetIsolate(), chunk); + event_loop->EnqueueMicrotask( + WTF::BindOnce(&TeeReadRequest::ChunkStepsBody, WrapPersistent(this), + WrapPersistent(script_state), std::move(value))); + } - // ii. Assert: Type(result) is Object. - DCHECK(result->IsObject()); + void CloseSteps(ScriptState* script_state) const override { + // 1. Set reading to false. + engine_->reading_ = false; - auto* isolate = script_state->GetIsolate(); - - // iii. Let done be ! Get(result, "done"). - // vi. Let value be ! Get(result, "value"). - // The precise order of operations is not important here, because |result| - // is guaranteed to have own properties of "value" and "done" and so the - // "Get" operations cannot have side-effects. - v8::Local<v8::Value> value; - bool done = false; - bool unpack_succeeded = V8UnpackIterationResult( - script_state, result.As<v8::Object>(), &value, &done); - CHECK(unpack_succeeded); - - // vi. Assert: Type(done) is Boolean. - // v. If done is true, - if (done) { - // 1. If canceled1 is false, - // a. Perform ! ReadableStreamDefaultControllerClose(branch1. - // [[readableStreamController]]). - // 2. If canceled2 is false, - // b. Perform ! ReadableStreamDefaultControllerClose(branch2. - // [[readableStreamController]]). - for (int branch = 0; branch < 2; ++branch) { - if (!engine_->canceled_[branch] && - ReadableStreamDefaultController::CanCloseOrEnqueue( - engine_->controller_[branch])) { - ReadableStreamDefaultController::Close( - script_state, engine_->controller_[branch]); - } - } - - // TODO(ricea): Implement https://github.com/whatwg/streams/pull/1045 so - // this step can be numbered correctly. - // If canceled1 is false or canceled2 is false, resolve |cancelPromise| - // with undefined. - if (!engine_->canceled_[0] || !engine_->canceled_[1]) { - engine_->cancel_promise_->ResolveWithUndefined(script_state); - } - - // 3. Set closed to true. - engine_->closed_ = true; - - // 4. Return. - return; - } - ExceptionState exception_state(isolate, ExceptionState::kUnknownContext, - "", ""); - // vii. Let value1 and value2 be value. - // viii. If canceled2 is false and cloneForBranch2 is true, set value2 to - // ? StructuredDeserialize(? StructuredSerialize(value2), the - // current Realm Record). - // TODO(ricea): Support cloneForBranch2 - - // ix. If canceled1 is false, perform ? - // ReadableStreamDefaultControllerEnqueue(branch1. - // [[readableStreamController]], value1). - // x. If canceled2 is false, perform ? - // ReadableStreamDefaultControllerEnqueue(branch2. - // [[readableStreamController]], value2). + // 2. If canceled1 is false, perform ! + // ReadableStreamDefaultControllerClose(branch1.[[controller]]). + // 3. If canceled2 is false, perform ! + // ReadableStreamDefaultControllerClose(branch2.[[controller]]). for (int branch = 0; branch < 2; ++branch) { if (!engine_->canceled_[branch] && ReadableStreamDefaultController::CanCloseOrEnqueue( engine_->controller_[branch])) { - ReadableStreamDefaultController::Enqueue(script_state, - engine_->controller_[branch], - value, exception_state); + ReadableStreamDefaultController::Close(script_state, + engine_->controller_[branch]); + } + } + + // 4. If canceled1 is false or canceled2 is false, resolve + // cancelPromise with undefined. + if (!engine_->canceled_[0] || !engine_->canceled_[1]) { + engine_->cancel_promise_->ResolveWithUndefined(script_state); + } + } + + void ErrorSteps(ScriptState* script_state, + v8::Local<v8::Value> e) const override { + // 1. Set reading to false. + engine_->reading_ = false; + } + + void Trace(Visitor* visitor) const override { + visitor->Trace(engine_); + ReadRequest::Trace(visitor); + } + + private: + void ChunkStepsBody(ScriptState* script_state, + v8::Global<v8::Value> chunk) const { + // 1. Set readAgain to false. + engine_->read_again_ = false; + + ExceptionState exception_state(script_state->GetIsolate(), + ExceptionState::kUnknownContext, "", ""); + + // 2. Let chunk1 and chunk2 be chunk. + // 3. If canceled2 is false and cloneForBranch2 is true, + // a. Let cloneResult be StructuredClone(chunk2). + // b. If cloneResult is an abrupt completion, + // i. Perform ! + // ReadableStreamDefaultControllerError(branch1.[[controller]], + // cloneResult.[[Value]]). + // ii. Perform ! + // ReadableStreamDefaultControllerError(branch2.[[controller]], + // cloneResult.[[Value]]). + // iii. Resolve cancelPromise with ! + // ReadableStreamCancel(stream, cloneResult.[[Value]]). iv. Return. + // c. Otherwise, set chunk2 to cloneResult.[[Value]]. + // TODO(ricea): Support cloneForBranch2 + + // 4. If canceled1 is false, perform ! + // ReadableStreamDefaultControllerEnqueue(branch1.[[controller]], chunk1). + // 5. If canceled2 is false, perform ! + // ReadableStreamDefaultControllerEnqueue(branch2.[[controller]], chunk2). + for (int branch = 0; branch < 2; ++branch) { + if (!engine_->canceled_[branch] && + ReadableStreamDefaultController::CanCloseOrEnqueue( + engine_->controller_[branch])) { + ReadableStreamDefaultController::Enqueue( + script_state, engine_->controller_[branch], + chunk.Get(script_state->GetIsolate()), exception_state); if (exception_state.HadException()) { // Instead of returning a rejection, which is inconvenient here, - // call ControllerError(). The only difference this makes is that - // it happens synchronously, but that should not be observable. + // call ControllerError(). The only difference this makes is that it + // happens synchronously, but that should not be observable. ReadableStreamDefaultController::Error( script_state, engine_->controller_[branch], exception_state.GetException()); @@ -1007,14 +1045,17 @@ } } } + + // 6. Set reading to false. + engine_->reading_ = false; + + // 7. If readAgain is true, perform pullAlgorithm. + if (engine_->read_again_) { + auto* pull_algorithm = MakeGarbageCollected<PullAlgorithm>(engine_); + pull_algorithm->Run(script_state, 0, nullptr); + } } - void Trace(Visitor* visitor) const override { - visitor->Trace(engine_); - PromiseHandler::Trace(visitor); - } - - private: Member<TeeEngine> engine_; }; @@ -1090,55 +1131,58 @@ stream_ = stream; // 3. Let reader be ? AcquireReadableStreamDefaultReader(stream). - reader_ = ReadableStream::AcquireDefaultReader(script_state, stream, false, + reader_ = ReadableStream::AcquireDefaultReader(script_state, stream, exception_state); if (exception_state.HadException()) { return; } // These steps are performed by the constructor: - // 4. Let closed be false. - DCHECK(!closed_); + // 4. Let reading be false. + DCHECK(!reading_); - // 5. Let canceled1 be false. + // 5. Let readAgain be false. + DCHECK(!read_again_); + + // 6. Let canceled1 be false. DCHECK(!canceled_[0]); - // 6. Let canceled2 be false. + // 7. Let canceled2 be false. DCHECK(!canceled_[1]); - // 7. Let reason1 be undefined. + // 8. Let reason1 be undefined. DCHECK(reason_[0].IsEmpty()); - // 8. Let reason2 be undefined. + // 9. Let reason2 be undefined. DCHECK(reason_[1].IsEmpty()); - // 9. Let branch1 be undefined. + // 10. Let branch1 be undefined. DCHECK(!branch_[0]); - // 10. Let branch2 be undefined. + // 11. Let branch2 be undefined. DCHECK(!branch_[1]); - // 11. Let cancelPromise be a new promise. + // 12. Let cancelPromise be a new promise. cancel_promise_ = MakeGarbageCollected<StreamPromiseResolver>(script_state); - // 12. Let pullAlgorithm be the following steps: + // 13. Let pullAlgorithm be the following steps: // (steps are defined in PullAlgorithm::Run()). auto* pull_algorithm = MakeGarbageCollected<PullAlgorithm>(this); - // 13. Let cancel1Algorithm be the following steps, taking a reason argument: + // 14. Let cancel1Algorithm be the following steps, taking a reason argument: // (see CancelAlgorithm::Run()). auto* cancel1_algorithm = MakeGarbageCollected<CancelAlgorithm>(this, 0); - // 14. Let cancel2Algorithm be the following steps, taking a reason argument: + // 15. Let cancel2Algorithm be the following steps, taking a reason argument: // (both algorithms share a single implementation). auto* cancel2_algorithm = MakeGarbageCollected<CancelAlgorithm>(this, 1); - // 15. Let startAlgorithm be an algorithm that returns undefined. + // 16. Let startAlgorithm be an algorithm that returns undefined. auto* start_algorithm = CreateTrivialStartAlgorithm(); auto* size_algorithm = CreateDefaultSizeAlgorithm(); - // 16. Set branch1 to ! CreateReadableStream(startAlgorithm, pullAlgorithm, + // 17. Set branch1 to ! CreateReadableStream(startAlgorithm, pullAlgorithm, // cancel1Algorithm). branch_[0] = ReadableStream::Create(script_state, start_algorithm, pull_algorithm, cancel1_algorithm, 1.0, @@ -1147,7 +1191,7 @@ return; } - // 17. Set branch2 to ! CreateReadableStream(startAlgorithm, pullAlgorithm, + // 18. Set branch2 to ! CreateReadableStream(startAlgorithm, pullAlgorithm, // cancel2Algorithm). branch_[1] = ReadableStream::Create(script_state, start_algorithm, pull_algorithm, cancel2_algorithm, 1.0, @@ -1199,14 +1243,14 @@ Member<TeeEngine> engine_; }; - // 18. Upon rejection of reader.[[closedPromise]] with reason r, + // 19. Upon rejection of reader.[[closedPromise]] with reason r, StreamThenPromise( script_state->GetContext(), reader_->closed_promise_->V8Promise(script_state->GetIsolate()), nullptr, MakeGarbageCollected<ScriptFunction>( script_state, MakeGarbageCollected<RejectFunction>(this))); - // Step "19. Return « branch1, branch2 »." + // Step "20. Return « branch1, branch2 »." // is performed by the caller. } @@ -1323,7 +1367,8 @@ Initialize(stream); // 6. Let controller be a new ReadableStreamDefaultController. - auto* controller = MakeGarbageCollected<ReadableStreamDefaultController>(); + auto* controller = + MakeGarbageCollected<ReadableStreamDefaultController>(script_state); // 7. Perform ? SetUpReadableStreamDefaultController(stream, controller, // startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, @@ -1442,7 +1487,7 @@ // 1. If options["mode"] does not exist, return ? // AcquireReadableStreamDefaultReader(this). ReadableStreamDefaultReader* reader = - AcquireDefaultReader(script_state, this, true, exception_state); + AcquireDefaultReader(script_state, this, exception_state); if (!reader) return nullptr; return MakeGarbageCollected<V8ReadableStreamReader>(reader); @@ -1700,11 +1745,8 @@ ReadableStreamDefaultReader* ReadableStream::AcquireDefaultReader( ScriptState* script_state, ReadableStream* stream, - bool for_author_code, ExceptionState& exception_state) { // https://streams.spec.whatwg.org/#acquire-readable-stream-reader - // for_author_code is compulsory in this implementation - // 1. Let reader by a new ReadableStreamDefaultReader. // 2. Perform ? SetUpReadableStreamReader(reader, stream). auto* reader = MakeGarbageCollected<ReadableStreamDefaultReader>( @@ -1713,8 +1755,6 @@ return nullptr; } - reader->for_author_code_ = for_author_code; - // 3. Return reader. return reader; } @@ -1884,7 +1924,7 @@ // Since the stream is not locked, AcquireDefaultReader cannot fail. NonThrowableExceptionState exception_state(__FILE__, __LINE__); - return AcquireDefaultReader(script_state, this, false, exception_state); + return AcquireDefaultReader(script_state, this, exception_state); } ScriptPromise ReadableStream::PipeTo(ScriptState* script_state, @@ -1916,10 +1956,9 @@ // Abstract Operations Used By Controllers // -void ReadableStream::AddReadIntoRequest( - ScriptState* script_state, - ReadableStream* stream, - ReadableStreamBYOBReader::ReadIntoRequest* readRequest) { +void ReadableStream::AddReadIntoRequest(ScriptState* script_state, + ReadableStream* stream, + ReadIntoRequest* readRequest) { // https://streams.spec.whatwg.org/#readable-stream-add-read-into-request // 1. Assert: stream.[[reader]] implements ReadableStreamBYOBReader. DCHECK(stream->reader_->IsBYOBReader()); @@ -1931,30 +1970,21 @@ byob_reader->read_into_requests_.push_back(readRequest); } -StreamPromiseResolver* ReadableStream::AddReadRequest(ScriptState* script_state, - ReadableStream* stream) { +void ReadableStream::AddReadRequest(ScriptState* script_state, + ReadableStream* stream, + ReadRequest* read_request) { // https://streams.spec.whatwg.org/#readable-stream-add-read-request // 1. Assert: ! IsReadableStreamDefaultReader(stream.[[reader]]) is true. - ReadableStreamGenericReader* reader = stream->reader_; - ReadableStreamDefaultReader* default_reader = - To<ReadableStreamDefaultReader>(reader); - DCHECK(default_reader); + DCHECK(stream->reader_->IsDefaultReader()); // 2. Assert: stream.[[state]] is "readable". CHECK_EQ(stream->state_, kReadable); - // 3. Let promise be a new promise. - auto* promise = MakeGarbageCollected<StreamPromiseResolver>(script_state); - - // This implementation stores promises directly in |read_requests_| rather - // than wrapping them in a Record. - // 4. Let readRequest be Record {[[promise]]: promise}. - // 5. Append readRequest as the last element of stream.[[reader]]. - // [[readRequests]]. - default_reader->read_requests_.push_back(promise); - - // 6. Return promise. - return promise; + // 3. Append readRequest to stream.[[reader]].[[readRequests]]. + ReadableStreamGenericReader* reader = stream->reader_; + ReadableStreamDefaultReader* default_reader = + To<ReadableStreamDefaultReader>(reader); + default_reader->read_requests_.push_back(read_request); } v8::Local<v8::Promise> ReadableStream::Cancel(ScriptState* script_state, @@ -1990,16 +2020,14 @@ // a. Let readIntoRequests be reader.[[readIntoRequests]]. ReadableStreamBYOBReader* byob_reader = To<ReadableStreamBYOBReader>(reader); - HeapDeque<Member<ReadableStreamBYOBReader::ReadIntoRequest>> - read_into_requests; + HeapDeque<Member<ReadIntoRequest>> read_into_requests; read_into_requests.Swap(byob_reader->read_into_requests_); // b. Set reader.[[readIntoRequests]] to an empty list. // This is not required since we've already called Swap(). // c. For each readIntoRequest of readIntoRequests, - for (ReadableStreamBYOBReader::ReadIntoRequest* request : - read_into_requests) { + for (ReadIntoRequest* request : read_into_requests) { // i. Perform readIntoRequest's close steps, given undefined. request->CloseSteps(script_state, nullptr); } @@ -2054,74 +2082,19 @@ // 6. If reader implements ReadableStreamDefaultReader, if (reader->IsDefaultReader()) { // a. Let readRequests be reader.[[readRequests]]. - HeapDeque<Member<StreamPromiseResolver>> requests; + HeapDeque<Member<ReadRequest>> requests; requests.Swap(To<ReadableStreamDefaultReader>(reader)->read_requests_); - bool for_author_code = - To<ReadableStreamDefaultReader>(reader)->for_author_code_; // b. Set reader.[[readRequests]] to an empty list.` // This is not required since we've already called Swap() - // c. Repeat for each readRequest that is an element of reader. - // [[readRequests]], - for (StreamPromiseResolver* promise : requests) { - // i. Resolve readRequest.[[promise]] with ! - // ReadableStreamCreateReadResult(undefined, true, reader. - // [[forAuthorCode]]). - promise->Resolve( - script_state, - CreateReadResult(script_state, - v8::Undefined(script_state->GetIsolate()), true, - for_author_code)); + // c. For each readRequest of readRequests, + for (ReadRequest* request : requests) { + // i. Perform readRequest’s close steps. + request->CloseSteps(script_state); } } } -v8::Local<v8::Value> ReadableStream::CreateReadResult( - ScriptState* script_state, - v8::Local<v8::Value> value, - bool done, - bool for_author_code) { - // https://streams.spec.whatwg.org/#readable-stream-create-read-result - auto* isolate = script_state->GetIsolate(); - auto context = script_state->GetContext(); - auto value_string = V8AtomicString(isolate, "value"); - auto done_string = V8AtomicString(isolate, "done"); - auto done_value = v8::Boolean::New(isolate, done); - // 1. Let prototype be null. - // 2. If forAuthorCode is true, set prototype to %ObjectPrototype%. - // This implementation doesn't use a |prototype| variable, instead using - // different code paths depending on the value of |for_author_code|. - if (for_author_code) { - // 4. Let obj be ObjectCreate(prototype). - auto obj = v8::Object::New(isolate); - - // 5. Perform CreateDataProperty(obj, "value", value). - obj->CreateDataProperty(context, value_string, value).Check(); - - // 6. Perform CreateDataProperty(obj, "done", done). - obj->CreateDataProperty(context, done_string, done_value).Check(); - - // 7. Return obj. - return obj; - } - - // When |for_author_code| is false, we can perform all the steps in a single - // call to V8. - - // 4. Let obj be ObjectCreate(prototype). - // 5. Perform CreateDataProperty(obj, "value", value). - // 6. Perform CreateDataProperty(obj, "done", done). - // 7. Return obj. - // TODO(ricea): Is it possible to use this optimised API in both cases? - v8::Local<v8::Name> names[2] = {value_string, done_string}; - v8::Local<v8::Value> values[2] = {value, done_value}; - - static_assert(std::size(names) == std::size(values), - "names and values arrays must be the same size"); - return v8::Object::New(isolate, v8::Null(isolate), names, values, - std::size(names)); -} - void ReadableStream::Error(ScriptState* script_state, ReadableStream* stream, v8::Local<v8::Value> e) { @@ -2182,8 +2155,7 @@ // 3. Assert: reader.[[readIntoRequests]] is not empty. DCHECK(!byob_reader->read_into_requests_.empty()); // 4. Let readIntoRequest be reader.[[readIntoRequests]][0]. - ReadableStreamBYOBReader::ReadIntoRequest* read_into_request = - byob_reader->read_into_requests_[0]; + ReadIntoRequest* read_into_request = byob_reader->read_into_requests_[0]; // 5. Remove readIntoRequest from reader.[[readIntoRequests]]. byob_reader->read_into_requests_.pop_front(); // 6. If done is true, perform readIntoRequest’s close steps, given chunk. @@ -2208,19 +2180,22 @@ ReadableStreamDefaultReader* default_reader = To<ReadableStreamDefaultReader>(reader); - // 3. Let readRequest be the first element of reader.[[readRequests]]. - StreamPromiseResolver* read_request = default_reader->read_requests_.front(); + // 3. Assert: reader.[[readRequests]] is not empty. + DCHECK(!default_reader->read_requests_.empty()); - // 4. Remove readIntoRequest from reader.[[readIntoRequests]], shifting all - // other elements downward (so that the second becomes the first, and so - // on). + // 4. Let readRequest be reader.[[readRequests]][0]. + ReadRequest* read_request = default_reader->read_requests_[0]; + + // 5. Remove readRequest from reader.[[readRequests]]. default_reader->read_requests_.pop_front(); - // 5. Resolve readIntoRequest.[[promise]] with ! - // ReadableStreamCreateReadResult(chunk, done, reader.[[forAuthorCode]]). - read_request->Resolve(script_state, ReadableStream::CreateReadResult( - script_state, chunk, done, - default_reader->for_author_code_)); + // 6. If done is true, perform readRequest’s close steps. + if (done) { + read_request->CloseSteps(script_state); + } else { + // 7. Otherwise, perform readRequest’s chunk steps, given chunk. + read_request->ChunkSteps(script_state, chunk); + } } int ReadableStream::GetNumReadIntoRequests(const ReadableStream* stream) {
diff --git a/third_party/blink/renderer/core/streams/readable_stream.h b/third_party/blink/renderer/core/streams/readable_stream.h index 4fae3ca..2688846 100644 --- a/third_party/blink/renderer/core/streams/readable_stream.h +++ b/third_party/blink/renderer/core/streams/readable_stream.h
@@ -11,7 +11,6 @@ #include "third_party/blink/renderer/bindings/core/v8/script_value.h" #include "third_party/blink/renderer/bindings/core/v8/v8_typedefs.h" #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/core/streams/readable_stream_byob_reader.h" #include "third_party/blink/renderer/core/streams/readable_stream_default_reader.h" #include "third_party/blink/renderer/core/streams/transferable_streams.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" @@ -26,17 +25,19 @@ class ExceptionState; class MessagePort; class ReadableByteStreamController; +class ReadableStreamBYOBReader; class ReadableStreamController; class ReadableStreamDefaultController; class ReadableStreamGetReaderOptions; class ReadableStreamTransferringOptimizer; class ReadableWritablePair; +class ReadIntoRequest; +class ReadRequest; class ScriptPromise; class ScriptState; class StrategySizeAlgorithm; class StreamAlgorithm; class StreamPipeOptions; -class StreamPromiseResolver; class StreamStartAlgorithm; class UnderlyingByteSourceBase; class UnderlyingSourceBase; @@ -249,7 +250,6 @@ // https://streams.spec.whatwg.org/#acquire-readable-stream-reader static ReadableStreamDefaultReader* AcquireDefaultReader(ScriptState*, ReadableStream*, - bool for_author_code, ExceptionState&); // https://streams.spec.whatwg.org/#acquire-readable-stream-byob-reader @@ -313,10 +313,10 @@ static void AddReadIntoRequest(ScriptState*, ReadableStream*, - ReadableStreamBYOBReader::ReadIntoRequest*); + ReadIntoRequest*); // https://streams.spec.whatwg.org/#readable-stream-add-read-request - static StreamPromiseResolver* AddReadRequest(ScriptState*, ReadableStream*); + static void AddReadRequest(ScriptState*, ReadableStream*, ReadRequest*); // https://streams.spec.whatwg.org/#readable-stream-cancel static v8::Local<v8::Promise> Cancel(ScriptState*, @@ -326,12 +326,6 @@ // https://streams.spec.whatwg.org/#readable-stream-close static void Close(ScriptState*, ReadableStream*); - // https://streams.spec.whatwg.org/#readable-stream-create-read-result - static v8::Local<v8::Value> CreateReadResult(ScriptState*, - v8::Local<v8::Value> value, - bool done, - bool for_author_code); - // https://streams.spec.whatwg.org/#readable-stream-error static void Error(ScriptState*, ReadableStream*, v8::Local<v8::Value> e);
diff --git a/third_party/blink/renderer/core/streams/readable_stream_byob_reader.cc b/third_party/blink/renderer/core/streams/readable_stream_byob_reader.cc index 52d6a40..9f39f720 100644 --- a/third_party/blink/renderer/core/streams/readable_stream_byob_reader.cc +++ b/third_party/blink/renderer/core/streams/readable_stream_byob_reader.cc
@@ -6,6 +6,8 @@ #include "third_party/blink/renderer/bindings/core/v8/script_promise.h" #include "third_party/blink/renderer/bindings/core/v8/to_v8_traits.h" +#include "third_party/blink/renderer/bindings/core/v8/v8_readable_stream_read_result.h" +#include "third_party/blink/renderer/core/streams/read_into_request.h" #include "third_party/blink/renderer/core/streams/readable_stream.h" #include "third_party/blink/renderer/core/streams/readable_stream_controller.h" #include "third_party/blink/renderer/core/streams/stream_promise_resolver.h" @@ -18,44 +20,53 @@ namespace blink { -ReadableStreamBYOBReader::ReadIntoRequest::ReadIntoRequest( - StreamPromiseResolver* resolver) - : resolver_(resolver) {} +class ReadableStreamBYOBReader::BYOBReaderReadIntoRequest final + : public ReadIntoRequest { + public: + explicit BYOBReaderReadIntoRequest(StreamPromiseResolver* resolver) + : resolver_(resolver) {} -void ReadableStreamBYOBReader::ReadIntoRequest::ChunkSteps( - ScriptState* script_state, - DOMArrayBufferView* chunk) const { - resolver_->Resolve(script_state, ReadableStream::CreateReadResult( - script_state, - ToV8Traits<DOMArrayBufferView>::ToV8( - script_state, chunk) - .ToLocalChecked(), - false, true)); -} + void ChunkSteps(ScriptState* script_state, + DOMArrayBufferView* chunk) const override { + auto* read_result = ReadableStreamReadResult::Create(); + read_result->setValue( + ScriptValue(script_state->GetIsolate(), + ToV8Traits<DOMArrayBufferView>::ToV8(script_state, chunk) + .ToLocalChecked())); + read_result->setDone(false); + resolver_->Resolve(script_state, + ToV8(read_result, script_state->GetContext()->Global(), + script_state->GetIsolate())); + } -void ReadableStreamBYOBReader::ReadIntoRequest::CloseSteps( - ScriptState* script_state, - DOMArrayBufferView* chunk) const { - resolver_->Resolve( - script_state, - ReadableStream::CreateReadResult( - script_state, - chunk ? ToV8Traits<DOMArrayBufferView>::ToV8(script_state, chunk) - .ToLocalChecked() - : static_cast<v8::Local<v8::Value>>( - v8::Undefined(script_state->GetIsolate())), - true, true)); -} + void CloseSteps(ScriptState* script_state, + DOMArrayBufferView* chunk) const override { + auto* read_result = ReadableStreamReadResult::Create(); + read_result->setValue(ScriptValue( + script_state->GetIsolate(), + chunk ? ToV8Traits<DOMArrayBufferView>::ToV8(script_state, chunk) + .ToLocalChecked() + : static_cast<v8::Local<v8::Value>>( + v8::Undefined(script_state->GetIsolate())))); + read_result->setDone(true); + resolver_->Resolve(script_state, + ToV8(read_result, script_state->GetContext()->Global(), + script_state->GetIsolate())); + } -void ReadableStreamBYOBReader::ReadIntoRequest::ErrorSteps( - ScriptState* script_state, - v8::Local<v8::Value> e) const { - resolver_->Reject(script_state, e); -} + void ErrorSteps(ScriptState* script_state, + v8::Local<v8::Value> e) const override { + resolver_->Reject(script_state, e); + } -void ReadableStreamBYOBReader::ReadIntoRequest::Trace(Visitor* visitor) const { - visitor->Trace(resolver_); -} + void Trace(Visitor* visitor) const override { + visitor->Trace(resolver_); + ReadIntoRequest::Trace(visitor); + } + + private: + Member<StreamPromiseResolver> resolver_; +}; ReadableStreamBYOBReader* ReadableStreamBYOBReader::Create( ScriptState* script_state, @@ -128,7 +139,8 @@ // 1. Resolve promise with «[ "value" → chunk, "done" → true ]». // error steps, given e // 1. Reject promise with e. - auto* read_into_request = MakeGarbageCollected<ReadIntoRequest>(promise); + auto* read_into_request = + MakeGarbageCollected<BYOBReaderReadIntoRequest>(promise); // 7. Perform ! ReadableStreamBYOBReaderRead(this, view, readIntoRequest). Read(script_state, this, view, read_into_request, exception_state); @@ -175,8 +187,7 @@ // 1. Let readIntoRequests be reader.[[readIntoRequests]]. // 2. Set reader.[[readIntoRequests]] to a new empty list. // 3. For each readIntoRequest of readIntoRequests, - for (ReadableStreamBYOBReader::ReadIntoRequest* request : - reader->read_into_requests_) { + for (ReadIntoRequest* request : reader->read_into_requests_) { // a. Perform readIntoRequest’s error steps, given e. request->ErrorSteps(script_state, e); }
diff --git a/third_party/blink/renderer/core/streams/readable_stream_byob_reader.h b/third_party/blink/renderer/core/streams/readable_stream_byob_reader.h index 9bfcbd0..be6dc9b 100644 --- a/third_party/blink/renderer/core/streams/readable_stream_byob_reader.h +++ b/third_party/blink/renderer/core/streams/readable_stream_byob_reader.h
@@ -19,8 +19,8 @@ class ExceptionState; class ScriptPromise; class ScriptState; -class StreamPromiseResolver; class ReadableStream; +class ReadIntoRequest; class DOMArrayBufferView; class CORE_EXPORT ReadableStreamBYOBReader @@ -61,21 +61,7 @@ friend class ReadableByteStreamController; friend class ReadableStream; - class ReadIntoRequest : public GarbageCollected<ReadIntoRequest> { - public: - explicit ReadIntoRequest(StreamPromiseResolver* resolver); - - void ChunkSteps(ScriptState*, DOMArrayBufferView* chunk) const; - void CloseSteps(ScriptState*, DOMArrayBufferView* chunk) const; - void ErrorSteps(ScriptState*, v8::Local<v8::Value> e) const; - - void Trace(Visitor*) const; - - private: - friend class ReadableStream; - - Member<StreamPromiseResolver> resolver_; - }; + class BYOBReaderReadIntoRequest; // // Readable stream reader abstract operations
diff --git a/third_party/blink/renderer/core/streams/readable_stream_byob_request.h b/third_party/blink/renderer/core/streams/readable_stream_byob_request.h index 1901107..e0456fcf 100644 --- a/third_party/blink/renderer/core/streams/readable_stream_byob_request.h +++ b/third_party/blink/renderer/core/streams/readable_stream_byob_request.h
@@ -8,6 +8,7 @@ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/streams/readable_byte_stream_controller.h" #include "third_party/blink/renderer/core/typed_arrays/array_buffer_view_helpers.h" +#include "third_party/blink/renderer/core/typed_arrays/dom_typed_array.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" namespace blink {
diff --git a/third_party/blink/renderer/core/streams/readable_stream_controller.h b/third_party/blink/renderer/core/streams/readable_stream_controller.h index f932514..b9465657 100644 --- a/third_party/blink/renderer/core/streams/readable_stream_controller.h +++ b/third_party/blink/renderer/core/streams/readable_stream_controller.h
@@ -10,8 +10,8 @@ namespace blink { +class ReadRequest; class ScriptState; -class StreamPromiseResolver; class ReadableStreamController : public ScriptWrappable { public: @@ -23,7 +23,7 @@ v8::Local<v8::Value> reason) = 0; // https://streams.spec.whatwg.org/#abstract-opdef-readablestreamcontroller-pullsteps - virtual StreamPromiseResolver* PullSteps(ScriptState*) = 0; + virtual void PullSteps(ScriptState*, ReadRequest*) = 0; // https://streams.spec.whatwg.org/#abstract-opdef-readablestreamcontroller-releasesteps virtual void ReleaseSteps() = 0;
diff --git a/third_party/blink/renderer/core/streams/readable_stream_default_controller.cc b/third_party/blink/renderer/core/streams/readable_stream_default_controller.cc index d2b0e54..db0e1f6 100644 --- a/third_party/blink/renderer/core/streams/readable_stream_default_controller.cc +++ b/third_party/blink/renderer/core/streams/readable_stream_default_controller.cc
@@ -9,10 +9,10 @@ #include "third_party/blink/renderer/core/streams/miscellaneous_operations.h" #include "third_party/blink/renderer/core/streams/promise_handler.h" #include "third_party/blink/renderer/core/streams/queue_with_sizes.h" +#include "third_party/blink/renderer/core/streams/read_request.h" #include "third_party/blink/renderer/core/streams/readable_stream.h" #include "third_party/blink/renderer/core/streams/readable_stream_default_reader.h" #include "third_party/blink/renderer/core/streams/stream_algorithms.h" -#include "third_party/blink/renderer/core/streams/stream_promise_resolver.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/bindings/to_v8.h" @@ -21,8 +21,70 @@ namespace blink { // This constructor is used internally; it is not reachable from JavaScript. -ReadableStreamDefaultController::ReadableStreamDefaultController() - : queue_(MakeGarbageCollected<QueueWithSizes>()) {} +ReadableStreamDefaultController::ReadableStreamDefaultController( + ScriptState* script_state) + : queue_(MakeGarbageCollected<QueueWithSizes>()) { + class CallPullIfNeededResolveFunction final : public PromiseHandler { + public: + explicit CallPullIfNeededResolveFunction( + ReadableStreamDefaultController* controller) + : controller_(controller) {} + + void CallWithLocal(ScriptState* script_state, + v8::Local<v8::Value>) override { + // https://streams.spec.whatwg.org/#readable-stream-default-controller-call-pull-if-needed + // 7. Upon fulfillment of pullPromise, + // a. Set controller.[[pulling]] to false. + controller_->is_pulling_ = false; + + // b. If controller.[[pullAgain]] is true, + if (controller_->will_pull_again_) { + // i. Set controller.[[pullAgain]] to false. + controller_->will_pull_again_ = false; + + // ii. Perform ! ReadableStreamDefaultControllerCallPullIfNeeded( + // controller). + CallPullIfNeeded(script_state, controller_); + } + } + + void Trace(Visitor* visitor) const override { + visitor->Trace(controller_); + PromiseHandler::Trace(visitor); + } + + private: + const Member<ReadableStreamDefaultController> controller_; + }; + + class CallPullIfNeededRejectFunction final : public PromiseHandler { + public: + explicit CallPullIfNeededRejectFunction( + ReadableStreamDefaultController* controller) + : controller_(controller) {} + + void CallWithLocal(ScriptState* script_state, + v8::Local<v8::Value> e) override { + // 8. Upon rejection of pullPromise with reason e, + // a. Perform ! ReadableStreamDefaultControllerError(controller, e). + Error(script_state, controller_, e); + } + + void Trace(Visitor* visitor) const override { + visitor->Trace(controller_); + PromiseHandler::Trace(visitor); + } + + private: + const Member<ReadableStreamDefaultController> controller_; + }; + + resolve_function_ = MakeGarbageCollected<ScriptFunction>( + script_state, + MakeGarbageCollected<CallPullIfNeededResolveFunction>(this)); + reject_function_ = MakeGarbageCollected<ScriptFunction>( + script_state, MakeGarbageCollected<CallPullIfNeededRejectFunction>(this)); +} void ReadableStreamDefaultController::close(ScriptState* script_state, ExceptionState& exception_state) { @@ -125,12 +187,14 @@ v8::Local<v8::Value> chunk, ExceptionState& exception_state) { // https://streams.spec.whatwg.org/#readable-stream-default-controller-enqueue - // 1. Let stream be controller.[[controlledReadableStream]]. - const auto stream = controller->controlled_readable_stream_; + // 1. If ! ReadableStreamDefaultControllerCanCloseOrEnqueue(controller) is + // false, return. + if (!CanCloseOrEnqueue(controller)) { + return; + } - // 2. Assert: ! ReadableStreamDefaultControllerCanCloseOrEnqueue(controller) - // is true. - CHECK(CanCloseOrEnqueue(controller)); + // 2. Let stream be controller.[[stream]]. + const auto stream = controller->controlled_readable_stream_; // 3. If ! IsReadableStreamLocked(stream) is true and ! // ReadableStreamGetNumReadRequests(stream) > 0, perform ! @@ -263,6 +327,8 @@ visitor->Trace(pull_algorithm_); visitor->Trace(queue_); visitor->Trace(strategy_size_algorithm_); + visitor->Trace(resolve_function_); + visitor->Trace(reject_function_); ScriptWrappable::Trace(visitor); } @@ -288,8 +354,8 @@ return result; } -StreamPromiseResolver* ReadableStreamDefaultController::PullSteps( - ScriptState* script_state) { +void ReadableStreamDefaultController::PullSteps(ScriptState* script_state, + ReadRequest* read_request) { // https://streams.spec.whatwg.org/#rs-default-controller-private-pull // 1. Let stream be this.[[stream]]. ReadableStream* stream = controlled_readable_stream_; @@ -312,26 +378,16 @@ CallPullIfNeeded(script_state, this); } - // d. Return a promise resolved with ! - // ReadableStreamCreateReadResult(chunk, false, - // stream.[[reader]].[[forAuthorCode]]). - ReadableStreamGenericReader* reader = stream->reader_; - return StreamPromiseResolver::CreateResolved( - script_state, - ReadableStream::CreateReadResult( - script_state, chunk, false, - To<ReadableStreamDefaultReader>(reader)->for_author_code_)); + // d. Perform readRequest’s chunk steps, given chunk. + read_request->ChunkSteps(script_state, chunk); + // 3. Otherwise, + } else { + // a. Perform ! ReadableStreamAddReadRequest(stream, readRequest). + ReadableStream::AddReadRequest(script_state, stream, read_request); + + // b. Perform ! ReadableStreamDefaultControllerCallPullIfNeeded(this). + CallPullIfNeeded(script_state, this); } - - // 3. Let pendingPromise be ! ReadableStreamAddReadRequest(stream). - StreamPromiseResolver* pendingPromise = - ReadableStream::AddReadRequest(script_state, stream); - - // 4. Perform ! ReadableStreamDefaultControllerCallPullIfNeeded(this). - CallPullIfNeeded(script_state, this); - - // 5. Return pendingPromise. - return pendingPromise; } void ReadableStreamDefaultController::ReleaseSteps() { @@ -377,65 +433,9 @@ auto pull_promise = controller->pull_algorithm_->Run(script_state, 0, nullptr); - class ResolveFunction final : public PromiseHandler { - public: - explicit ResolveFunction(ReadableStreamDefaultController* controller) - : controller_(controller) {} - - void CallWithLocal(ScriptState* script_state, - v8::Local<v8::Value>) override { - // 7. Upon fulfillment of pullPromise, - // a. Set controller.[[pulling]] to false. - controller_->is_pulling_ = false; - - // b. If controller.[[pullAgain]] is true, - if (controller_->will_pull_again_) { - // i. Set controller.[[pullAgain]] to false. - controller_->will_pull_again_ = false; - - // ii. Perform ! ReadableStreamDefaultControllerCallPullIfNeeded( - // controller). - CallPullIfNeeded(script_state, controller_); - } - } - - void Trace(Visitor* visitor) const override { - visitor->Trace(controller_); - PromiseHandler::Trace(visitor); - } - - private: - const Member<ReadableStreamDefaultController> controller_; - }; - - class RejectFunction final : public PromiseHandler { - public: - explicit RejectFunction(ReadableStreamDefaultController* controller) - : controller_(controller) {} - - void CallWithLocal(ScriptState* script_state, - v8::Local<v8::Value> e) override { - // 8. Upon rejection of pullPromise with reason e, - // a. Perform ! ReadableStreamDefaultControllerError(controller, e). - Error(script_state, controller_, e); - } - - void Trace(Visitor* visitor) const override { - visitor->Trace(controller_); - PromiseHandler::Trace(visitor); - } - - private: - const Member<ReadableStreamDefaultController> controller_; - }; - - StreamThenPromise( - script_state->GetContext(), pull_promise, - MakeGarbageCollected<ScriptFunction>( - script_state, MakeGarbageCollected<ResolveFunction>(controller)), - - MakeGarbageCollected<ScriptFunction>( - script_state, MakeGarbageCollected<RejectFunction>(controller))); + StreamThenPromise(script_state->GetContext(), pull_promise, + controller->resolve_function_, + controller->reject_function_); } bool ReadableStreamDefaultController::ShouldCallPull( @@ -614,7 +614,8 @@ // https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller-from-underlying-source // 2. Let controller be ObjectCreate(the original value of // ReadableStreamDefaultController's prototype property). - auto* controller = MakeGarbageCollected<ReadableStreamDefaultController>(); + auto* controller = + MakeGarbageCollected<ReadableStreamDefaultController>(script_state); // This method is only called when a WritableStream is being constructed by // JavaScript. So the execution context should be valid and this call should
diff --git a/third_party/blink/renderer/core/streams/readable_stream_default_controller.h b/third_party/blink/renderer/core/streams/readable_stream_default_controller.h index 70c1a7c..2071328 100644 --- a/third_party/blink/renderer/core/streams/readable_stream_default_controller.h +++ b/third_party/blink/renderer/core/streams/readable_stream_default_controller.h
@@ -16,18 +16,19 @@ class ExceptionState; class QueueWithSizes; class ReadableStream; +class ReadRequest; +class ScriptFunction; class ScriptState; class ScriptValue; class StrategySizeAlgorithm; class StreamAlgorithm; -class StreamPromiseResolver; class StreamStartAlgorithm; class ReadableStreamDefaultController : public ReadableStreamController { DEFINE_WRAPPERTYPEINFO(); public: - ReadableStreamDefaultController(); + explicit ReadableStreamDefaultController(ScriptState*); // https://streams.spec.whatwg.org/#rs-default-controller-desired-size absl::optional<double> desiredSize() const { return GetDesiredSize(); } @@ -82,7 +83,7 @@ v8::Local<v8::Value> reason) override; // https://streams.spec.whatwg.org/#rs-default-controller-private-pull - StreamPromiseResolver* PullSteps(ScriptState*) override; + void PullSteps(ScriptState*, ReadRequest*) override; // https://streams.spec.whatwg.org/#abstract-opdef-readablestreamdefaultcontroller-releasesteps void ReleaseSteps() override; @@ -131,6 +132,8 @@ Member<QueueWithSizes> queue_; double strategy_high_water_mark_ = 0.0; Member<StrategySizeAlgorithm> strategy_size_algorithm_; + Member<ScriptFunction> resolve_function_; + Member<ScriptFunction> reject_function_; }; template <>
diff --git a/third_party/blink/renderer/core/streams/readable_stream_default_reader.cc b/third_party/blink/renderer/core/streams/readable_stream_default_reader.cc index 8635e21..c6ea035 100644 --- a/third_party/blink/renderer/core/streams/readable_stream_default_reader.cc +++ b/third_party/blink/renderer/core/streams/readable_stream_default_reader.cc
@@ -5,16 +5,61 @@ #include "third_party/blink/renderer/core/streams/readable_stream_default_reader.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise.h" +#include "third_party/blink/renderer/bindings/core/v8/to_v8_traits.h" +#include "third_party/blink/renderer/bindings/core/v8/v8_readable_stream_read_result.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h" +#include "third_party/blink/renderer/core/streams/read_request.h" #include "third_party/blink/renderer/core/streams/readable_stream.h" #include "third_party/blink/renderer/core/streams/readable_stream_default_controller.h" #include "third_party/blink/renderer/core/streams/stream_promise_resolver.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h" +#include "third_party/blink/renderer/platform/bindings/to_v8.h" #include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h" namespace blink { +class ReadableStreamDefaultReader::DefaultReaderReadRequest final + : public ReadRequest { + public: + explicit DefaultReaderReadRequest(StreamPromiseResolver* resolver) + : resolver_(resolver) {} + + void ChunkSteps(ScriptState* script_state, + v8::Local<v8::Value> chunk) const override { + // This is needed so that there is a valid v8::Context when fulfilling the + // read request. + ScriptState::Scope scope(script_state); + auto* read_result = ReadableStreamReadResult::Create(); + read_result->setValue(ScriptValue(script_state->GetIsolate(), chunk)); + read_result->setDone(false); + resolver_->Resolve(script_state, ToV8(read_result, script_state)); + } + + void CloseSteps(ScriptState* script_state) const override { + auto* read_result = ReadableStreamReadResult::Create(); + read_result->setValue(ScriptValue( + script_state->GetIsolate(), v8::Undefined(script_state->GetIsolate()))); + read_result->setDone(true); + resolver_->Resolve(script_state, + ToV8(read_result, script_state->GetContext()->Global(), + script_state->GetIsolate())); + } + + void ErrorSteps(ScriptState* script_state, + v8::Local<v8::Value> e) const override { + resolver_->Reject(script_state, e); + } + + void Trace(Visitor* visitor) const override { + visitor->Trace(resolver_); + ReadRequest::Trace(visitor); + } + + private: + Member<StreamPromiseResolver> resolver_; +}; + ReadableStreamDefaultReader* ReadableStreamDefaultReader::Create( ScriptState* script_state, ReadableStream* stream, @@ -43,7 +88,7 @@ ScriptState* script_state, ExceptionState& exception_state) { // https://streams.spec.whatwg.org/#default-reader-read - // 2. If this.[[ownerReadableStream]] is undefined, return a promise rejected + // 1. If this.[[stream]] is undefined, return a promise rejected // with a TypeError exception. if (!owner_readable_stream_) { exception_state.ThrowTypeError( @@ -52,16 +97,31 @@ return ScriptPromise(); } - // 3. Return ! ReadableStreamReaderRead(this). - return Read(script_state, this)->GetScriptPromise(script_state); + // 2. Let promise be a new promise. + auto* promise = MakeGarbageCollected<StreamPromiseResolver>(script_state); + + // 3. Let readRequest be a new read request with the following items: + // chunk steps, given chunk + // 1. Resolve promise with «[ "value" → chunk, "done" → false ]». + // close steps + // 1. Resolve promise with «[ "value" → undefined, "done" → true ]». + // error steps, given e + // 1. Reject promise with e. + auto* read_request = MakeGarbageCollected<DefaultReaderReadRequest>(promise); + + // 4. Perform ! ReadableStreamReaderRead(this). + Read(script_state, this, read_request); + + // 5. Return promise. + return promise->GetScriptPromise(script_state); } -StreamPromiseResolver* ReadableStreamDefaultReader::Read( - ScriptState* script_state, - ReadableStreamDefaultReader* reader) { +void ReadableStreamDefaultReader::Read(ScriptState* script_state, + ReadableStreamDefaultReader* reader, + ReadRequest* read_request) { auto* isolate = script_state->GetIsolate(); // https://streams.spec.whatwg.org/#readable-stream-default-reader-read - // 1. Let stream be reader.[[ownerReadableStream]]. + // 1. Let stream be reader.[[stream]]. ReadableStream* stream = reader->owner_readable_stream_; // 2. Assert: stream is not undefined. @@ -71,27 +131,26 @@ stream->is_disturbed_ = true; switch (stream->state_) { - // 4. If stream.[[state]] is "closed", return a promise resolved with ! - // ReadableStreamCreateReadResult(undefined, true, - // reader.[[forAuthorCode]]). + // 4. If stream.[[state]] is "closed", perform readRequest's close steps. case ReadableStream::kClosed: - return StreamPromiseResolver::CreateResolved( - script_state, - ReadableStream::CreateReadResult(script_state, v8::Undefined(isolate), - true, reader->for_author_code_)); + read_request->CloseSteps(script_state); + break; - // 5. If stream.[[state]] is "errored", return a promise rejected with - // stream.[[storedError]]. + // 5. Otherwise, if stream.[[state]] is "errored", perform readRequest's + // error steps + // given stream.[[storedError]]. case ReadableStream::kErrored: - return StreamPromiseResolver::CreateRejected( - script_state, stream->GetStoredError(isolate)); + read_request->ErrorSteps(script_state, stream->GetStoredError(isolate)); + break; case ReadableStream::kReadable: - // 6. Assert: stream.[[state]] is "readable". + // 6. Otherwise, + // 1. Assert: stream.[[state]] is "readable". DCHECK_EQ(stream->state_, ReadableStream::kReadable); - // 7. Return ! stream.[[readableStreamController]].[[PullSteps]](). - return stream->GetController()->PullSteps(script_state); + // 2. Perform ! stream.[[controller]].[[PullSteps]](readRequest). + stream->GetController()->PullSteps(script_state, read_request); + break; } } @@ -103,9 +162,9 @@ // 1. Let readRequests be reader.[[readRequests]]. // 2. Set reader.[[readRequests]] to a new empty list. // 3. For each readRequest of readRequests, - for (StreamPromiseResolver* promise : reader->read_requests_) { + for (ReadRequest* read_request : reader->read_requests_) { // a. Perform readRequest’s error steps, given e. - promise->Reject(script_state, e); + read_request->ErrorSteps(script_state, e); } reader->read_requests_.clear(); } @@ -152,8 +211,6 @@ return; } - DCHECK(reader->for_author_code_); - // 2. Perform ! ReadableStreamReaderGenericInitialize(reader, stream). ReadableStreamGenericReader::GenericInitialize(script_state, reader, stream);
diff --git a/third_party/blink/renderer/core/streams/readable_stream_default_reader.h b/third_party/blink/renderer/core/streams/readable_stream_default_reader.h index 299e9d0..ef41666 100644 --- a/third_party/blink/renderer/core/streams/readable_stream_default_reader.h +++ b/third_party/blink/renderer/core/streams/readable_stream_default_reader.h
@@ -17,9 +17,9 @@ class ExceptionState; class ReadableStream; +class ReadRequest; class ScriptPromise; class ScriptState; -class StreamPromiseResolver; class CORE_EXPORT ReadableStreamDefaultReader : public ReadableStreamGenericReader, @@ -57,8 +57,9 @@ // // https://streams.spec.whatwg.org/#readable-stream-default-reader-read - static StreamPromiseResolver* Read(ScriptState*, - ReadableStreamDefaultReader* reader); + static void Read(ScriptState*, + ReadableStreamDefaultReader* reader, + ReadRequest*); // https://streams.spec.whatwg.org/#abstract-opdef-readablestreamdefaultreadererrorreadrequests static void ErrorReadRequests(ScriptState*, @@ -74,11 +75,13 @@ private: friend class ReadableByteStreamController; + friend class ReadableStreamController; friend class ReadableStreamDefaultController; friend class ReadableStream; - HeapDeque<Member<StreamPromiseResolver>> read_requests_; - bool for_author_code_ = true; + class DefaultReaderReadRequest; + + HeapDeque<Member<ReadRequest>> read_requests_; }; template <>
diff --git a/third_party/blink/renderer/core/streams/readable_stream_default_reader.idl b/third_party/blink/renderer/core/streams/readable_stream_default_reader.idl index 143fe390..9fe0981 100644 --- a/third_party/blink/renderer/core/streams/readable_stream_default_reader.idl +++ b/third_party/blink/renderer/core/streams/readable_stream_default_reader.idl
@@ -8,7 +8,7 @@ ActiveScriptWrappable ] interface ReadableStreamDefaultReader { [CallWith=ScriptState, RaisesException] constructor(ReadableStream stream); - [CallWith=ScriptState, RaisesException] Promise<void> read(); + [CallWith=ScriptState, RaisesException] Promise<ReadableStreamReadResult> read(); [CallWith=ScriptState, RaisesException] void releaseLock(); };
diff --git a/third_party/blink/renderer/core/streams/readable_stream_read_result.idl b/third_party/blink/renderer/core/streams/readable_stream_read_result.idl new file mode 100644 index 0000000..87eae07 --- /dev/null +++ b/third_party/blink/renderer/core/streams/readable_stream_read_result.idl
@@ -0,0 +1,10 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// https://streams.spec.whatwg.org/#dictdef-readablestreamreadresult + +dictionary ReadableStreamReadResult { + any value; + boolean done; +};
diff --git a/third_party/blink/renderer/core/streams/readable_stream_test.cc b/third_party/blink/renderer/core/streams/readable_stream_test.cc index d4f54de..6499d08 100644 --- a/third_party/blink/renderer/core/streams/readable_stream_test.cc +++ b/third_party/blink/renderer/core/streams/readable_stream_test.cc
@@ -19,6 +19,7 @@ #include "third_party/blink/renderer/bindings/core/v8/v8_readable_stream_get_reader_options.h" #include "third_party/blink/renderer/bindings/core/v8/v8_union_readablestreambyobreader_readablestreamdefaultreader.h" #include "third_party/blink/renderer/core/messaging/message_channel.h" +#include "third_party/blink/renderer/core/streams/readable_stream_byob_reader.h" #include "third_party/blink/renderer/core/streams/readable_stream_default_controller_with_script_scope.h" #include "third_party/blink/renderer/core/streams/readable_stream_default_reader.h" #include "third_party/blink/renderer/core/streams/readable_stream_transferring_optimizer.h"
diff --git a/third_party/blink/renderer/core/streams/transferable_streams.cc b/third_party/blink/renderer/core/streams/transferable_streams.cc index bb55a33..846fba62 100644 --- a/third_party/blink/renderer/core/streams/transferable_streams.cc +++ b/third_party/blink/renderer/core/streams/transferable_streams.cc
@@ -7,7 +7,6 @@ #include "third_party/blink/renderer/core/streams/transferable_streams.h" -#include "third_party/blink/renderer/bindings/core/v8/iterable.h" #include "third_party/blink/renderer/bindings/core/v8/script_function.h" #include "third_party/blink/renderer/bindings/core/v8/to_v8_traits.h" #include "third_party/blink/renderer/bindings/core/v8/v8_dom_exception.h" @@ -20,6 +19,7 @@ #include "third_party/blink/renderer/core/messaging/message_port.h" #include "third_party/blink/renderer/core/streams/miscellaneous_operations.h" #include "third_party/blink/renderer/core/streams/promise_handler.h" +#include "third_party/blink/renderer/core/streams/read_request.h" #include "third_party/blink/renderer/core/streams/readable_stream.h" #include "third_party/blink/renderer/core/streams/readable_stream_default_controller.h" #include "third_party/blink/renderer/core/streams/readable_stream_default_controller_with_script_scope.h" @@ -114,6 +114,7 @@ ExceptionState& exception_state) { DVLOG(3) << "PackAndPostMessage sending message type " << static_cast<int>(type); + v8::Context::Scope v8_context_scope(script_state->GetContext()); auto* isolate = script_state->GetIsolate(); // https://streams.spec.whatwg.org/#abstract-opdef-packandpostmessage @@ -401,6 +402,7 @@ // 2. Return the result of reacting to backpressurePromise with the // following fulfillment steps: + return StreamThenPromise( script_state->GetContext(), writable_->backpressure_promise_->V8Promise(isolate), @@ -798,74 +800,66 @@ const Member<ConcatenatingUnderlyingSource> source_; }; - class OnReadingSource1Success final : public ScriptFunction::Callable { + class ConcatenatingUnderlyingSourceReadRequest final : public ReadRequest { public: - explicit OnReadingSource1Success(ConcatenatingUnderlyingSource* source) - : source_(source) {} + explicit ConcatenatingUnderlyingSourceReadRequest( + ConcatenatingUnderlyingSource* source, + StreamPromiseResolver* resolver) + : source_(source), resolver_(resolver) {} - void Trace(Visitor* visitor) const override { - visitor->Trace(source_); - ScriptFunction::Callable::Trace(visitor); - } - ScriptValue Call(ScriptState* script_state, - ScriptValue read_result) override { - DCHECK(read_result.IsObject()); - v8::Local<v8::Value> value; - bool done = false; - CHECK(V8UnpackIterationResult( - script_state, read_result.V8Value().As<v8::Object>(), &value, &done)); - if (done) { - // We've finished reading `source1_`. Let's start reading `source2_`. - source_->has_finished_reading_stream1_ = true; - ReadableStreamDefaultController* controller = - source_->Controller()->GetOriginalController(); - // TODO(ricea): Remove or demote to DCHECK once - // https://crbug.com/1418910 has been fixed. - CHECK(controller); - return source_->source2_ - ->startWrapper(script_state, - ScriptValue::From(script_state, controller)) - .Then(CreateFunction<PullSource2>(script_state, source_)) - .AsScriptValue(); - } - source_->Controller()->Enqueue(value); - return ScriptPromise::CastUndefined(script_state).AsScriptValue(); + void ChunkSteps(ScriptState* script_state, + v8::Local<v8::Value> chunk) const override { + source_->Controller()->Enqueue(chunk); + resolver_->ResolveWithUndefined(script_state); } - private: - const Member<ConcatenatingUnderlyingSource> source_; - }; - - class OnReadingSource1Fail final : public ScriptFunction::Callable { - public: - explicit OnReadingSource1Fail(ConcatenatingUnderlyingSource* source) - : source_(source) {} - - void Trace(Visitor* visitor) const override { - visitor->Trace(source_); - ScriptFunction::Callable::Trace(visitor); + void CloseSteps(ScriptState* script_state) const override { + // We've finished reading `source1_`. Let's start reading `source2_`. + source_->has_finished_reading_stream1_ = true; + ReadableStreamDefaultController* controller = + source_->Controller()->GetOriginalController(); + // TODO(ricea): Remove or demote to DCHECK once + // https://crbug.com/1418910 has been fixed. + CHECK(controller); + resolver_->Resolve( + script_state, + ToV8(source_->source2_ + ->startWrapper(script_state, + ScriptValue::From(script_state, controller)) + .Then(CreateFunction<PullSource2>(script_state, source_)), + script_state->GetContext()->Global(), + script_state->GetIsolate())); } - ScriptValue Call(ScriptState* script_state, ScriptValue value) override { - ScriptValue reason(script_state->GetIsolate(), - v8::Undefined(script_state->GetIsolate())); - + void ErrorSteps(ScriptState* script_state, + v8::Local<v8::Value> e) const override { ReadableStream* dummy_stream = ReadableStream::CreateWithCountQueueingStrategy( script_state, source_->source2_, /*high_water_mark=*/0); + ExceptionState exception_state(script_state->GetIsolate(), ExceptionState::kUnknownContext, "", ""); - dummy_stream->cancel(script_state, reason, exception_state); + dummy_stream->cancel( + script_state, + ScriptValue(script_state->GetIsolate(), + v8::Undefined(script_state->GetIsolate())), + exception_state); // We don't care about the result of the cancellation, including // exceptions. exception_state.ClearException(); + resolver_->Reject(script_state, e); + } - return ScriptPromise::Reject(script_state, value).AsScriptValue(); + void Trace(Visitor* visitor) const override { + visitor->Trace(source_); + visitor->Trace(resolver_); + ReadRequest::Trace(visitor); } private: - const Member<ConcatenatingUnderlyingSource> source_; + Member<ConcatenatingUnderlyingSource> source_; + Member<StreamPromiseResolver> resolver_; }; ConcatenatingUnderlyingSource(ScriptState* script_state, @@ -879,7 +873,7 @@ ExceptionState exception_state(script_state->GetIsolate(), ExceptionState::kUnknownContext, "", ""); reader_for_stream1_ = ReadableStream::AcquireDefaultReader( - script_state, stream1_, /*for_author_code=*/false, exception_state); + script_state, stream1_, exception_state); if (exception_state.HadException()) { return ScriptPromise::Reject(script_state, exception_state); } @@ -891,16 +885,13 @@ if (has_finished_reading_stream1_) { return source2_->pull(script_state); } - ExceptionState exception_state(script_state->GetIsolate(), - ExceptionState::kUnknownContext, "", ""); - ScriptPromise read_promise = - reader_for_stream1_->read(script_state, exception_state); - if (exception_state.HadException()) { - return ScriptPromise::Reject(script_state, exception_state); - } - return read_promise.Then( - CreateFunction<OnReadingSource1Success>(script_state, this), - CreateFunction<OnReadingSource1Fail>(script_state, this)); + auto* promise = MakeGarbageCollected<StreamPromiseResolver>(script_state); + auto* read_request = + MakeGarbageCollected<ConcatenatingUnderlyingSourceReadRequest>(this, + promise); + ReadableStreamDefaultReader::Read(script_state, reader_for_stream1_, + read_request); + return promise->GetScriptPromise(script_state); } ScriptPromise Cancel(ScriptState* script_state, ScriptValue reason) override {
diff --git a/third_party/blink/renderer/core/streams/transform_stream.cc b/third_party/blink/renderer/core/streams/transform_stream.cc index da8f51ab..5895a24 100644 --- a/third_party/blink/renderer/core/streams/transform_stream.cc +++ b/third_party/blink/renderer/core/streams/transform_stream.cc
@@ -99,13 +99,8 @@ } ExceptionState exception_state(script_state->GetIsolate(), ExceptionState::kUnknownContext, "", ""); - ScriptPromise promise; - { - // This is needed because the realm of the transformer can be different - // from the realm of the transform stream. - ScriptState::Scope scope(transformer_script_state); - promise = transformer_->Transform(argv[0], controller_, exception_state); - } + ScriptPromise promise = + transformer_->Transform(argv[0], controller_, exception_state); if (exception_state.HadException()) { auto exception = exception_state.GetException(); exception_state.ClearException(); @@ -245,7 +240,7 @@ // 11. Perform ! SetUpTransformStreamDefaultController(stream, controller, // transformAlgorithm, flushAlgorithm). - TransformStreamDefaultController::SetUp(stream, controller, + TransformStreamDefaultController::SetUp(script_state, stream, controller, transform_algorithm, flush_algorithm); // 12. Let startResult be the result of performing startAlgorithm. (This may
diff --git a/third_party/blink/renderer/core/streams/transform_stream_default_controller.cc b/third_party/blink/renderer/core/streams/transform_stream_default_controller.cc index 48ab6f0a..2241363 100644 --- a/third_party/blink/renderer/core/streams/transform_stream_default_controller.cc +++ b/third_party/blink/renderer/core/streams/transform_stream_default_controller.cc
@@ -15,6 +15,7 @@ #include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/bindings/v8_binding.h" +#include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/wtf/casting.h" @@ -90,6 +91,7 @@ visitor->Trace(controlled_transform_stream_); visitor->Trace(flush_algorithm_); visitor->Trace(transform_algorithm_); + visitor->Trace(reject_function_); ScriptWrappable::Trace(visitor); } @@ -139,6 +141,7 @@ }; void TransformStreamDefaultController::SetUp( + ScriptState* script_state, TransformStream* stream, TransformStreamDefaultController* controller, StreamAlgorithm* transform_algorithm, @@ -161,6 +164,37 @@ // 6. Set controller.[[flushAlgorithm]] to flushAlgorithm. controller->flush_algorithm_ = flush_algorithm; + + class PerformTransformRejectFunction final : public PromiseHandlerWithValue { + public: + explicit PerformTransformRejectFunction(TransformStream* stream) + : stream_(stream) {} + + v8::Local<v8::Value> CallWithLocal(ScriptState* script_state, + v8::Local<v8::Value> r) override { + // 2. Return the result of transforming transformPromise with a rejection + // handler that, when called with argument r, performs the following + // steps: + // a. Perform ! TransformStreamError(controller. + // [[controlledTransformStream]], r). + TransformStream::Error(script_state, stream_, r); + + // b. Throw r. + return PromiseReject(script_state, r); + } + + void Trace(Visitor* visitor) const override { + visitor->Trace(stream_); + PromiseHandlerWithValue::Trace(visitor); + } + + private: + Member<TransformStream> stream_; + }; + + controller->reject_function_ = MakeGarbageCollected<ScriptFunction>( + script_state, MakeGarbageCollected<PerformTransformRejectFunction>( + controller->controlled_transform_stream_)); } v8::Local<v8::Value> TransformStreamDefaultController::SetUpFromTransformer( @@ -230,7 +264,7 @@ // 7. Perform ! SetUpTransformStreamDefaultController(stream, controller, // transformAlgorithm, flushAlgorithm). - SetUp(stream, controller, transform_algorithm, flush_algorithm); + SetUp(script_state, stream, controller, transform_algorithm, flush_algorithm); // This operation doesn't have a return value in the standard, but it's useful // to return the JavaScript wrapper here so that it can be used when calling @@ -321,44 +355,36 @@ ScriptState* script_state, TransformStreamDefaultController* controller, v8::Local<v8::Value> chunk) { + if (!script_state->ContextIsValid()) { + v8::Local<v8::Value> error = V8ThrowException::CreateTypeError( + script_state->GetIsolate(), "invalid realm"); + v8::MaybeLocal<v8::Value> result_maybe = + controller->reject_function_->V8Function()->Call( + script_state->GetContext(), + v8::Undefined(script_state->GetIsolate()), 1, &error); + v8::Local<v8::Value> result; + if (!result_maybe.ToLocal(&result)) { + result = v8::Local<v8::Promise>(); + } + return result.As<v8::Promise>(); + } // https://streams.spec.whatwg.org/#transform-stream-default-controller-perform-transform // 1. Let transformPromise be the result of performing controller. // [[transformAlgorithm]], passing chunk. + // This is needed because the result of transforming the transform promise + // needs to be returned to the outer scope. + ScriptState::EscapableScope scope(script_state); auto transform_promise = controller->transform_algorithm_->Run(script_state, 1, &chunk); - - class RejectFunction final : public PromiseHandlerWithValue { - public: - explicit RejectFunction(TransformStream* stream) : stream_(stream) {} - - v8::Local<v8::Value> CallWithLocal(ScriptState* script_state, - v8::Local<v8::Value> r) override { - // 2. Return the result of transforming transformPromise with a rejection - // handler that, when called with argument r, performs the following - // steps: - // a. Perform ! TransformStreamError(controller. - // [[controlledTransformStream]], r). - TransformStream::Error(script_state, stream_, r); - - // b. Throw r. - return PromiseReject(script_state, r); - } - - void Trace(Visitor* visitor) const override { - visitor->Trace(stream_); - PromiseHandlerWithValue::Trace(visitor); - } - - private: - Member<TransformStream> stream_; - }; + DCHECK(!transform_promise.IsEmpty()); // 2. Return the result of transforming transformPromise ... - return StreamThenPromise( - script_state->GetContext(), transform_promise, nullptr, - MakeGarbageCollected<ScriptFunction>( - script_state, MakeGarbageCollected<RejectFunction>( - controller->controlled_transform_stream_))); + v8::Local<v8::Promise> streamed_promise = + StreamThenPromise(script_state->GetContext(), transform_promise, nullptr, + controller->reject_function_); + v8::Local<v8::Value> escapable_streamed_promise = + scope.Escape(streamed_promise); + return escapable_streamed_promise.As<v8::Promise>(); } void TransformStreamDefaultController::Terminate(
diff --git a/third_party/blink/renderer/core/streams/transform_stream_default_controller.h b/third_party/blink/renderer/core/streams/transform_stream_default_controller.h index add6c80..cae622d9 100644 --- a/third_party/blink/renderer/core/streams/transform_stream_default_controller.h +++ b/third_party/blink/renderer/core/streams/transform_stream_default_controller.h
@@ -15,6 +15,7 @@ class ExceptionState; class ReadableStreamDefaultController; +class ScriptFunction; class ScriptState; class StreamAlgorithm; class TransformStream; @@ -48,7 +49,8 @@ class DefaultTransformAlgorithm; // https://streams.spec.whatwg.org/#set-up-transform-stream-default-controller - static void SetUp(TransformStream*, + static void SetUp(ScriptState*, + TransformStream*, TransformStreamDefaultController*, StreamAlgorithm* transform_algorithm, StreamAlgorithm* flush_algorithm); @@ -89,6 +91,7 @@ Member<TransformStream> controlled_transform_stream_; Member<StreamAlgorithm> flush_algorithm_; Member<StreamAlgorithm> transform_algorithm_; + Member<ScriptFunction> reject_function_; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/streams/writable_stream_default_controller.cc b/third_party/blink/renderer/core/streams/writable_stream_default_controller.cc index 15c351a..49f1f49 100644 --- a/third_party/blink/renderer/core/streams/writable_stream_default_controller.cc +++ b/third_party/blink/renderer/core/streams/writable_stream_default_controller.cc
@@ -218,6 +218,100 @@ script_state, MakeGarbageCollected<ResolvePromiseFunction>(stream)), MakeGarbageCollected<ScriptFunction>( script_state, MakeGarbageCollected<RejectPromiseFunction>(stream))); + + class ProcessWriteResolveFunction final : public PromiseHandler { + public: + ProcessWriteResolveFunction(WritableStream* stream, + WritableStreamDefaultController* controller) + : stream_(stream), controller_(controller) {} + + void CallWithLocal(ScriptState* script_state, + v8::Local<v8::Value>) override { + // https://streams.spec.whatwg.org/#writable-stream-default-controller-process-write + // 4. Upon fulfillment of sinkWritePromise, + // a. Perform ! WritableStreamFinishInFlightWrite(stream). + WritableStream::FinishInFlightWrite(script_state, stream_); + + // b. Let state be stream.[[state]]. + const auto state = stream_->GetState(); + + // c. Assert: state is "writable" or "erroring". + CHECK(state == WritableStream::kWritable || + state == WritableStream::kErroring); + + // d. Perform ! DequeueValue(controller). + controller_->queue_->DequeueValue(script_state->GetIsolate()); + + // e. If ! WritableStreamCloseQueuedOrInFlight(stream) is false and + // state is "writable", + if (!WritableStream::CloseQueuedOrInFlight(stream_) && + state == WritableStream::kWritable) { + // i. Let backpressure be ! + // WritableStreamDefaultControllerGetBackpressure( + // controller). + const bool backpressure = + WritableStreamDefaultController::GetBackpressure(controller_); + + // ii. Perform ! WritableStreamUpdateBackpressure(stream, + // backpressure). + WritableStream::UpdateBackpressure(script_state, stream_, backpressure); + } + // f. Perform ! WritableStreamDefaultControllerAdvanceQueueIfNeeded( + // controller). + WritableStreamDefaultController::AdvanceQueueIfNeeded(script_state, + controller_); + } + + void Trace(Visitor* visitor) const override { + visitor->Trace(stream_); + visitor->Trace(controller_); + PromiseHandler::Trace(visitor); + } + + private: + Member<WritableStream> stream_; + Member<WritableStreamDefaultController> controller_; + }; + + class ProcessWriteRejectFunction final : public PromiseHandler { + public: + ProcessWriteRejectFunction(WritableStream* stream, + WritableStreamDefaultController* controller) + : stream_(stream), controller_(controller) {} + + void CallWithLocal(ScriptState* script_state, + v8::Local<v8::Value> reason) override { + const auto state = stream_->GetState(); + // 5. Upon rejection of sinkWritePromise with reason, + // a. If stream.[[state]] is "writable", perform ! + // WritableStreamDefaultControllerClearAlgorithms(controller). + if (state == WritableStream::kWritable) { + WritableStreamDefaultController::ClearAlgorithms(controller_); + } + + // b. Perform ! WritableStreamFinishInFlightWriteWithError(stream, + // reason). + WritableStream::FinishInFlightWriteWithError(script_state, stream_, + reason); + } + + void Trace(Visitor* visitor) const override { + visitor->Trace(stream_); + visitor->Trace(controller_); + PromiseHandler::Trace(visitor); + } + + private: + Member<WritableStream> stream_; + Member<WritableStreamDefaultController> controller_; + }; + + controller->resolve_function_ = MakeGarbageCollected<ScriptFunction>( + script_state, MakeGarbageCollected<ProcessWriteResolveFunction>( + controller->controlled_writable_stream_, controller)); + controller->reject_function_ = MakeGarbageCollected<ScriptFunction>( + script_state, MakeGarbageCollected<ProcessWriteRejectFunction>( + controller->controlled_writable_stream_, controller)); } // TODO(ricea): Should this be a constructor? @@ -412,6 +506,8 @@ visitor->Trace(signal_); visitor->Trace(strategy_size_algorithm_); visitor->Trace(write_algorithm_); + visitor->Trace(resolve_function_); + visitor->Trace(reject_function_); ScriptWrappable::Trace(visitor); } @@ -579,99 +675,9 @@ const auto sinkWritePromise = controller->write_algorithm_->Run(script_state, 1, &chunk); - class ResolveFunction final : public PromiseHandler { - public: - ResolveFunction(WritableStream* stream, - WritableStreamDefaultController* controller) - : stream_(stream), controller_(controller) {} - - void CallWithLocal(ScriptState* script_state, - v8::Local<v8::Value>) override { - // 4. Upon fulfillment of sinkWritePromise, - // a. Perform ! WritableStreamFinishInFlightWrite(stream). - WritableStream::FinishInFlightWrite(script_state, stream_); - - // b. Let state be stream.[[state]]. - const auto state = stream_->GetState(); - - // c. Assert: state is "writable" or "erroring". - CHECK(state == WritableStream::kWritable || - state == WritableStream::kErroring); - - // d. Perform ! DequeueValue(controller). - controller_->queue_->DequeueValue(script_state->GetIsolate()); - - // e. If ! WritableStreamCloseQueuedOrInFlight(stream) is false and - // state is "writable", - if (!WritableStream::CloseQueuedOrInFlight(stream_) && - state == WritableStream::kWritable) { - // i. Let backpressure be ! - // WritableStreamDefaultControllerGetBackpressure( - // controller). - const bool backpressure = - WritableStreamDefaultController::GetBackpressure(controller_); - - // ii. Perform ! WritableStreamUpdateBackpressure(stream, - // backpressure). - WritableStream::UpdateBackpressure(script_state, stream_, backpressure); - } - // f. Perform ! WritableStreamDefaultControllerAdvanceQueueIfNeeded( - // controller). - WritableStreamDefaultController::AdvanceQueueIfNeeded(script_state, - controller_); - } - - void Trace(Visitor* visitor) const override { - visitor->Trace(stream_); - visitor->Trace(controller_); - PromiseHandler::Trace(visitor); - } - - private: - Member<WritableStream> stream_; - Member<WritableStreamDefaultController> controller_; - }; - - class RejectFunction final : public PromiseHandler { - public: - RejectFunction(WritableStream* stream, - WritableStreamDefaultController* controller) - : stream_(stream), controller_(controller) {} - - void CallWithLocal(ScriptState* script_state, - v8::Local<v8::Value> reason) override { - const auto state = stream_->GetState(); - // 5. Upon rejection of sinkWritePromise with reason, - // a. If stream.[[state]] is "writable", perform ! - // WritableStreamDefaultControllerClearAlgorithms(controller). - if (state == WritableStream::kWritable) { - WritableStreamDefaultController::ClearAlgorithms(controller_); - } - - // b. Perform ! WritableStreamFinishInFlightWriteWithError(stream, - // reason). - WritableStream::FinishInFlightWriteWithError(script_state, stream_, - reason); - } - - void Trace(Visitor* visitor) const override { - visitor->Trace(stream_); - visitor->Trace(controller_); - PromiseHandler::Trace(visitor); - } - - private: - Member<WritableStream> stream_; - Member<WritableStreamDefaultController> controller_; - }; - StreamThenPromise(script_state->GetContext(), sinkWritePromise, - MakeGarbageCollected<ScriptFunction>( - script_state, MakeGarbageCollected<ResolveFunction>( - stream, controller)), - MakeGarbageCollected<ScriptFunction>( - script_state, MakeGarbageCollected<RejectFunction>( - stream, controller))); + controller->resolve_function_, + controller->reject_function_); } bool WritableStreamDefaultController::GetBackpressure(
diff --git a/third_party/blink/renderer/core/streams/writable_stream_default_controller.h b/third_party/blink/renderer/core/streams/writable_stream_default_controller.h index 987f6e6..f729d075 100644 --- a/third_party/blink/renderer/core/streams/writable_stream_default_controller.h +++ b/third_party/blink/renderer/core/streams/writable_stream_default_controller.h
@@ -16,6 +16,7 @@ class AbortSignal; class ExceptionState; class QueueWithSizes; +class ScriptFunction; class ScriptState; class ScriptValue; class StrategySizeAlgorithm; @@ -151,6 +152,8 @@ double strategy_high_water_mark_ = 0.0; Member<StrategySizeAlgorithm> strategy_size_algorithm_; Member<StreamAlgorithm> write_algorithm_; + Member<ScriptFunction> resolve_function_; + Member<ScriptFunction> reject_function_; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/svg/svg_a_element.cc b/third_party/blink/renderer/core/svg/svg_a_element.cc index a7aab3bc..9c5bc4eb 100644 --- a/third_party/blink/renderer/core/svg/svg_a_element.cc +++ b/third_party/blink/renderer/core/svg/svg_a_element.cc
@@ -34,7 +34,6 @@ #include "third_party/blink/renderer/core/html/html_anchor_element.h" #include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_inline.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_transformable_container.h" #include "third_party/blink/renderer/core/loader/frame_load_request.h" #include "third_party/blink/renderer/core/loader/frame_loader.h"
diff --git a/third_party/blink/renderer/core/svg/svg_animated_string.cc b/third_party/blink/renderer/core/svg/svg_animated_string.cc index 88c7479d..7af0438 100644 --- a/third_party/blink/renderer/core/svg/svg_animated_string.cc +++ b/third_party/blink/renderer/core/svg/svg_animated_string.cc
@@ -20,7 +20,7 @@ ExceptionState& exception_state) { DCHECK(value); - // https://w3c.github.io/webappsec-trusted-types/dist/spec/#integration-with-svg + // https://w3c.github.io/trusted-types/dist/spec/#integration-with-svg String string; switch (value->GetContentType()) { case V8UnionStringOrTrustedScriptURL::ContentType::kString:
diff --git a/third_party/blink/renderer/core/svg/svg_foreign_object_element.cc b/third_party/blink/renderer/core/svg/svg_foreign_object_element.cc index 55e2b8fc..518ce56 100644 --- a/third_party/blink/renderer/core/svg/svg_foreign_object_element.cc +++ b/third_party/blink/renderer/core/svg/svg_foreign_object_element.cc
@@ -23,7 +23,7 @@ #include "third_party/blink/renderer/core/css/style_change_reason.h" #include "third_party/blink/renderer/core/frame/web_feature.h" #include "third_party/blink/renderer/core/layout/layout_object.h" -#include "third_party/blink/renderer/core/layout/layout_object_factory.h" +#include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_foreign_object.h" #include "third_party/blink/renderer/core/svg/svg_animated_length.h" #include "third_party/blink/renderer/core/svg/svg_length.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" @@ -143,7 +143,7 @@ ancestor->GetLayoutObject()->IsSVGHiddenContainer()) return nullptr; } - return LayoutObjectFactory::CreateSVGForeignObject(*this, style, legacy); + return MakeGarbageCollected<LayoutNGSVGForeignObject>(this); } bool SVGForeignObjectElement::SelfHasRelativeLengths() const {
diff --git a/third_party/blink/renderer/core/svg/svg_graphics_element.cc b/third_party/blink/renderer/core/svg/svg_graphics_element.cc index f574df2..7260456 100644 --- a/third_party/blink/renderer/core/svg/svg_graphics_element.cc +++ b/third_party/blink/renderer/core/svg/svg_graphics_element.cc
@@ -189,8 +189,9 @@ if (const auto* layout_object = GetLayoutObject()) { bounding_box = GetBBox(); - if (layout_object->IsSVGText() || layout_object->IsSVGInline()) + if (layout_object->IsSVGInline()) { UseCounter::Count(GetDocument(), WebFeature::kGetBBoxForText); + } } return SVGRectTearOff::CreateDetached(bounding_box); }
diff --git a/third_party/blink/renderer/core/svg/svg_svg_element.cc b/third_party/blink/renderer/core/svg/svg_svg_element.cc index 1e1c85a..14f54539 100644 --- a/third_party/blink/renderer/core/svg/svg_svg_element.cc +++ b/third_party/blink/renderer/core/svg/svg_svg_element.cc
@@ -310,8 +310,8 @@ // canvas. Specifically: circle, ellipse, image, line, path, polygon, polyline, // rect, text and use. static bool IsIntersectionOrEnclosureTarget(LayoutObject* layout_object) { - return layout_object->IsSVGShape() || layout_object->IsSVGText() || - layout_object->IsNGSVGText() || layout_object->IsSVGImage() || + return layout_object->IsSVGShape() || layout_object->IsNGSVGText() || + layout_object->IsSVGImage() || IsA<SVGUseElement>(*layout_object->GetNode()); }
diff --git a/third_party/blink/renderer/core/svg/svg_text_content_element.cc b/third_party/blink/renderer/core/svg/svg_text_content_element.cc index 7ed0341..81085c2f6 100644 --- a/third_party/blink/renderer/core/svg/svg_text_content_element.cc +++ b/third_party/blink/renderer/core/svg/svg_text_content_element.cc
@@ -28,8 +28,6 @@ #include "third_party/blink/renderer/core/layout/api/line_layout_item.h" #include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.h" #include "third_party/blink/renderer/core/layout/ng/svg/ng_svg_text_query.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" -#include "third_party/blink/renderer/core/layout/svg/svg_text_query.h" #include "third_party/blink/renderer/core/svg/svg_animated_length.h" #include "third_party/blink/renderer/core/svg/svg_enumeration_map.h" #include "third_party/blink/renderer/core/svg/svg_point_tear_off.h" @@ -110,7 +108,7 @@ auto* layout_object = GetLayoutObject(); if (IsNGTextOrInline(layout_object)) return NGSvgTextQuery(*layout_object).NumberOfCharacters(); - return SVGTextQuery(layout_object).NumberOfCharacters(); + return 0; } float SVGTextContentElement::getComputedTextLength() { @@ -121,7 +119,7 @@ NGSvgTextQuery query(*layout_object); return query.SubStringLength(0, query.NumberOfCharacters()); } - return SVGTextQuery(layout_object).TextLength(); + return 0; } float SVGTextContentElement::getSubStringLength( @@ -146,7 +144,7 @@ auto* layout_object = GetLayoutObject(); if (IsNGTextOrInline(layout_object)) return NGSvgTextQuery(*layout_object).SubStringLength(charnum, nchars); - return SVGTextQuery(layout_object).SubStringLength(charnum, nchars); + return 0; } SVGPointTearOff* SVGTextContentElement::getStartPositionOfChar( @@ -167,8 +165,6 @@ auto* layout_object = GetLayoutObject(); if (IsNGTextOrInline(layout_object)) { point = NGSvgTextQuery(*layout_object).StartPositionOfCharacter(charnum); - } else { - point = SVGTextQuery(layout_object).StartPositionOfCharacter(charnum); } return SVGPointTearOff::CreateDetached(point); } @@ -191,8 +187,6 @@ auto* layout_object = GetLayoutObject(); if (IsNGTextOrInline(layout_object)) { point = NGSvgTextQuery(*layout_object).EndPositionOfCharacter(charnum); - } else { - point = SVGTextQuery(layout_object).EndPositionOfCharacter(charnum); } return SVGPointTearOff::CreateDetached(point); } @@ -215,8 +209,6 @@ auto* layout_object = GetLayoutObject(); if (IsNGTextOrInline(layout_object)) { rect = NGSvgTextQuery(*layout_object).ExtentOfCharacter(charnum); - } else { - rect = SVGTextQuery(layout_object).ExtentOfCharacter(charnum); } return SVGRectTearOff::CreateDetached(rect); } @@ -238,7 +230,7 @@ auto* layout_object = GetLayoutObject(); if (IsNGTextOrInline(layout_object)) return NGSvgTextQuery(*layout_object).RotationOfCharacter(charnum); - return SVGTextQuery(layout_object).RotationOfCharacter(charnum); + return 0.0f; } int SVGTextContentElement::getCharNumAtPosition( @@ -251,8 +243,7 @@ return NGSvgTextQuery(*layout_object) .CharacterNumberAtPosition(point->Target()->Value()); } - return SVGTextQuery(layout_object) - .CharacterNumberAtPosition(point->Target()->Value()); + return -1; } void SVGTextContentElement::selectSubString(unsigned charnum, @@ -316,9 +307,10 @@ SVGElement::InvalidationGuard invalidation_guard(this); if (LayoutObject* layout_object = GetLayoutObject()) { - if (auto* ng_text = DynamicTo<LayoutNGSVGText>( - LayoutSVGText::LocateLayoutSVGTextAncestor(layout_object))) + if (auto* ng_text = + LayoutNGSVGText::LocateLayoutSVGTextAncestor(layout_object)) { ng_text->SetNeedsPositioningValuesUpdate(); + } MarkForLayoutAndParentResourceInvalidation(*layout_object); } @@ -337,12 +329,7 @@ SVGTextContentElement* SVGTextContentElement::ElementFromLineLayoutItem( const LineLayoutItem& line_layout_item) { - if (!line_layout_item || - (!line_layout_item.IsSVGText() && !line_layout_item.IsSVGInline())) - return nullptr; - - DCHECK(line_layout_item.GetNode()); - return DynamicTo<SVGTextContentElement>(line_layout_item.GetNode()); + return nullptr; } } // namespace blink
diff --git a/third_party/blink/renderer/core/svg/svg_text_element.cc b/third_party/blink/renderer/core/svg/svg_text_element.cc index e311c65..3b6fc24 100644 --- a/third_party/blink/renderer/core/svg/svg_text_element.cc +++ b/third_party/blink/renderer/core/svg/svg_text_element.cc
@@ -20,7 +20,7 @@ #include "third_party/blink/renderer/core/svg/svg_text_element.h" -#include "third_party/blink/renderer/core/layout/layout_object_factory.h" +#include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.h" namespace blink { @@ -29,7 +29,7 @@ LayoutObject* SVGTextElement::CreateLayoutObject(const ComputedStyle& style, LegacyLayout legacy) { - return LayoutObjectFactory::CreateSVGText(*this, style, legacy); + return MakeGarbageCollected<LayoutNGSVGText>(this); } } // namespace blink
diff --git a/third_party/blink/renderer/core/svg/svg_text_positioning_element.cc b/third_party/blink/renderer/core/svg/svg_text_positioning_element.cc index 4af4a79..a81b3994 100644 --- a/third_party/blink/renderer/core/svg/svg_text_positioning_element.cc +++ b/third_party/blink/renderer/core/svg/svg_text_positioning_element.cc
@@ -21,7 +21,6 @@ #include "third_party/blink/renderer/core/svg/svg_text_positioning_element.h" #include "third_party/blink/renderer/core/layout/ng/svg/layout_ng_svg_text.h" -#include "third_party/blink/renderer/core/layout/svg/layout_svg_text.h" #include "third_party/blink/renderer/core/svg/svg_animated_length_list.h" #include "third_party/blink/renderer/core/svg/svg_animated_number_list.h" #include "third_party/blink/renderer/core/svg/svg_length_list.h" @@ -87,12 +86,9 @@ if (!layout_object) return; - if (LayoutSVGBlock* text_or_ng_text = - LayoutSVGText::LocateLayoutSVGTextAncestor(layout_object)) { - if (auto* text_layout_object = DynamicTo<LayoutSVGText>(text_or_ng_text)) - text_layout_object->SetNeedsPositioningValuesUpdate(); - else - To<LayoutNGSVGText>(text_or_ng_text)->SetNeedsPositioningValuesUpdate(); + if (auto* ng_text = + LayoutNGSVGText::LocateLayoutSVGTextAncestor(layout_object)) { + ng_text->SetNeedsPositioningValuesUpdate(); } MarkForLayoutAndParentResourceInvalidation(*layout_object); return;
diff --git a/third_party/blink/renderer/core/trustedtypes/trusted_html.cc b/third_party/blink/renderer/core/trustedtypes/trusted_html.cc index 458a747..86debaf 100644 --- a/third_party/blink/renderer/core/trustedtypes/trusted_html.cc +++ b/third_party/blink/renderer/core/trustedtypes/trusted_html.cc
@@ -37,7 +37,7 @@ // TrustedHTML::fromLiteral requires additional normalization that the other // trusted types do not. We want to parse the literal as if it were a // HTMLTemplateElement content. Ref: Step 4 of - // https://w3c.github.io/webappsec-trusted-types/dist/spec/#create-a-trusted-type-from-literal-algorithm + // https://w3c.github.io/trusted-types/dist/spec/#create-a-trusted-type-from-literal-algorithm HTMLTemplateElement* template_element = MakeGarbageCollected<HTMLTemplateElement>(*window->document()); DCHECK(template_element->content());
diff --git a/third_party/blink/renderer/core/trustedtypes/trusted_html.idl b/third_party/blink/renderer/core/trustedtypes/trusted_html.idl index dd23ccfe..cbb2c70 100644 --- a/third_party/blink/renderer/core/trustedtypes/trusted_html.idl +++ b/third_party/blink/renderer/core/trustedtypes/trusted_html.idl
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// https://github.com/wicg/trusted-types +// https://github.com/w3c/trusted-types typedef [StringContext=TrustedHTML] DOMString HTMLString;
diff --git a/third_party/blink/renderer/core/trustedtypes/trusted_script.idl b/third_party/blink/renderer/core/trustedtypes/trusted_script.idl index 6df5004e..d0be4407 100644 --- a/third_party/blink/renderer/core/trustedtypes/trusted_script.idl +++ b/third_party/blink/renderer/core/trustedtypes/trusted_script.idl
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// https://github.com/wicg/trusted-types +// https://github.com/w3c/trusted-types typedef [StringContext=TrustedScript] DOMString ScriptString;
diff --git a/third_party/blink/renderer/core/trustedtypes/trusted_script_url.idl b/third_party/blink/renderer/core/trustedtypes/trusted_script_url.idl index c4bcfeb..d0f13e9 100644 --- a/third_party/blink/renderer/core/trustedtypes/trusted_script_url.idl +++ b/third_party/blink/renderer/core/trustedtypes/trusted_script_url.idl
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// https://github.com/wicg/trusted-types +// https://github.com/w3c/trusted-types typedef [StringContext=TrustedScriptURL] USVString ScriptURLString;
diff --git a/third_party/blink/renderer/core/trustedtypes/trusted_type_policy.idl b/third_party/blink/renderer/core/trustedtypes/trusted_type_policy.idl index 52e77bd5..ab1839e 100644 --- a/third_party/blink/renderer/core/trustedtypes/trusted_type_policy.idl +++ b/third_party/blink/renderer/core/trustedtypes/trusted_type_policy.idl
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// https://github.com/wicg/trusted-types +// https://github.com/w3c/trusted-types typedef (TrustedHTML or TrustedScript or TrustedScriptURL) TrustedType;
diff --git a/third_party/blink/renderer/core/trustedtypes/trusted_type_policy_options.idl b/third_party/blink/renderer/core/trustedtypes/trusted_type_policy_options.idl index 0477d70..ef8dbd5 100644 --- a/third_party/blink/renderer/core/trustedtypes/trusted_type_policy_options.idl +++ b/third_party/blink/renderer/core/trustedtypes/trusted_type_policy_options.idl
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// https://github.com/wicg/trusted-types +// https://github.com/w3c/trusted-types dictionary TrustedTypePolicyOptions { CreateHTMLCallback createHTML;
diff --git a/third_party/blink/renderer/core/trustedtypes/trusted_types_util.cc b/third_party/blink/renderer/core/trustedtypes/trusted_types_util.cc index 10a55a0..9213fc8 100644 --- a/third_party/blink/renderer/core/trustedtypes/trusted_types_util.cc +++ b/third_party/blink/renderer/core/trustedtypes/trusted_types_util.cc
@@ -608,7 +608,7 @@ DCHECK(script_state); // TrustedTypes fromLiteral requires several checks, which are steps 1-3 // in the "create a trusted type from literal algorithm". Ref: - // https://w3c.github.io/webappsec-trusted-types/dist/spec/#create-a-trusted-type-from-literal-algorithm + // https://w3c.github.io/trusted-types/dist/spec/#create-a-trusted-type-from-literal-algorithm // The core functionality here are the checks that we, indeed, have a // literal object. The key work is done by
diff --git a/third_party/blink/renderer/core/trustedtypes/trusted_types_util.h b/third_party/blink/renderer/core/trustedtypes/trusted_types_util.h index 1f6c5c5..0ce7f0cf 100644 --- a/third_party/blink/renderer/core/trustedtypes/trusted_types_util.h +++ b/third_party/blink/renderer/core/trustedtypes/trusted_types_util.h
@@ -106,7 +106,7 @@ // If an error occurs, this will return a null-String. // // Spec: -// https://w3c.github.io/webappsec-trusted-types/dist/spec/#check-templatedness-algorithm +// https://w3c.github.io/trusted-types/dist/spec/#check-templatedness-algorithm String GetTrustedTypesLiteral(const ScriptValue&, ScriptState*); } // namespace blink
diff --git a/third_party/blink/renderer/core/workers/worker_global_scope.idl b/third_party/blink/renderer/core/workers/worker_global_scope.idl index 324372b..fa92be24 100644 --- a/third_party/blink/renderer/core/workers/worker_global_scope.idl +++ b/third_party/blink/renderer/core/workers/worker_global_scope.idl
@@ -71,7 +71,7 @@ // TODO(fserb): temporarly until we can enable the interface below. readonly attribute FontFaceSet fonts; - // TrustedTypes API: http://github.com/wicg/trusted-types + // TrustedTypes API: http://github.com/w3c/trusted-types readonly attribute TrustedTypePolicyFactory trustedTypes; };
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 8a14915..0edd8709 100644 --- a/third_party/blink/renderer/modules/accessibility/ax_layout_object.cc +++ b/third_party/blink/renderer/modules/accessibility/ax_layout_object.cc
@@ -244,9 +244,9 @@ } if (layout_object_->IsSVGShape()) return ax::mojom::blink::Role::kGraphicsSymbol; - if (layout_object_->IsSVGForeignObjectIncludingNG() || - IsA<SVGGElement>(node)) + if (layout_object_->IsSVGForeignObject() || IsA<SVGGElement>(node)) { return ax::mojom::blink::Role::kGroup; + } if (IsA<SVGUseElement>(node)) return ax::mojom::blink::Role::kGraphicsObject; } @@ -380,9 +380,9 @@ return false; LayoutObject* parent_layout_object = parent_object->GetLayoutObject(); - if (!parent_layout_object || - !parent_layout_object->IsTextControlIncludingNG()) + if (!parent_layout_object || !parent_layout_object->IsTextControl()) { return false; + } const auto* text_control_element = To<TextControlElement>(parent_layout_object->GetNode());
diff --git a/third_party/blink/renderer/modules/accessibility/ax_node_object.cc b/third_party/blink/renderer/modules/accessibility/ax_node_object.cc index d632524..5f9ea3a 100644 --- a/third_party/blink/renderer/modules/accessibility/ax_node_object.cc +++ b/third_party/blink/renderer/modules/accessibility/ax_node_object.cc
@@ -3414,14 +3414,14 @@ return false; auto* html_input_element = DynamicTo<HTMLInputElement>(*GetNode()); - if (html_input_element && layout_object->IsTextFieldIncludingNG()) { + if (html_input_element && layout_object->IsTextField()) { html_input_element->SetValue( string, TextFieldEventBehavior::kDispatchInputAndChangeEvent); return true; } if (auto* text_area_element = DynamicTo<HTMLTextAreaElement>(*GetNode())) { - DCHECK(layout_object->IsTextAreaIncludingNG()); + DCHECK(layout_object->IsTextArea()); text_area_element->SetValue( string, TextFieldEventBehavior::kDispatchInputAndChangeEvent); return true;
diff --git a/third_party/blink/renderer/modules/mediacapturefromelement/html_media_element_capture.cc b/third_party/blink/renderer/modules/mediacapturefromelement/html_media_element_capture.cc index 22bb30a9..a95b4e45 100644 --- a/third_party/blink/renderer/modules/mediacapturefromelement/html_media_element_capture.cc +++ b/third_party/blink/renderer/modules/mediacapturefromelement/html_media_element_capture.cc
@@ -165,8 +165,16 @@ if (event->type() == event_type_names::kEnded) { const MediaStreamTrackVector tracks = media_stream_->getTracks(); + // Stop all tracks before removing them. This ensures multi-track stream + // consumers like the MediaRecorder sees all tracks ended before they're + // removed from the stream, which is interpreted as an error if happening + // earlier, see for example + // https://www.w3.org/TR/mediastream-recording/#dom-mediarecorder-start + // step 14.4. for (const auto& track : tracks) { track->stopTrack(context); + } + for (const auto& track : tracks) { media_stream_->RemoveTrackByComponentAndFireEvents( track->Component(), MediaStreamDescriptorClient::DispatchEventTiming::kScheduled);
diff --git a/third_party/blink/renderer/modules/mediarecorder/media_recorder.cc b/third_party/blink/renderer/modules/mediarecorder/media_recorder.cc index 5870964..b74ea11 100644 --- a/third_party/blink/renderer/modules/mediarecorder/media_recorder.cc +++ b/third_party/blink/renderer/modules/mediarecorder/media_recorder.cc
@@ -428,8 +428,7 @@ } void MediaRecorder::OnError(DOMExceptionCode code, const String& message) { - DLOG(ERROR) << message.Ascii(); - StopRecording(); + DVLOG(1) << __func__ << " message=" << message.Ascii(); ScriptState* script_state = ToScriptStateForMainWorld(DomWindow()->GetFrame()); @@ -440,12 +439,22 @@ event_init->setError(error_value); ScheduleDispatchEvent( ErrorEvent::Create(script_state, event_type_names::kError, event_init)); + StopRecording(); } void MediaRecorder::OnAllTracksEnded() { + DVLOG(1) << __func__; StopRecording(); } +void MediaRecorder::OnStreamChanged(const String& message) { + DVLOG(1) << __func__ << " message=" << message.Ascii() + << " state_=" << static_cast<int>(state_); + if (state_ != State::kInactive) { + OnError(DOMExceptionCode::kInvalidModificationError, message); + } +} + void MediaRecorder::CreateBlobEvent(Blob* blob, double timecode) { ScheduleDispatchEvent(MakeGarbageCollected<BlobEvent>( event_type_names::kDataavailable, blob, timecode));
diff --git a/third_party/blink/renderer/modules/mediarecorder/media_recorder.h b/third_party/blink/renderer/modules/mediarecorder/media_recorder.h index c537a37..f739916 100644 --- a/third_party/blink/renderer/modules/mediarecorder/media_recorder.h +++ b/third_party/blink/renderer/modules/mediarecorder/media_recorder.h
@@ -84,6 +84,10 @@ double timecode); virtual void OnError(DOMExceptionCode code, const String& message); + // This causes an invalid modification error to be sent and recording to be + // stopped if recording is not inactive. + void OnStreamChanged(const String& message); + // Causes recording to be stopped, remaining data to be written, and onstop to // be sent, unless recording isn't active in which case nothing happens. void OnAllTracksEnded();
diff --git a/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.cc b/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.cc index cadac52c..0623ab98e 100644 --- a/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.cc +++ b/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.cc
@@ -8,9 +8,12 @@ #include <memory> #include <utility> +#include "base/functional/bind.h" +#include "base/location.h" #include "base/logging.h" #include "base/system/sys_info.h" #include "base/task/bind_post_task.h" +#include "base/task/sequenced_task_runner.h" #include "media/base/audio_bus.h" #include "media/base/audio_codecs.h" #include "media/base/audio_parameters.h" @@ -254,6 +257,10 @@ DCHECK(timeslice_.is_zero()); DCHECK(!muxer_); + DCHECK(!is_media_stream_observer_); + media_stream_->AddObserver(this); + is_media_stream_observer_ = true; + invalidated_ = false; timeslice_ = base::Milliseconds(timeslice); @@ -363,6 +370,12 @@ // TODO(crbug.com/719023): The video recorder needs to be flushed to retrieve // the last N frames with some codecs. + // Unregister from media stream notifications. + if (media_stream_ && is_media_stream_observer_) { + media_stream_->RemoveObserver(this); + } + is_media_stream_observer_ = false; + // Ensure any stored data inside the muxer is flushed out before invalidation. muxer_ = nullptr; invalidated_ = true; @@ -527,6 +540,27 @@ return mime_type.ToString(); } +void MediaRecorderHandler::TrackAdded(const WebString& track_id) { + OnStreamChanged("Tracks in MediaStream were added."); +} + +void MediaRecorderHandler::TrackRemoved(const WebString& track_id) { + OnStreamChanged("Tracks in MediaStream were removed."); +} + +void MediaRecorderHandler::OnStreamChanged(const String& message) { + if (recorder_) { + // The call to MediaRecorder::OnStreamChanged has to be posted because + // otherwise stream track set changing leads to the MediaRecorder + // synchronously changing state to "inactive", which contradicts + // https://www.w3.org/TR/mediastream-recording/#dom-mediarecorder-start + // step 14.4. + base::SequencedTaskRunner::GetCurrentDefault()->PostTask( + FROM_HERE, WTF::BindOnce(&MediaRecorder::OnStreamChanged, + WrapWeakPersistent(recorder_.Get()), message)); + } +} + void MediaRecorderHandler::OnEncodedVideo( const media::Muxer::VideoParameters& params, std::string encoded_data, @@ -567,12 +601,6 @@ bool is_key_frame) { DCHECK(IsMainThread()); - if (UpdateTracksAndCheckIfChanged()) { - recorder_->OnError(DOMExceptionCode::kInvalidModificationError, - "Amount of tracks in MediaStream has changed."); - return; - } - if (!last_seen_codec_.has_value()) last_seen_codec_ = params.codec; if (*last_seen_codec_ != params.codec) { @@ -583,7 +611,6 @@ media::GetCodecName(params.codec).c_str())); return; } - if (!muxer_) return; if (!muxer_->OnEncodedVideo(params, std::move(encoded_data), @@ -601,12 +628,6 @@ if (invalidated_) return; - - if (UpdateTracksAndCheckIfChanged()) { - recorder_->OnError(DOMExceptionCode::kInvalidModificationError, - "Amount of tracks in MediaStream has changed."); - return; - } if (!muxer_) return; if (!muxer_->OnEncodedAudio(params, std::move(encoded_data), timestamp)) { @@ -638,43 +659,18 @@ (now - base::TimeTicks::UnixEpoch()).InMillisecondsF()); } -bool MediaRecorderHandler::UpdateTracksAndCheckIfChanged() { +void MediaRecorderHandler::UpdateTracksLiveAndEnabled() { DCHECK(IsMainThread()); const auto video_tracks = media_stream_->VideoComponents(); const auto audio_tracks = media_stream_->AudioComponents(); - bool video_tracks_changed = video_tracks_.size() != video_tracks.size(); - bool audio_tracks_changed = audio_tracks_.size() != audio_tracks.size(); - - if (!video_tracks_changed) { - for (wtf_size_t i = 0; i < video_tracks.size(); ++i) { - if (video_tracks_[i]->Id() != video_tracks[i]->Id()) { - video_tracks_changed = true; - break; - } - } - } - if (!video_tracks_changed && !audio_tracks_changed) { - for (wtf_size_t i = 0; i < audio_tracks.size(); ++i) { - if (audio_tracks_[i]->Id() != audio_tracks[i]->Id()) { - audio_tracks_changed = true; - break; - } - } - } - - if (video_tracks_changed) - video_tracks_ = video_tracks; - if (audio_tracks_changed) - audio_tracks_ = audio_tracks; - - if (video_tracks_.size()) + if (!video_tracks_.empty()) { UpdateTrackLiveAndEnabled(*video_tracks_[0], /*is_video=*/true); - if (audio_tracks_.size()) + } + if (!audio_tracks_.empty()) { UpdateTrackLiveAndEnabled(*audio_tracks_[0], /*is_video=*/false); - - return video_tracks_changed || audio_tracks_changed; + } } void MediaRecorderHandler::UpdateTrackLiveAndEnabled(
diff --git a/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.h b/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.h index b912964..10fab87 100644 --- a/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.h +++ b/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.h
@@ -12,6 +12,7 @@ #include "base/threading/thread_checker.h" #include "base/time/time.h" #include "third_party/abseil-cpp/absl/types/optional.h" +#include "third_party/blink/public/platform/modules/mediastream/web_media_stream.h" #include "third_party/blink/public/web/modules/mediastream/encoded_video_frame.h" #include "third_party/blink/renderer/modules/mediarecorder/audio_track_recorder.h" #include "third_party/blink/renderer/modules/mediarecorder/video_track_recorder.h" @@ -46,7 +47,8 @@ // is used to guarantee this, since VideoTrackRecorder sends back frames on IO // thread.) class MODULES_EXPORT MediaRecorderHandler final - : public GarbageCollected<MediaRecorderHandler> { + : public GarbageCollected<MediaRecorderHandler>, + public WebMediaStreamObserver { public: MediaRecorderHandler() = default; MediaRecorderHandler(const MediaRecorderHandler&) = delete; @@ -89,6 +91,12 @@ friend class MediaRecorderHandlerFixture; friend class MediaRecorderHandlerPassthroughTest; + // WebMediaStreamObserver overrides. + void TrackAdded(const WebString& track_id) override; + void TrackRemoved(const WebString& track_id) override; + + void OnStreamChanged(const String& message); + // Called to indicate there is encoded video data available. |encoded_alpha| // represents the encode output of alpha channel when available, can be // nullptr otherwise. @@ -112,8 +120,8 @@ base::TimeTicks timestamp); void WriteData(base::StringPiece data); - // Updates |video_tracks_|,|audio_tracks_| and returns true if any changed. - bool UpdateTracksAndCheckIfChanged(); + // Updates recorded tracks live and enabled. + void UpdateTracksLiveAndEnabled(); // Stops recording if all sources are ended void OnSourceReadyStateChanged(); @@ -161,6 +169,9 @@ bool invalidated_ = false; bool recording_ = false; + + // True if we're observing track changes to `media_stream_`. + bool is_media_stream_observer_ = false; // The MediaStream being recorded. Member<MediaStreamDescriptor> media_stream_; HeapVector<Member<MediaStreamComponent>> video_tracks_;
diff --git a/third_party/blink/renderer/modules/peerconnection/peer_connection_dependency_factory.cc b/third_party/blink/renderer/modules/peerconnection/peer_connection_dependency_factory.cc index 132aa07c..991ef9e 100644 --- a/third_party/blink/renderer/modules/peerconnection/peer_connection_dependency_factory.cc +++ b/third_party/blink/renderer/modules/peerconnection/peer_connection_dependency_factory.cc
@@ -829,7 +829,11 @@ PeerConnectionDependencyFactory::CreateLocalVideoTrack( const String& id, webrtc::VideoTrackSourceInterface* source) { - return GetPcFactory()->CreateVideoTrack(id.Utf8(), source).get(); + return GetPcFactory() + ->CreateVideoTrack( + rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>(source), + id.Utf8()) + .get(); } webrtc::IceCandidateInterface*
diff --git a/third_party/blink/renderer/modules/webtransport/incoming_stream_test.cc b/third_party/blink/renderer/modules/webtransport/incoming_stream_test.cc index 18e5ad60..2fbf893 100644 --- a/third_party/blink/renderer/modules/webtransport/incoming_stream_test.cc +++ b/third_party/blink/renderer/modules/webtransport/incoming_stream_test.cc
@@ -18,6 +18,7 @@ #include "third_party/blink/renderer/bindings/core/v8/v8_dom_exception.h" #include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/streams/readable_stream.h" +#include "third_party/blink/renderer/core/streams/readable_stream_byob_reader.h" #include "third_party/blink/renderer/core/streams/readable_stream_default_reader.h" #include "third_party/blink/renderer/core/streams/stream_promise_resolver.h" #include "third_party/blink/renderer/core/typed_arrays/dom_typed_array.h"
diff --git a/third_party/blink/renderer/modules/webtransport/web_transport_test.cc b/third_party/blink/renderer/modules/webtransport/web_transport_test.cc index c33a63b..2aee8f50 100644 --- a/third_party/blink/renderer/modules/webtransport/web_transport_test.cc +++ b/third_party/blink/renderer/modules/webtransport/web_transport_test.cc
@@ -36,6 +36,7 @@ #include "third_party/blink/renderer/bindings/modules/v8/v8_web_transport_options.h" #include "third_party/blink/renderer/core/frame/csp/content_security_policy.h" #include "third_party/blink/renderer/core/streams/readable_stream.h" +#include "third_party/blink/renderer/core/streams/readable_stream_byob_reader.h" #include "third_party/blink/renderer/core/streams/readable_stream_default_reader.h" #include "third_party/blink/renderer/core/streams/writable_stream.h" #include "third_party/blink/renderer/core/streams/writable_stream_default_writer.h"
diff --git a/third_party/blink/renderer/platform/graphics/canvas_resource.cc b/third_party/blink/renderer/platform/graphics/canvas_resource.cc index ad61f0e6..ed2fff5 100644 --- a/third_party/blink/renderer/platform/graphics/canvas_resource.cc +++ b/third_party/blink/renderer/platform/graphics/canvas_resource.cc
@@ -211,8 +211,8 @@ // the resource type and completely ignores the format set on the // TransferableResource. Clients are expected to render in N32 format but use // RGBA as the tagged format on resources. - *out_resource = - viz::TransferableResource::MakeSoftware(mailbox, Size(), viz::RGBA_8888); + *out_resource = viz::TransferableResource::MakeSoftware( + mailbox, Size(), viz::SinglePlaneFormat::kRGBA_8888); out_resource->color_space = GetColorSpace();
diff --git a/third_party/blink/renderer/platform/graphics/gpu/drawing_buffer.cc b/third_party/blink/renderer/platform/graphics/gpu/drawing_buffer.cc index 9171b1b..681f13c 100644 --- a/third_party/blink/renderer/platform/graphics/gpu/drawing_buffer.cc +++ b/third_party/blink/renderer/platform/graphics/gpu/drawing_buffer.cc
@@ -505,7 +505,7 @@ static_cast<uint8_t*>(registered.bitmap->memory())); *out_resource = viz::TransferableResource::MakeSoftware( - registered.bitmap->id(), size_, viz::RGBA_8888); + registered.bitmap->id(), size_, viz::SinglePlaneFormat::kRGBA_8888); out_resource->color_space = back_color_buffer_->color_space; // This holds a ref on the DrawingBuffer that will keep it alive until the
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 8066d26f..e26c43e0 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
@@ -194,7 +194,9 @@ *out_resource = viz::TransferableResource::MakeGpu( mailbox_holder.mailbox, filter, mailbox_holder.texture_target, mailbox_holder.sync_token, size, - viz::SkColorTypeToResourceFormat(color_type), is_overlay_candidate); + viz::SharedImageFormat::SinglePlane( + viz::SkColorTypeToResourceFormat(color_type)), + is_overlay_candidate); // If the transferred ImageBitmap contained in this ImageLayerBridge was // originated in a WebGPU context, we need to set the layer to be flipped.
diff --git a/third_party/blink/renderer/platform/loader/child_url_loader_factory_bundle.cc b/third_party/blink/renderer/platform/loader/child_url_loader_factory_bundle.cc index c3b19e6..ecf56b5 100644 --- a/third_party/blink/renderer/platform/loader/child_url_loader_factory_bundle.cc +++ b/third_party/blink/renderer/platform/loader/child_url_loader_factory_bundle.cc
@@ -147,6 +147,8 @@ pending_prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + pending_keep_alive_loader_factory, bool bypass_redirect_checks) : PendingURLLoaderFactoryBundle( std::move(pending_default_factory), @@ -155,8 +157,9 @@ bypass_redirect_checks), pending_prefetch_loader_factory_( std::move(pending_prefetch_loader_factory)), - pending_topics_loader_factory_(std::move(pending_topics_loader_factory)) { -} + pending_topics_loader_factory_(std::move(pending_topics_loader_factory)), + pending_keep_alive_loader_factory_( + std::move(pending_keep_alive_loader_factory)) {} ChildPendingURLLoaderFactoryBundle::~ChildPendingURLLoaderFactoryBundle() = default; @@ -173,6 +176,8 @@ std::move(pending_prefetch_loader_factory_); other->pending_topics_loader_factory_ = std::move(pending_topics_loader_factory_); + other->pending_keep_alive_loader_factory_ = + std::move(pending_keep_alive_loader_factory_); other->bypass_redirect_checks_ = bypass_redirect_checks_; return base::MakeRefCounted<ChildURLLoaderFactoryBundle>(std::move(other)); @@ -217,17 +222,19 @@ return; } - // Prefetch and topics are two disjoint request types. They cannot be true - // at the same time. - DCHECK( - !((request.load_flags & net::LOAD_PREFETCH) && request.browsing_topics)); + // Prefetch, browsing_topics, and keepalive are all disjoint request types. + // They cannot be true at the same time. + const bool request_is_prefetch = request.load_flags & net::LOAD_PREFETCH; + CHECK(!((request_is_prefetch && request.browsing_topics) || + (request_is_prefetch && request.keepalive) || + (request.browsing_topics && request.keepalive))); // Use |prefetch_loader_factory_| for prefetch requests to send the requests // to the PrefetchURLLoaderService in the browser process and trigger the // special prefetch handling. // TODO(horo): Move this routing logic to network service, when we will have // the special prefetch handling in network service. - if ((request.load_flags & net::LOAD_PREFETCH) && prefetch_loader_factory_) { + if (request_is_prefetch && prefetch_loader_factory_) { // This is no-state prefetch (see // WebURLRequest::GetLoadFlagsForWebUrlRequest). prefetch_loader_factory_->CreateLoaderAndStart( @@ -246,6 +253,17 @@ return; } + // Use |keep_alive_loader_factory_| to send the requests to the + // KeepAliveURLLoaderService in the browser process and trigger the special + // keepalive request handling. + if (request.keepalive && keep_alive_loader_factory_) { + keep_alive_loader_factory_->CreateLoaderAndStart( + std::move(loader), request_id, options, request, std::move(client), + traffic_annotation); + return; + } + + // Default request handling. URLLoaderFactoryBundle::CreateLoaderAndStart( std::move(loader), request_id, options, request, std::move(client), traffic_annotation); @@ -274,6 +292,13 @@ pending_topics_loader_factory.InitWithNewPipeAndPassReceiver()); } + mojo::PendingRemote<network::mojom::URLLoaderFactory> + pending_keep_alive_loader_factory; + if (keep_alive_loader_factory_) { + keep_alive_loader_factory_->Clone( + pending_keep_alive_loader_factory.InitWithNewPipeAndPassReceiver()); + } + // Currently there is no need to override subresources from workers, // therefore |subresource_overrides| are not shared with the clones. @@ -282,7 +307,8 @@ CloneRemoteMapToPendingRemoteMap(scheme_specific_factories_), CloneRemoteMapToPendingRemoteMap(isolated_world_factories_), std::move(pending_prefetch_loader_factory), - std::move(pending_topics_loader_factory), bypass_redirect_checks_); + std::move(pending_topics_loader_factory), + std::move(pending_keep_alive_loader_factory), bypass_redirect_checks_); } std::unique_ptr<ChildPendingURLLoaderFactoryBundle> @@ -303,12 +329,19 @@ pending_topics_loader_factory = topics_loader_factory_.Unbind(); } + mojo::PendingRemote<network::mojom::URLLoaderFactory> + pending_keep_alive_loader_factory; + if (keep_alive_loader_factory_) { + pending_keep_alive_loader_factory = keep_alive_loader_factory_.Unbind(); + } + return std::make_unique<ChildPendingURLLoaderFactoryBundle>( std::move(pending_default_factory), BoundRemoteMapToPendingRemoteMap(std::move(scheme_specific_factories_)), BoundRemoteMapToPendingRemoteMap(std::move(isolated_world_factories_)), std::move(pending_prefetch_loader_factory), - std::move(pending_topics_loader_factory), bypass_redirect_checks_); + std::move(pending_topics_loader_factory), + std::move(pending_keep_alive_loader_factory), bypass_redirect_checks_); } void ChildURLLoaderFactoryBundle::Update( @@ -321,6 +354,10 @@ topics_loader_factory_.Bind( std::move(pending_factories->pending_topics_loader_factory())); } + if (pending_factories->pending_keep_alive_loader_factory()) { + keep_alive_loader_factory_.Bind( + std::move(pending_factories->pending_keep_alive_loader_factory())); + } URLLoaderFactoryBundle::Update(std::move(pending_factories)); } @@ -343,6 +380,12 @@ topics_loader_factory_.Bind(std::move(topics_loader_factory)); } +void ChildURLLoaderFactoryBundle::SetKeepAliveLoaderFactory( + mojo::PendingRemote<network::mojom::URLLoaderFactory> + keep_alive_loader_factory) { + keep_alive_loader_factory_.Bind(std::move(keep_alive_loader_factory)); +} + bool ChildURLLoaderFactoryBundle::IsHostChildURLLoaderFactoryBundle() const { return false; }
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc b/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc index 6333dfc..8de0800 100644 --- a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc +++ b/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc
@@ -1424,7 +1424,9 @@ scoped_refptr<base::SingleThreadTaskRunner> task_runner = unfreezable_task_runner_; - if (request.GetKeepalive()) { + if (!base::FeatureList::IsEnabled( + blink::features::kKeepAliveInBrowserMigration) && + request.GetKeepalive()) { // Set the `task_runner` to the `AgentGroupScheduler`'s task-runner for // keepalive fetches because we want it to keep running even after the // frame is detached. It's pretty fragile to do that with the @@ -1964,7 +1966,9 @@ // first choice font failed to load). StopFetching(); - if (!loaders_.empty() || !non_blocking_loaders_.empty()) { + if ((!loaders_.empty() || !non_blocking_loaders_.empty()) && + !base::FeatureList::IsEnabled( + blink::features::kKeepAliveInBrowserMigration)) { // There are some keepalive requests. // The use of WrapPersistent creates a reference cycle intentionally, // to keep the ResourceFetcher and ResourceLoaders alive until the requests @@ -2346,7 +2350,12 @@ } void ResourceFetcher::StopFetching() { - StopFetchingInternal(StopFetchingTarget::kExcludingKeepaliveLoaders); + if (base::FeatureList::IsEnabled( + blink::features::kKeepAliveInBrowserMigration)) { + StopFetchingInternal(StopFetchingTarget::kIncludingKeepaliveLoaders); + } else { + StopFetchingInternal(StopFetchingTarget::kExcludingKeepaliveLoaders); + } } void ResourceFetcher::SetDefersLoading(LoaderFreezeMode mode) {
diff --git a/third_party/blink/renderer/platform/loader/tracked_child_url_loader_factory_bundle.cc b/third_party/blink/renderer/platform/loader/tracked_child_url_loader_factory_bundle.cc index 1e2f8739..0b5ed61 100644 --- a/third_party/blink/renderer/platform/loader/tracked_child_url_loader_factory_bundle.cc +++ b/third_party/blink/renderer/platform/loader/tracked_child_url_loader_factory_bundle.cc
@@ -26,6 +26,8 @@ pending_prefetch_loader_factory, mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_topics_loader_factory, + mojo::PendingRemote<network::mojom::URLLoaderFactory> + pending_keep_alive_loader_factory, std::unique_ptr<HostPtrAndTaskRunner> main_thread_host_bundle, bool bypass_redirect_checks) : ChildPendingURLLoaderFactoryBundle( @@ -34,6 +36,7 @@ std::move(pending_isolated_world_factories), std::move(pending_prefetch_loader_factory), std::move(pending_topics_loader_factory), + std::move(pending_keep_alive_loader_factory), bypass_redirect_checks), main_thread_host_bundle_(std::move(main_thread_host_bundle)) {} @@ -57,6 +60,8 @@ std::move(pending_prefetch_loader_factory_); other->pending_topics_loader_factory_ = std::move(pending_topics_loader_factory_); + other->pending_keep_alive_loader_factory_ = + std::move(pending_keep_alive_loader_factory_); other->main_thread_host_bundle_ = std::move(main_thread_host_bundle_); other->bypass_redirect_checks_ = bypass_redirect_checks_; @@ -97,6 +102,7 @@ std::move(pending_factories->pending_isolated_world_factories()), std::move(pending_factories->pending_prefetch_loader_factory()), std::move(pending_factories->pending_topics_loader_factory()), + std::move(pending_factories->pending_keep_alive_loader_factory()), std::move(main_thread_host_bundle_clone), pending_factories->bypass_redirect_checks()); } @@ -163,6 +169,7 @@ std::move(pending_factories->pending_isolated_world_factories()), std::move(pending_factories->pending_prefetch_loader_factory()), std::move(pending_factories->pending_topics_loader_factory()), + std::move(pending_factories->pending_keep_alive_loader_factory()), std::move(main_thread_host_bundle_clone), pending_factories->bypass_redirect_checks()); }
diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5 index c42d017..7607b9c 100644 --- a/third_party/blink/renderer/platform/runtime_enabled_features.json5 +++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5
@@ -933,6 +933,10 @@ status: "stable", }, { + // Support nested selectors that start with idents. + name: "CSSNestingIdent", + }, + { name: "CSSNewRootFontUnits", status: "stable", base_feature: "none", @@ -1597,8 +1601,6 @@ name: "FileHandling", depends_on: ["FileSystemAccessLocal"], status: {"Android": "test", "default": "stable"}, - origin_trial_feature_name: "FileHandling", - origin_trial_os: ["win", "mac", "linux", "fuchsia", "chromeos"], base_feature: "FileHandlingAPI", }, { @@ -1968,17 +1970,10 @@ { // crbug.com/1353190 name: "LayoutNGNoCopyBack", - depends_on: ["LayoutMediaNGContainer", "LayoutNGReplacedNoBoxSetters"], + depends_on: ["LayoutMediaNGContainer"], status: "test", }, { - // Avoid UpdateLogicalWidth() and UpdateLogicalHeight() in LayoutReplaced - // subclasses. - // It's a part of "stop-copying-back" project. crbug.com/1353190 - name: "LayoutNGReplacedNoBoxSetters", - status: "stable", - }, - { name: "LayoutNGShapeCache", status: "test", base_feature: "LayoutNGShapeCache",
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 666f4dd..6e50094 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
@@ -557,6 +557,7 @@ 'keywords::.+', 'layered_api::.+', 'layout_invalidation_reason::.+', + 'layout_text_control::.+', 'media_constraints_impl::.+', 'media_element_parser_helpers::.+', 'file_system_access_error::.+',
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index 8c81caf..c45ebf2 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -3194,7 +3194,6 @@ crbug.com/626703 external/wpt/input-events/input-events-get-target-ranges-joining-dl-element-and-another-list.tentative.html?Delete [ Failure Timeout ] crbug.com/626703 external/wpt/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html?Backspace,ol [ Failure Timeout ] crbug.com/626703 external/wpt/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html?Delete,ol [ Failure Timeout ] -crbug.com/626703 external/wpt/mediacapture-record/MediaRecorder-stop.html [ Timeout ] crbug.com/626703 [ Mac ] external/wpt/webxr/xr_viewport_scale.https.html [ Failure Timeout ] crbug.com/626703 external/wpt/infrastructure/testdriver/actions/iframe.html [ Failure Timeout ] crbug.com/626703 external/wpt/infrastructure/testdriver/actions/crossOrigin.sub.html [ Timeout ] @@ -6697,6 +6696,3 @@ # Sheriff 2023-03-27 crbug.com/1427936 external/wpt/js-self-profiling/function-expression-names.https.html [ Failure Pass ] - -# Temporarily disabled to land crrev.com/c/4365826 -crbug.com/1417112 http/tests/devtools/network/network-update-calculator-for-all-requests.js [ Failure Pass ]
diff --git a/third_party/blink/web_tests/VirtualTestSuites b/third_party/blink/web_tests/VirtualTestSuites index f3241d1..b613c13 100644 --- a/third_party/blink/web_tests/VirtualTestSuites +++ b/third_party/blink/web_tests/VirtualTestSuites
@@ -797,7 +797,16 @@ "args": ["--disable-blink-features=CSSSignRelatedFunctions"], "expires": "Jul 1, 2023" }, - + { + "prefix": "css-nesting-ident", + "platforms": ["Linux"], + "bases": [ + "wpt_internal/css/css-nesting/ident" + ], + "exclusive_tests": "ALL", + "args": ["--enable-blink-features=CSSNestingIdent"], + "expires": "Dec 1, 2023" + }, { "prefix": "import-maps-disabled", "platforms": ["Linux", "Mac", "Win"], @@ -1904,5 +1913,20 @@ ], "args": ["--disable-blink-features=AbortSignalComposition"], "expires": "Dec 21, 2023" + }, + { + "prefix": "keepalive-in-browser-migration", + "platforms": ["Linux", "Mac", "Win"], + "bases": [ + "external/wpt/background-fetch/", + "external/wpt/beacon/beacon-basic.https.window.js", + "external/wpt/beacon/beacon-navigate.https.window.js", + "external/wpt/fetch/", + "external/wpt/xhr/" + ], + "args": [ + "--enable-features=KeepAliveInBrowserMigration" + ], + "expires": "Dec 1, 2023" } ]
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/flexbox/monolithic-overflow-001.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/flexbox/monolithic-overflow-001.tentative.html new file mode 100644 index 0000000..1171485 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/flexbox/monolithic-overflow-001.tentative.html
@@ -0,0 +1,12 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:1; column-fill:auto; height:60px;"> + <div style="display:flex; flex-flow:column; height:100px; background:green;"> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/flexbox/monolithic-overflow-002.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/flexbox/monolithic-overflow-002.tentative.html new file mode 100644 index 0000000..298f749a --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/flexbox/monolithic-overflow-002.tentative.html
@@ -0,0 +1,12 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:1; column-fill:auto; height:60px;"> + <div style="display:flex; flex-flow:column; background:green;"> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/flexbox/monolithic-overflow-003.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/flexbox/monolithic-overflow-003.tentative.html new file mode 100644 index 0000000..ed223e8 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/flexbox/monolithic-overflow-003.tentative.html
@@ -0,0 +1,13 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:2; gap:0; column-fill:auto; height:60px;"> + <div style="display:flex; flex-flow:column; height:200px; background:green;"> + <div style="contain:size; height:100px;"></div> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/flexbox/monolithic-overflow-004.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/flexbox/monolithic-overflow-004.tentative.html new file mode 100644 index 0000000..ed7fea7 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/flexbox/monolithic-overflow-004.tentative.html
@@ -0,0 +1,13 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:2; gap:0; column-fill:auto; height:60px;"> + <div style="display:flex; flex-flow:column; background:green;"> + <div style="contain:size; height:100px;"></div> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-001.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-001.tentative.html new file mode 100644 index 0000000..95660ec --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-001.tentative.html
@@ -0,0 +1,12 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:1; column-fill:auto; height:60px;"> + <div style="display:grid; height:100px; background:green;"> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-002.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-002.tentative.html new file mode 100644 index 0000000..f487c3d --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-002.tentative.html
@@ -0,0 +1,12 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:1; column-fill:auto; height:60px;"> + <div style="display:grid; background:green;"> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-003.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-003.tentative.html new file mode 100644 index 0000000..c7a3903 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-003.tentative.html
@@ -0,0 +1,13 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:2; gap:0; column-fill:auto; height:60px;"> + <div style="display:grid; height:200px; background:green;"> + <div style="contain:size; height:100px;"></div> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-004.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-004.tentative.html new file mode 100644 index 0000000..20810061 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-004.tentative.html
@@ -0,0 +1,13 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:2; gap:0; column-fill:auto; height:60px;"> + <div style="display:grid; background:green;"> + <div style="contain:size; height:100px;"></div> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-005.html b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-005.html new file mode 100644 index 0000000..069ffb5b --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-005.html
@@ -0,0 +1,22 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<!-- Check that monolithic overflow in one grid item doesn't mess up the other item. --> +<div style="columns:4; gap:0; column-fill:auto; width:100px; height:100px; background:green;"> + <div style="display:grid; grid-template-columns:1fr 1fr; grid-template-rows:200px auto;"> + <div style="background:red;"> + <div style="height:200px; background:green;"></div> + </div> + <div style="background:red;"> + <div style="height:200px; background:green;"></div> + </div> + <div> + <div style="contain:size; height:150px;"></div> + </div> + <div style="background:red;"> + <div style="height:200px; background:green;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-006.html b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-006.html new file mode 100644 index 0000000..af4cfb1 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-006.html
@@ -0,0 +1,18 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<!-- Check that monolithic overflow in one grid item doesn't mess up the other item. --> +<div style="columns:4; gap:0; column-fill:auto; width:100px; height:100px; background:green;"> + <div style="display:grid; grid-template-columns:auto auto;"> + <div> + <div style="contain:size; height:150px;"></div> + <div style="contain:size; height:150px;"></div> + <div style="contain:size; height:150px;"></div> + </div> + <div style="background:red;"> + <div style="height:400px; background:green;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-007.html b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-007.html new file mode 100644 index 0000000..906ad29 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-007.html
@@ -0,0 +1,27 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="columns:4; gap:0; column-fill:auto; width:100px; height:100px;"> + <div style="display:grid; background:red;"> + <div> + <div style="contain:size; height:150px;"> + <div style="height:100px; background:green;"></div> + <div style="height:50px; background:white;"></div> + </div> + <div style="contain:size; height:150px;"> + <div style="height:100px; background:green;"></div> + <div style="height:50px; background:white;"></div> + </div> + <div style="contain:size; height:150px;"> + <div style="height:100px; background:green;"></div> + <div style="height:50px; background:white;"></div> + </div> + <div style="contain:size; height:150px;"> + <div style="height:100px; background:green;"></div> + <div style="height:50px; background:white;"></div> + </div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-008.html b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-008.html new file mode 100644 index 0000000..6e2caf6 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/grid/monolithic-overflow-008.html
@@ -0,0 +1,25 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="columns:4; gap:0; column-fill:auto; width:100px; height:100px;"> + <div style="display:grid; background:red;"> + <div style="contain:size; height:150px;"> + <div style="height:100px; background:green;"></div> + <div style="height:50px; background:white;"></div> + </div> + <div style="contain:size; height:150px;"> + <div style="height:100px; background:green;"></div> + <div style="height:50px; background:white;"></div> + </div> + <div style="contain:size; height:150px;"> + <div style="height:100px; background:green;"></div> + <div style="height:50px; background:white;"></div> + </div> + <div style="contain:size; height:150px;"> + <div style="height:100px; background:green;"></div> + <div style="height:50px; background:white;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-001.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-001.tentative.html new file mode 100644 index 0000000..db285a9 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-001.tentative.html
@@ -0,0 +1,12 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:1; column-fill:auto; height:60px;"> + <div style="height:100px; background:green;"> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-002.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-002.tentative.html new file mode 100644 index 0000000..387af9c --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-002.tentative.html
@@ -0,0 +1,12 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:1; column-fill:auto; height:60px;"> + <div style="background:green;"> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-003.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-003.tentative.html new file mode 100644 index 0000000..02210aee3 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-003.tentative.html
@@ -0,0 +1,13 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:2; gap:0; column-fill:auto; height:60px;"> + <div style="height:200px; background:green;"> + <div style="contain:size; height:100px;"></div> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-004.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-004.tentative.html new file mode 100644 index 0000000..9a19081 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-004.tentative.html
@@ -0,0 +1,13 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:2; gap:0; column-fill:auto; height:60px;"> + <div style="background:green;"> + <div style="contain:size; height:100px;"></div> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-005.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-005.tentative.html new file mode 100644 index 0000000..f1667a15 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-005.tentative.html
@@ -0,0 +1,13 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:2; gap:0; column-fill:auto; height:60px;"> + <div style="height:100px; background:green;"> + <div style="contain:size; height:300px;"></div> + <div style="contain:size; height:100px; background:green;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-006.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-006.tentative.html new file mode 100644 index 0000000..200f271 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/monolithic-overflow-006.tentative.html
@@ -0,0 +1,19 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:2; gap:0; column-fill:auto; height:60px;"> + <div style="height:150px; background:green;"> + <div style="contain:size; height:100px;"> + <div style="height:60px;"></div> + <div style="height:40px; margin-left:100%; width:100%; background:green;"></div> + </div> + <div style="height:60px;"> + <div style="height:50px;"></div> + <div style="height:10px; background:green;"></div> + </div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-001.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-001.tentative.html new file mode 100644 index 0000000..34487c4 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-001.tentative.html
@@ -0,0 +1,12 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:1; column-fill:auto; height:60px;"> + <div style="display:table; width:100%; height:100px; background:green;"> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-002.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-002.tentative.html new file mode 100644 index 0000000..74b63fb --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-002.tentative.html
@@ -0,0 +1,12 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:1; column-fill:auto; height:60px;"> + <div style="display:table; width:100%; background:green;"> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-003.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-003.tentative.html new file mode 100644 index 0000000..296a309 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-003.tentative.html
@@ -0,0 +1,13 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:2; gap:0; column-fill:auto; height:60px;"> + <div style="display:table; width:100%; height:200px; background:green;"> + <div style="contain:size; height:100px;"></div> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-004.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-004.tentative.html new file mode 100644 index 0000000..6f62f43 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-004.tentative.html
@@ -0,0 +1,13 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="width:100px; height:100px; background:red;"> + <div style="columns:2; gap:0; column-fill:auto; height:60px;"> + <div style="display:table; width:100%; background:green;"> + <div style="contain:size; height:100px;"></div> + <div style="contain:size; height:100px;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-005.html b/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-005.html new file mode 100644 index 0000000..7204359 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-005.html
@@ -0,0 +1,26 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<!-- Check that monolithic overflow in one cell doesn't mess up the other cell. --> +<div style="columns:4; gap:0; column-fill:auto; width:100px; height:100px; background:green;"> + <div style="display:table; width:100%;"> + <div style="display:table-row;"> + <div style="display:table-cell; background:red;"> + <div style="height:200px; background:green;"></div> + </div> + <div style="display:table-cell; background:red;"> + <div style="height:200px; background:green;"></div> + </div> + </div> + <div style="display:table-row;"> + <div style="display:table-cell; width:50%;"> + <div style="contain:size; height:150px;"></div> + </div> + <div style="display:table-cell; width:50%; background:red;"> + <div style="height:200px; background:green;"></div> + </div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-006.html b/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-006.html new file mode 100644 index 0000000..a8ebd11 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-break/table/monolithic-overflow-006.html
@@ -0,0 +1,19 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1425077"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<!-- Check that monolithic overflow in one table cell doesn't mess up percentage resolution in the other cell. --> +<div style="columns:2; column-fill:auto; gap:0; width:100px; height:100px; background:red;"> + <div style="display:table; width:100%; height:200px;"> + <div style="display:table-cell; width:50%;"> + <div style="height:100%; background:green;"></div> + </div> + <div style="display:table-cell; width:50%;"> + <div style="contain:size; height:130px;"> + <div style="height:100px; background:green;"></div> + </div> + <div style="height:100px; background:green;"></div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/fetch/api/basic/response-null-body.any.js b/third_party/blink/web_tests/external/wpt/fetch/api/basic/response-null-body.any.js index 7824a20..bb058926 100644 --- a/third_party/blink/web_tests/external/wpt/fetch/api/basic/response-null-body.any.js +++ b/third_party/blink/web_tests/external/wpt/fetch/api/basic/response-null-body.any.js
@@ -29,3 +29,10 @@ const text = await resp.text(); assert_equals(text, "", "null bodies result in empty text"); }, `Response.body is null for responses with method=HEAD`); + +promise_test(async (t) => { + const integrity = "sha384-UT6f7WCFp32YJnp1is4l/ZYnOeQKpE8xjmdkLOwZ3nIP+tmT2aMRFQGJomjVf5cE"; + const url = `${RESOURCES_DIR}status.py?code=204&content=hello-world`; + const promise = fetch(url, { method: "GET", integrity }); + promise_rejects_js(t, TypeError, promise); +}, "Null body status with subresource integrity should abort");
diff --git a/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-stop-expected.txt b/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-stop-expected.txt index 7c23f51..6bdc8e6 100644 --- a/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-stop-expected.txt +++ b/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-stop-expected.txt
@@ -5,6 +5,7 @@ PASS MediaRecorder will not fire an exception when stopped after having just been stopped PASS MediaRecorder will not fire an exception when stopped after having just been spontaneously stopped FAIL MediaRecorder will fire start event even if stopped synchronously assert_array_equals: lengths differ, expected array ["start", "stop"] length 2, got ["stop"] length 1 -FAIL MediaRecorder will fire start event even if a track is removed synchronously assert_array_equals: lengths differ, expected array ["start", "error", "data", "stop"] length 4, got [] length 0 +FAIL MediaRecorder will fire start event even if a track is removed synchronously assert_array_equals: lengths differ, expected array ["start", "error", "data", "stop"] length 4, got ["error", "data", "stop"] length 3 +PASS MediaRecorder will fire only start and stop events in a basic recording flow. Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-stop.html b/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-stop.html index 73eb299..2b49a4c 100644 --- a/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-stop.html +++ b/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-stop.html
@@ -26,7 +26,9 @@ assert_greater_than_equal( j, 0, "Sequence element " + event + " is not included in " + expected.slice(i)); - i = j; + // Ensure duplicates in actual aren't silently accepted by skipping + // past the matched element. + i = j + 1; } return true; } @@ -146,6 +148,19 @@ assert_array_equals(events, ["start", "error", "data", "stop"]); }, "MediaRecorder will fire start event even if a track is removed synchronously"); + promise_test(async t => { + const {stream} = createFlowingAudioVideoStream(t); + const recorder = new MediaRecorder(stream); + const events = recordEvents(recorder, + ["start", "stop", "dataavailable", "pause", "resume", "error"]); + const dataPromise = new Promise(r => recorder.ondataavailable = r); + recorder.start(0); + await dataPromise; + recorder.stop(); + await new Promise (r => recorder.onstop = r); + assertSequenceIn(events, ["start", "dataavailable", "stop"]); + }, "MediaRecorder will fire only start and stop events in a basic recording flow."); + </script> </body> </html>
diff --git a/third_party/blink/web_tests/external/wpt/navigation-api/navigate-event/defaultPrevented-navigation-preempted.html b/third_party/blink/web_tests/external/wpt/navigation-api/navigate-event/defaultPrevented-navigation-preempted.html new file mode 100644 index 0000000..1df4f56 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/navigation-api/navigate-event/defaultPrevented-navigation-preempted.html
@@ -0,0 +1,19 @@ +<!doctype html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(() => { + let navigateEvent; + let navigateError_called = false; + navigation.onnavigate = e => navigateEvent = e; + navigation.onnavigateerror = () => navigateError_called = true; + + navigation.navigate("#1"); + assert_false(navigateEvent.defaultPrevented); + assert_false(navigateError_called); + + navigation.navigate("#2"); + assert_false(navigateEvent.defaultPrevented); + assert_true(navigateError_called); +}, "navigateEvent.defaultPrevented isn't affected when the navigation is preempted after dispatch"); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/navigation-api/navigate-event/defaultPrevented-window-stop-after-dispatch.html b/third_party/blink/web_tests/external/wpt/navigation-api/navigate-event/defaultPrevented-window-stop-after-dispatch.html new file mode 100644 index 0000000..da5de10 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/navigation-api/navigate-event/defaultPrevented-window-stop-after-dispatch.html
@@ -0,0 +1,16 @@ +<!doctype html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +async_test(t => { + window.onload = t.step_func_done(() => { + let navigateEvent; + navigation.onnavigate = e => navigateEvent = e; + navigation.navigate("?1"); + assert_false(navigateEvent.defaultPrevented); + + window.stop(); + assert_false(navigateEvent.defaultPrevented); + }); +}, "window.stop() doesn't affect navigateEvent.defaultPrevented after dispatch"); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any-expected.txt b/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any-expected.txt index a804638..dc28c93f 100644 --- a/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any-expected.txt +++ b/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any-expected.txt
@@ -17,7 +17,7 @@ FAIL ReadableStream teeing with byte source: erroring the original should error pending reads from BYOB reader promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: canceling branch1 should finish when branch2 reads until end of stream promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: canceling branch1 should finish when original stream errors promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" -FAIL ReadableStream teeing with byte source: should not pull any chunks if no branches are reading assert_array_equals: pull should not be called lengths differ, expected array [] length 0, got ["pull", "pull"] length 2 +FAIL ReadableStream teeing with byte source: should not pull any chunks if no branches are reading assert_array_equals: pull should not be called lengths differ, expected array [] length 0, got ["pull"] length 1 FAIL ReadableStream teeing with byte source: should only pull enough to fill the emptiest queue promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: should not pull when original is already errored promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: stops pulling when original stream errors while branch 1 is reading promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream"
diff --git a/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any.serviceworker-expected.txt b/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any.serviceworker-expected.txt index a804638..dc28c93f 100644 --- a/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any.serviceworker-expected.txt +++ b/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any.serviceworker-expected.txt
@@ -17,7 +17,7 @@ FAIL ReadableStream teeing with byte source: erroring the original should error pending reads from BYOB reader promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: canceling branch1 should finish when branch2 reads until end of stream promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: canceling branch1 should finish when original stream errors promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" -FAIL ReadableStream teeing with byte source: should not pull any chunks if no branches are reading assert_array_equals: pull should not be called lengths differ, expected array [] length 0, got ["pull", "pull"] length 2 +FAIL ReadableStream teeing with byte source: should not pull any chunks if no branches are reading assert_array_equals: pull should not be called lengths differ, expected array [] length 0, got ["pull"] length 1 FAIL ReadableStream teeing with byte source: should only pull enough to fill the emptiest queue promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: should not pull when original is already errored promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: stops pulling when original stream errors while branch 1 is reading promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream"
diff --git a/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any.sharedworker-expected.txt b/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any.sharedworker-expected.txt index a804638..dc28c93f 100644 --- a/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any.sharedworker-expected.txt +++ b/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any.sharedworker-expected.txt
@@ -17,7 +17,7 @@ FAIL ReadableStream teeing with byte source: erroring the original should error pending reads from BYOB reader promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: canceling branch1 should finish when branch2 reads until end of stream promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: canceling branch1 should finish when original stream errors promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" -FAIL ReadableStream teeing with byte source: should not pull any chunks if no branches are reading assert_array_equals: pull should not be called lengths differ, expected array [] length 0, got ["pull", "pull"] length 2 +FAIL ReadableStream teeing with byte source: should not pull any chunks if no branches are reading assert_array_equals: pull should not be called lengths differ, expected array [] length 0, got ["pull"] length 1 FAIL ReadableStream teeing with byte source: should only pull enough to fill the emptiest queue promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: should not pull when original is already errored promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: stops pulling when original stream errors while branch 1 is reading promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream"
diff --git a/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any.worker-expected.txt b/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any.worker-expected.txt index a804638..dc28c93f 100644 --- a/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any.worker-expected.txt +++ b/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/tee.any.worker-expected.txt
@@ -17,7 +17,7 @@ FAIL ReadableStream teeing with byte source: erroring the original should error pending reads from BYOB reader promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: canceling branch1 should finish when branch2 reads until end of stream promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: canceling branch1 should finish when original stream errors promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" -FAIL ReadableStream teeing with byte source: should not pull any chunks if no branches are reading assert_array_equals: pull should not be called lengths differ, expected array [] length 0, got ["pull", "pull"] length 2 +FAIL ReadableStream teeing with byte source: should not pull any chunks if no branches are reading assert_array_equals: pull should not be called lengths differ, expected array [] length 0, got ["pull"] length 1 FAIL ReadableStream teeing with byte source: should only pull enough to fill the emptiest queue promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: should not pull when original is already errored promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream" FAIL ReadableStream teeing with byte source: stops pulling when original stream errors while branch 1 is reading promise_test: Unhandled rejection with value: object "TypeError: Failed to execute 'getReader' on 'ReadableStream': Cannot use a BYOB reader with a non-byte stream"
diff --git a/third_party/blink/web_tests/external/wpt/streams/readable-streams/global-expected.txt b/third_party/blink/web_tests/external/wpt/streams/readable-streams/global-expected.txt index 8fe1616d..e8a0733 100644 --- a/third_party/blink/web_tests/external/wpt/streams/readable-streams/global-expected.txt +++ b/third_party/blink/web_tests/external/wpt/streams/readable-streams/global-expected.txt
@@ -2,7 +2,7 @@ PASS Stream objects created in expected globals FAIL Cancel promise is created in same global as stream assert_equals: Cancel promise comes from the same global as the stream expected true but got false PASS Closed Promise in correct global -PASS Reader objects in correct global +FAIL Reader objects in correct global assert_equals: Object comes from other realm expected true but got false PASS Desired size can be grafted from one prototype to another PASS Closing errored stream throws object in appropriate global PASS Can enqueue chunks from multiple globals
diff --git a/third_party/blink/web_tests/external/wpt/streams/readable-streams/tee.any-expected.txt b/third_party/blink/web_tests/external/wpt/streams/readable-streams/tee.any-expected.txt deleted file mode 100644 index 852f5d01..0000000 --- a/third_party/blink/web_tests/external/wpt/streams/readable-streams/tee.any-expected.txt +++ /dev/null
@@ -1,29 +0,0 @@ -This is a testharness.js-based test. -PASS ReadableStream teeing: rs.tee() returns an array of two ReadableStreams -PASS ReadableStream teeing: should be able to read one branch to the end without affecting the other -PASS ReadableStream teeing: values should be equal across each branch -PASS ReadableStream teeing: errors in the source should propagate to both branches -PASS ReadableStream teeing: canceling branch1 should not impact branch2 -PASS ReadableStream teeing: canceling branch2 should not impact branch1 -PASS Running templatedRSTeeCancel with ReadableStream teeing -PASS ReadableStream teeing: canceling both branches should aggregate the cancel reasons into an array -PASS ReadableStream teeing: canceling both branches in reverse order should aggregate the cancel reasons into an array -PASS ReadableStream teeing: failing to cancel the original stream should cause cancel() to reject on branches -PASS ReadableStream teeing: erroring a teed stream should properly handle canceled branches -PASS ReadableStream teeing: erroring a teed stream should error both branches -PASS ReadableStream teeing: closing the original should immediately close the branches -PASS ReadableStream teeing: erroring the original should immediately error the branches -PASS ReadableStream teeing: canceling branch1 should finish when branch2 reads until end of stream -PASS ReadableStream teeing: canceling branch1 should finish when original stream errors -PASS ReadableStream teeing: canceling both branches in sequence with delay -PASS ReadableStream teeing: failing to cancel when canceling both branches in sequence with delay -PASS ReadableStreamTee should not use a modified ReadableStream constructor from the global object -FAIL ReadableStreamTee should not pull more chunks than can fit in the branch queue assert_array_equals: pull should only be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -PASS ReadableStreamTee should only pull enough to fill the emptiest queue -PASS ReadableStreamTee should not pull when original is already errored -FAIL ReadableStreamTee stops pulling when original stream errors while branch 1 is reading assert_array_equals: pull should be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -FAIL ReadableStreamTee stops pulling when original stream errors while branch 2 is reading assert_array_equals: pull should be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -FAIL ReadableStreamTee stops pulling when original stream errors while both branches are reading assert_array_equals: pull should be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -PASS ReadableStream teeing: enqueue() and close() while both branches are pulling -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/external/wpt/streams/readable-streams/tee.any.serviceworker-expected.txt b/third_party/blink/web_tests/external/wpt/streams/readable-streams/tee.any.serviceworker-expected.txt deleted file mode 100644 index 852f5d01..0000000 --- a/third_party/blink/web_tests/external/wpt/streams/readable-streams/tee.any.serviceworker-expected.txt +++ /dev/null
@@ -1,29 +0,0 @@ -This is a testharness.js-based test. -PASS ReadableStream teeing: rs.tee() returns an array of two ReadableStreams -PASS ReadableStream teeing: should be able to read one branch to the end without affecting the other -PASS ReadableStream teeing: values should be equal across each branch -PASS ReadableStream teeing: errors in the source should propagate to both branches -PASS ReadableStream teeing: canceling branch1 should not impact branch2 -PASS ReadableStream teeing: canceling branch2 should not impact branch1 -PASS Running templatedRSTeeCancel with ReadableStream teeing -PASS ReadableStream teeing: canceling both branches should aggregate the cancel reasons into an array -PASS ReadableStream teeing: canceling both branches in reverse order should aggregate the cancel reasons into an array -PASS ReadableStream teeing: failing to cancel the original stream should cause cancel() to reject on branches -PASS ReadableStream teeing: erroring a teed stream should properly handle canceled branches -PASS ReadableStream teeing: erroring a teed stream should error both branches -PASS ReadableStream teeing: closing the original should immediately close the branches -PASS ReadableStream teeing: erroring the original should immediately error the branches -PASS ReadableStream teeing: canceling branch1 should finish when branch2 reads until end of stream -PASS ReadableStream teeing: canceling branch1 should finish when original stream errors -PASS ReadableStream teeing: canceling both branches in sequence with delay -PASS ReadableStream teeing: failing to cancel when canceling both branches in sequence with delay -PASS ReadableStreamTee should not use a modified ReadableStream constructor from the global object -FAIL ReadableStreamTee should not pull more chunks than can fit in the branch queue assert_array_equals: pull should only be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -PASS ReadableStreamTee should only pull enough to fill the emptiest queue -PASS ReadableStreamTee should not pull when original is already errored -FAIL ReadableStreamTee stops pulling when original stream errors while branch 1 is reading assert_array_equals: pull should be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -FAIL ReadableStreamTee stops pulling when original stream errors while branch 2 is reading assert_array_equals: pull should be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -FAIL ReadableStreamTee stops pulling when original stream errors while both branches are reading assert_array_equals: pull should be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -PASS ReadableStream teeing: enqueue() and close() while both branches are pulling -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/external/wpt/streams/readable-streams/tee.any.sharedworker-expected.txt b/third_party/blink/web_tests/external/wpt/streams/readable-streams/tee.any.sharedworker-expected.txt deleted file mode 100644 index 852f5d01..0000000 --- a/third_party/blink/web_tests/external/wpt/streams/readable-streams/tee.any.sharedworker-expected.txt +++ /dev/null
@@ -1,29 +0,0 @@ -This is a testharness.js-based test. -PASS ReadableStream teeing: rs.tee() returns an array of two ReadableStreams -PASS ReadableStream teeing: should be able to read one branch to the end without affecting the other -PASS ReadableStream teeing: values should be equal across each branch -PASS ReadableStream teeing: errors in the source should propagate to both branches -PASS ReadableStream teeing: canceling branch1 should not impact branch2 -PASS ReadableStream teeing: canceling branch2 should not impact branch1 -PASS Running templatedRSTeeCancel with ReadableStream teeing -PASS ReadableStream teeing: canceling both branches should aggregate the cancel reasons into an array -PASS ReadableStream teeing: canceling both branches in reverse order should aggregate the cancel reasons into an array -PASS ReadableStream teeing: failing to cancel the original stream should cause cancel() to reject on branches -PASS ReadableStream teeing: erroring a teed stream should properly handle canceled branches -PASS ReadableStream teeing: erroring a teed stream should error both branches -PASS ReadableStream teeing: closing the original should immediately close the branches -PASS ReadableStream teeing: erroring the original should immediately error the branches -PASS ReadableStream teeing: canceling branch1 should finish when branch2 reads until end of stream -PASS ReadableStream teeing: canceling branch1 should finish when original stream errors -PASS ReadableStream teeing: canceling both branches in sequence with delay -PASS ReadableStream teeing: failing to cancel when canceling both branches in sequence with delay -PASS ReadableStreamTee should not use a modified ReadableStream constructor from the global object -FAIL ReadableStreamTee should not pull more chunks than can fit in the branch queue assert_array_equals: pull should only be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -PASS ReadableStreamTee should only pull enough to fill the emptiest queue -PASS ReadableStreamTee should not pull when original is already errored -FAIL ReadableStreamTee stops pulling when original stream errors while branch 1 is reading assert_array_equals: pull should be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -FAIL ReadableStreamTee stops pulling when original stream errors while branch 2 is reading assert_array_equals: pull should be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -FAIL ReadableStreamTee stops pulling when original stream errors while both branches are reading assert_array_equals: pull should be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -PASS ReadableStream teeing: enqueue() and close() while both branches are pulling -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/external/wpt/streams/readable-streams/tee.any.worker-expected.txt b/third_party/blink/web_tests/external/wpt/streams/readable-streams/tee.any.worker-expected.txt deleted file mode 100644 index 852f5d01..0000000 --- a/third_party/blink/web_tests/external/wpt/streams/readable-streams/tee.any.worker-expected.txt +++ /dev/null
@@ -1,29 +0,0 @@ -This is a testharness.js-based test. -PASS ReadableStream teeing: rs.tee() returns an array of two ReadableStreams -PASS ReadableStream teeing: should be able to read one branch to the end without affecting the other -PASS ReadableStream teeing: values should be equal across each branch -PASS ReadableStream teeing: errors in the source should propagate to both branches -PASS ReadableStream teeing: canceling branch1 should not impact branch2 -PASS ReadableStream teeing: canceling branch2 should not impact branch1 -PASS Running templatedRSTeeCancel with ReadableStream teeing -PASS ReadableStream teeing: canceling both branches should aggregate the cancel reasons into an array -PASS ReadableStream teeing: canceling both branches in reverse order should aggregate the cancel reasons into an array -PASS ReadableStream teeing: failing to cancel the original stream should cause cancel() to reject on branches -PASS ReadableStream teeing: erroring a teed stream should properly handle canceled branches -PASS ReadableStream teeing: erroring a teed stream should error both branches -PASS ReadableStream teeing: closing the original should immediately close the branches -PASS ReadableStream teeing: erroring the original should immediately error the branches -PASS ReadableStream teeing: canceling branch1 should finish when branch2 reads until end of stream -PASS ReadableStream teeing: canceling branch1 should finish when original stream errors -PASS ReadableStream teeing: canceling both branches in sequence with delay -PASS ReadableStream teeing: failing to cancel when canceling both branches in sequence with delay -PASS ReadableStreamTee should not use a modified ReadableStream constructor from the global object -FAIL ReadableStreamTee should not pull more chunks than can fit in the branch queue assert_array_equals: pull should only be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -PASS ReadableStreamTee should only pull enough to fill the emptiest queue -PASS ReadableStreamTee should not pull when original is already errored -FAIL ReadableStreamTee stops pulling when original stream errors while branch 1 is reading assert_array_equals: pull should be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -FAIL ReadableStreamTee stops pulling when original stream errors while branch 2 is reading assert_array_equals: pull should be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -FAIL ReadableStreamTee stops pulling when original stream errors while both branches are reading assert_array_equals: pull should be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2 -PASS ReadableStream teeing: enqueue() and close() while both branches are pulling -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/external/wpt/streams/transform-streams/invalid-realm.window-expected.txt b/third_party/blink/web_tests/external/wpt/streams/transform-streams/invalid-realm.window-expected.txt new file mode 100644 index 0000000..74422a3a --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/streams/transform-streams/invalid-realm.window-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +FAIL TransformStream: write in detached realm should succeed promise_test: Unhandled rejection with value: object "TypeError: invalid realm" +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/external/wpt/streams/transform-streams/invalid-realm.window.js b/third_party/blink/web_tests/external/wpt/streams/transform-streams/invalid-realm.window.js new file mode 100644 index 0000000..57cdfd94 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/streams/transform-streams/invalid-realm.window.js
@@ -0,0 +1,17 @@ +// TransformStream should still work even if the realm is detached. + +// Adds an iframe to the document and returns it. +function addIframe() { + const iframe = document.createElement('iframe'); + document.body.appendChild(iframe); + return iframe; +} + +promise_test(async t => { + const iframe = addIframe(); + const stream = new iframe.contentWindow.TransformStream(); + const readPromise = stream.readable.getReader().read(); + const writer = stream.writable.getWriter(); + iframe.remove(); + return Promise.all([writer.write('A'), readPromise]); +}, 'TransformStream: write in detached realm should succeed');
diff --git a/third_party/blink/web_tests/external/wpt/trusted-types/Document-execCommand.tentative.html b/third_party/blink/web_tests/external/wpt/trusted-types/Document-execCommand.tentative.html index 0fd7e64..761913365 100644 --- a/third_party/blink/web_tests/external/wpt/trusted-types/Document-execCommand.tentative.html +++ b/third_party/blink/web_tests/external/wpt/trusted-types/Document-execCommand.tentative.html
@@ -1,6 +1,6 @@ <!DOCTYPE html> <link rel="author" title="Daniel Vogelheim" href="mailto:vogelheim@chromium.org"></link> -<link rel="help" href="https://w3c.github.io/webappsec-trusted-types/dist/spec/"></link> +<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/"></link> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <body>
diff --git a/third_party/blink/web_tests/external/wpt/trusted-types/META.yml b/third_party/blink/web_tests/external/wpt/trusted-types/META.yml index 8cc6a43..04061ac 100644 --- a/third_party/blink/web_tests/external/wpt/trusted-types/META.yml +++ b/third_party/blink/web_tests/external/wpt/trusted-types/META.yml
@@ -1,3 +1,3 @@ -spec: https://w3c.github.io/webappsec-trusted-types/dist/spec/ +spec: https://w3c.github.io/trusted-types/dist/spec/ suggested_reviewers: - mikewest
diff --git a/third_party/blink/web_tests/external/wpt/trusted-types/TrustedTypePolicyFactory-getPropertyType.tentative.html b/third_party/blink/web_tests/external/wpt/trusted-types/TrustedTypePolicyFactory-getPropertyType.tentative.html index 9c65ef9..21aba668 100644 --- a/third_party/blink/web_tests/external/wpt/trusted-types/TrustedTypePolicyFactory-getPropertyType.tentative.html +++ b/third_party/blink/web_tests/external/wpt/trusted-types/TrustedTypePolicyFactory-getPropertyType.tentative.html
@@ -24,7 +24,7 @@ }, "sanity check trustedTypes.getTypeMapping"); - // getPropertyType tests adapted from WICG/trusted-types polyfill: + // getPropertyType tests adapted from w3c/trusted-types polyfill: test(t => { // returns the proper type for attribute-related properties assert_equals(trustedTypes.getPropertyType("script", "src"), "TrustedScriptURL"); @@ -46,7 +46,7 @@ ["text", "innerText", "textContent"].forEach((prop) => { assert_equals(trustedTypes.getPropertyType("script", prop), "TrustedScript"); }); - }, "getPropertyType tests adapted from WICG/trusted-types polyfill"); + }, "getPropertyType tests adapted from w3c/trusted-types polyfill"); test(t => { // returns the proper type @@ -69,7 +69,7 @@ // defaults to undefined assert_equals(trustedTypes.getAttributeType('unknown', 'src'), null); assert_equals(trustedTypes.getAttributeType('img', 'bar'), null); - }, "getAttributeType tests adapted from WICG/trusted-types polyfill"); + }, "getAttributeType tests adapted from w3c/trusted-types polyfill"); test(t=> { @@ -87,7 +87,7 @@ ; // Unknown namespaces: assert_equals(trustedTypes.getTypeMapping("http://foo/bar"), null); - }, "getTypeMapping tests adapted from WICG/trusted-types polyfill"); + }, "getTypeMapping tests adapted from w3c/trusted-types polyfill"); // Test case handling for both attributes and properties. for (let attr of ["codeBase", "CODEBASE", "codebase"]) {
diff --git a/third_party/blink/web_tests/external/wpt/trusted-types/block-Document-execCommand.tentative.html b/third_party/blink/web_tests/external/wpt/trusted-types/block-Document-execCommand.tentative.html index e25b7dd2..87759cd 100644 --- a/third_party/blink/web_tests/external/wpt/trusted-types/block-Document-execCommand.tentative.html +++ b/third_party/blink/web_tests/external/wpt/trusted-types/block-Document-execCommand.tentative.html
@@ -1,7 +1,7 @@ <!DOCTYPE html> <meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script'"> <link rel="author" title="Daniel Vogelheim" href="mailto:vogelheim@chromium.org"></link> -<link rel="help" href="https://w3c.github.io/webappsec-trusted-types/dist/spec/"></link> +<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/"></link> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <body>
diff --git a/third_party/blink/web_tests/external/wpt/trusted-types/block-text-node-insertion-into-script-element.tentative.html b/third_party/blink/web_tests/external/wpt/trusted-types/block-text-node-insertion-into-script-element.tentative.html index 8197536..08e3e69 100644 --- a/third_party/blink/web_tests/external/wpt/trusted-types/block-text-node-insertion-into-script-element.tentative.html +++ b/third_party/blink/web_tests/external/wpt/trusted-types/block-text-node-insertion-into-script-element.tentative.html
@@ -18,7 +18,7 @@ const policy = trustedTypes.createPolicy("policy", policy_dict); // Regression tests for 'Bypass via insertAdjacentText', reported at - // https://github.com/WICG/trusted-types/issues/133 + // https://github.com/w3c/trusted-types/issues/133 // We are trying to assert that scripts do _not_ get executed. We // accomplish by having the script under examination containing a
diff --git a/third_party/blink/web_tests/external/wpt/trusted-types/trusted-types-from-literal.tentative.html b/third_party/blink/web_tests/external/wpt/trusted-types/trusted-types-from-literal.tentative.html index b59c46fe0..a7d5659 100644 --- a/third_party/blink/web_tests/external/wpt/trusted-types/trusted-types-from-literal.tentative.html +++ b/third_party/blink/web_tests/external/wpt/trusted-types/trusted-types-from-literal.tentative.html
@@ -1,7 +1,7 @@ <!DOCTYPE html> <head> <link rel="author" title="Daniel Vogelheim" href="mailto:vogelheim@chromium.org"></link> -<link rel="help" href="https://w3c.github.io/webappsec-trusted-types/dist/spec/"></link> +<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/"></link> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script'">
diff --git a/third_party/blink/web_tests/fast/mediarecorder/MediaRecorder-error.html b/third_party/blink/web_tests/fast/mediarecorder/MediaRecorder-error.html index d4aa434..7c1d214 100644 --- a/third_party/blink/web_tests/fast/mediarecorder/MediaRecorder-error.html +++ b/third_party/blink/web_tests/fast/mediarecorder/MediaRecorder-error.html
@@ -21,7 +21,7 @@ } recorderOnDataAvailable = test.step_func(function(event) { - recorder.onstop = recorderOnStop; + recorder.onerror = recorderOnError; // Add another track to the MediaStream to force an error. stream.addTrack(stream.getVideoTracks()[0].clone()); @@ -29,13 +29,12 @@ }); recorderOnStop = test.step_func(function() { - recorder.onstop = test.unreached_func('Unexpected stop event'); recorder.ondataavailable = test.unreached_func('Unexpected data event'); - recorder.onerror = recorderOnError; + test.done(); }); recorderOnError = test.step_func(function() { - test.done(); + recorder.onstop = recorderOnStop; }); var step = test.step_func(function() {
diff --git a/third_party/blink/web_tests/virtual/css-nesting-ident/README.md b/third_party/blink/web_tests/virtual/css-nesting-ident/README.md new file mode 100644 index 0000000..07e0784 --- /dev/null +++ b/third_party/blink/web_tests/virtual/css-nesting-ident/README.md
@@ -0,0 +1,4 @@ +This suite runs with --enable-blink-features=CSSNestingIdent. + +https://crbug.com/1427259 +https://github.com/w3c/csswg-drafts/issues/7961
diff --git a/third_party/blink/web_tests/virtual/keepalive-in-browser-migration/README.md b/third_party/blink/web_tests/virtual/keepalive-in-browser-migration/README.md new file mode 100644 index 0000000..9c3e622 --- /dev/null +++ b/third_party/blink/web_tests/virtual/keepalive-in-browser-migration/README.md
@@ -0,0 +1,25 @@ +# Fetch Keepalive Infra Migration Virtual Tests + +This folder contains virtual test suites for the keepalive infra migration. +The suite runs the following with the argument +`--enable-features=KeepAliveInBrowserMigration`: + +- `web_tests/external/wpt/background-fetch/` +- `web_tests/external/wpt/beacon/` +- `web_tests/external/wpt/fetch/` +- `web_tests/external/wpt/xhr/` + + +To manually run the virtual test suites, use the following command: + +To run all tests: + +```bash +third_party/blink/tools/run_web_tests.py -t Default virtual/keepalive-in-browser-migration +``` + +To run a single test: + +```bash +third_party/blink/tools/run_web_tests.py -t Default virtual/keepalive-in-browser-migration/external/wpt/fetch/api/basic/keepalive.html +```
diff --git a/third_party/blink/web_tests/virtual/keepalive-in-browser-migration/external/wpt/fetch/api/basic/keepalive.any-expected.txt b/third_party/blink/web_tests/virtual/keepalive-in-browser-migration/external/wpt/fetch/api/basic/keepalive.any-expected.txt new file mode 100644 index 0000000..40ded2f --- /dev/null +++ b/third_party/blink/web_tests/virtual/keepalive-in-browser-migration/external/wpt/fetch/api/basic/keepalive.any-expected.txt
@@ -0,0 +1,9 @@ +This is a testharness.js-based test. +PASS simple GET request: no payload; setting up +PASS simple POST request: no payload; setting up +PASS keepalive in onunload in nested frame in another window; setting up +PASS simple GET request: no payload +PASS simple POST request: no payload +FAIL keepalive in onunload in nested frame in another window assert_unreached: Error: assert_equals: expected (string) "on" but got (object) null Reached unreachable code +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/virtual/keepalive-in-browser-migration/external/wpt/fetch/api/redirect/redirect-keepalive.any-expected.txt b/third_party/blink/web_tests/virtual/keepalive-in-browser-migration/external/wpt/fetch/api/redirect/redirect-keepalive.any-expected.txt new file mode 100644 index 0000000..d6569524 --- /dev/null +++ b/third_party/blink/web_tests/virtual/keepalive-in-browser-migration/external/wpt/fetch/api/redirect/redirect-keepalive.any-expected.txt
@@ -0,0 +1,9 @@ +This is a testharness.js-based test. +PASS same-origin redirect; setting up +PASS cross-origin redirect; setting up +PASS cross-origin redirect with preflight; setting up +FAIL same-origin redirect assert_unreached: Error: assert_equals: expected (string) "on" but got (object) null Reached unreachable code +FAIL cross-origin redirect assert_unreached: Error: assert_equals: expected (string) "on" but got (object) null Reached unreachable code +FAIL cross-origin redirect with preflight assert_unreached: Error: assert_equals: expected (string) "on" but got (object) null Reached unreachable code +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/wpt_internal/css/css-nesting/ident/implicit-nesting-ident-recovery.html b/third_party/blink/web_tests/wpt_internal/css/css-nesting/ident/implicit-nesting-ident-recovery.html new file mode 100644 index 0000000..e940ddb --- /dev/null +++ b/third_party/blink/web_tests/wpt_internal/css/css-nesting/ident/implicit-nesting-ident-recovery.html
@@ -0,0 +1,29 @@ +<!DOCTYPE html> +<title>Nesting, error recovery</title> +<link rel="help" href="https://drafts.csswg.org/css-nesting-1/"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> + #target1 { + display:block; + display:new-block; + color:green; + } + #target2 { + display:block; + display:hover {}; + color:green; + } +</style> +<div id=target1>Green</div> +<div id=target2>Green</div> +<script> + test(() => { + assert_equals(getComputedStyle(target1).color, 'rgb(0, 128, 0)'); + }, 'Unknown declaration does not consume subsequent declaration'); +</script> +<script> + test(() => { + assert_equals(getComputedStyle(target2).color, 'rgb(0, 128, 0)'); + }, 'Unknown declaration with blocks does not consume subsequent declaration'); +</script>
diff --git a/third_party/blink/web_tests/wpt_internal/css/css-nesting/ident/implicit-nesting-ident.html b/third_party/blink/web_tests/wpt_internal/css/css-nesting/ident/implicit-nesting-ident.html new file mode 100644 index 0000000..342ec18 --- /dev/null +++ b/third_party/blink/web_tests/wpt_internal/css/css-nesting/ident/implicit-nesting-ident.html
@@ -0,0 +1,22 @@ +<!DOCTYPE html> +<title>Implicit nesting (ident)</title> +<link rel="help" href="https://drafts.csswg.org/css-nesting-1/"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> + #main { + div { + color: green; + } + } +</style> +<div id=main> + <div id=target> + Green + </div> +</main> +<script> + test(() => { + assert_equals(getComputedStyle(target).color, 'rgb(0, 128, 0)'); + }, 'Nested rule starting with tag'); +</script>
diff --git a/third_party/blink/web_tests/wpt_internal/streams/transform-streams/invalid-realm.window.js b/third_party/blink/web_tests/wpt_internal/streams/transform-streams/invalid-realm.window.js new file mode 100644 index 0000000..bce21c9 --- /dev/null +++ b/third_party/blink/web_tests/wpt_internal/streams/transform-streams/invalid-realm.window.js
@@ -0,0 +1,29 @@ +// Blink requires entering a ScriptState::Scope in order to enqueue a value in a +// stream, because of use of the incumbent context in v8::Object::New() and the +// incumbent isolate in v8::Exception::TypeError(). The standard doesn't have +// this requirement, so we test Blink's behavior here and the standard behaviour +// in the external wpt tests. + +// See https://crbug.com/1395588. + +// Adds an iframe to the document and returns it. +function addIframe() { + const iframe = document.createElement('iframe'); + document.body.appendChild(iframe); + return iframe; +} + +promise_test(async t => { + const iframe = addIframe(); + const stream = new iframe.contentWindow.TransformStream(); + const NestedTypeError = iframe.contentWindow.TypeError; + const readPromise = stream.readable.getReader().read(); + const writer = stream.writable.getWriter(); + iframe.remove(); + return Promise.all([ + promise_rejects_js(t, NestedTypeError, writer.write('A'), + 'TypeError should be thrown'), + promise_rejects_js(t, NestedTypeError, readPromise, + 'TypeError should be thrown'), + ]); +}, 'TransformStream: write in detached realm should fail');
diff --git a/third_party/cros-components/BUILD.gn b/third_party/cros-components/BUILD.gn index d53f0e6..926f830 100644 --- a/third_party/cros-components/BUILD.gn +++ b/third_party/cros-components/BUILD.gn
@@ -4,12 +4,14 @@ import("//ash/webui/tools/mwc_path_mappings.gni") import("//build/config/chromeos/ui_mode.gni") +import("//third_party/material_web_components/rewrite_imports.gni") import("//tools/typescript/ts_library.gni") import("//ui/webui/resources/tools/generate_grd.gni") ts_library("cros_components_ts") { root_dir = "src/" - out_dir = "$root_gen_dir/ui/webui/resources/tsc/cros_components" + out_dir = + "$root_gen_dir/ui/webui/resources/tsc/cros_components/to_be_rewritten" in_files = [ "button/button.ts" ] @@ -23,15 +25,30 @@ deps = [ "//third_party/material_web_components:library" ] } +rewrite_imports("cros_components_rewrite") { + base_dir = + "$root_gen_dir/ui/webui/resources/tsc/cros_components/to_be_rewritten" + out_dir = "$root_gen_dir/ui/webui/resources/tsc/cros_components/rewritten" + + in_files = [ "button/button.js" ] + + import_mappings = [ + "lit|//resources/mwc/lit/index.js", + "@material/|chrome://resources/mwc/@material/", + ] + + deps = [ ":cros_components_ts" ] +} + generate_grd("cros_components_grdp") { grd_prefix = "cros_components" out_grd = "${target_gen_dir}/resources.grdp" - deps = [] manifest_files = [] - deps += [ ":cros_components_ts" ] - manifest_files += filter_include(get_target_outputs(":cros_components_ts"), - [ "*.manifest" ]) + deps = [ ":cros_components_rewrite" ] + manifest_files += + filter_include(get_target_outputs(":cros_components_rewrite"), + [ "*.manifest" ]) resource_path_prefix = "cros_components" }
diff --git a/third_party/material_web_components/BUILD.gn b/third_party/material_web_components/BUILD.gn index 17f5d89..16641d5c 100644 --- a/third_party/material_web_components/BUILD.gn +++ b/third_party/material_web_components/BUILD.gn
@@ -3,6 +3,7 @@ # found in the LICENSE file. import("//third_party/closure_compiler/compile_js.gni") +import("//third_party/material_web_components/rewrite_imports.gni") import("//tools/typescript/ts_library.gni") import("//ui/webui/resources/tools/generate_grd.gni") import("//ui/webui/resources/tools/optimize_webui.gni") @@ -13,10 +14,264 @@ # files into the same path. chrome_resources_dir = "${root_gen_dir}/ui/webui/resources/tsc/mwc" +material_files = [ + "@material/web/dialog/lib/dialog-styles.css.js", + "@material/web/dialog/lib/dialog.js", + "@material/web/dialog/dialog.js", + "@material/web/icon/lib/icon.js", + "@material/web/icon/lib/icon-styles.css.js", + "@material/web/icon/icon.js", + "@material/web/badge/badge.js", + "@material/web/badge/lib/badge.js", + "@material/web/badge/lib/badge-styles.css.js", + "@material/web/list/list-item-avatar.js", + "@material/web/list/list.js", + "@material/web/list/lib/icon/list-item-icon.js", + "@material/web/list/lib/icon/list-item-icon-styles.css.js", + "@material/web/list/lib/avatar/list-item-avatar.js", + "@material/web/list/lib/avatar/list-item-avatar-styles.css.js", + "@material/web/list/lib/list.js", + "@material/web/list/lib/image/list-item-image.js", + "@material/web/list/lib/image/list-item-image-styles.css.js", + "@material/web/list/lib/listitemlink/list-item-link.js", + "@material/web/list/lib/video/list-item-video-styles.css.js", + "@material/web/list/lib/video/list-item-video.js", + "@material/web/list/lib/listitem/list-item-private-styles.css.js", + "@material/web/list/lib/listitem/list-item-styles.css.js", + "@material/web/list/lib/listitem/list-item.js", + "@material/web/list/lib/list-styles.css.js", + "@material/web/list/list-item-video.js", + "@material/web/list/list-item-link.js", + "@material/web/list/list-item-icon.js", + "@material/web/list/list-item-image.js", + "@material/web/list/list-item.js", + "@material/web/segmentedbuttonset/lib/outlined-styles.css.js", + "@material/web/segmentedbuttonset/lib/segmented-button-set.js", + "@material/web/segmentedbuttonset/lib/outlined-segmented-button-set.js", + "@material/web/segmentedbuttonset/lib/shared-styles.css.js", + "@material/web/segmentedbuttonset/outlined-segmented-button-set.js", + "@material/web/motion/animation.js", + "@material/web/ripple/lib/ripple-styles.css.js", + "@material/web/ripple/lib/ripple.js", + "@material/web/ripple/directive.js", + "@material/web/ripple/ripple.js", + "@material/web/divider/lib/divider-styles.css.js", + "@material/web/divider/lib/divider.js", + "@material/web/divider/divider.js", + "@material/web/menu/menu.js", + "@material/web/menu/lib/menu.js", + "@material/web/menu/lib/menu-styles.css.js", + "@material/web/menu/lib/menuitem/menu-item-private-styles.css.js", + "@material/web/menu/lib/menuitem/menu-item.js", + "@material/web/menu/lib/menuitem/menu-item-styles.css.js", + "@material/web/menu/lib/shared.js", + "@material/web/menu/lib/typeaheadController.js", + "@material/web/menu/lib/submenuitem/sub-menu-item.js", + "@material/web/menu/lib/menuitemlink/menu-item-link.js", + "@material/web/menu/lib/types.js", + "@material/web/menu/lib/surfacePositionController.js", + "@material/web/menu/menu-item-link.js", + "@material/web/menu/menu-item.js", + "@material/web/menu/sub-menu-item.js", + "@material/web/chips/action/link-action.js", + "@material/web/chips/action/lib/link-action.js", + "@material/web/chips/action/lib/presentational-action.js", + "@material/web/chips/action/lib/events.js", + "@material/web/chips/action/lib/delete-action.js", + "@material/web/chips/action/lib/primary-action.js", + "@material/web/chips/action/lib/selectable-action.js", + "@material/web/chips/action/lib/action.js", + "@material/web/chips/action/lib/types.js", + "@material/web/chips/action/lib/constants.js", + "@material/web/chips/action/presentational-action.js", + "@material/web/chips/action/delete-action.js", + "@material/web/chips/action/primary-action.js", + "@material/web/chips/action/selectable-action.js", + "@material/web/chips/chipset/lib/foundation.js", + "@material/web/chips/chipset/lib/adapter.js", + "@material/web/chips/chipset/lib/types.js", + "@material/web/chips/chipset/lib/constants.js", + "@material/web/chips/chip/lib/selectable-chip.js", + "@material/web/chips/chip/lib/link-chip.js", + "@material/web/chips/chip/lib/action-chip.js", + "@material/web/chips/chip/lib/chip.js", + "@material/web/chips/chip/lib/foundation.js", + "@material/web/chips/chip/lib/adapter.js", + "@material/web/chips/chip/lib/types.js", + "@material/web/chips/chip/lib/animationframe.js", + "@material/web/chips/chip/lib/presentational-chip.js", + "@material/web/chips/chip/lib/constants.js", + "@material/web/segmentedbutton/lib/outlined-styles.css.js", + "@material/web/segmentedbutton/lib/shared-styles.css.js", + "@material/web/segmentedbutton/lib/segmented-button.js", + "@material/web/segmentedbutton/lib/outlined-segmented-button.js", + "@material/web/segmentedbutton/outlined-segmented-button.js", + "@material/web/button/tonal-link-button.js", + "@material/web/button/elevated-link-button.js", + "@material/web/button/lib/button.js", + "@material/web/button/lib/tonal-link-button.js", + "@material/web/button/lib/outlined-styles.css.js", + "@material/web/button/lib/elevated-link-button.js", + "@material/web/button/lib/elevated-styles.css.js", + "@material/web/button/lib/tonal-styles.css.js", + "@material/web/button/lib/link-button.js", + "@material/web/button/lib/filled-styles.css.js", + "@material/web/button/lib/text-link-button.js", + "@material/web/button/lib/tonal-button.js", + "@material/web/button/lib/filled-button.js", + "@material/web/button/lib/state.js", + "@material/web/button/lib/filled-link-button.js", + "@material/web/button/lib/elevated-button.js", + "@material/web/button/lib/shared-styles.css.js", + "@material/web/button/lib/outlined-button.js", + "@material/web/button/lib/outlined-link-button.js", + "@material/web/button/lib/shared-elevation-styles.css.js", + "@material/web/button/lib/text-styles.css.js", + "@material/web/button/lib/text-button.js", + "@material/web/button/text-link-button.js", + "@material/web/button/tonal-button.js", + "@material/web/button/filled-button.js", + "@material/web/button/filled-link-button.js", + "@material/web/button/elevated-button.js", + "@material/web/button/outlined-button.js", + "@material/web/button/outlined-link-button.js", + "@material/web/button/text-button.js", + "@material/web/menusurface/lib/menu-surface.js", + "@material/web/menusurface/lib/foundation.js", + "@material/web/menusurface/lib/menu-surface-styles.css.js", + "@material/web/menusurface/lib/adapter.js", + "@material/web/menusurface/lib/types.js", + "@material/web/menusurface/lib/constants.js", + "@material/web/menusurface/menu-surface.js", + "@material/web/tokens/v0_152/index.test.css.js", + "@material/web/tokens/v0_152/lib.test.css.js", + "@material/web/localization/localize.js", + "@material/web/focus/strong-focus.js", + "@material/web/focus/lib/focus-ring-styles.css.js", + "@material/web/focus/lib/focus-ring.js", + "@material/web/focus/focus-ring.js", + "@material/web/controller/events.js", + "@material/web/controller/action-controller.js", + "@material/web/controller/observer.js", + "@material/web/controller/observer-foundation.js", + "@material/web/controller/foundation.js", + "@material/web/controller/form-associated.js", + "@material/web/controller/form-controller.js", + "@material/web/controller/string-converter.js", + "@material/web/controller/is-rtl.js", + "@material/web/controller/shim-label-activation.js", + "@material/web/switch/lib/switch-styles.css.js", + "@material/web/switch/lib/switch.js", + "@material/web/switch/switch.js", + "@material/web/textfield/lib/outlined-styles.css.js", + "@material/web/textfield/lib/outlined-text-field.js", + "@material/web/textfield/lib/filled-styles.css.js", + "@material/web/textfield/lib/outlined-forced-colors-styles.css.js", + "@material/web/textfield/lib/shared-styles.css.js", + "@material/web/textfield/lib/filled-text-field.js", + "@material/web/textfield/lib/filled-forced-colors-styles.css.js", + "@material/web/textfield/lib/text-field.js", + "@material/web/textfield/outlined-text-field.js", + "@material/web/textfield/filled-text-field.js", + "@material/web/decorators/aria-property.js", + "@material/web/decorators/bound.js", + "@material/web/navigationdrawer/navigation-drawer.js", + "@material/web/navigationdrawer/lib/navigation-drawer.js", + "@material/web/navigationdrawer/lib/navigation-drawer-styles.css.js", + "@material/web/navigationdrawer/lib/navigation-drawer-modal.js", + "@material/web/navigationdrawer/lib/navigation-drawer-modal-styles.css.js", + "@material/web/navigationdrawer/lib/shared-styles.css.js", + "@material/web/navigationdrawer/navigation-drawer-modal.js", + "@material/web/fab/lib/fab-shared-styles.css.js", + "@material/web/fab/lib/fab-extended.js", + "@material/web/fab/lib/fab-extended-styles.css.js", + "@material/web/fab/lib/fab.js", + "@material/web/fab/lib/fab-shared.js", + "@material/web/fab/lib/fab-styles.css.js", + "@material/web/fab/fab-extended.js", + "@material/web/fab/fab.js", + "@material/web/elevation/lib/elevation-styles.css.js", + "@material/web/elevation/lib/elevation.js", + "@material/web/elevation/elevation.js", + "@material/web/checkbox/checkbox.js", + "@material/web/checkbox/lib/checkbox.js", + "@material/web/checkbox/lib/forced-colors-styles.css.js", + "@material/web/checkbox/lib/checkbox-styles.css.js", + "@material/web/field/outlined-field.js", + "@material/web/field/lib/outlined-styles.css.js", + "@material/web/field/lib/outlined-field.js", + "@material/web/field/lib/filled-field.js", + "@material/web/field/lib/filled-styles.css.js", + "@material/web/field/lib/field.js", + "@material/web/field/lib/shared-styles.css.js", + "@material/web/field/filled-field.js", + "@material/web/iconbutton/outlined-icon-button-toggle.js", + "@material/web/iconbutton/lib/outlined-styles.css.js", + "@material/web/iconbutton/lib/icon-button.js", + "@material/web/iconbutton/lib/filled-styles.css.js", + "@material/web/iconbutton/lib/link-icon-button.js", + "@material/web/iconbutton/lib/standard-styles.css.js", + "@material/web/iconbutton/lib/icon-button-toggle.js", + "@material/web/iconbutton/lib/shared-styles.css.js", + "@material/web/iconbutton/lib/filled-tonal-styles.css.js", + "@material/web/iconbutton/filled-link-icon-button.js", + "@material/web/iconbutton/outlined-link-icon-button.js", + "@material/web/iconbutton/standard-icon-button-toggle.js", + "@material/web/iconbutton/standard-link-icon-button.js", + "@material/web/iconbutton/filled-icon-button.js", + "@material/web/iconbutton/filled-tonal-icon-button-toggle.js", + "@material/web/iconbutton/filled-tonal-link-icon-button.js", + "@material/web/iconbutton/filled-icon-button-toggle.js", + "@material/web/iconbutton/outlined-icon-button.js", + "@material/web/iconbutton/standard-icon-button.js", + "@material/web/iconbutton/filled-tonal-icon-button.js", + "@material/web/autocomplete/outlined-autocomplete.js", + "@material/web/autocomplete/lib/autocompletesurface/autocomplete-surface-styles.css.js", + "@material/web/autocomplete/lib/autocompletesurface/autocomplete-surface.js", + "@material/web/autocomplete/lib/outlined-styles.css.js", + "@material/web/autocomplete/lib/autocompleteitem/autocomplete-item.js", + "@material/web/autocomplete/lib/autocompletelist/autocomplete-list.js", + "@material/web/autocomplete/lib/autocompletelist/autocomplete-list-styles.css.js", + "@material/web/autocomplete/lib/filled-styles.css.js", + "@material/web/autocomplete/lib/autocomplete.js", + "@material/web/autocomplete/lib/shared-styles.css.js", + "@material/web/autocomplete/autocomplete-list.js", + "@material/web/autocomplete/autocomplete-surface.js", + "@material/web/autocomplete/autocomplete-item.js", + "@material/web/autocomplete/filled-autocomplete.js", + "@material/web/navigationbar/lib/navigation-bar-styles.css.js", + "@material/web/navigationbar/lib/navigation-bar.js", + "@material/web/navigationbar/lib/state.js", + "@material/web/navigationbar/lib/constants.js", + "@material/web/navigationbar/navigation-bar.js", + "@material/web/actionelement/action-element.js", + "@material/web/navigationtab/lib/navigation-tab-styles.css.js", + "@material/web/navigationtab/lib/state.js", + "@material/web/navigationtab/lib/navigation-tab.js", + "@material/web/navigationtab/navigation-tab.js", + "@material/web/radio/lib/forced-colors-styles.css.js", + "@material/web/radio/lib/single-selection-controller.js", + "@material/web/radio/lib/radio.js", + "@material/web/radio/lib/radio-styles.css.js", + "@material/web/radio/radio.js", +] + js_library("bundle_lit_js") { sources = [ "lit_exports.js" ] } +rewrite_imports("mwc_rewrite") { + base_dir = + "//third_party/material_web_components/components-chromium/node_modules" + out_dir = chrome_resources_dir + + import_mappings = [ "lit|//resources/mwc/lit/index.js" ] + + in_files = material_files + + deps = [ ":library" ] +} + # Compile lit_exports.js into a singular bundle we can host on # chrome://resources. optimize_webui("bundle_lit") { @@ -56,253 +311,14 @@ } generate_grd("build_mwc_grdp") { - resource_path_prefix = "mwc" grd_prefix = "material_components" out_grd = "$target_gen_dir/mwc_resources.grdp" + input_files_base_dir = rebase_path(chrome_resources_dir, root_build_dir) + resource_path_prefix = "mwc" - input_files_base_dir = rebase_path("components-chromium/node_modules", "//") + input_files = material_files - input_files = [ - "@material/web/dialog/lib/dialog-styles.css.js", - "@material/web/dialog/lib/dialog.js", - "@material/web/dialog/dialog.js", - "@material/web/icon/lib/icon.js", - "@material/web/icon/lib/icon-styles.css.js", - "@material/web/icon/icon.js", - "@material/web/badge/badge.js", - "@material/web/badge/lib/badge.js", - "@material/web/badge/lib/badge-styles.css.js", - "@material/web/list/list-item-avatar.js", - "@material/web/list/list.js", - "@material/web/list/lib/icon/list-item-icon.js", - "@material/web/list/lib/icon/list-item-icon-styles.css.js", - "@material/web/list/lib/avatar/list-item-avatar.js", - "@material/web/list/lib/avatar/list-item-avatar-styles.css.js", - "@material/web/list/lib/list.js", - "@material/web/list/lib/image/list-item-image.js", - "@material/web/list/lib/image/list-item-image-styles.css.js", - "@material/web/list/lib/listitemlink/list-item-link.js", - "@material/web/list/lib/video/list-item-video-styles.css.js", - "@material/web/list/lib/video/list-item-video.js", - "@material/web/list/lib/listitem/list-item-private-styles.css.js", - "@material/web/list/lib/listitem/list-item-styles.css.js", - "@material/web/list/lib/listitem/list-item.js", - "@material/web/list/lib/list-styles.css.js", - "@material/web/list/list-item-video.js", - "@material/web/list/list-item-link.js", - "@material/web/list/list-item-icon.js", - "@material/web/list/list-item-image.js", - "@material/web/list/list-item.js", - "@material/web/segmentedbuttonset/lib/outlined-styles.css.js", - "@material/web/segmentedbuttonset/lib/segmented-button-set.js", - "@material/web/segmentedbuttonset/lib/outlined-segmented-button-set.js", - "@material/web/segmentedbuttonset/lib/shared-styles.css.js", - "@material/web/segmentedbuttonset/outlined-segmented-button-set.js", - "@material/web/motion/animation.js", - "@material/web/ripple/lib/ripple-styles.css.js", - "@material/web/ripple/lib/ripple.js", - "@material/web/ripple/directive.js", - "@material/web/ripple/ripple.js", - "@material/web/divider/lib/divider-styles.css.js", - "@material/web/divider/lib/divider.js", - "@material/web/divider/divider.js", - "@material/web/menu/menu.js", - "@material/web/menu/lib/menu.js", - "@material/web/menu/lib/menu-styles.css.js", - "@material/web/menu/lib/menuitem/menu-item-private-styles.css.js", - "@material/web/menu/lib/menuitem/menu-item.js", - "@material/web/menu/lib/menuitem/menu-item-styles.css.js", - "@material/web/menu/lib/shared.js", - "@material/web/menu/lib/typeaheadController.js", - "@material/web/menu/lib/submenuitem/sub-menu-item.js", - "@material/web/menu/lib/menuitemlink/menu-item-link.js", - "@material/web/menu/lib/types.js", - "@material/web/menu/lib/surfacePositionController.js", - "@material/web/menu/menu-item-link.js", - "@material/web/menu/menu-item.js", - "@material/web/menu/sub-menu-item.js", - "@material/web/chips/action/link-action.js", - "@material/web/chips/action/lib/link-action.js", - "@material/web/chips/action/lib/presentational-action.js", - "@material/web/chips/action/lib/events.js", - "@material/web/chips/action/lib/delete-action.js", - "@material/web/chips/action/lib/primary-action.js", - "@material/web/chips/action/lib/selectable-action.js", - "@material/web/chips/action/lib/action.js", - "@material/web/chips/action/lib/types.js", - "@material/web/chips/action/lib/constants.js", - "@material/web/chips/action/presentational-action.js", - "@material/web/chips/action/delete-action.js", - "@material/web/chips/action/primary-action.js", - "@material/web/chips/action/selectable-action.js", - "@material/web/chips/chipset/lib/foundation.js", - "@material/web/chips/chipset/lib/adapter.js", - "@material/web/chips/chipset/lib/types.js", - "@material/web/chips/chipset/lib/constants.js", - "@material/web/chips/chip/lib/selectable-chip.js", - "@material/web/chips/chip/lib/link-chip.js", - "@material/web/chips/chip/lib/action-chip.js", - "@material/web/chips/chip/lib/chip.js", - "@material/web/chips/chip/lib/foundation.js", - "@material/web/chips/chip/lib/adapter.js", - "@material/web/chips/chip/lib/types.js", - "@material/web/chips/chip/lib/animationframe.js", - "@material/web/chips/chip/lib/presentational-chip.js", - "@material/web/chips/chip/lib/constants.js", - "@material/web/segmentedbutton/lib/outlined-styles.css.js", - "@material/web/segmentedbutton/lib/shared-styles.css.js", - "@material/web/segmentedbutton/lib/segmented-button.js", - "@material/web/segmentedbutton/lib/outlined-segmented-button.js", - "@material/web/segmentedbutton/outlined-segmented-button.js", - "@material/web/button/tonal-link-button.js", - "@material/web/button/elevated-link-button.js", - "@material/web/button/lib/button.js", - "@material/web/button/lib/tonal-link-button.js", - "@material/web/button/lib/outlined-styles.css.js", - "@material/web/button/lib/elevated-link-button.js", - "@material/web/button/lib/elevated-styles.css.js", - "@material/web/button/lib/tonal-styles.css.js", - "@material/web/button/lib/link-button.js", - "@material/web/button/lib/filled-styles.css.js", - "@material/web/button/lib/text-link-button.js", - "@material/web/button/lib/tonal-button.js", - "@material/web/button/lib/filled-button.js", - "@material/web/button/lib/state.js", - "@material/web/button/lib/filled-link-button.js", - "@material/web/button/lib/elevated-button.js", - "@material/web/button/lib/shared-styles.css.js", - "@material/web/button/lib/outlined-button.js", - "@material/web/button/lib/outlined-link-button.js", - "@material/web/button/lib/shared-elevation-styles.css.js", - "@material/web/button/lib/text-styles.css.js", - "@material/web/button/lib/text-button.js", - "@material/web/button/text-link-button.js", - "@material/web/button/tonal-button.js", - "@material/web/button/filled-button.js", - "@material/web/button/filled-link-button.js", - "@material/web/button/elevated-button.js", - "@material/web/button/outlined-button.js", - "@material/web/button/outlined-link-button.js", - "@material/web/button/text-button.js", - "@material/web/menusurface/lib/menu-surface.js", - "@material/web/menusurface/lib/foundation.js", - "@material/web/menusurface/lib/menu-surface-styles.css.js", - "@material/web/menusurface/lib/adapter.js", - "@material/web/menusurface/lib/types.js", - "@material/web/menusurface/lib/constants.js", - "@material/web/menusurface/menu-surface.js", - "@material/web/tokens/v0_152/index.test.css.js", - "@material/web/tokens/v0_152/lib.test.css.js", - "@material/web/localization/localize.js", - "@material/web/focus/strong-focus.js", - "@material/web/focus/lib/focus-ring-styles.css.js", - "@material/web/focus/lib/focus-ring.js", - "@material/web/focus/focus-ring.js", - "@material/web/controller/events.js", - "@material/web/controller/action-controller.js", - "@material/web/controller/observer.js", - "@material/web/controller/observer-foundation.js", - "@material/web/controller/foundation.js", - "@material/web/controller/form-associated.js", - "@material/web/controller/form-controller.js", - "@material/web/controller/string-converter.js", - "@material/web/controller/is-rtl.js", - "@material/web/controller/shim-label-activation.js", - "@material/web/switch/lib/switch-styles.css.js", - "@material/web/switch/lib/switch.js", - "@material/web/switch/switch.js", - "@material/web/textfield/lib/outlined-styles.css.js", - "@material/web/textfield/lib/outlined-text-field.js", - "@material/web/textfield/lib/filled-styles.css.js", - "@material/web/textfield/lib/outlined-forced-colors-styles.css.js", - "@material/web/textfield/lib/shared-styles.css.js", - "@material/web/textfield/lib/filled-text-field.js", - "@material/web/textfield/lib/filled-forced-colors-styles.css.js", - "@material/web/textfield/lib/text-field.js", - "@material/web/textfield/outlined-text-field.js", - "@material/web/textfield/filled-text-field.js", - "@material/web/decorators/aria-property.js", - "@material/web/decorators/bound.js", - "@material/web/navigationdrawer/navigation-drawer.js", - "@material/web/navigationdrawer/lib/navigation-drawer.js", - "@material/web/navigationdrawer/lib/navigation-drawer-styles.css.js", - "@material/web/navigationdrawer/lib/navigation-drawer-modal.js", - "@material/web/navigationdrawer/lib/navigation-drawer-modal-styles.css.js", - "@material/web/navigationdrawer/lib/shared-styles.css.js", - "@material/web/navigationdrawer/navigation-drawer-modal.js", - "@material/web/fab/lib/fab-shared-styles.css.js", - "@material/web/fab/lib/fab-extended.js", - "@material/web/fab/lib/fab-extended-styles.css.js", - "@material/web/fab/lib/fab.js", - "@material/web/fab/lib/fab-shared.js", - "@material/web/fab/lib/fab-styles.css.js", - "@material/web/fab/fab-extended.js", - "@material/web/fab/fab.js", - "@material/web/elevation/lib/elevation-styles.css.js", - "@material/web/elevation/lib/elevation.js", - "@material/web/elevation/elevation.js", - "@material/web/checkbox/checkbox.js", - "@material/web/checkbox/lib/checkbox.js", - "@material/web/checkbox/lib/forced-colors-styles.css.js", - "@material/web/checkbox/lib/checkbox-styles.css.js", - "@material/web/field/outlined-field.js", - "@material/web/field/lib/outlined-styles.css.js", - "@material/web/field/lib/outlined-field.js", - "@material/web/field/lib/filled-field.js", - "@material/web/field/lib/filled-styles.css.js", - "@material/web/field/lib/field.js", - "@material/web/field/lib/shared-styles.css.js", - "@material/web/field/filled-field.js", - "@material/web/iconbutton/outlined-icon-button-toggle.js", - "@material/web/iconbutton/lib/outlined-styles.css.js", - "@material/web/iconbutton/lib/icon-button.js", - "@material/web/iconbutton/lib/filled-styles.css.js", - "@material/web/iconbutton/lib/link-icon-button.js", - "@material/web/iconbutton/lib/standard-styles.css.js", - "@material/web/iconbutton/lib/icon-button-toggle.js", - "@material/web/iconbutton/lib/shared-styles.css.js", - "@material/web/iconbutton/lib/filled-tonal-styles.css.js", - "@material/web/iconbutton/filled-link-icon-button.js", - "@material/web/iconbutton/outlined-link-icon-button.js", - "@material/web/iconbutton/standard-icon-button-toggle.js", - "@material/web/iconbutton/standard-link-icon-button.js", - "@material/web/iconbutton/filled-icon-button.js", - "@material/web/iconbutton/filled-tonal-icon-button-toggle.js", - "@material/web/iconbutton/filled-tonal-link-icon-button.js", - "@material/web/iconbutton/filled-icon-button-toggle.js", - "@material/web/iconbutton/outlined-icon-button.js", - "@material/web/iconbutton/standard-icon-button.js", - "@material/web/iconbutton/filled-tonal-icon-button.js", - "@material/web/autocomplete/outlined-autocomplete.js", - "@material/web/autocomplete/lib/autocompletesurface/autocomplete-surface-styles.css.js", - "@material/web/autocomplete/lib/autocompletesurface/autocomplete-surface.js", - "@material/web/autocomplete/lib/outlined-styles.css.js", - "@material/web/autocomplete/lib/autocompleteitem/autocomplete-item.js", - "@material/web/autocomplete/lib/autocompletelist/autocomplete-list.js", - "@material/web/autocomplete/lib/autocompletelist/autocomplete-list-styles.css.js", - "@material/web/autocomplete/lib/filled-styles.css.js", - "@material/web/autocomplete/lib/autocomplete.js", - "@material/web/autocomplete/lib/shared-styles.css.js", - "@material/web/autocomplete/autocomplete-list.js", - "@material/web/autocomplete/autocomplete-surface.js", - "@material/web/autocomplete/autocomplete-item.js", - "@material/web/autocomplete/filled-autocomplete.js", - "@material/web/navigationbar/lib/navigation-bar-styles.css.js", - "@material/web/navigationbar/lib/navigation-bar.js", - "@material/web/navigationbar/lib/state.js", - "@material/web/navigationbar/lib/constants.js", - "@material/web/navigationbar/navigation-bar.js", - "@material/web/actionelement/action-element.js", - "@material/web/navigationtab/lib/navigation-tab-styles.css.js", - "@material/web/navigationtab/lib/state.js", - "@material/web/navigationtab/lib/navigation-tab.js", - "@material/web/navigationtab/navigation-tab.js", - "@material/web/radio/lib/forced-colors-styles.css.js", - "@material/web/radio/lib/single-selection-controller.js", - "@material/web/radio/lib/radio.js", - "@material/web/radio/lib/radio-styles.css.js", - "@material/web/radio/radio.js", - ] + deps = [ ":mwc_rewrite" ] } ts_library("library") {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/actionelement/action-element.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/actionelement/action-element.js index 409d8103..380a204f 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/actionelement/action-element.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/actionelement/action-element.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { LitElement } from '../../../lit/index.js'; +import { LitElement } from 'lit'; import { ActionController } from '../controller/action-controller.js'; /** * @soyCompatible
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/autocomplete-item.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/autocomplete-item.js index 9e90f95..1779db6 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/autocomplete-item.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/autocomplete-item.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles } from '../list/lib/listitem/list-item-styles.css.js'; import { AutocompleteItem } from './lib/autocompleteitem/autocomplete-item.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/autocomplete-list.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/autocomplete-list.js index 8ca48f6..28be4756 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/autocomplete-list.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/autocomplete-list.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles } from '../list/lib/list-styles.css.js'; import { AutocompleteList } from './lib/autocompletelist/autocomplete-list.js'; import { styles as autocompleteStyles } from './lib/autocompletelist/autocomplete-list-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/autocomplete-surface.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/autocomplete-surface.js index dfc0661..772af57 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/autocomplete-surface.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/autocomplete-surface.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles } from '../menusurface/lib/menu-surface-styles.css.js'; import { AutocompleteSurface } from './lib/autocompletesurface/autocomplete-surface.js'; import { styles as autocompleteStyles } from './lib/autocompletesurface/autocomplete-surface-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/filled-autocomplete.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/filled-autocomplete.js index 65b1021a..b3fb37b 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/filled-autocomplete.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/filled-autocomplete.js
@@ -3,12 +3,12 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; +import { __decorate } from "tslib"; import '../field/filled-field.js'; import './autocomplete-list.js'; import './autocomplete-surface.js'; -import { customElement } from '../../../lit/decorators.js'; -import { literal } from '../../../lit/static-html.js'; +import { customElement } from 'lit/decorators.js'; +import { literal } from 'lit/static-html.js'; import { styles as filledForcedColorsStyles } from '../textfield/lib/filled-forced-colors-styles.css.js'; import { styles as filledStyles } from '../textfield/lib/filled-styles.css.js'; import { styles as sharedStyles } from '../textfield/lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/autocomplete.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/autocomplete.js index 342dc59..0a1d286 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/autocomplete.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/autocomplete.js
@@ -3,11 +3,11 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; -import { html } from '../../../../lit/index.js'; -import { property, query, queryAssignedElements, state } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { html as staticHtml } from '../../../../lit/static-html.js'; +import { __decorate, __metadata } from "tslib"; +import { html } from 'lit'; +import { property, query, queryAssignedElements, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { html as staticHtml } from 'lit/static-html.js'; import { TextField } from '../../textfield/lib/text-field.js'; import { AutocompleteItem } from './autocompleteitem/autocomplete-item.js'; import { AutocompleteList } from './autocompletelist/autocomplete-list.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/autocompletelist/autocomplete-list-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/autocompletelist/autocomplete-list-styles.css.js index 63055a7d..902dd3e 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/autocompletelist/autocomplete-list-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/autocompletelist/autocomplete-list-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `.md3-autocomplete-list{min-width:unset}/*# sourceMappingURL=autocomplete-list-styles.css.map */ `; //# sourceMappingURL=autocomplete-list-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/autocompletesurface/autocomplete-surface-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/autocompletesurface/autocomplete-surface-styles.css.js index 4d4312e..160ee90 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/autocompletesurface/autocomplete-surface-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/autocompletesurface/autocomplete-surface-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `.md3-autocomplete-surface{width:100%}/*# sourceMappingURL=autocomplete-surface-styles.css.map */ `; //# sourceMappingURL=autocomplete-surface-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/filled-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/filled-styles.css.js index 8c43d7ad..f8d441a 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/filled-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/filled-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_text-field-container-shape-start-start: var(--md-filled-autocomplete-text-field-container-shape-start-start, 4px);--_text-field-container-shape-start-end: var(--md-filled-autocomplete-text-field-container-shape-start-end, 4px);--_text-field-container-shape-end-end: var(--md-filled-autocomplete-text-field-container-shape-end-end, 0px);--_text-field-container-shape-end-start: var(--md-filled-autocomplete-text-field-container-shape-end-start, 0px);--_menu-cascading-menu-indicator-icon-color: var(--md-filled-autocomplete-menu-cascading-menu-indicator-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_menu-cascading-menu-indicator-icon-size: var(--md-filled-autocomplete-menu-cascading-menu-indicator-icon-size, 24px);--_menu-container-color: var(--md-filled-autocomplete-menu-container-color, var(--md-sys-color-surface, #fffbfe));--_menu-container-elevation: var(--md-filled-autocomplete-menu-container-elevation, 2);--_menu-container-shadow-color: var(--md-filled-autocomplete-menu-container-shadow-color, var(--md-sys-color-shadow, #000));--_menu-container-shape: var(--md-filled-autocomplete-menu-container-shape, 4px);--_menu-container-surface-tint-layer-color: var(--md-filled-autocomplete-menu-container-surface-tint-layer-color, var(--md-sys-color-primary, #6750a4));--_menu-divider-color: var(--md-filled-autocomplete-menu-divider-color, var(--md-sys-color-surface-variant, #e7e0ec));--_menu-divider-height: var(--md-filled-autocomplete-menu-divider-height, 1px);--_menu-list-item-container-height: var(--md-filled-autocomplete-menu-list-item-container-height, 48px);--_menu-list-item-label-text-color: var(--md-filled-autocomplete-menu-list-item-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_menu-list-item-label-text-font: var(--md-filled-autocomplete-menu-list-item-label-text-font, Roboto);--_menu-list-item-label-text-line-height: var(--md-filled-autocomplete-menu-list-item-label-text-line-height, 1.25rem);--_menu-list-item-label-text-size: var(--md-filled-autocomplete-menu-list-item-label-text-size, 0.875rem);--_menu-list-item-label-text-tracking: var(--md-filled-autocomplete-menu-list-item-label-text-tracking, 0.006rem);--_menu-list-item-label-text-type: var(--md-filled-autocomplete-menu-list-item-label-text-type, 500 0.875rem / 1.25rem Roboto);--_menu-list-item-label-text-weight: var(--md-filled-autocomplete-menu-list-item-label-text-weight, 500);--_menu-list-item-selected-container-color: var(--md-filled-autocomplete-menu-list-item-selected-container-color, var(--md-sys-color-surface-variant, #e7e0ec));--_text-field-active-indicator-color: var(--md-filled-autocomplete-text-field-active-indicator-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-active-indicator-height: var(--md-filled-autocomplete-text-field-active-indicator-height, 1px);--_text-field-caret-color: var(--md-filled-autocomplete-text-field-caret-color, var(--md-sys-color-primary, #6750a4));--_text-field-container-color: var(--md-filled-autocomplete-text-field-container-color, var(--md-sys-color-surface-variant, #e7e0ec));--_text-field-disabled-active-indicator-color: var(--md-filled-autocomplete-text-field-disabled-active-indicator-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-disabled-active-indicator-height: var(--md-filled-autocomplete-text-field-disabled-active-indicator-height, 1px);--_text-field-disabled-active-indicator-opacity: var(--md-filled-autocomplete-text-field-disabled-active-indicator-opacity, 0.38);--_text-field-disabled-container-color: var(--md-filled-autocomplete-text-field-disabled-container-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-disabled-container-opacity: var(--md-filled-autocomplete-text-field-disabled-container-opacity, 0.04);--_text-field-disabled-input-text-color: var(--md-filled-autocomplete-text-field-disabled-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-disabled-input-text-opacity: var(--md-filled-autocomplete-text-field-disabled-input-text-opacity, 0.38);--_text-field-disabled-label-text-color: var(--md-filled-autocomplete-text-field-disabled-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-disabled-label-text-opacity: var(--md-filled-autocomplete-text-field-disabled-label-text-opacity, 0.38);--_text-field-disabled-leading-icon-color: var(--md-filled-autocomplete-text-field-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-disabled-leading-icon-opacity: var(--md-filled-autocomplete-text-field-disabled-leading-icon-opacity, 0.38);--_text-field-disabled-supporting-text-color: var(--md-filled-autocomplete-text-field-disabled-supporting-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-disabled-supporting-text-opacity: var(--md-filled-autocomplete-text-field-disabled-supporting-text-opacity, 0.38);--_text-field-disabled-trailing-icon-color: var(--md-filled-autocomplete-text-field-disabled-trailing-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-disabled-trailing-icon-opacity: var(--md-filled-autocomplete-text-field-disabled-trailing-icon-opacity, 0.38);--_text-field-error-active-indicator-color: var(--md-filled-autocomplete-text-field-error-active-indicator-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-active-indicator-color: var(--md-filled-autocomplete-text-field-error-focus-active-indicator-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-caret-color: var(--md-filled-autocomplete-text-field-error-focus-caret-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-input-text-color: var(--md-filled-autocomplete-text-field-error-focus-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-error-focus-label-text-color: var(--md-filled-autocomplete-text-field-error-focus-label-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-leading-icon-color: var(--md-filled-autocomplete-text-field-error-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-error-focus-supporting-text-color: var(--md-filled-autocomplete-text-field-error-focus-supporting-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-trailing-icon-color: var(--md-filled-autocomplete-text-field-error-focus-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_text-field-error-hover-active-indicator-color: var(--md-filled-autocomplete-text-field-error-hover-active-indicator-color, var(--md-sys-color-on-error-container, #410e0b));--_text-field-error-hover-input-text-color: var(--md-filled-autocomplete-text-field-error-hover-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-error-hover-label-text-color: var(--md-filled-autocomplete-text-field-error-hover-label-text-color, var(--md-sys-color-on-error-container, #410e0b));--_text-field-error-hover-leading-icon-color: var(--md-filled-autocomplete-text-field-error-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-error-hover-state-layer-color: var(--md-filled-autocomplete-text-field-error-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-error-hover-state-layer-opacity: var(--md-filled-autocomplete-text-field-error-hover-state-layer-opacity, 0.08);--_text-field-error-hover-supporting-text-color: var(--md-filled-autocomplete-text-field-error-hover-supporting-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-hover-trailing-icon-color: var(--md-filled-autocomplete-text-field-error-hover-trailing-icon-color, var(--md-sys-color-on-error-container, #410e0b));--_text-field-error-input-text-color: var(--md-filled-autocomplete-text-field-error-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-error-label-text-color: var(--md-filled-autocomplete-text-field-error-label-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-leading-icon-color: var(--md-filled-autocomplete-text-field-error-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-error-supporting-text-color: var(--md-filled-autocomplete-text-field-error-supporting-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-trailing-icon-color: var(--md-filled-autocomplete-text-field-error-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_text-field-focus-active-indicator-color: var(--md-filled-autocomplete-text-field-focus-active-indicator-color, var(--md-sys-color-primary, #6750a4));--_text-field-focus-active-indicator-height: var(--md-filled-autocomplete-text-field-focus-active-indicator-height, 2px);--_text-field-focus-input-text-color: var(--md-filled-autocomplete-text-field-focus-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-focus-label-text-color: var(--md-filled-autocomplete-text-field-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_text-field-focus-leading-icon-color: var(--md-filled-autocomplete-text-field-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-focus-supporting-text-color: var(--md-filled-autocomplete-text-field-focus-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-focus-trailing-icon-color: var(--md-filled-autocomplete-text-field-focus-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-hover-active-indicator-color: var(--md-filled-autocomplete-text-field-hover-active-indicator-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-hover-active-indicator-height: var(--md-filled-autocomplete-text-field-hover-active-indicator-height, 1px);--_text-field-hover-input-text-color: var(--md-filled-autocomplete-text-field-hover-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-hover-label-text-color: var(--md-filled-autocomplete-text-field-hover-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-hover-leading-icon-color: var(--md-filled-autocomplete-text-field-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-hover-state-layer-color: var(--md-filled-autocomplete-text-field-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-hover-state-layer-opacity: var(--md-filled-autocomplete-text-field-hover-state-layer-opacity, 0.08);--_text-field-hover-supporting-text-color: var(--md-filled-autocomplete-text-field-hover-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-hover-trailing-icon-color: var(--md-filled-autocomplete-text-field-hover-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-input-text-color: var(--md-filled-autocomplete-text-field-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-input-text-font: var(--md-filled-autocomplete-text-field-input-text-font, Roboto);--_text-field-input-text-line-height: var(--md-filled-autocomplete-text-field-input-text-line-height, 1.5rem);--_text-field-input-text-size: var(--md-filled-autocomplete-text-field-input-text-size, 1rem);--_text-field-input-text-tracking: var(--md-filled-autocomplete-text-field-input-text-tracking, 0.031rem);--_text-field-input-text-type: var(--md-filled-autocomplete-text-field-input-text-type, 400 1rem / 1.5rem Roboto);--_text-field-input-text-weight: var(--md-filled-autocomplete-text-field-input-text-weight, 400);--_text-field-label-text-color: var(--md-filled-autocomplete-text-field-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-label-text-font: var(--md-filled-autocomplete-text-field-label-text-font, Roboto);--_text-field-label-text-line-height: var(--md-filled-autocomplete-text-field-label-text-line-height, 1.5rem);--_text-field-label-text-populated-line-height: var(--md-filled-autocomplete-text-field-label-text-populated-line-height, 1rem);--_text-field-label-text-populated-size: var(--md-filled-autocomplete-text-field-label-text-populated-size, 0.75rem);--_text-field-label-text-size: var(--md-filled-autocomplete-text-field-label-text-size, 1rem);--_text-field-label-text-tracking: var(--md-filled-autocomplete-text-field-label-text-tracking, 0.031rem);--_text-field-label-text-type: var(--md-filled-autocomplete-text-field-label-text-type, 400 1rem / 1.5rem Roboto);--_text-field-label-text-weight: var(--md-filled-autocomplete-text-field-label-text-weight, 400);--_text-field-leading-icon-color: var(--md-filled-autocomplete-text-field-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-leading-icon-size: var(--md-filled-autocomplete-text-field-leading-icon-size, 20px);--_text-field-supporting-text-color: var(--md-filled-autocomplete-text-field-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-supporting-text-font: var(--md-filled-autocomplete-text-field-supporting-text-font, Roboto);--_text-field-supporting-text-line-height: var(--md-filled-autocomplete-text-field-supporting-text-line-height, 1rem);--_text-field-supporting-text-size: var(--md-filled-autocomplete-text-field-supporting-text-size, 0.75rem);--_text-field-supporting-text-tracking: var(--md-filled-autocomplete-text-field-supporting-text-tracking, 0.025rem);--_text-field-supporting-text-type: var(--md-filled-autocomplete-text-field-supporting-text-type, 400 0.75rem / 1rem Roboto);--_text-field-supporting-text-weight: var(--md-filled-autocomplete-text-field-supporting-text-weight, 400);--_text-field-trailing-icon-color: var(--md-filled-autocomplete-text-field-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-trailing-icon-size: var(--md-filled-autocomplete-text-field-trailing-icon-size, 24px)}.md3-text-field{--md-filled-text-field-active-indicator-color:var(--_text-field-active-indicator-color);--md-filled-text-field-active-indicator-height:var(--_text-field-active-indicator-height);--md-filled-text-field-caret-color:var(--_text-field-caret-color);--md-filled-text-field-container-color:var(--_text-field-container-color);--md-filled-text-field-disabled-active-indicator-color:var(--_text-field-disabled-active-indicator-color);--md-filled-text-field-disabled-active-indicator-height:var(--_text-field-disabled-active-indicator-height);--md-filled-text-field-disabled-active-indicator-opacity:var(--_text-field-disabled-active-indicator-opacity);--md-filled-text-field-disabled-container-color:var(--_text-field-disabled-container-color);--md-filled-text-field-disabled-container-opacity:var(--_text-field-disabled-container-opacity);--md-filled-text-field-disabled-input-text-color:var(--_text-field-disabled-input-text-color);--md-filled-text-field-disabled-input-text-opacity:var(--_text-field-disabled-input-text-opacity);--md-filled-text-field-disabled-label-text-color:var(--_text-field-disabled-label-text-color);--md-filled-text-field-disabled-label-text-opacity:var(--_text-field-disabled-label-text-opacity);--md-filled-text-field-disabled-leading-icon-color:var(--_text-field-disabled-leading-icon-color);--md-filled-text-field-disabled-leading-icon-opacity:var(--_text-field-disabled-leading-icon-opacity);--md-filled-text-field-disabled-supporting-text-color:var(--_text-field-disabled-supporting-text-color);--md-filled-text-field-disabled-supporting-text-opacity:var(--_text-field-disabled-supporting-text-opacity);--md-filled-text-field-disabled-trailing-icon-color:var(--_text-field-disabled-trailing-icon-color);--md-filled-text-field-disabled-trailing-icon-opacity:var(--_text-field-disabled-trailing-icon-opacity);--md-filled-text-field-error-active-indicator-color:var(--_text-field-error-active-indicator-color);--md-filled-text-field-error-focus-active-indicator-color:var(--_text-field-error-focus-active-indicator-color);--md-filled-text-field-error-focus-caret-color:var(--_text-field-error-focus-caret-color);--md-filled-text-field-error-focus-input-text-color:var(--_text-field-error-focus-input-text-color);--md-filled-text-field-error-focus-label-text-color:var(--_text-field-error-focus-label-text-color);--md-filled-text-field-error-focus-leading-icon-color:var(--_text-field-error-focus-leading-icon-color);--md-filled-text-field-error-focus-supporting-text-color:var(--_text-field-error-focus-supporting-text-color);--md-filled-text-field-error-focus-trailing-icon-color:var(--_text-field-error-focus-trailing-icon-color);--md-filled-text-field-error-hover-active-indicator-color:var(--_text-field-error-hover-active-indicator-color);--md-filled-text-field-error-hover-input-text-color:var(--_text-field-error-hover-input-text-color);--md-filled-text-field-error-hover-label-text-color:var(--_text-field-error-hover-label-text-color);--md-filled-text-field-error-hover-leading-icon-color:var(--_text-field-error-hover-leading-icon-color);--md-filled-text-field-error-hover-state-layer-color:var(--_text-field-error-hover-state-layer-color);--md-filled-text-field-error-hover-state-layer-opacity:var(--_text-field-error-hover-state-layer-opacity);--md-filled-text-field-error-hover-supporting-text-color:var(--_text-field-error-hover-supporting-text-color);--md-filled-text-field-error-hover-trailing-icon-color:var(--_text-field-error-hover-trailing-icon-color);--md-filled-text-field-error-input-text-color:var(--_text-field-error-input-text-color);--md-filled-text-field-error-label-text-color:var(--_text-field-error-label-text-color);--md-filled-text-field-error-leading-icon-color:var(--_text-field-error-leading-icon-color);--md-filled-text-field-error-supporting-text-color:var(--_text-field-error-supporting-text-color);--md-filled-text-field-error-trailing-icon-color:var(--_text-field-error-trailing-icon-color);--md-filled-text-field-focus-active-indicator-color:var(--_text-field-focus-active-indicator-color);--md-filled-text-field-focus-active-indicator-height:var(--_text-field-focus-active-indicator-height);--md-filled-text-field-focus-input-text-color:var(--_text-field-focus-input-text-color);--md-filled-text-field-focus-label-text-color:var(--_text-field-focus-label-text-color);--md-filled-text-field-focus-leading-icon-color:var(--_text-field-focus-leading-icon-color);--md-filled-text-field-focus-supporting-text-color:var(--_text-field-focus-supporting-text-color);--md-filled-text-field-focus-trailing-icon-color:var(--_text-field-focus-trailing-icon-color);--md-filled-text-field-hover-active-indicator-color:var(--_text-field-hover-active-indicator-color);--md-filled-text-field-hover-active-indicator-height:var(--_text-field-hover-active-indicator-height);--md-filled-text-field-hover-input-text-color:var(--_text-field-hover-input-text-color);--md-filled-text-field-hover-label-text-color:var(--_text-field-hover-label-text-color);--md-filled-text-field-hover-leading-icon-color:var(--_text-field-hover-leading-icon-color);--md-filled-text-field-hover-state-layer-color:var(--_text-field-hover-state-layer-color);--md-filled-text-field-hover-state-layer-opacity:var(--_text-field-hover-state-layer-opacity);--md-filled-text-field-hover-supporting-text-color:var(--_text-field-hover-supporting-text-color);--md-filled-text-field-hover-trailing-icon-color:var(--_text-field-hover-trailing-icon-color);--md-filled-text-field-input-text-color:var(--_text-field-input-text-color);--md-filled-text-field-input-text-font:var(--_text-field-input-text-font);--md-filled-text-field-input-text-line-height:var(--_text-field-input-text-line-height);--md-filled-text-field-input-text-size:var(--_text-field-input-text-size);--md-filled-text-field-input-text-tracking:var(--_text-field-input-text-tracking);--md-filled-text-field-input-text-type:var(--_text-field-input-text-type);--md-filled-text-field-input-text-weight:var(--_text-field-input-text-weight);--md-filled-text-field-label-text-color:var(--_text-field-label-text-color);--md-filled-text-field-label-text-font:var(--_text-field-label-text-font);--md-filled-text-field-label-text-line-height:var(--_text-field-label-text-line-height);--md-filled-text-field-label-text-populated-line-height:var(--_text-field-label-text-populated-line-height);--md-filled-text-field-label-text-populated-size:var(--_text-field-label-text-populated-size);--md-filled-text-field-label-text-size:var(--_text-field-label-text-size);--md-filled-text-field-label-text-tracking:var(--_text-field-label-text-tracking);--md-filled-text-field-label-text-type:var(--_text-field-label-text-type);--md-filled-text-field-label-text-weight:var(--_text-field-label-text-weight);--md-filled-text-field-leading-icon-color:var(--_text-field-leading-icon-color);--md-filled-text-field-leading-icon-size:var(--_text-field-leading-icon-size);--md-filled-text-field-supporting-text-color:var(--_text-field-supporting-text-color);--md-filled-text-field-supporting-text-font:var(--_text-field-supporting-text-font);--md-filled-text-field-supporting-text-line-height:var(--_text-field-supporting-text-line-height);--md-filled-text-field-supporting-text-size:var(--_text-field-supporting-text-size);--md-filled-text-field-supporting-text-tracking:var(--_text-field-supporting-text-tracking);--md-filled-text-field-supporting-text-weight:var(--_text-field-supporting-text-weight);--md-filled-text-field-trailing-icon-color:var(--_text-field-trailing-icon-color);--md-filled-text-field-trailing-icon-size:var(--_text-field-trailing-icon-size);--md-filled-field-container-shape-start-start:var(--_text-field-container-shape-start-start);--md-filled-field-container-shape-start-end:var(--_text-field-container-shape-start-end);--md-filled-field-container-shape-end-end:var(--_text-field-container-shape-end-end);--md-filled-field-container-shape-end-start:var(--_text-field-container-shape-end-start)}.md3-autocomplete__menu-surface{--md-menu-surface-container-elevation:var(--_menu-container-elevation);--md-menu-surface-container-shape:var(--_menu-container-shape);--md-menu-surface-container-shadow-color:var(--_menu-container-shadow-color)}/*# sourceMappingURL=filled-styles.css.map */ `; //# sourceMappingURL=filled-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/outlined-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/outlined-styles.css.js index bba488734..bbec25a 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/outlined-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/outlined-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_text-field-container-shape-start-start: var(--md-outlined-autocomplete-text-field-container-shape-start-start, 4px);--_text-field-container-shape-start-end: var(--md-outlined-autocomplete-text-field-container-shape-start-end, 4px);--_text-field-container-shape-end-end: var(--md-outlined-autocomplete-text-field-container-shape-end-end, 4px);--_text-field-container-shape-end-start: var(--md-outlined-autocomplete-text-field-container-shape-end-start, 4px);--_menu-cascading-menu-indicator-icon-color: var(--md-outlined-autocomplete-menu-cascading-menu-indicator-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_menu-cascading-menu-indicator-icon-size: var(--md-outlined-autocomplete-menu-cascading-menu-indicator-icon-size, 24px);--_menu-container-color: var(--md-outlined-autocomplete-menu-container-color, var(--md-sys-color-surface, #fffbfe));--_menu-container-elevation: var(--md-outlined-autocomplete-menu-container-elevation, 2);--_menu-container-shadow-color: var(--md-outlined-autocomplete-menu-container-shadow-color, var(--md-sys-color-shadow, #000));--_menu-container-shape: var(--md-outlined-autocomplete-menu-container-shape, 4px);--_menu-container-surface-tint-layer-color: var(--md-outlined-autocomplete-menu-container-surface-tint-layer-color, var(--md-sys-color-primary, #6750a4));--_menu-divider-color: var(--md-outlined-autocomplete-menu-divider-color, var(--md-sys-color-surface-variant, #e7e0ec));--_menu-divider-height: var(--md-outlined-autocomplete-menu-divider-height, 1px);--_menu-list-item-container-height: var(--md-outlined-autocomplete-menu-list-item-container-height, 48px);--_menu-list-item-label-text-color: var(--md-outlined-autocomplete-menu-list-item-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_menu-list-item-label-text-font: var(--md-outlined-autocomplete-menu-list-item-label-text-font, Roboto);--_menu-list-item-label-text-line-height: var(--md-outlined-autocomplete-menu-list-item-label-text-line-height, 1.25rem);--_menu-list-item-label-text-size: var(--md-outlined-autocomplete-menu-list-item-label-text-size, 0.875rem);--_menu-list-item-label-text-tracking: var(--md-outlined-autocomplete-menu-list-item-label-text-tracking, 0.006rem);--_menu-list-item-label-text-type: var(--md-outlined-autocomplete-menu-list-item-label-text-type, 500 0.875rem / 1.25rem Roboto);--_menu-list-item-label-text-weight: var(--md-outlined-autocomplete-menu-list-item-label-text-weight, 500);--_menu-list-item-selected-container-color: var(--md-outlined-autocomplete-menu-list-item-selected-container-color, var(--md-sys-color-surface-variant, #e7e0ec));--_text-field-caret-color: var(--md-outlined-autocomplete-text-field-caret-color, var(--md-sys-color-primary, #6750a4));--_text-field-container-color: var(--md-outlined-autocomplete-text-field-container-color, var(--md-sys-color-surface-variant, #e7e0ec));--_text-field-disabled-input-text-color: var(--md-outlined-autocomplete-text-field-disabled-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-disabled-input-text-opacity: var(--md-outlined-autocomplete-text-field-disabled-input-text-opacity, 0.38);--_text-field-disabled-label-text-color: var(--md-outlined-autocomplete-text-field-disabled-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-disabled-label-text-opacity: var(--md-outlined-autocomplete-text-field-disabled-label-text-opacity, 0.38);--_text-field-disabled-leading-icon-color: var(--md-outlined-autocomplete-text-field-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-disabled-leading-icon-opacity: var(--md-outlined-autocomplete-text-field-disabled-leading-icon-opacity, 0.38);--_text-field-disabled-outline-color: var(--md-outlined-autocomplete-text-field-disabled-outline-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-disabled-outline-opacity: var(--md-outlined-autocomplete-text-field-disabled-outline-opacity, 0.12);--_text-field-disabled-outline-width: var(--md-outlined-autocomplete-text-field-disabled-outline-width, 1px);--_text-field-disabled-supporting-text-color: var(--md-outlined-autocomplete-text-field-disabled-supporting-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-disabled-supporting-text-opacity: var(--md-outlined-autocomplete-text-field-disabled-supporting-text-opacity, 0.38);--_text-field-disabled-trailing-icon-color: var(--md-outlined-autocomplete-text-field-disabled-trailing-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-disabled-trailing-icon-opacity: var(--md-outlined-autocomplete-text-field-disabled-trailing-icon-opacity, 0.38);--_text-field-error-focus-caret-color: var(--md-outlined-autocomplete-text-field-error-focus-caret-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-input-text-color: var(--md-outlined-autocomplete-text-field-error-focus-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-error-focus-label-text-color: var(--md-outlined-autocomplete-text-field-error-focus-label-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-leading-icon-color: var(--md-outlined-autocomplete-text-field-error-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-error-focus-outline-color: var(--md-outlined-autocomplete-text-field-error-focus-outline-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-supporting-text-color: var(--md-outlined-autocomplete-text-field-error-focus-supporting-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-trailing-icon-color: var(--md-outlined-autocomplete-text-field-error-focus-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_text-field-error-hover-input-text-color: var(--md-outlined-autocomplete-text-field-error-hover-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-error-hover-label-text-color: var(--md-outlined-autocomplete-text-field-error-hover-label-text-color, var(--md-sys-color-on-error-container, #410e0b));--_text-field-error-hover-leading-icon-color: var(--md-outlined-autocomplete-text-field-error-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-error-hover-outline-color: var(--md-outlined-autocomplete-text-field-error-hover-outline-color, var(--md-sys-color-on-error-container, #410e0b));--_text-field-error-hover-state-layer-color: var(--md-outlined-autocomplete-text-field-error-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-error-hover-state-layer-opacity: var(--md-outlined-autocomplete-text-field-error-hover-state-layer-opacity, 0.08);--_text-field-error-hover-supporting-text-color: var(--md-outlined-autocomplete-text-field-error-hover-supporting-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-hover-trailing-icon-color: var(--md-outlined-autocomplete-text-field-error-hover-trailing-icon-color, var(--md-sys-color-on-error-container, #410e0b));--_text-field-error-input-text-color: var(--md-outlined-autocomplete-text-field-error-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-error-label-text-color: var(--md-outlined-autocomplete-text-field-error-label-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-leading-icon-color: var(--md-outlined-autocomplete-text-field-error-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-error-outline-color: var(--md-outlined-autocomplete-text-field-error-outline-color, var(--md-sys-color-error, #b3261e));--_text-field-error-supporting-text-color: var(--md-outlined-autocomplete-text-field-error-supporting-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-trailing-icon-color: var(--md-outlined-autocomplete-text-field-error-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_text-field-focus-input-text-color: var(--md-outlined-autocomplete-text-field-focus-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-focus-label-text-color: var(--md-outlined-autocomplete-text-field-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_text-field-focus-leading-icon-color: var(--md-outlined-autocomplete-text-field-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-focus-outline-color: var(--md-outlined-autocomplete-text-field-focus-outline-color, var(--md-sys-color-primary, #6750a4));--_text-field-focus-outline-width: var(--md-outlined-autocomplete-text-field-focus-outline-width, 2px);--_text-field-focus-supporting-text-color: var(--md-outlined-autocomplete-text-field-focus-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-focus-trailing-icon-color: var(--md-outlined-autocomplete-text-field-focus-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-hover-input-text-color: var(--md-outlined-autocomplete-text-field-hover-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-hover-label-text-color: var(--md-outlined-autocomplete-text-field-hover-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-hover-leading-icon-color: var(--md-outlined-autocomplete-text-field-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-hover-outline-color: var(--md-outlined-autocomplete-text-field-hover-outline-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-hover-outline-width: var(--md-outlined-autocomplete-text-field-hover-outline-width, 1px);--_text-field-hover-state-layer-color: var(--md-outlined-autocomplete-text-field-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-hover-state-layer-opacity: var(--md-outlined-autocomplete-text-field-hover-state-layer-opacity, 0.08);--_text-field-hover-supporting-text-color: var(--md-outlined-autocomplete-text-field-hover-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-hover-trailing-icon-color: var(--md-outlined-autocomplete-text-field-hover-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-input-text-color: var(--md-outlined-autocomplete-text-field-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_text-field-input-text-font: var(--md-outlined-autocomplete-text-field-input-text-font, Roboto);--_text-field-input-text-line-height: var(--md-outlined-autocomplete-text-field-input-text-line-height, 1.5rem);--_text-field-input-text-size: var(--md-outlined-autocomplete-text-field-input-text-size, 1rem);--_text-field-input-text-tracking: var(--md-outlined-autocomplete-text-field-input-text-tracking, 0.031rem);--_text-field-input-text-type: var(--md-outlined-autocomplete-text-field-input-text-type, 400 1rem / 1.5rem Roboto);--_text-field-input-text-weight: var(--md-outlined-autocomplete-text-field-input-text-weight, 400);--_text-field-label-text-color: var(--md-outlined-autocomplete-text-field-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-label-text-font: var(--md-outlined-autocomplete-text-field-label-text-font, Roboto);--_text-field-label-text-line-height: var(--md-outlined-autocomplete-text-field-label-text-line-height, 1.5rem);--_text-field-label-text-populated-line-height: var(--md-outlined-autocomplete-text-field-label-text-populated-line-height, 1rem);--_text-field-label-text-populated-size: var(--md-outlined-autocomplete-text-field-label-text-populated-size, 0.75rem);--_text-field-label-text-size: var(--md-outlined-autocomplete-text-field-label-text-size, 1rem);--_text-field-label-text-tracking: var(--md-outlined-autocomplete-text-field-label-text-tracking, 0.031rem);--_text-field-label-text-type: var(--md-outlined-autocomplete-text-field-label-text-type, 400 1rem / 1.5rem Roboto);--_text-field-label-text-weight: var(--md-outlined-autocomplete-text-field-label-text-weight, 400);--_text-field-leading-icon-color: var(--md-outlined-autocomplete-text-field-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-leading-icon-size: var(--md-outlined-autocomplete-text-field-leading-icon-size, 24px);--_text-field-outline-color: var(--md-outlined-autocomplete-text-field-outline-color, var(--md-sys-color-outline, #79747e));--_text-field-outline-width: var(--md-outlined-autocomplete-text-field-outline-width, 1px);--_text-field-supporting-text-color: var(--md-outlined-autocomplete-text-field-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-supporting-text-font: var(--md-outlined-autocomplete-text-field-supporting-text-font, Roboto);--_text-field-supporting-text-line-height: var(--md-outlined-autocomplete-text-field-supporting-text-line-height, 1rem);--_text-field-supporting-text-size: var(--md-outlined-autocomplete-text-field-supporting-text-size, 0.75rem);--_text-field-supporting-text-tracking: var(--md-outlined-autocomplete-text-field-supporting-text-tracking, 0.025rem);--_text-field-supporting-text-type: var(--md-outlined-autocomplete-text-field-supporting-text-type, 400 0.75rem / 1rem Roboto);--_text-field-supporting-text-weight: var(--md-outlined-autocomplete-text-field-supporting-text-weight, 400);--_text-field-trailing-icon-color: var(--md-outlined-autocomplete-text-field-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-trailing-icon-size: var(--md-outlined-autocomplete-text-field-trailing-icon-size, 24px);--_text-field-container-shape: var(--md-outlined-autocomplete-text-field-container-shape, 4px)}.md3-text-field{--md-outlined-text-field-caret-color:var(--_text-field-caret-color);--md-outlined-text-field-disabled-input-text-color:var(--_text-field-disabled-input-text-color);--md-outlined-text-field-disabled-input-text-opacity:var(--_text-field-disabled-input-text-opacity);--md-outlined-text-field-disabled-label-text-color:var(--_text-field-disabled-label-text-color);--md-outlined-text-field-disabled-label-text-opacity:var(--_text-field-disabled-label-text-opacity);--md-outlined-text-field-disabled-leading-icon-color:var(--_text-field-disabled-leading-icon-color);--md-outlined-text-field-disabled-leading-icon-opacity:var(--_text-field-disabled-leading-icon-opacity);--md-outlined-text-field-disabled-outline-color:var(--_text-field-disabled-outline-color);--md-outlined-text-field-disabled-outline-opacity:var(--_text-field-disabled-outline-opacity);--md-outlined-text-field-disabled-outline-width:var(--_text-field-disabled-outline-width);--md-outlined-text-field-disabled-supporting-text-color:var(--_text-field-disabled-supporting-text-color);--md-outlined-text-field-disabled-supporting-text-opacity:var(--_text-field-disabled-supporting-text-opacity);--md-outlined-text-field-disabled-trailing-icon-color:var(--_text-field-disabled-trailing-icon-color);--md-outlined-text-field-disabled-trailing-icon-opacity:var(--_text-field-disabled-trailing-icon-opacity);--md-outlined-text-field-error-focus-caret-color:var(--_text-field-error-focus-caret-color);--md-outlined-text-field-error-focus-input-text-color:var(--_text-field-error-focus-input-text-color);--md-outlined-text-field-error-focus-label-text-color:var(--_text-field-error-focus-label-text-color);--md-outlined-text-field-error-focus-leading-icon-color:var(--_text-field-error-focus-leading-icon-color);--md-outlined-text-field-error-focus-outline-color:var(--_text-field-error-focus-outline-color);--md-outlined-text-field-error-focus-supporting-text-color:var(--_text-field-error-focus-supporting-text-color);--md-outlined-text-field-error-focus-trailing-icon-color:var(--_text-field-error-focus-trailing-icon-color);--md-outlined-text-field-error-hover-input-text-color:var(--_text-field-error-hover-input-text-color);--md-outlined-text-field-error-hover-label-text-color:var(--_text-field-error-hover-label-text-color);--md-outlined-text-field-error-hover-leading-icon-color:var(--_text-field-error-hover-leading-icon-color);--md-outlined-text-field-error-hover-outline-color:var(--_text-field-error-hover-outline-color);--md-outlined-text-field-error-hover-supporting-text-color:var(--_text-field-error-hover-supporting-text-color);--md-outlined-text-field-error-hover-trailing-icon-color:var(--_text-field-error-hover-trailing-icon-color);--md-outlined-text-field-error-input-text-color:var(--_text-field-error-input-text-color);--md-outlined-text-field-error-label-text-color:var(--_text-field-error-label-text-color);--md-outlined-text-field-error-leading-icon-color:var(--_text-field-error-leading-icon-color);--md-outlined-text-field-error-outline-color:var(--_text-field-error-outline-color);--md-outlined-text-field-error-supporting-text-color:var(--_text-field-error-supporting-text-color);--md-outlined-text-field-error-trailing-icon-color:var(--_text-field-error-trailing-icon-color);--md-outlined-text-field-focus-input-text-color:var(--_text-field-focus-input-text-color);--md-outlined-text-field-focus-label-text-color:var(--_text-field-focus-label-text-color);--md-outlined-text-field-focus-leading-icon-color:var(--_text-field-focus-leading-icon-color);--md-outlined-text-field-focus-outline-color:var(--_text-field-focus-outline-color);--md-outlined-text-field-focus-outline-width:var(--_text-field-focus-outline-width);--md-outlined-text-field-focus-supporting-text-color:var(--_text-field-focus-supporting-text-color);--md-outlined-text-field-focus-trailing-icon-color:var(--_text-field-focus-trailing-icon-color);--md-outlined-text-field-hover-input-text-color:var(--_text-field-hover-input-text-color);--md-outlined-text-field-hover-label-text-color:var(--_text-field-hover-label-text-color);--md-outlined-text-field-hover-leading-icon-color:var(--_text-field-hover-leading-icon-color);--md-outlined-text-field-hover-outline-color:var(--_text-field-hover-outline-color);--md-outlined-text-field-hover-outline-width:var(--_text-field-hover-outline-width);--md-outlined-text-field-hover-supporting-text-color:var(--_text-field-hover-supporting-text-color);--md-outlined-text-field-hover-trailing-icon-color:var(--_text-field-hover-trailing-icon-color);--md-outlined-text-field-input-text-color:var(--_text-field-input-text-color);--md-outlined-text-field-input-text-font:var(--_text-field-input-text-font);--md-outlined-text-field-input-text-line-height:var(--_text-field-input-text-line-height);--md-outlined-text-field-input-text-size:var(--_text-field-input-text-size);--md-outlined-text-field-input-text-tracking:var(--_text-field-input-text-tracking);--md-outlined-text-field-input-text-type:var(--_text-field-input-text-type);--md-outlined-text-field-input-text-weight:var(--_text-field-input-text-weight);--md-outlined-text-field-label-text-color:var(--_text-field-label-text-color);--md-outlined-text-field-label-text-font:var(--_text-field-label-text-font);--md-outlined-text-field-label-text-line-height:var(--_text-field-label-text-line-height);--md-outlined-text-field-label-text-populated-line-height:var(--_text-field-label-text-populated-line-height);--md-outlined-text-field-label-text-populated-size:var(--_text-field-label-text-populated-size);--md-outlined-text-field-label-text-size:var(--_text-field-label-text-size);--md-outlined-text-field-label-text-tracking:var(--_text-field-label-text-tracking);--md-outlined-text-field-label-text-type:var(--_text-field-label-text-type);--md-outlined-text-field-label-text-weight:var(--_text-field-label-text-weight);--md-outlined-text-field-leading-icon-color:var(--_text-field-leading-icon-color);--md-outlined-text-field-leading-icon-size:var(--_text-field-leading-icon-size);--md-outlined-text-field-outline-color:var(--_text-field-outline-color);--md-outlined-text-field-outline-width:var(--_text-field-outline-width);--md-outlined-text-field-supporting-text-color:var(--_text-field-supporting-text-color);--md-outlined-text-field-supporting-text-font:var(--_text-field-supporting-text-font);--md-outlined-text-field-supporting-text-line-height:var(--_text-field-supporting-text-line-height);--md-outlined-text-field-supporting-text-size:var(--_text-field-supporting-text-size);--md-outlined-text-field-supporting-text-tracking:var(--_text-field-supporting-text-tracking);--md-outlined-text-field-supporting-text-weight:var(--_text-field-supporting-text-weight);--md-outlined-text-field-trailing-icon-color:var(--_text-field-trailing-icon-color);--md-outlined-text-field-trailing-icon-size:var(--_text-field-trailing-icon-size);--md-outlined-field-container-shape-start-start:var(--_text-field-container-shape-start-start);--md-outlined-field-container-shape-start-end:var(--_text-field-container-shape-start-end);--md-outlined-field-container-shape-end-end:var(--_text-field-container-shape-end-end);--md-outlined-field-container-shape-end-start:var(--_text-field-container-shape-end-start)}.md3-autocomplete__menu-surface{--md-menu-surface-container-elevation:var(--_menu-container-elevation);--md-menu-surface-container-shape:var(--_menu-container-shape);--md-menu-surface-container-shadow-color:var(--_menu-container-shadow-color)}/*# sourceMappingURL=outlined-styles.css.map */ `; //# sourceMappingURL=outlined-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/shared-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/shared-styles.css.js index a0dce0f3..e795239 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/shared-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/lib/shared-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `.md3-autocomplete{display:inline-flex;flex:1}/*# sourceMappingURL=shared-styles.css.map */ `; //# sourceMappingURL=shared-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/outlined-autocomplete.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/outlined-autocomplete.js index 4a060f28..a743671 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/outlined-autocomplete.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/autocomplete/outlined-autocomplete.js
@@ -3,12 +3,12 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; +import { __decorate } from "tslib"; import '../field/outlined-field.js'; import './autocomplete-list.js'; import './autocomplete-surface.js'; -import { customElement } from '../../../lit/decorators.js'; -import { literal } from '../../../lit/static-html.js'; +import { customElement } from 'lit/decorators.js'; +import { literal } from 'lit/static-html.js'; import { styles as outlinedForcedColorsStyles } from '../textfield/lib/outlined-forced-colors-styles.css.js'; import { styles as outlinedStyles } from '../textfield/lib/outlined-styles.css.js'; import { styles as sharedStyles } from '../textfield/lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/badge/badge.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/badge/badge.js index 8a5a1fb..9211bac5 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/badge/badge.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/badge/badge.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { Badge } from './lib/badge.js'; import { styles } from './lib/badge-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/badge/lib/badge-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/badge/lib/badge-styles.css.js index a71a920..9bc0663 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/badge/lib/badge-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/badge/lib/badge-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_color: var(--md-badge-color, var(--md-sys-color-error, #b3261e));--_large-color: var(--md-badge-large-color, var(--md-sys-color-error, #b3261e));--_large-label-text-color: var(--md-badge-large-label-text-color, var(--md-sys-color-on-error, #fff));--_large-label-text-font: var(--md-badge-large-label-text-font, Roboto);--_large-label-text-line-height: var(--md-badge-large-label-text-line-height, 1rem);--_large-label-text-size: var(--md-badge-large-label-text-size, 0.688rem);--_large-label-text-tracking: var(--md-badge-large-label-text-tracking, 0.031rem);--_large-label-text-weight: var(--md-badge-large-label-text-weight, 500);--_large-shape: var(--md-badge-large-shape, 9999px);--_large-size: var(--md-badge-large-size, 16px);--_shape: var(--md-badge-shape, 9999px);--_size: var(--md-badge-size, 6px)}.md3-badge{inset-inline-start:50%;margin-inline-start:6px;margin-block-start:4px;position:absolute;inset-block-start:0px;background-color:var(--_color);border-radius:var(--_shape);height:var(--_size)}.md3-badge:not(.md3-badge--large){width:var(--_size)}.md3-badge.md3-badge--large{display:flex;flex-direction:column;justify-content:center;margin-inline-start:2px;margin-block-start:1px;background-color:var(--_large-color);border-radius:var(--_large-shape);height:var(--_large-size);min-width:var(--_large-size);color:var(--_large-label-text-color)}.md3-badge.md3-badge--large .md3-badge__value{padding:0px 4px}.md3-badge__value{font-family:var(--_large-label-text-font);font-size:var(--_large-label-text-size);letter-spacing:var(--_large-label-text-tracking);line-height:var(--_large-label-text-line-height);font-weight:var(--_large-label-text-weight)}/*# sourceMappingURL=badge-styles.css.map */ `; //# sourceMappingURL=badge-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/badge/lib/badge.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/badge/lib/badge.js index 113ef6b..6e0fd89 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/badge/lib/badge.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/badge/lib/badge.js
@@ -3,10 +3,10 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; -import { html, LitElement } from '../../../../lit/index.js'; -import { property } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; +import { __decorate, __metadata } from "tslib"; +import { html, LitElement } from 'lit'; +import { property } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; /** @soyCompatible */ export class Badge extends LitElement { constructor() {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/elevated-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/elevated-button.js index 334d101e..73fbcda 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/elevated-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/elevated-button.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { ElevatedButton } from './lib/elevated-button.js'; import { styles as elevatedStyles } from './lib/elevated-styles.css.js'; import { styles as sharedElevationStyles } from './lib/shared-elevation-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/elevated-link-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/elevated-link-button.js index 0994d81..63007d13 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/elevated-link-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/elevated-link-button.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { ElevatedLinkButton } from './lib/elevated-link-button.js'; import { styles as elevatedStyles } from './lib/elevated-styles.css.js'; import { styles as sharedElevationStyles } from './lib/shared-elevation-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/filled-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/filled-button.js index 57dfec7..ced12a63 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/filled-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/filled-button.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { FilledButton } from './lib/filled-button.js'; import { styles as filledStyles } from './lib/filled-styles.css.js'; import { styles as sharedElevationStyles } from './lib/shared-elevation-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/filled-link-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/filled-link-button.js index 2a6db4cf..8fa5875 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/filled-link-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/filled-link-button.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { FilledLinkButton } from './lib/filled-link-button.js'; import { styles as filledStyles } from './lib/filled-styles.css.js'; import { styles as sharedElevationStyles } from './lib/shared-elevation-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/button.js index 6dfe45a..fd3f0d4 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/button.js
@@ -3,15 +3,15 @@ * Copyright 2019 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; // This is required for @ariaProperty // tslint:disable:no-new-decorators import '../../focus/focus-ring.js'; import '../../ripple/ripple.js'; -import { html, LitElement, nothing } from '../../../../lit/index.js'; -import { property, query, queryAssignedElements, queryAsync, state } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { when } from '../../../../lit/directives/when.js'; +import { html, LitElement, nothing } from 'lit'; +import { property, query, queryAssignedElements, queryAsync, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { when } from 'lit/directives/when.js'; import { dispatchActivationClick, isActivationClick } from '../../controller/events.js'; import { ariaProperty } from '../../decorators/aria-property.js'; import { pointerPress, shouldShowStrongFocus } from '../../focus/strong-focus.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/elevated-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/elevated-button.js index 9a634af..07b24249 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/elevated-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/elevated-button.js
@@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import '../../elevation/elevation.js'; -import { html } from '../../../../lit/index.js'; +import { html } from 'lit'; import { Button } from './button.js'; // tslint:disable-next-line:enforce-comments-on-exported-symbols export class ElevatedButton extends Button {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/elevated-link-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/elevated-link-button.js index 9efbe7a..4c5909b 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/elevated-link-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/elevated-link-button.js
@@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import '../../elevation/elevation.js'; -import { html } from '../../../../lit/index.js'; +import { html } from 'lit'; import { LinkButton } from './link-button.js'; // tslint:disable-next-line:enforce-comments-on-exported-symbols export class ElevatedLinkButton extends LinkButton {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/elevated-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/elevated-styles.css.js index e85e997..02daf15 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/elevated-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/elevated-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-shape-start-start: var(--md-elevated-button-container-shape-start-start, 9999px);--_container-shape-start-end: var(--md-elevated-button-container-shape-start-end, 9999px);--_container-shape-end-end: var(--md-elevated-button-container-shape-end-end, 9999px);--_container-shape-end-start: var(--md-elevated-button-container-shape-end-start, 9999px);--_container-color: var(--md-elevated-button-container-color, var(--md-sys-color-surface, #fffbfe));--_container-elevation: var(--md-elevated-button-container-elevation, 1);--_container-height: var(--md-elevated-button-container-height, 40px);--_container-shadow-color: var(--md-elevated-button-container-shadow-color, var(--md-sys-color-shadow, #000));--_container-surface-tint-layer-color: var(--md-elevated-button-container-surface-tint-layer-color, var(--md-sys-color-primary, #6750a4));--_disabled-container-color: var(--md-elevated-button-disabled-container-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.12));--_disabled-container-elevation: var(--md-elevated-button-disabled-container-elevation, 0);--_disabled-label-text-color: var(--md-elevated-button-disabled-label-text-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_focus-container-elevation: var(--md-elevated-button-focus-container-elevation, 1);--_focus-label-text-color: var(--md-elevated-button-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_focus-state-layer-color: var(--md-elevated-button-focus-state-layer-color, var(--md-sys-color-primary, #6750a4));--_focus-state-layer-opacity: var(--md-elevated-button-focus-state-layer-opacity, 0.12);--_hover-container-elevation: var(--md-elevated-button-hover-container-elevation, 2);--_hover-label-text-color: var(--md-elevated-button-hover-label-text-color, var(--md-sys-color-primary, #6750a4));--_hover-state-layer-color: var(--md-elevated-button-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--_hover-state-layer-opacity: var(--md-elevated-button-hover-state-layer-opacity, 0.08);--_label-text-color: var(--md-elevated-button-label-text-color, var(--md-sys-color-primary, #6750a4));--_label-text-font: var(--md-elevated-button-label-text-font, Roboto);--_label-text-line-height: var(--md-elevated-button-label-text-line-height, 1.25rem);--_label-text-size: var(--md-elevated-button-label-text-size, 0.875rem);--_label-text-tracking: var(--md-elevated-button-label-text-tracking, 0.006rem);--_label-text-type: var(--md-elevated-button-label-text-type, 500 0.875rem / 1.25rem Roboto);--_label-text-weight: var(--md-elevated-button-label-text-weight, 500);--_pressed-container-elevation: var(--md-elevated-button-pressed-container-elevation, 1);--_pressed-label-text-color: var(--md-elevated-button-pressed-label-text-color, var(--md-sys-color-primary, #6750a4));--_pressed-state-layer-color: var(--md-elevated-button-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_pressed-state-layer-opacity: var(--md-elevated-button-pressed-state-layer-opacity, 0.12);--_with-icon-disabled-icon-color: var(--md-elevated-button-with-icon-disabled-icon-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_with-icon-focus-icon-color: var(--md-elevated-button-with-icon-focus-icon-color, var(--md-sys-color-primary, #6750a4));--_with-icon-hover-icon-color: var(--md-elevated-button-with-icon-hover-icon-color, var(--md-sys-color-primary, #6750a4));--_with-icon-icon-color: var(--md-elevated-button-with-icon-icon-color, var(--md-sys-color-primary, #6750a4));--_with-icon-icon-size: var(--md-elevated-button-with-icon-icon-size, 18px);--_with-icon-pressed-icon-color: var(--md-elevated-button-with-icon-pressed-icon-color, var(--md-sys-color-primary, #6750a4));--_spacing-leading: var(--md-elevated-button-spacing-leading, 24px);--_spacing-trailing: var(--md-elevated-button-spacing-trailing, 24px);--_with-icon-spacing-leading: var(--md-elevated-button-with-icon-spacing-leading, 16px);--_with-icon-spacing-trailing: var(--md-elevated-button-with-icon-spacing-trailing, 24px);--_with-trailing-icon-spacing-leading: var(--md-elevated-button-with-trailing-icon-spacing-leading, 24px);--_with-trailing-icon-spacing-trailing: var(--md-elevated-button-with-trailing-icon-spacing-trailing, 16px)}/*# sourceMappingURL=elevated-styles.css.map */ `; //# sourceMappingURL=elevated-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/filled-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/filled-button.js index 51f9215a..7f2d794 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/filled-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/filled-button.js
@@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import '../../elevation/elevation.js'; -import { html } from '../../../../lit/index.js'; +import { html } from 'lit'; import { Button } from './button.js'; // tslint:disable-next-line:enforce-comments-on-exported-symbols export class FilledButton extends Button {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/filled-link-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/filled-link-button.js index 1a82022c..84fad4ea 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/filled-link-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/filled-link-button.js
@@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import '../../elevation/elevation.js'; -import { html } from '../../../../lit/index.js'; +import { html } from 'lit'; import { LinkButton } from './link-button.js'; // tslint:disable-next-line:enforce-comments-on-exported-symbols export class FilledLinkButton extends LinkButton {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/filled-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/filled-styles.css.js index 82c6825..c39ccd7 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/filled-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/filled-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-shape-start-start: var(--md-filled-button-container-shape-start-start, 9999px);--_container-shape-start-end: var(--md-filled-button-container-shape-start-end, 9999px);--_container-shape-end-end: var(--md-filled-button-container-shape-end-end, 9999px);--_container-shape-end-start: var(--md-filled-button-container-shape-end-start, 9999px);--_container-color: var(--md-filled-button-container-color, var(--md-sys-color-primary, #6750a4));--_container-elevation: var(--md-filled-button-container-elevation, 0);--_container-height: var(--md-filled-button-container-height, 40px);--_container-shadow-color: var(--md-filled-button-container-shadow-color, var(--md-sys-color-shadow, #000));--_disabled-container-color: var(--md-filled-button-disabled-container-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.12));--_disabled-container-elevation: var(--md-filled-button-disabled-container-elevation, 0);--_disabled-label-text-color: var(--md-filled-button-disabled-label-text-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_focus-container-elevation: var(--md-filled-button-focus-container-elevation, 0);--_focus-label-text-color: var(--md-filled-button-focus-label-text-color, var(--md-sys-color-on-primary, #fff));--_focus-state-layer-color: var(--md-filled-button-focus-state-layer-color, var(--md-sys-color-on-primary, #fff));--_focus-state-layer-opacity: var(--md-filled-button-focus-state-layer-opacity, 0.12);--_hover-container-elevation: var(--md-filled-button-hover-container-elevation, 1);--_hover-label-text-color: var(--md-filled-button-hover-label-text-color, var(--md-sys-color-on-primary, #fff));--_hover-state-layer-color: var(--md-filled-button-hover-state-layer-color, var(--md-sys-color-on-primary, #fff));--_hover-state-layer-opacity: var(--md-filled-button-hover-state-layer-opacity, 0.08);--_label-text-color: var(--md-filled-button-label-text-color, var(--md-sys-color-on-primary, #fff));--_label-text-font: var(--md-filled-button-label-text-font, Roboto);--_label-text-line-height: var(--md-filled-button-label-text-line-height, 1.25rem);--_label-text-size: var(--md-filled-button-label-text-size, 0.875rem);--_label-text-tracking: var(--md-filled-button-label-text-tracking, 0.006rem);--_label-text-type: var(--md-filled-button-label-text-type, 500 0.875rem / 1.25rem Roboto);--_label-text-weight: var(--md-filled-button-label-text-weight, 500);--_pressed-container-elevation: var(--md-filled-button-pressed-container-elevation, 0);--_pressed-label-text-color: var(--md-filled-button-pressed-label-text-color, var(--md-sys-color-on-primary, #fff));--_pressed-state-layer-color: var(--md-filled-button-pressed-state-layer-color, var(--md-sys-color-on-primary, #fff));--_pressed-state-layer-opacity: var(--md-filled-button-pressed-state-layer-opacity, 0.12);--_with-icon-disabled-icon-color: var(--md-filled-button-with-icon-disabled-icon-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_with-icon-focus-icon-color: var(--md-filled-button-with-icon-focus-icon-color, var(--md-sys-color-on-primary, #fff));--_with-icon-hover-icon-color: var(--md-filled-button-with-icon-hover-icon-color, var(--md-sys-color-on-primary, #fff));--_with-icon-icon-color: var(--md-filled-button-with-icon-icon-color, var(--md-sys-color-on-primary, #fff));--_with-icon-icon-size: var(--md-filled-button-with-icon-icon-size, 18px);--_with-icon-pressed-icon-color: var(--md-filled-button-with-icon-pressed-icon-color, var(--md-sys-color-on-primary, #fff));--_spacing-leading: var(--md-filled-button-spacing-leading, 24px);--_spacing-trailing: var(--md-filled-button-spacing-trailing, 24px);--_with-icon-spacing-leading: var(--md-filled-button-with-icon-spacing-leading, 16px);--_with-icon-spacing-trailing: var(--md-filled-button-with-icon-spacing-trailing, 24px);--_with-trailing-icon-spacing-leading: var(--md-filled-button-with-trailing-icon-spacing-leading, 24px);--_with-trailing-icon-spacing-trailing: var(--md-filled-button-with-trailing-icon-spacing-trailing, 16px)}/*# sourceMappingURL=filled-styles.css.map */ `; //# sourceMappingURL=filled-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/link-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/link-button.js index 7be97422..fd9beb47c 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/link-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/link-button.js
@@ -3,12 +3,12 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; -import { html } from '../../../../lit/index.js'; -import { property } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../lit/directives/if-defined.js'; -import { when } from '../../../../lit/directives/when.js'; +import { __decorate, __metadata } from "tslib"; +import { html } from 'lit'; +import { property } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; +import { when } from 'lit/directives/when.js'; import { ripple } from '../../ripple/directive.js'; import { Button } from './button.js'; // tslint:disable-next-line:enforce-comments-on-exported-symbols
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/outlined-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/outlined-button.js index 0a43d31..ee8bb6b 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/outlined-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/outlined-button.js
@@ -3,7 +3,7 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { html } from '../../../../lit/index.js'; +import { html } from 'lit'; import { Button } from './button.js'; // tslint:disable-next-line:enforce-comments-on-exported-symbols export class OutlinedButton extends Button {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/outlined-link-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/outlined-link-button.js index 3eb590ae..28c3a75a 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/outlined-link-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/outlined-link-button.js
@@ -3,7 +3,7 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { html } from '../../../../lit/index.js'; +import { html } from 'lit'; import { LinkButton } from './link-button.js'; // tslint:disable-next-line:enforce-comments-on-exported-symbols export class OutlinedLinkButton extends LinkButton {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/outlined-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/outlined-styles.css.js index 80ca189d..a38776f1 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/outlined-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/outlined-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-shape-start-start: var(--md-outlined-button-container-shape-start-start, 9999px);--_container-shape-start-end: var(--md-outlined-button-container-shape-start-end, 9999px);--_container-shape-end-end: var(--md-outlined-button-container-shape-end-end, 9999px);--_container-shape-end-start: var(--md-outlined-button-container-shape-end-start, 9999px);--_container-height: var(--md-outlined-button-container-height, 40px);--_disabled-label-text-color: var(--md-outlined-button-disabled-label-text-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_disabled-outline-color: var(--md-outlined-button-disabled-outline-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.12));--_focus-label-text-color: var(--md-outlined-button-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_focus-outline-color: var(--md-outlined-button-focus-outline-color, var(--md-sys-color-primary, #6750a4));--_focus-state-layer-color: var(--md-outlined-button-focus-state-layer-color, var(--md-sys-color-primary, #6750a4));--_focus-state-layer-opacity: var(--md-outlined-button-focus-state-layer-opacity, 0.12);--_hover-label-text-color: var(--md-outlined-button-hover-label-text-color, var(--md-sys-color-primary, #6750a4));--_hover-outline-color: var(--md-outlined-button-hover-outline-color, var(--md-sys-color-outline, #79747e));--_hover-state-layer-color: var(--md-outlined-button-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--_hover-state-layer-opacity: var(--md-outlined-button-hover-state-layer-opacity, 0.08);--_label-text-color: var(--md-outlined-button-label-text-color, var(--md-sys-color-primary, #6750a4));--_label-text-font: var(--md-outlined-button-label-text-font, Roboto);--_label-text-line-height: var(--md-outlined-button-label-text-line-height, 1.25rem);--_label-text-size: var(--md-outlined-button-label-text-size, 0.875rem);--_label-text-tracking: var(--md-outlined-button-label-text-tracking, 0.006rem);--_label-text-type: var(--md-outlined-button-label-text-type, 500 0.875rem / 1.25rem Roboto);--_label-text-weight: var(--md-outlined-button-label-text-weight, 500);--_outline-color: var(--md-outlined-button-outline-color, var(--md-sys-color-outline, #79747e));--_outline-width: var(--md-outlined-button-outline-width, 1px);--_pressed-label-text-color: var(--md-outlined-button-pressed-label-text-color, var(--md-sys-color-primary, #6750a4));--_pressed-outline-color: var(--md-outlined-button-pressed-outline-color, var(--md-sys-color-outline, #79747e));--_pressed-state-layer-color: var(--md-outlined-button-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_pressed-state-layer-opacity: var(--md-outlined-button-pressed-state-layer-opacity, 0.12);--_with-icon-disabled-icon-color: var(--md-outlined-button-with-icon-disabled-icon-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_with-icon-focus-icon-color: var(--md-outlined-button-with-icon-focus-icon-color, var(--md-sys-color-primary, #6750a4));--_with-icon-hover-icon-color: var(--md-outlined-button-with-icon-hover-icon-color, var(--md-sys-color-primary, #6750a4));--_with-icon-icon-color: var(--md-outlined-button-with-icon-icon-color, var(--md-sys-color-primary, #6750a4));--_with-icon-icon-size: var(--md-outlined-button-with-icon-icon-size, 18px);--_with-icon-pressed-icon-color: var(--md-outlined-button-with-icon-pressed-icon-color, var(--md-sys-color-primary, #6750a4));--_spacing-leading: var(--md-outlined-button-spacing-leading, 24px);--_spacing-trailing: var(--md-outlined-button-spacing-trailing, 24px);--_with-icon-spacing-leading: var(--md-outlined-button-with-icon-spacing-leading, 16px);--_with-icon-spacing-trailing: var(--md-outlined-button-with-icon-spacing-trailing, 24px);--_with-trailing-icon-spacing-leading: var(--md-outlined-button-with-trailing-icon-spacing-leading, 24px);--_with-trailing-icon-spacing-trailing: var(--md-outlined-button-with-trailing-icon-spacing-trailing, 16px)}.md3-button__outline{inset:0;border-style:solid;position:absolute;box-sizing:border-box;border-color:var(--_outline-color);border-start-start-radius:var(--_container-shape-start-start);border-start-end-radius:var(--_container-shape-start-end);border-end-start-radius:var(--_container-shape-end-start);border-end-end-radius:var(--_container-shape-end-end)}.md3-button:active .md3-button__outline{border-color:var(--_pressed-outline-color)}.md3-button:disabled .md3-button__outline{border-color:var(--_disabled-outline-color)}.md3-button__outline,.md3-button__ripple{border-width:var(--_outline-width)}.md3-button__ripple{inline-size:calc(100% - 2*var(--_outline-width));block-size:calc(100% - 2*var(--_outline-width));border-style:solid;border-color:rgba(0,0,0,0)}/*# sourceMappingURL=outlined-styles.css.map */ `; //# sourceMappingURL=outlined-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/shared-elevation-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/shared-elevation-styles.css.js index 1978bdd..22940bd 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/shared-elevation-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/shared-elevation-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `md-elevation{inset:0;position:absolute}.md3-button{--md-elevation-duration:280ms;--md-elevation-level:var(--_container-elevation);--md-elevation-shadow-color:var(--_container-shadow-color);--md-elevation-surface-tint:var(--_container-surface-tint-layer-color)}.md3-button:focus{--md-elevation-level:var(--_focus-container-elevation)}.md3-button:hover{--md-elevation-level:var(--_hover-container-elevation)}.md3-button:active{--md-elevation-level:var(--_pressed-container-elevation)}.md3-button:disabled{--md-elevation-level:var(--_disabled-container-elevation)}/*# sourceMappingURL=shared-elevation-styles.css.map */ `; //# sourceMappingURL=shared-elevation-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/shared-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/shared-styles.css.js index 7e394dc..4561f36 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/shared-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/shared-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{display:inline-flex;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0);vertical-align:top;--md-ripple-hover-state-layer-color:var(--_hover-state-layer-color);--md-ripple-focus-state-layer-color:var(--_focus-state-layer-color);--md-ripple-pressed-state-layer-color:var(--_pressed-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_hover-state-layer-opacity);--md-ripple-focus-state-layer-opacity:var(--_focus-state-layer-opacity);--md-ripple-pressed-state-layer-opacity:var(--_pressed-state-layer-opacity);--md-focus-ring-shape-start-start:var(--_container-shape-start-start);--md-focus-ring-shape-start-end:var(--_container-shape-start-end);--md-focus-ring-shape-end-end:var(--_container-shape-end-end);--md-focus-ring-shape-end-start:var(--_container-shape-end-start)}:host([disabled]){cursor:default;pointer-events:none}.md3-button{display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;min-inline-size:64px;border:none;outline:none;line-height:inherit;user-select:none;-webkit-appearance:none;vertical-align:middle;background:rgba(0,0,0,0);text-decoration:none;inline-size:100%;position:relative;z-index:0;block-size:var(--_container-height);font-family:var(--_label-text-font);font-size:var(--_label-text-size);letter-spacing:var(--_label-text-tracking);font-weight:var(--_label-text-weight);background-color:var(--_container-color);color:var(--_label-text-color);padding-inline-start:var(--_spacing-leading);padding-inline-end:var(--_spacing-trailing);gap:8px}.md3-button::-moz-focus-inner{padding:0;border:0}.md3-button:hover{color:var(--_hover-label-text-color);cursor:pointer}.md3-button:focus{color:var(--_focus-label-text-color)}.md3-button:active{color:var(--_pressed-label-text-color);outline:none}.md3-button:disabled{background-color:var(--_disabled-container-color);color:var(--_disabled-label-text-color)}@media(forced-colors: active){.md3-button::before{position:absolute;box-sizing:border-box;width:100%;height:100%;top:0;left:0;border:1px solid rgba(0,0,0,0);border-radius:inherit;content:"";pointer-events:none}}.md3-button,.md3-button__ripple{border-start-start-radius:var(--_container-shape-start-start);border-start-end-radius:var(--_container-shape-start-end);border-end-start-radius:var(--_container-shape-end-start);border-end-end-radius:var(--_container-shape-end-end)}md-elevation,.md3-button__ripple{z-index:-1}.md3-button--icon-leading{padding-inline-start:var(--_with-icon-spacing-leading);padding-inline-end:var(--_with-icon-spacing-trailing)}.md3-button--icon-trailing{padding-inline-start:var(--_with-trailing-icon-spacing-leading);padding-inline-end:var(--_with-trailing-icon-spacing-trailing)}.md3-link-button-wrapper{inline-size:100%}.md3-button ::slotted([slot=icon]){display:inline-flex;position:relative;writing-mode:horizontal-tb;color:var(--_with-icon-icon-color);font-size:var(--_with-icon-icon-size);inline-size:var(--_with-icon-icon-size);block-size:var(--_with-icon-icon-size)}.md3-button:hover ::slotted([slot=icon]){color:var(--_with-icon-hover-icon-color)}.md3-button:focus ::slotted([slot=icon]){color:var(--_with-icon-focus-icon-color)}.md3-button:active ::slotted([slot=icon]){color:var(--_with-icon-pressed-icon-color)}.md3-button:disabled ::slotted([slot=icon]){color:var(--_with-icon-disabled-icon-color)}.md3-button__touch{position:absolute;top:50%;height:48px;left:0;right:0;transform:translateY(-50%)}/*# sourceMappingURL=shared-styles.css.map */ `; //# sourceMappingURL=shared-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/text-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/text-styles.css.js index c8be9ca..45c16b0 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/text-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/text-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-shape-start-start: var(--md-text-button-container-shape-start-start, 9999px);--_container-shape-start-end: var(--md-text-button-container-shape-start-end, 9999px);--_container-shape-end-end: var(--md-text-button-container-shape-end-end, 9999px);--_container-shape-end-start: var(--md-text-button-container-shape-end-start, 9999px);--_container-height: var(--md-text-button-container-height, 40px);--_disabled-label-text-color: var(--md-text-button-disabled-label-text-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_focus-label-text-color: var(--md-text-button-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_focus-state-layer-color: var(--md-text-button-focus-state-layer-color, var(--md-sys-color-primary, #6750a4));--_focus-state-layer-opacity: var(--md-text-button-focus-state-layer-opacity, 0.12);--_hover-label-text-color: var(--md-text-button-hover-label-text-color, var(--md-sys-color-primary, #6750a4));--_hover-state-layer-color: var(--md-text-button-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--_hover-state-layer-opacity: var(--md-text-button-hover-state-layer-opacity, 0.08);--_label-text-color: var(--md-text-button-label-text-color, var(--md-sys-color-primary, #6750a4));--_label-text-font: var(--md-text-button-label-text-font, Roboto);--_label-text-line-height: var(--md-text-button-label-text-line-height, 1.25rem);--_label-text-size: var(--md-text-button-label-text-size, 0.875rem);--_label-text-tracking: var(--md-text-button-label-text-tracking, 0.006rem);--_label-text-type: var(--md-text-button-label-text-type, 500 0.875rem / 1.25rem Roboto);--_label-text-weight: var(--md-text-button-label-text-weight, 500);--_pressed-label-text-color: var(--md-text-button-pressed-label-text-color, var(--md-sys-color-primary, #6750a4));--_pressed-state-layer-color: var(--md-text-button-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_pressed-state-layer-opacity: var(--md-text-button-pressed-state-layer-opacity, 0.12);--_with-icon-disabled-icon-color: var(--md-text-button-with-icon-disabled-icon-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_with-icon-focus-icon-color: var(--md-text-button-with-icon-focus-icon-color, var(--md-sys-color-primary, #6750a4));--_with-icon-hover-icon-color: var(--md-text-button-with-icon-hover-icon-color, var(--md-sys-color-primary, #6750a4));--_with-icon-icon-color: var(--md-text-button-with-icon-icon-color, var(--md-sys-color-primary, #6750a4));--_with-icon-icon-size: var(--md-text-button-with-icon-icon-size, 18px);--_with-icon-pressed-icon-color: var(--md-text-button-with-icon-pressed-icon-color, var(--md-sys-color-primary, #6750a4));--_spacing-leading: var(--md-text-button-spacing-leading, 12px);--_spacing-trailing: var(--md-text-button-spacing-trailing, 12px);--_with-icon-spacing-leading: var(--md-text-button-with-icon-spacing-leading, 12px);--_with-icon-spacing-trailing: var(--md-text-button-with-icon-spacing-trailing, 16px);--_with-trailing-icon-spacing-leading: var(--md-text-button-with-trailing-icon-spacing-leading, 16px);--_with-trailing-icon-spacing-trailing: var(--md-text-button-with-trailing-icon-spacing-trailing, 12px)}/*# sourceMappingURL=text-styles.css.map */ `; //# sourceMappingURL=text-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/tonal-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/tonal-button.js index c1dfb3f..ad28cfe 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/tonal-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/tonal-button.js
@@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import '../../elevation/elevation.js'; -import { html } from '../../../../lit/index.js'; +import { html } from 'lit'; import { Button } from './button.js'; // tslint:disable-next-line:enforce-comments-on-exported-symbols export class TonalButton extends Button {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/tonal-link-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/tonal-link-button.js index 7504acc..b63b500 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/tonal-link-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/tonal-link-button.js
@@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import '../../elevation/elevation.js'; -import { html } from '../../../../lit/index.js'; +import { html } from 'lit'; import { LinkButton } from './link-button.js'; // tslint:disable-next-line:enforce-comments-on-exported-symbols export class TonalLinkButton extends LinkButton {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/tonal-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/tonal-styles.css.js index f479bd8..e7ef0052 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/tonal-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/lib/tonal-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-shape-start-start: var(--md-tonal-button-container-shape-start-start, 9999px);--_container-shape-start-end: var(--md-tonal-button-container-shape-start-end, 9999px);--_container-shape-end-end: var(--md-tonal-button-container-shape-end-end, 9999px);--_container-shape-end-start: var(--md-tonal-button-container-shape-end-start, 9999px);--_container-color: var(--md-tonal-button-container-color, var(--md-sys-color-secondary-container, #e8def8));--_container-elevation: var(--md-tonal-button-container-elevation, 0);--_container-height: var(--md-tonal-button-container-height, 40px);--_container-shadow-color: var(--md-tonal-button-container-shadow-color, var(--md-sys-color-shadow, #000));--_disabled-container-color: var(--md-tonal-button-disabled-container-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.12));--_disabled-container-elevation: var(--md-tonal-button-disabled-container-elevation, 0);--_disabled-label-text-color: var(--md-tonal-button-disabled-label-text-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_focus-container-elevation: var(--md-tonal-button-focus-container-elevation, 0);--_focus-label-text-color: var(--md-tonal-button-focus-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_focus-state-layer-color: var(--md-tonal-button-focus-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_focus-state-layer-opacity: var(--md-tonal-button-focus-state-layer-opacity, 0.12);--_hover-container-elevation: var(--md-tonal-button-hover-container-elevation, 1);--_hover-label-text-color: var(--md-tonal-button-hover-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_hover-state-layer-color: var(--md-tonal-button-hover-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_hover-state-layer-opacity: var(--md-tonal-button-hover-state-layer-opacity, 0.08);--_label-text-color: var(--md-tonal-button-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_label-text-font: var(--md-tonal-button-label-text-font, Roboto);--_label-text-line-height: var(--md-tonal-button-label-text-line-height, 1.25rem);--_label-text-size: var(--md-tonal-button-label-text-size, 0.875rem);--_label-text-tracking: var(--md-tonal-button-label-text-tracking, 0.006rem);--_label-text-type: var(--md-tonal-button-label-text-type, 500 0.875rem / 1.25rem Roboto);--_label-text-weight: var(--md-tonal-button-label-text-weight, 500);--_pressed-container-elevation: var(--md-tonal-button-pressed-container-elevation, 0);--_pressed-label-text-color: var(--md-tonal-button-pressed-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_pressed-state-layer-color: var(--md-tonal-button-pressed-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_pressed-state-layer-opacity: var(--md-tonal-button-pressed-state-layer-opacity, 0.12);--_with-icon-disabled-icon-color: var(--md-tonal-button-with-icon-disabled-icon-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_with-icon-focus-icon-color: var(--md-tonal-button-with-icon-focus-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_with-icon-hover-icon-color: var(--md-tonal-button-with-icon-hover-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_with-icon-icon-color: var(--md-tonal-button-with-icon-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_with-icon-icon-size: var(--md-tonal-button-with-icon-icon-size, 18px);--_with-icon-pressed-icon-color: var(--md-tonal-button-with-icon-pressed-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_spacing-leading: var(--md-tonal-button-spacing-leading, 24px);--_spacing-trailing: var(--md-tonal-button-spacing-trailing, 24px);--_with-icon-spacing-leading: var(--md-tonal-button-with-icon-spacing-leading, 16px);--_with-icon-spacing-trailing: var(--md-tonal-button-with-icon-spacing-trailing, 24px);--_with-trailing-icon-spacing-leading: var(--md-tonal-button-with-trailing-icon-spacing-leading, 24px);--_with-trailing-icon-spacing-trailing: var(--md-tonal-button-with-trailing-icon-spacing-trailing, 16px)}/*# sourceMappingURL=tonal-styles.css.map */ `; //# sourceMappingURL=tonal-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/outlined-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/outlined-button.js index 7614aa2..4e3c899 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/outlined-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/outlined-button.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { OutlinedButton } from './lib/outlined-button.js'; import { styles as outlinedStyles } from './lib/outlined-styles.css.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/outlined-link-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/outlined-link-button.js index 5c700af..281c239 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/outlined-link-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/outlined-link-button.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { OutlinedLinkButton } from './lib/outlined-link-button.js'; import { styles as outlinedStyles } from './lib/outlined-styles.css.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/text-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/text-button.js index 8b6aad3d..ea69474 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/text-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/text-button.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js'; import { TextButton } from './lib/text-button.js'; import { styles as textStyles } from './lib/text-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/text-link-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/text-link-button.js index e1289d5..5018b4d 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/text-link-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/text-link-button.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js'; import { TextLinkButton } from './lib/text-link-button.js'; import { styles as textStyles } from './lib/text-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/tonal-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/tonal-button.js index 9509297..a221f498 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/tonal-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/tonal-button.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles as sharedElevationStyles } from './lib/shared-elevation-styles.css.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js'; import { TonalButton } from './lib/tonal-button.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/tonal-link-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/tonal-link-button.js index 8186382..52b34ba 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/button/tonal-link-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/button/tonal-link-button.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles as sharedElevationStyles } from './lib/shared-elevation-styles.css.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js'; import { TonalLinkButton } from './lib/tonal-link-button.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/checkbox.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/checkbox.js index 75beb50..5218b88 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/checkbox.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/checkbox.js
@@ -3,8 +3,8 @@ * Copyright 2018 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { Checkbox } from './lib/checkbox.js'; import { styles } from './lib/checkbox-styles.css.js'; import { styles as forcedColorsStyles } from './lib/forced-colors-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/lib/checkbox-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/lib/checkbox-styles.css.js index 5cce271b2..d183f35 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/lib/checkbox-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/lib/checkbox-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-height: var(--md-checkbox-container-height, 18px);--_container-shape: var(--md-checkbox-container-shape, 2px);--_container-width: var(--md-checkbox-container-width, 18px);--_error-focus-state-layer-color: var(--md-checkbox-error-focus-state-layer-color, var(--md-sys-color-error, #b3261e));--_error-hover-state-layer-color: var(--md-checkbox-error-hover-state-layer-color, var(--md-sys-color-error, #b3261e));--_error-hover-state-layer-opacity: var(--md-checkbox-error-hover-state-layer-opacity, 0.08);--_error-pressed-state-layer-color: var(--md-checkbox-error-pressed-state-layer-color, var(--md-sys-color-error, #b3261e));--_error-pressed-state-layer-opacity: var(--md-checkbox-error-pressed-state-layer-opacity, 0.12);--_icon-size: var(--md-checkbox-icon-size, 18px);--_selected-container-color: var(--md-checkbox-selected-container-color, var(--md-sys-color-primary, #6750a4));--_selected-disabled-container-color: var(--md-checkbox-selected-disabled-container-color, var(--md-sys-color-on-surface, #1c1b1f));--_selected-disabled-container-opacity: var(--md-checkbox-selected-disabled-container-opacity, 0.38);--_selected-disabled-icon-color: var(--md-checkbox-selected-disabled-icon-color, var(--md-sys-color-surface, #fffbfe));--_selected-error-container-color: var(--md-checkbox-selected-error-container-color, var(--md-sys-color-error, #b3261e));--_selected-error-focus-container-color: var(--md-checkbox-selected-error-focus-container-color, var(--md-sys-color-error, #b3261e));--_selected-error-focus-icon-color: var(--md-checkbox-selected-error-focus-icon-color, var(--md-sys-color-on-error, #fff));--_selected-error-hover-container-color: var(--md-checkbox-selected-error-hover-container-color, var(--md-sys-color-error, #b3261e));--_selected-error-hover-icon-color: var(--md-checkbox-selected-error-hover-icon-color, var(--md-sys-color-on-error, #fff));--_selected-error-icon-color: var(--md-checkbox-selected-error-icon-color, var(--md-sys-color-on-error, #fff));--_selected-error-pressed-container-color: var(--md-checkbox-selected-error-pressed-container-color, var(--md-sys-color-error, #b3261e));--_selected-error-pressed-icon-color: var(--md-checkbox-selected-error-pressed-icon-color, var(--md-sys-color-on-error, #fff));--_selected-focus-container-color: var(--md-checkbox-selected-focus-container-color, var(--md-sys-color-primary, #6750a4));--_selected-focus-icon-color: var(--md-checkbox-selected-focus-icon-color, var(--md-sys-color-on-primary, #fff));--_selected-focus-state-layer-color: var(--md-checkbox-selected-focus-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-focus-state-layer-opacity: var(--md-checkbox-selected-focus-state-layer-opacity, 0.12);--_selected-hover-container-color: var(--md-checkbox-selected-hover-container-color, var(--md-sys-color-primary, #6750a4));--_selected-hover-icon-color: var(--md-checkbox-selected-hover-icon-color, var(--md-sys-color-on-primary, #fff));--_selected-hover-state-layer-color: var(--md-checkbox-selected-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-hover-state-layer-opacity: var(--md-checkbox-selected-hover-state-layer-opacity, 0.08);--_selected-icon-color: var(--md-checkbox-selected-icon-color, var(--md-sys-color-on-primary, #fff));--_selected-pressed-container-color: var(--md-checkbox-selected-pressed-container-color, var(--md-sys-color-primary, #6750a4));--_selected-pressed-icon-color: var(--md-checkbox-selected-pressed-icon-color, var(--md-sys-color-on-primary, #fff));--_selected-pressed-state-layer-color: var(--md-checkbox-selected-pressed-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_selected-pressed-state-layer-opacity: var(--md-checkbox-selected-pressed-state-layer-opacity, 0.12);--_state-layer-shape: var(--md-checkbox-state-layer-shape, 9999px);--_state-layer-size: var(--md-checkbox-state-layer-size, 40px);--_unselected-disabled-container-opacity: var(--md-checkbox-unselected-disabled-container-opacity, 0.38);--_unselected-disabled-outline-color: var(--md-checkbox-unselected-disabled-outline-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-disabled-outline-width: var(--md-checkbox-unselected-disabled-outline-width, 2px);--_unselected-error-focus-outline-color: var(--md-checkbox-unselected-error-focus-outline-color, var(--md-sys-color-error, #b3261e));--_unselected-error-focus-outline-width: var(--md-checkbox-unselected-error-focus-outline-width, 2px);--_unselected-error-hover-outline-color: var(--md-checkbox-unselected-error-hover-outline-color, var(--md-sys-color-error, #b3261e));--_unselected-error-hover-outline-width: var(--md-checkbox-unselected-error-hover-outline-width, 2px);--_unselected-error-outline-color: var(--md-checkbox-unselected-error-outline-color, var(--md-sys-color-error, #b3261e));--_unselected-error-pressed-outline-color: var(--md-checkbox-unselected-error-pressed-outline-color, var(--md-sys-color-error, #b3261e));--_unselected-error-pressed-outline-width: var(--md-checkbox-unselected-error-pressed-outline-width, 2px);--_unselected-focus-outline-color: var(--md-checkbox-unselected-focus-outline-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-focus-outline-width: var(--md-checkbox-unselected-focus-outline-width, 2px);--_unselected-focus-state-layer-color: var(--md-checkbox-unselected-focus-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-focus-state-layer-opacity: var(--md-checkbox-unselected-focus-state-layer-opacity, 0.12);--_unselected-hover-outline-color: var(--md-checkbox-unselected-hover-outline-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-hover-outline-width: var(--md-checkbox-unselected-hover-outline-width, 2px);--_unselected-hover-state-layer-color: var(--md-checkbox-unselected-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-hover-state-layer-opacity: var(--md-checkbox-unselected-hover-state-layer-opacity, 0.08);--_unselected-outline-color: var(--md-checkbox-unselected-outline-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-outline-width: var(--md-checkbox-unselected-outline-width, 2px);--_unselected-pressed-outline-color: var(--md-checkbox-unselected-pressed-outline-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-pressed-outline-width: var(--md-checkbox-unselected-pressed-outline-width, 2px);--_unselected-pressed-state-layer-color: var(--md-checkbox-unselected-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_unselected-pressed-state-layer-opacity: var(--md-checkbox-unselected-pressed-state-layer-opacity, 0.12);border-radius:var(--_container-shape);display:inline-flex;height:48px;position:relative;vertical-align:top;width:48px;-webkit-tap-highlight-color:rgba(0,0,0,0)}input{appearance:none;inset:0;margin:0;outline:none;position:absolute;opacity:0;block-size:100%;inline-size:100%}.container{border-radius:inherit;height:100%;position:relative;width:100%}.outline,.background,md-ripple,.icon{inset:0;margin:auto;position:absolute}.outline,.background{border-radius:inherit;height:var(--_container-height);width:var(--_container-width)}.outline{border-color:var(--_unselected-outline-color);border-style:solid;border-width:var(--_unselected-outline-width);box-sizing:border-box}.background{background-color:var(--_selected-container-color)}.background,.icon{opacity:0;transition-duration:150ms,50ms;transition-property:transform,opacity;transition-timing-function:cubic-bezier(0.3, 0, 0.8, 0.15),linear;transform:scale(0.6)}.selected .background,.selected .icon{opacity:1;transition-duration:350ms,50ms;transition-timing-function:cubic-bezier(0.05, 0.7, 0.1, 1),linear;transform:scale(1)}md-focus-ring{--md-focus-ring-shape-start-start:9999px;--md-focus-ring-shape-start-end:9999px;--md-focus-ring-shape-end-end:9999px;--md-focus-ring-shape-end-start:9999px;--md-focus-ring-offset-vertical:-2px;--md-focus-ring-offset-horizontal:-2px}md-ripple{height:var(--_state-layer-size);width:var(--_state-layer-size);--md-ripple-focus-state-layer-color:var(--_unselected-focus-state-layer-color);--md-ripple-focus-state-layer-opacity:var(--_unselected-focus-state-layer-opacity);--md-ripple-hover-state-layer-color:var(--_unselected-hover-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_unselected-hover-state-layer-opacity);--md-ripple-pressed-state-layer-color:var(--_unselected-pressed-state-layer-color);--md-ripple-pressed-state-layer-opacity:var(--_unselected-pressed-state-layer-opacity);--md-ripple-state-layer-shape:var(--_state-layer-shape)}.selected md-ripple{--md-ripple-focus-state-layer-color:var(--_selected-focus-state-layer-color);--md-ripple-focus-state-layer-opacity:var(--_selected-focus-state-layer-opacity);--md-ripple-hover-state-layer-color:var(--_selected-hover-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_selected-hover-state-layer-opacity);--md-ripple-pressed-state-layer-color:var(--_selected-pressed-state-layer-color);--md-ripple-pressed-state-layer-opacity:var(--_selected-pressed-state-layer-opacity)}.error md-ripple{--md-ripple-focus-state-layer-color:var(--_error-focus-state-layer-color);--md-ripple-hover-state-layer-color:var(--_error-hover-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_error-hover-state-layer-opacity);--md-ripple-pressed-state-layer-color:var(--_error-pressed-state-layer-color);--md-ripple-pressed-state-layer-opacity:var(--_error-pressed-state-layer-opacity)}.icon{fill:var(--_selected-icon-color);height:var(--_icon-size);width:var(--_icon-size)}.mark.short{height:2px;transition-property:transform,height;width:2px}.mark.long{height:2px;transition-property:transform,width;width:10px}.mark{animation-duration:150ms;animation-timing-function:cubic-bezier(0.3, 0, 0.8, 0.15);transition-duration:150ms;transition-timing-function:cubic-bezier(0.3, 0, 0.8, 0.15)}.selected .mark{animation-duration:350ms;animation-timing-function:cubic-bezier(0.05, 0.7, 0.1, 1);transition-duration:350ms;transition-timing-function:cubic-bezier(0.05, 0.7, 0.1, 1)}.checked .mark,.prev-checked.unselected .mark{transform:scaleY(-1) translate(7px, -14px) rotate(45deg)}.checked .mark.short,.prev-checked.unselected .mark.short{height:5.6568542495px}.checked .mark.long,.prev-checked.unselected .mark.long{width:11.313708499px}.indeterminate .mark,.prev-indeterminate.unselected .mark{transform:scaleY(-1) translate(4px, -10px) rotate(0deg)}.prev-unselected .mark{transition-property:none}.prev-unselected.checked .mark.long{animation-name:prev-unselected-to-checked}@keyframes prev-unselected-to-checked{from{width:0}}.error .outline{border-color:var(--_unselected-error-outline-color)}.error .background{background:var(--_selected-error-container-color)}.error .icon{fill:var(--_selected-error-icon-color)}:host(:hover) .outline{border-color:var(--_unselected-hover-outline-color);border-width:var(--_unselected-hover-outline-width)}:host(:hover) .background{background:var(--_selected-hover-container-color)}:host(:hover) .icon{fill:var(--_selected-hover-icon-color)}:host(:hover) .error .outline{border-color:var(--_unselected-error-hover-outline-color);border-width:var(--_unselected-error-hover-outline-width)}:host(:hover) .error .background{background:var(--_selected-error-hover-container-color)}:host(:hover) .error .icon{fill:var(--_selected-error-hover-icon-color)}:host(:focus-within) .outline{border-color:var(--_unselected-focus-outline-color);border-width:var(--_unselected-focus-outline-width)}:host(:focus-within) .background{background:var(--_selected-focus-container-color)}:host(:focus-within) .icon{fill:var(--_selected-focus-icon-color)}:host(:focus-within) .error .outline{border-color:var(--_unselected-error-focus-outline-color);border-width:var(--_unselected-error-focus-outline-width)}:host(:focus-within) .error .background{background:var(--_selected-error-focus-container-color)}:host(:focus-within) .error .icon{fill:var(--_selected-error-focus-icon-color)}:host(:active) .outline{border-color:var(--_unselected-pressed-outline-color);border-width:var(--_unselected-pressed-outline-width)}:host(:active) .background{background:var(--_selected-pressed-container-color)}:host(:active) .icon{fill:var(--_selected-pressed-icon-color)}:host(:active) .error .outline{border-color:var(--_unselected-error-pressed-outline-color);border-width:var(--_unselected-error-pressed-outline-width)}:host(:active) .error .background{background:var(--_selected-error-pressed-container-color)}:host(:active) .error .icon{fill:var(--_selected-error-pressed-icon-color)}:host([disabled]) .background,:host([disabled]) .icon,:host([disabled]) .mark,.prev-disabled .background,.prev-disabled .icon,.prev-disabled .mark{animation-duration:0s;transition-duration:0s}:host([disabled]) .outline{border-color:var(--_unselected-disabled-outline-color);border-width:var(--_unselected-disabled-outline-width);opacity:var(--_unselected-disabled-container-opacity)}:host([disabled]) .selected .outline{visibility:hidden}:host([disabled]) .selected .background{background:var(--_selected-disabled-container-color);opacity:var(--_selected-disabled-container-opacity)}:host([disabled]) .icon{fill:var(--_selected-disabled-icon-color)}/*# sourceMappingURL=checkbox-styles.css.map */ `; //# sourceMappingURL=checkbox-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/lib/checkbox.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/lib/checkbox.js index 3581049..233cd01 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/lib/checkbox.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/lib/checkbox.js
@@ -3,13 +3,13 @@ * Copyright 2019 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; import '../../focus/focus-ring.js'; import '../../ripple/ripple.js'; -import { html, LitElement, nothing } from '../../../../lit/index.js'; -import { property, query, queryAsync, state } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { when } from '../../../../lit/directives/when.js'; +import { html, LitElement, nothing } from 'lit'; +import { property, query, queryAsync, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { when } from 'lit/directives/when.js'; import { dispatchActivationClick, isActivationClick, redispatchEvent } from '../../controller/events.js'; import { FormController, getFormValue } from '../../controller/form-controller.js'; import { stringConverter } from '../../controller/string-converter.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/lib/forced-colors-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/lib/forced-colors-styles.css.js index 14348f30..6e21f69f 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/lib/forced-colors-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/checkbox/lib/forced-colors-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `@media(forced-colors: active){:host{--md-checkbox-selected-container-color:CanvasText;--md-checkbox-selected-disabled-container-color:GrayText;--md-checkbox-selected-disabled-container-opacity:1;--md-checkbox-selected-disabled-icon-color:Canvas;--md-checkbox-selected-error-container-color:CanvasText;--md-checkbox-selected-error-focus-container-color:CanvasText;--md-checkbox-selected-error-focus-icon-color:Canvas;--md-checkbox-selected-error-hover-container-color:CanvasText;--md-checkbox-selected-error-hover-icon-color:Canvas;--md-checkbox-selected-error-icon-color:Canvas;--md-checkbox-selected-error-pressed-container-color:CanvasText;--md-checkbox-selected-error-pressed-icon-color:Canvas;--md-checkbox-selected-focus-container-color:CanvasText;--md-checkbox-selected-focus-icon-color:Canvas;--md-checkbox-selected-hover-container-color:CanvasText;--md-checkbox-selected-hover-icon-color:Canvas;--md-checkbox-selected-icon-color:Canvas;--md-checkbox-selected-pressed-container-color:CanvasText;--md-checkbox-selected-pressed-icon-color:Canvas;--md-checkbox-unselected-disabled-container-opacity:1;--md-checkbox-unselected-disabled-outline-color:GrayText;--md-checkbox-unselected-error-focus-outline-color:CanvasText;--md-checkbox-unselected-error-hover-outline-color:CanvasText;--md-checkbox-unselected-error-outline-color:CanvasText;--md-checkbox-unselected-error-pressed-outline-color:CanvasText;--md-checkbox-unselected-focus-outline-color:CanvasText;--md-checkbox-unselected-hover-outline-color:CanvasText;--md-checkbox-unselected-outline-color:CanvasText;--md-checkbox-unselected-pressed-outline-color:CanvasText}}/*# sourceMappingURL=forced-colors-styles.css.map */ `; //# sourceMappingURL=forced-colors-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/delete-action.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/delete-action.js index 30392f9..d82fb9c 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/delete-action.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/delete-action.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../../tslib/tslib.js'; -import { customElement } from '../../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { DeleteAction } from './lib/delete-action.js'; /** * @soyCompatible
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/action.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/action.js index 9c50584..613def5e 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/action.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/action.js
@@ -3,12 +3,12 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; import '../../../focus/focus-ring.js'; import '../../../ripple/ripple.js'; -import { html } from '../../../../../lit/index.js'; -import { property, query, state } from '../../../../../lit/decorators.js'; -import { classMap } from '../../../../../lit/directives/class-map.js'; +import { html } from 'lit'; +import { property, query, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; import { ActionElement } from '../../../actionelement/action-element.js'; import { ariaProperty } from '../../../decorators/aria-property.js'; import { pointerPress, shouldShowStrongFocus } from '../../../focus/strong-focus.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/delete-action.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/delete-action.js index 144a7bab..1e527662 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/delete-action.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/delete-action.js
@@ -3,9 +3,9 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { html } from '../../../../../lit/index.js'; -import { classMap } from '../../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../../lit/directives/if-defined.js'; +import { html } from 'lit'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { Action } from './action.js'; import { Md3ChipActionEventType } from './events.js'; /** @soyCompatible */
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/link-action.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/link-action.js index 47d0081..ba85ba6 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/link-action.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/link-action.js
@@ -3,11 +3,11 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; -import { html } from '../../../../../lit/index.js'; -import { property } from '../../../../../lit/decorators.js'; -import { classMap } from '../../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../../lit/directives/if-defined.js'; +import { __decorate, __metadata } from "tslib"; +import { html } from 'lit'; +import { property } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { PrimaryAction } from './primary-action.js'; /** @soyCompatible */ export class LinkAction extends PrimaryAction {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/presentational-action.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/presentational-action.js index f24cd0b3..0d6e084 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/presentational-action.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/presentational-action.js
@@ -3,9 +3,9 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { html } from '../../../../../lit/index.js'; -import { classMap } from '../../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../../lit/directives/if-defined.js'; +import { html } from 'lit'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { PrimaryAction } from './primary-action.js'; /** @soyCompatible */ export class PresentationalAction extends PrimaryAction {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/primary-action.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/primary-action.js index 1e8ff958..5ee8f398 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/primary-action.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/primary-action.js
@@ -3,11 +3,11 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; -import { html } from '../../../../../lit/index.js'; -import { property } from '../../../../../lit/decorators.js'; -import { classMap } from '../../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../../lit/directives/if-defined.js'; +import { __decorate, __metadata } from "tslib"; +import { html } from 'lit'; +import { property } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { Action } from './action.js'; /** * Base class for all primary actions: Presentational, Selectable, Link
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/selectable-action.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/selectable-action.js index 074c24a6..e45787d 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/selectable-action.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/lib/selectable-action.js
@@ -3,11 +3,11 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; -import { html } from '../../../../../lit/index.js'; -import { property } from '../../../../../lit/decorators.js'; -import { classMap } from '../../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../../lit/directives/if-defined.js'; +import { __decorate, __metadata } from "tslib"; +import { html } from 'lit'; +import { property } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { PrimaryAction } from './primary-action.js'; /** @soyCompatible */ export class SelectableAction extends PrimaryAction {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/link-action.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/link-action.js index a67e9a346..c277c2c 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/link-action.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/link-action.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../../tslib/tslib.js'; -import { customElement } from '../../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { LinkAction } from './lib/link-action.js'; /** * @soyCompatible
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/presentational-action.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/presentational-action.js index ccaf7f7..cfd0558f 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/presentational-action.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/presentational-action.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../../tslib/tslib.js'; -import { customElement } from '../../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { PresentationalAction } from './lib/presentational-action.js'; /** * @soyCompatible
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/primary-action.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/primary-action.js index 58979ede..cf4925d 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/primary-action.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/primary-action.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../../tslib/tslib.js'; -import { customElement } from '../../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { PrimaryAction } from './lib/primary-action.js'; /** * @soyCompatible
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/selectable-action.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/selectable-action.js index 816a426..26c0a99 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/selectable-action.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/action/selectable-action.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../../tslib/tslib.js'; -import { customElement } from '../../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { SelectableAction } from './lib/selectable-action.js'; /** * @soyCompatible
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/action-chip.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/action-chip.js index 023d43e..47570f9 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/action-chip.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/action-chip.js
@@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ import '../../action/primary-action.js'; -import { html } from '../../../../../lit/index.js'; -import { classMap } from '../../../../../lit/directives/class-map.js'; +import { html } from 'lit'; +import { classMap } from 'lit/directives/class-map.js'; import { Chip } from './chip.js'; /** @soyCompatible */ export class ActionChip extends Chip {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/chip.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/chip.js index b1da9635..495949a 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/chip.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/chip.js
@@ -3,11 +3,11 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; import '../../../elevation/elevation.js'; import '../../action/delete-action.js'; -import { html } from '../../../../../lit/index.js'; -import { property } from '../../../../../lit/decorators.js'; +import { html } from 'lit'; +import { property } from 'lit/decorators.js'; import { ActionElement } from '../../../actionelement/action-element.js'; import { ariaProperty } from '../../../decorators/aria-property.js'; /** Defines the border type of a chip. */
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/link-chip.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/link-chip.js index fdd0c121..0f75c314e 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/link-chip.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/link-chip.js
@@ -3,12 +3,12 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; // import '@material/web/chips/action.js'; import '../../action/link-action.js'; -import { html } from '../../../../../lit/index.js'; -import { property } from '../../../../../lit/decorators.js'; -import { classMap } from '../../../../../lit/directives/class-map.js'; +import { html } from 'lit'; +import { property } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; import { Chip } from './chip.js'; /** @soyCompatible */ export class LinkChip extends Chip {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/presentational-chip.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/presentational-chip.js index f4f4256..d1a1df88 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/presentational-chip.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/presentational-chip.js
@@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ import '../../action/presentational-action.js'; -import { html } from '../../../../../lit/index.js'; -import { classMap } from '../../../../../lit/directives/class-map.js'; +import { html } from 'lit'; +import { classMap } from 'lit/directives/class-map.js'; import { Chip } from './chip.js'; /** @soyCompatible */ export class PresentationalChip extends Chip {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/selectable-chip.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/selectable-chip.js index 6e668d8..34e5dec5 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/selectable-chip.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/chips/chip/lib/selectable-chip.js
@@ -3,11 +3,11 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; import '../../action/selectable-action.js'; -import { html } from '../../../../../lit/index.js'; -import { property } from '../../../../../lit/decorators.js'; -import { classMap } from '../../../../../lit/directives/class-map.js'; +import { html } from 'lit'; +import { property } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; import { Chip } from './chip.js'; /** @soyCompatible */ export class SelectableChip extends Chip {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/controller/form-controller.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/controller/form-controller.js index c863c52..8a46435 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/controller/form-controller.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/controller/form-controller.js
@@ -3,7 +3,7 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; import { bound } from '../decorators/bound.js'; import { isFormAssociated } from './form-associated.js'; import { shimLabelSupport, SUPPORTS_FACE_LABEL } from './shim-label-activation.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/dialog/dialog.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/dialog/dialog.js index ea71061c..d5d361b 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/dialog/dialog.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/dialog/dialog.js
@@ -3,8 +3,8 @@ * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { Dialog } from './lib/dialog.js'; import { styles } from './lib/dialog-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/dialog/lib/dialog-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/dialog/lib/dialog-styles.css.js index f429d0a..5c0ab8b2 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/dialog/lib/dialog-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/dialog/lib/dialog-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-color: var(--md-dialog-container-color, var(--md-sys-color-surface, #fffbfe));--_container-elevation: var(--md-dialog-container-elevation, 6);--_container-shape: var(--md-dialog-container-shape, 28px);--_container-surface-tint-layer-color: var(--md-dialog-container-surface-tint-layer-color, var(--md-sys-color-primary, #6750a4));--_headline-color: var(--md-dialog-headline-color, var(--md-sys-color-on-surface, #1c1b1f));--_headline-font: var(--md-dialog-headline-font, Roboto);--_headline-line-height: var(--md-dialog-headline-line-height, 2rem);--_headline-size: var(--md-dialog-headline-size, 1.5rem);--_headline-tracking: var(--md-dialog-headline-tracking, 0rem);--_headline-weight: var(--md-dialog-headline-weight, 400);--_supporting-text-color: var(--md-dialog-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_supporting-text-font: var(--md-dialog-supporting-text-font, Roboto);--_supporting-text-line-height: var(--md-dialog-supporting-text-line-height, 1.25rem);--_supporting-text-size: var(--md-dialog-supporting-text-size, 0.875rem);--_supporting-text-tracking: var(--md-dialog-supporting-text-tracking, 0.016rem);--_supporting-text-weight: var(--md-dialog-supporting-text-weight, 400);--_with-icon-icon-color: var(--md-dialog-with-icon-icon-color, var(--md-sys-color-secondary, #625b71));--_with-icon-icon-size: var(--md-dialog-with-icon-icon-size, 24px);--_container-max-inline-size: var(--md-dialog-container-max-inline-size, min(560px, 100% - 48px));--_container-min-inline-size: var(--md-dialog-container-min-inline-size, 280px);--_container-max-block-size: var(--md-dialog-container-max-block-size, min(560px, 100% - 48px));--_container-min-block-size: var(--md-dialog-container-min-block-size, 140px);--_container-inset-inline-start: var(--md-dialog-container-inset-inline-start, auto);--_container-inset-inline-end: var(--md-dialog-container-inset-inline-end, auto);--_container-inset-block-start: var(--md-dialog-container-inset-block-start, auto);--_container-inset-block-end: var(--md-dialog-container-inset-block-end, auto);--_opening-transition-duration: var(--md-dialog-opening-transition-duration, 400ms);--_opening-transition-easing: var(--md-dialog-opening-transition-easing, cubic-bezier(0.05, 0.7, 0.1, 1));--_closing-transition-duration: var(--md-dialog-closing-transition-duration, 200ms);--_closing-transition-easing: var(--md-dialog-closing-transition-easing, cubic-bezier(0.3, 0, 0.8, 0.15));--_scrim-color: var(--md-dialog-scrim-color, rgba(0, 0, 0, 0.32));--_container-block-padding: var(--md-dialog-container-block-padding, 24px);--_container-inline-padding: var(--md-dialog-container-inline-padding, 24px);--_header-spacing: var(--md-dialog-header-spacing, 16px);--_action-spacing: var(--md-dialog-action-spacing, 8px);--_content-block-start-spacing: var(--md-dialog-content-block-start-spacing, 16px);--_content-block-end-spacing: var(--md-dialog-content-block-end-spacing, 24px);--_with-divider-divider-height: var(--md-dialog-with-divider-divider-height, 1px);--_with-divider-divider-color: var(--md-dialog-with-divider-divider-color, var(--md-sys-color-outline, #79747e));--_fullscreen-header-block-size: var(--md-dialog-fullscreen-header-block-size, 56px);--_fullscreen-footer-block-size: var(--md-dialog-fullscreen-footer-block-size, 56px);--_fullscreen-container-block-padding: var(--md-dialog-fullscreen-container-block-padding, 8px);--_container-drag-inline-start: initial;--_container-drag-block-start: initial}@media(prefers-reduced-motion: reduce){:host{--_opening-transition-duration: 0;--_closing-transition-duration: 0}}.dialog{position:fixed;align-items:center;justify-content:center;box-sizing:border-box;inset:0;block-size:100vh;inline-size:100vw;max-block-size:100vh;max-inline-size:100vw;border:none;background:rgba(0,0,0,0);padding:0;margin:0;overflow:clip}.dialog:not(:modal){z-index:10000;pointer-events:none}.dialog[open]{display:flex}.dialog::backdrop{background:none}.dialog::before{content:"";position:absolute;z-index:-1;inset:0;block-size:100vh;inline-size:100vw;pointer-events:none}:host([modeless]) .dialog:before{display:none}.container{position:absolute;inset-inline-start:var(--_container-drag-inline-start, var(--_container-inset-inline-start));inset-inline-end:var(--_container-inset-inline-end);inset-block-start:var(--_container-drag-block-start, var(--_container-inset-block-start));inset-block-end:var(--_container-inset-block-end);background-color:var(--_container-color);border-radius:var(--_container-shape);display:flex;flex-direction:column;box-sizing:border-box;pointer-events:auto;min-block-size:var(--_container-min-block-size);max-block-size:var(--_container-max-block-size);min-inline-size:var(--_container-min-inline-size);max-inline-size:var(--_container-max-inline-size);padding-block-start:var(--_container-block-padding);padding-block-end:var(--_container-block-padding)}md-elevation{position:absolute;inset:0;pointer-events:none;border-radius:inherit;--md-elevation-level: var(--_container-elevation);--md-elevation-surface-tine-color: var( --_container-surface-tint-layer-color )}.container>*{box-sizing:border-box;padding-inline-start:var(--_container-inline-padding);padding-inline-end:var(--_container-inline-padding)}.header{display:flex;flex-direction:column;align-items:center;gap:var(--_header-spacing);-webkit-font-smoothing:antialiased;color:var(--_headline-color);font-family:var(--_headline-font);line-height:var(--_headline-line-height);font-size:var(--_headline-size);letter-spacing:var(--_headline-tracking);font-weight:var(--_headline-weight)}.content{flex:1;overflow:auto;margin-block-start:var(--_content-block-start-spacing);margin-block-end:var(--_content-block-end-spacing);-webkit-font-smoothing:antialiased;color:var(--_supporting-text-color);font-family:var(--_supporting-text-font);line-height:var(--_supporting-text-line-height);font-size:var(--_supporting-text-size);letter-spacing:var(--_supporting-text-tracking);font-weight:var(--_supporting-text-weight)}.footer{display:flex;position:relative;flex-wrap:wrap;align-items:center;justify-content:flex-end;box-sizing:border-box;gap:var(--_action-spacing)}.footerHidden{--_content-block-end-spacing: 0px}.footerHidden .footer{display:none}.stacked .footer{flex-direction:column;align-items:flex-end}.scrollable .content{border-block-start:var(--_with-divider-divider-height) solid rgba(0,0,0,0);border-block-end:var(--_with-divider-divider-height) solid rgba(0,0,0,0)}.scroll-divider-header .content{border-block-start-color:var(--_with-divider-divider-color)}.scroll-divider-footer:not(.footerHidden) .content{border-block-end-color:var(--_with-divider-divider-color)}.dragging{user-select:none;cursor:move;touch-action:none}.container{will-change:transform,opacity;transition-property:transform;overflow:hidden}.container>*{transition-timing-function:inherit;transition-duration:inherit;transition-property:opacity,transform;will-change:transform,opacity;opacity:0}:host([transition][showing-open]) .container>*{opacity:1;transform:none}:host([transition][showing-open]) .container{opacity:1;transform:none}.dialog::before{transition:background-color linear;background-color:rgba(0,0,0,0)}:host([showing-open]) .dialog::before{background-color:var(--_scrim-color)}:host([opening]) .dialog::before{transition-duration:calc(var(--_opening-transition-duration)/2)}:host([closing]) .dialog::before{transition-duration:calc(var(--_closing-transition-duration)/2)}:host([opening]) .container{transition-duration:var(--_opening-transition-duration);transition-timing-function:var(--_opening-transition-easing)}:host([closing]) .container{transition-duration:var(--_closing-transition-duration);transition-timing-function:var(--_closing-transition-easing)}:host([trasition][closing]) .container>*{transform:none;opacity:0}:host([transition=grow-down]){--_opening-transform: scale(1, 0.1) translateY(-20%);--_closing-transform: scale(1, 0.9) translateY(-10%);--_origin: top;--_opening-content-transform: scale(1, 2);--_origin-footer: bottom}:host([transition=grow-up]){--_opening-transform: scale(1, 0.1) translateY(20%);--_closing-transform: scale(1, 0.9) translateY(10%);--_origin: bottom;--_opening-content-transform: scale(1, 2);--_origin-footer: bottom}:host([transition=grow-left]){--_opening-transform: scale(0.1, 1) translateX(20%);--_closing-transform: scale(0.9, 1) translateX(10%);--_origin: right;--_opening-content-transform: none;--_origin-footer: none}:host([transition=grow-right]){--_opening-transform: scale(0.1, 1) translateX(-20%);--_closing-transform: scale(0.9, 1) translateX(-10%);--_origin: left;--_opening-content-transform: none;--_origin-footer: none}:host([transition^=grow-]) .container{transform-origin:var(--_origin);transform:var(--_opening-transform)}:host([transition^=grow-]) .container>*{transform-origin:var(--_origin);transform:var(--_opening-content-transform)}:host([transition^=grow-]) .footer{transform-origin:var(--_origin-footer)}:host([transition^=grow-][closing]){transform:var(--_closing-transform)}:host([transition=shrink]) .container{transform:scale(1.2)}:host([transition=grow]) .container{transform:scale(0.8)}:host([transition=shrink][closing]) .container,:host([transition=grow][closing]) .container{transition-duration:0;transform:none}:host([showing-fullscreen]){--_container-max-block-size: none;--_container-max-inline-size: none}:host([showing-fullscreen]) .container{block-size:100vh;inline-size:100vw;border-radius:0px;padding-block-start:0;padding-block-end:0}:host([showing-fullscreen]) .header{justify-content:space-between;flex-direction:row;max-block-size:var(--_fullscreen-header-block-size);padding-block-start:var(--_fullscreen-container-block-padding);padding-inline:4px;--_header-spacing: 4px}:host([showing-fullscreen]) .content{margin-block-start:0;margin-block-end:0}:host([showing-fullscreen]) .footer{max-block-size:var(--_fullscreen-footer-block-size);padding-block-end:var(--_fullscreen-container-block-padding)}:host([showing-fullscreen]) .scroll-divider-footer .content{border-block-end-color:rgba(0,0,0,0)}@media screen and (forced-colors: active),(-ms-high-contrast: active){.container{outline:windowtext solid 2px}}[name=headline-prefix]::slotted(*),[name=headline-suffix]::slotted(*){color:var(--_with-icon-icon-color);font-size:var(--_with-icon-icon-size)}[name=header]::slotted(*){flex:1;align-self:stretch;display:flex;align-items:center}:host([showing-fullscreen]) [name=headline]::slotted(*){flex:1}/*# sourceMappingURL=dialog-styles.css.map */ `; //# sourceMappingURL=dialog-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/dialog/lib/dialog.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/dialog/lib/dialog.js index a8d313b..759ed166 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/dialog/lib/dialog.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/dialog/lib/dialog.js
@@ -3,11 +3,11 @@ * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; import '../../elevation/elevation.js'; -import { html, LitElement } from '../../../../lit/index.js'; -import { property, query, state } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; +import { html, LitElement } from 'lit'; +import { property, query, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; import { createThrottle, msFromTimeCSSValue } from '../../motion/animation.js'; // This is required for decorators. // tslint:disable:no-new-decorators
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/divider/divider.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/divider/divider.js index 1213bdb..686b4dc5 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/divider/divider.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/divider/divider.js
@@ -3,8 +3,8 @@ * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { Divider } from './lib/divider.js'; import { styles } from './lib/divider-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/divider/lib/divider-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/divider/lib/divider-styles.css.js index d8add9d..a9b8ab2 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/divider/lib/divider-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/divider/lib/divider-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_color: var(--md-divider-color, var(--md-sys-color-outline-variant, #cac4d0));--_thickness: var(--md-divider-thickness, 1px);box-sizing:border-box;color:var(--_color);display:flex;height:var(--_thickness);width:100%}:host([inset]),:host([inset-start]){padding-inline-start:16px}:host([inset]),:host([inset-end]){padding-inline-end:16px}:host::before{background:currentColor;content:"";height:100%;width:100%}@media(forced-colors: active){:host::before{background:CanvasText}}/*# sourceMappingURL=divider-styles.css.map */ `; //# sourceMappingURL=divider-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/divider/lib/divider.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/divider/lib/divider.js index 9c8a6f3..4b29fa5 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/divider/lib/divider.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/divider/lib/divider.js
@@ -3,9 +3,9 @@ * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; -import { LitElement } from '../../../../lit/index.js'; -import { property } from '../../../../lit/decorators.js'; +import { __decorate, __metadata } from "tslib"; +import { LitElement } from 'lit'; +import { property } from 'lit/decorators.js'; /** * A divider component. */
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/elevation/elevation.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/elevation/elevation.js index ac306ea7..62500e9 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/elevation/elevation.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/elevation/elevation.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { Elevation } from './lib/elevation.js'; import { styles } from './lib/elevation-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/elevation/lib/elevation-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/elevation/lib/elevation-styles.css.js index e1181ae..546ef36 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/elevation/lib/elevation-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/elevation/lib/elevation-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_duration: var(--md-elevation-duration, 0s);--_easing: var(--md-elevation-easing, cubic-bezier(0.2, 0, 0, 1));--_level: var(--md-elevation-level, 0);--_shadow-color: var(--md-elevation-shadow-color, var(--md-sys-color-shadow, #000));--_surface-tint: var(--md-elevation-surface-tint, var(--md-sys-color-primary, #6750a4));border-radius:inherit;display:flex;position:relative}:host(:not([surface])) .surface,:host(:not([shadow])) .shadow{display:none}.surface,.shadow,.shadow::before,.shadow::after{border-radius:inherit;content:"";inset:0;position:absolute;transition-property:box-shadow,opacity;transition-duration:var(--_duration);transition-timing-function:var(--_easing)}.shadow::before{box-shadow:0px calc(1px*(clamp(0,var(--_level),1) + clamp(0,var(--_level) - 3,1) + 2*clamp(0,var(--_level) - 4,1))) calc(1px*(2*clamp(0,var(--_level),1) + clamp(0,var(--_level) - 2,1) + clamp(0,var(--_level) - 4,1))) 0px var(--_shadow-color);opacity:.3}.shadow::after{opacity:.15;box-shadow:0px calc(1px*(clamp(0,var(--_level),1) + clamp(0,var(--_level) - 1,1) + 2*clamp(0,var(--_level) - 2,3))) calc(1px*(3*clamp(0,var(--_level),2) + 2*clamp(0,var(--_level) - 2,3))) calc(1px*(clamp(0,var(--_level),4) + 2*clamp(0,var(--_level) - 4,1))) var(--_shadow-color)}.surface{background:var(--_surface-tint);opacity:calc(clamp(0,var(--_level),.05) + clamp(0,var(--_level) - 1,.03) + clamp(0,var(--_level) - 2,.03) + clamp(0,var(--_level) - 3,.01) + clamp(0,var(--_level) - 4,.02))}/*# sourceMappingURL=elevation-styles.css.map */ `; //# sourceMappingURL=elevation-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/elevation/lib/elevation.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/elevation/lib/elevation.js index 26c2aaf5..e397b8a 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/elevation/lib/elevation.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/elevation/lib/elevation.js
@@ -3,9 +3,9 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; -import { html, LitElement } from '../../../../lit/index.js'; -import { property } from '../../../../lit/decorators.js'; +import { __decorate, __metadata } from "tslib"; +import { html, LitElement } from 'lit'; +import { property } from 'lit/decorators.js'; /** * A component for elevation. */
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/fab-extended.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/fab-extended.js index 795157a..bd61980 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/fab-extended.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/fab-extended.js
@@ -3,10 +3,10 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; +import { __decorate } from "tslib"; import '../icon/icon.js'; -import { html } from '../../../lit/index.js'; -import { customElement } from '../../../lit/decorators.js'; +import { html } from 'lit'; +import { customElement } from 'lit/decorators.js'; import { FabExtended } from './lib/fab-extended.js'; import { styles as extendedStyles } from './lib/fab-extended-styles.css.js'; import { styles as sharedStyles } from './lib/fab-shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/fab.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/fab.js index 8a0c490..161e31d 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/fab.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/fab.js
@@ -3,10 +3,10 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; +import { __decorate } from "tslib"; import '../icon/icon.js'; -import { html } from '../../../lit/index.js'; -import { customElement } from '../../../lit/decorators.js'; +import { html } from 'lit'; +import { customElement } from 'lit/decorators.js'; import { Fab } from './lib/fab.js'; import { styles as sharedStyles } from './lib/fab-shared-styles.css.js'; import { styles as fabStyles } from './lib/fab-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-extended-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-extended-styles.css.js index 434da78..224c69e 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-extended-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-extended-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-color: var(--md-fab-extended-container-color, var(--md-sys-color-surface, #fffbfe));--_container-elevation: var(--md-fab-extended-container-elevation, 3);--_container-height: var(--md-fab-extended-container-height, 56px);--_container-shadow-color: var(--md-fab-extended-container-shadow-color, var(--md-sys-color-shadow, #000));--_container-shape: var(--md-fab-extended-container-shape, 16px);--_container-surface-tint-layer-color: var(--md-fab-extended-container-surface-tint-layer-color, var(--md-sys-color-primary, #6750a4));--_focus-container-elevation: var(--md-fab-extended-focus-container-elevation, 3);--_focus-icon-color: var(--md-fab-extended-focus-icon-color, var(--md-sys-color-primary, #6750a4));--_focus-label-text-color: var(--md-fab-extended-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_focus-state-layer-color: var(--md-fab-extended-focus-state-layer-color, var(--md-sys-color-primary, #6750a4));--_focus-state-layer-opacity: var(--md-fab-extended-focus-state-layer-opacity, 0.12);--_hover-container-elevation: var(--md-fab-extended-hover-container-elevation, 4);--_hover-icon-color: var(--md-fab-extended-hover-icon-color, var(--md-sys-color-primary, #6750a4));--_hover-label-text-color: var(--md-fab-extended-hover-label-text-color, var(--md-sys-color-primary, #6750a4));--_hover-state-layer-color: var(--md-fab-extended-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--_hover-state-layer-opacity: var(--md-fab-extended-hover-state-layer-opacity, 0.08);--_icon-color: var(--md-fab-extended-icon-color, var(--md-sys-color-primary, #6750a4));--_icon-size: var(--md-fab-extended-icon-size, 24px);--_label-text-color: var(--md-fab-extended-label-text-color, var(--md-sys-color-primary, #6750a4));--_label-text-font: var(--md-fab-extended-label-text-font, Roboto);--_label-text-line-height: var(--md-fab-extended-label-text-line-height, 1.25rem);--_label-text-size: var(--md-fab-extended-label-text-size, 0.875rem);--_label-text-tracking: var(--md-fab-extended-label-text-tracking, 0.006rem);--_label-text-type: var(--md-fab-extended-label-text-type, 500 0.875rem / 1.25rem Roboto);--_label-text-weight: var(--md-fab-extended-label-text-weight, 500);--_lowered-container-elevation: var(--md-fab-extended-lowered-container-elevation, 1);--_lowered-focus-container-elevation: var(--md-fab-extended-lowered-focus-container-elevation, 1);--_lowered-hover-container-elevation: var(--md-fab-extended-lowered-hover-container-elevation, 2);--_lowered-pressed-container-elevation: var(--md-fab-extended-lowered-pressed-container-elevation, 1);--_pressed-container-elevation: var(--md-fab-extended-pressed-container-elevation, 3);--_pressed-icon-color: var(--md-fab-extended-pressed-icon-color, var(--md-sys-color-primary, #6750a4));--_pressed-label-text-color: var(--md-fab-extended-pressed-label-text-color, var(--md-sys-color-primary, #6750a4));--_pressed-state-layer-color: var(--md-fab-extended-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_pressed-state-layer-opacity: var(--md-fab-extended-pressed-state-layer-opacity, 0.12)}.md3-fab--extended{box-sizing:border-box;padding-inline-start:16px;padding-inline-end:20px;height:var(--_container-height);font-family:var(--_label-text-font);line-height:var(--_label-text-line-height);font-size:var(--_label-text-size);font-weight:var(--_label-text-weight);letter-spacing:var(--_label-text-tracking)}.md3-fab__label{padding-inline-start:12px;color:var(--_label-text-color)}.md3-fab:hover .md3-fab__label{color:var(--_hover-label-text-color)}.md3-fab:focus .md3-fab__label{color:var(--_focus-label-text-color)}.md3-fab:active .md3-fab__label{color:var(--_pressed-label-text-color)}@media(forced-colors: active){.md3-fab--extended{padding-inline-start:15px;padding-inline-end:19px}}/*# sourceMappingURL=fab-extended-styles.css.map */ `; //# sourceMappingURL=fab-extended-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-extended.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-extended.js index eacfb45..07d6153 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-extended.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-extended.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { html } from '../../../../lit/index.js'; +import { html } from 'lit'; import { FabShared } from './fab-shared.js'; /** * @soyCompatible
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-shared-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-shared-styles.css.js index 3f79d50..4742af5 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-shared-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-shared-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{display:inline-flex;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0);vertical-align:top}:host([disabled]){cursor:default;pointer-events:none}.md3-fab{display:inline-flex;border:none;outline:none;user-select:none;-webkit-appearance:none;vertical-align:middle;text-decoration:none;align-items:center;justify-content:center;position:relative;z-index:0;background-color:var(--_container-color);--md-focus-ring-shape-start-start:var(--_container-shape);--md-focus-ring-shape-start-end:var(--_container-shape);--md-focus-ring-shape-end-end:var(--_container-shape);--md-focus-ring-shape-end-start:var(--_container-shape);--md-ripple-hover-state-layer-color:var(--_hover-state-layer-color);--md-ripple-focus-state-layer-color:var(--_focus-state-layer-color);--md-ripple-pressed-state-layer-color:var(--_pressed-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_hover-state-layer-opacity);--md-ripple-focus-state-layer-opacity:var(--_focus-state-layer-opacity);--md-ripple-pressed-state-layer-opacity:var(--_pressed-state-layer-opacity);--md-elevation-duration:280ms;--md-elevation-level:var(--_container-elevation);--md-elevation-shadow-color:var(--_container-shadow-color);--md-elevation-surface-tint:var(--_container-surface-tint-layer-color)}.md3-fab.md3-fab--lowered{--md-elevation-level:var(--_lowered-container-elevation)}.md3-fab:focus{--md-elevation-level:var(--_focus-container-elevation)}.md3-fab:focus.md3-fab--lowered{--md-elevation-level:var(--_lowered-focus-container-elevation)}.md3-fab:hover{cursor:pointer;--md-elevation-level:var(--_hover-container-elevation)}.md3-fab:hover.md3-fab--lowered{--md-elevation-level:var(--_lowered-hover-container-elevation)}.md3-fab:active{outline:none;--md-elevation-level:var(--_pressed-container-elevation)}.md3-fab:active.md3-fab--lowered{--md-elevation-level:var(--_lowered-pressed-container-elevation)}md-elevation{inset:0;position:absolute;z-index:-1}.md3-fab__ripple{overflow:hidden;z-index:-1}.md3-fab,.md3-fab__ripple{border-radius:var(--_container-shape)}.md3-fab__icon{display:inline-flex}.md3-fab__touch{position:absolute;top:50%;height:48px;left:50%;width:48px;transform:translate(-50%, -50%)}.md3-fab__icon ::slotted(*),.md3-fab__icon{color:var(--_icon-color);font-size:var(--_icon-size);height:var(--_icon-size);width:var(--_icon-size)}.md3-fab:hover .md3-fab__icon ::slotted(*),.md3-fab:hover .md3-fab__icon{color:var(--_hover-icon-color)}.md3-fab:focus .md3-fab__icon ::slotted(*),.md3-fab:focus .md3-fab__icon{color:var(--_focus-icon-color)}.md3-fab:active .md3-fab__icon ::slotted(*),.md3-fab:active .md3-fab__icon{color:var(--_pressed-icon-color)}@media(forced-colors: active){.md3-fab{--md-focus-ring-offset-vertical:3px;--md-focus-ring-offset-horizontal:3px;border:1px solid ButtonText}}/*# sourceMappingURL=fab-shared-styles.css.map */ `; //# sourceMappingURL=fab-shared-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-shared.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-shared.js index ecf2a4e..048da2e5 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-shared.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-shared.js
@@ -3,13 +3,13 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; import '../../elevation/elevation.js'; import '../../focus/focus-ring.js'; import '../../ripple/ripple.js'; -import { html } from '../../../../lit/index.js'; -import { property, query, state } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; +import { html } from 'lit'; +import { property, query, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; import { ActionElement } from '../../actionelement/action-element.js'; import { pointerPress, shouldShowStrongFocus } from '../../focus/strong-focus.js'; import { MdRipple } from '../../ripple/ripple.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-styles.css.js index 59b1fadb..fbbab40 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/fab/lib/fab-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-color: var(--md-fab-container-color, var(--md-sys-color-surface, #fffbfe));--_container-elevation: var(--md-fab-container-elevation, 3);--_container-height: var(--md-fab-container-height, 56px);--_container-shadow-color: var(--md-fab-container-shadow-color, var(--md-sys-color-shadow, #000));--_container-shape: var(--md-fab-container-shape, 16px);--_container-surface-tint-layer-color: var(--md-fab-container-surface-tint-layer-color, var(--md-sys-color-primary, #6750a4));--_container-width: var(--md-fab-container-width, 56px);--_focus-container-elevation: var(--md-fab-focus-container-elevation, 3);--_focus-icon-color: var(--md-fab-focus-icon-color, var(--md-sys-color-primary, #6750a4));--_focus-state-layer-color: var(--md-fab-focus-state-layer-color, var(--md-sys-color-primary, #6750a4));--_focus-state-layer-opacity: var(--md-fab-focus-state-layer-opacity, 0.12);--_hover-container-elevation: var(--md-fab-hover-container-elevation, 4);--_hover-icon-color: var(--md-fab-hover-icon-color, var(--md-sys-color-primary, #6750a4));--_hover-state-layer-color: var(--md-fab-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--_hover-state-layer-opacity: var(--md-fab-hover-state-layer-opacity, 0.08);--_icon-color: var(--md-fab-icon-color, var(--md-sys-color-primary, #6750a4));--_icon-size: var(--md-fab-icon-size, 24px);--_lowered-container-elevation: var(--md-fab-lowered-container-elevation, 1);--_lowered-focus-container-elevation: var(--md-fab-lowered-focus-container-elevation, 1);--_lowered-hover-container-elevation: var(--md-fab-lowered-hover-container-elevation, 2);--_lowered-pressed-container-elevation: var(--md-fab-lowered-pressed-container-elevation, 1);--_pressed-container-elevation: var(--md-fab-pressed-container-elevation, 3);--_pressed-icon-color: var(--md-fab-pressed-icon-color, var(--md-sys-color-primary, #6750a4));--_pressed-state-layer-color: var(--md-fab-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_pressed-state-layer-opacity: var(--md-fab-pressed-state-layer-opacity, 0.12)}.md3-fab{width:var(--_container-width);height:var(--_container-height)}.md3-fab--regular{padding:0}/*# sourceMappingURL=fab-styles.css.map */ `; //# sourceMappingURL=fab-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/filled-field.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/filled-field.js index 0b0306924..b20a24e 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/filled-field.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/filled-field.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { FilledField } from './lib/filled-field.js'; import { styles as filledStyles } from './lib/filled-styles.css.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/field.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/field.js index f7bdfb95..3fe2e0b4 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/field.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/field.js
@@ -3,10 +3,10 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; -import { html, LitElement } from '../../../../lit/index.js'; -import { property, queryAsync, state } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; +import { __decorate, __metadata } from "tslib"; +import { html, LitElement } from 'lit'; +import { property, queryAsync, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; import { createAnimationSignal, EASING } from '../../motion/animation.js'; /** @soyCompatible */ export class Field extends LitElement {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/filled-field.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/filled-field.js index dfb404b1..56d8ff77 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/filled-field.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/filled-field.js
@@ -3,10 +3,10 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; -import { html } from '../../../../lit/index.js'; -import { state } from '../../../../lit/decorators.js'; -import { styleMap } from '../../../../lit/directives/style-map.js'; +import { __decorate, __metadata } from "tslib"; +import { html } from 'lit'; +import { state } from 'lit/decorators.js'; +import { styleMap } from 'lit/directives/style-map.js'; import { Field } from './field.js'; /** @soyCompatible */ export class FilledField extends Field {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/filled-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/filled-styles.css.js index c6876fdc8..d6293c1 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/filled-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/filled-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-shape-start-start: var(--md-filled-field-container-shape-start-start, 4px);--_container-shape-start-end: var(--md-filled-field-container-shape-start-end, 4px);--_container-shape-end-end: var(--md-filled-field-container-shape-end-end, 0px);--_container-shape-end-start: var(--md-filled-field-container-shape-end-start, 0px);--_active-indicator-color: var(--md-filled-field-active-indicator-color, var(--md-sys-color-on-surface-variant, #49454f));--_active-indicator-height: var(--md-filled-field-active-indicator-height, 1px);--_container-color: var(--md-filled-field-container-color, var(--md-sys-color-surface-variant, #e7e0ec));--_disabled-active-indicator-color: var(--md-filled-field-disabled-active-indicator-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-active-indicator-height: var(--md-filled-field-disabled-active-indicator-height, 1px);--_disabled-active-indicator-opacity: var(--md-filled-field-disabled-active-indicator-opacity, 0.38);--_disabled-container-color: var(--md-filled-field-disabled-container-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-container-opacity: var(--md-filled-field-disabled-container-opacity, 0.04);--_disabled-label-text-color: var(--md-filled-field-disabled-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-label-text-opacity: var(--md-filled-field-disabled-label-text-opacity, 0.38);--_disabled-leading-icon-color: var(--md-filled-field-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-leading-icon-opacity: var(--md-filled-field-disabled-leading-icon-opacity, 0.38);--_disabled-supporting-text-color: var(--md-filled-field-disabled-supporting-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-supporting-text-opacity: var(--md-filled-field-disabled-supporting-text-opacity, 0.38);--_disabled-trailing-icon-color: var(--md-filled-field-disabled-trailing-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-trailing-icon-opacity: var(--md-filled-field-disabled-trailing-icon-opacity, 0.38);--_error-active-indicator-color: var(--md-filled-field-error-active-indicator-color, var(--md-sys-color-error, #b3261e));--_error-focus-active-indicator-color: var(--md-filled-field-error-focus-active-indicator-color, var(--md-sys-color-error, #b3261e));--_error-focus-label-text-color: var(--md-filled-field-error-focus-label-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-leading-icon-color: var(--md-filled-field-error-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-focus-supporting-text-color: var(--md-filled-field-error-focus-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-trailing-icon-color: var(--md-filled-field-error-focus-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_error-hover-active-indicator-color: var(--md-filled-field-error-hover-active-indicator-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-label-text-color: var(--md-filled-field-error-hover-label-text-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-leading-icon-color: var(--md-filled-field-error-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-hover-state-layer-color: var(--md-filled-field-error-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_error-hover-state-layer-opacity: var(--md-filled-field-error-hover-state-layer-opacity, 0.08);--_error-hover-supporting-text-color: var(--md-filled-field-error-hover-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-hover-trailing-icon-color: var(--md-filled-field-error-hover-trailing-icon-color, var(--md-sys-color-on-error-container, #410e0b));--_error-label-text-color: var(--md-filled-field-error-label-text-color, var(--md-sys-color-error, #b3261e));--_error-leading-icon-color: var(--md-filled-field-error-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-supporting-text-color: var(--md-filled-field-error-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-trailing-icon-color: var(--md-filled-field-error-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_focus-active-indicator-color: var(--md-filled-field-focus-active-indicator-color, var(--md-sys-color-primary, #6750a4));--_focus-active-indicator-height: var(--md-filled-field-focus-active-indicator-height, 2px);--_focus-label-text-color: var(--md-filled-field-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_focus-leading-icon-color: var(--md-filled-field-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-supporting-text-color: var(--md-filled-field-focus-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-trailing-icon-color: var(--md-filled-field-focus-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-active-indicator-color: var(--md-filled-field-hover-active-indicator-color, var(--md-sys-color-on-surface, #1c1b1f));--_hover-active-indicator-height: var(--md-filled-field-hover-active-indicator-height, 1px);--_hover-label-text-color: var(--md-filled-field-hover-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-leading-icon-color: var(--md-filled-field-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-state-layer-color: var(--md-filled-field-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_hover-state-layer-opacity: var(--md-filled-field-hover-state-layer-opacity, 0.08);--_hover-supporting-text-color: var(--md-filled-field-hover-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-trailing-icon-color: var(--md-filled-field-hover-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_label-text-color: var(--md-filled-field-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_label-text-font: var(--md-filled-field-label-text-font, Roboto);--_label-text-line-height: var(--md-filled-field-label-text-line-height, 1.5rem);--_label-text-populated-line-height: var(--md-filled-field-label-text-populated-line-height, 1rem);--_label-text-populated-size: var(--md-filled-field-label-text-populated-size, 0.75rem);--_label-text-size: var(--md-filled-field-label-text-size, 1rem);--_label-text-tracking: var(--md-filled-field-label-text-tracking, 0.031rem);--_label-text-weight: var(--md-filled-field-label-text-weight, 400);--_leading-icon-color: var(--md-filled-field-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_leading-icon-size: var(--md-filled-field-leading-icon-size, 24px);--_supporting-text-color: var(--md-filled-field-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_supporting-text-font: var(--md-filled-field-supporting-text-font, Roboto);--_supporting-text-line-height: var(--md-filled-field-supporting-text-line-height, 1rem);--_supporting-text-size: var(--md-filled-field-supporting-text-size, 0.75rem);--_supporting-text-tracking: var(--md-filled-field-supporting-text-tracking, 0.025rem);--_supporting-text-weight: var(--md-filled-field-supporting-text-weight, 400);--_trailing-icon-color: var(--md-filled-field-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_trailing-icon-size: var(--md-filled-field-trailing-icon-size, 24px);--_container-padding-horizontal: var(--md-filled-field-container-padding-horizontal, 16px);--_container-padding-vertical: var(--md-filled-field-container-padding-vertical, 16px);--_content-color: var(--md-filled-field-content-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-content-color: var(--md-filled-field-disabled-content-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-content-opacity: var(--md-filled-field-disabled-content-opacity, 0.38);--_error-content-color: var(--md-filled-field-error-content-color, var(--md-sys-color-on-surface, #1c1b1f));--_error-focus-content-color: var(--md-filled-field-error-focus-content-color, var(--md-sys-color-on-surface, #1c1b1f));--_error-hover-content-color: var(--md-filled-field-error-hover-content-color, var(--md-sys-color-on-surface, #1c1b1f));--_focus-content-color: var(--md-filled-field-focus-content-color, var(--md-sys-color-on-surface, #1c1b1f));--_hover-content-color: var(--md-filled-field-hover-content-color, var(--md-sys-color-on-surface, #1c1b1f));--_supporting-text-padding: var(--md-filled-field-supporting-text-padding, 16px);--_supporting-text-padding-top: var(--md-filled-field-supporting-text-padding-top, 4px);--_with-label-container-padding-vertical: var(--md-filled-field-with-label-container-padding-vertical, 8px);--_label-text-populated-font: ;--_label-text-populated-tracking: ;--_label-text-populated-weight: }.md3-field__container{border-start-start-radius:var(--_container-shape-start-start);border-start-end-radius:var(--_container-shape-start-end);border-end-end-radius:var(--_container-shape-end-end);border-end-start-radius:var(--_container-shape-end-start);overflow:hidden;z-index:0}.md3-field__container::before{background:var(--_container-color)}.md3-field__container::after{visibility:hidden}.md3-field__container::before,.md3-field__container::after{border-radius:inherit;content:"";display:flex;height:100%;position:absolute;width:100%;z-index:-1}.md3-field__label--floating{position:absolute;top:0}.md3-field__state-layer{border-radius:inherit;height:100%;position:absolute;width:100%;visibility:hidden;z-index:-1}.md3-field:not(.md3-field--disabled):hover .md3-field__state-layer{visibility:visible}.md3-field__active-indicator{inset:auto 0 0 0;pointer-events:none;position:absolute;width:100%}.md3-field__active-indicator::before,.md3-field__active-indicator::after{border-bottom:var(--_active-indicator-height) solid var(--_active-indicator-color);inset:auto 0 0 0;content:"";position:absolute;width:100%}.md3-field__active-indicator::after{opacity:0;transform:scaleX(0);transform-origin:inherit;transition:opacity 150ms cubic-bezier(0.4, 0, 0.2, 1),transform 0s ease 150ms}.md3-field--focused .md3-field__active-indicator::after{opacity:1;transform:scaleX(1);transition:transform 150ms cubic-bezier(0.4, 0, 0.2, 1)}.md3-field:not(.md3-field--with-start) .md3-field__start{padding-inline-start:var(--_container-padding-horizontal)}.md3-field:not(.md3-field--with-end) .md3-field__end{padding-inline-end:var(--_container-padding-horizontal)}.md3-field:not(.md3-field--no-label) .md3-field__container{padding-bottom:var(--_with-label-container-padding-vertical);padding-top:var(--_with-label-container-padding-vertical)}.md3-field:not(.md3-field--no-label) .md3-field__middle{padding-top:var(--_label-text-populated-line-height)}:hover .md3-field__active-indicator::before{border-bottom-color:var(--_hover-active-indicator-color);border-bottom-width:var(--_hover-active-indicator-height)}:hover .md3-field__state-layer{background:var(--_hover-state-layer-color);opacity:var(--_hover-state-layer-opacity)}.md3-field__active-indicator::after{border-bottom-color:var(--_focus-active-indicator-color);border-bottom-width:var(--_focus-active-indicator-height)}.md3-field--disabled .md3-field__active-indicator::before{border-bottom-color:var(--_disabled-active-indicator-color);border-bottom-width:var(--_disabled-active-indicator-height);opacity:var(--_disabled-active-indicator-opacity)}.md3-field--disabled .md3-field__container::before{background:var(--_disabled-container-color);opacity:var(--_disabled-container-opacity)}.md3-field--error:not(.md3-field--disabled) .md3-field__active-indicator::before{border-bottom-color:var(--_error-active-indicator-color)}.md3-field--error:not(.md3-field--disabled):hover .md3-field__active-indicator::before{border-bottom-color:var(--_error-hover-active-indicator-color)}.md3-field--error:not(.md3-field--disabled):hover .md3-field__state-layer{background:var(--_error-hover-state-layer-color);opacity:var(--_error-hover-state-layer-opacity)}.md3-field--error:not(.md3-field--disabled) .md3-field__active-indicator::after{border-bottom-color:var(--_error-focus-active-indicator-color)}/*# sourceMappingURL=filled-styles.css.map */ `; //# sourceMappingURL=filled-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/outlined-field.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/outlined-field.js index 644f539..7a87de0 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/outlined-field.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/outlined-field.js
@@ -3,7 +3,7 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { html } from '../../../../lit/index.js'; +import { html } from 'lit'; import { Field } from './field.js'; /** @soyCompatible */ export class OutlinedField extends Field {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/outlined-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/outlined-styles.css.js index adfb710..56449134a 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/outlined-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/outlined-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-shape-start-start: var(--md-outlined-field-container-shape-start-start, 4px);--_container-shape-start-end: var(--md-outlined-field-container-shape-start-end, 4px);--_container-shape-end-end: var(--md-outlined-field-container-shape-end-end, 4px);--_container-shape-end-start: var(--md-outlined-field-container-shape-end-start, 4px);--_disabled-label-text-color: var(--md-outlined-field-disabled-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-label-text-opacity: var(--md-outlined-field-disabled-label-text-opacity, 0.38);--_disabled-leading-icon-color: var(--md-outlined-field-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-leading-icon-opacity: var(--md-outlined-field-disabled-leading-icon-opacity, 0.38);--_disabled-outline-color: var(--md-outlined-field-disabled-outline-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-outline-opacity: var(--md-outlined-field-disabled-outline-opacity, 0.12);--_disabled-outline-width: var(--md-outlined-field-disabled-outline-width, 1px);--_disabled-supporting-text-color: var(--md-outlined-field-disabled-supporting-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-supporting-text-opacity: var(--md-outlined-field-disabled-supporting-text-opacity, 0.38);--_disabled-trailing-icon-color: var(--md-outlined-field-disabled-trailing-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-trailing-icon-opacity: var(--md-outlined-field-disabled-trailing-icon-opacity, 0.38);--_error-focus-label-text-color: var(--md-outlined-field-error-focus-label-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-leading-icon-color: var(--md-outlined-field-error-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-focus-outline-color: var(--md-outlined-field-error-focus-outline-color, var(--md-sys-color-error, #b3261e));--_error-focus-supporting-text-color: var(--md-outlined-field-error-focus-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-trailing-icon-color: var(--md-outlined-field-error-focus-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_error-hover-label-text-color: var(--md-outlined-field-error-hover-label-text-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-leading-icon-color: var(--md-outlined-field-error-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-hover-outline-color: var(--md-outlined-field-error-hover-outline-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-supporting-text-color: var(--md-outlined-field-error-hover-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-hover-trailing-icon-color: var(--md-outlined-field-error-hover-trailing-icon-color, var(--md-sys-color-on-error-container, #410e0b));--_error-label-text-color: var(--md-outlined-field-error-label-text-color, var(--md-sys-color-error, #b3261e));--_error-leading-icon-color: var(--md-outlined-field-error-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-outline-color: var(--md-outlined-field-error-outline-color, var(--md-sys-color-error, #b3261e));--_error-supporting-text-color: var(--md-outlined-field-error-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-trailing-icon-color: var(--md-outlined-field-error-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_focus-label-text-color: var(--md-outlined-field-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_focus-leading-icon-color: var(--md-outlined-field-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-outline-color: var(--md-outlined-field-focus-outline-color, var(--md-sys-color-primary, #6750a4));--_focus-outline-width: var(--md-outlined-field-focus-outline-width, 2px);--_focus-supporting-text-color: var(--md-outlined-field-focus-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-trailing-icon-color: var(--md-outlined-field-focus-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-label-text-color: var(--md-outlined-field-hover-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_hover-leading-icon-color: var(--md-outlined-field-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-outline-color: var(--md-outlined-field-hover-outline-color, var(--md-sys-color-on-surface, #1c1b1f));--_hover-outline-width: var(--md-outlined-field-hover-outline-width, 1px);--_hover-supporting-text-color: var(--md-outlined-field-hover-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-trailing-icon-color: var(--md-outlined-field-hover-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_label-text-color: var(--md-outlined-field-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_label-text-font: var(--md-outlined-field-label-text-font, Roboto);--_label-text-line-height: var(--md-outlined-field-label-text-line-height, 1.5rem);--_label-text-populated-line-height: var(--md-outlined-field-label-text-populated-line-height, 1rem);--_label-text-populated-size: var(--md-outlined-field-label-text-populated-size, 0.75rem);--_label-text-size: var(--md-outlined-field-label-text-size, 1rem);--_label-text-tracking: var(--md-outlined-field-label-text-tracking, 0.031rem);--_label-text-weight: var(--md-outlined-field-label-text-weight, 400);--_leading-icon-color: var(--md-outlined-field-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_leading-icon-size: var(--md-outlined-field-leading-icon-size, 24px);--_outline-color: var(--md-outlined-field-outline-color, var(--md-sys-color-outline, #79747e));--_outline-width: var(--md-outlined-field-outline-width, 1px);--_supporting-text-color: var(--md-outlined-field-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_supporting-text-font: var(--md-outlined-field-supporting-text-font, Roboto);--_supporting-text-line-height: var(--md-outlined-field-supporting-text-line-height, 1rem);--_supporting-text-size: var(--md-outlined-field-supporting-text-size, 0.75rem);--_supporting-text-tracking: var(--md-outlined-field-supporting-text-tracking, 0.025rem);--_supporting-text-weight: var(--md-outlined-field-supporting-text-weight, 400);--_trailing-icon-color: var(--md-outlined-field-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_trailing-icon-size: var(--md-outlined-field-trailing-icon-size, 24px);--_container-padding-horizontal: var(--md-outlined-field-container-padding-horizontal, 16px);--_container-padding-vertical: var(--md-outlined-field-container-padding-vertical, 16px);--_content-color: var(--md-outlined-field-content-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-content-color: var(--md-outlined-field-disabled-content-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-content-opacity: var(--md-outlined-field-disabled-content-opacity, 0.38);--_error-content-color: var(--md-outlined-field-error-content-color, var(--md-sys-color-on-surface, #1c1b1f));--_error-focus-content-color: var(--md-outlined-field-error-focus-content-color, var(--md-sys-color-on-surface, #1c1b1f));--_error-hover-content-color: var(--md-outlined-field-error-hover-content-color, var(--md-sys-color-on-surface, #1c1b1f));--_focus-content-color: var(--md-outlined-field-focus-content-color, var(--md-sys-color-on-surface, #1c1b1f));--_hover-content-color: var(--md-outlined-field-hover-content-color, var(--md-sys-color-on-surface, #1c1b1f));--_label-text-padding-bottom: var(--md-outlined-field-label-text-padding-bottom, 8px);--_outline-label-padding: var(--md-outlined-field-outline-label-padding, 4px);--_supporting-text-padding: var(--md-outlined-field-supporting-text-padding, 16px);--_supporting-text-padding-top: var(--md-outlined-field-supporting-text-padding-top, 4px);--_label-text-populated-font: ;--_label-text-populated-tracking: ;--_label-text-populated-weight: }.md3-field__outline{border-start-start-radius:var(--_container-shape-start-start);border-start-end-radius:var(--_container-shape-start-end);border-end-end-radius:var(--_container-shape-end-end);border-end-start-radius:var(--_container-shape-end-start);border-color:var(--_outline-color);color:var(--_outline-color);display:flex;pointer-events:none;height:100%;position:absolute;width:100%}.md3-field__outline-start::before,.md3-field__outline-start::after,.md3-field__outline-panel-inactive::before,.md3-field__outline-panel-inactive::after,.md3-field__outline-panel-active::before,.md3-field__outline-panel-active::after,.md3-field__outline-end::before,.md3-field__outline-end::after{border:inherit;content:"";inset:0;position:absolute}.md3-field__outline-start,.md3-field__outline-end{border:inherit;border-radius:inherit;box-sizing:border-box;position:relative}.md3-field__outline-start::before,.md3-field__outline-start::after,.md3-field__outline-end::before,.md3-field__outline-end::after{border-bottom-style:solid;border-top-style:solid}.md3-field__outline-start::after,.md3-field__outline-end::after{opacity:0;transition:opacity 150ms cubic-bezier(0.4, 0, 0.2, 1)}.md3-field--focused .md3-field__outline-start::after,.md3-field--focused .md3-field__outline-end::after{opacity:1}.md3-field__outline-start::before,.md3-field__outline-start::after{border-inline-start-style:solid;border-inline-end-style:none;border-start-start-radius:inherit;border-start-end-radius:0;border-end-start-radius:inherit;border-end-end-radius:0;margin-inline-end:var(--_outline-label-padding)}.md3-field__outline-end{flex-grow:1;margin-inline-start:calc(-1*var(--_outline-label-padding))}.md3-field__outline-end::before,.md3-field__outline-end::after{border-inline-start-style:none;border-inline-end-style:solid;border-start-start-radius:0;border-start-end-radius:inherit;border-end-start-radius:0;border-end-end-radius:inherit}.md3-field__outline-notch{align-items:flex-start;border:inherit;display:flex;margin-inline-start:calc(-1*var(--_outline-label-padding));margin-inline-end:var(--_outline-label-padding);max-width:calc(100% - 2*var(--_container-padding-horizontal));padding:0 var(--_outline-label-padding);position:relative}.md3-field--no-label .md3-field__outline-notch{display:none}.md3-field__outline-panel-inactive,.md3-field__outline-panel-active{border:inherit;border-bottom-style:solid;inset:0;position:absolute}.md3-field__outline-panel-inactive::before,.md3-field__outline-panel-inactive::after,.md3-field__outline-panel-active::before,.md3-field__outline-panel-active::after{border-top-style:solid;border-bottom:none;bottom:auto;transform:scaleX(1);transition:transform 150ms cubic-bezier(0.4, 0, 0.2, 1)}.md3-field__outline-panel-inactive::before,.md3-field__outline-panel-active::before{right:50%;transform-origin:top left}.md3-field__outline-panel-inactive::after,.md3-field__outline-panel-active::after{left:50%;transform-origin:top right}.md3-field--populated .md3-field__outline-panel-inactive::before,.md3-field--populated .md3-field__outline-panel-inactive::after,.md3-field--focused .md3-field__outline-panel-inactive::before,.md3-field--focused .md3-field__outline-panel-inactive::after,.md3-field--populated .md3-field__outline-panel-active::before,.md3-field--populated .md3-field__outline-panel-active::after,.md3-field--focused .md3-field__outline-panel-active::before,.md3-field--focused .md3-field__outline-panel-active::after{transform:scaleX(0)}.md3-field__outline-panel-active{opacity:0;transition:opacity 150ms cubic-bezier(0.4, 0, 0.2, 1)}.md3-field--focused .md3-field__outline-panel-active{opacity:1}.md3-field__label--floating{transform:translateY(calc(-100% + var(--_label-text-padding-bottom)))}.md3-field__outline-start,.md3-field:not(.md3-field--with-start) .md3-field__start{padding-inline-start:max(var(--_container-padding-horizontal),max(var(--_container-shape-start-start),var(--_container-shape-end-start)) + var(--_outline-label-padding))}.md3-field:not(.md3-field--with-end) .md3-field__end{padding-inline-end:max(var(--_container-padding-horizontal),max(var(--_container-shape-start-end),var(--_container-shape-end-end)))}.md3-field__outline-start::before,.md3-field__outline-end::before,.md3-field__outline-panel-inactive,.md3-field__outline-panel-inactive::before,.md3-field__outline-panel-inactive::after{border-width:var(--_outline-width)}:hover .md3-field__outline{border-color:var(--_hover-outline-color);color:var(--_hover-outline-color)}:hover .md3-field__outline-start::before,:hover .md3-field__outline-end::before,:hover .md3-field__outline-panel-inactive,:hover .md3-field__outline-panel-inactive::before,:hover .md3-field__outline-panel-inactive::after{border-width:var(--_hover-outline-width)}.md3-field--focused .md3-field__outline{border-color:var(--_focus-outline-color);color:var(--_focus-outline-color)}.md3-field__outline-start::after,.md3-field__outline-end::after,.md3-field__outline-panel-active,.md3-field__outline-panel-active::before,.md3-field__outline-panel-active::after{border-width:var(--_focus-outline-width)}.md3-field--disabled .md3-field__outline{border-color:var(--_disabled-outline-color);color:var(--_disabled-outline-color)}.md3-field--disabled .md3-field__outline-start,.md3-field--disabled .md3-field__outline-end,.md3-field--disabled .md3-field__outline-panel-inactive{opacity:var(--_disabled-outline-opacity)}.md3-field--disabled .md3-field__outline-start::before,.md3-field--disabled .md3-field__outline-end::before,.md3-field--disabled .md3-field__outline-panel-inactive,.md3-field--disabled .md3-field__outline-panel-inactive::before,.md3-field--disabled .md3-field__outline-panel-inactive::after{border-width:var(--_disabled-outline-width)}.md3-field--error:not(.md3-field--disabled) .md3-field__outline{border-color:var(--_error-outline-color);color:var(--_error-outline-color)}.md3-field--error:not(.md3-field--disabled):hover .md3-field__outline{border-color:var(--_error-hover-outline-color);color:var(--_error-hover-outline-color)}.md3-field--error:not(.md3-field--disabled).md3-field--focused .md3-field__outline{border-color:var(--_error-focus-outline-color);color:var(--_error-focus-outline-color)}/*# sourceMappingURL=outlined-styles.css.map */ `; //# sourceMappingURL=outlined-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/shared-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/shared-styles.css.js index 50381bc..60b0594 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/shared-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/lib/shared-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{display:inline-flex}.md3-field{display:inline-flex;flex:1;flex-direction:column;writing-mode:horizontal-tb}.md3-field__container{align-items:center;box-sizing:border-box;display:flex;flex:1;flex-basis:var(--_container-height);padding-top:var(--_container-padding-vertical);padding-bottom:var(--_container-padding-vertical);position:relative}.md3-field--disabled{pointer-events:none}.md3-field--with-start .md3-field__start,.md3-field--with-end .md3-field__end{min-width:48px}.md3-field--with-start .md3-field__start{margin-inline-end:4px}.md3-field--with-end .md3-field__end{margin-inline-start:4px}.md3-field__start,.md3-field__middle,.md3-field__end{display:flex;align-items:center;box-sizing:border-box;height:100%;position:relative}.md3-field__start,.md3-field__end{justify-content:center}.md3-field__middle{align-self:baseline;flex:1}.md3-field__content{display:flex;flex:1;opacity:0;transition:opacity 83ms cubic-bezier(0.4, 0, 0.2, 1);color:var(--_content-color)}.md3-field--no-label .md3-field__content,.md3-field--focused .md3-field__content,.md3-field--populated .md3-field__content{opacity:1;transition-delay:67ms}.md3-field--disabled.md3-field--no-label .md3-field__content,.md3-field--disabled.md3-field--focused .md3-field__content,.md3-field--disabled.md3-field--populated .md3-field__content{opacity:var(--_disabled-content-opacity)}:hover .md3-field__content{color:var(--_hover-content-color)}.md3-field--focused .md3-field__content{color:var(--_focus-content-color)}.md3-field--disabled .md3-field__content{color:var(--_disabled-content-color)}.md3-field--error:not(.md3-field--disabled) .md3-field__content{color:var(--_error-content-color)}.md3-field--error:not(.md3-field--disabled):hover .md3-field__content{color:var(--_error-hover-content-color)}.md3-field--error:not(.md3-field--disabled).md3-field--focused .md3-field__content{color:var(--_error-focus-content-color)}.md3-field__label{color:var(--_label-text-color);overflow:hidden;max-width:100%;pointer-events:none;text-overflow:ellipsis;white-space:nowrap;z-index:1;font-family:var(--_label-text-font);font-weight:var(--_label-text-weight);letter-spacing:var(--_label-text-tracking)}.md3-field__label--resting{position:absolute;top:50%;transform:translateY(-50%);transform-origin:top left;font-size:var(--_label-text-size);line-height:var(--_label-text-line-height)}.md3-field__label--floating{font-size:var(--_label-text-populated-size);line-height:var(--_label-text-populated-line-height)}.md3-field__label--hidden{opacity:0}.md3-field--no-label .md3-field__label{display:none}:hover .md3-field__label{color:var(--_hover-label-text-color)}.md3-field--focused .md3-field__label{color:var(--_focus-label-text-color)}.md3-field--disabled .md3-field__label{color:var(--_disabled-label-text-color)}.md3-field--disabled .md3-field__label:not(.md3-field__label--hidden){opacity:var(--_disabled-label-text-opacity)}.md3-field--error:not(.md3-field--disabled) .md3-field__label{color:var(--_error-label-text-color)}.md3-field--error:not(.md3-field--disabled):hover .md3-field__label{color:var(--_error-hover-label-text-color)}.md3-field--error:not(.md3-field--disabled).md3-field--focused .md3-field__label{color:var(--_error-focus-label-text-color)}.md3-field__supporting-text{color:var(--_supporting-text-color);display:flex;justify-content:space-between;padding:0 var(--_supporting-text-padding);font-family:var(--_supporting-text-font);font-size:var(--_supporting-text-size);font-weight:var(--_supporting-text-weight);letter-spacing:var(--_supporting-text-tracking);line-height:var(--_supporting-text-line-height)}.md3-field__supporting-text-start,.md3-field__supporting-text-end{display:flex}.md3-field__supporting-text-start ::slotted(:not(:empty)),.md3-field__supporting-text-end ::slotted(:not(:empty)){padding-top:var(--_supporting-text-padding-top)}.md3-field__supporting-text-end ::slotted(:not(:empty)){padding-inline-start:var(--_supporting-text-padding)}:hover .md3-field__supporting-text{color:var(--_hover-supporting-text-color)}.md3-field--focus .md3-field__supporting-text{color:var(--_focus-supporting-text-color)}.md3-field--disabled .md3-field__supporting-text{color:var(--_disabled-supporting-text-color);opacity:var(--_disabled-supporting-text-opacity)}.md3-field--error:not(.md3-field--disabled) .md3-field__supporting-text{color:var(--_error-supporting-text-color)}.md3-field--error:not(.md3-field--disabled):hover .md3-field__supporting-text{color:var(--_error-hover-supporting-text-color)}.md3-field--error:not(.md3-field--disabled).md3-field--focus .md3-field__supporting-text{color:var(--_error-focus-supporting-text-color)}/*# sourceMappingURL=shared-styles.css.map */ `; //# sourceMappingURL=shared-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/outlined-field.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/outlined-field.js index 4c288863..441b9280 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/field/outlined-field.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/field/outlined-field.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { OutlinedField } from './lib/outlined-field.js'; import { styles as outlinedStyles } from './lib/outlined-styles.css.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/focus/focus-ring.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/focus/focus-ring.js index 5d76399..a8eeeed 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/focus/focus-ring.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/focus/focus-ring.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { FocusRing } from './lib/focus-ring.js'; import { styles } from './lib/focus-ring-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/focus/lib/focus-ring-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/focus/lib/focus-ring-styles.css.js index a5c08bb7..a187b9a9 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/focus/lib/focus-ring-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/focus/lib/focus-ring-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_shape-start-start: var(--md-focus-ring-shape-start-start, 9999px);--_shape-start-end: var(--md-focus-ring-shape-start-end, 9999px);--_shape-end-end: var(--md-focus-ring-shape-end-end, 9999px);--_shape-end-start: var(--md-focus-ring-shape-end-start, 9999px);--_offset-vertical: var(--md-focus-ring-offset-vertical, 2px);--_offset-horizontal: var(--md-focus-ring-offset-horizontal, 2px);--_width: var(--md-focus-ring-width, 3px);--_color: var(--md-focus-ring-color, var(--md-sys-color-secondary, #625b71));display:none;position:absolute;box-sizing:border-box;pointer-events:none;border:var(--_width) solid var(--_color);border-start-start-radius:var(--_shape-start-start);border-start-end-radius:var(--_shape-start-end);border-end-start-radius:var(--_shape-end-start);border-end-end-radius:var(--_shape-end-end);inset:calc(-1*(var(--_offset-vertical) + var(--_width))) calc(-1*(var(--_offset-horizontal) + var(--_width)))}:host([visible]){display:flex}/*# sourceMappingURL=focus-ring-styles.css.map */ `; //# sourceMappingURL=focus-ring-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/focus/lib/focus-ring.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/focus/lib/focus-ring.js index 614dc2d..ab781ae 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/focus/lib/focus-ring.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/focus/lib/focus-ring.js
@@ -3,9 +3,9 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; -import { LitElement } from '../../../../lit/index.js'; -import { property } from '../../../../lit/decorators.js'; +import { __decorate, __metadata } from "tslib"; +import { LitElement } from 'lit'; +import { property } from 'lit/decorators.js'; /** * @summary An accessible, themable ring designed to be shown on * `:focus-visible`.
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/icon/icon.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/icon/icon.js index 759ad31..8ffb027 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/icon/icon.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/icon/icon.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { Icon } from './lib/icon.js'; import { styles } from './lib/icon-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/icon/lib/icon-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/icon/lib/icon-styles.css.js index a0e0dd47..7242790f 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/icon/lib/icon-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/icon/lib/icon-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_color: var(--md-icon-color, inherit);--_font: var(--md-icon-font, "Material Icons");--_font-variation-settings: var(--md-icon-font-variation-settings, inherit);--_size: var(--md-icon-size, 24px);--_weight: var(--md-icon-weight, 400);display:inline-flex;color:var(--_color);font-family:var(--_font);font-weight:var(--_weight);font-style:normal;font-size:var(--_size);font-variation-settings:var(--_font-varation-settings);line-height:1;letter-spacing:normal;text-transform:none;white-space:nowrap;word-wrap:normal;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale}span ::slotted(svg){fill:currentColor}span ::slotted(*){height:var(--_size);width:var(--_size)}/*# sourceMappingURL=icon-styles.css.map */ `; //# sourceMappingURL=icon-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/icon/lib/icon.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/icon/lib/icon.js index 0ee874f..10634a28 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/icon/lib/icon.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/icon/lib/icon.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { html, LitElement } from '../../../../lit/index.js'; +import { html, LitElement } from 'lit'; /** @soyCompatible */ export class Icon extends LitElement { /** @soyTemplate */
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-icon-button-toggle.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-icon-button-toggle.js index 01c906a56..55a782d 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-icon-button-toggle.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-icon-button-toggle.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles } from './lib/filled-styles.css.js'; import { IconButtonToggle } from './lib/icon-button-toggle.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-icon-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-icon-button.js index ad1685ae..f48b0603 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-icon-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-icon-button.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles } from './lib/filled-styles.css.js'; import { IconButton } from './lib/icon-button.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-link-icon-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-link-icon-button.js index 0347b2a5..079c99e3 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-link-icon-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-link-icon-button.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles } from './lib/filled-styles.css.js'; import { LinkIconButton } from './lib/link-icon-button.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-tonal-icon-button-toggle.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-tonal-icon-button-toggle.js index 531f89d..5cc014a 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-tonal-icon-button-toggle.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-tonal-icon-button-toggle.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles } from './lib/filled-tonal-styles.css.js'; import { IconButtonToggle } from './lib/icon-button-toggle.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-tonal-icon-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-tonal-icon-button.js index 503a56c7..dc22466f 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-tonal-icon-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-tonal-icon-button.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles } from './lib/filled-tonal-styles.css.js'; import { IconButton } from './lib/icon-button.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-tonal-link-icon-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-tonal-link-icon-button.js index 5123665..8a18244 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-tonal-link-icon-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/filled-tonal-link-icon-button.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles } from './lib/filled-tonal-styles.css.js'; import { LinkIconButton } from './lib/link-icon-button.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/filled-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/filled-styles.css.js index 7421eee..721f64bc 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/filled-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/filled-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-shape-start-start: var(--md-filled-icon-button-container-shape-start-start, 9999px);--_container-shape-start-end: var(--md-filled-icon-button-container-shape-start-end, 9999px);--_container-shape-end-end: var(--md-filled-icon-button-container-shape-end-end, 9999px);--_container-shape-end-start: var(--md-filled-icon-button-container-shape-end-start, 9999px);--_container-color: var(--md-filled-icon-button-container-color, var(--md-sys-color-primary, #6750a4));--_container-size: var(--md-filled-icon-button-container-size, 40px);--_disabled-container-color: var(--md-filled-icon-button-disabled-container-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.12));--_disabled-icon-color: var(--md-filled-icon-button-disabled-icon-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_focus-icon-color: var(--md-filled-icon-button-focus-icon-color, var(--md-sys-color-on-primary, #fff));--_focus-state-layer-color: var(--md-filled-icon-button-focus-state-layer-color, var(--md-sys-color-on-primary, #fff));--_focus-state-layer-opacity: var(--md-filled-icon-button-focus-state-layer-opacity, 0.12);--_hover-icon-color: var(--md-filled-icon-button-hover-icon-color, var(--md-sys-color-on-primary, #fff));--_hover-state-layer-color: var(--md-filled-icon-button-hover-state-layer-color, var(--md-sys-color-on-primary, #fff));--_hover-state-layer-opacity: var(--md-filled-icon-button-hover-state-layer-opacity, 0.08);--_icon-color: var(--md-filled-icon-button-icon-color, var(--md-sys-color-on-primary, #fff));--_icon-size: var(--md-filled-icon-button-icon-size, 24px);--_pressed-icon-color: var(--md-filled-icon-button-pressed-icon-color, var(--md-sys-color-on-primary, #fff));--_pressed-state-layer-color: var(--md-filled-icon-button-pressed-state-layer-color, var(--md-sys-color-on-primary, #fff));--_pressed-state-layer-opacity: var(--md-filled-icon-button-pressed-state-layer-opacity, 0.12);--_selected-container-color: var(--md-filled-icon-button-selected-container-color, var(--md-sys-color-primary, #6750a4));--_toggle-selected-focus-icon-color: var(--md-filled-icon-button-toggle-selected-focus-icon-color, var(--md-sys-color-on-primary, #fff));--_toggle-selected-focus-state-layer-color: var(--md-filled-icon-button-toggle-selected-focus-state-layer-color, var(--md-sys-color-on-primary, #fff));--_toggle-selected-hover-icon-color: var(--md-filled-icon-button-toggle-selected-hover-icon-color, var(--md-sys-color-on-primary, #fff));--_toggle-selected-hover-state-layer-color: var(--md-filled-icon-button-toggle-selected-hover-state-layer-color, var(--md-sys-color-on-primary, #fff));--_toggle-selected-icon-color: var(--md-filled-icon-button-toggle-selected-icon-color, var(--md-sys-color-on-primary, #fff));--_toggle-selected-pressed-icon-color: var(--md-filled-icon-button-toggle-selected-pressed-icon-color, var(--md-sys-color-on-primary, #fff));--_toggle-selected-pressed-state-layer-color: var(--md-filled-icon-button-toggle-selected-pressed-state-layer-color, var(--md-sys-color-on-primary, #fff));--_toggle-unselected-focus-icon-color: var(--md-filled-icon-button-toggle-unselected-focus-icon-color, var(--md-sys-color-primary, #6750a4));--_toggle-unselected-focus-state-layer-color: var(--md-filled-icon-button-toggle-unselected-focus-state-layer-color, var(--md-sys-color-primary, #6750a4));--_toggle-unselected-hover-icon-color: var(--md-filled-icon-button-toggle-unselected-hover-icon-color, var(--md-sys-color-primary, #6750a4));--_toggle-unselected-hover-state-layer-color: var(--md-filled-icon-button-toggle-unselected-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--_toggle-unselected-icon-color: var(--md-filled-icon-button-toggle-unselected-icon-color, var(--md-sys-color-primary, #6750a4));--_toggle-unselected-pressed-icon-color: var(--md-filled-icon-button-toggle-unselected-pressed-icon-color, var(--md-sys-color-primary, #6750a4));--_toggle-unselected-pressed-state-layer-color: var(--md-filled-icon-button-toggle-unselected-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_unselected-container-color: var(--md-filled-icon-button-unselected-container-color, var(--md-sys-color-surface-variant, #e7e0ec));--md-focus-ring-shape-start-start:var(--_container-shape-start-start);--md-focus-ring-shape-start-end:var(--_container-shape-start-end);--md-focus-ring-shape-end-end:var(--_container-shape-end-end);--md-focus-ring-shape-end-start:var(--_container-shape-end-start)}.md3-icon-button{background-color:var(--_container-color);color:var(--_icon-color);--md-ripple-focus-state-layer-color:var(--_focus-state-layer-color);--md-ripple-focus-state-layer-opacity:var(--_focus-state-layer-opacity);--md-ripple-hover-state-layer-color:var(--_hover-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_hover-state-layer-opacity);--md-ripple-pressed-state-layer-color:var(--_pressed-state-layer-color);--md-ripple-pressed-state-layer-opacity:var(--_pressed-state-layer-opacity)}.md3-icon-button:hover{color:var(--_hover-icon-color)}.md3-icon-button:focus{color:var(--_focus-icon-color)}.md3-icon-button:active{color:var(--_pressed-icon-color)}.md3-icon-button:disabled{background-color:var(--_disabled-container-color);color:var(--_disabled-icon-color)}.md3-icon-button--toggle-filled{--md-ripple-focus-state-layer-color:var(--_toggle-unselected-focus-state-layer-color);--md-ripple-hover-state-layer-color:var(--_toggle-unselected-hover-state-layer-color);--md-ripple-pressed-state-layer-color:var(--_toggle-unselected-pressed-state-layer-color)}.md3-icon-button--toggle-filled:not(:disabled){background-color:var(--_unselected-container-color);color:var(--_toggle-unselected-icon-color)}.md3-icon-button--toggle-filled:not(:disabled):hover{color:var(--_toggle-unselected-hover-icon-color)}.md3-icon-button--toggle-filled:not(:disabled):focus{color:var(--_toggle-unselected-focus-icon-color)}.md3-icon-button--toggle-filled:not(:disabled):active{color:var(--_toggle-unselected-pressed-icon-color)}.md3-icon-button--selected{--md-ripple-focus-state-layer-color:var(--_toggle-selected-focus-state-layer-color);--md-ripple-hover-state-layer-color:var(--_toggle-selected-hover-state-layer-color);--md-ripple-pressed-state-layer-color:var(--_toggle-selected-pressed-state-layer-color)}.md3-icon-button--selected:not(:disabled){background-color:var(--_selected-container-color);color:var(--_toggle-selected-icon-color)}.md3-icon-button--selected:not(:disabled):hover{color:var(--_toggle-selected-hover-icon-color)}.md3-icon-button--selected:not(:disabled):focus{color:var(--_toggle-selected-focus-icon-color)}.md3-icon-button--selected:not(:disabled):active{color:var(--_toggle-selected-pressed-icon-color)}/*# sourceMappingURL=filled-styles.css.map */ `; //# sourceMappingURL=filled-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/filled-tonal-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/filled-tonal-styles.css.js index a580bb3..c02a2fe 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/filled-tonal-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/filled-tonal-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-shape-start-start: var(--md-filled-tonal-icon-button-container-shape-start-start, 9999px);--_container-shape-start-end: var(--md-filled-tonal-icon-button-container-shape-start-end, 9999px);--_container-shape-end-end: var(--md-filled-tonal-icon-button-container-shape-end-end, 9999px);--_container-shape-end-start: var(--md-filled-tonal-icon-button-container-shape-end-start, 9999px);--_container-color: var(--md-filled-tonal-icon-button-container-color, var(--md-sys-color-secondary-container, #e8def8));--_container-size: var(--md-filled-tonal-icon-button-container-size, 40px);--_disabled-container-color: var(--md-filled-tonal-icon-button-disabled-container-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.12));--_disabled-icon-color: var(--md-filled-tonal-icon-button-disabled-icon-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_focus-icon-color: var(--md-filled-tonal-icon-button-focus-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_focus-state-layer-color: var(--md-filled-tonal-icon-button-focus-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_focus-state-layer-opacity: var(--md-filled-tonal-icon-button-focus-state-layer-opacity, 0.12);--_hover-icon-color: var(--md-filled-tonal-icon-button-hover-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_hover-state-layer-color: var(--md-filled-tonal-icon-button-hover-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_hover-state-layer-opacity: var(--md-filled-tonal-icon-button-hover-state-layer-opacity, 0.08);--_icon-color: var(--md-filled-tonal-icon-button-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_icon-size: var(--md-filled-tonal-icon-button-icon-size, 24px);--_pressed-icon-color: var(--md-filled-tonal-icon-button-pressed-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_pressed-state-layer-color: var(--md-filled-tonal-icon-button-pressed-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_pressed-state-layer-opacity: var(--md-filled-tonal-icon-button-pressed-state-layer-opacity, 0.12);--_selected-container-color: var(--md-filled-tonal-icon-button-selected-container-color, var(--md-sys-color-secondary-container, #e8def8));--_toggle-selected-focus-icon-color: var(--md-filled-tonal-icon-button-toggle-selected-focus-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_toggle-selected-focus-state-layer-color: var(--md-filled-tonal-icon-button-toggle-selected-focus-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_toggle-selected-hover-icon-color: var(--md-filled-tonal-icon-button-toggle-selected-hover-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_toggle-selected-hover-state-layer-color: var(--md-filled-tonal-icon-button-toggle-selected-hover-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_toggle-selected-icon-color: var(--md-filled-tonal-icon-button-toggle-selected-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_toggle-selected-pressed-icon-color: var(--md-filled-tonal-icon-button-toggle-selected-pressed-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_toggle-selected-pressed-state-layer-color: var(--md-filled-tonal-icon-button-toggle-selected-pressed-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_toggle-unselected-focus-icon-color: var(--md-filled-tonal-icon-button-toggle-unselected-focus-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_toggle-unselected-focus-state-layer-color: var(--md-filled-tonal-icon-button-toggle-unselected-focus-state-layer-color, var(--md-sys-color-on-surface-variant, #49454f));--_toggle-unselected-hover-icon-color: var(--md-filled-tonal-icon-button-toggle-unselected-hover-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_toggle-unselected-hover-state-layer-color: var(--md-filled-tonal-icon-button-toggle-unselected-hover-state-layer-color, var(--md-sys-color-on-surface-variant, #49454f));--_toggle-unselected-icon-color: var(--md-filled-tonal-icon-button-toggle-unselected-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_toggle-unselected-pressed-icon-color: var(--md-filled-tonal-icon-button-toggle-unselected-pressed-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_toggle-unselected-pressed-state-layer-color: var(--md-filled-tonal-icon-button-toggle-unselected-pressed-state-layer-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-container-color: var(--md-filled-tonal-icon-button-unselected-container-color, var(--md-sys-color-surface-variant, #e7e0ec));--md-focus-ring-shape-start-start:var(--_container-shape-start-start);--md-focus-ring-shape-start-end:var(--_container-shape-start-end);--md-focus-ring-shape-end-end:var(--_container-shape-end-end);--md-focus-ring-shape-end-start:var(--_container-shape-end-start)}.md3-icon-button{background-color:var(--_container-color);color:var(--_icon-color);--md-ripple-focus-state-layer-color:var(--_focus-state-layer-color);--md-ripple-focus-state-layer-opacity:var(--_focus-state-layer-opacity);--md-ripple-hover-state-layer-color:var(--_hover-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_hover-state-layer-opacity);--md-ripple-pressed-state-layer-color:var(--_pressed-state-layer-color);--md-ripple-pressed-state-layer-opacity:var(--_pressed-state-layer-opacity)}.md3-icon-button:hover{color:var(--_hover-icon-color)}.md3-icon-button:focus{color:var(--_focus-icon-color)}.md3-icon-button:active{color:var(--_pressed-icon-color)}.md3-icon-button:disabled{background-color:var(--_disabled-container-color);color:var(--_disabled-icon-color)}.md3-icon-button--toggle-filled-tonal{--md-ripple-focus-state-layer-color:var(--_toggle-unselected-focus-state-layer-color);--md-ripple-hover-state-layer-color:var(--_toggle-unselected-hover-state-layer-color);--md-ripple-pressed-state-layer-color:var(--_toggle-unselected-pressed-state-layer-color)}.md3-icon-button--toggle-filled-tonal:not(:disabled){background-color:var(--_unselected-container-color);color:var(--_toggle-unselected-icon-color)}.md3-icon-button--toggle-filled-tonal:not(:disabled):hover{color:var(--_toggle-unselected-hover-icon-color)}.md3-icon-button--toggle-filled-tonal:not(:disabled):focus{color:var(--_toggle-unselected-focus-icon-color)}.md3-icon-button--toggle-filled-tonal:not(:disabled):active{color:var(--_toggle-unselected-pressed-icon-color)}.md3-icon-button--selected{--md-ripple-focus-state-layer-color:var(--_toggle-selected-focus-state-layer-color);--md-ripple-hover-state-layer-color:var(--_toggle-selected-hover-state-layer-color);--md-ripple-pressed-state-layer-color:var(--_toggle-selected-pressed-state-layer-color)}.md3-icon-button--selected:not(:disabled){background-color:var(--_selected-container-color);color:var(--_toggle-selected-icon-color)}.md3-icon-button--selected:not(:disabled):hover{color:var(--_toggle-selected-hover-icon-color)}.md3-icon-button--selected:not(:disabled):focus{color:var(--_toggle-selected-focus-icon-color)}.md3-icon-button--selected:not(:disabled):active{color:var(--_toggle-selected-pressed-icon-color)}/*# sourceMappingURL=filled-tonal-styles.css.map */ `; //# sourceMappingURL=filled-tonal-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/icon-button-toggle.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/icon-button-toggle.js index 0ac90a5bf..729905b 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/icon-button-toggle.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/icon-button-toggle.js
@@ -3,16 +3,16 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; // Required for @ariaProperty // tslint:disable:no-new-decorators import '../../focus/focus-ring.js'; import '../../icon/icon.js'; import '../../ripple/ripple.js'; -import { html, nothing } from '../../../../lit/index.js'; -import { property } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { when } from '../../../../lit/directives/when.js'; +import { html, nothing } from 'lit'; +import { property } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { when } from 'lit/directives/when.js'; import { ripple } from '../../ripple/directive.js'; import { IconButton } from './icon-button.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/icon-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/icon-button.js index 43e53233..a158b75b 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/icon-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/icon-button.js
@@ -3,17 +3,17 @@ * Copyright 2018 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; // This is required for @ariaProperty // tslint:disable:no-new-decorators import '../../focus/focus-ring.js'; import '../../icon/icon.js'; import '../../ripple/ripple.js'; -import { html, LitElement } from '../../../../lit/index.js'; -import { property, query, queryAsync, state } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../lit/directives/if-defined.js'; -import { when } from '../../../../lit/directives/when.js'; +import { html, LitElement } from 'lit'; +import { property, query, queryAsync, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; +import { when } from 'lit/directives/when.js'; import { isRtl } from '../../controller/is-rtl.js'; import { ariaProperty } from '../../decorators/aria-property.js'; import { pointerPress, shouldShowStrongFocus } from '../../focus/strong-focus.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/link-icon-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/link-icon-button.js index 5a96936..be2f12f 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/link-icon-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/link-icon-button.js
@@ -3,12 +3,12 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; -import { html } from '../../../../lit/index.js'; -import { property } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../lit/directives/if-defined.js'; -import { when } from '../../../../lit/directives/when.js'; +import { __decorate, __metadata } from "tslib"; +import { html } from 'lit'; +import { property } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; +import { when } from 'lit/directives/when.js'; import { ripple } from '../../ripple/directive.js'; import { IconButton } from './icon-button.js'; // tslint:disable-next-line:enforce-comments-on-exported-symbols
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/outlined-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/outlined-styles.css.js index bfc9af7c..e560c27a 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/outlined-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/outlined-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-shape-start-start: var(--md-outlined-icon-button-container-shape-start-start, 9999px);--_container-shape-start-end: var(--md-outlined-icon-button-container-shape-start-end, 9999px);--_container-shape-end-end: var(--md-outlined-icon-button-container-shape-end-end, 9999px);--_container-shape-end-start: var(--md-outlined-icon-button-container-shape-end-start, 9999px);--_container-size: var(--md-outlined-icon-button-container-size, 40px);--_disabled-icon-color: var(--md-outlined-icon-button-disabled-icon-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_disabled-selected-container-color: var(--md-outlined-icon-button-disabled-selected-container-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.12));--_disabled-unselected-outline-color: var(--md-outlined-icon-button-disabled-unselected-outline-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-unselected-outline-opacity: var(--md-outlined-icon-button-disabled-unselected-outline-opacity, 0.12);--_focus-state-layer-opacity: var(--md-outlined-icon-button-focus-state-layer-opacity, 0.08);--_hover-state-layer-opacity: var(--md-outlined-icon-button-hover-state-layer-opacity, 0.08);--_icon-size: var(--md-outlined-icon-button-icon-size, 24px);--_pressed-state-layer-opacity: var(--md-outlined-icon-button-pressed-state-layer-opacity, 0.12);--_selected-container-color: var(--md-outlined-icon-button-selected-container-color, var(--md-sys-color-inverse-surface, #313033));--_selected-focus-icon-color: var(--md-outlined-icon-button-selected-focus-icon-color, var(--md-sys-color-inverse-on-surface, #f4eff4));--_selected-focus-state-layer-color: var(--md-outlined-icon-button-selected-focus-state-layer-color, var(--md-sys-color-inverse-on-surface, #f4eff4));--_selected-hover-icon-color: var(--md-outlined-icon-button-selected-hover-icon-color, var(--md-sys-color-inverse-on-surface, #f4eff4));--_selected-hover-state-layer-color: var(--md-outlined-icon-button-selected-hover-state-layer-color, var(--md-sys-color-inverse-on-surface, #f4eff4));--_selected-icon-color: var(--md-outlined-icon-button-selected-icon-color, var(--md-sys-color-inverse-on-surface, #f4eff4));--_selected-pressed-icon-color: var(--md-outlined-icon-button-selected-pressed-icon-color, var(--md-sys-color-inverse-on-surface, #f4eff4));--_selected-pressed-state-layer-color: var(--md-outlined-icon-button-selected-pressed-state-layer-color, var(--md-sys-color-inverse-on-surface, #f4eff4));--_unselected-focus-icon-color: var(--md-outlined-icon-button-unselected-focus-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-focus-state-layer-color: var(--md-outlined-icon-button-unselected-focus-state-layer-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-hover-icon-color: var(--md-outlined-icon-button-unselected-hover-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-hover-state-layer-color: var(--md-outlined-icon-button-unselected-hover-state-layer-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-icon-color: var(--md-outlined-icon-button-unselected-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-outline-color: var(--md-outlined-icon-button-unselected-outline-color, var(--md-sys-color-outline, #79747e));--_unselected-outline-width: var(--md-outlined-icon-button-unselected-outline-width, 1px);--_unselected-pressed-icon-color: var(--md-outlined-icon-button-unselected-pressed-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-pressed-state-layer-color: var(--md-outlined-icon-button-unselected-pressed-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--md-focus-ring-shape-start-start:var(--_container-shape-start-start);--md-focus-ring-shape-start-end:var(--_container-shape-start-end);--md-focus-ring-shape-end-end:var(--_container-shape-end-end);--md-focus-ring-shape-end-start:var(--_container-shape-end-start)}.md3-icon-button--outlined{background-color:rgba(0,0,0,0);color:var(--_unselected-icon-color);--md-ripple-focus-state-layer-color:var(--_unselected-focus-state-layer-color);--md-ripple-focus-state-layer-opacity:var(--_focus-state-layer-opacity);--md-ripple-hover-state-layer-color:var(--_unselected-hover-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_hover-state-layer-opacity);--md-ripple-pressed-state-layer-color:var(--_unselected-pressed-state-layer-color);--md-ripple-pressed-state-layer-opacity:var(--_pressed-state-layer-opacity)}.md3-icon-button--outlined::before{border-color:var(--_unselected-outline-color);border-width:var(--_unselected-outline-width)}.md3-icon-button--outlined:hover{color:var(--_unselected-hover-icon-color)}.md3-icon-button--outlined:focus{color:var(--_unselected-focus-icon-color)}.md3-icon-button--outlined:active{color:var(--_unselected-pressed-icon-color)}.md3-icon-button--outlined:disabled{color:var(--_disabled-icon-color)}.md3-icon-button--outlined:disabled::before{border-color:var(--_disabled-unselected-outline-color);opacity:var(--_disabled-unselected-outline-opacity)}.md3-icon-button--outlined::before{block-size:100%;border-style:solid;border-radius:inherit;box-sizing:border-box;content:"";inline-size:100%;inset:0;pointer-events:none;position:absolute}.md3-icon-button--outlined.md3-icon-button--selected::before{border-width:0}.md3-icon-button--selected{--md-ripple-focus-state-layer-color:var(--_selected-focus-state-layer-color);--md-ripple-focus-state-layer-opacity:var(--_focus-state-layer-opacity);--md-ripple-hover-state-layer-color:var(--_selected-hover-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_hover-state-layer-opacity);--md-ripple-pressed-state-layer-color:var(--_selected-pressed-state-layer-color);--md-ripple-pressed-state-layer-opacity:var(--_pressed-state-layer-opacity)}.md3-icon-button--selected:not(:disabled){background-color:var(--_selected-container-color);color:var(--_selected-icon-color)}.md3-icon-button--selected:not(:disabled):hover{color:var(--_selected-hover-icon-color)}.md3-icon-button--selected:not(:disabled):focus{color:var(--_selected-focus-icon-color)}.md3-icon-button--selected:not(:disabled):active{color:var(--_selected-pressed-icon-color)}.md3-icon-button--selected:disabled{background-color:var(--_disabled-selected-container-color)}@media(forced-colors: active){.md3-icon-button--selected::before{border-color:var(--_unselected-outline-color);border-width:var(--_unselected-outline-width)}.md3-icon-button--selected:disabled::before{border-color:var(--_disabled-unselected-outline-color);opacity:var(--_disabled-unselected-outline-opacity)}}/*# sourceMappingURL=outlined-styles.css.map */ `; //# sourceMappingURL=outlined-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/shared-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/shared-styles.css.js index b4ca2695..4d64996 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/shared-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/shared-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{display:inline-flex;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0);height:max(48px,var(--_container-size));width:max(48px,var(--_container-size));align-items:center;justify-content:center}:host([disabled]){pointer-events:none}.md3-icon-button{align-items:center;border:none;box-sizing:border-box;cursor:pointer;display:flex;justify-content:center;outline:none;position:relative;text-decoration:none;user-select:none;z-index:0;height:var(--_container-size);width:var(--_container-size);border-start-start-radius:var(--_container-shape-start-start);border-start-end-radius:var(--_container-shape-start-end);border-end-start-radius:var(--_container-shape-end-start);border-end-end-radius:var(--_container-shape-end-end)}.md3-icon-button__icon{--md-icon-size:var(--_icon-size);--md-icon-weight:inherit}md-ripple{z-index:-1;border-start-start-radius:var(--_container-shape-start-start);border-start-end-radius:var(--_container-shape-start-end);border-end-start-radius:var(--_container-shape-end-start);border-end-end-radius:var(--_container-shape-end-end)}.md3-icon-button--flip-icon .md3-icon-button__icon{transform:scaleX(-1)}.md3-icon-button__icon{display:inline-flex}.md3-icon-button__link{height:100%;outline:none;position:absolute;width:100%}.md3-icon-button__touch{position:absolute;top:50%;height:48px;left:50%;width:48px;transform:translate(-50%, -50%)}/*# sourceMappingURL=shared-styles.css.map */ `; //# sourceMappingURL=shared-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/standard-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/standard-styles.css.js index 6855ebfc..49bc45a 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/standard-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/lib/standard-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_state-layer-shape-start-start: var(--md-icon-button-state-layer-shape-start-start, 9999px);--_state-layer-shape-start-end: var(--md-icon-button-state-layer-shape-start-end, 9999px);--_state-layer-shape-end-end: var(--md-icon-button-state-layer-shape-end-end, 9999px);--_state-layer-shape-end-start: var(--md-icon-button-state-layer-shape-end-start, 9999px);--_disabled-icon-color: var(--md-icon-button-disabled-icon-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_icon-size: var(--md-icon-button-icon-size, 24px);--_selected-focus-icon-color: var(--md-icon-button-selected-focus-icon-color, var(--md-sys-color-primary, #6750a4));--_selected-focus-state-layer-color: var(--md-icon-button-selected-focus-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-focus-state-layer-opacity: var(--md-icon-button-selected-focus-state-layer-opacity, 0.12);--_selected-hover-icon-color: var(--md-icon-button-selected-hover-icon-color, var(--md-sys-color-primary, #6750a4));--_selected-hover-state-layer-color: var(--md-icon-button-selected-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-hover-state-layer-opacity: var(--md-icon-button-selected-hover-state-layer-opacity, 0.08);--_selected-icon-color: var(--md-icon-button-selected-icon-color, var(--md-sys-color-primary, #6750a4));--_selected-pressed-icon-color: var(--md-icon-button-selected-pressed-icon-color, var(--md-sys-color-primary, #6750a4));--_selected-pressed-state-layer-color: var(--md-icon-button-selected-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-pressed-state-layer-opacity: var(--md-icon-button-selected-pressed-state-layer-opacity, 0.12);--_state-layer-size: var(--md-icon-button-state-layer-size, 40px);--_unselected-focus-icon-color: var(--md-icon-button-unselected-focus-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-focus-state-layer-color: var(--md-icon-button-unselected-focus-state-layer-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-focus-state-layer-opacity: var(--md-icon-button-unselected-focus-state-layer-opacity, 0.12);--_unselected-hover-icon-color: var(--md-icon-button-unselected-hover-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-hover-state-layer-color: var(--md-icon-button-unselected-hover-state-layer-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-hover-state-layer-opacity: var(--md-icon-button-unselected-hover-state-layer-opacity, 0.08);--_unselected-icon-color: var(--md-icon-button-unselected-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-pressed-icon-color: var(--md-icon-button-unselected-pressed-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-pressed-state-layer-color: var(--md-icon-button-unselected-pressed-state-layer-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-pressed-state-layer-opacity: var(--md-icon-button-unselected-pressed-state-layer-opacity, 0.12);height:max(48px,var(--_state-layer-size));width:max(48px,var(--_state-layer-size));--md-focus-ring-shape-start-start:var(--_state-layer-shape-start-start);--md-focus-ring-shape-start-end:var(--_state-layer-shape-start-end);--md-focus-ring-shape-end-end:var(--_state-layer-shape-end-end);--md-focus-ring-shape-end-start:var(--_state-layer-shape-end-start)}.md3-icon-button--standard{background-color:rgba(0,0,0,0);color:var(--_unselected-icon-color);height:var(--_state-layer-size);width:var(--_state-layer-size);--md-ripple-focus-state-layer-color:var(--_unselected-focus-state-layer-color);--md-ripple-focus-state-layer-opacity:var(--_unselected-focus-state-layer-opacity);--md-ripple-hover-state-layer-color:var(--_unselected-hover-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_unselected-hover-state-layer-opacity);--md-ripple-pressed-state-layer-color:var(--_unselected-pressed-state-layer-color);--md-ripple-pressed-state-layer-opacity:var(--_unselected-pressed-state-layer-opacity);--md-ripple-state-layer-shape:var(--_state-layer-shape-start-start)}.md3-icon-button--standard:hover{color:var(--_unselected-hover-icon-color)}.md3-icon-button--standard:focus{color:var(--_unselected-focus-icon-color)}.md3-icon-button--standard:active{color:var(--_unselected-pressed-icon-color)}.md3-icon-button--standard:disabled{color:var(--_disabled-icon-color)}.md3-icon-button--selected{--md-ripple-focus-state-layer-color:var(--_selected-focus-state-layer-color);--md-ripple-focus-state-layer-opacity:var(--_selected-focus-state-layer-opacity);--md-ripple-hover-state-layer-color:var(--_selected-hover-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_selected-hover-state-layer-opacity);--md-ripple-pressed-state-layer-color:var(--_selected-pressed-state-layer-color);--md-ripple-pressed-state-layer-opacity:var(--_selected-pressed-state-layer-opacity)}.md3-icon-button--selected:not(:disabled){color:var(--_selected-icon-color)}.md3-icon-button--selected:not(:disabled):hover{color:var(--_selected-hover-icon-color)}.md3-icon-button--selected:not(:disabled):focus{color:var(--_selected-focus-icon-color)}.md3-icon-button--selected:not(:disabled):active{color:var(--_selected-pressed-icon-color)}/*# sourceMappingURL=standard-styles.css.map */ `; //# sourceMappingURL=standard-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/outlined-icon-button-toggle.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/outlined-icon-button-toggle.js index cb13b662..8a0ffd9 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/outlined-icon-button-toggle.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/outlined-icon-button-toggle.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { IconButtonToggle } from './lib/icon-button-toggle.js'; import { styles } from './lib/outlined-styles.css.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/outlined-icon-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/outlined-icon-button.js index 1d43513..f32870fb 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/outlined-icon-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/outlined-icon-button.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { IconButton } from './lib/icon-button.js'; import { styles } from './lib/outlined-styles.css.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/outlined-link-icon-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/outlined-link-icon-button.js index 7dcf0df..861069d 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/outlined-link-icon-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/outlined-link-icon-button.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { LinkIconButton } from './lib/link-icon-button.js'; import { styles } from './lib/outlined-styles.css.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/standard-icon-button-toggle.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/standard-icon-button-toggle.js index 13e2b37..ff0fe7f 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/standard-icon-button-toggle.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/standard-icon-button-toggle.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { IconButtonToggle } from './lib/icon-button-toggle.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js'; import { styles } from './lib/standard-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/standard-icon-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/standard-icon-button.js index 0badd5c..fb951e8df 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/standard-icon-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/standard-icon-button.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { IconButton } from './lib/icon-button.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js'; import { styles } from './lib/standard-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/standard-link-icon-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/standard-link-icon-button.js index b6f5de4..cc768dd 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/standard-link-icon-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/iconbutton/standard-link-icon-button.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { LinkIconButton } from './lib/link-icon-button.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js'; import { styles } from './lib/standard-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/avatar/list-item-avatar-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/avatar/list-item-avatar-styles.css.js index cc4a3d9..6989952c0 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/avatar/list-item-avatar-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/avatar/list-item-avatar-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_list-item-leading-avatar-color: var(--md-list-list-item-leading-avatar-color, var(--md-sys-color-primary-container, #eaddff));--_list-item-leading-avatar-shape: var(--md-list-list-item-leading-avatar-shape, 9999px);--_list-item-leading-avatar-size: var(--md-list-list-item-leading-avatar-size, 40px)}.md3-list-item__avatar{border-radius:var(--_list-item-leading-avatar-shape);display:inline-flex;height:var(--_list-item-leading-avatar-size);margin-inline-start:16px;width:var(--_list-item-leading-avatar-size)}/*# sourceMappingURL=list-item-avatar-styles.css.map */ `; //# sourceMappingURL=list-item-avatar-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/avatar/list-item-avatar.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/avatar/list-item-avatar.js index 588c8da7..b852b20 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/avatar/list-item-avatar.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/avatar/list-item-avatar.js
@@ -3,9 +3,9 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; -import { html, LitElement, nothing } from '../../../../../lit/index.js'; -import { property } from '../../../../../lit/decorators.js'; +import { __decorate, __metadata } from "tslib"; +import { html, LitElement, nothing } from 'lit'; +import { property } from 'lit/decorators.js'; // tslint:disable-next-line:enforce-comments-on-exported-symbols export class ListItemAvatar extends LitElement { constructor() {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/icon/list-item-icon-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/icon/list-item-icon-styles.css.js index 63dba3ff..b9f334c 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/icon/list-item-icon-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/icon/list-item-icon-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_list-item-icon-color: var(--md-list-item-icon-list-item-icon-color, #000);--_list-item-icon-size: var(--md-list-item-icon-list-item-icon-size, 0);--_list-item-icon-opacity: var(--md-list-item-icon-list-item-icon-opacity, 1);display:inline-flex}.md3-list-item__icon{color:var(--_list-item-icon-color);opacity:var(--_list-item-icon-opacity);font-family:"Material Icons";font-weight:normal;font-style:normal;font-size:var(--_list-item-icon-size);line-height:1;letter-spacing:normal;text-transform:none;display:inline-flex;white-space:nowrap;word-wrap:normal;direction:ltr;height:100%;width:100%;padding-inline-start:16px;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:"liga"}/*# sourceMappingURL=list-item-icon-styles.css.map */ `; //# sourceMappingURL=list-item-icon-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/icon/list-item-icon.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/icon/list-item-icon.js index 32023030..8718002 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/icon/list-item-icon.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/icon/list-item-icon.js
@@ -3,7 +3,7 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { html, LitElement } from '../../../../../lit/index.js'; +import { html, LitElement } from 'lit'; // tslint:disable-next-line:enforce-comments-on-exported-symbols export class ListItemIcon extends LitElement { render() {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/image/list-item-image-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/image/list-item-image-styles.css.js index cfeabd5d..9279c18a 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/image/list-item-image-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/image/list-item-image-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_list-item-leading-image-height: var(--md-list-item-image-list-item-leading-image-height, 56px);--_list-item-leading-image-width: var(--md-list-item-image-list-item-leading-image-width, 56px);--_list-item-leading-image-shape: var(--md-list-item-image-list-item-leading-image-shape, 0px)}.md3-list-item__image{display:inline-flex;margin-block-end:8px;margin-block-start:8px;margin-inline-start:16px;height:var(--_list-item-leading-image-height);width:var(--_list-item-leading-image-width);border-radius:var(--_list-item-leading-image-shape)}/*# sourceMappingURL=list-item-image-styles.css.map */ `; //# sourceMappingURL=list-item-image-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/image/list-item-image.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/image/list-item-image.js index 270f3d0e..8ddc945 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/image/list-item-image.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/image/list-item-image.js
@@ -3,9 +3,9 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; -import { html, LitElement, nothing } from '../../../../../lit/index.js'; -import { property } from '../../../../../lit/decorators.js'; +import { __decorate, __metadata } from "tslib"; +import { html, LitElement, nothing } from 'lit'; +import { property } from 'lit/decorators.js'; // tslint:disable-next-line:enforce-comments-on-exported-symbols export class ListItemImage extends LitElement { constructor() {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/list-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/list-styles.css.js index 56132397..901948a 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/list-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/list-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-color: var(--md-list-container-color, var(--md-sys-color-surface, #fffbfe));color:unset}.md3-list{background-color:var(--_container-color);display:block;list-style-type:none;margin:0;min-width:300px;outline:none;padding:8px 0;position:relative}/*# sourceMappingURL=list-styles.css.map */ `; //# sourceMappingURL=list-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/list.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/list.js index 1b788679..3a1aee62 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/list.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/list.js
@@ -3,13 +3,13 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; // Required for @ariaProperty // tslint:disable:no-new-decorators -import { html, LitElement } from '../../../../lit/index.js'; -import { property, query, queryAssignedElements } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../lit/directives/if-defined.js'; +import { html, LitElement } from 'lit'; +import { property, query, queryAssignedElements } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { ariaProperty } from '../../decorators/aria-property.js'; const NAVIGABLE_KEYS = { ArrowDown: 'ArrowDown',
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitem/list-item-private-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitem/list-item-private-styles.css.js index 40b313aef..84677845 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitem/list-item-private-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitem/list-item-private-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_list-item-container-color: var(--md-list-list-item-container-color, var(--md-sys-color-surface, #fffbfe));--_list-item-container-elevation: var(--md-list-list-item-container-elevation, 0);--_list-item-container-shape: var(--md-list-list-item-container-shape, 0px);--_list-item-disabled-label-text-color: var(--md-list-list-item-disabled-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-disabled-label-text-opacity: var(--md-list-list-item-disabled-label-text-opacity, 0.3);--_list-item-disabled-leading-icon-color: var(--md-list-list-item-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-disabled-leading-icon-opacity: var(--md-list-list-item-disabled-leading-icon-opacity, 0.38);--_list-item-disabled-state-layer-color: var(--md-list-list-item-disabled-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-disabled-state-layer-opacity: var(--md-list-list-item-disabled-state-layer-opacity, 0.12);--_list-item-disabled-trailing-icon-color: var(--md-list-list-item-disabled-trailing-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-disabled-trailing-icon-opacity: var(--md-list-list-item-disabled-trailing-icon-opacity, 0.38);--_list-item-dragged-container-elevation: var(--md-list-list-item-dragged-container-elevation, 8);--_list-item-dragged-label-text-color: var(--md-list-list-item-dragged-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-dragged-leading-icon-icon-color: var(--md-list-list-item-dragged-leading-icon-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-dragged-state-layer-color: var(--md-list-list-item-dragged-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-dragged-state-layer-opacity: var(--md-list-list-item-dragged-state-layer-opacity, 0.12);--_list-item-dragged-trailing-icon-icon-color: var(--md-list-list-item-dragged-trailing-icon-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-focus-label-text-color: var(--md-list-list-item-focus-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-focus-leading-icon-icon-color: var(--md-list-list-item-focus-leading-icon-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-focus-state-layer-color: var(--md-list-list-item-focus-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-focus-state-layer-opacity: var(--md-list-list-item-focus-state-layer-opacity, 0.12);--_list-item-focus-trailing-icon-icon-color: var(--md-list-list-item-focus-trailing-icon-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-hover-label-text-color: var(--md-list-list-item-hover-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-hover-leading-icon-icon-color: var(--md-list-list-item-hover-leading-icon-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-hover-state-layer-color: var(--md-list-list-item-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-hover-state-layer-opacity: var(--md-list-list-item-hover-state-layer-opacity, 0.08);--_list-item-hover-trailing-icon-icon-color: var(--md-list-list-item-hover-trailing-icon-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-label-text-color: var(--md-list-list-item-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-label-text-font: var(--md-list-list-item-label-text-font, Roboto);--_list-item-label-text-line-height: var(--md-list-list-item-label-text-line-height, 1.5rem);--_list-item-label-text-size: var(--md-list-list-item-label-text-size, 1rem);--_list-item-label-text-tracking: var(--md-list-list-item-label-text-tracking, 0.031rem);--_list-item-label-text-type: var(--md-list-list-item-label-text-type, 400 1rem / 1.5rem Roboto);--_list-item-label-text-weight: var(--md-list-list-item-label-text-weight, 400);--_list-item-large-leading-video-height: var(--md-list-list-item-large-leading-video-height, 69px);--_list-item-leading-avatar-label-color: var(--md-list-list-item-leading-avatar-label-color, var(--md-sys-color-on-primary-container, #21005d));--_list-item-leading-avatar-label-font: var(--md-list-list-item-leading-avatar-label-font, Roboto);--_list-item-leading-avatar-label-line-height: var(--md-list-list-item-leading-avatar-label-line-height, 1.5rem);--_list-item-leading-avatar-label-size: var(--md-list-list-item-leading-avatar-label-size, 1rem);--_list-item-leading-avatar-label-tracking: var(--md-list-list-item-leading-avatar-label-tracking, 0.009rem);--_list-item-leading-avatar-label-type: var(--md-list-list-item-leading-avatar-label-type, 500 1rem / 1.5rem Roboto);--_list-item-leading-avatar-label-weight: var(--md-list-list-item-leading-avatar-label-weight, 500);--_list-item-leading-avatar-color: var(--md-list-list-item-leading-avatar-color, var(--md-sys-color-primary-container, #eaddff));--_list-item-leading-avatar-shape: var(--md-list-list-item-leading-avatar-shape, 9999px);--_list-item-leading-avatar-size: var(--md-list-list-item-leading-avatar-size, 40px);--_list-item-leading-icon-color: var(--md-list-list-item-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-leading-icon-size: var(--md-list-list-item-leading-icon-size, 18px);--_list-item-leading-image-height: var(--md-list-list-item-leading-image-height, 56px);--_list-item-leading-image-shape: var(--md-list-list-item-leading-image-shape, 0px);--_list-item-leading-image-width: var(--md-list-list-item-leading-image-width, 56px);--_list-item-leading-video-shape: var(--md-list-list-item-leading-video-shape, 0px);--_list-item-leading-video-width: var(--md-list-list-item-leading-video-width, 100px);--_list-item-one-line-container-height: var(--md-list-list-item-one-line-container-height, 56px);--_list-item-overline-color: var(--md-list-list-item-overline-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-overline-font: var(--md-list-list-item-overline-font, Roboto);--_list-item-overline-line-height: var(--md-list-list-item-overline-line-height, 1rem);--_list-item-overline-size: var(--md-list-list-item-overline-size, 0.688rem);--_list-item-overline-tracking: var(--md-list-list-item-overline-tracking, 0.031rem);--_list-item-overline-type: var(--md-list-list-item-overline-type, 500 0.688rem / 1rem Roboto);--_list-item-overline-weight: var(--md-list-list-item-overline-weight, 500);--_list-item-pressed-label-text-color: var(--md-list-list-item-pressed-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-pressed-leading-icon-icon-color: var(--md-list-list-item-pressed-leading-icon-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-pressed-state-layer-color: var(--md-list-list-item-pressed-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-pressed-state-layer-opacity: var(--md-list-list-item-pressed-state-layer-opacity, 0.12);--_list-item-pressed-trailing-icon-icon-color: var(--md-list-list-item-pressed-trailing-icon-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-selected-trailing-icon-color: var(--md-list-list-item-selected-trailing-icon-color, var(--md-sys-color-primary, #6750a4));--_list-item-small-leading-video-height: var(--md-list-list-item-small-leading-video-height, 56px);--_list-item-supporting-text-color: var(--md-list-list-item-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-supporting-text-font: var(--md-list-list-item-supporting-text-font, Roboto);--_list-item-supporting-text-line-height: var(--md-list-list-item-supporting-text-line-height, 1.25rem);--_list-item-supporting-text-size: var(--md-list-list-item-supporting-text-size, 0.875rem);--_list-item-supporting-text-tracking: var(--md-list-list-item-supporting-text-tracking, 0.016rem);--_list-item-supporting-text-type: var(--md-list-list-item-supporting-text-type, 400 0.875rem / 1.25rem Roboto);--_list-item-supporting-text-weight: var(--md-list-list-item-supporting-text-weight, 400);--_list-item-three-line-container-height: var(--md-list-list-item-three-line-container-height, 88px);--_list-item-trailing-icon-color: var(--md-list-list-item-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-trailing-icon-size: var(--md-list-list-item-trailing-icon-size, 24px);--_list-item-trailing-supporting-text-color: var(--md-list-list-item-trailing-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-trailing-supporting-text-font: var(--md-list-list-item-trailing-supporting-text-font, Roboto);--_list-item-trailing-supporting-text-line-height: var(--md-list-list-item-trailing-supporting-text-line-height, 1rem);--_list-item-trailing-supporting-text-size: var(--md-list-list-item-trailing-supporting-text-size, 0.688rem);--_list-item-trailing-supporting-text-tracking: var(--md-list-list-item-trailing-supporting-text-tracking, 0.031rem);--_list-item-trailing-supporting-text-type: var(--md-list-list-item-trailing-supporting-text-type, 500 0.688rem / 1rem Roboto);--_list-item-trailing-supporting-text-weight: var(--md-list-list-item-trailing-supporting-text-weight, 500);--_list-item-two-line-container-height: var(--md-list-list-item-two-line-container-height, 72px);--_list-item-unselected-trailing-icon-color: var(--md-list-list-item-unselected-trailing-icon-color, var(--md-sys-color-on-surface, #1c1b1f))}/*# sourceMappingURL=list-item-private-styles.css.map */ `; //# sourceMappingURL=list-item-private-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitem/list-item-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitem/list-item-styles.css.js index 16f3644..da1faf2 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitem/list-item-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitem/list-item-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{color:unset;--md-list-item-image-list-item-leading-image-height:var(--_list-item-leading-image-height);--md-list-item-image-list-item-leading-image-width:var(--_list-item-leading-image-width);--md-list-item-image-list-item-leading-image-shape:var(--_list-item-leading-image-shape);--md-list-item-video-list-item-small-leading-video-height:var(--_list-item-small-leading-video-height);--md-list-item-video-list-item-large-leading-video-height:var(--_list-item-large-leading-video-height);--md-list-item-video-list-item-leading-video-width:var(--_list-item-leading-video-width);--md-list-item-video-list-item-leading-video-shape:var(--_list-item-leading-video-shape);--md-focus-ring-shape-start-start:4px;--md-focus-ring-shape-start-end:4px;--md-focus-ring-shape-end-end:4px;--md-focus-ring-shape-end-start:4px;--md-focus-ring-offset-vertical:-2px;--md-focus-ring-offset-horizontal:-3px;--md-ripple-hover-state-layer-color:var(--_list-item-hover-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_list-item-hover-state-layer-opacity);--md-ripple-pressed-state-layer-color:var(--_list-item-pressed-state-layer-color);--md-ripple-pressed-state-layer-opacity:var(--_list-item-pressed-state-layer-opacity);--md-ripple-focus-state-layer-color:var(--_list-item-focus-state-layer-color);--md-ripple-focus-state-layer-opacity:var(--_list-item-focus-state-layer-opacity)}.list-item{align-items:center;box-sizing:border-box;display:flex;outline:none;position:relative;width:100%;text-decoration:none;background-color:var(--_list-item-container-color);border-radius:var(--_list-item-container-shape)}.list-item.enabled{cursor:pointer}.list-item.disabled{pointer-events:none}.with-one-line{min-height:var(--_list-item-one-line-container-height)}.with-two-line{min-height:var(--_list-item-two-line-container-height)}.with-three-line{min-height:var(--_list-item-three-line-container-height)}.start{flex:0 0 auto;z-index:1;--md-list-item-icon-list-item-icon-color:var(--_list-item-leading-icon-color);--md-list-item-icon-list-item-icon-size:var(--_list-item-leading-icon-size)}:hover .start{--md-list-item-icon-list-item-icon-color:var(--_list-item-hover-leading-icon-icon-color)}:active .start{--md-list-item-icon-list-item-icon-color:var(--_list-item-pressed-leading-icon-icon-color)}.disabled .start{--md-list-item-icon-list-item-icon-color:var(--_list-item-disabled-leading-icon-color);--md-list-item-icon-list-item-icon-opacity:var(--_list-item-disabled-leading-icon-opacity)}.with-leading-thumbnail .start,.with-leading-image .start{padding-inline-start:16px}.with-leading-video .start{padding-inline-start:0}.body{box-sizing:border-box;flex:1 0 0;padding-inline-start:16px;width:100%;z-index:1}.end{flex:0 0 auto;padding-inline-end:24px;z-index:1;--md-list-item-icon-list-item-icon-color:var(--_list-item-trailing-icon-color);--md-list-item-icon-list-item-icon-size:var(--_list-item-trailing-icon-size)}:hover .end{--md-list-item-icon-list-item-icon-color:var(--_list-item-hover-trailing-icon-icon-color)}:active .end{--md-list-item-icon-list-item-icon-color:var(--_list-item-pressed-trailing-icon-icon-color)}.disabled .end{--md-list-item-icon-list-item-icon-color:var(--_list-item-disabled-trailing-icon-color);--md-list-item-icon-list-item-icon-opacity:var(--_list-item-disabled-trailing-icon-opacity)}.label-text{display:flex;color:var(--_list-item-label-text-color);font-family:var(--_list-item-label-text-font);font-size:var(--_list-item-label-text-size);letter-spacing:var(--_list-item-label-text-tracking);font-weight:var(--_list-item-label-text-weight);line-height:var(--_list-item-label-text-line-height)}.disabled .label-text{color:var(--_list-item-disabled-label-text-color);opacity:var(--_list-item-disabled-label-text-opacity)}.supporting-text{display:block;padding-block-start:4px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;width:100%;color:var(--_list-item-supporting-text-color);font-family:var(--_list-item-supporting-text-font);font-size:var(--_list-item-supporting-text-size);letter-spacing:var(--_list-item-supporting-text-tracking);font-weight:var(--_list-item-supporting-text-weight);line-height:var(--_list-item-supporting-text-line-height)}.disabled .supporting-text{color:var(--_list-item-disabled-label-text-color);opacity:var(--_list-item-disabled-label-text-opacity)}.supporting-text--multi-line{-webkit-box-orient:vertical;-webkit-line-clamp:2;display:-webkit-box;overflow:hidden;white-space:normal}.trailing-supporting-text{padding-inline-start:16px;font-family:var(--_list-item-trailing-supporting-text-font);font-size:var(--_list-item-trailing-supporting-text-size);letter-spacing:var(--_list-item-trailing-supporting-text-tracking);font-weight:var(--_list-item-trailing-supporting-text-weight);line-height:var(--_list-item-trailing-supporting-text-line-height)}.list-item:not(.disabled) .trailing-supporting-text{color:var(--_list-item-trailing-supporting-text-color)}.disabled .trailing-supporting-text{color:var(--_list-item-disabled-label-text-color);opacity:var(--_list-item-disabled-label-text-opacity)}.ripple{display:inline-flex;inset:0;position:absolute;z-index:0}.focus-ring{z-index:1}/*# sourceMappingURL=list-item-styles.css.map */ `; //# sourceMappingURL=list-item-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitem/list-item.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitem/list-item.js index 9a42985..4a8c1a1 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitem/list-item.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitem/list-item.js
@@ -3,14 +3,14 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; // Required for @ariaProperty // tslint:disable:no-new-decorators import '../../../ripple/ripple.js'; import '../../../focus/focus-ring.js'; -import { html, LitElement, nothing } from '../../../../../lit/index.js'; -import { property, query, queryAsync, state } from '../../../../../lit/decorators.js'; -import { classMap } from '../../../../../lit/directives/class-map.js'; +import { html, LitElement, nothing } from 'lit'; +import { property, query, queryAsync, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; import { ariaProperty } from '../../../decorators/aria-property.js'; import { pointerPress, shouldShowStrongFocus } from '../../../focus/strong-focus.js'; import { ripple } from '../../../ripple/directive.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitemlink/list-item-link.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitemlink/list-item-link.js index e4f04d1..2d2c59be 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitemlink/list-item-link.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/listitemlink/list-item-link.js
@@ -3,10 +3,10 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; -import { html, nothing } from '../../../../../lit/index.js'; -import { property } from '../../../../../lit/decorators.js'; -import { classMap } from '../../../../../lit/directives/class-map.js'; +import { __decorate, __metadata } from "tslib"; +import { html, nothing } from 'lit'; +import { property } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; import { ripple } from '../../../ripple/directive.js'; import { ListItemEl } from '../listitem/list-item.js'; // tslint:disable-next-line:enforce-comments-on-exported-symbols
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/video/list-item-video-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/video/list-item-video-styles.css.js index 59691e0..c0623e5 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/video/list-item-video-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/video/list-item-video-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_list-item-small-leading-video-height: var(--md-list-item-video-list-item-small-leading-video-height, 56px);--_list-item-large-leading-video-height: var(--md-list-item-video-list-item-large-leading-video-height, 69px);--_list-item-leading-video-width: var(--md-list-item-video-list-item-leading-video-width, 100px);--_list-item-leading-video-shape: var(--md-list-item-video-list-item-leading-video-shape, 0px);display:inline-flex}.md3-list-item__video{display:inline-flex;margin-block-end:12px;margin-block-start:12px;object-fit:cover;height:var(--_list-item-small-leading-video-height);width:var(--_list-item-leading-video-width);border-radius:var(--_list-item-leading-video-shape)}.md3-list-item__video.large{height:var(--_list-item-large-leading-video-height)}/*# sourceMappingURL=list-item-video-styles.css.map */ `; //# sourceMappingURL=list-item-video-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/video/list-item-video.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/video/list-item-video.js index 7a11e4dc..d6f0c93 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/video/list-item-video.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/lib/video/list-item-video.js
@@ -3,9 +3,9 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; -import { html, LitElement, nothing } from '../../../../../lit/index.js'; -import { property } from '../../../../../lit/decorators.js'; +import { __decorate, __metadata } from "tslib"; +import { html, LitElement, nothing } from 'lit'; +import { property } from 'lit/decorators.js'; /** * @fires loadeddata {Event} Dispatched whenever the native HTMLVideoElement * fires the loadeddate event.
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-avatar.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-avatar.js index 8e529ee..f3b2baca 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-avatar.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-avatar.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { ListItemAvatar } from './lib/avatar/list-item-avatar.js'; import { styles } from './lib/avatar/list-item-avatar-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-icon.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-icon.js index ee687b8..2ee5975c 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-icon.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-icon.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { ListItemIcon } from './lib/icon/list-item-icon.js'; import { styles } from './lib/icon/list-item-icon-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-image.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-image.js index 8528c19..1f1ec19 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-image.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-image.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { ListItemImage } from './lib/image/list-item-image.js'; import { styles } from './lib/image/list-item-image-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-link.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-link.js index 1ae1ff8..db03224 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-link.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-link.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles as privateProps } from './lib/listitem/list-item-private-styles.css.js'; import { styles } from './lib/listitem/list-item-styles.css.js'; import { ListItemLink } from './lib/listitemlink/list-item-link.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-video.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-video.js index bf9b33b1..a7fb5b9 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-video.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item-video.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { ListItemVideo } from './lib/video/list-item-video.js'; import { styles } from './lib/video/list-item-video-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item.js index d466b6e..ab3922c 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list-item.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { ListItemEl as ListItem } from './lib/listitem/list-item.js'; import { styles as privateProps } from './lib/listitem/list-item-private-styles.css.js'; import { styles } from './lib/listitem/list-item-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list.js index 190fee5b..c4ecb9a 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/list/list.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { List } from './lib/list.js'; import { styles } from './lib/list-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menu-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menu-styles.css.js index 6a9c2929..012dd7d 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menu-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menu-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_cascading-menu-indicator-icon-color: var(--md-menu-cascading-menu-indicator-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_cascading-menu-indicator-icon-size: var(--md-menu-cascading-menu-indicator-icon-size, 24px);--_container-color: var(--md-menu-container-color, var(--md-sys-color-surface, #fffbfe));--_container-elevation: var(--md-menu-container-elevation, 3);--_container-shadow-color: var(--md-menu-container-shadow-color, var(--md-sys-color-shadow, #000));--_container-shape: var(--md-menu-container-shape, 4px);--_container-surface-tint-layer-color: var(--md-menu-container-surface-tint-layer-color, var(--md-sys-color-primary, #6750a4));--_list-item-container-height: var(--md-menu-list-item-container-height, 48px);--_list-item-disabled-label-text-color: var(--md-menu-list-item-disabled-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-disabled-label-text-opacity: var(--md-menu-list-item-disabled-label-text-opacity, 0.38);--_list-item-focus-label-text-color: var(--md-menu-list-item-focus-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-focus-state-layer-color: var(--md-menu-list-item-focus-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-focus-state-layer-opacity: var(--md-menu-list-item-focus-state-layer-opacity, 0.12);--_list-item-hover-label-text-color: var(--md-menu-list-item-hover-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-hover-state-layer-color: var(--md-menu-list-item-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-hover-state-layer-opacity: var(--md-menu-list-item-hover-state-layer-opacity, 0.08);--_list-item-label-text-color: var(--md-menu-list-item-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-label-text-font: var(--md-menu-list-item-label-text-font, Roboto);--_list-item-label-text-line-height: var(--md-menu-list-item-label-text-line-height, 1.25rem);--_list-item-label-text-size: var(--md-menu-list-item-label-text-size, 0.875rem);--_list-item-label-text-tracking: var(--md-menu-list-item-label-text-tracking, 0.006rem);--_list-item-label-text-type: var(--md-menu-list-item-label-text-type, 500 0.875rem / 1.25rem Roboto);--_list-item-label-text-weight: var(--md-menu-list-item-label-text-weight, 500);--_list-item-pressed-label-text-color: var(--md-menu-list-item-pressed-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-pressed-state-layer-color: var(--md-menu-list-item-pressed-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-pressed-state-layer-opacity: var(--md-menu-list-item-pressed-state-layer-opacity, 0.12);--_list-item-selected-container-color: var(--md-menu-list-item-selected-container-color, var(--md-sys-color-surface-variant, #e7e0ec));--_list-item-with-leading-icon-disabled-leading-icon-color: var(--md-menu-list-item-with-leading-icon-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-with-leading-icon-disabled-leading-icon-opacity: var(--md-menu-list-item-with-leading-icon-disabled-leading-icon-opacity, 0.38);--_list-item-with-leading-icon-focus-icon-color: var(--md-menu-list-item-with-leading-icon-focus-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-with-leading-icon-hover-icon-color: var(--md-menu-list-item-with-leading-icon-hover-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-with-leading-icon-leading-icon-color: var(--md-menu-list-item-with-leading-icon-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-with-leading-icon-leading-icon-size: var(--md-menu-list-item-with-leading-icon-leading-icon-size, 24px);--_list-item-with-leading-icon-pressed-icon-color: var(--md-menu-list-item-with-leading-icon-pressed-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-with-trailing-icon-disabled-trailing-icon-color: var(--md-menu-list-item-with-trailing-icon-disabled-trailing-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-with-trailing-icon-disabled-trailing-icon-opacity: var(--md-menu-list-item-with-trailing-icon-disabled-trailing-icon-opacity, 0.38);--_list-item-with-trailing-icon-focus-icon-color: var(--md-menu-list-item-with-trailing-icon-focus-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-with-trailing-icon-hover-icon-color: var(--md-menu-list-item-with-trailing-icon-hover-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-with-trailing-icon-pressed-icon-color: var(--md-menu-list-item-with-trailing-icon-pressed-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-with-trailing-icon-trailing-icon-color: var(--md-menu-list-item-with-trailing-icon-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-with-trailing-icon-trailing-icon-size: var(--md-menu-list-item-with-trailing-icon-trailing-icon-size, 24px);--md-elevation-level:var(--_container-elevation);--md-elevation-shadow-color:var(--_container-shadow-color);--md-elevation-surface-tint:var(--_container-surface-tint-layer-color);--md-focus-ring-shape-start-start:var(--_container-shape);--md-focus-ring-shape-start-end:var(--_container-shape);--md-focus-ring-shape-end-end:var(--_container-shape);--md-focus-ring-shape-end-start:var(--_container-shape)}.menu{border-radius:var(--_container-shape);display:none;opacity:0;z-index:20;position:absolute;user-select:none;max-height:inherit;height:inherit}.menu.fixed{position:fixed}.menu md-list{height:inherit;max-height:inherit;display:block;overflow:auto}.menu.has-overflow md-list{overflow:visible}.menu.animating md-list{pointer-events:none;overflow:hidden}.menu.animating ::slotted(.hidden){opacity:0}.menu slot{display:block;height:inherit;max-height:inherit}md-elevation{position:absolute;inset:0;pointer-events:none}/*# sourceMappingURL=menu-styles.css.map */ `; //# sourceMappingURL=menu-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menu.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menu.js index ccfd902..998651c 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menu.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menu.js
@@ -3,16 +3,16 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; // Required for @ariaProperty // tslint:disable:no-new-decorators import '../../list/list.js'; import '../../focus/focus-ring.js'; import '../../elevation/elevation.js'; -import { html, LitElement } from '../../../../lit/index.js'; -import { property, query } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { styleMap } from '../../../../lit/directives/style-map.js'; +import { html, LitElement } from 'lit'; +import { property, query } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { styleMap } from 'lit/directives/style-map.js'; import { ariaProperty } from '../../decorators/aria-property.js'; import { MdFocusRing } from '../../focus/focus-ring.js'; import { pointerPress, shouldShowStrongFocus } from '../../focus/strong-focus.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitem/menu-item-private-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitem/menu-item-private-styles.css.js index 66434ae..e7a67220 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitem/menu-item-private-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitem/menu-item-private-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_list-item-container-height: var(--md-menu-list-item-container-height, 48px);--_list-item-disabled-label-text-color: var(--md-menu-list-item-disabled-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-disabled-label-text-opacity: var(--md-menu-list-item-disabled-label-text-opacity, 0.38);--_list-item-focus-label-text-color: var(--md-menu-list-item-focus-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-focus-state-layer-color: var(--md-menu-list-item-focus-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-focus-state-layer-opacity: var(--md-menu-list-item-focus-state-layer-opacity, 0.12);--_list-item-hover-label-text-color: var(--md-menu-list-item-hover-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-hover-state-layer-color: var(--md-menu-list-item-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-hover-state-layer-opacity: var(--md-menu-list-item-hover-state-layer-opacity, 0.08);--_list-item-label-text-color: var(--md-menu-list-item-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-label-text-font: var(--md-menu-list-item-label-text-font, Roboto);--_list-item-label-text-line-height: var(--md-menu-list-item-label-text-line-height, 1.25rem);--_list-item-label-text-size: var(--md-menu-list-item-label-text-size, 0.875rem);--_list-item-label-text-tracking: var(--md-menu-list-item-label-text-tracking, 0.006rem);--_list-item-label-text-type: var(--md-menu-list-item-label-text-type, 500 0.875rem / 1.25rem Roboto);--_list-item-label-text-weight: var(--md-menu-list-item-label-text-weight, 500);--_list-item-pressed-label-text-color: var(--md-menu-list-item-pressed-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-pressed-state-layer-color: var(--md-menu-list-item-pressed-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-pressed-state-layer-opacity: var(--md-menu-list-item-pressed-state-layer-opacity, 0.12);--_list-item-selected-container-color: var(--md-menu-list-item-selected-container-color, var(--md-sys-color-surface-variant, #e7e0ec));--_list-item-disabled-leading-icon-color: var(--md-menu-list-item-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-disabled-leading-icon-opacity: var(--md-menu-list-item-disabled-leading-icon-opacity, 0.38);--_list-item-focus-leading-icon-icon-color: var(--md-menu-list-item-focus-leading-icon-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-hover-leading-icon-icon-color: var(--md-menu-list-item-hover-leading-icon-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-leading-icon-color: var(--md-menu-list-item-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-leading-icon-size: var(--md-menu-list-item-leading-icon-size, 24px);--_list-item-pressed-leading-icon-icon-color: var(--md-menu-list-item-pressed-leading-icon-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-disabled-trailing-icon-color: var(--md-menu-list-item-disabled-trailing-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_list-item-disabled-trailing-icon-opacity: var(--md-menu-list-item-disabled-trailing-icon-opacity, 0.38);--_list-item-focus-trailing-icon-icon-color: var(--md-menu-list-item-focus-trailing-icon-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-hover-trailing-icon-icon-color: var(--md-menu-list-item-hover-trailing-icon-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-pressed-trailing-icon-icon-color: var(--md-menu-list-item-pressed-trailing-icon-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-trailing-icon-color: var(--md-menu-list-item-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_list-item-trailing-icon-size: var(--md-menu-list-item-trailing-icon-size, 24px);--_list-item-one-line-container-height: var(--md-menu-list-item-one-line-container-height, 48px)}/*# sourceMappingURL=menu-item-private-styles.css.map */ `; //# sourceMappingURL=menu-item-private-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitem/menu-item-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitem/menu-item-styles.css.js index ce900b7..d416ab5 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitem/menu-item-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitem/menu-item-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host([active]) .list-item{background-color:var(--_list-item-selected-container-color)}.list-item:has(.submenu:hover){--md-ripple-hover-state-layer-opacity:0}/*# sourceMappingURL=menu-item-styles.css.map */ `; //# sourceMappingURL=menu-item-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitem/menu-item.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitem/menu-item.js index 137f0ff5..b568a99 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitem/menu-item.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitem/menu-item.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; -import { property } from '../../../../../lit/decorators.js'; +import { __decorate, __metadata } from "tslib"; +import { property } from 'lit/decorators.js'; import { ListItemEl } from '../../../list/lib/listitem/list-item.js'; import { CLOSE_REASON, DefaultCloseMenuEvent, isClosableKey } from '../shared.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitemlink/menu-item-link.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitemlink/menu-item-link.js index 378eb54..696c0e7 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitemlink/menu-item-link.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/menuitemlink/menu-item-link.js
@@ -3,8 +3,8 @@ * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; -import { property } from '../../../../../lit/decorators.js'; +import { __decorate, __metadata } from "tslib"; +import { property } from 'lit/decorators.js'; import { ListItemLink } from '../../../list/lib/listitemlink/list-item-link.js'; import { CLOSE_REASON, DefaultCloseMenuEvent, isClosableKey, SELECTION_KEY } from '../shared.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/submenuitem/sub-menu-item.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/submenuitem/sub-menu-item.js index 8d32f76..daa0104 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/submenuitem/sub-menu-item.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/lib/submenuitem/sub-menu-item.js
@@ -3,9 +3,9 @@ * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../../tslib/tslib.js'; -import { html } from '../../../../../lit/index.js'; -import { property, queryAssignedElements } from '../../../../../lit/decorators.js'; +import { __decorate, __metadata } from "tslib"; +import { html } from 'lit'; +import { property, queryAssignedElements } from 'lit/decorators.js'; import { List } from '../../../list/lib/list.js'; import { MenuItemEl } from '../menuitem/menu-item.js'; import { CLOSE_REASON, DeactivateItemsEvent, KEYDOWN_CLOSE_KEYS, NAVIGABLE_KEY, SELECTION_KEY } from '../shared.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/menu-item-link.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/menu-item-link.js index 14ec5a07..d4c7f254 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/menu-item-link.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/menu-item-link.js
@@ -3,8 +3,8 @@ * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles as listItemStyles } from '../list/lib/listitem/list-item-styles.css.js'; import { styles as privateProps } from './lib/menuitem/menu-item-private-styles.css.js'; import { styles } from './lib/menuitem/menu-item-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/menu-item.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/menu-item.js index d453473f..2339b278 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/menu-item.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/menu-item.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles as listItemStyles } from '../list/lib/listitem/list-item-styles.css.js'; import { MenuItemEl } from './lib/menuitem/menu-item.js'; import { styles as privateProps } from './lib/menuitem/menu-item-private-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/menu.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/menu.js index fca2ed4b..974fb73 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/menu.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/menu.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { Menu } from './lib/menu.js'; import { styles } from './lib/menu-styles.css.js'; export { CloseMenuEvent, DeactivateItemsEvent } from './lib/shared.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/sub-menu-item.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/sub-menu-item.js index 3d7668fa..ce0fcd78 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/sub-menu-item.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/menu/sub-menu-item.js
@@ -3,8 +3,8 @@ * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles as listItemStyles } from '../list/lib/listitem/list-item-styles.css.js'; import { styles as privateProps } from './lib/menuitem/menu-item-private-styles.css.js'; import { styles } from './lib/menuitem/menu-item-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/menusurface/lib/menu-surface-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/menusurface/lib/menu-surface-styles.css.js index 2d5de5e0..3c2492c 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/menusurface/lib/menu-surface-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/menusurface/lib/menu-surface-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-elevation: var(--md-menu-surface-container-elevation, 2);--_container-shadow-color: var(--md-menu-surface-container-shadow-color, var(--md-sys-color-shadow, #000));--_container-shape: var(--md-menu-surface-container-shape, 4px);--_container-surface-tint-layer-color: var(--md-menu-surface-container-surface-tint-layer-color, var(--md-sys-color-primary, #6750a4))}.md3-menu-surface{border-radius:var(--_container-shape);box-sizing:border-box;display:none;opacity:0;overflow:auto;margin:0;max-height:calc(100vh - 32px);max-width:calc(100vw - 32px);padding:0;position:absolute;transform:scale(1);transform-origin:top left;transition:opacity .03s linear,transform .12s cubic-bezier(0, 0, 0.2, 1),height 250ms cubic-bezier(0, 0, 0.2, 1);will-change:transform,opacity;z-index:8;--md-elevation-level:var(--_container-elevation);--md-elevation-shadow-color:var(--_container-shadow-color);--md-elevation-surface-tint:var(--_container-surface-tint-layer-color)}.md3-menu-surface md-elevation{z-index:0}.md3-menu-surface:focus{outline:none}.md3-menu-surface--animating-open{display:inline-block;opacity:0;transform:scale(0.8)}.md3-menu-surface--open{display:inline-block;opacity:1;transform:scale(1)}.md3-menu-surface--animating-closed{display:inline-block;opacity:0;transition:opacity .075s linear}.md3-menu-surface--anchor{overflow:visible;position:relative}.md3-menu-surface--fixed{position:fixed}.md3-menu-surface--fullwidth{width:100%}.md3-menu-surface--is-open-below{border-top-left-radius:0px;border-top-right-radius:0px}/*# sourceMappingURL=menu-surface-styles.css.map */ `; //# sourceMappingURL=menu-surface-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/menusurface/lib/menu-surface.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/menusurface/lib/menu-surface.js index 95b6290..37c2bf4 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/menusurface/lib/menu-surface.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/menusurface/lib/menu-surface.js
@@ -3,14 +3,14 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; // Style preference for leading underscores. // tslint:disable:strip-private-property-underscore import '../../elevation/elevation.js'; -import { html, LitElement } from '../../../../lit/index.js'; -import { property, query, state } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { styleMap } from '../../../../lit/directives/style-map.js'; +import { html, LitElement } from 'lit'; +import { property, query, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { styleMap } from 'lit/directives/style-map.js'; import { isRtl } from '../../controller/is-rtl.js'; import { Corner as CornerEnum } from './constants.js'; import { MDCMenuSurfaceFoundation } from './foundation.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/menusurface/menu-surface.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/menusurface/menu-surface.js index f8fc51f..5b3c3ce 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/menusurface/menu-surface.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/menusurface/menu-surface.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { MenuSurface } from './lib/menu-surface.js'; import { styles } from './lib/menu-surface-styles.css.js'; let MdMenuSurface = class MdMenuSurface extends MenuSurface {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationbar/lib/navigation-bar-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationbar/lib/navigation-bar-styles.css.js index faf7b576..afe5268 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationbar/lib/navigation-bar-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationbar/lib/navigation-bar-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_active-indicator-color: var(--md-navigation-bar-active-indicator-color, var(--md-sys-color-secondary-container, #e8def8));--_active-indicator-height: var(--md-navigation-bar-active-indicator-height, 32px);--_active-indicator-shape: var(--md-navigation-bar-active-indicator-shape, 9999px);--_active-indicator-width: var(--md-navigation-bar-active-indicator-width, 64px);--_active-focus-icon-color: var(--md-navigation-bar-active-focus-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-focus-label-text-color: var(--md-navigation-bar-active-focus-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_active-focus-state-layer-color: var(--md-navigation-bar-active-focus-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_active-hover-icon-color: var(--md-navigation-bar-active-hover-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-hover-label-text-color: var(--md-navigation-bar-active-hover-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_active-hover-state-layer-color: var(--md-navigation-bar-active-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_active-icon-color: var(--md-navigation-bar-active-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-label-text-color: var(--md-navigation-bar-active-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_active-label-text-weight: var(--md-navigation-bar-active-label-text-weight, 700);--_active-pressed-icon-color: var(--md-navigation-bar-active-pressed-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-pressed-label-text-color: var(--md-navigation-bar-active-pressed-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_active-pressed-state-layer-color: var(--md-navigation-bar-active-pressed-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_container-color: var(--md-navigation-bar-container-color, var(--md-sys-color-surface, #fffbfe));--_container-elevation: var(--md-navigation-bar-container-elevation, 2);--_container-height: var(--md-navigation-bar-container-height, 80px);--_container-shape: var(--md-navigation-bar-container-shape, 0px);--_container-surface-tint-layer-color: var(--md-navigation-bar-container-surface-tint-layer-color, var(--md-sys-color-primary, #6750a4));--_focus-state-layer-opacity: var(--md-navigation-bar-focus-state-layer-opacity, 0.12);--_hover-state-layer-opacity: var(--md-navigation-bar-hover-state-layer-opacity, 0.08);--_icon-size: var(--md-navigation-bar-icon-size, 24px);--_inactive-focus-icon-color: var(--md-navigation-bar-inactive-focus-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-focus-label-text-color: var(--md-navigation-bar-inactive-focus-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-focus-state-layer-color: var(--md-navigation-bar-inactive-focus-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-hover-icon-color: var(--md-navigation-bar-inactive-hover-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-hover-label-text-color: var(--md-navigation-bar-inactive-hover-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-hover-state-layer-color: var(--md-navigation-bar-inactive-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-icon-color: var(--md-navigation-bar-inactive-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_inactive-label-text-color: var(--md-navigation-bar-inactive-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_inactive-pressed-icon-color: var(--md-navigation-bar-inactive-pressed-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-pressed-label-text-color: var(--md-navigation-bar-inactive-pressed-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-pressed-state-layer-color: var(--md-navigation-bar-inactive-pressed-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_label-text-font: var(--md-navigation-bar-label-text-font, Roboto);--_label-text-line-height: var(--md-navigation-bar-label-text-line-height, 1rem);--_label-text-size: var(--md-navigation-bar-label-text-size, 0.75rem);--_label-text-tracking: var(--md-navigation-bar-label-text-tracking, 0.031rem);--_label-text-type: var(--md-navigation-bar-label-text-type, 500 0.75rem / 1rem Roboto);--_label-text-weight: var(--md-navigation-bar-label-text-weight, 500);--_pressed-state-layer-opacity: var(--md-navigation-bar-pressed-state-layer-opacity, 0.12);--md-elevation-duration:280ms;--md-elevation-level:var(--_container-elevation);--md-elevation-shadow-color:var(--_container-shadow-color);--md-elevation-surface-tint:var(--_container-surface-tint-layer-color);width:100%}.md3-navigation-bar{display:flex;position:relative;width:100%;background-color:var(--_container-color);border-radius:var(--_container-shape);height:var(--_container-height)}.md3-navigation-bar .md3-navigation-bar__tabs-slot-container{display:inherit;width:inherit}md-elevation{inset:0;position:absolute;z-index:0}/*# sourceMappingURL=navigation-bar-styles.css.map */ `; //# sourceMappingURL=navigation-bar-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationbar/lib/navigation-bar.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationbar/lib/navigation-bar.js index 2a97597..09fbfd05 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationbar/lib/navigation-bar.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationbar/lib/navigation-bar.js
@@ -3,11 +3,11 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; import '../../elevation/elevation.js'; -import { html, LitElement } from '../../../../lit/index.js'; -import { property, queryAssignedElements } from '../../../../lit/decorators.js'; -import { ifDefined } from '../../../../lit/directives/if-defined.js'; +import { html, LitElement } from 'lit'; +import { property, queryAssignedElements } from 'lit/decorators.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { isRtl } from '../../controller/is-rtl.js'; import { ariaProperty } from '../../decorators/aria-property.js'; /** @soyCompatible */
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationbar/navigation-bar.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationbar/navigation-bar.js index fb3fab3..91c8ae44 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationbar/navigation-bar.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationbar/navigation-bar.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { NavigationBar } from './lib/navigation-bar.js'; import { styles } from './lib/navigation-bar-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer-modal-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer-modal-styles.css.js index d01aee0..06e28c1 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer-modal-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer-modal-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-shape-start-start: var(--md-navigation-drawer-modal-container-shape-start-start, 0);--_container-shape-start-end: var(--md-navigation-drawer-modal-container-shape-start-end, 16px);--_container-shape-end-end: var(--md-navigation-drawer-modal-container-shape-end-end, 16px);--_container-shape-end-start: var(--md-navigation-drawer-modal-container-shape-end-start, 0);--_container-color: var(--md-navigation-drawer-modal-container-color, #fff);--_container-height: var(--md-navigation-drawer-modal-container-height, 100%);--_container-surface-tint-layer-color: ;--_container-width: var(--md-navigation-drawer-modal-container-width, 360px);--_divider-color: var(--md-navigation-drawer-modal-divider-color, #000);--_modal-container-elevation: var(--md-navigation-drawer-modal-modal-container-elevation, 1);--_scrim-color: ;--_scrim-opacity: var(--md-navigation-drawer-modal-scrim-opacity, 0.04);--_standard-container-elevation: var(--md-navigation-drawer-modal-standard-container-elevation, 0);--md-elevation-level:var(--_modal-container-elevation)}.md3-navigation-drawer-modal{bottom:0;box-sizing:border-box;display:flex;justify-content:flex-end;overflow:hidden;position:absolute;top:0;inline-size:0;transition:inline-size .25s cubic-bezier(0.4, 0, 0.2, 1) 0s,visibility 0s cubic-bezier(0.4, 0, 0.2, 1) .25s}.md3-navigation-drawer-modal--opened{transition:inline-size .25s cubic-bezier(0.4, 0, 0.2, 1) 0s,visibility 0s cubic-bezier(0.4, 0, 0.2, 1) 0s}.md3-navigation-drawer-modal--pivot-at-start{justify-content:flex-start}.md3-navigation-drawer-modal__slot-content{display:flex;flex-direction:column;position:relative}.md3-navigation-drawer-modal__scrim{inset:0;opacity:0;position:absolute;visibility:hidden;background-color:var(--_scrim-color);transition:opacity .25s cubic-bezier(0.4, 0, 0.2, 1) 0s,visibility 0s cubic-bezier(0.4, 0, 0.2, 1) .25s}.md3-navigation-drawer-modal--scrim-visible{visibility:visible;opacity:var(--_scrim-opacity);transition:opacity .25s cubic-bezier(0.4, 0, 0.2, 1) 0s,visibility 0s cubic-bezier(0.4, 0, 0.2, 1) 0s}/*# sourceMappingURL=navigation-drawer-modal-styles.css.map */ `; //# sourceMappingURL=navigation-drawer-modal-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer-modal.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer-modal.js index 63e2259..b58ad03d 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer-modal.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer-modal.js
@@ -3,11 +3,11 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; -import { html, LitElement } from '../../../../lit/index.js'; -import { property } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../lit/directives/if-defined.js'; +import { __decorate, __metadata } from "tslib"; +import { html, LitElement } from 'lit'; +import { property } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { ariaProperty } from '../../decorators/aria-property.js'; /** @soyCompatible */ export class NavigationDrawerModal extends LitElement {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer-styles.css.js index 782b6688..23fdc829 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-shape-start-start: var(--md-navigation-drawer-container-shape-start-start, 0);--_container-shape-start-end: var(--md-navigation-drawer-container-shape-start-end, 16px);--_container-shape-end-end: var(--md-navigation-drawer-container-shape-end-end, 16px);--_container-shape-end-start: var(--md-navigation-drawer-container-shape-end-start, 0);--_container-color: var(--md-navigation-drawer-container-color, #fff);--_container-height: var(--md-navigation-drawer-container-height, 100%);--_container-surface-tint-layer-color: ;--_container-width: var(--md-navigation-drawer-container-width, 360px);--_divider-color: var(--md-navigation-drawer-divider-color, #000);--_modal-container-elevation: var(--md-navigation-drawer-modal-container-elevation, 1);--_standard-container-elevation: var(--md-navigation-drawer-standard-container-elevation, 0);--md-elevation-level:var(--_standard-container-elevation);--md-elevation-shadow-color:var(--_divider-color);--md-elevation-surface-tint:var(--_container-surface-tint-layer-color)}:host{display:flex}.md3-navigation-drawer{inline-size:0;box-sizing:border-box;display:flex;justify-content:flex-end;overflow:hidden;overflow-y:auto;visibility:hidden;transition:inline-size .25s cubic-bezier(0.4, 0, 0.2, 1) 0s,visibility 0s cubic-bezier(0.4, 0, 0.2, 1) .25s}md-elevation{inset:0;position:absolute;width:inherit;z-index:0}.md3-navigation-drawer--opened{visibility:visible;transition:inline-size .25s cubic-bezier(0.4, 0, 0.2, 1) 0s,visibility 0s cubic-bezier(0.4, 0, 0.2, 1) 0s}.md3-navigation-drawer--pivot-at-start{justify-content:flex-start}.md3-navigation-drawer__slot-content{display:flex;flex-direction:column;position:relative}/*# sourceMappingURL=navigation-drawer-styles.css.map */ `; //# sourceMappingURL=navigation-drawer-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer.js index 752a9da..8ef7e2c 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/navigation-drawer.js
@@ -3,12 +3,12 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; import '../../elevation/elevation.js'; -import { html, LitElement } from '../../../../lit/index.js'; -import { property } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../lit/directives/if-defined.js'; +import { html, LitElement } from 'lit'; +import { property } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { ariaProperty } from '../../decorators/aria-property.js'; /** @soyCompatible */ export class NavigationDrawer extends LitElement {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/shared-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/shared-styles.css.js index f9a2f25..bdbdf5d 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/shared-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/lib/shared-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `.md3-navigation-drawer-modal{background-color:var(--_container-color);border-start-start-radius:var(--_container-shape-start-start);border-start-end-radius:var(--_container-shape-start-end);border-end-end-radius:var(--_container-shape-end-end);border-end-start-radius:var(--_container-shape-end-start);height:var(--_container-height)}.md3-navigation-drawer-modal.md3-navigation-drawer-modal--opened{inline-size:var(--_container-width)}.md3-navigation-drawer-modal .md3-navigation-drawer-modal__slot-content{min-inline-size:var(--_container-width);max-inline-size:var(--_container-width)}/*# sourceMappingURL=shared-styles.css.map */ `; //# sourceMappingURL=shared-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/navigation-drawer-modal.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/navigation-drawer-modal.js index 18f05f1..5025308 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/navigation-drawer-modal.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/navigation-drawer-modal.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { NavigationDrawerModal } from './lib/navigation-drawer-modal.js'; import { styles } from './lib/navigation-drawer-modal-styles.css.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/navigation-drawer.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/navigation-drawer.js index f5fc218..b04f044 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/navigation-drawer.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationdrawer/navigation-drawer.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { NavigationDrawer } from './lib/navigation-drawer.js'; import { styles } from './lib/navigation-drawer-styles.css.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationtab/lib/navigation-tab-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationtab/lib/navigation-tab-styles.css.js index 5c2fb69f..b2716dd 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationtab/lib/navigation-tab-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationtab/lib/navigation-tab-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_active-indicator-color: var(--md-navigation-bar-active-indicator-color, var(--md-sys-color-secondary-container, #e8def8));--_active-indicator-height: var(--md-navigation-bar-active-indicator-height, 32px);--_active-indicator-shape: var(--md-navigation-bar-active-indicator-shape, 9999px);--_active-indicator-width: var(--md-navigation-bar-active-indicator-width, 64px);--_active-focus-icon-color: var(--md-navigation-bar-active-focus-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-focus-label-text-color: var(--md-navigation-bar-active-focus-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_active-focus-state-layer-color: var(--md-navigation-bar-active-focus-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_active-hover-icon-color: var(--md-navigation-bar-active-hover-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-hover-label-text-color: var(--md-navigation-bar-active-hover-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_active-hover-state-layer-color: var(--md-navigation-bar-active-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_active-icon-color: var(--md-navigation-bar-active-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-label-text-color: var(--md-navigation-bar-active-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_active-label-text-weight: var(--md-navigation-bar-active-label-text-weight, 700);--_active-pressed-icon-color: var(--md-navigation-bar-active-pressed-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-pressed-label-text-color: var(--md-navigation-bar-active-pressed-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_active-pressed-state-layer-color: var(--md-navigation-bar-active-pressed-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_container-color: var(--md-navigation-bar-container-color, var(--md-sys-color-surface, #fffbfe));--_container-elevation: var(--md-navigation-bar-container-elevation, 3);--_container-height: var(--md-navigation-bar-container-height, 80px);--_container-shape: var(--md-navigation-bar-container-shape, 0px);--_container-surface-tint-layer-color: var(--md-navigation-bar-container-surface-tint-layer-color, var(--md-sys-color-primary, #6750a4));--_focus-state-layer-opacity: var(--md-navigation-bar-focus-state-layer-opacity, 0.12);--_hover-state-layer-opacity: var(--md-navigation-bar-hover-state-layer-opacity, 0.08);--_icon-size: var(--md-navigation-bar-icon-size, 24px);--_inactive-focus-icon-color: var(--md-navigation-bar-inactive-focus-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-focus-label-text-color: var(--md-navigation-bar-inactive-focus-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-focus-state-layer-color: var(--md-navigation-bar-inactive-focus-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-hover-icon-color: var(--md-navigation-bar-inactive-hover-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-hover-label-text-color: var(--md-navigation-bar-inactive-hover-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-hover-state-layer-color: var(--md-navigation-bar-inactive-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-icon-color: var(--md-navigation-bar-inactive-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_inactive-label-text-color: var(--md-navigation-bar-inactive-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_inactive-pressed-icon-color: var(--md-navigation-bar-inactive-pressed-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-pressed-label-text-color: var(--md-navigation-bar-inactive-pressed-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_inactive-pressed-state-layer-color: var(--md-navigation-bar-inactive-pressed-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_label-text-font: var(--md-navigation-bar-label-text-font, Roboto);--_label-text-line-height: var(--md-navigation-bar-label-text-line-height, 1rem);--_label-text-size: var(--md-navigation-bar-label-text-size, 0.75rem);--_label-text-tracking: var(--md-navigation-bar-label-text-tracking, 0.031rem);--_label-text-type: var(--md-navigation-bar-label-text-type, 500 0.75rem / 1rem Roboto);--_label-text-weight: var(--md-navigation-bar-label-text-weight, 500);--_pressed-state-layer-opacity: var(--md-navigation-bar-pressed-state-layer-opacity, 0.12);--md-focus-ring-shape-start-start:8px;--md-focus-ring-shape-start-end:8px;--md-focus-ring-shape-end-end:8px;--md-focus-ring-shape-end-start:8px;--md-focus-ring-offset-vertical:-2px;--md-focus-ring-offset-horizontal:-2px;display:flex;flex-grow:1}.md3-navigation-tab{align-items:center;appearance:none;background:none;border:none;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;height:100%;justify-content:center;min-height:48px;min-width:48px;outline:none;padding:8px 0px 12px;position:relative;text-align:center;width:100%;font-family:var(--_label-text-font);font-size:var(--_label-text-size);letter-spacing:var(--_label-text-tracking);font-weight:var(--_label-text-weight);line-height:var(--_label-text-line-height)}.md3-navigation-tab::-moz-focus-inner{border:0;padding:0}.md3-navigation-tab__icon-content{align-items:center;box-sizing:border-box;display:flex;justify-content:center;position:relative;z-index:1}.md3-navigation-tab__label-text{height:16px;margin-top:4px;opacity:1;transition:opacity 100ms cubic-bezier(0.4, 0, 0.2, 1),height 100ms cubic-bezier(0.4, 0, 0.2, 1);z-index:1}.md3-navigation-tab--hide-inactive-label:not(.md3-navigation-tab--active) .md3-navigation-tab__label-text{height:0;opacity:0}.md3-navigation-tab__active-indicator{display:flex;justify-content:center;opacity:0;position:absolute;transition:width 100ms cubic-bezier(0.4, 0, 0.2, 1),opacity 100ms cubic-bezier(0.4, 0, 0.2, 1);width:32px;background-color:var(--_active-indicator-color);border-radius:var(--_active-indicator-shape)}.md3-navigation-tab--active .md3-navigation-tab__active-indicator{opacity:1}.md3-navigation-tab__active-indicator,.md3-navigation-tab__icon-content{height:var(--_active-indicator-height)}.md3-navigation-tab--active .md3-navigation-tab__active-indicator,.md3-navigation-tab__icon-content{width:var(--_active-indicator-width)}.md3-navigation-tab__icon{fill:currentColor;align-self:center;display:inline-block;position:relative;width:var(--_icon-size);height:var(--_icon-size);font-size:var(--_icon-size)}.md3-navigation-tab__icon.md3-navigation-tab__icon--active{display:none}.md3-navigation-tab--active .md3-navigation-tab__icon{display:none}.md3-navigation-tab--active .md3-navigation-tab__icon.md3-navigation-tab__icon--active{display:inline-block}.md3-navigation-tab__ripple{z-index:0}.md3-navigation-tab--active{--md-ripple-hover-state-layer-color:var(--_active-hover-state-layer-color);--md-ripple-focus-state-layer-color:var(--_active-focus-state-layer-color);--md-ripple-pressed-state-layer-color:var(--_active-pressed-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_hover-state-layer-opacity);--md-ripple-focus-state-layer-opacity:var(--_focus-state-layer-opacity);--md-ripple-pressed-state-layer-opacity:var(--_pressed-state-layer-opacity)}.md3-navigation-tab--active .md3-navigation-tab__icon{color:var(--_active-icon-color)}.md3-navigation-tab--active .md3-navigation-tab__label-text{color:var(--_active-label-text-color)}.md3-navigation-tab--active:hover .md3-navigation-tab__icon{color:var(--_active-hover-icon-color)}.md3-navigation-tab--active:hover .md3-navigation-tab__label-text{color:var(--_active-hover-label-text-color)}.md3-navigation-tab--active:focus .md3-navigation-tab__icon{color:var(--_active-focus-icon-color)}.md3-navigation-tab--active:focus .md3-navigation-tab__label-text{color:var(--_active-focus-label-text-color)}.md3-navigation-tab--active:active .md3-navigation-tab__icon{color:var(--_active-pressed-icon-color)}.md3-navigation-tab--active:active .md3-navigation-tab__label-text{color:var(--_active-pressed-label-text-color)}.md3-navigation-tab:not(.md3-navigation-tab--active){--md-ripple-hover-state-layer-color:var(--_inactive-hover-state-layer-color);--md-ripple-focus-state-layer-color:var(--_inactive-focus-state-layer-color);--md-ripple-pressed-state-layer-color:var(--_inactive-pressed-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_hover-state-layer-opacity);--md-ripple-focus-state-layer-opacity:var(--_focus-state-layer-opacity);--md-ripple-pressed-state-layer-opacity:var(--_pressed-state-layer-opacity)}.md3-navigation-tab:not(.md3-navigation-tab--active) .md3-navigation-tab__icon{color:var(--_inactive-icon-color)}.md3-navigation-tab:not(.md3-navigation-tab--active) .md3-navigation-tab__label-text{color:var(--_inactive-label-text-color)}.md3-navigation-tab:not(.md3-navigation-tab--active):hover .md3-navigation-tab__icon{color:var(--_inactive-hover-icon-color)}.md3-navigation-tab:not(.md3-navigation-tab--active):hover .md3-navigation-tab__label-text{color:var(--_inactive-hover-label-text-color)}.md3-navigation-tab:not(.md3-navigation-tab--active):focus .md3-navigation-tab__icon{color:var(--_inactive-focus-icon-color)}.md3-navigation-tab:not(.md3-navigation-tab--active):focus .md3-navigation-tab__label-text{color:var(--_inactive-focus-label-text-color)}.md3-navigation-tab:not(.md3-navigation-tab--active):active .md3-navigation-tab__icon{color:var(--_inactive-pressed-icon-color)}.md3-navigation-tab:not(.md3-navigation-tab--active):active .md3-navigation-tab__label-text{color:var(--_inactive-pressed-label-text-color)}/*# sourceMappingURL=navigation-tab-styles.css.map */ `; //# sourceMappingURL=navigation-tab-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationtab/lib/navigation-tab.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationtab/lib/navigation-tab.js index b2541e7..94a718b 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationtab/lib/navigation-tab.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationtab/lib/navigation-tab.js
@@ -3,13 +3,13 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; import '../../badge/badge.js'; import '../../focus/focus-ring.js'; -import { html } from '../../../../lit/index.js'; -import { property, query, state } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../lit/directives/if-defined.js'; +import { html } from 'lit'; +import { property, query, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { ActionElement } from '../../actionelement/action-element.js'; import { ariaProperty } from '../../decorators/aria-property.js'; import { pointerPress, shouldShowStrongFocus } from '../../focus/strong-focus.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationtab/navigation-tab.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationtab/navigation-tab.js index 5c9b1d1..432e3e6 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationtab/navigation-tab.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/navigationtab/navigation-tab.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { NavigationTab } from './lib/navigation-tab.js'; import { styles } from './lib/navigation-tab-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/lib/forced-colors-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/lib/forced-colors-styles.css.js index 3e9f7dcb..1030792 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/lib/forced-colors-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/lib/forced-colors-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `@media(forced-colors: active){:host{--md-radio-disabled-selected-icon-color:GrayText;--md-radio-disabled-selected-icon-opacity:1;--md-radio-disabled-unselected-icon-color:GrayText;--md-radio-disabled-unselected-icon-opacity:1;--md-radio-selected-icon-color:CanvasText;--md-radio-selected-hover-icon-color:CanvasText;--md-radio-selected-focus-icon-color:CanvasText;--md-radio-selected-pressed-icon-color:CanvasText;--md-radio-unselected-icon-color:CanvasText;--md-radio-unselected-hover-icon-color:CanvasText;--md-radio-unselected-focus-icon-color:CanvasText;--md-radio-unselected-pressed-icon-color:CanvasText}}/*# sourceMappingURL=forced-colors-styles.css.map */ `; //# sourceMappingURL=forced-colors-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/lib/radio-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/lib/radio-styles.css.js index 0c7eee46..b2d6cbc 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/lib/radio-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/lib/radio-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_disabled-selected-icon-color: var(--md-radio-disabled-selected-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-selected-icon-opacity: var(--md-radio-disabled-selected-icon-opacity, 0.38);--_disabled-unselected-icon-color: var(--md-radio-disabled-unselected-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-unselected-icon-opacity: var(--md-radio-disabled-unselected-icon-opacity, 0.38);--_icon-size: var(--md-radio-icon-size, 20px);--_selected-focus-icon-color: var(--md-radio-selected-focus-icon-color, var(--md-sys-color-primary, #6750a4));--_selected-focus-state-layer-color: var(--md-radio-selected-focus-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-focus-state-layer-opacity: var(--md-radio-selected-focus-state-layer-opacity, 0.12);--_selected-hover-icon-color: var(--md-radio-selected-hover-icon-color, var(--md-sys-color-primary, #6750a4));--_selected-hover-state-layer-color: var(--md-radio-selected-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-hover-state-layer-opacity: var(--md-radio-selected-hover-state-layer-opacity, 0.08);--_selected-icon-color: var(--md-radio-selected-icon-color, var(--md-sys-color-primary, #6750a4));--_selected-pressed-icon-color: var(--md-radio-selected-pressed-icon-color, var(--md-sys-color-primary, #6750a4));--_selected-pressed-state-layer-color: var(--md-radio-selected-pressed-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_selected-pressed-state-layer-opacity: var(--md-radio-selected-pressed-state-layer-opacity, 0.12);--_state-layer-size: var(--md-radio-state-layer-size, 40px);--_unselected-focus-icon-color: var(--md-radio-unselected-focus-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-focus-state-layer-color: var(--md-radio-unselected-focus-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-focus-state-layer-opacity: var(--md-radio-unselected-focus-state-layer-opacity, 0.12);--_unselected-hover-icon-color: var(--md-radio-unselected-hover-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-hover-state-layer-color: var(--md-radio-unselected-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-hover-state-layer-opacity: var(--md-radio-unselected-hover-state-layer-opacity, 0.08);--_unselected-icon-color: var(--md-radio-unselected-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-pressed-icon-color: var(--md-radio-unselected-pressed-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-pressed-state-layer-color: var(--md-radio-unselected-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_unselected-pressed-state-layer-opacity: var(--md-radio-unselected-pressed-state-layer-opacity, 0.12);--md-ripple-focus-state-layer-color:var(--_unselected-focus-state-layer-color);--md-ripple-focus-state-layer-opacity:var(--_unselected-focus-state-layer-opacity);--md-ripple-hover-state-layer-color:var(--_unselected-hover-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_unselected-hover-state-layer-opacity);--md-ripple-pressed-state-layer-color:var(--_unselected-pressed-state-layer-color);--md-ripple-pressed-state-layer-opacity:var(--_unselected-pressed-state-layer-opacity);--md-focus-ring-offset-vertical:-2px;--md-focus-ring-offset-horizontal:-2px;display:inline-flex;height:48px;position:relative;vertical-align:top;width:48px;-webkit-tap-highlight-color:rgba(0,0,0,0)}:host([checked]){--md-ripple-focus-state-layer-color:var(--_selected-focus-state-layer-color);--md-ripple-focus-state-layer-opacity:var(--_selected-focus-state-layer-opacity);--md-ripple-hover-state-layer-color:var(--_selected-hover-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_selected-hover-state-layer-opacity);--md-ripple-pressed-state-layer-color:var(--_selected-pressed-state-layer-color);--md-ripple-pressed-state-layer-opacity:var(--_selected-pressed-state-layer-opacity)}input,md-ripple,.icon{inset:0;margin:auto;position:absolute}input{appearance:none;outline:none}md-ripple{height:var(--_state-layer-size);width:var(--_state-layer-size)}.icon{fill:var(--_unselected-icon-color);height:var(--_icon-size);width:var(--_icon-size)}.outer.circle{transition:fill 50ms linear}.inner.circle{opacity:0;transform-origin:center;transition:opacity 50ms linear}:host([checked]) .icon{fill:var(--_selected-icon-color)}:host([checked]) .inner.circle{animation:inner-circle-grow 300ms cubic-bezier(0.05, 0.7, 0.1, 1);opacity:1}@keyframes inner-circle-grow{from{transform:scale(0)}to{transform:scale(1)}}:host([disabled]) .circle{animation-duration:0s;transition-duration:0s}:host(:hover) .icon{fill:var(--_unselected-hover-icon-color)}:host(:focus-within) .icon{fill:var(--_unselected-focus-icon-color)}:host(:active) .icon{fill:var(--_unselected-pressed-icon-color)}:host([disabled]) .icon{fill:var(--_disabled-unselected-icon-color);opacity:var(--_disabled-unselected-icon-opacity)}:host([checked]:hover) .icon{fill:var(--_selected-hover-icon-color)}:host([checked]:focus-within) .icon{fill:var(--_selected-focus-icon-color)}:host([checked]:active) .icon{fill:var(--_selected-pressed-icon-color)}:host([checked][disabled]) .icon{fill:var(--_disabled-selected-icon-color);opacity:var(--_disabled-selected-icon-opacity)}/*# sourceMappingURL=radio-styles.css.map */ `; //# sourceMappingURL=radio-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/lib/radio.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/lib/radio.js index 139a433..488bdb2 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/lib/radio.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/lib/radio.js
@@ -4,12 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ var _a; -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; import '../../focus/focus-ring.js'; import '../../ripple/ripple.js'; -import { html, LitElement, nothing } from '../../../../lit/index.js'; -import { property, query, queryAsync, state } from '../../../../lit/decorators.js'; -import { when } from '../../../../lit/directives/when.js'; +import { html, LitElement, nothing } from 'lit'; +import { property, query, queryAsync, state } from 'lit/decorators.js'; +import { when } from 'lit/directives/when.js'; import { dispatchActivationClick, isActivationClick, redispatchEvent } from '../../controller/events.js'; import { FormController, getFormValue } from '../../controller/form-controller.js'; import { ariaProperty } from '../../decorators/aria-property.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/radio.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/radio.js index 7df3c28..f922ab2 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/radio.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/radio/radio.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { styles as forcedColorsStyles } from './lib/forced-colors-styles.css.js'; import { Radio } from './lib/radio.js'; import { styles } from './lib/radio-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/directive.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/directive.js index 31ff90f..99bcc1c 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/directive.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/directive.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { noChange } from '../../../lit/index.js'; -import { Directive, directive, PartType } from '../../../lit/directive.js'; +import { noChange } from 'lit'; +import { Directive, directive, PartType } from 'lit/directive.js'; /** * Delay reacting to touch so that we do not show the ripple for a swipe or * scroll interaction.
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/lib/ripple-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/lib/ripple-styles.css.js index 7ee626a..3dba349 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/lib/ripple-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/lib/ripple-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_dragged-state-layer-opacity: var(--md-ripple-dragged-state-layer-opacity, 0.16);--_focus-state-layer-opacity: var(--md-ripple-focus-state-layer-opacity, 0.12);--_hover-state-layer-opacity: var(--md-ripple-hover-state-layer-opacity, 0.08);--_pressed-state-layer-opacity: var(--md-ripple-pressed-state-layer-opacity, 0.12);--_state-layer-shape: var(--md-ripple-state-layer-shape, 0px);--_focus-state-layer-color: var(--md-ripple-focus-state-layer-color, black);--_hover-state-layer-color: var(--md-ripple-hover-state-layer-color, black);--_pressed-state-layer-color: var(--md-ripple-pressed-state-layer-color, black);--_dragged-state-layer-color: var(--md-ripple-dragged-state-layer-color, black)}:host{display:flex}:host([disabled]){opacity:0}:host,.md3-ripple-surface{position:absolute;inset:0;pointer-events:none;overflow:hidden}.md3-ripple-surface{will-change:transform;border-radius:var(--_state-layer-shape);outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.md3-ripple-surface::before,.md3-ripple-surface::after{position:absolute;opacity:0;pointer-events:none;content:""}.md3-ripple-surface::before{background-color:var(--_hover-state-layer-color);transition:opacity 15ms linear,background-color 15ms linear;inset:0}.md3-ripple-surface::after{background:radial-gradient(closest-side, var(--_pressed-state-layer-color) max(100% - 70px, 65%), transparent 100%);transition:opacity 375ms linear;transform-origin:center center}.md3-ripple--hovered::before{background-color:var(--_hover-state-layer-color);opacity:var(--_hover-state-layer-opacity)}.md3-ripple--focused::before{background-color:var(--_focus-state-layer-color);opacity:var(--_focus-state-layer-opacity);transition-duration:75ms}.md3-ripple--pressed::after{opacity:var(--_pressed-state-layer-opacity);transition-duration:105ms}.md3-ripple--unbounded{--_state-layer-shape: var(--md-ripple-state-layer-shape, 9999px)}@media screen and (forced-colors: active){:host{display:none}}/*# sourceMappingURL=ripple-styles.css.map */ `; //# sourceMappingURL=ripple-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/lib/ripple.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/lib/ripple.js index 8392d2ac..cef389d 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/lib/ripple.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/lib/ripple.js
@@ -3,10 +3,10 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; -import { html, LitElement } from '../../../../lit/index.js'; -import { property, query, state } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; +import { __decorate, __metadata } from "tslib"; +import { html, LitElement } from 'lit'; +import { property, query, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; import { createAnimationSignal, EASING } from '../../motion/animation.js'; const PRESS_GROW_MS = 450; const MINIMUM_PRESS_MS = 225;
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/ripple.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/ripple.js index df55bcb..806a2b7 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/ripple.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/ripple/ripple.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { Ripple } from './lib/ripple.js'; import { styles } from './lib/ripple-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/outlined-segmented-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/outlined-segmented-button.js index f06b418..1c854e36 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/outlined-segmented-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/outlined-segmented-button.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { html } from '../../../../lit/index.js'; +import { html } from 'lit'; import { SegmentedButton } from './segmented-button.js'; /** @soyCompatible */ export class OutlinedSegmentedButton extends SegmentedButton {
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/outlined-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/outlined-styles.css.js index f0adb52..2671f29 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/outlined-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/outlined-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-height: var(--md-segmented-button-container-height, 40px);--_disabled-icon-color: var(--md-segmented-button-disabled-icon-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_disabled-label-text-color: var(--md-segmented-button-disabled-label-text-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_disabled-outline-color: var(--md-segmented-button-disabled-outline-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.12));--_focus-state-layer-opacity: var(--md-segmented-button-focus-state-layer-opacity, 0.12);--_hover-state-layer-opacity: var(--md-segmented-button-hover-state-layer-opacity, 0.08);--_label-text-font: var(--md-segmented-button-label-text-font, Roboto);--_label-text-line-height: var(--md-segmented-button-label-text-line-height, 1.25rem);--_label-text-size: var(--md-segmented-button-label-text-size, 0.875rem);--_label-text-tracking: var(--md-segmented-button-label-text-tracking, 0.006rem);--_label-text-type: var(--md-segmented-button-label-text-type, 500 0.875rem / 1.25rem Roboto);--_label-text-weight: var(--md-segmented-button-label-text-weight, 500);--_outline-color: var(--md-segmented-button-outline-color, var(--md-sys-color-outline, #79747e));--_outline-width: var(--md-segmented-button-outline-width, 1px);--_pressed-state-layer-opacity: var(--md-segmented-button-pressed-state-layer-opacity, 0.12);--_selected-container-color: var(--md-segmented-button-selected-container-color, var(--md-sys-color-secondary-container, #e8def8));--_selected-focus-icon-color: var(--md-segmented-button-selected-focus-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-focus-label-text-color: var(--md-segmented-button-selected-focus-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-focus-state-layer-color: var(--md-segmented-button-selected-focus-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-hover-icon-color: var(--md-segmented-button-selected-hover-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-hover-label-text-color: var(--md-segmented-button-selected-hover-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-hover-state-layer-color: var(--md-segmented-button-selected-hover-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-label-text-color: var(--md-segmented-button-selected-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-pressed-icon-color: var(--md-segmented-button-selected-pressed-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-pressed-label-text-color: var(--md-segmented-button-selected-pressed-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-pressed-state-layer-color: var(--md-segmented-button-selected-pressed-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-with-icon-icon-color: var(--md-segmented-button-selected-with-icon-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_shape: var(--md-segmented-button-shape, 9999px);--_unselected-focus-icon-color: var(--md-segmented-button-unselected-focus-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-focus-label-text-color: var(--md-segmented-button-unselected-focus-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-focus-state-layer-color: var(--md-segmented-button-unselected-focus-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-hover-icon-color: var(--md-segmented-button-unselected-hover-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-hover-label-text-color: var(--md-segmented-button-unselected-hover-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-hover-state-layer-color: var(--md-segmented-button-unselected-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-label-text-color: var(--md-segmented-button-unselected-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-pressed-icon-color: var(--md-segmented-button-unselected-pressed-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-pressed-label-text-color: var(--md-segmented-button-unselected-pressed-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-pressed-state-layer-color: var(--md-segmented-button-unselected-pressed-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-with-icon-icon-color: var(--md-segmented-button-unselected-with-icon-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_with-icon-icon-size: var(--md-segmented-button-with-icon-icon-size, 18px);--_spacing-leading: var(--md-segmented-button-spacing-leading, 12px);--_spacing-trailing: var(--md-segmented-button-spacing-trailing, 12px)}.md3-segmented-button__outline{border-radius:inherit;border-style:solid;border-width:1px;inset:0px -0.5px;pointer-events:none;position:absolute}/*# sourceMappingURL=outlined-styles.css.map */ `; //# sourceMappingURL=outlined-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/segmented-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/segmented-button.js index f232362..bad64f4 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/segmented-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/segmented-button.js
@@ -3,12 +3,12 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; import '../../focus/focus-ring.js'; -import { html } from '../../../../lit/index.js'; -import { property, query, queryAssignedElements, state } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../lit/directives/if-defined.js'; +import { html } from 'lit'; +import { property, query, queryAssignedElements, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { ActionElement } from '../../actionelement/action-element.js'; import { ariaProperty } from '../../decorators/aria-property.js'; import { pointerPress, shouldShowStrongFocus } from '../../focus/strong-focus.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/shared-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/shared-styles.css.js index 0d6ddb1..a11d1087 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/shared-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/lib/shared-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `@keyframes md3-segmented-button-checkmark-selection-draw-in{from{stroke-dashoffset:29.7833385}to{stroke-dashoffset:0}}@keyframes md3-segmented-button-simple-fade-out{from{opacity:1}to{opacity:0}}@keyframes md3-segmented-button-simple-fade-in{from{opacity:0}to{opacity:1}}:host{display:inline-flex;outline:none}.md3-segmented-button{align-items:center;background:rgba(0,0,0,0);border:none;border-radius:inherit;display:flex;flex:1;justify-content:center;outline:none;position:relative;vertical-align:middle;padding-inline-start:var(--_spacing-leading);padding-inline-end:var(--_spacing-trailing)}.md3-segmented-button .md3-segmented-button__outline{border-color:var(--_outline-color)}.md3-segmented-button:disabled .md3-segmented-button__outline{border-color:var(--_disabled-outline-color)}.md3-segmented-button .md3-segmented-button__graphic,.md3-segmented-button .md3-segmented-button__checkmark,.md3-segmented-button .md3-segmented-button__icon,.md3-segmented-button .md3-segmented-button__icon ::slotted([slot=icon]){height:var(--_with-icon-icon-size);width:var(--_with-icon-icon-size);font-size:var(--_with-icon-icon-size)}.md3-segmented-button.md3-segmented-button--with-icon.md3-segmented-button--with-label .md3-segmented-button__graphic,.md3-segmented-button.md3-segmented-button--selected.md3-segmented-button--with-label.md3-segmented-button--with-checkmark .md3-segmented-button__graphic,.md3-segmented-button.md3-segmented-button--selected.md3-segmented-button--without-label.md3-segmented-button--with-checkmark .md3-segmented-button__graphic{width:calc(var(--_with-icon-icon-size) + 8px)}.md3-segmented-button .md3-segmented-button__label-text{font-family:var(--_label-text-font);font-size:var(--_label-text-size);letter-spacing:var(--_label-text-tracking);font-weight:var(--_label-text-weight)}.md3-segmented-button.md3-segmented-button--selected:enabled .md3-segmented-button__label-text{color:var(--_selected-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:hover .md3-segmented-button__label-text{color:var(--_selected-hover-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:focus .md3-segmented-button__label-text{color:var(--_selected-focus-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:active .md3-segmented-button__label-text{color:var(--_selected-pressed-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled .md3-segmented-button__label-text{color:var(--_unselected-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:hover .md3-segmented-button__label-text{color:var(--_unselected-hover-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:focus .md3-segmented-button__label-text{color:var(--_unselected-focus-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:active .md3-segmented-button__label-text{color:var(--_unselected-pressed-label-text-color)}.md3-segmented-button:disabled .md3-segmented-button__label-text{color:var(--_disabled-label-text-color)}.md3-segmented-button--unselected{--md-ripple-hover-state-layer-color:var(--_unselected-hover-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_hover-state-layer-opacity);--md-ripple-focus-state-layer-color:var(--_unselected-focus-state-layer-color);--md-ripple-focus-state-layer-opacity:var(--_focus-state-layer-opacity);--md-ripple-pressed-state-layer-color:var(--_unselected-pressed-state-layer-color);--md-ripple-pressed-state-layer-opacity:var(--_pressed-state-layer-opacity)}.md3-segmented-button--unselected .md3-segmented-button__icon{color:var(--_unselected-with-icon-icon-color)}.md3-segmented-button--unselected:hover .md3-segmented-button__icon{color:var(--_unselected-hover-icon-color)}.md3-segmented-button--unselected:focus .md3-segmented-button__icon{color:var(--_unselected-focus-icon-color)}.md3-segmented-button--unselected:active .md3-segmented-button__icon{color:var(--_unselected-pressed-icon-color)}.md3-segmented-button--unselected:disabled .md3-segmented-button__icon{color:var(--_disabled-icon-color)}.md3-segmented-button--selected{background-color:var(--_selected-container-color);--md-ripple-hover-state-layer-color:var(--_selected-hover-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_hover-state-layer-opacity);--md-ripple-focus-state-layer-color:var(--_selected-focus-state-layer-color);--md-ripple-focus-state-layer-opacity:var(--_focus-state-layer-opacity);--md-ripple-pressed-state-layer-color:var(--_selected-pressed-state-layer-color);--md-ripple-pressed-state-layer-opacity:var(--_pressed-state-layer-opacity)}.md3-segmented-button--selected .md3-segmented-button__icon{color:var(--_selected-with-icon-icon-color)}.md3-segmented-button--selected .md3-segmented-button__checkmark-path{stroke:var(--_selected-with-icon-icon-color)}.md3-segmented-button--selected:hover .md3-segmented-button__checkmark-path{stroke:var(--_selected-hover-icon-color)}.md3-segmented-button--selected:focus .md3-segmented-button__checkmark-path{stroke:var(--_selected-focus-icon-color)}.md3-segmented-button--selected:active .md3-segmented-button__checkmark-path{stroke:var(--_selected-pressed-icon-color)}.md3-segmented-button--selected:disabled .md3-segmented-button__checkmark-path{stroke:var(--_disabled-icon-color)}.md3-segmented-button:enabled{cursor:pointer}.md3-segmented-button__focus-ring{z-index:1}.md3-segmented-button__ripple{border-radius:inherit;z-index:0}.md3-segmented-button__touch{position:absolute;top:50%;height:48px;left:50%;width:100%;transform:translate(-50%, -50%)}.md3-segmented-button__leading,.md3-segmented-button__graphic{display:inline-flex;justify-content:flex-start;align-items:center}.md3-segmented-button__graphic{position:relative;overflow:hidden}.md3-segmented-button__graphic{transition:width 150ms cubic-bezier(0.4, 0, 0.2, 1)}.md3-segmented-button--unselected.md3-segmented-button--with-label .md3-segmented-button__graphic,.md3-segmented-button--unselected.md3-segmented-button--without-label .md3-segmented-button__graphic,.md3-segmented-button--selected.md3-segmented-button--without-checkmark .md3-segmented-button__graphic{width:0}.md3-segmented-button--unselected .md3-segmented-button__checkmark{opacity:0}.md3-segmented-button--selected.md3-segmented-button--with-label .md3-segmented-button__icon{opacity:0}.md3-segmented-button--with-label .md3-segmented-button__checkmark{display:inline-flex;position:absolute}.md3-segmented-button__checkmark-path{stroke-width:2px;stroke-dasharray:29.7833385}.md3-segmented-button--selecting .md3-segmented-button__checkmark-path{stroke-dashoffset:29.7833385;animation:md3-segmented-button-checkmark-selection-draw-in;animation-duration:150ms;animation-delay:50ms;animation-fill-mode:forwards;animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.md3-segmented-button--selecting.md3-segmented-button--with-label .md3-segmented-button__icon{animation:md3-segmented-button-simple-fade-out;animation-duration:75ms;animation-timing-function:linear;animation-fill-mode:forwards}.md3-segmented-button--deselecting .md3-segmented-button__checkmark{animation:md3-segmented-button-simple-fade-out;animation-duration:50ms;animation-timing-function:linear;animation-fill-mode:forwards}.md3-segmented-button--deselecting.md3-segmented-button--with-label .md3-segmented-button__icon{opacity:0;animation:md3-segmented-button-simple-fade-in;animation-delay:50ms;animation-duration:150ms;animation-timing-function:linear;animation-fill-mode:forwards}/*# sourceMappingURL=shared-styles.css.map */ `; //# sourceMappingURL=shared-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/outlined-segmented-button.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/outlined-segmented-button.js index b698f5d..27a63ed3 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/outlined-segmented-button.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbutton/outlined-segmented-button.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { OutlinedSegmentedButton } from './lib/outlined-segmented-button.js'; import { styles as outlinedStyles } from './lib/outlined-styles.css.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/lib/outlined-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/lib/outlined-styles.css.js index 08c87c1..22801a9c 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/lib/outlined-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/lib/outlined-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_shape-start-start: var(--md-segmented-button-shape-start-start, 9999px);--_shape-start-end: var(--md-segmented-button-shape-start-end, 9999px);--_shape-end-end: var(--md-segmented-button-shape-end-end, 9999px);--_shape-end-start: var(--md-segmented-button-shape-end-start, 9999px);--_container-height: var(--md-segmented-button-container-height, 40px);--_disabled-icon-color: var(--md-segmented-button-disabled-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-icon-opacity: var(--md-segmented-button-disabled-icon-opacity, 0.38);--_disabled-label-text-color: var(--md-segmented-button-disabled-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-label-text-opacity: var(--md-segmented-button-disabled-label-text-opacity, 0.38);--_disabled-outline-color: var(--md-segmented-button-disabled-outline-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-outline-opacity: var(--md-segmented-button-disabled-outline-opacity, 0.12);--_focus-state-layer-opacity: var(--md-segmented-button-focus-state-layer-opacity, 0.12);--_hover-state-layer-opacity: var(--md-segmented-button-hover-state-layer-opacity, 0.08);--_label-text-font: var(--md-segmented-button-label-text-font, Roboto);--_label-text-line-height: var(--md-segmented-button-label-text-line-height, 1.25rem);--_label-text-size: var(--md-segmented-button-label-text-size, 0.875rem);--_label-text-tracking: var(--md-segmented-button-label-text-tracking, 0.006rem);--_label-text-type: var(--md-segmented-button-label-text-type, 500 0.875rem / 1.25rem Roboto);--_label-text-weight: var(--md-segmented-button-label-text-weight, 500);--_outline-color: var(--md-segmented-button-outline-color, var(--md-sys-color-outline, #79747e));--_outline-width: var(--md-segmented-button-outline-width, 1px);--_pressed-state-layer-opacity: var(--md-segmented-button-pressed-state-layer-opacity, 0.12);--_selected-container-color: var(--md-segmented-button-selected-container-color, var(--md-sys-color-secondary-container, #e8def8));--_selected-focus-icon-color: var(--md-segmented-button-selected-focus-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-focus-label-text-color: var(--md-segmented-button-selected-focus-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-focus-state-layer-color: var(--md-segmented-button-selected-focus-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-hover-icon-color: var(--md-segmented-button-selected-hover-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-hover-label-text-color: var(--md-segmented-button-selected-hover-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-hover-state-layer-color: var(--md-segmented-button-selected-hover-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-label-text-color: var(--md-segmented-button-selected-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-pressed-icon-color: var(--md-segmented-button-selected-pressed-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-pressed-label-text-color: var(--md-segmented-button-selected-pressed-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-pressed-state-layer-color: var(--md-segmented-button-selected-pressed-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-with-icon-icon-color: var(--md-segmented-button-selected-with-icon-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_unselected-focus-icon-color: var(--md-segmented-button-unselected-focus-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-focus-label-text-color: var(--md-segmented-button-unselected-focus-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-focus-state-layer-color: var(--md-segmented-button-unselected-focus-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-hover-icon-color: var(--md-segmented-button-unselected-hover-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-hover-label-text-color: var(--md-segmented-button-unselected-hover-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-hover-state-layer-color: var(--md-segmented-button-unselected-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-label-text-color: var(--md-segmented-button-unselected-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-pressed-icon-color: var(--md-segmented-button-unselected-pressed-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-pressed-label-text-color: var(--md-segmented-button-unselected-pressed-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-pressed-state-layer-color: var(--md-segmented-button-unselected-pressed-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-with-icon-icon-color: var(--md-segmented-button-unselected-with-icon-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_with-icon-icon-size: var(--md-segmented-button-with-icon-icon-size, 18px)}/*# sourceMappingURL=outlined-styles.css.map */ `; //# sourceMappingURL=outlined-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/lib/segmented-button-set.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/lib/segmented-button-set.js index f86c0b1..5441453 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/lib/segmented-button-set.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/lib/segmented-button-set.js
@@ -3,11 +3,11 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; -import { html, LitElement } from '../../../../lit/index.js'; -import { property, queryAssignedElements } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../lit/directives/if-defined.js'; +import { __decorate, __metadata } from "tslib"; +import { html, LitElement } from 'lit'; +import { property, queryAssignedElements } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { ariaProperty } from '../../decorators/aria-property.js'; /** * SegmentedButtonSet is the parent component for two or more
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/lib/shared-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/lib/shared-styles.css.js index 00e3f4d..64904c1 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/lib/shared-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/lib/shared-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{display:flex;outline:none}.md3-segmented-button-set{display:grid;grid-auto-columns:1fr;grid-auto-flow:column;grid-auto-rows:auto;width:100%;height:var(--_container-height)}.md3-segmented-button-set ::slotted(:first-child){border-start-start-radius:var(--_shape-start-start);border-end-start-radius:var(--_shape-end-start)}.md3-segmented-button-set ::slotted(:last-child){border-start-end-radius:var(--_shape-start-end);border-end-end-radius:var(--_shape-end-end)}/*# sourceMappingURL=shared-styles.css.map */ `; //# sourceMappingURL=shared-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/outlined-segmented-button-set.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/outlined-segmented-button-set.js index 78cd159..3f9b61c15 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/outlined-segmented-button-set.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/segmentedbuttonset/outlined-segmented-button-set.js
@@ -3,8 +3,8 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { OutlinedSegmentedButtonSet } from './lib/outlined-segmented-button-set.js'; import { styles as outlinedStyles } from './lib/outlined-styles.css.js'; import { styles as sharedStyles } from './lib/shared-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/switch/lib/switch-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/switch/lib/switch-styles.css.js index e30e3985..2c20aed 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/switch/lib/switch-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/switch/lib/switch-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_handle-shape-start-start: var(--md-switch-handle-shape-start-start, 9999px);--_handle-shape-start-end: var(--md-switch-handle-shape-start-end, 9999px);--_handle-shape-end-end: var(--md-switch-handle-shape-end-end, 9999px);--_handle-shape-end-start: var(--md-switch-handle-shape-end-start, 9999px);--_track-shape-start-start: var(--md-switch-track-shape-start-start, 9999px);--_track-shape-start-end: var(--md-switch-track-shape-start-end, 9999px);--_track-shape-end-end: var(--md-switch-track-shape-end-end, 9999px);--_track-shape-end-start: var(--md-switch-track-shape-end-start, 9999px);--_disabled-selected-handle-color: var(--md-switch-disabled-selected-handle-color, rgb(var(--md-sys-color-surface-rgb, 255, 251, 254), 1));--_disabled-selected-icon-color: var(--md-switch-disabled-selected-icon-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_disabled-selected-track-color: var(--md-switch-disabled-selected-track-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.12));--_disabled-unselected-handle-color: var(--md-switch-disabled-unselected-handle-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.38));--_disabled-unselected-icon-color: var(--md-switch-disabled-unselected-icon-color, rgb(var(--md-sys-color-surface-variant-rgb, 231, 224, 236), 0.38));--_disabled-unselected-track-color: var(--md-switch-disabled-unselected-track-color, rgb(var(--md-sys-color-surface-variant-rgb, 231, 224, 236), 0.12));--_disabled-unselected-track-outline-color: var(--md-switch-disabled-unselected-track-outline-color, rgb(var(--md-sys-color-on-surface-rgb, 28, 27, 31), 0.12));--_pressed-handle-height: var(--md-switch-pressed-handle-height, 28px);--_pressed-handle-width: var(--md-switch-pressed-handle-width, 28px);--_selected-focus-handle-color: var(--md-switch-selected-focus-handle-color, var(--md-sys-color-primary-container, #eaddff));--_selected-focus-icon-color: var(--md-switch-selected-focus-icon-color, var(--md-sys-color-on-primary-container, #21005d));--_selected-focus-state-layer-color: var(--md-switch-selected-focus-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-focus-state-layer-opacity: var(--md-switch-selected-focus-state-layer-opacity, 0.12);--_selected-focus-track-color: var(--md-switch-selected-focus-track-color, var(--md-sys-color-primary, #6750a4));--_selected-handle-color: var(--md-switch-selected-handle-color, var(--md-sys-color-on-primary, #fff));--_selected-handle-height: var(--md-switch-selected-handle-height, 24px);--_selected-handle-width: var(--md-switch-selected-handle-width, 24px);--_selected-hover-handle-color: var(--md-switch-selected-hover-handle-color, var(--md-sys-color-primary-container, #eaddff));--_selected-hover-icon-color: var(--md-switch-selected-hover-icon-color, var(--md-sys-color-on-primary-container, #21005d));--_selected-hover-state-layer-color: var(--md-switch-selected-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-hover-state-layer-opacity: var(--md-switch-selected-hover-state-layer-opacity, 0.08);--_selected-hover-track-color: var(--md-switch-selected-hover-track-color, var(--md-sys-color-primary, #6750a4));--_selected-icon-color: var(--md-switch-selected-icon-color, var(--md-sys-color-on-primary-container, #21005d));--_selected-icon-size: var(--md-switch-selected-icon-size, 16px);--_selected-pressed-handle-color: var(--md-switch-selected-pressed-handle-color, var(--md-sys-color-primary-container, #eaddff));--_selected-pressed-icon-color: var(--md-switch-selected-pressed-icon-color, var(--md-sys-color-on-primary-container, #21005d));--_selected-pressed-state-layer-color: var(--md-switch-selected-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-pressed-state-layer-opacity: var(--md-switch-selected-pressed-state-layer-opacity, 0.12);--_selected-pressed-track-color: var(--md-switch-selected-pressed-track-color, var(--md-sys-color-primary, #6750a4));--_selected-track-color: var(--md-switch-selected-track-color, var(--md-sys-color-primary, #6750a4));--_state-layer-shape: var(--md-switch-state-layer-shape, 9999px);--_state-layer-size: var(--md-switch-state-layer-size, 40px);--_track-height: var(--md-switch-track-height, 32px);--_track-outline-width: var(--md-switch-track-outline-width, 2px);--_track-width: var(--md-switch-track-width, 52px);--_unselected-focus-handle-color: var(--md-switch-unselected-focus-handle-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-focus-icon-color: var(--md-switch-unselected-focus-icon-color, var(--md-sys-color-surface-variant, #e7e0ec));--_unselected-focus-state-layer-color: var(--md-switch-unselected-focus-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-focus-state-layer-opacity: var(--md-switch-unselected-focus-state-layer-opacity, 0.12);--_unselected-focus-track-color: var(--md-switch-unselected-focus-track-color, var(--md-sys-color-surface-variant, #e7e0ec));--_unselected-focus-track-outline-color: var(--md-switch-unselected-focus-track-outline-color, var(--md-sys-color-outline, #79747e));--_unselected-handle-color: var(--md-switch-unselected-handle-color, var(--md-sys-color-outline, #79747e));--_unselected-handle-height: var(--md-switch-unselected-handle-height, 16px);--_unselected-handle-width: var(--md-switch-unselected-handle-width, 16px);--_unselected-hover-handle-color: var(--md-switch-unselected-hover-handle-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-hover-icon-color: var(--md-switch-unselected-hover-icon-color, var(--md-sys-color-surface-variant, #e7e0ec));--_unselected-hover-state-layer-color: var(--md-switch-unselected-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-hover-state-layer-opacity: var(--md-switch-unselected-hover-state-layer-opacity, 0.08);--_unselected-hover-track-color: var(--md-switch-unselected-hover-track-color, var(--md-sys-color-surface-variant, #e7e0ec));--_unselected-hover-track-outline-color: var(--md-switch-unselected-hover-track-outline-color, var(--md-sys-color-outline, #79747e));--_unselected-icon-color: var(--md-switch-unselected-icon-color, var(--md-sys-color-surface-variant, #e7e0ec));--_unselected-icon-size: var(--md-switch-unselected-icon-size, 16px);--_unselected-pressed-handle-color: var(--md-switch-unselected-pressed-handle-color, var(--md-sys-color-on-surface-variant, #49454f));--_unselected-pressed-icon-color: var(--md-switch-unselected-pressed-icon-color, var(--md-sys-color-surface-variant, #e7e0ec));--_unselected-pressed-state-layer-color: var(--md-switch-unselected-pressed-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_unselected-pressed-state-layer-opacity: var(--md-switch-unselected-pressed-state-layer-opacity, 0.12);--_unselected-pressed-track-color: var(--md-switch-unselected-pressed-track-color, var(--md-sys-color-surface-variant, #e7e0ec));--_unselected-pressed-track-outline-color: var(--md-switch-unselected-pressed-track-outline-color, var(--md-sys-color-outline, #79747e));--_unselected-track-color: var(--md-switch-unselected-track-color, var(--md-sys-color-surface-variant, #e7e0ec));--_unselected-track-outline-color: var(--md-switch-unselected-track-outline-color, var(--md-sys-color-outline, #79747e));--_with-icon-handle-height: var(--md-switch-with-icon-handle-height, 24px);--_with-icon-handle-width: var(--md-switch-with-icon-handle-width, 24px);display:inline-flex;outline:none;vertical-align:top;-webkit-tap-highlight-color:rgba(0,0,0,0)}@media screen and (forced-colors: active){:host{--md-switch-disabled-selected-icon-color:GrayText;--md-switch-disabled-selected-track-color:GrayText;--md-switch-disabled-unselected-handle-color:GrayText;--md-switch-disabled-unselected-icon-color:Canvas;--md-switch-selected-focus-track-color:ButtonText;--md-switch-selected-hover-track-color:ButtonText;--md-switch-selected-icon-color:ButtonText;--md-switch-selected-pressed-track-color:ButtonText;--md-switch-selected-track-color:ButtonText;--md-switch-unselected-focus-handle-color:ButtonText;--md-switch-unselected-handle-color:ButtonText;--md-switch-unselected-hover-handle-color:ButtonText;--md-switch-unselected-icon-color:Canvas;--md-switch-unselected-pressed-handle-color:ButtonText}}md-focus-ring{--md-focus-ring-shape-start-start:var(--_track-shape-start-start);--md-focus-ring-shape-start-end:var(--_track-shape-start-end);--md-focus-ring-shape-end-end:var(--_track-shape-end-start);--md-focus-ring-shape-end-start:var(--_track-shape-end-end)}.md3-switch{align-items:center;background:none;border:none;cursor:pointer;display:inline-flex;flex-shrink:0;margin:0;outline:none;padding:0;position:relative;width:var(--_track-width);height:var(--_track-height);border-start-start-radius:var(--_track-shape-start-start);border-start-end-radius:var(--_track-shape-start-end);border-end-end-radius:var(--_track-shape-end-end);border-end-start-radius:var(--_track-shape-end-start)}.md3-switch__touch{position:absolute;top:50%;height:48px;left:50%;width:48px;transform:translate(-50%, -50%)}.md3-switch:disabled{cursor:default;pointer-events:none}.md3-switch:disabled .md3-switch__track{background-color:rgba(0,0,0,0);border-color:rgba(0,0,0,0)}.md3-switch:disabled .md3-switch__track::before{background-clip:content-box}.md3-switch--selected:disabled .md3-switch__track{background-clip:border-box}.md3-switch__track{position:absolute;width:100%;height:100%;box-sizing:border-box;border-radius:inherit;display:flex;justify-content:center;align-items:center;transition:background-color 67ms linear;background-color:var(--_selected-track-color)}.md3-switch:disabled .md3-switch__track{transition:none}.md3-switch--selected:hover .md3-switch__track{background-color:var(--_selected-hover-track-color)}.md3-switch--selected:focus-visible .md3-switch__track{background-color:var(--_selected-focus-track-color)}.md3-switch--selected:active .md3-switch__track{background-color:var(--_selected-pressed-track-color)}.md3-switch--selected:disabled .md3-switch__track{background-color:var(--_disabled-selected-track-color)}.md3-switch__track::before{content:"";display:flex;position:absolute;height:100%;width:100%;border-radius:inherit;box-sizing:border-box;border-style:solid;transition-property:opacity,background-color;transition-timing-function:linear;transition-duration:67ms;border-width:var(--_track-outline-width);background-color:var(--_unselected-track-color);border-color:var(--_unselected-track-outline-color)}.md3-switch:disabled .md3-switch__track::before{transition:none}.md3-switch--selected .md3-switch__track::before{opacity:0}.md3-switch--unselected:hover .md3-switch__track::before{background-color:var(--_unselected-hover-track-color);border-color:var(--_unselected-hover-track-outline-color)}.md3-switch--unselected:focus-visible .md3-switch__track::before{background-color:var(--_unselected-focus-track-color);border-color:var(--_unselected-focus-track-outline-color)}.md3-switch--unselected:active .md3-switch__track::before{background-color:var(--_unselected-pressed-track-color);border-color:var(--_unselected-pressed-track-outline-color)}.md3-switch--unselected:disabled .md3-switch__track::before{background-color:var(--_disabled-unselected-track-color);border-color:var(--_disabled-unselected-track-outline-color)}.md3-switch__handle-container{position:relative;transition:margin 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275);display:flex}.md3-switch--selected .md3-switch__handle-container{margin-inline-start:calc(var(--_track-width) - var(--_track-height))}.md3-switch--unselected .md3-switch__handle-container{margin-inline-end:calc(var(--_track-width) - var(--_track-height))}.md3-switch:disabled .md3-switch__handle-container{transition:none}.md3-switch__handle{border-start-start-radius:var(--_handle-shape-start-start);border-start-end-radius:var(--_handle-shape-start-end);border-end-end-radius:var(--_handle-shape-end-end);border-end-start-radius:var(--_handle-shape-end-start);height:var(--_unselected-handle-height);width:var(--_unselected-handle-width);background-color:var(--_selected-handle-color);transform-origin:center;transition-property:height,width,background-color;transition-duration:250ms,250ms,67ms;transition-timing-function:cubic-bezier(0.2, 0, 0, 1),cubic-bezier(0.2, 0, 0, 1),linear;z-index:0}.md3-switch__handle::before{content:"";display:flex;position:absolute;height:100%;width:100%;border-radius:inherit;box-sizing:border-box;transition:opacity 67ms linear}.md3-switch--selected .md3-switch__handle::before{opacity:0}.md3-switch:disabled .md3-switch__handle::before{transition:none}.md3-switch:disabled .md3-switch__handle{transition:none}.md3-switch--selected .md3-switch__handle,.md3-switch--unselected .md3-switch__handle.md3-switch__handle--big{height:var(--_selected-handle-height);width:var(--_selected-handle-width)}.md3-switch--selected:enabled:active .md3-switch__handle,.md3-switch--unselected:enabled:active .md3-switch__handle{height:var(--_pressed-handle-height);width:var(--_pressed-handle-width);transition-timing-function:linear;transition-duration:100ms}.md3-switch--selected:hover .md3-switch__handle{background-color:var(--_selected-hover-handle-color)}.md3-switch--selected:focus-visible .md3-switch__handle{background-color:var(--_selected-focus-handle-color)}.md3-switch--selected:active .md3-switch__handle{background-color:var(--_selected-pressed-handle-color)}.md3-switch--selected:disabled .md3-switch__handle{background-color:var(--_disabled-selected-handle-color)}.md3-switch__handle::before{background-color:var(--_unselected-handle-color)}.md3-switch--unselected:hover .md3-switch__handle::before{background-color:var(--_unselected-hover-handle-color)}.md3-switch--unselected:focus-visible .md3-switch__handle::before{background-color:var(--_unselected-focus-handle-color)}.md3-switch--unselected:active .md3-switch__handle::before{background-color:var(--_unselected-pressed-handle-color)}.md3-switch--unselected:disabled .md3-switch__handle::before{background-color:var(--_disabled-unselected-handle-color)}.md3-switch__ripple{position:absolute;display:inline-flex;top:50%;left:50%;transform:translate(-50%, -50%);height:var(--_state-layer-size);width:var(--_state-layer-size)}.md3-switch--selected .md3-switch__ripple{--md-ripple-hover-state-layer-color:var(--_selected-hover-state-layer-color);--md-ripple-focus-state-layer-color:var(--_selected-focus-state-layer-color);--md-ripple-pressed-state-layer-color:var(--_selected-pressed-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_selected-hover-state-layer-opacity);--md-ripple-focus-state-layer-opacity:var(--_selected-focus-state-layer-opacity);--md-ripple-pressed-state-layer-opacity:var(--_selected-pressed-state-layer-opacity)}.md3-switch--unselected .md3-switch__ripple{--md-ripple-hover-state-layer-color:var(--_unselected-hover-state-layer-color);--md-ripple-focus-state-layer-color:var(--_unselected-focus-state-layer-color);--md-ripple-pressed-state-layer-color:var(--_unselected-pressed-state-layer-color);--md-ripple-hover-state-layer-opacity:var(--_unselected-hover-state-layer-opacity);--md-ripple-focus-state-layer-opacity:var(--_unselected-focus-state-layer-opacity);--md-ripple-pressed-state-layer-opacity:var(--_unselected-pressed-state-layer-opacity)}.md3-switch__icons{position:relative;height:100%;width:100%}.md3-switch__icon{position:absolute;inset:0;margin:auto;transition:fill 67ms linear,opacity 33ms linear,transform 167ms cubic-bezier(0.2, 0, 0, 1);opacity:0}.md3-switch:disabled .md3-switch__icon{transition:none}.md3-switch--selected .md3-switch__icon--on,.md3-switch--unselected .md3-switch__icon--off{opacity:1}.md3-switch--unselected .md3-switch__handle:not(.md3-switch__handle--big) .md3-switch__icon--on{transform:rotate(-45deg)}.md3-switch--selected .md3-switch__icon{width:var(--_selected-icon-size);height:var(--_selected-icon-size);fill:var(--_selected-icon-color)}.md3-switch--unselected .md3-switch__icon{width:var(--_unselected-icon-size);height:var(--_unselected-icon-size);fill:var(--_unselected-icon-color)}.md3-switch--selected:disabled .md3-switch__icon{fill:var(--_disabled-selected-icon-color)}.md3-switch--unselected:disabled .md3-switch__icon{fill:var(--_disabled-unselected-icon-color)}/*# sourceMappingURL=switch-styles.css.map */ `; //# sourceMappingURL=switch-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/switch/lib/switch.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/switch/lib/switch.js index f6c2565..31c33bb 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/switch/lib/switch.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/switch/lib/switch.js
@@ -3,15 +3,15 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; +import { __decorate, __metadata } from "tslib"; // tslint:disable:no-new-decorators import '../../focus/focus-ring.js'; import '../../ripple/ripple.js'; -import { html, LitElement } from '../../../../lit/index.js'; -import { eventOptions, property, query, queryAsync, state } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../lit/directives/if-defined.js'; -import { when } from '../../../../lit/directives/when.js'; +import { html, LitElement } from 'lit'; +import { eventOptions, property, query, queryAsync, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; +import { when } from 'lit/directives/when.js'; import { dispatchActivationClick, isActivationClick } from '../../controller/events.js'; import { FormController, getFormValue } from '../../controller/form-controller.js'; import { ariaProperty } from '../../decorators/aria-property.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/switch/switch.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/switch/switch.js index 226f482..8e9a84d7 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/switch/switch.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/switch/switch.js
@@ -3,8 +3,8 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; -import { customElement } from '../../../lit/decorators.js'; +import { __decorate } from "tslib"; +import { customElement } from 'lit/decorators.js'; import { Switch } from './lib/switch.js'; import { styles } from './lib/switch-styles.css.js'; /**
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/filled-text-field.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/filled-text-field.js index aed5d107..7facd514 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/filled-text-field.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/filled-text-field.js
@@ -3,10 +3,10 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; +import { __decorate } from "tslib"; import '../field/filled-field.js'; -import { customElement } from '../../../lit/decorators.js'; -import { literal } from '../../../lit/static-html.js'; +import { customElement } from 'lit/decorators.js'; +import { literal } from 'lit/static-html.js'; // TODO(b/236285090): update with HCM best practices import { styles as filledForcedColorsStyles } from './lib/filled-forced-colors-styles.css.js'; import { styles as filledStyles } from './lib/filled-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/filled-forced-colors-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/filled-forced-colors-styles.css.js index cb6a2fa..8d6da31 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/filled-forced-colors-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/filled-forced-colors-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `@media(forced-colors: active){:host{--md-filled-text-field-disabled-active-indicator-color:GrayText;--md-filled-text-field-disabled-active-indicator-opacity:1;--md-filled-text-field-disabled-input-text-color:GrayText;--md-filled-text-field-disabled-input-text-opacity:1;--md-filled-text-field-disabled-label-text-color:GrayText;--md-filled-text-field-disabled-label-text-opacity:1;--md-filled-text-field-disabled-leading-icon-color:GrayText;--md-filled-text-field-disabled-leading-icon-opacity:1;--md-filled-text-field-disabled-supporting-text-color:GrayText;--md-filled-text-field-disabled-supporting-text-opacity:1;--md-filled-text-field-disabled-trailing-icon-color:GrayText;--md-filled-text-field-disabled-trailing-icon-opacity:1}}/*# sourceMappingURL=filled-forced-colors-styles.css.map */ `; //# sourceMappingURL=filled-forced-colors-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/filled-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/filled-styles.css.js index c0e678e..c93fc04 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/filled-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/filled-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-shape-start-start: var(--md-filled-text-field-container-shape-start-start, 4px);--_container-shape-start-end: var(--md-filled-text-field-container-shape-start-end, 4px);--_container-shape-end-end: var(--md-filled-text-field-container-shape-end-end, 0px);--_container-shape-end-start: var(--md-filled-text-field-container-shape-end-start, 0px);--_container-padding-horizontal: var(--md-filled-text-field-container-padding-horizontal, 16px);--_container-padding-vertical: var(--md-filled-text-field-container-padding-vertical, 16px);--_input-text-prefix-padding: var(--md-filled-text-field-input-text-prefix-padding, 2px);--_input-text-suffix-padding: var(--md-filled-text-field-input-text-suffix-padding, 2px);--_with-label-container-padding-vertical: var(--md-filled-text-field-with-label-container-padding-vertical, 8px);--_active-indicator-color: var(--md-filled-text-field-active-indicator-color, var(--md-sys-color-on-surface-variant, #49454f));--_active-indicator-height: var(--md-filled-text-field-active-indicator-height, 1px);--_caret-color: var(--md-filled-text-field-caret-color, var(--md-sys-color-primary, #6750a4));--_container-color: var(--md-filled-text-field-container-color, var(--md-sys-color-surface-variant, #e7e0ec));--_disabled-active-indicator-color: var(--md-filled-text-field-disabled-active-indicator-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-active-indicator-height: var(--md-filled-text-field-disabled-active-indicator-height, 1px);--_disabled-active-indicator-opacity: var(--md-filled-text-field-disabled-active-indicator-opacity, 0.38);--_disabled-container-color: var(--md-filled-text-field-disabled-container-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-container-opacity: var(--md-filled-text-field-disabled-container-opacity, 0.04);--_disabled-input-text-color: var(--md-filled-text-field-disabled-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-input-text-opacity: var(--md-filled-text-field-disabled-input-text-opacity, 0.38);--_disabled-label-text-color: var(--md-filled-text-field-disabled-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-label-text-opacity: var(--md-filled-text-field-disabled-label-text-opacity, 0.38);--_disabled-leading-icon-color: var(--md-filled-text-field-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-leading-icon-opacity: var(--md-filled-text-field-disabled-leading-icon-opacity, 0.38);--_disabled-supporting-text-color: var(--md-filled-text-field-disabled-supporting-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-supporting-text-opacity: var(--md-filled-text-field-disabled-supporting-text-opacity, 0.38);--_disabled-trailing-icon-color: var(--md-filled-text-field-disabled-trailing-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-trailing-icon-opacity: var(--md-filled-text-field-disabled-trailing-icon-opacity, 0.38);--_error-active-indicator-color: var(--md-filled-text-field-error-active-indicator-color, var(--md-sys-color-error, #b3261e));--_error-focus-active-indicator-color: var(--md-filled-text-field-error-focus-active-indicator-color, var(--md-sys-color-error, #b3261e));--_error-focus-caret-color: var(--md-filled-text-field-error-focus-caret-color, var(--md-sys-color-error, #b3261e));--_error-focus-input-text-color: var(--md-filled-text-field-error-focus-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_error-focus-label-text-color: var(--md-filled-text-field-error-focus-label-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-leading-icon-color: var(--md-filled-text-field-error-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-focus-supporting-text-color: var(--md-filled-text-field-error-focus-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-trailing-icon-color: var(--md-filled-text-field-error-focus-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_error-hover-active-indicator-color: var(--md-filled-text-field-error-hover-active-indicator-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-input-text-color: var(--md-filled-text-field-error-hover-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_error-hover-label-text-color: var(--md-filled-text-field-error-hover-label-text-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-leading-icon-color: var(--md-filled-text-field-error-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-hover-state-layer-color: var(--md-filled-text-field-error-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_error-hover-state-layer-opacity: var(--md-filled-text-field-error-hover-state-layer-opacity, 0.08);--_error-hover-supporting-text-color: var(--md-filled-text-field-error-hover-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-hover-trailing-icon-color: var(--md-filled-text-field-error-hover-trailing-icon-color, var(--md-sys-color-on-error-container, #410e0b));--_error-input-text-color: var(--md-filled-text-field-error-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_error-label-text-color: var(--md-filled-text-field-error-label-text-color, var(--md-sys-color-error, #b3261e));--_error-leading-icon-color: var(--md-filled-text-field-error-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-supporting-text-color: var(--md-filled-text-field-error-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-trailing-icon-color: var(--md-filled-text-field-error-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_focus-active-indicator-color: var(--md-filled-text-field-focus-active-indicator-color, var(--md-sys-color-primary, #6750a4));--_focus-active-indicator-height: var(--md-filled-text-field-focus-active-indicator-height, 2px);--_focus-input-text-color: var(--md-filled-text-field-focus-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_focus-label-text-color: var(--md-filled-text-field-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_focus-leading-icon-color: var(--md-filled-text-field-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-supporting-text-color: var(--md-filled-text-field-focus-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-trailing-icon-color: var(--md-filled-text-field-focus-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-active-indicator-color: var(--md-filled-text-field-hover-active-indicator-color, var(--md-sys-color-on-surface, #1c1b1f));--_hover-active-indicator-height: var(--md-filled-text-field-hover-active-indicator-height, 1px);--_hover-input-text-color: var(--md-filled-text-field-hover-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_hover-label-text-color: var(--md-filled-text-field-hover-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-leading-icon-color: var(--md-filled-text-field-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-state-layer-color: var(--md-filled-text-field-hover-state-layer-color, var(--md-sys-color-on-surface, #1c1b1f));--_hover-state-layer-opacity: var(--md-filled-text-field-hover-state-layer-opacity, 0.08);--_hover-supporting-text-color: var(--md-filled-text-field-hover-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-trailing-icon-color: var(--md-filled-text-field-hover-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-color: var(--md-filled-text-field-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_input-text-font: var(--md-filled-text-field-input-text-font, Roboto);--_input-text-line-height: var(--md-filled-text-field-input-text-line-height, 1.5rem);--_input-text-placeholder-color: var(--md-filled-text-field-input-text-placeholder-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-prefix-color: var(--md-filled-text-field-input-text-prefix-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-size: var(--md-filled-text-field-input-text-size, 1rem);--_input-text-suffix-color: var(--md-filled-text-field-input-text-suffix-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-tracking: var(--md-filled-text-field-input-text-tracking, 0.031rem);--_input-text-type: var(--md-filled-text-field-input-text-type, 400 1rem / 1.5rem Roboto);--_input-text-weight: var(--md-filled-text-field-input-text-weight, 400);--_label-text-color: var(--md-filled-text-field-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_label-text-font: var(--md-filled-text-field-label-text-font, Roboto);--_label-text-line-height: var(--md-filled-text-field-label-text-line-height, 1.5rem);--_label-text-populated-line-height: var(--md-filled-text-field-label-text-populated-line-height, 1rem);--_label-text-populated-size: var(--md-filled-text-field-label-text-populated-size, 0.75rem);--_label-text-size: var(--md-filled-text-field-label-text-size, 1rem);--_label-text-tracking: var(--md-filled-text-field-label-text-tracking, 0.031rem);--_label-text-type: var(--md-filled-text-field-label-text-type, 400 1rem / 1.5rem Roboto);--_label-text-weight: var(--md-filled-text-field-label-text-weight, 400);--_leading-icon-color: var(--md-filled-text-field-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_leading-icon-size: var(--md-filled-text-field-leading-icon-size, 24px);--_supporting-text-color: var(--md-filled-text-field-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_supporting-text-font: var(--md-filled-text-field-supporting-text-font, Roboto);--_supporting-text-line-height: var(--md-filled-text-field-supporting-text-line-height, 1rem);--_supporting-text-size: var(--md-filled-text-field-supporting-text-size, 0.75rem);--_supporting-text-tracking: var(--md-filled-text-field-supporting-text-tracking, 0.025rem);--_supporting-text-type: var(--md-filled-text-field-supporting-text-type, 400 0.75rem / 1rem Roboto);--_supporting-text-weight: var(--md-filled-text-field-supporting-text-weight, 400);--_trailing-icon-color: var(--md-filled-text-field-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_trailing-icon-size: var(--md-filled-text-field-trailing-icon-size, 24px);--md-filled-field-container-shape-start-start:var(--_container-shape-start-start);--md-filled-field-container-shape-start-end:var(--_container-shape-start-end);--md-filled-field-container-shape-end-end:var(--_container-shape-end-end);--md-filled-field-container-shape-end-start:var(--_container-shape-end-start);--md-filled-field-active-indicator-color:var(--_active-indicator-color);--md-filled-field-active-indicator-height:var(--_active-indicator-height);--md-filled-field-container-color:var(--_container-color);--md-filled-field-container-padding-horizontal:var(--_container-padding-horizontal);--md-filled-field-container-padding-vertical:var(--_container-padding-vertical);--md-filled-field-content-color:var(--_input-text-color);--md-filled-field-disabled-active-indicator-color:var(--_disabled-active-indicator-color);--md-filled-field-disabled-active-indicator-height:var(--_disabled-active-indicator-height);--md-filled-field-disabled-active-indicator-opacity:var(--_disabled-active-indicator-opacity);--md-filled-field-disabled-container-color:var(--_disabled-container-color);--md-filled-field-disabled-container-opacity:var(--_disabled-container-opacity);--md-filled-field-disabled-content-color:var(--_disabled-input-text-color);--md-filled-field-disabled-content-opacity:var(--_disabled-input-text-opacity);--md-filled-field-disabled-label-text-color:var(--_disabled-label-text-color);--md-filled-field-disabled-label-text-opacity:var(--_disabled-label-text-opacity);--md-filled-field-disabled-leading-icon-color:var(--_disabled-leading-icon-color);--md-filled-field-disabled-leading-icon-opacity:var(--_disabled-leading-icon-opacity);--md-filled-field-disabled-supporting-text-color:var(--_disabled-supporting-text-color);--md-filled-field-disabled-supporting-text-opacity:var(--_disabled-supporting-text-opacity);--md-filled-field-disabled-trailing-icon-color:var(--_disabled-trailing-icon-color);--md-filled-field-disabled-trailing-icon-opacity:var(--_disabled-trailing-icon-opacity);--md-filled-field-error-active-indicator-color:var(--_error-active-indicator-color);--md-filled-field-error-focus-active-indicator-color:var(--_error-focus-active-indicator-color);--md-filled-field-error-focus-content-color:var(--_error-focus-input-text-color);--md-filled-field-error-focus-label-text-color:var(--_error-focus-label-text-color);--md-filled-field-error-focus-leading-icon-color:var(--_error-focus-leading-icon-color);--md-filled-field-error-focus-supporting-text-color:var(--_error-focus-supporting-text-color);--md-filled-field-error-focus-trailing-icon-color:var(--_error-focus-trailing-icon-color);--md-filled-field-error-hover-active-indicator-color:var(--_error-hover-active-indicator-color);--md-filled-field-error-hover-content-color:var(--_error-hover-input-text-color);--md-filled-field-error-hover-label-text-color:var(--_error-hover-label-text-color);--md-filled-field-error-hover-leading-icon-color:var(--_error-hover-leading-icon-color);--md-filled-field-error-hover-state-layer-color:var(--_error-hover-state-layer-color);--md-filled-field-error-hover-state-layer-opacity:var(--_error-hover-state-layer-opacity);--md-filled-field-error-hover-supporting-text-color:var(--_error-hover-supporting-text-color);--md-filled-field-error-hover-trailing-icon-color:var(--_error-hover-trailing-icon-color);--md-filled-field-error-content-color:var(--_error-input-text-color);--md-filled-field-error-label-text-color:var(--_error-label-text-color);--md-filled-field-error-leading-icon-color:var(--_error-leading-icon-color);--md-filled-field-error-supporting-text-color:var(--_error-supporting-text-color);--md-filled-field-error-trailing-icon-color:var(--_error-trailing-icon-color);--md-filled-field-focus-active-indicator-color:var(--_focus-active-indicator-color);--md-filled-field-focus-active-indicator-height:var(--_focus-active-indicator-height);--md-filled-field-focus-content-color:var(--_focus-input-text-color);--md-filled-field-focus-label-text-color:var(--_focus-label-text-color);--md-filled-field-focus-leading-icon-color:var(--_focus-leading-icon-color);--md-filled-field-focus-supporting-text-color:var(--_focus-supporting-text-color);--md-filled-field-focus-trailing-icon-color:var(--_focus-trailing-icon-color);--md-filled-field-hover-active-indicator-color:var(--_hover-active-indicator-color);--md-filled-field-hover-active-indicator-height:var(--_hover-active-indicator-height);--md-filled-field-hover-content-color:var(--_hover-input-text-color);--md-filled-field-hover-label-text-color:var(--_hover-label-text-color);--md-filled-field-hover-leading-icon-color:var(--_hover-leading-icon-color);--md-filled-field-hover-state-layer-color:var(--_hover-state-layer-color);--md-filled-field-hover-state-layer-opacity:var(--_hover-state-layer-opacity);--md-filled-field-hover-supporting-text-color:var(--_hover-supporting-text-color);--md-filled-field-hover-trailing-icon-color:var(--_hover-trailing-icon-color);--md-filled-field-label-text-color:var(--_label-text-color);--md-filled-field-label-text-font:var(--_label-text-font);--md-filled-field-label-text-line-height:var(--_label-text-line-height);--md-filled-field-label-text-populated-line-height:var(--_label-text-populated-line-height);--md-filled-field-label-text-populated-size:var(--_label-text-populated-size);--md-filled-field-label-text-size:var(--_label-text-size);--md-filled-field-label-text-tracking:var(--_label-text-tracking);--md-filled-field-label-text-weight:var(--_label-text-weight);--md-filled-field-leading-icon-color:var(--_leading-icon-color);--md-filled-field-leading-icon-size:var(--_leading-icon-size);--md-filled-field-supporting-text-color:var(--_supporting-text-color);--md-filled-field-supporting-text-font:var(--_supporting-text-font);--md-filled-field-supporting-text-line-height:var(--_supporting-text-line-height);--md-filled-field-supporting-text-size:var(--_supporting-text-size);--md-filled-field-supporting-text-tracking:var(--_supporting-text-tracking);--md-filled-field-supporting-text-weight:var(--_supporting-text-weight);--md-filled-field-trailing-icon-color:var(--_trailing-icon-color);--md-filled-field-trailing-icon-size:var(--_trailing-icon-size);--md-filled-field-with-label-container-padding-vertical:var(--_with-label-container-padding-vertical)}/*# sourceMappingURL=filled-styles.css.map */ `; //# sourceMappingURL=filled-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/outlined-forced-colors-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/outlined-forced-colors-styles.css.js index e762ee1..fbe810d 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/outlined-forced-colors-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/outlined-forced-colors-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `@media(forced-colors: active){:host{--md-outlined-text-field-disabled-input-text-color:GrayText;--md-outlined-text-field-disabled-input-text-opacity:1;--md-outlined-text-field-disabled-label-text-color:GrayText;--md-outlined-text-field-disabled-label-text-opacity:1;--md-outlined-text-field-disabled-leading-icon-color:GrayText;--md-outlined-text-field-disabled-leading-icon-opacity:1;--md-outlined-text-field-disabled-outline-color:GrayText;--md-outlined-text-field-disabled-outline-opacity:1;--md-outlined-text-field-disabled-supporting-text-color:GrayText;--md-outlined-text-field-disabled-supporting-text-opacity:1;--md-outlined-text-field-disabled-trailing-icon-color:GrayText;--md-outlined-text-field-disabled-trailing-icon-opacity:1}}/*# sourceMappingURL=outlined-forced-colors-styles.css.map */ `; //# sourceMappingURL=outlined-forced-colors-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/outlined-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/outlined-styles.css.js index bb0df04c..16cadcd 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/outlined-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/outlined-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{--_container-shape-start-start: var(--md-outlined-text-field-container-shape-start-start, 4px);--_container-shape-start-end: var(--md-outlined-text-field-container-shape-start-end, 4px);--_container-shape-end-end: var(--md-outlined-text-field-container-shape-end-end, 4px);--_container-shape-end-start: var(--md-outlined-text-field-container-shape-end-start, 4px);--_container-padding-horizontal: var(--md-outlined-text-field-container-padding-horizontal, 16px);--_container-padding-vertical: var(--md-outlined-text-field-container-padding-vertical, 16px);--_input-text-prefix-padding: var(--md-outlined-text-field-input-text-prefix-padding, 2px);--_input-text-suffix-padding: var(--md-outlined-text-field-input-text-suffix-padding, 2px);--_outline-label-padding: var(--md-outlined-text-field-outline-label-padding, 4px);--_caret-color: var(--md-outlined-text-field-caret-color, var(--md-sys-color-primary, #6750a4));--_disabled-input-text-color: var(--md-outlined-text-field-disabled-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-input-text-opacity: var(--md-outlined-text-field-disabled-input-text-opacity, 0.38);--_disabled-label-text-color: var(--md-outlined-text-field-disabled-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-label-text-opacity: var(--md-outlined-text-field-disabled-label-text-opacity, 0.38);--_disabled-leading-icon-color: var(--md-outlined-text-field-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-leading-icon-opacity: var(--md-outlined-text-field-disabled-leading-icon-opacity, 0.38);--_disabled-outline-color: var(--md-outlined-text-field-disabled-outline-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-outline-opacity: var(--md-outlined-text-field-disabled-outline-opacity, 0.12);--_disabled-outline-width: var(--md-outlined-text-field-disabled-outline-width, 1px);--_disabled-supporting-text-color: var(--md-outlined-text-field-disabled-supporting-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-supporting-text-opacity: var(--md-outlined-text-field-disabled-supporting-text-opacity, 0.38);--_disabled-trailing-icon-color: var(--md-outlined-text-field-disabled-trailing-icon-color, var(--md-sys-color-on-surface, #1c1b1f));--_disabled-trailing-icon-opacity: var(--md-outlined-text-field-disabled-trailing-icon-opacity, 0.38);--_error-focus-caret-color: var(--md-outlined-text-field-error-focus-caret-color, var(--md-sys-color-error, #b3261e));--_error-focus-input-text-color: var(--md-outlined-text-field-error-focus-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_error-focus-label-text-color: var(--md-outlined-text-field-error-focus-label-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-leading-icon-color: var(--md-outlined-text-field-error-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-focus-outline-color: var(--md-outlined-text-field-error-focus-outline-color, var(--md-sys-color-error, #b3261e));--_error-focus-supporting-text-color: var(--md-outlined-text-field-error-focus-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-trailing-icon-color: var(--md-outlined-text-field-error-focus-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_error-hover-input-text-color: var(--md-outlined-text-field-error-hover-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_error-hover-label-text-color: var(--md-outlined-text-field-error-hover-label-text-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-leading-icon-color: var(--md-outlined-text-field-error-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-hover-outline-color: var(--md-outlined-text-field-error-hover-outline-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-supporting-text-color: var(--md-outlined-text-field-error-hover-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-hover-trailing-icon-color: var(--md-outlined-text-field-error-hover-trailing-icon-color, var(--md-sys-color-on-error-container, #410e0b));--_error-input-text-color: var(--md-outlined-text-field-error-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_error-label-text-color: var(--md-outlined-text-field-error-label-text-color, var(--md-sys-color-error, #b3261e));--_error-leading-icon-color: var(--md-outlined-text-field-error-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-outline-color: var(--md-outlined-text-field-error-outline-color, var(--md-sys-color-error, #b3261e));--_error-supporting-text-color: var(--md-outlined-text-field-error-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-trailing-icon-color: var(--md-outlined-text-field-error-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_focus-input-text-color: var(--md-outlined-text-field-focus-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_focus-label-text-color: var(--md-outlined-text-field-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_focus-leading-icon-color: var(--md-outlined-text-field-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-outline-color: var(--md-outlined-text-field-focus-outline-color, var(--md-sys-color-primary, #6750a4));--_focus-outline-width: var(--md-outlined-text-field-focus-outline-width, 2px);--_focus-supporting-text-color: var(--md-outlined-text-field-focus-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-trailing-icon-color: var(--md-outlined-text-field-focus-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-input-text-color: var(--md-outlined-text-field-hover-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_hover-label-text-color: var(--md-outlined-text-field-hover-label-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_hover-leading-icon-color: var(--md-outlined-text-field-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-outline-color: var(--md-outlined-text-field-hover-outline-color, var(--md-sys-color-on-surface, #1c1b1f));--_hover-outline-width: var(--md-outlined-text-field-hover-outline-width, 1px);--_hover-supporting-text-color: var(--md-outlined-text-field-hover-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-trailing-icon-color: var(--md-outlined-text-field-hover-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-color: var(--md-outlined-text-field-input-text-color, var(--md-sys-color-on-surface, #1c1b1f));--_input-text-font: var(--md-outlined-text-field-input-text-font, Roboto);--_input-text-line-height: var(--md-outlined-text-field-input-text-line-height, 1.5rem);--_input-text-placeholder-color: var(--md-outlined-text-field-input-text-placeholder-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-prefix-color: var(--md-outlined-text-field-input-text-prefix-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-size: var(--md-outlined-text-field-input-text-size, 1rem);--_input-text-suffix-color: var(--md-outlined-text-field-input-text-suffix-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-tracking: var(--md-outlined-text-field-input-text-tracking, 0.031rem);--_input-text-type: var(--md-outlined-text-field-input-text-type, 400 1rem / 1.5rem Roboto);--_input-text-weight: var(--md-outlined-text-field-input-text-weight, 400);--_label-text-color: var(--md-outlined-text-field-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_label-text-font: var(--md-outlined-text-field-label-text-font, Roboto);--_label-text-line-height: var(--md-outlined-text-field-label-text-line-height, 1.5rem);--_label-text-populated-line-height: var(--md-outlined-text-field-label-text-populated-line-height, 1rem);--_label-text-populated-size: var(--md-outlined-text-field-label-text-populated-size, 0.75rem);--_label-text-size: var(--md-outlined-text-field-label-text-size, 1rem);--_label-text-tracking: var(--md-outlined-text-field-label-text-tracking, 0.031rem);--_label-text-type: var(--md-outlined-text-field-label-text-type, 400 1rem / 1.5rem Roboto);--_label-text-weight: var(--md-outlined-text-field-label-text-weight, 400);--_leading-icon-color: var(--md-outlined-text-field-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_leading-icon-size: var(--md-outlined-text-field-leading-icon-size, 24px);--_outline-color: var(--md-outlined-text-field-outline-color, var(--md-sys-color-outline, #79747e));--_outline-width: var(--md-outlined-text-field-outline-width, 1px);--_supporting-text-color: var(--md-outlined-text-field-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_supporting-text-font: var(--md-outlined-text-field-supporting-text-font, Roboto);--_supporting-text-line-height: var(--md-outlined-text-field-supporting-text-line-height, 1rem);--_supporting-text-size: var(--md-outlined-text-field-supporting-text-size, 0.75rem);--_supporting-text-tracking: var(--md-outlined-text-field-supporting-text-tracking, 0.025rem);--_supporting-text-type: var(--md-outlined-text-field-supporting-text-type, 400 0.75rem / 1rem Roboto);--_supporting-text-weight: var(--md-outlined-text-field-supporting-text-weight, 400);--_trailing-icon-color: var(--md-outlined-text-field-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_trailing-icon-size: var(--md-outlined-text-field-trailing-icon-size, 24px);--md-outlined-field-container-shape-start-start:var(--_container-shape-start-start);--md-outlined-field-container-shape-start-end:var(--_container-shape-start-end);--md-outlined-field-container-shape-end-end:var(--_container-shape-end-end);--md-outlined-field-container-shape-end-start:var(--_container-shape-end-start);--md-outlined-field-container-padding-horizontal:var(--_container-padding-horizontal);--md-outlined-field-container-padding-vertical:var(--_container-padding-vertical);--md-outlined-field-disabled-content-color:var(--_disabled-input-text-color);--md-outlined-field-disabled-content-opacity:var(--_disabled-input-text-opacity);--md-outlined-field-disabled-label-text-color:var(--_disabled-label-text-color);--md-outlined-field-disabled-label-text-opacity:var(--_disabled-label-text-opacity);--md-outlined-field-disabled-leading-icon-color:var(--_disabled-leading-icon-color);--md-outlined-field-disabled-leading-icon-opacity:var(--_disabled-leading-icon-opacity);--md-outlined-field-disabled-outline-color:var(--_disabled-outline-color);--md-outlined-field-disabled-outline-opacity:var(--_disabled-outline-opacity);--md-outlined-field-disabled-outline-width:var(--_disabled-outline-width);--md-outlined-field-disabled-supporting-text-color:var(--_disabled-supporting-text-color);--md-outlined-field-disabled-supporting-text-opacity:var(--_disabled-supporting-text-opacity);--md-outlined-field-disabled-trailing-icon-color:var(--_disabled-trailing-icon-color);--md-outlined-field-disabled-trailing-icon-opacity:var(--_disabled-trailing-icon-opacity);--md-outlined-field-error-focus-content-color:var(--_error-focus-input-text-color);--md-outlined-field-error-focus-label-text-color:var(--_error-focus-label-text-color);--md-outlined-field-error-focus-leading-icon-color:var(--_error-focus-leading-icon-color);--md-outlined-field-error-focus-outline-color:var(--_error-focus-outline-color);--md-outlined-field-error-focus-supporting-text-color:var(--_error-focus-supporting-text-color);--md-outlined-field-error-focus-trailing-icon-color:var(--_error-focus-trailing-icon-color);--md-outlined-field-error-hover-content-color:var(--_error-hover-input-text-color);--md-outlined-field-error-hover-label-text-color:var(--_error-hover-label-text-color);--md-outlined-field-error-hover-leading-icon-color:var(--_error-hover-leading-icon-color);--md-outlined-field-error-hover-outline-color:var(--_error-hover-outline-color);--md-outlined-field-error-hover-supporting-text-color:var(--_error-hover-supporting-text-color);--md-outlined-field-error-hover-trailing-icon-color:var(--_error-hover-trailing-icon-color);--md-outlined-field-error-content-color:var(--_error-input-text-color);--md-outlined-field-error-label-text-color:var(--_error-label-text-color);--md-outlined-field-error-leading-icon-color:var(--_error-leading-icon-color);--md-outlined-field-error-outline-color:var(--_error-outline-color);--md-outlined-field-error-supporting-text-color:var(--_error-supporting-text-color);--md-outlined-field-error-trailing-icon-color:var(--_error-trailing-icon-color);--md-outlined-field-focus-content-color:var(--_focus-input-text-color);--md-outlined-field-focus-label-text-color:var(--_focus-label-text-color);--md-outlined-field-focus-leading-icon-color:var(--_focus-leading-icon-color);--md-outlined-field-focus-outline-color:var(--_focus-outline-color);--md-outlined-field-focus-outline-width:var(--_focus-outline-width);--md-outlined-field-focus-supporting-text-color:var(--_focus-supporting-text-color);--md-outlined-field-focus-trailing-icon-color:var(--_focus-trailing-icon-color);--md-outlined-field-hover-content-color:var(--_hover-input-text-color);--md-outlined-field-hover-label-text-color:var(--_hover-label-text-color);--md-outlined-field-hover-leading-icon-color:var(--_hover-leading-icon-color);--md-outlined-field-hover-outline-color:var(--_hover-outline-color);--md-outlined-field-hover-outline-width:var(--_hover-outline-width);--md-outlined-field-hover-supporting-text-color:var(--_hover-supporting-text-color);--md-outlined-field-hover-trailing-icon-color:var(--_hover-trailing-icon-color);--md-outlined-field-content-color:var(--_input-text-color);--md-outlined-field-label-text-color:var(--_label-text-color);--md-outlined-field-label-text-font:var(--_label-text-font);--md-outlined-field-label-text-line-height:var(--_label-text-line-height);--md-outlined-field-label-text-padding-bottom:var(--_label-text-padding-bottom);--md-outlined-field-label-text-populated-line-height:var(--_label-text-populated-line-height);--md-outlined-field-label-text-populated-size:var(--_label-text-populated-size);--md-outlined-field-label-text-size:var(--_label-text-size);--md-outlined-field-label-text-tracking:var(--_label-text-tracking);--md-outlined-field-label-text-weight:var(--_label-text-weight);--md-outlined-field-leading-icon-color:var(--_leading-icon-color);--md-outlined-field-leading-icon-size:var(--_leading-icon-size);--md-outlined-field-outline-color:var(--_outline-color);--md-outlined-field-outline-width:var(--_outline-width);--md-outlined-field-supporting-text-color:var(--_supporting-text-color);--md-outlined-field-supporting-text-font:var(--_supporting-text-font);--md-outlined-field-supporting-text-line-height:var(--_supporting-text-line-height);--md-outlined-field-supporting-text-size:var(--_supporting-text-size);--md-outlined-field-supporting-text-tracking:var(--_supporting-text-tracking);--md-outlined-field-supporting-text-weight:var(--_supporting-text-weight);--md-outlined-field-trailing-icon-color:var(--_trailing-icon-color);--md-outlined-field-trailing-icon-size:var(--_trailing-icon-size)}/*# sourceMappingURL=outlined-styles.css.map */ `; //# sourceMappingURL=outlined-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/shared-styles.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/shared-styles.css.js index 1508929..ecd4bc4 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/shared-styles.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/shared-styles.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `:host{display:inline-flex;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.md3-text-field{display:inline-flex;flex:1}.md3-text-field__field{cursor:text;flex:1}.md3-text-field--disabled .md3-text-field__field{cursor:default}.md3-text-field__counter{white-space:nowrap}.md3-text-field__icon{display:flex}.md3-text-field__icon ::slotted(*){display:flex}.md3-text-field__icon--leading{color:var(--_leading-icon-color)}.md3-text-field__icon--trailing{color:var(--_trailing-icon-color)}:hover .md3-text-field__icon--leading{color:var(--_hover-leading-icon-color)}:hover .md3-text-field__icon--trailing{color:var(--_hover-trailing-icon-color)}:focus-within .md3-text-field__icon--leading{color:var(--_focus-leading-icon-color)}:focus-within .md3-text-field__icon--trailing{color:var(--_focus-trailing-icon-color)}.md3-text-field--disabled .md3-text-field__icon--leading{color:var(--_disabled-leading-icon-color);opacity:var(--_disabled-leading-icon-opacity)}.md3-text-field--disabled .md3-text-field__icon--trailing{color:var(--_disabled-trailing-icon-color);opacity:var(--_disabled-trailing-icon-opacity)}.md3-text-field--error:not(.md3-text-field--disabled) .md3-text-field__icon--leading{color:var(--_error-leading-icon-color)}.md3-text-field--error:not(.md3-text-field--disabled) .md3-text-field__icon--trailing{color:var(--_error-trailing-icon-color)}.md3-text-field--error:not(.md3-text-field--disabled):hover .md3-text-field__icon--leading{color:var(--_error-hover-leading-icon-color)}.md3-text-field--error:not(.md3-text-field--disabled):hover .md3-text-field__icon--trailing{color:var(--_error-hover-trailing-icon-color)}.md3-text-field--error:not(.md3-text-field--disabled):focus-within .md3-text-field__icon--leading{color:var(--_error-focus-leading-icon-color)}.md3-text-field--error:not(.md3-text-field--disabled):focus-within .md3-text-field__icon--trailing{color:var(--_error-focus-trailing-icon-color)}.md3-text-field__input{appearance:none;background:none;border:none;caret-color:var(--_caret-color);color:currentColor;outline:none;padding:0;text-align:inherit;width:100%}.md3-text-field__input::placeholder{color:currentColor;opacity:1}.md3-text-field__input::-webkit-calendar-picker-indicator{display:none}@media(forced-colors: active){.md3-text-field__input{background-color:Field}}:focus-within .md3-text-field__input{caret-color:var(--_focus-caret-color)}.md3-text-field--error:focus-within .md3-text-field__input{caret-color:var(--_error-focus-caret-color)}.md3-text-field__input,.md3-text-field__prefix,.md3-text-field__suffix{font-family:var(--_input-text-font);font-size:var(--_input-text-size);font-weight:var(--_input-text-weight);letter-spacing:var(--_input-text-tracking);line-height:var(--_input-text-line-height)}.md3-text-field:not(.md3-text-field--disabled) .md3-text-field__prefix,.md3-text-field:not(.md3-text-field--disabled) .md3-text-field__suffix{color:var(--_input-text-prefix-color)}.md3-text-field:not(.md3-text-field--disabled) .md3-text-field__input::placeholder{color:var(--_input-text-placeholder-color)}.md3-text-field__prefix{padding-inline-end:var(--_input-text-prefix-padding)}.md3-text-field__suffix{padding-inline-start:var(--_input-text-suffix-padding)}/*# sourceMappingURL=shared-styles.css.map */ `; //# sourceMappingURL=shared-styles.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/text-field.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/text-field.js index f5f70321..da0e1963 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/text-field.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/lib/text-field.js
@@ -3,14 +3,14 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate, __metadata } from '../../../../tslib/tslib.js'; -import { html, LitElement } from '../../../../lit/index.js'; -import { property, query, queryAssignedElements, state } from '../../../../lit/decorators.js'; -import { classMap } from '../../../../lit/directives/class-map.js'; -import { ifDefined } from '../../../../lit/directives/if-defined.js'; -import { live } from '../../../../lit/directives/live.js'; -import { styleMap } from '../../../../lit/directives/style-map.js'; -import { html as staticHtml } from '../../../../lit/static-html.js'; +import { __decorate, __metadata } from "tslib"; +import { html, LitElement } from 'lit'; +import { property, query, queryAssignedElements, state } from 'lit/decorators.js'; +import { classMap } from 'lit/directives/class-map.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; +import { live } from 'lit/directives/live.js'; +import { styleMap } from 'lit/directives/style-map.js'; +import { html as staticHtml } from 'lit/static-html.js'; import { redispatchEvent } from '../../controller/events.js'; import { FormController, getFormValue } from '../../controller/form-controller.js'; import { stringConverter } from '../../controller/string-converter.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/outlined-text-field.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/outlined-text-field.js index 05e0fa71..123df10 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/outlined-text-field.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/textfield/outlined-text-field.js
@@ -3,10 +3,10 @@ * Copyright 2021 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { __decorate } from '../../../tslib/tslib.js'; +import { __decorate } from "tslib"; import '../field/outlined-field.js'; -import { customElement } from '../../../lit/decorators.js'; -import { literal } from '../../../lit/static-html.js'; +import { customElement } from 'lit/decorators.js'; +import { literal } from 'lit/static-html.js'; // TODO(b/236285090): update with HCM best practices import { styles as outlinedForcedColorsStyles } from './lib/outlined-forced-colors-styles.css.js'; import { styles as outlinedStyles } from './lib/outlined-styles.css.js';
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/tokens/v0_152/index.test.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/tokens/v0_152/index.test.css.js index d90b7c9..dd68e97d4 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/tokens/v0_152/index.test.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/tokens/v0_152/index.test.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `/*# sourceMappingURL=index.test.css.map */ `; //# sourceMappingURL=index.test.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/components-chromium/node_modules/@material/web/tokens/v0_152/lib.test.css.js b/third_party/material_web_components/components-chromium/node_modules/@material/web/tokens/v0_152/lib.test.css.js index 5ed7811b..09e134e 100644 --- a/third_party/material_web_components/components-chromium/node_modules/@material/web/tokens/v0_152/lib.test.css.js +++ b/third_party/material_web_components/components-chromium/node_modules/@material/web/tokens/v0_152/lib.test.css.js
@@ -3,7 +3,7 @@ * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import { css } from '../../../../lit/index.js'; +import { css } from 'lit'; export const styles = css `/*# sourceMappingURL=lib.test.css.map */ `; //# sourceMappingURL=lib.test.css.js.map \ No newline at end of file
diff --git a/third_party/material_web_components/resolve_imports.js b/third_party/material_web_components/resolve_imports.js index e9eab2cd..c4c78cd 100644 --- a/third_party/material_web_components/resolve_imports.js +++ b/third_party/material_web_components/resolve_imports.js
@@ -22,6 +22,8 @@ for (const inputFile of inputFiles) { const inputDir = path.dirname(inputFile); + if (inputDir.startsWith("components-chromium/node_modules/@material")) continue; + const data = fs.readFileSync(inputFile, {encoding: 'utf8'}) const ast = acorn.parse(data, {sourceType: 'module'});
diff --git a/tools/gritsettings/resource_ids.spec b/tools/gritsettings/resource_ids.spec index 65cb5b2..03c4a6a 100644 --- a/tools/gritsettings/resource_ids.spec +++ b/tools/gritsettings/resource_ids.spec
@@ -740,6 +740,10 @@ "META": {"sizes": {"includes": [50],}}, "includes": [3405], }, + "<(SHARED_INTERMEDIATE_DIR)/ash/webui/projector_app/resources/annotator/trusted/ash_projector_annotator_trusted_resources.grd": { + "META": {"sizes": {"includes": [50],}}, + "includes": [3410], + }, "<(SHARED_INTERMEDIATE_DIR)/ash/webui/projector_app/resources/common/ash_projector_common_resources.grd": { "META": {"sizes": {"includes": [50],}}, "includes": [3415],
diff --git a/tools/mb/mb_config.pyl b/tools/mb/mb_config.pyl index 31ab7012..b494080 100644 --- a/tools/mb/mb_config.pyl +++ b/tools/mb/mb_config.pyl
@@ -581,6 +581,7 @@ 'GPU FYI Win x64 DX12 Vulkan Builder': 'gpu_fyi_tests_dx12vk_release_trybot_reclient', 'GPU FYI Win x64 DX12 Vulkan Builder (dbg)': 'gpu_fyi_tests_dx12vk_debug_trybot_reclient', 'GPU FYI XR Win x64 Builder': 'gpu_fyi_tests_release_trybot_reclient', + 'Lacros FYI Release (octopus)': 'gpu_tests_lacros_octopus_release_trybot_dcheck_off_no_symbols_reclient', 'Linux FYI GPU TSAN Release': 'gpu_fyi_tests_release_trybot_tsan_reclient', }, @@ -2679,6 +2680,11 @@ 'gpu_tests', 'debug', 'no_symbols', 'dcheck_always_on', 'static', 'reclient' ], + 'gpu_tests_lacros_octopus_release_trybot_dcheck_off_no_symbols_reclient': [ + 'gpu_tests', 'chromeos_octopus_reclient', 'release_trybot_dcheck_off_reclient', 'no_symbols', + 'also_build_lacros_chrome_for_architecture_amd64', + ], + 'gpu_tests_ozone_linux_non_x11_release_trybot_reclient': [ 'gpu_tests', 'ozone_linux', 'ozone_linux_non_x11', 'release_trybot_minimal_symbols_reclient', ],
diff --git a/tools/mb/mb_config_expectations/chromium.gpu.fyi.json b/tools/mb/mb_config_expectations/chromium.gpu.fyi.json index 97749c72..c200344 100644 --- a/tools/mb/mb_config_expectations/chromium.gpu.fyi.json +++ b/tools/mb/mb_config_expectations/chromium.gpu.fyi.json
@@ -231,6 +231,21 @@ "use_remoteexec": true } }, + "Lacros FYI Release (octopus)": { + "args_file": "//build/args/chromeos/octopus.gni", + "gn_args": { + "also_build_lacros_chrome_for_architecture": "amd64", + "dcheck_always_on": false, + "ffmpeg_branding": "Chrome", + "is_chromeos_device": true, + "is_component_build": false, + "is_debug": false, + "ozone_platform_headless": true, + "proprietary_codecs": true, + "symbol_level": 0, + "use_remoteexec": true + } + }, "Linux FYI GPU TSAN Release": { "gn_args": { "dcheck_always_on": true,
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 0a683665..2517b10 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -86039,6 +86039,7 @@ <int value="29" label="kLacrosMainProfile"/> <int value="30" label="kProfileCreationSamlFlow"/> <int value="31" label="kDriveFsNativeMessageHostLacros"/> + <int value="32" label="kProfileDeletionProcess"/> </enum> <enum name="ProfileMenuActionableItem">
diff --git a/tools/metrics/histograms/metadata/android/histograms.xml b/tools/metrics/histograms/metadata/android/histograms.xml index 08ed691..7ed51ee 100644 --- a/tools/metrics/histograms/metadata/android/histograms.xml +++ b/tools/metrics/histograms/metadata/android/histograms.xml
@@ -231,7 +231,7 @@ </histogram> <histogram name="Android.AdaptiveToolbarButton.SettingsToggle.Changed" - enum="BooleanEnabled" expires_after="2023-07-16"> + enum="BooleanEnabled" expires_after="2023-09-24"> <owner>shaktisahu@chromium.org</owner> <owner>chrome-segmentation-platform@google.com</owner> <summary> @@ -1650,7 +1650,7 @@ </histogram> <histogram name="Android.IncognitoReauth.AuthResult" - enum="DeviceAuthFinalResult" expires_after="M115"> + enum="DeviceAuthFinalResult" expires_after="2023-09-24"> <owner>roagarwal@chromium.org</owner> <owner>chrome-incognito@google.com</owner> <summary> @@ -2025,7 +2025,7 @@ </histogram> <histogram name="Android.Messages.Stacking" enum="StackingAnimationType" - expires_after="2023-09-17"> + expires_after="2023-09-24"> <owner>lazzzis@chromium.org</owner> <owner>src/components/messages/OWNERS</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/arc/histograms.xml b/tools/metrics/histograms/metadata/arc/histograms.xml index 5114d08..1c3371d 100644 --- a/tools/metrics/histograms/metadata/arc/histograms.xml +++ b/tools/metrics/histograms/metadata/arc/histograms.xml
@@ -565,7 +565,7 @@ </histogram> <histogram name="Arc.AppSync.InitialSession.InstalledAppSize" units="MB" - expires_after="2023-07-20"> + expires_after="2023-09-24"> <owner>batoon@google.com</owner> <owner>arc-core@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/ash/histograms.xml b/tools/metrics/histograms/metadata/ash/histograms.xml index 02c27e2..cb6accf 100644 --- a/tools/metrics/histograms/metadata/ash/histograms.xml +++ b/tools/metrics/histograms/metadata/ash/histograms.xml
@@ -1439,7 +1439,7 @@ </histogram> <histogram name="Ash.CaptureModeController.NumberOfConnectedCameras" - units="connected cameras" expires_after="2023-07-23"> + units="connected cameras" expires_after="2023-09-24"> <owner>conniekxu@chromium.org</owner> <owner>gzadina@google.com</owner> <summary> @@ -1813,7 +1813,7 @@ </histogram> <histogram name="Ash.Desks.BentoBarIsVisible" enum="Boolean" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>minch@chromium.org</owner> <owner>janetmac@chromium.org</owner> <summary> @@ -2039,7 +2039,7 @@ </histogram> <histogram name="Ash.Desks.NumberOfWindowsClosed2" units="units" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>aprilzhou@google.com</owner> <owner>janetmac@chromium.org</owner> <summary> @@ -3388,7 +3388,7 @@ </histogram> <histogram name="Ash.Login.PinAutosubmit.Backfill" - enum="PinAutosubmitBackfillEvent" expires_after="2023-06-04"> + enum="PinAutosubmitBackfillEvent" expires_after="2023-09-24"> <owner>emaamari@google.com</owner> <owner>rrsilva@google.com</owner> <owner>cros-lurs@google.com</owner> @@ -4156,7 +4156,7 @@ </histogram> <histogram name="Ash.Overview.EndAction" enum="OverviewEndAction" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>minch@chromium.org</owner> <owner>janetmac@chromium.org</owner> <summary> @@ -4229,7 +4229,7 @@ </histogram> <histogram name="Ash.Overview.StartAction" enum="OverviewStartAction" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>minch@chromium.org</owner> <owner>janetmac@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/assistant/histograms.xml b/tools/metrics/histograms/metadata/assistant/histograms.xml index 7377e555..617f8d5 100644 --- a/tools/metrics/histograms/metadata/assistant/histograms.xml +++ b/tools/metrics/histograms/metadata/assistant/histograms.xml
@@ -53,7 +53,7 @@ </histogram> <histogram name="Assistant.ContextEnabledUserCount" enum="BooleanEnabled" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>updowndota@chromium.org</owner> <owner>xiaohuic@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/autofill/histograms.xml b/tools/metrics/histograms/metadata/autofill/histograms.xml index 01a3722f..3bec88f 100644 --- a/tools/metrics/histograms/metadata/autofill/histograms.xml +++ b/tools/metrics/histograms/metadata/autofill/histograms.xml
@@ -662,7 +662,7 @@ </histogram> <histogram name="Autofill.BetterAuth.CardUnmaskDuration.Fido" units="ms" - expires_after="2023-09-17"> + expires_after="2023-09-24"> <owner>jsaul@google.com</owner> <owner>siyua@chromium.org</owner> <owner>autofill-auth-team@google.com</owner> @@ -4492,7 +4492,7 @@ </histogram> <histogram name="Autofill.UnmaskPrompt.GetRealPanDuration" units="ms" - expires_after="2023-09-17"> + expires_after="2023-09-24"> <owner>jsaul@google.com</owner> <owner>siyua@chromium.org</owner> <summary> @@ -4840,7 +4840,7 @@ <histogram name="Autofill.VirtualCardEnroll.CardArtImageAvailable.{EnrollmentSource}" - enum="BooleanAvailable" expires_after="2023-04-01"> + enum="BooleanAvailable" expires_after="2024-04-01"> <owner>alexandertekle@google.com</owner> <owner>payments-autofill-team@google.com</owner> <summary> @@ -4854,7 +4854,7 @@ <histogram name="Autofill.VirtualCardEnroll.LinkClicked.{EnrollmentSource}.{LinkType}" - enum="BooleanClicked" expires_after="2023-04-01"> + enum="BooleanClicked" expires_after="2024-04-01"> <owner>alexandertekle@google.com</owner> <owner>payments-autofill-team@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/blink/histograms.xml b/tools/metrics/histograms/metadata/blink/histograms.xml index dffffc72..3df641e 100644 --- a/tools/metrics/histograms/metadata/blink/histograms.xml +++ b/tools/metrics/histograms/metadata/blink/histograms.xml
@@ -1043,7 +1043,7 @@ </histogram> <histogram name="Blink.FedCm.CancelReason" enum="FedCmCancelReason" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>pkotwicz@chromium.org</owner> <owner>web-identity-eng@google.com</owner> <summary> @@ -1824,7 +1824,7 @@ </histogram> <histogram name="Blink.HTMLParsing.YieldedTimeAverage4" units="microseconds" - expires_after="2023-06-30"> + expires_after="2023-09-24"> <owner>masonf@chromium.org</owner> <owner>dom-dev@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/bluetooth/histograms.xml b/tools/metrics/histograms/metadata/bluetooth/histograms.xml index be1594ce..0eb6722 100644 --- a/tools/metrics/histograms/metadata/bluetooth/histograms.xml +++ b/tools/metrics/histograms/metadata/bluetooth/histograms.xml
@@ -360,7 +360,7 @@ <histogram name="Bluetooth.ChromeOS.FastPair.DeviceMetadataFetcher.Get.HttpResponseError" - enum="HttpResponseCode" expires_after="2023-07-02"> + enum="HttpResponseCode" expires_after="2023-09-24"> <owner>jackshira@google.com</owner> <owner>dclasson@google.com</owner> <owner>brandosocarras@google.com</owner> @@ -1670,7 +1670,7 @@ </histogram> <histogram name="Bluetooth.ChromeOS.PoweredState" enum="BooleanEnabled" - expires_after="2023-09-17"> + expires_after="2023-09-24"> <owner>khorimoto@chromium.org</owner> <owner>cros-connectivity@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/bookmarks/histograms.xml b/tools/metrics/histograms/metadata/bookmarks/histograms.xml index 1a6d3e58..8e3d6fe6 100644 --- a/tools/metrics/histograms/metadata/bookmarks/histograms.xml +++ b/tools/metrics/histograms/metadata/bookmarks/histograms.xml
@@ -1007,7 +1007,7 @@ </histogram> <histogram name="Bookmarks.Utilization.OnProfileLoad.PercentageUsed" - units="Percentage (0-100)" expires_after="2023-07-09"> + units="Percentage (0-100)" expires_after="2023-09-24"> <owner>wylieb@chromium.org</owner> <owner>chrome-collections@google.com</owner> <component>UI>Browser>Bookmarks</component>
diff --git a/tools/metrics/histograms/metadata/chromeos/histograms.xml b/tools/metrics/histograms/metadata/chromeos/histograms.xml index dbe7ce6..3135e140 100644 --- a/tools/metrics/histograms/metadata/chromeos/histograms.xml +++ b/tools/metrics/histograms/metadata/chromeos/histograms.xml
@@ -1628,7 +1628,7 @@ </histogram> <histogram name="ChromeOS.Intents.LinkCapturingEvent2" - enum="LinkCapturingEvent" expires_after="2023-07-23"> + enum="LinkCapturingEvent" expires_after="2023-09-24"> <owner>vpao@google.com</owner> <owner>chromeos-apps-foundation-team@google.com</owner> <summary> @@ -1692,7 +1692,7 @@ </histogram> <histogram name="ChromeOS.KeyPermissionsManager.Migration" - enum="KeyPermissionsManagerMigrationStatus" expires_after="2023-07-23"> + enum="KeyPermissionsManagerMigrationStatus" expires_after="2023-09-24"> <owner>omorsi@google.com</owner> <owner>pmarko@google.com</owner> <summary> @@ -2263,7 +2263,7 @@ </histogram> <histogram name="ChromeOS.Secagentd.Policy" enum="SecagentdPolicy" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>aashay@google.com</owner> <owner>cros-enterprise-security@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/compositing/histograms.xml b/tools/metrics/histograms/metadata/compositing/histograms.xml index 2f91726..5854cbe1 100644 --- a/tools/metrics/histograms/metadata/compositing/histograms.xml +++ b/tools/metrics/histograms/metadata/compositing/histograms.xml
@@ -1134,7 +1134,7 @@ </summary> </histogram> -<histogram name="Graphics.Smoothness.Jank" units="%" expires_after="2023-09-17"> +<histogram name="Graphics.Smoothness.Jank" units="%" expires_after="2023-09-24"> <owner>jonross@chromium.org</owner> <owner>mjzhang@chromium.org</owner> <owner>graphics-dev@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/content/histograms.xml b/tools/metrics/histograms/metadata/content/histograms.xml index 2b3f2b4..72c9724 100644 --- a/tools/metrics/histograms/metadata/content/histograms.xml +++ b/tools/metrics/histograms/metadata/content/histograms.xml
@@ -1117,7 +1117,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.Network.ResponseSizeKB" units="KB" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>carlosk@chromium.org</owner> <owner>harringtond@chromium.org</owner> <owner>feed@chromium.org</owner> @@ -1226,7 +1226,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.RefreshTrigger" - enum="FeedRefreshTrigger" expires_after="2023-07-23"> + enum="FeedRefreshTrigger" expires_after="2023-09-24"> <owner>edchin@google.com</owner> <owner>sczs@chromium.org</owner> <owner>feed@chromium.org</owner> @@ -1332,7 +1332,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.SessionDuration" units="ms" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>edchin@google.com</owner> <owner>sczs@chromium.org</owner> <owner>feed@chromium.org</owner> @@ -1382,7 +1382,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.TimeBetweenInteractions" units="ms" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>edchin@google.com</owner> <owner>sczs@chromium.org</owner> <owner>feed@chromium.org</owner> @@ -1392,7 +1392,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.TimeBetweenSessions" units="ms" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>edchin@google.com</owner> <owner>sczs@chromium.org</owner> <owner>feed@chromium.org</owner> @@ -1404,7 +1404,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.TimeSpentInFeed" units="ms" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>carlosk@chromium.org</owner> <owner>harringtond@chromium.org</owner> <owner>feed@chromium.org</owner> @@ -1490,7 +1490,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.UploadActionsStatus" - enum="FeedUploadActionsStatus" expires_after="2023-07-23"> + enum="FeedUploadActionsStatus" expires_after="2023-09-24"> <owner>iwells@chromium.org</owner> <owner>harringtond@chromium.org</owner> <owner>feed@chromium.org</owner> @@ -1524,7 +1524,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.UserActions" enum="FeedUserActionType" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>harringtond@chromium.org</owner> <owner>carlosk@chromium.org</owner> <owner>feed@chromium.org</owner> @@ -1535,7 +1535,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.UserActions.Commands" - enum="FeedUserCommandType" expires_after="2023-07-23"> + enum="FeedUserCommandType" expires_after="2023-09-24"> <owner>harringtond@chromium.org</owner> <owner>sczs@chromium.org</owner> <owner>feed@chromium.org</owner> @@ -1547,7 +1547,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.UserJourney.GetMore.FailureDuration" - units="ms" expires_after="2023-07-23"> + units="ms" expires_after="2023-09-24"> <owner>harringtond@chromium.org</owner> <owner>carlosk@chromium.org</owner> <owner>feed@chromium.org</owner> @@ -1558,7 +1558,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.UserJourney.GetMore.SuccessDuration" - units="ms" expires_after="2023-07-23"> + units="ms" expires_after="2023-09-24"> <owner>harringtond@chromium.org</owner> <owner>carlosk@chromium.org</owner> <owner>feed@chromium.org</owner> @@ -1624,7 +1624,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.UserSettingsOnStart" - enum="FeedUserSettingsOnStart" expires_after="2023-07-23"> + enum="FeedUserSettingsOnStart" expires_after="2023-09-24"> <owner>carlosk@chromium.org</owner> <owner>harringtond@chromium.org</owner> <owner>feed@chromium.org</owner> @@ -1636,7 +1636,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.ViewedCardCountAtManualRefresh" - units="count" expires_after="2023-07-23"> + units="count" expires_after="2023-09-24"> <owner>jianli@chromium.org</owner> <owner>feed@chromium.org</owner> <summary> @@ -1648,7 +1648,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.ViewedCardPercentageAtManualRefresh" - units="%" expires_after="2023-07-23"> + units="%" expires_after="2023-09-24"> <owner>jianli@chromium.org</owner> <owner>feed@chromium.org</owner> <summary> @@ -1671,7 +1671,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.VisitDuration" units="ms" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>harringtond@chromium.org</owner> <owner>freedjm@chromium.org</owner> <owner>feed@chromium.org</owner> @@ -1699,7 +1699,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.WebFeed.FollowCount.Engaged" - units="follows" expires_after="2023-07-23"> + units="follows" expires_after="2023-09-24"> <owner>harringtond@chromium.org</owner> <owner>feed@chromium.org</owner> <summary> @@ -1733,7 +1733,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.WebFeed.FollowUriResult" - enum="WebFeedSubscriptionRequestStatus" expires_after="2023-07-23"> + enum="WebFeedSubscriptionRequestStatus" expires_after="2023-09-24"> <owner>harringtond@chromium.org</owner> <owner>feed@chromium.org</owner> <summary> @@ -1775,7 +1775,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.WebFeed.NewFollow.ChangeReason" - enum="WebFeedChangeReason" expires_after="2023-07-23"> + enum="WebFeedChangeReason" expires_after="2023-09-24"> <owner>harringtond@chromium.org</owner> <owner>feed@chromium.org</owner> <summary> @@ -1788,7 +1788,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.WebFeed.NewFollow.IsRecommended" - enum="Boolean" expires_after="2023-07-23"> + enum="Boolean" expires_after="2023-09-24"> <owner>harringtond@chromium.org</owner> <owner>feed@chromium.org</owner> <summary> @@ -1877,7 +1877,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.WebFeed.SortTypeWhenEngaged" - enum="FeedSortType" expires_after="2023-07-23"> + enum="FeedSortType" expires_after="2023-09-24"> <owner>adamta@google.com</owner> <owner>sczs@chromium.org</owner> <owner>feed@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/cross_device/histograms.xml b/tools/metrics/histograms/metadata/cross_device/histograms.xml index c99c553..2b04749a 100644 --- a/tools/metrics/histograms/metadata/cross_device/histograms.xml +++ b/tools/metrics/histograms/metadata/cross_device/histograms.xml
@@ -1380,7 +1380,7 @@ </histogram> <histogram name="InstantTethering.FeatureState" - enum="InstantTethering_FeatureState" expires_after="2023-06-01"> + enum="InstantTethering_FeatureState" expires_after="2023-09-24"> <owner>hansberry@chromium.org</owner> <owner>chromeos-cross-device-eng@google.com</owner> <summary> @@ -1396,7 +1396,7 @@ </histogram> <histogram name="InstantTethering.HostScanBatchDuration" units="ms" - expires_after="2023-06-01"> + expires_after="2023-09-24"> <owner>hansberry@chromium.org</owner> <owner>chromeos-cross-device-eng@google.com</owner> <summary> @@ -1463,7 +1463,7 @@ <histogram name="InstantTethering.NotificationInteractionType" enum="InstantTethering_NotificationInteractionType" - expires_after="2023-06-01"> + expires_after="2023-09-24"> <owner>hansberry@chromium.org</owner> <owner>chromeos-cross-device-eng@google.com</owner> <summary> @@ -1549,7 +1549,7 @@ </histogram> <histogram name="InstantTethering.UserPreference.OnStartup" - enum="BooleanEnabled" expires_after="2023-06-01"> + enum="BooleanEnabled" expires_after="2023-09-24"> <owner>hansberry@chromium.org</owner> <owner>chromeos-cross-device-eng@google.com</owner> <summary> @@ -1560,7 +1560,7 @@ </histogram> <histogram name="InstantTethering.UserPreference.OnToggle" - enum="BooleanEnabled" expires_after="2023-06-01"> + enum="BooleanEnabled" expires_after="2023-09-24"> <owner>hansberry@chromium.org</owner> <owner>chromeos-cross-device-eng@google.com</owner> <summary> @@ -1756,7 +1756,7 @@ <histogram name="MultiDevice.SecureChannel.BLE.Performance.StartScanToConnectionDuration.Background" - units="ms" expires_after="2023-06-01"> + units="ms" expires_after="2023-09-24"> <owner>hansberry@google.com</owner> <owner>chromeos-cross-device-eng@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/download/histograms.xml b/tools/metrics/histograms/metadata/download/histograms.xml index 25c0112..4dfae91 100644 --- a/tools/metrics/histograms/metadata/download/histograms.xml +++ b/tools/metrics/histograms/metadata/download/histograms.xml
@@ -1448,7 +1448,7 @@ </histogram> <histogram name="Download.WarningData.AddWarningActionEventOutcome" - enum="DownloadAddWarningActionEventOutcome" expires_after="2023-07-23"> + enum="DownloadAddWarningActionEventOutcome" expires_after="2023-09-24"> <owner>xinghuilu@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/fastpair/histograms.xml b/tools/metrics/histograms/metadata/fastpair/histograms.xml index 24a97275f..472dfb9 100644 --- a/tools/metrics/histograms/metadata/fastpair/histograms.xml +++ b/tools/metrics/histograms/metadata/fastpair/histograms.xml
@@ -88,7 +88,7 @@ </histogram> <histogram name="FastPair.InitialPairing" - enum="FastPairInitialSuccessFunnelEvent" expires_after="2023-08-08"> + enum="FastPairInitialSuccessFunnelEvent" expires_after="2023-09-24"> <owner>jackshira@google.com</owner> <owner>dclasson@google.com</owner> <owner>brandosocarras@google.com</owner>
diff --git a/tools/metrics/histograms/metadata/feature_engagement/histograms.xml b/tools/metrics/histograms/metadata/feature_engagement/histograms.xml index 1d73f51..fa0df46 100644 --- a/tools/metrics/histograms/metadata/feature_engagement/histograms.xml +++ b/tools/metrics/histograms/metadata/feature_engagement/histograms.xml
@@ -538,7 +538,7 @@ </histogram> <histogram name="Tutorial.TabGroup.EditedTitle" enum="BooleanSuccess" - expires_after="2023-07-09"> + expires_after="2023-09-24"> <owner>dpenning@chromium.org</owner> <owner>dfried@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/gpu/histograms.xml b/tools/metrics/histograms/metadata/gpu/histograms.xml index 33ea9ae..e08db916 100644 --- a/tools/metrics/histograms/metadata/gpu/histograms.xml +++ b/tools/metrics/histograms/metadata/gpu/histograms.xml
@@ -461,7 +461,7 @@ </histogram> <histogram name="GPU.D3DShaderModel" enum="ShaderModel" - expires_after="2023-07-09"> + expires_after="2023-09-24"> <owner>jonahr@google.com</owner> <owner>angle-team@google.com</owner> <summary> @@ -483,7 +483,7 @@ </histogram> <histogram name="GPU.DirectComposition.CompositionMode2.VideoOrCanvas" - enum="DxgiFramePresentationMode" expires_after="2023-07-23"> + enum="DxgiFramePresentationMode" expires_after="2023-09-24"> <owner>sunnyps@chromium.org</owner> <owner>graphics-dev@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/history/histograms.xml b/tools/metrics/histograms/metadata/history/histograms.xml index d852ad987..73ca25cb 100644 --- a/tools/metrics/histograms/metadata/history/histograms.xml +++ b/tools/metrics/histograms/metadata/history/histograms.xml
@@ -1994,7 +1994,7 @@ </histogram> <histogram name="History.DomainCount28Day_V3" units="domains" - expires_after="2023-07-02"> + expires_after="2023-09-24"> <owner>mpearson@chromium.org</owner> <owner>mjzhang@chromium.org</owner> <owner>chrome-analysis-team@google.com</owner>
diff --git a/tools/metrics/histograms/metadata/input/histograms.xml b/tools/metrics/histograms/metadata/input/histograms.xml index 0a25f3fa..efdc543 100644 --- a/tools/metrics/histograms/metadata/input/histograms.xml +++ b/tools/metrics/histograms/metadata/input/histograms.xml
@@ -115,7 +115,7 @@ <histogram name="InputMethod.Assistive.AutocorrectV2.Distance.OriginalLengthVsLevenshteinDistance.{Keyboard}{Interaction}" - units="Distance" expires_after="2023-05-01"> + units="Distance" expires_after="2023-08-01"> <owner>zacpartridge@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -139,7 +139,7 @@ <histogram name="InputMethod.Assistive.AutocorrectV2.Distance.SuggestedLength.{Keyboard}{Interaction}" - units="chars" expires_after="2023-05-01"> + units="chars" expires_after="2023-08-01"> <owner>zacpartridge@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -176,7 +176,7 @@ <histogram name="InputMethod.Assistive.AutocorrectV2.Internal.PkState.EnabledByDefault" - enum="IMEAutocorrectActions" expires_after="2023-03-19"> + enum="IMEAutocorrectActions" expires_after="2023-08-01"> <owner>zacpartridge@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -194,7 +194,7 @@ </histogram> <histogram name="InputMethod.Assistive.AutocorrectV2.Internal.VkState" - enum="IMEAutocorrectInternalStates" expires_after="2023-05-01"> + enum="IMEAutocorrectInternalStates" expires_after="2023-08-01"> <owner>mehrab@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -224,7 +224,7 @@ <histogram name="InputMethod.Assistive.AutocorrectV2.Latency.Accept.EnabledByDefault" - units="ms" expires_after="2023-03-26"> + units="ms" expires_after="2023-08-01"> <owner>zacpartridge@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -235,7 +235,7 @@ </histogram> <histogram name="InputMethod.Assistive.AutocorrectV2.Latency.ExitField" - units="ms" expires_after="2023-05-01"> + units="ms" expires_after="2023-08-01"> <owner>mehrab@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -247,7 +247,7 @@ <histogram name="InputMethod.Assistive.AutocorrectV2.Latency.ExitField.EnabledByDefault" - units="ms" expires_after="2023-05-01"> + units="ms" expires_after="2023-08-01"> <owner>zacpartridge@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -258,7 +258,7 @@ </histogram> <histogram name="InputMethod.Assistive.AutocorrectV2.Latency.PkPending" - units="ms" expires_after="2023-05-01"> + units="ms" expires_after="2023-08-01"> <owner>mehrab@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -271,7 +271,7 @@ </histogram> <histogram name="InputMethod.Assistive.AutocorrectV2.Latency.Reject" units="ms" - expires_after="2023-05-01"> + expires_after="2023-08-01"> <owner>mehrab@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -283,7 +283,7 @@ <histogram name="InputMethod.Assistive.AutocorrectV2.Latency.Reject.EnabledByDefault" - units="ms" expires_after="2023-05-01"> + units="ms" expires_after="2023-08-01"> <owner>mehrab@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -295,7 +295,7 @@ </histogram> <histogram name="InputMethod.Assistive.AutocorrectV2.Latency.VkPending" - units="ms" expires_after="2023-05-01"> + units="ms" expires_after="2023-08-01"> <owner>mehrab@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -309,7 +309,7 @@ <histogram name="InputMethod.Assistive.AutocorrectV2.PkUserPreference.{Language}" - enum="IMEAutocorrectPreference" expires_after="2023-05-01"> + enum="IMEAutocorrectPreference" expires_after="2023-08-01"> <owner>mehrab@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -342,7 +342,7 @@ <histogram name="InputMethod.Assistive.AutocorrectV2.Quality.PkAccepted.EnabledByDefault" - enum="IMEAutocorrectQualityBreakdown" expires_after="2023-05-01"> + enum="IMEAutocorrectQualityBreakdown" expires_after="2023-08-01"> <owner>mehrab@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -356,7 +356,7 @@ </histogram> <histogram name="InputMethod.Assistive.AutocorrectV2.Quality.PkRejected" - enum="IMEAutocorrectQualityBreakdown" expires_after="2023-05-01"> + enum="IMEAutocorrectQualityBreakdown" expires_after="2023-08-01"> <owner>mehrab@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -371,7 +371,7 @@ <histogram name="InputMethod.Assistive.AutocorrectV2.Quality.PkRejected.EnabledByDefault" - enum="IMEAutocorrectQualityBreakdown" expires_after="2023-05-01"> + enum="IMEAutocorrectQualityBreakdown" expires_after="2023-08-01"> <owner>mehrab@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -385,7 +385,7 @@ </histogram> <histogram name="InputMethod.Assistive.AutocorrectV2.Quality.VkAccepted" - enum="IMEAutocorrectQualityBreakdown" expires_after="2023-05-01"> + enum="IMEAutocorrectQualityBreakdown" expires_after="2023-08-01"> <owner>mehrab@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -399,7 +399,7 @@ </histogram> <histogram name="InputMethod.Assistive.AutocorrectV2.Quality.VkRejected" - enum="IMEAutocorrectQualityBreakdown" expires_after="2023-05-01"> + enum="IMEAutocorrectQualityBreakdown" expires_after="2023-08-01"> <owner>mehrab@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -413,7 +413,7 @@ </histogram> <histogram name="InputMethod.Assistive.AutocorrectV2.Rejection.{Keyboard}" - enum="IMEAutocorrectRejectionBreakdown" expires_after="2023-05-01"> + enum="IMEAutocorrectRejectionBreakdown" expires_after="2023-08-01"> <owner>zacpartridge@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -428,7 +428,7 @@ </histogram> <histogram name="InputMethod.Assistive.AutocorrectV2.SuggestionProvider.Pk" - enum="IMEAutocorrectSuggestionProvider" expires_after="2023-06-01"> + enum="IMEAutocorrectSuggestionProvider" expires_after="2023-08-01"> <owner>curtismcmullan@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -452,7 +452,7 @@ <histogram name="InputMethod.Assistive.AutocorrectV2.UserPrefChange.{Language}.{Type}" - enum="IMEAutocorrectPrefStateTransition" expires_after="2023-06-01"> + enum="IMEAutocorrectPrefStateTransition" expires_after="2023-08-01"> <owner>curtismcmullan@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -472,7 +472,7 @@ <histogram name="InputMethod.Assistive.AutocorrectV2.UserPrefChange.{Type}.{Language}" - enum="IMEAutocorrectPrefStateTransition" expires_after="2023-06-01"> + enum="IMEAutocorrectPrefStateTransition" expires_after="2023-08-01"> <owner>curtismcmullan@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -493,7 +493,7 @@ </histogram> <histogram name="InputMethod.Assistive.CandidateGenerationTime.MultiWord" - units="ms" expires_after="2023-05-01"> + units="ms" expires_after="2023-08-01"> <owner>curtismcmullan@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -526,7 +526,7 @@ </histogram> <histogram name="InputMethod.Assistive.Disabled.Emoji" - enum="IMEAssistiveDisabledReason" expires_after="2023-05-01"> + enum="IMEAssistiveDisabledReason" expires_after="2023-08-01"> <owner>myy@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -538,7 +538,7 @@ </histogram> <histogram name="InputMethod.Assistive.Disabled.MultiWord" - enum="IMEAssistiveDisabledReason" expires_after="2023-05-01"> + enum="IMEAssistiveDisabledReason" expires_after="2023-08-01"> <owner>curtismcmullan@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -658,7 +658,7 @@ </histogram> <histogram name="InputMethod.Assistive.MultiWord.ImplicitAcceptance" - enum="IMEAssistiveMultiWordSuggestionType" expires_after="2023-07-30"> + enum="IMEAssistiveMultiWordSuggestionType" expires_after="2023-08-01"> <owner>curtismcmullan@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -763,7 +763,7 @@ </histogram> <histogram name="InputMethod.Assistive.TimeToAccept.MultiWord" units="ms" - expires_after="2023-05-01"> + expires_after="2023-08-01"> <owner>curtismcmullan@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -787,7 +787,7 @@ </histogram> <histogram name="InputMethod.Assistive.TimeToDismiss.MultiWord" units="ms" - expires_after="2023-05-01"> + expires_after="2023-08-01"> <owner>curtismcmullan@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary> @@ -809,7 +809,7 @@ </histogram> <histogram name="InputMethod.Assistive.UserPref.MultiWord" - enum="BooleanEnabled" expires_after="2023-05-01"> + enum="BooleanEnabled" expires_after="2023-08-01"> <owner>curtismcmullan@google.com</owner> <owner>essential-inputs-team@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/ios/histograms.xml b/tools/metrics/histograms/metadata/ios/histograms.xml index 637e4dd9..40c79f93 100644 --- a/tools/metrics/histograms/metadata/ios/histograms.xml +++ b/tools/metrics/histograms/metadata/ios/histograms.xml
@@ -201,7 +201,7 @@ </histogram> <histogram name="IOS.ContentExtension.DisplayCount" units="count" - expires_after="2023-07-16"> + expires_after="2023-09-24"> <owner>olivierrobin@chromium.org</owner> <owner>rkgibson@chromium.org</owner> <summary> @@ -427,7 +427,7 @@ <histogram name="IOS.CredentialExtension.Service.Error.ReplaceCredentialIdentitiesWithIdentities" enum="iOSCredentialIdentityStoreErrorForReporting" - expires_after="2023-06-11"> + expires_after="2023-09-24"> <owner>rkgibson@chromium.org</owner> <owner>djean@chromium.org</owner> <summary> @@ -969,7 +969,7 @@ </histogram> <histogram name="IOS.Fullscreen.State" enum="CrFullscreenState" - expires_after="2023-06-18"> + expires_after="2023-09-24"> <owner>joemerramos@chromium.org</owner> <owner>ajuma@chromium.org</owner> <summary> @@ -1640,7 +1640,7 @@ </histogram> <histogram name="IOS.PasswordsInOtherApps.Open" - enum="PasswordAutoFillEnrollmentStatus" expires_after="2023-07-16"> + enum="PasswordAutoFillEnrollmentStatus" expires_after="2023-09-24"> <owner>ginnyhuang@chromium.org</owner> <owner>bling-team@google.com</owner> <summary> @@ -1945,14 +1945,14 @@ </histogram> <histogram name="IOS.SearchExtension.Action" enum="IOSSearchExtensionAction" - expires_after="2023-05-14"> + expires_after="2023-09-24"> <owner>olivierrobin@chromium.org</owner> <owner>rkgibson@chromium.org</owner> <summary>The action selected by the user in the Search Extension.</summary> </histogram> <histogram name="IOS.SearchExtension.DisplayCount" units="count" - expires_after="2023-07-16"> + expires_after="2023-09-24"> <owner>olivierrobin@chromium.org</owner> <owner>rkgibson@chromium.org</owner> <summary> @@ -2251,7 +2251,7 @@ </histogram> <histogram name="IOS.TabSwitcher.PageChangeInteraction" - enum="IOSTabSwitcherPageChangeInteraction" expires_after="2023-07-16"> + enum="IOSTabSwitcherPageChangeInteraction" expires_after="2023-09-24"> <owner>marq@chromium.org</owner> <owner>ewannpv@chromium.org</owner> <owner>bling-team@google.com</owner> @@ -2440,7 +2440,7 @@ </histogram> <histogram name="IOS.WhatsNew.TableViewDidScroll" enum="Boolean" - expires_after="2023-07-16"> + expires_after="2023-09-24"> <owner>cheickcisse@google.com</owner> <owner>sebsg@google.com</owner> <summary> @@ -2448,7 +2448,7 @@ </summary> </histogram> -<histogram name="IOS.WhatsNew.TimeSpent" units="ms" expires_after="2023-07-16"> +<histogram name="IOS.WhatsNew.TimeSpent" units="ms" expires_after="2023-09-24"> <owner>cheickcisse@google.com</owner> <owner>sebsg@google.com</owner> <summary>Logs the time a user spent on What's New.</summary> @@ -2509,7 +2509,7 @@ </histogram> <histogram name="ManualFallback.PresentedOptions.AllPasswords" - units="Credentials" expires_after="2023-07-16"> + units="Credentials" expires_after="2023-09-24"> <owner>tmartino@chromium.org</owner> <owner>djean@chromium.org</owner> <summary> @@ -2520,7 +2520,7 @@ </histogram> <histogram name="ManualFallback.PresentedOptions.CreditCards" units="Cards" - expires_after="2023-07-16"> + expires_after="2023-09-24"> <owner>tmartino@chromium.org</owner> <owner>djean@chromium.org</owner> <summary> @@ -2530,7 +2530,7 @@ </histogram> <histogram name="ManualFallback.PresentedOptions.Passwords" units="Credentials" - expires_after="2023-07-16"> + expires_after="2023-09-24"> <owner>tmartino@chromium.org</owner> <owner>djean@chromium.org</owner> <summary> @@ -2551,7 +2551,7 @@ </histogram> <histogram name="ManualFallback.VisibleSuggestions.OpenCreditCards" - units="Suggestions" expires_after="2023-07-16"> + units="Suggestions" expires_after="2023-09-24"> <owner>tmartino@chromium.org</owner> <owner>djean@chromium.org</owner> <summary> @@ -2561,7 +2561,7 @@ </histogram> <histogram name="ManualFallback.VisibleSuggestions.OpenPasswords" - units="Suggestions" expires_after="2023-07-16"> + units="Suggestions" expires_after="2023-09-24"> <owner>tmartino@chromium.org</owner> <owner>djean@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/media/histograms.xml b/tools/metrics/histograms/metadata/media/histograms.xml index 63dca2e..59e4ed9 100644 --- a/tools/metrics/histograms/metadata/media/histograms.xml +++ b/tools/metrics/histograms/metadata/media/histograms.xml
@@ -1301,7 +1301,7 @@ </histogram> <histogram name="Media.AudioCodecProfile.AAC" enum="AudioCodecProfile" - expires_after="2023-07-01"> + expires_after="2023-09-24"> <owner>dalecurtis@chromium.org</owner> <owner>media-dev@chromium.org</owner> <summary>Audio codec profile used in HTML5 media for AAC playback.</summary> @@ -2987,7 +2987,7 @@ </histogram> <histogram name="Media.GlobalMediaControls.RepeatUsage" enum="BooleanIsRepeat" - expires_after="2023-07-09"> + expires_after="2023-09-24"> <owner>steimel@chromium.org</owner> <owner>media-dev@chromium.org</owner> <summary> @@ -5039,7 +5039,7 @@ </histogram> <histogram name="Media.Video.Capture.Mac.CameraSystemPermission.Startup" - enum="SystemMediaCapturePermission" expires_after="2023-07-23"> + enum="SystemMediaCapturePermission" expires_after="2023-09-24"> <owner>toprice@chromium.org</owner> <owner>video-cmi-apis@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/memory/histograms.xml b/tools/metrics/histograms/metadata/memory/histograms.xml index aeb8adc..4ee2e117 100644 --- a/tools/metrics/histograms/metadata/memory/histograms.xml +++ b/tools/metrics/histograms/metadata/memory/histograms.xml
@@ -2357,7 +2357,7 @@ </histogram> <histogram name="Memory.RenderProcessHost.Count.OriginAgentClusterOverhead" - units="processes" expires_after="2023-07-23"> + units="processes" expires_after="2023-09-24"> <owner>wjmaclean@chromium.org</owner> <owner>alexmos@chromium.org</owner> <owner>creis@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/mobile/histograms.xml b/tools/metrics/histograms/metadata/mobile/histograms.xml index 96ae71a..53076b1 100644 --- a/tools/metrics/histograms/metadata/mobile/histograms.xml +++ b/tools/metrics/histograms/metadata/mobile/histograms.xml
@@ -1172,7 +1172,7 @@ </histogram> <histogram name="MobileSignInPromo.NTPFeedTop.ImpressionsTilXButton" - units="impressions" expires_after="2023-06-01"> + units="impressions" expires_after="2023-09-24"> <owner>mrefaat@chromium.org</owner> <owner>jlebel@chromium.org</owner> <owner>chrome-signin-team@google.com</owner>
diff --git a/tools/metrics/histograms/metadata/navigation/histograms.xml b/tools/metrics/histograms/metadata/navigation/histograms.xml index 8cad16d1..8989421 100644 --- a/tools/metrics/histograms/metadata/navigation/histograms.xml +++ b/tools/metrics/histograms/metadata/navigation/histograms.xml
@@ -1611,7 +1611,7 @@ </histogram> <histogram name="Prerender.Experimental.BookmarkUrlButtonEvent" - enum="PreloadBookmarkMetricsEvent" expires_after="2023-06-20"> + enum="PreloadBookmarkMetricsEvent" expires_after="2023-09-24"> <owner>robertlin@chromium.org</owner> <owner>toyoshim@chromium.org</owner> <owner>chrome-prerendering@google.com</owner>
diff --git a/tools/metrics/histograms/metadata/nearby/histograms.xml b/tools/metrics/histograms/metadata/nearby/histograms.xml index 6e1d7fa6..8fda3bd 100644 --- a/tools/metrics/histograms/metadata/nearby/histograms.xml +++ b/tools/metrics/histograms/metadata/nearby/histograms.xml
@@ -959,7 +959,7 @@ </histogram> <histogram name="Nearby.Share.Payload.Medium" enum="NearbyShareUpgradedMedium" - expires_after="2023-09-17"> + expires_after="2023-09-24"> <owner>pushi@google.com</owner> <owner>nearby-share-chromeos-eng@google.com</owner> <summary> @@ -1174,7 +1174,7 @@ </histogram> <histogram name="Nearby.Share.Transfer.Success" enum="BooleanSuccess" - expires_after="2023-09-17"> + expires_after="2023-09-24"> <owner>pushi@google.com</owner> <owner>nearby-share-chromeos-eng@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/net/histograms.xml b/tools/metrics/histograms/metadata/net/histograms.xml index 95e856b..8d82cab 100644 --- a/tools/metrics/histograms/metadata/net/histograms.xml +++ b/tools/metrics/histograms/metadata/net/histograms.xml
@@ -324,7 +324,7 @@ </histogram> <histogram name="HttpCache.TotalDiskCacheTimePerTransaction.{AccessType}" - units="ms" expires_after="2023-05-06"> + units="ms" expires_after="2023-06-28"> <owner>bashi@chromium.org</owner> <owner>blink-network-stack@google.com</owner> <summary> @@ -690,7 +690,7 @@ </histogram> <histogram name="Net.ConnectionInfo.SubResource" enum="ConnectionInfo" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>dschinazi@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -982,7 +982,7 @@ </histogram> <histogram name="Net.DNS.DnsHosts.Count" units="count" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>horo@chromium.org</owner> <owner>net-dev@chromium.org</owner> <summary> @@ -992,7 +992,7 @@ </histogram> <histogram name="Net.DNS.DnsHosts.EstimateMemoryUsage" units="bytes" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>horo@chromium.org</owner> <owner>net-dev@chromium.org</owner> <summary> @@ -1002,7 +1002,7 @@ </histogram> <histogram name="Net.DNS.DnsHosts.FileSize" units="bytes" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>horo@chromium.org</owner> <owner>net-dev@chromium.org</owner> <summary> @@ -1333,7 +1333,7 @@ </histogram> <histogram name="Net.DNS.JobQueueTime.Failure" units="ms" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>horo@chromium.org</owner> <owner>net-dev@chromium.org</owner> <summary> @@ -1653,7 +1653,7 @@ </histogram> <histogram name="Net.DNS.UpgradeConfig.InsecureUpgradeSucceeded" enum="Boolean" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>horo@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -3924,7 +3924,7 @@ </histogram> <histogram name="Net.QuicSession.ReceivedSettings.BlockedStreams" units="units" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3955,7 +3955,7 @@ </histogram> <histogram name="Net.QuicSession.ReceivedSettings.MaxHeaderListSize2" - units="bytes" expires_after="2023-07-23"> + units="bytes" expires_after="2023-09-24"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -4941,7 +4941,7 @@ </histogram> <histogram name="Net.SpdyStreamsPushedAndClaimedPerSession" units="units" - expires_after="2023-07-16"> + expires_after="2023-09-24"> <owner>dschinazi@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -5124,7 +5124,7 @@ </histogram> <histogram name="Net.SSLLegacyCryptoFallback2" enum="SSLLegacyCryptoFallback" - expires_after="2023-07-21"> + expires_after="2023-09-24"> <owner>davidben@chromium.org</owner> <owner>trusty-transport@chromium.org</owner> <summary> @@ -5196,7 +5196,7 @@ </histogram> <histogram name="Net.SSLVersionGoogle" enum="SSLOrQUICVersion" - expires_after="2023-06-18"> + expires_after="2023-09-24"> <owner>davidben@chromium.org</owner> <owner>rsleevi@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/network/histograms.xml b/tools/metrics/histograms/metadata/network/histograms.xml index f10bea374..f0a44b4 100644 --- a/tools/metrics/histograms/metadata/network/histograms.xml +++ b/tools/metrics/histograms/metadata/network/histograms.xml
@@ -1453,7 +1453,7 @@ </histogram> <histogram name="Network.DnsProxy.DnsOverHttpsQuery.HttpErrors" - enum="DnsProxy.HttpError" expires_after="2023-05-07"> + enum="DnsProxy.HttpError" expires_after="2023-12-31"> <owner>garrick@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -1473,7 +1473,7 @@ </histogram> <histogram name="Network.DnsProxy.PlainTextProbe.{Family}.Errors" - enum="DnsProxy.QueryResult" expires_after="2023-05-07"> + enum="DnsProxy.QueryResult" expires_after="2023-12-31"> <owner>jasongustaman@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -1488,7 +1488,7 @@ </histogram> <histogram name="Network.DnsProxy.PlainTextProbe.{Family}.FailedRetries" - units="count" expires_after="2023-05-07"> + units="count" expires_after="2023-12-31"> <owner>jasongustaman@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -1503,7 +1503,7 @@ </histogram> <histogram name="Network.DnsProxy.PlainTextProbe.{Family}.Results" - enum="DnsProxy.QueryResult" expires_after="2023-05-07"> + enum="DnsProxy.QueryResult" expires_after="2023-12-31"> <owner>jasongustaman@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -1518,7 +1518,7 @@ </histogram> <histogram name="Network.DnsProxy.PlainTextProbe.{Family}.ResultsWithRetries" - enum="DnsProxy.QueryResult" expires_after="2023-05-07"> + enum="DnsProxy.QueryResult" expires_after="2023-12-31"> <owner>jasongustaman@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -1534,7 +1534,7 @@ </histogram> <histogram name="Network.DnsProxy.PlainTextProbe.{Family}.RetriesUntilSuccess" - units="count" expires_after="2023-05-07"> + units="count" expires_after="2023-12-31"> <owner>jasongustaman@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -1549,7 +1549,7 @@ </histogram> <histogram name="Network.DnsProxy.Query.Failed{Stage}Duration" units="ms" - expires_after="2023-05-07"> + expires_after="2023-12-31"> <owner>garrick@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -1585,7 +1585,7 @@ </histogram> <histogram name="Network.DnsProxy.Query.{Stage}Duration" units="ms" - expires_after="2023-05-07"> + expires_after="2023-12-31"> <owner>garrick@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -1621,7 +1621,7 @@ </histogram> <histogram name="Network.DnsProxy.{Family}Nameservers" units="units" - expires_after="2023-05-07"> + expires_after="2023-12-31"> <owner>garrick@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -1636,7 +1636,7 @@ </histogram> <histogram name="Network.DnsProxy.{ProcessType}.Event" - enum="DnsProxy.ProcessEvent" expires_after="2023-05-07"> + enum="DnsProxy.ProcessEvent" expires_after="2023-12-31"> <owner>garrick@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -1654,7 +1654,7 @@ </histogram> <histogram name="Network.DnsProxy.{Type}Query.Errors" - enum="DnsProxy.QueryError" expires_after="2023-05-07"> + enum="DnsProxy.QueryError" expires_after="2023-12-31"> <owner>garrick@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -1669,7 +1669,7 @@ </histogram> <histogram name="Network.DnsProxy.{Type}Query.FailedResolveDuration" units="ms" - expires_after="2023-05-07"> + expires_after="2023-12-31"> <owner>garrick@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -1690,7 +1690,7 @@ </histogram> <histogram name="Network.DnsProxy.{Type}Query.ResolveDuration" units="ms" - expires_after="2023-05-07"> + expires_after="2023-12-31"> <owner>garrick@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -1711,7 +1711,7 @@ </histogram> <histogram name="Network.DnsProxy.{Type}Query.Results" - enum="DnsProxy.QueryResult" expires_after="2023-05-07"> + enum="DnsProxy.QueryResult" expires_after="2023-12-31"> <owner>garrick@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -1726,7 +1726,7 @@ </histogram> <histogram name="Network.DnsProxy.{Type}Query.ResultsWithRetries" - enum="DnsProxy.QueryResult" expires_after="2023-05-07"> + enum="DnsProxy.QueryResult" expires_after="2023-12-31"> <owner>garrick@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -2509,7 +2509,7 @@ </histogram> <histogram name="Network.Shill.PPPMTUValue" units="bytes" - expires_after="2023-05-07"> + expires_after="2023-12-31"> <owner>jiejiang@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary> @@ -2692,7 +2692,7 @@ </histogram> <histogram name="Network.Shill.Vpn.WireGuardKeyPairSource" - enum="VPNWireGuardKeyPairSource" expires_after="2023-05-07"> + enum="VPNWireGuardKeyPairSource" expires_after="2023-12-31"> <owner>jiejiang@chromium.org</owner> <owner>cros-network-metrics@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/new_tab_page/histograms.xml b/tools/metrics/histograms/metadata/new_tab_page/histograms.xml index f919a07..f93fbc4 100644 --- a/tools/metrics/histograms/metadata/new_tab_page/histograms.xml +++ b/tools/metrics/histograms/metadata/new_tab_page/histograms.xml
@@ -2105,7 +2105,7 @@ </histogram> <histogram name="NewTabPage.TileTitleClicked" enum="NTPTileTitleSource" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>danielms@google.com</owner> <owner>tiborg@chromium.org</owner> <owner>chrome-desktop-ntp@google.com</owner>
diff --git a/tools/metrics/histograms/metadata/omnibox/histograms.xml b/tools/metrics/histograms/metadata/omnibox/histograms.xml index ffd63b3b..ac7eee9 100644 --- a/tools/metrics/histograms/metadata/omnibox/histograms.xml +++ b/tools/metrics/histograms/metadata/omnibox/histograms.xml
@@ -2086,7 +2086,7 @@ </histogram> <histogram name="Omnibox.SuggestRequests" enum="OmniboxSuggestRequests" - expires_after="2023-06-04"> + expires_after="2023-09-24"> <owner>mpearson@chromium.org</owner> <owner>jdonnelly@chromium.org</owner> <owner>cch@chromium.org</owner> @@ -2171,7 +2171,7 @@ </histogram> <histogram name="Omnibox.TabMatchTime" units="microseconds" - expires_after="2023-07-02"> + expires_after="2023-09-24"> <owner>gangwu@chromium.org</owner> <owner>jdonnelly@chromium.org</owner> <owner>mpearson@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/oobe/histograms.xml b/tools/metrics/histograms/metadata/oobe/histograms.xml index 71424b7..1594577b 100644 --- a/tools/metrics/histograms/metadata/oobe/histograms.xml +++ b/tools/metrics/histograms/metadata/oobe/histograms.xml
@@ -388,7 +388,7 @@ </histogram> <histogram name="OOBE.HidDetectionScreen.BluetoothPairing.Result" - enum="HidDetectionBluetoothPairingResult" expires_after="2023-07-09"> + enum="HidDetectionBluetoothPairingResult" expires_after="2023-09-24"> <owner>gordonseto@google.com</owner> <owner>cros-connectivity@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/others/histograms.xml b/tools/metrics/histograms/metadata/others/histograms.xml index 9f14c7dd..612bb33 100644 --- a/tools/metrics/histograms/metadata/others/histograms.xml +++ b/tools/metrics/histograms/metadata/others/histograms.xml
@@ -7957,7 +7957,7 @@ </histogram> <histogram name="Manifest.ParseIdResult" enum="ManifestParseIdResultType" - expires_after="2023-06-04"> + expires_after="2023-09-24"> <owner>phillis@chromium.org</owner> <owner>desktop-pwas-team@chromium.org</owner> <summary>Tracks the result of parsing id field in the Manifest.</summary> @@ -12957,7 +12957,7 @@ </histogram> <histogram name="SSORecallPromo.PromoSeenCount" units="units" - expires_after="2023-07-09"> + expires_after="2023-09-24"> <owner>jlebel@chromium.org</owner> <owner>chrome-signin-team@google.com</owner> <summary> @@ -14517,7 +14517,7 @@ </histogram> <histogram name="VoiceInteraction.VoiceResultConfidenceValue" units="%" - expires_after="2023-09-17"> + expires_after="2023-09-24"> <owner>basiaz@google.com</owner> <owner>chrome-language@google.com</owner> <summary> @@ -15132,7 +15132,7 @@ </histogram> <histogram name="WhatsNew.LoadResponseCode" - enum="CombinedHttpResponseAndNetErrorCode" expires_after="2023-06-18"> + enum="CombinedHttpResponseAndNetErrorCode" expires_after="2023-09-24"> <owner>rbpotter@chromium.org</owner> <owner>mahmadi@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/page/histograms.xml b/tools/metrics/histograms/metadata/page/histograms.xml index 58a221b2..3772d7c 100644 --- a/tools/metrics/histograms/metadata/page/histograms.xml +++ b/tools/metrics/histograms/metadata/page/histograms.xml
@@ -2551,7 +2551,7 @@ </histogram> <histogram name="PageLoad.Internal.Prerender2.ObserverEvent" - enum="PageLoadPrerenderObserverEvent" expires_after="2023-07-26"> + enum="PageLoadPrerenderObserverEvent" expires_after="2023-09-24"> <owner>nhiroki@chromium.org</owner> <owner>src/content/browser/preloading/prerender/OWNERS</owner> <summary> @@ -2562,7 +2562,7 @@ </histogram> <histogram name="PageLoad.Internal.Prerender2.VisibilityAtActivation" - enum="PageLoadPrerenderVisibilityAtActivation" expires_after="2023-07-26"> + enum="PageLoadPrerenderVisibilityAtActivation" expires_after="2023-09-24"> <owner>nhiroki@chromium.org</owner> <owner>src/content/browser/preloading/prerender/OWNERS</owner> <summary> @@ -2908,7 +2908,7 @@ </histogram> <histogram name="PageLoad.PaintTiming.NavigationToFirstImagePaint" units="ms" - expires_after="2023-07-21"> + expires_after="2023-09-24"> <owner>sullivan@chromium.org</owner> <owner>speed-metrics-dev@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/password/histograms.xml b/tools/metrics/histograms/metadata/password/histograms.xml index 39d89460..029b7e2 100644 --- a/tools/metrics/histograms/metadata/password/histograms.xml +++ b/tools/metrics/histograms/metadata/password/histograms.xml
@@ -1343,7 +1343,7 @@ </histogram> <histogram name="PasswordManager.DefaultPasswordStoreSet" - enum="PasswordManager.Store" expires_after="2023-07-23"> + enum="PasswordManager.Store" expires_after="2023-09-24"> <owner>mamir@chromium.org</owner> <owner>treib@chromium.org</owner> <summary> @@ -1426,7 +1426,7 @@ </histogram> <histogram name="PasswordManager.EnableState" enum="PasswordManagerEnableState" - expires_after="2023-07-09"> + expires_after="2023-09-24"> <owner>markusheintz@google.com</owner> <owner>mamir@chromium.org</owner> <summary> @@ -1830,7 +1830,7 @@ </histogram> <histogram name="PasswordManager.iOS.InfoBar.PasswordSave" enum="Boolean" - expires_after="2023-07-16"> + expires_after="2023-09-24"> <owner>djean@chromium.org</owner> <owner>sczs@google.com</owner> <summary> @@ -1839,7 +1839,7 @@ </histogram> <histogram name="PasswordManager.iOS.PasswordDetails.CopyDetailsFailed" - enum="Boolean" expires_after="2023-07-16"> + enum="Boolean" expires_after="2023-09-24"> <owner>eic@google.com</owner> <owner>tmartino@chromium.com</owner> <summary> @@ -2096,7 +2096,7 @@ </histogram> <histogram name="PasswordManager.MergeSyncData.AddLoginSyncError" - enum="PasswordAddLoginSyncError" expires_after="2023-07-23"> + enum="PasswordAddLoginSyncError" expires_after="2023-09-24"> <owner>mamir@chromium.org</owner> <owner>mastiz@chromium.org</owner> <summary> @@ -2107,7 +2107,7 @@ </histogram> <histogram name="PasswordManager.MergeSyncData.UpdateLoginSyncError" - enum="PasswordUpdateLoginSyncError" expires_after="2023-07-23"> + enum="PasswordUpdateLoginSyncError" expires_after="2023-09-24"> <owner>mamir@chromium.org</owner> <owner>mastiz@chromium.org</owner> <summary> @@ -3203,7 +3203,7 @@ </histogram> <histogram name="PasswordManager.SavingOnUsernameFirstFlow" - enum="SavingOnUsernameFirstFlow" expires_after="2023-07-23"> + enum="SavingOnUsernameFirstFlow" expires_after="2023-09-24"> <owner>kazinova@google.com</owner> <owner>vasilii@chromium.org</owner> <summary> @@ -3413,7 +3413,7 @@ </histogram> <histogram name="PasswordManager.SyncMetadataReadError2" - enum="PasswordSyncMetadataReadError" expires_after="2023-07-23"> + enum="PasswordSyncMetadataReadError" expires_after="2023-09-24"> <owner>mamir@chromium.org</owner> <owner>mastiz@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/prefetch/histograms.xml b/tools/metrics/histograms/metadata/prefetch/histograms.xml index e58155d8..16936187 100644 --- a/tools/metrics/histograms/metadata/prefetch/histograms.xml +++ b/tools/metrics/histograms/metadata/prefetch/histograms.xml
@@ -386,7 +386,7 @@ <histogram name="PrefetchProxy.Prefetch.NumExistingEligiblePrefetchWithMatchingURL" - units="count" expires_after="2023-07-23"> + units="count" expires_after="2023-09-24"> <owner>curranmax@chromium.org</owner> <owner>ryansturm@chromium.org</owner> <owner>spelchat@chromium.org</owner> @@ -412,7 +412,7 @@ <histogram name="PrefetchProxy.Prefetch.NumExistingPrefetchWithMatchingURLAndReferrer" - units="count" expires_after="2023-07-23"> + units="count" expires_after="2023-09-24"> <owner>curranmax@chromium.org</owner> <owner>ryansturm@chromium.org</owner> <owner>spelchat@chromium.org</owner> @@ -426,7 +426,7 @@ <histogram name="PrefetchProxy.Prefetch.NumExistingPrefetchWithMatchingURLAndRenderFrameHost" - units="count" expires_after="2023-07-23"> + units="count" expires_after="2023-09-24"> <owner>curranmax@chromium.org</owner> <owner>ryansturm@chromium.org</owner> <owner>spelchat@chromium.org</owner> @@ -443,7 +443,7 @@ <histogram name="PrefetchProxy.Prefetch.NumExistingServablePrefetchWithMatchingURL" - units="count" expires_after="2023-07-23"> + units="count" expires_after="2023-09-24"> <owner>curranmax@chromium.org</owner> <owner>ryansturm@chromium.org</owner> <owner>spelchat@chromium.org</owner> @@ -456,7 +456,7 @@ </histogram> <histogram name="PrefetchProxy.Prefetch.StreamingURLLoaderFinalStatus" - enum="PrefetchStreamingURLLoaderStatus" expires_after="2023-07-23"> + enum="PrefetchStreamingURLLoaderStatus" expires_after="2023-09-24"> <owner>curranmax@chromium.org</owner> <owner>ryansturm@chromium.org</owner> <owner>spelchat@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/profile/histograms.xml b/tools/metrics/histograms/metadata/profile/histograms.xml index 66ce878..09186d5 100644 --- a/tools/metrics/histograms/metadata/profile/histograms.xml +++ b/tools/metrics/histograms/metadata/profile/histograms.xml
@@ -258,7 +258,7 @@ </histogram> <histogram name="Profile.Incognito.MovedToBackgroundAfterDuration" - units="minutes" expires_after="2023-07-23"> + units="minutes" expires_after="2023-09-24"> <owner>rhalavati@chromium.org</owner> <owner>chrome-incognito@google.com</owner> <summary> @@ -405,7 +405,7 @@ </histogram> <histogram name="Profile.NukeFromDisk.Result" enum="NukeProfileResult" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>nicolaso@chromium.org</owner> <owner>cbe-eng@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/quota/histograms.xml b/tools/metrics/histograms/metadata/quota/histograms.xml index 6df6de1..41b16aa 100644 --- a/tools/metrics/histograms/metadata/quota/histograms.xml +++ b/tools/metrics/histograms/metadata/quota/histograms.xml
@@ -99,7 +99,7 @@ </histogram> <histogram name="Quota.EvictedBucketDaysSinceAccess" units="units" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>ayui@chromium.org</owner> <owner>chrome-owp-storage@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/safe_browsing/histograms.xml b/tools/metrics/histograms/metadata/safe_browsing/histograms.xml index e9950d8..ae689e2 100644 --- a/tools/metrics/histograms/metadata/safe_browsing/histograms.xml +++ b/tools/metrics/histograms/metadata/safe_browsing/histograms.xml
@@ -387,7 +387,7 @@ <histogram name="SafeBrowsing.ClientSafeBrowsingReport.DownloadWarningActionSize" - units="units" expires_after="2023-07-23"> + units="units" expires_after="2023-09-24"> <owner>xinghuilu@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -653,7 +653,7 @@ </histogram> <histogram name="SafeBrowsing.ExtensionTelemetry.FileData.CollectionDuration" - units="ms" expires_after="2023-07-23"> + units="ms" expires_after="2023-09-24"> <owner>richche@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -682,7 +682,7 @@ </histogram> <histogram name="SafeBrowsing.ExtensionTelemetry.FileData.NumFilesFound" - units="files" expires_after="2023-07-23"> + units="files" expires_after="2023-09-24"> <owner>richche@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -697,7 +697,7 @@ <histogram name="SafeBrowsing.ExtensionTelemetry.FileData.NumFilesOverProcessingLimit" - units="files" expires_after="2023-07-23"> + units="files" expires_after="2023-09-24"> <owner>richche@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -711,7 +711,7 @@ <histogram name="SafeBrowsing.ExtensionTelemetry.FileData.NumFilesOverSizeLimit" - units="files" expires_after="2023-07-23"> + units="files" expires_after="2023-09-24"> <owner>richche@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -724,7 +724,7 @@ </histogram> <histogram name="SafeBrowsing.ExtensionTelemetry.FileData.NumFilesProcessed" - units="files" expires_after="2023-07-23"> + units="files" expires_after="2023-09-24"> <owner>richche@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -738,7 +738,7 @@ <histogram name="SafeBrowsing.ExtensionTelemetry.FileData.NumOffstoreExtensions" - units="extensions" expires_after="2023-07-23"> + units="extensions" expires_after="2023-09-24"> <owner>richche@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -751,7 +751,7 @@ </histogram> <histogram name="SafeBrowsing.ExtensionTelemetry.FileData.ProcessedFileSize" - units="bytes" expires_after="2023-07-23"> + units="bytes" expires_after="2023-09-24"> <owner>richche@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -938,7 +938,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.AllowlistSizeTooSmall" - enum="BooleanUnavailable" expires_after="2023-07-20"> + enum="BooleanUnavailable" expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -951,7 +951,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.AllStoresAvailable" enum="BooleanAvailable" - expires_after="2023-07-20"> + expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -962,7 +962,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.BackoffState" enum="BooleanEnabled" - expires_after="2023-07-20"> + expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -974,7 +974,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.Cache.FullHashCount" units="entries" - expires_after="2023-07-20"> + expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -986,7 +986,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.Cache.HashPrefixCount" units="entries" - expires_after="2023-07-20"> + expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -998,7 +998,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.CacheHit" enum="BooleanCacheHit" - expires_after="2023-07-20"> + expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -1012,7 +1012,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.CacheHitAllPrefixes" enum="BooleanCacheHit" - expires_after="2023-07-20"> + expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -1024,7 +1024,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.FoundUnmatchedFullHashes" - enum="BooleanFound" expires_after="2023-07-20"> + enum="BooleanFound" expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -1035,7 +1035,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.GetCache.Time" units="ms" - expires_after="2023-07-20"> + expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -1046,7 +1046,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.IsLookupServiceFound" enum="BooleanFound" - expires_after="2023-07-20"> + expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -1058,7 +1058,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.LocalMatch.Result" - enum="SafeBrowsingAllowlistAsyncMatch" expires_after="2023-07-20"> + enum="SafeBrowsingAllowlistAsyncMatch" expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -1069,7 +1069,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.Network.Result" - enum="CombinedHttpResponseAndNetErrorCode" expires_after="2023-07-20"> + enum="CombinedHttpResponseAndNetErrorCode" expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -1080,7 +1080,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.Network.Time" units="ms" - expires_after="2023-07-20"> + expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -1091,7 +1091,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.OperationResult" - enum="SafeBrowsingHPRTOperationResult" expires_after="2023-07-20"> + enum="SafeBrowsingHPRTOperationResult" expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -1101,7 +1101,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.Request.CountOfPrefixes" units="prefixes" - expires_after="2023-07-20"> + expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -1112,7 +1112,7 @@ </histogram> <histogram name="SafeBrowsing.HPRT.ThreatInfoSize" units="verdicts" - expires_after="2023-07-20"> + expires_after="2023-09-24"> <owner>thefrog@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -2283,7 +2283,7 @@ </histogram> <histogram name="SafeBrowsing.V4GetHash.Result.BackoffErrorCount" units="times" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>skrakowi@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/sb_client/histograms.xml b/tools/metrics/histograms/metadata/sb_client/histograms.xml index 6accb18..165fcfa 100644 --- a/tools/metrics/histograms/metadata/sb_client/histograms.xml +++ b/tools/metrics/histograms/metadata/sb_client/histograms.xml
@@ -173,7 +173,7 @@ </histogram> <histogram name="SBClientDownload.DownloadRequestDuration" units="ms" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>vakh@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <owner>mattm@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/scheduler/histograms.xml b/tools/metrics/histograms/metadata/scheduler/histograms.xml index 1287ff60..7730c54 100644 --- a/tools/metrics/histograms/metadata/scheduler/histograms.xml +++ b/tools/metrics/histograms/metadata/scheduler/histograms.xml
@@ -139,7 +139,7 @@ </histogram> <histogram name="Scheduler.TaskQueueImpl.DelayedIncomingQueueSize" - units="tasks" expires_after="2023-06-18"> + units="tasks" expires_after="2023-09-24"> <owner>yafroze@google.com</owner> <owner>pmonette@chromium.org</owner> <owner>catan-team@chromium.org</owner> @@ -154,7 +154,7 @@ </histogram> <histogram name="Scheduler.TaskQueueImpl.PostDelayedTaskDelay" units="ms" - expires_after="2023-06-18"> + expires_after="2023-09-24"> <owner>yafroze@google.com</owner> <owner>pmonette@chromium.org</owner> <owner>catan-team@chromium.org</owner> @@ -199,7 +199,7 @@ </histogram> <histogram name="Scheduling.Renderer.DeadlineMode" - enum="RendererSchedulerDeadlineMode" expires_after="2023-07-02"> + enum="RendererSchedulerDeadlineMode" expires_after="2023-09-24"> <owner>weiliangc@chromium.org</owner> <owner>chrome-gpu-metrics@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/search/histograms.xml b/tools/metrics/histograms/metadata/search/histograms.xml index bc793dbb..58f0325 100644 --- a/tools/metrics/histograms/metadata/search/histograms.xml +++ b/tools/metrics/histograms/metadata/search/histograms.xml
@@ -1364,7 +1364,7 @@ </histogram> <histogram name="Search.iOS.SelectDefaultSearchEngine" - enum="OmniboxSearchEngineType" expires_after="2023-07-16"> + enum="OmniboxSearchEngineType" expires_after="2023-09-24"> <owner>sczs@chromium.org</owner> <owner>gambard@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/service/histograms.xml b/tools/metrics/histograms/metadata/service/histograms.xml index a7faac11..72c9adf 100644 --- a/tools/metrics/histograms/metadata/service/histograms.xml +++ b/tools/metrics/histograms/metadata/service/histograms.xml
@@ -887,7 +887,7 @@ </histogram> <histogram name="ServiceWorker.MaybeStartWorker.RunningStatus" - enum="EmbeddedWorkerStatus" expires_after="2023-09-17"> + enum="EmbeddedWorkerStatus" expires_after="2023-09-24"> <owner>yyanagisawa@chromium.org</owner> <owner>chrome-worker@google.com</owner> <summary> @@ -1065,7 +1065,7 @@ </histogram> <histogram name="ServiceWorker.StartTiming.ClockConsistency" - enum="CrossProcessTimeDelta" expires_after="2023-06-30"> + enum="CrossProcessTimeDelta" expires_after="2023-09-24"> <owner>yyanagisawa@chromium.org</owner> <owner>asamidoi@chromium.org</owner> <owner>chrome-worker@google.com</owner> @@ -1085,7 +1085,7 @@ </histogram> <histogram name="ServiceWorker.StartTiming.Duration" units="ms" - expires_after="2023-06-30"> + expires_after="2023-09-24"> <owner>yyanagisawa@chromium.org</owner> <owner>asamidoi@chromium.org</owner> <owner>chrome-worker@google.com</owner> @@ -1103,7 +1103,7 @@ <histogram name="ServiceWorker.StartTiming.ReceivedStartWorkerToScriptEvaluationStart" - units="ms" expires_after="2023-06-30"> + units="ms" expires_after="2023-09-24"> <owner>yyanagisawa@chromium.org</owner> <owner>asamidoi@chromium.org</owner> <owner>chrome-worker@google.com</owner> @@ -1207,7 +1207,7 @@ </histogram> <histogram name="ServiceWorker.StartWorker.Purpose" - enum="ServiceWorkerMetrics.EventType" expires_after="2023-06-30"> + enum="ServiceWorkerMetrics.EventType" expires_after="2023-09-24"> <owner>yyanagisawa@chromium.org</owner> <owner>chrome-worker@google.com</owner> <summary> @@ -1219,7 +1219,7 @@ </histogram> <histogram name="ServiceWorker.StartWorker.Status" - enum="ServiceWorkerStatusCode" expires_after="2023-09-17"> + enum="ServiceWorkerStatusCode" expires_after="2023-09-24"> <owner>wanderview@chromium.org</owner> <owner>asamidoi@chromium.org</owner> <owner>chrome-worker@google.com</owner>
diff --git a/tools/metrics/histograms/metadata/sharing/histograms.xml b/tools/metrics/histograms/metadata/sharing/histograms.xml index b78a35a6..5684ba3 100644 --- a/tools/metrics/histograms/metadata/sharing/histograms.xml +++ b/tools/metrics/histograms/metadata/sharing/histograms.xml
@@ -118,7 +118,7 @@ </histogram> <histogram name="Sharing.DefaultSharesheetAndroid.Opened" enum="ShareOrigin" - expires_after="2023-07-26"> + expires_after="2023-09-24"> <owner>sophey@chromium.org</owner> <owner>src/chrome/browser/share/OWNERS</owner> <summary> @@ -581,7 +581,7 @@ </histogram> <histogram name="Sharing.SharingHubDesktop.TimeToShow" units="ms" - expires_after="2023-07-26"> + expires_after="2023-09-24"> <owner>ellyjones@chromium.org</owner> <owner>src/chrome/browser/share/OWNERS</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/signin/histograms.xml b/tools/metrics/histograms/metadata/signin/histograms.xml index 43d6b798..c48263d 100644 --- a/tools/metrics/histograms/metadata/signin/histograms.xml +++ b/tools/metrics/histograms/metadata/signin/histograms.xml
@@ -205,7 +205,7 @@ </histogram> <histogram name="Signin.AndroidAccountInfoFetchTime" units="ms" - expires_after="2023-06-21"> + expires_after="2023-09-24"> <owner>samarchehade@chromium.org</owner> <owner>chrome-signin-team@google.com</owner> <summary> @@ -244,7 +244,7 @@ </histogram> <histogram name="Signin.AndroidIsFREStudyGroupConsistent" - enum="BooleanConsistent" expires_after="2023-07-23"> + enum="BooleanConsistent" expires_after="2023-09-24"> <owner>bsazonov@chromium.org</owner> <owner>chrome-signin-team@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/stability/histograms.xml b/tools/metrics/histograms/metadata/stability/histograms.xml index d690b0a..cc5e39e 100644 --- a/tools/metrics/histograms/metadata/stability/histograms.xml +++ b/tools/metrics/histograms/metadata/stability/histograms.xml
@@ -105,7 +105,7 @@ </histogram> <histogram name="Stability.Android.ProcessedRealMinidumps" - enum="AndroidProcessedMinidumps" expires_after="2023-07-23"> + enum="AndroidProcessedMinidumps" expires_after="2023-09-24"> <owner>wnwen@chromium.org</owner> <owner>src/components/minidump_uploader/OWNERS</owner> <summary> @@ -490,7 +490,7 @@ </histogram> <histogram name="Stability.iOS.UTE.HasPossibleExplanation" - enum="BooleanHasPossibleExplanation" expires_after="2023-07-16"> + enum="BooleanHasPossibleExplanation" expires_after="2023-09-24"> <owner>michaeldo@chromium.org</owner> <owner>olivierrobin@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/startup/histograms.xml b/tools/metrics/histograms/metadata/startup/histograms.xml index 778c03d..c1f0b814 100644 --- a/tools/metrics/histograms/metadata/startup/histograms.xml +++ b/tools/metrics/histograms/metadata/startup/histograms.xml
@@ -864,7 +864,7 @@ </histogram> <histogram name="Startup.TimeFromProcessCreationToLoad" units="ms" - expires_after="2023-05-14"> + expires_after="2023-09-24"> <owner>olivierrobin@chromium.org</owner> <owner>ajuma@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/sync/histograms.xml b/tools/metrics/histograms/metadata/sync/histograms.xml index 280d994..1651f0d 100644 --- a/tools/metrics/histograms/metadata/sync/histograms.xml +++ b/tools/metrics/histograms/metadata/sync/histograms.xml
@@ -402,7 +402,7 @@ </histogram> <histogram name="Sync.CryptographerReady" enum="SyncCryptographerReadyState" - expires_after="2023-07-09"> + expires_after="2023-09-24"> <owner>mmoskvitin@google.com</owner> <owner>mastiz@chromium.org</owner> <component>Services>Sync</component> @@ -1597,7 +1597,7 @@ <histogram name="Sync.TrustedVaultHintDegradedRecoverabilityChangedReason2" enum="TrustedVaultHintDegradedRecoverabilityChangedReason" - expires_after="2023-07-23"> + expires_after="2023-09-24"> <owner>mmrashad@google.com</owner> <owner>mmoskvitin@google.com</owner> <component>Services>Sync</component>
diff --git a/tools/metrics/histograms/metadata/uma/histograms.xml b/tools/metrics/histograms/metadata/uma/histograms.xml index 1446292..ffa4cb3b 100644 --- a/tools/metrics/histograms/metadata/uma/histograms.xml +++ b/tools/metrics/histograms/metadata/uma/histograms.xml
@@ -162,7 +162,7 @@ </histogram> <histogram name="UMA.CrosPerUser.IdReset" enum="PerUserIdType" - expires_after="2023-06-18"> + expires_after="2023-09-24"> <owner>jongahn@chromium.org</owner> <owner>asvitkine@chromium.org</owner> <summary> @@ -871,7 +871,7 @@ </histogram> <histogram name="UMA.TruncatedEvents.UserAction" units="events" - expires_after="2023-09-17"> + expires_after="2023-09-24"> <owner>rkaplow@chromium.org</owner> <owner>src/base/metrics/OWNERS</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/web_rtc/histograms.xml b/tools/metrics/histograms/metadata/web_rtc/histograms.xml index 032e3e8..5d681eb2 100644 --- a/tools/metrics/histograms/metadata/web_rtc/histograms.xml +++ b/tools/metrics/histograms/metadata/web_rtc/histograms.xml
@@ -1919,7 +1919,7 @@ </histogram> <histogram name="WebRTC.Stun.Integrity.{StunPacketType}" - enum="WebRtcStunIntegrityOutcome" expires_after="2023-04-07"> + enum="WebRtcStunIntegrityOutcome" expires_after="2023-10-07"> <owner>hta@chromium.org</owner> <owner>webrtc-dev@chromium.org</owner> <summary> @@ -3823,7 +3823,7 @@ </histogram> <histogram name="WebRtcTextLogging.UploadFailureNetErrorCode" - enum="NetErrorCodes" expires_after="2023-05-01"> + enum="NetErrorCodes" expires_after="2024-05-01"> <owner>toprice@chromium.org</owner> <owner>olka@chromium.org</owner> <owner>webrtc-dev@chromium.org</owner> @@ -3835,7 +3835,7 @@ </histogram> <histogram name="WebRtcTextLogging.UploadFailureReason" - enum="WebRtcLoggingUploadFailureReason" expires_after="2023-09-11"> + enum="WebRtcLoggingUploadFailureReason" expires_after="2024-05-01"> <owner>toprice@chromium.org</owner> <owner>olka@chromium.org</owner> <owner>webrtc-dev@chromium.org</owner> @@ -3847,7 +3847,7 @@ </histogram> <histogram name="WebRtcTextLogging{WebRtcLoggingEvent}" - enum="WebRtcLoggingWebAppIdHash" expires_after="2023-05-07"> + enum="WebRtcLoggingWebAppIdHash" expires_after="2024-05-07"> <owner>toprice@chromium.org</owner> <owner>olka@chromium.org</owner> <owner>webrtc-dev@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/webapps/histograms.xml b/tools/metrics/histograms/metadata/webapps/histograms.xml index a2f09e4..d5791c2 100644 --- a/tools/metrics/histograms/metadata/webapps/histograms.xml +++ b/tools/metrics/histograms/metadata/webapps/histograms.xml
@@ -943,7 +943,7 @@ </histogram> <histogram name="WebApp.Launcher.LaunchResult" - enum="WebAppLauncherLaunchResult" expires_after="2023-07-02"> + enum="WebAppLauncherLaunchResult" expires_after="2023-09-24"> <owner>davidbienvenu@chromium.org</owner> <owner>jessemckenna@google.com</owner> <summary>
diff --git a/tools/metrics/ukm/ukm.xml b/tools/metrics/ukm/ukm.xml index 5da49912..1c985222 100644 --- a/tools/metrics/ukm/ukm.xml +++ b/tools/metrics/ukm/ukm.xml
@@ -17464,6 +17464,54 @@ </history> </aggregation> </metric> + <metric name="Duration.LongScript.JSExecution.EventListeners"> + <summary> + The total duration spent in event listeners (e.g. onclick). + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.PromiseHandlers"> + <summary> + The total duration spent in promise resolve/reject tasks. + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.ScriptBlocks"> + <summary> + The total duration spent in script blocks (script element, import) + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.UserCallbacks"> + <summary> + The total duration spent in user callbacks (e.g. requestAnimationFrame). + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> <metric name="Duration.StyleAndLayout.Forced"> <summary> The total duration of forced style and layout in long scripts. @@ -17568,6 +17616,54 @@ </history> </aggregation> </metric> + <metric name="Duration.LongScript.JSExecution.EventListeners"> + <summary> + The total duration spent in event listeners (e.g. onclick). + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.PromiseHandlers"> + <summary> + The total duration spent in promise resolve/reject tasks. + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.ScriptBlocks"> + <summary> + The total duration spent in script blocks (script element, import) + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.UserCallbacks"> + <summary> + The total duration spent in user callbacks (e.g. requestAnimationFrame). + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> <metric name="Duration.StyleAndLayout.Forced"> <summary> The total duration of forced style and layout in long scripts. @@ -17672,6 +17768,54 @@ </history> </aggregation> </metric> + <metric name="Duration.LongScript.JSExecution.EventListeners"> + <summary> + The total duration spent in event listeners (e.g. onclick). + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.PromiseHandlers"> + <summary> + The total duration spent in promise resolve/reject tasks. + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.ScriptBlocks"> + <summary> + The total duration spent in script blocks (script element, import) + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.UserCallbacks"> + <summary> + The total duration spent in user callbacks (e.g. requestAnimationFrame). + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> <metric name="Duration.StyleAndLayout.Forced"> <summary> The total duration of forced style and layout in long scripts. @@ -17776,6 +17920,54 @@ </history> </aggregation> </metric> + <metric name="Duration.LongScript.JSExecution.EventListeners"> + <summary> + The total duration spent in event listeners (e.g. onclick). + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.PromiseHandlers"> + <summary> + The total duration spent in promise resolve/reject tasks. + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.ScriptBlocks"> + <summary> + The total duration spent in script blocks (script element, import) + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.UserCallbacks"> + <summary> + The total duration spent in user callbacks (e.g. requestAnimationFrame). + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> <metric name="Duration.StyleAndLayout.Forced"> <summary> The total duration of forced style and layout in long scripts. @@ -17880,6 +18072,54 @@ </history> </aggregation> </metric> + <metric name="Duration.LongScript.JSExecution.EventListeners"> + <summary> + The total duration spent in event listeners (e.g. onclick). + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.PromiseHandlers"> + <summary> + The total duration spent in promise resolve/reject tasks. + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.ScriptBlocks"> + <summary> + The total duration spent in script blocks (script element, import) + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.UserCallbacks"> + <summary> + The total duration spent in user callbacks (e.g. requestAnimationFrame). + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> <metric name="Duration.StyleAndLayout.Forced"> <summary> The total duration of forced style and layout in long scripts. @@ -17984,6 +18224,54 @@ </history> </aggregation> </metric> + <metric name="Duration.LongScript.JSExecution.EventListeners"> + <summary> + The total duration spent in event listeners (e.g. onclick). + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.PromiseHandlers"> + <summary> + The total duration spent in promise resolve/reject tasks. + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.ScriptBlocks"> + <summary> + The total duration spent in script blocks (script element, import) + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> + <metric name="Duration.LongScript.JSExecution.UserCallbacks"> + <summary> + The total duration spent in user callbacks (e.g. requestAnimationFrame). + </summary> + <aggregation> + <history> + <statistics> + <quantiles type="std-percentiles"/> + </statistics> + </history> + </aggregation> + </metric> <metric name="Duration.StyleAndLayout.Forced"> <summary> The total duration of forced style and layout in long scripts.
diff --git a/ui/chromeos/file_manager_strings.grdp b/ui/chromeos/file_manager_strings.grdp index 34b597f..de0a256f 100644 --- a/ui/chromeos/file_manager_strings.grdp +++ b/ui/chromeos/file_manager_strings.grdp
@@ -367,6 +367,9 @@ <message name="IDS_FILE_BROWSER_CLOSE_VOLUME_BUTTON_LABEL" desc="Title of the action for closing either an archive volume or a volume provided by an extension."> Close </message> + <message name="IDS_FILE_BROWSER_FILES_SETTINGS_LABEL" desc="Label for menu that will take users to the Files section of the Settings page."> + Files settings + </message> <message name="IDS_FILE_BROWSER_SEND_FEEDBACK_BUTTON_LABEL" desc="Title for the action of sending user feedback."> Send feedback </message>
diff --git a/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_FILES_SETTINGS_LABEL.png.sha1 b/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_FILES_SETTINGS_LABEL.png.sha1 new file mode 100644 index 0000000..6ec777a --- /dev/null +++ b/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_FILES_SETTINGS_LABEL.png.sha1
@@ -0,0 +1 @@ +47f354011d680e4fa3d4e6744d388c87a20fda2e \ No newline at end of file
diff --git a/ui/file_manager/file_manager/containers/search_container.ts b/ui/file_manager/file_manager/containers/search_container.ts index ada7c05..eef3420 100644 --- a/ui/file_manager/file_manager/containers/search_container.ts +++ b/ui/file_manager/file_manager/containers/search_container.ts
@@ -273,6 +273,7 @@ this.pathDisplay_.removeAttribute('hidden'); this.pathDisplay_.path = path; } else { + this.pathDisplay_.path = ''; this.pathDisplay_.setAttribute('hidden', ''); } } @@ -283,29 +284,17 @@ */ private getSelectedPath_(state: State): string { const keys = state.currentDirectory?.selection?.keys; - if (!keys) { + if (!keys || keys.length !== 1) { return ''; } - const pathSet = new Set(); - for (const dirKey of keys) { - const entry = state.allEntries[dirKey!]?.entry; - if (!entry) { - continue; - } - // TODO(b:274559834): Improve efficiency of these computations. - const parts: PathComponent[] = - PathComponent.computeComponentsFromEntry(entry, this.volumeManager_); - // Drop the file name; keep the folders only. - pathSet.add(parts.slice(0, -1).map(p => p.name).join('/')); - } - if (pathSet.size === 0) { + const entry = state.allEntries[keys[0]!]?.entry; + if (!entry) { return ''; } - if (pathSet.size === 1) { - return pathSet.values().next().value; - } - - return str('SEARCH_RESULTS_MULTIPLE_SELECTION'); + // TODO(b:274559834): Improve efficiency of these computations. + const parts: PathComponent[] = + PathComponent.computeComponentsFromEntry(entry, this.volumeManager_); + return parts.map(p => p.name).join('/'); } /**
diff --git a/ui/file_manager/file_manager/foreground/css/file_manager_gm3.css b/ui/file_manager/file_manager/foreground/css/file_manager_gm3.css index ae1790d..726969d 100644 --- a/ui/file_manager/file_manager/foreground/css/file_manager_gm3.css +++ b/ui/file_manager/file_manager/foreground/css/file_manager_gm3.css
@@ -2306,31 +2306,28 @@ /* File type filter buttons in Recents view. */ #file-type-filter-container { display: flex; - font-size: 13px; - padding: 12px 0 12px 12px; + padding-bottom: 12px; + padding-inline: 20px; + padding-top: 12px; } .file-type-filter-button { - --border-color: var(--cros-button-stroke-color-secondary); + --border-color: var(--cros-sys-separator); --cr-button-height: 32px; - --hover-bg-color: var(--cros-ripple-color); - --hover-border-color: var(--cros-button-stroke-color-secondary); - --ink-color: var(--cros-ripple-color); + --hover-bg-color: var(--cros-sys-hover_on_subtle); + --hover-border-color: var(--cros-sys-separator); + --ink-color: var(--cros-sys-ripple_neutral_on_subtle); --ripple-opacity: 100%; - --text-color: var(--cros-text-color-secondary); - border-radius: 20px; + --text-color: var(--cros-sys-on_surface); + border-radius: 8px; margin-inline: 4px; min-width: auto; - outline: none; + padding-inline: 12px; } .file-type-filter-button.active { - /* Intentionally no hover color for active state. */ - --hover-bg-color: none; - --ink-color: var(--cros-ripple-color-prominent); - --text-color: var(--cros-text-color-selection); - background-color: var(--cros-highlight-color); - border-color: transparent; + --text-color: var(--cros-sys-on_secondary_container); + background-color: var(--cros-sys-secondary_container); } html.pointer-active .file-type-filter-button:not(:active) { @@ -2339,7 +2336,7 @@ } html.focus-outline-visible .file-type-filter-button:focus { - outline: 2px solid var(--cros-focus-ring-color); + outline: 2px solid var(--cros-sys-focus_ring); outline-offset: 2px; }
diff --git a/ui/file_manager/file_manager/foreground/js/file_manager_commands.js b/ui/file_manager/file_manager/foreground/js/file_manager_commands.js index ef446c9d..44a0036 100644 --- a/ui/file_manager/file_manager/foreground/js/file_manager_commands.js +++ b/ui/file_manager/file_manager/foreground/js/file_manager_commands.js
@@ -20,13 +20,11 @@ import {FakeEntry, FilesAppDirEntry, FilesAppEntry} from '../../externs/files_app_entry_interfaces.js'; import {VolumeInfo} from '../../externs/volume_info.js'; import {VolumeManager} from '../../externs/volume_manager.js'; -import {XfDlpRestrictionDetailsDialog} from '../../widgets/xf_dlp_restriction_details_dialog.js'; import {ActionsModel} from './actions_model.js'; import {constants} from './constants.js'; import {DirectoryModel} from './directory_model.js'; import {FileSelection, FileSelectionHandler} from './file_selection.js'; -import {TaskPickerType} from './file_tasks.js'; import {HoldingSpaceUtil} from './holding_space_util.js'; import {PathComponent} from './path_component.js'; import {Command} from './ui/command.js'; @@ -1781,6 +1779,20 @@ })(); /** + * Opens settings/files sub page. + */ +CommandHandler.COMMANDS_['files-settings'] = new (class extends FilesCommand { + execute(event, fileManager) { + chrome.fileManagerPrivate.openSettingsSubpage('files'); + } + + /** @override */ + canExecute(event, fileManager) { + event.canExecute = true; + } +})(); + +/** * Opens drive help. */ CommandHandler.COMMANDS_['volume-help'] = new (class extends FilesCommand {
diff --git a/ui/file_manager/file_manager/main.html b/ui/file_manager/file_manager/main.html index fedc3d2..637f615 100644 --- a/ui/file_manager/file_manager/main.html +++ b/ui/file_manager/file_manager/main.html
@@ -85,6 +85,7 @@ <command id="erase-device" label="$i18n{REPARTITION_DEVICE_BUTTON_LABEL}"> <command id="configure" label="$i18n{CONFIGURE_VOLUME_BUTTON_LABEL}"> + <command id="files-settings" label="$i18n{FILES_SETTINGS_LABEL}"> <command id="volume-help" label="$i18n{DRIVE_MENU_HELP}"> <command id="send-feedback" label="$i18n{SEND_FEEDBACK}"> <command id="volume-storage"> @@ -270,6 +271,8 @@ <cr-menu-item id="gear-menu-manage-mirrorsync" command="#manage-mirrorsync"></cr-menu-item> <hr id="help-separator"> + <cr-menu-item id="gear-menu-files-settings" + command="#files-settings"></cr-menu-item> <cr-menu-item id="gear-menu-drive-buy-more-space" command="#drive-buy-more-space"></cr-menu-item> <cr-menu-item id="gear-menu-drive-go-to-drive"
diff --git a/ui/file_manager/file_manager/widgets/xf_tree.ts b/ui/file_manager/file_manager/widgets/xf_tree.ts index 8db0c1e..88689ba 100644 --- a/ui/file_manager/file_manager/widgets/xf_tree.ts +++ b/ui/file_manager/file_manager/widgets/xf_tree.ts
@@ -40,6 +40,14 @@ this.selectItem_(item); } + /** Return the focused tree item, could be null. */ + get focusedItem(): XfTreeItem|null { + return this.focusedItem_; + } + set focusedItem(item: XfTreeItem|null) { + this.focusItem_(item); + } + /** The child tree items. */ get items(): XfTreeItem[] { return this.items_; @@ -308,10 +316,10 @@ * one tree item is selected in the tree. */ private selectItem_(itemToSelect: XfTreeItem|null) { - if (itemToSelect === this.selectedItem_) { + const previousSelectedItem = this.selectedItem_; + if (itemToSelect === previousSelectedItem) { return; } - const previousSelectedItem = this.selectedItem_; if (previousSelectedItem) { previousSelectedItem.selected = false; } @@ -334,17 +342,21 @@ } /** - * Make `itemToSelect` become the focused item in the tree, this will - * also unfocus the previously focused tree item to make sure at most - * one tree item is selected in the tree. + * Make `itemToFocus` become the focused item in the tree, this will + * also unfocus the previously focused tree item. */ - private focusItem_(itemToFocus: XfTreeItem) { + private focusItem_(itemToFocus: XfTreeItem|null) { const previousFocusedItem = this.focusedItem_; + if (previousFocusedItem === itemToFocus) { + return; + } if (previousFocusedItem) { previousFocusedItem.blur(); } this.focusedItem_ = itemToFocus; - this.focusedItem_.focus(); + if (this.focusedItem_) { + this.focusedItem_.focus(); + } } }
diff --git a/ui/file_manager/file_manager/widgets/xf_tree_item.ts b/ui/file_manager/file_manager/widgets/xf_tree_item.ts index 8c7120a..c3cad86e 100644 --- a/ui/file_manager/file_manager/widgets/xf_tree_item.ts +++ b/ui/file_manager/file_manager/widgets/xf_tree_item.ts
@@ -74,8 +74,6 @@ TREE_ITEM_EXPANDED: 'tree_item_expanded', /** Triggers when a tree item has been collapsed. */ TREE_ITEM_COLLAPSED: 'tree_item_collapsed', - /** Triggers when a tree item's label has been renamed. */ - TREE_ITEM_RENAMED: 'tree_item_renamed', } as const; } @@ -175,15 +173,11 @@ @state() private level_ = 1; @query('li') private $treeItem_!: HTMLLIElement; - @query('.rename') private $renameInput_?: HTMLInputElement; @query('slot:not([name])') private $childrenSlot_!: HTMLSlotElement; /** The child tree items. */ private items_: XfTreeItem[] = []; - /** Indicate if we should commit the rename on input blur or not. */ - private shouldRenameOnBlur_ = true; - override render() { const showExpandIcon = this.hasChildren() && !this.disabled; const treeRowStyles = { @@ -227,22 +221,9 @@ private renderTreeLabel() { if (this.editing) { - // Stop propagation of some events to prevent them being captured by - // tree when the tree item is in editing mode. - return html` - <input - class="rename" - type="text" - spellcheck="false" - .value=${this.label} - @click=${(e: MouseEvent) => e.stopPropagation()} - @dblclick=${(e: MouseEvent) => e.stopPropagation()} - @mouseup=${(e: MouseEvent) => e.stopPropagation()} - @mousedown=${(e: MouseEvent) => e.stopPropagation()} - @blur=${this.onRenameInputBlur_} - @keydown=${this.onRenameInputKeydown_} - /> - `; + // The render of <input> for renaming is handled by + // `DirectoryTreeNamingController`. + return html``; } return html` <span @@ -303,9 +284,6 @@ if (changedProperties.has('selected')) { this.onSelectedChanged_(); } - if (changedProperties.has('editing')) { - this.onEditingChanged_(); - } } private onExpandChanged_() { @@ -342,67 +320,6 @@ } } - private onEditingChanged_() { - if (this.editing) { - this.$renameInput_?.focus(); - this.$renameInput_?.select(); - } - } - - private onRenameInputKeydown_(e: KeyboardEvent) { - // Make sure that the tree does not handle the key. - e.stopPropagation(); - - if (e.repeat) { - return; - } - - // Calling this.focus blurs the input which will make the tree item - // non editable. - switch (e.key) { - case 'Escape': - // By default blur() will trigger the rename, but when ESC is pressed - // we don't want the blur() (triggered by focus() below) to commit - // the rename. - this.shouldRenameOnBlur_ = false; - this.focus(); - e.preventDefault(); - break; - case 'Enter': - // focus() will trigger blur() for the rename input which will commit - // the rename. - this.focus(); - e.preventDefault(); - break; - } - } - - private onRenameInputBlur_() { - this.editing = false; - if (this.shouldRenameOnBlur_) { - this.commitRename_(this.$renameInput_?.value || ''); - } else { - this.shouldRenameOnBlur_ = true; - } - } - - private commitRename_(newName: string) { - const isEmpty = newName.trim() === ''; - const isChanged = newName !== this.label; - if (isEmpty || !isChanged) { - return; - } - const oldLabel = this.label; - this.label = newName; - const renameEvent: TreeItemRenamedEvent = - new CustomEvent(XfTreeItem.events.TREE_ITEM_RENAMED, { - bubbles: true, - composed: true, - detail: {item: this, oldLabel, newLabel: newName}, - }); - this.dispatchEvent(renameEvent); - } - /** Update the level of the tree item by traversing upwards. */ private updateLevel_() { // Traverse upwards to determine the level. @@ -551,17 +468,6 @@ white-space: pre; } - .rename { - background-color: var(--cros-bg-color); - border-radius: 2px; - border: none; - caret-color: var(--cros-textfield-cursor-color-focus); - color: var(--cros-text-color-primary); - margin: 0 10px; - outline: 2px solid var(--cros-focus-ring-color); - overflow: hidden; - } - paper-ripple { display: none; } @@ -717,26 +623,6 @@ white-space: pre; } - .rename { - background-color: var(--cros-sys-app_base); - border-radius: 4px; - border: none; - color: var(--cros-sys-on_surface); - height: 20px; - margin: 0 10px; - outline: 2px solid var(--cros-sys-focus_ring); - overflow: hidden; - padding: 1px 8px; - } - - :host([selected]) .rename { - outline: 2px solid var(--cros-sys-inverse_primary); - } - - .rename::selection { - background-color: var(--cros-sys-highlight_text) - } - paper-ripple { border-radius: 20px; color: var(--cros-sys-ripple_primary); @@ -779,21 +665,11 @@ /** The tree item which has been collapsed. */ item: XfTreeItem, }>; -/** Type of the tree item collapsed custom event. */ -export type TreeItemRenamedEvent = CustomEvent<{ - /** The tree item which has been renamed. */ - item: XfTreeItem, - /** The label before rename. */ - oldLabel: string, - /** The label after rename. */ - newLabel: string, -}>; declare global { interface HTMLElementEventMap { [XfTreeItem.events.TREE_ITEM_EXPANDED]: TreeItemExpandedEvent; [XfTreeItem.events.TREE_ITEM_COLLAPSED]: TreeItemCollapsedEvent; - [XfTreeItem.events.TREE_ITEM_RENAMED]: TreeItemRenamedEvent; } interface HTMLElementTagNameMap {
diff --git a/ui/file_manager/file_manager/widgets/xf_tree_item_unittest.ts b/ui/file_manager/file_manager/widgets/xf_tree_item_unittest.ts index 9f3f261e..4562d7a 100644 --- a/ui/file_manager/file_manager/widgets/xf_tree_item_unittest.ts +++ b/ui/file_manager/file_manager/widgets/xf_tree_item_unittest.ts
@@ -10,7 +10,7 @@ import {XfIcon} from './xf_icon.js'; import {XfTree} from './xf_tree.js'; -import {TREE_ITEM_INDENT, TreeItemCollapsedEvent, TreeItemExpandedEvent, TreeItemRenamedEvent, XfTreeItem} from './xf_tree_item.js'; +import {TREE_ITEM_INDENT, TreeItemCollapsedEvent, TreeItemExpandedEvent, XfTreeItem} from './xf_tree_item.js'; /** Construct a single tree item. */ async function setUpSingleTreeItem() { @@ -422,112 +422,6 @@ done(); } -/** Tests rename of the tree item. */ -export async function testRenameTreeItem(done: () => void) { - await setUpSingleTreeItem(); - - // Check input should not exist by default. - const item1 = getTreeItemById('item1'); - assertFalse(item1.editing); - assertEquals(null, item1.shadowRoot!.querySelector('.rename')); - - // Rename item1 by enable editing mode. - item1.editing = true; - await waitForElementUpdate(item1); - let renameInput = - item1.shadowRoot!.querySelector<HTMLInputElement>('.rename')!; - assertNotEquals(null, renameInput); - - // Rename input should be focused and text should be selected. - assertEquals(renameInput, item1.shadowRoot!.activeElement); - assertEquals(0, renameInput.selectionStart); - assertEquals(item1.label.length, renameInput.selectionEnd); - - // Change text then cancel the rename. - renameInput.value = 'rename1'; - renameInput.dispatchEvent(new KeyboardEvent('keydown', {key: 'Escape'})); - await waitForElementUpdate(item1); - - // Check rename input is disappeared and the label is not changed. - assertEquals(null, item1.shadowRoot!.querySelector('.rename')); - const {treeLabel} = getTreeItemInnerElements(item1); - assertEquals(item1, document.activeElement); - assertFalse(item1.editing); - assertEquals('item1', treeLabel.textContent); - assertEquals('item1', item1.label); - - // Rename again and commit the change. - const renamedEventPromise: Promise<TreeItemRenamedEvent> = - eventToPromise(XfTreeItem.events.TREE_ITEM_RENAMED, item1); - item1.editing = true; - await waitForElementUpdate(item1); - renameInput = item1.shadowRoot!.querySelector<HTMLInputElement>('.rename')!; - renameInput.value = 'rename2'; - renameInput.dispatchEvent(new KeyboardEvent('keydown', {key: 'Enter'})); - await waitForElementUpdate(item1); - - // Check event is triggered and the label is changed. - assertEquals(null, item1.shadowRoot!.querySelector('.rename')); - const {treeLabel: treeLabelAfterRename} = getTreeItemInnerElements(item1); - assertEquals(item1, document.activeElement); - assertFalse(item1.editing); - assertEquals('rename2', treeLabelAfterRename.textContent); - assertEquals('rename2', item1.label); - const renamedEvent = await renamedEventPromise; - assertEquals(item1, renamedEvent.detail.item); - assertEquals('item1', renamedEvent.detail.oldLabel); - assertEquals('rename2', renamedEvent.detail.newLabel); - - done(); -} - -/** Tests that blur of rename input will commit the rename. */ -export async function testBlurToCommitRename(done: () => void) { - await setUpSingleTreeItem(); - - // Rename item1 by enable editing mode. - const item1 = getTreeItemById('item1'); - item1.editing = true; - await waitForElementUpdate(item1); - const renameInput = - item1.shadowRoot!.querySelector<HTMLInputElement>('.rename')!; - renameInput.value = 'new name'; - - // Check blur() should commit the rename. - renameInput.blur(); - await waitForElementUpdate(item1); - const {treeLabel} = getTreeItemInnerElements(item1); - assertFalse(item1.editing); - assertEquals('new name', treeLabel.textContent); - assertEquals('new name', item1.label); - - done(); -} - -/** Tests that empty string won't commit the rename. */ -export async function testNoRenameWithEmptyString(done: () => void) { - await setUpSingleTreeItem(); - - // Rename item1 by enable editing mode. - const item1 = getTreeItemById('item1'); - item1.editing = true; - await waitForElementUpdate(item1); - const renameInput = - item1.shadowRoot!.querySelector<HTMLInputElement>('.rename')!; - renameInput.value = ' '; - - // Check pressing Enter with empty string shouldn't commit the rename. - renameInput.dispatchEvent(new KeyboardEvent('keydown', {key: 'Enter'})); - await waitForElementUpdate(item1); - const {treeLabel} = getTreeItemInnerElements(item1); - assertEquals(item1, document.activeElement); - assertFalse(item1.editing); - assertEquals('item1', treeLabel.textContent); - assertEquals('item1', item1.label); - - done(); -} - /** Tests that iconSet has higher priority than icon property. */ export async function testIconSetIgnoreIcon(done: () => void) { await setUpSingleTreeItem();
diff --git a/ui/file_manager/integration_tests/file_manager/drive_specific.js b/ui/file_manager/integration_tests/file_manager/drive_specific.js index ab9cc83..bc678918 100644 --- a/ui/file_manager/integration_tests/file_manager/drive_specific.js +++ b/ui/file_manager/integration_tests/file_manager/drive_specific.js
@@ -1262,60 +1262,3 @@ chrome.test.assertEq(1, await getUserActionCount(userActionDismiss)); await remoteCall.waitForElement(appId, 'google-one-offer-banner[hidden]'); }; - -/** - * Test that when files get deleted locally, they get unpinned prior to being - * deleted. - */ -testcase.driveLocalDeleteUnpinsItem = async () => { - const appId = await setupAndWaitUntilReady(RootPath.DRIVE); - - // Select test.txt which is already pinned. - await remoteCall.waitAndClickElement( - appId, '#file-list [file-name="test.txt"]'); - await remoteCall.waitForElement( - appId, '[file-name="test.txt"][selected] xf-icon[type=offline]'); - - // Ensure the metadata for the file is set to pinned. - await remoteCall.expectDriveItemPinnedStatus(appId, '/root/test.txt', true); - - // Delete the file and ensure it disappears from the file list. - await remoteCall.waitAndClickElement( - appId, '#delete-button:not([hidden]):not([disabled])'); - // Check: the delete confirm dialog should appear. - await remoteCall.waitForElement(appId, '.cr-dialog-container.shown'); - - // Click the delete confirm dialog 'Delete' button. - const dialogDeleteButton = - await remoteCall.waitAndClickElement(appId, '.cr-dialog-ok'); - - await remoteCall.waitForElementLost( - appId, '#file-list [file-name="test.txt"]'); - - // Ensure the file was unpinned prior to deleting. - await remoteCall.expectDriveItemPinnedStatus(appId, '/root/test.txt', false); -}; - -/** - * Test that when files get deleted in the cloud, they get unpinned after being - * deleted. - */ -testcase.driveCloudDeleteUnpinsItem = async () => { - const appId = await setupAndWaitUntilReady(RootPath.DRIVE); - - // Select test.txt which is already pinned. - await remoteCall.waitAndClickElement( - appId, '#file-list [file-name="test.txt"]'); - await remoteCall.waitForElement( - appId, '[file-name="test.txt"][selected] xf-icon[type=offline]'); - - // Ensure the metadata for the file is set to pinned. - await remoteCall.expectDriveItemPinnedStatus(appId, '/root/test.txt', true); - - await remoteCall.sendDriveCloudDeleteEvent(appId, '/root/test.txt'); - await remoteCall.waitForElementLost( - appId, '#file-list [file-name="test.txt"]'); - - // Ensure the file was unpinned prior to deleting. - await remoteCall.expectDriveItemPinnedStatus(appId, '/root/test.txt', false); -};
diff --git a/ui/file_manager/integration_tests/file_manager/gear_menu.js b/ui/file_manager/integration_tests/file_manager/gear_menu.js index 8f70b278..d4169f3802 100644 --- a/ui/file_manager/integration_tests/file_manager/gear_menu.js +++ b/ui/file_manager/integration_tests/file_manager/gear_menu.js
@@ -410,6 +410,40 @@ }; /** + * Tests that the "Files settings" button appears in the gear menu and properly + * opens the Files section of the Settings page. + */ +testcase.showFilesSettingsButton = async () => { + const settingsWindowOrigin = 'chrome://os-settings'; + const filesSettingsWindowURL = 'chrome://os-settings/files'; + + // Open Files.App on Downloads and wait for the gear menu button to appear. + const appId = await openNewWindow(RootPath.DOWNLOADS); + await remoteCall.waitForElement(appId, '#gear-button'); + + // Click the gear menu button. + chrome.test.assertTrue(await remoteCall.callRemoteTestUtil( + 'fakeMouseClick', appId, ['#gear-button'])); + + // Wait for the gear menu to appear. + await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])'); + + // Check that there is no Settings window opened. + chrome.test.assertFalse( + await remoteCall.windowOriginExists(settingsWindowOrigin)); + + // Click #files-settings, which should be shown and enabled. + await remoteCall.waitAndClickElement( + appId, + '#gear-menu:not([hidden]) cr-menu-item' + + '[command=\'#files-settings\']' + + ':not([disabled]):not([hidden])'); + + // Check that the settings window is opened on the Files subpage. + await remoteCall.waitForLastOpenedBrowserTabUrl(filesSettingsWindowURL); +}; + +/** * Tests that the "Send feedback" button appears in the gear menu and properly * opens the feedback window. */
diff --git a/ui/file_manager/integration_tests/file_manager/search.js b/ui/file_manager/integration_tests/file_manager/search.js index 75d75e8c..5c733c7 100644 --- a/ui/file_manager/integration_tests/file_manager/search.js +++ b/ui/file_manager/integration_tests/file_manager/search.js
@@ -737,25 +737,27 @@ const singleSelectionPath = await remoteCall.waitForElement(appId, [ 'xf-path-display', ]); + chrome.test.assertFalse(singleSelectionPath.hidden); chrome.test.assertEq( - 'My files/Downloads', singleSelectionPath.attributes.path); - // Select now the desktop entry, too. Both are in the same - // directory, so the path should not change. + 'My files/Downloads/' + ENTRIES.hello.nameText, + singleSelectionPath.attributes.path); + // Select now the desktop entry, too. Two or more selected files, + // regardless of the directory in which they sit, result in no path. await remoteCall.waitAndClickElement( appId, `#file-list [file-name="${ENTRIES.desktop.nameText}"]`, {ctrl: true}); - const twoFilesOneFolderPath = await remoteCall.waitForElement(appId, [ + const twoFilesSelectedPath = await remoteCall.waitForElement(appId, [ 'xf-path-display', ]); - chrome.test.assertEq( - 'My files/Downloads', twoFilesOneFolderPath.attributes.path); + chrome.test.assertTrue(twoFilesSelectedPath.hidden); + chrome.test.assertEq('', twoFilesSelectedPath.attributes.path); await remoteCall.waitAndClickElement( appId, `#file-list [file-name="${ENTRIES.deeplyBurriedSmallJpeg.nameText}"]`, {ctrl: true}); - const threeFilesTwoFolderPath = await remoteCall.waitForElement(appId, [ + const threeFilesSelectedPath = await remoteCall.waitForElement(appId, [ 'xf-path-display', ]); - chrome.test.assertEq( - 'Multiple file locations', threeFilesTwoFolderPath.attributes.path); + chrome.test.assertTrue(threeFilesSelectedPath.hidden); + chrome.test.assertEq('', threeFilesSelectedPath.attributes.path); };
diff --git a/ui/views/controls/button/button.cc b/ui/views/controls/button/button.cc index 5513499..61c61384 100644 --- a/ui/views/controls/button/button.cc +++ b/ui/views/controls/button/button.cc
@@ -540,6 +540,8 @@ } if (GetEnabled()) node_data->SetDefaultActionVerb(ax::mojom::DefaultActionVerb::kPress); + + button_controller_->UpdateAccessibleNodeData(node_data); } void Button::VisibilityChanged(View* starting_from, bool visible) {
diff --git a/ui/views/controls/button/button_controller.cc b/ui/views/controls/button/button_controller.cc index 404033706..b27d698 100644 --- a/ui/views/controls/button/button_controller.cc +++ b/ui/views/controls/button/button_controller.cc
@@ -137,6 +137,8 @@ } } +void ButtonController::UpdateAccessibleNodeData(ui::AXNodeData* node_data) {} + bool ButtonController::IsTriggerableEvent(const ui::Event& event) { return event.type() == ui::ET_GESTURE_TAP_DOWN || event.type() == ui::ET_GESTURE_TAP ||
diff --git a/ui/views/controls/button/button_controller.h b/ui/views/controls/button/button_controller.h index 3f3cb40..941586c6 100644 --- a/ui/views/controls/button/button_controller.h +++ b/ui/views/controls/button/button_controller.h
@@ -50,6 +50,9 @@ virtual bool OnKeyReleased(const ui::KeyEvent& event); virtual void OnGestureEvent(ui::GestureEvent* event); + // Updates |node_data| for a button based on the functionality. + virtual void UpdateAccessibleNodeData(ui::AXNodeData* node_data); + // Methods that parallel respective methods in Button: virtual bool IsTriggerableEvent(const ui::Event& event);
diff --git a/ui/views/controls/button/checkbox.cc b/ui/views/controls/button/checkbox.cc index da305daa1..fb0b27ab 100644 --- a/ui/views/controls/button/checkbox.cc +++ b/ui/views/controls/button/checkbox.cc
@@ -91,8 +91,6 @@ // Avoid the default ink-drop mask to allow the ripple effect to extend beyond // the checkbox view (otherwise it gets clipped which looks weird). views::InstallEmptyHighlightPathGenerator(this); - - SetAccessibilityProperties(ax::mojom::Role::kCheckBox); } Checkbox::~Checkbox() = default; @@ -148,6 +146,7 @@ void Checkbox::GetAccessibleNodeData(ui::AXNodeData* node_data) { LabelButton::GetAccessibleNodeData(node_data); + node_data->role = ax::mojom::Role::kCheckBox; const ax::mojom::CheckedState checked_state = GetChecked() ? ax::mojom::CheckedState::kTrue : ax::mojom::CheckedState::kFalse;
diff --git a/ui/views/controls/button/checkbox_unittest.cc b/ui/views/controls/button/checkbox_unittest.cc index f041472..69ac9fd9 100644 --- a/ui/views/controls/button/checkbox_unittest.cc +++ b/ui/views/controls/button/checkbox_unittest.cc
@@ -61,24 +61,10 @@ ui::AXNodeData ax_data; checkbox()->GetAccessibleNodeData(&ax_data); + EXPECT_EQ(ax_data.GetString16Attribute(ax::mojom::StringAttribute::kName), label_text); - EXPECT_EQ(checkbox()->GetAccessibleName(), label_text); EXPECT_EQ(ax_data.role, ax::mojom::Role::kCheckBox); - EXPECT_EQ(checkbox()->GetAccessibleRole(), ax::mojom::Role::kCheckBox); - EXPECT_EQ(ax_data.GetCheckedState(), ax::mojom::CheckedState::kFalse); - - ax_data = ui::AXNodeData(); - checkbox()->SetChecked(true); - checkbox()->GetAccessibleNodeData(&ax_data); - EXPECT_EQ(ax_data.GetCheckedState(), ax::mojom::CheckedState::kTrue); - - ax_data = ui::AXNodeData(); - checkbox()->SetAccessibleRole(ax::mojom::Role::kMenuItemCheckBox); - checkbox()->GetAccessibleNodeData(&ax_data); - EXPECT_EQ(ax_data.role, ax::mojom::Role::kMenuItemCheckBox); - EXPECT_EQ(checkbox()->GetAccessibleRole(), - ax::mojom::Role::kMenuItemCheckBox); } } // namespace views
diff --git a/ui/views/controls/button/image_button.cc b/ui/views/controls/button/image_button.cc index c0255128..cb799d8 100644 --- a/ui/views/controls/button/image_button.cc +++ b/ui/views/controls/button/image_button.cc
@@ -292,7 +292,6 @@ ToggleImageButton::ToggleImageButton(PressedCallback callback) : ImageButton(std::move(callback)) { - SetAccessibilityProperties(ax::mojom::Role::kToggleButton); } ToggleImageButton::~ToggleImageButton() = default; @@ -343,11 +342,6 @@ void ToggleImageButton::SetToggledTooltipText(const std::u16string& tooltip) { if (tooltip == toggled_tooltip_text_) return; - - if (toggled_accessible_name_.empty() && !tooltip.empty()) { - SetAccessibleName(tooltip); - } - toggled_tooltip_text_ = tooltip; OnPropertyChanged(&toggled_tooltip_text_, kPropertyEffectsNone); } @@ -359,14 +353,7 @@ void ToggleImageButton::SetToggledAccessibleName(const std::u16string& name) { if (name == toggled_accessible_name_) return; - toggled_accessible_name_ = name; - if (!toggled_accessible_name_.empty()) { - SetAccessibleName(toggled_accessible_name_); - } else if (!toggled_tooltip_text_.empty()) { - SetAccessibleName(toggled_tooltip_text_); - } - OnPropertyChanged(&toggled_accessible_name_, kPropertyEffectsNone); } @@ -414,6 +401,11 @@ if (!toggled_) return; + if (!toggled_accessible_name_.empty()) + node_data->SetName(toggled_accessible_name_); + else if (!toggled_tooltip_text_.empty()) + node_data->SetName(toggled_tooltip_text_); + // Use the visual pressed image as a cue for making this control into an // accessible toggle button. if ((toggled_ && !images_[ButtonState::STATE_NORMAL].IsEmpty()) ||
diff --git a/ui/views/controls/button/image_button.h b/ui/views/controls/button/image_button.h index 8da5ac8d..1241f13 100644 --- a/ui/views/controls/button/image_button.h +++ b/ui/views/controls/button/image_button.h
@@ -176,17 +176,10 @@ Background* GetToggledBackground() const { return toggled_background_.get(); } // Get/Set the tooltip text displayed when the button is toggled. - // TODO(accessibility): This seems like it provides a fallback name. - // Should callers who want this to be the name use `SetAccessibleName`? - // If it should be a description, then `SetAccessibleDescription`? - // Note that if something lacks an accessible description but has a tooltip, - // the tooltip text will be used. Does the tooltip text match this text? std::u16string GetToggledTooltipText() const; void SetToggledTooltipText(const std::u16string& tooltip); // Get/Set the accessible text used when the button is toggled. - // TODO(accessibility): Can we just use the `AccessibleName` getter/setter - // from View? std::u16string GetToggledAccessibleName() const; void SetToggledAccessibleName(const std::u16string& name);
diff --git a/ui/views/controls/button/image_button_unittest.cc b/ui/views/controls/button/image_button_unittest.cc index f7611802..5c6567bd 100644 --- a/ui/views/controls/button/image_button_unittest.cc +++ b/ui/views/controls/button/image_button_unittest.cc
@@ -197,34 +197,4 @@ EXPECT_EQ(1, parent.pref_size_changed_calls()); } -TEST_F(ImageButtonTest, ImageButtonAccessibleProperties) { - ImageButton button; - ui::AXNodeData data; - button.GetAccessibleNodeData(&data); - EXPECT_EQ(data.role, ax::mojom::Role::kButton); - EXPECT_EQ(button.GetAccessibleRole(), ax::mojom::Role::kButton); - - button.SetAccessibleRole(ax::mojom::Role::kPopUpButton); - - data = ui::AXNodeData(); - button.GetAccessibleNodeData(&data); - EXPECT_EQ(data.role, ax::mojom::Role::kPopUpButton); - EXPECT_EQ(button.GetAccessibleRole(), ax::mojom::Role::kPopUpButton); -} - -TEST_F(ImageButtonTest, ToggleImageButtonAccessibleProperties) { - ToggleImageButton button; - ui::AXNodeData data; - button.GetAccessibleNodeData(&data); - EXPECT_EQ(data.role, ax::mojom::Role::kToggleButton); - EXPECT_EQ(button.GetAccessibleRole(), ax::mojom::Role::kToggleButton); - - button.SetAccessibleRole(ax::mojom::Role::kPopUpButton); - - data = ui::AXNodeData(); - button.GetAccessibleNodeData(&data); - EXPECT_EQ(data.role, ax::mojom::Role::kPopUpButton); - EXPECT_EQ(button.GetAccessibleRole(), ax::mojom::Role::kPopUpButton); -} - } // namespace views
diff --git a/ui/views/controls/button/menu_button.cc b/ui/views/controls/button/menu_button.cc index 3203d471..b1d3b76 100644 --- a/ui/views/controls/button/menu_button.cc +++ b/ui/views/controls/button/menu_button.cc
@@ -7,7 +7,6 @@ #include <memory> #include <utility> -#include "ui/accessibility/ax_enums.mojom.h" #include "ui/base/metadata/metadata_impl_macros.h" #include "ui/events/event.h" #include "ui/views/controls/button/button_controller_delegate.h" @@ -29,7 +28,6 @@ SetButtonController(std::move(menu_button_controller)); SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); - SetAccessibilityProperties(ax::mojom::Role::kPopUpButton); } MenuButton::~MenuButton() = default; @@ -42,14 +40,6 @@ menu_button_controller_->SetCallback(std::move(callback)); } -void MenuButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { - LabelButton::GetAccessibleNodeData(node_data); - node_data->SetHasPopup(ax::mojom::HasPopup::kMenu); - if (GetEnabled()) { - node_data->SetDefaultActionVerb(ax::mojom::DefaultActionVerb::kOpen); - } -} - void MenuButton::NotifyClick(const ui::Event& event) { // Run pressed callback via MenuButtonController, instead of directly. button_controller()->Activate(&event);
diff --git a/ui/views/controls/button/menu_button.h b/ui/views/controls/button/menu_button.h index 53ba2b8..db8131d 100644 --- a/ui/views/controls/button/menu_button.h +++ b/ui/views/controls/button/menu_button.h
@@ -41,7 +41,6 @@ // Button: void SetCallback(PressedCallback callback) override; - void GetAccessibleNodeData(ui::AXNodeData* node_data) override; protected: // Button:
diff --git a/ui/views/controls/button/menu_button_controller.cc b/ui/views/controls/button/menu_button_controller.cc index 4a2dd57..4eb3e629 100644 --- a/ui/views/controls/button/menu_button_controller.cc +++ b/ui/views/controls/button/menu_button_controller.cc
@@ -8,6 +8,7 @@ #include "base/functional/bind.h" #include "ui/accessibility/ax_enums.mojom.h" +#include "ui/accessibility/ax_node_data.h" #include "ui/base/dragdrop/drag_drop_types.h" #include "ui/base/interaction/element_identifier.h" #include "ui/events/event_constants.h" @@ -176,6 +177,13 @@ return false; } +void MenuButtonController::UpdateAccessibleNodeData(ui::AXNodeData* node_data) { + node_data->role = ax::mojom::Role::kPopUpButton; + node_data->SetHasPopup(ax::mojom::HasPopup::kMenu); + if (button()->GetEnabled()) + node_data->SetDefaultActionVerb(ax::mojom::DefaultActionVerb::kOpen); +} + bool MenuButtonController::IsTriggerableEvent(const ui::Event& event) { return ButtonController::IsTriggerableEvent(event) && IsTriggerableEventType(event) && is_intentional_menu_trigger_;
diff --git a/ui/views/controls/button/menu_button_controller.h b/ui/views/controls/button/menu_button_controller.h index 358e420..7f23dbe7 100644 --- a/ui/views/controls/button/menu_button_controller.h +++ b/ui/views/controls/button/menu_button_controller.h
@@ -59,6 +59,7 @@ bool OnKeyPressed(const ui::KeyEvent& event) override; bool OnKeyReleased(const ui::KeyEvent& event) override; void OnGestureEvent(ui::GestureEvent* event) override; + void UpdateAccessibleNodeData(ui::AXNodeData* node_data) override; bool IsTriggerableEvent(const ui::Event& event) override; // Calls TakeLock with is_sibling_menu_show as false and a nullptr to the
diff --git a/ui/views/controls/button/menu_button_unittest.cc b/ui/views/controls/button/menu_button_unittest.cc index b8c6ace..2c4ff9e2 100644 --- a/ui/views/controls/button/menu_button_unittest.cc +++ b/ui/views/controls/button/menu_button_unittest.cc
@@ -610,23 +610,4 @@ button()->OnGestureEvent(&gesture_event); } -TEST_F(MenuButtonTest, AccessibleProperties) { - ConfigureMenuButton(std::make_unique<TestMenuButton>()); - ui::AXNodeData data; - button()->GetAccessibleNodeData(&data); - EXPECT_EQ(button()->GetAccessibleRole(), ax::mojom::Role::kPopUpButton); - EXPECT_EQ(data.role, ax::mojom::Role::kPopUpButton); - EXPECT_EQ(data.GetHasPopup(), ax::mojom::HasPopup::kMenu); - EXPECT_EQ(data.GetDefaultActionVerb(), ax::mojom::DefaultActionVerb::kOpen); - - button()->SetAccessibleRole(ax::mojom::Role::kButton); - - data = ui::AXNodeData(); - button()->GetAccessibleNodeData(&data); - EXPECT_EQ(button()->GetAccessibleRole(), ax::mojom::Role::kButton); - EXPECT_EQ(data.role, ax::mojom::Role::kButton); - EXPECT_EQ(data.GetHasPopup(), ax::mojom::HasPopup::kMenu); - EXPECT_EQ(data.GetDefaultActionVerb(), ax::mojom::DefaultActionVerb::kOpen); -} - } // namespace views
diff --git a/ui/views/controls/button/radio_button.cc b/ui/views/controls/button/radio_button.cc index 18665f0..4b61c2d1 100644 --- a/ui/views/controls/button/radio_button.cc +++ b/ui/views/controls/button/radio_button.cc
@@ -9,6 +9,7 @@ #include "base/ranges/algorithm.h" #include "ui/accessibility/ax_action_data.h" #include "ui/accessibility/ax_enums.mojom.h" +#include "ui/accessibility/ax_node_data.h" #include "ui/base/metadata/metadata_impl_macros.h" #include "ui/base/resource/resource_bundle.h" #include "ui/events/event_utils.h" @@ -32,11 +33,15 @@ RadioButton::RadioButton(const std::u16string& label, int group_id) : Checkbox(label) { SetGroup(group_id); - SetAccessibilityProperties(ax::mojom::Role::kRadioButton); } RadioButton::~RadioButton() = default; +void RadioButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { + Checkbox::GetAccessibleNodeData(node_data); + node_data->role = ax::mojom::Role::kRadioButton; +} + View* RadioButton::GetSelectedViewForGroup(int group) { Views views; GetViewsInGroupFromParent(group, &views);
diff --git a/ui/views/controls/button/radio_button.h b/ui/views/controls/button/radio_button.h index 7a4a53e..d4114df 100644 --- a/ui/views/controls/button/radio_button.h +++ b/ui/views/controls/button/radio_button.h
@@ -28,6 +28,7 @@ ~RadioButton() override; // Overridden from View: + void GetAccessibleNodeData(ui::AXNodeData* node_data) override; View* GetSelectedViewForGroup(int group) override; bool HandleAccessibleAction(const ui::AXActionData& action_data) override; bool IsGroupFocusTraversable() const override;
diff --git a/ui/views/controls/button/radio_button_unittest.cc b/ui/views/controls/button/radio_button_unittest.cc index f9cf8ad5..20a45fb 100644 --- a/ui/views/controls/button/radio_button_unittest.cc +++ b/ui/views/controls/button/radio_button_unittest.cc
@@ -131,28 +131,4 @@ EXPECT_EQ(button1, focus_manager->GetFocusedView()); } -TEST_F(RadioButtonTest, AccessibilityTest) { - RadioButton* button = new RadioButton(u"Item 1", kGroup); - ui::AXNodeData data; - button->GetAccessibleNodeData(&data); - - EXPECT_EQ(data.GetString16Attribute(ax::mojom::StringAttribute::kName), - u"Item 1"); - EXPECT_EQ(button->GetAccessibleName(), u"Item 1"); - EXPECT_EQ(data.role, ax::mojom::Role::kRadioButton); - EXPECT_EQ(button->GetAccessibleRole(), ax::mojom::Role::kRadioButton); - EXPECT_EQ(data.GetCheckedState(), ax::mojom::CheckedState::kFalse); - - data = ui::AXNodeData(); - button->SetChecked(true); - button->GetAccessibleNodeData(&data); - EXPECT_EQ(data.GetCheckedState(), ax::mojom::CheckedState::kTrue); - - data = ui::AXNodeData(); - button->SetAccessibleRole(ax::mojom::Role::kMenuItemRadio); - button->GetAccessibleNodeData(&data); - EXPECT_EQ(data.role, ax::mojom::Role::kMenuItemRadio); - EXPECT_EQ(button->GetAccessibleRole(), ax::mojom::Role::kMenuItemRadio); -} - } // namespace views
diff --git a/ui/views/controls/button/toggle_button.cc b/ui/views/controls/button/toggle_button.cc index ca0a0e9..d1056314 100644 --- a/ui/views/controls/button/toggle_button.cc +++ b/ui/views/controls/button/toggle_button.cc
@@ -292,8 +292,6 @@ SetInstallFocusRingOnFocus(true); FocusRing::Get(this)->SetPathGenerator( std::make_unique<FocusRingHighlightPathGenerator>()); - - SetAccessibilityProperties(ax::mojom::Role::kSwitch); } ToggleButton::~ToggleButton() { @@ -524,6 +522,8 @@ void ToggleButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { Button::GetAccessibleNodeData(node_data); + + node_data->role = ax::mojom::Role::kSwitch; node_data->SetCheckedState(GetIsOn() ? ax::mojom::CheckedState::kTrue : ax::mojom::CheckedState::kFalse); }
diff --git a/ui/views/controls/button/toggle_button.h b/ui/views/controls/button/toggle_button.h index 1d719fe..04f4d6e 100644 --- a/ui/views/controls/button/toggle_button.h +++ b/ui/views/controls/button/toggle_button.h
@@ -81,7 +81,6 @@ friend class TestToggleButton; class FocusRingHighlightPathGenerator; class ThumbView; - FRIEND_TEST_ALL_PREFIXES(ToggleButtonTest, AccessibilityTest); // Updates position of the thumb. void UpdateThumb();
diff --git a/ui/views/controls/button/toggle_button_unittest.cc b/ui/views/controls/button/toggle_button_unittest.cc index 74d34aa..59357c8 100644 --- a/ui/views/controls/button/toggle_button_unittest.cc +++ b/ui/views/controls/button/toggle_button_unittest.cc
@@ -152,28 +152,4 @@ EXPECT_FALSE(button()->GetIsOn()); } -TEST_F(ToggleButtonTest, AccessibilityTest) { - button()->SetAccessibleName(u"Name"); - ui::AXNodeData data; - button()->GetAccessibleNodeData(&data); - - EXPECT_EQ(data.GetString16Attribute(ax::mojom::StringAttribute::kName), - u"Name"); - EXPECT_EQ(button()->GetAccessibleName(), u"Name"); - EXPECT_EQ(data.role, ax::mojom::Role::kSwitch); - EXPECT_EQ(button()->GetAccessibleRole(), ax::mojom::Role::kSwitch); - EXPECT_EQ(data.GetCheckedState(), ax::mojom::CheckedState::kFalse); - - data = ui::AXNodeData(); - button()->SetIsOn(true); - button()->GetAccessibleNodeData(&data); - EXPECT_EQ(data.GetCheckedState(), ax::mojom::CheckedState::kTrue); - - data = ui::AXNodeData(); - button()->SetAccessibleRole(ax::mojom::Role::kCheckBox); - button()->GetAccessibleNodeData(&data); - EXPECT_EQ(data.role, ax::mojom::Role::kCheckBox); - EXPECT_EQ(button()->GetAccessibleRole(), ax::mojom::Role::kCheckBox); -} - } // namespace views
diff --git a/weblayer/browser/java/org/chromium/weblayer_private/WebLayerImpl.java b/weblayer/browser/java/org/chromium/weblayer_private/WebLayerImpl.java index a9c2f40..fda6b459 100644 --- a/weblayer/browser/java/org/chromium/weblayer_private/WebLayerImpl.java +++ b/weblayer/browser/java/org/chromium/weblayer_private/WebLayerImpl.java
@@ -215,6 +215,9 @@ if (mOnNativeLoadedCalled) return; mOnNativeLoadedCalled = true; + // TODO(swestphal): Move this earlier when it is not depending on native code being loaded. + ChildProcessLauncherHelper.warmUp(appContext, true); + CrashReporterControllerImpl.getInstance().notifyNativeInitialized(); NetworkChangeNotifier.init(); NetworkChangeNotifier.registerToReceiveNotificationsAlways(); @@ -308,7 +311,6 @@ BundleUtils.setIsBundle(ProductConfig.IS_BUNDLE); setChildProcessCreationParams(wrappedAppContext, packageInfo.packageName); - ChildProcessLauncherHelper.warmUp(wrappedAppContext, true); // Creating the Android shared preferences object causes I/O. try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) {
diff --git a/weblayer/shell/android/BUILD.gn b/weblayer/shell/android/BUILD.gn index ec9637b..1a1062c 100644 --- a/weblayer/shell/android/BUILD.gn +++ b/weblayer/shell/android/BUILD.gn
@@ -150,8 +150,8 @@ "webengine_shell_apk/src/org/chromium/webengine/shell/WebEngineNavigationTestActivity.java", "webengine_shell_apk/src/org/chromium/webengine/shell/WebEngineShellActivity.java", "webengine_shell_apk/src/org/chromium/webengine/shell/WebEngineStateTestActivity.java", + "webengine_shell_apk/src/org/chromium/webengine/shell/topbar/TabEventsDelegate.java", "webengine_shell_apk/src/org/chromium/webengine/shell/topbar/TabEventsObserver.java", - "webengine_shell_apk/src/org/chromium/webengine/shell/topbar/TopBarObservers.java", ] deps = [
diff --git a/weblayer/shell/android/webengine_shell_apk/src/org/chromium/webengine/shell/WebEngineShellActivity.java b/weblayer/shell/android/webengine_shell_apk/src/org/chromium/webengine/shell/WebEngineShellActivity.java index 2c46db82..29add0322 100644 --- a/weblayer/shell/android/webengine_shell_apk/src/org/chromium/webengine/shell/WebEngineShellActivity.java +++ b/weblayer/shell/android/webengine_shell_apk/src/org/chromium/webengine/shell/WebEngineShellActivity.java
@@ -44,8 +44,8 @@ import org.chromium.webengine.WebEngine; import org.chromium.webengine.WebFragment; import org.chromium.webengine.WebSandbox; +import org.chromium.webengine.shell.topbar.TabEventsDelegate; import org.chromium.webengine.shell.topbar.TabEventsObserver; -import org.chromium.webengine.shell.topbar.TopBarObservers; import java.util.Arrays; @@ -68,6 +68,7 @@ private WebSandbox mWebSandbox; private TabManager mTabManager; + private TabEventsDelegate mTabEventsDelegate; private ProgressBar mProgressBar; private EditText mUrlBar; @@ -91,7 +92,6 @@ mDefaultTabListObserver = new DefaultObservers(); setupActivitySpinner((Spinner) findViewById(R.id.activity_nav), this, 0); - mProgressBar = findViewById(R.id.progress_bar); mUrlBar = findViewById(R.id.url_bar); mTabCountButton = findViewById(R.id.tab_count); @@ -191,6 +191,17 @@ mTabManager = webEngine.getTabManager(); + mTabEventsDelegate = new TabEventsDelegate(mTabManager); + mTabEventsDelegate.registerObserver(this); + + mTabCountButton.setText(String.valueOf(getTabsCount())); + mTabListAdapter = new ArrayAdapter<TabWrapper>( + this, android.R.layout.simple_spinner_dropdown_item); + for (Tab t : mTabManager.getAllTabs()) { + mTabListAdapter.add(new TabWrapper(t)); + } + mTabListSpinner.setAdapter(mTabListAdapter); + for (Tab tab : mTabManager.getAllTabs()) { tab.setFullscreenCallback(this); } @@ -216,7 +227,6 @@ Tab activeTab = mTabManager.getActiveTab(); mTabCountButton.setText(String.valueOf(getTabsCount())); - mTabListAdapter = new ArrayAdapter<TabWrapper>(this, android.R.layout.simple_spinner_dropdown_item); for (Tab t : mTabManager.getAllTabs()) { @@ -224,7 +234,8 @@ } mTabListSpinner.setAdapter(mTabListAdapter); - new TopBarObservers(this, mTabManager); + mTabEventsDelegate = new TabEventsDelegate(mTabManager); + mTabEventsDelegate.registerObserver(this); activeTab.setFullscreenCallback(this); mTabManager.registerTabListObserver(new TabListObserver() { @@ -299,6 +310,7 @@ for (Tab tab : mTabManager.getAllTabs()) { tab.setFullscreenCallback(null); } + mTabEventsDelegate.unregisterObservers(); } @Override @@ -397,32 +409,38 @@ } } + public int getTabsCount() { + if (mTabManager == null) { + return 0; + } + return mTabManager.getAllTabs().size(); + } + @Override - public void setUrlBar(String uri) { + public void onVisibleUriChanged(String uri) { mUrlBar.setText(uri); } @Override - public void setProgress(double progress) { - int progressValue = (int) Math.rint(progress * 100); - if (progressValue != mProgressBar.getMax()) { - mReloadButton.setImageDrawable(mStopDrawable); - mProgressBar.setVisibility(View.VISIBLE); - } else { - mReloadButton.setImageDrawable(mRefreshDrawable); - mProgressBar.setVisibility(View.INVISIBLE); + public void onActiveTabChanged(Tab activeTab) { + mUrlBar.setText(activeTab.getDisplayUri().toString()); + for (int position = 0; position < mTabListAdapter.getCount(); ++position) { + TabWrapper tabWrapper = mTabListAdapter.getItem(position); + if (tabWrapper.getTab().equals(activeTab)) { + mTabListSpinner.setSelection(position); + return; + } } - mProgressBar.setProgress(progressValue); } @Override - public void addTabToList(Tab tab) { + public void onTabAdded(Tab tab) { mTabCountButton.setText(String.valueOf(getTabsCount())); mTabListAdapter.add(new TabWrapper(tab)); } @Override - public void removeTabFromList(Tab tab) { + public void onTabRemoved(Tab tab) { mTabCountButton.setText(String.valueOf(getTabsCount())); for (int position = 0; position < mTabListAdapter.getCount(); ++position) { TabWrapper tabAdapter = mTabListAdapter.getItem(position); @@ -434,18 +452,16 @@ } @Override - public void setTabListSelection(Tab tab) { - for (int position = 0; position < mTabListAdapter.getCount(); ++position) { - TabWrapper tabWrapper = mTabListAdapter.getItem(position); - if (tabWrapper.getTab().equals(tab)) { - mTabListSpinner.setSelection(mTabListAdapter.getPosition(tabWrapper)); - return; - } + public void onLoadProgressChanged(double progress) { + int progressValue = (int) Math.rint(progress * 100); + if (progressValue != mProgressBar.getMax()) { + mReloadButton.setImageDrawable(mStopDrawable); + mProgressBar.setVisibility(View.VISIBLE); + } else { + mReloadButton.setImageDrawable(mRefreshDrawable); + mProgressBar.setVisibility(View.INVISIBLE); } - } - - public int getTabsCount() { - return mTabManager.getAllTabs().size(); + mProgressBar.setProgress(progressValue); } static class TabWrapper {
diff --git a/weblayer/shell/android/webengine_shell_apk/src/org/chromium/webengine/shell/topbar/TopBarObservers.java b/weblayer/shell/android/webengine_shell_apk/src/org/chromium/webengine/shell/topbar/TabEventsDelegate.java similarity index 60% rename from weblayer/shell/android/webengine_shell_apk/src/org/chromium/webengine/shell/topbar/TopBarObservers.java rename to weblayer/shell/android/webengine_shell_apk/src/org/chromium/webengine/shell/topbar/TabEventsDelegate.java index 4529cdf..fa79d5a8 100644 --- a/weblayer/shell/android/webengine_shell_apk/src/org/chromium/webengine/shell/topbar/TopBarObservers.java +++ b/weblayer/shell/android/webengine_shell_apk/src/org/chromium/webengine/shell/topbar/TabEventsDelegate.java
@@ -16,28 +16,46 @@ import org.chromium.webengine.WebEngine; /** - * Top Bar observers for Test Activities. + * Delegate for Tab Events. */ -public class TopBarObservers implements TabObserver, NavigationObserver, TabListObserver { - final TabEventsObserver mTabEventsObserver; - final TabManager mTabManager; - public TopBarObservers(TabEventsObserver tabEventObserver, TabManager tabManager) { - mTabEventsObserver = tabEventObserver; - mTabManager = tabManager; +public class TabEventsDelegate implements TabObserver, NavigationObserver, TabListObserver { + private TabEventsObserver mTabEventsObserver; + private final TabManager mTabManager; + public TabEventsDelegate(TabManager tabManager) { + mTabManager = tabManager; + } + + // Registers only one TabEventsObserver. + public void registerObserver(TabEventsObserver tabEventsObserver) { + mTabEventsObserver = tabEventsObserver; mTabManager.registerTabListObserver(this); - mTabManager.getActiveTab().getNavigationController().registerNavigationObserver(this); - mTabManager.getActiveTab().registerTabObserver(this); + for (Tab t : mTabManager.getAllTabs()) { + t.getNavigationController().registerNavigationObserver(this); + t.registerTabObserver(this); + } + } + + public void unregisterObservers() { + mTabEventsObserver = null; + mTabManager.unregisterTabListObserver(this); + for (Tab t : mTabManager.getAllTabs()) { + t.getNavigationController().unregisterNavigationObserver(this); + t.unregisterTabObserver(this); + } } // TabObserver implementation. @Override public void onVisibleUriChanged(@NonNull Tab tab, @NonNull String uri) { + if (mTabEventsObserver == null) { + return; + } if (!isTabActive(tab)) { return; } - mTabEventsObserver.setUrlBar(uri); + mTabEventsObserver.onVisibleUriChanged(uri); } @Override @@ -50,24 +68,32 @@ @Override public void onActiveTabChanged(@NonNull WebEngine webEngine, @Nullable Tab activeTab) { + if (mTabEventsObserver == null) { + return; + } if (activeTab == null) { return; } - mTabEventsObserver.setUrlBar(activeTab.getDisplayUri().toString()); - mTabEventsObserver.setTabListSelection(activeTab); + mTabEventsObserver.onActiveTabChanged(activeTab); } @Override public void onTabAdded(@NonNull WebEngine webEngine, @NonNull Tab tab) { - mTabEventsObserver.addTabToList(tab); - // Recursively add tab and navigation observers to any new tab. + if (mTabEventsObserver == null) { + return; + } + mTabEventsObserver.onTabAdded(tab); + tab.registerTabObserver(this); tab.getNavigationController().registerNavigationObserver(this); } @Override public void onTabRemoved(@NonNull WebEngine webEngine, @NonNull Tab tab) { - mTabEventsObserver.removeTabFromList(tab); + if (mTabEventsObserver == null) { + return; + } + mTabEventsObserver.onTabRemoved(tab); } @Override @@ -88,10 +114,13 @@ @Override public void onLoadProgressChanged(@NonNull Tab tab, double progress) { + if (mTabEventsObserver == null) { + return; + } if (!isTabActive(tab)) { return; } - mTabEventsObserver.setProgress(progress); + mTabEventsObserver.onLoadProgressChanged(progress); } boolean isTabActive(Tab tab) {
diff --git a/weblayer/shell/android/webengine_shell_apk/src/org/chromium/webengine/shell/topbar/TabEventsObserver.java b/weblayer/shell/android/webengine_shell_apk/src/org/chromium/webengine/shell/topbar/TabEventsObserver.java index 2dfa8e2..860aaa2 100644 --- a/weblayer/shell/android/webengine_shell_apk/src/org/chromium/webengine/shell/topbar/TabEventsObserver.java +++ b/weblayer/shell/android/webengine_shell_apk/src/org/chromium/webengine/shell/topbar/TabEventsObserver.java
@@ -10,13 +10,13 @@ * An interface for setting values in the Top Bar. */ public interface TabEventsObserver { - void setUrlBar(String uri); + void onVisibleUriChanged(String uri); - void setProgress(double progress); + void onActiveTabChanged(Tab activeTab); - void addTabToList(Tab tab); + void onTabAdded(Tab tab); - void removeTabFromList(Tab tab); + void onTabRemoved(Tab tab); - void setTabListSelection(Tab tab); + void onLoadProgressChanged(double progress); }