Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low-hanging fruit replacements for getLayoutWidth/Box uses and deprecate some measurement APIs #31490

Merged
merged 2 commits into from
Dec 8, 2020

Conversation

dvoytenko
Copy link
Contributor

@dvoytenko dvoytenko commented Dec 8, 2020

Mostly replaced getLayoutBox/getLayoutWidth with a direct measurement where the old code is doing additional measurements anyway.

Partial for #31540.

build-system/tasks/presubmit-checks.js Show resolved Hide resolved
@@ -321,7 +321,7 @@ export class AmpScrollableCarousel extends BaseCarousel {
* @private
*/
withinWindow_(pos, callback) {
const containerWidth = this.element.getLayoutWidth();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we guaranteed that these sync measures won't cause reflows/jank? Shouldn't we still be relying on vysnc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in this case, because:

  1. There's more measuring code is peppered there, which negates any benefits.
  2. It's a component in the deprecation track.

@@ -114,7 +114,7 @@ export class AmpVizVega extends AMP.BaseElement {

/** @override */
onLayoutMeasure() {
const box = this.getLayoutBox();
const box = this./*OK*/ getBoundingClientRect();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here re. sync measurement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Measurements in the onLayoutMeasure are technically free since they are called in a version of vsync.measure from resources-impl. But it's also a deprecated component.

@dvoytenko dvoytenko merged commit 8434ab5 into ampproject:master Dec 8, 2020
@dvoytenko dvoytenko deleted the run3/no-layout-box branch December 8, 2020 20:34
ed-bird pushed a commit to ed-bird/amphtml that referenced this pull request Dec 10, 2020
…ate some measurement APIs (ampproject#31490)

* Low-hanging fruit replace getLayoutWidth/Box uses and deprecated measurement APIs

* test fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants