Skip to content

Commit

Permalink
Pure renaming. Create resources-interface.js, owners-interface.js, mu…
Browse files Browse the repository at this point in the history
…tator-interface.js (ampproject#24379)
  • Loading branch information
lannka authored Sep 5, 2019
1 parent 45893ae commit e0ed3d5
Show file tree
Hide file tree
Showing 32 changed files with 414 additions and 363 deletions.
2 changes: 1 addition & 1 deletion ads/google/a4a/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export function groupAmpAdsByType(win, type, groupFn) {
const {documentElement} = win.document;
// TODO(lannka): should avoid this type casting by moving the `getMeasuredResources`
// logic here.
const resources = /** @type {!../../../src/service/resources-impl.Resources} */ (Services.resourcesForDoc(
const resources = /** @type {!../../../src/service/resources-impl.ResourcesImpl} */ (Services.resourcesForDoc(
documentElement
));
return (
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-access/0.1/amp-access.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class AccessService {
/** @private @const {!../../../src/service/template-impl.Templates} */
this.templates_ = Services.templatesFor(ampdoc.win);

/** @private @const {!../../../src/service/resources-impl.ResourcesDef} */
/** @private @const {!../../../src/service/resources-interface.ResourcesInterface} */
this.resources_ = Services.resourcesForDoc(ampdoc);

/** @private @const {?../../../src/service/performance-impl.Performance} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-animation/0.1/web-animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class Builder {
* @param {!Document|!ShadowRoot} rootNode
* @param {string} baseUrl
* @param {!../../../src/service/vsync-impl.Vsync} vsync
* @param {!../../../src/service/owners-impl.OwnersDef} owners
* @param {!../../../src/service/owners-interface.OwnersInterface} owners
*/
constructor(win, rootNode, baseUrl, vsync, owners) {
/** @const @private */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-auto-ads/0.1/placement.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class Placement {
/** @const {!../../../src/service/ampdoc-impl.AmpDoc} */
this.ampdoc = ampdoc;

/** @const @private {!../../../src/service/resources-impl.ResourcesDef} */
/** @const @private {!../../../src/service/resources-interface.ResourcesInterface} */
this.resources_ = Services.resourcesForDoc(anchorElement);

/** @const @private {!../../../src/service/viewport/viewport-interface.ViewportInterface} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-bind/0.1/bind-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class Bind {
*/
this.maxNumberOfBindings_ = 1000;

/** @const @private {!../../../src/service/resources-impl.ResourcesDef} */
/** @const @private {!../../../src/service/resources-interface.ResourcesInterface} */
this.resources_ = Services.resourcesForDoc(ampdoc);

/**
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-form/0.1/amp-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class AmpForm {
/** @const @private {!../../../src/service/action-impl.ActionService} */
this.actions_ = Services.actionServiceForDoc(this.form_);

/** @const @private {!../../../src/service/resources-impl.ResourcesDef} */
/** @const @private {!../../../src/service/resources-interface.ResourcesInterface} */
this.resources_ = Services.resourcesForDoc(this.form_);

/** @const @private {!../../../src/service/viewer-interface.ViewerInterface} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-form/0.1/form-validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class FormValidator {
/** @protected @const {!../../../src/service/ampdoc-impl.AmpDoc} */
this.ampdoc = Services.ampdoc(form);

/** @const @protected {!../../../src/service/resources-impl.ResourcesDef} */
/** @const @protected {!../../../src/service/resources-interface.ResourcesInterface} */
this.resources = Services.resourcesForDoc(form);

/** @protected @const {!Document|!ShadowRoot} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-fx-collection/0.1/providers/fx-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class FxElement {
/** @private @const {!../../../../src/service/viewport/viewport-interface.ViewportInterface} */
this.viewport_ = Services.viewportForDoc(element);

/** @const @private {!../../../../src/service/resources-impl.ResourcesDef} */
/** @const @private {!../../../../src/service/resources-interface.ResourcesInterface} */
this.resources_ = Services.resourcesForDoc(element);

/** @type {?number} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-next-page/0.1/next-page-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class NextPageService {
/** @private {?Element} */
this.separator_ = null;

/** @private {?../../../src/service/resources-impl.ResourcesDef} */
/** @private {?../../../src/service/resources-interface.ResourcesInterface} */
this.resources_ = null;

/** @private {?MultidocManager} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-story/0.1/amp-story-info-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class InfoDialog {
/** @private @const {!Element} */
this.parentEl_ = parentEl;

/** @private @const {!../../../src/service/resources-impl.ResourcesDef} */
/** @private @const {!../../../src/service/resources-interface.ResourcesInterface} */
this.resources_ = Services.resourcesForDoc(getAmpdoc(this.win_.document));

/** @private {?Element} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-story/1.0/amp-story-affiliate-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class AmpStoryAffiliateLink {
/** @private {string} */
this.text_ = this.element_.textContent;

/** @private @const {!../../../src/service/resources-impl.ResourcesDef} */
/** @private @const {!../../../src/service/resources-interface.ResourcesInterface} */
this.resources_ = Services.resourcesForDoc(getAmpdoc(this.win_.document));
}

Expand Down
6 changes: 3 additions & 3 deletions extensions/amp-story/1.0/amp-story-embedded-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ export class AmpStoryEmbeddedComponent {
/** @private @const {!./amp-story-store-service.AmpStoryStoreService} */
this.storeService_ = getStoreService(this.win_);

/** @private @const {!../../../src/service/resources-impl.ResourcesDef} */
/** @private @const {!../../../src/service/resources-interface.ResourcesInterface} */
this.resources_ = Services.resourcesForDoc(getAmpdoc(this.win_.document));

/** @private @const {!../../../src/service/owners-impl.Owners} */
/** @private @const {!../../../src/service/owners-interface.OwnersInterface} */
this.owners_ = Services.ownersForDoc(getAmpdoc(this.win_.document));

/** @private @const {!../../../src/service/timer-impl.Timer} */
Expand Down Expand Up @@ -801,7 +801,7 @@ export class AmpStoryEmbeddedComponent {
* that content around stays put.
* @param {!Element} pageEl
* @param {!Element} element
* @param {!../../../src/service/resources-impl.ResourcesDef} resources
* @param {!../../../src/service/resources-interface.ResourcesInterface} resources
*/
static prepareForAnimation(pageEl, element, resources) {
let elId = null;
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-story/1.0/amp-story-info-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class InfoDialog {
/** @private @const {!Element} */
this.parentEl_ = parentEl;

/** @private @const {!../../../src/service/resources-impl.ResourcesDef} */
/** @private @const {!../../../src/service/resources-interface.ResourcesInterface} */
this.resources_ = Services.resourcesForDoc(getAmpdoc(this.win_.document));

/** @private {?Element} */
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-story/1.0/amp-story-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export const NavigationDirection = {
* animation.
* @param {!Window} win
* @param {!Element} page
* @param {!../../../src/service/resources-impl.ResourcesDef} resources
* @param {!../../../src/service/resources-interface.ResourcesInterface} resources
* @return {function(!Element, ?UnlistenDef)}
*/
function debounceEmbedResize(win, page, resources) {
Expand Down Expand Up @@ -245,7 +245,7 @@ export class AmpStoryPage extends AMP.BaseElement {
/** @private {?Element} */
this.openAttachmentEl_ = null;

/** @private @const {!../../../src/service/resources-impl.ResourcesDef} */
/** @private @const {!../../../src/service/resources-interface.ResourcesInterface} */
this.resources_ = Services.resourcesForDoc(getAmpdoc(this.win.document));

const deferred = new Deferred();
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-story/1.0/page-advancement.js
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ class MediaBasedAdvancement extends AdvancementConfig {
/** @private @const {!../../../src/service/timer-impl.Timer} */
this.timer_ = Services.timerFor(win);

/** @private @const {!../../../src/service/resources-impl.ResourcesDef} */
/** @private @const {!../../../src/service/resources-interface.ResourcesInterface} */
this.resources_ = Services.resourcesForDoc(getAmpdoc(win.document));

/** @private @const {!Array<!Element>} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-story/1.0/progress-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class ProgressBar {
/** @private {!../../../src/service/ampdoc-impl.AmpDoc} */
this.ampdoc_ = Services.ampdocServiceFor(this.win_).getSingleDoc();

/** @private @const {!../../../src/service/resources-impl.ResourcesDef} */
/** @private @const {!../../../src/service/resources-interface.ResourcesInterface} */
this.resources_ = Services.resourcesForDoc(this.ampdoc_);

/** @private {!Object<string, number>} */
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-subscriptions/0.1/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Renderer {
/** @const @private */
this.ampdoc_ = ampdoc;

/** @const @private {!../../../src/service/resources-impl.ResourcesDef} */
/** @const @private {!../../../src/service/resources-interface.ResourcesInterface} */
this.resources_ = Services.resourcesForDoc(ampdoc);

// Initial state is "unknown".
Expand Down
6 changes: 3 additions & 3 deletions src/custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function createBaseCustomElementClass(win) {

/**
* Resources can only be looked up when an element is attached.
* @private {?./service/resources-impl.ResourcesDef}
* @private {?./service/resources-interface.ResourcesInterface}
*/
this.resources_ = null;

Expand Down Expand Up @@ -348,7 +348,7 @@ function createBaseCustomElementClass(win) {
/**
* Returns Resources manager. Only available after attachment. It throws
* exception before the element is attached.
* @return {!./service/resources-impl.ResourcesDef}
* @return {!./service/resources-interface.ResourcesInterface}
* @final
* @package
*/
Expand All @@ -357,7 +357,7 @@ function createBaseCustomElementClass(win) {
this.resources_,
'no resources yet, since element is not attached'
);
return /** @typedef {!./service/resources-impl.ResourcesDef} */ this
return /** @typedef {!./service/resources-interface.ResourcesInterface} */ this
.resources_;
}

Expand Down
6 changes: 3 additions & 3 deletions src/friendly-iframe-embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ export class FriendlyIframeEmbed {
destroy() {
// TODO(lannka): should avoid this type casting by moving the `removeForChildWindow`
// logic here.
const resources = /** @type {!./service/resources-impl.Resources} */ (Services.resourcesForDoc(
const resources = /** @type {!./service/resources-impl.ResourcesImpl} */ (Services.resourcesForDoc(
this.iframe
));
resources.removeForChildWindow(this.win);
Expand Down Expand Up @@ -566,7 +566,7 @@ export class FriendlyIframeEmbed {
}

/**
* @return {!./service/resources-impl.ResourcesDef}
* @return {!./service/resources-interface.ResourcesInterface}
* @private
*/
getResources_() {
Expand Down Expand Up @@ -857,7 +857,7 @@ export class FriendlyIframeEmbed {
export function whenContentIniLoad(elementOrAmpDoc, hostWin, rect) {
// TODO(lannka): should avoid this type casting by moving the `getResourcesInRect`
// logic here.
const resources = /** @type {!./service/resources-impl.Resources} */ (Services.resourcesForDoc(
const resources = /** @type {!./service/resources-impl.ResourcesImpl} */ (Services.resourcesForDoc(
elementOrAmpDoc
));
return resources.getResourcesInRect(hostWin, rect).then(resources => {
Expand Down
6 changes: 3 additions & 3 deletions src/inabox/inabox-mutator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
import {Services} from '../services';

/**
* @implements {../service/resources-impl.MutatorsDef}
* @implements {../service/mutator-interface.MutatorInterface}
*/
export class InaboxMutator {
/**
* @param {!../service/ampdoc-impl.AmpDoc} ampdoc
* @param {!../service/resources-impl.ResourcesDef} resources
* @param {!../service/resources-interface.ResourcesInterface} resources
*/
constructor(ampdoc, resources) {
/** @const @private {!../service/resources-impl.ResourcesDef} */
/** @const @private {!../service/resources-interface.ResourcesInterface} */
this.resources_ = resources;

/** @private @const {!../service/vsync-impl.Vsync} */
Expand Down
2 changes: 1 addition & 1 deletion src/inabox/inabox-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const TAG = 'inabox-resources';
const FOUR_FRAME_DELAY = 70;

/**
* @implements {../service/resources-impl.ResourcesDef}
* @implements {../service/resources-interface.ResourcesInterface}
* @visibleForTesting
*/
export class InaboxResources {
Expand Down
119 changes: 119 additions & 0 deletions src/service/mutator-interface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/**
* Copyright 2019 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.
*/

/* eslint-disable no-unused-vars */
/**
* @interface
*/
export class MutatorInterface {
/**
* Requests the runtime to change the element's size. When the size is
* successfully updated then the opt_callback is called.
* @param {!Element} element
* @param {number|undefined} newHeight
* @param {number|undefined} newWidth
* @param {function()=} opt_callback A callback function.
* @param {!../layout-rect.LayoutMarginsChangeDef=} opt_newMargins
*/
changeSize(element, newHeight, newWidth, opt_callback, opt_newMargins) {}

/**
* Return a promise that requests the runtime to update the size of
* this element to the specified value.
* The runtime will schedule this request and attempt to process it
* as soon as possible. However, unlike in {@link changeSize}, the runtime
* may refuse to make a change in which case it will reject promise, call the
* `overflowCallback` method on the target resource with the height value.
* Overflow callback is expected to provide the reader with the user action
* to update the height manually.
* Note that the runtime does not call the `overflowCallback` method if the
* requested height is 0 or negative.
* If the height is successfully updated then the promise is resolved.
* @param {!Element} element
* @param {number|undefined} newHeight
* @param {number|undefined} newWidth
* @param {!../layout-rect.LayoutMarginsChangeDef=} opt_newMargins
* @return {!Promise}
* @param {?Event=} opt_event
*/
attemptChangeSize(element, newHeight, newWidth, opt_newMargins, opt_event) {}

/**
* Expands the element.
* @param {!Element} element
*/
expandElement(element) {}

/**
* Return a promise that requests runtime to collapse this element.
* The runtime will schedule this request and first attempt to resize
* the element to height and width 0. If success runtime will set element
* display to none, and notify element owner of this collapse.
* @param {!Element} element
* @return {!Promise}
*/
attemptCollapse(element) {}

/**
* Collapses the element: ensures that it's `display:none`, notifies its
* owner and updates the layout box.
* @param {!Element} element
*/
collapseElement(element) {}

/**
* Runs the specified measure, which is called in the "measure" vsync phase.
* This is simply a proxy to the privileged vsync service.
*
* @param {function()} measurer
* @return {!Promise}
*/
measureElement(measurer) {}

/**
* Runs the specified mutation on the element and ensures that remeasures and
* layouts performed for the affected elements.
*
* This method should be called whenever a significant mutations are done
* on the DOM that could affect layout of elements inside this subtree or
* its siblings. The top-most affected element should be specified as the
* first argument to this method and all the mutation work should be done
* in the mutator callback which is called in the "mutation" vsync phase.
*
* @param {!Element} element
* @param {function()} mutator
* @return {!Promise}
*/
mutateElement(element, mutator) {}

/**
* Runs the specified mutation on the element and ensures that remeasures and
* layouts performed for the affected elements.
*
* This method should be called whenever a significant mutations are done
* on the DOM that could affect layout of elements inside this subtree or
* its siblings. The top-most affected element should be specified as the
* first argument to this method and all the mutation work should be done
* in the mutator callback which is called in the "mutation" vsync phase.
*
* @param {!Element} element
* @param {?function()} measurer
* @param {function()} mutator
* @return {!Promise}
*/
measureMutateElement(element, measurer, mutator) {}
}
/* eslint-enable no-unused-vars */
Loading

0 comments on commit e0ed3d5

Please sign in to comment.