<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[193331] branches/safari-601-branch/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/193331">193331</a></dd>
<dt>Author</dt> <dd>timothy@apple.com</dd>
<dt>Date</dt> <dd>2015-12-03 11:11:38 -0800 (Thu, 03 Dec 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/192662">r192662</a>. rdar://problem/23221163</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari601branchSourceWebCoreChangeLog">branches/safari-601-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceWebCoreinspectorInspectorFrontendHostcpp">branches/safari-601-branch/Source/WebCore/inspector/InspectorFrontendHost.cpp</a></li>
<li><a href="#branchessafari601branchSourceWebCoreinspectorInspectorFrontendHosth">branches/safari-601-branch/Source/WebCore/inspector/InspectorFrontendHost.h</a></li>
<li><a href="#branchessafari601branchSourceWebCoreinspectorInspectorFrontendHostidl">branches/safari-601-branch/Source/WebCore/inspector/InspectorFrontendHost.idl</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIChangeLog">branches/safari-601-branch/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceControllersBreakpointPopoverControllerjs">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/BreakpointPopoverController.js</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceMainhtml">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Main.html</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceProtocolInspectorFrontendHostStubjs">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendHostStub.js</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceViewsBreakpointActionViewjs">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/BreakpointActionView.js</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceViewsCSSStyleDeclarationTextEditorjs">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceViewsConsolePromptjs">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceViewsScopeChainDetailsSidebarPaneljs">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceViewsTextEditorjs">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/TextEditor.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceControllersCodeMirrorTextKillControllerjs">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTextKillController.js</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceViewsCodeMirrorEditorjs">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CodeMirrorEditor.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari601branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/ChangeLog (193330 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/ChangeLog        2015-12-03 19:11:28 UTC (rev 193330)
+++ branches/safari-601-branch/Source/WebCore/ChangeLog        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -1,5 +1,41 @@
</span><span class="cx"> 2015-12-03 Timothy Hatcher <timothy@apple.com>
</span><span class="cx">
</span><ins>+ Merge r192662. rdar://problem/23221163
+
+ 2015-11-19 Brian Burg <bburg@apple.com>
+
+ Web Inspector: yank/kill shortcuts (CTRL+Y, K) don't work in Console / QuickConsole
+ https://bugs.webkit.org/show_bug.cgi?id=151157
+
+ Reviewed by Joseph Pecoraro.
+
+ CodeMirror maintains its own editor buffer and implements its own
+ `killLine` command but doesn't implement the yank command. So, text
+ that is "killed" with CTRL-k inside a CodeMirror instance isn't
+ added to Editor's kill ring. Subsequent yank commands won't match
+ up with the killed text, instead returning text from a prior kill
+ that was handled by Editor (i.e., in a contenteditable or form input).
+
+ This patch adds a host function so that the Inspector frontend can
+ append "missed" killed text to Editor's kill ring. Subsequent
+ yanks handled by Editor will then match the text killed by CodeMirror.
+
+ No new tests, because we need to use both InspectorFrontendHost
+ and TestRunner.execCommand, but the latter is not available in
+ the inspector context where we would need to simulate a kill.
+
+ * inspector/InspectorFrontendHost.cpp:
+ (WebCore::InspectorFrontendHost::killText):
+
+ Added. This appends the killed text to the kill ring, starting
+ a new sequence if necessary. Unlike Editor, Inspector waits
+ until the next kill command to clear the existing sequence.
+
+ * inspector/InspectorFrontendHost.h:
+ * inspector/InspectorFrontendHost.idl:
+
+2015-12-03 Timothy Hatcher <timothy@apple.com>
+
</ins><span class="cx"> Merge r192641. rdar://problem/23221163
</span><span class="cx">
</span><span class="cx"> 2015-11-19 Brian Burg <bburg@apple.com>
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCoreinspectorInspectorFrontendHostcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/inspector/InspectorFrontendHost.cpp (193330 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/inspector/InspectorFrontendHost.cpp        2015-12-03 19:11:28 UTC (rev 193330)
+++ branches/safari-601-branch/Source/WebCore/inspector/InspectorFrontendHost.cpp        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -36,7 +36,9 @@
</span><span class="cx"> #include "ContextMenuProvider.h"
</span><span class="cx"> #include "DOMWrapperWorld.h"
</span><span class="cx"> #include "Document.h"
</span><ins>+#include "Editor.h"
</ins><span class="cx"> #include "Event.h"
</span><ins>+#include "FocusController.h"
</ins><span class="cx"> #include "HitTestResult.h"
</span><span class="cx"> #include "InspectorFrontendClient.h"
</span><span class="cx"> #include "JSMainThreadExecState.h"
</span><span class="lines">@@ -182,12 +184,16 @@
</span><span class="cx">
</span><span class="cx"> void InspectorFrontendHost::setZoomFactor(float zoom)
</span><span class="cx"> {
</span><del>- m_frontendPage->mainFrame().setPageAndTextZoomFactors(zoom, 1);
</del><ins>+ if (m_frontendPage)
+ m_frontendPage->mainFrame().setPageAndTextZoomFactors(zoom, 1);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> float InspectorFrontendHost::zoomFactor()
</span><span class="cx"> {
</span><del>- return m_frontendPage->mainFrame().pageZoomFactor();
</del><ins>+ if (m_frontendPage)
+ return m_frontendPage->mainFrame().pageZoomFactor();
+
+ return 1.0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void InspectorFrontendHost::setAttachedWindowHeight(unsigned height)
</span><span class="lines">@@ -235,6 +241,17 @@
</span><span class="cx"> Pasteboard::createForCopyAndPaste()->writePlainText(text, Pasteboard::CannotSmartReplace);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void InspectorFrontendHost::killText(const String& text, bool shouldPrependToKillRing, bool shouldStartNewSequence)
+{
+ if (!m_frontendPage)
+ return;
+
+ Editor& editor = m_frontendPage->focusController().focusedOrMainFrame().editor();
+ editor.setStartNewKillRingSequence(shouldStartNewSequence);
+ Editor::KillRingInsertionMode insertionMode = shouldPrependToKillRing ? Editor::KillRingInsertionMode::PrependText : Editor::KillRingInsertionMode::AppendText;
+ editor.addTextToKillRing(text, insertionMode);
+}
+
</ins><span class="cx"> void InspectorFrontendHost::openInNewTab(const String& url)
</span><span class="cx"> {
</span><span class="cx"> if (m_client)
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCoreinspectorInspectorFrontendHosth"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/inspector/InspectorFrontendHost.h (193330 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/inspector/InspectorFrontendHost.h        2015-12-03 19:11:28 UTC (rev 193330)
+++ branches/safari-601-branch/Source/WebCore/inspector/InspectorFrontendHost.h        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -73,6 +73,7 @@
</span><span class="cx"> String debuggableType();
</span><span class="cx">
</span><span class="cx"> void copyText(const String& text);
</span><ins>+ void killText(const String& text, bool shouldPrependToKillRing, bool shouldStartNewSequence);
</ins><span class="cx"> void openInNewTab(const String& url);
</span><span class="cx"> bool canSave();
</span><span class="cx"> void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs);
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCoreinspectorInspectorFrontendHostidl"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/inspector/InspectorFrontendHost.idl (193330 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/inspector/InspectorFrontendHost.idl        2015-12-03 19:11:28 UTC (rev 193330)
+++ branches/safari-601-branch/Source/WebCore/inspector/InspectorFrontendHost.idl        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> DOMString debuggableType();
</span><span class="cx">
</span><span class="cx"> void copyText(DOMString text);
</span><ins>+ void killText(DOMString text, boolean shouldPrependToKillRing, boolean shouldStartNewSequence);
</ins><span class="cx"> void openInNewTab(DOMString url);
</span><span class="cx"> boolean canSave();
</span><span class="cx"> void save(DOMString url, DOMString content, boolean base64Encoded, boolean forceSaveAs);
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/ChangeLog (193330 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/ChangeLog        2015-12-03 19:11:28 UTC (rev 193330)
+++ branches/safari-601-branch/Source/WebInspectorUI/ChangeLog        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -1,5 +1,67 @@
</span><span class="cx"> 2015-12-03 Timothy Hatcher <timothy@apple.com>
</span><span class="cx">
</span><ins>+ Merge r192662. rdar://problem/23221163
+
+ 2015-11-19 Brian Burg <bburg@apple.com>
+
+ Web Inspector: yank/kill shortcuts (CTRL+Y, K) don't work in Console / QuickConsole
+ https://bugs.webkit.org/show_bug.cgi?id=151157
+
+ Reviewed by Joseph Pecoraro.
+
+ CodeMirror maintains its own editor buffer and implements its own
+ `killLine` command but doesn't implement the yank command. So, text
+ that is "killed" with CTRL-k inside a CodeMirror instance isn't
+ added to WebCore's kill ring. Subsequent yank commands won't match
+ up with the killed text, instead returning text from a prior kill
+ that was handled by WebCore (i.e., in a contenteditable or form input).
+
+ This patch adds a host function so that the Inspector frontend can
+ append "missed" killed text to WebCore's kill ring. Subsequent
+ yanks handled by WebCore will then match the text killed by CodeMirror.
+
+ In the frontend, we implement our own key binding handler for
+ CTRL-k that captures killed text, detects whether the kill
+ should start a new sequence, and sends it to WebCore. Because this
+ involves several flags and listeners, and we want this behavior for
+ all editable CodeMirror instances, the text kill handling is
+ factored into its own CodeMirrorTextKillController.
+
+ To add this behavior to all instances, this patch centralizes the
+ code that constructs a base CodeMirror instance, and attaches the
+ CodeMirrorTextKillController to all instances. The shortcut
+ does nothing when its CodeMirror instance is read-only.
+
+ The particulars of the kill controller are documented inline.
+
+ No new tests, because we need to use both InspectorFrontendHost
+ and TestRunner.execCommand, but the latter is not available in
+ the inspector context where we would need to simulate a kill.
+
+ * UserInterface/Controllers/CodeMirrorTextKillController.js: Added.
+ (WebInspector.CodeMirrorTextKillController):
+ (WebInspector.CodeMirrorTextKillController.prototype._handleKillLine):
+ (WebInspector.CodeMirrorTextKillController.prototype._handleTextChange):
+ (WebInspector.CodeMirrorTextKillController.prototype._handleEditorBlur):
+ (WebInspector.CodeMirrorTextKillController.prototype._handleSelectionOrCaretChange):
+ * UserInterface/Main.html:
+ * UserInterface/Protocol/InspectorFrontendHostStub.js:
+ (window.InspectorFrontendHost.WebInspector.InspectorFrontendHostStub.prototype.killText): Add a stub to avoid check-before-use.
+ * UserInterface/Views/BreakpointActionView.js:
+ (WebInspector.BreakpointActionView.prototype._updateBody):
+ * UserInterface/Views/CSSStyleDeclarationTextEditor.js:
+ (WebInspector.CSSStyleDeclarationTextEditor):
+ * UserInterface/Views/CodeMirrorEditor.js: Added.
+ (WebInspector.CodeMirrorEditor.create):
+ (WebInspector.CodeMirrorEditor):
+ * UserInterface/Views/ConsolePrompt.js:
+ (WebInspector.ConsolePrompt):
+ * UserInterface/Views/ScopeChainDetailsSidebarPanel.js:
+ * UserInterface/Views/TextEditor.js:
+ (WebInspector.TextEditor):
+
+2015-12-03 Timothy Hatcher <timothy@apple.com>
+
</ins><span class="cx"> Merge r192616. rdar://problem/23221163
</span><span class="cx">
</span><span class="cx"> 2015-11-19 Matt Baker <mattbaker@apple.com>
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceControllersBreakpointPopoverControllerjs"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/BreakpointPopoverController.js (193330 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/BreakpointPopoverController.js        2015-12-03 19:11:28 UTC (rev 193330)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/BreakpointPopoverController.js        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -139,7 +139,7 @@
</span><span class="cx"> var conditionEditorElement = conditionData.appendChild(document.createElement("div"));
</span><span class="cx"> conditionEditorElement.classList.add("edit-breakpoint-popover-condition", WebInspector.SyntaxHighlightedStyleClassName);
</span><span class="cx">
</span><del>- this._conditionCodeMirror = CodeMirror(conditionEditorElement, {
</del><ins>+ this._conditionCodeMirror = WebInspector.CodeMirrorEditor.create(conditionEditorElement, {
</ins><span class="cx"> extraKeys: {Tab: false},
</span><span class="cx"> lineWrapping: false,
</span><span class="cx"> mode: "text/javascript",
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceControllersCodeMirrorTextKillControllerjs"></a>
<div class="addfile"><h4>Added: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTextKillController.js (0 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTextKillController.js         (rev 0)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTextKillController.js        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -0,0 +1,121 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.CodeMirrorTextKillController = class CodeMirrorTextKillController extends WebInspector.Object
+{
+ constructor(codeMirror)
+ {
+ super();
+
+ console.assert(codeMirror);
+
+ this._codeMirror = codeMirror;
+ this._expectingChangeEventForKill = false;
+ this._nextKillStartsNewSequence = true;
+
+ this._handleTextChangeListener = this._handleTextChange.bind(this);
+ this._handleEditorBlurListener = this._handleEditorBlur.bind(this);
+ this._handleSelectionOrCaretChangeListener = this._handleSelectionOrCaretChange.bind(this);
+
+ this._codeMirror.addKeyMap({
+ "Ctrl-K": this._handleKillLine.bind(this),
+ });
+ }
+
+ _handleKillLine(codeMirror)
+ {
+ // Read-only mode is dynamic in some editors, so check every time
+ // and ignore the shortcut if in read-only mode.
+ if (this._codeMirror.getOption("readOnly"))
+ return;
+
+ // Don't add the listener if it's still registered because
+ // a previous empty kill didn't generate change events.
+ if (!this._expectingChangeEventForKill)
+ codeMirror.on("changes", this._handleTextChangeListener);
+
+ this._expectingChangeEventForKill = true;
+ codeMirror.execCommand("killLine");
+ }
+
+ _handleTextChange(codeMirror, changes)
+ {
+ this._codeMirror.off("changes", this._handleTextChangeListener);
+
+ // Sometimes a second change event fires after removing the listener
+ // if you perform an "empty kill" and type after moving the caret.
+ if (!this._expectingChangeEventForKill)
+ return;
+
+ this._expectingChangeEventForKill = false;
+
+ // It doesn't make sense to get more than one change per kill.
+ console.assert(changes.length === 1);
+ var change = changes[0];
+
+ // If an "empty kill" is followed by up/down or typing,
+ // the empty kill won't fire a change event, then we'll get an
+ // unrelated change event that shouldn't be treated as a kill.
+ if (change.origin !== "+delete")
+ return;
+
+ // Killing a newline by itself is reported as deletion of two
+ // empty strings, so check the change's ranges to detect this.
+ var killedText;
+ if (change.to.line === change.from.line + 1)
+ killedText = "\n";
+ else {
+ console.assert(change.removed.length === 1);
+ killedText = change.removed[0];
+ }
+
+ var shouldPrependToKillRing = false;
+ InspectorFrontendHost.killText(killedText, shouldPrependToKillRing, this._nextKillStartsNewSequence);
+
+ // If the editor loses focus or the caret / selection changes
+ // (not as a result of the kill), then the next kill should
+ // start a new kill ring sequence.
+ this._nextKillStartsNewSequence = false;
+ this._codeMirror.on("blur", this._handleEditorBlurListener);
+ this._codeMirror.on("cursorActivity", this._handleSelectionOrCaretChangeListener);
+ }
+
+ _handleEditorBlur(codeMirror)
+ {
+ this._nextKillStartsNewSequence = true;
+ this._codeMirror.off("blur", this._handleEditorBlurListener);
+ this._codeMirror.off("cursorActivity", this._handleSelectionOrCaretChangeListener);
+ }
+
+ _handleSelectionOrCaretChange(codeMirror)
+ {
+ if (this._expectingChangeEventForKill)
+ return;
+
+ this._nextKillStartsNewSequence = true;
+ this._codeMirror.off("blur", this._handleEditorBlurListener);
+ this._codeMirror.off("cursorActivity", this._handleSelectionOrCaretChangeListener);
+ }
+};
</ins></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceMainhtml"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Main.html (193330 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Main.html        2015-12-03 19:11:28 UTC (rev 193330)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Main.html        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -414,6 +414,7 @@
</span><span class="cx"> <script src="Views/ChartDetailsSectionRow.js"></script>
</span><span class="cx"> <script src="Views/ClusterContentView.js"></script>
</span><span class="cx"> <script src="Views/CodeMirrorAdditions.js"></script>
</span><ins>+ <script src="Views/CodeMirrorEditor.js"></script>
</ins><span class="cx"> <script src="Views/CodeMirrorFormatters.js"></script>
</span><span class="cx"> <script src="Views/CodeMirrorTextMarkers.js"></script>
</span><span class="cx"> <script src="Views/ColorPicker.js"></script>
</span><span class="lines">@@ -596,6 +597,7 @@
</span><span class="cx"> <script src="Controllers/CodeMirrorDragToAdjustNumberController.js"></script>
</span><span class="cx"> <script src="Controllers/CodeMirrorGradientEditingController.js"></script>
</span><span class="cx"> <script src="Controllers/CodeMirrorTokenTrackingController.js"></script>
</span><ins>+ <script src="Controllers/CodeMirrorTextKillController.js"></script>
</ins><span class="cx"> <script src="Controllers/DOMTreeManager.js"></script>
</span><span class="cx"> <script src="Controllers/DashboardManager.js"></script>
</span><span class="cx"> <script src="Controllers/DebuggerManager.js"></script>
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceProtocolInspectorFrontendHostStubjs"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendHostStub.js (193330 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendHostStub.js        2015-12-03 19:11:28 UTC (rev 193330)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendHostStub.js        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -122,6 +122,10 @@
</span><span class="cx"> console.error("Clipboard access is denied");
</span><span class="cx"> },
</span><span class="cx">
</span><ins>+ killText: function(text, shouldStartNewSequence)
+ {
+ },
+
</ins><span class="cx"> openInNewTab: function(url)
</span><span class="cx"> {
</span><span class="cx"> window.open(url, "_blank");
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceViewsBreakpointActionViewjs"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/BreakpointActionView.js (193330 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/BreakpointActionView.js        2015-12-03 19:11:28 UTC (rev 193330)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/BreakpointActionView.js        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -149,7 +149,7 @@
</span><span class="cx"> editorElement.classList.add("breakpoint-action-eval-editor");
</span><span class="cx"> editorElement.classList.add(WebInspector.SyntaxHighlightedStyleClassName);
</span><span class="cx">
</span><del>- this._codeMirror = CodeMirror(editorElement, {
</del><ins>+ this._codeMirror = WebInspector.CodeMirrorEditor.create(editorElement, {
</ins><span class="cx"> lineWrapping: true,
</span><span class="cx"> mode: "text/javascript",
</span><span class="cx"> indentWithTabs: true,
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceViewsCSSStyleDeclarationTextEditorjs"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js (193330 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js        2015-12-03 19:11:28 UTC (rev 193330)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx">
</span><span class="cx"> this._delegate = delegate || null;
</span><span class="cx">
</span><del>- this._codeMirror = CodeMirror(this.element, {
</del><ins>+ this._codeMirror = WebInspector.CodeMirrorEditor.create(this.element, {
</ins><span class="cx"> readOnly: true,
</span><span class="cx"> lineWrapping: true,
</span><span class="cx"> mode: "css-rule",
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceViewsCodeMirrorEditorjs"></a>
<div class="addfile"><h4>Added: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CodeMirrorEditor.js (0 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CodeMirrorEditor.js         (rev 0)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CodeMirrorEditor.js        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.CodeMirrorEditor = class CodeMirrorEditor
+{
+ static create(place, options)
+ {
+ var codeMirror = new CodeMirror(place, options);
+
+ // Set up default controllers that should be present for
+ // all CodeMirror editor instances.
+ new WebInspector.CodeMirrorTextKillController(codeMirror);
+
+ return codeMirror;
+ }
+}
</ins></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceViewsConsolePromptjs"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js (193330 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js        2015-12-03 19:11:28 UTC (rev 193330)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx">
</span><span class="cx"> this._delegate = delegate || null;
</span><span class="cx">
</span><del>- this._codeMirror = CodeMirror(this.element, {
</del><ins>+ this._codeMirror = WebInspector.CodeMirrorEditor.create(this.element, {
</ins><span class="cx"> lineWrapping: true,
</span><span class="cx"> mode: mimeType,
</span><span class="cx"> indentWithTabs: true,
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceViewsScopeChainDetailsSidebarPaneljs"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js (193330 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js        2015-12-03 19:11:28 UTC (rev 193330)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -316,7 +316,7 @@
</span><span class="cx"> var editorElement = content.appendChild(document.createElement("div"));
</span><span class="cx"> editorElement.classList.add("watch-expression-editor", WebInspector.SyntaxHighlightedStyleClassName);
</span><span class="cx">
</span><del>- this._codeMirror = CodeMirror(editorElement, {
</del><ins>+ this._codeMirror = WebInspector.CodeMirrorEditor.create(editorElement, {
</ins><span class="cx"> lineWrapping: true,
</span><span class="cx"> mode: "text/javascript",
</span><span class="cx"> indentWithTabs: true,
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceViewsTextEditorjs"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/TextEditor.js (193330 => 193331)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/TextEditor.js        2015-12-03 19:11:28 UTC (rev 193330)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/TextEditor.js        2015-12-03 19:11:38 UTC (rev 193331)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx"> this.element.classList.add("text-editor", WebInspector.SyntaxHighlightedStyleClassName);
</span><span class="cx">
</span><span class="cx"> // FIXME: <https://webkit.org/b/149120> Web Inspector: Preferences for Text Editor behavior
</span><del>- this._codeMirror = CodeMirror(this.element, {
</del><ins>+ this._codeMirror = WebInspector.CodeMirrorEditor.create(this.element, {
</ins><span class="cx"> readOnly: true,
</span><span class="cx"> indentWithTabs: true,
</span><span class="cx"> indentUnit: 4,
</span></span></pre>
</div>
</div>
</body>
</html>