General.Web/wwwroot/lib/codemirror-5.31.0/src/display/update_display.js

(开头部分) 9KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

import { sawCollapsedSpans } from "../line/saw_special_spans"
import { heightAtLine, visualLineEndNo, visualLineNo } from "../line/spans"
import { getLine, lineNumberFor } from "../line/utils_line"
import { displayHeight, displayWidth, getDimensions, paddingVert, scrollGap } from "../measurement/position_measurement"
import { mac, webkit } from "../util/browser"
import { activeElt, removeChildren, contains } from "../util/dom"
import { hasHandler, signal } from "../util/event"
import { indexOf } from "../util/misc"

import { buildLineElement, updateLineForChanges } from "./update_line"
import { startWorker } from "./highlight_worker"
import { maybeUpdateLineNumberWidth } from "./line_numbers"
import { measureForScrollbars, updateScrollbars } from "./scrollbars"
import { updateSelection } from "./selection"
import { updateHeightsInViewport, visibleLines } from "./update_lines"
import { adjustView, countDirtyView, resetView } from "./view_tracking"

// DISPLAY DRAWING

export class DisplayUpdate {
  constructor(cm, viewport, force) {
    let display = cm.display

    this.viewport = viewport
    // Store some values that we'll need later (but don't want to force a relayout for)
    this.visible = visibleLines(display, cm.doc, viewport)
    this.editorIsHidden = !display.wrapper.offsetWidth
    this.wrapperHeight = display.wrapper.clientHeight
    this.wrapperWidth = display.wrapper.clientWidth
    this.oldDisplayWidth = displayWidth(cm)
    this.force = force
    this.dims = getDimensions(cm)
    this.events = []
  }

  signal(emitter, type) {
    if (hasHandler(emitter, type))
      this.events.push(arguments)
  }
  finish() {
    for (let i = 0; i < this.events.length; i++)
      signal.apply(null, this.events[i])
  }
}

export function maybeClipScrollbars(cm) {
  let display = cm.display
  if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
    display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth
    display.heightForcer.style.height = scrollGap(cm) + "px"
    display.sizer.style.marginBottom = -display.nativeBarWidth + "px"
    display.sizer.style.borderRightWidth = scrollGap(cm) + "px"
    display.scrollbarsClipped = true
  }
}

function selectionSnapshot(cm) {
  if (cm.hasFocus()) return null
  let active = activeElt()
  if (!active || !contains(cm.display.lineDiv, active)) return null
后面还有 200 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。