Title: [186602] trunk/Source/WebInspectorUI
- Revision
- 186602
- Author
- drou...@apple.com
- Date
- 2015-07-09 12:25:25 -0700 (Thu, 09 Jul 2015)
Log Message
Web Inspector: Checkbox disappears when unchecking CSS background style
https://bugs.webkit.org/show_bug.cgi?id=146776
Reviewed by Timothy Hatcher.
* UserInterface/Views/CSSStyleDeclarationTextEditor.js:
(WebInspector.CSSStyleDeclarationTextEditor.prototype._updateTextMarkers.update):
(WebInspector.CSSStyleDeclarationTextEditor.prototype._updateTextMarkers): Now uses _createCommentedCheckboxMarker.
(WebInspector.CSSStyleDeclarationTextEditor.prototype._createCommentedCheckboxMarker):
Scans the content of the given lineHandle for any commented text and adds an unselected checkbox to
the beginning of that lineHandle's line.
(WebInspector.CSSStyleDeclarationTextEditor.prototype._resetContent.update):
(WebInspector.CSSStyleDeclarationTextEditor.prototype._resetContent): Now adds commented checkbox markers.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (186601 => 186602)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-07-09 19:16:10 UTC (rev 186601)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-07-09 19:25:25 UTC (rev 186602)
@@ -1,3 +1,19 @@
+2015-07-09 Devin Rousso <drou...@apple.com>
+
+ Web Inspector: Checkbox disappears when unchecking CSS background style
+ https://bugs.webkit.org/show_bug.cgi?id=146776
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Views/CSSStyleDeclarationTextEditor.js:
+ (WebInspector.CSSStyleDeclarationTextEditor.prototype._updateTextMarkers.update):
+ (WebInspector.CSSStyleDeclarationTextEditor.prototype._updateTextMarkers): Now uses _createCommentedCheckboxMarker.
+ (WebInspector.CSSStyleDeclarationTextEditor.prototype._createCommentedCheckboxMarker):
+ Scans the content of the given lineHandle for any commented text and adds an unselected checkbox to
+ the beginning of that lineHandle's line.
+ (WebInspector.CSSStyleDeclarationTextEditor.prototype._resetContent.update):
+ (WebInspector.CSSStyleDeclarationTextEditor.prototype._resetContent): Now adds commented checkbox markers.
+
2015-07-09 Nikita Vasilyev <nvasil...@apple.com>
Web Inspector: Align slider knobs in the color picker
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js (186601 => 186602)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js 2015-07-09 19:16:10 UTC (rev 186601)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js 2015-07-09 19:25:25 UTC (rev 186602)
@@ -799,34 +799,10 @@
});
if (!this._codeMirror.getOption("readOnly")) {
- // Matches a comment like: /* -webkit-foo: bar; */
- var commentedPropertyRegex = /\/\*\s*[-\w]+\s*:\s*[^;]+;?\s*\*\//g;
-
// Look for comments that look like properties and add checkboxes in front of them.
- var lineCount = this._codeMirror.lineCount();
- for (var i = 0; i < lineCount; ++i) {
- var lineContent = this._codeMirror.getLine(i);
-
- var match = commentedPropertyRegex.exec(lineContent);
- while (match) {
- var checkboxElement = document.createElement("input");
- checkboxElement.type = "checkbox";
- checkboxElement.checked = false;
- checkboxElement.addEventListener("change", this._propertyCommentCheckboxChanged.bind(this));
-
- var from = {line: i, ch: match.index};
- var to = {line: i, ch: match.index + match[0].length};
-
- var checkboxMarker = this._codeMirror.setUniqueBookmark(from, checkboxElement);
- checkboxMarker.__propertyCheckbox = true;
-
- var commentTextMarker = this._codeMirror.markText(from, to);
-
- checkboxElement.__commentTextMarker = commentTextMarker;
-
- match = commentedPropertyRegex.exec(lineContent);
- }
- }
+ this._codeMirror.eachLine(function(lineHandler) {
+ this._createCommentedCheckboxMarker(lineHandler);
+ }.bind(this));
}
// Look for colors and make swatches.
@@ -841,6 +817,41 @@
this._codeMirror.operation(update.bind(this));
}
+ _createCommentedCheckboxMarker(lineHandle)
+ {
+ var lineNumber = lineHandle.lineNo();
+
+ // Since lineNumber can be 0, it is also necessary to check if it is a number before returning.
+ if (!lineNumber && isNaN(lineNumber))
+ return;
+
+ // Matches a comment like: /* -webkit-foo: bar; */
+ var commentedPropertyRegex = /\/\*\s*[-\w]+\s*:\s*[^;]+;?\s*\*\//g;
+
+ var match = commentedPropertyRegex.exec(lineHandle.text);
+ if (!match)
+ return;
+
+ while (match) {
+ var checkboxElement = document.createElement("input");
+ checkboxElement.type = "checkbox";
+ checkboxElement.checked = false;
+ checkboxElement.addEventListener("change", this._propertyCommentCheckboxChanged.bind(this));
+
+ var from = {line: lineNumber, ch: match.index};
+ var to = {line: lineNumber, ch: match.index + match[0].length};
+
+ var checkboxMarker = this._codeMirror.setUniqueBookmark(from, checkboxElement);
+ checkboxMarker.__propertyCheckbox = true;
+
+ var commentTextMarker = this._codeMirror.markText(from, to);
+
+ checkboxElement.__commentTextMarker = commentTextMarker;
+
+ match = commentedPropertyRegex.exec(lineHandle.text);
+ }
+ }
+
_createColorSwatches(nonatomic, lineNumber)
{
function update()
@@ -1539,8 +1550,10 @@
var lineContentSansWhitespace = lineHandler.text.replace(findWhitespace, "");
var properties = cssPropertiesMap.get(lineContentSansWhitespace);
- if (!properties)
+ if (!properties) {
+ this._createCommentedCheckboxMarker(lineHandler);
return;
+ }
for (var property of properties) {
if (property.__refreshedAfterBlur)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes