diff options
Diffstat (limited to 'Source/WebCore/platform/android')
29 files changed, 4305 insertions, 0 deletions
diff --git a/Source/WebCore/platform/android/ClipboardAndroid.cpp b/Source/WebCore/platform/android/ClipboardAndroid.cpp new file mode 100644 index 0000000..a91fd21 --- /dev/null +++ b/Source/WebCore/platform/android/ClipboardAndroid.cpp @@ -0,0 +1,120 @@ +/* + * Copyright 2009, The Android Open Source Project + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ClipboardAndroid.h" + +#include "CachedImage.h" +#include "Element.h" +#include "FileList.h" +#include "Frame.h" +#include "Range.h" + +namespace WebCore { + +PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy, DragData*, Frame*) +{ + return 0; +} + +ClipboardAndroid::ClipboardAndroid(ClipboardAccessPolicy policy, ClipboardType clipboardType) + : Clipboard(policy, clipboardType) +{ +} + +ClipboardAndroid::~ClipboardAndroid() +{ +} + +void ClipboardAndroid::clearData(const String&) +{ + ASSERT(isForDragAndDrop()); +} + +void ClipboardAndroid::clearAllData() +{ + ASSERT(isForDragAndDrop()); +} + +String ClipboardAndroid::getData(const String&, bool& success) const +{ + success = false; + return ""; +} + +bool ClipboardAndroid::setData(const String&, const String&) +{ + ASSERT(isForDragAndDrop()); + return false; +} + +// extensions beyond IE's API +HashSet<String> ClipboardAndroid::types() const +{ + return HashSet<String>(); +} + +PassRefPtr<FileList> ClipboardAndroid::files() const +{ + return 0; +} + +void ClipboardAndroid::setDragImage(CachedImage*, const IntPoint&) +{ +} + +void ClipboardAndroid::setDragImageElement(Node*, const IntPoint&) +{ +} + +DragImageRef ClipboardAndroid::createDragImage(IntPoint&) const +{ + return 0; +} + +void ClipboardAndroid::declareAndWriteDragImage(Element*, const KURL&, const String&, Frame*) +{ +} + +void ClipboardAndroid::writeURL(const KURL&, const String&, Frame*) +{ +} + +void ClipboardAndroid::writeRange(Range* selectedRange, Frame*) +{ + ASSERT(selectedRange); +} + +void ClipboardAndroid::writePlainText(const String&) +{ +} + +bool ClipboardAndroid::hasData() +{ + return false; +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/ClipboardAndroid.h b/Source/WebCore/platform/android/ClipboardAndroid.h new file mode 100644 index 0000000..807653b --- /dev/null +++ b/Source/WebCore/platform/android/ClipboardAndroid.h @@ -0,0 +1,66 @@ +/* + * Copyright 2009, The Android Open Source Project + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ClipboardAndroid_h +#define ClipboardAndroid_h + +#include "Clipboard.h" + +#include "CachedResourceClient.h" + +namespace WebCore { + +class CachedImage; + +class ClipboardAndroid : public Clipboard, public CachedResourceClient { +public: + ClipboardAndroid(ClipboardAccessPolicy policy, ClipboardType); + ~ClipboardAndroid(); + + void clearData(const String&); + void clearAllData(); + String getData(const String&, bool& success) const; + bool setData(const String&, const String&); + + // extensions beyond IE's API + HashSet<String> types() const; + PassRefPtr<FileList> files() const; + + void setDragImage(CachedImage*, const IntPoint&); + void setDragImageElement(Node*, const IntPoint&); + + virtual DragImageRef createDragImage(IntPoint&) const; + virtual void declareAndWriteDragImage(Element*, const KURL&, const String&, Frame*); + virtual void writeURL(const KURL&, const String&, Frame*); + virtual void writeRange(Range*, Frame*); + virtual void writePlainText(const String&); + + virtual bool hasData(); +}; + +} // namespace WebCore + +#endif // ClipboardAndroid_h diff --git a/Source/WebCore/platform/android/CursorAndroid.cpp b/Source/WebCore/platform/android/CursorAndroid.cpp new file mode 100644 index 0000000..beef3b2 --- /dev/null +++ b/Source/WebCore/platform/android/CursorAndroid.cpp @@ -0,0 +1,298 @@ +/* + * Copyright 2009, The Android Open Source Project + * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define LOG_TAG "WebCore" + +#include "config.h" +#include "Cursor.h" + +#include "NotImplemented.h" + +namespace WebCore { + +Cursor::Cursor(Image*, const IntPoint&) +{ + notImplemented(); +} + +Cursor::Cursor(const Cursor&) +{ + notImplemented(); +} + +Cursor::~Cursor() +{ + notImplemented(); +} + +Cursor& Cursor::operator=(const Cursor&) +{ + notImplemented(); + return *this; +} + +static Cursor c; +const Cursor& pointerCursor() +{ + notImplemented(); + return c; +} + +const Cursor& crossCursor() +{ + notImplemented(); + return c; +} + +const Cursor& handCursor() +{ + notImplemented(); + return c; +} + +const Cursor& moveCursor() +{ + notImplemented(); + return c; +} + +const Cursor& iBeamCursor() +{ + notImplemented(); + return c; +} + +const Cursor& waitCursor() +{ + notImplemented(); + return c; +} + +const Cursor& helpCursor() +{ + notImplemented(); + return c; +} + +const Cursor& eastResizeCursor() +{ + notImplemented(); + return c; +} + +const Cursor& northResizeCursor() +{ + notImplemented(); + return c; +} + +const Cursor& northEastResizeCursor() +{ + notImplemented(); + return c; +} + +const Cursor& northWestResizeCursor() +{ + notImplemented(); + return c; +} + +const Cursor& southResizeCursor() +{ + notImplemented(); + return c; +} + +const Cursor& southEastResizeCursor() +{ + notImplemented(); + return c; +} + +const Cursor& southWestResizeCursor() +{ + notImplemented(); + return c; +} + +const Cursor& westResizeCursor() +{ + notImplemented(); + return c; +} + +const Cursor& northSouthResizeCursor() +{ + notImplemented(); + return c; +} + +const Cursor& eastWestResizeCursor() +{ + notImplemented(); + return c; +} + +const Cursor& northEastSouthWestResizeCursor() +{ + notImplemented(); + return c; +} + +const Cursor& northWestSouthEastResizeCursor() +{ + notImplemented(); + return c; +} + +const Cursor& columnResizeCursor() +{ + notImplemented(); + return c; +} + +const Cursor& rowResizeCursor() +{ + notImplemented(); + return c; +} + +const Cursor& verticalTextCursor() +{ + notImplemented(); + return c; +} + +const Cursor& cellCursor() +{ + notImplemented(); + return c; +} + +const Cursor& contextMenuCursor() +{ + notImplemented(); + return c; +} + +const Cursor& noDropCursor() +{ + notImplemented(); + return c; +} + +const Cursor& copyCursor() +{ + notImplemented(); + return c; +} + +const Cursor& progressCursor() +{ + notImplemented(); + return c; +} + +const Cursor& aliasCursor() +{ + notImplemented(); + return c; +} + +const Cursor& noneCursor() +{ + notImplemented(); + return c; +} + +const Cursor& middlePanningCursor() +{ + notImplemented(); + return c; +} + +const Cursor& eastPanningCursor() +{ + notImplemented(); + return c; +} + +const Cursor& northPanningCursor() +{ + notImplemented(); + return c; +} + +const Cursor& northEastPanningCursor() +{ + notImplemented(); + return c; +} + +const Cursor& northWestPanningCursor() +{ + notImplemented(); + return c; +} + +const Cursor& southPanningCursor() +{ + notImplemented(); + return c; +} + +const Cursor& southEastPanningCursor() +{ + notImplemented(); + return c; +} + +const Cursor& southWestPanningCursor() +{ + notImplemented(); + return c; +} + +const Cursor& westPanningCursor() +{ + notImplemented(); + return c; +} + +const Cursor& grabCursor() +{ + notImplemented(); + return c; +} + +const Cursor& grabbingCursor() +{ + notImplemented(); + return c; +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/DragDataAndroid.cpp b/Source/WebCore/platform/android/DragDataAndroid.cpp new file mode 100644 index 0000000..4e99b2c --- /dev/null +++ b/Source/WebCore/platform/android/DragDataAndroid.cpp @@ -0,0 +1,90 @@ +/* + * Copyright 2009, The Android Open Source Project + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "DragData.h" + +#include "Document.h" +#include "DocumentFragment.h" + +namespace WebCore { + +bool DragData::canSmartReplace() const +{ + return false; +} + +bool DragData::containsColor() const +{ + return false; +} + +bool DragData::containsPlainText() const +{ + return false; +} + +String DragData::asPlainText() const +{ + return String(); +} + +Color DragData::asColor() const +{ + return Color(); +} + +bool DragData::containsCompatibleContent() const +{ + return false; +} + +bool DragData::containsURL(FilenameConversionPolicy) const +{ + return false; +} + +String DragData::asURL(FilenameConversionPolicy, String*) const +{ + return String(); +} + + +PassRefPtr<DocumentFragment> DragData::asFragment(Document*) const +{ + return 0; +} + +void DragData::asFilenames(Vector<String>&) const +{ +} + +bool DragData::containsFiles() const +{ + return false; +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/EventLoopAndroid.cpp b/Source/WebCore/platform/android/EventLoopAndroid.cpp new file mode 100644 index 0000000..3a6d7ed --- /dev/null +++ b/Source/WebCore/platform/android/EventLoopAndroid.cpp @@ -0,0 +1,38 @@ +/* + * Copyright 2008, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "EventLoop.h" + +#include "NotImplemented.h" + +namespace WebCore { + +void EventLoop::cycle() +{ + notImplemented(); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/FileChooserAndroid.cpp b/Source/WebCore/platform/android/FileChooserAndroid.cpp new file mode 100644 index 0000000..f2ad3b9 --- /dev/null +++ b/Source/WebCore/platform/android/FileChooserAndroid.cpp @@ -0,0 +1,44 @@ +/* + * Copyright 2006, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#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 fileButtonNoFileSelectedLabel(); + + String output = pathGetFileName(m_filenames[0]); + return StringTruncator::centerTruncate(output, static_cast<float>(width), font, false); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/FileSystemAndroid.cpp b/Source/WebCore/platform/android/FileSystemAndroid.cpp new file mode 100644 index 0000000..9ed43f0 --- /dev/null +++ b/Source/WebCore/platform/android/FileSystemAndroid.cpp @@ -0,0 +1,126 @@ +/* + * Copyright 2009, The Android Open Source Project + * Copyright (C) 2007 Holger Hans Peter Freyther + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "FileSystem.h" + +#include "PlatformBridge.h" +#include "cutils/log.h" +#include <dirent.h> +#include <dlfcn.h> +#include <errno.h> +#include <fnmatch.h> +#include <sys/stat.h> +#include <wtf/text/CString.h> +#include <wtf/text/StringBuilder.h> + +namespace WebCore { + +// Global static used to store the base to the plugin path. +// This is set in WebSettings.cpp +String sPluginPath; + +CString fileSystemRepresentation(const String& path) +{ + // If the path is a content:// URI then ask Java to resolve it for us. + if (path.startsWith("content://")) + return PlatformBridge::resolveFilePathForContentUri(path).utf8(); + else if (path.startsWith("file://")) + return path.substring(strlen("file://")).utf8(); + + return path.utf8(); +} + +CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle) +{ + int number = rand() % 10000 + 1; + CString filename; + do { + StringBuilder builder; + builder.append(sPluginPath); + builder.append('/'); + builder.append(prefix); + builder.append(String::number(number)); + filename = builder.toString().utf8(); + const char* fstr = filename.data(); + handle = open(filename.data(), O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); + number++; + + if (handle != -1) + return filename; + } while (errno == EEXIST); + + return CString(); +} + +bool unloadModule(PlatformModule module) +{ + return !dlclose(module); +} + +String homeDirectoryPath() +{ + return sPluginPath; +} + +Vector<String> listDirectory(const String& path, const String& filter) +{ + Vector<String> entries; + CString cpath = path.utf8(); + CString cfilter = filter.utf8(); + DIR* dir = opendir(cpath.data()); + if (dir) { + struct dirent* dp; + while ((dp = readdir(dir))) { + const char* name = dp->d_name; + if (!strcmp(name, ".") || !strcmp(name, "..")) + continue; + if (fnmatch(cfilter.data(), name, 0)) + continue; + char filePath[1024]; + if (static_cast<int>(sizeof(filePath) - 1) < snprintf(filePath, sizeof(filePath), "%s/%s", cpath.data(), name)) + continue; // buffer overflow + entries.append(filePath); + } + closedir(dir); + } + return entries; +} + +// We define our own pathGetFileName rather than use the POSIX versions as we +// may get passed a content URI representing the path to the file. We pass +// the input through fileSystemRepresentation before using it to resolve it if +// it is a content URI. +String pathGetFileName(const String& path) +{ + CString fsRep = fileSystemRepresentation(path); + String fsPath = String(fsRep.data()); + return fsPath.substring(fsPath.reverseFind('/') + 1); +} + + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/GeolocationServiceAndroid.cpp b/Source/WebCore/platform/android/GeolocationServiceAndroid.cpp new file mode 100644 index 0000000..0f07722 --- /dev/null +++ b/Source/WebCore/platform/android/GeolocationServiceAndroid.cpp @@ -0,0 +1,204 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "GeolocationServiceAndroid.h" + +#include "Geolocation.h" +#include "GeolocationServiceBridge.h" +#include "Geoposition.h" +#include "PositionError.h" +#include "PositionOptions.h" + +#if PLATFORM(ANDROID) +// Required for sim-eng build +#include <math.h> +#endif +#include <wtf/CurrentTime.h> + +using JSC::Bindings::getJNIEnv; +using namespace std; + +namespace WebCore { + +// GeolocationServiceAndroid is the Android implmentation of Geolocation +// service. Each object of this class owns an object of type +// GeolocationServiceBridge, which in turn owns a Java GeolocationService +// object. Therefore, there is a 1:1 mapping between Geolocation, +// GeolocationServiceAndroid, GeolocationServiceBridge and Java +// GeolocationService objects. In the case where multiple Geolocation objects +// exist simultaneously, the corresponsing Java GeolocationService objects all +// register with the platform location service. It is the platform service that +// handles making sure that updates are passed to all Geolocation objects. +GeolocationService* GeolocationServiceAndroid::create(GeolocationServiceClient* client) +{ + return new GeolocationServiceAndroid(client); +} + +GeolocationService::FactoryFunction* GeolocationService::s_factoryFunction = &GeolocationServiceAndroid::create; + +GeolocationServiceAndroid::GeolocationServiceAndroid(GeolocationServiceClient* client) + : GeolocationService(client) + , m_timer(this, &GeolocationServiceAndroid::timerFired) + , m_javaBridge(0) +{ +} + +// ANDROID +// TODO: Upstream to webkit.org. See https://bugs.webkit.org/show_bug.cgi?id=34082 +bool GeolocationServiceAndroid::startUpdating(PositionOptions* options, bool suspend) +{ + // ANDROID + // This is an ugly hack. A correct fix would require a change to WebCore, + // but this isn't worth the effort as we're in the process of switching to a + // client-based implementation. See https://bugs.webkit.org/show_bug.cgi?id=40373 + Frame* frame = reinterpret_cast<Geolocation*>(geolocationServiceClient())->frame(); + if (!frame) + return false; + + // This method is called every time a new watch or one-shot position request + // is started. If we already have a position or an error, call back + // immediately. + if (m_lastPosition || m_lastError) { + ASSERT(m_javaBridge); + m_timer.startOneShot(0); + } + + // Lazilly create the Java object. + bool haveJavaBridge = m_javaBridge; + if (!haveJavaBridge) + m_javaBridge.set(new GeolocationServiceBridge(this, frame)); + ASSERT(m_javaBridge); + + // On Android, high power == GPS. Set whether to use GPS before we start the + // implementation. + ASSERT(options); + if (options->enableHighAccuracy()) + m_javaBridge->setEnableGps(true); + + // We need only start the service when it's first created. + if (!haveJavaBridge) { + // If the browser is paused, don't start the service. It will be started + // when we get the call to resume. + // ANDROID + // TODO: Upstream to webkit.org. See https://bugs.webkit.org/show_bug.cgi?id=34082 + if (!suspend) + return m_javaBridge->start(); + } + + return true; +} + +void GeolocationServiceAndroid::stopUpdating() +{ + // Called when the Geolocation object has no watches or one shots in + // progress. This may be called repeatedly. + m_javaBridge.clear(); + // Reset last position and error to make sure that we always try to get a + // new position from the system service when a request is first made. + m_lastPosition = 0; + m_lastError = 0; + // remove the pending timer + if (m_timer.isActive()) + m_timer.stop(); +} + +void GeolocationServiceAndroid::suspend() +{ + if (m_javaBridge) + m_javaBridge->stop(); +} + +void GeolocationServiceAndroid::resume() +{ + if (m_javaBridge) + m_javaBridge->start(); +} + +// Note that there is no guarantee that subsequent calls to this method offer a +// more accurate or updated position. +void GeolocationServiceAndroid::newPositionAvailable(PassRefPtr<Geoposition> position) +{ + ASSERT(position); + if (!m_lastPosition + || isPositionMovement(m_lastPosition.get(), position.get()) + || isPositionMoreAccurate(m_lastPosition.get(), position.get()) + || isPositionMoreTimely(m_lastPosition.get(), position.get())) { + m_lastPosition = position; + // Remove the last error. + m_lastError = 0; + positionChanged(); + } +} + +void GeolocationServiceAndroid::newErrorAvailable(PassRefPtr<PositionError> error) +{ + ASSERT(error); + // We leave the last position + m_lastError = error; + errorOccurred(); +} + +void GeolocationServiceAndroid::timerFired(Timer<GeolocationServiceAndroid>* timer) +{ + ASSERT(&m_timer == timer); + ASSERT(m_lastPosition || m_lastError); + if (m_lastPosition) + positionChanged(); + else if (m_lastError) + errorOccurred(); +} + +bool GeolocationServiceAndroid::isPositionMovement(Geoposition* position1, Geoposition* position2) +{ + ASSERT(position1 && position2); + // For the small distances in which we are likely concerned, it's reasonable + // to approximate the distance between the two positions as the sum of the + // differences in latitude and longitude. + double delta = fabs(position1->coords()->latitude() - position2->coords()->latitude()) + + fabs(position1->coords()->longitude() - position2->coords()->longitude()); + // Approximate conversion from degrees of arc to metres. + delta *= 60 * 1852; + // The threshold is when the distance between the two positions exceeds the + // worse (larger) of the two accuracies. + int maxAccuracy = max(position1->coords()->accuracy(), position2->coords()->accuracy()); + return delta > maxAccuracy; +} + +bool GeolocationServiceAndroid::isPositionMoreAccurate(Geoposition* position1, Geoposition* position2) +{ + ASSERT(position1 && position2); + return position2->coords()->accuracy() < position1->coords()->accuracy(); +} + +bool GeolocationServiceAndroid::isPositionMoreTimely(Geoposition* position1, Geoposition* position2) +{ + ASSERT(position1 && position2); + DOMTimeStamp currentTime = convertSecondsToDOMTimeStamp(WTF::currentTime()); + DOMTimeStamp maximumAge = convertSecondsToDOMTimeStamp(10 * 60); // 10 minutes + return currentTime - position1->timestamp() > maximumAge; +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/GeolocationServiceAndroid.h b/Source/WebCore/platform/android/GeolocationServiceAndroid.h new file mode 100644 index 0000000..72532f6 --- /dev/null +++ b/Source/WebCore/platform/android/GeolocationServiceAndroid.h @@ -0,0 +1,79 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef GeolocationServiceAndroid_h +#define GeolocationServiceAndroid_h + +#include "GeolocationService.h" +#include "Timer.h" +#include <wtf/OwnPtr.h> +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +// The GeolocationServiceBridge is the bridge to the Java implementation of +// the Geolocation service. It is an implementation detail of +// GeolocationServiceAndroid. +class GeolocationServiceBridge; + +class GeolocationServiceAndroid : public GeolocationService { +public: + static GeolocationService* create(GeolocationServiceClient*); + + virtual ~GeolocationServiceAndroid() { }; + + // ANDROID + // TODO: Upstream to webkit.org. See https://bugs.webkit.org/show_bug.cgi?id=34082 + virtual bool startUpdating(PositionOptions*, bool suspend); + virtual void stopUpdating(); + + virtual Geoposition* lastPosition() const { return m_lastPosition.get(); } + virtual PositionError* lastError() const { return m_lastError.get(); } + + virtual void suspend(); + virtual void resume(); + + // Android-specific + void newPositionAvailable(PassRefPtr<Geoposition>); + void newErrorAvailable(PassRefPtr<PositionError>); + void timerFired(Timer<GeolocationServiceAndroid>* timer); + +private: + GeolocationServiceAndroid(GeolocationServiceClient*); + + static bool isPositionMovement(Geoposition* position1, Geoposition* position2); + static bool isPositionMoreAccurate(Geoposition* position1, Geoposition* position2); + static bool isPositionMoreTimely(Geoposition* position1, Geoposition* position2); + + Timer<GeolocationServiceAndroid> m_timer; + RefPtr<Geoposition> m_lastPosition; + RefPtr<PositionError> m_lastError; + OwnPtr<GeolocationServiceBridge> m_javaBridge; +}; + +} // namespace WebCore + +#endif // GeolocationServiceAndroid_h diff --git a/Source/WebCore/platform/android/GeolocationServiceBridge.cpp b/Source/WebCore/platform/android/GeolocationServiceBridge.cpp new file mode 100644 index 0000000..2e81b32 --- /dev/null +++ b/Source/WebCore/platform/android/GeolocationServiceBridge.cpp @@ -0,0 +1,239 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "GeolocationServiceBridge.h" + +#include "Frame.h" +#include "GeolocationServiceAndroid.h" +#include "Geoposition.h" +#include "PositionError.h" +#include "WebViewCore.h" +#include <JNIHelp.h> + +namespace WebCore { + +using JSC::Bindings::getJNIEnv; + +static const char* javaGeolocationServiceClassName = "android/webkit/GeolocationService"; +enum javaGeolocationServiceClassMethods { + GeolocationServiceMethodInit = 0, + GeolocationServiceMethodStart, + GeolocationServiceMethodStop, + GeolocationServiceMethodSetEnableGps, + GeolocationServiceMethodCount, +}; +static jmethodID javaGeolocationServiceClassMethodIDs[GeolocationServiceMethodCount]; + +static const JNINativeMethod javaGeolocationServiceClassNativeMethods[] = { + { "nativeNewLocationAvailable", "(JLandroid/location/Location;)V", + (void*) GeolocationServiceBridge::newLocationAvailable }, + { "nativeNewErrorAvailable", "(JLjava/lang/String;)V", + (void*) GeolocationServiceBridge::newErrorAvailable } +}; + +static const char *javaLocationClassName = "android/location/Location"; +enum javaLocationClassMethods { + LocationMethodGetLatitude = 0, + LocationMethodGetLongitude, + LocationMethodHasAltitude, + LocationMethodGetAltitude, + LocationMethodHasAccuracy, + LocationMethodGetAccuracy, + LocationMethodHasBearing, + LocationMethodGetBearing, + LocationMethodHasSpeed, + LocationMethodGetSpeed, + LocationMethodGetTime, + LocationMethodCount, +}; +static jmethodID javaLocationClassMethodIDs[LocationMethodCount]; + +GeolocationServiceBridge::GeolocationServiceBridge(ListenerInterface* listener, Frame* frame) + : m_listener(listener) + , m_javaGeolocationServiceObject(0) +{ + ASSERT(m_listener); + startJavaImplementation(frame); +} + +GeolocationServiceBridge::~GeolocationServiceBridge() +{ + stop(); + stopJavaImplementation(); +} + +bool GeolocationServiceBridge::start() +{ + ASSERT(m_javaGeolocationServiceObject); + return getJNIEnv()->CallBooleanMethod(m_javaGeolocationServiceObject, + javaGeolocationServiceClassMethodIDs[GeolocationServiceMethodStart]); +} + +void GeolocationServiceBridge::stop() +{ + ASSERT(m_javaGeolocationServiceObject); + getJNIEnv()->CallVoidMethod(m_javaGeolocationServiceObject, + javaGeolocationServiceClassMethodIDs[GeolocationServiceMethodStop]); +} + +void GeolocationServiceBridge::setEnableGps(bool enable) +{ + ASSERT(m_javaGeolocationServiceObject); + getJNIEnv()->CallVoidMethod(m_javaGeolocationServiceObject, + javaGeolocationServiceClassMethodIDs[GeolocationServiceMethodSetEnableGps], + enable); +} + +void GeolocationServiceBridge::newLocationAvailable(JNIEnv* env, jclass, jlong nativeObject, jobject location) +{ + ASSERT(nativeObject); + ASSERT(location); + GeolocationServiceBridge* object = reinterpret_cast<GeolocationServiceBridge*>(nativeObject); + object->m_listener->newPositionAvailable(toGeoposition(env, location)); +} + +void GeolocationServiceBridge::newErrorAvailable(JNIEnv* env, jclass, jlong nativeObject, jstring message) +{ + GeolocationServiceBridge* object = reinterpret_cast<GeolocationServiceBridge*>(nativeObject); + RefPtr<PositionError> error = + PositionError::create(PositionError::POSITION_UNAVAILABLE, android::jstringToWtfString(env, message)); + object->m_listener->newErrorAvailable(error.release()); +} + +PassRefPtr<Geoposition> GeolocationServiceBridge::toGeoposition(JNIEnv *env, const jobject &location) +{ + // Altitude is optional and may not be supplied. + bool hasAltitude = + env->CallBooleanMethod(location, javaLocationClassMethodIDs[LocationMethodHasAltitude]); + double Altitude = + hasAltitude ? + env->CallDoubleMethod(location, javaLocationClassMethodIDs[LocationMethodGetAltitude]) : + 0.0; + // Accuracy is required, but is not supplied by the emulator. + double Accuracy = + env->CallBooleanMethod(location, javaLocationClassMethodIDs[LocationMethodHasAccuracy]) ? + env->CallFloatMethod(location, javaLocationClassMethodIDs[LocationMethodGetAccuracy]) : + 0.0; + // heading is optional and may not be supplied. + bool hasHeading = + env->CallBooleanMethod(location, javaLocationClassMethodIDs[LocationMethodHasBearing]); + double heading = + hasHeading ? + env->CallFloatMethod(location, javaLocationClassMethodIDs[LocationMethodGetBearing]) : + 0.0; + // speed is optional and may not be supplied. + bool hasSpeed = + env->CallBooleanMethod(location, javaLocationClassMethodIDs[LocationMethodHasSpeed]); + double speed = + hasSpeed ? + env->CallFloatMethod(location, javaLocationClassMethodIDs[LocationMethodGetSpeed]) : + 0.0; + + RefPtr<Coordinates> newCoordinates = WebCore::Coordinates::create( + env->CallDoubleMethod(location, javaLocationClassMethodIDs[LocationMethodGetLatitude]), + env->CallDoubleMethod(location, javaLocationClassMethodIDs[LocationMethodGetLongitude]), + hasAltitude, Altitude, + Accuracy, + false, 0.0, // AltitudeAccuracy not provided. + hasHeading, heading, + hasSpeed, speed); + + return WebCore::Geoposition::create( + newCoordinates.release(), + env->CallLongMethod(location, javaLocationClassMethodIDs[LocationMethodGetTime])); +} + +void GeolocationServiceBridge::startJavaImplementation(Frame* frame) +{ + JNIEnv* env = getJNIEnv(); + + // Get the Java GeolocationService class. + jclass javaGeolocationServiceClass = env->FindClass(javaGeolocationServiceClassName); + ASSERT(javaGeolocationServiceClass); + + // Set up the methods we wish to call on the Java GeolocationService class. + javaGeolocationServiceClassMethodIDs[GeolocationServiceMethodInit] = + env->GetMethodID(javaGeolocationServiceClass, "<init>", "(Landroid/content/Context;J)V"); + javaGeolocationServiceClassMethodIDs[GeolocationServiceMethodStart] = + env->GetMethodID(javaGeolocationServiceClass, "start", "()Z"); + javaGeolocationServiceClassMethodIDs[GeolocationServiceMethodStop] = + env->GetMethodID(javaGeolocationServiceClass, "stop", "()V"); + javaGeolocationServiceClassMethodIDs[GeolocationServiceMethodSetEnableGps] = + env->GetMethodID(javaGeolocationServiceClass, "setEnableGps", "(Z)V"); + + // Create the Java GeolocationService object. + jlong nativeObject = reinterpret_cast<jlong>(this); + jobject object = env->NewObject(javaGeolocationServiceClass, + javaGeolocationServiceClassMethodIDs[GeolocationServiceMethodInit], + android::WebViewCore::getWebViewCore(frame->view())->getContext(), + nativeObject); + + m_javaGeolocationServiceObject = getJNIEnv()->NewGlobalRef(object); + ASSERT(m_javaGeolocationServiceObject); + + // Register to handle calls to native methods of the Java GeolocationService + // object. We register once only. + static int registered = jniRegisterNativeMethods(env, + javaGeolocationServiceClassName, + javaGeolocationServiceClassNativeMethods, + NELEM(javaGeolocationServiceClassNativeMethods)); + ASSERT(registered == JNI_OK); + + // Set up the methods we wish to call on the Java Location class. + jclass javaLocationClass = env->FindClass(javaLocationClassName); + ASSERT(javaLocationClass); + javaLocationClassMethodIDs[LocationMethodGetLatitude] = + env->GetMethodID(javaLocationClass, "getLatitude", "()D"); + javaLocationClassMethodIDs[LocationMethodGetLongitude] = + env->GetMethodID(javaLocationClass, "getLongitude", "()D"); + javaLocationClassMethodIDs[LocationMethodHasAltitude] = + env->GetMethodID(javaLocationClass, "hasAltitude", "()Z"); + javaLocationClassMethodIDs[LocationMethodGetAltitude] = + env->GetMethodID(javaLocationClass, "getAltitude", "()D"); + javaLocationClassMethodIDs[LocationMethodHasAccuracy] = + env->GetMethodID(javaLocationClass, "hasAccuracy", "()Z"); + javaLocationClassMethodIDs[LocationMethodGetAccuracy] = + env->GetMethodID(javaLocationClass, "getAccuracy", "()F"); + javaLocationClassMethodIDs[LocationMethodHasBearing] = + env->GetMethodID(javaLocationClass, "hasBearing", "()Z"); + javaLocationClassMethodIDs[LocationMethodGetBearing] = + env->GetMethodID(javaLocationClass, "getBearing", "()F"); + javaLocationClassMethodIDs[LocationMethodHasSpeed] = + env->GetMethodID(javaLocationClass, "hasSpeed", "()Z"); + javaLocationClassMethodIDs[LocationMethodGetSpeed] = + env->GetMethodID(javaLocationClass, "getSpeed", "()F"); + javaLocationClassMethodIDs[LocationMethodGetTime] = + env->GetMethodID(javaLocationClass, "getTime", "()J"); +} + +void GeolocationServiceBridge::stopJavaImplementation() +{ + // Called by GeolocationServiceAndroid on WebKit thread. + ASSERT(m_javaGeolocationServiceObject); + getJNIEnv()->DeleteGlobalRef(m_javaGeolocationServiceObject); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/GeolocationServiceBridge.h b/Source/WebCore/platform/android/GeolocationServiceBridge.h new file mode 100644 index 0000000..3997d65 --- /dev/null +++ b/Source/WebCore/platform/android/GeolocationServiceBridge.h @@ -0,0 +1,66 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef GeolocationServiceBridge_h +#define GeolocationServiceBridge_h + +#include "JNIUtility.h" +#include <wtf/PassRefPtr.h> + +namespace WebCore { + +class Frame; +class GeolocationServiceAndroid; +class Geoposition; + +// GeolocationServiceBridge is the bridge to the Java implementation. It manages +// the lifetime of the Java object. It is an implementation detail of +// GeolocationServiceAndroid. +class GeolocationServiceBridge { +public: + typedef GeolocationServiceAndroid ListenerInterface; + GeolocationServiceBridge(ListenerInterface* listener, Frame* frame); + ~GeolocationServiceBridge(); + + bool start(); + void stop(); + void setEnableGps(bool enable); + + // Static wrapper functions to hide JNI nastiness. + static void newLocationAvailable(JNIEnv *env, jclass, jlong nativeObject, jobject location); + static void newErrorAvailable(JNIEnv *env, jclass, jlong nativeObject, jstring message); + static PassRefPtr<Geoposition> toGeoposition(JNIEnv *env, const jobject &location); + +private: + void startJavaImplementation(Frame* frame); + void stopJavaImplementation(); + + ListenerInterface* m_listener; + jobject m_javaGeolocationServiceObject; +}; + +} // namespace WebCore + +#endif // GeolocationServiceBridge_h diff --git a/Source/WebCore/platform/android/KeyEventAndroid.cpp b/Source/WebCore/platform/android/KeyEventAndroid.cpp new file mode 100644 index 0000000..eaf34a9 --- /dev/null +++ b/Source/WebCore/platform/android/KeyEventAndroid.cpp @@ -0,0 +1,281 @@ +/* + * Copyright 2007, The Android Open Source Project + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com + * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2008 Collabora, Ltd. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "PlatformKeyboardEvent.h" + +#include "NotImplemented.h" +#include "WindowsKeyboardCodes.h" +#include <ui/KeycodeLabels.h> + +namespace WebCore { + +// compare to same function in gdk/KeyEventGdk.cpp +static int windowsKeyCodeForKeyEvent(unsigned int keyCode) +{ + // Does not provide all key codes, and does not handle all keys. + switch (keyCode) { + case AKEYCODE_DEL: + return VK_BACK; + case AKEYCODE_TAB: + return VK_TAB; + case AKEYCODE_CLEAR: + return VK_CLEAR; + case AKEYCODE_DPAD_CENTER: + case AKEYCODE_ENTER: + return VK_RETURN; + case AKEYCODE_SHIFT_LEFT: + case AKEYCODE_SHIFT_RIGHT: + return VK_SHIFT; + // back will serve as escape, although we probably do not have access to it + case AKEYCODE_BACK: + return VK_ESCAPE; + case AKEYCODE_SPACE: + return VK_SPACE; + case AKEYCODE_HOME: + return VK_HOME; + case AKEYCODE_DPAD_LEFT: + return VK_LEFT; + case AKEYCODE_DPAD_UP: + return VK_UP; + case AKEYCODE_DPAD_RIGHT: + return VK_RIGHT; + case AKEYCODE_DPAD_DOWN: + return VK_DOWN; + case AKEYCODE_0: + return VK_0; + case AKEYCODE_1: + return VK_1; + case AKEYCODE_2: + return VK_2; + case AKEYCODE_3: + return VK_3; + case AKEYCODE_4: + return VK_4; + case AKEYCODE_5: + return VK_5; + case AKEYCODE_6: + return VK_6; + case AKEYCODE_7: + return VK_7; + case AKEYCODE_8: + return VK_8; + case AKEYCODE_9: + return VK_9; + case AKEYCODE_A: + return VK_A; + case AKEYCODE_B: + return VK_B; + case AKEYCODE_C: + return VK_C; + case AKEYCODE_D: + return VK_D; + case AKEYCODE_E: + return VK_E; + case AKEYCODE_F: + return VK_F; + case AKEYCODE_G: + return VK_G; + case AKEYCODE_H: + return VK_H; + case AKEYCODE_I: + return VK_I; + case AKEYCODE_J: + return VK_J; + case AKEYCODE_K: + return VK_K; + case AKEYCODE_L: + return VK_L; + case AKEYCODE_M: + return VK_M; + case AKEYCODE_N: + return VK_N; + case AKEYCODE_O: + return VK_O; + case AKEYCODE_P: + return VK_P; + case AKEYCODE_Q: + return VK_Q; + case AKEYCODE_R: + return VK_R; + case AKEYCODE_S: + return VK_S; + case AKEYCODE_T: + return VK_T; + case AKEYCODE_U: + return VK_U; + case AKEYCODE_V: + return VK_V; + case AKEYCODE_W: + return VK_W; + case AKEYCODE_X: + return VK_X; + case AKEYCODE_Y: + return VK_Y; + case AKEYCODE_Z: + return VK_Z; + // colon + case AKEYCODE_SEMICOLON: + return VK_OEM_1; + case AKEYCODE_COMMA: + return VK_OEM_COMMA; + case AKEYCODE_MINUS: + return VK_OEM_MINUS; + case AKEYCODE_EQUALS: + return VK_OEM_PLUS; + case AKEYCODE_PERIOD: + return VK_OEM_PERIOD; + case AKEYCODE_SLASH: + return VK_OEM_2; + // maybe not the right choice + case AKEYCODE_LEFT_BRACKET: + return VK_OEM_4; + case AKEYCODE_BACKSLASH: + return VK_OEM_5; + case AKEYCODE_RIGHT_BRACKET: + return VK_OEM_6; + default: + return 0; + } +} + +static String keyIdentifierForAndroidKeyCode(int keyCode) +{ + // Does not return all of the same key identifiers, and + // does not handle all the keys. + switch (keyCode) { + case AKEYCODE_CLEAR: + return "Clear"; + case AKEYCODE_ENTER: + case AKEYCODE_DPAD_CENTER: + return "Enter"; + case AKEYCODE_HOME: + return "Home"; + case AKEYCODE_DPAD_DOWN: + return "Down"; + case AKEYCODE_DPAD_LEFT: + return "Left"; + case AKEYCODE_DPAD_RIGHT: + return "Right"; + case AKEYCODE_DPAD_UP: + return "Up"; + // Standard says that DEL becomes U+00007F. + case AKEYCODE_DEL: + return "U+00007F"; + default: + char upper[16]; + sprintf(upper, "U+%06X", windowsKeyCodeForKeyEvent(keyCode)); + return String(upper); + } +} + +static inline String singleCharacterString(UChar32 c) +{ + if (!c) + return String(); + if (c > 0xffff) { + UChar lead = U16_LEAD(c); + UChar trail = U16_TRAIL(c); + UChar utf16[2] = {lead, trail}; + return String(utf16, 2); + } + UChar n = (UChar)c; + return String(&n, 1); +} + +PlatformKeyboardEvent::PlatformKeyboardEvent(int keyCode, UChar32 unichar, + int repeatCount, bool down, bool cap, bool alt, bool sym) + : m_type(down ? KeyDown : KeyUp) + , m_text(singleCharacterString(unichar)) + , m_unmodifiedText(singleCharacterString(unichar)) + , m_keyIdentifier(keyIdentifierForAndroidKeyCode(keyCode)) + , m_autoRepeat(repeatCount > 0) + , m_windowsVirtualKeyCode(windowsKeyCodeForKeyEvent(keyCode)) + , m_nativeVirtualKeyCode(keyCode) + , m_isKeypad(false) + , m_shiftKey(cap ? ShiftKey : 0) + , m_ctrlKey(sym ? CtrlKey : 0) + , m_altKey(alt ? AltKey : 0) + , m_metaKey(0) + // added for android + , m_repeatCount(repeatCount) + , m_unichar(unichar) +{ + // Copied from the mac port + if (m_windowsVirtualKeyCode == '\r') { + m_text = "\r"; + m_unmodifiedText = "\r"; + } + + if (m_text == "\x7F") + m_text = "\x8"; + if (m_unmodifiedText == "\x7F") + m_unmodifiedText = "\x8"; + + if (m_windowsVirtualKeyCode == 9) { + m_text = "\x9"; + m_unmodifiedText = "\x9"; + } +} + +bool PlatformKeyboardEvent::currentCapsLockState() +{ + notImplemented(); + return false; +} + +void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey) +{ + notImplemented(); + shiftKey = false; + ctrlKey = false; + altKey = false; + metaKey = false; +} + +void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCompatibilityMode) +{ + // Copied with modification from the mac port. + ASSERT(m_type == KeyDown); + ASSERT(type == RawKeyDown || type == Char); + m_type = type; + if (backwardCompatibilityMode) + return; + + if (type == RawKeyDown) { + m_text = String(); + m_unmodifiedText = String(); + } else { + m_keyIdentifier = String(); + m_windowsVirtualKeyCode = 0; + } +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/LanguageAndroid.cpp b/Source/WebCore/platform/android/LanguageAndroid.cpp new file mode 100644 index 0000000..52e614d --- /dev/null +++ b/Source/WebCore/platform/android/LanguageAndroid.cpp @@ -0,0 +1,42 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Language.h" + +#include "PlatformBridge.h" +#include "PlatformString.h" + +namespace WebCore { + +// This function is used by Javascript to find out what the default language +// the user has selected. It is used by the JS object Navigator.language +// I guess this information should be mapped with the Accept-Language: HTTP header. +String platformDefaultLanguage() +{ + return PlatformBridge::computeDefaultLanguage(); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/LocalizedStringsAndroid.cpp b/Source/WebCore/platform/android/LocalizedStringsAndroid.cpp new file mode 100644 index 0000000..18117f9 --- /dev/null +++ b/Source/WebCore/platform/android/LocalizedStringsAndroid.cpp @@ -0,0 +1,501 @@ +/* + * Copyright 2009, The Android Open Source Project + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com + * Copyright (C) 2007 Holger Hans Peter Freyther + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "LocalizedStrings.h" + +#include "NotImplemented.h" +#include "PlatformBridge.h" +#include "PlatformString.h" + +namespace WebCore { + +// The following two strings are used for File Upload form control, ie +// <input type="file">. The first is the text that appears on the button +// that when pressed, the user can browse for and select a file. The +// second string is rendered on the screen when no file has been selected. +String fileButtonChooseFileLabel() +{ + return *(PlatformBridge::globalLocalizedName( + PlatformBridge::FileUploadLabel)); +} + +String fileButtonNoFileSelectedLabel() +{ + return *(PlatformBridge::globalLocalizedName( + PlatformBridge::FileUploadNoFileChosenLabel)); +} + +String contextMenuItemTagInspectElement() +{ + return String("Inspect Element"); +} + +String unknownFileSizeText() +{ + return String("Unknown"); +} + +String contextMenuItemTagOpenLinkInNewWindow() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagDownloadLinkToDisk() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagCopyLinkToClipboard() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagOpenImageInNewWindow() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagDownloadImageToDisk() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagCopyImageToClipboard() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagOpenVideoInNewWindow() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagOpenAudioInNewWindow() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagCopyVideoLinkToClipboard() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagCopyAudioLinkToClipboard() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagToggleMediaControls() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagToggleMediaLoop() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagEnterVideoFullscreen() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagMediaPlay() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagMediaPause() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagMediaMute() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagOpenFrameInNewWindow() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagCopy() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagGoBack() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagGoForward() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagStop() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagReload() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagCut() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagPaste() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagNoGuessesFound() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagIgnoreSpelling() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagLearnSpelling() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagSearchWeb() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagLookUpInDictionary() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagOpenLink() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagIgnoreGrammar() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagSpellingMenu() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagShowSpellingPanel(bool show) +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagCheckSpelling() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagCheckSpellingWhileTyping() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagCheckGrammarWithSpelling() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagFontMenu() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagBold() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagItalic() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagUnderline() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagOutline() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagWritingDirectionMenu() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagTextDirectionMenu() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagDefaultDirection() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagLeftToRight() +{ + notImplemented(); + return String(); +} + +String contextMenuItemTagRightToLeft() +{ + notImplemented(); + return String(); +} + +String imageTitle(const String& filename, const IntSize& size) +{ + notImplemented(); + return String(); +} + +String mediaElementLoadingStateText() +{ + notImplemented(); + return String(); +} + +String mediaElementLiveBroadcastStateText() +{ + notImplemented(); + return String(); +} + +String localizedMediaControlElementString(const String& controlName) +{ + notImplemented(); + return String(); +} + +String localizedMediaControlElementHelpText(const String& controlName) +{ + notImplemented(); + return String(); +} + +String localizedMediaTimeDescription(const String& controlName) +{ + notImplemented(); + return String(); +} + +String searchableIndexIntroduction() +{ + notImplemented(); + return String(); +} + +String resetButtonDefaultLabel() +{ + return *(PlatformBridge::globalLocalizedName( + PlatformBridge::ResetLabel)); +} + +String submitButtonDefaultLabel() +{ + return *(PlatformBridge::globalLocalizedName( + PlatformBridge::SubmitLabel)); +} + +String inputElementAltText() +{ + notImplemented(); + return String(); +} + +String validationMessageValueMissingText() +{ + notImplemented(); + return String(); +} + +String validationMessageValueMissingForCheckboxText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForMultipleFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForRadioText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForSelectText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageTypeMismatchText() +{ + notImplemented(); + return String(); +} + +String validationMessageTypeMismatchForEmailText() +{ + notImplemented(); + return validationMessageTypeMismatchText(); +} + +String validationMessageTypeMismatchForMultipleEmailText() +{ + notImplemented(); + return validationMessageTypeMismatchText(); +} + +String validationMessageTypeMismatchForURLText() +{ + notImplemented(); + return validationMessageTypeMismatchText(); +} + +String validationMessagePatternMismatchText() +{ + notImplemented(); + return String(); +} + +String validationMessageTooLongText(int, int) +{ + notImplemented(); + return String(); +} + +String validationMessageRangeUnderflowText(const String&) +{ + notImplemented(); + return String(); +} + +String validationMessageRangeOverflowText(const String&) +{ + notImplemented(); + return String(); +} + +String validationMessageStepMismatchText(const String&, const String&) +{ + notImplemented(); + return String(); +} + +String missingPluginText() +{ + return String("Missing Plug-in"); +} + +String crashedPluginText() +{ + return String("Plug-in Failure"); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/PlatformBridge.h b/Source/WebCore/platform/android/PlatformBridge.h new file mode 100644 index 0000000..faa823e --- /dev/null +++ b/Source/WebCore/platform/android/PlatformBridge.h @@ -0,0 +1,157 @@ +/* + * Copyright 2009, 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef PlatformBridge_h +#define PlatformBridge_h + +#include "FloatRect.h" +#include "KURL.h" +#include "PlatformString.h" +#include "npapi.h" + +#include <wtf/Vector.h> + +// V8 bindings use the ARRAYSIZE_UNSAFE macro. This macro was copied +// from http://src.chromium.org/viewvc/chrome/trunk/src/base/basictypes.h +// +// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize, +// but can be used on anonymous types or types defined inside +// functions. It's less safe than arraysize as it accepts some +// (although not all) pointers. Therefore, you should use arraysize +// whenever possible. +// +// The expression ARRAYSIZE_UNSAFE(a) is a compile-time constant of type +// size_t. +// +// ARRAYSIZE_UNSAFE catches a few type errors. If you see a compiler error +// +// "warning: division by zero in ..." +// +// when using ARRAYSIZE_UNSAFE, you are (wrongfully) giving it a pointer. +// You should only use ARRAYSIZE_UNSAFE on statically allocated arrays. +// +// The following comments are on the implementation details, and can +// be ignored by the users. +// +// ARRAYSIZE_UNSAFE(arr) works by inspecting sizeof(arr) (the # of bytes in +// the array) and sizeof(*(arr)) (the # of bytes in one array +// element). If the former is divisible by the latter, perhaps arr is +// indeed an array, in which case the division result is the # of +// elements in the array. Otherwise, arr cannot possibly be an array, +// and we generate a compiler error to prevent the code from +// compiling. +// +// Since the size of bool is implementation-defined, we need to cast +// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final +// result has type size_t. +// +// This macro is not perfect as it wrongfully accepts certain +// pointers, namely where the pointer size is divisible by the pointee +// size. Since all our code has to go through a 32-bit compiler, +// where a pointer is 4 bytes, this means all pointers to a type whose +// size is 3 or greater than 4 will be (righteously) rejected. + +#define ARRAYSIZE_UNSAFE(a) \ + ((sizeof(a) / sizeof(*(a))) / \ + static_cast<size_t>(!(sizeof(a) % sizeof(*(a))))) + + +class NPObject; + +namespace WebCore { + +class Document; +class FrameView; +class Node; +class ScrollView; +class Widget; + +// An interface to the embedding layer, which has the ability to answer +// questions about the system and so on... +// This is very similar to ChromiumBridge and the two are likely to converge +// in the future. +// +// The methods in this class all need to reach across a JNI layer to the Java VM +// where the embedder runs. The JNI machinery is currently all in WebKit/android +// but the long term plan is to move to the WebKit API and share the bridge and its +// implementation with Chromium. The JNI machinery will then move outside of WebKit, +// similarly to how Chromium's IPC layer lives outside of WebKit. +class PlatformBridge { +public: + // KeyGenerator + static WTF::Vector<String> getSupportedKeyStrengthList(); + static String getSignedPublicKeyAndChallengeString(unsigned index, const String& challenge, const KURL&); + // Cookies + static void setCookies(const Document*, const KURL&, const String& value); + static String cookies(const Document*, const KURL&); + static bool cookiesEnabled(const Document*); + // Plugin + static NPObject* pluginScriptableObject(Widget*); + // Popups + static bool popupsAllowed(NPP); + + // These ids need to be in sync with the constants in BrowserFrame.java + enum rawResId { + NoDomain = 1, + LoadError, + DrawableDir, + FileUploadLabel, + ResetLabel, + SubmitLabel, + FileUploadNoFileChosenLabel + }; + static String* globalLocalizedName(rawResId resId); + + // Whether the WebView is paused. + // ANDROID + // TODO: Upstream to webkit.org. See https://bugs.webkit.org/show_bug.cgi?id=34082 + static bool isWebViewPaused(const FrameView*); + static String resolveFilePathForContentUri(const String&); + + static int screenDepth(); + static FloatRect screenRect(); + + // Update the viewport meta data. + static void updateViewport(FrameView*); + + static void updateTextfield(FrameView*, Node*, bool changeToPassword, const WTF::String& text); + + static void setScrollPosition(ScrollView*, int x, int y); + + // Language + static String computeDefaultLanguage(); + // Memory details for V8 GC + static int lowMemoryUsageMB(); + static int highMemoryUsageMB(); + static int highUsageDeltaMB(); + static int memoryUsageMB(); + static int actualMemoryUsageMB(); + + static int screenWidthInDocCoord(const FrameView*); + static int screenHeightInDocCoord(const FrameView*); +}; + +} +#endif // PlatformBridge_h diff --git a/Source/WebCore/platform/android/PlatformTouchEventAndroid.cpp b/Source/WebCore/platform/android/PlatformTouchEventAndroid.cpp new file mode 100644 index 0000000..84af56d --- /dev/null +++ b/Source/WebCore/platform/android/PlatformTouchEventAndroid.cpp @@ -0,0 +1,57 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "PlatformTouchEvent.h" + +#if ENABLE(TOUCH_EVENTS) + +namespace WebCore { + +// These values should be kept in sync with those defined in the android.view.KeyEvent class from the Android SDK. +enum AndroidMetaKeyState { + META_SHIFT_ON = 0x01, + META_ALT_ON = 0x02, + META_SYM_ON = 0x04 +}; + +// Changes in next line is in ANDROID but waiting to upstream to WebKit. TODO: upstream it. +PlatformTouchEvent::PlatformTouchEvent(const Vector<int>& ids, const Vector<IntPoint>& windowPoints, TouchEventType type, const Vector<PlatformTouchPoint::State>& states, int metaState) + : m_type(type) + , m_metaKey(false) +{ + m_touchPoints.reserveCapacity(windowPoints.size()); + for (unsigned c = 0; c < windowPoints.size(); c++) + // Changes in next line is in ANDROID but waiting to upstream to WebKit. TODO: upstream it. + m_touchPoints.append(PlatformTouchPoint(ids[c], windowPoints[c], states[c])); + + m_altKey = metaState & META_ALT_ON; + m_shiftKey = metaState & META_SHIFT_ON; + m_ctrlKey = metaState & META_SYM_ON; +} + +} + +#endif diff --git a/Source/WebCore/platform/android/PlatformTouchPointAndroid.cpp b/Source/WebCore/platform/android/PlatformTouchPointAndroid.cpp new file mode 100644 index 0000000..777410a --- /dev/null +++ b/Source/WebCore/platform/android/PlatformTouchPointAndroid.cpp @@ -0,0 +1,41 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "PlatformTouchPoint.h" + +#if ENABLE(TOUCH_EVENTS) + +namespace WebCore { + +PlatformTouchPoint::PlatformTouchPoint(unsigned id, const IntPoint& windowPos, State state) + : m_id(id) + , m_state(state) + , m_screenPos(windowPos) + , m_pos(windowPos) { } + +} + +#endif diff --git a/Source/WebCore/platform/android/PopupMenuAndroid.cpp b/Source/WebCore/platform/android/PopupMenuAndroid.cpp new file mode 100644 index 0000000..f4c351f --- /dev/null +++ b/Source/WebCore/platform/android/PopupMenuAndroid.cpp @@ -0,0 +1,164 @@ +/* + * This file is part of the popup menu implementation for <select> elements in WebCore. + * + * Copyright 2009, The Android Open Source Project + * Copyright (C) 2006 Apple Computer, Inc. + * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#include "config.h" +#include "PopupMenuAndroid.h" + +#include "PopupMenuClient.h" +#include "SkTDArray.h" +#include "WebViewCore.h" + +class PopupReply : public android::WebCoreReply { +public: + PopupReply(const IntRect& rect, android::WebViewCore* view, ListPopupMenuClient* client) + : m_rect(rect) + , m_viewImpl(view) + , m_popupClient(client) + { + } + + virtual ~PopupReply() {} + + virtual void replyInt(int value) + { + if (m_popupClient) { + m_popupClient->popupDidHide(); + // -2 is a special value signaling that the popup was canceled. + if (-2 == value) + return; + m_popupClient->valueChanged(value, true); + } + if (m_viewImpl) + m_viewImpl->contentInvalidate(m_rect); + } + + virtual void replyIntArray(const int* values, int count) + { + if (m_popupClient) { + m_popupClient->popupDidHide(); + if (0 == count) { + m_popupClient->valueChanged(-1, true); + } else { + for (int i = 0; i < count; i++) { + m_popupClient->listBoxSelectItem(values[i], + i != 0 /* allowMultiplySelection */, + false /* shift */, + i == count - 1 /* fireOnChangeNow */); + } + } + } + if (m_viewImpl) + m_viewImpl->contentInvalidate(m_rect); + } + + void disconnectClient() + { + m_popupClient = 0; + m_viewImpl = 0; + } +private: + IntRect m_rect; + // FIXME: Do not need this if we handle ChromeClientAndroid::formStateDidChange + android::WebViewCore* m_viewImpl; + ListPopupMenuClient* m_popupClient; +}; + +namespace WebCore { + +PopupMenuAndroid::PopupMenuAndroid(ListPopupMenuClient* menuList) + : m_popupClient(menuList) + , m_reply(0) +{ +} +PopupMenuAndroid::~PopupMenuAndroid() +{ + disconnectClient(); +} + +void PopupMenuAndroid::disconnectClient() +{ + m_popupClient = 0; + if (m_reply) { + m_reply->disconnectClient(); + Release(m_reply); + m_reply = 0; + } +} + +// Convert a WTF::String into an array of characters where the first +// character represents the length, for easy conversion to java. +static uint16_t* stringConverter(const WTF::String& text) +{ + size_t length = text.length(); + uint16_t* itemName = new uint16_t[length+1]; + itemName[0] = (uint16_t)length; + uint16_t* firstChar = &(itemName[1]); + memcpy((void*)firstChar, text.characters(), sizeof(UChar)*length); + return itemName; +} + +void PopupMenuAndroid::show(const IntRect& rect, FrameView* frameView, int) +{ + android::WebViewCore* viewImpl = android::WebViewCore::getWebViewCore(frameView); + m_reply = new PopupReply(rect, viewImpl, m_popupClient); + Retain(m_reply); + + SkTDArray<const uint16_t*> names; + // Possible values for enabledArray. Keep in Sync with values in + // InvokeListBox.Container in WebView.java + enum OptionStatus { + OPTGROUP = -1, + OPTION_DISABLED = 0, + OPTION_ENABLED = 1, + }; + SkTDArray<int> enabledArray; + SkTDArray<int> selectedArray; + int size = m_popupClient->listSize(); + bool multiple = m_popupClient->multiple(); + for (int i = 0; i < size; i++) { + *names.append() = stringConverter(m_popupClient->itemText(i)); + if (m_popupClient->itemIsSeparator(i)) { + *enabledArray.append() = OPTION_DISABLED; + } else if (m_popupClient->itemIsLabel(i)) { + *enabledArray.append() = OPTGROUP; + } else { + // Must be an Option + *enabledArray.append() = m_popupClient->itemIsEnabled(i) + ? OPTION_ENABLED : OPTION_DISABLED; + if (multiple && m_popupClient->itemIsSelected(i)) + *selectedArray.append() = i; + } + } + + viewImpl->listBoxRequest(m_reply, + names.begin(), + size, + enabledArray.begin(), + enabledArray.count(), + multiple, + selectedArray.begin(), + multiple ? selectedArray.count() : m_popupClient->selectedIndex()); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.cpp b/Source/WebCore/platform/android/RenderThemeAndroid.cpp new file mode 100644 index 0000000..113fa63 --- /dev/null +++ b/Source/WebCore/platform/android/RenderThemeAndroid.cpp @@ -0,0 +1,496 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "RenderThemeAndroid.h" + +#include "Color.h" +#include "Element.h" +#include "GraphicsContext.h" +#include "HTMLNames.h" +#include "HTMLOptionElement.h" +#include "HTMLSelectElement.h" +#include "Node.h" +#include "PlatformGraphicsContext.h" +#if ENABLE(VIDEO) +#include "RenderMediaControls.h" +#endif +#include "RenderSkinAndroid.h" +#include "RenderSkinButton.h" +#include "RenderSkinCombo.h" +#include "RenderSkinMediaButton.h" +#include "RenderSkinRadio.h" +#include "SkCanvas.h" +#include "UserAgentStyleSheets.h" +#include "WebCoreFrameBridge.h" + +namespace WebCore { + +// Add padding to the fontSize of ListBoxes to get their maximum sizes. +// Listboxes often have a specified size. Since we change them into +// dropdowns, we want a much smaller height, which encompasses the text. +const int listboxPadding = 5; + +// This is the color of selection in a textfield. It was computed from +// frameworks/base/core/res/res/values/colors.xml, which uses #9983CC39 +// (decimal a = 153, r = 131, g = 204, b = 57) +// for all four highlighted text values. Blending this with white yields: +// R = (131 * 153 + 255 * (255 - 153)) / 255 -> 180.6 +// G = (204 * 153 + 255 * (255 - 153)) / 255 -> 224.4 +// B = ( 57 * 153 + 255 * (255 - 153)) / 255 -> 136.2 + +const RGBA32 selectionColor = makeRGB(181, 224, 136); + +static SkCanvas* getCanvasFromInfo(const PaintInfo& info) +{ + return info.context->platformContext()->mCanvas; +} + +static android::WebFrame* getWebFrame(const Node* node) +{ + if (!node) + return 0; + return android::WebFrame::getWebFrame(node->document()->frame()); +} + +RenderTheme* theme() +{ + DEFINE_STATIC_LOCAL(RenderThemeAndroid, androidTheme, ()); + return &androidTheme; +} + +PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page* page) +{ + static RenderTheme* rt = RenderThemeAndroid::create().releaseRef(); + return rt; +} + +PassRefPtr<RenderTheme> RenderThemeAndroid::create() +{ + return adoptRef(new RenderThemeAndroid()); +} + +RenderThemeAndroid::RenderThemeAndroid() +{ +} + +RenderThemeAndroid::~RenderThemeAndroid() +{ +} + +void RenderThemeAndroid::close() +{ +} + +bool RenderThemeAndroid::stateChanged(RenderObject* obj, ControlState state) const +{ + if (CheckedState == state) { + obj->repaint(); + return true; + } + return false; +} + +Color RenderThemeAndroid::platformActiveSelectionBackgroundColor() const +{ + return Color(selectionColor); +} + +Color RenderThemeAndroid::platformInactiveSelectionBackgroundColor() const +{ + return Color(Color::transparent); +} + +Color RenderThemeAndroid::platformActiveSelectionForegroundColor() const +{ + return Color::black; +} + +Color RenderThemeAndroid::platformInactiveSelectionForegroundColor() const +{ + return Color::black; +} + +Color RenderThemeAndroid::platformTextSearchHighlightColor() const +{ + return Color(Color::transparent); +} + +Color RenderThemeAndroid::platformActiveListBoxSelectionBackgroundColor() const +{ + return Color(Color::transparent); +} + +Color RenderThemeAndroid::platformInactiveListBoxSelectionBackgroundColor() const +{ + return Color(Color::transparent); +} + +Color RenderThemeAndroid::platformActiveListBoxSelectionForegroundColor() const +{ + return Color(Color::transparent); +} + +Color RenderThemeAndroid::platformInactiveListBoxSelectionForegroundColor() const +{ + return Color(Color::transparent); +} + +int RenderThemeAndroid::baselinePosition(const RenderObject* obj) const +{ + // From the description of this function in RenderTheme.h: + // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline + // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of + // controls that need to do this. + // + // Our checkboxes and radio buttons need to be offset to line up properly. + return RenderTheme::baselinePosition(obj) - 2; +} + +void RenderThemeAndroid::addIntrinsicMargins(RenderStyle* style) const +{ + // Cut out the intrinsic margins completely if we end up using a small font size + if (style->fontSize() < 11) + return; + + // Intrinsic margin value. + const int m = 2; + + // FIXME: Using width/height alone and not also dealing with min-width/max-width is flawed. + if (style->width().isIntrinsicOrAuto()) { + if (style->marginLeft().quirk()) + style->setMarginLeft(Length(m, Fixed)); + if (style->marginRight().quirk()) + style->setMarginRight(Length(m, Fixed)); + } + + if (style->height().isAuto()) { + if (style->marginTop().quirk()) + style->setMarginTop(Length(m, Fixed)); + if (style->marginBottom().quirk()) + style->setMarginBottom(Length(m, Fixed)); + } +} + +bool RenderThemeAndroid::supportsFocus(ControlPart appearance) +{ + switch (appearance) { + case PushButtonPart: + case ButtonPart: + case TextFieldPart: + return true; + default: + return false; + } + + return false; +} + +void RenderThemeAndroid::adjustButtonStyle(CSSStyleSelector*, RenderStyle* style, WebCore::Element*) const +{ + // Code is taken from RenderThemeSafari.cpp + // It makes sure we have enough space for the button text. + const int padding = 8; + style->setPaddingLeft(Length(padding, Fixed)); + style->setPaddingRight(Length(padding, Fixed)); + + // Set a min-height so that we can't get smaller than the mini button. + style->setMinHeight(Length(15, Fixed)); +} + +bool RenderThemeAndroid::paintCheckbox(RenderObject* obj, const PaintInfo& info, const IntRect& rect) +{ + RenderSkinRadio::Draw(getCanvasFromInfo(info), obj->node(), rect, true); + return false; +} + +bool RenderThemeAndroid::paintButton(RenderObject* obj, const PaintInfo& info, const IntRect& rect) +{ + // If it is a disabled button, simply paint it to the master picture. + Node* node = obj->node(); + Element* formControlElement = static_cast<Element*>(node); + if (formControlElement && !formControlElement->isEnabledFormControl()) { + android::WebFrame* webFrame = getWebFrame(node); + if (webFrame) { + const RenderSkinAndroid* skins = webFrame->renderSkins(); + if (skins) + skins->renderSkinButton()->draw(getCanvasFromInfo(info), rect, + RenderSkinAndroid::kDisabled); + } + } else + // Store all the important information in the platform context. + info.context->platformContext()->storeButtonInfo(node, rect); + + // We always return false so we do not request to be redrawn. + return false; +} + +#if ENABLE(VIDEO) + +String RenderThemeAndroid::extraMediaControlsStyleSheet() +{ + return String(mediaControlsAndroidUserAgentStyleSheet, sizeof(mediaControlsAndroidUserAgentStyleSheet)); +} + +bool RenderThemeAndroid::shouldRenderMediaControlPart(ControlPart part, Element* e) +{ + HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(e); + switch (part) { + case MediaMuteButtonPart: + return false; + case MediaSeekBackButtonPart: + case MediaSeekForwardButtonPart: + return false; + case MediaRewindButtonPart: + return mediaElement->movieLoadType() != MediaPlayer::LiveStream; + case MediaReturnToRealtimeButtonPart: + return mediaElement->movieLoadType() == MediaPlayer::LiveStream; + case MediaFullscreenButtonPart: + return mediaElement->supportsFullscreen(); + case MediaToggleClosedCaptionsButtonPart: + return mediaElement->hasClosedCaptions(); + default: + return true; + } +} + +bool RenderThemeAndroid::paintMediaFullscreenButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect) +{ + bool translucent = false; + if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) + translucent = true; + RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::FULLSCREEN, translucent); + return false; +} + +bool RenderThemeAndroid::paintMediaMuteButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect) +{ + bool translucent = false; + if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) + translucent = true; + RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::MUTE, translucent); + return false; +} + +bool RenderThemeAndroid::paintMediaPlayButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect) +{ + bool translucent = false; + if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) + translucent = true; + if (MediaControlPlayButtonElement* btn = static_cast<MediaControlPlayButtonElement*>(o->node())) { + if (btn->displayType() == MediaPlayButton) + RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::PLAY, translucent); + else + RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::PAUSE, translucent); + return false; + } + return true; +} + +bool RenderThemeAndroid::paintMediaSeekBackButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect) +{ + bool translucent = false; + if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) + translucent = true; + RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::REWIND, translucent); + return false; +} + +bool RenderThemeAndroid::paintMediaSeekForwardButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect) +{ + bool translucent = false; + if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) + translucent = true; + RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::FORWARD, translucent); + return false; +} + +bool RenderThemeAndroid::paintMediaControlsBackground(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect) +{ + bool translucent = false; + if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) + translucent = true; + RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::BACKGROUND_SLIDER, translucent); + return false; +} + +bool RenderThemeAndroid::paintMediaSliderTrack(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect) +{ + bool translucent = false; + if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) + translucent = true; + RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, + RenderSkinMediaButton::SLIDER_TRACK, translucent, o); + return false; +} + +bool RenderThemeAndroid::paintMediaSliderThumb(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect) +{ + bool translucent = false; + if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) + translucent = true; + RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::SLIDER_THUMB, translucent); + return false; +} + +void RenderThemeAndroid::adjustSliderThumbSize(RenderObject* o) const +{ + static const int sliderThumbWidth = RenderSkinMediaButton::sliderThumbWidth(); + static const int sliderThumbHeight = RenderSkinMediaButton::sliderThumbHeight(); + if (o->style()->appearance() == MediaSliderThumbPart) { + o->style()->setWidth(Length(sliderThumbWidth, Fixed)); + o->style()->setHeight(Length(sliderThumbHeight, Fixed)); + } +} + +#endif + +bool RenderThemeAndroid::paintRadio(RenderObject* obj, const PaintInfo& info, const IntRect& rect) +{ + RenderSkinRadio::Draw(getCanvasFromInfo(info), obj->node(), rect, false); + return false; +} + +void RenderThemeAndroid::setCheckboxSize(RenderStyle* style) const +{ + style->setWidth(Length(19, Fixed)); + style->setHeight(Length(19, Fixed)); +} + +void RenderThemeAndroid::setRadioSize(RenderStyle* style) const +{ + // This is the same as checkboxes. + setCheckboxSize(style); +} + +void RenderThemeAndroid::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, WebCore::Element*) const +{ + addIntrinsicMargins(style); +} + +bool RenderThemeAndroid::paintTextField(RenderObject*, const PaintInfo&, const IntRect&) +{ + return true; +} + +void RenderThemeAndroid::adjustTextAreaStyle(CSSStyleSelector*, RenderStyle* style, WebCore::Element*) const +{ + addIntrinsicMargins(style); +} + +bool RenderThemeAndroid::paintTextArea(RenderObject* obj, const PaintInfo& info, const IntRect& rect) +{ + if (obj->isMenuList()) + paintCombo(obj, info, rect); + return true; +} + +void RenderThemeAndroid::adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const +{ + addIntrinsicMargins(style); +} + +bool RenderThemeAndroid::paintSearchField(RenderObject*, const PaintInfo&, const IntRect&) +{ + return true; +} + +static void adjustMenuListStyleCommon(RenderStyle* style) +{ + // Added to make room for our arrow and make the touch target less cramped. + style->setPaddingLeft(Length(RenderSkinCombo::padding(), Fixed)); + style->setPaddingTop(Length(RenderSkinCombo::padding(), Fixed)); + style->setPaddingBottom(Length(RenderSkinCombo::padding(), Fixed)); + style->setPaddingRight(Length(RenderSkinCombo::extraWidth(), Fixed)); +} + +void RenderThemeAndroid::adjustListboxStyle(CSSStyleSelector*, RenderStyle* style, Element*) const +{ + adjustMenuListButtonStyle(0, style, 0); +} + +void RenderThemeAndroid::adjustMenuListStyle(CSSStyleSelector*, RenderStyle* style, Element* e) const +{ + adjustMenuListStyleCommon(style); + addIntrinsicMargins(style); +} + +bool RenderThemeAndroid::paintCombo(RenderObject* obj, const PaintInfo& info, const IntRect& rect) +{ + if (obj->style() && !obj->style()->visitedDependentColor(CSSPropertyBackgroundColor).alpha()) + return true; + return RenderSkinCombo::Draw(getCanvasFromInfo(info), obj->node(), rect.x(), rect.y(), rect.width(), rect.height()); +} + +bool RenderThemeAndroid::paintMenuList(RenderObject* obj, const PaintInfo& info, const IntRect& rect) +{ + return paintCombo(obj, info, rect); +} + +void RenderThemeAndroid::adjustMenuListButtonStyle(CSSStyleSelector*, + RenderStyle* style, Element*) const +{ + // Copied from RenderThemeSafari. + const float baseFontSize = 11.0f; + const int baseBorderRadius = 5; + float fontScale = style->fontSize() / baseFontSize; + + style->resetPadding(); + style->setBorderRadius(IntSize(int(baseBorderRadius + fontScale - 1), int(baseBorderRadius + fontScale - 1))); // FIXME: Round up? + + const int minHeight = 15; + style->setMinHeight(Length(minHeight, Fixed)); + + style->setLineHeight(RenderStyle::initialLineHeight()); + // Found these padding numbers by trial and error. + const int padding = 4; + style->setPaddingTop(Length(padding, Fixed)); + style->setPaddingLeft(Length(padding, Fixed)); + adjustMenuListStyleCommon(style); +} + +bool RenderThemeAndroid::paintMenuListButton(RenderObject* obj, const PaintInfo& info, const IntRect& rect) +{ + return paintCombo(obj, info, rect); +} + +bool RenderThemeAndroid::supportsFocusRing(const RenderStyle* style) const +{ + return style->opacity() > 0 + && style->hasAppearance() + && style->appearance() != TextFieldPart + && style->appearance() != SearchFieldPart + && style->appearance() != TextAreaPart + && style->appearance() != CheckboxPart + && style->appearance() != RadioPart + && style->appearance() != PushButtonPart + && style->appearance() != SquareButtonPart + && style->appearance() != ButtonPart + && style->appearance() != ButtonBevelPart + && style->appearance() != MenulistPart + && style->appearance() != MenulistButtonPart; +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.h b/Source/WebCore/platform/android/RenderThemeAndroid.h new file mode 100644 index 0000000..8314a9c --- /dev/null +++ b/Source/WebCore/platform/android/RenderThemeAndroid.h @@ -0,0 +1,131 @@ +/* + * Copyright 2006, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef RenderThemeAndroid_h +#define RenderThemeAndroid_h + +#include "RenderTheme.h" + +namespace WebCore { + +class RenderSkinButton; +class RenderSkinRadio; +class RenderSkinCombo; + +struct ThemeData { + ThemeData() + : m_part(0) + , m_state(0) + { + } + + unsigned m_part; + unsigned m_state; +}; + +class RenderThemeAndroid : public RenderTheme { +public: + static PassRefPtr<RenderTheme> create(); + ~RenderThemeAndroid(); + + virtual bool stateChanged(RenderObject*, ControlState) const; + + virtual bool supportsFocusRing(const RenderStyle*) const; + // A method asking if the theme's controls actually care about redrawing when hovered. + virtual bool supportsHover(const RenderStyle* style) const { return style->affectedByHoverRules(); } + + virtual int baselinePosition(const RenderObject*) const; + + virtual Color platformActiveSelectionBackgroundColor() const; + virtual Color platformInactiveSelectionBackgroundColor() const; + virtual Color platformActiveSelectionForegroundColor() const; + virtual Color platformInactiveSelectionForegroundColor() const; + virtual Color platformTextSearchHighlightColor() const; + + virtual Color platformActiveListBoxSelectionBackgroundColor() const; + virtual Color platformInactiveListBoxSelectionBackgroundColor() const; + virtual Color platformActiveListBoxSelectionForegroundColor() const; + virtual Color platformInactiveListBoxSelectionForegroundColor() const; + + virtual void systemFont(int, WebCore::FontDescription&) const {} + + virtual int minimumMenuListSize(RenderStyle*) const { return 0; } + +protected: + virtual bool paintCheckbox(RenderObject*, const PaintInfo&, const IntRect&); + virtual void setCheckboxSize(RenderStyle*) const; + +#if ENABLE(VIDEO) + virtual String extraMediaControlsStyleSheet(); + virtual void adjustSliderThumbSize(RenderObject* o) const; + virtual bool shouldRenderMediaControlPart(ControlPart part, Element* e); + virtual bool paintMediaFullscreenButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r); + virtual bool paintMediaMuteButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r); + virtual bool paintMediaPlayButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r); + virtual bool paintMediaSeekBackButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r); + virtual bool paintMediaSeekForwardButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r); + virtual bool paintMediaSliderTrack(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r); + virtual bool paintMediaSliderThumb(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r); + virtual bool paintMediaControlsBackground(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect); + virtual double mediaControlsFadeInDuration() { return 0.5; } + virtual double mediaControlsFadeOutDuration() { return 0.5; } +#endif + + virtual bool paintRadio(RenderObject*, const PaintInfo&, const IntRect&); + virtual void setRadioSize(RenderStyle*) const; + + virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, WebCore::Element*) const; + virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&); + + virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, WebCore::Element*) const; + virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&); + + virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, WebCore::Element*) const; + virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&); + + bool paintCombo(RenderObject*, const PaintInfo&, const IntRect&); + + virtual void adjustListboxStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&); + + virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&); + + virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; + virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&); + +private: + RenderThemeAndroid(); + void addIntrinsicMargins(RenderStyle*) const; + void close(); + + bool supportsFocus(ControlPart); + friend RenderTheme* theme(); +}; + +} // namespace WebCore + +#endif // RenderThemeAndroid_h diff --git a/Source/WebCore/platform/android/SSLKeyGeneratorAndroid.cpp b/Source/WebCore/platform/android/SSLKeyGeneratorAndroid.cpp new file mode 100644 index 0000000..287d5c4 --- /dev/null +++ b/Source/WebCore/platform/android/SSLKeyGeneratorAndroid.cpp @@ -0,0 +1,43 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "SSLKeyGenerator.h" + +#include "PlatformBridge.h" + +namespace WebCore { + +void getSupportedKeySizes(Vector<String>& keys) +{ + keys = PlatformBridge::getSupportedKeyStrengthList(); +} + +String signedPublicKeyAndChallengeString(unsigned index, const String& challenge, const KURL& url) +{ + return PlatformBridge::getSignedPublicKeyAndChallengeString(index, challenge, url); +} + +} diff --git a/Source/WebCore/platform/android/ScreenAndroid.cpp b/Source/WebCore/platform/android/ScreenAndroid.cpp new file mode 100644 index 0000000..e779da6 --- /dev/null +++ b/Source/WebCore/platform/android/ScreenAndroid.cpp @@ -0,0 +1,63 @@ +/* + * Copyright 2009, The Android Open Source Project + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Screen.h" + +#include "PlatformBridge.h" + +namespace WebCore { + +int screenDepth(Widget*) +{ + return PlatformBridge::screenDepth(); +} + +int screenDepthPerComponent(Widget*) +{ + return PlatformBridge::screenDepth(); +} + +bool screenIsMonochrome(Widget*) +{ + return false; +} + +// This is used by JavaScript Screen object and media query for device info. We +// should return the value in the device pixel. +FloatRect screenRect(Widget*) +{ + return PlatformBridge::screenRect(); +} + +// Similar as screenRect, this is used by JavaScript Screen object. This is also +// used by JavaScript Window to position and resize (usually to full screen). +FloatRect screenAvailableRect(Widget*) +{ + return PlatformBridge::screenRect(); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/ScrollViewAndroid.cpp b/Source/WebCore/platform/android/ScrollViewAndroid.cpp new file mode 100644 index 0000000..f54e5ea --- /dev/null +++ b/Source/WebCore/platform/android/ScrollViewAndroid.cpp @@ -0,0 +1,151 @@ +/* + * Copyright 2007, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define LOG_TAG "WebCore" + +#include "config.h" +#include "ScrollView.h" + +#include "FloatRect.h" +#include "FrameView.h" +#include "IntRect.h" +#include "PlatformBridge.h" +#include "SkRegion.h" +#include "WebCoreFrameBridge.h" +#include "WebCoreViewBridge.h" +#include "WebViewCore.h" + +/* + This class implementation does NOT actually emulate the Qt ScrollView. + It does provide an implementation that khtml will use to interact with + WebKit's WebFrameView documentView and our NSScrollView subclass. + + ScrollView's view is a NSScrollView (or subclass of NSScrollView) + in most cases. That scrollview is a subview of an + WebCoreFrameView. The WebCoreFrameView's documentView will also be + the scroll view's documentView. + + The WebCoreFrameView's size is the frame size. The WebCoreFrameView's documentView + corresponds to the frame content size. The scrollview itself is autosized to the + WebCoreFrameView's size (see Widget::resize). +*/ + +namespace WebCore { + +IntRect ScrollView::platformVisibleContentRect(bool includeScrollbars) const +{ + // iframe's visible content rect is relative to its parent, not the viewport. + // As we auto expand the iframe, the frame rect is the content rect. + if (parent()) + return IntRect(0, 0, width(), height()); + else + return platformWidget()->getVisibleBounds(); +} + +IntSize ScrollView::platformContentsSize() const +{ + return m_contentsSize; +} + +int ScrollView::platformActualWidth() const +{ + if (parent()) + return width(); + return platformWidget()->visibleWidth(); +} + +int ScrollView::platformActualHeight() const +{ + if (parent()) + return height(); + return platformWidget()->visibleHeight(); +} + +int ScrollView::platformActualScrollX() const +{ + if (parent()) + return scrollX(); + return platformWidget()->visibleX(); +} + +int ScrollView::platformActualScrollY() const +{ + if (parent()) + return scrollY(); + return platformWidget()->visibleY(); +} + +void ScrollView::platformSetScrollPosition(const WebCore::IntPoint& pt) +{ + if (parent()) // don't attempt to scroll subframes; they're fully visible + return; + PlatformBridge::setScrollPosition(this, pt.x(), pt.y()); +} + +void ScrollView::platformSetScrollbarModes() +{ + if (parent()) // no scrollbar for the subframes + return; + android::WebViewCore::getWebViewCore(this)->setScrollbarModes(m_horizontalScrollbarMode, m_verticalScrollbarMode); +} + +void ScrollView::platformScrollbarModes(ScrollbarMode& h, ScrollbarMode& v) const +{ + // m_horizontalScrollbarMode and m_verticalScrollbarMode are set in ScrollView::setScrollbarModes() + h = m_horizontalScrollbarMode; + v = m_verticalScrollbarMode; +} + +void ScrollView::platformRepaintContentRectangle(const IntRect &rect, bool now) +{ + android::WebViewCore::getWebViewCore(this)->contentInvalidate(rect); +} + +#ifdef ANDROID_CAPTURE_OFFSCREEN_PAINTS +// Compute the offscreen parts of the drawn rectangle by subtracting +// vis from rect. This can compute up to four rectangular slices. +void ScrollView::platformOffscreenContentRectangle(const IntRect& vis, const IntRect& rect) +{ + android::WebViewCore* core = android::WebViewCore::getWebViewCore(this); + if (!core) // SVG does not instantiate webviewcore + return; // and doesn't need to record drawing offscreen + SkRegion rectRgn = SkRegion(rect); + rectRgn.op(vis, SkRegion::kDifference_Op); + SkRegion::Iterator iter(rectRgn); + for (; !iter.done(); iter.next()) { + const SkIRect& diff = iter.rect(); + core->offInvalidate(diff); + } +} +#endif + +bool ScrollView::platformIsOffscreen() const +{ + /* other platforms override platformIsOffscreen when the browser + window is no longer on screen. We override it to prevent gif + animations from queuing up subsequent frames during dragging. */ + return android::WebViewCore::getWebViewCore(this)->drawIsPaused(); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/SearchPopupMenuAndroid.cpp b/Source/WebCore/platform/android/SearchPopupMenuAndroid.cpp new file mode 100644 index 0000000..0d67fdd --- /dev/null +++ b/Source/WebCore/platform/android/SearchPopupMenuAndroid.cpp @@ -0,0 +1,52 @@ +/* + * Copyright 2006, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "SearchPopupMenu.h" + +namespace WebCore { + +// Save the past searches stored in 'searchItems' to a database associated with 'name' +void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems) +{ +} + +// Load past searches associated with 'name' from the database to 'searchItems' +void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems) +{ +} + +// Create a search popup menu - not sure what else we have to do here +SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client) + : PopupMenu(client) +{ +} + +bool SearchPopupMenu::enabled() +{ + return false; +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/SharedTimerAndroid.cpp b/Source/WebCore/platform/android/SharedTimerAndroid.cpp new file mode 100644 index 0000000..e4f3b36 --- /dev/null +++ b/Source/WebCore/platform/android/SharedTimerAndroid.cpp @@ -0,0 +1,65 @@ +/* + * Copyright 2007, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "SharedTimer.h" + +#define LOG_TAG "Timers" + +#include <TimerClient.h> +#include <JavaSharedClient.h> +#include <utils/Log.h> +#include <wtf/CurrentTime.h> + +using namespace android; + +namespace WebCore { + +// Single timer, shared to implement all the timers managed by the Timer class. +// Not intended to be used directly; use the Timer class instead. +void setSharedTimerFiredFunction(void (*f)()) +{ + if (JavaSharedClient::GetTimerClient()) + JavaSharedClient::GetTimerClient()->setSharedTimerCallback(f); +} + +// The fire time is relative to the classic POSIX epoch of January 1, 1970, +// as the result of currentTime() is. +void setSharedTimerFireTime(double fireTime) +{ + long long timeInMs = static_cast<long long>((fireTime - WTF::currentTime()) * 1000); + + LOGV("setSharedTimerFireTime: in %ld millisec", timeInMs); + if (JavaSharedClient::GetTimerClient()) + JavaSharedClient::GetTimerClient()->setSharedTimer(timeInMs); +} + +void stopSharedTimer() +{ + if (JavaSharedClient::GetTimerClient()) + JavaSharedClient::GetTimerClient()->stopSharedTimer(); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/SoundAndroid.cpp b/Source/WebCore/platform/android/SoundAndroid.cpp new file mode 100644 index 0000000..bc1aa76 --- /dev/null +++ b/Source/WebCore/platform/android/SoundAndroid.cpp @@ -0,0 +1,36 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Sound.h" + +namespace WebCore { + +void systemBeep() +{ + // do nothing +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/SystemTimeAndroid.cpp b/Source/WebCore/platform/android/SystemTimeAndroid.cpp new file mode 100644 index 0000000..b4a0699 --- /dev/null +++ b/Source/WebCore/platform/android/SystemTimeAndroid.cpp @@ -0,0 +1,38 @@ +/* + * Copyright 2007, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "SystemTime.h" + +namespace WebCore { + +float userIdleTime() +{ + // return an arbitrarily high userIdleTime so that releasing pages from the + // page cache isn't postponed. + return 1000.0F; +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/TemporaryLinkStubs.cpp b/Source/WebCore/platform/android/TemporaryLinkStubs.cpp new file mode 100644 index 0000000..98e8812 --- /dev/null +++ b/Source/WebCore/platform/android/TemporaryLinkStubs.cpp @@ -0,0 +1,490 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define LOG_TAG "WebCore" + +#include "config.h" + +#define ANDROID_COMPILE_HACK + +#include "AXObjectCache.h" +#include "CachedPage.h" +#include "CachedResource.h" +#include "Clipboard.h" +#include "Console.h" +#include "ContextMenu.h" +#include "ContextMenuItem.h" +#include "CookieJar.h" +#include "CookieStorage.h" +#include "Cursor.h" +#include "Database.h" +#include "DocumentFragment.h" +#include "DocumentLoader.h" +#include "EditCommand.h" +#include "Editor.h" +#include "File.h" +#include "Font.h" +#include "Frame.h" +#include "FrameLoadRequest.h" +#include "FrameLoader.h" +#include "FrameView.h" +#include "GraphicsContext.h" +#include "HTMLFrameOwnerElement.h" +#include "HTMLKeygenElement.h" +#include "History.h" +#include "Icon.h" +#include "IconDatabase.h" +#include "IconLoader.h" +#include "IntPoint.h" +#include "KURL.h" +#include "Language.h" +#include "LocalizedStrings.h" +#include "MainResourceLoader.h" +#include "Node.h" +#include "NotImplemented.h" +#include "PageCache.h" +#include "Pasteboard.h" +#include "Path.h" +#include "ResourceError.h" +#include "ResourceHandle.h" +#include "ResourceLoader.h" +#include "Screen.h" +#include "Scrollbar.h" +#include "ScrollbarTheme.h" +#include "SmartReplace.h" +#include "Widget.h" +#include <stdio.h> +#include <stdlib.h> +#include <wtf/text/CString.h> + +#if USE(JSC) +#include "API/JSClassRef.h" +#include "JNIUtilityPrivate.h" +#include "JavaScriptCallFrame.h" +#include "ScriptDebugServer.h" +#endif + +using namespace WebCore; + +/********************************************************/ +/* Completely empty stubs (mostly to allow DRT to run): */ +/********************************************************/ + +namespace WebCore { + +// This function tells the bridge that a resource was loaded from the cache and thus +// the app may update progress with the amount of data loaded. +void CheckCacheObjectStatus(CachedResourceLoader*, CachedResource*) +{ + ASSERT_NOT_REACHED(); + notImplemented(); +} + +// This class is used in conjunction with the File Upload form element, and +// therefore relates to the above. When a file has been selected, an icon +// representing the file type can be rendered next to the filename on the +// web page. The icon for the file is encapsulated within this class. +Icon::~Icon() { } +void Icon::paint(GraphicsContext*, const IntRect&) { } + +} // namespace WebCore + +// FIXME, no support for spelling yet. +Pasteboard* Pasteboard::generalPasteboard() +{ + return new Pasteboard(); +} + +void Pasteboard::writeSelection(Range*, bool, Frame*) +{ + notImplemented(); +} + +void Pasteboard::writePlainText(const String&) +{ + notImplemented(); +} + +void Pasteboard::writeURL(const KURL&, const String&, Frame*) +{ + notImplemented(); +} + +void Pasteboard::clear() +{ + notImplemented(); +} + +bool Pasteboard::canSmartReplace() +{ + notImplemented(); + return false; +} + +PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame*, PassRefPtr<Range>, bool, bool&) +{ + notImplemented(); + return 0; +} + +String Pasteboard::plainText(Frame*) +{ + notImplemented(); + return String(); +} + +Pasteboard::Pasteboard() +{ + notImplemented(); +} + +Pasteboard::~Pasteboard() +{ + notImplemented(); +} + + +ContextMenu::ContextMenu() +{ + ASSERT_NOT_REACHED(); + notImplemented(); +} + +ContextMenu::~ContextMenu() +{ + ASSERT_NOT_REACHED(); + notImplemented(); +} + +void ContextMenu::appendItem(ContextMenuItem&) +{ + ASSERT_NOT_REACHED(); + notImplemented(); +} + +void ContextMenu::setPlatformDescription(PlatformMenuDescription menu) +{ + ASSERT_NOT_REACHED(); + m_platformDescription = menu; +} + +PlatformMenuDescription ContextMenu::platformDescription() const +{ + ASSERT_NOT_REACHED(); + return m_platformDescription; +} + +ContextMenuItem::ContextMenuItem(PlatformMenuItemDescription) +{ + ASSERT_NOT_REACHED(); + notImplemented(); +} + +ContextMenuItem::ContextMenuItem(ContextMenu*) +{ + ASSERT_NOT_REACHED(); + notImplemented(); +} + +ContextMenuItem::ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, ContextMenu*) +{ + ASSERT_NOT_REACHED(); + notImplemented(); +} + +ContextMenuItem::~ContextMenuItem() +{ + ASSERT_NOT_REACHED(); + notImplemented(); +} + +PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription() +{ + ASSERT_NOT_REACHED(); + notImplemented(); + return m_platformDescription; +} + +ContextMenuItemType ContextMenuItem::type() const +{ + ASSERT_NOT_REACHED(); + notImplemented(); + return ActionType; +} + +void ContextMenuItem::setType(ContextMenuItemType) +{ + ASSERT_NOT_REACHED(); + notImplemented(); +} + +ContextMenuAction ContextMenuItem::action() const +{ + ASSERT_NOT_REACHED(); + notImplemented(); + return ContextMenuItemTagNoAction; +} + +void ContextMenuItem::setAction(ContextMenuAction) +{ + ASSERT_NOT_REACHED(); + notImplemented(); +} + +String ContextMenuItem::title() const +{ + ASSERT_NOT_REACHED(); + notImplemented(); + return String(); +} + +void ContextMenuItem::setTitle(const String&) +{ + ASSERT_NOT_REACHED(); + notImplemented(); +} + +PlatformMenuDescription ContextMenuItem::platformSubMenu() const +{ + ASSERT_NOT_REACHED(); + notImplemented(); + return 0; +} + +void ContextMenuItem::setSubMenu(ContextMenu*) +{ + ASSERT_NOT_REACHED(); + notImplemented(); +} + +void ContextMenuItem::setChecked(bool) +{ + ASSERT_NOT_REACHED(); + notImplemented(); +} + +void ContextMenuItem::setEnabled(bool) +{ + ASSERT_NOT_REACHED(); + notImplemented(); +} + +// systemBeep() is called by the Editor to indicate that there was nothing to copy, and may be called from +// other places too. +void systemBeep() +{ + notImplemented(); +} + +void* WebCore::Frame::dragImageForSelection() +{ + return 0; +} + +void WebCore::Pasteboard::writeImage(WebCore::Node*, WebCore::KURL const&, WTF::String const&) {} + +namespace WebCore { + +IntSize dragImageSize(void*) +{ + return IntSize(0, 0); +} + +void deleteDragImage(void*) {} +void* createDragImageFromImage(Image*) +{ + return 0; +} + +void* dissolveDragImageToFraction(void*, float) +{ + return 0; +} + +void* createDragImageIconForCachedImage(CachedImage*) +{ + return 0; +} + +Cursor dummyCursor; +const Cursor& zoomInCursor() +{ + return dummyCursor; +} + +const Cursor& zoomOutCursor() +{ + return dummyCursor; +} + +const Cursor& notAllowedCursor() +{ + return dummyCursor; +} + +void* scaleDragImage(void*, FloatSize) +{ + return 0; +} + +String searchMenuRecentSearchesText() +{ + return String(); +} + +String searchMenuNoRecentSearchesText() +{ + return String(); +} + +String searchMenuClearRecentSearchesText() +{ + return String(); +} + +Vector<String> supportedKeySizes() +{ + notImplemented(); + return Vector<String>(); +} + +} // namespace WebCore + +namespace WebCore { +// isCharacterSmartReplaceExempt is defined in SmartReplaceICU.cpp; in theory, we could use that one +// but we don't support all of the required icu functions +bool isCharacterSmartReplaceExempt(UChar32, bool) +{ + notImplemented(); + return false; +} + +} // WebCore + +int MakeDataExecutable; + +String KURL::fileSystemPath() const +{ + notImplemented(); + return String(); +} + + +PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String&) +{ + notImplemented(); + return 0; +} + + +#if USE(JSC) +namespace JSC { namespace Bindings { +bool dispatchJNICall(ExecState*, const void* targetAppletView, jobject obj, bool isStatic, JNIType returnType, + jmethodID methodID, jvalue* args, jvalue& result, const char* callingURL, JSValue& exceptionDescription) +{ + notImplemented(); + return false; +} + +} } // namespace Bindings +#endif + +char* dirname(const char*) +{ + notImplemented(); + return 0; +} + + // new as of SVN change 38068, Nov 5, 2008 +namespace WebCore { +void prefetchDNS(const String&) +{ + notImplemented(); +} + +PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>&) +{ + notImplemented(); + return 0; +} + +// ScrollbarTheme::nativeTheme() is called by RenderTextControl::calcPrefWidths() +// like this: scrollbarSize = ScrollbarTheme::nativeTheme()->scrollbarThickness(); +// with this comment: +// // FIXME: We should get the size of the scrollbar from the RenderTheme instead. +// since our text control doesn't have scrollbars, the default size of 0 width should be +// ok. notImplemented() is commented out below so that we can find other unresolved +// unimplemented functions. +ScrollbarTheme* ScrollbarTheme::nativeTheme() +{ + /* notImplemented(); */ + static ScrollbarTheme theme; + return &theme; +} + +} // namespace WebCore + +AXObjectCache::~AXObjectCache() +{ + notImplemented(); +} + +// This value turns on or off the Mac specific Accessibility support. +bool AXObjectCache::gAccessibilityEnabled = false; +bool AXObjectCache::gAccessibilityEnhancedUserInterfaceEnabled = false; + +void AXObjectCache::childrenChanged(RenderObject*) +{ + notImplemented(); +} + +void AXObjectCache::remove(RenderObject*) +{ + notImplemented(); +} + +#if USE(JSC) +using namespace JSC; + + +OpaqueJSClass::~OpaqueJSClass() +{ + notImplemented(); +} + +OpaqueJSClassContextData::~OpaqueJSClassContextData() +{ + notImplemented(); +} + +#endif + +namespace WebCore { + +void setCookieStoragePrivateBrowsingEnabled(bool) +{ + notImplemented(); +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/android/WidgetAndroid.cpp b/Source/WebCore/platform/android/WidgetAndroid.cpp new file mode 100644 index 0000000..10326f9 --- /dev/null +++ b/Source/WebCore/platform/android/WidgetAndroid.cpp @@ -0,0 +1,127 @@ +/* + * Copyright 2007, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Widget.h" + +#include "Font.h" +#include "FrameView.h" +#include "GraphicsContext.h" +#include "NotImplemented.h" +#include "WebCoreFrameBridge.h" +#include "WebCoreViewBridge.h" +#include "WebViewCore.h" + +namespace WebCore { + +Widget::Widget(PlatformWidget widget) +{ + init(widget); +} + +Widget::~Widget() +{ + ASSERT(!parent()); + releasePlatformWidget(); +} + +IntRect Widget::frameRect() const +{ + if (!platformWidget()) + return m_frame; + return platformWidget()->getBounds(); +} + +void Widget::setFocus(bool focused) +{ + notImplemented(); +} + +void Widget::paint(GraphicsContext* ctx, const IntRect& r) +{ + // FIXME: in what case, will this be called for the top frame? + if (!platformWidget()) + return; + platformWidget()->draw(ctx, r); +} + +void Widget::releasePlatformWidget() +{ + Release(platformWidget()); +} + +void Widget::retainPlatformWidget() +{ + Retain(platformWidget()); +} + +void Widget::setCursor(const Cursor& cursor) +{ + notImplemented(); +} + +void Widget::show() +{ + notImplemented(); +} + +void Widget::hide() +{ + notImplemented(); +} + +void Widget::setFrameRect(const IntRect& rect) +{ + m_frame = rect; + // platformWidget() is 0 when called from Scrollbar + if (!platformWidget()) + return; + platformWidget()->setLocation(rect.x(), rect.y()); + platformWidget()->setSize(rect.width(), rect.height()); +} + +void Widget::setIsSelected(bool isSelected) +{ + notImplemented(); +} + +int Widget::textWrapWidth() const +{ + const Widget* widget = this; + while (!widget->isFrameView()) { + widget = widget->parent(); + if (!widget) + break; + } + if (!widget) + return 0; + android::WebViewCore* core = android::WebViewCore::getWebViewCore( + static_cast<const ScrollView*>(widget)); + if (!core) + return 0; + return core->textWrapWidth(); +} + +} // WebCore namepsace |