ChildNodeList should not be LiveNodeList
https://bugs.webkit.org/show_bug.cgi?id=123708

Reviewed by Sam Weinig.

ChildNodeList is a poor fit to be a LiveNodeList. It is heavily special-cased. It is also
the only subtype that returns non-Elements thus preventing tightening.

* bindings/js/JSNodeListCustom.cpp:
(WebCore::JSNodeListOwner::isReachableFromOpaqueRoots):
        
    Support new types.

* dom/ChildNodeList.cpp:
(WebCore::EmptyNodeList::~EmptyNodeList):
(WebCore::ChildNodeList::ChildNodeList):
(WebCore::ChildNodeList::~ChildNodeList):
(WebCore::ChildNodeList::length):
(WebCore::childFromFirst):
(WebCore::childFromLast):
(WebCore::ChildNodeList::nodeBeforeCached):
(WebCore::ChildNodeList::nodeAfterCached):
(WebCore::ChildNodeList::item):
(WebCore::ChildNodeList::namedItem):
(WebCore::ChildNodeList::invalidateCache):
        
    Implement the same caching optimizations as LiveNodeList with tighter, less generic code.

* dom/ChildNodeList.h:
        
    Inherit ChildNodeList directly from NodeList.

    Add new EmptyNodeList type. This is only ever used if NodeList is requested for a non-container node.
    It allows tighter typing in ChildNodeList.

* dom/LiveNodeList.cpp:
(WebCore::LiveNodeList::namedItem):
* dom/LiveNodeList.h:
(WebCore::LiveNodeListBase::LiveNodeListBase):
(WebCore::LiveNodeListBase::~LiveNodeListBase):
(WebCore::LiveNodeList::LiveNodeList):
        
    Remove ChildNodeList specific code and branches.

* dom/Node.cpp:
(WebCore::Node::childNodes):
        
    Return EmptyNodeList for non-containers.

* dom/NodeList.h:
(WebCore::NodeList::~NodeList):
(WebCore::NodeList::isLiveNodeList):
(WebCore::NodeList::isChildNodeList):
(WebCore::NodeList::isEmptyNodeList):
        
    For isReachableFromOpaqueRoots.

* dom/NodeRareData.h:
(WebCore::NodeListsNodeData::ensureChildNodeList):
(WebCore::NodeListsNodeData::removeChildNodeList):
(WebCore::NodeListsNodeData::ensureEmptyChildNodeList):
(WebCore::NodeListsNodeData::removeEmptyChildNodeList):
(WebCore::NodeListsNodeData::NodeListsNodeData):
(WebCore::NodeListsNodeData::deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList):
        
    EmptyNodeList support.

* html/CollectionType.h:
* html/HTMLCollection.cpp:
(WebCore::shouldOnlyIncludeDirectChildren):
(WebCore::rootTypeFromCollectionType):
(WebCore::invalidationTypeExcludingIdAndNameAttributes):
(WebCore::isMatchingElement):
(WebCore::LiveNodeListBase::itemBefore):
(WebCore::LiveNodeListBase::traverseLiveNodeListFirstElement):
(WebCore::LiveNodeListBase::traverseLiveNodeListForwardToOffset):
(WebCore::LiveNodeListBase::item):
(WebCore::LiveNodeListBase::itemBeforeOrAfterCachedItem):
        
    Remove ChildNodeList specific code and branches.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158536 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Switch createContextualFragment to element iterator
https://bugs.webkit.org/show_bug.cgi?id=123704

Reviewed by Andreas Kling.

* editing/FrameSelection.cpp:
(WebCore::scanForForm):
        
    Use type helpers instead of hasTagName

* editing/markup.cpp:
(WebCore::collectElementsToRemoveFromFragment):
(WebCore::removeElementFromFragmentPreservingChildren):
(WebCore::createContextualFragment):
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::formElementIndex):
        
    Use type helpers instead of hasTagName

* html/HTMLTagNames.in:
        
    Generate type helpers for <html>.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158537 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Cocoa] Wrappers' -copyWithZone: should copy if the collection is mutable
https://bugs.webkit.org/show_bug.cgi?id=123707

Reviewed by Geoff Garen.

* Shared/Cocoa/WKNSArray.mm:
(-[WKNSArray copyWithZone:]): If the array is mutable, make a copy.
* Shared/Cocoa/WKNSDictionary.mm:
(-[WKNSDictionary copyWithZone:]): If the dictionary is mutable, make a copy.
* Shared/ImmutableArray.h:
(WebKit::ImmutableArray::entries): Added this accessor.



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