Skip to content

Make render-start respond to resize info#4842

Merged
zhouyx merged 10 commits intoampproject:masterfrom
zhouyx:render-start-resize
Sep 8, 2016
Merged

Make render-start respond to resize info#4842
zhouyx merged 10 commits intoampproject:masterfrom
zhouyx:render-start-resize

Conversation

@zhouyx
Copy link
Copy Markdown
Contributor

@zhouyx zhouyx commented Sep 6, 2016

This is to make render-start API support multi-size ad. #3176
It's also an improvement to ad load behavior #4022


function triggerRenderStart() {
nonSensitiveDataPostMessage('render-start');
function triggerRenderStart(width, height) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I copy the format from other function that postMessages. triggerRenderStart() and triggerRenderStart(width, height) both work, how can we represent this in our code and let 3p ad know?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's make the param a opt_data object, for future extensibility.
A JS doc for this optional param would help.

We should also update ads/README.md.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed. will add JS doc

* @private
*/
sendEmbedInfo_(inViewport) {
if (!this.embedStateApi_) {
Copy link
Copy Markdown
Contributor Author

@zhouyx zhouyx Sep 7, 2016

Choose a reason for hiding this comment

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

viewportCallback() can be called anytime after element build. this.embedStateApi_ may not be initiated when this function is called. Add the check here.

ads/README.md Outdated
- `window.context.noContentAvailable` is a function that the ad system can call if the ad slot was not filled. The container page will then react by showing fallback content or collapsing the ad if allowed by AMP resizing rules.
- `window.context.reportRenderedEntityIdentifier` MUST be called by ads, when they know information about which creative was rendered into a particular ad frame and should contain information to allow identifying the creative. Consider including a small string identifying the ad network. This is used by AMP for reporting purposes. The value MUST NOT contain user data or personal identifiable information.
- `window.context.renderStart` is a function that the ad system can call if the ad start rendering. The ad would then set the visibility of the iframe to visible. The ad type needs to be included in `waitForRenderStart` list in [integration.js](../3p/integration.js) for this function to be available.
- `window.context.renderStart(opt_data)` is a function that the ad system can call if the ad start rendering. The ad would then set the visibility of the iframe to visible. The ad type needs to be included in `waitForRenderStart` list in [integration.js](../3p/integration.js) for this function to be available. Ad system can use opt_data object {width, height} to send the rendered ad size which AMP will use for resize. Please check Ad resizing part for more information.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

... the returned ad size to request a resize. ...

Also, pls format opt_data into code style, same for {width, height}.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please also move this bullet point to the top (before noContentAvailable). And consider to change the wording from can to should, as we plan to push more ad networks to implement the new APIs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

should we also do this for noContentAvailabe?

consider to change the wording from can to should

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, please

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

it('should resolve and resize on message "render-start" w/ size if '
+ 'render-start is implemented by 3P', () => {
adImpl.adType = 'doubleclick';
sandbox.stub(adImpl, 'attemptChangeSize', () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please verify the size is correctly passed to attemptChangeSize

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

ads/README.md Outdated
- `window.context.noContentAvailable` is a function that the ad system can call if the ad slot was not filled. The container page will then react by showing fallback content or collapsing the ad if allowed by AMP resizing rules.
- `window.context.reportRenderedEntityIdentifier` MUST be called by ads, when they know information about which creative was rendered into a particular ad frame and should contain information to allow identifying the creative. Consider including a small string identifying the ad network. This is used by AMP for reporting purposes. The value MUST NOT contain user data or personal identifiable information.
- `window.context.renderStart` is a function that the ad system can call if the ad start rendering. The ad would then set the visibility of the iframe to visible. The ad type needs to be included in `waitForRenderStart` list in [integration.js](../3p/integration.js) for this function to be available.
- `window.context.renderStart(opt_data)` is a function that the ad system can call if the ad start rendering. The ad would then set the visibility of the iframe to visible. The ad type needs to be included in `waitForRenderStart` list in [integration.js](../3p/integration.js) for this function to be available. Ad system can use `opt_data` object of form `{width, height}` to send the returned ad size to request a resize. Please check Ad resizing part for more information.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also add a link to "Ad resizing"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@lannka
Copy link
Copy Markdown
Contributor

lannka commented Sep 7, 2016

LGTM with some cosmetic nitpicks.

@lannka lannka added LGTM and removed NEEDS REVIEW labels Sep 7, 2016
ads/README.md Outdated
### Methods available to the ad.

- `window.context.noContentAvailable` is a function that the ad system can call if the ad slot was not filled. The container page will then react by showing fallback content or collapsing the ad if allowed by AMP resizing rules.
- `window.context.renderStart(opt_data)` is a function that the ad system should call if the ad start rendering. The ad would then set the visibility of the iframe to visible. The ad type needs to be included in `waitForRenderStart` list in [integration.js](../3p/integration.js) for this function to be available. Ad system can use `opt_data` object of form `{width, height}` to send the returned ad size to request a resize. Please check [Ad resizing](https://github.com/ampproject/amphtml/blob/master/ads/README.md#ad-resizing) for more information.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

About the link, I think #ad-resizing should be enough?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you're right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants