diff options
Diffstat (limited to 'Source')
12 files changed, 47 insertions, 229 deletions
| diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index a09eb35..014fa40 100644 --- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -112,7 +112,8 @@ void BaseLayerAndroid::drawCanvas(SkCanvas* canvas)  }  #if USE(ACCELERATED_COMPOSITING) -bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale, double currentTime) +bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale, +                                           double currentTime, bool* pagesSwapped)  {      if (!m_glWebViewState)          return false; @@ -249,6 +250,8 @@ bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale, double          m_glWebViewState->setCurrentScale(scale);          m_glWebViewState->swapPages();          m_glWebViewState->unlockBaseLayerUpdate(); +        if (pagesSwapped) +            *pagesSwapped = true;      }      m_glWebViewState->paintExtras(); @@ -259,7 +262,8 @@ bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale, double  bool BaseLayerAndroid::drawGL(LayerAndroid* compositedRoot,                                IntRect& viewRect, SkRect& visibleRect,                                IntRect& webViewRect, int titleBarHeight, -                              IntRect& screenClip, float scale, SkColor color) +                              IntRect& screenClip, float scale, +                              bool* pagesSwapped, SkColor color)  {      bool needsRedraw = false;  #if USE(ACCELERATED_COMPOSITING) @@ -299,7 +303,8 @@ bool BaseLayerAndroid::drawGL(LayerAndroid* compositedRoot,      shader->resetBlending();      double currentTime = WTF::currentTime(); -    needsRedraw = drawBasePictureInGL(visibleRect, scale, currentTime); +    needsRedraw = drawBasePictureInGL(visibleRect, scale, currentTime, +                                      pagesSwapped);      bool goingDown = m_previousVisible.fTop - visibleRect.fTop <= 0;      bool goingLeft = m_previousVisible.fLeft - visibleRect.fLeft >= 0;      m_glWebViewState->setDirection(goingDown, goingLeft); diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h index 29ecf57..62aabb6 100644 --- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h @@ -57,11 +57,12 @@ public:      bool drawGL(LayerAndroid* compositedRoot, IntRect& rect, SkRect& viewport,                  IntRect& webViewRect, int titleBarHeight, IntRect& screenClip, -                float scale, SkColor color = SK_ColorWHITE); +                float scale, bool* pagesSwapped, SkColor color = SK_ColorWHITE);      void swapExtra(BaseLayerAndroid* base) { m_extra.swap(base->m_extra); }  private:  #if USE(ACCELERATED_COMPOSITING) -    bool drawBasePictureInGL(SkRect& viewport, float scale, double currentTime); +    bool drawBasePictureInGL(SkRect& viewport, float scale, double currentTime, +                             bool* pagesSwapped);      GLWebViewState* m_glWebViewState;      android::Mutex m_drawLock; diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index 2e379bc..07dda03 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -501,7 +501,8 @@ void GLWebViewState::resetLayersDirtyArea()  bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,                              IntRect& webViewRect, int titleBarHeight, -                            IntRect& clip, float scale, SkColor color) +                            IntRect& clip, float scale, bool* pagesSwapped, +                            SkColor color)  {      glFinish();      TilesManager::instance()->registerGLWebViewState(this); @@ -548,7 +549,8 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,          TilesManager::instance()->cleanupTilesTextures();      } -    bool ret = baseLayer->drawGL(compositedRoot, rect, viewport, webViewRect, titleBarHeight, clip, scale, color); +    bool ret = baseLayer->drawGL(compositedRoot, rect, viewport, webViewRect, +                                 titleBarHeight, clip, scale, pagesSwapped, color);      SkSafeRef(compositedRoot);      SkSafeUnref(m_previouslyUsedRoot);      m_previouslyUsedRoot = compositedRoot; diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h index 6834974..4f8d4fe 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.h +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h @@ -220,7 +220,8 @@ public:      bool drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,                  IntRect& webViewRect, int titleBarHeight, -                IntRect& clip, float scale, SkColor color = SK_ColorWHITE); +                IntRect& clip, float scale, bool* pagesSwapped, +                SkColor color = SK_ColorWHITE);      void setBackgroundColor(SkColor color) { m_backgroundColor = color; }      SkColor getBackgroundColor() { return m_backgroundColor; } diff --git a/Source/WebKit/Android.mk b/Source/WebKit/Android.mk index 3a47909..f3d33c6 100644 --- a/Source/WebKit/Android.mk +++ b/Source/WebKit/Android.mk @@ -131,7 +131,6 @@ LOCAL_CFLAGS += -DENABLE_WEB_AUTOFILL  LOCAL_SRC_FILES += \  	android/WebCoreSupport/autofill/AutoFillHostAndroid.cpp \ -	android/WebCoreSupport/autofill/FormFieldAndroid.cpp \  	android/WebCoreSupport/autofill/FormManagerAndroid.cpp \  	android/WebCoreSupport/autofill/WebAutofill.cpp  endif # ENABLE_AUTOFILL == true diff --git a/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h b/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h index 9728aad..022511a 100644 --- a/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h +++ b/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h @@ -46,6 +46,7 @@  #endif  #include <android/net/android_network_library_impl.h> +#include <android/jni/jni_utils.h>  #include <base/callback.h>  #include <base/memory/ref_counted.h>  #include <base/message_loop_proxy.h> @@ -95,6 +96,7 @@  #include <chrome/browser/profiles/profile.h>  #include <content/browser/tab_contents/tab_contents.h>  #include <webkit/glue/form_data.h> +#include <webkit/glue/form_field.h>  #endif  #undef LOG diff --git a/Source/WebKit/android/WebCoreSupport/ChromiumInit.cpp b/Source/WebKit/android/WebCoreSupport/ChromiumInit.cpp index 2bb4d3d..500975c 100644 --- a/Source/WebKit/android/WebCoreSupport/ChromiumInit.cpp +++ b/Source/WebKit/android/WebCoreSupport/ChromiumInit.cpp @@ -27,6 +27,8 @@  #include "ChromiumInit.h"  #include "ChromiumIncludes.h" +#include "JNIUtility.h" +#include "jni.h"  #include <cutils/log.h>  #include <string> @@ -68,6 +70,7 @@ void initChromium()          networkChangeNotifier.reset(net::NetworkChangeNotifier::Create());          net::HttpNetworkLayer::EnableSpdy("npn");          initCalled = true; +        jni::SetJavaVM(JSC::Bindings::getJavaVM());      }  } diff --git a/Source/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.cpp b/Source/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.cpp deleted file mode 100644 index 3f5970a..0000000 --- a/Source/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2010 The Chromium Authors. All rights reserved. - * Copyright 2010, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - *  * Redistributions of source code must retain the above copyright - *    notice, this list of conditions and the following disclaimer. - *  * Redistributions in binary form must reproduce the above copyright - *    notice, this list of conditions and the following disclaimer in the - *    documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "FormFieldAndroid.h" - -#include "ChromiumIncludes.h" -#include "Element.h" -#include "HTMLFormControlElement.h" -#include "HTMLInputElement.h" -#include "HTMLNames.h" -#include "HTMLOptionElement.h" -#include "HTMLSelectElement.h" -#include "StringUtils.h" -#include <wtf/Vector.h> - -using WebCore::Element; -using WebCore::HTMLFormControlElement; -using WebCore::HTMLInputElement; -using WebCore::HTMLOptionElement; -using WebCore::HTMLSelectElement; - -using namespace WebCore::HTMLNames; - -// TODO: This file is taken from chromium/webkit/glue/form_field.cc and -// customised to use WebCore types rather than WebKit API types. It would -// be nice and would ease future merge pain if the two could be combined. - -namespace webkit_glue { - -FormField::FormField() -    : max_length(0), -      is_autofilled(false) { -} - -// TODO: This constructor should probably be deprecated and the -// functionality moved to FormManager. -FormField::FormField(const HTMLFormControlElement& element) -    : max_length(0), -      is_autofilled(false) { -    name = nameForAutofill(element); - -    // TODO: Extract the field label.  For now we just use the field -    // name. -    label = name; - -    form_control_type = formControlType(element); -    if (form_control_type == kText) { -        const HTMLInputElement& input_element = static_cast<const HTMLInputElement&>(element); -        value = WTFStringToString16(input_element.value()); -        max_length = input_element.size(); -        is_autofilled = input_element.isAutofilled(); -    } else if (form_control_type == kSelectOne) { -        const HTMLSelectElement& const_select_element = static_cast<const HTMLSelectElement&>(element); -        HTMLSelectElement& select_element = const_cast<HTMLSelectElement&>(const_select_element); -        value = WTFStringToString16(select_element.value()); - -        // For select-one elements copy option strings. -        WTF::Vector<Element*> list_items = select_element.listItems(); -        option_strings.reserve(list_items.size()); -        for (size_t i = 0; i < list_items.size(); ++i) { -            if (list_items[i]->hasTagName(optionTag)) -                option_strings.push_back(WTFStringToString16(static_cast<HTMLOptionElement*>(list_items[i])->value())); -        } -    } - -    TrimWhitespace(value, TRIM_LEADING, &value); -} - -FormField::FormField(const string16& _label, const string16& _name, const string16& _value, const string16& _form_control_type, int _max_length, bool _is_autofilled) -    : label(_label), -      name(_name), -      value(_value), -      form_control_type(_form_control_type), -      max_length(_max_length), -      is_autofilled(_is_autofilled) { -} - -FormField::~FormField() { -} - -bool FormField::operator==(const FormField& field) const { -    // A FormField stores a value, but the value is not part of the identity of -    // the field, so we don't want to compare the values. -    return (label == field.label && -            name == field.name && -            form_control_type == field.form_control_type && -            max_length == field.max_length); -} - -bool FormField::operator!=(const FormField& field) const { -    return !operator==(field); -} - -bool FormField::StrictlyEqualsHack(const FormField& field) const { -    return (label == field.label && -            name == field.name && -            value == field.value && -            form_control_type == field.form_control_type && -            max_length == field.max_length); -} - -std::ostream& operator<<(std::ostream& os, const FormField& field) { -    return os -            << UTF16ToUTF8(field.label) -            << " " -            << UTF16ToUTF8(field.name) -            << " " -            << UTF16ToUTF8(field.value) -            << " " -            << UTF16ToUTF8(field.form_control_type) -            << " " -            << field.max_length; -} - -}  // namespace webkit_glue diff --git a/Source/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.h b/Source/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.h deleted file mode 100644 index 7367f86..0000000 --- a/Source/WebKit/android/WebCoreSupport/autofill/FormFieldAndroid.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2010 The Chromium Authors. All rights reserved. - * Copyright 2010, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - *  * Redistributions of source code must retain the above copyright - *    notice, this list of conditions and the following disclaimer. - *  * Redistributions in binary form must reproduce the above copyright - *    notice, this list of conditions and the following disclaimer in the - *    documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef FormFieldAndroid_h -#define FormFieldAndroid_h - -#include <base/string16.h> -#include <vector> - -// TODO: This file is taken from chromium/webkit/glue/form_field.h and -// customised to use WebCore types rather than WebKit API types. It would -// be nice and would ease future merge pain if the two could be combined. - -namespace WebCore { -class HTMLFormControlElement; -} - -namespace webkit_glue { - -// Stores information about a field in a form. -struct FormField { -    FormField(); -    explicit FormField(const WebCore::HTMLFormControlElement& element); -    FormField(const string16& label, const string16& name, const string16& value, const string16& form_control_type, int max_length, bool is_autofilled); -    virtual ~FormField(); - -    // Equality tests for identity which does not include |value_| or |size_|. -    // Use |StrictlyEqualsHack| method to test all members. -    // TODO: These operators need to be revised when we implement field -    // ids. -    bool operator==(const FormField& field) const; -    bool operator!=(const FormField& field) const; - -    // Test equality of all data members. -    // TODO: This will be removed when we implement field ids. -    bool StrictlyEqualsHack(const FormField& field) const; - -    string16 label; -    string16 name; -    string16 value; -    string16 form_control_type; -    int max_length; -    bool is_autofilled; -    std::vector<string16> option_strings; -}; - -// So we can compare FormFields with EXPECT_EQ(). -std::ostream& operator<<(std::ostream& os, const FormField& field); - -}  // namespace webkit_glue - -#endif  // WEBKIT_GLUE_FORM_FIELD_H_ diff --git a/Source/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp b/Source/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp index ba015e2..65b6771 100644 --- a/Source/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp @@ -44,7 +44,6 @@  #include "NodeList.h"  #include "HTMLCollection.h"  #include "FormAssociatedElement.h" -#include "FormFieldAndroid.h"  #include "QualifiedName.h"  #include "StringUtils.h" diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 1c51b14..a883075 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -437,6 +437,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m      // Static initialisation of certain important V8 static data gets performed at system startup when      // libwebcore gets loaded. We now need to associate the WebCore thread with V8 to complete      // initialisation. +    WebCore::ScriptController::setFlags("--nocrankshaft", strlen("--nocrankshaft"));      v8::V8::Initialize();  #endif  } diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 6a95d33..77ac2ae 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -126,6 +126,7 @@ struct JavaGlue {      jmethodID   m_viewInvalidate;      jmethodID   m_viewInvalidateRect;      jmethodID   m_postInvalidateDelayed; +    jmethodID   m_pageSwapCallback;      jmethodID   m_inFullScreenMode;      jfieldID    m_rectLeft;      jfieldID    m_rectTop; @@ -162,6 +163,7 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl, WTF::String drawableDir,      m_javaGlue.m_viewInvalidateRect = GetJMethod(env, clazz, "viewInvalidate", "(IIII)V");      m_javaGlue.m_postInvalidateDelayed = GetJMethod(env, clazz,          "viewInvalidateDelayed", "(JIIII)V"); +    m_javaGlue.m_pageSwapCallback = GetJMethod(env, clazz, "pageSwapCallback", "()V");      m_javaGlue.m_inFullScreenMode = GetJMethod(env, clazz, "inFullScreenMode", "()Z");      env->DeleteLocalRef(clazz); @@ -198,6 +200,7 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl, WTF::String drawableDir,          m_buttonSkin = new RenderSkinButton(am, drawableDir);  #if USE(ACCELERATED_COMPOSITING)      m_glWebViewState = 0; +    m_pageSwapCallbackRegistered = false;  #endif  } @@ -513,8 +516,20 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, WebCore::In      // once the correct scale is set      if (!visibleRect.hasValidCoordinates())          return false; +    bool pagesSwapped = false;      bool ret = m_glWebViewState->drawGL(viewRect, visibleRect, invalRect, -                                        webViewRect, titleBarHeight, clip, scale); +                                        webViewRect, titleBarHeight, clip, scale, +                                        &pagesSwapped); +    if (m_pageSwapCallbackRegistered && pagesSwapped) { +        m_pageSwapCallbackRegistered = false; +        LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); +        JNIEnv* env = JSC::Bindings::getJNIEnv(); +        AutoJObject javaObject = m_javaGlue.object(env); +        if (javaObject.get()) { +            env->CallVoidMethod(javaObject.get(), m_javaGlue.m_pageSwapCallback); +            checkException(env); +        } +    }      if (ret || m_glWebViewState->currentPictureCounter() != pic)          return true;  #endif @@ -1435,12 +1450,13 @@ static void copyScrollPositionRecursive(const LayerAndroid* from,  #endif  void setBaseLayer(BaseLayerAndroid* layer, SkRegion& inval, bool showVisualIndicator, -                  bool isPictureAfterFirstLayout) +                  bool isPictureAfterFirstLayout, bool registerPageSwapCallback)  {  #if USE(ACCELERATED_COMPOSITING)      if (m_glWebViewState)          m_glWebViewState->setBaseLayer(layer, inval, showVisualIndicator,                                         isPictureAfterFirstLayout); +    m_pageSwapCallbackRegistered |= registerPageSwapCallback;  #endif  #if ENABLE(ANDROID_OVERFLOW_SCROLL) @@ -1513,6 +1529,7 @@ private: // local state for WebView      Functor* m_glDrawFunctor;  #if USE(ACCELERATED_COMPOSITING)      GLWebViewState* m_glWebViewState; +    bool m_pageSwapCallbackRegistered;  #endif      const RenderSkinButton* m_buttonSkin;  }; // end of WebView class @@ -1875,14 +1892,16 @@ static bool nativeEvaluateLayersAnimations(JNIEnv *env, jobject obj)  static void nativeSetBaseLayer(JNIEnv *env, jobject obj, jint layer, jobject inval,                                  jboolean showVisualIndicator, -                                jboolean isPictureAfterFirstLayout) +                                jboolean isPictureAfterFirstLayout, +                                jboolean registerPageSwapCallback)  {      BaseLayerAndroid* layerImpl = reinterpret_cast<BaseLayerAndroid*>(layer);      SkRegion invalRegion;      if (inval)          invalRegion = *GraphicsJNI::getNativeRegion(env, inval);      GET_NATIVE_VIEW(env, obj)->setBaseLayer(layerImpl, invalRegion, showVisualIndicator, -                                            isPictureAfterFirstLayout); +                                            isPictureAfterFirstLayout, +                                            registerPageSwapCallback);  }  static BaseLayerAndroid* nativeGetBaseLayer(JNIEnv *env, jobject obj) @@ -2748,7 +2767,7 @@ static JNINativeMethod gJavaWebViewMethods[] = {          (void*) nativeSetFindIsUp },      { "nativeSetHeightCanMeasure", "(Z)V",          (void*) nativeSetHeightCanMeasure }, -    { "nativeSetBaseLayer", "(ILandroid/graphics/Region;ZZ)V", +    { "nativeSetBaseLayer", "(ILandroid/graphics/Region;ZZZ)V",          (void*) nativeSetBaseLayer },      { "nativeGetBaseLayer", "()I",          (void*) nativeGetBaseLayer }, | 
