Skip to content

Commit 2109072

Browse files
author
wangnaihe
committed
feat: W3C DOM/CSS API大规模补齐 — 6阶段实施完成
Phase 1 — DOM Core补全: - replaceChild, cloneNode(deep), DocumentFragment, Comment节点类型 - nextSibling/previousSibling/firstChild/lastChild访问器 - getElementsByTagName/ClassName, dataset, inner_text, outer_html - Runtime DOM桥接同步暴露所有新API Phase 2 — 事件系统重写: - 40+ EventType变体(pointer/touch/composition/custom等) - MouseEventData/KeyboardEventData/PointerEventData/WheelEventData子类型 - W3C三阶段事件传播: Capturing → AtTarget → Bubbling - 监听器options(capture/once/passive), 单监听器按ID移除 - stopImmediatePropagation, CustomEvent Phase 3 — CSS引擎增强: - StyleDecl扩展30+新属性(cursor/visibility/pointer-events/outline/flex-basis等) - CSS简写解析: flex/outline/border完整简写 - CSSStyleDeclaration补齐: text-*/font-*/align-*/outline-*等 - Style struct新增: cursor/visibility/pointer_events/user_select/outline/flex_basis/order/align_self/align_content - var(--name, fallback)解析与继承链消费 - @Keyframes解析(百分比停靠点/from/to) - @media解析(规则内容展开而非跳过) - @font-face解析(font-family/src/weight/style) Phase 4 — Canvas 2D完善: - 路径: quadraticCurveTo/bezierCurveTo/ellipse/rect/clip - 图像: drawImage/putImageData - 线型: setLineCap/setLineJoin/setMiterLimit/setLineDash - 变换: setTransform/resetTransform - TextMetrics扩展: boundingBox ascent/descent Phase 5 — Selection API: - Range: collapse/selectNode/selectNodeContents/cloneRange/setStartBefore等 - Selection: removeRange/containsNode/selectionType Phase 6 — Observer + Window API: - ResizeObserver/MutationObserver/IntersectionObserver - Window.matchMedia(min-width/max-width/prefers-color-scheme) Made-with: Cursor
1 parent 08ad98b commit 2109072

17 files changed

Lines changed: 1957 additions & 74 deletions

File tree

ROADMAP.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,54 @@
138138
- [x] Adaptive Layout: responsive dashboard that works on any screen size
139139

140140
## Phase 2.75 — VS Code Compatibility (see docs/vscode-compat.md)
141-
- [ ] Canvas 2D API (CanvasRenderingContext2D) (#32)
142-
- [ ] Selection API (window.getSelection, Range) (#37)
141+
142+
### DOM Core ✅
143+
- [x] replaceChild, cloneNode(deep), DocumentFragment, Comment node types
144+
- [x] nextSibling/previousSibling/firstChild/lastChild accessors on Element
145+
- [x] is_connected, node_type, node_name, child_element_count
146+
- [x] getElementsByTagName, getElementsByClassName
147+
- [x] dataset (DOMStringMap), inner_text, outer_html (read-only)
148+
- [x] Runtime DOM bridge: all new APIs exposed via w3cos_runtime::dom
149+
150+
### DOM Events ✅
151+
- [x] Full event sub-types: MouseEventData, KeyboardEventData, PointerEventData, WheelEventData
152+
- [x] 40+ EventType variants (pointer, touch, composition, custom, etc.)
153+
- [x] Event phases: Capturing → AtTarget → Bubbling (W3C 3-phase propagation)
154+
- [x] Listener options: capture, once, passive
155+
- [x] Single listener removal by ID
156+
- [x] stop_immediate_propagation support
157+
- [x] CustomEvent with detail
158+
159+
### CSS Engine ✅
160+
- [x] 30+ new CSS properties in StyleDecl/apply_css_property (cursor, visibility, pointer-events, user-select, outline-*, text-*, flex-basis, order, align-self, align-content, etc.)
161+
- [x] CSS shorthand parsing: flex, outline, border, margin/padding multi-value
162+
- [x] CSSStyleDeclaration: text-align, white-space, line-height, letter-spacing, text-decoration, text-overflow, font-family/style, word-break, cursor, visibility, pointer-events, user-select, outline-*, align-self/content
163+
- [x] Style struct: cursor, visibility, pointer_events, user_select, outline, flex_basis, order, align_self, align_content
164+
- [x] CSS Custom Properties: var(--name, fallback) resolution with inheritance
165+
- [x] @keyframes parsing: keyframe stops with percentage/from/to
166+
- [x] @media parsing: rules inside @media blocks now parsed (not skipped)
167+
- [x] @font-face parsing: font-family, src, weight, style extraction
143168
- [x] CSS pseudo-class selectors (:hover, :focus, :active, :first-child, :last-child, :nth-child, :only-child, :empty, :not(), :disabled, :enabled, :checked)
144169
- [x] CSS attribute selectors ([attr], [attr=value], [attr^=value], [attr$=value], [attr*=value], [attr~=value], [attr|=value])
170+
171+
### Canvas 2D ✅
172+
- [x] Path: quadraticCurveTo, bezierCurveTo, ellipse, rect, clip
173+
- [x] Image: drawImage, putImageData
174+
- [x] Line styles: setLineCap, setLineJoin, setMiterLimit, setLineDash/getLineDash
175+
- [x] Transform: setTransform, resetTransform
176+
- [x] TextMetrics: width + boundingBox ascent/descent
177+
178+
### Selection API ✅
179+
- [x] Range: collapse, selectNode, selectNodeContents, cloneRange, setStartBefore/After, setEndBefore/After
180+
- [x] Selection: removeRange, containsNode, selectionType
181+
182+
### Observer APIs ✅
183+
- [x] ResizeObserver (observe/unobserve/disconnect/checkForChanges)
184+
- [x] MutationObserver (MutationType/MutationRecord)
185+
- [x] IntersectionObserver (observe/unobserve/disconnect/checkForIntersections)
186+
- [x] Window.matchMedia (min-width, max-width, prefers-color-scheme)
187+
188+
### Remaining
145189
- [ ] Web Workers
146190
- [ ] WebSocket API
147191
- [x] localStorage (Web Storage API with JSON file persistence)

0 commit comments

Comments
 (0)