2008-06-14 Darin Adler <darin@apple.com>
Reviewed by Sam.
- https://bugs.webkit.org/show_bug.cgi?id=19545
use PassRefPtr, not RefPtr, for return values
* css/CSSParser.cpp:
(WebCore::CSSParser::parseGradient): Call release() when assigning result to avoid
a little bit of refcount churn.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::styleRulesForElement): Changed return value to PassRefPtr.
(WebCore::CSSStyleSelector::pseudoStyleRulesForElement): Ditto.
* css/CSSStyleSelector.h: Ditto.
* svg/SVGElementInstanceList.cpp:
(WebCore::SVGElementInstanceList::length): Tweaked formatting.
(WebCore::SVGElementInstanceList::item): Changed return value to raw pointer.
* svg/SVGElementInstanceList.h: Ditto.
* xml/XSLTProcessor.cpp:
(WebCore::XSLTProcessor::createDocumentFromSource): Changed return value to PassRefPtr.
(WebCore::XSLTProcessor::transformToDocument): Ditto.
(WebCore::XSLTProcessor::transformToFragment): Ditto.
* xml/XSLTProcessor.h: Ditto.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34551 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c043e89..8bf3aa8 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,5 +1,32 @@
2008-06-14 Darin Adler <darin@apple.com>
+ Reviewed by Sam.
+
+ - https://bugs.webkit.org/show_bug.cgi?id=19545
+ use PassRefPtr, not RefPtr, for return values
+
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseGradient): Call release() when assigning result to avoid
+ a little bit of refcount churn.
+
+ * css/CSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::styleRulesForElement): Changed return value to PassRefPtr.
+ (WebCore::CSSStyleSelector::pseudoStyleRulesForElement): Ditto.
+ * css/CSSStyleSelector.h: Ditto.
+
+ * svg/SVGElementInstanceList.cpp:
+ (WebCore::SVGElementInstanceList::length): Tweaked formatting.
+ (WebCore::SVGElementInstanceList::item): Changed return value to raw pointer.
+ * svg/SVGElementInstanceList.h: Ditto.
+
+ * xml/XSLTProcessor.cpp:
+ (WebCore::XSLTProcessor::createDocumentFromSource): Changed return value to PassRefPtr.
+ (WebCore::XSLTProcessor::transformToDocument): Ditto.
+ (WebCore::XSLTProcessor::transformToFragment): Ditto.
+ * xml/XSLTProcessor.h: Ditto.
+
+2008-06-14 Darin Adler <darin@apple.com>
+
- try to fix the gtk build
* platform/gtk/DragDataGtk.cpp:
diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp
index 8ac722f..291fc80 100644
--- a/WebCore/css/CSSParser.cpp
+++ b/WebCore/css/CSSParser.cpp
@@ -3662,7 +3662,7 @@
a = args->next();
}
- gradient = result;
+ gradient = result.release();
return true;
}
diff --git a/WebCore/css/CSSStyleSelector.cpp b/WebCore/css/CSSStyleSelector.cpp
index 5469e21..a1d255d 100644
--- a/WebCore/css/CSSStyleSelector.cpp
+++ b/WebCore/css/CSSStyleSelector.cpp
@@ -1294,7 +1294,7 @@
}
}
-RefPtr<CSSRuleList> CSSStyleSelector::styleRulesForElement(Element* e, bool authorOnly)
+PassRefPtr<CSSRuleList> CSSStyleSelector::styleRulesForElement(Element* e, bool authorOnly)
{
if (!e || !e->document()->haveStylesheetsLoaded())
return 0;
@@ -1327,7 +1327,7 @@
return m_ruleList.release();
}
-RefPtr<CSSRuleList> CSSStyleSelector::pseudoStyleRulesForElement(Element*, const String& pseudoStyle, bool authorOnly)
+PassRefPtr<CSSRuleList> CSSStyleSelector::pseudoStyleRulesForElement(Element*, const String& pseudoStyle, bool authorOnly)
{
// FIXME: Implement this.
return 0;
diff --git a/WebCore/css/CSSStyleSelector.h b/WebCore/css/CSSStyleSelector.h
index d92ac7d..7de53a6 100644
--- a/WebCore/css/CSSStyleSelector.h
+++ b/WebCore/css/CSSStyleSelector.h
@@ -90,8 +90,8 @@
public:
// These methods will give back the set of rules that matched for a given element (or a pseudo-element).
- RefPtr<CSSRuleList> styleRulesForElement(Element*, bool authorOnly);
- RefPtr<CSSRuleList> pseudoStyleRulesForElement(Element*, const String& pseudoStyle, bool authorOnly);
+ PassRefPtr<CSSRuleList> styleRulesForElement(Element*, bool authorOnly);
+ PassRefPtr<CSSRuleList> pseudoStyleRulesForElement(Element*, const String& pseudoStyle, bool authorOnly);
// Given a CSS keyword in the range (xx-small to -webkit-xxx-large), this function will return
// the correct font size scaled relative to the user's default (medium).
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 19a1bd2..db36f83 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -3541,8 +3541,7 @@
void Document::applyXSLTransform(ProcessingInstruction* pi)
{
RefPtr<XSLTProcessor> processor = XSLTProcessor::create();
- processor->setXSLStylesheet(static_cast<XSLStyleSheet*>(pi->sheet()));
-
+ processor->setXSLStyleSheet(static_cast<XSLStyleSheet*>(pi->sheet()));
String resultMIMEType;
String newSource;
String resultEncoding;
diff --git a/WebCore/svg/SVGElementInstanceList.cpp b/WebCore/svg/SVGElementInstanceList.cpp
index 3942599..f039d44 100644
--- a/WebCore/svg/SVGElementInstanceList.cpp
+++ b/WebCore/svg/SVGElementInstanceList.cpp
@@ -35,27 +35,23 @@
{
}
-unsigned int SVGElementInstanceList::length() const
+unsigned SVGElementInstanceList::length() const
{
- // NOTE: We could use the same caching facilities, "ChildNodeList" uses.
+ // NOTE: We could use the same caching facilities, like the ones "ChildNodeList" uses.
unsigned length = 0;
- SVGElementInstance* instance;
- for (instance = m_rootInstance->firstChild(); instance; instance = instance->nextSibling())
+ for (SVGElementInstance* instance = m_rootInstance->firstChild(); instance; instance = instance->nextSibling())
length++;
-
return length;
}
-RefPtr<SVGElementInstance> SVGElementInstanceList::item(unsigned int index)
+SVGElementInstance* SVGElementInstanceList::item(unsigned index)
{
- unsigned int pos = 0;
+ unsigned pos = 0;
SVGElementInstance* instance = m_rootInstance->firstChild();
-
while (instance && pos < index) {
instance = instance->nextSibling();
pos++;
}
-
return instance;
}
diff --git a/WebCore/svg/SVGElementInstanceList.h b/WebCore/svg/SVGElementInstanceList.h
index 6fb9412..ef4c73c 100644
--- a/WebCore/svg/SVGElementInstanceList.h
+++ b/WebCore/svg/SVGElementInstanceList.h
@@ -28,18 +28,20 @@
#include "SVGElementInstance.h"
namespace WebCore {
+
class SVGElementInstanceList : public RefCounted<SVGElementInstanceList> {
public:
static PassRefPtr<SVGElementInstanceList> create(PassRefPtr<SVGElementInstance> rootInstance) { return adoptRef(new SVGElementInstanceList(rootInstance)); }
virtual ~SVGElementInstanceList();
- unsigned int length() const;
- RefPtr<SVGElementInstance> item(unsigned int index);
+ unsigned length() const;
+ SVGElementInstance* item(unsigned index);
private:
SVGElementInstanceList(PassRefPtr<SVGElementInstance> rootInstance);
RefPtr<SVGElementInstance> m_rootInstance;
};
+
} // namespace WebCore
#endif // ENABLE(SVG)
diff --git a/WebCore/xml/XSLTProcessor.cpp b/WebCore/xml/XSLTProcessor.cpp
index 7ec8608..1158b87 100644
--- a/WebCore/xml/XSLTProcessor.cpp
+++ b/WebCore/xml/XSLTProcessor.cpp
@@ -240,7 +240,7 @@
}
-RefPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString,
+PassRefPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString,
const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame)
{
RefPtr<Document> ownerDocument = sourceNode->document();
@@ -277,7 +277,7 @@
result->finishParsing();
result->close();
- return result;
+ return result.release();
}
static inline RefPtr<DocumentFragment> createFragmentFromSource(const String& sourceString, const String& sourceMIMEType, Node* sourceNode, Document* outputDoc)
@@ -407,7 +407,7 @@
return success;
}
-RefPtr<Document> XSLTProcessor::transformToDocument(Node* sourceNode)
+PassRefPtr<Document> XSLTProcessor::transformToDocument(Node* sourceNode)
{
String resultMIMEType;
String resultString;
@@ -417,7 +417,7 @@
return createDocumentFromSource(resultString, resultEncoding, resultMIMEType, sourceNode, 0);
}
-RefPtr<DocumentFragment> XSLTProcessor::transformToFragment(Node* sourceNode, Document* outputDoc)
+PassRefPtr<DocumentFragment> XSLTProcessor::transformToFragment(Node* sourceNode, Document* outputDoc)
{
String resultMIMEType;
String resultString;
diff --git a/WebCore/xml/XSLTProcessor.h b/WebCore/xml/XSLTProcessor.h
index 03e73f4..9ee2aad 100644
--- a/WebCore/xml/XSLTProcessor.h
+++ b/WebCore/xml/XSLTProcessor.h
@@ -1,7 +1,7 @@
/*
* This file is part of the XSL implementation.
*
- * Copyright (C) 2004, 2007 Apple, Inc.
+ * Copyright (C) 2004, 2007, 2008 Apple, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -42,21 +42,21 @@
public:
static PassRefPtr<XSLTProcessor> create() { return adoptRef(new XSLTProcessor); }
- void setXSLStylesheet(XSLStyleSheet* styleSheet) { m_stylesheet = styleSheet; }
+ void setXSLStyleSheet(PassRefPtr<XSLStyleSheet> styleSheet) { m_stylesheet = styleSheet; }
bool transformToString(Node* source, String& resultMIMEType, String& resultString, String& resultEncoding);
- RefPtr<Document> createDocumentFromSource(const String& source, const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame);
+ PassRefPtr<Document> createDocumentFromSource(const String& source, const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame);
// DOM methods
- void importStylesheet(Node* style) { m_stylesheetRootNode = style; }
- RefPtr<DocumentFragment> transformToFragment(Node* source, Document* ouputDoc);
- RefPtr<Document> transformToDocument(Node* source);
+ void importStylesheet(PassRefPtr<Node> style) { m_stylesheetRootNode = style; }
+ PassRefPtr<DocumentFragment> transformToFragment(Node* source, Document* ouputDoc);
+ PassRefPtr<Document> transformToDocument(Node* source);
void setParameter(const String& namespaceURI, const String& localName, const String& value);
String getParameter(const String& namespaceURI, const String& localName) const;
void removeParameter(const String& namespaceURI, const String& localName);
void clearParameters() { m_parameters.clear(); }
- void reset() { m_stylesheet = NULL; m_stylesheetRootNode = NULL; m_parameters.clear(); }
+ void reset() { m_stylesheet.clear(); m_stylesheetRootNode.clear(); m_parameters.clear(); }
static void parseErrorFunc(void* userData, xmlError*);
static void genericErrorFunc(void* userData, const char* msg, ...);
@@ -64,18 +64,14 @@
public:
// Only for libXSLT callbacks
XSLStyleSheet* xslStylesheet() const { return m_stylesheet.get(); }
-
+
typedef HashMap<String, String> ParameterMap;
private:
XSLTProcessor() { }
- // Convert a libxml doc ptr to a KHTML DOM Document
- RefPtr<Document> documentFromXMLDocPtr(xmlDocPtr resultDoc, xsltStylesheetPtr sheet, Document* ownerDocument, bool sourceIsDocument);
-
RefPtr<XSLStyleSheet> m_stylesheet;
RefPtr<Node> m_stylesheetRootNode;
-
ParameterMap m_parameters;
};