Fix image centering when viewport meta is disabled on mobile [chromium/src : main]

0 views
Skip to first unread message

Perry (Gerrit)

unread,
Oct 14, 2025, 9:26:48 AM (yesterday) Oct 14
to Chromium LUCI CQ, chromium...@chromium.org, AyeAye, blink-...@chromium.org, blink-rev...@chromium.org
Attention needed from Joey Arhar

Perry voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Joey Arhar
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: Id53287b7db3c05902bc0bca3c833c4c6647a553a
Gerrit-Change-Number: 7030784
Gerrit-PatchSet: 3
Gerrit-Owner: Perry <perry...@gmail.com>
Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
Gerrit-Reviewer: Perry <perry...@gmail.com>
Gerrit-Attention: Joey Arhar <jar...@chromium.org>
Gerrit-Comment-Date: Tue, 14 Oct 2025 13:25:12 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Perry (Gerrit)

unread,
Oct 14, 2025, 10:12:51 AM (yesterday) Oct 14
to Chromium LUCI CQ, chromium...@chromium.org, AyeAye, blink-...@chromium.org, blink-rev...@chromium.org
Attention needed from Joey Arhar

Perry added 1 comment

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Perry . resolved

PTAL, thanks.

Open in Gerrit

Related details

Attention is currently required from:
  • Joey Arhar
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: Id53287b7db3c05902bc0bca3c833c4c6647a553a
Gerrit-Change-Number: 7030784
Gerrit-PatchSet: 3
Gerrit-Owner: Perry <perry...@gmail.com>
Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
Gerrit-Reviewer: Perry <perry...@gmail.com>
Gerrit-Attention: Joey Arhar <jar...@chromium.org>
Gerrit-Comment-Date: Tue, 14 Oct 2025 14:11:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Joey Arhar (Gerrit)

unread,
Oct 14, 2025, 2:54:20 PM (yesterday) Oct 14
to Perry, Philip Rogers, Chromium LUCI CQ, chromium...@chromium.org, AyeAye, blink-...@chromium.org, blink-rev...@chromium.org
Attention needed from Perry and Philip Rogers

Joey Arhar added 2 comments

Patchset-level comments
Joey Arhar . resolved

based on the bug comments I think that pdr has more context on this

File third_party/blink/renderer/core/html/image_document_test.cc
Joey Arhar . unresolved

Do you think we could make a WPT in web_tests/external/wpt? I imagine that this is something that other browsers would care about too, right?

Open in Gerrit

Related details

Attention is currently required from:
  • Perry
  • Philip Rogers
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: Id53287b7db3c05902bc0bca3c833c4c6647a553a
    Gerrit-Change-Number: 7030784
    Gerrit-PatchSet: 3
    Gerrit-Owner: Perry <perry...@gmail.com>
    Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
    Gerrit-Reviewer: Perry <perry...@gmail.com>
    Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
    Gerrit-Attention: Philip Rogers <p...@chromium.org>
    Gerrit-Attention: Perry <perry...@gmail.com>
    Gerrit-Comment-Date: Tue, 14 Oct 2025 18:53:57 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Philip Rogers (Gerrit)

    unread,
    Oct 14, 2025, 2:56:27 PM (yesterday) Oct 14
    to Perry, Chromium LUCI CQ, chromium...@chromium.org, AyeAye, blink-...@chromium.org, blink-rev...@chromium.org
    Attention needed from Joey Arhar and Perry

    Philip Rogers added 1 comment

    File third_party/blink/renderer/core/html/image_document_test.cc
    Joey Arhar . resolved

    Do you think we could make a WPT in web_tests/external/wpt? I imagine that this is something that other browsers would care about too, right?

    Philip Rogers

    Unfortunately we don't really have mobile coverage in WPT.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joey Arhar
    • Perry
    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: Id53287b7db3c05902bc0bca3c833c4c6647a553a
      Gerrit-Change-Number: 7030784
      Gerrit-PatchSet: 3
      Gerrit-Owner: Perry <perry...@gmail.com>
      Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
      Gerrit-Reviewer: Perry <perry...@gmail.com>
      Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
      Gerrit-Attention: Joey Arhar <jar...@chromium.org>
      Gerrit-Attention: Perry <perry...@gmail.com>
      Gerrit-Comment-Date: Tue, 14 Oct 2025 18:56:05 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Joey Arhar <jar...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Philip Rogers (Gerrit)

      unread,
      Oct 14, 2025, 4:42:20 PM (yesterday) Oct 14
      to Perry, Chromium LUCI CQ, chromium...@chromium.org, AyeAye, blink-...@chromium.org, blink-rev...@chromium.org
      Attention needed from Joey Arhar and Perry

      Philip Rogers added 3 comments

      File third_party/blink/renderer/core/html/image_document.cc
      Line 508, Patchset 3 (Latest): int layout_width =
      Philip Rogers . unresolved

      I think this change is good, but because of low test coverage, I'd like to guard this change with an enabled-by-default RuntimeEnabledFeature which we can force-disable in the event that we break some important image usecase.

      Can you please change this to roughly:
      ```
      int width = (RuntimeEnabledFeature::ImageDocumentUseLayoutWidthEnabled() ? View()->GetLayoutSize().width() : GetFrame()->GetPage()->GetVisualViewport().Size().width()) / GetFrame()->LayoutZoomFactor();
      ```

      Then add the following in `third_party/blink/renderer/platform/runtime_enabled_features.json5`:

      ```
      {
      name: "ImageDocumentUseLayoutWidth",
      status: "stable",
      },
      ```
      File third_party/blink/renderer/core/html/image_document_test.cc
      Line 492, Patchset 3 (Latest):TEST_F(ImageDocumentViewportTest, DivWidthOnMobileWithDisabledViewportMeta) {
      Philip Rogers . unresolved

      Can you add two additional testcases that are the same (verify centering) except the images are 10000x1 pixels and 1x10000 pixels? There is probably a better way to include the images than the `JpegImage` approach.

      Line 519, Patchset 3 (Latest): EXPECT_EQ(465, rect->x());
      Philip Rogers . unresolved

      This isn't obviously verifying centering to me. Can you add a comment about where this comes from? E.g., is it (980 / 2) - (50 / 2)?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Joey Arhar
      • Perry
      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: Id53287b7db3c05902bc0bca3c833c4c6647a553a
        Gerrit-Change-Number: 7030784
        Gerrit-PatchSet: 3
        Gerrit-Owner: Perry <perry...@gmail.com>
        Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
        Gerrit-Reviewer: Perry <perry...@gmail.com>
        Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
        Gerrit-Attention: Joey Arhar <jar...@chromium.org>
        Gerrit-Attention: Perry <perry...@gmail.com>
        Gerrit-Comment-Date: Tue, 14 Oct 2025 20:41:57 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Perry (Gerrit)

        unread,
        11:22 AM (10 hours ago) 11:22 AM
        to Philip Rogers, Chromium LUCI CQ, chromium...@chromium.org, AyeAye, kinuko...@chromium.org, jmedle...@chromium.org, blink-...@chromium.org, blink-rev...@chromium.org
        Attention needed from Joey Arhar and Philip Rogers

        Perry added 4 comments

        Patchset-level comments
        File-level comment, Patchset 5 (Latest):
        Perry . resolved

        Please take a look again, thanks.

        File third_party/blink/renderer/core/html/image_document.cc
        Line 508, Patchset 3: int layout_width =
        Philip Rogers . resolved

        I think this change is good, but because of low test coverage, I'd like to guard this change with an enabled-by-default RuntimeEnabledFeature which we can force-disable in the event that we break some important image usecase.

        Can you please change this to roughly:
        ```
        int width = (RuntimeEnabledFeature::ImageDocumentUseLayoutWidthEnabled() ? View()->GetLayoutSize().width() : GetFrame()->GetPage()->GetVisualViewport().Size().width()) / GetFrame()->LayoutZoomFactor();
        ```

        Then add the following in `third_party/blink/renderer/platform/runtime_enabled_features.json5`:

        ```
        {
        name: "ImageDocumentUseLayoutWidth",
        status: "stable",
        },
        ```
        Perry

        Done

        File third_party/blink/renderer/core/html/image_document_test.cc
        Line 492, Patchset 3:TEST_F(ImageDocumentViewportTest, DivWidthOnMobileWithDisabledViewportMeta) {
        Philip Rogers . resolved

        Can you add two additional testcases that are the same (verify centering) except the images are 10000x1 pixels and 1x10000 pixels? There is probably a better way to include the images than the `JpegImage` approach.

        Perry

        Done

        Line 519, Patchset 3: EXPECT_EQ(465, rect->x());
        Philip Rogers . resolved

        This isn't obviously verifying centering to me. Can you add a comment about where this comes from? E.g., is it (980 / 2) - (50 / 2)?

        Perry

        Done

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Joey Arhar
        • Philip Rogers
        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: Id53287b7db3c05902bc0bca3c833c4c6647a553a
          Gerrit-Change-Number: 7030784
          Gerrit-PatchSet: 5
          Gerrit-Owner: Perry <perry...@gmail.com>
          Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
          Gerrit-Reviewer: Perry <perry...@gmail.com>
          Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
          Gerrit-Attention: Philip Rogers <p...@chromium.org>
          Gerrit-Attention: Joey Arhar <jar...@chromium.org>
          Gerrit-Comment-Date: Wed, 15 Oct 2025 15:20:37 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Philip Rogers <p...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Philip Rogers (Gerrit)

          unread,
          12:44 PM (8 hours ago) 12:44 PM
          to Perry, Chromium LUCI CQ, chromium...@chromium.org, AyeAye, kinuko...@chromium.org, jmedle...@chromium.org, blink-...@chromium.org, blink-rev...@chromium.org
          Attention needed from Joey Arhar and Perry

          Philip Rogers voted and added 1 comment

          Votes added by Philip Rogers

          Code-Review+1

          1 comment

          Patchset-level comments
          Philip Rogers . resolved

          LGTM

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Joey Arhar
          • Perry
          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: Id53287b7db3c05902bc0bca3c833c4c6647a553a
          Gerrit-Change-Number: 7030784
          Gerrit-PatchSet: 5
          Gerrit-Owner: Perry <perry...@gmail.com>
          Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
          Gerrit-Reviewer: Perry <perry...@gmail.com>
          Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
          Gerrit-Attention: Joey Arhar <jar...@chromium.org>
          Gerrit-Attention: Perry <perry...@gmail.com>
          Gerrit-Comment-Date: Wed, 15 Oct 2025 16:43:43 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          open
          diffy

          Perry (Gerrit)

          unread,
          7:48 PM (1 hour ago) 7:48 PM
          to Philip Rogers, Chromium LUCI CQ, chromium...@chromium.org, AyeAye, kinuko...@chromium.org, jmedle...@chromium.org, blink-...@chromium.org, blink-rev...@chromium.org
          Attention needed from Joey Arhar

          Perry voted Commit-Queue+2

          Commit-Queue+2
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Joey Arhar
          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: Id53287b7db3c05902bc0bca3c833c4c6647a553a
          Gerrit-Change-Number: 7030784
          Gerrit-PatchSet: 5
          Gerrit-Owner: Perry <perry...@gmail.com>
          Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
          Gerrit-Reviewer: Perry <perry...@gmail.com>
          Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
          Gerrit-Attention: Joey Arhar <jar...@chromium.org>
          Gerrit-Comment-Date: Wed, 15 Oct 2025 23:46:15 +0000
          Gerrit-HasComments: No
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          open
          diffy

          Chromium LUCI CQ (Gerrit)

          unread,
          8:07 PM (1 hour ago) 8:07 PM
          to Perry, Philip Rogers, chromium...@chromium.org, AyeAye, kinuko...@chromium.org, jmedle...@chromium.org, blink-...@chromium.org, blink-rev...@chromium.org

          Chromium LUCI CQ submitted the change

          Change information

          Commit message:
          Fix image centering when viewport meta is disabled on mobile

          On mobile, when viewport meta is disabled, the layout width is greater
          than the viewport width, resulting in the image not being centered. This
          CL uses layout width instead of viewport width to calculate div width,
          ensuring that the image is displayed in the center.
          Bug: 40734764
          Change-Id: Id53287b7db3c05902bc0bca3c833c4c6647a553a
          Commit-Queue: Perry <perry...@gmail.com>
          Reviewed-by: Philip Rogers <p...@chromium.org>
          Cr-Commit-Position: refs/heads/main@{#1530545}
          Files:
          • M third_party/blink/renderer/core/html/image_document.cc
          • M third_party/blink/renderer/core/html/image_document.h
          • M third_party/blink/renderer/core/html/image_document_test.cc
          • M third_party/blink/renderer/platform/runtime_enabled_features.json5
          Change size: M
          Delta: 4 files changed, 125 insertions(+), 4 deletions(-)
          Branch: refs/heads/main
          Submit Requirements:
          • requirement satisfiedCode-Review: +1 by Philip Rogers
          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: Id53287b7db3c05902bc0bca3c833c4c6647a553a
          Gerrit-Change-Number: 7030784
          Gerrit-PatchSet: 6
          Gerrit-Owner: Perry <perry...@gmail.com>
          Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
          Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
          Gerrit-Reviewer: Perry <perry...@gmail.com>
          Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
          open
          diffy
          satisfied_requirement
          Reply all
          Reply to author
          Forward
          0 new messages