Skip to content
Permalink
Browse files
Web Inspector: Visual style editor shouldn't allow alpha characters i…
…n numeric input fields

https://bugs.webkit.org/show_bug.cgi?id=148580

Reviewed by Brian Burg.

* UserInterface/Views/VisualStyleNumberInputBox.js:
(WebInspector.VisualStyleNumberInputBox):
Added input element "changed" handler, renamed "keyup" handler to match "keydown" handler.
(WebInspector.VisualStyleNumberInputBox.prototype._valueNumberInputChanged):
Validate input in response to changed event.


Canonical link: https://commits.webkit.org/166788@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189210 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
LuckyKobold committed Sep 1, 2015
1 parent 511b786 commit e79a696c864e714be7e8cca7142f9ef0e0bafd98
Showing 2 changed files with 29 additions and 2 deletions.
@@ -1,3 +1,16 @@
2015-09-01 Matt Baker <mattbaker@apple.com>

Web Inspector: Visual style editor shouldn't allow alpha characters in numeric input fields
https://bugs.webkit.org/show_bug.cgi?id=148580

Reviewed by Brian Burg.

* UserInterface/Views/VisualStyleNumberInputBox.js:
(WebInspector.VisualStyleNumberInputBox):
Added input element "changed" handler, renamed "keyup" handler to match "keydown" handler.
(WebInspector.VisualStyleNumberInputBox.prototype._valueNumberInputChanged):
Validate input in response to changed event.

2015-08-31 Nikita Vasilyev <nvasilyev@apple.com>

Web Inspector: Command-Enter for selected JS in Debugger/Sources shouldn't change the focus
@@ -75,8 +75,9 @@ WebInspector.VisualStyleNumberInputBox = class VisualStyleNumberInputBox extends
this._valueNumberInputElement.spellcheck = false;
this._valueNumberInputElement.addEventListener("focus", this._focusContentElement.bind(this));
this._valueNumberInputElement.addEventListener("keydown", this._valueNumberInputKeyDown.bind(this));
this._valueNumberInputElement.addEventListener("keyup", this._numberInputChanged.bind(this));
this._valueNumberInputElement.addEventListener("keyup", this._valueNumberInputKeyUp.bind(this));
this._valueNumberInputElement.addEventListener("blur", this._blurContentElement.bind(this));
this._valueNumberInputElement.addEventListener("change", this._valueNumberInputChanged.bind(this));
this._numberUnitsContainer.appendChild(this._valueNumberInputElement);

this._unitsElement = document.createElement("span");
@@ -301,7 +302,7 @@ WebInspector.VisualStyleNumberInputBox = class VisualStyleNumberInputBox extends
this._valueDidChange();
}

_numberInputChanged()
_valueNumberInputKeyUp(event)
{
if (!this._numberInputIsEditable)
return;
@@ -376,6 +377,19 @@ WebInspector.VisualStyleNumberInputBox = class VisualStyleNumberInputBox extends
this.contentElement.classList.remove("focused");
}

_valueNumberInputChanged(event)
{
let newValue = this.value;
if (!newValue && isNaN(newValue))
newValue = this.placeholder && !isNaN(this.placeholder) ? parseFloat(this.placeholder) : 0;

if (!this._allowNegativeValues && newValue < 0)
newValue = 0;

this.value = Math.round(newValue * 100) / 100;
this._valueDidChange();
}

_toggleTabbingOfSelectableElements(disabled)
{
this._keywordSelectElement.tabIndex = disabled ? "-1" : null;

0 comments on commit e79a696

Please sign in to comment.