mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-10 13:54:27 +00:00
Bug 897960 - walker should support mozbrowser iframes. r=dcamp
This commit is contained in:
parent
255f72f060
commit
ec85d47fa1
@ -1747,7 +1747,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "AppCacheUtils",
|
||||
width = window.innerWidth;
|
||||
height = window.innerHeight;
|
||||
} else {
|
||||
let rect = LayoutHelpers.getRect(node, window);
|
||||
let lh = new LayoutHelpers(window);
|
||||
let rect = lh.getRect(node, window);
|
||||
top = rect.top;
|
||||
left = rect.left;
|
||||
width = rect.width;
|
||||
|
@ -19,7 +19,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
|
||||
let promise = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js").Promise;
|
||||
Cu.import("resource:///modules/source-editor.jsm");
|
||||
Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm");
|
||||
Cu.import("resource:///modules/devtools/BreadcrumbsWidget.jsm");
|
||||
Cu.import("resource:///modules/devtools/SideMenuWidget.jsm");
|
||||
Cu.import("resource:///modules/devtools/VariablesView.jsm");
|
||||
@ -40,6 +39,13 @@ Object.defineProperty(this, "NetworkHelper", {
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(this, "DevtoolsHelpers", {
|
||||
get: function() {
|
||||
return devtools.require("devtools/shared/helpers");
|
||||
},
|
||||
configurable: true,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
/**
|
||||
* Object defining the debugger controller components.
|
||||
|
@ -38,10 +38,10 @@ ToolbarView.prototype = {
|
||||
this._stepOutButton = document.getElementById("step-out");
|
||||
this._chromeGlobals = document.getElementById("chrome-globals");
|
||||
|
||||
let resumeKey = LayoutHelpers.prettyKey(document.getElementById("resumeKey"), true);
|
||||
let stepOverKey = LayoutHelpers.prettyKey(document.getElementById("stepOverKey"), true);
|
||||
let stepInKey = LayoutHelpers.prettyKey(document.getElementById("stepInKey"), true);
|
||||
let stepOutKey = LayoutHelpers.prettyKey(document.getElementById("stepOutKey"), true);
|
||||
let resumeKey = DevtoolsHelpers.prettyKey(document.getElementById("resumeKey"), true);
|
||||
let stepOverKey = DevtoolsHelpers.prettyKey(document.getElementById("stepOverKey"), true);
|
||||
let stepInKey = DevtoolsHelpers.prettyKey(document.getElementById("stepInKey"), true);
|
||||
let stepOutKey = DevtoolsHelpers.prettyKey(document.getElementById("stepOutKey"), true);
|
||||
this._resumeTooltip = L10N.getFormatStr("resumeButtonTooltip", resumeKey);
|
||||
this._pauseTooltip = L10N.getFormatStr("pauseButtonTooltip", resumeKey);
|
||||
this._stepOverTooltip = L10N.getFormatStr("stepOverTooltip", stepOverKey);
|
||||
@ -729,12 +729,12 @@ FilterView.prototype = {
|
||||
this._variableOperatorButton = document.getElementById("variable-operator-button");
|
||||
this._variableOperatorLabel = document.getElementById("variable-operator-label");
|
||||
|
||||
this._fileSearchKey = LayoutHelpers.prettyKey(document.getElementById("fileSearchKey"), true);
|
||||
this._globalSearchKey = LayoutHelpers.prettyKey(document.getElementById("globalSearchKey"), true);
|
||||
this._filteredFunctionsKey = LayoutHelpers.prettyKey(document.getElementById("functionSearchKey"), true);
|
||||
this._tokenSearchKey = LayoutHelpers.prettyKey(document.getElementById("tokenSearchKey"), true);
|
||||
this._lineSearchKey = LayoutHelpers.prettyKey(document.getElementById("lineSearchKey"), true);
|
||||
this._variableSearchKey = LayoutHelpers.prettyKey(document.getElementById("variableSearchKey"), true);
|
||||
this._fileSearchKey = DevtoolsHelpers.prettyKey(document.getElementById("fileSearchKey"), true);
|
||||
this._globalSearchKey = DevtoolsHelpers.prettyKey(document.getElementById("globalSearchKey"), true);
|
||||
this._filteredFunctionsKey = DevtoolsHelpers.prettyKey(document.getElementById("functionSearchKey"), true);
|
||||
this._tokenSearchKey = DevtoolsHelpers.prettyKey(document.getElementById("tokenSearchKey"), true);
|
||||
this._lineSearchKey = DevtoolsHelpers.prettyKey(document.getElementById("lineSearchKey"), true);
|
||||
this._variableSearchKey = DevtoolsHelpers.prettyKey(document.getElementById("variableSearchKey"), true);
|
||||
|
||||
this._searchbox.addEventListener("click", this._onClick, false);
|
||||
this._searchbox.addEventListener("select", this._onSearch, false);
|
||||
|
@ -8,7 +8,7 @@ var gPane = null;
|
||||
var gTab = null;
|
||||
var gDebugger = null;
|
||||
var gView = null;
|
||||
var gLH = null;
|
||||
var gDH = null;
|
||||
var gL10N = null;
|
||||
|
||||
function test() {
|
||||
@ -17,7 +17,7 @@ function test() {
|
||||
gPane = aPane;
|
||||
gDebugger = gPane.panelWin;
|
||||
gView = gDebugger.DebuggerView;
|
||||
gLH = gDebugger.LayoutHelpers;
|
||||
gDH = gDebugger.DevtoolsHelpers;
|
||||
gL10N = gDebugger.L10N;
|
||||
|
||||
testPause();
|
||||
@ -31,7 +31,7 @@ function testPause() {
|
||||
let button = gDebugger.document.getElementById("resume");
|
||||
is(button.getAttribute("tooltiptext"),
|
||||
gL10N.getFormatStr("pauseButtonTooltip",
|
||||
gLH.prettyKey(gDebugger.document.getElementById("resumeKey"))),
|
||||
gDH.prettyKey(gDebugger.document.getElementById("resumeKey"))),
|
||||
"Button tooltip should be pause when running.");
|
||||
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("paused", function() {
|
||||
@ -45,7 +45,7 @@ function testPause() {
|
||||
|
||||
is(button.getAttribute("tooltiptext"),
|
||||
gL10N.getFormatStr("resumeButtonTooltip",
|
||||
gLH.prettyKey(gDebugger.document.getElementById("resumeKey"))),
|
||||
gDH.prettyKey(gDebugger.document.getElementById("resumeKey"))),
|
||||
"Button tooltip should be resume when paused.");
|
||||
|
||||
is(frames.querySelectorAll(".dbg-stackframe").length, 0,
|
||||
@ -70,7 +70,7 @@ function testResume() {
|
||||
let button = gDebugger.document.getElementById("resume");
|
||||
is(button.getAttribute("tooltiptext"),
|
||||
gL10N.getFormatStr("pauseButtonTooltip",
|
||||
gLH.prettyKey(gDebugger.document.getElementById("resumeKey"))),
|
||||
gDH.prettyKey(gDebugger.document.getElementById("resumeKey"))),
|
||||
"Button tooltip should be pause when running.");
|
||||
|
||||
closeDebuggerAndFinish();
|
||||
@ -88,6 +88,6 @@ registerCleanupFunction(function() {
|
||||
gTab = null;
|
||||
gDebugger = null;
|
||||
gView = null;
|
||||
gLH = null;
|
||||
gDH = null;
|
||||
gL10N = null;
|
||||
});
|
||||
|
@ -11,7 +11,6 @@ const ENSURE_SELECTION_VISIBLE_DELAY = 50; // ms
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource:///modules/devtools/DOMHelpers.jsm");
|
||||
Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
let promise = require("sdk/core/promise");
|
||||
|
@ -93,6 +93,7 @@ function LocalHighlighter(aTarget, aInspector, aToolbox)
|
||||
this.chromeDoc = this.tab.ownerDocument;
|
||||
this.chromeWin = this.chromeDoc.defaultView;
|
||||
this.inspector = aInspector
|
||||
this.layoutHelpers = new LayoutHelpers(this.browser.contentWindow);
|
||||
|
||||
EventEmitter.decorate(this);
|
||||
|
||||
@ -225,7 +226,7 @@ LocalHighlighter.prototype = {
|
||||
this.invalidateSize();
|
||||
if (!this._highlighting &&
|
||||
this.selection.reason != "highlighter") {
|
||||
LayoutHelpers.scrollIntoViewIfNeeded(this.selection.node);
|
||||
this.layoutHelpers.scrollIntoViewIfNeeded(this.selection.node);
|
||||
}
|
||||
} else {
|
||||
this.disabled = true;
|
||||
@ -255,7 +256,7 @@ LocalHighlighter.prototype = {
|
||||
}
|
||||
|
||||
let clientRect = this.selection.node.getBoundingClientRect();
|
||||
let rect = LayoutHelpers.getDirtyRect(this.selection.node);
|
||||
let rect = this.layoutHelpers.getDirtyRect(this.selection.node);
|
||||
this.highlightRectangle(rect);
|
||||
|
||||
this.moveInfobar();
|
||||
@ -461,7 +462,7 @@ LocalHighlighter.prototype = {
|
||||
texthbox.addEventListener("mousedown", function(aEvent) {
|
||||
// On click, show the node:
|
||||
if (this.selection.isElementNode()) {
|
||||
LayoutHelpers.scrollIntoViewIfNeeded(this.selection.node);
|
||||
this.layoutHelpers.scrollIntoViewIfNeeded(this.selection.node);
|
||||
}
|
||||
}.bind(this), true);
|
||||
|
||||
@ -514,7 +515,7 @@ LocalHighlighter.prototype = {
|
||||
return; // same rectangle
|
||||
}
|
||||
|
||||
let aRectScaled = LayoutHelpers.getZoomedRect(this.win, aRect);
|
||||
let aRectScaled = this.layoutHelpers.getZoomedRect(this.win, aRect);
|
||||
|
||||
if (aRectScaled.left >= 0 && aRectScaled.top >= 0 &&
|
||||
aRectScaled.width > 0 && aRectScaled.height > 0) {
|
||||
@ -809,7 +810,7 @@ LocalHighlighter.prototype = {
|
||||
// This should never happen, but just in case, we don't let the
|
||||
// highlighter highlight browser nodes.
|
||||
if (doc && doc != this.chromeDoc) {
|
||||
let element = LayoutHelpers.getElementFromPoint(aEvent.target.ownerDocument,
|
||||
let element = this.layoutHelpers.getElementFromPoint(aEvent.target.ownerDocument,
|
||||
aEvent.clientX, aEvent.clientY);
|
||||
if (element && element != this.selection.node) {
|
||||
this.selection.setNode(element, "highlighter");
|
||||
|
@ -33,7 +33,8 @@ function test()
|
||||
|
||||
let tmp = {};
|
||||
Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm", tmp);
|
||||
ok(!tmp.LayoutHelpers.isNodeConnected(node), "Node considered as disconnected.");
|
||||
let lh = new tmp.LayoutHelpers(window.content);
|
||||
ok(!lh.isNodeConnected(node), "Node considered as disconnected.");
|
||||
|
||||
// Wait for the inspector to process the mutation
|
||||
inspector.once("inspector-updated", () => {
|
||||
|
@ -33,7 +33,8 @@ function test()
|
||||
|
||||
let tmp = {};
|
||||
Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm", tmp);
|
||||
ok(!tmp.LayoutHelpers.isNodeConnected(node), "Node considered as disconnected.");
|
||||
let lh = new tmp.LayoutHelpers(window.content);
|
||||
ok(!lh.isNodeConnected(node), "Node considered as disconnected.");
|
||||
ok(!inspector.selection.isConnected(), "Selection considered as disconnected");
|
||||
|
||||
finishUp();
|
||||
|
@ -77,7 +77,8 @@ function getHighlitNode()
|
||||
// Get midpoint of diagonal line.
|
||||
let midpoint = midPoint(a, b);
|
||||
|
||||
return LayoutHelpers.getElementFromPoint(h.win.document, midpoint.x,
|
||||
let lh = new LayoutHelpers(window.content);
|
||||
return lh.getElementFromPoint(h.win.document, midpoint.x,
|
||||
midpoint.y);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm");
|
||||
Cu.import("resource://gre/modules/devtools/Loader.jsm");
|
||||
Cu.import("resource://gre/modules/devtools/Console.jsm");
|
||||
|
||||
|
@ -53,6 +53,8 @@ function MarkupView(aInspector, aFrame, aControllerWindow)
|
||||
this.doc = this._frame.contentDocument;
|
||||
this._elt = this.doc.querySelector("#root");
|
||||
|
||||
this.layoutHelpers = new LayoutHelpers(this.doc.defaultView);
|
||||
|
||||
try {
|
||||
this.maxChildren = Services.prefs.getIntPref("devtools.markup.pagesize");
|
||||
} catch(ex) {
|
||||
@ -406,7 +408,7 @@ MarkupView.prototype = {
|
||||
return this._ensureVisible(aNode);
|
||||
}).then(() => {
|
||||
// Why is this not working?
|
||||
LayoutHelpers.scrollIntoViewIfNeeded(this._containers.get(aNode).editor.elt, centered);
|
||||
this.layoutHelpers.scrollIntoViewIfNeeded(this._containers.get(aNode).editor.elt, centered);
|
||||
});
|
||||
},
|
||||
|
||||
@ -1231,7 +1233,7 @@ ElementEditor.prototype = {
|
||||
// Double quotes need to be handled specially to prevent DOMParser failing.
|
||||
// name="v"a"l"u"e" when editing -> name='v"a"l"u"e"'
|
||||
// name="v'a"l'u"e" when editing -> name="v'a"l'u"e"
|
||||
let editValueDisplayed = aAttr.value;
|
||||
let editValueDisplayed = aAttr.value || "";
|
||||
let hasDoubleQuote = editValueDisplayed.contains('"');
|
||||
let hasSingleQuote = editValueDisplayed.contains("'");
|
||||
let initial = aAttr.name + '="' + editValueDisplayed + '"';
|
||||
|
@ -19,6 +19,7 @@ let require = Components.utils.import("resource://gre/modules/devtools/Loader.js
|
||||
let { Cc, Ci, Cu } = require("chrome");
|
||||
let promise = require("sdk/core/promise");
|
||||
let Telemetry = require("devtools/shared/telemetry");
|
||||
let DevtoolsHelpers = require("devtools/shared/helpers");
|
||||
let TargetFactory = require("devtools/framework/target").TargetFactory;
|
||||
const escodegen = require("escodegen/escodegen");
|
||||
|
||||
@ -26,7 +27,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource:///modules/source-editor.jsm");
|
||||
Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm");
|
||||
Cu.import("resource:///modules/devtools/scratchpad-manager.jsm");
|
||||
Cu.import("resource://gre/modules/jsdebugger.jsm");
|
||||
Cu.import("resource:///modules/devtools/gDevTools.jsm");
|
||||
@ -1284,9 +1284,9 @@ var Scratchpad = {
|
||||
|
||||
let initialText = this.strings.formatStringFromName(
|
||||
"scratchpadIntro1",
|
||||
[LayoutHelpers.prettyKey(document.getElementById("sp-key-run")),
|
||||
LayoutHelpers.prettyKey(document.getElementById("sp-key-inspect")),
|
||||
LayoutHelpers.prettyKey(document.getElementById("sp-key-display"))],
|
||||
[DevtoolsHelpers.prettyKey(document.getElementById("sp-key-run")),
|
||||
DevtoolsHelpers.prettyKey(document.getElementById("sp-key-inspect")),
|
||||
DevtoolsHelpers.prettyKey(document.getElementById("sp-key-display"))],
|
||||
3);
|
||||
|
||||
let args = window.arguments;
|
||||
|
@ -25,52 +25,54 @@ function test() {
|
||||
}
|
||||
|
||||
function runTest(win, some) {
|
||||
let lh = new LayoutHelpers(win);
|
||||
|
||||
some.style.top = win.innerHeight + 'px';
|
||||
some.style.left = win.innerWidth + 'px';
|
||||
// The tests start with a black 2x2 pixels square below bottom right.
|
||||
// Do not resize the window during the tests.
|
||||
|
||||
win.scroll(win.innerWidth / 2, win.innerHeight + 2); // Above the viewport.
|
||||
LayoutHelpers.scrollIntoViewIfNeeded(some);
|
||||
lh.scrollIntoViewIfNeeded(some);
|
||||
is(win.scrollY, Math.floor(win.innerHeight / 2) + 1,
|
||||
'Element completely hidden above should appear centered.');
|
||||
|
||||
win.scroll(win.innerWidth / 2, win.innerHeight + 1); // On the top edge.
|
||||
LayoutHelpers.scrollIntoViewIfNeeded(some);
|
||||
lh.scrollIntoViewIfNeeded(some);
|
||||
is(win.scrollY, win.innerHeight,
|
||||
'Element partially visible above should appear above.');
|
||||
|
||||
win.scroll(win.innerWidth / 2, 0); // Just below the viewport.
|
||||
LayoutHelpers.scrollIntoViewIfNeeded(some);
|
||||
lh.scrollIntoViewIfNeeded(some);
|
||||
is(win.scrollY, Math.floor(win.innerHeight / 2) + 1,
|
||||
'Element completely hidden below should appear centered.');
|
||||
|
||||
win.scroll(win.innerWidth / 2, 1); // On the bottom edge.
|
||||
LayoutHelpers.scrollIntoViewIfNeeded(some);
|
||||
lh.scrollIntoViewIfNeeded(some);
|
||||
is(win.scrollY, 2,
|
||||
'Element partially visible below should appear below.');
|
||||
|
||||
|
||||
win.scroll(win.innerWidth / 2, win.innerHeight + 2); // Above the viewport.
|
||||
LayoutHelpers.scrollIntoViewIfNeeded(some, false);
|
||||
lh.scrollIntoViewIfNeeded(some, false);
|
||||
is(win.scrollY, win.innerHeight,
|
||||
'Element completely hidden above should appear above ' +
|
||||
'if parameter is false.');
|
||||
|
||||
win.scroll(win.innerWidth / 2, win.innerHeight + 1); // On the top edge.
|
||||
LayoutHelpers.scrollIntoViewIfNeeded(some, false);
|
||||
lh.scrollIntoViewIfNeeded(some, false);
|
||||
is(win.scrollY, win.innerHeight,
|
||||
'Element partially visible above should appear above ' +
|
||||
'if parameter is false.');
|
||||
|
||||
win.scroll(win.innerWidth / 2, 0); // Below the viewport.
|
||||
LayoutHelpers.scrollIntoViewIfNeeded(some, false);
|
||||
lh.scrollIntoViewIfNeeded(some, false);
|
||||
is(win.scrollY, 2,
|
||||
'Element completely hidden below should appear below ' +
|
||||
'if parameter is false.');
|
||||
|
||||
win.scroll(win.innerWidth / 2, 1); // On the bottom edge.
|
||||
LayoutHelpers.scrollIntoViewIfNeeded(some, false);
|
||||
lh.scrollIntoViewIfNeeded(some, false);
|
||||
is(win.scrollY, 2,
|
||||
'Element partially visible below should appear below ' +
|
||||
'if parameter is false.');
|
||||
@ -86,7 +88,7 @@ function runTest(win, some) {
|
||||
|
||||
fwin.addEventListener('load', function frameLoad() {
|
||||
let some = fwin.document.getElementById('some');
|
||||
LayoutHelpers.scrollIntoViewIfNeeded(some);
|
||||
lh.scrollIntoViewIfNeeded(some);
|
||||
is(win.scrollX, Math.floor(win.innerWidth / 2) + 20,
|
||||
'Scrolling from an iframe should center the iframe vertically.');
|
||||
is(win.scrollY, Math.floor(win.innerHeight / 2) + 20,
|
||||
|
@ -55,10 +55,11 @@ function test() {
|
||||
iframe.contentWindow.innerHeight,
|
||||
"The content window height wasn't calculated correctly.");
|
||||
|
||||
let nodeCoordinates = LayoutHelpers.getRect(
|
||||
let lh = new LayoutHelpers(gBrowser.contentWindow);
|
||||
let nodeCoordinates = lh.getRect(
|
||||
iframe.contentDocument.getElementById("test-div"), iframe.contentWindow);
|
||||
|
||||
let frameOffset = LayoutHelpers.getIframeContentOffset(iframe);
|
||||
let frameOffset = lh.getIframeContentOffset(iframe);
|
||||
let frameRect = iframe.getBoundingClientRect();
|
||||
|
||||
is(nodeCoordinates.top, frameRect.top + frameOffset[0] + 98,
|
||||
|
@ -104,10 +104,11 @@ function test() {
|
||||
iframe.contentWindow.innerHeight,
|
||||
"The content window height wasn't calculated correctly.");
|
||||
|
||||
let nodeCoordinates = LayoutHelpers.getRect(
|
||||
let lh = new LayoutHelpers(gBrowser.contentWindow);
|
||||
let nodeCoordinates = lh.getRect(
|
||||
iframe.contentDocument.getElementById("test-div"), iframe.contentWindow);
|
||||
|
||||
let frameOffset = LayoutHelpers.getIframeContentOffset(iframe);
|
||||
let frameOffset = lh.getIframeContentOffset(iframe);
|
||||
let frameRect = iframe.getBoundingClientRect();
|
||||
|
||||
is(nodeCoordinates.top, frameRect.top + frameOffset[0],
|
||||
|
@ -405,8 +405,9 @@ TiltUtils.DOM = {
|
||||
*/
|
||||
getNodePosition: function TUD_getNodePosition(aContentWindow, aNode,
|
||||
aParentPosition) {
|
||||
let lh = new LayoutHelpers(aContentWindow);
|
||||
// get the x, y, width and height coordinates of the node
|
||||
let coord = LayoutHelpers.getRect(aNode, aContentWindow);
|
||||
let coord = lh.getRect(aNode, aContentWindow);
|
||||
if (!coord) {
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user