summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk13
-rw-r--r--Source/Android.mk8
-rw-r--r--Source/JavaScriptCore/parser/Parser.cpp10
-rw-r--r--Source/JavaScriptCore/runtime/TimeoutChecker.h12
-rw-r--r--Source/JavaScriptCore/wtf/Assertions.cpp8
-rw-r--r--Source/JavaScriptCore/wtf/Platform.h6
-rw-r--r--Source/WebCore/Android.derived.jscbindings.mk1
-rw-r--r--Source/WebCore/Android.derived.v8bindings.mk1
-rw-r--r--Source/WebCore/Android.jscbindings.mk1
-rw-r--r--Source/WebCore/Android.mk5
-rw-r--r--Source/WebCore/Android.v8bindings.mk1
-rw-r--r--Source/WebCore/DerivedSources.cpp1
-rw-r--r--Source/WebCore/bindings/js/JSBindingsAllInOne.cpp1
-rw-r--r--Source/WebCore/bindings/js/JSDOMWindowCustom.cpp6
-rw-r--r--Source/WebCore/bindings/js/JSFloat64ArrayCustom.cpp61
-rw-r--r--Source/WebCore/bindings/v8/V8DOMWindowShell.cpp12
-rw-r--r--Source/WebCore/bindings/v8/V8Proxy.cpp34
-rw-r--r--Source/WebCore/bindings/v8/V8Proxy.h8
-rw-r--r--Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp61
-rw-r--r--Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp43
-rw-r--r--Source/WebCore/bridge/jni/v8/JavaValueV8.h13
-rw-r--r--Source/WebCore/css/CSSImportRule.cpp22
-rw-r--r--Source/WebCore/css/CSSImportRule.h8
-rw-r--r--Source/WebCore/css/CSSParser.cpp55
-rw-r--r--Source/WebCore/css/CSSStyleDeclaration.cpp1
-rw-r--r--Source/WebCore/css/StyleBase.cpp33
-rw-r--r--Source/WebCore/css/StyleBase.h12
-rw-r--r--Source/WebCore/dom/Document.cpp14
-rw-r--r--Source/WebCore/dom/Node.cpp33
-rw-r--r--Source/WebCore/dom/Node.h12
-rw-r--r--Source/WebCore/dom/ProcessingInstruction.cpp22
-rw-r--r--Source/WebCore/dom/ProcessingInstruction.h8
-rw-r--r--Source/WebCore/dom/Text.cpp2
-rw-r--r--Source/WebCore/html/HTMLCanvasElement.h16
-rw-r--r--Source/WebCore/html/HTMLDocument.cpp22
-rw-r--r--Source/WebCore/html/HTMLDocument.h8
-rw-r--r--Source/WebCore/html/HTMLLinkElement.cpp22
-rw-r--r--Source/WebCore/html/HTMLLinkElement.h8
-rw-r--r--Source/WebCore/html/HTMLMediaElement.cpp7
-rw-r--r--Source/WebCore/html/canvas/ArrayBufferView.h1
-rw-r--r--Source/WebCore/html/canvas/Float64Array.cpp62
-rw-r--r--Source/WebCore/html/canvas/Float64Array.h75
-rw-r--r--Source/WebCore/html/canvas/Float64Array.idl48
-rw-r--r--Source/WebCore/html/parser/HTMLDocumentParser.cpp14
-rw-r--r--Source/WebCore/loader/FrameLoader.cpp19
-rw-r--r--Source/WebCore/loader/archive/android/WebArchiveAndroid.cpp61
-rw-r--r--Source/WebCore/loader/cache/MemoryCache.h6
-rw-r--r--Source/WebCore/loader/icon/IconDatabase.cpp26
-rw-r--r--Source/WebCore/page/DOMWindow.idl1
-rw-r--r--Source/WebCore/page/Frame.cpp4
-rw-r--r--Source/WebCore/page/FrameView.cpp14
-rw-r--r--Source/WebCore/platform/Arena.cpp12
-rw-r--r--Source/WebCore/platform/Arena.h4
-rw-r--r--Source/WebCore/platform/NotImplemented.h16
-rw-r--r--Source/WebCore/platform/android/RenderThemeAndroid.cpp8
-rw-r--r--Source/WebCore/platform/android/SharedTimerAndroid.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp9
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.cpp103
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.h6
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTileTexture.cpp154
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTileTexture.h53
-rw-r--r--Source/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp217
-rw-r--r--Source/WebCore/platform/graphics/android/DoubleBufferedTexture.h74
-rw-r--r--Source/WebCore/platform/graphics/android/FontAndroid.cpp91
-rw-r--r--Source/WebCore/platform/graphics/android/FontPlatformData.h2
-rw-r--r--Source/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp50
-rw-r--r--Source/WebCore/platform/graphics/android/GLExtras.cpp63
-rw-r--r--Source/WebCore/platform/graphics/android/GLExtras.h16
-rw-r--r--Source/WebCore/platform/graphics/android/GLUtils.cpp168
-rw-r--r--Source/WebCore/platform/graphics/android/GLUtils.h9
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp89
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.h7
-rw-r--r--Source/WebCore/platform/graphics/android/GaneshContext.cpp6
-rw-r--r--Source/WebCore/platform/graphics/android/GaneshRenderer.cpp40
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp24
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h2
-rw-r--r--Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp4
-rw-r--r--Source/WebCore/platform/graphics/android/ImageTexture.cpp6
-rw-r--r--Source/WebCore/platform/graphics/android/InspectorCanvas.cpp149
-rw-r--r--Source/WebCore/platform/graphics/android/InspectorCanvas.h102
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.cpp100
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.h5
-rw-r--r--Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h1
-rw-r--r--Source/WebCore/platform/graphics/android/MediaTexture.cpp1
-rw-r--r--Source/WebCore/platform/graphics/android/PaintedSurface.cpp12
-rw-r--r--Source/WebCore/platform/graphics/android/PaintedSurface.h2
-rw-r--r--Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp29
-rw-r--r--Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h3
-rw-r--r--Source/WebCore/platform/graphics/android/ShaderProgram.cpp374
-rw-r--r--Source/WebCore/platform/graphics/android/ShaderProgram.h138
-rw-r--r--Source/WebCore/platform/graphics/android/SharedTexture.cpp248
-rw-r--r--Source/WebCore/platform/graphics/android/SharedTexture.h118
-rw-r--r--Source/WebCore/platform/graphics/android/TextureInfo.cpp3
-rw-r--r--Source/WebCore/platform/graphics/android/TextureInfo.h16
-rw-r--r--Source/WebCore/platform/graphics/android/TiledPage.cpp10
-rw-r--r--Source/WebCore/platform/graphics/android/TiledTexture.cpp35
-rw-r--r--Source/WebCore/platform/graphics/android/TiledTexture.h10
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.cpp44
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.h15
-rw-r--r--Source/WebCore/platform/graphics/android/TransferQueue.cpp95
-rw-r--r--Source/WebCore/platform/graphics/android/TransferQueue.h17
-rw-r--r--Source/WebCore/platform/graphics/android/TreeManager.cpp4
-rw-r--r--Source/WebCore/platform/graphics/android/VerticalTextMap.cpp38
-rw-r--r--Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp133
-rw-r--r--Source/WebCore/platform/graphics/android/VideoLayerAndroid.h7
-rw-r--r--Source/WebCore/platform/graphics/android/VideoLayerManager.cpp36
-rw-r--r--Source/WebCore/platform/graphics/android/VideoLayerManager.h15
-rw-r--r--Source/WebCore/rendering/InlineTextBox.cpp1
-rw-r--r--Source/WebCore/rendering/RenderArena.cpp7
-rw-r--r--Source/WebCore/rendering/RenderArena.h4
-rw-r--r--Source/WebCore/rendering/RenderLayer.cpp3
-rw-r--r--Source/WebCore/storage/AbstractDatabase.h4
-rw-r--r--Source/WebCore/storage/DatabaseTask.cpp16
-rw-r--r--Source/WebCore/storage/DatabaseTask.h10
-rw-r--r--Source/WebCore/storage/SQLTransaction.cpp2
-rw-r--r--Source/WebCore/storage/SQLTransaction.h2
-rw-r--r--Source/WebCore/svg/SVGFontFaceUriElement.h16
-rw-r--r--Source/WebCore/workers/WorkerContext.idl1
-rw-r--r--Source/WebCore/xml/XSLImportRule.h16
-rw-r--r--Source/WebKit/Android.mk2
-rw-r--r--Source/WebKit/android/AndroidLog.h5
-rw-r--r--Source/WebKit/android/RenderSkinAndroid.cpp4
-rw-r--r--Source/WebKit/android/RenderSkinButton.cpp2
-rw-r--r--Source/WebKit/android/RenderSkinMediaButton.cpp10
-rw-r--r--Source/WebKit/android/RenderSkinMediaButton.h2
-rw-r--r--Source/WebKit/android/RenderSkinNinePatch.cpp6
-rw-r--r--Source/WebKit/android/TimeCounter.cpp198
-rw-r--r--Source/WebKit/android/TimeCounter.h120
-rw-r--r--Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h49
-rw-r--r--Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp10
-rw-r--r--Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp19
-rw-r--r--Source/WebKit/android/WebCoreSupport/V8Counters.cpp116
-rw-r--r--Source/WebKit/android/WebCoreSupport/V8Counters.h77
-rw-r--r--Source/WebKit/android/WebCoreSupport/WebCookieJar.cpp35
-rw-r--r--Source/WebKit/android/WebCoreSupport/WebCookieJar.h9
-rw-r--r--Source/WebKit/android/WebCoreSupport/WebRequest.cpp21
-rw-r--r--Source/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp9
-rw-r--r--Source/WebKit/android/WebCoreSupport/WebViewClientError.cpp1
-rw-r--r--Source/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp2
-rw-r--r--Source/WebKit/android/benchmark/Intercept.cpp8
-rw-r--r--Source/WebKit/android/benchmark/main.cpp6
-rw-r--r--Source/WebKit/android/jni/CacheManager.cpp2
-rw-r--r--Source/WebKit/android/jni/CookieManager.cpp2
-rw-r--r--Source/WebKit/android/jni/DeviceMotionAndOrientationManager.cpp2
-rwxr-xr-xSource/WebKit/android/jni/GeolocationPermissionsBridge.cpp2
-rw-r--r--Source/WebKit/android/jni/JavaBridge.cpp33
-rw-r--r--Source/WebKit/android/jni/JniUtil.cpp2
-rw-r--r--Source/WebKit/android/jni/MIMETypeRegistry.cpp4
-rwxr-xr-xSource/WebKit/android/jni/MockGeolocation.cpp2
-rw-r--r--Source/WebKit/android/jni/PictureSet.cpp41
-rw-r--r--Source/WebKit/android/jni/PictureSet.h6
-rw-r--r--Source/WebKit/android/jni/WebCoreFrameBridge.cpp367
-rw-r--r--Source/WebKit/android/jni/WebCoreJni.cpp4
-rw-r--r--Source/WebKit/android/jni/WebCoreJniOnLoad.cpp6
-rw-r--r--Source/WebKit/android/jni/WebCoreResourceLoader.cpp63
-rw-r--r--Source/WebKit/android/jni/WebHistory.cpp116
-rw-r--r--Source/WebKit/android/jni/WebIconDatabase.cpp24
-rw-r--r--Source/WebKit/android/jni/WebSettings.cpp108
-rw-r--r--Source/WebKit/android/jni/WebStorage.cpp2
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp1094
-rw-r--r--Source/WebKit/android/jni/WebViewCore.h20
-rw-r--r--Source/WebKit/android/nav/CacheBuilder.cpp362
-rw-r--r--Source/WebKit/android/nav/CachedDebug.h16
-rw-r--r--Source/WebKit/android/nav/CachedNode.cpp4
-rw-r--r--Source/WebKit/android/nav/CachedRoot.cpp12
-rw-r--r--Source/WebKit/android/nav/CachedRoot.h2
-rw-r--r--Source/WebKit/android/nav/FindCanvas.cpp23
-rw-r--r--Source/WebKit/android/nav/FindCanvas.h11
-rw-r--r--Source/WebKit/android/nav/SelectText.cpp2
-rw-r--r--Source/WebKit/android/nav/WebView.cpp186
-rw-r--r--Source/WebKit/android/plugins/ANPSoundInterface.cpp6
-rw-r--r--Source/WebKit/android/smoke/MessageThread.cpp2
-rw-r--r--Source/WebKit/android/wds/Command.cpp2
-rw-r--r--Source/WebKit/android/wds/Connection.cpp2
-rw-r--r--Source/WebKit/android/wds/DebugServer.cpp16
-rw-r--r--Source/WebKit/android/wds/client/AdbConnection.cpp24
-rw-r--r--Source/WebKit/android/wds/client/ClientUtils.h2
-rw-r--r--Source/WebKit/android/wds/client/main.cpp16
178 files changed, 3166 insertions, 4152 deletions
diff --git a/Android.mk b/Android.mk
index 623a35f..964ce1d 100644
--- a/Android.mk
+++ b/Android.mk
@@ -316,6 +316,7 @@ LOCAL_CFLAGS += -DGOOGLEURL
LOCAL_CFLAGS += -DWTF_USE_CHROME_NETWORK_STACK
endif # HTTP_STACK == chrome
LOCAL_CPPFLAGS := -Wno-sign-promo
+LOCAL_CPPFLAGS := -Wno-c++0x-compat
# Adds GL and EGL extensions for the GL backend
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
@@ -352,10 +353,6 @@ ifeq ($(ENABLE_WTF_USE_ACCELERATED_COMPOSITING),true)
LOCAL_CFLAGS += -DWTF_USE_ACCELERATED_COMPOSITING=1
endif
-ifeq ($(WEBCORE_INSTRUMENTATION),true)
-LOCAL_CFLAGS += -DANDROID_INSTRUMENT
-endif
-
# LOCAL_LDLIBS is used in simulator builds only and simulator builds are only
# valid on Linux
LOCAL_LDLIBS += -lpthread -ldl
@@ -377,14 +374,6 @@ LOCAL_SHARED_LIBRARIES := \
libGLESv2 \
libgui
-ifeq ($(PLATFORM_VERSION),3.1.4.1.5.9.2.6.5)
-LOCAL_SHARED_LIBRARIES += libsurfaceflinger_client
-endif
-
-ifeq ($(WEBCORE_INSTRUMENTATION),true)
-LOCAL_SHARED_LIBRARIES += libhardware_legacy
-endif
-
# We have to use the android version of libdl
LOCAL_SHARED_LIBRARIES += libdl libstlport
# We have to fake out some headers when using stlport.
diff --git a/Source/Android.mk b/Source/Android.mk
index fd1f622..6612cae 100644
--- a/Source/Android.mk
+++ b/Source/Android.mk
@@ -224,10 +224,6 @@ ifeq ($(ENABLE_SVG_ANIMATION),true)
LOCAL_CFLAGS += -DENABLE_SVG_ANIMATION=1
endif
-ifeq ($(WEBCORE_INSTRUMENTATION),true)
-LOCAL_CFLAGS += -DANDROID_INSTRUMENT
-endif
-
# LOCAL_LDLIBS is used in simulator builds only and simulator builds are only
# valid on Linux
LOCAL_LDLIBS += -lpthread -ldl
@@ -246,10 +242,6 @@ LOCAL_SHARED_LIBRARIES := \
libicui18n \
libmedia
-ifeq ($(WEBCORE_INSTRUMENTATION),true)
-LOCAL_SHARED_LIBRARIES += libhardware_legacy
-endif
-
# We have to use the android version of libdl.
LOCAL_SHARED_LIBRARIES += libdl
diff --git a/Source/JavaScriptCore/parser/Parser.cpp b/Source/JavaScriptCore/parser/Parser.cpp
index dc15e4f..fc1e986 100644
--- a/Source/JavaScriptCore/parser/Parser.cpp
+++ b/Source/JavaScriptCore/parser/Parser.cpp
@@ -27,17 +27,10 @@
#include "JSParser.h"
#include "Lexer.h"
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
-
namespace JSC {
void Parser::parse(JSGlobalData* globalData, FunctionParameters* parameters, JSParserStrictness strictness, JSParserMode mode, int* errLine, UString* errMsg)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::JavaScriptParseTimeCounter);
-#endif
ASSERT(globalData);
m_sourceElements = 0;
@@ -65,9 +58,6 @@ void Parser::parse(JSGlobalData* globalData, FunctionParameters* parameters, JSP
*errMsg = parseError ? parseError : "Parse error";
m_sourceElements = 0;
}
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::JavaScriptParseTimeCounter, __FUNCTION__);
-#endif
}
void Parser::didFinishParsing(SourceElements* sourceElements, ParserArenaData<DeclarationStacks::VarStack>* varStack,
diff --git a/Source/JavaScriptCore/runtime/TimeoutChecker.h b/Source/JavaScriptCore/runtime/TimeoutChecker.h
index 71ce169..5925641 100644
--- a/Source/JavaScriptCore/runtime/TimeoutChecker.h
+++ b/Source/JavaScriptCore/runtime/TimeoutChecker.h
@@ -31,10 +31,6 @@
#include <wtf/Assertions.h>
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
-
namespace JSC {
class ExecState;
@@ -52,10 +48,6 @@ namespace JSC {
{
if (!m_startCount)
reset();
-#ifdef ANDROID_INSTRUMENT
- if (!m_startCount)
- android::TimeCounter::start(android::TimeCounter::JavaScriptTimeCounter);
-#endif
++m_startCount;
}
@@ -63,10 +55,6 @@ namespace JSC {
{
ASSERT(m_startCount);
--m_startCount;
-#ifdef ANDROID_INSTRUMENT
- if (!m_startCount)
- android::TimeCounter::record(android::TimeCounter::JavaScriptTimeCounter, __FUNCTION__);
-#endif
}
void reset();
diff --git a/Source/JavaScriptCore/wtf/Assertions.cpp b/Source/JavaScriptCore/wtf/Assertions.cpp
index 930368c..0642414 100644
--- a/Source/JavaScriptCore/wtf/Assertions.cpp
+++ b/Source/JavaScriptCore/wtf/Assertions.cpp
@@ -66,6 +66,10 @@
#include <execinfo.h>
#endif
+#if OS(ANDROID)
+#include <utils/Log.h>
+#endif
+
extern "C" {
#if PLATFORM(BREWMP)
@@ -124,7 +128,9 @@ static void vprintf_stderr_common(const char* format, va_list args)
vsnprintf(buffer.data(), size, format, args);
printLog(buffer);
}
-
+#elif OS(ANDROID)
+ LOG_PRI_VA(ANDROID_LOG_DEBUG, "WebKit", format, args);
+ return;
#elif HAVE(ISDEBUGGERPRESENT)
if (IsDebuggerPresent()) {
size_t size = 1024;
diff --git a/Source/JavaScriptCore/wtf/Platform.h b/Source/JavaScriptCore/wtf/Platform.h
index e92af89..6e270eb 100644
--- a/Source/JavaScriptCore/wtf/Platform.h
+++ b/Source/JavaScriptCore/wtf/Platform.h
@@ -676,7 +676,10 @@
#if PLATFORM(ANDROID)
#define WEBCORE_NAVIGATOR_VENDOR "Google Inc."
-#define LOG_DISABLED 1
+// Force LOG_ERROR() to be enabled in all builds. All other logging and
+// assertions are enabled in debug builds only.
+#define ERROR_DISABLED 0
+
// This must be defined before we include FastMalloc.h in config.h.
#define USE_SYSTEM_MALLOC 1
@@ -688,6 +691,7 @@
#define ENABLE_3D_RENDERING 1
#endif
+#define ENABLE_ANDROID_NAVCACHE 1
// ENABLE guards
#define ENABLE_JAVA_BRIDGE 1
// Prevents Webkit from drawing the caret in textfields and textareas
diff --git a/Source/WebCore/Android.derived.jscbindings.mk b/Source/WebCore/Android.derived.jscbindings.mk
index d859b15..f48fc6a 100644
--- a/Source/WebCore/Android.derived.jscbindings.mk
+++ b/Source/WebCore/Android.derived.jscbindings.mk
@@ -316,6 +316,7 @@ GEN := \
$(intermediates)/html/canvas/JSCanvasRenderingContext2D.h \
$(intermediates)/html/canvas/JSDataView.h \
$(intermediates)/html/canvas/JSFloat32Array.h \
+ $(intermediates)/html/canvas/JSFloat64Array.h \
$(intermediates)/html/canvas/JSInt8Array.h \
$(intermediates)/html/canvas/JSInt16Array.h \
$(intermediates)/html/canvas/JSInt32Array.h \
diff --git a/Source/WebCore/Android.derived.v8bindings.mk b/Source/WebCore/Android.derived.v8bindings.mk
index 992cc40..546cefe 100644
--- a/Source/WebCore/Android.derived.v8bindings.mk
+++ b/Source/WebCore/Android.derived.v8bindings.mk
@@ -301,6 +301,7 @@ GEN := \
$(intermediates)/bindings/V8CanvasRenderingContext2D.h \
$(intermediates)/bindings/V8DataView.h \
$(intermediates)/bindings/V8Float32Array.h \
+ $(intermediates)/bindings/V8Float64Array.h \
$(intermediates)/bindings/V8Int8Array.h \
$(intermediates)/bindings/V8Int16Array.h \
$(intermediates)/bindings/V8Int32Array.h \
diff --git a/Source/WebCore/Android.jscbindings.mk b/Source/WebCore/Android.jscbindings.mk
index bdd6d92..09ea61c 100644
--- a/Source/WebCore/Android.jscbindings.mk
+++ b/Source/WebCore/Android.jscbindings.mk
@@ -121,6 +121,7 @@ LOCAL_SRC_FILES += \
bindings/js/JSEventTarget.cpp \
bindings/js/JSExceptionBase.cpp \
bindings/js/JSFloat32ArrayCustom.cpp \
+ bindings/js/JSFloat64ArrayCustom.cpp \
bindings/js/JSFileReaderCustom.cpp \
bindings/js/JSGeolocationCustom.cpp \
bindings/js/JSHTMLAllCollectionCustom.cpp \
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk
index 6542931..bdf6410 100644
--- a/Source/WebCore/Android.mk
+++ b/Source/WebCore/Android.mk
@@ -378,6 +378,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
html/canvas/CanvasStyle.cpp \
html/canvas/DataView.cpp \
html/canvas/Float32Array.cpp \
+ html/canvas/Float64Array.cpp \
html/canvas/Int16Array.cpp \
html/canvas/Int32Array.cpp \
html/canvas/Int8Array.cpp \
@@ -638,7 +639,6 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/android/BaseTileTexture.cpp \
platform/graphics/android/BitmapAllocatorAndroid.cpp \
platform/graphics/android/ClassTracker.cpp \
- platform/graphics/android/DoubleBufferedTexture.cpp \
platform/graphics/android/FontAndroid.cpp \
platform/graphics/android/FontCacheAndroid.cpp \
platform/graphics/android/FontCustomPlatformData.cpp \
@@ -658,6 +658,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/android/ImageSourceAndroid.cpp \
platform/graphics/android/ImagesManager.cpp \
platform/graphics/android/ImageTexture.cpp \
+ platform/graphics/android/InspectorCanvas.cpp \
platform/graphics/android/Layer.cpp \
platform/graphics/android/LayerAndroid.cpp \
platform/graphics/android/MediaLayer.cpp \
@@ -672,7 +673,6 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/android/ScrollableLayerAndroid.cpp \
platform/graphics/android/SharedBufferStream.cpp \
platform/graphics/android/ShaderProgram.cpp \
- platform/graphics/android/SharedTexture.cpp \
platform/graphics/android/TextureInfo.cpp \
platform/graphics/android/TexturesGenerator.cpp \
platform/graphics/android/TilesManager.cpp \
@@ -811,6 +811,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
plugins/DOMPluginArray.cpp \
plugins/PluginData.cpp \
plugins/PluginDatabase.cpp \
+ plugins/PluginDebug.cpp \
plugins/PluginMainThreadScheduler.cpp \
plugins/PluginPackage.cpp \
plugins/PluginStream.cpp \
diff --git a/Source/WebCore/Android.v8bindings.mk b/Source/WebCore/Android.v8bindings.mk
index 283a212..7858ef3 100644
--- a/Source/WebCore/Android.v8bindings.mk
+++ b/Source/WebCore/Android.v8bindings.mk
@@ -130,6 +130,7 @@ LOCAL_SRC_FILES += \
bindings/v8/custom/V8EventSourceConstructor.cpp \
bindings/v8/custom/V8FileReaderCustom.cpp \
bindings/v8/custom/V8Float32ArrayCustom.cpp \
+ bindings/v8/custom/V8Float64ArrayCustom.cpp \
bindings/v8/custom/V8GeolocationCustom.cpp \
bindings/v8/custom/V8HistoryCustom.cpp \
bindings/v8/custom/V8HTMLAllCollectionCustom.cpp \
diff --git a/Source/WebCore/DerivedSources.cpp b/Source/WebCore/DerivedSources.cpp
index 3bba78c..45a425c 100644
--- a/Source/WebCore/DerivedSources.cpp
+++ b/Source/WebCore/DerivedSources.cpp
@@ -130,6 +130,7 @@
#include "JSFileWriterSync.cpp"
#include "JSWebKitFlags.cpp"
#include "JSFloat32Array.cpp"
+#include "JSFloat64Array.cpp"
#include "JSGeolocation.cpp"
#include "JSGeoposition.cpp"
#include "JSHashChangeEvent.cpp"
diff --git a/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp b/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
index a457ce8..82367b2 100644
--- a/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
+++ b/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
@@ -81,6 +81,7 @@
#include "JSEventTarget.cpp"
#include "JSExceptionBase.cpp"
#include "JSFloat32ArrayCustom.cpp"
+#include "JSFloat64ArrayCustom.cpp"
#include "JSGeolocationCustom.cpp"
#include "JSHTMLAllCollectionCustom.cpp"
#include "JSHTMLAppletElementCustom.cpp"
diff --git a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
index 4bde9e5..938be96 100644
--- a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
+++ b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
@@ -31,6 +31,7 @@
#include "JSEventListener.h"
#include "JSEventSource.h"
#include "JSFloat32Array.h"
+#include "JSFloat64Array.h"
#include "JSHTMLCollection.h"
#include "JSHistory.h"
#include "JSImageConstructor.h"
@@ -569,6 +570,11 @@ JSValue JSDOMWindow::float32Array(ExecState* exec) const
return getDOMConstructor<JSFloat32ArrayConstructor>(exec, this);
}
+JSValue JSDOMWindow::float64Array(ExecState* exec) const
+{
+ return getDOMConstructor<JSFloat64ArrayConstructor>(exec, this);
+}
+
JSValue JSDOMWindow::dataView(ExecState* exec) const
{
return getDOMConstructor<JSDataViewConstructor>(exec, this);
diff --git a/Source/WebCore/bindings/js/JSFloat64ArrayCustom.cpp b/Source/WebCore/bindings/js/JSFloat64ArrayCustom.cpp
new file mode 100644
index 0000000..446b0ec
--- /dev/null
+++ b/Source/WebCore/bindings/js/JSFloat64ArrayCustom.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSFloat64Array.h"
+
+#include "Float64Array.h"
+#include "JSArrayBufferViewHelper.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+void JSFloat64Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value)
+{
+ impl()->set(index, value.toNumber(exec));
+}
+
+JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Float64Array* object)
+{
+ return toJSArrayBufferView<JSFloat64Array>(exec, globalObject, object);
+}
+
+JSC::JSValue JSFloat64Array::set(JSC::ExecState* exec)
+{
+ return setWebGLArrayHelper(exec, impl(), toFloat64Array);
+}
+
+EncodedJSValue JSC_HOST_CALL JSFloat64ArrayConstructor::constructJSFloat64Array(ExecState* exec)
+{
+ JSFloat64ArrayConstructor* jsConstructor = static_cast<JSFloat64ArrayConstructor*>(exec->callee());
+ RefPtr<Float64Array> array = constructArrayBufferView<Float64Array, double>(exec);
+ if (!array.get())
+ // Exception has already been thrown.
+ return JSValue::encode(JSValue());
+ return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get())));
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp b/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp
index e025008..c3a0cbb 100644
--- a/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp
+++ b/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp
@@ -76,10 +76,6 @@
#include <wtf/UnusedParam.h>
#include <wtf/text/CString.h>
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
-
namespace WebCore {
static void handleFatalErrorInV8()
@@ -283,10 +279,6 @@ bool V8DOMWindowShell::initContextIfNeeded()
if (!m_context.IsEmpty())
return false;
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::JavaScriptInitTimeCounter);
-#endif
-
// Create a handle scope for all local handles.
v8::HandleScope handleScope;
@@ -352,10 +344,6 @@ bool V8DOMWindowShell::initContextIfNeeded()
// we do isolated worlds the WebCore way.
m_frame->loader()->dispatchDidClearWindowObjectInWorld(0);
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::JavaScriptInitTimeCounter, __FUNCTION__);
-#endif
-
return true;
}
diff --git a/Source/WebCore/bindings/v8/V8Proxy.cpp b/Source/WebCore/bindings/v8/V8Proxy.cpp
index ca57fa8..d90cf1c 100644
--- a/Source/WebCore/bindings/v8/V8Proxy.cpp
+++ b/Source/WebCore/bindings/v8/V8Proxy.cpp
@@ -83,14 +83,6 @@
#include <wtf/UnusedParam.h>
#include <wtf/text/StringConcatenate.h>
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
-
-#if PLATFORM(ANDROID)
-#include <wtf/text/CString.h>
-#endif
-
namespace WebCore {
// Static list of registered extensions
@@ -209,16 +201,6 @@ V8Proxy::~V8Proxy()
}
v8::Handle<v8::Script> V8Proxy::compileScript(v8::Handle<v8::String> code, const String& fileName, const TextPosition0& scriptStartPosition, v8::ScriptData* scriptData)
-#ifdef ANDROID_INSTRUMENT
-{
- android::TimeCounter::start(android::TimeCounter::JavaScriptParseTimeCounter);
- v8::Handle<v8::Script> script = compileScriptInternal(code, fileName, scriptStartPosition, scriptData);
- android::TimeCounter::record(android::TimeCounter::JavaScriptParseTimeCounter, __FUNCTION__);
- return script;
-}
-
-v8::Handle<v8::Script> V8Proxy::compileScriptInternal(v8::Handle<v8::String> code, const String& fileName, const TextPosition0& scriptStartPosition, v8::ScriptData* scriptData)
-#endif
{
const uint16_t* fileNameString = fromWebCoreString(fileName);
v8::Handle<v8::String> name = v8::String::New(fileNameString, fileName.length());
@@ -398,16 +380,6 @@ v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* nod
}
v8::Local<v8::Value> V8Proxy::runScript(v8::Handle<v8::Script> script, bool isInlineCode)
-#ifdef ANDROID_INSTRUMENT
-{
- android::TimeCounter::start(android::TimeCounter::JavaScriptExecuteTimeCounter);
- v8::Local<v8::Value> result = runScriptInternal(script, isInlineCode);
- android::TimeCounter::record(android::TimeCounter::JavaScriptExecuteTimeCounter, __FUNCTION__);
- return result;
-}
-
-v8::Local<v8::Value> V8Proxy::runScriptInternal(v8::Handle<v8::Script> script, bool isInlineCode)
-#endif
{
if (script.IsEmpty())
return notHandledByInterceptor();
@@ -472,9 +444,6 @@ v8::Local<v8::Value> V8Proxy::runScriptInternal(v8::Handle<v8::Script> script, b
v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[])
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::JavaScriptExecuteTimeCounter);
-#endif
V8GCController::checkMemoryUsage();
v8::Local<v8::Value> result;
{
@@ -521,9 +490,6 @@ v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8
if (v8::V8::IsDead())
handleFatalErrorInV8();
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::JavaScriptExecuteTimeCounter, __FUNCTION__);
-#endif
return result;
}
diff --git a/Source/WebCore/bindings/v8/V8Proxy.h b/Source/WebCore/bindings/v8/V8Proxy.h
index fc52b19..777815b 100644
--- a/Source/WebCore/bindings/v8/V8Proxy.h
+++ b/Source/WebCore/bindings/v8/V8Proxy.h
@@ -171,10 +171,6 @@ namespace WebCore {
// Run an already compiled script.
v8::Local<v8::Value> runScript(v8::Handle<v8::Script>, bool isInlineCode);
-#ifdef ANDROID_INSTRUMENT
- v8::Local<v8::Value> runScriptInternal(v8::Handle<v8::Script> script, bool inline_code);
-#endif
-
// Call the function with the given receiver and arguments.
v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> argv[]);
@@ -244,10 +240,6 @@ namespace WebCore {
static v8::Handle<v8::Script> compileScript(v8::Handle<v8::String> code, const String& fileName, const TextPosition0& scriptStartPosition, v8::ScriptData* = 0);
-#ifdef ANDROID_INSTRUMENT
- static v8::Handle<v8::Script> compileScriptInternal(v8::Handle<v8::String> code, const String& fileName, int baseLine, v8::ScriptData* scriptData);
-#endif
-
// If the exception code is different from zero, a DOM exception is
// schedule to be thrown.
static void setDOMException(int exceptionCode);
diff --git a/Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp b/Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp
new file mode 100644
index 0000000..429e962
--- /dev/null
+++ b/Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Float64Array.h"
+
+#include "ArrayBuffer.h"
+#include "V8ArrayBuffer.h"
+#include "V8ArrayBufferViewCustom.h"
+#include "V8Binding.h"
+#include "V8Float64Array.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> V8Float64Array::constructorCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.Float64Array.Contructor");
+
+ return constructWebGLArray<Float64Array, double>(args, &info, v8::kExternalDoubleArray);
+}
+
+v8::Handle<v8::Value> V8Float64Array::setCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.Float64Array.set()");
+ return setWebGLArrayHelper<Float64Array, V8Float64Array>(args);
+}
+
+v8::Handle<v8::Value> toV8(Float64Array* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8Float64Array::wrap(impl);
+ if (!wrapper.IsEmpty())
+ wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalDoubleArray, impl->length());
+ return wrapper;
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp b/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
index 42efaac..15b4bda 100644
--- a/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
+++ b/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
@@ -72,11 +72,16 @@ JavaValue convertNPVariantToJavaValue(NPVariant value, const String& javaClass)
break;
}
- jsize length = 0;
- if (NPVARIANT_IS_INT32(npvLength))
- length = static_cast<jsize>(NPVARIANT_TO_INT32(npvLength));
- else if (NPVARIANT_IS_DOUBLE(npvLength))
- length = static_cast<jsize>(NPVARIANT_TO_DOUBLE(npvLength));
+ // Convert to null if the length property is not a number.
+ if (!NPVARIANT_IS_INT32(npvLength) && !NPVARIANT_IS_DOUBLE(npvLength))
+ break;
+
+ // Convert to null if the length property is out of bounds.
+ double doubleLength = NPVARIANT_IS_INT32(npvLength) ? NPVARIANT_TO_INT32(npvLength) : NPVARIANT_TO_DOUBLE(npvLength);
+ if (doubleLength < 0.0 || doubleLength > INT32_MAX)
+ break;
+
+ jsize length = static_cast<jsize>(doubleLength);
if (!strcmp(javaClassName.data(), "[Ljava.lang.String;")) {
// Match JSC behavior by only allowing Object arrays if they are Strings.
@@ -85,7 +90,7 @@ JavaValue convertNPVariantToJavaValue(NPVariant value, const String& javaClass)
for (jsize i = 0; i < length; i++) {
NPVariant npvValue;
_NPN_GetProperty(0, object, _NPN_GetIntIdentifier(i), &npvValue);
- if(NPVARIANT_IS_STRING(npvValue)) {
+ if (NPVARIANT_IS_STRING(npvValue)) {
NPString str = NPVARIANT_TO_STRING(npvValue);
env->SetObjectArrayElement(static_cast<jobjectArray>(javaArray), i, env->NewStringUTF(str.UTF8Characters));
}
@@ -100,11 +105,10 @@ JavaValue convertNPVariantToJavaValue(NPVariant value, const String& javaClass)
NPVariant npvValue;
_NPN_GetProperty(0, object, _NPN_GetIntIdentifier(i), &npvValue);
jbyte bVal = 0;
- if (NPVARIANT_IS_INT32(npvValue)) {
+ if (NPVARIANT_IS_INT32(npvValue))
bVal = static_cast<jbyte>(NPVARIANT_TO_INT32(npvValue));
- } else if (NPVARIANT_IS_DOUBLE(npvValue)) {
+ else if (NPVARIANT_IS_DOUBLE(npvValue))
bVal = static_cast<jbyte>(NPVARIANT_TO_DOUBLE(npvValue));
- }
env->SetByteArrayRegion(static_cast<jbyteArray>(javaArray), i, 1, &bVal);
}
} else if (!strcmp(javaClassName.data(), "[C")) {
@@ -115,12 +119,8 @@ JavaValue convertNPVariantToJavaValue(NPVariant value, const String& javaClass)
NPVariant npvValue;
_NPN_GetProperty(0, object, _NPN_GetIntIdentifier(i), &npvValue);
jchar cVal = 0;
- if (NPVARIANT_IS_INT32(npvValue)) {
+ if (NPVARIANT_IS_INT32(npvValue))
cVal = static_cast<jchar>(NPVARIANT_TO_INT32(npvValue));
- } else if (NPVARIANT_IS_STRING(npvValue)) {
- NPString str = NPVARIANT_TO_STRING(npvValue);
- cVal = str.UTF8Characters[0];
- }
env->SetCharArrayRegion(static_cast<jcharArray>(javaArray), i, 1, &cVal);
}
} else if (!strcmp(javaClassName.data(), "[D")) {
@@ -155,11 +155,10 @@ JavaValue convertNPVariantToJavaValue(NPVariant value, const String& javaClass)
NPVariant npvValue;
_NPN_GetProperty(0, object, _NPN_GetIntIdentifier(i), &npvValue);
jint iVal = 0;
- if (NPVARIANT_IS_INT32(npvValue)) {
+ if (NPVARIANT_IS_INT32(npvValue))
iVal = NPVARIANT_TO_INT32(npvValue);
- } else if (NPVARIANT_IS_DOUBLE(npvValue)) {
+ else if (NPVARIANT_IS_DOUBLE(npvValue))
iVal = static_cast<jint>(NPVARIANT_TO_DOUBLE(npvValue));
- }
env->SetIntArrayRegion(static_cast<jintArray>(javaArray), i, 1, &iVal);
}
} else if (!strcmp(javaClassName.data(), "[J")) {
@@ -170,11 +169,10 @@ JavaValue convertNPVariantToJavaValue(NPVariant value, const String& javaClass)
NPVariant npvValue;
_NPN_GetProperty(0, object, _NPN_GetIntIdentifier(i), &npvValue);
jlong jVal = 0;
- if (NPVARIANT_IS_INT32(npvValue)) {
+ if (NPVARIANT_IS_INT32(npvValue))
jVal = static_cast<jlong>(NPVARIANT_TO_INT32(npvValue));
- } else if (NPVARIANT_IS_DOUBLE(npvValue)) {
+ else if (NPVARIANT_IS_DOUBLE(npvValue))
jVal = static_cast<jlong>(NPVARIANT_TO_DOUBLE(npvValue));
- }
env->SetLongArrayRegion(static_cast<jlongArray>(javaArray), i, 1, &jVal);
}
} else if (!strcmp(javaClassName.data(), "[S")) {
@@ -185,11 +183,10 @@ JavaValue convertNPVariantToJavaValue(NPVariant value, const String& javaClass)
NPVariant npvValue;
_NPN_GetProperty(0, object, _NPN_GetIntIdentifier(i), &npvValue);
jshort sVal = 0;
- if (NPVARIANT_IS_INT32(npvValue)) {
+ if (NPVARIANT_IS_INT32(npvValue))
sVal = static_cast<jshort>(NPVARIANT_TO_INT32(npvValue));
- } else if (NPVARIANT_IS_DOUBLE(npvValue)) {
+ else if (NPVARIANT_IS_DOUBLE(npvValue))
sVal = static_cast<jshort>(NPVARIANT_TO_DOUBLE(npvValue));
- }
env->SetShortArrayRegion(static_cast<jshortArray>(javaArray), i, 1, &sVal);
}
} else if (!strcmp(javaClassName.data(), "[Z")) {
diff --git a/Source/WebCore/bridge/jni/v8/JavaValueV8.h b/Source/WebCore/bridge/jni/v8/JavaValueV8.h
index 3e1c623..c6ff315 100644
--- a/Source/WebCore/bridge/jni/v8/JavaValueV8.h
+++ b/Source/WebCore/bridge/jni/v8/JavaValueV8.h
@@ -49,7 +49,18 @@ class JavaInstance;
// currently used only with V8.
// See https://bugs.webkit.org/show_bug.cgi?id=57023.
struct JavaValue {
- JavaValue() : m_type(JavaTypeInvalid) {}
+// ANDROID
+ JavaValue()
+ : m_type(JavaTypeInvalid)
+ , m_booleanValue(false)
+ , m_byteValue(0)
+ , m_charValue(0)
+ , m_shortValue(0)
+ , m_intValue(0)
+ , m_longValue(0)
+ , m_floatValue(0.0)
+ , m_doubleValue(0.0) {}
+// ANDROID
JavaType m_type;
// We don't use a union because we want to be able to ref-count some of the
diff --git a/Source/WebCore/css/CSSImportRule.cpp b/Source/WebCore/css/CSSImportRule.cpp
index 09e313e..81ade39 100644
--- a/Source/WebCore/css/CSSImportRule.cpp
+++ b/Source/WebCore/css/CSSImportRule.cpp
@@ -170,26 +170,4 @@ void CSSImportRule::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
addSubresourceURL(urls, m_styleSheet->baseURL());
}
-#ifdef ANDROID_INSTRUMENT
-void* CSSImportRule::operator new(size_t size)
-{
- return StyleBase::operator new(size);
-}
-
-void* CSSImportRule::operator new[](size_t size)
-{
- return StyleBase::operator new[](size);
-}
-
-void CSSImportRule::operator delete(void* p, size_t size)
-{
- StyleBase::operator delete(p, size);
-}
-
-void CSSImportRule::operator delete[](void* p, size_t size)
-{
- StyleBase::operator delete[](p, size);
-}
-#endif
-
} // namespace WebCore
diff --git a/Source/WebCore/css/CSSImportRule.h b/Source/WebCore/css/CSSImportRule.h
index 3f44f5b..ad4e97d 100644
--- a/Source/WebCore/css/CSSImportRule.h
+++ b/Source/WebCore/css/CSSImportRule.h
@@ -66,14 +66,6 @@ private:
// from CachedResourceClient
virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*);
-#ifdef ANDROID_INSTRUMENT
- // Overridden to resolve the ambiguous
- void* operator new(size_t size);
- void* operator new[](size_t size);
- void operator delete(void* p, size_t size);
- void operator delete[](void* p, size_t size);
-#endif
-
String m_strHref;
RefPtr<MediaList> m_lstMedia;
RefPtr<CSSStyleSheet> m_styleSheet;
diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp
index 831e438..78b6b24 100644
--- a/Source/WebCore/css/CSSParser.cpp
+++ b/Source/WebCore/css/CSSParser.cpp
@@ -92,10 +92,6 @@ extern int cssyyparse(void* parser);
using namespace std;
using namespace WTF;
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
-
namespace WebCore {
static const unsigned INVALID_NUM_PARSED_PROPERTIES = UINT_MAX;
@@ -230,9 +226,6 @@ void CSSParser::setupParser(const char* prefix, const String& string, const char
void CSSParser::parseSheet(CSSStyleSheet* sheet, const String& string, int startLineNumber, StyleRuleRangeMap* ruleRangeMap)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
setStyleSheet(sheet);
m_defaultNamespace = starAtom; // Reset the default namespace.
m_ruleRangeMap = ruleRangeMap;
@@ -247,37 +240,22 @@ void CSSParser::parseSheet(CSSStyleSheet* sheet, const String& string, int start
m_ruleRangeMap = 0;
m_currentRuleData = 0;
m_rule = 0;
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
}
PassRefPtr<CSSRule> CSSParser::parseRule(CSSStyleSheet* sheet, const String& string)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
setStyleSheet(sheet);
m_allowNamespaceDeclarations = false;
setupParser("@-webkit-rule{", string, "} ");
cssyyparse(this);
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
return m_rule.release();
}
PassRefPtr<CSSRule> CSSParser::parseKeyframeRule(CSSStyleSheet *sheet, const String &string)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
setStyleSheet(sheet);
setupParser("@-webkit-keyframe-rule{ ", string, "} ");
cssyyparse(this);
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
return m_keyframe.release();
}
@@ -440,9 +418,6 @@ bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int property
bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int propertyId, const String& string, bool important)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet());
setStyleSheet(static_cast<CSSStyleSheet*>(declaration->stylesheet()));
@@ -464,9 +439,6 @@ bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int property
clearProperties();
}
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
return ok;
}
@@ -499,9 +471,6 @@ bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict)
bool CSSParser::parseColor(CSSMutableStyleDeclaration* declaration, const String& string)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet());
setStyleSheet(static_cast<CSSStyleSheet*>(declaration->stylesheet()));
@@ -509,9 +478,6 @@ bool CSSParser::parseColor(CSSMutableStyleDeclaration* declaration, const String
cssyyparse(this);
m_rule = 0;
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
return (m_numParsedProperties && m_parsedProperties[0]->m_id == CSSPropertyColor);
}
@@ -533,9 +499,6 @@ bool CSSParser::parseSystemColor(RGBA32& color, const String& string, Document*
void CSSParser::parseSelector(const String& string, Document* doc, CSSSelectorList& selectorList)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
RefPtr<CSSStyleSheet> dummyStyleSheet = CSSStyleSheet::create(doc);
setStyleSheet(dummyStyleSheet.get());
@@ -549,18 +512,10 @@ void CSSParser::parseSelector(const String& string, Document* doc, CSSSelectorLi
// The style sheet will be deleted right away, so it won't outlive the document.
ASSERT(dummyStyleSheet->hasOneRef());
-
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
}
bool CSSParser::parseDeclaration(CSSMutableStyleDeclaration* declaration, const String& string, RefPtr<CSSStyleSourceData>* styleSourceData)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
-
// Length of the "@-webkit-decls{" prefix.
static const unsigned prefixLength = 15;
@@ -599,9 +554,6 @@ bool CSSParser::parseDeclaration(CSSMutableStyleDeclaration* declaration, const
m_currentRuleData = 0;
m_inStyleRuleOrDeclaration = false;
}
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
return ok;
}
@@ -610,9 +562,6 @@ bool CSSParser::parseMediaQuery(MediaList* queries, const String& string)
if (string.isEmpty())
return true;
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
ASSERT(!m_mediaQuery);
// can't use { because tokenizer state switches from mediaquery to initial state when it sees { token.
@@ -626,9 +575,6 @@ bool CSSParser::parseMediaQuery(MediaList* queries, const String& string)
queries->appendMediaQuery(m_mediaQuery.release());
}
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
return ok;
}
@@ -2016,7 +1962,6 @@ bool CSSParser::parseValue(int propId, bool important)
case CSSPropertyTextOverline:
case CSSPropertyTextUnderline:
return false;
-
#if ENABLE(WCSS)
case CSSPropertyWapInputFormat:
validPrimitive = true;
diff --git a/Source/WebCore/css/CSSStyleDeclaration.cpp b/Source/WebCore/css/CSSStyleDeclaration.cpp
index 1c465e5..d4acc2a 100644
--- a/Source/WebCore/css/CSSStyleDeclaration.cpp
+++ b/Source/WebCore/css/CSSStyleDeclaration.cpp
@@ -27,6 +27,7 @@
#include "CSSPropertyNames.h"
#include "CSSRule.h"
#include <wtf/ASCIICType.h>
+#include <wtf/text/CString.h>
using namespace WTF;
diff --git a/Source/WebCore/css/StyleBase.cpp b/Source/WebCore/css/StyleBase.cpp
index 5d9d79d..93dbda0 100644
--- a/Source/WebCore/css/StyleBase.cpp
+++ b/Source/WebCore/css/StyleBase.cpp
@@ -65,37 +65,4 @@ KURL StyleBase::baseURL() const
return sheet->ownerNode()->document()->baseURL();
}
-#ifdef ANDROID_INSTRUMENT
-static size_t styleSize = 0;
-
-void* StyleBase::operator new(size_t size)
-{
- styleSize += size;
- return ::operator new(size);
-}
-
-void* StyleBase::operator new[](size_t size)
-{
- styleSize += size;
- return ::operator new[](size);
-}
-
-void StyleBase::operator delete(void* p, size_t size)
-{
- styleSize -= size;
- ::operator delete(p);
-}
-
-void StyleBase::operator delete[](void* p, size_t size)
-{
- styleSize -= size;
- ::operator delete[](p);
-}
-
-size_t StyleBase::reportStyleSize()
-{
- return styleSize;
-}
-#endif
-
}
diff --git a/Source/WebCore/css/StyleBase.h b/Source/WebCore/css/StyleBase.h
index 94efa01..63c671e 100644
--- a/Source/WebCore/css/StyleBase.h
+++ b/Source/WebCore/css/StyleBase.h
@@ -72,18 +72,6 @@ namespace WebCore {
StyleSheet* stylesheet();
-#ifdef ANDROID_INSTRUMENT
- // Overridden to prevent the normal new from being called.
- void* operator new(size_t size);
- void* operator new[](size_t size);
-
- // Overridden to prevent the normal delete from being called.
- void operator delete(void* p, size_t size);
- void operator delete[](void* p, size_t size);
-
- static size_t reportStyleSize();
-#endif
-
protected:
StyleBase(StyleBase* parent)
: m_parent(parent)
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index 6e21dc3..20dad55 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -194,10 +194,6 @@
#include "HTMLTextAreaElement.h"
#endif
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
-
#if ENABLE(TOUCH_EVENTS)
#if USE(V8)
#include "RuntimeEnabledFeatures.h"
@@ -1475,10 +1471,6 @@ void Document::recalcStyle(StyleChange change)
frameView->beginDeferredRepaints();
}
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CalculateStyleTimeCounter);
-#endif
-
ASSERT(!renderer() || renderArena());
if (!renderer() || !renderArena())
goto bail_out;
@@ -1500,10 +1492,6 @@ void Document::recalcStyle(StyleChange change)
if (change >= Inherit || n->childNeedsStyleRecalc() || n->needsStyleRecalc())
n->recalcStyle(change);
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CalculateStyleTimeCounter, __FUNCTION__);
-#endif
-
#if USE(ACCELERATED_COMPOSITING)
if (view()) {
bool layoutPending = view()->layoutPending() || renderer()->needsLayout();
@@ -2729,8 +2717,8 @@ void Document::processArguments(const String& features, void* data, ArgumentsCal
#ifdef ANDROID_META_SUPPORT
if (frame())
frame()->settings()->setMetadataSettings(keyString, valueString);
-#endif
if (callback && data)
+#endif
callback(keyString, valueString, this, data);
}
}
diff --git a/Source/WebCore/dom/Node.cpp b/Source/WebCore/dom/Node.cpp
index 1fd4b92..0967ef5 100644
--- a/Source/WebCore/dom/Node.cpp
+++ b/Source/WebCore/dom/Node.cpp
@@ -2498,39 +2498,6 @@ Node* Node::enclosingLinkEventParentOrSelf()
return 0;
}
-#ifdef ANDROID_INSTRUMENT
-static size_t nodeSize = 0;
-
-void* Node::operator new(size_t size)
-{
- nodeSize += size;
- return ::operator new(size);
-}
-
-void* Node::operator new[](size_t size)
-{
- nodeSize += size;
- return ::operator new[](size);
-}
-
-void Node::operator delete(void* p, size_t size)
-{
- nodeSize -= size;
- ::operator delete(p);
-}
-
-void Node::operator delete[](void* p, size_t size)
-{
- nodeSize -= size;
- ::operator delete[](p);
-}
-
-size_t Node::reportDOMNodesSize()
-{
- return nodeSize;
-}
-#endif
-
// --------
ScriptExecutionContext* Node::scriptExecutionContext() const
diff --git a/Source/WebCore/dom/Node.h b/Source/WebCore/dom/Node.h
index 1fe30ad..08b1921 100644
--- a/Source/WebCore/dom/Node.h
+++ b/Source/WebCore/dom/Node.h
@@ -528,18 +528,6 @@ public:
unsigned short compareDocumentPosition(Node*);
-#ifdef ANDROID_INSTRUMENT
- // Overridden to prevent the normal new from being called.
- void* operator new(size_t size);
- void* operator new[](size_t size);
-
- // Overridden to prevent the normal delete from being called.
- void operator delete(void* p, size_t size);
- void operator delete[](void* p, size_t size);
-
- static size_t reportDOMNodesSize();
-#endif
-
virtual Node* toNode() { return this; }
virtual InputElement* toInputElement();
diff --git a/Source/WebCore/dom/ProcessingInstruction.cpp b/Source/WebCore/dom/ProcessingInstruction.cpp
index 7135644..30111d8 100644
--- a/Source/WebCore/dom/ProcessingInstruction.cpp
+++ b/Source/WebCore/dom/ProcessingInstruction.cpp
@@ -297,26 +297,4 @@ void ProcessingInstruction::finishParsingChildren()
ContainerNode::finishParsingChildren();
}
-#ifdef ANDROID_INSTRUMENT
-void* ProcessingInstruction::operator new(size_t size)
-{
- return Node::operator new(size);
-}
-
-void* ProcessingInstruction::operator new[](size_t size)
-{
- return Node::operator new[](size);
-}
-
-void ProcessingInstruction::operator delete(void* p, size_t size)
-{
- Node::operator delete(p, size);
-}
-
-void ProcessingInstruction::operator delete[](void* p, size_t size)
-{
- Node::operator delete[](p, size);
-}
-#endif
-
} // namespace
diff --git a/Source/WebCore/dom/ProcessingInstruction.h b/Source/WebCore/dom/ProcessingInstruction.h
index fd98566..1be8710 100644
--- a/Source/WebCore/dom/ProcessingInstruction.h
+++ b/Source/WebCore/dom/ProcessingInstruction.h
@@ -56,14 +56,6 @@ public:
private:
ProcessingInstruction(Document*, const String& target, const String& data);
-#ifdef ANDROID_INSTRUMENT
- // Overridden to resolve the ambiguous
- void* operator new(size_t size);
- void* operator new[](size_t size);
- void operator delete(void* p, size_t size);
- void operator delete[](void* p, size_t size);
-#endif
-
virtual String nodeName() const;
virtual NodeType nodeType() const;
virtual String nodeValue() const;
diff --git a/Source/WebCore/dom/Text.cpp b/Source/WebCore/dom/Text.cpp
index 906e421..c4ea0a6 100644
--- a/Source/WebCore/dom/Text.cpp
+++ b/Source/WebCore/dom/Text.cpp
@@ -31,6 +31,8 @@
#include "SVGNames.h"
#endif
+#include <wtf/text/CString.h>
+
#if ENABLE(WML)
#include "WMLDocument.h"
#include "WMLVariables.h"
diff --git a/Source/WebCore/html/HTMLCanvasElement.h b/Source/WebCore/html/HTMLCanvasElement.h
index 9eab209..207c384 100644
--- a/Source/WebCore/html/HTMLCanvasElement.h
+++ b/Source/WebCore/html/HTMLCanvasElement.h
@@ -128,22 +128,6 @@ public:
void makeRenderingResultsAvailable();
-#ifdef ANDROID_INSTRUMENT
- void* operator new(size_t size) {
- return HTMLElement::operator new(size);
- }
- void* operator new[](size_t size) {
- return HTMLElement::operator new[](size);
- }
-
- void operator delete(void* p, size_t size) {
- HTMLElement::operator delete(p, size);
- }
- void operator delete[](void* p, size_t size) {
- HTMLElement::operator delete[](p, size);
- }
-#endif
-
private:
HTMLCanvasElement(const QualifiedName&, Document*);
diff --git a/Source/WebCore/html/HTMLDocument.cpp b/Source/WebCore/html/HTMLDocument.cpp
index dd41514..a1be93d 100644
--- a/Source/WebCore/html/HTMLDocument.cpp
+++ b/Source/WebCore/html/HTMLDocument.cpp
@@ -438,26 +438,4 @@ bool HTMLDocument::isFrameSet() const
return bodyElement && bodyElement->hasTagName(framesetTag);
}
-#ifdef ANDROID_INSTRUMENT
-void* HTMLDocument::operator new(size_t size)
-{
- return Node::operator new(size);
-}
-
-void* HTMLDocument::operator new[](size_t size)
-{
- return Node::operator new[](size);
-}
-
-void HTMLDocument::operator delete(void* p, size_t size)
-{
- Node::operator delete(p, size);
-}
-
-void HTMLDocument::operator delete[](void* p, size_t size)
-{
- Node::operator delete[](p, size);
-}
-#endif
-
}
diff --git a/Source/WebCore/html/HTMLDocument.h b/Source/WebCore/html/HTMLDocument.h
index 3310b71..d39f392 100644
--- a/Source/WebCore/html/HTMLDocument.h
+++ b/Source/WebCore/html/HTMLDocument.h
@@ -82,14 +82,6 @@ public:
protected:
HTMLDocument(Frame*, const KURL&);
-#ifdef ANDROID_INSTRUMENT
- // Overridden to resolve the ambiguous
- void* operator new(size_t size);
- void* operator new[](size_t size);
- void operator delete(void* p, size_t size);
- void operator delete[](void* p, size_t size);
-#endif
-
private:
virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
diff --git a/Source/WebCore/html/HTMLLinkElement.cpp b/Source/WebCore/html/HTMLLinkElement.cpp
index 7cbf38b..4673109 100644
--- a/Source/WebCore/html/HTMLLinkElement.cpp
+++ b/Source/WebCore/html/HTMLLinkElement.cpp
@@ -504,28 +504,6 @@ void HTMLLinkElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
styleSheet->addSubresourceStyleURLs(urls);
}
-#ifdef ANDROID_INSTRUMENT
-void* HTMLLinkElement::operator new(size_t size)
-{
- return Node::operator new(size);
-}
-
-void* HTMLLinkElement::operator new[](size_t size)
-{
- return Node::operator new[](size);
-}
-
-void HTMLLinkElement::operator delete(void* p, size_t size)
-{
- Node::operator delete(p, size);
-}
-
-void HTMLLinkElement::operator delete[](void* p, size_t size)
-{
- Node::operator delete[](p, size);
-}
-#endif
-
void HTMLLinkElement::addPendingSheet(PendingSheetType type)
{
if (type <= m_pendingSheetType)
diff --git a/Source/WebCore/html/HTMLLinkElement.h b/Source/WebCore/html/HTMLLinkElement.h
index f602d38..1a6eba9 100644
--- a/Source/WebCore/html/HTMLLinkElement.h
+++ b/Source/WebCore/html/HTMLLinkElement.h
@@ -120,14 +120,6 @@ private:
void addPendingSheet(PendingSheetType);
void removePendingSheet();
-#ifdef ANDROID_INSTRUMENT
- // Overridden to resolve the ambiguous
- void* operator new(size_t size);
- void* operator new[](size_t size);
- void operator delete(void* p, size_t size);
- void operator delete[](void* p, size_t size);
-#endif
-
private:
HTMLLinkElement(const QualifiedName&, Document*, bool createdByParser);
diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp
index 023e8d2..e1f4227 100644
--- a/Source/WebCore/html/HTMLMediaElement.cpp
+++ b/Source/WebCore/html/HTMLMediaElement.cpp
@@ -2402,6 +2402,13 @@ void HTMLMediaElement::defaultEventHandler(Event* event)
}
#endif
+#if PLATFORM(ANDROID)
+ // It is really hard to hit the play/pause button on mobile devices.
+ // This allows user to click the video area to toggle play/pause state.
+ if (event->type() == eventNames().clickEvent
+ && !hasEventListeners(eventNames().clickEvent))
+ togglePlayState();
+#endif
HTMLElement::defaultEventHandler(event);
#endif
}
diff --git a/Source/WebCore/html/canvas/ArrayBufferView.h b/Source/WebCore/html/canvas/ArrayBufferView.h
index 701abbc..d06fc8d 100644
--- a/Source/WebCore/html/canvas/ArrayBufferView.h
+++ b/Source/WebCore/html/canvas/ArrayBufferView.h
@@ -46,6 +46,7 @@ class ArrayBufferView : public RefCounted<ArrayBufferView> {
virtual bool isIntArray() const { return false; }
virtual bool isUnsignedIntArray() const { return false; }
virtual bool isFloatArray() const { return false; }
+ virtual bool isDoubleArray() const { return false; }
virtual bool isDataView() const { return false; }
PassRefPtr<ArrayBuffer> buffer() const
diff --git a/Source/WebCore/html/canvas/Float64Array.cpp b/Source/WebCore/html/canvas/Float64Array.cpp
new file mode 100644
index 0000000..2dcb373
--- /dev/null
+++ b/Source/WebCore/html/canvas/Float64Array.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Float64Array.h"
+
+namespace WebCore {
+
+PassRefPtr<Float64Array> Float64Array::create(unsigned length)
+{
+ return TypedArrayBase<double>::create<Float64Array>(length);
+}
+
+PassRefPtr<Float64Array> Float64Array::create(const double* array, unsigned length)
+{
+ return TypedArrayBase<double>::create<Float64Array>(array, length);
+}
+
+PassRefPtr<Float64Array> Float64Array::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+{
+ return TypedArrayBase<double>::create<Float64Array>(buffer, byteOffset, length);
+}
+
+Float64Array::Float64Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+ : TypedArrayBase<double>(buffer, byteOffset, length)
+{
+}
+
+PassRefPtr<Float64Array> Float64Array::subarray(int start) const
+{
+ return subarray(start, length());
+}
+
+PassRefPtr<Float64Array> Float64Array::subarray(int start, int end) const
+{
+ return subarrayImpl<Float64Array>(start, end);
+}
+
+}
diff --git a/Source/WebCore/html/canvas/Float64Array.h b/Source/WebCore/html/canvas/Float64Array.h
new file mode 100644
index 0000000..f45a21c
--- /dev/null
+++ b/Source/WebCore/html/canvas/Float64Array.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef Float64Array_h
+#define Float64Array_h
+
+#include "TypedArrayBase.h"
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+class Float64Array : public TypedArrayBase<double> {
+public:
+ static PassRefPtr<Float64Array> create(unsigned length);
+ static PassRefPtr<Float64Array> create(const double* array, unsigned length);
+ static PassRefPtr<Float64Array> create(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned length);
+
+ using TypedArrayBase<double>::set;
+
+ void set(unsigned index, double value)
+ {
+ if (index >= TypedArrayBase<double>::m_length)
+ return;
+ TypedArrayBase<double>::data()[index] = static_cast<double>(value);
+ }
+
+ // Invoked by the indexed getter. Does not perform range checks; caller
+ // is responsible for doing so and returning undefined as necessary.
+ double item(unsigned index) const
+ {
+ ASSERT(index < TypedArrayBase<double>::m_length);
+ double result = TypedArrayBase<double>::data()[index];
+ return result;
+ }
+
+ PassRefPtr<Float64Array> subarray(int start) const;
+ PassRefPtr<Float64Array> subarray(int start, int end) const;
+
+private:
+ Float64Array(PassRefPtr<ArrayBuffer>,
+ unsigned byteOffset,
+ unsigned length);
+ // Make constructor visible to superclass.
+ friend class TypedArrayBase<double>;
+
+ // Overridden from ArrayBufferView.
+ virtual bool isDoubleArray() const { return true; }
+};
+
+} // namespace WebCore
+
+#endif // Float64Array_h
diff --git a/Source/WebCore/html/canvas/Float64Array.idl b/Source/WebCore/html/canvas/Float64Array.idl
new file mode 100644
index 0000000..6057253
--- /dev/null
+++ b/Source/WebCore/html/canvas/Float64Array.idl
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [
+ CanBeConstructed,
+ CustomConstructFunction,
+ V8CustomConstructor,
+ HasNumericIndexGetter,
+ HasCustomIndexSetter,
+ GenerateNativeConverter,
+ NoStaticTables,
+ CustomToJS,
+ DontCheckEnums
+ ] Float64Array : ArrayBufferView {
+ const unsigned int BYTES_PER_ELEMENT = 8;
+
+ readonly attribute unsigned long length;
+ Float64Array subarray(in long start, in [Optional] long end);
+
+ // void set(in Float64Array array, [Optional] in unsigned long offset);
+ // void set(in sequence<long> array, [Optional] in unsigned long offset);
+ [Custom] void set();
+ };
+}
diff --git a/Source/WebCore/html/parser/HTMLDocumentParser.cpp b/Source/WebCore/html/parser/HTMLDocumentParser.cpp
index 8f95cc5..46dddf0 100644
--- a/Source/WebCore/html/parser/HTMLDocumentParser.cpp
+++ b/Source/WebCore/html/parser/HTMLDocumentParser.cpp
@@ -41,10 +41,6 @@
#include "NestingLevelIncrementer.h"
#include "Settings.h"
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
-
namespace WebCore {
using namespace HTMLNames;
@@ -318,10 +314,6 @@ void HTMLDocumentParser::insert(const SegmentedString& source)
if (isStopped())
return;
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::ParsingTimeCounter);
-#endif
-
// pumpTokenizer can cause this parser to be detached from the Document,
// but we need to ensure it isn't deleted yet.
RefPtr<HTMLDocumentParser> protect(this);
@@ -369,18 +361,12 @@ void HTMLDocumentParser::append(const SegmentedString& source)
// We've gotten data off the network in a nested write.
// We don't want to consume any more of the input stream now. Do
// not worry. We'll consume this data in a less-nested write().
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::ParsingTimeCounter, __FUNCTION__);
-#endif
return;
}
pumpTokenizerIfPossible(AllowYield);
endIfDelayed();
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::ParsingTimeCounter, __FUNCTION__);
-#endif
}
void HTMLDocumentParser::end()
diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp
index 85b1541..f999fdb 100644
--- a/Source/WebCore/loader/FrameLoader.cpp
+++ b/Source/WebCore/loader/FrameLoader.cpp
@@ -119,11 +119,6 @@
#include "ArchiveFactory.h"
#endif
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#include "RenderArena.h"
-#endif
-
namespace WebCore {
using namespace HTMLNames;
@@ -1114,11 +1109,7 @@ void FrameLoader::handleFallbackContent()
}
void FrameLoader::provisionalLoadStarted()
-{
-#ifdef ANDROID_INSTRUMENT
- if (!m_frame->tree()->parent())
- android::TimeCounter::reset();
-#endif
+{
if (m_stateMachine.firstLayoutDone())
m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad);
m_frame->navigationScheduler()->cancel(true);
@@ -2308,7 +2299,7 @@ void FrameLoader::finishedLoadingDocument(DocumentLoader* loader)
if (m_stateMachine.creatingInitialEmptyDocument())
return;
#endif
-
+
#if !ENABLE(WEB_ARCHIVE)
m_client->finishedLoading(loader);
#else
@@ -2499,12 +2490,6 @@ void FrameLoader::checkLoadCompleteForThisFrame()
if (Page* page = m_frame->page())
page->progress()->progressCompleted(m_frame);
-
-#ifdef ANDROID_INSTRUMENT
- if (!m_frame->tree()->parent() && m_frame->document()->renderArena())
- android::TimeCounter::report(m_URL, cache()->getLiveSize(), cache()->getDeadSize(),
- m_frame->document()->renderArena()->reportPoolSize());
-#endif
return;
}
diff --git a/Source/WebCore/loader/archive/android/WebArchiveAndroid.cpp b/Source/WebCore/loader/archive/android/WebArchiveAndroid.cpp
index 55d7cec..5f60163 100644
--- a/Source/WebCore/loader/archive/android/WebArchiveAndroid.cpp
+++ b/Source/WebCore/loader/archive/android/WebArchiveAndroid.cpp
@@ -36,6 +36,7 @@
#include <libxml/tree.h>
#include <libxml/xmlstring.h>
#include <libxml/xmlwriter.h>
+#include <utils/Log.h>
#include <wtf/text/CString.h>
namespace WebCore {
@@ -117,7 +118,7 @@ static bool loadArchiveResourceField(xmlNodePtr resourceNode, const xmlChar* fie
}
}
if (!base64Data) {
- LOGD("loadArchiveResourceField: Failed to load field.");
+ ALOGD("loadArchiveResourceField: Failed to load field.");
return false;
}
@@ -125,7 +126,7 @@ static bool loadArchiveResourceField(xmlNodePtr resourceNode, const xmlChar* fie
const int result = base64Decode(base64Data, base64Size, *outputData);
if (!result) {
- LOGD("loadArchiveResourceField: Failed to decode field.");
+ ALOGD("loadArchiveResourceField: Failed to decode field.");
return false;
}
@@ -165,37 +166,37 @@ static KURL loadArchiveResourceFieldURL(xmlNodePtr resourceNode, const xmlChar*
static PassRefPtr<ArchiveResource> loadArchiveResource(xmlNodePtr resourceNode)
{
if (!xmlStrEqual(resourceNode->name, archiveResourceTag)) {
- LOGD("loadArchiveResource: Malformed resource.");
+ ALOGD("loadArchiveResource: Malformed resource.");
return 0;
}
KURL url = loadArchiveResourceFieldURL(resourceNode, urlFieldTag);
if (url.isNull()) {
- LOGD("loadArchiveResource: Failed to load resource.");
+ ALOGD("loadArchiveResource: Failed to load resource.");
return 0;
}
String mimeType = loadArchiveResourceFieldString(resourceNode, mimeFieldTag);
if (mimeType.isNull()) {
- LOGD("loadArchiveResource: Failed to load resource.");
+ ALOGD("loadArchiveResource: Failed to load resource.");
return 0;
}
String textEncoding = loadArchiveResourceFieldString(resourceNode, encodingFieldTag);
if (textEncoding.isNull()) {
- LOGD("loadArchiveResource: Failed to load resource.");
+ ALOGD("loadArchiveResource: Failed to load resource.");
return 0;
}
String frameName = loadArchiveResourceFieldString(resourceNode, frameFieldTag);
if (frameName.isNull()) {
- LOGD("loadArchiveResource: Failed to load resource.");
+ ALOGD("loadArchiveResource: Failed to load resource.");
return 0;
}
PassRefPtr<SharedBuffer> data = loadArchiveResourceFieldBuffer(resourceNode, dataFieldTag);
if (!data) {
- LOGD("loadArchiveResource: Failed to load resource.");
+ ALOGD("loadArchiveResource: Failed to load resource.");
return 0;
}
@@ -211,7 +212,7 @@ static PassRefPtr<WebArchiveAndroid> loadArchive(xmlNodePtr archiveNode)
Vector<PassRefPtr<Archive> > subframes;
if (!xmlStrEqual(archiveNode->name, archiveTag)) {
- LOGD("loadArchive: Malformed archive.");
+ ALOGD("loadArchive: Malformed archive.");
return 0;
}
@@ -227,7 +228,7 @@ static PassRefPtr<WebArchiveAndroid> loadArchive(xmlNodePtr archiveNode)
}
}
if (!mainResource) {
- LOGD("loadArchive: Failed to load main resource.");
+ ALOGD("loadArchive: Failed to load main resource.");
return 0;
}
@@ -240,7 +241,7 @@ static PassRefPtr<WebArchiveAndroid> loadArchive(xmlNodePtr archiveNode)
resourceNode = resourceNode->next) {
PassRefPtr<ArchiveResource> subresource = loadArchiveResource(resourceNode);
if (!subresource) {
- LOGD("loadArchive: Failed to load subresource.");
+ ALOGD("loadArchive: Failed to load subresource.");
break;
}
subresources.append(subresource);
@@ -258,7 +259,7 @@ static PassRefPtr<WebArchiveAndroid> loadArchive(xmlNodePtr archiveNode)
resourceNode = resourceNode->next) {
PassRefPtr<WebArchiveAndroid> subframe = loadArchive(resourceNode);
if (!subframe) {
- LOGD("loadArchive: Failed to load subframe.");
+ ALOGD("loadArchive: Failed to load subframe.");
break;
}
subframes.append(subframe);
@@ -290,20 +291,20 @@ PassRefPtr<WebArchiveAndroid> WebArchiveAndroid::create(SharedBuffer* buffer)
xmlDocPtr doc = xmlReadMemory(buffer->data(), buffer->size(), noBaseUrl, defaultEncoding, noParserOptions);
if (!doc) {
- LOGD("create: Failed to parse document.");
+ ALOGD("create: Failed to parse document.");
return createArchiveForError();
}
xmlNodePtr root = xmlDocGetRootElement(doc);
if (!root) {
- LOGD("create: Empty document.");
+ ALOGD("create: Empty document.");
xmlFreeDoc(doc);
return createArchiveForError();
}
RefPtr<WebArchiveAndroid> archive = loadArchive(root);
if (!archive) {
- LOGD("create: Failed to load archive.");
+ ALOGD("create: Failed to load archive.");
xmlFreeDoc(doc);
return createArchiveForError();
}
@@ -316,7 +317,7 @@ static bool saveArchiveResourceField(xmlTextWriterPtr writer, const xmlChar* tag
{
int result = xmlTextWriterStartElement(writer, tag);
if (result < 0) {
- LOGD("saveArchiveResourceField: Failed to start element.");
+ ALOGD("saveArchiveResourceField: Failed to start element.");
return false;
}
@@ -324,20 +325,20 @@ static bool saveArchiveResourceField(xmlTextWriterPtr writer, const xmlChar* tag
Vector<char> base64Data;
base64Encode(data, size, base64Data, false);
if (base64Data.isEmpty()) {
- LOGD("saveArchiveResourceField: Failed to base64 encode data.");
+ ALOGD("saveArchiveResourceField: Failed to base64 encode data.");
return false;
}
result = xmlTextWriterWriteRawLen(writer, BAD_CAST base64Data.data(), base64Data.size());
if (result < 0) {
- LOGD("saveArchiveResourceField: Failed to write data.");
+ ALOGD("saveArchiveResourceField: Failed to write data.");
return false;
}
}
result = xmlTextWriterEndElement(writer);
if (result < 0) {
- LOGD("saveArchiveResourceField: Failed to end element.");
+ ALOGD("saveArchiveResourceField: Failed to end element.");
return false;
}
@@ -360,7 +361,7 @@ static bool saveArchiveResource(xmlTextWriterPtr writer, PassRefPtr<ArchiveResou
{
int result = xmlTextWriterStartElement(writer, archiveResourceTag);
if (result < 0) {
- LOGD("saveArchiveResource: Failed to start element.");
+ ALOGD("saveArchiveResource: Failed to start element.");
return false;
}
@@ -373,7 +374,7 @@ static bool saveArchiveResource(xmlTextWriterPtr writer, PassRefPtr<ArchiveResou
result = xmlTextWriterEndElement(writer);
if (result < 0) {
- LOGD("saveArchiveResource: Failed to end element.");
+ ALOGD("saveArchiveResource: Failed to end element.");
return false;
}
@@ -384,13 +385,13 @@ static bool saveArchive(xmlTextWriterPtr writer, PassRefPtr<Archive> archive)
{
int result = xmlTextWriterStartElement(writer, archiveTag);
if (result < 0) {
- LOGD("saveArchive: Failed to start element.");
+ ALOGD("saveArchive: Failed to start element.");
return false;
}
result = xmlTextWriterStartElement(writer, mainResourceTag);
if (result < 0) {
- LOGD("saveArchive: Failed to start element.");
+ ALOGD("saveArchive: Failed to start element.");
return false;
}
@@ -399,13 +400,13 @@ static bool saveArchive(xmlTextWriterPtr writer, PassRefPtr<Archive> archive)
result = xmlTextWriterEndElement(writer);
if (result < 0) {
- LOGD("saveArchive: Failed to end element.");
+ ALOGD("saveArchive: Failed to end element.");
return false;
}
result = xmlTextWriterStartElement(writer, subresourcesTag);
if (result < 0) {
- LOGD("saveArchive: Failed to start element.");
+ ALOGD("saveArchive: Failed to start element.");
return false;
}
@@ -418,13 +419,13 @@ static bool saveArchive(xmlTextWriterPtr writer, PassRefPtr<Archive> archive)
result = xmlTextWriterEndElement(writer);
if (result < 0) {
- LOGD("saveArchive: Failed to end element.");
+ ALOGD("saveArchive: Failed to end element.");
return false;
}
result = xmlTextWriterStartElement(writer, subframesTag);
if (result < 0) {
- LOGD("saveArchive: Failed to start element.");
+ ALOGD("saveArchive: Failed to start element.");
return false;
}
@@ -437,7 +438,7 @@ static bool saveArchive(xmlTextWriterPtr writer, PassRefPtr<Archive> archive)
result = xmlTextWriterEndElement(writer);
if (result < 0) {
- LOGD("saveArchive: Failed to end element.");
+ ALOGD("saveArchive: Failed to end element.");
return true;
}
@@ -452,7 +453,7 @@ bool WebArchiveAndroid::saveWebArchive(xmlTextWriterPtr writer)
int result = xmlTextWriterStartDocument(writer, defaultXmlVersion, defaultEncoding, defaultStandalone);
if (result < 0) {
- LOGD("saveWebArchive: Failed to start document.");
+ ALOGD("saveWebArchive: Failed to start document.");
return false;
}
@@ -461,7 +462,7 @@ bool WebArchiveAndroid::saveWebArchive(xmlTextWriterPtr writer)
result = xmlTextWriterEndDocument(writer);
if (result< 0) {
- LOGD("saveWebArchive: Failed to end document.");
+ ALOGD("saveWebArchive: Failed to end document.");
return false;
}
diff --git a/Source/WebCore/loader/cache/MemoryCache.h b/Source/WebCore/loader/cache/MemoryCache.h
index a092eac..c9b91f9 100644
--- a/Source/WebCore/loader/cache/MemoryCache.h
+++ b/Source/WebCore/loader/cache/MemoryCache.h
@@ -171,12 +171,6 @@ public:
void removeResourcesWithOrigin(SecurityOrigin*);
void getOriginsWithCache(SecurityOriginSet& origins);
-#ifdef ANDROID_INSTRUMENT
- unsigned getLiveSize() { return m_liveSize; }
- unsigned getDeadSize() { return m_deadSize; }
-#endif
-
-
private:
MemoryCache();
~MemoryCache(); // Not implemented to make sure nobody accidentally calls delete -- WebCore does not delete singletons.
diff --git a/Source/WebCore/loader/icon/IconDatabase.cpp b/Source/WebCore/loader/icon/IconDatabase.cpp
index 3cefea7..2bb22ec 100644
--- a/Source/WebCore/loader/icon/IconDatabase.cpp
+++ b/Source/WebCore/loader/icon/IconDatabase.cpp
@@ -73,7 +73,7 @@ static const int updateTimerDelay = 5;
static bool checkIntegrityOnOpen = false;
-#ifndef NDEBUG
+#if !LOG_DISABLED || !ERROR_DISABLED
static String urlForLogging(const String& url)
{
static unsigned urlTruncationLength = 120;
@@ -967,7 +967,7 @@ void* IconDatabase::iconDatabaseSyncThread()
LOG(IconDatabase, "(THREAD) IconDatabase sync thread started");
-#ifndef NDEBUG
+#if !LOG_DISABLED
double startTime = currentTime();
#endif
@@ -993,7 +993,7 @@ void* IconDatabase::iconDatabaseSyncThread()
if (shouldStopThreadActivity())
return syncThreadMainLoop();
-#ifndef NDEBUG
+#if !LOG_DISABLED
double timeStamp = currentTime();
LOG(IconDatabase, "(THREAD) Open took %.4f seconds", timeStamp - startTime);
#endif
@@ -1002,7 +1002,7 @@ void* IconDatabase::iconDatabaseSyncThread()
if (shouldStopThreadActivity())
return syncThreadMainLoop();
-#ifndef NDEBUG
+#if !LOG_DISABLED
double newStamp = currentTime();
LOG(IconDatabase, "(THREAD) performOpenInitialization() took %.4f seconds, now %.4f seconds from thread start", newStamp - timeStamp, newStamp - startTime);
timeStamp = newStamp;
@@ -1025,7 +1025,7 @@ void* IconDatabase::iconDatabaseSyncThread()
if (shouldStopThreadActivity())
return syncThreadMainLoop();
-#ifndef NDEBUG
+#if !LOG_DISABLED
newStamp = currentTime();
LOG(IconDatabase, "(THREAD) performImport() took %.4f seconds, now %.4f seconds from thread start", newStamp - timeStamp, newStamp - startTime);
timeStamp = newStamp;
@@ -1042,7 +1042,7 @@ void* IconDatabase::iconDatabaseSyncThread()
if (shouldStopThreadActivity())
return syncThreadMainLoop();
-#ifndef NDEBUG
+#if !LOG_DISABLED
newStamp = currentTime();
LOG(IconDatabase, "(THREAD) performURLImport() took %.4f seconds. Entering main loop %.4f seconds from thread start", newStamp - timeStamp, newStamp - startTime);
#endif
@@ -1358,7 +1358,7 @@ void* IconDatabase::syncThreadMainLoop()
while (!m_threadTerminationRequested) {
m_syncLock.unlock();
-#ifndef NDEBUG
+#if !LOG_DISABLED
double timeStamp = currentTime();
#endif
LOG(IconDatabase, "(THREAD) Main work loop starting");
@@ -1391,7 +1391,7 @@ void* IconDatabase::syncThreadMainLoop()
// has asked to delay pruning
static bool prunedUnretainedIcons = false;
if (didWrite && !m_privateBrowsingEnabled && !prunedUnretainedIcons && !databaseCleanupCounter) {
-#ifndef NDEBUG
+#if !LOG_DISABLED
double time = currentTime();
#endif
LOG(IconDatabase, "(THREAD) Starting pruneUnretainedIcons()");
@@ -1410,7 +1410,7 @@ void* IconDatabase::syncThreadMainLoop()
break;
}
-#ifndef NDEBUG
+#if !LOG_DISABLED
double newstamp = currentTime();
LOG(IconDatabase, "(THREAD) Main work loop ran for %.4f seconds, %s requested to terminate", newstamp - timeStamp, shouldStopThreadActivity() ? "was" : "was not");
#endif
@@ -1458,7 +1458,7 @@ bool IconDatabase::readFromDatabase()
{
ASSERT_ICON_SYNC_THREAD();
-#ifndef NDEBUG
+#if !LOG_DISABLED
double timeStamp = currentTime();
#endif
@@ -1567,7 +1567,7 @@ bool IconDatabase::writeToDatabase()
{
ASSERT_ICON_SYNC_THREAD();
-#ifndef NDEBUG
+#if !LOG_DISABLED
double timeStamp = currentTime();
#endif
@@ -1772,7 +1772,7 @@ void* IconDatabase::cleanupSyncThread()
{
ASSERT_ICON_SYNC_THREAD();
-#ifndef NDEBUG
+#if !LOG_DISABLED
double timeStamp = currentTime();
#endif
@@ -1792,7 +1792,7 @@ void* IconDatabase::cleanupSyncThread()
deleteAllPreparedStatements();
m_syncDB.close();
-#ifndef NDEBUG
+#if !LOG_DISABLED
LOG(IconDatabase, "(THREAD) Final closure took %.4f seconds", currentTime() - timeStamp);
#endif
diff --git a/Source/WebCore/page/DOMWindow.idl b/Source/WebCore/page/DOMWindow.idl
index 9f7313c..d5d3413 100644
--- a/Source/WebCore/page/DOMWindow.idl
+++ b/Source/WebCore/page/DOMWindow.idl
@@ -510,6 +510,7 @@ module window {
attribute [JSCCustomGetter] Int32ArrayConstructor Int32Array; // Usable with new operator
attribute [JSCCustomGetter] Uint32ArrayConstructor Uint32Array; // Usable with new operator
attribute [JSCCustomGetter] Float32ArrayConstructor Float32Array; // Usable with new operator
+ attribute [JSCCustomGetter] Float64ArrayConstructor Float64Array; // Usable with new operator
attribute [JSCCustomGetter] DataViewConstructor DataView; // Usable with new operator
attribute [JSCCustomGetter,Conditional=WEB_AUDIO,EnabledAtRuntime] AudioContextConstructor webkitAudioContext; // Usable with new operator
diff --git a/Source/WebCore/page/Frame.cpp b/Source/WebCore/page/Frame.cpp
index 8a1ad69..049f08b 100644
--- a/Source/WebCore/page/Frame.cpp
+++ b/Source/WebCore/page/Frame.cpp
@@ -113,10 +113,6 @@
#include "WMLNames.h"
#endif
-#if PLATFORM(ANDROID)
-#include "WebViewCore.h"
-#endif
-
using namespace std;
namespace WebCore {
diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp
index 49a7d0c..a79910b 100644
--- a/Source/WebCore/page/FrameView.cpp
+++ b/Source/WebCore/page/FrameView.cpp
@@ -62,11 +62,6 @@
#include "TextResourceDecoder.h"
#include <wtf/CurrentTime.h>
-#ifdef ANDROID_INSTRUMENT
-#include "FrameTree.h"
-#include "TimeCounter.h"
-#endif
-
#if USE(ACCELERATED_COMPOSITING)
#include "RenderLayerCompositor.h"
#endif
@@ -872,11 +867,6 @@ void FrameView::layout(bool allowSubtree)
return;
}
-#ifdef ANDROID_INSTRUMENT
- if (!m_frame->tree() || !m_frame->tree()->parent())
- android::TimeCounter::start(android::TimeCounter::LayoutTimeCounter);
-#endif
-
m_nestedLayoutCount++;
if (!m_layoutRoot) {
@@ -1014,10 +1004,6 @@ void FrameView::layout(bool allowSubtree)
updateDashboardRegions();
#endif
-#ifdef ANDROID_INSTRUMENT
- if (!m_frame->tree()->parent())
- android::TimeCounter::record(android::TimeCounter::LayoutTimeCounter, __FUNCTION__);
-#endif
ASSERT(!root->needsLayout());
updateCanBlitOnScrollRecursively();
diff --git a/Source/WebCore/platform/Arena.cpp b/Source/WebCore/platform/Arena.cpp
index 231e1b6..33980ed 100644
--- a/Source/WebCore/platform/Arena.cpp
+++ b/Source/WebCore/platform/Arena.cpp
@@ -255,16 +255,4 @@ void FinishArenaPool(ArenaPool *pool)
FreeArenaList(pool, &pool->first, true);
}
-#ifdef ANDROID_INSTRUMENT
-size_t ReportPoolSize(const ArenaPool* pool)
-{
- size_t total = 0;
- for (const Arena *a = &pool->first; a; a = a->next)
- total += (a->limit - a->base);
- for (const Arena *fa = arena_freelist; fa; fa = fa->next )
- total += (fa->limit - fa->base);
- return total;
-}
-#endif
-
}
diff --git a/Source/WebCore/platform/Arena.h b/Source/WebCore/platform/Arena.h
index e937955..06e09f2 100644
--- a/Source/WebCore/platform/Arena.h
+++ b/Source/WebCore/platform/Arena.h
@@ -134,10 +134,6 @@ void* ArenaAllocate(ArenaPool *pool, unsigned int nb);
fastFree(a); \
(a) = 0;
-#ifdef ANDROID_INSTRUMENT
-size_t ReportPoolSize(const ArenaPool* pool);
-#endif
-
}
#endif
diff --git a/Source/WebCore/platform/NotImplemented.h b/Source/WebCore/platform/NotImplemented.h
index a71e99c..e9758b0 100644
--- a/Source/WebCore/platform/NotImplemented.h
+++ b/Source/WebCore/platform/NotImplemented.h
@@ -38,21 +38,7 @@
#define supressNotImplementedWarning() false
#endif
-#if OS(ANDROID)
-
-#include <cutils/log.h>
-#ifndef LOG_TAG
-#define LOG_TAG "WebCore"
-#endif
-#define notImplemented() do { \
- static bool havePrinted = false; \
- if (!havePrinted && !supressNotImplementedWarning()) { \
- LOGV("%s: notImplemented", __PRETTY_FUNCTION__); \
- havePrinted = true; \
- } \
- } while (0)
-
-#elif defined(NDEBUG)
+#if defined(NDEBUG)
#define notImplemented() ((void)0)
#else
diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.cpp b/Source/WebCore/platform/android/RenderThemeAndroid.cpp
index 93c99a4..843068a 100644
--- a/Source/WebCore/platform/android/RenderThemeAndroid.cpp
+++ b/Source/WebCore/platform/android/RenderThemeAndroid.cpp
@@ -336,7 +336,9 @@ bool RenderThemeAndroid::paintMediaControlsBackground(RenderObject* o, const Pai
bool translucent = false;
if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag))
translucent = true;
- RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::BACKGROUND_SLIDER, translucent);
+ RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect,
+ RenderSkinMediaButton::BACKGROUND_SLIDER,
+ translucent, 0, false);
return false;
}
@@ -355,7 +357,9 @@ bool RenderThemeAndroid::paintMediaSliderThumb(RenderObject* o, const PaintInfo&
bool translucent = false;
if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag))
translucent = true;
- RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::SLIDER_THUMB, translucent);
+ RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect,
+ RenderSkinMediaButton::SLIDER_THUMB,
+ translucent, 0, false);
return false;
}
diff --git a/Source/WebCore/platform/android/SharedTimerAndroid.cpp b/Source/WebCore/platform/android/SharedTimerAndroid.cpp
index e4f3b36..a3f3db5 100644
--- a/Source/WebCore/platform/android/SharedTimerAndroid.cpp
+++ b/Source/WebCore/platform/android/SharedTimerAndroid.cpp
@@ -51,7 +51,7 @@ void setSharedTimerFireTime(double fireTime)
{
long long timeInMs = static_cast<long long>((fireTime - WTF::currentTime()) * 1000);
- LOGV("setSharedTimerFireTime: in %ld millisec", timeInMs);
+ ALOGV("setSharedTimerFireTime: in %ld millisec", timeInMs);
if (JavaSharedClient::GetTimerClient())
JavaSharedClient::GetTimerClient()->setSharedTimer(timeInMs);
}
diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
index 9c7716c..a3c92cd 100644
--- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
@@ -131,7 +131,7 @@ void BaseLayerAndroid::prefetchBasePicture(SkRect& viewport, float currentScale,
viewport.fTop,
viewport.fRight,
viewport.fBottom,
- scale);
+ currentScale);
bounds.fLeft = static_cast<int>(floorf(viewport.fLeft * invTileWidth)) - PREFETCH_X_DIST;
bounds.fTop = static_cast<int>(floorf(viewport.fTop * invTileHeight)) - PREFETCH_Y_DIST;
@@ -141,7 +141,7 @@ void BaseLayerAndroid::prefetchBasePicture(SkRect& viewport, float currentScale,
XLOG("prefetch rect %d %d %d %d, scale %f, preparing page %p",
bounds.fLeft, bounds.fTop,
bounds.fRight, bounds.fBottom,
- scale * PREFETCH_SCALE,
+ prefetchScale,
prefetchTiledPage);
prefetchTiledPage->setScale(prefetchScale);
@@ -290,8 +290,8 @@ bool BaseLayerAndroid::prepareBasePictureInGL(SkRect& viewport, float scale,
tiledPage->prepare(goingDown, goingLeft, preZoomBounds,
TiledPage::ExpandedBounds);
- XLOG("scrolling %d, zooming %d, needsRedraw %d",
- scrolling, zooming, needsRedraw);
+ XLOG("scrollState %d, zooming %d, needsRedraw %d",
+ m_scrollState, zooming, needsRedraw);
// prefetch in the nextTiledPage if unused by zooming (even if not scrolling
// since we want the tiles to be ready before they're needed)
@@ -361,6 +361,7 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
// TODO: consider moving drawBackground outside of prepare (into tree manager)
m_state->drawBackground(m_color);
drawBasePictureInGL();
+ m_state->glExtras()->drawGL(0);
bool needsRedraw = false;
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.cpp b/Source/WebCore/platform/graphics/android/BaseTile.cpp
index 27bd482..76ee1e7 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTile.cpp
@@ -68,6 +68,7 @@ BaseTile::BaseTile(bool isLayerTile)
, m_dirty(true)
, m_repaintPending(false)
, m_lastDirtyPicture(0)
+ , m_fullRepaint(true)
, m_isTexturePainted(false)
, m_isLayerTile(isLayerTile)
, m_drawCount(0)
@@ -76,20 +77,6 @@ BaseTile::BaseTile(bool isLayerTile)
#ifdef DEBUG_COUNT
ClassTracker::instance()->increment("BaseTile");
#endif
- m_currentDirtyAreaIndex = 0;
-
- // For EglImage Mode, the internal buffer should be 2.
- // For Surface Texture mode, we only need one.
- if (TilesManager::instance()->getSharedTextureMode() == EglImageMode)
- m_maxBufferNumber = 2;
- else
- m_maxBufferNumber = 1;
-
- m_dirtyArea = new SkRegion[m_maxBufferNumber];
- m_fullRepaint = new bool[m_maxBufferNumber];
- for (int i = 0; i < m_maxBufferNumber; i++)
- m_fullRepaint[i] = true;
-
m_renderer = BaseRenderer::createRenderer();
}
@@ -101,8 +88,6 @@ BaseTile::~BaseTile()
m_frontTexture->release(this);
delete m_renderer;
- delete[] m_dirtyArea;
- delete[] m_fullRepaint;
#ifdef DEBUG_COUNT
ClassTracker::instance()->decrement("BaseTile");
@@ -181,8 +166,7 @@ void BaseTile::markAsDirty(int unsigned pictureCount,
return;
android::AutoMutex lock(m_atomicSync);
m_lastDirtyPicture = pictureCount;
- for (int i = 0; i < m_maxBufferNumber; i++)
- m_dirtyArea[i].op(dirtyArea, SkRegion::kUnion_Op);
+ m_dirtyArea.op(dirtyArea, SkRegion::kUnion_Op);
// Check if we actually intersect with the area
bool intersect = false;
@@ -262,25 +246,11 @@ void BaseTile::draw(float transparency, SkRect& rect, float scale)
if (!isTexturePainted)
return;
- TextureInfo* textureInfo = m_frontTexture->consumerLock();
- if (!textureInfo) {
- m_frontTexture->consumerRelease();
- return;
- }
-
- if (m_frontTexture->readyFor(this)) {
- if (isLayerTile() && m_painter && m_painter->transform())
- TilesManager::instance()->shader()->drawLayerQuad(*m_painter->transform(),
- rect, m_frontTexture->m_ownTextureId,
- transparency, true);
- else
- TilesManager::instance()->shader()->drawQuad(rect, m_frontTexture->m_ownTextureId,
- transparency);
- } else {
+ if (m_frontTexture->readyFor(this))
+ m_frontTexture->draw(isLayerTile(), m_painter, rect, transparency);
+ else {
XLOG("tile %p at %d, %d not readyfor (at draw),", this, m_x, m_y);
}
-
- m_frontTexture->consumerRelease();
}
bool BaseTile::isTileReady()
@@ -301,9 +271,7 @@ bool BaseTile::isTileReady()
if (m_state != ReadyToSwap && m_state != UpToDate)
return false;
- texture->consumerLock();
bool ready = texture->readyFor(this);
- texture->consumerRelease();
if (ready)
return true;
@@ -350,7 +318,7 @@ void BaseTile::paintBitmap()
m_atomicSync.lock();
bool dirty = m_dirty;
BaseTileTexture* texture = m_backTexture;
- SkRegion dirtyArea = m_dirtyArea[m_currentDirtyAreaIndex];
+ SkRegion dirtyArea = m_dirtyArea;
float scale = m_scale;
const int x = m_x;
const int y = m_y;
@@ -365,15 +333,12 @@ void BaseTile::paintBitmap()
this, m_state, m_frontTexture, m_backTexture);
}
m_state = PaintingStarted;
-
- texture->producerAcquireContext();
- TextureInfo* textureInfo = texture->producerLock();
+ TextureInfo* textureInfo = texture->getTextureInfo();
m_atomicSync.unlock();
// at this point we can safely check the ownership (if the texture got
// transferred to another BaseTile under us)
if (texture->owner() != this) {
- texture->producerRelease();
return;
}
@@ -381,7 +346,6 @@ void BaseTile::paintBitmap()
// swap out the renderer if necessary
BaseRenderer::swapRendererIfNeeded(m_renderer);
-
// setup the common renderInfo fields;
TileRenderInfo renderInfo;
renderInfo.x = x;
@@ -399,16 +363,16 @@ void BaseTile::paintBitmap()
bool fullRepaint = false;
- if (m_fullRepaint[m_currentDirtyAreaIndex]
+ if (m_fullRepaint
|| textureInfo->m_width != tileWidth
|| textureInfo->m_height != tileHeight) {
fullRepaint = true;
}
- bool surfaceTextureMode = textureInfo->getSharedTextureMode() == SurfaceTextureMode;
-
- if (surfaceTextureMode)
- fullRepaint = true;
+ // With SurfaceTexture, just repaint the entire tile if we intersect.
+ // TODO: Implement the partial invalidate in Surface Texture Mode.
+ // Such that the code of partial invalidation below is preserved.
+ fullRepaint = true;
while (!fullRepaint && !cliperator.done()) {
SkRect realTileRect;
@@ -417,14 +381,7 @@ void BaseTile::paintBitmap()
bool intersect = intersectWithRect(x, y, tileWidth, tileHeight,
scale, dirtyRect, realTileRect);
- // With SurfaceTexture, just repaint the entire tile if we intersect
- // TODO: Implement the partial invalidate in Surface Texture Mode
- if (intersect && surfaceTextureMode) {
- fullRepaint = true;
- break;
- }
-
- if (intersect && !surfaceTextureMode) {
+ if (intersect) {
// initialize finalRealRect to the rounded values of realTileRect
SkIRect finalRealRect;
realTileRect.roundOut(&finalRealRect);
@@ -466,15 +423,11 @@ void BaseTile::paintBitmap()
m_atomicSync.lock();
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- texture->setTile(textureInfo, x, y, scale, painter, pictureCount);
-#endif
- texture->producerReleaseAndSwap();
if (texture == m_backTexture) {
m_isTexturePainted = true;
// set the fullrepaint flags
- m_fullRepaint[m_currentDirtyAreaIndex] = false;
+ m_fullRepaint = false;
// The various checks to see if we are still dirty...
@@ -484,19 +437,11 @@ void BaseTile::paintBitmap()
m_dirty = true;
if (fullRepaint)
- m_dirtyArea[m_currentDirtyAreaIndex].setEmpty();
+ m_dirtyArea.setEmpty();
else
- m_dirtyArea[m_currentDirtyAreaIndex].op(dirtyArea, SkRegion::kDifference_Op);
+ m_dirtyArea.op(dirtyArea, SkRegion::kDifference_Op);
- if (!m_dirtyArea[m_currentDirtyAreaIndex].isEmpty())
- m_dirty = true;
-
- // Now we can swap the dirty areas
- // TODO: For surface texture in Async mode, the index will be updated
- // according to the current buffer just dequeued.
- m_currentDirtyAreaIndex = (m_currentDirtyAreaIndex+1) % m_maxBufferNumber;
-
- if (!m_dirtyArea[m_currentDirtyAreaIndex].isEmpty())
+ if (!m_dirtyArea.isEmpty())
m_dirty = true;
XLOG("painted tile %p (%d, %d), texture %p, dirty=%d", this, x, y, texture, m_dirty);
@@ -522,10 +467,9 @@ void BaseTile::discardTextures() {
m_backTexture->release(this);
m_backTexture = 0;
}
- for (int i = 0; i < m_maxBufferNumber; i++) {
- m_dirtyArea[i].setEmpty();
- m_fullRepaint[i] = true;
- }
+ m_dirtyArea.setEmpty();
+ m_fullRepaint = true;
+
m_dirty = true;
m_state = Unpainted;
}
@@ -589,9 +533,12 @@ void BaseTile::validatePaint() {
// when both have happened, mark as 'ReadyToSwap'
if (m_state == PaintingStarted)
m_state = ValidatedUntransferred;
- else if (m_state == TransferredUnvalidated)
+ else if (m_state == TransferredUnvalidated) {
+ // When the backTexture has been marked pureColor, we will skip the
+ // transfer and marked as ReadyToSwap, in this case, we don't want
+ // to reset m_dirty bit to true.
m_state = ReadyToSwap;
- else {
+ } else {
XLOG("Note: validated tile %p at %d %d, state wasn't paintingstarted or transferred %d",
this, m_x, m_y, m_state);
// failed transferring, in which case mark dirty (since
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.h b/Source/WebCore/platform/graphics/android/BaseTile.h
index 685ca43..ed06332 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.h
+++ b/Source/WebCore/platform/graphics/android/BaseTile.h
@@ -172,10 +172,8 @@ private:
unsigned int m_lastDirtyPicture;
// store the dirty region
- SkRegion* m_dirtyArea;
- bool* m_fullRepaint;
- int m_maxBufferNumber;
- int m_currentDirtyAreaIndex;
+ SkRegion m_dirtyArea;
+ bool m_fullRepaint;
// flag used to know if we have a texture that was painted at least once
bool m_isTexturePainted;
diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
index caaf116..b3a6b84 100644
--- a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
@@ -53,10 +53,8 @@
namespace WebCore {
BaseTileTexture::BaseTileTexture(uint32_t w, uint32_t h)
- : DoubleBufferedTexture(eglGetCurrentContext(),
- TilesManager::instance()->getSharedTextureMode())
- , m_owner(0)
- , m_busy(false)
+ : m_owner(0)
+ , m_isPureColor(false)
{
m_size.set(w, h);
m_ownTextureId = 0;
@@ -71,10 +69,6 @@ BaseTileTexture::BaseTileTexture(uint32_t w, uint32_t h)
BaseTileTexture::~BaseTileTexture()
{
- if (m_sharedTextureMode == EglImageMode) {
- SharedTexture* textures[3] = { m_textureA, m_textureB, 0 };
- destroyTextures(textures);
- }
#ifdef DEBUG_COUNT
ClassTracker::instance()->decrement("BaseTileTexture");
#endif
@@ -98,71 +92,6 @@ void BaseTileTexture::discardGLTexture()
}
}
-void BaseTileTexture::destroyTextures(SharedTexture** textures)
-{
- int x = 0;
- while (textures[x]) {
- // We need to delete the source texture and EGLImage in the texture
- // generation thread. In theory we should be able to delete the EGLImage
- // from either thread, but it currently throws an error if not deleted
- // in the same EGLContext from which it was created.
- textures[x]->lock();
- DeleteTextureOperation* operation = new DeleteTextureOperation(
- textures[x]->getSourceTextureId(), textures[x]->getEGLImage());
- textures[x]->unlock();
- TilesManager::instance()->scheduleOperation(operation);
- x++;
- }
-}
-
-TextureInfo* BaseTileTexture::producerLock()
-{
- m_busyLock.lock();
- m_busy = true;
- m_busyLock.unlock();
- return DoubleBufferedTexture::producerLock();
-}
-
-void BaseTileTexture::producerRelease()
-{
- DoubleBufferedTexture::producerRelease();
- setNotBusy();
-}
-
-void BaseTileTexture::producerReleaseAndSwap()
-{
- DoubleBufferedTexture::producerReleaseAndSwap();
- setNotBusy();
-}
-
-void BaseTileTexture::setNotBusy()
-{
- android::Mutex::Autolock lock(m_busyLock);
- m_busy = false;
- m_busyCond.signal();
-}
-
-bool BaseTileTexture::busy()
-{
- android::Mutex::Autolock lock(m_busyLock);
- return m_busy;
-}
-
-void BaseTileTexture::producerUpdate(TextureInfo* textureInfo, const SkBitmap& bitmap)
-{
- // no need to upload a texture since the bitmap is empty
- if (!bitmap.width() && !bitmap.height()) {
- producerRelease();
- return;
- }
-
- // After the tiled layer checked in, this is not called anyway.
- // TODO: cleanup the old code path for layer painting
- // GLUtils::paintTextureWithBitmap(info, m_size, bitmap, 0, 0);
-
- producerReleaseAndSwap();
-}
-
bool BaseTileTexture::acquire(TextureOwner* owner, bool force)
{
if (m_owner == owner)
@@ -173,39 +102,21 @@ bool BaseTileTexture::acquire(TextureOwner* owner, bool force)
bool BaseTileTexture::setOwner(TextureOwner* owner, bool force)
{
- // if the writable texture is busy (i.e. currently being written to) then we
- // can't change the owner out from underneath that texture
- m_busyLock.lock();
- while (m_busy && force)
- m_busyCond.wait(m_busyLock);
- bool busy = m_busy;
- m_busyLock.unlock();
-
- if (!busy) {
- // if we are not busy we can try to remove the texture from the layer;
- // LayerAndroid::removeTexture() is protected by the same lock as
- // LayerAndroid::paintBitmapGL(), so either we execute removeTexture()
- // first and paintBitmapGL() will bail out, or we execute it after,
- // and paintBitmapGL() will mark the texture as busy before
- // relinquishing the lock. LayerAndroid::removeTexture() will call
- // BaseTileTexture::release(), which will then do nothing
- // if the texture is busy and we then don't return true.
- bool proceed = true;
- if (m_owner && m_owner != owner)
- proceed = m_owner->removeTexture(this);
-
- if (proceed) {
- m_owner = owner;
- return true;
- }
+ bool proceed = true;
+ if (m_owner && m_owner != owner)
+ proceed = m_owner->removeTexture(this);
+
+ if (proceed) {
+ m_owner = owner;
+ return true;
}
+
return false;
}
bool BaseTileTexture::release(TextureOwner* owner)
{
- android::Mutex::Autolock lock(m_busyLock);
- XLOG("texture %p releasing tile %p, m_owner %p, m_busy %d", this, owner, m_owner, m_busy);
+ XLOG("texture %p releasing tile %p, m_owner %p", this, owner, m_owner);
if (m_owner != owner)
return false;
@@ -213,22 +124,6 @@ bool BaseTileTexture::release(TextureOwner* owner)
return true;
}
-void BaseTileTexture::setTile(TextureInfo* info, int x, int y,
- float scale, TilePainter* painter,
- unsigned int pictureCount)
-{
- TextureTileInfo* textureInfo = m_texturesInfo.get(getWriteableTexture());
- if (!textureInfo) {
- textureInfo = new TextureTileInfo();
- }
- textureInfo->m_x = x;
- textureInfo->m_y = y;
- textureInfo->m_scale = scale;
- textureInfo->m_painter = painter;
- textureInfo->m_picture = pictureCount;
- m_texturesInfo.set(getWriteableTexture(), textureInfo);
-}
-
float BaseTileTexture::scale()
{
TextureTileInfo* textureInfo = &m_ownTextureTileInfo;
@@ -255,6 +150,13 @@ void BaseTileTexture::setOwnTextureTileInfoFromQueue(const TextureTileInfo* info
bool BaseTileTexture::readyFor(BaseTile* baseTile)
{
const TextureTileInfo* info = &m_ownTextureTileInfo;
+
+ if (isPureColor() && info->m_painter == baseTile->painter()) {
+ XLOG("ReadyFor saw a pureColor tile (%p) at (%d, %d), rgb %x",
+ this, baseTile->x(), baseTile->y(), pureColor().rgb());
+ return true;
+ }
+
if (info &&
(info->m_x == baseTile->x()) &&
(info->m_y == baseTile->y()) &&
@@ -270,4 +172,24 @@ bool BaseTileTexture::readyFor(BaseTile* baseTile)
return false;
}
+void BaseTileTexture::draw(bool isLayer, TilePainter* painter,
+ SkRect& rect, float transparency)
+{
+ ShaderProgram* shader = TilesManager::instance()->shader();
+ if (isLayer && painter && painter->transform()) {
+ if (isPureColor()) {
+ shader->drawLayerQuad(*painter->transform(), rect, 0, transparency,
+ true, GL_TEXTURE_2D, pureColor());
+ } else {
+ shader->drawLayerQuad(*painter->transform(), rect, m_ownTextureId,
+ transparency, true);
+ }
+ } else {
+ if (isPureColor())
+ shader->drawQuad(rect, 0,transparency, pureColor());
+ else
+ shader->drawQuad(rect, m_ownTextureId, transparency);
+ }
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.h b/Source/WebCore/platform/graphics/android/BaseTileTexture.h
index cd8e78b..55314c7 100644
--- a/Source/WebCore/platform/graphics/android/BaseTileTexture.h
+++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.h
@@ -26,10 +26,11 @@
#ifndef BaseTileTexture_h
#define BaseTileTexture_h
-#include "DoubleBufferedTexture.h"
#include "GLWebViewState.h"
+#include "TextureInfo.h"
#include "TextureOwner.h"
#include "TilePainter.h"
+#include <GLES2/gl2.h>
#include <SkBitmap.h>
class SkCanvas;
@@ -61,44 +62,26 @@ public:
bool m_inverted;
};
-// DoubleBufferedTexture using a SkBitmap as backing mechanism
-class BaseTileTexture : public DoubleBufferedTexture {
+class BaseTileTexture {
public:
// This object is to be constructed on the consumer's thread and must have
// a width and height greater than 0.
BaseTileTexture(uint32_t w, uint32_t h);
virtual ~BaseTileTexture();
- // these functions override their parent
- virtual TextureInfo* producerLock();
- virtual void producerRelease();
- virtual void producerReleaseAndSwap();
-
- // updates the texture with current bitmap and releases (and if needed also
- // swaps) the texture.
- virtual void producerUpdate(TextureInfo* textureInfo, const SkBitmap& bitmap);
-
// allows consumer thread to assign ownership of the texture to the tile. It
// returns false if ownership cannot be transferred because the tile is busy
bool acquire(TextureOwner* owner, bool force = false);
bool release(TextureOwner* owner);
- // removes Tile->Texture, and Texture->Tile links to fully discard the texture
- void releaseAndRemoveFromTile();
-
// set the texture owner if not busy. Return false if busy, true otherwise.
bool setOwner(TextureOwner* owner, bool force = false);
// private member accessor functions
TextureOwner* owner() { return m_owner; } // only used by the consumer thread
- bool busy();
- void setNotBusy();
-
const SkSize& getSize() const { return m_size; }
- void setTile(TextureInfo* info, int x, int y, float scale,
- TilePainter* painter, unsigned int pictureCount);
bool readyFor(BaseTile* baseTile);
float scale();
@@ -110,29 +93,31 @@ public:
void setOwnTextureTileInfoFromQueue(const TextureTileInfo* info);
-protected:
- HashMap<SharedTexture*, TextureTileInfo*> m_texturesInfo;
+ TextureInfo* getTextureInfo() { return &m_ownTextureInfo; }
+
+ // Make sure the following pureColor getter/setter are only read/written
+ // in UI thread. Therefore no need for a lock.
+ void setPure(bool pure) { m_isPureColor = pure; }
+ bool isPureColor() {return m_isPureColor; }
+ void setPureColor(const Color& color) { m_pureColor = color; setPure(true); }
+ Color pureColor() { return m_pureColor; }
+ void draw(bool isLayer, TilePainter* painter, SkRect& rect,
+ float transparency);
private:
- void destroyTextures(SharedTexture** textures);
TextureTileInfo m_ownTextureTileInfo;
-
+ // TODO: Merge this info into the TextureTileInfo.
+ TextureInfo m_ownTextureInfo;
SkSize m_size;
SkBitmap::Config m_config;
// BaseTile owning the texture, only modified by UI thread
TextureOwner* m_owner;
- // This values signals that the texture is currently in use by the consumer.
- // This allows us to prevent the owner of the texture from changing while the
- // consumer is holding a lock on the texture.
- bool m_busy;
- // We mutex protect the reads/writes of m_busy to ensure that we are reading
- // the most up-to-date value even across processors in an SMP system.
- android::Mutex m_busyLock;
- // We use this condition variable to signal that the texture
- // is not busy anymore
- android::Condition m_busyCond;
+ // When the whole tile is single color, skip the transfer queue and draw
+ // it directly through shader.
+ bool m_isPureColor;
+ Color m_pureColor;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp b/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp
deleted file mode 100644
index 4c5af9e..0000000
--- a/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * 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 "DoubleBufferedTexture.h"
-
-#include "ClassTracker.h"
-#include "GLUtils.h"
-
-#define LOG_NDEBUG 1
-#define LOG_TAG "DoubleBufferedTexture.cpp"
-#include <utils/Log.h>
-
-namespace WebCore {
-
-DoubleBufferedTexture::DoubleBufferedTexture(EGLContext sharedContext, SharedTextureMode mode)
-{
- m_sharedTextureMode = mode;
-
- m_textureA = new SharedTexture(m_sharedTextureMode);
- if (m_sharedTextureMode == EglImageMode)
- m_textureB = new SharedTexture(m_sharedTextureMode);
- else
- m_textureB = 0;
-
- m_display = eglGetCurrentDisplay();
- m_pContext = EGL_NO_CONTEXT;
- m_cContext = sharedContext;
- m_writeableTexture = m_textureA;
- m_lockedConsumerTexture = GL_NO_TEXTURE;
- m_supportsEGLImage = GLUtils::isEGLImageSupported();
-#ifdef DEBUG_COUNT
- ClassTracker::instance()->increment("DoubleBufferedTexture");
-#endif
-}
-
-DoubleBufferedTexture::~DoubleBufferedTexture()
-{
-#ifdef DEBUG_COUNT
- ClassTracker::instance()->decrement("DoubleBufferedTexture");
-#endif
- delete m_textureA;
- delete m_textureB;
-}
-
-SharedTexture* DoubleBufferedTexture::getWriteableTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return m_textureA;
- return reinterpret_cast<SharedTexture*>(
- android_atomic_release_load((int32_t*)&m_writeableTexture));
-}
-
-SharedTexture* DoubleBufferedTexture::getReadableTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return m_textureA;
- return (getWriteableTexture() != m_textureA) ? m_textureA : m_textureB;
-}
-
-EGLContext DoubleBufferedTexture::producerAcquireContext()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return EGL_NO_CONTEXT;
-
- if (m_pContext != EGL_NO_CONTEXT) {
- LOGV("AquireContext has previously generated a context.\n");
- return m_pContext;
- }
-
- // check to see if a context already exists on this thread
- EGLContext context = eglGetCurrentContext();
-
- // if no context exists then create one
- if (context == EGL_NO_CONTEXT) {
- EGLContext sharedContext = m_supportsEGLImage ? EGL_NO_CONTEXT : m_cContext;
- context = GLUtils::createBackgroundContext(sharedContext);
- }
-
- if (context == EGL_NO_CONTEXT) {
- LOGE("eglCreateContext failed");
- return EGL_NO_CONTEXT;
- }
-
- // initialize the producer's textures
- m_textureA->lock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->lock();
-
- m_textureA->initSourceTexture();
- LOGV("Initialized Textures A (%d)", m_textureA->getSourceTextureId());
- if (m_sharedTextureMode == EglImageMode) {
- m_textureB->initSourceTexture();
- LOGV("Initialized Textures B (%d)", m_textureB->getSourceTextureId());
- }
-
- m_textureA->unlock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->unlock();
-
- m_pContext = context;
- return context;
-}
-
-// For MediaTexture only
-void DoubleBufferedTexture::producerDeleteTextures()
-{
- m_textureA->lock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->lock();
-
- LOGV("Deleting Producer Textures A (%d)", m_textureA->getSourceTextureId());
- m_textureA->deleteSourceTexture();
- if (m_sharedTextureMode == EglImageMode){
- LOGV("Deleting Producer Textures B (%d)", m_textureB->getSourceTextureId());
- m_textureB->deleteSourceTexture();
- }
-
- m_textureA->unlock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->unlock();
-}
-
-// For MediaTexture only
-void DoubleBufferedTexture::consumerDeleteTextures()
-{
- m_textureA->lock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->lock();
-
- LOGV("Deleting Consumer Textures A (%d)", m_textureA->getTargetTextureId());
- m_textureA->deleteTargetTexture();
- if (m_sharedTextureMode == EglImageMode) {
- LOGV("Deleting Consumer Textures B (%d)", m_textureB->getTargetTextureId());
- m_textureB->deleteTargetTexture();
- }
-
- m_textureA->unlock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->unlock();
-}
-
-TextureInfo* DoubleBufferedTexture::producerLock()
-{
- SharedTexture* sharedTex = getWriteableTexture();
- LOGV("Acquiring P Lock (%d)", sharedTex->getSourceTextureId());
- TextureInfo* texInfo = sharedTex->lockSource();
- LOGV("Acquired P Lock");
-
- return texInfo;
-}
-
-void DoubleBufferedTexture::producerRelease()
-{
- // get the writable texture and unlock it
- SharedTexture* sharedTex = getWriteableTexture();
- LOGV("Releasing P Lock (%d)", sharedTex->getSourceTextureId());
- sharedTex->releaseSource();
- LOGV("Released P Lock (%d)", sharedTex->getSourceTextureId());
-}
-
-void DoubleBufferedTexture::producerReleaseAndSwap()
-{
- producerRelease();
- if (m_sharedTextureMode == EglImageMode) {
- // swap the front and back buffers using an atomic op for the memory barrier
- android_atomic_acquire_store((int32_t)getReadableTexture(), (int32_t*)&m_writeableTexture);
- }
-}
-
-TextureInfo* DoubleBufferedTexture::consumerLock()
-{
- SharedTexture* sharedTex = getReadableTexture();
- LOGV("Acquiring C Lock (%d)", sharedTex->getSourceTextureId());
- m_lockedConsumerTexture = sharedTex;
-
- TextureInfo* texInfo = sharedTex->lockTarget();
- LOGV("Acquired C Lock");
-
- if (!texInfo)
- LOGV("Released C Lock (Empty)");
-
- return texInfo;
-}
-
-void DoubleBufferedTexture::consumerRelease()
-{
- // we must check to see what texture the consumer had locked since the
- // producer may have swapped out the readable buffer
- SharedTexture* sharedTex = m_lockedConsumerTexture;
- sharedTex->releaseTarget();
- LOGV("Released C Lock (%d)", sharedTex->getSourceTextureId());
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.h b/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.h
deleted file mode 100644
index 821b79b..0000000
--- a/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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 DoubleBufferedTexture_h
-#define DoubleBufferedTexture_h
-
-#include "SharedTexture.h"
-#include <EGL/egl.h>
-
-namespace WebCore {
-
-class DoubleBufferedTexture {
-public:
- // consumer thread functions
- DoubleBufferedTexture(EGLContext sharedContext, SharedTextureMode mode);
- virtual ~DoubleBufferedTexture();
-
- // provider thread functions
- virtual TextureInfo* producerLock();
- virtual void producerRelease();
- virtual void producerReleaseAndSwap();
- EGLContext producerAcquireContext();
- void producerDeleteTextures();
-
- // consumer thread functions
- TextureInfo* consumerLock();
- void consumerRelease();
- void consumerDeleteTextures();
-
-protected:
- SharedTexture* getReadableTexture();
- SharedTexture* getWriteableTexture();
-
- SharedTexture* m_textureA;
- SharedTexture* m_textureB;
-
- SharedTextureMode m_sharedTextureMode;
-private:
-
- SharedTexture* m_writeableTexture;
- SharedTexture* m_lockedConsumerTexture; // only used by the consumer
-
- EGLDisplay m_display;
- EGLContext m_pContext;
- EGLContext m_cContext;
-
- bool m_supportsEGLImage;
-};
-
-} // namespace WebCore
-
-#endif // DoubleBufferedTexture_h
diff --git a/Source/WebCore/platform/graphics/android/FontAndroid.cpp b/Source/WebCore/platform/graphics/android/FontAndroid.cpp
index 0a8c0c1..ef7740c 100644
--- a/Source/WebCore/platform/graphics/android/FontAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/FontAndroid.cpp
@@ -52,6 +52,7 @@
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnArrayPtr.h>
#include <wtf/PassOwnPtr.h>
+#include <wtf/unicode/CharacterNames.h>
#include <wtf/unicode/Unicode.h>
#endif
@@ -379,7 +380,7 @@ static int truncateFixedPointToInteger(HB_Fixed value)
// can call |reset| to start over again.
class TextRunWalker {
public:
- TextRunWalker(const TextRun&, unsigned, const Font*);
+ TextRunWalker(const TextRun&, int, int, const Font*);
~TextRunWalker();
bool isWordBreak(unsigned, bool);
@@ -425,10 +426,10 @@ public:
// Return the length of the array returned by |glyphs|
unsigned length() const { return m_item.num_glyphs; }
- // Return the x offset for each of the glyphs. Note that this is translated
+ // Return the offset for each of the glyphs. Note that this is translated
// by the current x offset and that the x offset is updated for each script
// run.
- const SkScalar* xPositions() const { return m_xPositions; }
+ const SkPoint* positions() const { return m_positions; }
// Get the advances (widths) for each glyph.
const HB_Fixed* advances() const { return m_item.advances; }
@@ -472,7 +473,7 @@ private:
void createGlyphArrays(int);
void resetGlyphArrays();
void shapeGlyphs();
- void setGlyphXPositions(bool);
+ void setGlyphPositions(bool);
static void normalizeSpacesAndMirrorChars(const UChar* source, bool rtl,
UChar* destination, int length);
@@ -485,10 +486,11 @@ private:
const Font* const m_font;
HB_ShaperItem m_item;
uint16_t* m_glyphs16; // A vector of 16-bit glyph ids.
- SkScalar* m_xPositions; // A vector of x positions for each glyph.
+ SkPoint* m_positions; // A vector of positions for each glyph.
ssize_t m_indexOfNextScriptRun; // Indexes the script run in |m_run|.
- const unsigned m_startingX; // Offset in pixels of the first script run.
- unsigned m_offsetX; // Offset in pixels to the start of the next script run.
+ const int m_startingX; // Offset in pixels of the first script run.
+ const int m_startingY; // Offset in pixels of the first script run.
+ int m_offsetX; // Offset in pixels to the start of the next script run.
unsigned m_pixelWidth; // Width (in px) of the current script run.
unsigned m_numCodePoints; // Code points in current script run.
unsigned m_glyphsArrayCapacity; // Current size of all the Harfbuzz arrays.
@@ -519,9 +521,10 @@ const char* TextRunWalker::paths[] = {
"/system/fonts/DroidSansThai.ttf"
};
-TextRunWalker::TextRunWalker(const TextRun& run, unsigned startingX, const Font* font)
+TextRunWalker::TextRunWalker(const TextRun& run, int startingX, int startingY, const Font* font)
: m_font(font)
, m_startingX(startingX)
+ , m_startingY(startingY)
, m_offsetX(m_startingX)
, m_run(getNormalizedTextRun(run, m_normalizedRun, m_normalizedBuffer))
, m_iterateBackwards(m_run.rtl())
@@ -650,7 +653,7 @@ bool TextRunWalker::nextScriptRun()
setupFontForScriptRun();
shapeGlyphs();
- setGlyphXPositions(rtl());
+ setGlyphPositions(rtl());
return true;
}
@@ -737,6 +740,16 @@ void TextRunWalker::setupFontForScriptRun()
}
m_item.face = complexPlatformData->harfbuzzFace();
m_item.font->userData = const_cast<FontPlatformData*>(complexPlatformData);
+
+ int size = complexPlatformData->size();
+ m_item.font->x_ppem = size;
+ m_item.font->y_ppem = size;
+ // x_ and y_scale are the conversion factors from font design space (fEmSize) to 1/64th of device pixels in 16.16 format.
+ const int devicePixelFraction = 64;
+ const int multiplyFor16Dot16 = 1 << 16;
+ int scale = devicePixelFraction * size * multiplyFor16Dot16 / complexPlatformData->emSizeInFontUnits();
+ m_item.font->x_scale = scale;
+ m_item.font->y_scale = scale;
}
HB_FontRec* TextRunWalker::allocHarfbuzzFont()
@@ -745,13 +758,6 @@ HB_FontRec* TextRunWalker::allocHarfbuzzFont()
memset(font, 0, sizeof(HB_FontRec));
font->klass = &harfbuzzSkiaClass;
font->userData = 0;
- // The values which harfbuzzSkiaClass returns are already scaled to
- // pixel units, so we just set all these to one to disable further
- // scaling.
- font->x_ppem = 1;
- font->y_ppem = 1;
- font->x_scale = 1;
- font->y_scale = 1;
return font;
}
@@ -763,7 +769,7 @@ void TextRunWalker::deleteGlyphArrays()
delete[] m_item.advances;
delete[] m_item.offsets;
delete[] m_glyphs16;
- delete[] m_xPositions;
+ delete[] m_positions;
}
void TextRunWalker::createGlyphArrays(int size)
@@ -774,7 +780,7 @@ void TextRunWalker::createGlyphArrays(int size)
m_item.offsets = new HB_FixedPoint[size];
m_glyphs16 = new uint16_t[size];
- m_xPositions = new SkScalar[size];
+ m_positions = new SkPoint[size];
m_item.num_glyphs = size;
m_glyphsArrayCapacity = size; // Save the GlyphArrays size.
@@ -790,7 +796,7 @@ void TextRunWalker::resetGlyphArrays()
memset(m_item.advances, 0, size * sizeof(m_item.advances[0]));
memset(m_item.offsets, 0, size * sizeof(m_item.offsets[0]));
memset(m_glyphs16, 0, size * sizeof(m_glyphs16[0]));
- memset(m_xPositions, 0, size * sizeof(m_xPositions[0]));
+ memset(m_positions, 0, size * sizeof(m_positions[0]));
}
void TextRunWalker::shapeGlyphs()
@@ -810,7 +816,7 @@ void TextRunWalker::shapeGlyphs()
}
}
-void TextRunWalker::setGlyphXPositions(bool isRTL)
+void TextRunWalker::setGlyphPositions(bool isRTL)
{
int position = 0;
// logClustersIndex indexes logClusters for the first (or last when
@@ -825,7 +831,9 @@ void TextRunWalker::setGlyphXPositions(bool isRTL)
int i = isRTL ? m_item.num_glyphs - iter - 1 : iter;
m_glyphs16[i] = m_item.glyphs[i];
- m_xPositions[i] = SkIntToScalar(m_offsetX + position);
+ int offsetX = truncateFixedPointToInteger(m_item.offsets[i].x);
+ int offsetY = truncateFixedPointToInteger(m_item.offsets[i].y);
+ m_positions[i].set(SkIntToScalar(m_offsetX + position) + offsetX, m_startingY + offsetY);
int advance = truncateFixedPointToInteger(m_item.advances[i]);
// The first half of the conjunction works around the case where
@@ -846,6 +854,21 @@ void TextRunWalker::setGlyphXPositions(bool isRTL)
}
}
+ // ZeroWidthJoiners and ZeroWidthNonJoiners should be stripped by
+ // Harfbuzz, but aren't. Check for zwj and zwnj and replace with a
+ // zero width space. We get the glyph data for space instead of
+ // zeroWidthSpace because the latter was seen to render with an
+ // unexpected code point (the symbol for a cloud). Since the standard
+ // space is in page zero and since we've also confirmed that there is
+ // no advance on this glyph, that should be ok.
+ if (0 == m_item.advances[i]) {
+ const HB_UChar16 c = m_item.string[m_item.item.pos + logClustersIndex];
+ if ((c == zeroWidthJoiner) || (c == zeroWidthNonJoiner)) {
+ static Glyph spaceGlyph = m_font->glyphDataForCharacter(space, false).glyph;
+ m_glyphs16[i] = spaceGlyph;
+ }
+ }
+
// TODO We would like to add m_letterSpacing after each cluster, but I
// don't know where the cluster information is. This is typically
// fine for Roman languages, but breaks more complex languages
@@ -878,10 +901,14 @@ void TextRunWalker::normalizeSpacesAndMirrorChars(const UChar* source, bool rtl,
UChar32 character;
int nextPosition = position;
U16_NEXT(source, nextPosition, length, character);
+
if (Font::treatAsSpace(character))
- character = ' ';
+ character = space;
+ else if (Font::treatAsZeroWidthSpaceInComplexScript(character))
+ character = zeroWidthSpace;
else if (rtl)
character = u_charMirror(character);
+
U16_APPEND(destination, position, length, character, error);
ASSERT(!error);
position = nextPosition;
@@ -947,7 +974,7 @@ FloatRect Font::selectionRectForComplexText(const TextRun& run,
{
int fromX = -1, toX = -1, fromAdvance = -1, toAdvance = -1;
- TextRunWalker walker(run, 0, this);
+ TextRunWalker walker(run, 0, 0, this);
walker.setWordAndLetterSpacing(wordSpacing(), letterSpacing());
// Base will point to the x offset for the current script run. Note that, in
@@ -974,14 +1001,14 @@ FloatRect Font::selectionRectForComplexText(const TextRun& run,
// find which glyph this code-point contributed to and find its x
// position.
int glyph = walker.logClusters()[from];
- fromX = base + walker.xPositions()[glyph];
+ fromX = base + walker.positions()[glyph].x();
fromAdvance = walker.advances()[glyph];
} else
from -= numCodePoints;
if (toX == -1 && to < numCodePoints) {
int glyph = walker.logClusters()[to];
- toX = base + walker.xPositions()[glyph];
+ toX = base + walker.positions()[glyph].x();
toAdvance = walker.advances()[glyph];
} else
to -= numCodePoints;
@@ -1028,7 +1055,7 @@ void Font::drawComplexText(GraphicsContext* gc, TextRun const& run,
SkCanvas* canvas = gc->platformContext()->mCanvas;
bool haveMultipleLayers = isCanvasMultiLayered(canvas);
- TextRunWalker walker(run, point.x(), this);
+ TextRunWalker walker(run, point.x(), point.y(), this);
walker.setWordAndLetterSpacing(wordSpacing(), letterSpacing());
walker.setPadding(run.expansion());
@@ -1036,14 +1063,14 @@ void Font::drawComplexText(GraphicsContext* gc, TextRun const& run,
if (fill) {
walker.fontPlatformDataForScriptRun()->setupPaint(&fillPaint);
adjustTextRenderMode(&fillPaint, haveMultipleLayers);
- canvas->drawPosTextH(walker.glyphs(), walker.length() << 1,
- walker.xPositions(), point.y(), fillPaint);
+ canvas->drawPosText(walker.glyphs(), walker.length() << 1,
+ walker.positions(), fillPaint);
}
if (stroke) {
walker.fontPlatformDataForScriptRun()->setupPaint(&strokePaint);
adjustTextRenderMode(&strokePaint, haveMultipleLayers);
- canvas->drawPosTextH(walker.glyphs(), walker.length() << 1,
- walker.xPositions(), point.y(), strokePaint);
+ canvas->drawPosText(walker.glyphs(), walker.length() << 1,
+ walker.positions(), strokePaint);
}
}
}
@@ -1051,7 +1078,7 @@ void Font::drawComplexText(GraphicsContext* gc, TextRun const& run,
float Font::floatWidthForComplexText(const TextRun& run,
HashSet<const SimpleFontData*>*, GlyphOverflow*) const
{
- TextRunWalker walker(run, 0, this);
+ TextRunWalker walker(run, 0, 0, this);
walker.setWordAndLetterSpacing(wordSpacing(), letterSpacing());
return walker.widthOfFullRun();
}
@@ -1083,7 +1110,7 @@ int Font::offsetForPositionForComplexText(const TextRun& run, float x,
{
// (Mac code ignores includePartialGlyphs, and they don't know what it's
// supposed to do, so we just ignore it as well.)
- TextRunWalker walker(run, 0, this);
+ TextRunWalker walker(run, 0, 0, this);
walker.setWordAndLetterSpacing(wordSpacing(), letterSpacing());
// If this is RTL text, the first glyph from the left is actually the last
diff --git a/Source/WebCore/platform/graphics/android/FontPlatformData.h b/Source/WebCore/platform/graphics/android/FontPlatformData.h
index 5c3313e..1e46971 100644
--- a/Source/WebCore/platform/graphics/android/FontPlatformData.h
+++ b/Source/WebCore/platform/graphics/android/FontPlatformData.h
@@ -82,6 +82,7 @@ public:
float size() const { return mTextSize; }
unsigned hash() const;
+ int emSizeInFontUnits() const;
bool isFixedPitch() const;
#ifndef NDEBUG
@@ -113,6 +114,7 @@ private:
SkTypeface* mTypeface;
float mTextSize;
+ mutable int mEmSizeInFontUnits;
bool mFakeBold;
bool mFakeItalic;
FontOrientation mOrientation;
diff --git a/Source/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp b/Source/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp
index 3c90246..fc254c0 100644
--- a/Source/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp
@@ -33,6 +33,7 @@
#ifdef SUPPORT_COMPLEX_SCRIPTS
#include "HarfbuzzSkia.h"
#endif
+#include "SkAdvancedTypefaceMetrics.h"
#include "SkPaint.h"
#include "SkTypeface.h"
@@ -74,7 +75,7 @@ FontPlatformData::RefCountedHarfbuzzFace::~RefCountedHarfbuzzFace()
}
FontPlatformData::FontPlatformData()
- : mTypeface(NULL), mTextSize(0), mFakeBold(false), mFakeItalic(false),
+ : mTypeface(NULL), mTextSize(0), mEmSizeInFontUnits(0), mFakeBold(false), mFakeItalic(false),
mOrientation(Horizontal), mTextOrientation(TextOrientationVerticalRight)
{
inc_count();
@@ -87,10 +88,10 @@ FontPlatformData::FontPlatformData(const FontPlatformData& src)
SkSafeRef(src.mTypeface);
}
- mTypeface = src.mTypeface;
-
- mTextSize = src.mTextSize;
- mFakeBold = src.mFakeBold;
+ mTypeface = src.mTypeface;
+ mTextSize = src.mTextSize;
+ mEmSizeInFontUnits = src.mEmSizeInFontUnits;
+ mFakeBold = src.mFakeBold;
mFakeItalic = src.mFakeItalic;
m_harfbuzzFace = src.m_harfbuzzFace;
mOrientation = src.mOrientation;
@@ -102,7 +103,7 @@ FontPlatformData::FontPlatformData(const FontPlatformData& src)
FontPlatformData::FontPlatformData(SkTypeface* tf, float textSize, bool fakeBold, bool fakeItalic,
FontOrientation orientation, TextOrientation textOrientation)
- : mTypeface(tf), mTextSize(textSize), mFakeBold(fakeBold), mFakeItalic(fakeItalic),
+ : mTypeface(tf), mTextSize(textSize), mEmSizeInFontUnits(0), mFakeBold(fakeBold), mFakeItalic(fakeItalic),
mOrientation(orientation), mTextOrientation(textOrientation)
{
if (hashTableDeletedFontValue() != mTypeface) {
@@ -114,8 +115,8 @@ FontPlatformData::FontPlatformData(SkTypeface* tf, float textSize, bool fakeBold
}
FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize)
- : mTypeface(src.mTypeface), mTextSize(textSize), mFakeBold(src.mFakeBold), mFakeItalic(src.mFakeItalic),
- m_harfbuzzFace(src.m_harfbuzzFace), mOrientation(src.mOrientation), mTextOrientation(src.mTextOrientation)
+ : mTypeface(src.mTypeface), mTextSize(textSize), mEmSizeInFontUnits(src.mEmSizeInFontUnits), mFakeBold(src.mFakeBold), mFakeItalic(src.mFakeItalic),
+ mOrientation(src.mOrientation), mTextOrientation(src.mTextOrientation), m_harfbuzzFace(src.m_harfbuzzFace)
{
if (hashTableDeletedFontValue() != mTypeface) {
SkSafeRef(mTypeface);
@@ -126,7 +127,7 @@ FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize)
}
FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
- : mTypeface(NULL), mTextSize(size), mFakeBold(bold), mFakeItalic(oblique),
+ : mTypeface(NULL), mTextSize(size), mEmSizeInFontUnits(0), mFakeBold(bold), mFakeItalic(oblique),
mOrientation(Horizontal), mTextOrientation(TextOrientationVerticalRight)
{
inc_count();
@@ -134,7 +135,7 @@ FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
}
FontPlatformData::FontPlatformData(const FontPlatformData& src, SkTypeface* tf)
- : mTypeface(tf), mTextSize(src.mTextSize), mFakeBold(src.mFakeBold),
+ : mTypeface(tf), mTextSize(src.mTextSize), mEmSizeInFontUnits(0), mFakeBold(src.mFakeBold),
mFakeItalic(src.mFakeItalic), mOrientation(src.mOrientation),
mTextOrientation(src.mTextOrientation)
{
@@ -158,6 +159,22 @@ FontPlatformData::~FontPlatformData()
}
}
+int FontPlatformData::emSizeInFontUnits() const
+{
+ if (mEmSizeInFontUnits)
+ return mEmSizeInFontUnits;
+
+ SkAdvancedTypefaceMetrics* metrics = 0;
+ if (mTypeface)
+ metrics = mTypeface->getAdvancedTypefaceMetrics(SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo);
+ if (metrics) {
+ mEmSizeInFontUnits = metrics->fEmSize;
+ metrics->unref();
+ } else
+ mEmSizeInFontUnits = 1000; // default value copied from Skia.
+ return mEmSizeInFontUnits;
+}
+
FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src)
{
if (hashTableDeletedFontValue() != src.mTypeface) {
@@ -167,9 +184,10 @@ FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src)
SkSafeUnref(mTypeface);
}
- mTypeface = src.mTypeface;
- mTextSize = src.mTextSize;
- mFakeBold = src.mFakeBold;
+ mTypeface = src.mTypeface;
+ mEmSizeInFontUnits = src.mEmSizeInFontUnits;
+ mTextSize = src.mTextSize;
+ mFakeBold = src.mFakeBold;
mFakeItalic = src.mFakeItalic;
m_harfbuzzFace = src.m_harfbuzzFace;
mOrientation = src.mOrientation;
@@ -180,10 +198,6 @@ FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src)
void FontPlatformData::setupPaint(SkPaint* paint) const
{
- float ts = mTextSize;
- if (!(ts > 0))
- ts = 12;
-
if (hashTableDeletedFontValue() == mTypeface)
paint->setTypeface(0);
else
@@ -192,7 +206,7 @@ void FontPlatformData::setupPaint(SkPaint* paint) const
paint->setAntiAlias(true);
paint->setSubpixelText(true);
paint->setHinting(SkPaint::kSlight_Hinting);
- paint->setTextSize(SkFloatToScalar(ts));
+ paint->setTextSize(SkFloatToScalar(mTextSize));
paint->setFakeBoldText(mFakeBold);
paint->setTextSkewX(mFakeItalic ? -SK_Scalar1/4 : 0);
#ifndef SUPPORT_COMPLEX_SCRIPTS
diff --git a/Source/WebCore/platform/graphics/android/GLExtras.cpp b/Source/WebCore/platform/graphics/android/GLExtras.cpp
index 873ea33..bf489c9 100644
--- a/Source/WebCore/platform/graphics/android/GLExtras.cpp
+++ b/Source/WebCore/platform/graphics/android/GLExtras.cpp
@@ -67,6 +67,7 @@ GLExtras::GLExtras()
, m_drawExtra(0)
, m_lightRingTexture(-1)
, m_darkRingTexture(-1)
+ , m_viewport()
{
}
@@ -74,7 +75,8 @@ GLExtras::~GLExtras()
{
}
-void GLExtras::drawRing(SkRect& srcRect, int* texture, int r, int g, int b, float a)
+void GLExtras::drawRing(SkRect& srcRect, int* texture, int r, int g, int b, float a,
+ const TransformationMatrix* drawMat)
{
if (*texture == -1)
*texture = GLUtils::createSampleColorTexture(r, g, b);
@@ -85,11 +87,15 @@ void GLExtras::drawRing(SkRect& srcRect, int* texture, int r, int g, int b, floa
}
XLOG("drawQuad [%fx%f, %f, %f]", srcRect.fLeft, srcRect.fTop,
srcRect.width(), srcRect.height());
- TilesManager::instance()->shader()->drawQuad(srcRect, *texture, a);
+ if (drawMat)
+ TilesManager::instance()->shader()->drawLayerQuad(*drawMat, srcRect, *texture, a);
+ else
+ TilesManager::instance()->shader()->drawQuad(srcRect, *texture, a);
}
void GLExtras::drawRegion(const SkRegion& region, bool fill,
- bool drawBorder, bool useDark)
+ bool drawBorder, const TransformationMatrix* drawMat,
+ bool useDark)
{
if (region.isEmpty())
return;
@@ -100,9 +106,9 @@ void GLExtras::drawRegion(const SkRegion& region, bool fill,
SkRect r;
r.set(ir.fLeft, ir.fTop, ir.fRight, ir.fBottom);
if (useDark)
- drawRing(r, COLOR_HOLO_DARK);
+ drawRing(r, COLOR_HOLO_DARK, drawMat);
else
- drawRing(r, COLOR_HOLO_LIGHT);
+ drawRing(r, COLOR_HOLO_LIGHT, drawMat);
rgnIter.next();
}
}
@@ -144,9 +150,9 @@ void GLExtras::drawRegion(const SkRegion& region, bool fill,
}
r.set(line.fLeft, line.fTop, line.fRight, line.fBottom);
if (useDark)
- drawRing(r, COLOR_HOLO_DARK);
+ drawRing(r, COLOR_HOLO_DARK, drawMat);
else
- drawRing(r, COLOR_HOLO_LIGHT);
+ drawRing(r, COLOR_HOLO_LIGHT, drawMat);
if (startRect.isEmpty()) {
startRect.set(line.fLeft, line.fTop, line.fRight, line.fBottom);
}
@@ -157,7 +163,7 @@ void GLExtras::drawRegion(const SkRegion& region, bool fill,
}
}
-void GLExtras::drawCursorRings()
+void GLExtras::drawCursorRings(const LayerAndroid* layer)
{
SkRegion region;
for (size_t i = 0; i < m_ring->rings().size(); i++) {
@@ -167,26 +173,41 @@ void GLExtras::drawCursorRings()
else
region.op(rect, SkRegion::kUnion_Op);
}
- drawRegion(region, m_ring->m_isPressed, !m_ring->m_isButton, false);
+ drawRegion(region, m_ring->m_isPressed, !m_ring->m_isButton,
+ layer ? layer->drawTransform() : 0, false);
}
-void GLExtras::drawFindOnPage(SkRect& viewport)
+void GLExtras::drawFindOnPage(const LayerAndroid* layer)
{
WTF::Vector<MatchInfo>* matches = m_findOnPage->matches();
XLOG("drawFindOnPage, matches: %p", matches);
if (!matches || !m_findOnPage->isCurrentLocationValid())
return;
+ std::pair<unsigned, unsigned> matchRange =
+ m_findOnPage->getLayerMatchRange(layer ? layer->uniqueId() : -1);
+ if (matchRange.first >= matchRange.second)
+ return;
+
int count = matches->size();
- int current = m_findOnPage->currentMatchIndex();
+ unsigned current = m_findOnPage->currentMatchIndex();
XLOG("match count: %d", count);
+ const TransformationMatrix* drawTransform =
+ layer ? layer->drawTransform() : 0;
if (count < MAX_NUMBER_OF_MATCHES_TO_DRAW)
- for (int i = 0; i < count; i++) {
+ for (unsigned i = matchRange.first; i < matchRange.second; i++) {
MatchInfo& info = matches->at(i);
const SkRegion& region = info.getLocation();
SkIRect rect = region.getBounds();
- if (rect.intersect(viewport.fLeft, viewport.fTop,
- viewport.fRight, viewport.fBottom))
- drawRegion(region, i == current, false, true);
+ if (drawTransform) {
+ IntRect intRect(rect.fLeft, rect.fTop, rect.width(),
+ rect.height());
+ IntRect transformedRect = drawTransform->mapRect(intRect);
+ rect.setXYWH(transformedRect.x(), transformedRect.y(),
+ transformedRect.width(), transformedRect.height());
+ }
+ if (rect.intersect(m_viewport.fLeft, m_viewport.fTop,
+ m_viewport.fRight, m_viewport.fBottom))
+ drawRegion(region, i == current, false, drawTransform, true);
#ifdef DEBUG
else
XLOG("Quick rejecting [%dx%d, %d, %d", rect.fLeft, rect.fTop,
@@ -194,18 +215,20 @@ void GLExtras::drawFindOnPage(SkRect& viewport)
#endif // DEBUG
}
else {
- MatchInfo& info = matches->at(current);
- drawRegion(info.getLocation(), true, false, true);
+ if (matchRange.first <= current && current < matchRange.second) {
+ MatchInfo& info = matches->at(current);
+ drawRegion(info.getLocation(), true, false, drawTransform, true);
+ }
}
}
-void GLExtras::drawGL(IntRect& webViewRect, SkRect& viewport, int titleBarHeight)
+void GLExtras::drawGL(const LayerAndroid* layer)
{
if (m_drawExtra) {
if (m_drawExtra == m_ring)
- drawCursorRings();
+ drawCursorRings(layer);
else if (m_drawExtra == m_findOnPage)
- drawFindOnPage(viewport);
+ drawFindOnPage(layer);
else
XLOGC("m_drawExtra %p is unknown! (cursor: %p, find: %p",
m_drawExtra, m_ring, m_findOnPage);
diff --git a/Source/WebCore/platform/graphics/android/GLExtras.h b/Source/WebCore/platform/graphics/android/GLExtras.h
index c52e951..5ccf4cc 100644
--- a/Source/WebCore/platform/graphics/android/GLExtras.h
+++ b/Source/WebCore/platform/graphics/android/GLExtras.h
@@ -37,30 +37,36 @@ namespace android {
namespace WebCore {
+class LayerAndroid;
+class TransformationMatrix;
+
class GLExtras {
public:
GLExtras();
virtual ~GLExtras();
- void drawGL(IntRect& webViewRect, SkRect& viewport, int titleBarHeight);
+ void drawGL(const LayerAndroid* layer);
void setFindOnPageExtra(android::FindOnPage* findOnPage) {
m_findOnPage = findOnPage;
}
void setCursorRingExtra(android::CursorRing* ring) { m_ring = ring; }
void setDrawExtra(android::DrawExtra* extra) { m_drawExtra = extra; }
+ void setViewport(const SkRect & viewport) { m_viewport = viewport; }
private:
- void drawRing(SkRect& srcRect, int* texture, int r, int g, int b, float a);
+ void drawRing(SkRect& srcRect, int* texture, int r, int g, int b, float a,
+ const TransformationMatrix* drawMat);
void drawRegion(const SkRegion& region, bool fill, bool drawBorder,
- bool useDark = false);
- void drawCursorRings();
- void drawFindOnPage(SkRect& viewport);
+ const TransformationMatrix* drawMat, bool useDark = false);
+ void drawCursorRings(const LayerAndroid* layer);
+ void drawFindOnPage(const LayerAndroid* layer);
android::FindOnPage* m_findOnPage;
android::CursorRing* m_ring;
android::DrawExtra* m_drawExtra;
int m_lightRingTexture;
int m_darkRingTexture;
+ SkRect m_viewport;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/GLUtils.cpp b/Source/WebCore/platform/graphics/android/GLUtils.cpp
index 97a53fe..efd611b 100644
--- a/Source/WebCore/platform/graphics/android/GLUtils.cpp
+++ b/Source/WebCore/platform/graphics/android/GLUtils.cpp
@@ -237,7 +237,7 @@ static EGLConfig defaultPbufferConfig(EGLDisplay display)
eglChooseConfig(display, configAttribs, &config, 1, &numConfigs);
GLUtils::checkEglError("eglPbufferConfig");
if (numConfigs != 1)
- LOGI("eglPbufferConfig failed (%d)\n", numConfigs);
+ ALOGI("eglPbufferConfig failed (%d)\n", numConfigs);
return config;
}
@@ -370,9 +370,81 @@ GLuint GLUtils::createBaseTileGLTexture(int width, int height)
GLUtils::checkGlError("glTexImage2D");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+#ifdef DEBUG
+ delete pixels;
+#endif
return texture;
}
+bool GLUtils::isPureColorBitmap(const SkBitmap& bitmap, Color& pureColor)
+{
+ // If the bitmap is the pure color, skip the transfer step, and update the BaseTile Info.
+ // This check is taking < 1ms if we do full bitmap check per tile.
+ // TODO: use the SkPicture to determine whether or not a tile is single color.
+ pureColor = Color(Color::transparent);
+ bitmap.lockPixels();
+ bool sameColor = true;
+ int bitmapWidth = bitmap.width();
+
+ // Create a row of pure color using the first pixel.
+ // TODO: improve the perf here, by either picking a random pixel, or
+ // creating an array of rows with pre-defined commonly used color, add
+ // smart LUT to speed things up if possible.
+ int* firstPixelPtr = static_cast<int*> (bitmap.getPixels());
+ int* pixelsRow = new int[bitmapWidth];
+ for (int i = 0; i < bitmapWidth; i++)
+ pixelsRow[i] = (*firstPixelPtr);
+
+ // Then compare the pure color row with each row of the bitmap.
+ for (int j = 0; j < bitmap.height(); j++) {
+ if (memcmp(pixelsRow, &firstPixelPtr[bitmapWidth * j], 4 * bitmapWidth)) {
+ sameColor = false;
+ break;
+ }
+ }
+ delete pixelsRow;
+ pixelsRow = 0;
+
+ if (sameColor) {
+ char* rgbaPtr = static_cast<char*>(bitmap.getPixels());
+ pureColor = Color(rgbaPtr[0], rgbaPtr[1], rgbaPtr[2], rgbaPtr[3]);
+ XLOG("sameColor tile found , %x at (%d, %d, %d, %d)",
+ *firstPixelPtr, rgbaPtr[0], rgbaPtr[1], rgbaPtr[2], rgbaPtr[3]);
+ }
+ bitmap.unlockPixels();
+
+ return sameColor;
+}
+
+// Return true when the tile is pure color.
+bool GLUtils::skipTransferForPureColor(const TileRenderInfo* renderInfo,
+ const SkBitmap& bitmap)
+{
+ bool skipTransfer = false;
+ BaseTile* tilePtr = renderInfo->baseTile;
+
+ if (tilePtr) {
+ BaseTileTexture* tileTexture = tilePtr->backTexture();
+ // Check the bitmap, and make everything ready here.
+ Color pureColor;
+ if (tileTexture && isPureColorBitmap(bitmap, pureColor)) {
+ // update basetile's info
+ // Note that we are skipping the whole TransferQueue.
+ renderInfo->textureInfo->m_width = bitmap.width();
+ renderInfo->textureInfo->m_height = bitmap.height();
+ renderInfo->textureInfo->m_internalFormat = GL_RGBA;
+
+ TilesManager::instance()->transferQueue()->addItemInPureColorQueue(renderInfo,
+ pureColor);
+
+ skipTransfer = true;
+ }
+ }
+ return skipTransfer;
+}
+
void GLUtils::paintTextureWithBitmap(const TileRenderInfo* renderInfo,
const SkBitmap& bitmap)
{
@@ -382,106 +454,26 @@ void GLUtils::paintTextureWithBitmap(const TileRenderInfo* renderInfo,
const int y = renderInfo->invalRect->fTop;
const SkSize& requiredSize = renderInfo->tileSize;
TextureInfo* textureInfo = renderInfo->textureInfo;
- SharedTextureMode mode = textureInfo->getSharedTextureMode();
- if (requiredSize.equals(textureInfo->m_width, textureInfo->m_height)) {
- if (mode == EglImageMode)
- GLUtils::updateTextureWithBitmap(textureInfo->m_textureId, x, y, bitmap);
- else if (mode == SurfaceTextureMode)
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- GLUtils::updateSurfaceTextureWithBitmap(renderInfo, x, y, bitmap);
-#else
- GLUtils::updateSharedSurfaceTextureWithBitmap(renderInfo, x, y, bitmap);
-#endif
- } else {
+ if (skipTransferForPureColor(renderInfo, bitmap))
+ return;
+
+ if (requiredSize.equals(textureInfo->m_width, textureInfo->m_height))
+ GLUtils::updateSharedSurfaceTextureWithBitmap(renderInfo, x, y, bitmap);
+ else {
if (!requiredSize.equals(bitmap.width(), bitmap.height())) {
XLOG("The bitmap size (%d,%d) does not equal the texture size (%d,%d)",
bitmap.width(), bitmap.height(),
requiredSize.width(), requiredSize.height());
}
+ GLUtils::updateSharedSurfaceTextureWithBitmap(renderInfo, 0, 0, bitmap);
- if (mode == EglImageMode)
- GLUtils::createTextureWithBitmap(textureInfo->m_textureId, bitmap);
- else if (mode == SurfaceTextureMode)
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- GLUtils::createSurfaceTextureWithBitmap(renderInfo, bitmap);
-#else
- GLUtils::updateSharedSurfaceTextureWithBitmap(renderInfo, 0, 0, bitmap);
-#endif
textureInfo->m_width = bitmap.width();
textureInfo->m_height = bitmap.height();
textureInfo->m_internalFormat = GL_RGBA;
}
}
-#if DEPRECATED_SURFACE_TEXTURE_MODE
-void GLUtils::createSurfaceTextureWithBitmap(const TileRenderInfo* renderInfo, const SkBitmap& bitmap, GLint filter)
-{
-
- TextureInfo* texture = renderInfo->textureInfo;
-
- texture->m_width = bitmap.width();
- texture->m_height = bitmap.height();
- texture->m_internalFormat = GL_RGBA;
-
- sp<android::SurfaceTexture> surfaceTexture = texture->m_surfaceTexture;
- sp<ANativeWindow> ANW = texture->m_ANW;
-
- int result;
- result = native_window_set_buffers_geometry(ANW.get(),
- texture->m_width, texture->m_height, HAL_PIXEL_FORMAT_RGBA_8888);
- checkSurfaceTextureError("native_window_set_buffers_geometry", result);
- result = native_window_set_usage(ANW.get(),
- GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
- checkSurfaceTextureError("native_window_set_usage", result);
-
- updateSurfaceTextureWithBitmap(renderInfo, 0, 0, bitmap, filter);
-}
-
-void GLUtils::updateSurfaceTextureWithBitmap(const TileRenderInfo* renderInfo, int x, int y, const SkBitmap& bitmap, GLint filter)
-{
- TextureInfo* texture = renderInfo->textureInfo;
- sp<android::SurfaceTexture> surfaceTexture = texture->m_surfaceTexture;
- sp<ANativeWindow> ANW = texture->m_ANW;
-
- ANativeWindowBuffer* anb;
- int status = ANW->dequeueBuffer(ANW.get(), &anb);
- checkSurfaceTextureError("dequeueBuffer", status);
-
- if (status != NO_ERROR) { // FIXME: add proper error handling!
- native_window_set_buffer_count(ANW.get(), 3);
- return;
- }
-
- sp<android::GraphicBuffer> buf(new android::GraphicBuffer(anb, false));
- status |= ANW->lockBuffer(ANW.get(), buf->getNativeBuffer());
- checkSurfaceTextureError("lockBuffer", status);
-
- // Fill the buffer with the content of the bitmap
- uint8_t* img = 0;
- status |= buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
- checkSurfaceTextureError("lock", status);
-
- if (status == NO_ERROR) {
- int row, col;
- int bpp = 4; // Now only deal with RGBA8888 format.
-
- bitmap.lockPixels();
- uint8_t* bitmapOrigin = static_cast<uint8_t*>(bitmap.getPixels());
- // Copied line by line since we need to handle the offsets and stride.
- for (row = 0 ; row < bitmap.height(); row ++) {
- uint8_t* dst = &(img[(buf->getStride() * (row + x) + y) * bpp]);
- uint8_t* src = &(bitmapOrigin[bitmap.width() * row * bpp]);
- memcpy(dst, src, bpp * bitmap.width());
- }
- bitmap.unlockPixels();
- }
- buf->unlock();
- status = ANW->queueBuffer(ANW.get(), buf->getNativeBuffer());
- checkSurfaceTextureError("queueBuffer", status);
-}
-#endif
-
void GLUtils::updateSharedSurfaceTextureWithBitmap(const TileRenderInfo* renderInfo, int x, int y, const SkBitmap& bitmap)
{
if (!renderInfo
diff --git a/Source/WebCore/platform/graphics/android/GLUtils.h b/Source/WebCore/platform/graphics/android/GLUtils.h
index 68acbab..3475760 100644
--- a/Source/WebCore/platform/graphics/android/GLUtils.h
+++ b/Source/WebCore/platform/graphics/android/GLUtils.h
@@ -28,6 +28,7 @@
#if USE(ACCELERATED_COMPOSITING)
+#include "Color.h"
#include "SkBitmap.h"
#include "SkMatrix.h"
#include "SkSize.h"
@@ -78,12 +79,12 @@ public:
static void createTextureFromEGLImage(GLuint texture, EGLImageKHR image, GLint filter = GL_LINEAR);
static void paintTextureWithBitmap(const TileRenderInfo* renderInfo, const SkBitmap& bitmap);
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- static void createSurfaceTextureWithBitmap(const TileRenderInfo* , const SkBitmap& bitmap, GLint filter = GL_LINEAR);
- static void updateSurfaceTextureWithBitmap(const TileRenderInfo* , int x, int y, const SkBitmap& bitmap, GLint filter = GL_LINEAR);
-#endif
static void updateSharedSurfaceTextureWithBitmap(const TileRenderInfo* , int x, int y, const SkBitmap& bitmap);
static void convertToTransformationMatrix(const float* matrix, TransformationMatrix& transformMatrix);
+
+ static bool isPureColorBitmap(const SkBitmap& bitmap, Color& pureColor);
+ static bool skipTransferForPureColor(const TileRenderInfo* renderInfo,
+ const SkBitmap& bitmap);
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
index 3bcda9a..d8ad1c5 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -69,6 +69,13 @@
#define MIN_SCALE_WARNING 0.1
#define MAX_SCALE_WARNING 10
+// fps indicator is FPS_INDICATOR_HEIGHT pixels high.
+// The max width is equal to MAX_FPS_VALUE fps.
+#define FPS_INDICATOR_HEIGHT 10
+#define MAX_FPS_VALUE 60
+
+#define TREE_SWAPPED_COUNTER_MODULE 10
+
namespace WebCore {
using namespace android;
@@ -80,6 +87,7 @@ GLWebViewState::GLWebViewState()
, m_frameworkInval(0, 0, 0, 0)
, m_frameworkLayersInval(0, 0, 0, 0)
, m_isScrolling(false)
+ , m_isViewportScrolling(false)
, m_goingDown(true)
, m_goingLeft(false)
, m_expandedTileBoundsX(0)
@@ -108,9 +116,6 @@ GLWebViewState::GLWebViewState()
GLWebViewState::~GLWebViewState()
{
- // Take care of the transfer queue such that Tex Gen thread will not stuck
- TilesManager::instance()->unregisterGLWebViewState(this);
-
// We have to destroy the two tiled pages first as their destructor
// may depend on the existence of this GLWebViewState and some of its
// instance variables in order to complete.
@@ -241,11 +246,16 @@ int GLWebViewState::baseContentHeight()
void GLWebViewState::setViewport(SkRect& viewport, float scale)
{
if ((m_viewport == viewport) &&
- (zoomManager()->futureScale() == scale))
+ (zoomManager()->futureScale() == scale)) {
+ m_isViewportScrolling = false;
return;
+ }
m_goingDown = m_viewport.fTop - viewport.fTop <= 0;
m_goingLeft = m_viewport.fLeft - viewport.fLeft >= 0;
+
+ // detect viewport scrolling from short programmatic scrolls/jumps
+ m_isViewportScrolling = m_viewport != viewport && SkRect::Intersects(m_viewport, viewport);
m_viewport = viewport;
XLOG("New VIEWPORT %.2f - %.2f %.2f - %.2f (w: %2.f h: %.2f scale: %.2f currentScale: %.2f futureScale: %.2f)",
@@ -341,7 +351,7 @@ double GLWebViewState::setupDrawing(IntRect& viewRect, SkRect& visibleRect,
int height = viewRect.height();
ShaderProgram* shader = TilesManager::instance()->shader();
- if (shader->program() == -1) {
+ if (shader->needsInit()) {
XLOG("Reinit shader");
shader->init();
}
@@ -491,8 +501,10 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
// TODO: upload as many textures as possible within a certain time limit
bool ret = ImagesManager::instance()->prepareTextures(this);
- if (scale < MIN_SCALE_WARNING || scale > MAX_SCALE_WARNING)
+ if (scale < MIN_SCALE_WARNING || scale > MAX_SCALE_WARNING) {
XLOGC("WARNING, scale seems corrupted after update: %e", scale);
+ CRASH();
+ }
// gather the textures we can use
TilesManager::instance()->gatherLayerTextures();
@@ -502,6 +514,7 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
TexturesResult nbTexturesNeeded;
bool fastSwap = isScrolling() || m_layersRenderingMode == kSingleSurfaceRendering;
+ m_glExtras.setViewport(viewport);
ret |= m_treeManager.drawGL(currentTime, rect, viewport,
scale, fastSwap,
treesSwappedPtr, newTreeHasAnimPtr,
@@ -518,11 +531,6 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
nbTexturesNeeded.clipped += nbTexturesForImages;
ret |= setLayersRenderingMode(nbTexturesNeeded);
- FloatRect extrasclip(0, 0, rect.width(), rect.height());
- TilesManager::instance()->shader()->clip(extrasclip);
-
- m_glExtras.drawGL(webViewRect, viewport, titleBarHeight);
-
glBindBuffer(GL_ARRAY_BUFFER, 0);
// Clean up GL textures for video layer.
@@ -574,6 +582,30 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
resetFrameworkInval();
}
+ showFrameInfo(rect, *treesSwappedPtr);
+
+#ifdef DEBUG
+ TilesManager::instance()->getTilesTracker()->showTrackTextures();
+#endif
+
+ return ret;
+}
+
+void GLWebViewState::showFrameInfo(const IntRect& rect, bool treesSwapped)
+{
+ bool showVisualIndicator = TilesManager::instance()->getShowVisualIndicator();
+
+ bool drawOrDumpFrameInfo = showVisualIndicator;
+#ifdef MEASURES_PERF
+ drawOrDumpFrameInfo |= m_measurePerfs;
+#endif
+ if (!drawOrDumpFrameInfo)
+ return;
+
+ double currentDrawTime = WTF::currentTime();
+ double delta = currentDrawTime - m_prevDrawTime;
+ m_prevDrawTime = currentDrawTime;
+
#ifdef MEASURES_PERF
if (m_measurePerfs) {
m_delayTimes[m_timeCounter++] = delta;
@@ -582,12 +614,37 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
}
#endif
-#ifdef DEBUG
- TilesManager::instance()->getTilesTracker()->showTrackTextures();
- ImagesManager::instance()->showImages();
-#endif
+ IntRect frameInfoRect = rect;
+ frameInfoRect.setHeight(FPS_INDICATOR_HEIGHT);
+ double ratio = (1.0 / delta) / MAX_FPS_VALUE;
- return ret;
+ clearRectWithColor(frameInfoRect, 1, 1, 1, 1);
+ frameInfoRect.setWidth(frameInfoRect.width() * ratio);
+ clearRectWithColor(frameInfoRect, 1, 0, 0, 1);
+
+ // Draw the tree swap counter as a circling progress bar.
+ // This will basically show how fast we are updating the tree.
+ static int swappedCounter = 0;
+ if (treesSwapped)
+ swappedCounter = (swappedCounter + 1) % TREE_SWAPPED_COUNTER_MODULE;
+
+ frameInfoRect = rect;
+ frameInfoRect.setHeight(FPS_INDICATOR_HEIGHT);
+ frameInfoRect.move(0, FPS_INDICATOR_HEIGHT);
+
+ clearRectWithColor(frameInfoRect, 1, 1, 1, 1);
+ ratio = (swappedCounter + 1.0) / TREE_SWAPPED_COUNTER_MODULE;
+
+ frameInfoRect.setWidth(frameInfoRect.width() * ratio);
+ clearRectWithColor(frameInfoRect, 0, 1, 0, 1);
+}
+
+void GLWebViewState::clearRectWithColor(const IntRect& rect, float r, float g,
+ float b, float a)
+{
+ glScissor(rect.x(), rect.y(), rect.width(), rect.height());
+ glClearColor(r, g, b, a);
+ glClear(GL_COLOR_BUFFER_BIT);
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h
index 8d89704..d195597 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.h
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h
@@ -202,7 +202,7 @@ public:
unsigned int currentPictureCounter() const { return m_currentPictureCounter; }
void setIsScrolling(bool isScrolling) { m_isScrolling = isScrolling; }
- bool isScrolling() { return m_isScrolling; }
+ bool isScrolling() { return m_isScrolling || m_isViewportScrolling; }
void drawBackground(Color& backgroundColor);
double setupDrawing(IntRect& viewRect, SkRect& visibleRect,
@@ -254,6 +254,10 @@ public:
private:
void inval(const IntRect& rect);
+ void showFrameInfo(const IntRect& rect, bool treesSwapped);
+ void clearRectWithColor(const IntRect& rect, float r, float g,
+ float b, float a);
+ double m_prevDrawTime;
ZoomManager m_zoomManager;
android::Mutex m_tiledPageLock;
@@ -279,6 +283,7 @@ private:
GLExtras m_glExtras;
bool m_isScrolling;
+ bool m_isViewportScrolling;
bool m_goingDown;
bool m_goingLeft;
diff --git a/Source/WebCore/platform/graphics/android/GaneshContext.cpp b/Source/WebCore/platform/graphics/android/GaneshContext.cpp
index 03e6eb7..d4fa4e7 100644
--- a/Source/WebCore/platform/graphics/android/GaneshContext.cpp
+++ b/Source/WebCore/platform/graphics/android/GaneshContext.cpp
@@ -95,11 +95,7 @@ SkDevice* GaneshContext::getDeviceForBaseTile(const TileRenderInfo& renderInfo)
contextNeedsReset = true;
}
- SkDevice* device = 0;
- if (renderInfo.textureInfo->getSharedTextureMode() == SurfaceTextureMode)
- device = getDeviceForBaseTileSurface(renderInfo);
- else if (renderInfo.textureInfo->getSharedTextureMode() == EglImageMode)
- device = getDeviceForBaseTileFBO(renderInfo);
+ SkDevice* device = getDeviceForBaseTileSurface(renderInfo);
// We must reset the Ganesh context only after we are sure we have
// re-established our EGLContext as the current context.
diff --git a/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp b/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp
index f4df33a..5889655 100644
--- a/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp
+++ b/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp
@@ -84,20 +84,16 @@ void GaneshRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* can
GaneshContext* ganesh = GaneshContext::instance();
-#if !DEPRECATED_SURFACE_TEXTURE_MODE
- if (renderInfo.textureInfo->getSharedTextureMode() == SurfaceTextureMode) {
- TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
-
- tileQueue->lockQueue();
-
- bool ready = tileQueue->readyForUpdate();
- if (!ready) {
- XLOG("!ready");
- tileQueue->unlockQueue();
- return;
- }
+ TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
+
+ tileQueue->lockQueue();
+
+ bool ready = tileQueue->readyForUpdate();
+ if (!ready) {
+ XLOG("!ready");
+ tileQueue->unlockQueue();
+ return;
}
-#endif
SkDevice* device = NULL;
if (renderInfo.tileSize.width() == TilesManager::tileWidth()
@@ -118,12 +114,6 @@ void GaneshRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* can
// set the GPU device to the canvas
canvas->setDevice(device);
canvas->setDeviceFactory(device->getDeviceFactory());
-
- // invert canvas contents
- if (renderInfo.textureInfo->getSharedTextureMode() == EglImageMode) {
- canvas->scale(SK_Scalar1, -SK_Scalar1);
- canvas->translate(0, -renderInfo.tileSize.height());
- }
}
void GaneshRenderer::setupPartialInval(const TileRenderInfo& renderInfo, SkCanvas* canvas)
@@ -149,14 +139,10 @@ void GaneshRenderer::renderingComplete(const TileRenderInfo& renderInfo, SkCanva
// In SurfaceTextureMode we must call swapBuffers to unlock and post the
// tile's ANativeWindow (i.e. SurfaceTexture) buffer
- if (renderInfo.textureInfo->getSharedTextureMode() == SurfaceTextureMode) {
-#if !DEPRECATED_SURFACE_TEXTURE_MODE
- TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
- eglSwapBuffers(eglGetCurrentDisplay(), tileQueue->m_eglSurface);
- tileQueue->addItemInTransferQueue(&renderInfo, GpuUpload, 0);
- tileQueue->unlockQueue();
-#endif
- }
+ TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
+ eglSwapBuffers(eglGetCurrentDisplay(), tileQueue->m_eglSurface);
+ tileQueue->addItemInTransferQueue(&renderInfo, GpuUpload, 0);
+ tileQueue->unlockQueue();
if (renderInfo.measurePerf)
m_perfMon.stop(TAG_UPDATE_TEXTURE);
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index 567b54b..fc2eddd 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -555,6 +555,15 @@ void GraphicsLayerAndroid::updateScrollingLayers()
#endif
}
+void GraphicsLayerAndroid::updateScrollOffset() {
+ RenderLayer* layer = renderLayerFromClient(m_client);
+ if (!layer || !m_foregroundLayer)
+ return;
+ IntSize scroll = layer->scrolledContentOffset();
+ m_foregroundLayer->setScrollOffset(IntPoint(scroll.width(), scroll.height()));
+ askForSync();
+}
+
bool GraphicsLayerAndroid::repaint()
{
LOG("(%x) repaint(), gPaused(%d) m_needsRepaint(%d) m_haveContents(%d) ",
@@ -573,7 +582,7 @@ bool GraphicsLayerAndroid::repaint()
phase.set(GraphicsLayerPaintBackground);
if (!paintContext(m_contentLayer->recordContext(), layerBounds))
return false;
- m_contentLayer->checkTextPresence();
+ m_contentLayer->checkForPictureOptimizations();
// Construct the foreground layer and draw.
RenderBox* box = layer->renderBox();
@@ -592,7 +601,7 @@ bool GraphicsLayerAndroid::repaint()
layer->scrollToOffset(0, 0);
// At this point, it doesn't matter if painting failed.
(void) paintContext(m_foregroundLayer->recordContext(), contentsRect);
- m_foregroundLayer->checkTextPresence();
+ m_foregroundLayer->checkForPictureOptimizations();
layer->scrollToOffset(scroll.width(), scroll.height());
// Construct the clip layer for masking the contents.
@@ -606,6 +615,11 @@ bool GraphicsLayerAndroid::repaint()
m_foregroundClipLayer->setPosition(x, y);
m_foregroundClipLayer->setSize(width, height);
+ int rtlOffset = 0; // LTR uses no offset.
+ if (!layer->renderer()->style()->isLeftToRightDirection())
+ rtlOffset = layer->scrollWidth() - width; // Scroll all the way right.
+ m_foregroundLayer->setScrollOffset(IntPoint(scroll.width() + rtlOffset,
+ scroll.height()));
// Need to offset the foreground layer by the clip layer in order
// for the contents to be in the correct position.
m_foregroundLayer->setPosition(-x, -y);
@@ -625,7 +639,7 @@ bool GraphicsLayerAndroid::repaint()
// picture.
if (!paintContext(m_contentLayer->recordContext(), layerBounds))
return false;
- m_contentLayer->checkTextPresence();
+ m_contentLayer->checkForPictureOptimizations();
// Check for a scrollable iframe and report the scrolling
// limits based on the view size.
if (m_contentLayer->contentIsScrollable()) {
@@ -749,7 +763,7 @@ bool GraphicsLayerAndroid::createAnimationFromKeyframes(const KeyframeValueList&
KeyframeValueList* operationsList = new KeyframeValueList(AnimatedPropertyOpacity);
for (unsigned int i = 0; i < valueList.size(); i++) {
FloatAnimationValue* originalValue = (FloatAnimationValue*)valueList.at(i);
- PassRefPtr<TimingFunction> timingFunction(const_cast<TimingFunction*>(originalValue->timingFunction()));
+ RefPtr<TimingFunction> timingFunction(const_cast<TimingFunction*>(originalValue->timingFunction()));
FloatAnimationValue* value = new FloatAnimationValue(originalValue->keyTime(),
originalValue->value(),
timingFunction);
@@ -791,7 +805,7 @@ bool GraphicsLayerAndroid::createTransformAnimationsFromKeyframes(const Keyframe
KeyframeValueList* operationsList = new KeyframeValueList(AnimatedPropertyWebkitTransform);
for (unsigned int i = 0; i < valueList.size(); i++) {
TransformAnimationValue* originalValue = (TransformAnimationValue*)valueList.at(i);
- PassRefPtr<TimingFunction> timingFunction(const_cast<TimingFunction*>(originalValue->timingFunction()));
+ RefPtr<TimingFunction> timingFunction(const_cast<TimingFunction*>(originalValue->timingFunction()));
TransformAnimationValue* value = new TransformAnimationValue(originalValue->keyTime(),
originalValue->value(),
timingFunction);
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
index e6d75b0..c34aed8 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
@@ -125,6 +125,8 @@ public:
static int instancesCount();
+ virtual void updateScrollOffset();
+
private:
void askForSync();
diff --git a/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp b/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
index 691fbca..439733b 100644
--- a/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
@@ -195,7 +195,7 @@ void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sou
ASSERT(destx >= 0);
ASSERT(destx < m_size.width());
ASSERT(originx >= 0);
- ASSERT(originx <= sourceRect.right());
+ ASSERT(originx <= sourceRect.maxX());
int endx = destPoint.x() + sourceRect.maxX();
ASSERT(endx <= m_size.width());
@@ -207,7 +207,7 @@ void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sou
ASSERT(desty >= 0);
ASSERT(desty < m_size.height());
ASSERT(originy >= 0);
- ASSERT(originy <= sourceRect.bottom());
+ ASSERT(originy <= sourceRect.maxY());
int endy = destPoint.y() + sourceRect.maxY();
ASSERT(endy <= m_size.height());
diff --git a/Source/WebCore/platform/graphics/android/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/ImageTexture.cpp
index 23e3899..e1b18b4 100644
--- a/Source/WebCore/platform/graphics/android/ImageTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/ImageTexture.cpp
@@ -240,8 +240,10 @@ void ImageTexture::drawGL(LayerAndroid* layer)
// TiledTexture::draw() will call us back to know the
// transform and opacity, so we need to set m_layer
m_layer = layer;
- if (m_texture)
- m_texture->draw();
+ if (m_texture) {
+ IntRect visibleArea = m_layer->visibleArea();
+ m_texture->draw(visibleArea);
+ }
m_layer = 0;
}
diff --git a/Source/WebCore/platform/graphics/android/InspectorCanvas.cpp b/Source/WebCore/platform/graphics/android/InspectorCanvas.cpp
new file mode 100644
index 0000000..0137cec
--- /dev/null
+++ b/Source/WebCore/platform/graphics/android/InspectorCanvas.cpp
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2011, 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 "InspectorCanvas.h"
+
+#include "SkPicture.h"
+
+#include <cutils/log.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/text/CString.h>
+
+#undef XLOGC
+#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "InspectorCanvas", __VA_ARGS__)
+
+#ifdef DEBUG
+
+#undef XLOG
+#define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "InspectorCanvas", __VA_ARGS__)
+
+#else
+
+#undef XLOG
+#define XLOG(...)
+
+#endif // DEBUG
+
+
+namespace WebCore {
+
+
+void InspectorCanvas::setHasText()
+{
+ m_hasText = true;
+ setHasContent();
+}
+
+void InspectorCanvas::setHasContent()
+{
+ m_hasContent = true;
+ if (m_hasText) {
+ // has text. Have to paint properly, so no further
+ // information is useful
+ m_picture->abortPlayback();
+ }
+}
+
+void InspectorCanvas::setIsBackground(const SkPaint& paint)
+{
+ // TODO: if the paint is a solid color, opaque, and the last instruction in
+ // the picture, replace the picture with simple draw rect info
+ setHasContent();
+}
+
+void InspectorCanvas::commonDrawBitmap(const SkBitmap& bitmap,
+ const SkIRect* rect,
+ const SkMatrix&,
+ const SkPaint&)
+{
+ setHasContent();
+}
+
+void InspectorCanvas::drawPaint(const SkPaint& paint)
+{
+ setHasContent();
+}
+
+void InspectorCanvas::drawPath(const SkPath&, const SkPaint& paint)
+{
+ setHasContent();
+}
+void InspectorCanvas::drawPoints(PointMode, size_t,
+ const SkPoint [], const SkPaint& paint)
+{
+ setHasContent();
+}
+
+void InspectorCanvas::drawRect(const SkRect& rect, const SkPaint& paint)
+{
+ if (rect.fLeft == 0
+ && rect.fTop == 0
+ && rect.width() >= m_picture->width()
+ && rect.height() >= m_picture->height()) {
+ // rect same size as canvas, treat layer as a single color rect until
+ // more content is drawn
+ setIsBackground(paint);
+ } else {
+ // regular rect drawing path
+ setHasContent();
+ }
+ XLOG("draw rect at %f %f, size %f %f, picture size %d %d",
+ rect.fLeft, rect.fTop, rect.width(), rect.height(),
+ m_picture->width(), m_picture->height());
+}
+void InspectorCanvas::drawSprite(const SkBitmap& , int , int ,
+ const SkPaint* paint)
+{
+ setHasContent();
+}
+
+void InspectorCanvas::drawText(const void*, size_t byteLength, SkScalar,
+ SkScalar, const SkPaint& paint)
+{
+ setHasText();
+}
+
+void InspectorCanvas::drawPosText(const void* , size_t byteLength,
+ const SkPoint [], const SkPaint& paint)
+{
+ setHasText();
+}
+
+void InspectorCanvas::drawPosTextH(const void*, size_t byteLength,
+ const SkScalar [], SkScalar,
+ const SkPaint& paint)
+{
+ setHasText();
+}
+
+void InspectorCanvas::drawTextOnPath(const void*, size_t byteLength,
+ const SkPath&, const SkMatrix*,
+ const SkPaint& paint)
+{
+ setHasText();
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/InspectorCanvas.h b/Source/WebCore/platform/graphics/android/InspectorCanvas.h
new file mode 100644
index 0000000..415a579
--- /dev/null
+++ b/Source/WebCore/platform/graphics/android/InspectorCanvas.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2011, 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 InspectorCanvas_h
+#define InspectorCanvas_h
+
+#include "SkBounder.h"
+#include "SkCanvas.h"
+
+namespace WebCore {
+
+class InspectorBounder : public SkBounder {
+ virtual bool onIRect(const SkIRect& rect)
+ {
+ return false;
+ }
+};
+
+class InspectorCanvas : public SkCanvas {
+public:
+ InspectorCanvas(SkBounder* bounder, SkPicture* picture)
+ : m_picture(picture)
+ , m_hasText(false)
+ , m_hasContent(false)
+ {
+ setBounder(bounder);
+ }
+
+ bool hasText() {return m_hasText;}
+ bool hasContent() {return m_hasContent;}
+
+ virtual bool clipPath(const SkPath&, SkRegion::Op) {
+ return true;
+ }
+
+ virtual void commonDrawBitmap(const SkBitmap& bitmap,
+ const SkIRect* rect,
+ const SkMatrix&,
+ const SkPaint&);
+
+ virtual void drawPaint(const SkPaint& paint);
+ virtual void drawPath(const SkPath&, const SkPaint& paint);
+ virtual void drawPoints(PointMode, size_t,
+ const SkPoint [], const SkPaint& paint);
+
+ virtual void drawRect(const SkRect& , const SkPaint& paint);
+ virtual void drawSprite(const SkBitmap& , int , int ,
+ const SkPaint* paint = NULL);
+
+ virtual void drawText(const void*, size_t byteLength, SkScalar,
+ SkScalar, const SkPaint& paint);
+ virtual void drawPosText(const void* , size_t byteLength,
+ const SkPoint [], const SkPaint& paint);
+ virtual void drawPosTextH(const void*, size_t byteLength,
+ const SkScalar [], SkScalar,
+ const SkPaint& paint);
+ virtual void drawTextOnPath(const void*, size_t byteLength,
+ const SkPath&, const SkMatrix*,
+ const SkPaint& paint);
+
+private:
+
+ // vector instructions exist, must repaint at any scale
+ void setHasText();
+
+ // painting is required
+ void setHasContent();
+
+ // rect covering entire content, don't need to use a texture if nothing else
+ // is painted
+ void setIsBackground(const SkPaint& paint);
+
+ SkPicture* m_picture;
+ bool m_hasText;
+ bool m_hasContent;
+};
+
+} // namespace WebCore
+
+#endif // InspectorCanvas_h
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
index 962bcdf..88e419d 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -8,11 +8,11 @@
#include "DrawExtra.h"
#include "GLUtils.h"
#include "ImagesManager.h"
+#include "InspectorCanvas.h"
#include "MediaLayer.h"
#include "PaintedSurface.h"
#include "ParseCanvas.h"
#include "SkBitmapRef.h"
-#include "SkBounder.h"
#include "SkDrawFilter.h"
#include "SkPaint.h"
#include "SkPicture.h"
@@ -55,87 +55,6 @@ private:
int m_opacity;
};
-class HasTextBounder : public SkBounder {
- virtual bool onIRect(const SkIRect& rect)
- {
- return false;
- }
-};
-
-class HasTextCanvas : public SkCanvas {
-public:
- HasTextCanvas(SkBounder* bounder, SkPicture* picture)
- : m_picture(picture)
- , m_hasText(false)
- {
- setBounder(bounder);
- }
-
- void setHasText()
- {
- m_hasText = true;
- m_picture->abortPlayback();
- }
-
- bool hasText()
- {
- return m_hasText;
- }
-
- virtual bool clipPath(const SkPath&, SkRegion::Op) {
- return true;
- }
-
- virtual void commonDrawBitmap(const SkBitmap& bitmap,
- const SkIRect* rect,
- const SkMatrix&,
- const SkPaint&) {}
-
- virtual void drawPaint(const SkPaint& paint) {}
- virtual void drawPath(const SkPath&, const SkPaint& paint) {}
- virtual void drawPoints(PointMode, size_t,
- const SkPoint [], const SkPaint& paint) {}
-
- virtual void drawRect(const SkRect& , const SkPaint& paint) {}
- virtual void drawSprite(const SkBitmap& , int , int ,
- const SkPaint* paint = NULL) {}
-
- virtual void drawText(const void*, size_t byteLength, SkScalar,
- SkScalar, const SkPaint& paint)
- {
- setHasText();
- }
-
- virtual void drawPosText(const void* , size_t byteLength,
- const SkPoint [], const SkPaint& paint)
- {
- setHasText();
- }
-
- virtual void drawPosTextH(const void*, size_t byteLength,
- const SkScalar [], SkScalar,
- const SkPaint& paint)
- {
- setHasText();
- }
-
- virtual void drawTextOnPath(const void*, size_t byteLength,
- const SkPath&, const SkMatrix*,
- const SkPaint& paint)
- {
- setHasText();
- }
-
- virtual void drawPicture(SkPicture& picture) {
- SkCanvas::drawPicture(picture);
- }
-
-private:
-
- SkPicture* m_picture;
- bool m_hasText;
-};
-
///////////////////////////////////////////////////////////////////////////////
LayerAndroid::LayerAndroid(RenderLayer* owner) : Layer(),
@@ -198,6 +117,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer),
m_fixedMarginBottom = layer.m_fixedMarginBottom;
m_fixedRect = layer.m_fixedRect;
m_iframeOffset = layer.m_iframeOffset;
+ m_offset = layer.m_offset;
m_recordingPicture = layer.m_recordingPicture;
SkSafeRef(m_recordingPicture);
@@ -226,13 +146,13 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer),
#endif
}
-void LayerAndroid::checkTextPresence()
+void LayerAndroid::checkForPictureOptimizations()
{
if (m_recordingPicture) {
// Let's check if we have text or not. If we don't, we can limit
// ourselves to scale 1!
- HasTextBounder hasTextBounder;
- HasTextCanvas checker(&hasTextBounder, m_recordingPicture);
+ InspectorBounder inspectorBounder;
+ InspectorCanvas checker(&inspectorBounder, m_recordingPicture);
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config,
m_recordingPicture->width(),
@@ -240,6 +160,12 @@ void LayerAndroid::checkTextPresence()
checker.setBitmapDevice(bitmap);
checker.drawPicture(*m_recordingPicture);
m_hasText = checker.hasText();
+ if (!checker.hasContent()) {
+ // no content to draw, discard picture so UI / tile generation
+ // doesn't bother with it
+ SkSafeUnref(m_recordingPicture);
+ m_recordingPicture = 0;
+ }
}
}
@@ -685,7 +611,7 @@ void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentM
m_atomicSync.lock();
IntSize layerSize(getSize().width(), getSize().height());
FloatPoint anchorPoint(getAnchorPoint().fX, getAnchorPoint().fY);
- FloatPoint position(getPosition().fX, getPosition().fY);
+ FloatPoint position(getPosition().fX - m_offset.x(), getPosition().fY - m_offset.y());
float centerOffsetX = (0.5f - anchorPoint.x()) * layerSize.width();
float centerOffsetY = (0.5f - anchorPoint.y()) * layerSize.height();
float originX = anchorPoint.x() * layerSize.width();
@@ -1129,6 +1055,8 @@ bool LayerAndroid::drawGL()
}
}
+ m_state->glExtras()->drawGL(this);
+
// When the layer is dirty, the UI thread should be notified to redraw.
askScreenUpdate |= drawChildrenGL();
m_atomicSync.lock();
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h
index c1f1bc9..578c2ff 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h
@@ -199,6 +199,7 @@ public:
setShouldInheritFromRootTransform(true);
}
+ void setScrollOffset(IntPoint offset) { m_offset = offset; }
void setBackgroundColor(SkColor color);
void setMaskLayer(LayerAndroid*);
void setMasksToBounds(bool masksToBounds)
@@ -302,7 +303,7 @@ public:
int type() { return m_type; }
bool hasText() { return m_hasText; }
- void checkTextPresence();
+ void checkForPictureOptimizations();
void copyAnimationStartTimesRecursive(LayerAndroid* oldTree);
@@ -315,7 +316,7 @@ public:
protected:
virtual void onDraw(SkCanvas*, SkScalar opacity);
-
+ IntPoint m_offset;
TransformationMatrix m_drawTransform;
private:
diff --git a/Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h b/Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h
index 404ef08..535e7ae 100644
--- a/Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h
+++ b/Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h
@@ -95,6 +95,7 @@ public:
virtual void onPosterFetched(SkBitmap*) { }
void onBuffering(int percent);
void onTimeupdate(int position);
+ void onRestoreState();
// These following two functions are used to turn on inline video support
bool supportsAcceleratedRendering() const { return true; }
diff --git a/Source/WebCore/platform/graphics/android/MediaTexture.cpp b/Source/WebCore/platform/graphics/android/MediaTexture.cpp
index 1676186..f3d1756 100644
--- a/Source/WebCore/platform/graphics/android/MediaTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/MediaTexture.cpp
@@ -283,7 +283,6 @@ void MediaTexture::setDimensions(const ANativeWindow* window,
void MediaTexture::setFramerateCallback(const ANativeWindow* window,
FramerateCallbackProc callback)
{
- XLOG("Release ANW %p (%p):(%p)", this, m_surfaceTexture.get(), m_surfaceTextureClient.get());
android::Mutex::Autolock lock(m_mediaLock);
for (unsigned int i = 0; i < m_videoTextures.size(); i++) {
if (m_videoTextures[i]->nativeWindow.get() == window) {
diff --git a/Source/WebCore/platform/graphics/android/PaintedSurface.cpp b/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
index 45c7579..b65c64a 100644
--- a/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
+++ b/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
@@ -99,7 +99,7 @@ void PaintedSurface::prepare(GLWebViewState* state)
paintingLayer->uniqueId(), paintingLayer,
paintingLayer->getScale());
- IntRect visibleArea = computeVisibleArea(paintingLayer);
+ IntRect prepareArea = computePrepareArea(paintingLayer);
m_scale = state->scale();
@@ -109,7 +109,7 @@ void PaintedSurface::prepare(GLWebViewState* state)
m_scale = 1;
m_tiledTexture->prepare(state, m_scale, m_pictureUsed != paintingLayer->pictureUsed(),
- startFastSwap, visibleArea);
+ startFastSwap, prepareArea);
}
bool PaintedSurface::draw()
@@ -118,8 +118,10 @@ bool PaintedSurface::draw()
return false;
bool askRedraw = false;
- if (m_tiledTexture)
- askRedraw = m_tiledTexture->draw();
+ if (m_tiledTexture) {
+ IntRect visibleArea = m_drawingLayer->visibleArea();
+ askRedraw = m_tiledTexture->draw(visibleArea);
+ }
return askRedraw;
}
@@ -196,7 +198,7 @@ void PaintedSurface::computeTexturesAmount(TexturesResult* result)
result->full += nbTexturesUnclipped;
}
-IntRect PaintedSurface::computeVisibleArea(LayerAndroid* layer) {
+IntRect PaintedSurface::computePrepareArea(LayerAndroid* layer) {
IntRect area;
if (!layer)
return area;
diff --git a/Source/WebCore/platform/graphics/android/PaintedSurface.h b/Source/WebCore/platform/graphics/android/PaintedSurface.h
index b8ab7b8..0f201a7 100644
--- a/Source/WebCore/platform/graphics/android/PaintedSurface.h
+++ b/Source/WebCore/platform/graphics/android/PaintedSurface.h
@@ -67,7 +67,7 @@ public:
bool owns(BaseTileTexture* texture);
void computeTexturesAmount(TexturesResult*);
- IntRect computeVisibleArea(LayerAndroid*);
+ IntRect computePrepareArea(LayerAndroid*);
// TilePainter methods for TiledTexture
virtual const TransformationMatrix* transform();
diff --git a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp
index 3c2ced5..55692be 100644
--- a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp
@@ -9,27 +9,34 @@ namespace WebCore {
bool ScrollableLayerAndroid::scrollTo(int x, int y)
{
- SkIRect scrollBounds;
- getScrollRect(&scrollBounds);
- if (!scrollBounds.fRight && !scrollBounds.fBottom)
+ IntRect scrollBounds;
+ getScrollBounds(&scrollBounds);
+ if (!scrollBounds.width() && !scrollBounds.height())
return false;
-
- SkScalar newX = SkScalarPin(x, 0, scrollBounds.fRight);
- SkScalar newY = SkScalarPin(y, 0, scrollBounds.fBottom);
+ SkScalar newX = SkScalarPin(x, scrollBounds.x(), scrollBounds.width());
+ SkScalar newY = SkScalarPin(y, scrollBounds.y(), scrollBounds.height());
// Check for no change.
- if (newX == scrollBounds.fLeft && newY == scrollBounds.fTop)
+ if (newX == m_offset.x() && newY == m_offset.y())
return false;
+ setScrollOffset(IntPoint(newX, newY));
+ return true;
+}
- setPosition(m_scrollLimits.fLeft - newX, m_scrollLimits.fTop - newY);
+void ScrollableLayerAndroid::getScrollBounds(IntRect* out) const
+{
+ const SkPoint& pos = getPosition();
+ out->setX(m_scrollLimits.fLeft - pos.fX);
+ out->setY(m_scrollLimits.fTop - pos.fY);
+ out->setWidth(getSize().width() - m_scrollLimits.width());
+ out->setHeight(getSize().height() - m_scrollLimits.height());
- return true;
}
void ScrollableLayerAndroid::getScrollRect(SkIRect* out) const
{
const SkPoint& pos = getPosition();
- out->fLeft = m_scrollLimits.fLeft - pos.fX;
- out->fTop = m_scrollLimits.fTop - pos.fY;
+ out->fLeft = m_scrollLimits.fLeft - pos.fX + m_offset.x();
+ out->fTop = m_scrollLimits.fTop - pos.fY + m_offset.y();
out->fRight = getSize().width() - m_scrollLimits.width();
out->fBottom = getSize().height() - m_scrollLimits.height();
}
diff --git a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h
index 5cba5d9..b8ff299 100644
--- a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h
@@ -71,6 +71,9 @@ public:
friend LayerAndroid* android::deserializeLayer(SkStream* stream);
private:
+
+ void getScrollBounds(IntRect*) const;
+
// The position of the visible area of the layer, relative to the parent
// layer. This is fixed during scrolling. We acheive scrolling by modifying
// the position of the layer.
diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
index 2a6a488..a706276 100644
--- a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
+++ b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
@@ -62,6 +62,26 @@ static const char gFragmentShader[] =
" gl_FragColor *= alpha; "
"}\n";
+// We could pass the pureColor into either Vertex or Frag Shader.
+// The reason we passed the color into the Vertex Shader is that some driver
+// might create redundant copy when uniforms in fragment shader changed.
+static const char gPureColorVertexShader[] =
+ "attribute vec4 vPosition;\n"
+ "uniform mat4 projectionMatrix;\n"
+ "uniform vec4 inputColor;\n"
+ "varying vec4 v_color;\n"
+ "void main() {\n"
+ " gl_Position = projectionMatrix * vPosition;\n"
+ " v_color = inputColor;\n"
+ "}\n";
+
+static const char gPureColorFragmentShader[] =
+ "precision mediump float;\n"
+ "varying vec4 v_color;\n"
+ "void main() {\n"
+ " gl_FragColor = v_color;\n"
+ "}\n";
+
static const char gFragmentShaderInverted[] =
"precision mediump float;\n"
"varying vec2 v_texCoord; \n"
@@ -151,7 +171,7 @@ GLuint ShaderProgram::loadShader(GLenum shaderType, const char* pSource)
return shader;
}
-GLuint ShaderProgram::createProgram(const char* pVertexSource, const char* pFragmentSource)
+GLint ShaderProgram::createProgram(const char* pVertexSource, const char* pFragmentSource)
{
GLuint vertexShader = loadShader(GL_VERTEX_SHADER, pVertexSource);
if (!vertexShader) {
@@ -197,57 +217,80 @@ ShaderProgram::ShaderProgram()
, m_contrast(1)
, m_alphaLayer(false)
, m_currentScale(1.0f)
+ , m_needsInit(true)
{
init();
}
void ShaderProgram::init()
{
- m_program = createProgram(gVertexShader, gFragmentShader);
- m_programInverted = createProgram(gVertexShader, gFragmentShaderInverted);
- m_videoProgram = createProgram(gVideoVertexShader, gVideoFragmentShader);
- m_surfTexOESProgram =
+ GLint tex2DProgram = createProgram(gVertexShader, gFragmentShader);
+ GLint pureColorProgram = createProgram(gPureColorVertexShader, gPureColorFragmentShader);
+ GLint tex2DInvProgram = createProgram(gVertexShader, gFragmentShaderInverted);
+ GLint videoProgram = createProgram(gVideoVertexShader, gVideoFragmentShader);
+ GLint texOESProgram =
createProgram(gVertexShader, gSurfaceTextureOESFragmentShader);
- m_surfTexOESProgramInverted =
+ GLint texOESInvProgram =
createProgram(gVertexShader, gSurfaceTextureOESFragmentShaderInverted);
- if (m_program == -1
- || m_programInverted == -1
- || m_videoProgram == -1
- || m_surfTexOESProgram == -1
- || m_surfTexOESProgramInverted == -1)
+ if (tex2DProgram == -1
+ || pureColorProgram == -1
+ || tex2DInvProgram == -1
+ || videoProgram == -1
+ || texOESProgram == -1
+ || texOESInvProgram == -1) {
+ m_needsInit = true;
return;
-
- m_hProjectionMatrix = glGetUniformLocation(m_program, "projectionMatrix");
- m_hAlpha = glGetUniformLocation(m_program, "alpha");
- m_hTexSampler = glGetUniformLocation(m_program, "s_texture");
- m_hPosition = glGetAttribLocation(m_program, "vPosition");
-
- m_hProjectionMatrixInverted = glGetUniformLocation(m_programInverted, "projectionMatrix");
- m_hAlphaInverted = glGetUniformLocation(m_programInverted, "alpha");
- m_hContrastInverted = glGetUniformLocation(m_surfTexOESProgramInverted, "contrast");
- m_hTexSamplerInverted = glGetUniformLocation(m_programInverted, "s_texture");
- m_hPositionInverted = glGetAttribLocation(m_programInverted, "vPosition");
-
- m_hVideoProjectionMatrix =
- glGetUniformLocation(m_videoProgram, "projectionMatrix");
- m_hVideoTextureMatrix = glGetUniformLocation(m_videoProgram, "textureMatrix");
- m_hVideoTexSampler = glGetUniformLocation(m_videoProgram, "s_yuvTexture");
- m_hVideoPosition = glGetAttribLocation(m_program, "vPosition");
-
- m_hSTOESProjectionMatrix =
- glGetUniformLocation(m_surfTexOESProgram, "projectionMatrix");
- m_hSTOESAlpha = glGetUniformLocation(m_surfTexOESProgram, "alpha");
- m_hSTOESTexSampler = glGetUniformLocation(m_surfTexOESProgram, "s_texture");
- m_hSTOESPosition = glGetAttribLocation(m_surfTexOESProgram, "vPosition");
-
- m_hSTOESProjectionMatrixInverted =
- glGetUniformLocation(m_surfTexOESProgramInverted, "projectionMatrix");
- m_hSTOESAlphaInverted = glGetUniformLocation(m_surfTexOESProgramInverted, "alpha");
- m_hSTOESContrastInverted = glGetUniformLocation(m_surfTexOESProgramInverted, "contrast");
- m_hSTOESTexSamplerInverted = glGetUniformLocation(m_surfTexOESProgramInverted, "s_texture");
- m_hSTOESPositionInverted = glGetAttribLocation(m_surfTexOESProgramInverted, "vPosition");
-
+ }
+ m_needsInit = false;
+
+ GLint pureColorPosition = glGetAttribLocation(pureColorProgram, "vPosition");
+ GLint pureColorProjMtx = glGetUniformLocation(pureColorProgram, "projectionMatrix");
+ GLint pureColorValue = glGetUniformLocation(pureColorProgram, "inputColor");
+ m_handleArray[PureColor].init(-1, -1, pureColorPosition, pureColorProgram,
+ pureColorProjMtx, pureColorValue, -1, -1);
+
+ GLint tex2DAlpha = glGetUniformLocation(tex2DProgram, "alpha");
+ GLint tex2DPosition = glGetAttribLocation(tex2DProgram, "vPosition");
+ GLint tex2DProjMtx = glGetUniformLocation(tex2DProgram, "projectionMatrix");
+ GLint tex2DTexSampler = glGetUniformLocation(tex2DProgram, "s_texture");
+ m_handleArray[Tex2D].init(tex2DAlpha, -1, tex2DPosition, tex2DProgram,
+ tex2DProjMtx, -1, tex2DTexSampler, -1);
+
+ GLint tex2DInvAlpha = glGetUniformLocation(tex2DInvProgram, "alpha");
+ GLint tex2DInvContrast = glGetUniformLocation(tex2DInvProgram, "contrast");
+ GLint tex2DInvPosition = glGetAttribLocation(tex2DInvProgram, "vPosition");
+ GLint tex2DInvProjMtx = glGetUniformLocation(tex2DInvProgram, "projectionMatrix");
+ GLint tex2DInvTexSampler = glGetUniformLocation(tex2DInvProgram, "s_texture");
+ m_handleArray[Tex2DInv].init(tex2DInvAlpha, tex2DInvContrast,
+ tex2DInvPosition, tex2DInvProgram,
+ tex2DInvProjMtx, -1,
+ tex2DInvTexSampler, -1);
+
+ GLint texOESAlpha = glGetUniformLocation(texOESProgram, "alpha");
+ GLint texOESPosition = glGetAttribLocation(texOESProgram, "vPosition");
+ GLint texOESProjMtx = glGetUniformLocation(texOESProgram, "projectionMatrix");
+ GLint texOESTexSampler = glGetUniformLocation(texOESProgram, "s_texture");
+ m_handleArray[TexOES].init(texOESAlpha, -1, texOESPosition, texOESProgram,
+ texOESProjMtx, -1, texOESTexSampler, -1);
+
+ GLint texOESInvAlpha = glGetUniformLocation(texOESInvProgram, "alpha");
+ GLint texOESInvContrast = glGetUniformLocation(texOESInvProgram, "contrast");
+ GLint texOESInvPosition = glGetAttribLocation(texOESInvProgram, "vPosition");
+ GLint texOESInvProjMtx = glGetUniformLocation(texOESInvProgram, "projectionMatrix");
+ GLint texOESInvTexSampler = glGetUniformLocation(texOESInvProgram, "s_texture");
+ m_handleArray[TexOESInv].init(texOESInvAlpha, texOESInvContrast,
+ texOESInvPosition, texOESInvProgram,
+ texOESInvProjMtx, -1,
+ texOESInvTexSampler, -1);
+
+ GLint videoPosition = glGetAttribLocation(videoProgram, "vPosition");
+ GLint videoProjMtx = glGetUniformLocation(videoProgram, "projectionMatrix");
+ GLint videoTexSampler = glGetUniformLocation(videoProgram, "s_yuvTexture");
+ GLint videoTexMtx = glGetUniformLocation(videoProgram, "textureMatrix");
+ m_handleArray[Video].init(-1, -1, videoPosition, videoProgram,
+ videoProjMtx, -1, videoTexSampler,
+ videoTexMtx);
const GLfloat coord[] = {
0.0f, 0.0f, // C
@@ -260,6 +303,12 @@ void ShaderProgram::init()
glBindBuffer(GL_ARRAY_BUFFER, m_textureBuffer[0]);
glBufferData(GL_ARRAY_BUFFER, 2 * 4 * sizeof(GLfloat), coord, GL_STATIC_DRAW);
+ TransformationMatrix matrix;
+ // Map x,y from (0,1) to (-1, 1)
+ matrix.scale3d(2, 2, 1);
+ matrix.translate3d(-0.5, -0.5, 0);
+ GLUtils::toGLMatrix(m_transferProjMtx, matrix);
+
GLUtils::checkGlError("init");
}
@@ -298,7 +347,8 @@ void ShaderProgram::setViewport(SkRect& viewport, float scale)
m_currentScale = scale;
}
-void ShaderProgram::setProjectionMatrix(SkRect& geometry, GLint projectionMatrixHandle)
+// Calculate the matrix given the geometry.
+void ShaderProgram::setProjectionMatrix(const SkRect& geometry, GLfloat* mtxPtr)
{
TransformationMatrix translate;
translate.translate3d(geometry.fLeft, geometry.fTop, 0.0);
@@ -312,89 +362,73 @@ void ShaderProgram::setProjectionMatrix(SkRect& geometry, GLint projectionMatrix
else
total = m_projectionMatrix * translate * scale;
- GLfloat projectionMatrix[16];
- GLUtils::toGLMatrix(projectionMatrix, total);
- glUniformMatrix4fv(projectionMatrixHandle, 1, GL_FALSE, projectionMatrix);
+ GLUtils::toGLMatrix(mtxPtr, total);
}
-void ShaderProgram::drawQuadInternal(SkRect& geometry,
- GLint textureId,
- float opacity,
- GLint program,
- GLint projectionMatrixHandle,
- GLint texSampler,
- GLenum textureTarget,
- GLint position,
- GLint alpha,
- GLint texFilter,
- GLint contrast)
+// Calculate the right color value sent into the shader considering the (0,1)
+// clamp and alpha blending.
+Color ShaderProgram::shaderColor(Color pureColor, float opacity)
{
- glUseProgram(program);
-
- if (!geometry.isEmpty())
- setProjectionMatrix(geometry, projectionMatrixHandle);
- else {
- TransformationMatrix matrix;
- // Map x,y from (0,1) to (-1, 1)
- matrix.scale3d(2, 2, 1);
- matrix.translate3d(-0.5, -0.5, 0);
- GLfloat projectionMatrix[16];
- GLUtils::toGLMatrix(projectionMatrix, matrix);
- glUniformMatrix4fv(projectionMatrixHandle, 1, GL_FALSE, projectionMatrix);
+ float r = pureColor.red() / 255.0;
+ float g = pureColor.green() / 255.0;
+ float b = pureColor.blue() / 255.0;
+ float a = pureColor.alpha() / 255.0;
+
+ if (TilesManager::instance()->invertedScreen()) {
+ float intensity = a - (0.2989 * r + 0.5866 * g + 0.1145 * b);
+ intensity = ((intensity - a / 2.0) * m_contrast) + a / 2.0;
+ intensity *= opacity;
+ return Color(intensity, intensity, intensity, a * opacity);
}
-
- glActiveTexture(GL_TEXTURE0);
- glUniform1i(texSampler, 0);
- glBindTexture(textureTarget, textureId);
- glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, texFilter);
- glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, texFilter);
- glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- glBindBuffer(GL_ARRAY_BUFFER, m_textureBuffer[0]);
- glEnableVertexAttribArray(position);
- glVertexAttribPointer(position, 2, GL_FLOAT, GL_FALSE, 0, 0);
- glUniform1f(alpha, opacity);
- if (contrast != -1)
- glUniform1f(contrast, m_contrast);
-
- setBlendingState(opacity < 1.0);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ return Color(r * opacity, g * opacity, b * opacity, a * opacity);
}
-void ShaderProgram::drawQuad(SkRect& geometry, int textureId, float opacity,
- GLenum textureTarget, GLint texFilter)
+// For shaders using texture, it is easy to get the type from the textureTarget.
+ShaderType ShaderProgram::getTextureShaderType(GLenum textureTarget)
{
+ ShaderType type = UndefinedShader;
if (textureTarget == GL_TEXTURE_2D) {
- if (!TilesManager::instance()->invertedScreen()) {
- drawQuadInternal(geometry, textureId, opacity, m_program,
- m_hProjectionMatrix,
- m_hTexSampler, GL_TEXTURE_2D,
- m_hPosition, m_hAlpha, texFilter);
- } else {
+ if (!TilesManager::instance()->invertedScreen())
+ type = Tex2D;
+ else {
// With the new GPU texture upload path, we do not use an FBO
// to blit the texture we receive from the TexturesGenerator thread.
// To implement inverted rendering, we thus have to do the rendering
// live, by using a different shader.
- drawQuadInternal(geometry, textureId, opacity, m_programInverted,
- m_hProjectionMatrixInverted,
- m_hTexSamplerInverted, GL_TEXTURE_2D,
- m_hPositionInverted, m_hAlphaInverted, texFilter,
- m_hContrastInverted);
+ type = Tex2DInv;
}
- } else if (textureTarget == GL_TEXTURE_EXTERNAL_OES
- && !TilesManager::instance()->invertedScreen()) {
- drawQuadInternal(geometry, textureId, opacity, m_surfTexOESProgram,
- m_hSTOESProjectionMatrix,
- m_hSTOESTexSampler, GL_TEXTURE_EXTERNAL_OES,
- m_hSTOESPosition, m_hSTOESAlpha, texFilter);
- } else if (textureTarget == GL_TEXTURE_EXTERNAL_OES
- && TilesManager::instance()->invertedScreen()) {
- drawQuadInternal(geometry, textureId, opacity, m_surfTexOESProgramInverted,
- m_hSTOESProjectionMatrixInverted,
- m_hSTOESTexSamplerInverted, GL_TEXTURE_EXTERNAL_OES,
- m_hSTOESPositionInverted, m_hSTOESAlphaInverted,
- texFilter, m_hSTOESContrastInverted);
+ } else if (textureTarget == GL_TEXTURE_EXTERNAL_OES) {
+ if (!TilesManager::instance()->invertedScreen())
+ type = TexOES;
+ else
+ type = TexOESInv;
+ }
+ return type;
+}
+
+void ShaderProgram::drawQuad(SkRect& geometry, int textureId, float opacity,
+ Color pureColor, GLenum textureTarget, GLint texFilter)
+{
+ ShaderType type = UndefinedShader;
+ if (!textureId) {
+ pureColor = shaderColor(pureColor, opacity);
+ if (pureColor.rgb() == Color::transparent && opacity < 1.0)
+ return;
+ type = PureColor;
+ } else
+ type = getTextureShaderType(textureTarget);
+
+ if (type != UndefinedShader) {
+ // The matrix is either for the transfer queue or the tiles
+ GLfloat* finalMatrix = m_transferProjMtx;
+ GLfloat projectionMatrix[16];
+ if (!geometry.isEmpty()) {
+ setProjectionMatrix(geometry, projectionMatrix);
+ finalMatrix = projectionMatrix;
+ }
+ setBlendingState(opacity < 1.0);
+ drawQuadInternal(type, finalMatrix, textureId, opacity, textureTarget,
+ texFilter, pureColor);
}
GLUtils::checkGlError("drawQuad");
}
@@ -530,40 +564,45 @@ float ShaderProgram::zValue(const TransformationMatrix& drawMatrix, float w, flo
return result.z();
}
-void ShaderProgram::drawLayerQuadInternal(const GLfloat* projectionMatrix,
- int textureId, float opacity,
- GLenum textureTarget, GLint program,
- GLint matrix, GLint texSample,
- GLint position, GLint alpha,
- GLint contrast)
+void ShaderProgram::drawQuadInternal(ShaderType type, const GLfloat* matrix,
+ int textureId, float opacity,
+ GLenum textureTarget, GLenum filter,
+ const Color& pureColor)
{
- glUseProgram(program);
- glUniformMatrix4fv(matrix, 1, GL_FALSE, projectionMatrix);
-
- glActiveTexture(GL_TEXTURE0);
- glUniform1i(texSample, 0);
- glBindTexture(textureTarget, textureId);
- glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
+ glUseProgram(m_handleArray[type].programHandle);
+ glUniformMatrix4fv(m_handleArray[type].projMtxHandle, 1, GL_FALSE, matrix);
+
+ if (type != PureColor) {
+ glActiveTexture(GL_TEXTURE0);
+ glUniform1i(m_handleArray[type].texSamplerHandle, 0);
+ glBindTexture(textureTarget, textureId);
+ glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, filter);
+ glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, filter);
+ glUniform1f(m_handleArray[type].alphaHandle, opacity);
+
+ GLint contrastHandle = m_handleArray[type].contrastHandle;
+ if (contrastHandle != -1)
+ glUniform1f(contrastHandle, m_contrast);
+ } else {
+ glUniform4f(m_handleArray[type].pureColorHandle,
+ pureColor.red() / 255.0, pureColor.green() / 255.0,
+ pureColor.blue() / 255.0, pureColor.alpha() / 255.0);
+ }
+ GLint positionHandle = m_handleArray[type].positionHandle;
glBindBuffer(GL_ARRAY_BUFFER, m_textureBuffer[0]);
- glEnableVertexAttribArray(position);
- glVertexAttribPointer(position, 2, GL_FLOAT, GL_FALSE, 0, 0);
- glUniform1f(alpha, opacity);
- if (contrast != -1)
- glUniform1f(contrast, m_contrast);
-}
+ glEnableVertexAttribArray(positionHandle);
+ glVertexAttribPointer(positionHandle, 2, GL_FLOAT, GL_FALSE, 0, 0);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+}
void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix,
const SkRect& geometry, int textureId,
float opacity, bool forceBlending,
- GLenum textureTarget)
+ GLenum textureTarget,
+ Color pureColor)
{
-
TransformationMatrix modifiedDrawMatrix = drawMatrix;
// move the drawing depending on where the texture is on the layer
modifiedDrawMatrix.translate(geometry.fLeft, geometry.fTop);
@@ -578,37 +617,23 @@ void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix,
GLfloat projectionMatrix[16];
GLUtils::toGLMatrix(projectionMatrix, renderMatrix);
- if (textureTarget == GL_TEXTURE_2D) {
- if (!TilesManager::instance()->invertedScreen()) {
- drawLayerQuadInternal(projectionMatrix, textureId, opacity,
- GL_TEXTURE_2D, m_program,
- m_hProjectionMatrix, m_hTexSampler,
- m_hPosition, m_hAlpha);
- } else {
- drawLayerQuadInternal(projectionMatrix, textureId, opacity,
- GL_TEXTURE_2D, m_programInverted,
- m_hProjectionMatrixInverted, m_hTexSamplerInverted,
- m_hPositionInverted, m_hAlphaInverted,
- m_hContrastInverted);
- }
- } else if (textureTarget == GL_TEXTURE_EXTERNAL_OES
- && !TilesManager::instance()->invertedScreen()) {
- drawLayerQuadInternal(projectionMatrix, textureId, opacity,
- GL_TEXTURE_EXTERNAL_OES, m_surfTexOESProgram,
- m_hSTOESProjectionMatrix, m_hSTOESTexSampler,
- m_hSTOESPosition, m_hSTOESAlpha);
- } else if (textureTarget == GL_TEXTURE_EXTERNAL_OES
- && TilesManager::instance()->invertedScreen()) {
- drawLayerQuadInternal(projectionMatrix, textureId, opacity,
- GL_TEXTURE_EXTERNAL_OES, m_surfTexOESProgramInverted,
- m_hSTOESProjectionMatrixInverted, m_hSTOESTexSamplerInverted,
- m_hSTOESPositionInverted, m_hSTOESAlphaInverted,
- m_hSTOESContrastInverted);
+ bool enableBlending = forceBlending || opacity < 1.0;
+
+ ShaderType type = UndefinedShader;
+ if (!textureId) {
+ pureColor = shaderColor(pureColor, opacity);
+ if (pureColor.rgb() == Color::transparent && enableBlending)
+ return;
+ type = PureColor;
+ } else
+ type = getTextureShaderType(textureTarget);
+
+ if (type != UndefinedShader) {
+ setBlendingState(enableBlending);
+ drawQuadInternal(type, projectionMatrix, textureId, opacity,
+ textureTarget, GL_LINEAR, pureColor);
}
- setBlendingState(forceBlending || opacity < 1.0);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
GLUtils::checkGlError("drawLayerQuad");
}
@@ -617,7 +642,7 @@ void ShaderProgram::drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
int textureId)
{
// switch to our custom yuv video rendering program
- glUseProgram(m_videoProgram);
+ glUseProgram(m_handleArray[Video].programHandle);
TransformationMatrix modifiedDrawMatrix = drawMatrix;
modifiedDrawMatrix.translate(geometry.fLeft, geometry.fTop);
@@ -626,16 +651,19 @@ void ShaderProgram::drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
GLfloat projectionMatrix[16];
GLUtils::toGLMatrix(projectionMatrix, renderMatrix);
- glUniformMatrix4fv(m_hVideoProjectionMatrix, 1, GL_FALSE, projectionMatrix);
- glUniformMatrix4fv(m_hVideoTextureMatrix, 1, GL_FALSE, textureMatrix);
+ glUniformMatrix4fv(m_handleArray[Video].projMtxHandle, 1, GL_FALSE,
+ projectionMatrix);
+ glUniformMatrix4fv(m_handleArray[Video].videoMtxHandle, 1, GL_FALSE,
+ textureMatrix);
glActiveTexture(GL_TEXTURE0);
- glUniform1i(m_hVideoTexSampler, 0);
+ glUniform1i(m_handleArray[Video].texSamplerHandle, 0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, textureId);
+ GLint videoPosition = m_handleArray[Video].positionHandle;
glBindBuffer(GL_ARRAY_BUFFER, m_textureBuffer[0]);
- glEnableVertexAttribArray(m_hVideoPosition);
- glVertexAttribPointer(m_hVideoPosition, 2, GL_FLOAT, GL_FALSE, 0, 0);
+ glEnableVertexAttribArray(videoPosition);
+ glVertexAttribPointer(videoPosition, 2, GL_FLOAT, GL_FALSE, 0, 0);
setBlendingState(false);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.h b/Source/WebCore/platform/graphics/android/ShaderProgram.h
index 9ab7a46..3d7aab5 100644
--- a/Source/WebCore/platform/graphics/android/ShaderProgram.h
+++ b/Source/WebCore/platform/graphics/android/ShaderProgram.h
@@ -19,6 +19,7 @@
#if USE(ACCELERATED_COMPOSITING)
+#include "Color.h"
#include "FloatRect.h"
#include "IntRect.h"
#include "SkRect.h"
@@ -29,11 +30,60 @@
namespace WebCore {
+enum ShaderType {
+ UndefinedShader = -1,
+ PureColor,
+ Tex2D,
+ Tex2DInv,
+ TexOES,
+ TexOESInv,
+ Video,
+ // When growing this enum list, make sure to insert before the
+ // MaxShaderNumber and init the m_handleArray accordingly.
+ MaxShaderNumber
+};
+
+struct ShaderHandles {
+ ShaderHandles()
+ : alphaHandle(-1)
+ , contrastHandle(-1)
+ , positionHandle(-1)
+ , programHandle(-1)
+ , projMtxHandle(-1)
+ , pureColorHandle(-1)
+ , texSamplerHandle(-1)
+ , videoMtxHandle(-1)
+ {
+ }
+
+ void init(GLint alphaHdl, GLint contrastHdl, GLint posHdl, GLint pgmHdl,
+ GLint projMtxHdl, GLint colorHdl, GLint texSamplerHdl,
+ GLint videoMtxHdl)
+ {
+ alphaHandle = alphaHdl;
+ contrastHandle = contrastHdl;
+ positionHandle = posHdl;
+ programHandle = pgmHdl;
+ projMtxHandle = projMtxHdl;
+ pureColorHandle = colorHdl;
+ texSamplerHandle = texSamplerHdl;
+ videoMtxHandle = videoMtxHdl;
+ }
+
+ GLint alphaHandle;
+ GLint contrastHandle;
+ GLint positionHandle;
+ GLint programHandle;
+ GLint projMtxHandle;
+ GLint pureColorHandle;
+ GLint texSamplerHandle;
+ GLint videoMtxHandle;
+};
+
class ShaderProgram {
public:
ShaderProgram();
void init();
- int program() { return m_program; }
// Drawing
void setViewport(SkRect& viewport, float scale);
@@ -44,19 +94,16 @@ public:
// Normal texture in GL_TEXTURE_2D target.
// 2) textureTarget == GL_TEXTURE_EXTERNAL_OES
// Surface texture in GL_TEXTURE_EXTERNAL_OES target.
- // 3) textureTarget == 0 (Will be deprecated soon)
- // Surface texture in GL_TEXTURE_2D target.
- //
- // TODO: Shrink the support modes into 2 (1 and 2) after media framework
- // support Surface texture in GL_TEXTURE_EXTERNAL_OES target on all
- // platforms.
- void drawQuad(SkRect& geometry, int textureId, float opacity,
+ // 3) textureId == 0
+ // No texture needed, just a pureColor quad.
+ void drawQuad(SkRect& geometry, int textureId, float opacity, Color pureColor = Color(),
GLenum textureTarget = GL_TEXTURE_2D,
GLint texFilter = GL_LINEAR);
void drawLayerQuad(const TransformationMatrix& drawMatrix,
const SkRect& geometry, int textureId, float opacity,
bool forceBlending = false,
- GLenum textureTarget = GL_TEXTURE_2D);
+ GLenum textureTarget = GL_TEXTURE_2D,
+ Color pureColor = Color());
void drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
float* textureMatrix, SkRect& geometry, int textureId);
void setViewRect(const IntRect& viewRect);
@@ -100,33 +147,21 @@ public:
void calculateAnimationDelta();
int getAnimationDeltaX() { return m_animationDelta.x(); }
int getAnimationDeltaY() { return m_animationDelta.y(); }
+ bool needsInit() { return m_needsInit; }
private:
GLuint loadShader(GLenum shaderType, const char* pSource);
- GLuint createProgram(const char* vertexSource, const char* fragmentSource);
- void setProjectionMatrix(SkRect& geometry, GLint projectionMatrixHandle);
-
+ GLint createProgram(const char* vertexSource, const char* fragmentSource);
+ void setProjectionMatrix(const SkRect& geometry, GLfloat* mtxPtr);
void setBlendingState(bool enableBlending);
-
- void drawQuadInternal(SkRect& geometry, GLint textureId, float opacity,
- GLint program, GLint projectionMatrixHandle,
- GLint texSampler, GLenum textureTarget,
- GLint position, GLint alpha,
- GLint texFilter, GLint contrast = -1);
-
- void drawLayerQuadInternal(const GLfloat* projectionMatrix, int textureId,
- float opacity, GLenum textureTarget, GLint program,
- GLint matrix, GLint texSample,
- GLint position, GLint alpha, GLint contrast = -1);
+ void drawQuadInternal(ShaderType type, const GLfloat* matrix, int textureId,
+ float opacity, GLenum textureTarget, GLenum filter,
+ const Color& pureColor);
+ Color shaderColor(Color pureColor, float opacity);
+ ShaderType getTextureShaderType(GLenum textureTarget);
bool m_blendingEnabled;
- int m_program;
- int m_programInverted;
- int m_videoProgram;
- int m_surfTexOESProgram;
- int m_surfTexOESProgramInverted;
-
TransformationMatrix m_projectionMatrix;
GLuint m_textureBuffer[1];
@@ -141,37 +176,9 @@ private:
FloatRect m_documentViewport;
- // uniforms
- GLint m_hProjectionMatrix;
- GLint m_hAlpha;
- GLint m_hTexSampler;
- GLint m_hProjectionMatrixInverted;
- GLint m_hAlphaInverted;
- GLint m_hContrastInverted;
- GLint m_hTexSamplerInverted;
- GLint m_hVideoProjectionMatrix;
- GLint m_hVideoTextureMatrix;
- GLint m_hVideoTexSampler;
-
- GLint m_hSTOESProjectionMatrix;
- GLint m_hSTOESAlpha;
- GLint m_hSTOESTexSampler;
- GLint m_hSTOESPosition;
-
- GLint m_hSTOESProjectionMatrixInverted;
- GLint m_hSTOESAlphaInverted;
- GLint m_hSTOESContrastInverted;
- GLint m_hSTOESTexSamplerInverted;
- GLint m_hSTOESPositionInverted;
-
float m_contrast;
- // attribs
- GLint m_hPosition;
- GLint m_hPositionInverted;
- GLint m_hVideoPosition;
-
- bool m_alphaLayer;
+ bool m_alphaLayer;
TransformationMatrix m_webViewMatrix;
float m_currentScale;
@@ -184,8 +191,21 @@ private:
// TODO: Given that m_webViewMatrix contains most of the tranformation
// information, we should be able to get rid of some parameter we got from
// Java side and simplify our code.
- TransformationMatrix m_repositionMatrix;
+ TransformationMatrix m_repositionMatrix;
IntPoint m_animationDelta;
+
+ // Put all the uniform location (handle) info into an array, and group them
+ // by the shader's type, this can help to clean up the interface.
+ // TODO: use the type and data comparison to skip GL call if possible.
+ ShaderHandles m_handleArray[MaxShaderNumber];
+
+ // If there is any GL error happens such that the Shaders are not initialized
+ // successfully at the first time, then we need to init again when we draw.
+ bool m_needsInit;
+
+ // For transfer queue blitting, we need a special matrix map from (0,1) to
+ // (-1,1)
+ GLfloat m_transferProjMtx[16];
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/SharedTexture.cpp b/Source/WebCore/platform/graphics/android/SharedTexture.cpp
deleted file mode 100644
index 74cd2c6..0000000
--- a/Source/WebCore/platform/graphics/android/SharedTexture.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * 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 "SharedTexture.h"
-
-#include "GLUtils.h"
-#include <android/native_window.h>
-#include <gui/SurfaceTexture.h>
-#include <gui/SurfaceTextureClient.h>
-
-#define LOG_NDEBUG 1
-#define LOG_TAG "SharedTexture.cpp"
-#include <utils/Log.h>
-
-namespace WebCore {
-
-SharedTexture::SharedTexture(SharedTextureMode mode)
-{
- m_sharedTextureMode = mode;
-
- m_sourceTexture = new TextureInfo(m_sharedTextureMode);
- m_targetTexture = 0;
-
- if (m_sharedTextureMode == EglImageMode) {
- m_targetTexture = new TextureInfo(m_sharedTextureMode);
- m_eglImage = EGL_NO_IMAGE_KHR;
- m_isNewImage = true;
- m_syncObject = EGL_NO_SYNC_KHR;
-
- // Defer initialization of these values until we initialize the source
- // texture. This ensures that this initialization happens in the appropriate
- // thread.
- m_display = 0;
- m_supportsEGLImage = false;
- m_supportsEGLFenceSyncKHR = false;
- } else if (m_sharedTextureMode == SurfaceTextureMode) {
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- glGenTextures(1, &m_sourceTexture->m_textureId);
-
- m_sourceTexture->m_surfaceTexture =
- new android::SurfaceTexture(m_sourceTexture->m_textureId, false);
- m_sourceTexture->m_ANW =
- new android::SurfaceTextureClient(m_sourceTexture->m_surfaceTexture);
-#endif
- }
-}
-
-// called by the consumer when it no longer wants to consume and after it has
-// terminated all providers. If EGLImages are used, the deletion of the
-// source texture and EGLImage is the responsibility of the caller.
-SharedTexture::~SharedTexture()
-{
- if (m_sharedTextureMode == EglImageMode)
- deleteTargetTexture();
- else if (m_sharedTextureMode == SurfaceTextureMode) {
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- m_sourceTexture->m_surfaceTexture.clear();
- m_sourceTexture->m_ANW.clear();
- GLUtils::deleteTexture(&m_sourceTexture->m_textureId);
-#endif
- }
- delete m_sourceTexture;
- delete m_targetTexture;
-}
-
-
-void SharedTexture::initSourceTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
-
- m_display = eglGetCurrentDisplay();
- m_supportsEGLImage = GLUtils::isEGLImageSupported();
- m_supportsEGLFenceSyncKHR = GLUtils::isEGLFenceSyncSupported();
-
- // TODO temporarily disable fence sync until the EGL framework fixes
- // performance issues that result from consistently adding/removing fences.
- m_supportsEGLFenceSyncKHR = false;
-
- LOGI("imageEGL: %d syncKHR: %d", m_supportsEGLImage, m_supportsEGLFenceSyncKHR);
-
- glGenTextures(1, &m_sourceTexture->m_textureId);
-
-}
-
-// For MediaTexture only
-void SharedTexture::deleteSourceTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
- // We need to delete the source texture and EGLImage in the thread in which
- // it was created. In theory we should be able to delete the EGLImage
- // from either thread, but it currently throws an error if not deleted
- // in the same EGLContext from which it was created.
- if (m_supportsEGLImage) {
- GLUtils::deleteTexture(&m_sourceTexture->m_textureId);
- if (m_eglImage != EGL_NO_IMAGE_KHR) {
- eglDestroyImageKHR(eglGetCurrentDisplay(), m_eglImage);
- m_eglImage = EGL_NO_IMAGE_KHR;
- m_isNewImage = true;
- }
- LOGI("Deleted Source Texture and EGLImage");
- }
-}
-
-// For MediaTexture only
-void SharedTexture::deleteTargetTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
-
- if (m_supportsEGLImage)
- GLUtils::deleteTexture(&m_targetTexture->m_textureId);
- else
- GLUtils::deleteTexture(&m_sourceTexture->m_textureId);
-}
-
-TextureInfo* SharedTexture::lockSource()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return m_sourceTexture;
-
- m_lock.lock();
-
- if (m_supportsEGLFenceSyncKHR && m_syncObject != EGL_NO_SYNC_KHR) {
-
- EGLint status = eglClientWaitSyncKHR(m_display, m_syncObject, 0, 1000000);
-
- if (status == EGL_TIMEOUT_EXPIRED_KHR)
- LOGE("Sync timeout for shared texture (%d)", m_sourceTexture->m_textureId);
-
- eglDestroySyncKHR(m_display, m_syncObject);
- m_syncObject = EGL_NO_SYNC_KHR;
- }
- return m_sourceTexture;
-}
-
-void SharedTexture::releaseSource()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
-
- if (m_supportsEGLImage) {
- // delete the existing image if needed
- if (!m_sourceTexture->equalsAttributes(m_targetTexture)) {
- if (m_eglImage != EGL_NO_IMAGE_KHR) {
- eglDestroyImageKHR(m_display, m_eglImage);
- m_eglImage = EGL_NO_IMAGE_KHR;
- m_isNewImage = true;
- }
- m_targetTexture->copyAttributes(m_sourceTexture);
- }
-
- // create an image from the texture, only when the texture is valid
- if (m_eglImage == EGL_NO_IMAGE_KHR && m_sourceTexture->m_width
- && m_sourceTexture->m_height) {
- GLUtils::createEGLImageFromTexture(m_sourceTexture->m_textureId, &m_eglImage);
- LOGV("Generating Image (%d) 0x%x", m_sourceTexture->m_textureId, m_eglImage);
-
- glFinish(); // ensures the texture is ready to be used by the consumer
- }
-
- } else {
-
- m_targetTexture = m_sourceTexture;
-
- // in the case of shared contexts we must flush the texture edits to the
- // GPU. This ensures the edits complete prior to allowing the texture to
- // be bound on the producers context.
- glFlush();
- }
-
- m_lock.unlock();
-}
-
-TextureInfo* SharedTexture::lockTarget()
-{
- // Note that the source and targe are the same when using Surface Texture.
- if (m_sharedTextureMode == SurfaceTextureMode) {
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- m_sourceTexture->m_surfaceTexture->updateTexImage();
-#endif
- return m_sourceTexture;
- }
-
- m_lock.lock();
-
- if ((!m_supportsEGLImage && m_targetTexture->m_textureId == GL_NO_TEXTURE)
- || (m_supportsEGLImage && m_eglImage == EGL_NO_IMAGE_KHR)) {
- m_lock.unlock();
- return 0;
- }
-
- if (m_supportsEGLImage && (m_isNewImage || m_targetTexture->m_textureId == GL_NO_TEXTURE)) {
- if (m_targetTexture->m_textureId == GL_NO_TEXTURE)
- glGenTextures(1, &m_targetTexture->m_textureId);
-
- GLUtils::createTextureFromEGLImage(m_targetTexture->m_textureId, m_eglImage);
- LOGV("Generating Consumer Texture from 0x%x", m_eglImage);
- m_isNewImage = false;
- }
- return m_targetTexture;
-}
-
-void SharedTexture::releaseTarget()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
-
- if (m_supportsEGLFenceSyncKHR) {
- if (m_syncObject != EGL_NO_SYNC_KHR)
- eglDestroySyncKHR(m_display, m_syncObject);
- m_syncObject = eglCreateSyncKHR(m_display, EGL_SYNC_FENCE_KHR, 0);
- } else {
- // TODO the flush currently prevents the screen from getting partial
- // updates but the only way to guarantee this is to call glFinish. Until
- // we support an EGL sync we will leave flush enable in order to test
- // with modest performance.
- glFlush();
- }
-
- m_lock.unlock();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/SharedTexture.h b/Source/WebCore/platform/graphics/android/SharedTexture.h
deleted file mode 100644
index 305a442..0000000
--- a/Source/WebCore/platform/graphics/android/SharedTexture.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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 SharedTexture_h
-#define SharedTexture_h
-
-#include "TextureInfo.h"
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#include <utils/threads.h>
-
-namespace WebCore {
-
-/**
- * SharedTexture is a class that encapsulates all the necessary variables
- * needed to share a single texture across threads. In the case that threads
- * communicate using EGL's sharedContext mechanism or do not support the proper
- * EGLImage extensions the targetTexture, eglImage, and isNewImage variables are
- * not used.
- */
-class SharedTexture {
-public:
- // consumer thread functions
- SharedTexture(SharedTextureMode mode);
- ~SharedTexture();
-
- TextureInfo* lockSource();
- void releaseSource();
-
- TextureInfo* lockTarget();
- void releaseTarget();
-
- // these locks are only used for the methods below
- void lock() { m_lock.lock(); }
- void unlock() { m_lock.unlock(); }
-
- void initSourceTexture(); // producer thread only
- void deleteSourceTexture(); // producer thread only
- void deleteTargetTexture(); // consumer thread only
- GLuint getSourceTextureId() { return m_sourceTexture->m_textureId; }
- GLuint getTargetTextureId() { return m_targetTexture->m_textureId; }
- EGLImageKHR getEGLImage() { return m_eglImage; }
-
-private:
- /**
- * The mutex is used to ensure that the contents of the struct are current across
- * threads and that only one thread is manipulating the texture at a given time.
- */
- android::Mutex m_lock;
- /**
- * The texture and its associated metadata that is used by the producer. The
- * texture is created in the producer's thread and can only be read by the
- * consumer when the consumer shares the same context as the producer. The
- * metadata is used to track changes to the texture that would orphan the
- * target texture and require a new EGLImage to be constructed.
- */
- TextureInfo* m_sourceTexture;
- /**
- * The target texture stores the id and metadata of the texture that is to be
- * used by the consumer. In the case where EGLImages are supported this hold
- * the current eglImage target.
- */
- TextureInfo* m_targetTexture;
- /**
- * The EGLImage is used to share the texture between EGLContexts on two
- * different threads. This serves as an alternative to sharing the contexts
- * but is only used if GL and EGL support the required extensions.
- */
- EGLImageKHR m_eglImage;
- /**
- * This flag is used to determine if the eglImage has been updated. This
- * signals the consumer thread to rebind the targetTexture to the new image.
- */
- bool m_isNewImage;
- /**
- * The sync allows the consumer to release the lock prior to the commands
- * executing on the GPU. Prior to releasing the lock the consumer creates
- * a sync object and stores it here. After locking the texture the client
- * must check that the sync has completed prior to manipulating the texture.
- * This value is only used if the proper EGL extensions are supported.
- */
- EGLSyncKHR m_syncObject;
-
- EGLDisplay m_display;
-
- bool m_supportsEGLImage;
- bool m_supportsEGLFenceSyncKHR;
-
- SharedTextureMode m_sharedTextureMode;
-};
-
-} // namespace WebCore
-
-#endif // SharedTexture_h
diff --git a/Source/WebCore/platform/graphics/android/TextureInfo.cpp b/Source/WebCore/platform/graphics/android/TextureInfo.cpp
index 5356dcb..3c4dde2 100644
--- a/Source/WebCore/platform/graphics/android/TextureInfo.cpp
+++ b/Source/WebCore/platform/graphics/android/TextureInfo.cpp
@@ -35,13 +35,12 @@
namespace WebCore {
-TextureInfo::TextureInfo(SharedTextureMode mode)
+TextureInfo::TextureInfo()
{
m_textureId = GL_NO_TEXTURE;
m_width = 0;
m_height = 0;
m_internalFormat = 0;
- m_sharedTextureMode = mode;
m_eglSurface = EGL_NO_SURFACE;
m_pictureCount = 0;
}
diff --git a/Source/WebCore/platform/graphics/android/TextureInfo.h b/Source/WebCore/platform/graphics/android/TextureInfo.h
index 1c48937..8549365 100644
--- a/Source/WebCore/platform/graphics/android/TextureInfo.h
+++ b/Source/WebCore/platform/graphics/android/TextureInfo.h
@@ -34,8 +34,6 @@
#include "BaseTile.h"
using android::sp;
-#define DEPRECATED_SURFACE_TEXTURE_MODE 0
-
namespace android {
class SurfaceTexture;
}
@@ -47,20 +45,14 @@ static const GLuint GL_NO_TEXTURE = 0;
* TextureInfo is a class that stores both the texture and metadata about the
* texture.
*/
-enum SharedTextureMode {
- EglImageMode,
- SurfaceTextureMode
-};
class TextureInfo {
public:
-
- TextureInfo(SharedTextureMode mode);
+ TextureInfo();
bool equalsAttributes(const TextureInfo* otherTexture);
void copyAttributes(const TextureInfo* sourceTexture);
- SharedTextureMode getSharedTextureMode() { return m_sharedTextureMode; }
bool operator==(const TextureInfo& otherTexture);
GLuint m_textureId;
@@ -68,18 +60,12 @@ public:
int32_t m_height;
GLenum m_internalFormat;
- // Surface Texture specific data
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- sp<android::SurfaceTexture> m_surfaceTexture;
-#endif
// TODO: Delete this after the Ganesh code path get fixed.
sp<ANativeWindow> m_ANW;
// The EGLSurface wraps the m_ANW to enable direct OpenGL rendering (e.g. Ganesh)
EGLSurface m_eglSurface;
int m_pictureCount;
-private:
- SharedTextureMode m_sharedTextureMode;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp
index 31a0593..136b5a7 100644
--- a/Source/WebCore/platform/graphics/android/TiledPage.cpp
+++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp
@@ -93,9 +93,13 @@ void TiledPage::updateBaseTileSize()
TiledPage::~TiledPage()
{
+ TilesManager* tilesManager = TilesManager::instance();
// In order to delete the page we must ensure that none of its BaseTiles are
// currently painting or scheduled to be painted by the TextureGenerator
- TilesManager::instance()->removeOperationsForPage(this);
+ tilesManager->removeOperationsForPage(this);
+ // Discard the transfer queue after the removal operation to make sure
+ // no tiles for this page will be left in the transfer queue.
+ tilesManager->transferQueue()->discardQueue();
delete[] m_baseTiles;
#ifdef DEBUG_COUNT
ClassTracker::instance()->decrement("TiledPage");
@@ -276,8 +280,8 @@ void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBound
nbTilesHeight += firstTileY;
firstTileY = 0;
}
- nbTilesWidth = std::min(nbTilesWidth, maxX - firstTileX);
- nbTilesHeight = std::min(nbTilesHeight, maxY - firstTileY);
+ nbTilesWidth = std::min(nbTilesWidth, maxX - firstTileX + 1);
+ nbTilesHeight = std::min(nbTilesHeight, maxY - firstTileY + 1);
// check against corrupted scale values giving bad height/width (use float to avoid overflow)
float numTiles = static_cast<float>(nbTilesHeight) * static_cast<float>(nbTilesWidth);
diff --git a/Source/WebCore/platform/graphics/android/TiledTexture.cpp b/Source/WebCore/platform/graphics/android/TiledTexture.cpp
index d538416..3696b4a 100644
--- a/Source/WebCore/platform/graphics/android/TiledTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/TiledTexture.cpp
@@ -99,13 +99,13 @@ void TiledTexture::swapTiles()
XLOG("TT %p swapping, swaps = %d", this, swaps);
}
-IntRect TiledTexture::computeTilesArea(IntRect& visibleArea, float scale)
+IntRect TiledTexture::computeTilesArea(IntRect& contentArea, float scale)
{
IntRect computedArea;
- IntRect area(visibleArea.x() * scale,
- visibleArea.y() * scale,
- ceilf(visibleArea.width() * scale),
- ceilf(visibleArea.height() * scale));
+ IntRect area(contentArea.x() * scale,
+ contentArea.y() * scale,
+ ceilf(contentArea.width() * scale),
+ ceilf(contentArea.height() * scale));
XLOG("TT %p prepare, scale %f, area %d x %d", this, scale, area.width(), area.height());
@@ -128,21 +128,21 @@ IntRect TiledTexture::computeTilesArea(IntRect& visibleArea, float scale)
}
void TiledTexture::prepare(GLWebViewState* state, float scale, bool repaint,
- bool startFastSwap, IntRect& visibleArea)
+ bool startFastSwap, IntRect& prepareArea)
{
if (!m_surface)
return;
// first, how many tiles do we need
- m_area = computeTilesArea(visibleArea, scale);
+ m_area = computeTilesArea(prepareArea, scale);
if (m_area.isEmpty())
return;
- XLOG("for TiledTexture %p, we prepare with scale %.2f, have a visible area of "
+ XLOG("for TiledTexture %p, we prepare with scale %.2f, have a prepare area of "
" %d, %d - %d x %d, corresponding to %d, %d x - %d x %d tiles",
this, scale,
- visibleArea.x(), visibleArea.y(),
- visibleArea.width(), visibleArea.height(),
+ prepareArea.x(), prepareArea.y(),
+ prepareArea.width(), prepareArea.height(),
m_area.x(), m_area.y(),
m_area.width(), m_area.height());
@@ -239,7 +239,7 @@ int TiledTexture::nbTextures(IntRect& area, float scale)
return numberTextures;
}
-bool TiledTexture::draw()
+bool TiledTexture::draw(IntRect& visibleArea)
{
if (!m_surface)
return true;
@@ -250,6 +250,7 @@ bool TiledTexture::draw()
TilesManager::instance()->getTilesTracker()->trackLayer();
#endif
+ m_area = computeTilesArea(visibleArea, m_scale);
if (m_area.width() == 0 || m_area.height() == 0)
return false;
@@ -358,12 +359,12 @@ DualTiledTexture::~DualTiledTexture()
}
void DualTiledTexture::prepare(GLWebViewState* state, float scale, bool repaint,
- bool startFastSwap, IntRect& visibleArea)
+ bool startFastSwap, IntRect& prepareArea)
{
// If we are zooming, we will use the previously used area, to prevent the
// frontTexture to try to allocate more tiles than what it has already
if (!m_zooming)
- m_preZoomVisibleArea = visibleArea;
+ m_preZoomPrepareArea = prepareArea;
if (m_futureScale != scale) {
m_futureScale = scale;
@@ -375,11 +376,11 @@ void DualTiledTexture::prepare(GLWebViewState* state, float scale, bool repaint,
this, scale, m_scale, m_futureScale, m_zooming);
if (m_scale > 0)
- m_frontTexture->prepare(state, m_scale, repaint, startFastSwap, m_preZoomVisibleArea);
+ m_frontTexture->prepare(state, m_scale, repaint, startFastSwap, m_preZoomPrepareArea);
// If we had a scheduled update
if (m_zooming && m_zoomUpdateTime < WTF::currentTime()) {
- m_backTexture->prepare(state, m_futureScale, repaint, startFastSwap, visibleArea);
+ m_backTexture->prepare(state, m_futureScale, repaint, startFastSwap, prepareArea);
if (m_backTexture->ready()) {
m_backTexture->swapTiles();
swap();
@@ -396,9 +397,9 @@ void DualTiledTexture::swap()
m_backTexture->discardTextures();
}
-bool DualTiledTexture::draw()
+bool DualTiledTexture::draw(IntRect& visibleArea)
{
- bool needsRepaint = m_frontTexture->draw();
+ bool needsRepaint = m_frontTexture->draw(visibleArea);
needsRepaint |= m_zooming;
needsRepaint |= (m_scale <= 0);
return needsRepaint;
diff --git a/Source/WebCore/platform/graphics/android/TiledTexture.h b/Source/WebCore/platform/graphics/android/TiledTexture.h
index 444ab14..971a99f 100644
--- a/Source/WebCore/platform/graphics/android/TiledTexture.h
+++ b/Source/WebCore/platform/graphics/android/TiledTexture.h
@@ -57,12 +57,12 @@ public:
virtual ~TiledTexture();
- IntRect computeTilesArea(IntRect& visibleArea, float scale);
+ IntRect computeTilesArea(IntRect& contentArea, float scale);
void prepare(GLWebViewState* state, float scale, bool repaint,
- bool startFastSwap, IntRect& visibleArea);
+ bool startFastSwap, IntRect& prepareArea);
void swapTiles();
- bool draw();
+ bool draw(IntRect& visibleArea);
void prepareTile(bool repaint, int x, int y);
void update(const SkRegion& dirtyArea, SkPicture* picture);
@@ -114,7 +114,7 @@ public:
bool startFastSwap, IntRect& area);
void swapTiles();
void swap();
- bool draw();
+ bool draw(IntRect& visibleArea);
void update(const SkRegion& dirtyArea, SkPicture* picture);
bool owns(BaseTileTexture* texture);
bool isReady()
@@ -142,7 +142,7 @@ private:
float m_futureScale;
double m_zoomUpdateTime;
bool m_zooming;
- IntRect m_preZoomVisibleArea;
+ IntRect m_preZoomPrepareArea;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp
index 62324d7..fbf7ae6 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp
@@ -155,7 +155,7 @@ void TilesManager::allocateTiles()
m_tilesTextures.size() * LAYER_TILE_WIDTH * LAYER_TILE_HEIGHT * 4 / 1024 / 1024);
}
-void TilesManager::deallocateTextures(bool allTextures)
+void TilesManager::discardTextures(bool allTextures, bool glTextures)
{
const unsigned int max = m_textures.size();
@@ -169,24 +169,32 @@ void TilesManager::deallocateTextures(bool allTextures)
sparedDrawCount = std::max(sparedDrawCount, owner->drawCount());
}
}
- deallocateTexturesVector(sparedDrawCount, m_textures);
- deallocateTexturesVector(sparedDrawCount, m_tilesTextures);
+ discardTexturesVector(sparedDrawCount, m_textures, glTextures);
+ discardTexturesVector(sparedDrawCount, m_tilesTextures, glTextures);
}
-void TilesManager::deallocateTexturesVector(unsigned long long sparedDrawCount,
- WTF::Vector<BaseTileTexture*>& textures)
+void TilesManager::discardTexturesVector(unsigned long long sparedDrawCount,
+ WTF::Vector<BaseTileTexture*>& textures,
+ bool deallocateGLTextures)
{
const unsigned int max = textures.size();
int dealloc = 0;
for (unsigned int i = 0; i < max; i++) {
TextureOwner* owner = textures[i]->owner();
if (!owner || owner->drawCount() < sparedDrawCount) {
- textures[i]->discardGLTexture();
+ if (deallocateGLTextures) {
+ // deallocate textures' gl memory
+ textures[i]->discardGLTexture();
+ } else if (owner) {
+ // simply detach textures from owner
+ static_cast<BaseTile*>(owner)->discardTextures();
+ }
dealloc++;
}
}
- XLOG("Deallocated %d gl textures (out of %d base tiles and %d layer tiles)",
- dealloc, max, maxLayer);
+ XLOG("Discarded %d %s textures (out of %d %s tiles)",
+ dealloc, (deallocateGLTextures ? "gl" : ""),
+ max, (textures == m_textures) ? "base" : "layer");
}
void TilesManager::gatherTexturesNumbers(int* nbTextures, int* nbAllocatedTextures,
@@ -221,9 +229,9 @@ void TilesManager::printTextures()
x = o->x();
y = o->y();
}
- XLOG("[%d] texture %x busy: %d owner: %x (%d, %d) page: %x scale: %.2f",
+ XLOG("[%d] texture %x owner: %x (%d, %d) page: %x scale: %.2f",
i, texture,
- texture->busy(), o, x, y, o ? o->page() : 0, o ? o->scale() : 0);
+ o, x, y, o ? o->page() : 0, o ? o->scale() : 0);
}
XLOG("------");
#endif // DEBUG
@@ -285,12 +293,6 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner)
for (unsigned int i = 0; i < max; i++) {
BaseTileTexture* texture = (*availableTexturePool)[i];
BaseTile* currentOwner = static_cast<BaseTile*>(texture->owner());
-
- if (texture->busy()) {
- // don't bother, since the acquire() will likely fail
- continue;
- }
-
if (!currentOwner) {
// unused texture! take it!
farthestTexture = texture;
@@ -390,7 +392,8 @@ void TilesManager::setMaxLayerTextureCount(int max)
double secondsSinceLayersUsed = WTF::currentTime() - m_lastTimeLayersUsed;
if (secondsSinceLayersUsed > LAYER_TEXTURES_DESTROY_TIMEOUT) {
unsigned long long sparedDrawCount = ~0; // by default, spare no textures
- deallocateTexturesVector(sparedDrawCount, m_tilesTextures);
+ bool deleteGLTextures = true;
+ discardTexturesVector(sparedDrawCount, m_tilesTextures, deleteGLTextures);
m_hasLayerTextures = false;
}
return;
@@ -476,13 +479,6 @@ void TilesManager::paintedSurfacesCleanup(GLWebViewState* state)
}
}
-void TilesManager::unregisterGLWebViewState(GLWebViewState* state)
-{
- // Discard the whole queue b/c we lost GL context already.
- // Note the real updateTexImage will still wait for the next draw.
- transferQueue()->discardQueue();
-}
-
TilesManager* TilesManager::instance()
{
if (!gInstance) {
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h
index 9782fbb..f798196 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.h
+++ b/Source/WebCore/platform/graphics/android/TilesManager.h
@@ -115,12 +115,11 @@ public:
static float layerTileWidth();
static float layerTileHeight();
void paintedSurfacesCleanup(GLWebViewState* state = 0);
- void unregisterGLWebViewState(GLWebViewState* state);
void allocateTiles();
- // Called when webview is hidden to discard graphics memory
- void deallocateTextures(bool allTextures);
+ // remove all tiles from textures (and optionally deallocate gl memory)
+ void discardTextures(bool allTextures, bool glTextures);
bool getShowVisualIndicator()
{
@@ -132,11 +131,6 @@ public:
m_showVisualIndicator = showVisualIndicator;
}
- SharedTextureMode getSharedTextureMode()
- {
- return SurfaceTextureMode;
- }
-
TilesProfiler* getProfiler()
{
return &m_profiler;
@@ -209,8 +203,9 @@ private:
m_generatorReadyCond.wait(m_generatorLock);
}
- void deallocateTexturesVector(unsigned long long sparedDrawCount,
- WTF::Vector<BaseTileTexture*>& textures);
+ void discardTexturesVector(unsigned long long sparedDrawCount,
+ WTF::Vector<BaseTileTexture*>& textures,
+ bool deallocateGLTextures);
Vector<BaseTileTexture*> m_textures;
Vector<BaseTileTexture*> m_availableTextures;
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/TransferQueue.cpp
index b20ec7a..5d47629 100644
--- a/Source/WebCore/platform/graphics/android/TransferQueue.cpp
+++ b/Source/WebCore/platform/graphics/android/TransferQueue.cpp
@@ -97,7 +97,11 @@ void TransferQueue::initSharedSurfaceTextures(int width, int height)
#endif
m_ANW = new android::SurfaceTextureClient(m_sharedSurfaceTexture);
m_sharedSurfaceTexture->setSynchronousMode(true);
- m_sharedSurfaceTexture->setBufferCount(ST_BUFFER_NUMBER+1);
+
+ int extraBuffersNeeded = 0;
+ m_ANW->query(m_ANW.get(), NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
+ &extraBuffersNeeded);
+ m_sharedSurfaceTexture->setBufferCount(ST_BUFFER_NUMBER + extraBuffersNeeded);
int result = native_window_set_buffers_geometry(m_ANW.get(),
width, height, HAL_PIXEL_FORMAT_RGBA_8888);
@@ -114,9 +118,9 @@ void TransferQueue::initSharedSurfaceTextures(int width, int height)
// When bliting, if the item from the transfer queue is mismatching b/t the
// BaseTile and the content, then the item is considered as obsolete, and
// the content is discarded.
-bool TransferQueue::checkObsolete(int index)
+bool TransferQueue::checkObsolete(const TileTransferData* data)
{
- BaseTile* baseTilePtr = m_transferQueue[index].savedBaseTilePtr;
+ BaseTile* baseTilePtr = data->savedBaseTilePtr;
if (!baseTilePtr) {
XLOG("Invalid savedBaseTilePtr , such that the tile is obsolete");
return true;
@@ -128,7 +132,7 @@ bool TransferQueue::checkObsolete(int index)
return true;
}
- const TextureTileInfo* tileInfo = &m_transferQueue[index].tileInfo;
+ const TextureTileInfo* tileInfo = &(data->tileInfo);
if (tileInfo->m_x != baseTilePtr->x()
|| tileInfo->m_y != baseTilePtr->y()
@@ -265,6 +269,8 @@ void TransferQueue::discardQueue()
if (m_transferQueue[i].status == pendingBlit)
m_transferQueue[i].status = pendingDiscard;
+ m_pureColorTileQueue.clear();
+
bool GLContextExisted = getHasGLContext();
// Unblock the Tex Gen thread first before Tile Page deletion.
// Otherwise, there will be a deadlock while removing operations.
@@ -275,6 +281,26 @@ void TransferQueue::discardQueue()
m_transferQueueItemCond.signal();
}
+void TransferQueue::updatePureColorTiles()
+{
+ for (unsigned int i = 0 ; i < m_pureColorTileQueue.size(); i++) {
+ TileTransferData* data = &m_pureColorTileQueue[i];
+ if (data->status == pendingBlit) {
+ BaseTileTexture* destTexture = 0;
+ bool obsoleteBaseTile = checkObsolete(data);
+ if (!obsoleteBaseTile) {
+ destTexture = data->savedBaseTilePtr->backTexture();
+ destTexture->setPureColor(data->pureColor);
+ destTexture->setOwnTextureTileInfoFromQueue(&data->tileInfo);
+ }
+ } else if (data->status == emptyItem || data->status == pendingDiscard) {
+ // The queue should be clear instead of setting to different status.
+ XLOG("Warning: Don't expect an emptyItem here.");
+ }
+ }
+ m_pureColorTileQueue.clear();
+}
+
// Call on UI thread to copy from the shared Surface Texture to the BaseTile's texture.
void TransferQueue::updateDirtyBaseTiles()
{
@@ -284,6 +310,9 @@ void TransferQueue::updateDirtyBaseTiles()
if (!getHasGLContext())
setHasGLContext(true);
+ // Check the pure color tile first, since it is simpler.
+ updatePureColorTiles();
+
// Start from the oldest item, we call the updateTexImage to retrive
// the texture and blit that into each BaseTile's texture.
const int nextItemIndex = getNextTransferQueueIndex();
@@ -291,7 +320,7 @@ void TransferQueue::updateDirtyBaseTiles()
bool usedFboForUpload = false;
for (int k = 0; k < ST_BUFFER_NUMBER ; k++) {
if (m_transferQueue[index].status == pendingBlit) {
- bool obsoleteBaseTile = checkObsolete(index);
+ bool obsoleteBaseTile = checkObsolete(&m_transferQueue[index]);
// Save the needed info, update the Surf Tex, clean up the item in
// the queue. Then either move on to next item or copy the content.
BaseTileTexture* destTexture = 0;
@@ -333,6 +362,7 @@ void TransferQueue::updateDirtyBaseTiles()
// will find the latest texture's info
// We don't need a map any more, each texture contains its own
// texturesTileInfo.
+ destTexture->setPure(false);
destTexture->setOwnTextureTileInfoFromQueue(&m_transferQueue[index].tileInfo);
XLOG("Blit tile x, y %d %d with dest texture %p to destTexture->m_ownTextureId %d",
@@ -429,6 +459,39 @@ bool TransferQueue::tryUpdateQueueWithBitmap(const TileRenderInfo* renderInfo,
return true;
}
+void TransferQueue::addItemInPureColorQueue(const TileRenderInfo* renderInfo, Color color)
+{
+ // The pure color tiles' queue will be read from UI thread and written in
+ // Tex Gen thread, thus we need to have a lock here.
+ android::Mutex::Autolock lock(m_transferQueueItemLocks);
+ TileTransferData data;
+ addItemCommon(renderInfo, GpuUpload, &data);
+ data.pureColor = color;
+ m_pureColorTileQueue.append(data);
+}
+
+// Translates the info from TileRenderInfo and others to TileTransferData.
+// This is used by pure color tiles and normal tiles.
+void TransferQueue::addItemCommon(const TileRenderInfo* renderInfo,
+ TextureUploadType type,
+ TileTransferData* data)
+{
+ data->savedBaseTileTexturePtr = renderInfo->baseTile->backTexture();
+ data->savedBaseTilePtr = renderInfo->baseTile;
+ data->status = pendingBlit;
+ data->uploadType = type;
+
+ // Now fill the tileInfo.
+ TextureTileInfo* textureInfo = &(data->tileInfo);
+
+ textureInfo->m_x = renderInfo->x;
+ textureInfo->m_y = renderInfo->y;
+ textureInfo->m_scale = renderInfo->scale;
+ textureInfo->m_painter = renderInfo->tilePainter;
+
+ textureInfo->m_picture = renderInfo->textureInfo->m_pictureCount;
+}
+
// Note that there should be lock/unlock around this function call.
// Currently only called by GLUtils::updateSharedSurfaceTextureWithBitmap.
void TransferQueue::addItemInTransferQueue(const TileRenderInfo* renderInfo,
@@ -443,10 +506,8 @@ void TransferQueue::addItemInTransferQueue(const TileRenderInfo* renderInfo,
XLOG("ERROR update a tile which is dirty already @ index %d", index);
}
- m_transferQueue[index].savedBaseTileTexturePtr = renderInfo->baseTile->backTexture();
- m_transferQueue[index].savedBaseTilePtr = renderInfo->baseTile;
- m_transferQueue[index].status = pendingBlit;
- m_transferQueue[index].uploadType = type;
+ TileTransferData* data = &m_transferQueue[index];
+ addItemCommon(renderInfo, type, data);
if (type == CpuUpload && bitmap) {
// Lazily create the bitmap
if (!m_transferQueue[index].bitmap) {
@@ -458,16 +519,6 @@ void TransferQueue::addItemInTransferQueue(const TileRenderInfo* renderInfo,
bitmap->copyTo(m_transferQueue[index].bitmap, bitmap->config());
}
- // Now fill the tileInfo.
- TextureTileInfo* textureInfo = &m_transferQueue[index].tileInfo;
-
- textureInfo->m_x = renderInfo->x;
- textureInfo->m_y = renderInfo->y;
- textureInfo->m_scale = renderInfo->scale;
- textureInfo->m_painter = renderInfo->tilePainter;
-
- textureInfo->m_picture = renderInfo->textureInfo->m_pictureCount;
-
m_emptyItemCount--;
}
@@ -524,7 +575,7 @@ void TransferQueue::saveGLState()
glGetIntegerv(GL_VIEWPORT, m_GLStateBeforeBlit.viewport);
glGetBooleanv(GL_SCISSOR_TEST, m_GLStateBeforeBlit.scissor);
glGetBooleanv(GL_DEPTH_TEST, m_GLStateBeforeBlit.depth);
-#if DEBUG
+#ifdef DEBUG
glGetFloatv(GL_COLOR_CLEAR_VALUE, m_GLStateBeforeBlit.clearColor);
#endif
}
@@ -536,7 +587,7 @@ void TransferQueue::setGLStateForCopy(int width, int height)
glDisable(GL_SCISSOR_TEST);
glDisable(GL_DEPTH_TEST);
// Clear the content is only for debug purpose.
-#if DEBUG
+#ifdef DEBUG
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
#endif
@@ -554,7 +605,7 @@ void TransferQueue::restoreGLState()
if (m_GLStateBeforeBlit.depth[0])
glEnable(GL_DEPTH_TEST);
-#if DEBUG
+#ifdef DEBUG
glClearColor(m_GLStateBeforeBlit.clearColor[0],
m_GLStateBeforeBlit.clearColor[1],
m_GLStateBeforeBlit.clearColor[2],
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.h b/Source/WebCore/platform/graphics/android/TransferQueue.h
index 63455de..629935f 100644
--- a/Source/WebCore/platform/graphics/android/TransferQueue.h
+++ b/Source/WebCore/platform/graphics/android/TransferQueue.h
@@ -32,6 +32,7 @@
#include "BaseTileTexture.h"
#include "ShaderProgram.h"
#include "TiledPage.h"
+#include <EGL/eglext.h>
namespace WebCore {
@@ -92,6 +93,9 @@ public:
// lazily allocated.
SkBitmap* bitmap;
+ // Specific data to the pure color tiles' queue.
+ Color pureColor;
+
// Sync object for GPU fence, this is the only the info passed from UI
// thread to Tex Gen thread. The reason of having this is due to the
// missing sync mechanism on Surface Texture on some vendor. b/5122031.
@@ -132,6 +136,8 @@ public:
void lockQueue() { m_transferQueueItemLocks.lock(); }
void unlockQueue() { m_transferQueueItemLocks.unlock(); }
+ void addItemInPureColorQueue(const TileRenderInfo* renderInfo, Color color);
+
// This queue can be accessed from UI and TexGen thread, therefore, we need
// a lock to protect its access
TileTransferData* m_transferQueue;
@@ -156,7 +162,7 @@ private:
void restoreGLState();
// Check the current transfer queue item is obsolete or not.
- bool checkObsolete(int index);
+ bool checkObsolete(const TileTransferData* data);
// Before each draw call and the blit operation, clean up all the
// pendingDiscard items.
@@ -166,6 +172,10 @@ private:
GLuint srcTexId, GLenum srcTexTarget,
int index);
+ void addItemCommon(const TileRenderInfo* renderInfo,
+ TextureUploadType type, TileTransferData* data);
+
+ void updatePureColorTiles();
// Note that the m_transferQueueIndex only changed in the TexGen thread
// where we are going to move on to update the next item in the queue.
int m_transferQueueIndex;
@@ -201,6 +211,11 @@ private:
// This should be GpuUpload for production, but for debug purpose or working
// around driver/HW issue, we can set it to CpuUpload.
TextureUploadType m_currentUploadType;
+
+ // The non-pure-color tile are 1 to 1 mapping with Surface Texture which is
+ // resource limited. To get better performance, it is better to separate
+ // the pure color tile into another queue.
+ WTF::Vector<TileTransferData> m_pureColorTileQueue;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/TreeManager.cpp b/Source/WebCore/platform/graphics/android/TreeManager.cpp
index b7eaacf..35ddeb8 100644
--- a/Source/WebCore/platform/graphics/android/TreeManager.cpp
+++ b/Source/WebCore/platform/graphics/android/TreeManager.cpp
@@ -245,6 +245,10 @@ bool TreeManager::drawGL(double currentTime, IntRect& viewRect,
if (m_drawingTree) {
bool drawingReady = didTreeSwap || m_drawingTree->isReady();
+ // call the page swap callback if registration happened without more trees enqueued
+ if (treesSwappedPtr && drawingReady && !m_paintingTree)
+ *treesSwappedPtr = true;
+
if (didTreeSwap || m_fastSwapMode || (drawingReady && !m_paintingTree))
m_drawingTree->swapTiles();
diff --git a/Source/WebCore/platform/graphics/android/VerticalTextMap.cpp b/Source/WebCore/platform/graphics/android/VerticalTextMap.cpp
index 6e715e2..47c0613 100644
--- a/Source/WebCore/platform/graphics/android/VerticalTextMap.cpp
+++ b/Source/WebCore/platform/graphics/android/VerticalTextMap.cpp
@@ -34,27 +34,30 @@
static const UChar vTextCnvTable[][2] = {
// TODO: uncomment mappings once we add glyphs for vertical forms.
- // {0x0021, 0xfe15}, // exclamation mark
+ {0x0021, 0xfe15}, // exclamation mark
{0x0028, 0xfe35}, // left paren
{0x0029, 0xfe36}, // right paren
- // {0x002c, 0xfe10}, // comma
+ {0x002c, 0xfe10}, // comma
+ {0x002d, 0xfe32}, // hyphen
{0x003a, 0xfe30}, // colon
- {0x003b, 0x007c}, // hyphen
- // {0x003f, 0xfe16}, // question mark
- // {0x005b, 0xfe14}, // semicolon
- {0x005d, 0xfe47}, // left square bracket
- {0x005f, 0xfe48}, // right square bracket
+ {0x003b, 0xfe14}, // semicolon
+ {0x003f, 0xfe16}, // question mark
+ {0x005b, 0xfe47}, // left square bracket
+ {0x005d, 0xfe48}, // right square bracket
{0x007b, 0xfe37}, // left curly bracket
{0x007d, 0xfe38}, // right curly bracket
{0x007e, 0x007c}, // tilde to vertical line
+ {0x00ab, 0xfe3d}, // left pointing double angle quotation mark
+ {0x00bb, 0xfe3e}, // right pointing double angle quotation mark
+ {0x2010, 0xfe32}, // hyphen
{0x2013, 0xfe32}, // en dash
{0x2014, 0xfe31}, // em dash
{0x2015, 0xfe31}, // horizontal bar
{0x2025, 0xfe30}, // two dot leader
- // TODO: change the mapping 0x2026 -> 0xFE19 once Android has the glyph for 0xFE19.
- {0x2026, 0xfe30}, // three dot leader
- // {0x3001, 0xfe11}, // Ideographic comma
- // {0x3002, 0xfe12}, // Ideographic full stop
+ {0x2026, 0xfe19}, // three dot leader
+ // TODO: change the mapping 0x3001 -> 0xFE11 once Android has the glyph for 0xFE11.
+ {0x3001, 0xfe10}, // Ideographic comma
+ {0x3002, 0xfe12}, // Ideographic full stop
{0x3008, 0xfe3f}, // left angle bracket
{0x3009, 0xfe40}, // right angle bracket
{0x300a, 0xfe3d}, // left double angle bracket
@@ -67,19 +70,22 @@ static const UChar vTextCnvTable[][2] = {
{0x3011, 0xfe3c}, // right black lenticular bracket
{0x3014, 0xfe39}, // left black lenticular bracket
{0x3015, 0xfe3a}, // right tortise shell bracket
- // {0x3016, 0xfe17}, // left white lenticular bracket
- // {0x3017, 0xfe18}, // right white lenticular bracket
- // {0x3019, 0xfe19}, // horizontal ellipses
+ {0x3016, 0xfe17}, // left white lenticular bracket
+ {0x3017, 0xfe18}, // right white lenticular bracket
{0x30fc, 0x3021}, // prolonged sound
{0xfe4f, 0xfe34}, // wavy low line
{0xff08, 0xfe35}, // full width left paren
{0xff09, 0xfe36}, // full width right paren
+ {0xff0c, 0xfe10}, // full width comma
{0xff3b, 0xfe47}, // full width left square bracket
{0xff3d, 0xfe48}, // full width right square bracket
{0xff5b, 0xfe37}, // full width left curly bracket
+ {0xff5c, 0xfe31}, // fullwidth vertical line
{0xff5d, 0xfe38}, // full width right curly bracket
- // {0xff64, 0xfe11}, // halfwidth ideo comma
- // {0xff61, 0xfe12}, // halfwidth ideo full stop
+ {0xff5e, 0x007c}, // tilde to vertical line
+ // TODO: change the mapping 0xff64 -> 0xFE11 once Android has the glyph for 0xFE11.
+ {0xff64, 0xfe10}, // halfwidth ideo comma
+ {0xff61, 0xfe12}, // halfwidth ideo full stop
};
namespace WebCore {
diff --git a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp
index 482d711..58f47d0 100644
--- a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp
@@ -53,6 +53,8 @@ GLuint VideoLayerAndroid::m_spinnerOuterTextureId = 0;
GLuint VideoLayerAndroid::m_spinnerInnerTextureId = 0;
GLuint VideoLayerAndroid::m_posterTextureId = 0;
GLuint VideoLayerAndroid::m_backgroundTextureId = 0;
+GLuint VideoLayerAndroid::m_playTextureId = 0;
+GLuint VideoLayerAndroid::m_pauseTextureId = 0;
bool VideoLayerAndroid::m_createdTexture = false;
double VideoLayerAndroid::m_rotateDegree = 0;
@@ -102,6 +104,16 @@ GLuint VideoLayerAndroid::createPosterTexture()
return createTextureFromImage(RenderSkinMediaButton::VIDEO);
}
+GLuint VideoLayerAndroid::createPlayTexture()
+{
+ return createTextureFromImage(RenderSkinMediaButton::PLAY);
+}
+
+GLuint VideoLayerAndroid::createPauseTexture()
+{
+ return createTextureFromImage(RenderSkinMediaButton::PAUSE);
+}
+
GLuint VideoLayerAndroid::createTextureFromImage(int buttonType)
{
SkRect rect = SkRect(buttonRect);
@@ -112,7 +124,8 @@ GLuint VideoLayerAndroid::createTextureFromImage(int buttonType)
SkCanvas canvas(bitmap);
canvas.drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode);
- RenderSkinMediaButton::Draw(&canvas, buttonRect, buttonType, true);
+ RenderSkinMediaButton::Draw(&canvas, buttonRect, buttonType, true, 0,
+ false);
GLuint texture;
glGenTextures(1, &texture);
@@ -142,6 +155,31 @@ GLuint VideoLayerAndroid::createBackgroundTexture()
return texture;
}
+void VideoLayerAndroid::showPreparingAnimation(const SkRect& rect,
+ const SkRect innerRect)
+{
+ ShaderProgram* shader = TilesManager::instance()->shader();
+ shader->drawLayerQuad(m_drawTransform, rect, m_backgroundTextureId, 1, true);
+
+ TransformationMatrix addReverseRotation;
+ TransformationMatrix addRotation = m_drawTransform;
+ addRotation.translate(innerRect.fLeft, innerRect.fTop);
+ addRotation.translate(IMAGESIZE / 2, IMAGESIZE / 2);
+ addReverseRotation = addRotation;
+ addRotation.rotate(m_rotateDegree);
+ addRotation.translate(-IMAGESIZE / 2, -IMAGESIZE / 2);
+
+ SkRect size = SkRect::MakeWH(innerRect.width(), innerRect.height());
+ shader->drawLayerQuad(addRotation, size, m_spinnerOuterTextureId, 1, true);
+
+ addReverseRotation.rotate(-m_rotateDegree);
+ addReverseRotation.translate(-IMAGESIZE / 2, -IMAGESIZE / 2);
+
+ shader->drawLayerQuad(addReverseRotation, size, m_spinnerInnerTextureId, 1, true);
+
+ m_rotateDegree += ROTATESTEP;
+}
+
bool VideoLayerAndroid::drawGL()
{
// Lazily allocated the textures.
@@ -150,6 +188,8 @@ bool VideoLayerAndroid::drawGL()
m_spinnerOuterTextureId = createSpinnerOuterTexture();
m_spinnerInnerTextureId = createSpinnerInnerTexture();
m_posterTextureId = createPosterTexture();
+ m_playTextureId = createPlayTexture();
+ m_pauseTextureId = createPauseTexture();
m_createdTexture = true;
}
@@ -162,69 +202,64 @@ bool VideoLayerAndroid::drawGL()
innerRect.offset((rect.width() - IMAGESIZE) / 2 , (rect.height() - IMAGESIZE) / 2);
+ ShaderProgram* shader = TilesManager::instance()->shader();
+ VideoLayerManager* manager = TilesManager::instance()->videoLayerManager();
+
+ // When we are drawing the animation of the play/pause button in the
+ // middle of the video, we need to ask for redraw.
+ bool needRedraw = false;
+
// Draw the poster image, the progressing image or the Video depending
// on the player's state.
if (m_playerState == PREPARING) {
// Show the progressing animation, with two rotating circles
- TilesManager::instance()->shader()->drawLayerQuad(m_drawTransform, rect,
- m_backgroundTextureId,
- 1, true);
-
- TransformationMatrix addReverseRotation;
- TransformationMatrix addRotation = m_drawTransform;
- addRotation.translate(innerRect.fLeft, innerRect.fTop);
- addRotation.translate(IMAGESIZE / 2, IMAGESIZE / 2);
- addReverseRotation = addRotation;
- addRotation.rotate(m_rotateDegree);
- addRotation.translate(-IMAGESIZE / 2, -IMAGESIZE / 2);
-
- SkRect size = SkRect::MakeWH(innerRect.width(), innerRect.height());
- TilesManager::instance()->shader()->drawLayerQuad(addRotation, size,
- m_spinnerOuterTextureId,
- 1, true);
-
- addReverseRotation.rotate(-m_rotateDegree);
- addReverseRotation.translate(-IMAGESIZE / 2, -IMAGESIZE / 2);
-
- TilesManager::instance()->shader()->drawLayerQuad(addReverseRotation, size,
- m_spinnerInnerTextureId,
- 1, true);
-
- m_rotateDegree += ROTATESTEP;
-
+ showPreparingAnimation(rect, innerRect);
+ needRedraw = true;
} else if (m_playerState == PLAYING && m_surfaceTexture.get()) {
// Show the real video.
m_surfaceTexture->updateTexImage();
m_surfaceTexture->getTransformMatrix(surfaceMatrix);
- GLuint textureId =
- TilesManager::instance()->videoLayerManager()->getTextureId(uniqueId());
- TilesManager::instance()->shader()->drawVideoLayerQuad(m_drawTransform,
- surfaceMatrix,
- rect, textureId);
- TilesManager::instance()->videoLayerManager()->updateMatrix(uniqueId(),
- surfaceMatrix);
+ GLuint textureId = manager->getTextureId(uniqueId());
+ shader->drawVideoLayerQuad(m_drawTransform, surfaceMatrix,
+ rect, textureId);
+ manager->updateMatrix(uniqueId(), surfaceMatrix);
+
+ // Use the scale to control the fading the sizing during animation
+ double scale = manager->drawIcon(uniqueId(), PlayIcon);
+ if (scale != 0) {
+ innerRect.inset(IMAGESIZE / 4 * scale, IMAGESIZE / 4 * scale);
+ shader->drawLayerQuad(m_drawTransform, innerRect,
+ m_playTextureId, scale, true);
+ needRedraw = true;
+ }
+
} else {
- GLuint textureId =
- TilesManager::instance()->videoLayerManager()->getTextureId(uniqueId());
- GLfloat* matrix =
- TilesManager::instance()->videoLayerManager()->getMatrix(uniqueId());
+ GLuint textureId = manager->getTextureId(uniqueId());
+ GLfloat* matrix = manager->getMatrix(uniqueId());
if (textureId && matrix) {
// Show the screen shot for each video.
- TilesManager::instance()->shader()->drawVideoLayerQuad(m_drawTransform,
- matrix,
- rect, textureId);
+ shader->drawVideoLayerQuad(m_drawTransform, matrix,
+ rect, textureId);
} else {
// Show the static poster b/c there is no screen shot available.
- TilesManager::instance()->shader()->drawLayerQuad(m_drawTransform, rect,
- m_backgroundTextureId,
- 1, true);
- TilesManager::instance()->shader()->drawLayerQuad(m_drawTransform, innerRect,
- m_posterTextureId,
- 1, true);
+ shader->drawLayerQuad(m_drawTransform, rect, m_backgroundTextureId,
+ 1, true);
+ shader->drawLayerQuad(m_drawTransform, innerRect, m_posterTextureId,
+ 1, true);
}
- }
- return drawChildrenGL();
+ // Use the scale to control the fading and the sizing during animation.
+ double scale = manager->drawIcon(uniqueId(), PauseIcon);
+ if (scale != 0) {
+ innerRect.inset(IMAGESIZE / 4 * scale, IMAGESIZE / 4 * scale);
+ shader->drawLayerQuad(m_drawTransform, innerRect,
+ m_pauseTextureId, scale, true);
+ needRedraw = true;
+ }
+
+ }
+ // Don't short circuit here since we still want to draw the children.
+ return drawChildrenGL() || needRedraw;
}
}
diff --git a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h
index 8a064bb..cdb37f3 100644
--- a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h
@@ -30,6 +30,7 @@
#include "GLUtils.h"
#include "LayerAndroid.h"
+#include "ShaderProgram.h"
#include <jni.h>
namespace android {
@@ -62,10 +63,14 @@ public:
GLuint createSpinnerOuterTexture();
GLuint createSpinnerInnerTexture();
GLuint createPosterTexture();
+ GLuint createPlayTexture();
+ GLuint createPauseTexture();
private:
GLuint createTextureFromImage(int buttonType);
void init();
+ void showPreparingAnimation(const SkRect& rect,
+ const SkRect innerRect);
// Surface texture for showing the video is actually allocated in Java side
// and passed into this native code.
sp<android::SurfaceTexture> m_surfaceTexture;
@@ -78,6 +83,8 @@ private:
static GLuint m_posterTextureId;
static GLuint m_spinnerOuterTextureId;
static GLuint m_spinnerInnerTextureId;
+ static GLuint m_playTextureId;
+ static GLuint m_pauseTextureId;
static double m_rotateDegree;
diff --git a/Source/WebCore/platform/graphics/android/VideoLayerManager.cpp b/Source/WebCore/platform/graphics/android/VideoLayerManager.cpp
index cec4d67..d0fc873 100644
--- a/Source/WebCore/platform/graphics/android/VideoLayerManager.cpp
+++ b/Source/WebCore/platform/graphics/android/VideoLayerManager.cpp
@@ -25,6 +25,7 @@
#include "config.h"
#include "VideoLayerManager.h"
+#include <wtf/CurrentTime.h>
#if USE(ACCELERATED_COMPOSITING)
@@ -42,6 +43,10 @@
#endif // DEBUG
+// The animation of the play/pause icon will last for PLAY_PAUSE_ICON_SHOW_TIME
+// seconds.
+#define PLAY_PAUSE_ICON_SHOW_TIME 1
+
// Define the max sum of all the video's sizes.
// Note that video_size = width * height. If there is no compression, then the
// maximum memory consumption could be 4 * video_size.
@@ -105,6 +110,8 @@ void VideoLayerManager::registerTexture(const int layerId, const GLuint textureI
pInfo->videoSize = 0;
m_currentTimeStamp++;
pInfo->timeStamp = m_currentTimeStamp;
+ pInfo->lastIconShownTime = 0;
+ pInfo->iconState = Registered;
m_videoLayerInfoMap.add(layerId, pInfo);
XLOG("GL texture %d regisered for layerId %d", textureId, layerId);
@@ -238,5 +245,34 @@ void VideoLayerManager::removeLayerInternal(const int layerId)
return;
}
+double VideoLayerManager::drawIcon(const int layerId, IconType type)
+{
+ // When ratio 0 is returned, the Icon should not be drawn.
+ double ratio = 0;
+
+ android::Mutex::Autolock lock(m_videoLayerInfoMapLock);
+ if (m_videoLayerInfoMap.contains(layerId)) {
+ VideoLayerInfo* pInfo = m_videoLayerInfoMap.get(layerId);
+ // If this is state switching moment, reset the time and state
+ if ((type == PlayIcon && pInfo->iconState != PlayIconShown)
+ ||(type == PauseIcon && pInfo->iconState != PauseIconShown)) {
+ pInfo->lastIconShownTime = WTF::currentTime();
+ pInfo->iconState = (type == PlayIcon) ? PlayIconShown : PauseIconShown;
+ }
+
+ // After switching the state, we calculate the ratio depending on the
+ // time interval.
+ if ((type == PlayIcon && pInfo->iconState == PlayIconShown)
+ || (type == PauseIcon && pInfo->iconState == PauseIconShown)) {
+ double delta = WTF::currentTime() - pInfo->lastIconShownTime;
+ ratio = 1.0 - (delta / PLAY_PAUSE_ICON_SHOW_TIME);
+ }
+ }
+
+ if (ratio > 1 || ratio < 0 )
+ ratio = 0;
+ return ratio;
+}
+
}
#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/android/VideoLayerManager.h b/Source/WebCore/platform/graphics/android/VideoLayerManager.h
index de2dafc..a427269 100644
--- a/Source/WebCore/platform/graphics/android/VideoLayerManager.h
+++ b/Source/WebCore/platform/graphics/android/VideoLayerManager.h
@@ -34,6 +34,17 @@
namespace WebCore {
+enum IconState {
+ Registered,
+ PlayIconShown,
+ PauseIconShown
+};
+
+enum IconType {
+ PlayIcon,
+ PauseIcon
+};
+
// Every video layer can use its uniqueId to query VideoLayerManager about such
// info globally.
struct VideoLayerInfo {
@@ -41,6 +52,9 @@ struct VideoLayerInfo {
int videoSize; // The size of the video.
int timeStamp; // Used to decide which VideoLayerInfo is the oldest one.
GLfloat surfaceMatrix[16];
+
+ double lastIconShownTime;
+ IconState iconState;
};
@@ -68,6 +82,7 @@ public:
// Delete the GL textures
void deleteUnusedTextures();
+ double drawIcon(const int layerId, IconType type);
private:
// Get the sum of all the video size stored in m_videoLayerInfoMap.
int getTotalMemUsage();
diff --git a/Source/WebCore/rendering/InlineTextBox.cpp b/Source/WebCore/rendering/InlineTextBox.cpp
index 5815b8b..e8a9c7f 100644
--- a/Source/WebCore/rendering/InlineTextBox.cpp
+++ b/Source/WebCore/rendering/InlineTextBox.cpp
@@ -43,6 +43,7 @@
#include "Text.h"
#include "break_lines.h"
#include <wtf/AlwaysInline.h>
+#include <wtf/text/CString.h>
using namespace std;
diff --git a/Source/WebCore/rendering/RenderArena.cpp b/Source/WebCore/rendering/RenderArena.cpp
index 57ed978..e15101f 100644
--- a/Source/WebCore/rendering/RenderArena.cpp
+++ b/Source/WebCore/rendering/RenderArena.cpp
@@ -136,11 +136,4 @@ void RenderArena::free(size_t size, void* ptr)
#endif
}
-#ifdef ANDROID_INSTRUMENT
-size_t RenderArena::reportPoolSize() const
-{
- return ReportPoolSize(&m_pool);
-}
-#endif
-
} // namespace WebCore
diff --git a/Source/WebCore/rendering/RenderArena.h b/Source/WebCore/rendering/RenderArena.h
index 5d2559a..e1ff535 100644
--- a/Source/WebCore/rendering/RenderArena.h
+++ b/Source/WebCore/rendering/RenderArena.h
@@ -53,10 +53,6 @@ public:
void* allocate(size_t);
void free(size_t, void*);
-#ifdef ANDROID_INSTRUMENT
- size_t reportPoolSize() const;
-#endif
-
private:
// Underlying arena pool
ArenaPool m_pool;
diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp
index cdc4c05..0932224 100644
--- a/Source/WebCore/rendering/RenderLayer.cpp
+++ b/Source/WebCore/rendering/RenderLayer.cpp
@@ -64,6 +64,7 @@
#include "HTMLNames.h"
#if ENABLE(ANDROID_OVERFLOW_SCROLL)
#include "HTMLTextAreaElement.h"
+#include "GraphicsLayerAndroid.h"
#endif
#include "HitTestRequest.h"
#include "HitTestResult.h"
@@ -1424,6 +1425,8 @@ void RenderLayer::scrollTo(int x, int y)
// do not need to repaint simply because we are scrolling
if (view && !hasOverflowScroll())
renderer()->repaintUsingContainer(repaintContainer, rectForRepaint);
+ if (view && hasOverflowScroll() && backing() && backing()->graphicsLayer())
+ static_cast<GraphicsLayerAndroid*>(backing()->graphicsLayer())->updateScrollOffset();
#else
if (view)
renderer()->repaintUsingContainer(repaintContainer, rectForRepaint);
diff --git a/Source/WebCore/storage/AbstractDatabase.h b/Source/WebCore/storage/AbstractDatabase.h
index 9279adc..e0a277f 100644
--- a/Source/WebCore/storage/AbstractDatabase.h
+++ b/Source/WebCore/storage/AbstractDatabase.h
@@ -36,7 +36,7 @@
#include "SQLiteDatabase.h"
#include <wtf/Forward.h>
#include <wtf/ThreadSafeRefCounted.h>
-#ifndef NDEBUG
+#if !LOG_DISABLED || !ERROR_DISABLED
#include "SecurityOrigin.h"
#endif
@@ -109,7 +109,7 @@ protected:
unsigned long m_estimatedSize;
String m_filename;
-#ifndef NDEBUG
+#if !LOG_DISABLED || !ERROR_DISABLED
String databaseDebugName() const { return m_contextThreadSecurityOrigin->toString() + "::" + m_name; }
#endif
diff --git a/Source/WebCore/storage/DatabaseTask.cpp b/Source/WebCore/storage/DatabaseTask.cpp
index 343ae1e..ad744e5 100644
--- a/Source/WebCore/storage/DatabaseTask.cpp
+++ b/Source/WebCore/storage/DatabaseTask.cpp
@@ -62,7 +62,7 @@ void DatabaseTaskSynchronizer::taskCompleted()
DatabaseTask::DatabaseTask(Database* database, DatabaseTaskSynchronizer* synchronizer)
: m_database(database)
, m_synchronizer(synchronizer)
-#ifndef NDEBUG
+#if !LOG_DISABLED
, m_complete(false)
#endif
{
@@ -70,13 +70,17 @@ DatabaseTask::DatabaseTask(Database* database, DatabaseTaskSynchronizer* synchro
DatabaseTask::~DatabaseTask()
{
+#if !LOG_DISABLED
ASSERT(m_complete || !m_synchronizer);
+#endif
}
void DatabaseTask::performTask()
{
// Database tasks are meant to be used only once, so make sure this one hasn't been performed before.
+#if !LOG_DISABLED
ASSERT(!m_complete);
+#endif
LOG(StorageAPI, "Performing %s %p\n", debugTaskName(), this);
@@ -86,7 +90,7 @@ void DatabaseTask::performTask()
if (m_synchronizer)
m_synchronizer->taskCompleted();
-#ifndef NDEBUG
+#if !LOG_DISABLED
m_complete = true;
#endif
}
@@ -108,7 +112,7 @@ void Database::DatabaseOpenTask::doPerformTask()
m_success = database()->performOpenAndVerify(m_setVersionInNewDatabase, m_code);
}
-#ifndef NDEBUG
+#if !LOG_DISABLED
const char* Database::DatabaseOpenTask::debugTaskName() const
{
return "DatabaseOpenTask";
@@ -128,7 +132,7 @@ void Database::DatabaseCloseTask::doPerformTask()
database()->close();
}
-#ifndef NDEBUG
+#if !LOG_DISABLED
const char* Database::DatabaseCloseTask::debugTaskName() const
{
return "DatabaseCloseTask";
@@ -150,7 +154,7 @@ void Database::DatabaseTransactionTask::doPerformTask()
m_transaction->database()->inProgressTransactionCompleted();
}
-#ifndef NDEBUG
+#if !LOG_DISABLED
const char* Database::DatabaseTransactionTask::debugTaskName() const
{
return "DatabaseTransactionTask";
@@ -172,7 +176,7 @@ void Database::DatabaseTableNamesTask::doPerformTask()
m_tableNames = database()->performGetTableNames();
}
-#ifndef NDEBUG
+#if !LOG_DISABLED
const char* Database::DatabaseTableNamesTask::debugTaskName() const
{
return "DatabaseTableNamesTask";
diff --git a/Source/WebCore/storage/DatabaseTask.h b/Source/WebCore/storage/DatabaseTask.h
index e1df591..faadc69 100644
--- a/Source/WebCore/storage/DatabaseTask.h
+++ b/Source/WebCore/storage/DatabaseTask.h
@@ -90,7 +90,7 @@ private:
Database* m_database;
DatabaseTaskSynchronizer* m_synchronizer;
-#ifndef NDEBUG
+#if !LOG_DISABLED
virtual const char* debugTaskName() const = 0;
bool m_complete;
#endif
@@ -107,7 +107,7 @@ private:
DatabaseOpenTask(Database*, bool setVersionInNewDatabase, DatabaseTaskSynchronizer*, ExceptionCode&, bool& success);
virtual void doPerformTask();
-#ifndef NDEBUG
+#if !LOG_DISABLED
virtual const char* debugTaskName() const;
#endif
@@ -127,7 +127,7 @@ private:
DatabaseCloseTask(Database*, DatabaseTaskSynchronizer*);
virtual void doPerformTask();
-#ifndef NDEBUG
+#if !LOG_DISABLED
virtual const char* debugTaskName() const;
#endif
};
@@ -146,7 +146,7 @@ private:
DatabaseTransactionTask(PassRefPtr<SQLTransaction>);
virtual void doPerformTask();
-#ifndef NDEBUG
+#if !LOG_DISABLED
virtual const char* debugTaskName() const;
#endif
@@ -164,7 +164,7 @@ private:
DatabaseTableNamesTask(Database*, DatabaseTaskSynchronizer*, Vector<String>& names);
virtual void doPerformTask();
-#ifndef NDEBUG
+#if !LOG_DISABLED
virtual const char* debugTaskName() const;
#endif
diff --git a/Source/WebCore/storage/SQLTransaction.cpp b/Source/WebCore/storage/SQLTransaction.cpp
index dfcd568..0b1ad25 100644
--- a/Source/WebCore/storage/SQLTransaction.cpp
+++ b/Source/WebCore/storage/SQLTransaction.cpp
@@ -117,7 +117,7 @@ void SQLTransaction::enqueueStatement(PassRefPtr<SQLStatement> statement)
m_statementQueue.append(statement);
}
-#ifndef NDEBUG
+#if !LOG_DISABLED
const char* SQLTransaction::debugStepName(SQLTransaction::TransactionStepMethod step)
{
if (step == &SQLTransaction::acquireLock)
diff --git a/Source/WebCore/storage/SQLTransaction.h b/Source/WebCore/storage/SQLTransaction.h
index 4c84f91..a0a83ed 100644
--- a/Source/WebCore/storage/SQLTransaction.h
+++ b/Source/WebCore/storage/SQLTransaction.h
@@ -105,7 +105,7 @@ private:
void deliverTransactionErrorCallback();
void cleanupAfterTransactionErrorCallback();
-#ifndef NDEBUG
+#if !LOG_DISABLED
static const char* debugStepName(TransactionStepMethod);
#endif
diff --git a/Source/WebCore/svg/SVGFontFaceUriElement.h b/Source/WebCore/svg/SVGFontFaceUriElement.h
index ad9ba97..3806315 100644
--- a/Source/WebCore/svg/SVGFontFaceUriElement.h
+++ b/Source/WebCore/svg/SVGFontFaceUriElement.h
@@ -45,22 +45,6 @@ private:
virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
virtual void insertedIntoDocument();
-#ifdef ANDROID_INSTRUMENT
- void* operator new(size_t size) {
- return SVGElement::operator new(size);
- }
- void* operator new[](size_t size) {
- return SVGElement::operator new[](size);
- }
-
- void operator delete(void* p, size_t size) {
- SVGElement::operator delete(p, size);
- }
- void operator delete[](void* p, size_t size) {
- SVGElement::operator delete[](p, size);
- }
-#endif
-
void loadFont();
CachedResourceHandle<CachedFont> m_cachedFont;
diff --git a/Source/WebCore/workers/WorkerContext.idl b/Source/WebCore/workers/WorkerContext.idl
index e31f5ad..5a6c407 100644
--- a/Source/WebCore/workers/WorkerContext.idl
+++ b/Source/WebCore/workers/WorkerContext.idl
@@ -126,6 +126,7 @@ module threads {
attribute Int32ArrayConstructor Int32Array; // Usable with new operator
attribute Uint32ArrayConstructor Uint32Array; // Usable with new operator
attribute Float32ArrayConstructor Float32Array; // Usable with new operator
+ attribute Float64ArrayConstructor Float64Array; // Usable with new operator
};
}
diff --git a/Source/WebCore/xml/XSLImportRule.h b/Source/WebCore/xml/XSLImportRule.h
index 3c5939d..5c0ca8a 100644
--- a/Source/WebCore/xml/XSLImportRule.h
+++ b/Source/WebCore/xml/XSLImportRule.h
@@ -52,22 +52,6 @@ public:
bool isLoading();
void loadSheet();
-#ifdef ANDROID_INSTRUMENT
- void* operator new(size_t size) {
- return StyleBase::operator new(size);
- }
- void* operator new[](size_t size) {
- return StyleBase::operator new[](size);
- }
-
- void operator delete(void* p, size_t size) {
- StyleBase::operator delete(p, size);
- }
- void operator delete[](void* p, size_t size) {
- StyleBase::operator delete[](p, size);
- }
-#endif
-
private:
XSLImportRule(XSLStyleSheet* parentSheet, const String& href);
diff --git a/Source/WebKit/Android.mk b/Source/WebKit/Android.mk
index bbe212c..fb6ee31 100644
--- a/Source/WebKit/Android.mk
+++ b/Source/WebKit/Android.mk
@@ -31,7 +31,6 @@ LOCAL_SRC_FILES := \
android/WebCoreSupport/PlatformBridge.cpp \
android/WebCoreSupport/ResourceLoaderAndroid.cpp \
android/WebCoreSupport/UrlInterceptResponse.cpp \
- android/WebCoreSupport/V8Counters.cpp
ifeq ($(HTTP_STACK),chrome)
LOCAL_SRC_FILES += \
@@ -55,7 +54,6 @@ LOCAL_SRC_FILES += \
android/RenderSkinMediaButton.cpp \
android/RenderSkinNinePatch.cpp \
android/RenderSkinRadio.cpp \
- android/TimeCounter.cpp \
\
android/benchmark/Intercept.cpp \
android/benchmark/MyJavaVM.cpp \
diff --git a/Source/WebKit/android/AndroidLog.h b/Source/WebKit/android/AndroidLog.h
index 3d3eaaa..4090ab9 100644
--- a/Source/WebKit/android/AndroidLog.h
+++ b/Source/WebKit/android/AndroidLog.h
@@ -27,16 +27,17 @@
#define AndroidLog_h
#ifdef ANDROID_DOM_LOGGING
+#include <utils/Log.h>
#include <stdio.h>
extern FILE* gDomTreeFile;
#define DOM_TREE_LOG_FILE "/sdcard/domTree.txt"
#define DUMP_DOM_LOGD(...) { if (gDomTreeFile) \
- fprintf(gDomTreeFile, __VA_ARGS__); else LOGD(__VA_ARGS__); }
+ fprintf(gDomTreeFile, __VA_ARGS__); else ALOGD(__VA_ARGS__); }
extern FILE* gRenderTreeFile;
#define RENDER_TREE_LOG_FILE "/sdcard/renderTree.txt"
#define DUMP_RENDER_LOGD(...) { if (gRenderTreeFile) \
- fprintf(gRenderTreeFile, __VA_ARGS__); else LOGD(__VA_ARGS__); }
+ fprintf(gRenderTreeFile, __VA_ARGS__); else ALOGD(__VA_ARGS__); }
#else
#define DUMP_DOM_LOGD(...) ((void)0)
#define DUMP_RENDER_LOGD(...) ((void)0)
diff --git a/Source/WebKit/android/RenderSkinAndroid.cpp b/Source/WebKit/android/RenderSkinAndroid.cpp
index 4a9ce68..e6fb67b 100644
--- a/Source/WebKit/android/RenderSkinAndroid.cpp
+++ b/Source/WebKit/android/RenderSkinAndroid.cpp
@@ -65,14 +65,14 @@ bool RenderSkinAndroid::DecodeBitmap(android::AssetManager* am, const char* file
if (!asset) {
asset = am->openNonAsset(fileName, android::Asset::ACCESS_BUFFER);
if (!asset) {
- LOGD("RenderSkinAndroid: File \"%s\" not found.\n", fileName);
+ ALOGD("RenderSkinAndroid: File \"%s\" not found.\n", fileName);
return false;
}
}
bool success = SkImageDecoder::DecodeMemory(asset->getBuffer(false), asset->getLength(), bitmap);
if (!success) {
- LOGD("RenderSkinAndroid: Failed to decode %s\n", fileName);
+ ALOGD("RenderSkinAndroid: Failed to decode %s\n", fileName);
}
delete asset;
diff --git a/Source/WebKit/android/RenderSkinButton.cpp b/Source/WebKit/android/RenderSkinButton.cpp
index 11e2fa8..7ab50aa 100644
--- a/Source/WebKit/android/RenderSkinButton.cpp
+++ b/Source/WebKit/android/RenderSkinButton.cpp
@@ -76,7 +76,7 @@ void RenderSkinButton::decode()
path.append(String(gFiles[i]));
if (!RenderSkinNinePatch::decodeAsset(am, path.utf8().data(), &m_buttons[i])) {
m_decoded = false;
- LOGE("RenderSkinButton::decode: button assets failed to decode\n\tWebView buttons will not draw");
+ ALOGE("RenderSkinButton::decode: button assets failed to decode\n\tWebView buttons will not draw");
return;
}
}
diff --git a/Source/WebKit/android/RenderSkinMediaButton.cpp b/Source/WebKit/android/RenderSkinMediaButton.cpp
index ef4b313..f99c731 100644
--- a/Source/WebKit/android/RenderSkinMediaButton.cpp
+++ b/Source/WebKit/android/RenderSkinMediaButton.cpp
@@ -82,14 +82,14 @@ void RenderSkinMediaButton::Decode()
String path = drawableDirectory + gFiles[i].name;
if (!RenderSkinAndroid::DecodeBitmap(am, path.utf8().data(), &gButton[i])) {
gDecodingFailed = true;
- LOGD("RenderSkinButton::Init: button assets failed to decode\n\tBrowser buttons will not draw");
+ ALOGD("RenderSkinButton::Init: button assets failed to decode\n\tBrowser buttons will not draw");
break;
}
}
}
void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonType,
- bool translucent, RenderObject* o)
+ bool translucent, RenderObject* o, bool drawBackground)
{
if (!gDecoded) {
Decode();
@@ -102,7 +102,6 @@ void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonT
bool drawsNinePatch = false;
bool drawsImage = true;
- bool drawsBackgroundColor = true;
int ninePatchIndex = 0;
int imageIndex = 0;
@@ -136,13 +135,11 @@ void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonT
case SPINNER_INNER:
case VIDEO:
{
- drawsBackgroundColor = false;
imageIndex = buttonType + 1;
break;
}
case BACKGROUND_SLIDER:
{
- drawsBackgroundColor = false;
drawsImage = false;
break;
}
@@ -155,7 +152,6 @@ void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonT
}
case SLIDER_THUMB:
{
- drawsBackgroundColor = false;
imageMargin = 0;
imageIndex = buttonType + 1;
break;
@@ -164,7 +160,7 @@ void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonT
return;
}
- if (drawsBackgroundColor) {
+ if (drawBackground) {
canvas->drawRect(r, paint);
}
diff --git a/Source/WebKit/android/RenderSkinMediaButton.h b/Source/WebKit/android/RenderSkinMediaButton.h
index d8b7c8d..484b90c 100644
--- a/Source/WebKit/android/RenderSkinMediaButton.h
+++ b/Source/WebKit/android/RenderSkinMediaButton.h
@@ -42,7 +42,7 @@ public:
* State to determine which skin to use, i.e. focused or not focused.
*/
static void Draw(SkCanvas* , const IntRect& , int buttonType, bool translucent = false,
- RenderObject* o = 0);
+ RenderObject* o = 0, bool drawBackground = true);
/**
* Button types
*/
diff --git a/Source/WebKit/android/RenderSkinNinePatch.cpp b/Source/WebKit/android/RenderSkinNinePatch.cpp
index faa9dc4..d9f6011 100644
--- a/Source/WebKit/android/RenderSkinNinePatch.cpp
+++ b/Source/WebKit/android/RenderSkinNinePatch.cpp
@@ -53,7 +53,7 @@ bool RenderSkinNinePatch::decodeAsset(AssetManager* am, const char* filename, Ni
SkImageDecoder* decoder = SkImageDecoder::Factory(&stream);
if (!decoder) {
asset->close();
- LOGE("RenderSkinNinePatch::Failed to create an image decoder");
+ ALOGE("RenderSkinNinePatch::Failed to create an image decoder");
return false;
}
@@ -68,13 +68,13 @@ bool RenderSkinNinePatch::decodeAsset(AssetManager* am, const char* filename, Ni
decoder->setPeeker(&peeker);
if (!decoder->decode(&stream, &ninepatch->m_bitmap, prefConfig, mode, true)) {
asset->close();
- LOGE("RenderSkinNinePatch::Failed to decode nine patch asset");
+ ALOGE("RenderSkinNinePatch::Failed to decode nine patch asset");
return false;
}
asset->close();
if (!peeker.fPatchIsValid) {
- LOGE("RenderSkinNinePatch::Patch data not valid");
+ ALOGE("RenderSkinNinePatch::Patch data not valid");
return false;
}
void** data = &ninepatch->m_serializedPatchData;
diff --git a/Source/WebKit/android/TimeCounter.cpp b/Source/WebKit/android/TimeCounter.cpp
deleted file mode 100644
index 2393f8a..0000000
--- a/Source/WebKit/android/TimeCounter.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * 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.
- */
-
-#define LOG_TAG "WebCore"
-
-#include "config.h"
-#include "TimeCounter.h"
-
-#include "MemoryCache.h"
-#include "KURL.h"
-#include "Node.h"
-#include "SystemTime.h"
-#include "StyleBase.h"
-#include <sys/time.h>
-#include <time.h>
-#include <utils/Log.h>
-#include <wtf/CurrentTime.h>
-#include <wtf/text/CString.h>
-
-#if USE(JSC)
-#include "JSDOMWindow.h"
-#include <runtime/JSGlobalObject.h>
-#include <runtime/JSLock.h>
-#endif
-
-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;
-static uint32_t sStartThreadTime;
-static double sLastTotalTime;
-static uint32_t sLastThreadTime;
-
-uint32_t TimeCounter::sStartWebCoreThreadTime;
-uint32_t TimeCounter::sEndWebCoreThreadTime;
-bool TimeCounter::sRecordWebCoreTime;
-uint32_t TimeCounter::sTotalTimeUsed[TimeCounter::TotalTimeCounterCount];
-uint32_t TimeCounter::sLastTimeUsed[TimeCounter::TotalTimeCounterCount];
-uint32_t TimeCounter::sCounter[TimeCounter::TotalTimeCounterCount];
-uint32_t TimeCounter::sLastCounter[TimeCounter::TotalTimeCounterCount];
-uint32_t TimeCounter::sStartTime[TimeCounter::TotalTimeCounterCount];
-
-int QemuTracerAuto::reentry_count = 0;
-
-static const char* timeCounterNames[] = {
- "css parsing",
- "javascript",
- "javascript init",
- "javascript parsing",
- "javascript execution",
- "calculate style",
- "Java callback (frame bridge)",
- "parsing (may include calcStyle, Java callback or inline script execution)",
- "layout",
- "native 1 (frame bridge)",
- "native 2 (resource load)",
- "native 3 (shared timer)",
- "build nav (webview core)",
- "record content (webview core)",
- "native 4 (webview core)",
- "draw content (webview ui)",
-};
-
-void TimeCounter::record(enum Type type, const char* functionName)
-{
- recordNoCounter(type, functionName);
- sCounter[type]++;
-}
-
-void TimeCounter::recordNoCounter(enum Type type, const char* functionName)
-{
- uint32_t time = sEndWebCoreThreadTime = getThreadMsec();
- uint32_t elapsed = time - sStartTime[type];
- sTotalTimeUsed[type] += elapsed;
- if (elapsed > 1000)
- LOGW("***** %s() used %d ms\n", functionName, elapsed);
-}
-
-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 = 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
- = (Type) (type + 1)) {
- char scratch[256];
- int index = sprintf(scratch, "*-* Total %s time: %d ms",
- timeCounterNames[type], sTotalTimeUsed[type]);
- if (sCounter[type] > 0)
- sprintf(&scratch[index], " called %d times", sCounter[type]);
- LOGD("%s", scratch);
- }
- LOGD("Current cache has %d bytes live and %d bytes dead", live, dead);
- LOGD("Current render arena takes %d bytes", arenaSize);
-#if USE(JSC)
- JSLock lock(false);
- Heap::Statistics jsHeapStatistics = JSDOMWindow::commonJSGlobalData()->heap.statistics();
- LOGD("Current JavaScript heap size is %d and has %d bytes free",
- jsHeapStatistics.size, jsHeapStatistics.free);
-#endif
- LOGD("Current CSS styles use %d bytes", StyleBase::reportStyleSize());
- LOGD("Current DOM nodes use %d bytes", WebCore::Node::reportDOMNodesSize());
-}
-
-void TimeCounter::reportNow()
-{
- double current = currentTime();
- 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:"
- " %d ms\n", elapsedTime, elapsedThreadTime, sEndWebCoreThreadTime -
- sStartWebCoreThreadTime);
- for (Type type = (Type) 0; type < TotalTimeCounterCount; type
- = (Type) (type + 1)) {
- if (sTotalTimeUsed[type] == sLastTimeUsed[type])
- continue;
- char scratch[256];
- int index = sprintf(scratch, "*-* Diff %s time: %d ms",
- timeCounterNames[type], sTotalTimeUsed[type] - sLastTimeUsed[type]);
- if (sCounter[type] > sLastCounter[type])
- sprintf(&scratch[index], " called %d times", sCounter[type]
- - sLastCounter[type]);
- LOGD("%s", scratch);
- }
- memcpy(sLastTimeUsed, sTotalTimeUsed, sizeof(sTotalTimeUsed));
- memcpy(sLastCounter, sCounter, sizeof(sCounter));
- sLastTotalTime = current;
- sLastThreadTime = currentThread;
- sRecordWebCoreTime = true;
-}
-
-void TimeCounter::reset() {
- bzero(sTotalTimeUsed, sizeof(sTotalTimeUsed));
- bzero(sCounter, sizeof(sCounter));
- LOGD("*-* Start browser instrument\n");
- sStartTotalTime = currentTime();
- sStartThreadTime = getThreadMsec();
-}
-
-void TimeCounter::start(enum Type type)
-{
- uint32_t time = getThreadMsec();
- if (sRecordWebCoreTime) {
- sStartWebCoreThreadTime = time;
- sRecordWebCoreTime = false;
- }
- sStartTime[type] = time;
-}
-
-#endif // ANDROID_INSTRUMENT
-
-}
diff --git a/Source/WebKit/android/TimeCounter.h b/Source/WebKit/android/TimeCounter.h
deleted file mode 100644
index ecede27..0000000
--- a/Source/WebKit/android/TimeCounter.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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 TimeCounter_h
-#define TimeCounter_h
-
-#include "hardware_legacy/qemu_tracing.h"
-
-namespace WebCore {
-
-class KURL;
-
-}
-
-namespace android {
-
-uint32_t getThreadMsec();
-
-#ifdef ANDROID_INSTRUMENT
-
-class TimeCounter {
-public:
- enum Type {
- // function base counters
- CSSParseTimeCounter,
- JavaScriptTimeCounter,
- JavaScriptInitTimeCounter,
- JavaScriptParseTimeCounter,
- JavaScriptExecuteTimeCounter,
- CalculateStyleTimeCounter,
- JavaCallbackTimeCounter,
- ParsingTimeCounter,
- LayoutTimeCounter,
- // file base counters
- NativeCallbackTimeCounter, // WebCoreFrameBridge.cpp
- ResourceTimeCounter, // WebCoreResourceLoader.cpp
- SharedTimerTimeCounter, // JavaBridge.cpp
- WebViewCoreBuildNavTimeCounter,
- WebViewCoreRecordTimeCounter,
- WebViewCoreTimeCounter, // WebViewCore.cpp
- WebViewUIDrawTimeCounter,
- TotalTimeCounterCount
- };
-
- static void record(enum Type type, const char* functionName);
- static void recordNoCounter(enum Type type, const char* functionName);
- static void report(const WebCore::KURL& , int live, int dead, size_t arenaSize);
- static void reportNow();
- static void reset();
- static void start(enum Type type);
-private:
- static uint32_t sStartWebCoreThreadTime;
- static uint32_t sEndWebCoreThreadTime;
- static bool sRecordWebCoreTime;
- static uint32_t sTotalTimeUsed[TotalTimeCounterCount];
- static uint32_t sLastTimeUsed[TotalTimeCounterCount];
- static uint32_t sCounter[TotalTimeCounterCount];
- static uint32_t sLastCounter[TotalTimeCounterCount];
- static uint32_t sStartTime[TotalTimeCounterCount];
- friend class TimeCounterAuto;
-};
-
-class TimeCounterAuto {
-public:
- TimeCounterAuto(TimeCounter::Type type) :
- m_type(type), m_startTime(getThreadMsec()) {}
- ~TimeCounterAuto() {
- uint32_t time = getThreadMsec();
- TimeCounter::sEndWebCoreThreadTime = time;
- TimeCounter::sTotalTimeUsed[m_type] += time - m_startTime;
- TimeCounter::sCounter[m_type]++;
- }
-private:
- TimeCounter::Type m_type;
- uint32_t m_startTime;
-};
-
-class QemuTracerAuto {
-public:
- QemuTracerAuto() {
- if (!reentry_count)
- qemu_start_tracing();
- reentry_count++;
- }
-
- ~QemuTracerAuto() {
- reentry_count--;
- if (!reentry_count)
- qemu_stop_tracing();
- }
-private:
- static int reentry_count;
-};
-#endif // ANDROID_INSTRUMENT
-
-}
-
-#endif
diff --git a/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h b/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h
index 022511a..1c898a0 100644
--- a/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h
+++ b/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h
@@ -23,31 +23,46 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+// All source files wishing to include Chromium headers must include this file
+// and must not incude Chromium headers directly.
+
#ifndef ChromiumIncludes_h
#define ChromiumIncludes_h
#include "config.h"
-// Include all external/chromium files in this file so the problems with the LOG
-// and LOG_ASSERT defines can be handled in one place.
-
-// Undefine LOG and LOG_ASSERT before including chrome code, and if they were
-// defined attempt to set the macros to the Android logging macros (which are
-// the only ones that actually log).
-
+// Both WebKit and Chromium define LOG. In AOSP, the framework also defines
+// LOG. To avoid conflicts, we undefine LOG before including Chromium code,
+// then define it back to the WebKit macro.
#ifdef LOG
-#define LOG_WAS_DEFINED LOG
+#define LOG_WAS_DEFINED
#undef LOG
#endif
-#ifdef LOG_ASSERT
-#define LOG_ASSERT_WAS_DEFINED LOG_ASSERT
+// In AOSP, the framework still uses LOG_ASSERT (as well as ALOG_ASSERT), which
+// conflicts with Chromium's LOG_ASSERT. So we undefine LOG_ASSERT to allow the
+// Chromium implementation to be picked up. We also redefine ALOG_ASSERT to the
+// underlying framework implementation without using LOG_ASSERT.
+// TODO: Remove this once LOG_ASSERT is removed from the framework in AOSP.
#undef LOG_ASSERT
+#undef ALOG_ASSERT
+// Copied from log.h.
+#define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__)
+
+// Chromium won't build without NDEBUG set, so we set it for all source files
+// that use Chromium code. This means that if NDEBUG was previously unset, we
+// have to redefine ASSERT() to a no-op, as this is enabled in debug builds.
+// Unfortunately, ASSERT() is defined from config.h, so we can't get in first.
+#ifndef NDEBUG
+#define NDEBUG 1
+#undef ASSERT
+#define ASSERT(assertion) (void(0))
#endif
#include <android/net/android_network_library_impl.h>
#include <android/jni/jni_utils.h>
#include <base/callback.h>
+#include <base/lazy_instance.h>
#include <base/memory/ref_counted.h>
#include <base/message_loop_proxy.h>
#include <base/openssl_util.h>
@@ -100,13 +115,15 @@
#endif
#undef LOG
-#if defined(LOG_WAS_DEFINED) && defined(LOG_PRI)
-#define LOG(priority, tag, ...) LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__)
+// If LOG was defined, restore it to the WebKit macro.
+#ifdef LOG_WAS_DEFINED
+// If LOG was defined, JOIN_LOG_CHANNEL_WITH_PREFIX must be too.
+// Copied from Assertions.h.
+#if LOG_DISABLED
+#define LOG(channel, ...) ((void)0)
+#else
+#define LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
#endif
-
-#undef LOG_ASSERT
-#if defined(LOG_ASSERT_WAS_DEFINED) && defined(LOG_FATAL_IF)
-#define LOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__)
#endif
#endif
diff --git a/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
index 0be31eb..d26d523 100644
--- a/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
+++ b/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
@@ -267,11 +267,11 @@ void FrameLoaderClientAndroid::dispatchDidReceiveIcon() {
// There is a bug in webkit where cancelling an icon load is treated as a
// failure. When this is fixed, we can ASSERT again that we have an icon.
if (icon) {
- LOGV("Received icon (%p) for %s", icon,
+ ALOGV("Received icon (%p) for %s", icon,
url.utf8().data());
m_webFrame->didReceiveIcon(icon);
} else {
- LOGV("Icon data for %s unavailable, registering for notification...",
+ ALOGV("Icon data for %s unavailable, registering for notification...",
url.utf8().data());
registerForIconNotification();
}
@@ -1016,7 +1016,7 @@ WTF::PassRefPtr<WebCore::Frame> FrameLoaderClientAndroid::createFrame(const KURL
newFrame->setView(frameView);
newFrame->init();
newFrame->selection()->setFocused(true);
- LOGV("::WebCore:: createSubFrame returning %p", newFrame);
+ ALOGV("::WebCore:: createSubFrame returning %p", newFrame);
// The creation of the frame may have run arbitrary JavaScript that removed it from the page already.
if (!pFrame->page())
@@ -1331,8 +1331,8 @@ void FrameLoaderClientAndroid::dispatchDidClearWindowObjectInWorld(DOMWrapperWor
return;
ASSERT(m_frame);
- LOGV("::WebCore:: windowObjectCleared called on frame %p for %s\n",
- m_frame, m_frame->loader()->url().string().ascii().data());
+ ALOGV("::WebCore:: windowObjectCleared called on frame %p for %s\n",
+ m_frame, m_frame->document()->url().string().ascii().data());
m_webFrame->windowObjectCleared(m_frame);
}
diff --git a/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp b/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp
index 339e91b..7a80925 100644
--- a/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp
+++ b/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp
@@ -168,6 +168,14 @@ void MediaPlayerPrivate::onEnded()
m_networkState = MediaPlayer::Idle;
}
+void MediaPlayerPrivate::onRestoreState()
+{
+ if (!m_paused) {
+ //Kick off a JNI call to start the video.
+ play();
+ }
+}
+
void MediaPlayerPrivate::onPaused()
{
m_paused = true;
@@ -570,6 +578,15 @@ static void OnTimeupdate(JNIEnv* env, jobject obj, int position, int pointer)
}
}
+static void OnRestoreState(JNIEnv* env, jobject obj, int pointer)
+{
+ if (pointer) {
+ WebCore::MediaPlayerPrivate* player = reinterpret_cast<WebCore::MediaPlayerPrivate*>(pointer);
+ player->onRestoreState();
+ }
+}
+
+
// This is called on the UI thread only.
// The video layers are composited on the webkit thread and then copied over
// to the UI thread with the same ID. For rendering, we are only using the
@@ -632,6 +649,8 @@ static JNINativeMethod g_MediaPlayerMethods[] = {
(void*) OnPaused },
{ "nativeOnPosterFetched", "(Landroid/graphics/Bitmap;I)V",
(void*) OnPosterFetched },
+ { "nativeOnRestoreState", "(I)V",
+ (void*) OnRestoreState },
{ "nativeSendSurfaceTexture", "(Landroid/graphics/SurfaceTexture;IIII)Z",
(void*) SendSurfaceTexture },
{ "nativeOnTimeupdate", "(II)V",
diff --git a/Source/WebKit/android/WebCoreSupport/V8Counters.cpp b/Source/WebKit/android/WebCoreSupport/V8Counters.cpp
deleted file mode 100644
index d164f9a..0000000
--- a/Source/WebKit/android/WebCoreSupport/V8Counters.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.
- */
-
-
-#ifdef ANDROID_INSTRUMENT
-
-#define LOG_TAG "WebCore"
-
-#include "config.h"
-#include "V8Counters.h"
-
-#include "NotImplemented.h"
-#include <utils/Log.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringHash.h>
-
-#if USE(V8)
-
-namespace WebCore {
-
-V8Counters::Counter::Counter(bool isHistogram)
- : m_count(0), m_sampleTotal(0), m_isHistogram(isHistogram) { }
-
-void V8Counters::Counter::addSample(int sample)
-{
- m_count++;
- m_sampleTotal += sample;
-}
-
-HashMap<String, V8Counters::Counter*> V8Counters::m_counters;
-
-// static
-int* V8Counters::counterForName(const char* name)
-{
- Counter* counter = m_counters.get(name);
- if (!counter) {
- counter = new Counter(false);
- m_counters.add(name, counter);
- }
- return *counter;
-}
-
-// static
-void* V8Counters::createHistogram(const char* name, int min, int max,
- size_t buckets)
-{
- Counter* counter = new Counter(true);
- m_counters.add(name, counter);
- return counter;
-}
-
-// static
-void V8Counters::addHistogramSample(void* histogram, int sample)
-{
- Counter* counter = reinterpret_cast<Counter*>(histogram);
- counter->addSample(sample);
-}
-
-// static
-void V8Counters::initCounters()
-{
- static bool isInitialized = false;
- if (!isInitialized) {
- v8::V8::SetCounterFunction(counterForName);
- v8::V8::SetCreateHistogramFunction(createHistogram);
- v8::V8::SetAddHistogramSampleFunction(addHistogramSample);
- isInitialized = true;
- }
-}
-
-// static
-void V8Counters::dumpCounters()
-{
- LOGD("+----------------------------------------+-------------+\n");
- LOGD("| Name | Value |\n");
- LOGD("+----------------------------------------+-------------+\n");
- typedef HashMap<String, V8Counters::Counter*>::iterator CounterIterator;
- for (CounterIterator iter = m_counters.begin(); iter != m_counters.end(); ++iter) {
- Counter* counter = iter->second;
- if (counter->isHistogram()) {
- LOGD("| c:%-36s | %11i |\n", iter->first.latin1().data(), counter->count());
- LOGD("| t:%-36s | %11i |\n", iter->first.latin1().data(), counter->sampleTotal());
- } else {
- LOGD("| %-38s | %11i |\n", iter->first.latin1().data(), counter->count());
- }
- }
- LOGD("+----------------------------------------+-------------+\n");
-}
-
-}
-
-#endif // ANDROID_INSTRUMENT
-
-#endif // USE(V8)
diff --git a/Source/WebKit/android/WebCoreSupport/V8Counters.h b/Source/WebKit/android/WebCoreSupport/V8Counters.h
deleted file mode 100644
index 499b856..0000000
--- a/Source/WebKit/android/WebCoreSupport/V8Counters.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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 V8Counters_h
-#define V8Counters_h
-
-#if USE(V8)
-
-#ifdef ANDROID_INSTRUMENT
-
-#include <PlatformString.h>
-#include <v8.h>
-#include <wtf/HashMap.h>
-
-namespace WebCore {
-
-class V8Counters {
-public:
- // Counter callbacks, see v8.h
- static int* counterForName(const char* name);
-
- static void* createHistogram(const char* name,
- int min,
- int max,
- size_t buckets);
-
- static void addHistogramSample(void* histogram, int sample);
-
- static void initCounters();
- static void dumpCounters();
-private:
- class Counter {
- public:
- Counter(bool isHistogram);
-
- int count() { return m_count; }
- int sampleTotal() { return m_sampleTotal; }
- bool isHistogram() { return m_isHistogram; }
- void addSample(int32_t sample);
-
- operator int*() { return &m_count; }
- private:
- int m_count;
- int m_sampleTotal;
- bool m_isHistogram;
- };
-
- static HashMap<String, Counter*> m_counters;
-};
-
-}
-
-#endif // ANDROID_INSTRUMENT
-#endif // USE(V8)
-#endif // V8Counters_h
diff --git a/Source/WebKit/android/WebCoreSupport/WebCookieJar.cpp b/Source/WebKit/android/WebCoreSupport/WebCookieJar.cpp
index 1dc4637..0af3cc2 100644
--- a/Source/WebKit/android/WebCoreSupport/WebCookieJar.cpp
+++ b/Source/WebKit/android/WebCoreSupport/WebCookieJar.cpp
@@ -98,7 +98,7 @@ static std::string databaseDirectory(bool isPrivateBrowsing)
return databaseFilePath;
}
-scoped_refptr<WebCookieJar>* instance(bool isPrivateBrowsing)
+static scoped_refptr<WebCookieJar>* instance(bool isPrivateBrowsing)
{
static scoped_refptr<WebCookieJar> regularInstance;
static scoped_refptr<WebCookieJar> privateInstance;
@@ -127,10 +127,16 @@ void WebCookieJar::cleanup(bool isPrivateBrowsing)
}
WebCookieJar::WebCookieJar(const std::string& databaseFilePath)
- : m_allowCookies(true)
-{
+ : m_cookieStoreInitialized(false)
+ , m_databaseFilePath(databaseFilePath)
+ , m_allowCookies(true) {}
+
+void WebCookieJar::initCookieStore() {
+ MutexLocker lock(m_cookieStoreInitializeMutex);
+ if (m_cookieStoreInitialized)
+ return;
// Setup the permissions for the file
- const char* cDatabasePath = databaseFilePath.c_str();
+ const char* cDatabasePath = m_databaseFilePath.c_str();
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
if (access(cDatabasePath, F_OK) == 0)
chmod(cDatabasePath, mode);
@@ -140,9 +146,10 @@ WebCookieJar::WebCookieJar(const std::string& databaseFilePath)
close(fd);
}
- FilePath cookiePath(databaseFilePath.c_str());
+ FilePath cookiePath(cDatabasePath);
m_cookieDb = new SQLitePersistentCookieStore(cookiePath);
m_cookieStore = new net::CookieMonster(m_cookieDb.get(), 0);
+ m_cookieStoreInitialized = true;
}
bool WebCookieJar::allowCookies()
@@ -157,13 +164,6 @@ void WebCookieJar::setAllowCookies(bool allow)
m_allowCookies = allow;
}
-int WebCookieJar::getNumCookiesInDatabase()
-{
- if (!m_cookieStore)
- return 0;
- return m_cookieStore->GetCookieMonster()->GetAllCookies().size();
-}
-
// From CookiePolicy in chromium
int WebCookieJar::CanGetCookies(const GURL&, const GURL&) const
{
@@ -178,6 +178,17 @@ int WebCookieJar::CanSetCookie(const GURL&, const GURL&, const std::string&) con
return m_allowCookies ? net::OK : net::ERR_ACCESS_DENIED;
}
+net::CookieStore* WebCookieJar::cookieStore()
+{
+ initCookieStore();
+ return m_cookieStore.get();
+}
+
+int WebCookieJar::getNumCookiesInDatabase()
+{
+ return cookieStore()->GetCookieMonster()->GetAllCookies().size();
+}
+
class FlushSemaphore : public base::RefCounted<FlushSemaphore>
{
public:
diff --git a/Source/WebKit/android/WebCoreSupport/WebCookieJar.h b/Source/WebKit/android/WebCoreSupport/WebCookieJar.h
index b6490af..7ade9d0 100644
--- a/Source/WebKit/android/WebCoreSupport/WebCookieJar.h
+++ b/Source/WebKit/android/WebCoreSupport/WebCookieJar.h
@@ -55,9 +55,10 @@ public:
static bool acceptFileSchemeCookies();
static void setAcceptFileSchemeCookies(bool);
+ // TODO
// Instead of this it would probably be better to add the cookie methods
// here so the rest of WebKit doesn't have to know about Chromium classes
- net::CookieStore* cookieStore() { return m_cookieStore.get(); }
+ net::CookieStore* cookieStore();
net::CookiePolicy* cookiePolicy() { return this; }
// Get the number of cookies that have actually been saved to flash.
@@ -66,7 +67,13 @@ public:
private:
WebCookieJar(const std::string& databaseFilePath);
+ void initCookieStore();
+private:
+ bool m_cookieStoreInitialized;
+ WTF::Mutex m_cookieStoreInitializeMutex;
+
+ const std::string m_databaseFilePath;
scoped_refptr<SQLitePersistentCookieStore> m_cookieDb;
scoped_refptr<net::CookieStore> m_cookieStore;
bool m_allowCookies;
diff --git a/Source/WebKit/android/WebCoreSupport/WebRequest.cpp b/Source/WebKit/android/WebCoreSupport/WebRequest.cpp
index 90b0939..c239b80 100644
--- a/Source/WebKit/android/WebCoreSupport/WebRequest.cpp
+++ b/Source/WebKit/android/WebCoreSupport/WebRequest.cpp
@@ -30,6 +30,7 @@
#include "MainThread.h"
#include "UrlInterceptResponse.h"
#include "WebCoreFrameBridge.h"
+#include "WebCoreJni.h"
#include "WebRequestContext.h"
#include "WebResourceRequest.h"
#include "WebUrlLoaderClient.h"
@@ -58,7 +59,24 @@ while (0)
namespace android {
namespace {
- const int kInitialReadBufSize = 32768;
+const int kInitialReadBufSize = 32768;
+const char* kXRequestedWithHeader = "X-Requested-With";
+
+struct RequestPackageName {
+ std::string value;
+ RequestPackageName();
+};
+
+RequestPackageName::RequestPackageName() {
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ jclass bridgeClass = env->FindClass("android/webkit/JniUtil");
+ jmethodID method = env->GetStaticMethodID(bridgeClass, "getPackageName", "()Ljava/lang/String;");
+ value = jstringToStdString(env, static_cast<jstring>(env->CallStaticObjectMethod(bridgeClass, method)));
+ env->DeleteLocalRef(bridgeClass);
+}
+
+base::LazyInstance<RequestPackageName> s_packageName(base::LINKER_INITIALIZED);
+
}
WebRequest::WebRequest(WebUrlLoaderClient* loader, const WebResourceRequest& webResourceRequest)
@@ -79,6 +97,7 @@ WebRequest::WebRequest(WebUrlLoaderClient* loader, const WebResourceRequest& web
m_request = new net::URLRequest(gurl, this);
m_request->SetExtraRequestHeaders(webResourceRequest.requestHeaders());
+ m_request->SetExtraRequestHeaderByName(kXRequestedWithHeader, s_packageName.Get().value, true);
m_request->set_referrer(webResourceRequest.referrer());
m_request->set_method(webResourceRequest.method());
m_request->set_load_flags(webResourceRequest.loadFlags());
diff --git a/Source/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp b/Source/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
index 43037ab..5df0ed2 100644
--- a/Source/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
+++ b/Source/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
@@ -37,6 +37,7 @@
#include "WebRequest.h"
#include "WebResourceRequest.h"
+#include <utils/Log.h>
#include <wtf/text/CString.h>
using base::Lock;
@@ -156,11 +157,11 @@ WebUrlLoaderClient::WebUrlLoaderClient(WebFrame* webFrame, WebCore::ResourceHand
break;
#if ENABLE(BLOB)
case FormDataElement::encodedBlob:
- LOG_ASSERT(false, "Unexpected use of FormDataElement::encodedBlob");
+ ALOG_ASSERT(false, "Unexpected use of FormDataElement::encodedBlob");
break;
#endif // ENABLE(BLOB)
default:
- LOG_ASSERT(false, "Unexpected default case in WebUrlLoaderClient.cpp");
+ ALOG_ASSERT(false, "Unexpected default case in WebUrlLoaderClient.cpp");
break;
}
}
@@ -199,7 +200,7 @@ bool WebUrlLoaderClient::start(bool isMainResource, bool isMainFrame, bool sync,
syncCondition()->TimedWait(base::TimeDelta::FromSeconds(kCallbackWaitingTime));
if (m_queue.empty()) {
- LOGE("Synchronous request timed out after %d seconds for the %dth try, URL: %s",
+ ALOGE("Synchronous request timed out after %d seconds for the %dth try, URL: %s",
kCallbackWaitingTime, num_timeout, m_request->getUrl().c_str());
num_timeout++;
if (num_timeout >= kMaxNumTimeout) {
@@ -253,7 +254,7 @@ void WebUrlLoaderClient::downloadFile()
if (!m_isCertMimeType)
cancel();
} else {
- LOGE("Unexpected call to downloadFile() before didReceiveResponse(). URL: %s", m_request->getUrl().c_str());
+ ALOGE("Unexpected call to downloadFile() before didReceiveResponse(). URL: %s", m_request->getUrl().c_str());
// TODO: Turn off asserts crashing before release
// http://b/issue?id=2951985
CRASH();
diff --git a/Source/WebKit/android/WebCoreSupport/WebViewClientError.cpp b/Source/WebKit/android/WebCoreSupport/WebViewClientError.cpp
index 260c76e..1857e9c 100644
--- a/Source/WebKit/android/WebCoreSupport/WebViewClientError.cpp
+++ b/Source/WebKit/android/WebCoreSupport/WebViewClientError.cpp
@@ -79,6 +79,7 @@ WebViewClientError ToWebViewClientError(net::Error error) {
case ERR_CONNECTION_ABORTED:
case ERR_CONNECTION_FAILED:
case ERR_SOCKET_NOT_CONNECTED:
+ case ERR_CACHE_MISS:
return ERROR_CONNECT;
case ERR_ADDRESS_INVALID:
diff --git a/Source/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp b/Source/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp
index e837244..2969252 100644
--- a/Source/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp
+++ b/Source/WebKit/android/WebCoreSupport/autofill/FormManagerAndroid.cpp
@@ -562,7 +562,7 @@ void FormManager::ExtractForms(Frame* frame) {
ResetFrame(frame);
- WTF::PassRefPtr<HTMLCollection> web_forms = frame->document()->forms();
+ WTF::RefPtr<HTMLCollection> web_forms = frame->document()->forms();
for (size_t i = 0; i < web_forms->length(); ++i) {
// Owned by |form_elements|.
diff --git a/Source/WebKit/android/benchmark/Intercept.cpp b/Source/WebKit/android/benchmark/Intercept.cpp
index deffac2..28ada5a 100644
--- a/Source/WebKit/android/benchmark/Intercept.cpp
+++ b/Source/WebKit/android/benchmark/Intercept.cpp
@@ -57,7 +57,7 @@ void MyResourceLoader::handleRequest()
void MyResourceLoader::loadData(const String& data)
{
- LOGD("Loading data (%s) ...", data.latin1().data());
+ ALOGD("Loading data (%s) ...", data.latin1().data());
ResourceHandleClient* client = m_handle->client();
int index = data.find(',');
if (index == -1) {
@@ -141,7 +141,7 @@ static String mimeTypeForExtension(const String& file)
void MyResourceLoader::loadFile(const String& file)
{
- LOGD("Loading file (%s) ...", file.latin1().data());
+ ALOGD("Loading file (%s) ...", file.latin1().data());
FILE* f = fopen(file.latin1().data(), "r");
ResourceHandleClient* client = m_handle->client();
if (!f) {
@@ -178,7 +178,7 @@ PassRefPtr<WebCore::ResourceLoaderAndroid> MyWebFrame::startLoadingResource(
void MyWebFrame::timerFired(Timer<MyWebFrame>*)
{
- LOGD("Handling requests...");
+ ALOGD("Handling requests...");
Vector<RefPtr<WebCore::ResourceLoaderAndroid> > reqs;
reqs.swap(m_requests);
Vector<RefPtr<WebCore::ResourceLoaderAndroid> >::iterator i = reqs.begin();
@@ -186,5 +186,5 @@ void MyWebFrame::timerFired(Timer<MyWebFrame>*)
for (; i != end; i++)
static_cast<MyResourceLoader*>((*i).get())->handleRequest();
- LOGD("...done");
+ ALOGD("...done");
}
diff --git a/Source/WebKit/android/benchmark/main.cpp b/Source/WebKit/android/benchmark/main.cpp
index fcb797d..0dcb80b 100644
--- a/Source/WebKit/android/benchmark/main.cpp
+++ b/Source/WebKit/android/benchmark/main.cpp
@@ -47,17 +47,17 @@ int main(int argc, char** argv) {
if (x) {
width = atoi(optarg);
height = atoi(x + 1);
- LOGD("Rendering page at %dx%d", width, height);
+ ALOGD("Rendering page at %dx%d", width, height);
}
} else if (c == 'r') {
reloadCount = atoi(optarg);
if (reloadCount < 0)
reloadCount = 0;
- LOGD("Reloading %d times", reloadCount);
+ ALOGD("Reloading %d times", reloadCount);
}
}
if (optind >= argc) {
- LOGE("Please supply a file to read\n");
+ ALOGE("Please supply a file to read\n");
return 1;
}
diff --git a/Source/WebKit/android/jni/CacheManager.cpp b/Source/WebKit/android/jni/CacheManager.cpp
index f600d00..d319054 100644
--- a/Source/WebKit/android/jni/CacheManager.cpp
+++ b/Source/WebKit/android/jni/CacheManager.cpp
@@ -133,7 +133,7 @@ int registerCacheManager(JNIEnv* env)
{
#ifndef NDEBUG
jclass cacheManager = env->FindClass(javaCacheManagerClass);
- LOG_ASSERT(cacheManager, "Unable to find class");
+ ALOG_ASSERT(cacheManager, "Unable to find class");
env->DeleteLocalRef(cacheManager);
#endif
return jniRegisterNativeMethods(env, javaCacheManagerClass, gCacheManagerMethods, NELEM(gCacheManagerMethods));
diff --git a/Source/WebKit/android/jni/CookieManager.cpp b/Source/WebKit/android/jni/CookieManager.cpp
index f8c2dee..357d158 100644
--- a/Source/WebKit/android/jni/CookieManager.cpp
+++ b/Source/WebKit/android/jni/CookieManager.cpp
@@ -192,7 +192,7 @@ int registerCookieManager(JNIEnv* env)
{
#ifndef NDEBUG
jclass cookieManager = env->FindClass(javaCookieManagerClass);
- LOG_ASSERT(cookieManager, "Unable to find class");
+ ALOG_ASSERT(cookieManager, "Unable to find class");
env->DeleteLocalRef(cookieManager);
#endif
return jniRegisterNativeMethods(env, javaCookieManagerClass, gCookieManagerMethods, NELEM(gCookieManagerMethods));
diff --git a/Source/WebKit/android/jni/DeviceMotionAndOrientationManager.cpp b/Source/WebKit/android/jni/DeviceMotionAndOrientationManager.cpp
index 8beb372..bd63f59 100644
--- a/Source/WebKit/android/jni/DeviceMotionAndOrientationManager.cpp
+++ b/Source/WebKit/android/jni/DeviceMotionAndOrientationManager.cpp
@@ -161,7 +161,7 @@ int registerDeviceMotionAndOrientationManager(JNIEnv* env)
{
#ifndef NDEBUG
jclass deviceMotionAndOrientationManager = env->FindClass(javaDeviceMotionAndOrientationManagerClass);
- LOG_ASSERT(deviceMotionAndOrientationManager, "Unable to find class");
+ ALOG_ASSERT(deviceMotionAndOrientationManager, "Unable to find class");
env->DeleteLocalRef(deviceMotionAndOrientationManager);
#endif
diff --git a/Source/WebKit/android/jni/GeolocationPermissionsBridge.cpp b/Source/WebKit/android/jni/GeolocationPermissionsBridge.cpp
index a366601..2c1db3f 100755
--- a/Source/WebKit/android/jni/GeolocationPermissionsBridge.cpp
+++ b/Source/WebKit/android/jni/GeolocationPermissionsBridge.cpp
@@ -102,7 +102,7 @@ int registerGeolocationPermissions(JNIEnv* env)
const char* kGeolocationPermissionsClass = "android/webkit/GeolocationPermissions";
#ifndef NDEBUG
jclass geolocationPermissions = env->FindClass(kGeolocationPermissionsClass);
- LOG_ASSERT(geolocationPermissions, "Unable to find class");
+ ALOG_ASSERT(geolocationPermissions, "Unable to find class");
env->DeleteLocalRef(geolocationPermissions);
#endif
diff --git a/Source/WebKit/android/jni/JavaBridge.cpp b/Source/WebKit/android/jni/JavaBridge.cpp
index 68eb367..204ac4e 100644
--- a/Source/WebKit/android/jni/JavaBridge.cpp
+++ b/Source/WebKit/android/jni/JavaBridge.cpp
@@ -41,9 +41,6 @@
#include "PluginDatabase.h"
#include "Timer.h"
#include "TimerClient.h"
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
#include "WebCache.h"
#include "WebCoreJni.h"
@@ -148,15 +145,15 @@ JavaBridge::JavaBridge(JNIEnv* env, jobject obj)
mResolveFilePathForContentUri = env->GetMethodID(clazz, "resolveFilePathForContentUri", "(Ljava/lang/String;)Ljava/lang/String;");
env->DeleteLocalRef(clazz);
- LOG_ASSERT(mSetSharedTimer, "Could not find method setSharedTimer");
- LOG_ASSERT(mStopSharedTimer, "Could not find method stopSharedTimer");
- LOG_ASSERT(mSetCookies, "Could not find method setCookies");
- LOG_ASSERT(mCookies, "Could not find method cookies");
- LOG_ASSERT(mCookiesEnabled, "Could not find method cookiesEnabled");
- LOG_ASSERT(mGetPluginDirectories, "Could not find method getPluginDirectories");
- LOG_ASSERT(mGetPluginSharedDataDirectory, "Could not find method getPluginSharedDataDirectory");
- LOG_ASSERT(mGetKeyStrengthList, "Could not find method getKeyStrengthList");
- LOG_ASSERT(mGetSignedPublicKey, "Could not find method getSignedPublicKey");
+ ALOG_ASSERT(mSetSharedTimer, "Could not find method setSharedTimer");
+ ALOG_ASSERT(mStopSharedTimer, "Could not find method stopSharedTimer");
+ ALOG_ASSERT(mSetCookies, "Could not find method setCookies");
+ ALOG_ASSERT(mCookies, "Could not find method cookies");
+ ALOG_ASSERT(mCookiesEnabled, "Could not find method cookiesEnabled");
+ ALOG_ASSERT(mGetPluginDirectories, "Could not find method getPluginDirectories");
+ ALOG_ASSERT(mGetPluginSharedDataDirectory, "Could not find method getPluginSharedDataDirectory");
+ ALOG_ASSERT(mGetKeyStrengthList, "Could not find method getKeyStrengthList");
+ ALOG_ASSERT(mGetSignedPublicKey, "Could not find method getSignedPublicKey");
JavaSharedClient::SetTimerClient(this);
JavaSharedClient::SetCookieClient(this);
@@ -283,7 +280,7 @@ JavaBridge::getPluginSharedDataDirectory()
void
JavaBridge::setSharedTimerCallback(void (*f)())
{
- LOG_ASSERT(!sSharedTimerFiredCallback || sSharedTimerFiredCallback==f,
+ ALOG_ASSERT(!sSharedTimerFiredCallback || sSharedTimerFiredCallback==f,
"Shared timer callback may already be set or null!");
sSharedTimerFiredCallback = f;
@@ -363,8 +360,8 @@ void JavaBridge::Finalize(JNIEnv* env, jobject obj)
{
JavaBridge* javaBridge = (JavaBridge*)
(env->GetIntField(obj, gJavaBridge_ObjectID));
- LOG_ASSERT(javaBridge, "Finalize should not be called twice for the same java bridge!");
- LOGV("webcore_javabridge::nativeFinalize(%p)\n", javaBridge);
+ ALOG_ASSERT(javaBridge, "Finalize should not be called twice for the same java bridge!");
+ ALOGV("webcore_javabridge::nativeFinalize(%p)\n", javaBridge);
delete javaBridge;
env->SetIntField(obj, gJavaBridge_ObjectID, 0);
}
@@ -374,14 +371,8 @@ void JavaBridge::SharedTimerFired(JNIEnv* env, jobject)
{
if (sSharedTimerFiredCallback)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounter::start(TimeCounter::SharedTimerTimeCounter);
-#endif
SkAutoMemoryUsageProbe mup("JavaBridge::sharedTimerFired");
sSharedTimerFiredCallback();
-#ifdef ANDROID_INSTRUMENT
- TimeCounter::record(TimeCounter::SharedTimerTimeCounter, __FUNCTION__);
-#endif
}
}
diff --git a/Source/WebKit/android/jni/JniUtil.cpp b/Source/WebKit/android/jni/JniUtil.cpp
index ee1e3f9..651016e 100644
--- a/Source/WebKit/android/jni/JniUtil.cpp
+++ b/Source/WebKit/android/jni/JniUtil.cpp
@@ -49,7 +49,7 @@ int registerJniUtil(JNIEnv* env)
{
#ifndef NDEBUG
jclass jniUtil = env->FindClass(javaJniUtilClass);
- LOG_ASSERT(jniUtil, "Unable to find class");
+ ALOG_ASSERT(jniUtil, "Unable to find class");
env->DeleteLocalRef(jniUtil);
#endif
return jniRegisterNativeMethods(env, javaJniUtilClass, gJniUtilMethods, NELEM(gJniUtilMethods));
diff --git a/Source/WebKit/android/jni/MIMETypeRegistry.cpp b/Source/WebKit/android/jni/MIMETypeRegistry.cpp
index cbfef6c..2734aeb 100644
--- a/Source/WebKit/android/jni/MIMETypeRegistry.cpp
+++ b/Source/WebKit/android/jni/MIMETypeRegistry.cpp
@@ -44,11 +44,11 @@ String MIMETypeRegistry::getMIMETypeForExtension(const String& ext)
ASSERT(isMainThread());
JNIEnv* env = JSC::Bindings::getJNIEnv();
jclass mimeClass = env->FindClass("android/webkit/MimeTypeMap");
- LOG_ASSERT(mimeClass, "Could not find class MimeTypeMap");
+ ALOG_ASSERT(mimeClass, "Could not find class MimeTypeMap");
jmethodID mimeTypeFromExtension = env->GetStaticMethodID(mimeClass,
"mimeTypeFromExtension",
"(Ljava/lang/String;)Ljava/lang/String;");
- LOG_ASSERT(mimeTypeFromExtension,
+ ALOG_ASSERT(mimeTypeFromExtension,
"Could not find method mimeTypeFromExtension");
jstring extString = wtfStringToJstring(env, ext);
jobject mimeType = env->CallStaticObjectMethod(mimeClass,
diff --git a/Source/WebKit/android/jni/MockGeolocation.cpp b/Source/WebKit/android/jni/MockGeolocation.cpp
index 1370715..250953f 100755
--- a/Source/WebKit/android/jni/MockGeolocation.cpp
+++ b/Source/WebKit/android/jni/MockGeolocation.cpp
@@ -74,7 +74,7 @@ int registerMockGeolocation(JNIEnv* env)
{
#ifndef NDEBUG
jclass mockGeolocation = env->FindClass(javaMockGeolocationClass);
- LOG_ASSERT(mockGeolocation, "Unable to find class");
+ ALOG_ASSERT(mockGeolocation, "Unable to find class");
env->DeleteLocalRef(mockGeolocation);
#endif
diff --git a/Source/WebKit/android/jni/PictureSet.cpp b/Source/WebKit/android/jni/PictureSet.cpp
index 4d9d16c..1d50074 100644
--- a/Source/WebKit/android/jni/PictureSet.cpp
+++ b/Source/WebKit/android/jni/PictureSet.cpp
@@ -36,7 +36,6 @@
#include "SkRect.h"
#include "SkRegion.h"
#include "SkStream.h"
-#include "TimeCounter.h"
#define MAX_DRAW_TIME 100
#define MIN_SPLITTABLE 400
@@ -693,6 +692,22 @@ void PictureSet::clear()
mWidth = mHeight = 0;
}
+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
+}
+
bool PictureSet::draw(SkCanvas* canvas)
{
#ifdef FAST_PICTURESET
@@ -835,7 +850,7 @@ void PictureSet::dump(const char* label) const
MeasureStream measure;
if (working->mPicture != NULL)
working->mPicture->serialize(&measure);
- LOGD(" [%d]"
+ ALOGD(" [%d]"
" mArea.bounds={%d,%d,r=%d,b=%d}"
" mPicture=%p"
" mUnsplit={%d,%d,r=%d,b=%d}"
@@ -1184,24 +1199,24 @@ bool PictureSet::validate(const char* funct) const
const SkIRect& bounds = area.getBounds();
bool localValid = false;
if (working->mUnsplit.isEmpty())
- LOGD("%s working->mUnsplit.isEmpty()", funct);
+ ALOGD("%s working->mUnsplit.isEmpty()", funct);
else if (working->mUnsplit.contains(bounds) == false)
- LOGD("%s working->mUnsplit.contains(bounds) == false", funct);
+ ALOGD("%s working->mUnsplit.contains(bounds) == false", funct);
else if (working->mElapsed >= 1000)
- LOGD("%s working->mElapsed >= 1000", funct);
+ ALOGD("%s working->mElapsed >= 1000", funct);
else if ((working->mSplit & 0xfe) != 0)
- LOGD("%s (working->mSplit & 0xfe) != 0", funct);
+ ALOGD("%s (working->mSplit & 0xfe) != 0", funct);
else if ((working->mWroteElapsed & 0xfe) != 0)
- LOGD("%s (working->mWroteElapsed & 0xfe) != 0", funct);
+ ALOGD("%s (working->mWroteElapsed & 0xfe) != 0", funct);
else if (pict != NULL) {
int pictWidth = pict->width();
int pictHeight = pict->height();
if (pictWidth < bounds.width())
- LOGD("%s pictWidth=%d < bounds.width()=%d", funct, pictWidth, bounds.width());
+ ALOGD("%s pictWidth=%d < bounds.width()=%d", funct, pictWidth, bounds.width());
else if (pictHeight < bounds.height())
- LOGD("%s pictHeight=%d < bounds.height()=%d", funct, pictHeight, bounds.height());
+ ALOGD("%s pictHeight=%d < bounds.height()=%d", funct, pictHeight, bounds.height());
else if (working->mArea.isEmpty())
- LOGD("%s working->mArea.isEmpty()", funct);
+ ALOGD("%s working->mArea.isEmpty()", funct);
else
localValid = true;
} else
@@ -1209,7 +1224,7 @@ bool PictureSet::validate(const char* funct) const
working->mArea.validate();
if (localValid == false) {
if (all.contains(area) == true)
- LOGD("%s all.contains(area) == true", funct);
+ ALOGD("%s all.contains(area) == true", funct);
else
localValid = true;
}
@@ -1220,9 +1235,9 @@ bool PictureSet::validate(const char* funct) const
if (valid) {
valid = false;
if (allBounds.width() != mWidth)
- LOGD("%s allBounds.width()=%d != mWidth=%d", funct, allBounds.width(), mWidth);
+ ALOGD("%s allBounds.width()=%d != mWidth=%d", funct, allBounds.width(), mWidth);
else if (allBounds.height() != mHeight)
- LOGD("%s allBounds.height()=%d != mHeight=%d", funct, allBounds.height(), mHeight);
+ ALOGD("%s allBounds.height()=%d != mHeight=%d", funct, allBounds.height(), mHeight);
else
valid = true;
}
diff --git a/Source/WebKit/android/jni/PictureSet.h b/Source/WebKit/android/jni/PictureSet.h
index fe47361..97d91e0 100644
--- a/Source/WebKit/android/jni/PictureSet.h
+++ b/Source/WebKit/android/jni/PictureSet.h
@@ -31,9 +31,9 @@
#define PICTURE_SET_VALIDATE 0
#if PICTURE_SET_DEBUG
-#define DBG_SET_LOG(message) LOGD("%s %s", __FUNCTION__, message)
-#define DBG_SET_LOGD(format, ...) LOGD("%s " format, __FUNCTION__, __VA_ARGS__)
-#define DEBUG_SET_UI_LOGD(...) LOGD(__VA_ARGS__)
+#define DBG_SET_LOG(message) ALOGD("%s %s", __FUNCTION__, message)
+#define DBG_SET_LOGD(format, ...) ALOGD("%s " format, __FUNCTION__, __VA_ARGS__)
+#define DEBUG_SET_UI_LOGD(...) ALOGD(__VA_ARGS__)
#else
#define DBG_SET_LOG(message) ((void)0)
#define DBG_SET_LOGD(format, ...) ((void)0)
diff --git a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
index d53ddb6..adacb49 100644
--- a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -116,13 +116,8 @@
#elif USE(V8)
#include "JavaNPObjectV8.h"
#include "JavaInstanceJobjectV8.h"
-#include "V8Counters.h"
#endif // USE(JSC)
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
-
#if ENABLE(WEB_AUTOFILL)
#include "autofill/WebAutofill.h"
#endif
@@ -301,38 +296,38 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page*
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
env->DeleteLocalRef(clazz);
- LOG_ASSERT(mJavaFrame->mStartLoadingResource, "Could not find method startLoadingResource");
- LOG_ASSERT(mJavaFrame->mMaybeSavePassword, "Could not find method maybeSavePassword");
- LOG_ASSERT(mJavaFrame->mShouldInterceptRequest, "Could not find method shouldInterceptRequest");
- LOG_ASSERT(mJavaFrame->mLoadStarted, "Could not find method loadStarted");
- LOG_ASSERT(mJavaFrame->mTransitionToCommitted, "Could not find method transitionToCommitted");
- LOG_ASSERT(mJavaFrame->mLoadFinished, "Could not find method loadFinished");
- LOG_ASSERT(mJavaFrame->mReportError, "Could not find method reportError");
- LOG_ASSERT(mJavaFrame->mSetTitle, "Could not find method setTitle");
- LOG_ASSERT(mJavaFrame->mWindowObjectCleared, "Could not find method windowObjectCleared");
- LOG_ASSERT(mJavaFrame->mSetProgress, "Could not find method setProgress");
- LOG_ASSERT(mJavaFrame->mDidReceiveIcon, "Could not find method didReceiveIcon");
- LOG_ASSERT(mJavaFrame->mDidReceiveTouchIconUrl, "Could not find method didReceiveTouchIconUrl");
- LOG_ASSERT(mJavaFrame->mUpdateVisitedHistory, "Could not find method updateVisitedHistory");
- LOG_ASSERT(mJavaFrame->mHandleUrl, "Could not find method handleUrl");
- LOG_ASSERT(mJavaFrame->mCreateWindow, "Could not find method createWindow");
- LOG_ASSERT(mJavaFrame->mCloseWindow, "Could not find method closeWindow");
- LOG_ASSERT(mJavaFrame->mDecidePolicyForFormResubmission, "Could not find method decidePolicyForFormResubmission");
- 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");
- LOG_ASSERT(mJavaFrame->mDidReceiveAuthenticationChallenge, "Could not find method didReceiveAuthenticationChallenge");
- LOG_ASSERT(mJavaFrame->mReportSslCertError, "Could not find method reportSslCertError");
- LOG_ASSERT(mJavaFrame->mRequestClientCert, "Could not find method requestClientCert");
- LOG_ASSERT(mJavaFrame->mDownloadStart, "Could not find method downloadStart");
- LOG_ASSERT(mJavaFrame->mDidReceiveData, "Could not find method didReceiveData");
- LOG_ASSERT(mJavaFrame->mDidFinishLoading, "Could not find method didFinishLoading");
- LOG_ASSERT(mJavaFrame->mSetCertificate, "Could not find method setCertificate");
- LOG_ASSERT(mJavaFrame->mShouldSaveFormData, "Could not find method shouldSaveFormData");
- LOG_ASSERT(mJavaFrame->mSaveFormData, "Could not find method saveFormData");
- LOG_ASSERT(mJavaFrame->mAutoLogin, "Could not find method autoLogin");
+ ALOG_ASSERT(mJavaFrame->mStartLoadingResource, "Could not find method startLoadingResource");
+ ALOG_ASSERT(mJavaFrame->mMaybeSavePassword, "Could not find method maybeSavePassword");
+ ALOG_ASSERT(mJavaFrame->mShouldInterceptRequest, "Could not find method shouldInterceptRequest");
+ ALOG_ASSERT(mJavaFrame->mLoadStarted, "Could not find method loadStarted");
+ ALOG_ASSERT(mJavaFrame->mTransitionToCommitted, "Could not find method transitionToCommitted");
+ ALOG_ASSERT(mJavaFrame->mLoadFinished, "Could not find method loadFinished");
+ ALOG_ASSERT(mJavaFrame->mReportError, "Could not find method reportError");
+ ALOG_ASSERT(mJavaFrame->mSetTitle, "Could not find method setTitle");
+ ALOG_ASSERT(mJavaFrame->mWindowObjectCleared, "Could not find method windowObjectCleared");
+ ALOG_ASSERT(mJavaFrame->mSetProgress, "Could not find method setProgress");
+ ALOG_ASSERT(mJavaFrame->mDidReceiveIcon, "Could not find method didReceiveIcon");
+ ALOG_ASSERT(mJavaFrame->mDidReceiveTouchIconUrl, "Could not find method didReceiveTouchIconUrl");
+ ALOG_ASSERT(mJavaFrame->mUpdateVisitedHistory, "Could not find method updateVisitedHistory");
+ ALOG_ASSERT(mJavaFrame->mHandleUrl, "Could not find method handleUrl");
+ ALOG_ASSERT(mJavaFrame->mCreateWindow, "Could not find method createWindow");
+ ALOG_ASSERT(mJavaFrame->mCloseWindow, "Could not find method closeWindow");
+ ALOG_ASSERT(mJavaFrame->mDecidePolicyForFormResubmission, "Could not find method decidePolicyForFormResubmission");
+ ALOG_ASSERT(mJavaFrame->mRequestFocus, "Could not find method requestFocus");
+ ALOG_ASSERT(mJavaFrame->mGetRawResFilename, "Could not find method getRawResFilename");
+ ALOG_ASSERT(mJavaFrame->mDensity, "Could not find method density");
+ ALOG_ASSERT(mJavaFrame->mGetFileSize, "Could not find method getFileSize");
+ ALOG_ASSERT(mJavaFrame->mGetFile, "Could not find method getFile");
+ ALOG_ASSERT(mJavaFrame->mDidReceiveAuthenticationChallenge, "Could not find method didReceiveAuthenticationChallenge");
+ ALOG_ASSERT(mJavaFrame->mReportSslCertError, "Could not find method reportSslCertError");
+ ALOG_ASSERT(mJavaFrame->mRequestClientCert, "Could not find method requestClientCert");
+ ALOG_ASSERT(mJavaFrame->mDownloadStart, "Could not find method downloadStart");
+ ALOG_ASSERT(mJavaFrame->mDidReceiveData, "Could not find method didReceiveData");
+ ALOG_ASSERT(mJavaFrame->mDidFinishLoading, "Could not find method didFinishLoading");
+ ALOG_ASSERT(mJavaFrame->mSetCertificate, "Could not find method setCertificate");
+ ALOG_ASSERT(mJavaFrame->mShouldSaveFormData, "Could not find method shouldSaveFormData");
+ ALOG_ASSERT(mJavaFrame->mSaveFormData, "Could not find method saveFormData");
+ ALOG_ASSERT(mJavaFrame->mAutoLogin, "Could not find method autoLogin");
mUserAgent = WTF::String();
mUserInitiatedAction = false;
@@ -362,14 +357,14 @@ WebFrame* WebFrame::getWebFrame(const WebCore::Frame* frame)
static jobject createJavaMapFromHTTPHeaders(JNIEnv* env, const WebCore::HTTPHeaderMap& map)
{
jclass mapClass = env->FindClass("java/util/HashMap");
- LOG_ASSERT(mapClass, "Could not find HashMap class!");
+ ALOG_ASSERT(mapClass, "Could not find HashMap class!");
jmethodID init = env->GetMethodID(mapClass, "<init>", "(I)V");
- LOG_ASSERT(init, "Could not find constructor for HashMap");
+ ALOG_ASSERT(init, "Could not find constructor for HashMap");
jobject hashMap = env->NewObject(mapClass, init, map.size());
- LOG_ASSERT(hashMap, "Could not create a new HashMap");
+ ALOG_ASSERT(hashMap, "Could not create a new HashMap");
jmethodID put = env->GetMethodID(mapClass, "put",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
- LOG_ASSERT(put, "Could not find put method on HashMap");
+ ALOG_ASSERT(put, "Could not find put method on HashMap");
WebCore::HTTPHeaderMap::const_iterator end = map.end();
for (WebCore::HTTPHeaderMap::const_iterator i = map.begin(); i != end; ++i) {
@@ -422,10 +417,7 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader,
bool mainResource,
bool synchronous)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
- LOGV("::WebCore:: startLoadingResource(%p, %s)",
+ ALOGV("::WebCore:: startLoadingResource(%p, %s)",
loader, request.url().string().latin1().data());
JNIEnv* env = getJNIEnv();
@@ -449,7 +441,7 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader,
+ urlStr.substring(colon);
}
}
- LOGV("%s lower=%s", __FUNCTION__, urlStr.latin1().data());
+ ALOGV("%s lower=%s", __FUNCTION__, urlStr.latin1().data());
jstring jUrlStr = wtfStringToJstring(env, urlStr);
jstring jMethodStr = NULL;
if (!method.isEmpty())
@@ -475,7 +467,7 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader,
break;
}
- LOGV("::WebCore:: startLoadingResource %s with cacheMode %d", urlStr.ascii().data(), cacheMode);
+ ALOGV("::WebCore:: startLoadingResource %s with cacheMode %d", urlStr.ascii().data(), cacheMode);
ResourceHandleInternal* loaderInternal = loader->getInternal();
jstring jUsernameString = loaderInternal->m_user.isEmpty() ?
@@ -500,7 +492,7 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader,
if (checkException(env))
return 0;
- PassRefPtr<WebCore::ResourceLoaderAndroid> h;
+ RefPtr<WebCore::ResourceLoaderAndroid> h;
if (jLoadListener)
h = WebCoreResourceLoader::create(env, jLoadListener);
env->DeleteLocalRef(jLoadListener);
@@ -510,10 +502,7 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader,
UrlInterceptResponse*
WebFrame::shouldInterceptRequest(const WTF::String& url)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
- LOGV("::WebCore:: shouldInterceptRequest(%s)", url.latin1().data());
+ ALOGV("::WebCore:: shouldInterceptRequest(%s)", url.latin1().data());
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
@@ -534,10 +523,7 @@ void
WebFrame::reportError(int errorCode, const WTF::String& description,
const WTF::String& failingUrl)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
- LOGV("::WebCore:: reportError(%d, %s)", errorCode, description.ascii().data());
+ ALOGV("::WebCore:: reportError(%d, %s)", errorCode, description.ascii().data());
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -573,9 +559,6 @@ WebFrame::convertIDNToUnicode(const WebCore::KURL& url) {
void
WebFrame::loadStarted(WebCore::Frame* frame)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -589,7 +572,7 @@ WebFrame::loadStarted(WebCore::Frame* frame)
const WebCore::KURL& url = documentLoader->url();
if (url.isEmpty())
return;
- LOGV("::WebCore:: loadStarted %s", url.string().ascii().data());
+ ALOGV("::WebCore:: loadStarted %s", url.string().ascii().data());
bool isMainFrame = (!frame->tree() || !frame->tree()->parent());
WebCore::FrameLoadType loadType = frame->loader()->loadType();
@@ -609,7 +592,7 @@ WebFrame::loadStarted(WebCore::Frame* frame)
WebCore::Image* icon = WebCore::iconDatabase().synchronousIconForPageURL(urlString, WebCore::IntSize(16, 16));
if (icon)
favicon = webcoreImageToJavaBitmap(env, icon);
- LOGV("favicons", "Starting load with icon %p for %s", icon, url.string().utf8().data());
+ ALOGV("favicons", "Starting load with icon %p for %s", icon, url.string().utf8().data());
}
jstring urlStr = wtfStringToJstring(env, urlString);
@@ -633,9 +616,6 @@ WebFrame::loadStarted(WebCore::Frame* frame)
void
WebFrame::transitionToCommitted(WebCore::Frame* frame)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -650,9 +630,6 @@ WebFrame::transitionToCommitted(WebCore::Frame* frame)
void
WebFrame::didFinishLoad(WebCore::Frame* frame)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -667,7 +644,7 @@ WebFrame::didFinishLoad(WebCore::Frame* frame)
const WebCore::KURL& url = documentLoader->url();
if (url.isEmpty())
return;
- LOGV("::WebCore:: didFinishLoad %s", url.string().ascii().data());
+ ALOGV("::WebCore:: didFinishLoad %s", url.string().ascii().data());
bool isMainFrame = (!frame->tree() || !frame->tree()->parent());
WebCore::FrameLoadType loadType = loader->loadType();
@@ -681,10 +658,7 @@ WebFrame::didFinishLoad(WebCore::Frame* frame)
void
WebFrame::addHistoryItem(WebCore::HistoryItem* item)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
- LOGV("::WebCore:: addHistoryItem");
+ ALOGV("::WebCore:: addHistoryItem");
JNIEnv* env = getJNIEnv();
WebHistory::AddItem(mJavaFrame->history(env), item);
}
@@ -692,10 +666,7 @@ WebFrame::addHistoryItem(WebCore::HistoryItem* item)
void
WebFrame::removeHistoryItem(int index)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
- LOGV("::WebCore:: removeHistoryItem at %d", index);
+ ALOGV("::WebCore:: removeHistoryItem at %d", index);
JNIEnv* env = getJNIEnv();
WebHistory::RemoveItem(mJavaFrame->history(env), index);
}
@@ -703,10 +674,7 @@ WebFrame::removeHistoryItem(int index)
void
WebFrame::updateHistoryIndex(int newIndex)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
- LOGV("::WebCore:: updateHistoryIndex to %d", newIndex);
+ ALOGV("::WebCore:: updateHistoryIndex to %d", newIndex);
JNIEnv* env = getJNIEnv();
WebHistory::UpdateHistoryIndex(mJavaFrame->history(env), newIndex);
}
@@ -714,11 +682,8 @@ WebFrame::updateHistoryIndex(int newIndex)
void
WebFrame::setTitle(const WTF::String& title)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
#ifndef NDEBUG
- LOGV("setTitle(%s)", title.ascii().data());
+ ALOGV("setTitle(%s)", title.ascii().data());
#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
@@ -735,10 +700,7 @@ WebFrame::setTitle(const WTF::String& title)
void
WebFrame::windowObjectCleared(WebCore::Frame* frame)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
- LOGV("::WebCore:: windowObjectCleared");
+ ALOGV("::WebCore:: windowObjectCleared");
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -751,9 +713,6 @@ WebFrame::windowObjectCleared(WebCore::Frame* frame)
void
WebFrame::setProgress(float newProgress)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -773,10 +732,7 @@ WebFrame::userAgentForURL(const WebCore::KURL* url)
void
WebFrame::didReceiveIcon(WebCore::Image* icon)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
- LOG_ASSERT(icon, "DidReceiveIcon called without an image!");
+ ALOG_ASSERT(icon, "DidReceiveIcon called without an image!");
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -794,9 +750,6 @@ WebFrame::didReceiveIcon(WebCore::Image* icon)
void
WebFrame::didReceiveTouchIconURL(const WTF::String& url, bool precomposed)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -812,9 +765,6 @@ WebFrame::didReceiveTouchIconURL(const WTF::String& url, bool precomposed)
void
WebFrame::updateVisitedHistory(const WebCore::KURL& url, bool reload)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -831,9 +781,6 @@ WebFrame::updateVisitedHistory(const WebCore::KURL& url, bool reload)
bool
WebFrame::canHandleRequest(const WebCore::ResourceRequest& request)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -874,9 +821,6 @@ WebFrame::shouldSaveFormData()
WebCore::Frame*
WebFrame::createWindow(bool dialog, bool userGesture)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -890,9 +834,6 @@ WebFrame::createWindow(bool dialog, bool userGesture)
void
WebFrame::requestFocus() const
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -904,9 +845,6 @@ WebFrame::requestFocus() const
void
WebFrame::closeWindow(WebViewCore* webViewCore)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
assert(webViewCore);
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
@@ -925,9 +863,6 @@ struct PolicyFunctionWrapper {
void
WebFrame::decidePolicyForFormResubmission(WebCore::FramePolicyFunction func)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -965,9 +900,6 @@ WebFrame::density() const
void
WebFrame::didReceiveAuthenticationChallenge(WebUrlLoaderClient* client, const std::string& host, const std::string& realm, bool useCachedCredentials, bool suppressDialog)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -985,9 +917,6 @@ WebFrame::didReceiveAuthenticationChallenge(WebUrlLoaderClient* client, const st
void
WebFrame::reportSslCertError(WebUrlLoaderClient* client, int error, const std::string& cert, const std::string& url)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -1008,9 +937,6 @@ WebFrame::reportSslCertError(WebUrlLoaderClient* client, int error, const std::s
void
WebFrame::requestClientCert(WebUrlLoaderClient* client, const std::string& hostAndPort)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
int jHandle = reinterpret_cast<int>(client);
@@ -1024,9 +950,6 @@ WebFrame::requestClientCert(WebUrlLoaderClient* client, const std::string& hostA
void
WebFrame::downloadStart(const std::string& url, const std::string& userAgent, const std::string& contentDisposition, const std::string& mimetype, long long contentLength)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -1047,9 +970,6 @@ WebFrame::downloadStart(const std::string& url, const std::string& userAgent, co
void
WebFrame::didReceiveData(const char* data, int size) {
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -1064,9 +984,6 @@ WebFrame::didReceiveData(const char* data, int size) {
void
WebFrame::didFinishLoading() {
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -1078,9 +995,6 @@ WebFrame::didFinishLoading() {
void WebFrame::setCertificate(const std::string& cert)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -1098,9 +1012,6 @@ void WebFrame::setCertificate(const std::string& cert)
void WebFrame::autoLogin(const std::string& loginHeader)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimerCoutner::JavaCallbackTimeCounter);
-#endif
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
if (!javaFrame.get())
@@ -1174,7 +1085,7 @@ void WebFrame::maybeSavePassword(WebCore::Frame* frame, const WebCore::ResourceR
bool WebFrame::getUsernamePasswordFromDom(WebCore::Frame* frame, WTF::String& username, WTF::String& password)
{
bool found = false;
- WTF::PassRefPtr<WebCore::HTMLCollection> form = frame->document()->forms();
+ WTF::RefPtr<WebCore::HTMLCollection> form = frame->document()->forms();
WebCore::Node* node = form->firstItem();
while (node && !found && !node->namespaceURI().isNull() &&
!node->namespaceURI().isEmpty()) {
@@ -1271,13 +1182,10 @@ jbyteArray WebFrame::getPostData(const WebCore::ResourceRequest& request)
static void CallPolicyFunction(JNIEnv* env, jobject obj, jint func, jint decision)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "nativeCallPolicyFunction must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "nativeCallPolicyFunction must take a valid frame pointer!");
PolicyFunctionWrapper* pFunc = (PolicyFunctionWrapper*)func;
- LOG_ASSERT(pFunc, "nativeCallPolicyFunction must take a valid function pointer!");
+ ALOG_ASSERT(pFunc, "nativeCallPolicyFunction must take a valid function pointer!");
// If we are resending the form then we should reset the multiple submission protection.
if (decision == WebCore::PolicyUse)
@@ -1295,12 +1203,6 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss
initChromium();
#endif
-#ifdef ANDROID_INSTRUMENT
-#if USE(V8)
- V8Counters::initCounters();
-#endif
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
// Create a new page
ChromeClientAndroid* chromeC = new ChromeClientAndroid;
EditorClientAndroid* editorC = new EditorClientAndroid;
@@ -1362,7 +1264,7 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss
WebCore::SecurityOrigin::setLocalLoadPolicy(
WebCore::SecurityOrigin::AllowLocalLoadsForLocalAndSubstituteData);
- LOGV("::WebCore:: createFrame %p", frame);
+ ALOGV("::WebCore:: createFrame %p", frame);
// Set the mNativeFrame field in Frame
SET_NATIVE_FRAME(env, obj, (int)frame);
@@ -1370,7 +1272,7 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss
String directory = webFrame->getRawResourceFilename(
WebCore::PlatformBridge::DrawableDir);
if (directory.isEmpty())
- LOGE("Can't find the drawable directory");
+ ALOGE("Can't find the drawable directory");
else {
// Initialize our skinning classes
webFrame->setRenderSkins(new WebCore::RenderSkinAndroid(directory));
@@ -1384,13 +1286,10 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss
static void DestroyFrame(JNIEnv* env, jobject obj)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "nativeDestroyFrame must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "nativeDestroyFrame must take a valid frame pointer!");
- LOGV("::WebCore:: deleting frame %p", pFrame);
+ ALOGV("::WebCore:: deleting frame %p", pFrame);
WebCore::FrameView* view = pFrame->view();
view->ref();
@@ -1415,11 +1314,8 @@ static void DestroyFrame(JNIEnv* env, jobject obj)
static void LoadUrl(JNIEnv *env, jobject obj, jstring url, jobject headers)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "nativeLoadUrl must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "nativeLoadUrl must take a valid frame pointer!");
WTF::String webcoreUrl = jstringToWtfString(env, url);
WebCore::KURL kurl(WebCore::KURL(), webcoreUrl);
@@ -1463,17 +1359,14 @@ static void LoadUrl(JNIEnv *env, jobject obj, jstring url, jobject headers)
env->DeleteLocalRef(set);
env->DeleteLocalRef(mapClass);
}
- LOGV("LoadUrl %s", kurl.string().latin1().data());
+ ALOGV("LoadUrl %s", kurl.string().latin1().data());
pFrame->loader()->load(request, false);
}
static void PostUrl(JNIEnv *env, jobject obj, jstring url, jbyteArray postData)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "nativePostUrl must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "nativePostUrl must take a valid frame pointer!");
WebCore::KURL kurl(WebCore::KURL(), jstringToWtfString(env, url));
WebCore::ResourceRequest request(kurl);
@@ -1491,7 +1384,7 @@ static void PostUrl(JNIEnv *env, jobject obj, jstring url, jbyteArray postData)
env->ReleaseByteArrayElements(postData, bytes, 0);
}
- LOGV("PostUrl %s", kurl.string().latin1().data());
+ ALOGV("PostUrl %s", kurl.string().latin1().data());
WebCore::FrameLoadRequest frameRequest(pFrame->document()->securityOrigin(), request);
pFrame->loader()->loadFrameRequest(frameRequest, false, false, 0, 0, WebCore::SendReferrer);
}
@@ -1499,20 +1392,17 @@ static void PostUrl(JNIEnv *env, jobject obj, jstring url, jbyteArray postData)
static void LoadData(JNIEnv *env, jobject obj, jstring baseUrl, jstring data,
jstring mimeType, jstring encoding, jstring failUrl)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "nativeLoadData must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "nativeLoadData must take a valid frame pointer!");
// Setup the resource request
WebCore::ResourceRequest request(jstringToWtfString(env, baseUrl));
// Setup the substituteData
const char* dataStr = env->GetStringUTFChars(data, NULL);
- WTF::PassRefPtr<WebCore::SharedBuffer> sharedBuffer =
+ WTF::RefPtr<WebCore::SharedBuffer> sharedBuffer =
WebCore::SharedBuffer::create();
- LOG_ASSERT(dataStr, "nativeLoadData has a null data string.");
+ ALOG_ASSERT(dataStr, "nativeLoadData has a null data string.");
sharedBuffer->append(dataStr, strlen(dataStr));
env->ReleaseStringUTFChars(data, dataStr);
@@ -1526,12 +1416,9 @@ static void LoadData(JNIEnv *env, jobject obj, jstring baseUrl, jstring data,
static void StopLoading(JNIEnv *env, jobject obj)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "nativeStopLoading must take a valid frame pointer!");
- LOGV("::WebCore:: stopLoading %p", pFrame);
+ ALOG_ASSERT(pFrame, "nativeStopLoading must take a valid frame pointer!");
+ ALOGV("::WebCore:: stopLoading %p", pFrame);
// Stop loading the page and do not send an unload event
pFrame->loader()->stopForUserCancel();
@@ -1579,7 +1466,7 @@ static jstring SaveWebArchive(JNIEnv *env, jobject obj, jstring basename, jboole
{
#if ENABLE(WEB_ARCHIVE)
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "nativeSaveWebArchive must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "nativeSaveWebArchive must take a valid frame pointer!");
String mimeType = pFrame->loader()->documentLoader()->mainResource()->mimeType();
if ((mimeType != "text/html") && (mimeType != "application/xhtml+xml"))
return NULL;
@@ -1597,7 +1484,7 @@ static jstring SaveWebArchive(JNIEnv *env, jobject obj, jstring basename, jboole
}
if (filename.isNull() || filename.isEmpty()) {
- LOGD("saveWebArchive: Failed to select a filename to save.");
+ ALOGD("saveWebArchive: Failed to select a filename to save.");
releaseCharactersForJStringInEnv(env, basename, basenameNative);
return NULL;
}
@@ -1605,7 +1492,7 @@ static jstring SaveWebArchive(JNIEnv *env, jobject obj, jstring basename, jboole
const int noCompression = 0;
xmlTextWriterPtr writer = xmlNewTextWriterFilename(filename.utf8().data(), noCompression);
if (writer == NULL) {
- LOGD("saveWebArchive: Failed to initialize xml writer.");
+ ALOGD("saveWebArchive: Failed to initialize xml writer.");
releaseCharactersForJStringInEnv(env, basename, basenameNative);
return NULL;
}
@@ -1626,11 +1513,8 @@ static jstring SaveWebArchive(JNIEnv *env, jobject obj, jstring basename, jboole
static jstring ExternalRepresentation(JNIEnv *env, jobject obj)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "android_webcore_nativeExternalRepresentation must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "android_webcore_nativeExternalRepresentation must take a valid frame pointer!");
// Request external representation of the render tree
WTF::String renderDump = WebCore::externalRepresentation(pFrame);
@@ -1661,11 +1545,8 @@ static StringBuilder FrameAsText(WebCore::Frame *pFrame, jboolean dumpChildFrame
static jstring DocumentAsText(JNIEnv *env, jobject obj)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "android_webcore_nativeDocumentAsText must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "android_webcore_nativeDocumentAsText must take a valid frame pointer!");
WTF::String renderDump = FrameAsText(pFrame, false /* dumpChildFrames */).toString();
return wtfStringToJstring(env, renderDump);
@@ -1673,11 +1554,8 @@ static jstring DocumentAsText(JNIEnv *env, jobject obj)
static jstring ChildFramesAsText(JNIEnv *env, jobject obj)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "android_webcore_nativeDocumentAsText must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "android_webcore_nativeDocumentAsText must take a valid frame pointer!");
StringBuilder renderDumpBuilder;
for (unsigned i = 0; i < pFrame->tree()->childCount(); ++i) {
@@ -1689,11 +1567,8 @@ static jstring ChildFramesAsText(JNIEnv *env, jobject obj)
static void Reload(JNIEnv *env, jobject obj, jboolean allowStale)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "nativeReload must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "nativeReload must take a valid frame pointer!");
WebCore::FrameLoader* loader = pFrame->loader();
if (allowStale) {
@@ -1709,11 +1584,8 @@ static void Reload(JNIEnv *env, jobject obj, jboolean allowStale)
static void GoBackOrForward(JNIEnv *env, jobject obj, jint pos)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "nativeGoBackOrForward must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "nativeGoBackOrForward must take a valid frame pointer!");
if (pos == 1)
pFrame->page()->goForward();
@@ -1725,11 +1597,8 @@ static void GoBackOrForward(JNIEnv *env, jobject obj, jint pos)
static jobject StringByEvaluatingJavaScriptFromString(JNIEnv *env, jobject obj, jstring script)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "stringByEvaluatingJavaScriptFromString must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "stringByEvaluatingJavaScriptFromString must take a valid frame pointer!");
WebCore::ScriptValue value =
pFrame->script()->executeScript(jstringToWtfString(env, script), true);
@@ -1780,7 +1649,7 @@ private:
}
~WeakJavaInstance()
{
- LOG_ASSERT(!m_beginEndDepth, "Unbalanced calls to WeakJavaInstance::begin() / end()");
+ ALOG_ASSERT(!m_beginEndDepth, "Unbalanced calls to WeakJavaInstance::begin() / end()");
JNIEnv* env = getJNIEnv();
// The JavaInstance destructor attempts to delete the global ref stored
// in m_instance. Since we replaced it in our constructor with a weak
@@ -1831,19 +1700,16 @@ private:
static void AddJavascriptInterface(JNIEnv *env, jobject obj, jint nativeFramePointer,
jobject javascriptObj, jstring interfaceName)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = 0;
if (nativeFramePointer == 0)
pFrame = GET_NATIVE_FRAME(env, obj);
else
pFrame = (WebCore::Frame*)nativeFramePointer;
- LOG_ASSERT(pFrame, "nativeAddJavascriptInterface must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "nativeAddJavascriptInterface must take a valid frame pointer!");
JavaVM* vm;
env->GetJavaVM(&vm);
- LOGV("::WebCore:: addJSInterface: %p", pFrame);
+ ALOGV("::WebCore:: addJSInterface: %p", pFrame);
#if USE(JSC)
// Copied from qwebframe.cpp
@@ -1893,17 +1759,11 @@ static void AddJavascriptInterface(JNIEnv *env, jobject obj, jint nativeFramePoi
static void SetCacheDisabled(JNIEnv *env, jobject obj, jboolean disabled)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::memoryCache()->setDisabled(disabled);
}
static jboolean CacheDisabled(JNIEnv *env, jobject obj)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
return WebCore::memoryCache()->disabled();
}
@@ -1936,17 +1796,6 @@ static void ClearWebViewCache()
static void ClearCache(JNIEnv *env, jobject obj)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#if USE(JSC)
- JSC::JSLock lock(false);
- JSC::Heap::Statistics jsHeapStatistics = WebCore::JSDOMWindow::commonJSGlobalData()->heap.statistics();
- LOGD("About to gc and JavaScript heap size is %d and has %d bytes free",
- jsHeapStatistics.size, jsHeapStatistics.free);
-#endif // USE(JSC)
- LOGD("About to clear cache and current cache has %d bytes live and %d bytes dead",
- memoryCache()->getLiveSize(), memoryCache()->getDeadSize());
-#endif // ANDROID_INSTRUMENT
ClearWebCoreCache();
ClearWebViewCache();
#if USE(JSC)
@@ -1960,25 +1809,19 @@ static void ClearCache(JNIEnv *env, jobject obj)
static jboolean DocumentHasImages(JNIEnv *env, jobject obj)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "DocumentHasImages must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "DocumentHasImages must take a valid frame pointer!");
return pFrame->document()->images()->length() > 0;
}
static jboolean HasPasswordField(JNIEnv *env, jobject obj)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "HasPasswordField must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "HasPasswordField must take a valid frame pointer!");
bool found = false;
- WTF::PassRefPtr<WebCore::HTMLCollection> form = pFrame->document()->forms();
+ WTF::RefPtr<WebCore::HTMLCollection> form = pFrame->document()->forms();
WebCore::Node* node = form->firstItem();
// Null/Empty namespace means that node is not created in HTMLFormElement
// class, but just normal Element class.
@@ -2001,11 +1844,8 @@ static jboolean HasPasswordField(JNIEnv *env, jobject obj)
static jobjectArray GetUsernamePassword(JNIEnv *env, jobject obj)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "GetUsernamePassword must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "GetUsernamePassword must take a valid frame pointer!");
jobjectArray strArray = NULL;
WTF::String username;
WTF::String password;
@@ -2022,16 +1862,13 @@ static jobjectArray GetUsernamePassword(JNIEnv *env, jobject obj)
static void SetUsernamePassword(JNIEnv *env, jobject obj,
jstring username, jstring password)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- LOG_ASSERT(pFrame, "SetUsernamePassword must take a valid frame pointer!");
+ ALOG_ASSERT(pFrame, "SetUsernamePassword must take a valid frame pointer!");
WebCore::HTMLInputElement* usernameEle = NULL;
WebCore::HTMLInputElement* passwordEle = NULL;
bool found = false;
- WTF::PassRefPtr<WebCore::HTMLCollection> form = pFrame->document()->forms();
+ WTF::RefPtr<WebCore::HTMLCollection> form = pFrame->document()->forms();
WebCore::Node* node = form->firstItem();
while (node && !found && !node->namespaceURI().isNull() &&
!node->namespaceURI().isEmpty()) {
@@ -2071,14 +1908,14 @@ WebFrame::saveFormData(HTMLFormElement* form)
if (form->autoComplete()) {
JNIEnv* env = getJNIEnv();
jclass mapClass = env->FindClass("java/util/HashMap");
- LOG_ASSERT(mapClass, "Could not find HashMap class!");
+ ALOG_ASSERT(mapClass, "Could not find HashMap class!");
jmethodID init = env->GetMethodID(mapClass, "<init>", "(I)V");
- LOG_ASSERT(init, "Could not find constructor for HashMap");
+ ALOG_ASSERT(init, "Could not find constructor for HashMap");
jobject hashMap = env->NewObject(mapClass, init, 1);
- LOG_ASSERT(hashMap, "Could not create a new HashMap");
+ ALOG_ASSERT(hashMap, "Could not create a new HashMap");
jmethodID put = env->GetMethodID(mapClass, "put",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
- LOG_ASSERT(put, "Could not find put method on HashMap");
+ ALOG_ASSERT(put, "Could not find put method on HashMap");
WTF::Vector<WebCore::FormAssociatedElement*> elements = form->associatedElements();
size_t size = elements.size();
for (size_t i = 0; i < size; i++) {
@@ -2093,7 +1930,7 @@ WebFrame::saveFormData(HTMLFormElement* form)
const WTF::AtomicString& name = input->name();
jstring key = wtfStringToJstring(env, name);
jstring val = wtfStringToJstring(env, value);
- LOG_ASSERT(key && val, "name or value not set");
+ ALOG_ASSERT(key && val, "name or value not set");
env->CallObjectMethod(hashMap, put, key, val);
env->DeleteLocalRef(key);
env->DeleteLocalRef(val);
@@ -2109,11 +1946,8 @@ WebFrame::saveFormData(HTMLFormElement* form)
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);
- LOGV("Sending orientation: %d", orientation);
+ ALOGV("Sending orientation: %d", orientation);
pFrame->sendOrientationChangeEvent(orientation);
}
@@ -2126,8 +1960,9 @@ static jboolean GetShouldStartScrolledRight(JNIEnv *env, jobject obj,
if (document) {
RenderStyle* style = document->renderer()->style();
WritingMode writingMode = style->writingMode();
- LOG_ASSERT(writingMode != WebCore::BottomToTopWritingMode,
- "BottomToTopWritingMode isn't supported");
+ ALOG_ASSERT(writingMode != WebCore::BottomToTopWritingMode,
+ "BottomToTopWritingMode isn't possible in any "
+ "language and cannot be specified in w3c writing-mode.");
if (writingMode == WebCore::RightToLeftWritingMode)
startScrolledRight = true; // vertical-rl pages start scrolled right
else if (writingMode == WebCore::TopToBottomWritingMode)
@@ -2246,27 +2081,27 @@ static void SslClientCert(JNIEnv *env, jobject obj, int handle, jbyteArray pkey,
static void AuthenticationProceed(JNIEnv *env, jobject obj, int handle, jstring jUsername, jstring jPassword)
{
- LOGW("Chromium authentication API called, but libchromium is not available");
+ ALOGW("Chromium authentication API called, but libchromium is not available");
}
static void AuthenticationCancel(JNIEnv *env, jobject obj, int handle)
{
- LOGW("Chromium authentication API called, but libchromium is not available");
+ ALOGW("Chromium authentication API called, but libchromium is not available");
}
static void SslCertErrorProceed(JNIEnv *env, jobject obj, int handle)
{
- LOGW("Chromium SSL API called, but libchromium is not available");
+ ALOGW("Chromium SSL API called, but libchromium is not available");
}
static void SslCertErrorCancel(JNIEnv *env, jobject obj, int handle, int cert_error)
{
- LOGW("Chromium SSL API called, but libchromium is not available");
+ ALOGW("Chromium SSL API called, but libchromium is not available");
}
static void SslClientCert(JNIEnv *env, jobject obj, int handle, jbyteArray privateKey, jobjectArray chain)
{
- LOGW("Chromium SSL API called, but libchromium is not available");
+ ALOGW("Chromium SSL API called, but libchromium is not available");
}
#endif // USE(CHROME_NETWORK_STACK)
@@ -2341,9 +2176,9 @@ static JNINativeMethod gBrowserFrameNativeMethods[] = {
int registerWebFrame(JNIEnv* env)
{
jclass clazz = env->FindClass("android/webkit/BrowserFrame");
- LOG_ASSERT(clazz, "Cannot find BrowserFrame");
+ ALOG_ASSERT(clazz, "Cannot find BrowserFrame");
gFrameField = env->GetFieldID(clazz, "mNativeFrame", "I");
- LOG_ASSERT(gFrameField, "Cannot find mNativeFrame on BrowserFrame");
+ ALOG_ASSERT(gFrameField, "Cannot find mNativeFrame on BrowserFrame");
env->DeleteLocalRef(clazz);
return jniRegisterNativeMethods(env, "android/webkit/BrowserFrame",
diff --git a/Source/WebKit/android/jni/WebCoreJni.cpp b/Source/WebKit/android/jni/WebCoreJni.cpp
index 2a07999..10b3e95 100644
--- a/Source/WebKit/android/jni/WebCoreJni.cpp
+++ b/Source/WebKit/android/jni/WebCoreJni.cpp
@@ -38,7 +38,7 @@ namespace android {
AutoJObject getRealObject(JNIEnv* env, jobject obj)
{
jobject real = env->NewLocalRef(obj);
- LOG_ASSERT(real, "The real object has been deleted!");
+ ALOG_ASSERT(real, "The real object has been deleted!");
return AutoJObject(env, real);
}
@@ -50,7 +50,7 @@ bool checkException(JNIEnv* env)
{
if (env->ExceptionCheck() != 0)
{
- LOGE("*** Uncaught exception returned from Java call!\n");
+ ALOGE("*** Uncaught exception returned from Java call!\n");
env->ExceptionDescribe();
return true;
}
diff --git a/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp b/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp
index bb71bf5..fb959ac 100644
--- a/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp
+++ b/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp
@@ -141,16 +141,16 @@ EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
jint result = -1;
if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
- LOGE("GetEnv failed!");
+ ALOGE("GetEnv failed!");
return result;
}
- LOG_ASSERT(env, "Could not retrieve the env!");
+ ALOG_ASSERT(env, "Could not retrieve the env!");
const RegistrationMethod* method = gWebCoreRegMethods;
const RegistrationMethod* end = method + sizeof(gWebCoreRegMethods)/sizeof(RegistrationMethod);
while (method != end) {
if (method->func(env) < 0) {
- LOGE("%s registration failed!", method->name);
+ ALOGE("%s registration failed!", method->name);
return result;
}
method++;
diff --git a/Source/WebKit/android/jni/WebCoreResourceLoader.cpp b/Source/WebKit/android/jni/WebCoreResourceLoader.cpp
index f9acc97..f0861ff 100644
--- a/Source/WebKit/android/jni/WebCoreResourceLoader.cpp
+++ b/Source/WebKit/android/jni/WebCoreResourceLoader.cpp
@@ -34,9 +34,6 @@
#include "ResourceHandleInternal.h"
#include "ResourceResponse.h"
#include "SkUtils.h"
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
#include "WebCoreJni.h"
#include <JNIHelp.h>
@@ -133,14 +130,10 @@ bool WebCoreResourceLoader::willLoadFromCache(const WebCore::KURL& url, int64_t
// ----------------------------------------------------------------------------
void WebCoreResourceLoader::SetResponseHeader(JNIEnv* env, jobject obj, jint nativeResponse, jstring key, jstring val)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
-#endif
-
WebCore::ResourceResponse* response = (WebCore::ResourceResponse*)nativeResponse;
- LOG_ASSERT(response, "nativeSetResponseHeader must take a valid response pointer!");
+ ALOG_ASSERT(response, "nativeSetResponseHeader must take a valid response pointer!");
- LOG_ASSERT(key, "How did a null value become a key?");
+ ALOG_ASSERT(key, "How did a null value become a key?");
if (val)
response->setHTTPHeaderField(jstringToWtfString(env, key), jstringToWtfString(env, val));
}
@@ -149,20 +142,17 @@ jint WebCoreResourceLoader::CreateResponse(JNIEnv* env, jobject obj, jstring url
jstring statusText, jstring mimeType, jlong expectedLength,
jstring encoding)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
-#endif
- LOG_ASSERT(url, "Must have a url in the response!");
+ ALOG_ASSERT(url, "Must have a url in the response!");
WebCore::KURL kurl(WebCore::ParsedURLString, jstringToWtfString(env, url));
WTF::String encodingStr;
WTF::String mimeTypeStr;
if (mimeType) {
mimeTypeStr = jstringToWtfString(env, mimeType);
- LOGV("Response setMIMEType: %s", mimeTypeStr.latin1().data());
+ ALOGV("Response setMIMEType: %s", mimeTypeStr.latin1().data());
}
if (encoding) {
encodingStr = jstringToWtfString(env, encoding);
- LOGV("Response setTextEncodingName: %s", encodingStr.latin1().data());
+ ALOGV("Response setTextEncodingName: %s", encodingStr.latin1().data());
}
WebCore::ResourceResponse* response = new WebCore::ResourceResponse(
kurl, mimeTypeStr, (long long)expectedLength,
@@ -171,24 +161,21 @@ jint WebCoreResourceLoader::CreateResponse(JNIEnv* env, jobject obj, jstring url
if (statusText) {
WTF::String status = jstringToWtfString(env, statusText);
response->setHTTPStatusText(status);
- LOGV("Response setStatusText: %s", status.latin1().data());
+ ALOGV("Response setStatusText: %s", status.latin1().data());
}
return (int)response;
}
void WebCoreResourceLoader::ReceivedResponse(JNIEnv* env, jobject obj, jint nativeResponse)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
-#endif
WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj);
- LOG_ASSERT(handle, "nativeReceivedResponse must take a valid handle!");
+ ALOG_ASSERT(handle, "nativeReceivedResponse must take a valid handle!");
// ResourceLoader::didFail() can set handle to be NULL, we need to check
if (!handle)
return;
WebCore::ResourceResponse* response = (WebCore::ResourceResponse*)nativeResponse;
- LOG_ASSERT(response, "nativeReceivedResponse must take a valid resource pointer!");
+ ALOG_ASSERT(response, "nativeReceivedResponse must take a valid resource pointer!");
handle->client()->didReceiveResponse(handle, *response);
// As the client makes a copy of the response, delete it here.
delete response;
@@ -196,13 +183,10 @@ void WebCoreResourceLoader::ReceivedResponse(JNIEnv* env, jobject obj, jint nati
void WebCoreResourceLoader::AddData(JNIEnv* env, jobject obj, jbyteArray dataArray, jint length)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
-#endif
- LOGV("webcore_resourceloader data(%d)", length);
+ ALOGV("webcore_resourceloader data(%d)", length);
WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj);
- LOG_ASSERT(handle, "nativeAddData must take a valid handle!");
+ ALOG_ASSERT(handle, "nativeAddData must take a valid handle!");
// ResourceLoader::didFail() can set handle to be NULL, we need to check
if (!handle)
return;
@@ -212,41 +196,35 @@ void WebCoreResourceLoader::AddData(JNIEnv* env, jobject obj, jbyteArray dataArr
bool result = false;
jbyte * data = env->GetByteArrayElements(dataArray, NULL);
- LOG_ASSERT(handle->client(), "Why do we not have a client?");
+ ALOG_ASSERT(handle->client(), "Why do we not have a client?");
handle->client()->didReceiveData(handle, (const char *)data, length, length);
env->ReleaseByteArrayElements(dataArray, data, JNI_ABORT);
}
void WebCoreResourceLoader::Finished(JNIEnv* env, jobject obj)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
-#endif
- LOGV("webcore_resourceloader finished");
+ ALOGV("webcore_resourceloader finished");
WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj);
- LOG_ASSERT(handle, "nativeFinished must take a valid handle!");
+ ALOG_ASSERT(handle, "nativeFinished must take a valid handle!");
// ResourceLoader::didFail() can set handle to be NULL, we need to check
if (!handle)
return;
- LOG_ASSERT(handle->client(), "Why do we not have a client?");
+ ALOG_ASSERT(handle->client(), "Why do we not have a client?");
handle->client()->didFinishLoading(handle, 0);
}
jstring WebCoreResourceLoader::RedirectedToUrl(JNIEnv* env, jobject obj,
jstring baseUrl, jstring redirectTo, jint nativeResponse)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
-#endif
- LOGV("webcore_resourceloader redirectedToUrl");
+ ALOGV("webcore_resourceloader redirectedToUrl");
WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj);
- LOG_ASSERT(handle, "nativeRedirectedToUrl must take a valid handle!");
+ ALOG_ASSERT(handle, "nativeRedirectedToUrl must take a valid handle!");
// ResourceLoader::didFail() can set handle to be NULL, we need to check
if (!handle)
return NULL;
- LOG_ASSERT(handle->client(), "Why do we not have a client?");
+ ALOG_ASSERT(handle->client(), "Why do we not have a client?");
WebCore::ResourceRequest r = handle->firstRequest();
WebCore::KURL url(WebCore::KURL(WebCore::ParsedURLString, jstringToWtfString(env, baseUrl)),
jstringToWtfString(env, redirectTo));
@@ -275,12 +253,9 @@ jstring WebCoreResourceLoader::RedirectedToUrl(JNIEnv* env, jobject obj,
void WebCoreResourceLoader::Error(JNIEnv* env, jobject obj, jint id, jstring description,
jstring failingUrl)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
-#endif
- LOGV("webcore_resourceloader error");
+ ALOGV("webcore_resourceloader error");
WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj);
- LOG_ASSERT(handle, "nativeError must take a valid handle!");
+ ALOG_ASSERT(handle, "nativeError must take a valid handle!");
// ResourceLoader::didFail() can set handle to be NULL, we need to check
if (!handle)
return;
diff --git a/Source/WebKit/android/jni/WebHistory.cpp b/Source/WebKit/android/jni/WebHistory.cpp
index aa74b81..f782c37 100644
--- a/Source/WebKit/android/jni/WebHistory.cpp
+++ b/Source/WebKit/android/jni/WebHistory.cpp
@@ -78,7 +78,7 @@ struct WebBackForwardListFields {
static void WebHistoryClose(JNIEnv* env, jobject obj, jint frame)
{
- LOG_ASSERT(frame, "Close needs a valid Frame pointer!");
+ ALOG_ASSERT(frame, "Close needs a valid Frame pointer!");
WebCore::Frame* pFrame = (WebCore::Frame*)frame;
WebCore::BackForwardListImpl* list = static_cast<WebCore::BackForwardListImpl*>(pFrame->page()->backForwardList());
@@ -145,7 +145,7 @@ static void WebHistoryClose(JNIEnv* env, jobject obj, jint frame)
static void WebHistoryRestoreIndex(JNIEnv* env, jobject obj, jint frame, jint index)
{
- LOG_ASSERT(frame, "RestoreState needs a valid Frame pointer!");
+ ALOG_ASSERT(frame, "RestoreState needs a valid Frame pointer!");
WebCore::Frame* pFrame = (WebCore::Frame*)frame;
WebCore::Page* page = pFrame->page();
WebCore::HistoryItem* currentItem =
@@ -158,8 +158,8 @@ static void WebHistoryRestoreIndex(JNIEnv* env, jobject obj, jint frame, jint in
static void WebHistoryInflate(JNIEnv* env, jobject obj, jint frame, jbyteArray data)
{
- LOG_ASSERT(frame, "Inflate needs a valid frame pointer!");
- LOG_ASSERT(data, "Inflate needs a valid data pointer!");
+ ALOG_ASSERT(frame, "Inflate needs a valid frame pointer!");
+ ALOG_ASSERT(data, "Inflate needs a valid data pointer!");
// Get the actual bytes and the length from the java array.
const jbyte* bytes = env->GetByteArrayElements(data, NULL);
@@ -204,7 +204,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.
- LOG_ASSERT(item->bridge(), "Why don't we have a bridge object here?");
+ ALOG_ASSERT(item->bridge(), "Why don't we have a bridge object here?");
write_item(v, item);
write_children_recursive(v, item);
@@ -246,7 +246,7 @@ void WebHistoryItem::updateHistoryItem(WebCore::HistoryItem* item) {
// if the parent only has one ref, it is from this WebHistoryItem.
// This means that the matching WebCore::HistoryItem has been freed.
// This can happen during clear().
- LOGW("Can't updateHistoryItem as the top HistoryItem is gone");
+ ALOGW("Can't updateHistoryItem as the top HistoryItem is gone");
return;
}
while (webItem->parent())
@@ -256,7 +256,7 @@ void WebHistoryItem::updateHistoryItem(WebCore::HistoryItem* 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");
+ ALOGW("Can't updateHistoryItem as the top HistoryItem is gone");
return;
}
}
@@ -311,7 +311,7 @@ void WebHistoryItem::updateHistoryItem(WebCore::HistoryItem* item) {
}
static void historyItemChanged(WebCore::HistoryItem* item) {
- LOG_ASSERT(item, "historyItemChanged called with a null item");
+ ALOG_ASSERT(item, "historyItemChanged called with a null item");
if (item->bridge())
item->bridge()->updateHistoryItem(item);
@@ -319,7 +319,7 @@ static void historyItemChanged(WebCore::HistoryItem* item) {
void WebHistory::AddItem(const AutoJObject& list, WebCore::HistoryItem* item)
{
- LOG_ASSERT(item, "newItem must take a valid HistoryItem!");
+ ALOG_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())
return;
@@ -375,7 +375,7 @@ static void write_string(WTF::Vector<char>& v, const WTF::String& str)
char* data = v.begin() + vectorLen;
// Write the actual string
int l = SkUTF16_ToUTF8(str.characters(), strLen, data);
- LOGV("Writing string %d %.*s", l, l, data);
+ LOG_VERBOSE(History, "Writing string %d %.*s", l, l, data);
// Go back and write the utf8 length. Subtract sizeof(unsigned) from
// data to get the position to write the length.
memcpy(data - sizeof(unsigned), (char*)&l, sizeof(unsigned));
@@ -414,13 +414,13 @@ static void write_item(WTF::Vector<char>& v, WebCore::HistoryItem* item)
write_string(v, item->target());
AndroidWebHistoryBridge* bridge = item->bridge();
- LOG_ASSERT(bridge, "We should have a bridge here!");
+ ALOG_ASSERT(bridge, "We should have a bridge here!");
// Screen scale
const float scale = bridge->scale();
- LOGV("Writing scale %f", scale);
+ LOG_VERBOSE(History, "Writing scale %f", scale);
v.append((char*)&scale, sizeof(float));
const float textWrapScale = bridge->textWrapScale();
- LOGV("Writing text wrap scale %f", textWrapScale);
+ LOG_VERBOSE(History, "Writing text wrap scale %f", textWrapScale);
v.append((char*)&textWrapScale, sizeof(float));
// Scroll position.
@@ -433,19 +433,19 @@ static void write_item(WTF::Vector<char>& v, WebCore::HistoryItem* item)
const WTF::Vector<WTF::String>& docState = item->documentState();
WTF::Vector<WTF::String>::const_iterator end = docState.end();
unsigned stateSize = docState.size();
- LOGV("Writing docState %d", stateSize);
+ LOG_VERBOSE(History, "Writing docState %d", stateSize);
v.append((char*)&stateSize, sizeof(unsigned));
for (WTF::Vector<WTF::String>::const_iterator i = docState.begin(); i != end; ++i) {
write_string(v, *i);
}
// Is target item
- LOGV("Writing isTargetItem %d", item->isTargetItem());
+ LOG_VERBOSE(History, "Writing isTargetItem %d", item->isTargetItem());
v.append((char)item->isTargetItem());
// Children count
unsigned childCount = item->children().size();
- LOGV("Writing childCount %d", childCount);
+ LOG_VERBOSE(History, "Writing childCount %d", childCount);
v.append((char*)&childCount, sizeof(unsigned));
}
@@ -455,7 +455,7 @@ 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();
- LOG_ASSERT(parent->bridge(),
+ ALOG_ASSERT(parent->bridge(),
"The parent item should have a bridge object!");
if (!item->bridge()) {
WebHistoryItem* bridge = new WebHistoryItem(static_cast<WebHistoryItem*>(parent->bridge()));
@@ -467,7 +467,7 @@ static void write_children_recursive(WTF::Vector<char>& v, WebCore::HistoryItem*
// parent must not have a parent bridge.
WebHistoryItem* bridge = static_cast<WebHistoryItem*>(item->bridge());
WebHistoryItem* parentBridge = static_cast<WebHistoryItem*>(parent->bridge());
- LOG_ASSERT(parentBridge->parent() == 0 ||
+ ALOG_ASSERT(parentBridge->parent() == 0 ||
bridge->parent() == parentBridge,
"Somehow this item has an incorrect parent");
bridge->setParent(parentBridge);
@@ -490,12 +490,12 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
// Read the original url
// Read the expected length of the string.
- unsigned l;
+ size_t l;
memcpy(&l, data, sizeofUnsigned);
// Increment data pointer by the size of an unsigned int.
data += sizeofUnsigned;
if (l) {
- LOGV("Original url %d %.*s", l, l, data);
+ LOG_VERBOSE(History, "Original url %d %.*s", l, l, data);
// If we have a length, check if that length exceeds the data length
// and return null if there is not enough data.
if (data + l < end)
@@ -513,7 +513,7 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
memcpy(&l, data, sizeofUnsigned);
data += sizeofUnsigned;
if (l) {
- LOGV("Url %d %.*s", l, l, data);
+ LOG_VERBOSE(History, "Url %d %.*s", l, l, data);
if (data + l < end)
newItem->setURLString(e.decode(data, l));
else
@@ -527,7 +527,7 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
memcpy(&l, data, sizeofUnsigned);
data += sizeofUnsigned;
if (l) {
- LOGV("Title %d %.*s", l, l, data);
+ LOG_VERBOSE(History, "Title %d %.*s", l, l, data);
if (data + l < end)
newItem->setTitle(e.decode(data, l));
else
@@ -539,13 +539,13 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
// Generate a new ResourceRequest object for populating form information.
WTF::String formContentType;
- WTF::PassRefPtr<WebCore::FormData> formData = NULL;
+ WTF::RefPtr<WebCore::FormData> formData = NULL;
// Read the form content type
memcpy(&l, data, sizeofUnsigned);
data += sizeofUnsigned;
if (l) {
- LOGV("Content type %d %.*s", l, l, data);
+ LOG_VERBOSE(History, "Content type %d %.*s", l, l, data);
if (data + l < end)
formContentType = e.decode(data, l);
else
@@ -559,7 +559,7 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
memcpy(&l, data, sizeofUnsigned);
data += sizeofUnsigned;
if (l) {
- LOGV("Form data %d %.*s", l, l, data);
+ LOG_VERBOSE(History, "Form data %d %.*s", l, l, data);
if (data + l < end)
formData = WebCore::FormData::create(data, l);
else
@@ -591,7 +591,7 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
memcpy(&l, data, sizeofUnsigned);
data += sizeofUnsigned;
if (l) {
- LOGV("Target %d %.*s", l, l, data);
+ LOG_VERBOSE(History, "Target %d %.*s", l, l, data);
if (data + l < end)
newItem->setTarget(e.decode(data, l));
else
@@ -602,15 +602,15 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
return false;
AndroidWebHistoryBridge* bridge = newItem->bridge();
- LOG_ASSERT(bridge, "There should be a bridge object during inflate");
+ ALOG_ASSERT(bridge, "There should be a bridge object during inflate");
float fValue;
// Read the screen scale
memcpy(&fValue, data, sizeof(float));
- LOGV("Screen scale %f", fValue);
+ LOG_VERBOSE(History, "Screen scale %f", fValue);
bridge->setScale(fValue);
data += sizeof(float);
memcpy(&fValue, data, sizeofUnsigned);
- LOGV("Text wrap scale %f", fValue);
+ LOG_VERBOSE(History, "Text wrap scale %f", fValue);
bridge->setTextWrapScale(fValue);
data += sizeof(float);
@@ -631,7 +631,7 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
// Read the document state
memcpy(&l, data, sizeofUnsigned);
- LOGV("Document state %d", l);
+ LOG_VERBOSE(History, "Document state %d", l);
data += sizeofUnsigned;
if (l) {
// Check if we have enough data to at least parse the sizes of each
@@ -653,7 +653,7 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
docState.append(e.decode(data, strLen));
else
return false;
- LOGV("\t\t%d %.*s", strLen, strLen, data);
+ LOG_VERBOSE(History, "\t\t%d %.*s", strLen, strLen, data);
data += strLen;
}
newItem->setDocumentState(docState);
@@ -668,7 +668,7 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
unsigned char c = (unsigned char)data[0];
if (c > 1)
return false;
- LOGV("Target item %d", c);
+ LOG_VERBOSE(History, "Target item %d", c);
newItem->setIsTargetItem((bool)c);
data++;
if (end - data < sizeofUnsigned)
@@ -676,7 +676,7 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
// Read the child count
memcpy(&l, data, sizeofUnsigned);
- LOGV("Child count %d", l);
+ LOG_VERBOSE(History, "Child count %d", l);
data += sizeofUnsigned;
*pData = data;
if (l) {
@@ -686,7 +686,7 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
while (l--) {
// 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();
+ WTF::RefPtr<WebCore::HistoryItem> child = WebCore::HistoryItem::create();
// Set a bridge that will not call into java.
child->setBridge(new WebHistoryItem(static_cast<WebHistoryItem*>(bridge)));
// Read the child item.
@@ -711,72 +711,72 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
#ifdef UNIT_TEST
static void unit_test()
{
- LOGD("Entering history unit test!");
+ ALOGD("Entering history unit test!");
const char* test1 = new char[0];
WTF::RefPtr<WebCore::HistoryItem> item = WebCore::HistoryItem::create();
WebCore::HistoryItem* testItem = item.get();
testItem->setBridge(new WebHistoryItem(0));
- LOG_ASSERT(!read_item_recursive(testItem, &test1, 0), "0 length array should fail!");
+ ALOG_ASSERT(!read_item_recursive(testItem, &test1, 0), "0 length array should fail!");
delete[] test1;
const char* test2 = new char[2];
- LOG_ASSERT(!read_item_recursive(testItem, &test2, 2), "Small array should fail!");
+ ALOG_ASSERT(!read_item_recursive(testItem, &test2, 2), "Small array should fail!");
delete[] test2;
- LOG_ASSERT(!read_item_recursive(testItem, NULL, HISTORY_MIN_SIZE), "Null data should fail!");
+ ALOG_ASSERT(!read_item_recursive(testItem, NULL, HISTORY_MIN_SIZE), "Null data should fail!");
// Original Url
char* test3 = new char[HISTORY_MIN_SIZE];
const char* ptr = (const char*)test3;
memset(test3, 0, HISTORY_MIN_SIZE);
*(int*)test3 = 4000;
- LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length originalUrl should fail!");
+ ALOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length originalUrl should fail!");
// Url
int offset = 4;
memset(test3, 0, HISTORY_MIN_SIZE);
ptr = (const char*)test3;
*(int*)(test3 + offset) = 4000;
- LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length url should fail!");
+ ALOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length url should fail!");
// Title
offset += 4;
memset(test3, 0, HISTORY_MIN_SIZE);
ptr = (const char*)test3;
*(int*)(test3 + offset) = 4000;
- LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length title should fail!");
+ ALOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length title should fail!");
// Form content type
offset += 4;
memset(test3, 0, HISTORY_MIN_SIZE);
ptr = (const char*)test3;
*(int*)(test3 + offset) = 4000;
- LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length contentType should fail!");
+ ALOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length contentType should fail!");
// Form data
offset += 4;
memset(test3, 0, HISTORY_MIN_SIZE);
ptr = (const char*)test3;
*(int*)(test3 + offset) = 4000;
- LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length form data should fail!");
+ ALOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length form data should fail!");
// Target
offset += 4;
memset(test3, 0, HISTORY_MIN_SIZE);
ptr = (const char*)test3;
*(int*)(test3 + offset) = 4000;
- LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length target should fail!");
+ ALOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length target should fail!");
offset += 4; // Scale
// Document state
offset += 4;
memset(test3, 0, HISTORY_MIN_SIZE);
ptr = (const char*)test3;
*(int*)(test3 + offset) = 4000;
- LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length document state should fail!");
+ ALOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length document state should fail!");
// Is target item
offset += 1;
memset(test3, 0, HISTORY_MIN_SIZE);
ptr = (const char*)test3;
*(char*)(test3 + offset) = '!';
- LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "IsTargetItem should fail with ! as the value!");
+ ALOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "IsTargetItem should fail with ! as the value!");
// Child count
offset += 4;
memset(test3, 0, HISTORY_MIN_SIZE);
ptr = (const char*)test3;
*(int*)(test3 + offset) = 4000;
- LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 kids should fail!");
+ ALOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 kids should fail!");
offset = 36;
// Test document state
delete[] test3;
@@ -785,7 +785,7 @@ static void unit_test()
ptr = (const char*)test3;
*(int*)(test3 + offset) = 1;
*(int*)(test3 + offset + 4) = 20;
- LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE + sizeof(unsigned)), "1 20 length document state string should fail!");
+ ALOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE + sizeof(unsigned)), "1 20 length document state string should fail!");
delete[] test3;
test3 = new char[HISTORY_MIN_SIZE + 2 * sizeof(unsigned)];
memset(test3, 0, HISTORY_MIN_SIZE + 2 * sizeof(unsigned));
@@ -793,7 +793,7 @@ static void unit_test()
*(int*)(test3 + offset) = 2;
*(int*)(test3 + offset + 4) = 0;
*(int*)(test3 + offset + 8) = 20;
- LOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE + 2 * sizeof(unsigned) ), "2 20 length document state string should fail!");
+ ALOG_ASSERT(!read_item_recursive(testItem, &ptr, HISTORY_MIN_SIZE + 2 * sizeof(unsigned) ), "2 20 length document state string should fail!");
delete[] test3;
}
#endif
@@ -822,31 +822,31 @@ int registerWebHistory(JNIEnv* env)
#endif
// Find WebHistoryItem, its constructor, and the update method.
jclass clazz = env->FindClass("android/webkit/WebHistoryItem");
- LOG_ASSERT(clazz, "Unable to find class android/webkit/WebHistoryItem");
+ ALOG_ASSERT(clazz, "Unable to find class android/webkit/WebHistoryItem");
gWebHistoryItem.mInit = env->GetMethodID(clazz, "<init>", "()V");
- LOG_ASSERT(gWebHistoryItem.mInit, "Could not find WebHistoryItem constructor");
+ ALOG_ASSERT(gWebHistoryItem.mInit, "Could not find WebHistoryItem constructor");
gWebHistoryItem.mUpdate = env->GetMethodID(clazz, "update",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/graphics/Bitmap;[B)V");
- LOG_ASSERT(gWebHistoryItem.mUpdate, "Could not find method update in WebHistoryItem");
+ ALOG_ASSERT(gWebHistoryItem.mUpdate, "Could not find method update in WebHistoryItem");
// Find the field ids for mTitle and mUrl.
gWebHistoryItem.mTitle = env->GetFieldID(clazz, "mTitle", "Ljava/lang/String;");
- LOG_ASSERT(gWebHistoryItem.mTitle, "Could not find field mTitle in WebHistoryItem");
+ ALOG_ASSERT(gWebHistoryItem.mTitle, "Could not find field mTitle in WebHistoryItem");
gWebHistoryItem.mUrl = env->GetFieldID(clazz, "mUrl", "Ljava/lang/String;");
- LOG_ASSERT(gWebHistoryItem.mUrl, "Could not find field mUrl in WebHistoryItem");
+ ALOG_ASSERT(gWebHistoryItem.mUrl, "Could not find field mUrl in WebHistoryItem");
env->DeleteLocalRef(clazz);
// Find the WebBackForwardList object and method.
clazz = env->FindClass("android/webkit/WebBackForwardList");
- LOG_ASSERT(clazz, "Unable to find class android/webkit/WebBackForwardList");
+ ALOG_ASSERT(clazz, "Unable to find class android/webkit/WebBackForwardList");
gWebBackForwardList.mAddHistoryItem = env->GetMethodID(clazz, "addHistoryItem",
"(Landroid/webkit/WebHistoryItem;)V");
- LOG_ASSERT(gWebBackForwardList.mAddHistoryItem, "Could not find method addHistoryItem");
+ ALOG_ASSERT(gWebBackForwardList.mAddHistoryItem, "Could not find method addHistoryItem");
gWebBackForwardList.mRemoveHistoryItem = env->GetMethodID(clazz, "removeHistoryItem",
"(I)V");
- LOG_ASSERT(gWebBackForwardList.mRemoveHistoryItem, "Could not find method removeHistoryItem");
+ ALOG_ASSERT(gWebBackForwardList.mRemoveHistoryItem, "Could not find method removeHistoryItem");
gWebBackForwardList.mSetCurrentIndex = env->GetMethodID(clazz, "setCurrentIndex", "(I)V");
- LOG_ASSERT(gWebBackForwardList.mSetCurrentIndex, "Could not find method setCurrentIndex");
+ ALOG_ASSERT(gWebBackForwardList.mSetCurrentIndex, "Could not find method setCurrentIndex");
env->DeleteLocalRef(clazz);
int result = jniRegisterNativeMethods(env, "android/webkit/WebBackForwardList",
diff --git a/Source/WebKit/android/jni/WebIconDatabase.cpp b/Source/WebKit/android/jni/WebIconDatabase.cpp
index d5f8947..3d988e9 100644
--- a/Source/WebKit/android/jni/WebIconDatabase.cpp
+++ b/Source/WebKit/android/jni/WebIconDatabase.cpp
@@ -168,7 +168,7 @@ static void Open(JNIEnv* env, jobject obj, jstring path)
return;
iconDb.setEnabled(true);
iconDb.setClient(gIconDatabaseClient);
- LOG_ASSERT(path, "No path given to nativeOpen");
+ ALOG_ASSERT(path, "No path given to nativeOpen");
WTF::String pathStr = jstringToWtfString(env, path);
WTF::CString fullPath = WebCore::pathByAppendingComponent(pathStr,
WebCore::IconDatabase::defaultDatabaseFilename()).utf8();
@@ -185,12 +185,12 @@ static void Open(JNIEnv* env, jobject obj, jstring path)
}
}
if (didSetPermissions) {
- LOGV("Opening WebIconDatabase file '%s'", pathStr.latin1().data());
+ ALOGV("Opening WebIconDatabase file '%s'", pathStr.latin1().data());
bool res = iconDb.open(pathStr, WebCore::IconDatabase::defaultDatabaseFilename());
if (!res)
- LOGE("Open failed!");
+ ALOGE("Open failed!");
} else
- LOGE("Failed to set permissions on '%s'", fullPath.data());
+ ALOGE("Failed to set permissions on '%s'", fullPath.data());
}
static void Close(JNIEnv* env, jobject obj)
@@ -200,37 +200,37 @@ static void Close(JNIEnv* env, jobject obj)
static void RemoveAllIcons(JNIEnv* env, jobject obj)
{
- LOGV("Removing all icons");
+ ALOGV("Removing all icons");
WebCore::iconDatabase().removeAllIcons();
}
static jobject IconForPageUrl(JNIEnv* env, jobject obj, jstring url)
{
- LOG_ASSERT(url, "No url given to iconForPageUrl");
+ ALOG_ASSERT(url, "No url given to iconForPageUrl");
WTF::String urlStr = jstringToWtfString(env, url);
// FIXME: This method should not be used from outside WebCore and will be removed.
// http://trac.webkit.org/changeset/81484
WebCore::Image* icon = WebCore::iconDatabase().synchronousIconForPageURL(urlStr, WebCore::IntSize(16, 16));
- LOGV("Retrieving icon for '%s' %p", urlStr.latin1().data(), icon);
+ ALOGV("Retrieving icon for '%s' %p", urlStr.latin1().data(), icon);
return webcoreImageToJavaBitmap(env, icon);
}
static void RetainIconForPageUrl(JNIEnv* env, jobject obj, jstring url)
{
- LOG_ASSERT(url, "No url given to retainIconForPageUrl");
+ ALOG_ASSERT(url, "No url given to retainIconForPageUrl");
WTF::String urlStr = jstringToWtfString(env, url);
- LOGV("Retaining icon for '%s'", urlStr.latin1().data());
+ ALOGV("Retaining icon for '%s'", urlStr.latin1().data());
WebCore::iconDatabase().retainIconForPageURL(urlStr);
}
static void ReleaseIconForPageUrl(JNIEnv* env, jobject obj, jstring url)
{
- LOG_ASSERT(url, "No url given to releaseIconForPageUrl");
+ ALOG_ASSERT(url, "No url given to releaseIconForPageUrl");
WTF::String urlStr = jstringToWtfString(env, url);
- LOGV("Releasing icon for '%s'", urlStr.latin1().data());
+ ALOGV("Releasing icon for '%s'", urlStr.latin1().data());
WebCore::iconDatabase().releaseIconForPageURL(urlStr);
}
@@ -256,7 +256,7 @@ int registerWebIconDatabase(JNIEnv* env)
{
#ifndef NDEBUG
jclass webIconDatabase = env->FindClass("android/webkit/WebIconDatabase");
- LOG_ASSERT(webIconDatabase, "Unable to find class android.webkit.WebIconDatabase");
+ ALOG_ASSERT(webIconDatabase, "Unable to find class android.webkit.WebIconDatabase");
env->DeleteLocalRef(webIconDatabase);
#endif
diff --git a/Source/WebKit/android/jni/WebSettings.cpp b/Source/WebKit/android/jni/WebSettings.cpp
index 589615d..eae532a 100644
--- a/Source/WebKit/android/jni/WebSettings.cpp
+++ b/Source/WebKit/android/jni/WebSettings.cpp
@@ -150,49 +150,49 @@ struct FieldIds {
mOverrideCacheMode = env->GetFieldID(clazz, "mOverrideCacheMode", "I");
#endif
- LOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm");
- LOG_ASSERT(mTextSize, "Could not find field mTextSize");
- LOG_ASSERT(mStandardFontFamily, "Could not find field mStandardFontFamily");
- LOG_ASSERT(mFixedFontFamily, "Could not find field mFixedFontFamily");
- LOG_ASSERT(mSansSerifFontFamily, "Could not find field mSansSerifFontFamily");
- LOG_ASSERT(mSerifFontFamily, "Could not find field mSerifFontFamily");
- LOG_ASSERT(mCursiveFontFamily, "Could not find field mCursiveFontFamily");
- LOG_ASSERT(mFantasyFontFamily, "Could not find field mFantasyFontFamily");
- LOG_ASSERT(mDefaultTextEncoding, "Could not find field mDefaultTextEncoding");
- LOG_ASSERT(mUserAgent, "Could not find field mUserAgent");
- LOG_ASSERT(mAcceptLanguage, "Could not find field mAcceptLanguage");
- LOG_ASSERT(mMinimumFontSize, "Could not find field mMinimumFontSize");
- LOG_ASSERT(mMinimumLogicalFontSize, "Could not find field mMinimumLogicalFontSize");
- LOG_ASSERT(mDefaultFontSize, "Could not find field mDefaultFontSize");
- LOG_ASSERT(mDefaultFixedFontSize, "Could not find field mDefaultFixedFontSize");
- LOG_ASSERT(mLoadsImagesAutomatically, "Could not find field mLoadsImagesAutomatically");
+ ALOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm");
+ ALOG_ASSERT(mTextSize, "Could not find field mTextSize");
+ ALOG_ASSERT(mStandardFontFamily, "Could not find field mStandardFontFamily");
+ ALOG_ASSERT(mFixedFontFamily, "Could not find field mFixedFontFamily");
+ ALOG_ASSERT(mSansSerifFontFamily, "Could not find field mSansSerifFontFamily");
+ ALOG_ASSERT(mSerifFontFamily, "Could not find field mSerifFontFamily");
+ ALOG_ASSERT(mCursiveFontFamily, "Could not find field mCursiveFontFamily");
+ ALOG_ASSERT(mFantasyFontFamily, "Could not find field mFantasyFontFamily");
+ ALOG_ASSERT(mDefaultTextEncoding, "Could not find field mDefaultTextEncoding");
+ ALOG_ASSERT(mUserAgent, "Could not find field mUserAgent");
+ ALOG_ASSERT(mAcceptLanguage, "Could not find field mAcceptLanguage");
+ ALOG_ASSERT(mMinimumFontSize, "Could not find field mMinimumFontSize");
+ ALOG_ASSERT(mMinimumLogicalFontSize, "Could not find field mMinimumLogicalFontSize");
+ ALOG_ASSERT(mDefaultFontSize, "Could not find field mDefaultFontSize");
+ ALOG_ASSERT(mDefaultFixedFontSize, "Could not find field mDefaultFixedFontSize");
+ ALOG_ASSERT(mLoadsImagesAutomatically, "Could not find field mLoadsImagesAutomatically");
#ifdef ANDROID_BLOCK_NETWORK_IMAGE
- LOG_ASSERT(mBlockNetworkImage, "Could not find field mBlockNetworkImage");
+ ALOG_ASSERT(mBlockNetworkImage, "Could not find field mBlockNetworkImage");
#endif
- LOG_ASSERT(mBlockNetworkLoads, "Could not find field mBlockNetworkLoads");
- LOG_ASSERT(mJavaScriptEnabled, "Could not find field mJavaScriptEnabled");
- LOG_ASSERT(mPluginState, "Could not find field mPluginState");
+ ALOG_ASSERT(mBlockNetworkLoads, "Could not find field mBlockNetworkLoads");
+ ALOG_ASSERT(mJavaScriptEnabled, "Could not find field mJavaScriptEnabled");
+ ALOG_ASSERT(mPluginState, "Could not find field mPluginState");
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- LOG_ASSERT(mAppCacheEnabled, "Could not find field mAppCacheEnabled");
- LOG_ASSERT(mAppCachePath, "Could not find field mAppCachePath");
- LOG_ASSERT(mAppCacheMaxSize, "Could not find field mAppCacheMaxSize");
+ ALOG_ASSERT(mAppCacheEnabled, "Could not find field mAppCacheEnabled");
+ ALOG_ASSERT(mAppCachePath, "Could not find field mAppCachePath");
+ ALOG_ASSERT(mAppCacheMaxSize, "Could not find field mAppCacheMaxSize");
#endif
#if ENABLE(WORKERS)
- LOG_ASSERT(mWorkersEnabled, "Could not find field mWorkersEnabled");
+ ALOG_ASSERT(mWorkersEnabled, "Could not find field mWorkersEnabled");
#endif
- LOG_ASSERT(mJavaScriptCanOpenWindowsAutomatically,
+ ALOG_ASSERT(mJavaScriptCanOpenWindowsAutomatically,
"Could not find field mJavaScriptCanOpenWindowsAutomatically");
- LOG_ASSERT(mUseWideViewport, "Could not find field mUseWideViewport");
- LOG_ASSERT(mSupportMultipleWindows, "Could not find field mSupportMultipleWindows");
- LOG_ASSERT(mShrinksStandaloneImagesToFit, "Could not find field mShrinksStandaloneImagesToFit");
- LOG_ASSERT(mMaximumDecodedImageSize, "Could not find field mMaximumDecodedImageSize");
- LOG_ASSERT(mUseDoubleTree, "Could not find field mUseDoubleTree");
- LOG_ASSERT(mPageCacheCapacity, "Could not find field mPageCacheCapacity");
+ ALOG_ASSERT(mUseWideViewport, "Could not find field mUseWideViewport");
+ ALOG_ASSERT(mSupportMultipleWindows, "Could not find field mSupportMultipleWindows");
+ ALOG_ASSERT(mShrinksStandaloneImagesToFit, "Could not find field mShrinksStandaloneImagesToFit");
+ ALOG_ASSERT(mMaximumDecodedImageSize, "Could not find field mMaximumDecodedImageSize");
+ ALOG_ASSERT(mUseDoubleTree, "Could not find field mUseDoubleTree");
+ ALOG_ASSERT(mPageCacheCapacity, "Could not find field mPageCacheCapacity");
jclass enumClass = env->FindClass("java/lang/Enum");
- LOG_ASSERT(enumClass, "Could not find Enum class!");
+ ALOG_ASSERT(enumClass, "Could not find Enum class!");
mOrdinal = env->GetMethodID(enumClass, "ordinal", "()I");
- LOG_ASSERT(mOrdinal, "Could not find method ordinal");
+ ALOG_ASSERT(mOrdinal, "Could not find method ordinal");
env->DeleteLocalRef(enumClass);
}
@@ -315,7 +315,7 @@ public:
static void Sync(JNIEnv* env, jobject obj, jint frame)
{
WebCore::Frame* pFrame = (WebCore::Frame*)frame;
- LOG_ASSERT(pFrame, "%s must take a valid frame pointer!", __FUNCTION__);
+ ALOG_ASSERT(pFrame, "%s must take a valid frame pointer!", __FUNCTION__);
WebCore::Settings* s = pFrame->settings();
if (!s)
return;
@@ -331,7 +331,7 @@ public:
pFrame->document()->styleSelectorChanged(WebCore::RecalcStyleImmediately);
if (pFrame->document()->renderer()) {
recursiveCleanupForFullLayout(pFrame->document()->renderer());
- LOG_ASSERT(pFrame->view(), "No view for this frame when trying to relayout");
+ ALOG_ASSERT(pFrame->view(), "No view for this frame when trying to relayout");
pFrame->view()->layout();
// FIXME: This call used to scroll the page to put the focus into view.
// It worked on the WebViewCore, but now scrolling is done outside of the
@@ -420,22 +420,38 @@ public:
#endif
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- flag = env->GetBooleanField(obj, gFieldIds->mAppCacheEnabled);
- s->setOfflineWebApplicationCacheEnabled(flag);
- str = (jstring)env->GetObjectField(obj, gFieldIds->mAppCachePath);
- if (str) {
- String path = jstringToWtfString(env, str);
- if (path.length() && cacheStorage().cacheDirectory().isNull()) {
- cacheStorage().setCacheDirectory(path);
+ // We only enable AppCache if it's been enabled with a call to
+ // setAppCacheEnabled() and if a valid path has been supplied to
+ // setAppCachePath(). Note that the path is applied to all WebViews
+ // whereas enabling is applied per WebView.
+
+ // WebCore asserts that the path is only set once. Since the path is
+ // shared between WebViews, we can't do the required checks to guard
+ // against this in the Java WebSettings.
+ bool isPathValid = false;
+ if (cacheStorage().cacheDirectory().isNull()) {
+ str = static_cast<jstring>(env->GetObjectField(obj, gFieldIds->mAppCachePath));
+ // Check for non-null string as an optimization, as this is the common case.
+ if (str) {
+ String path = jstringToWtfString(env, str);
+ ALOG_ASSERT(!path.empty(), "Java side should never send empty string for AppCache path");
// This database is created on the first load. If the file
// doesn't exist, we create it and set its permissions. The
// filename must match that in ApplicationCacheStorage.cpp.
String filename = pathByAppendingComponent(path, "ApplicationCache.db");
- int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, permissionFlags660);
- if (fd >= 0)
+ int fd = open(filename.utf8().data(), O_CREAT, permissionFlags660);
+ if (fd >= 0) {
close(fd);
+ cacheStorage().setCacheDirectory(path);
+ isPathValid = true;
+ }
}
- }
+ } else
+ isPathValid = true;
+
+ flag = env->GetBooleanField(obj, gFieldIds->mAppCacheEnabled);
+ s->setOfflineWebApplicationCacheEnabled(flag && isPathValid);
+
jlong maxsize = env->GetLongField(obj, gFieldIds->mAppCacheMaxSize);
cacheStorage().setMaximumSize(maxsize);
#endif
@@ -587,7 +603,7 @@ static JNINativeMethod gWebSettingsMethods[] = {
int registerWebSettings(JNIEnv* env)
{
jclass clazz = env->FindClass("android/webkit/WebSettings");
- LOG_ASSERT(clazz, "Unable to find class WebSettings!");
+ ALOG_ASSERT(clazz, "Unable to find class WebSettings!");
gFieldIds = new FieldIds(env, clazz);
env->DeleteLocalRef(clazz);
return jniRegisterNativeMethods(env, "android/webkit/WebSettings",
diff --git a/Source/WebKit/android/jni/WebStorage.cpp b/Source/WebKit/android/jni/WebStorage.cpp
index 9ce207d..9e9774d 100644
--- a/Source/WebKit/android/jni/WebStorage.cpp
+++ b/Source/WebKit/android/jni/WebStorage.cpp
@@ -175,7 +175,7 @@ int registerWebStorage(JNIEnv* env)
{
#ifndef NDEBUG
jclass webStorage = env->FindClass("android/webkit/WebStorage");
- LOG_ASSERT(webStorage, "Unable to find class android.webkit.WebStorage");
+ ALOG_ASSERT(webStorage, "Unable to find class android.webkit.WebStorage");
env->DeleteLocalRef(webStorage);
#endif
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index 1e406b1..313563e 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -132,7 +132,6 @@
#if USE(V8)
#include "ScriptController.h"
-#include "V8Counters.h"
#include <wtf/text/CString.h>
#endif
@@ -153,10 +152,6 @@ FILE* gDomTreeFile = 0;
FILE* gRenderTreeFile = 0;
#endif
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
-
#if USE(ACCELERATED_COMPOSITING)
#include "GraphicsLayerAndroid.h"
#include "RenderLayerCompositor.h"
@@ -189,7 +184,7 @@ void WebViewCore::addInstance(WebViewCore* inst) {
void WebViewCore::removeInstance(WebViewCore* inst) {
int index = gInstanceList.find(inst);
- LOG_ASSERT(index >= 0, "RemoveInstance inst not found");
+ ALOG_ASSERT(index >= 0, "RemoveInstance inst not found");
if (index >= 0) {
gInstanceList.removeShuffle(index);
}
@@ -242,8 +237,6 @@ bool WebViewCore::isSupportedMediaMimeType(const WTF::String& mimeType) {
// ----------------------------------------------------------------------------
-#define GET_NATIVE_VIEW(env, obj) ((WebViewCore*)env->GetIntField(obj, gWebViewCoreFields.m_nativeClass))
-
// Field ids for WebViewCore
struct WebViewCoreFields {
jfieldID m_nativeClass;
@@ -332,7 +325,7 @@ struct WebViewCore::JavaGlue {
static jmethodID GetJMethod(JNIEnv* env, jclass clazz, const char name[], const char signature[])
{
jmethodID m = env->GetMethodID(clazz, name, signature);
- LOG_ASSERT(m, "Could not find method %s", name);
+ ALOG_ASSERT(m, "Could not find method %s", name);
return m;
}
@@ -395,7 +388,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
, m_webRequestContext(0)
#endif
{
- LOG_ASSERT(m_mainFrame, "Uh oh, somehow a frameview was made without an initial frame!");
+ ALOG_ASSERT(m_mainFrame, "Uh oh, somehow a frameview was made without an initial frame!");
jclass clazz = env->GetObjectClass(javaWebViewCore);
m_javaGlue->m_obj = env->NewWeakGlobalRef(javaWebViewCore);
@@ -536,14 +529,16 @@ static bool layoutIfNeededRecursive(WebCore::Frame* f)
return success && !v->needsLayout();
}
+#if ENABLE(ANDROID_NAVCACHE)
CacheBuilder& WebViewCore::cacheBuilder()
{
return FrameLoaderClientAndroid::get(m_mainFrame)->getCacheBuilder();
}
+#endif
WebCore::Node* WebViewCore::currentFocus()
{
- return cacheBuilder().currentFocus();
+ return m_mainFrame->document()->focusedNode();
}
void WebViewCore::recordPicture(SkPicture* picture)
@@ -595,11 +590,6 @@ void WebViewCore::recordPictureSet(PictureSet* content)
if (!success)
return;
- { // collect WebViewCoreRecordTimeCounter after layoutIfNeededRecursive
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreRecordTimeCounter);
-#endif
-
// if the webkit page dimensions changed, discard the pictureset and redraw.
WebCore::FrameView* view = m_mainFrame->view();
int width = view->contentsWidth();
@@ -669,8 +659,10 @@ void WebViewCore::recordPictureSet(PictureSet* content)
height = view->contentsHeight();
}
+#if ENABLE(ANDROID_NAVCACHE)
if (cacheBuilder().pictureSetDisabled())
content->clear();
+#endif
#if USE(ACCELERATED_COMPOSITING)
// The invals are not always correct when the content size has changed. For
@@ -710,8 +702,8 @@ void WebViewCore::recordPictureSet(PictureSet* content)
// Rebuild the pictureset (webkit repaint)
rebuildPictureSet(content);
- } // WebViewCoreRecordTimeCounter
+#if ENABLE(ANDROID_NAVCACHE)
WebCore::Node* oldFocusNode = currentFocus();
m_frameCacheOutOfDate = true;
WebCore::IntRect oldBounds;
@@ -765,8 +757,9 @@ void WebViewCore::recordPictureSet(PictureSet* content)
m_domtree_version = latestVersion;
DBG_NAV_LOG("call updateFrameCache");
updateFrameCache();
+#endif
if (m_findIsUp) {
- LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
+ ALOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject javaObject = m_javaGlue->object(env);
if (javaObject.get()) {
@@ -784,9 +777,9 @@ void WebViewCore::recordPictureSet(PictureSet* content)
void WebViewCore::updateCursorBounds(const CachedRoot* root,
const CachedFrame* cachedFrame, const CachedNode* cachedNode)
{
- LOG_ASSERT(root, "updateCursorBounds: root cannot be null");
- LOG_ASSERT(cachedNode, "updateCursorBounds: cachedNode cannot be null");
- LOG_ASSERT(cachedFrame, "updateCursorBounds: cachedFrame cannot be null");
+ ALOG_ASSERT(root, "updateCursorBounds: root cannot be null");
+ ALOG_ASSERT(cachedNode, "updateCursorBounds: cachedNode cannot be null");
+ ALOG_ASSERT(cachedFrame, "updateCursorBounds: cachedFrame cannot be null");
gCursorBoundsMutex.lock();
m_hasCursorBounds = !cachedNode->isHidden();
// If m_hasCursorBounds is false, we never look at the other
@@ -911,7 +904,7 @@ BaseLayerAndroid* WebViewCore::createBaseLayer(SkRegion* region)
bool layoutSucceeded = layoutIfNeededRecursive(m_mainFrame);
m_skipContentDraw = false;
// Layout only fails if called during a layout.
- LOG_ASSERT(layoutSucceeded, "Can never be called recursively");
+ ALOG_ASSERT(layoutSucceeded, "Can never be called recursively");
#if USE(ACCELERATED_COMPOSITING)
// We set the background color
@@ -945,7 +938,7 @@ BaseLayerAndroid* WebViewCore::recordContent(SkRegion* region, SkIPoint* point)
DBG_SET_LOG("start");
// If there is a pending style recalculation, just return.
if (m_mainFrame->document()->isPendingStyleRecalc()) {
- DBG_SET_LOGD("recordContent: pending style recalc, ignoring.");
+ DBG_SET_LOG("recordContent: pending style recalc, ignoring.");
return 0;
}
float progress = (float) m_mainFrame->page()->progress()->estimatedProgress();
@@ -977,7 +970,7 @@ void WebViewCore::splitContent(PictureSet* content)
#ifdef FAST_PICTURESET
#else
bool layoutSucceeded = layoutIfNeededRecursive(m_mainFrame);
- LOG_ASSERT(layoutSucceeded, "Can never be called recursively");
+ ALOG_ASSERT(layoutSucceeded, "Can never be called recursively");
content->split(&m_content);
rebuildPictureSet(&m_content);
content->set(m_content);
@@ -986,9 +979,9 @@ void WebViewCore::splitContent(PictureSet* content)
void WebViewCore::scrollTo(int x, int y, bool animate)
{
- LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
+ ALOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
-// LOGD("WebViewCore::scrollTo(%d %d)\n", x, y);
+// ALOGD("WebViewCore::scrollTo(%d %d)\n", x, y);
JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject javaObject = m_javaGlue->object(env);
@@ -1001,7 +994,7 @@ void WebViewCore::scrollTo(int x, int y, bool animate)
void WebViewCore::sendNotifyProgressFinished()
{
- LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
+ ALOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject javaObject = m_javaGlue->object(env);
if (!javaObject.get())
@@ -1012,7 +1005,7 @@ void WebViewCore::sendNotifyProgressFinished()
void WebViewCore::viewInvalidate(const WebCore::IntRect& rect)
{
- LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
+ ALOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject javaObject = m_javaGlue->object(env);
if (!javaObject.get())
@@ -1084,7 +1077,7 @@ static int pin_pos(int x, int width, int targetWidth)
void WebViewCore::didFirstLayout()
{
DEBUG_NAV_UI_LOGD("%s", __FUNCTION__);
- LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
+ ALOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject javaObject = m_javaGlue->object(env);
@@ -1094,7 +1087,7 @@ void WebViewCore::didFirstLayout()
const WebCore::KURL& url = m_mainFrame->document()->url();
if (url.isEmpty())
return;
- LOGV("::WebCore:: didFirstLayout %s", url.string().ascii().data());
+ ALOGV("::WebCore:: didFirstLayout %s", url.string().ascii().data());
WebCore::FrameLoadType loadType = m_mainFrame->loader()->loadType();
@@ -1109,16 +1102,18 @@ void WebViewCore::didFirstLayout()
|| loadType == WebCore::FrameLoadTypeSame);
checkException(env);
+#if ENABLE(ANDROID_NAVCACHE)
DBG_NAV_LOG("call updateFrameCache");
m_check_domtree_version = false;
updateFrameCache();
+#endif
m_history.setDidFirstLayout(true);
}
void WebViewCore::updateViewport()
{
DEBUG_NAV_UI_LOGD("%s", __FUNCTION__);
- LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
+ ALOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject javaObject = m_javaGlue->object(env);
@@ -1131,7 +1126,7 @@ void WebViewCore::updateViewport()
void WebViewCore::restoreScale(float scale, float textWrapScale)
{
DEBUG_NAV_UI_LOGD("%s", __FUNCTION__);
- LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
+ ALOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject javaObject = m_javaGlue->object(env);
@@ -1144,7 +1139,7 @@ void WebViewCore::restoreScale(float scale, float textWrapScale)
void WebViewCore::needTouchEvents(bool need)
{
DEBUG_NAV_UI_LOGD("%s", __FUNCTION__);
- LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
+ ALOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
#if ENABLE(TOUCH_EVENTS)
JNIEnv* env = JSC::Bindings::getJNIEnv();
@@ -1166,7 +1161,7 @@ void WebViewCore::requestKeyboardWithSelection(const WebCore::Node* node,
int selStart, int selEnd)
{
DEBUG_NAV_UI_LOGD("%s", __FUNCTION__);
- LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
+ ALOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject javaObject = m_javaGlue->object(env);
@@ -1181,7 +1176,7 @@ void WebViewCore::requestKeyboardWithSelection(const WebCore::Node* node,
void WebViewCore::requestKeyboard(bool showKeyboard)
{
DEBUG_NAV_UI_LOGD("%s", __FUNCTION__);
- LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
+ ALOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject javaObject = m_javaGlue->object(env);
@@ -1197,31 +1192,6 @@ void WebViewCore::notifyProgressFinished()
sendNotifyProgressFinished();
}
-void WebViewCore::doMaxScroll(CacheBuilder::Direction dir)
-{
- int dx = 0, dy = 0;
-
- switch (dir) {
- case CacheBuilder::LEFT:
- dx = -m_maxXScroll;
- break;
- case CacheBuilder::UP:
- dy = -m_maxYScroll;
- break;
- case CacheBuilder::RIGHT:
- dx = m_maxXScroll;
- break;
- case CacheBuilder::DOWN:
- dy = m_maxYScroll;
- break;
- case CacheBuilder::UNINITIALIZED:
- default:
- LOG_ASSERT(0, "unexpected focus selector");
- }
- WebCore::FrameView* view = m_mainFrame->view();
- this->scrollTo(view->scrollX() + dx, view->scrollY() + dy, true);
-}
-
void WebViewCore::setScrollOffset(int moveGeneration, bool sendScrollEvent, int dx, int dy)
{
DBG_NAV_LOGD("{%d,%d} m_scrollOffset=(%d,%d), sendScrollEvent=%d", dx, dy,
@@ -1455,12 +1425,12 @@ HTMLElement* WebViewCore::retrieveElement(int x, int y,
DontHitTestScrollbars, HitTestRequest::Active | HitTestRequest::ReadOnly,
IntSize(1, 1));
if (!hitTestResult.innerNode() || !hitTestResult.innerNode()->inDocument()) {
- LOGE("Should not happen: no in document Node found");
+ ALOGE("Should not happen: no in document Node found");
return 0;
}
const ListHashSet<RefPtr<Node> >& list = hitTestResult.rectBasedTestResult();
if (list.isEmpty()) {
- LOGE("Should not happen: no rect-based-test nodes found");
+ ALOGE("Should not happen: no rect-based-test nodes found");
return 0;
}
Node* node = hitTestResult.innerNode();
@@ -1489,8 +1459,10 @@ HTMLImageElement* WebViewCore::retrieveImageElement(int x, int y)
WTF::String WebViewCore::retrieveHref(int x, int y)
{
- WebCore::HTMLAnchorElement* anchor = retrieveAnchorElement(x, y);
- return anchor ? anchor->href() : WTF::String();
+ // TODO: This is expensive, cache
+ HitTestResult result = m_mainFrame->eventHandler()->hitTestResultAtPoint(IntPoint(x, y),
+ false, false, DontHitTestScrollbars, HitTestRequest::Active | HitTestRequest::ReadOnly, IntSize(1, 1));
+ return result.absoluteLinkURL();
}
WTF::String WebViewCore::retrieveAnchorText(int x, int y)
@@ -1501,8 +1473,10 @@ WTF::String WebViewCore::retrieveAnchorText(int x, int y)
WTF::String WebViewCore::retrieveImageSource(int x, int y)
{
- HTMLImageElement* image = retrieveImageElement(x, y);
- return image ? image->src().string() : WTF::String();
+ // TODO: This is expensive, cache
+ HitTestResult result = m_mainFrame->eventHandler()->hitTestResultAtPoint(IntPoint(x, y),
+ false, false, DontHitTestScrollbars, HitTestRequest::Active | HitTestRequest::ReadOnly, IntSize(1, 1));
+ return result.absoluteImageURL();
}
WTF::String WebViewCore::requestLabel(WebCore::Frame* frame,
@@ -1532,8 +1506,12 @@ WTF::String WebViewCore::requestLabel(WebCore::Frame* frame,
static bool isContentEditable(const WebCore::Node* node)
{
- if (!node) return false;
- return node->document()->frame()->selection()->isContentEditable();
+ if (!node)
+ return false;
+ Frame* frame = node->document()->frame();
+ if (!frame)
+ return false;
+ return frame->selection()->isContentEditable();
}
// Returns true if the node is a textfield, textarea, or contentEditable
@@ -1560,6 +1538,7 @@ void WebViewCore::revealSelection()
focusedFrame->selection()->revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
}
+#if ENABLE(ANDROID_NAVCACHE)
void WebViewCore::updateCacheOnNodeChange()
{
gCursorBoundsMutex.lock();
@@ -1603,12 +1582,9 @@ void WebViewCore::updateFrameCache()
// once the recalculation is complete.
// TODO: Do we need to reschedule an update for after the style is recalculated?
if (m_mainFrame && m_mainFrame->document() && m_mainFrame->document()->isPendingStyleRecalc()) {
- LOGW("updateFrameCache: pending style recalc, ignoring.");
+ ALOGW("updateFrameCache: pending style recalc, ignoring.");
return;
}
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreBuildNavTimeCounter);
-#endif
m_frameCacheOutOfDate = false;
m_temp = new CachedRoot();
m_temp->init(m_mainFrame, &m_history);
@@ -1658,6 +1634,7 @@ void WebViewCore::updateFrameCacheIfLoading()
if (!m_check_domtree_version)
updateFrameCache();
}
+#endif
struct TouchNodeData {
Node* mNode;
@@ -1668,6 +1645,8 @@ struct TouchNodeData {
static IntRect getAbsoluteBoundingBox(Node* node) {
IntRect rect;
RenderObject* render = node->renderer();
+ if (!render)
+ return rect;
if (render->isRenderInline())
rect = toRenderInline(render)->linesVisualOverflowBoundingBox();
else if (render->isBox())
@@ -1675,126 +1654,139 @@ static IntRect getAbsoluteBoundingBox(Node* node) {
else if (render->isText())
rect = toRenderText(render)->linesBoundingBox();
else
- LOGE("getAbsoluteBoundingBox failed for node %p, name %s", node, render->renderName());
+ ALOGE("getAbsoluteBoundingBox failed for node %p, name %s", node, render->renderName());
FloatPoint absPos = render->localToAbsolute();
rect.move(absPos.x(), absPos.y());
return rect;
}
// get the highlight rectangles for the touch point (x, y) with the slop
-Vector<IntRect> WebViewCore::getTouchHighlightRects(int x, int y, int slop)
+Vector<IntRect> WebViewCore::getTouchHighlightRects(int x, int y, int slop,
+ Node** node, HitTestResult* hitTestResult)
{
Vector<IntRect> rects;
- m_mousePos = IntPoint(x - m_scrollOffsetX, y - m_scrollOffsetY);
- HitTestResult hitTestResult = m_mainFrame->eventHandler()->hitTestResultAtPoint(IntPoint(x, y),
+ moveMouse(m_mainFrame, x, y);
+ *hitTestResult = m_mainFrame->eventHandler()->hitTestResultAtPoint(IntPoint(x, y),
false, false, DontHitTestScrollbars, HitTestRequest::Active | HitTestRequest::ReadOnly, IntSize(slop, slop));
- if (!hitTestResult.innerNode() || !hitTestResult.innerNode()->inDocument()) {
- LOGE("Should not happen: no in document Node found");
+ if (!hitTestResult->innerNode() || !hitTestResult->innerNode()->inDocument()) {
+ ALOGE("Should not happen: no in document Node found");
return rects;
}
- const ListHashSet<RefPtr<Node> >& list = hitTestResult.rectBasedTestResult();
+ const ListHashSet<RefPtr<Node> >& list = hitTestResult->rectBasedTestResult();
if (list.isEmpty()) {
- LOGE("Should not happen: no rect-based-test nodes found");
+ ALOGE("Should not happen: no rect-based-test nodes found");
return rects;
}
- Frame* frame = hitTestResult.innerNode()->document()->frame();
+ Frame* frame = hitTestResult->innerNode()->document()->frame();
Vector<TouchNodeData> nodeDataList;
- ListHashSet<RefPtr<Node> >::const_iterator last = list.end();
- for (ListHashSet<RefPtr<Node> >::const_iterator it = list.begin(); it != last; ++it) {
- // TODO: it seems reasonable to not search across the frame. Isn't it?
- // if the node is not in the same frame as the innerNode, skip it
- if (it->get()->document()->frame() != frame)
- continue;
- // traverse up the tree to find the first node that needs highlight
- bool found = false;
- Node* eventNode = it->get();
- while (eventNode) {
- RenderObject* render = eventNode->renderer();
- if (render && (render->isBody() || render->isRenderView()))
- break;
- if (eventNode->supportsFocus()
- || eventNode->hasEventListeners(eventNames().clickEvent)
- || eventNode->hasEventListeners(eventNames().mousedownEvent)
- || eventNode->hasEventListeners(eventNames().mouseupEvent)) {
- found = true;
- break;
+ if (hitTestResult->innerNode() != hitTestResult->innerNonSharedNode()
+ && hitTestResult->innerNode()->hasTagName(WebCore::HTMLNames::areaTag)) {
+ TouchNodeData newNode;
+ HTMLAreaElement* area = static_cast<HTMLAreaElement*>(hitTestResult->innerNode());
+ newNode.mNode = area;
+ newNode.mBounds = area->computeRect(hitTestResult->innerNonSharedNode()->renderer());
+ nodeDataList.append(newNode);
+ } else {
+ ListHashSet<RefPtr<Node> >::const_iterator last = list.end();
+ for (ListHashSet<RefPtr<Node> >::const_iterator it = list.begin(); it != last; ++it) {
+ // TODO: it seems reasonable to not search across the frame. Isn't it?
+ // if the node is not in the same frame as the innerNode, skip it
+ if (it->get()->document()->frame() != frame)
+ continue;
+ // traverse up the tree to find the first node that needs highlight
+ bool found = false;
+ Node* eventNode = it->get();
+ while (eventNode) {
+ RenderObject* render = eventNode->renderer();
+ if (render && (render->isBody() || render->isRenderView()))
+ break;
+ if (eventNode->supportsFocus()
+ || eventNode->hasEventListeners(eventNames().clickEvent)
+ || eventNode->hasEventListeners(eventNames().mousedownEvent)
+ || eventNode->hasEventListeners(eventNames().mouseupEvent)
+ || eventNode->hasEventListeners(eventNames().mouseoverEvent)) {
+ found = true;
+ break;
+ }
+ // the nodes in the rectBasedTestResult() are ordered based on z-index during hit testing.
+ // so do not search for the eventNode across explicit z-index border.
+ // TODO: this is a hard one to call. z-index is quite complicated as its value only
+ // matters when you compare two RenderLayer in the same hierarchy level. e.g. in
+ // the following example, "b" is on the top as its z level is the highest. even "c"
+ // has 100 as z-index, it is still below "d" as its parent has the same z-index as
+ // "d" and logically before "d". Of course "a" is the lowest in the z level.
+ //
+ // z-index:auto "a"
+ // z-index:2 "b"
+ // z-index:1
+ // z-index:100 "c"
+ // z-index:1 "d"
+ //
+ // If the fat point touches everyone, the order in the list should be "b", "d", "c"
+ // and "a". When we search for the event node for "b", we really don't want "a" as
+ // in the z-order it is behind everything else.
+ if (render && !render->style()->hasAutoZIndex())
+ break;
+ eventNode = eventNode->parentNode();
}
- // the nodes in the rectBasedTestResult() are ordered based on z-index during hit testing.
- // so do not search for the eventNode across explicit z-index border.
- // TODO: this is a hard one to call. z-index is quite complicated as its value only
- // matters when you compare two RenderLayer in the same hierarchy level. e.g. in
- // the following example, "b" is on the top as its z level is the highest. even "c"
- // has 100 as z-index, it is still below "d" as its parent has the same z-index as
- // "d" and logically before "d". Of course "a" is the lowest in the z level.
- //
- // z-index:auto "a"
- // z-index:2 "b"
- // z-index:1
- // z-index:100 "c"
- // z-index:1 "d"
- //
- // If the fat point touches everyone, the order in the list should be "b", "d", "c"
- // and "a". When we search for the event node for "b", we really don't want "a" as
- // in the z-order it is behind everything else.
- if (render && !render->style()->hasAutoZIndex())
- break;
- eventNode = eventNode->parentNode();
- }
- // didn't find any eventNode, skip it
- if (!found)
- continue;
- // first quick check whether it is a duplicated node before computing bounding box
- Vector<TouchNodeData>::const_iterator nlast = nodeDataList.end();
- for (Vector<TouchNodeData>::const_iterator n = nodeDataList.begin(); n != nlast; ++n) {
- // found the same node, skip it
- if (eventNode == n->mNode) {
- found = false;
- break;
+ // didn't find any eventNode, skip it
+ if (!found)
+ continue;
+ // first quick check whether it is a duplicated node before computing bounding box
+ Vector<TouchNodeData>::const_iterator nlast = nodeDataList.end();
+ for (Vector<TouchNodeData>::const_iterator n = nodeDataList.begin(); n != nlast; ++n) {
+ // found the same node, skip it
+ if (eventNode == n->mNode) {
+ found = false;
+ break;
+ }
}
- }
- if (!found)
- continue;
- // next check whether the node is fully covered by or fully covering another node.
- found = false;
- IntRect rect = getAbsoluteBoundingBox(eventNode);
- if (rect.isEmpty()) {
- // if the node's bounds is empty and it is not a ContainerNode, skip it.
- if (!eventNode->isContainerNode())
+ if (!found)
continue;
- // if the node's children are all positioned objects, its bounds can be empty.
- // Walk through the children to find the bounding box.
- Node* child = static_cast<const ContainerNode*>(eventNode)->firstChild();
- while (child) {
- IntRect childrect;
- if (child->renderer())
- childrect = getAbsoluteBoundingBox(child);
- if (!childrect.isEmpty()) {
- rect.unite(childrect);
- child = child->traverseNextSibling(eventNode);
- } else
- child = child->traverseNextNode(eventNode);
+ // next check whether the node is fully covered by or fully covering another node.
+ found = false;
+ IntRect rect = getAbsoluteBoundingBox(eventNode);
+ if (rect.isEmpty()) {
+ // if the node's bounds is empty and it is not a ContainerNode, skip it.
+ if (!eventNode->isContainerNode())
+ continue;
+ // if the node's children are all positioned objects, its bounds can be empty.
+ // Walk through the children to find the bounding box.
+ Node* child = static_cast<const ContainerNode*>(eventNode)->firstChild();
+ while (child) {
+ IntRect childrect;
+ if (child->renderer())
+ childrect = getAbsoluteBoundingBox(child);
+ if (!childrect.isEmpty()) {
+ rect.unite(childrect);
+ child = child->traverseNextSibling(eventNode);
+ } else
+ child = child->traverseNextNode(eventNode);
+ }
}
- }
- for (int i = nodeDataList.size() - 1; i >= 0; i--) {
- TouchNodeData n = nodeDataList.at(i);
- // the new node is enclosing an existing node, skip it
- if (rect.contains(n.mBounds)) {
- found = true;
- break;
+ for (int i = nodeDataList.size() - 1; i >= 0; i--) {
+ TouchNodeData n = nodeDataList.at(i);
+ // the new node is enclosing an existing node, skip it
+ if (rect.contains(n.mBounds)) {
+ found = true;
+ break;
+ }
+ // the new node is fully inside an existing node, remove the existing node
+ if (n.mBounds.contains(rect))
+ nodeDataList.remove(i);
+ }
+ if (!found) {
+ TouchNodeData newNode;
+ newNode.mNode = eventNode;
+ newNode.mBounds = rect;
+ nodeDataList.append(newNode);
}
- // the new node is fully inside an existing node, remove the existing node
- if (n.mBounds.contains(rect))
- nodeDataList.remove(i);
}
- if (!found) {
- TouchNodeData newNode;
- newNode.mNode = eventNode;
- newNode.mBounds = rect;
- nodeDataList.append(newNode);
+ if (!nodeDataList.size()) {
+ *node = 0;
+ return rects;
}
}
- if (!nodeDataList.size())
- return rects;
// finally select the node with the largest overlap with the fat point
TouchNodeData final;
final.mNode = 0;
@@ -1813,12 +1805,17 @@ Vector<IntRect> WebViewCore::getTouchHighlightRects(int x, int y, int slop)
}
// now get the node's highlight rectangles in the page coordinate system
if (final.mNode) {
+ if (final.mNode->isElementNode()) {
+ // We found a URL element. Update the hitTestResult
+ *node = final.mNode;
+ hitTestResult->setURLElement(static_cast<Element*>(final.mNode));
+ }
IntPoint frameAdjust;
if (frame != m_mainFrame) {
frameAdjust = frame->view()->contentsToWindow(IntPoint());
frameAdjust.move(m_scrollOffsetX, m_scrollOffsetY);
}
- if (final.mNode->isLink()) {
+ if (final.mNode->isLink() && final.mNode->renderer()) {
// most of the links are inline instead of box style. So the bounding box is not
// a good representation for the highlights. Get the list of rectangles instead.
RenderObject* render = final.mNode->renderer();
@@ -1877,8 +1874,7 @@ Vector<IntRect> WebViewCore::getTouchHighlightRects(int x, int y, int slop)
newx = rects[0].x();
newy = rects[0].y();
}
- m_mousePos.setX(newx - m_scrollOffsetX);
- m_mousePos.setY(newy - m_scrollOffsetY);
+ moveMouse(m_mainFrame, newx, newy);
DBG_NAV_LOGD("Move x/y from (%d, %d) to (%d, %d) scrollOffset is (%d, %d)",
x, y, m_mousePos.x() + m_scrollOffsetX, m_mousePos.y() + m_scrollOffsetY,
m_scrollOffsetX, m_scrollOffsetY);
@@ -1893,8 +1889,7 @@ Vector<IntRect> WebViewCore::getTouchHighlightRects(int x, int y, int slop)
testRect.move(frameAdjust.x(), frameAdjust.y());
testRect.intersect(rect);
if (!testRect.contains(x, y)) {
- m_mousePos = testRect.center();
- m_mousePos.move(-m_scrollOffsetX, -m_scrollOffsetY);
+ moveMouse(m_mainFrame, testRect.center().x(), testRect.center().y());
DBG_NAV_LOGD("Move x/y from (%d, %d) to (%d, %d) scrollOffset is (%d, %d)",
x, y, m_mousePos.x() + m_scrollOffsetX, m_mousePos.y() + m_scrollOffsetY,
m_scrollOffsetX, m_scrollOffsetY);
@@ -2134,7 +2129,9 @@ void WebViewCore::moveMouse(WebCore::Frame* frame, int x, int y)
WebCore::NoButton, WebCore::MouseEventMoved, 1, false, false, false,
false, WTF::currentTime());
frame->eventHandler()->handleMouseMoveEvent(mouseEvent);
+#if ENABLE(ANDROID_NAVCACHE)
updateCacheOnNodeChange();
+#endif
}
void WebViewCore::setSelection(int start, int end)
@@ -2197,7 +2194,7 @@ String WebViewCore::modifySelection(const int direction, const int axis)
case AXIS_DOCUMENT:
return modifySelectionDomNavigationAxis(selection, direction, axis);
default:
- LOGE("Invalid navigation axis: %d", axis);
+ ALOGE("Invalid navigation axis: %d", axis);
return String();
}
}
@@ -2240,7 +2237,7 @@ String WebViewCore::modifySelectionTextNavigationAxis(DOMSelection* selection, i
if (m_currentNodeDomNavigationAxis
&& CacheBuilder::validNode(m_mainFrame,
m_mainFrame, m_currentNodeDomNavigationAxis)) {
- PassRefPtr<Range> rangeRef =
+ RefPtr<Range> rangeRef =
selection->frame()->document()->createRange();
rangeRef->selectNode(m_currentNodeDomNavigationAxis, ec);
m_currentNodeDomNavigationAxis = 0;
@@ -2252,7 +2249,7 @@ String WebViewCore::modifySelectionTextNavigationAxis(DOMSelection* selection, i
} else if (m_cursorNode
&& CacheBuilder::validNode(m_mainFrame,
m_mainFrame, m_cursorNode)) {
- PassRefPtr<Range> rangeRef =
+ RefPtr<Range> rangeRef =
selection->frame()->document()->createRange();
rangeRef->selectNode(reinterpret_cast<Node*>(m_cursorNode), ec);
if (ec)
@@ -2456,13 +2453,13 @@ String WebViewCore::modifySelectionTextNavigationAxis(DOMSelection* selection, i
scrollNodeIntoView(m_mainFrame, selection->anchorNode());
// format markup for the visible content
- PassRefPtr<Range> range = selection->getRangeAt(0, ec);
+ RefPtr<Range> range = selection->getRangeAt(0, ec);
if (ec)
return String();
IntRect bounds = range->boundingBox();
selectAt(bounds.center().x(), bounds.center().y());
markup = formatMarkup(selection);
- LOGV("Selection markup: %s", markup.utf8().data());
+ ALOGV("Selection markup: %s", markup.utf8().data());
return markup;
}
@@ -2714,14 +2711,14 @@ String WebViewCore::modifySelectionDomNavigationAxis(DOMSelection* selection, in
if (direction == DIRECTION_FORWARD)
currentNode = currentNode->lastDescendant();
} else {
- LOGE("Invalid axis: %d", axis);
+ ALOGE("Invalid axis: %d", axis);
return String();
}
if (currentNode) {
m_currentNodeDomNavigationAxis = currentNode;
scrollNodeIntoView(m_mainFrame, currentNode);
String selectionString = createMarkup(currentNode);
- LOGV("Selection markup: %s", selectionString.utf8().data());
+ ALOGV("Selection markup: %s", selectionString.utf8().data());
return selectionString;
}
return String();
@@ -2783,7 +2780,7 @@ String WebViewCore::formatMarkup(DOMSelection* selection)
{
ExceptionCode ec = 0;
String markup = String();
- PassRefPtr<Range> wholeRange = selection->getRangeAt(0, ec);
+ RefPtr<Range> wholeRange = selection->getRangeAt(0, ec);
if (ec)
return String();
if (!wholeRange->startContainer() || !wholeRange->startContainer())
@@ -2793,7 +2790,7 @@ String WebViewCore::formatMarkup(DOMSelection* selection)
Node* firstNode = wholeRange->firstNode();
Node* pastLastNode = wholeRange->pastLastNode();
Node* currentNode = firstNode;
- PassRefPtr<Range> currentRange;
+ RefPtr<Range> currentRange;
while (currentNode != pastLastNode) {
Node* nextNode = currentNode->traverseNextNode();
@@ -2873,6 +2870,47 @@ void WebViewCore::deleteSelection(int start, int end, int textGeneration)
m_shouldPaintCaret = true;
}
+void WebViewCore::deleteSurroundingText(int leftLength, int rightLength)
+{
+ WebCore::Node* focus = currentFocus();
+ if (!isTextInput(focus))
+ return;
+
+ Frame* frame = focus->document()->frame();
+ if (!frame)
+ return;
+ SelectionController* selection = frame->selection();
+ Position endPosition = selection->end();
+
+ Position deleteStart = endPosition;
+ int leftDelete = leftLength;
+ while (leftDelete > 0) {
+ leftDelete--;
+ deleteStart = deleteStart.previous(Character);
+ }
+ Position deleteEnd = endPosition;
+ int rightDelete = rightLength;
+ while (rightDelete > 0) {
+ rightDelete--;
+ deleteEnd = deleteEnd.next(Character);
+ }
+
+ // Select the text to delete.
+ VisibleSelection deletedText(deleteStart, deleteEnd);
+ selection->setSelection(deletedText);
+ // Prevent our editor client from passing a message to change the
+ // selection.
+ EditorClientAndroid* client = static_cast<EditorClientAndroid*>(
+ m_mainFrame->editor()->client());
+ client->setUiGeneratedSelectionChange(true);
+ WebCore::TypingCommand::deleteSelection(focus->document(), 0);
+ client->setUiGeneratedSelectionChange(false);
+
+ // set the new cursor position
+ VisibleSelection endCarat(deleteStart);
+ selection->setSelection(endCarat);
+}
+
void WebViewCore::replaceTextfieldText(int oldStart,
int oldEnd, const WTF::String& replace, int start, int end,
int textGeneration)
@@ -2982,9 +3020,9 @@ void WebViewCore::saveDocumentState(WebCore::Frame* frame)
static jobjectArray makeLabelArray(JNIEnv* env, const uint16_t** labels, size_t count)
{
jclass stringClass = env->FindClass("java/lang/String");
- LOG_ASSERT(stringClass, "Could not find java/lang/String");
+ ALOG_ASSERT(stringClass, "Could not find java/lang/String");
jobjectArray array = env->NewObjectArray(count, stringClass, 0);
- LOG_ASSERT(array, "Could not create new string array");
+ ALOG_ASSERT(array, "Could not create new string array");
for (size_t i = 0; i < count; i++) {
jobject newString = env->NewString(&labels[i][1], labels[i][0]);
@@ -3023,7 +3061,7 @@ void WebViewCore::openFileChooser(PassRefPtr<WebCore::FileChooser> chooser)
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)
{
- LOG_ASSERT(m_javaGlue->m_obj, "No java widget associated with this view!");
+ ALOG_ASSERT(m_javaGlue->m_obj, "No java widget associated with this view!");
JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject javaObject = m_javaGlue->object(env);
@@ -3193,7 +3231,7 @@ bool WebViewCore::handleTouchEvent(int action, Vector<int>& ids, Vector<IntPoint
default:
// We do not support other kinds of touch event inside WebCore
// at the moment.
- LOGW("Java passed a touch event type that we do not support in WebCore: %d", action);
+ ALOGW("Java passed a touch event type that we do not support in WebCore: %d", action);
return 0;
}
@@ -3258,7 +3296,7 @@ void WebViewCore::touchUp(int touchGeneration,
// set to hidden, do not show the soft keyboard. Node passed as a parameter
// must not be null.
static bool shouldSuppressKeyboard(const WebCore::Node* node) {
- LOG_ASSERT(node, "node passed to shouldSuppressKeyboard cannot be null");
+ ALOG_ASSERT(node, "node passed to shouldSuppressKeyboard cannot be null");
const NamedNodeMap* attributes = node->attributes();
if (!attributes) return false;
size_t length = attributes->length();
@@ -3323,10 +3361,12 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node
if (!fake) {
RenderTextControl* rtc
= static_cast<RenderTextControl*> (renderer);
+#if ENABLE(ANDROID_NAVCACHE)
// Force an update of the navcache as this will fire off a
// message to WebView that *must* have an updated focus.
m_frameCacheOutOfDate = true;
updateFrameCache();
+#endif
requestKeyboardWithSelection(focusNode, rtc->selectionStart(),
rtc->selectionEnd());
}
@@ -3930,180 +3970,155 @@ void WebViewCore::scrollRenderLayer(int layer, const SkRect& rect)
//----------------------------------------------------------------------
// Native JNI methods
//----------------------------------------------------------------------
-static void RevealSelection(JNIEnv *env, jobject obj)
+static void RevealSelection(JNIEnv* env, jobject obj, jint nativeClass)
{
- GET_NATIVE_VIEW(env, obj)->revealSelection();
+ reinterpret_cast<WebViewCore*>(nativeClass)->revealSelection();
}
-static jstring RequestLabel(JNIEnv *env, jobject obj, int framePointer,
- int nodePointer)
+static jstring RequestLabel(JNIEnv* env, jobject obj, jint nativeClass,
+ int framePointer, int nodePointer)
{
- return wtfStringToJstring(env, GET_NATIVE_VIEW(env, obj)->requestLabel(
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ return wtfStringToJstring(env, viewImpl->requestLabel(
(WebCore::Frame*) framePointer, (WebCore::Node*) nodePointer));
}
-static void ClearContent(JNIEnv *env, jobject obj)
+static void ClearContent(JNIEnv* env, jobject obj, jint nativeClass)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
viewImpl->clearContent();
}
-static void UpdateFrameCacheIfLoading(JNIEnv *env, jobject obj)
+static void UpdateFrameCacheIfLoading(JNIEnv* env, jobject obj, jint nativeClass)
{
- GET_NATIVE_VIEW(env, obj)->updateFrameCacheIfLoading();
+#if ENABLE(ANDROID_NAVCACHE)
+ reinterpret_cast<WebViewCore*>(nativeClass)->updateFrameCacheIfLoading();
+#endif
}
-static void SetSize(JNIEnv *env, jobject obj, jint width, jint height,
- jint textWrapWidth, jfloat scale, jint screenWidth, jint screenHeight,
- jint anchorX, jint anchorY, jboolean ignoreHeight)
+static void SetSize(JNIEnv* env, jobject obj, jint nativeClass, jint width,
+ jint height, jint textWrapWidth, jfloat scale, jint screenWidth,
+ jint screenHeight, jint anchorX, jint anchorY, jboolean ignoreHeight)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOGV("webviewcore::nativeSetSize(%u %u)\n viewImpl: %p", (unsigned)width, (unsigned)height, viewImpl);
- LOG_ASSERT(viewImpl, "viewImpl not set in nativeSetSize");
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOGV("webviewcore::nativeSetSize(%u %u)\n viewImpl: %p", (unsigned)width, (unsigned)height, viewImpl);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in nativeSetSize");
viewImpl->setSizeScreenWidthAndScale(width, height, textWrapWidth, scale,
screenWidth, screenHeight, anchorX, anchorY, ignoreHeight);
}
-static void SetScrollOffset(JNIEnv *env, jobject obj, jint gen, jboolean sendScrollEvent, jint x, jint y)
+static void SetScrollOffset(JNIEnv* env, jobject obj, jint nativeClass,
+ jint gen, jboolean sendScrollEvent, jint x, jint y)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "need viewImpl");
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "need viewImpl");
viewImpl->setScrollOffset(gen, sendScrollEvent, x, y);
}
-static void SetGlobalBounds(JNIEnv *env, jobject obj, jint x, jint y, jint h,
- jint v)
+static void SetGlobalBounds(JNIEnv* env, jobject obj, jint nativeClass,
+ jint x, jint y, jint h, jint v)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "need viewImpl");
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "need viewImpl");
viewImpl->setGlobalBounds(x, y, h, v);
}
-static jboolean Key(JNIEnv *env, jobject obj, jint keyCode, jint unichar,
- jint repeatCount, jboolean isShift, jboolean isAlt, jboolean isSym,
- jboolean isDown)
+static jboolean Key(JNIEnv* env, jobject obj, jint nativeClass, jint keyCode,
+ jint unichar, jint repeatCount, jboolean isShift, jboolean isAlt,
+ jboolean isSym, jboolean isDown)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- return GET_NATIVE_VIEW(env, obj)->key(PlatformKeyboardEvent(keyCode,
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ return viewImpl->key(PlatformKeyboardEvent(keyCode,
unichar, repeatCount, isDown, isShift, isAlt, isSym));
}
-static void Click(JNIEnv *env, jobject obj, int framePtr, int nodePtr, jboolean fake)
+static void Click(JNIEnv* env, jobject obj, jint nativeClass, int framePtr,
+ int nodePtr, jboolean fake)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in Click");
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in Click");
viewImpl->click(reinterpret_cast<WebCore::Frame*>(framePtr),
reinterpret_cast<WebCore::Node*>(nodePtr), fake);
}
-static void ContentInvalidateAll(JNIEnv *env, jobject obj)
+static void ContentInvalidateAll(JNIEnv* env, jobject obj, jint nativeClass)
{
- GET_NATIVE_VIEW(env, obj)->contentInvalidateAll();
+ reinterpret_cast<WebViewCore*>(nativeClass)->contentInvalidateAll();
}
-static void DeleteSelection(JNIEnv *env, jobject obj, jint start, jint end,
- jint textGeneration)
+static void DeleteSelection(JNIEnv* env, jobject obj, jint nativeClass,
+ jint start, jint end, jint textGeneration)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
viewImpl->deleteSelection(start, end, textGeneration);
}
-static void SetSelection(JNIEnv *env, jobject obj, jint start, jint end)
+static void DeleteSurroundingText(JNIEnv *env, jobject obj, jint nativeClass,
+ jint leftLength, jint rightLength)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ viewImpl->deleteSurroundingText(leftLength, rightLength);
+}
+
+static void SetSelection(JNIEnv* env, jobject obj, jint nativeClass,
+ jint start, jint end)
+{
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
viewImpl->setSelection(start, end);
}
-static jstring ModifySelection(JNIEnv *env, jobject obj, jint direction, jint granularity)
+static jstring ModifySelection(JNIEnv* env, jobject obj, jint nativeClass,
+ jint direction, jint granularity)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
String selectionString = viewImpl->modifySelection(direction, granularity);
return wtfStringToJstring(env, selectionString);
}
-static void ReplaceTextfieldText(JNIEnv *env, jobject obj,
+static void ReplaceTextfieldText(JNIEnv* env, jobject obj, jint nativeClass,
jint oldStart, jint oldEnd, jstring replace, jint start, jint end,
jint textGeneration)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
WTF::String webcoreString = jstringToWtfString(env, replace);
viewImpl->replaceTextfieldText(oldStart,
oldEnd, webcoreString, start, end, textGeneration);
}
-static void PassToJs(JNIEnv *env, jobject obj,
+static void PassToJs(JNIEnv* env, jobject obj, jint nativeClass,
jint generation, jstring currentText, jint keyCode,
jint keyValue, jboolean down, jboolean cap, jboolean fn, jboolean sym)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
WTF::String current = jstringToWtfString(env, currentText);
- GET_NATIVE_VIEW(env, obj)->passToJs(generation, current,
+ reinterpret_cast<WebViewCore*>(nativeClass)->passToJs(generation, current,
PlatformKeyboardEvent(keyCode, keyValue, 0, down, cap, fn, sym));
}
-static void ScrollFocusedTextInput(JNIEnv *env, jobject obj, jfloat xPercent,
- jint y)
+static void ScrollFocusedTextInput(JNIEnv* env, jobject obj, jint nativeClass,
+ jfloat xPercent, jint y)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
viewImpl->scrollFocusedTextInput(xPercent, y);
}
-static void SetFocusControllerActive(JNIEnv *env, jobject obj, jboolean active)
+static void SetFocusControllerActive(JNIEnv* env, jobject obj, jint nativeClass,
+ jboolean active)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- LOGV("webviewcore::nativeSetFocusControllerActive()\n");
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in nativeSetFocusControllerActive");
+ ALOGV("webviewcore::nativeSetFocusControllerActive()\n");
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in nativeSetFocusControllerActive");
viewImpl->setFocusControllerActive(active);
}
-static void SaveDocumentState(JNIEnv *env, jobject obj, jint frame)
+static void SaveDocumentState(JNIEnv* env, jobject obj, jint nativeClass,
+ jint frame)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- LOGV("webviewcore::nativeSaveDocumentState()\n");
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in nativeSaveDocumentState");
+ ALOGV("webviewcore::nativeSaveDocumentState()\n");
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in nativeSaveDocumentState");
viewImpl->saveDocumentState((WebCore::Frame*) frame);
}
@@ -4113,7 +4128,8 @@ void WebViewCore::addVisitedLink(const UChar* string, int length)
m_groupForVisitedLinks->addVisitedLink(string, length);
}
-static bool UpdateLayers(JNIEnv *env, jobject obj, jint nativeClass, jint jbaseLayer)
+static bool UpdateLayers(JNIEnv* env, jobject obj, jint nativeClass,
+ jint jbaseLayer)
{
WebViewCore* viewImpl = (WebViewCore*) nativeClass;
BaseLayerAndroid* baseLayer = (BaseLayerAndroid*) jbaseLayer;
@@ -4125,18 +4141,16 @@ static bool UpdateLayers(JNIEnv *env, jobject obj, jint nativeClass, jint jbaseL
return true;
}
-static void NotifyAnimationStarted(JNIEnv *env, jobject obj, jint nativeClass)
+static void NotifyAnimationStarted(JNIEnv* env, jobject obj, jint nativeClass)
{
WebViewCore* viewImpl = (WebViewCore*) nativeClass;
viewImpl->notifyAnimationStarted();
}
-static jint RecordContent(JNIEnv *env, jobject obj, jobject region, jobject pt)
+static jint RecordContent(JNIEnv* env, jobject obj, jint nativeClass,
+ jobject region, jobject pt)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
SkRegion* nativeRegion = GraphicsJNI::getNativeRegion(env, region);
SkIPoint nativePt;
BaseLayerAndroid* result = viewImpl->recordContent(nativeRegion, &nativePt);
@@ -4144,22 +4158,18 @@ static jint RecordContent(JNIEnv *env, jobject obj, jobject region, jobject pt)
return reinterpret_cast<jint>(result);
}
-static void SplitContent(JNIEnv *env, jobject obj, jint content)
+static void SplitContent(JNIEnv* env, jobject obj, jint nativeClass,
+ jint content)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
viewImpl->splitContent(reinterpret_cast<PictureSet*>(content));
}
-static void SendListBoxChoice(JNIEnv* env, jobject obj, jint choice)
+static void SendListBoxChoice(JNIEnv* env, jobject obj, jint nativeClass,
+ jint choice)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in nativeSendListBoxChoice");
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in nativeSendListBoxChoice");
viewImpl->popupReply(choice);
}
@@ -4169,14 +4179,11 @@ static void SendListBoxChoice(JNIEnv* env, jobject obj, jint choice)
// number of items in the average multiple-select listbox.
#define PREPARED_LISTBOX_STORAGE 10
-static void SendListBoxChoices(JNIEnv* env, jobject obj, jbooleanArray jArray,
- jint size)
+static void SendListBoxChoices(JNIEnv* env, jobject obj, jint nativeClass,
+ jbooleanArray jArray, jint size)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in nativeSendListBoxChoices");
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in nativeSendListBoxChoices");
jboolean* ptrArray = env->GetBooleanArrayElements(jArray, 0);
SkAutoSTMalloc<PREPARED_LISTBOX_STORAGE, int> storage(size);
int* array = storage.get();
@@ -4190,12 +4197,9 @@ static void SendListBoxChoices(JNIEnv* env, jobject obj, jbooleanArray jArray,
viewImpl->popupReply(array, count);
}
-static jstring FindAddress(JNIEnv *env, jobject obj, jstring addr,
- jboolean caseInsensitive)
+static jstring FindAddress(JNIEnv* env, jobject obj, jstring addr,
+ jboolean caseInsensitive)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
if (!addr)
return 0;
int length = env->GetStringLength(addr);
@@ -4212,15 +4216,12 @@ static jstring FindAddress(JNIEnv *env, jobject obj, jstring addr,
return ret;
}
-static jboolean HandleTouchEvent(JNIEnv *env, jobject obj, jint action, jintArray idArray,
- jintArray xArray, jintArray yArray,
- jint count, jint actionIndex, jint metaState)
+static jboolean HandleTouchEvent(JNIEnv* env, jobject obj, jint nativeClass,
+ jint action, jintArray idArray, jintArray xArray, jintArray yArray,
+ jint count, jint actionIndex, jint metaState)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
jint* ptrIdArray = env->GetIntArrayElements(idArray, 0);
jint* ptrXArray = env->GetIntArrayElements(xArray, 0);
jint* ptrYArray = env->GetIntArrayElements(yArray, 0);
@@ -4238,105 +4239,88 @@ static jboolean HandleTouchEvent(JNIEnv *env, jobject obj, jint action, jintArra
return viewImpl->handleTouchEvent(action, ids, points, actionIndex, metaState);
}
-static void TouchUp(JNIEnv *env, jobject obj, jint touchGeneration,
- jint frame, jint node, jint x, jint y)
+static void TouchUp(JNIEnv* env, jobject obj, jint nativeClass,
+ jint touchGeneration, jint frame, jint node, jint x, jint y)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
viewImpl->touchUp(touchGeneration,
(WebCore::Frame*) frame, (WebCore::Node*) node, x, y);
}
-static jstring RetrieveHref(JNIEnv *env, jobject obj, jint x, jint y)
+static jstring RetrieveHref(JNIEnv* env, jobject obj, jint nativeClass,
+ jint x, jint y)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
WTF::String result = viewImpl->retrieveHref(x, y);
if (!result.isEmpty())
return wtfStringToJstring(env, result);
return 0;
}
-static jstring RetrieveAnchorText(JNIEnv *env, jobject obj, jint x, jint y)
+static jstring RetrieveAnchorText(JNIEnv* env, jobject obj, jint nativeClass,
+ jint x, jint y)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
WTF::String result = viewImpl->retrieveAnchorText(x, y);
if (!result.isEmpty())
return wtfStringToJstring(env, result);
return 0;
}
-static jstring RetrieveImageSource(JNIEnv *env, jobject obj, jint x, jint y)
+static jstring RetrieveImageSource(JNIEnv* env, jobject obj, jint nativeClass,
+ jint x, jint y)
{
- WTF::String result = GET_NATIVE_VIEW(env, obj)->retrieveImageSource(x, y);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ WTF::String result = viewImpl->retrieveImageSource(x, y);
return !result.isEmpty() ? wtfStringToJstring(env, result) : 0;
}
-static void StopPaintingCaret(JNIEnv *env, jobject obj)
+static void StopPaintingCaret(JNIEnv* env, jobject obj, jint nativeClass)
{
- GET_NATIVE_VIEW(env, obj)->setShouldPaintCaret(false);
+ reinterpret_cast<WebViewCore*>(nativeClass)->setShouldPaintCaret(false);
}
-static void MoveFocus(JNIEnv *env, jobject obj, jint framePtr, jint nodePtr)
+static void MoveFocus(JNIEnv* env, jobject obj, jint nativeClass, 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__);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_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,
+static void MoveMouse(JNIEnv* env, jobject obj, jint nativeClass, jint frame,
jint x, jint y)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
viewImpl->moveMouse((WebCore::Frame*) frame, x, y);
}
-static void MoveMouseIfLatest(JNIEnv *env, jobject obj, jint moveGeneration,
- jint frame, jint x, jint y)
+static void MoveMouseIfLatest(JNIEnv* env, jobject obj, jint nativeClass,
+ jint moveGeneration, jint frame, jint x, jint y)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
viewImpl->moveMouseIfLatest(moveGeneration,
(WebCore::Frame*) frame, x, y);
}
-static void UpdateFrameCache(JNIEnv *env, jobject obj)
+static void UpdateFrameCache(JNIEnv* env, jobject obj, jint nativeClass)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+#if ENABLE(ANDROID_NAVCACHE)
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
viewImpl->updateFrameCache();
+#endif
}
-static jint GetContentMinPrefWidth(JNIEnv *env, jobject obj)
+static jint GetContentMinPrefWidth(JNIEnv* env, jobject obj, jint nativeClass)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
WebCore::Frame* frame = viewImpl->mainFrame();
if (frame) {
@@ -4351,13 +4335,11 @@ static jint GetContentMinPrefWidth(JNIEnv *env, jobject obj)
return 0;
}
-static void SetViewportSettingsFromNative(JNIEnv *env, jobject obj)
+static void SetViewportSettingsFromNative(JNIEnv* env, jobject obj,
+ jint nativeClass)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
WebCore::Settings* s = viewImpl->mainFrame()->page()->settings();
if (!s)
@@ -4374,51 +4356,42 @@ static void SetViewportSettingsFromNative(JNIEnv *env, jobject obj)
#endif
}
-static void SetBackgroundColor(JNIEnv *env, jobject obj, jint color)
+static void SetBackgroundColor(JNIEnv* env, jobject obj, jint nativeClass,
+ jint color)
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
viewImpl->setBackgroundColor((SkColor) color);
}
-static void DumpDomTree(JNIEnv *env, jobject obj, jboolean useFile)
+static void DumpDomTree(JNIEnv* env, jobject obj, jint nativeClass,
+ jboolean useFile)
{
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
viewImpl->dumpDomTree(useFile);
}
-static void DumpRenderTree(JNIEnv *env, jobject obj, jboolean useFile)
+static void DumpRenderTree(JNIEnv* env, jobject obj, jint nativeClass,
+ jboolean useFile)
{
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
viewImpl->dumpRenderTree(useFile);
}
-static void DumpNavTree(JNIEnv *env, jobject obj)
+static void DumpNavTree(JNIEnv* env, jobject obj, jint nativeClass)
{
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
viewImpl->dumpNavTree();
}
-static void DumpV8Counters(JNIEnv*, jobject)
-{
-#if USE(V8)
-#ifdef ANDROID_INSTRUMENT
- V8Counters::dumpCounters();
-#endif
-#endif
-}
-
-static void SetJsFlags(JNIEnv *env, jobject obj, jstring flags)
+static void SetJsFlags(JNIEnv* env, jobject obj, jint nativeClass, jstring flags)
{
#if USE(V8)
WTF::String flagsString = jstringToWtfString(env, flags);
@@ -4431,9 +4404,11 @@ static void SetJsFlags(JNIEnv *env, jobject obj, jstring flags)
// Called from the Java side to set a new quota for the origin or new appcache
// max size in response to a notification that the original quota was exceeded or
// that the appcache has reached its maximum size.
-static void SetNewStorageLimit(JNIEnv* env, jobject obj, jlong quota) {
+static void SetNewStorageLimit(JNIEnv* env, jobject obj, jint nativeClass,
+ jlong quota)
+{
#if ENABLE(DATABASE) || ENABLE(OFFLINE_WEB_APPLICATIONS)
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
Frame* frame = viewImpl->mainFrame();
// The main thread is blocked awaiting this response, so now we can wake it
@@ -4444,93 +4419,98 @@ static void SetNewStorageLimit(JNIEnv* env, jobject obj, jlong quota) {
}
// Called from Java to provide a Geolocation permission state for the specified origin.
-static void GeolocationPermissionsProvide(JNIEnv* env, jobject obj, jstring origin, jboolean allow, jboolean remember) {
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+static void GeolocationPermissionsProvide(JNIEnv* env, jobject obj,
+ jint nativeClass, jstring origin, jboolean allow, jboolean remember)
+{
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
Frame* frame = viewImpl->mainFrame();
ChromeClientAndroid* chromeClient = static_cast<ChromeClientAndroid*>(frame->page()->chrome()->client());
chromeClient->provideGeolocationPermissions(jstringToWtfString(env, origin), allow, remember);
}
-static void RegisterURLSchemeAsLocal(JNIEnv* env, jobject obj, jstring scheme) {
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
+static void RegisterURLSchemeAsLocal(JNIEnv* env, jobject obj, jint nativeClass,
+ jstring scheme)
+{
WebCore::SchemeRegistry::registerURLSchemeAsLocal(jstringToWtfString(env, scheme));
}
-static bool FocusBoundsChanged(JNIEnv* env, jobject obj)
+static bool FocusBoundsChanged(JNIEnv* env, jobject obj, jint nativeClass)
{
- return GET_NATIVE_VIEW(env, obj)->focusBoundsChanged();
+ return reinterpret_cast<WebViewCore*>(nativeClass)->focusBoundsChanged();
}
-static void SetIsPaused(JNIEnv* env, jobject obj, jboolean isPaused)
+static void SetIsPaused(JNIEnv* env, jobject obj, jint nativeClass,
+ jboolean isPaused)
{
// tell the webcore thread to stop thinking while we do other work
// (selection and scrolling). This has nothing to do with the lifecycle
// pause and resume.
- GET_NATIVE_VIEW(env, obj)->setIsPaused(isPaused);
+ reinterpret_cast<WebViewCore*>(nativeClass)->setIsPaused(isPaused);
}
-static void Pause(JNIEnv* env, jobject obj)
+static void Pause(JNIEnv* env, jobject obj, jint nativeClass)
{
// This is called for the foreground tab when the browser is put to the
// background (and also for any tab when it is put to the background of the
// browser). The browser can only be killed by the system when it is in the
// background, so saving the Geolocation permission state now ensures that
// is maintained when the browser is killed.
- ChromeClient* chromeClient = GET_NATIVE_VIEW(env, obj)->mainFrame()->page()->chrome()->client();
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ChromeClient* chromeClient = viewImpl->mainFrame()->page()->chrome()->client();
ChromeClientAndroid* chromeClientAndroid = static_cast<ChromeClientAndroid*>(chromeClient);
chromeClientAndroid->storeGeolocationPermissions();
- Frame* mainFrame = GET_NATIVE_VIEW(env, obj)->mainFrame();
+ Frame* mainFrame = viewImpl->mainFrame();
for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext()) {
Geolocation* geolocation = frame->domWindow()->navigator()->optionalGeolocation();
if (geolocation)
geolocation->suspend();
}
- GET_NATIVE_VIEW(env, obj)->deviceMotionAndOrientationManager()->maybeSuspendClients();
+ viewImpl->deviceMotionAndOrientationManager()->maybeSuspendClients();
ANPEvent event;
SkANP::InitEvent(&event, kLifecycle_ANPEventType);
event.data.lifecycle.action = kPause_ANPLifecycleAction;
- GET_NATIVE_VIEW(env, obj)->sendPluginEvent(event);
+ viewImpl->sendPluginEvent(event);
- GET_NATIVE_VIEW(env, obj)->setIsPaused(true);
+ viewImpl->setIsPaused(true);
}
-static void Resume(JNIEnv* env, jobject obj)
+static void Resume(JNIEnv* env, jobject obj, jint nativeClass)
{
- Frame* mainFrame = GET_NATIVE_VIEW(env, obj)->mainFrame();
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ Frame* mainFrame = viewImpl->mainFrame();
for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext()) {
Geolocation* geolocation = frame->domWindow()->navigator()->optionalGeolocation();
if (geolocation)
geolocation->resume();
}
- GET_NATIVE_VIEW(env, obj)->deviceMotionAndOrientationManager()->maybeResumeClients();
+ viewImpl->deviceMotionAndOrientationManager()->maybeResumeClients();
ANPEvent event;
SkANP::InitEvent(&event, kLifecycle_ANPEventType);
event.data.lifecycle.action = kResume_ANPLifecycleAction;
- GET_NATIVE_VIEW(env, obj)->sendPluginEvent(event);
+ viewImpl->sendPluginEvent(event);
- GET_NATIVE_VIEW(env, obj)->setIsPaused(false);
+ viewImpl->setIsPaused(false);
}
-static void FreeMemory(JNIEnv* env, jobject obj)
+static void FreeMemory(JNIEnv* env, jobject obj, jint nativeClass)
{
ANPEvent event;
SkANP::InitEvent(&event, kLifecycle_ANPEventType);
event.data.lifecycle.action = kFreeMemory_ANPLifecycleAction;
- GET_NATIVE_VIEW(env, obj)->sendPluginEvent(event);
+ reinterpret_cast<WebViewCore*>(nativeClass)->sendPluginEvent(event);
}
-static void ProvideVisitedHistory(JNIEnv *env, jobject obj, jobject hist)
+static void ProvideVisitedHistory(JNIEnv* env, jobject obj, jint nativeClass,
+ jobject hist)
{
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
jobjectArray array = static_cast<jobjectArray>(hist);
@@ -4545,17 +4525,18 @@ static void ProvideVisitedHistory(JNIEnv *env, jobject obj, jobject hist)
}
}
-static void PluginSurfaceReady(JNIEnv* env, jobject obj)
+static void PluginSurfaceReady(JNIEnv* env, jobject obj, jint nativeClass)
{
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
if (viewImpl)
viewImpl->sendPluginSurfaceReady();
}
// Notification from the UI thread that the plugin's full-screen surface has been discarded
-static void FullScreenPluginHidden(JNIEnv* env, jobject obj, jint npp)
+static void FullScreenPluginHidden(JNIEnv* env, jobject obj, jint nativeClass,
+ jint npp)
{
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
PluginWidgetAndroid* plugin = viewImpl->getPluginWidget((NPP)npp);
if (plugin)
plugin->exitFullScreen(false);
@@ -4568,55 +4549,101 @@ static WebCore::IntRect jrect_to_webrect(JNIEnv* env, jobject obj)
return WebCore::IntRect(L, T, R - L, B - T);
}
-static bool ValidNodeAndBounds(JNIEnv *env, jobject obj, int frame, int node,
- jobject rect)
+static bool ValidNodeAndBounds(JNIEnv* env, jobject obj, jint nativeClass,
+ int frame, int node, jobject rect)
{
IntRect nativeRect = jrect_to_webrect(env, rect);
- return GET_NATIVE_VIEW(env, obj)->validNodeAndBounds(
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ return viewImpl->validNodeAndBounds(
reinterpret_cast<Frame*>(frame),
reinterpret_cast<Node*>(node), nativeRect);
}
-static jobject GetTouchHighlightRects(JNIEnv* env, jobject obj, jint x, jint y, jint slop)
+static int GetHitTestExtra(Node* node, HitTestResult& hitTestResult, WTF::String& extra)
+{
+ /*
+ UNKNOWN_TYPE = 0;
+ PHONE_TYPE = 2;
+ GEO_TYPE = 3;
+ EMAIL_TYPE = 4;
+ IMAGE_TYPE = 5;
+ SRC_ANCHOR_TYPE = 7;
+ SRC_IMAGE_ANCHOR_TYPE = 8;
+ EDIT_TEXT_TYPE = 9;
+ */
+ if (!node)
+ return 0;
+ KURL imageUrl = hitTestResult.absoluteImageURL();
+ if (node->isLink()) {
+ if (!imageUrl.isEmpty()) {
+ extra = imageUrl.string();
+ return 8;
+ }
+ extra = hitTestResult.absoluteLinkURL();
+ return 7;
+
+ }
+ if (!imageUrl.isEmpty()) {
+ extra = imageUrl.string();
+ return 5;
+ }
+ if (hitTestResult.isContentEditable()) {
+ return 9;
+ }
+ return 0;
+}
+
+static jobject HitTest(JNIEnv* env, jobject obj, jint nativeClass, jint x, jint y, jint slop)
{
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
if (!viewImpl)
return 0;
- Vector<IntRect> rects = viewImpl->getTouchHighlightRects(x, y, slop);
- if (rects.isEmpty())
+ Node* node = 0;
+ HitTestResult hitTestResult;
+ Vector<IntRect> rects = viewImpl->getTouchHighlightRects(x, y, slop, &node, &hitTestResult);
+ if (rects.isEmpty() && !node)
return 0;
- jclass arrayClass = env->FindClass("java/util/ArrayList");
- LOG_ASSERT(arrayClass, "Could not find java/util/ArrayList");
- jmethodID init = env->GetMethodID(arrayClass, "<init>", "(I)V");
- LOG_ASSERT(init, "Could not find constructor for ArrayList");
- jobject array = env->NewObject(arrayClass, init, rects.size());
- LOG_ASSERT(array, "Could not create a new ArrayList");
- jmethodID add = env->GetMethodID(arrayClass, "add", "(Ljava/lang/Object;)Z");
- LOG_ASSERT(add, "Could not find add method on ArrayList");
jclass rectClass = env->FindClass("android/graphics/Rect");
- LOG_ASSERT(rectClass, "Could not find android/graphics/Rect");
+ ALOG_ASSERT(rectClass, "Could not find android/graphics/Rect");
jmethodID rectinit = env->GetMethodID(rectClass, "<init>", "(IIII)V");
- LOG_ASSERT(rectinit, "Could not find init method on Rect");
+ ALOG_ASSERT(rectinit, "Could not find init method on Rect");
+ jobjectArray array = env->NewObjectArray(rects.size(), rectClass, 0);
+ ALOG_ASSERT(array, "Could not create a Rect array");
for (size_t i = 0; i < rects.size(); i++) {
jobject rect = env->NewObject(rectClass, rectinit, rects[i].x(),
rects[i].y(), rects[i].maxX(), rects[i].maxY());
if (rect) {
- env->CallBooleanMethod(array, add, rect);
+ env->SetObjectArrayElement(array, i, rect);
env->DeleteLocalRef(rect);
}
}
env->DeleteLocalRef(rectClass);
- env->DeleteLocalRef(arrayClass);
- return array;
-}
-static void AutoFillForm(JNIEnv* env, jobject obj, jint queryId)
+ jclass hitTestClass = env->FindClass("android/webkit/WebViewCore$WebKitHitTest");
+ ALOG_ASSERT(hitTestClass, "Could not find android/webkit/WebViewCore$WebKitHitTest");
+ jmethodID hitTestInit = env->GetMethodID(hitTestClass, "<init>", "()V");
+ jobject hitTest = env->NewObject(hitTestClass, hitTestInit);
+ jfieldID htTouchRects = env->GetFieldID(hitTestClass, "mTouchRects", "[Landroid/graphics/Rect;");
+ env->SetObjectField(hitTest, htTouchRects, array);
+ jfieldID htType = env->GetFieldID(hitTestClass, "mType", "I");
+ jfieldID htExtra = env->GetFieldID(hitTestClass, "mExtra", "Ljava/lang/String;");
+ WTF::String extra;
+ int type = GetHitTestExtra(node, hitTestResult, extra);
+ env->SetIntField(hitTest, htType, type);
+ jstring jextra = wtfStringToJstring(env, extra, false);
+ env->SetObjectField(hitTest, htExtra, jextra);
+ env->DeleteLocalRef(hitTestClass);
+ return hitTest;
+}
+
+static void AutoFillForm(JNIEnv* env, jobject obj, jint nativeClass,
+ jint queryId)
{
#if ENABLE(WEB_AUTOFILL)
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
if (!viewImpl)
return;
@@ -4629,7 +4656,7 @@ static void AutoFillForm(JNIEnv* env, jobject obj, jint queryId)
#endif
}
-static void CloseIdleConnections(JNIEnv* env, jobject obj)
+static void CloseIdleConnections(JNIEnv* env, jobject obj, jint nativeClass)
{
#if USE(CHROME_NETWORK_STACK)
WebCache::get(true)->closeIdleConnections();
@@ -4637,11 +4664,12 @@ static void CloseIdleConnections(JNIEnv* env, jobject obj)
#endif
}
-static void ScrollRenderLayer(JNIEnv* env, jobject obj, jint layer, jobject jRect)
+static void ScrollRenderLayer(JNIEnv* env, jobject obj, jint nativeClass,
+ jint layer, jobject jRect)
{
SkRect rect;
GraphicsJNI::jrect_to_rect(env, jRect, &rect);
- GET_NATIVE_VIEW(env, obj)->scrollRenderLayer(layer, rect);
+ reinterpret_cast<WebViewCore*>(nativeClass)->scrollRenderLayer(layer, rect);
}
// ----------------------------------------------------------------------------
@@ -4650,164 +4678,164 @@ static void ScrollRenderLayer(JNIEnv* env, jobject obj, jint layer, jobject jRec
* JNI registration.
*/
static JNINativeMethod gJavaWebViewCoreMethods[] = {
- { "nativeClearContent", "()V",
+ { "nativeClearContent", "(I)V",
(void*) ClearContent },
- { "nativeFocusBoundsChanged", "()Z",
+ { "nativeFocusBoundsChanged", "(I)Z",
(void*) FocusBoundsChanged } ,
- { "nativeKey", "(IIIZZZZ)Z",
+ { "nativeKey", "(IIIIZZZZ)Z",
(void*) Key },
- { "nativeClick", "(IIZ)V",
+ { "nativeClick", "(IIIZ)V",
(void*) Click },
- { "nativeContentInvalidateAll", "()V",
+ { "nativeContentInvalidateAll", "(I)V",
(void*) ContentInvalidateAll },
- { "nativeSendListBoxChoices", "([ZI)V",
+ { "nativeSendListBoxChoices", "(I[ZI)V",
(void*) SendListBoxChoices },
- { "nativeSendListBoxChoice", "(I)V",
+ { "nativeSendListBoxChoice", "(II)V",
(void*) SendListBoxChoice },
- { "nativeSetSize", "(IIIFIIIIZ)V",
+ { "nativeSetSize", "(IIIIFIIIIZ)V",
(void*) SetSize },
- { "nativeSetScrollOffset", "(IZII)V",
+ { "nativeSetScrollOffset", "(IIZII)V",
(void*) SetScrollOffset },
- { "nativeSetGlobalBounds", "(IIII)V",
+ { "nativeSetGlobalBounds", "(IIIII)V",
(void*) SetGlobalBounds },
- { "nativeSetSelection", "(II)V",
+ { "nativeSetSelection", "(III)V",
(void*) SetSelection } ,
- { "nativeModifySelection", "(II)Ljava/lang/String;",
+ { "nativeModifySelection", "(III)Ljava/lang/String;",
(void*) ModifySelection },
- { "nativeDeleteSelection", "(III)V",
+ { "nativeDeleteSelection", "(IIII)V",
(void*) DeleteSelection } ,
- { "nativeReplaceTextfieldText", "(IILjava/lang/String;III)V",
+ { "nativeDeleteSurroundingText", "(III)V",
+ (void*) DeleteSurroundingText } ,
+ { "nativeReplaceTextfieldText", "(IIILjava/lang/String;III)V",
(void*) ReplaceTextfieldText } ,
- { "nativeMoveFocus", "(II)V",
+ { "nativeMoveFocus", "(III)V",
(void*) MoveFocus },
- { "nativeMoveMouse", "(III)V",
+ { "nativeMoveMouse", "(IIII)V",
(void*) MoveMouse },
- { "nativeMoveMouseIfLatest", "(IIII)V",
+ { "nativeMoveMouseIfLatest", "(IIIII)V",
(void*) MoveMouseIfLatest },
- { "passToJs", "(ILjava/lang/String;IIZZZZ)V",
+ { "passToJs", "(IILjava/lang/String;IIZZZZ)V",
(void*) PassToJs },
- { "nativeScrollFocusedTextInput", "(FI)V",
+ { "nativeScrollFocusedTextInput", "(IFI)V",
(void*) ScrollFocusedTextInput },
- { "nativeSetFocusControllerActive", "(Z)V",
+ { "nativeSetFocusControllerActive", "(IZ)V",
(void*) SetFocusControllerActive },
- { "nativeSaveDocumentState", "(I)V",
+ { "nativeSaveDocumentState", "(II)V",
(void*) SaveDocumentState },
{ "nativeFindAddress", "(Ljava/lang/String;Z)Ljava/lang/String;",
(void*) FindAddress },
- { "nativeHandleTouchEvent", "(I[I[I[IIII)Z",
+ { "nativeHandleTouchEvent", "(II[I[I[IIII)Z",
(void*) HandleTouchEvent },
- { "nativeTouchUp", "(IIIII)V",
+ { "nativeTouchUp", "(IIIIII)V",
(void*) TouchUp },
- { "nativeRetrieveHref", "(II)Ljava/lang/String;",
+ { "nativeRetrieveHref", "(III)Ljava/lang/String;",
(void*) RetrieveHref },
- { "nativeRetrieveAnchorText", "(II)Ljava/lang/String;",
+ { "nativeRetrieveAnchorText", "(III)Ljava/lang/String;",
(void*) RetrieveAnchorText },
- { "nativeRetrieveImageSource", "(II)Ljava/lang/String;",
+ { "nativeRetrieveImageSource", "(III)Ljava/lang/String;",
(void*) RetrieveImageSource },
- { "nativeStopPaintingCaret", "()V",
+ { "nativeStopPaintingCaret", "(I)V",
(void*) StopPaintingCaret },
- { "nativeUpdateFrameCache", "()V",
+ { "nativeUpdateFrameCache", "(I)V",
(void*) UpdateFrameCache },
- { "nativeGetContentMinPrefWidth", "()I",
+ { "nativeGetContentMinPrefWidth", "(I)I",
(void*) GetContentMinPrefWidth },
{ "nativeUpdateLayers", "(II)Z",
(void*) UpdateLayers },
{ "nativeNotifyAnimationStarted", "(I)V",
(void*) NotifyAnimationStarted },
- { "nativeRecordContent", "(Landroid/graphics/Region;Landroid/graphics/Point;)I",
+ { "nativeRecordContent", "(ILandroid/graphics/Region;Landroid/graphics/Point;)I",
(void*) RecordContent },
- { "setViewportSettingsFromNative", "()V",
+ { "setViewportSettingsFromNative", "(I)V",
(void*) SetViewportSettingsFromNative },
- { "nativeSplitContent", "(I)V",
+ { "nativeSplitContent", "(II)V",
(void*) SplitContent },
- { "nativeSetBackgroundColor", "(I)V",
+ { "nativeSetBackgroundColor", "(II)V",
(void*) SetBackgroundColor },
- { "nativeRegisterURLSchemeAsLocal", "(Ljava/lang/String;)V",
+ { "nativeRegisterURLSchemeAsLocal", "(ILjava/lang/String;)V",
(void*) RegisterURLSchemeAsLocal },
- { "nativeDumpDomTree", "(Z)V",
+ { "nativeDumpDomTree", "(IZ)V",
(void*) DumpDomTree },
- { "nativeDumpRenderTree", "(Z)V",
+ { "nativeDumpRenderTree", "(IZ)V",
(void*) DumpRenderTree },
- { "nativeDumpNavTree", "()V",
+ { "nativeDumpNavTree", "(I)V",
(void*) DumpNavTree },
- { "nativeDumpV8Counters", "()V",
- (void*) DumpV8Counters },
- { "nativeSetNewStorageLimit", "(J)V",
+ { "nativeSetNewStorageLimit", "(IJ)V",
(void*) SetNewStorageLimit },
- { "nativeGeolocationPermissionsProvide", "(Ljava/lang/String;ZZ)V",
+ { "nativeGeolocationPermissionsProvide", "(ILjava/lang/String;ZZ)V",
(void*) GeolocationPermissionsProvide },
- { "nativeSetIsPaused", "(Z)V", (void*) SetIsPaused },
- { "nativePause", "()V", (void*) Pause },
- { "nativeResume", "()V", (void*) Resume },
- { "nativeFreeMemory", "()V", (void*) FreeMemory },
- { "nativeSetJsFlags", "(Ljava/lang/String;)V", (void*) SetJsFlags },
- { "nativeRequestLabel", "(II)Ljava/lang/String;",
+ { "nativeSetIsPaused", "(IZ)V", (void*) SetIsPaused },
+ { "nativePause", "(I)V", (void*) Pause },
+ { "nativeResume", "(I)V", (void*) Resume },
+ { "nativeFreeMemory", "(I)V", (void*) FreeMemory },
+ { "nativeSetJsFlags", "(ILjava/lang/String;)V", (void*) SetJsFlags },
+ { "nativeRequestLabel", "(III)Ljava/lang/String;",
(void*) RequestLabel },
- { "nativeRevealSelection", "()V", (void*) RevealSelection },
- { "nativeUpdateFrameCacheIfLoading", "()V",
+ { "nativeRevealSelection", "(I)V", (void*) RevealSelection },
+ { "nativeUpdateFrameCacheIfLoading", "(I)V",
(void*) UpdateFrameCacheIfLoading },
- { "nativeProvideVisitedHistory", "([Ljava/lang/String;)V",
+ { "nativeProvideVisitedHistory", "(I[Ljava/lang/String;)V",
(void*) ProvideVisitedHistory },
- { "nativeFullScreenPluginHidden", "(I)V",
+ { "nativeFullScreenPluginHidden", "(II)V",
(void*) FullScreenPluginHidden },
- { "nativePluginSurfaceReady", "()V",
+ { "nativePluginSurfaceReady", "(I)V",
(void*) PluginSurfaceReady },
- { "nativeValidNodeAndBounds", "(IILandroid/graphics/Rect;)Z",
+ { "nativeValidNodeAndBounds", "(IIILandroid/graphics/Rect;)Z",
(void*) ValidNodeAndBounds },
- { "nativeGetTouchHighlightRects", "(III)Ljava/util/ArrayList;",
- (void*) GetTouchHighlightRects },
- { "nativeAutoFillForm", "(I)V",
+ { "nativeHitTest", "(IIII)Landroid/webkit/WebViewCore$WebKitHitTest;",
+ (void*) HitTest },
+ { "nativeAutoFillForm", "(II)V",
(void*) AutoFillForm },
- { "nativeScrollLayer", "(ILandroid/graphics/Rect;)V",
+ { "nativeScrollLayer", "(IILandroid/graphics/Rect;)V",
(void*) ScrollRenderLayer },
- { "nativeCloseIdleConnections", "()V",
+ { "nativeCloseIdleConnections", "(I)V",
(void*) CloseIdleConnections },
};
int registerWebViewCore(JNIEnv* env)
{
jclass widget = env->FindClass("android/webkit/WebViewCore");
- LOG_ASSERT(widget,
+ ALOG_ASSERT(widget,
"Unable to find class android/webkit/WebViewCore");
gWebViewCoreFields.m_nativeClass = env->GetFieldID(widget, "mNativeClass",
"I");
- LOG_ASSERT(gWebViewCoreFields.m_nativeClass,
+ ALOG_ASSERT(gWebViewCoreFields.m_nativeClass,
"Unable to find android/webkit/WebViewCore.mNativeClass");
gWebViewCoreFields.m_viewportWidth = env->GetFieldID(widget,
"mViewportWidth", "I");
- LOG_ASSERT(gWebViewCoreFields.m_viewportWidth,
+ ALOG_ASSERT(gWebViewCoreFields.m_viewportWidth,
"Unable to find android/webkit/WebViewCore.mViewportWidth");
gWebViewCoreFields.m_viewportHeight = env->GetFieldID(widget,
"mViewportHeight", "I");
- LOG_ASSERT(gWebViewCoreFields.m_viewportHeight,
+ ALOG_ASSERT(gWebViewCoreFields.m_viewportHeight,
"Unable to find android/webkit/WebViewCore.mViewportHeight");
gWebViewCoreFields.m_viewportInitialScale = env->GetFieldID(widget,
"mViewportInitialScale", "I");
- LOG_ASSERT(gWebViewCoreFields.m_viewportInitialScale,
+ ALOG_ASSERT(gWebViewCoreFields.m_viewportInitialScale,
"Unable to find android/webkit/WebViewCore.mViewportInitialScale");
gWebViewCoreFields.m_viewportMinimumScale = env->GetFieldID(widget,
"mViewportMinimumScale", "I");
- LOG_ASSERT(gWebViewCoreFields.m_viewportMinimumScale,
+ ALOG_ASSERT(gWebViewCoreFields.m_viewportMinimumScale,
"Unable to find android/webkit/WebViewCore.mViewportMinimumScale");
gWebViewCoreFields.m_viewportMaximumScale = env->GetFieldID(widget,
"mViewportMaximumScale", "I");
- LOG_ASSERT(gWebViewCoreFields.m_viewportMaximumScale,
+ ALOG_ASSERT(gWebViewCoreFields.m_viewportMaximumScale,
"Unable to find android/webkit/WebViewCore.mViewportMaximumScale");
gWebViewCoreFields.m_viewportUserScalable = env->GetFieldID(widget,
"mViewportUserScalable", "Z");
- LOG_ASSERT(gWebViewCoreFields.m_viewportUserScalable,
+ ALOG_ASSERT(gWebViewCoreFields.m_viewportUserScalable,
"Unable to find android/webkit/WebViewCore.mViewportUserScalable");
gWebViewCoreFields.m_viewportDensityDpi = env->GetFieldID(widget,
"mViewportDensityDpi", "I");
- LOG_ASSERT(gWebViewCoreFields.m_viewportDensityDpi,
+ ALOG_ASSERT(gWebViewCoreFields.m_viewportDensityDpi,
"Unable to find android/webkit/WebViewCore.mViewportDensityDpi");
gWebViewCoreFields.m_webView = env->GetFieldID(widget,
"mWebView", "Landroid/webkit/WebView;");
- LOG_ASSERT(gWebViewCoreFields.m_webView,
+ ALOG_ASSERT(gWebViewCoreFields.m_webView,
"Unable to find android/webkit/WebViewCore.mWebView");
gWebViewCoreFields.m_drawIsPaused = env->GetFieldID(widget,
"mDrawIsPaused", "Z");
- LOG_ASSERT(gWebViewCoreFields.m_drawIsPaused,
+ ALOG_ASSERT(gWebViewCoreFields.m_drawIsPaused,
"Unable to find android/webkit/WebViewCore.mDrawIsPaused");
gWebViewCoreFields.m_lowMemoryUsageMb = env->GetFieldID(widget, "mLowMemoryUsageThresholdMb", "I");
gWebViewCoreFields.m_highMemoryUsageMb = env->GetFieldID(widget, "mHighMemoryUsageThresholdMb", "I");
diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h
index a05c3ea..9e7c4af 100644
--- a/Source/WebKit/android/jni/WebViewCore.h
+++ b/Source/WebKit/android/jni/WebViewCore.h
@@ -26,7 +26,9 @@
#ifndef WebViewCore_h
#define WebViewCore_h
+#ifndef DISABLE_NAVCACHE
#include "CacheBuilder.h"
+#endif
#include "CachedHistory.h"
#include "DeviceMotionAndOrientationManager.h"
#include "DOMSelection.h"
@@ -358,6 +360,14 @@ namespace android {
void deleteSelection(int start, int end, int textGeneration);
/**
+ * Delete text near the cursor (assumed to be at selection end).
+ * leftLength and rightLength refer to the number of characters
+ * left and right of the cursor to delete. The cursor will be
+ * set to the beginning of the deleted text.
+ */
+ void deleteSurroundingText(int leftLength, int rightLength);
+
+ /**
* Set the selection of the currently focused textfield to (start, end).
* If start and end are out of order, swap them.
*/
@@ -424,8 +434,11 @@ namespace android {
jobject getWebViewJavaObject();
void setBackgroundColor(SkColor c);
+#ifndef DISABLE_NAVCACHE
void updateFrameCache();
void updateCacheOnNodeChange();
+ void updateFrameCacheIfLoading();
+#endif
void dumpDomTree(bool);
void dumpRenderTree(bool);
void dumpNavTree();
@@ -511,7 +524,8 @@ namespace android {
void centerFitRect(int x, int y, int width, int height);
// return a list of rects matching the touch point (x, y) with the slop
- Vector<IntRect> getTouchHighlightRects(int x, int y, int slop);
+ Vector<IntRect> getTouchHighlightRects(int x, int y, int slop,
+ Node** node, HitTestResult* hitTestResult);
// Open a file chooser for selecting a file to upload
void openFileChooser(PassRefPtr<WebCore::FileChooser> );
@@ -537,7 +551,6 @@ namespace android {
WebCore::Frame* mainFrame() const { return m_mainFrame; }
void updateCursorBounds(const CachedRoot* root,
const CachedFrame* cachedFrame, const CachedNode* cachedNode);
- void updateFrameCacheIfLoading();
// utility to split slow parts of the picture set
void splitContent(PictureSet*);
@@ -600,13 +613,14 @@ namespace android {
// internal functions
private:
+#ifndef DISABLE_NAVCACHE
CacheBuilder& cacheBuilder();
+#endif
WebCore::Node* currentFocus();
// 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 doMaxScroll(CacheBuilder::Direction dir);
SkPicture* rebuildPicture(const SkIRect& inval);
void rebuildPictureSet(PictureSet* );
void sendNotifyProgressFinished();
diff --git a/Source/WebKit/android/nav/CacheBuilder.cpp b/Source/WebKit/android/nav/CacheBuilder.cpp
index 940991f..e943101 100644
--- a/Source/WebKit/android/nav/CacheBuilder.cpp
+++ b/Source/WebKit/android/nav/CacheBuilder.cpp
@@ -556,9 +556,7 @@ void CacheBuilder::Debug::groups() {
continue;
} else {
IntRect nodeBounds = node->getRect();
- if (CacheBuilder::ConstructPartRects(node, nodeBounds, rectPtr,
- globalOffsetX, globalOffsetY, &rects, &imageCount) == false)
- continue;
+ continue;
}
unsigned arraySize = rects.size();
if (arraySize > 1 || (arraySize == 1 && (rectPtr->width() != rect.width())) ||
@@ -1123,7 +1121,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
bool more = walk.mMore;
walk.reset();
// GetGlobalBounds(node, &bounds, false);
- bool computeCursorRings = false;
bool hasClip = false;
bool hasMouseOver = false;
bool isUnclipped = false;
@@ -1230,7 +1227,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
continue;
if (bounds.height() < MINIMUM_FOCUSABLE_HEIGHT)
continue;
- computeCursorRings = true;
isUnclipped = true; // FIXME: to hide or partially occlude synthesized links, each
// focus ring will also need the offset and length of characters
// used to produce it
@@ -1327,16 +1323,10 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
takesFocus = hasTrigger;
}
}
- computeCursorRings = true;
keepNode:
cachedNode.init(node);
- if (computeCursorRings == false) {
- cachedNode.setBounds(bounds);
- cachedNode.mCursorRing.append(bounds);
- } else if (ConstructPartRects(node, bounds, &cachedNode.mBounds,
- globalOffsetX, globalOffsetY, &cachedNode.mCursorRing,
- &imageCount) == false)
- continue;
+ cachedNode.setBounds(bounds);
+ cachedNode.mCursorRing.append(bounds);
keepTextNode:
if (nodeRenderer) { // area tags' node->renderer() == 0
RenderStyle* style = nodeRenderer->style();
@@ -1598,85 +1588,189 @@ static bool isUnicodeSpace(UChar ch)
static bool validZip(int stateIndex, const UChar* zipPtr)
{
- static const struct {
- char mLow;
- char mHigh;
- char mException1;
- char mException2;
- } zipRange[] = {
- { 99, 99, -1, -1 }, // AK Alaska
- { 35, 36, -1, -1 }, // AL Alabama
- { 71, 72, -1, -1 }, // AR Arkansas
- { 96, 96, -1, -1 }, // AS American Samoa
- { 85, 86, -1, -1 }, // AZ Arizona
- { 90, 96, -1, -1 }, // CA California
- { 80, 81, -1, -1 }, // CO Colorado
- { 6, 6, -1, -1 }, // CT Connecticut
- { 20, 20, -1, -1 }, // DC District of Columbia
- { 19, 19, -1, -1 }, // DE Delaware
- { 32, 34, -1, -1 }, // FL Florida
- { 96, 96, -1, -1 }, // FM Federated States of Micronesia
- { 30, 31, -1, -1 }, // GA Georgia
- { 96, 96, -1, -1 }, // GU Guam
- { 96, 96, -1, -1 }, // HI Hawaii
- { 50, 52, -1, -1 }, // IA Iowa
- { 83, 83, -1, -1 }, // ID Idaho
- { 60, 62, -1, -1 }, // IL Illinois
- { 46, 47, -1, -1 }, // IN Indiana
- { 66, 67, 73, -1 }, // KS Kansas
- { 40, 42, -1, -1 }, // KY Kentucky
- { 70, 71, -1, -1 }, // LA Louisiana
- { 1, 2, -1, -1 }, // MA Massachusetts
- { 20, 21, -1, -1 }, // MD Maryland
- { 3, 4, -1, -1 }, // ME Maine
- { 96, 96, -1, -1 }, // MH Marshall Islands
- { 48, 49, -1, -1 }, // MI Michigan
- { 55, 56, -1, -1 }, // MN Minnesota
- { 63, 65, -1, -1 }, // MO Missouri
- { 96, 96, -1, -1 }, // MP Northern Mariana Islands
- { 38, 39, -1, -1 }, // MS Mississippi
- { 55, 56, -1, -1 }, // MT Montana
- { 27, 28, -1, -1 }, // NC North Carolina
- { 58, 58, -1, -1 }, // ND North Dakota
- { 68, 69, -1, -1 }, // NE Nebraska
- { 3, 4, -1, -1 }, // NH New Hampshire
- { 7, 8, -1, -1 }, // NJ New Jersey
- { 87, 88, 86, -1 }, // NM New Mexico
- { 88, 89, 96, -1 }, // NV Nevada
- { 10, 14, 0, 6 }, // NY New York
- { 43, 45, -1, -1 }, // OH Ohio
- { 73, 74, -1, -1 }, // OK Oklahoma
- { 97, 97, -1, -1 }, // OR Oregon
- { 15, 19, -1, -1 }, // PA Pennsylvania
- { 6, 6, 0, 9 }, // PR Puerto Rico
- { 96, 96, -1, -1 }, // PW Palau
- { 2, 2, -1, -1 }, // RI Rhode Island
- { 29, 29, -1, -1 }, // SC South Carolina
- { 57, 57, -1, -1 }, // SD South Dakota
- { 37, 38, -1, -1 }, // TN Tennessee
- { 75, 79, 87, 88 }, // TX Texas
- { 84, 84, -1, -1 }, // UT Utah
- { 22, 24, 20, -1 }, // VA Virginia
- { 6, 9, -1, -1 }, // VI Virgin Islands
- { 5, 5, -1, -1 }, // VT Vermont
- { 98, 99, -1, -1 }, // WA Washington
- { 53, 54, -1, -1 }, // WI Wisconsin
- { 24, 26, -1, -1 }, // WV West Virginia
- { 82, 83, -1, -1 } // WY Wyoming
+ enum USState {
+ AP = -4, // AP (military base in the Pacific)
+ AA = -3, // AA (military base inside the US)
+ AE = -2, // AE (military base outside the US)
+ XX = -1, // (not in use)
+ AK = 0, // AK Alaska
+ AL = 1, // AL Alabama
+ AR = 2, // AR Arkansas
+ AS = 3, // AS American Samoa
+ AZ = 4, // AZ Arizona
+ CA = 5, // CA California
+ CO = 6, // CO Colorado
+ CT = 7, // CT Connecticut
+ DC = 8, // DC District of Columbia
+ DE = 9, // DE Delaware
+ FL = 10, // FL Florida
+ FM = 11, // FM Federated States of Micronesia
+ GA = 12, // GA Georgia
+ GU = 13, // GU Guam
+ HI = 14, // HI Hawaii
+ IA = 15, // IA Iowa
+ ID = 16, // ID Idaho
+ IL = 17, // IL Illinois
+ IN = 18, // IN Indiana
+ KS = 19, // KS Kansas
+ KY = 20, // KY Kentucky
+ LA = 21, // LA Louisiana
+ MA = 22, // MA Massachusetts
+ MD = 23, // MD Maryland
+ ME = 24, // ME Maine
+ MH = 25, // MH Marshall Islands
+ MI = 26, // MI Michigan
+ MN = 27, // MN Minnesota
+ MO = 28, // MO Missouri
+ MP = 29, // MP Northern Mariana Islands
+ MS = 30, // MS Mississippi
+ MT = 31, // MT Montana
+ NC = 32, // NC North Carolina
+ ND = 33, // ND North Dakota
+ NE = 34, // NE Nebraska
+ NH = 35, // NH New Hampshire
+ NJ = 36, // NJ New Jersey
+ NM = 37, // NM New Mexico
+ NV = 38, // NV Nevada
+ NY = 39, // NY New York
+ OH = 40, // OH Ohio
+ OK = 41, // OK Oklahoma
+ OR = 42, // OR Oregon
+ PA = 43, // PA Pennsylvania
+ PR = 44, // PR Puerto Rico
+ PW = 45, // PW Palau
+ RI = 46, // RI Rhode Island
+ SC = 47, // SC South Carolina
+ SD = 48, // SD South Dakota
+ TN = 49, // TN Tennessee
+ TX = 50, // TX Texas
+ UT = 51, // UT Utah
+ VA = 52, // VA Virginia
+ VI = 53, // VI Virgin Islands
+ VT = 54, // VT Vermont
+ WA = 55, // WA Washington
+ WI = 56, // WI Wisconsin
+ WV = 57, // WV West Virginia
+ WY = 58, // WY Wyoming
+ };
+
+ static const USState stateForZipPrefix[] = {
+ // 0 1 2 3 4 5 6 7 8 9
+ XX, XX, XX, XX, XX, NY, PR, PR, VI, PR, // 000-009
+ MA, MA, MA, MA, MA, MA, MA, MA, MA, MA, // 010-019
+ MA, MA, MA, MA, MA, MA, MA, MA, RI, RI, // 020-029
+ NH, NH, NH, NH, NH, NH, NH, NH, NH, ME, // 030-039
+ ME, ME, ME, ME, ME, ME, ME, ME, ME, ME, // 040-049
+ VT, VT, VT, VT, VT, MA, VT, VT, VT, VT, // 050-059
+ CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, // 060-069
+ NJ, NJ, NJ, NJ, NJ, NJ, NJ, NJ, NJ, NJ, // 070-079
+ NJ, NJ, NJ, NJ, NJ, NJ, NJ, NJ, NJ, NJ, // 080-089
+ AE, AE, AE, AE, AE, AE, AE, AE, AE, XX, // 090-099
+ NY, NY, NY, NY, NY, NY, NY, NY, NY, NY, // 100-109
+ NY, NY, NY, NY, NY, NY, NY, NY, NY, NY, // 110-119
+ NY, NY, NY, NY, NY, NY, NY, NY, NY, NY, // 120-129
+ NY, NY, NY, NY, NY, NY, NY, NY, NY, NY, // 130-139
+ NY, NY, NY, NY, NY, NY, NY, NY, NY, NY, // 140-149
+ PA, PA, PA, PA, PA, PA, PA, PA, PA, PA, // 150-159
+ PA, PA, PA, PA, PA, PA, PA, PA, PA, PA, // 160-169
+ PA, PA, PA, PA, PA, PA, PA, PA, PA, PA, // 170-179
+ PA, PA, PA, PA, PA, PA, PA, PA, PA, PA, // 180-189
+ PA, PA, PA, PA, PA, PA, PA, DE, DE, DE, // 190-199
+ DC, VA, DC, DC, DC, DC, MD, MD, MD, MD, // 200-209
+ MD, MD, MD, XX, MD, MD, MD, MD, MD, MD, // 210-219
+ VA, VA, VA, VA, VA, VA, VA, VA, VA, VA, // 220-229
+ VA, VA, VA, VA, VA, VA, VA, VA, VA, VA, // 230-239
+ VA, VA, VA, VA, VA, VA, VA, WV, WV, WV, // 240-249
+ WV, WV, WV, WV, WV, WV, WV, WV, WV, WV, // 250-259
+ WV, WV, WV, WV, WV, WV, WV, WV, WV, XX, // 260-269
+ NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, // 270-279
+ NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, // 280-289
+ SC, SC, SC, SC, SC, SC, SC, SC, SC, SC, // 290-299
+ GA, GA, GA, GA, GA, GA, GA, GA, GA, GA, // 300-309
+ GA, GA, GA, GA, GA, GA, GA, GA, GA, GA, // 310-319
+ FL, FL, FL, FL, FL, FL, FL, FL, FL, FL, // 320-329
+ FL, FL, FL, FL, FL, FL, FL, FL, FL, FL, // 330-339
+ AA, FL, FL, XX, FL, XX, FL, FL, XX, FL, // 340-349
+ AL, AL, AL, XX, AL, AL, AL, AL, AL, AL, // 350-359
+ AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, // 360-369
+ TN, TN, TN, TN, TN, TN, TN, TN, TN, TN, // 370-379
+ TN, TN, TN, TN, TN, TN, MS, MS, MS, MS, // 380-389
+ MS, MS, MS, MS, MS, MS, MS, MS, GA, GA, // 390-399
+ KY, KY, KY, KY, KY, KY, KY, KY, KY, KY, // 400-409
+ KY, KY, KY, KY, KY, KY, KY, KY, KY, XX, // 410-419
+ KY, KY, KY, KY, KY, KY, KY, KY, XX, XX, // 420-429
+ OH, OH, OH, OH, OH, OH, OH, OH, OH, OH, // 430-439
+ OH, OH, OH, OH, OH, OH, OH, OH, OH, OH, // 440-449
+ OH, OH, OH, OH, OH, OH, OH, OH, OH, OH, // 450-459
+ IN, IN, IN, IN, IN, IN, IN, IN, IN, IN, // 460-469
+ IN, IN, IN, IN, IN, IN, IN, IN, IN, IN, // 470-479
+ MI, MI, MI, MI, MI, MI, MI, MI, MI, MI, // 480-489
+ MI, MI, MI, MI, MI, MI, MI, MI, MI, MI, // 490-499
+ IA, IA, IA, IA, IA, IA, IA, IA, IA, IA, // 500-509
+ IA, IA, IA, IA, IA, IA, IA, XX, XX, XX, // 510-519
+ IA, IA, IA, IA, IA, IA, IA, IA, IA, XX, // 520-529
+ WI, WI, WI, XX, WI, WI, XX, WI, WI, WI, // 530-539
+ WI, WI, WI, WI, WI, WI, WI, WI, WI, WI, // 540-549
+ MN, MN, XX, MN, MN, MN, MN, MN, MN, MN, // 550-559
+ MN, MN, MN, MN, MN, MN, MN, MN, XX, DC, // 560-569
+ SD, SD, SD, SD, SD, SD, SD, SD, XX, XX, // 570-579
+ ND, ND, ND, ND, ND, ND, ND, ND, ND, XX, // 580-589
+ MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, // 590-599
+ IL, IL, IL, IL, IL, IL, IL, IL, IL, IL, // 600-609
+ IL, IL, IL, IL, IL, IL, IL, IL, IL, IL, // 610-619
+ IL, XX, IL, IL, IL, IL, IL, IL, IL, IL, // 620-629
+ MO, MO, XX, MO, MO, MO, MO, MO, MO, MO, // 630-639
+ MO, MO, XX, XX, MO, MO, MO, MO, MO, MO, // 640-649
+ MO, MO, MO, MO, MO, MO, MO, MO, MO, XX, // 650-659
+ KS, KS, KS, XX, KS, KS, KS, KS, KS, KS, // 660-669
+ KS, KS, KS, KS, KS, KS, KS, KS, KS, KS, // 670-679
+ NE, NE, XX, NE, NE, NE, NE, NE, NE, NE, // 680-689
+ NE, NE, NE, NE, XX, XX, XX, XX, XX, XX, // 690-699
+ LA, LA, XX, LA, LA, LA, LA, LA, LA, XX, // 700-709
+ LA, LA, LA, LA, LA, XX, AR, AR, AR, AR, // 710-719
+ AR, AR, AR, AR, AR, AR, AR, AR, AR, AR, // 720-729
+ OK, OK, XX, TX, OK, OK, OK, OK, OK, OK, // 730-739
+ OK, OK, XX, OK, OK, OK, OK, OK, OK, OK, // 740-749
+ TX, TX, TX, TX, TX, TX, TX, TX, TX, TX, // 750-759
+ TX, TX, TX, TX, TX, TX, TX, TX, TX, TX, // 760-769
+ TX, XX, TX, TX, TX, TX, TX, TX, TX, TX, // 770-779
+ TX, TX, TX, TX, TX, TX, TX, TX, TX, TX, // 780-789
+ TX, TX, TX, TX, TX, TX, TX, TX, TX, TX, // 790-799
+ CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, // 800-809
+ CO, CO, CO, CO, CO, CO, CO, XX, XX, XX, // 810-819
+ WY, WY, WY, WY, WY, WY, WY, WY, WY, WY, // 820-829
+ WY, WY, ID, ID, ID, ID, ID, ID, ID, XX, // 830-839
+ UT, UT, UT, UT, UT, UT, UT, UT, XX, XX, // 840-849
+ AZ, AZ, AZ, AZ, XX, AZ, AZ, AZ, XX, AZ, // 850-859
+ AZ, XX, XX, AZ, AZ, AZ, XX, XX, XX, XX, // 860-869
+ NM, NM, NM, NM, NM, NM, XX, NM, NM, NM, // 870-879
+ NM, NM, NM, NM, NM, TX, XX, XX, XX, NV, // 880-889
+ NV, NV, XX, NV, NV, NV, XX, NV, NV, XX, // 890-899
+ CA, CA, CA, CA, CA, CA, CA, CA, CA, XX, // 900-909
+ CA, CA, CA, CA, CA, CA, CA, CA, CA, CA, // 910-919
+ CA, CA, CA, CA, CA, CA, CA, CA, CA, XX, // 920-929
+ CA, CA, CA, CA, CA, CA, CA, CA, CA, CA, // 930-939
+ CA, CA, CA, CA, CA, CA, CA, CA, CA, CA, // 940-949
+ CA, CA, CA, CA, CA, CA, CA, CA, CA, CA, // 950-959
+ CA, CA, AP, AP, AP, AP, AP, HI, HI, GU, // 960-969
+ OR, OR, OR, OR, OR, OR, OR, OR, OR, OR, // 970-979
+ WA, WA, WA, WA, WA, WA, WA, XX, WA, WA, // 980-989
+ WA, WA, WA, WA, WA, AK, AK, AK, AK, AK, // 990-999
};
+ if (!zipPtr || !zipPtr[0] || !zipPtr[1] || !zipPtr[2])
+ return false;
+ if (zipPtr[0] < '0' || zipPtr[0] > '9' ||
+ zipPtr[1] < '0' || zipPtr[1] > '9' ||
+ zipPtr[2] < '0' || zipPtr[2] > '9')
+ return false;
+
int zip = zipPtr[0] - '0';
zip *= 10;
zip += zipPtr[1] - '0';
- int low = zipRange[stateIndex].mLow;
- int high = zipRange[stateIndex].mHigh;
- if (zip >= low && zip <= high)
- return true;
- if (zip == zipRange[stateIndex].mException1)
- return true;
- if (zip == zipRange[stateIndex].mException2)
- return true;
- return false;
+ zip *= 10;
+ zip += zipPtr[2] - '0';
+ return stateForZipPrefix[zip] == stateIndex;
}
#define MAX_PLACE_NAME_LENGTH 25 // the longest allowable one word place name
@@ -3027,100 +3121,6 @@ bool CacheBuilder::AddPartRect(IntRect& bounds, int x, int y,
return true;
}
-bool CacheBuilder::ConstructPartRects(Node* node, const IntRect& bounds,
- IntRect* focusBounds, int x, int y, WTF::Vector<IntRect>* result,
- int* imageCountPtr)
-{
- WTF::Vector<ClipColumnTracker> clipTracker(1);
- ClipColumnTracker* baseTracker = clipTracker.data(); // sentinel
- bzero(baseTracker, sizeof(ClipColumnTracker));
- if (node->hasChildNodes() && node->hasTagName(HTMLNames::buttonTag) == false
- && node->hasTagName(HTMLNames::selectTag) == false) {
- // collect all text rects from first to last child
- Node* test = node->firstChild();
- Node* last = NULL;
- Node* prior = node;
- while ((prior = prior->lastChild()) != NULL)
- last = prior;
- ASSERT(last != NULL);
- bool nodeIsAnchor = node->hasTagName(HTMLNames::aTag);
- do {
- do {
- const ClipColumnTracker* lastClip = &clipTracker.last();
- if (test != lastClip->mLastChild)
- break;
- clipTracker.removeLast();
- } while (true);
- RenderObject* renderer = test->renderer();
- if (renderer == NULL)
- continue;
- EVisibility vis = renderer->style()->visibility();
- if (vis == HIDDEN)
- continue;
- bool hasClip = renderer->hasOverflowClip();
- size_t clipIndex = clipTracker.size();
- IntRect clipBounds = IntRect(0, 0, INT_MAX, INT_MAX);
- if (hasClip || --clipIndex > 0) {
- clipBounds = hasClip ? renderer->absoluteBoundingBoxRect() :
- clipTracker.at(clipIndex).mBounds; // x, y fixup done by ConstructTextRect
- }
- if (test->isTextNode()) {
- RenderText* renderText = (RenderText*) renderer;
- InlineTextBox *textBox = renderText->firstTextBox();
- if (textBox == NULL)
- continue;
- if (ConstructTextRect((Text*) test, textBox, 0, INT_MAX,
- x, y, focusBounds, clipBounds, result) == false) {
- return false;
- }
- continue;
- }
- if (test->hasTagName(HTMLNames::imgTag)) {
- IntRect bounds = test->getRect();
- bounds.intersect(clipBounds);
- if (AddPartRect(bounds, x, y, result, focusBounds) == false)
- return false;
- *imageCountPtr += 1;
- continue;
- }
- if (hasClip == false) {
- if (nodeIsAnchor && test->hasTagName(HTMLNames::divTag)) {
- IntRect bounds = renderer->absoluteBoundingBoxRect(); // x, y fixup done by AddPartRect
- RenderBox* renderBox = static_cast<RenderBox*>(renderer);
- int left = bounds.x() + renderBox->paddingLeft() + renderBox->borderLeft();
- int top = bounds.y() + renderBox->paddingTop() + renderBox->borderTop();
- int right = bounds.maxX() - renderBox->paddingRight() - renderBox->borderRight();
- int bottom = bounds.maxY() - renderBox->paddingBottom() - renderBox->borderBottom();
- if (left >= right || top >= bottom)
- continue;
- bounds = IntRect(left, top, right - left, bottom - top);
- if (AddPartRect(bounds, x, y, result, focusBounds) == false)
- return false;
- }
- continue;
- }
- Node* lastChild = test->lastChild();
- if (lastChild == NULL)
- continue;
- clipTracker.grow(clipTracker.size() + 1);
- ClipColumnTracker& clip = clipTracker.last();
- clip.mBounds = renderer->absoluteBoundingBoxRect(); // x, y fixup done by ConstructTextRect
- clip.mLastChild = OneAfter(lastChild);
- clip.mNode = test;
- } while (test != last && (test = test->traverseNextNode()) != NULL);
- }
- if (result->size() == 0 || focusBounds->width() < MINIMUM_FOCUSABLE_WIDTH
- || focusBounds->height() < MINIMUM_FOCUSABLE_HEIGHT) {
- if (bounds.width() < MINIMUM_FOCUSABLE_WIDTH)
- return false;
- if (bounds.height() < MINIMUM_FOCUSABLE_HEIGHT)
- return false;
- result->append(bounds);
- *focusBounds = bounds;
- }
- return true;
-}
-
static inline bool isNotSpace(UChar c)
{
return c <= 0xA0 ? isUnicodeSpace(c) == false :
diff --git a/Source/WebKit/android/nav/CachedDebug.h b/Source/WebKit/android/nav/CachedDebug.h
index f77c07a..c78254e 100644
--- a/Source/WebKit/android/nav/CachedDebug.h
+++ b/Source/WebKit/android/nav/CachedDebug.h
@@ -31,9 +31,9 @@
#define DEBUG_NAV_UI_VERBOSE 0
#if DEBUG_NAV_UI
-#define DBG_NAV_LOG(message) LOGD("%s %s", __FUNCTION__, message)
-#define DBG_NAV_LOGD(format, ...) LOGD("%s " format, __FUNCTION__, __VA_ARGS__)
-#define DEBUG_NAV_UI_LOGD(...) LOGD(__VA_ARGS__)
+#define DBG_NAV_LOG(message) ALOGD("%s %s", __FUNCTION__, message)
+#define DBG_NAV_LOGD(format, ...) ALOGD("%s " format, __FUNCTION__, __VA_ARGS__)
+#define DEBUG_NAV_UI_LOGD(...) ALOGD(__VA_ARGS__)
#else
#define DBG_NAV_LOG(message) ((void)0)
#define DBG_NAV_LOGD(format, ...) ((void)0)
@@ -41,7 +41,7 @@
#endif
#if DEBUG_NAV_UI_VERBOSE
-#define DBG_NAV_LOGV(format, ...) LOGD("%s " format, __FUNCTION__, __VA_ARGS__)
+#define DBG_NAV_LOGV(format, ...) ALOGD("%s " format, __FUNCTION__, __VA_ARGS__)
#else
#define DBG_NAV_LOGV(format, ...) ((void)0)
#endif
@@ -56,13 +56,13 @@
extern FILE* gNavCacheLogFile;
#define NAV_CACHE_LOG_FILE "/data/data/com.android.browser/navlog"
#define DUMP_NAV_LOGD(...) do { if (gNavCacheLogFile) \
- fprintf(gNavCacheLogFile, __VA_ARGS__); else LOGD(__VA_ARGS__); } while (false)
+ fprintf(gNavCacheLogFile, __VA_ARGS__); else ALOGD(__VA_ARGS__); } while (false)
#define DUMP_NAV_LOGX(format, ...) do { if (gNavCacheLogFile) \
fprintf(gNavCacheLogFile, format, __VA_ARGS__); \
- else LOGD("%s " format, __FUNCTION__, __VA_ARGS__); } while (false)
+ else ALOGD("%s " format, __FUNCTION__, __VA_ARGS__); } while (false)
#else
-#define DUMP_NAV_LOGD(...) LOGD(__VA_ARGS__)
-#define DUMP_NAV_LOGX(format, ...) LOGD("%s " format, __FUNCTION__, __VA_ARGS__)
+#define DUMP_NAV_LOGD(...) ALOGD(__VA_ARGS__)
+#define DUMP_NAV_LOGX(format, ...) ALOGD("%s " format, __FUNCTION__, __VA_ARGS__)
#endif
#else
#define DUMP_NAV_LOGD(...) ((void)0)
diff --git a/Source/WebKit/android/nav/CachedNode.cpp b/Source/WebKit/android/nav/CachedNode.cpp
index e500875..e291504 100644
--- a/Source/WebKit/android/nav/CachedNode.cpp
+++ b/Source/WebKit/android/nav/CachedNode.cpp
@@ -132,7 +132,7 @@ void CachedNode::fixUpCursorRects(const CachedFrame* frame)
WebCore::IntRect* boundsPtr = mCursorRing.begin() - 1;
const WebCore::IntRect* const boundsEnd = mCursorRing.begin() + mCursorRing.size();
while (++boundsPtr < boundsEnd)
- LOGD("%s %d:(%d, %d, %d, %d)\n", __FUNCTION__, boundsPtr - mCursorRing.begin(),
+ ALOGD("%s %d:(%d, %d, %d, %d)\n", __FUNCTION__, boundsPtr - mCursorRing.begin(),
boundsPtr->x(), boundsPtr->y(), boundsPtr->width(), boundsPtr->height());
}
#endif
@@ -205,7 +205,7 @@ void CachedNode::fixUpCursorRects(const CachedFrame* frame)
candidateRight - candidateLeft, candidateBottom - candidateTop);
ASSERT(candidate.isEmpty() == false);
#if DEBUG_NAV_UI
- LOGD("%s %d:(%d, %d, %d, %d)\n", __FUNCTION__, mCursorRing.size(),
+ ALOGD("%s %d:(%d, %d, %d, %d)\n", __FUNCTION__, mCursorRing.size(),
candidate.x(), candidate.y(), candidate.width(), candidate.height());
#endif
mCursorRing.append(candidate);
diff --git a/Source/WebKit/android/nav/CachedRoot.cpp b/Source/WebKit/android/nav/CachedRoot.cpp
index 2371c4f..ddebaba 100644
--- a/Source/WebKit/android/nav/CachedRoot.cpp
+++ b/Source/WebKit/android/nav/CachedRoot.cpp
@@ -29,7 +29,6 @@
#include "CachedInput.h"
#include "CachedLayer.h"
#include "CachedNode.h"
-#include "FindCanvas.h"
#include "FloatRect.h"
#include "LayerAndroid.h"
#include "ParseCanvas.h"
@@ -1141,17 +1140,6 @@ bool CachedRoot::checkRings(SkPicture* picture, const CachedNode* node,
return result;
}
-void CachedRoot::draw(FindCanvas& canvas) const
-{
- canvas.setLayerId(-1); // overlays change the ID as their pictures draw
- canvas.drawPicture(*mPicture);
-#if USE(ACCELERATED_COMPOSITING)
- if (!mRootLayer)
- return;
- canvas.drawLayers(mRootLayer);
-#endif
-}
-
const CachedNode* CachedRoot::findAt(const WebCore::IntRect& rect,
const CachedFrame** framePtr, int* x, int* y, bool checkForHidden) const
{
diff --git a/Source/WebKit/android/nav/CachedRoot.h b/Source/WebKit/android/nav/CachedRoot.h
index 65c6062..dc055a5 100644
--- a/Source/WebKit/android/nav/CachedRoot.h
+++ b/Source/WebKit/android/nav/CachedRoot.h
@@ -42,7 +42,6 @@ namespace android {
class CachedHistory;
class CachedNode;
-class FindCanvas;
class CachedRoot : public CachedFrame {
public:
@@ -57,7 +56,6 @@ public:
WebCore::IntPoint cursorLocation() const;
int documentHeight() { return mContents.height(); }
int documentWidth() { return mContents.width(); }
- void draw(FindCanvas& ) const;
const CachedNode* findAt(const WebCore::IntRect& , const CachedFrame** ,
int* x, int* y, bool checkForHidden) const;
const WebCore::IntRect& focusBounds() const { return mFocusBounds; }
diff --git a/Source/WebKit/android/nav/FindCanvas.cpp b/Source/WebKit/android/nav/FindCanvas.cpp
index ca3cfba..a61b73b 100644
--- a/Source/WebKit/android/nav/FindCanvas.cpp
+++ b/Source/WebKit/android/nav/FindCanvas.cpp
@@ -254,15 +254,19 @@ SkRect FindCanvas::addMatchPosH(int index,
return r;
}
-void FindCanvas::drawLayers(LayerAndroid* layer) {
+void FindCanvas::drawLayers(LayerAndroid* layer, FindOnPage& findOnPage) {
#if USE(ACCELERATED_COMPOSITING)
+ int layerId = layer->uniqueId();
+ unsigned matchesBegin = found();
SkPicture* picture = layer->picture();
if (picture) {
- setLayerId(layer->uniqueId());
+ setLayerId(layerId);
drawPicture(*picture);
}
+ findOnPage.setLayerMatchRange(layerId,
+ std::pair<unsigned, unsigned>(matchesBegin, found()));
for (int i = 0; i < layer->countChildren(); i++)
- drawLayers(layer->getChild(i));
+ drawLayers(layer->getChild(i), findOnPage);
#endif
}
@@ -495,7 +499,7 @@ void FindCanvas::insertMatchInfo(const SkRegion& region) {
mWorkingPicture->endRecording();
MatchInfo matchInfo;
mMatches->append(matchInfo);
- LOGD("%s region=%p pict=%p layer=%d", __FUNCTION__,
+ ALOGD("%s region=%p pict=%p layer=%d", __FUNCTION__,
&region, mWorkingPicture, mLayerId);
mMatches->last().set(region, mWorkingPicture, mLayerId);
}
@@ -697,4 +701,15 @@ void FindOnPage::setMatches(WTF::Vector<MatchInfo>* matches)
}
}
+std::pair<unsigned, unsigned> FindOnPage::getLayerMatchRange(int layerId) const
+{
+ return m_layerMatchRangeMap.get(layerId);
+}
+
+void FindOnPage::setLayerMatchRange(int layerId,
+ const std::pair<unsigned, unsigned> range)
+{
+ m_layerMatchRangeMap.set(layerId, range);
+}
+
}
diff --git a/Source/WebKit/android/nav/FindCanvas.h b/Source/WebKit/android/nav/FindCanvas.h
index 0fa095c..939e568 100644
--- a/Source/WebKit/android/nav/FindCanvas.h
+++ b/Source/WebKit/android/nav/FindCanvas.h
@@ -37,8 +37,10 @@
#include <unicode/umachine.h>
#include <wtf/Vector.h>
+#include <wtf/HashMap.h>
namespace android {
+class FindOnPage;
// Stores both region information and an SkPicture of the match, so that the
// region can be drawn, followed by drawing the matching text on top of it.
@@ -141,7 +143,7 @@ public:
const SkPaint& paint) {
}
- void drawLayers(LayerAndroid*);
+ void drawLayers(LayerAndroid* rootLayer, FindOnPage& findOnPage);
int found() const { return mNumFound; }
void setLayerId(int layerId) { mLayerId = layerId; }
@@ -235,11 +237,18 @@ public:
bool isCurrentLocationValid() { return m_hasCurrentLocation; }
void setMatches(WTF::Vector<MatchInfo>* matches);
WTF::Vector<MatchInfo>* matches() { return m_matches; }
+
+ // Some functions to determine which matches belong to which layers.
+ std::pair<unsigned, unsigned> getLayerMatchRange(int layerId) const;
+ void setLayerMatchRange(int layerId,
+ const std::pair<unsigned, unsigned> range);
+
private:
void drawMatch(const SkRegion& region, SkCanvas* canvas, bool focused);
void setUpFindPaint();
void storeCurrentMatchLocation();
WTF::Vector<MatchInfo>* m_matches;
+ WTF::HashMap< int, std::pair<unsigned, unsigned> > m_layerMatchRangeMap;
// Stores the location of the current match.
SkIPoint m_currentMatchLocation;
// Tells whether the value in m_currentMatchLocation is valid.
diff --git a/Source/WebKit/android/nav/SelectText.cpp b/Source/WebKit/android/nav/SelectText.cpp
index d20c44a..2035fbb 100644
--- a/Source/WebKit/android/nav/SelectText.cpp
+++ b/Source/WebKit/android/nav/SelectText.cpp
@@ -52,7 +52,7 @@
// #define EXTRA_NOISY_LOGGING 1
#define DEBUG_TOUCH_HANDLES 0
#if DEBUG_TOUCH_HANDLES
-#define DBG_HANDLE_LOG(format, ...) LOGD("%s " format, __FUNCTION__, __VA_ARGS__)
+#define DBG_HANDLE_LOG(format, ...) ALOGD("%s " format, __FUNCTION__, __VA_ARGS__)
#else
#define DBG_HANDLE_LOG(...)
#endif
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index 76f0fb8..9bf95e5 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -53,9 +53,6 @@
#include "SkPicture.h"
#include "SkRect.h"
#include "SkTime.h"
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
#include "TilesManager.h"
#include "WebCoreJni.h"
#include "WebRequestContext.h"
@@ -95,7 +92,7 @@ static jfieldID gWebViewField;
static jmethodID GetJMethod(JNIEnv* env, jclass clazz, const char name[], const char signature[])
{
jmethodID m = env->GetMethodID(clazz, name, signature);
- LOG_ASSERT(m, "Could not find method %s", name);
+ ALOG_ASSERT(m, "Could not find method %s", name);
return m;
}
@@ -134,7 +131,6 @@ struct JavaGlue {
jmethodID m_viewInvalidateRect;
jmethodID m_postInvalidateDelayed;
jmethodID m_pageSwapCallback;
- jmethodID m_inFullScreenMode;
jfieldID m_rectLeft;
jfieldID m_rectTop;
jmethodID m_rectWidth;
@@ -173,12 +169,11 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl, WTF::String drawableDir,
m_javaGlue.m_postInvalidateDelayed = GetJMethod(env, clazz,
"viewInvalidateDelayed", "(JIIII)V");
m_javaGlue.m_pageSwapCallback = GetJMethod(env, clazz, "pageSwapCallback", "(Z)V");
- m_javaGlue.m_inFullScreenMode = GetJMethod(env, clazz, "inFullScreenMode", "()Z");
m_javaGlue.m_getTextHandleScale = GetJMethod(env, clazz, "getTextHandleScale", "()F");
env->DeleteLocalRef(clazz);
jclass rectClass = env->FindClass("android/graphics/Rect");
- LOG_ASSERT(rectClass, "Could not find Rect class");
+ ALOG_ASSERT(rectClass, "Could not find Rect class");
m_javaGlue.m_rectLeft = env->GetFieldID(rectClass, "left", "I");
m_javaGlue.m_rectTop = env->GetFieldID(rectClass, "top", "I");
m_javaGlue.m_rectWidth = GetJMethod(env, rectClass, "width", "()I");
@@ -186,7 +181,7 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl, WTF::String drawableDir,
env->DeleteLocalRef(rectClass);
jclass rectClassF = env->FindClass("android/graphics/RectF");
- LOG_ASSERT(rectClassF, "Could not find RectF class");
+ ALOG_ASSERT(rectClassF, "Could not find RectF class");
m_javaGlue.m_rectFLeft = env->GetFieldID(rectClassF, "left", "F");
m_javaGlue.m_rectFTop = env->GetFieldID(rectClassF, "top", "F");
m_javaGlue.m_rectFWidth = GetJMethod(env, rectClassF, "width", "()F");
@@ -196,7 +191,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl, WTF::String drawableDir,
env->SetIntField(javaWebView, gWebViewField, (jint)this);
m_viewImpl = (WebViewCore*) viewImpl;
m_frameCacheUI = 0;
- m_navPictureUI = 0;
m_generation = 0;
m_heightCanMeasure = false;
m_lastDx = 0;
@@ -227,7 +221,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl, WTF::String drawableDir,
stopGL();
#endif
delete m_frameCacheUI;
- delete m_navPictureUI;
SkSafeUnref(m_baseLayer);
delete m_glDrawFunctor;
delete m_buttonSkin;
@@ -247,7 +240,7 @@ WebViewCore* getWebViewCore() const {
float getTextHandleScale()
{
- LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!");
+ ALOG_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())
@@ -313,8 +306,12 @@ void scrollToCurrentMatch()
SkRect matchBounds = m_findOnPage.currentMatchBounds();
LayerAndroid* rootLayer = getFrameCache(DontAllowNewer)->rootLayer();
+ if (!rootLayer)
+ return;
+
Layer* layerContainingMatch = rootLayer->findById(m_findOnPage.currentMatchLayerId());
- ASSERT(layerContainingMatch);
+ if (!layerContainingMatch)
+ return;
// If the match is in a fixed position layer, there's nothing to do.
if (layerContainingMatch->shouldInheritFromRootTransform())
@@ -451,7 +448,7 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect,
WebCore::IntRect& clip, float scale, int extras)
{
#if USE(ACCELERATED_COMPOSITING)
- if (!m_baseLayer || inFullScreenMode())
+ if (!m_baseLayer)
return false;
if (!m_glWebViewState) {
@@ -512,7 +509,7 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect,
&treesSwapped, &newTreeHasAnim);
if (treesSwapped && (m_pageSwapCallbackRegistered || newTreeHasAnim)) {
m_pageSwapCallbackRegistered = false;
- LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!");
+ ALOG_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()) {
@@ -550,7 +547,6 @@ PictureSet* draw(SkCanvas* canvas, SkColor bgColor, int extras, bool split)
if (extras == DrawExtrasCursorRing)
resetCursorRing();
}
- LayerAndroid mainPicture(m_navPictureUI);
DrawExtra* extra = 0;
switch (extras) {
case DrawExtrasFind:
@@ -585,12 +581,12 @@ PictureSet* draw(SkCanvas* canvas, SkColor bgColor, int extras, bool split)
m_baseLayer->setMatrix(canvas->getTotalMatrix());
canvas->resetMatrix();
m_baseLayer->draw(canvas);
+ if (extra) {
+ IntRect dummy; // inval area, unused for now
+ extra->draw(canvas, compositeLayer, &dummy);
+ }
}
#endif
- if (extra) {
- IntRect dummy; // inval area, unused for now
- extra->draw(canvas, &mainPicture, &dummy);
- }
return ret;
}
@@ -708,12 +704,9 @@ CachedRoot* getFrameCache(FrameCachePermission allowNewer)
}
m_viewImpl->gFrameCacheMutex.lock();
delete m_frameCacheUI;
- SkSafeUnref(m_navPictureUI);
m_viewImpl->m_updatedFrameCache = false;
m_frameCacheUI = m_viewImpl->m_frameCacheKit;
- m_navPictureUI = m_viewImpl->m_navPictureKit;
m_viewImpl->m_frameCacheKit = 0;
- m_viewImpl->m_navPictureKit = 0;
m_viewImpl->gFrameCacheMutex.unlock();
if (m_frameCacheUI)
m_frameCacheUI->setRootLayer(compositeRoot());
@@ -734,7 +727,7 @@ CachedRoot* getFrameCache(FrameCachePermission allowNewer)
&& 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!");
+ ALOG_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()) {
@@ -750,7 +743,7 @@ CachedRoot* getFrameCache(FrameCachePermission allowNewer)
int getScaledMaxXScroll()
{
- LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!");
+ ALOG_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())
@@ -762,7 +755,7 @@ int getScaledMaxXScroll()
int getScaledMaxYScroll()
{
- LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!");
+ ALOG_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())
@@ -775,7 +768,7 @@ int getScaledMaxYScroll()
IntRect getVisibleRect()
{
IntRect rect;
- LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!");
+ ALOG_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())
@@ -1257,7 +1250,7 @@ void sendMoveMouse(WebCore::Frame* framePtr, WebCore::Node* nodePtr, int x, int
void sendMoveMouseIfLatest(bool clearTextEntry, bool stopPaintingCaret)
{
- LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!");
+ ALOG_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())
@@ -1269,7 +1262,7 @@ void sendMoveMouseIfLatest(bool clearTextEntry, bool stopPaintingCaret)
void sendMotionUp(WebCore::Frame* framePtr, WebCore::Node* nodePtr, int x, int y)
{
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!");
+ ALOG_ASSERT(m_javaGlue.m_obj, "A WebView was not associated with this WebViewNative!");
JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject javaObject = m_javaGlue.object(env);
@@ -1315,7 +1308,7 @@ int currentMatchIndex()
bool scrollBy(int dx, int dy)
{
- LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!");
+ ALOG_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);
@@ -1403,17 +1396,6 @@ void postInvalidateDelayed(int64_t delay, const WebCore::IntRect& bounds)
checkException(env);
}
-bool inFullScreenMode()
-{
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- AutoJObject javaObject = m_javaGlue.object(env);
- if (!javaObject.get())
- return false;
- jboolean result = env->CallBooleanMethod(javaObject.get(), m_javaGlue.m_inFullScreenMode);
- checkException(env);
- return result;
-}
-
int moveGeneration()
{
return m_viewImpl->m_moveGeneration;
@@ -1421,7 +1403,7 @@ int moveGeneration()
LayerAndroid* compositeRoot() const
{
- LOG_ASSERT(!m_baseLayer || m_baseLayer->countChildren() == 1,
+ ALOG_ASSERT(!m_baseLayer || m_baseLayer->countChildren() == 1,
"base layer can't have more than one child %s", __FUNCTION__);
if (m_baseLayer && m_baseLayer->countChildren() == 1)
return static_cast<LayerAndroid*>(m_baseLayer->getChild(0));
@@ -1530,13 +1512,16 @@ void setVisibleRect(SkRect& visibleRect) {
m_visibleRect = visibleRect;
}
+FindOnPage& findOnPage() {
+ return m_findOnPage;
+}
+
bool m_isDrawingPaused;
private: // local state for WebView
// private to getFrameCache(); other functions operate in a different thread
CachedRoot* m_frameCacheUI; // navigation data ready for use
WebViewCore* m_viewImpl;
int m_generation; // associate unique ID with sent kit focus to match with ui
- SkPicture* m_navPictureUI;
SkMSec m_ringAnimationEnd;
// Corresponds to the same-named boolean on the java side.
bool m_heightCanMeasure;
@@ -1566,8 +1551,7 @@ class GLDrawFunctor : Functor {
public:
GLDrawFunctor(WebView* _wvInstance,
bool(WebView::*_funcPtr)(WebCore::IntRect&, WebCore::IntRect*,
- WebCore::IntRect&, int, WebCore::IntRect&,
- jfloat, jint),
+ WebCore::IntRect&, int, WebCore::IntRect&, jfloat, jint),
WebCore::IntRect _viewRect, float _scale, int _extras) {
wvInstance = _wvInstance;
funcPtr = _funcPtr;
@@ -1671,7 +1655,7 @@ static bool nativeCacheHitIsPlugin(JNIEnv *env, jobject obj)
static void nativeClearCursor(JNIEnv *env, jobject obj)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
view->clearCursor();
}
@@ -1858,7 +1842,7 @@ static void nativeDebugDump(JNIEnv *env, jobject obj)
{
#if DUMP_NAV_CACHE
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
view->debugDump();
#endif
}
@@ -1924,7 +1908,7 @@ static bool nativeEvaluateLayersAnimations(JNIEnv *env, jobject obj, jint native
return false;
}
-static void nativeSetBaseLayer(JNIEnv *env, jobject obj, jint layer, jobject inval,
+static void nativeSetBaseLayer(JNIEnv *env, jobject obj, jint nativeView, jint layer, jobject inval,
jboolean showVisualIndicator,
jboolean isPictureAfterFirstLayout,
jboolean registerPageSwapCallback)
@@ -1933,7 +1917,7 @@ static void nativeSetBaseLayer(JNIEnv *env, jobject obj, jint layer, jobject inv
SkRegion invalRegion;
if (inval)
invalRegion = *GraphicsJNI::getNativeRegion(env, inval);
- GET_NATIVE_VIEW(env, obj)->setBaseLayer(layerImpl, invalRegion, showVisualIndicator,
+ ((WebView*)nativeView)->setBaseLayer(layerImpl, invalRegion, showVisualIndicator,
isPictureAfterFirstLayout,
registerPageSwapCallback);
}
@@ -1981,7 +1965,7 @@ static bool nativeHasContent(JNIEnv *env, jobject obj)
static jobject nativeImageURI(JNIEnv *env, jobject obj, jint x, jint y)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
WTF::String uri = view->imageURI(x, y);
return wtfStringToJstring(env, uri);
}
@@ -2142,28 +2126,21 @@ static jint nativeFocusNodePointer(JNIEnv *env, jobject obj)
static bool nativeCursorWantsKeyEvents(JNIEnv* env, jobject jwebview) {
WebView* view = GET_NATIVE_VIEW(env, jwebview);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
return view->cursorWantsKeyEvents();
}
static void nativeHideCursor(JNIEnv *env, jobject obj)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
view->hideCursor();
}
-static void nativeInstrumentReport(JNIEnv *env, jobject obj)
-{
-#ifdef ANDROID_INSTRUMENT
- TimeCounter::reportNow();
-#endif
-}
-
static void nativeSelectBestAt(JNIEnv *env, jobject obj, jobject jrect)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
WebCore::IntRect rect = jrect_to_webrect(env, jrect);
view->selectBestAt(rect);
}
@@ -2171,7 +2148,7 @@ static void nativeSelectBestAt(JNIEnv *env, jobject obj, jobject jrect)
static void nativeSelectAt(JNIEnv *env, jobject obj, jint x, jint y)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
WebCore::IntRect rect = IntRect(x, y , 1, 1);
view->selectBestAt(rect);
if (view->hasCursorNode())
@@ -2234,7 +2211,7 @@ static bool nativeMotionUp(JNIEnv *env, jobject obj,
int x, int y, int slop)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
return view->motionUp(x, y, slop);
}
@@ -2253,14 +2230,14 @@ static bool nativeMoveCursor(JNIEnv *env, jobject obj,
{
WebView* view = GET_NATIVE_VIEW(env, obj);
DBG_NAV_LOGD("env=%p obj=%p view=%p", env, obj, view);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
return view->moveCursor(key, count, ignoreScroll);
}
static void nativeSetFindIsUp(JNIEnv *env, jobject obj, jboolean isUp)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
view->setFindIsUp(isUp);
}
@@ -2277,18 +2254,18 @@ static void nativeShowCursorTimed(JNIEnv *env, jobject obj)
static void nativeSetHeightCanMeasure(JNIEnv *env, jobject obj, bool measure)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in nativeSetHeightCanMeasure");
+ ALOG_ASSERT(view, "view not set in nativeSetHeightCanMeasure");
view->setHeightCanMeasure(measure);
}
static jobject nativeGetCursorRingBounds(JNIEnv *env, jobject obj)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
jclass rectClass = env->FindClass("android/graphics/Rect");
- LOG_ASSERT(rectClass, "Could not find Rect class!");
+ ALOG_ASSERT(rectClass, "Could not find Rect class!");
jmethodID init = env->GetMethodID(rectClass, "<init>", "(IIII)V");
- LOG_ASSERT(init, "Could not find constructor for Rect");
+ ALOG_ASSERT(init, "Could not find constructor for Rect");
WebCore::IntRect webRect;
view->cursorRingBounds(&webRect);
jobject rect = env->NewObject(rectClass, init, webRect.x(),
@@ -2317,7 +2294,7 @@ static int nativeFindAll(JNIEnv *env, jobject obj, jstring findLower,
return 0;
}
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in nativeFindAll");
+ ALOG_ASSERT(view, "view not set in nativeFindAll");
CachedRoot* root = view->getFrameCache(WebView::AllowNewer);
if (!root) {
env->ReleaseStringChars(findLower, findLowerChars);
@@ -2343,7 +2320,20 @@ static int nativeFindAll(JNIEnv *env, jobject obj, jstring findLower,
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
canvas.setBitmapDevice(bitmap);
- root->draw(canvas);
+ FindOnPage& findOnPage = view->findOnPage();
+ BaseLayerAndroid* baseLayer = view->getBaseLayer();
+ if (baseLayer) {
+ canvas.setLayerId(-1);
+ unsigned matchesBegin = canvas.found();
+ baseLayer->drawCanvas(&canvas);
+ findOnPage.setLayerMatchRange(-1,
+ std::pair<unsigned, unsigned>(matchesBegin, canvas.found()));
+ }
+#if USE(ACCELERATED_COMPOSITING)
+ LayerAndroid* compositeLayer = view->compositeRoot();
+ if (compositeLayer)
+ canvas.drawLayers(compositeLayer, findOnPage);
+#endif
WTF::Vector<MatchInfo>* matches = canvas.detachMatches();
// With setMatches, the WebView takes ownership of matches
view->setMatches(matches, sameAsLastSearch);
@@ -2357,21 +2347,21 @@ static int nativeFindAll(JNIEnv *env, jobject obj, jstring findLower,
static void nativeFindNext(JNIEnv *env, jobject obj, bool forward)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in nativeFindNext");
+ ALOG_ASSERT(view, "view not set in nativeFindNext");
view->findNext(forward);
}
static int nativeFindIndex(JNIEnv *env, jobject obj)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in nativeFindIndex");
+ ALOG_ASSERT(view, "view not set in nativeFindIndex");
return view->currentMatchIndex();
}
static void nativeUpdateCachedTextfield(JNIEnv *env, jobject obj, jstring updatedText, jint generation)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in nativeUpdateCachedTextfield");
+ ALOG_ASSERT(view, "view not set in nativeUpdateCachedTextfield");
CachedRoot* root = view->getFrameCache(WebView::DontAllowNewer);
if (!root)
return;
@@ -2388,7 +2378,7 @@ static jint nativeGetBlockLeftEdge(JNIEnv *env, jobject obj, jint x, jint y,
jfloat scale)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
if (!view)
return -1;
return view->getBlockLeftEdge(x, y, scale);
@@ -2397,8 +2387,8 @@ static jint nativeGetBlockLeftEdge(JNIEnv *env, jobject obj, jint x, jint y,
static void nativeDestroy(JNIEnv *env, jobject obj)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOGD("nativeDestroy view: %p", view);
- LOG_ASSERT(view, "view not set in nativeDestroy");
+ ALOGD("nativeDestroy view: %p", view);
+ ALOG_ASSERT(view, "view not set in nativeDestroy");
delete view;
}
@@ -2492,7 +2482,7 @@ static void nativeExtendSelection(JNIEnv *env, jobject obj, int x, int y)
static jobject nativeGetSelection(JNIEnv *env, jobject obj)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
String selection = view->getSelection();
return wtfStringToJstring(env, selection);
}
@@ -2518,9 +2508,16 @@ static void nativeSetSelectionPointer(JNIEnv *env, jobject obj, jint nativeView,
((WebView*)nativeView)->setSelectionPointer(set, scale, x, y);
}
-static void nativeRegisterPageSwapCallback(JNIEnv *env, jobject obj)
+static void nativeRegisterPageSwapCallback(JNIEnv *env, jobject obj, jint nativeView)
+{
+ ((WebView*)nativeView)->registerPageSwapCallback();
+}
+
+static void nativeDiscardAllTextures(JNIEnv *env, jobject obj)
{
- GET_NATIVE_VIEW(env, obj)->registerPageSwapCallback();
+ //discard all textures for debugging/test purposes, but not gl backing memory
+ bool allTextures = true, deleteGLTextures = false;
+ TilesManager::instance()->discardTextures(allTextures, deleteGLTextures);
}
static void nativeTileProfilingStart(JNIEnv *env, jobject obj)
@@ -2617,8 +2614,8 @@ static jstring nativeGetProperty(JNIEnv *env, jobject obj, jstring key)
static void nativeOnTrimMemory(JNIEnv *env, jobject obj, jint level)
{
if (TilesManager::hardwareAccelerationEnabled()) {
- bool freeAllTextures = (level > TRIM_MEMORY_UI_HIDDEN);
- TilesManager::instance()->deallocateTextures(freeAllTextures);
+ bool freeAllTextures = (level > TRIM_MEMORY_UI_HIDDEN), glTextures = true;
+ TilesManager::instance()->discardTextures(freeAllTextures, glTextures);
}
}
@@ -2626,7 +2623,7 @@ static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl)
{
#ifdef ANDROID_DUMP_DISPLAY_TREE
WebView* view = GET_NATIVE_VIEW(env, jwebview);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
if (view && view->getWebViewCore()) {
FILE* file = fopen(DISPLAY_TREE_LOG_FILE, "w");
@@ -2666,7 +2663,7 @@ static int nativeScrollableLayer(JNIEnv* env, jobject jwebview, jint x, jint y,
jobject rect, jobject bounds)
{
WebView* view = GET_NATIVE_VIEW(env, jwebview);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
SkIRect nativeRect, nativeBounds;
int id = view->scrollableLayer(x, y, &nativeRect, &nativeBounds);
if (rect)
@@ -2698,7 +2695,7 @@ static bool nativeScrollLayer(JNIEnv* env, jobject obj, jint layerId, jint x,
static void nativeSetIsScrolling(JNIEnv* env, jobject jwebview, jboolean isScrolling)
{
WebView* view = GET_NATIVE_VIEW(env, jwebview);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
view->setIsScrolling(isScrolling);
}
@@ -2726,6 +2723,15 @@ static void nativeSetPauseDrawing(JNIEnv *env, jobject obj, jint nativeView,
((WebView*)nativeView)->m_isDrawingPaused = pause;
}
+static bool nativeDisableNavcache(JNIEnv *env, jobject obj)
+{
+#if ENABLE(ANDROID_NAVCACHE)
+ return false;
+#else
+ return true;
+#endif
+}
+
/*
* JNI registration
*/
@@ -2838,8 +2844,6 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeHitSelection },
{ "nativeImageURI", "(II)Ljava/lang/String;",
(void*) nativeImageURI },
- { "nativeInstrumentReport", "()V",
- (void*) nativeInstrumentReport },
{ "nativeLayerBounds", "(I)Landroid/graphics/Rect;",
(void*) nativeLayerBounds },
{ "nativeMotionUp", "(III)Z",
@@ -2876,7 +2880,7 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeSetFindIsUp },
{ "nativeSetHeightCanMeasure", "(Z)V",
(void*) nativeSetHeightCanMeasure },
- { "nativeSetBaseLayer", "(ILandroid/graphics/Region;ZZZ)V",
+ { "nativeSetBaseLayer", "(IILandroid/graphics/Region;ZZZ)V",
(void*) nativeSetBaseLayer },
{ "nativeGetTextSelectionRegion", "(ILandroid/graphics/Region;)V",
(void*) nativeGetTextSelectionRegion },
@@ -2894,8 +2898,10 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeSetSelectionPointer },
{ "nativeShowCursorTimed", "()V",
(void*) nativeShowCursorTimed },
- { "nativeRegisterPageSwapCallback", "()V",
+ { "nativeRegisterPageSwapCallback", "(I)V",
(void*) nativeRegisterPageSwapCallback },
+ { "nativeDiscardAllTextures", "()V",
+ (void*) nativeDiscardAllTextures },
{ "nativeTileProfilingStart", "()V",
(void*) nativeTileProfilingStart },
{ "nativeTileProfilingStop", "()F",
@@ -2942,14 +2948,16 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeOnTrimMemory },
{ "nativeSetPauseDrawing", "(IZ)V",
(void*) nativeSetPauseDrawing },
+ { "nativeDisableNavcache", "()Z",
+ (void*) nativeDisableNavcache },
};
int registerWebView(JNIEnv* env)
{
jclass clazz = env->FindClass("android/webkit/WebView");
- LOG_ASSERT(clazz, "Unable to find class android/webkit/WebView");
+ ALOG_ASSERT(clazz, "Unable to find class android/webkit/WebView");
gWebViewField = env->GetFieldID(clazz, "mNativeClass", "I");
- LOG_ASSERT(gWebViewField, "Unable to find android/webkit/WebView.mNativeClass");
+ ALOG_ASSERT(gWebViewField, "Unable to find android/webkit/WebView.mNativeClass");
env->DeleteLocalRef(clazz);
return jniRegisterNativeMethods(env, "android/webkit/WebView", gJavaWebViewMethods, NELEM(gJavaWebViewMethods));
diff --git a/Source/WebKit/android/plugins/ANPSoundInterface.cpp b/Source/WebKit/android/plugins/ANPSoundInterface.cpp
index c238872..12c9176 100644
--- a/Source/WebKit/android/plugins/ANPSoundInterface.cpp
+++ b/Source/WebKit/android/plugins/ANPSoundInterface.cpp
@@ -38,7 +38,7 @@ struct ANPAudioTrack {
android::AudioTrack* mTrack;
};
-static ANPSampleFormat toANPFormat(int fm) {
+static ANPSampleFormat toANPFormat(audio_format_t fm) {
switch (fm) {
case AUDIO_FORMAT_PCM_16_BIT:
return kPCM16Bit_ANPSampleFormat;
@@ -49,7 +49,7 @@ static ANPSampleFormat toANPFormat(int fm) {
}
}
-static int fromANPFormat(ANPSampleFormat fm) {
+static audio_format_t fromANPFormat(ANPSampleFormat fm) {
switch (fm) {
case kPCM16Bit_ANPSampleFormat:
return AUDIO_FORMAT_PCM_16_BIT;
@@ -71,7 +71,7 @@ static void callbackProc(int event, void* user, void* info) {
src = reinterpret_cast<android::AudioTrack::Buffer*>(info);
dst.bufferData = src->raw;
dst.channelCount = src->channelCount;
- dst.format = toANPFormat(src->format);
+ dst.format = toANPFormat((audio_format_t) src->format);
dst.size = src->size;
track->mProc(kMoreData_ANPAudioEvent, track->mUser, &dst);
// return the updated size field
diff --git a/Source/WebKit/android/smoke/MessageThread.cpp b/Source/WebKit/android/smoke/MessageThread.cpp
index 48f2222..97ab18c 100644
--- a/Source/WebKit/android/smoke/MessageThread.cpp
+++ b/Source/WebKit/android/smoke/MessageThread.cpp
@@ -79,7 +79,7 @@ void MessageQueue::post(Message* message) {
AutoMutex lock(m_mutex);
double when = message->m_when;
- LOG_ASSERT(when > 0, "Message time may not be 0");
+ ALOG_ASSERT(when > 0, "Message time may not be 0");
list<Message*>::iterator it;
for (it = m_messages.begin(); it != m_messages.end(); ++it) {
diff --git a/Source/WebKit/android/wds/Command.cpp b/Source/WebKit/android/wds/Command.cpp
index bd8536f..1a365e5 100644
--- a/Source/WebKit/android/wds/Command.cpp
+++ b/Source/WebKit/android/wds/Command.cpp
@@ -95,7 +95,7 @@ public:
virtual ~InternalCommand() { delete m_connection; }
void doCommand() const {
- LOGD("Executing command '%s' (%s)", m_name, m_description);
+ ALOGD("Executing command '%s' (%s)", m_name, m_description);
if (!m_dispatch(m_frame, m_connection))
// XXX: Have useful failure messages
m_connection->write("EPIC FAIL!\n", 11);
diff --git a/Source/WebKit/android/wds/Connection.cpp b/Source/WebKit/android/wds/Connection.cpp
index d7e55ac..52193e5 100644
--- a/Source/WebKit/android/wds/Connection.cpp
+++ b/Source/WebKit/android/wds/Connection.cpp
@@ -35,7 +35,7 @@
#if ENABLE(WDS)
#define MAX_CONNECTION_QUEUE 5
-#define log_errno(x) LOGE("%s: %d", x, strerror(errno))
+#define log_errno(x) ALOGE("%s: %d", x, strerror(errno))
namespace android {
diff --git a/Source/WebKit/android/wds/DebugServer.cpp b/Source/WebKit/android/wds/DebugServer.cpp
index f33a65b..2fde6bd 100644
--- a/Source/WebKit/android/wds/DebugServer.cpp
+++ b/Source/WebKit/android/wds/DebugServer.cpp
@@ -42,7 +42,7 @@
#if ENABLE(WDS)
#define DEFAULT_PORT 9999
-#define log_errno(x) LOGE("%s: %d", x, strerror(errno))
+#define log_errno(x) ALOGE("%s: %d", x, strerror(errno))
namespace android {
@@ -70,7 +70,7 @@ DebugServer::DebugServer() {
char buf[PROPERTY_VALUE_MAX];
int ret = property_get("webcore.wds.enable", buf, NULL);
if (ret != -1 && strcmp(buf, "1") == 0) {
- LOGD("WDS Enabled");
+ ALOGD("WDS Enabled");
m_threadId = createThread(mainThread, this, "WDS");
}
// Initialize the available commands.
@@ -78,26 +78,26 @@ DebugServer::DebugServer() {
}
void DebugServer::start() {
- LOGD("DebugServer thread started");
+ ALOGD("DebugServer thread started");
ConnectionServer cs;
if (!cs.connect(DEFAULT_PORT)) {
- LOGE("Failed to start the server socket connection");
+ ALOGE("Failed to start the server socket connection");
return;
}
while (true ) {
- LOGD("Waiting for incoming connections...");
+ ALOGD("Waiting for incoming connections...");
Connection* conn = cs.accept();
if (!conn) {
log_errno("Failed to accept new connections");
return;
}
- LOGD("...Connection established");
+ ALOGD("...Connection established");
Command* c = Command::Find(conn);
if (!c) {
- LOGE("Could not find matching command");
+ ALOGE("Could not find matching command");
delete conn;
} else {
// Dispatch the command, it will handle cleaning up the connection
@@ -106,7 +106,7 @@ void DebugServer::start() {
}
}
- LOGD("DebugServer thread finished");
+ ALOGD("DebugServer thread finished");
}
} // end namespace WDS
diff --git a/Source/WebKit/android/wds/client/AdbConnection.cpp b/Source/WebKit/android/wds/client/AdbConnection.cpp
index 465f9c3..7d02ecc 100644
--- a/Source/WebKit/android/wds/client/AdbConnection.cpp
+++ b/Source/WebKit/android/wds/client/AdbConnection.cpp
@@ -78,7 +78,7 @@ bool AdbConnection::connect() {
bool AdbConnection::sendRequest(const char* fmt, ...) const {
if (m_fd == -1) {
- LOGE("Connection is closed");
+ ALOGE("Connection is closed");
return false;
}
@@ -89,7 +89,7 @@ bool AdbConnection::sendRequest(const char* fmt, ...) const {
int res = vsnprintf(buf, MAX_COMMAND_LENGTH, fmt, args);
va_end(args);
- LOGV("Sending command: %04X%.*s", res, res, buf);
+ ALOGV("Sending command: %04X%.*s", res, res, buf);
// Construct the payload length
char payloadLen[PAYLOAD_LENGTH + 1];
@@ -115,7 +115,7 @@ static void printFailureMessage(int fd) {
// Grab the payload length
char lenStr[PAYLOAD_LENGTH + 1];
int payloadLen = recv(fd, lenStr, sizeof(lenStr) - 1, 0);
- LOG_ASSERT(payloadLen == PAYLOAD_LENGTH, "Incorrect payload size");
+ ALOG_ASSERT(payloadLen == PAYLOAD_LENGTH, "Incorrect payload size");
lenStr[PAYLOAD_LENGTH] = 0;
// Parse the hex payload
@@ -130,13 +130,13 @@ static void printFailureMessage(int fd) {
log_errno("Failure reading failure message from adb");
return;
} else if (res != payloadLen) {
- LOGE("Incorrect payload length %d - expected %d", res, payloadLen);
+ ALOGE("Incorrect payload length %d - expected %d", res, payloadLen);
return;
}
msg[res] = 0;
// Tell somebody about it
- LOGE("Received failure from adb: %s", msg);
+ ALOGE("Received failure from adb: %s", msg);
// Cleanup
delete[] msg;
@@ -145,7 +145,7 @@ static void printFailureMessage(int fd) {
#define ADB_RESPONSE_LENGTH 4
bool AdbConnection::checkOkayResponse() const {
- LOG_ASSERT(m_fd != -1, "Connection has been closed!");
+ ALOG_ASSERT(m_fd != -1, "Connection has been closed!");
char buf[ADB_RESPONSE_LENGTH];
int res = recv(m_fd, buf, sizeof(buf), 0);
@@ -156,14 +156,14 @@ bool AdbConnection::checkOkayResponse() const {
// Check for a response other than OKAY/FAIL
if ((res == ADB_RESPONSE_LENGTH) && (strncmp(buf, "OKAY", res) == 0)) {
- LOGV("Command OKAY");
+ ALOGV("Command OKAY");
return true;
} else if (strncmp(buf, "FAIL", ADB_RESPONSE_LENGTH) == 0) {
// Something happened, print out the reason for failure
printFailureMessage(m_fd);
return false;
}
- LOGE("Incorrect response from adb - '%.*s'", res, buf);
+ ALOGE("Incorrect response from adb - '%.*s'", res, buf);
return false;
}
@@ -178,13 +178,13 @@ const DeviceList& AdbConnection::getDeviceList() {
clearDevices();
if (m_fd == -1) {
- LOGE("Connection is closed");
+ ALOGE("Connection is closed");
return m_devices;
}
// Try to send the device list request
if (!sendRequest("host:devices")) {
- LOGE("Failed to get device list from adb");
+ ALOGE("Failed to get device list from adb");
return m_devices;
}
@@ -210,7 +210,7 @@ const DeviceList& AdbConnection::getDeviceList() {
log_errno("Failure reading the device list");
return m_devices;
} else if (res != payloadLen) {
- LOGE("Incorrect payload length %d - expected %d", res, payloadLen);
+ ALOGE("Incorrect payload length %d - expected %d", res, payloadLen);
return m_devices;
}
msg[res] = 0;
@@ -224,7 +224,7 @@ const DeviceList& AdbConnection::getDeviceList() {
static const char emulator[] = "emulator-";
if (strncmp(serial, emulator, sizeof(emulator) - 1) == 0)
t = Device::EMULATOR;
- LOGV("Adding device %s (%s)", serial, state);
+ ALOGV("Adding device %s (%s)", serial, state);
m_devices.add(new Device(serial, t, this));
// Reset for the next line
diff --git a/Source/WebKit/android/wds/client/ClientUtils.h b/Source/WebKit/android/wds/client/ClientUtils.h
index 7d0db30..7c4b9ce 100644
--- a/Source/WebKit/android/wds/client/ClientUtils.h
+++ b/Source/WebKit/android/wds/client/ClientUtils.h
@@ -37,7 +37,7 @@
#endif
// Callers need to include Log.h and errno.h to use this macro
-#define log_errno(str) LOGE("%s: %s", str, strerror(errno))
+#define log_errno(str) ALOGE("%s: %s", str, strerror(errno))
// Fill in the sockaddr_in structure for binding to the localhost on the given
// port
diff --git a/Source/WebKit/android/wds/client/main.cpp b/Source/WebKit/android/wds/client/main.cpp
index 1c7d856..276affe 100644
--- a/Source/WebKit/android/wds/client/main.cpp
+++ b/Source/WebKit/android/wds/client/main.cpp
@@ -74,7 +74,7 @@ int main(int argc, char** argv) {
Device::DeviceType type = Device::NONE;
if (argc <= 1) {
- LOGE("wdsclient takes at least 1 argument");
+ ALOGE("wdsclient takes at least 1 argument");
return 1;
} else {
// Parse the options, look for -e or -d to choose a device.
@@ -94,7 +94,7 @@ int main(int argc, char** argv) {
}
}
if (optind == argc) {
- LOGE("No command specified");
+ ALOGE("No command specified");
return 1;
}
}
@@ -109,10 +109,10 @@ int main(int argc, char** argv) {
// No device specified and more than one connected, bail
if (type == Device::NONE && devices.size() > 1) {
- LOGE("More than one device/emulator, please specify with -e or -d");
+ ALOGE("More than one device/emulator, please specify with -e or -d");
return 1;
} else if (devices.size() == 0) {
- LOGE("No devices connected");
+ ALOGE("No devices connected");
return 1;
}
@@ -131,23 +131,23 @@ int main(int argc, char** argv) {
}
if (!device) {
- LOGE("No device found!");
+ ALOGE("No device found!");
return 1;
}
// Forward tcp:9999
if (!device->sendRequest("forward:tcp:" PORT_STR ";tcp:" PORT_STR)) {
- LOGE("Failed to send forwarding request");
+ ALOGE("Failed to send forwarding request");
return 1;
}
- LOGV("Connecting to localhost port " PORT_STR);
+ ALOGV("Connecting to localhost port " PORT_STR);
const char* command = argv[optind];
int commandLen = strlen(command);
#define WDS_COMMAND_LENGTH 4
if (commandLen != WDS_COMMAND_LENGTH) {
- LOGE("Commands must be 4 characters '%s'", command);
+ ALOGE("Commands must be 4 characters '%s'", command);
return 1;
}