Skip to content

Commit

Permalink
Remove getPageLayoutBox API (#31754)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima Voytenko committed Dec 29, 2020
1 parent 46204c0 commit 3c710dd
Show file tree
Hide file tree
Showing 11 changed files with 0 additions and 111 deletions.
8 changes: 0 additions & 8 deletions build-system/tasks/presubmit-checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1199,14 +1199,6 @@ const forbiddenTermsSrcInclusive = {
'extensions/amp-fx-flying-carpet/0.1/amp-fx-flying-carpet.js',
],
},
'\\.getPageLayoutBox': {
message: measurementApiDeprecated,
allowlist: [
'src/base-element.js',
'src/custom-element.js',
'src/service/resource.js',
],
},
'\\.getIntersectionElementLayoutBox': {
message: measurementApiDeprecated,
allowlist: [
Expand Down
3 changes: 0 additions & 3 deletions extensions/amp-a4a/0.1/test/test-amp-a4a.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,6 @@ describe('amp-a4a', () => {
element.getLayoutBox = () => {
return opt_rect || layoutRectLtwh(0, 0, 200, 50);
};
element.getPageLayoutBox = () => {
return element.getLayoutBox.apply(element, arguments);
};
element.getIntersectionChangeEntry = () => {
return null;
};
Expand Down
6 changes: 0 additions & 6 deletions extensions/amp-a4a/0.1/test/test-name-frame-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ describes.realWin('NameFrameRenderer', realWinConfig, (env) => {
containerElement = env.win.document.createElement('div');
containerElement.setAttribute('height', 50);
containerElement.setAttribute('width', 320);
containerElement.getPageLayoutBox = () => ({
left: 0,
top: 0,
width: 0,
height: 0,
});
containerElement.getIntersectionChangeEntry = () => ({});
env.win.document.body.appendChild(containerElement);

Expand Down
6 changes: 0 additions & 6 deletions extensions/amp-a4a/0.1/test/test-template-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ describes.realWin('TemplateRenderer', realWinConfig, (env) => {
whenSignal: () => Promise.resolve(),
});
containerElement.renderStarted = () => {};
containerElement.getPageLayoutBox = () => ({
left: 0,
top: 0,
width: 0,
height: 0,
});
containerElement.getLayoutBox = () => ({
left: 0,
top: 0,
Expand Down
6 changes: 0 additions & 6 deletions extensions/amp-ad-custom/0.1/test/test-amp-ad-custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ describes.realWin('TemplateRenderer', realWinConfig, (env) => {
whenSignal: () => Promise.resolve(),
});
containerElement.renderStarted = () => {};
containerElement.getPageLayoutBox = () => ({
left: 0,
top: 0,
width: 0,
height: 0,
});
containerElement.getLayoutBox = () => ({
left: 0,
top: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,6 @@ describes.realWin(
});

it('should get current geometry when safeframe fills amp-ad', () => {
env.sandbox
./*OK*/ stub(safeframeHost.baseInstance_, 'getPageLayoutBox')
.returns({
top: 0,
left: 0,
right: 300,
bottom: 250,
});
const safeframeMock = createElementWithAttributes(doc, 'iframe', {
'class': 'safeframe',
});
Expand Down Expand Up @@ -392,14 +384,6 @@ describes.realWin(
});

it('should get geometry when safeframe does not fill amp-ad', () => {
env.sandbox
./*OK*/ stub(safeframeHost.baseInstance_, 'getPageLayoutBox')
.returns({
top: 0,
left: 0,
right: 50,
bottom: 50,
});
// In this case, the safeframe is smaller than its containing
// amp-ad element.
const safeframeMock = createElementWithAttributes(doc, 'iframe', {
Expand Down Expand Up @@ -444,14 +428,6 @@ describes.realWin(

it('should handle cancellation', () => {
expectAsyncConsoleError(/cancellation/i, 1);
env.sandbox
./*OK*/ stub(safeframeHost.baseInstance_, 'getPageLayoutBox')
.returns({
top: 0,
left: 0,
right: 50,
bottom: 50,
});
// In this case, the safeframe is smaller than its containing
// amp-ad element.
const safeframeMock = createElementWithAttributes(doc, 'iframe', {
Expand Down Expand Up @@ -481,14 +457,6 @@ describes.realWin(
});

it('should get geometry when scrolled', () => {
env.sandbox
./*OK*/ stub(safeframeHost.baseInstance_, 'getPageLayoutBox')
.returns({
top: 0,
left: 0,
right: 50,
bottom: 50,
});
// In this case, the safeframe is smaller than its containing
// amp-ad element.
const safeframeMock = createElementWithAttributes(doc, 'iframe', {
Expand Down Expand Up @@ -589,14 +557,6 @@ describes.realWin(

describe('formatGeom', () => {
it('should build proper geometry update', () => {
env.sandbox
./*OK*/ stub(safeframeHost.baseInstance_, 'getPageLayoutBox')
.returns({
top: 200,
left: 100,
right: 400,
bottom: 800,
});
const iframeBox = {
top: 300,
left: 200,
Expand Down
9 changes: 0 additions & 9 deletions src/base-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,6 @@ export class BaseElement {
return this.element.getLayoutBox();
}

/**
* Returns a previously measured layout box relative to the page. The
* fixed-position elements are relative to the top of the document.
* @return {!./layout-rect.LayoutRectDef}
*/
getPageLayoutBox() {
return this.element.getPageLayoutBox();
}

/**
* DO NOT CALL. Retained for backward compat during rollout.
* @public
Expand Down
10 changes: 0 additions & 10 deletions src/custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -1021,16 +1021,6 @@ function createBaseCustomElementClass(win) {
return this.getResource_().getLayoutBox();
}

/**
* Returns a previously measured layout box relative to the page. The
* fixed-position elements are relative to the top of the document.
* @return {!./layout-rect.LayoutRectDef}
* @final
*/
getPageLayoutBox() {
return this.getResource_().getPageLayoutBox();
}

/**
* @return {?Element}
* @final
Expand Down
9 changes: 0 additions & 9 deletions src/service/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,15 +674,6 @@ export class Resource {
);
}

/**
* Returns a previously measured layout box relative to the page. The
* fixed-position elements are relative to the top of the document.
* @return {!../layout-rect.LayoutRectDef}
*/
getPageLayoutBox() {
return this.layoutBox_;
}

/**
* Returns the first measured layout box.
* @return {!../layout-rect.LayoutRectDef}
Expand Down
6 changes: 0 additions & 6 deletions test/unit/test-base-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,9 @@ describes.realWin('BaseElement', {amp: true}, (env) => {
.withArgs(customElement)
.returns(resource);
const layoutBox = layoutRectLtwh(0, 50, 100, 200);
const pageLayoutBox = layoutRectLtwh(0, 0, 100, 200);
env.sandbox.stub(resource, 'getLayoutBox').callsFake(() => layoutBox);
env.sandbox
.stub(resource, 'getPageLayoutBox')
.callsFake(() => pageLayoutBox);
expect(element.getLayoutBox()).to.eql(layoutBox);
expect(customElement.getLayoutBox()).to.eql(layoutBox);
expect(element.getPageLayoutBox()).to.eql(pageLayoutBox);
expect(customElement.getPageLayoutBox()).to.eql(pageLayoutBox);
});

it('should return true for inabox experiment renderOutsideViewport', () => {
Expand Down
8 changes: 0 additions & 8 deletions test/unit/test-resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@ describes.realWin('Resource', {amp: true}, (env) => {
resource.measure();
}).to.not.throw();
expect(resource.getLayoutBox()).to.eql(layoutRectLtwh(0, 100, 300, 100));
// pageLayoutBox == layoutBox
expect(resource.getPageLayoutBox()).to.eql(
layoutRectLtwh(0, 100, 300, 100)
);
});

it('should allow measure even when not built', () => {
Expand Down Expand Up @@ -431,9 +427,7 @@ describes.realWin('Resource', {amp: true}, (env) => {
});
resource.measure();
expect(resource.isFixed()).to.be.true;
// layoutBox != pageLayoutBox
expect(resource.getLayoutBox()).to.eql(layoutRectLtwh(0, 11, 10, 10));
expect(resource.getPageLayoutBox()).to.eql(layoutRectLtwh(0, 0, 10, 10));
});

it('should calculate fixed for fixed-style parent', () => {
Expand All @@ -460,9 +454,7 @@ describes.realWin('Resource', {amp: true}, (env) => {
});
resource.measure();
expect(resource.isFixed()).to.be.true;
// layoutBox != pageLayoutBox
expect(resource.getLayoutBox()).to.eql(layoutRectLtwh(0, 11, 10, 10));
expect(resource.getPageLayoutBox()).to.eql(layoutRectLtwh(0, 0, 10, 10));
});

describe('ensureMeasured', () => {
Expand Down

0 comments on commit 3c710dd

Please sign in to comment.