summaryrefslogtreecommitdiff
path: root/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-05-07 11:21:11 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-05-07 11:21:11 +0200
commit2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (patch)
tree988e8c5b116dd0466244ae2fe5af8ee9be926d76 /Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp
parentdd91e772430dc294e3bf478c119ef8d43c0a3358 (diff)
downloadqtwebkit-2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47.tar.gz
Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286)
Diffstat (limited to 'Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp')
-rw-r--r--Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp110
1 files changed, 105 insertions, 5 deletions
diff --git a/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp b/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp
index 26c0e6cd2..3b972d6c9 100644
--- a/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp
+++ b/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp
@@ -48,6 +48,15 @@ namespace BlackBerry {
namespace WebKit {
namespace DOMSupport {
+void visibleTextQuads(const VisibleSelection& selection, Vector<FloatQuad>& quads)
+{
+ if (!selection.isRange())
+ return;
+ ASSERT(selection.firstRange());
+
+ visibleTextQuads(*(selection.firstRange()), quads, true /* useSelectionHeight */);
+}
+
void visibleTextQuads(const Range& range, Vector<FloatQuad>& quads, bool useSelectionHeight)
{
// Range::textQuads includes hidden text, which we don't want.
@@ -165,7 +174,7 @@ bool isColorInputField(const Element* element)
const HTMLInputElement* inputElement = static_cast<const HTMLInputElement*>(element);
-#if ENABLE(INPUT_COLOR)
+#if ENABLE(INPUT_TYPE_COLOR)
if (inputElement->isColorControl())
return true;
#endif
@@ -285,7 +294,7 @@ VisibleSelection visibleSelectionForRangeInputElement(Element* element, int star
Node* DOMContainerNodeForPosition(const Position& position)
{
Node* nodeAtPos = position.containerNode();
- if (nodeAtPos->isInShadowTree())
+ if (nodeAtPos && nodeAtPos->isInShadowTree())
nodeAtPos = nodeAtPos->shadowAncestorNode();
return nodeAtPos;
@@ -293,8 +302,14 @@ Node* DOMContainerNodeForPosition(const Position& position)
bool isPositionInNode(Node* node, const Position& position)
{
- int offset = 0;
+ if (!node)
+ return false;
+
Node* domNodeAtPos = DOMContainerNodeForPosition(position);
+ if (!domNodeAtPos)
+ return false;
+
+ int offset = 0;
if (domNodeAtPos == position.containerNode())
offset = position.computeOffsetInContainerNode();
@@ -304,9 +319,52 @@ bool isPositionInNode(Node* node, const Position& position)
return rangeForNode->isPointInRange(domNodeAtPos, offset, ec);
}
-bool matchesReservedStringPreventingAutocomplete(AtomicString& string)
+static bool matchesReservedStringEmail(const AtomicString& string)
{
- if (string.contains("email", false /* caseSensitive */)
+ return string.contains("email", false /* caseSensitive */);
+}
+
+static bool matchesReservedStringUrl(const AtomicString& string)
+{
+ return equalIgnoringCase("url", string);
+}
+
+bool elementIdOrNameIndicatesEmail(const HTMLInputElement* inputElement)
+{
+ if (!inputElement)
+ return false;
+
+ if (matchesReservedStringEmail(inputElement->getIdAttribute()))
+ return true;
+
+ if (inputElement->fastHasAttribute(HTMLNames::nameAttr)) {
+ if (matchesReservedStringEmail(inputElement->fastGetAttribute(HTMLNames::nameAttr)))
+ return true;
+ }
+
+ return false;
+}
+
+bool elementIdOrNameIndicatesUrl(const HTMLInputElement* inputElement)
+{
+ if (!inputElement)
+ return false;
+
+ if (matchesReservedStringUrl(inputElement->getIdAttribute()))
+ return true;
+
+ if (inputElement->fastHasAttribute(HTMLNames::nameAttr)) {
+ if (matchesReservedStringUrl(inputElement->fastGetAttribute(HTMLNames::nameAttr)))
+ return true;
+ }
+
+ return false;
+}
+
+static bool matchesReservedStringPreventingAutocomplete(const AtomicString& string)
+{
+ if (matchesReservedStringEmail(string)
+ || matchesReservedStringUrl(string)
|| string.contains("user", false /* caseSensitive */)
|| string.contains("name", false /* caseSensitive */)
|| string.contains("login", false /* caseSensitive */))
@@ -336,6 +394,48 @@ bool elementIdOrNameIndicatesNoAutocomplete(const Element* element)
return false;
}
+bool elementPatternIndicatesNumber(const HTMLInputElement* inputElement)
+{
+ return elementPatternMatches("[0-9]", inputElement);
+}
+
+bool elementPatternIndicatesHexadecimal(const HTMLInputElement* 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)) {
+ 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() == patternString.length())
+ return true;
+
+ // Check for *
+ if (patternAttribute.length() == patternString.length() + 1 && patternAttribute[patternString.length()] == '*')
+ return true;
+
+ // Is the regex specifying a character count?
+ if (patternAttribute[patternString.length()] != '{' || !patternAttribute.endsWith('}'))
+ return false;
+
+ // Make sure the number in the regex is actually a number.
+ unsigned count = 0;
+ patternString = patternString + "{%d}";
+ return (sscanf(patternAttribute.latin1().data(), patternString.latin1().data() + '\0', &count) == 1) && count > 0;
+ }
+ }
+ return false;
+}
+
IntPoint convertPointToFrame(const Frame* sourceFrame, const Frame* targetFrame, const IntPoint& point, const bool clampToTargetFrame)
{
ASSERT(sourceFrame && targetFrame);