Reviewed by Kevin.

	<rdar://problem/3878766> VIP: Program listings pages at directv.com takes 75% of time traversing NodeLists

        * khtml/dom/dom_node.cpp:
        (NodeList::itemById): New method, just forward to impl.
        * khtml/dom/dom_node.h: Prototype it.
        * khtml/ecma/kjs_dom.cpp:
        (DOMNodeList::tryGet): Instead of looping over the whole list to do by-id access,
	let the NodeList do it. The NodeList might be able to do it more efficiently.
        * khtml/xml/dom_nodeimpl.cpp:
	(NodeListImpl::itemById): Optimize for the case where the NodeList
	covers the whole document. In this case, just use getElementById,
	then check that the element satisfies the list criteria.
        (ChildNodeListImpl::nodeMatches): Return true only if the node is our child.
        (TagNodeListImpl::TagNodeListImpl): Irrelevant change to reformat initializers.
        * khtml/xml/dom_nodeimpl.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        Reviewed by mjs.

	fixed: <rdar://problem/3823038> LEAK: huge leak in DOM::HTMLElementImpl::createContextualFragment(DOM::DOMString const&, bool)

        * khtml/html/html_elementimpl.cpp:
        (HTMLElementImpl::setInnerHTML): uses the ref counting system to deallocate fragments instead of explicitly invoking a destructor.
        (HTMLElementImpl::setOuterHTML): function is responsible for derefing the fragment prior to returning. Now it does.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8002 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        Reviewed by Ken.

        - fixed <rdar://problem/3879513> leak in [WebArchive _propertyListRepresentation] copying HTML to pasteboard

        * WebView.subproj/WebArchive.m:
        (-[WebArchive _propertyListRepresentation]):
        the array holding the subresources was not released after use, oops!


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8003 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        Reviewed by Ken.

        - fixed <rdar://problem/3879539> leak of NSString after pasting into editable HTML (e.g. Mail)

        * kwq/KWQKHTMLPart.mm:
        (KWQKHTMLPart::documentFragmentWithText):
        release mutable copy of string after we're done using it


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8004 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        Reviewed by John.

	<rdar://problem/3879226> WebKit needlessly uses extra memory to store icon refcounts as NSNumbers

	* Misc.subproj/WebIconDatabase.m:
        (-[WebIconDatabase init]):
        (-[WebIconDatabase _setIconURL:forURL:]):
        (-[WebIconDatabase _retainIconForIconURLString:]):
        (-[WebIconDatabase _releaseIconForIconURLString:]):
        (-[WebIconDatabase _retainFutureIconForURL:]):
        (-[WebIconDatabase _releaseFutureIconForURL:]):
        * Misc.subproj/WebIconDatabasePrivate.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8005 268f45cc-cd09-0410-ab3c-d52691b4dbfc
	Cache image properties and frame durations.
	Create NSImage and TIFF representations from CGImage, lazily, as needed for
	dragging and element info dictionary.

        Reviewed by John.

        * WebCoreSupport.subproj/WebImageData.h:
        * WebCoreSupport.subproj/WebImageData.m:
        (-[WebImageData dealloc]):
        (-[WebImageData size]):
        (-[WebImageData propertiesAtIndex:]):
        (-[WebImageData _frameDurationAt:]):
        (-[WebImageData _frameDuration]):
        * WebCoreSupport.subproj/WebImageRenderer.h:
        * WebCoreSupport.subproj/WebImageRenderer.m:
        (-[WebImageRenderer dealloc]):
        (-[WebImageRenderer TIFFRepresentation]):
        (-[WebImageRenderer image]):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8006 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        Reviewed by Kevin.

	<rdar://problem/3807080> Safari so slow it seems like a hang accessing a page on an IBM website

        * khtml/xml/dom_nodeimpl.cpp:
        (NodeListImpl::NodeListImpl): Initialize isItemCacheValid, renamed isCacheValid to
	isLengthCacheValid.
        (NodeListImpl::recursiveLength): Adjusted for rename.
        (NodeListImpl::recursiveItem): Cache the last item accessed and its offset.
	If the same offset is looked up again, just return it, otherwise, if looking up
	a later offset, start at the last item and proceed from there.
        (NodeListImpl::itemById): Apply the special document optimization to all
	nodes that are either a document or in a document - just walk up to make
	sure the node found by ID has the root node as an ancestor.
        (NodeListImpl::rootNodeSubtreeModified): Adjust both cache bits.
        * khtml/xml/dom_nodeimpl.h: Prototype new stuff.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8007 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        Reviewed by John

        Fix for this bug:

        <rdar://problem/3879569> Many leaks in EditCommand mechanism, seen in Mail

        Fixed a couple of object lifetime issues. The EditCommand class used to hold an
        EditCommandPtr to its parent, but this caused a a reference cycle in composite
        commands as the children held a ref to their parent. Now, the parent variable
        is a non-retained reference to an EditCommand *. It would be nice to have a
        weak reference to the parent or even override deref in composite commands (but I
        can't since deref() is not virtual). However, this should be OK since any
        dangling parent pointer is a sign of a bigger object lifetime problem that
        would need to be addressed anyway.

        * khtml/css/css_valueimpl.cpp:
        (CSSStyleDeclarationImpl::CSSStyleDeclarationImpl): Fix bug in constructor that takes a
        QPtrList<CSSProperty> *. List values must be copied into newly-allocated list, rather than
        just assigning the list variable passed in to the local list variable, or the list will be
        double-deleted.
        * khtml/editing/htmlediting.cpp:
        (khtml::EditCommand::setStartingSelection): No longer call get(). m_parent is no longer a smart pointer.
        (khtml::EditCommand::setEndingSelection): Ditto.
        (khtml::EditCommand::assignTypingStyle): Short-circuit if passed in style is identical to current style.
        Unrelated to the change, but saves some ref's and deref's.
        (khtml::EditCommand::setTypingStyle): No longer call get(). m_parent is no longer a smart pointer.
        * khtml/editing/htmlediting.h: Change m_parent to a EditCommand *. Was an EditCommandPtr. Using an
        EditCommandPtr caused a reference cycle in composite commands as the children held a ref to their parent.
        (khtml::EditCommand::parent): No longer call get(). m_parent is no longer a smart pointer.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
	Fixed missing retain of image property data.

        Reviewed by John.

        * WebCoreSupport.subproj/WebImageData.h:
        * WebCoreSupport.subproj/WebImageData.m:
        (-[WebImageData dealloc]):
        (-[WebImageData _invalidateImages]):
        (-[WebImageData imageAtIndex:]):
        (-[WebImageData propertiesAtIndex:]):
        (-[WebImageData _frameDuration]):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8009 268f45cc-cd09-0410-ab3c-d52691b4dbfc
	Fixed leak (3879883) that John found.  Early return leaked
	allocated instance.

        Reviewed by John.

        * khtml/css/css_computedstyle.cpp:
        (DOM::CSSComputedStyleDeclarationImpl::getPropertyCSSValue):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8010 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        Reviewed by Ken.

        - fixed <rdar://problem/3880075> leak in CSSStyleDeclarationImpl::copyPropertiesInSet,
        seen often in Mail and Blot

        * khtml/css/css_valueimpl.cpp:
        (CSSStyleDeclarationImpl::copyPropertiesInSet):
        delete temporary list after we're done using it


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8011 268f45cc-cd09-0410-ab3c-d52691b4dbfc
	Fixed: <rdar://problem/3879891> WebKit should link against PDFKit instead of Quartz

        Reviewed by darin.

        * WebKit.pbproj/project.pbxproj: link against PDFKit if it is present instead of Quartz.framework


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8014 268f45cc-cd09-0410-ab3c-d52691b4dbfc
	Fixed: <rdar://problem/3880410> save 5 dirty pages by soft-linking against PDFKit framework

        Reviewed by john.

        * WebKit.pbproj/project.pbxproj:
        * WebView.subproj/WebPDFRepresentation.m:
        (+[WebPDFRepresentation PDFDocumentClass]): new
        (-[WebPDFRepresentation finishedLoadingWithDataSource:]): use PDFDocumentClass
        * WebView.subproj/WebPDFView.h:
        * WebView.subproj/WebPDFView.m:
        (+[WebPDFView PDFKitBundle]): new
        (+[WebPDFView PDFViewClass]): new
        (-[WebPDFView initWithFrame:]): create a PDFView subview
        (-[WebPDFView dealloc]): release the PDFView subview
        (-[WebPDFView PDFSubview]): new


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8015 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        Reviewed by Ken.

        - fixed <rdar://problem/3878489> REGRESSION: modifying attribute of <textarea> blows away edited text (breaks simplemachines.org forum)

        * khtml/xml/dom_nodeimpl.h: Added boolean "children changed" parameter to
        dispatchSubtreeModifiedEvent, so it can be called in cases where only the
        node's attributes changed without sending a misleading childrenChanged call,
        but the childrenChanged call can happen at the exact right moment.
        * khtml/xml/dom_nodeimpl.cpp: Removed some uneeded "DOM::".
        (NodeImpl::dispatchSubtreeModifiedEvent): Only call "children changed" if
        the boolean true is passed in.

        * khtml/xml/dom_elementimpl.cpp:
        (NamedAttrMapImpl::addAttribute): Pass false for "children changed".
        (NamedAttrMapImpl::removeAttribute): Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8016 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        Reviewed by Ken.

        Use separate mutable style and computed style types as appropriate.
        For now this should have no effect, but it prepares us for refactoring later.
        Also remove some unnecessary "DOM::" prefixes and in one case factor out
        some shared code.

        * khtml/khtml_part.cpp:
        (KHTMLPart::typingStyle):
        (KHTMLPart::setTypingStyle):
        (updateState):
        (KHTMLPart::selectionHasStyle):
        (KHTMLPart::selectionStartHasStyle):
        (KHTMLPart::selectionComputedStyle):
        * khtml/khtml_part.h:
        * khtml/khtmlpart_p.h:

        * khtml/css/css_base.h:
        * khtml/css/css_ruleimpl.cpp:
        (CSSStyleRuleImpl::setDeclaration):
        * khtml/css/css_ruleimpl.h:
        (DOM::CSSFontFaceRuleImpl::style):
        (DOM::CSSPageRuleImpl::style):
        (DOM::CSSStyleRuleImpl::style):
        (DOM::CSSStyleRuleImpl::declaration):
        * khtml/css/css_valueimpl.h:
        (DOM::CSSPrimitiveValueImpl::):
        * khtml/css/cssparser.cpp:
        (CSSParser::parseValue):
        (CSSParser::parseColor):
        (CSSParser::parseDeclaration):
        (CSSParser::createStyleDeclaration):
        * khtml/css/cssparser.h:
        * khtml/css/cssstyleselector.cpp:
        (khtml::CSSStyleSelector::addMatchedDeclaration):
        (khtml::CSSStyleSelector::matchRulesForList):
        (khtml::CSSStyleSelector::styleForElement):
        (khtml::CSSStyleSelector::applyDeclarations):
        * khtml/css/cssstyleselector.h:
        * khtml/css/parser.cpp:
        * khtml/css/parser.y:
        * khtml/dom/css_rule.h:
        * khtml/dom/css_stylesheet.h:
        * khtml/dom/css_value.h:
        * khtml/dom/dom2_views.cpp:
        * khtml/xml/dom2_viewsimpl.cpp:
        (DOM::AbstractViewImpl::getComputedStyle):
        * khtml/xml/dom_docimpl.cpp:
        (DocumentImpl::importNode):
        (DocumentImpl::setStyleSheet):
        * khtml/xml/dom_docimpl.h:
        * khtml/xml/dom_xmlimpl.cpp:
        (DOM::ProcessingInstructionImpl::setStyleSheet):
        * khtml/xml/dom_xmlimpl.h:

        * khtml/dom/css_value.cpp:
        (DOM::throwException): Added.
        (DOM::CSSStyleDeclaration::setCssText): Call throwException, but always on 0 for now.
        The real thing is coming with the next change to refactor.
        (DOM::CSSPrimitiveValue::setFloatValue): Call throwException.
        (DOM::CSSPrimitiveValue::setStringValue): Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8017 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        Reviewed by Ken.

        - fixed <rdar://problem/3880036> Many leaks from CSSComputedStyleDeclarationImpl::getPropertyCSSValue, seen in Mail and Blot

        * khtml/css/css_computedstyle.cpp:
        (DOM::CSSComputedStyleDeclarationImpl::getPropertyValue): Ref and deref the value returned from getPropertyCSSValue,
        since there's no guarantee it's already ref'd.
        * khtml/css/css_valueimpl.cpp:
        (CSSStyleDeclarationImpl::getPropertyValue): Wrap result in a CSSValue to ref/deref.
        (CSSStyleDeclarationImpl::get4Values): Ref/deref explicitly.
        (CSSStyleDeclarationImpl::getShortHandValue): Ditto.
        (CSSStyleDeclarationImpl::merge): Ditto.
        (CSSStyleDeclarationImpl::diff): Ditto.
        * khtml/editing/htmlediting.cpp:
        (khtml::StyleChange::currentlyHasStyle): Ditto.
        (khtml::ApplyStyleCommand::removeCSSStyle): Ditto.
        * khtml/html/html_baseimpl.cpp: (HTMLBodyElementImpl::parseHTMLAttribute): Ditto.
        * khtml/html/html_tableimpl.cpp: (HTMLTableElementImpl::parseHTMLAttribute): Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        Fixed <rdar://problem/3880561> Default string value of ObjC object in JS should be [obj description].

        Reviewed by Hyatt.

        * bindings/objc/objc_instance.mm:
        (ObjcInstance::stringValue):
        * bindings/objc/objc_utility.h:
        * bindings/objc/objc_utility.mm:
        (KJS::Bindings::convertNSStringToString):
        (KJS::Bindings::convertObjcValueToValue):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8019 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        Reviewed by Chris and Darin.

        <rdar://problem/3880304> Non-linear performance hit for style changes

        * khtml/xml/dom_nodeimpl.cpp:
        (NodeImpl::traverseNextNode):
        (NodeImpl::traverseNextSibling):
        (NodeImpl::traversePreviousNodePostOrder):
        Return 0 rather than traversing beyond stayWithin when this == stayWithin.
        Add asserts that stayWithin is an ancestor of the returned node.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8020 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        Reviewed by John

        It is unwise to use the QPtrList autodelete feature on shared objects like DOM nodes.
        Instead, I replaced this with a helper function that derefs DOM nodes stored in a
        QPtrList when the list goes out of scope.

        * khtml/editing/htmlediting.cpp:
        (khtml::derefNodesInList): New helper to deref DOM nodes stored in a QPtrList.
        (khtml::InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand): No longer set lists to autodelete.
        (khtml::InsertParagraphSeparatorCommand::~InsertParagraphSeparatorCommand): Call new derefNodesInList helper.
        (khtml::InsertParagraphSeparatorInQuotedContentCommand::InsertParagraphSeparatorInQuotedContentCommand):
        No longer set lists to autodelete.
        (khtml::InsertParagraphSeparatorInQuotedContentCommand::~InsertParagraphSeparatorInQuotedContentCommand):
         Call new derefNodesInList helper.
        * khtml/editing/htmlediting.h: Add virtual destructor for InsertParagraphSeparatorCommand. It had no need
        of one before, but now it does.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8021 268f45cc-cd09-0410-ab3c-d52691b4dbfc
        Reviewed by Richard.

        - fixed <rdar://problem/3881929> 32 byte leak in editingStyle() in KHTMLPart (one-time only)

        * khtml/khtml_part.cpp:
        (editingStyle):
        delete the list we created when we're done with it


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@8025 268f45cc-cd09-0410-ab3c-d52691b4dbfc