Skip to content

Commit c0f6211

Browse files
lillesDevtools-frontend LUCI CQ
authored andcommitted
Pass to queriesAnchored to getContainerForNode
getContainerForNode needs to know whether the @container selector queries anchored() in order to select correct container candidate. Bug: 417621241 Change-Id: I8eae0d4aac1eca513a3efcd10e3c390b1dc202dd Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6801802 Reviewed-by: Alex Rudenko <[email protected]> Commit-Queue: Rune Lillesveen <[email protected]> Reviewed-by: Wolfgang Beyer <[email protected]>
1 parent 86198e0 commit c0f6211

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

front_end/core/sdk/CSSContainerQuery.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import type * as Protocol from '../../generated/protocol.js';
6+
import {createTarget} from '../../testing/EnvironmentHelpers.js';
7+
import {describeWithMockConnection} from '../../testing/MockConnection.js';
8+
59
import * as SDK from './sdk.js';
610

711
const {getPhysicalAxisFromQueryAxis, getQueryAxisFromContainerType, PhysicalAxis, QueryAxis} = SDK.CSSContainerQuery;
@@ -49,4 +53,15 @@ describe('CSSContainerQuery', () => {
4953
assert.strictEqual(getPhysicalAxisFromQueryAxis(QueryAxis.BOTH, 'vertical-rl'), PhysicalAxis.BOTH);
5054
});
5155
});
56+
57+
describeWithMockConnection('Construction from protocol payload', () => {
58+
it('anchored()', () => {
59+
const target = createTarget();
60+
const cssModel = new SDK.CSSModel.CSSModel(target);
61+
const query = new SDK.CSSContainerQuery.CSSContainerQuery(
62+
cssModel, {queriesAnchored: true} as Protocol.CSS.CSSContainerQuery);
63+
assert.isTrue(query.queriesAnchored);
64+
assert.isUndefined(query.queriesScrollState);
65+
});
66+
});
5267
});

front_end/core/sdk/CSSContainerQuery.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export class CSSContainerQuery extends CSSQuery {
1414
physicalAxes?: Protocol.DOM.PhysicalAxes;
1515
logicalAxes?: Protocol.DOM.LogicalAxes;
1616
queriesScrollState?: boolean;
17+
queriesAnchored?: boolean;
1718

1819
static parseContainerQueriesPayload(cssModel: CSSModel, payload: Protocol.CSS.CSSContainerQuery[]):
1920
CSSContainerQuery[] {
@@ -33,6 +34,7 @@ export class CSSContainerQuery extends CSSQuery {
3334
this.physicalAxes = payload.physicalAxes;
3435
this.logicalAxes = payload.logicalAxes;
3536
this.queriesScrollState = payload.queriesScrollState;
37+
this.queriesAnchored = payload.queriesAnchored;
3638
}
3739

3840
active(): boolean {
@@ -41,7 +43,7 @@ export class CSSContainerQuery extends CSSQuery {
4143

4244
async getContainerForNode(nodeId: Protocol.DOM.NodeId): Promise<CSSContainerQueryContainer|undefined> {
4345
const containerNode = await this.cssModel.domModel().getContainerForNode(
44-
nodeId, this.name, this.physicalAxes, this.logicalAxes, this.queriesScrollState);
46+
nodeId, this.name, this.physicalAxes, this.logicalAxes, this.queriesScrollState, this.queriesAnchored);
4547
if (!containerNode) {
4648
return;
4749
}

front_end/core/sdk/DOMModel.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,9 +1623,10 @@ export class DOMModel extends SDKModel<EventTypes> {
16231623

16241624
async getContainerForNode(
16251625
nodeId: Protocol.DOM.NodeId, containerName?: string, physicalAxes?: Protocol.DOM.PhysicalAxes,
1626-
logicalAxes?: Protocol.DOM.LogicalAxes, queriesScrollState?: boolean): Promise<DOMNode|null> {
1626+
logicalAxes?: Protocol.DOM.LogicalAxes, queriesScrollState?: boolean,
1627+
queriesAnchored?: boolean): Promise<DOMNode|null> {
16271628
const {nodeId: containerNodeId} = await this.agent.invoke_getContainerForNode(
1628-
{nodeId, containerName, physicalAxes, logicalAxes, queriesScrollState});
1629+
{nodeId, containerName, physicalAxes, logicalAxes, queriesScrollState, queriesAnchored});
16291630
if (!containerNodeId) {
16301631
return null;
16311632
}

0 commit comments

Comments
 (0)