Commit 3aa89278 authored by darin@apple.com's avatar darin@apple.com

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
parent 0cd074ea
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
......@@ -3662,7 +3662,7 @@ bool CSSParser::parseGradient(RefPtr<CSSValue>& gradient)
a = args->next();
}
gradient = result;
gradient = result.release();
return true;
}
......
......@@ -1294,7 +1294,7 @@ void CSSStyleSelector::cacheBorderAndBackground()
}
}
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 @@ RefPtr<CSSRuleList> CSSStyleSelector::styleRulesForElement(Element* e, bool auth
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;
......
......@@ -90,8 +90,8 @@ public:
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).
......
......@@ -3541,8 +3541,7 @@ void Document::shiftMarkers(Node *node, unsigned startOffset, int delta, Documen
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;
......
......@@ -35,27 +35,23 @@ SVGElementInstanceList::~SVGElementInstanceList()
{
}
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;
}
......
......@@ -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)
......
......@@ -240,7 +240,7 @@ static void freeXsltParamArray(const char** params)
}
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 @@ RefPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourceStr
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 @@ bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String
return success;
}
RefPtr<Document> XSLTProcessor::transformToDocument(Node* sourceNode)
PassRefPtr<Document> XSLTProcessor::transformToDocument(Node* sourceNode)
{
String resultMIMEType;
String resultString;
......@@ -417,7 +417,7 @@ RefPtr<Document> XSLTProcessor::transformToDocument(Node* sourceNode)
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;
......
/*
* 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 @@ class XSLTProcessor : public RefCounted<XSLTProcessor> {
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:
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;
};
......
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