summaryrefslogtreecommitdiffstats
path: root/WebCore
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore')
-rw-r--r--WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp4
-rw-r--r--WebCore/dom/EventListener.h3
-rw-r--r--WebCore/loader/FrameLoader.cpp7
-rw-r--r--WebCore/page/Geolocation.cpp48
-rw-r--r--WebCore/page/Geolocation.h15
-rw-r--r--WebCore/platform/android/FileChooserAndroid.cpp16
-rw-r--r--WebCore/platform/android/FileSystemAndroid.cpp11
-rw-r--r--WebCore/platform/android/LocalizedStringsAndroid.cpp4
-rw-r--r--WebCore/platform/android/PlatformBridge.h4
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp28
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp54
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.h16
-rw-r--r--WebCore/platform/posix/FileSystemPOSIX.cpp2
13 files changed, 91 insertions, 121 deletions
diff --git a/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp b/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
index 008d1ab..8959189 100644
--- a/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
+++ b/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
@@ -198,7 +198,9 @@ JSValue JavaInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod
}
}
-#ifdef BUILDING_ON_TIGER
+// This is a deprecated code path which should not be required on Android.
+// Remove this guard once Bug 39476 is fixed.
+#if PLATFORM(ANDROID) || defined(BUILDING_ON_TIGER)
if (!handled) {
jobject obj = m_instance->m_instance;
switch (jMethod->JNIReturnType()) {
diff --git a/WebCore/dom/EventListener.h b/WebCore/dom/EventListener.h
index 249d3eb..d7c950f 100644
--- a/WebCore/dom/EventListener.h
+++ b/WebCore/dom/EventListener.h
@@ -41,8 +41,7 @@ namespace WebCore {
InspectorDOMAgentType,
InspectorDOMStorageResourceType,
ObjCEventListenerType,
- ConditionEventListenerType,
- GeolocationEventListenerType };
+ ConditionEventListenerType };
virtual ~EventListener() { }
virtual bool operator==(const EventListener&) = 0;
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index 125ee9b..f6b8f52 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -59,6 +59,7 @@
#include "FrameLoaderClient.h"
#include "FrameTree.h"
#include "FrameView.h"
+#include "Geolocation.h"
#include "HTMLAnchorElement.h"
#include "HTMLAppletElement.h"
#include "HTMLFormElement.h"
@@ -76,6 +77,7 @@
#include "Logging.h"
#include "MIMETypeRegistry.h"
#include "MainResourceLoader.h"
+#include "Navigator.h"
#include "Page.h"
#include "PageCache.h"
#include "PageGroup.h"
@@ -605,6 +607,11 @@ void FrameLoader::stopLoading(UnloadEventPolicy unloadEventPolicy, DatabasePolic
#endif
}
+ // Stop the Geolocation object, if present. This call is made after the unload
+ // event has fired, so no new Geolocation activity is possible.
+ if (m_frame->domWindow()->navigator()->optionalGeolocation())
+ m_frame->domWindow()->navigator()->optionalGeolocation()->stop();
+
// tell all subframes to stop as well
for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
child->loader()->stopLoading(unloadEventPolicy);
diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp
index 88e8941..49a4d84 100644
--- a/WebCore/page/Geolocation.cpp
+++ b/WebCore/page/Geolocation.cpp
@@ -31,10 +31,6 @@
#if ENABLE(GEOLOCATION)
#include "Chrome.h"
-// ANDROID
-#include "DOMWindow.h"
-#include "EventNames.h"
-// END ANDROID
#include "Frame.h"
#include "Page.h"
#if PLATFORM(ANDROID)
@@ -208,10 +204,7 @@ void Geolocation::Watchers::getNotifiersVector(Vector<RefPtr<GeoNotifier> >& cop
}
Geolocation::Geolocation(Frame* frame)
-// ANDROID
- : EventListener(GeolocationEventListenerType)
- , m_frame(frame)
-// END ANDROID
+ : m_frame(frame)
#if !ENABLE(CLIENT_BASED_GEOLOCATION)
, m_service(GeolocationService::create(this))
#endif
@@ -222,26 +215,23 @@ Geolocation::Geolocation(Frame* frame)
return;
ASSERT(m_frame->document());
m_frame->document()->setUsingGeolocation(true);
-
-// ANDROID
- if (m_frame->domWindow())
- m_frame->domWindow()->addEventListener(eventNames().unloadEvent, this, false);
-// END ANDROID
}
Geolocation::~Geolocation()
{
-// ANDROID
- if (m_frame && m_frame->domWindow())
- m_frame->domWindow()->removeEventListener(eventNames().unloadEvent, this, false);
-// END ANDROID
+}
+
+void Geolocation::stop()
+{
+ m_oneShots.clear();
+ m_watchers.clear();
+ stopUpdating();
}
void Geolocation::disconnectFrame()
{
if (m_frame && m_frame->page() && m_allowGeolocation == InProgress)
m_frame->page()->chrome()->cancelGeolocationPermissionRequestForFrame(m_frame, this);
- stopUpdating();
if (m_frame && m_frame->document())
m_frame->document()->setUsingGeolocation(false);
m_frame = 0;
@@ -684,26 +674,6 @@ void Geolocation::stopUpdating()
}
-// ANDROID
-bool Geolocation::operator==(const EventListener& listener)
-{
- if (listener.type() != GeolocationEventListenerType)
- return false;
- const Geolocation* geolocation = static_cast<const Geolocation*>(&listener);
- return m_frame == geolocation->m_frame;
-}
-
-void Geolocation::handleEvent(ScriptExecutionContext*, Event* event)
-{
- ASSERT_UNUSED(event, event->type() == eventNames().unloadEvent);
- // Cancel any ongoing requests on page unload. This is required to release
- // references to JS callbacks in the page, to allow the frame to be cleaned up
- // by WebKit.
- m_oneShots.clear();
- m_watchers.clear();
-}
-// END ANDROID
-
} // namespace WebCore
#else
@@ -720,6 +690,8 @@ Geolocation::~Geolocation() {}
void Geolocation::setIsAllowed(bool) {}
+void Geolocation::stop() {}
+
}
#endif // ENABLE(GEOLOCATION)
diff --git a/WebCore/page/Geolocation.h b/WebCore/page/Geolocation.h
index ba4f149..8803703 100644
--- a/WebCore/page/Geolocation.h
+++ b/WebCore/page/Geolocation.h
@@ -27,9 +27,6 @@
#ifndef Geolocation_h
#define Geolocation_h
-// ANDROID
-#include "EventListener.h"
-// END ANDROID
#include "GeolocationPositionCache.h"
#include "GeolocationService.h"
#include "Geoposition.h"
@@ -48,9 +45,7 @@ class GeolocationPosition;
class GeolocationError;
#endif
-// ANDROID
-class Geolocation : public EventListener
-// END ANDROID
+class Geolocation : public RefCounted<Geolocation>
#if !ENABLE(CLIENT_BASED_GEOLOCATION) && ENABLE(GEOLOCATION)
, public GeolocationServiceClient
#endif
@@ -70,6 +65,8 @@ public:
void suspend();
void resume();
+ void stop();
+
void setIsAllowed(bool);
Frame* frame() const { return m_frame; }
@@ -154,12 +151,6 @@ private:
PassRefPtr<GeoNotifier> startRequest(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>);
-// ANDROID
- // EventListener
- virtual bool operator==(const EventListener&);
- virtual void handleEvent(ScriptExecutionContext*, Event*);
-// END ANDROID
-
void fatalErrorOccurred(GeoNotifier*);
void requestTimedOut(GeoNotifier*);
void requestUsesCachedPosition(GeoNotifier*);
diff --git a/WebCore/platform/android/FileChooserAndroid.cpp b/WebCore/platform/android/FileChooserAndroid.cpp
index 1f8200f..f2ad3b9 100644
--- a/WebCore/platform/android/FileChooserAndroid.cpp
+++ b/WebCore/platform/android/FileChooserAndroid.cpp
@@ -25,22 +25,20 @@
#include "config.h"
#include "FileChooser.h"
+#include "FileSystem.h"
#include "Font.h"
+#include "LocalizedStrings.h"
+#include "StringTruncator.h"
namespace WebCore {
String FileChooser::basenameForWidth(const Font& font, int width) const
{
if (!m_filenames.size())
- return String();
- // FIXME: This could be a lot faster, but assuming the data will not
- // often be much longer than the provided width, this may be fast enough.
- // If this does not need to be threadsafe, we can use crossThreadString().
- // See http://trac.webkit.org/changeset/49160.
- String output = m_filenames[0].threadsafeCopy();
- while (font.width(TextRun(output.impl())) > width && output.length() > 4)
- output = output.replace(0, 4, String("..."));
- return output;
+ return fileButtonNoFileSelectedLabel();
+
+ String output = pathGetFileName(m_filenames[0]);
+ return StringTruncator::centerTruncate(output, static_cast<float>(width), font, false);
}
} // namespace WebCore
diff --git a/WebCore/platform/android/FileSystemAndroid.cpp b/WebCore/platform/android/FileSystemAndroid.cpp
index 3d841d7..cf9830e 100644
--- a/WebCore/platform/android/FileSystemAndroid.cpp
+++ b/WebCore/platform/android/FileSystemAndroid.cpp
@@ -28,6 +28,7 @@
#include "config.h"
#include "FileSystem.h"
+#include "PlatformBridge.h"
#include "StringBuilder.h"
#include "cutils/log.h"
#include <dirent.h>
@@ -106,4 +107,14 @@ Vector<String> listDirectory(const String& path, const String& filter)
return entries;
}
+String pathGetFileName(const String& path)
+{
+ // If the path is a content:// URI then ask Java to resolve it for us.
+ if (path.startsWith("content://"))
+ return PlatformBridge::resolveFileNameForContentUri(path);
+ else
+ return path.substring(path.reverseFind('/') + 1);
+}
+
+
} // namespace WebCore
diff --git a/WebCore/platform/android/LocalizedStringsAndroid.cpp b/WebCore/platform/android/LocalizedStringsAndroid.cpp
index e0db88d..5ca7fa2 100644
--- a/WebCore/platform/android/LocalizedStringsAndroid.cpp
+++ b/WebCore/platform/android/LocalizedStringsAndroid.cpp
@@ -48,8 +48,8 @@ String fileButtonChooseFileLabel()
String fileButtonNoFileSelectedLabel()
{
- notImplemented();
- return String();
+ return *(PlatformBridge::globalLocalizedName(
+ PlatformBridge::FileUploadNoFileChosenLabel));
}
String contextMenuItemTagInspectElement()
diff --git a/WebCore/platform/android/PlatformBridge.h b/WebCore/platform/android/PlatformBridge.h
index ad181e6..33f8697 100644
--- a/WebCore/platform/android/PlatformBridge.h
+++ b/WebCore/platform/android/PlatformBridge.h
@@ -119,7 +119,8 @@ public:
DrawableDir,
FileUploadLabel,
ResetLabel,
- SubmitLabel
+ SubmitLabel,
+ FileUploadNoFileChosenLabel
};
static String* globalLocalizedName(rawResId resId);
@@ -137,6 +138,7 @@ public:
static bool isWebViewPaused(const FrameView*);
static bool canScroll(const FrameView*);
+ static String resolveFileNameForContentUri(const String&);
};
}
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index 0d22719..c3df943 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -229,30 +229,39 @@ void GraphicsLayerAndroid::updateFixedPosition()
// If we are a fixed position layer, just set it
if (view->isPositioned() && view->style()->position() == FixedPosition) {
+ // We need to get the passed CSS properties for the element
SkLength left, top, right, bottom;
left = convertLength(view->style()->left());
top = convertLength(view->style()->top());
right = convertLength(view->style()->right());
bottom = convertLength(view->style()->bottom());
- // We need to pass the size of the element to compute the final fixed
- // position -- we can't use the layer's size as it could possibly differs.
- // We also have to use the visible overflow and not just the size,
- // as some child elements could be overflowing.
- int w = view->rightVisibleOverflow() - view->leftVisibleOverflow();
- int h = view->bottomVisibleOverflow() - view->topVisibleOverflow();
+ // We also need to get the margin...
SkLength marginLeft, marginTop, marginRight, marginBottom;
marginLeft = convertLength(view->style()->marginLeft());
marginTop = convertLength(view->style()->marginTop());
marginRight = convertLength(view->style()->marginRight());
marginBottom = convertLength(view->style()->marginBottom());
+ // The layer can be bigger than the element we want to draw;
+ // not only that, the layout rect of the element might also be
+ // different from the visible rect of that element (i.e. the element
+ // has a CSS shadow property -- the shadow is "outside" the element).
+ // We thus need to:
+ // 1/ get the size of the element (w,h), using the layoutOverflow rect
+ // 2/ pass the current offset of the painting relative to the layer
+ int w = view->rightLayoutOverflow() - view->leftLayoutOverflow();
+ int h = view->bottomLayoutOverflow() - view->topLayoutOverflow();
+ int paintingOffsetX = - offsetFromRenderer().width();
+ int paintingOffsetY = - offsetFromRenderer().height();
+
+ SkRect viewRect;
+ viewRect.set(paintingOffsetX, paintingOffsetY, paintingOffsetX + w, paintingOffsetY + h);
+
m_contentLayer->setFixedPosition(left, top, right, bottom,
marginLeft, marginTop,
marginRight, marginBottom,
- offsetFromRenderer().width(),
- offsetFromRenderer().height(),
- w, h);
+ viewRect);
}
}
@@ -283,6 +292,7 @@ void GraphicsLayerAndroid::setSize(const FloatSize& size)
MLOG("(%x) setSize (%.2f,%.2f)", this, size.width(), size.height());
GraphicsLayer::setSize(size);
m_contentLayer->setSize(size.width(), size.height());
+ updateFixedPosition();
askForSync();
}
}
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index 2f10d33..5aaa243 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -87,9 +87,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer),
m_fixedMarginTop = layer.m_fixedMarginTop;
m_fixedMarginRight = layer.m_fixedMarginRight;
m_fixedMarginBottom = layer.m_fixedMarginBottom;
- m_fixedOffset = layer.m_fixedOffset;
- m_fixedWidth = layer.m_fixedWidth;
- m_fixedHeight = layer.m_fixedHeight;
+ m_fixedRect = layer.m_fixedRect;
m_recordingPicture = layer.m_recordingPicture;
SkSafeRef(m_recordingPicture);
@@ -256,20 +254,6 @@ const LayerAndroid* LayerAndroid::find(int x, int y) const
///////////////////////////////////////////////////////////////////////////////
-// The Layer bounds and the renderview bounds are not always indentical.
-// We need to compute the intersection to correctly compute the
-// positiong...
-static SkRect computeLayerRect(LayerAndroid* layer) {
- SkRect layerRect, viewRect;
- SkScalar fX, fY;
- fX = layer->getOffset().fX;
- fY = layer->getOffset().fY;
- layerRect.set(0, 0, layer->getSize().width(), layer->getSize().height());
- viewRect.set(-fX, -fY, -fX + layer->getFixedWidth(), -fY + layer->getFixedHeight());
- layerRect.intersect(viewRect);
- return layerRect;
-}
-
void LayerAndroid::updateFixedLayersPositions(const SkRect& viewport)
{
if (m_isFixed) {
@@ -280,23 +264,21 @@ void LayerAndroid::updateFixedLayersPositions(const SkRect& viewport)
float x = dx;
float y = dy;
- SkRect layerRect = computeLayerRect(this);
-
// Not defined corresponds to 'auto';
- // so if right is auto, and left is auto, the w3c says we should set
- // left to zero (in left-to-right layout). So basically, if right is not
- // defined, we always apply auto.
- if (m_fixedRight.defined())
- x += w - m_fixedMarginRight.calcFloatValue(w) - m_fixedRight.calcFloatValue(w) - layerRect.width();
+ // If both left and right are auto, the w3c says we should set left
+ // to zero (in left-to-right layout). So we use left if it's defined
+ // or if right isn't defined.
+ if (m_fixedLeft.defined() || !m_fixedRight.defined())
+ x += m_fixedMarginLeft.calcFloatValue(w) + m_fixedLeft.calcFloatValue(w) - m_fixedRect.fLeft;
else
- x += m_fixedMarginLeft.calcFloatValue(w) + m_fixedLeft.calcFloatValue(w) - layerRect.fLeft;
+ x += w - m_fixedMarginRight.calcFloatValue(w) - m_fixedRight.calcFloatValue(w) - m_fixedRect.fRight;
// Following the same reason as above, if bottom isn't defined, we apply
// top regardless of it being defined or not.
- if (m_fixedBottom.defined())
- y += h - m_fixedMarginBottom.calcFloatValue(h) - m_fixedBottom.calcFloatValue(h) - layerRect.fTop - layerRect.height();
+ if (m_fixedTop.defined() || !m_fixedBottom.defined())
+ y += m_fixedMarginTop.calcFloatValue(h) + m_fixedTop.calcFloatValue(h) - m_fixedRect.fTop;
else
- y += m_fixedMarginTop.calcFloatValue(h) + m_fixedTop.calcFloatValue(h) - layerRect.fTop;
+ y += h - m_fixedMarginBottom.calcFloatValue(h) - m_fixedBottom.calcFloatValue(h) - m_fixedRect.fBottom;
this->setPosition(x, y);
}
@@ -375,10 +357,9 @@ void LayerAndroid::onDraw(SkCanvas* canvas, SkScalar opacity) {
canvas->drawLine(w, 0, 0, 0, paint);
if (m_isFixed) {
- SkRect layerRect = computeLayerRect(this);
SkPaint paint;
- paint.setARGB(128, 0, 0, 255);
- canvas->drawRect(layerRect, paint);
+ paint.setARGB(80, 255, 0, 0);
+ canvas->drawRect(m_fixedRect, paint);
}
#endif
}
@@ -513,6 +494,13 @@ void writeSize(FILE* file, int indentLevel, const char* str, SkSize size)
fprintf(file, "%s = { w = %.3f; h = %.3f; };\n", str, size.width(), size.height());
}
+void writeRect(FILE* file, int indentLevel, const char* str, SkRect rect)
+{
+ writeIndent(file, indentLevel);
+ fprintf(file, "%s = { x = %.3f; y = %.3f; w = %.3f; h = %.3f; };\n",
+ str, rect.fLeft, rect.fTop, rect.width(), rect.height());
+}
+
void writeLength(FILE* file, int indentLevel, const char* str, SkLength length)
{
if (!length.defined()) return;
@@ -549,9 +537,7 @@ void LayerAndroid::dumpLayers(FILE* file, int indentLevel) const
writeLength(file, indentLevel + 1, "fixedMarginTop", m_fixedMarginTop);
writeLength(file, indentLevel + 1, "fixedMarginRight", m_fixedMarginRight);
writeLength(file, indentLevel + 1, "fixedMarginBottom", m_fixedMarginBottom);
- writePoint(file, indentLevel + 1, "fixedOffset", m_fixedOffset);
- writeIntVal(file, indentLevel + 1, "fixedWidth", m_fixedWidth);
- writeIntVal(file, indentLevel + 1, "fixedHeight", m_fixedHeight);
+ writeRect(file, indentLevel + 1, "fixedRect", m_fixedRect);
}
if (m_recordingPicture) {
diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h
index 2b106d1..b6b6f70 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/WebCore/platform/graphics/android/LayerAndroid.h
@@ -104,10 +104,7 @@ public:
SkLength marginTop, // CSS margin-top property
SkLength marginRight, // CSS margin-right property
SkLength marginBottom, // CSS margin-bottom property
- int offsetX, // X Offset from the renderer
- int offsetY, // Y Offset from the renderer
- int width, // visible overflow width
- int height) { // visible overflow height
+ SkRect viewRect) { // view rect, can be smaller than the layer's
m_fixedLeft = left;
m_fixedTop = top;
m_fixedRight = right;
@@ -116,9 +113,7 @@ public:
m_fixedMarginTop = marginTop;
m_fixedMarginRight = marginRight;
m_fixedMarginBottom = marginBottom;
- m_fixedOffset.set(offsetX, offsetY);
- m_fixedWidth = width;
- m_fixedHeight = height;
+ m_fixedRect = viewRect;
m_isFixed = true;
setInheritFromRootTransform(true);
}
@@ -171,9 +166,6 @@ public:
void setExtra(DrawExtra* extra); // does not assign ownership
int uniqueId() const { return m_uniqueId; }
bool isFixed() { return m_isFixed; }
- const SkPoint& getOffset() const { return m_fixedOffset; }
- int getFixedWidth() { return m_fixedWidth; }
- int getFixedHeight() { return m_fixedHeight; }
/** This sets a content image -- calling it means we will use
the image directly when drawing the layer instead of using
@@ -208,9 +200,7 @@ private:
SkLength m_fixedMarginTop;
SkLength m_fixedMarginRight;
SkLength m_fixedMarginBottom;
- SkPoint m_fixedOffset;
- int m_fixedWidth;
- int m_fixedHeight;
+ SkRect m_fixedRect;
SkPoint m_translation;
SkPoint m_scale;
diff --git a/WebCore/platform/posix/FileSystemPOSIX.cpp b/WebCore/platform/posix/FileSystemPOSIX.cpp
index ac8c7fa..b7fcd71 100644
--- a/WebCore/platform/posix/FileSystemPOSIX.cpp
+++ b/WebCore/platform/posix/FileSystemPOSIX.cpp
@@ -213,10 +213,12 @@ bool makeAllDirectories(const String& path)
return true;
}
+#if !PLATFORM(ANDROID)
String pathGetFileName(const String& path)
{
return path.substring(path.reverseFind('/') + 1);
}
+#endif
String directoryName(const String& path)
{