Changeset 170080 in webkit
- Timestamp:
- Jun 17, 2014, 3:35:07 PM (11 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r170077 r170080 1 2014-06-17 Jono Wells <jonowells@apple.com> 2 3 Web Inspector: Two lines in CSS rule are hidden until resize or click 4 https://bugs.webkit.org/show_bug.cgi?id=133951 5 6 Reviewed by Joseph Pecoraro. 7 8 Update to CodeMirror 4.2 fixed the issue. 9 10 * Tools/PrettyPrinting/codemirror.js: 11 * Tools/PrettyPrinting/css.js: 12 * Tools/PrettyPrinting/javascript.js: 13 * UserInterface/External/CodeMirror/clojure.js: 14 * UserInterface/External/CodeMirror/closebrackets.js: 15 * UserInterface/External/CodeMirror/codemirror.js: 16 * UserInterface/External/CodeMirror/coffeescript.js: 17 * UserInterface/External/CodeMirror/comment.js: 18 * UserInterface/External/CodeMirror/css.js: 19 * UserInterface/External/CodeMirror/htmlmixed.js: 20 * UserInterface/External/CodeMirror/javascript.js: 21 * UserInterface/External/CodeMirror/livescript.js: 22 * UserInterface/External/CodeMirror/matchbrackets.js: 23 * UserInterface/External/CodeMirror/overlay.js: 24 * UserInterface/External/CodeMirror/placeholder.js: 25 * UserInterface/External/CodeMirror/runmode.js: 26 * UserInterface/External/CodeMirror/sass.js: 27 * UserInterface/External/CodeMirror/searchcursor.js: 28 * UserInterface/External/CodeMirror/sql.js: 29 * UserInterface/External/CodeMirror/xml.js: 30 Update CodeMirror 4.1 to CodeMirror 4.2.0. 31 1 32 2014-06-17 Jono Wells <jonowells@apple.com> 2 33 -
trunk/Source/WebInspectorUI/Tools/PrettyPrinting/codemirror.js
r168170 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 // This is CodeMirror (http://codemirror.net), a code editor 2 5 // implemented in JavaScript on top of the browser's DOM. … … 94 97 95 98 registerEventHandlers(this); 99 ensureGlobalHandlers(); 96 100 97 101 var cm = this; … … 460 464 // height, and ensure (see op.scrollToPos) properties. 461 465 function visibleLines(display, doc, viewPort) { 462 var top = viewPort && viewPort.top != null ? viewPort.top: display.scroller.scrollTop;466 var top = viewPort && viewPort.top != null ? Math.max(0, viewPort.top) : display.scroller.scrollTop; 463 467 top = Math.floor(top - paddingTop(display)); 464 468 var bottom = viewPort && viewPort.bottom != null ? viewPort.bottom : top + display.wrapper.clientHeight; … … 476 480 to: ensureTo}; 477 481 } 478 return {from: from, to: to};482 return {from: from, to: Math.max(to, from + 1)}; 479 483 } 480 484 … … 663 667 cm.display.gutters.style.height = Math.max(measure.docHeight, measure.clientHeight - scrollerCutOff) + "px"; 664 668 } 665 666 669 667 670 function checkForWebkitWidthBug(cm, measure) { … … 1147 1150 sel = filterSelectionChange(doc, sel); 1148 1151 1149 var bias = cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1; 1152 var bias = options && options.bias || 1153 (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1); 1150 1154 setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true)); 1151 1155 … … 1927 1931 if (!updated && op.startHeight != cm.doc.height) updateScrollbars(cm); 1928 1932 1933 // Abort mouse wheel delta measurement, when scrolling explicitly 1934 if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos)) 1935 display.wheelStartX = display.wheelStartY = null; 1936 1929 1937 // Propagate the scroll position to the actual DOM scroller 1930 1938 if (op.scrollTop != null && display.scroller.scrollTop != op.scrollTop) { … … 2140 2148 function viewCuttingPoint(cm, oldN, newN, dir) { 2141 2149 var index = findViewIndex(cm, oldN), diff, view = cm.display.view; 2142 if (!sawCollapsedSpans) return {index: index, lineN: newN}; 2150 if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size) 2151 return {index: index, lineN: newN}; 2143 2152 for (var i = 0, n = cm.display.viewFrom; i < index; i++) 2144 2153 n += view[i].size; … … 2352 2361 if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return; 2353 2362 e_preventDefault(e); 2354 var word = findWordAt(cm .doc, pos);2363 var word = findWordAt(cm, pos); 2355 2364 extendSelection(cm.doc, word.anchor, word.head); 2356 2365 })); … … 2392 2401 // Prevent wrapper from ever scrolling 2393 2402 on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; }); 2394 2395 // When the window resizes, we need to refresh active editors.2396 var resizeTimer;2397 function onResize() {2398 if (resizeTimer == null) resizeTimer = setTimeout(function() {2399 resizeTimer = null;2400 // Might be a text scaling operation, clear size caches.2401 d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = knownScrollbarWidth = null;2402 cm.setSize();2403 }, 100);2404 }2405 on(window, "resize", onResize);2406 // The above handler holds on to the editor and its data2407 // structures. Here we poll to unregister it when the editor is no2408 // longer in the document, so that it can be garbage-collected.2409 function unregister() {2410 if (contains(document.body, d.wrapper)) setTimeout(unregister, 5000);2411 else off(window, "resize", onResize);2412 }2413 setTimeout(unregister, 5000);2414 2403 2415 2404 on(d.input, "keyup", operation(cm, onKeyUp)); … … 2489 2478 } 2490 2479 2480 // Called when the window resizes 2481 function onResize(cm) { 2482 // Might be a text scaling operation, clear size caches. 2483 var d = cm.display; 2484 d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; 2485 cm.setSize(); 2486 } 2487 2491 2488 // MOUSE EVENTS 2492 2489 … … 2579 2576 } 2580 2577 2581 var sel = cm.doc.sel, addNew= mac ? e.metaKey : e.ctrlKey;2582 if (cm.options.dragDrop && dragAndDrop && ! addNew && !isReadOnly(cm) &&2578 var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey; 2579 if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) && 2583 2580 type == "single" && sel.contains(start) > -1 && sel.somethingSelected()) 2584 leftButtonStartDrag(cm, e, start );2581 leftButtonStartDrag(cm, e, start, modifier); 2585 2582 else 2586 leftButtonSelect(cm, e, start, type, addNew);2583 leftButtonSelect(cm, e, start, type, modifier); 2587 2584 } 2588 2585 2589 2586 // Start a text drag. When it ends, see if any dragging actually 2590 2587 // happen, and treat as a click if it didn't. 2591 function leftButtonStartDrag(cm, e, start ) {2588 function leftButtonStartDrag(cm, e, start, modifier) { 2592 2589 var display = cm.display; 2593 2590 var dragEnd = operation(cm, function(e2) { … … 2598 2595 if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) { 2599 2596 e_preventDefault(e2); 2600 extendSelection(cm.doc, start); 2597 if (!modifier) 2598 extendSelection(cm.doc, start); 2601 2599 focusInput(cm); 2602 2600 // Work around unexplainable focus problem in IE9 (#2127) … … 2636 2634 ourIndex = -1; 2637 2635 } else if (type == "double") { 2638 var word = findWordAt( doc, start);2636 var word = findWordAt(cm, start); 2639 2637 if (cm.display.shift || doc.extend) 2640 2638 ourRange = extendRange(doc, ourRange, word.anchor, word.head); … … 2682 2680 } 2683 2681 if (!ranges.length) ranges.push(new Range(start, start)); 2684 setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), sel_mouse); 2682 setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), 2683 {origin: "*mouse", scroll: false}); 2684 cm.scrollIntoView(pos); 2685 2685 } else { 2686 2686 var oldRange = ourRange; … … 2688 2688 if (type != "single") { 2689 2689 if (type == "double") 2690 var range = findWordAt( doc, pos);2690 var range = findWordAt(cm, pos); 2691 2691 else 2692 2692 var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0))); … … 2820 2820 var text = e.dataTransfer.getData("Text"); 2821 2821 if (text) { 2822 var selected = cm.state.draggingText && cm.listSelections(); 2822 if (cm.state.draggingText && !(mac ? e.metaKey : e.ctrlKey)) 2823 var selected = cm.listSelections(); 2823 2824 setSelectionNoUndo(cm.doc, simpleSelection(pos, pos)); 2824 2825 if (selected) for (var i = 0; i < selected.length; ++i) … … 3176 3177 display.prevInput = selected ? "" : "\u200b"; 3177 3178 display.input.selectionStart = 1; display.input.selectionEnd = extval.length; 3179 // Re-set this, in case some other handler touched the 3180 // selection in the meantime. 3181 display.selForContextMenu = cm.doc.sel; 3178 3182 } 3179 3183 } … … 3776 3780 else if (unit == "word" || unit == "group") { 3777 3781 var sawType = null, group = unit == "group"; 3782 var helper = doc.cm && doc.cm.getHelper(pos, "wordChars"); 3778 3783 for (var first = true;; first = false) { 3779 3784 if (dir < 0 && !moveOnce(!first)) break; 3780 3785 var cur = lineObj.text.charAt(ch) || "\n"; 3781 var type = isWordChar(cur ) ? "w"3786 var type = isWordChar(cur, helper) ? "w" 3782 3787 : group && cur == "\n" ? "n" 3783 3788 : !group || /\s/.test(cur) ? null … … 3819 3824 3820 3825 // Find the word at the given position (as returned by coordsChar). 3821 function findWordAt( doc, pos) {3822 var line = getLine(doc, pos.line).text;3826 function findWordAt(cm, pos) { 3827 var doc = cm.doc, line = getLine(doc, pos.line).text; 3823 3828 var start = pos.ch, end = pos.ch; 3824 3829 if (line) { 3830 var helper = cm.getHelper(pos, "wordChars"); 3825 3831 if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end; 3826 3832 var startChar = line.charAt(start); 3827 var check = isWordChar(startChar) ? isWordChar 3833 var check = isWordChar(startChar, helper) 3834 ? function(ch) { return isWordChar(ch, helper); } 3828 3835 : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);} 3829 3836 : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);}; … … 4630 4637 transposeChars: function(cm) { 4631 4638 runInOp(cm, function() { 4632 var ranges = cm.listSelections() ;4639 var ranges = cm.listSelections(), newSel = []; 4633 4640 for (var i = 0; i < ranges.length; i++) { 4634 4641 var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text; 4635 if (cur.ch > 0 && cur.ch < line.length - 1) 4636 cm.replaceRange(line.charAt(cur.ch) + line.charAt(cur.ch - 1), 4637 Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1)); 4642 if (line) { 4643 if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1); 4644 if (cur.ch > 0) { 4645 cur = new Pos(cur.line, cur.ch + 1); 4646 cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2), 4647 Pos(cur.line, cur.ch - 2), cur, "+transpose"); 4648 } else if (cur.line > cm.doc.first) { 4649 var prev = getLine(cm.doc, cur.line - 1).text; 4650 if (prev) 4651 cm.replaceRange(line.charAt(0) + "\n" + prev.charAt(prev.length - 1), 4652 Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose"); 4653 } 4654 } 4655 newSel.push(new Range(cur, cur)); 4638 4656 } 4657 cm.setSelections(newSel); 4639 4658 }); 4640 4659 }, … … 5596 5615 5597 5616 function readToken(mode, stream, state) { 5598 var style = mode.token(stream, state); 5599 if (stream.pos <= stream.start) 5600 throw new Error("Mode " + mode.name + " failed to advance stream."); 5601 return style; 5617 for (var i = 0; i < 10; i++) { 5618 var style = mode.token(stream, state); 5619 if (stream.pos > stream.start) return style; 5620 } 5621 throw new Error("Mode " + mode.name + " failed to advance stream."); 5602 5622 } 5603 5623 … … 5761 5781 5762 5782 signal(cm, "renderLine", cm, lineView.line, builder.pre); 5783 if (builder.pre.className) 5784 builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); 5763 5785 return builder; 5764 5786 } … … 7065 7087 7066 7088 var nonASCIISingleCaseWordChar = /[\u00df\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/; 7067 var isWordChar = CodeMirror.isWordChar = function(ch) {7089 var isWordCharBasic = CodeMirror.isWordChar = function(ch) { 7068 7090 return /\w/.test(ch) || ch > "\x80" && 7069 7091 (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)); 7070 7092 }; 7093 function isWordChar(ch, helper) { 7094 if (!helper) return isWordCharBasic(ch); 7095 if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true; 7096 return helper.test(ch); 7097 } 7071 7098 7072 7099 function isEmpty(obj) { … … 7148 7175 if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i]; 7149 7176 return b; 7177 } 7178 7179 // WINDOW-WIDE EVENTS 7180 7181 // These must be handled carefully, because naively registering a 7182 // handler for each editor will cause the editors to never be 7183 // garbage collected. 7184 7185 function forEachCodeMirror(f) { 7186 if (!document.body.getElementsByClassName) return; 7187 var byClass = document.body.getElementsByClassName("CodeMirror"); 7188 for (var i = 0; i < byClass.length; i++) { 7189 var cm = byClass[i].CodeMirror; 7190 if (cm) f(cm); 7191 } 7192 } 7193 7194 var globalsRegistered = false; 7195 function ensureGlobalHandlers() { 7196 if (globalsRegistered) return; 7197 registerGlobalHandlers(); 7198 globalsRegistered = true; 7199 } 7200 function registerGlobalHandlers() { 7201 // When the window resizes, we need to refresh active editors. 7202 var resizeTimer; 7203 on(window, "resize", function() { 7204 if (resizeTimer == null) resizeTimer = setTimeout(function() { 7205 resizeTimer = null; 7206 knownScrollbarWidth = null; 7207 forEachCodeMirror(onResize); 7208 }, 100); 7209 }); 7210 // When the window loses focus, we want to show the editor as blurred 7211 on(window, "blur", function() { 7212 forEachCodeMirror(onBlur); 7213 }); 7150 7214 } 7151 7215 … … 7532 7596 // THE END 7533 7597 7534 CodeMirror.version = "4. 1.1";7598 CodeMirror.version = "4.2.0"; 7535 7599 7536 7600 return CodeMirror; -
trunk/Source/WebInspectorUI/Tools/PrettyPrinting/css.js
r167781 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 (function(mod) { 2 5 if (typeof exports == "object" && typeof module == "object") // CommonJS … … 55 58 stream.eatWhile(/[\w.%]/); 56 59 return ret("number", "unit"); 57 } else if (stream.match(/^ [^-]+-/)) {60 } else if (stream.match(/^\w+-/)) { 58 61 return ret("meta", "meta"); 59 62 } … … 165 168 return "pseudo"; 166 169 } else if (allowNested && type == "(") { 167 return pushContext(state, stream, "par ams");170 return pushContext(state, stream, "parens"); 168 171 } 169 172 return state.context.type; … … 226 229 if (type == "{" || type == "}") return popAndPass(type, stream, state); 227 230 if (type == ")") return popContext(state); 231 if (type == "(") return pushContext(state, stream, "parens"); 232 if (type == "word") wordAsValue(stream); 228 233 return "parens"; 229 234 }; … … 301 306 }; 302 307 303 states.params = function(type, stream, state) {304 if (type == ")") return popContext(state);305 if (type == "{" || type == "}") return popAndPass(type, stream, state);306 if (type == "word") wordAsValue(stream);307 return "params";308 };309 310 308 return { 311 309 startState: function(base) { … … 330 328 var cx = state.context, ch = textAfter && textAfter.charAt(0); 331 329 var indent = cx.indent; 332 if (cx.type == "prop" && ch == "}") cx = cx.prev;330 if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev; 333 331 if (cx.prev && 334 332 (ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "font_face") || 335 ch == ")" && (cx.type == "parens" || cx.type == " params" || cx.type == "media_parens") ||333 ch == ")" && (cx.type == "parens" || cx.type == "media_parens") || 336 334 ch == "{" && (cx.type == "at" || cx.type == "media"))) { 337 335 indent = cx.indent - indentUnit; … … 423 421 "marquee-play-count", "marquee-speed", "marquee-style", "max-height", 424 422 "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index", 425 "nav-left", "nav-right", "nav-up", "opacity", "order", "orphans", "outline", 423 "nav-left", "nav-right", "nav-up", "object-fit", "object-position", 424 "opacity", "order", "orphans", "outline", 426 425 "outline-color", "outline-offset", "outline-style", "outline-width", 427 426 "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y", … … 434 433 "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness", 435 434 "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang", 436 "ruby-position", "ruby-span", "shape-i nside", "shape-outside", "size",437 "s peak", "speak-as", "speak-header",435 "ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shape-margin", 436 "shape-outside", "size", "speak", "speak-as", "speak-header", 438 437 "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set", 439 438 "tab-size", "table-layout", "target", "target-name", "target-new", -
trunk/Source/WebInspectorUI/Tools/PrettyPrinting/javascript.js
r167781 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 // TODO actually recognize syntax of TypeScript constructs 2 5 … … 646 649 }); 647 650 651 CodeMirror.registerHelper("wordChars", "javascript", /[\\w$]/); 652 648 653 CodeMirror.defineMIME("text/javascript", "javascript"); 649 654 CodeMirror.defineMIME("text/ecmascript", "javascript"); -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/clojure.js
r167294 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 /** 2 5 * Author: Hans Engel -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/closebrackets.js
r167294 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 (function(mod) { 2 5 if (typeof exports == "object" && typeof module == "object") // CommonJS -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/codemirror.js
r168170 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 // This is CodeMirror (http://codemirror.net), a code editor 2 5 // implemented in JavaScript on top of the browser's DOM. … … 94 97 95 98 registerEventHandlers(this); 99 ensureGlobalHandlers(); 96 100 97 101 var cm = this; … … 460 464 // height, and ensure (see op.scrollToPos) properties. 461 465 function visibleLines(display, doc, viewPort) { 462 var top = viewPort && viewPort.top != null ? viewPort.top: display.scroller.scrollTop;466 var top = viewPort && viewPort.top != null ? Math.max(0, viewPort.top) : display.scroller.scrollTop; 463 467 top = Math.floor(top - paddingTop(display)); 464 468 var bottom = viewPort && viewPort.bottom != null ? viewPort.bottom : top + display.wrapper.clientHeight; … … 476 480 to: ensureTo}; 477 481 } 478 return {from: from, to: to};482 return {from: from, to: Math.max(to, from + 1)}; 479 483 } 480 484 … … 663 667 cm.display.gutters.style.height = Math.max(measure.docHeight, measure.clientHeight - scrollerCutOff) + "px"; 664 668 } 665 666 669 667 670 function checkForWebkitWidthBug(cm, measure) { … … 1147 1150 sel = filterSelectionChange(doc, sel); 1148 1151 1149 var bias = cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1; 1152 var bias = options && options.bias || 1153 (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1); 1150 1154 setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true)); 1151 1155 … … 1927 1931 if (!updated && op.startHeight != cm.doc.height) updateScrollbars(cm); 1928 1932 1933 // Abort mouse wheel delta measurement, when scrolling explicitly 1934 if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos)) 1935 display.wheelStartX = display.wheelStartY = null; 1936 1929 1937 // Propagate the scroll position to the actual DOM scroller 1930 1938 if (op.scrollTop != null && display.scroller.scrollTop != op.scrollTop) { … … 2140 2148 function viewCuttingPoint(cm, oldN, newN, dir) { 2141 2149 var index = findViewIndex(cm, oldN), diff, view = cm.display.view; 2142 if (!sawCollapsedSpans) return {index: index, lineN: newN}; 2150 if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size) 2151 return {index: index, lineN: newN}; 2143 2152 for (var i = 0, n = cm.display.viewFrom; i < index; i++) 2144 2153 n += view[i].size; … … 2352 2361 if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return; 2353 2362 e_preventDefault(e); 2354 var word = findWordAt(cm .doc, pos);2363 var word = findWordAt(cm, pos); 2355 2364 extendSelection(cm.doc, word.anchor, word.head); 2356 2365 })); … … 2392 2401 // Prevent wrapper from ever scrolling 2393 2402 on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; }); 2394 2395 // When the window resizes, we need to refresh active editors.2396 var resizeTimer;2397 function onResize() {2398 if (resizeTimer == null) resizeTimer = setTimeout(function() {2399 resizeTimer = null;2400 // Might be a text scaling operation, clear size caches.2401 d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = knownScrollbarWidth = null;2402 cm.setSize();2403 }, 100);2404 }2405 on(window, "resize", onResize);2406 // The above handler holds on to the editor and its data2407 // structures. Here we poll to unregister it when the editor is no2408 // longer in the document, so that it can be garbage-collected.2409 function unregister() {2410 if (contains(document.body, d.wrapper)) setTimeout(unregister, 5000);2411 else off(window, "resize", onResize);2412 }2413 setTimeout(unregister, 5000);2414 2403 2415 2404 on(d.input, "keyup", operation(cm, onKeyUp)); … … 2489 2478 } 2490 2479 2480 // Called when the window resizes 2481 function onResize(cm) { 2482 // Might be a text scaling operation, clear size caches. 2483 var d = cm.display; 2484 d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; 2485 cm.setSize(); 2486 } 2487 2491 2488 // MOUSE EVENTS 2492 2489 … … 2579 2576 } 2580 2577 2581 var sel = cm.doc.sel, addNew= mac ? e.metaKey : e.ctrlKey;2582 if (cm.options.dragDrop && dragAndDrop && ! addNew && !isReadOnly(cm) &&2578 var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey; 2579 if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) && 2583 2580 type == "single" && sel.contains(start) > -1 && sel.somethingSelected()) 2584 leftButtonStartDrag(cm, e, start );2581 leftButtonStartDrag(cm, e, start, modifier); 2585 2582 else 2586 leftButtonSelect(cm, e, start, type, addNew);2583 leftButtonSelect(cm, e, start, type, modifier); 2587 2584 } 2588 2585 2589 2586 // Start a text drag. When it ends, see if any dragging actually 2590 2587 // happen, and treat as a click if it didn't. 2591 function leftButtonStartDrag(cm, e, start ) {2588 function leftButtonStartDrag(cm, e, start, modifier) { 2592 2589 var display = cm.display; 2593 2590 var dragEnd = operation(cm, function(e2) { … … 2598 2595 if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) { 2599 2596 e_preventDefault(e2); 2600 extendSelection(cm.doc, start); 2597 if (!modifier) 2598 extendSelection(cm.doc, start); 2601 2599 focusInput(cm); 2602 2600 // Work around unexplainable focus problem in IE9 (#2127) … … 2636 2634 ourIndex = -1; 2637 2635 } else if (type == "double") { 2638 var word = findWordAt( doc, start);2636 var word = findWordAt(cm, start); 2639 2637 if (cm.display.shift || doc.extend) 2640 2638 ourRange = extendRange(doc, ourRange, word.anchor, word.head); … … 2682 2680 } 2683 2681 if (!ranges.length) ranges.push(new Range(start, start)); 2684 setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), sel_mouse); 2682 setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), 2683 {origin: "*mouse", scroll: false}); 2684 cm.scrollIntoView(pos); 2685 2685 } else { 2686 2686 var oldRange = ourRange; … … 2688 2688 if (type != "single") { 2689 2689 if (type == "double") 2690 var range = findWordAt( doc, pos);2690 var range = findWordAt(cm, pos); 2691 2691 else 2692 2692 var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0))); … … 2820 2820 var text = e.dataTransfer.getData("Text"); 2821 2821 if (text) { 2822 var selected = cm.state.draggingText && cm.listSelections(); 2822 if (cm.state.draggingText && !(mac ? e.metaKey : e.ctrlKey)) 2823 var selected = cm.listSelections(); 2823 2824 setSelectionNoUndo(cm.doc, simpleSelection(pos, pos)); 2824 2825 if (selected) for (var i = 0; i < selected.length; ++i) … … 3176 3177 display.prevInput = selected ? "" : "\u200b"; 3177 3178 display.input.selectionStart = 1; display.input.selectionEnd = extval.length; 3179 // Re-set this, in case some other handler touched the 3180 // selection in the meantime. 3181 display.selForContextMenu = cm.doc.sel; 3178 3182 } 3179 3183 } … … 3776 3780 else if (unit == "word" || unit == "group") { 3777 3781 var sawType = null, group = unit == "group"; 3782 var helper = doc.cm && doc.cm.getHelper(pos, "wordChars"); 3778 3783 for (var first = true;; first = false) { 3779 3784 if (dir < 0 && !moveOnce(!first)) break; 3780 3785 var cur = lineObj.text.charAt(ch) || "\n"; 3781 var type = isWordChar(cur ) ? "w"3786 var type = isWordChar(cur, helper) ? "w" 3782 3787 : group && cur == "\n" ? "n" 3783 3788 : !group || /\s/.test(cur) ? null … … 3819 3824 3820 3825 // Find the word at the given position (as returned by coordsChar). 3821 function findWordAt( doc, pos) {3822 var line = getLine(doc, pos.line).text;3826 function findWordAt(cm, pos) { 3827 var doc = cm.doc, line = getLine(doc, pos.line).text; 3823 3828 var start = pos.ch, end = pos.ch; 3824 3829 if (line) { 3830 var helper = cm.getHelper(pos, "wordChars"); 3825 3831 if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end; 3826 3832 var startChar = line.charAt(start); 3827 var check = isWordChar(startChar) ? isWordChar 3833 var check = isWordChar(startChar, helper) 3834 ? function(ch) { return isWordChar(ch, helper); } 3828 3835 : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);} 3829 3836 : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);}; … … 4630 4637 transposeChars: function(cm) { 4631 4638 runInOp(cm, function() { 4632 var ranges = cm.listSelections() ;4639 var ranges = cm.listSelections(), newSel = []; 4633 4640 for (var i = 0; i < ranges.length; i++) { 4634 4641 var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text; 4635 if (cur.ch > 0 && cur.ch < line.length - 1) 4636 cm.replaceRange(line.charAt(cur.ch) + line.charAt(cur.ch - 1), 4637 Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1)); 4642 if (line) { 4643 if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1); 4644 if (cur.ch > 0) { 4645 cur = new Pos(cur.line, cur.ch + 1); 4646 cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2), 4647 Pos(cur.line, cur.ch - 2), cur, "+transpose"); 4648 } else if (cur.line > cm.doc.first) { 4649 var prev = getLine(cm.doc, cur.line - 1).text; 4650 if (prev) 4651 cm.replaceRange(line.charAt(0) + "\n" + prev.charAt(prev.length - 1), 4652 Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose"); 4653 } 4654 } 4655 newSel.push(new Range(cur, cur)); 4638 4656 } 4657 cm.setSelections(newSel); 4639 4658 }); 4640 4659 }, … … 5596 5615 5597 5616 function readToken(mode, stream, state) { 5598 var style = mode.token(stream, state); 5599 if (stream.pos <= stream.start) 5600 throw new Error("Mode " + mode.name + " failed to advance stream."); 5601 return style; 5617 for (var i = 0; i < 10; i++) { 5618 var style = mode.token(stream, state); 5619 if (stream.pos > stream.start) return style; 5620 } 5621 throw new Error("Mode " + mode.name + " failed to advance stream."); 5602 5622 } 5603 5623 … … 5761 5781 5762 5782 signal(cm, "renderLine", cm, lineView.line, builder.pre); 5783 if (builder.pre.className) 5784 builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); 5763 5785 return builder; 5764 5786 } … … 7065 7087 7066 7088 var nonASCIISingleCaseWordChar = /[\u00df\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/; 7067 var isWordChar = CodeMirror.isWordChar = function(ch) {7089 var isWordCharBasic = CodeMirror.isWordChar = function(ch) { 7068 7090 return /\w/.test(ch) || ch > "\x80" && 7069 7091 (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)); 7070 7092 }; 7093 function isWordChar(ch, helper) { 7094 if (!helper) return isWordCharBasic(ch); 7095 if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true; 7096 return helper.test(ch); 7097 } 7071 7098 7072 7099 function isEmpty(obj) { … … 7148 7175 if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i]; 7149 7176 return b; 7177 } 7178 7179 // WINDOW-WIDE EVENTS 7180 7181 // These must be handled carefully, because naively registering a 7182 // handler for each editor will cause the editors to never be 7183 // garbage collected. 7184 7185 function forEachCodeMirror(f) { 7186 if (!document.body.getElementsByClassName) return; 7187 var byClass = document.body.getElementsByClassName("CodeMirror"); 7188 for (var i = 0; i < byClass.length; i++) { 7189 var cm = byClass[i].CodeMirror; 7190 if (cm) f(cm); 7191 } 7192 } 7193 7194 var globalsRegistered = false; 7195 function ensureGlobalHandlers() { 7196 if (globalsRegistered) return; 7197 registerGlobalHandlers(); 7198 globalsRegistered = true; 7199 } 7200 function registerGlobalHandlers() { 7201 // When the window resizes, we need to refresh active editors. 7202 var resizeTimer; 7203 on(window, "resize", function() { 7204 if (resizeTimer == null) resizeTimer = setTimeout(function() { 7205 resizeTimer = null; 7206 knownScrollbarWidth = null; 7207 forEachCodeMirror(onResize); 7208 }, 100); 7209 }); 7210 // When the window loses focus, we want to show the editor as blurred 7211 on(window, "blur", function() { 7212 forEachCodeMirror(onBlur); 7213 }); 7150 7214 } 7151 7215 … … 7532 7596 // THE END 7533 7597 7534 CodeMirror.version = "4. 1.1";7598 CodeMirror.version = "4.2.0"; 7535 7599 7536 7600 return CodeMirror; -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/coffeescript.js
r167294 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 /** 2 5 * Link to the project's GitHub page: -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/comment.js
r167294 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 (function(mod) { 2 5 if (typeof exports == "object" && typeof module == "object") // CommonJS -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/css.js
r167781 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 (function(mod) { 2 5 if (typeof exports == "object" && typeof module == "object") // CommonJS … … 55 58 stream.eatWhile(/[\w.%]/); 56 59 return ret("number", "unit"); 57 } else if (stream.match(/^ [^-]+-/)) {60 } else if (stream.match(/^\w+-/)) { 58 61 return ret("meta", "meta"); 59 62 } … … 165 168 return "pseudo"; 166 169 } else if (allowNested && type == "(") { 167 return pushContext(state, stream, "par ams");170 return pushContext(state, stream, "parens"); 168 171 } 169 172 return state.context.type; … … 226 229 if (type == "{" || type == "}") return popAndPass(type, stream, state); 227 230 if (type == ")") return popContext(state); 231 if (type == "(") return pushContext(state, stream, "parens"); 232 if (type == "word") wordAsValue(stream); 228 233 return "parens"; 229 234 }; … … 301 306 }; 302 307 303 states.params = function(type, stream, state) {304 if (type == ")") return popContext(state);305 if (type == "{" || type == "}") return popAndPass(type, stream, state);306 if (type == "word") wordAsValue(stream);307 return "params";308 };309 310 308 return { 311 309 startState: function(base) { … … 330 328 var cx = state.context, ch = textAfter && textAfter.charAt(0); 331 329 var indent = cx.indent; 332 if (cx.type == "prop" && ch == "}") cx = cx.prev;330 if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev; 333 331 if (cx.prev && 334 332 (ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "font_face") || 335 ch == ")" && (cx.type == "parens" || cx.type == " params" || cx.type == "media_parens") ||333 ch == ")" && (cx.type == "parens" || cx.type == "media_parens") || 336 334 ch == "{" && (cx.type == "at" || cx.type == "media"))) { 337 335 indent = cx.indent - indentUnit; … … 423 421 "marquee-play-count", "marquee-speed", "marquee-style", "max-height", 424 422 "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index", 425 "nav-left", "nav-right", "nav-up", "opacity", "order", "orphans", "outline", 423 "nav-left", "nav-right", "nav-up", "object-fit", "object-position", 424 "opacity", "order", "orphans", "outline", 426 425 "outline-color", "outline-offset", "outline-style", "outline-width", 427 426 "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y", … … 434 433 "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness", 435 434 "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang", 436 "ruby-position", "ruby-span", "shape-i nside", "shape-outside", "size",437 "s peak", "speak-as", "speak-header",435 "ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shape-margin", 436 "shape-outside", "size", "speak", "speak-as", "speak-header", 438 437 "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set", 439 438 "tab-size", "table-layout", "target", "target-name", "target-new", -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/htmlmixed.js
r167294 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 (function(mod) { 2 5 if (typeof exports == "object" && typeof module == "object") // CommonJS -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/javascript.js
r167781 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 // TODO actually recognize syntax of TypeScript constructs 2 5 … … 646 649 }); 647 650 651 CodeMirror.registerHelper("wordChars", "javascript", /[\\w$]/); 652 648 653 CodeMirror.defineMIME("text/javascript", "javascript"); 649 654 CodeMirror.defineMIME("text/ecmascript", "javascript"); -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/livescript.js
r168170 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 /** 2 5 * Link to the project's GitHub page: -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/matchbrackets.js
r167294 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 (function(mod) { 2 5 if (typeof exports == "object" && typeof module == "object") // CommonJS -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/overlay.js
r167294 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 // Utility function that allows modes to be combined. The mode given 2 5 // as the base argument takes care of most of the normal mode … … 4 7 // can override the style of text. Both modes get to parse all of the 5 8 // text, but when both assign a non-null style to a piece of code, the 6 // overlay wins, unless the combine argument was true, in which case 7 // the styles are combined. 9 // overlay wins, unless the combine argument was true and not overridden, 10 // or state.overlay.combineTokens was true, in which case the styles are 11 // combined. 8 12 9 13 (function(mod) { … … 55 59 stream.pos = Math.min(state.basePos, state.overlayPos); 56 60 61 // state.overlay.combineTokens always takes precedence over combine, 62 // unless set to null 57 63 if (state.overlayCur == null) return state.baseCur; 58 if (state.baseCur != null && combine) return state.baseCur + " " + state.overlayCur; 64 else if (state.baseCur != null && 65 state.overlay.combineTokens || 66 combine && state.overlay.combineTokens == null) 67 return state.baseCur + " " + state.overlayCur; 59 68 else return state.overlayCur; 60 69 }, -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/placeholder.js
r167294 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 (function(mod) { 2 5 if (typeof exports == "object" && typeof module == "object") // CommonJS -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/runmode.js
r168170 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 (function(mod) { 2 5 if (typeof exports == "object" && typeof module == "object") // CommonJS -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/sass.js
r167294 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 (function(mod) { 2 5 if (typeof exports == "object" && typeof module == "object") // CommonJS -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/searchcursor.js
r167294 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 (function(mod) { 2 5 if (typeof exports == "object" && typeof module == "object") // CommonJS -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/sql.js
r167294 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 (function(mod) { 2 5 if (typeof exports == "object" && typeof module == "object") // CommonJS -
trunk/Source/WebInspectorUI/UserInterface/External/CodeMirror/xml.js
r167781 r170080 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 1 4 (function(mod) { 2 5 if (typeof exports == "object" && typeof module == "object") // CommonJS … … 122 125 state.tagName = state.tagStart = null; 123 126 var next = state.tokenize(stream, state); 124 return next ? next + " error" : "error";127 return next ? next + " tag error" : "tag error"; 125 128 } else if (/[\'\"]/.test(ch)) { 126 129 state.tokenize = inAttribute(ch);
Note:
See TracChangeset
for help on using the changeset viewer.