/* 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/. */
/** * The PausedDebuggerOverlay is a class that displays a semi-transparent mask on top of * the whole page and a toolbar at the top of the page. * This is used to signal to users that script execution is current paused. * The toolbar is used to display the reason for the pause in script execution as well as * buttons to resume or step through the program.
*/ class PausedDebuggerOverlay {
constructor(highlighterEnv, options = {}) { this.env = highlighterEnv; this.resume = options.resume; this.stepOver = options.stepOver;
onMouseMove(target) { // Not an element we care about if (!target || !target.id) { return;
}
// If the user didn't change targets, do nothing if (this.lastTarget && this.lastTarget.id === target.id) { return;
}
if (
target.id.includes("step-button") ||
target.id.includes("resume-button")
) { // The hover should be applied to the wrapper (icon's parent node) const newTarget = target.parentNode.id.includes("wrapper")
? target.parentNode
: target;
// Remove the hover class if the user has changed buttons if (this.lastTarget && this.lastTarget != newTarget) { this.lastTarget.classList.remove("hover");
}
newTarget.classList.add("hover"); this.lastTarget = newTarget;
} elseif (this.lastTarget) { // Remove the hover class if the user isn't on a button this.lastTarget.classList.remove("hover");
}
}
handleEvent(e) { switch (e.type) { case"mousedown": this.onClick(e.target); break; case"DOMMouseScroll": // Prevent scrolling. That's because we only took a screenshot of the viewport, so // scrolling out of the viewport wouldn't draw the expected things. In the future // we can take the screenshot again on scroll, but for now it doesn't seem // important.
e.preventDefault(); break;
show(reason) { if (this.env.isXUL || !reason) { returnfalse;
}
// Only track mouse movement when the the overlay is shown // Prevents mouse tracking when the user isn't paused const { pageListenerTarget } = this.env;
pageListenerTarget.addEventListener("mousemove", this);
// Show the highlighter's root element. const root = this.getElement("root");
root.removeAttribute("hidden");
root.setAttribute("overlay", "true");
// Set the text to appear in the toolbar. const toolbar = this.getElement("toolbar");
toolbar.removeAttribute("hidden");
// When the debugger pauses execution in a page, events will not be delivered // to any handlers added to elements on that page. So here we use the // document's setSuppressedEventListener interface to still be able to act on mouse // events (they'll be handled by the `handleEvent` method) this.env.window.document.setSuppressedEventListener(this); returntrue;
}
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.