/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Maximum size, in pixel, for the horizontal ruler and vertical ruler // used by RulersHighlighter const RULERS_MAX_X_AXIS = 10000; const RULERS_MAX_Y_AXIS = 15000; // Number of steps after we add a graduation, marker and text in // RulersHighliter; currently the unit is in pixel. const RULERS_GRADUATION_STEP = 5; const RULERS_MARKER_STEP = 50; const RULERS_TEXT_STEP = 100;
/** * The RulersHighlighter is a class that displays both horizontal and * vertical rules on the page, along the top and left edges, with pixel * graduations, useful for users to quickly check distances
*/ class RulersHighlighter {
constructor(highlighterEnv) { this.env = highlighterEnv; this.markup = new CanvasFrameAnonymousContentHelper(
highlighterEnv, this._buildMarkup.bind(this)
); this.isReady = this.markup.initialize();
handleEvent(event) { switch (event.type) { case"scroll": this._onScroll(event); break; case"pagehide": // If a page hide event is triggered for current window's highlighter, hide the // highlighter. if (event.target.defaultView === this.env.window) { this.destroy();
} break;
}
}
// Because `devicePixelRatio` is affected by zoom (see bug 809788), // in order to get the "real" device pixel ratio, we need divide by `zoom` const pixelRatio = devicePixelRatio / this._zoom;
// The "real" device pixel ratio is used to calculate the max stroke // width we can actually assign: on retina, for instance, it would be 0.5, // where on non high dpi monitor would be 1. const minWidth = 1 / pixelRatio; const strokeWidth = Math.min(minWidth, minWidth / this._zoom);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.