summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/win
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/win')
-rw-r--r--WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp8
-rw-r--r--WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h9
-rw-r--r--WebCore/platform/graphics/win/WKCACFLayer.cpp30
-rw-r--r--WebCore/platform/graphics/win/WKCACFLayer.h23
-rwxr-xr-xWebCore/platform/graphics/win/WebTiledLayer.cpp20
-rw-r--r--WebCore/platform/graphics/win/WebTiledLayer.h4
6 files changed, 83 insertions, 11 deletions
diff --git a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp b/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp
index 35839f5..02c5b99 100644
--- a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp
+++ b/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp
@@ -27,12 +27,12 @@
namespace WebCore {
-FontCustomPlatformDataCairo::~FontCustomPlatformDataCairo()
+FontCustomPlatformData::~FontCustomPlatformData()
{
cairo_font_face_destroy(m_fontFace);
}
-FontPlatformData FontCustomPlatformDataCairo::fontPlatformData(int size, bool bold, bool italic)
+FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic)
{
return FontPlatformData(m_fontFace, size, bold, italic);
}
@@ -42,7 +42,7 @@ static void releaseData(void* data)
static_cast<SharedBuffer*>(data)->deref();
}
-FontCustomPlatformDataCairo* createFontCustomPlatformData(SharedBuffer* buffer)
+FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
{
ASSERT_ARG(buffer, buffer);
@@ -55,7 +55,7 @@ FontCustomPlatformDataCairo* createFontCustomPlatformData(SharedBuffer* buffer)
static cairo_user_data_key_t bufferKey;
cairo_font_face_set_user_data(fontFace, &bufferKey, buffer, releaseData);
- return new FontCustomPlatformDataCairo(fontFace);
+ return new FontCustomPlatformData(fontFace);
}
bool FontCustomPlatformData::supportsFormat(const String& format)
diff --git a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h b/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h
index 2dbea51..525957f 100644
--- a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h
+++ b/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2007 Apple Computer, Inc.
+ * Copyright (C) 2010 Brent Fulgham <bfulgham@webkit.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -31,12 +32,12 @@ namespace WebCore {
class FontPlatformData;
class SharedBuffer;
-struct FontCustomPlatformDataCairo : Noncopyable {
- FontCustomPlatformDataCairo(cairo_font_face_t* fontFace)
+struct FontCustomPlatformData : Noncopyable {
+ FontCustomPlatformData(cairo_font_face_t* fontFace)
: m_fontFace(fontFace)
{
}
- ~FontCustomPlatformDataCairo();
+ ~FontCustomPlatformData();
FontPlatformData fontPlatformData(int size, bool bold, bool italic);
@@ -45,7 +46,7 @@ struct FontCustomPlatformDataCairo : Noncopyable {
cairo_font_face_t* m_fontFace;
};
-FontCustomPlatformDataCairo* createFontCustomPlatformData(SharedBuffer*);
+FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer*);
}
diff --git a/WebCore/platform/graphics/win/WKCACFLayer.cpp b/WebCore/platform/graphics/win/WKCACFLayer.cpp
index b5f3427..bbe5883 100644
--- a/WebCore/platform/graphics/win/WKCACFLayer.cpp
+++ b/WebCore/platform/graphics/win/WKCACFLayer.cpp
@@ -44,6 +44,24 @@ namespace WebCore {
using namespace std;
+#ifndef NDEBUG
+void WKCACFLayer::internalCheckLayerConsistency()
+{
+ ASSERT(layer());
+ size_t n = sublayerCount();
+ for (size_t i = 0; i < n; ++i) {
+ // This will ASSERT in internalSublayerAtIndex if this entry doesn't have proper user data
+ WKCACFLayer* sublayer = internalSublayerAtIndex(i);
+
+ // Make sure we don't have any null entries in the list
+ ASSERT(sublayer);
+
+ // Make sure the each layer has a corresponding CACFLayer
+ ASSERT(sublayer->layer());
+ }
+}
+#endif
+
static void displayCallback(CACFLayerRef layer, CGContextRef context)
{
ASSERT_ARG(layer, WKCACFLayer::layer(layer));
@@ -161,7 +179,14 @@ WKCACFLayer::~WKCACFLayer()
// Our superlayer should be holding a reference to us, so there should be no way for us to be destroyed while we still have a superlayer.
ASSERT(!superlayer());
+ // Get rid of the children so we don't have any dangling references around
+ removeAllSublayers();
+
+#ifndef NDEBUG
+ CACFLayerSetUserData(layer(), reinterpret_cast<void*>(0xDEADBEEF));
+#else
CACFLayerSetUserData(layer(), 0);
+#endif
CACFLayerSetDisplayCallback(layer(), 0);
}
@@ -192,10 +217,11 @@ void WKCACFLayer::addSublayer(PassRefPtr<WKCACFLayer> sublayer)
void WKCACFLayer::internalInsertSublayer(PassRefPtr<WKCACFLayer> sublayer, size_t index)
{
- index = min(index, sublayerCount());
+ index = min(index, sublayerCount() + 1);
sublayer->removeFromSuperlayer();
CACFLayerInsertSublayer(layer(), sublayer->layer(), index);
setNeedsCommit();
+ checkLayerConsistency();
}
void WKCACFLayer::insertSublayerAboveLayer(PassRefPtr<WKCACFLayer> sublayer, const WKCACFLayer* reference)
@@ -268,12 +294,14 @@ void WKCACFLayer::adoptSublayers(WKCACFLayer* source)
sublayers.append(source->internalSublayerAtIndex(i));
setSublayers(sublayers);
+ source->checkLayerConsistency();
}
void WKCACFLayer::removeFromSuperlayer()
{
WKCACFLayer* superlayer = this->superlayer();
CACFLayerRemoveFromSuperlayer(layer());
+ checkLayerConsistency();
if (superlayer)
superlayer->setNeedsCommit();
diff --git a/WebCore/platform/graphics/win/WKCACFLayer.h b/WebCore/platform/graphics/win/WKCACFLayer.h
index abc04c8..7243508 100644
--- a/WebCore/platform/graphics/win/WKCACFLayer.h
+++ b/WebCore/platform/graphics/win/WKCACFLayer.h
@@ -60,7 +60,11 @@ public:
BottomLeft, BottomRight, Resize, ResizeAspect, ResizeAspectFill };
static PassRefPtr<WKCACFLayer> create(LayerType);
- static WKCACFLayer* layer(CACFLayerRef layer) { return static_cast<WKCACFLayer*>(CACFLayerGetUserData(layer)); }
+ static WKCACFLayer* layer(CACFLayerRef layer)
+ {
+ ASSERT(CACFLayerGetUserData(layer) != reinterpret_cast<void*>(0xDEADBEEF));
+ return static_cast<WKCACFLayer*>(CACFLayerGetUserData(layer));
+ }
virtual ~WKCACFLayer();
@@ -133,7 +137,11 @@ public:
void adoptSublayers(WKCACFLayer* source);
void removeAllSublayers() { internalRemoveAllSublayers(); }
- void setSublayers(const Vector<RefPtr<WKCACFLayer> >& sublayers) { internalSetSublayers(sublayers); }
+ void setSublayers(const Vector<RefPtr<WKCACFLayer> >& sublayers)
+ {
+ internalSetSublayers(sublayers);
+ checkLayerConsistency();
+ }
void insertSublayer(PassRefPtr<WKCACFLayer> layer, size_t index) { internalInsertSublayer(layer, index); }
@@ -244,6 +252,13 @@ protected:
// This should only be called from removeFromSuperlayer.
void removeSublayer(const WKCACFLayer*);
+ void checkLayerConsistency()
+ {
+#ifndef NDEBUG
+ internalCheckLayerConsistency();
+#endif
+ }
+
// Methods to be overridden for sublayer and rendering management
virtual WKCACFLayer* internalSublayerAtIndex(int) const;
@@ -259,6 +274,10 @@ protected:
virtual void internalSetNeedsDisplay(const CGRect* dirtyRect);
#ifndef NDEBUG
+ virtual void internalCheckLayerConsistency();
+#endif
+
+#ifndef NDEBUG
// Print this layer and its children to the console
void printLayer(int indent) const;
#endif
diff --git a/WebCore/platform/graphics/win/WebTiledLayer.cpp b/WebCore/platform/graphics/win/WebTiledLayer.cpp
index d8c02d2..01dd6ae 100755
--- a/WebCore/platform/graphics/win/WebTiledLayer.cpp
+++ b/WebCore/platform/graphics/win/WebTiledLayer.cpp
@@ -36,6 +36,26 @@ namespace WebCore {
using namespace std;
+#ifndef NDEBUG
+void WebTiledLayer::internalCheckLayerConsistency()
+{
+ WKCACFLayer::internalCheckLayerConsistency();
+
+ // Additionally make sure the tiled parent is valid
+ CFArrayRef sublayers = CACFLayerGetSublayers(layer());
+
+ // Make sure there is a tile parent and it is the same as we remember
+ size_t n = CFArrayGetCount(sublayers);
+ ASSERT(n > 0);
+ const void* element = CFArrayGetValueAtIndex(sublayers, 0);
+ ASSERT(m_tileParent.get() == element);
+
+ // Make sure the tile parent doesn't have user data. If it does, it is probably
+ // a WKCACFLayer in the wrong place.
+ ASSERT(!layer(m_tileParent.get()));
+}
+#endif
+
void WebTiledLayer::tileDisplayCallback(CACFLayerRef layer, CGContextRef context)
{
static_cast<WebTiledLayer*>(CACFLayerGetUserData(layer))->drawTile(layer, context);
diff --git a/WebCore/platform/graphics/win/WebTiledLayer.h b/WebCore/platform/graphics/win/WebTiledLayer.h
index fdf0205..b8ae320 100644
--- a/WebCore/platform/graphics/win/WebTiledLayer.h
+++ b/WebCore/platform/graphics/win/WebTiledLayer.h
@@ -56,6 +56,10 @@ protected:
virtual void internalSetNeedsDisplay(const CGRect* dirtyRect);
+#ifndef NDEBUG
+ virtual void internalCheckLayerConsistency();
+#endif
+
private:
static void tileDisplayCallback(CACFLayerRef, CGContextRef);
void drawTile(CACFLayerRef, CGContextRef);