summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-02 22:54:32 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-02 22:54:32 -0800
commit6e5759672a7dacb80348e82ef9e14aa0b3722364 (patch)
tree11425ea0b299d6fb89c6d3618a22d97d5bf68d0f
parentcb992f06658b5dfc2075eb12f25b2b69a7482eb4 (diff)
downloadexternal_webkit-6e5759672a7dacb80348e82ef9e14aa0b3722364.zip
external_webkit-6e5759672a7dacb80348e82ef9e14aa0b3722364.tar.gz
external_webkit-6e5759672a7dacb80348e82ef9e14aa0b3722364.tar.bz2
auto import from //depot/cupcake/@137055
-rw-r--r--Android.mk4
-rw-r--r--JavaScriptCore/VM/CodeGenerator.cpp4
-rw-r--r--JavaScriptCore/VM/Machine.h13
-rw-r--r--JavaScriptCore/VM/SegmentedVector.h174
-rw-r--r--JavaScriptCore/kjs/config.h1
-rw-r--r--WebCore/WebCorePrefixAndroid.h3
-rw-r--r--WebCore/plugins/PluginInfoStore.cpp7
-rw-r--r--WebKit/android/TimeCounter.cpp19
-rw-r--r--WebKit/android/TimeCounter.h17
-rw-r--r--WebKit/android/jni/WebSettings.cpp7
-rw-r--r--WebKit/android/jni/WebViewCore.cpp74
-rw-r--r--WebKit/android/nav/CacheBuilder.cpp8
-rw-r--r--WebKit/android/nav/FindCanvas.cpp25
13 files changed, 222 insertions, 134 deletions
diff --git a/Android.mk b/Android.mk
index 6b3ee6b..a0e390f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -70,6 +70,10 @@ ifeq ($(TARGET_ARCH),arm)
LOCAL_CFLAGS += -Darm -fvisibility=hidden
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
diff --git a/JavaScriptCore/VM/CodeGenerator.cpp b/JavaScriptCore/VM/CodeGenerator.cpp
index 2cbf59f..3bfea93 100644
--- a/JavaScriptCore/VM/CodeGenerator.cpp
+++ b/JavaScriptCore/VM/CodeGenerator.cpp
@@ -226,7 +226,7 @@ CodeGenerator::CodeGenerator(ProgramNode* programNode, const Debugger* debugger,
m_globalVarStorageOffset = -RegisterFile::CallFrameHeaderSize - m_codeBlock->numParameters - registerFile->size();
// Add previously defined symbols to bookkeeping.
- m_globals.resize(symbolTable->size());
+ m_globals.grow(symbolTable->size());
SymbolTable::iterator end = symbolTable->end();
for (SymbolTable::iterator it = symbolTable->begin(); it != end; ++it)
registerFor(it->second.getIndex()).setIndex(it->second.getIndex() + m_globalVarStorageOffset);
@@ -322,7 +322,7 @@ CodeGenerator::CodeGenerator(FunctionBodyNode* functionBody, const Debugger* deb
const Identifier* parameters = functionBody->parameters();
size_t parameterCount = functionBody->parameterCount();
m_nextParameter = -RegisterFile::CallFrameHeaderSize - parameterCount - 1;
- m_parameters.resize(1 + parameterCount); // reserve space for "this"
+ m_parameters.grow(1 + parameterCount); // reserve space for "this"
// Add "this" as a parameter
m_thisRegister.setIndex(m_nextParameter);
diff --git a/JavaScriptCore/VM/Machine.h b/JavaScriptCore/VM/Machine.h
index 9ae4d25..6cb8aaa 100644
--- a/JavaScriptCore/VM/Machine.h
+++ b/JavaScriptCore/VM/Machine.h
@@ -36,6 +36,10 @@
#include "RegisterFile.h"
#include <wtf/HashMap.h>
+#ifdef ANDROID_INSTRUMENT
+#include "TimeCounter.h"
+#endif
+
namespace JSC {
class CodeBlock;
@@ -145,7 +149,10 @@ namespace JSC {
{
if (!m_timeoutCheckCount)
resetTimeoutCheck();
-
+#ifdef ANDROID_INSTRUMENT
+ if (!m_timeoutCheckCount)
+ android::TimeCounter::start(android::TimeCounter::JavaScriptTimeCounter);
+#endif
++m_timeoutCheckCount;
}
@@ -153,6 +160,10 @@ namespace JSC {
{
ASSERT(m_timeoutCheckCount);
--m_timeoutCheckCount;
+#ifdef ANDROID_INSTRUMENT
+ if (!m_timeoutCheckCount)
+ android::TimeCounter::record(android::TimeCounter::JavaScriptTimeCounter, __FUNCTION__);
+#endif
}
inline void initTimeout()
diff --git a/JavaScriptCore/VM/SegmentedVector.h b/JavaScriptCore/VM/SegmentedVector.h
index 36ffee0..bbab04f 100644
--- a/JavaScriptCore/VM/SegmentedVector.h
+++ b/JavaScriptCore/VM/SegmentedVector.h
@@ -33,6 +33,9 @@
namespace JSC {
+ // SegmentedVector is just like Vector, but it doesn't move the values
+ // stored in its buffer when it grows. Therefore, it is safe to keep
+ // pointers into a SegmentedVector.
template <typename T, size_t SegmentSize> class SegmentedVector {
public:
SegmentedVector()
@@ -43,121 +46,120 @@ namespace JSC {
~SegmentedVector()
{
- for (size_t i = 1; i < m_segments.size(); i++)
- delete m_segments[i];
+ deleteAllSegments();
}
- T& last()
+ size_t size() const { return m_size; }
+
+ T& at(size_t index)
{
- ASSERT(m_size);
- return m_segments.last()->last();
+ if (index < SegmentSize)
+ return m_inlineSegment[index];
+ return segmentFor(index)->at(subscriptFor(index));
}
- template <typename U> void append(const U& value)
+ T& operator[](size_t index)
{
- if (!(m_size % SegmentSize) && m_size)
- m_segments.append(new Segment);
- m_segments.last()->uncheckedAppend(value);
- m_size++;
+ return at(index);
}
- void removeLast()
+ T& last()
+ {
+ return at(size() - 1);
+ }
+
+ template <typename U> void append(const U& value)
{
- ASSERT(m_size);
- m_size--;
- m_segments.last()->removeLast();
- if (!(m_size % SegmentSize) && m_size >= SegmentSize) {
- delete m_segments.last();
- m_segments.removeLast();
+ ++m_size;
+
+ if (m_size <= SegmentSize) {
+ m_inlineSegment.uncheckedAppend(value);
+ return;
}
+
+ if (!segmentExistsFor(m_size - 1))
+ m_segments.append(new Segment);
+ segmentFor(m_size - 1)->uncheckedAppend(value);
}
- size_t size() const
+ void removeLast()
{
- return m_size;
+ if (m_size <= SegmentSize)
+ m_inlineSegment.removeLast();
+ else
+ segmentFor(m_size - 1)->removeLast();
+ --m_size;
}
- T& operator[](size_t index)
+ void grow(size_t size)
{
- ASSERT(index < m_size);
- if (index < SegmentSize)
- return m_inlineSegment[index];
- return m_segments[index / SegmentSize]->at(index % SegmentSize);
+ ASSERT(size > m_size);
+ ensureSegmentsFor(size);
+ m_size = size;
}
- void resize(size_t size)
+ void clear()
{
- if (size < m_size)
- shrink(size);
- else if (size > m_size)
- grow(size);
- ASSERT(size == m_size);
+ deleteAllSegments();
+ m_segments.resize(1);
+ m_inlineSegment.clear();
+ m_size = 0;
}
private:
- void shrink(size_t size)
+ typedef Vector<T, SegmentSize> Segment;
+
+ void deleteAllSegments()
{
- ASSERT(size < m_size);
- size_t numSegments = size / SegmentSize;
- size_t extra = size % SegmentSize;
- if (extra)
- numSegments++;
- if (!numSegments) {
- for (size_t i = 1; i < m_segments.size(); i++)
- delete m_segments[i];
- m_segments.resize(1);
- m_inlineSegment.resize(0);
- return;
- }
-
- for (size_t i = numSegments; i < m_segments.size(); i++)
+ // Skip the first segment, because it's our inline segment, which was
+ // not created by new.
+ for (size_t i = 1; i < m_segments.size(); i++)
delete m_segments[i];
-
- m_segments.resize(numSegments);
- if (extra)
- m_segments.last()->resize(extra);
- m_size = size;
}
-
- void grow(size_t size)
+
+ bool segmentExistsFor(size_t index)
{
- ASSERT(size > m_size);
- if (size <= SegmentSize) {
- m_inlineSegment.resize(size);
- m_size = size;
- return;
- }
-
- size_t numSegments = size / SegmentSize;
- size_t extra = size % SegmentSize;
- if (extra)
- numSegments++;
- size_t oldSize = m_segments.size();
-
- if (numSegments == oldSize) {
- m_segments.last()->resize(extra);
- m_size = size;
- return;
- }
-
- m_segments.last()->resize(SegmentSize);
-
- m_segments.resize(numSegments);
-
- ASSERT(oldSize < m_segments.size());
- for (size_t i = oldSize; i < (numSegments - 1); i++) {
- Segment* segment = new Segment;
- segment->resize(SegmentSize);
- m_segments[i] = segment;
- }
+ return index / SegmentSize < m_segments.size();
+ }
+
+ Segment* segmentFor(size_t index)
+ {
+ return m_segments[index / SegmentSize];
+ }
+
+ size_t subscriptFor(size_t index)
+ {
+ return index % SegmentSize;
+ }
+
+ void ensureSegmentsFor(size_t size)
+ {
+ size_t segmentCount = m_size / SegmentSize;
+ if (m_size % SegmentSize)
+ ++segmentCount;
+ segmentCount = std::max<size_t>(segmentCount, 1); // We always have at least our inline segment.
+
+ size_t neededSegmentCount = size / SegmentSize;
+ if (size % SegmentSize)
+ ++neededSegmentCount;
+
+ // Fill up to N - 1 segments.
+ size_t end = neededSegmentCount - 1;
+ for (size_t i = segmentCount - 1; i < end; ++i)
+ ensureSegment(i, SegmentSize);
+
+ // Grow segment N to accomodate the remainder.
+ ensureSegment(end, subscriptFor(size - 1) + 1);
+ }
- Segment* segment = new Segment;
- segment->resize(extra ? extra : SegmentSize);
- m_segments[numSegments - 1] = segment;
- m_size = size;
+ void ensureSegment(size_t segmentIndex, size_t size)
+ {
+ ASSERT(segmentIndex <= m_segments.size());
+ if (segmentIndex == m_segments.size())
+ m_segments.append(new Segment);
+ m_segments[segmentIndex]->grow(size);
}
- typedef Vector<T, SegmentSize> Segment;
size_t m_size;
Segment m_inlineSegment;
Vector<Segment*, 32> m_segments;
diff --git a/JavaScriptCore/kjs/config.h b/JavaScriptCore/kjs/config.h
index 80a3798..53bc0a9 100644
--- a/JavaScriptCore/kjs/config.h
+++ b/JavaScriptCore/kjs/config.h
@@ -28,7 +28,6 @@
#if PLATFORM(ANDROID)
#define ANDROID_MOBILE // change can be merged back to WebKit.org for MOBILE
-//#define ANDROID_INSTRUMENT
#endif
#if PLATFORM(WIN_OS)
diff --git a/WebCore/WebCorePrefixAndroid.h b/WebCore/WebCorePrefixAndroid.h
index c4782b6..96fa376 100644
--- a/WebCore/WebCorePrefixAndroid.h
+++ b/WebCore/WebCorePrefixAndroid.h
@@ -81,9 +81,6 @@ typedef unsigned char flex_uint8_t;
#define ANDROID_SELECT_TEXT_AREAS
#define ANDROID_FIX
-// note: if uncomment ANDROID_INSTRUMENT here, you must also
-// uncomment it on line 31 of JavaScriptCore/kjs/config.h
-// #define ANDROID_INSTRUMENT
// Fix for issue 878095. Only call onBlur on an element if it has an
// onBlur event.
diff --git a/WebCore/plugins/PluginInfoStore.cpp b/WebCore/plugins/PluginInfoStore.cpp
index 732a1e1..bd2f2d0 100644
--- a/WebCore/plugins/PluginInfoStore.cpp
+++ b/WebCore/plugins/PluginInfoStore.cpp
@@ -27,6 +27,9 @@
#include "PluginInfoStore.h"
#include "KURL.h"
+#if PLATFORM(ANDROID)
+#include "Page.h"
+#endif
#include "PluginData.h"
#include "PluginDatabase.h"
#include "PluginPackage.h"
@@ -93,11 +96,15 @@ bool PluginInfoStore::supportsMIMEType(const WebCore::String& mimeType)
void refreshPlugins(bool reloadOpenPages)
{
+#if PLATFORM(ANDROID)
+ Page::refreshPlugins(reloadOpenPages);
+#else
PluginDatabase::installedPlugins()->refresh();
if (reloadOpenPages) {
// FIXME: reload open pages
}
+#endif
}
}
diff --git a/WebKit/android/TimeCounter.cpp b/WebKit/android/TimeCounter.cpp
index c92afb2..0dc0f3e 100644
--- a/WebKit/android/TimeCounter.cpp
+++ b/WebKit/android/TimeCounter.cpp
@@ -56,18 +56,19 @@ uint32_t TimeCounter::sLastCounter[TimeCounter::TotalTimeCounterCount];
uint32_t TimeCounter::sStartTime[TimeCounter::TotalTimeCounterCount];
static const char* timeCounterNames[] = {
- "calculate style",
"css parsing",
+ "javascript",
+ "calculate style",
"Java callback (frame bridge)",
+ "parsing (may include calcStyle or Java callback)",
"layout",
"native 1 (frame bridge)",
- "parsing (may include calcStyle or Java callback)",
- "native 3 (resource load)",
- "native 2 (shared timer)",
+ "native 2 (resource load)",
+ "native 3 (shared timer)",
"build nav (webview core)",
- "draw content (webview core)",
"record content (webview core)",
- "native 4 (webview core)"
+ "native 4 (webview core)",
+ "draw content (webview ui)",
};
void TimeCounter::record(enum Type type, const char* functionName)
@@ -92,8 +93,6 @@ void TimeCounter::report(const KURL& url, int live, int dead)
int threadTime = get_thread_msec() - sStartThreadTime;
LOGD("*-* Total load time: %d ms, thread time: %d ms for %s\n",
totalTime, threadTime, urlString.utf8().data());
-// FIXME: JSGlobalObject no longer records time
-// JSC::JSGlobalObject::reportTimeCounter();
for (Type type = (Type) 0; type < TotalTimeCounterCount; type
= (Type) (type + 1)) {
char scratch[256];
@@ -115,8 +114,6 @@ void TimeCounter::reportNow()
LOGD("*-* Elapsed time: %d ms, ui thread time: %d ms, webcore thread time:"
" %d ms\n", elapsedTime, elapsedThreadTime, sEndWebCoreThreadTime -
sStartWebCoreThreadTime);
-// FIXME: JSGlobalObject no longer records time
-// JSC::JSGlobalObject::reportTimeCounter();
for (Type type = (Type) 0; type < TotalTimeCounterCount; type
= (Type) (type + 1)) {
if (sTotalTimeUsed[type] == sLastTimeUsed[type])
@@ -137,8 +134,6 @@ void TimeCounter::reportNow()
}
void TimeCounter::reset() {
-// FIXME: JSGlobalObject no longer records time
-// JSC::JSGlobalObject::resetTimeCounter();
bzero(sTotalTimeUsed, sizeof(sTotalTimeUsed));
bzero(sCounter, sizeof(sCounter));
LOGD("*-* Start browser instrument\n");
diff --git a/WebKit/android/TimeCounter.h b/WebKit/android/TimeCounter.h
index 58d2468..d1b2dff 100644
--- a/WebKit/android/TimeCounter.h
+++ b/WebKit/android/TimeCounter.h
@@ -41,18 +41,21 @@ namespace android {
class TimeCounter {
public:
enum Type {
- CalculateStyleTimeCounter,
+ // function base counters
CSSTimeCounter,
+ JavaScriptTimeCounter,
+ CalculateStyleTimeCounter,
JavaCallbackTimeCounter,
- LayoutTimeCounter,
- NativeCallbackTimeCounter,
ParsingTimeCounter,
- ResourceTimeCounter,
- SharedTimerTimeCounter,
+ LayoutTimeCounter,
+ // file base counters
+ NativeCallbackTimeCounter, // WebCoreFrameBridge.cpp
+ ResourceTimeCounter, // WebCoreResourceLoader.cpp
+ SharedTimerTimeCounter, // JavaBridge.cpp
WebViewCoreBuildNavTimeCounter,
- WebViewCoreDrawTimeCounter,
WebViewCoreRecordTimeCounter,
- WebViewCoreTimeCounter,
+ WebViewCoreTimeCounter, // WebViewCore.cpp
+ WebViewUIDrawTimeCounter,
TotalTimeCounterCount
};
diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp
index 855abdd..407544a 100644
--- a/WebKit/android/jni/WebSettings.cpp
+++ b/WebKit/android/jni/WebSettings.cpp
@@ -305,8 +305,11 @@ public:
pluginDatabase->setPluginDirectories(paths);
// Set the home directory for plugin temporary files
WebCore::sPluginPath = paths[0];
- // Reload plugins.
- pluginDatabase->refresh();
+ // Reload plugins. We call Page::refreshPlugins() instead
+ // of pluginDatabase->refresh(), as we need to ensure that
+ // the list of mimetypes exposed by the browser are also
+ // updated.
+ WebCore::Page::refreshPlugins(false);
}
}
#endif
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index ee74685..d9f9cec 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -476,7 +476,7 @@ void WebViewCore::copyContentToPicture(SkPicture* picture)
bool WebViewCore::drawContent(SkCanvas* canvas, SkColor color)
{
#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreDrawTimeCounter);
+ TimeCounterAuto counter(TimeCounter::WebViewUIDrawTimeCounter);
#endif
DBG_SET_LOG("start");
m_contentMutex.lock();
@@ -1153,21 +1153,20 @@ bool WebViewCore::commonKitFocus(int generation, int buildGeneration,
bool WebViewCore::finalKitFocus(WebCore::Frame* frame, WebCore::Node* node,
int x, int y, bool donotChangeDOMFocus)
{
- if (!frame)
+ CacheBuilder& builder = FrameLoaderClientAndroid::
+ get(m_mainFrame)->getCacheBuilder();
+ if (!frame || builder.validNode(frame, NULL) == false)
frame = m_mainFrame;
- CacheBuilder& builder = FrameLoaderClientAndroid::get(m_mainFrame)->getCacheBuilder();
WebCore::Node* oldFocusNode = builder.currentFocus();
// mouse event expects the position in the window coordinate
m_mousePos = WebCore::IntPoint(x - m_scrollOffsetX, y - m_scrollOffsetY);
// validNode will still return true if the node is null, as long as we have
// a valid frame. Do not want to make a call on frame unless it is valid.
+ WebCore::PlatformMouseEvent mouseEvent(m_mousePos, m_mousePos,
+ WebCore::NoButton, WebCore::MouseEventMoved, 1, false, false, false,
+ false, WebCore::currentTime());
+ frame->eventHandler()->handleMouseMoveEvent(mouseEvent);
bool valid = builder.validNode(frame, node);
- if (valid) {
- WebCore::PlatformMouseEvent mouseEvent(m_mousePos, m_mousePos, WebCore::NoButton,
- WebCore::MouseEventMoved, 1, false, false, false, false, WebCore::currentTime());
- frame->eventHandler()->handleMouseMoveEvent(mouseEvent);
- }
-
if (!donotChangeDOMFocus) {
WebCore::Document* oldDoc = oldFocusNode ? oldFocusNode->document() : 0;
if (!node) {
@@ -1737,7 +1736,7 @@ void WebViewCore::touchUp(int touchGeneration, int buildGeneration,
" x=%d y=%d", m_touchGeneration, touchGeneration, x, y);
return; // short circuit if a newer touch has been generated
}
- if (retry)
+ if (retry || isClick)
finalKitFocus(frame, node, x, y, true); // don't change DOM focus
else if (!commonKitFocus(touchGeneration, buildGeneration,
frame, node, x, y, false)) {
@@ -2021,6 +2020,9 @@ static void SetScrollOffset(JNIEnv *env, jobject obj, jint dx, jint dy)
static void SetGlobalBounds(JNIEnv *env, jobject obj, 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");
@@ -2131,6 +2133,9 @@ static bool RecordContent(JNIEnv *env, jobject obj, jobject region, jobject pt)
static void SplitContent(JNIEnv *env, jobject obj)
{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
viewImpl->splitContent();
}
@@ -2174,6 +2179,9 @@ static void SendListBoxChoices(JNIEnv* env, jobject obj, jbooleanArray jArray,
static jstring FindAddress(JNIEnv *env, jobject obj, jstring addr)
{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
if (!addr)
return 0;
int length = env->GetStringLength(addr);
@@ -2194,6 +2202,9 @@ static jstring FindAddress(JNIEnv *env, jobject obj, jstring addr)
static jboolean HandleTouchEvent(JNIEnv *env, jobject obj, jint action, 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__);
return viewImpl->handleTouchEvent(action, x, y);
@@ -2215,6 +2226,9 @@ static void TouchUp(JNIEnv *env, jobject obj, jint touchGeneration,
static jstring RetrieveHref(JNIEnv *env, jobject obj, jint frame,
jint node)
{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
WebCore::String result = viewImpl->retrieveHref((WebCore::Frame*) frame,
@@ -2252,6 +2266,9 @@ static void SetKitFocus(JNIEnv *env, jobject obj, jint moveGeneration,
static void UnblockFocus(JNIEnv *env, jobject obj)
{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
viewImpl->unblockFocus();
@@ -2259,6 +2276,9 @@ static void UnblockFocus(JNIEnv *env, jobject obj)
static void UpdateFrameCache(JNIEnv *env, jobject obj)
{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
viewImpl->updateFrameCache();
@@ -2266,6 +2286,9 @@ static void UpdateFrameCache(JNIEnv *env, jobject obj)
static jint GetContentMinPrefWidth(JNIEnv *env, jobject obj)
{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
@@ -2284,6 +2307,9 @@ static jint GetContentMinPrefWidth(JNIEnv *env, jobject obj)
static void SetViewportSettingsFromNative(JNIEnv *env, jobject obj)
{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
@@ -2303,6 +2329,9 @@ static void SetViewportSettingsFromNative(JNIEnv *env, jobject obj)
static void SetSnapAnchor(JNIEnv *env, jobject obj, 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__);
@@ -2311,6 +2340,9 @@ static void SetSnapAnchor(JNIEnv *env, jobject obj, jint x, jint y)
static void SnapToAnchor(JNIEnv *env, jobject obj)
{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
@@ -2319,6 +2351,9 @@ static void SnapToAnchor(JNIEnv *env, jobject obj)
static void SetBackgroundColor(JNIEnv *env, jobject obj, 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__);
@@ -2327,6 +2362,9 @@ static void SetBackgroundColor(JNIEnv *env, jobject obj, jint color)
static jstring GetSelection(JNIEnv *env, jobject obj, jobject selRgn)
{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
SkRegion* selectionRegion = GraphicsJNI::getNativeRegion(env, selRgn);
@@ -2364,29 +2402,44 @@ static void RefreshPlugins(JNIEnv *env,
jobject obj,
jboolean reloadOpenPages)
{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
// Refresh the list of plugins, optionally reloading all open
// pages.
WebCore::refreshPlugins(reloadOpenPages);
}
static void RegisterURLSchemeAsLocal(JNIEnv* env, jobject obj, jstring scheme) {
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
WebCore::FrameLoader::registerURLSchemeAsLocal(to_string(env, scheme));
}
static void CheckNavCache(JNIEnv *env, jobject obj)
{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
viewImpl->checkNavCache();
}
static void ClearContent(JNIEnv *env, jobject obj)
{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
viewImpl->clearContent();
}
static void CopyContentToPicture(JNIEnv *env, jobject obj, jobject pict)
{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
+#endif
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
if (!viewImpl)
return;
@@ -2396,6 +2449,7 @@ static void CopyContentToPicture(JNIEnv *env, jobject obj, jobject pict)
static bool DrawContent(JNIEnv *env, jobject obj, jobject canv, jint color)
{
+ // Note: this is called from UI thread, don't count it for WebViewCoreTimeCounter
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, canv);
return viewImpl->drawContent(canvas, color);
diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp
index 8b31de6..9150830 100644
--- a/WebKit/android/nav/CacheBuilder.cpp
+++ b/WebKit/android/nav/CacheBuilder.cpp
@@ -1093,6 +1093,8 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
IntRect bounds;
IntRect absBounds;
WTF::Vector<IntRect>* columns = NULL;
+ int minimumFocusableWidth = MINIMUM_FOCUSABLE_WIDTH;
+ int minimumFocusableHeight = MINIMUM_FOCUSABLE_HEIGHT;
if (isArea) {
HTMLAreaElement* area = static_cast<HTMLAreaElement*>(node);
bounds = getAreaRect(area);
@@ -1224,6 +1226,8 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
style->textAlign() == WebCore::RIGHT ||
style->textAlign() == WebCore::WEBKIT_RIGHT;
}
+ minimumFocusableWidth += 4;
+ minimumFocusableHeight += 4;
}
takesFocus = true;
if (isAnchor) {
@@ -1255,9 +1259,9 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
bounds.setLocation(IntPoint(x, y));
bounds.setSize(IntSize(width, height));
}
- if (bounds.width() < MINIMUM_FOCUSABLE_WIDTH)
+ if (bounds.width() < minimumFocusableWidth)
continue;
- if (bounds.height() < MINIMUM_FOCUSABLE_HEIGHT)
+ if (bounds.height() < minimumFocusableHeight)
continue;
bounds.move(globalOffsetX, globalOffsetY);
}
diff --git a/WebKit/android/nav/FindCanvas.cpp b/WebKit/android/nav/FindCanvas.cpp
index 61bb07e..24b0129 100644
--- a/WebKit/android/nav/FindCanvas.cpp
+++ b/WebKit/android/nav/FindCanvas.cpp
@@ -275,8 +275,15 @@ void FindCanvas::findHelper(const void* text, size_t byteLength,
if (mWorkingIndex) {
SkPoint newY;
getTotalMatrix().mapXY(0, y, &newY);
- SkIRect bounds = mWorkingRegion.getBounds();
- if (bounds.fBottom < SkScalarRound(newY.fY)) {
+ SkIRect workingBounds = mWorkingRegion.getBounds();
+ int newYInt = SkScalarRound(newY.fY);
+ if (workingBounds.fTop > newYInt) {
+ // The new text is above the working region, so we know it's not
+ // a continuation.
+ resetWorkingCanvas();
+ mWorkingIndex = 0;
+ mWorkingRegion.setEmpty();
+ } else if (workingBounds.fBottom < newYInt) {
// Now we know that this line is lower than our partial match.
SkPaint clonePaint(paint);
clonePaint.setTextEncoding(SkPaint::kUTF8_TextEncoding);
@@ -301,6 +308,9 @@ void FindCanvas::findHelper(const void* text, size_t byteLength,
mWorkingRegion.setEmpty();
}
}
+ // If neither one is true, then we are likely continuing on the same
+ // line, but are in a new draw call because the paint has changed. In
+ // this case, we can continue without adding a space.
}
// j is the position in the search text
// Start off with mWorkingIndex in case we are continuing from a prior call
@@ -396,21 +406,20 @@ void FindCanvas::findHelper(const void* text, size_t byteLength,
// call.
// Keep track of a partial match that may start on this line.
if (j > 0) { // if j is greater than 0, we have a partial match
- int partialIndex = index - j + mWorkingIndex;
+ int relativeCount = j - mWorkingIndex; // Number of characters in this
+ // part of the match.
+ int partialIndex = index - relativeCount; // Index that starts our
+ // partial match.
const uint16_t* partialGlyphs = chars + partialIndex;
- SkRect partial = (this->*addMatch)(partialIndex, paint, j,
+ SkRect partial = (this->*addMatch)(partialIndex, paint, relativeCount,
partialGlyphs, positions, y);
partial.inset(mOutset, mOutset);
- getTotalMatrix().mapRect(&partial);
SkIRect dest;
partial.roundOut(&dest);
// Only save a partial if it is in the current clip.
if (getTotalClip().contains(dest)) {
mWorkingRegion.op(dest, SkRegion::kUnion_Op);
mWorkingIndex = j;
- // From one perspective, it seems like we would want to draw here,
- // since we have all the information (paint, matrix, etc)
- // However, we only want to draw if we find the rest
return;
}
}