summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrace Kloba <klobag@google.com>2009-09-02 16:20:34 -0700
committerGrace Kloba <klobag@google.com>2009-09-02 16:20:34 -0700
commit2bb8c3514e2062c0a533f101ba32a7b861605152 (patch)
tree303281f3b945fc163d66f98616ac01eae26542e9
parent75310d0981eaef5dfd790e839bf23d7851b68d10 (diff)
downloadexternal_webkit-2bb8c3514e2062c0a533f101ba32a7b861605152.zip
external_webkit-2bb8c3514e2062c0a533f101ba32a7b861605152.tar.gz
external_webkit-2bb8c3514e2062c0a533f101ba32a7b861605152.tar.bz2
Get the drawable directory from Java for the platform buttons.
Fix http://b/issue?id=2086818
-rw-r--r--WebKit/android/RenderSkinAndroid.cpp6
-rw-r--r--WebKit/android/RenderSkinAndroid.h4
-rw-r--r--WebKit/android/RenderSkinButton.cpp14
-rw-r--r--WebKit/android/RenderSkinButton.h2
-rw-r--r--WebKit/android/RenderSkinRadio.cpp23
-rw-r--r--WebKit/android/RenderSkinRadio.h4
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.cpp13
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.h1
8 files changed, 42 insertions, 25 deletions
diff --git a/WebKit/android/RenderSkinAndroid.cpp b/WebKit/android/RenderSkinAndroid.cpp
index a261b27..fda4241 100644
--- a/WebKit/android/RenderSkinAndroid.cpp
+++ b/WebKit/android/RenderSkinAndroid.cpp
@@ -41,11 +41,11 @@ RenderSkinAndroid::RenderSkinAndroid()
, m_width(0)
{}
-void RenderSkinAndroid::Init(android::AssetManager* am)
+void RenderSkinAndroid::Init(android::AssetManager* am, String drawableDirectory)
{
- RenderSkinButton::Init(am);
+ RenderSkinButton::Init(am, drawableDirectory);
RenderSkinCombo::Init(am);
- RenderSkinRadio::Init(am);
+ RenderSkinRadio::Init(am, drawableDirectory);
}
bool RenderSkinAndroid::DecodeBitmap(android::AssetManager* am, const char* fileName, SkBitmap* bitmap)
diff --git a/WebKit/android/RenderSkinAndroid.h b/WebKit/android/RenderSkinAndroid.h
index c693dd1..475ad75 100644
--- a/WebKit/android/RenderSkinAndroid.h
+++ b/WebKit/android/RenderSkinAndroid.h
@@ -26,6 +26,8 @@
#ifndef RenderSkinAndroid_h
#define RenderSkinAndroid_h
+#include "PlatformString.h"
+
namespace android {
class AssetManager;
}
@@ -58,7 +60,7 @@ public:
* Initialize the Android skinning system. The AssetManager may be used to find resources used
* in rendering.
*/
- static void Init(android::AssetManager*);
+ static void Init(android::AssetManager*, String drawableDirectory);
/* DecodeBitmap determines which file to use, with the given fileName of the form
* "images/bitmap.png", and uses the asset manager to select the exact one. It
diff --git a/WebKit/android/RenderSkinButton.cpp b/WebKit/android/RenderSkinButton.cpp
index 7ab2491..c28dccf 100644
--- a/WebKit/android/RenderSkinButton.cpp
+++ b/WebKit/android/RenderSkinButton.cpp
@@ -25,6 +25,7 @@
#define LOG_TAG "WebCore"
#include "config.h"
+#include "CString.h"
#include "android_graphics.h"
#include "Document.h"
#include "IntRect.h"
@@ -43,10 +44,10 @@ struct PatchData {
static const PatchData gFiles[] =
{
- { "res/drawable-mdpi/btn_default_normal_disable.9.png", 2, 7 },
- { "res/drawable-mdpi/btn_default_normal.9.png", 2, 7 },
- { "res/drawable-mdpi/btn_default_selected.9.png", 2, 7 },
- { "res/drawable-mdpi/btn_default_pressed.9.png", 2, 7 }
+ { "btn_default_normal_disable.9.png", 2, 7 },
+ { "btn_default_normal.9.png", 2, 7 },
+ { "btn_default_selected.9.png", 2, 7 },
+ { "btn_default_pressed.9.png", 2, 7 }
};
static SkBitmap gButton[sizeof(gFiles)/sizeof(gFiles[0])];
@@ -54,7 +55,7 @@ static bool gDecoded;
namespace WebCore {
-void RenderSkinButton::Init(android::AssetManager* am)
+void RenderSkinButton::Init(android::AssetManager* am, String drawableDirectory)
{
static bool gInited;
if (gInited)
@@ -63,7 +64,8 @@ void RenderSkinButton::Init(android::AssetManager* am)
gInited = true;
gDecoded = true;
for (size_t i = 0; i < sizeof(gFiles)/sizeof(gFiles[0]); i++) {
- if (!RenderSkinAndroid::DecodeBitmap(am, gFiles[i].name, &gButton[i])) {
+ String path = drawableDirectory + gFiles[i].name;
+ if (!RenderSkinAndroid::DecodeBitmap(am, path.utf8().data(), &gButton[i])) {
gDecoded = false;
LOGD("RenderSkinButton::Init: button assets failed to decode\n\tBrowser buttons will not draw");
break;
diff --git a/WebKit/android/RenderSkinButton.h b/WebKit/android/RenderSkinButton.h
index 55eb2da..247b2f5 100644
--- a/WebKit/android/RenderSkinButton.h
+++ b/WebKit/android/RenderSkinButton.h
@@ -39,7 +39,7 @@ public:
* Initialize the class before use. Uses the AssetManager to initialize any
* bitmaps the class may use.
*/
- static void Init(android::AssetManager*);
+ static void Init(android::AssetManager*, 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.
diff --git a/WebKit/android/RenderSkinRadio.cpp b/WebKit/android/RenderSkinRadio.cpp
index b9b67f5..0207a28 100644
--- a/WebKit/android/RenderSkinRadio.cpp
+++ b/WebKit/android/RenderSkinRadio.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "RenderSkinRadio.h"
+#include "CString.h"
#include "android_graphics.h"
#include "Document.h"
#include "Element.h"
@@ -37,10 +38,10 @@
#include "SkCanvas.h"
#include "SkRect.h"
-static const char* checks[] = { "res/drawable-mdpi/btn_check_off.png",
- "res/drawable-mdpi/btn_check_on.png",
- "res/drawable-mdpi/btn_radio_off.png",
- "res/drawable-mdpi/btn_radio_on.png"};
+static const char* checks[] = { "btn_check_off.png",
+ "btn_check_on.png",
+ "btn_radio_off.png",
+ "btn_radio_on.png"};
// Matches the width of the bitmap
static SkScalar SIZE;
@@ -49,14 +50,18 @@ namespace WebCore {
static SkBitmap s_bitmap[4];
static bool s_decoded;
-void RenderSkinRadio::Init(android::AssetManager* am)
+void RenderSkinRadio::Init(android::AssetManager* am, String drawableDirectory)
{
if (s_decoded)
return;
- s_decoded = RenderSkinAndroid::DecodeBitmap(am, checks[0], &s_bitmap[0]);
- s_decoded = RenderSkinAndroid::DecodeBitmap(am, checks[1], &s_bitmap[1]) && s_decoded;
- s_decoded = RenderSkinAndroid::DecodeBitmap(am, checks[2], &s_bitmap[2]) && s_decoded;
- s_decoded = RenderSkinAndroid::DecodeBitmap(am, checks[3], &s_bitmap[3]) && s_decoded;
+ String path = drawableDirectory + checks[0];
+ s_decoded = RenderSkinAndroid::DecodeBitmap(am, path.utf8().data(), &s_bitmap[0]);
+ path = drawableDirectory + checks[1];
+ s_decoded = RenderSkinAndroid::DecodeBitmap(am, path.utf8().data(), &s_bitmap[1]) && s_decoded;
+ path = drawableDirectory + checks[2];
+ s_decoded = RenderSkinAndroid::DecodeBitmap(am, path.utf8().data(), &s_bitmap[2]) && s_decoded;
+ path = drawableDirectory + checks[3];
+ s_decoded = RenderSkinAndroid::DecodeBitmap(am, path.utf8().data(), &s_bitmap[3]) && s_decoded;
SIZE = SkIntToScalar(s_bitmap[0].width());
}
diff --git a/WebKit/android/RenderSkinRadio.h b/WebKit/android/RenderSkinRadio.h
index f70098f..e196194 100644
--- a/WebKit/android/RenderSkinRadio.h
+++ b/WebKit/android/RenderSkinRadio.h
@@ -26,6 +26,8 @@
#ifndef RenderSkinRadio_h
#define RenderSkinRadio_h
+#include "PlatformString.h"
+
class SkCanvas;
namespace android {
@@ -45,7 +47,7 @@ public:
/**
* Initialize the class before use. Uses the AssetManager to initialize any bitmaps the class may use.
*/
- static void Init(android::AssetManager*);
+ static void Init(android::AssetManager*, String drawableDirectory);
/**
* Draw the element to the canvas at the specified size and location.
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp
index 5145a85..418af49 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -788,10 +788,15 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss
// Set the mNativeFrame field in Frame
SET_NATIVE_FRAME(env, obj, (int)frame);
- // Setup the asset manager.
- AssetManager* am = assetManagerForJavaObject(env, jAssetManager);
- // Initialize our skinning classes
- WebCore::RenderSkinAndroid::Init(am);
+ String directory = webFrame->getRawResourceFilename(WebFrame::DRAWABLEDIR);
+ if (directory.isEmpty())
+ LOGE("Can't find the drawable directory");
+ else {
+ // Setup the asset manager.
+ AssetManager* am = assetManagerForJavaObject(env, jAssetManager);
+ // Initialize our skinning classes
+ WebCore::RenderSkinAndroid::Init(am, directory);
+ }
}
static void DestroyFrame(JNIEnv* env, jobject obj)
diff --git a/WebKit/android/jni/WebCoreFrameBridge.h b/WebKit/android/jni/WebCoreFrameBridge.h
index 6b5c90c..353545e 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.h
+++ b/WebKit/android/jni/WebCoreFrameBridge.h
@@ -54,6 +54,7 @@ class WebFrame : public WebCoreRefObject {
enum RAW_RES_ID {
NODOMAIN = 1,
LOADERROR,
+ DRAWABLEDIR,
};
WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* page);
~WebFrame();