[PDF Ink Signatures] Add size selector dropdown in bottom toolbar [chromium/src : main]

0 views
Skip to first unread message

Andy Phan (Gerrit)

unread,
Oct 31, 2024, 5:43:33 PM10/31/24
to Rebekah Potter, AyeAye, findit...@appspot.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Daniel Cheng, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org
Attention needed from Rebekah Potter

Andy Phan added 4 comments

Patchset-level comments
File-level comment, Patchset 4 (Latest):
Andy Phan . resolved

+rbpotter@ for review, PTAL. I also have some questions listed as comments here, but we can discuss in a separate media if you prefer. Thanks!

File chrome/browser/resources/pdf/elements/viewer_bottom_toolbar_dropdown.html.ts
Line 13, Patchset 4 (Latest): <cr-icon-button iron-icon="${this.buttonIcon}"
Andy Phan . resolved

Ideally, the color selector will use ViewerBottomToolbarDropdownElement. The icon should then be a circle with the color that is currently selected (see CrOS Gallery). The color selector doesn't use icons; it's just background color in a circle. Is there a way to make this work with cr-icon-button?

Line 17, Patchset 3: ${this.showDropdown_ ? html`<slot></slot>` : ''}
Andy Phan . resolved

The new UI elements are lacking transitions. Will transitions still work using this?

File chrome/browser/resources/pdf/elements/viewer_bottom_toolbar_dropdown.ts
Line 72, Patchset 3: // TODO(crbug.com/369653190): Ideally, the dropdown should be toggled when the
// stroke starts, not when the stroke finishes. Exit out of the dropdown when
// the user draws an ink stroke.
Andy Phan . resolved

There's no click event for when the user clicks the PDF content iframe, so we're relying on the PDF content to respond back about clicking. We might have to add a new plugin message here?

Open in Gerrit

Related details

Attention is currently required from:
  • Rebekah Potter
Submit Requirements:
  • requirement is blockingCode-Coverage
  • requirement is not satisfiedCode-Review
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: I53722e395eb6e67a9603f000a301fe34131d9e4e
Gerrit-Change-Number: 5980052
Gerrit-PatchSet: 4
Gerrit-Owner: Andy Phan <andy...@chromium.org>
Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
Gerrit-CC: Daniel Cheng <dch...@chromium.org>
Gerrit-Attention: Rebekah Potter <rbpo...@chromium.org>
Gerrit-Comment-Date: Thu, 31 Oct 2024 21:43:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
blocking_requirement
unsatisfied_requirement
open
diffy

Rebekah Potter (Gerrit)

unread,
Oct 31, 2024, 7:04:13 PM10/31/24
to Andy Phan, AyeAye, findit...@appspot.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Daniel Cheng, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org
Attention needed from Andy Phan

Rebekah Potter added 4 comments

File chrome/browser/resources/pdf/elements/viewer_bottom_toolbar.html.ts
Line 20, Patchset 4 (Latest): <viewer-bottom-toolbar-dropdown id="size" .buttonIcon="${'pdf:pen-size-3'}">
Rebekah Potter . unresolved

can just use attribute binding since this is a hardcoded string for now. i.e. `button-icon="pdf:pen-size-3"`. The `${` should only be used when data binding.

File chrome/browser/resources/pdf/elements/viewer_bottom_toolbar_dropdown.html.ts
Line 13, Patchset 4 (Latest): <cr-icon-button iron-icon="${this.buttonIcon}"
Andy Phan . resolved

Ideally, the color selector will use ViewerBottomToolbarDropdownElement. The icon should then be a circle with the color that is currently selected (see CrOS Gallery). The color selector doesn't use icons; it's just background color in a circle. Is there a way to make this work with cr-icon-button?

Rebekah Potter

Ideally, the color selector will use ViewerBottomToolbarDropdownElement. The icon should then be a circle with the color that is currently selected (see CrOS Gallery). The color selector doesn't use icons; it's just background color in a circle. Is there a way to make this work with cr-icon-button?

I don't think this would work with cr-icon-button as-is. There are 2 different ways to set images for cr-icon-button, see https://source.chromium.org/chromium/chromium/src/+/main:ui/webui/resources/cr_elements/cr_icon_button/cr_icon_button.ts

but neither of these involve just creating a circle with a background color. If you wanted to use cr-icon-button, you could probably create an SVG that looks like a circle, and use iron-icon-fill-color to change its color.

File chrome/browser/resources/pdf/elements/viewer_bottom_toolbar_dropdown.ts
Line 48, Patchset 4 (Latest): override disconnectedCallback() {
this.tracker_.removeAll();
}
Rebekah Potter . unresolved

if you're resetting in disconnectedCallback(), you should add the event in connectedCallback(). The constructor will only be called once, but connected/disconnected callbacks can be called multiple times if this element is disconnected and reconnected to the DOM.

File chrome/browser/resources/pdf/pdf_viewer.html
Line 73, Patchset 4 (Latest): @current-size-changed="${this.onBrushSizeChanged_}"
@current-type-changed="${this.onBrushTypeChanged_}">
Rebekah Potter . unresolved

These events aren't fired by default. Either need to set notify: true on these properties in viewer_bottom_toolbar.ts, or manually dispatch such events using fire().

Open in Gerrit

Related details

Attention is currently required from:
  • Andy Phan
Submit Requirements:
    • requirement is blockingCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: I53722e395eb6e67a9603f000a301fe34131d9e4e
    Gerrit-Change-Number: 5980052
    Gerrit-PatchSet: 4
    Gerrit-Owner: Andy Phan <andy...@chromium.org>
    Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
    Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
    Gerrit-CC: Daniel Cheng <dch...@chromium.org>
    Gerrit-Attention: Andy Phan <andy...@chromium.org>
    Gerrit-Comment-Date: Thu, 31 Oct 2024 23:04:04 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Andy Phan <andy...@chromium.org>
    blocking_requirement
    unsatisfied_requirement
    open
    diffy

    Andy Phan (Gerrit)

    unread,
    Oct 31, 2024, 7:54:13 PM10/31/24
    to Rebekah Potter, AyeAye, findit...@appspot.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Daniel Cheng, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org
    Attention needed from Rebekah Potter

    Andy Phan added 5 comments

    File chrome/browser/resources/pdf/elements/viewer_bottom_toolbar.html.ts
    Line 20, Patchset 4: <viewer-bottom-toolbar-dropdown id="size" .buttonIcon="${'pdf:pen-size-3'}">
    Rebekah Potter . resolved

    can just use attribute binding since this is a hardcoded string for now. i.e. `button-icon="pdf:pen-size-3"`. The `${` should only be used when data binding.

    Andy Phan

    Done

    File chrome/browser/resources/pdf/elements/viewer_bottom_toolbar_dropdown.html.ts
    Line 13, Patchset 4: <cr-icon-button iron-icon="${this.buttonIcon}"
    Andy Phan . resolved

    Ideally, the color selector will use ViewerBottomToolbarDropdownElement. The icon should then be a circle with the color that is currently selected (see CrOS Gallery). The color selector doesn't use icons; it's just background color in a circle. Is there a way to make this work with cr-icon-button?

    Rebekah Potter

    Ideally, the color selector will use ViewerBottomToolbarDropdownElement. The icon should then be a circle with the color that is currently selected (see CrOS Gallery). The color selector doesn't use icons; it's just background color in a circle. Is there a way to make this work with cr-icon-button?

    I don't think this would work with cr-icon-button as-is. There are 2 different ways to set images for cr-icon-button, see https://source.chromium.org/chromium/chromium/src/+/main:ui/webui/resources/cr_elements/cr_icon_button/cr_icon_button.ts

    but neither of these involve just creating a circle with a background color. If you wanted to use cr-icon-button, you could probably create an SVG that looks like a circle, and use iron-icon-fill-color to change its color.

    Andy Phan

    Ack, thanks.

    Line 17, Patchset 3: ${this.showDropdown_ ? html`<slot></slot>` : ''}
    Andy Phan . resolved

    The new UI elements are lacking transitions. Will transitions still work using this?

    Andy Phan

    In this case, the transition is opacity, and fade to full opacity on opening, and zero opacity when closing. I haven't been able to get this to work, and I wonder if it's my CSS or if it's due to the element being removed.

    File chrome/browser/resources/pdf/elements/viewer_bottom_toolbar_dropdown.ts
    Line 48, Patchset 4: override disconnectedCallback() {
    this.tracker_.removeAll();
    }
    Rebekah Potter . resolved

    if you're resetting in disconnectedCallback(), you should add the event in connectedCallback(). The constructor will only be called once, but connected/disconnected callbacks can be called multiple times if this element is disconnected and reconnected to the DOM.

    Andy Phan

    Thanks, done.

    File chrome/browser/resources/pdf/pdf_viewer.html
    Line 73, Patchset 4: @current-size-changed="${this.onBrushSizeChanged_}"
    @current-type-changed="${this.onBrushTypeChanged_}">
    Rebekah Potter . unresolved

    These events aren't fired by default. Either need to set notify: true on these properties in viewer_bottom_toolbar.ts, or manually dispatch such events using fire().

    Andy Phan

    These events are actually fired from ViewerBottomToolbar's children/grandchildren. For instance, InkBrushSelectorElement is a child of ViewerBottomToolbar, and has notify: true on the property [1]. Same with InkSizeSelectorElement.

    The flow is PdfViewerElement initializes the values in ViewerBottomToolbar, and consequently, InkBrushSelectorElement. If a user clicks a brush in InkBrushSelectorElement, it notifies PdfViewerElement, which will then set its own property, which sets ViewerBottomToolbar's property.

    [1] https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/resources/pdf/elements/ink_brush_selector.ts;l=41-44

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Rebekah Potter
    Submit Requirements:
    • requirement is blockingCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: I53722e395eb6e67a9603f000a301fe34131d9e4e
    Gerrit-Change-Number: 5980052
    Gerrit-PatchSet: 5
    Gerrit-Owner: Andy Phan <andy...@chromium.org>
    Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
    Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
    Gerrit-CC: Daniel Cheng <dch...@chromium.org>
    Gerrit-Attention: Rebekah Potter <rbpo...@chromium.org>
    Gerrit-Comment-Date: Thu, 31 Oct 2024 23:54:05 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Rebekah Potter <rbpo...@chromium.org>
    Comment-In-Reply-To: Andy Phan <andy...@chromium.org>
    blocking_requirement
    unsatisfied_requirement
    open
    diffy

    Rebekah Potter (Gerrit)

    unread,
    Nov 1, 2024, 5:32:54 PM11/1/24
    to Andy Phan, AyeAye, findit...@appspot.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Daniel Cheng, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org
    Attention needed from Andy Phan

    Rebekah Potter voted and added 2 comments

    Votes added by Rebekah Potter

    Code-Review+1

    2 comments

    Patchset-level comments
    File-level comment, Patchset 6 (Latest):
    Rebekah Potter . resolved

    LGTM but see comment on using 2 way bindings only to set grandparent properties so that the parent is updated via data binding, rather than having the parent set properties directly.

    File chrome/browser/resources/pdf/pdf_viewer.html
    Line 73, Patchset 4: @current-size-changed="${this.onBrushSizeChanged_}"
    @current-type-changed="${this.onBrushTypeChanged_}">
    Rebekah Potter . unresolved

    These events aren't fired by default. Either need to set notify: true on these properties in viewer_bottom_toolbar.ts, or manually dispatch such events using fire().

    Andy Phan

    These events are actually fired from ViewerBottomToolbar's children/grandchildren. For instance, InkBrushSelectorElement is a child of ViewerBottomToolbar, and has notify: true on the property [1]. Same with InkSizeSelectorElement.

    The flow is PdfViewerElement initializes the values in ViewerBottomToolbar, and consequently, InkBrushSelectorElement. If a user clicks a brush in InkBrushSelectorElement, it notifies PdfViewerElement, which will then set its own property, which sets ViewerBottomToolbar's property.

    [1] https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/resources/pdf/elements/ink_brush_selector.ts;l=41-44

    Rebekah Potter

    I see. This is a bit of an odd way to use these events. To clarify, such events were implemented in CrLitElement as a "compatibility layer" between Lit and Polymer, so that when elements were migrated to Lit any Polymer clients of these elements using 2 way bindings to them would not immediately be broken. 2 way bindings are between parent and child elements.

    If the idea is that the parent element needs to react to an event fired by its child so that it can track the change in state, the parent element itself should react to the event. Relying on bubbling the event all the way up to the grandparent, so that the grandparent can then in turn update the parent's state, seems like incorrect layering.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Andy Phan
    Submit Requirements:
      • requirement is blockingCode-Coverage
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      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: I53722e395eb6e67a9603f000a301fe34131d9e4e
      Gerrit-Change-Number: 5980052
      Gerrit-PatchSet: 6
      Gerrit-Owner: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
      Gerrit-CC: Daniel Cheng <dch...@chromium.org>
      Gerrit-Attention: Andy Phan <andy...@chromium.org>
      Gerrit-Comment-Date: Fri, 01 Nov 2024 21:32:44 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      blocking_requirement
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Andy Phan (Gerrit)

      unread,
      Nov 1, 2024, 6:13:31 PM11/1/24
      to Rebekah Potter, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Daniel Cheng, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org

      Andy Phan added 1 comment

      File chrome/browser/resources/pdf/pdf_viewer.html
      Line 73, Patchset 4: @current-size-changed="${this.onBrushSizeChanged_}"
      @current-type-changed="${this.onBrushTypeChanged_}">
      Rebekah Potter . resolved

      These events aren't fired by default. Either need to set notify: true on these properties in viewer_bottom_toolbar.ts, or manually dispatch such events using fire().

      Andy Phan

      These events are actually fired from ViewerBottomToolbar's children/grandchildren. For instance, InkBrushSelectorElement is a child of ViewerBottomToolbar, and has notify: true on the property [1]. Same with InkSizeSelectorElement.

      The flow is PdfViewerElement initializes the values in ViewerBottomToolbar, and consequently, InkBrushSelectorElement. If a user clicks a brush in InkBrushSelectorElement, it notifies PdfViewerElement, which will then set its own property, which sets ViewerBottomToolbar's property.

      [1] https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/resources/pdf/elements/ink_brush_selector.ts;l=41-44

      Rebekah Potter

      I see. This is a bit of an odd way to use these events. To clarify, such events were implemented in CrLitElement as a "compatibility layer" between Lit and Polymer, so that when elements were migrated to Lit any Polymer clients of these elements using 2 way bindings to them would not immediately be broken. 2 way bindings are between parent and child elements.

      If the idea is that the parent element needs to react to an event fired by its child so that it can track the change in state, the parent element itself should react to the event. Relying on bubbling the event all the way up to the grandparent, so that the grandparent can then in turn update the parent's state, seems like incorrect layering.

      Andy Phan

      I'm okay with the child responding to and emitting the same event in the parent-child-grandchild hierarchy. It adds a bit more boilerplate to ViewerSidePanelElement and ViewerBottomToolbarElement, but it's not too bad.

      I can do this in a separate CL, so temporarily marking as resolved for submission.

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Review
      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: I53722e395eb6e67a9603f000a301fe34131d9e4e
      Gerrit-Change-Number: 5980052
      Gerrit-PatchSet: 7
      Gerrit-Owner: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
      Gerrit-Comment-Date: Fri, 01 Nov 2024 22:13:20 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      open
      diffy

      Rebekah Potter (Gerrit)

      unread,
      Nov 1, 2024, 7:48:27 PM11/1/24
      to Andy Phan, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Daniel Cheng, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org
      Attention needed from Andy Phan

      Rebekah Potter voted and added 1 comment

      Votes added by Rebekah Potter

      Code-Review+1

      1 comment

      File chrome/browser/resources/pdf/pdf_viewer.html
      Line 73, Patchset 4: @current-size-changed="${this.onBrushSizeChanged_}"
      @current-type-changed="${this.onBrushTypeChanged_}">
      Rebekah Potter . resolved

      These events aren't fired by default. Either need to set notify: true on these properties in viewer_bottom_toolbar.ts, or manually dispatch such events using fire().

      Andy Phan

      These events are actually fired from ViewerBottomToolbar's children/grandchildren. For instance, InkBrushSelectorElement is a child of ViewerBottomToolbar, and has notify: true on the property [1]. Same with InkSizeSelectorElement.

      The flow is PdfViewerElement initializes the values in ViewerBottomToolbar, and consequently, InkBrushSelectorElement. If a user clicks a brush in InkBrushSelectorElement, it notifies PdfViewerElement, which will then set its own property, which sets ViewerBottomToolbar's property.

      [1] https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/resources/pdf/elements/ink_brush_selector.ts;l=41-44

      Rebekah Potter

      I see. This is a bit of an odd way to use these events. To clarify, such events were implemented in CrLitElement as a "compatibility layer" between Lit and Polymer, so that when elements were migrated to Lit any Polymer clients of these elements using 2 way bindings to them would not immediately be broken. 2 way bindings are between parent and child elements.

      If the idea is that the parent element needs to react to an event fired by its child so that it can track the change in state, the parent element itself should react to the event. Relying on bubbling the event all the way up to the grandparent, so that the grandparent can then in turn update the parent's state, seems like incorrect layering.

      Andy Phan

      I'm okay with the child responding to and emitting the same event in the parent-child-grandchild hierarchy. It adds a bit more boilerplate to ViewerSidePanelElement and ViewerBottomToolbarElement, but it's not too bad.

      I can do this in a separate CL, so temporarily marking as resolved for submission.

      Rebekah Potter

      SGTM. There's probably a larger question here of why we need to track identical state through 3 different layers of custom elements. It is indeed common for some initial or backend-created state to flow down from a top level element through several layers, but from that point responsibility for tracking small pieces of the state tends to be managed by subcomponents, and events are only fired up to the top level element when they may be triggering some larger scale change. Part of the benefit of componentization is supposed to be that we don't need to manage every detail of the state in a single complicated element, but instead this can be delegated to subcomponents.

      Looking at the PDF viewer code, this problem appears to be created by the fact that unlike most UIs, where browser proxy/backend interfaces are used by many different elements, the PDF viewer only allows interaction with the plugin from the top level component. Wondering if it would be feasible to make the calls to the plugin directly from ViewerBottomToolbar for example, given that it seems to be tracking all the necessary state anyway as of the next CL that passes it the color. The extensions page is an example of a WebUI that passes a browser proxy object ("Service") down through various levels of UI with data bindings; singleton instance is the more common pattern. Not sure which would work better for this case.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Andy Phan
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Review
      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: I53722e395eb6e67a9603f000a301fe34131d9e4e
      Gerrit-Change-Number: 5980052
      Gerrit-PatchSet: 7
      Gerrit-Owner: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
      Gerrit-CC: Daniel Cheng <dch...@chromium.org>
      Gerrit-Attention: Andy Phan <andy...@chromium.org>
      Gerrit-Comment-Date: Fri, 01 Nov 2024 23:48:18 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Andy Phan (Gerrit)

      unread,
      Nov 1, 2024, 7:59:22 PM11/1/24
      to Rebekah Potter, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Daniel Cheng, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org

      Andy Phan added 1 comment

      File chrome/browser/resources/pdf/pdf_viewer.html
      Line 73, Patchset 4: @current-size-changed="${this.onBrushSizeChanged_}"
      @current-type-changed="${this.onBrushTypeChanged_}">
      Rebekah Potter . resolved

      These events aren't fired by default. Either need to set notify: true on these properties in viewer_bottom_toolbar.ts, or manually dispatch such events using fire().

      Andy Phan

      These events are actually fired from ViewerBottomToolbar's children/grandchildren. For instance, InkBrushSelectorElement is a child of ViewerBottomToolbar, and has notify: true on the property [1]. Same with InkSizeSelectorElement.

      The flow is PdfViewerElement initializes the values in ViewerBottomToolbar, and consequently, InkBrushSelectorElement. If a user clicks a brush in InkBrushSelectorElement, it notifies PdfViewerElement, which will then set its own property, which sets ViewerBottomToolbar's property.

      [1] https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/resources/pdf/elements/ink_brush_selector.ts;l=41-44

      Rebekah Potter

      I see. This is a bit of an odd way to use these events. To clarify, such events were implemented in CrLitElement as a "compatibility layer" between Lit and Polymer, so that when elements were migrated to Lit any Polymer clients of these elements using 2 way bindings to them would not immediately be broken. 2 way bindings are between parent and child elements.

      If the idea is that the parent element needs to react to an event fired by its child so that it can track the change in state, the parent element itself should react to the event. Relying on bubbling the event all the way up to the grandparent, so that the grandparent can then in turn update the parent's state, seems like incorrect layering.

      Andy Phan

      I'm okay with the child responding to and emitting the same event in the parent-child-grandchild hierarchy. It adds a bit more boilerplate to ViewerSidePanelElement and ViewerBottomToolbarElement, but it's not too bad.

      I can do this in a separate CL, so temporarily marking as resolved for submission.

      Rebekah Potter

      SGTM. There's probably a larger question here of why we need to track identical state through 3 different layers of custom elements. It is indeed common for some initial or backend-created state to flow down from a top level element through several layers, but from that point responsibility for tracking small pieces of the state tends to be managed by subcomponents, and events are only fired up to the top level element when they may be triggering some larger scale change. Part of the benefit of componentization is supposed to be that we don't need to manage every detail of the state in a single complicated element, but instead this can be delegated to subcomponents.

      Looking at the PDF viewer code, this problem appears to be created by the fact that unlike most UIs, where browser proxy/backend interfaces are used by many different elements, the PDF viewer only allows interaction with the plugin from the top level component. Wondering if it would be feasible to make the calls to the plugin directly from ViewerBottomToolbar for example, given that it seems to be tracking all the necessary state anyway as of the next CL that passes it the color. The extensions page is an example of a WebUI that passes a browser proxy object ("Service") down through various levels of UI with data bindings; singleton instance is the more common pattern. Not sure which would work better for this case.

      Andy Phan

      In my original prototype, I had ViewerSidePanelElement making calls to the plugin, and not storing fields in PdfViewerElement. Not storing fields in PdfViewerElement caused flickering, so I had to add the params as a property there.

      Since the params have already surfaced to PdfViewerElement, I think plugin calls should probably stay there. It's possible to make them in ViewerSidePanelElement/ViewerBottomToolbarElement, but I think the flow would be a bit more confusing, as it's no longer a top-to-bottom or bottom-to-top flow.

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Review
      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: I53722e395eb6e67a9603f000a301fe34131d9e4e
      Gerrit-Change-Number: 5980052
      Gerrit-PatchSet: 7
      Gerrit-Owner: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
      Gerrit-CC: Daniel Cheng <dch...@chromium.org>
      Gerrit-Comment-Date: Fri, 01 Nov 2024 23:59:12 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      open
      diffy

      Chromium LUCI CQ (Gerrit)

      unread,
      Nov 1, 2024, 8:08:37 PM11/1/24
      to Andy Phan, Rebekah Potter, AyeAye, chromium...@chromium.org, Daniel Cheng, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org

      Chromium LUCI CQ submitted the change

      Change information

      Commit message:
      [PDF Ink Signatures] Add size selector dropdown in bottom toolbar

      Add a size selector dropdown menu and button so that users can choose
      brush sizes. Clicking the button will show the dropdown menu with
      brush size selection.

      To do so, introduce ViewerBottomToolbarDropdownElement to have a
      button that opens a dropdown menu. This can be re-used when the color
      selector is added in the future.

      Low-Coverage-Reason: COVERAGE_UNDERREPORTED This CL adds tests that use
      the bottom toolbar element and the new bottom toolbar dropdown element.
      Bug: 369653190
      Change-Id: I53722e395eb6e67a9603f000a301fe34131d9e4e
      Commit-Queue: Andy Phan <andy...@chromium.org>
      Reviewed-by: Rebekah Potter <rbpo...@chromium.org>
      Cr-Commit-Position: refs/heads/main@{#1377189}
      Files:
      • M chrome/browser/pdf/pdf_extension_js_test.cc
      • M chrome/browser/resources/pdf/BUILD.gn
      • M chrome/browser/resources/pdf/elements/viewer_bottom_toolbar.html.ts
      • M chrome/browser/resources/pdf/elements/viewer_bottom_toolbar.ts
      • A chrome/browser/resources/pdf/elements/viewer_bottom_toolbar_dropdown.css
      • A chrome/browser/resources/pdf/elements/viewer_bottom_toolbar_dropdown.html.ts
      • A chrome/browser/resources/pdf/elements/viewer_bottom_toolbar_dropdown.ts
      • M chrome/browser/resources/pdf/pdf_viewer.html
      • M chrome/browser/resources/pdf/pdf_viewer_wrapper.ts
      • M chrome/test/data/pdf/BUILD.gn
      • A chrome/test/data/pdf/ink2_bottom_toolbar_dropdown_test.ts
      • M chrome/test/data/pdf/ink2_bottom_toolbar_test.ts
      Change size: L
      Delta: 12 files changed, 307 insertions(+), 7 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Rebekah Potter
      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: I53722e395eb6e67a9603f000a301fe34131d9e4e
      Gerrit-Change-Number: 5980052
      Gerrit-PatchSet: 8
      Gerrit-Owner: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
      open
      diffy
      satisfied_requirement

      Andy Phan (Gerrit)

      unread,
      Nov 6, 2024, 6:44:36 PM11/6/24
      to Chromium LUCI CQ, Rebekah Potter, AyeAye, chromium...@chromium.org, Daniel Cheng, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org

      Andy Phan added 1 comment

      File chrome/browser/resources/pdf/pdf_viewer.html
      Line 73, Patchset 4: @current-size-changed="${this.onBrushSizeChanged_}"
      @current-type-changed="${this.onBrushTypeChanged_}">
      Rebekah Potter . unresolved

      These events aren't fired by default. Either need to set notify: true on these properties in viewer_bottom_toolbar.ts, or manually dispatch such events using fire().

      Andy Phan

      These events are actually fired from ViewerBottomToolbar's children/grandchildren. For instance, InkBrushSelectorElement is a child of ViewerBottomToolbar, and has notify: true on the property [1]. Same with InkSizeSelectorElement.

      The flow is PdfViewerElement initializes the values in ViewerBottomToolbar, and consequently, InkBrushSelectorElement. If a user clicks a brush in InkBrushSelectorElement, it notifies PdfViewerElement, which will then set its own property, which sets ViewerBottomToolbar's property.

      [1] https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/resources/pdf/elements/ink_brush_selector.ts;l=41-44

      Rebekah Potter

      I see. This is a bit of an odd way to use these events. To clarify, such events were implemented in CrLitElement as a "compatibility layer" between Lit and Polymer, so that when elements were migrated to Lit any Polymer clients of these elements using 2 way bindings to them would not immediately be broken. 2 way bindings are between parent and child elements.

      If the idea is that the parent element needs to react to an event fired by its child so that it can track the change in state, the parent element itself should react to the event. Relying on bubbling the event all the way up to the grandparent, so that the grandparent can then in turn update the parent's state, seems like incorrect layering.

      Andy Phan

      I'm okay with the child responding to and emitting the same event in the parent-child-grandchild hierarchy. It adds a bit more boilerplate to ViewerSidePanelElement and ViewerBottomToolbarElement, but it's not too bad.

      I can do this in a separate CL, so temporarily marking as resolved for submission.

      Rebekah Potter

      SGTM. There's probably a larger question here of why we need to track identical state through 3 different layers of custom elements. It is indeed common for some initial or backend-created state to flow down from a top level element through several layers, but from that point responsibility for tracking small pieces of the state tends to be managed by subcomponents, and events are only fired up to the top level element when they may be triggering some larger scale change. Part of the benefit of componentization is supposed to be that we don't need to manage every detail of the state in a single complicated element, but instead this can be delegated to subcomponents.

      Looking at the PDF viewer code, this problem appears to be created by the fact that unlike most UIs, where browser proxy/backend interfaces are used by many different elements, the PDF viewer only allows interaction with the plugin from the top level component. Wondering if it would be feasible to make the calls to the plugin directly from ViewerBottomToolbar for example, given that it seems to be tracking all the necessary state anyway as of the next CL that passes it the color. The extensions page is an example of a WebUI that passes a browser proxy object ("Service") down through various levels of UI with data bindings; singleton instance is the more common pattern. Not sure which would work better for this case.

      Andy Phan

      In my original prototype, I had ViewerSidePanelElement making calls to the plugin, and not storing fields in PdfViewerElement. Not storing fields in PdfViewerElement caused flickering, so I had to add the params as a property there.

      Since the params have already surfaced to PdfViewerElement, I think plugin calls should probably stay there. It's possible to make them in ViewerSidePanelElement/ViewerBottomToolbarElement, but I think the flow would be a bit more confusing, as it's no longer a top-to-bottom or bottom-to-top flow.

      Andy Phan

      Re-opening as a TODO later.

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Review
      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: I53722e395eb6e67a9603f000a301fe34131d9e4e
      Gerrit-Change-Number: 5980052
      Gerrit-PatchSet: 8
      Gerrit-Owner: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
      Gerrit-CC: Daniel Cheng <dch...@chromium.org>
      Gerrit-Comment-Date: Wed, 06 Nov 2024 23:44:27 +0000
      satisfied_requirement
      open
      diffy

      Andy Phan (Gerrit)

      unread,
      1:14 PM (4 hours ago) 1:14 PM
      to Chromium LUCI CQ, Rebekah Potter, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, Daniel Cheng, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org

      Andy Phan added 1 comment

      File chrome/browser/resources/pdf/pdf_viewer.html
      Line 73, Patchset 4: @current-size-changed="${this.onBrushSizeChanged_}"
      @current-type-changed="${this.onBrushTypeChanged_}">
      Rebekah Potter . resolved

      These events aren't fired by default. Either need to set notify: true on these properties in viewer_bottom_toolbar.ts, or manually dispatch such events using fire().

      Andy Phan

      These events are actually fired from ViewerBottomToolbar's children/grandchildren. For instance, InkBrushSelectorElement is a child of ViewerBottomToolbar, and has notify: true on the property [1]. Same with InkSizeSelectorElement.

      The flow is PdfViewerElement initializes the values in ViewerBottomToolbar, and consequently, InkBrushSelectorElement. If a user clicks a brush in InkBrushSelectorElement, it notifies PdfViewerElement, which will then set its own property, which sets ViewerBottomToolbar's property.

      [1] https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/resources/pdf/elements/ink_brush_selector.ts;l=41-44

      Rebekah Potter

      I see. This is a bit of an odd way to use these events. To clarify, such events were implemented in CrLitElement as a "compatibility layer" between Lit and Polymer, so that when elements were migrated to Lit any Polymer clients of these elements using 2 way bindings to them would not immediately be broken. 2 way bindings are between parent and child elements.

      If the idea is that the parent element needs to react to an event fired by its child so that it can track the change in state, the parent element itself should react to the event. Relying on bubbling the event all the way up to the grandparent, so that the grandparent can then in turn update the parent's state, seems like incorrect layering.

      Andy Phan

      I'm okay with the child responding to and emitting the same event in the parent-child-grandchild hierarchy. It adds a bit more boilerplate to ViewerSidePanelElement and ViewerBottomToolbarElement, but it's not too bad.

      I can do this in a separate CL, so temporarily marking as resolved for submission.

      Rebekah Potter

      SGTM. There's probably a larger question here of why we need to track identical state through 3 different layers of custom elements. It is indeed common for some initial or backend-created state to flow down from a top level element through several layers, but from that point responsibility for tracking small pieces of the state tends to be managed by subcomponents, and events are only fired up to the top level element when they may be triggering some larger scale change. Part of the benefit of componentization is supposed to be that we don't need to manage every detail of the state in a single complicated element, but instead this can be delegated to subcomponents.

      Looking at the PDF viewer code, this problem appears to be created by the fact that unlike most UIs, where browser proxy/backend interfaces are used by many different elements, the PDF viewer only allows interaction with the plugin from the top level component. Wondering if it would be feasible to make the calls to the plugin directly from ViewerBottomToolbar for example, given that it seems to be tracking all the necessary state anyway as of the next CL that passes it the color. The extensions page is an example of a WebUI that passes a browser proxy object ("Service") down through various levels of UI with data bindings; singleton instance is the more common pattern. Not sure which would work better for this case.

      Andy Phan

      In my original prototype, I had ViewerSidePanelElement making calls to the plugin, and not storing fields in PdfViewerElement. Not storing fields in PdfViewerElement caused flickering, so I had to add the params as a property there.

      Since the params have already surfaced to PdfViewerElement, I think plugin calls should probably stay there. It's possible to make them in ViewerSidePanelElement/ViewerBottomToolbarElement, but I think the flow would be a bit more confusing, as it's no longer a top-to-bottom or bottom-to-top flow.

      Andy Phan

      Re-opening as a TODO later.

      Andy Phan

      I believe this is now obsolete after introducing Ink2Manager.

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      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: I53722e395eb6e67a9603f000a301fe34131d9e4e
      Gerrit-Change-Number: 5980052
      Gerrit-PatchSet: 8
      Gerrit-Owner: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
      Gerrit-CC: Daniel Cheng <dch...@chromium.org>
      Gerrit-Comment-Date: Mon, 01 Jun 2026 17:14:46 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Andy Phan <andy...@chromium.org>
      Comment-In-Reply-To: Rebekah Potter <rbpo...@chromium.org>
      satisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages