Closed
Bug 896181
Opened 12 years ago
Closed 12 years ago
Autocomplete CSS properties and values in markup view
Categories
(DevTools :: Inspector, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 25
People
(Reporter: Optimizer, Assigned: Optimizer)
References
Details
Attachments
(1 file, 2 obsolete files)
17.99 KB,
patch
|
miker
:
review+
|
Details | Diff | Splinter Review |
Markup View also uses inplace editor to edit html. Thus, it will not be a lot much work to port autocompletion there.
the CONTENT_TYPES.MIXED_CONTENT in inplace-editor is specifically for that.
Assignee | ||
Comment 1•12 years ago
|
||
err. make that CONTENT_TYPES.CSS_MIXED
Assignee | ||
Comment 2•12 years ago
|
||
Adds a popup and suggestions to the markup panel when you are in a style = "" thing.
Assignee: nobody → scrapmachines
Status: NEW → ASSIGNED
Attachment #780314 -
Flags: feedback?(mratcliffe)
Comment 3•12 years ago
|
||
Comment on attachment 780314 [details] [diff] [review]
patch v0.1
Review of attachment 780314 [details] [diff] [review]:
-----------------------------------------------------------------
This is well on it's way.
A few points and nits to address.
This patch also needs a test.
::: browser/devtools/markupview/markup-view.js
@@ +73,5 @@
>
> this._initPreview();
> +
> + // Initialize static autocomplete popup
> + getAutocompletePopup(this.doc.defaultView.parent.document);
getAutocompletePopup(this._frame.ownerDocument);
@@ +1130,5 @@
> element: this.newAttr,
> trigger: "dblclick",
> stopOnReturn: true,
> + contentType: InplaceEditor.CONTENT_TYPES.CSS_MIXED,
> + popup: getAutocompletePopup(this.doc.defaultView.parent.document),
getAutocompletePopup(this._frame.ownerDocument);
@@ +1224,5 @@
> trigger: "dblclick",
> stopOnReturn: true,
> selectAll: false,
> + contentType: InplaceEditor.CONTENT_TYPES.CSS_MIXED,
> + popup: getAutocompletePopup(this.doc.defaultView.parent.document),
getAutocompletePopup(this._frame.ownerDocument);
@@ +1492,5 @@
> "chrome://browser/locale/devtools/inspector.properties"
> ));
> +
> +let _autocompletePopup = null;
> +function getAutocompletePopup(doc) {
Please move this method inside the MarkupView prototype, make it a getter and change _autocompletePopup to this._autocompletePopup. You should then destroy it from the destroy method.
::: browser/devtools/shared/inplace-editor.js
@@ +752,5 @@
> cycling = true;
> prevent = true;
> increment > 0 ? this.popup.selectPreviousItem()
> : this.popup.selectNextItem();
> + let input = this.input, pre = input.value.slice(0, input.selectionStart),
Each let should be on it's own line.
@@ +900,5 @@
> + list = list.concat(CSSPropertyList);
> + } else if (this.contentType == CONTENT_TYPES.CSS_VALUE) {
> + list = domUtils.getCSSValuesForProperty(this.property.name).sort();
> + } else if (this.contentType == CONTENT_TYPES.CSS_MIXED &&
> + query.match(/^\s*style\s*=/)) {
test is more efficient than match and designed for this purpose, use:
/^\s*style\s*=/.test(query);
@@ +902,5 @@
> + list = domUtils.getCSSValuesForProperty(this.property.name).sort();
> + } else if (this.contentType == CONTENT_TYPES.CSS_MIXED &&
> + query.match(/^\s*style\s*=/)) {
> + // Detecting if cursor is at property or value;
> + let match = query.match(/([:;\"\'=]?)\s*([^\"\';:=\s]+)$/);
You don't need to escape quotes in bracket expressions. This can be:
let match = query.match(/([:;"'=]?)\s*([^"';:=\s]+)$/);
@@ +906,5 @@
> + let match = query.match(/([:;\"\'=]?)\s*([^\"\';:=\s]+)$/);
> + if (match && match.length == 3) {
> + if (match[1] == ":") { // We are in CSS value completion
> + let propertyName =
> + query.match(/[;\"\'=]\s*([^:;\"\'=\s]+)\s*:\s*[^;:\s\"\']+$/)[1];
You don't need to escape quotes in bracket expressions.
@@ +934,5 @@
> if (!this.popup) {
> return;
> }
> let finalList = [], i = 0, count = 0, length = list.length;
> for (; i < length && count < MAX_POPUP_ENTRIES; i++) {
Try to stick to one let variable per line (of course, multiple inside a for is fine as long as it doesn't get too crowded).
e.g.
let finalList = [];
let length = list.length;
for (let i = 0, count = 0; i < length && count < MAX_POPUP_ENTRIES; i++) {
Attachment #780314 -
Flags: feedback?(mratcliffe)
Assignee | ||
Comment 4•12 years ago
|
||
Addressed review comments. Still needs tests. Will write some tomorrow.
Attachment #780314 -
Attachment is obsolete: true
Attachment #780600 -
Flags: review?(mratcliffe)
Comment 5•12 years ago
|
||
Comment on attachment 780600 [details] [diff] [review]
patch v0.2
Review of attachment 780600 [details] [diff] [review]:
-----------------------------------------------------------------
Lookin good.
Not r+ing until you have added the test.
Attachment #780600 -
Flags: review?(mratcliffe) → feedback+
Assignee | ||
Comment 6•12 years ago
|
||
Adds test. Please push it to try as I cannot atm
Attachment #780600 -
Attachment is obsolete: true
Attachment #783828 -
Flags: review?(mratcliffe)
Comment 7•12 years ago
|
||
I will review this on a green try:
https://tbpl.mozilla.org/?tree=Try&rev=c39bf5c9e8ca
Comment 8•12 years ago
|
||
Updated•12 years ago
|
Attachment #783828 -
Flags: review?(mratcliffe) → review+
Assignee | ||
Comment 9•12 years ago
|
||
landed in fx-team : https://hg.mozilla.org/integration/fx-team/rev/2a567b5e955d
Whiteboard: [fixed-in-fx-team]
Comment 10•12 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 25
Updated•11 years ago
|
Updated•7 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•