diff options
-rw-r--r-- | Source/WebCore/platform/android/RenderThemeAndroid.cpp | 91 | ||||
-rw-r--r-- | Source/WebCore/platform/android/RenderThemeAndroid.h | 1 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h | 1 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/TilesManager.cpp | 2 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/TilesManager.h | 13 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/TreeManager.cpp | 12 | ||||
-rw-r--r-- | Source/WebKit/Android.mk | 1 | ||||
-rw-r--r-- | Source/WebKit/android/RenderSkinAndroid.cpp | 3 | ||||
-rw-r--r-- | Source/WebKit/android/RenderSkinAndroid.h | 4 | ||||
-rw-r--r-- | Source/WebKit/android/RenderSkinButton.cpp | 105 | ||||
-rw-r--r-- | Source/WebKit/android/RenderSkinButton.h | 55 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebHistory.cpp | 48 | ||||
-rw-r--r-- | Source/WebKit/android/nav/WebView.cpp | 25 |
13 files changed, 134 insertions, 227 deletions
diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.cpp b/Source/WebCore/platform/android/RenderThemeAndroid.cpp index 843068a..5f40ede 100644 --- a/Source/WebCore/platform/android/RenderThemeAndroid.cpp +++ b/Source/WebCore/platform/android/RenderThemeAndroid.cpp @@ -38,10 +38,10 @@ #include "RenderMediaControls.h" #endif #include "RenderSkinAndroid.h" -#include "RenderSkinButton.h" #include "RenderSkinCombo.h" #include "RenderSkinMediaButton.h" #include "RenderSkinRadio.h" +#include "RoundedIntRect.h" #include "SkCanvas.h" #include "UserAgentStyleSheets.h" #include "WebCoreFrameBridge.h" @@ -63,6 +63,20 @@ const int listboxPadding = 5; const RGBA32 selectionColor = makeRGB(181, 224, 136); +// Colors copied from the holo resources +const RGBA32 defaultBgColor = makeRGBA(204, 204, 204, 197); +const RGBA32 defaultBgBright = makeRGBA(213, 213, 213, 221); +const RGBA32 defaultBgDark = makeRGBA(92, 92, 92, 160); +const RGBA32 defaultFgColor = makeRGBA(101, 101, 101, 225); + +const RGBA32 disabledBgColor = makeRGBA(205, 205, 205, 107); +const RGBA32 disabledBgBright = makeRGBA(213, 213, 213, 133); +const RGBA32 disabledBgDark = makeRGBA(92, 92, 92, 96); +const RGBA32 disabledFgColor = makeRGBA(148, 148, 148, 137); + +const int paddingButton = 2; +const int cornerButton = 2; + static SkCanvas* getCanvasFromInfo(const PaintInfo& info) { return info.context->platformContext()->mCanvas; @@ -174,10 +188,10 @@ void RenderThemeAndroid::addIntrinsicMargins(RenderStyle* style) const // Cut out the intrinsic margins completely if we end up using a small font size if (style->fontSize() < 11) return; - + // Intrinsic margin value. const int m = 2; - + // FIXME: Using width/height alone and not also dealing with min-width/max-width is flawed. if (style->width().isIntrinsicOrAuto()) { if (style->marginLeft().quirk()) @@ -210,17 +224,6 @@ bool RenderThemeAndroid::supportsFocus(ControlPart appearance) void RenderThemeAndroid::adjustButtonStyle(CSSStyleSelector*, RenderStyle* style, WebCore::Element*) const { - // Code is taken from RenderThemeSafari.cpp - // It makes sure we have enough space for the button text. - const int paddingHoriz = 12; - const int paddingVert = 8; - style->setPaddingLeft(Length(paddingHoriz, Fixed)); - style->setPaddingRight(Length(paddingHoriz, Fixed)); - style->setPaddingTop(Length(paddingVert, Fixed)); - style->setPaddingBottom(Length(paddingVert, Fixed)); - - // Set a min-height so that we can't get smaller than the mini button. - style->setMinHeight(Length(15, Fixed)); } bool RenderThemeAndroid::paintCheckbox(RenderObject* obj, const PaintInfo& info, const IntRect& rect) @@ -237,16 +240,42 @@ bool RenderThemeAndroid::paintButton(RenderObject* obj, const PaintInfo& info, c if (formControlElement) { android::WebFrame* webFrame = getWebFrame(node); if (webFrame) { - RenderSkinAndroid* skins = webFrame->renderSkins(); - if (skins) { - RenderSkinAndroid::State state = RenderSkinAndroid::kNormal; - if (!formControlElement->isEnabledFormControl()) - state = RenderSkinAndroid::kDisabled; - skins->renderSkinButton()->draw(getCanvasFromInfo(info), rect, state); + GraphicsContext *context = info.context; + IntRect innerrect = IntRect(rect.x() + paddingButton, rect.y() + paddingButton, + rect.width() - 2 * paddingButton, rect.height() - 2 * paddingButton); + IntSize cornerrect = IntSize(cornerButton, cornerButton); + Color bg, bright, dark; + if (formControlElement->isEnabledFormControl()) { + bg = Color(defaultBgColor); + bright = Color(defaultBgBright); + dark = Color(defaultBgDark); + } else { + bg = Color(disabledBgColor); + bright = Color(disabledBgBright); + dark = Color(disabledBgDark); } + context->save(); + context->clip( + IntRect(innerrect.x(), innerrect.y(), innerrect.width(), 1)); + context->fillRoundedRect(innerrect, cornerrect, cornerrect, + cornerrect, cornerrect, bright, context->fillColorSpace()); + context->restore(); + context->save(); + context->clip(IntRect(innerrect.x(), innerrect.y() + innerrect.height() - 1, + innerrect.width(), 1)); + context->fillRoundedRect(innerrect, cornerrect, cornerrect, + cornerrect, cornerrect, dark, context->fillColorSpace()); + context->restore(); + context->save(); + context->clip(IntRect(innerrect.x(), innerrect.y() + 1, innerrect.width(), + innerrect.height() - 2)); + context->fillRoundedRect(innerrect, cornerrect, cornerrect, + cornerrect, cornerrect, bg, context->fillColorSpace()); + context->restore(); } } + // We always return false so we do not request to be redrawn. return false; } @@ -400,7 +429,7 @@ void RenderThemeAndroid::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* st bool RenderThemeAndroid::paintTextField(RenderObject*, const PaintInfo&, const IntRect&) { - return true; + return true; } void RenderThemeAndroid::adjustTextAreaStyle(CSSStyleSelector*, RenderStyle* style, WebCore::Element*) const @@ -422,7 +451,7 @@ void RenderThemeAndroid::adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle* bool RenderThemeAndroid::paintSearchField(RenderObject*, const PaintInfo&, const IntRect&) { - return true; + return true; } static void adjustMenuListStyleCommon(RenderStyle* style) @@ -453,8 +482,8 @@ bool RenderThemeAndroid::paintCombo(RenderObject* obj, const PaintInfo& info, c return RenderSkinCombo::Draw(getCanvasFromInfo(info), obj->node(), rect.x(), rect.y(), rect.width(), rect.height()); } -bool RenderThemeAndroid::paintMenuList(RenderObject* obj, const PaintInfo& info, const IntRect& rect) -{ +bool RenderThemeAndroid::paintMenuList(RenderObject* obj, const PaintInfo& info, const IntRect& rect) +{ return paintCombo(obj, info, rect); } @@ -465,13 +494,13 @@ void RenderThemeAndroid::adjustMenuListButtonStyle(CSSStyleSelector*, const float baseFontSize = 11.0f; const int baseBorderRadius = 5; float fontScale = style->fontSize() / baseFontSize; - + style->resetPadding(); style->setBorderRadius(IntSize(int(baseBorderRadius + fontScale - 1), int(baseBorderRadius + fontScale - 1))); // FIXME: Round up? const int minHeight = 15; style->setMinHeight(Length(minHeight, Fixed)); - + style->setLineHeight(RenderStyle::initialLineHeight()); // Found these padding numbers by trial and error. const int padding = 4; @@ -480,7 +509,7 @@ void RenderThemeAndroid::adjustMenuListButtonStyle(CSSStyleSelector*, adjustMenuListStyleCommon(style); } -bool RenderThemeAndroid::paintMenuListButton(RenderObject* obj, const PaintInfo& info, const IntRect& rect) +bool RenderThemeAndroid::paintMenuListButton(RenderObject* obj, const PaintInfo& info, const IntRect& rect) { return paintCombo(obj, info, rect); } @@ -488,10 +517,10 @@ bool RenderThemeAndroid::paintMenuListButton(RenderObject* obj, const PaintInfo& bool RenderThemeAndroid::supportsFocusRing(const RenderStyle* style) const { return style->opacity() > 0 - && style->hasAppearance() - && style->appearance() != TextFieldPart - && style->appearance() != SearchFieldPart - && style->appearance() != TextAreaPart + && style->hasAppearance() + && style->appearance() != TextFieldPart + && style->appearance() != SearchFieldPart + && style->appearance() != TextAreaPart && style->appearance() != CheckboxPart && style->appearance() != RadioPart && style->appearance() != PushButtonPart diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.h b/Source/WebCore/platform/android/RenderThemeAndroid.h index e3922a1..7ac372d 100644 --- a/Source/WebCore/platform/android/RenderThemeAndroid.h +++ b/Source/WebCore/platform/android/RenderThemeAndroid.h @@ -31,7 +31,6 @@ namespace WebCore { -class RenderSkinButton; class RenderSkinRadio; class RenderSkinCombo; diff --git a/Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h b/Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h index d22dbd8..80ea5d6 100644 --- a/Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h +++ b/Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h @@ -28,7 +28,6 @@ #include "IntRect.h" #include "RenderSkinAndroid.h" -#include "RenderSkinButton.h" #include "SkCanvas.h" #include "SkPicture.h" #include "SkTDArray.h" diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index fbf7ae6..cbbbe5c 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -103,6 +103,8 @@ TilesManager::TilesManager() , m_invertedScreen(false) , m_invertedScreenSwitch(false) , m_useMinimalMemory(true) + , m_useDoubleBuffering(true) + , m_treeUpdates(0) , m_drawGLCount(1) , m_lastTimeLayersUsed(0) , m_hasLayerTextures(false) diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h index f798196..dd01fc5 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.h +++ b/Source/WebCore/platform/graphics/android/TilesManager.h @@ -178,6 +178,16 @@ public: return m_useMinimalMemory; } + void setUseDoubleBuffering(bool useDoubleBuffering) + { + m_useDoubleBuffering = useDoubleBuffering; + } + bool useDoubleBuffering() { return m_useDoubleBuffering; } + + void incTreeUpdates() { m_treeUpdates++; } + unsigned int getTreeUpdates() { return m_treeUpdates; } + void clearTreeUpdates() { m_treeUpdates = 0; } + void incDrawGLCount() { m_drawGLCount++; @@ -227,6 +237,9 @@ private: bool m_useMinimalMemory; + bool m_useDoubleBuffering; + unsigned int m_treeUpdates; + sp<TexturesGenerator> m_pixmapsGenerationThread; android::Mutex m_texturesLock; diff --git a/Source/WebCore/platform/graphics/android/TreeManager.cpp b/Source/WebCore/platform/graphics/android/TreeManager.cpp index 35ddeb8..be161a0 100644 --- a/Source/WebCore/platform/graphics/android/TreeManager.cpp +++ b/Source/WebCore/platform/graphics/android/TreeManager.cpp @@ -159,10 +159,15 @@ void TreeManager::updateWithTree(Layer* newTree, bool brandNew) if (m_queuedTree || m_paintingTree) { // currently painting, so defer this new tree if (m_queuedTree) { - // have a queued tree, copy over invals so the regions are - // eventually repainted + // already have a queued tree, copy over invals so the regions are + // eventually repainted and let the old queued tree be discarded m_queuedTree->mergeInvalsInto(newTree); + if (!TilesManager::instance()->useDoubleBuffering()) { + // not double buffering, count discarded tree/webkit paint as an update + TilesManager::instance()->incTreeUpdates(); + } + XLOG("DISCARDING tree - %p, has children %d, has animations %d", newTree, newTree && newTree->countChildren(), newTree && newTree->countChildren() @@ -222,9 +227,10 @@ bool TreeManager::drawGL(double currentTime, IntRect& viewRect, if (laTree) laTree->computeTexturesAmount(texturesResultPtr); - if (/*!m_fastSwapMode && */ m_paintingTree->isReady()) { + if (!TilesManager::instance()->useDoubleBuffering() || m_paintingTree->isReady()) { XLOG("have painting tree %p ready, swapping!", m_paintingTree); didTreeSwap = true; + TilesManager::instance()->incTreeUpdates(); swap(); if (treesSwappedPtr) *treesSwappedPtr = true; diff --git a/Source/WebKit/Android.mk b/Source/WebKit/Android.mk index f581111..6f9d8eb 100644 --- a/Source/WebKit/Android.mk +++ b/Source/WebKit/Android.mk @@ -49,7 +49,6 @@ endif # HTTP_STACK == chrome LOCAL_SRC_FILES += \ android/RenderSkinAndroid.cpp \ - android/RenderSkinButton.cpp \ android/RenderSkinCombo.cpp \ android/RenderSkinMediaButton.cpp \ android/RenderSkinNinePatch.cpp \ diff --git a/Source/WebKit/android/RenderSkinAndroid.cpp b/Source/WebKit/android/RenderSkinAndroid.cpp index e6fb67b..0662bbe 100644 --- a/Source/WebKit/android/RenderSkinAndroid.cpp +++ b/Source/WebKit/android/RenderSkinAndroid.cpp @@ -27,7 +27,6 @@ #include "config.h" #include "RenderSkinAndroid.h" -#include "RenderSkinButton.h" #include "RenderSkinCombo.h" #include "RenderSkinMediaButton.h" #include "RenderSkinRadio.h" @@ -43,7 +42,6 @@ RenderSkinAndroid::Resolution RenderSkinAndroid::s_drawableResolution = RenderSk RenderSkinAndroid::~RenderSkinAndroid() { - delete m_button; } RenderSkinAndroid::RenderSkinAndroid(String drawableDirectory) { @@ -56,7 +54,6 @@ RenderSkinAndroid::RenderSkinAndroid(String drawableDirectory) s_drawableDirectory = drawableDirectory; } - m_button = new RenderSkinButton(drawableDirectory); } bool RenderSkinAndroid::DecodeBitmap(android::AssetManager* am, const char* fileName, SkBitmap* bitmap) diff --git a/Source/WebKit/android/RenderSkinAndroid.h b/Source/WebKit/android/RenderSkinAndroid.h index bbc327d..1d3820d 100644 --- a/Source/WebKit/android/RenderSkinAndroid.h +++ b/Source/WebKit/android/RenderSkinAndroid.h @@ -36,7 +36,6 @@ class SkBitmap; namespace WebCore { class Node; -class RenderSkinButton; class RenderSkinAndroid { @@ -69,12 +68,9 @@ public: static String DrawableDirectory() { return s_drawableDirectory; } static Resolution DrawableResolution() { return s_drawableResolution; } - RenderSkinButton* renderSkinButton() const { return m_button; } - private: static String s_drawableDirectory; static Resolution s_drawableResolution; - RenderSkinButton* m_button; }; } // WebCore diff --git a/Source/WebKit/android/RenderSkinButton.cpp b/Source/WebKit/android/RenderSkinButton.cpp deleted file mode 100644 index 7ab50aa..0000000 --- a/Source/WebKit/android/RenderSkinButton.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2006, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 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 "android_graphics.h" -#include "Document.h" -#include "IntRect.h" -#include "Node.h" -#include "RenderSkinButton.h" -#include "RenderSkinNinePatch.h" -#include "SkCanvas.h" -#include "SkNinePatch.h" -#include "SkRect.h" -#include <utils/Asset.h> -#include <utils/AssetManager.h> -#include <utils/Debug.h> -#include <utils/Log.h> -#include <utils/ResourceTypes.h> -#include <wtf/text/CString.h> - -extern android::AssetManager* globalAssetManager(); - -static const char* gFiles[] = { - "btn_default_disabled_holo.9.png", - "btn_default_normal_holo.9.png", - "btn_default_focused_holo.9.png", - "btn_default_pressed_holo.9.png" - }; - -namespace WebCore { - -RenderSkinButton::RenderSkinButton(String drawableDirectory) - : m_decoded(false) - , m_decodingAttempted(false) - , m_drawableDirectory(drawableDirectory) -{ - // Ensure our enums properly line up with our arrays. - android::CompileTimeAssert<(RenderSkinAndroid::kDisabled == 0)> a1; - android::CompileTimeAssert<(RenderSkinAndroid::kNormal == 1)> a2; - android::CompileTimeAssert<(RenderSkinAndroid::kFocused == 2)> a3; - android::CompileTimeAssert<(RenderSkinAndroid::kPressed == 3)> a4; -} - -void RenderSkinButton::decode() -{ - m_decodingAttempted = true; - - android::AssetManager* am = globalAssetManager(); - - for (size_t i = 0; i < 4; i++) { - String path = m_drawableDirectory; - path.append(String(gFiles[i])); - if (!RenderSkinNinePatch::decodeAsset(am, path.utf8().data(), &m_buttons[i])) { - m_decoded = false; - ALOGE("RenderSkinButton::decode: button assets failed to decode\n\tWebView buttons will not draw"); - return; - } - } - m_decoded = true; -} - -void RenderSkinButton::draw(SkCanvas* canvas, const IntRect& r, - RenderSkinAndroid::State newState) -{ - if (!m_decodingAttempted) - decode(); - - // If we failed to decode, do nothing. This way the browser still works, - // and webkit will still draw the label and layout space for us. - if (!m_decoded) { - return; - } - - // Ensure that the state is within the valid range of our array. - SkASSERT(static_cast<unsigned>(newState) < - static_cast<unsigned>(RenderSkinAndroid::kNumStates)); - - RenderSkinNinePatch::DrawNinePatch(canvas, SkRect(r), m_buttons[newState]); -} - -} //WebCore diff --git a/Source/WebKit/android/RenderSkinButton.h b/Source/WebKit/android/RenderSkinButton.h deleted file mode 100644 index 83c57dd..0000000 --- a/Source/WebKit/android/RenderSkinButton.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2006, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 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 RenderSkinButton_h -#define RenderSkinButton_h - -#include "RenderSkinAndroid.h" -#include "RenderSkinNinePatch.h" - -class SkCanvas; - -namespace WebCore { -class IntRect; - -class RenderSkinButton { -public: - RenderSkinButton(String drawableDirectory); - /** - * Draw the skin to the canvas, using the rectangle for its bounds and the - * State to determine which skin to use, i.e. focused or not focused. - */ - void draw(SkCanvas* , const IntRect& , RenderSkinAndroid::State); - - void decode(); -private: - bool m_decoded; - bool m_decodingAttempted; - NinePatch m_buttons[4]; - String m_drawableDirectory; -}; - -} // WebCore -#endif diff --git a/Source/WebKit/android/jni/WebHistory.cpp b/Source/WebKit/android/jni/WebHistory.cpp index db31429..1ab8f37 100644 --- a/Source/WebKit/android/jni/WebHistory.cpp +++ b/Source/WebKit/android/jni/WebHistory.cpp @@ -24,7 +24,6 @@ */ #define LOG_TAG "webhistory" -#define LOG_NDEBUG 0 // enable ALOGV and ALOG_ASSERT #include "config.h" #include "WebHistory.h" @@ -489,7 +488,8 @@ bool readUnsigned(const char*& data, const char* end, unsigned& result, const ch { // Check if we have enough data left to continue. if ((end < data) || (static_cast<size_t>(end - data) < sizeof(unsigned))) { - ALOGW("\tNot enough data to read unsigned; end=%p data=%p", end, data); + ALOGW("\tNot enough data to read unsigned; tag=\"%s\" end=%p data=%p", + dbgLabel ? dbgLabel : "<no tag>", end, data); return false; } @@ -504,7 +504,8 @@ bool readInt(const char*& data, const char* end, int& result, const char* dbgLab { // Check if we have enough data left to continue. if ((end < data) || (static_cast<size_t>(end - data) < sizeof(int))) { - ALOGW("\tNot enough data to read int; end=%p data=%p", end, data); + ALOGW("Not enough data to read int; tag=\"%s\" end=%p data=%p", + dbgLabel ? dbgLabel : "<no tag>", end, data); return false; } @@ -519,7 +520,8 @@ bool readInt64(const char*& data, const char* end, int64_t& result, const char* { // Check if we have enough data left to continue. if ((end < data) || (static_cast<size_t>(end - data) < sizeof(int64_t))) { - ALOGW("\tNot enough data to read int64_t; end=%p data=%p", end, data); + ALOGW("Not enough data to read int64_t; tag=\"%s\" end=%p data=%p", + dbgLabel ? dbgLabel : "<no tag>", end, data); return false; } @@ -534,7 +536,8 @@ bool readFloat(const char*& data, const char* end, float& result, const char* db { // Check if we have enough data left to continue. if ((end < data) || (static_cast<size_t>(end - data) < sizeof(float))) { - ALOGW("\tNot enough data to read float; end=%p data=%p", end, data); + ALOGW("Not enough data to read float; tag=\"%s\" end=%p data=%p", + dbgLabel ? dbgLabel : "<no tag>", end, data); return false; } @@ -551,7 +554,8 @@ bool readBool(const char*& data, const char* end, bool& result, const char* dbgL { // Check if we have enough data left to continue. if ((end < data) || (static_cast<size_t>(end - data) < sizeof(char))) { - ALOGW("\tNot enough data to read bool; end=%p data=%p", end, data); + ALOGW("Not enough data to read bool; tag=\"%s\" end=%p data=%p", + dbgLabel ? dbgLabel : "<no tag>", end, data); return false; } @@ -564,7 +568,8 @@ bool readBool(const char*& data, const char* end, bool& result, const char* dbgL // Valid bool results are 0 or 1 if ((c != 0) && (c != 1)) { - ALOGW("\tInvalid value for bool; end=%p data=%p c=%u", end, data, c); + ALOGW("Invalid value for bool; tag=\"%s\" end=%p data=%p c=%u", + dbgLabel ? dbgLabel : "<no tag>", end, data, c); return false; } @@ -575,7 +580,8 @@ bool readString(const char*& data, const char* end, String& result, const char* { unsigned stringLength; if (!readUnsigned(data, end, stringLength)) { - ALOGW("Not enough data to read string length; end=%p data=%p", end, data); + ALOGW("Not enough data to read string length; tag=\"%s\" end=%p data=%p", + dbgLabel ? dbgLabel : "<no tag>", end, data); return false; } @@ -589,19 +595,31 @@ bool readString(const char*& data, const char* end, String& result, const char* } if ((end < data) || ((unsigned)(end - data) < stringLength)) { - ALOGW("\tNot enough data to read content; end=%p data=%p stringLength=%u", end, data, stringLength); + ALOGW("Not enough data to read content; tag=\"%s\" end=%p data=%p stringLength=%u", + dbgLabel ? dbgLabel : "<no tag>", end, data, stringLength); return false; } - bool decodeFailed; + const unsigned MAX_REASONABLE_STRING_LENGTH = 10000; + if (stringLength > MAX_REASONABLE_STRING_LENGTH) { + ALOGW("String length is suspiciously large (>%d); tag=\"%s\" end=%p data=%p stringLength=%u", + MAX_REASONABLE_STRING_LENGTH, dbgLabel ? dbgLabel : "<no tag>", + end, data, stringLength); + } + + bool decodeFailed = false; static const WebCore::TextEncoding& encoding = WebCore::UTF8Encoding(); result = encoding.decode(data, stringLength, true, decodeFailed); if (decodeFailed) { - ALOGW("\tdecode failed, end=%p data=%p stringLength=%u content=\"%s\"", - end, data, stringLength, result.utf8().data()); - // Although an error was reported, the previous implementation did not - // stop here, and debug output of the result, which looks correct, makes - // it unclear just what the error was. + ALOGW("Decode failed, tag=\"%s\" end=%p data=%p stringLength=%u content=\"%s\"", + dbgLabel ? dbgLabel : "<no tag>", end, data, stringLength, + result.utf8().data()); + return false; + } + + if (stringLength > MAX_REASONABLE_STRING_LENGTH) { + ALOGW("\tdecodeFailed=%d (flag is ignored) content=\"%s\"", + decodeFailed, result.utf8().data()); } data += stringLength; diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 1501a12..78881a9 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -199,7 +199,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl, WTF::String drawableDir, m_baseLayer = 0; m_glDrawFunctor = 0; m_isDrawingPaused = false; - m_buttonSkin = drawableDir.isEmpty() ? 0 : new RenderSkinButton(drawableDir); #if USE(ACCELERATED_COMPOSITING) m_glWebViewState = 0; m_pageSwapCallbackRegistered = false; @@ -223,7 +222,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl, WTF::String drawableDir, delete m_frameCacheUI; SkSafeUnref(m_baseLayer); delete m_glDrawFunctor; - delete m_buttonSkin; } void stopGL() @@ -1536,7 +1534,6 @@ private: // local state for WebView GLWebViewState* m_glWebViewState; bool m_pageSwapCallbackRegistered; #endif - RenderSkinButton* m_buttonSkin; SkRect m_visibleRect; bool m_isHighEndGfx; }; // end of WebView class @@ -2600,10 +2597,8 @@ static bool nativeSetProperty(JNIEnv *env, jobject obj, jstring jkey, jstring jv WTF::String key = jstringToWtfString(env, jkey); WTF::String value = jstringToWtfString(env, jvalue); if (key == "inverted") { - if (value == "true") - TilesManager::instance()->setInvertedScreen(true); - else - TilesManager::instance()->setInvertedScreen(false); + bool shouldInvert = (value == "true"); + TilesManager::instance()->setInvertedScreen(shouldInvert); return true; } else if (key == "inverted_contrast") { @@ -2620,11 +2615,25 @@ static bool nativeSetProperty(JNIEnv *env, jobject obj, jstring jkey, jstring jv TilesManager::instance()->setUseMinimalMemory(value == "true"); return true; } + else if (key == "use_double_buffering") { + TilesManager::instance()->setUseDoubleBuffering(value == "true"); + return true; + } + else if (key == "tree_updates") { + TilesManager::instance()->clearTreeUpdates(); + return true; + } return false; } -static jstring nativeGetProperty(JNIEnv *env, jobject obj, jstring key) +static jstring nativeGetProperty(JNIEnv *env, jobject obj, jstring jkey) { + WTF::String key = jstringToWtfString(env, jkey); + if (key == "tree_updates") { + int updates = TilesManager::instance()->getTreeUpdates(); + WTF::String wtfUpdates = WTF::String::number(updates); + return wtfStringToJstring(env, wtfUpdates); + } return 0; } |