summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Roard <nicolasroard@google.com>2012-05-15 09:57:23 -0700
committerNicolas Roard <nicolasroard@google.com>2012-05-15 10:02:38 -0700
commitca602195c97340b621ffe0c5a7fdf3732d439219 (patch)
tree729afeab943aabdc543043f016f73a6708808626
parent0d38139a55b1f371edb1a2a65f4b7ee51daa8e37 (diff)
downloadexternal_webkit-ca602195c97340b621ffe0c5a7fdf3732d439219.zip
external_webkit-ca602195c97340b621ffe0c5a7fdf3732d439219.tar.gz
external_webkit-ca602195c97340b621ffe0c5a7fdf3732d439219.tar.bz2
Fix crash on arstechnica
Not checking for cachedImage for the background images... bug:6482165 Change-Id: I9de5ee9cef446cd07688b40f6b04bdd493e40edd
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp34
-rw-r--r--Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp31
-rw-r--r--Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.h2
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp3
4 files changed, 51 insertions, 19 deletions
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index 68f452a..a6bf6af 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -604,24 +604,22 @@ void GraphicsLayerAndroid::updateFixedBackgroundLayers() {
// Grab the background image and create a layer for it
// the layer will be fixed positioned.
- FillLayer* layers = view->style()->accessBackgroundLayers();
- StyleImage* styleImage = layers->image();
- if (styleImage->isCachedImage()) {
- CachedImage* cachedImage = static_cast<StyleCachedImage*>(styleImage)->cachedImage();
- Image* image = cachedImage->image();
- if (image) {
- m_fixedBackgroundLayer = new FixedBackgroundImageLayerAndroid(view->style(),
- view->width(),
- view->height());
-
- Color color = view->style()->visitedDependentColor(CSSPropertyBackgroundColor);
- SkColor skiaColor = SkColorSetARGB(color.alpha(),
- color.red(),
- color.green(),
- color.blue());
- m_fixedBackgroundLayer->setBackgroundColor(skiaColor);
- }
- }
+
+ Image* image = FixedBackgroundImageLayerAndroid::GetCachedImage(view->style());
+
+ if (!image)
+ return;
+
+ m_fixedBackgroundLayer = new FixedBackgroundImageLayerAndroid(view->style(),
+ view->width(),
+ view->height());
+
+ Color color = view->style()->visitedDependentColor(CSSPropertyBackgroundColor);
+ SkColor skiaColor = SkColorSetARGB(color.alpha(),
+ color.red(),
+ color.green(),
+ color.blue());
+ m_fixedBackgroundLayer->setBackgroundColor(skiaColor);
// We need to clip the background image to the bounds of the original element
m_foregroundClipLayer = new LayerAndroid(renderLayer);
diff --git a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp
index 8abff96..62a5824 100644
--- a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp
@@ -202,4 +202,35 @@ bool FixedBackgroundImageLayerAndroid::drawGL(bool layerTilesDisabled)
return false;
}
+Image* FixedBackgroundImageLayerAndroid::GetCachedImage(PassRefPtr<RenderStyle> aStyle)
+{
+ RefPtr<RenderStyle> style = aStyle;
+ if (!style)
+ return 0;
+
+ if (!style->hasFixedBackgroundImage())
+ return 0;
+
+ FillLayer* layers = style->accessBackgroundLayers();
+ StyleImage* styleImage = layers->image();
+
+ if (!styleImage)
+ return 0;
+
+ if (!styleImage->isLoaded())
+ return 0;
+
+ if (!styleImage->isCachedImage())
+ return 0;
+
+ CachedImage* cachedImage = static_cast<StyleCachedImage*>(styleImage)->cachedImage();
+
+ Image* image = cachedImage->image();
+
+ if (image == Image::nullImage())
+ return 0;
+
+ return image;
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.h
index 7c755ae..57d8ed9 100644
--- a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.h
@@ -31,6 +31,7 @@
namespace WebCore {
+class Image;
class RenderLayerCompositor;
class RenderStyle;
@@ -68,6 +69,7 @@ public:
virtual bool needsTexture() { return true; }
virtual SubclassType subclassType() { return LayerAndroid::FixedBackgroundImageLayer; }
virtual bool drawGL(bool layerTilesDisabled);
+ static Image* GetCachedImage(PassRefPtr<RenderStyle> style);
private:
int m_width;
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index e621644..1a67efa 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -835,7 +835,8 @@ BaseLayerAndroid* WebViewCore::createBaseLayer()
Color viewBackground = view->baseBackgroundColor();
background = bodyHasCSSBackground ? viewBackground.blend(background) : viewBackground;
}
- bodyHasFixedBackgroundImage = style->hasFixedBackgroundImage();
+ bodyHasFixedBackgroundImage = style->hasFixedBackgroundImage()
+ && FixedBackgroundImageLayerAndroid::GetCachedImage(style);
}
PicturePileLayerContent* content = new PicturePileLayerContent(m_content);