summaryrefslogtreecommitdiffstats
path: root/WebKit/android
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android')
-rw-r--r--WebKit/android/WebCoreSupport/WebResponse.cpp31
-rw-r--r--WebKit/android/nav/CachedNode.h3
-rw-r--r--WebKit/android/nav/CachedRoot.cpp6
3 files changed, 24 insertions, 16 deletions
diff --git a/WebKit/android/WebCoreSupport/WebResponse.cpp b/WebKit/android/WebCoreSupport/WebResponse.cpp
index e564215..113fb05 100644
--- a/WebKit/android/WebCoreSupport/WebResponse.cpp
+++ b/WebKit/android/WebCoreSupport/WebResponse.cpp
@@ -115,18 +115,25 @@ void WebResponse::setUrl(const string& url)
const string& WebResponse::getMimeType()
{
if (!m_mime.length() && m_url.length()) {
- WTF::String wtfMime(m_url.c_str(), m_url.length());
- // Need to strip fragment and/or query if present.
- size_t position = wtfMime.reverseFind('#');
- if (position != WTF::notFound)
- wtfMime.truncate(position);
-
- position = wtfMime.reverseFind('?');
- if (position != WTF::notFound)
- wtfMime.truncate(position);
-
- wtfMime = WebCore::MIMETypeRegistry::getMIMETypeForPath(wtfMime);
- m_mime = std::string(wtfMime.utf8().data(), wtfMime.length());
+ // Use "text/html" as a default (matching the behaviour of the Apache
+ // HTTP stack -- see guessMimeType() in LoadListener.java).
+ m_mime = "text/html";
+
+ // Try to guess a better MIME type from the URL. We call
+ // getMIMETypeForExtension rather than getMIMETypeForPath because the
+ // latter defaults to "application/octet-stream" on failure.
+ WebCore::KURL kurl(WebCore::ParsedURLString, m_url.c_str());
+ WTF::String path = kurl.path();
+ size_t extensionPos = path.reverseFind('.');
+ if (extensionPos != WTF::notFound) {
+ // We found a file extension.
+ path.remove(0, extensionPos + 1);
+ WTF::String mime = WebCore::MIMETypeRegistry::getMIMETypeForExtension(path);
+ if (!mime.isEmpty()) {
+ // Great, we found a MIME type.
+ m_mime = std::string(mime.utf8().data(), mime.length());
+ }
+ }
}
return m_mime;
diff --git a/WebKit/android/nav/CachedNode.h b/WebKit/android/nav/CachedNode.h
index db48a66..961018b 100644
--- a/WebKit/android/nav/CachedNode.h
+++ b/WebKit/android/nav/CachedNode.h
@@ -178,7 +178,8 @@ public:
const CachedNode* traverseNextNode() const { return mLast ? NULL : &this[1]; }
bool useBounds() const { return mUseBounds; }
bool useHitBounds() const { return mUseHitBounds; }
- bool wantsKeyEvents() const { return isTextInput() || isPlugin() || isContentEditable(); }
+ bool wantsKeyEvents() const { return isTextInput() || isPlugin()
+ || isContentEditable() || isFrame(); }
private:
friend class CacheBuilder;
WTF::String mExport;
diff --git a/WebKit/android/nav/CachedRoot.cpp b/WebKit/android/nav/CachedRoot.cpp
index d529a00..3823ec9 100644
--- a/WebKit/android/nav/CachedRoot.cpp
+++ b/WebKit/android/nav/CachedRoot.cpp
@@ -899,10 +899,10 @@ protected:
return false;
if (mLayerTypes.isEmpty() || mLayerTypes.last() != mType
|| !mAppendLikeTypes
- // if the last was a rect, and the current one is also a rect,
- // but the two rects have a gap between, don't join them -- push
+ // if the last and current were not glyphs,
+ // and the two bounds have a gap between, don't join them -- push
// an empty between them
- || (mType == kDrawRect_Type && !joinable(rect))) {
+ || (mType != kDrawGlyph_Type && !joinable(rect))) {
push(mType, mEmpty);
}
DBG_NAV_LOGD("RingCheck join %s (%d,%d,r=%d,b=%d) '%c'",