Chromium Code Reviews| Index: Source/weborigin/KURL.cpp |
| diff --git a/Source/weborigin/KURL.cpp b/Source/weborigin/KURL.cpp |
| index d4501b3ccb10feed23211499e5f1858e56e49a0f..650ac8ac4560569348c7b2eab801f890b115c857 100644 |
| --- a/Source/weborigin/KURL.cpp |
| +++ b/Source/weborigin/KURL.cpp |
| @@ -297,7 +297,7 @@ bool KURL::hasPath() const |
| // which can lead to different results in some cases. |
| String KURL::lastPathComponent() const |
| { |
| - if (!m_isValid) |
| + if (m_string.isNull() || !m_isValid) |
| return stringForInvalidComponent(); |
| // When the output ends in a slash, WebCore has different expectations than |
| @@ -308,7 +308,7 @@ String KURL::lastPathComponent() const |
| path.len--; |
| url_parse::Component file; |
| - if (!m_string.isNull() && m_string.is8Bit()) |
| + if (m_string.is8Bit()) |
| url_parse::ExtractFileName(asURLChar8Subtle(m_string), path, &file); |
| else |
| url_parse::ExtractFileName(m_string.characters16(), path, &file); |
| @@ -337,13 +337,11 @@ String KURL::host() const |
| // return invalidPortNumber from this port() function, so we mirror that behavior here. |
| unsigned short KURL::port() const |
| { |
| - if (!m_isValid || m_parsed.port.len <= 0) |
| + if (m_string.isNull() || !m_isValid || m_parsed.port.len <= 0) |
| return 0; |
| - int port = 0; |
| - if (!m_string.isNull() && m_string.is8Bit()) |
| - port = url_parse::ParsePort(asURLChar8Subtle(m_string), m_parsed.port); |
| - else |
| - port = url_parse::ParsePort(m_string.characters16(), m_parsed.port); |
| + int port = m_string.is8Bit() ? |
| + url_parse::ParsePort(asURLChar8Subtle(m_string), m_parsed.port) : |
| + url_parse::ParsePort(m_string.characters16(), m_parsed.port); |
| ASSERT(port != url_parse::PORT_UNSPECIFIED); // Checked port.len <= 0 before. |
| if (port == url_parse::PORT_INVALID || port > maximumValidPortNumber) // Mimic KURL::port() |
| @@ -624,11 +622,12 @@ String encodeWithURLEscapeSequences(const String& notEncodedString) |
| bool KURL::isHierarchical() const |
| { |
| - if (!m_parsed.scheme.is_nonempty()) |
| + if (m_string.isNull() || !m_parsed.scheme.is_nonempty()) |
| return false; |
| - if (!m_string.isNull() && m_string.is8Bit()) |
| - return url_util::IsStandard(asURLChar8Subtle(m_string), m_parsed.scheme); |
| - return url_util::IsStandard(m_string.characters16(), m_parsed.scheme); |
| + |
| + return m_string.is8Bit() ? |
| + url_util::IsStandard(asURLChar8Subtle(m_string), m_parsed.scheme) : |
| + url_util::IsStandard(m_string.characters16(), m_parsed.scheme); |
| } |
| #ifndef NDEBUG |
| @@ -686,11 +685,12 @@ unsigned KURL::pathEnd() const |
| unsigned KURL::pathAfterLastSlash() const |
| { |
| + if (m_string.isNull()) |
| + return 0; |
| if (!m_isValid || !m_parsed.path.is_valid()) |
| return m_parsed.CountCharactersBefore(url_parse::Parsed::PATH, false); |
| - |
| url_parse::Component filename; |
| - if (!m_string.isNull() && m_string.is8Bit()) |
| + if (m_string.is8Bit()) |
| url_parse::ExtractFileName(asURLChar8Subtle(m_string), m_parsed.path, &filename); |
| else |
| url_parse::ExtractFileName(m_string.characters16(), m_parsed.path, &filename); |
| @@ -783,15 +783,14 @@ bool checkIfProtocolIsInHTTPFamily(const url_parse::Component& scheme, const CHA |
| void KURL::initProtocolIsInHTTPFamily() |
| { |
| - if (!m_isValid) { |
| + if (m_string.isNull() || !m_isValid) { |
|
abarth-chromium
2013/09/17 19:48:35
Shouldn't m_string.isNull() imply !m_isValid?
Tom Sepez
2013/09/17 19:55:38
Yep. Just confirmed this one worked previously. H
|
| m_protocolIsInHTTPFamily = false; |
| return; |
| } |
| - if (!m_string.isNull() && m_string.is8Bit()) |
| - m_protocolIsInHTTPFamily = checkIfProtocolIsInHTTPFamily(m_parsed.scheme, m_string.characters8()); |
| - else |
| - m_protocolIsInHTTPFamily = checkIfProtocolIsInHTTPFamily(m_parsed.scheme, m_string.characters16()); |
| + m_protocolIsInHTTPFamily = m_string.is8Bit() ? |
| + checkIfProtocolIsInHTTPFamily(m_parsed.scheme, m_string.characters8()) : |
| + checkIfProtocolIsInHTTPFamily(m_parsed.scheme, m_string.characters16()); |
| } |
| bool KURL::protocolIs(const char* protocol) const |
| @@ -802,11 +801,12 @@ bool KURL::protocolIs(const char* protocol) const |
| // The free function protocolIsJavaScript() should be used instead. |
| // FIXME: Chromium code needs to be fixed for this assert to be enabled. ASSERT(strcmp(protocol, "javascript")); |
| - if (m_parsed.scheme.len <= 0) |
| - return !protocol; |
| - if (!m_string.isNull() && m_string.is8Bit()) |
| - return internalProtocolIs(m_parsed.scheme, m_string.characters8(), protocol); |
| - return internalProtocolIs(m_parsed.scheme, m_string.characters16(), protocol); |
| + if (m_string.isNull() || m_parsed.scheme.len <= 0) |
| + return *protocol == '\0'; |
| + |
| + return m_string.is8Bit() ? |
| + internalProtocolIs(m_parsed.scheme, m_string.characters8(), protocol) : |
| + internalProtocolIs(m_parsed.scheme, m_string.characters16(), protocol); |
| } |
| String KURL::stringForInvalidComponent() const |