WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
proposed patch
sfd2.patch (text/plain), 15.91 KB, created by
Balazs Kelemen
on 2009-03-17 01:29:59 PDT
(
hide
)
Description:
proposed patch
Filename:
MIME Type:
Creator:
Balazs Kelemen
Created:
2009-03-17 01:29:59 PDT
Size:
15.91 KB
patch
obsolete
>diff --git a/WebCore/css/CSSFontFaceSource.cpp b/WebCore/css/CSSFontFaceSource.cpp >index 111cea2..44f14b5 100644 >--- a/WebCore/css/CSSFontFaceSource.cpp >+++ b/WebCore/css/CSSFontFaceSource.cpp >@@ -154,7 +154,7 @@ SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescri > } > > SVGFontData* svgFontData = new SVGFontData(fontFaceElement); >- fontData.set(new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, fontDescription.renderingMode()), true, false, svgFontData)); >+ fontData.set((SimpleFontData::create(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, fontDescription.renderingMode()), true, false, svgFontData)).releaseRef()); > } > } else > #endif >@@ -163,14 +163,14 @@ SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescri > if (!m_font->ensureCustomFontData()) > return 0; > >- fontData.set(new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, fontDescription.renderingMode()), true, false)); >+ fontData.set(SimpleFontData::create(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, fontDescription.renderingMode()), true, false).releaseRef()); > } > } else { > #if ENABLE(SVG_FONTS) > // In-Document SVG Fonts > if (m_svgFontFaceElement) { > SVGFontData* svgFontData = new SVGFontData(m_svgFontFaceElement); >- fontData.set(new SimpleFontData(FontPlatformData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic), true, false, svgFontData)); >+ fontData.set((SimpleFontData::create(FontPlatformData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic), true, false, svgFontData)).releaseRef()); > } > #endif > } >@@ -182,7 +182,7 @@ SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescri > FontPlatformData* tempData = fontCache()->getCachedFontPlatformData(fontDescription, m_string); > if (!tempData) > tempData = fontCache()->getLastResortFallbackFont(fontDescription); >- fontData.set(new SimpleFontData(*tempData, true, true)); >+ fontData.set(SimpleFontData::create(*tempData, true, true).releaseRef()); > } > > m_fontDataTable.set(hashKey, fontData.get()); >diff --git a/WebCore/platform/graphics/Font.cpp b/WebCore/platform/graphics/Font.cpp >index f8bec82..bf95927 100644 >--- a/WebCore/platform/graphics/Font.cpp >+++ b/WebCore/platform/graphics/Font.cpp >@@ -32,6 +32,7 @@ > #include "GlyphBuffer.h" > #include "WidthIterator.h" > #include <wtf/MathExtras.h> >+#include <wtf/PassRefPtr.h> > > using namespace WTF; > using namespace Unicode; >@@ -59,7 +60,6 @@ Font::CodePath Font::s_codePath = Auto; > > Font::Font() > : m_pageZero(0) >- , m_cachedPrimaryFont(0) > , m_letterSpacing(0) > , m_wordSpacing(0) > , m_isPlatformFont(false) >@@ -69,7 +69,6 @@ Font::Font() > Font::Font(const FontDescription& fd, short letterSpacing, short wordSpacing) > : m_fontDescription(fd) > , m_pageZero(0) >- , m_cachedPrimaryFont(0) > , m_letterSpacing(letterSpacing) > , m_wordSpacing(wordSpacing) > , m_isPlatformFont(false) >@@ -79,7 +78,6 @@ Font::Font(const FontDescription& fd, short letterSpacing, short wordSpacing) > Font::Font(const FontPlatformData& fontData, bool isPrinterFont) > : m_fontList(FontFallbackList::create()) > , m_pageZero(0) >- , m_cachedPrimaryFont(0) > , m_letterSpacing(0) > , m_wordSpacing(0) > , m_isPlatformFont(true) >@@ -139,16 +137,16 @@ void Font::cachePrimaryFont() const > { > ASSERT(m_fontList); > ASSERT(!m_cachedPrimaryFont); >- m_cachedPrimaryFont = m_fontList->primaryFont(this)->fontDataForCharacter(' '); >+ m_cachedPrimaryFont = const_cast<SimpleFontData*>(m_fontList->primaryFont(this)->fontDataForCharacter(' ')); > } > >-const FontData* Font::fontDataAt(unsigned index) const >+PassRefPtr<FontData> Font::fontDataAt(unsigned index) const > { > ASSERT(m_fontList); > return m_fontList->fontDataAt(this, index); > } > >-const FontData* Font::fontDataForCharacters(const UChar* characters, int length) const >+PassRefPtr<FontData> Font::fontDataForCharacters(const UChar* characters, int length) const > { > ASSERT(m_fontList); > return m_fontList->fontDataForCharacters(this, characters, length); >@@ -164,7 +162,7 @@ void Font::update(PassRefPtr<FontSelector> fontSelector) const > if (!m_fontList) > m_fontList = FontFallbackList::create(); > m_fontList->invalidate(fontSelector); >- m_cachedPrimaryFont = 0; >+ m_cachedPrimaryFont.clear(); > m_pageZero = 0; > m_pages.clear(); > } >diff --git a/WebCore/platform/graphics/Font.h b/WebCore/platform/graphics/Font.h >index 1bfee8f..1470d94 100644 >--- a/WebCore/platform/graphics/Font.h >+++ b/WebCore/platform/graphics/Font.h >@@ -30,6 +30,7 @@ > #include "SimpleFontData.h" > #include <wtf/HashMap.h> > #include <wtf/MathExtras.h> >+#include <wtf/RefPtr.h> > > #if PLATFORM(QT) > #include <QFont> >@@ -115,16 +116,17 @@ public: > int spaceWidth() const { return (int)ceilf(primaryFont()->m_adjustedSpaceWidth + m_letterSpacing); } > int tabWidth() const { return 8 * spaceWidth(); } > >- const SimpleFontData* primaryFont() const { >+ const SimpleFontData* primaryFont() const >+ { > if (!m_cachedPrimaryFont) > cachePrimaryFont(); >- return m_cachedPrimaryFont; >+ return m_cachedPrimaryFont.get(); > } > >- const FontData* fontDataAt(unsigned) const; >+ PassRefPtr<FontData> fontDataAt(unsigned) const; > const GlyphData& glyphDataForCharacter(UChar32, bool mirror, bool forceSmallCaps = false) const; > // Used for complex text, and does not utilize the glyph map cache. >- const FontData* fontDataForCharacters(const UChar*, int length) const; >+ PassRefPtr<FontData> fontDataForCharacters(const UChar*, int length) const; > > #if PLATFORM(QT) > QFont font() const; >@@ -186,7 +188,7 @@ private: > mutable RefPtr<FontFallbackList> m_fontList; > mutable HashMap<int, GlyphPageTreeNode*> m_pages; > mutable GlyphPageTreeNode* m_pageZero; >- mutable const SimpleFontData* m_cachedPrimaryFont; >+ mutable RefPtr<SimpleFontData> m_cachedPrimaryFont; > short m_letterSpacing; > short m_wordSpacing; > bool m_isPlatformFont; >diff --git a/WebCore/platform/graphics/FontData.h b/WebCore/platform/graphics/FontData.h >index cb79919..0a5455e 100644 >--- a/WebCore/platform/graphics/FontData.h >+++ b/WebCore/platform/graphics/FontData.h >@@ -28,18 +28,15 @@ > > #include <wtf/Noncopyable.h> > #include <wtf/unicode/Unicode.h> >+#include <wtf/RefCounted.h> >+#include <wtf/PassRefPtr.h> > > namespace WebCore { > > class SimpleFontData; > >-class FontData : Noncopyable { >+class FontData : public RefCounted<FontData> { > public: >- FontData() >- : m_maxGlyphPageTreeLevel(0) >- { >- } >- > virtual ~FontData(); > > virtual const SimpleFontData* fontDataForCharacter(UChar32) const = 0; >@@ -51,6 +48,12 @@ public: > void setMaxGlyphPageTreeLevel(unsigned level) const { m_maxGlyphPageTreeLevel = level; } > unsigned maxGlyphPageTreeLevel() const { return m_maxGlyphPageTreeLevel; } > >+protected: >+ FontData() >+ : m_maxGlyphPageTreeLevel(0) >+ { >+ } >+ > private: > mutable unsigned m_maxGlyphPageTreeLevel; > }; >diff --git a/WebCore/platform/graphics/FontFallbackList.h b/WebCore/platform/graphics/FontFallbackList.h >index a23b32c..fb633dc 100644 >--- a/WebCore/platform/graphics/FontFallbackList.h >+++ b/WebCore/platform/graphics/FontFallbackList.h >@@ -27,6 +27,7 @@ > #include "FontSelector.h" > #include "SimpleFontData.h" > #include <wtf/Forward.h> >+#include <wtf/PassRefPtr.h> > > namespace WebCore { > >@@ -57,9 +58,9 @@ public: > private: > FontFallbackList(); > >- const FontData* primaryFont(const Font* f) const { return fontDataAt(f, 0); } >- const FontData* fontDataAt(const Font*, unsigned index) const; >- const FontData* fontDataForCharacters(const Font*, const UChar*, int length) const; >+ PassRefPtr<FontData> primaryFont(const Font* f) const { return fontDataAt(f, 0); } >+ PassRefPtr<FontData> fontDataAt(const Font*, unsigned index) const; >+ PassRefPtr<FontData> fontDataForCharacters(const Font*, const UChar*, int length) const; > > void setPlatformFont(const FontPlatformData&); > >diff --git a/WebCore/platform/graphics/SegmentedFontData.h b/WebCore/platform/graphics/SegmentedFontData.h >index 0a78321..333b8dc 100644 >--- a/WebCore/platform/graphics/SegmentedFontData.h >+++ b/WebCore/platform/graphics/SegmentedFontData.h >@@ -28,6 +28,7 @@ > > #include "FontData.h" > #include <wtf/Vector.h> >+#include <wtf/PassRefPtr.h> > > namespace WebCore { > >@@ -37,22 +38,27 @@ struct FontDataRange { > FontDataRange(UChar32 from, UChar32 to, const SimpleFontData* fontData) > : m_from(from) > , m_to(to) >- , m_fontData(fontData) >+ , m_fontData(const_cast<SimpleFontData*>(fontData)) > { > } > > UChar32 from() const { return m_from; } > UChar32 to() const { return m_to; } >- const SimpleFontData* fontData() const { return m_fontData; } >+ const SimpleFontData* fontData() const { return m_fontData.get(); } > > private: > UChar32 m_from; > UChar32 m_to; >- const SimpleFontData* m_fontData; >+ RefPtr<SimpleFontData> m_fontData; > }; > > class SegmentedFontData : public FontData { > public: >+ static PassRefPtr<SegmentedFontData> create() >+ { >+ return adoptRef(new SegmentedFontData); >+ } >+ > virtual ~SegmentedFontData(); > > void appendRange(const FontDataRange& range) { m_ranges.append(range); } >diff --git a/WebCore/platform/graphics/SimpleFontData.cpp b/WebCore/platform/graphics/SimpleFontData.cpp >index 9f51037..40bd29f 100644 >--- a/WebCore/platform/graphics/SimpleFontData.cpp >+++ b/WebCore/platform/graphics/SimpleFontData.cpp >@@ -37,6 +37,7 @@ > #include "SVGFontFaceElement.h" > #endif > >+#include "GlyphPageTreeNode.h" > #include <wtf/MathExtras.h> > > namespace WebCore { >@@ -50,7 +51,6 @@ SimpleFontData::SimpleFontData(const FontPlatformData& f, bool customFont, bool > #endif > , m_isCustomFont(customFont) > , m_isLoading(loading) >- , m_smallCapsFontData(0) > { > #if ENABLE(SVG_FONTS) > if (SVGFontFaceElement* svgFontFaceElement = svgFontData ? svgFontData->svgFontFaceElement() : 0) { >@@ -63,7 +63,7 @@ SimpleFontData::SimpleFontData(const FontPlatformData& f, bool customFont, bool > m_ascent = static_cast<int>(svgFontFaceElement->ascent() * scale); > m_descent = static_cast<int>(svgFontFaceElement->descent() * scale); > m_xHeight = static_cast<int>(svgFontFaceElement->xHeight() * scale); >- m_lineGap = 0.1f * f.size(); >+ m_lineGap = static_cast<int>(0.1f * f.size()); > m_lineSpacing = m_ascent + m_descent + m_lineGap; > > m_spaceGlyph = 0; >@@ -131,7 +131,7 @@ SimpleFontData::~SimpleFontData() > > if (!isCustomFont()) { > if (m_smallCapsFontData) >- fontCache()->releaseFontData(m_smallCapsFontData); >+ fontCache()->releaseFontData(m_smallCapsFontData.get()); > GlyphPageTreeNode::pruneTreeFontData(this); > } > } >diff --git a/WebCore/platform/graphics/SimpleFontData.h b/WebCore/platform/graphics/SimpleFontData.h >index d2dd0b9..131c02e 100644 >--- a/WebCore/platform/graphics/SimpleFontData.h >+++ b/WebCore/platform/graphics/SimpleFontData.h >@@ -28,6 +28,7 @@ > #include "GlyphPageTreeNode.h" > #include "GlyphWidthMap.h" > #include <wtf/OwnPtr.h> >+#include <wtf/PassRefPtr.h> > > #if USE(ATSUI) > typedef struct OpaqueATSUStyle* ATSUStyle; >@@ -57,11 +58,14 @@ enum Pitch { UnknownPitch, FixedPitch, VariablePitch }; > > class SimpleFontData : public FontData { > public: >- SimpleFontData(const FontPlatformData&, bool customFont = false, bool loading = false, SVGFontData* data = 0); >+ static PassRefPtr<SimpleFontData> create(const FontPlatformData& platformData, bool customFont = false, bool loading = false, SVGFontData* data = 0) >+ { >+ return adoptRef(new SimpleFontData(platformData, customFont, loading, data)); >+ } > virtual ~SimpleFontData(); > > public: >- const FontPlatformData& platformData() const { return m_font; } >+ const FontPlatformData& platformData() const { return m_font; } > SimpleFontData* smallCapsFontData(const FontDescription& fontDescription) const; > > // vertical metrics >@@ -135,6 +139,7 @@ public: > #endif > > private: >+ SimpleFontData(const FontPlatformData&, bool customFont, bool loading, SVGFontData* data); > void platformInit(); > void platformGlyphInit(); > void platformDestroy(); >@@ -174,7 +179,7 @@ public: > > GlyphData m_missingGlyphData; > >- mutable SimpleFontData* m_smallCapsFontData; >+ mutable RefPtr<SimpleFontData> m_smallCapsFontData; > > #if PLATFORM(CG) || PLATFORM(WIN) > float m_syntheticBoldOffset; >diff --git a/WebCore/platform/graphics/qt/FontCacheQt.cpp b/WebCore/platform/graphics/qt/FontCacheQt.cpp >index 114f073..444d075 100644 >--- a/WebCore/platform/graphics/qt/FontCacheQt.cpp >+++ b/WebCore/platform/graphics/qt/FontCacheQt.cpp >@@ -49,8 +49,9 @@ FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& de > return new FontPlatformData(description); > } > >-SimpleFontData* FontCache::getCachedFontData(const FontPlatformData*) >+SimpleFontData* FontCache::getCachedFontData(const FontPlatformData* data) > { >+ delete data; > return 0; > } > >diff --git a/WebCore/platform/graphics/qt/FontFallbackListQt.cpp b/WebCore/platform/graphics/qt/FontFallbackListQt.cpp >index 22ae205..ebf2096 100644 >--- a/WebCore/platform/graphics/qt/FontFallbackListQt.cpp >+++ b/WebCore/platform/graphics/qt/FontFallbackListQt.cpp >@@ -26,6 +26,8 @@ > > #include "Font.h" > #include "SegmentedFontData.h" >+#include <wtf/RefPtr.h> >+#include <wtf/PassRefPtr.h> > > #include <QDebug> > >@@ -57,11 +59,11 @@ void FontFallbackList::releaseFontData() > > void FontFallbackList::determinePitch(const WebCore::Font* font) const > { >- const FontData* fontData = primaryFont(font); >+ RefPtr<FontData> fontData = primaryFont(font); > if (!fontData->isSegmented()) >- m_pitch = static_cast<const SimpleFontData*>(fontData)->pitch(); >+ m_pitch = static_pointer_cast<SimpleFontData>(fontData)->pitch(); > else { >- const SegmentedFontData* segmentedFontData = static_cast<const SegmentedFontData*>(fontData); >+ const SegmentedFontData* segmentedFontData = static_pointer_cast<SegmentedFontData>(fontData).get(); > unsigned numRanges = segmentedFontData->numRanges(); > if (numRanges == 1) > m_pitch = segmentedFontData->rangeAt(0).fontData()->pitch(); >@@ -70,10 +72,10 @@ void FontFallbackList::determinePitch(const WebCore::Font* font) const > } > } > >-const FontData* FontFallbackList::fontDataAt(const WebCore::Font* _font, unsigned index) const >+PassRefPtr<FontData> FontFallbackList::fontDataAt(const WebCore::Font* _font, unsigned index) const > { > if (index != 0) >- return 0; >+ return PassRefPtr<FontData>(); > > // Use the FontSelector to get a WebCore font and then fallback to Qt > const FontDescription& description = _font->fontDescription(); >@@ -84,16 +86,16 @@ const FontData* FontFallbackList::fontDataAt(const WebCore::Font* _font, unsigne > if (data) { > if (data->isLoading()) > m_loadingCustomFonts = true; >- return data; >+ return adoptRef(data); > } > } > family = family->next(); > } > >- return new SimpleFontData(FontPlatformData(description), _font->wordSpacing(), _font->letterSpacing()); >+ return SimpleFontData::create(FontPlatformData(description), _font->wordSpacing(), _font->letterSpacing()); > } > >-const FontData* FontFallbackList::fontDataForCharacters(const WebCore::Font* font, const UChar*, int) const >+PassRefPtr<FontData> FontFallbackList::fontDataForCharacters(const WebCore::Font* font, const UChar*, int) const > { > return primaryFont(font); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
hyatt
:
review-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 24551
:
28536
|
28684
|
28928
|
28931
|
28966
|
29158
|
29228
|
29277
|
29815
|
29816