Skip to content

Commit

Permalink
Bug 1343167 - Add navigation for the box model's position, padding, b…
Browse files Browse the repository at this point in the history
…order, margin and content layout. r=jdescottes
  • Loading branch information
gabrielluong committed Apr 6, 2017
1 parent 85e118a commit ea4f15c
Show file tree
Hide file tree
Showing 8 changed files with 380 additions and 34 deletions.
12 changes: 12 additions & 0 deletions devtools/client/inspector/boxmodel/box-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ BoxModel.prototype = {
* Hides the box-model highlighter on the currently selected element.
*/
onHideBoxModelHighlighter() {
if (!this.inspector) {
return;
}

let toolbox = this.inspector.toolbox;
toolbox.highlighterUtils.unhighlight();
},
Expand Down Expand Up @@ -305,6 +309,10 @@ BoxModel.prototype = {
return;
}

if (!this.inspector) {
return;
}

let node = this.inspector.selection.nodeFront;
this.inspector.pageStyle.getLayout(node, {
autoMargins: true,
Expand All @@ -324,6 +332,10 @@ BoxModel.prototype = {
* Options passed to the highlighter actor.
*/
onShowBoxModelHighlighter(options = {}) {
if (!this.inspector) {
return;
}

let toolbox = this.inspector.toolbox;
let nodeFront = this.inspector.selection.nodeFront;

Expand Down
17 changes: 17 additions & 0 deletions devtools/client/inspector/boxmodel/components/BoxModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ module.exports = createClass({

mixins: [ addons.PureRenderMixin ],

onKeyDown(event) {
let { target } = event;

if (target == this.boxModelContainer) {
this.boxModelMain.onKeyDown(event);
}
},

render() {
let {
boxModel,
Expand All @@ -45,10 +53,19 @@ module.exports = createClass({
return dom.div(
{
className: "boxmodel-container",
tabIndex: 0,
ref: div => {
this.boxModelContainer = div;
},
onKeyDown: this.onKeyDown,
},
BoxModelMain({
boxModel,
boxModelContainer: this.boxModelContainer,
setSelectedNode,
ref: boxModelMain => {
this.boxModelMain = boxModelMain;
},
onHideBoxModelHighlighter,
onShowBoxModelEditor,
onShowBoxModelHighlighter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ module.exports = createClass({
propTypes: {
box: PropTypes.string.isRequired,
direction: PropTypes.string,
focusable: PropTypes.bool.isRequired,
level: PropTypes.string,
property: PropTypes.string.isRequired,
textContent: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
onShowBoxModelEditor: PropTypes.func.isRequired,
Expand All @@ -28,7 +30,7 @@ module.exports = createClass({
let { property, onShowBoxModelEditor } = this.props;

editableItem({
element: this.refs.span,
element: this.boxModelEditable,
}, (element, event) => {
onShowBoxModelEditor(element, event, property);
});
Expand All @@ -38,6 +40,8 @@ module.exports = createClass({
let {
box,
direction,
focusable,
level,
property,
textContent,
} = this.props;
Expand All @@ -57,8 +61,11 @@ module.exports = createClass({
{
className: "boxmodel-editable",
"data-box": box,
tabIndex: box === level && focusable ? 0 : -1,
title: property,
ref: "span",
ref: span => {
this.boxModelEditable = span;
},
},
textContent
)
Expand Down
Loading

0 comments on commit ea4f15c

Please sign in to comment.