[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.18-1-697-g2f78b87
sullivan at apple.com
sullivan at apple.com
Wed Jan 20 22:26:57 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit dbfce61f403687fd544739af547568e89a21288f
Author: sullivan at apple.com <sullivan at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sun Jan 17 01:03:32 2010 +0000
https://bugs.webkit.org/show_bug.cgi?id=33751 and <rdar://problem/7538330>
Zip code field is misidentified as street address because id attribute isn't checked.
Reviewed by Darin Adler
No new tests. I believe this code is used only by Safari AutoFill, but in any case
it does not affect page rendering or anything else at the WebCore/WebKit level.
* page/Frame.cpp:
(WebCore::matchLabelsAgainstString):
New function, split out from matchLabelsAgainstElement.
(WebCore::Frame::matchLabelsAgainstElement):
Now calls matchLabelsAgainstString for the id attribute if no match is found for the name attribute.
* page/mac/FrameMac.mm:
(WebCore::matchLabelsAgainstString):
Same as above. This is a parallel copy of the function using Mac-specific data structures.
(WebCore::Frame::matchLabelsAgainstElement):
Ditto.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53367 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c8c6421..7307b16 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-01-15 John Sullivan <sullivan at apple.com>
+
+ https://bugs.webkit.org/show_bug.cgi?id=33751 and <rdar://problem/7538330>
+ Zip code field is misidentified as street address because id attribute isn't checked.
+
+ Reviewed by Darin Adler
+
+ No new tests. I believe this code is used only by Safari AutoFill, but in any case
+ it does not affect page rendering or anything else at the WebCore/WebKit level.
+
+ * page/Frame.cpp:
+ (WebCore::matchLabelsAgainstString):
+ New function, split out from matchLabelsAgainstElement.
+ (WebCore::Frame::matchLabelsAgainstElement):
+ Now calls matchLabelsAgainstString for the id attribute if no match is found for the name attribute.
+
+ * page/mac/FrameMac.mm:
+ (WebCore::matchLabelsAgainstString):
+ Same as above. This is a parallel copy of the function using Mac-specific data structures.
+ (WebCore::Frame::matchLabelsAgainstElement):
+ Ditto.
+
2010-01-16 Timothy Hatcher <timothy at apple.com>
Use String.trim() instead of a regex in the Web Inspector.
diff --git a/WebCore/page/Frame.cpp b/WebCore/page/Frame.cpp
index 77f06ca..9625ca6 100644
--- a/WebCore/page/Frame.cpp
+++ b/WebCore/page/Frame.cpp
@@ -494,25 +494,26 @@ String Frame::searchForLabelsBeforeElement(const Vector<String>& labels, Element
return String();
}
-String Frame::matchLabelsAgainstElement(const Vector<String>& labels, Element* element)
+static String matchLabelsAgainstString(const Vector<String>& labels, const String& stringToMatch)
{
- String name = element->getAttribute(nameAttr);
- if (name.isEmpty())
+ if (stringToMatch.isEmpty())
return String();
- // Make numbers and _'s in field names behave like word boundaries, e.g., "address2"
- replace(name, RegularExpression("\\d", TextCaseSensitive), " ");
- name.replace('_', ' ');
+ String mutableStringToMatch = stringToMatch;
+ // Make numbers and _'s in field names behave like word boundaries, e.g., "address2"
+ replace(mutableStringToMatch, RegularExpression("\\d", TextCaseSensitive), " ");
+ mutableStringToMatch.replace('_', ' ');
+
OwnPtr<RegularExpression> regExp(createRegExpForLabels(labels));
- // Use the largest match we can find in the whole name string
+ // Use the largest match we can find in the whole string
int pos;
int length;
int bestPos = -1;
int bestLength = -1;
int start = 0;
do {
- pos = regExp->match(name, start);
+ pos = regExp->match(mutableStringToMatch, start);
if (pos != -1) {
length = regExp->matchedLength();
if (length >= bestLength) {
@@ -522,11 +523,24 @@ String Frame::matchLabelsAgainstElement(const Vector<String>& labels, Element* e
start = pos + 1;
}
} while (pos != -1);
-
+
if (bestPos != -1)
- return name.substring(bestPos, bestLength);
+ return mutableStringToMatch.substring(bestPos, bestLength);
return String();
}
+
+String Frame::matchLabelsAgainstElement(const Vector<String>& labels, Element* element)
+{
+ // Match against the name element, then against the id element if no match is found for the name element.
+ // See 7538330 for one popular site that benefits from the id element check.
+ // FIXME: This code is mirrored in FrameMac.mm. It would be nice to make the Mac code call the platform-agnostic
+ // code, which would require converting the NSArray of NSStrings to a Vector of Strings somewhere along the way.
+ String resultFromNameAttribute = matchLabelsAgainstString(labels, element->getAttribute(nameAttr));
+ if (!resultFromNameAttribute.isEmpty())
+ return resultFromNameAttribute;
+
+ return matchLabelsAgainstString(labels, element->getAttribute(idAttr));
+}
const VisibleSelection& Frame::mark() const
{
diff --git a/WebCore/page/mac/FrameMac.mm b/WebCore/page/mac/FrameMac.mm
index fce5704..fbaf895 100644
--- a/WebCore/page/mac/FrameMac.mm
+++ b/WebCore/page/mac/FrameMac.mm
@@ -229,25 +229,26 @@ NSString* Frame::searchForLabelsBeforeElement(NSArray* labels, Element* element)
return nil;
}
-NSString* Frame::matchLabelsAgainstElement(NSArray* labels, Element* element)
+static NSString *matchLabelsAgainstString(NSArray *labels, const String& stringToMatch)
{
- String name = element->getAttribute(nameAttr);
- if (name.isEmpty())
+ if (stringToMatch.isEmpty())
return nil;
-
+
+ String mutableStringToMatch = stringToMatch;
+
// Make numbers and _'s in field names behave like word boundaries, e.g., "address2"
- replace(name, RegularExpression("\\d", TextCaseSensitive), " ");
- name.replace('_', ' ');
-
+ replace(mutableStringToMatch, RegularExpression("\\d", TextCaseSensitive), " ");
+ mutableStringToMatch.replace('_', ' ');
+
RegularExpression* regExp = regExpForLabels(labels);
- // Use the largest match we can find in the whole name string
+ // Use the largest match we can find in the whole string
int pos;
int length;
int bestPos = -1;
int bestLength = -1;
int start = 0;
do {
- pos = regExp->match(name, start);
+ pos = regExp->match(mutableStringToMatch, start);
if (pos != -1) {
length = regExp->matchedLength();
if (length >= bestLength) {
@@ -257,12 +258,25 @@ NSString* Frame::matchLabelsAgainstElement(NSArray* labels, Element* element)
start = pos + 1;
}
} while (pos != -1);
-
+
if (bestPos != -1)
- return name.substring(bestPos, bestLength);
+ return mutableStringToMatch.substring(bestPos, bestLength);
return nil;
}
+NSString* Frame::matchLabelsAgainstElement(NSArray* labels, Element* element)
+{
+ // Match against the name element, then against the id element if no match is found for the name element.
+ // See 7538330 for one popular site that benefits from the id element check.
+ // FIXME: This code is mirrored in Frame.cpp. It would be nice to make the Mac code call the platform-agnostic
+ // code, which would require converting the NSArray of NSStrings to a Vector of Strings somewhere along the way.
+ String resultFromNameAttribute = matchLabelsAgainstString(labels, element->getAttribute(nameAttr));
+ if (!resultFromNameAttribute.isEmpty())
+ return resultFromNameAttribute;
+
+ return matchLabelsAgainstString(labels, element->getAttribute(idAttr));
+}
+
NSImage* Frame::imageFromRect(NSRect rect) const
{
NSView* view = m_view->documentView();
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list