/*
 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
 * Copyright (C) 2006 James G. Speth (speth@end.com)
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

#import "DOMAbstractViewInternal.h"
#import "DOMCSSRuleInternal.h"
#import "DOMCSSRuleListInternal.h"
#import "DOMCSSStyleDeclarationInternal.h"
#import "DOMCSSValueInternal.h"
#import "DOMCounterInternal.h"
#import "DOMEventInternal.h"
#import "DOMHTMLCollectionInternal.h"
#import "DOMImplementationInternal.h"
#import "DOMInternal.h"
#import "DOMMediaListInternal.h"
#import "DOMNamedNodeMapInternal.h"
#import "DOMNodeInternal.h"
#import "DOMNodeIteratorInternal.h"
#import "DOMNodeListInternal.h"
#import "DOMRGBColorInternal.h"
#import "DOMRangeInternal.h"
#import "DOMRectInternal.h"
#import "DOMStyleSheetInternal.h"
#import "DOMStyleSheetListInternal.h"
#import "DOMTreeWalkerInternal.h"
#import "DOMXPathExpressionInternal.h"
#import "DOMXPathResultInternal.h"
#import <WebCore/JSCSSRule.h>
#import <WebCore/JSCSSRuleList.h>
#import <WebCore/JSCSSStyleDeclaration.h>
#import <WebCore/JSDOMImplementation.h>
#import <WebCore/JSDOMWindowProxy.h>
#import <WebCore/JSDeprecatedCSSOMCounter.h>
#import <WebCore/JSDeprecatedCSSOMRGBColor.h>
#import <WebCore/JSDeprecatedCSSOMRect.h>
#import <WebCore/JSDeprecatedCSSOMValue.h>
#import <WebCore/JSEvent.h>
#import <WebCore/JSHTMLCollection.h>
#import <WebCore/JSHTMLOptionsCollection.h>
#import <WebCore/JSMediaList.h>
#import <WebCore/JSNamedNodeMap.h>
#import <WebCore/JSNode.h>
#import <WebCore/JSNodeIterator.h>
#import <WebCore/JSNodeList.h>
#import <WebCore/JSRange.h>
#import <WebCore/JSStyleSheet.h>
#import <WebCore/JSStyleSheetList.h>
#import <WebCore/JSTreeWalker.h>
#import <WebCore/JSXPathExpression.h>
#import <WebCore/JSXPathResult.h>
#import <WebCore/WebScriptObjectPrivate.h>

static WebScriptObject *createDOMWrapper(JSC::JSObject& jsWrapper)
{
    JSC::VM& vm = *jsWrapper.vm();
    #define WRAP(className) \
        if (auto* wrapped = WebCore::JS##className::toWrapped(vm, &jsWrapper)) \
            return kit(wrapped);

    WRAP(CSSRule)
    WRAP(CSSRuleList)
    WRAP(CSSStyleDeclaration)
    WRAP(DeprecatedCSSOMValue)
    WRAP(DeprecatedCSSOMCounter)
    WRAP(DOMImplementation)
    WRAP(DOMWindowProxy)
    WRAP(Event)
    WRAP(HTMLOptionsCollection)
    WRAP(MediaList)
    WRAP(NamedNodeMap)
    WRAP(Node)
    WRAP(NodeIterator)
    WRAP(NodeList)
    WRAP(DeprecatedCSSOMRGBColor)
    WRAP(Range)
    WRAP(DeprecatedCSSOMRect)
    WRAP(StyleSheet)
    WRAP(StyleSheetList)
    WRAP(TreeWalker)
    WRAP(XPathExpression)
    WRAP(XPathResult)

    // This must be after HTMLOptionsCollection, because JSHTMLCollection is a base class of
    // JSHTMLOptionsCollection, and HTMLCollection is *not* a base class of HTMLOptionsCollection.
    WRAP(HTMLCollection)

    #undef WRAP

    return nil;
}

static void disconnectWindowWrapper(WebScriptObject *windowWrapper)
{
    ASSERT([windowWrapper isKindOfClass:[DOMAbstractView class]]);
    [(DOMAbstractView *)windowWrapper _disconnectFrame];
}

void initializeDOMWrapperHooks()
{
    WebCore::initializeDOMWrapperHooks(createDOMWrapper, disconnectWindowWrapper);
}
