From cb366cf9d79a7cfc7b0407d232c4d47495b12cb4 Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 3 Aug 2015 18:54:03 +0300 Subject: [PATCH 1/4] fixup 1ad9200: don't overwrite the initial lint delay --- edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edit.js b/edit.js index d1cf8b61..5eaa6fc3 100644 --- a/edit.js +++ b/edit.js @@ -778,7 +778,7 @@ function updateLintReport(cm, delay) { // by settings its internal delay to 1ms and restoring it back later var lintOpt = editors[0].state.lint.options; setTimeout((function(opt, delay) { - opt.delay = delay; + opt.delay = delay == 1 ? opt.delay : delay; // options object is shared between editors update(this); }).bind(cm, lintOpt, lintOpt.delay), delay); lintOpt.delay = 1; From 78fea74a0e47e5f89154b1604664133d99dd3ca7 Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 3 Aug 2015 19:34:47 +0300 Subject: [PATCH 2/4] Editor: update CSSLint report ASAP once an issue is fixed --- edit.js | 30 ++++++++++++++++++++++++++---- storage.js | 2 ++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/edit.js b/edit.js index 5eaa6fc3..bdf26d82 100644 --- a/edit.js +++ b/edit.js @@ -161,7 +161,8 @@ function initCodeMirror() { foldGutter: true, gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter", "CodeMirror-lint-markers"], matchBrackets: true, - lint: CodeMirror.lint.css, + lint: {getAnnotations: CodeMirror.lint.css, delay: prefs.getPref("editor.lintDelay")}, + lintReportDelay: prefs.getPref("editor.lintReportDelay"), styleActiveLine: true, theme: "default", keyMap: prefs.getPref("editor.keyMap"), @@ -784,16 +785,28 @@ function updateLintReport(cm, delay) { lintOpt.delay = 1; return; } + // user is editing right now: postpone updating the report for the new issues (default: 500ms lint + 4500ms) + // or update it as soon as possible (default: 500ms lint + 100ms) in case an existing issue was just fixed + var postponeNewIssues = delay == undefined; var state = cm.state.lint; clearTimeout(state.reportTimeout); - state.reportTimeout = setTimeout(update.bind(cm), (state.options.delay || 500) + 4500); + state.reportTimeout = setTimeout(update.bind(cm), state.options.delay + 100); + function update() { // this == cm var scope = this ? [this] : editors; var changed = false; + var fixedOldIssues = false; scope.forEach(function(cm) { + var oldMarkers = cm.state.lint.markedLast || {}; + var newMarkers = {}; var html = cm.state.lint.marked.length == 0 ? "" : "" + cm.state.lint.marked.map(function(mark) { var info = mark.__annotation; + var pos = info.from.line + "," + info.from.ch; + if (oldMarkers[pos] == info.message) { + delete oldMarkers[pos]; + } + newMarkers[pos] = info.message; return "" + "" + info.severity + "" + @@ -802,13 +815,22 @@ function updateLintReport(cm, delay) { "" + (info.from.ch+1) + "" + "" + info.message.replace(/ at line \d.+$/, "") + ""; }).join("") + ""; + cm.state.lint.markedLast = newMarkers; + fixedOldIssues |= Object.keys(oldMarkers).length > 0; if (cm.state.lint.html != html) { cm.state.lint.html = html; changed = true; } }); if (changed) { - renderLintReport(true); + clearTimeout(state ? state.renderTimeout : undefined); + if (!postponeNewIssues || fixedOldIssues) { + renderLintReport(true); + } else { + state.renderTimeout = setTimeout(function() { + renderLintReport(true); + }, CodeMirror.defaults.lintReportDelay); + } } } } @@ -1001,7 +1023,7 @@ function initWithStyle(style) { function add() { var sectionDiv = addSection(null, queue.shift()); maximizeCodeHeight(sectionDiv, !queue.length); - updateLintReport(getCodeMirrorForSection(sectionDiv), 500); + updateLintReport(getCodeMirrorForSection(sectionDiv), prefs.getPref("editor.lintDelay")); } } diff --git a/storage.js b/storage.js index 62332718..3f8d2d02 100644 --- a/storage.js +++ b/storage.js @@ -189,6 +189,8 @@ var prefs = { newline_between_rules: false, end_with_newline: false }, + "editor.lintDelay": 500, // lint gutter marker update delay, ms + "editor.lintReportDelay": 4500, // lint report update delay, ms NO_DEFAULT_PREFERENCE: "No default preference for '%s'", UNHANDLED_DATA_TYPE: "Default '%s' is of type '%s' - what should be done with it?", From ad12fb10915e41a6172df2377b64468bc0548e4e Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 3 Aug 2015 08:47:13 +0300 Subject: [PATCH 3/4] Manage: fix broken horizontal scrolling --- manage.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manage.html b/manage.html index 58da0dec..ab4eb79b 100644 --- a/manage.html +++ b/manage.html @@ -43,6 +43,9 @@ width: 100%; height: 2px; background-color: #fff; } + .applies-to { + word-break: break-word; + } .applies-to, .actions { padding-left: 15px; } From 92c2e743d60124c7636a62a658c258695cafd6ae Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 4 Aug 2015 21:54:56 +0300 Subject: [PATCH 4/4] Don't break gmail chat iframe by iframeObserver Apparently some same-domain (!) iframes fail to load when their "contentDocument" is accessed (!) --- apply.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apply.js b/apply.js index 79b9981f..b647428b 100644 --- a/apply.js +++ b/apply.js @@ -216,6 +216,13 @@ function initObserver() { getDynamicIFrames(document).forEach(addDocumentStylesToIFrame); return; } + // move the check out of current execution context + // because some same-domain (!) iframes fail to load when their "contentDocument" is accessed (!) + // namely gmail's old chat iframe talkgadget.google.com + setTimeout(process.bind(null, mutations), 0); + }); + + function process(mutations) { for (var m = 0, ml = mutations.length; m < ml; m++) { var mutation = mutations[m]; if (mutation.type === "childList") { @@ -227,7 +234,7 @@ function initObserver() { } } } - }); + } iframeObserver.start = function() { // will be ignored by browser if already observing