Diff
Modified: trunk/Source/WebCore/ChangeLog (154022 => 154023)
--- trunk/Source/WebCore/ChangeLog 2013-08-13 21:12:21 UTC (rev 154022)
+++ trunk/Source/WebCore/ChangeLog 2013-08-13 21:42:16 UTC (rev 154023)
@@ -1,5 +1,41 @@
2013-08-13 Anders Carlsson <[email protected]>
+ 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 <[email protected]>
+
Stop using DEFINE_STATIC_LOCAL with RetainPtr
https://bugs.webkit.org/show_bug.cgi?id=119765
Modified: trunk/Source/WebCore/dom/ContextFeatures.cpp (154022 => 154023)
--- trunk/Source/WebCore/dom/ContextFeatures.cpp 2013-08-13 21:12:21 UTC (rev 154022)
+++ trunk/Source/WebCore/dom/ContextFeatures.cpp 2013-08-13 21:42:16 UTC (rev 154023)
@@ -46,8 +46,8 @@
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)
Modified: trunk/Source/WebCore/dom/DocumentMarker.cpp (154022 => 154023)
--- trunk/Source/WebCore/dom/DocumentMarker.cpp 2013-08-13 21:12:21 UTC (rev 154022)
+++ trunk/Source/WebCore/dom/DocumentMarker.cpp 2013-08-13 21:42:16 UTC (rev 154023)
@@ -84,8 +84,8 @@
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;
}
Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (154022 => 154023)
--- trunk/Source/WebCore/editing/EditingStyle.cpp 2013-08-13 21:12:21 UTC (rev 154022)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp 2013-08-13 21:42:16 UTC (rev 154023)
@@ -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 @@
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 @@
// 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()))
Modified: trunk/Source/WebCore/html/FTPDirectoryDocument.cpp (154022 => 154023)
--- trunk/Source/WebCore/html/FTPDirectoryDocument.cpp 2013-08-13 21:12:21 UTC (rev 154022)
+++ trunk/Source/WebCore/html/FTPDirectoryDocument.cpp 2013-08-13 21:42:16 UTC (rev 154023)
@@ -289,7 +289,7 @@
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.
Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (154022 => 154023)
--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp 2013-08-13 21:12:21 UTC (rev 154022)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp 2013-08-13 21:42:16 UTC (rev 154023)
@@ -372,11 +372,11 @@
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);
Modified: trunk/Source/WebCore/html/track/TextTrack.cpp (154022 => 154023)
--- trunk/Source/WebCore/html/track/TextTrack.cpp 2013-08-13 21:12:21 UTC (rev 154022)
+++ trunk/Source/WebCore/html/track/TextTrack.cpp 2013-08-13 21:42:16 UTC (rev 154023)
@@ -103,14 +103,14 @@
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)
Modified: trunk/Source/WebCore/loader/icon/IconDatabase.cpp (154022 => 154023)
--- trunk/Source/WebCore/loader/icon/IconDatabase.cpp 2013-08-13 21:12:21 UTC (rev 154022)
+++ trunk/Source/WebCore/loader/icon/IconDatabase.cpp 2013-08-13 21:42:16 UTC (rev 154023)
@@ -389,7 +389,7 @@
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
Modified: trunk/Source/WebCore/platform/graphics/Image.cpp (154022 => 154023)
--- trunk/Source/WebCore/platform/graphics/Image.cpp 2013-08-13 21:12:21 UTC (rev 154022)
+++ trunk/Source/WebCore/platform/graphics/Image.cpp 2013-08-13 21:42:16 UTC (rev 154023)
@@ -57,8 +57,8 @@
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)
Modified: trunk/Source/WebCore/platform/graphics/PlatformTextTrack.h (154022 => 154023)
--- trunk/Source/WebCore/platform/graphics/PlatformTextTrack.h 2013-08-13 21:12:21 UTC (rev 154022)
+++ trunk/Source/WebCore/platform/graphics/PlatformTextTrack.h 2013-08-13 21:42:16 UTC (rev 154023)
@@ -76,14 +76,14 @@
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:
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (154022 => 154023)
--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2013-08-13 21:12:21 UTC (rev 154022)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2013-08-13 21:42:16 UTC (rev 154023)
@@ -1786,8 +1786,8 @@
#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
Modified: trunk/Source/WebCore/testing/MockCDM.cpp (154022 => 154023)
--- trunk/Source/WebCore/testing/MockCDM.cpp 2013-08-13 21:12:21 UTC (rev 154022)
+++ trunk/Source/WebCore/testing/MockCDM.cpp 2013-08-13 21:42:16 UTC (rev 154023)
@@ -75,38 +75,26 @@
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()