summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp30
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h13
-rw-r--r--Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h36
-rw-r--r--Source/WebCore/platform/graphics/android/fonts/FontPlatformDataAndroid.cpp155
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp1
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp42
6 files changed, 168 insertions, 109 deletions
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
index 2a7db11..c70a67d 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
@@ -524,6 +524,7 @@ void PlatformGraphicsContextRecording::beginTransparencyLayer(float opacity)
{
CanvasState* parent = mRecordingStateStack.last().mCanvasState;
pushStateOperation(new (heap()) CanvasState(parent, opacity));
+ mRecordingStateStack.last().disableOpaqueTracking();
}
void PlatformGraphicsContextRecording::endTransparencyLayer()
@@ -688,13 +689,13 @@ const SkMatrix& PlatformGraphicsContextRecording::getTotalMatrix()
void PlatformGraphicsContextRecording::addInnerRoundedRectClip(const IntRect& rect,
int thickness)
{
- mRecordingStateStack.last().setHasComplexClip();
+ mRecordingStateStack.last().disableOpaqueTracking();
appendStateOperation(NEW_OP(InnerRoundedRectClip)(rect, thickness));
}
void PlatformGraphicsContextRecording::canvasClip(const Path& path)
{
- mRecordingStateStack.last().setHasComplexClip();
+ mRecordingStateStack.last().disableOpaqueTracking();
clip(path);
}
@@ -707,7 +708,7 @@ bool PlatformGraphicsContextRecording::clip(const FloatRect& rect)
bool PlatformGraphicsContextRecording::clip(const Path& path)
{
- mRecordingStateStack.last().setHasComplexClip();
+ mRecordingStateStack.last().disableOpaqueTracking();
clipState(path.boundingRect());
appendStateOperation(NEW_OP(ClipPath)(path));
return true;
@@ -722,21 +723,21 @@ bool PlatformGraphicsContextRecording::clipConvexPolygon(size_t numPoints,
bool PlatformGraphicsContextRecording::clipOut(const IntRect& r)
{
- mRecordingStateStack.last().setHasComplexClip();
+ mRecordingStateStack.last().disableOpaqueTracking();
appendStateOperation(NEW_OP(ClipOut)(r));
return true;
}
bool PlatformGraphicsContextRecording::clipOut(const Path& path)
{
- mRecordingStateStack.last().setHasComplexClip();
+ mRecordingStateStack.last().disableOpaqueTracking();
appendStateOperation(NEW_OP(ClipPath)(path, true));
return true;
}
bool PlatformGraphicsContextRecording::clipPath(const Path& pathToClip, WindRule clipRule)
{
- mRecordingStateStack.last().setHasComplexClip();
+ mRecordingStateStack.last().disableOpaqueTracking();
clipState(pathToClip.boundingRect());
GraphicsOperation::ClipPath* operation = NEW_OP(ClipPath)(pathToClip);
operation->setWindRule(clipRule);
@@ -930,7 +931,9 @@ void PlatformGraphicsContextRecording::clipState(const FloatRect& clip)
void PlatformGraphicsContextRecording::pushStateOperation(CanvasState* canvasState)
{
ALOGV("RECORDING: pushStateOperation: %p(isLayer=%d)", canvasState, canvasState->isTransparencyLayer());
- mRecordingStateStack.append(canvasState);
+
+ RecordingState* parent = mRecordingStateStack.isEmpty() ? 0 : &(mRecordingStateStack.last());
+ mRecordingStateStack.append(RecordingState(canvasState, parent));
mRecording->recording()->addCanvasState(canvasState);
}
@@ -1000,6 +1003,13 @@ IntRect PlatformGraphicsContextRecording::calculateFinalBounds(FloatRect bounds)
IntRect PlatformGraphicsContextRecording::calculateCoveredBounds(FloatRect bounds)
{
+ if (mRecordingStateStack.last().mOpaqueTrackingDisabled
+ || m_state->alpha != 1.0f
+ || (m_state->mode != SkXfermode::kSrc_Mode && m_state->mode != SkXfermode::kSrcOver_Mode)
+ || !mCurrentMatrix->rectStaysRect()) {
+ return IntRect();
+ }
+
SkRect translated;
mCurrentMatrix->mapRect(&translated, bounds);
FloatRect ftrect = translated;
@@ -1029,11 +1039,7 @@ void PlatformGraphicsContextRecording::appendDrawingOperation(
operation->~Operation();
return;
}
- if (operation->isOpaque()
- && !untranslatedBounds.isEmpty()
- && operation->m_state->alpha == 1.0f
- && mCurrentMatrix->rectStaysRect()
- && !state.mHasComplexClip) {
+ if (operation->isOpaque() && !untranslatedBounds.isEmpty()) {
// if the operation maps to an opaque rect, record the area it will cover
operation->setOpaqueRect(calculateCoveredBounds(untranslatedBounds));
}
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
index b1018e7..061ee0e 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
@@ -168,22 +168,23 @@ private:
Recording* mRecording;
class RecordingState {
public:
- RecordingState(CanvasState* state)
+ RecordingState(CanvasState* state, const RecordingState* parent)
: mCanvasState(state)
, mHasDrawing(false)
- , mHasClip(false)
- , mHasComplexClip(false)
+ , mHasClip(parent ? parent->mHasClip : false)
+ , mOpaqueTrackingDisabled(parent ? parent->mOpaqueTrackingDisabled : false)
+ , mBounds(parent ? parent->mBounds : FloatRect())
{}
RecordingState(const RecordingState& other)
: mCanvasState(other.mCanvasState)
, mHasDrawing(other.mHasDrawing)
, mHasClip(other.mHasClip)
- , mHasComplexClip(false)
+ , mOpaqueTrackingDisabled(other.mOpaqueTrackingDisabled)
, mBounds(other.mBounds)
{}
- void setHasComplexClip() { mHasComplexClip = true; }
+ void disableOpaqueTracking() { mOpaqueTrackingDisabled = true; }
void clip(const FloatRect& rect)
{
@@ -198,7 +199,7 @@ private:
CanvasState* mCanvasState;
bool mHasDrawing;
bool mHasClip;
- bool mHasComplexClip;
+ bool mOpaqueTrackingDisabled;
FloatRect mBounds;
};
Vector<RecordingState> mRecordingStateStack;
diff --git a/Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h b/Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h
index 02a0cea..afae949 100644
--- a/Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h
+++ b/Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h
@@ -33,12 +33,13 @@
#include "FontOrientation.h"
#include "TextOrientation.h"
#include <wtf/text/StringImpl.h>
+#include "SkLanguage.h"
+#include "SkPaint.h"
#ifndef NDEBUG
#include "PlatformString.h"
#endif
-class SkPaint;
class SkTypeface;
struct HB_FaceRec_;
@@ -62,13 +63,13 @@ public:
~FontPlatformData();
FontPlatformData(WTF::HashTableDeletedValueType)
- : mTypeface(hashTableDeletedFontValue()) { }
+ : m_typeface(hashTableDeletedFontValue()) { }
bool isHashTableDeletedValue() const {
- return mTypeface == hashTableDeletedFontValue();
+ return m_typeface == hashTableDeletedFontValue();
}
- FontOrientation orientation() const { return mOrientation; }
- void setOrientation(FontOrientation orientation) { mOrientation = orientation; }
+ FontOrientation orientation() const { return m_orientation; }
+ void setOrientation(FontOrientation orientation) { m_orientation = orientation; }
FontPlatformData& operator=(const FontPlatformData&);
bool operator==(const FontPlatformData& a) const;
@@ -80,7 +81,7 @@ public:
// -------------------------------------------------------------------------
uint32_t uniqueID() const;
- float size() const { return mTextSize; }
+ float size() const { return m_textSize; }
unsigned hash() const;
int emSizeInFontUnits() const;
bool isFixedPitch() const;
@@ -90,10 +91,12 @@ public:
#endif
HB_FaceRec_* harfbuzzFace() const;
- SkTypeface* typeface() const { return mTypeface; }
+ SkTypeface* typeface() const { return m_typeface; }
- bool isFakeBold() const { return mFakeBold; }
- bool isFakeItalic() const { return mFakeItalic; }
+ bool isFakeBold() const { return m_fakeBold; }
+ bool isFakeItalic() const { return m_fakeItalic; }
+
+ static void setDefaultLanguage(const char* language);
private:
class RefCountedHarfbuzzFace : public RefCounted<RefCountedHarfbuzzFace> {
@@ -115,14 +118,15 @@ private:
HB_FaceRec_* m_harfbuzzFace;
};
- SkTypeface* mTypeface;
- float mTextSize;
- mutable int mEmSizeInFontUnits;
- bool mFakeBold;
- bool mFakeItalic;
- FontOrientation mOrientation;
- TextOrientation mTextOrientation;
+ SkTypeface* m_typeface;
+ float m_textSize;
+ mutable int m_emSizeInFontUnits;
+ bool m_fakeBold;
+ bool m_fakeItalic;
+ FontOrientation m_orientation;
+ TextOrientation m_textOrientation;
mutable RefPtr<RefCountedHarfbuzzFace> m_harfbuzzFace;
+ static SkLanguage s_defaultLanguage;
static SkTypeface* hashTableDeletedFontValue() {
return reinterpret_cast<SkTypeface*>(-1);
diff --git a/Source/WebCore/platform/graphics/android/fonts/FontPlatformDataAndroid.cpp b/Source/WebCore/platform/graphics/android/fonts/FontPlatformDataAndroid.cpp
index fc254c0..f3e4227 100644
--- a/Source/WebCore/platform/graphics/android/fonts/FontPlatformDataAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/fonts/FontPlatformDataAndroid.cpp
@@ -41,26 +41,26 @@
//#define COUNT_FONTPLATFORMDATA_LIFE
#ifdef COUNT_FONTPLATFORMDATA_LIFE
-static int gCount;
-static int gMaxCount;
+static int g_count;
+static int g_maxCount;
static void inc_count()
{
- if (++gCount > gMaxCount)
+ if (++g_count > g_maxCount)
{
- gMaxCount = gCount;
- SkDebugf("---------- FontPlatformData %d\n", gMaxCount);
+ g_maxCount = g_count;
+ SkDebugf("---------- FontPlatformData %d\n", g_maxCount);
}
}
-static void dec_count() { --gCount; }
+static void dec_count() { --g_count; }
#else
#define inc_count()
#define dec_count()
#endif
#ifdef TRACE_FONTPLATFORMDATA_LIFE
- #define trace(num) SkDebugf("FontPlatformData%d %p %g %d %d\n", num, mTypeface, mTextSize, mFakeBold, mFakeItalic)
+ #define trace(num) SkDebugf("FontPlatformData%d %p %g %d %d\n", num, m_typeface, m_textSize, m_fakeBold, m_fakeItalic)
#else
#define trace(num)
#endif
@@ -75,8 +75,8 @@ FontPlatformData::RefCountedHarfbuzzFace::~RefCountedHarfbuzzFace()
}
FontPlatformData::FontPlatformData()
- : mTypeface(NULL), mTextSize(0), mEmSizeInFontUnits(0), mFakeBold(false), mFakeItalic(false),
- mOrientation(Horizontal), mTextOrientation(TextOrientationVerticalRight)
+ : m_typeface(NULL), m_textSize(0), m_emSizeInFontUnits(0), m_fakeBold(false), m_fakeItalic(false),
+ m_orientation(Horizontal), m_textOrientation(TextOrientationVerticalRight)
{
inc_count();
trace(1);
@@ -84,30 +84,29 @@ FontPlatformData::FontPlatformData()
FontPlatformData::FontPlatformData(const FontPlatformData& src)
{
- if (hashTableDeletedFontValue() != src.mTypeface) {
- SkSafeRef(src.mTypeface);
+ if (hashTableDeletedFontValue() != src.m_typeface) {
+ SkSafeRef(src.m_typeface);
}
- mTypeface = src.mTypeface;
- mTextSize = src.mTextSize;
- mEmSizeInFontUnits = src.mEmSizeInFontUnits;
- mFakeBold = src.mFakeBold;
- mFakeItalic = src.mFakeItalic;
+ m_typeface = src.m_typeface;
+ m_textSize = src.m_textSize;
+ m_emSizeInFontUnits = src.m_emSizeInFontUnits;
+ m_fakeBold = src.m_fakeBold;
+ m_fakeItalic = src.m_fakeItalic;
m_harfbuzzFace = src.m_harfbuzzFace;
- mOrientation = src.mOrientation;
- mTextOrientation = src.mTextOrientation;
-
+ m_orientation = src.m_orientation;
+ m_textOrientation = src.m_textOrientation;
inc_count();
trace(2);
}
FontPlatformData::FontPlatformData(SkTypeface* tf, float textSize, bool fakeBold, bool fakeItalic,
FontOrientation orientation, TextOrientation textOrientation)
- : mTypeface(tf), mTextSize(textSize), mEmSizeInFontUnits(0), mFakeBold(fakeBold), mFakeItalic(fakeItalic),
- mOrientation(orientation), mTextOrientation(textOrientation)
+ : m_typeface(tf), m_textSize(textSize), m_emSizeInFontUnits(0), m_fakeBold(fakeBold), m_fakeItalic(fakeItalic),
+ m_orientation(orientation), m_textOrientation(textOrientation)
{
- if (hashTableDeletedFontValue() != mTypeface) {
- SkSafeRef(mTypeface);
+ if (hashTableDeletedFontValue() != m_typeface) {
+ SkSafeRef(m_typeface);
}
inc_count();
@@ -115,11 +114,11 @@ FontPlatformData::FontPlatformData(SkTypeface* tf, float textSize, bool fakeBold
}
FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize)
- : 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)
+ : m_typeface(src.m_typeface), m_textSize(textSize), m_emSizeInFontUnits(src.m_emSizeInFontUnits), m_fakeBold(src.m_fakeBold), m_fakeItalic(src.m_fakeItalic),
+ m_orientation(src.m_orientation), m_textOrientation(src.m_textOrientation), m_harfbuzzFace(src.m_harfbuzzFace)
{
- if (hashTableDeletedFontValue() != mTypeface) {
- SkSafeRef(mTypeface);
+ if (hashTableDeletedFontValue() != m_typeface) {
+ SkSafeRef(m_typeface);
}
inc_count();
@@ -127,20 +126,20 @@ FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize)
}
FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
- : mTypeface(NULL), mTextSize(size), mEmSizeInFontUnits(0), mFakeBold(bold), mFakeItalic(oblique),
- mOrientation(Horizontal), mTextOrientation(TextOrientationVerticalRight)
+ : m_typeface(NULL), m_textSize(size), m_emSizeInFontUnits(0), m_fakeBold(bold), m_fakeItalic(oblique),
+ m_orientation(Horizontal), m_textOrientation(TextOrientationVerticalRight)
{
inc_count();
trace(5);
}
FontPlatformData::FontPlatformData(const FontPlatformData& src, SkTypeface* tf)
- : mTypeface(tf), mTextSize(src.mTextSize), mEmSizeInFontUnits(0), mFakeBold(src.mFakeBold),
- mFakeItalic(src.mFakeItalic), mOrientation(src.mOrientation),
- mTextOrientation(src.mTextOrientation)
+ : m_typeface(tf), m_textSize(src.m_textSize), m_emSizeInFontUnits(0), m_fakeBold(src.m_fakeBold),
+ m_fakeItalic(src.m_fakeItalic), m_orientation(src.m_orientation),
+ m_textOrientation(src.m_textOrientation)
{
- if (hashTableDeletedFontValue() != mTypeface) {
- SkSafeRef(mTypeface);
+ if (hashTableDeletedFontValue() != m_typeface) {
+ SkSafeRef(m_typeface);
}
inc_count();
@@ -154,61 +153,67 @@ FontPlatformData::~FontPlatformData()
SkDebugf("----------- ~FontPlatformData\n");
#endif
- if (hashTableDeletedFontValue() != mTypeface) {
- SkSafeUnref(mTypeface);
+ if (hashTableDeletedFontValue() != m_typeface) {
+ SkSafeUnref(m_typeface);
}
}
int FontPlatformData::emSizeInFontUnits() const
{
- if (mEmSizeInFontUnits)
- return mEmSizeInFontUnits;
+ if (m_emSizeInFontUnits)
+ return m_emSizeInFontUnits;
SkAdvancedTypefaceMetrics* metrics = 0;
- if (mTypeface)
- metrics = mTypeface->getAdvancedTypefaceMetrics(SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo);
+ if (m_typeface)
+ metrics = m_typeface->getAdvancedTypefaceMetrics(SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo);
if (metrics) {
- mEmSizeInFontUnits = metrics->fEmSize;
+ m_emSizeInFontUnits = metrics->fEmSize;
metrics->unref();
} else
- mEmSizeInFontUnits = 1000; // default value copied from Skia.
- return mEmSizeInFontUnits;
+ m_emSizeInFontUnits = 1000; // default value copied from Skia.
+ return m_emSizeInFontUnits;
}
FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src)
{
- if (hashTableDeletedFontValue() != src.mTypeface) {
- SkSafeRef(src.mTypeface);
+ if (hashTableDeletedFontValue() != src.m_typeface) {
+ SkSafeRef(src.m_typeface);
}
- if (hashTableDeletedFontValue() != mTypeface) {
- SkSafeUnref(mTypeface);
+ if (hashTableDeletedFontValue() != m_typeface) {
+ SkSafeUnref(m_typeface);
}
- mTypeface = src.mTypeface;
- mEmSizeInFontUnits = src.mEmSizeInFontUnits;
- mTextSize = src.mTextSize;
- mFakeBold = src.mFakeBold;
- mFakeItalic = src.mFakeItalic;
+ m_typeface = src.m_typeface;
+ m_emSizeInFontUnits = src.m_emSizeInFontUnits;
+ m_textSize = src.m_textSize;
+ m_fakeBold = src.m_fakeBold;
+ m_fakeItalic = src.m_fakeItalic;
m_harfbuzzFace = src.m_harfbuzzFace;
- mOrientation = src.mOrientation;
- mTextOrientation = src.mTextOrientation;
+ m_orientation = src.m_orientation;
+ m_textOrientation = src.m_textOrientation;
return *this;
}
+SkLanguage FontPlatformData::s_defaultLanguage;
+void FontPlatformData::setDefaultLanguage(const char* language) {
+ s_defaultLanguage = SkLanguage(language);
+}
+
void FontPlatformData::setupPaint(SkPaint* paint) const
{
- if (hashTableDeletedFontValue() == mTypeface)
+ if (hashTableDeletedFontValue() == m_typeface)
paint->setTypeface(0);
else
- paint->setTypeface(mTypeface);
+ paint->setTypeface(m_typeface);
paint->setAntiAlias(true);
paint->setSubpixelText(true);
paint->setHinting(SkPaint::kSlight_Hinting);
- paint->setTextSize(SkFloatToScalar(mTextSize));
- paint->setFakeBoldText(mFakeBold);
- paint->setTextSkewX(mFakeItalic ? -SK_Scalar1/4 : 0);
+ paint->setTextSize(SkFloatToScalar(m_textSize));
+ paint->setFakeBoldText(m_fakeBold);
+ paint->setTextSkewX(m_fakeItalic ? -SK_Scalar1/4 : 0);
+ paint->setLanguage(s_defaultLanguage);
#ifndef SUPPORT_COMPLEX_SCRIPTS
paint->setTextEncoding(SkPaint::kUTF16_TextEncoding);
#endif
@@ -216,44 +221,44 @@ void FontPlatformData::setupPaint(SkPaint* paint) const
uint32_t FontPlatformData::uniqueID() const
{
- if (hashTableDeletedFontValue() == mTypeface)
+ if (hashTableDeletedFontValue() == m_typeface)
return SkTypeface::UniqueID(0);
else
- return SkTypeface::UniqueID(mTypeface);
+ return SkTypeface::UniqueID(m_typeface);
}
bool FontPlatformData::operator==(const FontPlatformData& a) const
{
- return mTypeface == a.mTypeface &&
- mTextSize == a.mTextSize &&
- mFakeBold == a.mFakeBold &&
- mFakeItalic == a.mFakeItalic &&
- mOrientation == a.mOrientation &&
- mTextOrientation == a.mTextOrientation;
+ return m_typeface == a.m_typeface &&
+ m_textSize == a.m_textSize &&
+ m_fakeBold == a.m_fakeBold &&
+ m_fakeItalic == a.m_fakeItalic &&
+ m_orientation == a.m_orientation &&
+ m_textOrientation == a.m_textOrientation;
}
unsigned FontPlatformData::hash() const
{
unsigned h;
- if (hashTableDeletedFontValue() == mTypeface) {
- h = reinterpret_cast<unsigned>(mTypeface);
+ if (hashTableDeletedFontValue() == m_typeface) {
+ h = reinterpret_cast<unsigned>(m_typeface);
} else {
- h = SkTypeface::UniqueID(mTypeface);
+ h = SkTypeface::UniqueID(m_typeface);
}
- uint32_t sizeAsInt = *reinterpret_cast<const uint32_t*>(&mTextSize);
+ uint32_t sizeAsInt = *reinterpret_cast<const uint32_t*>(&m_textSize);
- h ^= 0x01010101 * ((static_cast<int>(mTextOrientation) << 3) | (static_cast<int>(mOrientation) << 2) |
- ((int)mFakeBold << 1) | (int)mFakeItalic);
+ h ^= 0x01010101 * ((static_cast<int>(m_textOrientation) << 3) | (static_cast<int>(m_orientation) << 2) |
+ ((int)m_fakeBold << 1) | (int)m_fakeItalic);
h ^= sizeAsInt;
return h;
}
bool FontPlatformData::isFixedPitch() const
{
- if (mTypeface && (mTypeface != hashTableDeletedFontValue()))
- return mTypeface->isFixedWidth();
+ if (m_typeface && (m_typeface != hashTableDeletedFontValue()))
+ return m_typeface->isFixedWidth();
else
return false;
}
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
index 1270498..9914176 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
@@ -258,6 +258,7 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
if (!TilesManager::instance()->useDoubleBuffering() || m_paintingCollection->isReady()) {
ALOGV("have painting collection %p ready, swapping!", m_paintingCollection);
didCollectionSwap = true;
+ m_fastSwapMode = false;
TilesManager::instance()->incContentUpdates();
if (collectionsSwappedPtr)
*collectionsSwappedPtr = true;
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index fd5e9c4..920119b 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -134,6 +134,7 @@
#include "autofill/WebAutofill.h"
#include "htmlediting.h"
#include "markup.h"
+#include "unicode/uloc.h"
#include "visible_units.h"
#include <JNIHelp.h>
@@ -4407,6 +4408,44 @@ void WebViewCore::getLocale(String& language, String& region)
region = String(propRegn, 2);
}
+// generate bcp47 identifier for the supplied language/region
+static void toLanguageTag(char* output, size_t outSize, const String& language,
+ const String& region) {
+ if (output == NULL || outSize <= 0)
+ return;
+ String locale = language;
+ locale.append('_');
+ locale.append(region);
+ char canonicalChars[ULOC_FULLNAME_CAPACITY];
+ UErrorCode uErr = U_ZERO_ERROR;
+ uloc_canonicalize(locale.ascii().data(), canonicalChars,
+ ULOC_FULLNAME_CAPACITY, &uErr);
+ if (U_SUCCESS(uErr)) {
+ char likelyChars[ULOC_FULLNAME_CAPACITY];
+ uErr = U_ZERO_ERROR;
+ uloc_addLikelySubtags(canonicalChars, likelyChars,
+ ULOC_FULLNAME_CAPACITY, &uErr);
+ if (U_SUCCESS(uErr)) {
+ uErr = U_ZERO_ERROR;
+ uloc_toLanguageTag(likelyChars, output, outSize, FALSE, &uErr);
+ if (U_SUCCESS(uErr)) {
+ return;
+ } else {
+ ALOGD("uloc_toLanguageTag(\"%s\") failed: %s", likelyChars,
+ u_errorName(uErr));
+ }
+ } else {
+ ALOGD("uloc_addLikelySubtags(\"%s\") failed: %s", canonicalChars,
+ u_errorName(uErr));
+ }
+ } else {
+ ALOGD("uloc_canonicalize(\"%s\") failed: %s", locale.ascii().data(),
+ u_errorName(uErr));
+ }
+ // unable to build a proper language identifier
+ output[0] = '\0';
+}
+
void WebViewCore::updateLocale()
{
static String prevLang;
@@ -4421,6 +4460,9 @@ void WebViewCore::updateLocale()
prevRegn = region;
GlyphPageTreeNode::resetRoots();
fontCache()->invalidate();
+ char langTag[ULOC_FULLNAME_CAPACITY];
+ toLanguageTag(langTag, ULOC_FULLNAME_CAPACITY, language, region);
+ FontPlatformData::setDefaultLanguage(langTag);
}
}