mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
fix(vom): canvas recognition
This commit is contained in:
@@ -10,7 +10,6 @@ import type {
|
||||
VomResult,
|
||||
VomScene,
|
||||
VomVisualSurface,
|
||||
VomVisualSurfaceSummary,
|
||||
} from "./types";
|
||||
|
||||
const SKIP_ROLES = new Set(["generic", "none", "presentation", "inlinetextbox"]);
|
||||
@@ -796,7 +795,6 @@ interface RenderState {
|
||||
surfaceMap: Map<number, CondSurface>;
|
||||
scopeMap: Map<number, ActiveScopeBlock>;
|
||||
visualSurfaces: Map<number | null, VomVisualSurface[]>;
|
||||
visualSurfaceSummaries: Map<number | null, VomVisualSurfaceSummary[]>;
|
||||
}
|
||||
|
||||
function groupedByParent<T extends { parentId: number | null }>(
|
||||
@@ -842,23 +840,6 @@ function emitVisualEntries(parentId: number | null, depth: number, state: Render
|
||||
});
|
||||
state.nextRef += 1;
|
||||
}
|
||||
|
||||
for (const summary of state.visualSurfaceSummaries.get(parentId) ?? []) {
|
||||
if (depth > state.maxDepth) {
|
||||
state.truncated = true;
|
||||
continue;
|
||||
}
|
||||
const noun = summary.count === 1 ? "surface is" : "surfaces are";
|
||||
const line = `${" ".repeat(depth)}[${summary.count} additional visual ${noun} not represented]`;
|
||||
const nextTokens = state.tokens + estimateTokens(line);
|
||||
if (nextTokens > state.maxTokens) {
|
||||
state.truncated = true;
|
||||
state.stopped = true;
|
||||
return;
|
||||
}
|
||||
state.lines.push(line);
|
||||
state.tokens = nextTokens;
|
||||
}
|
||||
}
|
||||
|
||||
function emitActiveScopeBlock(scope: ActiveScopeBlock, depth: number, state: RenderState): void {
|
||||
@@ -965,7 +946,6 @@ function renderNodes(
|
||||
surfaces: CondSurface[] = [],
|
||||
activeScopeBlocks: ActiveScopeBlock[] = [],
|
||||
visualSurfaces: VomVisualSurface[] = [],
|
||||
visualSurfaceSummaries: VomVisualSurfaceSummary[] = [],
|
||||
): RenderState {
|
||||
const children = buildChildren(nodes);
|
||||
const state: RenderState = {
|
||||
@@ -986,7 +966,6 @@ function renderNodes(
|
||||
surfaceMap: new Map(surfaces.map((surface) => [surface.triggerId, surface])),
|
||||
scopeMap: new Map(activeScopeBlocks.map((scope) => [scope.triggerId, scope])),
|
||||
visualSurfaces: groupedByParent(visualSurfaces),
|
||||
visualSurfaceSummaries: groupedByParent(visualSurfaceSummaries),
|
||||
};
|
||||
|
||||
renderTree(children, state);
|
||||
@@ -1207,7 +1186,6 @@ function renderDoubleLayer(scene: VomScene, layer: BlockingLayer, options: VomOp
|
||||
scene.surfaces,
|
||||
scene.activeScopeBlocks,
|
||||
scene.visualSurfaces?.filter((surface) => visibleSurface(surface.parentId)),
|
||||
scene.visualSurfaceSummaries?.filter((summary) => visibleSurface(summary.parentId)),
|
||||
);
|
||||
state.lines.push(renderPageOcclusionLine(hiddenCount));
|
||||
|
||||
@@ -1237,7 +1215,6 @@ export function renderVom(scene: VomScene, options: VomOptions = {}): VomResult
|
||||
scene.surfaces,
|
||||
scene.activeScopeBlocks,
|
||||
scene.visualSurfaces,
|
||||
scene.visualSurfaceSummaries,
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user