Document PiP: Improve standalone window parity with browser-backed [chromium/src : main]

0 views
Skip to first unread message

Jiayu Chen (Gerrit)

unread,
Jun 23, 2026, 10:11:25 AM (2 days ago) Jun 23
to Thomas Lukaszewicz, Qikai Zhong, Chromium LUCI CQ, chromium...@chromium.org, mac-r...@chromium.org
Attention needed from Qikai Zhong and Thomas Lukaszewicz

Jiayu Chen added 1 comment

Patchset-level comments
File-level comment, Patchset 11 (Latest):
Jiayu Chen . resolved

Hi reviewers, could u help review this when available? Thx.

Open in Gerrit

Related details

Attention is currently required from:
  • Qikai Zhong
  • Thomas Lukaszewicz
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I9970b8daf4ff570c596467ef483d184d3f49923f
Gerrit-Change-Number: 7953781
Gerrit-PatchSet: 11
Gerrit-Owner: Jiayu Chen <jiay...@microsoft.com>
Gerrit-Reviewer: Jiayu Chen <jiay...@microsoft.com>
Gerrit-Reviewer: Qikai Zhong <qikai...@microsoft.com>
Gerrit-Reviewer: Thomas Lukaszewicz <tl...@chromium.org>
Gerrit-Attention: Qikai Zhong <qikai...@microsoft.com>
Gerrit-Attention: Thomas Lukaszewicz <tl...@chromium.org>
Gerrit-Comment-Date: Tue, 23 Jun 2026 14:10:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Thomas Lukaszewicz (Gerrit)

unread,
Jun 24, 2026, 1:37:16 AM (yesterday) Jun 24
to Jiayu Chen, Qikai Zhong, Chromium LUCI CQ, chromium...@chromium.org, mac-r...@chromium.org
Attention needed from Jiayu Chen and Qikai Zhong

Thomas Lukaszewicz added 6 comments

Patchset-level comments
Thomas Lukaszewicz . resolved

Overall lgtm, just some quick comments and recommendations for follow-up CLs.

File chrome/browser/ui/views/picture_in_picture/BUILD.gn
Line 75, Patchset 11 (Latest): "document_pip_native_widget_mac.h",
Thomas Lukaszewicz . unresolved

nit: Could we add the header to `public`

File chrome/browser/ui/views/picture_in_picture/document_pip_frame_view.cc
Line 131, Patchset 11 (Latest): SetBorder(views::CreateEmptyBorder(gfx::Insets::VH(3, 2)));
Thomas Lukaszewicz . unresolved

Not for this but could we add a TODO to add these magic constants (here and below) to the layout provider?

Line 158, Patchset 11 (Latest): const int alpha = GetState() == STATE_PRESSED ? 0x33 : 0x22;
Thomas Lukaszewicz . unresolved

Could we add `kColorPipWindowForegroundHovered` and `kColorPipWindowForegroundPressed` to `chrome_color_id.h` and add appropriate mixer definitions? (this can be done as a follow up to keep this CL simpler)

Line 414, Patchset 11 (Latest): if (back_to_tab_button_) {
back_to_tab_button_->SetPaintToLayer();
back_to_tab_button_->layer()->SetFillsBoundsOpaquely(false);
}
close_image_button_->SetPaintToLayer();
close_image_button_->layer()->SetFillsBoundsOpaquely(false);
Thomas Lukaszewicz . unresolved

Layers are simple from a code perspective but can be inefficient performance wise (especially when not configured to be opaque.

Would it work to create a wrapper view with the same preferred size as the wrapped button, and toggle visibility on the child? I.e.

```
// 1. Create an empty container view to act as the placeholder in the layout
auto wrapper = std::make_unique<views::View>();

// 2. Add your actual view inside the wrapper
back_to_tab_button_ = wrapper->AddChildView(CreatePipTitleBarButton(
back_icon,
l10n_util::GetStringUTF16(
IDS_PICTURE_IN_PICTURE_BACK_TO_TAB_CONTROL_TEXT),
// Safety: The widget owns the frame view and its child buttons,
// so the callback cannot outlive the widget.
base::BindRepeating(back_to_tab_cb, base::Unretained(this)))););

// 3. Force the wrapper to always report the button's size to the parent LayoutManager
wrapper->SetPreferredSize(back_to_tab_button_->GetPreferredSize());

// Add the wrapper to your main layout
button_container_view_->AddChildView(std::move(wrapper));
```

Similarly for the close image button.

Line 658, Patchset 11 (Latest): // Match browser-backed PiP title behavior: for standard web URLs, show the
// security-display origin (scheme/path omitted, subdomain preserved); for
// file URLs, keep the path but omit the file:// scheme (the File security
// chip already communicates the scheme).
std::u16string origin_text;
if (url.SchemeIsFile()) {
const url_formatter::FormatUrlTypes format_types =
url_formatter::kFormatUrlOmitDefaults |
url_formatter::kFormatUrlOmitFileScheme;
origin_text =
url_formatter::FormatUrl(url, format_types, base::UnescapeRule::NORMAL,
/*new_parsed=*/nullptr, /*prefix_end=*/nullptr,
/*offset_for_adjustment=*/nullptr);
} else {
origin_text = url_formatter::FormatUrlForSecurityDisplay(
url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
}
window_title_->SetText(origin_text);
origin_chip_->GetViewAccessibility().SetDescription(origin_text);

// Choose the elision direction by scheme, mirroring
// PictureInPictureBrowserFrameView. For file URLs we elide the tail, since
// the file name and/or query part of the file URL can be crafted to look
// like an origin for spoofing. For HTTPS URLs we elide the head, since in the
// HTTPS case everything besides the origin is removed for display. Extension
// and isolated-app URLs likewise elide the tail, where the tail is the more
// important part to keep visible.
gfx::ElideBehavior elide_behavior =
url.SchemeIsFile() ? gfx::ELIDE_TAIL : gfx::ELIDE_HEAD;
#if BUILDFLAG(ENABLE_EXTENSIONS)
if (url.SchemeIs(extensions::kExtensionScheme) ||
url.SchemeIs(webapps::kIsolatedAppScheme)) {
elide_behavior = gfx::ELIDE_TAIL;
}
#endif
window_title_->SetElideBehavior(elide_behavior);
Thomas Lukaszewicz . unresolved

Since this is security sensitive can we land the changes in `UpdateOriginAndSecurity()` in a follow-up CL? (better for blame history)

Open in Gerrit

Related details

Attention is currently required from:
  • Jiayu Chen
  • Qikai Zhong
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I9970b8daf4ff570c596467ef483d184d3f49923f
    Gerrit-Change-Number: 7953781
    Gerrit-PatchSet: 11
    Gerrit-Owner: Jiayu Chen <jiay...@microsoft.com>
    Gerrit-Reviewer: Jiayu Chen <jiay...@microsoft.com>
    Gerrit-Reviewer: Qikai Zhong <qikai...@microsoft.com>
    Gerrit-Reviewer: Thomas Lukaszewicz <tl...@chromium.org>
    Gerrit-Attention: Qikai Zhong <qikai...@microsoft.com>
    Gerrit-Attention: Jiayu Chen <jiay...@microsoft.com>
    Gerrit-Comment-Date: Wed, 24 Jun 2026 05:36:45 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Jiayu Chen (Gerrit)

    unread,
    Jun 24, 2026, 5:57:37 AM (yesterday) Jun 24
    to Thomas Lukaszewicz, Qikai Zhong, Chromium LUCI CQ, chromium...@chromium.org, mac-r...@chromium.org
    Attention needed from Qikai Zhong and Thomas Lukaszewicz

    Jiayu Chen voted and added 6 comments

    Votes added by Jiayu Chen

    Commit-Queue+1

    6 comments

    Patchset-level comments
    File-level comment, Patchset 12 (Latest):
    Jiayu Chen . resolved

    Tom, could u take another look? Thx

    File chrome/browser/ui/views/picture_in_picture/BUILD.gn
    Line 75, Patchset 11: "document_pip_native_widget_mac.h",
    Thomas Lukaszewicz . resolved

    nit: Could we add the header to `public`

    Jiayu Chen

    Done

    File chrome/browser/ui/views/picture_in_picture/document_pip_frame_view.cc
    Line 131, Patchset 11: SetBorder(views::CreateEmptyBorder(gfx::Insets::VH(3, 2)));
    Thomas Lukaszewicz . resolved

    Not for this but could we add a TODO to add these magic constants (here and below) to the layout provider?

    Jiayu Chen

    I reverted changes made to `OriginChipButton`, considering reuse `IconLabelBubbleView` would be cheaper. Plan to do it in a following CL.

    Line 158, Patchset 11: const int alpha = GetState() == STATE_PRESSED ? 0x33 : 0x22;
    Thomas Lukaszewicz . resolved

    Could we add `kColorPipWindowForegroundHovered` and `kColorPipWindowForegroundPressed` to `chrome_color_id.h` and add appropriate mixer definitions? (this can be done as a follow up to keep this CL simpler)

    Jiayu Chen

    as above.

    Line 414, Patchset 11: if (back_to_tab_button_) {

    back_to_tab_button_->SetPaintToLayer();
    back_to_tab_button_->layer()->SetFillsBoundsOpaquely(false);
    }
    close_image_button_->SetPaintToLayer();
    close_image_button_->layer()->SetFillsBoundsOpaquely(false);
    Thomas Lukaszewicz . resolved

    Layers are simple from a code perspective but can be inefficient performance wise (especially when not configured to be opaque.

    Would it work to create a wrapper view with the same preferred size as the wrapped button, and toggle visibility on the child? I.e.

    ```
    // 1. Create an empty container view to act as the placeholder in the layout
    auto wrapper = std::make_unique<views::View>();

    // 2. Add your actual view inside the wrapper
    back_to_tab_button_ = wrapper->AddChildView(CreatePipTitleBarButton(
    back_icon,
    l10n_util::GetStringUTF16(
    IDS_PICTURE_IN_PICTURE_BACK_TO_TAB_CONTROL_TEXT),
    // Safety: The widget owns the frame view and its child buttons,
    // so the callback cannot outlive the widget.
    base::BindRepeating(back_to_tab_cb, base::Unretained(this)))););

    // 3. Force the wrapper to always report the button's size to the parent LayoutManager
    wrapper->SetPreferredSize(back_to_tab_button_->GetPreferredSize());

    // Add the wrapper to your main layout
    button_container_view_->AddChildView(std::move(wrapper));
    ```

    Similarly for the close image button.

    Jiayu Chen

    Thanks, this is great advice.

    Line 658, Patchset 11: // Match browser-backed PiP title behavior: for standard web URLs, show the
    Thomas Lukaszewicz . resolved

    Since this is security sensitive can we land the changes in `UpdateOriginAndSecurity()` in a follow-up CL? (better for blame history)

    Jiayu Chen

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Qikai Zhong
    • Thomas Lukaszewicz
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I9970b8daf4ff570c596467ef483d184d3f49923f
      Gerrit-Change-Number: 7953781
      Gerrit-PatchSet: 12
      Gerrit-Owner: Jiayu Chen <jiay...@microsoft.com>
      Gerrit-Reviewer: Jiayu Chen <jiay...@microsoft.com>
      Gerrit-Reviewer: Qikai Zhong <qikai...@microsoft.com>
      Gerrit-Reviewer: Thomas Lukaszewicz <tl...@chromium.org>
      Gerrit-Attention: Qikai Zhong <qikai...@microsoft.com>
      Gerrit-Attention: Thomas Lukaszewicz <tl...@chromium.org>
      Gerrit-Comment-Date: Wed, 24 Jun 2026 09:56:58 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Thomas Lukaszewicz <tl...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Thomas Lukaszewicz (Gerrit)

      unread,
      Jun 24, 2026, 7:12:54 PM (17 hours ago) Jun 24
      to Jiayu Chen, Qikai Zhong, Chromium LUCI CQ, chromium...@chromium.org, mac-r...@chromium.org
      Attention needed from Jiayu Chen and Qikai Zhong

      Thomas Lukaszewicz voted and added 1 comment

      Votes added by Thomas Lukaszewicz

      Code-Review+1

      1 comment

      Patchset-level comments
      Thomas Lukaszewicz . resolved

      thanks - lgtm!

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Jiayu Chen
      • Qikai Zhong
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I9970b8daf4ff570c596467ef483d184d3f49923f
      Gerrit-Change-Number: 7953781
      Gerrit-PatchSet: 12
      Gerrit-Owner: Jiayu Chen <jiay...@microsoft.com>
      Gerrit-Reviewer: Jiayu Chen <jiay...@microsoft.com>
      Gerrit-Reviewer: Qikai Zhong <qikai...@microsoft.com>
      Gerrit-Reviewer: Thomas Lukaszewicz <tl...@chromium.org>
      Gerrit-Attention: Qikai Zhong <qikai...@microsoft.com>
      Gerrit-Attention: Jiayu Chen <jiay...@microsoft.com>
      Gerrit-Comment-Date: Wed, 24 Jun 2026 23:12:23 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Jiayu Chen (Gerrit)

      unread,
      Jun 24, 2026, 9:24:12 PM (15 hours ago) Jun 24
      to Thomas Lukaszewicz, Qikai Zhong, Chromium LUCI CQ, chromium...@chromium.org, mac-r...@chromium.org
      Attention needed from Qikai Zhong

      Jiayu Chen voted Commit-Queue+2

      Commit-Queue+2
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Qikai Zhong
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I9970b8daf4ff570c596467ef483d184d3f49923f
        Gerrit-Change-Number: 7953781
        Gerrit-PatchSet: 13
        Gerrit-Owner: Jiayu Chen <jiay...@microsoft.com>
        Gerrit-Reviewer: Jiayu Chen <jiay...@microsoft.com>
        Gerrit-Reviewer: Qikai Zhong <qikai...@microsoft.com>
        Gerrit-Reviewer: Thomas Lukaszewicz <tl...@chromium.org>
        Gerrit-Attention: Qikai Zhong <qikai...@microsoft.com>
        Gerrit-Comment-Date: Thu, 25 Jun 2026 01:23:43 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        open
        diffy

        Chromium LUCI CQ (Gerrit)

        unread,
        Jun 24, 2026, 9:39:20 PM (15 hours ago) Jun 24
        to Jiayu Chen, Thomas Lukaszewicz, Qikai Zhong, chromium...@chromium.org, mac-r...@chromium.org

        Chromium LUCI CQ submitted the change

        Unreviewed changes

        12 is the latest approved patch-set.
        No files were changed between the latest approved patch-set and the submitted one.

        Change information

        Commit message:
        Document PiP: Improve standalone window parity with browser-backed

        The standalone Document Picture-in-Picture window should visually and
        behaviorally match the Browser-backed Document PiP window. This CL
        closes some UI-parity gaps in the standalone path:

        - Add DocumentPipNativeWidgetMac so the borderless standalone widget
        gets the same macOS rounded corners, shadow, and resize affordance as
        the Browser-backed PiP window while still drawing its own title bar.

        - Recompute the outer window bounds after Widget::Init() so a requested
        inner web-contents size is honored. This mirrors the Browser-backed
        post-init bounds adjustment and avoids creating the standalone window
        one top-bar height too short.

        - Rework the top bar to mirror the Browser-backed location-chip layout:
        a clickable security chip with hover/pressed styling, security icon,
        and chip text such as "File" / "Not secure" / "Dangerous", plus a
        separate draggable window-title label.

        - Format the window title like the Browser-backed frame.

        - Keep the back-to-tab and close buttons laid out while inactive and
        fade them via layer opacity instead of toggling visibility, so the
        title no longer expands into the reserved window-control area.

        - Restrict the JavaScript dialog native-window title override to macOS,
        where the platform accessibility API ignores the dialog description
        and derives the native window name from the child RootView.
        Bug: 515252142
        Change-Id: I9970b8daf4ff570c596467ef483d184d3f49923f
        Commit-Queue: Jiayu Chen <jiay...@microsoft.com>
        Reviewed-by: Thomas Lukaszewicz <tl...@chromium.org>
        Cr-Commit-Position: refs/heads/main@{#1652117}
        Files:
        • M chrome/browser/ui/views/picture_in_picture/BUILD.gn
        • M chrome/browser/ui/views/picture_in_picture/document_pip_dialog_manager_delegate.cc
        • M chrome/browser/ui/views/picture_in_picture/document_pip_dialog_manager_delegate_unittest.cc
        • M chrome/browser/ui/views/picture_in_picture/document_pip_frame_view.cc
        • M chrome/browser/ui/views/picture_in_picture/document_pip_frame_view.h
        • M chrome/browser/ui/views/picture_in_picture/document_pip_frame_view_unittest.cc
        • M chrome/browser/ui/views/picture_in_picture/document_pip_host.cc
        • M chrome/browser/ui/views/picture_in_picture/document_pip_host_unittest.cc
        • A chrome/browser/ui/views/picture_in_picture/document_pip_native_widget_mac.h
        • A chrome/browser/ui/views/picture_in_picture/document_pip_native_widget_mac.mm
        Change size: L
        Delta: 10 files changed, 346 insertions(+), 72 deletions(-)
        Branch: refs/heads/main
        Submit Requirements:
        • requirement satisfiedCode-Review: +1 by Thomas Lukaszewicz
        Open in Gerrit
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: merged
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I9970b8daf4ff570c596467ef483d184d3f49923f
        Gerrit-Change-Number: 7953781
        Gerrit-PatchSet: 14
        Gerrit-Owner: Jiayu Chen <jiay...@microsoft.com>
        Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
        Gerrit-Reviewer: Jiayu Chen <jiay...@microsoft.com>
        Gerrit-Reviewer: Qikai Zhong <qikai...@microsoft.com>
        Gerrit-Reviewer: Thomas Lukaszewicz <tl...@chromium.org>
        open
        diffy
        satisfied_requirement
        Reply all
        Reply to author
        Forward
        0 new messages