- Revision
- 103676
- Author
- [email protected]
- Date
- 2011-12-25 20:46:34 -0800 (Sun, 25 Dec 2011)
Log Message
Use OwnPtr for CSSFontFace::m_sources
https://bugs.webkit.org/show_bug.cgi?id=75219
Reviewed by Dan Bernstein.
* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::isLoaded): Use the same size_t idiom here as in the rest
of the functions.
(WebCore::CSSFontFace::isValid): Ditto. Also removed unneeded empty special casing.
(WebCore::CSSFontFace::addSource): Changed to take a PassOwnPtr. Reordered so the
PassOwnPtr zeroing does not cause trouble.
(WebCore::CSSFontFace::getFontData): Added call to get.
(WebCore::CSSFontFace::hasSVGFontFaceSource): Use the same size_t idiom here as in
the rest of the functions.
* css/CSSFontFace.h: Use PassOwnPtr for addSource argument, and Vector<OwnPtr> for
the m_sources vector.
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule): Use OwnPtr and PassOwnPtr for font face
sources that are passed to addSource.
* css/CSSSegmentedFontFace.cpp: Added a now-needed include.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (103675 => 103676)
--- trunk/Source/WebCore/ChangeLog 2011-12-26 04:02:21 UTC (rev 103675)
+++ trunk/Source/WebCore/ChangeLog 2011-12-26 04:46:34 UTC (rev 103676)
@@ -1,3 +1,29 @@
+2011-12-25 Darin Adler <[email protected]>
+
+ Use OwnPtr for CSSFontFace::m_sources
+ https://bugs.webkit.org/show_bug.cgi?id=75219
+
+ Reviewed by Dan Bernstein.
+
+ * css/CSSFontFace.cpp:
+ (WebCore::CSSFontFace::isLoaded): Use the same size_t idiom here as in the rest
+ of the functions.
+ (WebCore::CSSFontFace::isValid): Ditto. Also removed unneeded empty special casing.
+ (WebCore::CSSFontFace::addSource): Changed to take a PassOwnPtr. Reordered so the
+ PassOwnPtr zeroing does not cause trouble.
+ (WebCore::CSSFontFace::getFontData): Added call to get.
+ (WebCore::CSSFontFace::hasSVGFontFaceSource): Use the same size_t idiom here as in
+ the rest of the functions.
+
+ * css/CSSFontFace.h: Use PassOwnPtr for addSource argument, and Vector<OwnPtr> for
+ the m_sources vector.
+
+ * css/CSSFontSelector.cpp:
+ (WebCore::CSSFontSelector::addFontFaceRule): Use OwnPtr and PassOwnPtr for font face
+ sources that are passed to addSource.
+
+ * css/CSSSegmentedFontFace.cpp: Added a now-needed include.
+
2011-12-24 Jarred Nicholls <[email protected]>
Allow XMLHttpRequest responseType to be set at any state up to and including HEADERS_RECEIVED
Modified: trunk/Source/WebCore/css/CSSFontFace.cpp (103675 => 103676)
--- trunk/Source/WebCore/css/CSSFontFace.cpp 2011-12-26 04:02:21 UTC (rev 103675)
+++ trunk/Source/WebCore/css/CSSFontFace.cpp 2011-12-26 04:46:34 UTC (rev 103676)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -34,15 +34,10 @@
namespace WebCore {
-CSSFontFace::~CSSFontFace()
-{
- deleteAllValues(m_sources);
-}
-
bool CSSFontFace::isLoaded() const
{
- unsigned size = m_sources.size();
- for (unsigned i = 0; i < size; i++) {
+ size_t size = m_sources.size();
+ for (size_t i = 0; i < size; i++) {
if (!m_sources[i]->isLoaded())
return false;
}
@@ -51,10 +46,8 @@
bool CSSFontFace::isValid() const
{
- unsigned size = m_sources.size();
- if (!size)
- return false;
- for (unsigned i = 0; i < size; i++) {
+ size_t size = m_sources.size();
+ for (size_t i = 0; i < size; i++) {
if (m_sources[i]->isValid())
return true;
}
@@ -71,10 +64,10 @@
m_segmentedFontFaces.remove(segmentedFontFace);
}
-void CSSFontFace::addSource(CSSFontFaceSource* source)
+void CSSFontFace::addSource(PassOwnPtr<CSSFontFaceSource> source)
{
- m_sources.append(source);
source->setFontFace(this);
+ m_sources.append(source);
}
void CSSFontFace::fontLoaded(CSSFontFaceSource* source)
@@ -110,7 +103,7 @@
size_t size = m_sources.size();
for (size_t i = 0; i < size; ++i) {
if (SimpleFontData* result = m_sources[i]->getFontData(fontDescription, syntheticBold, syntheticItalic, fontSelector)) {
- m_activeSource = m_sources[i];
+ m_activeSource = m_sources[i].get();
return result;
}
}
@@ -121,7 +114,8 @@
#if ENABLE(SVG_FONTS)
bool CSSFontFace::hasSVGFontFaceSource() const
{
- for (unsigned i = 0; i < m_sources.size(); i++) {
+ size_t size = m_sources.size();
+ for (size_t i = 0; i < size; i++) {
if (m_sources[i]->isSVGFontFaceSource())
return true;
}
@@ -130,4 +124,3 @@
#endif
}
-
Modified: trunk/Source/WebCore/css/CSSFontFace.h (103675 => 103676)
--- trunk/Source/WebCore/css/CSSFontFace.h 2011-12-26 04:02:21 UTC (rev 103675)
+++ trunk/Source/WebCore/css/CSSFontFace.h 2011-12-26 04:46:34 UTC (rev 103676)
@@ -27,6 +27,7 @@
#define CSSFontFace_h
#include "FontTraitsMask.h"
+#include <wtf/Forward.h>
#include <wtf/HashSet.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -43,7 +44,6 @@
class CSSFontFace : public RefCounted<CSSFontFace> {
public:
static PassRefPtr<CSSFontFace> create(FontTraitsMask traitsMask, bool isLocalFallback = false) { return adoptRef(new CSSFontFace(traitsMask, isLocalFallback)); }
- ~CSSFontFace();
FontTraitsMask traitsMask() const { return m_traitsMask; }
@@ -60,7 +60,7 @@
bool isLocalFallback() const { return m_isLocalFallback; }
- void addSource(CSSFontFaceSource*);
+ void addSource(PassOwnPtr<CSSFontFaceSource>);
void fontLoaded(CSSFontFaceSource*);
@@ -96,7 +96,7 @@
FontTraitsMask m_traitsMask;
Vector<UnicodeRange> m_ranges;
HashSet<CSSSegmentedFontFace*> m_segmentedFontFaces;
- Vector<CSSFontFaceSource*> m_sources;
+ Vector<OwnPtr<CSSFontFaceSource> > m_sources;
CSSFontFaceSource* m_activeSource;
bool m_isLocalFallback;
};
Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (103675 => 103676)
--- trunk/Source/WebCore/css/CSSFontSelector.cpp 2011-12-26 04:02:21 UTC (rev 103675)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp 2011-12-26 04:46:34 UTC (rev 103676)
@@ -234,7 +234,7 @@
for (int i = 0; i < srcLength; i++) {
// An item in the list either specifies a string (local font name) or a URL (remote font to download).
CSSFontFaceSrcValue* item = static_cast<CSSFontFaceSrcValue*>(srcList->itemWithoutBoundsCheck(i));
- CSSFontFaceSource* source = 0;
+ OwnPtr<CSSFontFaceSource> source;
#if ENABLE(SVG_FONTS)
foundSVGFont = item->isSVGFontFaceSrc() || item->svgFontFaceElement();
@@ -246,7 +246,7 @@
ResourceRequest request(m_document->completeURL(item->resource()));
CachedFont* cachedFont = m_document->cachedResourceLoader()->requestFont(request);
if (cachedFont) {
- source = new CSSFontFaceSource(item->resource(), cachedFont);
+ source = adoptPtr(new CSSFontFaceSource(item->resource(), cachedFont));
#if ENABLE(SVG_FONTS)
if (foundSVGFont)
source->setHasExternalSVGFont(true);
@@ -254,7 +254,7 @@
}
}
} else {
- source = new CSSFontFaceSource(item->resource());
+ source = adoptPtr(new CSSFontFaceSource(item->resource()));
}
if (!fontFace)
@@ -264,7 +264,7 @@
#if ENABLE(SVG_FONTS)
source->setSVGFontFaceElement(item->svgFontFaceElement());
#endif
- fontFace->addSource(source);
+ fontFace->addSource(source.release());
}
}
@@ -332,7 +332,7 @@
for (unsigned i = 0; i < numLocallyInstalledFaces; ++i) {
RefPtr<CSSFontFace> locallyInstalledFontFace = CSSFontFace::create(static_cast<FontTraitsMask>(locallyInstalledFontsTraitsMasks[i]), true);
- locallyInstalledFontFace->addSource(new CSSFontFaceSource(familyName));
+ locallyInstalledFontFace->addSource(adoptPtr(new CSSFontFaceSource(familyName)));
ASSERT(locallyInstalledFontFace->isValid());
familyLocallyInstalledFaces->append(locallyInstalledFontFace);
}
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (103675 => 103676)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2011-12-26 04:02:21 UTC (rev 103675)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2011-12-26 04:46:34 UTC (rev 103676)
@@ -146,18 +146,19 @@
return nullAtom;
if (valueOrPropertyID < numCSSValueKeywords) {
- static AtomicString* cssValueKeywordStrings[numCSSValueKeywords];
- if (!cssValueKeywordStrings[valueOrPropertyID])
- cssValueKeywordStrings[valueOrPropertyID] = new AtomicString(getValueName(valueOrPropertyID));
- return *cssValueKeywordStrings[valueOrPropertyID];
+ static AtomicString* keywordStrings = new AtomicString[numCSSValueKeywords]; // Leaked intentionally.
+ AtomicString& keywordString = keywordStrings[valueOrPropertyID];
+ if (keywordString.isNull())
+ keywordString = getValueName(valueOrPropertyID);
+ return keywordString;
}
if (valueOrPropertyID >= firstCSSProperty && valueOrPropertyID < firstCSSProperty + numCSSProperties) {
- static AtomicString* cssPropertyStrings[numCSSProperties];
- int propertyIndex = valueOrPropertyID - firstCSSProperty;
- if (!cssPropertyStrings[propertyIndex])
- cssPropertyStrings[propertyIndex] = new AtomicString(getPropertyName(static_cast<CSSPropertyID>(valueOrPropertyID)));
- return *cssPropertyStrings[propertyIndex];
+ static AtomicString* propertyStrings = new AtomicString[numCSSProperties]; // Leaked intentionally.
+ AtomicString& propertyString = propertyStrings[valueOrPropertyID - firstCSSProperty];
+ if (propertyString.isNull())
+ propertyString = getPropertyName(static_cast<CSSPropertyID>(valueOrPropertyID));
+ return propertyString;
}
return nullAtom;
Modified: trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp (103675 => 103676)
--- trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp 2011-12-26 04:02:21 UTC (rev 103675)
+++ trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp 2011-12-26 04:46:34 UTC (rev 103676)
@@ -27,6 +27,7 @@
#include "CSSSegmentedFontFace.h"
#include "CSSFontFace.h"
+#include "CSSFontFaceSource.h"
#include "CSSFontSelector.h"
#include "Document.h"
#include "FontDescription.h"