Commit f1154b09 authored by andersca@apple.com's avatar andersca@apple.com

Stop using DEFINE_STATIC_LOCAL with RefPtr

https://bugs.webkit.org/show_bug.cgi?id=119769

Reviewed by Andreas Kling.

No need to waste heap memory allocating RefPtr, just store the raw pointers directly.

* dom/ContextFeatures.cpp:
(WebCore::ContextFeatures::defaultSwitch):
* dom/DocumentMarker.cpp:
(WebCore::DocumentMarkerTextMatch::instanceFor):
* editing/EditingStyle.cpp:
(WebCore::StyleChange::extractTextStyles):
* html/FTPDirectoryDocument.cpp:
(WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate):
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot):
* html/track/TextTrack.cpp:
(WebCore::TextTrack::captionMenuOffItem):
(WebCore::TextTrack::captionMenuAutomaticItem):
* loader/icon/IconDatabase.cpp:
(WebCore::loadDefaultIconRecord):
* platform/graphics/Image.cpp:
(WebCore::Image::nullImage):
* platform/graphics/PlatformTextTrack.h:
(WebCore::PlatformTextTrack::captionMenuOffItem):
(WebCore::PlatformTextTrack::captionMenuAutomaticItem):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::initialShapeInside):
* testing/MockCDM.cpp:
(WebCore::initDataPrefix):
(WebCore::keyPrefix):
(WebCore::keyRequest):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154023 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 75cfa4d4
2013-08-13 Anders Carlsson <andersca@apple.com>
Stop using DEFINE_STATIC_LOCAL with RefPtr
https://bugs.webkit.org/show_bug.cgi?id=119769
Reviewed by Andreas Kling.
No need to waste heap memory allocating RefPtr, just store the raw pointers directly.
* dom/ContextFeatures.cpp:
(WebCore::ContextFeatures::defaultSwitch):
* dom/DocumentMarker.cpp:
(WebCore::DocumentMarkerTextMatch::instanceFor):
* editing/EditingStyle.cpp:
(WebCore::StyleChange::extractTextStyles):
* html/FTPDirectoryDocument.cpp:
(WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate):
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot):
* html/track/TextTrack.cpp:
(WebCore::TextTrack::captionMenuOffItem):
(WebCore::TextTrack::captionMenuAutomaticItem):
* loader/icon/IconDatabase.cpp:
(WebCore::loadDefaultIconRecord):
* platform/graphics/Image.cpp:
(WebCore::Image::nullImage):
* platform/graphics/PlatformTextTrack.h:
(WebCore::PlatformTextTrack::captionMenuOffItem):
(WebCore::PlatformTextTrack::captionMenuAutomaticItem):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::initialShapeInside):
* testing/MockCDM.cpp:
(WebCore::initDataPrefix):
(WebCore::keyPrefix):
(WebCore::keyRequest):
2013-08-13 Anders Carlsson <andersca@apple.com>
Stop using DEFINE_STATIC_LOCAL with RetainPtr
......@@ -46,8 +46,8 @@ const char* ContextFeatures::supplementName()
ContextFeatures* ContextFeatures::defaultSwitch()
{
DEFINE_STATIC_LOCAL(RefPtr<ContextFeatures>, instance, (ContextFeatures::create(ContextFeaturesClient::empty())));
return instance.get();
static ContextFeatures* instance = ContextFeatures::create(ContextFeaturesClient::empty()).leakRef();
return instance;
}
bool ContextFeatures::dialogElementEnabled(Document* document)
......
......@@ -84,8 +84,8 @@ private:
PassRefPtr<DocumentMarkerTextMatch> DocumentMarkerTextMatch::instanceFor(bool match)
{
DEFINE_STATIC_LOCAL(RefPtr<DocumentMarkerTextMatch>, trueInstance, (adoptRef(new DocumentMarkerTextMatch(true))));
DEFINE_STATIC_LOCAL(RefPtr<DocumentMarkerTextMatch>, falseInstance, (adoptRef(new DocumentMarkerTextMatch(false))));
static DocumentMarkerTextMatch* trueInstance = adoptRef(new DocumentMarkerTextMatch(true)).leakRef();
static DocumentMarkerTextMatch* falseInstance = adoptRef(new DocumentMarkerTextMatch(false)).leakRef();
return match ? trueInstance : falseInstance;
}
......
......@@ -34,6 +34,7 @@
#include "CSSStyleRule.h"
#include "CSSValueKeywords.h"
#include "CSSValueList.h"
#include "CSSValuePool.h"
#include "Editor.h"
#include "Frame.h"
#include "FrameSelection.h"
......@@ -1062,8 +1063,8 @@ PassRefPtr<EditingStyle> EditingStyle::wrappingStyleForSerialization(Node* conte
static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueList* valueToMerge)
{
DEFINE_STATIC_LOCAL(const RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
DEFINE_STATIC_LOCAL(const RefPtr<CSSPrimitiveValue>, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
RefPtr<CSSPrimitiveValue> underline = cssValuePool().createIdentifierValue(CSSValueUnderline);
RefPtr<CSSPrimitiveValue> lineThrough = cssValuePool().createIdentifierValue(CSSValueLineThrough);
if (valueToMerge->hasValue(underline.get()) && !mergedValue->hasValue(underline.get()))
mergedValue->append(underline.get());
......@@ -1427,8 +1428,8 @@ void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
// Furthermore, text-decoration: none has been trimmed so that text-decoration property is always a CSSValueList.
RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyTextDecoration);
if (textDecoration && textDecoration->isValueList()) {
DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
RefPtr<CSSPrimitiveValue> underline = cssValuePool().createIdentifierValue(CSSValueUnderline);
RefPtr<CSSPrimitiveValue> lineThrough = cssValuePool().createIdentifierValue(CSSValueLineThrough);
RefPtr<CSSValueList> newTextDecoration = static_cast<CSSValueList*>(textDecoration.get())->copy();
if (newTextDecoration->removeAll(underline.get()))
......
......@@ -289,7 +289,7 @@ static inline PassRefPtr<SharedBuffer> createTemplateDocumentData(Settings* sett
bool FTPDirectoryDocumentParser::loadDocumentTemplate()
{
DEFINE_STATIC_LOCAL(RefPtr<SharedBuffer>, templateDocumentData, (createTemplateDocumentData(document()->settings())));
static SharedBuffer* templateDocumentData = createTemplateDocumentData(document()->settings()).leakRef();
// FIXME: Instead of storing the data, we'd rather actually parse the template data into the template Document once,
// store that document, then "copy" it whenever we get an FTP directory listing. There are complexities with this
// approach that make it worth putting this off.
......
......@@ -372,11 +372,11 @@ void HTMLPlugInImageElement::didAddUserAgentShadowRoot(ShadowRoot* root)
String mimeType = loadedMimeType();
DEFINE_STATIC_LOCAL(RefPtr<DOMWrapperWorld>, isolatedWorld, (DOMWrapperWorld::create(JSDOMWindow::commonVM())));
document()->ensurePlugInsInjectedScript(isolatedWorld.get());
static DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::create(JSDOMWindow::commonVM()).leakRef();
document()->ensurePlugInsInjectedScript(isolatedWorld);
ScriptController* scriptController = page->mainFrame()->script();
JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController->globalObject(isolatedWorld.get()));
JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController->globalObject(isolatedWorld));
JSC::ExecState* exec = globalObject->globalExec();
JSC::JSLockHolder lock(exec);
......
......@@ -103,14 +103,14 @@ const AtomicString& TextTrack::showingKeyword()
TextTrack* TextTrack::captionMenuOffItem()
{
DEFINE_STATIC_LOCAL(RefPtr<TextTrack>, off, (TextTrack::create(0, 0, "off menu item", "", "")));
return off.get();
static TextTrack* off = TextTrack::create(0, 0, "off menu item", "", "").leakRef();
return off;
}
TextTrack* TextTrack::captionMenuAutomaticItem()
{
DEFINE_STATIC_LOCAL(RefPtr<TextTrack>, automatic, (TextTrack::create(0, 0, "automatic menu item", "", "")));
return automatic.get();
static TextTrack* automatic = TextTrack::create(0, 0, "automatic menu item", "", "").leakRef();
return automatic;
}
TextTrack::TextTrack(ScriptExecutionContext* context, TextTrackClient* client, const AtomicString& kind, const AtomicString& label, const AtomicString& language, TextTrackType type)
......
......@@ -389,7 +389,7 @@ static inline void loadDefaultIconRecord(IconRecord* defaultIconRecord)
0x00, 0x00, 0x01, 0x52, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x0A,
0xFC, 0x80, 0x00, 0x00, 0x27, 0x10, 0x00, 0x0A, 0xFC, 0x80, 0x00, 0x00, 0x27, 0x10 };
DEFINE_STATIC_LOCAL(RefPtr<SharedBuffer>, defaultIconBuffer, (SharedBuffer::create(defaultIconData, sizeof(defaultIconData))));
static SharedBuffer* defaultIconBuffer = SharedBuffer::create(defaultIconData, sizeof(defaultIconData)).leakRef();
defaultIconRecord->setImageData(defaultIconBuffer);
}
#endif
......
......@@ -57,8 +57,8 @@ Image::~Image()
Image* Image::nullImage()
{
ASSERT(isMainThread());
DEFINE_STATIC_LOCAL(RefPtr<Image>, nullImage, (BitmapImage::create()));;
return nullImage.get();
static Image* nullImage = BitmapImage::create().leakRef();
return nullImage;
}
bool Image::supportsType(const String& type)
......
......@@ -76,14 +76,14 @@ public:
static PlatformTextTrack* captionMenuOffItem()
{
DEFINE_STATIC_LOCAL(RefPtr<PlatformTextTrack>, off, (PlatformTextTrack::create(0, "off menu item", "", Subtitle, InBand, 0)));
return off.get();
static PlatformTextTrack* off = PlatformTextTrack::create(0, "off menu item", "", Subtitle, InBand, 0).leakRef();
return off;
}
static PlatformTextTrack* captionMenuAutomaticItem()
{
DEFINE_STATIC_LOCAL(RefPtr<PlatformTextTrack>, automatic, (PlatformTextTrack::create(0, "automatic menu item", "", Subtitle, InBand, 0)));
return automatic.get();
static PlatformTextTrack *automatic = PlatformTextTrack::create(0, "automatic menu item", "", Subtitle, InBand, 0).leakRef();
return automatic;
}
protected:
......
......@@ -1786,8 +1786,8 @@ void RenderStyle::setBorderImageOutset(LengthBox outset)
#if ENABLE(CSS_SHAPES)
ShapeValue* RenderStyle::initialShapeInside()
{
DEFINE_STATIC_LOCAL(RefPtr<ShapeValue>, sOutsideValue, (ShapeValue::createOutsideValue()));
return sOutsideValue.get();
static ShapeValue* outsideValue = ShapeValue::createOutsideValue().leakRef();
return outsideValue;
}
#endif
......
......@@ -75,38 +75,26 @@ PassOwnPtr<CDMSession> MockCDM::createSession()
static Uint8Array* initDataPrefix()
{
static const unsigned char prefixData[] = {'m', 'o', 'c', 'k'};
DEFINE_STATIC_LOCAL(RefPtr<Uint8Array>, prefix, ());
static bool initialized = false;
if (!initialized) {
initialized = true;
prefix = Uint8Array::create(prefixData, sizeof(prefixData) / sizeof(prefixData[0]));
}
return prefix.get();
const unsigned char prefixData[] = { 'm', 'o', 'c', 'k' };
static Uint8Array* prefix = Uint8Array::create(prefixData, WTF_ARRAY_LENGTH(prefixData)).leakRef();
return prefix;
}
static Uint8Array* keyPrefix()
{
static const unsigned char prefixData[] = {'k', 'e', 'y'};
DEFINE_STATIC_LOCAL(RefPtr<JSC::Uint8Array>, prefix, ());
static bool initialized = false;
if (!initialized) {
initialized = true;
prefix = Uint8Array::create(prefixData, sizeof(prefixData) / sizeof(prefixData[0]));
}
return prefix.get();
static Uint8Array* prefix = Uint8Array::create(prefixData, WTF_ARRAY_LENGTH(prefixData)).leakRef();
return prefix;
}
static Uint8Array* keyRequest()
{
static const unsigned char requestData[] = {'r', 'e', 'q', 'u', 'e', 's', 't'};
DEFINE_STATIC_LOCAL(RefPtr<JSC::Uint8Array>, request, ());
static bool initialized = false;
if (!initialized) {
initialized = true;
request = Uint8Array::create(requestData, sizeof(requestData) / sizeof(requestData[0]));
}
return request.get();
static Uint8Array* request = Uint8Array::create(requestData, WTF_ARRAY_LENGTH(requestData)).leakRef();
return request;
}
static String generateSessionId()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment