diff options
Diffstat (limited to 'WebKit/android')
136 files changed, 3839 insertions, 4594 deletions
diff --git a/WebKit/android/AndroidLog.h b/WebKit/android/AndroidLog.h index e62153b..b5d63e8 100644 --- a/WebKit/android/AndroidLog.h +++ b/WebKit/android/AndroidLog.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -42,6 +42,6 @@ extern FILE* gRenderTreeFile; #define DUMP_RENDER_LOGD(...) ((void)0) #endif /* ANDROID_DOM_LOGGING */ -#define DISPLAY_TREE_LOG_FILE "/data/data/com.android.browser/displayTree.txt" +#define DISPLAY_TREE_LOG_FILE "/sdcard/displayTree.txt" #endif /* ANDROIDLOG_H_ */ diff --git a/WebKit/android/JavaVM/jni.h b/WebKit/android/JavaVM/jni.h index 93c73f3..da02603 100644 --- a/WebKit/android/JavaVM/jni.h +++ b/WebKit/android/JavaVM/jni.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/RenderSkinAndroid.cpp b/WebKit/android/RenderSkinAndroid.cpp index fda4241..d148262 100644 --- a/WebKit/android/RenderSkinAndroid.cpp +++ b/WebKit/android/RenderSkinAndroid.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -22,6 +22,7 @@ * (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" diff --git a/WebKit/android/RenderSkinAndroid.h b/WebKit/android/RenderSkinAndroid.h index 475ad75..b877ff2 100644 --- a/WebKit/android/RenderSkinAndroid.h +++ b/WebKit/android/RenderSkinAndroid.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -91,4 +91,3 @@ protected: } // WebCore #endif - diff --git a/WebKit/android/RenderSkinButton.cpp b/WebKit/android/RenderSkinButton.cpp index d4483a7..63f545a 100644 --- a/WebKit/android/RenderSkinButton.cpp +++ b/WebKit/android/RenderSkinButton.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -22,6 +22,7 @@ * (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" @@ -116,4 +117,3 @@ void RenderSkinButton::Draw(SkCanvas* canvas, const IntRect& r, RenderSkinAndroi } } //WebCore - diff --git a/WebKit/android/RenderSkinButton.h b/WebKit/android/RenderSkinButton.h index 247b2f5..e9cf0ec 100644 --- a/WebKit/android/RenderSkinButton.h +++ b/WebKit/android/RenderSkinButton.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -49,4 +49,3 @@ public: } // WebCore #endif - diff --git a/WebKit/android/RenderSkinCombo.cpp b/WebKit/android/RenderSkinCombo.cpp index 870c13e..e15b3c3 100644 --- a/WebKit/android/RenderSkinCombo.cpp +++ b/WebKit/android/RenderSkinCombo.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -29,6 +29,8 @@ #include "Document.h" #include "Element.h" #include "Node.h" +#include "NodeRenderStyle.h" +#include "RenderStyle.h" #include "SkCanvas.h" #include "SkNinePatch.h" @@ -65,6 +67,13 @@ bool RenderSkinCombo::Draw(SkCanvas* canvas, Node* element, int x, int y, int wi height = (s_margin<<1) + 1; } SkRect bounds; + + bounds.set(SkIntToScalar(x+1), SkIntToScalar(y+1), SkIntToScalar(x + width-1), SkIntToScalar(y + height-1)); + RenderStyle* style = element->renderStyle(); + SkPaint paint; + paint.setColor(style->backgroundColor().rgb()); + canvas->drawRect(bounds, paint); + bounds.set(SkIntToScalar(x), SkIntToScalar(y), SkIntToScalar(x + width), SkIntToScalar(y + height)); SkNinePatch::DrawNine(canvas, bounds, s_bitmap[state], s_mar); return false; diff --git a/WebKit/android/RenderSkinCombo.h b/WebKit/android/RenderSkinCombo.h index b5321ff..91c9367 100644 --- a/WebKit/android/RenderSkinCombo.h +++ b/WebKit/android/RenderSkinCombo.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/RenderSkinRadio.cpp b/WebKit/android/RenderSkinRadio.cpp index 0207a28..27c3ce3 100644 --- a/WebKit/android/RenderSkinRadio.cpp +++ b/WebKit/android/RenderSkinRadio.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -103,4 +103,3 @@ void RenderSkinRadio::Draw(SkCanvas* canvas, Node* element, const IntRect& ir, } } //WebCore - diff --git a/WebKit/android/RenderSkinRadio.h b/WebKit/android/RenderSkinRadio.h index e196194..f77e1be 100644 --- a/WebKit/android/RenderSkinRadio.h +++ b/WebKit/android/RenderSkinRadio.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/TimeCounter.cpp b/WebKit/android/TimeCounter.cpp index 7abc113..da09b07 100644 --- a/WebKit/android/TimeCounter.cpp +++ b/WebKit/android/TimeCounter.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -34,6 +34,11 @@ #include "Node.h" #include "SystemTime.h" #include "StyleBase.h" +#include <utils/Log.h> +#include <wtf/CurrentTime.h> + +#include <sys/time.h> +#include <time.h> #if USE(JSC) #include "JSDOMWindow.h" @@ -41,14 +46,28 @@ #include <runtime/JSLock.h> #endif -#include <utils/Log.h> - using namespace WebCore; using namespace WTF; using namespace JSC; namespace android { +uint32_t getThreadMsec() +{ +#if defined(HAVE_POSIX_CLOCKS) + struct timespec tm; + + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tm); + return tm.tv_sec * 1000LL + tm.tv_nsec / 1000000; +#else + struct timeval now; + struct timezone zone; + + gettimeofday(&now, &zone); + return now.tv_sec * 1000LL + now.tv_usec / 1000; +#endif +} + #ifdef ANDROID_INSTRUMENT static double sStartTotalTime; @@ -94,7 +113,7 @@ void TimeCounter::record(enum Type type, const char* functionName) void TimeCounter::recordNoCounter(enum Type type, const char* functionName) { - uint32_t time = sEndWebCoreThreadTime = get_thread_msec(); + uint32_t time = sEndWebCoreThreadTime = getThreadMsec(); uint32_t elapsed = time - sStartTime[type]; sTotalTimeUsed[type] += elapsed; if (elapsed > 1000) @@ -105,7 +124,7 @@ void TimeCounter::report(const KURL& url, int live, int dead, size_t arenaSize) { String urlString = url; int totalTime = static_cast<int>((currentTime() - sStartTotalTime) * 1000); - int threadTime = get_thread_msec() - sStartThreadTime; + int threadTime = getThreadMsec() - sStartThreadTime; LOGD("*-* Total load time: %d ms, thread time: %d ms for %s\n", totalTime, threadTime, urlString.utf8().data()); for (Type type = (Type) 0; type < TotalTimeCounterCount; type @@ -132,7 +151,7 @@ void TimeCounter::report(const KURL& url, int live, int dead, size_t arenaSize) void TimeCounter::reportNow() { double current = currentTime(); - uint32_t currentThread = get_thread_msec(); + uint32_t currentThread = getThreadMsec(); int elapsedTime = static_cast<int>((current - sLastTotalTime) * 1000); int elapsedThreadTime = currentThread - sLastThreadTime; LOGD("*-* Elapsed time: %d ms, ui thread time: %d ms, webcore thread time:" @@ -162,12 +181,12 @@ void TimeCounter::reset() { bzero(sCounter, sizeof(sCounter)); LOGD("*-* Start browser instrument\n"); sStartTotalTime = currentTime(); - sStartThreadTime = get_thread_msec(); + sStartThreadTime = getThreadMsec(); } void TimeCounter::start(enum Type type) { - uint32_t time = get_thread_msec(); + uint32_t time = getThreadMsec(); if (sRecordWebCoreTime) { sStartWebCoreThreadTime = time; sRecordWebCoreTime = false; @@ -175,6 +194,6 @@ void TimeCounter::start(enum Type type) sStartTime[type] = time; } -#endif +#endif // ANDROID_INSTRUMENT } diff --git a/WebKit/android/TimeCounter.h b/WebKit/android/TimeCounter.h index 29c3eb9..64908d1 100644 --- a/WebKit/android/TimeCounter.h +++ b/WebKit/android/TimeCounter.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -26,10 +26,7 @@ #ifndef TIME_COUNTER_H #define TIME_COUNTER_H -#ifdef ANDROID_INSTRUMENT - #include "hardware_legacy/qemu_tracing.h" -#include <wtf/CurrentTime.h> namespace WebCore { @@ -39,6 +36,10 @@ class KURL; namespace android { +uint32_t getThreadMsec(); + +#ifdef ANDROID_INSTRUMENT + class TimeCounter { public: enum Type { @@ -84,9 +85,9 @@ private: class TimeCounterAuto { public: TimeCounterAuto(TimeCounter::Type type) : - m_type(type), m_startTime(WTF::get_thread_msec()) {} + m_type(type), m_startTime(getThreadMsec()) {} ~TimeCounterAuto() { - uint32_t time = WTF::get_thread_msec(); + uint32_t time = getThreadMsec(); TimeCounter::sEndWebCoreThreadTime = time; TimeCounter::sTotalTimeUsed[m_type] += time - m_startTime; TimeCounter::sCounter[m_type]++; @@ -112,8 +113,8 @@ public: private: static int reentry_count; }; +#endif // ANDROID_INSTRUMENT } -#endif #endif diff --git a/WebKit/android/TimerClient.h b/WebKit/android/TimerClient.h index f8cbb9d..0c3c84c 100644 --- a/WebKit/android/TimerClient.h +++ b/WebKit/android/TimerClient.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -40,4 +40,3 @@ namespace android { } #endif - diff --git a/WebKit/android/WebCoreSupport/CachedFramePlatformDataAndroid.cpp b/WebKit/android/WebCoreSupport/CachedFramePlatformDataAndroid.cpp new file mode 100644 index 0000000..30f374f --- /dev/null +++ b/WebKit/android/WebCoreSupport/CachedFramePlatformDataAndroid.cpp @@ -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. + */ + +#include "config.h" + +#include "CachedFramePlatformDataAndroid.h" +#include "Settings.h" + +namespace android { + +CachedFramePlatformDataAndroid::CachedFramePlatformDataAndroid(WebCore::Settings* settings) +{ +#ifdef ANDROID_META_SUPPORT + m_viewport_width = settings->viewportWidth(); + m_viewport_height = settings->viewportHeight(); + m_viewport_initial_scale = settings->viewportInitialScale(); + m_viewport_minimum_scale = settings->viewportMinimumScale(); + m_viewport_maximum_scale = settings->viewportMaximumScale(); + m_viewport_target_densitydpi = settings->viewportTargetDensityDpi(); + m_viewport_user_scalable = settings->viewportUserScalable(); + m_format_detection_address = settings->formatDetectionAddress(); + m_format_detection_email = settings->formatDetectionEmail(); + m_format_detection_telephone = settings->formatDetectionTelephone(); +#endif + +} + +#ifdef ANDROID_META_SUPPORT +void CachedFramePlatformDataAndroid::restoreMetadata(WebCore::Settings* settings) +{ + settings->setViewportWidth(m_viewport_width); + settings->setViewportHeight(m_viewport_height); + settings->setViewportInitialScale(m_viewport_initial_scale); + settings->setViewportMinimumScale(m_viewport_minimum_scale); + settings->setViewportMaximumScale(m_viewport_maximum_scale); + settings->setViewportTargetDensityDpi(m_viewport_target_densitydpi); + settings->setViewportUserScalable(m_viewport_user_scalable); + settings->setFormatDetectionAddress(m_format_detection_address); + settings->setFormatDetectionEmail(m_format_detection_email); + settings->setFormatDetectionTelephone(m_format_detection_telephone); +} +#endif + +} diff --git a/WebKit/android/WebCoreSupport/CachedFramePlatformDataAndroid.h b/WebKit/android/WebCoreSupport/CachedFramePlatformDataAndroid.h new file mode 100644 index 0000000..ac22d05 --- /dev/null +++ b/WebKit/android/WebCoreSupport/CachedFramePlatformDataAndroid.h @@ -0,0 +1,63 @@ +/* + * 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 CachedFramePlatformDatatAndroid_h +#define CachedFramePlatformDatatAndroid_h + +#include "CachedFramePlatformData.h" + +namespace WebCore { + class Settings; +} + +namespace android { + +class CachedFramePlatformDataAndroid : public WebCore::CachedFramePlatformData { +public: + CachedFramePlatformDataAndroid(WebCore::Settings* settings); + +#ifdef ANDROID_META_SUPPORT + void restoreMetadata(WebCore::Settings* settings); +#endif + +private: +#ifdef ANDROID_META_SUPPORT + // meta data of the frame + int m_viewport_width; + int m_viewport_height; + int m_viewport_initial_scale; + int m_viewport_minimum_scale; + int m_viewport_maximum_scale; + int m_viewport_target_densitydpi; + bool m_viewport_user_scalable : 1; + bool m_format_detection_address : 1; + bool m_format_detection_email : 1; + bool m_format_detection_telephone : 1; +#endif +}; + +} + +#endif
\ No newline at end of file diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp index 1c17ffe..f14c2c1 100644 --- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -38,6 +38,7 @@ #include "FrameLoader.h" #include "FrameView.h" #include "Geolocation.h" +#include "GraphicsLayerAndroid.h" #include "Page.h" #include "Screen.h" #include "ScriptController.h" @@ -49,6 +50,68 @@ namespace android { +#if USE(ACCELERATED_COMPOSITING) + +void ChromeClientAndroid::syncTimerFired(Timer<ChromeClientAndroid>* client) +{ + m_syncTimer.stop(); + compositingLayerSync(); +} + +void ChromeClientAndroid::compositingLayerSync() +{ + if (!m_rootGraphicsLayer) { + scheduleCompositingLayerSync(); + return; + } + + if (m_webFrame) { + FrameView* frameView = m_webFrame->page()->mainFrame()->view(); + if (frameView && !frameView->layoutPending() && !frameView->needsLayout()) { + frameView->syncCompositingStateRecursive(); + GraphicsLayerAndroid* androidGraphicsLayer = + static_cast<GraphicsLayerAndroid*>(m_rootGraphicsLayer); + if (androidGraphicsLayer) + androidGraphicsLayer->sendImmediateRepaint(); + return; + } + } + if (m_askToDrawAgain) { + m_askToDrawAgain = false; + scheduleCompositingLayerSync(); + } +} + +void ChromeClientAndroid::scheduleCompositingLayerSync() +{ + if (!m_syncTimer.isActive()) + m_syncTimer.startOneShot(0.001); // 1ms + else + m_askToDrawAgain = true; +} + +void ChromeClientAndroid::setNeedsOneShotDrawingSynchronization() +{ + // This should not be needed +} + +void ChromeClientAndroid::attachRootGraphicsLayer(WebCore::Frame* frame, WebCore::GraphicsLayer* layer) +{ + m_rootGraphicsLayer = layer; + if (!layer) { + WebViewCore::getWebViewCore(frame->view())->setRootLayer(0); + return; + } + WebCore::GraphicsLayerAndroid* androidGraphicsLayer = static_cast<GraphicsLayerAndroid*>(layer); + if (frame && frame->view() && androidGraphicsLayer) { + androidGraphicsLayer->setFrame(frame); + WebCore::LayerAndroid* androidLayer = new LayerAndroid(androidGraphicsLayer->contentLayer()); + WebViewCore::getWebViewCore(frame->view())->setRootLayer((int)androidLayer); + } +} + +#endif + void ChromeClientAndroid::setWebFrame(android::WebFrame* webframe) { Release(m_webFrame); @@ -85,16 +148,27 @@ float ChromeClientAndroid::scaleFactor() return m_webFrame->density(); } +#ifdef ANDROID_USER_GESTURE +void ChromeClientAndroid::focus(bool userGesture) { +#else void ChromeClientAndroid::focus() { + // The old behavior was to always allow javascript to focus a window. If we + // turn off ANDROID_USER_GESTURE, go back to the old behavior by forcing + // userGesture to be true. + bool userGesture = true; +#endif ASSERT(m_webFrame); // Ask the application to focus this WebView. - m_webFrame->requestFocus(); + if (userGesture) + m_webFrame->requestFocus(); } void ChromeClientAndroid::unfocus() { notImplemented(); } bool ChromeClientAndroid::canTakeFocus(FocusDirection) { notImplemented(); return false; } void ChromeClientAndroid::takeFocus(FocusDirection) { notImplemented(); } +void ChromeClientAndroid::focusedNodeChanged(Node*) { notImplemented(); } + Page* ChromeClientAndroid::createWindow(Frame* frame, const FrameLoadRequest&, const WindowFeatures& features) { @@ -165,7 +239,7 @@ void ChromeClientAndroid::closeWindowSoon() // This will prevent javascript cross-scripting during unload page->setGroupName(String()); // Stop loading but do not send the unload event - mainFrame->loader()->stopLoading(false); + mainFrame->loader()->stopLoading(UnloadEventPolicyNone); // Cancel all pending loaders mainFrame->loader()->stopAllLoaders(); // Remove all event listeners so that no javascript can execute as a result @@ -241,9 +315,7 @@ IntRect ChromeClientAndroid::windowToScreen(const IntRect&) const { return IntRect(); } -// new to change 38068 (Nov 6, 2008) -// in place of view()->containingWindow(), webkit now uses view()->hostWindow()->platformWindow() -PlatformWidget ChromeClientAndroid::platformWindow() const { +PlatformPageClient ChromeClientAndroid::platformPageClient() const { Page* page = m_webFrame->page(); Frame* mainFrame = page->mainFrame(); FrameView* view = mainFrame->view(); @@ -266,6 +338,11 @@ void ChromeClientAndroid::formStateDidChange(const Node*) notImplemented(); } +void ChromeClientAndroid::scrollbarsModeDidChange() const +{ + notImplemented(); +} + void ChromeClientAndroid::mouseDidMoveOverElement(const HitTestResult&, unsigned int) {} void ChromeClientAndroid::setToolTip(const String&, TextDirection) {} void ChromeClientAndroid::print(Frame*) {} @@ -368,7 +445,14 @@ void ChromeClientAndroid::onMainFrameLoadStarted() m_geolocationPermissions->resetTemporaryPermissionStates(); } -void ChromeClientAndroid::runOpenPanel(Frame*, PassRefPtr<FileChooser>) { notImplemented(); } +void ChromeClientAndroid::runOpenPanel(Frame* frame, + PassRefPtr<FileChooser> chooser) +{ + android::WebViewCore* core = android::WebViewCore::getWebViewCore( + frame->view()); + core->openFileChooser(chooser); +} + bool ChromeClientAndroid::setCursor(PlatformCursorHandle) { notImplemented(); diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h index 9976326..45dd078 100644 --- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h +++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -29,8 +29,8 @@ #include "ChromeClient.h" #include "GeolocationPermissions.h" -#include "Threading.h" #include "Timer.h" +#include <wtf/Threading.h> namespace WebCore { class Geolocation; @@ -43,7 +43,13 @@ namespace android { class ChromeClientAndroid : public ChromeClient { public: - ChromeClientAndroid() : m_webFrame(0), m_geolocationPermissions(0) { } + ChromeClientAndroid() : m_webFrame(0), m_geolocationPermissions(0) +#if USE(ACCELERATED_COMPOSITING) + , m_rootGraphicsLayer(0) + , m_askToDrawAgain(false) + , m_syncTimer(this, &ChromeClientAndroid::syncTimerFired) +#endif + { } virtual void chromeDestroyed(); virtual void setWindowRect(const FloatRect&); @@ -53,12 +59,18 @@ namespace android { virtual float scaleFactor(); +#ifdef ANDROID_USER_GESTURE + virtual void focus(bool userGesture); +#else virtual void focus(); +#endif virtual void unfocus(); virtual bool canTakeFocus(FocusDirection); virtual void takeFocus(FocusDirection); - + + virtual void focusedNodeChanged(Node*); + // The Frame pointer provides the ChromeClient with context about which // Frame wants to create the new Page. Also, the newly created window // should not be shown to the user until the ChromeClient of the newly @@ -104,11 +116,12 @@ namespace android { virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect); virtual IntPoint screenToWindow(const IntPoint&) const; virtual IntRect windowToScreen(const IntRect&) const; - virtual PlatformWidget platformWindow() const; + virtual PlatformPageClient platformPageClient() const; virtual void contentsSizeChanged(Frame*, const IntSize&) const; virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const; // End methods used by HostWindow. + virtual void scrollbarsModeDidChange() const; virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned int); virtual void setToolTip(const String&, TextDirection); @@ -142,13 +155,27 @@ namespace android { // Android-specific void setWebFrame(android::WebFrame* webframe); void wakeUpMainThreadWithNewQuota(long newQuota); + +#if USE(ACCELERATED_COMPOSITING) + virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer* g); + virtual void setNeedsOneShotDrawingSynchronization(); + virtual void scheduleCompositingLayerSync(); + void compositingLayerSync(); + void syncTimerFired(Timer<ChromeClientAndroid>*); +#endif + private: android::WebFrame* m_webFrame; + // The Geolocation permissions manager. + OwnPtr<GeolocationPermissions> m_geolocationPermissions; +#if USE(ACCELERATED_COMPOSITING) + WebCore::GraphicsLayer* m_rootGraphicsLayer; + bool m_askToDrawAgain; + Timer<ChromeClientAndroid> m_syncTimer; +#endif WTF::ThreadCondition m_quotaThreadCondition; WTF::Mutex m_quotaThreadLock; long m_newQuota; - // The Geolocation permissions manager. - OwnPtr<GeolocationPermissions> m_geolocationPermissions; }; } diff --git a/WebKit/android/WebCoreSupport/ContextMenuClientAndroid.cpp b/WebKit/android/WebCoreSupport/ContextMenuClientAndroid.cpp index e6ad0a6..3dc4b00 100644 --- a/WebKit/android/WebCoreSupport/ContextMenuClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/ContextMenuClientAndroid.cpp @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/WebCoreSupport/ContextMenuClientAndroid.h b/WebKit/android/WebCoreSupport/ContextMenuClientAndroid.h index ab4e445..4563829 100644 --- a/WebKit/android/WebCoreSupport/ContextMenuClientAndroid.h +++ b/WebKit/android/WebCoreSupport/ContextMenuClientAndroid.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/stl/new.h b/WebKit/android/WebCoreSupport/CookieClient.h index 599a890..56d9382 100644 --- a/WebKit/android/stl/new.h +++ b/WebKit/android/WebCoreSupport/CookieClient.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -23,3 +23,24 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef COOKIE_CLIENT_H +#define COOKIE_CLIENT_H + +#include <KURL.h> +#include <PlatformString.h> + +using namespace WebCore; + +namespace android { + +class CookieClient { + +public: + virtual ~CookieClient() {} + virtual void setCookies(const KURL& url, const String& value) = 0; + virtual String cookies(const KURL& url) = 0; + virtual bool cookiesEnabled() = 0; +}; + +} +#endif diff --git a/WebKit/android/WebCoreSupport/DragClientAndroid.cpp b/WebKit/android/WebCoreSupport/DragClientAndroid.cpp index 64406e7..f64b80c 100644 --- a/WebKit/android/WebCoreSupport/DragClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/DragClientAndroid.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -22,6 +22,7 @@ * (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" diff --git a/WebKit/android/WebCoreSupport/DragClientAndroid.h b/WebKit/android/WebCoreSupport/DragClientAndroid.h index 5f0548f..020e1f1 100644 --- a/WebKit/android/WebCoreSupport/DragClientAndroid.h +++ b/WebKit/android/WebCoreSupport/DragClientAndroid.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp b/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp index d2e45ff..c07ea71 100644 --- a/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -22,6 +22,7 @@ * (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" diff --git a/WebKit/android/WebCoreSupport/EditorClientAndroid.h b/WebKit/android/WebCoreSupport/EditorClientAndroid.h index 3569f10..614926a 100644 --- a/WebKit/android/WebCoreSupport/EditorClientAndroid.h +++ b/WebKit/android/WebCoreSupport/EditorClientAndroid.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index c567c66..c928d46 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -22,12 +22,15 @@ * (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 "android_graphics.h" #include "CString.h" +#include "CachedFrame.h" +#include "CachedFramePlatformDataAndroid.h" #include "DocumentLoader.h" #include "DOMImplementation.h" #include "Frame.h" @@ -41,6 +44,7 @@ #include "MIMETypeRegistry.h" #include "NotImplemented.h" #include "Page.h" +#include "PlatformBridge.h" #include "PlatformGraphicsContext.h" #include "PlatformString.h" #include "PluginDatabase.h" @@ -211,6 +215,21 @@ void FrameLoaderClientAndroid::dispatchDidChangeLocationWithinPage() { notImplemented(); } +void FrameLoaderClientAndroid::dispatchDidPushStateWithinPage() +{ + notImplemented(); +} + +void FrameLoaderClientAndroid::dispatchDidReplaceStateWithinPage() +{ + notImplemented(); +} + +void FrameLoaderClientAndroid::dispatchDidPopStateWithinPage() +{ + notImplemented(); +} + void FrameLoaderClientAndroid::dispatchWillClose() { notImplemented(); } @@ -297,11 +316,11 @@ void FrameLoaderClientAndroid::dispatchDidFailProvisionalLoad(const ResourceErro AssetManager* am = globalAssetManager(); // Check to see if the error code was not generated internally - WebFrame::RAW_RES_ID id = WebFrame::NODOMAIN; + WebCore::PlatformBridge::rawResId id = WebCore::PlatformBridge::NoDomain; if ((error.errorCode() == ErrorFile || error.errorCode() == ErrorFileNotFound) && (!error.localizedDescription().isEmpty())) { - id = WebFrame::LOADERROR; + id = WebCore::PlatformBridge::LoadError; } String filename = m_webFrame->getRawResourceFilename(id); if (filename.isEmpty()) @@ -343,7 +362,7 @@ void FrameLoaderClientAndroid::dispatchDidFailProvisionalLoad(const ResourceErro // load with the replacement data. // use KURL(const char*) as KURL(const String& url) can trigger ASSERT for // invalidate URL string. - loadDataIntoFrame(m_frame, KURL(data), error.failingURL(), s); + loadDataIntoFrame(m_frame, KURL(ParsedURLString, data), error.failingURL(), s); // Delete the asset. delete a; @@ -432,7 +451,7 @@ void FrameLoaderClientAndroid::dispatchDecidePolicyForMIMEType(FramePolicyFuncti if (!func) return; if (request.isNull()) { - (m_frame->loader()->*func)(PolicyIgnore); + (m_frame->loader()->policyChecker()->*func)(PolicyIgnore); return; } // Default to Use (display internally). @@ -463,7 +482,7 @@ void FrameLoaderClientAndroid::dispatchDecidePolicyForMIMEType(FramePolicyFuncti WebCore::DocumentLoader* docLoader = m_frame->loader()->activeDocumentLoader(); if (docLoader->response().httpStatusCode() == 204) action = PolicyIgnore; - (m_frame->loader()->*func)(action); + (m_frame->loader()->policyChecker()->*func)(action); } void FrameLoaderClientAndroid::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction func, @@ -475,7 +494,7 @@ void FrameLoaderClientAndroid::dispatchDecidePolicyForNewWindowAction(FramePolic return; if (request.isNull()) { - (m_frame->loader()->*func)(PolicyIgnore); + (m_frame->loader()->policyChecker()->*func)(PolicyIgnore); return; } @@ -486,9 +505,9 @@ void FrameLoaderClientAndroid::dispatchDecidePolicyForNewWindowAction(FramePolic // found by the frame tree. Instead of creating a new frame, return the // current frame in dispatchCreatePage. if (canHandleRequest(request)) - (m_frame->loader()->*func)(PolicyUse); + (m_frame->loader()->policyChecker()->*func)(PolicyUse); else - (m_frame->loader()->*func)(PolicyIgnore); + (m_frame->loader()->policyChecker()->*func)(PolicyIgnore); } void FrameLoaderClientAndroid::cancelPolicyCheck() { @@ -507,7 +526,7 @@ void FrameLoaderClientAndroid::dispatchDecidePolicyForNavigationAction(FramePoli if (!func) return; if (request.isNull()) { - (m_frame->loader()->*func)(PolicyIgnore); + (m_frame->loader()->policyChecker()->*func)(PolicyIgnore); return; } @@ -520,14 +539,14 @@ void FrameLoaderClientAndroid::dispatchDecidePolicyForNavigationAction(FramePoli m_webFrame->decidePolicyForFormResubmission(func); return; } else { - (m_frame->loader()->*func)(PolicyUse); + (m_frame->loader()->policyChecker()->*func)(PolicyUse); } } void FrameLoaderClientAndroid::dispatchWillSubmitForm(FramePolicyFunction func, PassRefPtr<FormState>) { ASSERT(m_frame); ASSERT(func); - (m_frame->loader()->*func)(PolicyUse); + (m_frame->loader()->policyChecker()->*func)(PolicyUse); } void FrameLoaderClientAndroid::dispatchDidLoadMainResource(DocumentLoader*) { @@ -619,7 +638,7 @@ void FrameLoaderClientAndroid::updateGlobalHistory() { && docLoader->response().httpStatusCode() < 400) { m_webFrame->updateVisitedHistory(docLoader->urlForHistory(), false); if (!docLoader->serverRedirectSourceForHistory().isNull()) - m_webFrame->updateVisitedHistory(KURL(docLoader->serverRedirectDestinationForHistory()), false); + m_webFrame->updateVisitedHistory(KURL(ParsedURLString, docLoader->serverRedirectDestinationForHistory()), false); } } @@ -635,6 +654,16 @@ bool FrameLoaderClientAndroid::shouldGoToHistoryItem(HistoryItem* item) const { return item != NULL; } +void FrameLoaderClientAndroid::didDisplayInsecureContent() +{ + notImplemented(); +} + +void FrameLoaderClientAndroid::didRunInsecureContent(SecurityOrigin*) +{ + notImplemented(); +} + void FrameLoaderClientAndroid::committedLoad(DocumentLoader* loader, const char* data, int length) { ASSERT(m_frame); String encoding = loader->overrideEncoding(); @@ -724,12 +753,11 @@ void FrameLoaderClientAndroid::frameLoadCompleted() { } void FrameLoaderClientAndroid::saveViewStateToItem(HistoryItem* item) { -#ifdef ANDROID_HISTORY_CLIENT ASSERT(m_frame); ASSERT(item); // We should have added a bridge when the child item was added to its // parent. - WebHistoryItem* bridge = item->bridge(); + AndroidWebHistoryBridge* bridge = item->bridge(); ASSERT(bridge); // store the current scale (only) for the top frame if (!m_frame->tree()->parent()) { @@ -739,41 +767,38 @@ void FrameLoaderClientAndroid::saveViewStateToItem(HistoryItem* item) { } WebCore::notifyHistoryItemChanged(item); -#endif } void FrameLoaderClientAndroid::restoreViewState() { -#ifdef ANDROID_HISTORY_CLIENT WebViewCore* webViewCore = WebViewCore::getWebViewCore(m_frame->view()); - HistoryItem* item = m_frame->loader()->currentHistoryItem(); + HistoryItem* item = m_frame->loader()->history()->currentItem(); + AndroidWebHistoryBridge* bridge = item->bridge(); // restore the scale (only) for the top frame if (!m_frame->tree()->parent()) { - int scale = item->bridge()->scale(); + int scale = bridge->scale(); webViewCore->restoreScale(scale); - int screenWidthScale = item->bridge()->screenWidthScale(); + int screenWidthScale = bridge->screenWidthScale(); if (screenWidthScale != scale) webViewCore->restoreScreenWidthScale(screenWidthScale); } -#endif } -#ifdef ANDROID_HISTORY_CLIENT -void FrameLoaderClientAndroid::dispatchDidAddHistoryItem(HistoryItem* item) const { +void FrameLoaderClientAndroid::dispatchDidAddBackForwardItem(HistoryItem* item) const { ASSERT(m_frame); m_webFrame->addHistoryItem(item); } -void FrameLoaderClientAndroid::dispatchDidRemoveHistoryItem(HistoryItem* item, int index) const { +void FrameLoaderClientAndroid::dispatchDidRemoveBackForwardItem(HistoryItem* item) const { ASSERT(m_frame); - m_webFrame->removeHistoryItem(index); + m_webFrame->removeHistoryItem(0); } -void FrameLoaderClientAndroid::dispatchDidChangeHistoryIndex( - BackForwardList* list) const { +void FrameLoaderClientAndroid::dispatchDidChangeBackForwardIndex() const { ASSERT(m_frame); + BackForwardList* list = m_frame->page()->backForwardList(); + ASSERT(list); m_webFrame->updateHistoryIndex(list->backListCount()); } -#endif void FrameLoaderClientAndroid::provisionalLoadStarted() { ASSERT(m_frame); @@ -806,12 +831,17 @@ String FrameLoaderClientAndroid::userAgent(const KURL& u) { return m_webFrame->userAgentForURL(&u); } -void FrameLoaderClientAndroid::savePlatformDataToCachedFrame(WebCore::CachedFrame*) { - notImplemented(); +void FrameLoaderClientAndroid::savePlatformDataToCachedFrame(WebCore::CachedFrame* cachedFrame) { + CachedFramePlatformDataAndroid* platformData = new CachedFramePlatformDataAndroid(m_frame->settings()); + cachedFrame->setCachedFramePlatformData(platformData); } -void FrameLoaderClientAndroid::transitionToCommittedFromCachedFrame(WebCore::CachedFrame*) { - notImplemented(); +void FrameLoaderClientAndroid::transitionToCommittedFromCachedFrame(WebCore::CachedFrame* cachedFrame) { + CachedFramePlatformDataAndroid* platformData = reinterpret_cast<CachedFramePlatformDataAndroid*>(cachedFrame->cachedFramePlatformData()); +#ifdef ANDROID_META_SUPPORT + platformData->restoreMetadata(m_frame->settings()); +#endif + m_webFrame->transitionToCommitted(m_frame); } void FrameLoaderClientAndroid::transitionToCommittedForNewPage() { @@ -823,32 +853,28 @@ void FrameLoaderClientAndroid::transitionToCommittedForNewPage() { m_frame->settings()->resetMetadataSettings(); #endif - if (m_frame->settings() && !m_frame->settings()->usesPageCache()) { - m_webFrame->transitionToCommitted(m_frame); - return; - } - - // Remember the old WebFrameView - WebFrameView* webFrameView = static_cast<WebFrameView*> ( - m_frame->view()->platformWidget()); - Retain(webFrameView); - - // Remove the old FrameView - m_frame->setView(NULL); - - // Create a new FrameView and associate it with the saved webFrameView - RefPtr<FrameView> view = FrameView::create(m_frame); - webFrameView->setView(view.get()); - - Release(webFrameView); - - // Give the new FrameView to the Frame - m_frame->setView(view); - - if (m_frame->ownerRenderer()) - m_frame->ownerRenderer()->setWidget(view.get()); - - m_frame->view()->initScrollbars(); + // Save the old WebViewCore before creating a new FrameView. There is one + // WebViewCore per page. Each frame, including the main frame and sub frame, + // has a 1:1 FrameView and WebFrameView. + WebViewCore* webViewCore = WebViewCore::getWebViewCore(m_frame->view()); + Retain(webViewCore); + + // Save the old WebFrameView's bounds and apply them to the new WebFrameView + WebFrameView* oldFrameView = static_cast<WebFrameView*> (m_frame->view()->platformWidget()); + IntRect bounds = oldFrameView->getBounds(); + IntRect windowBounds = oldFrameView->getWindowBounds(); + // we only support opaque, white background for now + m_frame->createView(bounds.size(), Color::white, false, IntSize(), false); + // Create a new WebFrameView for the new FrameView + WebFrameView* newFrameView = new WebFrameView(m_frame->view(), webViewCore); + newFrameView->setLocation(bounds.x(), bounds.y()); + newFrameView->setSize(bounds.width(), bounds.height()); + newFrameView->setWindowBounds(windowBounds.x(), windowBounds.y(), windowBounds.width(), windowBounds.height()); + // newFrameView attaches itself to FrameView which Retains the reference, so + // call Release for newFrameView + Release(newFrameView); + // WebFrameView Retains webViewCore, so call Release for webViewCore + Release(webViewCore); m_webFrame->transitionToCommitted(m_frame); } @@ -860,8 +886,7 @@ bool FrameLoaderClientAndroid::canCachePage() const { void FrameLoaderClientAndroid::download(ResourceHandle* handle, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&) { // Get the C++ side of the load listener and tell it to handle the download - WebCoreResourceLoader* loader = handle->getInternal()->m_loader; - loader->downloadFile(); + handle->getInternal()->m_loader->downloadFile(); } WTF::PassRefPtr<WebCore::Frame> FrameLoaderClientAndroid::createFrame(const KURL& url, const String& name, @@ -970,7 +995,7 @@ WTF::PassRefPtr<Widget> FrameLoaderClientAndroid::createPlugin( s = s.replace("VIDEO_ID", videoId); delete a; loadDataIntoFrame(frame.get(), - KURL("file:///android_asset/webkit/"), String(), s); + KURL(ParsedURLString, "file:///android_asset/webkit/"), String(), s); // Transfer ownership to a local refptr. WTF::RefPtr<Widget> widget(frame->view()); return widget.release(); @@ -1049,7 +1074,11 @@ String FrameLoaderClientAndroid::overrideMediaType() const { } // This function is used to re-attach Javascript<->native code classes. -void FrameLoaderClientAndroid::windowObjectCleared() { +void FrameLoaderClientAndroid::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world) +{ + if (world != mainThreadNormalWorld()) + return; + ASSERT(m_frame); LOGV("::WebCore:: windowObjectCleared called on frame %p for %s\n", m_frame, m_frame->loader()->url().string().ascii().data()); @@ -1088,7 +1117,7 @@ void FrameLoaderClientAndroid::didAddIconForPageUrl(const String& pageUrl) { // may register for icon notifications again since the icon data may have // to be read from disk. registerForIconNotification(false); - KURL u(pageUrl); + KURL u(ParsedURLString, pageUrl); if (equalIgnoringFragmentIdentifier(u, m_frame->loader()->url())) { dispatchDidReceiveIcon(); } diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h index 176c8be..ddf0deb 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -78,6 +78,9 @@ namespace android { virtual void dispatchDidCancelClientRedirect(); virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate); virtual void dispatchDidChangeLocationWithinPage(); + virtual void dispatchDidPushStateWithinPage(); + virtual void dispatchDidReplaceStateWithinPage(); + virtual void dispatchDidPopStateWithinPage(); virtual void dispatchWillClose(); virtual void dispatchDidReceiveIcon(); virtual void dispatchDidStartProvisionalLoad(); @@ -126,11 +129,13 @@ namespace android { virtual void updateGlobalHistoryRedirectLinks(); virtual bool shouldGoToHistoryItem(HistoryItem*) const; -#ifdef ANDROID_HISTORY_CLIENT - virtual void dispatchDidAddHistoryItem(HistoryItem*) const; - virtual void dispatchDidRemoveHistoryItem(HistoryItem*, int) const; - virtual void dispatchDidChangeHistoryIndex(BackForwardList*) const; -#endif + + virtual void didDisplayInsecureContent(); + virtual void didRunInsecureContent(SecurityOrigin*); + + virtual void dispatchDidAddBackForwardItem(HistoryItem*) const; + virtual void dispatchDidRemoveBackForwardItem(HistoryItem*) const; + virtual void dispatchDidChangeBackForwardIndex() const; virtual ResourceError cancelledError(const ResourceRequest&); virtual ResourceError blockedError(const ResourceRequest&); @@ -179,7 +184,7 @@ namespace android { virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType); virtual String overrideMediaType() const; - virtual void windowObjectCleared(); + virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*); virtual void documentElementAvailable(); virtual void didPerformFirstNavigation() const; diff --git a/WebKit/android/WebCoreSupport/GeolocationPermissions.cpp b/WebKit/android/WebCoreSupport/GeolocationPermissions.cpp index 62df3c0..aeee017 100755 --- a/WebKit/android/WebCoreSupport/GeolocationPermissions.cpp +++ b/WebKit/android/WebCoreSupport/GeolocationPermissions.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -42,8 +42,9 @@ namespace android { GeolocationPermissions::PermissionsMap GeolocationPermissions::s_permanentPermissions; GeolocationPermissions::GeolocationPermissionsVector GeolocationPermissions::s_instances; bool GeolocationPermissions::s_alwaysDeny = false; -String GeolocationPermissions::s_databasePath; bool GeolocationPermissions::s_permanentPermissionsLoaded = false; +bool GeolocationPermissions::s_permanentPermissionsModified = false; +String GeolocationPermissions::s_databasePath; static const char* databaseName = "/GeolocationPermissions.db"; @@ -158,6 +159,7 @@ void GeolocationPermissions::recordPermissionState(String origin, bool allow, bo { if (remember) { s_permanentPermissions.set(m_originInProgress, allow); + s_permanentPermissionsModified = true; } else { // It's possible that another tab recorded a permanent permission for // this origin while our request was in progress, but we record it @@ -253,8 +255,10 @@ void GeolocationPermissions::clear(String origin) { maybeLoadPermanentPermissions(); PermissionsMap::iterator iter = s_permanentPermissions.find(origin); - if (iter != s_permanentPermissions.end()) + if (iter != s_permanentPermissions.end()) { s_permanentPermissions.remove(iter); + s_permanentPermissionsModified = true; + } } void GeolocationPermissions::allow(String origin) @@ -262,12 +266,14 @@ void GeolocationPermissions::allow(String origin) maybeLoadPermanentPermissions(); // We replace any existing permanent permission. s_permanentPermissions.set(origin, true); + s_permanentPermissionsModified = true; } void GeolocationPermissions::clearAll() { maybeLoadPermanentPermissions(); s_permanentPermissions.clear(); + s_permanentPermissionsModified = true; } void GeolocationPermissions::maybeLoadPermanentPermissions() @@ -302,11 +308,10 @@ void GeolocationPermissions::maybeLoadPermanentPermissions() void GeolocationPermissions::maybeStorePermanentPermissions() { - // Protect against the case where we haven't yet loaded permissions, as - // saving in this case would overwrite the stored permissions with the empty - // set. This is safe as the permissions are always loaded before they are - // modified. - if (!s_permanentPermissionsLoaded) + // If the permanent permissions haven't been modified, there's no need to + // save them to the DB. (If we haven't even loaded them, writing them now + // would overwrite the stored permissions with the empty set.) + if (!s_permanentPermissionsModified) return; SQLiteDatabase database; @@ -334,6 +339,8 @@ void GeolocationPermissions::maybeStorePermanentPermissions() transaction.commit(); database.close(); + + s_permanentPermissionsModified = false; } void GeolocationPermissions::setDatabasePath(String path) diff --git a/WebKit/android/WebCoreSupport/GeolocationPermissions.h b/WebKit/android/WebCoreSupport/GeolocationPermissions.h index d6b8296..33434b9 100755 --- a/WebKit/android/WebCoreSupport/GeolocationPermissions.h +++ b/WebKit/android/WebCoreSupport/GeolocationPermissions.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -30,11 +30,11 @@ // We must include this before before HashMap.h, as it provides specalizations // for String hash types instantiated there. #include "StringHash.h" -#include "HashMap.h" -#include "HashSet.h" #include "Timer.h" -#include "Vector.h" -#include "wtf/RefCounted.h" +#include <wtf/HashMap.h> +#include <wtf/HashSet.h> +#include <wtf/RefCounted.h> +#include <wtf/Vector.h> namespace WebCore { class Frame; @@ -45,7 +45,13 @@ namespace android { class WebViewCore; - // The GeolocationPermissions class manages permissions for the browser. + // The GeolocationPermissions class manages Geolocation permissions for the + // browser. Permissions are managed on a per-origin basis, as required by + // the Geolocation spec - http://dev.w3.org/geo/api/spec-source.html. An + // origin specifies the scheme, host and port of particular frame. An + // origin is represented here as a string, using the output of + // WebCore::SecurityOrigin::toString. + // // Each instance handles permissions for a given main frame. The class // enforces the following policy. // - Non-remembered permissions last for the dureation of the main frame. @@ -69,8 +75,10 @@ namespace android { // the same origin as the requesting frame. void queryPermissionState(WebCore::Frame* frame); - // Provides this object the given permission state from the user. The - // new permission state is recorded and will trigger callbacks to + // Provides this object with a permission state set by the user. The + // permission is specified by 'allow' and applied to 'origin'. If + // 'remember' is set, the permission state is remembered permanently. + // The new permission state is recorded and will trigger callbacks to // geolocation objects as described above. If any other permission // requests are queued, the next is started. void providePermissionState(WebCore::String origin, bool allow, bool remember); @@ -82,12 +90,21 @@ namespace android { // Static methods for use from Java. These are used to interact with the // browser settings menu and to update the permanent permissions when // system settings are changed. + // Gets the list of all origins for which permanent permissions are + // recorded. typedef HashSet<WebCore::String> OriginSet; static OriginSet getOrigins(); + // Gets whether the specified origin is allowed. static bool getAllowed(WebCore::String origin); + // Clears the permission state for the specified origin. static void clear(WebCore::String origin); + // Sets the permission state for the specified origin to allowed. static void allow(WebCore::String origin); + // Clears the permission state for all origins. static void clearAll(); + // Sets whether the GeolocationPermissions object should always deny + // permission requests, irrespective of previously recorded permission + // states. static void setAlwaysDeny(bool deny); static void setDatabasePath(WebCore::String path); @@ -96,7 +113,8 @@ namespace android { static void maybeStorePermanentPermissions(); private: - // Records the permission state for the specified origin. + // Records the permission state for the specified origin and whether + // this should be remembered. void recordPermissionState(WebCore::String origin, bool allow, bool remember); // Used to make an asynchronous callback to the Geolocation objects. @@ -141,6 +159,7 @@ namespace android { static bool s_alwaysDeny; static bool s_permanentPermissionsLoaded; + static bool s_permanentPermissionsModified; static WebCore::String s_databasePath; }; diff --git a/WebKit/android/WebCoreSupport/InspectorClientAndroid.h b/WebKit/android/WebCoreSupport/InspectorClientAndroid.h index 54d15cb..6feb2d7 100644 --- a/WebKit/android/WebCoreSupport/InspectorClientAndroid.h +++ b/WebKit/android/WebCoreSupport/InspectorClientAndroid.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -52,11 +52,9 @@ public: virtual void hideHighlight() {} virtual void inspectedURLChanged(const String& newURL) {} - - // new as of 38068 - virtual void populateSetting(const String&, InspectorController::Setting&) {} - virtual void storeSetting(const String&, const InspectorController::Setting&) {} - virtual void removeSetting(const String&) {} + + virtual void populateSetting(const String& key, String* value) {} + virtual void storeSetting(const String& key, const String& value) {} virtual String hiddenPanels() { return String(); } virtual void inspectorWindowObjectCleared() {} }; diff --git a/WebKit/android/stl/strings.h b/WebKit/android/WebCoreSupport/KeyGeneratorClient.h index 599a890..1bcd8e8 100644 --- a/WebKit/android/stl/strings.h +++ b/WebKit/android/WebCoreSupport/KeyGeneratorClient.h @@ -1,5 +1,5 @@ /* - * Copyright 2007, The Android Open Source Project + * 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 @@ -13,7 +13,7 @@ * 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 + * 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 @@ -23,3 +23,24 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef KEY_GENERATOR_CLIENT_H +#define KEY_GENERATOR_CLIENT_H + +#include "KURL.h" +#include "PlatformString.h" + +#include <wtf/Vector.h> + +using namespace WebCore; + +namespace android { + +class KeyGeneratorClient { +public: + virtual ~KeyGeneratorClient() { } + virtual WTF::Vector<String> getSupportedKeyStrengthList() = 0; + virtual String getSignedPublicKeyAndChallengeString(unsigned index, + const String& challenge, const KURL& url) = 0; + }; +} +#endif diff --git a/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp b/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp index 5ca6e83..1bb8802 100644 --- a/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp +++ b/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -30,6 +30,7 @@ #include "GraphicsContext.h" #include "MediaPlayerPrivateAndroid.h" #include "SkiaUtils.h" +#include "TimeRanges.h" #include "WebCoreJni.h" #include "WebViewCore.h" #include "jni_utility.h" @@ -112,11 +113,17 @@ IntSize MediaPlayerPrivate::naturalSize() const return m_naturalSize; } -bool MediaPlayerPrivate::hasVideo() const +bool MediaPlayerPrivate::hasAudio() const { + // TODO return false; } +bool MediaPlayerPrivate::hasVideo() const +{ + return m_hasVideo; +} + void MediaPlayerPrivate::setVisible(bool visible) { m_isVisible = visible; @@ -182,9 +189,9 @@ float MediaPlayerPrivate::maxTimeSeekable() const return 0; } -float MediaPlayerPrivate::maxTimeBuffered() const +PassRefPtr<TimeRanges> MediaPlayerPrivate::buffered() const { - return 0; + return TimeRanges::create(); } int MediaPlayerPrivate::dataRate() const @@ -275,6 +282,7 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player) m_duration(6000), m_currentTime(0), m_paused(true), + m_hasVideo(false), m_readyState(MediaPlayer::HaveNothing), m_networkState(MediaPlayer::Empty), m_poster(0), @@ -345,13 +353,17 @@ void MediaPlayerPrivate::onPrepared(int duration, int width, int height) { m_duration = duration / 1000.0f; m_naturalSize = IntSize(width, height); m_naturalSizeUnknown = false; + m_hasVideo = true; m_player->durationChanged(); m_player->sizeChanged(); } void MediaPlayerPrivate::onEnded() { + m_currentTime = duration(); + m_player->timeChanged(); m_paused = true; m_currentTime = 0; + m_hasVideo = false; m_networkState = MediaPlayer::Idle; m_readyState = MediaPlayer::HaveNothing; } @@ -370,6 +382,11 @@ void MediaPlayerPrivate::onPosterFetched(SkBitmap* poster) { } } +void MediaPlayerPrivate::onTimeupdate(int position) { + m_currentTime = position / 1000.0f; + m_player->timeChanged(); +} + } namespace android { @@ -399,6 +416,13 @@ static void OnPosterFetched(JNIEnv* env, jobject obj, jobject poster, int pointe player->onPosterFetched(posterNative); } +static void OnTimeupdate(JNIEnv* env, jobject obj, int position, int pointer) { + if (pointer) { + WebCore::MediaPlayerPrivate* player = reinterpret_cast<WebCore::MediaPlayerPrivate*>(pointer); + player->onTimeupdate(position); + } +} + /* * JNI registration */ @@ -409,6 +433,8 @@ static JNINativeMethod g_MediaPlayerMethods[] = { (void*) OnEnded }, { "nativeOnPosterFetched", "(Landroid/graphics/Bitmap;I)V", (void*) OnPosterFetched }, + { "nativeOnTimeupdate", "(II)V", + (void*) OnTimeupdate }, }; int register_mediaplayer(JNIEnv* env) diff --git a/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/WebKit/android/WebCoreSupport/PlatformBridge.cpp index 2931b36..f36ecf7 100644 --- a/WebKit/android/WebCoreSupport/PlatformBridge.cpp +++ b/WebKit/android/WebCoreSupport/PlatformBridge.cpp @@ -24,17 +24,112 @@ */ #include "config.h" -#include "PlatformBridge.h" +#include <PlatformBridge.h> +#include "CookieClient.h" +#include "JavaSharedClient.h" +#include "KeyGeneratorClient.h" #include "WebViewCore.h" +#include <wtf/android/AndroidThreading.h> +#include <wtf/MainThread.h> using namespace android; namespace WebCore { +#if USE(ACCELERATED_COMPOSITING) + +void PlatformBridge::setRootLayer(const WebCore::FrameView* view, int layer) +{ + android::WebViewCore* core = android::WebViewCore::getWebViewCore(view); + core->setRootLayer(layer); +} + +void PlatformBridge::immediateRepaint(const WebCore::FrameView* view) +{ + android::WebViewCore* core = android::WebViewCore::getWebViewCore(view); + core->immediateRepaint(); +} + +#endif // USE(ACCELERATED_COMPOSITING) + +WTF::Vector<String> PlatformBridge::getSupportedKeyStrengthList() +{ + KeyGeneratorClient* client = JavaSharedClient::GetKeyGeneratorClient(); + if (!client) + return Vector<String>(); + + return client->getSupportedKeyStrengthList(); +} + +String PlatformBridge::getSignedPublicKeyAndChallengeString(unsigned index, const String& challenge, const KURL& url) +{ + KeyGeneratorClient* client = JavaSharedClient::GetKeyGeneratorClient(); + if (!client) + return String(); + + return client->getSignedPublicKeyAndChallengeString(index, challenge, url); +} + +void PlatformBridge::setCookies(const KURL& url, const String& value) +{ + CookieClient* client = JavaSharedClient::GetCookieClient(); + if (!client) + return; + + client->setCookies(url, value); +} + +String PlatformBridge::cookies(const KURL& url) +{ + CookieClient* client = JavaSharedClient::GetCookieClient(); + if (!client) + return String(); + + return client->cookies(url); +} + +bool PlatformBridge::cookiesEnabled() +{ + CookieClient* client = JavaSharedClient::GetCookieClient(); + if (!client) + return false; + + return client->cookiesEnabled(); +} + bool PlatformBridge::isWebViewPaused() { return WebViewCore::isPaused(); } +} // namespace WebCore + + +// This is the implementation of AndroidThreading, which is declared in +// JavaScriptCore/wtf/android/AndroidThreading.h. It is provided here, rather +// than in its own source file, to avoid linker problems. +// +// By default, when building a shared library, the linker strips from static +// libraries any compilation units which do not contain any code referenced from +// that static library. Since +// AndroidThreading::scheduleDispatchFunctionsOnMainThread is not referenced +// from libwebcore.a, implementing it in its own compilation unit results in it +// being stripped. This stripping can be avoided by using the linker option +// --whole-archive for libwebcore.a, but this adds considerably to the size of +// libwebcore.so. + +namespace WTF { + +// Callback in the main thread. +static void timeoutFired(void*) +{ + dispatchFunctionsFromMainThread(); } + +void AndroidThreading::scheduleDispatchFunctionsOnMainThread() +{ + JavaSharedClient::EnqueueFunctionPtr(timeoutFired, 0); +} + +} // namespace WTF diff --git a/WebKit/android/WebCoreSupport/ResourceLoaderAndroid.cpp b/WebKit/android/WebCoreSupport/ResourceLoaderAndroid.cpp new file mode 100644 index 0000000..2b2ad95 --- /dev/null +++ b/WebKit/android/WebCoreSupport/ResourceLoaderAndroid.cpp @@ -0,0 +1,50 @@ +/* + * 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 <ResourceLoaderAndroid.h> + +#include "FrameLoaderClientAndroid.h" +#include "WebCoreFrameBridge.h" +#include "WebCoreResourceLoader.h" + +using namespace android; + +namespace WebCore { + +PassRefPtr<ResourceLoaderAndroid> ResourceLoaderAndroid::start( + ResourceHandle* handle, const ResourceRequest& request, FrameLoaderClient* client, bool isMainResource, bool isSync) +{ + FrameLoaderClientAndroid* clientAndroid = static_cast<FrameLoaderClientAndroid*> (client); + return clientAndroid->webFrame()->startLoadingResource(handle, request, isMainResource, isSync); +} + +bool ResourceLoaderAndroid::willLoadFromCache(const WebCore::KURL& url, int64_t identifier) +{ + return WebCoreResourceLoader::willLoadFromCache(url, identifier); +} + +} diff --git a/WebKit/android/benchmark/Android.mk b/WebKit/android/benchmark/Android.mk new file mode 100644 index 0000000..5b189e1 --- /dev/null +++ b/WebKit/android/benchmark/Android.mk @@ -0,0 +1,41 @@ +## +## +## 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. +## + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + main.cpp + +# Pull the webkit definitions from the base webkit makefile. +LOCAL_SHARED_LIBRARIES := libwebcore $(WEBKIT_SHARED_LIBRARIES) +LOCAL_LDLIBS := $(WEBKIT_LDLIBS) + +LOCAL_MODULE := webcore_test + +LOCAL_MODULE_TAGS := optional + +include $(BUILD_EXECUTABLE) diff --git a/WebKit/android/benchmark/Intercept.cpp b/WebKit/android/benchmark/Intercept.cpp new file mode 100644 index 0000000..fe8e7bb --- /dev/null +++ b/WebKit/android/benchmark/Intercept.cpp @@ -0,0 +1,189 @@ +/* + * 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_test" +#include "config.h" + +#include "Base64.h" +#include "CString.h" +#include "HTTPParsers.h" +#include "Intercept.h" +#include "ResourceHandle.h" +#include "ResourceHandleClient.h" +#include "ResourceRequest.h" +#include "ResourceResponse.h" +#include "StringHash.h" +#include "TextEncoding.h" +#include <utils/Log.h> +#include <wtf/HashMap.h> + +PassRefPtr<WebCore::ResourceLoaderAndroid> MyResourceLoader::create( + ResourceHandle* handle, String url) +{ + return adoptRef<WebCore::ResourceLoaderAndroid>( + new MyResourceLoader(handle, url)); +} + +void MyResourceLoader::handleRequest() +{ + if (protocolIs(m_url, "data")) + loadData(m_url.substring(5)); // 5 for data: + else if (protocolIs(m_url, "file")) + loadFile(m_url.substring(7)); // 7 for file:// +} + +void MyResourceLoader::loadData(const String& data) +{ + LOGD("Loading data (%s) ...", data.latin1().data()); + ResourceHandleClient* client = m_handle->client(); + int index = data.find(','); + if (index == -1) { + client->cannotShowURL(m_handle); + return; + } + + String mediaType = data.substring(0, index); + String base64 = data.substring(index + 1); + + bool decode = mediaType.endsWith(";base64", false); + if (decode) + mediaType = mediaType.left(mediaType.length() - 7); // 7 for base64; + + if (mediaType.isEmpty()) + mediaType = "text/plain;charset=US-ASCII"; + + String mimeType = extractMIMETypeFromMediaType(mediaType); + String charset = extractCharsetFromMediaType(mediaType); + + ResourceResponse response; + response.setMimeType(mimeType); + + if (decode) { + base64 = decodeURLEscapeSequences(base64); + response.setTextEncodingName(charset); + client->didReceiveResponse(m_handle, response); + + // FIXME: This is annoying. WebCore's Base64 decoder chokes on spaces. + // That is correct with strict decoding but html authors (particularly + // the acid3 authors) put spaces in the data which should be ignored. + // Remove them here before sending to the decoder. + Vector<char> in; + CString str = base64.latin1(); + const char* chars = str.data(); + unsigned i = 0; + while (i < str.length()) { + char c = chars[i]; + // Don't send spaces or control characters. + if (c != ' ' && c != '\n' && c != '\t' && c != '\b' + && c != '\f' && c != '\r') + in.append(chars[i]); + i++; + } + Vector<char> out; + if (base64Decode(in, out) && out.size() > 0) + client->didReceiveData(m_handle, out.data(), out.size(), 0); + } else { + base64 = decodeURLEscapeSequences(base64, TextEncoding(charset)); + response.setTextEncodingName("UTF-16"); + client->didReceiveResponse(m_handle, response); + if (base64.length() > 0) + client->didReceiveData(m_handle, (const char*)base64.characters(), + base64.length() * sizeof(UChar), 0); + } + client->didFinishLoading(m_handle); +} +static String mimeTypeForExtension(const String& file) +{ + static HashMap<String, String, CaseFoldingHash> extensionToMime; + if (extensionToMime.isEmpty()) { + extensionToMime.set("txt", "text/plain"); + extensionToMime.set("html", "text/html"); + extensionToMime.set("htm", "text/html"); + extensionToMime.set("png", "image/png"); + extensionToMime.set("jpeg", "image/jpeg"); + extensionToMime.set("jpg", "image/jpeg"); + extensionToMime.set("gif", "image/gif"); + extensionToMime.set("ico", "image/x-icon"); + extensionToMime.set("js", "text/javascript"); + } + int dot = file.reverseFind('.'); + String mime("text/plain"); + if (dot != -1) { + String ext = file.substring(dot + 1); + if (extensionToMime.contains(ext)) + mime = extensionToMime.get(ext); + } + return mime; +} + +void MyResourceLoader::loadFile(const String& file) +{ + LOGD("Loading file (%s) ...", file.latin1().data()); + FILE* f = fopen(file.latin1().data(), "r"); + ResourceHandleClient* client = m_handle->client(); + if (!f) { + client->didFail(m_handle, + ResourceError("", -14, file, "Could not open file")); + } else { + ResourceResponse response; + response.setTextEncodingName("utf-8"); + response.setMimeType(mimeTypeForExtension(file)); + client->didReceiveResponse(m_handle, response); + char buf[512]; + while (true) { + int res = fread(buf, 1, sizeof(buf), f); + if (res <= 0) + break; + client->didReceiveData(m_handle, buf, res, 0); + } + fclose(f); + client->didFinishLoading(m_handle); + } +} + +PassRefPtr<WebCore::ResourceLoaderAndroid> MyWebFrame::startLoadingResource( + ResourceHandle* handle, const ResourceRequest& req, bool ignore, + bool ignore2) +{ + RefPtr<WebCore::ResourceLoaderAndroid> loader = + MyResourceLoader::create(handle, req.url().string()); + m_requests.append(loader); + if (!m_timer.isActive()) + m_timer.startOneShot(0); + return loader.release(); +} + +void MyWebFrame::timerFired(Timer<MyWebFrame>*) +{ + LOGD("Handling requests..."); + Vector<RefPtr<WebCore::ResourceLoaderAndroid> > reqs; + reqs.swap(m_requests); + Vector<RefPtr<WebCore::ResourceLoaderAndroid> >::iterator i = reqs.begin(); + Vector<RefPtr<WebCore::ResourceLoaderAndroid> >::iterator end = reqs.end(); + for (; i != end; i++) + static_cast<MyResourceLoader*>((*i).get())->handleRequest(); + + LOGD("...done"); +} diff --git a/WebKit/android/benchmark/Intercept.h b/WebKit/android/benchmark/Intercept.h new file mode 100644 index 0000000..fbf38bc --- /dev/null +++ b/WebKit/android/benchmark/Intercept.h @@ -0,0 +1,82 @@ +/* + * 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. + */ + +#ifndef INTERCEPT_H +#define INTERCEPT_H + +#include "jni_utility.h" +#include "MyJavaVM.h" +#include "PlatformString.h" +#include "Timer.h" +#include "WebCoreFrameBridge.h" +#include "WebCoreResourceLoader.h" +#include <wtf/Vector.h> + +namespace WebCore { + class Page; + class ResourceHandle; + class ResourceRequest; +} + +using namespace android; +using namespace WebCore; +using namespace WTF; + +class MyResourceLoader : public WebCoreResourceLoader { +public: + static PassRefPtr<WebCore::ResourceLoaderAndroid> create( + ResourceHandle* handle, String url); + void handleRequest(); + +private: + MyResourceLoader(ResourceHandle* handle, String url) + : WebCoreResourceLoader(JSC::Bindings::getJNIEnv(), MY_JOBJECT) + , m_handle(handle) + , m_url(url) {} + + void loadData(const String&); + void loadFile(const String&); + ResourceHandle* m_handle; + String m_url; +}; + +class MyWebFrame : public WebFrame { +public: + MyWebFrame(Page* page) + : WebFrame(JSC::Bindings::getJNIEnv(), MY_JOBJECT, MY_JOBJECT, page) + , m_timer(this, &MyWebFrame::timerFired) {} + + virtual PassRefPtr<WebCore::ResourceLoaderAndroid> startLoadingResource( + ResourceHandle* handle, const ResourceRequest& req, bool, bool); + + virtual bool canHandleRequest(const ResourceRequest&) { return true; } + +private: + void timerFired(Timer<MyWebFrame>*); + Vector<RefPtr<WebCore::ResourceLoaderAndroid> > m_requests; + Timer<MyWebFrame> m_timer; +}; + +#endif diff --git a/WebKit/android/benchmark/MyJavaVM.cpp b/WebKit/android/benchmark/MyJavaVM.cpp new file mode 100644 index 0000000..f73a3ea --- /dev/null +++ b/WebKit/android/benchmark/MyJavaVM.cpp @@ -0,0 +1,131 @@ +/* + * 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. + */ + +#include "config.h" + +#include "MyJavaVM.h" +#include "jni_utility.h" + +#include <jni.h> + +static JNIEnv* s_env; +static JavaVM* s_jvm; + +// JavaVM functions +jint vm_attachCurrentThread(JavaVM*, JNIEnv** env, void*) { + *env = s_env; + return JNI_OK; +} + +// JNIEnv functions +jobject env_callObjectMethodV(JNIEnv*, jobject, jmethodID, va_list) { + return MY_JOBJECT; +} +void env_callVoidMethodV(JNIEnv*, jobject, jmethodID, va_list) {} +void env_deleteRef(JNIEnv*, jobject) {} +jboolean env_exceptionCheck(JNIEnv*) { + return false; +} +jclass env_findClass(JNIEnv*, const char*) { + return (jclass) 1; +} +jbyte* env_getByteArrayElements(JNIEnv*, jbyteArray, jboolean*) { + return NULL; +} +jmethodID env_getMethodID(JNIEnv*, jclass, const char*, const char*) { + return (jmethodID) 1; +} +jclass env_getObjectClass(JNIEnv*, jobject) { + return (jclass) 1; +} +static const char* s_fakeString = "Fake Java String"; +const jchar* env_getStringChars(JNIEnv*, jstring, jboolean* isCopy) { + if (isCopy) + *isCopy = false; + return (const jchar*)s_fakeString; +} +jsize env_getStringLength(JNIEnv*, jstring) { + return sizeof(s_fakeString) - 1; +} +jbyteArray env_newByteArray(JNIEnv*, jsize) { + return (jbyteArray) 1; +} +jobject env_newRef(JNIEnv*, jobject obj) { + return obj; +} +jobject env_newObjectV(JNIEnv*, jclass, jmethodID, va_list) { + return MY_JOBJECT; +} +jstring env_newString(JNIEnv*, const jchar*, jsize) { + return (jstring) 1; +} +void env_releaseByteArrayElements(JNIEnv*, jbyteArray, jbyte*, jint) {} +void env_releaseStringChars(JNIEnv*, jstring, const jchar*) {} +void env_setByteArrayRegion(JNIEnv*, jbyteArray, jsize, jsize, const jbyte*) {} +void env_setIntField(JNIEnv*, jobject, jfieldID, jint) {} + +void InitializeJavaVM() { + // First, create the fake vm + s_jvm = new JavaVM; + JNIInvokeInterface* i = new JNIInvokeInterface; + memset(i, 0, sizeof(JNIInvokeInterface)); + s_jvm->functions = i; + + // Now, assign the functions of the vm to our fake ones. + i->AttachCurrentThread = vm_attachCurrentThread; + + // Create the fake env next + s_env = new JNIEnv; + JNINativeInterface* n = new JNINativeInterface; + memset(n, 0, sizeof(JNINativeInterface)); + s_env->functions = n; + + // Point the functions we care about to out fake ones. + n->CallObjectMethodV = env_callObjectMethodV; + n->CallVoidMethodV = env_callVoidMethodV; + n->DeleteLocalRef = env_deleteRef; + n->DeleteGlobalRef = env_deleteRef; + n->DeleteWeakGlobalRef = env_deleteRef; + n->ExceptionCheck = env_exceptionCheck; + n->FindClass = env_findClass; + n->GetByteArrayElements = env_getByteArrayElements; + n->GetMethodID = env_getMethodID; + n->GetObjectClass = env_getObjectClass; + n->GetStringChars = env_getStringChars; + n->GetStringLength = env_getStringLength; + n->NewByteArray = env_newByteArray; + n->NewLocalRef = env_newRef; + n->NewGlobalRef = env_newRef; + n->NewWeakGlobalRef = env_newRef; + n->NewObjectV = env_newObjectV; + n->NewString = env_newString; + n->ReleaseByteArrayElements = env_releaseByteArrayElements; + n->ReleaseStringChars = env_releaseStringChars; + n->SetByteArrayRegion = env_setByteArrayRegion; + n->SetIntField = env_setIntField; + + // Tell WebCore about the vm + JSC::Bindings::setJavaVM(s_jvm); +} diff --git a/WebKit/android/stl/limits b/WebKit/android/benchmark/MyJavaVM.h index 672e605..36d478d 100644 --- a/WebKit/android/stl/limits +++ b/WebKit/android/benchmark/MyJavaVM.h @@ -1,5 +1,5 @@ /* - * Copyright 2007, The Android Open Source Project + * 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 @@ -23,9 +23,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __ANDROID_LIMITS -#define __ANDROID_LIMITS +#ifndef MY_JAVA_VM_H +#define MY_JAVA_VM_H -#include <limits.h> +// Make it 1 just to appease any assertions or checks for valid objects +#define MY_JOBJECT ((jobject) 1) -#endif // __ANDROID_LIMITS +void InitializeJavaVM(); + +#endif diff --git a/WebKit/android/sort.cpp b/WebKit/android/benchmark/main.cpp index de7aa6c..fcb797d 100644 --- a/WebKit/android/sort.cpp +++ b/WebKit/android/benchmark/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2007, The Android Open Source Project + * 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 @@ -23,34 +23,43 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "config.h" +#define LOG_TAG "webcore_test" -namespace std -{ - void sort(const void** start, const void** end, const void** temp, Comparator comp) - { - size_t endlen = end - start; - size_t midlen = endlen / 2; - const void** mid = start + midlen; - if (midlen > 1) - sort(start, mid, temp, comp); - if (end - mid > 1) - sort(mid, end, temp, comp); - memcpy(temp, start, midlen * sizeof(*start)); - size_t i = 0; - size_t j = midlen; - size_t off = 0; - while (i < midlen && j < endlen) - start[off++] = (*comp)(start[j], temp[i]) ? start[j++] : temp[i++]; - if (i < midlen) - memcpy(&start[off], &temp[i], (midlen - i) * sizeof(*start)); - } +#include <stdlib.h> +#include <string.h> +#include <getopt.h> +#include <utils/Log.h> + +namespace android { +extern void benchmark(const char*, int, int ,int); +} - void sort(const void** start, const void** end, Comparator comp) { - if (end - start > 1) { - const void** temp = new sortType[(end - start) / 2]; - sort(start, end, temp, comp); - delete[] temp; +int main(int argc, char** argv) { + int width = 800; + int height = 600; + int reloadCount = 0; + while (true) { + int c = getopt(argc, argv, "d:r:"); + if (c == -1) + break; + else if (c == 'd') { + char* x = strchr(optarg, 'x'); + if (x) { + width = atoi(optarg); + height = atoi(x + 1); + LOGD("Rendering page at %dx%d", width, height); + } + } else if (c == 'r') { + reloadCount = atoi(optarg); + if (reloadCount < 0) + reloadCount = 0; + LOGD("Reloading %d times", reloadCount); } } + if (optind >= argc) { + LOGE("Please supply a file to read\n"); + return 1; + } + + android::benchmark(argv[optind], reloadCount, width, height); } diff --git a/WebKit/android/icu/unicode/ucnv.cpp b/WebKit/android/icu/unicode/ucnv.cpp index 775820a..1963dd2 100644 --- a/WebKit/android/icu/unicode/ucnv.cpp +++ b/WebKit/android/icu/unicode/ucnv.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -23,6 +23,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// BEGIN android-added +// Add config.h to avoid compiler error in uobject.h +// ucnv.h includes uobject.h indirectly and uobjetcs.h defines new/delete. +// new/delete are also defined in WebCorePrefix.h which auto included in Android make. +// +// config.h has to be on top of the include list. +#include "config.h" +// END android-added + #include "EmojiFont.h" #include <icu4c/common/unicode/ucnv.h> diff --git a/WebKit/android/icu/unicode/ucnv.h b/WebKit/android/icu/unicode/ucnv.h index 8c441f1..5ddaedb 100644 --- a/WebKit/android/icu/unicode/ucnv.h +++ b/WebKit/android/icu/unicode/ucnv.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/jni/GeolocationPermissionsBridge.cpp b/WebKit/android/jni/GeolocationPermissionsBridge.cpp index 0eeab3a..a9f79b0 100755 --- a/WebKit/android/jni/GeolocationPermissionsBridge.cpp +++ b/WebKit/android/jni/GeolocationPermissionsBridge.cpp @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/jni/JavaBridge.cpp b/WebKit/android/jni/JavaBridge.cpp index f1b532d..049a7da 100644 --- a/WebKit/android/jni/JavaBridge.cpp +++ b/WebKit/android/jni/JavaBridge.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -101,7 +101,7 @@ public: static void UpdatePluginDirectories(JNIEnv* env, jobject obj, jobjectArray array, jboolean reload); private: - jobject mJavaObject; + jweak mJavaObject; jmethodID mSetSharedTimer; jmethodID mStopSharedTimer; jmethodID mSetCookies; @@ -118,7 +118,7 @@ static void (*sSharedTimerFiredCallback)(); JavaBridge::JavaBridge(JNIEnv* env, jobject obj) { - mJavaObject = adoptGlobalRef(env, obj); + mJavaObject = env->NewWeakGlobalRef(obj); jclass clazz = env->GetObjectClass(obj); mSetSharedTimer = env->GetMethodID(clazz, "setSharedTimer", "(J)V"); @@ -152,7 +152,7 @@ JavaBridge::~JavaBridge() { if (mJavaObject) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->DeleteGlobalRef(mJavaObject); + env->DeleteWeakGlobalRef(mJavaObject); mJavaObject = 0; } @@ -167,8 +167,6 @@ JavaBridge::setSharedTimer(long long timemillis) { JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = getRealObject(env, mJavaObject); - if (!obj.get()) - return; env->CallVoidMethod(obj.get(), mSetSharedTimer, timemillis); } @@ -177,8 +175,6 @@ JavaBridge::stopSharedTimer() { JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = getRealObject(env, mJavaObject); - if (!obj.get()) - return; env->CallVoidMethod(obj.get(), mStopSharedTimer); } @@ -186,13 +182,11 @@ void JavaBridge::setCookies(WebCore::KURL const& url, WebCore::String const& value) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = getRealObject(env, mJavaObject); - if (!obj.get()) - return; const WebCore::String& urlStr = url.string(); jstring jUrlStr = env->NewString(urlStr.characters(), urlStr.length()); jstring jValueStr = env->NewString(value.characters(), value.length()); + AutoJObject obj = getRealObject(env, mJavaObject); env->CallVoidMethod(obj.get(), mSetCookies, jUrlStr, jValueStr); env->DeleteLocalRef(jUrlStr); env->DeleteLocalRef(jValueStr); @@ -203,10 +197,9 @@ JavaBridge::cookies(WebCore::KURL const& url) { JNIEnv* env = JSC::Bindings::getJNIEnv(); const WebCore::String& urlStr = url.string(); - AutoJObject obj = getRealObject(env, mJavaObject); - if (!obj.get()) - return WebCore::String(); jstring jUrlStr = env->NewString(urlStr.characters(), urlStr.length()); + + AutoJObject obj = getRealObject(env, mJavaObject); jstring string = (jstring)(env->CallObjectMethod(obj.get(), mCookies, jUrlStr)); WebCore::String ret = to_string(env, string); @@ -220,8 +213,6 @@ JavaBridge::cookiesEnabled() { JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = getRealObject(env, mJavaObject); - if (!obj.get()) - return false; jboolean ret = env->CallBooleanMethod(obj.get(), mCookiesEnabled); return (ret != 0); } @@ -232,8 +223,6 @@ JavaBridge::getPluginDirectories() WTF::Vector<WebCore::String> directories; JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = getRealObject(env, mJavaObject); - if (!obj.get()) - return directories; jobjectArray array = (jobjectArray) env->CallObjectMethod(obj.get(), mGetPluginDirectories); int count = env->GetArrayLength(array); @@ -252,8 +241,6 @@ JavaBridge::getPluginSharedDataDirectory() { JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = getRealObject(env, mJavaObject); - if (!obj.get()) - return WebCore::String(); jstring ret = (jstring)env->CallObjectMethod(obj.get(), mGetPluginSharedDataDirectory); WebCore::String path = to_string(env, ret); checkException(env); @@ -276,8 +263,6 @@ void JavaBridge::signalServiceFuncPtrQueue() // environment is setup. JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = getRealObject(env, mJavaObject); - if (!obj.get()) - return; env->CallVoidMethod(obj.get(), mSignalFuncPtrQueue); } @@ -285,8 +270,6 @@ WTF::Vector<WebCore::String>JavaBridge::getSupportedKeyStrengthList() { WTF::Vector<WebCore::String> list; JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = getRealObject(env, mJavaObject); - if (!obj.get()) - return list; jobjectArray array = (jobjectArray) env->CallObjectMethod(obj.get(), mGetKeyStrengthList); int count = env->GetArrayLength(array); diff --git a/WebKit/android/jni/JavaSharedClient.cpp b/WebKit/android/jni/JavaSharedClient.cpp index 2eec7b9..ce46570 100644 --- a/WebKit/android/jni/JavaSharedClient.cpp +++ b/WebKit/android/jni/JavaSharedClient.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -102,24 +102,23 @@ namespace android { void JavaSharedClient::ServiceFunctionPtrQueue() { for (;;) { - void (*proc)(void*); - void* payload; + void (*proc)(void*) = 0; + void* payload = 0; const FuncPtrRec* rec; // we have to copy the proc/payload (if present). we do this so we // don't call the proc inside the mutex (possible deadlock!) gFuncPtrQMutex.acquire(); rec = (const FuncPtrRec*)gFuncPtrQ.front(); - if (NULL != rec) { + if (rec) { proc = rec->fProc; payload = rec->fPayload; gFuncPtrQ.pop_front(); } gFuncPtrQMutex.release(); - if (NULL == rec) { + if (!rec) break; - } proc(payload); } } diff --git a/WebKit/android/jni/JavaSharedClient.h b/WebKit/android/jni/JavaSharedClient.h index bf59969..d33df67 100644 --- a/WebKit/android/jni/JavaSharedClient.h +++ b/WebKit/android/jni/JavaSharedClient.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/jni/MockGeolocation.cpp b/WebKit/android/jni/MockGeolocation.cpp index 3e79680..e76b1c1 100755 --- a/WebKit/android/jni/MockGeolocation.cpp +++ b/WebKit/android/jni/MockGeolocation.cpp @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/jni/PictureSet.cpp b/WebKit/android/jni/PictureSet.cpp index e8fcba5..22f57a3 100644 --- a/WebKit/android/jni/PictureSet.cpp +++ b/WebKit/android/jni/PictureSet.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -36,7 +36,7 @@ #include "SkRect.h" #include "SkRegion.h" #include "SkStream.h" -#include <wtf/CurrentTime.h> +#include "TimeCounter.h" #define MAX_DRAW_TIME 100 #define MIN_SPLITTABLE 400 @@ -270,9 +270,9 @@ bool PictureSet::draw(SkCanvas* canvas) } canvas->translate(pathBounds.fLeft, pathBounds.fTop); canvas->save(); - uint32_t startTime = WTF::get_thread_msec(); + uint32_t startTime = getThreadMsec(); canvas->drawPicture(*working->mPicture); - size_t elapsed = working->mElapsed = WTF::get_thread_msec() - startTime; + size_t elapsed = working->mElapsed = getThreadMsec() - startTime; working->mWroteElapsed = true; if (maxElapsed < elapsed && (pathBounds.width() >= MIN_SPLITTABLE || pathBounds.height() >= MIN_SPLITTABLE)) diff --git a/WebKit/android/jni/PictureSet.h b/WebKit/android/jni/PictureSet.h index 51ff0b5..b177958 100644 --- a/WebKit/android/jni/PictureSet.h +++ b/WebKit/android/jni/PictureSet.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 745cc57..150c428 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -28,6 +28,7 @@ #include <config.h> #include <wtf/Platform.h> +#include <wtf/CurrentTime.h> #include "android_graphics.h" #include "Arena.h" @@ -63,10 +64,8 @@ #if USE(JSC) #include "GCController.h" #include "JSDOMWindow.h" -#include <runtime/InitializeThreading.h> #include <runtime/JSLock.h> #elif USE(V8) -#include "InitializeThreading.h" #include "jni_npobject.h" #include "jni_instance.h" #endif // USE(JSC) @@ -82,6 +81,7 @@ #include "ResourceHandle.h" #include "ScriptController.h" #include "ScriptValue.h" +#include "SecurityOrigin.h" #include "SelectionController.h" #include "Settings.h" #include "SubstituteData.h" @@ -116,6 +116,51 @@ #include "TimeCounter.h" #endif +using namespace JSC::Bindings; + +static String* gUploadFileLabel; +static String* gResetLabel; +static String* gSubmitLabel; + +String* WebCore::PlatformBridge::globalLocalizedName( + WebCore::PlatformBridge::rawResId resId) +{ + switch (resId) { + case WebCore::PlatformBridge::FileUploadLabel: + return gUploadFileLabel; + case WebCore::PlatformBridge::ResetLabel: + return gResetLabel; + case WebCore::PlatformBridge::SubmitLabel: + return gSubmitLabel; + default: + return 0; + } +} +/** + * Instantiate the localized name desired. + */ +void initGlobalLocalizedName(WebCore::PlatformBridge::rawResId resId, + android::WebFrame* webFrame) +{ + String** pointer; + switch (resId) { + case WebCore::PlatformBridge::FileUploadLabel: + pointer = &gUploadFileLabel; + break; + case WebCore::PlatformBridge::ResetLabel: + pointer = &gResetLabel; + break; + case WebCore::PlatformBridge::SubmitLabel: + pointer = &gSubmitLabel; + break; + default: + return; + } + if (!(*pointer) && webFrame) { + (*pointer) = new String(webFrame->getRawResourceFilename(resId).impl()); + } +} + namespace android { // ---------------------------------------------------------------------------- @@ -126,8 +171,8 @@ namespace android { struct WebFrame::JavaBrowserFrame { - jobject mObj; - jobject mHistoryList; // WebBackForwardList object + jweak mObj; + jweak mHistoryList; // WebBackForwardList object jmethodID mStartLoadingResource; jmethodID mLoadStarted; jmethodID mTransitionToCommitted; @@ -146,6 +191,8 @@ struct WebFrame::JavaBrowserFrame jmethodID mRequestFocus; jmethodID mGetRawResFilename; jmethodID mDensity; + jmethodID mGetFileSize; + jmethodID mGetFile; AutoJObject frame(JNIEnv* env) { return getRealObject(env, mObj); } @@ -165,10 +212,10 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* { jclass clazz = env->GetObjectClass(obj); mJavaFrame = new JavaBrowserFrame; - mJavaFrame->mObj = adoptGlobalRef(env, obj); - mJavaFrame->mHistoryList = adoptGlobalRef(env, historyList); + mJavaFrame->mObj = env->NewWeakGlobalRef(obj); + mJavaFrame->mHistoryList = env->NewWeakGlobalRef(historyList); mJavaFrame->mStartLoadingResource = env->GetMethodID(clazz, "startLoadingResource", - "(ILjava/lang/String;Ljava/lang/String;Ljava/util/HashMap;[BIZ)Landroid/webkit/LoadListener;"); + "(ILjava/lang/String;Ljava/lang/String;Ljava/util/HashMap;[BJIZZZ)Landroid/webkit/LoadListener;"); mJavaFrame->mLoadStarted = env->GetMethodID(clazz, "loadStarted", "(Ljava/lang/String;Landroid/graphics/Bitmap;IZ)V"); mJavaFrame->mTransitionToCommitted = env->GetMethodID(clazz, "transitionToCommitted", @@ -202,6 +249,8 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* mJavaFrame->mGetRawResFilename = env->GetMethodID(clazz, "getRawResFilename", "(I)Ljava/lang/String;"); mJavaFrame->mDensity = env->GetMethodID(clazz, "density","()F"); + mJavaFrame->mGetFileSize = env->GetMethodID(clazz, "getFileSize", "(Ljava/lang/String;)I"); + mJavaFrame->mGetFile = env->GetMethodID(clazz, "getFile", "(Ljava/lang/String;[BII)I"); LOG_ASSERT(mJavaFrame->mStartLoadingResource, "Could not find method startLoadingResource"); LOG_ASSERT(mJavaFrame->mLoadStarted, "Could not find method loadStarted"); @@ -221,6 +270,8 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* LOG_ASSERT(mJavaFrame->mRequestFocus, "Could not find method requestFocus"); LOG_ASSERT(mJavaFrame->mGetRawResFilename, "Could not find method getRawResFilename"); LOG_ASSERT(mJavaFrame->mDensity, "Could not find method density"); + LOG_ASSERT(mJavaFrame->mGetFileSize, "Could not find method getFileSize"); + LOG_ASSERT(mJavaFrame->mGetFile, "Could not find method getFile"); mUserAgent = WebCore::String(); mUserInitiatedClick = false; @@ -229,9 +280,9 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* WebFrame::~WebFrame() { if (mJavaFrame->mObj) { - JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->DeleteGlobalRef(mJavaFrame->mObj); - env->DeleteGlobalRef(mJavaFrame->mHistoryList); + JNIEnv* env = getJNIEnv(); + env->DeleteWeakGlobalRef(mJavaFrame->mObj); + env->DeleteWeakGlobalRef(mJavaFrame->mHistoryList); mJavaFrame->mObj = 0; } delete mJavaFrame; @@ -274,9 +325,50 @@ static jobject createJavaMapFromHTTPHeaders(JNIEnv* env, const WebCore::HTTPHead return hashMap; } -WebCoreResourceLoader* +// In WebViewCore.java, we artificially append the filename to the URI so that +// webkit treats the actual display name of the file as the filename, rather +// than the last segment of the URI (which will simply be a number). When we +// pass the URI up to BrowserFrame, we no longer need the appended name (in fact +// it causes problems), so remove it here. +// FIXME: If we rewrite pathGetFileName (the current version is in +// FileSystemPOSIX), we can get the filename that way rather than appending it. +static jstring uriFromUriFileName(JNIEnv* env, const WebCore::String& name) +{ + const WebCore::String fileName = name.left(name.reverseFind('/')); + return env->NewString(fileName.characters(), fileName.length()); +} + +// This class stores the URI and the size of each file for upload. The URI is +// stored so we do not have to create it again. The size is stored so we can +// compare the actual size of the file with the stated size. If the actual size +// is larger, we will not copy it, since we will not have enough space in our +// buffer. +class FileInfo { +public: + FileInfo(JNIEnv* env, const WebCore::String& name) { + m_uri = uriFromUriFileName(env, name); + checkException(env); + m_size = 0; + m_env = env; + } + ~FileInfo() { + m_env->DeleteLocalRef(m_uri); + } + int getSize() { return m_size; } + jstring getUri() { return m_uri; } + void setSize(int size) { m_size = size; } +private: + // This is only a pointer to the JNIEnv* returned by + // JSC::Bindings::getJNIEnv(). Used to delete the jstring when finished. + JNIEnv* m_env; + jstring m_uri; + int m_size; +}; + +PassRefPtr<WebCore::ResourceLoaderAndroid> WebFrame::startLoadingResource(WebCore::ResourceHandle* loader, const WebCore::ResourceRequest& request, + bool mainResource, bool synchronous) { #ifdef ANDROID_INSTRUMENT @@ -288,11 +380,7 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader, WebCore::String method = request.httpMethod(); WebCore::HTTPHeaderMap headers = request.httpHeaderFields(); - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return 0; - + JNIEnv* env = getJNIEnv(); WebCore::String urlStr = request.url().string(); int colon = urlStr.find(':'); bool allLower = true; @@ -313,6 +401,7 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader, jMethodStr = env->NewString(method.characters(), method.length()); jbyteArray jPostDataStr = NULL; WebCore::FormData* formdata = request.httpBody(); + AutoJObject obj = mJavaFrame->frame(env); if (formdata) { // We can use the formdata->flatten() but it will result in two // memcpys, first through loading up the vector with the form data @@ -325,10 +414,19 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader, // Sizing pass int size = 0; size_t n = elements.size(); + FileInfo** fileinfos = new FileInfo*[n]; for (size_t i = 0; i < n; ++i) { + fileinfos[i] = 0; const WebCore::FormDataElement& e = elements[i]; if (e.m_type == WebCore::FormDataElement::data) { size += e.m_data.size(); + } else if (e.m_type == WebCore::FormDataElement::encodedFile) { + fileinfos[i] = new FileInfo(env, e.m_filename); + int delta = env->CallIntMethod(obj.get(), + mJavaFrame->mGetFileSize, fileinfos[i]->getUri()); + checkException(env); + fileinfos[i]->setSize(delta); + size += delta; } } @@ -347,11 +445,19 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader, int delta = e.m_data.size(); memcpy(bytes + offset, e.m_data.data(), delta); offset += delta; + } else if (e.m_type + == WebCore::FormDataElement::encodedFile) { + int delta = env->CallIntMethod(obj.get(), + mJavaFrame->mGetFile, fileinfos[i]->getUri(), + jPostDataStr, offset, fileinfos[i]->getSize()); + checkException(env); + offset += delta; } } env->ReleaseByteArrayElements(jPostDataStr, bytes, 0); } } + delete[] fileinfos; } jobject jHeaderMap = createJavaMapFromHTTPHeaders(env, headers); @@ -378,8 +484,10 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader, jobject jLoadListener = env->CallObjectMethod(obj.get(), mJavaFrame->mStartLoadingResource, - (int)loader, jUrlStr, jMethodStr, jHeaderMap, - jPostDataStr, cacheMode, synchronous); + (int)loader, jUrlStr, jMethodStr, jHeaderMap, + jPostDataStr, formdata ? formdata->identifier(): 0, + cacheMode, mainResource, request.getUserGesture(), + synchronous); env->DeleteLocalRef(jUrlStr); env->DeleteLocalRef(jMethodStr); @@ -388,9 +496,9 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader, if (checkException(env)) return NULL; - WebCoreResourceLoader* h = NULL; + PassRefPtr<WebCore::ResourceLoaderAndroid> h; if (jLoadListener) - h = new WebCoreResourceLoader(env, jLoadListener); + h = WebCoreResourceLoader::create(env, jLoadListener); env->DeleteLocalRef(jLoadListener); return h; } @@ -403,14 +511,12 @@ WebFrame::reportError(int errorCode, const WebCore::String& description, TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif LOGV("::WebCore:: reportError(%d, %s)", errorCode, description.ascii().data()); - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return; + JNIEnv* env = getJNIEnv(); jstring descStr = env->NewString((unsigned short*)description.characters(), description.length()); jstring failUrl = env->NewString((unsigned short*)failingUrl.characters(), failingUrl.length()); - env->CallVoidMethod(obj.get(), mJavaFrame->mReportError, errorCode, descStr, failUrl); + env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mReportError, + errorCode, descStr, failUrl); env->DeleteLocalRef(descStr); env->DeleteLocalRef(failUrl); } @@ -435,10 +541,7 @@ WebFrame::loadStarted(WebCore::Frame* frame) !isMainFrame)) return; - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return; + JNIEnv* env = getJNIEnv(); WebCore::String urlString(url.string()); // If this is the main frame and we already have a favicon in the database, // send it along with the page started notification. @@ -451,7 +554,7 @@ WebFrame::loadStarted(WebCore::Frame* frame) } jstring urlStr = env->NewString((unsigned short*)urlString.characters(), urlString.length()); - env->CallVoidMethod(obj.get(), mJavaFrame->mLoadStarted, urlStr, favicon, + env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mLoadStarted, urlStr, favicon, (int)loadType, isMainFrame); checkException(env); env->DeleteLocalRef(urlStr); @@ -475,13 +578,10 @@ WebFrame::transitionToCommitted(WebCore::Frame* frame) #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return; + JNIEnv* env = getJNIEnv(); WebCore::FrameLoadType loadType = frame->loader()->loadType(); bool isMainFrame = (!frame->tree() || !frame->tree()->parent()); - env->CallVoidMethod(obj.get(), mJavaFrame->mTransitionToCommitted, + env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mTransitionToCommitted, (int)loadType, isMainFrame); checkException(env); } @@ -492,10 +592,7 @@ WebFrame::didFinishLoad(WebCore::Frame* frame) #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return; + JNIEnv* env = getJNIEnv(); WebCore::FrameLoader* loader = frame->loader(); const WebCore::KURL& url = loader->activeDocumentLoader()->url(); if (url.isEmpty()) @@ -506,7 +603,7 @@ WebFrame::didFinishLoad(WebCore::Frame* frame) WebCore::FrameLoadType loadType = loader->loadType(); WebCore::String urlString(url.string()); jstring urlStr = env->NewString((unsigned short*)urlString.characters(), urlString.length()); - env->CallVoidMethod(obj.get(), mJavaFrame->mLoadFinished, urlStr, + env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mLoadFinished, urlStr, (int)loadType, isMainFrame); checkException(env); env->DeleteLocalRef(urlStr); @@ -519,7 +616,7 @@ WebFrame::addHistoryItem(WebCore::HistoryItem* item) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif LOGV("::WebCore:: addHistoryItem"); - JNIEnv* env = JSC::Bindings::getJNIEnv(); + JNIEnv* env = getJNIEnv(); WebHistory::AddItem(mJavaFrame->history(env), item); } @@ -530,7 +627,7 @@ WebFrame::removeHistoryItem(int index) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif LOGV("::WebCore:: removeHistoryItem at %d", index); - JNIEnv* env = JSC::Bindings::getJNIEnv(); + JNIEnv* env = getJNIEnv(); WebHistory::RemoveItem(mJavaFrame->history(env), index); } @@ -541,7 +638,7 @@ WebFrame::updateHistoryIndex(int newIndex) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif LOGV("::WebCore:: updateHistoryIndex to %d", newIndex); - JNIEnv* env = JSC::Bindings::getJNIEnv(); + JNIEnv* env = getJNIEnv(); WebHistory::UpdateHistoryIndex(mJavaFrame->history(env), newIndex); } @@ -554,13 +651,10 @@ WebFrame::setTitle(const WebCore::String& title) #ifndef NDEBUG LOGV("setTitle(%s)", title.ascii().data()); #endif - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return; + JNIEnv* env = getJNIEnv(); jstring jTitleStr = env->NewString((unsigned short *)title.characters(), title.length()); - env->CallVoidMethod(obj.get(), mJavaFrame->mSetTitle, + env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mSetTitle, jTitleStr); checkException(env); env->DeleteLocalRef(jTitleStr); @@ -573,12 +667,9 @@ WebFrame::windowObjectCleared(WebCore::Frame* frame) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif LOGV("::WebCore:: windowObjectCleared"); - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return; + JNIEnv* env = getJNIEnv(); - env->CallVoidMethod(obj.get(), mJavaFrame->mWindowObjectCleared, (int)frame); + env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mWindowObjectCleared, (int)frame); checkException(env); } @@ -588,12 +679,9 @@ WebFrame::setProgress(float newProgress) #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return; + JNIEnv* env = getJNIEnv(); int progress = (int) (100 * newProgress); - env->CallVoidMethod(obj.get(), mJavaFrame->mSetProgress, progress); + env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mSetProgress, progress); checkException(env); } @@ -610,15 +698,12 @@ WebFrame::didReceiveIcon(WebCore::Image* icon) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif LOG_ASSERT(icon, "DidReceiveIcon called without an image!"); - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return; + JNIEnv* env = getJNIEnv(); jobject bitmap = webcoreImageToJavaBitmap(env, icon); if (!bitmap) return; - env->CallVoidMethod(obj.get(), mJavaFrame->mDidReceiveIcon, bitmap); + env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mDidReceiveIcon, bitmap); env->DeleteLocalRef(bitmap); checkException(env); } @@ -629,14 +714,11 @@ WebFrame::didReceiveTouchIconURL(const WebCore::String& url, bool precomposed) #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return; + JNIEnv* env = getJNIEnv(); jstring jUrlStr = env->NewString((unsigned short*)url.characters(), url.length()); - env->CallVoidMethod(obj.get(), + env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mDidReceiveTouchIconUrl, jUrlStr, precomposed); checkException(env); } @@ -648,14 +730,10 @@ WebFrame::updateVisitedHistory(const WebCore::KURL& url, bool reload) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif WebCore::String urlStr(url.string()); - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return; - + JNIEnv* env = getJNIEnv(); jstring jUrlStr = env->NewString((unsigned short*)urlStr.characters(), urlStr.length()); - env->CallVoidMethod(obj.get(), mJavaFrame->mUpdateVisitedHistory, jUrlStr, reload); + env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mUpdateVisitedHistory, jUrlStr, reload); checkException(env); } @@ -678,15 +756,12 @@ WebFrame::canHandleRequest(const WebCore::ResourceRequest& request) // Empty urls should not be sent to java if (url.isEmpty()) return true; - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return true; + JNIEnv* env = getJNIEnv(); jstring jUrlStr = env->NewString((unsigned short *)url.characters(), url.length()); // check to see whether browser app wants to hijack url loading. // if browser app handles the url, we will return false to bail out WebCore loading - jboolean ret = env->CallBooleanMethod(obj.get(), mJavaFrame->mHandleUrl, jUrlStr); + jboolean ret = env->CallBooleanMethod(mJavaFrame->frame(env).get(), mJavaFrame->mHandleUrl, jUrlStr); checkException(env); return (ret == 0); } @@ -697,14 +772,11 @@ WebFrame::createWindow(bool dialog, bool userGesture) #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return NULL; - jobject jobj = env->CallObjectMethod(obj.get(), + JNIEnv* env = getJNIEnv(); + jobject obj = env->CallObjectMethod(mJavaFrame->frame(env).get(), mJavaFrame->mCreateWindow, dialog, userGesture); - if (jobj) { - WebCore::Frame* frame = GET_NATIVE_FRAME(env, jobj); + if (obj) { + WebCore::Frame* frame = GET_NATIVE_FRAME(env, obj); return frame; } return NULL; @@ -716,11 +788,8 @@ WebFrame::requestFocus() const #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), mJavaFrame->mRequestFocus); + JNIEnv* env = getJNIEnv(); + env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mRequestFocus); checkException(env); } @@ -731,11 +800,8 @@ WebFrame::closeWindow(WebViewCore* webViewCore) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif assert(webViewCore); - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), mJavaFrame->mCloseWindow, + JNIEnv* env = getJNIEnv(); + env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mCloseWindow, webViewCore->getJavaObject().get()); } @@ -749,23 +815,17 @@ WebFrame::decidePolicyForFormResubmission(WebCore::FramePolicyFunction func) #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return; + JNIEnv* env = getJNIEnv(); PolicyFunctionWrapper* p = new PolicyFunctionWrapper; p->func = func; - env->CallVoidMethod(obj.get(), mJavaFrame->mDecidePolicyForFormResubmission, p); + env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mDecidePolicyForFormResubmission, p); } WebCore::String -WebFrame::getRawResourceFilename(RAW_RES_ID id) const +WebFrame::getRawResourceFilename(WebCore::PlatformBridge::rawResId id) const { - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return WebCore::String(); - jstring ret = (jstring) env->CallObjectMethod(obj.get(), + JNIEnv* env = getJNIEnv(); + jstring ret = (jstring) env->CallObjectMethod(mJavaFrame->frame(env).get(), mJavaFrame->mGetRawResFilename, (int)id); return to_string(env, ret); @@ -774,11 +834,8 @@ WebFrame::getRawResourceFilename(RAW_RES_ID id) const float WebFrame::density() const { - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = mJavaFrame->frame(env); - if (!obj.get()) - return 1.0; - jfloat dpi = env->CallFloatMethod(obj.get(), mJavaFrame->mDensity); + JNIEnv* env = getJNIEnv(); + jfloat dpi = env->CallFloatMethod(mJavaFrame->frame(env).get(), mJavaFrame->mDensity); checkException(env); return dpi; } @@ -798,16 +855,12 @@ static void CallPolicyFunction(JNIEnv* env, jobject obj, jint func, jint decisio if (decision == WebCore::PolicyUse) pFrame->loader()->resetMultipleFormSubmissionProtection(); - (pFrame->loader()->*(pFunc->func))((WebCore::PolicyAction)decision); + (pFrame->loader()->policyChecker()->*(pFunc->func))((WebCore::PolicyAction)decision); } static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAssetManager, jobject historyList) { -#if USE(JSC) - JSC::initializeThreading(); -#elif USE(V8) - V8::initializeThreading(); -#endif + ScriptController::initializeThreading(); #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter); @@ -818,18 +871,10 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss WebCore::DragClient* dragC = new DragClientAndroid; InspectorClientAndroid* inspectorC = new InspectorClientAndroid; // Create a new page - WebCore::Page* page = new WebCore::Page(chromeC, contextMenuC, editorC, dragC, inspectorC); + WebCore::Page* page = new WebCore::Page(chromeC, contextMenuC, editorC, dragC, inspectorC, 0); // css files without explicit MIMETYPE is treated as generic text files in // the Java side. So we can't enforce CSS MIMETYPE. page->settings()->setEnforceCSSMIMETypeInStrictMode(false); - /* TODO: Don't turn on PageCache until we can restore the ScrollView State. - * This caused bug http://b/issue?id=1202983 - page->settings()->setUsesPageCache(true); - // 10 is a random number chosen because it is small enough to give the user - // a good back/forward page cache without allowing the page cache to get too - // big. - WebCore::pageCache()->setCapacity(10); - */ editorC->setPage(page); page->setGroupName("android.webkit"); @@ -865,15 +910,16 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss frame->selection()->setFocused(true); // Allow local access to file:/// and substitute data - WebCore::FrameLoader::setLocalLoadPolicy( - WebCore::FrameLoader::AllowLocalLoadsForLocalAndSubstituteData); + WebCore::SecurityOrigin::setLocalLoadPolicy( + WebCore::SecurityOrigin::AllowLocalLoadsForLocalAndSubstituteData); LOGV("::WebCore:: createFrame %p", frame); // Set the mNativeFrame field in Frame SET_NATIVE_FRAME(env, obj, (int)frame); - String directory = webFrame->getRawResourceFilename(WebFrame::DRAWABLEDIR); + String directory = webFrame->getRawResourceFilename( + WebCore::PlatformBridge::DrawableDir); if (directory.isEmpty()) LOGE("Can't find the drawable directory"); else { @@ -882,6 +928,10 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss // Initialize our skinning classes WebCore::RenderSkinAndroid::Init(am, directory); } + for (int i = WebCore::PlatformBridge::FileUploadLabel; + i <= WebCore::PlatformBridge::SubmitLabel; i++) + initGlobalLocalizedName( + static_cast<WebCore::PlatformBridge::rawResId>(i), webFrame); } static void DestroyFrame(JNIEnv* env, jobject obj) @@ -942,13 +992,17 @@ static void PostUrl(JNIEnv *env, jobject obj, jstring url, jbyteArray postData) if (postData) { jsize size = env->GetArrayLength(postData); jbyte* bytes = env->GetByteArrayElements(postData, NULL); - request.setHTTPBody(WebCore::FormData::create((const void*)bytes, size)); + RefPtr<FormData> formData = FormData::create((const void*)bytes, size); + // the identifier uses the same logic as generateFormDataIdentifier() in + // HTMLFormElement.cpp + formData->setIdentifier(static_cast<int64_t>(WTF::currentTime() * 1000000.0)); + request.setHTTPBody(formData); env->ReleaseByteArrayElements(postData, bytes, 0); } LOGV("PostUrl %s", kurl.string().latin1().data()); WebCore::FrameLoadRequest frameRequest(request); - pFrame->loader()->loadFrameRequest(frameRequest, false, false, 0, 0); + pFrame->loader()->loadFrameRequest(frameRequest, false, false, 0, 0, WebCore::SendReferrer); } static void LoadData(JNIEnv *env, jobject obj, jstring baseUrl, jstring data, @@ -973,7 +1027,7 @@ static void LoadData(JNIEnv *env, jobject obj, jstring baseUrl, jstring data, WebCore::SubstituteData substituteData(sharedBuffer, to_string(env, mimeType), to_string(env, encoding), - WebCore::KURL(to_string(env, failUrl))); + WebCore::KURL(ParsedURLString, to_string(env, failUrl))); // Perform the load pFrame->loader()->load(request, substituteData, false); @@ -1001,7 +1055,7 @@ static jstring ExternalRepresentation(JNIEnv *env, jobject obj) LOG_ASSERT(pFrame, "android_webcore_nativeExternalRepresentation must take a valid frame pointer!"); // Request external representation of the render tree - WebCore::String renderDump = WebCore::externalRepresentation(pFrame->contentRenderer()); + WebCore::String renderDump = WebCore::externalRepresentation(pFrame); unsigned len = renderDump.length(); if (!len) return NULL; @@ -1060,7 +1114,7 @@ static void GoBackOrForward(JNIEnv *env, jobject obj, jint pos) else if (pos == -1) pFrame->page()->goBack(); else - pFrame->loader()->goBackOrForward(pos); + pFrame->page()->goBackOrForward(pos); } static jobject StringByEvaluatingJavaScriptFromString(JNIEnv *env, jobject obj, jstring script) @@ -1072,9 +1126,14 @@ static jobject StringByEvaluatingJavaScriptFromString(JNIEnv *env, jobject obj, LOG_ASSERT(pFrame, "stringByEvaluatingJavaScriptFromString must take a valid frame pointer!"); WebCore::ScriptValue value = - pFrame->loader()->executeScript(to_string(env, script), true); + pFrame->script()->executeScript(to_string(env, script), true); WebCore::String result = WebCore::String(); - if (!value.getString(result)) +#if USE(JSC) + ScriptState* scriptState = pFrame->script()->globalObject(mainThreadNormalWorld())->globalExec(); +#elif USE(V8) + ScriptState* scriptState = pFrame->script()->mainWorldScriptState(); +#endif + if (!value.getString(scriptState, result)) return NULL; unsigned len = result.length(); if (len == 0) @@ -1082,31 +1141,55 @@ static jobject StringByEvaluatingJavaScriptFromString(JNIEnv *env, jobject obj, return env->NewString((unsigned short*)result.characters(), len); } -#if USE(JSC) // Wrap the JavaInstance used when binding custom javascript interfaces. Use a // weak reference so that the gc can collect the WebView. Override virtualBegin // and virtualEnd and swap the weak reference for the real object. -class WeakJavaInstance : public JSC::Bindings::JavaInstance { +class WeakJavaInstance : public JavaInstance { public: - static PassRefPtr<WeakJavaInstance> create(jobject obj, - PassRefPtr<JSC::Bindings::RootObject> root) { +#if USE(JSC) + static PassRefPtr<WeakJavaInstance> create(jobject obj, PassRefPtr<RootObject> root) + { return adoptRef(new WeakJavaInstance(obj, root)); } +#elif USE(V8) + static PassRefPtr<WeakJavaInstance> create(jobject obj) + { + return adoptRef(new WeakJavaInstance(obj)); + } +#endif -protected: - WeakJavaInstance(jobject instance, PassRefPtr<JSC::Bindings::RootObject> rootObject) - : JSC::Bindings::JavaInstance(instance, rootObject) +private: +#if USE(JSC) + WeakJavaInstance(jobject instance, PassRefPtr<RootObject> rootObject) + : JavaInstance(instance, rootObject) +#elif USE(V8) + WeakJavaInstance(jobject instance) : JavaInstance(instance) +#endif { - JNIEnv* env = JSC::Bindings::getJNIEnv(); + JNIEnv* env = getJNIEnv(); // JavaInstance creates a global ref to instance in its constructor. - env->DeleteGlobalRef(_instance->_instance); - // Set the object to our WeakReference wrapper. - _instance->_instance = adoptGlobalRef(env, instance); + env->DeleteGlobalRef(_instance->instance()); + // Set the object to a weak reference. + _instance->setInstance(env->NewWeakGlobalRef(instance)); + } + ~WeakJavaInstance() + { + JNIEnv* env = getJNIEnv(); + // Store the weak reference so we can delete it later. + jweak weak = _instance->instance(); + // The JavaInstance destructor attempts to delete the global ref stored + // in _instance. Since we replaced it in our constructor with a weak + // reference, restore the global ref here so the vm will not complain. + _instance->setInstance(env->NewGlobalRef( + getRealObject(env, _instance->instance()).get())); + // Delete the weak reference. + env->DeleteWeakGlobalRef(weak); } - virtual void virtualBegin() { - _weakRef = _instance->_instance; - JNIEnv* env = JSC::Bindings::getJNIEnv(); + virtual void virtualBegin() + { + _weakRef = _instance->instance(); + JNIEnv* env = getJNIEnv(); // This is odd. getRealObject returns an AutoJObject which is used to // cleanly create and delete a local reference. But, here we need to // maintain the local reference across calls to virtualBegin() and @@ -1114,26 +1197,26 @@ protected: // and delete the local reference in virtualEnd(). _realObject = getRealObject(env, _weakRef).release(); // Point to the real object - _instance->_instance = _realObject; + _instance->setInstance(_realObject); // Call the base class method INHERITED::virtualBegin(); } - virtual void virtualEnd() { + virtual void virtualEnd() + { // Call the base class method first to pop the local frame. INHERITED::virtualEnd(); // Get rid of the local reference to the real object. - JSC::Bindings::getJNIEnv()->DeleteLocalRef(_realObject); + getJNIEnv()->DeleteLocalRef(_realObject); // Point back to the WeakReference. - _instance->_instance = _weakRef; + _instance->setInstance(_weakRef); } private: - typedef JSC::Bindings::JavaInstance INHERITED; + typedef JavaInstance INHERITED; jobject _realObject; - jobject _weakRef; + jweak _weakRef; }; -#endif // USE(JSC) static void AddJavascriptInterface(JNIEnv *env, jobject obj, jint nativeFramePointer, jobject javascriptObj, jstring interfaceName) @@ -1155,39 +1238,44 @@ static void AddJavascriptInterface(JNIEnv *env, jobject obj, jint nativeFramePoi #if USE(JSC) // Copied from qwebframe.cpp JSC::JSLock lock(false); - WebCore::JSDOMWindow *window = WebCore::toJSDOMWindow(pFrame); + WebCore::JSDOMWindow *window = WebCore::toJSDOMWindow(pFrame, mainThreadNormalWorld()); if (window) { - JSC::Bindings::RootObject *root = pFrame->script()->bindingRootObject(); - JSC::Bindings::setJavaVM(vm); + RootObject *root = pFrame->script()->bindingRootObject(); + setJavaVM(vm); // Add the binding to JS environment JSC::ExecState* exec = window->globalExec(); - JSC::JSObject *addedObject = WeakJavaInstance::create(javascriptObj, + JSC::JSObject* addedObject = WeakJavaInstance::create(javascriptObj, root)->createRuntimeObject(exec); const jchar* s = env->GetStringChars(interfaceName, NULL); if (s) { // Add the binding name to the window's table of child objects. JSC::PutPropertySlot slot; - window->put(exec, JSC::Identifier(exec, (const UChar *)s, + window->put(exec, JSC::Identifier(exec, (const UChar *)s, env->GetStringLength(interfaceName)), addedObject, slot); env->ReleaseStringChars(interfaceName, s); checkException(env); } } -#endif // USE(JSC) - -#if USE(V8) +#elif USE(V8) if (pFrame) { - const char* name = JSC::Bindings::getCharactersFromJStringInEnv(env, interfaceName); - NPObject* obj = JSC::Bindings::JavaInstanceToNPObject(new JSC::Bindings::JavaInstance(javascriptObj)); + PassRefPtr<JavaInstance> addedObject = WeakJavaInstance::create(javascriptObj); + const char* name = getCharactersFromJStringInEnv(env, interfaceName); + // Pass ownership of the added object to bindToWindowObject. + NPObject* obj = JavaInstanceToNPObject(addedObject.releaseRef()); pFrame->script()->bindToWindowObject(pFrame, name, obj); - // JavaInstanceToNPObject calls NPN_RetainObject on the - // returned one (see CreateV8ObjectForNPObject in V8NPObject.cpp). - // BindToWindowObject also increases obj's ref count and decrease + // bindToWindowObject calls NPN_RetainObject on the + // returned one (see createV8ObjectForNPObject in V8NPObject.cpp). + // bindToWindowObject also increases obj's ref count and decreases // the ref count when the object is not reachable from JavaScript // side. Code here must release the reference count increased by - // JavaInstanceToNPObject. - _NPN_ReleaseObject(obj); - JSC::Bindings::releaseCharactersForJString(interfaceName, name); + // bindToWindowObject. + + // Note that while this function is declared in WebCore/bridge/npruntime.h, for V8 builds + // we use WebCore/bindings/v8/npruntime.cpp (rather than + // WebCore/bridge/npruntime.cpp), so the function is implemented there. + // TODO: Combine the two versions of these NPAPI files. + NPN_ReleaseObject(obj); + releaseCharactersForJString(interfaceName, name); } #endif @@ -1228,6 +1316,14 @@ static void ClearCache(JNIEnv *env, jobject obj) WebCore::cache()->setDisabled(true); WebCore::cache()->setDisabled(false); } + + // clear page cache + int pageCapacity = WebCore::pageCache()->capacity(); + // Setting size to 0, makes all pages be released. + WebCore::pageCache()->setCapacity(0); + WebCore::pageCache()->releaseAutoreleasedPagesNow(); + WebCore::pageCache()->setCapacity(pageCapacity); + #if USE(JSC) // force JavaScript to GC when clear cache WebCore::gcController().garbageCollectSoon(); @@ -1381,9 +1477,6 @@ static jobject GetFormTextData(JNIEnv *env, jobject obj) "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); LOG_ASSERT(put, "Could not find put method on HashMap"); - static const WebCore::AtomicString text("text"); - static const WebCore::AtomicString off("off"); - WebCore::HTMLFormElement* form; WebCore::HTMLInputElement* input; for (WebCore::Node* node = collection->firstItem(); node; node = collection->nextItem()) { @@ -1393,23 +1486,21 @@ static jobject GetFormTextData(JNIEnv *env, jobject obj) size_t size = elements.size(); for (size_t i = 0; i < size; i++) { WebCore::HTMLFormControlElement* e = elements[i]; - if (e->type() == text) { - if (e->hasAttribute(WebCore::HTMLNames::autocompleteAttr)) { - const WebCore::AtomicString& attr = e->getAttribute(WebCore::HTMLNames::autocompleteAttr); - if (attr == off) - continue; - } - input = (WebCore::HTMLInputElement*) e; - WebCore::String value = input->value(); - int len = value.length(); - if (len) { - const WebCore::AtomicString& name = input->name(); - jstring key = env->NewString((jchar *)name.characters(), name.length()); - jstring val = env->NewString((jchar *)value.characters(), len); - LOG_ASSERT(key && val, "name or value not set"); - env->CallObjectMethod(hashMap, put, key, val); - env->DeleteLocalRef(key); - env->DeleteLocalRef(val); + if (e->hasTagName(WebCore::HTMLNames::inputTag)) { + input = static_cast<WebCore::HTMLInputElement*>(e); + if (input->isTextField() && !input->isPasswordField() + && input->autoComplete()) { + WebCore::String value = input->value(); + int len = value.length(); + if (len) { + const WebCore::AtomicString& name = input->name(); + jstring key = env->NewString((jchar *)name.characters(), name.length()); + jstring val = env->NewString((jchar *)value.characters(), len); + LOG_ASSERT(key && val, "name or value not set"); + env->CallObjectMethod(hashMap, put, key, val); + env->DeleteLocalRef(key); + env->DeleteLocalRef(val); + } } } } @@ -1421,6 +1512,16 @@ static jobject GetFormTextData(JNIEnv *env, jobject obj) return hashMap; } +static void OrientationChanged(JNIEnv *env, jobject obj, int orientation) +{ +#ifdef ANDROID_INSTRUMENT + TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter); +#endif + WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj); + LOGE("Sending orientation: %d", orientation); + pFrame->sendOrientationChangeEvent(orientation); +} + // ---------------------------------------------------------------------------- /* @@ -1470,7 +1571,9 @@ static JNINativeMethod gBrowserFrameNativeMethods[] = { { "setUsernamePassword", "(Ljava/lang/String;Ljava/lang/String;)V", (void*) SetUsernamePassword }, { "getFormTextData", "()Ljava/util/HashMap;", - (void*) GetFormTextData } + (void*) GetFormTextData }, + { "nativeOrientationChanged", "(I)V", + (void*) OrientationChanged } }; int register_webframe(JNIEnv* env) diff --git a/WebKit/android/jni/WebCoreFrameBridge.h b/WebKit/android/jni/WebCoreFrameBridge.h index 7b49981..657ebf1 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.h +++ b/WebKit/android/jni/WebCoreFrameBridge.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -29,9 +29,10 @@ #define WEBFRAME_H #include "FrameLoaderClient.h" -#include "PlatformString.h" +#include "PlatformBridge.h" #include "WebCoreRefObject.h" #include <jni.h> +#include <wtf/RefCounted.h> namespace WebCore { class HistoryItem; @@ -39,31 +40,25 @@ namespace WebCore { class Page; class RenderPart; class ResourceHandle; + class ResourceLoaderAndroid; class ResourceRequest; } namespace android { -class WebCoreResourceLoader; class WebViewCore; // one instance of WebFrame per Page for calling into Java's BrowserFrame class WebFrame : public WebCoreRefObject { public: - // these ids need to be in sync with the constants in BrowserFrame.java - enum RAW_RES_ID { - NODOMAIN = 1, - LOADERROR, - DRAWABLEDIR, - }; WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* page); ~WebFrame(); // helper function static WebFrame* getWebFrame(const WebCore::Frame* frame); - virtual WebCoreResourceLoader* startLoadingResource(WebCore::ResourceHandle*, - const WebCore::ResourceRequest& request, + virtual PassRefPtr<WebCore::ResourceLoaderAndroid> startLoadingResource(WebCore::ResourceHandle*, + const WebCore::ResourceRequest& request, bool mainResource, bool synchronous); void reportError(int errorCode, const WebCore::String& description, @@ -107,7 +102,7 @@ class WebFrame : public WebCoreRefObject { void setUserAgent(WebCore::String userAgent) { mUserAgent = userAgent; } - WebCore::String getRawResourceFilename(RAW_RES_ID) const; + WebCore::String getRawResourceFilename(WebCore::PlatformBridge::rawResId) const; float density() const; diff --git a/WebKit/android/jni/WebCoreJni.cpp b/WebKit/android/jni/WebCoreJni.cpp index e7088b2..ef33cc0 100644 --- a/WebKit/android/jni/WebCoreJni.cpp +++ b/WebKit/android/jni/WebCoreJni.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -22,6 +22,7 @@ * (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 "webcoreglue" #include "config.h" @@ -34,25 +35,10 @@ namespace android { -// Class, constructor, and get method on WeakReference -jclass gWeakRefClass; -jmethodID gWeakRefInit; -jmethodID gWeakRefGet; - -jobject adoptGlobalRef(JNIEnv* env, jobject obj) -{ - // Create a WeakReference object - jobject ref = env->NewObject(gWeakRefClass, gWeakRefInit, obj); - // Increment the ref count of the WeakReference - ref = env->NewGlobalRef(ref); - return ref; -} - AutoJObject getRealObject(JNIEnv* env, jobject obj) { - jobject real = env->CallObjectMethod(obj, gWeakRefGet); - if (!real) - LOGE("The real object has been deleted"); + jobject real = env->NewLocalRef(obj); + LOG_ASSERT(real, "The real object has been deleted!"); return AutoJObject(env, real); } @@ -85,20 +71,4 @@ WebCore::String to_string(JNIEnv* env, jstring str) return ret; } -int register_webcorejni(JNIEnv* env) { - // Instantiate the WeakReference fields. - jclass weakRef = env->FindClass("java/lang/ref/WeakReference"); - LOG_ASSERT(weakRef, "Could not find WeakReference"); - android::gWeakRefClass = (jclass)env->NewGlobalRef(weakRef); - android::gWeakRefInit = env->GetMethodID(android::gWeakRefClass, - "<init>", "(Ljava/lang/Object;)V"); - LOG_ASSERT(android::gWeakRefInit, - "Could not find constructor for WeakReference"); - android::gWeakRefGet = env->GetMethodID(android::gWeakRefClass, "get", - "()Ljava/lang/Object;"); - LOG_ASSERT(android::gWeakRefInit, - "Could not find get method for WeakReference"); - return JNI_OK; -} - } diff --git a/WebKit/android/jni/WebCoreJni.h b/WebKit/android/jni/WebCoreJni.h index 0b55497..1a1bfc0 100644 --- a/WebKit/android/jni/WebCoreJni.h +++ b/WebKit/android/jni/WebCoreJni.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -61,14 +61,10 @@ private: friend AutoJObject getRealObject(JNIEnv*, jobject); }; -// Get the real object stored in the WeakReference returned as an +// Get the real object stored in the weak reference returned as an // AutoJObject. AutoJObject getRealObject(JNIEnv*, jobject); -// Convert the given jobject to a WeakReference and create a new global -// reference to that WeakReference. -jobject adoptGlobalRef(JNIEnv*, jobject); - // Helper method for check java exceptions. Returns true if an exception // occurred and logs the exception. bool checkException(JNIEnv* env); diff --git a/WebKit/android/jni/WebCoreJniOnLoad.cpp b/WebKit/android/jni/WebCoreJniOnLoad.cpp index 0d2b61f..d69177e 100644 --- a/WebKit/android/jni/WebCoreJniOnLoad.cpp +++ b/WebKit/android/jni/WebCoreJniOnLoad.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -22,10 +22,49 @@ * (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 "webcoreglue" #include "config.h" +#include "BackForwardList.h" +#include "ChromeClientAndroid.h" +#include "ContextMenuClientAndroid.h" +#include "CookieClient.h" +#include "DragClientAndroid.h" +#include "EditorClientAndroid.h" +#include "Frame.h" +#include "FrameLoader.h" +#include "FrameLoaderClientAndroid.h" +#include "FrameView.h" +#include "GraphicsContext.h" +#include "HistoryItem.h" +#include "InspectorClientAndroid.h" +#include "IntRect.h" +#include "JavaSharedClient.h" +#include "jni_utility.h" +#include "Page.h" +#include "PlatformGraphicsContext.h" +#include "ResourceRequest.h" +#include "ScriptController.h" +#include "SecurityOrigin.h" +#include "SelectionController.h" +#include "Settings.h" +#include "SharedBuffer.h" +#include "SubstituteData.h" +#include "TimerClient.h" +#include "TextEncoding.h" +#include "WebCoreViewBridge.h" +#include "WebFrameView.h" +#include "WebViewCore.h" + +#include "SkBitmap.h" +#include "SkCanvas.h" +#include "SkImageEncoder.h" + +#include "benchmark/Intercept.h" +#include "benchmark/MyJavaVM.h" + #include "jni_utility.h" #include <jni.h> #include <utils/Log.h> @@ -40,7 +79,6 @@ extern int register_webhistory(JNIEnv*); extern int register_webicondatabase(JNIEnv*); extern int register_websettings(JNIEnv*); extern int register_webview(JNIEnv*); -extern int register_webcorejni(JNIEnv*); #if ENABLE(DATABASE) extern int register_webstorage(JNIEnv*); #endif @@ -61,7 +99,6 @@ static RegistrationMethod gWebCoreRegMethods[] = { { "JavaBridge", android::register_javabridge }, { "WebFrame", android::register_webframe }, { "WebCoreResourceLoader", android::register_resource_loader }, - { "WebCoreJni", android::register_webcorejni }, { "WebViewCore", android::register_webviewcore }, { "WebHistory", android::register_webhistory }, { "WebIconDatabase", android::register_webicondatabase }, @@ -107,3 +144,143 @@ EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) return JNI_VERSION_1_4; } + +class MyJavaSharedClient : public TimerClient, public CookieClient { +public: + MyJavaSharedClient() : m_hasTimer(false) {} + virtual void setSharedTimer(long long timemillis) { m_hasTimer = true; } + virtual void stopSharedTimer() { m_hasTimer = false; } + virtual void setSharedTimerCallback(void (*f)()) { m_func = f; } + virtual void signalServiceFuncPtrQueue() {} + + // Cookie methods that do nothing. + virtual void setCookies(const KURL&, const String&) {} + virtual String cookies(const KURL&) { return ""; } + virtual bool cookiesEnabled() { return false; } + + bool m_hasTimer; + void (*m_func)(); +}; + +static void historyItemChanged(HistoryItem* i) { + if (i->bridge()) + i->bridge()->updateHistoryItem(i); +} + +namespace android { + +EXPORT void benchmark(const char* url, int reloadCount, int width, int height) { + ScriptController::initializeThreading(); + + // Setting this allows data: urls to load from a local file. + SecurityOrigin::setLocalLoadPolicy(SecurityOrigin::AllowLocalLoadsForAll); + + // Create the fake JNIEnv and JavaVM + InitializeJavaVM(); + + // The real function is private to libwebcore but we know what it does. + notifyHistoryItemChanged = historyItemChanged; + + // Implement the shared timer callback + MyJavaSharedClient client; + JavaSharedClient::SetTimerClient(&client); + JavaSharedClient::SetCookieClient(&client); + + // Create the page with all the various clients + ChromeClientAndroid* chrome = new ChromeClientAndroid; + EditorClientAndroid* editor = new EditorClientAndroid; + Page* page = new Page(chrome, new ContextMenuClientAndroid, editor, + new DragClientAndroid, new InspectorClientAndroid, NULL); + editor->setPage(page); + + // Create MyWebFrame that intercepts network requests + MyWebFrame* webFrame = new MyWebFrame(page); + webFrame->setUserAgent("Performance testing"); // needs to be non-empty + chrome->setWebFrame(webFrame); + // ChromeClientAndroid maintains the reference. + Release(webFrame); + + // Create the Frame and the FrameLoaderClient + FrameLoaderClientAndroid* loader = new FrameLoaderClientAndroid(webFrame); + RefPtr<Frame> frame = Frame::create(page, NULL, loader); + loader->setFrame(frame.get()); + + // Build our View system, resize it to the given dimensions and release our + // references. Note: We keep a referenec to frameView so we can layout and + // draw later without risk of it being deleted. + WebViewCore* webViewCore = new WebViewCore(JSC::Bindings::getJNIEnv(), + MY_JOBJECT, frame.get()); + RefPtr<FrameView> frameView = FrameView::create(frame.get()); + WebFrameView* webFrameView = new WebFrameView(frameView.get(), webViewCore); + frame->setView(frameView); + frameView->resize(width, height); + Release(webViewCore); + Release(webFrameView); + + // Initialize the frame and turn of low-bandwidth display (it fails an + // assertion in the Cache code) + frame->init(); + frame->selection()->setFocused(true); + + // Set all the default settings the Browser normally uses. + Settings* s = frame->settings(); + s->setLayoutAlgorithm(Settings::kLayoutNormal); // Normal layout for now + s->setStandardFontFamily("sans-serif"); + s->setFixedFontFamily("monospace"); + s->setSansSerifFontFamily("sans-serif"); + s->setSerifFontFamily("serif"); + s->setCursiveFontFamily("cursive"); + s->setFantasyFontFamily("fantasy"); + s->setMinimumFontSize(8); + s->setMinimumLogicalFontSize(8); + s->setDefaultFontSize(16); + s->setDefaultFixedFontSize(13); + s->setLoadsImagesAutomatically(true); + s->setJavaScriptEnabled(true); + s->setDefaultTextEncodingName("latin1"); + s->setPluginsEnabled(false); + s->setShrinksStandaloneImagesToFit(false); + s->setUseWideViewport(false); + + // Finally, load the actual data + ResourceRequest req(url); + frame->loader()->load(req, false); + + do { + // Layout the page and service the timer + frame->view()->layout(); + while (client.m_hasTimer) { + client.m_func(); + JavaSharedClient::ServiceFunctionPtrQueue(); + } + JavaSharedClient::ServiceFunctionPtrQueue(); + + // Layout more if needed. + while (frame->view()->needsLayout()) + frame->view()->layout(); + JavaSharedClient::ServiceFunctionPtrQueue(); + + if (reloadCount) + frame->loader()->reload(true); + } while (reloadCount--); + + // Draw into an offscreen bitmap + SkBitmap bmp; + bmp.setConfig(SkBitmap::kARGB_8888_Config, width, height); + bmp.allocPixels(); + SkCanvas canvas(bmp); + PlatformGraphicsContext ctx(&canvas, NULL); + GraphicsContext gc(&ctx); + frame->view()->paintContents(&gc, IntRect(0, 0, width, height)); + + // Write the bitmap to the sdcard + SkImageEncoder* enc = SkImageEncoder::Create(SkImageEncoder::kPNG_Type); + enc->encodeFile("/sdcard/webcore_test.png", bmp, 100); + delete enc; + + // Tear down the world. + frame->loader()->detachFromParent(); + delete page; +} + +} // namespace android diff --git a/WebKit/android/jni/WebCoreRefObject.h b/WebKit/android/jni/WebCoreRefObject.h index 3e9f840..4228db6 100644 --- a/WebKit/android/jni/WebCoreRefObject.h +++ b/WebKit/android/jni/WebCoreRefObject.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/jni/WebCoreResourceLoader.cpp b/WebKit/android/jni/WebCoreResourceLoader.cpp index 5ccd09c..55af52d 100644 --- a/WebKit/android/jni/WebCoreResourceLoader.cpp +++ b/WebKit/android/jni/WebCoreResourceLoader.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -68,6 +68,11 @@ static struct resourceloader_t { //----------------------------------------------------------------------------- // ResourceLoadHandler +PassRefPtr<WebCore::ResourceLoaderAndroid> WebCoreResourceLoader::create(JNIEnv *env, jobject jLoadListener) +{ + return adoptRef<WebCore::ResourceLoaderAndroid>(new WebCoreResourceLoader(env, jLoadListener)); +} + WebCoreResourceLoader::WebCoreResourceLoader(JNIEnv *env, jobject jLoadListener) { mJLoader = env->NewGlobalRef(jLoadListener); @@ -100,14 +105,14 @@ void WebCoreResourceLoader::downloadFile() * the cache. This may be slow, but is only used during a navigation to * a POST response. */ -bool WebCoreResourceLoader::willLoadFromCache(const WebCore::KURL& url) +bool WebCoreResourceLoader::willLoadFromCache(const WebCore::KURL& url, int64_t identifier) { JNIEnv* env = JSC::Bindings::getJNIEnv(); WebCore::String urlStr = url.string(); jstring jUrlStr = env->NewString(urlStr.characters(), urlStr.length()); jclass resourceLoader = env->FindClass("android/webkit/LoadListener"); bool val = env->CallStaticBooleanMethod(resourceLoader, - gResourceLoader.mWillLoadFromCacheMethodID, jUrlStr); + gResourceLoader.mWillLoadFromCacheMethodID, jUrlStr, identifier); checkException(env); env->DeleteLocalRef(jUrlStr); @@ -140,7 +145,7 @@ jint WebCoreResourceLoader::CreateResponse(JNIEnv* env, jobject obj, jstring url TimeCounterAuto counter(TimeCounter::ResourceTimeCounter); #endif LOG_ASSERT(url, "Must have a url in the response!"); - WebCore::KURL kurl(to_string(env, url)); + WebCore::KURL kurl(WebCore::ParsedURLString, to_string(env, url)); WebCore::String encodingStr; WebCore::String mimeTypeStr; if (mimeType) { @@ -235,7 +240,7 @@ jstring WebCoreResourceLoader::RedirectedToUrl(JNIEnv* env, jobject obj, LOG_ASSERT(handle->client(), "Why do we not have a client?"); WebCore::ResourceRequest r = handle->request(); - WebCore::KURL url(WebCore::KURL(to_string(env, baseUrl)), + WebCore::KURL url(WebCore::KURL(WebCore::ParsedURLString, to_string(env, baseUrl)), to_string(env, redirectTo)); r.setURL(url); if (r.httpMethod() == "POST") { @@ -318,7 +323,7 @@ int register_resource_loader(JNIEnv* env) "Could not find method downloadFile on LoadListener"); gResourceLoader.mWillLoadFromCacheMethodID = - env->GetStaticMethodID(resourceLoader, "willLoadFromCache", "(Ljava/lang/String;)Z"); + env->GetStaticMethodID(resourceLoader, "willLoadFromCache", "(Ljava/lang/String;J)Z"); LOG_FATAL_IF(gResourceLoader.mWillLoadFromCacheMethodID == NULL, "Could not find static method willLoadFromCache on LoadListener"); diff --git a/WebKit/android/jni/WebCoreResourceLoader.h b/WebKit/android/jni/WebCoreResourceLoader.h index 60c0d0e..d24a43e 100644 --- a/WebKit/android/jni/WebCoreResourceLoader.h +++ b/WebKit/android/jni/WebCoreResourceLoader.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -26,34 +26,33 @@ #ifndef ANDROID_WEBKIT_RESOURCELOADLISTENER_H #define ANDROID_WEBKIT_RESOURCELOADLISTENER_H -#include "KURL.h" - -#include "WebCoreRefObject.h" +#include <KURL.h> +#include <ResourceLoaderAndroid.h> #include <jni.h> namespace android { -class WebCoreResourceLoader : public WebCoreRefObject +class WebCoreResourceLoader : public WebCore::ResourceLoaderAndroid { public: - WebCoreResourceLoader(JNIEnv *env, jobject jLoadListener); + static PassRefPtr<WebCore::ResourceLoaderAndroid> create(JNIEnv *env, jobject jLoadListener); virtual ~WebCoreResourceLoader(); /** * Call to java to cancel the current load. */ - void cancel(); + virtual void cancel(); /** * Call to java to download the current load rather than feed it * back to WebCore */ - void downloadFile(); + virtual void downloadFile(); /** * Call to java to find out if this URL is in the cache */ - static bool willLoadFromCache(const WebCore::KURL& url); + static bool willLoadFromCache(const WebCore::KURL& url, int64_t identifier); // Native jni functions static void SetResponseHeader(JNIEnv*, jobject, jint, jstring, jstring); @@ -65,6 +64,8 @@ public: static jstring RedirectedToUrl(JNIEnv*, jobject, jstring, jstring, jint); static void Error(JNIEnv*, jobject, jint, jstring, jstring); +protected: + WebCoreResourceLoader(JNIEnv *env, jobject jLoadListener); private: jobject mJLoader; }; diff --git a/WebKit/android/jni/WebCoreViewBridge.h b/WebKit/android/jni/WebCoreViewBridge.h index db79a37..61990af 100644 --- a/WebKit/android/jni/WebCoreViewBridge.h +++ b/WebKit/android/jni/WebCoreViewBridge.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/jni/WebFrameView.cpp b/WebKit/android/jni/WebFrameView.cpp index 0ab7410..8e5eac4 100644 --- a/WebKit/android/jni/WebFrameView.cpp +++ b/WebKit/android/jni/WebFrameView.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -102,4 +102,3 @@ void WebFrameView::setView(WebCore::FrameView* frameView) { } } // namespace android - diff --git a/WebKit/android/jni/WebFrameView.h b/WebKit/android/jni/WebFrameView.h index 2347071..d83def1 100644 --- a/WebKit/android/jni/WebFrameView.h +++ b/WebKit/android/jni/WebFrameView.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/jni/WebHistory.cpp b/WebKit/android/jni/WebHistory.cpp index d7aacfb..76a310b 100644 --- a/WebKit/android/jni/WebHistory.cpp +++ b/WebKit/android/jni/WebHistory.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -44,6 +44,7 @@ #include "TextEncoding.h" #include "WebCoreFrameBridge.h" #include "WebCoreJni.h" +#include "WebIconDatabase.h" #include "jni_utility.h" #include <JNIHelp.h> @@ -90,7 +91,7 @@ static void WebHistoryClose(JNIEnv* env, jobject obj, jint frame) list->removeItem(entries[i].get()); // Add the current item back to the list. if (current) { - current->setBridge(NULL); + current->setBridge(0); // addItem will update the children to match the newly created bridge list->addItem(current); @@ -113,7 +114,7 @@ static void WebHistoryClose(JNIEnv* env, jobject obj, jint frame) // Keep a small list of child frames to traverse. WTF::Vector<WebCore::Frame*> frameQueue; // Fix the top-level item. - pFrame->loader()->setCurrentHistoryItem(current); + pFrame->loader()->history()->setCurrentItem(current.get()); WebCore::Frame* child = pFrame->tree()->firstChild(); // Remember the parent history item so we can search for a child item. RefPtr<WebCore::HistoryItem> parent = current; @@ -121,10 +122,13 @@ static void WebHistoryClose(JNIEnv* env, jobject obj, jint frame) // Use the old history item since the current one may have a // deleted parent. WebCore::HistoryItem* item = parent->childItemWithTarget(child->tree()->name()); - child->loader()->setCurrentHistoryItem(item); - // Append the first child to the queue if it exists. - if (WebCore::Frame* f = child->tree()->firstChild()) - frameQueue.append(f); + child->loader()->history()->setCurrentItem(item); + // Append the first child to the queue if it exists. If there is no + // item, then we do not need to traverse the children since there + // will be no parent history item. + WebCore::Frame* firstChild; + if (item && (firstChild = child->tree()->firstChild())) + frameQueue.append(firstChild); child = child->tree()->nextSibling(); // If we don't have a sibling for this frame and the queue isn't // empty, use the next entry in the queue. @@ -133,7 +137,7 @@ static void WebHistoryClose(JNIEnv* env, jobject obj, jint frame) frameQueue.remove(0); // Figure out the parent history item used when searching for // the history item to use. - parent = child->tree()->parent()->loader()->currentHistoryItem(); + parent = child->tree()->parent()->loader()->history()->currentItem(); } } } @@ -152,7 +156,7 @@ static void WebHistoryRestoreIndex(JNIEnv* env, jobject obj, jint frame, jint in // Update the current and previous history item. WebCore::FrameLoader* loader = pFrame->loader(); - loader->setCurrentHistoryItem(currentItem); + loader->history()->setCurrentItem(currentItem); // load the current page with FrameLoadTypeIndexedBackForward so that it // will use cache when it is possible @@ -171,10 +175,9 @@ static void WebHistoryInflate(JNIEnv* env, jobject obj, jint frame, jbyteArray d // Inflate the history tree into one HistoryItem or null if the inflation // failed. RefPtr<WebCore::HistoryItem> newItem = WebCore::HistoryItem::create(); -#ifdef ANDROID_HISTORY_CLIENT RefPtr<WebHistoryItem> bridge = new WebHistoryItem(env, obj, newItem.get()); newItem->setBridge(bridge.get()); -#endif + // Inflate the item recursively. If it fails, that is ok. We'll have an // incomplete HistoryItem but that is better than crashing due to a null // item. @@ -184,28 +187,19 @@ static void WebHistoryInflate(JNIEnv* env, jobject obj, jint frame, jbyteArray d const char* ptr = reinterpret_cast<const char*>(bytes); read_item_recursive(newItem.get(), &ptr, (int)size); env->ReleaseByteArrayElements(data, const_cast<jbyte*>(bytes), JNI_ABORT); -#ifdef ANDROID_HISTORY_CLIENT bridge->setActive(); -#endif // Add the new item to the back/forward list. WebCore::Frame* pFrame = (WebCore::Frame*)frame; pFrame->page()->backForwardList()->addItem(newItem); -#ifdef ANDROID_HISTORY_CLIENT // Update the item. bridge->updateHistoryItem(newItem.get()); -#endif } // 6 empty strings + no document state + children count = 8 unsigned values -// 1 char for isTargetItem -// ANDROID_HISTORY_CLIENT adds 1 int for scale. -#ifdef ANDROID_HISTORY_CLIENT +// 1 char for isTargetItem and 1 char is for scale. #define HISTORY_MIN_SIZE ((int)(sizeof(unsigned) * 9 + sizeof(char))) -#else -#define HISTORY_MIN_SIZE ((int)(sizeof(unsigned) * 8 + sizeof(char))) -#endif jbyteArray WebHistory::Flatten(JNIEnv* env, WTF::Vector<char>& v, WebCore::HistoryItem* item) { @@ -217,9 +211,7 @@ jbyteArray WebHistory::Flatten(JNIEnv* env, WTF::Vector<char>& v, WebCore::Histo // Write the top-level history item and then write all the children // recursively. -#ifdef ANDROID_HISTORY_CLIENT LOG_ASSERT(item->bridge(), "Why don't we have a bridge object here?"); -#endif write_item(v, item); write_children_recursive(v, item); @@ -234,33 +226,29 @@ jbyteArray WebHistory::Flatten(JNIEnv* env, WTF::Vector<char>& v, WebCore::Histo } WebHistoryItem::WebHistoryItem(JNIEnv* env, jobject obj, - WebCore::HistoryItem* item) { - mObject = adoptGlobalRef(env, obj); - mScale = 100; - mActive = false; - mParent = NULL; - mHistoryItem = item; + WebCore::HistoryItem* item) : WebCore::AndroidWebHistoryBridge(item) { + m_object = env->NewWeakGlobalRef(obj); + m_parent = 0; } WebHistoryItem::~WebHistoryItem() { - if (mObject) { + if (m_object) { JNIEnv* env = JSC::Bindings::getJNIEnv(); if (!env) return; - env->DeleteGlobalRef(mObject); + env->DeleteWeakGlobalRef(m_object); } } void WebHistoryItem::updateHistoryItem(WebCore::HistoryItem* item) { -#ifdef ANDROID_HISTORY_CLIENT // Do not want to update during inflation. - if (!mActive) + if (!m_active) return; WebHistoryItem* webItem = this; // Now we need to update the top-most WebHistoryItem based on the top-most // HistoryItem. - if (mParent) { - webItem = mParent.get(); + if (m_parent) { + webItem = m_parent.get(); if (webItem->hasOneRef()) { // if the parent only has one ref, it is from this WebHistoryItem. // This means that the matching WebCore::HistoryItem has been freed. @@ -271,13 +259,20 @@ void WebHistoryItem::updateHistoryItem(WebCore::HistoryItem* item) { while (webItem->parent()) webItem = webItem->parent(); item = webItem->historyItem(); + if (!item) { + // If a HistoryItem only exists for page cache, it is possible that + // the parent HistoryItem destroyed before the child HistoryItem. If + // it happens, skip updating. + LOGW("Can't updateHistoryItem as the top HistoryItem is gone"); + return; + } } JNIEnv* env = JSC::Bindings::getJNIEnv(); if (!env) return; // Don't do anything if the item has been gc'd already - AutoJObject realItem = getRealObject(env, webItem->mObject); + AutoJObject realItem = getRealObject(env, webItem->m_object); if (!realItem.get()) return; @@ -322,21 +317,17 @@ void WebHistoryItem::updateHistoryItem(WebCore::HistoryItem* item) { if (favicon) env->DeleteLocalRef(favicon); env->DeleteLocalRef(array); -#endif } static void historyItemChanged(WebCore::HistoryItem* item) { -#ifdef ANDROID_HISTORY_CLIENT - LOG_ASSERT(item, - "historyItemChanged called with a null item"); + LOG_ASSERT(item, "historyItemChanged called with a null item"); + if (item->bridge()) item->bridge()->updateHistoryItem(item); -#endif } void WebHistory::AddItem(const AutoJObject& list, WebCore::HistoryItem* item) { -#ifdef ANDROID_HISTORY_CLIENT LOG_ASSERT(item, "newItem must take a valid HistoryItem!"); // Item already added. Should only happen when we are inflating the list. if (item->bridge() || !list.get()) @@ -361,7 +352,6 @@ void WebHistory::AddItem(const AutoJObject& list, WebCore::HistoryItem* item) // Delete our local reference. env->DeleteLocalRef(newItem); -#endif } void WebHistory::RemoveItem(const AutoJObject& list, int index) @@ -420,22 +410,23 @@ static void write_item(WTF::Vector<char>& v, WebCore::HistoryItem* item) // Form data const WebCore::FormData* formData = item->formData(); - if (formData) + if (formData) { write_string(v, formData->flattenToString()); - else + // save the identifier as it is not included in the flatten data + int64_t id = formData->identifier(); + v.append((char*)&id, sizeof(int64_t)); + } else write_string(v, WebCore::String()); // Empty constructor does not allocate a buffer. // Target write_string(v, item->target()); -#ifdef ANDROID_HISTORY_CLIENT - WebHistoryItem* bridge = item->bridge(); + AndroidWebHistoryBridge* bridge = item->bridge(); LOG_ASSERT(bridge, "We should have a bridge here!"); // Screen scale int scale = bridge->scale(); LOGV("Writing scale %d", scale); v.append((char*)&scale, sizeof(int)); -#endif // Document state const WTF::Vector<WebCore::String>& docState = item->documentState(); @@ -463,23 +454,23 @@ static void write_children_recursive(WTF::Vector<char>& v, WebCore::HistoryItem* WebCore::HistoryItemVector::const_iterator end = children.end(); for (WebCore::HistoryItemVector::const_iterator i = children.begin(); i != end; ++i) { WebCore::HistoryItem* item = (*i).get(); -#ifdef ANDROID_HISTORY_CLIENT LOG_ASSERT(parent->bridge(), "The parent item should have a bridge object!"); if (!item->bridge()) { - WebHistoryItem* bridge = new WebHistoryItem(parent->bridge()); + WebHistoryItem* bridge = new WebHistoryItem(static_cast<WebHistoryItem*>(parent->bridge())); item->setBridge(bridge); bridge->setActive(); } else { // The only time this item's parent may not be the same as the // parent's bridge is during history close. In that case, the // parent must not have a parent bridge. - LOG_ASSERT(parent->bridge()->parent() == NULL || - item->bridge()->parent() == parent->bridge(), + WebHistoryItem* bridge = static_cast<WebHistoryItem*>(item->bridge()); + WebHistoryItem* parentBridge = static_cast<WebHistoryItem*>(parent->bridge()); + LOG_ASSERT(parentBridge->parent() == 0 || + bridge->parent() == parentBridge, "Somehow this item has an incorrect parent"); - item->bridge()->setParent(parent->bridge()); + bridge->setParent(parentBridge); } -#endif write_item(v, item); write_children_recursive(v, item); } @@ -573,6 +564,15 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem, else return false; data += l; + // Read the identifier + { + int64_t id; + int size = (int)sizeof(int64_t); + memcpy(&id, data, size); + data += size; + if (id) + formData->setIdentifier(id); + } } if (end - data < sizeofUnsigned) return false; @@ -600,8 +600,7 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem, if (end - data < sizeofUnsigned) return false; -#ifdef ANDROID_HISTORY_CLIENT - WebHistoryItem* bridge = newItem->bridge(); + AndroidWebHistoryBridge* bridge = newItem->bridge(); LOG_ASSERT(bridge, "There should be a bridge object during inflate"); // Read the screen scale memcpy(&l, data, sizeofUnsigned); @@ -610,7 +609,6 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem, data += sizeofUnsigned; if (end - data < sizeofUnsigned) return false; -#endif // Read the document state memcpy(&l, data, sizeofUnsigned); @@ -670,18 +668,14 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem, // No need to check the length each time because read_item_recursive // will return null if there isn't enough data left to parse. WTF::PassRefPtr<WebCore::HistoryItem> child = WebCore::HistoryItem::create(); -#ifdef ANDROID_HISTORY_CLIENT // Set a bridge that will not call into java. - child->setBridge(new WebHistoryItem(bridge)); -#endif + child->setBridge(new WebHistoryItem(static_cast<WebHistoryItem*>(bridge))); // Read the child item. if (!read_item_recursive(child.get(), pData, end - data)) { child.clear(); return false; } -#ifdef ANDROID_HISTORY_CLIENT child->bridge()->setActive(); -#endif newItem->addChildItem(child); } } @@ -702,9 +696,7 @@ static void unit_test() const char* test1 = new char[0]; WTF::RefPtr<WebCore::HistoryItem> item = WebCore::HistoryItem::create(); WebCore::HistoryItem* testItem = item.get(); -#ifdef ANDROID_HISTORY_CLIENT - testItem->setBridge(new WebHistoryItem(NULL)); -#endif + testItem->setBridge(new WebHistoryItem(0)); LOG_ASSERT(!read_item_recursive(testItem, &test1, 0), "0 length array should fail!"); delete[] test1; const char* test2 = new char[2]; @@ -747,9 +739,7 @@ static void unit_test() ptr = (const char*)test3; *(int*)(test3 + offset) = 4000; LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length target should fail!"); -#ifdef ANDROID_HISTORY_CLIENT offset += 4; // Scale -#endif // Document state offset += 4; memset(test3, 0, HISTORY_MIN_SIZE); @@ -768,12 +758,7 @@ static void unit_test() ptr = (const char*)test3; *(int*)(test3 + offset) = 4000; LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 kids should fail!"); - -#ifdef ANDROID_HISTORY_CLIENT offset = 36; -#else - offset = 28; -#endif // Test document state delete[] test3; test3 = new char[HISTORY_MIN_SIZE + sizeof(unsigned)]; @@ -811,10 +796,8 @@ static JNINativeMethod gWebHistoryItemMethods[] = { int register_webhistory(JNIEnv* env) { -#ifdef ANDROID_HISTORY_CLIENT // Get notified of all changes to history items. WebCore::notifyHistoryItemChanged = historyItemChanged; -#endif #ifdef UNIT_TEST unit_test(); #endif diff --git a/WebKit/android/jni/WebHistory.h b/WebKit/android/jni/WebHistory.h index fe70443..12bf00a 100644 --- a/WebKit/android/jni/WebHistory.h +++ b/WebKit/android/jni/WebHistory.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -26,14 +26,12 @@ #ifndef ANDROID_WEBKIT_WEBHISTORY_H #define ANDROID_WEBKIT_WEBHISTORY_H +#include "AndroidWebHistoryBridge.h" + #include <jni.h> #include <wtf/RefCounted.h> #include <wtf/Vector.h> -namespace WebCore { - class HistoryItem; -} - namespace android { class AutoJObject; @@ -49,33 +47,20 @@ public: // there are two scale factors saved with each history item. mScale reflects the // viewport scale factor, default to 100 means 100%. mScreenWidthScale records // the scale factor for the screen width used to wrap the text paragraph. -class WebHistoryItem : public WTF::RefCounted<WebHistoryItem> { +class WebHistoryItem : public WebCore::AndroidWebHistoryBridge { public: WebHistoryItem(WebHistoryItem* parent) - : mParent(parent) - , mObject(NULL) - , mScale(100) - , mScreenWidthScale(100) - , mActive(false) - , mHistoryItem(NULL) {} + : WebCore::AndroidWebHistoryBridge(0) + , m_parent(parent) + , m_object(NULL) { } WebHistoryItem(JNIEnv*, jobject, WebCore::HistoryItem*); ~WebHistoryItem(); void updateHistoryItem(WebCore::HistoryItem* item); - void setScale(int s) { mScale = s; } - void setScreenWidthScale(int s) { mScreenWidthScale = s; } - void setActive() { mActive = true; } - void setParent(WebHistoryItem* parent) { mParent = parent; } - WebHistoryItem* parent() { return mParent.get(); } - int scale() { return mScale; } - int screenWidthScale() { return mScreenWidthScale; } - WebCore::HistoryItem* historyItem() { return mHistoryItem; } + void setParent(WebHistoryItem* parent) { m_parent = parent; } + WebHistoryItem* parent() const { return m_parent.get(); } private: - RefPtr<WebHistoryItem> mParent; - jobject mObject; - int mScale; - int mScreenWidthScale; - bool mActive; - WebCore::HistoryItem* mHistoryItem; + RefPtr<WebHistoryItem> m_parent; + jweak m_object; }; }; diff --git a/WebKit/android/jni/WebIconDatabase.cpp b/WebKit/android/jni/WebIconDatabase.cpp index daf0334..20258a4 100644 --- a/WebKit/android/jni/WebIconDatabase.cpp +++ b/WebKit/android/jni/WebIconDatabase.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -67,10 +67,6 @@ static WebIconDatabase* gIconDatabaseClient = new WebIconDatabase(); // XXX: Called by the IconDatabase thread void WebIconDatabase::dispatchDidAddIconForPageURL(const WebCore::String& pageURL) { - // If there are no clients currently, drop this message. - if (mClients.size() == 0) - return; - mNotificationsMutex.lock(); mNotifications.append(pageURL); if (!mDeliveryRequested) { @@ -83,23 +79,25 @@ void WebIconDatabase::dispatchDidAddIconForPageURL(const WebCore::String& pageUR // Called in the WebCore thread void WebIconDatabase::RegisterForIconNotification(WebIconDatabaseClient* client) { - gIconDatabaseClient->mClientsMutex.lock(); + WebIconDatabase* db = gIconDatabaseClient; + for (unsigned i = 0; i < db->mClients.size(); ++i) { + // Do not add the same client twice. + if (db->mClients[i] == client) + return; + } gIconDatabaseClient->mClients.append(client); - gIconDatabaseClient->mClientsMutex.unlock(); } // Called in the WebCore thread void WebIconDatabase::UnregisterForIconNotification(WebIconDatabaseClient* client) { WebIconDatabase* db = gIconDatabaseClient; - db->mClientsMutex.lock(); for (unsigned i = 0; i < db->mClients.size(); ++i) { if (db->mClients[i] == client) { db->mClients.remove(i); break; } } - db->mClientsMutex.unlock(); } // Called in the WebCore thread @@ -123,9 +121,7 @@ void WebIconDatabase::deliverNotifications() // Swap the clients queue Vector<WebIconDatabaseClient*> clients; - mClientsMutex.lock(); clients.swap(mClients); - mClientsMutex.unlock(); for (unsigned i = 0; i < queue.size(); ++i) { for (unsigned j = 0; j < clients.size(); ++j) { diff --git a/WebKit/android/jni/WebIconDatabase.h b/WebKit/android/jni/WebIconDatabase.h index c88842c..c91c4ae 100644 --- a/WebKit/android/jni/WebIconDatabase.h +++ b/WebKit/android/jni/WebIconDatabase.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -59,9 +59,8 @@ namespace android { // Deliver all the icon notifications void deliverNotifications(); - // List of clients and a mutex to protect it. + // List of clients. Vector<WebIconDatabaseClient*> mClients; - android::Mutex mClientsMutex; // Queue of page urls that have received an icon. Vector<WebCore::String> mNotifications; diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp index 4240dd5..00fec85 100644 --- a/WebKit/android/jni/WebSettings.cpp +++ b/WebKit/android/jni/WebSettings.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -38,6 +38,7 @@ #include "Geolocation.h" #include "GeolocationPermissions.h" #include "Page.h" +#include "PageCache.h" #include "RenderTable.h" #include "Settings.h" #include "WebCoreFrameBridge.h" @@ -110,6 +111,7 @@ struct FieldIds { mSupportMultipleWindows = env->GetFieldID(clazz, "mSupportMultipleWindows", "Z"); mShrinksStandaloneImagesToFit = env->GetFieldID(clazz, "mShrinksStandaloneImagesToFit", "Z"); mUseDoubleTree = env->GetFieldID(clazz, "mUseDoubleTree", "Z"); + mPageCacheCapacity = env->GetFieldID(clazz, "mPageCacheCapacity", "I"); LOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm"); LOG_ASSERT(mTextSize, "Could not find field mTextSize"); @@ -145,6 +147,7 @@ struct FieldIds { LOG_ASSERT(mSupportMultipleWindows, "Could not find field mSupportMultipleWindows"); LOG_ASSERT(mShrinksStandaloneImagesToFit, "Could not find field mShrinksStandaloneImagesToFit"); LOG_ASSERT(mUseDoubleTree, "Could not find field mUseDoubleTree"); + LOG_ASSERT(mPageCacheCapacity, "Could not find field mPageCacheCapacity"); jclass c = env->FindClass("java/lang/Enum"); LOG_ASSERT(c, "Could not find Enum class!"); @@ -189,6 +192,7 @@ struct FieldIds { jfieldID mSupportMultipleWindows; jfieldID mShrinksStandaloneImagesToFit; jfieldID mUseDoubleTree; + jfieldID mPageCacheCapacity; // Ordinal() method and value field for enums jmethodID mOrdinal; jfieldID mTextSizeValue; @@ -342,7 +346,8 @@ public: flag = env->GetBooleanField(obj, gFieldIds->mDatabaseEnabled); s->setDatabasesEnabled(flag); str = (jstring)env->GetObjectField(obj, gFieldIds->mDatabasePath); - WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(to_string(env, str)); + if (str && WebCore::DatabaseTracker::tracker().databaseDirectoryPath().isNull()) + WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(to_string(env, str)); #endif #if ENABLE(DOM_STORAGE) flag = env->GetBooleanField(obj, gFieldIds->mDomStorageEnabled); @@ -363,6 +368,13 @@ public: GeolocationPermissions::setDatabasePath(to_string(env,str)); WebCore::Geolocation::setDatabasePath(to_string(env,str)); } + + size = env->GetIntField(obj, gFieldIds->mPageCacheCapacity); + if (size > 0) { + s->setUsesPageCache(true); + WebCore::pageCache()->setCapacity(size); + } else + s->setUsesPageCache(false); } }; diff --git a/WebKit/android/jni/WebStorage.cpp b/WebKit/android/jni/WebStorage.cpp index aa83892..07e4880 100644 --- a/WebKit/android/jni/WebStorage.cpp +++ b/WebKit/android/jni/WebStorage.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -93,9 +93,9 @@ static unsigned long long GetUsageForOrigin(JNIEnv* env, jobject obj, jstring or if (manifestOrigin.get() == 0) continue; if (manifestOrigin->isSameSchemeHostPort(securityOrigin.get())) { - int64_t size = 0; - WebCore::cacheStorage().cacheGroupSize(manifestUrls[i].string(), &size); - usage += size; + int64_t cacheSize = 0; + WebCore::cacheStorage().cacheGroupSize(manifestUrls[i].string(), &cacheSize); + usage += cacheSize; } } return usage; @@ -163,4 +163,3 @@ int register_webstorage(JNIEnv* env) } #endif //ENABLE(DATABASE) - diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 0eca9bc..8414068 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -57,6 +57,7 @@ #include "HTMLElement.h" #include "HTMLImageElement.h" #include "HTMLInputElement.h" +#include "HTMLLabelElement.h" #include "HTMLMapElement.h" #include "HTMLNames.h" #include "HTMLOptGroupElement.h" @@ -68,6 +69,7 @@ #include "KeyboardCodes.h" #include "Navigator.h" #include "Node.h" +#include "NodeList.h" #include "Page.h" #include "PageGroup.h" #include "PlatformKeyboardEvent.h" @@ -88,6 +90,7 @@ #include "Settings.h" #include "SkANP.h" #include "SkTemplates.h" +#include "SkTDArray.h" #include "SkTypes.h" #include "SkCanvas.h" #include "SkPicture.h" @@ -129,6 +132,11 @@ FILE* gRenderTreeFile = 0; #include "TimeCounter.h" #endif +#if USE(ACCELERATED_COMPOSITING) +#include "GraphicsLayerAndroid.h" +#include "RenderLayerCompositor.h" +#endif + /* We pass this flag when recording the actual content, so that we don't spend time actually regionizing complex path clips, when all we really want to do is record them. @@ -141,6 +149,24 @@ namespace android { bool WebViewCore::s_isPaused = false; +static SkTDArray<WebViewCore*> gInstanceList; + +void WebViewCore::addInstance(WebViewCore* inst) { + *gInstanceList.append() = inst; +} + +void WebViewCore::removeInstance(WebViewCore* inst) { + int index = gInstanceList.find(inst); + LOG_ASSERT(index >= 0, "RemoveInstance inst not found"); + if (index >= 0) { + gInstanceList.removeShuffle(index); + } +} + +bool WebViewCore::isInstance(WebViewCore* inst) { + return gInstanceList.find(inst) >= 0; +} + // ---------------------------------------------------------------------------- #define GET_NATIVE_VIEW(env, obj) ((WebViewCore*)env->GetIntField(obj, gWebViewCoreFields.m_nativeClass)) @@ -161,12 +187,13 @@ struct WebViewCoreFields { // ---------------------------------------------------------------------------- struct WebViewCore::JavaGlue { - jobject m_obj; + jweak m_obj; jmethodID m_spawnScrollTo; jmethodID m_scrollTo; jmethodID m_scrollBy; jmethodID m_contentDraw; jmethodID m_requestListBox; + jmethodID m_openFileChooser; jmethodID m_requestSingleListBox; jmethodID m_jsAlert; jmethodID m_jsConfirm; @@ -177,6 +204,8 @@ struct WebViewCore::JavaGlue { jmethodID m_updateViewport; jmethodID m_sendNotifyProgressFinished; jmethodID m_sendViewInvalidate; + jmethodID m_sendImmediateRepaint; + jmethodID m_setRootLayer; jmethodID m_updateTextfield; jmethodID m_updateTextSelection; jmethodID m_clearTextEntry; @@ -190,10 +219,15 @@ struct WebViewCore::JavaGlue { jmethodID m_geolocationPermissionsShowPrompt; jmethodID m_geolocationPermissionsHidePrompt; jmethodID m_addMessageToConsole; - jmethodID m_startFullScreenPluginActivity; - jmethodID m_createSurface; + jmethodID m_getPluginClass; + jmethodID m_showFullScreenPlugin; + jmethodID m_hideFullScreenPlugin; + jmethodID m_updateFullScreenPlugin; + jmethodID m_addSurface; + jmethodID m_updateSurface; jmethodID m_destroySurface; - jmethodID m_showRect; + jmethodID m_getContext; + jmethodID m_sendFindAgain; AutoJObject object(JNIEnv* env) { return getRealObject(env, m_obj); } @@ -222,7 +256,6 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_popupReply = 0; m_moveGeneration = 0; - m_generation = 0; m_lastGeneration = 0; m_touchGeneration = 0; m_blockTextfieldUpdates = false; @@ -238,13 +271,14 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m jclass clazz = env->GetObjectClass(javaWebViewCore); m_javaGlue = new JavaGlue; - m_javaGlue->m_obj = adoptGlobalRef(env, javaWebViewCore); + m_javaGlue->m_obj = env->NewWeakGlobalRef(javaWebViewCore); m_javaGlue->m_spawnScrollTo = GetJMethod(env, clazz, "contentSpawnScrollTo", "(II)V"); m_javaGlue->m_scrollTo = GetJMethod(env, clazz, "contentScrollTo", "(II)V"); m_javaGlue->m_scrollBy = GetJMethod(env, clazz, "contentScrollBy", "(IIZ)V"); m_javaGlue->m_contentDraw = GetJMethod(env, clazz, "contentDraw", "()V"); - m_javaGlue->m_requestListBox = GetJMethod(env, clazz, "requestListBox", "([Ljava/lang/String;[Z[I)V"); - m_javaGlue->m_requestSingleListBox = GetJMethod(env, clazz, "requestListBox", "([Ljava/lang/String;[ZI)V"); + m_javaGlue->m_requestListBox = GetJMethod(env, clazz, "requestListBox", "([Ljava/lang/String;[I[I)V"); + m_javaGlue->m_openFileChooser = GetJMethod(env, clazz, "openFileChooser", "()Ljava/lang/String;"); + m_javaGlue->m_requestSingleListBox = GetJMethod(env, clazz, "requestListBox", "([Ljava/lang/String;[II)V"); m_javaGlue->m_jsAlert = GetJMethod(env, clazz, "jsAlert", "(Ljava/lang/String;Ljava/lang/String;)V"); m_javaGlue->m_jsConfirm = GetJMethod(env, clazz, "jsConfirm", "(Ljava/lang/String;Ljava/lang/String;)Z"); m_javaGlue->m_jsPrompt = GetJMethod(env, clazz, "jsPrompt", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); @@ -254,23 +288,30 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_updateViewport = GetJMethod(env, clazz, "updateViewport", "()V"); m_javaGlue->m_sendNotifyProgressFinished = GetJMethod(env, clazz, "sendNotifyProgressFinished", "()V"); m_javaGlue->m_sendViewInvalidate = GetJMethod(env, clazz, "sendViewInvalidate", "(IIII)V"); + m_javaGlue->m_sendImmediateRepaint = GetJMethod(env, clazz, "sendImmediateRepaint", "()V"); + m_javaGlue->m_setRootLayer = GetJMethod(env, clazz, "setRootLayer", "(I)V"); m_javaGlue->m_updateTextfield = GetJMethod(env, clazz, "updateTextfield", "(IZLjava/lang/String;I)V"); m_javaGlue->m_updateTextSelection = GetJMethod(env, clazz, "updateTextSelection", "(IIII)V"); m_javaGlue->m_clearTextEntry = GetJMethod(env, clazz, "clearTextEntry", "()V"); m_javaGlue->m_restoreScale = GetJMethod(env, clazz, "restoreScale", "(I)V"); m_javaGlue->m_restoreScreenWidthScale = GetJMethod(env, clazz, "restoreScreenWidthScale", "(I)V"); m_javaGlue->m_needTouchEvents = GetJMethod(env, clazz, "needTouchEvents", "(Z)V"); - m_javaGlue->m_requestKeyboard = GetJMethod(env, clazz, "requestKeyboard", "(Z)V"); + m_javaGlue->m_requestKeyboard = GetJMethod(env, clazz, "requestKeyboard", "(ZZ)V"); m_javaGlue->m_exceededDatabaseQuota = GetJMethod(env, clazz, "exceededDatabaseQuota", "(Ljava/lang/String;Ljava/lang/String;JJ)V"); m_javaGlue->m_reachedMaxAppCacheSize = GetJMethod(env, clazz, "reachedMaxAppCacheSize", "(J)V"); m_javaGlue->m_populateVisitedLinks = GetJMethod(env, clazz, "populateVisitedLinks", "()V"); m_javaGlue->m_geolocationPermissionsShowPrompt = GetJMethod(env, clazz, "geolocationPermissionsShowPrompt", "(Ljava/lang/String;)V"); m_javaGlue->m_geolocationPermissionsHidePrompt = GetJMethod(env, clazz, "geolocationPermissionsHidePrompt", "()V"); m_javaGlue->m_addMessageToConsole = GetJMethod(env, clazz, "addMessageToConsole", "(Ljava/lang/String;ILjava/lang/String;)V"); - m_javaGlue->m_startFullScreenPluginActivity = GetJMethod(env, clazz, "startFullScreenPluginActivity", "(Ljava/lang/String;Ljava/lang/String;I)V"); - m_javaGlue->m_createSurface = GetJMethod(env, clazz, "createSurface", "(Ljava/lang/String;Ljava/lang/String;IIIII)Landroid/webkit/ViewManager$ChildView;"); + m_javaGlue->m_getPluginClass = GetJMethod(env, clazz, "getPluginClass", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Class;"); + m_javaGlue->m_showFullScreenPlugin = GetJMethod(env, clazz, "showFullScreenPlugin", "(Landroid/webkit/ViewManager$ChildView;IIIII)V"); + m_javaGlue->m_hideFullScreenPlugin = GetJMethod(env, clazz, "hideFullScreenPlugin", "()V"); + m_javaGlue->m_updateFullScreenPlugin = GetJMethod(env, clazz, "updateFullScreenPlugin", "(IIII)V"); + m_javaGlue->m_addSurface = GetJMethod(env, clazz, "addSurface", "(Landroid/view/View;IIII)Landroid/webkit/ViewManager$ChildView;"); + m_javaGlue->m_updateSurface = GetJMethod(env, clazz, "updateSurface", "(Landroid/webkit/ViewManager$ChildView;IIII)V"); m_javaGlue->m_destroySurface = GetJMethod(env, clazz, "destroySurface", "(Landroid/webkit/ViewManager$ChildView;)V"); - m_javaGlue->m_showRect = GetJMethod(env, clazz, "showRect", "(IIIIIIFFFF)V"); + m_javaGlue->m_getContext = GetJMethod(env, clazz, "getContext", "()Landroid/content/Context;"); + m_javaGlue->m_sendFindAgain = GetJMethod(env, clazz, "sendFindAgain", "()V"); env->SetIntField(javaWebViewCore, gWebViewCoreFields.m_nativeClass, (jint)this); @@ -279,16 +320,20 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m PageGroup::setShouldTrackVisitedLinks(true); reset(true); + + WebViewCore::addInstance(this); } WebViewCore::~WebViewCore() { + WebViewCore::removeInstance(this); + // Release the focused view Release(m_popupReply); if (m_javaGlue->m_obj) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->DeleteGlobalRef(m_javaGlue->m_obj); + env->DeleteWeakGlobalRef(m_javaGlue->m_obj); m_javaGlue->m_obj = 0; } delete m_javaGlue; @@ -326,9 +371,9 @@ void WebViewCore::reset(bool fromConstructor) m_lastFocused = 0; m_lastFocusedBounds = WebCore::IntRect(0,0,0,0); + m_focusBoundsChanged = false; m_lastFocusedSelStart = 0; m_lastFocusedSelEnd = 0; - m_lastMoveGeneration = 0; clearContent(); m_updatedFrameCache = true; m_frameCacheOutOfDate = true; @@ -573,6 +618,8 @@ void WebViewCore::recordPictureSet(PictureSet* content) { return; } + m_focusBoundsChanged |= m_lastFocused == oldFocusNode + && m_lastFocusedBounds != oldBounds; m_lastFocused = oldFocusNode; m_lastFocusedBounds = oldBounds; m_lastFocusedSelStart = oldSelStart; @@ -580,6 +627,14 @@ void WebViewCore::recordPictureSet(PictureSet* content) m_domtree_version = latestVersion; DBG_NAV_LOG("call updateFrameCache"); updateFrameCache(); + if (m_findIsUp) { + LOG_ASSERT(m_javaGlue->m_obj, + "A Java widget was not associated with this view bridge!"); + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_sendFindAgain); + checkException(env); + } } void WebViewCore::updateButtonList(WTF::Vector<Container>* buttons) @@ -666,6 +721,13 @@ bool WebViewCore::drawContent(SkCanvas* canvas, SkColor color) return tookTooLong; } +bool WebViewCore::focusBoundsChanged() +{ + bool result = m_focusBoundsChanged; + m_focusBoundsChanged = false; + return result; +} + bool WebViewCore::pictureReady() { bool done; @@ -776,12 +838,9 @@ void WebViewCore::scrollTo(int x, int y, bool animate) // LOGD("WebViewCore::scrollTo(%d %d)\n", x, y); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), animate ? m_javaGlue->m_spawnScrollTo : m_javaGlue->m_scrollTo, x, y); + env->CallVoidMethod(m_javaGlue->object(env).get(), + animate ? m_javaGlue->m_spawnScrollTo : m_javaGlue->m_scrollTo, + x, y); checkException(env); } @@ -789,12 +848,7 @@ void WebViewCore::sendNotifyProgressFinished() { LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue->m_sendNotifyProgressFinished); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_sendNotifyProgressFinished); checkException(env); } @@ -802,12 +856,7 @@ void WebViewCore::viewInvalidate(const WebCore::IntRect& rect) { LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_sendViewInvalidate, rect.x(), rect.y(), rect.right(), rect.bottom()); checkException(env); @@ -818,25 +867,37 @@ void WebViewCore::scrollBy(int dx, int dy, bool animate) if (!(dx | dy)) return; JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue->m_scrollBy, + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_scrollBy, dx, dy, animate); checkException(env); } +#if USE(ACCELERATED_COMPOSITING) + +void WebViewCore::immediateRepaint() +{ + LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_sendImmediateRepaint); + checkException(env); +} + +void WebViewCore::setRootLayer(int layer) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_setRootLayer, + layer); + checkException(env); +} + +#endif // USE(ACCELERATED_COMPOSITING) + void WebViewCore::contentDraw() { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue->m_contentDraw); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_contentDraw); checkException(env); } @@ -885,18 +946,14 @@ void WebViewCore::didFirstLayout() WebCore::FrameLoadType loadType = loader->loadType(); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue->m_didFirstLayout, + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_didFirstLayout, loadType == WebCore::FrameLoadTypeStandard // When redirect with locked history, we would like to reset the // scale factor. This is important for www.yahoo.com as it is // redirected to www.yahoo.com/?rs=1 on load. || loadType == WebCore::FrameLoadTypeRedirectWithLockedBackForwardList); checkException(env); + DBG_NAV_LOG("call updateFrameCache"); m_check_domtree_version = false; updateFrameCache(); @@ -909,12 +966,7 @@ void WebViewCore::updateViewport() LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue->m_updateViewport); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_updateViewport); checkException(env); } @@ -924,12 +976,7 @@ void WebViewCore::restoreScale(int scale) LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue->m_restoreScale, scale); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_restoreScale, scale); checkException(env); } @@ -939,12 +986,8 @@ void WebViewCore::restoreScreenWidthScale(int scale) LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue->m_restoreScreenWidthScale, scale); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_restoreScreenWidthScale, scale); checkException(env); } @@ -955,28 +998,19 @@ void WebViewCore::needTouchEvents(bool need) #if ENABLE(TOUCH_EVENTS) // Android JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue->m_needTouchEvents, need); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_needTouchEvents, need); checkException(env); #endif } -void WebViewCore::requestKeyboard(bool showKeyboard) +void WebViewCore::requestKeyboard(bool showKeyboard, bool isTextView) { - DEBUG_NAV_UI_LOGD("%s", __FUNCTION__); + DBG_NAV_LOGD("showKeyboard=%d", showKeyboard); LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue->m_requestKeyboard, showKeyboard); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_requestKeyboard, showKeyboard, + isTextView); checkException(env); } @@ -1047,15 +1081,13 @@ void WebViewCore::setGlobalBounds(int x, int y, int h, int v) void WebViewCore::setSizeScreenWidthAndScale(int width, int height, int screenWidth, float scale, int realScreenWidth, int screenHeight, - int anchorX, int anchorY, bool ignoreHeight) + bool ignoreHeight) { WebCoreViewBridge* window = m_mainFrame->view()->platformWidget(); int ow = window->width(); int oh = window->height(); window->setSize(width, height); int osw = m_screenWidth; - int orsw = m_screenWidth * m_screenWidthScale / m_scale; - int osh = m_screenHeight; DBG_NAV_LOGD("old:(w=%d,h=%d,sw=%d,scale=%g) new:(w=%d,h=%d,sw=%d,scale=%g)", ow, oh, osw, m_scale, width, height, screenWidth, scale); m_screenWidth = screenWidth; @@ -1074,63 +1106,46 @@ void WebViewCore::setSizeScreenWidthAndScale(int width, int height, DBG_NAV_LOGD("renderer=%p view=(w=%d,h=%d)", r, realScreenWidth, screenHeight); if (r) { - WebCore::IntPoint anchorPoint; - if ((anchorX | anchorY) == 0) - // get current screen center position - anchorPoint = WebCore::IntPoint(m_scrollOffsetX - + (realScreenWidth >> 1), m_scrollOffsetY - + (screenHeight >> 1)); - else - anchorPoint = WebCore::IntPoint(anchorX, anchorY); - WebCore::HitTestResult hitTestResult = m_mainFrame->eventHandler()-> - hitTestResultAtPoint(anchorPoint, false); - WebCore::Node* node = hitTestResult.innerNode(); + // get current screen center position + WebCore::IntPoint screenCenter = WebCore::IntPoint( + m_scrollOffsetX + (realScreenWidth >> 1), + m_scrollOffsetY + (screenHeight >> 1)); + WebCore::Node* node = 0; WebCore::IntRect bounds; WebCore::IntPoint offset; + // If the screen width changed, it is probably zoom change or + // orientation change. Try to keep the node in the center of the + // screen staying at the same place. + if (osw != screenWidth) { + WebCore::HitTestResult hitTestResult = + m_mainFrame->eventHandler()-> hitTestResultAtPoint( + screenCenter, false); + node = hitTestResult.innerNode(); + } if (node) { bounds = node->getRect(); DBG_NAV_LOGD("ob:(x=%d,y=%d,w=%d,h=%d)", bounds.x(), bounds.y(), bounds.width(), bounds.height()); - if ((anchorX | anchorY) == 0) { - offset = WebCore::IntPoint(anchorPoint.x() - bounds.x(), - anchorPoint.y() - bounds.y()); - if (offset.x() < 0 || offset.x() > realScreenWidth || - offset.y() < 0 || offset.y() > screenHeight) - { - DBG_NAV_LOGD("offset out of bounds:(x=%d,y=%d)", - offset.x(), offset.y()); - node = 0; - } + offset = WebCore::IntPoint(screenCenter.x() - bounds.x(), + screenCenter.y() - bounds.y()); + if (offset.x() < 0 || offset.x() > realScreenWidth || + offset.y() < 0 || offset.y() > screenHeight) + { + DBG_NAV_LOGD("offset out of bounds:(x=%d,y=%d)", + offset.x(), offset.y()); + node = 0; } } r->setNeedsLayoutAndPrefWidthsRecalc(); m_mainFrame->view()->forceLayout(); // scroll to restore current screen center - if (!node) - return; - const WebCore::IntRect& newBounds = node->getRect(); - DBG_NAV_LOGD("nb:(x=%d,y=%d,w=%d," - "h=%d,ns=%d)", newBounds.x(), newBounds.y(), - newBounds.width(), newBounds.height()); - if ((anchorX | anchorY) == 0) - scrollBy(newBounds.x() - bounds.x(), - newBounds.y() - bounds.y(), false); - else if ((orsw && osh && bounds.width() && bounds.height()) - && (bounds != newBounds)) { - WebCore::FrameView* view = m_mainFrame->view(); - // force left align if width is not changed while height changed. - // the anchorPoint is probably at some white space in the node - // which is affected by text wrap around the screen width. - bool leftAlign = (osw != m_screenWidth) - && (bounds.width() == newBounds.width()) - && (bounds.height() != newBounds.height()); - showRect(newBounds.x(), newBounds.y(), newBounds.width(), - newBounds.height(), view->contentsWidth(), - view->contentsHeight(), - leftAlign ? 0.0 : (float) (anchorX - bounds.x()) / bounds.width(), - leftAlign ? 0.0 : (float) (anchorX - m_scrollOffsetX) / orsw, - (float) (anchorY - bounds.y()) / bounds.height(), - (float) (anchorY - m_scrollOffsetY) / osh); + if (node) { + const WebCore::IntRect& newBounds = node->getRect(); + DBG_NAV_LOGD("nb:(x=%d,y=%d,w=%d," + "h=%d,ns=%d)", newBounds.x(), newBounds.y(), + newBounds.width(), newBounds.height()); + scrollBy(newBounds.x() - bounds.x(), newBounds.y() - bounds.y(), + false); } } } @@ -1155,26 +1170,24 @@ void WebViewCore::dumpDomTree(bool useFile) void WebViewCore::dumpRenderTree(bool useFile) { #ifdef ANDROID_DOM_LOGGING - if (useFile) - gRenderTreeFile = fopen(RENDER_TREE_LOG_FILE, "w"); - WebCore::CString renderDump = WebCore::externalRepresentation(m_mainFrame->contentRenderer()).utf8(); + WebCore::CString renderDump = WebCore::externalRepresentation(m_mainFrame).utf8(); const char* data = renderDump.data(); - int length = renderDump.length(); - int last = 0; - for (int i = 0; i < length; i++) { - if (data[i] == '\n') { - if (i != last) { - char* chunk = new char[i - last + 1]; - strncpy(chunk, (data + last), i - last); - chunk[i - last] = '\0'; - DUMP_RENDER_LOGD("%s", chunk); - } - last = i + 1; - } - } - if (gRenderTreeFile) { + if (useFile) { + gRenderTreeFile = fopen(RENDER_TREE_LOG_FILE, "w"); + DUMP_RENDER_LOGD("%s", data); fclose(gRenderTreeFile); gRenderTreeFile = 0; + } else { + // adb log can only output 1024 characters, so write out line by line. + // exclude '\n' as adb log adds it for each output. + int length = renderDump.length(); + for (int i = 0, last = 0; i < length; i++) { + if (data[i] == '\n') { + if (i != last) + DUMP_RENDER_LOGD("%.*s", (i - last), &(data[last])); + last = i + 1; + } + } } #endif } @@ -1186,14 +1199,41 @@ void WebViewCore::dumpNavTree() #endif } -WebCore::String WebViewCore::retrieveHref(WebCore::Frame* frame, WebCore::Node* node) +WebCore::HTMLAnchorElement* WebViewCore::retrieveAnchorElement(WebCore::Frame* frame, WebCore::Node* node) { if (!CacheBuilder::validNode(m_mainFrame, frame, node)) - return WebCore::String(); + return 0; if (!node->hasTagName(WebCore::HTMLNames::aTag)) - return WebCore::String(); - WebCore::HTMLAnchorElement* anchor = static_cast<WebCore::HTMLAnchorElement*>(node); - return anchor->href(); + return 0; + return static_cast<WebCore::HTMLAnchorElement*>(node); +} + +WebCore::String WebViewCore::retrieveHref(WebCore::Frame* frame, WebCore::Node* node) +{ + WebCore::HTMLAnchorElement* anchor = retrieveAnchorElement(frame, node); + return anchor ? anchor->href() : WebCore::String(); +} + +WebCore::String WebViewCore::retrieveAnchorText(WebCore::Frame* frame, WebCore::Node* node) +{ + WebCore::HTMLAnchorElement* anchor = retrieveAnchorElement(frame, node); + return anchor ? anchor->text() : WebCore::String(); +} + +WebCore::String WebViewCore::requestLabel(WebCore::Frame* frame, + WebCore::Node* node) +{ + if (CacheBuilder::validNode(m_mainFrame, frame, node)) { + RefPtr<WebCore::NodeList> list = node->document()->getElementsByTagName("label"); + unsigned length = list->length(); + for (unsigned i = 0; i < length; i++) { + WebCore::HTMLLabelElement* label = static_cast<WebCore::HTMLLabelElement*>( + list->item(i)); + if (label->correspondingControl() == node) + return label->innerHTML(); + } + } + return WebCore::String(); } void WebViewCore::updateCacheOnNodeChange() @@ -1226,6 +1266,12 @@ void WebViewCore::updateCacheOnNodeChange() void WebViewCore::updateFrameCache() { +#if USE(ACCELERATED_COMPOSITING) + ChromeClientAndroid* chromeC = static_cast<ChromeClientAndroid*>( + mainFrame()->page()->chrome()->client()); + chromeC->scheduleCompositingLayerSync(); +#endif + if (!m_frameCacheOutOfDate) { DBG_NAV_LOG("!m_frameCacheOutOfDate"); return; @@ -1300,6 +1346,11 @@ void WebViewCore::removePlugin(PluginWidgetAndroid* w) } } +bool WebViewCore::isPlugin(PluginWidgetAndroid* w) const +{ + return m_plugins.find(w) >= 0; +} + void WebViewCore::invalPlugin(PluginWidgetAndroid* w) { const double PLUGIN_INVAL_DELAY = 1.0 / 60; @@ -1398,6 +1449,18 @@ void WebViewCore::sendPluginEvent(const ANPEvent& evt) } } +PluginWidgetAndroid* WebViewCore::getPluginWidget(NPP npp) +{ + PluginWidgetAndroid** iter = m_plugins.begin(); + PluginWidgetAndroid** stop = m_plugins.end(); + for (; iter < stop; ++iter) { + if ((*iter)->pluginView()->instance() == npp) { + return (*iter); + } + } + return NULL; +} + static PluginView* nodeIsPlugin(Node* node) { RenderObject* renderer = node->renderer(); if (renderer && renderer->isWidget()) { @@ -1421,33 +1484,6 @@ Node* WebViewCore::cursorNodeIsPlugin() { return 0; } - -void WebViewCore::updatePluginState(Frame* frame, Node* node, PluginState state) { - - // check that the node and frame pointers are (still) valid - if (!frame || !node || !CacheBuilder::validNode(m_mainFrame, frame, node)) - return; - - // check that the node is a plugin view - PluginView* pluginView = nodeIsPlugin(node); - if (!pluginView) - return; - - // create the event - ANPEvent event; - SkANP::InitEvent(&event, kLifecycle_ANPEventType); - - if (state == kLoseFocus_PluginState) - event.data.lifecycle.action = kLoseFocus_ANPLifecycleAction; - else if (state == kGainFocus_PluginState) - event.data.lifecycle.action = kGainFocus_ANPLifecycleAction; - else - return; - - // send the event - pluginView->platformPluginWidget()->sendEvent(event); -} - /////////////////////////////////////////////////////////////////////////////// void WebViewCore::moveMouseIfLatest(int moveGeneration, WebCore::Frame* frame, int x, int y) @@ -1464,7 +1500,26 @@ void WebViewCore::moveMouseIfLatest(int moveGeneration, moveMouse(frame, x, y); } -// Update mouse position and may change focused node. +void WebViewCore::moveFocus(WebCore::Frame* frame, WebCore::Node* node) +{ + DBG_NAV_LOGD("frame=%p node=%p", frame, node); + if (!node || !CacheBuilder::validNode(m_mainFrame, frame, node) + || !node->isElementNode()) + return; + // Code borrowed from FocusController::advanceFocus + WebCore::FocusController* focusController + = m_mainFrame->page()->focusController(); + WebCore::Document* oldDoc + = focusController->focusedOrMainFrame()->document(); + if (oldDoc->focusedNode() == node) + return; + if (node->document() != oldDoc) + oldDoc->setFocusedNode(0); + focusController->setFocusedFrame(frame); + static_cast<WebCore::Element*>(node)->focus(false); +} + +// Update mouse position void WebViewCore::moveMouse(WebCore::Frame* frame, int x, int y) { DBG_NAV_LOGD("frame=%p x=%d y=%d scrollOffset=(%d,%d)", frame, @@ -1482,161 +1537,6 @@ void WebViewCore::moveMouse(WebCore::Frame* frame, int x, int y) updateCacheOnNodeChange(); } -static int findTextBoxIndex(WebCore::Node* node, const WebCore::IntPoint& pt) -{ - if (!node->isTextNode()) { - DBG_NAV_LOGD("node=%p pt=(%d,%d) isText=false", node, pt.x(), pt.y()); - return -2; // error - } - WebCore::RenderText* renderText = (WebCore::RenderText*) node->renderer(); - if (!renderText) { - DBG_NAV_LOGD("node=%p pt=(%d,%d) renderText=0", node, pt.x(), pt.y()); - return -3; // error - } - FloatPoint absPt = renderText->localToAbsolute(); - WebCore::InlineTextBox *textBox = renderText->firstTextBox(); - int globalX, globalY; - CacheBuilder::GetGlobalOffset(node, &globalX, &globalY); - int x = pt.x() - globalX; - int y = pt.y() - globalY; - do { - int textBoxStart = textBox->start(); - int textBoxEnd = textBoxStart + textBox->len(); - if (textBoxEnd <= textBoxStart) - continue; - WebCore::IntRect bounds = textBox->selectionRect(absPt.x(), absPt.y(), - textBoxStart, textBoxEnd); - if (!bounds.contains(x, y)) - continue; - int offset = textBox->offsetForPosition(x - absPt.x()); -#if DEBUG_NAV_UI - int prior = offset > 0 ? textBox->positionForOffset(offset - 1) : -1; - int current = textBox->positionForOffset(offset); - int next = textBox->positionForOffset(offset + 1); - DBG_NAV_LOGD( - "offset=%d pt.x=%d globalX=%d renderX=%d x=%d " - "textBox->x()=%d textBox->start()=%d prior=%d current=%d next=%d", - offset, pt.x(), globalX, absPt.x(), x, - textBox->x(), textBox->start(), prior, current, next - ); -#endif - return textBox->start() + offset; - } while ((textBox = textBox->nextTextBox())); - return -1; // couldn't find point, may have walked off end -} - -static inline bool isPunctuation(UChar c) -{ - return WTF::Unicode::category(c) & (0 - | WTF::Unicode::Punctuation_Dash - | WTF::Unicode::Punctuation_Open - | WTF::Unicode::Punctuation_Close - | WTF::Unicode::Punctuation_Connector - | WTF::Unicode::Punctuation_Other - | WTF::Unicode::Punctuation_InitialQuote - | WTF::Unicode::Punctuation_FinalQuote - ); -} - -static int centerX(const SkIRect& rect) -{ - return (rect.fLeft + rect.fRight) >> 1; -} - -static int centerY(const SkIRect& rect) -{ - return (rect.fTop + rect.fBottom) >> 1; -} - -WebCore::String WebViewCore::getSelection(SkRegion* selRgn) -{ - SkRegion::Iterator iter(*selRgn); - // FIXME: switch this to use StringBuilder instead - WebCore::String result; - WebCore::Node* lastStartNode = 0; - int lastStartEnd = -1; - UChar lastChar = 0xffff; - for (; !iter.done(); iter.next()) { - const SkIRect& rect = iter.rect(); - DBG_NAV_LOGD("rect=(%d, %d, %d, %d)", rect.fLeft, rect.fTop, - rect.fRight, rect.fBottom); - int cy = centerY(rect); - WebCore::IntPoint startPt = WebCore::IntPoint(rect.fLeft + 1, cy); - WebCore::HitTestResult hitTestResult = m_mainFrame->eventHandler()-> - hitTestResultAtPoint(startPt, false); - WebCore::Node* node = hitTestResult.innerNode(); - if (!node) { - DBG_NAV_LOG("!node"); - return result; - } - WebCore::IntPoint endPt = WebCore::IntPoint(rect.fRight - 1, cy); - hitTestResult = m_mainFrame->eventHandler()->hitTestResultAtPoint(endPt, false); - WebCore::Node* endNode = hitTestResult.innerNode(); - if (!endNode) { - DBG_NAV_LOG("!endNode (right-1)"); - endPt = WebCore::IntPoint(rect.fRight - 2, cy); - hitTestResult = m_mainFrame->eventHandler()->hitTestResultAtPoint(endPt, false); - endNode = hitTestResult.innerNode(); - } - if (!endNode) { - DBG_NAV_LOG("!endNode (right-2)"); - return result; - } - int start = findTextBoxIndex(node, startPt); - if (start < 0) - continue; - int end = findTextBoxIndex(endNode, endPt); - if (end < -1) // use node if endNode is not valid - endNode = node; - if (end <= 0) - end = static_cast<WebCore::Text*>(endNode)->string()->length(); - DBG_NAV_LOGD("node=%p start=%d endNode=%p end=%d", node, start, endNode, end); - WebCore::Node* startNode = node; - do { - if (!node->isTextNode()) - continue; - if (node->getRect().isEmpty()) - continue; - WebCore::Text* textNode = static_cast<WebCore::Text*>(node); - WebCore::StringImpl* string = textNode->string(); - if (!string->length()) - continue; - const UChar* chars = string->characters(); - int newLength = node == endNode ? end : string->length(); - if (node == startNode) { - #if DEBUG_NAV_UI - if (node == lastStartNode) - DBG_NAV_LOGD("start=%d last=%d", start, lastStartEnd); - #endif - if (node == lastStartNode && start < lastStartEnd) - break; // skip rect if text overlaps already written text - lastStartNode = node; - lastStartEnd = newLength - start; - } - if (newLength < start) { - DBG_NAV_LOGD("newLen=%d < start=%d", newLength, start); - break; - } - if (!isPunctuation(chars[start])) - result.append(' '); - result.append(chars + start, newLength - start); - start = 0; - } while (node != endNode && (node = node->traverseNextNode())); - } - result = result.simplifyWhiteSpace().stripWhiteSpace(); -#if DUMP_NAV_CACHE - { - char buffer[256]; - CacheBuilder::Debug debug; - debug.init(buffer, sizeof(buffer)); - debug.print("copy: "); - debug.wideString(result); - DUMP_NAV_LOGD("%s", buffer); - } -#endif - return result; -} - void WebViewCore::setSelection(int start, int end) { WebCore::Node* focus = currentFocus(); @@ -1670,7 +1570,16 @@ void WebViewCore::deleteSelection(int start, int end, int textGeneration) WebCore::Node* focus = currentFocus(); if (!focus) return; - WebCore::TypingCommand::deleteSelection(focus->document()); + // Prevent our editor client from passing a message to change the + // selection. + EditorClientAndroid* client = static_cast<EditorClientAndroid*>( + m_mainFrame->editor()->client()); + client->setUiGeneratedSelectionChange(true); + PlatformKeyboardEvent down(kKeyCodeDel, 0, 0, true, false, false, false); + PlatformKeyboardEvent up(kKeyCodeDel, 0, 0, false, false, false, false); + key(down); + key(up); + client->setUiGeneratedSelectionChange(false); m_textGeneration = textGeneration; } @@ -1765,7 +1674,7 @@ void WebViewCore::saveDocumentState(WebCore::Frame* frame) { if (!CacheBuilder::validNode(m_mainFrame, frame, 0)) frame = m_mainFrame; - WebCore::HistoryItem *item = frame->loader()->currentHistoryItem(); + WebCore::HistoryItem *item = frame->loader()->history()->currentItem(); // item can be null when there is no offical URL for the current page. This happens // when the content is loaded using with WebCoreFrameBridge::LoadData() and there @@ -1883,6 +1792,21 @@ static jobjectArray makeLabelArray(JNIEnv* env, const uint16_t** labels, size_t return array; } +void WebViewCore::openFileChooser(PassRefPtr<WebCore::FileChooser> chooser) { + if (!chooser) + return; + JNIEnv* env = JSC::Bindings::getJNIEnv(); + jstring jName = (jstring) env->CallObjectMethod( + m_javaGlue->object(env).get(), m_javaGlue->m_openFileChooser); + checkException(env); + const UChar* string = (const UChar*) env->GetStringChars(jName, NULL); + if (!string) + return; + WebCore::String webcoreString = to_string(env, jName); + env->ReleaseStringChars(jName, string); + chooser->chooseFile(webcoreString); +} + void WebViewCore::listBoxRequest(WebCoreReply* reply, const uint16_t** labels, size_t count, const int enabled[], size_t enabledCount, bool multiple, const int selected[], size_t selectedCountOrSelection) { @@ -1894,22 +1818,17 @@ void WebViewCore::listBoxRequest(WebCoreReply* reply, const uint16_t** labels, s // Create an array of java Strings for the drop down. JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; jobjectArray labelArray = makeLabelArray(env, labels, count); // Create an array determining whether each item is enabled. - jbooleanArray enabledArray = env->NewBooleanArray(enabledCount); + jintArray enabledArray = env->NewIntArray(enabledCount); checkException(env); - jboolean* ptrArray = env->GetBooleanArrayElements(enabledArray, 0); + jint* ptrArray = env->GetIntArrayElements(enabledArray, 0); checkException(env); for (size_t i = 0; i < enabledCount; i++) { ptrArray[i] = enabled[i]; } - env->ReleaseBooleanArrayElements(enabledArray, ptrArray, 0); + env->ReleaseIntArrayElements(enabledArray, ptrArray, 0); checkException(env); if (multiple) { @@ -1923,11 +1842,15 @@ void WebViewCore::listBoxRequest(WebCoreReply* reply, const uint16_t** labels, s } env->ReleaseIntArrayElements(selectedArray, selArray, 0); - env->CallVoidMethod(obj.get(), m_javaGlue->m_requestListBox, labelArray, enabledArray, selectedArray); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_requestListBox, labelArray, enabledArray, + selectedArray); env->DeleteLocalRef(selectedArray); } else { // Pass up the single selection. - env->CallVoidMethod(obj.get(), m_javaGlue->m_requestSingleListBox, labelArray, enabledArray, selectedCountOrSelection); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_requestSingleListBox, labelArray, enabledArray, + selectedCountOrSelection); } env->DeleteLocalRef(labelArray); @@ -1972,9 +1895,19 @@ void WebViewCore::click(WebCore::Frame* frame, WebCore::Node* node) { } } -bool WebViewCore::handleTouchEvent(int action, int x, int y) +int WebViewCore::handleTouchEvent(int action, int x, int y) { - bool preventDefault = false; + int preventDefault = 0; + +#if USE(ACCELERATED_COMPOSITING) + RenderView* contentRenderer = m_mainFrame->contentRenderer(); + GraphicsLayerAndroid* rootLayer = 0; + if (contentRenderer) + rootLayer = static_cast<GraphicsLayerAndroid*>( + contentRenderer->compositor()->rootPlatformLayer()); + if (rootLayer) + rootLayer->pauseDisplay(true); +#endif #if ENABLE(TOUCH_EVENTS) // Android WebCore::TouchEventType type = WebCore::TouchEventCancel; @@ -1991,12 +1924,22 @@ bool WebViewCore::handleTouchEvent(int action, int x, int y) case 3: // MotionEvent.ACTION_CANCEL type = WebCore::TouchEventCancel; break; + case 0x100: // WebViewCore.ACTION_LONGPRESS + type = WebCore::TouchEventLongPress; + break; + case 0x200: // WebViewCore.ACTION_DOUBLETAP + type = WebCore::TouchEventDoubleTap; + break; } WebCore::IntPoint pt(x - m_scrollOffsetX, y - m_scrollOffsetY); WebCore::PlatformTouchEvent te(pt, pt, type); preventDefault = m_mainFrame->eventHandler()->handleTouchEvent(te); #endif +#if USE(ACCELERATED_COMPOSITING) + if (rootLayer) + rootLayer->pauseDisplay(false); +#endif return preventDefault; } @@ -2008,35 +1951,16 @@ void WebViewCore::touchUp(int touchGeneration, " x=%d y=%d", m_touchGeneration, touchGeneration, x, y); return; // short circuit if a newer touch has been generated } + // This moves m_mousePos to the correct place, and handleMouseClick uses + // m_mousePos to determine where the click happens. moveMouse(frame, x, y); m_lastGeneration = touchGeneration; if (frame && CacheBuilder::validNode(m_mainFrame, frame, 0)) { frame->loader()->resetMultipleFormSubmissionProtection(); } - // If the click is on an unselected textfield/area we do not want to allow - // the click to change the selection, because we will set it ourselves - // elsewhere - beginning for textareas, end for textfields - bool needToIgnoreChangesToSelectedRange = true; - WebCore::Node* focusNode = currentFocus(); - if (focusNode) { - WebCore::RenderObject* renderer = focusNode->renderer(); - if (renderer && (renderer->isTextField() || renderer->isTextArea())) { - // Now check to see if the click is inside the focused textfield - if (focusNode->getRect().contains(x, y)) - needToIgnoreChangesToSelectedRange = false; - } - } - EditorClientAndroid* client = 0; - if (needToIgnoreChangesToSelectedRange) { - client = static_cast<EditorClientAndroid*>( - m_mainFrame->editor()->client()); - client->setShouldChangeSelectedRange(false); - } DBG_NAV_LOGD("touchGeneration=%d handleMouseClick frame=%p node=%p" " x=%d y=%d", touchGeneration, frame, node, x, y); handleMouseClick(frame, node); - if (needToIgnoreChangesToSelectedRange) - client->setShouldChangeSelectedRange(true); } // Common code for both clicking with the trackball and touchUp @@ -2060,6 +1984,13 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node WebCore::HTMLSelectElement* select = static_cast<WebCore::HTMLSelectElement*>(nodePtr); const WTF::Vector<WebCore::Element*>& listItems = select->listItems(); 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 = listItems.size(); @@ -2068,13 +1999,13 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node if (listItems[i]->hasTagName(WebCore::HTMLNames::optionTag)) { WebCore::HTMLOptionElement* option = static_cast<WebCore::HTMLOptionElement*>(listItems[i]); *names.append() = stringConverter(option->textIndentedToRespectGroupLabel()); - *enabledArray.append() = option->disabled() ? 0 : 1; + *enabledArray.append() = option->disabled() ? OPTION_DISABLED : OPTION_ENABLED; if (multiple && option->selected()) *selectedArray.append() = i; } else if (listItems[i]->hasTagName(WebCore::HTMLNames::optgroupTag)) { WebCore::HTMLOptGroupElement* optGroup = static_cast<WebCore::HTMLOptGroupElement*>(listItems[i]); *names.append() = stringConverter(optGroup->groupLabelText()); - *enabledArray.append() = 0; + *enabledArray.append() = OPTGROUP; } } WebCoreReply* reply = new ListBoxReply(select, select->document()->frame(), this); @@ -2109,8 +2040,12 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node m_mousePos.y(), focusNode, handled ? "true" : "false"); if (focusNode) { WebCore::RenderObject* renderer = focusNode->renderer(); - if (renderer && (renderer->isTextField() || renderer->isTextArea())) - setFocusControllerActive(true); + if (renderer && (renderer->isTextField() || renderer->isTextArea())) { + bool ime = !(static_cast<WebCore::HTMLInputElement*>(focusNode)) + ->readOnly(); + setFocusControllerActive(ime); + requestKeyboard(ime, true); + } } return handled; } @@ -2135,14 +2070,11 @@ void WebViewCore::popupReply(const int* array, int count) void WebViewCore::addMessageToConsole(const WebCore::String& message, unsigned int lineNumber, const WebCore::String& sourceID) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; jstring jMessageStr = env->NewString((unsigned short *)message.characters(), message.length()); jstring jSourceIDStr = env->NewString((unsigned short *)sourceID.characters(), sourceID.length()); - env->CallVoidMethod(obj.get(), m_javaGlue->m_addMessageToConsole, jMessageStr, lineNumber, jSourceIDStr); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_addMessageToConsole, jMessageStr, lineNumber, + jSourceIDStr); env->DeleteLocalRef(jMessageStr); env->DeleteLocalRef(jSourceIDStr); checkException(env); @@ -2151,14 +2083,9 @@ void WebViewCore::addMessageToConsole(const WebCore::String& message, unsigned i void WebViewCore::jsAlert(const WebCore::String& url, const WebCore::String& text) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; jstring jInputStr = env->NewString((unsigned short *)text.characters(), text.length()); jstring jUrlStr = env->NewString((unsigned short *)url.characters(), url.length()); - env->CallVoidMethod(obj.get(), m_javaGlue->m_jsAlert, jUrlStr, jInputStr); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_jsAlert, jUrlStr, jInputStr); env->DeleteLocalRef(jInputStr); env->DeleteLocalRef(jUrlStr); checkException(env); @@ -2168,14 +2095,11 @@ void WebViewCore::exceededDatabaseQuota(const WebCore::String& url, const WebCor { #if ENABLE(DATABASE) JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; jstring jDatabaseIdentifierStr = env->NewString((unsigned short *)databaseIdentifier.characters(), databaseIdentifier.length()); jstring jUrlStr = env->NewString((unsigned short *)url.characters(), url.length()); - env->CallVoidMethod(obj.get(), m_javaGlue->m_exceededDatabaseQuota, jUrlStr, jDatabaseIdentifierStr, currentQuota, estimatedSize); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_exceededDatabaseQuota, jUrlStr, + jDatabaseIdentifierStr, currentQuota, estimatedSize); env->DeleteLocalRef(jDatabaseIdentifierStr); env->DeleteLocalRef(jUrlStr); checkException(env); @@ -2186,12 +2110,8 @@ void WebViewCore::reachedMaxAppCacheSize(const unsigned long long spaceNeeded) { #if ENABLE(OFFLINE_WEB_APPLICATIONS) JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue->m_reachedMaxAppCacheSize, spaceNeeded); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_reachedMaxAppCacheSize, spaceNeeded); checkException(env); #endif } @@ -2200,25 +2120,15 @@ void WebViewCore::populateVisitedLinks(WebCore::PageGroup* group) { m_groupForVisitedLinks = group; JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue->m_populateVisitedLinks); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_populateVisitedLinks); checkException(env); } void WebViewCore::geolocationPermissionsShowPrompt(const WebCore::String& origin) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; jstring originString = env->NewString((unsigned short *)origin.characters(), origin.length()); - env->CallVoidMethod(obj.get(), + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_geolocationPermissionsShowPrompt, originString); env->DeleteLocalRef(originString); @@ -2228,12 +2138,7 @@ void WebViewCore::geolocationPermissionsShowPrompt(const WebCore::String& origin void WebViewCore::geolocationPermissionsHidePrompt() { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_geolocationPermissionsHidePrompt); checkException(env); } @@ -2241,14 +2146,9 @@ void WebViewCore::geolocationPermissionsHidePrompt() bool WebViewCore::jsConfirm(const WebCore::String& url, const WebCore::String& text) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return false; jstring jInputStr = env->NewString((unsigned short *)text.characters(), text.length()); jstring jUrlStr = env->NewString((unsigned short *)url.characters(), url.length()); - jboolean result = env->CallBooleanMethod(obj.get(), m_javaGlue->m_jsConfirm, jUrlStr, jInputStr); + jboolean result = env->CallBooleanMethod(m_javaGlue->object(env).get(), m_javaGlue->m_jsConfirm, jUrlStr, jInputStr); env->DeleteLocalRef(jInputStr); env->DeleteLocalRef(jUrlStr); checkException(env); @@ -2258,16 +2158,10 @@ bool WebViewCore::jsConfirm(const WebCore::String& url, const WebCore::String& t bool WebViewCore::jsPrompt(const WebCore::String& url, const WebCore::String& text, const WebCore::String& defaultValue, WebCore::String& result) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return false; - jstring jInputStr = env->NewString((unsigned short *)text.characters(), text.length()); jstring jDefaultStr = env->NewString((unsigned short *)defaultValue.characters(), defaultValue.length()); jstring jUrlStr = env->NewString((unsigned short *)url.characters(), url.length()); - jstring returnVal = (jstring) env->CallObjectMethod(obj.get(), m_javaGlue->m_jsPrompt, jUrlStr, jInputStr, jDefaultStr); + jstring returnVal = (jstring) env->CallObjectMethod(m_javaGlue->object(env).get(), m_javaGlue->m_jsPrompt, jUrlStr, jInputStr, jDefaultStr); // If returnVal is null, it means that the user cancelled the dialog. if (!returnVal) return false; @@ -2283,14 +2177,9 @@ bool WebViewCore::jsPrompt(const WebCore::String& url, const WebCore::String& te bool WebViewCore::jsUnload(const WebCore::String& url, const WebCore::String& message) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return false; jstring jInputStr = env->NewString((unsigned short *)message.characters(), message.length()); jstring jUrlStr = env->NewString((unsigned short *)url.characters(), url.length()); - jboolean result = env->CallBooleanMethod(obj.get(), m_javaGlue->m_jsUnload, jUrlStr, jInputStr); + jboolean result = env->CallBooleanMethod(m_javaGlue->object(env).get(), m_javaGlue->m_jsUnload, jUrlStr, jInputStr); env->DeleteLocalRef(jInputStr); env->DeleteLocalRef(jUrlStr); checkException(env); @@ -2300,12 +2189,7 @@ bool WebViewCore::jsUnload(const WebCore::String& url, const WebCore::String& me bool WebViewCore::jsInterrupt() { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return true; // default to interrupt - jboolean result = env->CallBooleanMethod(obj.get(), m_javaGlue->m_jsInterrupt); + jboolean result = env->CallBooleanMethod(m_javaGlue->object(env).get(), m_javaGlue->m_jsInterrupt); checkException(env); return result; } @@ -2320,12 +2204,7 @@ jobject WebViewCore::getWebViewJavaObject() { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return 0; - return env->GetObjectField(obj.get(), gWebViewCoreFields.m_webView); + return env->GetObjectField(m_javaGlue->object(env).get(), gWebViewCoreFields.m_webView); } void WebViewCore::updateTextSelection() { @@ -2337,12 +2216,7 @@ void WebViewCore::updateTextSelection() { return; RenderTextControl* rtc = static_cast<RenderTextControl*>(renderer); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_updateTextSelection, reinterpret_cast<int>(focusNode), rtc->selectionStart(), rtc->selectionEnd(), m_textGeneration); checkException(env); @@ -2354,21 +2228,15 @@ void WebViewCore::updateTextfield(WebCore::Node* ptr, bool changeToPassword, if (m_blockTextfieldUpdates) return; JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - if (changeToPassword) { - env->CallVoidMethod(obj.get(), m_javaGlue->m_updateTextfield, + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_updateTextfield, (int) ptr, true, 0, m_textGeneration); checkException(env); return; } int length = text.length(); jstring string = env->NewString((unsigned short *) text.characters(), length); - env->CallVoidMethod(obj.get(), m_javaGlue->m_updateTextfield, + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_updateTextfield, (int) ptr, false, string, m_textGeneration); env->DeleteLocalRef(string); checkException(env); @@ -2377,13 +2245,8 @@ void WebViewCore::updateTextfield(WebCore::Node* ptr, bool changeToPassword, void WebViewCore::clearTextEntry() { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - - env->CallVoidMethod(obj.get(), m_javaGlue->m_clearTextEntry); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_clearTextEntry); } void WebViewCore::setBackgroundColor(SkColor c) @@ -2398,73 +2261,106 @@ void WebViewCore::setBackgroundColor(SkColor c) view->setBaseBackgroundColor(bcolor); } -void WebViewCore::startFullScreenPluginActivity(const char* libName, - const char* className, NPP npp) +jclass WebViewCore::getPluginClass(const WebCore::String& libName, const char* className) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - jstring libString = env->NewStringUTF(libName); + jstring libString = env->NewString(libName.characters(), libName.length()); + jstring classString = env->NewStringUTF(className); + jobject pluginClass = env->CallObjectMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_getPluginClass, + libString, classString); + checkException(env); + + // cleanup unneeded local JNI references + env->DeleteLocalRef(libString); + env->DeleteLocalRef(classString); + + if (pluginClass != NULL) { + return static_cast<jclass>(pluginClass); + } else { + return NULL; + } +} + +void WebViewCore::showFullScreenPlugin(jobject childView, NPP npp, int x, + int y, int width, int height) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - jstring classString = env->NewStringUTF(className); env->CallVoidMethod(obj.get(), - m_javaGlue->m_startFullScreenPluginActivity, - libString, classString, (int) npp); + m_javaGlue->m_showFullScreenPlugin, + childView, (int)npp, x, y, width, height); checkException(env); } -jobject WebViewCore::createSurface(const char* libName, const char* className, - NPP npp, int x, int y, int width, int height) +void WebViewCore::hideFullScreenPlugin() { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return 0; + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_hideFullScreenPlugin); + checkException(env); +} - jstring libString = env->NewStringUTF(libName); - jstring classString = env->NewStringUTF(className); - jobject result = env->CallObjectMethod(obj.get(), - m_javaGlue->m_createSurface, libString, - classString,(int) npp, x, y, width, height); +void WebViewCore::updateFullScreenPlugin(int x, int y, int width, int height) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_updateFullScreenPlugin, x, y, + width, height); + checkException(env); +} + +jobject WebViewCore::addSurface(jobject view, int x, int y, int width, int height) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + jobject result = env->CallObjectMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_addSurface, + view, x, y, width, height); checkException(env); return result; +} +void WebViewCore::updateSurface(jobject childView, int x, int y, int width, int height) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_updateSurface, childView, + x, y, width, height); + checkException(env); } void WebViewCore::destroySurface(jobject childView) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - - env->CallVoidMethod(obj.get(), m_javaGlue->m_destroySurface, childView); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_destroySurface, childView); checkException(env); } -void WebViewCore::showRect(int left, int top, int width, int height, - int contentWidth, int contentHeight, float xPercentInDoc, - float xPercentInView, float yPercentInDoc, float yPercentInView) +jobject WebViewCore::getContext() { JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = m_javaGlue->object(env); - // if it is called during DESTROY is handled, the real object of WebViewCore - // can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue->m_showRect, left, top, width, - height, contentWidth, contentHeight, xPercentInDoc, xPercentInView, - yPercentInDoc, yPercentInView); + jobject result = env->CallObjectMethod(obj.get(), m_javaGlue->m_getContext); checkException(env); + return result; +} + +bool WebViewCore::validNodeAndBounds(Frame* frame, Node* node, + const IntRect& originalAbsoluteBounds) +{ + bool valid = CacheBuilder::validNode(m_mainFrame, frame, node); + if (!valid) + return false; + RenderObject* renderer = node->renderer(); + if (!renderer) + return false; + IntRect absBounds = node->hasTagName(HTMLNames::areaTag) + ? CacheBuilder::getAreaRect(static_cast<HTMLAreaElement*>(node)) + : renderer->absoluteBoundingBoxRect(); + return absBounds == originalAbsoluteBounds; } //---------------------------------------------------------------------- @@ -2480,6 +2376,13 @@ static jstring WebCoreStringToJString(JNIEnv *env, WebCore::String string) return ret; } +static jstring RequestLabel(JNIEnv *env, jobject obj, int framePointer, + int nodePointer) +{ + return WebCoreStringToJString(env, GET_NATIVE_VIEW(env, obj)->requestLabel( + (WebCore::Frame*) framePointer, (WebCore::Node*) nodePointer)); +} + static void UpdateFrameCacheIfLoading(JNIEnv *env, jobject obj) { GET_NATIVE_VIEW(env, obj)->updateFrameCacheIfLoading(); @@ -2487,7 +2390,7 @@ static void UpdateFrameCacheIfLoading(JNIEnv *env, jobject obj) static void SetSize(JNIEnv *env, jobject obj, jint width, jint height, jint screenWidth, jfloat scale, jint realScreenWidth, jint screenHeight, - jint anchorX, jint anchorY, jboolean ignoreHeight) + jboolean ignoreHeight) { #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); @@ -2496,7 +2399,7 @@ static void SetSize(JNIEnv *env, jobject obj, jint width, jint height, LOGV("webviewcore::nativeSetSize(%u %u)\n viewImpl: %p", (unsigned)width, (unsigned)height, viewImpl); LOG_ASSERT(viewImpl, "viewImpl not set in nativeSetSize"); viewImpl->setSizeScreenWidthAndScale(width, height, screenWidth, scale, - realScreenWidth, screenHeight, anchorX, anchorY, ignoreHeight); + realScreenWidth, screenHeight, ignoreHeight); } static void SetScrollOffset(JNIEnv *env, jobject obj, jint gen, jint x, jint y) @@ -2711,7 +2614,7 @@ static jstring FindAddress(JNIEnv *env, jobject obj, jstring addr, return ret; } -static jboolean HandleTouchEvent(JNIEnv *env, jobject obj, jint action, jint x, jint y) +static jint HandleTouchEvent(JNIEnv *env, jobject obj, jint action, jint x, jint y) { #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); @@ -2748,6 +2651,32 @@ static jstring RetrieveHref(JNIEnv *env, jobject obj, jint frame, return 0; } +static jstring RetrieveAnchorText(JNIEnv *env, jobject obj, jint frame, + jint node) +{ +#ifdef ANDROID_INSTRUMENT + TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); +#endif + WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); + LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__); + WebCore::String result = viewImpl->retrieveAnchorText((WebCore::Frame*) frame, + (WebCore::Node*) node); + if (!result.isEmpty()) + return WebCoreStringToJString(env, result); + return 0; +} + + +static void MoveFocus(JNIEnv *env, jobject obj, jint framePtr, jint nodePtr) +{ +#ifdef ANDROID_INSTRUMENT + TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); +#endif + WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); + LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__); + viewImpl->moveFocus((WebCore::Frame*) framePtr, (WebCore::Node*) nodePtr); +} + static void MoveMouse(JNIEnv *env, jobject obj, jint frame, jint x, jint y) { @@ -2836,20 +2765,6 @@ static void SetBackgroundColor(JNIEnv *env, jobject obj, jint color) viewImpl->setBackgroundColor((SkColor) color); } -static jstring GetSelection(JNIEnv *env, jobject obj, jobject selRgn) -{ -#ifdef ANDROID_INSTRUMENT - TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); -#endif - WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); - LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__); - SkRegion* selectionRegion = GraphicsJNI::getNativeRegion(env, selRgn); - WebCore::String result = viewImpl->getSelection(selectionRegion); - if (!result.isEmpty()) - return WebCoreStringToJString(env, result); - return 0; -} - static void DumpDomTree(JNIEnv *env, jobject obj, jboolean useFile) { WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); @@ -2944,20 +2859,14 @@ static bool DrawContent(JNIEnv *env, jobject obj, jobject canv, jint color) return viewImpl->drawContent(canvas, color); } -static bool PictureReady(JNIEnv* env, jobject obj) +static bool FocusBoundsChanged(JNIEnv* env, jobject obj) { - return GET_NATIVE_VIEW(env, obj)->pictureReady(); + return GET_NATIVE_VIEW(env, obj)->focusBoundsChanged(); } -static void UpdatePluginState(JNIEnv* env, jobject obj, jint framePtr, jint nodePtr, jint state) +static bool PictureReady(JNIEnv* env, jobject obj) { -#ifdef ANDROID_INSTRUMENT - TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); -#endif - WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); - LOG_ASSERT(viewImpl, "viewImpl not set in nativeUpdatePluginState"); - viewImpl->updatePluginState((WebCore::Frame*) framePtr, (WebCore::Node*) nodePtr, - (PluginState) state); + return GET_NATIVE_VIEW(env, obj)->pictureReady(); } static void Pause(JNIEnv* env, jobject obj) @@ -3027,7 +2936,30 @@ static void ProvideVisitedHistory(JNIEnv *env, jobject obj, jobject hist) env->ReleaseStringChars(item, str); env->DeleteLocalRef(item); } - env->DeleteLocalRef(array); +} + +// Notification from the UI thread that the plugin's full-screen surface has been discarded +static void FullScreenPluginHidden(JNIEnv* env, jobject obj, jint npp) +{ + WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); + PluginWidgetAndroid* plugin = viewImpl->getPluginWidget((NPP)npp); + plugin->exitFullScreen(false); +} + +static WebCore::IntRect jrect_to_webrect(JNIEnv* env, jobject obj) +{ + int L, T, R, B; + GraphicsJNI::get_jrect(env, obj, &L, &T, &R, &B); + return WebCore::IntRect(L, T, R - L, B - T); +} + +static bool ValidNodeAndBounds(JNIEnv *env, jobject obj, int frame, int node, + jobject rect) +{ + IntRect nativeRect = jrect_to_webrect(env, rect); + return GET_NATIVE_VIEW(env, obj)->validNodeAndBounds( + reinterpret_cast<Frame*>(frame), + reinterpret_cast<Node*>(node), nativeRect); } // ---------------------------------------------------------------------------- @@ -3042,6 +2974,8 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) CopyContentToPicture }, { "nativeDrawContent", "(Landroid/graphics/Canvas;I)Z", (void*) DrawContent } , + { "nativeFocusBoundsChanged", "()Z", + (void*) FocusBoundsChanged } , { "nativeKey", "(IIIZZZZ)Z", (void*) Key }, { "nativeClick", "(II)V", @@ -3052,7 +2986,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) SendListBoxChoices }, { "nativeSendListBoxChoice", "(I)V", (void*) SendListBoxChoice }, - { "nativeSetSize", "(IIIFIIIIZ)V", + { "nativeSetSize", "(IIIFIIZ)V", (void*) SetSize }, { "nativeSetScrollOffset", "(III)V", (void*) SetScrollOffset }, @@ -3064,6 +2998,8 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) DeleteSelection } , { "nativeReplaceTextfieldText", "(IILjava/lang/String;III)V", (void*) ReplaceTextfieldText } , + { "nativeMoveFocus", "(II)V", + (void*) MoveFocus }, { "nativeMoveMouse", "(III)V", (void*) MoveMouse }, { "nativeMoveMouseIfLatest", "(IIII)V", @@ -3078,12 +3014,14 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) SaveDocumentState }, { "nativeFindAddress", "(Ljava/lang/String;Z)Ljava/lang/String;", (void*) FindAddress }, - { "nativeHandleTouchEvent", "(III)Z", + { "nativeHandleTouchEvent", "(III)I", (void*) HandleTouchEvent }, { "nativeTouchUp", "(IIIII)V", (void*) TouchUp }, { "nativeRetrieveHref", "(II)Ljava/lang/String;", (void*) RetrieveHref }, + { "nativeRetrieveAnchorText", "(II)Ljava/lang/String;", + (void*) RetrieveAnchorText }, { "nativeUpdateFrameCache", "()V", (void*) UpdateFrameCache }, { "nativeGetContentMinPrefWidth", "()I", @@ -3096,8 +3034,6 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) SplitContent }, { "nativeSetBackgroundColor", "(I)V", (void*) SetBackgroundColor }, - { "nativeGetSelection", "(Landroid/graphics/Region;)Ljava/lang/String;", - (void*) GetSelection }, { "nativeRegisterURLSchemeAsLocal", "(Ljava/lang/String;)V", (void*) RegisterURLSchemeAsLocal }, { "nativeDumpDomTree", "(Z)V", @@ -3114,11 +3050,16 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { { "nativeResume", "()V", (void*) Resume }, { "nativeFreeMemory", "()V", (void*) FreeMemory }, { "nativeSetJsFlags", "(Ljava/lang/String;)V", (void*) SetJsFlags }, - { "nativeUpdatePluginState", "(III)V", (void*) UpdatePluginState }, + { "nativeRequestLabel", "(II)Ljava/lang/String;", + (void*) RequestLabel }, { "nativeUpdateFrameCacheIfLoading", "()V", (void*) UpdateFrameCacheIfLoading }, { "nativeProvideVisitedHistory", "([Ljava/lang/String;)V", (void*) ProvideVisitedHistory }, + { "nativeFullScreenPluginHidden", "(I)V", + (void*) FullScreenPluginHidden }, + { "nativeValidNodeAndBounds", "(IILandroid/graphics/Rect;)Z", + (void*) ValidNodeAndBounds }, }; int register_webviewcore(JNIEnv* env) diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index eab22b4..0569b4d 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -27,6 +27,7 @@ #define WEBVIEWCORE_H #include "android_npapi.h" +#include "FileChooser.h" #include "CacheBuilder.h" #include "CachedHistory.h" #include "PictureSet.h" @@ -45,6 +46,7 @@ namespace WebCore { class AtomicString; class Color; class FrameView; + class HTMLAnchorElement; class HTMLSelectElement; class RenderPart; class RenderText; @@ -62,14 +64,8 @@ class SkIRect; namespace android { - enum PluginState { - kGainFocus_PluginState = 0, - kLoseFocus_PluginState = 1, - }; - class CachedRoot; class ListBoxReply; - class SurfaceCallback; class WebCoreReply : public WebCoreRefObject { public: @@ -130,6 +126,11 @@ namespace android { */ void contentDraw(); +#if USE(ACCELERATED_COMPOSITING) + void immediateRepaint(); + void setRootLayer(int layer); +#endif + /** Invalidate the view/screen, NOT the content/DOM, but expressed in * content/DOM coordinates (i.e. they need to eventually be scaled, * by webview into view.java coordinates @@ -242,9 +243,10 @@ namespace android { // Followings support calls from Java to native WebCore // - WebCore::String retrieveHref(WebCore::Frame* frame, WebCore::Node* node); - WebCore::String getSelection(SkRegion* ); + WebCore::String retrieveHref(WebCore::Frame* frame, WebCore::Node* node); + WebCore::String retrieveAnchorText(WebCore::Frame* frame, WebCore::Node* node); + WebCore::String requestLabel(WebCore::Frame* , WebCore::Node* ); // Create a single picture to represent the drawn DOM (used by navcache) void recordPicture(SkPicture* picture); @@ -252,6 +254,7 @@ namespace android { // Create a set of pictures to represent the drawn DOM, driven by // the invalidated region and the time required to draw (used to draw) void recordPictureSet(PictureSet* master); + void moveFocus(WebCore::Frame* frame, WebCore::Node* node); void moveMouse(WebCore::Frame* frame, int x, int y); void moveMouseIfLatest(int moveGeneration, WebCore::Frame* frame, int x, int y); @@ -262,8 +265,8 @@ namespace android { void setGlobalBounds(int x, int y, int h, int v); void setSizeScreenWidthAndScale(int width, int height, int screenWidth, - float scale, int realScreenWidth, int screenHeight, int anchorX, - int anchorY, bool ignoreHeight); + float scale, int realScreenWidth, int screenHeight, + bool ignoreHeight); /** * Handle key events from Java. @@ -279,7 +282,7 @@ namespace android { /** * Handle touch event */ - bool handleTouchEvent(int action, int x, int y); + int handleTouchEvent(int action, int x, int y); /** * Handle motionUp event from the UI thread (called touchUp in the @@ -348,6 +351,8 @@ namespace android { */ void addPlugin(PluginWidgetAndroid*); void removePlugin(PluginWidgetAndroid*); + // returns true if the pluginwidgit is in our active list + bool isPlugin(PluginWidgetAndroid*) const; void invalPlugin(PluginWidgetAndroid*); void drawPlugins(); @@ -363,39 +368,48 @@ namespace android { // send this event to all of the plugins who have the given flag set void sendPluginEvent(const ANPEvent& evt, ANPEventFlag flag); + // lookup the plugin widget struct given an NPP + PluginWidgetAndroid* getPluginWidget(NPP npp); + // return the cursorNode if it is a plugin Node* cursorNodeIsPlugin(); - // notify the plugin of an update in state - void updatePluginState(Frame* frame, Node* node, PluginState state); - // Notify the Java side whether it needs to pass down the touch events void needTouchEvents(bool); // Notify the Java side that webkit is requesting a keyboard - void requestKeyboard(bool); + void requestKeyboard(bool showKeyboard, bool isTextView); + + // Generates a class loader that contains classes from the plugin's apk + jclass getPluginClass(const WebCore::String& libName, const char* className); - // Creates a full screen surface (i.e. View on an Activity) for a plugin - void startFullScreenPluginActivity(const char* libName, - const char* className, NPP npp); + // Creates a full screen surface for a plugin + void showFullScreenPlugin(jobject webkitPlugin, NPP npp, int x, int y, int width, int height); - // Creates a Surface (i.e. View) for a plugin - jobject createSurface(const char* libName, const char* className, - NPP npp, int x, int y, int width, int height); + // Instructs the UI thread to discard the plugin's full-screen surface + void hideFullScreenPlugin(); + + // Update coordinates and dimensions for a full screen plugin + void updateFullScreenPlugin(int x, int y, int width, int height); + + // Adds the plugin's view (aka surface) to the view hierarchy + jobject addSurface(jobject view, int x, int y, int width, int height); + + // Updates a Surface coordinates and dimensions for a plugin + void updateSurface(jobject childView, int x, int y, int width, int height); // Destroys a SurfaceView for a plugin void destroySurface(jobject childView); - // Make the rect (left, top, width, height) visible. If it can be fully - // fit, center it on the screen. Otherwise make sure the point specified - // by (left + xPercentInDoc * width, top + yPercentInDoc * height) - // pinned at the screen position (xPercentInView, yPercentInView). - void showRect(int left, int top, int width, int height, int contentWidth, - int contentHeight, float xPercentInDoc, float xPercentInView, - float yPercentInDoc, float yPercentInView); + // Returns the context (android.content.Context) of the WebView + jobject getContext(); + bool validNodeAndBounds(Frame* , Node* , const IntRect& ); // other public functions public: + // Open a file chooser for selecting a file to upload + void openFileChooser(PassRefPtr<WebCore::FileChooser> ); + // reset the picture set to empty void clearContent(); @@ -404,6 +418,7 @@ namespace android { // draw the picture set with the specified background color bool drawContent(SkCanvas* , SkColor ); + bool focusBoundsChanged(); bool pictureReady(); // record the inval area, and the picture size @@ -421,7 +436,6 @@ namespace android { static Mutex gFrameCacheMutex; CachedRoot* m_frameCacheKit; // nav data being built by webcore SkPicture* m_navPictureKit; - int m_generation; // copy of the number bumped by WebViewNative int m_moveGeneration; // copy of state in WebViewNative triggered by move int m_touchGeneration; // copy of state in WebViewNative triggered by touch int m_lastGeneration; // last action using up to date cache @@ -466,7 +480,6 @@ namespace android { WebCore::IntRect m_lastFocusedBounds; int m_lastFocusedSelStart; int m_lastFocusedSelEnd; - int m_lastMoveGeneration; static Mutex m_contentMutex; // protects ui/core thread pictureset access PictureSet m_content; // the set of pictures to draw (accessed by UI too) SkRegion m_addInval; // the accumulated inval region (not yet drawn) @@ -474,6 +487,7 @@ namespace android { // Used in passToJS to avoid updating the UI text field until after the // key event has been processed. bool m_blockTextfieldUpdates; + bool m_focusBoundsChanged; bool m_skipContentDraw; // Passed in with key events to know when they were generated. Store it // with the cache so that we can ignore stale text changes. @@ -510,9 +524,21 @@ namespace android { void rebuildPictureSet(PictureSet* ); void sendNotifyProgressFinished(); bool handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* nodePtr); + WebCore::HTMLAnchorElement* retrieveAnchorElement(WebCore::Frame* frame, WebCore::Node* node); + #if DEBUG_NAV_UI uint32_t m_now; #endif + + private: + // called from constructor, to add this to a global list + static void addInstance(WebViewCore*); + // called from destructor, to remove this from a global list + static void removeInstance(WebViewCore*); + public: + // call only from webkit thread (like add/remove), return true if inst + // is still alive + static bool isInstance(WebViewCore*); }; } // namespace android diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp index 4acf598..784c3aa 100644 --- a/WebKit/android/nav/CacheBuilder.cpp +++ b/WebKit/android/nav/CacheBuilder.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -42,6 +42,7 @@ #include "HTMLNames.h" #include "HTMLOptionElement.h" #include "HTMLSelectElement.h" +#include "HTMLTextAreaElement.h" #include "InlineTextBox.h" #include "KURL.h" #include "PluginView.h" @@ -93,14 +94,11 @@ Frame* CacheBuilder::FrameAnd(const CacheBuilder* cacheBuilder) { #if DUMP_NAV_CACHE static bool hasEventListener(Node* node, const AtomicString& eventType) { - const RegisteredEventListenerVector& listeners = node->eventListeners(); - size_t size = listeners.size(); - for (size_t i = 0; i < size; ++i) { - const RegisteredEventListener& r = *listeners[i]; - if (r.eventType() == eventType) - return true; - } - return false; + if (!node->isElementNode()) + return false; + Element* element = static_cast<Element*>(node); + EventListener* listener = element->getAttributeEventListener(eventType); + return 0 != listener; } #define DEBUG_BUFFER_SIZE 256 @@ -143,7 +141,9 @@ void CacheBuilder::Debug::flush() { break; len++; } - while (mBuffer[len] == '\\' || mBuffer[len] == '"') + while (len > 0 && mBuffer[len - 1] == '\\') + len--; + while (mBuffer[len] == '"') len++; } const char* prefix = mPrefix; @@ -349,8 +349,11 @@ void CacheBuilder::Debug::groups() { } while ((node = node->traverseNextNode()) != NULL); int focusIndex = -1; if (atLeastOne == false) { - DUMP_NAV_LOGD("#define TEST%s_RECTS NULL\n", name); - DUMP_NAV_LOGD("static int TEST%s_RECT_COUNT = 0; // no focusable nodes\n", name); + DUMP_NAV_LOGD("static DebugTestNode TEST%s_RECTS[] = {\n" + "{{0, 0, 0, 0}, \"\", 0, -1, \"\", {0, 0, 0, 0}, false, 0}\n" + "};\n\n", name); + DUMP_NAV_LOGD("static int TEST%s_RECT_COUNT = 1;" + " // no focusable nodes\n", name); DUMP_NAV_LOGD("#define TEST%s_RECTPARTS NULL\n", name); } else { node = doc; @@ -435,6 +438,7 @@ void CacheBuilder::Debug::groups() { snprintf(scratch, sizeof(scratch), ", {%d, %d, %d, %d}, %s" ", %d},",absB.x(), absB.y(), absB.width(), absB.height(), renderer->hasOverflowClip() ? "true" : "false", tabindex); + // TODO: add renderer->style()->visibility() print(scratch); } else print(", {0, 0, 0, 0}, false, 0},"); @@ -547,7 +551,7 @@ void CacheBuilder::Debug::groups() { int contentsHeight = layer->height(); DUMP_NAV_LOGD("static int TEST%s_FOCUS = %d;\n", name, focusIndex); DUMP_NAV_LOGD("static int TEST%s_WIDTH = %d;\n", name, contentsWidth); - DUMP_NAV_LOGD("static int TEST%s_HEIGHT = %d;\n", name, contentsHeight); + DUMP_NAV_LOGD("static int TEST%s_HEIGHT = %d;\n\n", name, contentsHeight); } bool CacheBuilder::Debug::isFocusable(Node* node) { @@ -721,7 +725,7 @@ void CacheBuilder::Debug::wideString(const String& str) { CacheBuilder::CacheBuilder() { - mAllowableTypes = ALL_CACHEDNODETYPES; + mAllowableTypes = ALL_CACHEDNODE_BITS; #ifdef DUMP_NAV_CACHE_USING_PRINTF gNavCacheLogFile = NULL; #endif @@ -756,14 +760,9 @@ void CacheBuilder::adjustForColumns(const ClipColumnTracker& track, // Checks if a node has one of event listener types. bool CacheBuilder::NodeHasEventListeners(Node* node, AtomicString* eventTypes, int length) { - const RegisteredEventListenerVector& listeners = node->eventListeners(); - size_t size = listeners.size(); - for (size_t i = 0; i < size; ++i) { - const RegisteredEventListener& r = *listeners[i]; - for (int j = 0; j < length; ++j) { - if (r.eventType() == eventTypes[j]) - return true; - } + for (int i = 0; i < length; ++i) { + if (!node->getEventListeners(eventTypes[i]).isEmpty()) + return true; } return false; } @@ -825,6 +824,16 @@ void CacheBuilder::buildCache(CachedRoot* root) setData((CachedFrame*) root); } +static Node* ParentWithChildren(Node* node) +{ + Node* parent = node; + while ((parent = parent->parentNode())) { + if (parent->childNodeCount() > 1) + return parent; + } + return 0; +} + static Node* OneAfter(Node* node) { Node* parent = node; @@ -900,6 +909,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, cachedFrame->add(cachedParentNode); Node* node = parent; int cacheIndex = 1; + int textInputIndex = 0; Node* focused = doc->focusedNode(); if (focused) cachedRoot->setFocusBounds(focused->getRect()); @@ -918,8 +928,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, lastChildIndex = last->mCachedNodeIndex; last = &tracker.last(); } - if (node == last->mParentLastChild) - last->mParentLastChild = NULL; do { const ClipColumnTracker* lastClip = &clipTracker.last(); if (node != lastClip->mLastChild) @@ -946,7 +954,8 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, cachedFrame->addFrame(cachedChild); cachedNode.init(node); cachedNode.setIndex(cacheIndex++); - cachedNode.setChildFrameIndex(childFrameIndex); + cachedNode.setDataIndex(childFrameIndex); + cachedNode.setType(FRAME_CACHEDNODETYPE); #if DUMP_NAV_CACHE cachedNode.mDebug.mNodeIndex = nodeIndex; cachedNode.mDebug.mParentGroupIndex = Debug::ParentIndex( @@ -986,29 +995,23 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, bool computeCursorRings = false; bool hasClip = false; bool hasMouseOver = false; - bool isAnchor = false; - bool isArea = node->hasTagName(HTMLNames::areaTag); - bool isPassword = false; - bool isTextArea = false; - bool isTextField = false; - bool isRtlText = false; bool isUnclipped = false; bool isFocus = node == focused; bool takesFocus = false; - bool wantsKeyEvents = false; - int maxLength = -1; - int textSize = 12; int columnGap = 0; TextDirection direction = LTR; - String name; String exported; CachedNodeType type = NORMAL_CACHEDNODETYPE; + CachedInput cachedInput; IntRect bounds; IntRect absBounds; + IntRect originalAbsBounds; WTF::Vector<IntRect>* columns = NULL; - if (isArea) { + if (node->hasTagName(HTMLNames::areaTag)) { + type = AREA_CACHEDNODETYPE; HTMLAreaElement* area = static_cast<HTMLAreaElement*>(node); bounds = getAreaRect(area); + originalAbsBounds = bounds; bounds.move(globalOffsetX, globalOffsetY); absBounds = bounds; isUnclipped = true; // FIXME: areamaps require more effort to detect @@ -1021,6 +1024,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, // some common setup absBounds = nodeRenderer->absoluteBoundingBoxRect(); + originalAbsBounds = absBounds; absBounds.move(globalOffsetX, globalOffsetY); hasClip = nodeRenderer->hasOverflowClip(); @@ -1028,7 +1032,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, bounds = absBounds; isUnclipped = true; takesFocus = true; - wantsKeyEvents = true; + type = PLUGIN_CACHEDNODETYPE; goto keepNode; } if (nodeRenderer->isRenderBlock()) { @@ -1052,11 +1056,11 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, clip.mHasClip = hasClip; clip.mDirection = direction; if (columns != NULL) { - const IntRect& oRect = ((RenderBox*)nodeRenderer)->overflowRect(true); + const IntRect& oRect = ((RenderBox*)nodeRenderer)->visibleOverflowRect(); clip.mBounds.move(oRect.x(), oRect.y()); } } - if (node->isTextNode() && mAllowableTypes != NORMAL_CACHEDNODETYPE) { + if (node->isTextNode() && mAllowableTypes != NORMAL_CACHEDNODE_BITS) { if (last->mSomeParentTakesFocus) // don't look at text inside focusable node continue; CachedNodeType checkType; @@ -1072,7 +1076,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, DUMP_NAV_LOGD("%s\n", buffer); } #endif - type = (CachedNodeType) checkType; + type = checkType; // !!! test ! is the following line correctly needed for frames to work? cachedNode.init(node); const ClipColumnTracker& clipTrack = clipTracker.last(); @@ -1095,19 +1099,34 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, goto keepTextNode; } if (node->hasTagName(WebCore::HTMLNames::inputTag)) { - HTMLInputElement* input = (HTMLInputElement*) node; - if (input->inputType() == HTMLInputElement::FILE) + HTMLInputElement* input = static_cast<HTMLInputElement*>(node); + HTMLInputElement::InputType inputType = input->inputType(); + if (input->isTextField()) { + type = TEXT_INPUT_CACHEDNODETYPE; + cachedInput.init(); + cachedInput.setFormPointer(input->form()); + cachedInput.setIsTextField(true); + exported = input->value().threadsafeCopy(); + cachedInput.setMaxLength(input->maxLength()); + cachedInput.setInputType(inputType); + // If this does not need to be threadsafe, we can use crossThreadString(). + // See http://trac.webkit.org/changeset/49160. + cachedInput.setName(input->name().string().threadsafeCopy()); + // can't detect if this is drawn on top (example: deviant.com login parts) + isUnclipped = isTransparent; + } else if (inputType == HTMLInputElement::HIDDEN) continue; - isTextField = input->isTextField(); - if (isTextField) - wantsKeyEvents = true; - isPassword = input->inputType() == HTMLInputElement::PASSWORD; - maxLength = input->maxLength(); - name = input->name().string().copy(); - isUnclipped = isTransparent; // can't detect if this is drawn on top (example: deviant.com login parts) - } else if (node->hasTagName(HTMLNames::textareaTag)) - isTextArea = wantsKeyEvents = true; - else if (node->hasTagName(HTMLNames::aTag)) { + } else if (node->hasTagName(HTMLNames::textareaTag)) { + cachedInput.init(); + type = TEXT_INPUT_CACHEDNODETYPE; + HTMLTextAreaElement* area = static_cast<HTMLTextAreaElement*>(node); + cachedInput.setFormPointer(area->form()); + // Although technically it is not an HTMLInputElement, and therefore + // has no InputType, this one is the most appropriate. + cachedInput.setInputType(HTMLInputElement::TEXT); + cachedInput.setIsTextField(false); + exported = area->value().threadsafeCopy(); + } else if (node->hasTagName(HTMLNames::aTag)) { const HTMLAnchorElement* anchorNode = (const HTMLAnchorElement*) node; if (!anchorNode->isFocusable() && !HasTriggerEvent(node)) @@ -1115,32 +1134,31 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, if (node->disabled()) continue; hasMouseOver = NodeHasEventListeners(node, &eventNames().mouseoverEvent, 1); - isAnchor = true; + type = ANCHOR_CACHEDNODETYPE; KURL href = anchorNode->href(); if (!href.isEmpty() && !WebCore::protocolIsJavaScript(href.string())) // Set the exported string for all non-javascript anchors. - exported = href.string().copy(); + exported = href.string().threadsafeCopy(); } - if (isTextField || isTextArea) { + if (type == TEXT_INPUT_CACHEDNODETYPE) { RenderTextControl* renderText = static_cast<RenderTextControl*>(nodeRenderer); if (isFocus) cachedRoot->setSelection(renderText->selectionStart(), renderText->selectionEnd()); - exported = renderText->text().copy(); // FIXME: Would it be better to use (float) size()? // FIXME: Are we sure there will always be a style and font, and it's correct? RenderStyle* style = nodeRenderer->style(); if (style) { isUnclipped |= !style->hasAppearance(); - textSize = style->fontSize(); - isRtlText = style->direction() == RTL || - style->textAlign() == WebCore::RIGHT || - style->textAlign() == WebCore::WEBKIT_RIGHT; + cachedInput.setTextSize(style->fontSize()); + cachedInput.setIsRtlText(style->direction() == RTL + || style->textAlign() == WebCore::RIGHT + || style->textAlign() == WebCore::WEBKIT_RIGHT); } } takesFocus = true; bounds = absBounds; - if (!isAnchor) { + if (type != ANCHOR_CACHEDNODETYPE) { bool isFocusable = node->isKeyboardFocusable(NULL) || node->isMouseFocusable() || node->isFocusable(); if (isFocusable == false) { @@ -1174,43 +1192,38 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, continue; } const IntRect& parentClip = clipTrack.mBounds; - if (hasClip == false && isAnchor) + if (hasClip == false && type == ANCHOR_CACHEDNODETYPE) clip = parentClip; else clip.intersect(parentClip); hasClip = true; } - if (hasClip && !clip.isEmpty() && cachedNode.clip(clip) == false) { - cachedNode.setBounds(clip); - cachedNode.cursorRings().append(clip); - isUnclipped = true; + if (hasClip) { + if (clip.isEmpty()) + continue; // skip this node if clip prevents all drawing + else if (cachedNode.clip(clip) == false) + continue; // skip this node if outside of the clip } cachedNode.setNavableRects(); - cachedNode.setChildFrameIndex(-1); cachedNode.setExport(exported); cachedNode.setHasCursorRing(hasCursorRing); cachedNode.setHasMouseOver(hasMouseOver); cachedNode.setHitBounds(absBounds); cachedNode.setIndex(cacheIndex); - cachedNode.setIsAnchor(isAnchor); - cachedNode.setIsArea(isArea); cachedNode.setIsFocus(isFocus); - cachedNode.setIsPassword(isPassword); - cachedNode.setIsRtlText(isRtlText); - cachedNode.setIsTextArea(isTextArea); - cachedNode.setIsTextField(isTextField); cachedNode.setIsTransparent(isTransparent); cachedNode.setIsUnclipped(isUnclipped); - cachedNode.setMaxLength(maxLength); - cachedNode.setName(name); + cachedNode.setOriginalAbsoluteBounds(originalAbsBounds); cachedNode.setParentIndex(last->mCachedNodeIndex); - if (last->mParentLastChild == NULL) - last->mParentLastChild = OneAfter(node->parentNode()->lastChild()); - cachedNode.setParentGroup(last->mParentLastChild); + cachedNode.setParentGroup(ParentWithChildren(node)); cachedNode.setTabIndex(tabIndex); - cachedNode.setTextSize(textSize); cachedNode.setType(type); - cachedNode.setWantsKeyEvents(wantsKeyEvents); + if (type == TEXT_INPUT_CACHEDNODETYPE) { + cachedFrame->add(cachedInput); + cachedNode.setDataIndex(textInputIndex); + textInputIndex++; + } else + cachedNode.setDataIndex(-1); #if DUMP_NAV_CACHE cachedNode.mDebug.mNodeIndex = nodeIndex; cachedNode.mDebug.mParentGroupIndex = Debug::ParentIndex( @@ -1228,7 +1241,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, Tracker& working = tracker.last(); working.mCachedNodeIndex = lastIndex; working.mLastChild = OneAfter(lastChild); - working.mParentLastChild = OneAfter(node->parentNode()->lastChild()); last = &tracker.at(tracker.size() - 2); working.mSomeParentTakesFocus = last->mSomeParentTakesFocus | takesFocus; } @@ -1672,9 +1684,7 @@ CacheBuilder::FoundState CacheBuilder::FindPartialAddress(const UChar* baseChars // is that suggested this fix. // if (s->mWordCount == 0 && s->mContinuationNode) // return FOUND_NONE; - s->mBases[s->mWordCount] = baseChars; - s->mWords[s->mWordCount] = chars - s->mNumberCount; - s->mStarts[s->mWordCount] = s->mCurrentStart; + s->newWord(baseChars, chars); if (WTF::isASCIILower(ch) && s->mNumberCount == 0) s->mFirstLower = chars; s->mNumberCount = 0; @@ -1722,9 +1732,7 @@ CacheBuilder::FoundState CacheBuilder::FindPartialAddress(const UChar* baseChars s->mNumberWords >>= ++shift; if (s->mBases[0] != s->mBases[shift]) // if we're past the original node, bail break; - memmove(s->mBases, &s->mBases[shift], (sizeof(s->mBases) / sizeof(s->mBases[0]) - shift) * sizeof(s->mBases[0])); - memmove(s->mWords, &s->mWords[shift], (sizeof(s->mWords) / sizeof(s->mWords[0]) - shift) * sizeof(s->mWords[0])); - memmove(s->mStarts, &s->mStarts[shift], (sizeof(s->mStarts) / sizeof(s->mStarts[0]) - shift) * sizeof(s->mStarts[0])); + s->shiftWords(shift); s->mStartResult = s->mWords[0] - s->mStarts[0]; s->mWordCount -= shift; // FIXME: need to adjust lineCount to account for discarded delimiters @@ -1771,9 +1779,7 @@ CacheBuilder::FoundState CacheBuilder::FindPartialAddress(const UChar* baseChars continue; if (s->mWordCount == 0 && s->mContinuationNode) return FOUND_NONE; - s->mBases[s->mWordCount] = baseChars; - s->mWords[s->mWordCount] = chars; - s->mStarts[s->mWordCount] = s->mCurrentStart; + s->newWord(baseChars, chars); s->mNumberWords |= 1 << s->mWordCount; s->mUnparsed = true; } @@ -1796,9 +1802,7 @@ CacheBuilder::FoundState CacheBuilder::FindPartialAddress(const UChar* baseChars case SECOND_HALF: if (WTF::isASCIIAlpha(ch)) { if (s->mLetterCount == 0) { - s->mBases[s->mWordCount] = baseChars; - s->mWords[s->mWordCount] = chars; - s->mStarts[s->mWordCount] = s->mCurrentStart; + s->newWord(baseChars, chars); s->mWordCount++; } s->mLetterCount++; @@ -1917,9 +1921,7 @@ CacheBuilder::FoundState CacheBuilder::FindPartialAddress(const UChar* baseChars s->mZipDelimiter = true; else { if (s->mLetterCount == 0) { - s->mBases[s->mWordCount] = baseChars; - s->mWords[s->mWordCount] = chars; - s->mStarts[s->mWordCount] = s->mCurrentStart; + s->newWord(baseChars, chars); s->mUnparsed = true; } ++s->mLetterCount; @@ -1990,7 +1992,8 @@ CacheBuilder::FoundState CacheBuilder::FindPartialAddress(const UChar* baseChars goto nextTest; abbr = true; } - letter = test[testIndex]; + letter = &test[testIndex] < s->mEnds[wordsIndex] ? + test[testIndex] : ' '; if (WTF::isASCIIAlpha(letter) == false && WTF::isASCIIDigit(letter) == false) { if (s->mNumberWords != 0) { int shift = 0; @@ -2031,9 +2034,7 @@ CacheBuilder::FoundState CacheBuilder::FindPartialAddress(const UChar* baseChars s->mNumberWords >>= ++shift; if (s->mBases[0] != s->mBases[shift]) return FOUND_NONE; - memmove(s->mBases, &s->mBases[shift], (sizeof(s->mBases) / sizeof(s->mBases[0]) - shift) * sizeof(s->mBases[0])); - memmove(s->mWords, &s->mWords[shift], (sizeof(s->mWords) / sizeof(s->mWords[0]) - shift) * sizeof(s->mWords[0])); - memmove(s->mStarts, &s->mStarts[shift], (sizeof(s->mStarts) / sizeof(s->mStarts[0]) - shift) * sizeof(s->mStarts[0])); + s->shiftWords(shift); s->mStartResult = s->mWords[0] - s->mStarts[0]; s->mWordCount -= shift; s->mProgress = ADDRESS_LINE; @@ -2431,7 +2432,7 @@ bool CacheBuilder::isFocusableText(NodeWalk* walk, bool more, Node* node, CachedNodeType* type, String* exported) const { Text* textNode = static_cast<Text*>(node); - StringImpl* string = textNode->string(); + StringImpl* string = textNode->dataImpl(); const UChar* baseChars = string->characters(); // const UChar* originalBase = baseChars; int length = string->length(); @@ -2462,9 +2463,9 @@ bool CacheBuilder::isFocusableText(NodeWalk* walk, bool more, Node* node, baseStart = start; for (CachedNodeType checkType = ADDRESS_CACHEDNODETYPE; checkType <= PHONE_CACHEDNODETYPE; - checkType = (CachedNodeType) (checkType << 1)) + checkType = static_cast<CachedNodeType>(checkType + 1)) { - if ((checkType & mAllowableTypes) == 0) + if ((1 << (checkType - 1) & mAllowableTypes) == 0) continue; InlineTextBox* inlineTextBox = baseInline; FindState findState; @@ -2536,7 +2537,7 @@ bool CacheBuilder::isFocusableText(NodeWalk* walk, bool more, Node* node, exported->truncate(0); do { Text* tempText = static_cast<Text*>(temp); - StringImpl* string = tempText->string(); + StringImpl* string = tempText->dataImpl(); int end = tempText == walk->mFinalNode ? walk->mEnd : string->length(); exported->append(String(string->substring( @@ -2596,7 +2597,7 @@ bool CacheBuilder::isFocusableText(NodeWalk* walk, bool more, Node* node, } while (renderer == NULL); baseInline = renderer->firstTextBox(); } while (baseInline == NULL); - string = nextNode->string(); + string = nextNode->dataImpl(); baseChars = string->characters(); inlineTextBox = baseInline; start = inlineTextBox->start(); @@ -2606,7 +2607,7 @@ bool CacheBuilder::isFocusableText(NodeWalk* walk, bool more, Node* node, tryNextCheckType: node = textNode; baseInline = saveInline; - string = textNode->string(); + string = textNode->dataImpl(); baseChars = string->characters(); } if (foundBetter) { @@ -2865,7 +2866,7 @@ bool CacheBuilder::ConstructTextRect(Text* textNode, { RenderText* renderText = (RenderText*) textNode->renderer(); EVisibility vis = renderText->style()->visibility(); - StringImpl* string = textNode->string(); + StringImpl* string = textNode->dataImpl(); const UChar* chars = string->characters(); FloatPoint pt = renderText->localToAbsolute(); do { diff --git a/WebKit/android/nav/CacheBuilder.h b/WebKit/android/nav/CacheBuilder.h index 35bd623..ff395d3 100644 --- a/WebKit/android/nav/CacheBuilder.h +++ b/WebKit/android/nav/CacheBuilder.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -77,19 +77,20 @@ public: FOUND_COMPLETE }; CacheBuilder(); - void allowAllTextDetection() { mAllowableTypes = ALL_CACHEDNODETYPES; } + void allowAllTextDetection() { mAllowableTypes = ALL_CACHEDNODE_BITS; } void buildCache(CachedRoot* root); static bool ConstructPartRects(Node* node, const IntRect& bounds, IntRect* focusBounds, int x, int y, WTF::Vector<IntRect>* result); Node* currentFocus() const; - void disallowAddressDetection() { mAllowableTypes = (CachedNodeType) ( - mAllowableTypes & ~ADDRESS_CACHEDNODETYPE); } - void disallowEmailDetection() { mAllowableTypes = (CachedNodeType) ( - mAllowableTypes & ~EMAIL_CACHEDNODETYPE); } - void disallowPhoneDetection() { mAllowableTypes = (CachedNodeType) ( - mAllowableTypes & ~PHONE_CACHEDNODETYPE); } + void disallowAddressDetection() { mAllowableTypes = (CachedNodeBits) ( + mAllowableTypes & ~ADDRESS_CACHEDNODE_BIT); } + void disallowEmailDetection() { mAllowableTypes = (CachedNodeBits) ( + mAllowableTypes & ~EMAIL_CACHEDNODE_BIT); } + void disallowPhoneDetection() { mAllowableTypes = (CachedNodeBits) ( + mAllowableTypes & ~PHONE_CACHEDNODE_BIT); } static FoundState FindAddress(const UChar* , unsigned length, int* start, int* end, bool caseInsensitive); + static IntRect getAreaRect(const HTMLAreaElement* area); static void GetGlobalOffset(Frame* , int* x, int * y); static void GetGlobalOffset(Node* , int* x, int * y); static bool validNode(Frame* startFrame, void* framePtr, void* nodePtr); @@ -126,7 +127,6 @@ private: BoundsPart mPart; WTF::Vector<BoundsPart> mParts; char mStore[NAVIGATION_MAX_PHONE_LENGTH + 1]; - CachedNodeType mStoreType; int mPartIndex; Node* mNode; Node* mFinalNode; @@ -146,6 +146,7 @@ private: const UChar* mZipStart; const UChar* mBases[16]; // FIXME: random guess, maybe too small, maybe too big const UChar* mWords[16]; + const UChar* mEnds[16]; const UChar* mStarts[16]; // text is not necessarily contiguous const char* mStates; int mEndWord; @@ -165,6 +166,22 @@ private: bool mInitialized; bool mContinuationNode; bool mCaseInsensitive; + void shiftWords(int shift) { + memmove(mBases, &mBases[shift], (sizeof(mBases) / + sizeof(mBases[0]) - shift) * sizeof(mBases[0])); + memmove(mWords, &mWords[shift], (sizeof(mWords) / + sizeof(mWords[0]) - shift) * sizeof(mWords[0])); + memmove(mEnds, &mEnds[shift], (sizeof(mEnds) / + sizeof(mEnds[0]) - shift) * sizeof(mEnds[0])); + memmove(mStarts, &mStarts[shift], (sizeof(mStarts) / + sizeof(mStarts[0]) - shift) * sizeof(mStarts[0])); + } + void newWord(const UChar* baseChars, const UChar* chars) { + mBases[mWordCount] = baseChars; + mWords[mWordCount] = chars; + mEnds[mWordCount] = mEnd; + mStarts[mWordCount] = mCurrentStart; + } }; struct ClipColumnTracker { IntRect mBounds; @@ -183,7 +200,6 @@ private: int mCachedNodeIndex; int mTabIndex; Node* mLastChild; - Node* mParentLastChild; bool mSomeParentTakesFocus; }; void adjustForColumns(const ClipColumnTracker& track, @@ -212,7 +228,6 @@ private: static Frame* FrameAnd(CacheBuilder* focusNav); static Frame* FrameAnd(const CacheBuilder* focusNav); static CacheBuilder* Builder(Frame* ); - static IntRect getAreaRect(const HTMLAreaElement* area); static Frame* HasFrame(Node* ); static bool HasOverOrOut(Node* ); static bool HasTriggerEvent(Node* ); @@ -225,7 +240,7 @@ private: bool setData(CachedFrame* ); Node* tryFocus(Direction direction); Node* trySegment(Direction direction, int mainStart, int mainEnd); - CachedNodeType mAllowableTypes; + CachedNodeBits mAllowableTypes; #if DUMP_NAV_CACHE public: class Debug { diff --git a/WebKit/android/nav/CachedDebug.h b/WebKit/android/nav/CachedDebug.h index 3127112..3dbe5ef 100644 --- a/WebKit/android/nav/CachedDebug.h +++ b/WebKit/android/nav/CachedDebug.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -26,21 +26,9 @@ #ifndef CachedDebug_H #define CachedDebug_H -#ifndef DUMP_NAV_CACHE -#ifdef NDEBUG #define DUMP_NAV_CACHE 0 -#else -#define DUMP_NAV_CACHE 1 -#endif -#endif - -#ifndef DEBUG_NAV_UI -#ifdef NDEBUG #define DEBUG_NAV_UI 0 -#else -#define DEBUG_NAV_UI 1 -#endif -#endif +#define DEBUG_NAV_UI_VERBOSE 0 #if DEBUG_NAV_UI #define DBG_NAV_LOG(message) LOGD("%s %s", __FUNCTION__, message) @@ -49,10 +37,15 @@ #else #define DBG_NAV_LOG(message) ((void)0) #define DBG_NAV_LOGD(format, ...) ((void)0) -#define DBG_NAV_LOGD_THROTTLE(format, ...) ((void)0) #define DEBUG_NAV_UI_LOGD(...) ((void)0) #endif +#if DEBUG_NAV_UI_VERBOSE +#define DBG_NAV_LOGV(format, ...) LOGD("%s " format, __FUNCTION__, __VA_ARGS__) +#else +#define DBG_NAV_LOGV(format, ...) ((void)0) +#endif + #if DUMP_NAV_CACHE != 0 && !defined DUMP_NAV_CACHE_USING_PRINTF && defined NDEBUG #define DUMP_NAV_CACHE_USING_PRINTF #endif diff --git a/WebKit/android/nav/CachedFrame.cpp b/WebKit/android/nav/CachedFrame.cpp index 955a439..299dc53 100644 --- a/WebKit/android/nav/CachedFrame.cpp +++ b/WebKit/android/nav/CachedFrame.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -402,7 +402,7 @@ const CachedNode* CachedFrame::findBestAt(const WebCore::IntRect& rect, int dx = testCenter.x() - center.x(); int dy = testCenter.y() - center.y(); int distance = dx * dx + dy * dy; - if ((!*inside && testInside) || *best > distance) { + if ((!*inside && testInside) || *best >= distance) { *best = distance; *inside = testInside; result = test; @@ -441,14 +441,18 @@ const CachedFrame* CachedFrame::findBestFrameAt(int x, int y) const } const CachedNode* CachedFrame::findBestHitAt(const WebCore::IntRect& rect, - int* best, const CachedFrame** framePtr, int* x, int* y) const + const CachedFrame** framePtr, int* x, int* y) const { - const CachedNode* result = NULL; - int rectWidth = rect.width(); - WebCore::IntPoint center = WebCore::IntPoint(rect.x() + (rectWidth >> 1), - rect.y() + (rect.height() >> 1)); mRoot->setupScrolledBounds(); - for (const CachedNode* test = mCachedNodes.begin(); test != mCachedNodes.end(); test++) { + for (const CachedFrame* frame = mCachedFrames.end() - 1; + frame != mCachedFrames.begin() - 1; frame--) { + const CachedNode* frameResult = frame->findBestHitAt(rect, + framePtr, x, y); + if (NULL != frameResult) + return frameResult; + } + for (const CachedNode* test = mCachedNodes.end() - 1; + test != mCachedNodes.begin() - 1; test--) { if (test->disabled()) continue; const WebCore::IntRect& testRect = test->hitBounds(); @@ -459,29 +463,19 @@ const CachedNode* CachedFrame::findBestHitAt(const WebCore::IntRect& rect, testData.mMouseBounds = testData.mNodeBounds = testRect; if (mRoot->maskIfHidden(&testData) == true) continue; - const WebCore::IntRect& bounds = testData.mMouseBounds; - WebCore::IntPoint testCenter = WebCore::IntPoint(bounds.x() + - (bounds.width() >> 1), bounds.y() + (bounds.height() >> 1)); - int dx = testCenter.x() - center.x(); - int dy = testCenter.y() - center.y(); - int distance = dx * dx + dy * dy; - if (*best <= distance) - continue; - *best = distance; - result = test; - *framePtr = this; - const WebCore::IntRect& cursorRect = test->cursorRings().at(0); - *x = cursorRect.x() + (cursorRect.width() >> 1); - *y = cursorRect.y() + (cursorRect.height() >> 1); - } - for (const CachedFrame* frame = mCachedFrames.begin(); - frame != mCachedFrames.end(); frame++) { - const CachedNode* frameResult = frame->findBestHitAt(rect, best, - framePtr, x, y); - if (NULL != frameResult) - result = frameResult; + for (unsigned i = 0; i < test->cursorRings().size(); i++) { + const WebCore::IntRect& cursorRect = test->cursorRings().at(i); + if (cursorRect.intersects(rect)) { + WebCore::IntRect intersection(cursorRect); + intersection.intersect(rect); + *x = intersection.x() + (intersection.width() >> 1); + *y = intersection.y() + (intersection.height() >> 1); + *framePtr = this; + return test; + } + } } - return result; + return NULL; } void CachedFrame::findClosest(BestData* bestData, Direction originalDirection, @@ -687,7 +681,7 @@ int CachedFrame::frameNodeCommon(BestData& testData, const CachedNode* test, Bes // return REJECT_TEST; // } void* par = cursor ? cursor->parentGroup() : NULL; - testData.mCursorChild = test->parentGroup() == par; + testData.mCursorChild = par ? test->parentGroup() == par : false; #if 0 // not debugged if (cursor && cursor->hasMouseOver() && test->hasMouseOver() == false && cursor->bounds().contains(test->bounds())) @@ -753,7 +747,7 @@ int CachedFrame::frameNodeCommon(BestData& testData, const CachedNode* test, Bes int CachedFrame::framePartCommon(BestData& testData, const CachedNode* test, BestData* bestData, const CachedNode* cursor) const { - if (cursor && testData.mNodeBounds.contains(cursor->bounds())) { + if (cursor && testData.mNodeBounds.contains(cursor->bounds()) && !test->wantsKeyEvents()) { testData.mNode->setCondition(CachedNode::NOT_ENCLOSING_CURSOR); return REJECT_TEST; } @@ -911,8 +905,8 @@ const CachedNode* CachedFrame::nextTextField(const CachedNode* start, = frame->nextTextField(0, framePtr, includeTextAreas); if (node) return node; - } else if (test->isTextField() - || (includeTextAreas && test->isTextArea())) { + } else if (test->isTextField(this) + || (includeTextAreas && test->isTextInput())) { if (framePtr) *framePtr = this; return test; @@ -1144,7 +1138,7 @@ bool CachedFrame::BestData::setDownDirection(const CachedHistory* history) int inNavBottom = navBounds.bottom() - mNodeBounds.bottom(); setNavInclusion(testRight - navBounds.right(), navBounds.x() - testX); bool subsumes = navBounds.height() > 0 && inOrSubsumesNav(); - if (inNavTop <= 0 && inNavBottom <= 0 && subsumes) { + if (inNavTop <= 0 && inNavBottom <= 0 && subsumes && !mNode->wantsKeyEvents()) { mNode->setCondition(CachedNode::NOT_ENCLOSING_CURSOR); return REJECT_TEST; } @@ -1184,7 +1178,7 @@ bool CachedFrame::BestData::setLeftDirection(const CachedHistory* history) int inNavLeft = mNodeBounds.x() - navBounds.x(); setNavInclusion(navBounds.y() - testY, testBottom - navBounds.bottom()); bool subsumes = navBounds.width() > 0 && inOrSubsumesNav(); - if (inNavLeft <= 0 && inNavRight <= 0 && subsumes) { + if (inNavLeft <= 0 && inNavRight <= 0 && subsumes && !mNode->wantsKeyEvents()) { mNode->setCondition(CachedNode::NOT_ENCLOSING_CURSOR); return REJECT_TEST; } @@ -1224,7 +1218,7 @@ bool CachedFrame::BestData::setRightDirection(const CachedHistory* history) int inNavRight = navBounds.right() - mNodeBounds.right(); setNavInclusion(testBottom - navBounds.bottom(), navBounds.y() - testY); bool subsumes = navBounds.width() > 0 && inOrSubsumesNav(); - if (inNavLeft <= 0 && inNavRight <= 0 && subsumes) { + if (inNavLeft <= 0 && inNavRight <= 0 && subsumes && !mNode->wantsKeyEvents()) { mNode->setCondition(CachedNode::NOT_ENCLOSING_CURSOR); return REJECT_TEST; } @@ -1264,7 +1258,7 @@ bool CachedFrame::BestData::setUpDirection(const CachedHistory* history) int inNavTop = mNodeBounds.y() - navBounds.y(); setNavInclusion(navBounds.x() - testX, testRight - navBounds.right()); bool subsumes = navBounds.height() > 0 && inOrSubsumesNav(); - if (inNavTop <= 0 && inNavBottom <= 0 && subsumes) { + if (inNavTop <= 0 && inNavBottom <= 0 && subsumes && !mNode->wantsKeyEvents()) { mNode->setCondition(CachedNode::NOT_ENCLOSING_CURSOR); return REJECT_TEST; } @@ -1332,8 +1326,12 @@ void CachedFrame::Debug::print() const DEBUG_PRINT_RECT("//", VIEW, mViewBounds); DUMP_NAV_LOGD("// CachedNode mCachedNodes={ // count=%d\n", b->mCachedNodes.size()); for (CachedNode* node = b->mCachedNodes.begin(); - node != b->mCachedNodes.end(); node++) + node != b->mCachedNodes.end(); node++) { node->mDebug.print(); + const CachedInput* input = b->textInput(node); + if (input) + input->mDebug.print(); + } DUMP_NAV_LOGD("// }; // end of nodes\n"); DUMP_NAV_LOGD("// CachedFrame mCachedFrames={ // count=%d\n", b->mCachedFrames.size()); for (CachedFrame* child = b->mCachedFrames.begin(); diff --git a/WebKit/android/nav/CachedFrame.h b/WebKit/android/nav/CachedFrame.h index fcfddb8..7a00539 100644 --- a/WebKit/android/nav/CachedFrame.h +++ b/WebKit/android/nav/CachedFrame.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -26,6 +26,7 @@ #ifndef CachedFrame_H #define CachedFrame_H +#include "CachedInput.h" #include "CachedNode.h" #include "IntRect.h" #include "SkFixed.h" @@ -66,6 +67,7 @@ public: CURSOR_SET = 0 }; CachedFrame() {} + void add(CachedInput& input) { mCachedTextInputs.append(input); } void add(CachedNode& node) { mCachedNodes.append(node); } void addFrame(CachedFrame& child) { mCachedFrames.append(child); } bool checkVisited(const CachedNode* , CachedFrame::Direction ) const; @@ -83,7 +85,7 @@ public: int* y, bool checkForHidden) const; const CachedFrame* findBestFrameAt(int x, int y) const; const CachedNode* findBestHitAt(const WebCore::IntRect& , - int* best, const CachedFrame** , int* x, int* y) const; + const CachedFrame** , int* x, int* y) const; void finishInit(); CachedFrame* firstChild() { return mCachedFrames.begin(); } const CachedFrame* firstChild() const { return mCachedFrames.begin(); } @@ -123,6 +125,10 @@ public: void setFocusIndex(int index) { mFocusIndex = index; } void setLocalViewBounds(const WebCore::IntRect& bounds) { mLocalViewBounds = bounds; } int size() { return mCachedNodes.size(); } + const CachedInput* textInput(const CachedNode* node) const { + return node->isTextInput() ? &mCachedTextInputs[node->textInputIndex()] + : 0; + } const CachedNode* validDocument() const; protected: struct BestData { @@ -206,6 +212,7 @@ protected: WebCore::IntRect mViewBounds; WTF::Vector<CachedNode> mCachedNodes; WTF::Vector<CachedFrame> mCachedFrames; + WTF::Vector<CachedInput> mCachedTextInputs; void* mFrame; // WebCore::Frame*, used only to compare pointers CachedFrame* mParent; int mCursorIndex; diff --git a/WebKit/android/nav/CachedHistory.cpp b/WebKit/android/nav/CachedHistory.cpp index 7aca1ad..47a560c 100644 --- a/WebKit/android/nav/CachedHistory.cpp +++ b/WebKit/android/nav/CachedHistory.cpp @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/nav/CachedHistory.h b/WebKit/android/nav/CachedHistory.h index 1ae62b9..302da4e 100644 --- a/WebKit/android/nav/CachedHistory.h +++ b/WebKit/android/nav/CachedHistory.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/nav/CachedInput.cpp b/WebKit/android/nav/CachedInput.cpp new file mode 100644 index 0000000..924bbca --- /dev/null +++ b/WebKit/android/nav/CachedInput.cpp @@ -0,0 +1,68 @@ +/* + * 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 "CachedPrefix.h" +#include "CachedInput.h" + +namespace android { + +#if DUMP_NAV_CACHE + +#define DEBUG_PRINT_BOOL(field) \ + DUMP_NAV_LOGD("// bool " #field "=%s;\n", b->field ? "true" : "false") + +CachedInput* CachedInput::Debug::base() const { + CachedInput* nav = (CachedInput*) ((char*) this - OFFSETOF(CachedInput, mDebug)); + return nav; +} + +static void printWebCoreString(const char* label, + const WebCore::String& string) { + char scratch[256]; + size_t index = snprintf(scratch, sizeof(scratch), label); + const UChar* ch = string.characters(); + while (ch && *ch && index < sizeof(scratch)) { + UChar c = *ch++; + if (c < ' ' || c >= 0x7f) c = ' '; + scratch[index++] = c; + } + DUMP_NAV_LOGD("%.*s\"\n", index, scratch); +} + +void CachedInput::Debug::print() const +{ + CachedInput* b = base(); + printWebCoreString("// char* mName=\"", b->mName); + DUMP_NAV_LOGD("// void* mForm=%p;", b->mForm); + DUMP_NAV_LOGD("// int mMaxLength=%d;\n", b->mMaxLength); + DUMP_NAV_LOGD("// int mTextSize=%d;\n", b->mTextSize); + DUMP_NAV_LOGD("// int mInputType=%d;\n", b->mInputType); + DEBUG_PRINT_BOOL(mIsRtlText); + DEBUG_PRINT_BOOL(mIsTextField); +} + +#endif + +} diff --git a/WebKit/android/nav/CachedInput.h b/WebKit/android/nav/CachedInput.h new file mode 100644 index 0000000..42cadf1 --- /dev/null +++ b/WebKit/android/nav/CachedInput.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 CachedInput_H +#define CachedInput_H + +#include "CachedDebug.h" +#include "HTMLInputElement.h" +#include "PlatformString.h" + +namespace android { + +class CachedInput { +public: + CachedInput() { + // Initiaized to 0 in its array, so nothing to do in the + // constructor + } + void* formPointer() const { return mForm; } + void init() { + bzero(this, sizeof(CachedInput)); + mName = WebCore::String(); + } + WebCore::HTMLInputElement::InputType inputType() const { return mInputType; } + bool isRtlText() const { return mIsRtlText; } + bool isTextField() const { return mIsTextField; } + int maxLength() const { return mMaxLength; }; + const WebCore::String& name() const { return mName; } + void setFormPointer(void* form) { mForm = form; } + void setInputType(WebCore::HTMLInputElement::InputType type) { mInputType = type; } + void setIsRtlText(bool isRtlText) { mIsRtlText = isRtlText; } + void setIsTextField(bool isTextField) { mIsTextField = isTextField; } + void setMaxLength(int maxLength) { mMaxLength = maxLength; } + void setName(const WebCore::String& name) { mName = name; } + void setTextSize(int textSize) { mTextSize = textSize; } + int textSize() const { return mTextSize; } +private: + void* mForm; + WebCore::String mName; + int mMaxLength; + int mTextSize; + WebCore::HTMLInputElement::InputType mInputType; + bool mIsRtlText : 1; + bool mIsTextField : 1; +#if DUMP_NAV_CACHE +public: + class Debug { +public: + CachedInput* base() const; + void print() const; + } mDebug; +#endif +}; + +} + +#endif diff --git a/WebKit/android/nav/CachedNode.cpp b/WebKit/android/nav/CachedNode.cpp index cab1f15..58ada58 100644 --- a/WebKit/android/nav/CachedNode.cpp +++ b/WebKit/android/nav/CachedNode.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -76,6 +76,16 @@ bool CachedNode::clip(const WebCore::IntRect& bounds) return Clip(bounds, &mBounds, &mCursorRing); } +void CachedNode::cursorRingBounds(WebCore::IntRect* bounds) const +{ + int partMax = mNavableRects; + ASSERT(partMax > 0); + *bounds = mCursorRing[0]; + for (int partIndex = 1; partIndex < partMax; partIndex++) + bounds->unite(mCursorRing[partIndex]); + bounds->inflate(CURSOR_RING_HIT_TEST_RADIUS); +} + #define OVERLAP 3 void CachedNode::fixUpCursorRects(const CachedRoot* root) @@ -194,17 +204,6 @@ tryAgain: } while (again); } - -void CachedNode::cursorRingBounds(WebCore::IntRect* bounds) const -{ - int partMax = mNavableRects; - ASSERT(partMax > 0); - *bounds = mCursorRing[0]; - for (int partIndex = 1; partIndex < partMax; partIndex++) - bounds->unite(mCursorRing[partIndex]); - bounds->inflate(CURSOR_RING_HIT_TEST_RADIUS); -} - void CachedNode::hideCursor(CachedFrame* parent) { if (isFrame()) { @@ -218,12 +217,17 @@ void CachedNode::init(WebCore::Node* node) { bzero(this, sizeof(CachedNode)); mExport = WebCore::String(); - mName = WebCore::String(); mNode = node; - mParentIndex = mChildFrameIndex = -1; + mParentIndex = mDataIndex = -1; mType = android::NORMAL_CACHEDNODETYPE; } +bool CachedNode::isTextField(const CachedFrame* frame) const +{ + const CachedInput* input = frame->textInput(this); + return input ? input->isTextField() : false; +} + void CachedNode::move(int x, int y) { mBounds.move(x, y); @@ -306,6 +310,11 @@ const char* CachedNode::Debug::type(android::CachedNodeType t) const case ADDRESS_CACHEDNODETYPE: return "ADDRESS"; break; case EMAIL_CACHEDNODETYPE: return "EMAIL"; break; case PHONE_CACHEDNODETYPE: return "PHONE"; break; + case ANCHOR_CACHEDNODETYPE: return "ANCHOR"; break; + case AREA_CACHEDNODETYPE: return "AREA"; break; + case FRAME_CACHEDNODETYPE: return "FRAME"; break; + case PLUGIN_CACHEDNODETYPE: return "PLUGIN"; break; + case TEXT_INPUT_CACHEDNODETYPE: return "INPUT"; break; default: return "???"; } } @@ -316,13 +325,11 @@ void CachedNode::Debug::print() const char scratch[256]; size_t index = snprintf(scratch, sizeof(scratch), "// char* mExport=\""); const UChar* ch = b->mExport.characters(); - while (ch && *ch && index < sizeof(scratch)) - scratch[index++] = *ch++; - DUMP_NAV_LOGD("%.*s\"\n", index, scratch); - index = snprintf(scratch, sizeof(scratch), "// char* mName=\""); - ch = b->mName.characters(); - while (ch && *ch && index < sizeof(scratch)) - scratch[index++] = *ch++; + while (ch && *ch && index < sizeof(scratch)) { + UChar c = *ch++; + if (c < ' ' || c >= 0x7f) c = ' '; + scratch[index++] = c; + } DUMP_NAV_LOGD("%.*s\"\n", index, scratch); DEBUG_PRINT_RECT(mBounds); DEBUG_PRINT_RECT(mHitBounds); @@ -335,12 +342,10 @@ void CachedNode::Debug::print() const DUMP_NAV_LOGD("// };\n"); DUMP_NAV_LOGD("// void* mNode=%p; // (%d) \n", b->mNode, mNodeIndex); DUMP_NAV_LOGD("// void* mParentGroup=%p; // (%d) \n", b->mParentGroup, mParentGroupIndex); - DUMP_NAV_LOGD("// int mChildFrameIndex=%d;\n", b->mChildFrameIndex); + DUMP_NAV_LOGD("// int mDataIndex=%d;\n", b->mDataIndex); DUMP_NAV_LOGD("// int mIndex=%d;\n", b->mIndex); - DUMP_NAV_LOGD("// int mMaxLength=%d;\n", b->mMaxLength); DUMP_NAV_LOGD("// int mNavableRects=%d;\n", b->mNavableRects); DUMP_NAV_LOGD("// int mParentIndex=%d;\n", b->mParentIndex); - DUMP_NAV_LOGD("// int mTextSize=%d;\n", b->mTextSize); DUMP_NAV_LOGD("// int mTabIndex=%d;\n", b->mTabIndex); DUMP_NAV_LOGD("// Condition mCondition=%s;\n", condition(b->mCondition)); DUMP_NAV_LOGD("// Type mType=%s;\n", type(b->mType)); @@ -349,22 +354,15 @@ void CachedNode::Debug::print() const DEBUG_PRINT_BOOL(mFixedUpCursorRects); DEBUG_PRINT_BOOL(mHasCursorRing); DEBUG_PRINT_BOOL(mHasMouseOver); - DEBUG_PRINT_BOOL(mIsAnchor); - DEBUG_PRINT_BOOL(mIsArea); DEBUG_PRINT_BOOL(mIsCursor); DEBUG_PRINT_BOOL(mIsFocus); DEBUG_PRINT_BOOL(mIsHidden); DEBUG_PRINT_BOOL(mIsParentAnchor); - DEBUG_PRINT_BOOL(mIsPassword); - DEBUG_PRINT_BOOL(mIsRtlText); - DEBUG_PRINT_BOOL(mIsTextArea); - DEBUG_PRINT_BOOL(mIsTextField); DEBUG_PRINT_BOOL(mIsTransparent); DEBUG_PRINT_BOOL(mIsUnclipped); DEBUG_PRINT_BOOL(mLast); DEBUG_PRINT_BOOL(mUseBounds); DEBUG_PRINT_BOOL(mUseHitBounds); - DEBUG_PRINT_BOOL(mWantsKeyEvents); DUMP_NAV_LOGD("\n"); } diff --git a/WebKit/android/nav/CachedNode.h b/WebKit/android/nav/CachedNode.h index 2efbaf7..a433a47 100644 --- a/WebKit/android/nav/CachedNode.h +++ b/WebKit/android/nav/CachedNode.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -62,6 +62,7 @@ public: IN_UMBRA, IN_WORKING, LEFTMOST, + NOT_ENCLOSING_CURSOR, OVERLAP_OR_EDGE_FURTHER, PREFERRED, // better overlap measure SECOND_CHANCE_END = PREFERRED, // must be last in list @@ -73,7 +74,6 @@ public: HIGHER_TAB_INDEX, IN_CURSOR, IN_CURSOR_CHILDREN, - NOT_ENCLOSING_CURSOR, NOT_CURSOR_NODE, OUTSIDE_OF_BEST, // containership OUTSIDE_OF_ORIGINAL, // containership @@ -86,7 +86,7 @@ public: const WebCore::IntRect& bounds() const { return mBounds; } WebCore::IntRect* boundsPtr() { return &mBounds; } - int childFrameIndex() const { return mChildFrameIndex; } + int childFrameIndex() const { return isFrame() ? mDataIndex : -1; } void clearCondition() const { mCondition = NOT_REJECTED; } void clearCursor(CachedFrame* ); static bool Clip(const WebCore::IntRect& outer, WebCore::IntRect* inner, @@ -94,131 +94,112 @@ public: bool clip(const WebCore::IntRect& ); bool clippedOut() { return mClippedOut; } void cursorRingBounds(WebCore::IntRect* ) const; + WTF::Vector<WebCore::IntRect>& cursorRings() { return mCursorRing; } + const WTF::Vector<WebCore::IntRect>& cursorRings() const { return mCursorRing; } bool disabled() const { return mDisabled; } const CachedNode* document() const { return &this[-mIndex]; } void fixUpCursorRects(const CachedRoot* root); - WTF::Vector<WebCore::IntRect>& cursorRings() { return mCursorRing; } - const WTF::Vector<WebCore::IntRect>& cursorRings() const { return mCursorRing; } const WebCore::IntRect& getBounds() const { return mBounds; } void getBounds(WebCore::IntRect* bounds) const { *bounds = mBounds; } const WebCore::String& getExport() const { return mExport; } - bool hasCursorRing() const { return !mIsHidden && mHasCursorRing; } + bool hasCursorRing() const { return mHasCursorRing; } bool hasMouseOver() const { return mHasMouseOver; } void hideCursor(CachedFrame* ); const WebCore::IntRect& hitBounds() const { return mHitBounds; } int index() const { return mIndex; } void init(WebCore::Node* node); - bool isAnchor() const { return mIsAnchor; } + bool isAnchor() const { return mType == ANCHOR_CACHEDNODETYPE; } bool isCursor() const { return mIsCursor; } - bool isArea() const { return mIsArea; } + bool isArea() const { return mType == AREA_CACHEDNODETYPE; } bool isFocus() const { return mIsFocus; } - bool isFrame() const { return mChildFrameIndex >= 0 ; } + bool isFrame() const { return mType == FRAME_CACHEDNODETYPE; } + bool isHidden() const { return mIsHidden; } bool isNavable(const WebCore::IntRect& clip) const { return clip.intersects(mBounds); } - bool isPassword() const { return mIsPassword; } - bool isPlugin() const { - return mWantsKeyEvents && !mIsTextArea && !mIsTextField; + bool isPlugin() const { return mType == PLUGIN_CACHEDNODETYPE; } + bool isSyntheticLink() const { + return mType >= ADDRESS_CACHEDNODETYPE && mType <= PHONE_CACHEDNODETYPE; } - bool isRtlText() const { return mIsRtlText; } - bool isTextArea() const { return mIsTextArea; } - bool isTextField() const { return mIsTextField; } + bool isTextField(const CachedFrame*) const; + bool isTextInput() const { return mType == TEXT_INPUT_CACHEDNODETYPE; } bool isTransparent() const { return mIsTransparent; } bool isUnclipped() const { return mIsUnclipped; } - int maxLength() const { return mMaxLength; }; void move(int x, int y); - const WebCore::String& name() const { return mName; } int navableRects() const { return mNavableRects; } void* nodePointer() const { return mNode; } bool noSecondChance() const { return mCondition > SECOND_CHANCE_END; } + const WebCore::IntRect& originalAbsoluteBounds() const { + return mOriginalAbsoluteBounds; } const CachedNode* parent() const { return document() + mParentIndex; } void* parentGroup() const { return mParentGroup; } int parentIndex() const { return mParentIndex; } bool partRectsContains(const CachedNode* other) const; void reset(); void setBounds(const WebCore::IntRect& bounds) { mBounds = bounds; } - void setChildFrameIndex(int index) { mChildFrameIndex = index; } void setClippedOut(bool clipped) { mClippedOut = clipped; } void setCondition(Condition condition) const { mCondition = condition; } + void setDataIndex(int index) { mDataIndex = index; } void setDisabled(bool disabled) { mDisabled = disabled; } void setExport(const WebCore::String& exported) { mExport = exported; } void setHasCursorRing(bool hasRing) { mHasCursorRing = hasRing; } void setHasMouseOver(bool hasMouseOver) { mHasMouseOver = hasMouseOver; } void setHitBounds(const WebCore::IntRect& bounds) { mHitBounds = bounds; } + void setOriginalAbsoluteBounds(const WebCore::IntRect& bounds) { + mOriginalAbsoluteBounds = bounds; } void setIndex(int index) { mIndex = index; } - void setIsAnchor(bool isAnchor) { mIsAnchor = isAnchor; } - void setIsArea(bool isArea) { mIsArea = isArea; } void setIsCursor(bool isCursor) { mIsCursor = isCursor; } void setIsFocus(bool isFocus) { mIsFocus = isFocus; } void setIsParentAnchor(bool isAnchor) { mIsParentAnchor = isAnchor; } - void setIsPassword(bool isPassword) { mIsPassword = isPassword; } - void setIsRtlText(bool isRtlText) { mIsRtlText = isRtlText; } - void setIsTextArea(bool isTextArea) { mIsTextArea = isTextArea; } - void setIsTextField(bool isTextField) { mIsTextField = isTextField; } void setIsTransparent(bool isTransparent) { mIsTransparent = isTransparent; } void setIsUnclipped(bool unclipped) { mIsUnclipped = unclipped; } void setLast() { mLast = true; } - void setMaxLength(int maxLength) { mMaxLength = maxLength; } - void setName(const WebCore::String& name) { mName = name; } void setNavableRects() { mNavableRects = mCursorRing.size(); } void setParentGroup(void* group) { mParentGroup = group; } void setParentIndex(int parent) { mParentIndex = parent; } void setTabIndex(int index) { mTabIndex = index; } - void setTextSize(int textSize) { mTextSize = textSize; } void setType(CachedNodeType type) { mType = type; } - void setWantsKeyEvents(bool wantsKeys) { mWantsKeyEvents = wantsKeys; } void show() { mIsHidden = false; } int tabIndex() const { return mTabIndex; } + int textInputIndex() const { return isTextInput() ? mDataIndex : -1; } const CachedNode* traverseNextNode() const { return mLast ? NULL : &this[1]; } - int textSize() const { return mTextSize; } - CachedNodeType type() const { return mType; } bool useBounds() const { return mUseBounds; } bool useHitBounds() const { return mUseHitBounds; } - bool wantsKeyEvents() const { return mWantsKeyEvents; } + bool wantsKeyEvents() const { return isTextInput() || isPlugin(); } private: WebCore::String mExport; - WebCore::String mName; WebCore::IntRect mBounds; WebCore::IntRect mHitBounds; + WebCore::IntRect mOriginalAbsoluteBounds; WTF::Vector<WebCore::IntRect> mCursorRing; void* mNode; // WebCore::Node*, only used to match pointers void* mParentGroup; // WebCore::Node*, only used to match pointers - int mChildFrameIndex; // set to -1 if node is not a frame + int mDataIndex; // child frame if a frame; input data index; or -1 int mIndex; // index of itself, to find first in array (document) - int mMaxLength; int mNavableRects; // FIXME: could be bitfield once I limit max number of rects int mParentIndex; - int mTextSize; int mTabIndex; mutable Condition mCondition : 5; // why the node was not chosen on the first pass - CachedNodeType mType : 3; + CachedNodeType mType : 4; bool mClippedOut : 1; bool mDisabled : 1; bool mFixedUpCursorRects : 1; bool mHasCursorRing : 1; bool mHasMouseOver : 1; - bool mIsAnchor : 1; - bool mIsArea : 1; bool mIsCursor : 1; bool mIsFocus : 1; bool mIsHidden : 1; bool mIsParentAnchor : 1; - bool mIsPassword : 1; - bool mIsRtlText : 1; - bool mIsTextArea : 1; - bool mIsTextField : 1; bool mIsTransparent : 1; bool mIsUnclipped : 1; bool mLast : 1; // true if this is the last node in a group bool mUseBounds : 1; bool mUseHitBounds : 1; - bool mWantsKeyEvents : 1; // true for nodes like plugins #ifdef BROWSER_DEBUG public: WebCore::Node* webCoreNode() const { return (WebCore::Node*) mNode; } bool mDisplayMeasure; mutable bool mInCompare; - // mutable int mCondition; int mSideDistance; int mSecondSide; #endif diff --git a/WebKit/android/nav/CachedNodeType.h b/WebKit/android/nav/CachedNodeType.h index 07346ac..21e2d40 100644 --- a/WebKit/android/nav/CachedNodeType.h +++ b/WebKit/android/nav/CachedNodeType.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -29,11 +29,24 @@ namespace android { enum CachedNodeType { - NORMAL_CACHEDNODETYPE = 0, - ADDRESS_CACHEDNODETYPE = 1, - EMAIL_CACHEDNODETYPE = 2, - PHONE_CACHEDNODETYPE = 4, - ALL_CACHEDNODETYPES = 7 + NORMAL_CACHEDNODETYPE, + ADDRESS_CACHEDNODETYPE, + EMAIL_CACHEDNODETYPE, + PHONE_CACHEDNODETYPE, + ANCHOR_CACHEDNODETYPE, + AREA_CACHEDNODETYPE, + FRAME_CACHEDNODETYPE, + PLUGIN_CACHEDNODETYPE, + TEXT_INPUT_CACHEDNODETYPE +}; + +enum CachedNodeBits { + NORMAL_CACHEDNODE_BITS = 0, + ADDRESS_CACHEDNODE_BIT = 1 << (ADDRESS_CACHEDNODETYPE - 1), + EMAIL_CACHEDNODE_BIT = 1 << (EMAIL_CACHEDNODETYPE - 1), + PHONE_CACHEDNODE_BIT = 1 << (PHONE_CACHEDNODETYPE - 1), + ALL_CACHEDNODE_BITS = ADDRESS_CACHEDNODE_BIT | EMAIL_CACHEDNODE_BIT + | PHONE_CACHEDNODE_BIT }; } diff --git a/WebKit/android/nav/CachedPrefix.h b/WebKit/android/nav/CachedPrefix.h index b466771..b682288 100644 --- a/WebKit/android/nav/CachedPrefix.h +++ b/WebKit/android/nav/CachedPrefix.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/nav/CachedRoot.cpp b/WebKit/android/nav/CachedRoot.cpp index 38417b1..d9669bd 100644 --- a/WebKit/android/nav/CachedRoot.cpp +++ b/WebKit/android/nav/CachedRoot.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -26,6 +26,7 @@ #include "CachedPrefix.h" #include "android_graphics.h" #include "CachedHistory.h" +#include "CachedInput.h" #include "CachedNode.h" #include "SkBitmap.h" #include "SkBounder.h" @@ -755,14 +756,17 @@ bool CachedRoot::checkRings(const WTF::Vector<WebCore::IntRect>& rings, return ringCheck.success(); } -CachedRoot::ImeAction CachedRoot::cursorTextFieldAction() const +CachedRoot::ImeAction CachedRoot::currentTextFieldAction() const { - const CachedFrame* cursorFrame; - const CachedNode* cursor = currentCursor(&cursorFrame); - if (!cursor) { - // Error case. The cursor has no action, because there is no node under - // the cursor - return FAILURE; + const CachedFrame* currentFrame; + const CachedNode* current = currentCursor(¤tFrame); + if (!current || !current->isTextInput()) { + // Although the cursor is not on a textfield, a textfield may have + // focus. Find the action for that textfield. + current = currentFocus(¤tFrame); + if (!current || !current->isTextInput()) + // Error case. No cursor and no focus. + return FAILURE; } const CachedNode* firstTextfield = nextTextField(0, 0, false); if (!firstTextfield) { @@ -770,9 +774,13 @@ CachedRoot::ImeAction CachedRoot::cursorTextFieldAction() const return FAILURE; } // Now find the next textfield/area starting with the cursor - if (cursorFrame->nextTextField(cursor, 0, true)) { - // There is a textfield/area after the cursor, so the textfield under - // the cursor should have the NEXT action + const CachedFrame* potentialFrame; + const CachedNode* potentialNext + = currentFrame->nextTextField(current, &potentialFrame, true); + if (potentialNext && currentFrame->textInput(current)->formPointer() + == potentialFrame->textInput(potentialNext)->formPointer()) { + // There is a textfield/area after the cursor in the same form, + // so the textfield under the cursor should have the NEXT action return NEXT; } // If this line is reached, we know that the textfield under the cursor is @@ -792,7 +800,7 @@ const CachedNode* CachedRoot::findAt(const WebCore::IntRect& rect, DBG_NAV_LOGD("node=%d (%p)", node == NULL ? 0 : node->index(), node == NULL ? NULL : node->nodePointer()); if (node == NULL) { - node = findBestHitAt(rect, &best, framePtr, x, y); + node = findBestHitAt(rect, framePtr, x, y); DBG_NAV_LOGD("node=%d (%p)", node == NULL ? 0 : node->index(), node == NULL ? NULL : node->nodePointer()); } @@ -844,9 +852,9 @@ int CachedRoot::getBlockLeftEdge(int x, int y, float scale) const const CachedFrame* frame; int fx, fy; const CachedNode* node = findAt(rect, &frame, &fx, &fy, true); - if (node && (node->isTextArea() || node->isTextField() || node->isPlugin())) { + if (node && node->wantsKeyEvents()) { DBG_NAV_LOGD("x=%d (%s)", node->bounds().x(), - node->isTextArea() || node->isTextField() ? "text" : "plugin"); + node->isTextInput() ? "text" : "plugin"); return node->bounds().x(); } int halfW = (int) (mViewBounds.width() * scale * 0.5f); diff --git a/WebKit/android/nav/CachedRoot.h b/WebKit/android/nav/CachedRoot.h index 123e7d2..5fdf8df 100644 --- a/WebKit/android/nav/CachedRoot.h +++ b/WebKit/android/nav/CachedRoot.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -52,11 +52,12 @@ public: void checkForJiggle(int* ) const; bool checkRings(const WTF::Vector<WebCore::IntRect>& rings, const WebCore::IntRect& bounds) const; - WebCore::IntPoint cursorLocation() const; // This method returns the desired ImeAction for the textfield where the - // mouse cursor currently is. If the mouse cursor is not on a textfield, + // mouse cursor currently is, or where the focus is if there is no mouse + // cursor. If the mouse cursor is not on a textfield, // it will return FAILURE - ImeAction cursorTextFieldAction() const; + ImeAction currentTextFieldAction() const; + WebCore::IntPoint cursorLocation() const; int documentHeight() { return mContents.height(); } int documentWidth() { return mContents.width(); } const CachedNode* findAt(const WebCore::IntRect& , const CachedFrame** , diff --git a/WebKit/android/nav/FindCanvas.cpp b/WebKit/android/nav/FindCanvas.cpp index 24b0129..1465b91 100644 --- a/WebKit/android/nav/FindCanvas.cpp +++ b/WebKit/android/nav/FindCanvas.cpp @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/nav/FindCanvas.h b/WebKit/android/nav/FindCanvas.h index 5d79b4c..d357a2a 100644 --- a/WebKit/android/nav/FindCanvas.h +++ b/WebKit/android/nav/FindCanvas.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -204,4 +204,3 @@ private: }; #endif // Find_Canvas_h - diff --git a/WebKit/android/nav/SelectText.cpp b/WebKit/android/nav/SelectText.cpp index 7bdbf14..d8b184a 100644 --- a/WebKit/android/nav/SelectText.cpp +++ b/WebKit/android/nav/SelectText.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -22,6 +22,7 @@ * (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 "webcoreglue" #include "CachedPrefix.h" @@ -34,14 +35,17 @@ #include "SkPoint.h" #include "SkRect.h" #include "SkRegion.h" +#include "SkUtils.h" class CommonCheck : public SkBounder { public: CommonCheck() : mMatrix(NULL), mPaint(NULL) {} - virtual void setUp(const SkPaint& paint, const SkMatrix& matrix, SkScalar y) { + virtual void setUp(const SkPaint& paint, const SkMatrix& matrix, SkScalar y, + const void* text) { mMatrix = &matrix; mPaint = &paint; + mText = static_cast<const uint16_t*>(text); mY = y; mBase = mBottom = mTop = INT_MAX; } @@ -80,10 +84,11 @@ public: protected: const SkMatrix* mMatrix; const SkPaint* mPaint; + const uint16_t* mText; + SkScalar mY; int mBase; int mBottom; int mTop; - SkScalar mY; }; class FirstCheck : public CommonCheck { @@ -161,6 +166,8 @@ public: full.fRight = mLast.fLeft; } mSelectRegion->op(full, SkRegion::kUnion_Op); + DBG_NAV_LOGD("MultilineBuilder full=(%d,%d,r=%d,b=%d)", + full.fLeft, full.fTop, full.fRight, full.fBottom); mLast = full; mLastBase = base(); if (mStart == mEnd) @@ -177,6 +184,66 @@ protected: bool mCapture; }; +class TextExtractor : public CommonCheck { +public: + TextExtractor(const SkRegion& region) : mSelectRegion(region), + mSkipFirstSpace(true) { // don't start with a space + } + + virtual void setUp(const SkPaint& paint, const SkMatrix& matrix, SkScalar y, + const void* text) { + INHERITED::setUp(paint, matrix, y, text); + SkPaint charPaint = paint; + charPaint.setTextEncoding(SkPaint::kUTF8_TextEncoding); + mMinSpaceWidth = charPaint.measureText(" ", 1) * 3 / 4; + } + + virtual bool onIRect(const SkIRect& rect, uint16_t glyphID) { + SkIRect full; + full.set(rect.fLeft, top(), rect.fRight, bottom()); + if (mSelectRegion.contains(full)) { + if (!mSkipFirstSpace + && ((mLast.fTop < top() && mLast.fBottom < top() + 2) + || (mLast.fLeft < rect.fLeft // glyphs are LTR + && mLast.fRight + mMinSpaceWidth < rect.fLeft))) { + DBG_NAV_LOGD("TextExtractor [%02x] append space", glyphID); + *mSelectText.append() = ' '; + } else + mSkipFirstSpace = false; + DBG_NAV_LOGD("TextExtractor [%02x] append full=(%d,%d,r=%d,b=%d)", + glyphID, full.fLeft, full.fTop, full.fRight, full.fBottom); + SkUnichar uni; + SkPaint utfPaint = *mPaint; + utfPaint.setTextEncoding(SkPaint::kUTF16_TextEncoding); + utfPaint.glyphsToUnichars(&glyphID, 1, &uni); + if (uni) { + uint16_t chars[2]; + size_t count = SkUTF16_FromUnichar(uni, chars); + *mSelectText.append() = chars[0]; + if (count == 2) + *mSelectText.append() = chars[1]; + } + mLast = full; + } else + DBG_NAV_LOGD("TextExtractor [%02x] skip full=(%d,%d,r=%d,b=%d)", + glyphID, full.fLeft, full.fTop, full.fRight, full.fBottom); + return false; + } + + WebCore::String text() { + return WebCore::String(mSelectText.begin(), mSelectText.count()); + } + +protected: + const SkRegion& mSelectRegion; + SkTDArray<uint16_t> mSelectText; + SkIRect mLast; + SkScalar mMinSpaceWidth; + bool mSkipFirstSpace; +private: + typedef CommonCheck INHERITED; +}; + class TextCanvas : public SkCanvas { public: @@ -217,14 +284,14 @@ public: virtual void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint) { - mBounder.setUp(paint, getTotalMatrix(), y); + mBounder.setUp(paint, getTotalMatrix(), y, text); SkCanvas::drawText(text, byteLength, x, y, paint); } virtual void drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkPaint& paint) { - mBounder.setUp(paint, getTotalMatrix(), constY); + mBounder.setUp(paint, getTotalMatrix(), constY, text); SkCanvas::drawPosTextH(text, byteLength, xpos, constY, paint); } @@ -261,3 +328,17 @@ SkIRect CopyPaste::findClosest(const SkPicture& picture, const SkIRect& area, _check.offsetBounds(area.fLeft, area.fTop); return _check.bestBounds(); } + +WebCore::String CopyPaste::text(const SkPicture& picture, const SkIRect& area, + const SkRegion& region) { + SkRegion copy = region; + copy.translate(-area.fLeft, -area.fTop); + const SkIRect& bounds = copy.getBounds(); + DBG_NAV_LOGD("area=(%d, %d, %d, %d) region=(%d, %d, %d, %d)", + area.fLeft, area.fTop, area.fRight, area.fBottom, + bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom); + TextExtractor extractor(copy); + TextCanvas checker(&extractor, picture, area); + checker.drawPicture(const_cast<SkPicture&>(picture)); + return extractor.text(); +} diff --git a/WebKit/android/nav/SelectText.h b/WebKit/android/nav/SelectText.h index b991198..32d8311 100644 --- a/WebKit/android/nav/SelectText.h +++ b/WebKit/android/nav/SelectText.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -26,6 +26,8 @@ #ifndef SELECT_TEXT_H #define SELECT_TEXT_H +#include "PlatformString.h" + class SkPicture; struct SkIRect; struct SkIPoint; @@ -37,6 +39,8 @@ public: const SkIRect& selStart, const SkIRect& selEnd, SkRegion* region); static SkIRect findClosest(const SkPicture& , const SkIRect& area, int x, int y); + static WebCore::String text(const SkPicture& , const SkIRect& area, + const SkRegion& ); }; #endif diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 6f01fec..8931d72 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -28,16 +28,20 @@ #include <config.h> #include "android_graphics.h" +#include "AndroidAnimation.h" #include "AndroidLog.h" #include "AtomicString.h" #include "CachedFrame.h" #include "CachedNode.h" #include "CachedRoot.h" +#include "CString.h" #include "FindCanvas.h" #include "Frame.h" #include "GraphicsJNI.h" +#include "HTMLInputElement.h" #include "IntPoint.h" #include "IntRect.h" +#include "LayerAndroid.h" #include "Node.h" #include "PlatformGraphicsContext.h" #include "PlatformString.h" @@ -95,19 +99,19 @@ enum FrameCachePermission { }; struct JavaGlue { - jobject m_obj; + jweak m_obj; jmethodID m_clearTextEntry; jmethodID m_overrideLoading; - jmethodID m_sendPluginState; jmethodID m_scrollBy; + jmethodID m_sendMoveFocus; jmethodID m_sendMoveMouse; jmethodID m_sendMoveMouseIfLatest; jmethodID m_sendMotionUp; + jmethodID m_domChangedFocus; jmethodID m_getScaledMaxXScroll; jmethodID m_getScaledMaxYScroll; jmethodID m_getVisibleRect; jmethodID m_rebuildWebTextView; - jmethodID m_displaySoftKeyboard; jmethodID m_viewInvalidate; jmethodID m_viewInvalidateRect; jmethodID m_postInvalidateDelayed; @@ -124,19 +128,19 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) { jclass clazz = env->FindClass("android/webkit/WebView"); // m_javaGlue = new JavaGlue; - m_javaGlue.m_obj = adoptGlobalRef(env, javaWebView); + m_javaGlue.m_obj = env->NewWeakGlobalRef(javaWebView); m_javaGlue.m_scrollBy = GetJMethod(env, clazz, "setContentScrollBy", "(IIZ)Z"); m_javaGlue.m_clearTextEntry = GetJMethod(env, clazz, "clearTextEntry", "()V"); m_javaGlue.m_overrideLoading = GetJMethod(env, clazz, "overrideLoading", "(Ljava/lang/String;)V"); - m_javaGlue.m_sendPluginState = GetJMethod(env, clazz, "sendPluginState", "(I)V"); + m_javaGlue.m_sendMoveFocus = GetJMethod(env, clazz, "sendMoveFocus", "(II)V"); m_javaGlue.m_sendMoveMouse = GetJMethod(env, clazz, "sendMoveMouse", "(IIII)V"); m_javaGlue.m_sendMoveMouseIfLatest = GetJMethod(env, clazz, "sendMoveMouseIfLatest", "(Z)V"); m_javaGlue.m_sendMotionUp = GetJMethod(env, clazz, "sendMotionUp", "(IIIII)V"); + m_javaGlue.m_domChangedFocus = GetJMethod(env, clazz, "domChangedFocus", "()V"); m_javaGlue.m_getScaledMaxXScroll = GetJMethod(env, clazz, "getScaledMaxXScroll", "()I"); m_javaGlue.m_getScaledMaxYScroll = GetJMethod(env, clazz, "getScaledMaxYScroll", "()I"); m_javaGlue.m_getVisibleRect = GetJMethod(env, clazz, "sendOurVisibleRect", "()Landroid/graphics/Rect;"); m_javaGlue.m_rebuildWebTextView = GetJMethod(env, clazz, "rebuildWebTextView", "()V"); - m_javaGlue.m_displaySoftKeyboard = GetJMethod(env, clazz, "displaySoftKeyboard", "(Z)V"); m_javaGlue.m_viewInvalidate = GetJMethod(env, clazz, "viewInvalidate", "()V"); m_javaGlue.m_viewInvalidateRect = GetJMethod(env, clazz, "viewInvalidate", "(IIII)V"); m_javaGlue.m_postInvalidateDelayed = GetJMethod(env, clazz, @@ -163,10 +167,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) m_matches = 0; m_hasCurrentLocation = false; m_isFindPaintSetUp = false; - m_pluginReceivesEvents = false; // initialization is the only time this - // variable should be set directly, all - // other changes should be made through - // setPluginReceivesEvents(bool) } ~WebView() @@ -174,7 +174,7 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) if (m_javaGlue.m_obj) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->DeleteGlobalRef(m_javaGlue.m_obj); + env->DeleteWeakGlobalRef(m_javaGlue.m_obj); m_javaGlue.m_obj = 0; } delete m_frameCacheUI; @@ -215,12 +215,7 @@ void clearTextEntry() { DEBUG_NAV_UI_LOGD("%s", __FUNCTION__); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue.m_clearTextEntry); + env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_clearTextEntry); checkException(env); } @@ -419,7 +414,6 @@ void drawMatches(SkCanvas* canvas) void resetCursorRing() { m_followedLink = false; - setPluginReceivesEvents(false); m_viewImpl->m_hasCursorBounds = false; } @@ -434,12 +428,12 @@ void drawCursorRing(SkCanvas* canvas) const CachedFrame* frame; const CachedNode* node = root->currentCursor(&frame); if (!node) { - DBG_NAV_LOG("!node"); + DBG_NAV_LOGV("%s", "!node"); resetCursorRing(); return; } - if (!node->hasCursorRing()) { - DBG_NAV_LOG("!node->hasCursorRing()"); + if (node->isHidden()) { + DBG_NAV_LOG("node->isHidden()"); m_viewImpl->m_hasCursorBounds = false; return; } @@ -484,16 +478,14 @@ void drawCursorRing(SkCanvas* canvas) " bounds=(%d,%d,w=%d,h=%d)", node->index(), node->nodePointer(), bounds.x(), bounds.y(), bounds.width(), bounds.height()); m_followedLink = false; - setPluginReceivesEvents(false); return; } + if (!node->hasCursorRing() || (node->isPlugin() && node->isFocus())) + return; CursorRing::Flavor flavor = CursorRing::NORMAL_FLAVOR; if (!isButton) { - flavor = node->type() != NORMAL_CACHEDNODETYPE ? - CursorRing::FAKE_FLAVOR : CursorRing::NORMAL_FLAVOR; - if (m_pluginReceivesEvents && node->isPlugin()) { - return; - } + flavor = node->isSyntheticLink() + ? CursorRing::FAKE_FLAVOR : CursorRing::NORMAL_FLAVOR; if (m_followedLink) { flavor = static_cast<CursorRing::Flavor> (flavor + CursorRing::NORMAL_ANIMATING); @@ -501,13 +493,12 @@ void drawCursorRing(SkCanvas* canvas) #if DEBUG_NAV_UI const WebCore::IntRect& ring = (*rings)[0]; DBG_NAV_LOGD("cursorNode=%d (nodePointer=%p) flavor=%s rings=%d" - " (%d, %d, %d, %d) pluginReceivesEvents=%s isPlugin=%s", + " (%d, %d, %d, %d) isPlugin=%s", node->index(), node->nodePointer(), flavor == CursorRing::FAKE_FLAVOR ? "FAKE_FLAVOR" : flavor == CursorRing::NORMAL_ANIMATING ? "NORMAL_ANIMATING" : flavor == CursorRing::FAKE_ANIMATING ? "FAKE_ANIMATING" : "NORMAL_FLAVOR", rings->size(), ring.x(), ring.y(), ring.width(), ring.height(), - m_pluginReceivesEvents ? "true" : "false", node->isPlugin() ? "true" : "false"); #endif } @@ -541,9 +532,8 @@ bool cursorIsTextInput(FrameCachePermission allowNewer) DBG_NAV_LOG("!cursor"); return false; } - DBG_NAV_LOGD("%s", - cursor->isTextArea() || cursor->isTextField() ? "true" : "false"); - return cursor->isTextArea() || cursor->isTextField(); + DBG_NAV_LOGD("%s", cursor->isTextInput() ? "true" : "false"); + return cursor->isTextInput(); } void cursorRingBounds(WebCore::IntRect* bounds) @@ -609,7 +599,7 @@ void fixCursor() CachedRoot* getFrameCache(FrameCachePermission allowNewer) { if (!m_viewImpl->m_updatedFrameCache) { - DBG_NAV_LOG("!m_viewImpl->m_updatedFrameCache"); + DBG_NAV_LOGV("%s", "!m_viewImpl->m_updatedFrameCache"); return m_frameCacheUI; } if (allowNewer == DontAllowNewer && m_viewImpl->m_lastGeneration < m_generation) { @@ -619,6 +609,7 @@ CachedRoot* getFrameCache(FrameCachePermission allowNewer) } DBG_NAV_LOGD("%s", "m_viewImpl->m_updatedFrameCache == true"); bool hadCursor = m_frameCacheUI && m_frameCacheUI->currentCursor(); + const CachedNode* oldFocus = m_frameCacheUI ? m_frameCacheUI->currentFocus() : 0; m_viewImpl->gFrameCacheMutex.lock(); delete m_frameCacheUI; delete m_navPictureUI; @@ -629,6 +620,19 @@ CachedRoot* getFrameCache(FrameCachePermission allowNewer) m_viewImpl->m_navPictureKit = 0; m_viewImpl->gFrameCacheMutex.unlock(); fixCursor(); + if (oldFocus && m_frameCacheUI) { + const CachedNode* newFocus = m_frameCacheUI->currentFocus(); + if (newFocus && oldFocus->nodePointer() != newFocus->nodePointer() + && oldFocus->isTextInput() && newFocus->isTextInput() + && newFocus != m_frameCacheUI->currentCursor()) { + // The focus has changed. We may need to update things. + LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue.object(env).get(), + m_javaGlue.m_domChangedFocus); + checkException(env); + } + } if (hadCursor && (!m_frameCacheUI || !m_frameCacheUI->currentCursor())) viewInvalidate(); // redraw in case cursor ring is still visible return m_frameCacheUI; @@ -638,12 +642,7 @@ int getScaledMaxXScroll() { LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return 0; - int result = env->CallIntMethod(obj.get(), m_javaGlue.m_getScaledMaxXScroll); + int result = env->CallIntMethod(m_javaGlue.object(env).get(), m_javaGlue.m_getScaledMaxXScroll); checkException(env); return result; } @@ -652,12 +651,7 @@ int getScaledMaxYScroll() { LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return 0; - int result = env->CallIntMethod(obj.get(), m_javaGlue.m_getScaledMaxYScroll); + int result = env->CallIntMethod(m_javaGlue.object(env).get(), m_javaGlue.m_getScaledMaxYScroll); checkException(env); return result; } @@ -666,12 +660,7 @@ void getVisibleRect(WebCore::IntRect* rect) { LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return; - jobject jRect = env->CallObjectMethod(obj.get(), m_javaGlue.m_getVisibleRect); + jobject jRect = env->CallObjectMethod(m_javaGlue.object(env).get(), m_javaGlue.m_getVisibleRect); checkException(env); int left = (int) env->GetIntField(jRect, m_javaGlue.m_rectLeft); checkException(env); @@ -738,7 +727,7 @@ void updateCursorBounds(const CachedRoot* root, const CachedFrame* cachedFrame, LOG_ASSERT(cachedNode, "updateCursorBounds: cachedNode cannot be null"); LOG_ASSERT(cachedFrame, "updateCursorBounds: cachedFrame cannot be null"); m_viewImpl->gCursorBoundsMutex.lock(); - m_viewImpl->m_hasCursorBounds = cachedNode->hasCursorRing(); + m_viewImpl->m_hasCursorBounds = !cachedNode->isHidden(); // If m_viewImpl->m_hasCursorBounds is false, we never look at the other // values, so do not bother setting them. if (m_viewImpl->m_hasCursorBounds) { @@ -758,7 +747,6 @@ void updateCursorBounds(const CachedRoot* root, const CachedFrame* cachedFrame, /* returns true if the key had no effect (neither scrolled nor changed cursor) */ bool moveCursor(int keyCode, int count, bool ignoreScroll) { - setPluginReceivesEvents(false); CachedRoot* root = getFrameCache(AllowNewer); if (!root) { DBG_NAV_LOG("!root"); @@ -843,21 +831,6 @@ bool moveCursor(int keyCode, int count, bool ignoreScroll) return result; } -bool pluginEatsNavKey() -{ - CachedRoot* root = getFrameCache(DontAllowNewer); - if (!root) { - DBG_NAV_LOG("!root"); - return false; - } - const CachedNode* cursor = root->currentCursor(); - DBG_NAV_LOGD("cursor=%p isPlugin=%s pluginReceivesEvents=%s", - cursor, cursor && cursor->isPlugin() ? "true" : "false", - m_pluginReceivesEvents ? "true" : "false"); - // FIXME: check to see if plugin wants keys - return cursor && cursor->isPlugin() && m_pluginReceivesEvents; -} - void notifyProgressFinished() { DBG_NAV_LOGD("cursorIsTextInput=%d", cursorIsTextInput(DontAllowNewer)); @@ -929,36 +902,31 @@ void setNavBounds(const WebCore::IntRect& rect) root->rootHistory()->setNavBounds(rect); } -/** - * This function is only to be called by WebTextView, when there is a motion up - * on an already focused text input. Unlike motionUp which may change our - * cursor, it simply passes the click, so it can change the selection. - * Variables are in content space, relative to the page. - */ -void textInputMotionUp(int x, int y) + + +const CachedNode* m_cacheHitNode; +const CachedFrame* m_cacheHitFrame; + +bool pointInNavCache(int x, int y, int slop) { - const CachedRoot* root = getFrameCache(DontAllowNewer); - if (!root) { - return; - } - const CachedFrame* frame; - const CachedNode* node = root->currentCursor(&frame); - if (node) { - sendMotionUp(static_cast<WebCore::Frame*>(frame->framePointer()), - static_cast<WebCore::Node*>(node->nodePointer()), x, y); - } + CachedRoot* root = getFrameCache(AllowNewer); + if (!root) + return false; + IntRect rect = IntRect(x - slop, y - slop, slop * 2, slop * 2); + int rx, ry; + return (m_cacheHitNode = findAt(root, rect, &m_cacheHitFrame, &rx, &ry)); } bool motionUp(int x, int y, int slop) { bool pageScrolled = false; m_followedLink = false; - const CachedFrame* frame; - WebCore::IntRect rect = WebCore::IntRect(x - slop, y - slop, slop * 2, slop * 2); + IntRect rect = IntRect(x - slop, y - slop, slop * 2, slop * 2); int rx, ry; CachedRoot* root = getFrameCache(AllowNewer); if (!root) - return false; + return 0; + const CachedFrame* frame = 0; const CachedNode* result = findAt(root, rect, &frame, &rx, &ry); if (!result) { DBG_NAV_LOGD("no nodes found root=%p", root); @@ -974,30 +942,27 @@ bool motionUp(int x, int y, int slop) 0, x, y); viewInvalidate(); clearTextEntry(); - setPluginReceivesEvents(false); return pageScrolled; } DBG_NAV_LOGD("CachedNode:%p (%d) x=%d y=%d rx=%d ry=%d", result, result->index(), x, y, rx, ry); - setNavBounds(WebCore::IntRect(rx, ry, 1, 1)); + WebCore::IntRect navBounds = WebCore::IntRect(rx, ry, 1, 1); + setNavBounds(navBounds); + root->rootHistory()->setMouseBounds(navBounds); updateCursorBounds(root, frame, result); root->setCursor(const_cast<CachedFrame*>(frame), const_cast<CachedNode*>(result)); - updatePluginReceivesEvents(); - CachedNodeType type = result->type(); - if (type == NORMAL_CACHEDNODETYPE) { + bool syntheticLink = result->isSyntheticLink(); + if (!syntheticLink) { sendMotionUp( - frame ? (WebCore::Frame*) frame->framePointer() : 0, - result ? (WebCore::Node*) result->nodePointer() : 0, rx, ry); + (WebCore::Frame*) frame->framePointer(), + (WebCore::Node*) result->nodePointer(), rx, ry); } viewInvalidate(); - if (result->isTextField() || result->isTextArea()) { - rebuildWebTextView(); - displaySoftKeyboard(true); - } else { + if (!result->isTextInput()) { clearTextEntry(); setFollowedLink(true); - if (type != NORMAL_CACHEDNODETYPE) + if (syntheticLink) overrideUrlLoading(result->getExport()); } return pageScrolled; @@ -1014,13 +979,9 @@ int getBlockLeftEdge(int x, int y, float scale) void overrideUrlLoading(const WebCore::String& url) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return; jstring jName = env->NewString((jchar*) url.characters(), url.length()); - env->CallVoidMethod(obj.get(), m_javaGlue.m_overrideLoading, jName); + env->CallVoidMethod(m_javaGlue.object(env).get(), + m_javaGlue.m_overrideLoading, jName); env->DeleteLocalRef(jName); } @@ -1031,35 +992,6 @@ void setFindIsUp(bool up) m_hasCurrentLocation = false; } -void setPluginReceivesEvents(bool value) -{ - if (value == m_pluginReceivesEvents) - return; - - //send message to plugin in webkit - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue.m_sendPluginState, - value ? kGainFocus_PluginState : kLoseFocus_PluginState); - checkException(env); - m_pluginReceivesEvents = value; -} - -void updatePluginReceivesEvents() -{ - CachedRoot* root = getFrameCache(DontAllowNewer); - if (!root) - return; - const CachedNode* cursor = root->currentCursor(); - setPluginReceivesEvents(cursor && cursor->isPlugin()); - DBG_NAV_LOGD("m_pluginReceivesEvents=%s cursor=%p", m_pluginReceivesEvents - ? "true" : "false", cursor); -} - void setFollowedLink(bool followed) { if ((m_followedLink = followed) != false) { @@ -1096,20 +1028,15 @@ void moveSelection(int x, int y, bool extendSelection) m_selEnd.fLeft, m_selEnd.fTop, m_selEnd.fRight, m_selEnd.fBottom); } -const SkRegion& getSelection() +const String getSelection() { - return m_selRegion; -} - -void drawSelection(SkCanvas* canvas, float scale, int offset, int x, int y, - bool extendSelection) -{ - if (!extendSelection) { - drawSelectionArrow(canvas, scale, x, y - offset); - } else { - drawSelectionRegion(canvas); - drawSelectionPointer(canvas, scale, offset, x, y, false); - } + WebCore::IntRect r; + getVisibleRect(&r); + SkIRect area; + area.set(r.x(), r.y(), r.right(), r.bottom()); + String result = CopyPaste::text(*m_navPictureUI, area, m_selRegion); + DBG_NAV_LOGD("text=%s", result.latin1().data()); + return result; } void drawSelectionRegion(SkCanvas* canvas) @@ -1131,46 +1058,31 @@ void drawSelectionRegion(SkCanvas* canvas) canvas->drawPath(path, paint); } -void drawSelectionPointer(SkCanvas* canvas, float scale, int offset, - int x, int y, bool gridded) +void drawSelectionPointer(SkCanvas* canvas, float scale, int x, int y, bool ex) { SkPath path; - getSelectionCaret(&path); + if (ex) + getSelectionCaret(&path); + else + getSelectionArrow(&path); SkPaint paint; paint.setAntiAlias(true); paint.setStyle(SkPaint::kStroke_Style); paint.setColor(SK_ColorBLACK); SkPixelXorXfermode xorMode(SK_ColorWHITE); - paint.setXfermode(&xorMode); - int sc = canvas->save(); - canvas->scale(scale, scale); - canvas->translate(0, -SkIntToScalar(offset)); - if (gridded) { - bool useLeft = x <= (m_selStart.fLeft + m_selStart.fRight) >> 1; - canvas->translate(SkIntToScalar(useLeft ? m_selStart.fLeft : - m_selStart.fRight), SkIntToScalar(m_selStart.fTop)); - } else - canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); - canvas->drawPath(path, paint); - canvas->restoreToCount(sc); -} - -void drawSelectionArrow(SkCanvas* canvas, float scale, int x, int y) -{ - SkPath path; - getSelectionArrow(&path); - SkPaint paint; - paint.setAntiAlias(true); - paint.setStyle(SkPaint::kStroke_Style); - paint.setColor(SK_ColorBLACK); - paint.setStrokeWidth(SK_Scalar1 * 2); + if (ex) + paint.setXfermode(&xorMode); + else + paint.setStrokeWidth(SK_Scalar1 * 2); int sc = canvas->save(); canvas->scale(scale, scale); canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); canvas->drawPath(path, paint); - paint.setStyle(SkPaint::kFill_Style); - paint.setColor(SK_ColorWHITE); - canvas->drawPath(path, paint); + if (!ex) { + paint.setStyle(SkPaint::kFill_Style); + paint.setColor(SK_ColorWHITE); + canvas->drawPath(path, paint); + } canvas->restoreToCount(sc); } @@ -1188,26 +1100,29 @@ void getSelectionCaret(SkPath* path) { SkScalar height = SkIntToScalar(m_selStart.fBottom - m_selStart.fTop); SkScalar dist = height / 4; - path->lineTo(0, height); - SkScalar bottom = height + dist; - path->lineTo(-dist, bottom); - SkScalar edge = bottom - SK_Scalar1/2; - path->moveTo(-dist, edge); - path->lineTo(dist, edge); - path->moveTo(dist, bottom); - path->lineTo(0, height); + path->moveTo(0, -height / 2); + path->rLineTo(0, height); + path->rLineTo(-dist, dist); + path->rMoveTo(0, -SK_Scalar1/2); + path->rLineTo(dist * 2, 0); + path->rMoveTo(0, SK_Scalar1/2); + path->rLineTo(-dist, -dist); +} + +void sendMoveFocus(WebCore::Frame* framePtr, WebCore::Node* nodePtr) +{ + DBG_NAV_LOGD("framePtr=%p nodePtr=%p", framePtr, nodePtr); + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue.object(env).get(), + m_javaGlue.m_sendMoveFocus, (jint) framePtr, (jint) nodePtr); + checkException(env); } void sendMoveMouse(WebCore::Frame* framePtr, WebCore::Node* nodePtr, int x, int y) { DBG_NAV_LOGD("framePtr=%p nodePtr=%p x=%d y=%d", framePtr, nodePtr, x, y); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue.m_sendMoveMouse, + env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_sendMoveMouse, (jint) framePtr, (jint) nodePtr, x, y); checkException(env); } @@ -1216,29 +1131,20 @@ void sendMoveMouseIfLatest(bool disableFocusController) { LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue.m_sendMoveMouseIfLatest, disableFocusController); + env->CallVoidMethod(m_javaGlue.object(env).get(), + m_javaGlue.m_sendMoveMouseIfLatest, disableFocusController); checkException(env); } void sendMotionUp( WebCore::Frame* framePtr, WebCore::Node* nodePtr, int x, int y) { - m_viewImpl->m_touchGeneration = m_viewImpl->m_generation = ++m_generation; + m_viewImpl->m_touchGeneration = ++m_generation; DBG_NAV_LOGD("m_generation=%d framePtr=%p nodePtr=%p x=%d y=%d", m_generation, framePtr, nodePtr, x, y); LOG_ASSERT(m_javaGlue.m_obj, "A WebView was not associated with this WebViewNative!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue.m_sendMotionUp, + env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_sendMotionUp, m_generation, (jint) framePtr, (jint) nodePtr, x, y); checkException(env); } @@ -1307,12 +1213,7 @@ bool scrollBy(int dx, int dy) LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return false; - bool result = env->CallBooleanMethod(obj.get(), + bool result = env->CallBooleanMethod(m_javaGlue.object(env).get(), m_javaGlue.m_scrollBy, dx, dy, true); checkException(env); return result; @@ -1349,62 +1250,30 @@ bool hasFocusNode() void rebuildWebTextView() { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue.m_rebuildWebTextView); - checkException(env); -} - -void displaySoftKeyboard(bool isTextView) -{ - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), - m_javaGlue.m_displaySoftKeyboard, isTextView); + env->CallVoidMethod(m_javaGlue.object(env).get(), + m_javaGlue.m_rebuildWebTextView); checkException(env); } void viewInvalidate() { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue.m_viewInvalidate); + env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_viewInvalidate); checkException(env); } void viewInvalidateRect(int l, int t, int r, int b) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue.m_viewInvalidateRect, l, r, t, b); + env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_viewInvalidateRect, l, r, t, b); checkException(env); } void postInvalidateDelayed(int64_t delay, const WebCore::IntRect& bounds) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue.m_postInvalidateDelayed, - delay, bounds.x(), bounds.y(), bounds.right(), bounds.bottom()); + env->CallVoidMethod(m_javaGlue.object(env).get(), m_javaGlue.m_postInvalidateDelayed, + delay, bounds.x(), bounds.y(), bounds.right(), bounds.bottom()); checkException(env); } @@ -1420,7 +1289,6 @@ private: // local state for WebView int m_generation; // associate unique ID with sent kit focus to match with ui SkPicture* m_navPictureUI; bool m_followedLink; - bool m_pluginReceivesEvents; SkMSec m_ringAnimationEnd; // Corresponds to the same-named boolean on the java side. bool m_heightCanMeasure; @@ -1453,6 +1321,29 @@ static jstring WebCoreStringToJString(JNIEnv *env, WebCore::String string) return ret; } +static int nativeCacheHitFramePointer(JNIEnv *env, jobject obj) +{ + return reinterpret_cast<int>(GET_NATIVE_VIEW(env, obj) + ->m_cacheHitFrame->framePointer()); +} + +static jobject nativeCacheHitNodeBounds(JNIEnv *env, jobject obj) +{ + WebCore::IntRect bounds = GET_NATIVE_VIEW(env, obj) + ->m_cacheHitNode->originalAbsoluteBounds(); + jclass rectClass = env->FindClass("android/graphics/Rect"); + jmethodID init = env->GetMethodID(rectClass, "<init>", "(IIII)V"); + jobject rect = env->NewObject(rectClass, init, bounds.x(), + bounds.y(), bounds.right(), bounds.bottom()); + return rect; +} + +static int nativeCacheHitNodePointer(JNIEnv *env, jobject obj) +{ + return reinterpret_cast<int>(GET_NATIVE_VIEW(env, obj) + ->m_cacheHitNode->nodePointer()); +} + static void nativeClearCursor(JNIEnv *env, jobject obj) { WebView* view = GET_NATIVE_VIEW(env, obj); @@ -1485,6 +1376,14 @@ static const CachedNode* getCursorNode(JNIEnv *env, jobject obj) return root ? root->currentCursor() : 0; } +static const CachedNode* getCursorNode(JNIEnv *env, jobject obj, + const CachedFrame** frame) +{ + WebView* view = GET_NATIVE_VIEW(env, obj); + CachedRoot* root = view->getFrameCache(WebView::DontAllowNewer); + return root ? root->currentCursor(frame) : 0; +} + static const CachedNode* getFocusCandidate(JNIEnv *env, jobject obj) { WebView* view = GET_NATIVE_VIEW(env, obj); @@ -1504,6 +1403,19 @@ static const CachedNode* getFocusNode(JNIEnv *env, jobject obj) return root ? root->currentFocus() : 0; } +static const CachedInput* getInputCandidate(JNIEnv *env, jobject obj) +{ + WebView* view = GET_NATIVE_VIEW(env, obj); + CachedRoot* root = view->getFrameCache(WebView::DontAllowNewer); + if (!root) + return 0; + const CachedFrame* frame; + const CachedNode* cursor = root->currentCursor(&frame); + if (!cursor || !cursor->wantsKeyEvents()) + cursor = root->currentFocus(&frame); + return cursor ? frame->textInput(cursor) : 0; +} + static jboolean nativeCursorMatchesFocus(JNIEnv *env, jobject obj) { const CachedNode* cursor = getCursorNode(env, obj); @@ -1562,16 +1474,10 @@ static bool nativeCursorIsAnchor(JNIEnv *env, jobject obj) return node ? node->isAnchor() : false; } -static bool nativeCursorIsPlugin(JNIEnv *env, jobject obj) -{ - const CachedNode* node = getCursorNode(env, obj); - return node ? node->isPlugin() : false; -} - static bool nativeCursorIsTextInput(JNIEnv *env, jobject obj) { const CachedNode* node = getCursorNode(env, obj); - return node ? node->isTextField() || node->isTextArea() : false; + return node ? node->isTextInput() : false; } static jobject nativeCursorText(JNIEnv *env, jobject obj) @@ -1608,6 +1514,86 @@ static void nativeDrawMatches(JNIEnv *env, jobject obj, jobject canv) view->drawMatches(canvas); } +static void nativeDrawLayers(JNIEnv *env, jobject obj, + jint layer, jfloat scrollX, jfloat scrollY, + jfloat scale, jobject canv) +{ + if (!env) + return; + if (!layer) + return; + if (!canv) + return; + +#if USE(ACCELERATED_COMPOSITING) + LayerAndroid* layerImpl = reinterpret_cast<LayerAndroid*>(layer); + SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, canv); + if (canvas) + layerImpl->paintOn(scrollX, scrollY, scale, canvas); +#endif +} + +static void nativeUpdateLayers(JNIEnv *env, jobject obj, + jint layer, jint updates) +{ + if (!env) + return; + if (!layer) + return; + if (!updates) + return; + +#if USE(ACCELERATED_COMPOSITING) + Vector<RefPtr<AndroidAnimationValue> >* updatesImpl = + reinterpret_cast<Vector<RefPtr<AndroidAnimationValue> >* >(updates); + if (updatesImpl) { + for (unsigned int i = 0; i < updatesImpl->size(); i++) + (updatesImpl->at(i))->apply(); + delete updatesImpl; + } +#endif +} + +static bool nativeLayersHaveAnimations(JNIEnv *env, jobject obj, jint layer) +{ + if (!env) + return false; + if (!layer) + return false; +#if USE(ACCELERATED_COMPOSITING) + LayerAndroid* layerImpl = reinterpret_cast<LayerAndroid*>(layer); + return layerImpl->hasAnimations(); +#else + return false; +#endif +} + +static int nativeEvaluateLayersAnimations(JNIEnv *env, jobject obj, jint layer) +{ + if (!env) + return 0; + if (!layer) + return 0; +#if USE(ACCELERATED_COMPOSITING) + LayerAndroid* layerImpl = reinterpret_cast<LayerAndroid*>(layer); + return reinterpret_cast<int>(layerImpl->evaluateAnimations()); +#else + return 0; +#endif +} + +static void nativeDestroyLayer(JNIEnv *env, jobject obj, jint layer) +{ + if (!env) + return; + if (!layer) + return; +#if USE(ACCELERATED_COMPOSITING) + LayerAndroid* layerImpl = reinterpret_cast<LayerAndroid*>(layer); + delete layerImpl; +#endif +} + static void nativeDrawCursorRing(JNIEnv *env, jobject obj, jobject canv) { SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, canv); @@ -1623,8 +1609,8 @@ static void nativeDrawCursorRing(JNIEnv *env, jobject obj, jobject canv) view->drawCursorRing(canvas); } -static void nativeDrawSelection(JNIEnv *env, jobject obj, - jobject canv, jfloat scale, jint offset, jint x, jint y, bool ex) +static void nativeDrawSelectionPointer(JNIEnv *env, jobject obj, + jobject canv, jfloat scale, jint x, jint y, bool ex) { SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, canv); if (!canv) { @@ -1636,7 +1622,7 @@ static void nativeDrawSelection(JNIEnv *env, jobject obj, DBG_NAV_LOG("!view"); return; } - view->drawSelection(canvas, scale, offset, x, y, ex); + view->drawSelectionPointer(canvas, scale, x, y, ex); } static void nativeDrawSelectionRegion(JNIEnv *env, jobject obj, jobject canv) @@ -1668,42 +1654,49 @@ static jobject nativeImageURI(JNIEnv *env, jobject obj, jint x, jint y) return ret; } -static bool nativeFocusCandidateIsPassword(JNIEnv *env, jobject obj) +static jint nativeFocusCandidateFramePointer(JNIEnv *env, jobject obj) { - const CachedNode* node = getFocusCandidate(env, obj); - return node ? node->isPassword() : false; + WebView* view = GET_NATIVE_VIEW(env, obj); + CachedRoot* root = view->getFrameCache(WebView::DontAllowNewer); + if (!root) + return 0; + const CachedFrame* frame = 0; + const CachedNode* cursor = root->currentCursor(&frame); + if (!cursor || !cursor->wantsKeyEvents()) + (void) root->currentFocus(&frame); + return reinterpret_cast<int>(frame ? frame->framePointer() : 0); } -static bool nativeFocusCandidateIsRtlText(JNIEnv *env, jobject obj) +static bool nativeFocusCandidateIsPassword(JNIEnv *env, jobject obj) { - const CachedNode* node = getFocusCandidate(env, obj); - return node ? node->isRtlText() : false; + const CachedInput* input = getInputCandidate(env, obj); + return input && input->inputType() == WebCore::HTMLInputElement::PASSWORD; } -static bool nativeFocusCandidateIsTextField(JNIEnv *env, jobject obj) +static bool nativeFocusCandidateIsRtlText(JNIEnv *env, jobject obj) { - const CachedNode* node = getFocusCandidate(env, obj); - return node ? node->isTextField() : false; + const CachedInput* input = getInputCandidate(env, obj); + return input ? input->isRtlText() : false; } static bool nativeFocusCandidateIsTextInput(JNIEnv *env, jobject obj) { const CachedNode* node = getFocusCandidate(env, obj); - return node ? node->isTextField() || node->isTextArea() : false; + return node ? node->isTextInput() : false; } static jint nativeFocusCandidateMaxLength(JNIEnv *env, jobject obj) { - const CachedNode* node = getFocusCandidate(env, obj); - return node ? node->maxLength() : false; + const CachedInput* input = getInputCandidate(env, obj); + return input ? input->maxLength() : false; } static jobject nativeFocusCandidateName(JNIEnv *env, jobject obj) { - const CachedNode* node = getFocusCandidate(env, obj); - if (!node) + const CachedInput* input = getInputCandidate(env, obj); + if (!input) return 0; - const WebCore::String& name = node->name(); + const WebCore::String& name = input->name(); return env->NewString((jchar*)name.characters(), name.length()); } @@ -1737,8 +1730,49 @@ static jobject nativeFocusCandidateText(JNIEnv *env, jobject obj) static jint nativeFocusCandidateTextSize(JNIEnv *env, jobject obj) { - const CachedNode* node = getFocusCandidate(env, obj); - return node ? node->textSize() : 0; + const CachedInput* input = getInputCandidate(env, obj); + return input ? input->textSize() : 0; +} + +enum type { + NONE = -1, + NORMAL_TEXT_FIELD = 0, + TEXT_AREA = 1, + PASSWORD = 2, + SEARCH = 3, + EMAIL = 4, + NUMBER = 5, + TELEPHONE = 6, + URL = 7 +}; + +static int nativeFocusCandidateType(JNIEnv *env, jobject obj) +{ + const CachedInput* input = getInputCandidate(env, obj); + if (!input) return NONE; + if (!input->isTextField()) return TEXT_AREA; + switch (input->inputType()) { + case HTMLInputElement::PASSWORD: + return PASSWORD; + case HTMLInputElement::SEARCH: + return SEARCH; + case HTMLInputElement::EMAIL: + return EMAIL; + case HTMLInputElement::NUMBER: + return NUMBER; + case HTMLInputElement::TELEPHONE: + return TELEPHONE; + case HTMLInputElement::URL: + return URL; + default: + return NORMAL_TEXT_FIELD; + } +} + +static bool nativeFocusIsPlugin(JNIEnv *env, jobject obj) +{ + const CachedNode* node = getFocusNode(env, obj); + return node ? node->isPlugin() : false; } static jint nativeFocusNodePointer(JNIEnv *env, jobject obj) @@ -1782,10 +1816,10 @@ static jint nativeTextGeneration(JNIEnv *env, jobject obj) return root ? root->textGeneration() : 0; } -static void nativeTextInputMotionUp(JNIEnv *env, jobject obj, int x, int y) +static bool nativePointInNavCache(JNIEnv *env, jobject obj, + int x, int y, int slop) { - WebView* view = GET_NATIVE_VIEW(env, obj); - view->textInputMotionUp(x, y); + return GET_NATIVE_VIEW(env, obj)->pointInNavCache(x, y, slop); } static bool nativeMotionUp(JNIEnv *env, jobject obj, @@ -1823,18 +1857,13 @@ static void nativeRecordButtons(JNIEnv* env, jobject obj, bool hasFocus, view->nativeRecordButtons(hasFocus, pressed, invalidate); } -static void nativeSetFindIsDown(JNIEnv *env, jobject obj) +static void nativeSetFindIsUp(JNIEnv *env, jobject obj) { WebView* view = GET_NATIVE_VIEW(env, obj); LOG_ASSERT(view, "view not set in %s", __FUNCTION__); view->setFindIsUp(false); } -static void nativeUpdatePluginReceivesEvents(JNIEnv *env, jobject obj) -{ - GET_NATIVE_VIEW(env, obj)->updatePluginReceivesEvents(); -} - static void nativeSetFollowedLink(JNIEnv *env, jobject obj, bool followed) { WebView* view = GET_NATIVE_VIEW(env, obj); @@ -1937,7 +1966,7 @@ static void nativeUpdateCachedTextfield(JNIEnv *env, jobject obj, jstring update if (!root) return; const CachedNode* cachedFocusNode = root->currentFocus(); - if (!cachedFocusNode || (!cachedFocusNode->isTextField() && !cachedFocusNode->isTextArea())) + if (!cachedFocusNode || !cachedFocusNode->isTextInput()) return; WebCore::String webcoreString = to_string(env, updatedText); (const_cast<CachedNode*>(cachedFocusNode))->setExport(webcoreString); @@ -1969,11 +1998,13 @@ static void nativeMoveCursorToNextTextInput(JNIEnv *env, jobject obj) CachedRoot* root = view->getFrameCache(WebView::DontAllowNewer); if (!root) return; - const CachedNode* cursor = root->currentCursor(); - if (!cursor) + const CachedNode* current = root->currentCursor(); + if (!current) + current = root->currentFocus(); + if (!current) return; const CachedFrame* frame; - const CachedNode* next = root->nextTextField(cursor, &frame, true); + const CachedNode* next = root->nextTextField(current, &frame, true); if (!next) return; const WebCore::IntRect& bounds = next->bounds(); @@ -1981,12 +2012,11 @@ static void nativeMoveCursorToNextTextInput(JNIEnv *env, jobject obj) view->updateCursorBounds(root, frame, next); root->setCursor(const_cast<CachedFrame*>(frame), const_cast<CachedNode*>(next)); - WebCore::IntPoint pos; - root->getSimulatedMousePosition(&pos); - view->sendMoveMouse(static_cast<WebCore::Frame*>(frame->framePointer()), - static_cast<WebCore::Node*>(next->nodePointer()), pos.x(), pos.y()); + view->sendMoveFocus(static_cast<WebCore::Frame*>(frame->framePointer()), + static_cast<WebCore::Node*>(next->nodePointer())); view->scrollRectOnScreen(bounds.x(), bounds.y(), bounds.right(), bounds.bottom()); + view->getWebViewCore()->m_moveGeneration++; } static jint nativeTextFieldAction(JNIEnv *env, jobject obj) @@ -1995,7 +2025,7 @@ static jint nativeTextFieldAction(JNIEnv *env, jobject obj) CachedRoot* root = view->getFrameCache(WebView::DontAllowNewer); if (!root) return static_cast<jint>(CachedRoot::FAILURE); - return static_cast<jint>(root->cursorTextFieldAction()); + return static_cast<jint>(root->currentTextFieldAction()); } static int nativeMoveGeneration(JNIEnv *env, jobject obj) @@ -2013,16 +2043,12 @@ static void nativeMoveSelection(JNIEnv *env, jobject obj, int x, int y, bool ex) view->moveSelection(x, y, ex); } -static bool nativePluginEatsNavKey(JNIEnv *env, jobject obj) -{ - return GET_NATIVE_VIEW(env, obj)->pluginEatsNavKey(); -} - static jobject nativeGetSelection(JNIEnv *env, jobject obj) { WebView* view = GET_NATIVE_VIEW(env, obj); LOG_ASSERT(view, "view not set in %s", __FUNCTION__); - return GraphicsJNI::createRegion(env, new SkRegion(view->getSelection())); + String selection = view->getSelection(); + return env->NewString((jchar*)selection.characters(), selection.length()); } #ifdef ANDROID_DUMP_DISPLAY_TREE @@ -2066,6 +2092,12 @@ static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl) * JNI registration */ static JNINativeMethod gJavaWebViewMethods[] = { + { "nativeCacheHitFramePointer", "()I", + (void*) nativeCacheHitFramePointer }, + { "nativeCacheHitNodeBounds", "()Landroid/graphics/Rect;", + (void*) nativeCacheHitNodeBounds }, + { "nativeCacheHitNodePointer", "()I", + (void*) nativeCacheHitNodePointer }, { "nativeClearCursor", "()V", (void*) nativeClearCursor }, { "nativeCreate", "(I)V", @@ -2082,8 +2114,6 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeCursorIntersects }, { "nativeCursorIsAnchor", "()Z", (void*) nativeCursorIsAnchor }, - { "nativeCursorIsPlugin", "()Z", - (void*) nativeCursorIsPlugin }, { "nativeCursorIsTextInput", "()Z", (void*) nativeCursorIsTextInput }, { "nativeCursorPosition", "()Landroid/graphics/Point;", @@ -2098,10 +2128,20 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeDestroy }, { "nativeDrawCursorRing", "(Landroid/graphics/Canvas;)V", (void*) nativeDrawCursorRing }, + { "nativeDestroyLayer", "(I)V", + (void*) nativeDestroyLayer }, + { "nativeLayersHaveAnimations", "(I)Z", + (void*) nativeLayersHaveAnimations }, + { "nativeEvaluateLayersAnimations", "(I)I", + (void*) nativeEvaluateLayersAnimations }, + { "nativeDrawLayers", "(IFFFLandroid/graphics/Canvas;)V", + (void*) nativeDrawLayers }, + { "nativeUpdateLayers", "(II)V", + (void*) nativeUpdateLayers }, { "nativeDrawMatches", "(Landroid/graphics/Canvas;)V", (void*) nativeDrawMatches }, - { "nativeDrawSelection", "(Landroid/graphics/Canvas;FIIIZ)V", - (void*) nativeDrawSelection }, + { "nativeDrawSelectionPointer", "(Landroid/graphics/Canvas;FIIZ)V", + (void*) nativeDrawSelectionPointer }, { "nativeDrawSelectionRegion", "(Landroid/graphics/Canvas;)V", (void*) nativeDrawSelectionRegion }, { "nativeDumpDisplayTree", "(Ljava/lang/String;)V", @@ -2110,12 +2150,12 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeFindAll }, { "nativeFindNext", "(Z)V", (void*) nativeFindNext }, + { "nativeFocusCandidateFramePointer", "()I", + (void*) nativeFocusCandidateFramePointer }, { "nativeFocusCandidateIsPassword", "()Z", (void*) nativeFocusCandidateIsPassword }, { "nativeFocusCandidateIsRtlText", "()Z", (void*) nativeFocusCandidateIsRtlText }, - { "nativeFocusCandidateIsTextField", "()Z", - (void*) nativeFocusCandidateIsTextField }, { "nativeFocusCandidateIsTextInput", "()Z", (void*) nativeFocusCandidateIsTextInput }, { "nativeFocusCandidateMaxLength", "()I", @@ -2130,11 +2170,15 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeFocusCandidateText }, { "nativeFocusCandidateTextSize", "()I", (void*) nativeFocusCandidateTextSize }, + { "nativeFocusCandidateType", "()I", + (void*) nativeFocusCandidateType }, + { "nativeFocusIsPlugin", "()Z", + (void*) nativeFocusIsPlugin }, { "nativeFocusNodePointer", "()I", (void*) nativeFocusNodePointer }, { "nativeGetCursorRingBounds", "()Landroid/graphics/Rect;", (void*) nativeGetCursorRingBounds }, - { "nativeGetSelection", "()Landroid/graphics/Region;", + { "nativeGetSelection", "()Ljava/lang/String;", (void*) nativeGetSelection }, { "nativeHasCursorNode", "()Z", (void*) nativeHasCursorNode }, @@ -2146,8 +2190,6 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeImageURI }, { "nativeInstrumentReport", "()V", (void*) nativeInstrumentReport }, - { "nativeTextInputMotionUp", "(II)V", - (void*) nativeTextInputMotionUp }, { "nativeMotionUp", "(III)Z", (void*) nativeMotionUp }, { "nativeMoveCursor", "(IIZ)Z", @@ -2158,14 +2200,14 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeMoveGeneration }, { "nativeMoveSelection", "(IIZ)V", (void*) nativeMoveSelection }, - { "nativePluginEatsNavKey", "()Z", - (void*) nativePluginEatsNavKey }, + { "nativePointInNavCache", "(III)Z", + (void*) nativePointInNavCache }, { "nativeRecordButtons", "(ZZZ)V", (void*) nativeRecordButtons }, { "nativeSelectBestAt", "(Landroid/graphics/Rect;)V", (void*) nativeSelectBestAt }, - { "nativeSetFindIsDown", "()V", - (void*) nativeSetFindIsDown }, + { "nativeSetFindIsUp", "()V", + (void*) nativeSetFindIsUp }, { "nativeSetFollowedLink", "(Z)V", (void*) nativeSetFollowedLink }, { "nativeSetHeightCanMeasure", "(Z)V", @@ -2178,8 +2220,6 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeUpdateCachedTextfield }, { "nativeGetBlockLeftEdge", "(IIF)I", (void*) nativeGetBlockLeftEdge }, - { "nativeUpdatePluginReceivesEvents", "()V", - (void*) nativeUpdatePluginReceivesEvents } }; int register_webview(JNIEnv* env) diff --git a/WebKit/android/plugins/ANPBitmapInterface.cpp b/WebKit/android/plugins/ANPBitmapInterface.cpp index 25d1e97..4c6ad7c 100644 --- a/WebKit/android/plugins/ANPBitmapInterface.cpp +++ b/WebKit/android/plugins/ANPBitmapInterface.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -69,4 +69,3 @@ void ANPBitmapInterfaceV0_Init(ANPInterface* value) { ASSIGN(i, getPixelPacking); } - diff --git a/WebKit/android/plugins/ANPCanvasInterface.cpp b/WebKit/android/plugins/ANPCanvasInterface.cpp index c985f64..d6d89ff 100644 --- a/WebKit/android/plugins/ANPCanvasInterface.cpp +++ b/WebKit/android/plugins/ANPCanvasInterface.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -195,4 +195,3 @@ void ANPCanvasInterfaceV0_Init(ANPInterface* value) { ASSIGN(i, drawBitmap); ASSIGN(i, drawBitmapRect); } - diff --git a/WebKit/android/plugins/ANPEventInterface.cpp b/WebKit/android/plugins/ANPEventInterface.cpp new file mode 100644 index 0000000..2fdf159 --- /dev/null +++ b/WebKit/android/plugins/ANPEventInterface.cpp @@ -0,0 +1,84 @@ +/* + * 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. + */ + +// must include config.h first for webkit to fiddle with new/delete +#include "config.h" +#include "SkANP.h" +#include "WebViewCore.h" +#include "PluginView.h" +#include "PluginWidgetAndroid.h" + +#include "JavaSharedClient.h" + +using namespace android; + +struct WrappedANPEvent { + WebViewCore* fWVC; + PluginWidgetAndroid* fPWA; + ANPEvent fEvent; +}; + +/* Its possible we may be called after the plugin that initiated the event + has been torn-down. Thus we check that the assicated webviewcore and + pluginwidget are still active before dispatching the event. + */ +static void send_anpevent(void* data) { + WrappedANPEvent* wrapper = static_cast<WrappedANPEvent*>(data); + WebViewCore* core = wrapper->fWVC; + PluginWidgetAndroid* widget = wrapper->fPWA; + + // be sure we're still alive before delivering the event + if (WebViewCore::isInstance(core) && core->isPlugin(widget)) { + widget->sendEvent(wrapper->fEvent); + } + delete wrapper; +} + +static void anp_postEvent(NPP instance, const ANPEvent* event) { + if (instance && instance->ndata && event) { + PluginView* pluginView = static_cast<PluginView*>(instance->ndata); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + WebViewCore* wvc = pluginWidget->webViewCore(); + + WrappedANPEvent* wrapper = new WrappedANPEvent; + // recored these, and recheck that they are valid before delivery + // in send_anpevent + wrapper->fWVC = pluginWidget->webViewCore(); + wrapper->fPWA = pluginWidget; + // make a copy of the event + wrapper->fEvent = *event; + JavaSharedClient::EnqueueFunctionPtr(send_anpevent, wrapper); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +#define ASSIGN(obj, name) (obj)->name = anp_##name + +void ANPEventInterfaceV0_Init(ANPInterface* value) { + ANPEventInterfaceV0* i = reinterpret_cast<ANPEventInterfaceV0*>(value); + + ASSIGN(i, postEvent); +} diff --git a/WebKit/android/plugins/ANPKeyCodes.h b/WebKit/android/plugins/ANPKeyCodes.h index 5213f57..328eb56 100644 --- a/WebKit/android/plugins/ANPKeyCodes.h +++ b/WebKit/android/plugins/ANPKeyCodes.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -122,4 +122,3 @@ enum ANPKeyCodes { }; #endif - diff --git a/WebKit/android/plugins/ANPLogInterface.cpp b/WebKit/android/plugins/ANPLogInterface.cpp index 6ccca0a..23a4ed6 100644 --- a/WebKit/android/plugins/ANPLogInterface.cpp +++ b/WebKit/android/plugins/ANPLogInterface.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -23,13 +23,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define LOG_TAG "plugin" +#define LOG_TAG "webkitPlugin" #include "utils/Log.h" #include "android_npapi.h" #include <stdarg.h> -static void anp_log(NPP inst, ANPLogType logType, const char format[], ...) { +static void anp_log(ANPLogType logType, const char format[], ...) { va_list args; va_start(args, format); @@ -58,4 +58,3 @@ void ANPLogInterfaceV0_Init(ANPInterface* value) { i->log = anp_log; } - diff --git a/WebKit/android/plugins/ANPMatrixInterface.cpp b/WebKit/android/plugins/ANPMatrixInterface.cpp index 815b954..f322315 100644 --- a/WebKit/android/plugins/ANPMatrixInterface.cpp +++ b/WebKit/android/plugins/ANPMatrixInterface.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -165,4 +165,3 @@ void ANPMatrixInterfaceV0_Init(ANPInterface* value) { ASSIGN(i, invert); ASSIGN(i, mapPoints); } - diff --git a/WebKit/android/plugins/ANPPaintInterface.cpp b/WebKit/android/plugins/ANPPaintInterface.cpp index 4b561f0..5c59df9 100644 --- a/WebKit/android/plugins/ANPPaintInterface.cpp +++ b/WebKit/android/plugins/ANPPaintInterface.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -210,4 +210,3 @@ void ANPPaintInterfaceV0_Init(ANPInterface* value) { ASSIGN(i, getTextWidths); ASSIGN(i, getFontMetrics); } - diff --git a/WebKit/android/plugins/ANPPathInterface.cpp b/WebKit/android/plugins/ANPPathInterface.cpp index 468d866..69cabcf 100644 --- a/WebKit/android/plugins/ANPPathInterface.cpp +++ b/WebKit/android/plugins/ANPPathInterface.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -110,4 +110,3 @@ void ANPPathInterfaceV0_Init(ANPInterface* value) { ASSIGN(i, offset); ASSIGN(i, transform); } - diff --git a/WebKit/android/plugins/ANPSoundInterface.cpp b/WebKit/android/plugins/ANPSoundInterface.cpp index c4bec1c..8e31d69 100644 --- a/WebKit/android/plugins/ANPSoundInterface.cpp +++ b/WebKit/android/plugins/ANPSoundInterface.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -27,6 +27,7 @@ #include "config.h" #include "android_npapi.h" +#include "SkTypes.h" #include "media/AudioTrack.h" struct ANPAudioTrack { @@ -146,4 +147,3 @@ void ANPAudioTrackInterfaceV0_Init(ANPInterface* value) { si->stop = ANPTrackStop; si->isStopped = ANPTrackIsStopped; } - diff --git a/WebKit/android/plugins/ANPSurfaceInterface.cpp b/WebKit/android/plugins/ANPSurfaceInterface.cpp index dd5dbe0..02ff77e 100644 --- a/WebKit/android/plugins/ANPSurfaceInterface.cpp +++ b/WebKit/android/plugins/ANPSurfaceInterface.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -39,23 +39,48 @@ using namespace android; +// used to cache JNI method and field IDs for Surface Objects +static struct ANPSurfaceInterfaceJavaGlue { + bool initialized; + jmethodID getSurfaceHolder; + jmethodID getSurface; + jfieldID surfacePointer; +} gSurfaceJavaGlue; + static inline sp<Surface> getSurface(JNIEnv* env, jobject view) { if (!env || !view) { return NULL; } - jclass clazz = env->FindClass("android/view/Surface"); - jfieldID surfaceField = env->GetFieldID(clazz, "mSurface", "I"); + if (!gSurfaceJavaGlue.initialized) { + + jclass surfaceViewClass = env->FindClass("android/view/SurfaceView"); + gSurfaceJavaGlue.getSurfaceHolder = env->GetMethodID(surfaceViewClass, "getHolder", + "()Landroid/view/SurfaceHolder;"); + + jclass surfaceHolderClass = env->FindClass("android/view/SurfaceHolder"); + gSurfaceJavaGlue.getSurface = env->GetMethodID(surfaceHolderClass, "getSurface", + "()Landroid/view/Surface;"); - clazz = env->FindClass("android/view/SurfaceView"); - jmethodID getHolder = env->GetMethodID(clazz, "getHolder", "()Landroid/view/SurfaceHolder;"); + jclass surfaceClass = env->FindClass("android/view/Surface"); + gSurfaceJavaGlue.surfacePointer = env->GetFieldID(surfaceClass, + "mSurface", "I"); - clazz = env->FindClass("android/view/SurfaceHolder"); - jmethodID getSurface = env->GetMethodID(clazz, "getSurface", "()Landroid/view/Surface;"); + env->DeleteLocalRef(surfaceClass); + env->DeleteLocalRef(surfaceViewClass); + env->DeleteLocalRef(surfaceHolderClass); + + gSurfaceJavaGlue.initialized = true; + } - jobject holder = env->CallObjectMethod(view, getHolder); - jobject surface = env->CallObjectMethod(holder, getSurface); - return sp<Surface>((Surface*) env->GetIntField(surface, surfaceField)); + jobject holder = env->CallObjectMethod(view, gSurfaceJavaGlue.getSurfaceHolder); + jobject surface = env->CallObjectMethod(holder, gSurfaceJavaGlue.getSurface); + jint surfacePointer = env->GetIntField(surface, gSurfaceJavaGlue.surfacePointer); + + env->DeleteLocalRef(holder); + env->DeleteLocalRef(surface); + + return sp<Surface>((Surface*) surfacePointer); } static inline ANPBitmapFormat convertPixelFormat(PixelFormat format) { @@ -133,5 +158,7 @@ void ANPSurfaceInterfaceV0_Init(ANPInterface* value) { ASSIGN(i, lock); ASSIGN(i, unlock); -} + // setup the java glue struct + gSurfaceJavaGlue.initialized = false; +} diff --git a/WebKit/android/plugins/ANPSurface_npapi.h b/WebKit/android/plugins/ANPSurface_npapi.h index 7dcec92..910a948 100644 --- a/WebKit/android/plugins/ANPSurface_npapi.h +++ b/WebKit/android/plugins/ANPSurface_npapi.h @@ -1,3 +1,28 @@ +/* + * 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 ANPSurface_npapi_H #define ANPSurface_npapi_H diff --git a/WebKit/android/plugins/ANPSystemInterface.cpp b/WebKit/android/plugins/ANPSystemInterface.cpp index a5b9bcb..42ec9e4 100644 --- a/WebKit/android/plugins/ANPSystemInterface.cpp +++ b/WebKit/android/plugins/ANPSystemInterface.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -26,10 +26,16 @@ // must include config.h first for webkit to fiddle with new/delete #include "config.h" -#include "android_npapi.h" #include "CString.h" #include "JavaSharedClient.h" #include "PluginClient.h" +#include "PluginPackage.h" +#include "PluginView.h" +#include "PluginWidgetAndroid.h" +#include "SkString.h" +#include "WebViewCore.h" + +#include "ANPSystem_npapi.h" static const char* gApplicationDataDir = NULL; @@ -61,6 +67,22 @@ static const char* anp_getApplicationDataDirectory() { return gApplicationDataDir; } +static WebCore::PluginView* pluginViewForInstance(NPP instance) { + if (instance && instance->ndata) + return static_cast<WebCore::PluginView*>(instance->ndata); + return PluginView::currentPluginView(); +} + +static jclass anp_loadJavaClass(NPP instance, const char* className) { + WebCore::PluginView* pluginView = pluginViewForInstance(instance); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + + jclass result; + result = pluginWidget->webViewCore()->getPluginClass(pluginView->plugin()->path(), + className); + return result; +} + /////////////////////////////////////////////////////////////////////////////// #define ASSIGN(obj, name) (obj)->name = anp_##name @@ -69,4 +91,5 @@ void ANPSystemInterfaceV0_Init(ANPInterface* v) { ANPSystemInterfaceV0* i = reinterpret_cast<ANPSystemInterfaceV0*>(v); ASSIGN(i, getApplicationDataDirectory); + ASSIGN(i, loadJavaClass); } diff --git a/WebKit/android/plugins/ANPSystem_npapi.h b/WebKit/android/plugins/ANPSystem_npapi.h new file mode 100644 index 0000000..6a102a7 --- /dev/null +++ b/WebKit/android/plugins/ANPSystem_npapi.h @@ -0,0 +1,50 @@ +/* + * 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 ANPSystem_npapi_H +#define ANPSystem_npapi_H + +#include "android_npapi.h" +#include <jni.h> + +struct ANPSystemInterfaceV0 : ANPInterface { + /** Return the path name for the current Application's plugin data directory, + or NULL if not supported + */ + const char* (*getApplicationDataDirectory)(); + + /** A helper function to load java classes from the plugin's apk. The + function looks for a class given the fully qualified and null terminated + string representing the className. For example, + + const char* className = "com.android.mypackage.MyClass"; + + If the class cannot be found or there is a problem loading the class + NULL will be returned. + */ + jclass (*loadJavaClass)(NPP instance, const char* className); +}; + +#endif //ANPSystem_npapi_H diff --git a/WebKit/android/plugins/ANPTypefaceInterface.cpp b/WebKit/android/plugins/ANPTypefaceInterface.cpp index e33e580..4b2dda2 100644 --- a/WebKit/android/plugins/ANPTypefaceInterface.cpp +++ b/WebKit/android/plugins/ANPTypefaceInterface.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -102,4 +102,3 @@ void ANPTypefaceInterfaceV0_Init(ANPInterface* v) { ASSIGN(i, getFontPath); ASSIGN(i, getFontDirectoryPath); } - diff --git a/WebKit/android/plugins/ANPWindowInterface.cpp b/WebKit/android/plugins/ANPWindowInterface.cpp index 7a2f94c..06afab1 100644 --- a/WebKit/android/plugins/ANPWindowInterface.cpp +++ b/WebKit/android/plugins/ANPWindowInterface.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -30,27 +30,6 @@ #include "PluginView.h" #include "PluginWidgetAndroid.h" -static bool anp_lockRect(void* window, const ANPRectI* inval, - ANPBitmap* bitmap) { - if (window) { - // todo - return true; - } - return false; -} - -static bool anp_lockRegion(void* window, const ANPRegion* inval, - ANPBitmap* bitmap) { - if (window) { - // todo - return true; - } - return false; -} - -static void anp_unlock(void* window) { -} - static PluginView* pluginViewForInstance(NPP instance) { if (instance && instance->ndata) return static_cast<PluginView*>(instance->ndata); @@ -68,14 +47,23 @@ static void anp_clearVisibleRects(NPP instance) { } static void anp_showKeyboard(NPP instance, bool value) { - ScrollView* scrollView = pluginViewForInstance(instance)->parent(); - android::WebViewCore* core = android::WebViewCore::getWebViewCore(scrollView); - core->requestKeyboard(value); + PluginView* pluginView = pluginViewForInstance(instance); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + pluginWidget->webViewCore()->requestKeyboard(value, false); } static void anp_requestFullScreen(NPP instance) { PluginView* pluginView = pluginViewForInstance(instance); - pluginView->platformPluginWidget()->requestFullScreenMode(); + // call focusPluginElement() so that the pluginView receives keyboard events + pluginView->focusPluginElement(); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + pluginWidget->requestFullScreen(); +} + +static void anp_exitFullScreen(NPP instance) { + PluginView* pluginView = pluginViewForInstance(instance); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + pluginWidget->exitFullScreen(true); } /////////////////////////////////////////////////////////////////////////////// @@ -85,12 +73,9 @@ static void anp_requestFullScreen(NPP instance) { void ANPWindowInterfaceV0_Init(ANPInterface* value) { ANPWindowInterfaceV0* i = reinterpret_cast<ANPWindowInterfaceV0*>(value); - ASSIGN(i, lockRect); - ASSIGN(i, lockRegion); ASSIGN(i, setVisibleRects); ASSIGN(i, clearVisibleRects); ASSIGN(i, showKeyboard); - ASSIGN(i, unlock); ASSIGN(i, requestFullScreen); + ASSIGN(i, exitFullScreen); } - diff --git a/WebKit/android/plugins/PluginDebugAndroid.h b/WebKit/android/plugins/PluginDebugAndroid.h index 992e953..2143b39 100644 --- a/WebKit/android/plugins/PluginDebugAndroid.h +++ b/WebKit/android/plugins/PluginDebugAndroid.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/plugins/PluginTimer.cpp b/WebKit/android/plugins/PluginTimer.cpp index 1097330..cdcde9c 100644 --- a/WebKit/android/plugins/PluginTimer.cpp +++ b/WebKit/android/plugins/PluginTimer.cpp @@ -5,23 +5,23 @@ * 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 + * * 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 + * * 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 + * 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 + * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" diff --git a/WebKit/android/plugins/PluginTimer.h b/WebKit/android/plugins/PluginTimer.h index ccb49da..3fbe728 100644 --- a/WebKit/android/plugins/PluginTimer.h +++ b/WebKit/android/plugins/PluginTimer.h @@ -5,23 +5,23 @@ * 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 + * * 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 + * * 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 + * 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 + * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PluginTimer_H diff --git a/WebKit/android/plugins/PluginViewBridgeAndroid.cpp b/WebKit/android/plugins/PluginViewBridgeAndroid.cpp index 945115a..2be9dc3 100644 --- a/WebKit/android/plugins/PluginViewBridgeAndroid.cpp +++ b/WebKit/android/plugins/PluginViewBridgeAndroid.cpp @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/plugins/PluginViewBridgeAndroid.h b/WebKit/android/plugins/PluginViewBridgeAndroid.h index e17a2dc..5d16f46 100644 --- a/WebKit/android/plugins/PluginViewBridgeAndroid.h +++ b/WebKit/android/plugins/PluginViewBridgeAndroid.h @@ -6,23 +6,23 @@ * 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 + * * 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 + * * 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 + * 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 + * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PluginViewBridgeAndroid_H diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index fdc4016..113a3bc 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -36,6 +36,9 @@ #include "SkFlipPixelRef.h" #include "SkString.h" #include "WebViewCore.h" +#include "jni_utility.h" + +#define DEBUG_VISIBLE_RECTS 1 // temporary debug printfs and fixes PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view) : m_pluginView(view) { @@ -47,22 +50,28 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view) m_requestedVisibleRectCount = 0; m_requestedFrameRect.setEmpty(); m_visibleDocRect.setEmpty(); + m_pluginBounds.setEmpty(); m_hasFocus = false; + m_isFullScreen = false; + m_visible = true; m_zoomLevel = 0; - m_javaClassName = NULL; - m_childView = NULL; + m_embeddedView = NULL; } PluginWidgetAndroid::~PluginWidgetAndroid() { if (m_core) { m_core->removePlugin(this); - if (m_childView) { - m_core->destroySurface(m_childView); + if (m_embeddedView) { + m_core->destroySurface(m_embeddedView); } } - if (m_javaClassName) { - free(m_javaClassName); + + // cleanup any remaining JNI References + JNIEnv* env = JSC::Bindings::getJNIEnv(); + if (m_embeddedView) { + env->DeleteGlobalRef(m_embeddedView); } + m_flipPixelRef->safeUnref(); } @@ -77,66 +86,60 @@ static SkBitmap::Config computeConfig(bool isTransparent) { } void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) { + + // store the reference locally for easy lookup m_pluginWindow = window; - if (m_drawingModel == kSurface_ANPDrawingModel) { - if (!m_childView) { - IntPoint docPoint = frameToDocumentCoords(window->x, window->y); + // make a copy of the previous bounds + SkIRect oldPluginBounds = m_pluginBounds; - const String& libName = m_pluginView->plugin()->path(); - SkString skLibName; - skLibName.setUTF16(libName.characters(), libName.length()); + // keep a local copy of the plugin bounds because the m_pluginWindow pointer + // gets updated values prior to this method being called + m_pluginBounds.set(m_pluginWindow->x, m_pluginWindow->y, + m_pluginWindow->x + m_pluginWindow->width, + m_pluginWindow->y + m_pluginWindow->height); - m_childView = m_core->createSurface(skLibName.c_str(), m_javaClassName, - m_pluginView->instance(), - docPoint.x(), docPoint.y(), - window->width, window->height); - } - } else { - m_flipPixelRef->safeUnref(); - m_flipPixelRef = new SkFlipPixelRef(computeConfig(isTransparent), - window->width, window->height); - } -} + if (m_drawingModel == kSurface_ANPDrawingModel) { -bool PluginWidgetAndroid::setPluginStubJavaClassName(const char* className) { + IntPoint docPoint = frameToDocumentCoords(window->x, window->y); - if (m_javaClassName) { - free(m_javaClassName); - } + // if the surface exists check for changes and update accordingly + if (m_embeddedView && m_pluginBounds != oldPluginBounds) { - // don't call strdup() if the className is to be set to NULL - if (!className) { - m_javaClassName = NULL; - return true; - } + m_core->updateSurface(m_embeddedView, docPoint.x(), docPoint.y(), + window->width, window->height); - // make a local copy of the className - m_javaClassName = strdup(className); - return (m_javaClassName != NULL); -} + // if the surface does not exist then create a new surface + } else if(!m_embeddedView) { -void PluginWidgetAndroid::requestFullScreenMode() { + WebCore::PluginPackage* pkg = m_pluginView->plugin(); + NPP instance = m_pluginView->instance(); - if (!m_javaClassName) { - return; - } - const String& libName = m_pluginView->plugin()->path(); - SkString skLibName; - skLibName.setUTF16(libName.characters(), libName.length()); + jobject pluginSurface; + pkg->pluginFuncs()->getvalue(instance, kJavaSurface_ANPGetValue, + static_cast<void*>(&pluginSurface)); - m_core->startFullScreenPluginActivity(skLibName.c_str(), m_javaClassName, - m_pluginView->instance()); + jobject tempObj = m_core->addSurface(pluginSurface, + docPoint.x(), docPoint.y(), + window->width, window->height); + if (tempObj) { + JNIEnv* env = JSC::Bindings::getJNIEnv(); + m_embeddedView = env->NewGlobalRef(tempObj); + } + } + if (m_isFullScreen && m_pluginBounds != oldPluginBounds) { + m_core->updateFullScreenPlugin(docPoint.x(), docPoint.y(), + window->width, window->height); + } + } else { + m_flipPixelRef->safeUnref(); + m_flipPixelRef = new SkFlipPixelRef(computeConfig(isTransparent), + window->width, window->height); + } } bool PluginWidgetAndroid::setDrawingModel(ANPDrawingModel model) { - - // disallow the surface drawing model if no java class name has been given - if (model == kSurface_ANPDrawingModel && m_javaClassName == NULL) { - return false; - } - m_drawingModel = model; return true; } @@ -264,7 +267,10 @@ bool PluginWidgetAndroid::isAcceptingEvent(ANPEventFlag flag) { } void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float zoom) { - +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s (%d,%d,%d,%d)", __FUNCTION__, visibleDocRect.left, + visibleDocRect.top, visibleDocRect.right, visibleDocRect.bottom); +#endif // TODO update the bitmap size based on the zoom? (for kBitmap_ANPDrawingModel) int oldScreenW = m_visibleDocRect.width(); @@ -278,10 +284,24 @@ void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float if (oldScreenW != newScreenW || oldScreenH != newScreenH) computeVisibleFrameRect(); + + bool visible = SkIRect::Intersects(m_visibleDocRect, m_pluginBounds); + if(m_visible != visible) { + // change the visibility + m_visible = visible; + // send the event + ANPEvent event; + SkANP::InitEvent(&event, kLifecycle_ANPEventType); + event.data.lifecycle.action = visible ? kOnScreen_ANPLifecycleAction + : kOffScreen_ANPLifecycleAction; + sendEvent(event); + } } void PluginWidgetAndroid::setVisibleRects(const ANPRectI rects[], int32_t count) { - +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s count=%d", __FUNCTION__, count); +#endif // ensure the count does not exceed our allocated space if (count > MAX_REQUESTED_RECTS) count = MAX_REQUESTED_RECTS; @@ -290,6 +310,24 @@ void PluginWidgetAndroid::setVisibleRects(const ANPRectI rects[], int32_t count) m_requestedVisibleRectCount = count; memcpy(m_requestedVisibleRect, rects, count * sizeof(rects[0])); +#if DEBUG_VISIBLE_RECTS // FIXME: this fixes bad data from the plugin + // take it out once plugin supplies better data + for (int index = 0; index < count; index++) { + SkDebugf("%s [%d](%d,%d,%d,%d)", __FUNCTION__, index, + m_requestedVisibleRect[index].left, + m_requestedVisibleRect[index].top, + m_requestedVisibleRect[index].right, + m_requestedVisibleRect[index].bottom); + if (m_requestedVisibleRect[index].left == + m_requestedVisibleRect[index].right) { + m_requestedVisibleRect[index].right += 1; + } + if (m_requestedVisibleRect[index].top == + m_requestedVisibleRect[index].bottom) { + m_requestedVisibleRect[index].bottom += 1; + } + } +#endif computeVisibleFrameRect(); } @@ -299,12 +337,6 @@ void PluginWidgetAndroid::computeVisibleFrameRect() { if (m_visibleDocRect.isEmpty() || !m_pluginWindow) return; - // create a rect that represents the plugin's bounds - SkIRect pluginBounds; - pluginBounds.set(m_pluginWindow->x, m_pluginWindow->y, - m_pluginWindow->x + m_pluginWindow->width, - m_pluginWindow->y + m_pluginWindow->height); - // create a rect that will contain as many of the rects that will fit on screen SkIRect visibleRect; visibleRect.setEmpty(); @@ -319,9 +351,18 @@ void PluginWidgetAndroid::computeVisibleFrameRect() { pluginRect.offset(m_pluginWindow->x, m_pluginWindow->y); // ensure the rect falls within the plugin's bounds - if (!pluginBounds.contains(pluginRect)) - continue; - + if (!m_pluginBounds.contains(pluginRect)) { +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s (%d,%d,%d,%d) !contain (%d,%d,%d,%d)", __FUNCTION__, + m_pluginBounds.fLeft, m_pluginBounds.fTop, + m_pluginBounds.fRight, m_pluginBounds.fBottom, + pluginRect.fLeft, pluginRect.fTop, + pluginRect.fRight, pluginRect.fBottom); + // FIXME: assume that the desired outcome is to clamp to the container + pluginRect.intersect(m_pluginBounds); +#endif + continue; + } // combine this new rect with the higher priority rects pluginRect.join(visibleRect); @@ -342,9 +383,14 @@ void PluginWidgetAndroid::computeVisibleFrameRect() { void PluginWidgetAndroid::scrollToVisibleFrameRect() { - if (!m_hasFocus || m_requestedFrameRect.isEmpty() || m_visibleDocRect.isEmpty()) + if (!m_hasFocus || m_requestedFrameRect.isEmpty() || m_visibleDocRect.isEmpty()) { +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s call m_hasFocus=%d m_requestedFrameRect.isEmpty()=%d" + " m_visibleDocRect.isEmpty()=%d", __FUNCTION__, m_hasFocus, + m_requestedFrameRect.isEmpty(), m_visibleDocRect.isEmpty()); +#endif return; - + } // if the entire rect is already visible then we don't need to scroll, which // requires converting the m_requestedFrameRect from frame to doc coordinates IntPoint pluginDocPoint = frameToDocumentCoords(m_requestedFrameRect.fLeft, @@ -371,6 +417,9 @@ void PluginWidgetAndroid::scrollToVisibleFrameRect() { ScrollView* scrollView = m_pluginView->parent(); android::WebViewCore* core = android::WebViewCore::getWebViewCore(scrollView); +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s call scrollBy (%d,%d)", __FUNCTION__, deltaX, deltaY); +#endif core->scrollBy(deltaX, deltaY, true); } @@ -391,3 +440,49 @@ IntPoint PluginWidgetAndroid::frameToDocumentCoords(int frameX, int frameY) cons return docPoint; } + +void PluginWidgetAndroid::requestFullScreen() { + if (m_isFullScreen || !m_embeddedView) { + return; + } + + // send event to notify plugin of full screen change + ANPEvent event; + SkANP::InitEvent(&event, kLifecycle_ANPEventType); + event.data.lifecycle.action = kEnterFullScreen_ANPLifecycleAction; + sendEvent(event); + + // remove the embedded surface from the view hierarchy + m_core->destroySurface(m_embeddedView); + + // add the full screen view + IntPoint docPoint = frameToDocumentCoords(m_pluginWindow->x, m_pluginWindow->y); + m_core->showFullScreenPlugin(m_embeddedView, m_pluginView->instance(), + docPoint.x(), docPoint.y(), m_pluginWindow->width, + m_pluginWindow->height); + m_isFullScreen = true; +} + +void PluginWidgetAndroid::exitFullScreen(bool pluginInitiated) { + if (!m_isFullScreen || !m_embeddedView) { + return; + } + + // remove the full screen surface from the view hierarchy + if (pluginInitiated) { + m_core->hideFullScreenPlugin(); + } + + // add the embedded view back + IntPoint docPoint = frameToDocumentCoords(m_pluginWindow->x, m_pluginWindow->y); + m_core->updateSurface(m_embeddedView, docPoint.x(), docPoint.y(), + m_pluginWindow->width, m_pluginWindow->height); + + // send event to notify plugin of full screen change + ANPEvent event; + SkANP::InitEvent(&event, kLifecycle_ANPEventType); + event.data.lifecycle.action = kExitFullScreen_ANPLifecycleAction; + sendEvent(event); + + m_isFullScreen = false; +} diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h index 9fc2209..93ad4a8 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -67,12 +67,6 @@ struct PluginWidgetAndroid { */ void setWindow(NPWindow* window, bool isTransparent); - /* Called to notify us of the plugin's java class that implements the - * PluginStub interface. A local copy is made of the className so the caller - * can safely free the memory as soon as the function returns. - */ - bool setPluginStubJavaClassName(const char* className); - /* Called whenever the plugin itself requests a new drawing model. If the hardware does not support the requested model then false is returned, otherwise true is returned. @@ -131,11 +125,20 @@ struct PluginWidgetAndroid { */ void setVisibleRects(const ANPRectI rects[], int32_t count); - /** Called when a plugin wishes to enter into full screen mode. The plugin's - Java class (set using setPluginStubJavaClassName(...)) will be called - asynchronously to provide a View to be displayed in full screen. + /** Called when a plugin wishes to enter into full screen mode. It invokes + the plugin's Java class (defined in the plugin's apk manifest), which is + called asynchronously and provides a View to be displayed full screen. */ - void requestFullScreenMode(); + void requestFullScreen(); + + /** Called when a plugin wishes to exit from full screen mode. As a result, + the plugin's full-screen view is discarded by the view system. It is also + called in order to notify the native code that the browser has discarded + the view. + */ + void exitFullScreen(bool pluginInitiated); + + bool inFullScreen() { return m_isFullScreen; } private: WebCore::IntPoint frameToDocumentCoords(int frameX, int frameY) const; @@ -148,12 +151,14 @@ private: ANPDrawingModel m_drawingModel; ANPEventFlags m_eventFlags; NPWindow* m_pluginWindow; + SkIRect m_pluginBounds; SkIRect m_visibleDocRect; SkIRect m_requestedFrameRect; bool m_hasFocus; + bool m_isFullScreen; + bool m_visible; float m_zoomLevel; - char* m_javaClassName; - jobject m_childView; + jobject m_embeddedView; /* We limit the number of rectangles to minimize storage and ensure adequate speed. diff --git a/WebKit/android/plugins/SkANP.cpp b/WebKit/android/plugins/SkANP.cpp index 3912f99..9bbb09e 100644 --- a/WebKit/android/plugins/SkANP.cpp +++ b/WebKit/android/plugins/SkANP.cpp @@ -13,7 +13,7 @@ * 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 + * 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 @@ -103,4 +103,3 @@ void SkANP::InitEvent(ANPEvent* event, ANPEventType et) { event->inSize = sizeof(ANPEvent); event->eventType = et; } - diff --git a/WebKit/android/plugins/SkANP.h b/WebKit/android/plugins/SkANP.h index f319c9b..5c2a936 100644 --- a/WebKit/android/plugins/SkANP.h +++ b/WebKit/android/plugins/SkANP.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -77,4 +77,3 @@ public: }; #endif - diff --git a/WebKit/android/plugins/SurfaceCallback.h b/WebKit/android/plugins/SurfaceCallback.h index fb2e015..945fc3f 100644 --- a/WebKit/android/plugins/SurfaceCallback.h +++ b/WebKit/android/plugins/SurfaceCallback.h @@ -5,16 +5,16 @@ * 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 + * * 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 + * * 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 + * 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 + * 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 diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index 95ab889..4173528 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -1,5 +1,5 @@ /* - * Copyright 2008, The Android Open Source Project + * 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 @@ -13,7 +13,7 @@ * 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 + * 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 @@ -118,15 +118,20 @@ typedef uint32_t ANPMatrixFlag; #define kBitmapInterfaceV0_ANPGetValue ((NPNVariable)1008) #define kSurfaceInterfaceV0_ANPGetValue ((NPNVariable)1009) #define kSystemInterfaceV0_ANPGetValue ((NPNVariable)1010) +#define kEventInterfaceV0_ANPGetValue ((NPNVariable)1011) -/** queries for which drawing model is desired (for the draw event) +/** queries for the drawing models supported on this device. - Should be called inside NPP_New(...) - - NPN_GetValue(inst, ANPSupportedDrawingModel_EnumValue, uint32_t* bits) + NPN_GetValue(inst, kSupportedDrawingModel_ANPGetValue, uint32_t* bits) */ #define kSupportedDrawingModel_ANPGetValue ((NPNVariable)2000) +/** queries for the context (android.content.Context) in which the plugin resides + + NPN_GetValue(inst, kJavaContext_ANPGetValue, jobject context) + */ +#define kJavaContext_ANPGetValue ((NPNVariable)2001) + /////////////////////////////////////////////////////////////////////////////// // NPN_SetValue @@ -137,20 +142,6 @@ typedef uint32_t ANPMatrixFlag; */ #define kRequestDrawingModel_ANPSetValue ((NPPVariable)1000) -/** Set the name of the Java class found in the plugin's apk that implements the - PluginStub interface. The value provided must be a null terminated char* - that contains the fully qualified class name (e.g., your.package.className). - A local copy is made of the char* so the caller can safely free the memory - as soon as the function returns. - - This value must be set prior to selecting the Surface_ANPDrawingModel or - requesting to enter full-screen mode. - - NPN_SetValue(inst, kSetPluginStubJavaClassName_ANPSetValue, - (void*)nullTerminatedChar*) - */ -#define kSetPluginStubJavaClassName_ANPSetValue ((NPPVariable)1001) - /** These are used as bitfields in ANPSupportedDrawingModels_EnumValue, and as-is in ANPRequestDrawingModel_EnumValue. The drawing model determines how to interpret the ANPDrawingContext provided in the Draw event and how @@ -160,18 +151,28 @@ enum ANPDrawingModels { /** Draw into a bitmap from the browser thread in response to a Draw event. NPWindow->window is reserved (ignore) */ - kBitmap_ANPDrawingModel = 0, - /** Draw into a surface (e.g. raster, opengl, etc.)using the surface interface. - Unlike the bitmap model a surface model is opaque so no html content behind - the plugin will be visible. Unless the surface needs to be transparent the - surface model should be chosen over the bitmap model as it will have faster - performance. An example surface is the raster surface where the service - interface is used to lock/unlock and draw into bitmap without waiting for - draw events. Prior to requesting this drawing model the plugin must provide - the name of the Java class that implements the PluginStub interface via - kSetJavaClassName_ANPSetValue. - */ - kSurface_ANPDrawingModel = 1, + kBitmap_ANPDrawingModel = 1 << 0, + /** Draw into a surface (e.g. raster, openGL, etc.) using the Java surface + interface. When this model is used the browser will invoke the Java + class specified in the plugin's apk manifest. From that class the browser + will invoke the appropriate method to return an an instance of a android + Java View. The instance is then embedded in the html. The plugin can then + manipulate the view as it would any normal Java View in android. + + Unlike the bitmap model, a surface model is opaque so no html content + behind the plugin will be visible. Unless the plugin needs to be + transparent the surface model should be chosen over the bitmap model as + it will have better performance. + + Further, a plugin can manipulate some surfaces in native code using the + ANPSurfaceInterface. This interface can be used to manipulate Java + objects that extend Surface.class by allowing them to access the + surface's underlying bitmap in native code. For instance, if a raster + surface is used the plugin can lock, draw directly into the bitmap, and + unlock the surface in native code without making JNI calls to the Java + surface object. + */ + kSurface_ANPDrawingModel = 1 << 1, }; typedef int32_t ANPDrawingModel; @@ -181,7 +182,7 @@ typedef int32_t ANPDrawingModel; NPN_SetValue(inst, ANPAcceptEvents, (void*)EventFlags) */ -#define kAcceptEvents_ANPSetValue ((NPPVariable)1002) +#define kAcceptEvents_ANPSetValue ((NPPVariable)1001) /** The EventFlags are a set of bits used to determine which types of events the plugin wishes to receive. For example, if the value is 0x03 then both key @@ -193,6 +194,20 @@ enum ANPEventFlag { }; typedef uint32_t ANPEventFlags; +/////////////////////////////////////////////////////////////////////////////// +// NPP_GetValue + +/** Requests that the plugin return a java surface to be displayed. This will + only be used if the plugin has choosen the kSurface_ANPDrawingModel. + + NPP_GetValue(inst, kJavaSurface_ANPGetValue, jobject surface) + */ +#define kJavaSurface_ANPGetValue ((NPPVariable)2000) + + +/////////////////////////////////////////////////////////////////////////////// +// ANDROID INTERFACE DEFINITIONS + /** Interfaces provide additional functionality to the plugin via function ptrs. Once an interface is retrieved, it is valid for the lifetime of the plugin (just like browserfuncs). @@ -216,7 +231,7 @@ struct ANPLogInterfaceV0 : ANPInterface { /** dumps printf messages to the log file e.g. interface->log(instance, kWarning_ANPLogType, "value is %d", value); */ - void (*log)(NPP instance, ANPLogType, const char format[], ...); + void (*log)(ANPLogType, const char format[], ...); }; struct ANPBitmapInterfaceV0 : ANPInterface { @@ -622,23 +637,6 @@ struct ANPCanvasInterfaceV0 : ANPInterface { }; struct ANPWindowInterfaceV0 : ANPInterface { - /** Given the window field from the NPWindow struct, and an optional rect - describing the subset of the window that will be drawn to (may be null) - return true if the bitmap for that window can be accessed, and if so, - fill out the specified ANPBitmap to point to the window's pixels. - - When drawing is complete, call unlock(window) - */ - bool (*lockRect)(void* window, const ANPRectI* inval, ANPBitmap*); - /** The same as lockRect, but takes a region instead of a rect to specify - the area that will be changed/drawn. - */ - bool (*lockRegion)(void* window, const ANPRegion* inval, ANPBitmap*); - /** Given a successful call to lock(window, inval, &bitmap), call unlock - to release access to the pixels, and allow the browser to display the - results. If lock returned false, unlock should not be called. - */ - void (*unlock)(void* window); /** Registers a set of rectangles that the plugin would like to keep on screen. The rectangles are listed in order of priority with the highest priority rectangle in location rects[0]. The browser will attempt to keep @@ -660,10 +658,14 @@ struct ANPWindowInterfaceV0 : ANPInterface { */ void (*showKeyboard)(NPP instance, bool value); /** Called when a plugin wishes to enter into full screen mode. The plugin's - Java class (set using kSetPluginStubJavaClassName_ANPSetValue) will be - called asynchronously to provide a View object to be displayed full screen. + Java class (defined in the plugin's apk manifest) will be called + asynchronously to provide a View object to be displayed full screen. */ void (*requestFullScreen)(NPP instance); + /** Called when a plugin wishes to exit from full screen mode. As a result, + the plugin's full screen view will be discarded by the view system. + */ + void (*exitFullScreen)(NPP instance); }; /////////////////////////////////////////////////////////////////////////////// @@ -751,7 +753,7 @@ struct ANPAudioTrackInterfaceV0 : ANPInterface { }; /////////////////////////////////////////////////////////////////////////////// -// HandleEvent +// DEFINITION OF VALUES PASSED THROUGH NPP_HandleEvent enum ANPEventTypes { kNull_ANPEventType = 0, @@ -772,6 +774,21 @@ enum ANPEventTypes { */ kDraw_ANPEventType = 4, kLifecycle_ANPEventType = 5, + + /** This event type is completely defined by the plugin. + When creating an event, the caller must always set the first + two fields, the remaining data is optional. + ANPEvent evt; + evt.inSize = sizeof(ANPEvent); + evt.eventType = kCustom_ANPEventType + // other data slots are optional + evt.other[] = ...; + To post a copy of the event, call + eventInterface->postEvent(myNPPInstance, &evt); + That call makes a copy of the event struct, and post that on the event + queue for the plugin. + */ + kCustom_ANPEventType = 6, }; typedef int32_t ANPEventType; @@ -803,39 +820,73 @@ enum ANPTouchActions { the plugin chooses to not handle this action then no other events related to that particular touch gesture will be generated. */ - kDown_ANPTouchAction = 0, - kUp_ANPTouchAction = 1, - kMove_ANPTouchAction = 2, - kCancel_ANPTouchAction = 3, + kDown_ANPTouchAction = 0, + kUp_ANPTouchAction = 1, + kMove_ANPTouchAction = 2, + kCancel_ANPTouchAction = 3, + // The web view will ignore the return value from the following actions + kLongPress_ANPTouchAction = 4, + kDoubleTap_ANPTouchAction = 5, }; typedef int32_t ANPTouchAction; +/** + * When a plugin returns from NPP_HandleEvent() for a touch event, it can use + * ANPTouchResultMask to tell the web view which touch event it wants to handle. + * kHandleTouch_ANPTouchResult will handle all touch event inside the plugin. If + * it is not set, a plugin can choose only handle individual event like long + * press, or double tap. + */ +enum ANPTouchResultMask { + kHandleTouch_ANPTouchResult = 1, + kHandleLongPress_ANPTouchResult = 2, + kHandleDoubleTap_ANPTouchResult = 4, +}; + enum ANPLifecycleActions { /** The web view containing this plugin has been paused. See documentation on the android activity lifecycle for more information. */ - kPause_ANPLifecycleAction = 0, + kPause_ANPLifecycleAction = 0, /** The web view containing this plugin has been resumed. See documentation on the android activity lifecycle for more information. */ - kResume_ANPLifecycleAction = 1, + kResume_ANPLifecycleAction = 1, /** The plugin has focus and is now the recipient of input events (e.g. key, touch, etc.) */ - kGainFocus_ANPLifecycleAction = 2, + kGainFocus_ANPLifecycleAction = 2, /** The plugin has lost focus and will not receive any input events until it regains focus. This event is always preceded by a GainFocus action. */ - kLoseFocus_ANPLifecycleAction = 3, + kLoseFocus_ANPLifecycleAction = 3, /** The browser is running low on available memory and is requesting that the plugin free any unused/inactive resources to prevent a performance degradation. */ - kFreeMemory_ANPLifecycleAction = 4, + kFreeMemory_ANPLifecycleAction = 4, /** The page has finished loading. This happens when the page's top level frame reports that it has completed loading. */ - kOnLoad_ANPLifecycleAction = 5, + kOnLoad_ANPLifecycleAction = 5, + /** The browser is honoring the plugin's request to go full screen. Upon + returning from this event the browser will resize the plugin's java + surface to full-screen coordinates. + */ + kEnterFullScreen_ANPLifecycleAction = 6, + /** The browser has exited from full screen mode. Immediately prior to + sending this event the browser has resized the plugin's java surface to + its original coordinates. + */ + kExitFullScreen_ANPLifecycleAction = 7, + /** The plugin is visible to the user on the screen. This event will always + occur after a kOffScreen_ANPLifecycleAction event. + */ + kOnScreen_ANPLifecycleAction = 8, + /** The plugin is no longer visible to the user on the screen. This event + will always occur prior to an kOnScreen_ANPLifecycleAction event. + */ + kOffScreen_ANPLifecycleAction = 9, }; typedef uint32_t ANPLifecycleAction; @@ -880,15 +931,14 @@ struct ANPEvent { } data; }; -/////////////////////////////////////////////////////////////////////////////// -// System properties - -struct ANPSystemInterfaceV0 : ANPInterface { - /** Return the path name for the current Application's plugin data directory, - * or NULL if not supported +struct ANPEventInterfaceV0 : ANPInterface { + /** Post a copy of the specified event to the plugin. The event will be + delivered to the plugin in its main thread (the thread that receives + other ANPEvents). If, after posting before delivery, the NPP instance + is torn down, the event will be discarded. */ - const char* (*getApplicationDataDirectory)(); + void (*postEvent)(NPP inst, const ANPEvent* event); }; -#endif +#endif diff --git a/WebKit/android/stl/algorithm b/WebKit/android/stl/algorithm deleted file mode 100644 index 131fe0d..0000000 --- a/WebKit/android/stl/algorithm +++ /dev/null @@ -1,277 +0,0 @@ -#ifdef __cplusplus - -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996-1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - - // extracted from stl_algobase.h - // full STL is not compatible with the ARM build - // a limited number of STL functions is used by webkit: swap, max, and min are - // included below for webkit compatibility - -#ifdef __GLIBCPP_INTERNAL_ALGOBASE_H -#error "real STL defined" -#endif - -#ifndef __ANDROID_ALGORITHM -#define __ANDROID_ALGORITHM - -#ifndef __ANDROID_LIMITS -#include <limits> -#endif - -#ifndef _CPP_UTILITY -#include <utility> -#endif - -#include <SkScalar.h> // for SK_ScalarNaN -#ifdef PREFIX_FOR_WEBCORE -#include <SkTSearch.h> -#endif - -#include <float.h> -#include <math.h> -#include <stdint.h> -#include <stddef.h> - -#ifndef WCHAR_MAX - #define WCHAR_MAX 0xFFFF -#endif - -namespace std -{ - template<typename _Tp> - inline void - swap(_Tp& __a, _Tp& __b) - { - _Tp __tmp = __a; - __a = __b; - __b = __tmp; - } - - template<typename _Tp> - inline void - reverse(_Tp* __first, _Tp* __last) - { - while(true) - { - if (__first == __last || __first == --__last) - return; - else - { - _Tp __tmp = *__first; - *__first = *__last; - *__last = __tmp; - } - ++__first; - } - } - - #undef min - #undef max - - template<typename _Tp> - inline const _Tp& - min(const _Tp& __a, const _Tp& __b) - { - return __b < __a ? __b : __a; - } - - template<typename _Tp> - inline const _Tp& - max(const _Tp& __a, const _Tp& __b) - { - return __a < __b ? __b : __a; - } - -template <class _InputIter, class _OutputIter> -inline _OutputIter copy(_InputIter __first, _InputIter __last, - _OutputIter __result) -{ - for (size_t __n = __last - __first; __n > 0; --__n) { - *__result = *__first; - ++__first; - ++__result; - } - return __result; -} - -template <class _ForwardIter, class _Tp> -void fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __value) { - for ( ; __first != __last; ++__first) - *__first = __value; -} - -#ifndef UINTPTR_MAX -#define UINTPTR_MAX UINT32_MAX -#endif - -#ifndef UINT32_MAX -#define UINT32_MAX (0xffffffff) -#endif - -template <typename T> -struct numeric_limits { - /// Returns the minimum value for type T. - static inline T min (void) { return (T(0)); } - /// Returns the minimum value for type T. - static inline T max (void) { return (T(0)); } - static const bool is_signed = false; ///< True if the type is signed. - static const bool is_integer = false; ///< True if stores an exact value. - static const bool is_integral = false; ///< True if fixed size and cast-copyable. -}; - -template <typename T> -struct numeric_limits<T*> { - static inline T* min (void) { return (NULL); } - static inline T* max (void) { return (UINTPTR_MAX); } - static const bool is_signed = false; - static const bool is_integer = true; - static const bool is_integral = true; -}; - -#define _NUMERIC_LIMITS(type, minVal, maxVal, quietNaN, bSigned, bInteger, bIntegral) \ -template <> \ -struct numeric_limits<type> { \ - static inline type infinity (void) { return (maxVal); } \ - static inline type min (void) { return (minVal); } \ - static inline type max (void) { return (maxVal); } \ - static inline type quiet_NaN() { return (quietNaN); } \ - static const bool is_signed = bSigned; \ - static const bool is_integer = bInteger; \ - static const bool is_integral = bIntegral; \ -} - -//-------------------------------------------------------------------------------------- -// type min max NaN signed integer integral -//-------------------------------------------------------------------------------------- -_NUMERIC_LIMITS (bool, false, true, 0, false, true, true); -_NUMERIC_LIMITS (char, SCHAR_MIN, SCHAR_MAX, 0, true, true, true); -_NUMERIC_LIMITS (int, INT_MIN, INT_MAX, 0, true, true, true); -_NUMERIC_LIMITS (short, SHRT_MIN, SHRT_MAX, 0, true, true, true); -_NUMERIC_LIMITS (long, LONG_MIN, LONG_MAX, 0, true, true, true); -#if HAVE_THREE_CHAR_TYPES -_NUMERIC_LIMITS (signed char, SCHAR_MIN, SCHAR_MAX, 0, true, true, true); -#endif -_NUMERIC_LIMITS (unsigned char, 0, UCHAR_MAX, 0, false, true, true); -_NUMERIC_LIMITS (unsigned int, 0, UINT_MAX, 0, false, true, true); -_NUMERIC_LIMITS (unsigned short,0, USHRT_MAX, 0, false, true, true); -_NUMERIC_LIMITS (unsigned long, 0, ULONG_MAX, 0, false, true, true); -_NUMERIC_LIMITS (wchar_t, 0, WCHAR_MAX, 0, false, true, true); -_NUMERIC_LIMITS (float, FLT_MIN, FLT_MAX, SK_ScalarNaN, true, false, true); -_NUMERIC_LIMITS (double, DBL_MIN, DBL_MAX, SK_ScalarNaN, true, false, true); -_NUMERIC_LIMITS (long double, LDBL_MIN, LDBL_MAX, SK_ScalarNaN, true, false, true); -#ifdef HAVE_LONG_LONG -_NUMERIC_LIMITS (long long, LLONG_MIN, LLONG_MAX, 0, true, true, true); -_NUMERIC_LIMITS (unsigned long long, 0, ULLONG_MAX, 0, false, true, true); -#endif -//-------------------------------------------------------------------------------------- - -using ::ptrdiff_t; - -typedef bool (* Comparator)(const void*, const void*); -extern void sort(const void** start, const void** end, Comparator comp); - -#ifdef PREFIX_FOR_WEBCORE - typedef const void* sortType; - - inline bool binary_search(const unsigned short* const base, - const unsigned short* const end, - short target) - { - return SkTSearch<unsigned short>(base, end - base, target, sizeof(unsigned short)) >= 0; - } - - - template<typename P> inline void sort (P** start, P**end, - bool (* comp)(const P*, const P*)) - { - sort((const void**) start, (const void**) end, (Comparator) comp); - } - - template<typename P> void sort(P* start, P* end, - bool (* comp)(const P&, const P&)) { - stable_sort(start, end, *comp); - } - - template<typename P> inline void stable_sort(P** start, P** end, - bool (* comp)(P*, P*)) - { - sort((const void**) start, (const void**) end, (Comparator) comp); - } - - template<typename P> inline void stable_sort(P** start, P** end, - bool (& comp)(const P*, const P*)) - { - sort((const void**) start, (const void**) end, (Comparator) &comp); - } - - template<typename P> void stable_sort(P* start, P* end, P* temp, - bool (& comp)(const P&, const P&)) { - size_t endlen = end - start; - size_t midlen = endlen / 2; - P* mid = start + midlen; - if (midlen > 1) - stable_sort(start, mid, temp, comp); - if (end - mid > 1) - stable_sort(mid, end, temp, comp); - memcpy(temp, start, midlen * sizeof(*start)); - size_t i = 0; - size_t j = midlen; - size_t off = 0; - while (i < midlen && j < endlen) { - P* dst = (comp)(start[j], temp[i]) ? &start[j++] : &temp[i++]; - memcpy(&start[off++], dst, sizeof(*start)); - } - if (i < midlen) - memcpy(&start[off], &temp[i], (midlen - i) * sizeof(*start)); - } - - template<typename P> void stable_sort(P* start, P* end, - bool (& comp)(const P&, const P&)) { - if (end - start > 1) { - size_t count = (end - start) / 2; - P* temp = static_cast<P*>(malloc(count * sizeof(P))); - stable_sort(start, end, temp, comp); - free(temp); - } - } - - template<typename P> void stable_sort(P* start, P* end, - bool (& comp)(P, P)) { - stable_sort(start, end, (bool (&)(const P&, const P&))(comp)); - } - - class ostream { - int this_class_intentionally_left_empty; - }; -#endif - -} - -#endif - -#endif // __cplusplus - diff --git a/WebKit/android/stl/concept_checks.h b/WebKit/android/stl/concept_checks.h deleted file mode 100644 index 72cc138..0000000 --- a/WebKit/android/stl/concept_checks.h +++ /dev/null @@ -1,812 +0,0 @@ -/* - * Copyright 2009, The Android Open Source Project - * Copyright (c) 1999 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __CONCEPT_CHECKS_H -#define __CONCEPT_CHECKS_H - -/* - Use these macro like assertions, but they assert properties - on types (usually template arguments). In technical terms they - verify whether a type "models" a "concept". - - This set of requirements and the terminology used here is derived - from the book "Generic Programming and the STL" by Matt Austern - (Addison Wesley). For further information please consult that - book. The requirements also are intended to match the ANSI/ISO C++ - standard. - - This file covers the basic concepts and the iterator concepts. - There are several other files that provide the requirements - for the STL containers: - container_concepts.h - sequence_concepts.h - assoc_container_concepts.h - - Jeremy Siek, 1999 - - TO DO: - - some issues with regards to concept classification and mutability - including AssociativeContianer -> ForwardContainer - and SortedAssociativeContainer -> ReversibleContainer - - HashedAssociativeContainer - - Allocator - - Function Object Concepts - - */ - -#ifndef __STL_USE_CONCEPT_CHECKS - -// Some compilers lack the features that are necessary for concept checks. -// On those compilers we define the concept check macros to do nothing. -#define __STL_REQUIRES(__type_var, __concept) do {} while(0) -#define __STL_CLASS_REQUIRES(__type_var, __concept) \ - static int __##__type_var##_##__concept -#define __STL_CONVERTIBLE(__type_x, __type_y) do {} while(0) -#define __STL_REQUIRES_SAME_TYPE(__type_x, __type_y) do {} while(0) -#define __STL_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \ - static int __##__type_x##__type_y##_require_same_type -#define __STL_GENERATOR_CHECK(__func, __ret) do {} while(0) -#define __STL_CLASS_GENERATOR_CHECK(__func, __ret) \ - static int __##__func##__ret##_generator_check -#define __STL_UNARY_FUNCTION_CHECK(__func, __ret, __arg) do {} while(0) -#define __STL_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \ - static int __##__func##__ret##__arg##_unary_function_check -#define __STL_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ - do {} while(0) -#define __STL_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ - static int __##__func##__ret##__first##__second##_binary_function_check -#define __STL_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ - do {} while(0) -#define __STL_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ - static int __##__opname##__ret##__first##__second##_require_binary_op - -#else /* __STL_USE_CONCEPT_CHECKS */ - -// This macro tests whether the template argument "__type_var" -// satisfies the requirements of "__concept". Here is a list of concepts -// that we know how to check: -// _Allocator -// _Assignable -// _DefaultConstructible -// _EqualityComparable -// _LessThanComparable -// _TrivialIterator -// _InputIterator -// _OutputIterator -// _ForwardIterator -// _BidirectionalIterator -// _RandomAccessIterator -// _Mutable_TrivialIterator -// _Mutable_ForwardIterator -// _Mutable_BidirectionalIterator -// _Mutable_RandomAccessIterator - -#define __STL_REQUIRES(__type_var, __concept) \ -do { \ - void (*__x)( __type_var ) = __concept##_concept_specification< __type_var >\ - ::__concept##_requirement_violation; __x = __x; } while (0) - -// Use this to check whether type X is convertible to type Y -#define __STL_CONVERTIBLE(__type_x, __type_y) \ -do { \ - void (*__x)( __type_x , __type_y ) = _STL_CONVERT_ERROR< __type_x , \ - __type_y >::__type_X_is_not_convertible_to_type_Y; \ - __x = __x; } while (0) - -// Use this to test whether two template arguments are the same type -#define __STL_REQUIRES_SAME_TYPE(__type_x, __type_y) \ -do { \ - void (*__x)( __type_x , __type_y ) = _STL_SAME_TYPE_ERROR< __type_x, \ - __type_y >::__type_X_not_same_as_type_Y; \ - __x = __x; } while (0) - - -// function object checks -#define __STL_GENERATOR_CHECK(__func, __ret) \ -do { \ - __ret (*__x)( __func&) = \ - _STL_GENERATOR_ERROR< \ - __func, __ret>::__generator_requirement_violation; \ - __x = __x; } while (0) - - -#define __STL_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \ -do { \ - __ret (*__x)( __func&, const __arg& ) = \ - _STL_UNARY_FUNCTION_ERROR< \ - __func, __ret, __arg>::__unary_function_requirement_violation; \ - __x = __x; } while (0) - - -#define __STL_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ -do { \ - __ret (*__x)( __func&, const __first&, const __second& ) = \ - _STL_BINARY_FUNCTION_ERROR< \ - __func, __ret, __first, __second>::__binary_function_requirement_violation; \ - __x = __x; } while (0) - - -#define __STL_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ - do { \ - __ret (*__x)( __first&, __second& ) = _STL_BINARY##__opname##_ERROR< \ - __ret, __first, __second>::__binary_operator_requirement_violation; \ - __ret (*__y)( const __first&, const __second& ) = \ - _STL_BINARY##__opname##_ERROR< __ret, __first, __second>:: \ - __const_binary_operator_requirement_violation; \ - __y = __y; __x = __x; } while (0) - - -#ifdef __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE - -#define __STL_CLASS_REQUIRES(__type_var, __concept) -#define __STL_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) -#define __STL_CLASS_GENERATOR_CHECK(__func, __ret) -#define __STL_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) -#define __STL_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) -#define __STL_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) - -#else - -// Use this macro inside of template classes, where you would -// like to place requirements on the template arguments to the class -// Warning: do not pass pointers and such (e.g. T*) in as the __type_var, -// since the type_var is used to construct identifiers. Instead typedef -// the pointer type, then use the typedef name for the __type_var. -#define __STL_CLASS_REQUIRES(__type_var, __concept) \ - typedef void (* __func##__type_var##__concept)( __type_var ); \ - template <__func##__type_var##__concept _Tp1> \ - struct __dummy_struct_##__type_var##__concept { }; \ - static __dummy_struct_##__type_var##__concept< \ - __concept##_concept_specification< \ - __type_var>::__concept##_requirement_violation> \ - __dummy_ptr_##__type_var##__concept - - -#define __STL_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \ - typedef void (* __func_##__type_x##__type_y##same_type)( __type_x, \ - __type_y ); \ - template < __func_##__type_x##__type_y##same_type _Tp1> \ - struct __dummy_struct_##__type_x##__type_y##_same_type { }; \ - static __dummy_struct_##__type_x##__type_y##_same_type< \ - _STL_SAME_TYPE_ERROR<__type_x, __type_y>::__type_X_not_same_as_type_Y> \ - __dummy_ptr_##__type_x##__type_y##_same_type - - -#define __STL_CLASS_GENERATOR_CHECK(__func, __ret) \ - typedef __ret (* __f_##__func##__ret##_generator)( __func& ); \ - template <__f_##__func##__ret##_generator _Tp1> \ - struct __dummy_struct_##__func##__ret##_generator { }; \ - static __dummy_struct_##__func##__ret##_generator< \ - _STL_GENERATOR_ERROR< \ - __func, __ret>::__generator_requirement_violation> \ - __dummy_ptr_##__func##__ret##_generator - - -#define __STL_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \ - typedef __ret (* __f_##__func##__ret##__arg##_unary_check)( __func&, \ - const __arg& ); \ - template <__f_##__func##__ret##__arg##_unary_check _Tp1> \ - struct __dummy_struct_##__func##__ret##__arg##_unary_check { }; \ - static __dummy_struct_##__func##__ret##__arg##_unary_check< \ - _STL_UNARY_FUNCTION_ERROR< \ - __func, __ret, __arg>::__unary_function_requirement_violation> \ - __dummy_ptr_##__func##__ret##__arg##_unary_check - - -#define __STL_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \ - typedef __ret (* __f_##__func##__ret##__first##__second##_binary_check)( __func&, const __first&,\ - const __second& ); \ - template <__f_##__func##__ret##__first##__second##_binary_check _Tp1> \ - struct __dummy_struct_##__func##__ret##__first##__second##_binary_check { }; \ - static __dummy_struct_##__func##__ret##__first##__second##_binary_check< \ - _STL_BINARY_FUNCTION_ERROR<__func, __ret, __first, __second>:: \ - __binary_function_requirement_violation> \ - __dummy_ptr_##__func##__ret##__first##__second##_binary_check - - -#define __STL_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \ - typedef __ret (* __f_##__func##__ret##__first##__second##_binary_op)(const __first&, \ - const __second& ); \ - template <__f_##__func##__ret##__first##__second##_binary_op _Tp1> \ - struct __dummy_struct_##__func##__ret##__first##__second##_binary_op { }; \ - static __dummy_struct_##__func##__ret##__first##__second##_binary_op< \ - _STL_BINARY##__opname##_ERROR<__ret, __first, __second>:: \ - __binary_operator_requirement_violation> \ - __dummy_ptr_##__func##__ret##__first##__second##_binary_op - -#endif - -/* helper class for finding non-const version of a type. Need to have - something to assign to etc. when testing constant iterators. */ - -template <class _Tp> -struct _Mutable_trait { - typedef _Tp _Type; -}; -template <class _Tp> -struct _Mutable_trait<const _Tp> { - typedef _Tp _Type; -}; - - -/* helper function for avoiding compiler warnings about unused variables */ -template <class _Type> -void __sink_unused_warning(_Type) { } - -template <class _TypeX, class _TypeY> -struct _STL_CONVERT_ERROR { - static void - __type_X_is_not_convertible_to_type_Y(_TypeX __x, _TypeY) { - _TypeY __y = __x; - __sink_unused_warning(__y); - } -}; - - -template <class _Type> struct __check_equal { }; - -template <class _TypeX, class _TypeY> -struct _STL_SAME_TYPE_ERROR { - static void - __type_X_not_same_as_type_Y(_TypeX , _TypeY ) { - __check_equal<_TypeX> t1 = __check_equal<_TypeY>(); - } -}; - - -// Some Functon Object Checks - -template <class _Func, class _Ret> -struct _STL_GENERATOR_ERROR { - static _Ret __generator_requirement_violation(_Func& __f) { - return __f(); - } -}; - -template <class _Func> -struct _STL_GENERATOR_ERROR<_Func, void> { - static void __generator_requirement_violation(_Func& __f) { - __f(); - } -}; - - -template <class _Func, class _Ret, class _Arg> -struct _STL_UNARY_FUNCTION_ERROR { - static _Ret - __unary_function_requirement_violation(_Func& __f, - const _Arg& __arg) { - return __f(__arg); - } -}; - -template <class _Func, class _Arg> -struct _STL_UNARY_FUNCTION_ERROR<_Func, void, _Arg> { - static void - __unary_function_requirement_violation(_Func& __f, - const _Arg& __arg) { - __f(__arg); - } -}; - -template <class _Func, class _Ret, class _First, class _Second> -struct _STL_BINARY_FUNCTION_ERROR { - static _Ret - __binary_function_requirement_violation(_Func& __f, - const _First& __first, - const _Second& __second) { - return __f(__first, __second); - } -}; - -template <class _Func, class _First, class _Second> -struct _STL_BINARY_FUNCTION_ERROR<_Func, void, _First, _Second> { - static void - __binary_function_requirement_violation(_Func& __f, - const _First& __first, - const _Second& __second) { - __f(__first, __second); - } -}; - - -#define __STL_DEFINE_BINARY_OP_CHECK(_OP, _NAME) \ -template <class _Ret, class _First, class _Second> \ -struct _STL_BINARY##_NAME##_ERROR { \ - static _Ret \ - __const_binary_operator_requirement_violation(const _First& __first, \ - const _Second& __second) { \ - return __first _OP __second; \ - } \ - static _Ret \ - __binary_operator_requirement_violation(_First& __first, \ - _Second& __second) { \ - return __first _OP __second; \ - } \ -} - -__STL_DEFINE_BINARY_OP_CHECK(==, _OP_EQUAL); -__STL_DEFINE_BINARY_OP_CHECK(!=, _OP_NOT_EQUAL); -__STL_DEFINE_BINARY_OP_CHECK(<, _OP_LESS_THAN); -__STL_DEFINE_BINARY_OP_CHECK(<=, _OP_LESS_EQUAL); -__STL_DEFINE_BINARY_OP_CHECK(>, _OP_GREATER_THAN); -__STL_DEFINE_BINARY_OP_CHECK(>=, _OP_GREATER_EQUAL); -__STL_DEFINE_BINARY_OP_CHECK(+, _OP_PLUS); -__STL_DEFINE_BINARY_OP_CHECK(*, _OP_TIMES); -__STL_DEFINE_BINARY_OP_CHECK(/, _OP_DIVIDE); -__STL_DEFINE_BINARY_OP_CHECK(-, _OP_SUBTRACT); -__STL_DEFINE_BINARY_OP_CHECK(%, _OP_MOD); -// ... - -// TODO, add unary operators (prefix and postfix) - -/* - The presence of this class is just to trick EDG into displaying - these error messages before any other errors. Without the - classes, the errors in the functions get reported after - other class errors deep inside the library. The name - choice just makes for an eye catching error message :) - */ -struct _STL_ERROR { - - template <class _Type> - static _Type - __default_constructor_requirement_violation(_Type) { - return _Type(); - } - template <class _Type> - static _Type - __assignment_operator_requirement_violation(_Type __a) { - __a = __a; - return __a; - } - template <class _Type> - static _Type - __copy_constructor_requirement_violation(_Type __a) { - _Type __c(__a); - return __c; - } - template <class _Type> - static _Type - __const_parameter_required_for_copy_constructor(_Type /* __a */, - const _Type& __b) { - _Type __c(__b); - return __c; - } - template <class _Type> - static _Type - __const_parameter_required_for_assignment_operator(_Type __a, - const _Type& __b) { - __a = __b; - return __a; - } - template <class _Type> - static _Type - __less_than_comparable_requirement_violation(_Type __a, _Type __b) { - if (__a < __b || __a > __b || __a <= __b || __a >= __b) return __a; - return __b; - } - template <class _Type> - static _Type - __equality_comparable_requirement_violation(_Type __a, _Type __b) { - if (__a == __b || __a != __b) return __a; - return __b; - } - template <class _Iterator> - static void - __dereference_operator_requirement_violation(_Iterator __i) { - __sink_unused_warning(*__i); - } - template <class _Iterator> - static void - __dereference_operator_and_assignment_requirement_violation(_Iterator __i) { - *__i = *__i; - } - template <class _Iterator> - static void - __preincrement_operator_requirement_violation(_Iterator __i) { - ++__i; - } - template <class _Iterator> - static void - __postincrement_operator_requirement_violation(_Iterator __i) { - __i++; - } - template <class _Iterator> - static void - __predecrement_operator_requirement_violation(_Iterator __i) { - --__i; - } - template <class _Iterator> - static void - __postdecrement_operator_requirement_violation(_Iterator __i) { - __i--; - } - template <class _Iterator, class _Type> - static void - __postincrement_operator_and_assignment_requirement_violation(_Iterator __i, - _Type __t) { - *__i++ = __t; - } - template <class _Iterator, class _Distance> - static _Iterator - __iterator_addition_assignment_requirement_violation(_Iterator __i, - _Distance __n) { - __i += __n; - return __i; - } - template <class _Iterator, class _Distance> - static _Iterator - __iterator_addition_requirement_violation(_Iterator __i, _Distance __n) { - __i = __i + __n; - __i = __n + __i; - return __i; - } - template <class _Iterator, class _Distance> - static _Iterator - __iterator_subtraction_assignment_requirement_violation(_Iterator __i, - _Distance __n) { - __i -= __n; - return __i; - } - template <class _Iterator, class _Distance> - static _Iterator - __iterator_subtraction_requirement_violation(_Iterator __i, _Distance __n) { - __i = __i - __n; - return __i; - } - template <class _Iterator, class _Distance> - static _Distance - __difference_operator_requirement_violation(_Iterator __i, _Iterator __j, - _Distance __n) { - __n = __i - __j; - return __n; - } - template <class _Exp, class _Type, class _Distance> - static _Type - __element_access_operator_requirement_violation(_Exp __x, _Type*, - _Distance __n) { - return __x[__n]; - } - template <class _Exp, class _Type, class _Distance> - static void - __element_assignment_operator_requirement_violation(_Exp __x, - _Type* __t, - _Distance __n) { - __x[__n] = *__t; - } - -}; /* _STL_ERROR */ - -/* Associated Type Requirements */ - -__STL_BEGIN_NAMESPACE -template <class _Iterator> struct iterator_traits; -__STL_END_NAMESPACE - -template <class _Iter> -struct __value_type_type_definition_requirement_violation { - typedef typename __STD::iterator_traits<_Iter>::value_type value_type; -}; - -template <class _Iter> -struct __difference_type_type_definition_requirement_violation { - typedef typename __STD::iterator_traits<_Iter>::difference_type - difference_type; -}; - -template <class _Iter> -struct __reference_type_definition_requirement_violation { - typedef typename __STD::iterator_traits<_Iter>::reference reference; -}; - -template <class _Iter> -struct __pointer_type_definition_requirement_violation { - typedef typename __STD::iterator_traits<_Iter>::pointer pointer; -}; - -template <class _Iter> -struct __iterator_category_type_definition_requirement_violation { - typedef typename __STD::iterator_traits<_Iter>::iterator_category - iterator_category; -}; - -/* Assignable Requirements */ - - -template <class _Type> -struct _Assignable_concept_specification { - static void _Assignable_requirement_violation(_Type __a) { - _STL_ERROR::__assignment_operator_requirement_violation(__a); - _STL_ERROR::__copy_constructor_requirement_violation(__a); - _STL_ERROR::__const_parameter_required_for_copy_constructor(__a,__a); - _STL_ERROR::__const_parameter_required_for_assignment_operator(__a,__a); - } -}; - -/* DefaultConstructible Requirements */ - - -template <class _Type> -struct _DefaultConstructible_concept_specification { - static void _DefaultConstructible_requirement_violation(_Type __a) { - _STL_ERROR::__default_constructor_requirement_violation(__a); - } -}; - -/* EqualityComparable Requirements */ - -template <class _Type> -struct _EqualityComparable_concept_specification { - static void _EqualityComparable_requirement_violation(_Type __a) { - _STL_ERROR::__equality_comparable_requirement_violation(__a, __a); - } -}; - -/* LessThanComparable Requirements */ -template <class _Type> -struct _LessThanComparable_concept_specification { - static void _LessThanComparable_requirement_violation(_Type __a) { - _STL_ERROR::__less_than_comparable_requirement_violation(__a, __a); - } -}; - -/* TrivialIterator Requirements */ - -template <class _TrivialIterator> -struct _TrivialIterator_concept_specification { -static void -_TrivialIterator_requirement_violation(_TrivialIterator __i) { - typedef typename - __value_type_type_definition_requirement_violation<_TrivialIterator>:: - value_type __T; - // Refinement of Assignable - _Assignable_concept_specification<_TrivialIterator>:: - _Assignable_requirement_violation(__i); - // Refinement of DefaultConstructible - _DefaultConstructible_concept_specification<_TrivialIterator>:: - _DefaultConstructible_requirement_violation(__i); - // Refinement of EqualityComparable - _EqualityComparable_concept_specification<_TrivialIterator>:: - _EqualityComparable_requirement_violation(__i); - // Valid Expressions - _STL_ERROR::__dereference_operator_requirement_violation(__i); -} -}; - -template <class _TrivialIterator> -struct _Mutable_TrivialIterator_concept_specification { -static void -_Mutable_TrivialIterator_requirement_violation(_TrivialIterator __i) { - _TrivialIterator_concept_specification<_TrivialIterator>:: - _TrivialIterator_requirement_violation(__i); - // Valid Expressions - _STL_ERROR::__dereference_operator_and_assignment_requirement_violation(__i); -} -}; - -/* InputIterator Requirements */ - -template <class _InputIterator> -struct _InputIterator_concept_specification { -static void -_InputIterator_requirement_violation(_InputIterator __i) { - // Refinement of TrivialIterator - _TrivialIterator_concept_specification<_InputIterator>:: - _TrivialIterator_requirement_violation(__i); - // Associated Types - __difference_type_type_definition_requirement_violation<_InputIterator>(); - __reference_type_definition_requirement_violation<_InputIterator>(); - __pointer_type_definition_requirement_violation<_InputIterator>(); - __iterator_category_type_definition_requirement_violation<_InputIterator>(); - // Valid Expressions - _STL_ERROR::__preincrement_operator_requirement_violation(__i); - _STL_ERROR::__postincrement_operator_requirement_violation(__i); -} -}; - -/* OutputIterator Requirements */ - -template <class _OutputIterator> -struct _OutputIterator_concept_specification { -static void -_OutputIterator_requirement_violation(_OutputIterator __i) { - // Refinement of Assignable - _Assignable_concept_specification<_OutputIterator>:: - _Assignable_requirement_violation(__i); - // Associated Types - __iterator_category_type_definition_requirement_violation<_OutputIterator>(); - // Valid Expressions - _STL_ERROR::__dereference_operator_requirement_violation(__i); - _STL_ERROR::__preincrement_operator_requirement_violation(__i); - _STL_ERROR::__postincrement_operator_requirement_violation(__i); - _STL_ERROR:: - __postincrement_operator_and_assignment_requirement_violation(__i, *__i); -} -}; - -/* ForwardIterator Requirements */ - -template <class _ForwardIterator> -struct _ForwardIterator_concept_specification { -static void -_ForwardIterator_requirement_violation(_ForwardIterator __i) { - // Refinement of InputIterator - _InputIterator_concept_specification<_ForwardIterator>:: - _InputIterator_requirement_violation(__i); -} -}; - -template <class _ForwardIterator> -struct _Mutable_ForwardIterator_concept_specification { -static void -_Mutable_ForwardIterator_requirement_violation(_ForwardIterator __i) { - _ForwardIterator_concept_specification<_ForwardIterator>:: - _ForwardIterator_requirement_violation(__i); - // Refinement of OutputIterator - _OutputIterator_concept_specification<_ForwardIterator>:: - _OutputIterator_requirement_violation(__i); -} -}; - -/* BidirectionalIterator Requirements */ - -template <class _BidirectionalIterator> -struct _BidirectionalIterator_concept_specification { -static void -_BidirectionalIterator_requirement_violation(_BidirectionalIterator __i) { - // Refinement of ForwardIterator - _ForwardIterator_concept_specification<_BidirectionalIterator>:: - _ForwardIterator_requirement_violation(__i); - // Valid Expressions - _STL_ERROR::__predecrement_operator_requirement_violation(__i); - _STL_ERROR::__postdecrement_operator_requirement_violation(__i); -} -}; - -template <class _BidirectionalIterator> -struct _Mutable_BidirectionalIterator_concept_specification { -static void -_Mutable_BidirectionalIterator_requirement_violation( - _BidirectionalIterator __i) -{ - _BidirectionalIterator_concept_specification<_BidirectionalIterator>:: - _BidirectionalIterator_requirement_violation(__i); - // Refinement of mutable_ForwardIterator - _Mutable_ForwardIterator_concept_specification<_BidirectionalIterator>:: - _Mutable_ForwardIterator_requirement_violation(__i); - typedef typename - __value_type_type_definition_requirement_violation< - _BidirectionalIterator>::value_type __T; - typename _Mutable_trait<__T>::_Type* __tmp_ptr = 0; - // Valid Expressions - _STL_ERROR:: - __postincrement_operator_and_assignment_requirement_violation(__i, - *__tmp_ptr); -} -}; - -/* RandomAccessIterator Requirements */ - -template <class _RandAccIter> -struct _RandomAccessIterator_concept_specification { -static void -_RandomAccessIterator_requirement_violation(_RandAccIter __i) { - // Refinement of BidirectionalIterator - _BidirectionalIterator_concept_specification<_RandAccIter>:: - _BidirectionalIterator_requirement_violation(__i); - // Refinement of LessThanComparable - _LessThanComparable_concept_specification<_RandAccIter>:: - _LessThanComparable_requirement_violation(__i); - typedef typename - __value_type_type_definition_requirement_violation<_RandAccIter> - ::value_type - value_type; - typedef typename - __difference_type_type_definition_requirement_violation<_RandAccIter> - ::difference_type - _Dist; - typedef typename _Mutable_trait<_Dist>::_Type _MutDist; - - // Valid Expressions - _STL_ERROR::__iterator_addition_assignment_requirement_violation(__i, - _MutDist()); - _STL_ERROR::__iterator_addition_requirement_violation(__i, - _MutDist()); - _STL_ERROR:: - __iterator_subtraction_assignment_requirement_violation(__i, - _MutDist()); - _STL_ERROR::__iterator_subtraction_requirement_violation(__i, - _MutDist()); - _STL_ERROR::__difference_operator_requirement_violation(__i, __i, - _MutDist()); - typename _Mutable_trait<value_type>::_Type* __dummy_ptr = 0; - _STL_ERROR::__element_access_operator_requirement_violation(__i, - __dummy_ptr, - _MutDist()); -} -}; - -template <class _RandAccIter> -struct _Mutable_RandomAccessIterator_concept_specification { -static void -_Mutable_RandomAccessIterator_requirement_violation(_RandAccIter __i) -{ - _RandomAccessIterator_concept_specification<_RandAccIter>:: - _RandomAccessIterator_requirement_violation(__i); - // Refinement of mutable_BidirectionalIterator - _Mutable_BidirectionalIterator_concept_specification<_RandAccIter>:: - _Mutable_BidirectionalIterator_requirement_violation(__i); - typedef typename - __value_type_type_definition_requirement_violation<_RandAccIter> - ::value_type - value_type; - typedef typename - __difference_type_type_definition_requirement_violation<_RandAccIter> - ::difference_type - _Dist; - - typename _Mutable_trait<value_type>::_Type* __tmp_ptr = 0; - // Valid Expressions - _STL_ERROR::__element_assignment_operator_requirement_violation(__i, - __tmp_ptr, _Dist()); -} -}; - -#define __STL_TYPEDEF_REQUIREMENT(__REQUIREMENT) \ -template <class Type> \ -struct __##__REQUIREMENT##__typedef_requirement_violation { \ - typedef typename Type::__REQUIREMENT __REQUIREMENT; \ -} - -__STL_TYPEDEF_REQUIREMENT(value_type); -__STL_TYPEDEF_REQUIREMENT(difference_type); -__STL_TYPEDEF_REQUIREMENT(size_type); -__STL_TYPEDEF_REQUIREMENT(reference); -__STL_TYPEDEF_REQUIREMENT(const_reference); -__STL_TYPEDEF_REQUIREMENT(pointer); -__STL_TYPEDEF_REQUIREMENT(const_pointer); - - -template <class _Alloc> -struct _Allocator_concept_specification { -static void -_Allocator_requirement_violation(_Alloc __a) { - // Refinement of DefaultConstructible - _DefaultConstructible_concept_specification<_Alloc>:: - _DefaultConstructible_requirement_violation(__a); - // Refinement of EqualityComparable - _EqualityComparable_concept_specification<_Alloc>:: - _EqualityComparable_requirement_violation(__a); - // Associated Types - __value_type__typedef_requirement_violation<_Alloc>(); - __difference_type__typedef_requirement_violation<_Alloc>(); - __size_type__typedef_requirement_violation<_Alloc>(); - __reference__typedef_requirement_violation<_Alloc>(); - __const_reference__typedef_requirement_violation<_Alloc>(); - __pointer__typedef_requirement_violation<_Alloc>(); - __const_pointer__typedef_requirement_violation<_Alloc>(); - typedef typename _Alloc::value_type _Tp; - //__STL_REQUIRES_SAME_TYPE(typename _Alloc::__STL_TEMPLATE rebind<_Tp>::other, - // _Alloc); -} -}; - -#endif /* __STL_USE_CONCEPT_CHECKS */ - -#endif /* __CONCEPT_CHECKS_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/WebKit/android/stl/cstring b/WebKit/android/stl/cstring deleted file mode 100644 index 77c9175..0000000 --- a/WebKit/android/stl/cstring +++ /dev/null @@ -1,128 +0,0 @@ -// -*- C++ -*- forwarding header. - -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 -// Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2, 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 General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// -// ISO C++ 14882: 20.4.6 C library -// - -/** @file cstring - * This is a Standard C++ Library file. You should @c #include this file - * in your programs, rather than any of the "*.h" implementation files. - * - * This is the C++ version of the Standard C Library header @c string.h, - * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. - */ - -#ifndef _GLIBCXX_CSTRING -#define _GLIBCXX_CSTRING 1 - -#pragma GCC system_header - -#include <cstddef> - -#include <string.h> - -// Get rid of those macros defined in <string.h> in lieu of real functions. -#undef memcpy -#undef memmove -#undef strcpy -#undef strncpy -#undef strcat -#undef strncat -#undef memcmp -#undef strcmp -#undef strcoll -#undef strncmp -#undef strxfrm -#undef memchr -#undef strchr -#undef strcspn -#undef strpbrk -#undef strrchr -#undef strspn -#undef strstr -#undef strtok -#undef memset -#undef strerror -#undef strlen - -namespace std -{ - using ::memcpy; - using ::memmove; - using ::strcpy; - using ::strncpy; - using ::strcat; - using ::strncat; - using ::memcmp; - using ::strcmp; -// using ::strcoll; - using ::strncmp; -// using ::strxfrm; - using ::strcspn; - using ::strspn; - using ::strtok; - using ::memset; - using ::strerror; - using ::strlen; - - using ::memchr; - - inline void* - memchr(void* __p, int __c, size_t __n) - { return memchr(const_cast<const void*>(__p), __c, __n); } - - using ::strchr; - - inline char* - strchr(char* __s1, int __n) - { return __builtin_strchr(const_cast<const char*>(__s1), __n); } - - using ::strpbrk; - - inline char* - strpbrk(char* __s1, const char* __s2) - { return __builtin_strpbrk(const_cast<const char*>(__s1), __s2); } - - using ::strrchr; - - inline char* - strrchr(char* __s1, int __n) - { return __builtin_strrchr(const_cast<const char*>(__s1), __n); } - - using ::strstr; - - inline char* - strstr(char* __s1, const char* __s2) - { return __builtin_strstr(const_cast<const char*>(__s1), __s2); } -} - -#endif diff --git a/WebKit/android/stl/heap.h b/WebKit/android/stl/heap.h deleted file mode 100644 index 70d2249..0000000 --- a/WebKit/android/stl/heap.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Copyright 2009, The Android Open Source Project - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * Copyright (c) 1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef __SGI_STL_HEAP_H -#define __SGI_STL_HEAP_H - -#include <concept_checks.h> -#include <stl_config.h> -#include <stl_heap.h> - -#ifdef __STL_USE_NAMESPACES - -using __STD::push_heap; -using __STD::pop_heap; -using __STD::make_heap; -using __STD::sort_heap; - -#endif /* __STL_USE_NAMESPACES */ - - -#endif /* __SGI_STL_HEAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/WebKit/android/stl/memory b/WebKit/android/stl/memory deleted file mode 100644 index b224c33..0000000 --- a/WebKit/android/stl/memory +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 1997-1999 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -//minimal file to get build to work - -#ifdef _CPP_MEMORY -#error "real STL defined" -#endif - -#ifndef __ANDROID_MEMORY -#define __ANDROID_MEMORY -//we good to do this? -#define __STL_MEMBER_TEMPLATES - -#define __STL_NOTHROW - -/*#if defined(__SGI_STL_USE_AUTO_PTR_CONVERSIONS) && \*/ - -#if defined(__STL_MEMBER_TEMPLATES) -template<class _Tp1> struct auto_ptr_ref { - _Tp1* _M_ptr; - auto_ptr_ref(_Tp1* __p) : _M_ptr(__p) {} -}; -#endif - -namespace std { - -template <class _Tp> class auto_ptr { -private: - _Tp* _M_ptr; - -public: - typedef _Tp element_type; - - explicit auto_ptr(_Tp* __p = 0) __STL_NOTHROW : _M_ptr(__p) {} - auto_ptr(auto_ptr& __a) __STL_NOTHROW : _M_ptr(__a.release()) {} - -#ifdef __STL_MEMBER_TEMPLATES - template <class _Tp1> auto_ptr(auto_ptr<_Tp1>& __a) __STL_NOTHROW - : _M_ptr(__a.release()) {} -#endif /* __STL_MEMBER_TEMPLATES */ - - auto_ptr& operator=(auto_ptr& __a) __STL_NOTHROW { - if (&__a != this) { - delete _M_ptr; - _M_ptr = __a.release(); - } - return *this; - } - -#ifdef __STL_MEMBER_TEMPLATES - template <class _Tp1> - auto_ptr& operator=(auto_ptr<_Tp1>& __a) __STL_NOTHROW { - if (__a.get() != this->get()) { - delete _M_ptr; - _M_ptr = __a.release(); - } - return *this; - } -#endif /* __STL_MEMBER_TEMPLATES */ - - // Note: The C++ standard says there is supposed to be an empty throw - // specification here, but omitting it is standard conforming. Its - // presence can be detected only if _Tp::~_Tp() throws, but (17.4.3.6/2) - // this is prohibited. - ~auto_ptr() { delete _M_ptr; } - - _Tp& operator*() const __STL_NOTHROW { - return *_M_ptr; - } - _Tp* operator->() const __STL_NOTHROW { - return _M_ptr; - } - _Tp* get() const __STL_NOTHROW { - return _M_ptr; - } - _Tp* release() __STL_NOTHROW { - _Tp* __tmp = _M_ptr; - _M_ptr = 0; - return __tmp; - } - void reset(_Tp* __p = 0) __STL_NOTHROW { - if (__p != _M_ptr) { - delete _M_ptr; - _M_ptr = __p; - } - } - -/*#if defined(__SGI_STL_USE_AUTO_PTR_CONVERSIONS) && \*/ -#if defined(__STL_MEMBER_TEMPLATES) - -public: - auto_ptr(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW - : _M_ptr(__ref._M_ptr) {} - - auto_ptr& operator=(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW { - if (__ref._M_ptr != this->get()) { - delete _M_ptr; - _M_ptr = __ref._M_ptr; - } - return *this; - } - - template <class _Tp1> operator auto_ptr_ref<_Tp1>() __STL_NOTHROW - { return auto_ptr_ref<_Tp1>(this->release()); } - template <class _Tp1> operator auto_ptr<_Tp1>() __STL_NOTHROW - { return auto_ptr<_Tp1>(this->release()); } - -#endif /* auto ptr conversions && member templates */ - -}; - -} //namespace std - -#endif /* __ANDROID_MEMORY */ - - -// Local Variables: -// mode:C++ -// End: - diff --git a/WebKit/android/stl/stl_config.h b/WebKit/android/stl/stl_config.h deleted file mode 100644 index 448babc..0000000 --- a/WebKit/android/stl/stl_config.h +++ /dev/null @@ -1,577 +0,0 @@ -/* - * - * Copyright 2009, The Android Open Source Project - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * Copyright (c) 1997 - * Silicon Graphics - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef __STL_CONFIG_H -# define __STL_CONFIG_H - -// Flags: -// * __STL_NO_BOOL: defined if the compiler doesn't have bool as a builtin -// type. -// * __STL_HAS_WCHAR_T: defined if the compier has wchar_t as a builtin type. -// * __STL_NO_DRAND48: defined if the compiler doesn't have the drand48 -// function. -// * __STL_STATIC_TEMPLATE_MEMBER_BUG: defined if the compiler can't handle -// static members of template classes. -// * __STL_STATIC_CONST_INIT_BUG: defined if the compiler can't handle a -// constant-initializer in the declaration of a static const data member -// of integer type. (See section 9.4.2, paragraph 4, of the C++ standard.) -// * __STL_CLASS_PARTIAL_SPECIALIZATION: defined if the compiler supports -// partial specialization of template classes. -// * __STL_PARTIAL_SPECIALIZATION_SYNTAX: defined if the compiler -// supports partial specialization syntax for full specialization of -// class templates. (Even if it doesn't actually support partial -// specialization itself.) -// * __STL_FUNCTION_TMPL_PARTIAL_ORDER: defined if the compiler supports -// partial ordering of function templates. (a.k.a partial specialization -// of function templates.) -// * __STL_MEMBER_TEMPLATES: defined if the compiler supports template -// member functions of classes. -// * __STL_MEMBER_TEMPLATE_CLASSES: defined if the compiler supports -// nested classes that are member templates of other classes. -// * __STL_TEMPLATE_FRIENDS: defined if the compiler supports templatized -// friend declarations. -// * __STL_EXPLICIT_FUNCTION_TMPL_ARGS: defined if the compiler -// supports calling a function template by providing its template -// arguments explicitly. -// * __STL_LIMITED_DEFAULT_TEMPLATES: defined if the compiler is unable -// to handle default template parameters that depend on previous template -// parameters. -// * __STL_NON_TYPE_TMPL_PARAM_BUG: defined if the compiler has trouble with -// function template argument deduction for non-type template parameters. -// * __SGI_STL_NO_ARROW_OPERATOR: defined if the compiler is unable -// to support the -> operator for iterators. -// * __STL_DEFAULT_CONSTRUCTOR_BUG: defined if T() does not work properly -// when T is a builtin type. -// * __STL_USE_EXCEPTIONS: defined if the compiler (in the current compilation -// mode) supports exceptions. -// * __STL_USE_NAMESPACES: defined if the compiler has the necessary -// support for namespaces. -// * __STL_NO_EXCEPTION_HEADER: defined if the compiler does not have a -// standard-conforming header <exception>. -// * __STL_NO_BAD_ALLOC: defined if the compiler does not have a <new> -// header, or if <new> does not contain a bad_alloc class. If a bad_alloc -// class exists, it is assumed to be in namespace std. -// * __STL_SGI_THREADS: defined if this is being compiled for an SGI IRIX -// system in multithreaded mode, using native SGI threads instead of -// pthreads. -// * __STL_WIN32THREADS: defined if this is being compiled on a WIN32 -// compiler in multithreaded mode. -// * __STL_PTHREADS: defined if we should use portable pthreads -// synchronization. -// * __STL_UITHREADS: defined if we should use UI / solaris / UnixWare threads -// synchronization. UIthreads are similar to pthreads, but are based -// on an earlier version of the Posix threads standard. -// * __STL_LONG_LONG if the compiler has long long and unsigned long long -// types. (They're not in the C++ standard, but they are expected to be -// included in the forthcoming C9X standard.) -// * __STL_THREADS is defined if thread safety is needed. -// * __STL_VOLATILE is defined to be "volatile" if threads are being -// used, and the empty string otherwise. -// * __STL_USE_CONCEPT_CHECKS enables some extra compile-time error -// checking to make sure that user-defined template arguments satisfy -// all of the appropriate requirements. This may result in more -// comprehensible error messages. It incurs no runtime overhead. This -// feature requires member templates and partial specialization. -// * __STL_NO_USING_CLAUSE_IN_CLASS: The compiler does not handle "using" -// clauses inside of class definitions. -// * __STL_NO_FRIEND_TEMPLATE_CLASS: The compiler does not handle friend -// declaractions where the friend is a template class. -// * __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE: The compiler does not -// support the use of a function pointer type as the argument -// for a template. -// * __STL_MEMBER_TEMPLATE_KEYWORD: standard C++ requires the template -// keyword in a few new places (14.2.4). This flag is set for -// compilers that support (and require) this usage. - - -// User-settable macros that control compilation: -// * __STL_USE_SGI_ALLOCATORS: if defined, then the STL will use older -// SGI-style allocators, instead of standard-conforming allocators, -// even if the compiler supports all of the language features needed -// for standard-conforming allocators. -// * __STL_NO_NAMESPACES: if defined, don't put the library in namespace -// std, even if the compiler supports namespaces. -// * __STL_NO_RELOPS_NAMESPACE: if defined, don't put the relational -// operator templates (>, <=. >=, !=) in namespace std::rel_ops, even -// if the compiler supports namespaces and partial ordering of -// function templates. -// * __STL_ASSERTIONS: if defined, then enable runtime checking through the -// __stl_assert macro. -// * _PTHREADS: if defined, use Posix threads for multithreading support. -// * _UITHREADS:if defined, use SCO/Solaris/UI threads for multithreading -// support -// * _NOTHREADS: if defined, don't use any multithreading support. -// * _STL_NO_CONCEPT_CHECKS: if defined, disables the error checking that -// we get from __STL_USE_CONCEPT_CHECKS. -// * __STL_USE_NEW_IOSTREAMS: if defined, then the STL will use new, -// standard-conforming iostreams (e.g. the <iosfwd> header). If not -// defined, the STL will use old cfront-style iostreams (e.g. the -// <iostream.h> header). - -// Other macros defined by this file: - -// * bool, true, and false, if __STL_NO_BOOL is defined. -// * typename, as a null macro if it's not already a keyword. -// * explicit, as a null macro if it's not already a keyword. -// * namespace-related macros (__STD, __STL_BEGIN_NAMESPACE, etc.) -// * exception-related macros (__STL_TRY, __STL_UNWIND, etc.) -// * __stl_assert, either as a test or as a null macro, depending on -// whether or not __STL_ASSERTIONS is defined. - -# if defined(_PTHREADS) && !defined(_NOTHREADS) -# define __STL_PTHREADS -# endif - -# if defined(_UITHREADS) && !defined(_PTHREADS) && !defined(_NOTHREADS) -# define __STL_UITHREADS -# endif - -# if defined(__sgi) && !defined(__GNUC__) -# include <standards.h> -# if !defined(_BOOL) -# define __STL_NO_BOOL -# endif -# if defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32 -# define __STL_STATIC_CONST_INIT_BUG -# endif -# if defined(_WCHAR_T_IS_KEYWORD) -# define __STL_HAS_WCHAR_T -# endif -# if !defined(_TYPENAME_IS_KEYWORD) -# define __STL_NEED_TYPENAME -# endif -# ifdef _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# endif -# if (_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32 -# define __STL_FUNCTION_TMPL_PARTIAL_ORDER -# endif -# ifdef _MEMBER_TEMPLATES -# define __STL_MEMBER_TEMPLATES -# define __STL_TEMPLATE_FRIENDS -# define __STL_MEMBER_TEMPLATE_CLASSES -# endif -# if defined(_MEMBER_TEMPLATE_KEYWORD) -# define __STL_MEMBER_TEMPLATE_KEYWORD -# endif -# if defined(_STANDARD_C_PLUS_PLUS) -# define __STL_EXPLICIT_FUNCTION_TMPL_ARGS -# endif -# if (_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32 -# define __STL_MEMBER_TEMPLATE_KEYWORD -# endif -# if COMPILER_VERSION < 720 || (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) -# define __STL_DEFAULT_CONSTRUCTOR_BUG -# endif -# if !defined(_EXPLICIT_IS_KEYWORD) -# define __STL_NEED_EXPLICIT -# endif -# ifdef __EXCEPTIONS -# define __STL_USE_EXCEPTIONS -# endif -# if (_COMPILER_VERSION >= 721) && defined(_NAMESPACES) -# define __STL_HAS_NAMESPACES -# endif -# if (_COMPILER_VERSION < 721) || \ - !defined(__STL_HAS_NAMESPACES) || defined(__STL_NO_NAMESPACES) -# define __STL_NO_EXCEPTION_HEADER -# endif -# if _COMPILER_VERSION < 730 || !defined(_STANDARD_C_PLUS_PLUS) || \ - !defined(_NAMESPACES) -# define __STL_NO_BAD_ALLOC -# endif -# if !defined(_NOTHREADS) && !defined(__STL_PTHREADS) -# define __STL_SGI_THREADS -# endif -# if defined(_LONGLONG) && defined(_SGIAPI) && _SGIAPI -# define __STL_LONG_LONG -# endif -# if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS) -# define __STL_USE_NEW_IOSTREAMS -# endif -# if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS) -# define __STL_CAN_THROW_RANGE_ERRORS -# endif -# if _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS) -# define __SGI_STL_USE_AUTO_PTR_CONVERSIONS -# endif -# endif - - -/* - * Jochen Schlick '1999 - added new #defines (__STL)_UITHREADS (for - * providing SCO / Solaris / UI thread support) - * - added the necessary defines for the SCO UDK 7 - * compiler (and its template friend behavior) - * - all UDK7 specific STL changes are based on the - * macro __USLC__ being defined - */ -// SCO UDK 7 compiler (UnixWare 7x, OSR 5, UnixWare 2x) -# if defined(__USLC__) -# define __STL_HAS_WCHAR_T -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# define __STL_PARTIAL_SPECIALIZATION_SYNTAX -# define __STL_FUNCTION_TMPL_PARTIAL_ORDER -# define __STL_MEMBER_TEMPLATES -# define __STL_MEMBER_TEMPLATE_CLASSES -# define __STL_USE_EXCEPTIONS -# define __STL_HAS_NAMESPACES -# define __STL_USE_NAMESPACES -# define __STL_LONG_LONG -# if defined(_REENTRANT) -# define _UITHREADS /* if UnixWare < 7.0.1 */ -# define __STL_UITHREADS -// use the following defines instead of the UI threads defines when -// you want to use POSIX threads -//# define _PTHREADS /* only if UnixWare >=7.0.1 */ -//# define __STL_PTHREADS -# endif -# endif - - - -# ifdef __GNUC__ -# if __GNUC__ == 2 && __GNUC_MINOR__ <= 7 -# define __STL_STATIC_TEMPLATE_MEMBER_BUG -# endif -# if __GNUC__ < 2 -# define __STL_NEED_TYPENAME -# define __STL_NEED_EXPLICIT -# endif -# if __GNUC__ == 2 && __GNUC_MINOR__ <= 8 -# define __STL_NO_EXCEPTION_HEADER -# define __STL_NO_BAD_ALLOC -# endif -# if __GNUC__ == 2 && __GNUC_MINOR__ >= 8 || __GNUC__ > 2 -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# define __STL_FUNCTION_TMPL_PARTIAL_ORDER -# define __STL_EXPLICIT_FUNCTION_TMPL_ARGS -# define __STL_MEMBER_TEMPLATES -# define __STL_CAN_THROW_RANGE_ERRORS - // g++ 2.8.1 supports member template functions, but not member - // template nested classes. -# if __GNUC_MINOR__ >= 9 || __GNUC__ > 2 -# define __STL_MEMBER_TEMPLATE_CLASSES -# define __STL_TEMPLATE_FRIENDS -# define __SGI_STL_USE_AUTO_PTR_CONVERSIONS -# define __STL_HAS_NAMESPACES -//# define __STL_USE_NEW_IOSTREAMS -# endif -# endif -# define __STL_DEFAULT_CONSTRUCTOR_BUG -# ifdef __EXCEPTIONS -# define __STL_USE_EXCEPTIONS -# endif -# ifdef _REENTRANT -# define __STL_PTHREADS -# endif -# if (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 95) -# define __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE -# endif -# endif - -# if defined(__SUNPRO_CC) -# define __STL_NO_BOOL -# define __STL_NEED_TYPENAME -# define __STL_NEED_EXPLICIT -# define __STL_USE_EXCEPTIONS -# ifdef _REENTRANT -# define __STL_PTHREADS -# endif -# define __SGI_STL_NO_ARROW_OPERATOR -# define __STL_PARTIAL_SPECIALIZATION_SYNTAX -# define __STL_NO_EXCEPTION_HEADER -# define __STL_NO_BAD_ALLOC -# endif - -# if defined(__COMO__) -# define __STL_MEMBER_TEMPLATES -# define __STL_MEMBER_TEMPLATE_CLASSES -# define __STL_TEMPLATE_FRIENDS -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# define __STL_USE_EXCEPTIONS -# define __STL_HAS_NAMESPACES -# endif - -// Intel compiler, which uses the EDG front end. -# if defined(__ICL) -# define __STL_LONG_LONG -# define __STL_MEMBER_TEMPLATES -# define __STL_MEMBER_TEMPLATE_CLASSES -# define __STL_TEMPLATE_FRIENDS -# define __STL_FUNCTION_TMPL_PARTIAL_ORDER -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# define __STL_NO_DRAND48 -# define __STL_HAS_NAMESPACES -# define __STL_USE_EXCEPTIONS -# define __STL_MEMBER_TEMPLATE_KEYWORD -# ifdef _CPPUNWIND -# define __STL_USE_EXCEPTIONS -# endif -# ifdef _MT -# define __STL_WIN32THREADS -# endif -# endif - -// Mingw32, egcs compiler using the Microsoft C runtime -# if defined(__MINGW32__) -# define __STL_NO_DRAND48 -# ifdef _MT -# define __STL_WIN32THREADS -# endif -# endif - -// Cygwin32, egcs compiler on MS Windows -# if defined(__CYGWIN__) -# define __STL_NO_DRAND48 -# endif - - - -// Microsoft compiler. -# if defined(_MSC_VER) && !defined(__ICL) && !defined(__MWERKS__) -# define __STL_NO_DRAND48 -# define __STL_STATIC_CONST_INIT_BUG -# define __STL_NEED_TYPENAME -# define __STL_NO_USING_CLAUSE_IN_CLASS -# define __STL_NO_FRIEND_TEMPLATE_CLASS -# if _MSC_VER < 1100 /* 1000 is version 4.0, 1100 is 5.0, 1200 is 6.0. */ -# define __STL_NEED_EXPLICIT -# define __STL_NO_BOOL -# define __STL_NO_BAD_ALLOC -# endif -# if _MSC_VER > 1000 -# include <yvals.h> -# define __STL_DONT_USE_BOOL_TYPEDEF -# endif -# define __STL_NON_TYPE_TMPL_PARAM_BUG -# define __SGI_STL_NO_ARROW_OPERATOR -# define __STL_DEFAULT_CONSTRUCTOR_BUG -# ifdef _CPPUNWIND -# define __STL_USE_EXCEPTIONS -# endif -# ifdef _MT -# define __STL_WIN32THREADS -# endif -# if _MSC_VER >= 1200 -# define __STL_PARTIAL_SPECIALIZATION_SYNTAX -# define __STL_HAS_NAMESPACES -# define __STL_CAN_THROW_RANGE_ERRORS -# define NOMINMAX -# undef min -# undef max -// disable warning 'initializers put in unrecognized initialization area' -# pragma warning ( disable : 4075 ) -// disable warning 'empty controlled statement found' -# pragma warning ( disable : 4390 ) -// disable warning 'debug symbol greater than 255 chars' -# pragma warning ( disable : 4786 ) -# endif -# if _MSC_VER < 1100 -# define __STL_NO_EXCEPTION_HEADER -# define __STL_NO_BAD_ALLOC -# endif - // Because of a Microsoft front end bug, we must not provide a - // namespace qualifier when declaring a friend function. -# define __STD_QUALIFIER -# endif - -# if defined(__BORLANDC__) -# define __STL_NO_BAD_ALLOC -# define __STL_NO_DRAND48 -# define __STL_DEFAULT_CONSTRUCTOR_BUG -# if __BORLANDC__ >= 0x540 /* C++ Builder 4.0 */ -# define __STL_CLASS_PARTIAL_SPECIALIZATION -# define __STL_FUNCTION_TMPL_PARTIAL_ORDER -# define __STL_EXPLICIT_FUNCTION_TMPL_ARGS -# define __STL_MEMBER_TEMPLATES -# define __STL_TEMPLATE_FRIENDS -# else -# define __STL_NEED_TYPENAME -# define __STL_LIMITED_DEFAULT_TEMPLATES -# define __SGI_STL_NO_ARROW_OPERATOR -# define __STL_NON_TYPE_TMPL_PARAM_BUG -# endif -# ifdef _CPPUNWIND -# define __STL_USE_EXCEPTIONS -# endif -# ifdef __MT__ -# define __STL_WIN32THREADS -# endif -# endif - -# if defined(__STL_NO_BOOL) && !defined(__STL_DONT_USE_BOOL_TYPEDEF) - typedef int bool; -# define true 1 -# define false 0 -# endif - -# ifdef __STL_NEED_TYPENAME -# define typename -# endif - -# ifdef __STL_LIMITED_DEFAULT_TEMPLATES -# define __STL_DEPENDENT_DEFAULT_TMPL(_Tp) -# else -# define __STL_DEPENDENT_DEFAULT_TMPL(_Tp) = _Tp -# endif - -# ifdef __STL_MEMBER_TEMPLATE_KEYWORD -# define __STL_TEMPLATE template -# else -# define __STL_TEMPLATE -# endif - -# ifdef __STL_NEED_EXPLICIT -# define explicit -# endif - -# ifdef __STL_EXPLICIT_FUNCTION_TMPL_ARGS -# define __STL_NULL_TMPL_ARGS <> -# else -# define __STL_NULL_TMPL_ARGS -# endif - -# if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) \ - || defined (__STL_PARTIAL_SPECIALIZATION_SYNTAX) -# define __STL_TEMPLATE_NULL template<> -# else -# define __STL_TEMPLATE_NULL -# endif - -// Use standard-conforming allocators if we have the necessary language -// features. __STL_USE_SGI_ALLOCATORS is a hook so that users can -// disable new-style allocators, and continue to use the same kind of -// allocators as before, without having to edit library headers. -# if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && \ - defined(__STL_MEMBER_TEMPLATES) && \ - defined(__STL_MEMBER_TEMPLATE_CLASSES) && \ - !defined(__STL_NO_BOOL) && \ - !defined(__STL_NON_TYPE_TMPL_PARAM_BUG) && \ - !defined(__STL_LIMITED_DEFAULT_TEMPLATES) && \ - !defined(__STL_USE_SGI_ALLOCATORS) -# define __STL_USE_STD_ALLOCATORS -# endif - -# ifndef __STL_DEFAULT_ALLOCATOR -# ifdef __STL_USE_STD_ALLOCATORS -# define __STL_DEFAULT_ALLOCATOR(T) allocator< T > -# else -# define __STL_DEFAULT_ALLOCATOR(T) alloc -# endif -# endif - -// __STL_NO_NAMESPACES is a hook so that users can disable namespaces -// without having to edit library headers. __STL_NO_RELOPS_NAMESPACE is -// a hook so that users can disable the std::rel_ops namespace, keeping -// the relational operator template in namespace std, without having to -// edit library headers. -# if defined(__STL_HAS_NAMESPACES) && !defined(__STL_NO_NAMESPACES) -# define __STL_USE_NAMESPACES -# define __STD std -# define __STL_BEGIN_NAMESPACE namespace std { -# define __STL_END_NAMESPACE } -# if defined(__STL_FUNCTION_TMPL_PARTIAL_ORDER) && \ - !defined(__STL_NO_RELOPS_NAMESPACE) -# define __STL_USE_NAMESPACE_FOR_RELOPS -# define __STL_BEGIN_RELOPS_NAMESPACE namespace std { namespace rel_ops { -# define __STL_END_RELOPS_NAMESPACE } } -# define __STD_RELOPS std::rel_ops -# else /* Use std::rel_ops namespace */ -# define __STL_USE_NAMESPACE_FOR_RELOPS -# define __STL_BEGIN_RELOPS_NAMESPACE namespace std { -# define __STL_END_RELOPS_NAMESPACE } -# define __STD_RELOPS std -# endif /* Use std::rel_ops namespace */ -# else -# define __STD -# define __STL_BEGIN_NAMESPACE -# define __STL_END_NAMESPACE -# undef __STL_USE_NAMESPACE_FOR_RELOPS -# define __STL_BEGIN_RELOPS_NAMESPACE -# define __STL_END_RELOPS_NAMESPACE -# define __STD_RELOPS -# undef __STL_USE_NAMESPACES -# endif - -// Some versions of the EDG front end sometimes require an explicit -// namespace spec where they shouldn't. This macro facilitates that. -// If the bug becomes irrelevant, then all uses of __STD_QUALIFIER -// should be removed. The 7.3 beta SGI compiler has this bug, but the -// MR version is not expected to have it. - -# if defined(__STL_USE_NAMESPACES) && !defined(__STD_QUALIFIER) -# define __STD_QUALIFIER std:: -# else -# define __STD_QUALIFIER -# endif - -# ifdef __STL_USE_EXCEPTIONS -# define __STL_TRY try -# define __STL_CATCH_ALL catch(...) -# define __STL_THROW(x) throw x -# define __STL_RETHROW throw -# define __STL_NOTHROW throw() -# define __STL_UNWIND(action) catch(...) { action; throw; } -# else -# define __STL_TRY -# define __STL_CATCH_ALL if (false) -# define __STL_THROW(x) -# define __STL_RETHROW -# define __STL_NOTHROW -# define __STL_UNWIND(action) -# endif - -#ifdef __STL_ASSERTIONS -# include <stdio.h> -# define __stl_assert(expr) \ - if (!(expr)) { fprintf(stderr, "%s:%d STL assertion failure: %s\n", \ - __FILE__, __LINE__, # expr); abort(); } -#else -# define __stl_assert(expr) -#endif - -#if defined(__STL_WIN32THREADS) || defined(__STL_SGI_THREADS) \ - || defined(__STL_PTHREADS) || defined(__STL_UITHREADS) -# define __STL_THREADS -# define __STL_VOLATILE volatile -#else -# define __STL_VOLATILE -#endif - -#if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) \ - && defined(__STL_MEMBER_TEMPLATES) \ - && !defined(_STL_NO_CONCEPT_CHECKS) -# define __STL_USE_CONCEPT_CHECKS -#endif - - -#endif /* __STL_CONFIG_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/WebKit/android/stl/stl_heap.h b/WebKit/android/stl/stl_heap.h deleted file mode 100644 index 9e3cf13..0000000 --- a/WebKit/android/stl/stl_heap.h +++ /dev/null @@ -1,298 +0,0 @@ -/* - * - * Copyright 2009, The Android Open Source Project - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * Copyright (c) 1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_HEAP_H -#define __SGI_STL_INTERNAL_HEAP_H - -__STL_BEGIN_NAMESPACE - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1209 -#endif - -// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap. - -template <class _RandomAccessIterator, class _Distance, class _Tp> -void -__push_heap(_RandomAccessIterator __first, - _Distance __holeIndex, _Distance __topIndex, _Tp __value) -{ - _Distance __parent = (__holeIndex - 1) / 2; - while (__holeIndex > __topIndex && *(__first + __parent) < __value) { - *(__first + __holeIndex) = *(__first + __parent); - __holeIndex = __parent; - __parent = (__holeIndex - 1) / 2; - } - *(__first + __holeIndex) = __value; -} - -template <class _RandomAccessIterator, class _Distance, class _Tp> -inline void -__push_heap_aux(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Distance*, _Tp*) -{ - __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), - _Tp(*(__last - 1))); -} - -template <class _RandomAccessIterator> -inline void -push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type, - _LessThanComparable); - __push_heap_aux(__first, __last, - __DISTANCE_TYPE(__first), __VALUE_TYPE(__first)); -} - -template <class _RandomAccessIterator, class _Distance, class _Tp, - class _Compare> -void -__push_heap(_RandomAccessIterator __first, _Distance __holeIndex, - _Distance __topIndex, _Tp __value, _Compare __comp) -{ - _Distance __parent = (__holeIndex - 1) / 2; - while (__holeIndex > __topIndex && __comp(*(__first + __parent), __value)) { - *(__first + __holeIndex) = *(__first + __parent); - __holeIndex = __parent; - __parent = (__holeIndex - 1) / 2; - } - *(__first + __holeIndex) = __value; -} - -template <class _RandomAccessIterator, class _Compare, - class _Distance, class _Tp> -inline void -__push_heap_aux(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Compare __comp, - _Distance*, _Tp*) -{ - __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), - _Tp(*(__last - 1)), __comp); -} - -template <class _RandomAccessIterator, class _Compare> -inline void -push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _Compare __comp) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - __push_heap_aux(__first, __last, __comp, - __DISTANCE_TYPE(__first), __VALUE_TYPE(__first)); -} - -template <class _RandomAccessIterator, class _Distance, class _Tp> -void -__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, - _Distance __len, _Tp __value) -{ - _Distance __topIndex = __holeIndex; - _Distance __secondChild = 2 * __holeIndex + 2; - while (__secondChild < __len) { - if (*(__first + __secondChild) < *(__first + (__secondChild - 1))) - __secondChild--; - *(__first + __holeIndex) = *(__first + __secondChild); - __holeIndex = __secondChild; - __secondChild = 2 * (__secondChild + 1); - } - if (__secondChild == __len) { - *(__first + __holeIndex) = *(__first + (__secondChild - 1)); - __holeIndex = __secondChild - 1; - } - __push_heap(__first, __holeIndex, __topIndex, __value); -} - -template <class _RandomAccessIterator, class _Tp, class _Distance> -inline void -__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _RandomAccessIterator __result, _Tp __value, _Distance*) -{ - *__result = *__first; - __adjust_heap(__first, _Distance(0), _Distance(__last - __first), __value); -} - -template <class _RandomAccessIterator, class _Tp> -inline void -__pop_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last, - _Tp*) -{ - __pop_heap(__first, __last - 1, __last - 1, - _Tp(*(__last - 1)), __DISTANCE_TYPE(__first)); -} - -template <class _RandomAccessIterator> -inline void pop_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type, - _LessThanComparable); - __pop_heap_aux(__first, __last, __VALUE_TYPE(__first)); -} - -template <class _RandomAccessIterator, class _Distance, - class _Tp, class _Compare> -void -__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, - _Distance __len, _Tp __value, _Compare __comp) -{ - _Distance __topIndex = __holeIndex; - _Distance __secondChild = 2 * __holeIndex + 2; - while (__secondChild < __len) { - if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1)))) - __secondChild--; - *(__first + __holeIndex) = *(__first + __secondChild); - __holeIndex = __secondChild; - __secondChild = 2 * (__secondChild + 1); - } - if (__secondChild == __len) { - *(__first + __holeIndex) = *(__first + (__secondChild - 1)); - __holeIndex = __secondChild - 1; - } - __push_heap(__first, __holeIndex, __topIndex, __value, __comp); -} - -template <class _RandomAccessIterator, class _Tp, class _Compare, - class _Distance> -inline void -__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _RandomAccessIterator __result, _Tp __value, _Compare __comp, - _Distance*) -{ - *__result = *__first; - __adjust_heap(__first, _Distance(0), _Distance(__last - __first), - __value, __comp); -} - -template <class _RandomAccessIterator, class _Tp, class _Compare> -inline void -__pop_heap_aux(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Tp*, _Compare __comp) -{ - __pop_heap(__first, __last - 1, __last - 1, _Tp(*(__last - 1)), __comp, - __DISTANCE_TYPE(__first)); -} - -template <class _RandomAccessIterator, class _Compare> -inline void -pop_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Compare __comp) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - __pop_heap_aux(__first, __last, __VALUE_TYPE(__first), __comp); -} - -template <class _RandomAccessIterator, class _Tp, class _Distance> -void -__make_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Tp*, _Distance*) -{ - if (__last - __first < 2) return; - _Distance __len = __last - __first; - _Distance __parent = (__len - 2)/2; - - while (true) { - __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent))); - if (__parent == 0) return; - __parent--; - } -} - -template <class _RandomAccessIterator> -inline void -make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type, - _LessThanComparable); - __make_heap(__first, __last, - __VALUE_TYPE(__first), __DISTANCE_TYPE(__first)); -} - -template <class _RandomAccessIterator, class _Compare, - class _Tp, class _Distance> -void -__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _Compare __comp, _Tp*, _Distance*) -{ - if (__last - __first < 2) return; - _Distance __len = __last - __first; - _Distance __parent = (__len - 2)/2; - - while (true) { - __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)), - __comp); - if (__parent == 0) return; - __parent--; - } -} - -template <class _RandomAccessIterator, class _Compare> -inline void -make_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Compare __comp) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - __make_heap(__first, __last, __comp, - __VALUE_TYPE(__first), __DISTANCE_TYPE(__first)); -} - -template <class _RandomAccessIterator> -void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type, - _LessThanComparable); - while (__last - __first > 1) - pop_heap(__first, __last--); -} - -template <class _RandomAccessIterator, class _Compare> -void -sort_heap(_RandomAccessIterator __first, - _RandomAccessIterator __last, _Compare __comp) -{ - __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); - while (__last - __first > 1) - pop_heap(__first, __last--, __comp); -} - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1209 -#endif - -__STL_END_NAMESPACE - -#endif /* __SGI_STL_INTERNAL_HEAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/WebKit/android/stl/stl_iterator_base.h b/WebKit/android/stl/stl_iterator_base.h deleted file mode 100644 index 746d1d4..0000000 --- a/WebKit/android/stl/stl_iterator_base.h +++ /dev/null @@ -1,274 +0,0 @@ -/* - * - * Copyright 2009, The Android Open Source Project - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996-1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -/* NOTE: This is an internal header file, included by other STL headers. - * You should not attempt to use it directly. - */ - -#ifndef __SGI_STL_INTERNAL_ITERATOR_BASE_H -#define __SGI_STL_INTERNAL_ITERATOR_BASE_H - -// This file contains all of the general iterator-related utilities. -// The internal file stl_iterator.h contains predefined iterators, -// such as front_insert_iterator and istream_iterator. - -#include <concept_checks.h> - -struct input_iterator_tag {}; -struct output_iterator_tag {}; -struct forward_iterator_tag : public input_iterator_tag {}; -struct bidirectional_iterator_tag : public forward_iterator_tag {}; -struct random_access_iterator_tag : public bidirectional_iterator_tag {}; - -// The base classes input_iterator, output_iterator, forward_iterator, -// bidirectional_iterator, and random_access_iterator are not part of -// the C++ standard. (They have been replaced by struct iterator.) -// They are included for backward compatibility with the HP STL. - -template <class _Tp, class _Distance> struct input_iterator { - typedef input_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - -struct output_iterator { - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; -}; - -template <class _Tp, class _Distance> struct forward_iterator { - typedef forward_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - - -template <class _Tp, class _Distance> struct bidirectional_iterator { - typedef bidirectional_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - -template <class _Tp, class _Distance> struct random_access_iterator { - typedef random_access_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - -template <class _Category, class _Tp, class _Distance = ptrdiff_t, - class _Pointer = _Tp*, class _Reference = _Tp&> -struct iterator { - typedef _Category iterator_category; - typedef _Tp value_type; - typedef _Distance difference_type; - typedef _Pointer pointer; - typedef _Reference reference; -}; - -template <class _Iterator> -struct iterator_traits { - typedef typename _Iterator::iterator_category iterator_category; - typedef typename _Iterator::value_type value_type; - typedef typename _Iterator::difference_type difference_type; - typedef typename _Iterator::pointer pointer; - typedef typename _Iterator::reference reference; -}; - -template <class _Tp> -struct iterator_traits<_Tp*> { - typedef random_access_iterator_tag iterator_category; - typedef _Tp value_type; - typedef ptrdiff_t difference_type; - typedef _Tp* pointer; - typedef _Tp& reference; -}; - -template <class _Tp> -struct iterator_traits<const _Tp*> { - typedef random_access_iterator_tag iterator_category; - typedef _Tp value_type; - typedef ptrdiff_t difference_type; - typedef const _Tp* pointer; - typedef const _Tp& reference; -}; - -// The overloaded functions iterator_category, distance_type, and -// value_type are not part of the C++ standard. (They have been -// replaced by struct iterator_traits.) They are included for -// backward compatibility with the HP STL. - -// We introduce internal names for these functions. - -template <class _Iter> -inline typename iterator_traits<_Iter>::iterator_category -__iterator_category(const _Iter&) -{ - typedef typename iterator_traits<_Iter>::iterator_category _Category; - return _Category(); -} - -template <class _Iter> -inline typename iterator_traits<_Iter>::difference_type* -__distance_type(const _Iter&) -{ - return static_cast<typename iterator_traits<_Iter>::difference_type*>(0); -} - -template <class _Iter> -inline typename iterator_traits<_Iter>::value_type* -__value_type(const _Iter&) -{ - return static_cast<typename iterator_traits<_Iter>::value_type*>(0); -} - -template <class _Iter> -inline typename iterator_traits<_Iter>::iterator_category -iterator_category(const _Iter& __i) { return __iterator_category(__i); } - - -template <class _Iter> -inline typename iterator_traits<_Iter>::difference_type* -distance_type(const _Iter& __i) { return __distance_type(__i); } - -template <class _Iter> -inline typename iterator_traits<_Iter>::value_type* -value_type(const _Iter& __i) { return __value_type(__i); } - -#define __ITERATOR_CATEGORY(__i) __iterator_category(__i) -#define __DISTANCE_TYPE(__i) __distance_type(__i) -#define __VALUE_TYPE(__i) __value_type(__i) - -template <class _InputIterator, class _Distance> -inline void __distance(_InputIterator __first, _InputIterator __last, - _Distance& __n, input_iterator_tag) -{ - while (__first != __last) { ++__first; ++__n; } -} - -template <class _RandomAccessIterator, class _Distance> -inline void __distance(_RandomAccessIterator __first, - _RandomAccessIterator __last, - _Distance& __n, random_access_iterator_tag) -{ - __STL_REQUIRES(_RandomAccessIterator, _RandomAccessIterator); - __n += __last - __first; -} - -template <class _InputIterator, class _Distance> -inline void distance(_InputIterator __first, - _InputIterator __last, _Distance& __n) -{ - __STL_REQUIRES(_InputIterator, _InputIterator); - __distance(__first, __last, __n, iterator_category(__first)); -} - -#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION - -template <class _InputIterator> -inline typename iterator_traits<_InputIterator>::difference_type -__distance(_InputIterator __first, _InputIterator __last, input_iterator_tag) -{ - typename iterator_traits<_InputIterator>::difference_type __n = 0; - while (__first != __last) { - ++__first; ++__n; - } - return __n; -} - -template <class _RandomAccessIterator> -inline typename iterator_traits<_RandomAccessIterator>::difference_type -__distance(_RandomAccessIterator __first, _RandomAccessIterator __last, - random_access_iterator_tag) { - __STL_REQUIRES(_RandomAccessIterator, _RandomAccessIterator); - return __last - __first; -} - -template <class _InputIterator> -inline typename iterator_traits<_InputIterator>::difference_type -distance(_InputIterator __first, _InputIterator __last) { - typedef typename iterator_traits<_InputIterator>::iterator_category - _Category; - __STL_REQUIRES(_InputIterator, _InputIterator); - return __distance(__first, __last, _Category()); -} - -#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ - -template <class _InputIter, class _Distance> -inline void __advance(_InputIter& __i, _Distance __n, input_iterator_tag) { - while (__n--) ++__i; -} - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma set woff 1183 -#endif - -template <class _BidirectionalIterator, class _Distance> -inline void __advance(_BidirectionalIterator& __i, _Distance __n, - bidirectional_iterator_tag) { - __STL_REQUIRES(_BidirectionalIterator, _BidirectionalIterator); - if (__n >= 0) - while (__n--) ++__i; - else - while (__n++) --__i; -} - -#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) -#pragma reset woff 1183 -#endif - -template <class _RandomAccessIterator, class _Distance> -inline void __advance(_RandomAccessIterator& __i, _Distance __n, - random_access_iterator_tag) { - __STL_REQUIRES(_RandomAccessIterator, _RandomAccessIterator); - __i += __n; -} - -template <class _InputIterator, class _Distance> -inline void advance(_InputIterator& __i, _Distance __n) { - __STL_REQUIRES(_InputIterator, _InputIterator); - __advance(__i, __n, iterator_category(__i)); -} - -#endif /* __SGI_STL_INTERNAL_ITERATOR_BASE_H */ - - - -// Local Variables: -// mode:C++ -// End: diff --git a/WebKit/android/wds/Command.cpp b/WebKit/android/wds/Command.cpp index e150d4f..7f2046e 100644 --- a/WebKit/android/wds/Command.cpp +++ b/WebKit/android/wds/Command.cpp @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/wds/Command.h b/WebKit/android/wds/Command.h index 753486d..90861d4 100644 --- a/WebKit/android/wds/Command.h +++ b/WebKit/android/wds/Command.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/wds/Connection.cpp b/WebKit/android/wds/Connection.cpp index 1afd00c..d7e55ac 100644 --- a/WebKit/android/wds/Connection.cpp +++ b/WebKit/android/wds/Connection.cpp @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/wds/Connection.h b/WebKit/android/wds/Connection.h index ce88316..d67179e 100644 --- a/WebKit/android/wds/Connection.h +++ b/WebKit/android/wds/Connection.h @@ -13,7 +13,7 @@ * 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 + * 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 @@ -26,6 +26,7 @@ #ifndef WDS_CONNECTION_H #define WDS_CONNECTION_H +#include <unistd.h> #include <sys/socket.h> namespace android { diff --git a/WebKit/android/wds/DebugServer.cpp b/WebKit/android/wds/DebugServer.cpp index 0990452..f33a65b 100644 --- a/WebKit/android/wds/DebugServer.cpp +++ b/WebKit/android/wds/DebugServer.cpp @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/wds/DebugServer.h b/WebKit/android/wds/DebugServer.h index 3ec158b..92edad9 100644 --- a/WebKit/android/wds/DebugServer.h +++ b/WebKit/android/wds/DebugServer.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/wds/client/AdbConnection.cpp b/WebKit/android/wds/client/AdbConnection.cpp index f83ad2f..465f9c3 100644 --- a/WebKit/android/wds/client/AdbConnection.cpp +++ b/WebKit/android/wds/client/AdbConnection.cpp @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/wds/client/AdbConnection.h b/WebKit/android/wds/client/AdbConnection.h index 433d7ea..58bad67 100644 --- a/WebKit/android/wds/client/AdbConnection.h +++ b/WebKit/android/wds/client/AdbConnection.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/wds/client/Android.mk b/WebKit/android/wds/client/Android.mk index e6bf7cf..db79dd4 100644 --- a/WebKit/android/wds/client/Android.mk +++ b/WebKit/android/wds/client/Android.mk @@ -1,5 +1,4 @@ ## -## ## Copyright 2008, The Android Open Source Project ## ## Redistribution and use in source and binary forms, with or without @@ -14,7 +13,7 @@ ## 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 +## 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 @@ -38,4 +37,3 @@ LOCAL_STATIC_LIBRARIES := liblog libutils libcutils LOCAL_MODULE:= wdsclient include $(BUILD_HOST_EXECUTABLE) - diff --git a/WebKit/android/wds/client/ClientUtils.cpp b/WebKit/android/wds/client/ClientUtils.cpp index 03514f6..f8ca889 100644 --- a/WebKit/android/wds/client/ClientUtils.cpp +++ b/WebKit/android/wds/client/ClientUtils.cpp @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/wds/client/ClientUtils.h b/WebKit/android/wds/client/ClientUtils.h index 261af27..5da1624 100644 --- a/WebKit/android/wds/client/ClientUtils.h +++ b/WebKit/android/wds/client/ClientUtils.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/wds/client/Device.cpp b/WebKit/android/wds/client/Device.cpp index 6c36979..789a89d 100644 --- a/WebKit/android/wds/client/Device.cpp +++ b/WebKit/android/wds/client/Device.cpp @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/wds/client/Device.h b/WebKit/android/wds/client/Device.h index df076cb..39d4b12 100644 --- a/WebKit/android/wds/client/Device.h +++ b/WebKit/android/wds/client/Device.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/wds/client/DeviceList.h b/WebKit/android/wds/client/DeviceList.h index 0b278d2..45bfb87 100644 --- a/WebKit/android/wds/client/DeviceList.h +++ b/WebKit/android/wds/client/DeviceList.h @@ -13,7 +13,7 @@ * 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 + * 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 diff --git a/WebKit/android/wds/client/main.cpp b/WebKit/android/wds/client/main.cpp index bc8df86..1c7d856 100644 --- a/WebKit/android/wds/client/main.cpp +++ b/WebKit/android/wds/client/main.cpp @@ -13,7 +13,7 @@ * 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 + * 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 |
