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

Ads/Runtime: move getIntersectionChangeEntry out of Runtime and into Ads only #34133

Closed
wants to merge 6 commits into from

Conversation

samouri
Copy link
Member

@samouri samouri commented Apr 30, 2021

summary
I have been attempting to remove all usages of getIntersectionChangeEntry from the Runtime since last December (#31753). One last usage has been particularly tricky to remove because of being part of the ads render flow, and the requirement to ensure it doesn't degrade impressions.

This PR opts to remove ads as a blocker, by simply moving all the same logic to ads folders and out of custom-element. Note: this creates a usage of custom-element.getLayoutBox, but we can deal with that in a future PR.

changes

  • Renames getIntersectionChangeEntry within intersection-observer-3p-host to getIntersectionChangeEntryHelper.
  • Moves getIntersectionChangeEntry from custom-element to intersection-observer-3p-host, and updates all the associated tests.

Size changes:

dist/v0/amp-apester-media-0.1.mjs: Δ +0.03KB
dist/v0/amp-iframe-0.1.js: Δ -0.01KB
dist/v0/amp-apester-media-0.1.js: Δ -0.01KB
dist/compiler.mjs: Δ +0.02KB
dist/compiler.js: Δ -0.01KB
dist/v0/amp-ad-0.1.mjs: Δ +0.23KB
dist/v0/amp-ad-0.1.js: Δ +0.24KB
dist/v0/amp-ad-custom-0.1.mjs: Δ +0.22KB
dist/v0/amp-ad-custom-0.1.js: Δ +0.29KB
dist/v0/amp-ad-network-dianomi-impl-0.1.mjs: Δ +0.31KB
dist/v0/amp-ad-network-nws-impl-0.1.mjs: Δ +0.26KB
dist/v0/amp-ad-network-adzerk-impl-0.1.mjs: Δ +0.28KB
dist/v0/amp-ad-network-fake-impl-0.1.mjs: Δ +0.27KB
dist/v0/amp-ad-network-dianomi-impl-0.1.js: Δ +0.20KB
dist/v0/amp-ad-network-nws-impl-0.1.js: Δ +0.19KB
dist/v0/amp-ad-network-adzerk-impl-0.1.js: Δ +0.26KB
dist/v0/amp-ad-network-fake-impl-0.1.js: Δ +0.24KB
dist/v0/amp-ad-network-valueimpression-impl-0.1.mjs: Δ +0.23KB
dist/v0/amp-ad-network-valueimpression-impl-0.1.js: Δ +0.20KB
dist/v0/amp-ad-network-adsense-impl-0.1.mjs: Δ +0.23KB
dist/v0/amp-ad-network-adsense-impl-0.1.js: Δ +0.30KB
dist/amp4ads-v0.mjs: Δ -0.19KB
dist/v0/amp-ad-network-doubleclick-impl-0.1.mjs: Δ +0.22KB
dist/v0/amp-ad-network-doubleclick-impl-0.1.js: Δ +0.20KB
dist/amp4ads-v0.js: Δ -0.22KB
dist/shadow-v0.mjs: Δ -0.22KB
dist/v0.mjs: Δ -0.19KB
dist/shadow-v0.js: Δ -0.22KB
dist/v0.js: Δ -0.24KB

@samouri samouri self-assigned this Apr 30, 2021
@samouri samouri requested a review from jridgewell April 30, 2021 16:10
@samouri samouri marked this pull request as ready for review April 30, 2021 16:38
@amp-owners-bot
Copy link

Hey @Jiaming-X! These files were changed:

extensions/amp-ad-network-adsense-impl/0.1/amp-ad-network-adsense-impl.js

Hey @jeffkaufman! These files were changed:

extensions/amp-ad-network-adsense-impl/0.1/amp-ad-network-adsense-impl.js
extensions/amp-ad-network-doubleclick-impl/0.1/amp-ad-network-doubleclick-impl.js

* @return {!IntersectionChangeEntry} a change entry
*/
export function getIntersectionChangeEntry(element) {
const box = element.getLayoutBox();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is intended to get the bounding client rect of the ad iframe, not the amp-element. Are we sure the size is the same?

Also, this is an absolutely positioned (from the top-left corner of the <body>) box, and not a viewport-relative box, which is extremely important for ads (they want to know that they're in viewport, not 10m pixels down the page). We can accommodate that in getIntersectionChangeEntryHelper by subtracting the viewportBox's position.

@stale
Copy link

stale bot commented Sep 21, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Inactive for one year or more label Sep 21, 2022
@stale stale bot closed this Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Inactive for one year or more
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants