Diff
Modified: trunk/Source/WTF/ChangeLog (130608 => 130609)
--- trunk/Source/WTF/ChangeLog 2012-10-07 19:33:49 UTC (rev 130608)
+++ trunk/Source/WTF/ChangeLog 2012-10-07 22:01:27 UTC (rev 130609)
@@ -1,3 +1,35 @@
+2012-10-07 Benjamin Poulain <[email protected]>
+
+ WTFURL: implement URL port removal for HTMLAnchorElement
+ https://bugs.webkit.org/show_bug.cgi?id=98604
+
+ Reviewed by Adam Barth.
+
+ Add hasStandardScheme() (similar to isStandard from Google URL),
+ hasPort() and removePort() to implement the port removal of KURL.
+
+ * wtf/url/api/ParsedURL.cpp:
+ (WTF::ParsedURL::hasStandardScheme):
+ (WTF::ParsedURL::hasPort):
+ (WTF::ParsedURL::removePort):
+ * wtf/url/api/ParsedURL.h:
+ (ParsedURL):
+ * wtf/url/src/URLComponent.h:
+ (WTF::URLComponent::move):
+ * wtf/url/src/URLSegments.cpp:
+ (WTF::URLSegments::moveComponentsAfter):
+ * wtf/url/src/URLSegments.h:
+ (URLSegments):
+ * wtf/url/src/URLUtil.cpp:
+ (URLUtilities):
+ (WTF::URLUtilities::isStandard):
+ * wtf/url/src/URLUtil.h:
+ (URLUtilities):
+ Remove LowerCaseEqualsASCII() from the interface, make it an internal template.
+
+ (WTF::URLUtilities::isStandard):
+ Since in WebKit, LChar is a superset of char, expose LChar and cast char* to LChar*.
+
2012-10-06 Ilya Tikhonovsky <[email protected]>
Web Inspector: NMI fix String instrumentation the way it was discussed in WK97964
Modified: trunk/Source/WTF/wtf/url/api/ParsedURL.cpp (130608 => 130609)
--- trunk/Source/WTF/wtf/url/api/ParsedURL.cpp 2012-10-07 19:33:49 UTC (rev 130608)
+++ trunk/Source/WTF/wtf/url/api/ParsedURL.cpp 2012-10-07 22:01:27 UTC (rev 130609)
@@ -137,6 +137,15 @@
return segment(m_segments.scheme);
}
+bool ParsedURL::hasStandardScheme() const
+{
+ ASSERT(m_segments.scheme.isValid());
+ const String& urlStringSpec = m_spec.m_string;
+ if (urlStringSpec.is8Bit())
+ return URLUtilities::isStandard(urlStringSpec.characters8(), m_segments.scheme);
+ return URLUtilities::isStandard(urlStringSpec.characters16(), m_segments.scheme);
+}
+
String ParsedURL::username() const
{
return segment(m_segments.username);
@@ -152,11 +161,35 @@
return segment(m_segments.host);
}
+bool ParsedURL::hasPort() const
+{
+ return m_segments.port.isNonEmpty();
+}
+
String ParsedURL::port() const
{
return segment(m_segments.port);
}
+void ParsedURL::removePort()
+{
+ if (!hasPort())
+ return;
+
+ // 1) Remove the port from the spec, including the delimiter.
+ String newSpec;
+ int beginning = m_segments.port.begin() - 1;
+ unsigned length = m_segments.port.length() + 1;
+
+ String newSpecString = m_spec.string();
+ newSpecString.remove(beginning, length);
+ m_spec = URLString(newSpecString);
+
+ // 2) Update the components positions.
+ m_segments.port.reset();
+ m_segments.moveComponentsAfter(URLSegments::Port, -length);
+}
+
String ParsedURL::path() const
{
return segment(m_segments.path);
Modified: trunk/Source/WTF/wtf/url/api/ParsedURL.h (130608 => 130609)
--- trunk/Source/WTF/wtf/url/api/ParsedURL.h 2012-10-07 19:33:49 UTC (rev 130608)
+++ trunk/Source/WTF/wtf/url/api/ParsedURL.h 2012-10-07 22:01:27 UTC (rev 130609)
@@ -54,10 +54,16 @@
// Return a URL component or a null String if the component is undefined for the URL.
WTF_EXPORT_PRIVATE String scheme() const;
+ WTF_EXPORT_PRIVATE bool hasStandardScheme() const;
+
WTF_EXPORT_PRIVATE String username() const;
WTF_EXPORT_PRIVATE String password() const;
WTF_EXPORT_PRIVATE String host() const;
+
+ WTF_EXPORT_PRIVATE bool hasPort() const;
WTF_EXPORT_PRIVATE String port() const;
+ WTF_EXPORT_PRIVATE void removePort();
+
WTF_EXPORT_PRIVATE String path() const;
WTF_EXPORT_PRIVATE String query() const;
@@ -65,6 +71,7 @@
WTF_EXPORT_PRIVATE String fragment() const;
WTF_EXPORT_PRIVATE ParsedURL withoutFragment() const;
+
WTF_EXPORT_PRIVATE String baseAsString() const;
const URLString& spec() const { return m_spec; }
Modified: trunk/Source/WTF/wtf/url/src/URLComponent.h (130608 => 130609)
--- trunk/Source/WTF/wtf/url/src/URLComponent.h 2012-10-07 19:33:49 UTC (rev 130608)
+++ trunk/Source/WTF/wtf/url/src/URLComponent.h 2012-10-07 22:01:27 UTC (rev 130609)
@@ -65,6 +65,7 @@
int begin() const { return m_begin; }
void setBegin(int begin) { m_begin = begin; }
+ void move(int offset) { m_begin += offset; }
int length() const { return m_length; }
void setLength(int length) { m_length = length; }
Modified: trunk/Source/WTF/wtf/url/src/URLSegments.cpp (130608 => 130609)
--- trunk/Source/WTF/wtf/url/src/URLSegments.cpp 2012-10-07 19:33:49 UTC (rev 130608)
+++ trunk/Source/WTF/wtf/url/src/URLSegments.cpp 2012-10-07 22:01:27 UTC (rev 130609)
@@ -110,6 +110,29 @@
return current;
}
+void URLSegments::moveComponentsAfter(ComponentType type, int offset)
+{
+ switch (type) {
+ // Fall through.
+ case Scheme:
+ username.move(offset);
+ case Username:
+ password.move(offset);
+ case Password:
+ host.move(offset);
+ case Host:
+ port.move(offset);
+ case Port:
+ path.move(offset);
+ case Path:
+ query.move(offset);
+ case Query:
+ fragment.move(offset);
+ case Fragment:
+ break;
+ }
+}
+
} // namespace WTF
#endif // USE(WTFURL)
Modified: trunk/Source/WTF/wtf/url/src/URLSegments.h (130608 => 130609)
--- trunk/Source/WTF/wtf/url/src/URLSegments.h 2012-10-07 19:33:49 UTC (rev 130608)
+++ trunk/Source/WTF/wtf/url/src/URLSegments.h 2012-10-07 22:01:27 UTC (rev 130609)
@@ -121,6 +121,9 @@
//
int charactersBefore(ComponentType, DelimiterInclusion) const;
+ // Shift all the components after ComponentType by 'offset'.
+ void moveComponentsAfter(ComponentType, int offset);
+
// Each component excludes the related delimiters and has a length of -1
// if that component is absent but 0 if the component exists but is empty.
URLComponent scheme;
Modified: trunk/Source/WTF/wtf/url/src/URLUtil.cpp (130608 => 130609)
--- trunk/Source/WTF/wtf/url/src/URLUtil.cpp 2012-10-07 19:33:49 UTC (rev 130608)
+++ trunk/Source/WTF/wtf/url/src/URLUtil.cpp 2012-10-07 22:01:27 UTC (rev 130609)
@@ -50,9 +50,8 @@
namespace {
-// Backend for LowerCaseEqualsASCII.
template<typename Iter>
-inline bool doLowerCaseEqualsASCII(Iter aBegin, Iter aEnd, const char* b)
+static bool lowerCaseEqualsASCII(Iter aBegin, Iter aEnd, const char* b)
{
for (Iter it = aBegin; it != aEnd; ++it, ++b) {
if (!*b || toASCIILower(*it) != *b)
@@ -80,7 +79,7 @@
{
if (!component.isNonEmpty())
return !compareTo[0]; // When component is empty, match empty scheme.
- return LowerCaseEqualsASCII(&spec[component.begin()], &spec[component.end()], compareTo);
+ return lowerCaseEqualsASCII(&spec[component.begin()], &spec[component.end()], compareTo);
}
// Returns true if the given scheme identified by |scheme| within |spec| is one
@@ -92,7 +91,7 @@
return false; // Empty or invalid schemes are non-standard.
for (size_t i = 0; i < kNumStandardURLSchemes; ++i) {
- if (LowerCaseEqualsASCII(&spec[scheme.begin()], &spec[scheme.end()], kStandardURLSchemes[i]))
+ if (lowerCaseEqualsASCII(&spec[scheme.begin()], &spec[scheme.end()], kStandardURLSchemes[i]))
return true;
}
return false;
@@ -319,7 +318,7 @@
} // namespace
-bool isStandard(const char* spec, const URLComponent& scheme)
+bool isStandard(const LChar* spec, const URLComponent& scheme)
{
return doIsStandard(spec, scheme);
}
@@ -397,26 +396,6 @@
charsetConverter, output, *outputParsed);
}
-// Front-ends for LowerCaseEqualsASCII.
-bool LowerCaseEqualsASCII(const char* aBegin, const char* aEnd, const char* b)
-{
- return doLowerCaseEqualsASCII(aBegin, aEnd, b);
-}
-
-bool LowerCaseEqualsASCII(const char* aBegin, const char* aEnd, const char* bBegin, const char* bEnd)
-{
- while (aBegin != aEnd && bBegin != bEnd && toASCIILower(*aBegin) == *bBegin) {
- aBegin++;
- bBegin++;
- }
- return aBegin == aEnd && bBegin == bEnd;
-}
-
-bool LowerCaseEqualsASCII(const UChar* aBegin, const UChar* aEnd, const char* b)
-{
- return doLowerCaseEqualsASCII(aBegin, aEnd, b);
-}
-
void DecodeURLEscapeSequences(const char* input, int length, URLBuffer<UChar>& output)
{
RawURLBuffer<char> unescapedChars;
Modified: trunk/Source/WTF/wtf/url/src/URLUtil.h (130608 => 130609)
--- trunk/Source/WTF/wtf/url/src/URLUtil.h 2012-10-07 19:33:49 UTC (rev 130608)
+++ trunk/Source/WTF/wtf/url/src/URLUtil.h 2012-10-07 22:01:27 UTC (rev 130609)
@@ -56,8 +56,9 @@
// Returns true if the given string represents a standard URL. This means that
// either the scheme is in the list of known standard schemes.
-bool isStandard(const char* spec, const URLComponent& scheme);
+bool isStandard(const LChar* spec, const URLComponent& scheme);
bool isStandard(const UChar* spec, const URLComponent& scheme);
+inline bool isStandard(const char* spec, const URLComponent& scheme) { return isStandard(reinterpret_cast<const LChar*>(spec), scheme); }
// URL library wrappers -------------------------------------------------------
@@ -108,18 +109,6 @@
URLQueryCharsetConverter*,
URLBuffer<char>&, URLSegments* outputParsed);
-// String helper functions ----------------------------------------------------
-
-// Compare the lower-case form of the given string against the given ASCII
-// string. This is useful for doing checking if an input string matches some
-// token, and it is optimized to avoid intermediate string copies.
-//
-// The versions of this function that don't take a bEnd assume that the b
-// string is zero terminated.
-bool LowerCaseEqualsASCII(const char* aBegin, const char* aEnd, const char* b);
-bool LowerCaseEqualsASCII(const char* aBegin, const char* aEnd, const char* bBegin, const char* bEnd);
-bool LowerCaseEqualsASCII(const UChar* aBegin, const UChar* aEnd, const char* b);
-
// Unescapes the given string using URL escaping rules.
void DecodeURLEscapeSequences(const char* input, int length, URLBuffer<UChar>&);
Modified: trunk/Source/WebCore/ChangeLog (130608 => 130609)
--- trunk/Source/WebCore/ChangeLog 2012-10-07 19:33:49 UTC (rev 130608)
+++ trunk/Source/WebCore/ChangeLog 2012-10-07 22:01:27 UTC (rev 130609)
@@ -1,3 +1,16 @@
+2012-10-07 Benjamin Poulain <[email protected]>
+
+ WTFURL: implement URL port removal for HTMLAnchorElement
+ https://bugs.webkit.org/show_bug.cgi?id=98604
+
+ Reviewed by Adam Barth.
+
+ * platform/KURLWTFURL.cpp:
+ (WebCore::KURL::hasPort):
+ (WebCore::KURL::removePort):
+ (WebCore::KURL::isHierarchical):
+ Implement those methods to pass the port removal test of HTMLAnchorElement.
+
2012-10-05 Dirk Schulze <[email protected]>
SVG radialGradient should support 'fr' for focal radius (just like Canvas)
Modified: trunk/Source/WebCore/platform/KURLWTFURL.cpp (130608 => 130609)
--- trunk/Source/WebCore/platform/KURLWTFURL.cpp 2012-10-07 19:33:49 UTC (rev 130608)
+++ trunk/Source/WebCore/platform/KURLWTFURL.cpp 2012-10-07 22:01:27 UTC (rev 130609)
@@ -175,7 +175,7 @@
if (!isValid())
return false;
- return !m_urlImpl->m_parsedURL.port().isNull();
+ return m_urlImpl->m_parsedURL.hasPort();
}
unsigned short KURL::port() const
@@ -313,8 +313,11 @@
void KURL::removePort()
{
+ if (!hasPort())
+ return;
+
detach(m_urlImpl);
- // FIXME: Add WTFURL Implementation.
+ m_urlImpl->m_parsedURL.removePort();
}
void KURL::setPort(unsigned short)
@@ -423,8 +426,9 @@
bool KURL::isHierarchical() const
{
- // FIXME: Add WTFURL Implementation.
- return false;
+ if (!isValid())
+ return false;
+ return m_urlImpl->m_parsedURL.hasStandardScheme();
}
bool protocolIs(const String&, const char*)