Commit e5ae0240 authored by andersca's avatar andersca

WebCore:

2006-06-29  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Tim O.

        <rdar://problem/4599760> Objective-C XPath support
        
        * WebCore.xcodeproj/project.pbxproj:
        Add files.
        
        * bindings/objc/DOMInternal.h:
        * bindings/objc/DOMInternal.mm:
        (raiseDOMException):
        Handle XPath exceptions
        
        * bindings/objc/DOMXPath.h: Added.
        (-[DOMXPathNSResolver lookupNamespaceURI:]):
        * bindings/objc/DOMXPath.mm: Added.
        (-[DOMNativeXPathNSResolver dealloc]):
        (-[DOMNativeXPathNSResolver finalize]):
        (-[DOMNativeXPathNSResolver _xpathNSResolver]):
        (-[DOMNativeXPathNSResolver _initWithXPathNSResolver:]):
        (+[DOMNativeXPathNSResolver _xpathNSResolverWith:]):
        (-[DOMNativeXPathNSResolver lookupNamespaceURI:]):
        (-[DOMXPathResult dealloc]):
        (-[DOMXPathResult finalize]):
        (-[DOMXPathResult resultType]):
        (-[DOMXPathResult numberValue]):
        (-[DOMXPathResult stringValue]):
        (-[DOMXPathResult booleanValue]):
        (-[DOMXPathResult singleNodeValue]):
        (-[DOMXPathResult invalidIteratorState]):
        (-[DOMXPathResult snapshotLength]):
        (-[DOMXPathResult iterateNext]):
        (-[DOMXPathResult snapshotItem:]):
        (-[DOMXPathResult _xpathResult]):
        (-[DOMXPathResult _initWithXPathResult:]):
        (+[DOMXPathResult _xpathResultWith:]):
        (-[DOMXPathExpression evaluate:::]):
        (-[DOMXPathExpression _xpathExpression]):
        (-[DOMXPathExpression _initWithXPathExpression:]):
        (+[DOMXPathExpression _xpathExpressionWith:]):
        (-[DOMDocument createExpression::]):
        (-[DOMDocument createNSResolver:]):
        (-[DOMDocument evaluate:::::]):
        * bindings/objc/DOMXPathInternal.h: Added.
        Add Objective-C XPath API.

WebKit:

2006-06-29  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Tim O.

        * WebKit.xcodeproj/project.pbxproj:
        Add DOMXPath.h header.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@15091 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 06186597
2006-06-29 Anders Carlsson <acarlsson@apple.com>
Reviewed by Tim O.
<rdar://problem/4599760> Objective-C XPath support
* WebCore.xcodeproj/project.pbxproj:
Add files.
* bindings/objc/DOMInternal.h:
* bindings/objc/DOMInternal.mm:
(raiseDOMException):
Handle XPath exceptions
* bindings/objc/DOMXPath.h: Added.
(-[DOMXPathNSResolver lookupNamespaceURI:]):
* bindings/objc/DOMXPath.mm: Added.
(-[DOMNativeXPathNSResolver dealloc]):
(-[DOMNativeXPathNSResolver finalize]):
(-[DOMNativeXPathNSResolver _xpathNSResolver]):
(-[DOMNativeXPathNSResolver _initWithXPathNSResolver:]):
(+[DOMNativeXPathNSResolver _xpathNSResolverWith:]):
(-[DOMNativeXPathNSResolver lookupNamespaceURI:]):
(-[DOMXPathResult dealloc]):
(-[DOMXPathResult finalize]):
(-[DOMXPathResult resultType]):
(-[DOMXPathResult numberValue]):
(-[DOMXPathResult stringValue]):
(-[DOMXPathResult booleanValue]):
(-[DOMXPathResult singleNodeValue]):
(-[DOMXPathResult invalidIteratorState]):
(-[DOMXPathResult snapshotLength]):
(-[DOMXPathResult iterateNext]):
(-[DOMXPathResult snapshotItem:]):
(-[DOMXPathResult _xpathResult]):
(-[DOMXPathResult _initWithXPathResult:]):
(+[DOMXPathResult _xpathResultWith:]):
(-[DOMXPathExpression evaluate:::]):
(-[DOMXPathExpression _xpathExpression]):
(-[DOMXPathExpression _initWithXPathExpression:]):
(+[DOMXPathExpression _xpathExpressionWith:]):
(-[DOMDocument createExpression::]):
(-[DOMDocument createNSResolver:]):
(-[DOMDocument evaluate:::::]):
* bindings/objc/DOMXPathInternal.h: Added.
Add Objective-C XPath API.
2006-06-28 David Hyatt <hyatt@apple.com>
Add support for custom highlighting to paint at the root line box level
......
......@@ -41,6 +41,9 @@
14E8378E09F85D4F00B85AE4 /* JSEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 14E8378D09F85D4F00B85AE4 /* JSEvent.h */; };
14EC267F09CA07E000E1EEEC /* EventTargetNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 14EC267D09CA07E000E1EEEC /* EventTargetNode.h */; };
14EC268009CA07E000E1EEEC /* EventTargetNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14EC267E09CA07E000E1EEEC /* EventTargetNode.cpp */; };
1A1D13800A5325520064BF5F /* DOMXPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A1D137E0A5325520064BF5F /* DOMXPath.h */; settings = {ATTRIBUTES = (Private, ); }; };
1A1D13810A5325520064BF5F /* DOMXPath.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A1D137F0A5325520064BF5F /* DOMXPath.mm */; };
1A1D13CA0A5329090064BF5F /* DOMXPathInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A1D13C90A5329090064BF5F /* DOMXPathInternal.h */; };
1A494BFA0A122F4400FDAFC1 /* JSHTMLElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A494BF80A122F4400FDAFC1 /* JSHTMLElement.cpp */; };
1A494BFB0A122F4400FDAFC1 /* JSHTMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A494BF90A122F4400FDAFC1 /* JSHTMLElement.h */; };
1A494E340A12358B00FDAFC1 /* JSHTMLDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A494E320A12358A00FDAFC1 /* JSHTMLDocument.cpp */; };
......@@ -1569,23 +1572,6 @@
FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
/* End PBXBuildFile section */
/* Begin PBXBuildStyle section */
BCEED0480A530A0A00443D9A /* Development */ = {
isa = PBXBuildStyle;
buildSettings = {
COPY_PHASE_STRIP = NO;
};
name = Development;
};
BCEED0490A530A0A00443D9A /* Deployment */ = {
isa = PBXBuildStyle;
buildSettings = {
COPY_PHASE_STRIP = YES;
};
name = Deployment;
};
/* End PBXBuildStyle section */
/* Begin PBXContainerItemProxy section */
DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
......@@ -1628,6 +1614,9 @@
14E8378D09F85D4F00B85AE4 /* JSEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSEvent.h; sourceTree = "<group>"; };
14EC267D09CA07E000E1EEEC /* EventTargetNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventTargetNode.h; sourceTree = "<group>"; };
14EC267E09CA07E000E1EEEC /* EventTargetNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventTargetNode.cpp; sourceTree = "<group>"; };
1A1D137E0A5325520064BF5F /* DOMXPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMXPath.h; sourceTree = "<group>"; };
1A1D137F0A5325520064BF5F /* DOMXPath.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMXPath.mm; sourceTree = "<group>"; };
1A1D13C90A5329090064BF5F /* DOMXPathInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMXPathInternal.h; sourceTree = "<group>"; };
1A494BBB0A122DCD00FDAFC1 /* HTMLElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLElement.idl; sourceTree = "<group>"; };
1A494BF80A122F4400FDAFC1 /* JSHTMLElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLElement.cpp; sourceTree = "<group>"; };
1A494BF90A122F4400FDAFC1 /* JSHTMLElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLElement.h; sourceTree = "<group>"; };
......@@ -4962,6 +4951,9 @@
BC1A37AA097C715F0019F3D8 /* DOMViews.h */,
BC1A37AB097C715F0019F3D8 /* DOMViews.mm */,
BC1A37AC097C715F0019F3D8 /* DOMViewsInternal.h */,
1A1D137E0A5325520064BF5F /* DOMXPath.h */,
1A1D137F0A5325520064BF5F /* DOMXPath.mm */,
1A1D13C90A5329090064BF5F /* DOMXPathInternal.h */,
);
path = objc;
sourceTree = "<group>";
......@@ -6355,6 +6347,8 @@
DB23C2CC0A508D29002489EB /* IndentOutdentCommand.h in Headers */,
BCCD74DC0A4C8D35005FDA6D /* HTMLViewSourceDocument.h in Headers */,
1A8086CC0A4D097600DFB6A7 /* DOMCSSInternal.h in Headers */,
1A1D13800A5325520064BF5F /* DOMXPath.h in Headers */,
1A1D13CA0A5329090064BF5F /* DOMXPathInternal.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -6388,12 +6382,6 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
buildSettings = {
};
buildStyles = (
BCEED0480A530A0A00443D9A /* Development */,
BCEED0490A530A0A00443D9A /* Deployment */,
);
hasScannedForEncodings = 1;
knownRegions = (
English,
......@@ -7216,6 +7204,7 @@
BCCD74E50A4C8DDF005FDA6D /* HTMLViewSourceDocument.cpp in Sources */,
E1052C320A4D70010072D99B /* DOMEventsNonstandard.mm in Sources */,
516149ED0A525E3A003DFC7A /* SiteIcon.cpp in Sources */,
1A1D13810A5325520064BF5F /* DOMXPath.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -160,3 +160,6 @@ ALLOW_DOM_CAST(RectImpl)
ALLOW_DOM_CAST(StyleSheet)
ALLOW_DOM_CAST(StyleSheetList)
ALLOW_DOM_CAST(TreeWalker)
ALLOW_DOM_CAST(XPathExpression)
ALLOW_DOM_CAST(XPathNSResolver)
ALLOW_DOM_CAST(XPathResult)
......@@ -32,6 +32,7 @@
#import "Range.h"
#import "kjs_dom.h"
#import "kjs_proxy.h"
#import "XPathEvaluator.h"
#import <JavaScriptCore/WebScriptObjectPrivate.h>
using namespace WebCore;
......@@ -74,6 +75,7 @@ void removeDOMWrapper(DOMObjectInternal* impl)
NSString * const DOMException = @"DOMException";
NSString * const DOMRangeException = @"DOMRangeException";
NSString * const DOMEventException = @"DOMEventException";
NSString * const DOMXPathException = @"DOMXPathException";
void raiseDOMException(ExceptionCode ec)
{
......@@ -88,6 +90,9 @@ void raiseDOMException(ExceptionCode ec)
} else if (ec >= EventExceptionOffset && ec <= EventExceptionMax) {
name = DOMEventException;
code -= EventExceptionOffset;
} else if (ec >= XPathExceptionOffset && ec <= XPathExceptionMax) {
name = DOMXPathException;
code -= XPathExceptionOffset;
}
NSString *reason = [NSString stringWithFormat:@"*** Exception received from DOM API: %d", code];
......
/*
* Copyright (C) 2006 Apple Computer, 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.
*/
#import <WebCore/DOMCore.h>
extern NSString * const DOMXPathException;
enum DOMXPathExceptionCode {
DOM_INVALID_EXPRESSION_ERR = 51,
DOM_TYPE_ERR = 52
};
@protocol DOMXPathNSResolver <NSObject>
- (NSString *)lookupNamespaceURI:(NSString *)prefix;
@end
enum {
// XPath result types
DOM_ANY_TYPE = 0,
DOM_NUMBER_TYPE = 1,
DOM_STRING_TYPE = 2,
DOM_BOOLEAN_TYPE = 3,
DOM_UNORDERED_NODE_ITERATOR_TYPE = 4,
DOM_ORDERED_NODE_ITERATOR_TYPE = 5,
DOM_UNORDERED_NODE_SNAPSHOT_TYPE = 6,
DOM_ORDERED_NODE_SNAPSHOT_TYPE = 7,
DOM_ANY_UNORDERED_NODE_TYPE = 8,
DOM_FIRST_ORDERED_NODE_TYPE = 9,
};
@interface DOMXPathResult : DOMObject
- (unsigned short)resultType;
- (double)numberValue;
- (NSString *)stringValue;
- (BOOL)booleanValue;
- (DOMNode *)singleNodeValue;
- (BOOL)invalidIteratorState;
- (unsigned)snapshotLength;
- (DOMNode *)iterateNext;
- (DOMNode *)snapshotItem:(unsigned)index;
@end
@interface DOMXPathExpression : DOMObject
- (DOMXPathResult *)evaluate:(DOMNode *)contextNode :(unsigned short)type :(DOMXPathResult *)result;
@end
@interface DOMDocument (DOMDocumentXPath)
- (DOMXPathExpression *)createExpression:(NSString *)expression :(id <DOMXPathNSResolver>)resolver;
- (id <DOMXPathNSResolver>)createNSResolver:(DOMNode *)nodeResolver;
- (DOMXPathResult *)evaluate:(NSString *)expression :(DOMNode *)contextNode :(id <DOMXPathNSResolver>)resolver :(unsigned short)type :(DOMXPathResult *)result;
@end
/*
* Copyright (C) 2006 Apple Computer, 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.
*/
#import "config.h"
#import "DOMXPath.h"
#import "DOMInternal.h"
#import "DOMXPathInternal.h"
#import "Document.h"
using WebCore::ExceptionCode;
using WebCore::XPathExpression;
using WebCore::XPathNSResolver;
using WebCore::XPathResult;
@implementation DOMNativeXPathNSResolver
- (void)dealloc
{
if (_internal) {
DOM_cast<XPathNSResolver*>(_internal)->deref();
}
[super dealloc];
}
- (void)finalize
{
if (_internal) {
DOM_cast<XPathNSResolver*>(_internal)->deref();
}
[super finalize];
}
- (XPathNSResolver *)_xpathNSResolver
{
return DOM_cast<XPathNSResolver *>(_internal);
}
- (id)_initWithXPathNSResolver:(XPathNSResolver *)impl
{
ASSERT(impl);
[super _init];
_internal = DOM_cast<DOMObjectInternal *>(impl);
impl->ref();
addDOMWrapper(self, impl);
return self;
}
+ (DOMNativeXPathNSResolver *)_xpathNSResolverWith:(XPathNSResolver *)impl
{
if (!impl)
return nil;
id cachedInstance;
cachedInstance = getDOMWrapper(impl);
if (cachedInstance)
return [[cachedInstance retain] autorelease];
return [[[DOMNativeXPathNSResolver alloc] _initWithXPathNSResolver:impl] autorelease];
}
- (NSString *)lookupNamespaceURI:(NSString *)prefix
{
return [self _xpathNSResolver]->lookupNamespaceURI(prefix);
}
@end
@implementation DOMXPathResult
- (void)dealloc
{
if (_internal) {
DOM_cast<XPathResult*>(_internal)->deref();
}
[super dealloc];
}
- (void)finalize
{
if (_internal) {
DOM_cast<XPathResult*>(_internal)->deref();
}
[super finalize];
}
- (unsigned short)resultType
{
return [self _xpathResult]->resultType();
}
- (double)numberValue
{
ExceptionCode ec = 0;
double result = [self _xpathResult]->numberValue(ec);
raiseOnDOMError(ec);
return result;
}
- (NSString *)stringValue
{
ExceptionCode ec = 0;
NSString *result = [self _xpathResult]->stringValue(ec);
raiseOnDOMError(ec);
return result;
}
- (BOOL)booleanValue
{
ExceptionCode ec = 0;
BOOL result = [self _xpathResult]->booleanValue(ec);
raiseOnDOMError(ec);
return result;
}
- (DOMNode *)singleNodeValue
{
ExceptionCode ec = 0;
DOMNode *result = [DOMNode _nodeWith:[self _xpathResult]->singleNodeValue(ec)];
raiseOnDOMError(ec);
return result;
}
- (BOOL)invalidIteratorState
{
return [self _xpathResult]->invalidIteratorState();
}
- (unsigned)snapshotLength
{
ExceptionCode ec = 0;
unsigned result = [self _xpathResult]->snapshotLength(ec);
raiseOnDOMError(ec);
return result;
}
- (DOMNode *)iterateNext
{
ExceptionCode ec = 0;
DOMNode *result = [DOMNode _nodeWith:[self _xpathResult]->iterateNext(ec)];
raiseOnDOMError(ec);
return result;
}
- (DOMNode *)snapshotItem:(unsigned)index
{
ExceptionCode ec = 0;
DOMNode *result = [DOMNode _nodeWith:[self _xpathResult]->snapshotItem(index, ec)];
raiseOnDOMError(ec);
return result;
}
@end
@implementation DOMXPathResult (WebCoreInternal)
- (XPathResult *)_xpathResult
{
return DOM_cast<XPathResult *>(_internal);
}
- (id)_initWithXPathResult:(XPathResult *)impl
{
ASSERT(impl);
[super _init];
_internal = DOM_cast<DOMObjectInternal *>(impl);
impl->ref();
addDOMWrapper(self, impl);
return self;
}
+ (DOMXPathResult *)_xpathResultWith:(XPathResult *)impl
{
if (!impl)
return nil;
id cachedInstance;
cachedInstance = getDOMWrapper(impl);
if (cachedInstance)
return [[cachedInstance retain] autorelease];
return [[[DOMXPathResult alloc] _initWithXPathResult:impl] autorelease];
}
@end
@implementation DOMXPathExpression
- (void)dealloc
{
if (_internal) {
DOM_cast<XPathNSResolver*>(_internal)->deref();
}
[super dealloc];
}
- (void)finalize
{
if (_internal) {
DOM_cast<XPathNSResolver*>(_internal)->deref();
}
[super finalize];
}
- (DOMXPathResult *)evaluate:(DOMNode *)contextNode :(unsigned short)type :(DOMXPathResult *)result
{
ExceptionCode ec = 0;
DOMXPathResult *_result = [DOMXPathResult _xpathResultWith:[self _xpathExpression]->evaluate([contextNode _node], type, [result _xpathResult], ec).get()];
raiseOnDOMError(ec);
return _result;
}
@end
@implementation DOMXPathExpression (WebCoreInternal)
- (XPathExpression *)_xpathExpression
{
return DOM_cast<XPathExpression *>(_internal);
}
- (id)_initWithXPathExpression:(XPathExpression *)impl
{
ASSERT(impl);
[super _init];
_internal = DOM_cast<DOMObjectInternal *>(impl);
impl->ref();
addDOMWrapper(self, impl);
return self;
}
+ (DOMXPathExpression *)_xpathExpressionWith:(XPathExpression *)impl
{
if (!impl)
return nil;
id cachedInstance;
cachedInstance = getDOMWrapper(impl);
if (cachedInstance)
return [[cachedInstance retain] autorelease];
return [[[DOMXPathExpression alloc] _initWithXPathExpression:impl] autorelease];
}
@end
@implementation DOMDocument (DOMDocumentXPath)
- (DOMXPathExpression *)createExpression:(NSString *)expression :(id <DOMXPathNSResolver>)resolver
{
if (resolver && ![resolver isMemberOfClass:[DOMNativeXPathNSResolver class]])
[NSException raise:NSGenericException format:@"createExpression currently does not work with custom NS resolvers"];
DOMNativeXPathNSResolver *nativeResolver = (DOMNativeXPathNSResolver *)resolver;
ExceptionCode ec = 0;
DOMXPathExpression *result = [DOMXPathExpression _xpathExpressionWith:[self _document]->createExpression(expression, [nativeResolver _xpathNSResolver], ec).get()];
raiseOnDOMError(ec);
return result;
}
- (id <DOMXPathNSResolver>)createNSResolver:(DOMNode *)nodeResolver
{
return [DOMNativeXPathNSResolver _xpathNSResolverWith:[self _document]->createNSResolver([nodeResolver _node]).get()];
}
- (DOMXPathResult *)evaluate:(NSString *)expression :(DOMNode *)contextNode :(id <DOMXPathNSResolver>)resolver :(unsigned short)type :(DOMXPathResult *)result
{
if (resolver && ![resolver isMemberOfClass:[DOMNativeXPathNSResolver class]])
[NSException raise:NSGenericException format:@"createExpression currently does not work with custom NS resolvers"];
DOMNativeXPathNSResolver *nativeResolver = (DOMNativeXPathNSResolver *)resolver;
ExceptionCode ec = 0;
DOMXPathResult *_result = [DOMXPathResult _xpathResultWith:[self _document]->evaluate(expression, [contextNode _node], [nativeResolver _xpathNSResolver], type, [result _xpathResult], ec).get()];
raiseOnDOMError(ec);
return _result;
}
@end
/*
* Copyright (C) 2006 Apple Computer, 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.
*/
#import "DOMXPath.h"
#import "XPathExpression.h"
#import "XPathNSResolver.h"
#import "XPathResult.h"
@interface DOMXPathResult (WebCoreInternal)
+ (DOMXPathResult *)_xpathResultWith:(WebCore::XPathResult *)impl;
- (WebCore::XPathResult *)_xpathResult;
@end
@interface DOMXPathExpression (WebCoreInternal)
+ (DOMXPathExpression *)_xpathExpressionWith:(WebCore::XPathExpression *)impl;
- (WebCore::XPathExpression *)_xpathExpression;
@end
@interface DOMNativeXPathNSResolver : DOMObject <DOMXPathNSResolver>
+ (DOMNativeXPathNSResolver *)_xpathNSResolverWith:(WebCore::XPathNSResolver *)impl;
- (WebCore::XPathNSResolver *)_xpathNSResolver;
@end
2006-06-29 Anders Carlsson <acarlsson@apple.com>
Reviewed by Tim O.
* WebKit.xcodeproj/project.pbxproj:
Add DOMXPath.h header.
2006-06-28 David Hyatt <hyatt@apple.com>
Fix custom highlighting so that you can paint the entire line (and go
......
......@@ -1219,6 +1219,7 @@
93AF529B08254D62005D0156 /* DOMStylesheets.h */,
93AF52CE08254E18005D0156 /* DOMTraversal.h */,
93AF52D808254E31005D0156 /* DOMViews.h */,
1A1D16590A5351520064BF5F /* DOMXPath.h */,
939811300824BF01008DF038 /* Frameworks (symlink) */,
933932420825A64800AADA6B /* npapi.h */,
9339323E0825A64200AADA6B /* npruntime.h */,
......@@ -1290,6 +1291,22 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
1A1D16590A5351520064BF5F /* DOMXPath.h */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"$(WEBCORE_PRIVATE_HEADERS_DIR)/DOMXPath.h",
);
name = DOMXPath.h;
outputPaths = (
"$(TARGET_BUILD_DIR)/$(PRIVATE_HEADERS_FOLDER_PATH)/DOMXPath.h",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "mkdir -p \"$TARGET_BUILD_DIR/$PRIVATE_HEADERS_FOLDER_PATH\"\nsed -e s/WebCore/WebKit/ \"$WEBCORE_PRIVATE_HEADERS_DIR/DOMXpath.h\" > \"$TARGET_BUILD_DIR/$PRIVATE_HEADERS_FOLDER_PATH/DOMXPath.h\"";
};
9339323E0825A64200AADA6B /* npruntime.h */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment