Repository navigation
Coordinate systems: page/window modes and CM5 method forms (Refs #53) - #81
DJAscendance wants to merge 2 commits into
Conversation
) cursorCoords/charCoords/coordsChar/lineAtHeight/heightAtLine method forms (cursor_coords_in, char_coords_in, coords_char_in, line_at_height_in, height_at_line_in) with page and window modes over a host-supplied window origin and page scroll, start=null/true/false, clipPos, LineHandle arguments, includeWidgets (no widgets yet) and the end-of-document adjustment; intoCoordSystem/fromCoordSystem ported with CM5's div (viewOffset) semantics. The port's internal document-y frame is now CoordSys::Doc. Checked against a CM5 recording (cm5-coord-systems.json).
MiniMax-M3.1-Flash QAFindingsP1 —
|
into_coord_system honors include_widgets as CM5 does: without it the box moves below the widgets above the line (widgetTopHeight), before the "line" early return; master's into_coords path is the include_widgets = false case. Exports keep both sides' items. New test into_coord_system_include_widgets.
…wing Keep both sides' options and listeners. cursor_rects uses CoordSys::Doc, the internal document frame after #81 (CM5's "div" plus viewOffset).
Refs #53
Ledger rows: 452 cursorCoords, 453 charCoords, 454 coordsChar, 455 lineAtHeight, 456 heightAtLine, 737 intoCoordSystem, 738 fromCoordSystem.
Base:
7d917785a1b65259b238f35a3fad98343d8a6d02(master, merged in)Head:
a4a6293496d23fce990c73a899a0b823e574e6cbIntegration: Bottom of the stack #81, #83, #86, #89, #90, #91, #92; merge in that order. Until the PR below it merges, this PR's diff against master includes that PR.
What this adds
CoordSys::PageandCoordSys::Window. The native "window" is the host's drawing surface.Display::window_originis where the editor's top-left corner sits in it (wrapper.getBoundingClientRect()), andDisplay::page_scrollis the page scroll (pageXOffset/pageYOffset). Both are supplied by the host and default to (0, 0). The text area (lineSpace) box is computed from them plusgutter_width, the scroll offsets,paddingTopandviewOffset. This is documented onCoordSysand in the README.CoordSys::Divnow has CM5's meaning: relative tolineSpace, i.e. document y minusviewOffset(Editor::view_offset()). The port's internal document-y frame (CM5 div with viewOffset 0), which the renderer,moveV/findPosVand goLineUp/Down use, is renamed toCoordSys::Doc. Behavior is unchanged at those call sites (render.rs, commands.rs, movement.rs, cm-web frame.rs, and the visual/browser_host tests).into_coord_system(line, rect, sys, include_widgets)andfrom_coord_system(left, top, sys), ported from position_measurement.js. As in CM5, "line" goes through the window path in fromCoordSystem.Nonemeaning CM5's default "page":cursor_coords_in(start, mode).startis aCoordsStart:Head,From,To(null/true/false), or a clippedPos.char_coords_in(pos, mode), with clipPos.coords_char_in(left, top, mode).line_at_height_in(h, mode). As CM5 does (and as recorded), a height above the document givesfirst, and a height past the end givesfirst + size.height_at_line_in(LineArg, mode, include_widgets). Takes a number or aLineHandle. Clamps to the document, and a line past the last gives the bottom of the document.include_widgetsis accepted and documented, but line widgets are not ported.Upstream refs (pinned 4ca3d05)
src/edit/methods.js:184-216; src/measurement/position_measurement.js:285-345; src/line/utils_line.js:61; src/display/update_display.js:128-130.
Tests and evidence
crates/cm-view/tests/coord_systems.rs::coord_systems_match_cm5: 1,040 exact comparisons againsttests/data/cm5-coord-systems.json. That file was recorded by the neworacle/cm5-coord-systems.mjsfrom CM5 5.65.21 in headless Chromium. It covers 4 editors (scrolled with viewOffset 2584, at top, line numbers, firstLineNumber 5), with the editor offset in the page and the page scrolled, every mode, and all argument forms.coord_system_round_trip_and_deleted_handle.0b167ad, which contains this PR and every PR below it):cargo test --workspace --no-fail-fastgave 834 passed, 0 failed, 0 ignored. The same underxvfb-run -a: 834 passed, 0 failed.tools/web-test.sh: all 5 browser profiles passed 63/63.tools/web-test.sh(cm-web was touched by the rename): chromium, firefox, webkit, chromium-mobile and webkit-mobile all PASS 63/63.Known differences
heightAtLine(visualLine)and the collapsed-span loop of coordsChar are not modeled (collapsed ranges are a layout-wide gap).window_origin/page_scrollyet.maybeUpdateLineNumberWidthadds+ 1tolineNumInnerWidth(line_numbers.js:40). The test takes CM5's gutter width so that only the coordinate code is compared. The gutter fix belongs to the gutter work.Coverage change
into_coord_systemhonorsinclude_widgets. Without it, the box moves below the widgets above the line (widgetTopHeight), as master'sinto_coordsdoes; see the new testinto_coord_system_include_widgets.CI: pending (Actions cannot start: billing)