Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(851)

Unified Diff: Source/core/html/forms/NumberInputType.cpp

Issue 1100273002: input[type=number] UI should reject invalid characters. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/forms/NumberInputType.h ('k') | Source/platform/text/PlatformLocale.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/forms/NumberInputType.cpp
diff --git a/Source/core/html/forms/NumberInputType.cpp b/Source/core/html/forms/NumberInputType.cpp
index 6795eb2afdadb6f28da3a8b347cbc6aa90f1c77c..7ceeda8c8394e11f464da0041c41edee3245450e 100644
--- a/Source/core/html/forms/NumberInputType.cpp
+++ b/Source/core/html/forms/NumberInputType.cpp
@@ -36,6 +36,7 @@
#include "core/HTMLNames.h"
#include "core/InputTypeNames.h"
#include "core/dom/ExceptionCode.h"
+#include "core/events/BeforeTextInsertedEvent.h"
#include "core/events/KeyboardEvent.h"
#include "core/events/ScopedEventQueue.h"
#include "core/html/HTMLInputElement.h"
@@ -188,6 +189,11 @@ void NumberInputType::handleKeydownEvent(KeyboardEvent* event)
TextFieldInputType::handleKeydownEvent(event);
}
+void NumberInputType::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event)
+{
+ event->setText(locale().stripInvalidNumberCharacters(event->text(), "0123456789.Ee-+"));
+}
+
Decimal NumberInputType::parseToNumber(const String& src, const Decimal& defaultValue) const
{
return parseToDecimalForNumberType(src, defaultValue);
« no previous file with comments | « Source/core/html/forms/NumberInputType.h ('k') | Source/platform/text/PlatformLocale.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698