Skip to content

Commit

Permalink
Merge tag '1455583178615' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
camelburrito committed Feb 16, 2016
2 parents b22c45e + 6db7c8c commit 94ba705
Show file tree
Hide file tree
Showing 115 changed files with 4,368 additions and 1,599 deletions.
14 changes: 8 additions & 6 deletions 3p/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,11 @@ function minTime(time) {
return time;
}

listenParent(window, 'embed-state', function(data) {
inViewport = data.inViewport;
if (inViewport) {
becomeVisible();
}
});
export function installEmbedStateListener() {
listenParent(window, 'embed-state', function(data) {
inViewport = data.inViewport;
if (inViewport) {
becomeVisible();
}
});
};
5 changes: 5 additions & 0 deletions 3p/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

import './polyfills';
import {installEmbedStateListener} from './environment';
import {a9} from '../ads/a9';
import {adform} from '../ads/adform';
import {adreactor} from '../ads/adreactor';
Expand All @@ -41,6 +42,7 @@ import {parseUrl} from '../src/url';
import {assert} from '../src/asserts';
import {taboola} from '../ads/taboola';
import {smartadserver} from '../ads/smartadserver';
import {revcontent} from '../ads/revcontent';

/**
* Whether the embed type may be used with amp-embed tag.
Expand All @@ -66,6 +68,7 @@ register('_ping_', function(win, data) {
register('twitter', twitter);
register('facebook', facebook);
register('smartadserver', smartadserver);
register('revcontent', revcontent);

/**
* Visible for testing.
Expand Down Expand Up @@ -154,7 +157,9 @@ window.draw3p = function(opt_configCallback) {
window.context.reportRenderedEntityIdentifier =
reportRenderedEntityIdentifier;
delete data._context;

manageWin(window);
installEmbedStateListener();
draw3p(window, data, opt_configCallback);
updateVisibilityState(window);
nonSensitiveDataPostMessage('render-start');
Expand Down
6 changes: 6 additions & 0 deletions ads/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const adPrefetch = {
dotandads: 'https://amp.ad.dotandad.com/dotandadsAmp.js',
smartadserver: 'https://ec-ns.sascdn.com/diff/js/smart.js',
yieldmo: 'https://static.yieldmo.com/ym.amp1.js',
revcontent: 'https://labs-cdn.revcontent.com/build/amphtml/revcontent.amp.min.js',
};

/**
Expand Down Expand Up @@ -57,6 +58,11 @@ export const adPreconnect = {
'https://s.yieldmo.com',
'https://ads.yieldmo.com',
],
revcontent: [
'https://trends.revcontent.com',
'https://cdn.revcontent.com',
'https://img.revcontent.com',
]
};

/**
Expand Down
28 changes: 28 additions & 0 deletions ads/revcontent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright 2015 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {writeScript, checkData} from '../src/3p';

/**
* @param {!Window} global
* @param {!Object} data
*/
export function revcontent(global, data) {
checkData(data, ['id', 'width', 'height', 'endpoint', 'ssl', 'wrapper']);
const revampServiceUrl = 'https://labs-cdn.revcontent.com/build/amphtml/revcontent.amp.min.js';
global.data = data;
writeScript(window, revampServiceUrl);
}
40 changes: 40 additions & 0 deletions ads/revcontent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!---
Copyright 2015 The AMP HTML Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Revcontent

## Example

```html
<amp-ad width=320 height=420
type="revcontent"
data-wrapper="rcjsload_2ff711"
data-endpoint="trends.revcontent.com"
data-id="203">
</amp-ad>
```

## Configuration

For semantics of configuration, please see [ad network documentation](http://faq.revcontent.com/support/solutions/5000137293).

Supported parameters:

- data-id
- data-wrapper
- data-endpoint
- data-ssl
- data-testing
4 changes: 3 additions & 1 deletion ads/taboola.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ export function taboola(global, data) {
framework: 'amp',
container: 'c'
},
params]);
params,
{flush: true}]
);

// install observation on entering/leaving the view
global.context.observeIntersection(function(changes) {
Expand Down
1 change: 1 addition & 0 deletions build-system/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ module.exports = {
'!validator/node_modules/**/*.*',
'!build-system/tasks/presubmit-checks.js',
'!build/polyfills.js',
'!build/polyfills/*.js',
'!gulpfile.js',
'!third_party/**/*.*',
],
Expand Down
33 changes: 24 additions & 9 deletions build-system/tasks/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var rename = require('gulp-rename');
var replace = require('gulp-replace');
var internalRuntimeVersion = require('../internal-version').VERSION;
var internalRuntimeToken = require('../internal-version').TOKEN;
var rimraf = require('rimraf');

var isProdBuild = !!argv.type;
var queue = [];
Expand Down Expand Up @@ -69,14 +70,12 @@ function compile(entryModuleFilename, outputDir,
entryModuleFilename.replace(/\//g, '_').replace(/^\./, '');
console./*OK*/log('Starting closure compiler for ', entryModuleFilename);
fs.mkdirsSync('build/cc');
rimraf.sync('build/fake-module');
fs.mkdirsSync('build/fake-module/third_party/babel');
fs.mkdirsSync('build/fake-module/src');
fs.writeFileSync(
'build/fake-module/third_party/babel/custom-babel-helpers.js',
'// Not needed in closure compiler\n');
fs.writeFileSync(
'build/fake-module/src/polyfills.js',
'// Not needed in closure compiler\n');
fs.mkdirsSync('build/fake-module/src/polyfills/');
var unneededFiles = [
'build/fake-module/third_party/babel/custom-babel-helpers.js',
];
var wrapper = windowConfig.getTemplate() +
'(function(){var process={env:{NODE_ENV:"production"}};' +
'%output%})();';
Expand Down Expand Up @@ -106,6 +105,7 @@ function compile(entryModuleFilename, outputDir,
'build/**/*.js',
'!build/cc/**',
'!build/polyfills.js',
'!build/polyfills/**/*.js',
'src/**/*.js',
'!third_party/babel/custom-babel-helpers.js',
// Exclude since it's not part of the runtime/extension binaries.
Expand All @@ -114,6 +114,7 @@ function compile(entryModuleFilename, outputDir,
'third_party/caja/html-sanitizer.js',
'third_party/closure-library/sha384-generated.js',
'third_party/mustache/**/*.js',
'node_modules/promise-pjs/promise.js',
'node_modules/document-register-element/build/' +
'document-register-element.max.js',
'node_modules/core-js/modules/**.js',
Expand All @@ -128,10 +129,24 @@ function compile(entryModuleFilename, outputDir,
// once. Since all files automatically wait for the main binary to load
// this works fine.
if (options.includePolyfills) {
srcs.push('!build/fake-module/src/polyfills.js');
srcs.push(
'!build/fake-module/src/polyfills.js',
'!build/fake-module/src/polyfills/**/*.js'
);
} else {
srcs.push('!src/polyfills.js');
srcs.push(
'!src/polyfills.js',
'!src/polyfills/**/*.js'
);
unneededFiles.push(
'build/fake-module/src/polyfills.js',
'build/fake-module/src/polyfills/promise.js',
'build/fake-module/src/polyfills/math-sign.js'
);
}
unneededFiles.forEach(function(fake) {
fs.writeFileSync(fake, '// Not needed in closure compiler\n');
});
/*eslint "google-camelcase/google-camelcase": 0*/
return gulp.src(srcs)
.pipe(closureCompiler({
Expand Down
23 changes: 21 additions & 2 deletions build-system/tasks/presubmit-checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ var forbiddenTerms = {
'validator/validator-in-browser.js',
]
},
'iframePing': {
message: 'This is only available in vendor config for ' +
'temporary workarounds.',
whitelist: [
'extensions/amp-analytics/0.1/amp-analytics.js',
],
},
// Service factories that should only be installed once.
'installActionService': {
message: privateServiceFactory,
Expand Down Expand Up @@ -221,14 +228,26 @@ var forbiddenTerms = {
'openDatabase': requiresReviewPrivacy,
'requestFileSystem': requiresReviewPrivacy,
'webkitRequestFileSystem': requiresReviewPrivacy,
'getAccessReaderId': {
message: requiresReviewPrivacy,
whitelist: [
'extensions/amp-access/0.1/amp-access.js',
'src/url-replacements.js',
]
},
'getAuthdataField': {
message: requiresReviewPrivacy,
whitelist: [
'extensions/amp-access/0.1/amp-access.js',
'src/url-replacements.js',
]
},
'debugger': '',

// ES6. These are only the most commonly used.
'Array\\.of': es6polyfill,
// These currently depend on core-js/modules/web.dom.iterable which
// we don't want. That decision could be reconsidered.
'Promise\\.all': es6polyfill,
'Promise\\.race': es6polyfill,
'\\.startsWith': {
message: es6polyfill,
whitelist: [
Expand Down
62 changes: 1 addition & 61 deletions builtins/amp-ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {loadPromise} from '../src/event-helper';
import {parseUrl} from '../src/url';
import {registerElement} from '../src/custom-element';
import {adPrefetch, adPreconnect, clientIdScope} from '../ads/_config';
import {toggle} from '../src/style';
import {timer} from '../src/timer';
import {viewerFor} from '../src/viewer';
import {userNotificationManagerFor} from '../src/user-notification';
Expand Down Expand Up @@ -111,18 +110,6 @@ export function installAd(win) {
/** @private {IntersectionObserver} */
this.intersectionObserver_ = null;

/**
* In this state the iframe is set to display: none to reduce
* CPU/GPU/Battery consumption by the ad.
* @private {boolean}
*/
this.paused_ = false;

/**
* Whether this ad was ever in the viewport.
*/
this.wasEverVisible_ = false;

/**
* @private @const
*/
Expand Down Expand Up @@ -223,7 +210,6 @@ export function installAd(win) {

/** @override */
layoutCallback() {
this.maybeUnpause_();
if (!this.iframe_) {
loadingAdsCount++;
assert(!this.isInFixedContainer_,
Expand Down Expand Up @@ -283,13 +269,6 @@ export function installAd(win) {
return loadPromise(this.iframe_);
}

/** @override */
documentInactiveCallback() {
this.maybePause_();
// Call layoutCallback again when this document becomes active.
return true;
}

/**
* @return {!Promise<string|undefined>} A promise for a CID or undefined if
* - the ad network does not request one or
Expand All @@ -309,7 +288,7 @@ export function installAd(win) {
const consentId = this.element.getAttribute(
'data-consent-notification-id');
if (consentId) {
consent = userNotificationManagerFor(this.win).then(service => {
consent = userNotificationManagerFor(this.getWin()).then(service => {
return service.get(consentId);
});
}
Expand All @@ -319,51 +298,12 @@ export function installAd(win) {

/** @override */
viewportCallback(inViewport) {
if (inViewport) {
this.wasEverVisible_ = true;
this.maybeUnpause_();
} else {
this.maybePause_();
}
if (this.intersectionObserver_) {
this.intersectionObserver_.onViewportCallback(inViewport);
}
this.sendEmbedInfo_(inViewport);
}

/**
* Unpauses the ad if it is paused.
* @private
*/
maybeUnpause_() {
if (this.paused_) {
this.paused_ = false;
toggle(this.iframe_, true);
}
}

/**
* Pauses the ad unless
* - it was never visible and the viewport is visible.
* We have that exception because setting `diplay:none` can break some
* measurements inside the ad and these are more likely to occur early
* in the ad lifecycle. We could probably enhance this by still hiding
* ads that have been loaded for a while (Say 10 seconds).
* @private
*/
maybePause_() {
if (!this.wasEverVisible_ && this.viewer_.isVisible()) {
return;
}
// We only pause ads that have been visible before
if (this.iframe_ && !this.paused_) {
this.paused_ = true;
// When the doc is inactive, hide the ads, so any work they do takes
// less CPU and power.
toggle(this.iframe_, false);
}
}

/**
* @param {boolean} inViewport
* @private
Expand Down
1 change: 1 addition & 0 deletions builtins/amp-ad.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ resources in AMP. It requires a `type` argument that select what ad network is d
- [plista](../ads/plista.md)
- [Smart AdServer](../ads/smartadserver.md)
- [Yieldmo](../ads/yieldmo.md)
- [Revcontent](../ads/revcontent.md)

#### Styling

Expand Down
Loading

0 comments on commit 94ba705

Please sign in to comment.