DOM
本页面介绍 Lynx DevTool 支持的 DOM CDP domain。
实验性参考
此生成的参考文档仍在完善中。
- CDP events 尚未包含。
- 部分 Lynx 扩展已列出,但尚未提供详细文档。
- 方法说明尚未根据实现自动校验,可能不完整或不准确。
在依赖本参考前,请根据实现及所链接的 upstream CDP reference 验证实际行为。
概览
- 作用域:
instance - CDP domain:DOM
标准方法
- DOM.copyTo
- DOM.describeNode
- DOM.disable
- DOM.discardSearchResults
- DOM.enable
- DOM.focus
- DOM.getAttributes
- DOM.getBoxModel
- DOM.getDocument
- DOM.getNodeForLocation
- DOM.getOuterHTML
- DOM.getSearchResults
- DOM.markUndoableState
- DOM.moveTo
- DOM.performSearch
- DOM.pushNodesByBackendIdsToFrontend
- DOM.querySelector
- DOM.querySelectorAll
- DOM.removeNode
- DOM.requestChildNodes
- DOM.scrollIntoViewIfNeeded
- DOM.setAttributesAsText
- DOM.setInspectedNode
- DOM.setOuterHTML
Lynx 扩展
DOM.disableDomTree
Disables Lynx DOM tree capture and reloads the current page.
- Origin:
lynx-extension - Source:
devtool/lynx_devtool/agent/domain_agent/inspector_dom_agent_ng.cc
参数
返回字段
无返回字段。
备注
- Dispatches through LynxDevToolMediator to InspectorTasmExecutor on the TASM thread.
- Sets the local Lynx environment flag kLynxEnableDomTree to false.
- Calls Page.reload with params.ignoreCache. Missing params or a missing ignoreCache field are treated as false.
- Returns an empty result object after scheduling the reload.
- If the mediator has no TASM task runner, the current handler does not send an explicit CDP response.
示例
Disable DOM tree capture and reload
Request:
Response:
DOM.enableDomTree
Enables Lynx DOM tree capture and reloads the current page.
- Origin:
lynx-extension - Source:
devtool/lynx_devtool/agent/domain_agent/inspector_dom_agent_ng.cc
参数
返回字段
无返回字段。
备注
- Dispatches through LynxDevToolMediator to InspectorTasmExecutor on the TASM thread.
- Sets the local Lynx environment flag kLynxEnableDomTree to true.
- Calls Page.reload with params.ignoreCache. Missing params or a missing ignoreCache field are treated as false.
- Returns an empty result object after scheduling the reload.
- If the mediator has no TASM task runner, the current handler does not send an explicit CDP response.
示例
Enable DOM tree capture and reload
Request:
Response:
DOM.getDocumentWithBoxModel
Returns the Lynx DOM tree with per-node box model data when it can be computed.
- Origin:
lynx-extension - Source:
devtool/lynx_devtool/agent/domain_agent/inspector_dom_agent_ng.cc
参数
无参数。
返回字段
备注
- Dispatches through LynxDevToolMediator to InspectorTasmExecutor on the TASM thread, then asks the platform for native box models before sending the response.
- The returned tree is built from the current element root and uses the same node fields as the standard DOM tree, with Lynx's box_model field added to each serializable node.
- Coordinates are adjusted relative to the root box model in LynxView screenshot mode and converted by LayoutsUnitPerPx.
- If the serialized root exceeds the native DOM compression threshold and compression succeeds, result.compress is true and result.root is a compressed base64 string.
- If a node cannot produce a valid box model, that node's box_model field is null.
- The native implementation does not read request params.
- If the mediator has no TASM task runner or the element root is unavailable, the current handler does not send an explicit CDP response.
示例
Read the DOM tree with box models
Request:
Response:
DOM.getOriginalNodeIndex
Returns the Lynx source node index associated with a DevTool node id.
- Origin:
lynx-extension - Source:
devtool/lynx_devtool/agent/domain_agent/inspector_dom_agent_ng.cc
参数
返回字段
备注
- Dispatches through LynxDevToolMediator to InspectorTasmExecutor on the TASM thread.
- The handler resolves params.nodeId with the current inspector element map and returns Element::NodeIndex().
- The response result is an empty object when no element is found for params.nodeId.
- If the mediator has no TASM task runner, the current handler does not send an explicit CDP response.
示例
Resolve a DevTool node to its Lynx source index
Request:
Response:
DOM.innerText
Returns raw text child values for a Lynx text node.
- Origin:
lynx-extension - Source:
devtool/lynx_devtool/agent/domain_agent/inspector_dom_agent_ng.cc
参数
返回字段
备注
- Dispatches through LynxDevToolMediator to InspectorTasmExecutor on the TASM thread.
- The handler only scans attached elements whose localName is text.
- For matching text elements, the handler walks direct raw-text children and reads their text attributes.
- The method does not concatenate text; callers receive one rawTextValues item per raw-text child that contributes text.
- If the mediator has no TASM task runner, the current handler does not send an explicit CDP response.
示例
Read raw text children
Request:
Response: