diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index ac19599ab8f8e0766193099724fbe0c060380129..5feeb6d761ef19c046354b7412afe3726aafc38f 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,260 @@ +2008-06-07 Darin Adler + + Reviewed by Mitz. + + - work on https://bugs.webkit.org/show_bug.cgi?id=17257 + start ref counts at 1 instead of 0 for speed + + * bindings/js/JSCanvasRenderingContext2DCustom.cpp: + (WebCore::toHTMLCanvasStyle): + * bindings/js/JSDOMWindowBase.cpp: + (WebCore::JSDOMWindowBase::findOrCreateJSEventListener): + (WebCore::JSDOMWindowBase::findOrCreateJSUnprotectedEventListener): + * bindings/js/JSNodeFilterCondition.h: + (WebCore::JSNodeFilterCondition::create): + * bindings/js/JSNodeFilterCustom.cpp: + (WebCore::toNodeFilter): + * bindings/js/JSSVGLazyEventListener.h: + (WebCore::JSSVGLazyEventListener::create): + * bindings/js/JSSVGMatrixCustom.cpp: + (WebCore::JSSVGMatrix::multiply): + (WebCore::JSSVGMatrix::inverse): + (WebCore::JSSVGMatrix::translate): + (WebCore::JSSVGMatrix::scale): + (WebCore::JSSVGMatrix::scaleNonUniform): + (WebCore::JSSVGMatrix::rotate): + (WebCore::JSSVGMatrix::rotateFromVector): + (WebCore::JSSVGMatrix::flipX): + (WebCore::JSSVGMatrix::flipY): + (WebCore::JSSVGMatrix::skewX): + (WebCore::JSSVGMatrix::skewY): + * bindings/js/JSSVGPODTypeWrapper.h: + (WebCore::JSSVGPODTypeWrapperCreatorReadWrite::create): + (WebCore::JSSVGPODTypeWrapperCreatorReadWrite::JSSVGPODTypeWrapperCreatorReadWrite): + (WebCore::JSSVGPODTypeWrapperCreatorReadOnly::create): + (WebCore::JSSVGPODTypeWrapperCreatorReadOnly::JSSVGPODTypeWrapperCreatorReadOnly): + (WebCore::JSSVGPODTypeWrapperCreatorForList::create): + (WebCore::JSSVGPODTypeWrapperCreatorForList::JSSVGPODTypeWrapperCreatorForList): + (WebCore::JSSVGPODTypeWrapperCache::lookupOrCreateWrapper): + (WebCore::JSSVGPODTypeWrapperCache::forgetWrapper): + * bindings/js/JSSVGPointListCustom.cpp: + (WebCore::commonExit): + (WebCore::commonExitReadOnly): + (WebCore::JSSVGPointList::initialize): + (WebCore::JSSVGPointList::getItem): + (WebCore::JSSVGPointList::insertItemBefore): + (WebCore::JSSVGPointList::replaceItem): + (WebCore::JSSVGPointList::removeItem): + (WebCore::JSSVGPointList::appendItem): + * bindings/js/JSSVGTransformListCustom.cpp: + (WebCore::JSSVGTransformList::initialize): + (WebCore::JSSVGTransformList::getItem): + (WebCore::JSSVGTransformList::insertItemBefore): + (WebCore::JSSVGTransformList::replaceItem): + (WebCore::JSSVGTransformList::removeItem): + (WebCore::JSSVGTransformList::appendItem): + * bindings/js/kjs_binding.cpp: + (WebCore::setDOMException): + * bindings/js/kjs_events.h: + (WebCore::JSUnprotectedEventListener::create): + (WebCore::JSEventListener::create): + (WebCore::JSLazyEventListener::create): + * bindings/js/kjs_proxy.cpp: + (WebCore::KJSProxy::createHTMLEventHandler): + (WebCore::KJSProxy::createSVGEventHandler): + * bindings/objc/DOM.mm: + (WebCore::ObjCNodeFilterCondition::create): + (WebCore::ObjCNodeFilterCondition::ObjCNodeFilterCondition): + (WebCore::ObjCNodeFilterCondition::acceptNode): + (-[DOMDocument createNodeIterator:whatToShow:filter:expandEntityReferences:]): + (-[DOMDocument createTreeWalker:whatToShow:filter:expandEntityReferences:]): + * bindings/scripts/CodeGeneratorJS.pm: + * css/CSSComputedStyleDeclaration.cpp: + (WebCore::valueForNinePieceImage): + (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): + * css/CSSFontFace.h: + (WebCore::CSSFontFace::create): + (WebCore::CSSFontFace::CSSFontFace): + * css/CSSFontSelector.cpp: + (WebCore::CSSFontSelector::addFontFaceRule): + * css/CSSParser.cpp: + (WebCore::CSSParser::parseDashboardRegions): + (WebCore::CSSParser::parseCounterContent): + (WebCore::CSSParser::parseShape): + (WebCore::BorderImageParseContext::commitBorderImage): + * css/CSSSegmentedFontFace.cpp: + (WebCore::CSSSegmentedFontFace::CSSSegmentedFontFace): + * css/CSSSegmentedFontFace.h: + (WebCore::CSSSegmentedFontFace::create): + * css/Counter.h: + (WebCore::Counter::create): + (WebCore::Counter::Counter): + * css/DashboardRegion.h: + (WebCore::DashboardRegion::create): + (WebCore::DashboardRegion::DashboardRegion): + * css/Rect.h: + (WebCore::Rect::create): + (WebCore::Rect::Rect): + * dom/ChildNodeList.h: + (WebCore::ChildNodeList::create): + * dom/ClassNodeList.h: + (WebCore::ClassNodeList::create): + * dom/Clipboard.h: + * dom/DOMCoreException.h: + (WebCore::DOMCoreException::create): + * dom/DOMImplementation.cpp: + (WebCore::DOMImplementation::instance): + * dom/DOMImplementation.h: + (WebCore::DOMImplementation::DOMImplementation): + * dom/Document.cpp: + (WebCore::Document::addWindowEventListener): + (WebCore::Document::removeWindowEventListener): + (WebCore::Document::setDecoder): + (WebCore::Document::images): + (WebCore::Document::applets): + (WebCore::Document::embeds): + (WebCore::Document::plugins): + (WebCore::Document::objects): + (WebCore::Document::scripts): + (WebCore::Document::links): + (WebCore::Document::forms): + (WebCore::Document::anchors): + (WebCore::Document::all): + (WebCore::Document::windowNamedItems): + (WebCore::Document::documentNamedItems): + * dom/Document.h: + * dom/DynamicNodeList.h: + * dom/EventException.h: + (WebCore::EventException::create): + (WebCore::EventException::EventException): + * dom/EventListener.h: + * dom/EventTarget.cpp: + (WebCore::EventTarget::addEventListener): + (WebCore::EventTarget::removeEventListener): + * dom/ExceptionBase.cpp: + (WebCore::ExceptionBase::ExceptionBase): + * dom/ExceptionBase.h: + * dom/NameNodeList.h: + (WebCore::NameNodeList::create): + * dom/Node.cpp: + (WebCore::Node::childNodes): + (WebCore::Node::getElementsByTagNameNS): + (WebCore::Node::getElementsByName): + (WebCore::Node::getElementsByClassName): + (WebCore::Node::querySelectorAll): + * dom/NodeFilterCondition.h: + * dom/NodeList.h: + * dom/RangeException.h: + (WebCore::RangeException::create): + (WebCore::RangeException::RangeException): + * dom/RegisteredEventListener.h: + (WebCore::RegisteredEventListener::create): + * dom/SelectorNodeList.cpp: + (WebCore::createSelectorNodeList): + * dom/SelectorNodeList.h: + * dom/StaticNodeList.cpp: + (WebCore::StaticNodeList::StaticNodeList): + * dom/StaticNodeList.h: + (WebCore::StaticNodeList::adopt): + * dom/TagNodeList.h: + (WebCore::TagNodeList::create): + * history/HistoryItem.cpp: + (WebCore::defaultNotifyHistoryItemChanged): + (WebCore::HistoryItem::HistoryItem): + (WebCore::HistoryItem::copy): + * history/HistoryItem.h: + (WebCore::HistoryItem::create): + * html/CanvasGradient.h: + * html/CanvasPattern.cpp: + (WebCore::CanvasPattern::CanvasPattern): + * html/CanvasPattern.h: + (WebCore::CanvasPattern::create): + * html/CanvasRenderingContext2D.cpp: + (WebCore::CanvasRenderingContext2D::State::State): + (WebCore::CanvasRenderingContext2D::setStrokeColor): + (WebCore::CanvasRenderingContext2D::setFillColor): + (WebCore::CanvasRenderingContext2D::createPattern): + * html/CanvasStyle.cpp: + (WebCore::CanvasStyle::CanvasStyle): + * html/CanvasStyle.h: + (WebCore::CanvasStyle::create): + * html/HTMLCollection.cpp: + (WebCore::HTMLCollection::HTMLCollection): + (WebCore::HTMLCollection::create): + * html/HTMLCollection.h: + * html/HTMLElement.cpp: + (WebCore::HTMLElement::children): + * html/HTMLFormCollection.cpp: + (WebCore::HTMLFormCollection::create): + * html/HTMLFormCollection.h: + * html/HTMLFormElement.cpp: + (WebCore::HTMLFormElement::elements): + * html/HTMLMapElement.cpp: + (WebCore::HTMLMapElement::areas): + * html/HTMLMediaElement.cpp: + (WebCore::HTMLMediaElement::load): + (WebCore::HTMLMediaElement::mediaPlayerNetworkStateChanged): + (WebCore::HTMLMediaElement::willSaveToCache): + * html/HTMLNameCollection.h: + (WebCore::HTMLNameCollection::create): + * html/HTMLOptionsCollection.cpp: + (WebCore::HTMLOptionsCollection::create): + * html/HTMLOptionsCollection.h: + * html/HTMLSelectElement.cpp: + (WebCore::HTMLSelectElement::options): + * html/HTMLTableElement.cpp: + (WebCore::HTMLTableElement::rows): + (WebCore::HTMLTableElement::tBodies): + * html/HTMLTableRowElement.cpp: + (WebCore::HTMLTableRowElement::cells): + * html/HTMLTableRowsCollection.cpp: + (WebCore::HTMLTableRowsCollection::HTMLTableRowsCollection): + (WebCore::HTMLTableRowsCollection::create): + * html/HTMLTableRowsCollection.h: + * html/HTMLTableSectionElement.cpp: + (WebCore::HTMLTableSectionElement::rows): + * html/MediaError.h: + (WebCore::MediaError::create): + (WebCore::MediaError::MediaError): + * loader/CachedCSSStyleSheet.cpp: + (WebCore::CachedCSSStyleSheet::CachedCSSStyleSheet): + * loader/CachedFont.cpp: + (WebCore::CachedFont::ensureSVGFontData): + * loader/CachedXSLStyleSheet.cpp: + (WebCore::CachedXSLStyleSheet::CachedXSLStyleSheet): + * loader/FrameLoader.cpp: + (WebCore::FrameLoader::write): + (WebCore::FrameLoader::createHistoryItem): + * loader/ImageDocument.cpp: + (WebCore::ImageEventListener::create): + (WebCore::ImageEventListener::ImageEventListener): + (WebCore::ImageDocument::createDocumentStructure): + * loader/TextResourceDecoder.h: + (WebCore::TextResourceDecoder::create): + * page/Page.cpp: + (WebCore::Page::userStyleSheet): + * svg/SVGException.h: + (WebCore::SVGException::create): + (WebCore::SVGException::SVGException): + * svg/animation/SVGSMILElement.cpp: + (WebCore::ConditionEventListener::create): + (WebCore::ConditionEventListener::ConditionEventListener): + (WebCore::SVGSMILElement::connectConditions): + * xml/XMLHttpRequest.cpp: + (WebCore::XMLHttpRequest::didReceiveData): + * xml/XMLHttpRequestException.h: + (WebCore::XMLHttpRequestException::create): + (WebCore::XMLHttpRequestException::XMLHttpRequestException): + * xml/XPathException.h: + (WebCore::XPathException::create): + (WebCore::XPathException::XPathException): + * xml/XPathResult.cpp: + (WebCore::InvalidatingEventListener::create): + (WebCore::InvalidatingEventListener::InvalidatingEventListener): + (WebCore::XPathResult::XPathResult): + * xml/XSLTProcessor.cpp: + (WebCore::XSLTProcessor::createDocumentFromSource): + 2008-06-07 Christian Dywan Reviewed by Alp Toker. diff --git a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp index e952302f757f35d7215eb8fb2c99429ac1cfe748..66ced7da4a8ab17c8e6a43d1cbe321fbd4261481 100644 --- a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp +++ b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp @@ -52,14 +52,14 @@ static JSValue* toJS(ExecState* exec, CanvasStyle* style) static PassRefPtr toHTMLCanvasStyle(ExecState* exec, JSValue* value) { if (value->isString()) - return new CanvasStyle(value->toString(exec)); + return CanvasStyle::create(value->toString(exec)); if (!value->isObject()) return 0; JSObject* object = static_cast(value); if (object->inherits(&JSCanvasGradient::s_info)) - return new CanvasStyle(static_cast(object)->impl()); + return CanvasStyle::create(static_cast(object)->impl()); if (object->inherits(&JSCanvasPattern::s_info)) - return new CanvasStyle(static_cast(object)->impl()); + return CanvasStyle::create(static_cast(object)->impl()); return 0; } diff --git a/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp b/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp index b01a4119a37dbc28378b19f53daa3226e8765e07..f1c3cb81a72621e111fd46507b7eb6270a8fb8a2 100644 --- a/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp +++ b/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp @@ -73,10 +73,10 @@ JSValue* JSDOMApplicationCache::addEventListener(ExecState* exec, const List& ar Frame* frame = impl()->frame(); if (!frame) return jsUndefined(); - JSUnprotectedEventListener* listener = toJSDOMWindow(frame)->findOrCreateJSUnprotectedEventListener(args[1], true); + RefPtr listener = toJSDOMWindow(frame)->findOrCreateJSUnprotectedEventListener(args[1], true); if (!listener) return jsUndefined(); - impl()->addEventListener(args[0]->toString(exec), listener, args[2]->toBoolean(exec)); + impl()->addEventListener(args[0]->toString(exec), listener.release(), args[2]->toBoolean(exec)); return jsUndefined(); } @@ -85,7 +85,7 @@ JSValue* JSDOMApplicationCache::removeEventListener(ExecState* exec, const List& Frame* frame = impl()->frame(); if (!frame) return jsUndefined(); - JSUnprotectedEventListener* listener = toJSDOMWindow(frame)->findOrCreateJSUnprotectedEventListener(args[1], true); + JSUnprotectedEventListener* listener = toJSDOMWindow(frame)->findJSUnprotectedEventListener(args[1], true); if (!listener) return jsUndefined(); impl()->removeEventListener(args[0]->toString(exec), listener, args[2]->toBoolean(exec)); diff --git a/WebCore/bindings/js/JSDOMWindowBase.cpp b/WebCore/bindings/js/JSDOMWindowBase.cpp index fb40c2537947774fc2047e02c47bb16b9c50d572..5bfbe3da1709aad34d1d1122003740391d8e1d06 100644 --- a/WebCore/bindings/js/JSDOMWindowBase.cpp +++ b/WebCore/bindings/js/JSDOMWindowBase.cpp @@ -817,7 +817,7 @@ JSEventListener* JSDOMWindowBase::findJSEventListener(JSValue* val, bool html) return listeners.get(object); } -JSEventListener* JSDOMWindowBase::findOrCreateJSEventListener(JSValue* val, bool html) +PassRefPtr JSDOMWindowBase::findOrCreateJSEventListener(JSValue* val, bool html) { JSEventListener* listener = findJSEventListener(val, html); if (listener) @@ -828,7 +828,7 @@ JSEventListener* JSDOMWindowBase::findOrCreateJSEventListener(JSValue* val, bool JSObject* object = static_cast(val); // Note that the JSEventListener constructor adds it to our jsEventListeners list - return new JSEventListener(object, static_cast(this), html); + return JSEventListener::create(object, static_cast(this), html).get(); } JSUnprotectedEventListener* JSDOMWindowBase::findJSUnprotectedEventListener(JSValue* val, bool html) @@ -840,7 +840,7 @@ JSUnprotectedEventListener* JSDOMWindowBase::findJSUnprotectedEventListener(JSVa return listeners.get(object); } -JSUnprotectedEventListener* JSDOMWindowBase::findOrCreateJSUnprotectedEventListener(JSValue* val, bool html) +PassRefPtr JSDOMWindowBase::findOrCreateJSUnprotectedEventListener(JSValue* val, bool html) { JSUnprotectedEventListener* listener = findJSUnprotectedEventListener(val, html); if (listener) @@ -850,7 +850,7 @@ JSUnprotectedEventListener* JSDOMWindowBase::findOrCreateJSUnprotectedEventListe JSObject* object = static_cast(val); // The JSUnprotectedEventListener constructor adds it to our jsUnprotectedEventListeners map. - return new JSUnprotectedEventListener(object, static_cast(this), html); + return JSUnprotectedEventListener::create(object, static_cast(this), html).get(); } void JSDOMWindowBase::clearHelperObjectProperties() @@ -1098,9 +1098,9 @@ JSValue* windowProtoFuncAddEventListener(ExecState* exec, JSObject* thisObj, con if (!frame) return jsUndefined(); - if (JSEventListener* listener = window->findOrCreateJSEventListener(args[1])) { + if (RefPtr listener = window->findOrCreateJSEventListener(args[1])) { if (Document* doc = frame->document()) - doc->addWindowEventListener(AtomicString(args[0]->toString(exec)), listener, args[2]->toBoolean(exec)); + doc->addWindowEventListener(AtomicString(args[0]->toString(exec)), listener.release(), args[2]->toBoolean(exec)); } return jsUndefined(); diff --git a/WebCore/bindings/js/JSDOMWindowBase.h b/WebCore/bindings/js/JSDOMWindowBase.h index b52446d500aee96a984ba8522147a79e52ce1d19..483b874ee75402eebfeeabcf542e05bf5bf4789b 100644 --- a/WebCore/bindings/js/JSDOMWindowBase.h +++ b/WebCore/bindings/js/JSDOMWindowBase.h @@ -76,13 +76,13 @@ namespace WebCore { JSEventListener* findJSEventListener(KJS::JSValue*, bool html = false); // Finds or creates a wrapper of a JS EventListener. JS EventListener object is GC-protected. - JSEventListener* findOrCreateJSEventListener(KJS::JSValue*, bool html = false); + PassRefPtr findOrCreateJSEventListener(KJS::JSValue*, bool html = false); // Finds a wrapper of a GC-unprotected JS EventListener, returns 0 if no existing one. JSUnprotectedEventListener* findJSUnprotectedEventListener(KJS::JSValue*, bool html = false); // Finds or creates a wrapper of a JS EventListener. JS EventListener object is *NOT* GC-protected. - JSUnprotectedEventListener* findOrCreateJSUnprotectedEventListener(KJS::JSValue*, bool html = false); + PassRefPtr findOrCreateJSUnprotectedEventListener(KJS::JSValue*, bool html = false); void clear(); diff --git a/WebCore/bindings/js/JSEventTargetBase.cpp b/WebCore/bindings/js/JSEventTargetBase.cpp index 74e4d33c8a73e699699397ccefd6f9ae0e6ff036..aa15dee6e948ee2580aa3bfc72a88e947b2af318 100644 --- a/WebCore/bindings/js/JSEventTargetBase.cpp +++ b/WebCore/bindings/js/JSEventTargetBase.cpp @@ -106,8 +106,8 @@ JSValue* jsEventTargetAddEventListener(ExecState* exec, JSObject* thisObj, const if (!frame) return jsUndefined(); - if (JSEventListener* listener = toJSDOMWindow(frame)->findOrCreateJSEventListener(args[1])) - eventTarget->addEventListener(args[0]->toString(exec), listener, args[2]->toBoolean(exec)); + if (RefPtr listener = toJSDOMWindow(frame)->findOrCreateJSEventListener(args[1])) + eventTarget->addEventListener(args[0]->toString(exec), listener.release(), args[2]->toBoolean(exec)); return jsUndefined(); } diff --git a/WebCore/bindings/js/JSNodeFilterCondition.h b/WebCore/bindings/js/JSNodeFilterCondition.h index 65519e993e1ec3febd1046e80cc795caf0ad52b8..ea425afe0aac1d9d225aa46ef73aeb784ea2eb08 100644 --- a/WebCore/bindings/js/JSNodeFilterCondition.h +++ b/WebCore/bindings/js/JSNodeFilterCondition.h @@ -21,6 +21,7 @@ #define JSNodeFilterCondition_h #include "NodeFilterCondition.h" +#include namespace KJS { class JSObject; @@ -32,11 +33,16 @@ namespace WebCore { class JSNodeFilterCondition : public NodeFilterCondition { public: - JSNodeFilterCondition(KJS::JSObject* filter); + static PassRefPtr create(KJS::JSObject* filter) + { + return adoptRef(new JSNodeFilterCondition(filter)); + } + virtual short acceptNode(Node*, KJS::JSValue*& exception) const; virtual void mark(); - protected: + private: + JSNodeFilterCondition(KJS::JSObject* filter); KJS::JSObject* m_filter; }; diff --git a/WebCore/bindings/js/JSNodeFilterCustom.cpp b/WebCore/bindings/js/JSNodeFilterCustom.cpp index 98b75af8af69ae94950f984522a45e92caac55cb..bbbe9641e4a926500fd8e16e3a517e1e1b015659 100644 --- a/WebCore/bindings/js/JSNodeFilterCustom.cpp +++ b/WebCore/bindings/js/JSNodeFilterCustom.cpp @@ -60,7 +60,7 @@ NodeFilter* toNodeFilter(KJS::JSValue* val) KJS::JSObject* o = static_cast(val); if (o->implementsCall()) - return new NodeFilter(new JSNodeFilterCondition(o)); + return new NodeFilter(JSNodeFilterCondition::create(o)); return 0; } diff --git a/WebCore/bindings/js/JSSVGLazyEventListener.h b/WebCore/bindings/js/JSSVGLazyEventListener.h index b219af8951b7ed424f2b60cd428a5eb3fc1da391..fa138212a077fd36f01a0a07709052bf69ee53fb 100644 --- a/WebCore/bindings/js/JSSVGLazyEventListener.h +++ b/WebCore/bindings/js/JSSVGLazyEventListener.h @@ -1,7 +1,5 @@ /* - Copyright (C) 2006 Apple Computer, Inc. - - This file is part of the WebKit project + Copyright (C) 2006, 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 @@ -21,21 +19,28 @@ #ifndef JSSVGLazyEventListener_h #define JSSVGLazyEventListener_h -#if ENABLE(SVG) #include "kjs_events.h" +#if ENABLE(SVG) + namespace WebCore { class JSSVGLazyEventListener : public JSLazyEventListener { public: - JSSVGLazyEventListener(const String& functionName, const String& code, JSDOMWindow*, Node*, int lineNumber = 0); + static PassRefPtr create(const String& functionName, const String& code, JSDOMWindow* window, Node* node, int lineNumber) + { + return adoptRef(new JSSVGLazyEventListener(functionName, code, window, node, lineNumber)); + } private: + JSSVGLazyEventListener(const String& functionName, const String& code, JSDOMWindow*, Node*, int lineNumber); + virtual KJS::JSValue* eventParameterName() const; }; } // namespace WebCore #endif // ENABLE(SVG) + #endif // JSSVGLazyEventListener_h diff --git a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp index 8fd107f7ef8e4b3f7f36c7aff5ad3f75fa430828..003a14ad43404d4cc59535e74b20d0539802fb4e 100644 --- a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp +++ b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp @@ -211,10 +211,10 @@ JSValue* JSXMLHttpRequest::addEventListener(ExecState* exec, const List& args) Frame* frame = document->frame(); if (!frame) return jsUndefined(); - JSUnprotectedEventListener* listener = toJSDOMWindow(frame)->findOrCreateJSUnprotectedEventListener(args[1], true); + RefPtr listener = toJSDOMWindow(frame)->findOrCreateJSUnprotectedEventListener(args[1], true); if (!listener) return jsUndefined(); - impl()->addEventListener(args[0]->toString(exec), listener, args[2]->toBoolean(exec)); + impl()->addEventListener(args[0]->toString(exec), listener.release(), args[2]->toBoolean(exec)); return jsUndefined(); } @@ -226,7 +226,7 @@ JSValue* JSXMLHttpRequest::removeEventListener(ExecState* exec, const List& args Frame* frame = document->frame(); if (!frame) return jsUndefined(); - JSUnprotectedEventListener* listener = toJSDOMWindow(frame)->findOrCreateJSUnprotectedEventListener(args[1], true); + JSUnprotectedEventListener* listener = toJSDOMWindow(frame)->findJSUnprotectedEventListener(args[1], true); if (!listener) return jsUndefined(); impl()->removeEventListener(args[0]->toString(exec), listener, args[2]->toBoolean(exec)); diff --git a/WebCore/bindings/js/kjs_binding.cpp b/WebCore/bindings/js/kjs_binding.cpp index f1bbc969bf55e30f9bcee20e73b07f25e87f5783..14aa1d223e3af8cad45e286d0cf6c0d3fb7bdfce 100644 --- a/WebCore/bindings/js/kjs_binding.cpp +++ b/WebCore/bindings/js/kjs_binding.cpp @@ -278,25 +278,25 @@ void setDOMException(ExecState* exec, ExceptionCode ec) JSValue* errorObject = 0; switch (description.type) { case DOMExceptionType: - errorObject = toJS(exec, new DOMCoreException(description)); + errorObject = toJS(exec, DOMCoreException::create(description)); break; case RangeExceptionType: - errorObject = toJS(exec, new RangeException(description)); + errorObject = toJS(exec, RangeException::create(description)); break; case EventExceptionType: - errorObject = toJS(exec, new EventException(description)); + errorObject = toJS(exec, EventException::create(description)); break; case XMLHttpRequestExceptionType: - errorObject = toJS(exec, new XMLHttpRequestException(description)); + errorObject = toJS(exec, XMLHttpRequestException::create(description)); break; #if ENABLE(SVG) case SVGExceptionType: - errorObject = toJS(exec, new SVGException(description), 0); + errorObject = toJS(exec, SVGException::create(description).get(), 0); break; #endif #if ENABLE(XPATH) case XPathExceptionType: - errorObject = toJS(exec, new XPathException(description)); + errorObject = toJS(exec, XPathException::create(description)); break; #endif } diff --git a/WebCore/bindings/js/kjs_events.cpp b/WebCore/bindings/js/kjs_events.cpp index 970f57bfbd5d0b22352d21fa00813f2a3573f274..6b3939b9873ee27336cb199b301526100ce0584f 100644 --- a/WebCore/bindings/js/kjs_events.cpp +++ b/WebCore/bindings/js/kjs_events.cpp @@ -40,15 +40,8 @@ namespace WebCore { using namespace EventNames; -JSAbstractEventListener::JSAbstractEventListener(bool html) - : m_html(html) +void JSAbstractEventListener::handleEvent(Event* event, bool isWindowEvent) { -} - -void JSAbstractEventListener::handleEvent(Event* ele, bool isWindowEvent) -{ - Event* event = ele; - JSObject* listener = listenerObj(); if (!listener) return; @@ -113,7 +106,7 @@ void JSAbstractEventListener::handleEvent(Event* ele, bool isWindowEvent) } else { if (!retval->isUndefinedOrNull() && event->storesResultAsString()) event->storeResult(retval->toString(exec)); - if (m_html) { + if (m_isHTML) { bool retvalbool; if (retval->getBoolean(retvalbool) && !retvalbool) event->preventDefault(); @@ -127,18 +120,18 @@ void JSAbstractEventListener::handleEvent(Event* ele, bool isWindowEvent) bool JSAbstractEventListener::isHTMLEventListener() const { - return m_html; + return m_isHTML; } // ------------------------------------------------------------------------- -JSUnprotectedEventListener::JSUnprotectedEventListener(JSObject* listener, JSDOMWindow* window, bool html) - : JSAbstractEventListener(html) +JSUnprotectedEventListener::JSUnprotectedEventListener(JSObject* listener, JSDOMWindow* window, bool isHTML) + : JSAbstractEventListener(isHTML) , m_listener(listener) , m_window(window) { if (m_listener) { - JSDOMWindow::UnprotectedListenersMap& listeners = html + JSDOMWindow::UnprotectedListenersMap& listeners = isHTML ? window->jsUnprotectedHTMLEventListeners() : window->jsUnprotectedEventListeners(); listeners.set(m_listener, this); } @@ -194,13 +187,13 @@ static EventListenerCounter eventListenerCounter; // ------------------------------------------------------------------------- -JSEventListener::JSEventListener(JSObject* listener, JSDOMWindow* window, bool html) - : JSAbstractEventListener(html) +JSEventListener::JSEventListener(JSObject* listener, JSDOMWindow* window, bool isHTML) + : JSAbstractEventListener(isHTML) , m_listener(listener) , m_window(window) { if (m_listener) { - JSDOMWindow::ListenersMap& listeners = html + JSDOMWindow::ListenersMap& listeners = isHTML ? m_window->jsHTMLEventListeners() : m_window->jsEventListeners(); listeners.set(m_listener, this); } diff --git a/WebCore/bindings/js/kjs_events.h b/WebCore/bindings/js/kjs_events.h index bb712254303cd4ec6c33e0850357628cac76b542..34fbfa8486290b918cc21535762f8bb6fc8a82ce 100644 --- a/WebCore/bindings/js/kjs_events.h +++ b/WebCore/bindings/js/kjs_events.h @@ -32,20 +32,27 @@ namespace WebCore { class JSAbstractEventListener : public EventListener { public: - JSAbstractEventListener(bool html = false); - virtual void handleEvent(Event*, bool isWindowEvent); virtual bool isHTMLEventListener() const; virtual KJS::JSObject* listenerObj() const = 0; virtual JSDOMWindow* window() const = 0; + protected: + JSAbstractEventListener(bool isHTML) + : m_isHTML(isHTML) + { + } + private: - bool m_html; + bool m_isHTML; }; class JSUnprotectedEventListener : public JSAbstractEventListener { public: - JSUnprotectedEventListener(KJS::JSObject* listener, JSDOMWindow*, bool html = false); + static PassRefPtr create(KJS::JSObject* listener, JSDOMWindow* window, bool isHTML) + { + return adoptRef(new JSUnprotectedEventListener(listener, window, isHTML)); + } virtual ~JSUnprotectedEventListener(); virtual KJS::JSObject* listenerObj() const; @@ -54,13 +61,18 @@ namespace WebCore { void mark(); private: + JSUnprotectedEventListener(KJS::JSObject* listener, JSDOMWindow*, bool isHTML); + KJS::JSObject* m_listener; JSDOMWindow* m_window; }; class JSEventListener : public JSAbstractEventListener { public: - JSEventListener(KJS::JSObject* listener, JSDOMWindow*, bool html = false); + static PassRefPtr create(KJS::JSObject* listener, JSDOMWindow* window, bool isHTML) + { + return adoptRef(new JSEventListener(listener, window, isHTML)); + } virtual ~JSEventListener(); virtual KJS::JSObject* listenerObj() const; @@ -68,6 +80,8 @@ namespace WebCore { void clearWindow(); protected: + JSEventListener(KJS::JSObject* listener, JSDOMWindow*, bool isHTML); + mutable KJS::ProtectedPtr m_listener; private: @@ -76,9 +90,15 @@ namespace WebCore { class JSLazyEventListener : public JSEventListener { public: - JSLazyEventListener(const String& functionName, const String& code, JSDOMWindow*, Node*, int lineNumber); + static PassRefPtr create(const String& functionName, const String& code, JSDOMWindow* window, Node* node, int lineNumber) + { + return adoptRef(new JSLazyEventListener(functionName, code, window, node, lineNumber)); + } virtual KJS::JSObject* listenerObj() const; + protected: + JSLazyEventListener(const String& functionName, const String& code, JSDOMWindow*, Node*, int lineNumber); + private: virtual KJS::JSValue* eventParameterName() const; void parseCode() const; diff --git a/WebCore/bindings/js/kjs_proxy.cpp b/WebCore/bindings/js/kjs_proxy.cpp index 3baad5fc5a01f3a7b1bd25e81cbf7dcca116d7b1..a65e4ae0c2ec5d1bbeaa826f4f48b6f001793729 100644 --- a/WebCore/bindings/js/kjs_proxy.cpp +++ b/WebCore/bindings/js/kjs_proxy.cpp @@ -123,19 +123,19 @@ void KJSProxy::clear() gcController().garbageCollectSoon(); } -EventListener* KJSProxy::createHTMLEventHandler(const String& functionName, const String& code, Node* node) +PassRefPtr KJSProxy::createHTMLEventHandler(const String& functionName, const String& code, Node* node) { initScriptIfNeeded(); JSLock lock; - return new JSLazyEventListener(functionName, code, m_windowShell->window(), node, m_handlerLineno); + return JSLazyEventListener::create(functionName, code, m_windowShell->window(), node, m_handlerLineno); } #if ENABLE(SVG) -EventListener* KJSProxy::createSVGEventHandler(const String& functionName, const String& code, Node* node) +PassRefPtr KJSProxy::createSVGEventHandler(const String& functionName, const String& code, Node* node) { initScriptIfNeeded(); JSLock lock; - return new JSSVGLazyEventListener(functionName, code, m_windowShell->window(), node, m_handlerLineno); + return JSSVGLazyEventListener::create(functionName, code, m_windowShell->window(), node, m_handlerLineno); } #endif diff --git a/WebCore/bindings/js/kjs_proxy.h b/WebCore/bindings/js/kjs_proxy.h index 732a4f2f5818ece0df19ff930985d77e31573386..aede1f24fbd758979b2008f5ec824b5f102941fc 100644 --- a/WebCore/bindings/js/kjs_proxy.h +++ b/WebCore/bindings/js/kjs_proxy.h @@ -60,9 +60,9 @@ public: KJS::JSValue* evaluate(const String& filename, int baseLine, const String& code); void clear(); - EventListener* createHTMLEventHandler(const String& functionName, const String& code, Node*); + PassRefPtr createHTMLEventHandler(const String& functionName, const String& code, Node*); #if ENABLE(SVG) - EventListener* createSVGEventHandler(const String& functionName, const String& code, Node*); + PassRefPtr createSVGEventHandler(const String& functionName, const String& code, Node*); #endif void finishedWithEvent(Event*); void setEventHandlerLineno(int lineno) { m_handlerLineno = lineno; } diff --git a/WebCore/bindings/objc/DOM.mm b/WebCore/bindings/objc/DOM.mm index 2f3c9d830d6fde49467450502dac51cf8ac0ed0f..3577b76b1efb8ab50e635a20a0b92b53f2069611 100644 --- a/WebCore/bindings/objc/DOM.mm +++ b/WebCore/bindings/objc/DOM.mm @@ -692,34 +692,27 @@ namespace WebCore { class ObjCNodeFilterCondition : public NodeFilterCondition { public: - ObjCNodeFilterCondition(id ); - virtual ~ObjCNodeFilterCondition(); + static PassRefPtr create(id filter) + { + return adoptRef(new ObjCNodeFilterCondition(filter)); + } + virtual short acceptNode(Node*, JSValue*& exception) const; private: - ObjCNodeFilterCondition(const ObjCNodeFilterCondition&); - ObjCNodeFilterCondition &operator=(const ObjCNodeFilterCondition&); + ObjCNodeFilterCondition(id filter) + : m_filter(filter) + { + } - id m_filter; + RetainPtr > m_filter; }; -ObjCNodeFilterCondition::ObjCNodeFilterCondition(id filter) - : m_filter(filter) -{ - ASSERT(m_filter); - HardRetain(m_filter); -} - -ObjCNodeFilterCondition::~ObjCNodeFilterCondition() -{ - HardRelease(m_filter); -} - short ObjCNodeFilterCondition::acceptNode(Node* node, JSValue*&) const { if (!node) return NodeFilter::FILTER_REJECT; - return [m_filter acceptNode:[DOMNode _wrapNode:node]]; + return [m_filter.get() acceptNode:[DOMNode _wrapNode:node]]; } } // namespace WebCore @@ -734,7 +727,7 @@ short ObjCNodeFilterCondition::acceptNode(Node* node, JSValue*&) const { RefPtr cppFilter; if (filter) - cppFilter = new NodeFilter(new ObjCNodeFilterCondition(filter)); + cppFilter = new NodeFilter(ObjCNodeFilterCondition::create(filter)); ExceptionCode ec = 0; RefPtr impl = [self _document]->createNodeIterator([root _node], whatToShow, cppFilter.release(), expandEntityReferences, ec); raiseOnDOMError(ec); @@ -745,7 +738,7 @@ short ObjCNodeFilterCondition::acceptNode(Node* node, JSValue*&) const { RefPtr cppFilter; if (filter) - cppFilter = new NodeFilter(new ObjCNodeFilterCondition(filter)); + cppFilter = new NodeFilter(ObjCNodeFilterCondition::create(filter)); ExceptionCode ec = 0; RefPtr impl = [self _document]->createTreeWalker([root _node], whatToShow, cppFilter.release(), expandEntityReferences, ec); raiseOnDOMError(ec); @@ -781,12 +774,13 @@ ObjCEventListener* ObjCEventListener::find(id listener) return 0; } -ObjCEventListener *ObjCEventListener::create(id listener) +ObjCEventListener* ObjCEventListener::create(id listener) { ObjCEventListener* wrapper = find(listener); - if (!wrapper) + if (wrapper) + wrapper->ref(); + else wrapper = new ObjCEventListener(listener); - wrapper->ref(); return wrapper; } diff --git a/WebCore/css/CSSComputedStyleDeclaration.cpp b/WebCore/css/CSSComputedStyleDeclaration.cpp index 2f5ba26aa1d88979f228e654fe7181ac85aac4de..d5781476467b88d183c5f8068f4552a8a691aa91 100644 --- a/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -302,7 +302,7 @@ static PassRefPtr valueForNinePieceImage(const NinePieceImage& image) else left = new CSSPrimitiveValue(image.m_slices.left.value(), CSSPrimitiveValue::CSS_NUMBER); - RefPtr rect = new Rect(); + RefPtr rect = Rect::create(); rect->setTop(top); rect->setRight(right); rect->setBottom(bottom); @@ -948,7 +948,7 @@ PassRefPtr CSSComputedStyleDeclaration::getPropertyCSSValue(int proper RefPtr firstRegion; DashboardRegion* previousRegion = 0; for (unsigned i = 0; i < count; i++) { - RefPtr region = new DashboardRegion; + RefPtr region = DashboardRegion::create(); StyleDashboardRegion styleRegion = regions[i]; region->m_label = styleRegion.label; @@ -1001,12 +1001,12 @@ PassRefPtr CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyClip: { if (style->hasClip()) { - Rect* rect = new Rect(); + RefPtr rect = Rect::create(); rect->setTop(new CSSPrimitiveValue(style->clip().top.value(), CSSPrimitiveValue::CSS_PX)); rect->setRight(new CSSPrimitiveValue(style->clip().right.value(), CSSPrimitiveValue::CSS_PX)); rect->setBottom(new CSSPrimitiveValue(style->clip().bottom.value(), CSSPrimitiveValue::CSS_PX)); rect->setLeft(new CSSPrimitiveValue(style->clip().left.value(), CSSPrimitiveValue::CSS_PX)); - return new CSSPrimitiveValue(rect); + return new CSSPrimitiveValue(rect.release()); } return 0; } diff --git a/WebCore/css/CSSFontFace.h b/WebCore/css/CSSFontFace.h index 8c26b9f2dfa443196f97d0a0d61e7380f0a00f2f..3112e49b4eaad4f6d135b5070da8609005a49bdd 100644 --- a/WebCore/css/CSSFontFace.h +++ b/WebCore/css/CSSFontFace.h @@ -26,6 +26,7 @@ #ifndef CSSFontFace_h #define CSSFontFace_h +#include #include #include @@ -38,26 +39,26 @@ class SimpleFontData; class CSSFontFace : public RefCounted { public: - CSSFontFace() - : RefCounted(0) - , m_segmentedFontFace(0) - { - } - - virtual ~CSSFontFace(); + static PassRefPtr create() { return adoptRef(new CSSFontFace); } + ~CSSFontFace(); void setSegmentedFontFace(CSSSegmentedFontFace* segmentedFontFace) { m_segmentedFontFace = segmentedFontFace; } bool isLoaded() const; - virtual bool isValid() const; + bool isValid() const; - virtual void addSource(CSSFontFaceSource*); + void addSource(CSSFontFaceSource*); void fontLoaded(CSSFontFaceSource*); - virtual SimpleFontData* getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic); + SimpleFontData* getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic); private: + CSSFontFace() + : m_segmentedFontFace(0) + { + } + CSSSegmentedFontFace* m_segmentedFontFace; Vector m_sources; }; diff --git a/WebCore/css/CSSFontSelector.cpp b/WebCore/css/CSSFontSelector.cpp index e586232ada9cd80a017a408e30d116da60c80e28..ac3f5797aede8c3653a74e2334cff4e2e699edfb 100644 --- a/WebCore/css/CSSFontSelector.cpp +++ b/WebCore/css/CSSFontSelector.cpp @@ -154,7 +154,7 @@ void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule) fontDescription.setSmallCaps(static_cast(fontVariant.get())->getIdent() == CSSValueSmallCaps); // Each item in the src property's list is a single CSSFontFaceSource. Put them all into a CSSFontFace. - CSSFontFace* fontFace = 0; + RefPtr fontFace; int i; int srcLength = srcList->length(); @@ -201,7 +201,7 @@ void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule) } if (!fontFace) - fontFace = new CSSFontFace(); + fontFace = CSSFontFace::create(); if (source) { #if ENABLE(SVG_FONTS) @@ -217,10 +217,8 @@ void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule) ASSERT(fontFace); - if (fontFace && !fontFace->isValid()) { - delete fontFace; + if (fontFace && !fontFace->isValid()) return; - } // Hash under every single family name. int familyLength = familyList->length(); @@ -267,17 +265,18 @@ void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule) String hash = hashForFont(familyName.lower(), fontDescription.weight(), fontDescription.italic()); CSSSegmentedFontFace* segmentedFontFace = m_fonts.get(hash).get(); if (!segmentedFontFace) { - segmentedFontFace = new CSSSegmentedFontFace(this); - m_fonts.set(hash, segmentedFontFace); + RefPtr newFace = CSSSegmentedFontFace::create(this); + segmentedFontFace = newFace.get(); + m_fonts.set(hash, newFace.release()); } if (rangeList) { // A local font matching the font description should come first, so that it gets used for // any character not overlaid by explicit @font-face rules for the family. if (!segmentedFontFace->numRanges() && FontCache::fontExists(fontDescription, familyName)) { - CSSFontFace* implicitFontFace = new CSSFontFace(); + RefPtr implicitFontFace = CSSFontFace::create(); implicitFontFace->addSource(new CSSFontFaceSource(familyName)); ASSERT(implicitFontFace->isValid()); - segmentedFontFace->overlayRange(0, 0x7FFFFFFF, implicitFontFace); + segmentedFontFace->overlayRange(0, 0x7FFFFFFF, implicitFontFace.release()); } unsigned numRanges = rangeList->length(); @@ -286,7 +285,7 @@ void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule) segmentedFontFace->overlayRange(range->from(), range->to(), fontFace); } } else - segmentedFontFace->overlayRange(0, 0x7FFFFFFF, fontFace); + segmentedFontFace->overlayRange(0, 0x7FFFFFFF, fontFace.release()); } } diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp index ed230b681548171b75fee09dc3bf92ea9b801ad5..76b0545a667a452c458e310dfa535f65e405d1fb 100644 --- a/WebCore/css/CSSParser.cpp +++ b/WebCore/css/CSSParser.cpp @@ -2383,14 +2383,14 @@ bool CSSParser::parseDashboardRegions(int propId, bool important) return valid; } - RefPtr firstRegion = new DashboardRegion; + RefPtr firstRegion = DashboardRegion::create(); DashboardRegion* region = 0; while (value) { if (region == 0) { region = firstRegion.get(); } else { - RefPtr nextRegion = new DashboardRegion(); + RefPtr nextRegion = DashboardRegion::create(); region->m_next = nextRegion; region = nextRegion.get(); } @@ -2545,7 +2545,7 @@ PassRefPtr CSSParser::parseCounterContent(ValueList* args, bool counte listStyle = new CSSPrimitiveValue(ls, (CSSPrimitiveValue::UnitTypes) i->unit); } - return new CSSPrimitiveValue(new Counter(identifier.release(), listStyle.release(), separator.release())); + return new CSSPrimitiveValue(Counter::create(identifier.release(), listStyle.release(), separator.release())); } bool CSSParser::parseShape(int propId, bool important) @@ -2558,7 +2558,7 @@ bool CSSParser::parseShape(int propId, bool important) // rect(t, r, b, l) || rect(t r b l) if (args->size() != 4 && args->size() != 7) return false; - Rect *rect = new Rect(); + RefPtr rect = Rect::create(); bool valid = true; int i = 0; Value *a = args->current(); @@ -2589,11 +2589,10 @@ bool CSSParser::parseShape(int propId, bool important) i++; } if (valid) { - addProperty(propId, new CSSPrimitiveValue(rect), important); + addProperty(propId, new CSSPrimitiveValue(rect.release()), important); m_valueList->next(); return true; } - delete rect; return false; } @@ -3315,7 +3314,7 @@ struct BorderImageParseContext m_left = new CSSPrimitiveValue(m_right->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_right->primitiveType()); // Now build a rect value to hold all four of our primitive values. - RefPtr rect = new Rect; + RefPtr rect = Rect::create(); rect->setTop(m_top); rect->setRight(m_right); rect->setBottom(m_bottom); diff --git a/WebCore/css/CSSSegmentedFontFace.cpp b/WebCore/css/CSSSegmentedFontFace.cpp index 8ecfea9481115fab2da8cb192e44507dbacee2c9..30f535c26d50867aabe6431d91cf1ce48719d91b 100644 --- a/WebCore/css/CSSSegmentedFontFace.cpp +++ b/WebCore/css/CSSSegmentedFontFace.cpp @@ -35,8 +35,7 @@ namespace WebCore { CSSSegmentedFontFace::CSSSegmentedFontFace(CSSFontSelector* fontSelector) - : RefCounted(0) - , m_fontSelector(fontSelector) + : m_fontSelector(fontSelector) { } diff --git a/WebCore/css/CSSSegmentedFontFace.h b/WebCore/css/CSSSegmentedFontFace.h index 55a9da5f1f06dc636fd9410ac400dfeca71f29d7..839fe7c3af237b170451eb59c4193586b3f0bdb5 100644 --- a/WebCore/css/CSSSegmentedFontFace.h +++ b/WebCore/css/CSSSegmentedFontFace.h @@ -60,7 +60,7 @@ private: class CSSSegmentedFontFace : public RefCounted { public: - CSSSegmentedFontFace(CSSFontSelector*); + static PassRefPtr create(CSSFontSelector* selector) { return adoptRef(new CSSSegmentedFontFace(selector)); } ~CSSSegmentedFontFace(); bool isLoaded() const; @@ -75,6 +75,8 @@ public: FontData* getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic); private: + CSSSegmentedFontFace(CSSFontSelector*); + void pruneTable(); CSSFontSelector* m_fontSelector; diff --git a/WebCore/css/Counter.h b/WebCore/css/Counter.h index 9bca29b80f829dfca79ba7e2e75dcda78a484f78..0a450091d7c47416e817d1cdaca3949759dbe461 100644 --- a/WebCore/css/Counter.h +++ b/WebCore/css/Counter.h @@ -1,8 +1,6 @@ /* - * This file is part of the DOM implementation for KDE. - * * (C) 1999-2003 Lars Knoll (knoll@kde.org) - * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. + * Copyright (C) 2004, 2005, 2006, 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 @@ -25,19 +23,14 @@ #include "CSSPrimitiveValue.h" #include "PlatformString.h" -#include -#include namespace WebCore { class Counter : public RefCounted { public: - Counter(PassRefPtr identifier, PassRefPtr listStyle, PassRefPtr separator) - : RefCounted(0) - , m_identifier(identifier) - , m_listStyle(listStyle) - , m_separator(separator) + static PassRefPtr create(PassRefPtr identifier, PassRefPtr listStyle, PassRefPtr separator) { + return adoptRef(new Counter(identifier, listStyle, separator)); } String identifier() const { return m_identifier ? m_identifier->getStringValue() : String(); } @@ -50,10 +43,17 @@ public: void setListStyle(PassRefPtr listStyle) { m_listStyle = listStyle; } void setSeparator(PassRefPtr separator) { m_separator = separator; } -protected: - RefPtr m_identifier; // String - RefPtr m_listStyle; // int - RefPtr m_separator; // String +private: + Counter(PassRefPtr identifier, PassRefPtr listStyle, PassRefPtr separator) + : m_identifier(identifier) + , m_listStyle(listStyle) + , m_separator(separator) + { + } + + RefPtr m_identifier; // string + RefPtr m_listStyle; // int + RefPtr m_separator; // string }; } // namespace WebCore diff --git a/WebCore/css/DashboardRegion.h b/WebCore/css/DashboardRegion.h index e0b8555ef38b28342dae07968b030e873c3a3909..f8adfeb476083b8ed3fce850a394e095589cb626 100644 --- a/WebCore/css/DashboardRegion.h +++ b/WebCore/css/DashboardRegion.h @@ -1,6 +1,4 @@ /* - * This file is part of the DOM implementation for KDE. - * * (C) 1999-2003 Lars Knoll (knoll@kde.org) * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. * @@ -23,25 +21,28 @@ #ifndef DashboardRegion_h #define DashboardRegion_h -#include +#include "Rect.h" #if ENABLE(DASHBOARD_SUPPORT) -#include "Rect.h" namespace WebCore { class DashboardRegion : public Rect { public: - DashboardRegion() : m_isCircle(0), m_isRectangle(0) { } + static PassRefPtr create() { return adoptRef(new DashboardRegion); } RefPtr m_next; String m_label; String m_geometryType; bool m_isCircle : 1; bool m_isRectangle : 1; + +private: + DashboardRegion() : m_isCircle(false), m_isRectangle(false) { } }; } // namespace + #endif #endif diff --git a/WebCore/css/Rect.h b/WebCore/css/Rect.h index e0cc024d2d6f61eb776375c53692a22fb09c75be..5b3afab28f447b6ce308605b6273c775241325d1 100644 --- a/WebCore/css/Rect.h +++ b/WebCore/css/Rect.h @@ -1,6 +1,6 @@ /* * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2005, 2006, 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 @@ -22,16 +22,13 @@ #define Rect_h #include "CSSPrimitiveValue.h" -#include -#include #include namespace WebCore { class Rect : public RefCounted { public: - Rect() : RefCounted(0) { } - virtual ~Rect() { } + static RefPtr create() { return adoptRef(new Rect); } CSSPrimitiveValue* top() const { return m_top.get(); } CSSPrimitiveValue* right() const { return m_right.get(); } @@ -43,6 +40,9 @@ namespace WebCore { void setBottom(PassRefPtr bottom) { m_bottom = bottom; } void setLeft(PassRefPtr left) { m_left = left; } + protected: + Rect() { } + private: RefPtr m_top; RefPtr m_right; diff --git a/WebCore/dom/ChildNodeList.h b/WebCore/dom/ChildNodeList.h index 7e8b1f5e53d868d1e77e852efb83032bb0540f22..c6fc1cab2bb694e3ccd54fd062747c710c82dbbd 100644 --- a/WebCore/dom/ChildNodeList.h +++ b/WebCore/dom/ChildNodeList.h @@ -25,17 +25,23 @@ #define ChildNodeList_h #include "DynamicNodeList.h" +#include namespace WebCore { class ChildNodeList : public DynamicNodeList { public: - ChildNodeList(PassRefPtr rootNode, DynamicNodeList::Caches*); + static PassRefPtr create(PassRefPtr rootNode, Caches* caches) + { + return adoptRef(new ChildNodeList(rootNode, caches)); + } virtual unsigned length() const; virtual Node* item(unsigned index) const; protected: + ChildNodeList(PassRefPtr rootNode, Caches*); + virtual bool nodeMatches(Node*) const; }; diff --git a/WebCore/dom/ClassNodeList.h b/WebCore/dom/ClassNodeList.h index 40fe11add397d5c49d6abac66c458d7143c58890..9e104531d32a22224b1c877fca7a45d809bf82d7 100644 --- a/WebCore/dom/ClassNodeList.h +++ b/WebCore/dom/ClassNodeList.h @@ -37,9 +37,14 @@ namespace WebCore { class ClassNodeList : public DynamicNodeList { public: - ClassNodeList(PassRefPtr rootNode, const String& classNames, DynamicNodeList::Caches*); + static PassRefPtr create(PassRefPtr rootNode, const String& classNames, Caches* caches) + { + return adoptRef(new ClassNodeList(rootNode, classNames, caches)); + } private: + ClassNodeList(PassRefPtr rootNode, const String& classNames, Caches*); + virtual bool nodeMatches(Node*) const; ClassNames m_classNames; diff --git a/WebCore/dom/Clipboard.h b/WebCore/dom/Clipboard.h index 5491c25253012dc79e2e6e9bf9fe0ec5b8233957..8d7a62ae1b10254fecb29a86abbf2e5557000e77 100644 --- a/WebCore/dom/Clipboard.h +++ b/WebCore/dom/Clipboard.h @@ -1,10 +1,8 @@ /* - * This file is part of the DOM implementation for KDE. - * * Copyright (C) 2001 Peter Kelly (pmk@post.com) * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) - * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. + * Copyright (C) 2003, 2004, 2005, 2006, 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 @@ -26,29 +24,17 @@ #ifndef Clipboard_h #define Clipboard_h -#include -#include "AtomicString.h" #include "ClipboardAccessPolicy.h" #include "DragActions.h" #include "DragImage.h" #include "IntPoint.h" #include "Node.h" -#include namespace WebCore { - class CachedImage; - class Element; - class Frame; - class Image; - class KURL; - class Range; - class String; - // State available during IE's events for drag and drop and copy/paste class Clipboard : public RefCounted { public: - Clipboard(ClipboardAccessPolicy policy, bool isForDragging); virtual ~Clipboard() { } // Is this operation a drag-drop or a copy-paste? @@ -73,8 +59,7 @@ namespace WebCore { Node* dragImageElement() { return m_dragImageElement.get(); } virtual void setDragImageElement(Node*, const IntPoint&) = 0; - //Provides the DOM specified - virtual DragImageRef createDragImage(IntPoint& dragLoc) const = 0; + virtual DragImageRef createDragImage(IntPoint& dragLocation) const = 0; virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*) = 0; virtual void writeURL(const KURL&, const String&, Frame*) = 0; virtual void writeRange(Range*, Frame*) = 0; @@ -91,6 +76,8 @@ namespace WebCore { void setDragHasStarted() { m_dragStarted = true; } protected: + Clipboard(ClipboardAccessPolicy, bool isForDragging); + ClipboardAccessPolicy policy() const { return m_policy; } bool dragStarted() const { return m_dragStarted; } diff --git a/WebCore/dom/DOMCoreException.h b/WebCore/dom/DOMCoreException.h index 48bf52cd123e8132a12dda4a1c2640466754eb8a..4edf678188e2e34e5c9510b29d16b7aa327722af 100644 --- a/WebCore/dom/DOMCoreException.h +++ b/WebCore/dom/DOMCoreException.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,6 +35,12 @@ namespace WebCore { class DOMCoreException : public ExceptionBase { public: + static PassRefPtr create(const ExceptionCodeDescription& description) + { + return adoptRef(new DOMCoreException(description)); + } + + private: DOMCoreException(const ExceptionCodeDescription& description) : ExceptionBase(description) { diff --git a/WebCore/dom/DOMImplementation.cpp b/WebCore/dom/DOMImplementation.cpp index 3496b48cb490b1b4e3ea166e4b5d14c03cc24ae5..f588705d8c1d6620ece097b241fe152ea30e4b34 100644 --- a/WebCore/dom/DOMImplementation.cpp +++ b/WebCore/dom/DOMImplementation.cpp @@ -275,8 +275,8 @@ PassRefPtr DOMImplementation::createHTMLDocument(Frame* frame) DOMImplementation* DOMImplementation::instance() { - static RefPtr i = new DOMImplementation; - return i.get(); + static DOMImplementation* staticInstance = new DOMImplementation; + return staticInstance; } bool DOMImplementation::isXMLMIMEType(const String& mimeType) diff --git a/WebCore/dom/DOMImplementation.h b/WebCore/dom/DOMImplementation.h index 80b921cef089c65436c5dc1fd01a0ed98e3e66c4..fed74072cba52bf28fe20c7fd505f039117389d9 100644 --- a/WebCore/dom/DOMImplementation.h +++ b/WebCore/dom/DOMImplementation.h @@ -1,10 +1,8 @@ /* - * This file is part of the DOM implementation for KDE. - * * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. + * Copyright (C) 2004, 2005, 2006, 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,8 +40,7 @@ typedef int ExceptionCode; class DOMImplementation : public RefCounted { public: - DOMImplementation() : RefCounted(0) { } - virtual ~DOMImplementation(); + ~DOMImplementation(); // DOM methods & attributes for DOMImplementation bool hasFeature(const String& feature, const String& version) const; @@ -69,6 +66,9 @@ public: static bool isXMLMIMEType(const String& MIMEType); static bool isTextMIMEType(const String& MIMEType); + +private: + DOMImplementation() { } }; } //namespace diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp index 9a53debb10992bdc1e8bd9d878ed07216c4276ed..4d6d5a1e9fae0d259925ab1958eba836644ad360 100644 --- a/WebCore/dom/Document.cpp +++ b/WebCore/dom/Document.cpp @@ -2625,54 +2625,57 @@ void Document::setHTMLWindowEventListener(const AtomicString &eventType, PassRef addWindowEventListener(eventType, listener, false); } -EventListener *Document::getHTMLWindowEventListener(const AtomicString &eventType) +EventListener *Document::getHTMLWindowEventListener(const AtomicString& eventType) { RegisteredEventListenerList::iterator it = m_windowEventListeners.begin(); - for (; it != m_windowEventListeners.end(); ++it) - if ( (*it)->eventType() == eventType && (*it)->listener()->isHTMLEventListener()) + for (; it != m_windowEventListeners.end(); ++it) { + if ((*it)->eventType() == eventType && (*it)->listener()->isHTMLEventListener()) return (*it)->listener(); + } return 0; } -void Document::removeHTMLWindowEventListener(const AtomicString &eventType) +void Document::removeHTMLWindowEventListener(const AtomicString& eventType) { RegisteredEventListenerList::iterator it = m_windowEventListeners.begin(); - for (; it != m_windowEventListeners.end(); ++it) - if ( (*it)->eventType() == eventType && (*it)->listener()->isHTMLEventListener()) { - if (eventType == ((AtomicString)unloadEvent)) + for (; it != m_windowEventListeners.end(); ++it) { + if ((*it)->eventType() == eventType && (*it)->listener()->isHTMLEventListener()) { + if (eventType == unloadEvent) removePendingFrameUnloadEventCount(); - else if (eventType == ((AtomicString)beforeunloadEvent)) + else if (eventType == beforeunloadEvent) removePendingFrameBeforeUnloadEventCount(); m_windowEventListeners.remove(it); return; } + } } void Document::addWindowEventListener(const AtomicString &eventType, PassRefPtr listener, bool useCapture) { - if (eventType == ((AtomicString)unloadEvent)) + if (eventType == unloadEvent) addPendingFrameUnloadEventCount(); - else if (eventType == ((AtomicString)beforeunloadEvent)) + else if (eventType == beforeunloadEvent) addPendingFrameBeforeUnloadEventCount(); // Remove existing identical listener set with identical arguments. // The DOM 2 spec says that "duplicate instances are discarded" in this case. removeWindowEventListener(eventType, listener.get(), useCapture); - m_windowEventListeners.append(new RegisteredEventListener(eventType, listener, useCapture)); + m_windowEventListeners.append(RegisteredEventListener::create(eventType, listener, useCapture)); } -void Document::removeWindowEventListener(const AtomicString &eventType, EventListener *listener, bool useCapture) +void Document::removeWindowEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture) { - RegisteredEventListener rl(eventType, listener, useCapture); RegisteredEventListenerList::iterator it = m_windowEventListeners.begin(); - for (; it != m_windowEventListeners.end(); ++it) - if (*(*it) == rl) { - if (eventType == ((AtomicString)unloadEvent)) + for (; it != m_windowEventListeners.end(); ++it) { + RegisteredEventListener& r = **it; + if (r.eventType() == eventType && r.listener() == listener && r.useCapture() == useCapture) { + if (eventType == unloadEvent) removePendingFrameUnloadEventCount(); - else if (eventType == ((AtomicString)beforeunloadEvent)) + else if (eventType == beforeunloadEvent) removePendingFrameBeforeUnloadEventCount(); m_windowEventListeners.remove(it); return; } + } } bool Document::hasWindowEventListener(const AtomicString &eventType) @@ -2986,7 +2989,7 @@ HTMLMapElement *Document::getImageMap(const String& url) const return m_imageMapsByName.get(mapName.impl()); } -void Document::setDecoder(TextResourceDecoder *decoder) +void Document::setDecoder(PassRefPtr decoder) { m_decoder = decoder; } @@ -3641,63 +3644,63 @@ SVGDocumentExtensions* Document::accessSVGExtensions() PassRefPtr Document::images() { - return new HTMLCollection(this, HTMLCollection::DocImages); + return HTMLCollection::create(this, HTMLCollection::DocImages); } PassRefPtr Document::applets() { - return new HTMLCollection(this, HTMLCollection::DocApplets); + return HTMLCollection::create(this, HTMLCollection::DocApplets); } PassRefPtr Document::embeds() { - return new HTMLCollection(this, HTMLCollection::DocEmbeds); + return HTMLCollection::create(this, HTMLCollection::DocEmbeds); } PassRefPtr Document::plugins() { // This is an alias for embeds() required for the JS DOM bindings. - return new HTMLCollection(this, HTMLCollection::DocEmbeds); + return HTMLCollection::create(this, HTMLCollection::DocEmbeds); } PassRefPtr Document::objects() { - return new HTMLCollection(this, HTMLCollection::DocObjects); + return HTMLCollection::create(this, HTMLCollection::DocObjects); } PassRefPtr Document::scripts() { - return new HTMLCollection(this, HTMLCollection::DocScripts); + return HTMLCollection::create(this, HTMLCollection::DocScripts); } PassRefPtr Document::links() { - return new HTMLCollection(this, HTMLCollection::DocLinks); + return HTMLCollection::create(this, HTMLCollection::DocLinks); } PassRefPtr Document::forms() { - return new HTMLCollection(this, HTMLCollection::DocForms); + return HTMLCollection::create(this, HTMLCollection::DocForms); } PassRefPtr Document::anchors() { - return new HTMLCollection(this, HTMLCollection::DocAnchors); + return HTMLCollection::create(this, HTMLCollection::DocAnchors); } PassRefPtr Document::all() { - return new HTMLCollection(this, HTMLCollection::DocAll); + return HTMLCollection::create(this, HTMLCollection::DocAll); } PassRefPtr Document::windowNamedItems(const String &name) { - return new HTMLNameCollection(this, HTMLCollection::WindowNamedItems, name); + return HTMLNameCollection::create(this, HTMLCollection::WindowNamedItems, name); } PassRefPtr Document::documentNamedItems(const String &name) { - return new HTMLNameCollection(this, HTMLCollection::DocumentNamedItems, name); + return HTMLNameCollection::create(this, HTMLCollection::DocumentNamedItems, name); } HTMLCollection::CollectionInfo* Document::nameCollectionInfo(HTMLCollection::Type type, const AtomicString& name) diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h index a91e4bf9ec50b8e8a993c312bd77ea755e5c8717..54e5ca417d65acba8c3165aa13746484973a20f0 100644 --- a/WebCore/dom/Document.h +++ b/WebCore/dom/Document.h @@ -884,7 +884,7 @@ public: void setShouldCreateRenderers(bool); bool shouldCreateRenderers(); - void setDecoder(TextResourceDecoder*); + void setDecoder(PassRefPtr); TextResourceDecoder* decoder() const { return m_decoder.get(); } UChar backslashAsCurrencySymbol() const; diff --git a/WebCore/dom/DynamicNodeList.h b/WebCore/dom/DynamicNodeList.h index 8674ae144766ec4fed423ca7a7d2d933c074255d..a5cad338a6959b057a60a63c49af2340e98f95be 100644 --- a/WebCore/dom/DynamicNodeList.h +++ b/WebCore/dom/DynamicNodeList.h @@ -48,8 +48,6 @@ namespace WebCore { unsigned refCount; }; - DynamicNodeList(PassRefPtr rootNode); - DynamicNodeList(PassRefPtr rootNode, Caches*); virtual ~DynamicNodeList(); bool hasOwnCaches() const { return m_ownsCaches; } @@ -63,6 +61,9 @@ namespace WebCore { void invalidateCache(); protected: + DynamicNodeList(PassRefPtr rootNode); + DynamicNodeList(PassRefPtr rootNode, Caches*); + virtual bool nodeMatches(Node*) const = 0; RefPtr m_rootNode; diff --git a/WebCore/dom/EventException.h b/WebCore/dom/EventException.h index 15a0dc817a0c1712dc16795296183020121d78c9..dd37ba5752641aada418a168d327464ad2a9ee2e 100644 --- a/WebCore/dom/EventException.h +++ b/WebCore/dom/EventException.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,9 +35,9 @@ namespace WebCore { class EventException : public ExceptionBase { public: - EventException(const ExceptionCodeDescription& description) - : ExceptionBase(description) + static PassRefPtr create(const ExceptionCodeDescription& description) { + return adoptRef(new EventException(description)); } static const int EventExceptionOffset = 100; @@ -46,6 +46,12 @@ namespace WebCore { enum EventExceptionCode { UNSPECIFIED_EVENT_TYPE_ERR = EventExceptionOffset }; + + private: + EventException(const ExceptionCodeDescription& description) + : ExceptionBase(description) + { + } }; } // namespace WebCore diff --git a/WebCore/dom/EventListener.h b/WebCore/dom/EventListener.h index 093804145fed3e8f0adb755fc7f4d376da696564..37e86bab8f15e00250c0dd659e7b42ac57d90ef0 100644 --- a/WebCore/dom/EventListener.h +++ b/WebCore/dom/EventListener.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. + * Copyright (C) 2006, 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 @@ -29,7 +29,6 @@ namespace WebCore { class EventListener : public RefCounted { public: - EventListener() : RefCounted(0) { } virtual ~EventListener() { } virtual void handleEvent(Event*, bool isWindowEvent = false) = 0; virtual bool isHTMLEventListener() const { return false; } diff --git a/WebCore/dom/EventTarget.cpp b/WebCore/dom/EventTarget.cpp index 213a3cabe283d419f2a35ba7676d13496898a352..cad96073ced09133de1b048ccda55a15ea3e9814 100644 --- a/WebCore/dom/EventTarget.cpp +++ b/WebCore/dom/EventTarget.cpp @@ -125,7 +125,7 @@ void EventTarget::addEventListener(EventTargetNode* referenceNode, const AtomicS if (referenceNode->m_regdListeners->isEmpty() && !referenceNode->inDocument()) referenceNode->document()->registerDisconnectedNodeWithEventListeners(referenceNode); - referenceNode->m_regdListeners->append(new RegisteredEventListener(eventType, listener.get(), useCapture)); + referenceNode->m_regdListeners->append(RegisteredEventListener::create(eventType, listener, useCapture)); } void EventTarget::removeEventListener(EventTargetNode* referenceNode, const AtomicString& eventType, EventListener* listener, bool useCapture) @@ -134,11 +134,10 @@ void EventTarget::removeEventListener(EventTargetNode* referenceNode, const Atom if (!referenceNode->m_regdListeners) return; - RegisteredEventListener rl(eventType, listener, useCapture); - RegisteredEventListenerList::Iterator end = referenceNode->m_regdListeners->end(); for (RegisteredEventListenerList::Iterator it = referenceNode->m_regdListeners->begin(); it != end; ++it) { - if (*(*it).get() == rl) { + RegisteredEventListener& r = **it; + if (r.eventType() == eventType && r.listener() == listener && r.useCapture() == useCapture) { (*it)->setRemoved(true); it = referenceNode->m_regdListeners->remove(it); diff --git a/WebCore/dom/EventTargetNode.cpp b/WebCore/dom/EventTargetNode.cpp index 3c118cf8324fff00658e409a296f4186b679f44b..0269e86d9b4a872595847fb7a1b2159917d13c79 100644 --- a/WebCore/dom/EventTargetNode.cpp +++ b/WebCore/dom/EventTargetNode.cpp @@ -395,7 +395,7 @@ void EventTargetNode::setHTMLEventListener(const AtomicString &eventType, PassRe // In case we are the only one holding a reference to it, we don't want removeHTMLEventListener to destroy it. removeHTMLEventListener(eventType); if (listener) - addEventListener(eventType, listener.get(), false); + addEventListener(eventType, listener, false); } EventListener *EventTargetNode::getHTMLEventListener(const AtomicString &eventType) diff --git a/WebCore/dom/ExceptionBase.cpp b/WebCore/dom/ExceptionBase.cpp index d2526bd5b02e4aa41e6904632fdac3d7486926aa..c73d5142ae3b3bdeca53b0ce46bda511b7317618 100644 --- a/WebCore/dom/ExceptionBase.cpp +++ b/WebCore/dom/ExceptionBase.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,13 +32,12 @@ namespace WebCore { ExceptionBase::ExceptionBase(const ExceptionCodeDescription& description) - : RefCounted(0) + : m_code(description.code) + , m_name(description.name) { - m_code = description.code; - if (description.name) { - m_name = description.name; + if (description.name) m_message = String::format("%s: %s Exception %d", description.name, description.typeName, description.code); - } else + else m_message = String::format("%s Exception %d", description.typeName, description.code); } diff --git a/WebCore/dom/ExceptionBase.h b/WebCore/dom/ExceptionBase.h index 3fe14aed584a78ab21f1a9272a9b7a9ce6c09896..44fad7e20548640b19081bb1a4a9ee3846960dc5 100644 --- a/WebCore/dom/ExceptionBase.h +++ b/WebCore/dom/ExceptionBase.h @@ -37,14 +37,15 @@ namespace WebCore { class ExceptionBase : public RefCounted { public: - ExceptionBase(const ExceptionCodeDescription&); - unsigned short code() const { return m_code; } String name() const { return m_name; } String message() const { return m_message; } String toString() const; + protected: + ExceptionBase(const ExceptionCodeDescription&); + private: unsigned short m_code; String m_name; diff --git a/WebCore/dom/NameNodeList.h b/WebCore/dom/NameNodeList.h index eab548a3f8d6ee4c579ae8d2efe96299ccbf8e91..d7ca1dd6e40b082a44436be8ca4cf10927afc177 100644 --- a/WebCore/dom/NameNodeList.h +++ b/WebCore/dom/NameNodeList.h @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2007m 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 @@ -24,8 +24,8 @@ #ifndef NameNodeList_h #define NameNodeList_h -#include "DynamicNodeList.h" #include "AtomicString.h" +#include "DynamicNodeList.h" namespace WebCore { @@ -34,9 +34,14 @@ namespace WebCore { // NodeList which lists all Nodes in a Element with a given "name" attribute class NameNodeList : public DynamicNodeList { public: - NameNodeList(PassRefPtr rootNode, const String& name, DynamicNodeList::Caches*); + static PassRefPtr create(PassRefPtr rootNode, const String& name, Caches* caches) + { + return adoptRef(new NameNodeList(rootNode, name, caches)); + } private: + NameNodeList(PassRefPtr rootNode, const String& name, Caches*); + virtual bool nodeMatches(Node*) const; AtomicString m_nodeName; diff --git a/WebCore/dom/Node.cpp b/WebCore/dom/Node.cpp index f31fb4699848fac930dd7318d71ef2aae88b055f..c63ca5dd40ff726581f175c7f0a71768574b19f7 100644 --- a/WebCore/dom/Node.cpp +++ b/WebCore/dom/Node.cpp @@ -210,7 +210,7 @@ PassRefPtr Node::childNodes() document()->addNodeListCache(); } - return new ChildNodeList(this, &m_nodeLists->m_childNodeListCaches); + return ChildNodeList::create(this, &m_nodeLists->m_childNodeListCaches); } Node* Node::virtualFirstChild() const @@ -1202,7 +1202,7 @@ PassRefPtr Node::getElementsByTagNameNS(const String& namespaceURI, co String name = localName; if (document()->isHTMLDocument()) name = localName.lower(); - return new TagNodeList(this, namespaceURI.isEmpty() ? nullAtom : AtomicString(namespaceURI), name); + return TagNodeList::create(this, namespaceURI.isEmpty() ? nullAtom : AtomicString(namespaceURI), name); } PassRefPtr Node::getElementsByName(const String& elementName) @@ -1216,7 +1216,7 @@ PassRefPtr Node::getElementsByName(const String& elementName) if (result.second) result.first->second = new DynamicNodeList::Caches; - return new NameNodeList(this, elementName, result.first->second); + return NameNodeList::create(this, elementName, result.first->second); } PassRefPtr Node::getElementsByClassName(const String& classNames) @@ -1230,7 +1230,7 @@ PassRefPtr Node::getElementsByClassName(const String& classNames) if (result.second) result.first->second = new DynamicNodeList::Caches; - return new ClassNodeList(this, classNames, result.first->second); + return ClassNodeList::create(this, classNames, result.first->second); } PassRefPtr Node::querySelector(const String& selectors, ExceptionCode& ec) @@ -1278,9 +1278,7 @@ PassRefPtr Node::querySelectorAll(const String& selectors, ExceptionCo return 0; } - SelectorNodeList* resultList = new SelectorNodeList(this, static_cast(rule.get())->selector()); - - return resultList; + return createSelectorNodeList(this, static_cast(rule.get())->selector()); } Document *Node::ownerDocument() const diff --git a/WebCore/dom/NodeFilterCondition.h b/WebCore/dom/NodeFilterCondition.h index 75966843385a9e7570b48cca0d70c80282c76410..69250a5048d39146318d56125612053613149c7a 100644 --- a/WebCore/dom/NodeFilterCondition.h +++ b/WebCore/dom/NodeFilterCondition.h @@ -37,9 +37,8 @@ namespace WebCore { class NodeFilterCondition : public RefCounted { public: - NodeFilterCondition() : RefCounted(0) { } virtual ~NodeFilterCondition() { } - virtual short acceptNode(Node*, KJS::JSValue*& exception) const; + virtual short acceptNode(Node*, KJS::JSValue*& exception) const = 0; virtual void mark() { } }; diff --git a/WebCore/dom/NodeList.h b/WebCore/dom/NodeList.h index 2bc1443b28d6f109d1c4d50fe9cc6b11b9270438..99a066289560c245074c7e75d88a1f9e185b4719 100644 --- a/WebCore/dom/NodeList.h +++ b/WebCore/dom/NodeList.h @@ -33,7 +33,6 @@ namespace WebCore { class NodeList : public RefCounted { public: - NodeList() : RefCounted(0) { } virtual ~NodeList() { } // DOM methods & attributes for NodeList diff --git a/WebCore/dom/RangeException.h b/WebCore/dom/RangeException.h index 11a35a5cc0d55b5e03c48c5182857cf56c9188de..2eee3b046c8946f52ce85be06c6b8073bbb4cc76 100644 --- a/WebCore/dom/RangeException.h +++ b/WebCore/dom/RangeException.h @@ -33,9 +33,9 @@ namespace WebCore { class RangeException : public ExceptionBase { public: - RangeException(const ExceptionCodeDescription& description) - : ExceptionBase(description) + static PassRefPtr create(const ExceptionCodeDescription& description) { + return adoptRef(new RangeException(description)); } static const int RangeExceptionOffset = 200; @@ -45,6 +45,12 @@ namespace WebCore { BAD_BOUNDARYPOINTS_ERR = RangeExceptionOffset + 1, INVALID_NODE_TYPE_ERR }; + + private: + RangeException(const ExceptionCodeDescription& description) + : ExceptionBase(description) + { + } }; } // namespace WebCore diff --git a/WebCore/dom/RegisteredEventListener.cpp b/WebCore/dom/RegisteredEventListener.cpp index e995bd0be7bccb4bbf6f89499318b64ceccbafee..7312785f580793cbfc6dade1e7672bae542be495 100644 --- a/WebCore/dom/RegisteredEventListener.cpp +++ b/WebCore/dom/RegisteredEventListener.cpp @@ -1,10 +1,8 @@ -/** - * This file is part of the DOM implementation for KDE. - * +/* * Copyright (C) 2001 Peter Kelly (pmk@post.com) * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) - * Copyright (C) 2003, 2005, 2006 Apple Computer, Inc. + * Copyright (C) 2003, 2005, 2006, 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 @@ -30,8 +28,7 @@ namespace WebCore { RegisteredEventListener::RegisteredEventListener(const AtomicString& eventType, PassRefPtr listener, bool useCapture) - : RefCounted(0) - , m_eventType(eventType) + : m_eventType(eventType) , m_listener(listener) , m_useCapture(useCapture) , m_removed(false) diff --git a/WebCore/dom/RegisteredEventListener.h b/WebCore/dom/RegisteredEventListener.h index b1bb0efc97b0a5c705beb1db85a876a3ebe3404f..58cd9319f3215fc3f5af5f0037d59eab5a26ba0c 100644 --- a/WebCore/dom/RegisteredEventListener.h +++ b/WebCore/dom/RegisteredEventListener.h @@ -1,10 +1,8 @@ /* - * This file is part of the DOM implementation for KDE. - * * Copyright (C) 2001 Peter Kelly (pmk@post.com) * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) - * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. + * Copyright (C) 2003, 2004, 2005, 2006, 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 @@ -27,7 +25,6 @@ #define RegisteredEventListener_h #include "AtomicString.h" -#include namespace WebCore { @@ -35,7 +32,10 @@ namespace WebCore { class RegisteredEventListener : public RefCounted { public: - RegisteredEventListener(const AtomicString& eventType, PassRefPtr, bool useCapture); + static PassRefPtr create(const AtomicString& eventType, PassRefPtr listener, bool useCapture) + { + return adoptRef(new RegisteredEventListener(eventType, listener, useCapture)); + } const AtomicString& eventType() const { return m_eventType; } EventListener* listener() const { return m_listener.get(); } @@ -45,6 +45,8 @@ namespace WebCore { void setRemoved(bool removed) { m_removed = removed; } private: + RegisteredEventListener(const AtomicString& eventType, PassRefPtr, bool useCapture); + AtomicString m_eventType; RefPtr m_listener; bool m_useCapture; diff --git a/WebCore/dom/SelectorNodeList.cpp b/WebCore/dom/SelectorNodeList.cpp index d79c8c82df149c6ae4435472302019b14fed674c..1c199408ae7b0fe95f75aca45f0551bae5a98d1a 100644 --- a/WebCore/dom/SelectorNodeList.cpp +++ b/WebCore/dom/SelectorNodeList.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -33,12 +33,12 @@ #include "CSSStyleSelector.h" #include "Document.h" #include "Element.h" -#include "Node.h" namespace WebCore { -SelectorNodeList::SelectorNodeList(PassRefPtr rootNode, CSSSelector* querySelector) +PassRefPtr createSelectorNodeList(PassRefPtr rootNode, CSSSelector* querySelector) { + Vector > nodes; Document* document = rootNode->document(); CSSStyleSelector::SelectorChecker selectorChecker(document, !document->inCompatMode()); for (Node* n = rootNode->firstChild(); n; n = n->traverseNextNode(rootNode.get())) { @@ -46,12 +46,13 @@ SelectorNodeList::SelectorNodeList(PassRefPtr rootNode, CSSSelector* query Element* element = static_cast(n); for (CSSSelector* selector = querySelector; selector; selector = selector->next()) { if (selectorChecker.checkSelector(selector, element)) { - m_nodes.append(n); + nodes.append(n); break; } } } } + return StaticNodeList::adopt(nodes); } } // namespace WebCore diff --git a/WebCore/dom/SelectorNodeList.h b/WebCore/dom/SelectorNodeList.h index 147e0285f60d0a376c6e5bd07f243899e38dbcaa..b1efbbb0e2e3c24375a93ec1c09eb3716d24f7e8 100644 --- a/WebCore/dom/SelectorNodeList.h +++ b/WebCore/dom/SelectorNodeList.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,17 +30,12 @@ #define SelectorNodeList_h #include "StaticNodeList.h" -#include namespace WebCore { - class Node; class CSSSelector; - class SelectorNodeList : public StaticNodeList { - public: - SelectorNodeList(PassRefPtr rootNode, CSSSelector*); - }; + PassRefPtr createSelectorNodeList(PassRefPtr rootNode, CSSSelector*); } // namespace WebCore diff --git a/WebCore/dom/StaticNodeList.cpp b/WebCore/dom/StaticNodeList.cpp index 3d7c70d893699da574ce9bc0afbac7103a16a3b0..99fd818a8a734385cffcbd52eb933f078b9b60a0 100644 --- a/WebCore/dom/StaticNodeList.cpp +++ b/WebCore/dom/StaticNodeList.cpp @@ -29,8 +29,6 @@ #include "config.h" #include "StaticNodeList.h" -#include "AtomicString.h" -#include "Node.h" #include "Element.h" namespace WebCore { diff --git a/WebCore/dom/StaticNodeList.h b/WebCore/dom/StaticNodeList.h index aacd1ca6d29944e6907bae6045862cf9869421c8..60fca193043fa23264938c22dcb45a38b50d269f 100644 --- a/WebCore/dom/StaticNodeList.h +++ b/WebCore/dom/StaticNodeList.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,6 +30,7 @@ #define StaticNodeList_h #include "NodeList.h" +#include #include #include @@ -39,15 +40,21 @@ namespace WebCore { class StaticNodeList : public NodeList { public: - // Derived classes should build up the Vector in their constructor. - StaticNodeList() { } - virtual ~StaticNodeList() { } + // Adopts the contents of the nodes vector. + static PassRefPtr adopt(Vector >& nodes) + { + return adoptRef(new StaticNodeList(nodes)); + } virtual unsigned length() const; virtual Node* item(unsigned index) const; virtual Node* itemWithName(const AtomicString&) const; - protected: + private: + StaticNodeList(Vector >& nodes) + { + m_nodes.swap(nodes); + } Vector > m_nodes; }; diff --git a/WebCore/dom/TagNodeList.h b/WebCore/dom/TagNodeList.h index 6593a0a30e5bf7519a94938435e62cc80f962168..5dbfb038f16398d9c42e3ab5ee2c1d2a0871be5f 100644 --- a/WebCore/dom/TagNodeList.h +++ b/WebCore/dom/TagNodeList.h @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2007 Trolltech ASA * * This library is free software; you can redistribute it and/or @@ -32,9 +32,14 @@ namespace WebCore { // NodeList that limits to a particular tag. class TagNodeList : public DynamicNodeList { public: - TagNodeList(PassRefPtr rootNode, const AtomicString& namespaceURI, const AtomicString& localName); + static PassRefPtr create(PassRefPtr rootNode, const AtomicString& namespaceURI, const AtomicString& localName) + { + return adoptRef(new TagNodeList(rootNode, namespaceURI, localName)); + } private: + TagNodeList(PassRefPtr rootNode, const AtomicString& namespaceURI, const AtomicString& localName); + virtual bool nodeMatches(Node*) const; AtomicString m_namespaceURI; diff --git a/WebCore/history/HistoryItem.cpp b/WebCore/history/HistoryItem.cpp index 05ee6eccc45a984b61f5140a443129162fa1d40b..6983b94a3814f583896e41bf96f3424ec9fb3158 100644 --- a/WebCore/history/HistoryItem.cpp +++ b/WebCore/history/HistoryItem.cpp @@ -38,12 +38,14 @@ namespace WebCore { -static void defaultNotifyHistoryItemChanged() {} +static void defaultNotifyHistoryItemChanged() +{ +} + void (*notifyHistoryItemChanged)() = defaultNotifyHistoryItemChanged; HistoryItem::HistoryItem() - : RefCounted(0) - , m_lastVisitedTime(0) + : m_lastVisitedTime(0) , m_isInPageCache(false) , m_isTargetItem(false) , m_visitCount(0) @@ -51,8 +53,7 @@ HistoryItem::HistoryItem() } HistoryItem::HistoryItem(const String& urlString, const String& title, double time) - : RefCounted(0) - , m_urlString(urlString) + : m_urlString(urlString) , m_originalURLString(urlString) , m_title(title) , m_lastVisitedTime(time) @@ -64,8 +65,7 @@ HistoryItem::HistoryItem(const String& urlString, const String& title, double ti } HistoryItem::HistoryItem(const String& urlString, const String& title, const String& alternateTitle, double time) - : RefCounted(0) - , m_urlString(urlString) + : m_urlString(urlString) , m_originalURLString(urlString) , m_title(title) , m_displayTitle(alternateTitle) @@ -77,22 +77,8 @@ HistoryItem::HistoryItem(const String& urlString, const String& title, const Str iconDatabase()->retainIconForPageURL(m_urlString); } -HistoryItem::HistoryItem(const KURL& url, const String& title) - : RefCounted(0) - , m_urlString(url.string()) - , m_originalURLString(url.string()) - , m_title(title) - , m_lastVisitedTime(0) - , m_isInPageCache(false) - , m_isTargetItem(false) - , m_visitCount(0) -{ - iconDatabase()->retainIconForPageURL(m_urlString); -} - HistoryItem::HistoryItem(const KURL& url, const String& target, const String& parent, const String& title) - : RefCounted(0) - , m_urlString(url.string()) + : m_urlString(url.string()) , m_originalURLString(url.string()) , m_target(target) , m_parent(parent) @@ -111,8 +97,8 @@ HistoryItem::~HistoryItem() iconDatabase()->releaseIconForPageURL(m_urlString); } -HistoryItem::HistoryItem(const HistoryItem& item) - : RefCounted(0) +inline HistoryItem::HistoryItem(const HistoryItem& item) + : RefCounted(1) , m_urlString(item.m_urlString) , m_originalURLString(item.m_originalURLString) , m_target(item.m_target) @@ -139,7 +125,7 @@ HistoryItem::HistoryItem(const HistoryItem& item) PassRefPtr HistoryItem::copy() const { - return new HistoryItem(*this); + return adoptRef(new HistoryItem(*this)); } const String& HistoryItem::urlString() const diff --git a/WebCore/history/HistoryItem.h b/WebCore/history/HistoryItem.h index c0650a4094a020555b1b181f8befb6ca21110482..a5c1707d7524794b1220c85e92a20374138377c3 100644 --- a/WebCore/history/HistoryItem.h +++ b/WebCore/history/HistoryItem.h @@ -58,11 +58,19 @@ class HistoryItem : public RefCounted { friend class PageCache; public: - HistoryItem(); - HistoryItem(const String& urlString, const String& title, double lastVisited); - HistoryItem(const String& urlString, const String& title, const String& alternateTitle, double lastVisited); - HistoryItem(const KURL& url, const String& title); - HistoryItem(const KURL& url, const String& target, const String& parent, const String& title); + static PassRefPtr create() { return adoptRef(new HistoryItem); } + static PassRefPtr create(const String& urlString, const String& title, double lastVisited) + { + return adoptRef(new HistoryItem(urlString, title, lastVisited)); + } + static PassRefPtr create(const String& urlString, const String& title, const String& alternateTitle, double lastVisited) + { + return adoptRef(new HistoryItem(urlString, title, alternateTitle, lastVisited)); + } + static PassRefPtr create(const KURL& url, const String& target, const String& parent, const String& title) + { + return adoptRef(new HistoryItem(url, target, parent, title)); + } ~HistoryItem(); @@ -146,6 +154,11 @@ public: #endif private: + HistoryItem(); + HistoryItem(const String& urlString, const String& title, double lastVisited); + HistoryItem(const String& urlString, const String& title, const String& alternateTitle, double lastVisited); + HistoryItem(const KURL& url, const String& target, const String& parent, const String& title); + HistoryItem(const HistoryItem&); String m_urlString; diff --git a/WebCore/html/CanvasGradient.h b/WebCore/html/CanvasGradient.h index f4a2428981420cefd9fcc150d5a669a29e845763..f08bfff9f89d64b157926fb04f0c8f4b62ce8ed9 100644 --- a/WebCore/html/CanvasGradient.h +++ b/WebCore/html/CanvasGradient.h @@ -27,11 +27,9 @@ #ifndef CanvasGradient_h #define CanvasGradient_h -#include "FloatPoint.h" #include "Gradient.h" #include #include -#include namespace WebCore { diff --git a/WebCore/html/CanvasPattern.cpp b/WebCore/html/CanvasPattern.cpp index 86167edefab12cae50968cf1cce6dcff7760ba62..72e954661f86c5d9a12cd54aae98d942c470ab14 100644 --- a/WebCore/html/CanvasPattern.cpp +++ b/WebCore/html/CanvasPattern.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -66,8 +66,7 @@ void CanvasPattern::parseRepetitionType(const String& type, bool& repeatX, bool& #if PLATFORM(CG) CanvasPattern::CanvasPattern(CGImageRef image, bool repeatX, bool repeatY, bool originClean) - : RefCounted(0) - , m_platformImage(image) + : m_platformImage(image) , m_cachedImage(0) , m_repeatX(repeatX) , m_repeatY(repeatY) @@ -78,8 +77,7 @@ CanvasPattern::CanvasPattern(CGImageRef image, bool repeatX, bool repeatY, bool #elif PLATFORM(CAIRO) CanvasPattern::CanvasPattern(cairo_surface_t* surface, bool repeatX, bool repeatY, bool originClean) - : RefCounted(0) - , m_platformImage(cairo_surface_reference(surface)) + : m_platformImage(cairo_surface_reference(surface)) , m_cachedImage(0) , m_repeatX(repeatX) , m_repeatY(repeatY) @@ -90,15 +88,14 @@ CanvasPattern::CanvasPattern(cairo_surface_t* surface, bool repeatX, bool repeat #endif CanvasPattern::CanvasPattern(CachedImage* cachedImage, bool repeatX, bool repeatY, bool originClean) - : RefCounted(0) -#if PLATFORM(CG) || PLATFORM(CAIRO) - , m_platformImage(0) -#endif - , m_cachedImage(cachedImage) + : m_cachedImage(cachedImage) , m_repeatX(repeatX) , m_repeatY(repeatY) , m_originClean(originClean) { +#if PLATFORM(CAIRO) + m_platformImage = 0; +#endif if (cachedImage) cachedImage->addClient(this); } diff --git a/WebCore/html/CanvasPattern.h b/WebCore/html/CanvasPattern.h index 867870204150fadb4ecb48dfd2b03065cbf2ae43..87e8a5d88212f7b7b2613a09b9655a8fc2b2ffd2 100644 --- a/WebCore/html/CanvasPattern.h +++ b/WebCore/html/CanvasPattern.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,6 +27,7 @@ #define CanvasPattern_h #include "CachedResourceClient.h" +#include #include #if PLATFORM(CG) @@ -48,12 +49,21 @@ namespace WebCore { static void parseRepetitionType(const String&, bool& repeatX, bool& repeatY, ExceptionCode&); #if PLATFORM(CG) - CanvasPattern(CGImageRef, bool repeatX, bool repeatY, bool originClean); + static PassRefPtr create(CGImageRef image, bool repeatX, bool repeatY, bool originClean) + { + return adoptRef(new CanvasPattern(image, repeatX, repeatY, originClean)); + } #elif PLATFORM(CAIRO) - CanvasPattern(cairo_surface_t*, bool repeatX, bool repeatY, bool originClean); + static PassRefPtr create(cairo_surface_t* surface, bool repeatX, bool repeatY, bool originClean) + { + return adoptRef(new CanvasPattern(surface, repeatX, repeatY, originClean)); + } #endif - CanvasPattern(CachedImage*, bool repeatX, bool repeatY, bool originClean); - ~CanvasPattern(); + static PassRefPtr create(CachedImage* image, bool repeatX, bool repeatY, bool originClean) + { + return adoptRef(new CanvasPattern(image, repeatX, repeatY, originClean)); + } + virtual ~CanvasPattern(); #if PLATFORM(CG) CGImageRef platformImage() const { return m_platformImage.get(); } @@ -71,6 +81,13 @@ namespace WebCore { bool originClean() const { return m_originClean; } private: +#if PLATFORM(CG) + CanvasPattern(CGImageRef, bool repeatX, bool repeatY, bool originClean); +#elif PLATFORM(CAIRO) + CanvasPattern(cairo_surface_t*, bool repeatX, bool repeatY, bool originClean); +#endif + CanvasPattern(CachedImage*, bool repeatX, bool repeatY, bool originClean); + #if PLATFORM(CG) const RetainPtr m_platformImage; #elif PLATFORM(CAIRO) diff --git a/WebCore/html/CanvasRenderingContext2D.cpp b/WebCore/html/CanvasRenderingContext2D.cpp index 14c4a4eb1d89b0724bb9c74d000dd3922b358c2c..380f9a3a093ade50eee11f177c5cc2b63e0f6451 100644 --- a/WebCore/html/CanvasRenderingContext2D.cpp +++ b/WebCore/html/CanvasRenderingContext2D.cpp @@ -81,8 +81,8 @@ void CanvasRenderingContext2D::reset() } CanvasRenderingContext2D::State::State() - : m_strokeStyle(new CanvasStyle("black")) - , m_fillStyle(new CanvasStyle("black")) + : m_strokeStyle(CanvasStyle::create("black")) + , m_fillStyle(CanvasStyle::create("black")) , m_lineWidth(1) , m_lineCap(ButtCap) , m_lineJoin(MiterJoin) @@ -367,62 +367,62 @@ void CanvasRenderingContext2D::transform(float m11, float m12, float m21, float void CanvasRenderingContext2D::setStrokeColor(const String& color) { - setStrokeStyle(new CanvasStyle(color)); + setStrokeStyle(CanvasStyle::create(color)); } void CanvasRenderingContext2D::setStrokeColor(float grayLevel) { - setStrokeStyle(new CanvasStyle(grayLevel, 1)); + setStrokeStyle(CanvasStyle::create(grayLevel, 1)); } void CanvasRenderingContext2D::setStrokeColor(const String& color, float alpha) { - setStrokeStyle(new CanvasStyle(color, alpha)); + setStrokeStyle(CanvasStyle::create(color, alpha)); } void CanvasRenderingContext2D::setStrokeColor(float grayLevel, float alpha) { - setStrokeStyle(new CanvasStyle(grayLevel, alpha)); + setStrokeStyle(CanvasStyle::create(grayLevel, alpha)); } void CanvasRenderingContext2D::setStrokeColor(float r, float g, float b, float a) { - setStrokeStyle(new CanvasStyle(r, g, b, a)); + setStrokeStyle(CanvasStyle::create(r, g, b, a)); } void CanvasRenderingContext2D::setStrokeColor(float c, float m, float y, float k, float a) { - setStrokeStyle(new CanvasStyle(c, m, y, k, a)); + setStrokeStyle(CanvasStyle::create(c, m, y, k, a)); } void CanvasRenderingContext2D::setFillColor(const String& color) { - setFillStyle(new CanvasStyle(color)); + setFillStyle(CanvasStyle::create(color)); } void CanvasRenderingContext2D::setFillColor(float grayLevel) { - setFillStyle(new CanvasStyle(grayLevel, 1)); + setFillStyle(CanvasStyle::create(grayLevel, 1)); } void CanvasRenderingContext2D::setFillColor(const String& color, float alpha) { - setFillStyle(new CanvasStyle(color, 1)); + setFillStyle(CanvasStyle::create(color, 1)); } void CanvasRenderingContext2D::setFillColor(float grayLevel, float alpha) { - setFillStyle(new CanvasStyle(grayLevel, alpha)); + setFillStyle(CanvasStyle::create(grayLevel, alpha)); } void CanvasRenderingContext2D::setFillColor(float r, float g, float b, float a) { - setFillStyle(new CanvasStyle(r, g, b, a)); + setFillStyle(CanvasStyle::create(r, g, b, a)); } void CanvasRenderingContext2D::setFillColor(float c, float m, float y, float k, float a) { - setFillStyle(new CanvasStyle(c, m, y, k, a)); + setFillStyle(CanvasStyle::create(c, m, y, k, a)); } void CanvasRenderingContext2D::beginPath() @@ -1119,7 +1119,7 @@ PassRefPtr CanvasRenderingContext2D::createPattern(HTMLImageEleme RefPtr origin = SecurityOrigin::create(url); originClean = m_canvas->document()->securityOrigin()->canAccess(origin.get()); } - return new CanvasPattern(image->cachedImage(), repeatX, repeatY, originClean); + return CanvasPattern::create(image->cachedImage(), repeatX, repeatY, originClean); } PassRefPtr CanvasRenderingContext2D::createPattern(HTMLCanvasElement* canvas, @@ -1132,19 +1132,17 @@ PassRefPtr CanvasRenderingContext2D::createPattern(HTMLCanvasElem return 0; // FIXME: Do this through platform-independent GraphicsContext API. #if PLATFORM(CG) - CGImageRef image = canvas->createPlatformImage(); + RetainPtr image = canvas->createPlatformImage(); if (!image) return 0; - PassRefPtr pattern = new CanvasPattern(image, repeatX, repeatY, canvas->originClean()); - CGImageRelease(image); - return pattern; + return CanvasPattern::create(image.get(), repeatX, repeatY, canvas->originClean()); #elif PLATFORM(CAIRO) cairo_surface_t* surface = canvas->createPlatformImage(); if (!surface) return 0; - PassRefPtr pattern = new CanvasPattern(surface, repeatX, repeatY, canvas->originClean()); + RefPtr pattern = CanvasPattern::create(surface, repeatX, repeatY, canvas->originClean()); cairo_surface_destroy(surface); - return pattern; + return pattern.release(); #else notImplemented(); return 0; diff --git a/WebCore/html/CanvasStyle.cpp b/WebCore/html/CanvasStyle.cpp index a3948c35f98b36c4194bf0f9b63605553fa99b94..be5013a478bbc0f0af9cb33f7f9feb4c2a94146b 100644 --- a/WebCore/html/CanvasStyle.cpp +++ b/WebCore/html/CanvasStyle.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. * Copyright (C) 2007 Trolltech ASA * Copyright (C) 2007 Alp Toker * @@ -47,53 +47,45 @@ namespace WebCore { CanvasStyle::CanvasStyle(const String& color) - : RefCounted(0) - , m_type(ColorString) + : m_type(ColorString) , m_color(color) { } CanvasStyle::CanvasStyle(float grayLevel) - : RefCounted(0) - , m_type(GrayLevel) + : m_type(GrayLevel) , m_alpha(1) , m_grayLevel(grayLevel) { } CanvasStyle::CanvasStyle(const String& color, float alpha) - : RefCounted(0) - , m_type(ColorStringWithAlpha), m_color(color), m_alpha(alpha) + : m_type(ColorStringWithAlpha), m_color(color), m_alpha(alpha) { } CanvasStyle::CanvasStyle(float grayLevel, float alpha) - : RefCounted(0) - , m_type(GrayLevel), m_alpha(alpha), m_grayLevel(grayLevel) + : m_type(GrayLevel), m_alpha(alpha), m_grayLevel(grayLevel) { } CanvasStyle::CanvasStyle(float r, float g, float b, float a) - : RefCounted(0) - , m_type(RGBA), m_alpha(a), m_red(r), m_green(g), m_blue(b) + : m_type(RGBA), m_alpha(a), m_red(r), m_green(g), m_blue(b) { } CanvasStyle::CanvasStyle(float c, float m, float y, float k, float a) - : RefCounted(0) - , m_type(CMYKA), m_alpha(a), m_cyan(c), m_magenta(m), m_yellow(y), m_black(k) + : m_type(CMYKA), m_alpha(a), m_cyan(c), m_magenta(m), m_yellow(y), m_black(k) { } CanvasStyle::CanvasStyle(PassRefPtr gradient) - : RefCounted(0) - , m_type(gradient ? Gradient : ColorString), m_gradient(gradient) + : m_type(gradient ? Gradient : ColorString), m_gradient(gradient) { } CanvasStyle::CanvasStyle(PassRefPtr pattern) - : RefCounted(0) - , m_type(pattern ? ImagePattern : ColorString), m_pattern(pattern) + : m_type(pattern ? ImagePattern : ColorString), m_pattern(pattern) { } diff --git a/WebCore/html/CanvasStyle.h b/WebCore/html/CanvasStyle.h index 5aac04067d96d2bbaa003773e03627b2bd912b61..b7a38e94ead52b458d9ae2e41032f835e5e551b4 100644 --- a/WebCore/html/CanvasStyle.h +++ b/WebCore/html/CanvasStyle.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,14 +36,14 @@ namespace WebCore { class CanvasStyle : public RefCounted { public: - CanvasStyle(const String& color); - CanvasStyle(float grayLevel); - CanvasStyle(const String& color, float alpha); - CanvasStyle(float grayLevel, float alpha); - CanvasStyle(float r, float g, float b, float a); - CanvasStyle(float c, float m, float y, float k, float a); - CanvasStyle(PassRefPtr); - CanvasStyle(PassRefPtr); + static PassRefPtr create(const String& color) { return adoptRef(new CanvasStyle(color)); } + static PassRefPtr create(float grayLevel) { return adoptRef(new CanvasStyle(grayLevel)); } + static PassRefPtr create(const String& color, float alpha) { return adoptRef(new CanvasStyle(color, alpha)); } + static PassRefPtr create(float grayLevel, float alpha) { return adoptRef(new CanvasStyle(grayLevel, alpha)); } + static PassRefPtr create(float r, float g, float b, float a) { return adoptRef(new CanvasStyle(r, g, b, a)); } + static PassRefPtr create(float c, float m, float y, float k, float a) { return adoptRef(new CanvasStyle(c, m, y, k, a)); } + static PassRefPtr create(PassRefPtr gradient) { return adoptRef(new CanvasStyle(gradient)); } + static PassRefPtr create(PassRefPtr pattern) { return adoptRef(new CanvasStyle(pattern)); } String color() const { return m_color; } CanvasGradient* canvasGradient() const { return m_gradient.get(); } @@ -56,6 +56,15 @@ namespace WebCore { void applyStrokeColor(GraphicsContext*); private: + CanvasStyle(const String& color); + CanvasStyle(float grayLevel); + CanvasStyle(const String& color, float alpha); + CanvasStyle(float grayLevel, float alpha); + CanvasStyle(float r, float g, float b, float a); + CanvasStyle(float c, float m, float y, float k, float a); + CanvasStyle(PassRefPtr); + CanvasStyle(PassRefPtr); + enum Type { ColorString, ColorStringWithAlpha, GrayLevel, RGBA, CMYKA, Gradient, ImagePattern }; Type m_type; diff --git a/WebCore/html/HTMLCollection.cpp b/WebCore/html/HTMLCollection.cpp index 8214b0758184ce504f34089ee751b2764867a174..a4881af7460d04ccf797b531bcb173eb56751cf2 100644 --- a/WebCore/html/HTMLCollection.cpp +++ b/WebCore/html/HTMLCollection.cpp @@ -36,8 +36,7 @@ namespace WebCore { using namespace HTMLNames; HTMLCollection::HTMLCollection(PassRefPtr base, Type type) - : RefCounted(0) - , m_idsDone(false) + : m_idsDone(false) , m_base(base) , m_type(type) , m_info(m_base->isDocumentNode() ? static_cast(m_base.get())->collectionInfo(type) : 0) @@ -46,8 +45,7 @@ HTMLCollection::HTMLCollection(PassRefPtr base, Type type) } HTMLCollection::HTMLCollection(PassRefPtr base, Type type, CollectionInfo* info) - : RefCounted(0) - , m_idsDone(false) + : m_idsDone(false) , m_base(base) , m_type(type) , m_info(info) @@ -55,6 +53,11 @@ HTMLCollection::HTMLCollection(PassRefPtr base, Type type, CollectionInfo* { } +PassRefPtr HTMLCollection::create(PassRefPtr base, Type type) +{ + return adoptRef(new HTMLCollection(base, type)); +} + HTMLCollection::~HTMLCollection() { if (m_ownsInfo) diff --git a/WebCore/html/HTMLCollection.h b/WebCore/html/HTMLCollection.h index d992c81a80c95ea1641c94ed7ca3857113ef3985..3d75108315440d627277c2c6edf2c2cfdcee811e 100644 --- a/WebCore/html/HTMLCollection.h +++ b/WebCore/html/HTMLCollection.h @@ -76,7 +76,7 @@ public: static const Type FirstNamedDocumentCachedType = WindowNamedItems; static const unsigned NumNamedDocumentCachedTypes = DocumentNamedItems - WindowNamedItems + 1; - HTMLCollection(PassRefPtr base, Type); + static PassRefPtr create(PassRefPtr base, Type); virtual ~HTMLCollection(); unsigned length() const; @@ -139,6 +139,8 @@ protected: mutable bool m_idsDone; // for nextNamedItem() private: + HTMLCollection(PassRefPtr base, Type); + virtual Element* itemAfter(Element*) const; virtual unsigned calcLength() const; virtual void updateNameCache() const; diff --git a/WebCore/html/HTMLElement.cpp b/WebCore/html/HTMLElement.cpp index 23503ef696cd3e7904c778266032edd68558f85d..30dc4758a7b9b2016c0537411ac872fc3a03f6d5 100644 --- a/WebCore/html/HTMLElement.cpp +++ b/WebCore/html/HTMLElement.cpp @@ -703,7 +703,7 @@ void HTMLElement::setTabIndex(int value) PassRefPtr HTMLElement::children() { - return new HTMLCollection(this, HTMLCollection::NodeChildren); + return HTMLCollection::create(this, HTMLCollection::NodeChildren); } // DOM Section 1.1.1 diff --git a/WebCore/html/HTMLFormCollection.cpp b/WebCore/html/HTMLFormCollection.cpp index fd2b836d195faab9f6f709b8ce117821cd3a8145..f9d3b979eb39ed0612407ca08fa48848dbf6f408 100644 --- a/WebCore/html/HTMLFormCollection.cpp +++ b/WebCore/html/HTMLFormCollection.cpp @@ -47,6 +47,11 @@ HTMLFormCollection::HTMLFormCollection(PassRefPtr form) { } +PassRefPtr HTMLFormCollection::create(PassRefPtr form) +{ + return adoptRef(new HTMLFormCollection(form)); +} + HTMLFormCollection::~HTMLFormCollection() { } diff --git a/WebCore/html/HTMLFormCollection.h b/WebCore/html/HTMLFormCollection.h index ae2fb112b891f93b638d01e6d2ac9f817b7fb58f..b81138f8ae884e1a0b80182bb9d6099af410c1f7 100644 --- a/WebCore/html/HTMLFormCollection.h +++ b/WebCore/html/HTMLFormCollection.h @@ -1,7 +1,7 @@ /* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) - * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2003, 2004, 2005, 2006, 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 @@ -35,8 +35,9 @@ class QualifiedName; class HTMLFormCollection : public HTMLCollection { public: - HTMLFormCollection(PassRefPtr); - ~HTMLFormCollection(); + static PassRefPtr create(PassRefPtr); + + virtual ~HTMLFormCollection(); virtual Node* item(unsigned index) const; virtual Node* nextItem() const; @@ -45,6 +46,8 @@ public: virtual Node* nextNamedItem(const String& name) const; private: + HTMLFormCollection(PassRefPtr); + virtual void updateNameCache() const; virtual unsigned calcLength() const; diff --git a/WebCore/html/HTMLFormElement.cpp b/WebCore/html/HTMLFormElement.cpp index 87865051040c93732150aa9e9f0ff91c1b9fdea7..436a87cefa39287f6e07e42d2a614a91d8c7c9c1 100644 --- a/WebCore/html/HTMLFormElement.cpp +++ b/WebCore/html/HTMLFormElement.cpp @@ -618,7 +618,7 @@ void HTMLFormElement::removeImgElement(HTMLImageElement* e) PassRefPtr HTMLFormElement::elements() { - return new HTMLFormCollection(this); + return HTMLFormCollection::create(this); } String HTMLFormElement::name() const diff --git a/WebCore/html/HTMLMapElement.cpp b/WebCore/html/HTMLMapElement.cpp index ef2673ebf482b64c39fe2744c5ed772d74687efa..891f5609400308906ab2ebac116ef275c6b8c41a 100644 --- a/WebCore/html/HTMLMapElement.cpp +++ b/WebCore/html/HTMLMapElement.cpp @@ -95,7 +95,7 @@ void HTMLMapElement::parseMappedAttribute(MappedAttribute* attr) PassRefPtr HTMLMapElement::areas() { - return new HTMLCollection(this, HTMLCollection::MapAreas); + return HTMLCollection::create(this, HTMLCollection::MapAreas); } String HTMLMapElement::name() const diff --git a/WebCore/html/HTMLMediaElement.cpp b/WebCore/html/HTMLMediaElement.cpp index b9464b789cca1428175d60a36ce51fe6a102171a..cd487d265fd7b6d8e156dc0cedd7de8cafa4cf34 100644 --- a/WebCore/html/HTMLMediaElement.cpp +++ b/WebCore/html/HTMLMediaElement.cpp @@ -277,7 +277,7 @@ void HTMLMediaElement::load(ExceptionCode& ec) // 2 if (m_begun) { m_begun = false; - m_error = new MediaError(MediaError::MEDIA_ERR_ABORTED); + m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED); initAndDispatchProgressEvent(abortEvent); if (m_loadNestingLevel < m_terminateLoadBelowNestingLevel) goto end; @@ -363,7 +363,7 @@ void HTMLMediaElement::mediaPlayerNetworkStateChanged(MediaPlayer*) //delete m_player; //m_player = 0; // FIXME better error handling - m_error = new MediaError(MediaError::MEDIA_ERR_NETWORK); + m_error = MediaError::create(MediaError::MEDIA_ERR_NETWORK); m_begun = false; m_progressEventTimer.stop(); m_bufferingRate = 0; @@ -1002,7 +1002,7 @@ void HTMLMediaElement::willSaveToCache() m_player.clear(); m_progressEventTimer.stop(); - m_error = new MediaError(MediaError::MEDIA_ERR_ABORTED); + m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED); m_begun = false; initAndDispatchProgressEvent(abortEvent); if (m_networkState >= LOADING) { diff --git a/WebCore/html/HTMLNameCollection.h b/WebCore/html/HTMLNameCollection.h index 916cced83d56990532528f1f2a55a2bc05a06f60..9add926c2c34ae2609f177c2c7c225d95976332c 100644 --- a/WebCore/html/HTMLNameCollection.h +++ b/WebCore/html/HTMLNameCollection.h @@ -32,9 +32,14 @@ class Document; class HTMLNameCollection : public HTMLCollection { public: - HTMLNameCollection(PassRefPtr, Type, const String& name); + static PassRefPtr create(PassRefPtr document, Type type, const String& name) + { + return adoptRef(new HTMLNameCollection(document, type, name)); + } private: + HTMLNameCollection(PassRefPtr, Type, const String& name); + virtual Element* itemAfter(Element*) const; String m_name; diff --git a/WebCore/html/HTMLOptionsCollection.cpp b/WebCore/html/HTMLOptionsCollection.cpp index d5a1a7f7426b7608a7d63853c1c62d171430f223..0b88183c6a8db92f5103d91088b8251ceb5c9654 100644 --- a/WebCore/html/HTMLOptionsCollection.cpp +++ b/WebCore/html/HTMLOptionsCollection.cpp @@ -34,6 +34,11 @@ HTMLOptionsCollection::HTMLOptionsCollection(PassRefPtr selec { } +PassRefPtr HTMLOptionsCollection::create(PassRefPtr select) +{ + return adoptRef(new HTMLOptionsCollection(select)); +} + void HTMLOptionsCollection::add(PassRefPtr element, ExceptionCode &ec) { add(element, length(), ec); diff --git a/WebCore/html/HTMLOptionsCollection.h b/WebCore/html/HTMLOptionsCollection.h index 9fb5bbfa73ca789c52b66102a090a0ed2bdf0616..a82749bc96fd00954a2c430f1fcf2c588e245c53 100644 --- a/WebCore/html/HTMLOptionsCollection.h +++ b/WebCore/html/HTMLOptionsCollection.h @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2005, 2006, 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 @@ -35,7 +35,7 @@ typedef int ExceptionCode; class HTMLOptionsCollection : public HTMLCollection { public: - HTMLOptionsCollection(PassRefPtr); + static PassRefPtr create(PassRefPtr); void add(PassRefPtr, ExceptionCode&); void add(PassRefPtr, int index, ExceptionCode&); @@ -45,6 +45,9 @@ public: void setSelectedIndex(int); void setLength(unsigned, ExceptionCode&); + +private: + HTMLOptionsCollection(PassRefPtr); }; } //namespace diff --git a/WebCore/html/HTMLSelectElement.cpp b/WebCore/html/HTMLSelectElement.cpp index e66c3433dbee18ca127db584448b06c919046796..cd1646383cd07410afa50e304be8b2e8ab42850f 100644 --- a/WebCore/html/HTMLSelectElement.cpp +++ b/WebCore/html/HTMLSelectElement.cpp @@ -492,7 +492,7 @@ int HTMLSelectElement::listToOptionIndex(int listIndex) const PassRefPtr HTMLSelectElement::options() { - return new HTMLOptionsCollection(this); + return HTMLOptionsCollection::create(this); } void HTMLSelectElement::recalcListItems(bool updateSelectedStates) const diff --git a/WebCore/html/HTMLTableElement.cpp b/WebCore/html/HTMLTableElement.cpp index c7791f5842b74dd6ab1f1abcc46248bf172000b4..6cc4d656cf91659a0b16f0b991d82be9225ddae5 100644 --- a/WebCore/html/HTMLTableElement.cpp +++ b/WebCore/html/HTMLTableElement.cpp @@ -658,12 +658,12 @@ bool HTMLTableElement::isURLAttribute(Attribute *attr) const PassRefPtr HTMLTableElement::rows() { - return new HTMLTableRowsCollection(this); + return HTMLTableRowsCollection::create(this); } PassRefPtr HTMLTableElement::tBodies() { - return new HTMLCollection(this, HTMLCollection::TableTBodies); + return HTMLCollection::create(this, HTMLCollection::TableTBodies); } String HTMLTableElement::align() const diff --git a/WebCore/html/HTMLTableRowElement.cpp b/WebCore/html/HTMLTableRowElement.cpp index a9558a0f2344c7e3c88d88cbc2d9cb856954c5ef..da075947389d7c4c28b433a2b849376576410297 100644 --- a/WebCore/html/HTMLTableRowElement.cpp +++ b/WebCore/html/HTMLTableRowElement.cpp @@ -167,7 +167,7 @@ void HTMLTableRowElement::deleteCell(int index, ExceptionCode& ec) PassRefPtr HTMLTableRowElement::cells() { - return new HTMLCollection(this, HTMLCollection::TRCells); + return HTMLCollection::create(this, HTMLCollection::TRCells); } void HTMLTableRowElement::setCells(HTMLCollection *, ExceptionCode& ec) diff --git a/WebCore/html/HTMLTableRowsCollection.cpp b/WebCore/html/HTMLTableRowsCollection.cpp index 3630fdc84ef45adeb6499cd466726cb8cc784806..704757649146e20e0b419358982e09a1e094785e 100644 --- a/WebCore/html/HTMLTableRowsCollection.cpp +++ b/WebCore/html/HTMLTableRowsCollection.cpp @@ -149,10 +149,15 @@ HTMLTableRowElement* HTMLTableRowsCollection::lastRow(HTMLTableElement* table) } HTMLTableRowsCollection::HTMLTableRowsCollection(PassRefPtr table) - : HTMLCollection(table, Other) + : HTMLCollection(table, Other, 0) { } +PassRefPtr HTMLTableRowsCollection::create(PassRefPtr table) +{ + return adoptRef(new HTMLTableRowsCollection(table)); +} + Element* HTMLTableRowsCollection::itemAfter(Element* previous) const { ASSERT(!previous || previous->hasLocalName(trTag)); diff --git a/WebCore/html/HTMLTableRowsCollection.h b/WebCore/html/HTMLTableRowsCollection.h index 9acce69ffe6e25b50eaa017b914c660a1ebac2bf..f997e3c42f83cbf3f253c5350a40f94c9fc0f7eb 100644 --- a/WebCore/html/HTMLTableRowsCollection.h +++ b/WebCore/html/HTMLTableRowsCollection.h @@ -38,12 +38,14 @@ class HTMLTableRowElement; class HTMLTableRowsCollection : public HTMLCollection { public: - HTMLTableRowsCollection(PassRefPtr); + static PassRefPtr create(PassRefPtr); static HTMLTableRowElement* rowAfter(HTMLTableElement*, HTMLTableRowElement*); static HTMLTableRowElement* lastRow(HTMLTableElement*); private: + HTMLTableRowsCollection(PassRefPtr); + virtual Element* itemAfter(Element*) const; }; diff --git a/WebCore/html/HTMLTableSectionElement.cpp b/WebCore/html/HTMLTableSectionElement.cpp index 15999e0b0d742dc9522aeaab12715c628ed3c66d..8190d93a43d3477be42d3f09c0e9bedd09dddd67 100644 --- a/WebCore/html/HTMLTableSectionElement.cpp +++ b/WebCore/html/HTMLTableSectionElement.cpp @@ -169,7 +169,7 @@ void HTMLTableSectionElement::setVAlign(const String &value) PassRefPtr HTMLTableSectionElement::rows() { - return new HTMLCollection(this, HTMLCollection::TSectionRows); + return HTMLCollection::create(this, HTMLCollection::TSectionRows); } } diff --git a/WebCore/html/MediaError.h b/WebCore/html/MediaError.h index 02b16dad11b3447e9dbea7def149e6f08c54f4f3..fbf375fb8e5cd6d6fcbf177144347be987247a16 100644 --- a/WebCore/html/MediaError.h +++ b/WebCore/html/MediaError.h @@ -36,11 +36,13 @@ class MediaError : public RefCounted { public: enum Code { MEDIA_ERR_ABORTED = 1, MEDIA_ERR_NETWORK, MEDIA_ERR_DECODE }; - MediaError(Code code) : RefCounted(0), m_code(code) { } + static PassRefPtr create(Code code) { return adoptRef(new MediaError(code)); } Code code() const { return m_code; } private: + MediaError(Code code) : m_code(code) { } + Code m_code; }; diff --git a/WebCore/loader/CachedCSSStyleSheet.cpp b/WebCore/loader/CachedCSSStyleSheet.cpp index 491fdc8ac8ba314228b257be470c207421cf265f..91211f502797591019b8a1a2c9d5def18efbd403 100644 --- a/WebCore/loader/CachedCSSStyleSheet.cpp +++ b/WebCore/loader/CachedCSSStyleSheet.cpp @@ -38,7 +38,7 @@ namespace WebCore { CachedCSSStyleSheet::CachedCSSStyleSheet(const String& url, const String& charset) : CachedResource(url, CSSStyleSheet) - , m_decoder(new TextResourceDecoder("text/css", charset)) + , m_decoder(TextResourceDecoder::create("text/css", charset)) { // Prefer text/css but accept any type (dell.com serves a stylesheet // as text/html; see ). diff --git a/WebCore/loader/CachedFont.cpp b/WebCore/loader/CachedFont.cpp index 6217d11831197a73d8b56eafb2056ef08c76b1a9..a89160ead08b61336fcbcbc3388b066f72dae54f 100644 --- a/WebCore/loader/CachedFont.cpp +++ b/WebCore/loader/CachedFont.cpp @@ -135,9 +135,9 @@ bool CachedFont::ensureSVGFontData() m_externalSVGDocument = new SVGDocument(DOMImplementation::instance(), 0); m_externalSVGDocument->open(); - TextResourceDecoder decoder("application/xml"); - m_externalSVGDocument->write(decoder.decode(m_data->data(), m_data->size())); - if (decoder.sawError()) { + RefPtr decoder = TextResourceDecoder::create("application/xml"); + m_externalSVGDocument->write(decoder->decode(m_data->data(), m_data->size())); + if (decoder->sawError()) { m_externalSVGDocument.clear(); return 0; } diff --git a/WebCore/loader/CachedXSLStyleSheet.cpp b/WebCore/loader/CachedXSLStyleSheet.cpp index f3a455f7704260f194a6eab0279e06cf2b9ce79a..54d01e4558e1bd928cab9204193f871b6149b676 100644 --- a/WebCore/loader/CachedXSLStyleSheet.cpp +++ b/WebCore/loader/CachedXSLStyleSheet.cpp @@ -42,7 +42,7 @@ namespace WebCore { CachedXSLStyleSheet::CachedXSLStyleSheet(const String &url) : CachedResource(url, XSLStyleSheet) - , m_decoder(new TextResourceDecoder("text/xsl")) + , m_decoder(TextResourceDecoder::create("text/xsl")) { // It's XML we want. // FIXME: This should accept more general xml formats */*+xml, image/svg+xml for example. diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp index 68f17755bd5c5ce565f7c5a47e678d3575f65f98..2d4cf1d0ee6894251fcaef90c669e6a6e9b7a77a 100644 --- a/WebCore/loader/FrameLoader.cpp +++ b/WebCore/loader/FrameLoader.cpp @@ -996,7 +996,7 @@ void FrameLoader::write(const char* str, int len, bool flush) if (!m_decoder) { Settings* settings = m_frame->settings(); - m_decoder = new TextResourceDecoder(m_responseMIMEType, settings ? settings->defaultTextEncodingName() : String()); + m_decoder = TextResourceDecoder::create(m_responseMIMEType, settings ? settings->defaultTextEncodingName() : String()); if (m_encoding.isEmpty()) { Frame* parentFrame = m_frame->tree()->parent(); if (parentFrame && parentFrame->document()->securityOrigin()->canAccess(m_frame->document()->securityOrigin())) @@ -3974,7 +3974,7 @@ PassRefPtr FrameLoader::createHistoryItem(bool useOriginal) if (originalURL.isEmpty()) originalURL = blankURL(); - RefPtr item = new HistoryItem(url, m_frame->tree()->name(), m_frame->tree()->parent() ? m_frame->tree()->parent()->tree()->name() : "", docLoader ? docLoader->title() : ""); + RefPtr item = HistoryItem::create(url, m_frame->tree()->name(), m_frame->tree()->parent() ? m_frame->tree()->parent()->tree()->name() : "", docLoader ? docLoader->title() : ""); item->setOriginalURLString(originalURL.string()); // Save form state if this is a POST diff --git a/WebCore/loader/ImageDocument.cpp b/WebCore/loader/ImageDocument.cpp index 3b24a258a7c412a59265e813f8cffb98a4891048..75f664ba55e10b669d17fc60c2e11cc50f2cb483 100644 --- a/WebCore/loader/ImageDocument.cpp +++ b/WebCore/loader/ImageDocument.cpp @@ -52,10 +52,11 @@ using namespace HTMLNames; class ImageEventListener : public EventListener { public: - ImageEventListener(ImageDocument* doc) : m_doc(doc) { } + static PassRefPtr create(ImageDocument* document) { return adoptRef(new ImageEventListener(document)); } virtual void handleEvent(Event*, bool isWindowEvent); private: + ImageEventListener(ImageDocument* document) : m_doc(document) { } ImageDocument* m_doc; }; @@ -173,7 +174,7 @@ void ImageDocument::createDocumentStructure() if (shouldShrinkToFit()) { // Add event listeners - RefPtr listener = new ImageEventListener(this); + RefPtr listener = ImageEventListener::create(this); addWindowEventListener("resize", listener, false); imageElement->addEventListener("click", listener.release(), false); } diff --git a/WebCore/loader/TextResourceDecoder.cpp b/WebCore/loader/TextResourceDecoder.cpp index a1d5bc6213471ef8dc8d635a0db665890e2994e7..93018d9754c5b89b0d1a3c3a2a31123704b4f7ac 100644 --- a/WebCore/loader/TextResourceDecoder.cpp +++ b/WebCore/loader/TextResourceDecoder.cpp @@ -320,8 +320,7 @@ const TextEncoding& TextResourceDecoder::defaultEncoding(ContentType contentType } TextResourceDecoder::TextResourceDecoder(const String& mimeType, const TextEncoding& specifiedDefaultEncoding) - : RefCounted(0) - , m_contentType(determineContentType(mimeType)) + : m_contentType(determineContentType(mimeType)) , m_decoder(defaultEncoding(m_contentType, specifiedDefaultEncoding)) , m_source(DefaultEncoding) , m_checkedForBOM(false) diff --git a/WebCore/loader/TextResourceDecoder.h b/WebCore/loader/TextResourceDecoder.h index 1dd9d58feb9bfae451f2a566dc3b831b1638fcc4..8bbe85e3c43b16588f0302f1c93fa846819b0b33 100644 --- a/WebCore/loader/TextResourceDecoder.h +++ b/WebCore/loader/TextResourceDecoder.h @@ -1,9 +1,7 @@ /* - This file is part of the KDE libraries - Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de) Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) - Copyright (C) 2006 Apple Computer, Inc. + Copyright (C) 2006, 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 @@ -25,10 +23,7 @@ #ifndef TextResourceDecoder_h #define TextResourceDecoder_h -#include "PlatformString.h" -#include #include "TextDecoder.h" -#include namespace WebCore { @@ -44,7 +39,10 @@ public: UserChosenEncoding }; - TextResourceDecoder(const String& mimeType, const TextEncoding& defaultEncoding = TextEncoding()); + static PassRefPtr create(const String& mimeType, const TextEncoding& defaultEncoding = TextEncoding()) + { + return adoptRef(new TextResourceDecoder(mimeType, defaultEncoding)); + } ~TextResourceDecoder(); void setEncoding(const TextEncoding&, EncodingSource); @@ -56,6 +54,8 @@ public: bool sawError() const { return m_sawError; } private: + TextResourceDecoder(const String& mimeType, const TextEncoding& defaultEncoding); + enum ContentType { PlainText, HTML, XML, CSS }; // PlainText is equivalent to directly using TextDecoder. static ContentType determineContentType(const String& mimeType); static const TextEncoding& defaultEncoding(ContentType, const TextEncoding& defaultEncoding); diff --git a/WebCore/loader/appcache/DOMApplicationCache.h b/WebCore/loader/appcache/DOMApplicationCache.h index 5f9dd65e482da70aea707184233438325adf23b3..7d0e78815b13bac5d97cfb204388967a6eef11e7 100644 --- a/WebCore/loader/appcache/DOMApplicationCache.h +++ b/WebCore/loader/appcache/DOMApplicationCache.h @@ -78,25 +78,25 @@ public: using RefCounted::ref; using RefCounted::deref; - void setOnCheckingListener(EventListener* eventListener) { m_onCheckingListener = eventListener; } + void setOnCheckingListener(PassRefPtr eventListener) { m_onCheckingListener = eventListener; } EventListener* onCheckingListener() const { return m_onCheckingListener.get(); } - void setOnErrorListener(EventListener* eventListener) { m_onErrorListener = eventListener; } + void setOnErrorListener(PassRefPtr eventListener) { m_onErrorListener = eventListener; } EventListener* onErrorListener() const { return m_onErrorListener.get(); } - void setOnNoUpdateListener(EventListener* eventListener) { m_onNoUpdateListener = eventListener; } + void setOnNoUpdateListener(PassRefPtr eventListener) { m_onNoUpdateListener = eventListener; } EventListener* onNoUpdateListener() const { return m_onNoUpdateListener.get(); } - void setOnDownloadingListener(EventListener* eventListener) { m_onDownloadingListener = eventListener; } + void setOnDownloadingListener(PassRefPtr eventListener) { m_onDownloadingListener = eventListener; } EventListener* onDownloadingListener() const { return m_onDownloadingListener.get(); } - void setOnProgressListener(EventListener* eventListener) { m_onProgressListener = eventListener; } + void setOnProgressListener(PassRefPtr eventListener) { m_onProgressListener = eventListener; } EventListener* onProgressListener() const { return m_onProgressListener.get(); } - void setOnUpdateReadyListener(EventListener* eventListener) { m_onUpdateReadyListener = eventListener; } + void setOnUpdateReadyListener(PassRefPtr eventListener) { m_onUpdateReadyListener = eventListener; } EventListener* onUpdateReadyListener() const { return m_onUpdateReadyListener.get(); } - void setOnCachedListener(EventListener* eventListener) { m_onCachedListener = eventListener; } + void setOnCachedListener(PassRefPtr eventListener) { m_onCachedListener = eventListener; } EventListener* onCachedListener() const { return m_onCachedListener.get(); } Frame* frame() const { return m_frame; } @@ -111,8 +111,8 @@ public: void callCachedListener(); private: - DOMApplicationCache(Frame* frame); - void callListener(const AtomicString& eventType, EventListener* listener); + DOMApplicationCache(Frame*); + void callListener(const AtomicString& eventType, EventListener*); virtual void refEventTarget() { ref(); } virtual void derefEventTarget() { deref(); } diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp index c8b08f0a232388f47a246830dca85ec3a62c8c77..bf3aec6a2b4188db13eb05874fa7b09c7dca65b4 100644 --- a/WebCore/page/Page.cpp +++ b/WebCore/page/Page.cpp @@ -435,7 +435,7 @@ const String& Page::userStyleSheet() const if (!data) return m_userStyleSheet; - m_userStyleSheet = TextResourceDecoder("text/css").decode(data->data(), data->size()); + m_userStyleSheet = TextResourceDecoder::create("text/css")->decode(data->data(), data->size()); return m_userStyleSheet; } diff --git a/WebCore/svg/SVGException.h b/WebCore/svg/SVGException.h index aa82e703c9bf1f59a034a9c729c676d6fbdfb5af..b82adf758c33b82e38ace2e6c7b1ecd57beb8e35 100644 --- a/WebCore/svg/SVGException.h +++ b/WebCore/svg/SVGException.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2006 Samuel Weinig - * Copyright (C) 2006 Apple Computer, Inc. + * Copyright (C) 2006, 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 @@ -22,17 +22,17 @@ #ifndef SVGException_h #define SVGException_h -#if ENABLE(SVG) - #include "ExceptionBase.h" +#if ENABLE(SVG) + namespace WebCore { class SVGException : public ExceptionBase { public: - SVGException(const ExceptionCodeDescription& description) - : ExceptionBase(description) + static PassRefPtr create(const ExceptionCodeDescription& description) { + return adoptRef(new SVGException(description)); } static const int SVGExceptionOffset = 300; @@ -43,6 +43,12 @@ namespace WebCore { SVG_INVALID_VALUE_ERR = SVGExceptionOffset + 1, SVG_MATRIX_NOT_INVERTABLE = SVGExceptionOffset + 2 }; + + private: + SVGException(const ExceptionCodeDescription& description) + : ExceptionBase(description) + { + } }; } // namespace WebCore diff --git a/WebCore/svg/animation/SVGSMILElement.cpp b/WebCore/svg/animation/SVGSMILElement.cpp index b1f6c6a3eeca68350029c89f848cb35eeed651f0..a07a4071ef6fe15f7e8db43ce5ef029ba2e29b34 100644 --- a/WebCore/svg/animation/SVGSMILElement.cpp +++ b/WebCore/svg/animation/SVGSMILElement.cpp @@ -53,12 +53,9 @@ static const double invalidCachedTime = -1.; class ConditionEventListener : public EventListener { public: - ConditionEventListener(SVGSMILElement* animation, Element* eventBase, SVGSMILElement::Condition* condition) - : m_animation(animation) - , m_condition(condition) - , m_eventBase(eventBase) + static PassRefPtr create(SVGSMILElement* animation, Element* eventBase, SVGSMILElement::Condition* condition) { - m_eventBase->addEventListener(m_condition->m_name, this, false); + return adoptRef(new ConditionEventListener(animation, eventBase, condition)); } void unregister() @@ -72,7 +69,16 @@ public: { m_animation->handleConditionEvent(event, m_condition); } + private: + ConditionEventListener(SVGSMILElement* animation, Element* eventBase, SVGSMILElement::Condition* condition) + : m_animation(animation) + , m_condition(condition) + , m_eventBase(eventBase) + { + m_eventBase->addEventListener(m_condition->m_name, this, false); + } + SVGSMILElement* m_animation; SVGSMILElement::Condition* m_condition; Element* m_eventBase; @@ -377,7 +383,7 @@ void SVGSMILElement::connectConditions() if (!eventBase) continue; ASSERT(!condition.m_eventListener); - condition.m_eventListener = new ConditionEventListener(this, eventBase, &condition); + condition.m_eventListener = ConditionEventListener::create(this, eventBase, &condition); } else if (condition.m_type == Condition::Syncbase) { ASSERT(!condition.m_baseID.isEmpty()); condition.m_syncbase = document()->getElementById(condition.m_baseID); diff --git a/WebCore/xml/XMLHttpRequest.cpp b/WebCore/xml/XMLHttpRequest.cpp index 254bd9603d3ba07bd9356547fc0f9092f5a358a3..60cdefad84aea987aa819dda30c878f8e3a5405f 100644 --- a/WebCore/xml/XMLHttpRequest.cpp +++ b/WebCore/xml/XMLHttpRequest.cpp @@ -205,7 +205,7 @@ EventListener* XMLHttpRequest::onReadyStateChangeListener() const return m_onReadyStateChangeListener.get(); } -void XMLHttpRequest::setOnReadyStateChangeListener(EventListener* eventListener) +void XMLHttpRequest::setOnReadyStateChangeListener(PassRefPtr eventListener) { m_onReadyStateChangeListener = eventListener; } @@ -220,12 +220,12 @@ EventListener* XMLHttpRequest::onProgressListener() const return m_onProgressListener.get(); } -void XMLHttpRequest::setOnLoadListener(EventListener* eventListener) +void XMLHttpRequest::setOnLoadListener(PassRefPtr eventListener) { m_onLoadListener = eventListener; } -void XMLHttpRequest::setOnProgressListener(EventListener* eventListener) +void XMLHttpRequest::setOnProgressListener(PassRefPtr eventListener) { m_onProgressListener = eventListener; } @@ -933,14 +933,14 @@ void XMLHttpRequest::didReceiveData(SubresourceLoader*, const char* data, int le if (!m_decoder) { if (!m_responseEncoding.isEmpty()) - m_decoder = new TextResourceDecoder("text/plain", m_responseEncoding); + m_decoder = TextResourceDecoder::create("text/plain", m_responseEncoding); // allow TextResourceDecoder to look inside the m_response if it's XML or HTML else if (responseIsXML()) - m_decoder = new TextResourceDecoder("application/xml"); + m_decoder = TextResourceDecoder::create("application/xml"); else if (responseMIMEType() == "text/html") - m_decoder = new TextResourceDecoder("text/html", "UTF-8"); + m_decoder = TextResourceDecoder::create("text/html", "UTF-8"); else - m_decoder = new TextResourceDecoder("text/plain", "UTF-8"); + m_decoder = TextResourceDecoder::create("text/plain", "UTF-8"); } if (len == 0) return; diff --git a/WebCore/xml/XMLHttpRequest.h b/WebCore/xml/XMLHttpRequest.h index 48dc7d78cc170231a252563574714532d62eab20..31ee9525785de59ae74dba1e51a1dc1bc5fcc402 100644 --- a/WebCore/xml/XMLHttpRequest.h +++ b/WebCore/xml/XMLHttpRequest.h @@ -65,11 +65,11 @@ public: const KJS::UString& responseText() const; Document* responseXML() const; - void setOnReadyStateChangeListener(EventListener*); + void setOnReadyStateChangeListener(PassRefPtr); EventListener* onReadyStateChangeListener() const; - void setOnLoadListener(EventListener*); + void setOnLoadListener(PassRefPtr); EventListener* onLoadListener() const; - void setOnProgressListener(EventListener*); + void setOnProgressListener(PassRefPtr); EventListener* onProgressListener() const; typedef Vector > ListenerVector; diff --git a/WebCore/xml/XMLHttpRequestException.h b/WebCore/xml/XMLHttpRequestException.h index e9e6f786913284db7ffe71c0df18ce72815f2b30..737cab0410623929b8b350a400a78df080872fdd 100644 --- a/WebCore/xml/XMLHttpRequestException.h +++ b/WebCore/xml/XMLHttpRequestException.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,9 +35,9 @@ namespace WebCore { class XMLHttpRequestException : public ExceptionBase { public: - XMLHttpRequestException(const ExceptionCodeDescription& description) - : ExceptionBase(description) + static PassRefPtr create(const ExceptionCodeDescription& description) { + return adoptRef(new XMLHttpRequestException(description)); } static const int XMLHttpRequestExceptionOffset = 500; @@ -47,6 +47,12 @@ namespace WebCore { NETWORK_ERR = XMLHttpRequestExceptionOffset + 101, ABORT_ERR }; + + private: + XMLHttpRequestException(const ExceptionCodeDescription& description) + : ExceptionBase(description) + { + } }; } // namespace WebCore diff --git a/WebCore/xml/XPathException.h b/WebCore/xml/XPathException.h index aa3585c6828dd890c469db66427b708b39008a4a..45ad6283a49b178b253ec522c112fcd1df3c1e76 100644 --- a/WebCore/xml/XPathException.h +++ b/WebCore/xml/XPathException.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,17 +29,17 @@ #ifndef XPathException_h #define XPathException_h -#if ENABLE(XPATH) - #include "ExceptionBase.h" +#if ENABLE(XPATH) + namespace WebCore { class XPathException : public ExceptionBase { public: - XPathException(const ExceptionCodeDescription& description) - : ExceptionBase(description) + static PassRefPtr create(const ExceptionCodeDescription& description) { + return adoptRef(new XPathException(description)); } static const int XPathExceptionOffset = 400; @@ -49,6 +49,12 @@ namespace WebCore { INVALID_EXPRESSION_ERR = XPathExceptionOffset + 51, TYPE_ERR }; + + private: + XPathException(const ExceptionCodeDescription& description) + : ExceptionBase(description) + { + } }; } // namespace WebCore diff --git a/WebCore/xml/XPathResult.cpp b/WebCore/xml/XPathResult.cpp index e7c4db3ffb747f4e32a6dd2b489a7a5858ee363b..da377f7c0f702a18a8bbd21a5c77f8a6f86a7621 100644 --- a/WebCore/xml/XPathResult.cpp +++ b/WebCore/xml/XPathResult.cpp @@ -42,9 +42,11 @@ using namespace XPath; class InvalidatingEventListener : public EventListener { public: - InvalidatingEventListener(XPathResult* result) : m_result(result) { } + static PassRefPtr create(XPathResult* result) { return adoptRef(new InvalidatingEventListener(result)); } virtual void handleEvent(Event*, bool) { m_result->invalidateIteratorState(); } + private: + InvalidatingEventListener(XPathResult* result) : m_result(result) { } XPathResult* m_result; }; @@ -52,7 +54,7 @@ XPathResult::XPathResult(EventTargetNode* eventTarget, const Value& value) : m_value(value) , m_eventTarget(eventTarget) { - m_eventListener = new InvalidatingEventListener(this); + m_eventListener = InvalidatingEventListener::create(this); m_eventTarget->addEventListener(EventNames::DOMSubtreeModifiedEvent, m_eventListener, false); switch (m_value.type()) { case Value::BooleanValue: diff --git a/WebCore/xml/XSLTProcessor.cpp b/WebCore/xml/XSLTProcessor.cpp index 7ffa7d3f55850724e968725eda6386dfa6aaff17..41a933dc8cf03926e6fa3ad3cf01f4a7c3f7155e 100644 --- a/WebCore/xml/XSLTProcessor.cpp +++ b/WebCore/xml/XSLTProcessor.cpp @@ -269,9 +269,9 @@ RefPtr XSLTProcessor::createDocumentFromSource(const String& sourceStr } result->open(); - RefPtr decoder = new TextResourceDecoder(sourceMIMEType); + RefPtr decoder = TextResourceDecoder::create(sourceMIMEType); decoder->setEncoding(sourceEncoding.isEmpty() ? UTF8Encoding() : TextEncoding(sourceEncoding), TextResourceDecoder::EncodingFromXMLHeader); - result->setDecoder(decoder.get()); + result->setDecoder(decoder.release()); result->write(documentSource); result->finishParsing(); diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog index a3069c89f1d253a14da9cca7afde779e676cf0d2..bbb30102b08a53d36c135d77312b9b1f36579f87 100644 --- a/WebKit/mac/ChangeLog +++ b/WebKit/mac/ChangeLog @@ -1,3 +1,18 @@ +2008-06-07 Darin Adler + + Reviewed by Mitz. + + - work on https://bugs.webkit.org/show_bug.cgi?id=17257 + start ref counts at 1 instead of 0 for speed + + * History/WebHistoryItem.mm: + (-[WebHistoryItem init]): + (-[WebHistoryItem initWithURLString:title:lastVisitedTimeInterval:]): + (-[WebHistoryItem initWithURL:target:parent:title:]): + (-[WebHistoryItem initWithURLString:title:displayTitle:lastVisitedTimeInterval:]): + * WebView/WebView.mm: + (+[WebView _decodeData:]): + 2008-06-03 Oliver Hunt Reviewed by Tim. diff --git a/WebKit/mac/History/WebHistoryItem.mm b/WebKit/mac/History/WebHistoryItem.mm index 7ee1f178d80e07fe9fbcdf5731cb2006dfddc7a1..7d0bb4fa5173e4a5c4bd202a4cb35789fd42152a 100644 --- a/WebKit/mac/History/WebHistoryItem.mm +++ b/WebKit/mac/History/WebHistoryItem.mm @@ -91,13 +91,13 @@ void WKNotifyHistoryItemChanged() - (id)init { - return [self initWithWebCoreHistoryItem:(new HistoryItem)]; + return [self initWithWebCoreHistoryItem:HistoryItem::create()]; } - (id)initWithURLString:(NSString *)URLString title:(NSString *)title lastVisitedTimeInterval:(NSTimeInterval)time { WebCoreThreadViolationCheck(); - return [self initWithWebCoreHistoryItem:(new HistoryItem(URLString, title, time))]; + return [self initWithWebCoreHistoryItem:HistoryItem::create(URLString, title, time)]; } - (void)dealloc @@ -276,12 +276,12 @@ static WebWindowWatcher *_windowWatcher = nil; - (id)initWithURL:(NSURL *)URL target:(NSString *)target parent:(NSString *)parent title:(NSString *)title { - return [self initWithWebCoreHistoryItem:(new HistoryItem(URL, target, parent, title))]; + return [self initWithWebCoreHistoryItem:HistoryItem::create(URL, target, parent, title)]; } - (id)initWithURLString:(NSString *)URLString title:(NSString *)title displayTitle:(NSString *)displayTitle lastVisitedTimeInterval:(NSTimeInterval)time { - return [self initWithWebCoreHistoryItem:(new HistoryItem(URLString, title, displayTitle, time))]; + return [self initWithWebCoreHistoryItem:HistoryItem::create(URLString, title, displayTitle, time)]; } - (id)initWithWebCoreHistoryItem:(PassRefPtr)item diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm index a4a6d2ac7d5de2221f7ab58f3042511cce1c8ec5..a22809d0c27424e187445209d1e55ca4c68f75e1 100644 --- a/WebKit/mac/WebView/WebView.mm +++ b/WebKit/mac/WebView/WebView.mm @@ -1192,7 +1192,7 @@ WebFrameLoadDelegateImplementationCache* WebViewGetFrameLoadDelegateImplementati + (NSString *)_decodeData:(NSData *)data { HTMLNames::init(); // this method is used for importing bookmarks at startup, so HTMLNames are likely to be uninitialized yet - RefPtr decoder = new TextResourceDecoder("text/html"); // bookmark files are HTML + RefPtr decoder = TextResourceDecoder::create("text/html"); // bookmark files are HTML String result = decoder->decode(static_cast([data bytes]), [data length]); result += decoder->flush(); return result; diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog index 2a5d852e0ba3738e8ef3dfbe30131bceb6f57ef2..6edb72b88cd45158dc152d3dd88992fdaa78f266 100644 --- a/WebKit/win/ChangeLog +++ b/WebKit/win/ChangeLog @@ -1,3 +1,15 @@ +2008-06-07 Darin Adler + + Reviewed by Mitz. + + - work on https://bugs.webkit.org/show_bug.cgi?id=17257 + start ref counts at 1 instead of 0 for speed + + * WebHistoryItem.cpp: + (WebHistoryItem::createInstance): + (WebHistoryItem::initFromDictionaryRepresentation): + (WebHistoryItem::initWithURLString): + 2008-05-30 Steve Falkenburg Registry-free COM. diff --git a/WebKit/win/WebHistoryItem.cpp b/WebKit/win/WebHistoryItem.cpp index c0469a73260c8a1f51a63927ec14285da094f18e..a2fd9d9a7f065bca770276f93231557801ce92c5 100644 --- a/WebKit/win/WebHistoryItem.cpp +++ b/WebKit/win/WebHistoryItem.cpp @@ -68,7 +68,7 @@ WebHistoryItem::~WebHistoryItem() WebHistoryItem* WebHistoryItem::createInstance() { - WebHistoryItem* instance = new WebHistoryItem(new HistoryItem); + WebHistoryItem* instance = new WebHistoryItem(HistoryItem::create()); instance->AddRef(); return instance; } @@ -126,7 +126,7 @@ HRESULT STDMETHODCALLTYPE WebHistoryItem::initFromDictionaryRepresentation(void* } historyItemWrappers().remove(m_historyItem.get()); - m_historyItem = new HistoryItem(urlStringRef, titleRef, lastVisitedTime); + m_historyItem = HistoryItem::create(urlStringRef, titleRef, lastVisitedTime); historyItemWrappers().set(m_historyItem.get(), this); if (!CFNumberGetValue(visitCountRef, kCFNumberIntType, &visitedCount)) { @@ -360,7 +360,7 @@ HRESULT STDMETHODCALLTYPE WebHistoryItem::initWithURLString( /* [in] */ DATE lastVisited) { historyItemWrappers().remove(m_historyItem.get()); - m_historyItem = new HistoryItem(String(urlString, SysStringLen(urlString)), String(title, SysStringLen(title)), MarshallingHelpers::DATEToCFAbsoluteTime(lastVisited)); + m_historyItem = HistoryItem::create(String(urlString, SysStringLen(urlString)), String(title, SysStringLen(title)), MarshallingHelpers::DATEToCFAbsoluteTime(lastVisited)); historyItemWrappers().set(m_historyItem.get(), this); return S_OK;