Title: [114380] trunk/Source/WebKit/blackberry
- Revision
- 114380
- Author
- mifen...@rim.com
- Date
- 2012-04-17 08:20:29 -0700 (Tue, 17 Apr 2012)
Log Message
[BlackBerry] Pattern matching should be applied to numbers
https://bugs.webkit.org/show_bug.cgi?id=84152
Reviewed by Antonio Gomes.
PR 148906.
Add pattern matching for number based on [0-9] to trigger
input help matching number fields.
* WebKitSupport/DOMSupport.cpp:
(BlackBerry::WebKit::DOMSupport::elementPatternIndicatesNumber):
(DOMSupport):
(BlackBerry::WebKit::DOMSupport::elementPatternIndicatesHexadecimal):
(BlackBerry::WebKit::DOMSupport::elementPatternMatches):
* WebKitSupport/DOMSupport.h:
* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::convertInputType):
Modified Paths
Diff
Modified: trunk/Source/WebKit/blackberry/ChangeLog (114379 => 114380)
--- trunk/Source/WebKit/blackberry/ChangeLog 2012-04-17 15:20:01 UTC (rev 114379)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2012-04-17 15:20:29 UTC (rev 114380)
@@ -1,3 +1,24 @@
+2012-04-17 Mike Fenton <mifen...@rim.com>
+
+ [BlackBerry] Pattern matching should be applied to numbers
+ https://bugs.webkit.org/show_bug.cgi?id=84152
+
+ Reviewed by Antonio Gomes.
+
+ PR 148906.
+
+ Add pattern matching for number based on [0-9] to trigger
+ input help matching number fields.
+
+ * WebKitSupport/DOMSupport.cpp:
+ (BlackBerry::WebKit::DOMSupport::elementPatternIndicatesNumber):
+ (DOMSupport):
+ (BlackBerry::WebKit::DOMSupport::elementPatternIndicatesHexadecimal):
+ (BlackBerry::WebKit::DOMSupport::elementPatternMatches):
+ * WebKitSupport/DOMSupport.h:
+ * WebKitSupport/InputHandler.cpp:
+ (BlackBerry::WebKit::convertInputType):
+
2012-04-17 George Staikos <stai...@webkit.org>
Export the initialization function so it can be called earlier.
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp (114379 => 114380)
--- trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp 2012-04-17 15:20:01 UTC (rev 114379)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp 2012-04-17 15:20:29 UTC (rev 114380)
@@ -394,35 +394,45 @@
return false;
}
+bool elementPatternIndicatesNumber(const HTMLInputElement* inputElement)
+{
+ return elementPatternMatches("[0-9]", inputElement);
+}
+
bool elementPatternIndicatesHexadecimal(const HTMLInputElement* inputElement)
{
- if (!inputElement)
+ return elementPatternMatches("[0-9a-fA-F]", inputElement);
+}
+
+bool elementPatternMatches(const char* pattern, const HTMLInputElement* inputElement)
+{
+ WTF::String patternString(pattern);
+ if (!inputElement || patternString.isEmpty())
return false;
if (inputElement->fastHasAttribute(HTMLNames::patternAttr)) {
- AtomicString patternAttribute = inputElement->fastGetAttribute(HTMLNames::patternAttr);
- if (patternAttribute.startsWith("[0-9a-fA-F]")) {
+ WTF::String patternAttribute = inputElement->fastGetAttribute(HTMLNames::patternAttr);
+ if (patternAttribute.startsWith(patternString)) {
// The pattern is for hexadecimal, make sure nothing else is permitted.
// Check if it was an exact match.
- if (patternAttribute.length() == 11)
+ if (patternAttribute.length() == patternString.length())
return true;
// Check for *
- if (patternAttribute.length() == 12 && patternAttribute[11] == '*')
+ if (patternAttribute.length() == patternString.length() + 1 && patternAttribute[patternString.length()] == '*')
return true;
// Is the regex specifying a character count?
- if (patternAttribute[11] != '{' || !patternAttribute.endsWith("}"))
+ if (patternAttribute[patternString.length()] != '{' || !patternAttribute.endsWith("}"))
return false;
- int count = 0;
// Make sure the number in the regex is actually a number.
- if ((sscanf(patternAttribute.string().latin1().data(), "[0-9a-fA-F]{%d}\0", &count) == 1) && count > 0)
- return true;
+ unsigned count = 0;
+ patternString = patternString + "{%d}";
+ return (sscanf(patternAttribute.latin1().data(), patternString.latin1().data() + '\0', &count) == 1) && count > 0;
}
}
-
return false;
}
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.h (114379 => 114380)
--- trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.h 2012-04-17 15:20:01 UTC (rev 114379)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.h 2012-04-17 15:20:29 UTC (rev 114380)
@@ -78,6 +78,8 @@
bool elementIdOrNameIndicatesNoAutocomplete(const WebCore::Element*);
bool elementIdOrNameIndicatesEmail(const WebCore::HTMLInputElement*);
bool elementIdOrNameIndicatesUrl(const WebCore::HTMLInputElement*);
+bool elementPatternMatches(const char*, const WebCore::HTMLInputElement*);
+bool elementPatternIndicatesNumber(const WebCore::HTMLInputElement*);
bool elementPatternIndicatesHexadecimal(const WebCore::HTMLInputElement*);
WebCore::IntPoint convertPointToFrame(const WebCore::Frame* sourceFrame, const WebCore::Frame* targetFrame, const WebCore::IntPoint& sourcePoint, const bool clampToTargetFrame = false);
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (114379 => 114380)
--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp 2012-04-17 15:20:01 UTC (rev 114379)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp 2012-04-17 15:20:29 UTC (rev 114380)
@@ -158,6 +158,8 @@
return InputTypeEmail;
if (DOMSupport::elementIdOrNameIndicatesUrl(inputElement))
return InputTypeURL;
+ if (DOMSupport::elementPatternIndicatesNumber(inputElement))
+ return InputTypeNumber;
if (DOMSupport::elementPatternIndicatesHexadecimal(inputElement))
return InputTypeHexadecimal;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes