Skip to content

Commit

Permalink
Only in localDev
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Aug 15, 2019
1 parent b0a794e commit 0febff8
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 30 deletions.
4 changes: 2 additions & 2 deletions extensions/amp-carousel/0.1/scrollable-carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import {BaseCarousel} from './base-carousel';
import {Layout} from '../../../src/layout';
import {Services} from '../../../src/services';
import {dev} from '../../../src/log';
import {getMode} from '../../../src/mode';
import {isExperimentOn} from '../../../src/experiments';
import {listen} from '../../../src/event-helper';
import {numeric} from '../../../src/transition';
import {getMode} from '../../../src/mode';

/** @const {string} */
const TAG = 'amp-scrollable-carousel';
Expand Down Expand Up @@ -66,7 +66,7 @@ export class AmpScrollableCarousel extends BaseCarousel {
this.element.appendChild(this.container_);

this.useLayersPrioritization_ =
(getMode().localDev || getMode().test) &&
getMode().localDev &&
isExperimentOn(this.win, 'layers') &&
isExperimentOn(this.win, 'layers-prioritization');

Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-image-slider/0.1/amp-image-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import {Services} from '../../../src/services';
import {SwipeXRecognizer} from '../../../src/gesture-recognizers';
import {clamp} from '../../../src/utils/math';
import {dev, user, userAssert} from '../../../src/log';
import {getMode} from '../../../src/mode';
import {isExperimentOn} from '../../../src/experiments';
import {isLayoutSizeDefined} from '../../../src/layout';
import {listen} from '../../../src/event-helper';
import {setStyles} from '../../../src/style';
import {getMode} from '../../../src/mode';

export class AmpImageSlider extends AMP.BaseElement {
/** @param {!AmpElement} element */
Expand Down Expand Up @@ -107,7 +107,7 @@ export class AmpImageSlider extends AMP.BaseElement {

/** @private @const {boolean} */
this.useLayersPrioritization_ =
(getMode().localDev || getMode().test) &&
getMode().localDev &&
isExperimentOn(this.win, 'layers') &&
isExperimentOn(this.win, 'layers-prioritization');
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-live-list/0.1/amp-live-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import {AmpEvents} from '../../../src/amp-events';
import {CSS} from '../../../build/amp-live-list-0.1.css';
import {Layout} from '../../../src/layout';
import {childElementByAttr} from '../../../src/dom';
import {getMode} from '../../../src/mode';
import {isExperimentOn} from '../../../src/experiments';
import {user, userAssert} from '../../../src/log';
import {getMode} from '../../../src/mode';

/**
* @enum {string}
Expand Down Expand Up @@ -999,7 +999,7 @@ export class AmpLiveList extends AMP.BaseElement {
* @return {boolean}
*/
isElementBelowViewport_(element) {
if ((getMode().localDev || getMode().test) && isExperimentOn(this.win, 'layers')) {
if (getMode().localDev && isExperimentOn(this.win, 'layers')) {
// Well, if the scroller is above the viewport, but the element is way
// down in the box, is it above or below?
return this.viewport_.getLayoutRect(element).top > 0;
Expand Down
2 changes: 1 addition & 1 deletion src/base-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ export class BaseElement {
*/
declareLayer(opt_element) {
devAssert(
(getMode().localDev || getMode().test) && isExperimentOn(this.win, 'layers'),
getMode().localDev && isExperimentOn(this.win, 'layers'),
'Layers must be enabled to declare layer.'
);
if (opt_element) {
Expand Down
4 changes: 2 additions & 2 deletions src/custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ function createBaseCustomElementClass(win) {
// Resources can now be initialized since the ampdoc is now available.
this.resources_ = Services.resourcesForDoc(this.ampdoc_);
}
if ((getMode().localDev || getMode().test) && isExperimentOn(this.ampdoc_.win, 'layers')) {
if (getMode().localDev && isExperimentOn(this.ampdoc_.win, 'layers')) {
if (!this.layers_) {
// Resources can now be initialized since the ampdoc is now available.
this.layers_ = Services.layersForDoc(this.ampdoc_);
Expand Down Expand Up @@ -999,7 +999,7 @@ function createBaseCustomElementClass(win) {

this.isConnected_ = false;
this.getResources().remove(this);
if ((getMode().localDev || getMode().test) && isExperimentOn(this.ampdoc_.win, 'layers')) {
if (getMode().localDev && isExperimentOn(this.ampdoc_.win, 'layers')) {
this.getLayers().remove(this);
}
this.implementation_.detachedCallback();
Expand Down
4 changes: 2 additions & 2 deletions src/inabox/inabox-viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import {ViewportBindingDef} from '../service/viewport/viewport-binding-def';
import {ViewportImpl} from '../service/viewport/viewport-impl';
import {canInspectWindow} from '../iframe-helper';
import {dev, devAssert} from '../log';
import {getMode} from '../mode';
import {getPositionObserver} from '../../ads/inabox/position-observer';
import {iframeMessagingClientFor} from './inabox-iframe-messaging-client';
import {isExperimentOn} from '../experiments';
import {layoutRectLtwh, moveLayoutRect} from '../layout-rect';
import {px, resetStyles, setImportantStyles} from '../style';
import {registerServiceBuilderForDoc} from '../service';
import {throttle} from '../utils/rate-limit';
import {getMode} from '../mode';

/** @const {string} */
const TAG = 'inabox-viewport';
Expand Down Expand Up @@ -153,7 +153,7 @@ export class ViewportBindingInabox {
);

/** @private @const {boolean} */
this.useLayers_ = (getMode().localDev || getMode().test) && isExperimentOn(this.win, 'layers');
this.useLayers_ = getMode().localDev && isExperimentOn(this.win, 'layers');

/** @private {?../../ads/inabox/position-observer.PositionObserver} */
this.topWindowPositionObserver_ = null;
Expand Down
11 changes: 5 additions & 6 deletions src/service/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {Layout} from '../layout';
import {Services} from '../services';
import {computedStyle, toggle} from '../style';
import {dev, devAssert} from '../log';
import {getMode} from '../mode';
import {isBlockedByConsent} from '../error';
import {isExperimentOn} from '../experiments';
import {
Expand All @@ -29,7 +30,6 @@ import {
} from '../layout-rect';
import {startsWith} from '../string';
import {toWin} from '../types';
import {getMode} from '../mode';

const TAG = 'Resource';
const RESOURCE_PROP_ = '__AMP__RESOURCE';
Expand Down Expand Up @@ -215,13 +215,12 @@ export class Resource {
this.loadPromiseResolve_ = deferred.resolve;

/** @private @const {boolean} */
this.useLayers_ = (getMode().localDev || getMode().test) && isExperimentOn(this.hostWin, 'layers');
this.useLayers_ =
getMode().localDev && isExperimentOn(this.hostWin, 'layers');

/** @private @const {boolean} */
this.useLayersPrioritization_ = this.useLayers_ && isExperimentOn(
this.hostWin,
'layers-prioritization'
);
this.useLayersPrioritization_ =
this.useLayers_ && isExperimentOn(this.hostWin, 'layers-prioritization');
}

/**
Expand Down
10 changes: 4 additions & 6 deletions src/service/resources-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {closest, hasNextNodeInDocumentOrder} from '../dom';
import {computedStyle} from '../style';
import {dev, devAssert, user} from '../log';
import {dict, hasOwn} from '../utils/object';
import {getMode} from '../mode';
import {getSourceUrl, isProxyOrigin} from '../url';
import {checkAndFix as ieMediaCheckAndFix} from './ie-media-bug';
import {isArray} from '../types';
Expand All @@ -35,7 +36,6 @@ import {isExperimentOn} from '../experiments';
import {loadPromise} from '../event-helper';
import {registerServiceBuilderForDoc} from '../service';
import {remove} from '../utils/array';
import {getMode} from '../mode';

const TAG_ = 'Resources';
const READY_SCAN_SIGNAL_ = 'ready-scan';
Expand Down Expand Up @@ -403,13 +403,11 @@ export class Resources {
this.queue_ = new TaskQueue();

/** @private @const {boolean} */
this.useLayers_ = (getMode().localDev || getMode().test) && isExperimentOn(this.win, 'layers');
this.useLayers_ = getMode().localDev && isExperimentOn(this.win, 'layers');

/** @private @const {boolean} */
this.useLayersPrioritization_ = this.useLayers_ && isExperimentOn(
this.win,
'layers-prioritization'
);
this.useLayersPrioritization_ =
this.useLayers_ && isExperimentOn(this.win, 'layers-prioritization');

let boundScorer;
if (this.useLayersPrioritization_) {
Expand Down
4 changes: 2 additions & 2 deletions src/service/viewport/viewport-binding-ios-embed-sd.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ import {
setInitialDisplay,
} from '../../style';
import {dev} from '../../log';
import {getMode} from '../../mode';
import {htmlFor} from '../../static-template';
import {isExperimentOn} from '../../experiments';
import {layoutRectLtwh} from '../../layout-rect';
import {waitForBodyOpen} from '../../dom';
import {whenDocumentReady} from '../../document-ready';
import {getMode} from '../../mode';

const TAG_ = 'Viewport';

Expand Down Expand Up @@ -171,7 +171,7 @@ export class ViewportBindingIosEmbedShadowRoot_ {
this.boundResizeEventListener_ = this.onResized_.bind(this);

/** @private @const {boolean} */
this.useLayers_ = (getMode().localDev || getMode().test) && isExperimentOn(this.win, 'layers');
this.useLayers_ = getMode().localDev && isExperimentOn(this.win, 'layers');

/** @private {boolean} */
this.bodySyncScheduled_ = false;
Expand Down
4 changes: 2 additions & 2 deletions src/service/viewport/viewport-binding-ios-embed-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import {
} from './viewport-binding-def';
import {computedStyle, px, setImportantStyles} from '../../style';
import {dev} from '../../log';
import {getMode} from '../../mode';
import {isExperimentOn} from '../../experiments';
import {layoutRectLtwh} from '../../layout-rect';
import {waitForBodyOpen} from '../../dom';
import {whenDocumentReady} from '../../document-ready';
import {getMode} from '../../mode';

const TAG_ = 'Viewport';

Expand Down Expand Up @@ -75,7 +75,7 @@ export class ViewportBindingIosEmbedWrapper_ {
this.boundResizeEventListener_ = () => this.resizeObservable_.fire();

/** @private @const {boolean} */
this.useLayers_ = (getMode().localDev || getMode().test) && isExperimentOn(this.win, 'layers');
this.useLayers_ = getMode().localDev && isExperimentOn(this.win, 'layers');

/** @private {number} */
this.paddingTop_ = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/service/viewport/viewport-binding-natural.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import {
} from './viewport-binding-def';
import {computedStyle, px, setImportantStyles} from '../../style';
import {dev} from '../../log';
import {getMode} from '../../mode';
import {isExperimentOn} from '../../experiments';
import {layoutRectLtwh} from '../../layout-rect';
import {getMode} from '../../mode';

const TAG_ = 'Viewport';

Expand Down Expand Up @@ -68,7 +68,7 @@ export class ViewportBindingNatural_ {
this.boundResizeEventListener_ = () => this.resizeObservable_.fire();

/** @private @const {boolean} */
this.useLayers_ = (getMode().localDev || getMode().test) && isExperimentOn(this.win, 'layers');
this.useLayers_ = getMode().localDev && isExperimentOn(this.win, 'layers');

dev().fine(TAG_, 'initialized natural viewport');
}
Expand Down
2 changes: 1 addition & 1 deletion src/service/viewport/viewport-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class ViewportImpl {
this.originalViewportMetaString_ = undefined;

/** @private @const {boolean} */
this.useLayers_ = (getMode().localDev || getMode().test) && isExperimentOn(win, 'layers');
this.useLayers_ = getMode().localDev && isExperimentOn(win, 'layers');
if (this.useLayers_) {
installLayersServiceForDoc(
ampdoc,
Expand Down

0 comments on commit 0febff8

Please sign in to comment.