summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp38
-rw-r--r--Source/WebCore/platform/graphics/GlyphPageTreeNode.h5
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp38
-rw-r--r--Source/WebKit/android/jni/WebViewCore.h6
4 files changed, 87 insertions, 0 deletions
diff --git a/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp b/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp
index 951cf56..126b3b4 100644
--- a/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp
+++ b/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp
@@ -47,12 +47,19 @@ GlyphPageTreeNode* GlyphPageTreeNode::pageZeroRoot = 0;
GlyphPageTreeNode* GlyphPageTreeNode::getRoot(unsigned pageNumber)
{
+#if !PLATFORM(ANDROID)
static bool initialized;
if (!initialized) {
initialized = true;
roots = new HashMap<int, GlyphPageTreeNode*>;
pageZeroRoot = new GlyphPageTreeNode;
}
+#else
+ if (!roots)
+ roots = new HashMap<int, GlyphPageTreeNode*>;
+ if (!pageZeroRoot)
+ pageZeroRoot = new GlyphPageTreeNode;
+#endif
GlyphPageTreeNode* node = pageNumber ? roots->get(pageNumber) : pageZeroRoot;
if (!node) {
@@ -68,6 +75,29 @@ GlyphPageTreeNode* GlyphPageTreeNode::getRoot(unsigned pageNumber)
return node;
}
+#if PLATFORM(ANDROID)
+void GlyphPageTreeNode::resetRoots()
+{
+ if (roots) {
+ HashMap<int, GlyphPageTreeNode*>::iterator end = roots->end();
+ for (HashMap<int, GlyphPageTreeNode*>::iterator it = roots->begin(); it != end; ++it)
+ it->second->resetChildren();
+ }
+ if (pageZeroRoot) {
+ pageZeroRoot->resetChildren();
+ }
+}
+
+void GlyphPageTreeNode::resetChildren()
+{
+ HashMap<const FontData*, GlyphPageTreeNode*>::const_iterator end = m_children.end();
+ for (HashMap<const FontData*, GlyphPageTreeNode*>::const_iterator it = m_children.begin(); it != end; ++it) {
+ pruneTreeFontData(static_cast<const SimpleFontData*>(it->first));
+ pruneTreeCustomFontData(it->first);
+ }
+}
+#endif
+
size_t GlyphPageTreeNode::treeGlyphPageCount()
{
size_t count = 0;
@@ -347,7 +377,11 @@ GlyphPageTreeNode* GlyphPageTreeNode::getChild(const FontData* fontData, unsigne
void GlyphPageTreeNode::pruneCustomFontData(const FontData* fontData)
{
+#if !PLATFORM(ANDROID)
if (!fontData || !m_customFontCount)
+#else
+ if (!fontData || !m_customFontCount || fontData == (SimpleFontData*)-1)
+#endif
return;
// Prune any branch that contains this FontData.
@@ -371,7 +405,11 @@ void GlyphPageTreeNode::pruneCustomFontData(const FontData* fontData)
void GlyphPageTreeNode::pruneFontData(const SimpleFontData* fontData, unsigned level)
{
ASSERT(fontData);
+#if !PLATFORM(ANDROID)
if (!fontData)
+#else
+ if (!fontData || fontData == (SimpleFontData*)-1)
+#endif
return;
// Prune any branch that contains this FontData.
diff --git a/Source/WebCore/platform/graphics/GlyphPageTreeNode.h b/Source/WebCore/platform/graphics/GlyphPageTreeNode.h
index b68c0ed..72a62ea 100644
--- a/Source/WebCore/platform/graphics/GlyphPageTreeNode.h
+++ b/Source/WebCore/platform/graphics/GlyphPageTreeNode.h
@@ -196,6 +196,11 @@ public:
void pruneCustomFontData(const FontData*);
void pruneFontData(const SimpleFontData*, unsigned level = 0);
+#if PLATFORM(ANDROID)
+ static void resetRoots();
+ void resetChildren();
+#endif
+
GlyphPageTreeNode* parent() const { return m_parent; }
GlyphPageTreeNode* getChild(const FontData*, unsigned pageNumber);
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index 33a6382..14077eb 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -54,6 +54,7 @@
#include "ExceptionCode.h"
#include "FocusController.h"
#include "Font.h"
+#include "FontCache.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameLoaderClientAndroid.h"
@@ -135,6 +136,7 @@
#include <JNIHelp.h>
#include <JNIUtility.h>
#include <androidfw/KeycodeLabels.h>
+#include <cutils/properties.h>
#include <v8.h>
#include <wtf/CurrentTime.h>
#include <wtf/text/AtomicString.h>
@@ -729,6 +731,7 @@ void WebViewCore::clearContent()
m_content.clear();
m_addInval.setEmpty();
m_rebuildInval.setEmpty();
+ updateLocale();
}
bool WebViewCore::focusBoundsChanged()
@@ -4252,6 +4255,41 @@ String WebViewCore::getText(int startX, int startY, int endX, int endY)
return text;
}
+/**
+ * Read the persistent locale.
+ */
+void WebViewCore::getLocale(String& language, String& region)
+{
+ char propLang[PROPERTY_VALUE_MAX], propRegn[PROPERTY_VALUE_MAX];
+
+ property_get("persist.sys.language", propLang, "");
+ property_get("persist.sys.country", propRegn, "");
+ if (*propLang == 0 && *propRegn == 0) {
+ /* Set to ro properties, default is en_US */
+ property_get("ro.product.locale.language", propLang, "en");
+ property_get("ro.product.locale.region", propRegn, "US");
+ }
+ language = String(propLang, 2);
+ region = String(propRegn, 2);
+}
+
+void WebViewCore::updateLocale()
+{
+ static String prevLang;
+ static String prevRegn;
+ String language;
+ String region;
+
+ getLocale(language, region);
+
+ if ((language != prevLang) || (region != prevRegn)) {
+ prevLang = language;
+ prevRegn = region;
+ GlyphPageTreeNode::resetRoots();
+ fontCache()->invalidate();
+ }
+}
+
//----------------------------------------------------------------------
// Native JNI methods
//----------------------------------------------------------------------
diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h
index 6f9bb13..d905556 100644
--- a/Source/WebKit/android/jni/WebViewCore.h
+++ b/Source/WebKit/android/jni/WebViewCore.h
@@ -608,6 +608,12 @@ namespace android {
*/
WebCore::VisiblePosition visiblePositionForWindowPoint(int x, int y);
+ // Retrieves the current locale from system properties
+ void getLocale(String& language, String& region);
+
+ // Handles changes in system locale
+ void updateLocale();
+
// these members are shared with webview.cpp
int m_touchGeneration; // copy of state in WebViewNative triggered by touch
int m_lastGeneration; // last action using up to date cache