mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 892274 - H should toggle the selected node's hidden attribute. r=harth
--HG-- extra : rebase_source : 2e56afd40e611dc2d6d87d1c7c978e64ebb90baf
This commit is contained in:
parent
cb4ef24fb6
commit
a95844e6f8
@ -159,6 +159,14 @@ MarkupView.prototype = {
|
||||
}
|
||||
|
||||
switch(aEvent.keyCode) {
|
||||
case Ci.nsIDOMKeyEvent.DOM_VK_H:
|
||||
let node = this._selectedContainer.node;
|
||||
if (node.hidden) {
|
||||
this.walker.unhideNode(node).then(() => this.nodeChanged(node));
|
||||
} else {
|
||||
this.walker.hideNode(node).then(() => this.nodeChanged(node));
|
||||
}
|
||||
break;
|
||||
case Ci.nsIDOMKeyEvent.DOM_VK_DELETE:
|
||||
case Ci.nsIDOMKeyEvent.DOM_VK_BACK_SPACE:
|
||||
this.deleteNode(this._selectedContainer.node);
|
||||
@ -521,7 +529,7 @@ MarkupView.prototype = {
|
||||
*/
|
||||
nodeChanged: function MT_nodeChanged(aNode)
|
||||
{
|
||||
if (aNode === this._inspector.selection) {
|
||||
if (aNode === this._inspector.selection.nodeFront) {
|
||||
this._inspector.change("markupview");
|
||||
}
|
||||
},
|
||||
|
@ -63,6 +63,10 @@ const { Class } = require("sdk/core/heritage");
|
||||
|
||||
const PSEUDO_CLASSES = [":hover", ":active", ":focus"];
|
||||
|
||||
const HIDDEN_CLASS = "__fx-devtools-hide-shortcut__";
|
||||
|
||||
const HELPER_SHEET = "." + HIDDEN_CLASS + " { visibility: hidden !important }";
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
exports.register = function(handle) {
|
||||
@ -402,6 +406,11 @@ let NodeFront = protocol.FrontClass(NodeActor, {
|
||||
return (name in this._attrMap);
|
||||
},
|
||||
|
||||
get hidden() {
|
||||
let cls = this.getAttribute("class");
|
||||
return cls && cls.indexOf(HIDDEN_CLASS) > -1;
|
||||
},
|
||||
|
||||
get attributes() this._form.attrs,
|
||||
|
||||
get pseudoClassLocks() this._form.pseudoClassLocks || [],
|
||||
@ -1291,6 +1300,33 @@ var WalkerActor = protocol.ActorClass({
|
||||
return true;
|
||||
},
|
||||
|
||||
_installHelperSheet: function(node) {
|
||||
if (!this.installedHelpers) {
|
||||
this.installedHelpers = new WeakMap;
|
||||
}
|
||||
let win = node.rawNode.ownerDocument.defaultView;
|
||||
if (!this.installedHelpers.has(win)) {
|
||||
let { Style } = require("sdk/stylesheet/style");
|
||||
let { attach } = require("sdk/content/mod");
|
||||
let style = Style({source: HELPER_SHEET, type: "agent" });
|
||||
attach(style, win);
|
||||
this.installedHelpers.set(win, style);
|
||||
}
|
||||
},
|
||||
|
||||
hideNode: method(function(node) {
|
||||
this._installHelperSheet(node);
|
||||
node.rawNode.classList.add(HIDDEN_CLASS);
|
||||
}, {
|
||||
request: { node: Arg(0, "domnode") }
|
||||
}),
|
||||
|
||||
unhideNode: method(function(node) {
|
||||
node.rawNode.classList.remove(HIDDEN_CLASS);
|
||||
}, {
|
||||
request: { node: Arg(0, "domnode") }
|
||||
}),
|
||||
|
||||
/**
|
||||
* Remove a pseudo-class lock from a node.
|
||||
*
|
||||
|
@ -16,6 +16,7 @@ MOCHITEST_CHROME_FILES = \
|
||||
inspector-traversal-data.html \
|
||||
test_inspector-changeattrs.html \
|
||||
test_inspector-changevalue.html \
|
||||
test_inspector-hide.html \
|
||||
test_inspector-insert.html \
|
||||
test_inspector-mutations-attr.html \
|
||||
test_inspector-mutations-childlist.html \
|
||||
|
@ -0,0 +1,79 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug </title>
|
||||
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
<script type="application/javascript;version=1.8" src="inspector-helpers.js"></script>
|
||||
<script type="application/javascript;version=1.8">
|
||||
Components.utils.import("resource://gre/modules/devtools/Loader.jsm");
|
||||
|
||||
const promise = devtools.require("sdk/core/promise");
|
||||
const inspector = devtools.require("devtools/server/actors/inspector");
|
||||
|
||||
window.onload = function() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
runNextTest();
|
||||
}
|
||||
|
||||
var gWalker = null;
|
||||
var gClient = null;
|
||||
|
||||
addTest(function setup() {
|
||||
let url = document.getElementById("inspectorContent").href;
|
||||
attachURL(url, function(err, client, tab, doc) {
|
||||
gInspectee = doc;
|
||||
let {InspectorFront} = devtools.require("devtools/server/actors/inspector");
|
||||
let inspector = InspectorFront(client, tab);
|
||||
promiseDone(inspector.getWalker().then(walker => {
|
||||
ok(walker, "getWalker() should return an actor.");
|
||||
gClient = client;
|
||||
gWalker = walker;
|
||||
}).then(runNextTest));
|
||||
});
|
||||
});
|
||||
|
||||
addTest(function testRearrange() {
|
||||
let listFront = null;
|
||||
let listNode = gInspectee.querySelector("#longlist");
|
||||
|
||||
promiseDone(gWalker.querySelector(gWalker.rootNode, "#longlist").then(front => {
|
||||
listFront = front;
|
||||
}).then(() => {
|
||||
let computed = gInspectee.defaultView.getComputedStyle(listNode);
|
||||
ok(computed.visibility, "visible", "Node should be visible to start with");
|
||||
return gWalker.hideNode(listFront);
|
||||
}).then(response => {
|
||||
let computed = gInspectee.defaultView.getComputedStyle(listNode);
|
||||
ok(computed.visibility, "hidden", "Node should be hidden");
|
||||
return gWalker.unhideNode(listFront);
|
||||
}).then(() => {
|
||||
let computed = gInspectee.defaultView.getComputedStyle(listNode);
|
||||
ok(computed.visibility, "visible", "Node should be visible again.");
|
||||
}).then(runNextTest));
|
||||
});
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gWalker;
|
||||
delete gClient;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
|
||||
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user