Changeset 170080 in webkit


Ignore:
Timestamp:
Jun 17, 2014, 3:35:07 PM (11 years ago)
Author:
jonowells@apple.com
Message:

Web Inspector: Two lines in CSS rule are hidden until resize or click
https://bugs.webkit.org/show_bug.cgi?id=133951

Reviewed by Joseph Pecoraro.

Update to CodeMirror 4.2 fixed the issue.

  • Tools/PrettyPrinting/codemirror.js:
  • Tools/PrettyPrinting/css.js:
  • Tools/PrettyPrinting/javascript.js:
  • UserInterface/External/CodeMirror/clojure.js:
  • UserInterface/External/CodeMirror/closebrackets.js:
  • UserInterface/External/CodeMirror/codemirror.js:
  • UserInterface/External/CodeMirror/coffeescript.js:
  • UserInterface/External/CodeMirror/comment.js:
  • UserInterface/External/CodeMirror/css.js:
  • UserInterface/External/CodeMirror/htmlmixed.js:
  • UserInterface/External/CodeMirror/javascript.js:
  • UserInterface/External/CodeMirror/livescript.js:
  • UserInterface/External/CodeMirror/matchbrackets.js:
  • UserInterface/External/CodeMirror/overlay.js:
  • UserInterface/External/CodeMirror/placeholder.js:
  • UserInterface/External/CodeMirror/runmode.js:
  • UserInterface/External/CodeMirror/sass.js:
  • UserInterface/External/CodeMirror/searchcursor.js:
  • UserInterface/External/CodeMirror/sql.js:
  • UserInterface/External/CodeMirror/xml.js:

Update CodeMirror 4.1 to CodeMirror 4.2.0.

Location:
trunk/Source/WebInspectorUI
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r170077 r170080  
     12014-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
    1322014-06-17  Jono Wells  <jonowells@apple.com>
    233
  • 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
    14// This is CodeMirror (http://codemirror.net), a code editor
    25// implemented in JavaScript on top of the browser's DOM.
     
    9497
    9598    registerEventHandlers(this);
     99    ensureGlobalHandlers();
    96100
    97101    var cm = this;
     
    460464  // height, and ensure (see op.scrollToPos) properties.
    461465  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;
    463467    top = Math.floor(top - paddingTop(display));
    464468    var bottom = viewPort && viewPort.bottom != null ? viewPort.bottom : top + display.wrapper.clientHeight;
     
    476480                to: ensureTo};
    477481    }
    478     return {from: from, to: to};
     482    return {from: from, to: Math.max(to, from + 1)};
    479483  }
    480484
     
    663667    cm.display.gutters.style.height = Math.max(measure.docHeight, measure.clientHeight - scrollerCutOff) + "px";
    664668  }
    665 
    666669
    667670  function checkForWebkitWidthBug(cm, measure) {
     
    11471150      sel = filterSelectionChange(doc, sel);
    11481151
    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);
    11501154    setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
    11511155
     
    19271931    if (!updated && op.startHeight != cm.doc.height) updateScrollbars(cm);
    19281932
     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
    19291937    // Propagate the scroll position to the actual DOM scroller
    19301938    if (op.scrollTop != null && display.scroller.scrollTop != op.scrollTop) {
     
    21402148  function viewCuttingPoint(cm, oldN, newN, dir) {
    21412149    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};
    21432152    for (var i = 0, n = cm.display.viewFrom; i < index; i++)
    21442153      n += view[i].size;
     
    23522361        if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;
    23532362        e_preventDefault(e);
    2354         var word = findWordAt(cm.doc, pos);
     2363        var word = findWordAt(cm, pos);
    23552364        extendSelection(cm.doc, word.anchor, word.head);
    23562365      }));
     
    23922401    // Prevent wrapper from ever scrolling
    23932402    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 data
    2407     // structures. Here we poll to unregister it when the editor is no
    2408     // 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);
    24142403
    24152404    on(d.input, "keyup", operation(cm, onKeyUp));
     
    24892478  }
    24902479
     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
    24912488  // MOUSE EVENTS
    24922489
     
    25792576    }
    25802577
    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) &&
    25832580        type == "single" && sel.contains(start) > -1 && sel.somethingSelected())
    2584       leftButtonStartDrag(cm, e, start);
     2581      leftButtonStartDrag(cm, e, start, modifier);
    25852582    else
    2586       leftButtonSelect(cm, e, start, type, addNew);
     2583      leftButtonSelect(cm, e, start, type, modifier);
    25872584  }
    25882585
    25892586  // Start a text drag. When it ends, see if any dragging actually
    25902587  // happen, and treat as a click if it didn't.
    2591   function leftButtonStartDrag(cm, e, start) {
     2588  function leftButtonStartDrag(cm, e, start, modifier) {
    25922589    var display = cm.display;
    25932590    var dragEnd = operation(cm, function(e2) {
     
    25982595      if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
    25992596        e_preventDefault(e2);
    2600         extendSelection(cm.doc, start);
     2597        if (!modifier)
     2598          extendSelection(cm.doc, start);
    26012599        focusInput(cm);
    26022600        // Work around unexplainable focus problem in IE9 (#2127)
     
    26362634      ourIndex = -1;
    26372635    } else if (type == "double") {
    2638       var word = findWordAt(doc, start);
     2636      var word = findWordAt(cm, start);
    26392637      if (cm.display.shift || doc.extend)
    26402638        ourRange = extendRange(doc, ourRange, word.anchor, word.head);
     
    26822680        }
    26832681        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);
    26852685      } else {
    26862686        var oldRange = ourRange;
     
    26882688        if (type != "single") {
    26892689          if (type == "double")
    2690             var range = findWordAt(doc, pos);
     2690            var range = findWordAt(cm, pos);
    26912691          else
    26922692            var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0)));
     
    28202820        var text = e.dataTransfer.getData("Text");
    28212821        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();
    28232824          setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
    28242825          if (selected) for (var i = 0; i < selected.length; ++i)
     
    31763177        display.prevInput = selected ? "" : "\u200b";
    31773178        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;
    31783182      }
    31793183    }
     
    37763780    else if (unit == "word" || unit == "group") {
    37773781      var sawType = null, group = unit == "group";
     3782      var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
    37783783      for (var first = true;; first = false) {
    37793784        if (dir < 0 && !moveOnce(!first)) break;
    37803785        var cur = lineObj.text.charAt(ch) || "\n";
    3781         var type = isWordChar(cur) ? "w"
     3786        var type = isWordChar(cur, helper) ? "w"
    37823787          : group && cur == "\n" ? "n"
    37833788          : !group || /\s/.test(cur) ? null
     
    38193824
    38203825  // 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;
    38233828    var start = pos.ch, end = pos.ch;
    38243829    if (line) {
     3830      var helper = cm.getHelper(pos, "wordChars");
    38253831      if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end;
    38263832      var startChar = line.charAt(start);
    3827       var check = isWordChar(startChar) ? isWordChar
     3833      var check = isWordChar(startChar, helper)
     3834        ? function(ch) { return isWordChar(ch, helper); }
    38283835        : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);}
    38293836        : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
     
    46304637    transposeChars: function(cm) {
    46314638      runInOp(cm, function() {
    4632         var ranges = cm.listSelections();
     4639        var ranges = cm.listSelections(), newSel = [];
    46334640        for (var i = 0; i < ranges.length; i++) {
    46344641          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));
    46384656        }
     4657        cm.setSelections(newSel);
    46394658      });
    46404659    },
     
    55965615
    55975616  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.");
    56025622  }
    56035623
     
    57615781
    57625782    signal(cm, "renderLine", cm, lineView.line, builder.pre);
     5783    if (builder.pre.className)
     5784      builder.textClass = joinClasses(builder.pre.className, builder.textClass || "");
    57635785    return builder;
    57645786  }
     
    70657087
    70667088  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) {
    70687090    return /\w/.test(ch) || ch > "\x80" &&
    70697091      (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
    70707092  };
     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  }
    70717098
    70727099  function isEmpty(obj) {
     
    71487175      if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i];
    71497176    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    });
    71507214  }
    71517215
     
    75327596  // THE END
    75337597
    7534   CodeMirror.version = "4.1.1";
     7598  CodeMirror.version = "4.2.0";
    75357599
    75367600  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
    14(function(mod) {
    25  if (typeof exports == "object" && typeof module == "object") // CommonJS
     
    5558        stream.eatWhile(/[\w.%]/);
    5659        return ret("number", "unit");
    57       } else if (stream.match(/^[^-]+-/)) {
     60      } else if (stream.match(/^\w+-/)) {
    5861        return ret("meta", "meta");
    5962      }
     
    165168      return "pseudo";
    166169    } else if (allowNested && type == "(") {
    167       return pushContext(state, stream, "params");
     170      return pushContext(state, stream, "parens");
    168171    }
    169172    return state.context.type;
     
    226229    if (type == "{" || type == "}") return popAndPass(type, stream, state);
    227230    if (type == ")") return popContext(state);
     231    if (type == "(") return pushContext(state, stream, "parens");
     232    if (type == "word") wordAsValue(stream);
    228233    return "parens";
    229234  };
     
    301306  };
    302307
    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 
    310308  return {
    311309    startState: function(base) {
     
    330328      var cx = state.context, ch = textAfter && textAfter.charAt(0);
    331329      var indent = cx.indent;
    332       if (cx.type == "prop" && ch == "}") cx = cx.prev;
     330      if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
    333331      if (cx.prev &&
    334332          (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") ||
    336334           ch == "{" && (cx.type == "at" || cx.type == "media"))) {
    337335        indent = cx.indent - indentUnit;
     
    423421    "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
    424422    "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",
    426425    "outline-color", "outline-offset", "outline-style", "outline-width",
    427426    "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
     
    434433    "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
    435434    "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
    436     "ruby-position", "ruby-span", "shape-inside", "shape-outside", "size",
    437     "speak", "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",
    438437    "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
    439438    "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
    14// TODO actually recognize syntax of TypeScript constructs
    25
     
    646649});
    647650
     651CodeMirror.registerHelper("wordChars", "javascript", /[\\w$]/);
     652
    648653CodeMirror.defineMIME("text/javascript", "javascript");
    649654CodeMirror.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
    14/**
    25 * 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
    14(function(mod) {
    25  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
    14// This is CodeMirror (http://codemirror.net), a code editor
    25// implemented in JavaScript on top of the browser's DOM.
     
    9497
    9598    registerEventHandlers(this);
     99    ensureGlobalHandlers();
    96100
    97101    var cm = this;
     
    460464  // height, and ensure (see op.scrollToPos) properties.
    461465  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;
    463467    top = Math.floor(top - paddingTop(display));
    464468    var bottom = viewPort && viewPort.bottom != null ? viewPort.bottom : top + display.wrapper.clientHeight;
     
    476480                to: ensureTo};
    477481    }
    478     return {from: from, to: to};
     482    return {from: from, to: Math.max(to, from + 1)};
    479483  }
    480484
     
    663667    cm.display.gutters.style.height = Math.max(measure.docHeight, measure.clientHeight - scrollerCutOff) + "px";
    664668  }
    665 
    666669
    667670  function checkForWebkitWidthBug(cm, measure) {
     
    11471150      sel = filterSelectionChange(doc, sel);
    11481151
    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);
    11501154    setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
    11511155
     
    19271931    if (!updated && op.startHeight != cm.doc.height) updateScrollbars(cm);
    19281932
     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
    19291937    // Propagate the scroll position to the actual DOM scroller
    19301938    if (op.scrollTop != null && display.scroller.scrollTop != op.scrollTop) {
     
    21402148  function viewCuttingPoint(cm, oldN, newN, dir) {
    21412149    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};
    21432152    for (var i = 0, n = cm.display.viewFrom; i < index; i++)
    21442153      n += view[i].size;
     
    23522361        if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;
    23532362        e_preventDefault(e);
    2354         var word = findWordAt(cm.doc, pos);
     2363        var word = findWordAt(cm, pos);
    23552364        extendSelection(cm.doc, word.anchor, word.head);
    23562365      }));
     
    23922401    // Prevent wrapper from ever scrolling
    23932402    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 data
    2407     // structures. Here we poll to unregister it when the editor is no
    2408     // 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);
    24142403
    24152404    on(d.input, "keyup", operation(cm, onKeyUp));
     
    24892478  }
    24902479
     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
    24912488  // MOUSE EVENTS
    24922489
     
    25792576    }
    25802577
    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) &&
    25832580        type == "single" && sel.contains(start) > -1 && sel.somethingSelected())
    2584       leftButtonStartDrag(cm, e, start);
     2581      leftButtonStartDrag(cm, e, start, modifier);
    25852582    else
    2586       leftButtonSelect(cm, e, start, type, addNew);
     2583      leftButtonSelect(cm, e, start, type, modifier);
    25872584  }
    25882585
    25892586  // Start a text drag. When it ends, see if any dragging actually
    25902587  // happen, and treat as a click if it didn't.
    2591   function leftButtonStartDrag(cm, e, start) {
     2588  function leftButtonStartDrag(cm, e, start, modifier) {
    25922589    var display = cm.display;
    25932590    var dragEnd = operation(cm, function(e2) {
     
    25982595      if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
    25992596        e_preventDefault(e2);
    2600         extendSelection(cm.doc, start);
     2597        if (!modifier)
     2598          extendSelection(cm.doc, start);
    26012599        focusInput(cm);
    26022600        // Work around unexplainable focus problem in IE9 (#2127)
     
    26362634      ourIndex = -1;
    26372635    } else if (type == "double") {
    2638       var word = findWordAt(doc, start);
     2636      var word = findWordAt(cm, start);
    26392637      if (cm.display.shift || doc.extend)
    26402638        ourRange = extendRange(doc, ourRange, word.anchor, word.head);
     
    26822680        }
    26832681        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);
    26852685      } else {
    26862686        var oldRange = ourRange;
     
    26882688        if (type != "single") {
    26892689          if (type == "double")
    2690             var range = findWordAt(doc, pos);
     2690            var range = findWordAt(cm, pos);
    26912691          else
    26922692            var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0)));
     
    28202820        var text = e.dataTransfer.getData("Text");
    28212821        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();
    28232824          setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
    28242825          if (selected) for (var i = 0; i < selected.length; ++i)
     
    31763177        display.prevInput = selected ? "" : "\u200b";
    31773178        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;
    31783182      }
    31793183    }
     
    37763780    else if (unit == "word" || unit == "group") {
    37773781      var sawType = null, group = unit == "group";
     3782      var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
    37783783      for (var first = true;; first = false) {
    37793784        if (dir < 0 && !moveOnce(!first)) break;
    37803785        var cur = lineObj.text.charAt(ch) || "\n";
    3781         var type = isWordChar(cur) ? "w"
     3786        var type = isWordChar(cur, helper) ? "w"
    37823787          : group && cur == "\n" ? "n"
    37833788          : !group || /\s/.test(cur) ? null
     
    38193824
    38203825  // 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;
    38233828    var start = pos.ch, end = pos.ch;
    38243829    if (line) {
     3830      var helper = cm.getHelper(pos, "wordChars");
    38253831      if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end;
    38263832      var startChar = line.charAt(start);
    3827       var check = isWordChar(startChar) ? isWordChar
     3833      var check = isWordChar(startChar, helper)
     3834        ? function(ch) { return isWordChar(ch, helper); }
    38283835        : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);}
    38293836        : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
     
    46304637    transposeChars: function(cm) {
    46314638      runInOp(cm, function() {
    4632         var ranges = cm.listSelections();
     4639        var ranges = cm.listSelections(), newSel = [];
    46334640        for (var i = 0; i < ranges.length; i++) {
    46344641          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));
    46384656        }
     4657        cm.setSelections(newSel);
    46394658      });
    46404659    },
     
    55965615
    55975616  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.");
    56025622  }
    56035623
     
    57615781
    57625782    signal(cm, "renderLine", cm, lineView.line, builder.pre);
     5783    if (builder.pre.className)
     5784      builder.textClass = joinClasses(builder.pre.className, builder.textClass || "");
    57635785    return builder;
    57645786  }
     
    70657087
    70667088  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) {
    70687090    return /\w/.test(ch) || ch > "\x80" &&
    70697091      (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
    70707092  };
     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  }
    70717098
    70727099  function isEmpty(obj) {
     
    71487175      if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i];
    71497176    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    });
    71507214  }
    71517215
     
    75327596  // THE END
    75337597
    7534   CodeMirror.version = "4.1.1";
     7598  CodeMirror.version = "4.2.0";
    75357599
    75367600  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
    14/**
    25 * 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
    14(function(mod) {
    25  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
    14(function(mod) {
    25  if (typeof exports == "object" && typeof module == "object") // CommonJS
     
    5558        stream.eatWhile(/[\w.%]/);
    5659        return ret("number", "unit");
    57       } else if (stream.match(/^[^-]+-/)) {
     60      } else if (stream.match(/^\w+-/)) {
    5861        return ret("meta", "meta");
    5962      }
     
    165168      return "pseudo";
    166169    } else if (allowNested && type == "(") {
    167       return pushContext(state, stream, "params");
     170      return pushContext(state, stream, "parens");
    168171    }
    169172    return state.context.type;
     
    226229    if (type == "{" || type == "}") return popAndPass(type, stream, state);
    227230    if (type == ")") return popContext(state);
     231    if (type == "(") return pushContext(state, stream, "parens");
     232    if (type == "word") wordAsValue(stream);
    228233    return "parens";
    229234  };
     
    301306  };
    302307
    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 
    310308  return {
    311309    startState: function(base) {
     
    330328      var cx = state.context, ch = textAfter && textAfter.charAt(0);
    331329      var indent = cx.indent;
    332       if (cx.type == "prop" && ch == "}") cx = cx.prev;
     330      if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
    333331      if (cx.prev &&
    334332          (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") ||
    336334           ch == "{" && (cx.type == "at" || cx.type == "media"))) {
    337335        indent = cx.indent - indentUnit;
     
    423421    "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
    424422    "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",
    426425    "outline-color", "outline-offset", "outline-style", "outline-width",
    427426    "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
     
    434433    "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
    435434    "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
    436     "ruby-position", "ruby-span", "shape-inside", "shape-outside", "size",
    437     "speak", "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",
    438437    "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
    439438    "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
    14(function(mod) {
    25  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
    14// TODO actually recognize syntax of TypeScript constructs
    25
     
    646649});
    647650
     651CodeMirror.registerHelper("wordChars", "javascript", /[\\w$]/);
     652
    648653CodeMirror.defineMIME("text/javascript", "javascript");
    649654CodeMirror.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
    14/**
    25 * 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
    14(function(mod) {
    25  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
    14// Utility function that allows modes to be combined. The mode given
    25// as the base argument takes care of most of the normal mode
     
    47// can override the style of text. Both modes get to parse all of the
    58// 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.
    812
    913(function(mod) {
     
    5559      stream.pos = Math.min(state.basePos, state.overlayPos);
    5660
     61      // state.overlay.combineTokens always takes precedence over combine,
     62      // unless set to null
    5763      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;
    5968      else return state.overlayCur;
    6069    },
  • 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
    14(function(mod) {
    25  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
    14(function(mod) {
    25  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
    14(function(mod) {
    25  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
    14(function(mod) {
    25  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
    14(function(mod) {
    25  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
    14(function(mod) {
    25  if (typeof exports == "object" && typeof module == "object") // CommonJS
     
    122125      state.tagName = state.tagStart = null;
    123126      var next = state.tokenize(stream, state);
    124       return next ? next + " error" : "error";
     127      return next ? next + " tag error" : "tag error";
    125128    } else if (/[\'\"]/.test(ch)) {
    126129      state.tokenize = inAttribute(ch);
Note: See TracChangeset for help on using the changeset viewer.