Repository navigation
Scroll API: getScrollInfo, all scrollIntoView forms, rect helper (Refs #54) - #83
DJAscendance wants to merge 4 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).
… (Refs #54) get_scroll_info() returns CM5's {left, top, height, width, clientHeight, clientWidth}; scroll_into_view_target takes null (cursor plus cursorScrollMargin), a line number, a position, a range, a coordinate box or a box range (scrollToCoordsRange); scroll_rect_into_view is the immediate, thresholded scrollIntoView(cm, rect) helper. Checked against a CM5 recording (cm5-scroll-api.json), including scrollTo and scrollIntoView inside one operation.
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.
MiniMax-M3.1-Flash QAReview findings1.
|
Refs #54
Ledger rows: 472 scrollTo, 473 getScrollInfo, 474 scrollIntoView (method), 659 scrollIntoView(cm, rect) helper. Also checked, but unchanged here: 657 maybeScrollWindow.
Base:
7d917785a1b65259b238f35a3fad98343d8a6d02(master, merged in); parent PR heada4a6293496d23fce990c73a899a0b823e574e6cbHead:
2919bd97af2043426f40b1d3558340e9bcf56959Integration: Stacked on #81 (
a4a6293); merge in order #81, #83, #86, #89, #90, #91, #92. Until the PR below it merges, this PR's diff against master includes that PR.This branch is independent of #81 (coordinate systems). Both edit the
pub use editor::{...}line in lib.rs, so whichever merges second has a one-line conflict to resolve.What this adds
Editor::get_scroll_info() -> ScrollInfo { left, top, height, width, client_height, client_width }.height/widthare the content size (max scroll + client size). The client sizes aredisplayHeightanddisplayWidth, gutters included.Editor::scroll_into_view_target(target, margin)covers everyrangeform ofcm.scrollIntoView:ScrollTarget::Cursor(null): the primary head, withcursorScrollMarginwhen the margin isNone.Line(n):Pos(n, 0).PosandRange(from, to).Coords(rect)andCoordsRange(a, b): local coordinates, through a newscroll_to_coords_range(scrollToCoordsRange).margin || 0:Noneand NaN become 0.Fromimpls exist fori64,PosandRect. The existingscroll_into_view(from, to, margin)stays.Editor::scroll_rect_into_view(rect)is the rect helperscrollIntoView(cm, rect). It runs calculateScrollPos and then the thresholdedupdateScrollTop/setScrollLeftat once, so changes under 2 px are dropped. It runs as an operation, so the rendered range follows.scrollTo: no code change. The recording confirms that it resolves a pending scrollToPos (a later scrollTo overrides it) and that null axes are left alone. The ledger note "does not resolve a pending scrollToPos" was stale.Upstream refs (pinned 4ca3d05)
src/edit/methods.js:364-390; src/display/scrolling.js:70-75 (rect helper), 82-114 (calculateScrollPos), 125-157 (scrollToCoords, scrollToRange, resolveScrollToPos, scrollToCoordsRange), 161-185 (updateScrollTop, setScrollLeft thresholds).
Tests and evidence
crates/cm-view/tests/scroll_api.rs, againsttests/data/cm5-scroll-api.json. That file was recorded by the neworacle/cm5-scroll-api.mjsfrom CM5 5.65.21 in headless Chromium.get_scroll_info_matches_cm5: 8 editors (long, scrolled, short, wide, at max, line numbers, wrapped).scroll_into_view_forms_match_cm5: 26 cases. They cover every form, margins, cursorScrollMargin, top/bottom snap, rects taller than the view, and scrollTo/scrollIntoView/setCursor sequences inside one operation.rect_helper_is_immediate_and_thresholded(unit test; no CM5 API exposes the helper).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.Known differences
widthandleftare compared within 1 px. The browser'sscrollWidthandscrollLeftare whole pixels, while the port's longest-line width is fractional. This is the right-edge precision gap already documented in scroll_clamp.rs.scrollCursorIntoViewveto is added in the events PR ([Parity][Core] Support string-named, custom and DOM-level events (signal/on/off/signalDOMEvent) #37).Coverage change
CI: pending (Actions cannot start: billing)