Commit 79190704 authored by weinig's avatar weinig

LayoutTests:

        Reviewed by Hyatt.

        Update results for http://bugs.webkit.org/show_bug.cgi?id=13947
        Finish autogenerating the JS DOM traversal code

        * fast/dom/Window/window-properties-expected.txt:

WebCore:

        Reviewed by Hyatt.

        Patch for http://bugs.webkit.org/show_bug.cgi?id=13947
        Finish autogenerating the JS DOM traversal code

        - Completely generate JSNodeFilter.
        - Move JSNodeFilterCondition into its own file

        * DerivedSources.make:
        * WebCore.pro:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/JSNodeFilterCondition.cpp: Copied from WebCore/bindings/js/kjs_traversal.cpp.
        (WebCore::JSNodeFilterCondition::JSNodeFilterCondition):
        (WebCore::JSNodeFilterCondition::mark):
        (WebCore::JSNodeFilterCondition::acceptNode):
        * bindings/js/JSNodeFilterCondition.h: Copied from WebCore/bindings/js/kjs_traversal.h.
        * bindings/js/JSNodeFilterCustom.cpp: Added.
        (WebCore::JSNodeFilter::mark):
        (WebCore::toNodeFilter):
        * bindings/js/kjs_dom.cpp:
        * bindings/js/kjs_traversal.cpp: Removed.
        * bindings/js/kjs_traversal.h: Removed.
        * bindings/js/kjs_window.cpp:
        * bindings/objc/DOM.mm:
        (-[DOMDocument createNodeIterator:whatToShow:filter:expandEntityReferences:]):
        (-[DOMDocument createTreeWalker:whatToShow:filter:expandEntityReferences:]):
        * bindings/scripts/CodeGeneratorJS.pm:
        * dom/Document.cpp:
        (WebCore::Document::createNodeIterator):
        (WebCore::Document::createTreeWalker):
        * dom/Document.h:
        * dom/NodeFilter.idl:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@22035 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c8c6c6d6
2007-06-06 Sam Weinig <sam@webkit.org>
Reviewed by Hyatt.
Update results for http://bugs.webkit.org/show_bug.cgi?id=13947
Finish autogenerating the JS DOM traversal code
* fast/dom/Window/window-properties-expected.txt:
2007-06-05 Anders Carlsson <andersca@apple.com>
Reviewed by Geoff.
......@@ -752,6 +752,7 @@ window.NodeFilter.prototype.SHOW_ENTITY_REFERENCE [number]
window.NodeFilter.prototype.SHOW_NOTATION [number]
window.NodeFilter.prototype.SHOW_PROCESSING_INSTRUCTION [number]
window.NodeFilter.prototype.SHOW_TEXT [number]
window.NodeFilter.prototype.acceptNode [function]
window.Notation [object NotationConstructor]
window.Notation.prototype [printed above as window.Node.prototype]
window.Option [object Object]
......
2007-06-06 Sam Weinig <sam@webkit.org>
Reviewed by Hyatt.
Patch for http://bugs.webkit.org/show_bug.cgi?id=13947
Finish autogenerating the JS DOM traversal code
- Completely generate JSNodeFilter.
- Move JSNodeFilterCondition into its own file
* DerivedSources.make:
* WebCore.pro:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSNodeFilterCondition.cpp: Copied from WebCore/bindings/js/kjs_traversal.cpp.
(WebCore::JSNodeFilterCondition::JSNodeFilterCondition):
(WebCore::JSNodeFilterCondition::mark):
(WebCore::JSNodeFilterCondition::acceptNode):
* bindings/js/JSNodeFilterCondition.h: Copied from WebCore/bindings/js/kjs_traversal.h.
* bindings/js/JSNodeFilterCustom.cpp: Added.
(WebCore::JSNodeFilter::mark):
(WebCore::toNodeFilter):
* bindings/js/kjs_dom.cpp:
* bindings/js/kjs_traversal.cpp: Removed.
* bindings/js/kjs_traversal.h: Removed.
* bindings/js/kjs_window.cpp:
* bindings/objc/DOM.mm:
(-[DOMDocument createNodeIterator:whatToShow:filter:expandEntityReferences:]):
(-[DOMDocument createTreeWalker:whatToShow:filter:expandEntityReferences:]):
* bindings/scripts/CodeGeneratorJS.pm:
* dom/Document.cpp:
(WebCore::Document::createNodeIterator):
(WebCore::Document::createTreeWalker):
* dom/Document.h:
* dom/NodeFilter.idl:
2007-06-06 Alp Toker <alp.toker@collabora.co.uk>
Reviewed by Eric Seidel.
......@@ -549,7 +549,6 @@ all : \
kjs_events.lut.h \
kjs_html.lut.h \
kjs_navigator.lut.h \
kjs_traversal.lut.h \
kjs_window.lut.h \
ksvgcssproperties.h \
ksvgcssvalues.h \
......
......@@ -143,7 +143,6 @@ LUT_FILES += \
bindings/js/kjs_events.cpp \
bindings/js/kjs_html.cpp \
bindings/js/kjs_navigator.cpp \
bindings/js/kjs_traversal.cpp \
bindings/js/kjs_window.cpp
LUT_TABLE_FILES += \
......@@ -282,6 +281,8 @@ SOURCES += \
bindings/js/JSHTMLOptionElementConstructor.cpp \
bindings/js/JSHTMLOptionsCollectionCustom.cpp \
bindings/js/JSHTMLSelectElementCustom.cpp \
bindings/js/JSNodeFilterCondition.cpp \
bindings/js/JSNodeFilterCustom.cpp \
bindings/js/JSNodeIteratorCustom.cpp \
bindings/js/JSStyleSheetCustom.cpp \
bindings/js/JSTreeWalkerCustom.cpp \
......@@ -294,7 +295,6 @@ SOURCES += \
bindings/js/kjs_html.cpp \
bindings/js/kjs_navigator.cpp \
bindings/js/kjs_proxy.cpp \
bindings/js/kjs_traversal.cpp \
bindings/js/kjs_window.cpp \
css/CSSBorderImageValue.cpp \
css/CSSCharsetRule.cpp \
......
......@@ -1539,8 +1539,6 @@
93B70D6E09EB0C7C009D8468 /* kjs_navigator.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D5209EB0C7C009D8468 /* kjs_navigator.h */; };
93B70D6F09EB0C7C009D8468 /* kjs_proxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B70D5309EB0C7C009D8468 /* kjs_proxy.cpp */; };
93B70D7009EB0C7C009D8468 /* kjs_proxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D5409EB0C7C009D8468 /* kjs_proxy.h */; settings = {ATTRIBUTES = (Private, ); }; };
93B70D7109EB0C7C009D8468 /* kjs_traversal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B70D5509EB0C7C009D8468 /* kjs_traversal.cpp */; };
93B70D7209EB0C7C009D8468 /* kjs_traversal.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D5609EB0C7C009D8468 /* kjs_traversal.h */; };
93B70D7509EB0C7C009D8468 /* kjs_window.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B70D5909EB0C7C009D8468 /* kjs_window.cpp */; };
93B70D7609EB0C7C009D8468 /* kjs_window.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D5A09EB0C7C009D8468 /* kjs_window.h */; };
93B77A380ADD792500EA4B81 /* FrameLoaderTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B77A370ADD792500EA4B81 /* FrameLoaderTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -2846,6 +2844,9 @@
BCB16C2D0979C3BD00467741 /* loader.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB16C140979C3BD00467741 /* loader.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCB16C2E0979C3BD00467741 /* Request.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB16C150979C3BD00467741 /* Request.cpp */; };
BCB16C2F0979C3BD00467741 /* Request.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB16C160979C3BD00467741 /* Request.h */; };
BCB773610C17853D00132BA4 /* JSNodeFilterCondition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB7735E0C17853D00132BA4 /* JSNodeFilterCondition.cpp */; };
BCB773620C17853D00132BA4 /* JSNodeFilterCondition.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB7735F0C17853D00132BA4 /* JSNodeFilterCondition.h */; };
BCB773630C17853D00132BA4 /* JSNodeFilterCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB773600C17853D00132BA4 /* JSNodeFilterCustom.cpp */; };
BCC088860A1BD78D006189A6 /* FontDataMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCC088850A1BD78D006189A6 /* FontDataMac.mm */; };
BCC0891A0A1C4652006189A6 /* FontData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCC089190A1C4652006189A6 /* FontData.cpp */; };
BCC0892A0A1C4991006189A6 /* GlyphWidthMap.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC089290A1C4991006189A6 /* GlyphWidthMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -4706,8 +4707,6 @@
93B70D5209EB0C7C009D8468 /* kjs_navigator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_navigator.h; sourceTree = "<group>"; };
93B70D5309EB0C7C009D8468 /* kjs_proxy.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = kjs_proxy.cpp; sourceTree = "<group>"; };
93B70D5409EB0C7C009D8468 /* kjs_proxy.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_proxy.h; sourceTree = "<group>"; };
93B70D5509EB0C7C009D8468 /* kjs_traversal.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = kjs_traversal.cpp; sourceTree = "<group>"; };
93B70D5609EB0C7C009D8468 /* kjs_traversal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_traversal.h; sourceTree = "<group>"; };
93B70D5909EB0C7C009D8468 /* kjs_window.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = kjs_window.cpp; sourceTree = "<group>"; };
93B70D5A09EB0C7C009D8468 /* kjs_window.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_window.h; sourceTree = "<group>"; };
93B77A370ADD792500EA4B81 /* FrameLoaderTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FrameLoaderTypes.h; sourceTree = "<group>"; };
......@@ -6121,6 +6120,9 @@
BCB16C140979C3BD00467741 /* loader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = loader.h; sourceTree = "<group>"; };
BCB16C150979C3BD00467741 /* Request.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Request.cpp; sourceTree = "<group>"; };
BCB16C160979C3BD00467741 /* Request.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Request.h; sourceTree = "<group>"; };
BCB7735E0C17853D00132BA4 /* JSNodeFilterCondition.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeFilterCondition.cpp; sourceTree = "<group>"; };
BCB7735F0C17853D00132BA4 /* JSNodeFilterCondition.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSNodeFilterCondition.h; sourceTree = "<group>"; };
BCB773600C17853D00132BA4 /* JSNodeFilterCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeFilterCustom.cpp; sourceTree = "<group>"; };
BCC088850A1BD78D006189A6 /* FontDataMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FontDataMac.mm; sourceTree = "<group>"; };
BCC089190A1C4652006189A6 /* FontData.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FontData.cpp; sourceTree = "<group>"; };
BCC089290A1C4991006189A6 /* GlyphWidthMap.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GlyphWidthMap.h; sourceTree = "<group>"; };
......@@ -9188,8 +9190,6 @@
93B70D5209EB0C7C009D8468 /* kjs_navigator.h */,
93B70D5309EB0C7C009D8468 /* kjs_proxy.cpp */,
93B70D5409EB0C7C009D8468 /* kjs_proxy.h */,
93B70D5509EB0C7C009D8468 /* kjs_traversal.cpp */,
93B70D5609EB0C7C009D8468 /* kjs_traversal.h */,
93B70D5909EB0C7C009D8468 /* kjs_window.cpp */,
93B70D5A09EB0C7C009D8468 /* kjs_window.h */,
);
......@@ -9256,6 +9256,9 @@
448AD27A0A4813790023D179 /* JSHTMLOptionsCollectionCustom.cpp */,
BC17F9650B64EBB8004A65CB /* JSHTMLSelectElementCustom.cpp */,
AB4CB4EA0B8BDA3D009F40B0 /* JSHTMLSelectElementCustom.h */,
BCB7735E0C17853D00132BA4 /* JSNodeFilterCondition.cpp */,
BCB7735F0C17853D00132BA4 /* JSNodeFilterCondition.h */,
BCB773600C17853D00132BA4 /* JSNodeFilterCustom.cpp */,
1A750DD30A90E729000FF215 /* JSNodeIteratorCustom.cpp */,
BC98A27C0C0C9950004BEBF7 /* JSStyleSheetCustom.cpp */,
B25DFAAE0B2E2929000E6510 /* JSSVGMatrixCustom.cpp */,
......@@ -10403,7 +10406,6 @@
93B70D6C09EB0C7C009D8468 /* kjs_html.h in Headers */,
93B70D6E09EB0C7C009D8468 /* kjs_navigator.h in Headers */,
93B70D7009EB0C7C009D8468 /* kjs_proxy.h in Headers */,
93B70D7209EB0C7C009D8468 /* kjs_traversal.h in Headers */,
93B70D7609EB0C7C009D8468 /* kjs_window.h in Headers */,
1403B99709EB13AF00797C7F /* DOMWindow.h in Headers */,
1403BA0F09EB18F900797C7F /* JSDOMWindow.h in Headers */,
......@@ -11496,6 +11498,7 @@
BC46C2030C0DDC8F0020CFC3 /* JSCSSPageRule.h in Headers */,
BC46C2070C0DDCA10020CFC3 /* JSCSSStyleRule.h in Headers */,
BCC5BE010C0E93110011C2DB /* JSCSSStyleSheet.h in Headers */,
BCB773620C17853D00132BA4 /* JSNodeFilterCondition.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -11533,7 +11536,6 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
knownRegions = (
English,
......@@ -11548,7 +11550,6 @@
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
projectRoot = "";
shouldCheckCompatibility = 1;
targets = (
93F198A508245E59001E9ABC /* WebCore */,
DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
......@@ -12026,7 +12027,6 @@
93B70D6B09EB0C7C009D8468 /* kjs_html.cpp in Sources */,
93B70D6D09EB0C7C009D8468 /* kjs_navigator.cpp in Sources */,
93B70D6F09EB0C7C009D8468 /* kjs_proxy.cpp in Sources */,
93B70D7109EB0C7C009D8468 /* kjs_traversal.cpp in Sources */,
93B70D7509EB0C7C009D8468 /* kjs_window.cpp in Sources */,
1403B99809EB13AF00797C7F /* DOMWindow.cpp in Sources */,
1403BA0C09EB18C700797C7F /* JSDOMWindow.cpp in Sources */,
......@@ -12909,6 +12909,8 @@
BC46C2060C0DDCA10020CFC3 /* JSCSSStyleRule.cpp in Sources */,
BC20FB7F0C0E8E6C00D1447F /* JSCSSValueCustom.cpp in Sources */,
BCC5BE000C0E93110011C2DB /* JSCSSStyleSheet.cpp in Sources */,
BCB773610C17853D00132BA4 /* JSNodeFilterCondition.cpp in Sources */,
BCB773630C17853D00132BA4 /* JSNodeFilterCustom.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/*
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "JSNodeFilterCondition.h"
#include "Document.h"
#include "Frame.h"
#include "JSNodeFilter.h"
#include "NodeFilter.h"
#include "kjs_proxy.h"
namespace WebCore {
JSNodeFilterCondition::JSNodeFilterCondition(KJS::JSObject* filter)
: m_filter(filter)
{
}
void JSNodeFilterCondition::mark()
{
m_filter->mark();
}
short JSNodeFilterCondition::acceptNode(Node* filterNode) const
{
Node* node = filterNode;
Frame* frame = node->document()->frame();
KJSProxy* proxy = frame->scriptProxy();
if (proxy && m_filter->implementsCall()) {
KJS::JSLock lock;
KJS::ExecState* exec = proxy->interpreter()->globalExec();
KJS::List args;
args.append(KJS::toJS(exec, node));
KJS::JSObject* obj = m_filter;
KJS::JSValue* result = obj->call(exec, obj, args);
return result->toInt32(exec);
}
return NodeFilter::FILTER_REJECT;
}
} // namespace WebCore
// -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -18,46 +17,26 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef kjs_traversal_h
#define kjs_traversal_h
#ifndef JSNodeFilterCondition_h
#define JSNodeFilterCondition_h
#include "NodeFilter.h"
#include "NodeFilterCondition.h"
#include "kjs_dom.h"
namespace WebCore {
class NodeFilter;
}
namespace KJS {
class DOMNodeFilter : public DOMObject {
public:
DOMNodeFilter(ExecState*, WebCore::NodeFilter*);
~DOMNodeFilter();
virtual void mark();
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
WebCore::NodeFilter* impl() const { return m_impl.get(); }
enum { AcceptNode };
private:
RefPtr<WebCore::NodeFilter> m_impl;
};
JSValue* toJS(ExecState*, WebCore::NodeFilter*);
PassRefPtr<WebCore::NodeFilter> toNodeFilter(JSValue*); // returns 0 if value is not a DOMNodeFilter or JS function
class JSNodeFilterCondition : public WebCore::NodeFilterCondition {
public:
JSNodeFilterCondition(JSObject* filter);
virtual short acceptNode(WebCore::Node*) const;
virtual void mark();
protected:
JSObject *filter;
};
} // namespace
#endif
class Node;
class JSNodeFilterCondition : public NodeFilterCondition {
public:
JSNodeFilterCondition(KJS::JSObject* filter);
virtual short acceptNode(Node*) const;
virtual void mark();
protected:
KJS::JSObject* m_filter;
};
} // namespace WebCore
#endif // JSNodeFilterCondition_h
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* 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 COMPUTER, 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 COMPUTER, 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.
*/
#include "config.h"
#include "JSNodeFilter.h"
#include "JSNodeFilterCondition.h"
#include "NodeFilter.h"
#include "kjs_binding.h"
namespace WebCore {
void JSNodeFilter::mark()
{
impl()->mark();
DOMObject::mark();
}
NodeFilter* toNodeFilter(KJS::JSValue* val)
{
if (!val || !val->isObject())
return 0;
if (val->isObject(&JSNodeFilter::info))
return static_cast<JSNodeFilter*>(val)->impl();
KJS::JSObject* o = static_cast<KJS::JSObject*>(val);
if (o->implementsCall())
return new NodeFilter(new JSNodeFilterCondition(o));
return 0;
}
} // namespace WebCore
......@@ -60,7 +60,6 @@
#include "RenderView.h"
#include "kjs_css.h"
#include "kjs_events.h"
#include "kjs_traversal.h"
#include "kjs_window.h"
#include "xmlhttprequest.h"
......
/*
* This file is part of the KDE libraries
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "kjs_traversal.h"
#include "Document.h"
#include "Frame.h"
#include "JSNodeFilter.h"
#include "kjs_proxy.h"
#include "kjs_traversal.lut.h"
using namespace WebCore;
namespace KJS {
// -------------------------------------------------------------------------
const ClassInfo DOMNodeFilter::info = { "NodeFilter", 0, 0, 0 };
/*
@begin DOMNodeFilterPrototypeTable 1
acceptNode DOMNodeFilter::AcceptNode DontDelete|Function 0
@end
*/
KJS_DEFINE_PROTOTYPE(DOMNodeFilterPrototype)
KJS_IMPLEMENT_PROTOTYPE_FUNCTION(DOMNodeFilterPrototypeFunction)
KJS_IMPLEMENT_PROTOTYPE("DOMNodeFilter",DOMNodeFilterPrototype,DOMNodeFilterPrototypeFunction)
DOMNodeFilter::DOMNodeFilter(ExecState *exec, NodeFilter *nf)
: m_impl(nf)
{
setPrototype(DOMNodeFilterPrototype::self(exec));
}
DOMNodeFilter::~DOMNodeFilter()
{
ScriptInterpreter::forgetDOMObject(m_impl.get());
}
void DOMNodeFilter::mark()
{
m_impl->mark();
DOMObject::mark();
}
JSValue *DOMNodeFilterPrototypeFunction::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
{
if (!thisObj->inherits(&KJS::DOMNodeFilter::info))
return throwError(exec, TypeError);
NodeFilter &nodeFilter = *static_cast<DOMNodeFilter *>(thisObj)->impl();
switch (id) {
case DOMNodeFilter::AcceptNode:
return jsNumber(nodeFilter.acceptNode(toNode(args[0])));
}
return jsUndefined();
}
JSValue *toJS(ExecState* exec, NodeFilter* nf)
{
return cacheDOMObject<NodeFilter, JSNodeFilter>(exec, nf);
}
PassRefPtr<NodeFilter> toNodeFilter(JSValue* val)
{
if (!val)
return 0;
if (!val->isObject())
return 0;
if (val->isObject(&DOMNodeFilter::info))
return static_cast<DOMNodeFilter *>(val)->impl();
JSObject* o = static_cast<JSObject*>(val);
if (o->implementsCall())
return new NodeFilter(new JSNodeFilterCondition(o));
return 0;
}
// -------------------------------------------------------------------------
JSNodeFilterCondition::JSNodeFilterCondition(JSObject * _filter)
: filter( _filter )
{
}
void JSNodeFilterCondition::mark()
{
filter->mark();
}
short JSNodeFilterCondition::acceptNode(WebCore::Node* filterNode) const
{
WebCore::Node *node = filterNode;
Frame *frame = node->document()->frame();
KJSProxy *proxy = frame->scriptProxy();
if (proxy && filter->implementsCall()) {
JSLock lock;
ExecState *exec = proxy->interpreter()->globalExec();
List args;
args.append(toJS(exec, node));
JSObject *obj = filter;
JSValue *result = obj->call(exec, obj, args);
return result->toInt32(exec);
}
return NodeFilter::FILTER_REJECT;
}
} // namespace
......@@ -61,7 +61,6 @@
#include "kjs_events.h"
#include "kjs_navigator.h"
#include "kjs_proxy.h"
#include "kjs_traversal.h"
#include <wtf/MathExtras.h>
#if ENABLE(XSLT)
......
......@@ -700,7 +700,7 @@ short ObjCNodeFilterCondition::acceptNode(WebCore::Node* node) const
- (DOMNodeIterator *)createNodeIterator:(DOMNode *)root whatToShow:(unsigned)whatToShow filter:(id <DOMNodeFilter>)filter expandEntityReferences:(BOOL)expandEntityReferences
{
RefPtr<WebCore::NodeFilter> cppFilter;
WebCore::NodeFilter* cppFilter;
if (filter)
cppFilter = new WebCore::NodeFilter(new ObjCNodeFilterCondition(filter));
WebCore::ExceptionCode ec = 0;
......@@ -711,7 +711,7 @@ short ObjCNodeFilterCondition::acceptNode(WebCore::Node* node) const
- (DOMTreeWalker *)createTreeWalker:(DOMNode *)root whatToShow:(unsigned)whatToShow filter:(id <DOMNodeFilter>)filter expandEntityReferences:(BOOL)expandEntityReferences
{
RefPtr<WebCore::NodeFilter> cppFilter;
WebCore::NodeFilter* cppFilter;
if (filter)
cppFilter = new WebCore::NodeFilter(new ObjCNodeFilterCondition(filter));
WebCore::ExceptionCode ec = 0;
......
......@@ -144,7 +144,6 @@ sub GetLegacyHeaderIncludes
return "#include \"kjs_dom.h\"\n\n" if $module eq "core";
return "#include \"kjs_css.h\"\n\n" if $module eq "css";
return "#include \"kjs_html.h\"\n\n" if $module eq "html";
return "#include \"kjs_traversal.h\"\n\n" if $module eq "traversal";
die "Don't know what headers to include for module $module";
}
......@@ -1167,7 +1166,7 @@ sub GenerateImplementation
push(@implContent, "}\n");
}
if (!$hasParent || $dataNode->extendedAttributes->{"GenerateNativeConverter"}) {
if ((!$hasParent or $dataNode->extendedAttributes->{"GenerateNativeConverter"}) and !$dataNode->extendedAttributes->{"CustomNativeConverter"}) {
if ($podType) {
push(@implContent, "$podType to${interfaceName}(KJS::JSValue* val)\n");
} else {
......@@ -1245,7 +1244,6 @@ sub GetNativeType
return "bool" if $type eq "boolean";
return "int" if $type eq "long";
return "String" if $type eq "DOMString";
return "PassRefPtr<${type}>" if $type eq "NodeFilter";
return "Range::CompareHow" if $type eq "CompareHow";
return "EventTargetNode*" if $type eq "EventTarget";
return "FloatRect" if $type eq "SVGRect";
......@@ -1355,11 +1353,6 @@ sub JSValueToNative
return "toElement($value)";
}
if ($type eq "NodeFilter") {
$implIncludes{"kjs_traversal.h"} = 1;
return "toNodeFilter($value)";
}
if ($type eq "DOMWindow") {
$implIncludes{"kjs_window.h"} = 1;
return "toDOMWindow($value)";
......
......@@ -917,7 +917,7 @@ PassRefPtr<Range> Document::createRange()
}
PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatToShow,
PassRefPtr<NodeFilter> filter, bool expandEntityReferences, ExceptionCode& ec)
NodeFilter* filter, bool expandEntityReferences, ExceptionCode& ec)
{
if (!root) {
ec = NOT_SUPPORTED_ERR;
......@@ -927,7 +927,7 @@ PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT
}
PassRefPtr<TreeWalker> Document::createTreeWalker(Node *root, unsigned whatToShow,
PassRefPtr<NodeFilter> filter, bool expandEntityReferences, ExceptionCode& ec)
NodeFilter* filter, bool expandEntityReferences, ExceptionCode& ec)
{
if (!root) {
ec = NOT_SUPPORTED_ERR;
......
......@@ -308,10 +308,10 @@ public:
PassRefPtr<Range> createRange();
PassRefPtr<NodeIterator> createNodeIterator(Node* root, unsigned whatToShow,
PassRefPtr<NodeFilter>, bool expandEntityReferences, ExceptionCode&);
NodeFilter*, bool expandEntityReferences, ExceptionCode&);
PassRefPtr<TreeWalker> createTreeWalker(Node* root, unsigned whatToShow,
PassRefPtr<NodeFilter>, bool expandEntityReferences, ExceptionCode&);
NodeFilter*, bool expandEntityReferences, ExceptionCode&);
// Special support for editing
PassRefPtr<CSSStyleDeclaration> createCSSStyleDeclaration();
......
/*
* Copyright (C) 2006 Apple Computer, Inc.
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
*
* This library is free software; you can redistribute it and/or
......@@ -21,7 +21,7 @@
module traversal {
// Introduced in DOM Level 2:
interface [LegacyParent=KJS::DOMNodeFilter, GenerateConstructor, ObjCProtocol] NodeFilter {
interface [GenerateConstructor, CustomMarkFunction, CustomNativeConverter, ObjCProtocol] NodeFilter {
// Constants returned by acceptNode
const short FILTER_ACCEPT = 1;
......@@ -43,9 +43,7 @@ module traversal {
const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x00000400;
const unsigned long SHOW_NOTATION = 0x00000800;