Changeset 125402 in webkit


Ignore:
Timestamp:
Aug 13, 2012 2:33:09 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: Feature Request - Adding mouse gesture for editing attribute values in elements/css panel
https://bugs.webkit.org/show_bug.cgi?id=93581

Patch by Sam D <dsam2912@gmail.com> on 2012-08-13
Reviewed by Alexander Pavlov.

Added functionality to modify valuesAdding support for updating number values in attributes in element
panel/ css panel using mouse gestures as well.

No new tests.

  • inspector/front-end/StylesSidebarPane.js:

handling mousewheel event

  • inspector/front-end/TextPrompt.js:

adding mouse event listener
(WebInspector.TextPrompt.prototype._attachInternal):
(WebInspector.TextPrompt.prototype.defaultKeyHandler):
(WebInspector.TextPrompt.prototype.onMouseWheel):

  • inspector/front-end/UIUtils.js:

handling mouse event gesture and updating number based on mouse wheel
scroll direction as well.
(WebInspector._valueModificationDirection):
(WebInspector._modifiedHexValue):
(WebInspector._modifiedFloatNumber):
(WebInspector.handleElementValueModifications):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r125400 r125402  
     12012-08-13  Sam D  <dsam2912@gmail.com>
     2
     3        Web Inspector: Feature Request - Adding mouse gesture for editing attribute values in elements/css panel
     4        https://bugs.webkit.org/show_bug.cgi?id=93581
     5
     6        Reviewed by Alexander Pavlov.
     7
     8        Added functionality to modify valuesAdding support for updating number values in attributes in element
     9        panel/ css panel using mouse gestures as well.
     10
     11        No new tests.
     12
     13        * inspector/front-end/StylesSidebarPane.js:
     14        handling mousewheel event
     15        * inspector/front-end/TextPrompt.js:
     16        adding mouse event listener
     17        (WebInspector.TextPrompt.prototype._attachInternal):
     18        (WebInspector.TextPrompt.prototype.defaultKeyHandler):
     19        (WebInspector.TextPrompt.prototype.onMouseWheel):
     20        * inspector/front-end/UIUtils.js:
     21        handling mouse event gesture and updating number based on mouse wheel
     22        scroll direction as well.
     23        (WebInspector._valueModificationDirection):
     24        (WebInspector._modifiedHexValue):
     25        (WebInspector._modifiedFloatNumber):
     26        (WebInspector.handleElementValueModifications):
     27
    1282012-08-13  Carlos Garcia Campos  <cgarcia@igalia.com>
    229
  • trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js

    r125399 r125402  
    25382538    },
    25392539
     2540    onMouseWheel: function(event)
     2541    {
     2542        if (this._handleNameOrValueUpDown(event)) {
     2543            event.consume(true);
     2544            return;
     2545        }
     2546        WebInspector.TextPrompt.prototype.onMouseWheel.call(this, event);
     2547    },
     2548
    25402549    tabKeyPressed: function()
    25412550    {
  • trunk/Source/WebCore/inspector/front-end/TextPrompt.js

    r116305 r125402  
    106106
    107107        this._boundOnKeyDown = this.onKeyDown.bind(this);
     108        this._boundOnMouseWheel = this.onMouseWheel.bind(this);
    108109        this._boundSelectStart = this._selectStart.bind(this);
    109110        this._proxyElement = element.ownerDocument.createElement("span");
     
    113114        this._element.addStyleClass("text-prompt");
    114115        this._element.addEventListener("keydown", this._boundOnKeyDown, false);
     116        this._element.addEventListener("mousewheel", this._boundOnMouseWheel, false);
    115117        this._element.addEventListener("selectstart", this._boundSelectStart, false);
    116118
     
    128130        this._element.removeStyleClass("text-prompt");
    129131        this._element.removeEventListener("keydown", this._boundOnKeyDown, false);
     132        this._element.removeEventListener("mousewheel", this._boundOnMouseWheel, false);
    130133        this._element.removeEventListener("selectstart", this._boundSelectStart, false);
    131134        delete this._proxyElement;
     
    219222        this.autoCompleteSoon(force);
    220223        return false;
     224    },
     225
     226    onMouseWheel: function(event)
     227    {
     228        // Subclasses can implement.
    221229    },
    222230
  • trunk/Source/WebCore/inspector/front-end/UIUtils.js

    r124469 r125402  
    309309WebInspector.StyleValueDelimiters = " \xA0\t\n\"':;,/()";
    310310
     311
     312/**
     313  * @param {Event} event
     314  * @return {?string}
     315  */
     316WebInspector._valueModificationDirection = function(event)
     317{
     318    var direction = null;
     319    if (event.type === "mousewheel") {
     320        if (event.wheelDeltaY > 0)
     321            direction = "Up";
     322        else if (event.wheelDeltaY < 0)
     323            direction = "Down";
     324    } else {
     325        if (event.keyIdentifier === "Up" || event.keyIdentifier === "PageUp")
     326            direction = "Up";
     327        else if (event.keyIdentifier === "Down" || event.keyIdentifier === "PageDown")
     328            direction = "Down";       
     329    }
     330    return direction;
     331}
     332
    311333/**
    312334 * @param {string} hexString
     
    315337WebInspector._modifiedHexValue = function(hexString, event)
    316338{
     339    var direction = WebInspector._valueModificationDirection(event);
     340    if (!direction)
     341        return hexString;
     342
    317343    var number = parseInt(hexString, 16);
    318344    if (isNaN(number) || !isFinite(number))
     
    320346
    321347    var maxValue = Math.pow(16, hexString.length) - 1;
    322     var arrowKeyPressed = (event.keyIdentifier === "Up" || event.keyIdentifier === "Down");
    323 
     348    var arrowKeyOrMouseWheelEvent = (event.keyIdentifier === "Up" || event.keyIdentifier === "Down" || event.type === "mousewheel");
    324349    var delta;
    325     if (arrowKeyPressed)
    326         delta = (event.keyIdentifier === "Up") ? 1 : -1;
     350
     351    if (arrowKeyOrMouseWheelEvent)
     352        delta = (direction === "Up") ? 1 : -1;
    327353    else
    328354        delta = (event.keyIdentifier === "PageUp") ? 16 : -16;
     
    350376WebInspector._modifiedFloatNumber = function(number, event)
    351377{
    352     var arrowKeyPressed = (event.keyIdentifier === "Up" || event.keyIdentifier === "Down");
     378    var direction = WebInspector._valueModificationDirection(event);
     379    if (!direction)
     380        return number;
     381   
     382    var arrowKeyOrMouseWheelEvent = (event.keyIdentifier === "Up" || event.keyIdentifier === "Down" || event.type === "mousewheel");
    353383
    354384    // Jump by 10 when shift is down or jump by 0.1 when Alt/Option is down.
    355385    // Also jump by 10 for page up and down, or by 100 if shift is held with a page key.
    356386    var changeAmount = 1;
    357     if (event.shiftKey && !arrowKeyPressed)
     387    if (event.shiftKey && !arrowKeyOrMouseWheelEvent)
    358388        changeAmount = 100;
    359     else if (event.shiftKey || !arrowKeyPressed)
     389    else if (event.shiftKey || !arrowKeyOrMouseWheelEvent)
    360390        changeAmount = 10;
    361391    else if (event.altKey)
    362392        changeAmount = 0.1;
    363393
    364     if (event.keyIdentifier === "Down" || event.keyIdentifier === "PageDown")
     394    if (direction === "Down")
    365395        changeAmount *= -1;
    366396
     
    383413WebInspector.handleElementValueModifications = function(event, element, finishHandler, suggestionHandler, customNumberHandler)
    384414{
    385     var arrowKeyPressed = (event.keyIdentifier === "Up" || event.keyIdentifier === "Down");
     415    var arrowKeyOrMouseWheelEvent = (event.keyIdentifier === "Up" || event.keyIdentifier === "Down" || event.type === "mousewheel");
    386416    var pageKeyPressed = (event.keyIdentifier === "PageUp" || event.keyIdentifier === "PageDown");
    387     if (!arrowKeyPressed && !pageKeyPressed)
     417    if (!arrowKeyOrMouseWheelEvent && !pageKeyPressed)
    388418        return false;
    389419
Note: See TracChangeset for help on using the changeset viewer.