Closed Bug 896181 Opened 11 years ago Closed 11 years ago

Autocomplete CSS properties and values in markup view

Categories

(DevTools :: Inspector, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 25

People

(Reporter: Optimizer, Assigned: Optimizer)

References

Details

Attachments

(1 file, 2 obsolete files)

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.
err. make that CONTENT_TYPES.CSS_MIXED
Attached patch patch v0.1 (obsolete) — Splinter Review
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 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)
Attached patch patch v0.2 (obsolete) — Splinter Review
Addressed review comments. Still needs tests. Will write some tomorrow.
Attachment #780314 - Attachment is obsolete: true
Attachment #780600 - Flags: review?(mratcliffe)
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+
Attached patch Patch v3.0Splinter Review
Adds test. Please push it to try as I cannot atm
Attachment #780600 - Attachment is obsolete: true
Attachment #783828 - Flags: review?(mratcliffe)
Attachment #783828 - Flags: review?(mratcliffe) → review+
Whiteboard: [fixed-in-fx-team]
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 25
Blocks: 916862
Blocks: 916763
No longer blocks: 916763
Depends on: 916763
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: