[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e

apavlov at chromium.org apavlov at chromium.org
Fri Jan 21 14:48:18 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit a25484c3d114dbf4abda8820878426204aac1e51
Author: apavlov at chromium.org <apavlov at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 30 17:26:30 2010 +0000

    2010-12-30  Alexander Pavlov  <apavlov at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Web Inspector: Pasting a style property with value should automatically split it into prop/value
            https://bugs.webkit.org/show_bug.cgi?id=51581
    
            The "paste" DOM event is handled for the CSS property name field to parse out the name and value parts
            of a CSS property being pasted (by the first ':' found). The property is committed (if not a new one),
            and the edit focus is transferred to the value field.
    
            * inspector/front-end/StylesSidebarPane.js:
            (WebInspector.StylePropertyTreeElement.prototype.selectElement):
            (WebInspector.StylePropertyTreeElement.prototype):
            * inspector/front-end/inspector.js:
            (WebInspector.completeURL): Drive-by: return full URLs as-is.
            (WebInspector.startEditing.cleanUpAfterEditing):
            (WebInspector.startEditing):
            (WebInspector.startEditing.pasteEventListener):
            (WebInspector.startEditing.keyDownEventListener):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74799 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 6cca7d0..77d4c6b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2010-12-30  Alexander Pavlov  <apavlov at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Pasting a style property with value should automatically split it into prop/value
+        https://bugs.webkit.org/show_bug.cgi?id=51581
+
+        The "paste" DOM event is handled for the CSS property name field to parse out the name and value parts
+        of a CSS property being pasted (by the first ':' found). The property is committed (if not a new one),
+        and the edit focus is transferred to the value field.
+
+        * inspector/front-end/StylesSidebarPane.js:
+        (WebInspector.StylePropertyTreeElement.prototype.selectElement):
+        (WebInspector.StylePropertyTreeElement.prototype):
+        * inspector/front-end/inspector.js:
+        (WebInspector.completeURL): Drive-by: return full URLs as-is.
+        (WebInspector.startEditing.cleanUpAfterEditing):
+        (WebInspector.startEditing):
+        (WebInspector.startEditing.pasteEventListener):
+        (WebInspector.startEditing.keyDownEventListener):
+
 2010-12-30  Pavel Podivilov  <podivilov at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/inspector/front-end/StylesSidebarPane.js b/WebCore/inspector/front-end/StylesSidebarPane.js
index 0bc941c..d646829 100644
--- a/WebCore/inspector/front-end/StylesSidebarPane.js
+++ b/WebCore/inspector/front-end/StylesSidebarPane.js
@@ -1581,11 +1581,37 @@ WebInspector.StylePropertyTreeElement.prototype = {
                 return "move-" + (event.shiftKey ? "backward" : "forward");
         }
 
+        function pasteHandler(context, event)
+        {
+            var data = event.clipboardData.getData("Text");
+            if (!data)
+                return;
+            var colonIdx = data.indexOf(":");
+            if (colonIdx < 0)
+                return;
+            var name = data.substring(0, colonIdx).trim();
+            var value = data.substring(colonIdx + 1).trim();
+
+            event.preventDefault();
+
+            if (!("originalName" in context)) {
+                context.originalName = this.nameElement.textContent;
+                context.originalValue = this.valueElement.textContent;
+            }
+            this.nameElement.textContent = name;
+            this.valueElement.textContent = value;
+            this.nameElement.normalize();
+            this.valueElement.normalize();
+
+            return "move-forward";
+        }
+
         WebInspector.startEditing(selectElement, {
             context: context,
             commitHandler: this.editingCommitted.bind(this),
             cancelHandler: this.editingCancelled.bind(this),
-            customFinishHandler: nameValueFinishHandler.bind(this, context, isEditingName)
+            customFinishHandler: nameValueFinishHandler.bind(this, context, isEditingName),
+            pasteHandler: isEditingName ? pasteHandler.bind(this, context) : null
         });
         window.getSelection().setBaseAndExtent(selectElement, 0, selectElement, 1);
     },
@@ -1793,9 +1819,10 @@ WebInspector.StylePropertyTreeElement.prototype = {
 
         // Make the Changes and trigger the moveToNextCallback after updating.
         var blankInput = /^\s*$/.test(userInput);
+        var isDataPasted = "originalName" in context;
+        var isDirtyViaPaste = isDataPasted && (this.nameElement.textContent !== context.originalName || this.valueElement.textContent !== context.originalValue);
         var shouldCommitNewProperty = this._newProperty && (moveToOther || (!moveDirection && !isEditingName) || (isEditingName && blankInput));
-
-        if ((userInput !== previousContent && !this._newProperty) || shouldCommitNewProperty) {
+        if (((userInput !== previousContent || isDirtyViaPaste) && !this._newProperty) || shouldCommitNewProperty) {
             this.treeOutline.section._afterUpdate = moveToNextCallback.bind(this, this._newProperty, !blankInput, this.treeOutline.section);
             var propertyText;
             if (blankInput || (this._newProperty && /^\s*$/.test(this.valueElement.textContent)))
@@ -1808,7 +1835,7 @@ WebInspector.StylePropertyTreeElement.prototype = {
             }
             this.applyStyleText(propertyText, true);
         } else {
-            if (!this._newProperty)
+            if (!isDataPasted && !this._newProperty)
                 this.updateTitle();
             moveToNextCallback(this._newProperty, false, this.treeOutline.section);
         }
diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js
index cc255aa..33a75d7 100644
--- a/WebCore/inspector/front-end/inspector.js
+++ b/WebCore/inspector/front-end/inspector.js
@@ -1547,6 +1547,13 @@ WebInspector.resourceURLForRelatedNode = function(node, url)
 
 WebInspector.completeURL = function(baseURL, href)
 {
+    if (href) {
+        // Return absolute URLs as-is.
+        var parsedHref = href.asParsedURL();
+        if (parsedHref && parsedHref.scheme)
+            return href;
+    }
+
     var parsedURL = baseURL.asParsedURL();
     if (parsedURL) {
         var path = href;
@@ -1753,6 +1760,7 @@ WebInspector.isEditingAnyField = function()
 // commitHandler: Function - handles editing "commit" outcome
 // cancelHandler: Function - handles editing "cancel" outcome
 // customFinishHandler: Function - custom finish handler for the editing session (invoked on keydown)
+// pasteHandler: Function - handles the "paste" event, return values are the same as those for customFinishHandler
 // multiline: Boolean - whether the edited element is multiline
 WebInspector.startEditing = function(element, config)
 {
@@ -1764,6 +1772,7 @@ WebInspector.startEditing = function(element, config)
     config = config || {};
     var committedCallback = config.commitHandler;
     var cancelledCallback = config.cancelHandler;
+    var pasteCallback = config.pasteHandler;
     var context = config.context;
     var oldText = getContent(element);
     var moveDirection = "";
@@ -1796,6 +1805,8 @@ WebInspector.startEditing = function(element, config)
 
         element.removeEventListener("blur", blurEventListener, false);
         element.removeEventListener("keydown", keyDownEventListener, true);
+        if (pasteCallback)
+            element.removeEventListener("paste", pasteEventListener, true);
 
         if (element === WebInspector.currentFocusElement || element.isAncestor(WebInspector.currentFocusElement))
             WebInspector.currentFocusElement = WebInspector.previousFocusElement;
@@ -1833,10 +1844,8 @@ WebInspector.startEditing = function(element, config)
             return "move-" + (event.shiftKey ? "backward" : "forward");
     }
 
-    function keyDownEventListener(event)
+    function handleEditingResult(result, event)
     {
-        var handler = config.customFinishHandler || defaultFinishHandler;
-        var result = handler(event);
         if (result === "commit") {
             editingCommitted.call(element);
             event.preventDefault();
@@ -1852,8 +1861,23 @@ WebInspector.startEditing = function(element, config)
         }
     }
 
+    function pasteEventListener(event)
+    {
+        var result = pasteCallback(event);
+        handleEditingResult(result, event);
+    }
+
+    function keyDownEventListener(event)
+    {
+        var handler = config.customFinishHandler || defaultFinishHandler;
+        var result = handler(event);
+        handleEditingResult(result, event);
+    }
+
     element.addEventListener("blur", blurEventListener, false);
     element.addEventListener("keydown", keyDownEventListener, true);
+    if (pasteCallback)
+        element.addEventListener("paste", pasteEventListener, true);
 
     WebInspector.currentFocusElement = element;
     return {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list