Bug 745961 - Hard to find the clickable region for adding a new CSS property in the Style Inspector. r=paul

This commit is contained in:
Dave Camp 2012-06-01 15:13:48 -07:00
parent 2a2116f6b5
commit fa726897b3
6 changed files with 95 additions and 24 deletions

View File

@ -1351,9 +1351,12 @@ RuleEditor.prototype = {
textContent: " {"
});
this.openBrace.addEventListener("click", function() {
this.newProperty();
}.bind(this), true);
code.addEventListener("click", function() {
let selection = this.doc.defaultView.getSelection();
if (selection.isCollapsed) {
this.newProperty();
}
}.bind(this), false);
this.propertyList = createChild(code, "ul", {
class: "ruleview-propertylist"
@ -1412,6 +1415,11 @@ RuleEditor.prototype = {
*/
newProperty: function RuleEditor_newProperty()
{
// If we're already creating a new property, ignore this.
if (!this.closeBrace.hasAttribute("tabindex")) {
return;
}
// While we're editing a new property, it doesn't make sense to
// start a second new property editor, so disable focusing the
// close brace for now.
@ -1522,12 +1530,21 @@ TextPropertyEditor.prototype = {
});
this.expander.addEventListener("click", this._onExpandClicked, true);
this.nameContainer = createChild(this.element, "span", {
class: "ruleview-namecontainer"
});
this.nameContainer.addEventListener("click", function(aEvent) {
this.nameSpan.click();
aEvent.stopPropagation();
}.bind(this), false);
// Property name, editable when focused. Property name
// is committed when the editor is unfocused.
this.nameSpan = createChild(this.element, "span", {
this.nameSpan = createChild(this.nameContainer, "span", {
class: "ruleview-propertyname",
tabindex: "0",
});
editableField({
start: this._onStartEditing,
element: this.nameSpan,
@ -1535,12 +1552,23 @@ TextPropertyEditor.prototype = {
advanceChars: ':'
});
appendText(this.element, ": ");
appendText(this.nameContainer, ": ");
// Create a span that will hold the property and semicolon.
// Use this span to create a slightly larger click target
// for the value.
let propertyContainer = createChild(this.element, "span", {
class: "ruleview-propertycontainer"
});
propertyContainer.addEventListener("click", function(aEvent) {
this.valueSpan.click();
aEvent.stopPropagation();
}.bind(this), false);
// Property value, editable when focused. Changes to the
// property value are applied as they are typed, and reverted
// if the user presses escape.
this.valueSpan = createChild(this.element, "span", {
this.valueSpan = createChild(propertyContainer, "span", {
class: "ruleview-propertyvalue",
tabindex: "0",
});
@ -1558,7 +1586,7 @@ TextPropertyEditor.prototype = {
value: this.prop.value,
priority: this.prop.priority };
appendText(this.element, ";");
appendText(propertyContainer, ";");
this.warning = createChild(this.element, "div", {
hidden: "",
@ -1672,18 +1700,20 @@ TextPropertyEditor.prototype = {
/**
* Handles clicks on the disabled property.
*/
_onEnableClicked: function TextPropertyEditor_onEnableClicked()
_onEnableClicked: function TextPropertyEditor_onEnableClicked(aEvent)
{
this.prop.setEnabled(this.enable.checked);
aEvent.stopPropagation();
},
/**
* Handles clicks on the computed property expander.
*/
_onExpandClicked: function TextPropertyEditor_onExpandClicked()
_onExpandClicked: function TextPropertyEditor_onExpandClicked(aEvent)
{
this.expander.classList.toggle("styleinspector-open");
this.computed.classList.toggle("styleinspector-open");
aEvent.stopPropagation();
},
/**
@ -1811,12 +1841,13 @@ function editableField(aOptions)
function editableItem(aElement, aCallback)
{
aElement.addEventListener("click", function() {
aElement.addEventListener("click", function(evt) {
let win = this.ownerDocument.defaultView;
let selection = win.getSelection();
if (selection.isCollapsed) {
aCallback(aElement);
}
evt.stopPropagation();
}, false);
// If focused by means other than a click, start editing by

View File

@ -45,3 +45,12 @@
.ruleview-property:not(:hover) > .ruleview-enableproperty {
visibility: hidden;
}
.ruleview-namecontainer {
cursor: text;
}
.ruleview-propertycontainer {
cursor: text;
padding-right: 15px;
}

View File

@ -228,15 +228,16 @@ function checkCopySelection()
{
let contentDoc = ruleViewFrame().contentDocument;
let props = contentDoc.querySelectorAll(".ruleview-property");
let values = contentDoc.querySelectorAll(".ruleview-propertycontainer");
let range = document.createRange();
range.setStart(props[0], 0);
range.setEnd(props[4], 8);
range.setEnd(values[4], 2);
let selection = ruleViewFrame().contentWindow.getSelection();
selection.addRange(range);
info("Checking that _boundCopy() returns the correct" +
info("Checking that _boundCopy() returns the correct " +
"clipboard value");
let expectedPattern = " margin: 10em;[\\r\\n]+" +
" font-size: 14pt;[\\r\\n]+" +

View File

@ -174,7 +174,7 @@
}
.ruleview-ruleclose {
width: -moz-min-content;
cursor: text;
padding-right: 20px;
}
@ -211,13 +211,13 @@
.ruleview-propertyname {
padding: 1px 0;
cursor: text;
color: #0060C0;
text-decoration: inherit;
}
.ruleview-namecontainer,
.ruleview-propertycontainer,
.ruleview-propertyname,
.ruleview-propertyvalue {
cursor: text;
text-decoration: inherit;
}
@ -247,3 +247,13 @@
.ruleview-property[dirty] {
border-left-color: #68E268;
}
.ruleview-namecontainer > .ruleview-propertyname,
.ruleview-propertycontainer > .ruleview-propertyvalue {
border-bottom: 1px dotted transparent;
}
.ruleview-namecontainer:hover > .ruleview-propertyname,
.ruleview-propertycontainer:hover > .ruleview-propertyvalue {
border-bottom-color: black;
}

View File

@ -176,7 +176,7 @@
}
.ruleview-ruleclose {
width: -moz-min-content;
cursor: text;
padding-right: 20px;
}
@ -213,13 +213,13 @@
.ruleview-propertyname {
padding: 1px 0;
cursor: text;
color: #0060C0;
text-decoration: inherit;
}
.ruleview-namecontainer,
.ruleview-propertycontainer,
.ruleview-propertyname,
.ruleview-propertyvalue {
cursor: text;
text-decoration: inherit;
}
@ -249,3 +249,13 @@
.ruleview-property[dirty] {
border-left-color: #68E268;
}
.ruleview-namecontainer > .ruleview-propertyname,
.ruleview-propertycontainer > .ruleview-propertyvalue {
border-bottom: 1px dotted transparent;
}
.ruleview-namecontainer:hover > .ruleview-propertyname,
.ruleview-propertycontainer:hover > .ruleview-propertyvalue {
border-bottom-color: black;
}

View File

@ -175,7 +175,7 @@
}
.ruleview-ruleclose {
width: -moz-min-content;
cursor: text;
padding-right: 20px;
}
@ -212,13 +212,13 @@
.ruleview-propertyname {
padding: 1px 0;
cursor: text;
color: #0060C0;
text-decoration: inherit;
}
.ruleview-namecontainer,
.ruleview-propertycontainer,
.ruleview-propertyname,
.ruleview-propertyvalue {
cursor: text;
text-decoration: inherit;
}
@ -248,3 +248,13 @@
.ruleview-property[dirty] {
border-left-color: #68E268;
}
.ruleview-namecontainer > .ruleview-propertyname,
.ruleview-propertycontainer > .ruleview-propertyvalue {
border-bottom: 1px dotted transparent;
}
.ruleview-namecontainer:hover > .ruleview-propertyname,
.ruleview-propertycontainer:hover > .ruleview-propertyvalue {
border-bottom-color: black;
}